@hienlh/ppm 0.1.6 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/bun.lock +52 -0
  2. package/dist/web/assets/{button-KIZetva8.js → button-CvHWF07y.js} +1 -1
  3. package/dist/web/assets/{chat-tab-CNXjLOhI.js → chat-tab-C4ovA2w4.js} +3 -3
  4. package/dist/web/assets/{code-editor-tGMPwYNs.js → code-editor-BgiyQO-M.js} +1 -1
  5. package/dist/web/assets/{dialog-D8ulRTfX.js → dialog-f3IZM-6v.js} +1 -1
  6. package/dist/web/assets/{diff-viewer-B4A8pPbo.js → diff-viewer-8_asmBRZ.js} +1 -1
  7. package/dist/web/assets/{dist-C4W3AGh3.js → dist-CCBctnax.js} +1 -1
  8. package/dist/web/assets/{git-graph-ODjrGZOQ.js → git-graph-BiyTIbCz.js} +1 -1
  9. package/dist/web/assets/{git-status-panel-B0Im1hrU.js → git-status-panel-BifyO31N.js} +1 -1
  10. package/dist/web/assets/index-DILaVO6p.css +2 -0
  11. package/dist/web/assets/index-DasstYgw.js +11 -0
  12. package/dist/web/assets/project-list-C7L3hZct.js +1 -0
  13. package/dist/web/assets/settings-tab-Cn5Ja0_J.js +1 -0
  14. package/dist/web/assets/{terminal-tab-DDf6S-Tu.js → terminal-tab-CyjhG4Ao.js} +1 -1
  15. package/dist/web/index.html +8 -8
  16. package/dist/web/sw.js +1 -1
  17. package/docs/code-standards.md +74 -0
  18. package/docs/codebase-summary.md +11 -7
  19. package/docs/deployment-guide.md +81 -11
  20. package/docs/project-overview-pdr.md +62 -2
  21. package/docs/system-architecture.md +24 -8
  22. package/package.json +5 -2
  23. package/src/cli/commands/init.ts +196 -43
  24. package/src/cli/commands/logs.ts +58 -0
  25. package/src/cli/commands/report.ts +60 -0
  26. package/src/cli/commands/status.ts +73 -0
  27. package/src/cli/commands/stop.ts +24 -10
  28. package/src/index.ts +48 -6
  29. package/src/server/index.ts +184 -17
  30. package/src/services/cloudflared.service.ts +99 -0
  31. package/src/services/tunnel.service.ts +100 -0
  32. package/src/types/config.ts +2 -0
  33. package/src/web/app.tsx +10 -2
  34. package/src/web/components/auth/login-screen.tsx +9 -2
  35. package/src/web/components/layout/sidebar.tsx +15 -0
  36. package/src/web/components/ui/sonner.tsx +9 -6
  37. package/src/web/hooks/use-health-check.ts +95 -0
  38. package/src/web/stores/settings-store.ts +19 -0
  39. package/src/web/stores/tab-store.ts +28 -8
  40. package/src/web/styles/globals.css +4 -3
  41. package/dist/web/assets/index-BePIZMuy.css +0 -2
  42. package/dist/web/assets/index-D2STBl88.js +0 -10
  43. package/dist/web/assets/project-list-VjQQcU3X.js +0 -1
  44. package/dist/web/assets/settings-tab-ChhdL0EG.js +0 -1
  45. /package/dist/web/assets/{dist-PA84y4Ga.js → dist-B6sG2GPc.js} +0 -0
  46. /package/dist/web/assets/{react-BSLFEYu8.js → react-gOPBns57.js} +0 -0
  47. /package/dist/web/assets/{utils-DpJF9mAi.js → utils-61GRB9Cb.js} +0 -0
package/bun.lock CHANGED
@@ -15,6 +15,7 @@
15
15
  "@codemirror/lang-python": "^6.2.1",
16
16
  "@codemirror/merge": "^6.12.1",
17
17
  "@codemirror/theme-one-dark": "^6.1.3",
18
+ "@inquirer/prompts": "^8.3.0",
18
19
  "@uiw/react-codemirror": "^4.25.8",
19
20
  "@xterm/addon-fit": "^0.11.0",
20
21
  "@xterm/addon-web-links": "^0.12.0",
@@ -30,6 +31,7 @@
30
31
  "lucide-react": "^0.577.0",
31
32
  "marked": "^17.0.4",
32
33
  "next-themes": "^0.4.6",
34
+ "qrcode-terminal": "^0.12.0",
33
35
  "radix-ui": "^1.4.3",
34
36
  "react": "^19.2.4",
35
37
  "react-dom": "^19.2.4",
@@ -317,6 +319,38 @@
317
319
 
318
320
  "@img/sharp-win32-x64": ["@img/sharp-win32-x64@0.34.5", "", { "os": "win32", "cpu": "x64" }, "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw=="],
319
321
 
