@bendyline/gezel-service 1.0.7 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/dist/bin/gezeld.js +6253 -3616
  2. package/dist/handboek-content/whats-new/1.26224.md +1 -0
  3. package/dist/handboek-content/whats-new/1.26226.md +1 -0
  4. package/dist/handboek-content/whats-new/1.26231.md +1 -0
  5. package/dist/handboek-content/whats-new/1.26234.md +1 -0
  6. package/dist/handboek-content/whats-new/1.26237.md +1 -0
  7. package/dist/handboek-content/whats-new/1.26244.md +2 -1
  8. package/dist/handboek-content/whats-new/1.26247.md +88 -0
  9. package/dist/handboek-content/whats-new/whats-new-index.md +1 -0
  10. package/dist/index-store/static-index-worker.js +17 -1
  11. package/dist/index.d.ts +473 -209
  12. package/dist/index.js +6251 -3614
  13. package/dist/memory/embed-worker.js +58 -2
  14. package/dist/memory/image-embed-worker.js +8 -0
  15. package/dist/providers/llama-cpp/gguf-metadata-worker.js +2 -0
  16. package/dist/providers/mlx/python/gezel_mlx_server.py +18 -18
  17. package/dist/ui/assets/AmbientDashboardCard-Cf5fi_fY.js +1 -0
  18. package/dist/ui/assets/{AudioEngineSettings-BDrNIGGm.js → AudioEngineSettings-D3L7HOHe.js} +1 -1
  19. package/dist/ui/assets/{BenchmarksView-CHyujjs8.js → BenchmarksView-B68hrLCl.js} +1 -1
  20. package/dist/ui/assets/CatalogBrowser-DEM9t7Es.js +1 -0
  21. package/dist/ui/assets/{ChannelsSettings-Be_W1mr8.js → ChannelsSettings-DtK_k0Ul.js} +1 -1
  22. package/dist/ui/assets/ChatTimelineView-CQ4Sf4Ip.js +7 -0
  23. package/dist/ui/assets/ConfirmDialog-Dt1ed4Fh.js +1 -0
  24. package/dist/ui/assets/ConnectedAppsPanel-Cl8LEkrt.js +1 -0
  25. package/dist/ui/assets/CraftbookEditor-DEQRlQ2p.js +1 -0
  26. package/dist/ui/assets/{CraftbookScriptEditorView-DXIZYZT3.js → CraftbookScriptEditorView-DhXkkIdK.js} +1 -1
  27. package/dist/ui/assets/{CraftbookTabContent-Bm7t_b37.js → CraftbookTabContent-_oIdpQTG.js} +1 -1
  28. package/dist/ui/assets/{CraftbookToolsetSetup-DTEA-3K3.js → CraftbookToolsetSetup-BKg136L1.js} +1 -1
  29. package/dist/ui/assets/{CraftbooksView-C4X99TTe.js → CraftbooksView-Dm2zH-nW.js} +2 -2
  30. package/dist/ui/assets/{DiffpackReviewView-ClcNxtmF.js → DiffpackReviewView-EFLGJnwr.js} +1 -1
  31. package/dist/ui/assets/DocumentDetail-ClDRj2N-.js +1 -0
  32. package/dist/ui/assets/DocumentsView-ny9oieg2.js +1 -0
  33. package/dist/ui/assets/DropdownMenu-S4d9-3j3.js +1 -0
  34. package/dist/ui/assets/Ds4Settings-CeWlm5Vf.js +1 -0
  35. package/dist/ui/assets/EmbeddedChat-Hjrrgpao.js +1 -0
  36. package/dist/ui/assets/{FaceRecognitionCard-D3hdc7uU.js → FaceRecognitionCard-D7ufKqjI.js} +1 -1
  37. package/dist/ui/assets/FileMapView-DRjf59RH.js +1 -0
  38. package/dist/ui/assets/{FoldersSettings-BcNzl4vT.js → FoldersSettings-DDUhaFio.js} +1 -1
  39. package/dist/ui/assets/GezelDetail-Cph6pVGb.js +1 -0
  40. package/dist/ui/assets/{GezelJsonEditor-fOvYclu9.js → GezelJsonEditor-7vDGyBib.js} +1 -1
  41. package/dist/ui/assets/{GezellenView-BTzhHrxi.js → GezellenView-DQhcO1CP.js} +1 -1
  42. package/dist/ui/assets/{GildeUpdatesCard-Bq6XEpLP.js → GildeUpdatesCard-UKKNm_U8.js} +1 -1
  43. package/dist/ui/assets/{GithubSignInChip-CnlTCG8G.js → GithubSignInChip-DjM3qZsL.js} +1 -1
  44. package/dist/ui/assets/{HandboekMediaProvider-BfQW8_Nr.js → HandboekMediaProvider-DixaXTAH.js} +1 -1
  45. package/dist/ui/assets/HandboekView-BeNQqho9.js +1 -0
  46. package/dist/ui/assets/HistoryView-E2szGNGS.js +1 -0
  47. package/dist/ui/assets/{HomeView-CB_5TJIp.css → HomeView-CNeqCFPc.css} +1 -1
  48. package/dist/ui/assets/HomeView-CkiS3DXy.js +1 -0
  49. package/dist/ui/assets/{ImageEngineSettings-BpMfQy4f.js → ImageEngineSettings-BCKT7Gvi.js} +1 -1
  50. package/dist/ui/assets/{ImageRecognitionSettings-Ct-7-Oas.js → ImageRecognitionSettings-DD6syFez.js} +1 -1
  51. package/dist/ui/assets/IncompleteDownloads-BiPaaahS.js +1 -0
  52. package/dist/ui/assets/InstallProgressRow-DyKOI4MU.js +1 -0
  53. package/dist/ui/assets/KnowledgeCatalogsCard-B132vzRa.js +1 -0
  54. package/dist/ui/assets/KnowledgeView-CtPuIlN4.js +1 -0
  55. package/dist/ui/assets/LlamaCppSettings-D6zHcu4W.js +1 -0
  56. package/dist/ui/assets/{MarkdownField-D-0Zw7gM.js → MarkdownField-CK8K3fzj.js} +1 -1
  57. package/dist/ui/assets/MemoriesTree-DzjXzIrM.js +1 -0
  58. package/dist/ui/assets/{MicrophoneSettings-BIaFxyY_.js → MicrophoneSettings-1FH83SCq.js} +1 -1
  59. package/dist/ui/assets/MlxSettings-BYxUqFnJ.js +1 -0
  60. package/dist/ui/assets/ModelPicker-DoXPfQkQ.js +1 -0
  61. package/dist/ui/assets/{NewScriptDialog-D-gkY8TS.js → NewScriptDialog-C5X-7PMt.js} +1 -1
  62. package/dist/ui/assets/NewTaskDialog-Cyqtmigv.js +2 -0
  63. package/dist/ui/assets/{OllamaSettings-oIE2Mech.js → OllamaSettings-DkjmA-sB.js} +1 -1
  64. package/dist/ui/assets/ProjectChat-YEqUME6k.js +5 -0
  65. package/dist/ui/assets/{ProjectConnectionsTab-BZqp-oKI.js → ProjectConnectionsTab-dFCJpW93.js} +1 -1
  66. package/dist/ui/assets/ProjectGitStatusBar-CjZxG54t.js +1 -0
  67. package/dist/ui/assets/{ProjectGithubView-w8suLCsA.js → ProjectGithubView-CQ4-tmPx.js} +1 -1
  68. package/dist/ui/assets/{ProjectMailTab-DGo7eyB8.js → ProjectMailTab-NaScsZJf.js} +1 -1
  69. package/dist/ui/assets/ProjectOverviewView-ChjxbQas.js +1 -0
  70. package/dist/ui/assets/{ProjectTimeline-DRe3D9qY.js → ProjectTimeline-BZpdCisR.js} +1 -1
  71. package/dist/ui/assets/ProjectsView-J77ECk6V.js +7 -0
  72. package/dist/ui/assets/{RecommendedBadge-BKiDixnB.js → RecommendedBadge-D0m68PAu.js} +1 -1
  73. package/dist/ui/assets/{RemoteServersPanel-DGyl6-Rg.js → RemoteServersPanel-BdLOoORu.js} +1 -1
  74. package/dist/ui/assets/ScriptEditorTabs-BFvIiDFZ.js +2 -0
  75. package/dist/ui/assets/ScriptEditorView-B09rm1vz.js +5 -0
  76. package/dist/ui/assets/{ScriptsView-WQc28TmQ.js → ScriptsView-BvNAJXpo.js} +1 -1
  77. package/dist/ui/assets/{SecurityComplianceSettings-DsMEA4J3.js → SecurityComplianceSettings-DzGOnptO.js} +1 -1
  78. package/dist/ui/assets/SessionSwitcher-6okzcxT7.js +1 -0
  79. package/dist/ui/assets/SettingsView-Dur4dLhW.js +3 -0
  80. package/dist/ui/assets/SquisqIntegration-6v3yNOIP.js +2 -0
  81. package/dist/ui/assets/{StorageCleanupDialog-DHqwyMZZ.js → StorageCleanupDialog-OQlomMJD.js} +1 -1
  82. package/dist/ui/assets/{StorageUsageCard-CdT6SU51.js → StorageUsageCard-f6c6qTbM.js} +1 -1
  83. package/dist/ui/assets/Tabs-jE0Z5Tzd.js +1 -0
  84. package/dist/ui/assets/TaskTabContent-0w3kAUWR.js +1 -0
  85. package/dist/ui/assets/TasksView-BVMT4BAY.js +1 -0
  86. package/dist/ui/assets/{TerminalCodeEditor-77pBm6f3.js → TerminalCodeEditor-DO7zLKy-.js} +2 -2
  87. package/dist/ui/assets/ToolsetsEditor-Bb1wD5mV.js +8 -0
  88. package/dist/ui/assets/TransformToolbarButton-BWYkEB0d.js +5 -0
  89. package/dist/ui/assets/UnrecognizedModels-HtdMZUqK.js +1 -0
  90. package/dist/ui/assets/{VideoEngineSettings-DzMeINuv.js → VideoEngineSettings-Dq8Nw_tK.js} +1 -1
  91. package/dist/ui/assets/{WorkspaceIndexPane-DU4yd4Ai.js → WorkspaceIndexPane-fpDz4MwZ.js} +1 -1
  92. package/dist/ui/assets/{api-BX5xXiFs.js → api-BPraLwsh.js} +1 -1
  93. package/dist/ui/assets/chat-thread-memory-Be48zsyG.js +1 -0
  94. package/dist/ui/assets/chunk-6ECMNUIP-DDVjPyfK.js +15 -0
  95. package/dist/ui/assets/{chunk-6N2J7C2B-B5QIrD9m.js → chunk-6N2J7C2B-CsppiLVr.js} +1 -1
  96. package/dist/ui/assets/{chunk-A6N6IN3I-DXok09eC.js → chunk-A6N6IN3I-ofeM4l8g.js} +1 -1
  97. package/dist/ui/assets/chunk-B7GEAZBI-Divd2h1k.js +1 -0
  98. package/dist/ui/assets/chunk-DXYWKZ52-BXcAlClu.js +1 -0
  99. package/dist/ui/assets/chunk-FLR2ARKC-D7wrvQgT.js +2 -0
  100. package/dist/ui/assets/chunk-IIQYS2YH-DKZhWMpn.js +1 -0
  101. package/dist/ui/assets/{chunk-ILCJ3WFD-WRukZ7R1.js → chunk-ILCJ3WFD-CLZxw4Ge.js} +3 -3
  102. package/dist/ui/assets/chunk-OBADJV7C-CDVOcmYt.js +1 -0
  103. package/dist/ui/assets/chunk-Q77KNJIN-BIDRf0aP.js +6 -0
  104. package/dist/ui/assets/chunk-S5PCVMKU-Df5XzhSE.js +6 -0
  105. package/dist/ui/assets/chunk-UBFT2CDQ-FexGDigd.js +31 -0
  106. package/dist/ui/assets/{chunk-USU6HTKB-D5FmDzJU.js → chunk-USU6HTKB-B_p-YcDp.js} +1 -1
  107. package/dist/ui/assets/chunk-VKXOZTYP-BoVvWSBR.js +5 -0
  108. package/dist/ui/assets/{chunk-6RQOV3B3-CwvKotJw.js → chunk-VPWPEMZJ-DRKoa_j0.js} +1 -1
  109. package/dist/ui/assets/{chunk-WATAOG4Y-DXg2lov5.js → chunk-WATAOG4Y-C1EXVPmG.js} +1 -1
  110. package/dist/ui/assets/{container-B7jJtK5V.js → container-Ce94efbg.js} +1 -1
  111. package/dist/ui/assets/csv-62UGQMzZ.js +1 -0
  112. package/dist/ui/assets/data-B2kHjlc5.js +1 -0
  113. package/dist/ui/assets/dist-B9-VrAP8.js +2 -0
  114. package/dist/ui/assets/dist-BaHut5iX.js +2 -0
  115. package/dist/ui/assets/dist-BqGwkOe5.js +225 -0
  116. package/dist/ui/assets/dist-ZnIgkoEi.js +4 -0
  117. package/dist/ui/assets/{dist-BHl1ZAVG.js → dist-l6uUFZMV.js} +2 -2
  118. package/dist/ui/assets/dist-pLLFUPO-.js +1 -0
  119. package/dist/ui/assets/{doc-s6H7T0IO.js → doc-Dr5K49bx.js} +28 -28
  120. package/dist/ui/assets/document-companion-BQk2kS0F.js +1 -0
  121. package/dist/ui/assets/document-import-QoM9UxJr.js +1 -0
  122. package/dist/ui/assets/docx-sXa1Rf41.js +2 -0
  123. package/dist/ui/assets/{epub-B98SgHBz.js → epub-RopMP0ec.js} +4 -4
  124. package/dist/ui/assets/{export-options-Bu-tI6og.js → export-options-f7PKjEBb.js} +1 -1
  125. package/dist/ui/assets/extract-UTAOG7LV-4WDRw1o4.js +1 -0
  126. package/dist/ui/assets/file-browser-c2tf4MIb.js +5 -0
  127. package/dist/ui/assets/html-BGVOMhkv.js +253 -0
  128. package/dist/ui/assets/icons-DWaUNQbT.js +1 -0
  129. package/dist/ui/assets/images-JLBFCDD4-6JitW0hD.js +1 -0
  130. package/dist/ui/assets/index-B8NcxqcR.css +1 -0
  131. package/dist/ui/assets/index-C0DYtvfg.js +34 -0
  132. package/dist/ui/assets/index-J8TOMdvV.js +2 -0
  133. package/dist/ui/assets/{infer-kCLH1C8z.js → infer-LEGOsu64.js} +2 -2
  134. package/dist/ui/assets/ironcalc-BAi5gOlE.js +3 -0
  135. package/dist/ui/assets/layouts-2A7QNF6Y-CVwP7noP.js +1 -0
  136. package/dist/ui/assets/{mail-link-CI6YD6k2.js → mail-link-DXkmCd5b.js} +1 -1
  137. package/dist/ui/assets/markdown-baseline-9B52XlX2.js +1 -0
  138. package/dist/ui/assets/{markdown-Bi9b5f5Y.js → markdown-ryKA_OmY.js} +1 -1
  139. package/dist/ui/assets/materialize-A34OZGEU-xNNKzytx.js +1 -0
  140. package/dist/ui/assets/model-inventory-ykSm_IT5.js +1 -0
  141. package/dist/ui/assets/{model-quantization-BDzrELN_.js → model-quantization-CLO7XLoF.js} +1 -1
  142. package/dist/ui/assets/{monaco-base-BiVSa1J-.js → monaco-base-B1H1U1Sw.js} +1 -1
  143. package/dist/ui/assets/{monaco-setup-UeltVkg_.js → monaco-setup-DjhrGQui.js} +1 -1
  144. package/dist/ui/assets/{new-project-meta-0xhggGA_.js → new-project-meta-_f9sfcRX.js} +1 -1
  145. package/dist/ui/assets/outside-in-D73N1g_b.js +3 -0
  146. package/dist/ui/assets/{pdf-DgTjy3rN.js → pdf-BOjVDlCK.js} +3 -3
  147. package/dist/ui/assets/{pending-drafts-YVW6X55O.js → pending-drafts-B11MKQ9R.js} +1 -1
  148. package/dist/ui/assets/{poppetje-Ce-02Aqi.js → poppetje-DLB8uevw.js} +2 -2
  149. package/dist/ui/assets/pptx-BuxyNxQh.js +6 -0
  150. package/dist/ui/assets/primitives-CWrGZpPI.js +41 -0
  151. package/dist/ui/assets/run-export-ChaMXrKS.js +23 -0
  152. package/dist/ui/assets/squisq-formats-aAdypXoy.js +1 -0
  153. package/dist/ui/assets/standalone-source-q_Zzd1bd.js +11 -0
  154. package/dist/ui/assets/storage-D8pE2zg0.js +1 -0
  155. package/dist/ui/assets/styles-BhnF3s2q.css +1 -0
  156. package/dist/ui/assets/styles-CKVKwqoQ.js +550 -0
  157. package/dist/ui/assets/table-fcouR4db.js +1 -0
  158. package/dist/ui/assets/{terminal-monaco-setup-DNoK2tN4.js → terminal-monaco-setup-BAzrVzeR.js} +1 -1
  159. package/dist/ui/assets/{useCompactLayout-BarJPYcv.js → useCompactLayout-Dtolvzye.js} +0 -0
  160. package/dist/ui/assets/{useCopilotAvailability-BH1nLXQI.js → useCopilotAvailability-3xZvKgTF.js} +1 -1
  161. package/dist/ui/assets/{useDiffpacks-CK8W_OD_.js → useDiffpacks-Dsnr0wtX.js} +1 -1
  162. package/dist/ui/assets/{useGitSync-DWxX5-7K.js → useGitSync-BCTptQsp.js} +1 -1
  163. package/dist/ui/assets/{useShowWorkInProgressFeatures-DwwviLRO.js → useShowWorkInProgressFeatures-BhDNuQiU.js} +1 -1
  164. package/dist/ui/assets/{useTotalRamBytes-WoN_mi-V.js → useTotalRamBytes-DIx-_pf8.js} +1 -1
  165. package/dist/ui/assets/wasm-DdxEDD2H.js +1 -0
  166. package/dist/ui/assets/wasm_bg-DW9Xt_vt.wasm +0 -0
  167. package/dist/ui/assets/xlsx-DyBGuAO1.js +4 -0
  168. package/dist/ui/index.html +19 -18
  169. package/package.json +11 -11
  170. package/dist/ui/assets/AmbientDashboardCard-C1Ee-FKZ.js +0 -1
  171. package/dist/ui/assets/CatalogBrowser-Bz8ZtxPn.js +0 -1
  172. package/dist/ui/assets/ChatTimelineView-Do9EryEH.js +0 -7
  173. package/dist/ui/assets/ConfirmDialog-BHFs6vmJ.js +0 -1
  174. package/dist/ui/assets/ConnectedAppsPanel-BtMayq0R.js +0 -1
  175. package/dist/ui/assets/CraftbookEditor-D5jTzWwF.js +0 -1
  176. package/dist/ui/assets/DocumentDetail-CPU51d04.js +0 -1
  177. package/dist/ui/assets/DocumentsView-B6OyjvJ0.js +0 -1
  178. package/dist/ui/assets/DropdownMenu-D5fCzIrh.js +0 -1
  179. package/dist/ui/assets/Ds4Settings-CrUM_KGP.js +0 -1
  180. package/dist/ui/assets/EmbeddedChat-ue9ia-WY.js +0 -1
  181. package/dist/ui/assets/FileMapView-CxvfDLGA.js +0 -1
  182. package/dist/ui/assets/GezelDetail-DHuqBK55.js +0 -1
  183. package/dist/ui/assets/HandboekView-CPnnyj29.js +0 -1
  184. package/dist/ui/assets/HistoryView-B4VAfEMe.js +0 -1
  185. package/dist/ui/assets/HomeView-ccH60J6f.js +0 -1
  186. package/dist/ui/assets/KnowledgeCatalogsCard-Bi5Rx9Iz.js +0 -1
  187. package/dist/ui/assets/KnowledgeView-DAwjwLZo.js +0 -1
  188. package/dist/ui/assets/LlamaCppSettings-Ceyk9pDP.js +0 -1
  189. package/dist/ui/assets/MemoriesTree-BKZEPJpm.js +0 -1
  190. package/dist/ui/assets/MlxSettings-CG3wfuc3.js +0 -1
  191. package/dist/ui/assets/ModelPicker-CCBVjLMS.js +0 -1
  192. package/dist/ui/assets/NewPathDialog-D4jnNBfP.js +0 -1
  193. package/dist/ui/assets/NewTaskDialog-Ox9D612Z.js +0 -2
  194. package/dist/ui/assets/ProjectChat-DMwKnkW-.js +0 -5
  195. package/dist/ui/assets/ProjectGitStatusBar-C6bkCSby.js +0 -1
  196. package/dist/ui/assets/ProjectOverviewView-NNwXd_QQ.js +0 -1
  197. package/dist/ui/assets/ProjectsView-SBPgYOq8.js +0 -7
  198. package/dist/ui/assets/ScriptEditorTabs-paocQ6dj.js +0 -2
  199. package/dist/ui/assets/ScriptEditorView-N9zSLqqi.js +0 -5
  200. package/dist/ui/assets/SessionSwitcher-C8te7YSe.js +0 -1
  201. package/dist/ui/assets/SettingsView-Brl4JQkW.js +0 -3
  202. package/dist/ui/assets/Tabs-BAY1Q79B.js +0 -1
  203. package/dist/ui/assets/TaskTabContent-CNPJ4DQj.js +0 -1
  204. package/dist/ui/assets/TasksView-DuMjFS8S.js +0 -1
  205. package/dist/ui/assets/ToolsetsEditor-BdxHnIBj.js +0 -8
  206. package/dist/ui/assets/TransformToolbarButton-CVg5nz36.js +0 -5
  207. package/dist/ui/assets/UnrecognizedModels-Cw9Ku_bW.js +0 -1
  208. package/dist/ui/assets/chat-thread-memory-CZGcwgGo.js +0 -1
  209. package/dist/ui/assets/chunk-6ECMNUIP-C1kohb1U.js +0 -15
  210. package/dist/ui/assets/chunk-AONELFLA-Cv2nS9ga.js +0 -1
  211. package/dist/ui/assets/chunk-IIQYS2YH-Dxg6MAfT.js +0 -1
  212. package/dist/ui/assets/chunk-MIKKUKOD-XIkmalSN.js +0 -31
  213. package/dist/ui/assets/chunk-NNJLSQPW-DJA6camf.js +0 -5
  214. package/dist/ui/assets/chunk-S5PCVMKU-DbCZ5AUH.js +0 -6
  215. package/dist/ui/assets/csv-xmd1_Aqd.js +0 -4
  216. package/dist/ui/assets/dist-BPx-FyRH.js +0 -222
  217. package/dist/ui/assets/dist-Bvo52IGx.js +0 -1
  218. package/dist/ui/assets/dist-D5aoNQwk.js +0 -2
  219. package/dist/ui/assets/docx-Cj4A9MhC.js +0 -2
  220. package/dist/ui/assets/extract-UTAOG7LV-C4b7ycaL.js +0 -1
  221. package/dist/ui/assets/file-browser-80qWoVju.js +0 -5
  222. package/dist/ui/assets/html-C9TlzI57.js +0 -253
  223. package/dist/ui/assets/icons-C9dD-bDi.js +0 -1
  224. package/dist/ui/assets/images-ESPQKVTW-D7SgdVJ_.js +0 -1
  225. package/dist/ui/assets/index-D1m4Wx8V.css +0 -1
  226. package/dist/ui/assets/index-DXWR4qW1.js +0 -34
  227. package/dist/ui/assets/layouts-2A7QNF6Y-De2t-YXl.js +0 -1
  228. package/dist/ui/assets/markdown-baseline-HMqF2ChK.js +0 -1
  229. package/dist/ui/assets/outside-in-BFVUUcLa.js +0 -3
  230. package/dist/ui/assets/pptx-6ChgUEf4.js +0 -6
  231. package/dist/ui/assets/primitives-DEsn1shf.js +0 -41
  232. package/dist/ui/assets/run-export-BrYhHj1O.js +0 -23
  233. package/dist/ui/assets/standalone-source-D6mbpa3h.js +0 -11
  234. package/dist/ui/assets/storage-fn4FCEVK.js +0 -1
  235. package/dist/ui/assets/styles-C0EoNJbk.css +0 -1
  236. package/dist/ui/assets/styles-CKr_yrbn.js +0 -541
  237. package/dist/ui/assets/xlsx-DH7sTb3W.js +0 -4
