kontexta 7.4.3 → 8.0.0
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/bundle/standalone/CHANGELOG.md +14 -0
- package/bundle/standalone/apps/web/.next/BUILD_ID +1 -1
- package/bundle/standalone/apps/web/.next/app-build-manifest.json +189 -180
- package/bundle/standalone/apps/web/.next/app-path-routes-manifest.json +10 -9
- package/bundle/standalone/apps/web/.next/build-manifest.json +5 -5
- package/bundle/standalone/apps/web/.next/prerender-manifest.json +3 -3
- package/bundle/standalone/apps/web/.next/react-loadable-manifest.json +5 -5
- package/bundle/standalone/apps/web/.next/routes-manifest.json +8 -0
- package/bundle/standalone/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/_not-found.html +1 -1
- package/bundle/standalone/apps/web/.next/server/app/_not-found.rsc +5 -4
- package/bundle/standalone/apps/web/.next/server/app/api/about/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/hooks/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/mcp/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/setup/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/token/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/brain/machines/[machineId]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/brain/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/brain/share/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/conflicts/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/ics/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/links/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/settings/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/clip/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/conflicts/[gid]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/conflicts/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/docker-config/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/export/zip/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/backlinks/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/download/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-html/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-pdf/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/diff/route.js +1 -0
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/diff/route.js.nft.json +1 -0
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/diff/route_client-reference-manifest.js +1 -0
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/restore/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/move/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/upload/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/folders/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/graph/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/hands/test-pattern/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/hands/validate/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/hygiene/resolve/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/hygiene/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/install-snippets/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/mcp-tools/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/profile/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/hands-config/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-config/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-status/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/onboard/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/refresh/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/onboard/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/publish/html/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/publish/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/refresh/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/reindex/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/reports/resources/[name]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/search/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/version-check/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/welcome/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/ws-config/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/brain/page.js +2 -2
- package/bundle/standalone/apps/web/.next/server/app/brain/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/brain/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/calendar/page.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/calendar/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/calendar/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/conflicts/page.js +2 -2
- package/bundle/standalone/apps/web/.next/server/app/conflicts/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/conflicts/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/graph/page.js +2 -2
- package/bundle/standalone/apps/web/.next/server/app/graph/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/graph/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/hygiene/page.js +6 -6
- package/bundle/standalone/apps/web/.next/server/app/hygiene/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/hygiene/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/login/page.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/login/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/page.js +6 -6
- package/bundle/standalone/apps/web/.next/server/app/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/preview/motifs/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/preview/motifs.html +2 -2
- package/bundle/standalone/apps/web/.next/server/app/preview/motifs.rsc +25 -23
- package/bundle/standalone/apps/web/.next/server/app-paths-manifest.json +10 -9
- package/bundle/standalone/apps/web/.next/server/chunks/{8671.js → 4674.js} +1 -1
- package/bundle/standalone/apps/web/.next/server/chunks/4978.js +1 -0
- package/bundle/standalone/apps/web/.next/server/chunks/6910.js +1 -0
- package/bundle/standalone/apps/web/.next/server/chunks/8485.js +1 -0
- package/bundle/standalone/apps/web/.next/server/middleware-build-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/pages/404.html +1 -1
- package/bundle/standalone/apps/web/.next/server/pages/500.html +1 -1
- package/bundle/standalone/apps/web/.next/server/server-reference-manifest.json +1 -1
- package/bundle/standalone/apps/web/.next/static/chunks/1130.c3ba70728796955d.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/1293-4bba2e7cc2ea452b.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/{4758-d1a82f1ccab8aa16.js → 1514-a775f6757941e7d5.js} +1 -1
- package/bundle/standalone/apps/web/.next/static/chunks/4283.edea07cef5bde1ad.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/4473-16d270c408eb35cc.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/807.a2f62f79be9478d7.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/8439-20334d6f23c9608e.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/{9699.8e15c2b743d792a3.js → 9699.3cbe1b534e6d60b6.js} +1 -1
- package/bundle/standalone/apps/web/.next/static/chunks/9807-d7e6925db821481e.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/about/{route-04da9ec2ec835204.js → route-5f1cd3b80296b4e0.js} +1 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/agents/[id]/hooks/{route-04da9ec2ec835204.js → route-5f1cd3b80296b4e0.js} +1 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/agents/[id]/mcp/{route-04da9ec2ec835204.js → route-5f1cd3b80296b4e0.js} +1 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/agents/[id]/{route-04da9ec2ec835204.js → route-5f1cd3b80296b4e0.js} +1 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/agents/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/login/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/logout/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/setup/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/status/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/token/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/brain/machines/[machineId]/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/brain/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/brain/share/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/conflicts/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/entities/[id]/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/entities/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/events/[id]/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/events/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/ics/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/links/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/settings/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/clip/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/conflicts/[gid]/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/conflicts/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/docker-config/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/export/zip/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/backlinks/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/download/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/export-html/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/export-pdf/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/history/diff/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/history/restore/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/history/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/move/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/upload/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/folders/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/graph/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/hands/test-pattern/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/hands/validate/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/health/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/hygiene/resolve/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/hygiene/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/install-snippets/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/mcp-tools/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/profile/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/hands-config/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/journal-config/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/journal-status/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/onboard/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/refresh/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/onboard/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/publish/html/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/publish/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/refresh/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/reindex/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/reports/resources/[name]/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/search/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/tags/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/version-check/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/welcome/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/ws-config/route-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/brain/page-d8dd3aa559f8c446.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/calendar/page-32e0a1099c2ea003.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/conflicts/page-7db91010184bea8c.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/graph/page-0a7e70cae2e08c53.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/hygiene/page-5459f3659546ede0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/layout-6a78849b3891e1fe.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/login/page-32b526e8c76c7c39.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/page-4b24e4bc6e356c15.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/app/preview/motifs/page-5f1cd3b80296b4e0.js +1 -0
- package/bundle/standalone/apps/web/.next/static/chunks/{webpack-357e2269171845c0.js → webpack-cd92fca72525c167.js} +1 -1
- package/bundle/standalone/apps/web/.next/static/css/dc420d235ed07713.css +3 -0
- package/bundle/standalone/apps/web/.next/static/css/e0baf4e6c17b91dc.css +1 -0
- package/bundle/standalone/apps/web/package.json +4 -4
- package/bundle/standalone/node_modules/kontexta-mcp/package.json +1 -1
- package/bundle/standalone/node_modules/kxta-core/package.json +1 -1
- package/bundle/standalone/node_modules/kxta-publish/package.json +2 -2
- package/bundle/standalone/package.json +1 -1
- package/package.json +1 -1
- package/bundle/standalone/apps/web/.next/server/chunks/3645.js +0 -1
- package/bundle/standalone/apps/web/.next/server/chunks/7887.js +0 -1
- package/bundle/standalone/apps/web/.next/server/chunks/8948.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/2449-eb3c50eadeb2dfe2.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/3518.5a080b5b9172e9ab.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/3617-ed93ee6af5ece2f3.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/4283.524bc904dbdd2417.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/807.5bf32ba308aae89a.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/8362-ac3bfd52a83684a1.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/agents/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/login/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/logout/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/setup/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/status/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/token/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/brain/machines/[machineId]/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/brain/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/brain/share/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/conflicts/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/entities/[id]/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/entities/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/events/[id]/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/events/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/ics/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/links/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/settings/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/clip/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/conflicts/[gid]/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/conflicts/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/docker-config/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/export/zip/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/backlinks/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/download/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/export-html/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/export-pdf/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/history/restore/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/history/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/move/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/upload/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/folders/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/graph/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/hands/test-pattern/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/hands/validate/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/health/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/hygiene/resolve/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/hygiene/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/install-snippets/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/mcp-tools/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/profile/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/hands-config/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/journal-config/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/journal-status/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/onboard/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/refresh/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/onboard/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/publish/html/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/publish/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/refresh/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/reindex/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/reports/resources/[name]/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/search/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/tags/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/version-check/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/welcome/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/api/ws-config/route-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/brain/page-c59ed9682d1734a4.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/calendar/page-480be4847d2e89d1.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/conflicts/page-7da3e6e6c563c569.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/graph/page-df6cef9d4646adff.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/hygiene/page-ae4a438701ce8b97.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/layout-483e7f39872cf229.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/login/page-66b93bc9a93b026d.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/page-88470b8cd166cf75.js +0 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/preview/motifs/page-04da9ec2ec835204.js +0 -1
- package/bundle/standalone/apps/web/.next/static/css/def7c93f9fc92d12.css +0 -3
- /package/bundle/standalone/apps/web/.next/static/{idjbcSJE8hK49A4CJHc8Z → ywmMNuYFqWWdZKKOMO5_E}/_buildManifest.js +0 -0
- /package/bundle/standalone/apps/web/.next/static/{idjbcSJE8hK49A4CJHc8Z → ywmMNuYFqWWdZKKOMO5_E}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{2720:(e,t,a)=>{"use strict";a.d(t,{A:()=>b});var r=a(14915),n=a(65347),l=a(30300),s=a(89872),o=a(77843),i=a(32577),c=a(83097),d=a(54810),u=a(7612),x=a(48727),h=a(49292),m=a(49129),p=a(39624),f=a(93478);function b(e){let t,a,{unresolvedConflicts:b=0,onConfigure:v,onLock:g}=e,[j,y]=(0,n.useState)(!1),w=null;try{w=(0,l.useRouter)()}catch(e){}let N="";try{var k;N=null!=(k="function"==typeof l.usePathname?(0,l.usePathname)():null)?k:""}catch(e){N=window.location.pathname||""}try{let e=(0,s.D)();t=e.theme,a=e.setTheme}catch(e){}(0,n.useEffect)(()=>{y(!0)},[]);let S=e=>{try{w?w.push(e):window.location.href=e}catch(e){}},C=async()=>{if(g)return void g();try{await fetch("/api/auth/logout",{method:"POST"})}catch(e){}S("/login")},A=[{id:"vault",label:"Vault",href:"/",icon:(0,r.jsx)(o.A,{className:"w-[18px] h-[18px]","aria-hidden":!0})},{id:"graph",label:"Knowledge Graph",href:"/graph",icon:(0,r.jsx)(i.A,{className:"w-[18px] h-[18px]","aria-hidden":!0})},{id:"calendar",label:"Calendar",href:"/calendar",icon:(0,r.jsx)(c.A,{className:"w-[18px] h-[18px]","aria-hidden":!0})}],T=[{id:"hygiene",label:"Knowledge Hygiene",href:"/hygiene",icon:(0,r.jsx)(d.A,{className:"w-[18px] h-[18px]","aria-hidden":!0})},{id:"conflicts",label:"Conflicts",href:"/conflicts",icon:(0,r.jsx)(u.A,{className:"w-[18px] h-[18px]","aria-hidden":!0}),badge:b>0?b:void 0},{id:"brain",label:"Brain & Sync",href:"/brain",icon:(0,r.jsx)(x.A,{className:"w-[18px] h-[18px]","aria-hidden":!0})}],F=e=>{let t="/"===e.href?"/"===N:N.startsWith(e.href),a=e.badge?"".concat(e.label," (").concat(e.badge," unresolved)"):e.label;return(0,r.jsxs)("button",{type:"button",onClick:()=>S(e.href),"aria-label":e.label,"aria-current":t?"page":void 0,title:a,"data-testid":"app-rail-".concat(e.id),className:"relative w-10 h-10 rounded-xl flex items-center justify-center transition-all duration-150 group ".concat(t?"bg-[var(--accent)] text-white dark:text-[#090D16] shadow-sm":"text-[var(--text-secondary)] hover:bg-[var(--accent-soft)] hover:text-[var(--text-primary)]"),children:[t&&(0,r.jsx)("span",{className:"absolute -left-2 top-2 bottom-2 w-1 rounded-r-full bg-[var(--accent)] bp-keep-round"}),e.icon,!!e.badge&&(0,r.jsx)("span",{"data-testid":"app-rail-badge-".concat(e.id),className:"absolute -top-1 -right-1 flex h-4 min-w-4 px-1 items-center justify-center rounded-full bg-[var(--danger)] text-[10px] font-bold text-white leading-none shadow-sm bp-keep-round",children:e.badge})]},e.id)};return(0,r.jsxs)("nav",{"aria-label":"Primary navigation",className:"hidden lg:flex sticky top-14 h-[calc(100vh-3.5rem)] w-14 shrink-0 bg-[var(--bg-secondary)]/90 border-r border-[var(--border)] flex-col items-center py-3 gap-1.5 z-40 select-none",children:[(0,r.jsx)("div",{className:"flex flex-col items-center gap-1.5",children:A.map(F)}),(0,r.jsx)("div",{className:"w-6 h-px bg-[var(--border)] my-1.5","aria-hidden":!0}),(0,r.jsx)("div",{className:"flex flex-col items-center gap-1.5",children:T.map(F)}),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("div",{className:"w-6 h-px bg-[var(--border)] my-1","aria-hidden":!0}),(0,r.jsxs)("div",{className:"flex flex-col items-center gap-1.5",children:[(0,r.jsx)("button",{type:"button",onClick:()=>v?v():S("/?configure=1"),"aria-label":"Configure Kontexta",title:"Configure Kontexta","data-testid":"app-rail-configure",className:"w-10 h-10 rounded-xl flex items-center justify-center text-[var(--text-secondary)] hover:bg-[var(--accent-soft)] hover:text-[var(--text-primary)] transition-colors",children:(0,r.jsx)(h.A,{className:"w-[18px] h-[18px]","aria-hidden":!0})}),j&&a&&(0,r.jsx)("button",{type:"button",onClick:()=>a("light"===t?"dark":"light"),"aria-label":"Toggle theme",title:"Theme: ".concat(null!=t?t:"dark"," — click to switch"),"data-testid":"app-rail-theme",className:"w-10 h-10 rounded-xl flex items-center justify-center text-[var(--text-secondary)] hover:bg-[var(--accent-soft)] hover:text-[var(--text-primary)] transition-colors",children:"light"===t?(0,r.jsx)(m.A,{className:"w-[18px] h-[18px]","aria-hidden":!0}):(0,r.jsx)(p.A,{className:"w-[18px] h-[18px]","aria-hidden":!0})}),(0,r.jsx)("button",{type:"button",onClick:()=>void C(),"aria-label":"Lock Kontexta",title:"Lock Kontexta","data-testid":"app-rail-lock",className:"w-10 h-10 rounded-xl flex items-center justify-center text-[var(--text-secondary)] hover:bg-[var(--danger-soft)] hover:text-[var(--danger)] transition-colors",children:(0,r.jsx)(f.A,{className:"w-[18px] h-[18px]","aria-hidden":!0})})]})]})}},6519:(e,t,a)=>{"use strict";a.d(t,{q:()=>i});var r=a(14915),n=a(65347),l=a(89872);let s=0;function o(e){if("undefined"!=typeof document){for(let t of[e,"d".concat(e),"i".concat(e),"dom-".concat(e)]){let e=document.getElementById(t);e&&e.remove()}try{document.querySelectorAll('[id="'.concat(e,'"], [id^="d').concat(e,'"], [id^="i').concat(e,'"], [id^="dom-').concat(e,'"]')).forEach(e=>e.remove())}catch(e){}}}function i(e){var t,i;let{source:c,className:d,filename:u}=e,x=(0,n.useRef)(null),[h,m]=(0,n.useState)(null),[p,f]=(0,n.useState)(null),{resolvedTheme:b}=(0,l.D)();(0,n.useEffect)(()=>{let e=!1,t=(s+=1,"mermaid-".concat(Date.now(),"-").concat(s));return m(null),f(null),(async()=>{try{let r=(await Promise.all([a.e(1805),a.e(7050),a.e(5514)]).then(a.bind(a,61081))).default;r.initialize({startOnLoad:!1,theme:"light"===b?"default":"dark",securityLevel:"strict"});let{svg:n}=await r.render(t,c);e||f(n),o(t)}catch(a){o(t),e||(m(a instanceof Error?a.message:String(a)),f(null))}})(),()=>{e=!0,o(t)}},[c,b]);let v=u&&(null!=(i=null==(t=u.split(/[\\/]/).pop())?void 0:t.trim())?i:"").replace(/\.(mmd|md|markdown)$/i,"").trim()||"diagram",g=e=>{let t=new DOMParser().parseFromString(e,"image/svg+xml");if(t.getElementsByTagName("parsererror").length>0){let t=document.createElement("div");return t.innerHTML=e,t.querySelector("svg")}return"svg"===t.documentElement.tagName.toLowerCase()?t.documentElement:null},j=!!p&&!h;return(0,r.jsxs)("div",{className:d,children:[j&&(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{if(!p)return;let e=g(p);if(!e)return void m("SVG export failed: could not parse rendered SVG");e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");let t=new XMLSerializer().serializeToString(e),a=new Blob([t.startsWith("<?xml")?t:'<?xml version="1.0" encoding="UTF-8"?>\n'.concat(t)],{type:"image/svg+xml;charset=utf-8"}),r=URL.createObjectURL(a),n=document.createElement("a");n.href=r,n.download="".concat(v,".svg"),document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)},className:"btn btn-sm","aria-label":"Export diagram as SVG",title:"Export as SVG",children:"SVG"}),(0,r.jsx)("button",{type:"button",onClick:()=>{var e,t;if(!p)return;let a=null==(e=x.current)?void 0:e.querySelector("svg"),r=null!=a?a:g(p);if(!r)return void m("PNG export failed: could not parse rendered SVG");let n=800,l=600,s=null==(t=r.viewBox)?void 0:t.baseVal;if(s&&s.width>0&&s.height>0)n=s.width,l=s.height;else if(a)try{let e=a.getBBox();e.width>0&&e.height>0&&(n=e.width,l=e.height)}catch(e){}let o=r.cloneNode(!0);o.setAttribute("xmlns","http://www.w3.org/2000/svg"),o.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),o.setAttribute("width",String(n)),o.setAttribute("height",String(l));let i=new XMLSerializer().serializeToString(o),c=new TextEncoder().encode(i),d="";for(let e=0;e<c.length;e++)d+=String.fromCharCode(c[e]);let u="data:image/svg+xml;base64,".concat(btoa(d)),h=document.createElement("canvas");h.width=Math.max(1,Math.round(2*n)),h.height=Math.max(1,Math.round(2*l));let f=h.getContext("2d");if(!f)return void m("PNG export failed: 2D canvas context unavailable");let j=new Image;j.onload=()=>{f.fillStyle="light"===b?"#ffffff":"#1f2937",f.fillRect(0,0,h.width,h.height),f.drawImage(j,0,0,h.width,h.height);try{h.toBlob(e=>{if(!e)return void m("PNG export failed: canvas returned empty blob");let t=URL.createObjectURL(e),a=document.createElement("a");a.href=t,a.download="".concat(v,".png"),document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(t)},"image/png")}catch(t){let e=t instanceof Error?t.message:String(t);m("PNG export failed: ".concat(e))}},j.onerror=()=>{m("PNG export failed: SVG could not be loaded as an image (it may reference external resources or unsupported features)")},j.src=u},className:"btn btn-sm","aria-label":"Export diagram as PNG",title:"Export as PNG (2x)",children:"PNG"})]}),h&&(0,r.jsxs)("pre",{className:"text-[var(--danger)] whitespace-pre-wrap mb-2 text-sm",children:["Mermaid render error: ",h]}),(0,r.jsx)("div",{ref:x,dangerouslySetInnerHTML:p?{__html:p}:void 0}),h&&(0,r.jsx)("pre",{className:"mt-2 p-3 bg-zinc-900 text-zinc-100 text-xs overflow-x-auto",children:c})]})}},7395:(e,t,a)=>{"use strict";a.d(t,{H:()=>l});var r=a(14915);let n={sm:{lightSrc:"/logo.png",darkSrc:"/logo-dark.png",imgClass:"h-[56px] w-auto",floatClass:"",particles:[],orbitRadius:0},lg:{lightSrc:"/logo.png",darkSrc:"/logo-dark.png",imgClass:"h-[150px] w-auto",floatClass:"animate-[logo-float-lg_3s_ease-in-out_infinite]",particles:[{size:6,color:"#C2410C",opacity:.75,duration:5,reverse:!1,delay:0},{size:4,color:"#D4A050",opacity:.55,duration:7,reverse:!0,delay:-3},{size:3,color:"#FFD49A",opacity:.45,duration:9,reverse:!1,delay:-5}],orbitRadius:70}};function l(e){let{size:t}=e,{lightSrc:a,darkSrc:l,imgClass:s,floatClass:o,particles:i,orbitRadius:c}=n[t];return(0,r.jsxs)("div",{className:"relative inline-flex flex-shrink-0 overflow-visible",children:[(0,r.jsx)("img",{src:a,alt:"Kontexta",className:"block dark:hidden ".concat(s," object-contain ").concat(o)}),(0,r.jsx)("img",{src:l,alt:"Kontexta",className:"hidden dark:block ".concat(s," object-contain ").concat(o)}),i.map((e,t)=>(0,r.jsx)("span",{className:"absolute rounded-full bp-keep-round pointer-events-none",style:{width:e.size,height:e.size,backgroundColor:e.color,opacity:e.opacity,top:"calc(50% - ".concat(c,"px)"),left:"calc(50% - ".concat(e.size/2,"px)"),transformOrigin:"".concat(e.size/2,"px ").concat(c,"px"),animation:"logo-orbit ".concat(e.duration,"s linear infinite").concat(e.reverse?" reverse":""),animationDelay:"".concat(e.delay,"s")}},t))]})}},17695:(e,t,a)=>{"use strict";a.d(t,{T:()=>l});var r=a(14915),n=a(56570);function l(e){let{open:t,onClose:a,onConfirm:l,title:s,message:o,confirmLabel:i="Confirm",cancelLabel:c="Cancel",destructive:d=!1,loading:u=!1}=e;return(0,r.jsxs)(n.l,{open:t,onClose:a,title:s,children:[(0,r.jsx)("div",{className:"text-sm text-[var(--text-secondary)]",children:o}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-5",children:[(0,r.jsx)("button",{type:"button",className:"btn btn-md",onClick:a,disabled:u,children:c}),(0,r.jsx)("button",{type:"button",className:"btn btn-md ".concat(d?"btn-destructive":"btn-primary"),onClick:l,disabled:u,children:u?"…":i})]})]})}},29881:(e,t,a)=>{"use strict";a.d(t,{p:()=>n});var r=a(14915);function n(e){let{icon:t,title:a,hint:n,action:l}=e;return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 px-6 text-center gap-2",children:[t&&(0,r.jsx)("div",{className:"text-[var(--muted)] opacity-60 mb-1",children:t}),(0,r.jsx)("p",{className:"text-sm font-medium text-[var(--text-primary)]",children:a}),n&&(0,r.jsx)("p",{className:"text-xs text-[var(--text-secondary)]",children:n}),l&&(0,r.jsx)("div",{className:"mt-3",children:l})]})}},33039:(e,t,a)=>{"use strict";a.d(t,{default:()=>tA});var r=a(14915),n=a(65347),l=a(4341),s=a(30300),o=a(97935),i=a(51205),c=a(77843),d=a(22377),u=a(89872),x=a(51750),h=a(5816),m=a(79358),p=a(92819),f=a(62376),b=a(85972),v=a(51386),g=a(31131),j=a(49292),y=a(51815),w=a(73382),N=a(32577),k=a(54810),S=a(51569),C=a(7612),A=a(48727),T=a(49129),F=a(39624),P=a(81339),E=a.n(P),L=a(7395),_=a(94567);function R(e){let{trigger:t,items:a,align:n="end"}=e;return(0,r.jsxs)(_.bL,{children:[(0,r.jsx)(_.l9,{asChild:!0,children:t}),(0,r.jsx)(_.ZL,{children:(0,r.jsx)(_.UC,{align:n,sideOffset:6,className:"z-[var(--z-dropdown)]",children:(0,r.jsx)("div",{className:"min-w-[180px] rounded-md border border-[var(--border)] bg-[var(--bg-primary)] py-1.5 shadow-xl animate-scale-in",children:a.map(e=>(0,r.jsxs)(_.q7,{onSelect:e.onSelect,className:"flex w-full cursor-pointer items-center gap-2 px-3 py-2 text-left text-xs font-medium outline-none transition-colors data-[highlighted]:bg-[var(--accent)] data-[highlighted]:text-white ".concat(e.destructive?"text-[var(--danger)]":"text-[var(--text-secondary)]"),children:[e.icon,e.label]},e.label))})})})]})}let D="8.0.0";function M(e){let{onSearch:t,onAbout:a,onConfigure:l,onPublish:o,onViewPublished:i,onNewFile:c,focusMode:P=!1,onToggleFocus:_,unresolvedConflicts:M}=e,I=(0,s.useRouter)(),{theme:O,setTheme:U}=(0,u.D)(),[H,B]=(0,n.useState)(!1),[G,z]=(0,n.useState)(!1),[K,W]=(0,n.useState)(!1),[J,V]=(0,n.useState)(null!=M?M:0);(0,n.useEffect)(()=>{if(void 0!==M)return void V(M);let e=!1,t=async()=>{try{let t=await fetch("/api/conflicts?count=1",{cache:"no-store"});if(t.ok){let a=await t.json();e||"number"!=typeof(null==a?void 0:a.count)||V(a.count)}}catch(e){}};t();let a=setInterval(()=>{"undefined"!=typeof document&&document.hidden||t()},15e3),r=()=>{t()};return window.addEventListener("kontexta:conflicts-changed",r),()=>{e=!0,clearInterval(a),window.removeEventListener("kontexta:conflicts-changed",r)}},[M]);let q=async()=>{var e,t,a,r,n,l;if(!K){W(!0);try{let l=await fetch("/api/reindex",{method:"POST"}),s=await l.json().catch(()=>({}));if(l.ok&&(null==s?void 0:s.success)){let n=null!=(t=s.totals)?t:{newly_indexed:0,refreshed:0,pruned:0,errors:0};d.o.success("Reindexed ".concat(null!=(a=null==(e=s.scopes)?void 0:e.length)?a:0," scope(s) in ").concat(null!=(r=s.duration_ms)?r:"?","ms - ")+"+".concat(n.newly_indexed," new, ").concat(n.refreshed," updated, ").concat(n.pruned," removed")+(n.errors?", ".concat(n.errors," scope error(s)"):""))}else 409===l.status?d.o.error("Reindex already in progress"):d.o.error("Reindex failed: ".concat(null!=(n=null==s?void 0:s.error)?n:"HTTP ".concat(l.status)))}catch(e){d.o.error("Reindex failed: ".concat(null!=(l=null==e?void 0:e.message)?l:"Network error"))}finally{W(!1)}}};(0,n.useEffect)(()=>{B(!0),z(navigator.platform.toUpperCase().indexOf("MAC")>=0)},[]);let $=G?"⌘":"Ctrl";return(0,r.jsxs)("header",{className:"sticky top-0 z-50 h-14 bg-[var(--bg-secondary)]/85 backdrop-blur-xl flex flex-nowrap items-center px-3 sm:px-5 border-b border-[var(--border)] gap-2 sm:gap-3 transition-all",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[_&&(0,r.jsx)("button",{type:"button",onClick:_,className:"hidden lg:inline-flex btn btn-icon-sm text-[var(--text-secondary)]","aria-label":P?"Show sidebars":"Focus mode (hide sidebars)",title:P?"Show sidebars (".concat($,"\\)"):"Focus mode (".concat($,"\\)"),children:P?(0,r.jsx)(x.A,{className:"w-4 h-4","aria-hidden":!0}):(0,r.jsx)(h.A,{className:"w-4 h-4","aria-hidden":!0})}),(0,r.jsxs)("div",{className:"flex items-center gap-0 group cursor-pointer shrink-0",onClick:()=>I.push("/"),children:[(0,r.jsx)(L.H,{size:"sm"}),(0,r.jsx)("span",{className:"-ml-3 font-extrabold text-lg tracking-[3.5px] font-title text-[var(--text-primary)] transition-colors group-hover:text-[var(--accent)] whitespace-nowrap",children:"ONTEXTA"})]})]}),(0,r.jsx)("div",{className:"flex-1 min-w-[36px] sm:min-w-[160px] flex justify-center px-1 sm:px-4",children:(0,r.jsxs)("button",{onClick:t,className:"w-full max-w-[520px] h-9 px-3 sm:px-3.5 bg-[var(--bg-primary)]/80 text-[13px] text-[var(--text-secondary)] rounded-lg hover:bg-[var(--bg-primary)] hover:border-[var(--border-strong)] transition-all flex items-center justify-center sm:justify-start gap-2.5 border border-[var(--border)] group focus-glow whitespace-nowrap overflow-hidden shrink","aria-label":"Search context",title:"Search context (".concat($,"K)"),children:[(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-4 h-4 opacity-60 group-hover:opacity-100 group-hover:text-[var(--accent)] transition-all shrink-0",children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,r.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),(0,r.jsx)("span",{className:"hidden sm:inline flex-1 text-left text-[var(--text-tertiary)] group-hover:text-[var(--text-secondary)] truncate",children:"Search files, tags, or > commands..."}),(0,r.jsxs)("kbd",{className:"hidden md:inline-block text-[10px] font-mono text-[var(--text-secondary)] bg-[var(--bg-secondary)] px-1.5 py-0.5 rounded border border-[var(--border)] shrink-0",children:[$,"K"]})]})}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-2 shrink-0 flex-nowrap",children:[J>0&&(0,r.jsxs)(E(),{href:"/conflicts",onClick:e=>{e.preventDefault();try{I.push("/conflicts")}catch(e){}},className:"btn btn-sm font-semibold text-amber-accent bg-[var(--accent-soft)] hover:bg-amber-accent/25 border border-[var(--border-strong)] whitespace-nowrap shrink-0 inline-flex items-center gap-1.5 transition-all","aria-label":"".concat(J," unresolved conflict").concat(1===J?"":"s"),title:"".concat(J," unresolved conflict").concat(1===J?"":"s"),"data-testid":"unresolved-conflicts-badge",children:[(0,r.jsx)(m.A,{className:"w-3.5 h-3.5 text-amber-accent shrink-0","aria-hidden":!0}),(0,r.jsx)("span",{children:"Conflicts"}),(0,r.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] rounded-full bg-amber-accent text-black font-extrabold leading-none bp-keep-round",children:J})]}),c&&(0,r.jsxs)("button",{type:"button",onClick:c,className:"hidden sm:inline-flex btn btn-sm btn-primary whitespace-nowrap shrink-0","aria-label":"New file",children:[(0,r.jsx)(p.A,{className:"w-3.5 h-3.5","aria-hidden":!0}),"New"]}),(0,r.jsx)("div",{className:"hidden lg:block",children:(0,r.jsx)(R,{trigger:(0,r.jsx)("button",{type:"button",className:"btn btn-sm btn-outline whitespace-nowrap shrink-0","aria-label":"Publish menu",title:"Publish documentation",children:"Publish\xa0▾"}),items:[{label:"New Publish",onSelect:o,icon:(0,r.jsx)(f.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})},{label:"View Published",onSelect:i,icon:(0,r.jsx)(b.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})}]})}),(0,r.jsx)("div",{className:"hidden lg:block",children:(0,r.jsx)(R,{trigger:(0,r.jsx)("button",{type:"button",className:"btn btn-icon-sm btn-outline shrink-0","aria-label":"Workspace tools",title:"Tools & info (v".concat(D,")"),children:(0,r.jsx)(v.A,{className:"w-4 h-4","aria-hidden":!0})}),items:[{label:K?"Reindexing…":"Reindex Vault",onSelect:q,icon:(0,r.jsx)(g.A,{className:"w-4 h-4 text-[var(--accent)] ".concat(K?"animate-spin":""),"aria-hidden":!0})},{label:"Configure",onSelect:l,icon:(0,r.jsx)(j.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})},{label:"About Kontexta (v".concat(D,")"),onSelect:a,icon:(0,r.jsx)(y.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})}]})}),(0,r.jsx)("div",{className:"lg:hidden",children:(0,r.jsx)(R,{trigger:(0,r.jsx)("button",{type:"button",className:"btn btn-icon-sm btn-outline shrink-0","aria-label":"Open navigation menu",title:"Menu",children:(0,r.jsx)(w.A,{className:"w-4 h-4","aria-hidden":!0})}),items:[...c?[{label:"New File",onSelect:c,icon:(0,r.jsx)(p.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})}]:[],{label:"Graph",onSelect:()=>I.push("/graph"),icon:(0,r.jsx)(N.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})},{label:"Hygiene",onSelect:()=>I.push("/hygiene"),icon:(0,r.jsx)(k.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})},{label:"Calendar",onSelect:()=>I.push("/calendar"),icon:(0,r.jsx)(S.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})},{label:"Conflicts",onSelect:()=>I.push("/conflicts"),icon:(0,r.jsx)(C.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})},{label:"Brain & Sync",onSelect:()=>I.push("/brain"),icon:(0,r.jsx)(A.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})},{label:K?"Reindexing…":"Reindex",onSelect:q,icon:(0,r.jsx)(g.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})},{label:"Configure",onSelect:l,icon:(0,r.jsx)(j.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})},{label:"About",onSelect:a,icon:(0,r.jsx)(y.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})},{label:"New Publish",onSelect:o,icon:(0,r.jsx)(f.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})},{label:"View Published",onSelect:i,icon:(0,r.jsx)(b.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})}]})}),H&&(0,r.jsx)("button",{onClick:()=>U("light"===O?"dark":"light"),className:"lg:hidden btn btn-icon-sm btn-outline shrink-0","aria-label":"Toggle theme (light / dark)",title:"Theme: ".concat(O," - click to toggle"),children:"light"===O?(0,r.jsx)(T.A,{className:"w-4 h-4","aria-hidden":!0}):(0,r.jsx)(F.A,{className:"w-4 h-4","aria-hidden":!0})}),(0,r.jsx)("button",{onClick:async()=>{await fetch("/api/auth/logout",{method:"POST"}),I.push("/login")},className:"lg:hidden btn btn-icon-sm text-[var(--text-secondary)] hover:text-[var(--danger)] shrink-0","aria-label":"Lock Kontexta",title:"Lock Kontexta",children:(0,r.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,r.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})})]})]})}function I(e){let[t,a]=(0,n.useState)(()=>window.matchMedia(e).matches);return(0,n.useEffect)(()=>{let t=window.matchMedia(e);a(t.matches);let r=e=>a(e.matches);return t.addEventListener("change",r),()=>t.removeEventListener("change",r)},[e]),t}let O="kontexta:pane-widths:v1";function U(e){let{left:t,leftRail:a,middle:l,right:s,isPhone:o=!1,mobileTab:i="files",leftCollapsed:c=!1,middleCollapsed:d=!1}=e,[u,x]=(0,n.useState)(240),[h,m]=(0,n.useState)(320),[p,f]=(0,n.useState)(!1),b=I("(max-width: 1023px)");(0,n.useEffect)(()=>{try{let e=localStorage.getItem(O);if(e){let t=JSON.parse(e);"number"==typeof t.left&&x(H(t.left,180,360)),"number"==typeof t.middle&&m(H(t.middle,260,600))}}catch(e){}f(!0)},[]),(0,n.useEffect)(()=>{if(p)try{localStorage.setItem(O,JSON.stringify({left:u,middle:h}))}catch(e){}},[p,u,h]);let v=(0,n.useRef)(null),g=(0,n.useRef)(0),j=(0,n.useRef)(0),y=e=>t=>{v.current=e,g.current=t.clientX,j.current="left"===e?u:h,t.target.setPointerCapture(t.pointerId)},w=!o&&b&&!!a&&!c;return(0,r.jsxs)("div",{className:"flex flex-1 min-h-0 min-w-0",onPointerMove:e=>{if(!v.current)return;let t=e.clientX-g.current;"left"===v.current?x(H(j.current+t,180,360)):m(H(j.current+t,260,600))},onPointerUp:()=>{v.current=null},children:[w?a:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:o||c?void 0:{width:u},className:o?"browse"===i?"flex-1 w-full h-full overflow-y-auto bg-[var(--bg-primary)] scrollbar-thin":"hidden":c?"hidden":"shrink-0 h-full overflow-y-auto bg-[var(--bg-secondary)]/35 border-r border-[var(--border)] scrollbar-thin",onScroll:e=>e.stopPropagation(),children:t}),!o&&!c&&(0,r.jsx)("div",{onPointerDown:y("left"),className:"w-1 cursor-col-resize bg-transparent hover:bg-[var(--accent)]/40 transition-colors z-10"})]}),(0,r.jsx)("div",{style:o||d?void 0:{width:h},className:o?"files"===i?"flex-1 w-full h-full overflow-y-auto bg-[var(--bg-primary)]":"hidden":d?"hidden":"shrink-0 h-full overflow-y-auto bg-[var(--bg-primary)] border-r border-[var(--border)]",children:l}),!o&&!d&&(0,r.jsx)("div",{onPointerDown:y("middle"),className:"w-1 cursor-col-resize bg-transparent hover:bg-[var(--accent)]/40 transition-colors z-10"}),(0,r.jsx)("div",{className:o?"read"===i?"flex-1 min-w-0 bg-[var(--bg-primary)] overflow-y-auto flex flex-col":"hidden":"flex-1 min-w-0 bg-[var(--bg-primary)] overflow-y-auto flex flex-col",children:(0,r.jsx)("div",{className:"flex-1 min-w-0 overflow-auto relative",children:s})})]})}function H(e,t,a){return Math.max(t,Math.min(a,e))}var B=a(98526),G=a(93756),z=a(15708),K=a(83097),W=a(54725),J=a(89191),V=a(29723),q=a(78707),$=a(6299),Y=a(34683);function Z(e){let{label:t,icon:a,active:l=!1,initialExpanded:s=!1,children:o,onClick:i,hasHands:c=!1,count:d,trailingAction:u}=e,[x,h]=(0,n.useState)(s),m=!!o;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{onClick:()=>{m&&!x&&h(!0),null==i||i()},className:"relative flex items-center gap-1.5 py-1.5 px-2 rounded-lg text-sm cursor-pointer transition-all duration-150 group ".concat(l?"bg-[var(--accent-soft)] text-[var(--text-primary)] font-semibold":"text-[var(--text-secondary)] hover:bg-[var(--accent-soft)]/70 hover:text-[var(--text-primary)]"),children:[l&&(0,r.jsx)("span",{className:"absolute left-0 top-1.5 bottom-1.5 w-0.5 bg-[var(--accent)] rounded-full bp-keep-round"}),m&&(0,r.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),h(e=>!e)},"aria-label":x?"Collapse ".concat(t):"Expand ".concat(t),"aria-expanded":x,className:"p-0.5 -ml-0.5 rounded hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors shrink-0",children:(0,r.jsx)(Y.A,{className:"w-3 h-3 transition-transform duration-200 ".concat(x?"rotate-90":""),"aria-hidden":!0})}),a&&(0,r.jsx)("span",{className:"dark-icon shrink-0",children:a}),(0,r.jsx)("span",{className:"truncate flex-1",children:t}),"number"==typeof d&&d>0&&(0,r.jsx)("span",{className:"text-[10px] font-mono tabular-nums text-[var(--text-tertiary)] shrink-0",children:d}),c&&(0,r.jsx)("span",{className:"ml-0.5 flex items-center justify-center text-[10px] text-[var(--accent)] opacity-80 shrink-0",title:"Hands enabled",children:(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-3 h-3",children:[(0,r.jsx)("path",{d:"M18 11V6a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v0"}),(0,r.jsx)("path",{d:"M14 10V4a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v0"}),(0,r.jsx)("path",{d:"M10 10.5V6a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v0"}),(0,r.jsx)("path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"})]})}),u&&(0,r.jsx)("span",{className:"ml-auto flex items-center opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity",onClick:e=>e.stopPropagation(),children:u})]}),(0,r.jsx)("div",{className:"grid transition-all duration-200 ease-in-out ".concat(m&&x?"grid-rows-[1fr] opacity-100 mt-0.5":"grid-rows-[0fr] opacity-0"),children:(0,r.jsx)("div",{className:"overflow-hidden ml-3",children:o})})]})}let X=e=>e.replace(/\\/g,"/");function Q(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=!(arguments.length>3)||void 0===arguments[3]||arguments[3],n={name:"",path:"",children:[],files:[]},l=X(t),s=l.endsWith("/")?l:l+"/";for(let t of e){var o;let e=X(t.path);if(!e.startsWith(s))continue;let a=e.slice(s.length).split("/");a.pop();let r=n,l="";for(let e of a){l=l?"".concat(l,"/").concat(e):e;let t=r.children.find(t=>t.name===e);t||(t={name:e,path:l,children:[],files:[]},r.children.push(t)),r=t}r.files.push({id:t.id,title:t.title,path:t.path,content_class:null!=(o=t.content_class)?o:null})}for(let e of a){let t=X(e).split("/"),a=n,r="";for(let e of t){r=r?"".concat(r,"/").concat(e):e;let t=a.children.find(t=>t.name===e);t||(t={name:e,path:r,children:[],files:[]},a.children.push(t)),a=t}}return r&&function e(t){return t.children=t.children.filter(t=>e(t)),t.files.length>0||t.children.length>0||!!t.isExplicit}(n),function e(t){for(let a of(t.children.sort((e,t)=>e.name.localeCompare(t.name)),t.files.sort((e,t)=>e.title.localeCompare(t.title)),t.children))e(a)}(n),n}var ee=a(29881);let et={fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round"};function ea(e){let{contentClass:t,className:a,title:n}=e,l=null!=a?a:"w-4 h-4",s=null!=n?n:null!=t?t:"file";switch(t){case"dictionary":return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",...et,className:l,"aria-label":s,children:[(0,r.jsx)("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20"}),(0,r.jsx)("path",{d:"M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"})]});case"note":return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",...et,className:l,"aria-label":s,children:[(0,r.jsx)("path",{d:"M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9l-6-6z"}),(0,r.jsx)("polyline",{points:"14 3 14 9 20 9"}),(0,r.jsx)("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),(0,r.jsx)("line",{x1:"8",y1:"17",x2:"13",y2:"17"})]});case"journal":return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",...et,className:l,"aria-label":s,children:[(0,r.jsx)("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),(0,r.jsx)("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),(0,r.jsx)("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),(0,r.jsx)("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]});case"project":return(0,r.jsx)("svg",{viewBox:"0 0 24 24",...et,className:l,"aria-label":s,children:(0,r.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h5l2 2h7a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"})});default:return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",...et,className:l,"aria-label":s,children:[(0,r.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,r.jsx)("polyline",{points:"14 2 14 8 20 8"})]})}}let er=e=>{let{className:t}=e;return(0,r.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:(0,r.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})},en=[{name:"knowledge",label:"Knowledge",icon:e=>(0,r.jsx)(B.A,{...e})},{name:"mermaid",label:"Mermaid",icon:e=>(0,r.jsx)(G.A,{...e})},{name:"html",label:"HTML",icon:e=>(0,r.jsx)(z.A,{...e})},{name:"journal",label:"Journal",icon:e=>(0,r.jsx)(K.A,{...e})}],el=new Set(en.map(e=>e.name));function es(e){let{tags:t,selectedTag:a,onSelectTag:l}=e,[s,o]=(0,n.useState)(!1),[i,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(""),x=t.filter(e=>e.count>0);if(0===x.length)return null;let h=d.trim().toLowerCase(),m=h?x.filter(e=>e.name.toLowerCase().includes(h)):x,p=h||i?m:m.slice(0,10),f=m.length-p.length;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-2 pt-2 pb-1",children:[(0,r.jsxs)("button",{onClick:()=>o(e=>!e),className:"text-[12px] uppercase tracking-wider text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors inline-flex items-center gap-1","aria-label":"Toggle tags",children:[(0,r.jsx)(W.A,{className:"w-3 h-3 transition-transform ".concat(s?"":"-rotate-90"),"aria-hidden":!0}),"Tags",(0,r.jsxs)("span",{className:"normal-case tracking-normal text-[var(--text-secondary)]/70",children:["(",x.length,")"]})]}),a&&(0,r.jsx)("button",{onClick:()=>l(null),className:"text-[10px] uppercase tracking-wider text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",title:"Clear tag filter",children:"Clear"})]}),s&&(0,r.jsxs)("div",{className:"space-y-0.5 mt-0.5",children:[(0,r.jsxs)("div",{className:"relative px-2 mb-1",children:[(0,r.jsx)(J.A,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-3 h-3 text-[var(--text-secondary)]/60 pointer-events-none","aria-hidden":!0}),(0,r.jsx)("input",{type:"text",value:d,onChange:e=>u(e.target.value),placeholder:"Filter tags…",className:"w-full bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md pl-6 pr-6 py-1 text-[12px] text-[var(--text-primary)] outline-none focus:border-[var(--accent)]/50","aria-label":"Filter tags"}),d&&(0,r.jsx)("button",{onClick:()=>u(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)] hover:text-[var(--accent)]","aria-label":"Clear tag filter",title:"Clear",children:(0,r.jsx)(V.A,{className:"w-3 h-3","aria-hidden":!0})})]}),0===m.length?(0,r.jsxs)("div",{className:"px-3 py-2 text-[11px] italic text-[var(--text-secondary)]",children:["No tags match “",d,"”."]}):p.map(e=>{let t=a===e.name;return(0,r.jsxs)("button",{onClick:()=>l(t?null:e.name),className:"w-full flex items-center gap-1.5 py-1 px-2 rounded-lg text-[13px] cursor-pointer transition-all group ".concat(t?"bg-[var(--accent-soft)] text-[var(--text-primary)] font-semibold":"text-[var(--text-secondary)] hover:bg-[var(--accent-soft)] hover:text-[var(--text-primary)]"),"aria-pressed":t,title:'Show files tagged "'.concat(e.name,'"'),children:[(0,r.jsx)(q.A,{className:"w-3 h-3 shrink-0 ".concat(t?"text-[var(--accent)]":"text-[var(--text-secondary)] group-hover:text-[var(--accent)]"),"aria-hidden":!0}),(0,r.jsx)("span",{className:"truncate flex-1 text-left",children:e.name}),(0,r.jsx)("span",{className:"text-[10px] font-mono tabular-nums ".concat(t?"text-[var(--accent)]":"text-[var(--text-secondary)]/60"),children:e.count})]},e.id)}),!h&&f>0&&(0,r.jsxs)("button",{onClick:()=>c(!0),className:"w-full text-left px-2 py-1 text-[11px] text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors italic",children:["Show ",f," more…"]}),!h&&i&&x.length>10&&(0,r.jsxs)("button",{onClick:()=>c(!1),className:"w-full text-left px-2 py-1 text-[11px] text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors italic",children:["Show top ",10]})]})]})}function eo(e){let{node:t,selectedFolder:a,onSelectFolder:n,onSelectFile:l}=e;return(0,r.jsxs)(r.Fragment,{children:[t.children.map(e=>(0,r.jsx)(Z,{label:e.name,icon:(0,r.jsx)(er,{className:"w-3.5 h-3.5 text-[#FF7F50] group-hover:text-[var(--accent)] transition-colors"}),active:a===e.path,onClick:()=>n(e.path),children:(0,r.jsx)(eo,{node:e,selectedFolder:a,onSelectFolder:n,onSelectFile:l})},e.path)),t.files.map(e=>{var t;return(0,r.jsx)(Z,{label:e.title,icon:(0,r.jsx)(ea,{contentClass:null!=(t=e.content_class)?t:null,className:"w-3.5 h-3.5 text-amber-accent group-hover:text-[var(--accent)] transition-colors"}),onClick:()=>l(e.id)},e.id)})]})}function ei(e){let{projects:t,projectFiles:a,knowledgeFiles:l,selectedProjectId:s,selectedSection:i,selectedFolder:c,projectFolders:d,knowledgeFolders:u,projectBasePath:x,knowledgeBasePath:h,projectFileCounts:m,onSelectProject:p,onSelectKnowledge:f,onSelectFavorites:b,onSelectKnowledgeFolder:v,onSelectFolder:g,onSelectFile:j,onCreateBucketFolder:y,showJournal:w=!1,onToggleShowJournal:N,selectedTag:k,tags:S,onSelectTag:C}=e,A=(0,n.useMemo)(()=>{if(!s)return null;let e=t.find(e=>e.id===s);return e&&e.path?Q(a,e.path,d):null},[s,a,d,t]),T=(0,n.useMemo)(()=>0===u.length&&0===l.length?null:Q(l,h,u,!1),[l,u,h]);return(0,r.jsxs)("div",{className:"p-2 space-y-3 text-[var(--text-primary)]",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"bp-annotation px-2 pt-2 pb-1 text-[12px] uppercase tracking-wider text-[var(--text-secondary)]",children:"Projects"}),(0,r.jsxs)("div",{className:"space-y-0.5",children:[t.map(e=>{var t;let n=s===e.id,l=m?null!=(t=m[e.id])?t:0:a.filter(t=>t.project_id===e.id).length;return(0,r.jsx)(Z,{label:e.name,icon:(0,r.jsx)(er,{className:"w-3.5 h-3.5 text-[#FF7F50] group-hover:text-[var(--accent)] transition-colors"}),active:n&&null===c,initialExpanded:n,hasHands:e.has_hands,count:l>0?l:void 0,onClick:()=>{p(e.id),g(null)},children:n&&A?(0,r.jsx)(eo,{node:A,selectedFolder:c,onSelectFolder:g,onSelectFile:j}):void 0},e.id)}),0===t.length&&(0,r.jsx)(ee.p,{icon:(0,r.jsx)(o.A,{className:"w-8 h-8 opacity-40","aria-hidden":!0}),title:"No projects yet"})]})]}),(0,r.jsx)("div",{children:(0,r.jsx)("div",{className:"flex items-center justify-between px-2 pt-2 pb-1",children:(0,r.jsx)("button",{onClick:b,className:"text-[12px] uppercase tracking-wider transition-colors ".concat("favorites"===i?"text-[var(--accent)]":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"),"aria-label":"Select favorites",children:"Favorites"})})}),(0,r.jsx)(es,{tags:S,selectedTag:k,onSelectTag:C}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-2 pt-2 pb-1",children:[(0,r.jsx)("button",{onClick:f,className:"text-[12px] uppercase tracking-wider transition-colors ".concat("knowledge"!==i||c?"text-[var(--text-secondary)] hover:text-[var(--text-primary)]":"text-[var(--accent)]"),"aria-label":"Select knowledge base",children:"Knowledge"}),N&&(0,r.jsxs)("button",{type:"button",onClick:N,"aria-pressed":w,"aria-label":w?"Hide journal":"Show journal",title:w?"Hide agent journal files":"Show agent journal files",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] uppercase tracking-wider transition-colors ".concat(w?"bg-[var(--accent-soft)] text-[var(--accent)] font-semibold":"text-[var(--text-secondary)]/60 hover:text-[var(--text-primary)]"),children:[(0,r.jsx)(K.A,{className:"w-3 h-3 shrink-0","aria-hidden":!0}),(0,r.jsx)("span",{children:"Journal"})]})]}),(0,r.jsx)("div",{className:"space-y-0.5",children:(()=>{var e,t,a;let n=null!=(e=null==T?void 0:T.files)?e:[],l=new Map;for(let e of null!=(t=null==T?void 0:T.children)?t:[]){let t=e.name.toLowerCase();el.has(t)&&!l.has(t)&&l.set(t,e)}let s=(null!=(a=null==T?void 0:T.children)?a:[]).filter(e=>!el.has(e.name.toLowerCase())),o=w?en:en.filter(e=>"journal"!==e.name);return(0,r.jsxs)(r.Fragment,{children:[n.map(e=>{var t;let a=e.path.toLowerCase().endsWith("/profile.md")||e.path.toLowerCase().endsWith("\\profile.md");return(0,r.jsx)(Z,{label:e.title,icon:a?(0,r.jsx)($.A,{className:"w-3.5 h-3.5 text-[var(--accent)] group-hover:text-[var(--accent)] transition-colors"}):(0,r.jsx)(ea,{contentClass:null!=(t=e.content_class)?t:null,className:"w-3.5 h-3.5 text-amber-accent group-hover:text-[var(--accent)] transition-colors"}),onClick:()=>j(e.id)},e.id)}),o.map(e=>{var t;let a,n=null!=(t=l.get(e.name))?t:{name:a=e.name,path:a,children:[],files:[]},s=0===n.children.length&&0===n.files.length,o=function e(t){return t.files.length+t.children.reduce((t,a)=>t+e(a),0)}(n);return(0,r.jsx)(Z,{label:e.label,icon:e.icon({className:"w-3.5 h-3.5 ".concat(s?"text-[var(--text-secondary)] opacity-60":"text-[#FF7F50]"," group-hover:text-[var(--accent)] transition-colors")}),active:c===e.name,count:o>0?o:void 0,onClick:()=>v(e.name),trailingAction:y?(0,r.jsx)("button",{type:"button",onClick:()=>y(e.name),className:"text-[10px] px-1.5 py-0.5 rounded hover:bg-[var(--accent-soft)] text-[var(--text-secondary)] hover:text-[var(--accent)]",title:"New subfolder inside ".concat(e.name,"/"),"aria-label":"New subfolder inside ".concat(e.name),children:"+"}):void 0,children:s?void 0:(0,r.jsx)(eo,{node:n,selectedFolder:c,onSelectFolder:v,onSelectFile:j})},e.name)}),s.map(e=>(0,r.jsx)(Z,{label:"".concat(e.name," (legacy)"),icon:(0,r.jsx)(er,{className:"w-3.5 h-3.5 text-[var(--text-secondary)] opacity-70 group-hover:text-[var(--accent)] transition-colors"}),active:c===e.path,onClick:()=>v(e.path),children:(0,r.jsx)(eo,{node:e,selectedFolder:c,onSelectFolder:v,onSelectFile:j})},e.path))]})})()})]})]})}var ec=a(50329),ed=a(24598);function eu(e){let{value:t,onChange:a}=e;return(0,r.jsxs)("div",{className:"relative px-2 py-1.5 border-b border-[var(--border)] bg-[var(--bg-primary)]",children:[(0,r.jsx)(J.A,{className:"w-3.5 h-3.5 absolute left-4 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)] pointer-events-none","aria-hidden":!0}),(0,r.jsx)("input",{type:"text",value:t,onChange:e=>a(e.target.value),placeholder:"Filter files...","aria-label":"Filter files",className:"w-full pl-7 pr-6 py-1 text-xs bg-[var(--bg-secondary)]/60 border border-[var(--border)] rounded-md text-[var(--text-primary)] placeholder:text-[var(--text-tertiary)] focus:outline-none focus:border-[var(--accent)] transition-colors"}),t&&(0,r.jsx)("button",{type:"button",onClick:()=>a(""),"aria-label":"Clear filter",className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)] hover:text-[var(--text-primary)]",children:(0,r.jsx)(V.A,{className:"w-3.5 h-3.5","aria-hidden":!0})})]})}var ex=a(31923),eh=a(46644);let em=e=>{let{className:t}=e;return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,r.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})};function ep(e){let{id:t,title:a,updatedAt:n,active:l,onClick:s,estTokens:o,selectMode:i,selected:c,onToggleSelect:u,favorite:x,onToggleFavorite:h,onDelete:m,tags:p,contentClass:f}=e;return(0,r.jsx)("div",{onClick:e=>{if(i){e.preventDefault(),null==u||u();return}s()},className:"\n group relative mx-1.5 my-0.5 px-3 py-2.5 rounded-lg cursor-pointer border-l-[3px] transition-all duration-150\n ".concat(l&&!i||i&&c?"bg-[var(--accent-soft)] border-[var(--accent)]":"border-transparent hover:bg-[var(--accent-soft)]/60","\n "),children:(0,r.jsxs)("div",{className:"flex items-start gap-2.5",children:[i?(0,r.jsx)("input",{type:"checkbox",checked:!!c,onChange:()=>null==u?void 0:u(),onClick:e=>e.stopPropagation(),className:"mt-1 cursor-pointer accent-amber-accent"}):(0,r.jsx)(ea,{contentClass:null!=f?f:null,className:"w-4 h-4 mt-0.5 text-[var(--accent)] shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"text-sm font-semibold truncate transition-colors flex items-center gap-1.5 ".concat(l?"text-[var(--text-primary)]":"text-[var(--text-primary)] group-hover:text-[var(--accent)]"),children:[x&&(0,r.jsx)("span",{className:"text-[var(--accent)] shrink-0",title:"Favorite","aria-label":"Favorite",children:(0,r.jsx)(ex.A,{className:"w-3.5 h-3.5 fill-current","aria-hidden":!0})}),(0,r.jsx)("span",{className:"truncate",children:a})]}),(0,r.jsxs)("div",{className:"text-[11px] mt-1 flex flex-wrap items-center gap-1.5 text-[var(--text-secondary)]",children:[(0,r.jsx)("span",{children:function(e){let t=new Date(e),a=new Date().getTime()-t.getTime(),r=Math.floor(a/6e4),n=Math.floor(a/36e5),l=Math.floor(a/864e5);return r<1?"just now":1===r?"1 min ago":r<60?"".concat(r," mins ago"):1===n?"1 hour ago":n<24?"".concat(n," hours ago"):1===l?"1 day ago":l<30?"".concat(l," days ago"):t.toLocaleDateString()}(n)}),"number"==typeof o&&o>0&&(0,r.jsxs)("span",{className:"text-[var(--text-tertiary)]",children:["\xb7 ~",o<1e3?String(o):o<1e4?(o/1e3).toFixed(1)+"k":Math.round(o/1e3)+"k"," tok"]}),p&&p.length>0&&(0,r.jsxs)("span",{className:"flex flex-wrap gap-1",children:[p.slice(0,3).map(e=>(0,r.jsx)("span",{className:"px-1.5 rounded bg-[var(--accent-soft)] border border-[var(--border)] text-[10px]",children:e},e)),p.length>3&&(0,r.jsxs)("span",{className:"text-[10px] opacity-60",children:["+",p.length-3]})]})]})]}),!i&&(0,r.jsxs)("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity shrink-0",children:[h&&(0,r.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),h(t,!x)},title:x?"Remove from favorites":"Add to favorites","aria-label":x?"Remove from favorites":"Add to favorites",className:"btn btn-icon-sm",children:(0,r.jsx)(ex.A,{className:"w-3.5 h-3.5 ".concat(x?"fill-current text-[var(--accent)]":""),"aria-hidden":!0})}),(0,r.jsx)("button",{type:"button",onClick:async e=>{var r,n;e.stopPropagation();try{let e=await fetch("/api/files/".concat(t,"/download"));if(!e.ok){let t="HTTP ".concat(e.status);try{let a=await e.json();(null==a?void 0:a.error)&&(t=a.error)}catch(e){}d.o.error("Download failed: ".concat(t));return}let n=e.headers.get("content-disposition")||"",l=/filename="([^"]+)"/.exec(n),s=null!=(r=null==l?void 0:l[1])?r:"".concat(a,".md"),o=await e.blob(),i=URL.createObjectURL(o),c=document.createElement("a");c.href=i,c.download=s,document.body.appendChild(c),c.click(),c.remove(),URL.revokeObjectURL(i)}catch(e){d.o.error("Download failed: ".concat(null!=(n=null==e?void 0:e.message)?n:String(e)))}},title:"Download .md","aria-label":"Download file",className:"btn btn-icon-sm",children:(0,r.jsx)(em,{className:"w-3.5 h-3.5"})}),m&&(0,r.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),m(t)},title:"Delete file","aria-label":"Delete file",className:"btn btn-icon-sm btn-destructive",children:(0,r.jsx)(eh.A,{className:"w-3.5 h-3.5","aria-hidden":!0})})]})]})})}var ef=a(85170);function eb(e){let{open:t,onClose:a,projects:l,defaultProjectId:s,defaultFolder:o,onUploaded:i,showJournal:c=!1}=e,[d,u]=(0,n.useState)([]),[x,h]=(0,n.useState)(null!=s?s:""),[m,p]=(0,n.useState)(o),[f,b]=(0,n.useState)([]),[v,g]=(0,n.useState)(""),[j,y]=(0,n.useState)(!1),[w,N]=(0,n.useState)(null),[k,S]=(0,n.useState)(null);(0,n.useEffect)(()=>{t&&(u([]),h(null!=s?s:""),p(o),g(""),N(null),S(null))},[t,s,o]),(0,n.useEffect)(()=>{let e=!1;return(async()=>{let t=x?"/api/folders?projectId=".concat(x):"/api/folders";try{var a;let r=await fetch(t),n=await r.json();e||b(null!=(a=n.folders)?a:[])}catch(t){e||b([])}})(),()=>{e=!0}},[x]);let C=""===x,A=C?(0,ef.AU)(m):null,T=c?ef.is:ef.is.filter(e=>"journal"!==e),F=C?f.filter(e=>T.some(t=>e===t||e.startsWith("".concat(t,"/"))||e.startsWith("".concat(t,"\\")))):f,P=C?(0,ef.UF)(m):null,E=C?d.filter(e=>!(0,ef.zQ)(e.name,m)):[],L=async e=>{var t,a;if(e.preventDefault(),0!==d.length){if(C&&!m)return void S(c?"Pick a KB folder (journal, knowledge, mermaid, or html - or a subfolder).":"Pick a KB folder (knowledge, mermaid, or html - or a subfolder).");if(E.length>0)return void S("".concat(E.length," file(s) don't fit ").concat(A?A+"/":"this folder",": ").concat(E.map(e=>e.name).join(", ")));y(!0),S(null),N(null);try{let e=new FormData;e.append("project_id",""===x?"":String(x)),e.append("folder",m);let a=v.split(",").map(e=>e.trim()).filter(Boolean);for(let t of(a.length&&e.append("tags",JSON.stringify(a)),d))e.append("files",t);let r=await fetch("/api/files/upload",{method:"POST",body:e}),n=await r.json();r.ok?(N(n),i()):S(null!=(t=n.error)?t:"HTTP ".concat(r.status))}catch(e){S(null!=(a=null==e?void 0:e.message)?a:String(e))}finally{y(!1)}}};return t?(0,r.jsx)("div",{className:"fixed inset-0 z-50 bg-black/50 flex items-center justify-center p-4",children:(0,r.jsx)("div",{className:"w-[600px] bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-2xl overflow-hidden",children:(0,r.jsxs)("form",{onSubmit:L,children:[(0,r.jsxs)("div",{className:"px-6 py-4 border-b border-[var(--border-color)] flex items-center justify-between",children:[(0,r.jsx)("h3",{className:"text-lg font-bold text-amber-accent",children:"UPLOAD MARKDOWN FILES"}),(0,r.jsx)("button",{type:"button",onClick:a,className:"btn btn-icon-md","aria-label":"Close dialog",children:(0,r.jsx)(V.A,{className:"w-4 h-4","aria-hidden":!0})})]}),(0,r.jsxs)("div",{className:"p-6 space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[10px] font-bold text-[var(--text-secondary)] tracking-widest mb-1.5",children:"FILES"}),(0,r.jsx)("input",{type:"file",multiple:!0,accept:null===P?".md,.markdown,.mmd,.html,.htm":P||void 0,onChange:e=>{var t;return u(Array.from(null!=(t=e.target.files)?t:[]))},className:"w-full text-sm text-[var(--text-primary)]"}),C&&A&&!(0,ef.$3)(m)&&(0,r.jsxs)("p",{className:"text-[10px] text-[var(--text-secondary)] mt-1 italic",children:[A,"/ accepts ",P," only. Media goes in html/resources/."]}),d.length>0&&(0,r.jsx)("ul",{className:"mt-2 text-xs text-[var(--text-secondary)] max-h-32 overflow-auto",children:d.map((e,t)=>(0,r.jsxs)("li",{className:"flex items-center justify-between py-0.5",children:[(0,r.jsx)("span",{className:"truncate",children:e.name}),(0,r.jsx)("button",{type:"button",className:"btn btn-icon-sm btn-destructive","aria-label":"Remove ".concat(e.name),onClick:()=>u(e=>e.filter((e,a)=>a!==t)),children:(0,r.jsx)(V.A,{className:"w-3.5 h-3.5","aria-hidden":!0})})]},t))})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[10px] font-bold text-[var(--text-secondary)] tracking-widest mb-1.5",children:"PROJECT"}),(0,r.jsxs)("select",{value:""===x?"":String(x),onChange:e=>h(""===e.target.value?"":Number(e.target.value)),className:"w-full bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded px-3 py-2 text-sm text-[var(--text-primary)] outline-none focus:border-amber-accent/50 cursor-pointer",children:[(0,r.jsx)("option",{value:"",children:"- Knowledge Base -"}),l.map(e=>(0,r.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[10px] font-bold text-[var(--text-secondary)] tracking-widest mb-1.5",children:"FOLDER"}),C&&0===F.length?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("input",{type:"text",value:m,onChange:e=>p(e.target.value),placeholder:c?"e.g. knowledge or journal/2026":"e.g. knowledge or mermaid",list:"kb-bucket-hints",className:"w-full bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded px-3 py-2 text-sm text-[var(--text-primary)] outline-none focus:border-amber-accent/50",required:!0}),(0,r.jsx)("datalist",{id:"kb-bucket-hints",children:T.map(e=>(0,r.jsx)("option",{value:e},e))})]}):(0,r.jsxs)("select",{value:m,onChange:e=>p(e.target.value),className:"w-full bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded px-3 py-2 text-sm text-[var(--text-primary)] outline-none focus:border-amber-accent/50 cursor-pointer",required:C,children:[C?(0,r.jsx)("option",{value:"",disabled:!0,children:"- Pick a KB folder -"}):(0,r.jsx)("option",{value:"",children:"- Root level -"}),F.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[10px] font-bold text-[var(--text-secondary)] tracking-widest mb-1.5",children:"TAGS"}),(0,r.jsx)("input",{type:"text",value:v,onChange:e=>g(e.target.value),placeholder:"comma, separated, tags",className:"w-full bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded px-3 py-2 text-sm text-[var(--text-primary)] outline-none focus:border-amber-accent/50"})]}),k&&(0,r.jsx)("div",{className:"text-sm text-[var(--danger)]",children:k}),w&&(0,r.jsxs)("div",{className:"text-sm text-[var(--text-secondary)]",children:["Uploaded ",w.uploaded.length," \xb7 renamed ",w.uploaded.filter(e=>e.final_name!==e.original_name).length," \xb7 rejected ",w.rejected.length,(w.uploaded.some(e=>e.final_name!==e.original_name)||w.rejected.length>0)&&(0,r.jsxs)("details",{className:"mt-2",children:[(0,r.jsx)("summary",{className:"cursor-pointer",children:"Details"}),(0,r.jsxs)("ul",{className:"mt-1 text-xs",children:[w.uploaded.filter(e=>e.final_name!==e.original_name).map((e,t)=>(0,r.jsxs)("li",{children:["renamed: ",e.original_name," → ",e.final_name]},"r".concat(t))),w.rejected.map((e,t)=>(0,r.jsxs)("li",{children:["rejected: ",e.name," (",e.reason,")"]},"x".concat(t)))]})]})]})]}),(0,r.jsxs)("div",{className:"px-6 py-4 border-t border-[var(--border-color)] flex justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:a,className:"btn btn-md",children:"Close"}),(0,r.jsx)("button",{type:"submit",disabled:j||0===d.length,className:"btn btn-md",children:j?"Uploading…":"Upload"})]})]})})}):null}function ev(e){let{open:t,onClose:a,onClipped:l}=e,[s,o]=(0,n.useState)(""),[i,c]=(0,n.useState)(""),[d,u]=(0,n.useState)(!1),[x,h]=(0,n.useState)(null);(0,n.useEffect)(()=>{t&&(o(""),c(""),h(null),u(!1))},[t]);let m=async e=>{var t,r;if(e.preventDefault(),s.trim()){u(!0),h(null);try{let e=await fetch("/api/clip",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:s.trim(),title:i.trim()||void 0})}),r=await e.json();if(!e.ok)return void h(null!=(t=null==r?void 0:r.error)?t:"HTTP ".concat(e.status));l(),a()}catch(e){h(null!=(r=null==e?void 0:e.message)?r:String(e))}finally{u(!1)}}};return t?(0,r.jsx)("div",{className:"fixed inset-0 z-50 bg-black/50 flex items-center justify-center p-4",children:(0,r.jsx)("div",{className:"w-[600px] bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-2xl overflow-hidden",children:(0,r.jsxs)("form",{onSubmit:m,children:[(0,r.jsxs)("div",{className:"px-6 py-4 border-b border-[var(--border-color)] flex items-center justify-between",children:[(0,r.jsx)("h3",{className:"text-lg font-bold text-amber-accent",children:"CLIP URL"}),(0,r.jsx)("button",{type:"button",onClick:a,className:"btn btn-icon-md","aria-label":"Close dialog",children:(0,r.jsx)(V.A,{className:"w-4 h-4","aria-hidden":!0})})]}),(0,r.jsxs)("div",{className:"p-6 space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[10px] font-bold text-[var(--text-secondary)] tracking-widest mb-1.5",children:"URL"}),(0,r.jsx)("input",{type:"url",required:!0,value:s,onChange:e=>o(e.target.value),placeholder:"https://example.com/article",disabled:d,className:"w-full bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded px-3 py-2 text-sm text-[var(--text-primary)] outline-none focus:border-amber-accent/50"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[10px] font-bold text-[var(--text-secondary)] tracking-widest mb-1.5",children:"TITLE (OPTIONAL)"}),(0,r.jsx)("input",{type:"text",value:i,onChange:e=>c(e.target.value),placeholder:"Defaults to page title",disabled:d,className:"w-full bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded px-3 py-2 text-sm text-[var(--text-primary)] outline-none focus:border-amber-accent/50"})]}),x&&(0,r.jsx)("div",{className:"text-sm text-[var(--danger)]",children:x})]}),(0,r.jsxs)("div",{className:"px-6 py-4 border-t border-[var(--border-color)] flex justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:a,className:"btn btn-md",children:"Close"}),(0,r.jsx)("button",{type:"submit",disabled:d||!s.trim(),className:"btn btn-md",children:d?"Clipping…":"Clip"})]})]})})}):null}var eg=a(56570);let ej=[{id:"generic",label:"Universal — AGENTS.md (Recommended)",path:"AGENTS.md"},{id:"claude-code",label:"Claude Code (CLAUDE.md)",path:"CLAUDE.md"},{id:"codex",label:"Codex CLI (AGENTS.md)",path:"AGENTS.md"},{id:"cursor",label:"Cursor (.cursor/rules/kontexta.mdc)",path:".cursor/rules/kontexta.mdc"},{id:"windsurf",label:"Windsurf (AGENTS.md)",path:"AGENTS.md"},{id:"opencode",label:"OpenCode (AGENTS.md)",path:"AGENTS.md"},{id:"gemini",label:"Gemini CLI (GEMINI.md)",path:"GEMINI.md"},{id:"antigravity",label:"Antigravity (ANTIGRAVITY.md)",path:"ANTIGRAVITY.md"},{id:"copilot",label:"GitHub Copilot (.github/copilot-instructions.md)",path:".github/copilot-instructions.md"},{id:"cline",label:"Cline (.clinerules)",path:".clinerules"},{id:"continue",label:"Continue (.continue/rules/kontexta.md)",path:".continue/rules/kontexta.md"},{id:"aider",label:"Aider (.aider/kontexta.md)",path:".aider/kontexta.md"}];function ey(e){var t;let{isOpen:a,onClose:l,projectId:s,projectName:o,onOnboarded:i}=e,[c,u]=(0,n.useState)("generic"),[x,h]=(0,n.useState)(!1),m=null!=(t=ej.find(e=>e.id===c))?t:ej[0],p=async()=>{h(!0);try{let e=await fetch("/api/projects/".concat(s,"/onboard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetAgent:c})});if(e.ok)d.o.success("Onboarded ".concat(o)),i(),l();else{let t=await e.json().catch(()=>({}));d.o.error(t.error||"Onboarding failed: HTTP ".concat(e.status))}}catch(e){d.o.error("Failed to connect to server")}finally{h(!1)}};return(0,r.jsx)(eg.l,{open:a,onClose:l,title:"Onboard agent",widthClass:"max-w-[500px]",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"text-sm text-[var(--text-secondary)] leading-relaxed",children:["Scaffold workflow rules for ",(0,r.jsx)("strong",{children:o}),". This writes workflow rules to"," ",(0,r.jsx)("code",{children:m.path})," (and ",(0,r.jsx)("code",{children:"KONTEXTA.md"}),") in the project root."]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"block text-[10px] font-bold text-[var(--text-secondary)] tracking-widest uppercase",children:"Target agent"}),(0,r.jsx)("select",{value:c,onChange:e=>u(e.target.value),className:"w-full bg-[var(--bg-secondary)] border border-[var(--border)] rounded px-3 py-2 text-sm text-[var(--text-primary)] outline-none focus:border-amber-accent/50 cursor-pointer",children:ej.map(e=>(0,r.jsx)("option",{value:e.id,children:e.label},e.id))})]}),"aider"===c&&(0,r.jsxs)("div",{className:"p-3 bg-amber-500/5 border border-amber-500/20 rounded text-[11px] text-amber-600 dark:text-amber-400 leading-normal",children:[(0,r.jsx)("strong",{children:"Aider note:"})," Integration is file-based. After onboarding, ensure your ",(0,r.jsx)("code",{children:".aider.conf.yml"})," reads the new file."]}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:l,className:"btn btn-md",disabled:x,children:"Cancel"}),(0,r.jsx)("button",{type:"button",onClick:p,disabled:x,className:"btn btn-md min-w-[140px]",children:x?"Onboarding…":"Onboard agent"})]})]})})}var ew=a(17695);function eN(e){let{open:t,title:a,onClose:n,onConfirm:l,loading:s}=e;return(0,r.jsx)(ew.T,{open:t,onClose:n,onConfirm:l,title:"Delete file",message:(0,r.jsxs)(r.Fragment,{children:['Delete "',(0,r.jsx)("span",{className:"font-bold text-[var(--text-primary)]",children:a}),'"? Knowledge Base files are recoverable from git history (Time Travel). Project files are only removed from the index. The file on disk is untouched.']}),confirmLabel:"Delete",destructive:!0,loading:s})}function ek(e){var t;let{files:a,selectedFileId:l,onSelectFile:s,sortBy:o,onSortChange:i,selectedFolder:c,selectedProject:u,selectedSection:x,basePath:h,onUnregisterProject:m,onDeleteFolder:p,loading:f,projects:b,onUploaded:v,onRefresh:j,onOnboarded:y,refreshing:w,onNewFile:N,onToggleFavorite:k,onDeleteFile:S,showJournal:C=!1}=e,[A,T]=(0,n.useState)(""),[F,P]=(0,n.useState)(!1),[E,L]=(0,n.useState)(!1),[_,D]=(0,n.useState)(!1),[M,I]=(0,n.useState)(!1),[O,U]=(0,n.useState)(new Set),[H,B]=(0,n.useState)(!1),[G,z]=(0,n.useState)(!1),[K,W]=(0,n.useState)(150),[q,$]=(0,n.useState)(null),[Y,Z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{U(new Set),W(150)},[c,null==u?void 0:u.id,x,A,o]);let X=(0,n.useMemo)(()=>{let e=[...a],t=e=>(e||"").replace(/\\/g,"/").replace(/\/+$/,""),r=(e,a)=>{if(!e||!a)return!1;let r=t(e),n=t(a)+"/";return r.startsWith(n)};if("projects"===x)if(u){let a=h||u.path;if(a){let n=t(a)+"/";if(c){let a=n+t(c);e=e.filter(e=>r(e.path,a))}else e=e.filter(e=>e.project_id===u.id)}else e=e.filter(e=>e.project_id===u.id)}else e=[];else if("favorites"===x)e=[...a];else if("tags"===x)e=[...a];else if("knowledge"===x){if(e=e.filter(e=>!e.project_id),h){let a=t(h)+"/";if(c){let n=a+t(c);e=e.filter(e=>r(e.path,n))}}}else e=[];switch(o){case"name":e.sort((e,t)=>e.title.localeCompare(t.title));break;case"updated_at":e.sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime());break;case"created_at":e.sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime())}let n=A.trim();if(n){let t=/^(?:#|(?:(?:file_)?id|file):\s*#?)(\d+)$/i.exec(n);if(t){let a=Number(t[1]);e=e.filter(e=>e.id===a)}else{let t=n.toLowerCase(),a=/^\d+$/.test(n)?Number(n):null;e=e.filter(e=>null!==a&&e.id===a||e.title.toLowerCase().includes(t))}}return e},[a,o,c,u,x,h,A]);return(0,n.useEffect)(()=>{if(null==l)return;let e=X.findIndex(e=>e.id===l);e>=K&&W(e+150)},[l,X,K]),(0,r.jsxs)("div",{className:"flex flex-col h-full",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]/30",children:[(0,r.jsx)("div",{children:(0,r.jsx)(R,{align:"start",trigger:(0,r.jsxs)("button",{type:"button",className:"btn btn-sm btn-primary",title:"Add content to the knowledge base",children:["+ New ",(0,r.jsx)("span",{className:"opacity-80 text-xs",children:"▾"})]}),items:[{label:"New File",icon:(0,r.jsx)("span",{children:"+"}),onSelect:N},{label:"Upload Files",icon:(0,r.jsx)("span",{children:"↑"}),onSelect:()=>P(!0)},{label:"Clip URL",icon:(0,r.jsx)(ec.A,{className:"w-3.5 h-3.5","aria-hidden":!0}),onSelect:()=>B(!0)}]})}),"projects"===x&&u&&(0,r.jsx)("div",{children:(0,r.jsx)(R,{align:"start",trigger:(0,r.jsxs)("button",{type:"button",className:"btn btn-sm btn-outline",title:"Project actions",children:["Project ",(0,r.jsx)("span",{className:"opacity-60 text-xs",children:"▾"})]}),items:[{label:"Export ZIP",icon:(0,r.jsx)("span",{children:"↓"}),onSelect:()=>{let e=c?"/api/export/zip?project_id=".concat(u.id,"&folder=").concat(encodeURIComponent(c)):"/api/export/zip?project_id=".concat(u.id),t=document.createElement("a");t.href=e,t.download="",document.body.appendChild(t),t.click(),t.remove()}},{label:"Scan for New Files",icon:(0,r.jsx)(J.A,{className:"w-3.5 h-3.5","aria-hidden":!0}),onSelect:j},{label:"Onboard Agent",icon:(0,r.jsx)("span",{children:"✨"}),onSelect:()=>z(!0)},...!c&&m?[{label:"Unregister",icon:(0,r.jsx)(V.A,{className:"w-3.5 h-3.5","aria-hidden":!0}),onSelect:m,destructive:!0}]:[]]})}),(0,r.jsx)("button",{type:"button",onClick:()=>{L(e=>!e),U(new Set)},className:"btn btn-sm ml-auto ".concat(E?"bg-[var(--accent-soft)] text-[var(--accent)] border-[var(--border-strong)]":"btn-outline"),title:"Toggle multi-select",children:E?"Done":"Select"}),(0,r.jsx)("button",{type:"button",onClick:j,disabled:w,className:"btn btn-icon-sm btn-outline ".concat(w?"opacity-50":""),title:"Refresh (scan disk for changes)","aria-label":"Refresh",children:(0,r.jsx)(g.A,{className:"w-3.5 h-3.5 ".concat(w?"animate-spin":""),"aria-hidden":!0})})]}),"projects"===x&&u&&u.agent_rules&&"up_to_date"!==u.agent_rules.status&&(0,r.jsxs)("div",{className:"px-3 py-2 flex items-center justify-between gap-3 text-[11px] bg-amber-500/5 border-b border-amber-500/20 text-amber-600 dark:text-amber-400",children:[(0,r.jsx)("span",{children:"none"===u.agent_rules.status?"This project has no agent instructions file yet - your AI agent won't know Kontexta is registered.":"This project's agent rules are outdated (v".concat(u.agent_rules.latest_version," available).")}),(0,r.jsx)("button",{type:"button",onClick:()=>z(!0),className:"btn btn-sm shrink-0",children:"Onboard Agent"})]}),(0,r.jsxs)("div",{className:"bp-annotation bp-dashed px-3 py-2 flex items-center justify-between text-[11px] uppercase tracking-wider text-[var(--text-secondary)] border-b border-[var(--border)]",children:[(0,r.jsxs)("span",{children:[X.length," ",1===X.length?"file":"files",(()=>{var e;let t=X.reduce((e,t)=>{var a;return e+(null!=(a=t.est_tokens)?a:0)},0);return t>0?" \xb7 ~".concat((e=t)<1e3?String(e):e<1e4?"".concat((e/1e3).toFixed(1),"k"):e<1e6?"".concat(Math.round(e/1e3),"k"):"".concat((e/1e6).toFixed(1),"M")," tok"):""})()]}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsxs)("select",{value:o,onChange:e=>i(e.target.value),className:"bg-transparent text-[11px] uppercase tracking-wider focus:outline-none cursor-pointer",children:[(0,r.jsx)("option",{value:"updated_at",className:"bg-[var(--bg-primary)] text-[var(--text-primary)]",children:"updated"}),(0,r.jsx)("option",{value:"created_at",className:"bg-[var(--bg-primary)] text-[var(--text-primary)]",children:"created"}),(0,r.jsx)("option",{value:"name",className:"bg-[var(--bg-primary)] text-[var(--text-primary)]",children:"name"})]})})]}),x&&(0,r.jsx)(eu,{value:A,onChange:T}),(()=>{let e=new Set(X.map(e=>e.id)),t=[...O].filter(t=>e.has(t)),a=u?String(u.id):"kb",n=async()=>{if(0===t.length||_)return;D(!0);let e=[];for(let n of t){var a,r;try{let t=await fetch("/api/files/".concat(n),{method:"DELETE"});if(!t.ok){let r=await t.json().catch(()=>({}));e.push({id:n,error:null!=(a=null==r?void 0:r.error)?a:"HTTP ".concat(t.status)})}}catch(t){e.push({id:n,error:null!=(r=null==t?void 0:t.message)?r:"Network error"})}}D(!1),I(!1),U(new Set),j();let n=t.length-e.length;e.length>0?(console.error("[bulk-delete] failures:",e),n>0&&d.o.success("Deleted ".concat(n," file(s)")),d.o.error("".concat(e.length," file(s) failed to delete: ")+e.slice(0,5).map(e=>"#".concat(e.id," (").concat(e.error,")")).join(", ")+(e.length>5?", …and ".concat(e.length-5," more (see console)"):""))):d.o.success("Deleted ".concat(n," file(s)"))};return(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[E&&t.length>0&&(0,r.jsxs)("div",{className:"sticky top-0 z-10 px-3 py-2 bg-[var(--bg-secondary)] border-b border-amber-accent/40 flex items-center justify-between gap-2 text-[11px]",children:[(0,r.jsxs)("span",{className:"whitespace-nowrap shrink-0",children:[t.length," selected"]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,r.jsx)("a",{href:"/api/export/zip?file_ids=".concat(t.join(","),"&scope=").concat(a),download:!0,className:"px-2 py-1 bg-amber-accent text-black font-bold rounded whitespace-nowrap leading-none",title:"Download selected files as ZIP",children:"ZIP"}),(0,r.jsx)("button",{type:"button",onClick:()=>I(!0),disabled:_,className:"px-2 py-1 bg-[var(--danger)] text-white font-bold rounded whitespace-nowrap leading-none ".concat(_?"opacity-50":"hover:bg-[color-mix(in_srgb,var(--danger)_85%,black)]"),title:"Delete ".concat(t.length," selected file(s)"),children:_?"…":"Delete"}),(0,r.jsx)("button",{type:"button",onClick:()=>U(new Set),className:"px-2 py-1 border border-[var(--border)] rounded whitespace-nowrap leading-none hover:bg-[var(--bg-tertiary)]",title:"Clear selection",children:"Clear"})]})]}),(0,r.jsx)(ew.T,{open:M,onClose:()=>I(!1),onConfirm:n,title:"Delete ".concat(t.length," file").concat(1===t.length?"":"s","?"),message:"Knowledge Base files will be removed from disk and the deletion will be committed to git (recoverable via Time Travel). Project files are only un-indexed; the source file on disk is left intact.",confirmLabel:"Delete ".concat(t.length," file").concat(1===t.length?"":"s"),destructive:!0,loading:_}),X.length>0?(0,r.jsxs)(r.Fragment,{children:[X.slice(0,K).map(e=>{var t,a;return(0,r.jsx)(ep,{id:e.id,title:e.title,updatedAt:e.updated_at,active:e.id===l,onClick:()=>s(e.id),estTokens:e.est_tokens,favorite:e.favorite,onToggleFavorite:k,onDelete:S?()=>$({id:e.id,title:e.title}):void 0,tags:null!=(t=e.tags)?t:void 0,contentClass:null!=(a=e.content_class)?a:null,selectMode:E,selected:O.has(e.id),onToggleSelect:()=>{U(t=>{let a=new Set(t);return a.has(e.id)?a.delete(e.id):a.add(e.id),a})}},e.id)}),X.length>K&&(0,r.jsx)("div",{className:"p-3 flex justify-center border-b border-[var(--border)]",children:(0,r.jsxs)("button",{type:"button",onClick:()=>W(e=>e+150),className:"btn btn-sm text-xs w-full",children:["Show more (",X.length-K," remaining)"]})})]}):f||"projects"===x&&!u?(0,r.jsx)("div",{"aria-label":"Loading files",role:"status",children:[0,1,2,3].map(e=>(0,r.jsxs)("div",{className:"px-3 py-2 border-b border-[var(--bg-tertiary)]",children:[(0,r.jsx)("div",{className:"skeleton h-3.5",style:{width:"".concat(60+13*e%30,"%")}}),(0,r.jsx)("div",{className:"skeleton h-2.5 mt-2",style:{width:"".concat(30+7*e%20,"%")}})]},e))}):x?(0,r.jsx)(ee.p,{icon:(0,r.jsx)(ed.A,{className:"w-16 h-16 opacity-30 dark-icon","aria-hidden":!0}),title:"Folder is empty",hint:"This folder doesn't contain any indexed context files.",action:"knowledge"===x&&c&&!(0,ef.BZ)(c)&&p?(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)("div",{className:"h-px w-16 bg-[var(--border)]"}),(0,r.jsx)("button",{onClick:p,className:"btn btn-md btn-outline btn-destructive",children:"Delete this folder"}),(0,r.jsx)("p",{className:"text-[11px] text-[var(--muted)]",children:"Permanent action"})]}):void 0}):(0,r.jsx)(ee.p,{icon:(0,r.jsx)(ed.A,{className:"w-16 h-16 opacity-30 dark-icon","aria-hidden":!0}),title:"No Selection",hint:"Please select a project or the Knowledge Base from the sidebar to view files."})]})})(),(0,r.jsx)(eb,{open:F,onClose:()=>P(!1),projects:null!=b?b:[],defaultProjectId:"projects"===x&&u?u.id:null,defaultFolder:null!=c?c:"",onUploaded:()=>{P(!1),null==v||v()},showJournal:C}),(0,r.jsx)(ev,{open:H,onClose:()=>B(!1),onClipped:()=>{j()}}),u&&(0,r.jsx)(ey,{isOpen:G,onClose:()=>z(!1),projectId:u.id,projectName:u.name,onOnboarded:()=>{(null!=y?y:j)()}}),(0,r.jsx)(eN,{open:null!==q,title:null!=(t=null==q?void 0:q.title)?t:"",onClose:()=>{Y||$(null)},loading:Y,onConfirm:async()=>{if(q&&S){Z(!0);try{await S(q.id),$(null)}finally{Z(!1)}}}})]})}var eS=a(52436),eC=a(83459),eA=a(63147),eT=a(27962),eF=a(78302),eP=a(72388),eE=a(35047),eL=a(6519);function e_(e){let{html:t}=e,a=(0,n.useMemo)(()=>'<!doctype html><html><head><meta charset="utf-8"><base href="/api/reports/"><style>body{font-family:-apple-system,Segoe UI,Roboto,sans-serif;margin:16px;color:#111}img{max-width:100%}</style></head><body>'.concat(t,"</body></html>"),[t]);return(0,r.jsx)("iframe",{title:"report",sandbox:"allow-same-origin",srcDoc:a,style:{width:"100%",height:"100%",border:"0",background:"white"}})}function eR(e){let{fileId:t,initial:a,expectedUpdatedAt:l,onClose:s,onSaved:o,onDirtyChange:i}=e,[c,u]=(0,n.useState)(a),[x,h]=(0,n.useState)(!1),[m,p]=(0,n.useState)(!1),f=c!==a;function b(){if(f)return void p(!0);s()}async function v(){h(!0);try{let e=await fetch("/api/files/".concat(t),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:c,expected_updated_at:l})});if(409===e.status)return void d.o.error("This file changed elsewhere since you opened it - reload before saving to avoid overwriting the newer version.");if(!e.ok){let t=await e.text().catch(()=>"");d.o.error("Save failed".concat(t?": ".concat(t):""));return}let a=await e.json();o(a),s()}catch(t){var e;d.o.error("Save failed: ".concat(null!=(e=null==t?void 0:t.message)?e:String(t)))}finally{h(!1)}}return(0,r.jsxs)(eg.l,{open:!0,onClose:b,title:"Edit HTML source",widthClass:"max-w-4xl",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-4",style:{height:"min(70vh, 600px)"},children:[(0,r.jsx)("textarea",{value:c,onChange:e=>{let t=e.target.value;u(t),null==i||i(t!==a)},className:"flex-1 font-mono text-sm p-3 border border-[var(--border)] rounded resize-none bg-[var(--bg-secondary)] text-[var(--text-primary)]",spellCheck:!1}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:b,disabled:x,className:"btn btn-md",children:"Cancel"}),(0,r.jsx)("button",{type:"button",onClick:v,disabled:x,className:"btn btn-md",children:x?"Saving...":"Save"})]})]}),(0,r.jsx)(ew.T,{open:m,onClose:()=>p(!1),onConfirm:()=>{p(!1),s()},title:"Unsaved changes",message:"You have unsaved changes. Discard them?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0})]})}var eD=a(9432),eM=a(52010),eI=a(62291),eO=a(55956),eU=a(19099),eH=a(31028),eB=a(29518),eG=a(13167);function ez(e){let{content:t,onChange:a,viewMode:l="edit",onSave:s}=e,o=(0,n.useRef)(null),i=(e,r,n)=>{let l=o.current;if(!l)return;let s=l.selectionStart,i=l.selectionEnd,c=t.slice(s,i)||n;a(t.slice(0,s)+e+c+r+t.slice(i)),requestAnimationFrame(()=>{l.focus(),l.setSelectionRange(s+e.length,s+e.length+c.length)})},c=e=>{let r=o.current;if(!r)return;let n=r.selectionStart,l=0===n?0:t.lastIndexOf("\n",n-1)+1;a(t.slice(0,l)+e+t.slice(l)),requestAnimationFrame(()=>{r.focus(),r.setSelectionRange(n+e.length,n+e.length)})};return(0,r.jsxs)("div",{className:"flex flex-col h-full bg-[var(--bg-primary)]",children:[(0,r.jsxs)("div",{role:"toolbar","aria-label":"Markdown formatting",className:"flex flex-wrap items-center gap-1 px-4 py-1.5 border-b border-[var(--border)] bg-[var(--bg-secondary)]/50 shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:()=>c("## "),className:"btn btn-icon-sm",title:"Heading 2","aria-label":"Insert heading",children:(0,r.jsx)(eD.A,{className:"w-3.5 h-3.5","aria-hidden":!0})}),(0,r.jsx)("button",{type:"button",onClick:()=>i("**","**","bold text"),className:"btn btn-icon-sm",title:"Bold","aria-label":"Bold",children:(0,r.jsx)(eM.A,{className:"w-3.5 h-3.5","aria-hidden":!0})}),(0,r.jsx)("button",{type:"button",onClick:()=>i("*","*","italic text"),className:"btn btn-icon-sm",title:"Italic","aria-label":"Italic",children:(0,r.jsx)(eI.A,{className:"w-3.5 h-3.5","aria-hidden":!0})}),(0,r.jsx)("button",{type:"button",onClick:()=>i("`","`","code"),className:"btn btn-icon-sm",title:"Inline code","aria-label":"Inline code",children:(0,r.jsx)(eO.A,{className:"w-3.5 h-3.5","aria-hidden":!0})}),(0,r.jsx)("span",{className:"w-px h-4 bg-[var(--border)] mx-1","aria-hidden":!0}),(0,r.jsx)("button",{type:"button",onClick:()=>c("- "),className:"btn btn-icon-sm",title:"Bullet list","aria-label":"Bullet list",children:(0,r.jsx)(eU.A,{className:"w-3.5 h-3.5","aria-hidden":!0})}),(0,r.jsx)("button",{type:"button",onClick:()=>c("- [ ] "),className:"btn btn-icon-sm",title:"Checklist item","aria-label":"Checklist",children:(0,r.jsx)(eH.A,{className:"w-3.5 h-3.5","aria-hidden":!0})}),(0,r.jsx)("button",{type:"button",onClick:()=>i("[","](https://)","link text"),className:"btn btn-icon-sm",title:"Link","aria-label":"Insert link",children:(0,r.jsx)(eB.A,{className:"w-3.5 h-3.5","aria-hidden":!0})}),(0,r.jsx)("button",{type:"button",onClick:()=>(e=>{let r=o.current;if(!r)return;let n=r.selectionStart,l=(n>0&&"\n"!==t[n-1]?"\n\n":"")+e;a(t.slice(0,n)+l+t.slice(n)),requestAnimationFrame(()=>{r.focus();let e=n+l.length;r.setSelectionRange(e,e)})})("| Column 1 | Column 2 |\n| --- | --- |\n| Value 1 | Value 2 |\n"),className:"btn btn-icon-sm",title:"Insert table","aria-label":"Insert table",children:(0,r.jsx)(eG.A,{className:"w-3.5 h-3.5","aria-hidden":!0})})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col lg:flex-row overflow-hidden",children:[(0,r.jsx)("textarea",{ref:o,value:t,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key.toLowerCase()&&(e.preventDefault(),null==s||s())},className:"".concat("split"===l?"lg:w-1/2 border-b lg:border-b-0 lg:border-r border-[var(--border)]":"w-full"," flex-1 h-full p-6 sm:p-8 bg-transparent border-none outline-none resize-none font-mono text-[14px] text-[var(--text-primary)] leading-relaxed overflow-y-auto scrollbar-thin"),placeholder:"Start typing your markdown...",spellCheck:!1}),"split"===l&&(0,r.jsx)("div",{className:"lg:w-1/2 flex-1 h-full overflow-y-auto bg-[var(--bg-secondary)]/20 p-6 sm:p-8 scrollbar-thin",children:(0,r.jsx)(eE.Gd,{content:t})})]})]})}var eK=a(12570),eW=a(94495),eJ=a(42528),eV=a(95852),eq=a(53352),e$=a(35811),eY=a(40873),eZ=a(49799);let eX=[{key:"name",title:"Name",hint:"How the agent should address you.",icon:e=>(0,r.jsx)(eK.A,{className:e,"aria-hidden":!0}),placeholder:"e.g. Safiyu"},{key:"role",title:"Role",hint:"Your role, focus, and areas of expertise.",icon:e=>(0,r.jsx)(eW.A,{className:e,"aria-hidden":!0}),placeholder:"e.g. Full-stack engineer, platform core"},{key:"vision",title:"Vision",hint:"Where you want your work to go over the medium term.",icon:e=>(0,r.jsx)(eJ.A,{className:e,"aria-hidden":!0}),placeholder:"e.g. Improve API performance and streamline developer workflows"},{key:"roadmap",title:"Roadmap",hint:"Active initiatives, upcoming milestones, current themes.",icon:e=>(0,r.jsx)(eV.A,{className:e,"aria-hidden":!0}),placeholder:"e.g. Q3 auth refactor; performance benchmarking"},{key:"preferences",title:"Preferences",hint:"General working style, tools, and communication quirks.",icon:e=>(0,r.jsx)(j.A,{className:e,"aria-hidden":!0}),placeholder:"e.g. Prefers TypeScript, concise explanations, test-driven development"},{key:"sessionCodingStyle",title:"Session coding style",hint:"Hard rules the agent must honor every session. Comment style, git etiquette, review gates.",icon:e=>(0,r.jsx)(eq.A,{className:e,"aria-hidden":!0}),placeholder:"e.g. one-line comments only; no auto push to git; ask before schema migrations"},{key:"teamMembers",title:"Team members and roles",hint:"People you work with, so the agent names them correctly in summaries and updates.",icon:e=>(0,r.jsx)(e$.A,{className:e,"aria-hidden":!0}),placeholder:"e.g. Alice - Product Manager\nBob - DevOps / SRE"},{key:"notes",title:"Notes",hint:"Anything else worth remembering that doesn't fit elsewhere.",icon:e=>(0,r.jsx)(eY.A,{className:e,"aria-hidden":!0}),placeholder:"Free-form scratch space."}],eQ=new Set(eX.map(e=>e.title.toLowerCase()));function e0(e){let t={name:"",role:"",vision:"",roadmap:"",preferences:"",sessionCodingStyle:"",teamMembers:"",notes:""},a=[],r=e.replace(/^\s*#\s+Profile\s*$/m,"").split("\n"),n=[],l=null,s=null,o="",i=[],c=()=>{let e=i.join("\n").replace(/^\s+|\s+$/g,"");"required"===l&&s?t[s]=e:"custom"===l&&a.push({title:o,body:e}),i=[]};for(let e of r){let t=/^##\s+(.+?)\s*$/.exec(e);if(t){null!==l?c():n=i.slice();let e=function(e){let t=eX.find(t=>t.title.toLowerCase()===e.toLowerCase());return t?t.key:null}(t[1]);e?(l="required",s=e):(l="custom",o=t[1],s=null),i=[]}else i.push(e)}return null!==l?c():n=i.slice(),{preamble:n.join("\n").replace(/^\s+|\s+$/g,""),required:t,custom:a}}function e1(e){let t=["# Profile",""];for(let a of(e.preamble&&t.push(e.preamble,""),eX))t.push("## ".concat(a.title),e.required[a.key]||"","");for(let a of e.custom){let e=a.title.trim();e&&(eQ.has(e.toLowerCase())||t.push("## ".concat(e),a.body||"",""))}return t.join("\n").replace(/\n{3,}/g,"\n\n")}function e2(e){let{onDirtyChange:t,onChanged:a}=e,[l,s]=(0,n.useState)(!0),[o,c]=(0,n.useState)(null),[u,x]=(0,n.useState)({preamble:"",required:{name:"",role:"",vision:"",roadmap:"",preferences:"",sessionCodingStyle:"",teamMembers:"",notes:""},custom:[]}),[h,m]=(0,n.useState)(""),[f,b]=(0,n.useState)(!1),[v,g]=(0,n.useState)(""),[j,y]=(0,n.useState)(!1),w=(0,n.useMemo)(()=>f?h:e1(u),[f,h,u]),N=!l&&w.trim()!==v.trim(),k=eX.filter(e=>!u.required[e.key].trim()).length;(0,n.useEffect)(()=>{null==t||t(N)},[N,t]);let S=(0,n.useRef)(t);(0,n.useEffect)(()=>{S.current=t},[t]),(0,n.useEffect)(()=>()=>{var e;return null==(e=S.current)?void 0:e.call(S,!1)},[]);let C=(0,n.useRef)(!1);(0,n.useEffect)(()=>{C.current||(C.current=!0,(async()=>{try{let e=await fetch("/api/profile");if(!e.ok)throw Error("HTTP ".concat(e.status));let t=await e.json(),a=t.exists?t.content:"",r=e1(e0(a));x(e0(a)),m(r),g(r)}catch(t){var e;c(null!=(e=null==t?void 0:t.message)?e:"Failed to load profile")}finally{s(!1)}})())},[]);let A=(e,t)=>{x(a=>{let r=[...a.custom];return r[e]={...r[e],...t},{...a,custom:r}})},T=async()=>{var e,t,r;y(!0);try{let r=await fetch("/api/profile",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:w})}),n=await r.json();if(!r.ok)throw Error(null!=(e=null==n?void 0:n.error)?e:"HTTP ".concat(r.status));let l=null!=(t=n.content)?t:w,s=e1(e0(l));g(s),x(e0(l)),m(s),d.o.success("Profile saved"),null==a||a()}catch(e){d.o.error("Failed to save profile: ".concat(null!=(r=null==e?void 0:e.message)?r:"Network error"))}finally{y(!1)}};if(l)return(0,r.jsxs)("div",{className:"h-full flex flex-col animate-fade-in",children:[(0,r.jsxs)("div",{className:"border-b border-[var(--border)] px-6 py-4",children:[(0,r.jsx)("div",{className:"skeleton h-6 w-48 mb-2"}),(0,r.jsx)("div",{className:"skeleton h-4 w-32"})]}),(0,r.jsxs)("div",{className:"flex-1 p-6 space-y-4",children:[(0,r.jsx)("div",{className:"skeleton h-4 w-full"}),(0,r.jsx)("div",{className:"skeleton h-4 w-5/6"})]})]});if(o)return(0,r.jsx)("div",{className:"h-full flex items-center justify-center p-6 text-[var(--text-secondary)]",children:(0,r.jsx)("div",{className:"text-center max-w-md",children:(0,r.jsxs)("p",{className:"text-sm",children:["Failed to load profile: ",o]})})});let F=u.required.name.trim()||"Set your name",P=u.required.role.trim(),E=Math.round((eX.length-k)/eX.length*100);return(0,r.jsxs)("div",{className:"h-full flex flex-col animate-fade-in bg-[var(--bg-primary)]",children:[(0,r.jsxs)("div",{className:"h-11 px-5 border-b border-[var(--border)] flex items-center gap-3 sticky top-0 bg-[var(--bg-primary)] z-20",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-[var(--text-primary)]",children:[(0,r.jsx)($.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0}),(0,r.jsx)("span",{className:"text-[13px] font-semibold uppercase tracking-wider",children:"Profile"})]}),(0,r.jsx)("span",{className:"text-[11px] text-[var(--text-secondary)] font-mono",children:"knowledge/profile.md"}),N&&(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-widest text-amber-accent font-bold",children:"• unsaved"}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{f?x(e0(h)):m(e1(u)),b(e=>!e)},className:"btn btn-sm inline-flex items-center gap-1 ".concat(f?"border-[var(--accent)]":""),title:f?"Switch back to the structured view":"Edit as raw markdown",children:[f?(0,r.jsx)(i.A,{className:"w-3.5 h-3.5","aria-hidden":!0}):(0,r.jsx)(eS.A,{className:"w-3.5 h-3.5","aria-hidden":!0}),f?"Structured":"Raw"]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{x(e0(v)),m(v)},disabled:!N||j,className:"btn btn-sm inline-flex items-center gap-1",title:"Discard unsaved edits",children:[(0,r.jsx)(eZ.A,{className:"w-3.5 h-3.5","aria-hidden":!0}),"Revert"]}),(0,r.jsx)("button",{type:"button",onClick:T,disabled:!N||j,className:"btn btn-sm border-[var(--accent)]/40",children:j?"Saving…":"Save"})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:f?(0,r.jsx)("textarea",{value:h,onChange:e=>m(e.target.value),className:"w-full h-full bg-[var(--bg-primary)] text-[var(--text-primary)] p-6 font-mono text-sm outline-none resize-none",spellCheck:!1}):(0,r.jsxs)("div",{className:"max-w-3xl mx-auto px-6 py-8 space-y-8",children:[(0,r.jsxs)("header",{className:"flex items-start gap-5",children:[(0,r.jsx)("div",{className:"shrink-0 w-16 h-16 rounded-2xl bg-gradient-to-br from-[var(--accent-soft)] to-[var(--bg-secondary)] border border-[var(--border)] flex items-center justify-center",children:(0,r.jsx)($.A,{className:"w-9 h-9 text-[var(--accent)]","aria-hidden":!0})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("h1",{className:"text-2xl font-bold tracking-tight truncate ".concat(u.required.name.trim()?"text-[var(--text-primary)]":"text-[var(--text-secondary)] italic"),children:F}),(0,r.jsx)("p",{className:"mt-1 text-sm text-[var(--text-secondary)]",children:P||(0,r.jsx)("span",{className:"italic",children:"Add your role"})}),(0,r.jsxs)("div",{className:"mt-3 flex items-center gap-3",children:[(0,r.jsx)("div",{className:"flex-1 h-1.5 rounded-full bg-[var(--bg-secondary)] border border-[var(--border)] overflow-hidden",children:(0,r.jsx)("div",{className:"h-full transition-all duration-500 ".concat(0===k?"bg-[var(--accent)]":"bg-amber-accent/70"),style:{width:"".concat(E,"%")}})}),(0,r.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-wider whitespace-nowrap ".concat(0===k?"text-[var(--accent)]":"text-amber-accent"),children:0===k?"Complete":"".concat(eX.length-k,"/").concat(eX.length)})]})]})]}),u.preamble&&(0,r.jsx)("div",{className:"text-[12px] text-[var(--text-secondary)] italic border-l-2 border-[var(--accent)]/40 pl-3 py-1",children:u.preamble}),(0,r.jsx)("div",{className:"space-y-4",children:eX.map(e=>{let t=u.required[e.key],a=!t.trim();return(0,r.jsxs)("section",{className:"rounded-xl border transition-colors ".concat(a?"border-[var(--border)] bg-[var(--bg-secondary)]/40":"border-[var(--border)] bg-[var(--bg-secondary)]/70 hover:border-[var(--accent)]/30"),children:[(0,r.jsxs)("header",{className:"flex items-start gap-3 px-4 pt-4",children:[(0,r.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-lg flex items-center justify-center ".concat(a?"bg-[var(--bg-primary)] text-[var(--text-secondary)]":"bg-[var(--accent-soft)] text-[var(--accent)]"),children:e.icon("w-4 h-4")}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsx)("h3",{className:"text-[13px] font-bold uppercase tracking-widest text-[var(--text-primary)]",children:e.title}),a&&(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-widest text-amber-accent/80 font-semibold",children:"Empty"})]}),(0,r.jsx)("p",{className:"mt-0.5 text-[12px] text-[var(--text-secondary)]",children:e.hint})]})]}),(0,r.jsx)("div",{className:"p-4 pt-3",children:(0,r.jsx)("textarea",{value:t,onChange:t=>{var a,r;return a=e.key,r=t.target.value,void x(e=>({...e,required:{...e.required,[a]:r}}))},placeholder:e.placeholder,rows:Math.max(3,t.split("\n").length+1),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-lg px-3 py-2.5 text-sm text-[var(--text-primary)] outline-none focus:border-[var(--accent)]/50 font-mono resize-y placeholder:text-[var(--text-secondary)]/60"})})]},e.key)})}),(0,r.jsxs)("section",{className:"rounded-xl border border-dashed border-[var(--border)] bg-[var(--bg-secondary)]/30 p-4",children:[(0,r.jsxs)("header",{className:"flex items-center gap-3 mb-3",children:[(0,r.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-lg bg-[var(--bg-primary)] text-[var(--text-secondary)] flex items-center justify-center",children:(0,r.jsx)(p.A,{className:"w-4 h-4","aria-hidden":!0})}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("h3",{className:"text-[13px] font-bold uppercase tracking-widest text-[var(--text-primary)]",children:["Custom sections",(0,r.jsxs)("span",{className:"ml-2 text-[11px] font-normal tracking-normal text-[var(--text-secondary)] normal-case",children:["(",u.custom.length,")"]})]}),(0,r.jsx)("p",{className:"mt-0.5 text-[12px] text-[var(--text-secondary)]",children:"Add your own headings for anything the required set doesn't cover."})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{let e="New section",t=2;for(;u.custom.some(t=>t.title.toLowerCase()===e.toLowerCase());)e="New section ".concat(t++);x(t=>({...t,custom:[...t.custom,{title:e,body:""}]}))},className:"btn btn-sm inline-flex items-center gap-1",children:[(0,r.jsx)(p.A,{className:"w-3.5 h-3.5","aria-hidden":!0}),"Add section"]})]}),u.custom.length>0&&(0,r.jsx)("div",{className:"space-y-3",children:u.custom.map((e,t)=>{let a=eX.some(t=>t.title.toLowerCase()===e.title.trim().toLowerCase()),n=!e.title.trim(),l=a||n;return(0,r.jsxs)("div",{className:"rounded-lg border p-3 bg-[var(--bg-primary)] ".concat(l?"border-amber-accent/40":"border-[var(--border)]"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,r.jsx)("input",{type:"text",value:e.title,onChange:e=>A(t,{title:e.target.value}),placeholder:"Section title",className:"flex-1 bg-transparent border-0 border-b-2 px-1 py-1 text-[13px] font-bold uppercase tracking-widest text-[var(--text-primary)] outline-none focus:border-[var(--accent)] transition-colors ".concat(l?"border-amber-accent/60":"border-[var(--border)]")}),(0,r.jsx)("button",{type:"button",onClick:()=>{x(e=>({...e,custom:e.custom.filter((e,a)=>a!==t)}))},className:"btn btn-icon-sm text-[var(--text-secondary)] hover:text-[var(--danger)]","aria-label":"Delete section ".concat(e.title),title:"Delete this section",children:(0,r.jsx)(eh.A,{className:"w-3.5 h-3.5","aria-hidden":!0})})]}),l&&(0,r.jsx)("p",{className:"text-[10px] text-amber-accent mb-2",children:n?"Give this section a title, or it will be lost on save.":'Title collides with the required "'.concat(e.title.trim(),'" section - pick a different name.')}),(0,r.jsx)("textarea",{value:e.body,onChange:e=>A(t,{body:e.target.value}),placeholder:"Section content",rows:Math.max(2,e.body.split("\n").length+1),className:"w-full bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-[var(--text-primary)] outline-none focus:border-[var(--accent)]/50 font-mono resize-y placeholder:text-[var(--text-secondary)]/60"})]},t)})})]})]})})]})}var e5=a(25008),e3=a(62625),e4=a(91665);function e6(e){let t=new Date(e);return{day:t.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"}),time:t.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}}function e8(e){let{recentFiles:t=[],onSelectFile:a,onNewFile:l,onOpenProfile:o,unresolvedConflicts:i=0}=e,[c,d]=(0,n.useState)(null),[u,x]=(0,n.useState)(null),[h,p]=(0,n.useState)(!0),f=null;try{f=(0,s.useRouter)()}catch(e){}let b=e=>{try{f?f.push(e):window.location.href=e}catch(e){}};if((0,n.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch("/api/welcome");if(!t.ok)throw Error("HTTP ".concat(t.status));let a=await t.json();e||d(a)}catch(a){var t;e||x(null!=(t=null==a?void 0:a.message)?t:"Failed to load welcome")}finally{e||p(!1)}})(),()=>{e=!0}},[]),h)return(0,r.jsx)("div",{className:"h-full flex items-center justify-center animate-fade-in",children:(0,r.jsxs)("div",{className:"w-full max-w-2xl px-8 space-y-4",children:[(0,r.jsx)("div",{className:"skeleton h-8 w-2/3"}),(0,r.jsx)("div",{className:"skeleton h-4 w-1/2"}),(0,r.jsx)("div",{className:"skeleton h-20 w-full"}),(0,r.jsx)("div",{className:"skeleton h-20 w-full"})]})});if(u||!c)return(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-[var(--text-secondary)] p-6",children:(0,r.jsx)("div",{className:"text-center max-w-md",children:(0,r.jsxs)("p",{className:"text-sm",children:["Couldn't load your briefing",u?": ".concat(u):"","."]})})});let v=c.conflicts.length>0,g=c.upcoming.length>0,j=c.profile.exists&&(c.profile.emptySections.length>0||null!=c.profile.daysSinceUpdate&&c.profile.daysSinceUpdate>=30);return(0,r.jsx)("div",{className:"h-full overflow-auto animate-fade-in bg-[var(--bg-primary)]",children:(0,r.jsxs)("div",{className:"max-w-3xl mx-auto px-6 py-9 space-y-7",children:[(0,r.jsxs)("header",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-start gap-4",children:[(0,r.jsx)("div",{className:"shrink-0 w-14 h-14 rounded-2xl bg-gradient-to-br from-[var(--accent-soft)] to-[var(--bg-secondary)] border border-[var(--border)] flex items-center justify-center",children:(0,r.jsx)(k.A,{className:"w-7 h-7 text-[var(--accent)]","aria-hidden":!0})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("h1",{className:"text-2xl font-bold tracking-tight text-[var(--text-primary)]",children:[function(){let e=new Date().getHours();return e<5?"Working late":e<12?"Good morning":e<18?"Good afternoon":"Good evening"}(),c.profile.name?(0,r.jsxs)(r.Fragment,{children:[", ",(0,r.jsx)("span",{className:"text-[var(--accent)]",children:c.profile.name})]}):"","."]}),(0,r.jsx)("p",{className:"mt-1 text-sm text-[var(--text-secondary)]",children:new Date(c.today+"T00:00:00Z").toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"})})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[l&&(0,r.jsxs)("button",{type:"button",onClick:l,className:"btn btn-sm btn-primary inline-flex items-center gap-1.5",children:[(0,r.jsx)(e5.A,{className:"w-3.5 h-3.5","aria-hidden":!0}),"New File"]}),(0,r.jsxs)("button",{type:"button",onClick:()=>b("/graph"),className:"btn btn-sm btn-outline inline-flex items-center gap-1.5",children:[(0,r.jsx)(N.A,{className:"w-3.5 h-3.5 text-[var(--accent)]","aria-hidden":!0}),"Open Graph"]}),(0,r.jsxs)("button",{type:"button",onClick:()=>b("/calendar"),className:"btn btn-sm btn-outline inline-flex items-center gap-1.5",children:[(0,r.jsx)(K.A,{className:"w-3.5 h-3.5 text-[var(--accent)]","aria-hidden":!0}),"Open Calendar"]}),(0,r.jsxs)("button",{type:"button",onClick:()=>b("/hygiene"),className:"btn btn-sm btn-outline inline-flex items-center gap-1.5",children:[(0,r.jsx)(k.A,{className:"w-3.5 h-3.5 text-[var(--accent)]","aria-hidden":!0}),"Knowledge Hygiene"]})]})]}),(0,r.jsxs)("section",{"aria-label":"Vault pulse",className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>b("/conflicts"),className:"text-left rounded-xl border p-3.5 transition-all hover:border-[var(--border-strong)] ".concat(i>0?"border-[var(--border-strong)] bg-[var(--accent-soft)]":"border-[var(--border)] bg-[var(--bg-secondary)]/50"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-[var(--text-secondary)]",children:"Sync Conflicts"}),(0,r.jsx)(C.A,{className:"w-4 h-4 ".concat(i>0?"text-[var(--accent)]":"text-[var(--text-tertiary)]"),"aria-hidden":!0})]}),(0,r.jsx)("div",{className:"mt-1.5 text-sm font-bold text-[var(--text-primary)]",children:i>0?"".concat(i," unresolved"):"All clear"})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>b("/hygiene"),className:"text-left rounded-xl border border-[var(--border)] bg-[var(--bg-secondary)]/50 p-3.5 transition-all hover:border-[var(--border-strong)]",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-[var(--text-secondary)]",children:"Vault Hygiene"}),(0,r.jsx)(k.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})]}),(0,r.jsx)("div",{className:"mt-1.5 text-sm font-bold text-[var(--text-primary)]",children:"Review duplicates & refs"})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>b("/brain"),className:"text-left rounded-xl border border-[var(--border)] bg-[var(--bg-secondary)]/50 p-3.5 transition-all hover:border-[var(--border-strong)]",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-[var(--text-secondary)]",children:"Brain & Sync"}),(0,r.jsx)(A.A,{className:"w-4 h-4 text-[var(--accent)]","aria-hidden":!0})]}),(0,r.jsx)("div",{className:"mt-1.5 text-sm font-bold text-[var(--text-primary)]",children:"Manage relay & devices"})]})]}),t.length>0&&(0,r.jsxs)("section",{className:"space-y-2.5",children:[(0,r.jsx)("h2",{className:"text-xs font-bold uppercase tracking-wider text-[var(--text-secondary)]",children:"Continue Reading"}),(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2.5",children:t.slice(0,6).map(e=>{var t;return(0,r.jsxs)("button",{type:"button",onClick:()=>null==a?void 0:a(e.id),className:"text-left rounded-xl border border-[var(--border)] bg-[var(--bg-secondary)]/50 hover:bg-[var(--accent-soft)] hover:border-[var(--border-strong)] px-3.5 py-2.5 flex items-center gap-3 transition-all group",children:[(0,r.jsx)(ea,{contentClass:null!=(t=e.content_class)?t:null,className:"w-4 h-4 text-[var(--accent)] shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"text-sm font-semibold text-[var(--text-primary)] group-hover:text-[var(--accent)] truncate",children:e.title}),(0,r.jsx)("div",{className:"text-[11px] text-[var(--text-tertiary)] truncate font-mono",children:function(e){let t=e.replace(/\\/g,"/").split("/").filter(Boolean);return t.length<=2?t.join("/"):t.slice(-2).join("/")}(e.path)})]}),(0,r.jsx)(e3.A,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)] opacity-0 group-hover:opacity-100 transition-opacity shrink-0","aria-hidden":!0})]},e.id)})})]}),v&&(0,r.jsxs)("section",{className:"rounded-xl border border-[var(--danger)]/40 bg-[var(--danger)]/5 overflow-hidden",children:[(0,r.jsxs)("header",{className:"flex items-center gap-3 px-4 py-3 border-b border-[var(--danger)]/30 bg-[var(--danger)]/10",children:[(0,r.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-lg bg-[var(--danger)]/15 text-[var(--danger)] flex items-center justify-center",children:(0,r.jsx)(m.A,{className:"w-4 h-4","aria-hidden":!0})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("h2",{className:"text-xs font-bold uppercase tracking-wider text-[var(--text-primary)]",children:["Calendar conflicts ",(0,r.jsxs)("span",{className:"ml-1 text-[var(--text-secondary)] font-normal normal-case tracking-normal",children:["(",c.conflicts.length,")"]})]}),(0,r.jsx)("p",{className:"mt-0.5 text-xs text-[var(--text-secondary)]",children:"Overlaps or buffer violations in the next 7 days."})]}),(0,r.jsx)("button",{type:"button",onClick:()=>b("/calendar"),className:"btn btn-sm btn-outline shrink-0",children:"Resolve in Calendar"})]}),(0,r.jsx)("ul",{className:"divide-y divide-[var(--border)]",children:c.conflicts.map((e,t)=>{let a=e6(e.event_a.starts_at),n=e6(e.event_b.starts_at);return(0,r.jsxs)("li",{className:"px-4 py-3 text-sm",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-widest text-[var(--danger)] font-bold",children:e.kind.replace(/_/g," ")}),(0,r.jsx)("span",{className:"text-[11px] text-[var(--text-secondary)]",children:e.reason})]}),(0,r.jsxs)("div",{className:"mt-1 text-[var(--text-primary)]",children:[(0,r.jsx)("span",{className:"font-medium",children:e.event_a.title}),(0,r.jsxs)("span",{className:"text-[var(--text-secondary)]",children:[" \xb7 ",a.day," ",a.time," \xb7 ",e.event_a.entity_name]})]}),(0,r.jsxs)("div",{className:"text-[var(--text-primary)]",children:[(0,r.jsx)("span",{className:"font-medium",children:e.event_b.title}),(0,r.jsxs)("span",{className:"text-[var(--text-secondary)]",children:[" \xb7 ",n.day," ",n.time," \xb7 ",e.event_b.entity_name]})]})]},t)})})]}),(0,r.jsxs)("section",{className:"rounded-xl border border-[var(--border)] bg-[var(--bg-secondary)]/50 overflow-hidden",children:[(0,r.jsxs)("header",{className:"flex items-center gap-3 px-4 py-3 border-b border-[var(--border)]",children:[(0,r.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-lg bg-[var(--accent-soft)] text-[var(--accent)] flex items-center justify-center",children:(0,r.jsx)(K.A,{className:"w-4 h-4","aria-hidden":!0})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("h2",{className:"text-xs font-bold uppercase tracking-wider text-[var(--text-primary)]",children:"Upcoming (next 7 days)"}),(0,r.jsx)("p",{className:"mt-0.5 text-xs text-[var(--text-secondary)]",children:g?"".concat(c.upcoming.length," event").concat(1===c.upcoming.length?"":"s"," in view."):"No scheduled events."})]}),(0,r.jsx)("button",{type:"button",onClick:()=>b("/calendar"),className:"btn btn-sm btn-outline shrink-0",children:g?"View Calendar":"+ Add Event"})]}),g?(0,r.jsx)("ul",{className:"divide-y divide-[var(--border)]",children:c.upcoming.map(e=>{let t=e6(e.starts_at),a=e6(e.ends_at);return(0,r.jsxs)("li",{className:"px-4 py-3 flex items-start gap-3 hover:bg-[var(--bg-primary)]/50 transition-colors",children:[(0,r.jsxs)("div",{className:"shrink-0 w-14 text-center pt-0.5",children:[(0,r.jsx)("div",{className:"text-[10px] uppercase tracking-widest text-[var(--text-secondary)] font-bold",children:t.day.split(" ")[0]}),(0,r.jsx)("div",{className:"text-lg font-semibold leading-none text-[var(--text-primary)]",children:t.day.split(" ")[2]})]}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-[var(--text-primary)] truncate",children:e.title}),(0,r.jsxs)("div",{className:"mt-0.5 flex items-center gap-2 text-[11px] text-[var(--text-secondary)]",children:[(0,r.jsx)(e4.A,{className:"w-3 h-3","aria-hidden":!0}),(0,r.jsxs)("span",{children:[t.time,"–",a.time]}),(0,r.jsx)("span",{className:"text-[var(--border)]",children:"\xb7"}),(0,r.jsx)("span",{children:e.entity_name})]})]})]},e.id)})}):(0,r.jsx)("div",{className:"px-4 py-5 text-center text-xs text-[var(--text-secondary)]",children:"Your calendar is clear for the next 7 days."})]}),j&&(0,r.jsxs)("section",{className:"rounded-xl border border-[var(--border-strong)] bg-[var(--accent-soft)] p-4 flex items-start gap-3",children:[(0,r.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-lg bg-[var(--bg-primary)] text-[var(--accent)] flex items-center justify-center border border-[var(--border)]",children:(0,r.jsx)($.A,{className:"w-4 h-4","aria-hidden":!0})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("h3",{className:"text-xs font-bold uppercase tracking-wider text-[var(--text-primary)]",children:"Keep your profile current"}),(0,r.jsxs)("p",{className:"mt-1 text-xs text-[var(--text-secondary)]",children:[c.profile.emptySections.length>0&&(0,r.jsxs)(r.Fragment,{children:["The agent uses your profile to honor coding style and name people correctly. ",(0,r.jsxs)("span",{className:"text-[var(--text-primary)] font-medium",children:[c.profile.emptySections.length," section",1===c.profile.emptySections.length?"":"s"," still empty"]}),": ",c.profile.emptySections.join(", "),"."]}),0===c.profile.emptySections.length&&null!=c.profile.daysSinceUpdate&&c.profile.daysSinceUpdate>=30&&(0,r.jsxs)(r.Fragment,{children:["Your profile hasn't been updated in ",c.profile.daysSinceUpdate," days."]})]}),o&&(0,r.jsxs)("button",{type:"button",onClick:o,className:"btn btn-sm btn-primary mt-3 inline-flex items-center gap-1.5",children:["Edit Profile",(0,r.jsx)(e3.A,{className:"w-3.5 h-3.5","aria-hidden":!0})]})]})]}),!c.profile.exists&&(0,r.jsxs)("section",{className:"rounded-xl border border-[var(--border)] bg-[var(--bg-secondary)]/50 p-4 flex items-start gap-3",children:[(0,r.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-lg bg-[var(--accent-soft)] text-[var(--accent)] flex items-center justify-center",children:(0,r.jsx)($.A,{className:"w-4 h-4","aria-hidden":!0})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("h3",{className:"text-xs font-bold uppercase tracking-wider text-[var(--text-primary)]",children:"Set up your profile"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-[var(--text-secondary)]",children:"Kontexta hands your profile to the agent on every session start: coding rules, roadmap, team roster. Create one to make sessions consistent."}),o&&(0,r.jsxs)("button",{type:"button",onClick:o,className:"btn btn-sm btn-primary mt-3 inline-flex items-center gap-1.5",children:["Set Up Profile",(0,r.jsx)(e3.A,{className:"w-3.5 h-3.5","aria-hidden":!0})]})]})]})]})})}function e9(e){let{fileId:t,onSelectFile:a}=e,[l,s]=(0,n.useState)([]),[o,c]=(0,n.useState)(!0),[d,u]=(0,n.useState)(null),[x,h]=(0,n.useState)(!0);return((0,n.useEffect)(()=>{let e=!1;return c(!0),u(null),(async()=>{var a,r;try{let r=await fetch("/api/files/".concat(t,"/backlinks"));if(!r.ok)throw Error("HTTP ".concat(r.status));let n=await r.json();e||s(null!=(a=n.backlinks)?a:[])}catch(t){e||u(null!=(r=null==t?void 0:t.message)?r:"Failed to load backlinks")}finally{e||c(!1)}})(),()=>{e=!0}},[t]),o)?(0,r.jsx)("div",{className:"border-t border-[var(--border)] px-6 py-4",children:(0,r.jsx)("div",{className:"skeleton h-4 w-32"})}):d||0===l.length?null:(0,r.jsxs)("div",{className:"border-t border-[var(--border)] bg-[var(--bg-secondary)]/40",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>h(e=>!e),className:"w-full flex items-center gap-2 px-6 py-3 text-left hover:bg-[var(--bg-secondary)]/60 transition-colors","aria-expanded":x,children:[(0,r.jsx)(W.A,{className:"w-3.5 h-3.5 shrink-0 transition-transform text-[var(--text-secondary)] ".concat(x?"":"-rotate-90"),"aria-hidden":!0}),(0,r.jsx)(eB.A,{className:"w-3.5 h-3.5 shrink-0 text-[var(--accent)]","aria-hidden":!0}),(0,r.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-widest text-[var(--text-primary)]",children:"Referenced by"}),(0,r.jsx)("span",{className:"text-[11px] text-[var(--text-secondary)] font-mono",children:l.length})]}),x&&(0,r.jsx)("ul",{className:"divide-y divide-[var(--border)]",children:l.map(e=>{var t;return(0,r.jsx)("li",{children:(0,r.jsx)("button",{type:"button",onClick:()=>a(e.id),className:"w-full text-left px-6 py-3 hover:bg-[var(--bg-secondary)] transition-colors group",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)(i.A,{className:"w-3.5 h-3.5 shrink-0 mt-0.5 text-[var(--text-secondary)] group-hover:text-[var(--accent)]","aria-hidden":!0}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsx)("span",{className:"text-[13px] font-medium text-[var(--text-primary)] truncate",children:e.title}),(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-widest text-[var(--text-secondary)]/70 font-semibold shrink-0",children:"title"===(t=e.reason)?"title mention":"basename"===t?"path mention":"wikilink"})]}),e.snippet&&(0,r.jsx)("p",{className:"mt-1 text-[12px] text-[var(--text-secondary)] leading-relaxed line-clamp-2",children:e.snippet.split(/<<<|>>>/).map((e,t)=>t%2==1?(0,r.jsx)("mark",{className:"bg-[var(--accent-soft)] text-[var(--accent)] px-0.5 rounded-sm",children:e},t):(0,r.jsx)("span",{children:e},t))})]})]})})},e.id)})})]})}function e7(e){let{open:t,onClose:a,title:n,body:l,detail:s}=e;return(0,r.jsxs)(eg.l,{open:t,onClose:a,title:n,children:[(0,r.jsx)("p",{className:"text-sm text-[var(--text-primary)] mb-4 leading-relaxed",children:l}),s&&(0,r.jsxs)("div",{className:"bg-[var(--danger-soft)] border border-[var(--danger)]/20 rounded-lg p-4 mb-6",children:[(0,r.jsx)("p",{className:"text-[11px] text-[var(--danger)] uppercase tracking-tighter font-bold mb-2 opacity-70",children:"Detail:"}),(0,r.jsx)("pre",{className:"text-[12px] font-mono text-[var(--danger)] whitespace-pre-wrap break-words leading-tight overflow-x-auto max-h-48 custom-scrollbar",children:s})]}),(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsx)("button",{onClick:a,className:"btn btn-md btn-destructive",children:"Got it"})})]})}let te=e=>{let{className:t}=e;return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,r.jsx)("path",{d:"M3 6h18"}),(0,r.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,r.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})},tt=e=>{let{className:t}=e;return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,r.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})};function ta(e,t,a){let r=new Blob([e],{type:a}),n=URL.createObjectURL(r),l=document.createElement("a");l.href=n,l.download=t,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(n)}let tr=e=>{let{filled:t,className:a}=e;return(0,r.jsx)("svg",{viewBox:"0 0 24 24",fill:t?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:a,children:(0,r.jsx)("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})};function tn(e){var t,l;let{fileId:s,onDelete:o,onChanged:i,onDirtyChange:c,onNavigateToFile:u,allTags:x=[],onSelectTag:h,focusMode:p=!1,onToggleFocus:f,recentFiles:v=[],onNewFile:g,onOpenProfile:j,unresolvedConflicts:y=0,externalFavorite:w,welcomeRefreshKey:N=0}=e,[k,S]=(0,n.useState)(null),[C,A]=(0,n.useState)(null),[T,F]=(0,n.useState)(!1),[P,E]=(0,n.useState)("edit"),[L,_]=(0,n.useState)(!1),[D,M]=(0,n.useState)([]),[I,O]=(0,n.useState)(!1),[U,H]=(0,n.useState)({}),[B,G]=(0,n.useState)(null),[z,K]=(0,n.useState)(null),[W,V]=(0,n.useState)(""),[q,$]=(0,n.useState)(!1),[Y,Z]=(0,n.useState)(!1),[X,Q]=(0,n.useState)(!1),[et,ea]=(0,n.useState)(!1),[er,en]=(0,n.useState)(!1),[el,es]=(0,n.useState)(""),[eo,ei]=(0,n.useState)(""),[ec,ed]=(0,n.useState)(void 0),[eu,ex]=(0,n.useState)(!1),[eh,em]=(0,n.useState)(!1),[ep,ef]=(0,n.useState)(!1),[eb,ev]=(0,n.useState)(""),[eg,ej]=(0,n.useState)(!1),[ey,ek]=(0,n.useState)(!1),eD=(0,n.useRef)(null),eM=(0,n.useRef)(!1);(0,n.useEffect)(()=>{void 0!==w&&S(e=>e&&e.favorite!==w?{...e,favorite:w}:e)},[w]);let eI=()=>((null==k?void 0:k.title)||"untitled").replace(/\.(md|mmd|html)$/i,""),eO=async()=>{if(!k)return;let[{unified:e},{default:t},{default:r},{default:n},{default:l}]=await Promise.all([a.e(2443).then(a.bind(a,2443)),a.e(5858).then(a.bind(a,95858)),a.e(245).then(a.bind(a,50245)),a.e(1108).then(a.bind(a,11108)),a.e(3685).then(a.bind(a,43685))]);ta(String(await e().use(t).use(r).use(l,{keep:["code","inlineCode","table","tableCell"]}).use(n).process(k.content)),"".concat(eI(),".txt"),"text/plain"),d.o.success("Exported text")},[eU,eH]=(0,n.useState)(!1),[eB,eG]=(0,n.useState)(!1),eK=!!(null==k?void 0:k.path.endsWith(".html")),eW=!!(null==k?void 0:k.path.endsWith(".mmd")),eJ=!!k&&!eK&&!eW,eV=async(e,t,a,r)=>{r(!0);let n=d.o.loading("Generating ".concat(a,"…"));try{var l;let r=await fetch(e);if(!r.ok){let e=await r.text(),t="Failed to export ".concat(a," (HTTP ").concat(r.status,")");try{let a=JSON.parse(e);(null==a?void 0:a.error)&&(t=a.error)}catch(t){console.error("[export-".concat(a,"] non-JSON error response:"),e)}d.o.error(t,{id:n});return}let s=r.headers.get("content-disposition")||"",o=/filename="([^"]+)"/.exec(s),i=null!=(l=null==o?void 0:o[1])?l:t,c=await r.blob(),u=URL.createObjectURL(c),x=document.createElement("a");x.href=u,x.download=i,document.body.appendChild(x),x.click(),x.remove(),URL.revokeObjectURL(u),d.o.success("Exported ".concat(a),{id:n})}catch(e){console.error("[export-".concat(a,"] request failed:"),e),d.o.error("Failed to export ".concat(a,". Check the browser console for details."),{id:n})}finally{r(!1)}},eq=()=>{k&&eV(eK?"/api/files/".concat(k.id,"/export-html?format=pdf"):"/api/files/".concat(k.id,"/export-pdf"),"".concat(eI(),".pdf"),"PDF",eH)},e$=async()=>{if(s){ex(!0);try{let e=await fetch("/api/files/".concat(s));if(e.ok){let t=await e.json();S(t),V(t.content)}else d.o.error("Failed to refresh file (HTTP ".concat(e.status,")"))}catch(t){var e;d.o.error("Failed to refresh file: ".concat(null!=(e=null==t?void 0:t.message)?e:"Network error"))}finally{ex(!1)}}},eY=(0,n.useRef)(s);(0,n.useEffect)(()=>{eY.current=s},[s]);let eZ=(0,n.useRef)(c);(0,n.useEffect)(()=>{eZ.current=c},[c]);let[eX,eQ]=(0,n.useState)(!1),e0=T&&null!=k&&W!==k.content;(0,n.useEffect)(()=>{var e;let t=e0||ep&&eX,a="file:".concat(s);return null==(e=eZ.current)||e.call(eZ,a,t),()=>{var e;return null==(e=eZ.current)?void 0:e.call(eZ,a,!1)}},[s,e0,ep,eX]);let e1=(0,n.useCallback)(e=>{var t;return null==(t=eZ.current)?void 0:t.call(eZ,"profile",e)},[]);(0,n.useEffect)(()=>{if(!ey)return;let e=e=>{eD.current&&!eD.current.contains(e.target)&&ek(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[ey]),(0,n.useEffect)(()=>{if(null===s){S(null),A(null),F(!1),_(!1);return}F(!1),_(!1),ef(!1),G(null),H({}),ek(!1),ev("");let e=new AbortController;return(async()=>{var t,a,r;$(!0),A(null);try{let r=await fetch("/api/files/".concat(s),{signal:e.signal});if(eY.current!==s)return;if(r.ok){let e=await r.json();if(eY.current!==s)return;S(e),V(e.content)}else{let e=null;try{e=await r.json()}catch(e){}if(eY.current!==s)return;S(null),A({kind:null!=(t=null==e?void 0:e.kind)?t:"http",message:null!=(a=null==e?void 0:e.error)?a:"Request failed with HTTP ".concat(r.status),status:r.status,path:null==e?void 0:e.path})}}catch(e){if((null==e?void 0:e.name)==="AbortError"||(console.error("Failed to fetch file:",e),eY.current!==s))return;S(null),A({kind:"network",message:null!=(r=null==e?void 0:e.message)?r:"Network error"})}finally{eY.current===s&&$(!1)}})(),_(!1),()=>e.abort()},[s]);let e5=(0,n.useMemo)(()=>{if(!eJ||!(null==k?void 0:k.content))return[];let e=k.content.split("\n"),t=[],a=(0,eE._A)(),r=!1;for(let n of e){if(/^```/.test(n.trim())){r=!r;continue}if(r)continue;let e=/^(#{1,3})\s+(.+?)\s*$/.exec(n);if(e){let r=e[2].replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`~]/g,"").trim(),n=a(r);r&&n&&t.push({level:e[1].length,text:r,id:n})}}return t},[eJ,null==k?void 0:k.content]),e3=(0,n.useMemo)(()=>{var e;if(!k)return[];let t=new Set(null!=(e=k.tags)?e:[]),a=eb.trim().toLowerCase();return x.filter(e=>!t.has(e.name)&&(!a||e.name.toLowerCase().includes(a))).slice(0,6)},[x,k,eb]),[e4,e6]=(0,n.useState)(!1),tn=async e=>{var t,a;if(k&&!e4&&k.content_class!==e){e6(!0);try{let a=await fetch("/api/files/".concat(k.id,"/move"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:e})});if(!a.ok){let e=await a.json().catch(()=>({}));d.o.error(null!=(t=null==e?void 0:e.error)?t:"Move failed: HTTP ".concat(a.status));return}let r=await a.json();S(e=>{var t;return e?{...e,path:r.path,content_class:null!=(t=r.content_class)?t:null}:e}),null==i||i(),d.o.success("Moved to ".concat("dictionary"===e?"dictionary":"notes"))}catch(e){d.o.error("Move failed: ".concat(null!=(a=null==e?void 0:e.message)?a:"network error"))}finally{e6(!1)}}},tl=async()=>{var e,t;if(null!=s){em(!0);try{let t=await fetch("/api/files/".concat(s),{method:"DELETE"});if(t.ok)A(null),S(null),o(s).catch(e=>console.error("onDelete after orphan remove failed:",e)),null==i||i();else{let a=await t.json().catch(()=>({}));A({kind:"http",message:null!=(e=null==a?void 0:a.error)?e:"Remove failed: HTTP ".concat(t.status),status:t.status})}}catch(e){A({kind:"network",message:null!=(t=null==e?void 0:e.message)?t:"Network error while removing orphan row"})}finally{em(!1)}}},ts=async()=>{if(s){O(!0),G(null),H({});try{let e=await fetch("/api/files/".concat(s,"/history"));if(e.ok){let t=await e.json();if(eY.current!==s)return;M(t)}}catch(e){console.error("Failed to fetch history:",e)}finally{eY.current===s&&O(!1)}}},to=async e=>{var t,a;if(s){if(B===e)return void G(null);if(G(e),(null==(t=U[e])?void 0:t.diff)===void 0&&(null==(a=U[e])||!a.loading)){H(t=>({...t,[e]:{loading:!0}}));try{let t=await fetch("/api/files/".concat(s,"/history/diff?hash=").concat(encodeURIComponent(e))),a=await t.json().catch(()=>({}));if(eY.current!==s)return;if(!t.ok)throw Error((null==a?void 0:a.error)||"HTTP ".concat(t.status));H(t=>{var r;return{...t,[e]:{loading:!1,diff:null!=(r=a.diff)?r:""}}})}catch(t){if(eY.current!==s)return;H(a=>{var r;return{...a,[e]:{loading:!1,error:null!=(r=null==t?void 0:t.message)?r:"Failed to load diff"}}})}}}},ti=async e=>{if(s)try{let t=await fetch("/api/files/".concat(s,"/history/restore"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hash:e})});if(t.ok){let e=await t.json();if(eY.current!==s)return;S(t=>t&&t.id===s?{...t,content:e.content}:t),V(e.content),_(!1),G(null),H({}),d.o.success("Restored from history")}else{let e=await t.json().catch(()=>({}));d.o.error((null==e?void 0:e.error)||"Failed to restore version")}}catch(e){var t;d.o.error("Failed to restore version: ".concat(null!=(t=null==e?void 0:e.message)?t:"Network error"))}},tc=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"edit";E(e),_(!1),T||(V((null==k?void 0:k.content)||""),F(!0))},td=e=>{F(!1),V((null==k?void 0:k.content)||""),_("history"===e),"history"===e&&ts()},tu=async()=>{var e,t,a;if(!k||eM.current)return;let r=k.id;eM.current=!0;try{Z(!0);let a=await fetch("/api/files/".concat(r),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:W,expected_updated_at:k.updated_at})});if(a.ok){let e=await a.json();if(eY.current!==r){e.git_warning&&console.warn("[kontexta] git_warning for stale file ".concat(r,":"),e.git_warning);return}S(e),F(!1),G(null),H({}),d.o.success("Saved"),e.git_warning&&(es("Git commit failed"),ei("Your changes were saved to the database, but Kontexta could not create a Git history entry for this file."),ed(e.git_warning),en(!0))}else if(409===a.status){let n,l;try{let r=await a.json();n=null==r||null==(e=r.current)?void 0:e.content,l=null==r||null==(t=r.current)?void 0:t.updated_at}catch(e){}eY.current===r&&(void 0!==n&&void 0!==l&&S(e=>e?{...e,content:n,updated_at:l}:e),es("File changed on disk"),ei("This file was NOT saved. It was modified elsewhere since you opened it. Disk content has been reloaded below; your edits are still in the editor. Click Save again to overwrite with your edits."),ed(void 0),en(!0))}else{let e="Save failed (".concat(a.status,")");try{let t=await a.json();(null==t?void 0:t.error)&&(e=t.error)}catch(e){}eY.current===r&&(es("Save failed"),ei("Your changes were NOT saved."),ed(e),en(!0))}}catch(e){console.error("Failed to save file:",e),eY.current===r&&(es("Save failed"),ei("Your changes were NOT saved. A network error occurred."),ed(null!=(a=null==e?void 0:e.message)?a:"Network error while saving"),en(!0))}finally{eM.current=!1,eY.current===r&&Z(!1)}},tx=async e=>{if(!k)return;let t=e.trim().toLowerCase().replace(/\s+/g,"-");if(!t||k.tags.includes(t))return void ev("");let a=k.id,r=k.tags,n=[...r,t];S(e=>e&&e.id===a?{...e,tags:n}:e),ev("");try{if(!(await fetch("/api/files/".concat(a),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:n})})).ok)throw Error("PATCH failed");null==i||i()}catch(e){var l;S(e=>e&&e.id===a?{...e,tags:r}:e),d.o.error("Failed to add tag: ".concat(null!=(l=null==e?void 0:e.message)?l:"Network error"))}},th=async()=>{if(k){ea(!0);try{await o(k.id),S(null),Q(!1)}finally{ea(!1)}}};if(!s)return(0,r.jsx)(e8,{recentFiles:v,onSelectFile:u,onNewFile:g,onOpenProfile:j,unresolvedConflicts:y},N);if(q)return(0,r.jsxs)("div",{className:"h-full flex flex-col animate-fade-in",children:[(0,r.jsxs)("div",{className:"border-b border-[var(--border)] px-6 py-4",children:[(0,r.jsx)("div",{className:"skeleton h-6 w-48 mb-2"}),(0,r.jsx)("div",{className:"skeleton h-4 w-32"})]}),(0,r.jsxs)("div",{className:"flex-1 p-6 space-y-4",children:[(0,r.jsx)("div",{className:"skeleton h-4 w-full"}),(0,r.jsx)("div",{className:"skeleton h-4 w-5/6"}),(0,r.jsx)("div",{className:"skeleton h-4 w-4/6"}),(0,r.jsx)("div",{className:"skeleton h-4 w-full"}),(0,r.jsx)("div",{className:"skeleton h-4 w-3/4"})]})]});if(!k)return(null==C?void 0:C.kind)==="disk_missing"?(0,r.jsxs)("div",{className:"h-full flex flex-col items-center justify-center text-[var(--text-secondary)] gap-4 animate-fade-in p-8",children:[(0,r.jsx)(m.A,{className:"w-16 h-16 opacity-40 dark-icon","aria-hidden":!0}),(0,r.jsxs)("div",{className:"text-center max-w-lg",children:[(0,r.jsx)("p",{className:"text-lg font-bold text-[var(--text-primary)]",children:"File is missing on disk"}),(0,r.jsx)("p",{className:"text-sm font-medium text-[var(--text-secondary)] mt-2",children:"The index still has a row for this file, but the file at the path below no longer exists. This usually happens when the file was deleted while the watcher wasn't running."}),C.path&&(0,r.jsx)("pre",{className:"mt-3 p-2 bg-[var(--bg-tertiary)] text-[var(--text-primary)] text-xs overflow-x-auto rounded",children:C.path}),(0,r.jsx)("button",{type:"button",className:"btn btn-sm btn-primary mt-4",onClick:tl,disabled:eh,children:eh?"Removing…":"Remove from index"})]})]}):C?(0,r.jsxs)("div",{className:"h-full flex flex-col items-center justify-center text-[var(--text-secondary)] gap-3 animate-fade-in p-8",children:[(0,r.jsx)(m.A,{className:"w-16 h-16 opacity-40 dark-icon","aria-hidden":!0}),(0,r.jsxs)("div",{className:"text-center max-w-lg",children:[(0,r.jsxs)("p",{className:"text-lg font-bold text-[var(--text-primary)]",children:["Failed to load file",C.status?" (HTTP ".concat(C.status,")"):""]}),(0,r.jsx)("p",{className:"text-sm font-medium text-[var(--text-secondary)] mt-2 break-words",children:C.message})]})]}):(0,r.jsx)("div",{className:"h-full flex flex-col items-center justify-center animate-fade-in",children:(0,r.jsx)(ee.p,{icon:(0,r.jsx)(J.A,{className:"w-16 h-16 opacity-40 dark-icon","aria-hidden":!0}),title:"File not found",hint:"This file may have been moved or deleted"})});let tm=k.path.replace(/\\/g,"/");if(null===k.project_id&&/(^|\/)knowledge\/profile\.md$/.test(tm))return(0,r.jsx)("div",{className:"h-full flex flex-col",children:(0,r.jsx)(e2,{onDirtyChange:e1,onChanged:i})},s);let tp=null===k.project_id&&/\/knowledge\/(html|knowledge)\/publish\//.test(tm),tf=!eK&&!tp,tb=T?P:L?"history":"view",tv=[{id:"view",label:"Read",icon:(0,r.jsx)(b.A,{className:"w-3.5 h-3.5","aria-hidden":!0})},...tf?[{id:"edit",label:"Edit",icon:(0,r.jsx)(eS.A,{className:"w-3.5 h-3.5","aria-hidden":!0})},...eW?[]:[{id:"split",label:"Split",icon:(0,r.jsx)(eC.A,{className:"w-3.5 h-3.5","aria-hidden":!0})}]]:[],{id:"history",label:"History",icon:(0,r.jsx)(eA.A,{className:"w-3.5 h-3.5","aria-hidden":!0})}];return(0,r.jsxs)("div",{className:"h-full flex flex-col animate-fade-in",children:[(0,r.jsxs)("div",{className:"min-h-11 px-4 py-1.5 border-b border-[var(--border)] flex flex-wrap items-center gap-2.5 text-[13px] sticky top-0 bg-[var(--bg-primary)]/95 backdrop-blur-md z-10",children:[(0,r.jsx)("div",{role:"tablist","aria-label":"Document view mode",className:"inline-flex items-center rounded-lg border border-[var(--border)] bg-[var(--bg-secondary)]/70 p-0.5 gap-0.5",children:tv.map(e=>{let t=tb===e.id,a=("edit"===e.id||"split"===e.id)&&e0;return(0,r.jsxs)("button",{type:"button",role:"tab","aria-selected":t,onClick:()=>{var t;return"edit"===(t=e.id)||"split"===t?void tc(t):e0?void K(t):void td(t)},className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium transition-all ".concat(t?"bg-[var(--bg-primary)] text-[var(--text-primary)] shadow-sm font-semibold":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"),children:[e.icon,(0,r.jsx)("span",{children:e.label}),a&&(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--accent)] bp-keep-round",title:"Unsaved changes"})]},e.id)})}),tp&&(0,r.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md bg-[var(--accent-soft)] border border-[var(--border-strong)] text-[10px] text-[var(--text-primary)] uppercase tracking-wider font-bold",title:"Regenerated on publish",children:"Read-only"}),null===k.project_id&&/\/knowledge\/knowledge\/(dictionary|notes|urlclips)\//.test(tm)&&(0,r.jsxs)("div",{className:"inline-flex items-center rounded-full border border-[var(--border)] bg-[var(--bg-secondary)] p-0.5 text-[10px] transition-opacity bp-keep-round ".concat(e4?"opacity-60":""),role:"group","aria-label":"Content class",children:[(0,r.jsx)("button",{type:"button",onClick:()=>tn("dictionary"),disabled:e4||"dictionary"===k.content_class,"aria-pressed":"dictionary"===k.content_class,className:"px-2.5 py-0.5 rounded-full uppercase tracking-wider font-bold transition-all bp-keep-round ".concat("dictionary"===k.content_class?"bg-amber-accent text-[var(--bg-primary)] cursor-default":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] cursor-pointer"),title:"Authoritative: trusted over notes on conflict",children:"Dictionary"}),(0,r.jsx)("button",{type:"button",onClick:()=>tn("note"),disabled:e4||"note"===k.content_class,"aria-pressed":"note"===k.content_class,className:"px-2.5 py-0.5 rounded-full uppercase tracking-wider font-bold transition-all bp-keep-round ".concat("note"===k.content_class?"bg-amber-accent text-[var(--bg-primary)] cursor-default":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] cursor-pointer"),title:"Informational",children:"Note"})]}),(0,r.jsx)("div",{className:"ml-auto flex items-center gap-1.5 text-[12px] text-[var(--text-secondary)]",children:T?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",onClick:()=>{F(!1),V((null==k?void 0:k.content)||"")},disabled:Y,className:"btn btn-sm btn-outline",children:"Cancel"}),(0,r.jsx)("button",{type:"button",onClick:tu,disabled:Y,className:"btn btn-sm btn-primary",title:"Save changes (Ctrl/Cmd+S)",children:Y?"Saving...":"Save"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"hidden sm:inline font-mono text-[11px] text-[var(--text-tertiary)] mr-1",children:[(null==k?void 0:k.updated_at)&&"edited ".concat(function(e){if(!e)return"";let t=new Date(e).getTime();if(!isFinite(t))return e;let a=Math.floor((Date.now()-t)/1e3);return a<60?"".concat(a,"s ago"):a<3600?"".concat(Math.floor(a/60),"m ago"):a<86400?"".concat(Math.floor(a/3600),"h ago"):"".concat(Math.floor(a/86400),"d ago")}(k.updated_at)),(null==k?void 0:k.content)&&(0,r.jsxs)(r.Fragment,{children:[" \xb7 ",(0,r.jsxs)("span",{title:"~".concat(Math.max(1,Math.ceil(k.content.length/4)).toLocaleString()," tokens (heuristic: chars/4)"),children:["~",(l=Math.max(1,Math.ceil(k.content.length/4)))<1e3?String(l):l<1e4?"".concat((l/1e3).toFixed(1),"k"):l<1e6?"".concat(Math.round(l/1e3),"k"):"".concat((l/1e6).toFixed(1),"M")," tok"]})]})]}),e5.length>=2&&!L&&(0,r.jsxs)("div",{className:"relative",ref:eD,children:[(0,r.jsx)("button",{type:"button",onClick:()=>ek(e=>!e),className:"btn btn-icon-sm ".concat(ey?"bg-[var(--accent-soft)] text-[var(--accent)]":""),"aria-label":"Table of contents",title:"Document outline",children:(0,r.jsx)(eT.A,{className:"w-4 h-4","aria-hidden":!0})}),ey&&(0,r.jsxs)("div",{className:"absolute right-0 top-full mt-1.5 w-64 max-h-72 overflow-y-auto rounded-xl border border-[var(--border)] bg-[var(--bg-primary)] shadow-xl p-1.5 z-40 animate-scale-in",children:[(0,r.jsx)("div",{className:"px-2.5 py-1 text-[10px] font-bold uppercase tracking-wider text-[var(--text-tertiary)]",children:"Outline"}),e5.map((e,t)=>(0,r.jsx)("button",{type:"button",onClick:()=>{var t;null==(t=document.getElementById(e.id))||t.scrollIntoView({behavior:"smooth",block:"start"}),ek(!1)},style:{paddingLeft:"".concat((e.level-1)*10+10,"px")},className:"w-full text-left py-1.5 pr-2.5 rounded-md text-xs text-[var(--text-secondary)] hover:bg-[var(--accent-soft)] hover:text-[var(--text-primary)] truncate transition-colors",children:e.text},"".concat(e.id,"-").concat(t)))]})]}),f&&(0,r.jsx)("button",{type:"button",onClick:f,className:"hidden md:inline-flex btn btn-icon-sm","aria-label":p?"Exit focus mode":"Enter focus mode",title:p?"Exit focus mode (Ctrl/Cmd+\\)":"Focus mode (Ctrl/Cmd+\\)",children:p?(0,r.jsx)(eF.A,{className:"w-4 h-4","aria-hidden":!0}):(0,r.jsx)(eP.A,{className:"w-4 h-4","aria-hidden":!0})}),(0,r.jsx)("button",{type:"button",onClick:e$,disabled:eu,className:"btn btn-icon-sm","aria-label":"Refresh file",title:"Refresh file content",children:(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-4 h-4 ".concat(eu?"animate-spin":""),children:[(0,r.jsx)("path",{d:"M21 2v6h-6"}),(0,r.jsx)("path",{d:"M3 12a9 9 0 0 1 15-6.7L21 8"}),(0,r.jsx)("path",{d:"M3 22v-6h6"}),(0,r.jsx)("path",{d:"M21 12a9 9 0 0 1-15 6.7L3 16"})]})}),k.path.endsWith(".html")&&!tp&&(0,r.jsx)("button",{type:"button",onClick:()=>ef(!0),className:"btn btn-icon-sm","aria-label":"Edit HTML source",title:"Edit HTML source",children:(0,r.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-4 h-4",children:(0,r.jsx)("path",{d:"M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),(0,r.jsx)("button",{type:"button",onClick:async()=>{if(!k)return;let e=!k.favorite;S({...k,favorite:e});try{if(!(await fetch("/api/files/".concat(k.id),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({favorite:e})})).ok)throw Error("PATCH failed");null==i||i()}catch(a){var t;S({...k,favorite:!e}),d.o.error("Failed to update favorite: ".concat(null!=(t=null==a?void 0:a.message)?t:"Network error"))}},className:"btn btn-icon-sm","aria-label":(null==k?void 0:k.favorite)?"Unfavorite":"Favorite",title:(null==k?void 0:k.favorite)?"Remove from favorites":"Add to favorites",children:(0,r.jsx)(tr,{filled:!!(null==k?void 0:k.favorite),className:"w-4 h-4 ".concat((null==k?void 0:k.favorite)?"text-amber-accent":"opacity-70")})}),(0,r.jsx)(R,{trigger:(0,r.jsx)("button",{type:"button",disabled:eU||eB,className:"btn btn-icon-sm","aria-label":"Export file",title:eU?"Generating PDF…":eB?"Generating PNG…":"Export file",children:(0,r.jsx)(tt,{className:"w-4 h-4 ".concat(eU||eB?"animate-pulse":"")})}),items:eK?[{label:"PDF",onSelect:eq},{label:"PNG",onSelect:()=>{k&&eV("/api/files/".concat(k.id,"/export-html?format=png"),"".concat(eI(),".png"),"PNG",eG)}}]:[{label:"Markdown (.md)",onSelect:()=>{k&&(ta(k.content,"".concat(eI(),".md"),"text/markdown"),d.o.success("Exported Markdown"))}},{label:"Text (.txt)",onSelect:()=>{eO()}},{label:"PDF",onSelect:eq}]}),(0,r.jsx)("button",{type:"button",onClick:()=>Q(!0),className:"btn btn-icon-sm btn-destructive","aria-label":"Delete file",title:"Delete file",children:(0,r.jsx)(te,{className:"w-4 h-4"})})]})})]}),!T&&!L&&(0,r.jsxs)("div",{className:"px-4 py-2 border-b border-[var(--border)] flex flex-wrap items-center gap-2 text-[12px] bg-[var(--bg-secondary)]/25",children:[(0,r.jsx)("span",{className:"text-[var(--text-tertiary)] uppercase tracking-wider text-[10px] font-bold",children:"Tags"}),(null!=(t=null==k?void 0:k.tags)?t:[]).map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-[var(--accent-soft)] border border-[var(--border-strong)] text-[var(--text-primary)]",children:[h?(0,r.jsx)("button",{type:"button",onClick:()=>h(e),className:"hover:text-[var(--accent)] transition-colors",title:'Filter files tagged "'.concat(e,'"'),children:e}):(0,r.jsx)("span",{children:e}),(0,r.jsx)("button",{type:"button","aria-label":"Remove tag ".concat(e),title:"Remove tag ".concat(e),onClick:async()=>{if(!k)return;let t=k.id,a=k.tags,r=a.filter(t=>t!==e);S(e=>e&&e.id===t?{...e,tags:r}:e);try{if(!(await fetch("/api/files/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:r})})).ok)throw Error("PATCH failed");null==i||i()}catch(e){var n;S(e=>e&&e.id===t?{...e,tags:a}:e),d.o.error("Failed to remove tag: ".concat(null!=(n=null==e?void 0:e.message)?n:"Network error"))}},className:"text-[var(--text-secondary)] hover:text-[var(--danger)] leading-none",children:"\xd7"})]},e)),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{type:"text",value:eb,onChange:e=>ev(e.target.value),onFocus:()=>ej(!0),onBlur:()=>setTimeout(()=>ej(!1),150),placeholder:"+ add tag…",className:"bg-transparent border-b border-transparent focus:border-[var(--accent)] outline-none px-1 py-0.5 w-28 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-tertiary)]",onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),tx(eb))}}),eg&&e3.length>0&&(0,r.jsx)("div",{className:"absolute left-0 top-full mt-1 w-44 rounded-lg border border-[var(--border)] bg-[var(--bg-primary)] shadow-xl py-1 z-30",children:e3.map(e=>(0,r.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),tx(e.name)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-[var(--accent-soft)] flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"truncate",children:e.name}),(0,r.jsx)("span",{className:"text-[10px] font-mono text-[var(--text-tertiary)]",children:e.count})]},e.id))})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:T?(0,r.jsx)(ez,{content:W,onChange:V,viewMode:P,onSave:()=>{tu()}}):L?(0,r.jsx)("div",{className:"h-full overflow-auto bg-[var(--bg-secondary)]/30 p-6",children:(0,r.jsxs)("div",{className:"max-w-3xl mx-auto space-y-4",children:[(0,r.jsx)("h3",{className:"text-xs font-bold text-[var(--text-secondary)] uppercase tracking-widest mb-4",children:"Version History (Time Travel)"}),I?(0,r.jsx)("div",{className:"space-y-3",children:[1,2,3].map(e=>(0,r.jsx)("div",{className:"skeleton h-20 w-full rounded-xl"},e))}):0===D.length?(0,r.jsx)("div",{className:"text-center py-12",children:(0,r.jsx)("p",{className:"text-[var(--muted)]",children:"No version history found for this file."})}):(0,r.jsx)("div",{className:"space-y-3",children:D.map(e=>{var t;let a=B===e.hash,n=U[e.hash];return(0,r.jsxs)("div",{className:"bg-[var(--bg-primary)] border border-[var(--border)] rounded-xl overflow-hidden shadow-sm hover:border-[var(--border-strong)] transition-colors",children:[(0,r.jsxs)("div",{className:"p-4 flex flex-wrap items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("p",{className:"text-sm font-semibold text-[var(--text-primary)] truncate",children:e.message}),(0,r.jsxs)("div",{className:"flex items-center gap-2.5 mt-1 text-[11px] text-[var(--text-secondary)]",children:[(0,r.jsx)("span",{children:new Date(e.date).toLocaleString()}),(0,r.jsx)("span",{className:"opacity-40",children:"•"}),(0,r.jsx)("span",{className:"font-mono text-[var(--accent)]",children:e.hash.substring(0,7)})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:()=>void to(e.hash),className:"btn btn-sm btn-outline",children:a?"Hide diff":"Preview diff"}),(0,r.jsx)("button",{type:"button",onClick:()=>ti(e.hash),className:"btn btn-sm btn-primary",children:"Restore"})]})]}),a&&(0,r.jsx)("div",{className:"border-t border-[var(--border)] bg-[var(--bg-secondary)]/50 p-3 max-h-72 overflow-auto font-mono text-xs",children:(null==n?void 0:n.loading)?(0,r.jsx)("div",{className:"text-[var(--text-secondary)] py-2",children:"Loading diff…"}):(null==n?void 0:n.error)?(0,r.jsx)("div",{className:"text-[var(--danger)] py-2",children:n.error}):(null==n||null==(t=n.diff)?void 0:t.trim())?(0,r.jsx)("div",{className:"space-y-0.5 leading-5",children:n.diff.split("\n").map((e,t)=>{let a=e.startsWith("+")&&!e.startsWith("+++")?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":e.startsWith("-")&&!e.startsWith("---")?"bg-red-500/15 text-red-700 dark:text-red-300":e.startsWith("@@")?"text-[var(--accent)] opacity-80":"text-[var(--text-secondary)]";return(0,r.jsx)("div",{className:"px-2 whitespace-pre-wrap break-all rounded-sm ".concat(a),children:e||" "},t)})}):(0,r.jsx)("div",{className:"text-[var(--text-secondary)] py-2 italic",children:"Identical to the latest saved revision."})})]},e.hash)})})]})}):(0,r.jsxs)("div",{className:"h-full overflow-auto",children:[k.path.endsWith(".mmd")?(0,r.jsx)(eL.q,{source:k.content,className:"p-8",filename:k.title}):k.path.endsWith(".html")?(0,r.jsx)(e_,{html:k.content}):(0,r.jsx)(eE.Gd,{content:k.content,className:"p-8"}),!k.path.endsWith(".mmd")&&!k.path.endsWith(".html")&&u&&(0,r.jsx)(e9,{fileId:k.id,onSelectFile:u})]})}),(0,r.jsx)(ew.T,{open:null!==z,onClose:()=>K(null),onConfirm:()=>{K(null),z&&td(z)},title:"Discard unsaved changes?",message:"You have unsaved edits in this document. Switching tabs will discard them.",confirmLabel:"Discard changes",destructive:!0}),(0,r.jsx)(eN,{open:X,title:k.title,onClose:()=>Q(!1),onConfirm:th,loading:et}),(0,r.jsx)(e7,{open:er,onClose:()=>en(!1),title:el,body:eo,detail:ec}),ep&&k&&(0,r.jsx)(eR,{fileId:k.id,initial:k.content,expectedUpdatedAt:k.updated_at,onClose:()=>{ef(!1),eQ(!1)},onDirtyChange:eQ,onSaved:e=>{let t=k.id;if(eQ(!1),eY.current!==t){e.git_warning&&console.warn("[kontexta] git_warning for stale file ".concat(t,":"),e.git_warning);return}S(e),e.git_warning&&(es("Git commit failed"),ei("Your changes were saved to the database, but Kontexta could not create a Git history entry for this file."),ed(e.git_warning),en(!0))}})]},s)}var tl=a(96405);let ts="hooksBannerDismissed";function to(e){var t,a;let{onOpen:l}=e,{state:s}=(0,tl._)(),[o,i]=(0,n.useState)(null);(0,n.useEffect)(()=>{i(sessionStorage.getItem(ts))},[]);let c=null!=(t=null==s?void 0:s.alerts)?t:[],d=null!=(a=null==s?void 0:s.mcp_alerts)?a:[],u="".concat(c.map(e=>e.agent).sort().join(","),"|mcp:").concat(d.map(e=>e.agent).sort().join(","));if(0===c.length&&0===d.length||o===u)return null;let x=c.filter(e=>!e.installed).map(e=>e.name),h=c.filter(e=>e.installed).map(e=>e.name),p=[];return x.length>0&&p.push("Hooks not installed for ".concat(x.join(", "))),h.length>0&&p.push("No events yet from ".concat(h.join(", "))),d.length>0&&p.push("MCP not connected for ".concat(d.map(e=>e.name).join(", "))),(0,r.jsxs)("div",{role:"alert","aria-label":p.join(". "),className:"mx-4 mt-2 flex items-center gap-3 rounded-lg border border-[var(--border)] bg-[var(--accent-soft)] px-4 py-2 text-[var(--text-primary)]",children:[(0,r.jsx)(m.A,{className:"h-4 w-4 shrink-0 text-[var(--accent)]","aria-hidden":!0}),(0,r.jsxs)("p",{className:"flex-1 text-sm",children:[p.join(". "),"."]}),(0,r.jsx)("button",{className:"btn btn-sm btn-outline",onClick:l,children:d.length>0?"Set up agents":"Set up hooks"}),(0,r.jsx)("button",{className:"btn btn-icon-sm","aria-label":"Dismiss",onClick:()=>{sessionStorage.setItem(ts,u),i(u)},children:(0,r.jsx)(V.A,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function ti(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,[a,r]=(0,n.useState)([]),[l,s]=(0,n.useState)(""),[o,i]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{r([]),s("");let t=!1,a=new AbortController;return async function(){i(!0);try{let n=await fetch(e?"/api/folders?projectId=".concat(e):"/api/folders",{signal:a.signal});if(t)return;if(n.ok){let e=await n.json();if(t)return;r(e.folders),s(e.basePath)}}catch(e){if((null==e?void 0:e.name)==="AbortError")return;console.error("Failed to fetch folders:",e)}finally{t||i(!1)}}(),()=>{t=!0,a.abort()}},[e,t]),{folders:a,basePath:l,loading:o}}var tc=a(31144);function td(e){let{segments:t}=e;return 0===t.length?null:(0,r.jsx)("nav",{"aria-label":"Breadcrumb",className:"h-8 px-4 flex items-center gap-1.5 text-[13px] border-b border-[var(--border)] bg-[var(--bg-tertiary)] text-[var(--text-secondary)] select-none",children:t.map((e,a)=>{let n=a===t.length-1;return(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[a>0&&(0,r.jsx)(Y.A,{className:"w-3.5 h-3.5 opacity-40","aria-hidden":!0}),n||!e.onClick?(0,r.jsx)("span",{className:n?"font-bold text-[var(--text-primary)]":"",children:e.label}):(0,r.jsx)("button",{onClick:e.onClick,className:"hover:text-[var(--accent)] transition-colors",children:e.label})]},"".concat(a,"-").concat(e.label))})})}function tu(e){var t,a,l;let{items:o,footer:i,conflictsItem:c,unresolvedConflicts:d}=e,[u,x]=(0,n.useState)(null),[h,m]=(0,n.useState)(()=>null!=d?d:0),p=null;try{p=(0,s.useRouter)()}catch(e){}let f="";try{f=null!=(t="function"==typeof s.usePathname?(0,s.usePathname)():null)?t:""}catch(e){f=window.location.pathname||""}(0,n.useEffect)(()=>{if(void 0!==d)return void m(d);let e=!1,t=async()=>{try{let t=await fetch("/api/conflicts?status=unresolved&limit=1",{cache:"no-store"});if(t.ok){let a=await t.json();e||"number"!=typeof(null==a?void 0:a.unresolved)||m(a.unresolved)}}catch(e){}};t();let a=setInterval(()=>{"undefined"!=typeof document&&document.hidden||t()},15e3),r=()=>{t()};return window.addEventListener("kontexta:conflicts-changed",r),()=>{e=!0,clearInterval(a),window.removeEventListener("kontexta:conflicts-changed",r)}},[d]);let b=o.some(e=>"conflicts"===e.id),v={id:"conflicts",label:"Conflict Manager",active:"/conflicts"===f,onClick:()=>{try{p?p.push("/conflicts"):window.location.href="/conflicts"}catch(e){}},icon:(0,r.jsx)(C.A,{className:"w-5 h-5",strokeWidth:2.2}),badge:h>0?h:void 0,href:"/conflicts"},g=b?null:void 0===c?v:c,j=o.some(e=>"brain"===e.id)?null:{id:"brain",label:"Brain",active:"/brain"===f,onClick:()=>{try{p?p.push("/brain"):window.location.href="/brain"}catch(e){}},icon:(0,r.jsx)(A.A,{className:"w-5 h-5",strokeWidth:2.2}),href:"/brain"},y=null!=(a=[...o,...g?[g]:[],...j?[j]:[],...i?[i]:[]].find(e=>e.id===u))?a:null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"w-14 shrink-0 bg-[var(--bg-secondary)] border-r border-[var(--border)] flex flex-col items-center py-4 gap-4 z-50",children:[(0,r.jsx)("div",{className:"flex flex-col items-center gap-3 w-full",children:o.map(e=>(0,r.jsx)(tx,{item:e,onPeek:()=>x(e.id)},e.id))}),(0,r.jsx)("div",{className:"flex-1"}),(g||j||i)&&(0,r.jsxs)("div",{className:"pt-4 border-t border-[var(--border)] w-full flex flex-col items-center gap-3",children:[g&&(0,r.jsx)(tx,{item:g,onPeek:()=>x(g.id),badge:null!=(l=g.badge)?l:h>0?h:void 0}),j&&(0,r.jsx)(tx,{item:j,onPeek:()=>x(j.id)}),i&&(0,r.jsx)(tx,{item:i,onPeek:()=>x(i.id)})]})]}),(null==y?void 0:y.peek)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-40 bg-black/20 backdrop-blur-sm transition-all",onClick:()=>x(null)}),(0,r.jsxs)("div",{className:"absolute z-50 left-16 top-16 w-64 max-h-[80vh] overflow-auto bg-[var(--bg-secondary)]/90 backdrop-blur-xl border border-amber-accent/20 rounded-xl shadow-2xl p-4 animate-fade-in",children:[(0,r.jsx)("div",{className:"text-[10px] font-black uppercase tracking-[0.2em] text-amber-accent/70 mb-4",children:y.label}),(0,r.jsx)("div",{className:"scrollbar-thin",children:y.peek})]})]})]})}function tx(e){var t;let{item:a,onPeek:n,badge:l}=e,s=a.label.charAt(0).toUpperCase(),o="kb"===a.id,i="conflicts"===a.id||"conflict-manager"===a.id,c=null!=(t=a.badge)?t:l,d=c?"".concat(a.label," (").concat(c," unresolved)"):a.label;return(0,r.jsxs)("button",{title:d,onClick:()=>{a.onClick(),a.peek&&n()},className:"\n w-10 h-10 flex items-center justify-center relative rounded-xl transition-all duration-300 group hover-lift\n ".concat(a.active?"bg-amber-accent text-white shadow-[0_0_20px_rgba(180,120,30,0.4)]":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:bg-[var(--accent-soft)] hover:text-[var(--text-primary)] active:scale-95","\n "),"aria-label":a.label,"data-testid":"rail-button-".concat(a.id),children:[a.active&&(0,r.jsx)("span",{className:"absolute -left-3 top-1/2 -translate-y-1/2 w-1.5 h-6 bg-amber-accent rounded-r-full shadow-[4px_0_15px_rgba(180,120,30,0.6)] bp-keep-round"}),a.icon?a.icon:o?(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"w-5 h-5",children:[(0,r.jsx)("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20"}),(0,r.jsx)("path",{d:"M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"})]}):i?(0,r.jsx)(C.A,{className:"w-5 h-5",strokeWidth:2.2}):(0,r.jsx)("span",{className:"font-black text-sm tracking-tighter",children:s}),!!c&&(0,r.jsx)("span",{"data-testid":"rail-badge-".concat(a.id),className:"absolute -top-1 -right-1 flex h-4 min-w-4 px-1 items-center justify-center rounded-full bg-amber-accent text-[10px] font-extrabold text-black leading-none shadow-md",children:c})]})}var th=a(2720);let tm=(0,l.default)(()=>a.e(8693).then(a.bind(a,48693)).then(e=>e.SearchDialog),{loadableGenerated:{webpack:()=>[48693]},ssr:!1}),tp=(0,l.default)(()=>a.e(9699).then(a.bind(a,9699)).then(e=>e.AboutDialog),{loadableGenerated:{webpack:()=>[9699]},ssr:!1}),tf=(0,l.default)(()=>a.e(1130).then(a.bind(a,41130)).then(e=>e.DocsModal),{loadableGenerated:{webpack:()=>[41130]},ssr:!1}),tb=(0,l.default)(()=>a.e(807).then(a.bind(a,70807)).then(e=>e.FirstRunWizard),{loadableGenerated:{webpack:()=>[70807]},ssr:!1}),tv=(0,l.default)(()=>a.e(4283).then(a.bind(a,84283)).then(e=>e.NewFileDialog),{loadableGenerated:{webpack:()=>[84283]},ssr:!1}),tg=(0,l.default)(()=>a.e(3987).then(a.bind(a,13987)).then(e=>e.NewFolderDialog),{loadableGenerated:{webpack:()=>[13987]},ssr:!1}),tj=(0,l.default)(()=>a.e(2966).then(a.bind(a,22966)).then(e=>e.DeleteFolderDialog),{loadableGenerated:{webpack:()=>[22966]},ssr:!1}),ty=(0,l.default)(()=>a.e(2205).then(a.bind(a,62205)).then(e=>e.UnregisterModal),{loadableGenerated:{webpack:()=>[62205]},ssr:!1}),tw=(0,l.default)(()=>a.e(3259).then(a.bind(a,43259)).then(e=>e.PublishDialog),{loadableGenerated:{webpack:()=>[43259]},ssr:!1}),tN="kontexta:show-journal:v1",tk="kontexta:recent-files:v1",tS="kontexta:focus-mode:v1";function tC(e){let t=(0,n.useRef)(!1);return e&&(t.current=!0),t.current}function tA(){let e=(0,s.useRouter)(),[t,a]=(0,n.useState)(!1),[l,u]=(0,n.useState)(!1),[x,h]=(0,n.useState)(!1),[m,p]=(0,n.useState)(void 0),[f,b]=(0,n.useState)(!1),[v,g]=(0,n.useState)(1),[j,y]=(0,n.useState)(0),[w,N]=(0,n.useState)(!1),[k,S]=(0,n.useState)(!1),[C,A]=(0,n.useState)(null),[T,F]=(0,n.useState)(!1),[P,E]=(0,n.useState)(!1),[L,_]=(0,n.useState)(!1),[R,D]=(0,n.useState)("publish"),[O,H]=(0,n.useState)(!1),[B,G]=(0,n.useState)(!1),[z,K]=(0,n.useState)(null),[W,J]=(0,n.useState)(null),[V,q]=(0,n.useState)(null),[$,Y]=(0,n.useState)(null),[Z,X]=(0,n.useState)(null),[Q,ee]=(0,n.useState)(null),[et,ea]=(0,n.useState)([]),[er,en]=(0,n.useState)("updated_at"),[el,es]=(0,n.useState)(0),[eo,ec]=(0,n.useState)(!1),[ed,eu]=(0,n.useState)(!1),[ex,eh]=(0,n.useState)([]),[em,ep]=(0,n.useState)("files"),eb=(0,n.useRef)(null),ev=(0,s.useSearchParams)();(0,n.useEffect)(()=>{let e=ev.get("setup"),t=ev.get("configure"),a=ev.get("file"),r=!1,n=new URL(window.location.href);if("1"===e&&(g(1),b(!0),n.searchParams.delete("setup"),r=!0),"1"===t&&(h(!0),n.searchParams.delete("configure"),r=!0),a&&/^\d+$/.test(a)){let e=Number(a);e>0&&(eb.current=e,Y(e),ep("read")),n.searchParams.delete("file"),r=!0}r&&window.history.replaceState({},"",n.toString())},[]),(0,n.useEffect)(()=>{let e=sessionStorage.getItem("selectedSection"),t=sessionStorage.getItem("selectedProjectId");e?q(e):q("knowledge"),t&&K(Number(t));try{"true"===localStorage.getItem(tN)&&ec(!0),"true"===localStorage.getItem(tS)&&eu(!0);let e=localStorage.getItem(tk);if(e){let t=JSON.parse(e);Array.isArray(t)&&eh(t.filter(e=>"number"==typeof e&&e>0).slice(0,6))}}catch(e){}},[]),(0,n.useEffect)(()=>{$&&eh(e=>{let t=[$,...e.filter(e=>e!==$)].slice(0,6);try{localStorage.setItem(tk,JSON.stringify(t))}catch(e){}return t})},[$]);let eg=(0,n.useCallback)(()=>{let e=!eo;ec(e);try{localStorage.setItem(tN,String(e))}catch(e){}!e&&"knowledge"===V&&(0,ef.sZ)(Z)&&X(null)},[eo,V,Z]),{projects:ej,loading:ey,refresh:eN}=function(){let[e,t]=(0,n.useState)([]),[a,r]=(0,n.useState)(!0),l=(0,n.useRef)(0),s=(0,n.useCallback)(async()=>{let e=++l.current;try{r(!0);let a=await fetch("/api/projects");if(a.ok){let r=await a.json();if(e!==l.current)return;t(r)}}catch(e){console.error("Failed to fetch projects:",e)}finally{e===l.current&&r(!1)}},[]);return(0,n.useEffect)(()=>{s()},[s]),{projects:e,loading:a,refresh:s}}(),eS=function(){let[e,t]=(0,n.useState)(0);return(0,n.useEffect)(()=>{let e=!1,a=async()=>{try{let a=await fetch("/api/conflicts?count=1",{cache:"no-store"});if(a.ok){let r=await a.json();e||"number"!=typeof(null==r?void 0:r.count)||t(r.count)}}catch(e){}};a();let r=setInterval(()=>{"undefined"!=typeof document&&document.hidden||a()},15e3),n=()=>{a()},l=()=>{"undefined"==typeof document||document.hidden||a()};return window.addEventListener("kontexta:conflicts-changed",n),"undefined"!=typeof document&&document.addEventListener("visibilitychange",l),()=>{e=!0,clearInterval(r),window.removeEventListener("kontexta:conflicts-changed",n),"undefined"!=typeof document&&document.removeEventListener("visibilitychange",l)}},[]),e}(),eC=async()=>{if(z)try{let e=await fetch("/api/projects/".concat(z),{method:"DELETE"});if(e.ok)K(null),q(null),X(null),Y(null),sessionStorage.removeItem("selectedSection"),sessionStorage.removeItem("selectedProjectId"),eN(),d.o.success("Project unregistered");else{let t=await e.json().catch(()=>({}));d.o.error(t.error||"Failed to unregister project")}}catch(t){var e;d.o.error("Failed to unregister project: ".concat(null!=(e=null==t?void 0:t.message)?e:"Network error"))}},{folders:eA,basePath:eT}=ti(null,el),{folders:eF,basePath:eP}=ti("projects"===V?z:null,el),{files:eE,loading:eL,refresh:e_}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[t,a]=(0,n.useState)([]),[r,l]=(0,n.useState)(!0),s=(0,n.useRef)(e);s.current=e;let o=(0,n.useRef)(0),i=(0,n.useRef)(null),c=(0,n.useCallback)(async()=>{var e;let t=s.current,r=++o.current;null==(e=i.current)||e.abort();let n=new AbortController;i.current=n;try{l(!0);let e=new URLSearchParams;void 0!==t.project_id&&e.append("project_id",null===t.project_id?"none":t.project_id.toString()),t.tag&&e.append("tag",t.tag),void 0!==t.favorite&&e.append("favorite",t.favorite.toString()),t.folder&&e.append("folder",t.folder);let s="/api/files".concat(e.toString()?"?".concat(e.toString()):""),i=await fetch(s,{signal:n.signal});if(r!==o.current)return;if(i.ok){let e=await i.json();if(r!==o.current)return;a(e)}}catch(e){if((null==e?void 0:e.name)==="AbortError")return;console.error("Failed to fetch files:",e)}finally{r===o.current&&l(!1)}},[]);return(0,n.useEffect)(()=>(a([]),c(),()=>{var e;return null==(e=i.current)?void 0:e.abort()}),[e.project_id,e.tag,e.favorite,e.folder,c]),{files:t,loading:r,refresh:c}}({}),eR=(0,n.useMemo)(()=>{let e=eE.filter(e=>!(null===e.project_id&&/(^|[\\/])knowledge[\\/]profile\.md$/i.test(e.path)));return eo||(e=e.filter(e=>!(0,ef.Ai)(e,eT))),"favorites"===V?e=e.filter(e=>e.favorite):"projects"===V&&null!==z&&(e=e.filter(e=>e.project_id===z)),Q&&(e=e.filter(e=>{var t;return(null!=(t=e.tags)?t:[]).includes(Q)})),e},[eE,V,z,Q,eo,eT]),eD=(0,n.useMemo)(()=>eE.filter(e=>!e.project_id&&(eo||!(0,ef.Ai)(e,eT))),[eE,eo,eT]),eM=(0,n.useCallback)(e=>{if(e.project_id){let t=ej.find(t=>t.id===e.project_id);q("projects"),K(e.project_id),sessionStorage.setItem("selectedSection","projects"),sessionStorage.setItem("selectedProjectId",String(e.project_id)),(null==t?void 0:t.path)&&e.path.startsWith(t.path)?X(e.path.slice(t.path.length).replace(/^[\/\\]+/,"").split(/[\/\\]/).slice(0,-1).join("/")||null):X(null)}else q("knowledge"),K(null),sessionStorage.setItem("selectedSection","knowledge"),sessionStorage.removeItem("selectedProjectId"),!eo&&(0,ef.Ai)(e,eT)?X(null):eT&&e.path.startsWith(eT)?X(e.path.slice(eT.length).replace(/^[\/\\]+/,"").split(/[\/\\]/).slice(0,-1).join("/")||null):X(null)},[ej,eT,eo]);(0,n.useEffect)(()=>{if(null==eb.current)return;let e=eE.find(e=>e.id===eb.current);e&&(eM(e),eb.current=null)},[eE,eM]),(0,n.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch("/api/tags");if(!t.ok)return;let a=await t.json();e||ea(a)}catch(e){}})(),()=>{e=!0}},[eE]);let eI=e=>{(!e||eQ(()=>eI(e)))&&(ee(e),e&&(q("tags"),K(null),X(null),Y(null),ep("files"),sessionStorage.setItem("selectedSection","tags"),sessionStorage.removeItem("selectedProjectId")))},eO=ej.find(e=>e.id===z),eU=tC(t),eH=tC(l),eB=tC(x),eG=tC(w),ez=tC(k),eK=tC(T),eW=tC(P),eJ=tC(L),eV=(0,n.useRef)(null),eq=(0,n.useCallback)(e=>{eV.current||(eV.current=setTimeout(()=>{eV.current=null,e_()},350))},[e_]);(0,n.useEffect)(()=>()=>{eV.current&&clearTimeout(eV.current)},[]);let e$=(0,n.useRef)(eq);e$.current=eq,(0,n.useEffect)(()=>{let e={ws:null,reconnectTimer:null,cancelled:!1,stopReconnecting:!1,attempt:0},t=e=>{e&&(e.onmessage=null,e.onclose=null,e.onerror=null,e.onopen=null)},a=async()=>{if(e.cancelled||e.stopReconnecting)return;let r="https:"===window.location.protocol?"wss:":"ws:",n=tc.env.NEXT_PUBLIC_WS_TOKEN||"",l="";try{let e=await fetch("/api/auth/token");e.ok&&(l=(await e.json()).token)}catch(e){console.warn("[Kontexta] WS could not fetch session token:",e)}if(e.cancelled||e.stopReconnecting)return;let s=l||n,o=s?"?token=".concat(encodeURIComponent(s)):"",i="".concat(r,"//").concat(window.location.host,"/_kontexta_ws").concat(o);if(e.ws){t(e.ws);try{e.ws.close()}catch(e){}e.ws=null}let c=new WebSocket(i);e.ws=c,c.onopen=()=>{e.attempt=0},c.onmessage=e=>{try{let t=JSON.parse(e.data);e$.current(t)}catch(e){}},c.onclose=t=>{if(e.cancelled)return;if(1008===t.code||4401===t.code){console.warn("[Kontexta] WS auth failed; stopping reconnect attempts"),e.stopReconnecting=!0;return}e.attempt++;let r=Math.min(3e4,1e3*2**Math.min(e.attempt,5))*(.75+.5*Math.random());e.reconnectTimer=setTimeout(a,r)},c.onerror=()=>{}};return a(),()=>{e.cancelled=!0,e.reconnectTimer&&clearTimeout(e.reconnectTimer),t(e.ws);try{var a;null==(a=e.ws)||a.close()}catch(e){}e.ws=null}},[]);let eY=I("(max-width: 767px)"),[eZ,eX]=(0,n.useState)(!1);(0,n.useEffect)(()=>eX(!0),[]);let{confirmDiscardIfDirty:eQ,setDirty:e0,dialog:e1}=function(){let e=(0,n.useRef)(new Set),[t,a]=(0,n.useState)(null),l=(0,n.useCallback)((t,a)=>{a?e.current.add(t):e.current.delete(t)},[]),s=(0,n.useCallback)(t=>0===e.current.size||(a(()=>t),!1),[]);return(0,n.useEffect)(()=>{let t=t=>{e.current.size>0&&(t.preventDefault(),t.returnValue="")};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[]),{confirmDiscardIfDirty:s,setDirty:l,dialog:(0,r.jsx)(ew.T,{open:null!==t,onClose:()=>a(null),onConfirm:()=>{e.current.clear(),a(null),null==t||t()},title:"Unsaved changes",message:"You have unsaved changes in the open file. Discard them?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0})}}(),e2=e=>{eQ(()=>e2(e))&&(K(e),q("projects"),Y(null),X(null),ee(null),ep("files"),sessionStorage.setItem("selectedSection","projects"),sessionStorage.setItem("selectedProjectId",String(e)))},e5=()=>{eQ(()=>e5())&&(q("knowledge"),K(null),Y(null),X(null),ee(null),ep("files"),sessionStorage.setItem("selectedSection","knowledge"),sessionStorage.removeItem("selectedProjectId"))},e3=()=>{eQ(()=>e3())&&(q("favorites"),K(null),Y(null),X(null),ee(null),ep("files"),sessionStorage.setItem("selectedSection","favorites"),sessionStorage.removeItem("selectedProjectId"))},e4=e=>{eQ(()=>e4(e))&&(q("knowledge"),K(null),Y(null),X(e),ee(null),ep("files"),sessionStorage.setItem("selectedSection","knowledge"),sessionStorage.removeItem("selectedProjectId"))},e6=(e,t)=>{if(e!==$&&!eQ(()=>e6(e,t)))return;let a=eE.find(t=>t.id===e);a&&eM(a),Y(e),ep("read")},e8=e=>{eQ(()=>e8(e))&&(X(e),Y(null),ep("files"))},e9=(0,n.useCallback)(async()=>{H(!0);try{let e=await fetch("/api/refresh",{method:"POST",body:JSON.stringify({projectId:z}),headers:{"Content-Type":"application/json"}});if(e.ok)e_(),e_(),es(e=>e+1),d.o.success("Index refreshed");else{let t=await e.json().catch(()=>({}));d.o.error(t.error||"Refresh failed")}}catch(t){var e;d.o.error("Failed to refresh: ".concat(null!=(e=null==t?void 0:t.message)?e:"Network error"))}finally{H(!1)}},[z,e_,e_]),e7=e=>{(e.id===$||eQ(()=>e7(e)))&&(eM(e),Y(e.id),ep("read"),a(!1))},te=async(e,t,a,r,n,l)=>{try{let s=await fetch("/api/files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e,content:t,destination:a,projectId:z,folder:r,format:n,kind:l})}),o=await s.json().catch(()=>({}));if(s.ok)return N(!1),d.o.success('Created "'.concat(e,'"')),await e_(),"number"==typeof o.id&&Y(o.id),!0;return d.o.error(o.error||"Failed to create file"),!1}catch(e){var s;return d.o.error("Failed to create file: ".concat(null!=(s=null==e?void 0:e.message)?s:"Network error")),!1}},tt=async e=>{try{let t=await fetch("/api/files/".concat(e),{method:"DELETE"});if(t.ok)e_(),es(e=>e+1),Y(t=>t===e?null:t),d.o.success("File deleted");else{let e=await t.json().catch(()=>({}));d.o.error(e.error||"Failed to delete file")}}catch(e){var t;d.o.error("Failed to delete file: ".concat(null!=(t=null==e?void 0:e.message)?t:"Network error"))}},ta=async e=>{try{let t=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:W&&W>0?W:null,name:e})});if(t.ok)return S(!1),W&&0!==W?X(e):(q("knowledge"),K(null),X(e),sessionStorage.setItem("selectedSection","knowledge"),sessionStorage.removeItem("selectedProjectId")),es(e=>e+1),d.o.success('Folder "'.concat(e,'" created')),!0;{let e=await t.json().catch(()=>({}));return d.o.error(e.error||"Failed to create folder"),!1}}catch(e){var t;return d.o.error("Failed to create folder: ".concat(null!=(t=null==e?void 0:e.message)?t:"Network error")),!1}},tr=async()=>{if(Z){if("knowledge"===V&&(0,ef.BZ)(Z)){d.o.error("Cannot delete root knowledge folders"),F(!1);return}G(!0);try{let e=await fetch("/api/folders?name=".concat(encodeURIComponent(Z),"&projectId=").concat(z||""),{method:"DELETE"});if(e.ok)X(null),es(e=>e+1),F(!1),d.o.success("Folder deleted");else{let t=await e.json().catch(()=>({}));d.o.error(t.error||"Failed to delete folder")}}catch(t){var e;d.o.error("Failed to delete folder: ".concat(null!=(e=null==t?void 0:t.message)?e:"Network error"))}finally{G(!1)}}},tl=(0,n.useCallback)(()=>{eu(e=>{let t=!e;try{localStorage.setItem(tS,String(t))}catch(e){}return t})},[]);(0,n.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"k"===e.key.toLowerCase()?(e.preventDefault(),a(e=>!e)):(e.metaKey||e.ctrlKey)&&"\\"===e.key&&(e.preventDefault(),tl())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[tl]);let ts=(0,n.useMemo)(()=>{var e,t;let a=[];"favorites"===V?a.push({label:"Favorites",onClick:e3}):"knowledge"===V?a.push({label:"Knowledge",onClick:e5}):"projects"===V&&eO?a.push({label:eO.name,onClick:()=>e2(eO.id)}):"tags"===V&&Q&&a.push({label:"#".concat(Q),onClick:()=>eI(Q)});let r=$?eR.find(e=>e.id===$)||eE.find(e=>e.id===$):null,n="projects"===V?null!=(t=null==eO?void 0:eO.path)?t:null:null!=eT?eT:null,l=[];return r&&n&&(null==(e=r.path)?void 0:e.startsWith(n))?l=r.path.slice(n.length).replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).slice(0,-1):Z&&(l=Z.split("/").filter(Boolean)),l.forEach(e=>a.push({label:e})),r&&a.push({label:r.title}),a},[V,eO,$,eR,eE,eT,Z]),tx=ej.map(e=>({id:"p-".concat(e.id),label:e.name,active:"projects"===V&&z===e.id,onClick:()=>e2(e.id)})),tA=(0,n.useMemo)(()=>{let e=new Map(eE.map(e=>[e.id,e])),t=[];for(let l of ex){var a,r,n;let s=e.get(l);s&&(!eo&&(0,ef.Ai)(s,eT)||t.push({id:s.id,title:s.title,storage_type:null!=(a=s.storage_type)?a:"local",path:s.path,project_id:null!=(r=s.project_id)?r:null,content_class:null!=(n=s.content_class)?n:null}))}return t},[eE,ex,eo,eT]),tT=(0,n.useCallback)(()=>{let e=eE.find(e=>null===e.project_id&&/(^|[\\/])knowledge[\\/]profile\.md$/i.test(e.path));if(e){if(e.id!==$&&!eQ(()=>tT()))return;eM(e),Y(e.id),ep("read")}else g(3),b(!0)},[eE,$,eQ,eM]),tF=(0,n.useMemo)(()=>{let e={};for(let a of eE)if(null!=a.project_id){var t;e[a.project_id]=(null!=(t=e[a.project_id])?t:0)+1}return e},[eE]),tP=(0,n.useMemo)(()=>{var e;if(null!=$)return null==(e=eE.find(e=>e.id===$))?void 0:e.favorite},[eE,$]),tE=(0,n.useCallback)(async(e,t)=>{try{let a=await fetch("/api/files/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({favorite:t})});if(!a.ok)throw Error("HTTP ".concat(a.status));e_()}catch(e){var a;d.o.error("Failed to update favorite: ".concat(null!=(a=null==e?void 0:e.message)?a:"Network error"))}},[e_]),tL=(0,n.useMemo)(()=>[{id:"new-file",label:"New File",hint:"Create a KB or project note",onRun:()=>N(!0)},{id:"toggle-focus",label:ed?"Exit Focus Mode":"Toggle Focus Mode",hint:"Ctrl/Cmd+\\",onRun:tl},{id:"graph",label:"Open Knowledge Graph",hint:"/graph",onRun:()=>e.push("/graph")},{id:"hygiene",label:"Knowledge Hygiene",hint:"/hygiene",onRun:()=>e.push("/hygiene")},{id:"toggle-journal",label:eo?"Hide Journal Files":"Show Journal Files",hint:"Toggle agent journal visibility",onRun:eg},{id:"refresh",label:"Scan / Refresh Files",hint:"Re-scan disk for changes",onRun:()=>{e9()}},{id:"calendar",label:"Open Calendar",hint:"/calendar",onRun:()=>e.push("/calendar")},{id:"conflicts",label:"View Sync Conflicts",hint:"/conflicts",onRun:()=>e.push("/conflicts")},{id:"brain",label:"Brain & Relay Sync",hint:"/brain",onRun:()=>e.push("/brain")},{id:"configure",label:"Configure Kontexta",hint:"Tools, Agents, Journal settings",onRun:()=>h(!0)},{id:"publish",label:"Publish Documentation",hint:"Build static HTML docs",onRun:()=>{D("publish"),_(!0)}}],[ed,tl,eo,e,eg,e9]);if(!eZ)return(0,r.jsx)("div",{className:"h-screen bg-[var(--bg-primary)]"});let t_=(0,r.jsx)(ei,{projects:ej,projectFiles:eR,knowledgeFiles:eD,selectedProjectId:z,selectedSection:V,selectedFolder:Z,projectFolders:eF||[],knowledgeFolders:eA||[],projectBasePath:eP,knowledgeBasePath:eT,projectFileCounts:tF,onSelectProject:e2,onSelectKnowledge:e5,onSelectFavorites:e3,onSelectKnowledgeFolder:e4,onSelectFolder:e8,onSelectFile:e=>e6(e,!0),selectedTag:Q,tags:et,onSelectTag:eI,onCreateBucketFolder:e=>{J(0),A(e),S(!0)},showJournal:eo,onToggleShowJournal:eg}),tR=(0,r.jsx)(ek,{files:eR,selectedFileId:$,onSelectFile:e6,sortBy:er,onSortChange:en,selectedFolder:Z,selectedProject:null!=eO?eO:null,selectedSection:V,basePath:"projects"===V?eP:eT,loading:eL||ey,onUnregisterProject:()=>E(!0),onDeleteFolder:()=>{Z&&("knowledge"===V&&(0,ef.BZ)(Z)||F(!0))},projects:ej,onUploaded:e_,onRefresh:e9,onOnboarded:()=>{eN(),e_()},refreshing:O,onNewFile:()=>N(!0),onToggleFavorite:tE,onDeleteFile:tt,showJournal:eo}),tD=(0,r.jsx)(tn,{fileId:$,onDelete:tt,onChanged:e_,onDirtyChange:e0,onNavigateToFile:e=>e6(e),allTags:et,onSelectTag:e=>eI(e),focusMode:ed,onToggleFocus:tl,recentFiles:tA,onNewFile:()=>N(!0),onOpenProfile:tT,unresolvedConflicts:eS,externalFavorite:tP,welcomeRefreshKey:j});return(0,r.jsxs)("div",{className:"h-screen flex flex-col",children:[(0,r.jsx)(M,{onSearch:()=>a(!0),onAbout:()=>u(!0),onConfigure:()=>h(!0),onPublish:()=>{D("publish"),_(!0)},onViewPublished:()=>window.open("/api/publish/html","_blank"),onNewFile:()=>N(!0),focusMode:ed,onToggleFocus:tl,unresolvedConflicts:eS}),(0,r.jsx)(td,{segments:ts}),e1,(0,r.jsx)(to,{onOpen:()=>{p("agents"),h(!0)}}),(0,r.jsxs)("div",{className:"flex flex-1 min-h-0",children:[(0,r.jsx)(th.A,{unresolvedConflicts:eS,onConfigure:()=>h(!0),onLock:async()=>{await fetch("/api/auth/logout",{method:"POST"}),e.push("/login")}}),(0,r.jsx)(U,{isPhone:eY,mobileTab:em,leftCollapsed:ed,middleCollapsed:ed,leftRail:(0,r.jsx)(tu,{items:tx,footer:{id:"kb",label:"Knowledge Base",active:"knowledge"===V,onClick:e5},unresolvedConflicts:eS}),left:t_,middle:tR,right:tD})]}),eY&&(0,r.jsxs)("nav",{"aria-label":"Mobile navigation",className:"h-14 shrink-0 border-t border-[var(--border)] bg-[var(--bg-secondary)] grid grid-cols-3 text-xs",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>ep("browse"),"aria-current":"browse"===em?"page":void 0,className:"flex flex-col items-center justify-center gap-1 transition-colors ".concat("browse"===em?"text-[var(--accent)] font-semibold":"text-[var(--text-secondary)]"),children:[(0,r.jsx)(o.A,{className:"w-4 h-4","aria-hidden":!0}),(0,r.jsx)("span",{children:"Browse"})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>ep("files"),"aria-current":"files"===em?"page":void 0,className:"flex flex-col items-center justify-center gap-1 transition-colors ".concat("files"===em?"text-[var(--accent)] font-semibold":"text-[var(--text-secondary)]"),children:[(0,r.jsx)(i.A,{className:"w-4 h-4","aria-hidden":!0}),(0,r.jsx)("span",{children:"Files"})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>ep("read"),"aria-current":"read"===em?"page":void 0,className:"flex flex-col items-center justify-center gap-1 transition-colors ".concat("read"===em?"text-[var(--accent)] font-semibold":"text-[var(--text-secondary)]"),children:[(0,r.jsx)(c.A,{className:"w-4 h-4","aria-hidden":!0}),(0,r.jsx)("span",{children:"Read"})]})]}),eU&&(0,r.jsx)(tm,{open:t,onClose:()=>a(!1),onSelectFile:e7,includeJournal:eo,commands:tL,recentFiles:tA}),eH&&(0,r.jsx)(tp,{open:l,onClose:()=>u(!1)}),eB&&(0,r.jsx)(tf,{open:x,onClose:()=>{h(!1),p(void 0)},initialTab:m}),f&&(0,r.jsx)(tb,{open:!0,initialStep:v,onClose:()=>{b(!1),g(1)},projects:ej,onSaved:()=>{eN(),e_(),y(e=>e+1)}}),eG&&(0,r.jsx)(tv,{open:w,onClose:()=>N(!1),onCreate:te,currentProjectId:z,availableFolders:"knowledge"===V?eA:eF,defaultFolder:"knowledge"===V&&null!=Z?Z:void 0,showJournal:eo}),ez&&(0,r.jsx)(tg,{open:k,onClose:()=>{S(!1),A(null)},onCreate:ta,bucketPrefix:C}),eK&&(0,r.jsx)(tj,{open:T,folderName:Z||"",onClose:()=>F(!1),onConfirm:tr,loading:B}),eW&&(0,r.jsx)(ty,{isOpen:P,projectName:(null==eO?void 0:eO.name)||"",onClose:()=>E(!1),onConfirm:()=>{eC(),E(!1)}}),eJ&&(0,r.jsx)(tw,{isOpen:L,onClose:()=>{_(!1),D("publish")},mode:R,onSwitchToPublish:()=>{D("publish")},onPublishSuccess:e=>{var t,a;return d.o.success("Publish successful",{duration:1/0,closeButton:!0,description:["".concat(null!=(t=e.docCount)?t:0," docs"),e.endpointCount?"".concat(e.endpointCount," endpoints"):null,e.termCount?"".concat(e.termCount," terms"):null,null!=(a=e.output)?a:null].filter(Boolean).join(" \xb7 "),action:{label:"View Published",onClick:()=>window.open("/api/publish/html","_blank","noopener,noreferrer")}})}})]})}},35047:(e,t,a)=>{"use strict";a.d(t,{Gd:()=>c,_A:()=>i});var r=a(14915),n=a(35186),l=a(59217),s=a(6519);function o(e){if("string"==typeof e||"number"==typeof e)return String(e);if(Array.isArray(e))return e.map(o).join("");if(e&&"object"==typeof e&&"props"in e){var t;return o(null==(t=e.props)?void 0:t.children)}return""}function i(){let e=new Map;return t=>{var a;let r=t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-");if(!r)return"";let n=(null!=(a=e.get(r))?a:0)+1;return e.set(r,n),1===n?r:"".concat(r,"-").concat(n)}}function c(e){let{content:t,className:a}=e,c=i();return(0,r.jsx)("div",{className:"prose dark:prose-invert max-w-[74ch] mx-auto text-[var(--text-primary)] prose-p:leading-relaxed prose-pre:bg-[var(--bg-secondary)] prose-pre:border prose-pre:border-[var(--border)] prose-code:text-[var(--prose-heading-accent)] prose-a:text-[var(--accent)] prose-a:no-underline hover:prose-a:underline prose-th:border-[var(--border)] prose-td:border-[var(--border)] prose-hr:border-[var(--border)] ".concat(a||""),children:(0,r.jsx)(n.oz,{remarkPlugins:[l.A],components:{h1:e=>{let{children:t}=e,a=c(o(t));return(0,r.jsx)("h1",{id:a||void 0,className:"text-3xl font-extrabold mb-6 pb-3 border-b border-[var(--border)] text-[var(--prose-heading)] font-title tracking-tight scroll-mt-16",children:t})},h2:e=>{let{children:t}=e,a=c(o(t));return(0,r.jsx)("h2",{id:a||void 0,className:"text-[var(--prose-heading)] text-2xl font-bold mb-3.5 mt-8 border-b border-[var(--border)] pb-2 scroll-mt-16",children:t})},h3:e=>{let{children:t}=e,a=c(o(t));return(0,r.jsx)("h3",{id:a||void 0,className:"text-[var(--prose-heading-accent)] text-xl font-bold mb-2.5 mt-6 scroll-mt-16",children:t})},h4:e=>{let{children:t}=e;return(0,r.jsx)("h4",{className:"text-[var(--prose-heading)] text-lg font-semibold mb-2 mt-4",children:t})},h5:e=>{let{children:t}=e;return(0,r.jsx)("h5",{className:"text-[var(--prose-heading)] text-base font-semibold mb-2",children:t})},h6:e=>{let{children:t}=e;return(0,r.jsx)("h6",{className:"text-[var(--text-secondary)] text-sm font-semibold mb-2",children:t})},blockquote:e=>{let{children:t}=e;return(0,r.jsx)("blockquote",{className:"border-l-4 border-[var(--accent)]/50 bg-[var(--accent-soft)] px-5 py-3 rounded-r-lg my-6 text-[var(--text-secondary)] italic leading-relaxed",children:t})},strong:e=>{let{children:t}=e;return(0,r.jsx)("strong",{className:"font-bold text-[var(--prose-strong)]",children:t})},code:e=>{let{className:t,children:a,...n}=e;return"language-mermaid"===t?(0,r.jsx)(s.q,{source:String(a).replace(/\n$/,""),className:"my-4"}):(0,r.jsx)("code",{className:t,...n,children:a})}},children:t})})}},56570:(e,t,a)=>{"use strict";a.d(t,{l:()=>s});var r=a(14915),n=a(88691),l=a(29723);function s(e){let{open:t,onClose:a,title:s,description:o,widthClass:i="max-w-md",hideHeader:c=!1,positionClass:d="left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:u}=e;return(0,r.jsx)(n.bL,{open:t,onOpenChange:e=>{e||a()},children:(0,r.jsxs)(n.ZL,{children:[(0,r.jsx)(n.hJ,{className:"fixed inset-0 z-[var(--z-modal)] bg-black/60 backdrop-blur-sm animate-fade-in"}),(0,r.jsx)(n.UC,{className:"fixed ".concat(d," z-[var(--z-modal)] focus:outline-none"),children:(0,r.jsxs)("div",{className:"relative w-[92vw] ".concat(i," rounded-xl border border-[var(--border)] bg-[var(--bg-primary)] shadow-2xl animate-scale-in max-h-[85vh] flex flex-col"),children:[c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.hE,{className:"sr-only",children:s}),(0,r.jsx)(n.bm,{className:"btn btn-icon-sm absolute right-3 top-3 z-10","aria-label":"Close",children:(0,r.jsx)(l.A,{className:"w-4 h-4","aria-hidden":!0})})]}):(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 pt-4 pb-3 border-b border-[var(--border)] shrink-0",children:[(0,r.jsx)(n.hE,{className:"text-sm font-bold text-[var(--text-primary)] font-title",children:s}),(0,r.jsx)(n.bm,{className:"btn btn-icon-sm","aria-label":"Close",children:(0,r.jsx)(l.A,{className:"w-4 h-4","aria-hidden":!0})})]}),o?(0,r.jsx)(n.VY,{className:"px-5 pt-3 text-xs text-[var(--text-secondary)]",children:o}):(0,r.jsx)(n.VY,{className:"sr-only",children:s}),(0,r.jsx)("div",{className:"p-5 overflow-y-auto",children:u})]})})]})})}},80966:(e,t,a)=>{Promise.resolve().then(a.bind(a,33039))},85170:(e,t,a)=>{"use strict";a.d(t,{$3:()=>d,AU:()=>s,Ai:()=>i,BZ:()=>c,UF:()=>x,is:()=>r,jh:()=>u,sZ:()=>o,zQ:()=>h});let r=["journal","knowledge","mermaid","html"],n=new Set(r);function l(e){return e?e.split(/[/\\]/).filter(Boolean):[]}function s(e){let[t]=l(e);return t&&n.has(t)?t:null}function o(e){return"journal"===s(e)}function i(e,t){var a;if("journal"===e.content_class)return!0;if(e.project_id)return!1;let r=(null!=(a=e.path)?a:"").replace(/\\/g,"/");if(t){let e=t.replace(/\\/g,"/").replace(/\/+$/,"")+"/";if(r.startsWith(e)){let t=r.slice(e.length);return"journal"===t||t.startsWith("journal/")}}return/(?:^|\/)knowledge\/journal(?:\/|$)/i.test(r)}function c(e){return!!e&&l(e).length<=1}function d(e){let t=l(e);return"html"===t[0]&&"resources"===t[1]}function u(e){if(d(e))return null;switch(s(e)){case"journal":case"knowledge":return"md";case"mermaid":return"mmd";case"html":return"html";default:return null}}function x(e){if(d(e))return"";let t=u(e);return"md"===t?".md,.markdown":"mmd"===t?".mmd":"html"===t?".html,.htm":null}function h(e,t){if(d(t))return!0;let a=u(t);if(!a)return!0;let r=function(e){let t=e.lastIndexOf(".");return t<0?"":e.slice(t+1).toLowerCase()}(e);return"md"===a?"md"===r||"markdown"===r:"mmd"===a?"mmd"===r:"html"!==a||"html"===r||"htm"===r}},96405:(e,t,a)=>{"use strict";a.d(t,{_:()=>s});var r=a(65347);let n="kontexta:agents-changed",l=()=>window.dispatchEvent(new Event(n));function s(){let[e,t]=(0,r.useState)(null),[a,s]=(0,r.useState)(!0),o=(0,r.useRef)(0),i=(0,r.useCallback)(async()=>{let e=++o.current;try{let a=await fetch("/api/agents");if(a.ok){let r=await a.json();e===o.current&&t(Array.isArray(null==r?void 0:r.agents)?r:null)}else e===o.current&&t(null)}catch(a){e===o.current&&t(null)}finally{e===o.current&&s(!1)}},[]);(0,r.useEffect)(()=>{i();let e=()=>{i()};return window.addEventListener(n,e),()=>window.removeEventListener(n,e)},[i]);let c=(0,r.useCallback)(async(e,t)=>{try{let a=await fetch("/api/agents/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:t})});if(!a.ok)return null;let r=await a.json();return l(),r}catch(e){return null}},[]);return{state:e,loading:a,refresh:i,setEnabled:c,hooksAction:(0,r.useCallback)(async(e,t)=>{try{let a=await fetch("/api/agents/".concat(e,"/hooks"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t})}),r=await a.json().catch(()=>({}));return l(),{ok:a.ok,status:a.status,...r}}catch(e){return{ok:!1,status:0,error:"Request failed"}}},[]),mcpAction:(0,r.useCallback)(async function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"prompt";try{let r=await fetch("/api/agents/".concat(e,"/mcp"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,approval:a})}),n=await r.json().catch(()=>({}));return l(),{ok:r.ok,status:r.status,...n}}catch(e){return{ok:!1,status:0,error:"Request failed"}}},[])}}}},e=>{e.O(0,[1514,9807,4473,8439,9922,5159,7358],()=>e(e.s=80966)),_N_E=e.O()}]);
|
package/bundle/standalone/apps/web/.next/static/chunks/app/preview/motifs/page-5f1cd3b80296b4e0.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[64,533,635,1113,1151,1273,1610,1636,1699,1806,2041,2096,2224,2522,2598,2607,2654,2772,3004,3063,3145,3365,3425,3426,3430,3549,3576,3878,3943,4076,4096,4260,4490,4882,4930,4931,5031,5148,5394,5469,5581,5789,6202,6274,7073,7473,7490,7574,7676,7758,7874,8100,8198,8208,8267,8489,8518,8967,8998,9234,9329,9347,9514,9881,9900,9930],{98473:()=>{}},_=>{_.O(0,[9922,5159,7358],()=>_(_.s=98473)),_N_E=_.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var e={},a={};function t(r){var f=a[r];if(void 0!==f)return f.exports;var c=a[r]={exports:{}},d=!0;try{e[r].call(c.exports,c,c.exports,t),d=!1}finally{d&&delete a[r]}return c.exports}t.m=e,(()=>{var e=[];t.O=(a,r,f,c)=>{if(r){c=c||0;for(var d=e.length;d>0&&e[d-1][2]>c;d--)e[d]=e[d-1];e[d]=[r,f,c];return}for(var b=1/0,d=0;d<e.length;d++){for(var[r,f,c]=e[d],o=!0,n=0;n<r.length;n++)(!1&c||b>=c)&&Object.keys(t.O).every(e=>t.O[e](r[n]))?r.splice(n--,1):(o=!1,c<b&&(b=c));if(o){e.splice(d--,1);var i=f();void 0!==i&&(a=i)}}return a}})(),t.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return t.d(a,{a:a}),a},(()=>{var e,a=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;t.t=function(r,f){if(1&f&&(r=this(r)),8&f||"object"==typeof r&&r&&(4&f&&r.__esModule||16&f&&"function"==typeof r.then))return r;var c=Object.create(null);t.r(c);var d={};e=e||[null,a({}),a([]),a(a)];for(var b=2&f&&r;"object"==typeof b&&!~e.indexOf(b);b=a(b))Object.getOwnPropertyNames(b).forEach(e=>d[e]=()=>r[e]);return d.default=()=>r,t.d(c,d),c}})(),t.d=(e,a)=>{for(var r in a)t.o(a,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:a[r]})},t.f={},t.e=e=>Promise.all(Object.keys(t.f).reduce((a,r)=>(t.f[r](e,a),a),[])),t.u=e=>"static/chunks/"+(({1097:"6a2ca82e",1805:"a118fb18",4371:"02852184",7050:"8080c6f4",7241:"6b5bb80a",8881:"d185f5cd"})[e]||e)+"."+({46:"9922e50f2158e1a9",171:"a4732e77e941b2cd",245:"3ed04e1f16f90b31",338:"77f45c7810885961",408:"82356d1e11e880d9",492:"234794e12315e4bb",559:"c4615787d977bf47",693:"71c8b97896628a66",807:"
|
|
1
|
+
(()=>{"use strict";var e={},a={};function t(r){var f=a[r];if(void 0!==f)return f.exports;var c=a[r]={exports:{}},d=!0;try{e[r].call(c.exports,c,c.exports,t),d=!1}finally{d&&delete a[r]}return c.exports}t.m=e,(()=>{var e=[];t.O=(a,r,f,c)=>{if(r){c=c||0;for(var d=e.length;d>0&&e[d-1][2]>c;d--)e[d]=e[d-1];e[d]=[r,f,c];return}for(var b=1/0,d=0;d<e.length;d++){for(var[r,f,c]=e[d],o=!0,n=0;n<r.length;n++)(!1&c||b>=c)&&Object.keys(t.O).every(e=>t.O[e](r[n]))?r.splice(n--,1):(o=!1,c<b&&(b=c));if(o){e.splice(d--,1);var i=f();void 0!==i&&(a=i)}}return a}})(),t.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return t.d(a,{a:a}),a},(()=>{var e,a=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;t.t=function(r,f){if(1&f&&(r=this(r)),8&f||"object"==typeof r&&r&&(4&f&&r.__esModule||16&f&&"function"==typeof r.then))return r;var c=Object.create(null);t.r(c);var d={};e=e||[null,a({}),a([]),a(a)];for(var b=2&f&&r;"object"==typeof b&&!~e.indexOf(b);b=a(b))Object.getOwnPropertyNames(b).forEach(e=>d[e]=()=>r[e]);return d.default=()=>r,t.d(c,d),c}})(),t.d=(e,a)=>{for(var r in a)t.o(a,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:a[r]})},t.f={},t.e=e=>Promise.all(Object.keys(t.f).reduce((a,r)=>(t.f[r](e,a),a),[])),t.u=e=>"static/chunks/"+(({1097:"6a2ca82e",1805:"a118fb18",4371:"02852184",7050:"8080c6f4",7241:"6b5bb80a",8881:"d185f5cd"})[e]||e)+"."+({46:"9922e50f2158e1a9",171:"a4732e77e941b2cd",245:"3ed04e1f16f90b31",338:"77f45c7810885961",408:"82356d1e11e880d9",492:"234794e12315e4bb",559:"c4615787d977bf47",693:"71c8b97896628a66",807:"a2f62f79be9478d7",944:"6a3d93405d7cb403",1097:"c26cb70da3106c1c",1108:"60fb822c3e3fdaf3",1130:"c3ba70728796955d",1226:"49d217dc03a1770f",1286:"8da72129ab3aa8fd",1733:"3a6dae5cc3785d0b",1805:"88c57fd88bdf91aa",2081:"313746c212bfc5c9",2086:"0b05a08670aae1db",2205:"68bae400481d0a3a",2443:"9d9dd31cc33fc741",2966:"2216b92e18a0bb66",3034:"e1171cbeeed85923",3259:"585f965f16cd7406",3297:"7664b51ee69c7513",3471:"7790a4192ef84a1a",3514:"14aa56fe189fd052",3685:"1e1d7cc834bf67db",3696:"5d462babda0c0b9e",3987:"07ce2f3afff6c9a1",4283:"edea07cef5bde1ad",4371:"a3b62691cdc349cf",4798:"d851e8027b2db933",4908:"2fed0b6fbc391b55",4915:"97b9c59991c26fa7",4936:"c65cdd63440ade70",5127:"e5e917b5cb9c4e52",5141:"93a42ebd1580da60",5514:"104d052cec14d85a",5667:"e0097b2112faa29b",5858:"cff8810734332b7e",6367:"fd87728718a97771",6394:"c2172a59c01bd0bd",6396:"d288334e13a70139",6483:"88695b22b21b10f1",6561:"176d35e576df3f9d",6584:"87fc375a0510108d",6934:"45e50410379dc377",7050:"ed360e7424d6fe99",7216:"d1b096d2a35967fd",7241:"c511153adad62faf",7342:"fcb52cf5f7ce0e17",7541:"43ff810bb14fd5c0",7563:"376c2692778a62b3",7756:"b0dd00e996549a39",8052:"69c066e56bbd5d6c",8280:"81c2b0d61e27a576",8547:"5bef8f1afd162429",8602:"0b457ca55bd2c08e",8693:"7e10450df289d6a0",8794:"401ab179d53aa5d5",8881:"71b8f43667fbf60d",9053:"c953d758ff5dc6ee",9122:"cf7fd16fc8d7fad0",9255:"78469e88fa06e186",9699:"3cbe1b534e6d60b6",9852:"dff25fd2ed9a2763",9981:"8fa0bb90a26c66eb"})[e]+".js",t.miniCssF=e=>{},t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),t.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),(()=>{var e={},a="_N_E:";t.l=(r,f,c,d)=>{if(e[r])return void e[r].push(f);if(void 0!==c)for(var b,o,n=document.getElementsByTagName("script"),i=0;i<n.length;i++){var u=n[i];if(u.getAttribute("src")==r||u.getAttribute("data-webpack")==a+c){b=u;break}}b||(o=!0,(b=document.createElement("script")).charset="utf-8",b.timeout=120,t.nc&&b.setAttribute("nonce",t.nc),b.setAttribute("data-webpack",a+c),b.src=t.tu(r)),e[r]=[f];var l=(a,t)=>{b.onerror=b.onload=null,clearTimeout(s);var f=e[r];if(delete e[r],b.parentNode&&b.parentNode.removeChild(b),f&&f.forEach(e=>e(t)),a)return a(t)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:b}),12e4);b.onerror=l.bind(null,b.onerror),b.onload=l.bind(null,b.onload),o&&document.head.appendChild(b)}})(),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;t.tt=()=>(void 0===e&&(e={createScriptURL:e=>e},"undefined"!=typeof trustedTypes&&trustedTypes.createPolicy&&(e=trustedTypes.createPolicy("nextjs#bundler",e))),e)})(),t.tu=e=>t.tt().createScriptURL(e),t.p="/_next/",(()=>{var e={8068:0,2206:0,42:0};t.f.j=(a,r)=>{var f=t.o(e,a)?e[a]:void 0;if(0!==f)if(f)r.push(f[2]);else if(/^(2206|42|8068)$/.test(a))e[a]=0;else{var c=new Promise((t,r)=>f=e[a]=[t,r]);r.push(f[2]=c);var d=t.p+t.u(a),b=Error();t.l(d,r=>{if(t.o(e,a)&&(0!==(f=e[a])&&(e[a]=void 0),f)){var c=r&&("load"===r.type?"missing":r.type),d=r&&r.target&&r.target.src;b.message="Loading chunk "+a+" failed.\n("+c+": "+d+")",b.name="ChunkLoadError",b.type=c,b.request=d,f[1](b)}},"chunk-"+a,a)}},t.O.j=a=>0===e[a];var a=(a,r)=>{var f,c,[d,b,o]=r,n=0;if(d.some(a=>0!==e[a])){for(f in b)t.o(b,f)&&(t.m[f]=b[f]);if(o)var i=o(t)}for(a&&a(r);n<d.length;n++)c=d[n],t.o(e,c)&&e[c]&&e[c][0](),e[c]=0;return t.O(i)},r=self.webpackChunk_N_E=self.webpackChunk_N_E||[];r.forEach(a.bind(null,0)),r.push=a.bind(null,r.push.bind(r))})(),t.nc=void 0})();
|