322
+ "@inquirer/ansi": ["@inquirer/ansi@2.0.3", "", {}, "sha512-g44zhR3NIKVs0zUesa4iMzExmZpLUdTLRMCStqX3GE5NT6VkPcxQGJ+uC8tDgBUC/vB1rUhUd55cOf++4NZcmw=="],
323
+
324
+ "@inquirer/checkbox": ["@inquirer/checkbox@5.1.0", "", { "dependencies": { "@inquirer/ansi": "^2.0.3", "@inquirer/core": "^11.1.5", "@inquirer/figures": "^2.0.3", "@inquirer/type": "^4.0.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-/HjF1LN0a1h4/OFsbGKHNDtWICFU/dqXCdym719HFTyJo9IG7Otr+ziGWc9S0iQuohRZllh+WprSgd5UW5Fw0g=="],
325
+
326
+ "@inquirer/confirm": ["@inquirer/confirm@6.0.8", "", { "dependencies": { "@inquirer/core": "^11.1.5", "@inquirer/type": "^4.0.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-Di6dgmiZ9xCSUxWUReWTqDtbhXCuG2MQm2xmgSAIruzQzBqNf49b8E07/vbCYY506kDe8BiwJbegXweG8M1klw=="],
327
+
328
+ "@inquirer/core": ["@inquirer/core@11.1.5", "", { "dependencies": { "@inquirer/ansi": "^2.0.3", "@inquirer/figures": "^2.0.3", "@inquirer/type": "^4.0.3", "cli-width": "^4.1.0", "fast-wrap-ansi": "^0.2.0", "mute-stream": "^3.0.0", "signal-exit": "^4.1.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-QQPAX+lka8GyLcZ7u7Nb1h6q72iZ/oy0blilC3IB2nSt1Qqxp7akt94Jqhi/DzARuN3Eo9QwJRvtl4tmVe4T5A=="],
329
+
330
+ "@inquirer/editor": ["@inquirer/editor@5.0.8", "", { "dependencies": { "@inquirer/core": "^11.1.5", "@inquirer/external-editor": "^2.0.3", "@inquirer/type": "^4.0.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-sLcpbb9B3XqUEGrj1N66KwhDhEckzZ4nI/W6SvLXyBX8Wic3LDLENlWRvkOGpCPoserabe+MxQkpiMoI8irvyA=="],
331
+
332
+ "@inquirer/expand": ["@inquirer/expand@5.0.8", "", { "dependencies": { "@inquirer/core": "^11.1.5", "@inquirer/type": "^4.0.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-QieW3F1prNw3j+hxO7/NKkG1pk3oz7pOB6+5Upwu3OIwADfPX0oZVppsqlL+Vl/uBHHDSOBY0BirLctLnXwGGg=="],
333
+
334
+ "@inquirer/external-editor": ["@inquirer/external-editor@2.0.3", "", { "dependencies": { "chardet": "^2.1.1", "iconv-lite": "^0.7.2" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-LgyI7Agbda74/cL5MvA88iDpvdXI2KuMBCGRkbCl2Dg1vzHeOgs+s0SDcXV7b+WZJrv2+ERpWSM65Fpi9VfY3w=="],
335
+
336
+ "@inquirer/figures": ["@inquirer/figures@2.0.3", "", {}, "sha512-y09iGt3JKoOCBQ3w4YrSJdokcD8ciSlMIWsD+auPu+OZpfxLuyz+gICAQ6GCBOmJJt4KEQGHuZSVff2jiNOy7g=="],
337
+
338
+ "@inquirer/input": ["@inquirer/input@5.0.8", "", { "dependencies": { "@inquirer/core": "^11.1.5", "@inquirer/type": "^4.0.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-p0IJslw0AmedLEkOU+yrEX3Aj2RTpQq7ZOf8nc1DIhjzaxRWrrgeuE5Kyh39fVRgtcACaMXx/9WNo8+GjgBOfw=="],
339
+
340
+ "@inquirer/number": ["@inquirer/number@4.0.8", "", { "dependencies": { "@inquirer/core": "^11.1.5", "@inquirer/type": "^4.0.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-uGLiQah9A0F9UIvJBX52m0CnqtLaym0WpT9V4YZrjZ+YRDKZdwwoEPz06N6w8ChE2lrnsdyhY9sL+Y690Kh9gQ=="],
341
+
342
+ "@inquirer/password": ["@inquirer/password@5.0.8", "", { "dependencies": { "@inquirer/ansi": "^2.0.3", "@inquirer/core": "^11.1.5", "@inquirer/type": "^4.0.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-zt1sF4lYLdvPqvmvHdmjOzuUUjuCQ897pdUCO8RbXMUDKXJTTyOQgtn23le+jwcb+MpHl3VAFvzIdxRAf6aPlA=="],
343
+
344
+ "@inquirer/prompts": ["@inquirer/prompts@8.3.0", "", { "dependencies": { "@inquirer/checkbox": "^5.1.0", "@inquirer/confirm": "^6.0.8", "@inquirer/editor": "^5.0.8", "@inquirer/expand": "^5.0.8", "@inquirer/input": "^5.0.8", "@inquirer/number": "^4.0.8", "@inquirer/password": "^5.0.8", "@inquirer/rawlist": "^5.2.4", "@inquirer/search": "^4.1.4", "@inquirer/select": "^5.1.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-JAj66kjdH/F1+B7LCigjARbwstt3SNUOSzMdjpsvwJmzunK88gJeXmcm95L9nw1KynvFVuY4SzXh/3Y0lvtgSg=="],
345
+
346
+ "@inquirer/rawlist": ["@inquirer/rawlist@5.2.4", "", { "dependencies": { "@inquirer/core": "^11.1.5", "@inquirer/type": "^4.0.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-fTuJ5Cq9W286isLxwj6GGyfTjx1Zdk4qppVEPexFuA6yioCCXS4V1zfKroQqw7QdbDPN73xs2DiIAlo55+kBqg=="],
347
+
348
+ "@inquirer/search": ["@inquirer/search@4.1.4", "", { "dependencies": { "@inquirer/core": "^11.1.5", "@inquirer/figures": "^2.0.3", "@inquirer/type": "^4.0.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-9yPTxq7LPmYjrGn3DRuaPuPbmC6u3fiWcsE9ggfLcdgO/ICHYgxq7mEy1yJ39brVvgXhtOtvDVjDh9slJxE4LQ=="],
349
+
350
+ "@inquirer/select": ["@inquirer/select@5.1.0", "", { "dependencies": { "@inquirer/ansi": "^2.0.3", "@inquirer/core": "^11.1.5", "@inquirer/figures": "^2.0.3", "@inquirer/type": "^4.0.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-OyYbKnchS1u+zRe14LpYrN8S0wH1vD0p2yKISvSsJdH2TpI87fh4eZdWnpdbrGauCRWDph3NwxRmM4Pcm/hx1Q=="],
351
+
352
+ "@inquirer/type": ["@inquirer/type@4.0.3", "", { "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-cKZN7qcXOpj1h+1eTTcGDVLaBIHNMT1Rz9JqJP5MnEJ0JhgVWllx7H/tahUp5YEK1qaByH2Itb8wLG/iScD5kw=="],
353
+
320
354
  "@isaacs/cliui": ["@isaacs/cliui@9.0.0", "", {}, "sha512-AokJm4tuBHillT+FpMtxQ60n8ObyXBatq7jD2/JA9dxbDDokKQm8KMht5ibGzLVU9IJDIKK4TPKgMHEYMn3lMg=="],
321
355
 
322
356
  "@jridgewell/gen-mapping": ["@jridgewell/gen-mapping@0.3.13", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA=="],
@@ -637,8 +671,12 @@
637
671
 
638
672
  "ccburn": ["ccburn@0.6.0", "", { "os": [ "linux", "win32", "darwin", ], "cpu": [ "x64", "arm64", ], "bin": { "ccburn": "bin/ccburn.js" } }, "sha512-mdNrj6g+ulJ1Zs4TKWSMqmd8y7HDjxaRtsQSzPg8h+JkV6Hiix7b6sbZGu5Achx8KFkI+chNFO6K0W3j8AIgEw=="],
639
673
 
674
+ "chardet": ["chardet@2.1.1", "", {}, "sha512-PsezH1rqdV9VvyNhxxOW32/d75r01NY7TQCmOqomRo15ZSOKbpTFVsfjghxo6JloQUCGnH4k1LGu0R4yCLlWQQ=="],
675
+
640
676
  "class-variance-authority": ["class-variance-authority@0.7.1", "", { "dependencies": { "clsx": "^2.1.1" } }, "sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg=="],
641
677
 
678
+ "cli-width": ["cli-width@4.1.0", "", {}, "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ=="],
679
+
642
680
  "clsx": ["clsx@2.1.1", "", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="],
643
681
 
644
682
  "codemirror": ["codemirror@6.0.2", "", { "dependencies": { "@codemirror/autocomplete": "^6.0.0", "@codemirror/commands": "^6.0.0", "@codemirror/language": "^6.0.0", "@codemirror/lint": "^6.0.0", "@codemirror/search": "^6.0.0", "@codemirror/state": "^6.0.0", "@codemirror/view": "^6.0.0" } }, "sha512-VhydHotNW5w1UGK0Qj96BwSk/Zqbp9WbnyK2W/eVMv4QyF41INRGpjUhFJY7/uDNuudSc33a/PKr4iDqRduvHw=="],
@@ -711,8 +749,14 @@
711
749
 
712
750
  "fast-json-stable-stringify": ["fast-json-stable-stringify@2.1.0", "", {}, "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="],
713
751
 
752
+ "fast-string-truncated-width": ["fast-string-truncated-width@3.0.3", "", {}, "sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g=="],
753
+
754
+ "fast-string-width": ["fast-string-width@3.0.2", "", { "dependencies": { "fast-string-truncated-width": "^3.0.2" } }, "sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg=="],
755
+
714
756
  "fast-uri": ["fast-uri@3.1.0", "", {}, "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA=="],
715
757
 
758
+ "fast-wrap-ansi": ["fast-wrap-ansi@0.2.0", "", { "dependencies": { "fast-string-width": "^3.0.2" } }, "sha512-rLV8JHxTyhVmFYhBJuMujcrHqOT2cnO5Zxj37qROj23CP39GXubJRBUFF0z8KFK77Uc0SukZUf7JZhsVEQ6n8w=="],
759
+
716
760
  "fdir": ["fdir@6.5.0", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg=="],
717
761
 
718
762
  "filelist": ["filelist@1.0.6", "", { "dependencies": { "minimatch": "^5.0.1" } }, "sha512-5giy2PkLYY1cP39p17Ech+2xlpTRL9HLspOfEgm0L6CwBXBTgsK5ou0JtzYuepxkaQ/tvhCFIJ5uXo0OrM2DxA=="],
@@ -769,6 +813,8 @@
769
813
 
770
814
  "hono": ["hono@4.12.8", "", {}, "sha512-VJCEvtrezO1IAR+kqEYnxUOoStaQPGrCmX3j4wDTNOcD1uRPFpGlwQUIW8niPuvHXaTUxeOUl5MMDGrl+tmO9A=="],
771
815
 
816
+ "iconv-lite": ["iconv-lite@0.7.2", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw=="],
817
+
772
818
  "idb": ["idb@7.1.1", "", {}, "sha512-gchesWBzyvGHRO9W8tzUWFDycow5gwjvFKfyV9FF32Y7F50yZMp7mP+T2mJIWFx49zicqyC4uefHM17o6xKIVQ=="],
773
819
 
774
820
  "internal-slot": ["internal-slot@1.1.0", "", { "dependencies": { "es-errors": "^1.3.0", "hasown": "^2.0.2", "side-channel": "^1.1.0" } }, "sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw=="],
@@ -899,6 +945,8 @@
899
945
 
900
946
  "ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
901
947
 
948
+ "mute-stream": ["mute-stream@3.0.0", "", {}, "sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw=="],
949
+
902
950
  "nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
903
951
 
904
952
  "next-themes": ["next-themes@0.4.6", "", { "peerDependencies": { "react": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc", "react-dom": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc" } }, "sha512-pZvgD5L0IEvX5/9GWyHMf3m8BKiVQwsCMHfoFosXtXBMnaS0ZnIJ9ST4b4NqLVKDEm8QBxoNNGNaBv2JNF6XNA=="],
@@ -935,6 +983,8 @@
935
983
 
936
984
  "punycode": ["punycode@2.3.1", "", {}, "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg=="],
937
985
 
986
+ "qrcode-terminal": ["qrcode-terminal@0.12.0", "", { "bin": { "qrcode-terminal": "./bin/qrcode-terminal.js" } }, "sha512-EXtzRZmC+YGmGlDFbXKxQiMZNwCLEO6BANKXG4iCtSIM0yqc/pappSx3RIKr4r0uh5JsBckOXeKrB3Iz7mdQpQ=="],
987
+
938
988
  "radix-ui": ["radix-ui@1.4.3", "", { "dependencies": { "@radix-ui/primitive": "1.1.3", "@radix-ui/react-accessible-icon": "1.1.7", "@radix-ui/react-accordion": "1.2.12", "@radix-ui/react-alert-dialog": "1.1.15", "@radix-ui/react-arrow": "1.1.7", "@radix-ui/react-aspect-ratio": "1.1.7", "@radix-ui/react-avatar": "1.1.10", "@radix-ui/react-checkbox": "1.3.3", "@radix-ui/react-collapsible": "1.1.12", "@radix-ui/react-collection": "1.1.7", "@radix-ui/react-compose-refs": "1.1.2", "@radix-ui/react-context": "1.1.2", "@radix-ui/react-context-menu": "2.2.16", "@radix-ui/react-dialog": "1.1.15", "@radix-ui/react-direction": "1.1.1", "@radix-ui/react-dismissable-layer": "1.1.11", "@radix-ui/react-dropdown-menu": "2.1.16", "@radix-ui/react-focus-guards": "1.1.3", "@radix-ui/react-focus-scope": "1.1.7", "@radix-ui/react-form": "0.1.8", "@radix-ui/react-hover-card": "1.1.15", "@radix-ui/react-label": "2.1.7", "@radix-ui/react-menu": "2.1.16", "@radix-ui/react-menubar": "1.1.16", "@radix-ui/react-navigation-menu": "1.2.14", "@radix-ui/react-one-time-password-field": "0.1.8", "@radix-ui/react-password-toggle-field": "0.1.3", "@radix-ui/react-popover": "1.1.15", "@radix-ui/react-popper": "1.2.8", "@radix-ui/react-portal": "1.1.9", "@radix-ui/react-presence": "1.1.5", "@radix-ui/react-primitive": "2.1.3", "@radix-ui/react-progress": "1.1.7", "@radix-ui/react-radio-group": "1.3.8", "@radix-ui/react-roving-focus": "1.1.11", "@radix-ui/react-scroll-area": "1.2.10", "@radix-ui/react-select": "2.2.6", "@radix-ui/react-separator": "1.1.7", "@radix-ui/react-slider": "1.3.6", "@radix-ui/react-slot": "1.2.3", "@radix-ui/react-switch": "1.2.6", "@radix-ui/react-tabs": "1.1.13", "@radix-ui/react-toast": "1.2.15", "@radix-ui/react-toggle": "1.1.10", "@radix-ui/react-toggle-group": "1.1.11", "@radix-ui/react-toolbar": "1.1.11", "@radix-ui/react-tooltip": "1.2.8", "@radix-ui/react-use-callback-ref": "1.1.1", "@radix-ui/react-use-controllable-state": "1.2.2", "@radix-ui/react-use-effect-event": "0.0.2", "@radix-ui/react-use-escape-keydown": "1.1.1", "@radix-ui/react-use-is-hydrated": "0.1.0", "@radix-ui/react-use-layout-effect": "1.1.1", "@radix-ui/react-use-size": "1.1.1", "@radix-ui/react-visually-hidden": "1.2.3" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-aWizCQiyeAenIdUbqEpXgRA1ya65P13NKn/W8rWkcN0OPkRDxdBVLWnIEDsS2RpwCK2nobI7oMUSmexzTDyAmA=="],
939
989
 
940
990
  "randombytes": ["randombytes@2.1.0", "", { "dependencies": { "safe-buffer": "^5.1.0" } }, "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ=="],
@@ -981,6 +1031,8 @@
981
1031
 
982
1032
  "safe-regex-test": ["safe-regex-test@1.1.0", "", { "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "is-regex": "^1.2.1" } }, "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw=="],
983
1033
 
1034
+ "safer-buffer": ["safer-buffer@2.1.2", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="],
1035
+
984
1036
  "scheduler": ["scheduler@0.27.0", "", {}, "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="],
985
1037
 
986
1038
  "semver": ["semver@6.3.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
@@ -1,4 +1,4 @@
1
- import{a as e,i as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{r as i,t as a}from"./utils-DpJF9mAi.js";var o=t((e=>{var t=n();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return s(e,t,null,n)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.4`})),s=t(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=o()})),c=e(n(),1);function l(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function u(...e){return t=>{let n=!1,r=e.map(e=>{let r=l(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():l(e[t],null)}}}}function d(...e){return c.useCallback(u(...e),e)}var f=r();function p(e){let t=h(e),n=c.forwardRef((e,n)=>{let{children:r,...i}=e,a=c.Children.toArray(r),o=a.find(v);if(o){let e=o.props.children,r=a.map(t=>t===o?c.Children.count(e)>1?c.Children.only(null):c.isValidElement(e)?e.props.children:null:t);return(0,f.jsx)(t,{...i,ref:n,children:c.isValidElement(e)?c.cloneElement(e,void 0,r):null})}return(0,f.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var m=p(`Slot`);function h(e){let t=c.forwardRef((e,t)=>{let{children:n,...r}=e;if(c.isValidElement(n)){let e=b(n),i=y(r,n.props);return n.type!==c.Fragment&&(i.ref=t?u(t,e):e),c.cloneElement(n,i)}return c.Children.count(n)>1?c.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var g=Symbol(`radix.slottable`);function _(e){let t=({children:e})=>(0,f.jsx)(f.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=g,t}function v(e){return c.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===g}function y(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function b(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var x=e(s(),1),S=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=p(`Primitive.${t}`),r=c.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,f.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function C(e,t){e&&x.flushSync(()=>e.dispatchEvent(t))}function w(e,t){let n=c.createContext(t),r=e=>{let{children:t,...r}=e,i=c.useMemo(()=>r,Object.values(r));return(0,f.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=c.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function ee(e,t=[]){let n=[];function r(t,r){let i=c.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,l=c.useMemo(()=>o,Object.values(o));return(0,f.jsx)(s.Provider,{value:l,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,l=c.useContext(s);if(l)return l;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>c.createContext(e));return function(n){let r=n?.[e]||t;return c.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,T(i,...t)]}function T(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return c.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}typeof window<`u`&&window.document&&window.document.createElement;function E(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var D=globalThis?.document?c.useLayoutEffect:()=>{},te=c.useInsertionEffect||D;function ne({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=re({defaultProp:t,onChange:n}),s=e!==void 0,l=s?e:i;{let t=c.useRef(e!==void 0);c.useEffect(()=>{let e=t.current;if(e!==s){let t=e?`controlled`:`uncontrolled`,n=s?`controlled`:`uncontrolled`;console.warn(`${r} is changing from ${t} to ${n}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=s},[s,r])}return[l,c.useCallback(t=>{if(s){let n=ie(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function re({defaultProp:e,onChange:t}){let[n,r]=c.useState(e),i=c.useRef(n),a=c.useRef(t);return te(()=>{a.current=t},[t]),c.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function ie(e){return typeof e==`function`}var ae=c.useId||(()=>void 0),oe=0;function se(e){let[t,n]=c.useState(ae());return D(()=>{e||n(e=>e??String(oe++))},[e]),e||(t?`radix-${t}`:``)}function O(e){let t=c.useRef(e);return c.useEffect(()=>{t.current=e}),c.useMemo(()=>(...e)=>t.current?.(...e),[])}function ce(e,t=globalThis?.document){let n=O(e);c.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var le=`DismissableLayer`,k=`dismissableLayer.update`,ue=`dismissableLayer.pointerDownOutside`,de=`dismissableLayer.focusOutside`,fe,pe=c.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),me=c.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...l}=e,u=c.useContext(pe),[p,m]=c.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=c.useState({}),_=d(t,e=>m(e)),v=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(y),x=p?v.indexOf(p):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,w=x>=b,ee=_e(e=>{let t=e.target,n=[...u.branches].some(e=>e.contains(t));!w||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},h),T=ve(e=>{let t=e.target;[...u.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},h);return ce(e=>{x===u.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},h),c.useEffect(()=>{if(p)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(fe=h.body.style.pointerEvents,h.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),ye(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=fe)}},[p,h,n,u]),c.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),ye())},[p,u]),c.useEffect(()=>{let e=()=>g({});return document.addEventListener(k,e),()=>document.removeEventListener(k,e)},[]),(0,f.jsx)(S.div,{...l,ref:_,style:{pointerEvents:C?w?`auto`:`none`:void 0,...e.style},onFocusCapture:E(e.onFocusCapture,T.onFocusCapture),onBlurCapture:E(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:E(e.onPointerDownCapture,ee.onPointerDownCapture)})});me.displayName=le;var he=`DismissableLayerBranch`,ge=c.forwardRef((e,t)=>{let n=c.useContext(pe),r=c.useRef(null),i=d(t,r);return c.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,f.jsx)(S.div,{...e,ref:i})});ge.displayName=he;function _e(e,t=globalThis?.document){let n=O(e),r=c.useRef(!1),i=c.useRef(()=>{});return c.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){be(ue,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function ve(e,t=globalThis?.document){let n=O(e),r=c.useRef(!1);return c.useEffect(()=>{let e=e=>{e.target&&!r.current&&be(de,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function ye(){let e=new CustomEvent(k);document.dispatchEvent(e)}function be(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?C(i,a):i.dispatchEvent(a)}var A=`focusScope.autoFocusOnMount`,j=`focusScope.autoFocusOnUnmount`,M={bubbles:!1,cancelable:!0},xe=`FocusScope`,N=c.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,l]=c.useState(null),u=O(i),p=O(a),m=c.useRef(null),h=d(t,e=>l(e)),g=c.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;c.useEffect(()=>{if(r){let e=function(e){if(g.paused||!s)return;let t=e.target;s.contains(t)?m.current=t:P(m.current,{select:!0})},t=function(e){if(g.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||P(m.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&P(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,g.paused]),c.useEffect(()=>{if(s){Oe.add(g);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(A,M);s.addEventListener(A,u),s.dispatchEvent(t),t.defaultPrevented||(Se(je(we(s)),{select:!0}),document.activeElement===e&&P(s))}return()=>{s.removeEventListener(A,u),setTimeout(()=>{let t=new CustomEvent(j,M);s.addEventListener(j,p),s.dispatchEvent(t),t.defaultPrevented||P(e??document.body,{select:!0}),s.removeEventListener(j,p),Oe.remove(g)},0)}}},[s,u,p,g]);let _=c.useCallback(e=>{if(!n&&!r||g.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Ce(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&P(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&P(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,g.paused]);return(0,f.jsx)(S.div,{tabIndex:-1,...o,ref:h,onKeyDown:_})});N.displayName=xe;function Se(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(P(r,{select:t}),document.activeElement!==n)return}function Ce(e){let t=we(e);return[Te(t,e),Te(t.reverse(),e)]}function we(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Te(e,t){for(let n of e)if(!Ee(n,{upTo:t}))return n}function Ee(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function De(e){return e instanceof HTMLInputElement&&`select`in e}function P(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&De(e)&&t&&e.select()}}var Oe=ke();function ke(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Ae(e,t),e.unshift(t)},remove(t){e=Ae(e,t),e[0]?.resume()}}}function Ae(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function je(e){return e.filter(e=>e.tagName!==`A`)}var Me=`Portal`,Ne=c.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=c.useState(!1);D(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?x.createPortal((0,f.jsx)(S.div,{...r,ref:t}),o):null});Ne.displayName=Me;var F=0;function Pe(){c.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Fe()),document.body.insertAdjacentElement(`beforeend`,e[1]??Fe()),F++,()=>{F===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),F--}},[])}function Fe(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var I=function(){return I=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},I.apply(this,arguments)};function Ie(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Le(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var L=`right-scroll-bar-position`,R=`width-before-scroll-bar`,Re=`with-scroll-bars-hidden`,ze=`--removed-body-scroll-bar-size`;function z(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Be(e,t){var n=(0,c.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Ve=typeof window<`u`?c.useLayoutEffect:c.useEffect,He=new WeakMap;function Ue(e,t){var n=Be(t||null,function(t){return e.forEach(function(e){return z(e,t)})});return Ve(function(){var t=He.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||z(e,null)}),i.forEach(function(e){r.has(e)||z(e,a)})}He.set(n,e)},[e]),n}function We(e){return e}function Ge(e,t){t===void 0&&(t=We);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Ke(e){e===void 0&&(e={});var t=Ge(null);return t.options=I({async:!0,ssr:!1},e),t}var qe=function(e){var t=e.sideCar,n=Ie(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return c.createElement(r,I({},n))};qe.isSideCarExport=!0;function Je(e,t){return e.useMedium(t),qe}var Ye=Ke(),B=function(){},V=c.forwardRef(function(e,t){var n=c.useRef(null),r=c.useState({onScrollCapture:B,onWheelCapture:B,onTouchMoveCapture:B}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=Ie(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=Ue([n,t]),w=I(I({},x),i);return c.createElement(c.Fragment,null,d&&c.createElement(S,{sideCar:Ye,removeScrollBar:u,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?c.cloneElement(c.Children.only(s),I(I({},w),{ref:C})):c.createElement(y,I({},w,{className:l,ref:C}),s))});V.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},V.classNames={fullWidth:R,zeroRight:L};var Xe,Ze=function(){if(Xe)return Xe;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function Qe(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Ze();return t&&e.setAttribute(`nonce`,t),e}function $e(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function et(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var tt=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Qe())&&($e(t,n),et(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},nt=function(){var e=tt();return function(t,n){c.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},rt=function(){var e=nt();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},it={left:0,top:0,right:0,gap:0},H=function(e){return parseInt(e||``,10)||0},at=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[H(n),H(r),H(i)]},ot=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return it;var t=at(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},st=rt(),U=`data-scroll-locked`,ct=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
1
+ import{a as e,i as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{r as i,t as a}from"./utils-61GRB9Cb.js";var o=t((e=>{var t=n();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return s(e,t,null,n)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.4`})),s=t(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=o()})),c=e(n(),1);function l(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function u(...e){return t=>{let n=!1,r=e.map(e=>{let r=l(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():l(e[t],null)}}}}function d(...e){return c.useCallback(u(...e),e)}var f=r();function p(e){let t=h(e),n=c.forwardRef((e,n)=>{let{children:r,...i}=e,a=c.Children.toArray(r),o=a.find(v);if(o){let e=o.props.children,r=a.map(t=>t===o?c.Children.count(e)>1?c.Children.only(null):c.isValidElement(e)?e.props.children:null:t);return(0,f.jsx)(t,{...i,ref:n,children:c.isValidElement(e)?c.cloneElement(e,void 0,r):null})}return(0,f.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var m=p(`Slot`);function h(e){let t=c.forwardRef((e,t)=>{let{children:n,...r}=e;if(c.isValidElement(n)){let e=b(n),i=y(r,n.props);return n.type!==c.Fragment&&(i.ref=t?u(t,e):e),c.cloneElement(n,i)}return c.Children.count(n)>1?c.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var g=Symbol(`radix.slottable`);function _(e){let t=({children:e})=>(0,f.jsx)(f.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=g,t}function v(e){return c.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===g}function y(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function b(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var x=e(s(),1),S=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=p(`Primitive.${t}`),r=c.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,f.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function C(e,t){e&&x.flushSync(()=>e.dispatchEvent(t))}function w(e,t){let n=c.createContext(t),r=e=>{let{children:t,...r}=e,i=c.useMemo(()=>r,Object.values(r));return(0,f.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=c.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function ee(e,t=[]){let n=[];function r(t,r){let i=c.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,l=c.useMemo(()=>o,Object.values(o));return(0,f.jsx)(s.Provider,{value:l,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,l=c.useContext(s);if(l)return l;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>c.createContext(e));return function(n){let r=n?.[e]||t;return c.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,T(i,...t)]}function T(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return c.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}typeof window<`u`&&window.document&&window.document.createElement;function E(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var D=globalThis?.document?c.useLayoutEffect:()=>{},te=c.useInsertionEffect||D;function ne({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=re({defaultProp:t,onChange:n}),s=e!==void 0,l=s?e:i;{let t=c.useRef(e!==void 0);c.useEffect(()=>{let e=t.current;if(e!==s){let t=e?`controlled`:`uncontrolled`,n=s?`controlled`:`uncontrolled`;console.warn(`${r} is changing from ${t} to ${n}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=s},[s,r])}return[l,c.useCallback(t=>{if(s){let n=ie(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function re({defaultProp:e,onChange:t}){let[n,r]=c.useState(e),i=c.useRef(n),a=c.useRef(t);return te(()=>{a.current=t},[t]),c.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function ie(e){return typeof e==`function`}var ae=c.useId||(()=>void 0),oe=0;function se(e){let[t,n]=c.useState(ae());return D(()=>{e||n(e=>e??String(oe++))},[e]),e||(t?`radix-${t}`:``)}function O(e){let t=c.useRef(e);return c.useEffect(()=>{t.current=e}),c.useMemo(()=>(...e)=>t.current?.(...e),[])}function ce(e,t=globalThis?.document){let n=O(e);c.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var le=`DismissableLayer`,k=`dismissableLayer.update`,ue=`dismissableLayer.pointerDownOutside`,de=`dismissableLayer.focusOutside`,fe,pe=c.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),me=c.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...l}=e,u=c.useContext(pe),[p,m]=c.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=c.useState({}),_=d(t,e=>m(e)),v=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(y),x=p?v.indexOf(p):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,w=x>=b,ee=_e(e=>{let t=e.target,n=[...u.branches].some(e=>e.contains(t));!w||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},h),T=ve(e=>{let t=e.target;[...u.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},h);return ce(e=>{x===u.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},h),c.useEffect(()=>{if(p)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(fe=h.body.style.pointerEvents,h.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),ye(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=fe)}},[p,h,n,u]),c.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),ye())},[p,u]),c.useEffect(()=>{let e=()=>g({});return document.addEventListener(k,e),()=>document.removeEventListener(k,e)},[]),(0,f.jsx)(S.div,{...l,ref:_,style:{pointerEvents:C?w?`auto`:`none`:void 0,...e.style},onFocusCapture:E(e.onFocusCapture,T.onFocusCapture),onBlurCapture:E(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:E(e.onPointerDownCapture,ee.onPointerDownCapture)})});me.displayName=le;var he=`DismissableLayerBranch`,ge=c.forwardRef((e,t)=>{let n=c.useContext(pe),r=c.useRef(null),i=d(t,r);return c.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,f.jsx)(S.div,{...e,ref:i})});ge.displayName=he;function _e(e,t=globalThis?.document){let n=O(e),r=c.useRef(!1),i=c.useRef(()=>{});return c.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){be(ue,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function ve(e,t=globalThis?.document){let n=O(e),r=c.useRef(!1);return c.useEffect(()=>{let e=e=>{e.target&&!r.current&&be(de,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function ye(){let e=new CustomEvent(k);document.dispatchEvent(e)}function be(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?C(i,a):i.dispatchEvent(a)}var A=`focusScope.autoFocusOnMount`,j=`focusScope.autoFocusOnUnmount`,M={bubbles:!1,cancelable:!0},xe=`FocusScope`,N=c.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,l]=c.useState(null),u=O(i),p=O(a),m=c.useRef(null),h=d(t,e=>l(e)),g=c.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;c.useEffect(()=>{if(r){let e=function(e){if(g.paused||!s)return;let t=e.target;s.contains(t)?m.current=t:P(m.current,{select:!0})},t=function(e){if(g.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||P(m.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&P(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,g.paused]),c.useEffect(()=>{if(s){Oe.add(g);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(A,M);s.addEventListener(A,u),s.dispatchEvent(t),t.defaultPrevented||(Se(je(we(s)),{select:!0}),document.activeElement===e&&P(s))}return()=>{s.removeEventListener(A,u),setTimeout(()=>{let t=new CustomEvent(j,M);s.addEventListener(j,p),s.dispatchEvent(t),t.defaultPrevented||P(e??document.body,{select:!0}),s.removeEventListener(j,p),Oe.remove(g)},0)}}},[s,u,p,g]);let _=c.useCallback(e=>{if(!n&&!r||g.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Ce(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&P(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&P(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,g.paused]);return(0,f.jsx)(S.div,{tabIndex:-1,...o,ref:h,onKeyDown:_})});N.displayName=xe;function Se(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(P(r,{select:t}),document.activeElement!==n)return}function Ce(e){let t=we(e);return[Te(t,e),Te(t.reverse(),e)]}function we(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Te(e,t){for(let n of e)if(!Ee(n,{upTo:t}))return n}function Ee(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function De(e){return e instanceof HTMLInputElement&&`select`in e}function P(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&De(e)&&t&&e.select()}}var Oe=ke();function ke(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Ae(e,t),e.unshift(t)},remove(t){e=Ae(e,t),e[0]?.resume()}}}function Ae(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function je(e){return e.filter(e=>e.tagName!==`A`)}var Me=`Portal`,Ne=c.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=c.useState(!1);D(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?x.createPortal((0,f.jsx)(S.div,{...r,ref:t}),o):null});Ne.displayName=Me;var F=0;function Pe(){c.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Fe()),document.body.insertAdjacentElement(`beforeend`,e[1]??Fe()),F++,()=>{F===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),F--}},[])}function Fe(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var I=function(){return I=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},I.apply(this,arguments)};function Ie(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Le(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var L=`right-scroll-bar-position`,R=`width-before-scroll-bar`,Re=`with-scroll-bars-hidden`,ze=`--removed-body-scroll-bar-size`;function z(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Be(e,t){var n=(0,c.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Ve=typeof window<`u`?c.useLayoutEffect:c.useEffect,He=new WeakMap;function Ue(e,t){var n=Be(t||null,function(t){return e.forEach(function(e){return z(e,t)})});return Ve(function(){var t=He.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||z(e,null)}),i.forEach(function(e){r.has(e)||z(e,a)})}He.set(n,e)},[e]),n}function We(e){return e}function Ge(e,t){t===void 0&&(t=We);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Ke(e){e===void 0&&(e={});var t=Ge(null);return t.options=I({async:!0,ssr:!1},e),t}var qe=function(e){var t=e.sideCar,n=Ie(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return c.createElement(r,I({},n))};qe.isSideCarExport=!0;function Je(e,t){return e.useMedium(t),qe}var Ye=Ke(),B=function(){},V=c.forwardRef(function(e,t){var n=c.useRef(null),r=c.useState({onScrollCapture:B,onWheelCapture:B,onTouchMoveCapture:B}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=Ie(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=Ue([n,t]),w=I(I({},x),i);return c.createElement(c.Fragment,null,d&&c.createElement(S,{sideCar:Ye,removeScrollBar:u,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?c.cloneElement(c.Children.only(s),I(I({},w),{ref:C})):c.createElement(y,I({},w,{className:l,ref:C}),s))});V.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},V.classNames={fullWidth:R,zeroRight:L};var Xe,Ze=function(){if(Xe)return Xe;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function Qe(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Ze();return t&&e.setAttribute(`nonce`,t),e}function $e(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function et(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var tt=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Qe())&&($e(t,n),et(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},nt=function(){var e=tt();return function(t,n){c.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},rt=function(){var e=nt();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},it={left:0,top:0,right:0,gap:0},H=function(e){return parseInt(e||``,10)||0},at=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[H(n),H(r),H(i)]},ot=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return it;var t=at(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},st=rt(),U=`data-scroll-locked`,ct=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
2
2
  .${Re} {
3
3
  overflow: hidden ${r};
4
4
  padding-right: ${s}px ${r};
@@ -1,6 +1,6 @@
1
- import{a as e,n as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{n as i,t as a}from"./marked.esm-Cv8mjgnt.js";import{t as o}from"./external-link-Dim3NH6h.js";import{t as s}from"./refresh-cw-DJSjl6Ev.js";import{t as c}from"./trash-2-CjahwKg8.js";import{t as l}from"./x-BxhOxZ5p.js";import{n as u}from"./utils-DpJF9mAi.js";import{n as d,r as f,t as p}from"./api-client-BgVufYKf.js";import{D as m,E as h,S as g,T as _,_ as v,g as y,h as b,l as x,m as S,p as C,u as w,w as T,x as E,y as D}from"./index-D2STBl88.js";var O=t(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),k=t(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),A=t(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),j=t(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),M=t(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),N=t(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),P=t(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),F=t(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),I=t(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),L=t(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),R=t(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ee=t(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),z=t(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),B=e(n(),1),V=3e4,H=1e3,te=class{ws=null;url;handlers=[];reconnectAttempts=0;reconnectTimer=null;intentionalClose=!1;constructor(e){this.url=e}connect(){this.intentionalClose=!1,this.cleanup();let e=window.location.protocol===`https:`?`wss:`:`ws:`,t=this.url.startsWith(`ws`)?this.url:`${e}//${window.location.host}${this.url}`;this.ws=new WebSocket(t),this.ws.onopen=()=>{this.reconnectAttempts=0},this.ws.onmessage=e=>{for(let t of this.handlers)t(e)},this.ws.onclose=()=>{this.intentionalClose||this.scheduleReconnect()},this.ws.onerror=()=>{this.ws?.close()}}disconnect(){this.intentionalClose=!0,this.cleanup(),this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null)}send(e){this.ws?.readyState===WebSocket.OPEN&&this.ws.send(e)}onMessage(e){return this.handlers.push(e),()=>{this.handlers=this.handlers.filter(t=>t!==e)}}get isConnected(){return this.ws?.readyState===WebSocket.OPEN}cleanup(){this.ws&&=(this.ws.onopen=null,this.ws.onclose=null,this.ws.onmessage=null,this.ws.onerror=null,(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING)&&this.ws.close(),null)}scheduleReconnect(){let e=Math.min(H*2**this.reconnectAttempts,V);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>this.connect(),e)}};function ne({url:e,onMessage:t,autoConnect:n=!0}){let r=(0,B.useRef)(null);return(0,B.useEffect)(()=>{let i=new te(e);return r.current=i,t&&i.onMessage(t),n&&i.connect(),()=>{i.disconnect(),r.current=null}},[e,n]),{send:(0,B.useCallback)(e=>{r.current?.send(e)},[]),connect:(0,B.useCallback)(()=>{r.current?.connect()},[]),disconnect:(0,B.useCallback)(()=>{r.current?.disconnect()},[])}}function re(e,t=`claude-sdk`,n=``){let[r,i]=(0,B.useState)([]),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(null),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)({}),[_,v]=(0,B.useState)(!1),y=(0,B.useRef)(``),b=(0,B.useRef)([]),x=(0,B.useRef)(!1),S=(0,B.useRef)(null),C=(0,B.useRef)(()=>{}),w=(0,B.useCallback)(e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(t.type!==`ping`){if(t.type===`connected`){m(!0);return}switch(t.type){case`text`:{y.current+=t.content,b.current.push(t);let e=y.current,n=[...b.current];i(t=>{let r=t[t.length-1];return r?.role===`assistant`&&!r.id.startsWith(`final-`)?[...t.slice(0,-1),{...r,content:e,events:n}]:[...t,{id:`streaming-${Date.now()}`,role:`assistant`,content:e,events:n,timestamp:new Date().toISOString()}]});break}case`tool_use`:{b.current.push(t);let e=y.current,n=[...b.current];i(t=>{let r=t[t.length-1];return r?.role===`assistant`?[...t.slice(0,-1),{...r,events:n}]:[...t,{id:`streaming-${Date.now()}`,role:`assistant`,content:e,events:n,timestamp:new Date().toISOString()}]});break}case`tool_result`:{b.current.push(t);let e=[...b.current];i(t=>{let n=t[t.length-1];return n?.role===`assistant`?[...t.slice(0,-1),{...n,events:e}]:t});break}case`approval_request`:b.current.push(t),u({requestId:t.requestId,tool:t.tool,input:t.input});break;case`usage`:g(e=>{let n={...e,...t.usage};return t.usage.totalCostUsd!=null&&(n.queryCostUsd=t.usage.totalCostUsd,n.totalCostUsd=(e.totalCostUsd??0)+t.usage.totalCostUsd),n});break;case`error`:{b.current.push(t);let e=[...b.current];i(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,events:e}]:[...n,{id:`error-${Date.now()}`,role:`system`,content:t.message,events:[t],timestamp:new Date().toISOString()}]}),x.current=!1,c(!1);break}case`done`:{let e=y.current,t=[...b.current];i(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n}),y.current=``,b.current=[];let n=S.current;n?(S.current=null,i(e=>[...e,{id:`user-${Date.now()}`,role:`user`,content:n,timestamp:new Date().toISOString()}]),y.current=``,b.current=[],x.current=!0,c(!0),C.current(JSON.stringify({type:`message`,content:n}))):(x.current=!1,c(!1));break}}}},[]),{send:T}=ne({url:e&&n?`/ws/project/${encodeURIComponent(n)}/chat/${e}`:``,onMessage:w,autoConnect:!!e&&!!n});return C.current=T,(0,B.useEffect)(()=>{let r=!1;return c(!1),u(null),y.current=``,b.current=[],m(!1),n&&fetch(`${f(n)}/chat/usage?providerId=${t}`,{headers:{Authorization:`Bearer ${d()}`}}).then(e=>e.json()).then(e=>{!r&&e.ok&&e.data&&g(t=>({...t,...e.data}))}).catch(()=>{}),e&&n?(o(!0),fetch(`${f(n)}/chat/sessions/${e}/messages?providerId=${t}`,{headers:{Authorization:`Bearer ${d()}`}}).then(e=>e.json()).then(e=>{r||x.current||(e.ok&&Array.isArray(e.data)&&e.data.length>0?i(e.data):i([]))}).catch(()=>{!r&&!x.current&&i([])}).finally(()=>{r||o(!1)})):i([]),()=>{r=!0}},[e,t,n]),{messages:r,messagesLoading:a,isStreaming:s,pendingApproval:l,usageInfo:h,usageLoading:_,sendMessage:(0,B.useCallback)(e=>{if(e.trim()){if(s){S.current=e;return}i(t=>[...t,{id:`user-${Date.now()}`,role:`user`,content:e,timestamp:new Date().toISOString()}]),y.current=``,b.current=[],x.current=!0,c(!0),T(JSON.stringify({type:`message`,content:e}))}},[T,s]),respondToApproval:(0,B.useCallback)((e,t,n)=>{if(T(JSON.stringify({type:`approval_response`,requestId:e,approved:t,data:n})),t&&n){let t=b.current.find(t=>t.type===`approval_request`&&t.requestId===e&&t.tool===`AskUserQuestion`);if(t){let e=t.input;e&&typeof e==`object`&&(e.answers=n)}i(e=>[...e])}u(null)},[T]),cancelStreaming:(0,B.useCallback)(()=>{if(!x.current)return;T(JSON.stringify({type:`cancel`}));let e=y.current,t=[...b.current];i(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n}),y.current=``,b.current=[],S.current=null,x.current=!1,c(!1),u(null)},[T]),refreshUsage:(0,B.useCallback)(()=>{n&&(v(!0),fetch(`${f(n)}/chat/usage?providerId=${t}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${d()}`}}).then(e=>e.json()).then(e=>{e.ok&&e.data&&g(t=>({...t,...e.data}))}).catch(()=>{}).finally(()=>v(!1)))},[n,t]),isConnected:p}}var U=r();function W(e){let t=e.type===`approval_request`;return{toolName:e.type===`tool_use`?e.tool:t?e.tool??`Tool`:`Tool`,input:e.type===`tool_use`?e.input:t?e.input??{}:{}}}function G({tool:e,result:t,completed:n,projectName:r}){let[i,a]=(0,B.useState)(!1);if(e.type===`error`)return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded bg-red-500/10 border border-red-500/20 px-2 py-1.5 text-xs text-red-400`,children:[(0,U.jsx)(_,{className:`size-3`}),(0,U.jsx)(`span`,{children:e.message})]});let{toolName:o,input:s}=W(e),c=t?.type===`tool_result`,l=c&&!!t.isError,u=o===`AskUserQuestion`&&!!s?.answers;return(0,U.jsxs)(`div`,{className:`rounded border border-border bg-background text-xs`,children:[(0,U.jsxs)(`button`,{onClick:()=>a(!i),className:`flex items-center gap-2 px-2 py-1.5 w-full text-left hover:bg-surface transition-colors min-w-0`,children:[i?(0,U.jsx)(m,{className:`size-3 shrink-0`}):(0,U.jsx)(h,{className:`size-3 shrink-0`}),l?(0,U.jsx)(A,{className:`size-3 text-red-400 shrink-0`}):c||u||n?(0,U.jsx)(T,{className:`size-3 text-green-400 shrink-0`}):(0,U.jsx)(z,{className:`size-3 text-yellow-400 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate text-text-primary`,children:(0,U.jsx)(K,{name:o,input:s})})]}),i&&(0,U.jsxs)(`div`,{className:`px-2 pb-2 space-y-1.5`,children:[(e.type===`tool_use`||e.type===`approval_request`)&&(0,U.jsx)(q,{name:o,input:s,projectName:r}),c&&(0,U.jsx)(Y,{toolName:o,output:t.output})]})]})}function K({name:e,input:t}){let n=e=>String(e??``);switch(e){case`Read`:case`Write`:case`Edit`:case`MultiEdit`:case`NotebookEdit`:return(0,U.jsxs)(U.Fragment,{children:[e,` `,(0,U.jsx)(`span`,{className:`text-text-subtle`,children:ie(n(t.file_path))})]});case`Bash`:return(0,U.jsxs)(U.Fragment,{children:[e,` `,(0,U.jsx)(`span`,{className:`font-mono text-text-subtle`,children:Q(n(t.command),60)})]});case`Glob`:return(0,U.jsxs)(U.Fragment,{children:[e,` `,(0,U.jsx)(`span`,{className:`font-mono text-text-subtle`,children:n(t.pattern)})]});case`Grep`:return(0,U.jsxs)(U.Fragment,{children:[e,` `,(0,U.jsx)(`span`,{className:`font-mono text-text-subtle`,children:Q(n(t.pattern),40)})]});case`WebSearch`:return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(S,{className:`size-3 inline`}),` `,e,` `,(0,U.jsx)(`span`,{className:`text-text-subtle`,children:Q(n(t.query),50)})]});case`WebFetch`:return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(j,{className:`size-3 inline`}),` `,e,` `,(0,U.jsx)(`span`,{className:`text-text-subtle`,children:Q(n(t.url),50)})]});case`ToolSearch`:return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(S,{className:`size-3 inline`}),` `,e,` `,(0,U.jsx)(`span`,{className:`text-text-subtle`,children:Q(n(t.query),50)})]});case`Agent`:case`Task`:return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(k,{className:`size-3 inline`}),` `,e,` `,(0,U.jsx)(`span`,{className:`text-text-subtle`,children:Q(n(t.description||t.prompt),60)})]});case`TodoWrite`:{let n=t.todos??[],r=n.filter(e=>e.status===`completed`).length;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(N,{className:`size-3 inline`}),` `,e,` `,(0,U.jsxs)(`span`,{className:`text-text-subtle`,children:[r,`/`,n.length,` done`]})]})}case`AskUserQuestion`:{let n=t.questions??[],r=!!t.answers;return(0,U.jsxs)(U.Fragment,{children:[e,` `,(0,U.jsxs)(`span`,{className:`text-text-subtle`,children:[n.length,` question`,n.length===1?``:`s`,r?` ✓`:``]})]})}default:return(0,U.jsx)(U.Fragment,{children:e})}}function q({name:e,input:t,projectName:n}){let r=e=>String(e??``),{openTab:i}=w(),a=e=>{n&&i({type:`editor`,title:e.split(`/`).pop()??e,metadata:{filePath:e,projectName:n},projectId:n,closable:!0})};switch(e){case`Bash`:return(0,U.jsxs)(`div`,{className:`space-y-1`,children:[!!t.description&&(0,U.jsx)(`p`,{className:`text-text-subtle italic`,children:r(t.description)}),(0,U.jsx)(`pre`,{className:`font-mono text-text-secondary overflow-x-auto whitespace-pre-wrap break-all`,children:r(t.command)})]});case`Read`:case`Write`:case`Edit`:case`MultiEdit`:case`NotebookEdit`:{let n=r(t.file_path);return(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`font-mono text-text-secondary break-all hover:text-primary hover:underline text-left flex items-center gap-1`,onClick:()=>a(n),title:`Open file in editor`,children:[(0,U.jsx)(o,{className:`size-3 shrink-0`}),n]}),e===`Edit`&&!!t.old_string&&(0,U.jsx)(`div`,{className:`border-l-2 border-red-400/40 pl-2`,children:(0,U.jsx)(`pre`,{className:`font-mono text-red-400/70 overflow-x-auto whitespace-pre-wrap`,children:Q(r(t.old_string),200)})}),e===`Edit`&&!!t.new_string&&(0,U.jsx)(`div`,{className:`border-l-2 border-green-400/40 pl-2`,children:(0,U.jsx)(`pre`,{className:`font-mono text-green-400/70 overflow-x-auto whitespace-pre-wrap`,children:Q(r(t.new_string),200)})}),e===`Write`&&!!t.content&&(0,U.jsx)(`pre`,{className:`font-mono text-text-subtle overflow-x-auto max-h-32 whitespace-pre-wrap`,children:Q(r(t.content),300)})]})}case`Glob`:return(0,U.jsxs)(`p`,{className:`font-mono text-text-secondary`,children:[r(t.pattern),t.path?` in ${r(t.path)}`:``]});case`Grep`:return(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsxs)(`p`,{className:`font-mono text-text-secondary`,children:[`/`,r(t.pattern),`/`]}),!!t.path&&(0,U.jsxs)(`p`,{className:`text-text-subtle`,children:[`in `,r(t.path)]})]});case`TodoWrite`:return(0,U.jsx)(J,{todos:t.todos??[]});case`Agent`:case`Task`:return(0,U.jsxs)(`div`,{className:`space-y-1`,children:[!!t.description&&(0,U.jsx)(`p`,{className:`text-text-secondary font-medium`,children:r(t.description)}),!!t.subagent_type&&(0,U.jsxs)(`p`,{className:`text-text-subtle`,children:[`Type: `,r(t.subagent_type)]}),!!t.prompt&&(0,U.jsx)(Z,{content:r(t.prompt),maxHeight:`max-h-48`})]});case`ToolSearch`:return(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(`p`,{className:`font-mono text-text-secondary`,children:r(t.query)}),!!t.max_results&&(0,U.jsxs)(`p`,{className:`text-text-subtle`,children:[`Max results: `,r(t.max_results)]})]});case`WebFetch`:return(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsxs)(`a`,{href:r(t.url),target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-primary hover:underline break-all flex items-center gap-1`,children:[(0,U.jsx)(j,{className:`size-3 shrink-0`}),r(t.url)]}),!!t.prompt&&(0,U.jsx)(`p`,{className:`text-text-subtle`,children:Q(r(t.prompt),100)})]});case`AskUserQuestion`:{let e=t.questions??[],n=t.answers??{};return(0,U.jsx)(`div`,{className:`space-y-2`,children:e.map((e,t)=>(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsxs)(`p`,{className:`text-text-primary font-medium`,children:[e.header?`${e.header}: `:``,e.question]}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.options.map((t,r)=>(0,U.jsx)(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-xs border ${(n[e.question]??``).split(`, `).includes(t.label)?`border-accent bg-accent/20 text-text-primary`:`border-border text-text-subtle`}`,children:t.label},r))}),n[e.question]&&(0,U.jsxs)(`p`,{className:`text-accent text-xs`,children:[`Answer: `,n[e.question]]})]},t))})}default:return(0,U.jsx)(`pre`,{className:`overflow-x-auto text-text-secondary font-mono whitespace-pre-wrap break-all`,children:JSON.stringify(t,null,2)})}}function J({todos:e}){return(0,U.jsx)(`div`,{className:`space-y-0.5`,children:e.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,U.jsx)(`span`,{className:`shrink-0 mt-0.5 ${e.status===`completed`?`text-green-400`:e.status===`in_progress`?`text-yellow-400`:`text-text-subtle`}`,children:e.status===`completed`?`✓`:e.status===`in_progress`?`▶`:`○`}),(0,U.jsx)(`span`,{className:e.status===`completed`?`line-through text-text-subtle`:`text-text-secondary`,children:e.content})]},t))})}function Y({toolName:e,output:t}){let[n,r]=(0,B.useState)(!1),a=(0,B.useMemo)(()=>{if(e!==`Agent`&&e!==`Task`)return null;try{let e=JSON.parse(t);if(Array.isArray(e)){let t=e.filter(e=>e.type===`text`&&e.text).map(e=>e.text).join(`
1
+ import{a as e,n as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{n as i,t as a}from"./marked.esm-Cv8mjgnt.js";import{t as o}from"./external-link-Dim3NH6h.js";import{t as s}from"./refresh-cw-DJSjl6Ev.js";import{t as c}from"./trash-2-CjahwKg8.js";import{t as l}from"./x-BxhOxZ5p.js";import{n as u}from"./utils-61GRB9Cb.js";import{n as d,r as f,t as p}from"./api-client-BgVufYKf.js";import{D as m,E as h,S as g,T as _,_ as v,c as y,g as b,h as x,l as S,m as C,p as w,w as T,x as E,y as D}from"./index-DasstYgw.js";var O=t(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),k=t(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),A=t(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),j=t(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),M=t(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),N=t(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),P=t(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),F=t(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),I=t(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),L=t(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),R=t(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ee=t(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),z=t(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),B=e(n(),1),V=3e4,H=1e3,te=class{ws=null;url;handlers=[];reconnectAttempts=0;reconnectTimer=null;intentionalClose=!1;constructor(e){this.url=e}connect(){this.intentionalClose=!1,this.cleanup();let e=window.location.protocol===`https:`?`wss:`:`ws:`,t=this.url.startsWith(`ws`)?this.url:`${e}//${window.location.host}${this.url}`;this.ws=new WebSocket(t),this.ws.onopen=()=>{this.reconnectAttempts=0},this.ws.onmessage=e=>{for(let t of this.handlers)t(e)},this.ws.onclose=()=>{this.intentionalClose||this.scheduleReconnect()},this.ws.onerror=()=>{this.ws?.close()}}disconnect(){this.intentionalClose=!0,this.cleanup(),this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null)}send(e){this.ws?.readyState===WebSocket.OPEN&&this.ws.send(e)}onMessage(e){return this.handlers.push(e),()=>{this.handlers=this.handlers.filter(t=>t!==e)}}get isConnected(){return this.ws?.readyState===WebSocket.OPEN}cleanup(){this.ws&&=(this.ws.onopen=null,this.ws.onclose=null,this.ws.onmessage=null,this.ws.onerror=null,(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING)&&this.ws.close(),null)}scheduleReconnect(){let e=Math.min(H*2**this.reconnectAttempts,V);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>this.connect(),e)}};function ne({url:e,onMessage:t,autoConnect:n=!0}){let r=(0,B.useRef)(null);return(0,B.useEffect)(()=>{let i=new te(e);return r.current=i,t&&i.onMessage(t),n&&i.connect(),()=>{i.disconnect(),r.current=null}},[e,n]),{send:(0,B.useCallback)(e=>{r.current?.send(e)},[]),connect:(0,B.useCallback)(()=>{r.current?.connect()},[]),disconnect:(0,B.useCallback)(()=>{r.current?.disconnect()},[])}}function re(e,t=`claude-sdk`,n=``){let[r,i]=(0,B.useState)([]),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(null),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)({}),[_,v]=(0,B.useState)(!1),y=(0,B.useRef)(``),b=(0,B.useRef)([]),x=(0,B.useRef)(!1),S=(0,B.useRef)(null),C=(0,B.useRef)(()=>{}),w=(0,B.useCallback)(e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(t.type!==`ping`){if(t.type===`connected`){m(!0);return}switch(t.type){case`text`:{y.current+=t.content,b.current.push(t);let e=y.current,n=[...b.current];i(t=>{let r=t[t.length-1];return r?.role===`assistant`&&!r.id.startsWith(`final-`)?[...t.slice(0,-1),{...r,content:e,events:n}]:[...t,{id:`streaming-${Date.now()}`,role:`assistant`,content:e,events:n,timestamp:new Date().toISOString()}]});break}case`tool_use`:{b.current.push(t);let e=y.current,n=[...b.current];i(t=>{let r=t[t.length-1];return r?.role===`assistant`?[...t.slice(0,-1),{...r,events:n}]:[...t,{id:`streaming-${Date.now()}`,role:`assistant`,content:e,events:n,timestamp:new Date().toISOString()}]});break}case`tool_result`:{b.current.push(t);let e=[...b.current];i(t=>{let n=t[t.length-1];return n?.role===`assistant`?[...t.slice(0,-1),{...n,events:e}]:t});break}case`approval_request`:b.current.push(t),u({requestId:t.requestId,tool:t.tool,input:t.input});break;case`usage`:g(e=>{let n={...e,...t.usage};return t.usage.totalCostUsd!=null&&(n.queryCostUsd=t.usage.totalCostUsd,n.totalCostUsd=(e.totalCostUsd??0)+t.usage.totalCostUsd),n});break;case`error`:{b.current.push(t);let e=[...b.current];i(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,events:e}]:[...n,{id:`error-${Date.now()}`,role:`system`,content:t.message,events:[t],timestamp:new Date().toISOString()}]}),x.current=!1,c(!1);break}case`done`:{let e=y.current,t=[...b.current];i(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n}),y.current=``,b.current=[];let n=S.current;n?(S.current=null,i(e=>[...e,{id:`user-${Date.now()}`,role:`user`,content:n,timestamp:new Date().toISOString()}]),y.current=``,b.current=[],x.current=!0,c(!0),C.current(JSON.stringify({type:`message`,content:n}))):(x.current=!1,c(!1));break}}}},[]),{send:T}=ne({url:e&&n?`/ws/project/${encodeURIComponent(n)}/chat/${e}`:``,onMessage:w,autoConnect:!!e&&!!n});return C.current=T,(0,B.useEffect)(()=>{let r=!1;return c(!1),u(null),y.current=``,b.current=[],m(!1),n&&fetch(`${f(n)}/chat/usage?providerId=${t}`,{headers:{Authorization:`Bearer ${d()}`}}).then(e=>e.json()).then(e=>{!r&&e.ok&&e.data&&g(t=>({...t,...e.data}))}).catch(()=>{}),e&&n?(o(!0),fetch(`${f(n)}/chat/sessions/${e}/messages?providerId=${t}`,{headers:{Authorization:`Bearer ${d()}`}}).then(e=>e.json()).then(e=>{r||x.current||(e.ok&&Array.isArray(e.data)&&e.data.length>0?i(e.data):i([]))}).catch(()=>{!r&&!x.current&&i([])}).finally(()=>{r||o(!1)})):i([]),()=>{r=!0}},[e,t,n]),{messages:r,messagesLoading:a,isStreaming:s,pendingApproval:l,usageInfo:h,usageLoading:_,sendMessage:(0,B.useCallback)(e=>{if(e.trim()){if(s){S.current=e;return}i(t=>[...t,{id:`user-${Date.now()}`,role:`user`,content:e,timestamp:new Date().toISOString()}]),y.current=``,b.current=[],x.current=!0,c(!0),T(JSON.stringify({type:`message`,content:e}))}},[T,s]),respondToApproval:(0,B.useCallback)((e,t,n)=>{if(T(JSON.stringify({type:`approval_response`,requestId:e,approved:t,data:n})),t&&n){let t=b.current.find(t=>t.type===`approval_request`&&t.requestId===e&&t.tool===`AskUserQuestion`);if(t){let e=t.input;e&&typeof e==`object`&&(e.answers=n)}i(e=>[...e])}u(null)},[T]),cancelStreaming:(0,B.useCallback)(()=>{if(!x.current)return;T(JSON.stringify({type:`cancel`}));let e=y.current,t=[...b.current];i(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n}),y.current=``,b.current=[],S.current=null,x.current=!1,c(!1),u(null)},[T]),refreshUsage:(0,B.useCallback)(()=>{n&&(v(!0),fetch(`${f(n)}/chat/usage?providerId=${t}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${d()}`}}).then(e=>e.json()).then(e=>{e.ok&&e.data&&g(t=>({...t,...e.data}))}).catch(()=>{}).finally(()=>v(!1)))},[n,t]),isConnected:p}}var U=r();function W(e){let t=e.type===`approval_request`;return{toolName:e.type===`tool_use`?e.tool:t?e.tool??`Tool`:`Tool`,input:e.type===`tool_use`?e.input:t?e.input??{}:{}}}function G({tool:e,result:t,completed:n,projectName:r}){let[i,a]=(0,B.useState)(!1);if(e.type===`error`)return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded bg-red-500/10 border border-red-500/20 px-2 py-1.5 text-xs text-red-400`,children:[(0,U.jsx)(_,{className:`size-3`}),(0,U.jsx)(`span`,{children:e.message})]});let{toolName:o,input:s}=W(e),c=t?.type===`tool_result`,l=c&&!!t.isError,u=o===`AskUserQuestion`&&!!s?.answers;return(0,U.jsxs)(`div`,{className:`rounded border border-border bg-background text-xs`,children:[(0,U.jsxs)(`button`,{onClick:()=>a(!i),className:`flex items-center gap-2 px-2 py-1.5 w-full text-left hover:bg-surface transition-colors min-w-0`,children:[i?(0,U.jsx)(m,{className:`size-3 shrink-0`}):(0,U.jsx)(h,{className:`size-3 shrink-0`}),l?(0,U.jsx)(A,{className:`size-3 text-red-400 shrink-0`}):c||u||n?(0,U.jsx)(T,{className:`size-3 text-green-400 shrink-0`}):(0,U.jsx)(z,{className:`size-3 text-yellow-400 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate text-text-primary`,children:(0,U.jsx)(K,{name:o,input:s})})]}),i&&(0,U.jsxs)(`div`,{className:`px-2 pb-2 space-y-1.5`,children:[(e.type===`tool_use`||e.type===`approval_request`)&&(0,U.jsx)(q,{name:o,input:s,projectName:r}),c&&(0,U.jsx)(Y,{toolName:o,output:t.output})]})]})}function K({name:e,input:t}){let n=e=>String(e??``);switch(e){case`Read`:case`Write`:case`Edit`:case`MultiEdit`:case`NotebookEdit`:return(0,U.jsxs)(U.Fragment,{children:[e,` `,(0,U.jsx)(`span`,{className:`text-text-subtle`,children:ie(n(t.file_path))})]});case`Bash`:return(0,U.jsxs)(U.Fragment,{children:[e,` `,(0,U.jsx)(`span`,{className:`font-mono text-text-subtle`,children:Q(n(t.command),60)})]});case`Glob`:return(0,U.jsxs)(U.Fragment,{children:[e,` `,(0,U.jsx)(`span`,{className:`font-mono text-text-subtle`,children:n(t.pattern)})]});case`Grep`:return(0,U.jsxs)(U.Fragment,{children:[e,` `,(0,U.jsx)(`span`,{className:`font-mono text-text-subtle`,children:Q(n(t.pattern),40)})]});case`WebSearch`:return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(C,{className:`size-3 inline`}),` `,e,` `,(0,U.jsx)(`span`,{className:`text-text-subtle`,children:Q(n(t.query),50)})]});case`WebFetch`:return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(j,{className:`size-3 inline`}),` `,e,` `,(0,U.jsx)(`span`,{className:`text-text-subtle`,children:Q(n(t.url),50)})]});case`ToolSearch`:return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(C,{className:`size-3 inline`}),` `,e,` `,(0,U.jsx)(`span`,{className:`text-text-subtle`,children:Q(n(t.query),50)})]});case`Agent`:case`Task`:return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(k,{className:`size-3 inline`}),` `,e,` `,(0,U.jsx)(`span`,{className:`text-text-subtle`,children:Q(n(t.description||t.prompt),60)})]});case`TodoWrite`:{let n=t.todos??[],r=n.filter(e=>e.status===`completed`).length;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(N,{className:`size-3 inline`}),` `,e,` `,(0,U.jsxs)(`span`,{className:`text-text-subtle`,children:[r,`/`,n.length,` done`]})]})}case`AskUserQuestion`:{let n=t.questions??[],r=!!t.answers;return(0,U.jsxs)(U.Fragment,{children:[e,` `,(0,U.jsxs)(`span`,{className:`text-text-subtle`,children:[n.length,` question`,n.length===1?``:`s`,r?` ✓`:``]})]})}default:return(0,U.jsx)(U.Fragment,{children:e})}}function q({name:e,input:t,projectName:n}){let r=e=>String(e??``),{openTab:i}=S(),a=e=>{n&&i({type:`editor`,title:e.split(`/`).pop()??e,metadata:{filePath:e,projectName:n},projectId:n,closable:!0})};switch(e){case`Bash`:return(0,U.jsxs)(`div`,{className:`space-y-1`,children:[!!t.description&&(0,U.jsx)(`p`,{className:`text-text-subtle italic`,children:r(t.description)}),(0,U.jsx)(`pre`,{className:`font-mono text-text-secondary overflow-x-auto whitespace-pre-wrap break-all`,children:r(t.command)})]});case`Read`:case`Write`:case`Edit`:case`MultiEdit`:case`NotebookEdit`:{let n=r(t.file_path);return(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`font-mono text-text-secondary break-all hover:text-primary hover:underline text-left flex items-center gap-1`,onClick:()=>a(n),title:`Open file in editor`,children:[(0,U.jsx)(o,{className:`size-3 shrink-0`}),n]}),e===`Edit`&&!!t.old_string&&(0,U.jsx)(`div`,{className:`border-l-2 border-red-400/40 pl-2`,children:(0,U.jsx)(`pre`,{className:`font-mono text-red-400/70 overflow-x-auto whitespace-pre-wrap`,children:Q(r(t.old_string),200)})}),e===`Edit`&&!!t.new_string&&(0,U.jsx)(`div`,{className:`border-l-2 border-green-400/40 pl-2`,children:(0,U.jsx)(`pre`,{className:`font-mono text-green-400/70 overflow-x-auto whitespace-pre-wrap`,children:Q(r(t.new_string),200)})}),e===`Write`&&!!t.content&&(0,U.jsx)(`pre`,{className:`font-mono text-text-subtle overflow-x-auto max-h-32 whitespace-pre-wrap`,children:Q(r(t.content),300)})]})}case`Glob`:return(0,U.jsxs)(`p`,{className:`font-mono text-text-secondary`,children:[r(t.pattern),t.path?` in ${r(t.path)}`:``]});case`Grep`:return(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsxs)(`p`,{className:`font-mono text-text-secondary`,children:[`/`,r(t.pattern),`/`]}),!!t.path&&(0,U.jsxs)(`p`,{className:`text-text-subtle`,children:[`in `,r(t.path)]})]});case`TodoWrite`:return(0,U.jsx)(J,{todos:t.todos??[]});case`Agent`:case`Task`:return(0,U.jsxs)(`div`,{className:`space-y-1`,children:[!!t.description&&(0,U.jsx)(`p`,{className:`text-text-secondary font-medium`,children:r(t.description)}),!!t.subagent_type&&(0,U.jsxs)(`p`,{className:`text-text-subtle`,children:[`Type: `,r(t.subagent_type)]}),!!t.prompt&&(0,U.jsx)(Z,{content:r(t.prompt),maxHeight:`max-h-48`})]});case`ToolSearch`:return(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(`p`,{className:`font-mono text-text-secondary`,children:r(t.query)}),!!t.max_results&&(0,U.jsxs)(`p`,{className:`text-text-subtle`,children:[`Max results: `,r(t.max_results)]})]});case`WebFetch`:return(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsxs)(`a`,{href:r(t.url),target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-primary hover:underline break-all flex items-center gap-1`,children:[(0,U.jsx)(j,{className:`size-3 shrink-0`}),r(t.url)]}),!!t.prompt&&(0,U.jsx)(`p`,{className:`text-text-subtle`,children:Q(r(t.prompt),100)})]});case`AskUserQuestion`:{let e=t.questions??[],n=t.answers??{};return(0,U.jsx)(`div`,{className:`space-y-2`,children:e.map((e,t)=>(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsxs)(`p`,{className:`text-text-primary font-medium`,children:[e.header?`${e.header}: `:``,e.question]}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.options.map((t,r)=>(0,U.jsx)(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-xs border ${(n[e.question]??``).split(`, `).includes(t.label)?`border-accent bg-accent/20 text-text-primary`:`border-border text-text-subtle`}`,children:t.label},r))}),n[e.question]&&(0,U.jsxs)(`p`,{className:`text-accent text-xs`,children:[`Answer: `,n[e.question]]})]},t))})}default:return(0,U.jsx)(`pre`,{className:`overflow-x-auto text-text-secondary font-mono whitespace-pre-wrap break-all`,children:JSON.stringify(t,null,2)})}}function J({todos:e}){return(0,U.jsx)(`div`,{className:`space-y-0.5`,children:e.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,U.jsx)(`span`,{className:`shrink-0 mt-0.5 ${e.status===`completed`?`text-green-400`:e.status===`in_progress`?`text-yellow-400`:`text-text-subtle`}`,children:e.status===`completed`?`✓`:e.status===`in_progress`?`▶`:`○`}),(0,U.jsx)(`span`,{className:e.status===`completed`?`line-through text-text-subtle`:`text-text-secondary`,children:e.content})]},t))})}function Y({toolName:e,output:t}){let[n,r]=(0,B.useState)(!1),a=(0,B.useMemo)(()=>{if(e!==`Agent`&&e!==`Task`)return null;try{let e=JSON.parse(t);if(Array.isArray(e)){let t=e.filter(e=>e.type===`text`&&e.text).map(e=>e.text).join(`
2
2
 
3
3
  `);if(t)return t}if(typeof e==`string`)return e}catch{if(t&&!t.startsWith(`[{`))return t}return null},[e,t]);return a?(0,U.jsxs)(`div`,{className:`border-t border-border pt-1.5 space-y-1`,children:[(0,U.jsx)(Z,{content:a,maxHeight:`max-h-60`}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),className:`flex items-center gap-1 text-[10px] text-text-subtle hover:text-text-secondary transition-colors`,children:[(0,U.jsx)(i,{className:`size-3`}),n?`Hide`:`Show`,` raw`]}),n&&(0,U.jsx)(`pre`,{className:`overflow-x-auto text-text-subtle font-mono max-h-40 whitespace-pre-wrap break-all text-[10px]`,children:t})]}):(0,U.jsx)(X,{output:t})}function X({output:e}){let t=e.split(`
4
4
  `).length,n=t>3||e.length>200,[r,i]=(0,B.useState)(n);return(0,U.jsxs)(`div`,{className:`border-t border-border pt-1.5`,children:[n&&(0,U.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),className:`flex items-center gap-1 text-[10px] text-text-subtle hover:text-text-secondary transition-colors mb-1`,children:[r?(0,U.jsx)(h,{className:`size-3`}):(0,U.jsx)(m,{className:`size-3`}),`Output (`,t,` lines)`]}),(0,U.jsx)(`pre`,{className:`overflow-x-auto text-text-subtle font-mono whitespace-pre-wrap break-all ${r?`max-h-16 overflow-hidden`:`max-h-60`}`,children:e})]})}function Z({content:e,maxHeight:t=`max-h-48`}){let n=(0,B.useMemo)(()=>{try{return a.parse(e,{gfm:!0,breaks:!0})}catch{return e}},[e]);return(0,U.jsx)(`div`,{className:`markdown-content prose-sm text-text-secondary overflow-auto ${t}`,dangerouslySetInnerHTML:{__html:n}})}function ie(e){return e?e.split(`/`).pop()??e:``}function Q(e,t=50){return e?e.length>t?e.slice(0,t)+`…`:e:``}function ae({messages:e,messagesLoading:t,pendingApproval:n,onApprovalResponse:r,isStreaming:i,projectName:a}){let o=(0,B.useRef)(null),s=(0,B.useRef)(!0);return(0,B.useEffect)(()=>{let t=s.current?`instant`:`smooth`;o.current?.scrollIntoView({behavior:t}),s.current&&e.length>0&&(s.current=!1)},[e,n]),t?(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,U.jsx)(k,{className:`size-10 text-text-subtle animate-pulse`}),(0,U.jsx)(`p`,{className:`text-sm`,children:`Loading messages...`})]}):e.length===0&&!i?(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,U.jsx)(k,{className:`size-10 text-text-subtle`}),(0,U.jsx)(`p`,{className:`text-sm`,children:`Send a message to start the conversation`})]}):(0,U.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[e.filter(e=>{let t=e.content&&e.content.trim().length>0,n=e.events&&e.events.length>0;return t||n}).map(e=>(0,U.jsx)(oe,{message:e,isStreaming:i&&e.id.startsWith(`streaming-`),projectName:a},e.id)),n&&(n.tool===`AskUserQuestion`?(0,U.jsx)(be,{approval:n,onRespond:r}):(0,U.jsx)(ye,{approval:n,onRespond:r})),i&&(0,U.jsx)(_e,{lastMessage:e[e.length-1]}),(0,U.jsx)(`div`,{ref:o})]})}function oe({message:e,isStreaming:t,projectName:n}){return e.role===`user`?(0,U.jsx)(fe,{content:e.content,projectName:n}):e.role===`system`?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-red-500/10 border border-red-500/20 px-3 py-2 text-sm text-red-400`,children:[(0,U.jsx)(_,{className:`size-4 shrink-0`}),(0,U.jsx)(`p`,{children:e.content})]}):(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.events&&e.events.length>0?(0,U.jsx)(he,{events:e.events,isStreaming:t,projectName:n}):e.content&&(0,U.jsx)(`div`,{className:`text-sm text-text-primary`,children:(0,U.jsx)(ve,{content:e.content,projectName:n})})})}var se=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`]);function ce(e){let t=e.match(/^\[Attached file: (.+?)\]\n\n?/);if(t)return{files:[t[1]],text:e.slice(t[0].length)};let n=e.match(/^\[Attached files:\n([\s\S]+?)\]\n\n?/);return n?{files:n[1].split(`
5
- `).map(e=>e.trim()).filter(Boolean),text:e.slice(n[0].length)}:{files:[],text:e}}function le(e,t){let n=e.split(`/`).pop()??``;return`/api/project/${encodeURIComponent(t??`_`)}/chat/uploads/${encodeURIComponent(n)}`}function ue(e){let t=e.lastIndexOf(`.`);return t===-1?!1:se.has(e.slice(t).toLowerCase())}function de(e){return e.toLowerCase().endsWith(`.pdf`)}function fe({content:e,projectName:t}){let{files:n,text:r}=(0,B.useMemo)(()=>ce(e),[e]);return(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsxs)(`div`,{className:`rounded-lg bg-primary/10 px-3 py-2 text-sm text-text-primary max-w-[85%] space-y-2`,children:[n.length>0&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n.map((e,n)=>ue(e)?(0,U.jsx)(pe,{src:le(e,t),alt:e.split(`/`).pop()??`image`},n):de(e)?(0,U.jsx)(me,{src:le(e,t),filename:e.split(`/`).pop()??`document.pdf`,mimeType:`application/pdf`},n):(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-background/50 px-2 py-1 text-xs text-text-secondary`,children:[(0,U.jsx)(g,{className:`size-3.5 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate max-w-40`,children:e.split(`/`).pop()})]},n))}),r&&(0,U.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:r})]})})}function pe({src:e,alt:t}){let[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{let t,n=d();return fetch(e,{headers:n?{Authorization:`Bearer ${n}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed to load`);return e.blob()}).then(e=>{let n=URL.createObjectURL(e);t=n,r(n)}).catch(()=>a(!0)),()=>{t&&URL.revokeObjectURL(t)}},[e]),i?(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-background/50 px-2 py-1 text-xs text-text-secondary`,children:[(0,U.jsx)(M,{className:`size-3.5 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate max-w-40`,children:t})]}):n?(0,U.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:`block`,children:(0,U.jsx)(`img`,{src:n,alt:t,className:`rounded-md max-h-48 max-w-full object-contain border border-border`})}):(0,U.jsx)(`div`,{className:`rounded-md bg-surface border border-border h-24 w-32 animate-pulse`})}function me({src:e,filename:t,mimeType:n}){let[r,i]=(0,B.useState)(!1);return(0,U.jsxs)(`button`,{type:`button`,onClick:(0,B.useCallback)(async()=>{i(!0);try{let t=d(),r=await fetch(e,{headers:t?{Authorization:`Bearer ${t}`}:{}});if(!r.ok)throw Error(`Failed to load`);let i=await r.blob(),a=URL.createObjectURL(new Blob([i],{type:n}));window.open(a,`_blank`),setTimeout(()=>URL.revokeObjectURL(a),6e4)}catch{window.open(e,`_blank`)}finally{i(!1)}},[e,n]),disabled:r,className:`flex items-center gap-1.5 rounded-md border border-border bg-background/50 px-2 py-1 text-xs text-text-secondary hover:bg-surface hover:text-text-primary transition-colors cursor-pointer disabled:opacity-50`,children:[(0,U.jsx)(g,{className:`size-3.5 shrink-0 text-red-400`}),(0,U.jsx)(`span`,{className:`truncate max-w-40`,children:t}),r&&(0,U.jsx)(`span`,{className:`animate-spin text-[10px]`,children:`...`})]})}function he({events:e,isStreaming:t,projectName:n}){let r=[],i=``;for(let t=0;t<e.length;t++){let n=e[t];n.type===`text`?i+=n.content:n.type===`tool_use`?(i&&=(r.push({kind:`text`,content:i}),``),r.push({kind:`tool`,tool:n})):n.type===`tool_result`||(i&&=(r.push({kind:`text`,content:i}),``),r.push({kind:`tool`,tool:n}))}i&&r.push({kind:`text`,content:i});let a=e.filter(e=>e.type===`tool_result`);for(let e of a){let t=e.toolUseId;if(t){let n=r.find(e=>e.kind===`tool`&&e.tool.type===`tool_use`&&e.tool.toolUseId===t);if(n){n.result=e;continue}}let n=r.find(e=>e.kind===`tool`&&!e.result);n&&(n.result=e)}for(let e=0;e<r.length;e++){let n=r[e];n.kind===`tool`&&!n.result&&(n.completed=e<r.length-1||!t)}return(0,U.jsx)(U.Fragment,{children:r.map((e,i)=>{if(e.kind===`text`){let a=t&&i===r.length-1;return(0,U.jsx)(`div`,{className:`text-sm text-text-primary`,children:(0,U.jsx)(ge,{content:e.content,animate:a,projectName:n})},`text-${i}`)}return(0,U.jsx)(G,{tool:e.tool,result:e.result,completed:e.completed,projectName:n},`tool-${i}`)})})}function ge({content:e,animate:t,projectName:n}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ve,{content:e,projectName:n}),t&&(0,U.jsx)(`span`,{className:`text-text-subtle text-sm animate-pulse`,children:`Thinking...`})]})}function _e({lastMessage:e}){if(!e||e.role!==`assistant`)return(0,U.jsx)(`div`,{className:`flex items-center gap-2 text-text-subtle text-sm`,children:(0,U.jsx)(`span`,{className:`animate-pulse`,children:`Thinking...`})});let t=e.events;if(t&&t.length>0){let e=t[t.length-1];if(e?.type===`tool_use`||e?.type===`tool_result`)return(0,U.jsx)(`div`,{className:`flex items-center gap-2 text-text-subtle text-sm`,children:(0,U.jsx)(`span`,{className:`animate-pulse`,children:`Thinking...`})})}return null}a.setOptions({gfm:!0,breaks:!0});function ve({content:e,projectName:t}){let n=(0,B.useMemo)(()=>{try{return a.parse(e)}catch{return e}},[e]),r=(0,B.useRef)(null),{openTab:i}=w();return(0,B.useEffect)(()=>{let e=r.current;if(!e)return;e.querySelectorAll(`pre`).forEach(e=>{if(e.querySelector(`.code-actions`))return;let n=e.querySelector(`code`),r=n?.textContent??e.textContent??``,a=n?.className??``,o=/language-(bash|sh|shell|zsh)/.test(a)||!a.includes(`language-`)&&r.startsWith(`$`);e.style.position=`relative`;let s=document.createElement(`div`);s.className=`code-actions absolute top-1 right-1 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,e.classList.add(`group`);let c=document.createElement(`button`);if(c.className=`flex items-center justify-center size-6 rounded bg-surface-elevated/80 hover:bg-surface-elevated text-text-secondary hover:text-text-primary transition-colors border border-border/50`,c.title=`Copy`,c.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,c.addEventListener(`click`,()=>{navigator.clipboard.writeText(r),c.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>`,setTimeout(()=>{c.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`},2e3)}),s.appendChild(c),o){let e=document.createElement(`button`);e.className=`flex items-center justify-center size-6 rounded bg-surface-elevated/80 hover:bg-surface-elevated text-text-secondary hover:text-text-primary transition-colors border border-border/50`,e.title=`Run in terminal`,e.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/></svg>`,e.addEventListener(`click`,()=>{navigator.clipboard.writeText(r.replace(/^\$\s*/gm,``)),t&&i({type:`terminal`,title:`Terminal`,metadata:{projectName:t},projectId:t,closable:!0})}),s.appendChild(e)}e.appendChild(s)});let n=n=>{let r=n.target.closest(`a`);if(!r||!e.contains(r))return;let a=r.getAttribute(`href`)??``;(/^(\/|\.\/|\.\.\/)/.test(a)||/\.(ts|tsx|js|jsx|py|json|md|yaml|yml|toml|css|html|sh|go|rs|sql)$/i.test(a))&&t&&(n.preventDefault(),i({type:`editor`,title:a.split(`/`).pop()??a,metadata:{filePath:a,projectName:t},projectId:t,closable:!0}))};return e.addEventListener(`click`,n),()=>e.removeEventListener(`click`,n)},[n,t,i]),(0,U.jsx)(`div`,{ref:r,className:`markdown-content prose-sm`,dangerouslySetInnerHTML:{__html:n}})}function ye({approval:e,onRespond:t}){return(0,U.jsxs)(`div`,{className:`rounded-lg border-2 border-yellow-500/40 bg-yellow-500/10 p-3 space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-yellow-400 text-sm font-medium`,children:[(0,U.jsx)(I,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Tool Approval Required`})]}),(0,U.jsx)(`div`,{className:`text-xs text-text-primary`,children:(0,U.jsx)(`span`,{className:`font-medium`,children:e.tool})}),(0,U.jsx)(`pre`,{className:`text-xs font-mono text-text-secondary overflow-x-auto bg-background rounded p-2 border border-border`,children:JSON.stringify(e.input,null,2)}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`button`,{onClick:()=>t(e.requestId,!0),className:`px-4 py-1.5 rounded bg-green-600 text-white text-xs font-medium hover:bg-green-500 transition-colors`,children:`Allow`}),(0,U.jsx)(`button`,{onClick:()=>t(e.requestId,!1),className:`px-4 py-1.5 rounded bg-red-600 text-white text-xs font-medium hover:bg-red-500 transition-colors`,children:`Deny`})]})]})}function be({approval:e,onRespond:t}){let n=e.input.questions??[],[r,i]=(0,B.useState)({}),[a,o]=(0,B.useState)({}),s=(e,t,n)=>{o(t=>({...t,[e]:!1})),i(r=>{if(!n)return{...r,[e]:t};let i=r[e]??``,a=i?i.split(`, `):[],o=a.indexOf(t);return o>=0?a.splice(o,1):a.push(t),{...r,[e]:a.join(`, `)}})},c=e=>{o(t=>({...t,[e]:!0})),i(t=>({...t,[e]:``}))},l=(e,t)=>{i(n=>({...n,[e]:t}))},u=n.every(e=>r[e.question]?.trim());return(0,U.jsxs)(`div`,{className:`rounded-lg border-2 border-accent/40 bg-accent/5 p-3 space-y-3`,children:[n.map((e,t)=>(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsxs)(`p`,{className:`text-sm text-text-primary font-medium`,children:[e.header?`${e.header}: `:``,e.question]}),e.multiSelect&&(0,U.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Select multiple`}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.options.map((t,n)=>(0,U.jsxs)(`button`,{onClick:()=>s(e.question,t.label,e.multiSelect),className:`text-left rounded px-2.5 py-1.5 text-xs border transition-colors ${!a[e.question]&&(r[e.question]??``).split(`, `).includes(t.label)?`border-accent bg-accent/20 text-text-primary`:`border-border bg-background text-text-secondary hover:bg-surface-elevated`}`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:t.label}),t.description&&(0,U.jsxs)(`span`,{className:`text-text-subtle ml-1.5`,children:[`— `,t.description]})]},n)),a[e.question]?(0,U.jsx)(`input`,{type:`text`,autoFocus:!0,placeholder:`Type your answer...`,value:r[e.question]??``,onChange:t=>l(e.question,t.target.value),className:`rounded px-2.5 py-1.5 text-xs border border-accent bg-accent/10 text-text-primary outline-none placeholder:text-text-subtle`}):(0,U.jsx)(`button`,{onClick:()=>c(e.question),className:`text-left rounded px-2.5 py-1.5 text-xs border border-dashed border-border text-text-subtle hover:bg-surface-elevated transition-colors`,children:`Other — type your own answer`})]})]},t)),(0,U.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,U.jsx)(`button`,{onClick:()=>t(e.requestId,!0,r),disabled:!u,className:`px-4 py-1.5 rounded bg-accent text-white text-xs font-medium hover:bg-accent/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:`Submit`}),(0,U.jsx)(`button`,{onClick:()=>t(e.requestId,!1),className:`px-4 py-1.5 rounded bg-surface-elevated text-text-secondary text-xs hover:bg-surface transition-colors`,children:`Skip`})]})]})}var xe=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]),Se=new Set([`application/pdf`]),Ce=[`text/`,`application/json`,`application/xml`,`application/javascript`,`application/typescript`,`application/x-yaml`,`application/toml`,`application/x-sh`],we=new Set(`.ts,.tsx,.js,.jsx,.mjs,.cjs,.py,.rb,.go,.rs,.java,.kt,.swift,.c,.cpp,.h,.hpp,.cs,.json,.yaml,.yml,.toml,.xml,.md,.mdx,.txt,.csv,.tsv,.html,.css,.scss,.less,.sass,.sh,.bash,.zsh,.fish,.sql,.graphql,.gql,.env,.ini,.cfg,.conf,.dockerfile,.makefile,.vue,.svelte,.astro,.ipynb`.split(`,`));function Te(e){return xe.has(e.type)}function Ee(e){if(xe.has(e.type)||Se.has(e.type)||Ce.some(t=>e.type.startsWith(t)))return!0;let t=De(e.name);return!!(t&&we.has(t))}function De(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t).toLowerCase()}function Oe({attachments:e,onRemove:t}){return e.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-3 pt-2`,children:e.map(e=>(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-surface px-2 py-1 text-xs text-text-secondary max-w-48`,children:[e.previewUrl?(0,U.jsx)(`img`,{src:e.previewUrl,alt:e.name,className:`size-5 rounded object-cover shrink-0`}):e.isImage?(0,U.jsx)(M,{className:`size-3.5 shrink-0 text-text-subtle`}):(0,U.jsx)(g,{className:`size-3.5 shrink-0 text-text-subtle`}),(0,U.jsx)(`span`,{className:`truncate`,children:e.name}),e.status===`uploading`?(0,U.jsx)(v,{className:`size-3 shrink-0 animate-spin text-text-subtle`}):e.status===`error`?(0,U.jsx)(`span`,{className:`text-red-500 shrink-0`,title:`Upload failed`,children:`!`}):null,(0,U.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),className:`shrink-0 rounded-sm p-0.5 hover:bg-border/50 transition-colors`,"aria-label":`Remove ${e.name}`,children:(0,U.jsx)(l,{className:`size-3`})})]},e.id))})}function ke(e){let t=[];function n(e){for(let r of e)t.push(r),r.children&&n(r.children)}return n(e),t}function Ae({items:e,filter:t,onSelect:n,onClose:r,visible:i}){let[a,o]=(0,B.useState)(0),s=(0,B.useRef)(null),c=(()=>{if(!t)return e.slice(0,50);let n=t.toLowerCase();return e.filter(e=>e.path.toLowerCase().includes(n)||e.name.toLowerCase().includes(n)).slice(0,50)})();(0,B.useEffect)(()=>{o(0)},[t]),(0,B.useEffect)(()=>{let e=s.current;e&&e.children[a]?.scrollIntoView({block:`nearest`})},[a]);let l=(0,B.useCallback)(e=>{if(!i||c.length===0)return!1;switch(e.key){case`ArrowUp`:return e.preventDefault(),o(e=>e>0?e-1:c.length-1),!0;case`ArrowDown`:return e.preventDefault(),o(e=>e<c.length-1?e+1:0),!0;case`Enter`:case`Tab`:return e.preventDefault(),c[a]&&n(c[a]),!0;case`Escape`:return e.preventDefault(),r(),!0}return!1},[i,c,a,n,r]);return(0,B.useEffect)(()=>{if(!i)return;let e=e=>{l(e)};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i,l]),!i||c.length===0?null:(0,U.jsx)(`div`,{className:`max-h-52 overflow-y-auto border-b border-border bg-surface`,children:(0,U.jsx)(`div`,{ref:s,className:`py-1`,children:c.map((e,t)=>(0,U.jsxs)(`button`,{className:`flex items-center gap-2 w-full px-3 py-1.5 text-left transition-colors ${t===a?`bg-primary/10 text-primary`:`hover:bg-surface-hover text-text-primary`}`,onMouseEnter:()=>o(t),onClick:()=>n(e),children:[(0,U.jsx)(`span`,{className:`shrink-0`,children:e.type===`directory`?(0,U.jsx)(D,{className:`size-4 text-amber-500`}):(0,U.jsx)(E,{className:`size-4 text-blue-400`})}),(0,U.jsx)(`span`,{className:`text-sm truncate`,children:e.path})]},e.path))})})}function je({onSend:e,isStreaming:t,onCancel:n,disabled:r,projectName:i,onSlashStateChange:a,onSlashItemsLoaded:o,slashSelected:s,onFileStateChange:c,onFileItemsLoaded:l,fileSelected:m,externalFiles:h}){let[g,_]=(0,B.useState)(``),[v,y]=(0,B.useState)([]),b=(0,B.useRef)(null),x=(0,B.useRef)(null),S=(0,B.useRef)([]),C=(0,B.useRef)([]);(0,B.useEffect)(()=>{if(!i){S.current=[],o?.([]);return}p.get(`${f(i)}/chat/slash-items`).then(e=>{S.current=e,o?.(e)}).catch(()=>{S.current=[],o?.([])})},[i]),(0,B.useEffect)(()=>{if(!i){C.current=[],l?.([]);return}p.get(`${f(i)}/files/tree?depth=5`).then(e=>{let t=ke(e);C.current=t,l?.(t)}).catch(()=>{C.current=[],l?.([])})},[i]),(0,B.useEffect)(()=>{if(!s)return;let e=`/${s.name} `;_(e),a?.(!1,``),c?.(!1,``);let t=b.current;t&&(t.focus(),setTimeout(()=>{t.selectionStart=t.selectionEnd=e.length},0))},[s]),(0,B.useEffect)(()=>{if(!m)return;let e=b.current;if(!e)return;let t=e.selectionStart,n=g.slice(0,t),r=g.slice(t),i=n.match(/@(\S*)$/);if(i){let t=n.length-i[0].length;_(n.slice(0,t)+`@${m.path} `+r);let a=t+m.path.length+2;setTimeout(()=>{e.selectionStart=e.selectionEnd=a,e.focus()},0)}else{let t=g+`@${m.path} `;_(t),setTimeout(()=>{e.selectionStart=e.selectionEnd=t.length,e.focus()},0)}c?.(!1,``)},[m]),(0,B.useEffect)(()=>{!h||h.length===0||T(h)},[h]);let w=(0,B.useCallback)(async e=>{if(!i)return null;try{let t=new FormData;t.append(`files`,e);let n={},r=d();r&&(n.Authorization=`Bearer ${r}`);let a=await(await fetch(`${f(i)}/chat/upload`,{method:`POST`,headers:n,body:t})).json();return a.ok&&Array.isArray(a.data)&&a.data.length>0?a.data[0].path:null}catch{return null}},[i]),T=(0,B.useCallback)(e=>{for(let t of e){if(!Ee(t)){_(e=>e+(e.length>0&&!e.endsWith(` `)?` `:``)+t.name);continue}let e=u(),n=Te(t),r=n?URL.createObjectURL(t):void 0,i={id:e,name:t.name,file:t,isImage:n,previewUrl:r,status:`uploading`};y(e=>[...e,i]),w(t).then(t=>{y(n=>n.map(n=>n.id===e?{...n,serverPath:t??void 0,status:t?`ready`:`error`}:n))})}b.current?.focus()},[w]),E=(0,B.useCallback)(e=>{y(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),D=(0,B.useCallback)(()=>{let t=g.trim(),n=v.filter(e=>e.status===`ready`);if(!(!t&&n.length===0)&&!r){a?.(!1,``),c?.(!1,``),e(t,n),_(``);for(let e of v)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);y([]),b.current&&(b.current.style.height=`auto`)}},[g,v,r,e,a,c]),O=(0,B.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),D())},[D]),k=(0,B.useCallback)((e,t)=>{let n=e.match(/^\/(\S*)$/);if(n&&S.current.length>0){a?.(!0,n[1]??``),c?.(!1,``);return}let r=e.slice(0,t).match(/@(\S*)$/);if(r&&C.current.length>0){c?.(!0,r[1]??``),a?.(!1,``);return}a?.(!1,``),c?.(!1,``)},[a,c]),A=(0,B.useCallback)(e=>{_(e),setTimeout(()=>{k(e,b.current?.selectionStart??e.length)},0)},[k]),j=(0,B.useCallback)(()=>{let e=b.current;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,160)+`px`)},[]),M=(0,B.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),T(n))},[T]),N=(0,B.useCallback)(e=>{e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length>0&&T(t)},[T]),I=(0,B.useCallback)(e=>{e.preventDefault()},[]),L=(0,B.useCallback)(()=>{x.current?.click()},[]),ee=(0,B.useCallback)(e=>{let t=Array.from(e.target.files??[]);t.length>0&&T(t),e.target.value=``},[T]),z=g.trim().length>0||v.some(e=>e.status===`ready`),V=t&&!z;return(0,U.jsxs)(`div`,{className:`border-t border-border bg-background`,children:[(0,U.jsx)(Oe,{attachments:v,onRemove:E}),(0,U.jsxs)(`div`,{className:`flex items-end gap-2 p-3`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:L,disabled:r,className:`flex items-center justify-center rounded-lg p-2 text-text-subtle hover:text-text-primary hover:bg-surface transition-colors shrink-0 disabled:opacity-50`,"aria-label":`Attach file`,children:(0,U.jsx)(P,{className:`size-4`})}),(0,U.jsx)(`input`,{ref:x,type:`file`,multiple:!0,className:`hidden`,onChange:ee}),(0,U.jsx)(`textarea`,{ref:b,value:g,onChange:e=>{A(e.target.value),j()},onKeyDown:O,onPaste:M,onDrop:N,onDragOver:I,placeholder:t?`Send follow-up or press Stop...`:`Type / for commands, @ for files, or drop files...`,disabled:r,rows:1,className:`flex-1 resize-none rounded-lg border border-border bg-surface px-3 py-2 text-base md:text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-ring disabled:opacity-50 max-h-40`}),V?(0,U.jsx)(`button`,{onClick:n,className:`flex items-center justify-center rounded-lg bg-red-600 p-2 text-white hover:bg-red-500 transition-colors shrink-0`,"aria-label":`Stop response`,children:(0,U.jsx)(R,{className:`size-4`})}):(0,U.jsx)(`button`,{onClick:D,disabled:r||!z,className:`flex items-center justify-center rounded-lg bg-primary p-2 text-white hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,"aria-label":`Send message`,children:(0,U.jsx)(F,{className:`size-4`})})]})]})}function Me({currentSessionId:e,onSelectSession:t,onNewSession:n,projectName:r}){let[i,a]=(0,B.useState)([]),[o,s]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1),d=(0,B.useCallback)(async()=>{if(r){u(!0);try{a(await p.get(`${f(r)}/chat/sessions`))}catch{}finally{u(!1)}}},[r]);(0,B.useEffect)(()=>{d()},[d]),(0,B.useEffect)(()=>{o&&d()},[o,d]);let h=i.find(t=>t.id===e),g=async(e,t)=>{e.stopPropagation();try{if(!r)return;await p.del(`${f(r)}/chat/sessions/${t.id}?providerId=${t.providerId}`),a(e=>e.filter(e=>e.id!==t.id))}catch{}};return(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsxs)(`button`,{onClick:()=>s(!o),className:`flex items-center gap-1.5 text-sm text-text-secondary hover:text-text-primary transition-colors px-2 py-1 rounded hover:bg-surface-elevated`,children:[(0,U.jsx)(y,{className:`size-3.5`}),(0,U.jsx)(`span`,{className:`truncate max-w-[150px]`,children:h?.title??`Select chat`}),(0,U.jsx)(m,{className:`size-3`})]}),o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>s(!1)}),(0,U.jsxs)(`div`,{className:`absolute bottom-full left-0 mb-1 z-50 w-64 rounded-lg border border-border bg-surface shadow-lg overflow-hidden`,children:[(0,U.jsxs)(`button`,{onClick:()=>{n(),s(!1)},className:`flex items-center gap-2 w-full px-3 py-2 text-sm text-primary hover:bg-surface-elevated transition-colors border-b border-border`,children:[(0,U.jsx)(b,{className:`size-4`}),(0,U.jsx)(`span`,{children:`New Chat`})]}),(0,U.jsxs)(`div`,{className:`max-h-60 overflow-y-auto`,children:[l&&(0,U.jsx)(`p`,{className:`px-3 py-2 text-xs text-text-subtle animate-pulse`,children:`Loading sessions...`}),!l&&i.length===0&&(0,U.jsx)(`p`,{className:`px-3 py-2 text-xs text-text-subtle`,children:`No sessions yet`}),i.map(n=>(0,U.jsxs)(`div`,{onClick:()=>{t(n),s(!1)},className:`flex items-center justify-between px-3 py-2 text-sm cursor-pointer hover:bg-surface-elevated transition-colors ${n.id===e?`bg-surface-elevated text-text-primary`:`text-text-secondary`}`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`truncate text-xs font-medium`,children:n.title}),(0,U.jsx)(`span`,{className:`text-xs text-text-subtle`,children:new Date(n.createdAt).toLocaleDateString()})]}),(0,U.jsx)(`button`,{onClick:e=>g(e,n),className:`p-1 rounded hover:bg-red-500/20 text-text-subtle hover:text-red-400 transition-colors shrink-0`,"aria-label":`Delete session`,children:(0,U.jsx)(c,{className:`size-3`})})]},n.id))]})]})]})]})}function Ne({items:e,filter:t,onSelect:n,onClose:r,visible:i}){let[a,o]=(0,B.useState)(0),s=(0,B.useRef)(null),c=e.filter(e=>{let n=t.toLowerCase();return e.name.toLowerCase().includes(n)||e.description.toLowerCase().includes(n)});(0,B.useEffect)(()=>{o(0)},[t]),(0,B.useEffect)(()=>{let e=s.current;e&&e.children[a]?.scrollIntoView({block:`nearest`})},[a]);let l=(0,B.useCallback)(e=>{if(!i||c.length===0)return!1;switch(e.key){case`ArrowUp`:return e.preventDefault(),o(e=>e>0?e-1:c.length-1),!0;case`ArrowDown`:return e.preventDefault(),o(e=>e<c.length-1?e+1:0),!0;case`Enter`:case`Tab`:return e.preventDefault(),c[a]&&n(c[a]),!0;case`Escape`:return e.preventDefault(),r(),!0}return!1},[i,c,a,n,r]);return(0,B.useEffect)(()=>{if(!i)return;let e=e=>{l(e)};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i,l]),!i||c.length===0?null:(0,U.jsx)(`div`,{className:`max-h-52 overflow-y-auto border-b border-border bg-surface`,children:(0,U.jsx)(`div`,{ref:s,className:`py-1`,children:c.map((e,t)=>(0,U.jsxs)(`button`,{className:`flex items-start gap-3 w-full px-3 py-2 text-left transition-colors ${t===a?`bg-primary/10 text-primary`:`hover:bg-surface-hover text-text-primary`}`,onMouseEnter:()=>o(t),onClick:()=>n(e),children:[(0,U.jsx)(`span`,{className:`shrink-0 mt-0.5`,children:e.type===`skill`?(0,U.jsx)(L,{className:`size-4 text-amber-500`}):(0,U.jsx)(C,{className:`size-4 text-blue-500`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,U.jsxs)(`span`,{className:`font-medium text-sm`,children:[`/`,e.name]}),e.argumentHint&&(0,U.jsx)(`span`,{className:`text-xs text-text-subtle`,children:e.argumentHint}),(0,U.jsx)(`span`,{className:`text-xs text-text-subtle capitalize ml-auto`,children:e.scope===`user`?`global`:e.type})]}),e.description&&(0,U.jsx)(`p`,{className:`text-xs text-text-subtle mt-0.5 line-clamp-2`,children:e.description})]})]},`${e.type}-${e.name}`))})})}function Pe(e){return e>=90?`text-red-500`:e>=70?`text-amber-500`:`text-green-500`}function Fe(e){return e>=90?`bg-red-500`:e>=70?`bg-amber-500`:`bg-green-500`}function Ie({usage:e,onClick:t}){let n=e.fiveHour==null?null:Math.round(e.fiveHour*100),r=e.sevenDay==null?null:Math.round(e.sevenDay*100),i=n==null?`--%`:`${n}%`,a=r==null?`--%`:`${r}%`;return(0,U.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] font-medium tabular-nums transition-colors hover:bg-surface-hover ${n!=null||r!=null?Pe(Math.max(n??0,r??0)):`text-text-subtle`}`,title:`Click for usage details`,children:[(0,U.jsx)(O,{className:`size-3`}),(0,U.jsxs)(`span`,{children:[`5h:`,i]}),(0,U.jsx)(`span`,{className:`text-text-subtle`,children:`·`}),(0,U.jsxs)(`span`,{children:[`Wk:`,a]})]})}function Le(e){if(!e)return null;let t=null;if(e.resetsInMinutes!=null)t=e.resetsInMinutes;else if(e.resetsInHours!=null)t=Math.round(e.resetsInHours*60);else if(e.resetsAt){let n=new Date(e.resetsAt).getTime()-Date.now();t=n>0?Math.ceil(n/6e4):0}if(t==null)return null;if(t<=0)return`now`;let n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?i>0?`${n}d ${r}h ${i}m`:r>0?`${n}d ${r}h`:`${n}d`:r>0?i>0?`${r}h ${i}m`:`${r}h`:`${i}m`}function Re(e){if(!e)return null;switch(e){case`ahead_of_pace`:return{text:`Ahead of pace`,color:`text-green-500`};case`behind_pace`:return{text:`Behind pace`,color:`text-amber-500`};case`on_pace`:return{text:`On pace`,color:`text-text-subtle`};default:return{text:e.replace(/_/g,` `),color:`text-text-subtle`}}}function $({label:e,bucket:t}){if(!t)return null;let n=Math.round(t.utilization*100),r=Le(t),i=Re(t.status);return(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium text-text-primary`,children:e}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&(0,U.jsx)(`span`,{className:`text-[10px] ${i.color}`,children:i.text}),r&&(0,U.jsxs)(`span`,{className:`text-[10px] text-text-subtle`,children:[`↻ `,r]})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`div`,{className:`flex-1 h-2 rounded-full bg-border overflow-hidden`,children:(0,U.jsx)(`div`,{className:`h-full rounded-full transition-all ${Fe(n)}`,style:{width:`${Math.min(n,100)}%`}})}),(0,U.jsxs)(`span`,{className:`text-xs font-medium tabular-nums w-10 text-right ${Pe(n)}`,children:[n,`%`]})]})]})}function ze({usage:e,visible:t,onClose:n,onReload:r,loading:i}){if(!t)return null;let a=e.queryCostUsd!=null||e.totalCostUsd!=null,o=e.session||e.weekly||e.weeklyOpus||e.weeklySonnet;return(0,U.jsxs)(`div`,{className:`border-b border-border bg-surface px-3 py-2.5 space-y-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-xs font-semibold text-text-primary`,children:`Usage Limits`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[r&&(0,U.jsx)(`button`,{onClick:r,disabled:i,className:`text-xs text-text-subtle hover:text-text-primary px-1 disabled:opacity-50`,title:`Refresh usage data`,children:(0,U.jsx)(s,{className:`size-3 ${i?`animate-spin`:``}`})}),(0,U.jsx)(`button`,{onClick:n,className:`text-xs text-text-subtle hover:text-text-primary px-1`,children:`✕`})]})]}),o?(0,U.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,U.jsx)($,{label:`5-Hour Session`,bucket:e.session}),(0,U.jsx)($,{label:`Weekly`,bucket:e.weekly}),(0,U.jsx)($,{label:`Weekly (Opus)`,bucket:e.weeklyOpus}),(0,U.jsx)($,{label:`Weekly (Sonnet)`,bucket:e.weeklySonnet})]}):(0,U.jsxs)(`p`,{className:`text-xs text-text-subtle`,children:[`No data — run `,(0,U.jsx)(`code`,{className:`bg-surface-elevated px-1 rounded`,children:`bun install`})]}),a&&(0,U.jsxs)(`div`,{className:`border-t border-border pt-2 space-y-1`,children:[e.queryCostUsd!=null&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,U.jsx)(`span`,{className:`text-text-subtle`,children:`Last query`}),(0,U.jsxs)(`span`,{className:`text-text-primary font-medium tabular-nums`,children:[`$`,e.queryCostUsd.toFixed(4)]})]}),e.totalCostUsd!=null&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,U.jsx)(`span`,{className:`text-text-subtle`,children:`Session total`}),(0,U.jsxs)(`span`,{className:`text-text-primary font-medium tabular-nums`,children:[`$`,e.totalCostUsd.toFixed(4)]})]})]})]})}function Be({metadata:e,tabId:t}){let[n,r]=(0,B.useState)(e?.sessionId??null),[i,a]=(0,B.useState)(e?.providerId??`claude-sdk`),[o,s]=(0,B.useState)([]),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(``),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)([]),[v,y]=(0,B.useState)(!1),[b,S]=(0,B.useState)(``),[C,T]=(0,B.useState)(null),[E,D]=(0,B.useState)(!1),[O,k]=(0,B.useState)(!1),[A,j]=(0,B.useState)(null),M=(0,B.useRef)(0),N=x(e=>e.activeProject),P=w(e=>e.updateTab);(0,B.useEffect)(()=>{!t||!n||P(t,{metadata:{...e,sessionId:n,providerId:i}})},[n,i]);let{messages:F,messagesLoading:I,isStreaming:L,pendingApproval:R,usageInfo:z,usageLoading:V,sendMessage:H,respondToApproval:te,cancelStreaming:ne,refreshUsage:W,isConnected:G}=re(n,i,N?.name??``),K=(0,B.useCallback)(()=>{let e=N?.name??null;w.getState().openTab({type:`chat`,title:`AI Chat`,metadata:{projectName:e},projectId:e,closable:!0})},[N?.name]),q=(0,B.useCallback)(e=>{r(e.id),a(e.providerId)},[]),J=(0,B.useCallback)((e,t)=>{if(t.length===0)return e;let n=t.filter(e=>e.serverPath).map(e=>e.serverPath).join(`
6
- `);return n?(t.length===1?`[Attached file: ${n}]\n\n`:`[Attached files:\n${n}\n]\n\n`)+e:e},[]),Y=(0,B.useCallback)(async(t,o=[])=>{let s=J(t,o);if(s.trim()){if(!n)try{let n=N?.name??e?.project??``,o=await p.post(`${f(n)}/chat/sessions`,{providerId:i,title:t.slice(0,50)});r(o.id),a(o.providerId),setTimeout(()=>{H(s)},500);return}catch(e){console.error(`Failed to create session:`,e);return}H(s)}},[n,i,e?.project,H,J,N?.name]),X=(0,B.useCallback)((e,t)=>{l(e),d(t)},[]),Z=(0,B.useCallback)(e=>{h(e),l(!1),d(``),setTimeout(()=>h(null),50)},[]),ie=(0,B.useCallback)(()=>{l(!1),d(``)},[]),Q=(0,B.useCallback)((e,t)=>{y(e),S(t)},[]),oe=(0,B.useCallback)(e=>{T(e),y(!1),S(``),setTimeout(()=>T(null),50)},[]),se=(0,B.useCallback)(()=>{y(!1),S(``)},[]);return(0,U.jsxs)(`div`,{className:`flex flex-col h-full relative`,onDragEnter:(0,B.useCallback)(e=>{e.preventDefault(),M.current++,e.dataTransfer.types.includes(`Files`)&&k(!0)},[]),onDragLeave:(0,B.useCallback)(e=>{e.preventDefault(),M.current--,M.current===0&&k(!1)},[]),onDragOver:(0,B.useCallback)(e=>{e.preventDefault()},[]),onDrop:(0,B.useCallback)(e=>{e.preventDefault(),M.current=0,k(!1);let t=Array.from(e.dataTransfer.files);t.length>0&&(j(t),setTimeout(()=>j(null),100))},[]),children:[O&&(0,U.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm border-2 border-dashed border-primary rounded-lg pointer-events-none`,children:(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-primary`,children:[(0,U.jsx)(ee,{className:`size-8`}),(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Drop files to attach`})]})}),(0,U.jsx)(ae,{messages:F,messagesLoading:I,pendingApproval:R,onApprovalResponse:te,isStreaming:L,projectName:N?.name}),(0,U.jsxs)(`div`,{className:`border-t border-border bg-background shrink-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-border/50`,children:[(0,U.jsx)(Me,{currentSessionId:n,onSelectSession:q,onNewSession:K,projectName:N?.name}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(Ie,{usage:z,onClick:()=>D(e=>!e)}),G&&(0,U.jsx)(`span`,{className:`size-2 rounded-full bg-green-500`,title:`Connected`})]})]}),(0,U.jsx)(ze,{usage:z,visible:E,onClose:()=>D(!1),onReload:W,loading:V}),(0,U.jsx)(Ne,{items:o,filter:u,onSelect:Z,onClose:ie,visible:c}),(0,U.jsx)(Ae,{items:g,filter:b,onSelect:oe,onClose:se,visible:v}),(0,U.jsx)(je,{onSend:Y,isStreaming:L,onCancel:ne,projectName:N?.name,onSlashStateChange:X,onSlashItemsLoaded:s,slashSelected:m,onFileStateChange:Q,onFileItemsLoaded:_,fileSelected:C,externalFiles:A})]})]})}export{Be as ChatTab};
5
+ `).map(e=>e.trim()).filter(Boolean),text:e.slice(n[0].length)}:{files:[],text:e}}function le(e,t){let n=e.split(`/`).pop()??``;return`/api/project/${encodeURIComponent(t??`_`)}/chat/uploads/${encodeURIComponent(n)}`}function ue(e){let t=e.lastIndexOf(`.`);return t===-1?!1:se.has(e.slice(t).toLowerCase())}function de(e){return e.toLowerCase().endsWith(`.pdf`)}function fe({content:e,projectName:t}){let{files:n,text:r}=(0,B.useMemo)(()=>ce(e),[e]);return(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsxs)(`div`,{className:`rounded-lg bg-primary/10 px-3 py-2 text-sm text-text-primary max-w-[85%] space-y-2`,children:[n.length>0&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n.map((e,n)=>ue(e)?(0,U.jsx)(pe,{src:le(e,t),alt:e.split(`/`).pop()??`image`},n):de(e)?(0,U.jsx)(me,{src:le(e,t),filename:e.split(`/`).pop()??`document.pdf`,mimeType:`application/pdf`},n):(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-background/50 px-2 py-1 text-xs text-text-secondary`,children:[(0,U.jsx)(g,{className:`size-3.5 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate max-w-40`,children:e.split(`/`).pop()})]},n))}),r&&(0,U.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:r})]})})}function pe({src:e,alt:t}){let[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{let t,n=d();return fetch(e,{headers:n?{Authorization:`Bearer ${n}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed to load`);return e.blob()}).then(e=>{let n=URL.createObjectURL(e);t=n,r(n)}).catch(()=>a(!0)),()=>{t&&URL.revokeObjectURL(t)}},[e]),i?(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-background/50 px-2 py-1 text-xs text-text-secondary`,children:[(0,U.jsx)(M,{className:`size-3.5 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate max-w-40`,children:t})]}):n?(0,U.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:`block`,children:(0,U.jsx)(`img`,{src:n,alt:t,className:`rounded-md max-h-48 max-w-full object-contain border border-border`})}):(0,U.jsx)(`div`,{className:`rounded-md bg-surface border border-border h-24 w-32 animate-pulse`})}function me({src:e,filename:t,mimeType:n}){let[r,i]=(0,B.useState)(!1);return(0,U.jsxs)(`button`,{type:`button`,onClick:(0,B.useCallback)(async()=>{i(!0);try{let t=d(),r=await fetch(e,{headers:t?{Authorization:`Bearer ${t}`}:{}});if(!r.ok)throw Error(`Failed to load`);let i=await r.blob(),a=URL.createObjectURL(new Blob([i],{type:n}));window.open(a,`_blank`),setTimeout(()=>URL.revokeObjectURL(a),6e4)}catch{window.open(e,`_blank`)}finally{i(!1)}},[e,n]),disabled:r,className:`flex items-center gap-1.5 rounded-md border border-border bg-background/50 px-2 py-1 text-xs text-text-secondary hover:bg-surface hover:text-text-primary transition-colors cursor-pointer disabled:opacity-50`,children:[(0,U.jsx)(g,{className:`size-3.5 shrink-0 text-red-400`}),(0,U.jsx)(`span`,{className:`truncate max-w-40`,children:t}),r&&(0,U.jsx)(`span`,{className:`animate-spin text-[10px]`,children:`...`})]})}function he({events:e,isStreaming:t,projectName:n}){let r=[],i=``;for(let t=0;t<e.length;t++){let n=e[t];n.type===`text`?i+=n.content:n.type===`tool_use`?(i&&=(r.push({kind:`text`,content:i}),``),r.push({kind:`tool`,tool:n})):n.type===`tool_result`||(i&&=(r.push({kind:`text`,content:i}),``),r.push({kind:`tool`,tool:n}))}i&&r.push({kind:`text`,content:i});let a=e.filter(e=>e.type===`tool_result`);for(let e of a){let t=e.toolUseId;if(t){let n=r.find(e=>e.kind===`tool`&&e.tool.type===`tool_use`&&e.tool.toolUseId===t);if(n){n.result=e;continue}}let n=r.find(e=>e.kind===`tool`&&!e.result);n&&(n.result=e)}for(let e=0;e<r.length;e++){let n=r[e];n.kind===`tool`&&!n.result&&(n.completed=e<r.length-1||!t)}return(0,U.jsx)(U.Fragment,{children:r.map((e,i)=>{if(e.kind===`text`){let a=t&&i===r.length-1;return(0,U.jsx)(`div`,{className:`text-sm text-text-primary`,children:(0,U.jsx)(ge,{content:e.content,animate:a,projectName:n})},`text-${i}`)}return(0,U.jsx)(G,{tool:e.tool,result:e.result,completed:e.completed,projectName:n},`tool-${i}`)})})}function ge({content:e,animate:t,projectName:n}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ve,{content:e,projectName:n}),t&&(0,U.jsx)(`span`,{className:`text-text-subtle text-sm animate-pulse`,children:`Thinking...`})]})}function _e({lastMessage:e}){if(!e||e.role!==`assistant`)return(0,U.jsx)(`div`,{className:`flex items-center gap-2 text-text-subtle text-sm`,children:(0,U.jsx)(`span`,{className:`animate-pulse`,children:`Thinking...`})});let t=e.events;if(t&&t.length>0){let e=t[t.length-1];if(e?.type===`tool_use`||e?.type===`tool_result`)return(0,U.jsx)(`div`,{className:`flex items-center gap-2 text-text-subtle text-sm`,children:(0,U.jsx)(`span`,{className:`animate-pulse`,children:`Thinking...`})})}return null}a.setOptions({gfm:!0,breaks:!0});function ve({content:e,projectName:t}){let n=(0,B.useMemo)(()=>{try{return a.parse(e)}catch{return e}},[e]),r=(0,B.useRef)(null),{openTab:i}=S();return(0,B.useEffect)(()=>{let e=r.current;if(!e)return;e.querySelectorAll(`pre`).forEach(e=>{if(e.querySelector(`.code-actions`))return;let n=e.querySelector(`code`),r=n?.textContent??e.textContent??``,a=n?.className??``,o=/language-(bash|sh|shell|zsh)/.test(a)||!a.includes(`language-`)&&r.startsWith(`$`);e.style.position=`relative`;let s=document.createElement(`div`);s.className=`code-actions absolute top-1 right-1 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,e.classList.add(`group`);let c=document.createElement(`button`);if(c.className=`flex items-center justify-center size-6 rounded bg-surface-elevated/80 hover:bg-surface-elevated text-text-secondary hover:text-text-primary transition-colors border border-border/50`,c.title=`Copy`,c.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,c.addEventListener(`click`,()=>{navigator.clipboard.writeText(r),c.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>`,setTimeout(()=>{c.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`},2e3)}),s.appendChild(c),o){let e=document.createElement(`button`);e.className=`flex items-center justify-center size-6 rounded bg-surface-elevated/80 hover:bg-surface-elevated text-text-secondary hover:text-text-primary transition-colors border border-border/50`,e.title=`Run in terminal`,e.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/></svg>`,e.addEventListener(`click`,()=>{navigator.clipboard.writeText(r.replace(/^\$\s*/gm,``)),t&&i({type:`terminal`,title:`Terminal`,metadata:{projectName:t},projectId:t,closable:!0})}),s.appendChild(e)}e.appendChild(s)});let n=n=>{let r=n.target.closest(`a`);if(!r||!e.contains(r))return;let a=r.getAttribute(`href`)??``;(/^(\/|\.\/|\.\.\/)/.test(a)||/\.(ts|tsx|js|jsx|py|json|md|yaml|yml|toml|css|html|sh|go|rs|sql)$/i.test(a))&&t&&(n.preventDefault(),i({type:`editor`,title:a.split(`/`).pop()??a,metadata:{filePath:a,projectName:t},projectId:t,closable:!0}))};return e.addEventListener(`click`,n),()=>e.removeEventListener(`click`,n)},[n,t,i]),(0,U.jsx)(`div`,{ref:r,className:`markdown-content prose-sm`,dangerouslySetInnerHTML:{__html:n}})}function ye({approval:e,onRespond:t}){return(0,U.jsxs)(`div`,{className:`rounded-lg border-2 border-yellow-500/40 bg-yellow-500/10 p-3 space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-yellow-400 text-sm font-medium`,children:[(0,U.jsx)(I,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Tool Approval Required`})]}),(0,U.jsx)(`div`,{className:`text-xs text-text-primary`,children:(0,U.jsx)(`span`,{className:`font-medium`,children:e.tool})}),(0,U.jsx)(`pre`,{className:`text-xs font-mono text-text-secondary overflow-x-auto bg-background rounded p-2 border border-border`,children:JSON.stringify(e.input,null,2)}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`button`,{onClick:()=>t(e.requestId,!0),className:`px-4 py-1.5 rounded bg-green-600 text-white text-xs font-medium hover:bg-green-500 transition-colors`,children:`Allow`}),(0,U.jsx)(`button`,{onClick:()=>t(e.requestId,!1),className:`px-4 py-1.5 rounded bg-red-600 text-white text-xs font-medium hover:bg-red-500 transition-colors`,children:`Deny`})]})]})}function be({approval:e,onRespond:t}){let n=e.input.questions??[],[r,i]=(0,B.useState)({}),[a,o]=(0,B.useState)({}),s=(e,t,n)=>{o(t=>({...t,[e]:!1})),i(r=>{if(!n)return{...r,[e]:t};let i=r[e]??``,a=i?i.split(`, `):[],o=a.indexOf(t);return o>=0?a.splice(o,1):a.push(t),{...r,[e]:a.join(`, `)}})},c=e=>{o(t=>({...t,[e]:!0})),i(t=>({...t,[e]:``}))},l=(e,t)=>{i(n=>({...n,[e]:t}))},u=n.every(e=>r[e.question]?.trim());return(0,U.jsxs)(`div`,{className:`rounded-lg border-2 border-accent/40 bg-accent/5 p-3 space-y-3`,children:[n.map((e,t)=>(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsxs)(`p`,{className:`text-sm text-text-primary font-medium`,children:[e.header?`${e.header}: `:``,e.question]}),e.multiSelect&&(0,U.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Select multiple`}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.options.map((t,n)=>(0,U.jsxs)(`button`,{onClick:()=>s(e.question,t.label,e.multiSelect),className:`text-left rounded px-2.5 py-1.5 text-xs border transition-colors ${!a[e.question]&&(r[e.question]??``).split(`, `).includes(t.label)?`border-accent bg-accent/20 text-text-primary`:`border-border bg-background text-text-secondary hover:bg-surface-elevated`}`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:t.label}),t.description&&(0,U.jsxs)(`span`,{className:`text-text-subtle ml-1.5`,children:[`— `,t.description]})]},n)),a[e.question]?(0,U.jsx)(`input`,{type:`text`,autoFocus:!0,placeholder:`Type your answer...`,value:r[e.question]??``,onChange:t=>l(e.question,t.target.value),className:`rounded px-2.5 py-1.5 text-xs border border-accent bg-accent/10 text-text-primary outline-none placeholder:text-text-subtle`}):(0,U.jsx)(`button`,{onClick:()=>c(e.question),className:`text-left rounded px-2.5 py-1.5 text-xs border border-dashed border-border text-text-subtle hover:bg-surface-elevated transition-colors`,children:`Other — type your own answer`})]})]},t)),(0,U.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,U.jsx)(`button`,{onClick:()=>t(e.requestId,!0,r),disabled:!u,className:`px-4 py-1.5 rounded bg-accent text-white text-xs font-medium hover:bg-accent/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:`Submit`}),(0,U.jsx)(`button`,{onClick:()=>t(e.requestId,!1),className:`px-4 py-1.5 rounded bg-surface-elevated text-text-secondary text-xs hover:bg-surface transition-colors`,children:`Skip`})]})]})}var xe=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]),Se=new Set([`application/pdf`]),Ce=[`text/`,`application/json`,`application/xml`,`application/javascript`,`application/typescript`,`application/x-yaml`,`application/toml`,`application/x-sh`],we=new Set(`.ts,.tsx,.js,.jsx,.mjs,.cjs,.py,.rb,.go,.rs,.java,.kt,.swift,.c,.cpp,.h,.hpp,.cs,.json,.yaml,.yml,.toml,.xml,.md,.mdx,.txt,.csv,.tsv,.html,.css,.scss,.less,.sass,.sh,.bash,.zsh,.fish,.sql,.graphql,.gql,.env,.ini,.cfg,.conf,.dockerfile,.makefile,.vue,.svelte,.astro,.ipynb`.split(`,`));function Te(e){return xe.has(e.type)}function Ee(e){if(xe.has(e.type)||Se.has(e.type)||Ce.some(t=>e.type.startsWith(t)))return!0;let t=De(e.name);return!!(t&&we.has(t))}function De(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t).toLowerCase()}function Oe({attachments:e,onRemove:t}){return e.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-3 pt-2`,children:e.map(e=>(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-surface px-2 py-1 text-xs text-text-secondary max-w-48`,children:[e.previewUrl?(0,U.jsx)(`img`,{src:e.previewUrl,alt:e.name,className:`size-5 rounded object-cover shrink-0`}):e.isImage?(0,U.jsx)(M,{className:`size-3.5 shrink-0 text-text-subtle`}):(0,U.jsx)(g,{className:`size-3.5 shrink-0 text-text-subtle`}),(0,U.jsx)(`span`,{className:`truncate`,children:e.name}),e.status===`uploading`?(0,U.jsx)(v,{className:`size-3 shrink-0 animate-spin text-text-subtle`}):e.status===`error`?(0,U.jsx)(`span`,{className:`text-red-500 shrink-0`,title:`Upload failed`,children:`!`}):null,(0,U.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),className:`shrink-0 rounded-sm p-0.5 hover:bg-border/50 transition-colors`,"aria-label":`Remove ${e.name}`,children:(0,U.jsx)(l,{className:`size-3`})})]},e.id))})}function ke(e){let t=[];function n(e){for(let r of e)t.push(r),r.children&&n(r.children)}return n(e),t}function Ae({items:e,filter:t,onSelect:n,onClose:r,visible:i}){let[a,o]=(0,B.useState)(0),s=(0,B.useRef)(null),c=(()=>{if(!t)return e.slice(0,50);let n=t.toLowerCase();return e.filter(e=>e.path.toLowerCase().includes(n)||e.name.toLowerCase().includes(n)).slice(0,50)})();(0,B.useEffect)(()=>{o(0)},[t]),(0,B.useEffect)(()=>{let e=s.current;e&&e.children[a]?.scrollIntoView({block:`nearest`})},[a]);let l=(0,B.useCallback)(e=>{if(!i||c.length===0)return!1;switch(e.key){case`ArrowUp`:return e.preventDefault(),o(e=>e>0?e-1:c.length-1),!0;case`ArrowDown`:return e.preventDefault(),o(e=>e<c.length-1?e+1:0),!0;case`Enter`:case`Tab`:return e.preventDefault(),c[a]&&n(c[a]),!0;case`Escape`:return e.preventDefault(),r(),!0}return!1},[i,c,a,n,r]);return(0,B.useEffect)(()=>{if(!i)return;let e=e=>{l(e)};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i,l]),!i||c.length===0?null:(0,U.jsx)(`div`,{className:`max-h-52 overflow-y-auto border-b border-border bg-surface`,children:(0,U.jsx)(`div`,{ref:s,className:`py-1`,children:c.map((e,t)=>(0,U.jsxs)(`button`,{className:`flex items-center gap-2 w-full px-3 py-1.5 text-left transition-colors ${t===a?`bg-primary/10 text-primary`:`hover:bg-surface-hover text-text-primary`}`,onMouseEnter:()=>o(t),onClick:()=>n(e),children:[(0,U.jsx)(`span`,{className:`shrink-0`,children:e.type===`directory`?(0,U.jsx)(D,{className:`size-4 text-amber-500`}):(0,U.jsx)(E,{className:`size-4 text-blue-400`})}),(0,U.jsx)(`span`,{className:`text-sm truncate`,children:e.path})]},e.path))})})}function je({onSend:e,isStreaming:t,onCancel:n,disabled:r,projectName:i,onSlashStateChange:a,onSlashItemsLoaded:o,slashSelected:s,onFileStateChange:c,onFileItemsLoaded:l,fileSelected:m,externalFiles:h}){let[g,_]=(0,B.useState)(``),[v,y]=(0,B.useState)([]),b=(0,B.useRef)(null),x=(0,B.useRef)(null),S=(0,B.useRef)([]),C=(0,B.useRef)([]);(0,B.useEffect)(()=>{if(!i){S.current=[],o?.([]);return}p.get(`${f(i)}/chat/slash-items`).then(e=>{S.current=e,o?.(e)}).catch(()=>{S.current=[],o?.([])})},[i]),(0,B.useEffect)(()=>{if(!i){C.current=[],l?.([]);return}p.get(`${f(i)}/files/tree?depth=5`).then(e=>{let t=ke(e);C.current=t,l?.(t)}).catch(()=>{C.current=[],l?.([])})},[i]),(0,B.useEffect)(()=>{if(!s)return;let e=`/${s.name} `;_(e),a?.(!1,``),c?.(!1,``);let t=b.current;t&&(t.focus(),setTimeout(()=>{t.selectionStart=t.selectionEnd=e.length},0))},[s]),(0,B.useEffect)(()=>{if(!m)return;let e=b.current;if(!e)return;let t=e.selectionStart,n=g.slice(0,t),r=g.slice(t),i=n.match(/@(\S*)$/);if(i){let t=n.length-i[0].length;_(n.slice(0,t)+`@${m.path} `+r);let a=t+m.path.length+2;setTimeout(()=>{e.selectionStart=e.selectionEnd=a,e.focus()},0)}else{let t=g+`@${m.path} `;_(t),setTimeout(()=>{e.selectionStart=e.selectionEnd=t.length,e.focus()},0)}c?.(!1,``)},[m]),(0,B.useEffect)(()=>{!h||h.length===0||T(h)},[h]);let w=(0,B.useCallback)(async e=>{if(!i)return null;try{let t=new FormData;t.append(`files`,e);let n={},r=d();r&&(n.Authorization=`Bearer ${r}`);let a=await(await fetch(`${f(i)}/chat/upload`,{method:`POST`,headers:n,body:t})).json();return a.ok&&Array.isArray(a.data)&&a.data.length>0?a.data[0].path:null}catch{return null}},[i]),T=(0,B.useCallback)(e=>{for(let t of e){if(!Ee(t)){_(e=>e+(e.length>0&&!e.endsWith(` `)?` `:``)+t.name);continue}let e=u(),n=Te(t),r=n?URL.createObjectURL(t):void 0,i={id:e,name:t.name,file:t,isImage:n,previewUrl:r,status:`uploading`};y(e=>[...e,i]),w(t).then(t=>{y(n=>n.map(n=>n.id===e?{...n,serverPath:t??void 0,status:t?`ready`:`error`}:n))})}b.current?.focus()},[w]),E=(0,B.useCallback)(e=>{y(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),D=(0,B.useCallback)(()=>{let t=g.trim(),n=v.filter(e=>e.status===`ready`);if(!(!t&&n.length===0)&&!r){a?.(!1,``),c?.(!1,``),e(t,n),_(``);for(let e of v)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);y([]),b.current&&(b.current.style.height=`auto`)}},[g,v,r,e,a,c]),O=(0,B.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),D())},[D]),k=(0,B.useCallback)((e,t)=>{let n=e.match(/^\/(\S*)$/);if(n&&S.current.length>0){a?.(!0,n[1]??``),c?.(!1,``);return}let r=e.slice(0,t).match(/@(\S*)$/);if(r&&C.current.length>0){c?.(!0,r[1]??``),a?.(!1,``);return}a?.(!1,``),c?.(!1,``)},[a,c]),A=(0,B.useCallback)(e=>{_(e),setTimeout(()=>{k(e,b.current?.selectionStart??e.length)},0)},[k]),j=(0,B.useCallback)(()=>{let e=b.current;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,160)+`px`)},[]),M=(0,B.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),T(n))},[T]),N=(0,B.useCallback)(e=>{e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length>0&&T(t)},[T]),I=(0,B.useCallback)(e=>{e.preventDefault()},[]),L=(0,B.useCallback)(()=>{x.current?.click()},[]),ee=(0,B.useCallback)(e=>{let t=Array.from(e.target.files??[]);t.length>0&&T(t),e.target.value=``},[T]),z=g.trim().length>0||v.some(e=>e.status===`ready`),V=t&&!z;return(0,U.jsxs)(`div`,{className:`border-t border-border bg-background`,children:[(0,U.jsx)(Oe,{attachments:v,onRemove:E}),(0,U.jsxs)(`div`,{className:`flex items-end gap-2 p-3`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:L,disabled:r,className:`flex items-center justify-center rounded-lg p-2 text-text-subtle hover:text-text-primary hover:bg-surface transition-colors shrink-0 disabled:opacity-50`,"aria-label":`Attach file`,children:(0,U.jsx)(P,{className:`size-4`})}),(0,U.jsx)(`input`,{ref:x,type:`file`,multiple:!0,className:`hidden`,onChange:ee}),(0,U.jsx)(`textarea`,{ref:b,value:g,onChange:e=>{A(e.target.value),j()},onKeyDown:O,onPaste:M,onDrop:N,onDragOver:I,placeholder:t?`Send follow-up or press Stop...`:`Type / for commands, @ for files, or drop files...`,disabled:r,rows:1,className:`flex-1 resize-none rounded-lg border border-border bg-surface px-3 py-2 text-base md:text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-ring disabled:opacity-50 max-h-40`}),V?(0,U.jsx)(`button`,{onClick:n,className:`flex items-center justify-center rounded-lg bg-red-600 p-2 text-white hover:bg-red-500 transition-colors shrink-0`,"aria-label":`Stop response`,children:(0,U.jsx)(R,{className:`size-4`})}):(0,U.jsx)(`button`,{onClick:D,disabled:r||!z,className:`flex items-center justify-center rounded-lg bg-primary p-2 text-white hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,"aria-label":`Send message`,children:(0,U.jsx)(F,{className:`size-4`})})]})]})}function Me({currentSessionId:e,onSelectSession:t,onNewSession:n,projectName:r}){let[i,a]=(0,B.useState)([]),[o,s]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1),d=(0,B.useCallback)(async()=>{if(r){u(!0);try{a(await p.get(`${f(r)}/chat/sessions`))}catch{}finally{u(!1)}}},[r]);(0,B.useEffect)(()=>{d()},[d]),(0,B.useEffect)(()=>{o&&d()},[o,d]);let h=i.find(t=>t.id===e),g=async(e,t)=>{e.stopPropagation();try{if(!r)return;await p.del(`${f(r)}/chat/sessions/${t.id}?providerId=${t.providerId}`),a(e=>e.filter(e=>e.id!==t.id))}catch{}};return(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsxs)(`button`,{onClick:()=>s(!o),className:`flex items-center gap-1.5 text-sm text-text-secondary hover:text-text-primary transition-colors px-2 py-1 rounded hover:bg-surface-elevated`,children:[(0,U.jsx)(b,{className:`size-3.5`}),(0,U.jsx)(`span`,{className:`truncate max-w-[150px]`,children:h?.title??`Select chat`}),(0,U.jsx)(m,{className:`size-3`})]}),o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>s(!1)}),(0,U.jsxs)(`div`,{className:`absolute bottom-full left-0 mb-1 z-50 w-64 rounded-lg border border-border bg-surface shadow-lg overflow-hidden`,children:[(0,U.jsxs)(`button`,{onClick:()=>{n(),s(!1)},className:`flex items-center gap-2 w-full px-3 py-2 text-sm text-primary hover:bg-surface-elevated transition-colors border-b border-border`,children:[(0,U.jsx)(x,{className:`size-4`}),(0,U.jsx)(`span`,{children:`New Chat`})]}),(0,U.jsxs)(`div`,{className:`max-h-60 overflow-y-auto`,children:[l&&(0,U.jsx)(`p`,{className:`px-3 py-2 text-xs text-text-subtle animate-pulse`,children:`Loading sessions...`}),!l&&i.length===0&&(0,U.jsx)(`p`,{className:`px-3 py-2 text-xs text-text-subtle`,children:`No sessions yet`}),i.map(n=>(0,U.jsxs)(`div`,{onClick:()=>{t(n),s(!1)},className:`flex items-center justify-between px-3 py-2 text-sm cursor-pointer hover:bg-surface-elevated transition-colors ${n.id===e?`bg-surface-elevated text-text-primary`:`text-text-secondary`}`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`truncate text-xs font-medium`,children:n.title}),(0,U.jsx)(`span`,{className:`text-xs text-text-subtle`,children:new Date(n.createdAt).toLocaleDateString()})]}),(0,U.jsx)(`button`,{onClick:e=>g(e,n),className:`p-1 rounded hover:bg-red-500/20 text-text-subtle hover:text-red-400 transition-colors shrink-0`,"aria-label":`Delete session`,children:(0,U.jsx)(c,{className:`size-3`})})]},n.id))]})]})]})]})}function Ne({items:e,filter:t,onSelect:n,onClose:r,visible:i}){let[a,o]=(0,B.useState)(0),s=(0,B.useRef)(null),c=e.filter(e=>{let n=t.toLowerCase();return e.name.toLowerCase().includes(n)||e.description.toLowerCase().includes(n)});(0,B.useEffect)(()=>{o(0)},[t]),(0,B.useEffect)(()=>{let e=s.current;e&&e.children[a]?.scrollIntoView({block:`nearest`})},[a]);let l=(0,B.useCallback)(e=>{if(!i||c.length===0)return!1;switch(e.key){case`ArrowUp`:return e.preventDefault(),o(e=>e>0?e-1:c.length-1),!0;case`ArrowDown`:return e.preventDefault(),o(e=>e<c.length-1?e+1:0),!0;case`Enter`:case`Tab`:return e.preventDefault(),c[a]&&n(c[a]),!0;case`Escape`:return e.preventDefault(),r(),!0}return!1},[i,c,a,n,r]);return(0,B.useEffect)(()=>{if(!i)return;let e=e=>{l(e)};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i,l]),!i||c.length===0?null:(0,U.jsx)(`div`,{className:`max-h-52 overflow-y-auto border-b border-border bg-surface`,children:(0,U.jsx)(`div`,{ref:s,className:`py-1`,children:c.map((e,t)=>(0,U.jsxs)(`button`,{className:`flex items-start gap-3 w-full px-3 py-2 text-left transition-colors ${t===a?`bg-primary/10 text-primary`:`hover:bg-surface-hover text-text-primary`}`,onMouseEnter:()=>o(t),onClick:()=>n(e),children:[(0,U.jsx)(`span`,{className:`shrink-0 mt-0.5`,children:e.type===`skill`?(0,U.jsx)(L,{className:`size-4 text-amber-500`}):(0,U.jsx)(w,{className:`size-4 text-blue-500`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,U.jsxs)(`span`,{className:`font-medium text-sm`,children:[`/`,e.name]}),e.argumentHint&&(0,U.jsx)(`span`,{className:`text-xs text-text-subtle`,children:e.argumentHint}),(0,U.jsx)(`span`,{className:`text-xs text-text-subtle capitalize ml-auto`,children:e.scope===`user`?`global`:e.type})]}),e.description&&(0,U.jsx)(`p`,{className:`text-xs text-text-subtle mt-0.5 line-clamp-2`,children:e.description})]})]},`${e.type}-${e.name}`))})})}function Pe(e){return e>=90?`text-red-500`:e>=70?`text-amber-500`:`text-green-500`}function Fe(e){return e>=90?`bg-red-500`:e>=70?`bg-amber-500`:`bg-green-500`}function Ie({usage:e,onClick:t}){let n=e.fiveHour==null?null:Math.round(e.fiveHour*100),r=e.sevenDay==null?null:Math.round(e.sevenDay*100),i=n==null?`--%`:`${n}%`,a=r==null?`--%`:`${r}%`;return(0,U.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] font-medium tabular-nums transition-colors hover:bg-surface-hover ${n!=null||r!=null?Pe(Math.max(n??0,r??0)):`text-text-subtle`}`,title:`Click for usage details`,children:[(0,U.jsx)(O,{className:`size-3`}),(0,U.jsxs)(`span`,{children:[`5h:`,i]}),(0,U.jsx)(`span`,{className:`text-text-subtle`,children:`·`}),(0,U.jsxs)(`span`,{children:[`Wk:`,a]})]})}function Le(e){if(!e)return null;let t=null;if(e.resetsInMinutes!=null)t=e.resetsInMinutes;else if(e.resetsInHours!=null)t=Math.round(e.resetsInHours*60);else if(e.resetsAt){let n=new Date(e.resetsAt).getTime()-Date.now();t=n>0?Math.ceil(n/6e4):0}if(t==null)return null;if(t<=0)return`now`;let n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?i>0?`${n}d ${r}h ${i}m`:r>0?`${n}d ${r}h`:`${n}d`:r>0?i>0?`${r}h ${i}m`:`${r}h`:`${i}m`}function Re(e){if(!e)return null;switch(e){case`ahead_of_pace`:return{text:`Ahead of pace`,color:`text-green-500`};case`behind_pace`:return{text:`Behind pace`,color:`text-amber-500`};case`on_pace`:return{text:`On pace`,color:`text-text-subtle`};default:return{text:e.replace(/_/g,` `),color:`text-text-subtle`}}}function $({label:e,bucket:t}){if(!t)return null;let n=Math.round(t.utilization*100),r=Le(t),i=Re(t.status);return(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium text-text-primary`,children:e}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&(0,U.jsx)(`span`,{className:`text-[10px] ${i.color}`,children:i.text}),r&&(0,U.jsxs)(`span`,{className:`text-[10px] text-text-subtle`,children:[`↻ `,r]})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`div`,{className:`flex-1 h-2 rounded-full bg-border overflow-hidden`,children:(0,U.jsx)(`div`,{className:`h-full rounded-full transition-all ${Fe(n)}`,style:{width:`${Math.min(n,100)}%`}})}),(0,U.jsxs)(`span`,{className:`text-xs font-medium tabular-nums w-10 text-right ${Pe(n)}`,children:[n,`%`]})]})]})}function ze({usage:e,visible:t,onClose:n,onReload:r,loading:i}){if(!t)return null;let a=e.queryCostUsd!=null||e.totalCostUsd!=null,o=e.session||e.weekly||e.weeklyOpus||e.weeklySonnet;return(0,U.jsxs)(`div`,{className:`border-b border-border bg-surface px-3 py-2.5 space-y-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-xs font-semibold text-text-primary`,children:`Usage Limits`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[r&&(0,U.jsx)(`button`,{onClick:r,disabled:i,className:`text-xs text-text-subtle hover:text-text-primary px-1 disabled:opacity-50`,title:`Refresh usage data`,children:(0,U.jsx)(s,{className:`size-3 ${i?`animate-spin`:``}`})}),(0,U.jsx)(`button`,{onClick:n,className:`text-xs text-text-subtle hover:text-text-primary px-1`,children:`✕`})]})]}),o?(0,U.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,U.jsx)($,{label:`5-Hour Session`,bucket:e.session}),(0,U.jsx)($,{label:`Weekly`,bucket:e.weekly}),(0,U.jsx)($,{label:`Weekly (Opus)`,bucket:e.weeklyOpus}),(0,U.jsx)($,{label:`Weekly (Sonnet)`,bucket:e.weeklySonnet})]}):(0,U.jsxs)(`p`,{className:`text-xs text-text-subtle`,children:[`No data — run `,(0,U.jsx)(`code`,{className:`bg-surface-elevated px-1 rounded`,children:`bun install`})]}),a&&(0,U.jsxs)(`div`,{className:`border-t border-border pt-2 space-y-1`,children:[e.queryCostUsd!=null&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,U.jsx)(`span`,{className:`text-text-subtle`,children:`Last query`}),(0,U.jsxs)(`span`,{className:`text-text-primary font-medium tabular-nums`,children:[`$`,e.queryCostUsd.toFixed(4)]})]}),e.totalCostUsd!=null&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,U.jsx)(`span`,{className:`text-text-subtle`,children:`Session total`}),(0,U.jsxs)(`span`,{className:`text-text-primary font-medium tabular-nums`,children:[`$`,e.totalCostUsd.toFixed(4)]})]})]})]})}function Be({metadata:e,tabId:t}){let[n,r]=(0,B.useState)(e?.sessionId??null),[i,a]=(0,B.useState)(e?.providerId??`claude-sdk`),[o,s]=(0,B.useState)([]),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(``),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)([]),[v,b]=(0,B.useState)(!1),[x,C]=(0,B.useState)(``),[w,T]=(0,B.useState)(null),[E,D]=(0,B.useState)(!1),[O,k]=(0,B.useState)(!1),[A,j]=(0,B.useState)(null),M=(0,B.useRef)(0),N=y(e=>e.activeProject),P=S(e=>e.updateTab);(0,B.useEffect)(()=>{!t||!n||P(t,{metadata:{...e,sessionId:n,providerId:i}})},[n,i]);let{messages:F,messagesLoading:I,isStreaming:L,pendingApproval:R,usageInfo:z,usageLoading:V,sendMessage:H,respondToApproval:te,cancelStreaming:ne,refreshUsage:W,isConnected:G}=re(n,i,N?.name??``),K=(0,B.useCallback)(()=>{let e=N?.name??null;S.getState().openTab({type:`chat`,title:`AI Chat`,metadata:{projectName:e},projectId:e,closable:!0})},[N?.name]),q=(0,B.useCallback)(e=>{r(e.id),a(e.providerId)},[]),J=(0,B.useCallback)((e,t)=>{if(t.length===0)return e;let n=t.filter(e=>e.serverPath).map(e=>e.serverPath).join(`
6
+ `);return n?(t.length===1?`[Attached file: ${n}]\n\n`:`[Attached files:\n${n}\n]\n\n`)+e:e},[]),Y=(0,B.useCallback)(async(t,o=[])=>{let s=J(t,o);if(s.trim()){if(!n)try{let n=N?.name??e?.project??``,o=await p.post(`${f(n)}/chat/sessions`,{providerId:i,title:t.slice(0,50)});r(o.id),a(o.providerId),setTimeout(()=>{H(s)},500);return}catch(e){console.error(`Failed to create session:`,e);return}H(s)}},[n,i,e?.project,H,J,N?.name]),X=(0,B.useCallback)((e,t)=>{l(e),d(t)},[]),Z=(0,B.useCallback)(e=>{h(e),l(!1),d(``),setTimeout(()=>h(null),50)},[]),ie=(0,B.useCallback)(()=>{l(!1),d(``)},[]),Q=(0,B.useCallback)((e,t)=>{b(e),C(t)},[]),oe=(0,B.useCallback)(e=>{T(e),b(!1),C(``),setTimeout(()=>T(null),50)},[]),se=(0,B.useCallback)(()=>{b(!1),C(``)},[]);return(0,U.jsxs)(`div`,{className:`flex flex-col h-full relative`,onDragEnter:(0,B.useCallback)(e=>{e.preventDefault(),M.current++,e.dataTransfer.types.includes(`Files`)&&k(!0)},[]),onDragLeave:(0,B.useCallback)(e=>{e.preventDefault(),M.current--,M.current===0&&k(!1)},[]),onDragOver:(0,B.useCallback)(e=>{e.preventDefault()},[]),onDrop:(0,B.useCallback)(e=>{e.preventDefault(),M.current=0,k(!1);let t=Array.from(e.dataTransfer.files);t.length>0&&(j(t),setTimeout(()=>j(null),100))},[]),children:[O&&(0,U.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm border-2 border-dashed border-primary rounded-lg pointer-events-none`,children:(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-primary`,children:[(0,U.jsx)(ee,{className:`size-8`}),(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Drop files to attach`})]})}),(0,U.jsx)(ae,{messages:F,messagesLoading:I,pendingApproval:R,onApprovalResponse:te,isStreaming:L,projectName:N?.name}),(0,U.jsxs)(`div`,{className:`border-t border-border bg-background shrink-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-border/50`,children:[(0,U.jsx)(Me,{currentSessionId:n,onSelectSession:q,onNewSession:K,projectName:N?.name}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(Ie,{usage:z,onClick:()=>D(e=>!e)}),G&&(0,U.jsx)(`span`,{className:`size-2 rounded-full bg-green-500`,title:`Connected`})]})]}),(0,U.jsx)(ze,{usage:z,visible:E,onClose:()=>D(!1),onReload:W,loading:V}),(0,U.jsx)(Ne,{items:o,filter:u,onSelect:Z,onClose:ie,visible:c}),(0,U.jsx)(Ae,{items:g,filter:x,onSelect:oe,onClose:se,visible:v}),(0,U.jsx)(je,{onSend:Y,isStreaming:L,onCancel:ne,projectName:N?.name,onSlashStateChange:X,onSlashItemsLoaded:s,slashSelected:m,onFileStateChange:Q,onFileItemsLoaded:_,fileSelected:w,externalFiles:A})]})]})}export{Be as ChatTab};