@@ -0,0 +1,7 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProjectChat-YEqUME6k.js","assets/rolldown-runtime-aKtaBQYM.js","assets/jsx-runtime-CEpd2cAX.js","assets/dist-BqGwkOe5.js","assets/api-BPraLwsh.js","assets/dist-BaHut5iX.js","assets/primitives-CWrGZpPI.js","assets/react-dom-OL4w_gzs.js","assets/Tabs-jE0Z5Tzd.js","assets/DropdownMenu-S4d9-3j3.js","assets/dist-pLLFUPO-.js","assets/relative-time-B2kBaekd.js","assets/preload-helper-Czpn1I53.js","assets/index-C0DYtvfg.js","assets/document-companion-BQk2kS0F.js","assets/FileTypeIcon-Cwzl1GkZ.js","assets/model-context-DBqdK0PS.js","assets/model-memory-copy-CeuXAj-T.js","assets/StorageCleanupDialog-OQlomMJD.js","assets/poppetje-DLB8uevw.js","assets/safe-svg-image-NbuPaBIv.js","assets/ConfirmDialog-Dt1ed4Fh.js","assets/model-inventory-ykSm_IT5.js","assets/doc-Dr5K49bx.js","assets/chunk-O7JILDEF-CqcO1qaI.js","assets/chunk-BAOV476U-CEOFYt8X.js","assets/chunk-4VOD55SX-BFSSw0c8.js","assets/chunk-GAZKTT4R-BkP6-w3z.js","assets/chunk-UBFT2CDQ-FexGDigd.js","assets/chunk-XRW6P7IF-BeQQgMVK.js","assets/chunk-7ZAAICW4-BsCpYJH6.js","assets/markdown-ryKA_OmY.js","assets/schemas-JY4jmLbC.js","assets/chunk-6ECMNUIP-DDVjPyfK.js","assets/inlineIconMarker-BQI2HLeD.js","assets/chunk-TT6ENR6T-CaYjVwjm.js","assets/chunk-DAMIRKTO-CGniCSiM.js","assets/new-project-meta-_f9sfcRX.js","assets/chunk-AE3IUKMM-mZjzzO8Z.js","assets/index-B8NcxqcR.css","assets/NewTaskDialog-Cyqtmigv.js","assets/GezelJsonEditor-7vDGyBib.js","assets/dist-l6uUFZMV.js","assets/icons-DWaUNQbT.js","assets/CraftbookToolsetSetup-BKg136L1.js","assets/ToolsetConfigForm-gUVMTPR_.js","assets/useShowWorkInProgressFeatures-BhDNuQiU.js","assets/ChatTimelineView-CQ4Sf4Ip.js","assets/styles-CKVKwqoQ.js","assets/chunk-VKXOZTYP-BoVvWSBR.js","assets/chunk-V4NBQF5C-D9I4DV9v.js","assets/storage-D8pE2zg0.js","assets/table-fcouR4db.js","assets/transform-CmAXy0Ck.js","assets/styles-BhnF3s2q.css","assets/SquisqIntegration-6v3yNOIP.js","assets/outside-in-D73N1g_b.js","assets/chunk-7AWFHP5U-MiVVPFTx.js","assets/jszip.min-DhiFe-R7.js","assets/html-BGVOMhkv.js","assets/chunk-BXWNU4T5-CFA9w1DZ.js","assets/chunk-VPWPEMZJ-DRKoa_j0.js","assets/chunk-B7GEAZBI-Divd2h1k.js","assets/chunk-KXOZMWBS-BwD4KMLI.js","assets/document-import-QoM9UxJr.js","assets/microphone-input-5gqW_NKf.js","assets/composer-prefill-CbG_i1Rx.js","assets/SessionSwitcher-6okzcxT7.js","assets/ProjectTimeline-BZpdCisR.js","assets/chat-thread-memory-Be48zsyG.js","assets/useCompactLayout-Dtolvzye.js","assets/GitDiffView-DrDrSeBb.js","assets/gitCopy-Dcjz17cJ.js","assets/completion-data--97asQiQ.js","assets/ProjectConnectionsTab-dFCJpW93.js","assets/ProjectMailTab-NaScsZJf.js","assets/mail-link-DXkmCd5b.js","assets/DiffpackReviewView-EFLGJnwr.js","assets/MarkdownField-CK8K3fzj.js","assets/useDiffpacks-Dsnr0wtX.js","assets/FileMapView-DRjf59RH.js","assets/HistoryView-E2szGNGS.js","assets/ProjectGithubView-CQ4-tmPx.js","assets/useGitSync-BCTptQsp.js","assets/GithubSignInChip-DjM3qZsL.js","assets/ProjectOverviewView-ChjxbQas.js","assets/WorkspaceIndexPane-fpDz4MwZ.js","assets/TasksView-BVMT4BAY.js","assets/TaskTabContent-0w3kAUWR.js","assets/TransformToolbarButton-BWYkEB0d.js","assets/pending-drafts-B11MKQ9R.js","assets/NewScriptDialog-C5X-7PMt.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{At as r,Et as i,F as a,Ht as o,Lt as s,S as c,V as l,Vt as u,an as d,ct as f,et as p,ht as m,on as h,qt as g,vt as _,xt as v,yn as y,zt as ee}from"./dist-BqGwkOe5.js";import{t as b}from"./dist-BaHut5iX.js";import{t as x}from"./api-BPraLwsh.js";import{i as S,n as C,r as w}from"./Tabs-jE0Z5Tzd.js";import{G as T,H as E,J as te,K as ne,W as re,Y as ie,d as ae,l as oe,m as se,p as ce,q as le,s as ue,y as D}from"./primitives-CWrGZpPI.js";import{S as O,_ as de,b as fe,g as pe,h as me,l as he,m as ge,n as k,p as _e,t as A,v as ve,w as ye,y as be}from"./document-companion-BQk2kS0F.js";import{t as j}from"./poppetje-DLB8uevw.js";import{n as xe,t as M}from"./relative-time-B2kBaekd.js";import{t as Se}from"./ConfirmDialog-Dt1ed4Fh.js";import{t as N}from"./preload-helper-Czpn1I53.js";import{i as Ce,n as P}from"./styles-CKVKwqoQ.js";import{t as F}from"./GezelJsonEditor-7vDGyBib.js";import{a as I,i as we,n as L,o as Te,r as Ee,t as De}from"./new-project-meta-_f9sfcRX.js";import{C as Oe,It as R,U as ke,Y as z,Z as Ae,a as je,d as Me,ht as Ne,l as Pe,lt as Fe,n as Ie,t as Le,u as Re,x as ze,z as Be}from"./index-C0DYtvfg.js";import"./storage-D8pE2zg0.js";import"./provider-default-BLsHrgzI.js";import{a as Ve,c as He,i as Ue,o as We,r as Ge}from"./SquisqIntegration-6v3yNOIP.js";import{t as Ke}from"./useShowWorkInProgressFeatures-BhDNuQiU.js";import{c as qe,d as Je,f as B,h as V,i as Ye,l as Xe,m as H,o as Ze,p as U,r as Qe,s as $e,t as et,u as tt}from"./file-browser-c2tf4MIb.js";import{a as nt,c as rt,d as it,l as at,n as ot,o as st,r as ct,s as lt,t as ut,u as dt}from"./outside-in-D73N1g_b.js";import{n as ft}from"./composer-prefill-CbG_i1Rx.js";import{n as pt,r as W,t as mt}from"./useCompactLayout-Dtolvzye.js";import{n as ht,r as gt}from"./mail-link-DXkmCd5b.js";import{t as _t}from"./ToolsetsEditor-Bb1wD5mV.js";import{t as vt}from"./useDiffpacks-Dsnr0wtX.js";import{i as yt,n as bt,o as xt,r as St,t as Ct}from"./WorkspaceIndexPane-fpDz4MwZ.js";import{n as wt}from"./MemoriesTree-DzjXzIrM.js";import{t as Tt}from"./ProjectGitStatusBar-CjZxG54t.js";import{t as Et}from"./markdown-baseline-9B52XlX2.js";import{n as Dt,t as Ot}from"./TransformToolbarButton-BWYkEB0d.js";import{t as kt}from"./GithubSignInChip-DjM3qZsL.js";var G=e(t(),1),K=n(),At=`__GEZEL_PICKER_NONE__`;function jt({gezels:e,value:t,onValueChange:n,noneLabel:r,placeholder:i=`Select a gezel…`,ariaLabel:a,disabled:o,className:s}){let c=Oe(),l=e.find(e=>e.id===t),u=[`gezel-picker-trigger`,s].filter(Boolean).join(` `);return(0,K.jsxs)(ae,{value:l?.id??At,disabled:o,onValueChange:e=>n(e===At?null:e),children:[(0,K.jsx)(ce,{className:u,"aria-label":a,children:(0,K.jsx)(se,{children:l?(0,K.jsx)(Mt,{gezel:l,roleBasedNameOnly:c}):(0,K.jsx)(`span`,{className:`gezel-picker-empty`,children:r??i})})}),(0,K.jsxs)(ue,{className:`gezel-picker-menu`,children:[r&&(0,K.jsx)(oe,{value:At,children:r}),e.map(e=>(0,K.jsx)(oe,{value:e.id,textValue:Nt(e,c),children:(0,K.jsx)(Mt,{gezel:e,roleBasedNameOnly:c})},e.id))]})]})}function Mt({gezel:e,roleBasedNameOnly:t}){let n=l(e,t);return(0,K.jsxs)(`span`,{className:`gezel-picker-option`,children:[(0,K.jsx)(R,{svg:e.icon??null,poppetje:e.poppetje,iconOverride:e.iconOverride,name:n,size:26}),(0,K.jsxs)(`span`,{className:`gezel-picker-option-text`,children:[(0,K.jsx)(`span`,{className:`gezel-picker-option-name`,children:n}),!t&&e.role&&(0,K.jsxs)(`span`,{className:`gezel-picker-option-role`,children:[`— `,e.role]})]})]})}function Nt(e,t){let n=l(e,t);return!t&&e.role?`${n} — ${e.role}`:n}function Pt(e){return e?.leadLabel?e.leadLabel:e?.mode===`solo`?`Builder`:`Voorman`}function Ft(e){return e?.leadLabel?e.leadLabel.toLowerCase():e?.mode===`solo`?`builder`:`voorman`}function It(){return Math.floor(Math.random()*2147483647)}function Lt(e){return e.manifest.kind===`gezel-template`}function q(e){return(e??``).toLocaleLowerCase().replaceAll(/[^a-z0-9]+/g,``)}function Rt(e,t,n){return[l(e,n),e.role??``].some(e=>e.toLocaleLowerCase().includes(t))}function zt(e,t){return[e.manifest.name,e.manifest.role,e.manifest.description,...e.manifest.tags].some(e=>e.toLocaleLowerCase().includes(t))}function Bt({open:e,project:t,gezels:n,roleBasedNameOnlyMode:r,onClose:i,onAddExisting:a,onCreateTemplate:o}){let[c,u]=(0,G.useState)([]),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(null),[b,S]=(0,G.useState)(``),[C,w]=(0,G.useState)(null),[ae,oe]=(0,G.useState)(``),[se,ce]=(0,G.useState)(),[ue,D]=(0,G.useState)(It),O=p(d(t));(0,G.useEffect)(()=>{if(!e)return;let t=!1;return h(!0),y(null),S(``),w(null),x.listCatalogItems(`gezel-template`).then(({items:e})=>{if(t)return;let n=new Map;for(let t of e)Lt(t)&&!n.has(t.manifest.id)&&n.set(t.manifest.id,t);u([...n.values()])}).catch(e=>{t||y(e.message)}).finally(()=>{t||h(!1)}),()=>{t=!0}},[e]);let de=(0,G.useMemo)(()=>new Set([...t.gezelIds??[],...t.voormanGezelId?[t.voormanGezelId]:[]]),[t.gezelIds,t.voormanGezelId]),fe=(0,G.useMemo)(()=>{let e=new Map,t=0;for(let n of O?.gezelRoles.default??[])e.set(n.templateId,{...n,tier:`default`,rank:t++});for(let n of O?.gezelRoles.suggested??[])e.has(n.templateId)||e.set(n.templateId,{...n,tier:`suggested`,rank:t++});return e},[O]),pe=(0,G.useMemo)(()=>{let e=new Map;for(let t of c){let n=fe.get(t.manifest.id);if(n)for(let r of[q(t.manifest.role),q(t.manifest.name)])r&&!e.has(r)&&e.set(r,n)}return e},[fe,c]),me=(0,G.useMemo)(()=>new Set(n.flatMap(e=>e.templateId?[e.templateId]:[])),[n]),he=(0,G.useMemo)(()=>new Set(n.flatMap(e=>[e.role,e.roleBasedName].map(q).filter(Boolean))),[n]),ge=(0,G.useMemo)(()=>n.filter(e=>!de.has(e.id)&&e.scope!==`project`).sort((e,t)=>l(e,r).localeCompare(l(t,r))),[de,n,r]),k=(0,G.useMemo)(()=>c.filter(e=>!me.has(e.manifest.id)&&!he.has(q(e.manifest.role))&&!he.has(q(e.manifest.name))).sort((e,t)=>e.manifest.name.localeCompare(t.manifest.name)),[he,me,c]),_e=(0,G.useCallback)(e=>{if(e.templateId){let t=fe.get(e.templateId);if(t)return t}for(let t of[q(e.role),q(e.roleBasedName)]){let e=pe.get(t);if(e)return e}},[pe,fe]),A=(0,G.useMemo)(()=>{let e=[];for(let t of ge){let n=_e(t);n&&e.push({kind:`existing`,gezel:t,affinity:n})}for(let t of k){let n=fe.get(t.manifest.id);n&&e.push({kind:`template`,template:t,affinity:n})}return e.sort((e,t)=>e.affinity.rank-t.affinity.rank||(e.kind===`existing`?l(e.gezel,r):e.template.manifest.name).localeCompare(t.kind===`existing`?l(t.gezel,r):t.template.manifest.name))},[_e,ge,k,fe,r]),ve=(0,G.useMemo)(()=>new Set(A.flatMap(e=>e.kind===`existing`?[e.gezel.id]:[])),[A]),ye=(0,G.useMemo)(()=>new Set(A.flatMap(e=>e.kind===`template`?[e.template.manifest.id]:[])),[A]),be=(0,G.useMemo)(()=>ge.filter(e=>!ve.has(e.id)),[ge,ve]),xe=(0,G.useMemo)(()=>k.filter(e=>!ye.has(e.manifest.id)),[k,ye]),M=b.trim().toLocaleLowerCase(),Se=(0,G.useMemo)(()=>M?A.filter(e=>e.kind===`existing`?Rt(e.gezel,M,r):zt(e.template,M)):A,[M,r,A]),N=(0,G.useMemo)(()=>M?be.filter(e=>Rt(e,M,r)):be,[M,be,r]),Ce=(0,G.useMemo)(()=>M?xe.filter(e=>zt(e,M)):xe,[M,xe]),P=()=>{g||i()},F=async e=>{_(!0),y(null);try{await a(e),i()}catch(e){y(e.message)}finally{_(!1)}},I=async(e,t)=>{_(!0),y(null);try{await o(e.manifest.id,t),i()}catch(e){y(e.message)}finally{_(!1)}},we=e=>{if(r){I(e,{name:e.manifest.name});return}let t=s(),n=e.manifest.nameSuggestions??[],i=n.length>0?n[Math.floor(Math.random()*n.length)]:t.name;w(e),oe(i??t.name),ce(t.gender),D(It()),y(null)},L=C&&ae.trim()?ee(ue,{key:`project-add-preview:${C.manifest.id}`,name:ae.trim(),gender:se}):null;return(0,K.jsx)(te,{open:e,onOpenChange:e=>!e&&P(),children:(0,K.jsxs)(le,{children:[(0,K.jsx)(ne,{}),(0,K.jsxs)(re,{className:`project-add-gezel-dialog`,children:[(0,K.jsx)(ie,{asChild:!0,children:(0,K.jsx)(`h3`,{children:C?`Customize ${C.manifest.name}`:`Add Gezel`})}),(0,K.jsx)(T,{className:`muted small`,children:C?`Give this new ${C.manifest.role} a name and appearance before adding them to ${t.name}.`:`Choose someone from your workshop or add a new role to ${t.name}.`}),v&&(0,K.jsx)(`p`,{className:`error small project-add-gezel-error`,children:v}),C?(0,K.jsxs)(`form`,{className:`project-add-gezel-customize`,onSubmit:e=>{e.preventDefault(),ae.trim()&&I(C,{name:ae.trim(),...se?{gender:se}:{},appearanceSeed:ue})},children:[(0,K.jsx)(`div`,{className:`project-add-gezel-preview`,"aria-hidden":`true`,children:L&&(0,K.jsx)(j,{poppetje:L,variant:`full`,size:150,grainStyle:`wavy`})}),(0,K.jsxs)(`div`,{className:`project-add-gezel-customize-fields`,children:[(0,K.jsxs)(`label`,{children:[`Name`,(0,K.jsx)(`input`,{type:`text`,value:ae,onChange:e=>oe(e.target.value),disabled:g})]}),(0,K.jsx)(`button`,{type:`button`,className:`subtle`,disabled:g,onClick:()=>D(It()),children:`Reroll appearance`}),(0,K.jsxs)(`p`,{className:`muted small`,children:[`Their role and working style come from the `,C.manifest.name,` `,`template.`]})]}),(0,K.jsxs)(E,{children:[(0,K.jsx)(`button`,{type:`button`,disabled:g,onClick:()=>{w(null),y(null)},children:`Back`}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:g||!ae.trim(),children:g?`Adding…`:`Add to project`})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{className:`project-add-gezel-search`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Search gezels and roles`}),(0,K.jsx)(`input`,{type:`text`,placeholder:`Search gezels and roles…`,value:b,onChange:e=>S(e.target.value),disabled:g})]}),(0,K.jsxs)(`div`,{className:`project-add-gezel-options`,children:[Se.length>0&&(0,K.jsxs)(`section`,{className:`project-add-gezel-suggestions`,"aria-labelledby":`project-add-suggested-title`,children:[(0,K.jsx)(`h4`,{id:`project-add-suggested-title`,children:`Suggested for this project type`}),O&&(0,K.jsxs)(`p`,{className:`muted small project-add-gezel-section-hint`,children:[O.label,` projects often benefit from these roles.`]}),(0,K.jsx)(`ul`,{className:`project-add-gezel-list`,children:Se.map(e=>{let t=e.affinity.tier==="default"?`Core role`:`Suggested`;if(e.kind===`existing`){let n=l(e.gezel,r);return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:`project-add-gezel-option`,disabled:g,onClick:()=>void F(e.gezel.id),children:[(0,K.jsx)(R,{svg:e.gezel.icon??null,poppetje:e.gezel.poppetje,iconOverride:e.gezel.iconOverride,name:n,size:36}),(0,K.jsxs)(`span`,{className:`project-add-gezel-option-copy`,children:[(0,K.jsx)(`span`,{className:`project-add-gezel-option-name`,children:n}),(0,K.jsxs)(`span`,{className:`muted small`,children:[e.gezel.role??`Gezel`,` · `,e.affinity.reason]})]}),(0,K.jsx)(`span`,{className:`gz-badge`,children:t})]})},`existing:${e.gezel.id}`)}return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:`project-add-gezel-option`,disabled:g,onClick:()=>we(e.template),children:[(0,K.jsx)(R,{poppetje:f(`project-role:${e.template.manifest.id}`,e.template.manifest.name),name:e.template.manifest.name,size:36}),(0,K.jsxs)(`span`,{className:`project-add-gezel-option-copy`,children:[(0,K.jsx)(`span`,{className:`project-add-gezel-option-name`,children:e.template.manifest.name}),(0,K.jsx)(`span`,{className:`muted small`,children:e.affinity.reason})]}),(0,K.jsx)(`span`,{className:`gz-badge`,children:t})]})},`template:${e.template.manifest.id}`)})})]}),(0,K.jsxs)(`section`,{"aria-labelledby":`project-add-existing-title`,children:[(0,K.jsx)(`h4`,{id:`project-add-existing-title`,children:`From your workshop`}),N.length>0?(0,K.jsx)(`ul`,{className:`project-add-gezel-list`,children:N.map(e=>{let t=l(e,r);return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:`project-add-gezel-option`,disabled:g,onClick:()=>void F(e.id),children:[(0,K.jsx)(R,{svg:e.icon??null,poppetje:e.poppetje,iconOverride:e.iconOverride,name:t,size:36}),(0,K.jsxs)(`span`,{className:`project-add-gezel-option-copy`,children:[(0,K.jsx)(`span`,{className:`project-add-gezel-option-name`,children:t}),(0,K.jsxs)(`span`,{className:`muted small`,children:[e.role??`Gezel`,` · ready to add`]})]})]})},e.id)})}):(0,K.jsx)(`p`,{className:`muted small project-add-gezel-empty`,children:be.length>0?`No workshop gezels match that search.`:A.some(e=>e.kind===`existing`)?`No other workshop gezels are available.`:`Every available gezel is already on this project.`})]}),(0,K.jsxs)(`section`,{"aria-labelledby":`project-add-role-title`,children:[(0,K.jsx)(`h4`,{id:`project-add-role-title`,children:`Add a new gezel for a role`}),m&&(0,K.jsx)(`p`,{className:`muted small`,children:`Loading roles…`}),!m&&Ce.length>0?(0,K.jsx)(`ul`,{className:`project-add-gezel-list`,children:Ce.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:`project-add-gezel-option`,disabled:g,onClick:()=>we(e),children:[(0,K.jsx)(R,{poppetje:f(`project-role:${e.manifest.id}`,e.manifest.name),name:e.manifest.name,size:36}),(0,K.jsxs)(`span`,{className:`project-add-gezel-option-copy`,children:[(0,K.jsx)(`span`,{className:`project-add-gezel-option-name`,children:e.manifest.name}),(0,K.jsx)(`span`,{className:`muted small`,children:e.manifest.description})]}),(0,K.jsx)(`span`,{className:`gz-badge`,children:`New role`})]})},e.manifest.id))}):!m&&(0,K.jsx)(`p`,{className:`muted small project-add-gezel-empty`,children:xe.length>0?`No new roles match that search.`:A.some(e=>e.kind===`template`)?`No other role types are available.`:`Every role type already has a gezel.`})]})]}),(0,K.jsx)(E,{children:(0,K.jsx)(`button`,{type:`button`,onClick:P,disabled:g,children:`Cancel`})})]})]})]})})}function Vt({projectId:e,projectProperties:t,refreshKey:n,recentlyAddedGezelId:r}){let[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(!1),m=(0,G.useCallback)(async()=>{try{let t=await x.listSuggestedWork(e);a(t.items)}catch(e){l(e.message)}},[e]);(0,G.useEffect)(()=>{m()},[m,n]);let h=async(e,t)=>{s(e),l(null);try{await t(),await m()}catch(e){l(e.message)}finally{s(null)}},g=async(t,n)=>{d(null),await h(t.key,async()=>{await x.enableSuggestedWork(e,{key:t.key,...n?{params:n}:{}});let r=Gt(t,n);r&&await x.updateProject(e,{properties:r})})};if(i===null)return c?(0,K.jsx)(`p`,{className:`error small suggested-work-error`,children:c}):null;let _=i.filter(e=>e.state!==`dismissed`),v=i.filter(e=>e.state===`dismissed`);return i.length===0?null:(0,K.jsxs)(`div`,{className:`suggested-work`,children:[_.map(n=>(0,K.jsx)(Ht,{item:n,busy:o===n.key,flash:n.state===`suggested`&&n.source.kind===`gezel-template`&&n.source.gezelId!==void 0&&n.source.gezelId===r,paramFormOpen:u===n.key,projectProperties:t,onEnable:e=>void g(n,e),onOpenParamForm:()=>d(n.key),onCloseParamForm:()=>d(null),onDisable:()=>void h(n.key,()=>x.disableSuggestedWork(e,n.key)),onDismiss:()=>void h(n.key,()=>x.dismissSuggestedWork(e,n.key,!0))},n.key)),v.length>0&&(0,K.jsxs)(`div`,{className:`suggested-work-hidden`,children:[(0,K.jsx)(`button`,{type:`button`,className:`subtle small`,onClick:()=>p(e=>!e),children:f?`Hide dismissed suggestions`:`${v.length} hidden suggestion${v.length===1?``:`s`}`}),f&&v.map(t=>(0,K.jsxs)(`div`,{className:`project-autonomous-role suggested-work-row`,children:[(0,K.jsxs)(`div`,{className:`project-autonomous-role-copy`,children:[(0,K.jsx)(`span`,{className:`project-autonomous-role-title`,children:t.craftbookName??t.craftbookId}),(0,K.jsx)(`span`,{className:`muted small`,children:`Hidden from suggestions.`})]}),(0,K.jsx)(`button`,{type:`button`,className:`subtle`,disabled:o===t.key,onClick:()=>void h(t.key,()=>x.dismissSuggestedWork(e,t.key,!1)),children:`Suggest again`})]},t.key))]}),c&&(0,K.jsx)(`p`,{className:`error small suggested-work-error`,children:c})]})}function Ht({item:e,busy:t,flash:n,paramFormOpen:r,projectProperties:i,onEnable:a,onOpenParamForm:o,onCloseParamForm:s,onDisable:c,onDismiss:l}){let u=e.state===`enabled`,d=Wt(e),f=e.runMode===`night-shift`?`Runs during the Night Shift window, at most once per night.`:`Runs on schedule (cron ${e.cron}, UTC).`,p=e.source.kind===`gezel-template`?e.source.gezelName?`Suggested by ${e.source.gezelName}${e.source.role?` — ${e.source.role}`:``}.`:`Suggested by the "${e.source.templateId}" role.`:`From the "${e.source.typeId}" project type.`,m=e.pendingQuestionId?` Awaiting approval — enabling here answers the pending question.`:e.orphaned?` The sponsoring role is no longer on this crew.`:``;return(0,K.jsxs)(`div`,{className:`project-autonomous-role suggested-work-row${u?` project-autonomous-role-active`:``}${n?` timeline-focus-flash`:``}`,children:[(0,K.jsx)(`span`,{className:`suggested-work-glyph`,"aria-hidden":`true`,children:e.runMode===`night-shift`?(0,K.jsx)(Kt,{}):(0,K.jsx)(qt,{})}),(0,K.jsxs)(`div`,{className:`project-autonomous-role-copy`,children:[(0,K.jsxs)(`span`,{className:`project-autonomous-role-title`,children:[e.craftbookName??e.craftbookId,` `,u?`on`:`off`]}),(0,K.jsxs)(`span`,{className:`muted small`,children:[e.reason?`${e.reason} `:``,f,` `,p,m]}),r&&(0,K.jsx)(Ut,{item:e,projectProperties:i,onSubmit:a,onCancel:s})]}),(0,K.jsxs)(`div`,{className:`suggested-work-actions`,children:[u?(0,K.jsx)(`button`,{type:`button`,className:`subtle`,disabled:t,onClick:c,children:t?`Updating…`:`Pause`}):(0,K.jsx)(`button`,{type:`button`,className:`subtle`,disabled:t||r,onClick:()=>d&&e.state===`suggested`?o():a(),children:t?`Updating…`:e.state===`paused`?`Resume`:`Enable`}),e.state===`suggested`&&(0,K.jsx)(`button`,{type:`button`,className:`subtle small suggested-work-dismiss`,disabled:t,onClick:l,title:`Don't suggest this for this project`,children:`Don't suggest`})]})]})}function Ut({item:e,projectProperties:t,onSubmit:n,onCancel:i}){let a=e.paramSchema,[o,s]=(0,G.useState)(()=>{let n={},i=a?.properties??{};for(let[a,o]of Object.entries(i)){let i=r(o),s=i?t?.[i]:void 0,c=Fe(o);s===void 0?e.params?.[a]===void 0?c!==void 0&&(n[a]=c):n[a]=e.params[a]:n[a]=s}return n}),c=(0,G.useMemo)(()=>{let e={};for(let[t,n]of Object.entries(o))n!=null&&(typeof n==`boolean`?e[t]=n?`true`:`false`:typeof n==`number`?e[t]=String(n):typeof n==`string`&&(e[t]=n));return e},[o]);return(0,K.jsxs)(`form`,{className:`suggested-work-param-form`,onSubmit:e=>{e.preventDefault(),n(c)},children:[a&&(0,K.jsx)(F,{schema:a,value:o,onChange:e=>s(e??{}),density:`compact`}),(0,K.jsxs)(`div`,{className:`suggested-work-param-actions`,children:[(0,K.jsx)(`button`,{type:`button`,className:`subtle`,onClick:i,children:`Cancel`}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,children:`Enable`})]})]})}function Wt(e){let t=e.paramSchema?.properties;return!!(t&&Object.keys(t).length>0)}function Gt(e,t){if(!t)return null;let n=e.paramSchema?.properties??{},i={};for(let[e,a]of Object.entries(n)){let n=r(a),o=t[e];n&&o!==void 0&&o!==``&&(i[n]=o)}return Object.keys(i).length>0?i:null}function Kt(){return(0,K.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M12 3a9 9 0 1 0 9 9c0-.46-.04-.92-.1-1.36a5.39 5.39 0 0 1-8.54-6.5A8.97 8.97 0 0 0 12 3z`})})}function qt(){return(0,K.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,K.jsx)(`path`,{d:`M12 7v5l3 2`})]})}function Jt({project:e,gezels:t,boekwachterGezelId:n,recentlyAddedGezelId:r,onAddGezel:i,onCreateTemplateGezel:a,onRemoveGezel:o}){let s=Oe(),[c,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(null),h=(0,G.useMemo)(()=>{let n=new Set,r=[];if(e.voormanGezelId){let i=t.find(t=>t.id===e.voormanGezelId);i&&(r.push({gezel:i,isLead:!0}),n.add(i.id))}for(let i of e.gezelIds??[]){if(n.has(i))continue;let e=t.find(e=>e.id===i);e&&(r.push({gezel:e,isLead:!1}),n.add(i))}return r},[t,e.gezelIds,e.voormanGezelId]),g=n?t.find(e=>e.id===n):void 0,_=t.find(t=>(e.gezelIds??[]).includes(t.id)&&(t.id===n||t.templateId===`boekwachter`||t.role?.trim().toLocaleLowerCase()===`boekwachter`)),v=async e=>{let t=e===`add`?g:_,n=e===`add`?i:o;if(!(!t||!n)){f(!0),m(null);try{await n(t.id)}catch(e){m(e.message)}finally{f(!1)}}};return(0,K.jsxs)(`section`,{id:`project-about-crew`,className:`project-crew-settings project-about-anchor`,"aria-labelledby":`project-crew-settings-title`,children:[(0,K.jsxs)(`div`,{className:`project-crew-settings-heading`,children:[(0,K.jsx)(`h3`,{id:`project-crew-settings-title`,className:`project-crew-settings-title`,children:`Assigned gezellen`}),i&&a&&(0,K.jsx)(`button`,{type:`button`,className:`primary project-crew-add`,onClick:()=>u(!0),children:`Add Gezel`})]}),(0,K.jsx)(`p`,{className:`muted small project-crew-settings-hint`,children:`The crew attached to this project. Change the lead below; task and conversation assignments are added automatically.`}),h.length>0?(0,K.jsx)(`ul`,{className:`project-crew-list`,children:h.map(({gezel:t,isLead:n})=>{let r=l({name:t.name,roleBasedName:t.roleBasedName},s),i=n?`⭐ ${Ft(e)}`:t.role;return(0,K.jsxs)(`li`,{className:`project-crew-card${n?` project-crew-card-lead`:``}`,children:[(0,K.jsx)(R,{svg:t.icon??null,poppetje:t.poppetje,iconOverride:t.iconOverride,name:r,size:30}),(0,K.jsxs)(`span`,{className:`project-crew-card-text`,children:[(0,K.jsx)(`span`,{className:`project-crew-card-name`,children:r}),i&&(0,K.jsx)(`span`,{className:`project-crew-card-role`,children:i})]})]},t.id)})}):(0,K.jsx)(`p`,{className:`muted small project-crew-empty`,children:`No gezellen are assigned to this project yet.`}),(0,K.jsxs)(`div`,{className:`project-autonomous-role${_?` project-autonomous-role-active`:``}`,children:[(0,K.jsxs)(`div`,{className:`project-autonomous-role-copy`,children:[(0,K.jsxs)(`span`,{className:`project-autonomous-role-title`,children:[`AI indexing `,_?`on`:`off`]}),(0,K.jsx)(`span`,{className:`muted small`,children:_?`${_.name} studies changed files, writes short summaries and reviews, and prepares weekly digests while the workshop is quiet.`:`Structural file and symbol search stays available. Add the Boekwachter to this crew for background AI summaries, reviews, and digests.`})]}),_?(0,K.jsx)(`button`,{type:`button`,className:`subtle`,disabled:d||!o,onClick:()=>void v(`remove`),children:d?`Updating…`:`Remove Boekwachter`}):(0,K.jsx)(`button`,{type:`button`,className:`subtle`,disabled:d||!g||!i,onClick:()=>void v(`add`),children:d?`Updating…`:g?`Add ${g.name}`:`No Boekwachter available`})]}),p&&(0,K.jsx)(`p`,{className:`error small project-autonomous-role-error`,children:p}),(0,K.jsx)(Vt,{projectId:e.id,projectProperties:e.properties,refreshKey:[e.voormanGezelId??``,...e.gezelIds??[]].join(`|`),recentlyAddedGezelId:r}),i&&a&&(0,K.jsx)(Bt,{open:c,project:e,gezels:t,roleBasedNameOnlyMode:s,onClose:()=>u(!1),onAddExisting:i,onCreateTemplate:a})]})}function Yt({project:e,onUpdated:t}){let[n,r]=(0,G.useState)([]),i=e.knowledgeCatalogs?.mode??`inherit`,a=e.knowledgeCatalogs?.refs??[];(0,G.useEffect)(()=>{let e=!1;return x.listKnowledgeCatalogs().then(t=>{e||r(t.catalogs)}).catch(()=>{}),()=>{e=!0}},[]);let o=(0,G.useCallback)(async n=>{try{t(await x.updateProject(e.id,{knowledgeCatalogs:n}))}catch(e){console.error(`updateProject(knowledgeCatalogs) failed:`,e)}},[e.id,t]);if(n.length===0)return null;let s=(e,t,n)=>{let r=a.filter(n=>!(n.publisherId===e&&n.catalogId===t)),i=n?[...r,{publisherId:e,catalogId:t}]:r;o({mode:`selected`,refs:i})};return(0,K.jsxs)(`label`,{className:`config-label`,style:{marginTop:`0.75rem`},children:[`Knowledge catalogs`,(0,K.jsx)(`div`,{className:`new-row`,style:{alignItems:`center`},children:(0,K.jsxs)(`select`,{"aria-label":`Knowledge catalog scope`,value:i,onChange:e=>{let t=e.target.value;o(t===`selected`?{mode:t,refs:a}:{mode:t})},children:[(0,K.jsx)(`option`,{value:`inherit`,children:`All my catalogs`}),(0,K.jsx)(`option`,{value:`selected`,children:`Only selected catalogs`}),(0,K.jsx)(`option`,{value:`off`,children:`None for this project`})]})}),i===`selected`&&(0,K.jsxs)(`fieldset`,{className:`project-tab-settings`,children:[(0,K.jsx)(`legend`,{children:`Catalogs in scope`}),(0,K.jsx)(`div`,{className:`project-tab-settings-grid`,children:n.map(e=>(0,K.jsxs)(`label`,{className:`new-row`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:a.some(t=>t.publisherId===e.ref.publisherId&&t.catalogId===e.ref.catalogId),onChange:t=>s(e.ref.publisherId,e.ref.catalogId,t.target.checked)}),(0,K.jsx)(`span`,{children:e.name??e.ref.catalogId})]},e.ref.catalogId))})]}),(0,K.jsx)(`small`,{className:`muted`,children:`Reference material gezellen in this project can search and cite. Manage the catalogs themselves in Settings.`})]})}var Xt=360,J={width:16,height:16,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,focusable:!1},Zt=()=>(0,K.jsxs)(`svg`,{...J,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M12.5 8a4.5 4.5 0 1 1-1.32-3.18`}),(0,K.jsx)(`path`,{d:`M12.8 2.6v2.6h-2.6`})]}),Qt=()=>(0,K.jsxs)(`svg`,{...J,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M8 3.5H4.2A0.7 0.7 0 0 0 3.5 4.2V11.8A0.7 0.7 0 0 0 4.2 12.5H11.8A0.7 0.7 0 0 0 12.5 11.8V8`}),(0,K.jsx)(`path`,{d:`M9.5 3.5H12.5V6.5`}),(0,K.jsx)(`path`,{d:`M12.5 3.5 8 8`})]}),$t=()=>(0,K.jsxs)(`svg`,{...J,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M9.5 3.5H12.5V6.5`}),(0,K.jsx)(`path`,{d:`M12.5 3.5 9 7`}),(0,K.jsx)(`path`,{d:`M6.5 12.5H3.5V9.5`}),(0,K.jsx)(`path`,{d:`M3.5 12.5 7 9`})]}),en=()=>(0,K.jsxs)(`svg`,{...J,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M12.5 6.5H9.5V3.5`}),(0,K.jsx)(`path`,{d:`M9.5 6.5 12.8 3.2`}),(0,K.jsx)(`path`,{d:`M3.5 9.5H6.5V12.5`}),(0,K.jsx)(`path`,{d:`M6.5 9.5 3.2 12.8`})]}),tn=()=>(0,K.jsxs)(`svg`,{...J,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M4 4 12 12`}),(0,K.jsx)(`path`,{d:`M12 4 4 12`})]}),nn=()=>(0,K.jsxs)(`svg`,{...J,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M5 5 6.2 3.5H9.8L11 5H12.5A1 1 0 0 1 13.5 6V12A1 1 0 0 1 12.5 13H3.5A1 1 0 0 1 2.5 12V6A1 1 0 0 1 3.5 5H5Z`}),(0,K.jsx)(`circle`,{cx:`8`,cy:`9`,r:`2.25`})]}),rn=()=>(0,K.jsxs)(`svg`,{...J,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M4 2.5H9.5L12 5V13.5H4Z`}),(0,K.jsx)(`path`,{d:`M9.5 2.5V5H12`}),(0,K.jsx)(`path`,{d:`M6 8H10`}),(0,K.jsx)(`path`,{d:`M6 10.5H9`})]});function an({actions:e}){let[t,n]=(0,G.useState)(!1),r=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,i),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,i)}},[t]),(0,K.jsxs)(`div`,{className:`project-output-menu`,ref:r,children:[(0,K.jsx)(`button`,{type:`button`,className:`project-output-btn`,onClick:()=>n(e=>!e),title:`More actions`,"aria-label":`More output actions`,"aria-haspopup":`menu`,"aria-expanded":t,children:`⋯`}),t&&(0,K.jsx)(`div`,{className:`project-output-menu-dropdown`,role:`menu`,children:e.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`project-output-menu-item`,onClick:()=>{n(!1),e.onClick()},disabled:e.disabled,title:e.title,children:[(0,K.jsx)(`span`,{className:`project-output-menu-item-glyph`,"aria-hidden":`true`,children:e.icon}),(0,K.jsx)(`span`,{children:e.label})]},e.key))})]})}function on({projectId:e,htmlFiles:t,typePage:n,onClose:r,onDebugFrame:i}){let[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(0),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(``),[y,ee]=(0,G.useState)(!1),[b,S]=(0,G.useState)(null),[C,w]=(0,G.useState)(`idle`),[T,E]=(0,G.useState)(null),te=(0,G.useRef)([]),ne=(0,G.useRef)(null),re=(0,G.useRef)(null),ie=mt(re,Xt);(0,G.useEffect)(()=>{let e=!1;return x.getConfig().then(t=>{e||ee(t.debugMode===!0)}).catch(()=>{}),()=>{e=!0}},[]),(0,G.useEffect)(()=>{let n=!1;if(t.length===0){c(``),u(!1);return}return u(!0),(async()=>{let r=await pn(e,t);n||(c(r),u(!1))})(),()=>{n=!0}},[e,(0,G.useMemo)(()=>[...t].sort().join(`
3
+ `),[t])]);let le=(0,G.useMemo)(()=>{let e=[];n&&e.push({id:`type::${n.entry}`,source:`type`,path:n.entry,label:n.label});for(let n of t)e.push({id:`workspace::${n}`,source:`workspace`,path:n,label:cn(n)});return e},[n,t]),D=(n?le[0]:void 0)??(s?le.find(e=>e.source===`workspace`&&e.path===s):void 0)??le.find(e=>e.source===`workspace`),O=le.find(e=>e.id===a)??D??null,de=(0,G.useCallback)(()=>f(e=>e+1),[]);(0,G.useEffect)(()=>{let e=e=>{e.key===`F5`?(e.preventDefault(),m(e=>!e)):e.key===`Escape`&&p&&(e.preventDefault(),m(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[p]),(0,G.useEffect)(()=>{let e=()=>m(!1);return window.addEventListener(Le,e),()=>{window.removeEventListener(Le,e),Ie(!1)}},[]),(0,G.useEffect)(()=>{Ie(p)},[p]);let fe=(0,G.useCallback)(()=>{!O||!T||window.open(T,`_blank`,`noopener,noreferrer`)},[O,T]),pe=(0,G.useCallback)(e=>{let t=[...te.current,e];te.current=t.length>200?t.slice(-200):t},[]);(0,G.useEffect)(()=>{te.current=[],v(``),S(null),w(`idle`)},[O?.id,d]),(0,G.useEffect)(()=>{y||(S(null),w(`idle`))},[y]);let me=(0,G.useCallback)(e=>{S(e),w(`idle`)},[]),he=(0,G.useCallback)(async()=>{if(b)try{await navigator.clipboard.writeText(sn(b)),w(`copied`)}catch{w(`error`)}},[b]),ge=(0,G.useCallback)(async()=>{if(!O||h)return;let t=window.__GEZEL__?.capturePageRegion;if(!t){v(`Screenshots need the desktop app.`);return}let n=ne.current;if(n){g(!0),v(``);try{let r=n.getBoundingClientRect(),a=await t({x:r.left,y:r.top,width:r.width,height:r.height});if(!a.ok)throw Error(a.error);let o=ln(a.dataUrl),{relativePath:s}=await x.uploadProjectAttachment(e,o,`image/png`),c=un(O.path,s,te.current);i?.(c)}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[e,O,h,i]),k=[{key:`reload`,label:`Reload`,icon:(0,K.jsx)(Zt,{}),onClick:de,disabled:!O,title:`Reload the preview`,ariaLabel:`Reload the preview`},{key:`open`,label:`Open in browser`,icon:(0,K.jsx)(Qt,{}),onClick:fe,disabled:!O||!T,title:`Open in your default browser`,ariaLabel:`Open in your default browser`},{key:`maximize`,label:p?`Restore`:`Maximize`,icon:p?(0,K.jsx)(en,{}):(0,K.jsx)($t,{}),onClick:()=>m(e=>!e),title:p?`Restore (F5)`:`Maximize (F5)`,ariaLabel:p?`Restore output pane`:`Maximize output pane`}];p||k.push({key:`close`,label:`Hide output`,icon:(0,K.jsx)(tn,{}),onClick:r,title:`Hide output pane`,ariaLabel:`Hide output pane`});let _e=(0,K.jsxs)(`div`,{className:`project-output-toolbar`,ref:re,children:[le.length>0&&(0,K.jsxs)(ae,{value:O?.id,onValueChange:e=>o(e),children:[(0,K.jsx)(ce,{className:`project-output-picker${ie?` is-compact`:``}`,"aria-label":O?`Choose output page. Current page: ${O.label}`:`Choose output page`,children:ie?(0,K.jsx)(`span`,{className:`project-output-picker-icon`,"aria-hidden":`true`,children:(0,K.jsx)(rn,{})}):(0,K.jsx)(se,{placeholder:l?`Detecting…`:`Select a target…`})}),(0,K.jsx)(ue,{children:le.map(e=>(0,K.jsx)(oe,{value:e.id,textValue:e.label,children:e.label},e.id))})]}),(0,K.jsx)(`span`,{className:`project-output-toolbar-spacer`}),ie?(0,K.jsx)(an,{actions:k}):k.map(e=>(0,K.jsx)(`button`,{type:`button`,className:`project-output-btn`,onClick:e.onClick,disabled:e.disabled,title:e.title,"aria-label":e.ariaLabel,children:e.icon},e.key))]}),A=O?(0,K.jsx)(W,{projectId:e,path:O.path,source:O.source,title:O.label,className:`project-output-iframe`,refreshKey:d,onLog:pe,onUrlReady:E,...O.source===`type`&&n?.pageTools?.length?{pageTools:n.pageTools}:{},...y?{onPageScriptError:me}:{},onRequestRefresh:de}):l?(0,K.jsx)(`div`,{className:`project-output-empty`,children:(0,K.jsx)(`p`,{className:`muted small`,children:`Detecting output target…`})}):(0,K.jsx)(`div`,{className:`project-output-empty`,children:(0,K.jsxs)(`p`,{className:`muted small`,children:[`No previewable HTML in this workspace yet. When a gezel writes an `,(0,K.jsx)(`code`,{children:`index.html`}),`, it'll show up here.`]})}),ve=i||y&&b?(0,K.jsxs)(`div`,{className:`project-output-debugbar`,children:[_&&(0,K.jsx)(`span`,{className:`project-output-debugbar-error small`,role:`alert`,children:_}),y&&b&&(0,K.jsx)(`output`,{className:`project-output-script-error-label small`,children:b.response?.error??b.transportError??`Script failed`}),(0,K.jsx)(`span`,{className:`project-output-toolbar-spacer`}),y&&b&&(0,K.jsx)(`button`,{type:`button`,className:`project-output-script-error-copy`,onClick:()=>void he(),title:`Copy the full script run, including logs and call trace`,"aria-label":`Copy full script error details`,children:C===`copied`?`Copied`:C===`error`?`Copy failed`:`Copy details`}),i&&(0,K.jsx)(`button`,{type:`button`,className:`project-output-btn`,onClick:ge,disabled:!O||h,title:`Send a screenshot + browser state to the chat`,"aria-label":`Send a debug frame to the chat`,children:(0,K.jsx)(nn,{})})]}):null;return(0,K.jsxs)(`aside`,{className:`project-output-pane${p?` project-output-pane-maximized`:``}`,children:[_e,(0,K.jsx)(`div`,{ref:ne,className:`project-output-pane-body`,children:A}),ve]})}function sn(e){let t=[`# Gezel page script error`,``,`Tool: ${e.tool}`];return e.response&&(t.push(`Run ID: ${e.response.runId}`),t.push(`Status: ${e.response.status}`),e.response.error&&t.push(`Error: ${e.response.error}`),t.push(``,`## Page invoke response`,``,"```json"),t.push(JSON.stringify(e.response,null,2)),t.push("```")),e.run&&(t.push(``,`## Full script run`,``,"```json"),t.push(JSON.stringify(e.run,null,2)),t.push("```")),e.transportError&&t.push(``,`Transport error: ${e.transportError}`),e.detailLoadError&&t.push(``,`Full run could not be loaded: ${e.detailLoadError}`),`${t.join(`
4
+ `)}\n`}function cn(e){let t=e.lastIndexOf(`/`),n=t>=0?e.slice(0,t+1):``,r=e.slice(t+1).replace(/\.html?$/i,``);return n+(r.toLowerCase()===`index`?`(Default Page)`:r)}function ln(e){let t=e.indexOf(`,`),n=e.slice(0,t).match(/data:([^;]+)/)?.[1]??`application/octet-stream`,r=atob(e.slice(t+1)),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return new Blob([i],{type:n})}function un(e,t,n){let r=[];if(r.push(`![Screenshot of workspace file ${e}](${t})`),n.length>0){r.push(``),r.push(`**Browser state:** ${n.length} console event(s) captured since load:`),r.push(``);for(let e of n.slice(-50))r.push(`- ${dn(e)}`)}return r.join(`
5
+ `)}function dn(e){let t=e.kind===`console.error`?(e.detail.args??[]).join(` `):e.detail.message??`(unknown error)`,n=[e.detail.filename,e.detail.lineno?String(e.detail.lineno):null,e.detail.colno?String(e.detail.colno):null].filter(Boolean).join(`:`);return`**${e.kind}:** ${t}${n?` _(${n})_`:``}`}var fn=24;async function pn(e,t){if(t.length===0)return``;if(t.length===1)return t[0]??``;let n=t.slice(0,fn);return mn(await Promise.all(n.map(async t=>{let[n,r]=await Promise.all([x.statProjectWorkspacePath(e,t).catch(()=>null),x.readProjectWorkspaceFile(e,t).then(e=>e.content).catch(()=>``)]);return{path:t,size:n?.size??r.length,mtimeMs:n?.mtime?Date.parse(n.mtime):0,placeholder:gn(r)}})))||(t[0]??``)}function mn(e){if(e.length===0)return``;let t=Math.max(1,...e.map(e=>e.size)),n=e.map(e=>e.mtimeMs).filter(e=>e>0),r=n.length?Math.max(...n):0,i=n.length?Math.min(...n):0,a=r-i,o=e[0],s=-1/0;for(let n of e){let e=n.size/t,r=a>0?(n.mtimeMs-i)/a:0,c=+!!/(^|\/)index\.html?$/i.test(n.path),l=(n.placeholder?0:1e3)+e*100+r*40+c*10;l>s&&(s=l,o=n)}return o?.path??``}var hn=[`logic here`,`code here`,`goes here`,`your code`,`add your`,`fill in`,`coming soon`,`placeholder`,`todo`,`fixme`];function gn(e){if(!e.trim())return!0;let t=[...e.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script>/gi)].map(e=>e[1]??``),n=t.length>0,r=t.join(`
6
+ `).replace(/\/\*[\s\S]*?\*\//g,``).replace(/\/\/[^\n]*/g,``).trim();if(n&&r.length<40)return!0;let i=e.toLowerCase();return hn.some(e=>i.includes(e))&&e.length<2e3}function _n(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading this project…`}),(0,K.jsx)(`div`,{className:`entity-tabs-row project-tabs-row project-pane-placeholder-tabs`,"aria-hidden":`true`,children:(0,K.jsx)(`span`,{className:`gz-tabs-trigger`,children:`Chat`})}),(0,K.jsx)(`div`,{className:`project-pane-placeholder-body`,"aria-hidden":`true`})]})}function vn({project:e,onProjectChange:t}){let[n,r]=(0,G.useState)({}),[i,a]=(0,G.useState)(null),s=e.properties??{},l=Object.keys(s).filter(e=>!o(e)),u=[...c.map(e=>({id:e.id,label:e.label,description:e.description,options:e.options})),...l.map(e=>({id:e,label:e,description:void 0,options:void 0}))],d=async i=>{let o=n[i];if(!(o===void 0||o===(s[i]??``))){a(null);try{t(await x.updateProject(e.id,{properties:{[i]:o}})),r(e=>{let{[i]:t,...n}=e;return n})}catch(e){a(e.message)}}};return(0,K.jsxs)(`div`,{className:`project-properties`,children:[u.map(e=>(0,K.jsxs)(`label`,{className:`config-label project-properties-row`,children:[e.label,(0,K.jsxs)(`div`,{className:`new-row`,children:[(0,K.jsx)(`input`,{value:n[e.id]??s[e.id]??``,placeholder:`Not set`,list:e.options?`project-property-options-${e.id}`:void 0,onChange:t=>r(n=>({...n,[e.id]:t.target.value})),onBlur:()=>void d(e.id)}),e.options&&(0,K.jsx)(`datalist`,{id:`project-property-options-${e.id}`,children:e.options.map(e=>(0,K.jsx)(`option`,{value:e},e))})]}),e.description&&(0,K.jsx)(`small`,{className:`muted`,children:e.description})]},e.id)),i&&(0,K.jsx)(`p`,{className:`error small`,children:i})]})}var Y=[{id:`developer`,label:`Developer`,canonical:[`developer`,`web-developer`]},{id:`writer`,label:`Writer`,canonical:[`copywriter`]},{id:`designer`,label:`Designer`,canonical:[`designer`]},{id:`researcher`,label:`Researcher`,canonical:[`researcher`]}],yn=new Set([`adoc`,`asciidoc`,`markdown`,`md`,`mdx`,`rst`,`tex`,`txt`]),bn=new Set([`ai`,`avif`,`bmp`,`fig`,`gif`,`ico`,`jpeg`,`jpg`,`pdf`,`png`,`psd`,`sketch`,`svg`,`webp`]),xn=new Set([`csv`,`ods`,`parquet`,`tsv`,`xls`,`xlsx`]);function Sn(e){let t=e.split(`/`).pop()?.toLowerCase()??``,n=t.includes(`.`)?t.split(`.`).pop()??``:``;return yn.has(n)?`writer`:bn.has(n)?`designer`:xn.has(n)?`researcher`:`developer`}function Cn(e,t,n){if(t.stale){let r=t.line==null?``:` It was previously reported near line ${t.line}.`;return`@${n}, can you address ${t.ref} in ${e}: ${t.message}${r} The file has changed since this was reported, so please verify it against the current file before editing.`}let r=t.line==null?``:` at line ${t.line}`;return`@${n}, can you address ${t.ref} in ${e}${r}: ${t.message}`}function wn(e){return h(e.role)??h(e.roleBasedName)}function X(e,t,n){let r=new Set(Y.find(e=>e.id===t).canonical);return e.filter(e=>{let t=wn(e);return!e.fixedFunction&&t!==null&&r.has(t)}).sort((e,t)=>Number(n.has(t.id))-Number(n.has(e.id))||e.name.localeCompare(t.name))}function Tn({path:e,issue:t,gezels:n,assignedGezelIds:r,onCancel:i,onConfirm:a}){let o=Sn(e),[s,c]=(0,G.useState)(o),l=(0,G.useMemo)(()=>X(n,s,r),[r,n,s]),[u,d]=(0,G.useState)(()=>X(n,o,r)[0]?.id??``),[f,p]=(0,G.useState)(()=>Cn(e,t,o)),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(null),ee=i=>{let a=X(n,i,r);c(i),d(a[0]?.id??``),m||p(Cn(e,t,i))},b=async()=>{if(!(g||!u||!f.trim())){_(!0),y(null);try{await a(u,f.trim())}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(!1)}}},x=Y.find(e=>e.id===s).label;return(0,K.jsx)(te,{open:!0,onOpenChange:e=>!e&&!g&&i(),children:(0,K.jsxs)(le,{children:[(0,K.jsx)(ne,{}),(0,K.jsx)(re,{className:`workspace-issue-fix-dialog`,children:(0,K.jsxs)(`form`,{className:`workspace-issue-fix-form`,onSubmit:e=>{e.preventDefault(),b()},children:[(0,K.jsx)(ie,{asChild:!0,children:(0,K.jsx)(`h3`,{children:`Assign issue fix`})}),(0,K.jsx)(T,{className:`muted small`,children:`This creates an assigned task and starts its specialist chat immediately. Your files aren’t touched — the fix arrives as a change proposal you review and apply.`}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{children:`Assigned role`}),(0,K.jsx)(`select`,{value:s,onChange:e=>ee(e.currentTarget.value),disabled:g,children:Y.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{children:`Gezel`}),(0,K.jsx)(jt,{gezels:l,value:u,onValueChange:e=>d(e??``),placeholder:`No ${x.toLowerCase()} gezel available`,ariaLabel:`Gezel assigned to fix this issue`,disabled:g||l.length===0})]}),l.length===0&&(0,K.jsxs)(`p`,{className:`workspace-issue-fix-missing`,role:`alert`,children:[`No `,x.toLowerCase(),` gezel is available. Choose another role or add one to the crew first.`]}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{children:`Message`}),(0,K.jsx)(`textarea`,{value:f,onChange:e=>{p(e.currentTarget.value),h(!0)},rows:5,disabled:g})]}),v&&(0,K.jsxs)(`p`,{className:`gz-dialog-error`,role:`alert`,children:[`Couldn’t start the fix: `,v]}),(0,K.jsxs)(E,{children:[(0,K.jsx)(`button`,{type:`button`,onClick:i,disabled:g,children:`Cancel`}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:g||!u||!f.trim(),children:g?`Starting…`:`OK`})]})]})})]})})}function En(e,t,n,r){let i=r?.provider??`llama-cpp`,a=new Set(e.gezelIds??[]);e.voormanGezelId&&a.add(e.voormanGezelId);let o=[...t.filter(e=>a.has(e.id)),...n].filter(e=>!e.fixedFunction);return[{provider:i},...o.map(e=>({provider:e.provider??i,gezel:e}))]}function Dn(e,t,n,r){let i=En(e,t,n,r),a=!1,o=!1;for(let t of i){let n=g({provider:t.provider,projectCodexMode:e.codexPermissionMode,projectClaudeMode:e.claudePermissionMode,gezel:t.gezel,config:r});n===`none`&&(o=!0),(n===`edit`||n===`reviewed`||n===`full`)&&(a=!0)}return{nativeWritable:a,managedSurfaceAvailable:o}}function On(e,t,n,r){let i=u(e),{nativeWritable:a,managedSurfaceAvailable:o}=Dn(e,t,n,r);return{managedWritable:i,nativeWritable:a,effectiveWritable:a||i&&o}}function kn(e,t,n,r){return En(e,t,n,r).some(e=>e.provider===`codex-cli`)}function An(e,t,n,r){return En(e,t,n,r).some(e=>e.provider===`anthropic-cli`)}function jn(e,t,n,r){if(e.claudePermissionMode)return e.claudePermissionMode;let i=new Set(En(e,t,n,r).filter(e=>e.provider===`anthropic-cli`).map(e=>e.gezel?.claudePermissionMode??r?.anthropicCli?.defaultPermissionMode??`acceptEdits`));return i.size>1?`mixed`:i.values().next().value??`acceptEdits`}function Mn(e){return e.split(/[-_]/).filter(Boolean).map(e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`).join(` `)}function Nn(e,t){return`${e} ${t}${e===1?``:`s`}`}function Pn(e){if(e.source!==`catalog`)return null;let t=e.item.manifest;return t.kind===`project-type`?t:null}function Fn(e){if(e.source===`catalog`){let t=e.item.manifest;return{name:t.name,categoryLabel:Te(I(e.item)).label,description:t.description}}return{name:e.kind.label,categoryLabel:Te(e.kind.category).label,description:e.kind.description}}function In({selection:e,size:t}){let n=e.source===`catalog`,r=Pn(e),i=n&&!r?.icon;return(0,K.jsx)(Ae,{...i&&e.source===`catalog`&&e.item.iconSvg?{iconSvg:e.item.iconSvg}:{},...i&&e.source===`catalog`&&e.item.logoUrl?{logoUrl:e.item.logoUrl}:{},svgClassName:`gz-npd-hero-art-svg`,fallback:(0,K.jsx)(Ee,{glyph:e.source===`catalog`?we(e.item):e.kind.glyph,size:t})})}function Ln({selection:e}){let t=Pn(e),{description:n}=Fn(e),r=t?t.gezels??[]:[],i=[];if(t){let e=(t.tools??[]).length;e>0&&i.push({glyph:`code`,text:Nn(e,`custom tool`)}),t.pages&&i.push({glyph:`frame`,text:`Live dashboard in the Output pane`});let n=(t.schedules??[]).length;n>0&&i.push({glyph:`calendar`,text:Nn(n,`scheduled routine`)});let r=(t.toolsets??[]).length;r>0&&i.push({glyph:`dots`,text:Nn(r,`toolset`)});let a=(t.craftbooks??[]).length;a>0&&i.push({glyph:`sheet`,text:Nn(a,`craftbook`)})}let a=e.source===`builtin`?e.kind.give:[],o=r.length>0||i.length>0||a.length>0;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`gz-npd-brief-lede`,children:n}),o&&(0,K.jsxs)(`div`,{className:`gz-npd-give`,children:[(0,K.jsx)(`p`,{className:`gz-npd-give-eyebrow`,children:`Gezellen and Tools`}),r.length>0&&(0,K.jsx)(`div`,{className:`gz-npd-crew`,children:r.map(e=>{let t=Mn(e.templateId);return(0,K.jsxs)(`figure`,{className:`gz-npd-crew-member`,children:[(0,K.jsx)(`span`,{className:`gz-npd-crew-figure`,children:(0,K.jsx)(j,{poppetje:f(e.templateId,t),variant:`headshot`,size:44})}),(0,K.jsxs)(`figcaption`,{children:[t,e.voorman&&(0,K.jsx)(`span`,{className:`gz-npd-crew-voorman`,children:`voorman`})]})]},e.templateId)})}),(0,K.jsxs)(`ul`,{className:`gz-npd-give-rows`,children:[i.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(Ee,{glyph:e.glyph,size:15}),e.text]},e.text)),a.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(Ee,{glyph:`sheet`,size:15}),e]},e))]})]})]})}function Rn({label:e,description:t,active:n,disabled:r=!1,badge:i,iconSvg:a,logoUrl:o,glyph:s,index:c,onSelect:l}){return(0,K.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"aria-label":r?`${e} (coming soon)`:e,className:`gz-npd-card${n?` active`:``}`,disabled:r,onClick:l,style:{"--card-i":Math.min(c,11)},children:[(0,K.jsx)(`span`,{className:`gz-npd-card-mark`,"aria-hidden":`true`,children:(0,K.jsx)(Ae,{...a?{iconSvg:a}:{},...o?{logoUrl:o}:{},svgClassName:`gz-npd-card-mark-svg`,fallback:(0,K.jsx)(Ee,{glyph:s??`dots`,size:22})})}),(0,K.jsx)(`span`,{className:`gz-npd-card-name`,children:e}),(0,K.jsx)(`span`,{className:`gz-npd-card-description`,children:t}),i&&(0,K.jsx)(`span`,{className:`gz-npd-card-badge`,"aria-hidden":`true`,children:i})]})}var zn=[{id:`imap`,label:`IMAP`},{id:`gmail`,label:`Gmail`},{id:`microsoft365`,label:`Microsoft 365`},{id:`outlook`,label:`Outlook.com`}];function Bn(e){let t=e||`this mailbox`;return{about:`Email workspace for ${t}. Messages are synced here as searchable markdown files so gezellen can triage the inbox, answer questions over your mail, and draft replies for your review.`,mission:`Keep ${t} triaged and responsive: surface threads needing a reply, draft responses for approval, and never send without explicit consent.`}}var Vn=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());function Hn(e){let t=e?.properties??{},n={};for(let[e,r]of Object.entries(t))r&&r.default!==void 0&&(n[e]=r.default);return n}function Un(e){return typeof e==`string`?e.trim()||null:typeof e==`number`&&Number.isFinite(e)?String(e):null}function Z(e){let t=e.replace(/\s+/g,` `).trim();return t?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:``}function Wn(e,t){let n=e.manifest;if(n.kind!==`project-type`)return n.name;if(n.nameTemplate){let e=n.nameTemplate.replace(/\{\{\s*([a-zA-Z0-9_.-]+)\s*\}\}/g,(e,n)=>Un(t[n])??e);if(!e.includes(`{{`))return Z(e)}let r=n.params,i=Object.keys(r?.properties??{});return Z([...(i.length>0?i:Object.keys(t)).map(e=>Un(t[e])).filter(e=>e!==null).filter((e,t,n)=>n.indexOf(e)===t).slice(0,2),n.name].join(` `))}function Gn({open:e,mode:t,onClose:n,onCreated:r}){let i=Ke(),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(`general`),[f,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(``),[g,_]=(0,G.useState)([]),[v,ee]=(0,G.useState)(null),[b,S]=(0,G.useState)({}),[C,w]=(0,G.useState)(``),[T,ae]=(0,G.useState)(`all`),[oe,se]=(0,G.useState)(`pick`),[ce,ue]=(0,G.useState)(!1),[D,O]=(0,G.useState)(``),[de,fe]=(0,G.useState)(``),[pe,me]=(0,G.useState)(`imap`),[he,ge]=(0,G.useState)(``),[k,_e]=(0,G.useState)(``),[A,ve]=(0,G.useState)(``),[ye,be]=(0,G.useState)(!0),[j,xe]=(0,G.useState)(``),[M,Se]=(0,G.useState)(null),[N,Ce]=(0,G.useState)(null),[P,Te]=(0,G.useState)(null),[Oe,R]=(0,G.useState)([]),[ke,z]=(0,G.useState)(``),[Ae,je]=(0,G.useState)(!1),Me=(0,G.useRef)(null),Ne=(0,G.useRef)(0),Pe=(0,G.useRef)(null),Fe=(0,G.useRef)(null),Ie=(0,G.useRef)({name:o,nameManuallyEdited:c,about:f,mission:m});Ie.current={name:o,nameManuallyEdited:c,about:f,mission:m};let Le=(0,G.useId)();(0,G.useEffect)(()=>{Ne.current+=1,Pe.current=null,Fe.current?.abort(),Fe.current=null,e&&(s(``),l(!1),d(`general`),p(``),h(``),O(``),Se(null),Ce(null),fe(``),me(`imap`),ge(``),_e(``),ve(``),be(!0),xe(``),ee(null),S({}),w(``),ae(`all`),se(`pick`),ue(!1),z(``),je(!1),Me.current=null)},[e]),(0,G.useEffect)(()=>{if(!e)return;let t=!1,n=x.listCatalogItems(`project-type`),r=i?Promise.resolve({items:[]}):x.listCatalogItems(`craftbook-template`);return Promise.all([n,r]).then(([e,n])=>{if(t)return;let r=a(n.items);_(y(e.items,i,r).filter(e=>e.manifest.id!==`email`))}).catch(()=>{t||_([])}),()=>{t=!0}},[e,i]),(0,G.useEffect)(()=>{!i&&u===`email`&&d(`general`)},[u,i]),(0,G.useEffect)(()=>{if(!e||!P){R([]);return}let t=!1;return x.listGitHubRepos().then(e=>{t||R(e.repos)}).catch(()=>{t||R([])}),()=>{t=!0}},[e,P]);let Re=t===`solo`||u===`folder`,ze=Re?`New Job`:`New Project`,Be=Re?`Describe the job. What do you want done? What's in scope, what's out? The Builder lands on this with no other context.`:`Who's this project for, what's in scope, what's out. The first thing any gezel joining the project reads.`,Ve=Re?`Concrete success criteria. What does the finished job look like?`:`Concrete success criteria, usually a bullet list. What does "done" look like?`,He=window.__GEZEL__?.platform===`win32`?`C:\\projects\\mystuff`:`/path/to/folder`,Ue=(0,G.useCallback)(()=>{Ne.current+=1,Pe.current=null,Fe.current?.abort(),Fe.current=null,Ce(null)},[]),We=(0,G.useCallback)(()=>{se(`pick`),z(``)},[]),Ge=(0,G.useCallback)(e=>{Ue(),Se(null),O(e)},[Ue]),qe=(0,G.useCallback)(async e=>{let t=(e??D).trim();if(!t){Se(null);return}if(!Xn(t)){Se({message:`Looks incomplete — enter owner/repo (e.g. bendyline/squisq).`});return}if(Me.current===t){Se(null);return}if(!P){Se({message:`Sign in to GitHub to auto-fill About and Mission objectives from this repo.`});return}if(Pe.current===t)return;Se(null);let n=Ne.current+1,r=new AbortController;Ne.current=n,Pe.current=t,Fe.current=r,Ce(`reading`);try{let e=await x.previewGitHubRepo(Yn(t),r.signal);if(Ne.current!==n)return;Ce(`drafting`);let i=Ie.current;i.nameManuallyEdited||s(e.repo);let a=i.nameManuallyEdited&&i.name.trim()||e.repo,o=await x.previewProjectAbout({name:a,repoUrl:e.canonicalUrl,...e.description?{description:e.description}:{},...e.topics?{topics:e.topics}:{},readme:e.readme},r.signal);if(Ne.current!==n)return;let c=Ie.current,l=c.about.trim().length>0,u=c.mission.trim().length>0;(!l&&!u||window.confirm(`Replace the current About and Mission objectives with text drafted from this repo?`))&&(p(o.about),h(o.missionObjectives),Me.current=t)}catch(e){if(Ne.current!==n)return;let t=Qn(e);Se({message:`Couldn't read this repo: ${Zn(e)}`,...t?{fixUrl:t}:{}})}finally{Ne.current===n&&(Pe.current=null,Fe.current=null,Ce(null))}},[D,P]),Je=(0,G.useCallback)(async e=>{xe(e);let t=e.trim();if(t)try{let e=await x.previewFolder(t);e.name&&!c&&s(e.name),e.about&&p(t=>t.trim()?t:e.about??``)}catch{if(!c){let e=t.replace(/[\\/]+$/,``).split(/[\\/]/).pop();e&&s(e)}}},[c]),B=(0,G.useCallback)(async()=>{let e=window.__GEZEL__?.selectDirectory;if(e)try{let t=await e({title:`Choose a project folder`});t&&await Je(t)}catch{}},[Je]),V=v?g.find(e=>e.manifest.id===v)??null:null,Ye=V?.manifest.kind===`project-type`?V.manifest.params:void 0,Xe=(0,G.useMemo)(()=>L.filter(e=>i||e.id!==`email`),[i]),H=C.trim().toLowerCase(),Ze=(0,G.useMemo)(()=>H?Xe.filter(e=>`${e.label} ${e.description}`.toLowerCase().includes(H)):Xe,[Xe,H]),U=(0,G.useMemo)(()=>H?g.filter(e=>{let t=e.manifest;return`${t.name} ${t.description} ${t.tags.join(` `)}`.toLowerCase().includes(H)}):g,[H,g]),Qe=H.length>0,$e=(0,G.useMemo)(()=>De.map(e=>({cat:e,builtins:Ze.filter(t=>t.category===e.id),types:U.filter(t=>I(t)===e.id)})).filter(e=>e.builtins.length+e.types.length>0),[Ze,U]),et=Qe||T===`all`?$e:$e.filter(e=>e.cat.id===T),tt=(0,G.useMemo)(()=>De.map(e=>({cat:e,count:Xe.filter(t=>t.category===e.id).length+g.filter(t=>I(t)===e.id).length})).filter(e=>e.count>0),[Xe,g]),nt=V?{source:`catalog`,item:V}:{source:`builtin`,kind:Xe.find(e=>e.id===u)??Xe[0]},rt=Fn(nt),it=(0,G.useCallback)(async e=>{if(e.preventDefault(),oe!==`configure`)return;if(z(``),v&&V){let e=o.trim();if(!e){z(`Name is required.`);return}je(!0);try{let t=V.manifest.kind===`project-type`?V.manifest.params:void 0,{project:i,applied:a}=await x.createTypedProject({name:e,...Re?{mode:`solo`}:{},projectType:{typeId:v,params:{...Hn(t),...b}}});a.gezelsCreated.length>0&&window.dispatchEvent(new CustomEvent(`gezel:gezel-updated`)),await r(i),n()}catch(e){z(e.message)}finally{je(!1)}return}if(u===`email`){let e=de.trim();if(!Vn(e)){z(`Enter a valid email address — it becomes the project name.`);return}if(pe===`imap`&&(!he.trim()||!A)){z(`IMAP needs at least a host and a password.`);return}je(!0);try{let t=Bn(e),i=await x.createProject({name:e,about:t.about,missionObjectives:t.mission,...Re?{mode:`solo`}:{}}),a=await x.updateProject(i.id,{projectTypeId:`email`}).catch(()=>i);pe===`imap`?await gt(i.id,{address:e,host:he.trim(),...k.trim()?{port:Number(k.trim())}:{},secure:ye,pass:A}).catch(e=>console.warn(`mail link failed:`,e)):await ht(i.id,pe,e).catch(e=>console.warn(`mail OAuth failed:`,e)),await r(a),n()}catch(e){z(e.message)}finally{je(!1)}return}let t=o.trim(),i=f.trim(),a=m.trim(),s=D.trim();if(!t){z(`Name is required.`);return}if(u!==`folder`&&!i){z(Re?`Job description is required — what you want done, what is in scope, what is out.`:`About is required — who this project is for, what's in scope, what's out.`);return}let c=u===`github`;if(c&&s&&!Xn(s)){z(`GitHub repo doesn't look right — leave it blank or use owner/repo.`);return}if(u===`folder`&&!j.trim()){z(`Choose a folder for this project.`);return}je(!0);try{await r(await x.createProject({name:t,about:i,missionObjectives:a,...Re?{mode:`solo`}:{},...u===`folder`?{workingDir:j.trim()}:{},...c&&s?{github:{url:Yn(s)}}:{}})),n()}catch(e){z(e.message)}finally{je(!1)}},[o,u,f,m,D,de,pe,he,k,A,ye,j,v,V,b,Re,oe,n,r]);return(0,K.jsx)(te,{open:e,onOpenChange:e=>{e||n()},children:(0,K.jsxs)(le,{children:[(0,K.jsx)(ne,{}),(0,K.jsx)(re,{className:`gz-npd gz-npd-step-${oe}`,children:(0,K.jsx)(`form`,{onSubmit:it,style:{display:`contents`},children:oe===`pick`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`header`,{className:`gz-npd-header`,children:[(0,K.jsxs)(`div`,{className:`gz-npd-header-copy`,children:[(0,K.jsx)(ie,{asChild:!0,children:(0,K.jsx)(`h3`,{children:ze})}),(0,K.jsx)(`p`,{className:`gz-npd-header-sub`,children:Re?`A job is a solo project — one Builder handles the work end to end.`:`Pick a starting point — blank, connected, or purpose-built.`})]}),(0,K.jsxs)(`label`,{className:`gz-npd-search`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Search project types`}),(0,K.jsx)(`input`,{type:`search`,value:C,onChange:e=>w(e.target.value),placeholder:`Search types…`})]})]}),(0,K.jsxs)(`div`,{className:`gz-npd-body`,children:[(0,K.jsxs)(`nav`,{className:`gz-npd-rail`,"aria-label":`Project type categories`,children:[(0,K.jsx)(`button`,{type:`button`,className:`gz-npd-rail-item${!Qe&&T===`all`?` active`:``}`,onClick:()=>ae(`all`),children:(0,K.jsx)(`span`,{className:`gz-npd-rail-label`,children:`All`})}),tt.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`gz-npd-rail-item${!Qe&&T===e.cat.id?` active`:``}`,onClick:()=>ae(e.cat.id),children:[(0,K.jsx)(Ee,{glyph:e.cat.glyph,size:16}),(0,K.jsx)(`span`,{className:`gz-npd-rail-label`,children:e.cat.label}),(0,K.jsx)(`span`,{className:`gz-npd-rail-count`,children:e.count})]},e.cat.id))]}),(0,K.jsxs)(`div`,{className:`gz-npd-gallery`,role:`radiogroup`,"aria-label":`Project type`,children:[et.map(e=>(0,K.jsxs)(`section`,{className:`gz-npd-section`,children:[(0,K.jsxs)(`div`,{className:`gz-npd-section-head`,children:[(0,K.jsx)(`span`,{className:`gz-npd-section-title`,children:e.cat.label}),(0,K.jsx)(`span`,{className:`gz-npd-section-tagline`,children:e.cat.tagline})]}),(0,K.jsxs)(`div`,{className:`gz-npd-grid`,children:[e.builtins.map((e,t)=>(0,K.jsx)(Rn,{label:e.label,description:e.description,glyph:e.glyph,index:t,active:ce&&!v&&e.id===u,...e.soon?{disabled:!0,badge:`Soon`}:{},onSelect:()=>{e.soon||(u===`github`&&e.id!==`github`&&Ue(),d(e.id),ue(!0),ee(null),S({}),c||s(``),z(``),se(`configure`))}},e.id)),e.types.map((t,n)=>(0,K.jsx)(Rn,{label:t.manifest.name,description:t.manifest.description,glyph:we(t),index:e.builtins.length+n,active:t.manifest.id===v,...!(t.manifest.kind===`project-type`&&t.manifest.icon)&&t.iconSvg?{iconSvg:t.iconSvg}:{},...!(t.manifest.kind===`project-type`&&t.manifest.icon)&&t.logoUrl?{logoUrl:t.logoUrl}:{},onSelect:()=>{u===`github`&&Ue(),ee(t.manifest.id),d(`general`),ue(!1);let e=Hn(t.manifest.kind===`project-type`?t.manifest.params:void 0);S(e),c||s(Wn(t,e)),z(``),se(`configure`)}},t.manifest.id))]})]},e.cat.id)),et.length===0&&(0,K.jsx)(`p`,{className:`gz-npd-empty`,children:`No project types match your search.`})]})]}),(0,K.jsxs)(`div`,{className:`gz-npd-pane-footer gz-npd-pick-footer`,children:[(0,K.jsx)(`p`,{className:`gz-npd-footnote`,children:`Pick one to see what it brings — nothing is created until the next screen.`}),(0,K.jsx)(E,{children:(0,K.jsx)(`button`,{type:`button`,onClick:n,children:`Cancel`})})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`header`,{className:`gz-npd-header gz-npd-detail-header`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`gz-npd-back`,onClick:We,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`‹`}),`Project types`]}),(0,K.jsxs)(`div`,{className:`gz-npd-detail-id`,children:[(0,K.jsx)(`span`,{className:`gz-npd-detail-art`,"aria-hidden":`true`,children:(0,K.jsx)(In,{selection:nt,size:26})}),(0,K.jsxs)(`div`,{className:`gz-npd-header-copy`,children:[(0,K.jsx)(`p`,{className:`gz-npd-hero-eyebrow`,children:rt.categoryLabel}),(0,K.jsx)(ie,{asChild:!0,children:(0,K.jsx)(`h3`,{className:`gz-npd-hero-name`,children:rt.name})})]})]})]}),(0,K.jsxs)(`div`,{className:`gz-npd-detail`,"data-lean":V?void 0:`true`,children:[(0,K.jsx)(`div`,{className:`gz-npd-brief`,children:(0,K.jsx)(Ln,{selection:nt})}),(0,K.jsx)(`div`,{className:`gz-npd-setup`,children:(0,K.jsxs)(`div`,{className:`gz-npd-pane-form`,children:[V&&Ye&&(0,K.jsx)(`div`,{className:`gz-npd-params`,children:(0,K.jsx)(F,{schema:Ye,value:b,onChange:e=>{let t=e??{};S(t),c||s(Wn(V,t))},density:`compact`})}),u===`github`&&(0,K.jsxs)(`div`,{className:`gz-npd-field`,children:[(0,K.jsxs)(`span`,{className:`gz-new-project-github-label`,children:[(0,K.jsxs)(`label`,{htmlFor:Le,children:[`GitHub repository `,(0,K.jsx)(`span`,{className:`muted`,children:`(optional)`})]}),(0,K.jsx)(kt,{onChange:Te,compact:!0})]}),(0,K.jsx)(qn,{inputId:Le,value:D,onChange:Ge,onBlur:()=>void qe(),onSelect:e=>{Ge(e),qe(e)},repos:Oe}),N&&(0,K.jsx)(Kn,{phase:N,onCancel:Ue}),!N&&M&&(0,K.jsxs)(`small`,{className:`error`,children:[M.message,M.fixUrl&&(0,K.jsxs)(K.Fragment,{children:[` `,(0,K.jsx)(`a`,{href:M.fixUrl,target:`_blank`,rel:`noopener noreferrer`,children:`Open GitHub authorization page →`})]})]})]}),u===`folder`&&(0,K.jsxs)(`label`,{children:[`Folder`,(0,K.jsxs)(`div`,{className:`gz-folder-row`,children:[(0,K.jsx)(`input`,{value:j,onChange:e=>xe(e.target.value),onBlur:()=>void Je(j),placeholder:He}),window.__GEZEL__?.selectDirectory&&(0,K.jsx)(`button`,{type:`button`,className:`gz-folder-browse`,onClick:()=>void B(),children:`Browse…`})]}),(0,K.jsx)(`small`,{className:`muted`,children:`Gezels read — and, with permission, write — files in this folder.`})]}),u===`email`?(0,K.jsxs)(`label`,{children:[`Email address`,(0,K.jsx)(`input`,{type:`email`,value:de,onChange:e=>fe(e.target.value),placeholder:`you@example.com`,autoComplete:`email`}),(0,K.jsx)(`small`,{className:`muted`,children:`The project is named after this address.`})]}):(0,K.jsxs)(`label`,{children:[`Name`,(0,K.jsx)(`input`,{value:o,onChange:e=>{s(e.target.value),l(!0)},placeholder:Re?`e.g. Bird-feeder prototype`:`e.g. Eliza's Pet Shop`}),V&&o&&!c&&(0,K.jsx)(`small`,{className:`muted`,children:`Suggested from your choices — edit it anytime.`}),u===`folder`&&o&&!c&&(0,K.jsx)(`small`,{className:`muted`,children:`Suggested from the folder — edit it anytime.`})]}),u===`email`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`gz-type-field`,children:[(0,K.jsx)(`span`,{className:`gz-type-field-label`,children:`Provider`}),(0,K.jsx)(`div`,{className:`gz-type-picker`,role:`radiogroup`,"aria-label":`Mail provider`,children:zn.map(e=>{let t=e.id===pe;return(0,K.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t,className:`gz-type-chip${t?` active`:``}`,onClick:()=>me(e.id),children:e.label},e.id)})})]}),pe===`imap`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{children:[`IMAP host`,(0,K.jsx)(`input`,{value:he,onChange:e=>ge(e.target.value),placeholder:`imap.example.com`})]}),(0,K.jsxs)(`div`,{className:`gz-imap-row`,children:[(0,K.jsxs)(`label`,{className:`gz-imap-port`,children:[`Port `,(0,K.jsx)(`span`,{className:`muted`,children:`(optional)`}),(0,K.jsx)(`input`,{value:k,onChange:e=>_e(e.target.value),placeholder:`993`,inputMode:`numeric`})]}),(0,K.jsxs)(`label`,{className:`gz-imap-tls`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:ye,onChange:e=>be(e.target.checked)}),`Use TLS`]})]}),(0,K.jsxs)(`label`,{children:[`Password / app password`,(0,K.jsx)(`input`,{type:`password`,value:A,onChange:e=>ve(e.target.value),placeholder:`app password`,autoComplete:`off`})]}),(0,K.jsx)(`small`,{className:`muted`,children:`Gmail and Outlook.com also work over IMAP with an app password. The username is your email address.`})]}):(0,K.jsxs)(`p`,{className:`muted small`,children:[zn.find(e=>e.id===pe)?.label,` connects via OAuth. Create the project, then click `,(0,K.jsx)(`strong`,{children:`Connect`}),` in its Mail tab to authorize in the browser. Synced messages become searchable files; sending is consent-gated.`]})]}),u!==`email`&&!v&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{children:[Re?`Job description`:`About`,` `,(0,K.jsx)(`span`,{className:`muted`,children:u===`folder`?`(optional)`:``}),(0,K.jsx)(`textarea`,{value:f,onChange:e=>p(e.target.value),placeholder:u===`folder`?`Optional. Auto-filled from the folder's AGENTS.md or CLAUDE.md if it has one — or add your own notes about what's here.`:Be,rows:4})]}),(0,K.jsxs)(`label`,{children:[`Mission objectives `,(0,K.jsx)(`span`,{className:`muted`,children:`(optional)`}),(0,K.jsx)(`textarea`,{value:m,onChange:e=>h(e.target.value),placeholder:Ve,rows:3})]})]})]})})]},v??u),(0,K.jsxs)(`div`,{className:`gz-npd-pane-footer gz-npd-detail-footer`,children:[ke?(0,K.jsx)(`p`,{className:`error small gz-npd-submit-error`,role:`alert`,children:ke}):(0,K.jsx)(`p`,{className:`gz-npd-footnote`,children:V?`Creating sets up the crew, tools, and starting files in one go.`:`Nothing is created until you press Create.`}),(0,K.jsxs)(E,{children:[(0,K.jsx)(`button`,{type:`button`,onClick:n,disabled:Ae,children:`Cancel`}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:Ae,children:Ae?`Creating…`:`Create`})]})]})]})})})]})})}function Kn({phase:e,onCancel:t}){let n=Dt(),r=n?.name??`Klerk`;return(0,K.jsxs)(`output`,{className:`gz-npd-repo-progress`,"aria-live":`polite`,children:[(0,K.jsx)(R,{svg:n?.icon,poppetje:n?.poppetje,iconOverride:n?.iconOverride,name:r,size:28,pulsing:!0,title:`${r} is working`}),(0,K.jsx)(`span`,{className:`gz-npd-repo-progress-text`,children:e===`reading`?`${r} is reading the repository…`:`${r} is drafting About and Mission objectives…`}),(0,K.jsx)(`button`,{type:`button`,className:`secondary gz-npd-repo-cancel`,onClick:e=>{e.preventDefault(),t()},children:`Cancel draft`})]})}function qn({inputId:e,value:t,onChange:n,onBlur:r,onSelect:i,repos:a,disabled:o}){let[s,c]=(0,G.useState)(!1),l=(0,G.useRef)(null),u=(0,G.useRef)(null),d=(0,G.useMemo)(()=>{if(a.length===0)return[];let e=t.trim().toLowerCase();return!e||a.some(t=>t.fullName.toLowerCase()===e)?a:a.filter(t=>t.fullName.toLowerCase().includes(e)||(t.description?t.description.toLowerCase().includes(e):!1))},[a,t]);(0,G.useEffect)(()=>{if(!s)return;let e=e=>{l.current&&(l.current.contains(e.target)||c(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[s]);let f=s&&d.length>0;return(0,K.jsxs)(`div`,{className:`gz-github-repo-combobox`,ref:l,children:[(0,K.jsxs)(`div`,{className:`gz-github-repo-input-row`,children:[(0,K.jsx)(`span`,{className:`gz-github-repo-prefix`,"aria-hidden":`true`,children:`github.com/`}),(0,K.jsx)(`input`,{id:e,ref:u,value:t,onChange:e=>{n(Jn(e.target.value)),s||c(!0)},onFocus:()=>c(!0),onBlur:()=>{window.setTimeout(()=>r(),120)},onKeyDown:e=>{e.key===`Escape`&&c(!1)},placeholder:`owner/repo`,disabled:o,autoComplete:`off`}),a.length>0&&(0,K.jsx)(`button`,{type:`button`,className:`gz-github-repo-chevron`,"aria-label":s?`Hide repo suggestions`:`Show repo suggestions`,"aria-expanded":s,disabled:o,onMouseDown:e=>{e.preventDefault(),c(e=>!e),u.current?.focus()},children:(0,K.jsx)(D,{style:{transform:s?`rotate(180deg)`:`none`,transition:`transform 0.12s`}})})]}),f&&(0,K.jsx)(`ul`,{className:`gz-github-repo-suggestions`,children:d.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:`gz-github-repo-suggestion`,onMouseDown:t=>{t.preventDefault(),i(e.fullName),c(!1)},children:[(0,K.jsx)(`span`,{className:`gz-github-repo-suggestion-name`,children:e.fullName}),e.description&&(0,K.jsx)(`span`,{className:`gz-github-repo-suggestion-desc`,children:e.description})]})},e.url))})]})}function Jn(e){return e.replace(/^\s*https?:\/\//i,``).replace(/^www\./i,``).replace(/^github\.com\//i,``).replace(/^\/+/,``)}function Yn(e){let t=Jn(e).trim().replace(/\.git$/i,``).replace(/\/+$/,``);return t?`https://github.com/${t}`:``}function Xn(e){let t=Jn(e).trim().replace(/\.git$/i,``).replace(/\/+$/,``);return/^[\w.-]+\/[\w.-]+$/.test(t)}function Zn(e){if(e instanceof b){let t=e.details;if(t&&typeof t==`object`&&`error`in t){let e=t.error;if(typeof e==`string`&&e.length>0)return e}return e.message}return e instanceof Error?e.message:String(e)}function Qn(e){if(!(e instanceof b))return null;let t=e.details;if(t&&typeof t==`object`&&`fixUrl`in t){let e=t.fixUrl;if(typeof e==`string`&&e.length>0)return e}return null}function $n({projectId:e,file:t,outsideIn:n,isReadOnly:r,editorTheme:i,onChange:a,onSave:o,toolbarIndexToggle:s}){let{layout:c,sourcePath:l}=n,u=ze({resourceKey:`outside-in:${e}:${t.source}:${l}`,initialValue:Et(t.content),save:async e=>{await o(e)}}),d=(0,G.useCallback)(e=>{a(e),u.update(e)},[u.update,a]),f=(0,G.useMemo)(()=>Ue({projectId:e,root:c.companionDirectory,client:x,primaryDocumentFilename:er(l),source:t.source}),[t.source,c.companionDirectory,e,l]),p=(0,G.useMemo)(()=>V(f),[f]),m=(0,G.useMemo)(()=>k(l),[l]),h=(0,G.useMemo)(()=>Ve(p,m),[p,m]),g=(0,G.useMemo)(()=>Be(p),[p]);(0,G.useEffect)(()=>()=>g.dispose(),[g]);let _=(0,G.useMemo)(()=>t.source===`artifacts`?H({client:x,currentDocumentPath:l,source:`project-artifacts`,projectId:e}):void 0,[t.source,e,l]);return(0,K.jsx)(`div`,{className:`editor-wrap`,style:{height:`100%`},children:(0,K.jsx)(P,{initialMarkdown:u.desiredValue(),fileName:l,initialView:`wysiwyg`,readOnly:r,onChange:r?void 0:d,height:`100%`,colorScheme:i,fullWidth:!0,workspaceContainer:h,mediaProvider:g,documentLinkProvider:_,calcEngineFactory:r?void 0:U,allowVersioning:!r,versionBasename:m,outline:!0,toolbarSlotAfterActions:(0,K.jsxs)(K.Fragment,{children:[!r&&(0,K.jsx)(Ot,{context:`generic`}),(0,K.jsx)(Je,{fileName:t.path,projectId:e})]}),toolbarSlotRight:(0,K.jsxs)(K.Fragment,{children:[s,!r&&(0,K.jsx)(He,{autosave:u}),!r&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>void u.flush(),style:{marginLeft:`0.5rem`},children:[`Save `,c.format.toUpperCase()]}),t.source===`artifacts`&&(0,K.jsx)(B,{selectedFile:t.path,mediaContainer:p,mediaSource:{kind:`project-artifacts`,projectId:e}})]})})})}function er(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function tr(e){return e.kind===`console.error`?(e.detail.args??[]).join(` `):e.detail.message??`(unknown error)`}function nr(e,t){let n=[];n.push(`I was previewing \`${t.source}/${t.path}\` and the browser surfaced a JavaScript error.`),n.push(``),n.push(`- **Kind:** ${e.kind}`);let r=tr(e);if(r&&n.push(`- **Message:** ${r}`),e.detail.filename){let t=[e.detail.filename,e.detail.lineno?String(e.detail.lineno):null,e.detail.colno?String(e.detail.colno):null].filter(Boolean).join(`:`);n.push(`- **Location:** ${t}`)}return e.url&&n.push(`- **Preview URL:** ${e.url}`),e.detail.stack&&(n.push(``),n.push(`Stack trace:`),n.push("```"),n.push(e.detail.stack),n.push("```")),n.push(``),n.push(`Can you take a look and figure out what's going wrong? Feel free to edit the file directly.`),n.join(`
7
+ `)}var rr=()=>N(()=>import(`./ProjectChat-YEqUME6k.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73])),ir=()=>N(()=>import(`./ProjectConnectionsTab-dFCJpW93.js`),__vite__mapDeps([74,1,2,4,5,3,11,21,6,7,8,37,13,14,9,10,15,16,17,18,19,20,22,23,24,25,26,27,28,29,30,31,32,12,33,34,35,36,38,39])),ar=()=>N(()=>import(`./ProjectMailTab-NaScsZJf.js`),__vite__mapDeps([75,1,2,4,5,3,11,76])),or=()=>N(()=>import(`./DiffpackReviewView-EFLGJnwr.js`),__vite__mapDeps([77,1,2,3,4,5,11,21,6,7,8,71,72,78,48,23,24,25,26,27,28,29,30,31,32,12,33,34,35,49,38,13,14,9,10,15,16,17,18,19,20,22,36,37,39,50,51,52,43,53,42,54,79])),sr=()=>N(()=>import(`./FileMapView-DRjf59RH.js`),__vite__mapDeps([80,1,2,3,4,5,6,7,8,48,23,24,25,26,27,28,29,30,31,32,12,33,34,35,49,38,13,14,9,10,11,15,16,17,18,19,20,21,22,36,37,39,50,51,52,43,53,42,54,78])),cr=()=>N(()=>import(`./HistoryView-E2szGNGS.js`),__vite__mapDeps([81,1,2,4,5,3,6,7,8,11,13,14,9,10,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,12,33,34,35,36,37,38,39])),lr=()=>N(()=>import(`./ProjectGithubView-CQ4-tmPx.js`),__vite__mapDeps([82,1,2,5,3,4,8,7,6,11,21,71,72,78,48,23,24,25,26,27,28,29,30,31,32,12,33,34,35,49,38,13,14,9,10,15,16,17,18,19,20,22,36,37,39,50,51,52,43,53,42,54,83,84])),ur=()=>N(()=>import(`./ProjectOverviewView-ChjxbQas.js`),__vite__mapDeps([85,1,2,3,4,5,21,6,7,8,13,14,9,10,11,15,16,17,18,19,20,22,23,24,25,26,27,28,29,30,31,32,12,33,34,35,36,37,38,39,78,48,49,50,51,52,43,53,42,54,86])),dr=()=>N(()=>import(`./TasksView-BVMT4BAY.js`),__vite__mapDeps([87,1,2,4,5,3,6,7,8,9,10,40,41,26,27,25,32,35,36,42,28,24,31,43,30,37,13,14,11,15,16,17,18,19,20,21,22,23,29,12,33,34,38,39,44,45,46,88,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,47,65,66,67,68,78,89,90,91])),fr=(0,G.lazy)(()=>rr().then(({ProjectChat:e})=>({default:e}))),pr=(0,G.lazy)(()=>ir().then(({ProjectConnectionsTab:e})=>({default:e}))),mr=(0,G.lazy)(()=>ar().then(({ProjectMailTab:e})=>({default:e}))),hr=(0,G.lazy)(()=>or().then(({DiffpackReviewView:e})=>({default:e}))),gr=(0,G.lazy)(()=>sr().then(({FileMapView:e})=>({default:e}))),_r=(0,G.lazy)(()=>cr().then(({HistoryView:e})=>({default:e}))),vr=(0,G.lazy)(()=>lr().then(({ProjectGitHubView:e})=>({default:e}))),yr=(0,G.lazy)(()=>ur().then(({ProjectOverviewView:e})=>({default:e}))),br=(0,G.lazy)(()=>dr().then(({TasksView:e})=>({default:e}))),xr=`gezel:projects:selectedId`;function Sr(e){return/\.html?$/i.test(e)}function Cr(e){return/\.(md|markdown|mdx)$/i.test(e)}function wr(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function Tr(e,t){if(!t)return 0;if(!e.isDirectory)return t.issues.filter(t=>t.path===e.path).length;let n=`${e.path.replace(/\/$/,``)}/`;return t.issues.filter(e=>e.path.startsWith(n)).length}function Er(e){let t;switch(e){case`chat`:t=rr();break;case`tasks`:t=dr();break;case`proposals`:t=or();break;case`github`:t=lr();break;case`mail`:t=ar();break;case`map`:t=sr();break;case`overview`:t=ur();break;case`about`:t=Promise.all([ir(),cr()]);break;default:break}t?.catch(()=>{})}function Dr({children:e}){return(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`p`,{className:`placeholder project-pane-loading`,children:`Loading view…`}),children:e})}var Or=[{key:`overview`,label:`Overview`},{key:`tasks`,label:`Tasks`},{key:`approvals`,label:`Approvals`},{key:`workspace`,label:`Workspace`},{key:`artifacts`,label:`Artifacts`},{key:`map`,label:`Village`}];function kr(e,t){return t===`map`?e.tabVisibility?.map??zr(e):e.tabVisibility?.[t]!==!1}var Ar=`gezel:project-output-fraction:v2`,jr=.18,Mr=.7,Q=.42;function Nr(e){return Number.isFinite(e)?Math.max(jr,Math.min(Mr,e)):Q}function Pr(){if(typeof window>`u`)return Q;try{let e=window.localStorage.getItem(Ar);return e?Nr(Number.parseFloat(e)):Q}catch{return Q}}function Fr(e){return`gezel.projectOutputVisible:${e}`}function Ir(e){try{let t=window.localStorage.getItem(Fr(e));return t===null?null:t===`1`}catch{return null}}function Lr(e){try{window.localStorage.removeItem(Fr(e))}catch{}}var Rr=new Set([`content-writing`,`media-production`,`design-prototype`]);function zr(e){let t=d(e);return!t||!Rr.has(t)}function Br(e){return d(e)===`email`||(e.connectors??[]).some(e=>e.type.startsWith(`mail-`))}function Vr({tab:e}){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.4,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:Hr(e)})}function Hr(e){switch(e){case`output`:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`1.8`,y:`2.8`,width:`12.4`,height:`8.4`,rx:`1.2`}),(0,K.jsx)(`path`,{d:`M6.5 5.6 L9.8 7.5 L6.5 9.4 Z`,fill:`currentColor`,stroke:`none`}),(0,K.jsx)(`line`,{x1:`5.5`,y1:`13.4`,x2:`10.5`,y2:`13.4`})]});case`chat`:return(0,K.jsx)(`path`,{d:`M2.6 4.2A1.6 1.6 0 0 1 4.2 2.6h7.6a1.6 1.6 0 0 1 1.6 1.6v4.4a1.6 1.6 0 0 1-1.6 1.6H6.4L3.4 13V8.6A1.6 1.6 0 0 1 2.6 7Z`});case`about`:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`}),(0,K.jsx)(`line`,{x1:`8`,y1:`7.4`,x2:`8`,y2:`11`}),(0,K.jsx)(`circle`,{cx:`8`,cy:`5`,r:`0.5`,fill:`currentColor`,stroke:`none`})]});case`tasks`:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`2.6`,y:`2.6`,width:`10.8`,height:`10.8`,rx:`2`}),(0,K.jsx)(`path`,{d:`M5.4 8 L7.2 9.8 L10.6 6`})]});case`packages`:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M8 2.4 L12.6 4 V7.2 C12.6 10 10.6 12 8 13.2 C5.4 12 3.4 10 3.4 7.2 V4 Z`}),(0,K.jsx)(`path`,{d:`M6 7.6 L7.4 9 L10 5.9`})]});case`workspace`:return(0,K.jsx)(`path`,{d:`M2.6 5.4 A1 1 0 0 1 3.6 4.4 H6 L7.3 5.8 H12.4 A1 1 0 0 1 13.4 6.8 V11.6 A1 1 0 0 1 12.4 12.6 H3.6 A1 1 0 0 1 2.6 11.6 Z`});case`artifacts`:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M4.4 2.6 H8.6 L11.6 5.6 V13 A0.4 0.4 0 0 1 11.2 13.4 H4.4 A0.4 0.4 0 0 1 4 13 V3 A0.4 0.4 0 0 1 4.4 2.6 Z`}),(0,K.jsx)(`path`,{d:`M8.4 2.6 V5.6 H11.4`})]});case`github`:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`4.6`,cy:`4.2`,r:`1.5`}),(0,K.jsx)(`circle`,{cx:`4.6`,cy:`11.8`,r:`1.5`}),(0,K.jsx)(`circle`,{cx:`11.4`,cy:`5.6`,r:`1.5`}),(0,K.jsx)(`path`,{d:`M4.6 5.7 V10.3`}),(0,K.jsx)(`path`,{d:`M11.4 7.1 C11.4 9.4 9.4 9.6 7.2 9.7 C5.6 9.8 4.6 10 4.6 11`})]});case`mail`:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`2.5`,y:`4`,width:`11`,height:`8`,rx:`0.7`}),(0,K.jsx)(`path`,{d:`M2.8 4.6 L8 8.6 L13.2 4.6`})]});case`connections`:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M6 10 L4.2 11.8 A2.2 2.2 0 0 1 4.2 8.6 L5.6 7.2`}),(0,K.jsx)(`path`,{d:`M10 6 L11.8 4.2 A2.2 2.2 0 0 1 11.8 7.4 L10.4 8.8`}),(0,K.jsx)(`path`,{d:`M6.4 9.6 L9.6 6.4`})]});case`history`:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`}),(0,K.jsx)(`path`,{d:`M8 4.6 V8 L10.4 9.4`})]});case`map`:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M1.6 13.4 V7.2 L5.6 3.8 L9.6 7.2 V13.4`}),(0,K.jsx)(`path`,{d:`M9.6 13.4 V9 L12 6.9 L14.4 9 V13.4`}),(0,K.jsx)(`path`,{d:`M4.4 13.4 V10.2 H6.8 V13.4`}),(0,K.jsx)(`path`,{d:`M1.2 13.4 H14.8`})]});case`overview`:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5.8`}),(0,K.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.4`,fill:`currentColor`,stroke:`none`}),(0,K.jsx)(`line`,{x1:`8`,y1:`2.2`,x2:`8`,y2:`4.4`}),(0,K.jsx)(`line`,{x1:`8`,y1:`11.6`,x2:`8`,y2:`13.8`}),(0,K.jsx)(`line`,{x1:`2.2`,y1:`8`,x2:`4.4`,y2:`8`}),(0,K.jsx)(`line`,{x1:`11.6`,y1:`8`,x2:`13.8`,y2:`8`})]});default:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`line`,{x1:`3`,y1:`5`,x2:`13`,y2:`5`}),(0,K.jsx)(`line`,{x1:`3`,y1:`11`,x2:`13`,y2:`11`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`5`,r:`1.5`,fill:`var(--panel)`}),(0,K.jsx)(`circle`,{cx:`10`,cy:`11`,r:`1.5`,fill:`var(--panel)`})]})}}function Ur(e){return e.stored?e.allowedOrigins.length===0?e.originSource===`webhook`?`Configure an HTTPS webhook URL in Settings → Channels first`:`No HTTPS destination configured`:`Restricted to ${e.allowedOrigins.map(e=>{try{return new URL(e).host}catch{return e}}).join(`, `)}`:null}function Wr({projectId:e,compact:t=!1}){return(0,K.jsx)(Gr,{forceProjectId:e,compact:t})}function Gr({forceProjectId:e,compact:t=!1}={}){let n=e!==void 0,r=Ke(),a=(0,G.useRef)(null),o=mt(a),s=t||o,c=Ne(),[l,d]=(0,G.useState)([]),[f,h]=(0,G.useState)(null),[g,y]=(0,G.useState)(!1),[ee,b]=(0,G.useState)(void 0),[T,E]=(0,G.useState)(null),[te,ne]=(0,G.useState)(``),[re,ie]=(0,G.useState)(``),[le,D]=(0,G.useState)(null),[k,A]=(0,G.useState)({}),[j,Ce]=(0,G.useState)(null),[P,F]=(0,G.useState)(`chat`);(0,G.useEffect)(()=>{!r&&P===`mail`&&F(`about`)},[r,P]);let[I,we]=(0,G.useState)(()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`gezel.projectsSidebarCollapsed`)===`1`}catch{return!1}});(0,G.useEffect)(()=>{try{window.localStorage.setItem(`gezel.projectsSidebarCollapsed`,I?`1`:`0`)}catch{}},[I]);let L=P===`workspace`?`workspace`:P===`artifacts`?`artifacts`:null,[Te,Ee]=(0,G.useState)([]),[De,Oe]=(0,G.useState)([]),[R,Ae]=(0,G.useState)([]),[Fe,Ie]=(0,G.useState)(!1),[Le,ze]=(0,G.useState)(!1),[Be,Ve]=(0,G.useState)({workspace:`tree-alpha`,artifacts:`tree-alpha`}),[He,We]=(0,G.useState)({workspace:!1,artifacts:!1}),[Ge,Je]=(0,G.useState)(null),[B,H]=(0,G.useState)(null),[U,pt]=(0,G.useState)(null),[W,ht]=(0,G.useState)(null),[gt,Et]=(0,G.useState)(null),[Dt,Ot]=(0,G.useState)(null),[kt,At]=(0,G.useState)(!1),[Mt,Nt]=(0,G.useState)(null),[It,Lt]=(0,G.useState)(!1),[q,Rt]=(0,G.useState)(null),[zt,Bt]=(0,G.useState)(null),[Vt,Ht]=(0,G.useState)(null),[Ut,Wt]=(0,G.useState)(null),[Gt,Kt]=(0,G.useState)([]),[qt,Xt]=(0,G.useState)(null),[J,Zt]=(0,G.useState)(null),[Qt,$t]=(0,G.useState)(),[en,tn]=(0,G.useState)(``),[nn,rn]=(0,G.useState)(!1),[an,sn]=(0,G.useState)([]),[cn,ln]=(0,G.useState)(``),[un,dn]=(0,G.useState)(``),[fn,pn]=(0,G.useState)(!1),[mn,hn]=(0,G.useState)([]),gn=mn.filter(e=>e.stored),Y=(0,G.useCallback)(async()=>{try{d((await x.listProjects()).projects)}catch(e){D(e.message)}},[]),yn=(0,G.useMemo)(()=>l.filter(e=>!e.archived),[l]),bn=(0,G.useMemo)(()=>l.filter(e=>e.archived),[l]),xn=(0,G.useMemo)(()=>{if(!f)return[];let e=new Set(f.linkedProjectIds??[]);return l.filter(t=>t.id!==f.id&&!_(t)&&(!t.archived||e.has(t.id)))},[l,f]),Sn=(f?.linkedProjectIds?.length??0)>=32;(0,G.useEffect)(()=>{Y()},[Y]),(0,G.useEffect)(()=>{let e=e=>{let t=e.detail;if(t?.projectId){if(!t.project){Y();return}d(e=>e.map(e=>e.id===t.projectId?{...e,...t.project}:e)),h(e=>e?.id===t.projectId?t.project:e)}};return window.addEventListener(`gezel:project-updated`,e),()=>window.removeEventListener(`gezel:project-updated`,e)},[Y]),(0,G.useEffect)(()=>{if(n)return;je(`project`)&&E(`crew`);let e=()=>{je(`project`),E(`crew`)};return window.addEventListener(`gezel:new-project`,e),()=>window.removeEventListener(`gezel:new-project`,e)},[n]),(0,G.useEffect)(()=>{let e=e=>{let t=e.detail?.projectId;Y(),t&&h(e=>e?.id===t?null:e)};return window.addEventListener(`gezel:project-deleted`,e),()=>window.removeEventListener(`gezel:project-deleted`,e)},[Y]);let Cn=(0,G.useCallback)(async()=>{try{Kt((await x.listGezels()).gezels)}catch(e){console.error(`[ProjectsView] listGezels failed`,e)}},[]),wn=(0,G.useCallback)(async()=>{try{let e=await x.getConfig();$t(e.boekwachterGezelId),Zt(e)}catch{}},[]);(0,G.useEffect)(()=>{Cn(),wn()},[Cn,wn]),(0,G.useEffect)(()=>{let e=()=>void wn();return window.addEventListener(`gezel:config-updated`,e),()=>window.removeEventListener(`gezel:config-updated`,e)},[wn]),(0,G.useEffect)(()=>{let e=()=>void Cn();return window.addEventListener(`gezel:gezel-updated`,e),()=>window.removeEventListener(`gezel:gezel-updated`,e)},[Cn]);let X=f?.id;(0,G.useEffect)(()=>{if(!X){Xt(null);return}let e=!1,t=()=>{x.listProjectLocalGezels(X).then(t=>{e||Xt({projectId:X,gezels:t.gezels})}).catch(()=>{e||Xt({projectId:X,gezels:[]})})},n=()=>t();return t(),window.addEventListener(`gezel:gezel-updated`,n),()=>{e=!0,window.removeEventListener(`gezel:gezel-updated`,n)}},[X]);let En=(0,G.useMemo)(()=>{if(!f)return{managedWritable:!0,nativeWritable:!1,effectiveWritable:!0,codexInUse:!1,claudeInUse:!1,claudeMode:`acceptEdits`};let e=qt?.projectId===f.id?qt.gezels:[];return{...On(f,Gt,e,J),codexInUse:kn(f,Gt,e,J),claudeInUse:An(f,Gt,e,J),claudeMode:jn(f,Gt,e,J)}},[f,Gt,qt,J]),Dn=i(f?.codexPermissionMode??J?.codexCli?.defaultPermissionMode),Mn=(0,G.useCallback)(async e=>{if(!f)return;let t=await x.addGezelToProject(f.id,e);b(e),h(e=>e?.id===f.id?{...e,gezelIds:t.gezelIds}:e)},[f]),Nn=(0,G.useCallback)(async e=>{if(!f)return;let t=await x.removeGezelFromProject(f.id,e);h(e=>e?.id===f.id?{...e,gezelIds:t.gezelIds}:e)},[f]),Pn=(0,G.useCallback)(async(e,t)=>{if(!f)return;let n=f.id,r=await x.createGezelFromTemplate(e,{name:t.name,...t.gender?{gender:t.gender}:{}});if(t.appearanceSeed!==void 0){let{poppetje:e}=await x.rerollGezelPoppetje(r.id,{seed:t.appearanceSeed});r={...r,poppetje:e}}let i=await x.addGezelToProject(n,r.id);b(r.id),Kt(e=>[...e.filter(e=>e.id!==r.id),r]),h(e=>e?.id===n?{...e,gezelIds:i.gezelIds}:e),window.dispatchEvent(new CustomEvent(`gezel:gezel-updated`,{detail:r}))},[f]),Fn=He.workspace,In=He.artifacts,Ln=(0,G.useCallback)(async e=>{let[t,n]=await Promise.all([x.listProjectWorkspace(e,``,!0,{stats:!0,hidden:Fn}),x.listProjectArtifacts(e,``,!0,{stats:!0,hidden:In})]);Ee(t.files),Ae(n.files),Ie(t.truncated===!0),ze(n.truncated===!0)},[Fn,In]),Rn=(0,G.useCallback)(async e=>{let t=await x.listProjectWorkspaceHtmlPages(e);Oe(t.files.map(e=>e.path))},[]),zn=(0,G.useCallback)(async e=>{await Promise.all([Ln(e),Rn(e)])},[Ln,Rn]);(0,G.useEffect)(()=>{L===null||!f||zn(f.id)},[L,f,zn]),(0,G.useEffect)(()=>{if(L!==`workspace`||!X)return;let e=!1;pt(null),ht(null),Et(null);let t=async()=>{let[t,n]=await Promise.allSettled([x.getProjectIndexStatus(X),x.toolListFileIssues(X,{maxResults:1e3})]);if(!e)if(t.status===`fulfilled`&&pt(t.value),n.status===`fulfilled`&&ht(n.value),t.status===`rejected`&&n.status===`rejected`){let e=t.reason;Et(e instanceof Error?e.message:String(e))}else Et(null)};t();let n=window.setInterval(()=>void t(),3e4);return()=>{e=!0,window.clearInterval(n)}},[L,X]),(0,G.useEffect)(()=>{if(Je(null),!X){Ve({workspace:`tree-alpha`,artifacts:`tree-alpha`}),We({workspace:!1,artifacts:!1});return}let e=`tree-alpha`,t=`tree-alpha`,n=!1,r=!1;try{e=me(window.localStorage.getItem(fe(X,`workspace`)),`workspace`),t=me(window.localStorage.getItem(fe(X,`artifacts`)),`artifacts`),n=window.localStorage.getItem(be(X,`workspace`))===`1`,r=window.localStorage.getItem(be(X,`artifacts`))===`1`}catch{}Ve({workspace:e,artifacts:t}),We({workspace:n,artifacts:r})},[X]);let Bn=(0,G.useCallback)((e,t)=>{if(Ve(n=>({...n,[e]:t})),X)try{window.localStorage.setItem(fe(X,e),t)}catch{}},[X]),Vn=(0,G.useCallback)((e,t)=>{if(We(n=>({...n,[e]:t})),X)try{window.localStorage.setItem(be(X,e),t?`1`:`0`)}catch{}},[X]),Hn=Be.workspace,Un=U?.meta?.scannedAt;(0,G.useEffect)(()=>{if(L!==`workspace`||Hn!==`flat-modified`||!X)return;let e=!1;return x.listProjectIndexFilesDetail(X,{hidden:Fn}).then(t=>{e||Je(t.files)}).catch(()=>{e||Je(null)}),()=>{e=!0}},[L,Hn,X,Un,Fn]);let Z=L===`workspace`&&B?.source===`workspace`?B.path:null,Wn=U?.enrichment?.reviews?.reviewed;(0,G.useEffect)(()=>{if(!X||!Z){Ot(null),At(!1),Nt(null);return}let e=!1;return Ot(null),At(!0),Nt(null),x.toolFileReview(X,{path:Z}).then(t=>{e||Ot(t)}).catch(t=>{e||Nt(t instanceof Error?t.message:String(t))}).finally(()=>{e||At(!1)}),()=>{e=!0}},[X,Z,Wn]);let Kn=(0,G.useCallback)(async()=>{if(!X)return;let[e,t]=await Promise.all([x.toolListFileIssues(X,{maxResults:1e3}),Z?x.toolFileReview(X,{path:Z}):Promise.resolve(null)]);ht(e),t&&Ot(t)},[X,Z]),qn=(0,G.useCallback)(async(e,t)=>{X&&(await x.updateBoekwachterIssue(X,{ref:e.ref,...t}),await Kn())},[Kn,X]);(0,G.useEffect)(()=>{if(P!==`packages`||!f){A({}),Ce(null);return}x.listPackageScripts(f.id).then(e=>A(e.scripts)).catch(e=>{console.warn(`[ProjectsView] listPackageScripts failed`,e),A({})}),x.getProjectApprovals(f.id).then(Ce).catch(e=>{console.warn(`[ProjectsView] getProjectApprovals failed`,e),Ce(null)})},[P,f]),(0,G.useEffect)(()=>{H(null)},[L]),(0,G.useEffect)(()=>{if(P!==`about`||!f)return;let e=!1;return(async()=>{try{let t=await x.listWorkspaceWrites(f.id,20);e||sn(t.entries)}catch{}try{let t=await x.listAvailableCredentials();e||hn(t.credentials.map(e=>{let t=e;return{name:e.name,label:e.label,stored:e.stored,allowedOrigins:t.allowedOrigins??e.defaultOrigins,originSource:t.originSource??(e.name.startsWith(`webhook.`)?`webhook`:`provider`)}}))}catch{}})(),()=>{e=!0}},[P,f]);let Jn=(0,G.useCallback)(async(e,t)=>{if(!f)return;let n=f.grantedCredentials??[],r=t?Array.from(new Set([...n,e])):n.filter(t=>t!==e),i=mn.find(t=>t.name===e);if(t&&(i?.allowedOrigins.length??0)===0){D(`Configure an HTTPS destination for ${e} before granting it.`);return}try{let e=await x.updateProject(f.id,{grantedCredentials:r});h(e),D(null)}catch(e){D(e.message)}},[f,mn]),Yn=(0,G.useCallback)((e,t)=>{if(!f)return;let n=nr(e,t);ft(f.id,n),F(`chat`)},[f]),Xn=(0,G.useCallback)(e=>{f&&(ft(f.id,e),F(`chat`))},[f]),Zn=(0,G.useCallback)(async e=>{let t=await x.getProject(e);h(t),H(null),Ee([]),Oe([]),Ae([]),Lt(!1),F(`chat`),tn(t.workingDir??``),ln(t.github?.url??``),dn(``),await Rn(e),window.dispatchEvent(new CustomEvent(`gezel:project-opened`,{detail:{id:t.id,name:t.name}}))},[Rn]),Qn=(0,G.useCallback)(async(e,t,n,r)=>{F(n);let i=Xe(t.slice(t.lastIndexOf(`/`)+1));if(i){H({path:t,content:i,source:n});return}let a=n===`workspace`?await x.readProjectWorkspaceFile(e,t):await x.readProjectArtifact(e,t),o=qe(a.content)?Ye:a.content;H({...a,content:o,source:n}),r&&Bt(e=>({path:t,line:r,requestId:(e?.requestId??0)+1}))},[]);(0,G.useEffect)(()=>{let e=e=>{let t=e.detail;t?.projectId&&Zn(t.projectId)};return window.addEventListener(`gezel:open-project`,e),()=>window.removeEventListener(`gezel:open-project`,e)},[Zn]),(0,G.useEffect)(()=>{let e=e=>{let t=e.detail;t?.projectId&&f&&t.projectId!==f.id||F(`settings`)};return window.addEventListener(`gezel:open-project-settings`,e),()=>window.removeEventListener(`gezel:open-project-settings`,e)},[f]),(0,G.useEffect)(()=>{let e=e=>{let t=e.detail;!t?.path||!t.source||f&&(!t.projectId||t.projectId===f.id)&&(z(f.id),Qn(f.id,t.path,t.source,t.line))};return window.addEventListener(`gezel:open-file`,e),()=>window.removeEventListener(`gezel:open-file`,e)},[f,Qn]),(0,G.useEffect)(()=>{e&&Zn(e).then(()=>{let t=z(e);t&&Qn(e,t.path,t.source,t.line)})},[e,Zn,Qn]);let er=(0,G.useCallback)(async e=>{await Y(),h(e),H(null),Ee([]),Oe([]),Ae([]),Lt(!1),F(`chat`),tn(``),ln(``),dn(``),await Rn(e.id)},[Y,Rn]),tr=(0,G.useCallback)(async()=>{if(!(!f||!te.trim())){ie(`installing…`);try{let e=await x.installPackage(f.id,{name:te.trim()});ie(e.log),h(e.project),ne(``)}catch(e){ie(e.message)}}},[te,f]),rr=(0,G.useCallback)(async e=>{if(!f)return;let t=e.trim();if(t!==(f.github?.url??``))try{if(t===``){let e=await x.updateProject(f.id,{github:null});h(e),dn(`Unlinked.`);return}let e=await x.updateProject(f.id,{github:{url:t}});h(e),dn(`Cloning…`);try{let e=await x.cloneProjectGit(f.id),t=await x.getProject(f.id);h(t),dn(e.adopted?`Adopted existing checkout.`:`Cloned.`)}catch(e){let t=e.message||`clone failed`;dn(`Linked, but clone failed: ${t}`)}}catch(e){dn(`save failed: ${e.message}`)}},[f]),ir=(0,G.useCallback)(async e=>{if(!f)return;let t=e.trim()||void 0;if(t!==(f.workingDir??void 0))try{let e=await x.setProjectWorkingDir(f.id,t);h(e),await zn(f.id)}catch(e){console.error(`setProjectWorkingDir failed:`,e)}},[f,zn]),ar=(0,G.useCallback)(async e=>{if(f)try{let t=await x.updateProject(f.id,{managedWorkspaceWritePolicy:e?`allow`:`deny`});h(t)}catch(e){console.error(`updateProject(managedWorkspaceWritePolicy) failed:`,e)}},[f]),or=(0,G.useCallback)(async e=>{if(f)try{let t=await x.updateProject(f.id,{codexPermissionMode:e});h(t)}catch(e){console.error(`updateProject(codexPermissionMode) failed:`,e)}},[f]),sr=(0,G.useCallback)(async e=>{if(f)try{let t=await x.updateProject(f.id,{claudePermissionMode:e});h(t)}catch(e){console.error(`updateProject(claudePermissionMode) failed:`,e)}},[f]),cr=(0,G.useCallback)(async e=>{if(f)try{let t=await x.updateProject(f.id,{indexingEnabled:e});h(t),e&&x.refreshProjectIndex(f.id).catch(()=>{})}catch(e){console.error(`updateProject(indexingEnabled) failed:`,e)}},[f]),lr=(0,G.useCallback)(async e=>{if(f)try{h(await x.updateProject(f.id,{nightlyFixesEnabled:e}))}catch(e){console.error(`updateProject(nightlyFixesEnabled) failed:`,e)}},[f]),ur=(0,G.useCallback)(async(e,t)=>{if(!f||fn)return;let n=f.linkedProjectIds??[],r=t?Array.from(new Set([...n,e])):n.filter(t=>t!==e);pn(!0);try{let e=await x.updateProject(f.id,{linkedProjectIds:r});h(e),d(t=>t.map(t=>t.id===e.id?{...t,...e}:t))}catch(e){D(e instanceof Error?e.message:String(e))}finally{pn(!1)}},[fn,f]),dr=(0,G.useCallback)(async e=>{if(f)try{let t=await x.updateProject(f.id,{nudgeConfig:{...f.nudgeConfig,enabled:!e}});h(t)}catch(e){D(e.message)}},[f]),Cr=(0,G.useCallback)(async(e,t)=>{if(f)try{let n=await x.updateProject(f.id,{tabVisibility:{...f.tabVisibility,[e]:t}});h(n),D(null)}catch(e){D(e.message)}},[f]),Q=(0,G.useCallback)(e=>e===`artifacts`||u(f),[f]),Fr=(0,G.useCallback)(async(e,t)=>{if(!f)throw Error(`Open a project before viewing this document.`);let n=lt(e.path);if(!n)throw Error(`This file does not support a Markdown companion.`);let r=ut(n,(t===`workspace`?Te:R).filter(e=>!e.isDirectory).map(e=>e.path)),i;if(r)i=(t===`workspace`?await x.readProjectWorkspaceFile(f.id,r):await x.readProjectArtifact(f.id,r)).content;else{if(!Q(t))throw Error(`Enable workspace writes for this external project before importing its Markdown companion.`);let a=await ot(await(t===`workspace`?await x.fetchProjectWorkspaceBlob(f.id,e.path):await x.fetchProjectArtifactBlob(f.id,e.path)).arrayBuffer(),n),o=Ue({projectId:f.id,root:n.companionDirectory,client:x,primaryDocumentFilename:n.markdownFilename,source:t});for(let e of await a.container.listFiles()){if(/\.md$/i.test(e.path))continue;let t=await a.container.readFile(e.path);t&&await o.writeFile(e.path,t,e.mimeType)}await o.writeDocument(a.markdown,n.markdownFilename),r=n.markdownPath,i=a.markdown,await Ln(f.id)}let a=it(i,n);return a!==i&&Q(t)&&(t===`workspace`?await x.writeProjectWorkspaceFile(f.id,{path:r,content:a}):await x.writeProjectArtifact(f.id,r,a)),{layout:{...n,markdownPath:r},sourcePath:r,content:a,editingEnabled:at(n.format)&&ct(a)}},[f,Te,R,Q,Ln]),Rr=(0,G.useCallback)(async(e,t)=>{if(!f||e.isDirectory)return;if(lt(e.path)){try{let n=await Fr(e,t);H({path:e.path,content:n.content,source:t,outsideIn:{layout:n.layout,sourcePath:n.sourcePath,editingEnabled:n.editingEnabled}}),D(null)}catch(e){D(e instanceof Error?e.message:`Could not open this rendered document.`)}return}let n=Xe(e.name);if(n)H({path:e.path,content:n,source:t});else{let n=t===`workspace`?await x.readProjectWorkspaceFile(f.id,e.path):await x.readProjectArtifact(f.id,e.path),r=qe(n.content)?Ye:n.content;H({...n,content:r,source:t})}},[f,Fr]),zr=(0,G.useCallback)(async(e,t)=>{if(!f||e.isDirectory)return;let n=lt(e.path);if(!n||!at(n.format)){D(`CSV data previews are read-only.`);return}if(!Q(t)){D(`Enable workspace writes before allowing Markdown editing.`);return}try{let n=await Fr(e,t),r=t===`workspace`?await x.fetchProjectWorkspaceBlob(f.id,n.layout.targetPath):await x.fetchProjectArtifactBlob(f.id,n.layout.targetPath);try{t===`workspace`?await x.writeProjectWorkspaceBinary(f.id,n.layout.backupPath,r,r.type||`application/octet-stream`,{createOnly:!0}):await x.writeProjectArtifactBinary(f.id,n.layout.backupPath,r,r.type||`application/octet-stream`,{createOnly:!0})}catch(e){if(!(e instanceof Error)||!e.message.includes(`already exists`))throw e}let i=dt(n.content,n.layout);t===`workspace`?await x.writeProjectWorkspaceFile(f.id,{path:n.sourcePath,content:i}):await x.writeProjectArtifact(f.id,n.sourcePath,i),H({path:e.path,content:i,source:t,outsideIn:{layout:n.layout,sourcePath:n.sourcePath,editingEnabled:!0}}),D(null),await Ln(f.id)}catch(e){D(e instanceof Error?e.message:`Could not enable Markdown editing.`)}},[f,Q,Fr,Ln]),Hr=(0,G.useCallback)(e=>{H(t=>t&&{...t,content:e})},[]),Wr=(0,G.useCallback)(async e=>{if(!f||!B||Ze.has(B.content))return;let t=e??B.content;if(B.outsideIn){if(!Q(B.source)||!B.outsideIn.editingEnabled)return;let{layout:e,sourcePath:n}=B.outsideIn,r=V(Ue({projectId:f.id,root:e.companionDirectory,client:x,primaryDocumentFilename:wr(n),source:B.source})),i=B.source===`workspace`?Te:R,a=e.format===`html`?rt(e.targetPath,new Set(i.filter(e=>e.isDirectory).map(e=>e.path.replace(/^\/+/,``)))):void 0,o=it(t,e),s=await st(o,e,r,a?nt(e.parentDirectory,a):void 0);if(B.source===`workspace`?await x.writeProjectWorkspaceFile(f.id,{path:n,content:o}):await x.writeProjectArtifact(f.id,n,o),a){let{PLAYER_BUNDLE:e}=await N(async()=>{let{PLAYER_BUNDLE:e}=await import(`./standalone-source-q_Zzd1bd.js`);return{PLAYER_BUNDLE:e}},[]);B.source===`workspace`?await x.writeProjectWorkspaceFile(f.id,{path:a,content:e}):await x.writeProjectArtifact(f.id,a,e)}B.source===`workspace`?await x.writeProjectWorkspaceBinary(f.id,e.targetPath,s.bytes,s.mimeType):await x.writeProjectArtifactBinary(f.id,e.targetPath,s.bytes,s.mimeType),H(e=>e?.path===B.path&&e.source===B.source?{...e,content:o}:e),await zn(f.id);return}Q(B.source)&&(B.source===`workspace`?await x.writeProjectWorkspaceFile(f.id,{path:B.path,content:t}):await x.writeProjectArtifact(f.id,B.path,t))},[f,B,Q,Te,R,zn]);(0,G.useCallback)((e,t)=>f?`/api/projects/${f.id}/${t===`workspace`?`workspace`:`artifacts`}/read?path=${encodeURIComponent(e)}&raw=1`:``,[f]);let Gr=L===`workspace`?Te:R,Yr=L?He[L]:!1,Qr=(0,G.useMemo)(()=>Yr?Gr:Gr.filter(e=>!m(e.path)),[Gr,Yr]),$=L?Be[L]:`tree-alpha`,$r=(0,G.useMemo)(()=>$===`flat-modified`?L===`workspace`&&Ge&&Ge.length>0?Ge.filter(e=>Yr||!m(e.path)).map(e=>ve(e.path,e.mtimeMs)).sort(pe):Qr.filter(e=>!e.isDirectory).slice().sort(pe):[],[$,L,Ge,Qr,Yr]),ei=(0,G.useMemo)(()=>ge(W?.issues??[]),[W]),ti=(0,G.useMemo)(()=>new Map(ei.map(e=>[e.path,e])),[ei]),ni=(0,G.useMemo)(()=>$!==`flat-issues`&&$!==`flat-criticality`?[]:ye(ei,$===`flat-issues`?`count`:`score`).map(e=>ve(e.path)),[$,ei]),ri=$===`flat-modified`&&L===`workspace`&&Ge!==null&&Ge.length>0,ii=(0,G.useMemo)(()=>$===`flat-issues`||$===`flat-criticality`?{entries:ni,emptyMessage:`No open review issues.`,onSelect:e=>{L&&(Rr(e,L),Lt(!0))},trailingForEntry:e=>{let t=ti.get(e.path);return t?(0,K.jsxs)(K.Fragment,{children:[$===`flat-criticality`?(0,K.jsx)(`span`,{className:`file-flat-score`,title:`Criticality score ${t.score}`,children:t.score}):(0,K.jsx)(`span`,{className:`workspace-tree-issue-count`,title:`${t.total} Boekwachter issue${t.total===1?``:`s`} in this file`,children:t.total}),(0,K.jsx)(`span`,{className:`file-flat-severities`,children:de(t.bySeverity)})]}):null}}:ri?{entries:$r,emptyMessage:`No files yet.`,trailingForEntry:e=>e.mtimeMs===void 0?null:(0,K.jsx)(`span`,{className:`file-flat-time`,title:M(new Date(e.mtimeMs)),children:O(new Date(e.mtimeMs).toISOString())})}:null,[$,L,ni,$r,ri,ti,Rr]),ai=(0,G.useMemo)(()=>Qe(f?.id??``,L??`artifacts`,{canWrite:f!==null&&L!==null&&Q(L)}),[f,L,Q]),oi=(0,G.useCallback)(e=>{if(!e){H(null);return}L&&Rr(ve(e),L)},[L,Rr]),si=et({source:ai,entries:Gr,selectedPath:B?.path??null,onSelectPath:oi,refresh:(0,G.useCallback)(async()=>{f&&await zn(f.id)},[f,zn])}),ci=B?.outsideIn?!B.outsideIn.editingEnabled||!Q(B.source):!L||!Q(L),li=Z?Tr({name:wr(Z),path:Z,isDirectory:!1},W):0,ui=zt?.path===B?.path?zt:null,di=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Kr,{request:ui}),Z?(0,K.jsx)(bt,{open:It,issueCount:li,onToggle:()=>Lt(e=>!e)}):null]}),fi=(0,G.useMemo)(()=>De.some(e=>/(^|\/)index\.html?$/i.test(e)),[De]);(0,G.useEffect)(()=>{if(!f){Ht(null);return}if(typeof f.outputPaneVisible==`boolean`){Lr(f.id);return}let e=Ir(f.id);if(e===null)return;let t=f.id;Ht({projectId:t,visible:e}),x.updateProject(t,{outputPaneVisible:e}).then(e=>{Lr(t),h(n=>n?.id===t?e:n)}).catch(()=>{})},[f?.id]);let pi=f?.projectType;(0,G.useEffect)(()=>{let e=!1;if(!pi){Wt(null);return}return(async()=>{try{let t=await x.getCatalogItem(`project-type`,pi.id,{source:pi.source,version:pi.version}),n=t.manifest.kind===`project-type`?t.manifest.pages:void 0,r=t.manifest.kind===`project-type`?new Set((t.manifest.tools??[]).map(e=>e.name)):new Set,i=(n?.tools??[]).filter(e=>r.has(e));e||Wt(n?.entry?{entry:n.entry,label:`Dashboard`,...i.length>0?{pageTools:i}:{}}:null)}catch{e||Wt(null)}})(),()=>{e=!0}},[pi?.id,pi?.version,pi?.source]);let mi=Vt&&Vt.projectId===f?.id?Vt.visible:null,hi=!!f&&(mi??f?.outputPaneVisible??(fi||!!Ut)),gi=(0,G.useCallback)(()=>{if(!f)return;let e=!hi,t=f.id;Ht({projectId:t,visible:e}),x.updateProject(t,{outputPaneVisible:e}).then(e=>{h(n=>n?.id===t?e:n)}).catch(e=>{D(e.message)})},[f,hi]),_i=(0,G.useRef)(null),[vi,yi]=(0,G.useState)(()=>Pr()),bi=(0,G.useRef)(null),xi=(0,G.useCallback)(e=>{let t=Nr(e);yi(t);try{window.localStorage.setItem(Ar,t.toFixed(4))}catch{}},[]),Si=(0,G.useCallback)(e=>{e.preventDefault(),bi.current={startX:e.clientX,startFraction:vi,width:_i.current?.clientWidth??1},document.body.classList.add(`chat-rail-resizing`),document.body.style.cursor=`col-resize`;let t=e=>{let t=bi.current;!t||t.width<=0||xi(t.startFraction+(e.clientX-t.startX)/t.width)},n=()=>{bi.current=null,document.body.style.cursor=``,document.body.classList.remove(`chat-rail-resizing`),window.removeEventListener(`mousemove`,t),window.removeEventListener(`mouseup`,n)};window.addEventListener(`mousemove`,t),window.addEventListener(`mouseup`,n)},[vi,xi]),Ci=(0,G.useCallback)(e=>{let t=e.shiftKey?.08:.02;e.key===`ArrowRight`?(e.preventDefault(),xi(vi+t)):e.key===`ArrowLeft`?(e.preventDefault(),xi(vi-t)):e.key===`Home`?(e.preventDefault(),xi(jr)):e.key===`End`&&(e.preventDefault(),xi(Mr))},[vi,xi]),wi=s&&De.length>0,Ti=vt(f?.id??``);(0,G.useEffect)(()=>{P===`output`&&!wi&&F(`chat`)},[P,wi]);let Ei=!s&&hi,Di=wi&&P===`output`,Oi=(0,G.useCallback)(e=>{if(Zn(e),!n)try{window.localStorage.setItem(xr,e)}catch{}},[n,Zn]),ki=(0,G.useCallback)(async()=>{if(!(!f||f.id==="default"||_(f))&&!g){y(!0);try{let e=await x.updateProject(f.id,{archived:!f.archived});window.dispatchEvent(new CustomEvent(`gezel:project-updated`,{detail:{projectId:f.id,project:e}}))}catch(e){D(e instanceof Error?e.message:String(e))}finally{y(!1)}}},[g,f]),Ai=(e,t)=>e.map(e=>(0,K.jsx)(Me,{project:e,onDeleted:()=>void Y(),onChanged:()=>void Y(),children:(0,K.jsxs)(`li`,{className:`project-rail-row${t?` project-rail-row-archived`:``}`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`project-rail-name${f?.id===e.id?` active`:``}`,onClick:()=>Oi(e.id),title:e.name,"aria-label":I?e.name:void 0,children:[(0,K.jsx)(Pe,{project:e,size:18,className:`project-rail-mark`}),!I&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`project-rail-label`,children:e.name}),e.storageScope===`machine-shared`&&(0,K.jsx)(`span`,{className:`machine-shared-badge`,title:`Shared with accounts on this machine`,children:`Shared`})]})]}),!I&&(0,K.jsx)(Re,{project:e,onDeleted:()=>void Y(),onChanged:()=>void Y()})]})},e.id));return(0,G.useEffect)(()=>{if(n||f||l.length===0)return;let e=null;try{e=window.localStorage.getItem(xr)}catch{e=null}e&&l.some(t=>t.id===e)&&Zn(e)},[n,f,l,Zn]),(0,K.jsxs)(`div`,{ref:a,className:`two-col${I&&!n?` sidebar-collapsed`:``}${n?` detail-only`:``}${s?` is-compact`:``}`,children:[!n&&(0,K.jsx)(Gn,{open:T!==null,mode:T??`crew`,onClose:()=>E(null),onCreated:er}),f&&q&&(0,K.jsx)(Tn,{path:q.path,issue:q.issue,gezels:Gt,assignedGezelIds:new Set([...f.gezelIds??[],...f.voormanGezelId?[f.voormanGezelId]:[]]),onCancel:()=>Rt(null),onConfirm:async(e,t)=>{await x.fixBoekwachterIssue(f.id,{ref:q.issue.ref,gezelId:e,message:t}),await Kn(),Rt(null),F(`chat`)}},`${q.path}:${q.issue.category}:${q.issue.message}`),!n&&(0,K.jsxs)(`aside`,{className:`side${I?` collapsed`:``}`,children:[(0,K.jsxs)(`div`,{className:`area-toolbar`,children:[!I&&(0,K.jsx)(`button`,{type:`button`,className:`area-toolbar-btn`,onClick:()=>E(`crew`),children:`+ New Project`}),(0,K.jsx)(`button`,{type:`button`,className:`area-toolbar-toggle`,onClick:()=>we(e=>!e),title:I?`Expand project list`:`Collapse project list`,"aria-label":I?`Expand project list`:`Collapse project list`,children:I?`›`:`‹`})]}),I&&(0,K.jsx)(`div`,{className:`new-row collapsed-create-row`,"aria-label":`Create`,children:(0,K.jsxs)(`button`,{type:`button`,className:`collapsed-create-btn`,onClick:()=>E(`crew`),title:`New Project`,"aria-label":`New Project`,children:[(0,K.jsx)(`span`,{className:`collapsed-create-symbol`,"aria-hidden":`true`,children:`+`}),(0,K.jsx)(`span`,{className:`collapsed-create-label`,children:`Project`})]})}),(0,K.jsx)(`ul`,{children:Ai(yn,!1)}),bn.length>0&&(0,K.jsxs)(`section`,{className:`project-archive-section${I?` is-collapsed`:``}`,"aria-labelledby":`archived-projects-heading`,children:[(0,K.jsx)(`h3`,{id:`archived-projects-heading`,children:`Archived projects`}),(0,K.jsx)(`ul`,{children:Ai(bn,!0)})]}),le&&!I&&(0,K.jsx)(`p`,{className:`error`,children:le})]}),(0,K.jsx)(`section`,{className:`main`,children:!n&&!f?(0,K.jsx)(`p`,{className:`placeholder`,children:`Pick a project on the left to view it here.`}):f?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`entity-tabs-row project-tabs-row`,children:[!s&&(0,K.jsx)(`button`,{type:`button`,className:`output-toggle${hi?` is-active`:``}`,onClick:gi,title:hi?`Hide output pane`:`Show output pane`,"aria-label":hi?`Hide output pane`:`Show output pane`,"aria-pressed":hi,children:(0,K.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:[(0,K.jsx)(`rect`,{x:`1.5`,y:`2.5`,width:`13`,height:`9`,rx:`1.2`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.3`}),(0,K.jsx)(`path`,{d:`M6.4 5.4 L10 7.5 L6.4 9.6 Z`,fill:`currentColor`}),(0,K.jsx)(`line`,{x1:`5`,y1:`13.6`,x2:`11`,y2:`13.6`,stroke:`currentColor`,strokeWidth:`1.3`,strokeLinecap:`round`})]})}),(0,K.jsx)(w,{value:P,onValueChange:e=>F(e),children:(0,K.jsx)(C,{children:[{value:`output`,label:`Output`,show:wi},{value:`chat`,label:`Chat`,show:!0},{value:`overview`,label:`Overview`,show:kr(f,`overview`)},{value:`tasks`,label:`Tasks`,show:kr(f,`tasks`)},{value:`packages`,label:`Approvals`,show:kr(f,`approvals`)},{value:`workspace`,label:`Workspace`,show:kr(f,`workspace`)},{value:`artifacts`,label:`Artifacts`,show:kr(f,`artifacts`)},{value:`proposals`,label:`Proposals`,show:Ti>0},{value:`github`,label:`GitHub`,show:!!f.github?.url},{value:`mail`,label:`Mail`,show:r&&Br(f)},{value:`map`,label:`Village`,show:kr(f,`map`)},{value:`about`,label:`Settings`,show:!0}].filter(e=>e.show).map(e=>s?(0,K.jsx)(S,{value:e.value,"data-testid":`project-tab-${e.value}`,className:`gz-tab-icon`,"aria-label":e.label,title:e.label,onPointerEnter:()=>Er(e.value),onFocus:()=>Er(e.value),onPointerDown:()=>Er(e.value),children:(0,K.jsx)(Vr,{tab:e.value})},e.value):(0,K.jsx)(S,{value:e.value,"data-testid":`project-tab-${e.value}`,onPointerEnter:()=>Er(e.value),onFocus:()=>Er(e.value),onPointerDown:()=>Er(e.value),children:e.label},e.value))})}),f.archived&&(0,K.jsx)(`span`,{className:`project-archived-badge`,title:`Hidden from primary navigation`,children:`Archived`})]}),(0,K.jsxs)(`div`,{ref:_i,className:`project-body${Ei?` has-output`:``}${s?` project-body-compact`:``}`,style:Ei?{"--project-output-width":`${(vi*100).toFixed(2)}%`}:void 0,children:[(Ei||Di)&&(0,K.jsx)(on,{projectId:f.id,htmlFiles:De,typePage:Ut??void 0,onClose:Di?()=>F(`chat`):gi,onDebugFrame:Xn},f.id),Ei&&(0,K.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize output pane`,tabIndex:0,className:`chat-rail-grip project-output-grip`,onMouseDown:Si,onKeyDown:Ci}),!Di&&(0,K.jsxs)(`div`,{className:`project-body-content`,children:[P===`about`&&(0,K.jsxs)(`div`,{className:`project-about-page`,children:[(0,K.jsx)(Jt,{project:f,gezels:Gt,boekwachterGezelId:Qt,recentlyAddedGezelId:ee,onAddGezel:Mn,onCreateTemplateGezel:Pn,onRemoveGezel:Nn}),(0,K.jsx)(Xr,{projectId:f.id,resourceKey:`project:${f.id}:about`,id:`project-about-overview`,label:`About this project`,hint:`Flows into the system prompt when a chat is scoped to this project.`,initial:f.about??``,onSave:async e=>{let t=await x.updateProject(f.id,{about:e});return h(n=>n?.id===t.id?{...n,about:e}:n),t}},`${f.id}:about`),(0,K.jsx)(Xr,{projectId:f.id,resourceKey:`project:${f.id}:mission`,id:`project-about-mission`,label:`Mission objectives`,hint:`A concrete list of what success looks like. Also flows into the system prompt.`,initial:f.missionObjectives??``,onSave:async e=>{let t=await x.updateProject(f.id,{missionObjectives:e});return h(n=>n?.id===t.id?{...n,missionObjectives:e}:n),t}},`${f.id}:mission`),(0,K.jsx)(wt,{projectId:f.id,projectName:f.name},`${f.id}:memories`),r&&(0,K.jsx)(`section`,{id:`project-about-connections`,className:`project-about-section project-about-anchor`,children:(0,K.jsx)(Dr,{children:(0,K.jsx)(pr,{project:f,onProjectChange:h})})}),(0,K.jsxs)(`section`,{id:`project-about-settings`,className:`project-about-section project-about-anchor`,children:[(0,K.jsx)(`h3`,{className:`project-about-section-title`,children:`Settings`}),(0,K.jsxs)(`div`,{className:`project-config`,children:[(0,K.jsxs)(`label`,{className:`config-label`,children:[`Working directory`,(0,K.jsxs)(`div`,{className:`new-row`,children:[(0,K.jsx)(`input`,{placeholder:`External path (leave blank for internal)`,value:en,onChange:e=>tn(e.target.value),onBlur:()=>void ir(en)}),window.__GEZEL__?.selectDirectory&&(0,K.jsx)(`button`,{type:`button`,onClick:async()=>{let e=await window.__GEZEL__?.selectDirectory?.({title:`Choose working directory`,defaultPath:en||void 0});e&&(tn(e),ir(e))},title:`Browse for folder`,children:`Browse…`})]}),(0,K.jsx)(`small`,{className:`muted`,children:f.workingDir?`External: ${f.workingDir}`:`Using internal workspace`})]}),(0,K.jsxs)(`label`,{className:`config-label`,style:{marginTop:`0.75rem`},children:[`Allow built-in tools and background work to modify the workspace`,(0,K.jsxs)(`div`,{className:`new-row`,style:{alignItems:`center`},children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:En.managedWritable,onChange:e=>{let t=e.target.checked;t&&f.workingDir?rn(!0):ar(t)}}),(0,K.jsx)(`span`,{className:`muted small`,children:f.workingDir?`Off by default for external folders. Turn on only if you trust the crew’s tools and automations to edit this path.`:`Internal workspace — on by default. Provider-native access, when used, follows its own project posture.`})]})]}),(0,K.jsxs)(`label`,{className:`config-label`,style:{marginTop:`0.75rem`},children:[`Index this project's workspace`,(0,K.jsxs)(`div`,{className:`new-row`,style:{alignItems:`center`},children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:f.indexingEnabled!==!1,onChange:e=>void cr(e.target.checked)}),(0,K.jsx)(`span`,{className:`muted small`,children:`Builds file search, commands, the Village map, and AI summaries. Turn it off for lightweight projects such as games or language practice.`})]})]}),(0,K.jsxs)(`label`,{className:`config-label`,style:{marginTop:`0.75rem`},children:[`Fix problems overnight`,(0,K.jsxs)(`div`,{className:`new-row`,style:{alignItems:`center`},children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:f.nightlyFixesEnabled!==!1,onChange:e=>void lr(e.target.checked)}),(0,K.jsx)(`span`,{className:`muted small`,children:`When this project has both a Boekwachter and a developer, the developer works through open issues during the night shift. Your files aren’t touched — fixes arrive as change proposals in the Proposals tab for you to review and apply.`})]})]}),!_(f)&&(0,K.jsxs)(`fieldset`,{className:`project-tab-settings`,children:[(0,K.jsx)(`legend`,{children:`Linked projects`}),(0,K.jsxs)(`p`,{className:`muted small`,children:[`Give this project one-way access to another project’s indexed knowledge and workspace. The other project does not gain access back. Shared documents are always included automatically.`,` `,(f.linkedProjectIds??[]).length,` of 32 linked.`]}),(0,K.jsxs)(`div`,{className:`project-tab-settings-grid`,children:[xn.map(e=>{let t=(f.linkedProjectIds??[]).includes(e.id);return(0,K.jsxs)(`label`,{className:`new-row`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:t,disabled:fn||!t&&Sn,onChange:t=>void ur(e.id,t.target.checked)}),(0,K.jsxs)(`span`,{children:[e.name,(0,K.jsxs)(`span`,{className:`muted small`,children:[` — `,e.id]}),e.archived?(0,K.jsx)(`span`,{className:`muted small`,children:` — archived`}):null,u(e)?null:(0,K.jsxs)(`span`,{className:`muted small`,children:[` `,`— workspace read-only`]})]})]},e.id)}),xn.length===0?(0,K.jsx)(`span`,{className:`muted small`,children:`No other projects are available.`}):null]}),(0,K.jsxs)(`small`,{className:`muted`,children:[`Gezels address linked files with the existing file tools at`,` `,(0,K.jsx)(`code`,{children:`../project-id/…`}),`. Writes still follow the linked project’s own workspace-write setting.`]})]}),(0,K.jsx)(Yt,{project:f,onUpdated:h}),(0,K.jsxs)(`div`,{className:`config-label`,style:{marginTop:`0.75rem`},children:[`Project properties`,(0,K.jsx)(vn,{project:f,onProjectChange:h}),(0,K.jsx)(`small`,{className:`muted`,children:`Shared values gezellen and recurring craftbooks draw from — set the designated language once and every translation run uses it.`})]}),(0,K.jsxs)(`label`,{className:`config-label`,style:{marginTop:`0.75rem`},children:[`GitHub repository`,(0,K.jsx)(`div`,{className:`new-row`,children:(0,K.jsx)(`input`,{placeholder:`https://github.com/owner/repo`,value:cn,onChange:e=>ln(e.target.value),onBlur:()=>void rr(cn)})}),(0,K.jsxs)(`small`,{className:`muted`,children:[f.github?.url?f.github.checkoutDir?`Linked. Checkout: ${f.github.checkoutDir}${f.github.branch?` (${f.github.branch})`:``}`:`Linked. Use the GitHub tab to clone.`:`Optional. When set, gezels gain a GitHub-linked checkout and a new GitHub tab.`,un&&(0,K.jsxs)(K.Fragment,{children:[` `,`— `,(0,K.jsx)(`span`,{className:`status`,children:un})]})]})]}),(0,K.jsxs)(`label`,{className:`config-label`,style:{marginTop:`0.75rem`},children:[Pt(f),(0,K.jsx)(`div`,{className:`new-row`,children:(0,K.jsx)(jt,{gezels:Gt,value:f.voormanGezelId,noneLabel:`(no ${Ft(f)})`,ariaLabel:Pt(f),onValueChange:async e=>{let t=await x.updateProject(f.id,{voormanGezelId:e});h(t)}})}),(0,K.jsx)(`small`,{className:`muted`,children:f.mode===`solo`?`The single gezel who handles this entire job — the Builder. Mentioned in the system prompt for any chat scoped here. Team-management tools are stripped from their thread.`:`The gezel who acts as voorman (foreman) of this project. Mentioned in the system prompt for any chat scoped here.`})]}),(0,K.jsxs)(`div`,{className:`config-label`,style:{marginTop:`0.75rem`},children:[(0,K.jsxs)(`label`,{className:`new-row`,style:{alignItems:`center`},children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:f.nudgeConfig?.enabled===!1,onChange:e=>void dr(e.target.checked)}),(0,K.jsx)(`span`,{children:`Exclude from Meester progress check-ins`})]}),(0,K.jsx)(`small`,{className:`muted`,children:`For long-running or ambient projects. The Meester won’t ask the project lead for overall progress; direct chats and the project’s own work continue.`})]}),(0,K.jsxs)(`label`,{className:`config-label`,style:{marginTop:`0.75rem`},children:[`Project type`,(0,K.jsx)(`div`,{className:`new-row`,children:(0,K.jsxs)(ae,{value:f.projectTypeId||`__AUTO__`,onValueChange:async e=>{let t=await x.updateProject(f.id,{projectTypeId:e===`__AUTO__`?null:e});h(t)},children:[(0,K.jsx)(ce,{children:(0,K.jsx)(se,{})}),(0,K.jsxs)(ue,{children:[(0,K.jsx)(oe,{value:`__AUTO__`,children:(()=>{let e=p(f.detectedProjectType?.id);return e?`Auto-detect (${e.label})`:`Auto-detect`})()}),v().map(e=>(0,K.jsx)(oe,{value:e.id,children:e.label},e.id))]})]})}),(0,K.jsx)(`small`,{className:`muted`,children:`Tunes which craftbooks the command rail suggests for this project. Auto-detect classifies the project from its files and About text.`})]}),(0,K.jsxs)(`fieldset`,{className:`project-tab-settings`,children:[(0,K.jsx)(`legend`,{children:`Project tabs`}),(0,K.jsx)(`p`,{className:`muted small`,children:`Keep this project focused by hiding work areas it does not use.`}),(0,K.jsx)(`div`,{className:`project-tab-settings-grid`,children:Or.map(e=>(0,K.jsxs)(`label`,{className:`new-row`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:kr(f,e.key),onChange:t=>void Cr(e.key,t.target.checked)}),(0,K.jsx)(`span`,{children:e.label})]},e.key))}),(0,K.jsx)(`small`,{className:`muted`,children:`Chat and Settings always stay available. Output appears whenever the project has a previewable page.`})]}),f.id!=="default"&&!_(f)&&(0,K.jsxs)(`div`,{className:`project-archive-setting`,children:[(0,K.jsxs)(`div`,{className:`project-archive-setting-copy`,children:[(0,K.jsx)(`span`,{className:`project-archive-setting-title`,children:f.archived?`Restore project`:`Archive project`}),(0,K.jsx)(`small`,{className:`muted`,children:f.archived?`Return this project to primary navigation. Its previous inactive status is preserved.`:`Hide this project from primary navigation and pause automatic project work. Its files and chats stay on disk.`})]}),(0,K.jsx)(`button`,{type:`button`,className:`secondary project-archive-setting-action`,onClick:()=>void ki(),disabled:g,children:g?f.archived?`Restoring…`:`Archiving…`:f.archived?`Restore project`:`Archive project`})]}),gn.length>0&&(0,K.jsxs)(`div`,{className:`project-credentials`,children:[(0,K.jsx)(`h4`,{children:`Granted credentials`}),(0,K.jsx)(`p`,{className:`muted small`,children:`Credentials are stored once for your whole workspace and shared across projects you grant them to. Scripts and MCP tools running in this project can resolve only the names checked below. They never see the raw values.`}),(0,K.jsx)(`ul`,{className:`credentials-list`,children:gn.map(e=>{let t=(f.grantedCredentials??[]).includes(e.name),n=Ur(e);return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`label`,{className:`new-row`,style:{alignItems:`center`},children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:t,disabled:!t&&(!e.stored||e.allowedOrigins.length===0),onChange:t=>void Jn(e.name,t.target.checked)}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`code`,{children:e.name}),(0,K.jsxs)(`span`,{className:`muted small`,children:[` — `,e.label]}),n&&(0,K.jsxs)(`span`,{className:`muted small`,children:[` `,`— `,n]})]})]})},e.name)})})]}),(0,K.jsxs)(`div`,{className:`project-writes-log`,children:[(0,K.jsx)(`h4`,{children:`Recent workspace changes`}),an.length===0?(0,K.jsxs)(`p`,{className:`muted small`,children:[`No workspace mutations recorded yet. Gezels that call`,` `,(0,K.jsx)(`code`,{children:`write_file`}),`, `,(0,K.jsx)(`code`,{children:`delete_path`}),`,`,` `,(0,K.jsx)(`code`,{children:`make_dir`}),`, or `,(0,K.jsx)(`code`,{children:`rename`}),` will show up here.`]}):(0,K.jsx)(`ul`,{children:an.map((e,t)=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`writes-op writes-op-${e.op}`,children:e.op}),(0,K.jsx)(`code`,{children:e.op===`rename`?`${e.fromPath} → ${e.path}`:e.path}),e.bytes!==void 0&&(0,K.jsxs)(`span`,{className:`muted small`,children:[` `,`· `,Zr(e.bytes)]}),e.gezelId&&(0,K.jsxs)(`span`,{className:`muted small`,children:[` · by `,e.gezelId]}),(0,K.jsxs)(`span`,{className:`muted small`,title:M(e.at),children:[` `,`· `,xe(e.at)]})]},`${e.at}:${t}`))})]})]})]}),(0,K.jsxs)(`section`,{id:`project-about-toolsets`,className:`project-about-section project-about-anchor`,children:[(0,K.jsx)(`h3`,{className:`project-about-section-title`,children:`Toolsets`}),(0,K.jsx)(_t,{scope:{kind:`project`,projectId:f.id},subject:f.name,hint:`Available to every gezel working in this project. Project MCP files are discovered automatically.`})]}),(0,K.jsxs)(`section`,{id:`project-about-history`,className:`project-about-section project-about-anchor`,children:[(0,K.jsx)(`h3`,{className:`project-about-section-title`,children:`History`}),(0,K.jsx)(`div`,{className:`project-about-history`,children:(0,K.jsx)(Dr,{children:(0,K.jsx)(_r,{projectId:f.id})})})]}),(0,K.jsxs)(`nav`,{className:`project-about-toc`,"aria-label":`About sections`,children:[(0,K.jsx)(`div`,{className:`project-about-toc-title`,children:`On this page`}),(0,K.jsx)(`a`,{href:`#project-about-crew`,children:`Assigned gezellen`}),(0,K.jsx)(`a`,{href:`#project-about-overview`,children:`About this project`}),(0,K.jsx)(`a`,{href:`#project-about-mission`,children:`Mission objectives`}),(0,K.jsx)(`a`,{href:`#project-about-memories`,children:`Project memories`}),r&&(0,K.jsx)(`a`,{href:`#project-about-connections`,children:`Connections`}),(0,K.jsx)(`a`,{href:`#project-about-settings`,children:`Settings`}),(0,K.jsx)(`a`,{href:`#project-about-toolsets`,children:`Toolsets`}),(0,K.jsx)(`a`,{href:`#project-about-history`,children:`History`})]})]}),(0,K.jsx)(Se,{open:nn,title:`Enable workspace writes?`,message:f.workingDir?(0,K.jsxs)(K.Fragment,{children:[`Gezels will be able to create, modify, and delete files inside`,` `,(0,K.jsx)(`code`,{children:f.workingDir}),`. Every change is logged in the Settings section. You can turn this back off at any time.`]}):null,confirmLabel:`Enable`,danger:!0,onConfirm:async()=>{await ar(!0),rn(!1)},onCancel:()=>rn(!1)}),P===`packages`&&(0,K.jsxs)(`div`,{className:`project-config`,children:[(0,K.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Each gezel asks the runtime before installing a package or running a script. Decisions persist per project — once approved, future calls run automatically.`}),(0,K.jsx)(`h4`,{className:`project-section-heading`,children:`Approved npm packages`}),(0,K.jsxs)(`ul`,{children:[j?.npmApproved.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`strong`,{children:e.package}),` `,(0,K.jsx)(`code`,{children:e.version}),` `,(0,K.jsxs)(`span`,{className:`muted small`,children:[`(`,e.approvedBy===`shipped`?`shipped allowlist`:`approved by you`,`)`]})]},`${e.package}@${e.version}`)),(!j||j.npmApproved.length===0)&&(0,K.jsx)(`li`,{className:`muted`,children:`No project-specific npm approvals yet.`})]}),j&&j.npmDeclined.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h4`,{className:`project-section-heading`,children:`Declined npm packages`}),(0,K.jsx)(`ul`,{children:j.npmDeclined.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`strong`,{children:e.package}),` `,(0,K.jsx)(`code`,{children:e.version})]},`${e.package}@${e.version}`))})]}),(0,K.jsx)(`h4`,{className:`project-section-heading`,children:`Approved scripts (run via package.json)`}),(0,K.jsxs)(`ul`,{children:[j&&Object.entries(j.scriptApprovals).map(([e,t])=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`strong`,{children:e}),` `,(0,K.jsxs)(`span`,{className:`muted small${t===`declined`?` error`:``}`,children:[`(`,t,`)`]})]},`script-${e}`)),(!j||Object.keys(j.scriptApprovals).length===0)&&(0,K.jsx)(`li`,{className:`muted`,children:`No script approvals on file yet.`})]}),j&&Object.keys(j.npxApprovals).length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h4`,{className:`project-section-heading`,children:`Approved npx binaries`}),(0,K.jsx)(`ul`,{children:Object.entries(j.npxApprovals).map(([e,t])=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`strong`,{children:e}),` `,(0,K.jsxs)(`span`,{className:`muted small${t===`declined`?` error`:``}`,children:[`(`,t,`)`]})]},`npx-${e}`))})]}),(0,K.jsx)(`h4`,{className:`project-section-heading`,children:`Install a package`}),(0,K.jsxs)(`div`,{className:`new-row`,children:[(0,K.jsx)(`input`,{placeholder:`npm package name`,value:te,onChange:e=>ne(e.target.value)}),(0,K.jsx)(`button`,{type:`button`,onClick:tr,children:`Install`})]}),(0,K.jsxs)(`ul`,{children:[f.packages.map(e=>(0,K.jsxs)(`li`,{children:[e.name,` `,(0,K.jsx)(`code`,{children:e.version})]},e.name)),f.packages.length===0&&(0,K.jsx)(`li`,{className:`muted`,children:`No packages installed in this project's workspace.`})]}),(0,K.jsxs)(`h4`,{className:`project-section-heading`,children:[`Available scripts (from `,(0,K.jsx)(`code`,{children:`package.json`}),`)`]}),(0,K.jsxs)(`p`,{className:`muted small`,style:{marginTop:`-0.25rem`},children:[`Listed scripts are eligible for first-use approval when a gezel calls`,` `,(0,K.jsx)(`code`,{children:`run_package_script`}),`.`]}),(0,K.jsxs)(`ul`,{children:[Object.entries(k).map(([e,t])=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`strong`,{children:e}),`: `,(0,K.jsx)(`code`,{children:t})]},e)),Object.keys(k).length===0&&(0,K.jsx)(`li`,{className:`muted`,children:`no scripts defined in package.json`})]}),re&&(0,K.jsx)(`pre`,{className:`log`,children:re})]}),L!==null&&(0,K.jsx)(tt,{source:ai,layoutClassName:`project-files-layout-${L}`,entries:Qr,truncated:(L===`workspace`?Fe:Le)&&!ri,viewMode:$,modes:L===`workspace`?_e:he,onViewModeChange:e=>Bn(L,e),showHidden:Yr,onShowHiddenChange:e=>Vn(L,e),selectedPath:B?.path,onSelect:e=>void Rr(e,L),emptyMessage:L===`workspace`?f.workingDir?`Workspace directory is empty.`:`No external working directory set. Use the internal workspace or set an external path under the Settings tab.`:`No artifacts yet. Your gezellen will store reports and outputs here.`,mutations:si,customList:ii,trailingForEntry:L===`workspace`?e=>{let t=Tr(e,W);return t>0?(0,K.jsx)(`span`,{className:`workspace-tree-issue-count`,title:`${t} Boekwachter issue${t===1?``:`s`} ${e.isDirectory?`in this folder`:`in this file`}`,"aria-label":`${t} indexing issue${t===1?``:`s`}`,children:t}):null}:void 0,actionsForEntry:e=>{let t=e.isDirectory?null:lt(e.path);return e.isDirectory||!t||!at(t.format)||B?.path===e.path&&B.source===L&&B.outsideIn?.editingEnabled?[]:[{label:`Allow editing via markdown`,disabled:!Q(L),onSelect:()=>zr(e,L)}]},headerExtra:L===`workspace`?(0,K.jsxs)(`div`,{className:`workspace-tree-index-summary`,"aria-live":`polite`,title:gt??(W?`${W.reviewedFiles} of ${W.eligibleFiles} eligible files reviewed`:yt(U)),children:[(0,K.jsxs)(`span`,{className:`workspace-index-state workspace-index-state-${St(U)}`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`}),gt?`Index unavailable`:yt(U)]}),W&&W.counts.total>0&&(0,K.jsxs)(`span`,{className:`workspace-tree-issue-total`,children:[W.counts.total,` issue`,W.counts.total===1?``:`s`]})]}):void 0,notices:L===`workspace`?(0,K.jsxs)(K.Fragment,{children:[$===`flat-modified`&&U&&U.state!==`fresh`&&(0,K.jsxs)(`div`,{className:`file-flat-notice`,children:[(0,K.jsx)(`span`,{children:U.state===`indexing`?`Indexing…`:U.state===`stale`?`Index is out of date.`:U.state===`never`?`Not indexed yet — showing files from the folder walk.`:`Indexing is disabled — showing files from the folder walk.`}),(U.state===`stale`||U.state===`never`)&&(0,K.jsx)(`button`,{type:`button`,className:`file-flat-notice-action`,onClick:()=>void x.refreshProjectIndex(f.id).then(e=>pt(e.status)).catch(()=>{}),children:`Index now`})]}),($===`flat-issues`||$===`flat-criticality`)&&(0,K.jsxs)(`div`,{className:`file-flat-notice`,children:[(0,K.jsx)(`span`,{children:W?`${W.reviewedFiles} of ${W.eligibleFiles} eligible files reviewed${W.truncated?` — showing the first 1000 issues`:``}`:`Loading review coverage…`}),(U?.state===`stale`||U?.state===`never`)&&(0,K.jsx)(`button`,{type:`button`,className:`file-flat-notice-action`,onClick:()=>void x.refreshProjectIndex(f.id).then(e=>pt(e.status)).catch(()=>{}),children:`Index now`})]})]}):void 0,extraPane:L===`workspace`&&It?(0,K.jsx)(Ct,{path:Z,status:U,issues:W,review:Dt,loading:kt,error:Mt,onClose:()=>Lt(!1),onSelectLine:e=>{Z&&Bt(t=>({path:Z,line:e,requestId:(t?.requestId??0)+1}))},onFixIssue:e=>{Z&&Rt({path:Z,issue:e})},onUpdateIssue:qn,onOpenTask:e=>ke({kind:`task`,ref:e})}):void 0,viewer:B?B.outsideIn?(0,K.jsx)($n,{projectId:f.id,file:B,outsideIn:B.outsideIn,isReadOnly:ci,editorTheme:c,onChange:Hr,onSave:Wr,toolbarIndexToggle:di},`${B.source}:${B.path}`):Ze.has(B.content)?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($e,{content:B.content,path:B.path,fetchBlob:ai.fetchBlob,...B.size===void 0?{}:{sizeBytes:B.size}}),B.content===`__IMAGE__`&&B.source===`workspace`&&(0,K.jsx)(xt,{projectId:f.id,path:B.path,fetchBlob:ai.fetchBlob,onOpen:e=>void Qn(f.id,e,`workspace`)},B.path)]}):Sr(B.path)?(0,K.jsx)(Jr,{projectId:f.id,file:B,isReadOnly:ci,editorTheme:c,onEditorChange:Hr,onSave:Wr,onComplainAboutPreviewError:Yn,toolbarIndexToggle:di,sourceReveal:ui}):(0,K.jsx)(qr,{projectId:f.id,file:B,isReadOnly:ci,editorTheme:c,onChange:Hr,onSave:Wr,toolbarIndexToggle:di},`${B.source}:${B.path}`):(0,K.jsx)(`p`,{className:`placeholder`,style:{padding:`2rem`},children:`Select a file from the tree to view or edit it.`})}),P===`chat`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(fr,{project:f,compact:s},f.id)}),P===`tasks`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(br,{projectId:f.id})}),P===`proposals`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(hr,{projectId:f.id})}),P===`github`&&f.github?.url&&(0,K.jsx)(Dr,{children:(0,K.jsx)(vr,{project:f,onProjectChange:h})}),r&&P===`mail`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(mr,{project:f,onProjectChange:h})}),P===`map`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(gr,{projectId:f.id})}),P===`overview`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(yr,{projectId:f.id,project:f})})]})]}),(0,K.jsx)(Tt,{projectId:f.id,compact:s,managedWorkspaceWritable:En.managedWritable,onManagedWorkspaceWritesChange:e=>{e&&f.workingDir?rn(!0):ar(e)},codexMode:En.codexInUse?Dn:void 0,onCodexModeChange:En.codexInUse?or:void 0,claudeMode:En.claudeInUse?En.claudeMode:void 0,onClaudeModeChange:En.claudeInUse?sr:void 0,onOpenGitHub:f.github?.url?()=>F(`github`):void 0,onAddBoekwachter:Qt?()=>Mn(Qt):void 0,status:f.status??`active`,statusLocked:f.archived===!0,onStatusChange:async e=>{let t=await x.updateProject(f.id,{status:e});h(t)}})]}):(0,K.jsx)(_n,{})})]})}function Kr({request:e}){let{activeView:t,setActiveView:n,monacoEditor:r}=Ce();return(0,G.useEffect)(()=>{if(!e)return;if(t!==`raw`){n(`raw`);return}if(!r)return;let i=r.getModel();if(!i)return;let a=Math.max(1,Math.min(e.line,i.getLineCount()));r.setSelection({startLineNumber:a,startColumn:1,endLineNumber:a,endColumn:i.getLineMaxColumn(a)}),r.revealLineInCenter(a),r.focus()},[t,r,e,n]),null}function qr({projectId:e,file:t,isReadOnly:n,editorTheme:r,onChange:i,onSave:a,toolbarIndexToggle:o}){let s=Cr(t.path)&&t.source===`artifacts`,{root:c,parentDirectory:l,companionName:u,primaryDocumentFilename:d}=(0,G.useMemo)(()=>A(t.path),[t.path]),f=(0,G.useMemo)(()=>k(t.path),[t.path]),p=ze({resourceKey:`file:${t.source}:${t.path}`,initialValue:s?Et(t.content):t.content,save:async e=>{await a(e)}}),m=(0,G.useCallback)(e=>{i(e),p.update(e)},[p.update,i]),h=(0,G.useMemo)(()=>s?Ge({projectId:e,root:c,client:x,referencePrefix:u}):null,[u,s,e,c]),g=(0,G.useMemo)(()=>s?Ge({projectId:e,root:l,client:x,primaryDocumentFilename:d}):null,[s,l,d,e]),_=(0,G.useMemo)(()=>h&&g?We(h,u,g):null,[u,h,g]),v=(0,G.useMemo)(()=>h&&g?Ve(h,f,[{container:g,basenames:[d,f]}],g):null,[h,g,d,f]);(0,G.useEffect)(()=>()=>_?.dispose(),[_]);let y=(0,G.useMemo)(()=>s?H({client:x,currentDocumentPath:t.path,source:`project-artifacts`,projectId:e}):null,[s,e,t.path]),ee=(0,G.useMemo)(()=>s?pt({projectId:e,reportPath:t.path}):void 0,[s,e,t.path]);return(0,K.jsx)(`div`,{className:`editor-wrap`,style:{height:`100%`},children:(0,K.jsx)(P,{initialMarkdown:p.desiredValue(),fileName:t.path,readOnly:n,onChange:n?void 0:m,height:`100%`,colorScheme:r,fullWidth:!0,showPlayTab:s,workspaceContainer:v,mediaProvider:_,documentLinkProvider:y,fenceRenderers:ee,calcEngineFactory:s&&!n?U:void 0,allowVersioning:s&&!n,versionBasename:f,outline:s,toolbarSlotAfterActions:s?(0,K.jsxs)(K.Fragment,{children:[!n&&(0,K.jsx)(Ot,{context:`generic`}),(0,K.jsx)(Je,{fileName:t.path,projectId:e})]}):void 0,toolbarSlotRight:(0,K.jsxs)(K.Fragment,{children:[o,s&&g&&(0,K.jsx)(B,{selectedFile:t.path,mediaContainer:g,mediaSource:{kind:`project-artifacts`,projectId:e}})]}),statusBarSlotRight:n?void 0:(0,K.jsx)(He,{autosave:p})})})}function Jr({projectId:e,file:t,isReadOnly:n,editorTheme:r,onEditorChange:i,onSave:a,onComplainAboutPreviewError:o,toolbarIndexToggle:s,sourceReveal:c}){let[l,u]=(0,G.useState)(`preview`),[d,f]=(0,G.useState)(0),[p,m]=(0,G.useState)([]),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(void 0),[y,ee]=(0,G.useState)(null);(0,G.useEffect)(()=>{c?.path===t.path&&u(`source`)},[t.path,c]);let b=ze({resourceKey:`file:${t.source}:${t.path}`,initialValue:t.content,save:async e=>{await a(e)}}),x=(0,G.useCallback)(e=>{i(e),b.update(e)},[i,b.update]),T=(0,G.useCallback)(async e=>{if(o){v(e.at);try{await o(e,{path:t.path,source:t.source})}finally{v(void 0)}}},[o,t.path,t.source]),E=(0,G.useCallback)(e=>{m(t=>[e,...t].slice(0,50)),g(!1)},[]),te=(0,G.useCallback)(()=>{f(e=>e+1),m([])},[]),ne=(0,G.useCallback)(()=>{y&&window.open(y,`_blank`,`noopener,noreferrer`)},[y]);return(0,K.jsxs)(`div`,{className:`html-file-viewer`,children:[(0,K.jsx)(w,{value:l,onValueChange:e=>u(e),children:(0,K.jsxs)(`div`,{className:`html-file-viewer-bar`,children:[(0,K.jsxs)(C,{children:[(0,K.jsx)(S,{value:`preview`,children:`Preview`}),(0,K.jsx)(S,{value:`source`,children:`Source`})]}),l===`preview`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,onClick:te,className:`html-file-viewer-refresh`,title:`Reload the preview`,children:`Refresh`}),(0,K.jsx)(`button`,{type:`button`,onClick:ne,disabled:!y,className:`html-file-viewer-refresh`,title:`Open this page in your default system browser`,children:`Open in browser`})]})]})}),l===`preview`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(W,{projectId:e,path:t.path,source:t.source,title:t.path,className:`html-file-viewer-iframe`,refreshKey:d,onLog:E,onUrlReady:ee}),p.length>0&&(0,K.jsx)(Yr,{logs:p,collapsed:h,onToggleCollapsed:()=>g(e=>!e),onClear:()=>m([]),...o?{onComplain:T}:{},..._===void 0?{}:{complainBusyAt:_}})]}):(0,K.jsx)(`div`,{className:`editor-wrap`,children:(0,K.jsx)(P,{initialMarkdown:b.desiredValue(),fileName:t.path,onChange:n?void 0:x,height:`100%`,colorScheme:r,showPlayTab:!1,fullWidth:!0,toolbarSlotRight:s,statusBarSlotRight:n?void 0:(0,K.jsx)(He,{autosave:b})},`${t.source}:${t.path}`)})]})}function Yr({logs:e,collapsed:t,onToggleCollapsed:n,onClear:r,onComplain:i,complainBusyAt:a}){return(0,K.jsxs)(`div`,{className:`html-preview-log`,children:[(0,K.jsxs)(`div`,{className:`html-preview-log-bar`,children:[(0,K.jsxs)(`strong`,{children:[e.length,` preview error`,e.length===1?``:`s`]}),(0,K.jsx)(`button`,{type:`button`,onClick:n,className:`html-preview-log-toggle`,title:t?`Show errors`:`Hide errors`,children:t?`Show`:`Hide`}),(0,K.jsx)(`button`,{type:`button`,onClick:r,className:`html-preview-log-toggle`,title:`Clear error log`,children:`Clear`})]}),!t&&(0,K.jsx)(`ul`,{className:`html-preview-log-entries`,children:e.map((e,t)=>(0,K.jsxs)(`li`,{className:`html-preview-log-${e.kind}`,children:[(0,K.jsx)(`span`,{className:`html-preview-log-kind`,children:e.kind}),(0,K.jsx)(`span`,{className:`html-preview-log-message`,children:tr(e)}),(e.detail.filename||e.detail.lineno)&&(0,K.jsxs)(`span`,{className:`html-preview-log-loc muted small`,children:[e.detail.filename?e.detail.filename.split(`/`).pop():``,e.detail.lineno?`:${e.detail.lineno}`:``,e.detail.colno?`:${e.detail.colno}`:``]}),e.detail.stack&&(0,K.jsx)(`pre`,{className:`html-preview-log-stack`,children:e.detail.stack}),i&&(0,K.jsx)(`button`,{type:`button`,className:`html-preview-log-complain`,disabled:a===e.at,onClick:()=>void i(e),title:`Send this error to the project chat as a new message`,children:a===e.at?`Sending…`:`Complain about this`})]},`${e.at}-${t}`))})]})}function Xr({projectId:e,resourceKey:t,id:n,label:r,hint:i,initial:a,onSave:o}){let s=Ne(),c=ze({resourceKey:t,initialValue:(0,G.useMemo)(()=>Et(a),[a]),save:o}),l=(0,G.useCallback)(e=>{c.update(e)},[c.update]);return(0,K.jsxs)(`section`,{id:n,className:`project-doc-editor project-about-anchor`,children:[(0,K.jsx)(`h3`,{className:`project-doc-editor-title`,children:r}),(0,K.jsx)(`p`,{className:`muted small`,style:{marginTop:0,marginBottom:`0.4rem`},children:i}),(0,K.jsx)(`div`,{className:`editor-wrap`,children:(0,K.jsx)(P,{initialMarkdown:c.desiredValue(),onChange:l,height:`240px`,colorScheme:s,showPlayTab:!1,fullWidth:!0,toolbarSlotAfterActions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ot,{context:`generic`}),(0,K.jsx)(Je,{fileName:`${r}.md`,projectId:e})]}),statusBarSlotRight:(0,K.jsx)(He,{autosave:c})})})]})}function Zr(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}export{Wr as ProjectDetailView,Gr as ProjectsView};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-CEpd2cAX.js";import{pt as t}from"./dist-BPx-FyRH.js";var n=e();function r({manifest:e}){return t(e)?(0,n.jsx)(`span`,{className:`reco-badge`,title:`A recommended on-device model — fully open, tool-capable, and a good default for its size.`,children:`★ Recommended`}):null}export{r as t};
1
+ import{t as e}from"./jsx-runtime-CEpd2cAX.js";import{gt as t}from"./dist-BqGwkOe5.js";var n=e();function r({manifest:e}){return t(e)?(0,n.jsx)(`span`,{className:`reco-badge`,title:`A recommended on-device model — fully open, tool-capable, and a good default for its size.`,children:`★ Recommended`}):null}export{r as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-BX5xXiFs.js";import{n as i,t as a}from"./relative-time-B2kBaekd.js";import{t as o}from"./ConfirmDialog-BHFs6vmJ.js";var s=e(t(),1),c=n();function l(e){return(e.slice(0,16).match(/.{1,4}/g)??[]).join(` `)}function u(e){return e?i(e):`never`}var d={port:``,bindAddress:``,priority:`equal`,allowModels:``,maxConcurrentPerDevice:``,maxChatPerDevice:``,requestsPerMinute:``},ee=[{id:`equal`,label:`Equal`,title:`Remote turns queue like local work`},{id:`below-local`,label:`Local first`,title:`This machine's own work always drains first`},{id:`above-local`,label:`Remote first`,title:`Paired devices get priority over local work`}];function f(e){return{port:e?.port===void 0?``:String(e.port),bindAddress:e?.bindAddress??``,priority:e?.priority??`equal`,allowModels:(e?.allowModels??[]).join(`, `),maxConcurrentPerDevice:e?.limits?.maxConcurrentPerDevice===void 0?``:String(e.limits.maxConcurrentPerDevice),maxChatPerDevice:e?.limits?.maxChatPerDevice===void 0?``:String(e.limits.maxChatPerDevice),requestsPerMinute:e?.limits?.requestsPerMinute===void 0?``:String(e.limits.requestsPerMinute)}}function p(e,t){let n=e=>{let t=Number.parseInt(e.trim(),10);return Number.isFinite(t)&&t>0?t:void 0},r=n(e.port),i=e.bindAddress.trim(),a=e.allowModels.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean),o={},s=n(e.maxConcurrentPerDevice),c=n(e.maxChatPerDevice),l=n(e.requestsPerMinute);return s!==void 0&&(o.maxConcurrentPerDevice=s),c!==void 0&&(o.maxChatPerDevice=c),l!==void 0&&(o.requestsPerMinute=l),{enabled:t,...i?{bindAddress:i}:{},...r===void 0?{}:{port:r},...e.priority===`equal`?{}:{priority:e.priority},...a.length>0?{allowModels:a}:{},...Object.keys(o).length>0?{limits:o}:{}}}function m(){let[e,t]=(0,s.useState)([]),[n,i]=(0,s.useState)(null),[m,h]=(0,s.useState)(!1),[g,_]=(0,s.useState)(void 0),[v,y]=(0,s.useState)(null),[b,x]=(0,s.useState)([]),[S,C]=(0,s.useState)([]),[w,T]=(0,s.useState)(!1),[E,D]=(0,s.useState)(null),[O,k]=(0,s.useState)(null),[A,j]=(0,s.useState)(``),[M,N]=(0,s.useState)(``),[P,F]=(0,s.useState)(null),[I,L]=(0,s.useState)(null),[R,z]=(0,s.useState)(null),[B,V]=(0,s.useState)(d),[H,U]=(0,s.useState)(!1),W=(0,s.useRef)(!1),G=(0,s.useCallback)(e=>{W.current=e,U(e)},[]),K=(0,s.useCallback)(e=>{V(t=>({...t,...e})),G(!0)},[G]),q=(0,s.useCallback)(async()=>{try{let[e,n]=await Promise.all([r.listRemotes(),r.getConfig()]);t(e.remotes),h(!!n.remoteServing?.enabled),_(n.remoteServing?.port),W.current||V(f(n.remoteServing)),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}try{let e=await r.getMachineServing();y(e),h(!!e.config.enabled),_(e.status.port??e.config.port),W.current||V(f(e.config));let[t,n]=await Promise.all([r.listMachineServingGrants(),r.listMachineServingDevices()]);x(t.grants.filter(e=>e.status===`pending`)),C(n.devices)}catch{y(null),x([]),C([])}try{let e=await fetch(`${r.getBaseUrl()}/v1/identity`,{headers:r.authHeader()});if(e.ok){let t=await e.json();i({deviceId:t.deviceId,fingerprint:t.fingerprint})}}catch{}},[]);(0,s.useEffect)(()=>{if(!v){T(!1);return}let e=!1;return(async()=>{try{let t=await fetch(`${r.getBaseUrl()}/v1/apps`,{headers:r.authHeader()});if(!t.ok)return;let n=await t.json();e||T((n.apps??[]).some(e=>e.kind===`device`))}catch{}})(),()=>{e=!0}},[v]),(0,s.useEffect)(()=>{q();let e=window.setInterval(()=>void q(),5e3);return()=>window.clearInterval(e)},[q]);let J=(0,s.useCallback)(async e=>{k(`serving`);try{let t=p(B,e);if(v){let e=await r.updateMachineServing(t);y(e),h(!!e.config.enabled),_(e.status.port??e.config.port),V(f(e.config))}else{let e=await r.updateConfig({remoteServing:t});h(!!e.remoteServing?.enabled),_(e.remoteServing?.port),V(f(e.remoteServing))}G(!1),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}},[v,B,G]),Y=(0,s.useCallback)(()=>{G(!1),q()},[G,q]),X=(0,s.useCallback)(async(e,t)=>{k(`grant:${e.id}`);try{t?await r.approveMachineServingGrant(e.id):await r.denyMachineServingGrant(e.id),D(null),await q()}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}},[q]),Z=(0,s.useCallback)(async()=>{if(R){k(`revoke`);try{await r.revokeMachineServingDevice(R.appId),z(null),await q()}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}}},[R,q]),Q=(0,s.useCallback)(async()=>{if(!(!A.trim()||O)){k(`pair`);try{let e=A.trim(),t=await r.inspectRemote({baseUrl:e});F({baseUrl:e,...M.trim()?{displayName:M.trim()}:{},...t}),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}}},[A,M,O]),te=(0,s.useCallback)(async()=>{if(P){k(`pair`);try{await r.pairRemote({baseUrl:P.baseUrl,...P.displayName?{displayName:P.displayName}:{},expectedIdentityFingerprint:P.fingerprint,...P.identityChanged?{acceptIdentityChange:!0}:{}}),F(null),j(``),N(``),D(null),await q()}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}}},[P,q]),ne=(0,s.useCallback)(async()=>{if(I){k(`unpair`);try{await r.unpairRemote(I.remoteId),L(null),await q()}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}}},[I,q]),$=v?v.identity.fingerprint:n?.fingerprint??null;return(0,c.jsxs)(`section`,{className:`settings-section`,children:[(0,c.jsx)(`h2`,{children:`Remote Servers`}),(0,c.jsx)(`p`,{className:`muted small`,children:`Run models on another gezel device over your LAN. Pair with a powerful machine to use its big models as if they were local — chat and image/video/audio generation. The agentic loop and your files stay on this device; only the model runs remotely.`}),E&&(0,c.jsx)(`p`,{className:`settings-error`,role:`alert`,children:E}),(0,c.jsxs)(`div`,{className:`settings-subsection`,children:[(0,c.jsx)(`h3`,{children:v?`This machine as a server`:`This device as a server`}),(0,c.jsxs)(`label`,{className:`settings-toggle`,children:[(0,c.jsx)(`input`,{type:`checkbox`,checked:m,disabled:O===`serving`,onChange:e=>void J(e.target.checked)}),(0,c.jsx)(`span`,{children:`Serve my models to paired devices over the LAN`})]}),m?(0,c.jsxs)(`p`,{className:`muted small`,children:[`Other devices on your network can request inference here once you approve their pairing`,v?` below`:` (Connected Apps → Paired devices)`,`. They reach only inference — never your projects or files.`,v?` Served by the machine service, so it keeps working while nobody is logged in.`:``,` `,`Listening on port `,g??6229,`.`]}):(0,c.jsx)(`p`,{className:`muted small`,children:`Off — no other device can run models here.`}),$&&(0,c.jsxs)(`div`,{className:`device-code-block`,children:[(0,c.jsxs)(`span`,{className:`muted small`,children:[v?`This machine's identity code`:`This device's identity code`,` — when you pair from another device, check that it shows the same code:`]}),(0,c.jsx)(`code`,{className:`device-code`,children:l($)}),(0,c.jsxs)(`details`,{className:`device-code-full`,children:[(0,c.jsx)(`summary`,{className:`muted small`,children:`Show the full fingerprint`}),(0,c.jsx)(`code`,{style:{wordBreak:`break-all`},children:$})]})]}),v&&w&&(0,c.jsx)(`p`,{className:`muted small`,children:`Some devices paired with this account's daemon before the machine service took over serving. Those pairings no longer work — ask them to unpair and pair again against this machine's identity code above.`}),(0,c.jsxs)(`div`,{className:`remote-serving-fields`,children:[(0,c.jsxs)(`div`,{className:`remote-serving-field`,children:[(0,c.jsx)(`span`,{className:`muted small`,children:`Port`}),(0,c.jsx)(`input`,{type:`number`,min:1,max:65535,placeholder:`6229`,value:B.port,onChange:e=>K({port:e.target.value})})]}),(0,c.jsxs)(`div`,{className:`remote-serving-field`,children:[(0,c.jsx)(`span`,{className:`muted small`,children:`Network interface (IP)`}),(0,c.jsx)(`input`,{type:`text`,placeholder:`all networks (0.0.0.0)`,value:B.bindAddress,onChange:e=>K({bindAddress:e.target.value})})]}),(0,c.jsxs)(`div`,{className:`remote-serving-field`,children:[(0,c.jsx)(`span`,{className:`muted small`,children:`Max concurrent per device`}),(0,c.jsx)(`input`,{type:`number`,min:1,placeholder:`4`,value:B.maxConcurrentPerDevice,onChange:e=>K({maxConcurrentPerDevice:e.target.value})})]}),(0,c.jsxs)(`div`,{className:`remote-serving-field`,children:[(0,c.jsx)(`span`,{className:`muted small`,children:`Max chat per device`}),(0,c.jsx)(`input`,{type:`number`,min:1,placeholder:`same as concurrent`,value:B.maxChatPerDevice,onChange:e=>K({maxChatPerDevice:e.target.value})})]}),(0,c.jsxs)(`div`,{className:`remote-serving-field`,children:[(0,c.jsx)(`span`,{className:`muted small`,children:`Requests per minute per device`}),(0,c.jsx)(`input`,{type:`number`,min:1,placeholder:`unlimited`,value:B.requestsPerMinute,onChange:e=>K({requestsPerMinute:e.target.value})})]}),(0,c.jsxs)(`div`,{className:`remote-serving-field remote-serving-field-wide`,children:[(0,c.jsxs)(`span`,{className:`muted small`,children:[`Allowed models — comma-separated ids like `,(0,c.jsx)(`code`,{children:`llama-cpp:gemma4-e4b-q4`}),`; empty serves every installed model`]}),(0,c.jsx)(`input`,{type:`text`,placeholder:`all installed models`,value:B.allowModels,onChange:e=>K({allowModels:e.target.value})})]}),(0,c.jsxs)(`div`,{className:`remote-serving-field remote-serving-field-wide`,children:[(0,c.jsx)(`span`,{className:`muted small`,children:`When remote and local work compete`}),(0,c.jsx)(`div`,{className:`gz-tray`,role:`radiogroup`,"aria-label":`Remote work priority`,children:ee.map(e=>(0,c.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":B.priority===e.id,className:`gz-key${B.priority===e.id?` gz-key-active`:``}`,title:e.title,onClick:()=>K({priority:e.id}),children:e.label},e.id))})]})]}),H&&(0,c.jsxs)(`div`,{className:`remote-serving-actions`,children:[(0,c.jsx)(`button`,{type:`button`,className:`primary`,disabled:O!==null,onClick:()=>void J(m),children:O===`serving`?`Applying…`:`Apply server settings`}),(0,c.jsx)(`button`,{type:`button`,disabled:O!==null,onClick:Y,children:`Discard changes`})]})]}),v&&b.length>0&&(0,c.jsxs)(`div`,{className:`settings-subsection`,children:[(0,c.jsx)(`h3`,{children:`Pending pairing requests`}),(0,c.jsx)(`ul`,{className:`settings-list`,children:b.map(e=>(0,c.jsxs)(`li`,{className:`connected-app-row`,children:[(0,c.jsxs)(`div`,{className:`connected-app-meta`,children:[(0,c.jsx)(`div`,{className:`connected-app-name`,children:e.appName}),(0,c.jsxs)(`div`,{className:`muted small`,title:a(e.createdAt),children:[`requested `,u(e.createdAt),` — scopes: `,e.scopes.join(`, `)]})]}),(0,c.jsxs)(`div`,{className:`connected-app-actions`,children:[(0,c.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void X(e,!0),disabled:O!==null,children:`Approve`}),(0,c.jsx)(`button`,{type:`button`,onClick:()=>void X(e,!1),disabled:O!==null,children:`Deny`})]})]},e.id))})]}),v&&S.length>0&&(0,c.jsxs)(`div`,{className:`settings-subsection`,children:[(0,c.jsx)(`h3`,{children:`Devices paired with this machine`}),(0,c.jsx)(`ul`,{className:`settings-list`,children:S.map(e=>(0,c.jsxs)(`li`,{className:`connected-app-row`,children:[(0,c.jsxs)(`div`,{className:`connected-app-meta`,children:[(0,c.jsx)(`div`,{className:`connected-app-name`,children:e.appName}),(0,c.jsxs)(`div`,{className:`muted small`,title:a(e.lastUsedAt),children:[`paired `,u(e.createdAt),` — last used `,u(e.lastUsedAt)]})]}),(0,c.jsx)(`div`,{className:`connected-app-actions`,children:(0,c.jsx)(`button`,{type:`button`,className:`danger`,onClick:()=>z(e),disabled:O!==null,children:`Revoke`})})]},e.appId))})]}),(0,c.jsxs)(`div`,{className:`settings-subsection`,children:[(0,c.jsx)(`h3`,{children:`Paired servers`}),(0,c.jsxs)(`div`,{className:`remote-pair-form`,children:[(0,c.jsx)(`input`,{type:`text`,placeholder:`https://192.168.1.50:6229`,value:A,onChange:e=>j(e.target.value)}),(0,c.jsx)(`input`,{type:`text`,placeholder:`Name (optional)`,value:M,onChange:e=>N(e.target.value)}),(0,c.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void Q(),disabled:O!==null||!A.trim(),children:O===`pair`?`Pairing…`:`Pair`})]}),e.length===0?(0,c.jsx)(`p`,{className:`muted small`,children:`No servers paired yet.`}):(0,c.jsx)(`ul`,{className:`settings-list`,children:e.map(e=>(0,c.jsxs)(`li`,{className:`connected-app-row`,children:[(0,c.jsxs)(`div`,{className:`connected-app-meta`,children:[(0,c.jsx)(`div`,{className:`connected-app-name`,children:e.displayName}),(0,c.jsxs)(`div`,{className:`muted small`,title:a(e.lastSeenAt),children:[e.baseUrl,` — identity code`,` `,(0,c.jsx)(`code`,{children:l(e.pinnedIdentityFingerprint)}),` — last seen`,` `,u(e.lastSeenAt)]})]}),(0,c.jsx)(`div`,{className:`connected-app-actions`,children:(0,c.jsx)(`button`,{type:`button`,className:`danger`,onClick:()=>L(e),disabled:O!==null,children:`Unpair`})})]},e.remoteId))})]}),(0,c.jsx)(o,{open:P!==null,title:P?.identityChanged?`Server identity changed`:`Check the identity code`,message:P?(0,c.jsxs)(c.Fragment,{children:[`On the server device, open Settings → Remote Servers and check that it shows this same identity code:`,(0,c.jsxs)(`div`,{className:`device-code-block`,children:[(0,c.jsx)(`code`,{className:`device-code`,children:l(P.fingerprint)}),(0,c.jsxs)(`details`,{className:`device-code-full`,children:[(0,c.jsx)(`summary`,{className:`muted small`,children:`Show the full fingerprint`}),(0,c.jsx)(`code`,{style:{wordBreak:`break-all`},children:P.fingerprint})]})]}),P.identityChanged&&P.existingFingerprint&&(0,c.jsxs)(c.Fragment,{children:[`This is not the code you trusted before. Continue only if you know why it changed — a reinstall or a wiped keychain does this, and so does someone impersonating the server. Previously trusted:`,` `,(0,c.jsx)(`code`,{children:l(P.existingFingerprint)})]})]}):null,confirmLabel:P?.identityChanged?`Trust new identity`:`The code matches`,danger:P?.identityChanged===!0,onConfirm:te,onCancel:()=>F(null)}),(0,c.jsx)(o,{open:I!==null,title:I?`Unpair ${I.displayName}?`:`Unpair server`,message:I?(0,c.jsxs)(c.Fragment,{children:[`This device will forget `,(0,c.jsx)(`strong`,{children:I.displayName}),` and its remote models will disappear from your model picker. You can pair again later.`]}):null,confirmLabel:`Unpair`,danger:!0,onConfirm:ne,onCancel:()=>L(null)}),(0,c.jsx)(o,{open:R!==null,title:R?`Revoke ${R.appName}?`:`Revoke device`,message:R?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`strong`,{children:R.appName}),` will immediately lose access to this machine's models. It can pair again later, which you would approve here.`]}):null,confirmLabel:`Revoke`,danger:!0,onConfirm:Z,onCancel:()=>z(null)})]})}export{m as RemoteServersPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-BPraLwsh.js";import{n as i,t as a}from"./relative-time-B2kBaekd.js";import{t as o}from"./ConfirmDialog-Dt1ed4Fh.js";var s=e(t(),1),c=n();function l(e){return(e.slice(0,16).match(/.{1,4}/g)??[]).join(` `)}function u(e){return e?i(e):`never`}var d={port:``,bindAddress:``,priority:`equal`,allowModels:``,maxConcurrentPerDevice:``,maxChatPerDevice:``,requestsPerMinute:``},ee=[{id:`equal`,label:`Equal`,title:`Remote turns queue like local work`},{id:`below-local`,label:`Local first`,title:`This machine's own work always drains first`},{id:`above-local`,label:`Remote first`,title:`Paired devices get priority over local work`}];function f(e){return{port:e?.port===void 0?``:String(e.port),bindAddress:e?.bindAddress??``,priority:e?.priority??`equal`,allowModels:(e?.allowModels??[]).join(`, `),maxConcurrentPerDevice:e?.limits?.maxConcurrentPerDevice===void 0?``:String(e.limits.maxConcurrentPerDevice),maxChatPerDevice:e?.limits?.maxChatPerDevice===void 0?``:String(e.limits.maxChatPerDevice),requestsPerMinute:e?.limits?.requestsPerMinute===void 0?``:String(e.limits.requestsPerMinute)}}function p(e,t){let n=e=>{let t=Number.parseInt(e.trim(),10);return Number.isFinite(t)&&t>0?t:void 0},r=n(e.port),i=e.bindAddress.trim(),a=e.allowModels.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean),o={},s=n(e.maxConcurrentPerDevice),c=n(e.maxChatPerDevice),l=n(e.requestsPerMinute);return s!==void 0&&(o.maxConcurrentPerDevice=s),c!==void 0&&(o.maxChatPerDevice=c),l!==void 0&&(o.requestsPerMinute=l),{enabled:t,...i?{bindAddress:i}:{},...r===void 0?{}:{port:r},...e.priority===`equal`?{}:{priority:e.priority},...a.length>0?{allowModels:a}:{},...Object.keys(o).length>0?{limits:o}:{}}}function m(){let[e,t]=(0,s.useState)([]),[n,i]=(0,s.useState)(null),[m,h]=(0,s.useState)(!1),[g,_]=(0,s.useState)(void 0),[v,y]=(0,s.useState)(null),[b,x]=(0,s.useState)([]),[S,C]=(0,s.useState)([]),[w,T]=(0,s.useState)(!1),[E,D]=(0,s.useState)(null),[O,k]=(0,s.useState)(null),[A,j]=(0,s.useState)(``),[M,N]=(0,s.useState)(``),[P,F]=(0,s.useState)(null),[I,L]=(0,s.useState)(null),[R,z]=(0,s.useState)(null),[B,V]=(0,s.useState)(d),[H,U]=(0,s.useState)(!1),W=(0,s.useRef)(!1),G=(0,s.useCallback)(e=>{W.current=e,U(e)},[]),K=(0,s.useCallback)(e=>{V(t=>({...t,...e})),G(!0)},[G]),q=(0,s.useCallback)(async()=>{try{let[e,n]=await Promise.all([r.listRemotes(),r.getConfig()]);t(e.remotes),h(!!n.remoteServing?.enabled),_(n.remoteServing?.port),W.current||V(f(n.remoteServing)),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}try{let e=await r.getMachineServing();y(e),h(!!e.config.enabled),_(e.status.port??e.config.port),W.current||V(f(e.config));let[t,n]=await Promise.all([r.listMachineServingGrants(),r.listMachineServingDevices()]);x(t.grants.filter(e=>e.status===`pending`)),C(n.devices)}catch{y(null),x([]),C([])}try{let e=await fetch(`${r.getBaseUrl()}/v1/identity`,{headers:r.authHeader()});if(e.ok){let t=await e.json();i({deviceId:t.deviceId,fingerprint:t.fingerprint})}}catch{}},[]);(0,s.useEffect)(()=>{if(!v){T(!1);return}let e=!1;return(async()=>{try{let t=await fetch(`${r.getBaseUrl()}/v1/apps`,{headers:r.authHeader()});if(!t.ok)return;let n=await t.json();e||T((n.apps??[]).some(e=>e.kind===`device`))}catch{}})(),()=>{e=!0}},[v]),(0,s.useEffect)(()=>{q();let e=window.setInterval(()=>void q(),5e3);return()=>window.clearInterval(e)},[q]);let J=(0,s.useCallback)(async e=>{k(`serving`);try{let t=p(B,e);if(v){let e=await r.updateMachineServing(t);y(e),h(!!e.config.enabled),_(e.status.port??e.config.port),V(f(e.config))}else{let e=await r.updateConfig({remoteServing:t});h(!!e.remoteServing?.enabled),_(e.remoteServing?.port),V(f(e.remoteServing))}G(!1),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}},[v,B,G]),Y=(0,s.useCallback)(()=>{G(!1),q()},[G,q]),X=(0,s.useCallback)(async(e,t)=>{k(`grant:${e.id}`);try{t?await r.approveMachineServingGrant(e.id):await r.denyMachineServingGrant(e.id),D(null),await q()}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}},[q]),Z=(0,s.useCallback)(async()=>{if(R){k(`revoke`);try{await r.revokeMachineServingDevice(R.appId),z(null),await q()}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}}},[R,q]),Q=(0,s.useCallback)(async()=>{if(!(!A.trim()||O)){k(`pair`);try{let e=A.trim(),t=await r.inspectRemote({baseUrl:e});F({baseUrl:e,...M.trim()?{displayName:M.trim()}:{},...t}),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}}},[A,M,O]),te=(0,s.useCallback)(async()=>{if(P){k(`pair`);try{await r.pairRemote({baseUrl:P.baseUrl,...P.displayName?{displayName:P.displayName}:{},expectedIdentityFingerprint:P.fingerprint,...P.identityChanged?{acceptIdentityChange:!0}:{}}),F(null),j(``),N(``),D(null),await q()}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}}},[P,q]),ne=(0,s.useCallback)(async()=>{if(I){k(`unpair`);try{await r.unpairRemote(I.remoteId),L(null),await q()}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}}},[I,q]),$=v?v.identity.fingerprint:n?.fingerprint??null;return(0,c.jsxs)(`section`,{className:`settings-section`,children:[(0,c.jsx)(`h2`,{children:`Remote Servers`}),(0,c.jsx)(`p`,{className:`muted small`,children:`Run models on another gezel device over your LAN. Pair with a powerful machine to use its big models as if they were local — chat and image/video/audio generation. The agentic loop and your files stay on this device; only the model runs remotely.`}),E&&(0,c.jsx)(`p`,{className:`settings-error`,role:`alert`,children:E}),(0,c.jsxs)(`div`,{className:`settings-subsection`,children:[(0,c.jsx)(`h3`,{children:v?`This machine as a server`:`This device as a server`}),(0,c.jsxs)(`label`,{className:`settings-toggle`,children:[(0,c.jsx)(`input`,{type:`checkbox`,checked:m,disabled:O===`serving`,onChange:e=>void J(e.target.checked)}),(0,c.jsx)(`span`,{children:`Serve my models to paired devices over the LAN`})]}),m?(0,c.jsxs)(`p`,{className:`muted small`,children:[`Other devices on your network can request inference here once you approve their pairing`,v?` below`:` (Connected Apps → Paired devices)`,`. They reach only inference — never your projects or files.`,v?` Served by the machine service, so it keeps working while nobody is logged in.`:``,` `,`Listening on port `,g??6229,`.`]}):(0,c.jsx)(`p`,{className:`muted small`,children:`Off — no other device can run models here.`}),$&&(0,c.jsxs)(`div`,{className:`device-code-block`,children:[(0,c.jsxs)(`span`,{className:`muted small`,children:[v?`This machine's identity code`:`This device's identity code`,` — when you pair from another device, check that it shows the same code:`]}),(0,c.jsx)(`code`,{className:`device-code`,children:l($)}),(0,c.jsxs)(`details`,{className:`device-code-full`,children:[(0,c.jsx)(`summary`,{className:`muted small`,children:`Show the full fingerprint`}),(0,c.jsx)(`code`,{style:{wordBreak:`break-all`},children:$})]})]}),v&&w&&(0,c.jsx)(`p`,{className:`muted small`,children:`Some devices paired with this account's daemon before the machine service took over serving. Those pairings no longer work — ask them to unpair and pair again against this machine's identity code above.`}),(0,c.jsxs)(`div`,{className:`remote-serving-fields`,children:[(0,c.jsxs)(`div`,{className:`remote-serving-field`,children:[(0,c.jsx)(`span`,{className:`muted small`,children:`Port`}),(0,c.jsx)(`input`,{type:`number`,min:1,max:65535,placeholder:`6229`,value:B.port,onChange:e=>K({port:e.target.value})})]}),(0,c.jsxs)(`div`,{className:`remote-serving-field`,children:[(0,c.jsx)(`span`,{className:`muted small`,children:`Network interface (IP)`}),(0,c.jsx)(`input`,{type:`text`,placeholder:`all networks (0.0.0.0)`,value:B.bindAddress,onChange:e=>K({bindAddress:e.target.value})})]}),(0,c.jsxs)(`div`,{className:`remote-serving-field`,children:[(0,c.jsx)(`span`,{className:`muted small`,children:`Max concurrent per device`}),(0,c.jsx)(`input`,{type:`number`,min:1,placeholder:`4`,value:B.maxConcurrentPerDevice,onChange:e=>K({maxConcurrentPerDevice:e.target.value})})]}),(0,c.jsxs)(`div`,{className:`remote-serving-field`,children:[(0,c.jsx)(`span`,{className:`muted small`,children:`Max chat per device`}),(0,c.jsx)(`input`,{type:`number`,min:1,placeholder:`same as concurrent`,value:B.maxChatPerDevice,onChange:e=>K({maxChatPerDevice:e.target.value})})]}),(0,c.jsxs)(`div`,{className:`remote-serving-field`,children:[(0,c.jsx)(`span`,{className:`muted small`,children:`Requests per minute per device`}),(0,c.jsx)(`input`,{type:`number`,min:1,placeholder:`unlimited`,value:B.requestsPerMinute,onChange:e=>K({requestsPerMinute:e.target.value})})]}),(0,c.jsxs)(`div`,{className:`remote-serving-field remote-serving-field-wide`,children:[(0,c.jsxs)(`span`,{className:`muted small`,children:[`Allowed models — comma-separated ids like `,(0,c.jsx)(`code`,{children:`llama-cpp:gemma4-e4b-q4`}),`; empty serves every installed model`]}),(0,c.jsx)(`input`,{type:`text`,placeholder:`all installed models`,value:B.allowModels,onChange:e=>K({allowModels:e.target.value})})]}),(0,c.jsxs)(`div`,{className:`remote-serving-field remote-serving-field-wide`,children:[(0,c.jsx)(`span`,{className:`muted small`,children:`When remote and local work compete`}),(0,c.jsx)(`div`,{className:`gz-tray`,role:`radiogroup`,"aria-label":`Remote work priority`,children:ee.map(e=>(0,c.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":B.priority===e.id,className:`gz-key${B.priority===e.id?` gz-key-active`:``}`,title:e.title,onClick:()=>K({priority:e.id}),children:e.label},e.id))})]})]}),H&&(0,c.jsxs)(`div`,{className:`remote-serving-actions`,children:[(0,c.jsx)(`button`,{type:`button`,className:`primary`,disabled:O!==null,onClick:()=>void J(m),children:O===`serving`?`Applying…`:`Apply server settings`}),(0,c.jsx)(`button`,{type:`button`,disabled:O!==null,onClick:Y,children:`Discard changes`})]})]}),v&&b.length>0&&(0,c.jsxs)(`div`,{className:`settings-subsection`,children:[(0,c.jsx)(`h3`,{children:`Pending pairing requests`}),(0,c.jsx)(`ul`,{className:`settings-list`,children:b.map(e=>(0,c.jsxs)(`li`,{className:`connected-app-row`,children:[(0,c.jsxs)(`div`,{className:`connected-app-meta`,children:[(0,c.jsx)(`div`,{className:`connected-app-name`,children:e.appName}),(0,c.jsxs)(`div`,{className:`muted small`,title:a(e.createdAt),children:[`requested `,u(e.createdAt),` — scopes: `,e.scopes.join(`, `)]})]}),(0,c.jsxs)(`div`,{className:`connected-app-actions`,children:[(0,c.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void X(e,!0),disabled:O!==null,children:`Approve`}),(0,c.jsx)(`button`,{type:`button`,onClick:()=>void X(e,!1),disabled:O!==null,children:`Deny`})]})]},e.id))})]}),v&&S.length>0&&(0,c.jsxs)(`div`,{className:`settings-subsection`,children:[(0,c.jsx)(`h3`,{children:`Devices paired with this machine`}),(0,c.jsx)(`ul`,{className:`settings-list`,children:S.map(e=>(0,c.jsxs)(`li`,{className:`connected-app-row`,children:[(0,c.jsxs)(`div`,{className:`connected-app-meta`,children:[(0,c.jsx)(`div`,{className:`connected-app-name`,children:e.appName}),(0,c.jsxs)(`div`,{className:`muted small`,title:a(e.lastUsedAt),children:[`paired `,u(e.createdAt),` — last used `,u(e.lastUsedAt)]})]}),(0,c.jsx)(`div`,{className:`connected-app-actions`,children:(0,c.jsx)(`button`,{type:`button`,className:`danger`,onClick:()=>z(e),disabled:O!==null,children:`Revoke`})})]},e.appId))})]}),(0,c.jsxs)(`div`,{className:`settings-subsection`,children:[(0,c.jsx)(`h3`,{children:`Paired servers`}),(0,c.jsxs)(`div`,{className:`remote-pair-form`,children:[(0,c.jsx)(`input`,{type:`text`,placeholder:`https://192.168.1.50:6229`,value:A,onChange:e=>j(e.target.value)}),(0,c.jsx)(`input`,{type:`text`,placeholder:`Name (optional)`,value:M,onChange:e=>N(e.target.value)}),(0,c.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void Q(),disabled:O!==null||!A.trim(),children:O===`pair`?`Pairing…`:`Pair`})]}),e.length===0?(0,c.jsx)(`p`,{className:`muted small`,children:`No servers paired yet.`}):(0,c.jsx)(`ul`,{className:`settings-list`,children:e.map(e=>(0,c.jsxs)(`li`,{className:`connected-app-row`,children:[(0,c.jsxs)(`div`,{className:`connected-app-meta`,children:[(0,c.jsx)(`div`,{className:`connected-app-name`,children:e.displayName}),(0,c.jsxs)(`div`,{className:`muted small`,title:a(e.lastSeenAt),children:[e.baseUrl,` — identity code`,` `,(0,c.jsx)(`code`,{children:l(e.pinnedIdentityFingerprint)}),` — last seen`,` `,u(e.lastSeenAt)]})]}),(0,c.jsx)(`div`,{className:`connected-app-actions`,children:(0,c.jsx)(`button`,{type:`button`,className:`danger`,onClick:()=>L(e),disabled:O!==null,children:`Unpair`})})]},e.remoteId))})]}),(0,c.jsx)(o,{open:P!==null,title:P?.identityChanged?`Server identity changed`:`Check the identity code`,message:P?(0,c.jsxs)(c.Fragment,{children:[`On the server device, open Settings → Remote Servers and check that it shows this same identity code:`,(0,c.jsxs)(`div`,{className:`device-code-block`,children:[(0,c.jsx)(`code`,{className:`device-code`,children:l(P.fingerprint)}),(0,c.jsxs)(`details`,{className:`device-code-full`,children:[(0,c.jsx)(`summary`,{className:`muted small`,children:`Show the full fingerprint`}),(0,c.jsx)(`code`,{style:{wordBreak:`break-all`},children:P.fingerprint})]})]}),P.identityChanged&&P.existingFingerprint&&(0,c.jsxs)(c.Fragment,{children:[`This is not the code you trusted before. Continue only if you know why it changed — a reinstall or a wiped keychain does this, and so does someone impersonating the server. Previously trusted:`,` `,(0,c.jsx)(`code`,{children:l(P.existingFingerprint)})]})]}):null,confirmLabel:P?.identityChanged?`Trust new identity`:`The code matches`,danger:P?.identityChanged===!0,onConfirm:te,onCancel:()=>F(null)}),(0,c.jsx)(o,{open:I!==null,title:I?`Unpair ${I.displayName}?`:`Unpair server`,message:I?(0,c.jsxs)(c.Fragment,{children:[`This device will forget `,(0,c.jsx)(`strong`,{children:I.displayName}),` and its remote models will disappear from your model picker. You can pair again later.`]}):null,confirmLabel:`Unpair`,danger:!0,onConfirm:ne,onCancel:()=>L(null)}),(0,c.jsx)(o,{open:R!==null,title:R?`Revoke ${R.appName}?`:`Revoke device`,message:R?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`strong`,{children:R.appName}),` will immediately lose access to this machine's models. It can pair again later, which you would approve here.`]}):null,confirmLabel:`Revoke`,danger:!0,onConfirm:Z,onCancel:()=>z(null)})]})}export{m as RemoteServersPanel};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-setup-DjhrGQui.js","assets/dist-BqGwkOe5.js","assets/rolldown-runtime-aKtaBQYM.js","assets/monaco-DeTXJU-n.js","assets/preload-helper-Czpn1I53.js","assets/chunk-V4NBQF5C-D9I4DV9v.js","assets/iconLabel-uMn49Ame.js","assets/iconLabel-Bdh_-Hrb.css","assets/codiconStyles-104B1IQ5.js","assets/codiconStyles-Bp1tMeMk.css","assets/editor.api-DShZZcgD.js","assets/editor-BOOlEWca.css","assets/monaco-Cvm179Eb.css","assets/monaco-base-B1H1U1Sw.js","assets/index-C0DYtvfg.js","assets/jsx-runtime-CEpd2cAX.js","assets/react-dom-OL4w_gzs.js","assets/dist-BaHut5iX.js","assets/api-BPraLwsh.js","assets/primitives-CWrGZpPI.js","assets/Tabs-jE0Z5Tzd.js","assets/document-companion-BQk2kS0F.js","assets/DropdownMenu-S4d9-3j3.js","assets/dist-pLLFUPO-.js","assets/relative-time-B2kBaekd.js","assets/FileTypeIcon-Cwzl1GkZ.js","assets/model-context-DBqdK0PS.js","assets/model-memory-copy-CeuXAj-T.js","assets/StorageCleanupDialog-OQlomMJD.js","assets/poppetje-DLB8uevw.js","assets/safe-svg-image-NbuPaBIv.js","assets/ConfirmDialog-Dt1ed4Fh.js","assets/model-inventory-ykSm_IT5.js","assets/doc-Dr5K49bx.js","assets/chunk-O7JILDEF-CqcO1qaI.js","assets/chunk-BAOV476U-CEOFYt8X.js","assets/chunk-4VOD55SX-BFSSw0c8.js","assets/chunk-GAZKTT4R-BkP6-w3z.js","assets/chunk-UBFT2CDQ-FexGDigd.js","assets/chunk-XRW6P7IF-BeQQgMVK.js","assets/chunk-7ZAAICW4-BsCpYJH6.js","assets/markdown-ryKA_OmY.js","assets/schemas-JY4jmLbC.js","assets/chunk-6ECMNUIP-DDVjPyfK.js","assets/inlineIconMarker-BQI2HLeD.js","assets/chunk-TT6ENR6T-CaYjVwjm.js","assets/chunk-DAMIRKTO-CGniCSiM.js","assets/new-project-meta-_f9sfcRX.js","assets/chunk-AE3IUKMM-mZjzzO8Z.js","assets/index-B8NcxqcR.css"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{Mt as r,Y as i,bt as a,dn as o,mn as s,pn as c,wt as l}from"./dist-BqGwkOe5.js";import{i as u,n as d,r as f,t as p}from"./Tabs-jE0Z5Tzd.js";import{t as m}from"./preload-helper-Czpn1I53.js";import{t as h}from"./GezelJsonEditor-7vDGyBib.js";import{ht as g}from"./index-C0DYtvfg.js";var _=e(t(),1),v=n();function y(e){e.trigger(`gezel-preamble`,`editor.fold`,{selectionLines:[1]})}var b=(0,_.forwardRef)(function({projectId:e,scriptName:t,initialSource:n,collapsePreambleOnMount:r,readOnly:i,onChangeContent:a,onSave:o,onProblems:s,onReady:c},l){let u=(0,_.useRef)(null),d=(0,_.useRef)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(null),[h,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),C=g(),w=(0,_.useRef)(a),T=(0,_.useRef)(o),E=(0,_.useRef)(s),D=(0,_.useRef)(c);(0,_.useEffect)(()=>{w.current=a,T.current=o,E.current=s,D.current=c},[a,o,s,c]);let O=(0,_.useRef)(n),k=(0,_.useRef)(r??!1),A=(0,_.useRef)(C);return A.current=C,(0,_.useEffect)(()=>{let n=!1,r=[];return(async()=>{let a;try{a=await m(()=>import(`./monaco-setup-DjhrGQui.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49]));let{api:e}=await m(async()=>{let{api:e}=await import(`./api-BPraLwsh.js`).then(e=>e.n);return{api:e}},__vite__mapDeps([18,2,17,1]));await a.ensureScriptTypescript(()=>e.getSdkTypes())}catch(e){n||S(e.message);return}if(n||!u.current)return;let o=a.monaco;d.current=o;let s=a.scriptModelUri(e,t);o.editor.getModel(s)?.dispose();let c=o.editor.createModel(O.current,`typescript`,s);p.current=c;let l=o.editor.create(u.current,{model:c,automaticLayout:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,tabSize:2,fixedOverflowWidgets:!0,readOnly:i??!1});f.current=l,o.editor.setTheme(A.current===`dark`?`gezel-dark`:`gezel-light`),k.current&&y(l),r.push(c.onDidChangeContent(()=>w.current?.(c.getValue()))),l.addCommand(o.KeyMod.CtrlCmd|o.KeyCode.KeyS,()=>T.current?.()),r.push(o.editor.onDidChangeMarkers(e=>{if(!e.some(e=>e.toString()===s.toString()))return;let t=o.editor.getModelMarkers({resource:s});E.current?.(t.map(e=>({severity:e.severity===o.MarkerSeverity.Error?`error`:e.severity===o.MarkerSeverity.Warning?`warning`:`info`,message:e.message,line:e.startLineNumber,column:e.startColumn})))})),b(!0),D.current?.()})(),()=>{n=!0;for(let e of r)e.dispose();f.current?.dispose(),f.current=null,p.current?.dispose(),p.current=null}},[e,t,i]),(0,_.useEffect)(()=>{d.current?.editor.setTheme(C===`dark`?`gezel-dark`:`gezel-light`)},[C]),(0,_.useImperativeHandle)(l,()=>({getValue:()=>p.current?.getValue()??null,setValue:e=>p.current?.setValue(e),revealLine:e=>{f.current?.revealLineInCenter(e),f.current?.setPosition({lineNumber:e,column:1}),f.current?.focus()},focus:()=>f.current?.focus(),collapsePreamble:()=>{f.current&&y(f.current)},setServerDiagnostics:e=>{let t=d.current,n=p.current;!t||!n||t.editor.setModelMarkers(n,`gezel-save`,e.map(e=>({severity:e.severity===`error`?t.MarkerSeverity.Error:e.severity===`warning`?t.MarkerSeverity.Warning:t.MarkerSeverity.Info,message:e.message,startLineNumber:e.line??1,startColumn:e.column??1,endLineNumber:e.line??1,endColumn:e.column?e.column+1:1})))}}),[]),(0,v.jsxs)(`div`,{className:`script-code-editor`,children:[!h&&!x&&(0,v.jsx)(`p`,{className:`muted small`,children:`Loading editor…`}),x&&(0,v.jsxs)(`p`,{className:`script-code-editor__error`,children:[`Editor failed to load: `,x]}),(0,v.jsx)(`div`,{ref:u,className:`script-code-editor__host`})]})});function x({value:e,onChange:t,readOnly:n,issues:r}){return(0,v.jsxs)(`div`,{className:`script-meta-form`,children:[(0,v.jsx)(h,{schema:(0,_.useMemo)(()=>O(),[]),value:e,onChange:n?void 0:e=>t(e??{}),density:`compact`}),r&&r.length>0&&(0,v.jsx)(`ul`,{className:`script-meta-form__issues small`,children:r.map((e,t)=>(0,v.jsx)(`li`,{className:`error`,children:e},`${t}:${e}`))})]})}var S={type:`string`,title:`Name`,pattern:`^[a-zA-Z][\\w-]*$`,squisq:{width:`half`,help:`Becomes a key on the input/output object.`}},C={type:`string`,title:`Description`,squisq:{control:`multiline`,help:`What it is, for teammates and the test-run form.`}},w={type:`boolean`,title:`Required`},T={type:`string`,squisq:{control:`multiline`,help:`JSON (parsed on save).`}};function E(e,t,n){return{type:`object`,title:t,required:[`name`,`type`,`description`],properties:{name:S,type:{type:`string`,const:e,title:`Type`,squisq:{width:`half`}},description:C,required:w,...n}}}function D(e,t,n){return{type:`object`,title:t,required:[`name`,`type`,`description`],properties:{name:S,type:{type:`string`,const:e,title:`Type`,squisq:{width:`half`}},description:C,...n}}}function O(){return{type:`object`,required:[`name`,`description`],properties:{name:{type:`string`,title:`Script name`,pattern:`^[a-zA-Z][\\w-]*$`,squisq:{width:`half`,help:`Letters, digits, _ or -; must start with a letter.`}},description:{type:`string`,title:`Description`,minLength:10,squisq:{control:`multiline`,help:`At least 10 characters.`}},kind:{type:`string`,title:`Kind`,enum:[`action`,`gate`],default:`action`,squisq:{control:`segmented`,width:`half`,enumLabels:{action:`Action`,gate:`Gate`},help:`Gate scripts return a decision for a step gate.`}},inputs:{type:`array`,title:`Inputs`,squisq:{control:`card-stack`,addLabel:`Add input`,itemLabel:{fromField:`name`}},items:{type:`object`,required:[`name`,`type`,`description`],oneOf:[E(`string`,`Text`,{default:{type:`string`,title:`Default`},pattern:{type:`string`,title:`Pattern (regex)`},multiline:{type:`boolean`,title:`Multiline`}}),E(`number`,`Number`,{default:{type:`number`,title:`Default`},min:{type:`number`,title:`Min`,squisq:{width:`third`}},max:{type:`number`,title:`Max`,squisq:{width:`third`}},integer:{type:`boolean`,title:`Integer only`,squisq:{width:`third`}}}),E(`boolean`,`Boolean`,{default:{type:`boolean`,title:`Default`}}),E(`choice`,`Choice`,{default:{type:`string`,title:`Default`},options:{type:`array`,title:`Options`,minItems:1,squisq:{control:`card-stack`,addLabel:`Add option`,itemLabel:{fromField:`value`}},items:{type:`object`,required:[`value`],properties:{value:{type:`string`,title:`Value`,squisq:{width:`half`}},label:{type:`string`,title:`Label`,squisq:{width:`half`}}}}}}),E(`ref`,`Reference`,{kind:{type:`string`,title:`Refers to`,enum:[`gezel`,`task`,`artifact`,`document`],squisq:{control:`segmented`}}}),E(`json`,`JSON`,{defaultJson:{...T,title:`Default (JSON)`},schemaJson:{...T,title:`Schema (JSON)`}})]}},outputs:{type:`array`,title:`Outputs`,squisq:{control:`card-stack`,addLabel:`Add output`,itemLabel:{fromField:`name`}},items:{type:`object`,required:[`name`,`type`,`description`],oneOf:[D(`string`,`Text`,{nullable:{type:`boolean`,title:`Nullable`}}),D(`number`,`Number`,{nullable:{type:`boolean`,title:`Nullable`}}),D(`boolean`,`Boolean`,{nullable:{type:`boolean`,title:`Nullable`}}),D(`array`,`Array`,{itemType:{type:`string`,title:`Item type`,enum:[`string`,`number`,`boolean`,`object`],squisq:{control:`segmented`}}}),D(`object`,`Object`,{schemaJson:{...T,title:`Schema (JSON)`}}),D(`json`,`JSON`,{schemaJson:{...T,title:`Schema (JSON)`}})]}},requires:{type:`array`,title:`Allowed to (capabilities)`,squisq:{control:`chip-bin`,addLabel:`Add capability`,help:`e.g. network, llm, tasks.write, credential:github.token`},items:{type:`string`}}}}}var k=(0,_.forwardRef)(function({projectId:e,scriptName:t,initialSource:n,initialMeta:m,readOnly:h,onChangeContent:g,onSave:y,onProblems:S,onReady:C},w){let T=(0,_.useRef)(null),E=(0,_.useRef)(n),D=(0,_.useRef)(c(n)),O=(0,_.useRef)(!1),k=(0,_.useRef)(!1),A=(0,_.useRef)(0),[j,M]=(0,_.useState)(`script`),N=(0,_.useMemo)(()=>{if(m)return{value:l(m),ok:!0};let e=r(D.current.metaText);return e.ok?{value:l(e.meta),ok:!0}:{value:null,ok:!1}},[]),[P,F]=(0,_.useState)(N.value),[I,L]=(0,_.useState)(N.ok),[R,z]=(0,_.useState)([]),B=D.current.found,V=e=>{A.current++,T.current?.setValue(e),T.current?.collapsePreamble(),A.current--},H=()=>{let e=r(D.current.metaText);e.ok?(F(l(e.meta)),z([]),L(!0)):L(!1)},U=e=>{A.current>0||(E.current=e,D.current=c(e),k.current=!0,g?.(e))},W=e=>{F(e);let t=i(e);if(!t.ok){z(t.issues);return}z([]);let n=o(t.meta);D.current={...D.current,metaText:n,found:!0};let r=s({preamble:D.current.preamble,metaText:a(D.current),body:D.current.body});E.current=r,O.current=!0,g?.(r)},G=e=>{e===`script`&&O.current?(V(E.current),O.current=!1):e===`properties`&&k.current&&(H(),k.current=!1),M(e)};(0,_.useImperativeHandle)(w,()=>({getValue:()=>E.current,setValue:e=>{E.current=e,D.current=c(e),V(e),H(),O.current=!1,k.current=!1,g?.(e)},revealLine:e=>{j!==`script`&&G(`script`),T.current?.revealLine(e)},focus:()=>T.current?.focus(),setServerDiagnostics:e=>T.current?.setServerDiagnostics(e)}),[j]);let K=!B||!I;return(0,v.jsx)(`div`,{className:`script-editor-tabs`,children:(0,v.jsxs)(f,{value:j,onValueChange:e=>G(e),children:[(0,v.jsxs)(d,{"aria-label":`Script editor`,children:[(0,v.jsx)(u,{value:`script`,children:`Script`}),(0,v.jsx)(u,{value:`properties`,disabled:K,children:`Properties`})]}),(0,v.jsx)(p,{value:`script`,forceMount:!0,className:`script-editor-tabs__panel`,children:(0,v.jsx)(b,{ref:T,projectId:e,scriptName:t,initialSource:n,collapsePreambleOnMount:!0,readOnly:h,onChangeContent:U,onSave:y,onProblems:S,onReady:C})}),(0,v.jsx)(p,{value:`properties`,forceMount:!0,className:`script-editor-tabs__panel`,children:K||!P?(0,v.jsx)(`p`,{className:`placeholder small`,children:`The meta block can't be shown as a form — expand the setup section at the top of the Script tab and edit it there.`}):(0,v.jsx)(x,{value:P,onChange:W,readOnly:h,issues:R})})]})})});export{k as t};
@@ -0,0 +1,5 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{Ot as r,kt as i}from"./dist-BqGwkOe5.js";import{t as a}from"./dist-BaHut5iX.js";import{t as o}from"./api-BPraLwsh.js";import{i as s,n as c,r as ee,t as l}from"./Tabs-jE0Z5Tzd.js";import"./primitives-CWrGZpPI.js";import{t as te}from"./ConfirmDialog-Dt1ed4Fh.js";import{t as ne}from"./ScriptEditorTabs-BFvIiDFZ.js";import{a as u,i as re,n as ie,o as ae,r as oe,s as d}from"./pending-drafts-B11MKQ9R.js";var f=e(t(),1),p=n(),m=new Map;function h(e){return`gezel:script-draft:${e}`}function se(e){let t=m.get(e);if(t!==void 0)return t;try{return window.localStorage.getItem(h(e))}catch{return null}}function g(e,t){m.set(e,t);try{window.localStorage.setItem(h(e),t)}catch{}}function ce(e){m.delete(e);try{window.localStorage.removeItem(h(e))}catch{}}function _(){m.clear()}var v=[{kind:`craftbook`,marker:`// @gezel-craftbook:`},{kind:`import`,marker:`// @gezel-import:`}];function le(e){for(let{kind:t,marker:n}of v){if(!e.startsWith(n))continue;let r=e.indexOf(`
2
+ `);return{kind:t,ref:(r===-1?e:e.slice(0,r)).slice(n.length).trim()}}return null}function ue(e){if(!v.some(({marker:t})=>e.startsWith(t)))return e;let t=e.indexOf(`
3
+ `);return t===-1?``:e.slice(t+1)}function de(e){return e?.includes(`did not declare it in meta.requires`)?/capability:\s*([\w.:-]+)/.exec(e)?.[1]??null:null}function fe(e,t){let n=/requires:\s*\[([^\]]*)\]/.exec(e);if(!n)return null;let r=(n[1]??``).trim().length>0?`requires: [${n[1]}, '${t}']`:`requires: ['${t}']`;return e.slice(0,n.index)+r+e.slice(n.index+n[0].length)}function pe(e,t){let n=[];for(let a of e)for(let e of a.craftbook.steps){let o={taskRef:a.ref,taskTitle:a.title,stepName:e.name};r(e.onEnter).some(e=>e.name===t)&&n.push({...o,moment:`enter`}),e.gate&&i(e.gate).scripts.some(e=>e.name===t)&&n.push({...o,moment:`gate`}),r(e.onExit).some(e=>e.name===t)&&n.push({...o,moment:`exit`})}return n}function y({projectId:e,scriptName:t,scope:n}){let r=`${n?`${n}:`:``}${e}/${t}`,i=(0,f.useRef)(null),h=n===`standard`,[_,v]=(0,f.useState)(null),[y,he]=(0,f.useState)(null),b=(0,f.useRef)(``),[x,S]=(0,f.useState)(!1),[C,ge]=(0,f.useState)(!1),[_e,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(void 0),[D,O]=(0,f.useState)(!0),[ve,ye]=(0,f.useState)([]),[k,be]=(0,f.useState)([]),[A,j]=(0,f.useState)(null),[M,N]=(0,f.useState)(null),[P,xe]=(0,f.useState)(!1),[Se,F]=(0,f.useState)(!1),[Ce,I]=(0,f.useState)(!1),[L,we]=(0,f.useState)([]),[R,z]=(0,f.useState)(`about`),[Te,B]=(0,f.useState)(null),[V,H]=(0,f.useState)({}),[Ee,De]=(0,f.useState)(!1),[Oe,U]=(0,f.useState)(null),[W,ke]=(0,f.useState)(null),[Ae,je]=(0,f.useState)(null),[Me,Ne]=(0,f.useState)(!1),G=(0,f.useRef)(null),K=(0,f.useRef)(null),q=(0,f.useCallback)(()=>{G.current&&clearTimeout(G.current),G.current=null,K.current=null,ce(r)},[r]);(0,f.useEffect)(()=>()=>{if(!G.current)return;clearTimeout(G.current),G.current=null;let e=K.current;K.current=null,e!==null&&g(r,e)},[r]),(0,f.useEffect)(()=>{let a=!1;return(n===`standard`?o.getStandardScriptSource(t):n===`user`?o.getUserScriptSource(t):o.getProjectScriptSource(e,t)).then(n=>{if(a)return;let s=se(r);b.current=n.source,v(s!==null&&s!==n.source?{...n,source:s}:n),S(s!==null&&s!==n.source),I(s!==null&&s!==n.source),E(n.meta),O(!n.metaError),N(n.provenance??null),n.metaError&&ye([{severity:`error`,source:`meta`,message:n.metaError}]),n.meta&&H(u(n.meta));let c=ie(r);c&&(B(`busy`),o.draftProjectScript(e,{name:t,description:c}).then(({source:e})=>{a||(B(null),i.current?i.current.setValue(e):(v(t=>t&&{...t,source:e}),S(!0),m.set(r,e)))}).catch(()=>{a||B(`failed`)}))}).catch(e=>{a||he(e.message)}),o.listProjectTasks(e).then(e=>{a||we(pe(e.tasks,t))}).catch(()=>{}),()=>{a=!0}},[e,t,n,r]);let J=(0,f.useCallback)(e=>{let t=e!==b.current;if(S(t),!t){q();return}m.set(r,e),K.current=e,G.current&&clearTimeout(G.current),G.current=setTimeout(()=>{G.current=null,K.current=null,g(r,e)},500)},[r,q]),Y=(0,f.useCallback)(async(r={})=>{let a=i.current?.getValue();if(a==null||!_)return!1;ge(!0),w(null);try{if(n===`standard`)return!1;let s={name:t,source:a,baseHash:r.overrideHash??_.hash},c=n===`user`?await o.saveUserScriptSource(s):await o.saveProjectScriptSource(e,s);return c.status===`conflict`?(j({currentHash:c.currentHash,currentSource:c.currentSource}),!1):(b.current=a,v({..._,source:a,hash:c.hash}),S(!1),I(!1),q(),j(null),O(c.metaOk),c.meta&&(E(c.meta),H(e=>({...u(c.meta),...e}))),ye(c.diagnostics),i.current?.setServerDiagnostics(c.diagnostics),N(le(a)),c.metaOk)}catch(e){return w(e.message),!1}finally{ge(!1)}},[_,q,e,t,n]),Pe=(0,f.useCallback)(()=>{!A||!_||(b.current=A.currentSource,v({..._,source:A.currentSource,hash:A.currentHash}),i.current?.setValue(A.currentSource),S(!1),I(!1),q(),N(le(A.currentSource)),j(null))},[A,_,q]),Fe=(0,f.useCallback)(()=>{A&&Y({overrideHash:A.currentHash})},[A,Y]),Ie=(0,f.useCallback)(()=>{q(),i.current?.setValue(b.current),v(e=>e&&{...e,source:b.current}),S(!1),I(!1)},[q]);(0,f.useEffect)(()=>{let n=()=>{!_||C||A||o.getProjectScriptSource(e,t).then(e=>{e.hash!==_.hash&&(x?j({currentHash:e.hash,currentSource:e.source}):(b.current=e.source,v(e),i.current?.setValue(e.source),E(e.meta),O(!e.metaError),N(e.provenance??null)))}).catch(()=>{})};return window.addEventListener(`focus`,n),()=>window.removeEventListener(`focus`,n)},[_,x,C,A,e,t]);let X=M!==null&&!P||h,Le=(0,f.useCallback)(async()=>{let n=i.current?.getValue()??_?.source;if(!n)return;let r=ue(n);for(let n=0;n<5;n++){let i=n===0?`${t}-custom`:`${t}-custom-${n+1}`;try{await o.createProjectScript(e,{name:i,source:r}),q(),window.dispatchEvent(new CustomEvent(`gezel:open-tab`,{detail:{kind:`script`,projectId:e,name:i,activate:!0}}));return}catch(e){if(e instanceof a&&e.status===409)continue;w(e.message);return}}w(`could not find a free name for the copy`)},[_,q,e,t]),Z=(0,f.useCallback)(async()=>{De(!0),U(null),ke(null),je(null);try{if(x||C){if(!await Y())return}else if(!D){U(`Fix the meta block before running.`);return}let r;try{r=await o.runProjectScript(e,{name:t,...n?{scope:n}:{},input:V})}catch(e){let t=e instanceof a?e.details:null;if(t&&typeof t==`object`&&`runId`in t)r=t;else throw e}ke(r),o.getProjectScriptRun(e,r.runId).then(je).catch(()=>{})}catch(e){U(e.message)}finally{De(!1)}},[x,D,e,V,Y,C,n,t]),Q=de(W?.error),Re=(0,f.useCallback)(async()=>{if(!Q)return;let e=i.current?.getValue();if(!e)return;let t=fe(e,Q);if(!t){let t=e.slice(0,e.indexOf(`meta`)).split(`
4
+ `).length;i.current?.revealLine(Math.max(1,t));return}Ne(!0);try{i.current?.setValue(t),J(t),await Z()}finally{Ne(!1)}},[J,Z,Q]),$=(0,f.useMemo)(()=>k.filter(e=>e.severity===`error`).length,[k]),ze=()=>window.dispatchEvent(new CustomEvent(`gezel:open-tab`,{detail:{kind:`area`,area:`scripts`,activate:!0}})),Be=e=>window.dispatchEvent(new CustomEvent(`gezel:open-tab`,{detail:{kind:`task`,ref:e.taskRef,activate:!0}}));return y?(0,p.jsx)(`div`,{className:`script-editor-view`,children:(0,p.jsx)(`p`,{className:`scripts-view__error`,children:y.includes(`404`)||y.includes(`not found`)?`Script "${t}" does not exist in this project.`:`Error: ${y}`})}):_?(0,p.jsxs)(`div`,{className:`script-editor-view`,children:[(0,p.jsxs)(`header`,{className:`script-editor-header`,children:[(0,p.jsx)(`button`,{type:`button`,className:`script-editor-back muted`,onClick:ze,title:`All scripts`,"aria-label":`Back to scripts`,children:`‹`}),(0,p.jsxs)(`div`,{className:`script-editor-title`,children:[(0,p.jsx)(`h1`,{children:t}),T?.description&&(0,p.jsx)(`p`,{className:`muted small`,children:T.description})]}),(0,p.jsx)(ae,{requires:T?.requires}),L.length>0&&(0,p.jsxs)(`button`,{type:`button`,className:`script-editor-usages muted small`,onClick:()=>Be(L[0]),title:L.map(e=>`${e.taskTitle} — ${e.stepName} (on ${e.moment})`).join(`
5
+ `),children:[`Runs on `,L.length,` task step`,L.length===1?``:`s`]}),(0,p.jsxs)(`div`,{className:`script-editor-actions`,children:[x&&(0,p.jsx)(`span`,{className:`script-editor-dirty small`,title:`Unsaved changes`,children:`● Unsaved`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>void Y(),disabled:!x||C||X,children:C?`Saving…`:`Save`}),(0,p.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>{z(`run`)},children:`Test run`}),(0,p.jsx)(`button`,{type:`button`,className:`script-editor-rail-toggle muted`,onClick:()=>z(e=>e===null?`about`:null),title:R===null?`Show panel`:`Hide panel`,"aria-label":R===null?`Show panel`:`Hide panel`,children:R===null?`⟨`:`⟩`})]})]}),Te===`busy`&&(0,p.jsx)(`div`,{className:`script-editor-banner script-editor-banner--info`,children:(0,p.jsx)(`span`,{children:`Drafting with AI… you can start editing; the draft will replace the buffer.`})}),Te===`failed`&&(0,p.jsxs)(`div`,{className:`script-editor-banner script-editor-banner--warn`,children:[(0,p.jsx)(`span`,{children:`The AI draft didn't come through — starting from the blank skeleton instead.`}),(0,p.jsx)(`button`,{type:`button`,className:`muted small`,onClick:()=>B(null),children:`Dismiss`})]}),Ce&&(0,p.jsxs)(`div`,{className:`script-editor-banner script-editor-banner--info`,children:[(0,p.jsx)(`span`,{children:`Restored your unsaved changes from last time.`}),(0,p.jsx)(`button`,{type:`button`,className:`muted small`,onClick:Ie,children:`Discard them`})]}),A&&(0,p.jsxs)(`div`,{className:`script-editor-banner script-editor-banner--warn`,children:[(0,p.jsx)(`span`,{children:`This script changed on disk while you were editing.`}),(0,p.jsx)(`button`,{type:`button`,onClick:Pe,children:`Reload from disk`}),(0,p.jsx)(`button`,{type:`button`,onClick:Fe,children:`Overwrite with my version`})]}),M&&(0,p.jsxs)(`div`,{className:`script-editor-banner script-editor-banner--warn`,children:[(0,p.jsx)(`span`,{children:M.kind===`standard`?`Standard library — packed into the app and read-only. Duplicate it into this project to customize.`:M.kind===`user`?`From your machine-wide library (~/.gezel/scripts). Edits here apply everywhere it is referenced.`:M.kind===`craftbook`?`Part of the ${M.ref} craftbook — updates to the craftbook replace this file, so direct edits would be lost.`:`Generated from import ${M.ref} — re-syncing the import replaces this file.`}),M.kind!==`user`&&(0,p.jsx)(`button`,{type:`button`,onClick:()=>void Le(),children:M.kind===`standard`?`Duplicate into this project`:`Make my own copy`}),!P&&M.kind!==`standard`&&M.kind!==`user`&&(0,p.jsx)(`button`,{type:`button`,className:`muted`,onClick:()=>F(!0),children:`Edit anyway`})]}),!D&&(0,p.jsx)(`div`,{className:`script-editor-banner script-editor-banner--warn`,children:`Saved, but the meta block is invalid — this script is hidden from lists and can't run until it's fixed.`}),_e&&(0,p.jsxs)(`div`,{className:`script-editor-banner script-editor-banner--error`,children:[`Save failed: `,_e]}),(0,p.jsxs)(`div`,{className:`script-editor-body`,children:[(0,p.jsx)(ne,{ref:i,projectId:e,scriptName:t,initialSource:_.source,initialMeta:T,readOnly:X,onChangeContent:J,onSave:()=>void Y(),onProblems:be,onReady:()=>{ve.length>0&&i.current?.setServerDiagnostics(ve)}}),R!==null&&(0,p.jsx)(`aside`,{className:`script-editor-rail`,children:(0,p.jsxs)(ee,{value:R,onValueChange:e=>z(e),children:[(0,p.jsxs)(c,{"aria-label":`Script panel`,children:[(0,p.jsx)(s,{value:`about`,children:`About`}),(0,p.jsx)(s,{value:`run`,children:`Test run`})]}),(0,p.jsx)(l,{value:`about`,children:(0,p.jsx)(me,{meta:T,provenance:M,usages:L})}),(0,p.jsx)(l,{value:`run`,children:(0,p.jsxs)(`div`,{className:`script-editor-run`,children:[T?.inputs&&Object.keys(T.inputs).length>0&&(0,p.jsxs)(`fieldset`,{className:`script-detail__inputs`,children:[(0,p.jsx)(`legend`,{children:`Inputs`}),(0,p.jsx)(re,{inputs:T.inputs,values:V,onChange:H})]}),(0,p.jsx)(`div`,{className:`script-detail__actions`,children:(0,p.jsx)(`button`,{type:`button`,className:`primary`,disabled:Ee||C||X,onClick:()=>void Z(),children:Ee?`Running…`:x?`Save & run`:`Run`})}),Oe&&(0,p.jsx)(`p`,{className:`scripts-view__error`,children:Oe}),W&&Q&&(0,p.jsxs)(`div`,{className:`script-editor-capfix`,children:[(0,p.jsx)(`p`,{children:(0,p.jsxs)(`strong`,{children:[`This script tried to use “`,d(Q),`”, but it isn't allowed to yet.`]})}),(0,p.jsx)(`p`,{className:`muted small`,children:`Scripts can only use what they declare up front in their meta block.`}),(0,p.jsx)(`button`,{type:`button`,className:`primary`,disabled:Me,onClick:()=>void Re(),children:Me?`Updating…`:`Allow “${d(Q)}” and run again`})]}),W&&T&&(0,p.jsx)(oe,{result:W,meta:T}),Ae?.logs&&(0,p.jsxs)(`section`,{className:`script-editor-logs`,children:[(0,p.jsx)(`h4`,{children:`Log`}),(0,p.jsx)(`pre`,{children:Ae.logs})]})]})})]})})]}),k.length>0&&(0,p.jsxs)(`footer`,{className:`script-editor-problems`,children:[(0,p.jsxs)(`strong`,{className:`small`,children:[`Problems (`,$>0?`${$} error${$===1?``:`s`}`:k.length,`)`]}),(0,p.jsx)(`ul`,{children:k.slice(0,50).map((e,t)=>(0,p.jsx)(`li`,{children:(0,p.jsxs)(`button`,{type:`button`,className:`script-editor-problem script-editor-problem--${e.severity}`,onClick:()=>i.current?.revealLine(e.line),children:[(0,p.jsx)(`span`,{className:`script-editor-problem-msg`,children:e.message}),(0,p.jsxs)(`span`,{className:`muted small`,children:[`line `,e.line]})]})},`${e.line}:${e.column}:${t}`))})]}),(0,p.jsx)(te,{open:Se,title:`Edit a managed script?`,message:`This file is replaced wholesale when its craftbook or import updates — your edits would be lost then. Making your own copy is the safe way to customize it.`,confirmLabel:`Edit anyway`,danger:!0,onConfirm:()=>{xe(!0),F(!1)},onCancel:()=>F(!1)})]}):(0,p.jsx)(`div`,{className:`script-editor-view`,children:(0,p.jsx)(`p`,{className:`muted small`,children:`Loading script…`})})}function me({meta:e,provenance:t,usages:n}){return e?(0,p.jsxs)(`div`,{className:`script-editor-about`,children:[(0,p.jsx)(`p`,{children:e.description}),e.inputs&&Object.keys(e.inputs).length>0&&(0,p.jsxs)(`section`,{children:[(0,p.jsx)(`h4`,{children:`Takes`}),(0,p.jsx)(`ul`,{children:Object.entries(e.inputs).map(([e,t])=>(0,p.jsxs)(`li`,{children:[(0,p.jsx)(`code`,{children:e}),` — `,t.description,t.required?` (required)`:``]},e))})]}),e.outputs&&Object.keys(e.outputs).length>0&&(0,p.jsxs)(`section`,{children:[(0,p.jsx)(`h4`,{children:`Produces`}),(0,p.jsx)(`ul`,{children:Object.entries(e.outputs).map(([e,t])=>(0,p.jsxs)(`li`,{children:[(0,p.jsx)(`code`,{children:e}),` — `,t.description]},e))})]}),e.requires&&e.requires.length>0&&(0,p.jsxs)(`section`,{children:[(0,p.jsx)(`h4`,{children:`Allowed to`}),(0,p.jsx)(`ul`,{children:e.requires.map(e=>(0,p.jsxs)(`li`,{children:[d(e),` `,(0,p.jsx)(`code`,{className:`muted small`,children:e})]},e))})]}),(0,p.jsxs)(`section`,{children:[(0,p.jsx)(`h4`,{children:`Origin`}),(0,p.jsx)(`p`,{className:`muted small`,children:t?t.kind===`standard`?`Standard library (${t.ref}) — ships with the app.`:t.kind===`user`?`Your machine-wide library (~/.gezel/scripts).`:t.kind===`craftbook`?`Installed by the ${t.ref} craftbook.`:`Generated from import ${t.ref}.`:`A script of this project.`})]}),n.length>0&&(0,p.jsxs)(`section`,{children:[(0,p.jsx)(`h4`,{children:`Used by`}),(0,p.jsx)(`ul`,{children:n.map(e=>(0,p.jsxs)(`li`,{children:[e.taskTitle,` — `,e.stepName,` (on `,e.moment,`)`]},`${e.taskRef}:${e.stepName}:${e.moment}`))})]})]}):(0,p.jsx)(`p`,{className:`muted small`,children:`This script's meta block doesn't parse yet, so there's nothing to summarize. Fix the problems listed below the editor.`})}export{y as ScriptEditorView,_ as __clearAllScriptDrafts};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-BX5xXiFs.js";import{a as i,i as a,o,r as s}from"./pending-drafts-YVW6X55O.js";import{t as c}from"./NewScriptDialog-D-gkY8TS.js";var l=e(t(),1),u=n(),d=`shared-library`,f=`default`;function p({projectId:e}={}){let[t,n]=(0,l.useState)([]),[a,o]=(0,l.useState)(e??d),[s,p]=(0,l.useState)([]),[h,g]=(0,l.useState)(null),[_,v]=(0,l.useState)(null),[y,b]=(0,l.useState)({}),[x,S]=(0,l.useState)(!1),[C,w]=(0,l.useState)(null),[T,E]=(0,l.useState)(!1),D=a===d,O=D?e??f:a;(0,l.useEffect)(()=>{if(e!==void 0){o(e);return}r.listProjects().then(e=>n(e.projects)).catch(e=>v(e.message))},[e]);let k=(0,l.useCallback)(async e=>{try{let t=e===d?await r.listUserScripts():e?await r.listProjectScripts(e):{scripts:[]};p(t.scripts)}catch(e){v(e.message)}},[]);(0,l.useEffect)(()=>{k(a)},[a,k]),(0,l.useEffect)(()=>{g(e=>e&&s.some(t=>t.name===e)?e:s[0]?.name??null)},[s]);let A=(0,l.useMemo)(()=>s.find(e=>e.name===h)??null,[s,h]);(0,l.useEffect)(()=>{if(!A){b({}),w(null);return}b(i(A.meta)),w(null)},[A]);let j=(0,l.useCallback)(async()=>{if(A){S(!0),v(null);try{let e=await r.runProjectScript(O,{name:A.name,...D?{scope:`user`}:{},input:y});w(e)}catch(e){v(e.message)}finally{S(!1)}}},[A,O,D,y]),M=(0,l.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`gezel:open-tab`,{detail:{kind:`script`,projectId:O,name:e,...D?{scope:`user`}:{},activate:!0}}))},[O,D]);return(0,u.jsxs)(`div`,{className:`scripts-view`,"data-testid":`scripts-view`,children:[(0,u.jsxs)(`header`,{className:`scripts-view__header`,children:[(0,u.jsx)(`h1`,{children:`Scripts`}),(0,u.jsxs)(`div`,{className:`scripts-view__toolbar`,children:[e===void 0&&(0,u.jsxs)(`label`,{className:`scripts-view__field`,children:[(0,u.jsx)(`span`,{children:`Scripts from`}),(0,u.jsxs)(`select`,{value:a,onChange:e=>{o(e.target.value),g(null)},children:[(0,u.jsx)(`option`,{value:d,children:`Shared library`}),t.map(e=>(0,u.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,u.jsxs)(`label`,{className:`scripts-view__field`,children:[(0,u.jsx)(`span`,{children:`Script`}),(0,u.jsx)(`select`,{value:h??``,disabled:s.length===0,onChange:e=>g(e.target.value||null),children:s.map(e=>(0,u.jsx)(`option`,{value:e.name,children:e.meta.name},e.name))})]}),(0,u.jsx)(`button`,{type:`button`,className:`primary scripts-view__new`,onClick:()=>E(!0),children:`New script`})]})]}),_&&(0,u.jsxs)(`p`,{className:`scripts-view__error`,children:[`Error: `,_]}),(0,u.jsx)(`div`,{className:`scripts-view__detail`,children:s.length===0?(0,u.jsx)(`p`,{className:`scripts-view__empty`,children:D?`No shared scripts yet. Scripts here belong to no single project — every project can run them — so this is the place for anything more than one job needs.`:`No scripts yet. Scripts are small automations that run when task phases start or finish — create one to get going.`}):A?(0,u.jsx)(m,{entry:A,shared:D,inputValues:y,onInputChange:b,running:x,onRun:j,onEdit:()=>M(A.name),lastRun:C}):null}),(0,u.jsx)(c,{open:T,projectId:O,...D?{scope:`user`}:{},onClose:()=>E(!1),onCreated:e=>{E(!1),k(a),g(e),M(e)}})]})}function m({entry:e,shared:t,inputValues:n,onInputChange:r,running:i,onRun:c,onEdit:l,lastRun:d}){let f=e.meta;return(0,u.jsxs)(`div`,{className:`script-detail`,children:[(0,u.jsxs)(`header`,{children:[(0,u.jsx)(`h2`,{children:f.name}),(0,u.jsx)(`p`,{children:f.description}),t&&(0,u.jsx)(`p`,{className:`muted small`,children:`In the shared library — every project can run it.`}),(0,u.jsx)(o,{requires:f.requires})]}),f.inputs&&Object.keys(f.inputs).length>0&&(0,u.jsxs)(`fieldset`,{className:`script-detail__inputs`,children:[(0,u.jsx)(`legend`,{children:`Inputs`}),(0,u.jsx)(a,{inputs:f.inputs,values:n,onChange:r})]}),f.outputs&&Object.keys(f.outputs).length>0&&(0,u.jsxs)(`section`,{className:`script-detail__outputs`,children:[(0,u.jsx)(`h3`,{children:`Declared outputs`}),(0,u.jsx)(`ul`,{children:Object.entries(f.outputs).map(([e,t])=>(0,u.jsxs)(`li`,{children:[(0,u.jsx)(`code`,{children:e}),`: `,(0,u.jsx)(`em`,{children:t.type}),` — `,t.description]},e))})]}),(0,u.jsxs)(`div`,{className:`script-detail__actions`,children:[(0,u.jsx)(`button`,{type:`button`,disabled:i,onClick:c,children:i?`Running…`:`Run`}),(0,u.jsx)(`button`,{type:`button`,onClick:l,children:`Edit code`})]}),d&&(0,u.jsx)(s,{result:d,meta:f})]})}export{p as ScriptsView};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-BPraLwsh.js";import{a as i,i as a,o,r as s}from"./pending-drafts-B11MKQ9R.js";import{t as c}from"./NewScriptDialog-C5X-7PMt.js";var l=e(t(),1),u=n(),d=`shared-library`,f=`default`;function p({projectId:e}={}){let[t,n]=(0,l.useState)([]),[a,o]=(0,l.useState)(e??d),[s,p]=(0,l.useState)([]),[h,g]=(0,l.useState)(null),[_,v]=(0,l.useState)(null),[y,b]=(0,l.useState)({}),[x,S]=(0,l.useState)(!1),[C,w]=(0,l.useState)(null),[T,E]=(0,l.useState)(!1),D=a===d,O=D?e??f:a;(0,l.useEffect)(()=>{if(e!==void 0){o(e);return}r.listProjects().then(e=>n(e.projects)).catch(e=>v(e.message))},[e]);let k=(0,l.useCallback)(async e=>{try{let t=e===d?await r.listUserScripts():e?await r.listProjectScripts(e):{scripts:[]};p(t.scripts)}catch(e){v(e.message)}},[]);(0,l.useEffect)(()=>{k(a)},[a,k]),(0,l.useEffect)(()=>{g(e=>e&&s.some(t=>t.name===e)?e:s[0]?.name??null)},[s]);let A=(0,l.useMemo)(()=>s.find(e=>e.name===h)??null,[s,h]);(0,l.useEffect)(()=>{if(!A){b({}),w(null);return}b(i(A.meta)),w(null)},[A]);let j=(0,l.useCallback)(async()=>{if(A){S(!0),v(null);try{let e=await r.runProjectScript(O,{name:A.name,...D?{scope:`user`}:{},input:y});w(e)}catch(e){v(e.message)}finally{S(!1)}}},[A,O,D,y]),M=(0,l.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`gezel:open-tab`,{detail:{kind:`script`,projectId:O,name:e,...D?{scope:`user`}:{},activate:!0}}))},[O,D]);return(0,u.jsxs)(`div`,{className:`scripts-view`,"data-testid":`scripts-view`,children:[(0,u.jsxs)(`header`,{className:`scripts-view__header`,children:[(0,u.jsx)(`h1`,{children:`Scripts`}),(0,u.jsxs)(`div`,{className:`scripts-view__toolbar`,children:[e===void 0&&(0,u.jsxs)(`label`,{className:`scripts-view__field`,children:[(0,u.jsx)(`span`,{children:`Scripts from`}),(0,u.jsxs)(`select`,{value:a,onChange:e=>{o(e.target.value),g(null)},children:[(0,u.jsx)(`option`,{value:d,children:`Shared library`}),t.map(e=>(0,u.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,u.jsxs)(`label`,{className:`scripts-view__field`,children:[(0,u.jsx)(`span`,{children:`Script`}),(0,u.jsx)(`select`,{value:h??``,disabled:s.length===0,onChange:e=>g(e.target.value||null),children:s.map(e=>(0,u.jsx)(`option`,{value:e.name,children:e.meta.name},e.name))})]}),(0,u.jsx)(`button`,{type:`button`,className:`primary scripts-view__new`,onClick:()=>E(!0),children:`New script`})]})]}),_&&(0,u.jsxs)(`p`,{className:`scripts-view__error`,children:[`Error: `,_]}),(0,u.jsx)(`div`,{className:`scripts-view__detail`,children:s.length===0?(0,u.jsx)(`p`,{className:`scripts-view__empty`,children:D?`No shared scripts yet. Scripts here belong to no single project — every project can run them — so this is the place for anything more than one job needs.`:`No scripts yet. Scripts are small automations that run when task phases start or finish — create one to get going.`}):A?(0,u.jsx)(m,{entry:A,shared:D,inputValues:y,onInputChange:b,running:x,onRun:j,onEdit:()=>M(A.name),lastRun:C}):null}),(0,u.jsx)(c,{open:T,projectId:O,...D?{scope:`user`}:{},onClose:()=>E(!1),onCreated:e=>{E(!1),k(a),g(e),M(e)}})]})}function m({entry:e,shared:t,inputValues:n,onInputChange:r,running:i,onRun:c,onEdit:l,lastRun:d}){let f=e.meta;return(0,u.jsxs)(`div`,{className:`script-detail`,children:[(0,u.jsxs)(`header`,{children:[(0,u.jsx)(`h2`,{children:f.name}),(0,u.jsx)(`p`,{children:f.description}),t&&(0,u.jsx)(`p`,{className:`muted small`,children:`In the shared library — every project can run it.`}),(0,u.jsx)(o,{requires:f.requires})]}),f.inputs&&Object.keys(f.inputs).length>0&&(0,u.jsxs)(`fieldset`,{className:`script-detail__inputs`,children:[(0,u.jsx)(`legend`,{children:`Inputs`}),(0,u.jsx)(a,{inputs:f.inputs,values:n,onChange:r})]}),f.outputs&&Object.keys(f.outputs).length>0&&(0,u.jsxs)(`section`,{className:`script-detail__outputs`,children:[(0,u.jsx)(`h3`,{children:`Declared outputs`}),(0,u.jsx)(`ul`,{children:Object.entries(f.outputs).map(([e,t])=>(0,u.jsxs)(`li`,{children:[(0,u.jsx)(`code`,{children:e}),`: `,(0,u.jsx)(`em`,{children:t.type}),` — `,t.description]},e))})]}),(0,u.jsxs)(`div`,{className:`script-detail__actions`,children:[(0,u.jsx)(`button`,{type:`button`,disabled:i,onClick:c,children:i?`Running…`:`Run`}),(0,u.jsx)(`button`,{type:`button`,onClick:l,children:`Edit code`})]}),d&&(0,u.jsx)(s,{result:d,meta:f})]})}export{p as ScriptsView};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{an as r,in as i,k as a}from"./dist-BPx-FyRH.js";import{t as o}from"./api-BX5xXiFs.js";import{t as s}from"./security-levels-QFeYFDP-.js";var c=e(t(),1),l=n(),u=[{key:`allowFileEdits`,label:`Edit files`,help:`Gate the file-adjacent model powers: git tools and shared-document writes from scripts. Gezel-managed workspace writes are decided per project — internal workspaces start writable, while folders you opened require explicit consent. Provider-native CLI access follows that provider's project posture.`},{key:`allowExternalChat`,label:`External chat providers`,help:`Expose cloud models (Claude, Copilot, ChatGPT). Off = local models only. You can still download new local models from Hugging Face.`},{key:`allowExternalServices`,label:`External services`,help:`Let gezellen reach the open web and let project previews load external resources. Off blocks those paths; cloud chat has its own switch, and manual GitHub pulls and model downloads are unaffected.`},{key:`allowScriptExecution`,label:`Execute scripts`,help:`Let gezellen run scripts they write and run craftbook script steps. Off still lets the app itself run npm / Node CLIs / MCP servers.`},{key:`allowAppNetwork`,label:`App network`,help:`Allow desktop-owned network traffic, including update checks and external resources in project previews. Off blocks background traffic and automatic renderer egress.`}];function d({config:e,onConfigChanged:t}){let[n,d]=(0,c.useState)(``),f=i({securityPolicy:e?.securityPolicy}).level,p=(0,c.useMemo)(()=>{let t=i({securityPolicy:e?.securityPolicy});return{allowFileEdits:t.allowFileEdits,allowExternalChat:t.allowExternalChat,allowExternalServices:t.allowExternalServices,allowScriptExecution:t.allowScriptExecution,allowAppNetwork:t.allowAppNetwork}},[e?.securityPolicy]),m=(0,c.useCallback)(async e=>{d(`saving…`);try{let n=await o.updateConfig({securityPolicy:e});t(n),window.dispatchEvent(new CustomEvent(`gezel:config-updated`,{detail:n})),d(`saved — open chats restart on their next message.`)}catch(e){d(`save failed: ${e.message}`)}},[t]),h=(0,c.useCallback)(e=>void m(r(e)),[m]),g=(0,c.useCallback)((e,t)=>{let n={...p,[e]:t};m({level:a(n),...n})},[p,m]);return(0,l.jsxs)(`section`,{className:`engagement-mode-panel engagement-mode-${f}`,children:[(0,l.jsx)(`h3`,{children:`Security & Compliance`}),(0,l.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:`One control over what gezellen are allowed to do — edits, cloud providers, the open web, and script execution. Slide toward lockdown to make Gezel safe to try; loosen it as you build trust. Locked-down work still flows into the artifacts sandbox, so reviews, prototypes, and documents keep working.`}),(0,l.jsx)(`p`,{className:`muted small`,style:{marginTop:`-0.35rem`},children:`Changing the posture restarts open chat sessions so gezellen pick up the new rules on their next message. A gezel that is answering right now finishes that answer first.`}),(0,l.jsxs)(`div`,{className:`engagement-mode-switch gz-tray`,role:`radiogroup`,"aria-label":`Security posture`,children:[s.map(e=>(0,l.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":f===e.id,className:`gz-key${f===e.id?` gz-key-active`:``}`,onClick:()=>h(e.id),children:e.label},e.id)),f===`custom`&&(0,l.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":!0,className:`gz-key gz-key-active gz-key-state`,disabled:!0,children:`Custom`})]}),(0,l.jsx)(`p`,{className:`engagement-mode-description`,"aria-live":`polite`,children:f===`custom`?`Custom posture — individual capabilities below differ from the presets.`:s.find(e=>e.id===f)?.description??``}),(0,l.jsxs)(`div`,{className:`workshop-tempo`,style:{marginTop:`1rem`},children:[(0,l.jsx)(`h4`,{className:`workshop-tempo-heading`,children:`Advanced — individual capabilities`}),(0,l.jsx)(`p`,{className:`muted small`,style:{margin:`0 0 0.5rem`},children:`Changing any switch off-preset sets the level to “Custom”.`}),u.map(e=>(0,l.jsxs)(`label`,{className:`debug-toggle`,style:{display:`flex`,alignItems:`flex-start`,gap:`0.5rem`,marginTop:`0.6rem`},children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:p[e.key],onChange:t=>g(e.key,t.target.checked)}),(0,l.jsxs)(`span`,{children:[(0,l.jsx)(`strong`,{children:e.label}),(0,l.jsx)(`br`,{}),(0,l.jsx)(`span`,{className:`muted small`,children:e.help})]})]},e.key))]}),n&&(0,l.jsx)(`p`,{className:`muted`,style:{marginTop:`0.75rem`},children:n})]})}export{d as SecurityComplianceSettings};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{j as r,ln as i,sn as a}from"./dist-BqGwkOe5.js";import{t as o}from"./api-BPraLwsh.js";import{t as s}from"./security-levels-QFeYFDP-.js";var c=e(t(),1),l=n(),u=[{key:`allowFileEdits`,label:`Edit files`,help:`Gate the file-adjacent model powers: git tools and shared-document writes from scripts. Gezel-managed workspace writes are decided per project — internal workspaces start writable, while folders you opened require explicit consent. Provider-native CLI access follows that provider's project posture.`},{key:`allowExternalChat`,label:`External chat providers`,help:`Expose cloud models (Claude, Copilot, ChatGPT). Off = local models only. You can still download new local models from Hugging Face.`},{key:`allowExternalServices`,label:`External services`,help:`Let gezellen reach the open web and let project previews load external resources. Off blocks those paths; cloud chat has its own switch, and manual GitHub pulls and model downloads are unaffected.`},{key:`allowScriptExecution`,label:`Execute scripts`,help:`Let gezellen run scripts they write and run craftbook script steps. Off still lets the app itself run npm / Node CLIs / MCP servers.`},{key:`allowAppNetwork`,label:`App network`,help:`Allow desktop-owned network traffic, including update checks and external resources in project previews. Off blocks background traffic and automatic renderer egress.`}];function d({config:e,onConfigChanged:t}){let[n,d]=(0,c.useState)(``),f=a({securityPolicy:e?.securityPolicy}).level,p=(0,c.useMemo)(()=>{let t=a({securityPolicy:e?.securityPolicy});return{allowFileEdits:t.allowFileEdits,allowExternalChat:t.allowExternalChat,allowExternalServices:t.allowExternalServices,allowScriptExecution:t.allowScriptExecution,allowAppNetwork:t.allowAppNetwork}},[e?.securityPolicy]),m=(0,c.useCallback)(async e=>{d(`saving…`);try{let n=await o.updateConfig({securityPolicy:e});t(n),window.dispatchEvent(new CustomEvent(`gezel:config-updated`,{detail:n})),d(`saved — open chats restart on their next message.`)}catch(e){d(`save failed: ${e.message}`)}},[t]),h=(0,c.useCallback)(e=>void m(i(e)),[m]),g=(0,c.useCallback)((e,t)=>{let n={...p,[e]:t};m({level:r(n),...n})},[p,m]);return(0,l.jsxs)(`section`,{className:`engagement-mode-panel engagement-mode-${f}`,children:[(0,l.jsx)(`h3`,{children:`Security & Compliance`}),(0,l.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:`One control over what gezellen are allowed to do — edits, cloud providers, the open web, and script execution. Slide toward lockdown to make Gezel safe to try; loosen it as you build trust. Locked-down work still flows into the artifacts sandbox, so reviews, prototypes, and documents keep working.`}),(0,l.jsx)(`p`,{className:`muted small`,style:{marginTop:`-0.35rem`},children:`Changing the posture restarts open chat sessions so gezellen pick up the new rules on their next message. A gezel that is answering right now finishes that answer first.`}),(0,l.jsxs)(`div`,{className:`engagement-mode-switch gz-tray gz-tray--described`,role:`radiogroup`,"aria-label":`Security posture`,children:[s.map(e=>(0,l.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":f===e.id,className:`gz-key${f===e.id?` gz-key-active`:``}`,onClick:()=>h(e.id),children:e.label},e.id)),f===`custom`&&(0,l.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":!0,className:`gz-key gz-key-active gz-key-state`,disabled:!0,children:`Custom`})]}),(0,l.jsx)(`p`,{className:`engagement-mode-description gz-tray-description`,"aria-live":`polite`,children:f===`custom`?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`strong`,{children:`Custom`}),` — individual capabilities below differ from the presets.`]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`strong`,{children:s.find(e=>e.id===f)?.label}),` —`,` `,s.find(e=>e.id===f)?.description??``]})}),(0,l.jsxs)(`div`,{className:`workshop-tempo`,style:{marginTop:`1rem`},children:[(0,l.jsx)(`h4`,{className:`workshop-tempo-heading`,children:`Advanced — individual capabilities`}),(0,l.jsx)(`p`,{className:`muted small`,style:{margin:`0 0 0.5rem`},children:`Changing any switch off-preset sets the level to “Custom”.`}),u.map(e=>(0,l.jsxs)(`label`,{className:`debug-toggle`,style:{display:`flex`,alignItems:`flex-start`,gap:`0.5rem`,marginTop:`0.6rem`},children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:p[e.key],onChange:t=>g(e.key,t.target.checked)}),(0,l.jsxs)(`span`,{children:[(0,l.jsx)(`strong`,{children:e.label}),(0,l.jsx)(`br`,{}),(0,l.jsx)(`span`,{className:`muted small`,children:e.help})]})]},e.key))]}),n&&(0,l.jsx)(`p`,{className:`muted`,style:{marginTop:`0.75rem`},children:n})]})}export{d as SecurityComplianceSettings};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{Ft as r,V as i,z as a}from"./dist-BqGwkOe5.js";import{t as o}from"./dist-BaHut5iX.js";import{t as s}from"./api-BPraLwsh.js";import{_ as c,c as l,d as u,f as d,g as f,l as p,m,p as h,s as g,u as _,v}from"./primitives-CWrGZpPI.js";import{t as y}from"./model-context-DBqdK0PS.js";import{t as b}from"./poppetje-DLB8uevw.js";import{n as x,t as S}from"./relative-time-B2kBaekd.js";import{C,Lt as w,Mt as T,X as E,zt as ee}from"./index-C0DYtvfg.js";import{a as te,o as ne}from"./ChatTimelineView-CQ4Sf4Ip.js";var D=e(t(),1),O=n(),k=/@\[([^\]]+)\]\(gezel\\?:[^)\s]+\)/g;function A(e){return e.replace(k,(e,t)=>`@${t}`)}function j(e){return e===`New session`?`New thread`:e}function re(e){return!e||e===`New session`}function M(e,t,n){return e.completedAt?`done`:!n&&e.id===t?`active`:`pending`}var ie={done:`Signed off`,active:`Active`,pending:`Waiting its turn`};function N({steps:e,activeStepId:t,selectedStepId:n,onSelect:r,onAddStep:a,busy:o=!1,gezels:s=[],taskAssignee:c,taskStatus:l,onAssign:u}){let d=w(),f=C(),p=l===`complete`||l===`canceled`,m=e=>{let t=(e.suggestedGezelId?{kind:`gezel`,gezelId:e.suggestedGezelId}:null)??c??null;if(t?.kind===`user`)return`you`;if(t?.kind===`gezel`){let e=s.find(e=>e.id===t.gezelId);return e?i(e,f):void 0}};return(0,O.jsx)(E,{variant:`bench`,steps:e,selectedStepId:n,onSelect:r,statusOf:e=>M(e,t,p),stepOf:e=>{let n=M(e,t,p),r=e.assignee??(e.suggestedGezelId?{kind:`gezel`,gezelId:e.suggestedGezelId}:null)??c??null,a,l,h;r?.kind===`user`?a=`You`:r?.kind===`gezel`&&(h=s.find(e=>e.id===r.gezelId),a=h?i(h,f):void 0,l=f?void 0:h?.role);let g=n===`active`?l?`${l} · with the task`:`with the task`:l,_=n===`active`&&d&&h?.poppetje?(0,O.jsx)(b,{poppetje:h.poppetje,variant:`full`,size:26,svgId:`track-${e.id}`,...a?{title:a}:{}}):void 0,v=p&&n===`pending`?void 0:ie[n],y=e.assignee,x=y?.kind===`user`?`__user`:y?.kind===`gezel`?y.gezelId:`__inherit`,S=m(e),C=u?(0,O.jsxs)(`select`,{className:`bench-step-select`,value:x,disabled:o,"aria-label":`Assignee for ${e.name}`,title:`Assignee for ${e.name}`,onChange:t=>{let n=t.target.value;n===`__inherit`?u(e.id,null):n===`__user`?u(e.id,{kind:`user`}):u(e.id,{kind:`gezel`,gezelId:n})},children:[(0,O.jsx)(`option`,{value:`__inherit`,children:S?`inherit · ${S}`:`inherit from task`}),(0,O.jsx)(`option`,{value:`__user`,children:`you`}),s.map(e=>(0,O.jsx)(`option`,{value:e.id,children:!f&&e.role?`${e.name} · ${e.role}`:i(e,f)},e.id))]}):void 0;return{..._?{figure:_}:{},...C?{assigneeControl:C}:{},...a?{assigneeName:a}:{},...g?{assigneeRole:g}:{},...v?{statusWord:v}:{}}},onAddStep:a,busy:o,ariaLabel:`Task steps`,addLabel:`add a step`,...p?{terminal:{word:l===`complete`?`Complete`:`Canceled`,tone:l===`complete`?`complete`:`canceled`}}:{}})}var P=100;function F(e){if(e instanceof o&&e.details&&typeof e.details==`object`){let t=e.details.error;if(typeof t==`string`)return t}return e instanceof Error?e.message:String(e)}function ae({status:e,sessionId:t}){let[n,r]=(0,D.useState)(!1),[i,a]=(0,D.useState)(!1),[o,l]=(0,D.useState)(null);if(!e||!(e.numCtx>0))return null;let{numCtx:u,estimatedTokens:d,transcriptTokens:p,autoCompactRatio:m,compactionCount:h,model:g}=e,_=d??p,b=d!==void 0,x=_===void 0?null:Math.round(100*_/u),S=x===null?0:Math.max(0,Math.min(100,x)),C=m===void 0?void 0:Math.round(m*100),w=e.compactionFailed?`critical`:x!==null&&x>=Math.min(C??80,80)?`warn`:``,T=`${y(u)}-token context`,E=x===null?y(u):`${S}%`,ee=x===null?`${T} in this thread — nothing measured yet`:`This thread fills ${b?`about`:`at least`} ${S}% of its ${T}`,te=async()=>{if(t){a(!0),l(null);try{await s.compactChatSession(t),r(!1)}catch(e){l(F(e))}finally{a(!1)}}};return(0,O.jsxs)(c,{open:n,onOpenChange:e=>{r(e),e||l(null)},children:[(0,O.jsx)(v,{asChild:!0,children:(0,O.jsxs)(`button`,{type:`button`,className:`context-meter${w?` context-meter-${w}`:``}`,"aria-label":`Thread context: ${ee}`,title:ee,children:[(0,O.jsx)(`span`,{className:`context-meter-ring-wrap`,children:(0,O.jsxs)(`svg`,{className:`context-meter-ring`,viewBox:`0 0 36 36`,"aria-hidden":`true`,children:[(0,O.jsx)(`circle`,{className:`context-meter-ring-bg`,cx:`18`,cy:`18`,r:`15.5`,fill:`none`,strokeWidth:`5`}),(0,O.jsx)(`circle`,{className:`context-meter-ring-fill`,cx:`18`,cy:`18`,r:`15.5`,fill:`none`,strokeWidth:`5`,pathLength:P,strokeDasharray:`${S} ${P-S}`,strokeDashoffset:`25`,strokeLinecap:`round`})]})}),(0,O.jsx)(`span`,{className:`context-meter-label`,children:E})]})}),(0,O.jsxs)(f,{className:`context-meter-popover`,side:`bottom`,align:`end`,children:[(0,O.jsx)(`div`,{className:`context-meter-popover-header`,children:`This thread’s context`}),(0,O.jsxs)(`dl`,{className:`context-meter-stats`,children:[g&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`dt`,{children:`Model`}),(0,O.jsx)(`dd`,{children:g})]}),(0,O.jsx)(`dt`,{children:`Window`}),(0,O.jsxs)(`dd`,{children:[y(u),` tokens`]}),(0,O.jsx)(`dt`,{children:`In use`}),(0,O.jsx)(`dd`,{children:_===void 0?`Not measured yet`:`${b?`~`:`at least `}${_.toLocaleString()} tokens (${S}%)`}),(0,O.jsx)(`dt`,{children:`Auto-compaction`}),(0,O.jsx)(`dd`,{children:C===void 0?`On`:`At ${C}% full`}),h!==void 0&&h>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`dt`,{children:`Compactions`}),(0,O.jsxs)(`dd`,{children:[h,` so far`]})]})]}),e.compactionFailed?(0,O.jsx)(`p`,{className:`context-meter-note context-meter-note-warn`,children:`Automatic compaction could not reduce this thread. The runtime will still apply its deterministic fit safeguards, but a fresh thread will think more clearly.`}):(0,O.jsxs)(`p`,{className:`context-meter-note`,children:[b?`Counts this thread only, measured before the last turn ran.`:`Counted from the messages on disk. The system prompt and tool list add a few thousand tokens on top; the exact figure lands after the next turn.`,` `,`Older messages are summarized automatically when the thread fills up.`]}),t&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,className:`context-meter-action`,onClick:()=>void te(),disabled:i,children:i?`Compacting…`:`Compact now`}),o&&(0,O.jsx)(`p`,{className:`context-meter-note context-meter-note-warn`,children:o})]})]})]})}var oe=150,se=1e3,I=`draft:`,ce=`__NEW__`,le=`New thread`,ue=`__EMPTY__`,L=`Untitled draft`;function R(){return(0,O.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,focusable:`false`,children:[(0,O.jsx)(`circle`,{cx:`7`,cy:`7`,r:`5.9`,stroke:`currentColor`,strokeWidth:`1.2`}),(0,O.jsx)(`path`,{d:`M7 4.4v5.2M4.4 7h5.2`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`})]})}var de=(0,O.jsxs)(`span`,{className:`session-row session-row-action`,children:[(0,O.jsx)(R,{}),(0,O.jsx)(`span`,{className:`session-row-title`,children:le})]}),fe=5,pe=`sent:`;function z({gezelId:e,projectId:t,sessionId:n,gezelName:i,onSessionIdChange:o,onActiveSessionChange:c,onFreshThread:f,refreshKey:v,taskRef:y,stepId:b,autoPickNewest:S=!0,engineLabel:C,activeDraftId:w,onDraftSelect:T,draftScope:E,craftbookRef:k}){let[A,j]=(0,D.useState)([]),[M,ie]=(0,D.useState)([]),[N,P]=(0,D.useState)(new Map),[F,R]=(0,D.useState)(!1),[z,B]=(0,D.useState)([]),[V,ye]=(0,D.useState)(new Map),U=(0,D.useRef)(null),be=(0,D.useRef)(w);be.current=w;let xe=(0,D.useRef)(async()=>{}),Se=(0,D.useRef)(null),W=`${e}:${t}:${y??``}`,[G,Ce]=(0,D.useState)(null),K=(0,D.useCallback)(async()=>{let n=`${e}:${t}:${y??``}`;try{let i;if(y){let t=r(y);if(!t)return[];i=(await s.listTaskSessions(t.projectId,t.num)).sessions.filter(t=>t.gezelId===e)}else i=(await s.listChatSessions({gezelId:e,projectId:t})).sessions.filter(e=>!e.taskRef);let a=i.filter(e=>!e.archived);return j(a),Ce(n),a}catch(n){return console.error(`[SessionSwitcher] list sessions failed`,{gezelId:e,projectId:t,taskRef:y,err:n}),[]}},[e,t,y]);(0,D.useEffect)(()=>{U.current=null,j([]),Ce(null),K()},[K,v]);let q=(0,D.useCallback)(e=>(e.taskRef??void 0)===(y??void 0)&&(e.craftbookRef??void 0)===(k??void 0)&&(e.scope??void 0)===(E??void 0),[y,k,E]),J=(0,D.useCallback)(async()=>{try{let{drafts:n}=await s.listPromptDrafts(t,{gezelId:e,status:`draft`}),r=n.filter(q);ie(r.filter(e=>e.sessionId===null));let i=new Map;for(let e of r){if(!e.sessionId)continue;let t=i.get(e.sessionId);t?t.push(e):i.set(e.sessionId,[e])}P(i)}catch{}},[t,e,q]);xe.current=J,(0,D.useEffect)(()=>{J()},[J]),(0,D.useEffect)(()=>{let e=W;if(G!==e)return;if(n&&A.some(e=>e.id===n)){U.current=e;return}if(U.current===e)return;if(w){U.current=e;return}let t=M[0];if(!(A.length===0&&!t)){if(U.current=e,S&&A.length>0){o(A[0].id);return}t&&(o(void 0),T?.(t.id))}},[A,G,n,W,S,o,w,M,T]),(0,D.useEffect)(()=>{if(G!==W)return;let e=A.find(e=>e.id===n);n&&!e||c?.(e??null)},[A,G,n,W,c]),(0,D.useEffect)(()=>{if(G!==W||!n||A.some(e=>e.id===n))return;let e=`${W}:${n}`;Se.current!==e&&(Se.current=e,K())},[A,G,n,W,K]),(0,D.useEffect)(()=>{let n=new AbortController,r=null,i=!1,a=null,o=()=>{r!==null&&window.clearTimeout(r),r=window.setTimeout(()=>{r=null,K()},oe)},c=()=>{a!==null&&window.clearTimeout(a),a=window.setTimeout(()=>{a=null,xe.current()},se)};return(async()=>{let r=250;for(;!i;){try{for await(let a of ee({url:s.projectEventsUrl(t),headers:s.authHeader(),signal:n.signal,fetch:s.getFetch()})){if(i)return;if(a.event.type===`prompt_draft_changed`){let n=a.event;n.projectId===t&&n.gezelId===e&&(n.draftId===be.current&&!n.deleted&&n.status===`draft`||c());continue}if(a.projectId!==t||a.gezelId!==e)continue;let{event:n}=a;if((n.type===`user_message`||n.type===`done`||n.type===`context_compacted`)&&o(),a.sessionId&&(n.type===`context_window`||n.type===`context_warning`||n.type===`context_compacted`)){let e=a.sessionId;ye(t=>{let r=new Map(t),i=r.get(e);if(n.type===`context_window`)r.set(e,{...i,numCtx:n.numCtx,model:n.model,autoCompactRatio:n.autoCompactRatio,...n.estimatedTokens===void 0?{}:{estimatedTokens:n.estimatedTokens}});else if(n.type===`context_warning`)r.set(e,{...i,numCtx:n.numCtx,model:n.model,estimatedTokens:n.estimatedTokens,compactionFailed:!0});else{let t=n.numCtx??i?.numCtx;if(t!==void 0){let{estimatedTokens:a,...o}=i??{};r.set(e,{...o,numCtx:t,model:n.model,...n.autoCompactRatio===void 0?{}:{autoCompactRatio:n.autoCompactRatio},...n.compactionCount===void 0?{}:{compactionCount:n.compactionCount},compactionFailed:!1})}}return r})}r=250}}catch(e){if(i||e.name===`AbortError`)return;console.warn(`[SessionSwitcher] chat event stream error (reconnecting in ${r}ms):`,e)}if(i)return;await new Promise(e=>window.setTimeout(e,r)),r=Math.min(r*2,5e3)}})(),()=>{i=!0,n.abort(),r!==null&&window.clearTimeout(r),a!==null&&window.clearTimeout(a)}},[e,t,K]);let we=(0,D.useCallback)(async()=>{R(!0);try{let r=await s.createPromptDraft(t,{gezelId:e,sessionId:n??null,...y?{taskRef:y}:{},...k?{craftbookRef:k}:{},...E?{scope:E}:{}});n?P(e=>{let t=new Map(e);return t.set(n,[r,...e.get(n)??[]]),t}):(ie(e=>[r,...e.filter(e=>e.id!==r.id)]),o(void 0)),T?.(r.id)}finally{R(!1)}},[t,e,n,y,k,E,o,T]),Te=(0,D.useCallback)(async(e,r)=>{R(!0);try{await s.deletePromptDraft(t,e),e===w&&T?.(void 0),r&&(await s.archiveChatSession(r),r===n&&o(void 0),await K()),await J()}finally{R(!1)}},[t,w,n,T,o,K,J]),Ee=(0,D.useCallback)(async()=>{if(!n){B([]);return}try{let{drafts:r}=await s.listPromptDrafts(t,{gezelId:e,sessionId:n,status:`sent`});B(r.filter(q).slice(0,fe))}catch{B([])}},[t,e,n,q]),De=(0,D.useCallback)(async e=>{R(!0);try{let r=await s.duplicatePromptDraft(t,e,{sessionId:n??null});T?.(r.id),await J()}finally{R(!1)}},[t,n,T,J]),Oe=(0,D.useCallback)(async e=>{R(!0);try{await s.archiveChatSession(e);let t=await K();e===n&&(T?.(void 0),o(t[0]?.id)),await J()}finally{R(!1)}},[n,K,J,o,T]),ke=(0,D.useSyncExternalStore)(ne,()=>w?te(w):void 0),Ae=ke===void 0?``:a(ke),je=A.length>0,Me=M.length>0,Y=w&&!n&&!M.some(e=>e.id===w)?w:null,X=Me||Y!==null||A.some(e=>re(e.title)),Z=A.some(e=>!re(e.title)),Ne=e=>e.id===w&&Ae?{...e,title:Ae}:e,Pe=A.map(e=>{let t=(N.get(e.id)??[]).map(Ne),n=re(e.title),r=n?t[0]:void 0;return{s:e,drafts:t,namer:r,unsent:n,at:me(e,r)}}),Fe=(e,t)=>e.at<t.at?1:e.at>t.at?-1:0,Ie=[...M.map(e=>{let t=Ne(e);return{kind:`draft`,draft:t,at:t.updatedAt}}),...Pe.filter(e=>e.unsent).map(e=>({kind:`thread`,...e}))].sort(Fe),Le=Pe.filter(e=>!e.unsent).sort(Fe),Re=(e,t)=>(0,O.jsx)(`button`,{type:`button`,className:`session-row-archive`,"aria-label":`Archive thread ${H(e,t)}`,title:`Hide this thread from the list. It stays on disk.`,disabled:F,onPointerDown:e=>e.stopPropagation(),onPointerUp:e=>e.stopPropagation(),onClick:t=>{t.preventDefault(),t.stopPropagation(),Oe(e.id)},children:`Archive`}),ze=(e,t,n)=>(0,O.jsx)(`button`,{type:`button`,className:`session-row-delete`,"aria-label":`Delete draft ${t}`,title:`Throw this message away`,disabled:F,onPointerDown:e=>e.stopPropagation(),onPointerUp:e=>e.stopPropagation(),onClick:t=>{t.preventDefault(),t.stopPropagation(),Te(e,n)},children:`×`}),Be=(e,t)=>(0,O.jsx)(p,{value:`${I}${e.id}`,textValue:ve(e),trailing:ze(e.id,e.title||L),children:_e(e,t)},e.id),Ve=({s:e,drafts:t,namer:n,unsent:r})=>(0,O.jsxs)(D.Fragment,{children:[(0,O.jsx)(p,{value:e.id,textValue:ge(e,C,n,r),trailing:n?ze(n.id,n.title||L,t.length<=1?e.id:void 0):Re(e,n),children:he(e,C,n,r)}),t.filter(e=>e.id!==n?.id).map(e=>Be(e,{child:!0,mark:!r}))]},e.id),Q=Ae||(ke===void 0?le:L),He=w&&!n?`${I}${w}`:n&&je?n:``,Ue=i?`No threads with ${i} yet — a message starts one`:`No threads yet`,We=X?`No threads yet`:Ue,$=n?A.find(e=>e.id===n):void 0,Ge=$?.contextWindow?{numCtx:$.contextWindow,model:$.model,...$.contextEstimatedTokens===void 0?{}:{estimatedTokens:$.contextEstimatedTokens},...$.contextAutoCompactRatio===void 0?{}:{autoCompactRatio:$.contextAutoCompactRatio},...$.compactionCount===void 0?{}:{compactionCount:$.compactionCount},...$.transcriptTokens===void 0?{}:{transcriptTokens:$.transcriptTokens}}:void 0,Ke=n?V.get(n):void 0,qe=Ke?{...Ge,...Ke}:Ge;return(0,O.jsxs)(`div`,{className:`gezel-chat-session-header`,children:[(0,O.jsxs)(u,{value:He,onOpenChange:e=>{e&&Ee()},onValueChange:e=>{if(!(!e||e===ue)){if(e.startsWith(pe)){De(e.slice(5));return}if(e===ce){T?.(void 0),o(void 0),f?.();return}if(e.startsWith(I)){let t=e.slice(6),r=[...N].find(([,e])=>e.some(e=>e.id===t))?.[0];r!==n&&o(r),T?.(t);return}T?.(void 0),o(e)}},disabled:F,children:[(0,O.jsx)(h,{className:`gezel-chat-session-select`,children:(0,O.jsx)(m,{placeholder:je?de:Ue})}),(0,O.jsxs)(g,{className:`gezel-chat-session-menu`,children:[(0,O.jsx)(p,{value:ce,textValue:le,children:de}),(X||Z)&&(0,O.jsx)(d,{}),X&&(0,O.jsxs)(l,{children:[(0,O.jsx)(_,{children:`Not sent yet`}),Y&&(0,O.jsx)(p,{value:`${I}${Y}`,textValue:Q,trailing:ze(Y,Q),children:(0,O.jsx)(`span`,{className:`session-row`,children:(0,O.jsx)(`span`,{className:`session-row-title`,children:Q})})}),Ie.map(e=>e.kind===`draft`?Be(e.draft,{mark:!1}):Ve(e))]}),X&&Z&&(0,O.jsx)(d,{}),Z?(0,O.jsxs)(l,{children:[(0,O.jsx)(_,{children:`Threads`}),Le.map(Ve)]}):X?(0,O.jsx)(p,{value:ue,disabled:!0,children:We}):null,z.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(d,{}),(0,O.jsxs)(l,{children:[(0,O.jsx)(_,{children:`Recently sent`}),z.map(e=>(0,O.jsx)(p,{value:`${pe}${e.id}`,textValue:`${e.title||L} · use again`,children:(0,O.jsxs)(`span`,{className:`session-row session-row-child`,children:[(0,O.jsx)(`span`,{className:`session-row-title`,children:e.title||L}),(0,O.jsx)(`span`,{className:`session-row-meta`,children:` · use again · sent ${x(e.sentAt??e.updatedAt)}`})]})},e.id))]})]})]})]}),(0,O.jsx)(ae,{status:qe,sessionId:n}),n&&(0,O.jsx)(`button`,{type:`button`,className:`gezel-chat-session-btn`,onClick:()=>void we(),disabled:F,title:`Start another message in this thread and keep the one you have`,children:`+ Draft`})]})}function B(e){let t=[],n=0,r=0;for(let i of e.matchAll(k)){let a=i.index??0;a>n&&t.push(e.slice(n,a)),t.push((0,O.jsxs)(`span`,{className:`session-mention`,children:[`@`,i[1]]},`m-${r}`)),n=a+i[0].length,r++}return t.length===0?e:(n<e.length&&t.push(e.slice(n)),t)}function V(e,t){return e.source?.kind===`external`?`From ${e.source.appName} · read-only`:t||`${T(e.providerName,window.__GEZEL__?.platform)}${e.model?` (${e.model})`:``}`}function H(e,t){return t?t.title||L:j(e.title)}function me(e,t){return t&&t.updatedAt>e.lastActivityAt?t.updatedAt:e.lastActivityAt}function he(e,t,n,r){let i=me(e,n),a=r?` · ${x(i)}`:` · ${x(i)} · ${V(e,t)}`;return(0,O.jsxs)(`span`,{className:`session-row`,children:[(0,O.jsx)(`span`,{className:`session-row-title`,children:B(H(e,n))}),(0,O.jsx)(`span`,{className:`session-row-meta`,title:S(i),children:a})]})}function ge(e,t,n,r){let i=`${A(H(e,n))} · ${x(me(e,n))}`;return r?i:`${i} · ${V(e,t)}`}function _e(e,t){return(0,O.jsxs)(`span`,{className:t?.child?`session-row session-row-child`:`session-row`,children:[(0,O.jsx)(`span`,{className:`session-row-title`,children:e.title||L}),t?.mark!==!1&&(0,O.jsx)(`span`,{className:`session-row-draft-mark`,children:`draft`}),(0,O.jsx)(`span`,{className:`session-row-meta`,title:S(e.updatedAt),children:` · ${x(e.updatedAt)}`})]})}function ve(e){return`${e.title||L} · draft · ${x(e.updatedAt)}`}export{A as a,j as i,N as n,M as r,z as t};