@bendyline/gezel-service 1.1.1 → 1.1.2

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 (185) hide show
  1. package/dist/NOTICE.md +3 -3
  2. package/dist/bin/gezeld.js +8471 -5311
  3. package/dist/handboek-content/technical/building-connected-apps-with-gezel-app-sdk.md +78 -0
  4. package/dist/handboek-content/whats-new/{1.26250.md → 1.26251.md} +5 -5
  5. package/dist/index-store/static-index-worker.js +160 -51
  6. package/dist/index.d.ts +416 -71
  7. package/dist/index.js +8465 -5305
  8. package/dist/memory/embed-worker.js +132 -4
  9. package/dist/memory/image-embed-worker.js +14 -5
  10. package/dist/providers/mlx/python/cache_persist.py +52 -8
  11. package/dist/providers/mlx/python/gezel_mlx_server.py +44 -1
  12. package/dist/providers/mlx/python/qwen4_ple.py +159 -0
  13. package/dist/providers/mlx/python/spec_decode.py +73 -31
  14. package/dist/providers/mlx/python/tool_call_stream.py +10 -2
  15. package/dist/providers/mlx/python/tool_grammar.py +16 -0
  16. package/dist/ui/assets/{AmbientDashboardCard-DcVHxEdC.js → AmbientDashboardCard-_xnAQGnk.js} +1 -1
  17. package/dist/ui/assets/{AudioEngineSettings-BFM2S1mm.js → AudioEngineSettings-CgXgbX0i.js} +1 -1
  18. package/dist/ui/assets/{BenchmarksView-84-YeULA.js → BenchmarksView-BlExZpYA.js} +1 -1
  19. package/dist/ui/assets/CatalogBrowser-DYXUZQ_t.js +1 -0
  20. package/dist/ui/assets/{ChannelsSettings-7NAVUk4k.js → ChannelsSettings-EH27HcqZ.js} +1 -1
  21. package/dist/ui/assets/ChatTimelineView-Dn1TNyVn.js +7 -0
  22. package/dist/ui/assets/{ConnectedAppsPanel-CIgF4Q3R.js → ConnectedAppsPanel-BROry-Y0.js} +1 -1
  23. package/dist/ui/assets/CraftbookEditor-B2RNJnFf.js +1 -0
  24. package/dist/ui/assets/{CraftbookScriptEditorView-Ck5tzj3Y.js → CraftbookScriptEditorView-B-vySmHP.js} +1 -1
  25. package/dist/ui/assets/{CraftbookTabContent-BWg7FhK_.js → CraftbookTabContent-BW_2KC89.js} +1 -1
  26. package/dist/ui/assets/{CraftbookToolsetSetup-EuFOiUzR.js → CraftbookToolsetSetup-J7rEa835.js} +1 -1
  27. package/dist/ui/assets/{CraftbooksView-BIzQ1VVn.js → CraftbooksView-BjBUWPGF.js} +1 -1
  28. package/dist/ui/assets/DiffpackReviewView-CD4qJmgT.js +1 -0
  29. package/dist/ui/assets/DocumentDetail-SYozruTJ.js +1 -0
  30. package/dist/ui/assets/DocumentsView-DE7eL49Z.js +1 -0
  31. package/dist/ui/assets/{Ds4Settings-9soZCSeO.js → Ds4Settings-DGzc7JcD.js} +1 -1
  32. package/dist/ui/assets/{EmbeddedChat-Cce7nxXT.js → EmbeddedChat-D92TaJQ8.js} +1 -1
  33. package/dist/ui/assets/{FaceRecognitionCard-BVZyOwB8.js → FaceRecognitionCard-CB1Dt9X4.js} +1 -1
  34. package/dist/ui/assets/FileMapView-kVBG22FU.js +1 -0
  35. package/dist/ui/assets/FoldersSettings-BWFQU5B4.js +1 -0
  36. package/dist/ui/assets/GezelDetail-Br4v42Nv.js +1 -0
  37. package/dist/ui/assets/{GezelJsonEditor-DXXt165-.js → GezelJsonEditor-B9XEiW5Y.js} +1 -1
  38. package/dist/ui/assets/GezellenView-DheEBAy4.js +1 -0
  39. package/dist/ui/assets/{GildeUpdatesCard-CtY8mUTA.js → GildeUpdatesCard-BeIYv09f.js} +1 -1
  40. package/dist/ui/assets/{GithubSignInChip-DT3l6E0Q.js → GithubSignInChip-eEGCe9ar.js} +1 -1
  41. package/dist/ui/assets/{HandboekMediaProvider-ByJ4NAzz.js → HandboekMediaProvider-D0zcbbpf.js} +1 -1
  42. package/dist/ui/assets/HandboekView-p0BZT1rH.js +1 -0
  43. package/dist/ui/assets/{HistoryView-CkinzFEC.js → HistoryView-CKWcWW-Y.js} +1 -1
  44. package/dist/ui/assets/{HomeView-DNBrQnwy.js → HomeView-b_TT5oV3.js} +1 -1
  45. package/dist/ui/assets/{ImageEngineSettings-BfM9HSd_.js → ImageEngineSettings-CJfk4OJ4.js} +1 -1
  46. package/dist/ui/assets/{ImageRecognitionSettings-CaSQu5Br.js → ImageRecognitionSettings-DzbvZk5S.js} +1 -1
  47. package/dist/ui/assets/{IncompleteDownloads-C36lTCMG.js → IncompleteDownloads-C8_XyP8O.js} +1 -1
  48. package/dist/ui/assets/{KnowledgeCatalogsCard-CK9bqdf6.js → KnowledgeCatalogsCard-CHopG_j-.js} +1 -1
  49. package/dist/ui/assets/KnowledgeView-CXNKZUJq.js +1 -0
  50. package/dist/ui/assets/{LlamaCppSettings-CdNMHBbp.js → LlamaCppSettings-ohcM7kes.js} +1 -1
  51. package/dist/ui/assets/{MarkdownField-Dugmfr_e.js → MarkdownField-BX0qsaFq.js} +1 -1
  52. package/dist/ui/assets/{MemoriesTree-CgFqUNEr.js → MemoriesTree-BPj5Rod8.js} +1 -1
  53. package/dist/ui/assets/{MicrophoneSettings-DzDe9y1q.js → MicrophoneSettings-CWjeYnfI.js} +1 -1
  54. package/dist/ui/assets/MlxSettings-Dq6dRpcl.js +1 -0
  55. package/dist/ui/assets/{ModelPicker-BVkJhNAH.js → ModelPicker-0Ue-eEKj.js} +1 -1
  56. package/dist/ui/assets/NewPathDialog-BhAZm9dp.js +1 -0
  57. package/dist/ui/assets/{NewScriptDialog-TEAd0KLl.js → NewScriptDialog-DuryIe50.js} +1 -1
  58. package/dist/ui/assets/NewTaskDialog-BX24flMY.js +2 -0
  59. package/dist/ui/assets/{OllamaSettings-CPy2vxyZ.js → OllamaSettings-Boj8Nd1G.js} +1 -1
  60. package/dist/ui/assets/ProjectChat-Dhw_M5bq.js +5 -0
  61. package/dist/ui/assets/ProjectConnectionsTab-BwpMQNrg.js +1 -0
  62. package/dist/ui/assets/{ProjectGitStatusBar-BgHZ2ijN.js → ProjectGitStatusBar-BORGYx5l.js} +1 -1
  63. package/dist/ui/assets/{ProjectGithubView-BV2uTNU0.js → ProjectGithubView-CTP1BOMv.js} +1 -1
  64. package/dist/ui/assets/{ProjectMailTab-DLtJdXSL.js → ProjectMailTab-qFmAeV3M.js} +1 -1
  65. package/dist/ui/assets/{ProjectOverviewView-ZMs9nL5N.js → ProjectOverviewView-Cq1FsoaT.js} +1 -1
  66. package/dist/ui/assets/{ProjectTimeline-CTPcn4Kc.js → ProjectTimeline-Cqae2Z92.js} +1 -1
  67. package/dist/ui/assets/ProjectsView-D0uJjUB-.js +7 -0
  68. package/dist/ui/assets/{RecommendedBadge-iUoisQBi.js → RecommendedBadge-CN1jEmSn.js} +1 -1
  69. package/dist/ui/assets/{RemoteServersPanel-CTVJ0IRh.js → RemoteServersPanel-CMakvCCM.js} +1 -1
  70. package/dist/ui/assets/{ScriptEditorTabs-CCDFZjdC.js → ScriptEditorTabs-st6dJePd.js} +2 -2
  71. package/dist/ui/assets/{ScriptEditorView-CergLqKj.js → ScriptEditorView-BkySh57_.js} +2 -2
  72. package/dist/ui/assets/{ScriptsView-v7ckdhDi.js → ScriptsView-7uPKwjDB.js} +1 -1
  73. package/dist/ui/assets/{SecurityComplianceSettings-Bd0-66Gs.js → SecurityComplianceSettings-Tsv_pXfy.js} +1 -1
  74. package/dist/ui/assets/SessionSwitcher-D0fSeeHO.js +1 -0
  75. package/dist/ui/assets/SettingsView-cli_z8ZW.js +3 -0
  76. package/dist/ui/assets/{SquisqIntegration-C5l_OPvD.js → SquisqIntegration-BTZ1kBlg.js} +1 -1
  77. package/dist/ui/assets/{StorageCleanupDialog-3kv9-2mT.js → StorageCleanupDialog-CDBjl8JQ.js} +1 -1
  78. package/dist/ui/assets/{StorageUsageCard-7sWTrZFa.js → StorageUsageCard-DXY1j0dZ.js} +1 -1
  79. package/dist/ui/assets/TaskTabContent-C0P681SL.js +1 -0
  80. package/dist/ui/assets/TasksView-Ddwz10ri.js +1 -0
  81. package/dist/ui/assets/{TerminalCodeEditor-ChmdzmCz.js → TerminalCodeEditor-BkNQ6QoQ.js} +2 -2
  82. package/dist/ui/assets/ToolsetsEditor-KVigemfL.js +8 -0
  83. package/dist/ui/assets/{TransformToolbarButton-gzIxUBH7.js → TransformToolbarButton-8wfJR1bO.js} +2 -2
  84. package/dist/ui/assets/{UnrecognizedModels-0hptopv6.js → UnrecognizedModels-BzdU1clO.js} +1 -1
  85. package/dist/ui/assets/{VideoEngineSettings-BdNzCEdR.js → VideoEngineSettings-f79ff57u.js} +1 -1
  86. package/dist/ui/assets/{WorkspaceIndexPane-DnsOO916.js → WorkspaceIndexPane-fu5V6o1W.js} +1 -1
  87. package/dist/ui/assets/{api-C0I7spBl.js → api-CmrgM5Rf.js} +1 -1
  88. package/dist/ui/assets/chat-thread-memory-8MCtb17Q.js +1 -0
  89. package/dist/ui/assets/{chunk-6ECMNUIP-BvCy0HUI.js → chunk-6ECMNUIP-D5AA6ozp.js} +1 -1
  90. package/dist/ui/assets/{chunk-A6N6IN3I-ofeM4l8g.js → chunk-A6N6IN3I-BpxihS5H.js} +1 -1
  91. package/dist/ui/assets/{chunk-ATWVNF7D-CYuW1Yc6.js → chunk-ATWVNF7D-CKIWh7bN.js} +1 -1
  92. package/dist/ui/assets/{chunk-UBFT2CDQ-FexGDigd.js → chunk-CW24CH7I-BD0FIooX.js} +1 -1
  93. package/dist/ui/assets/{chunk-DXYWKZ52-zxe8pjH4.js → chunk-DXYWKZ52-DMKPZnpo.js} +1 -1
  94. package/dist/ui/assets/chunk-IIQYS2YH-BtDJt4Xr.js +1 -0
  95. package/dist/ui/assets/{chunk-KGWT454C-v5-l6U5m.js → chunk-KGWT454C-DsQOBuLg.js} +1 -1
  96. package/dist/ui/assets/{chunk-Q77KNJIN-BLuPdsQF.js → chunk-Q77KNJIN-BdWizq9s.js} +1 -1
  97. package/dist/ui/assets/{chunk-USU6HTKB-B_p-YcDp.js → chunk-USU6HTKB-DyGZplh4.js} +1 -1
  98. package/dist/ui/assets/{chunk-UXEANVBI-Bt0kX-0Z.js → chunk-UXEANVBI-BUBXvqyE.js} +1 -1
  99. package/dist/ui/assets/{chunk-O7JILDEF-CqcO1qaI.js → chunk-X7BNDUNI-D14WIvlD.js} +2 -2
  100. package/dist/ui/assets/{chunk-AE3IUKMM-mZjzzO8Z.js → chunk-ZSU5DJLX-CrjQf-vs.js} +1 -1
  101. package/dist/ui/assets/{container-BI8hxN1N.js → container-iFj1r6Hk.js} +1 -1
  102. package/dist/ui/assets/csv-Di411Mv-.js +1 -0
  103. package/dist/ui/assets/data-Q05qqAp4.js +1 -0
  104. package/dist/ui/assets/{dist-APSIK7H3.js → dist-1FNFiksd.js} +3 -3
  105. package/dist/ui/assets/dist-BMZhqfv7.js +2 -0
  106. package/dist/ui/assets/dist-CE5CbmDb.js +225 -0
  107. package/dist/ui/assets/doc-BHcGsJZd.js +587 -0
  108. package/dist/ui/assets/{document-import-DPK4r8Am.js → document-import-B2Ya6sbf.js} +1 -1
  109. package/dist/ui/assets/{docx-DRLuCTaC.js → docx-B8Pwz5Ih.js} +1 -1
  110. package/dist/ui/assets/{epub-a0p2Xb1b.js → epub-BQ4g8Q9j.js} +1 -1
  111. package/dist/ui/assets/{export-options-BqYFyzWx.js → export-options-Dylv69b3.js} +1 -1
  112. package/dist/ui/assets/file-browser-BLOPfnS0.js +5 -0
  113. package/dist/ui/assets/{html-BbQNmJ5X.js → html-BnA7qFwq.js} +1 -1
  114. package/dist/ui/assets/icons-CyM7Cg4E.js +1 -0
  115. package/dist/ui/assets/index-DW6qHqhU.css +1 -0
  116. package/dist/ui/assets/index-DivKnJyx.js +36 -0
  117. package/dist/ui/assets/{mail-link-CWfsP5Aq.js → mail-link-NtlcX5OE.js} +1 -1
  118. package/dist/ui/assets/{markdown-ryKA_OmY.js → markdown-CLKH_zzl.js} +1 -1
  119. package/dist/ui/assets/markdown-baseline-0dqv9qbV.js +1 -0
  120. package/dist/ui/assets/materialize-G4WC5UG3-xq2dcwS8.js +1 -0
  121. package/dist/ui/assets/{monaco-base-C0VTMpv-.js → monaco-base-BSvdAweA.js} +1 -1
  122. package/dist/ui/assets/{monaco-setup-CX8q88c5.js → monaco-setup-CT7LZ0o_.js} +1 -1
  123. package/dist/ui/assets/{new-project-meta-ZmDPGYzC.js → new-project-meta-5Y9Blozr.js} +1 -1
  124. package/dist/ui/assets/outside-in-Msmhxf_U.js +3 -0
  125. package/dist/ui/assets/{pdf-BHrygJa5.js → pdf-C4BhW3zg.js} +1 -1
  126. package/dist/ui/assets/{pending-drafts-27ujtQxX.js → pending-drafts-BD227X9H.js} +1 -1
  127. package/dist/ui/assets/{poppetje-CfaAvFkE.js → poppetje-DvCJO36y.js} +3 -3
  128. package/dist/ui/assets/{pptx-nDW64jAN.js → pptx-B6uaM2s7.js} +3 -3
  129. package/dist/ui/assets/{run-export-86KzLZ7R.js → run-export-TscWwR6y.js} +2 -2
  130. package/dist/ui/assets/{standalone-source-7QdiNsDW.js → standalone-source-Cw9SF7Zk.js} +1 -1
  131. package/dist/ui/assets/storage-Cmhlwx70.js +1 -0
  132. package/dist/ui/assets/styles-BjDaWeMA.css +1 -0
  133. package/dist/ui/assets/styles-CqO-rmOt.js +554 -0
  134. package/dist/ui/assets/{terminal-monaco-setup-Bar-sYKd.js → terminal-monaco-setup-me523-j-.js} +1 -1
  135. package/dist/ui/assets/{transform-CmAXy0Ck.js → transform-DxJCwK68.js} +1 -1
  136. package/dist/ui/assets/{use-local-model-manager-D1yiurrC.js → use-local-model-manager-8wvk-I-y.js} +1 -1
  137. package/dist/ui/assets/{useCompactLayout-BDtPQcDh.js → useCompactLayout-cm4E9Vja.js} +0 -0
  138. package/dist/ui/assets/{useCopilotAvailability-BHOfHrfT.js → useCopilotAvailability-D9hglSH_.js} +1 -1
  139. package/dist/ui/assets/{useDiffpacks-B0kYhlWQ.js → useDiffpacks-1BN2XJWg.js} +1 -1
  140. package/dist/ui/assets/{useGitSync-DOt-ODiw.js → useGitSync-7m9YA7h5.js} +1 -1
  141. package/dist/ui/assets/{useShowWorkInProgressFeatures-BtpredG7.js → useShowWorkInProgressFeatures-D6QOaTUT.js} +1 -1
  142. package/dist/ui/assets/{useTotalRamBytes-B8NFM27w.js → useTotalRamBytes-Durk383U.js} +1 -1
  143. package/dist/ui/assets/{xlsx-B_pu1ZvY.js → xlsx-BbHA9bxA.js} +1 -1
  144. package/dist/ui/index.html +15 -15
  145. package/package.json +12 -11
  146. package/dist/ui/assets/CatalogBrowser-7_jHy5Q3.js +0 -1
  147. package/dist/ui/assets/ChatTimelineView-Cg_kLK_U.js +0 -7
  148. package/dist/ui/assets/CraftbookEditor-BKAIsnXv.js +0 -1
  149. package/dist/ui/assets/DiffpackReviewView-B2a3zgE-.js +0 -1
  150. package/dist/ui/assets/DocumentDetail-GCYhwQqV.js +0 -1
  151. package/dist/ui/assets/DocumentsView-Cm3RaQ5N.js +0 -1
  152. package/dist/ui/assets/FileMapView-BKJovLcL.js +0 -1
  153. package/dist/ui/assets/FoldersSettings-CuJd2JdE.js +0 -1
  154. package/dist/ui/assets/GezelDetail-D_KIPDhQ.js +0 -1
  155. package/dist/ui/assets/GezellenView-BOOW1QQU.js +0 -1
  156. package/dist/ui/assets/HandboekView-gRzJcIbJ.js +0 -1
  157. package/dist/ui/assets/KnowledgeView-DJ3cJVHA.js +0 -1
  158. package/dist/ui/assets/MlxSettings-45mBFHbA.js +0 -1
  159. package/dist/ui/assets/NewTaskDialog-CIXVunZn.js +0 -2
  160. package/dist/ui/assets/ProjectChat-BiJRweob.js +0 -5
  161. package/dist/ui/assets/ProjectConnectionsTab-CQgaIzuv.js +0 -1
  162. package/dist/ui/assets/ProjectsView-BUdR76n6.js +0 -7
  163. package/dist/ui/assets/SessionSwitcher-BgZqyiRn.js +0 -1
  164. package/dist/ui/assets/SettingsView-DLhOYiR5.js +0 -3
  165. package/dist/ui/assets/TaskTabContent-CG2KmfwV.js +0 -1
  166. package/dist/ui/assets/TasksView-Dy5Ue4zS.js +0 -1
  167. package/dist/ui/assets/ToolsetsEditor-J9XxQ5Ms.js +0 -8
  168. package/dist/ui/assets/chat-thread-memory-CI2-giEq.js +0 -1
  169. package/dist/ui/assets/chunk-IIQYS2YH-DEkyBlHg.js +0 -1
  170. package/dist/ui/assets/csv-B0D9jJG2.js +0 -1
  171. package/dist/ui/assets/data-BIL84EaT.js +0 -1
  172. package/dist/ui/assets/dist-CJqyWK6E.js +0 -2
  173. package/dist/ui/assets/dist-DOqbRmFj.js +0 -225
  174. package/dist/ui/assets/doc-C2Ph2FWI.js +0 -584
  175. package/dist/ui/assets/document-companion-aDThLOwl.js +0 -1
  176. package/dist/ui/assets/file-browser-DVyWN0LD.js +0 -5
  177. package/dist/ui/assets/icons-DWaUNQbT.js +0 -1
  178. package/dist/ui/assets/index-DDu8nyO6.js +0 -34
  179. package/dist/ui/assets/index-DEDUSiCx.css +0 -1
  180. package/dist/ui/assets/markdown-baseline-9B52XlX2.js +0 -1
  181. package/dist/ui/assets/materialize-G4WC5UG3-BlZQe-88.js +0 -1
  182. package/dist/ui/assets/outside-in-BmIIeMid.js +0 -3
  183. package/dist/ui/assets/storage-B-vhjyV2.js +0 -1
  184. package/dist/ui/assets/styles-BvkZd-EV.js +0 -550
  185. package/dist/ui/assets/styles-IQ4adxWr.css +0 -1
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{Sn as r,Ut as i}from"./dist-DOqbRmFj.js";import{t as a}from"./dist-CJqyWK6E.js";import{t as o}from"./api-C0I7spBl.js";import{H as ee,J as te,K as ne,W as re,Y as ie,d as ae,l as s,m as c,p as oe,q as se,s as ce}from"./primitives-CWrGZpPI.js";import{t as le}from"./GezelJsonEditor-DXXt165-.js";import{r as l}from"./new-project-meta-ZmDPGYzC.js";import{$ as ue,Q as u,Z as de,at as fe,et as pe,it as me,nt as he,ot as ge,rt as _e,tt as ve}from"./index-DDu8nyO6.js";import{t as ye}from"./CraftbookToolsetSetup-EuFOiUzR.js";import{t as be}from"./useShowWorkInProgressFeatures-BtpredG7.js";var d=e(t(),1);function xe(e){if(e instanceof a){let t=e.details;if(t&&typeof t==`object`&&`error`in t){let e=t.error;if(typeof e==`string`&&e.length>0&&e!==`internal_error`)return e}return e.message}return e instanceof Error?e.message:String(e)}var f=n(),p=`__auto`,Se={"one-time":{title:`New Task`,subtitle:`Pick a craftbook — a proven recipe your crew follows step by step — or start blank.`,generalLabel:u.label,generalDescription:u.description,featuredLabel:`Recommended`,featuredTitle:`Recommended`,featuredTagline:`proven recipes for this kind of project`,submitLabel:`Create task`,footnote:`Lands ready to fire — nothing runs until you fire it.`},scheduled:{title:`New Scheduled Task`,subtitle:`Choose a repeatable craftbook, then set when each fresh run should begin.`,generalLabel:`Blank scheduled task`,generalDescription:`Define a repeatable job from scratch and run a fresh copy on a cadence.`,featuredLabel:`For schedules`,featuredTitle:`Scheduled craftbooks`,featuredTagline:`recipes identified as safe for recurring unattended runs`,submitLabel:`Create schedule`,footnote:`Starts active and creates a fresh task on each scheduled run.`},"night-shift":{title:`New Night Shift Task`,subtitle:`Choose work your crew can pick up unattended during the Night Shift window.`,generalLabel:`Blank Night Shift task`,generalDescription:`Define a one-off job that waits for Night Shift before it begins.`,featuredLabel:`For Night Shift`,featuredTitle:`Night Shift craftbooks`,featuredTagline:`recipes identified as safe for unattended overnight work`,submitLabel:`Queue for Night Shift`,footnote:`Starts active, but only runs while Night Shift is on.`}};function m({open:e,creationMode:t=`one-time`,defaultProjectId:n,projects:a,gezels:m,projectLocked:Te,onClose:h,onCreated:g}){let _=Se[t],Ee=be(),[v,De]=(0,d.useState)(n),[y,Oe]=(0,d.useState)([]),[ke,b]=(0,d.useState)(!1),x=(0,d.useRef)(0),[S,Ae]=(0,d.useState)({}),[C,je]=(0,d.useState)(null),[w,Me]=(0,d.useState)(new Set),[T,E]=(0,d.useState)(null),[D,O]=(0,d.useState)(`pick`),[Ne,k]=(0,d.useState)(!1),[A,Pe]=(0,d.useState)(``),[j,M]=(0,d.useState)(`all`),[Fe,Ie]=(0,d.useState)(!1),[N,P]=(0,d.useState)(``),[F,Le]=(0,d.useState)(!1),[I,Re]=(0,d.useState)(``),[ze,Be]=(0,d.useState)(`Main`),[Ve,He]=(0,d.useState)(``),[Ue,We]=(0,d.useState)(!1),[L,R]=(0,d.useState)({}),[z,Ge]=(0,d.useState)(``),[B,Ke]=(0,d.useState)(`skip`),[V,H]=(0,d.useState)(!1),[qe,U]=(0,d.useState)(``),[Je,W]=(0,d.useState)(null),Ye=(0,d.useRef)(0);(0,d.useEffect)(()=>{e&&(De(n),E(null),k(!1),O(`pick`),Pe(``),M(`all`),Ie(!1),P(``),Le(!1),Re(``),Be(`Main`),He(``),We(!1),R({}),Ge(``),Ke(`skip`),H(!1),U(``),W(null))},[e,n]);let Xe=(0,d.useCallback)(async()=>{let e=++x.current;if(!v){if(e!==x.current)return;Oe([]),b(!0);return}try{let t=await o.listProjectCraftbooks(v);if(e!==x.current)return;let n=r(t.items??[],Ee),i=new Set(n.map(e=>e.manifest.id));Oe(ge(n)),Ae(t.missingToolsets??{}),je(t.projectType??null),Me(new Set((t.suggestedIds??[]).filter(e=>i.has(e)))),E(e=>e&&!i.has(e)?null:e)}catch{if(e!==x.current)return;Oe([]),Ae({}),je(null),Me(new Set)}finally{e===x.current&&b(!0)}},[v,Ee]);(0,d.useEffect)(()=>{e&&(b(!1),Xe())},[e,Xe]),(0,d.useEffect)(()=>{!e||!ke||Fe||(Ie(!0),(t===`one-time`?w.size>0:y.some(e=>t===`scheduled`?e.manifest.runModes?.scheduled:e.manifest.runModes?.nightShift))&&M(`recommended`))},[e,ke,Fe,w,t,y]);let G=T?y.find(e=>e.manifest.id===T)??null:null,K=(()=>{if(!G)return null;let e=G.manifest;return(e.steps.find(t=>t.id===e.entryStepId)??e.steps[0])?.suggestedRole??null})(),Ze=t!==`scheduled`&&(G?.manifest.connectors??[]).some(e=>e.typeId===`github-pulls`&&!e.optional),Qe=String(L.number??``).trim();(0,d.useEffect)(()=>{let t=++Ye.current;W(null),!(!e||!Ze||!v)&&(async()=>{try{let[e,n]=await Promise.all([o.getProjectGitStatus(v),o.listProjectGitHubPulls(v)]);if(t!==Ye.current)return;let{matchingCount:r}=i(n.pulls??[],e.branch);if(r>0)return;W(e.branch?`No open pull request for branch "${e.branch}" — enter a pull request number above, or switch branches first.`:`This checkout is not on a branch — enter a pull request number above.`)}catch{}})()},[e,Ze,v]);let $e=(0,d.useCallback)(()=>{E(null),k(!0),R({}),U(``),O(`configure`),F||P(``)},[F]),et=(0,d.useCallback)(()=>{O(`pick`),U(``)},[]),tt=(0,d.useCallback)(e=>{De(e),E(null),k(!1),R({}),M(`all`),Ie(!1),U(``)},[]),nt=(0,d.useCallback)(e=>{if(E(e.manifest.id),k(!1),R(he(e.manifest.paramSchema)),U(``),O(`configure`),F||P(e.manifest.name),!Ue){let t=e.manifest.defaultAssignee;t?.kind===`gezel`&&m.some(e=>e.id===t.gezelId)&&He(t.gezelId)}},[F,Ue,m]),q=Ve||(K?p:m[0]?.id??`__user`),J=q===p?null:q===`__user`?{kind:`user`}:{kind:`gezel`,gezelId:q},Y=(0,d.useMemo)(()=>fe(y),[y]),X=A.trim().toLowerCase(),Z=X.length>0,Q=(0,d.useMemo)(()=>{if(t===`one-time`)return y.filter(e=>w.has(e.manifest.id));let e=t===`scheduled`?`scheduled`:`nightShift`;return y.filter(t=>t.manifest.runModes?.[e]).sort((t,n)=>{let r=+(t.manifest.runModes?.[e]===`recommended`);return+(n.manifest.runModes?.[e]===`recommended`)-r||t.manifest.name.localeCompare(n.manifest.name)})},[y,w,t]),rt=(0,d.useCallback)(e=>{if(t===`one-time`)return w.has(e.manifest.id);let n=t===`scheduled`?`scheduled`:`nightShift`;return e.manifest.runModes?.[n]===`recommended`},[t,w]),it=(0,d.useMemo)(()=>Z?y.filter(e=>`${e.manifest.id} ${e.manifest.name} ${e.manifest.description} ${(e.manifest.tags??[]).join(` `)}`.toLowerCase().includes(X)).sort((e,t)=>{let n=w.has(e.manifest.id)||e.manifest.tags?.includes(`recommended`)?1:0;return(w.has(t.manifest.id)||t.manifest.tags?.includes(`recommended`)?1:0)-n||Ce(e,X)-Ce(t,X)||e.manifest.name.localeCompare(t.manifest.name)}):y,[y,Z,X,w]),at=!Z||`${_.generalLabel} ${_.generalDescription} blank fresh`.toLowerCase().includes(X),ot=(0,d.useMemo)(()=>{if(Z)return[{id:`search`,title:`Craftbooks`,tagline:`matching "${A.trim()}"`,books:it}];if(j===`recommended`&&Q.length>0)return[{id:`recommended`,title:t===`one-time`&&C?`Recommended for ${C.label}`:_.featuredTitle,tagline:_.featuredTagline,books:Q}];let e=Y.find(e=>e.id===j);return e?[{id:e.id,title:e.label,tagline:e.tagline,books:y.filter(t=>e.bookIds.has(t.manifest.id))}]:[{id:`all`,title:`All craftbooks`,tagline:void 0,books:y}]},[Z,A,it,j,Q,C,Y,y,t,_]),$=G?S[G.manifest.id]??[]:[],st=(0,d.useCallback)(async e=>{if(e.preventDefault(),V||D!==`configure`)return;if(U(``),!v){U(`Pick a project.`);return}let n=z.trim();if(t===`scheduled`&&!n){U(`Enter a schedule.`);return}if(G){let e=G.manifest;if((S[e.id]?.length??0)>0){U(`This craftbook needs its toolsets installed first — see the setup list.`);return}let r=e.paramSchema,i=(Array.isArray(r?.required)?r.required:[]).find(e=>{let t=L[e];return t==null||t===``});if(i){U(`"${i}" is required.`);return}let a=_e(L);H(!0);try{let r=t===`scheduled`?await o.createTask(v,{title:N.trim()||e.name,description:`Recurring scheduled task. ${ue(e,a)} Each scheduled run creates a fresh task from this recipe.`,steps:[{name:`Wait for schedule`,prompt:`This host holds a recurring schedule. It does not perform the work itself; each tick creates a fresh child task.`}],spawnsCraftbookId:e.id,...G.item.sourceId?{spawnsCraftbookSourceId:G.item.sourceId}:{},...J?{assignee:J}:{},cron:{expression:n,overlap:B},...Object.keys(a).length>0?{spawnsCraftbookParams:a}:{}}):await o.createTask(v,{title:N.trim()||e.name,description:ue(e,a),craftbookId:e.id,...G.item.sourceId?{craftbookSourceId:G.item.sourceId}:{},...J?{assignee:J}:{},...t===`one-time`?{dispatchEntry:!0}:{nightShift:{enabled:!0},dispatchEntry:!0},...Object.keys(a).length>0?{craftbookParams:a}:{}});if(t!==`scheduled`&&Object.keys(a).length>0&&r.activeStepId){let e=[`# Invocation parameters`,``];for(let[t,n]of Object.entries(a))e.push(`- **${t}**: ${n}`);await o.appendTaskNote(r.projectId,r.num,{text:e.join(`
2
- `),stepId:r.activeStepId}).catch(()=>{})}await g(r),h()}catch(e){U(xe(e))}finally{H(!1)}return}let r=N.trim();if(!r){U(`Title is required.`);return}if(I.trim().length<40){U(`Description must be at least 40 characters — the job-to-be-done from the user's perspective. What does success look like?`);return}let i=ze.split(/\n|,/).map(e=>e.trim()).filter(Boolean).map(e=>({name:e}));i.length===0&&i.push({name:`Main`}),H(!0);try{await g(t===`scheduled`?await o.createTask(v,{title:r,description:I.trim(),steps:[{name:`Wait for schedule`,prompt:`This host holds a recurring schedule. It does not perform the work itself; each tick creates a fresh child task.`}],spawnsSteps:i,...J?{assignee:J}:{},cron:{expression:n,overlap:B}}):await o.createTask(v,{title:r,description:I.trim(),steps:i,...J?{assignee:J}:{},...t===`one-time`?{status:`draft`}:{nightShift:{enabled:!0},dispatchEntry:!0}})),h()}catch(e){U(xe(e))}finally{H(!1)}},[V,D,t,v,G,S,L,N,J,I,ze,z,B,g,h]),ct=G&&ve(G.manifest)?G.manifest.paramSchema:null,lt=V||G!==null&&$.length>0,ut=G?`Craftbook${rt(G)?t===`night-shift`?` · recommended for Night Shift`:t===`scheduled`?` · recommended for schedules`:` · recommended`:``}`:t===`one-time`?`Blank task`:t===`scheduled`?`Blank schedule`:`Blank Night Shift task`,dt=a.find(e=>e.id===v)?.name??``;return(0,f.jsx)(te,{open:e,onOpenChange:e=>{e||h()},children:(0,f.jsxs)(se,{children:[(0,f.jsx)(ne,{}),(0,f.jsx)(re,{className:`gz-npd gz-ntd gz-npd-step-${D}`,children:(0,f.jsx)(`form`,{onSubmit:st,style:{display:`contents`},children:D===`pick`?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`header`,{className:`gz-npd-header`,children:[(0,f.jsxs)(`div`,{className:`gz-npd-header-copy`,children:[(0,f.jsx)(ie,{asChild:!0,children:(0,f.jsx)(`h3`,{children:_.title})}),(0,f.jsx)(`p`,{className:`gz-npd-header-sub`,children:_.subtitle})]}),(0,f.jsxs)(`div`,{className:`gz-ntd-header-controls`,children:[!Te&&(0,f.jsxs)(`label`,{className:`gz-ntd-header-project`,children:[(0,f.jsx)(`span`,{children:`Project`}),(0,f.jsxs)(ae,{value:v,onValueChange:tt,children:[(0,f.jsx)(oe,{children:(0,f.jsx)(c,{})}),(0,f.jsx)(ce,{children:a.map(e=>(0,f.jsx)(s,{value:e.id,children:e.name},e.id))})]})]}),(0,f.jsxs)(`label`,{className:`gz-npd-search`,children:[(0,f.jsx)(`span`,{className:`sr-only`,children:`Search craftbooks`}),(0,f.jsx)(`input`,{type:`search`,value:A,onChange:e=>Pe(e.target.value),placeholder:`Search craftbooks…`})]})]})]}),(0,f.jsxs)(`div`,{className:`gz-npd-body`,children:[(0,f.jsxs)(`nav`,{className:`gz-npd-rail`,"aria-label":`Craftbook shelves`,children:[Q.length>0&&(0,f.jsxs)(`button`,{type:`button`,className:`gz-npd-rail-item${!Z&&j===`recommended`?` active`:``}`,onClick:()=>M(`recommended`),children:[(0,f.jsx)(l,{glyph:`sprout`,size:16}),(0,f.jsx)(`span`,{className:`gz-npd-rail-label`,children:_.featuredLabel}),(0,f.jsx)(`span`,{className:`gz-npd-rail-count`,children:Q.length})]}),(0,f.jsxs)(`button`,{type:`button`,className:`gz-npd-rail-item${!Z&&j===`all`?` active`:``}`,onClick:()=>M(`all`),children:[(0,f.jsx)(l,{glyph:`sheet`,size:16}),(0,f.jsx)(`span`,{className:`gz-npd-rail-label`,children:`All craftbooks`}),(0,f.jsx)(`span`,{className:`gz-npd-rail-count`,children:y.length})]}),Y.map((e,t)=>{let n=Y[t-1]?.family===e.family?null:me(e.family);return(0,f.jsxs)(d.Fragment,{children:[n&&(0,f.jsx)(`span`,{className:`gz-npd-rail-group`,children:n}),(0,f.jsxs)(`button`,{type:`button`,className:`gz-npd-rail-item${!Z&&j===e.id?` active`:``}`,onClick:()=>M(e.id),children:[(0,f.jsx)(l,{glyph:e.glyph,size:16}),(0,f.jsx)(`span`,{className:`gz-npd-rail-label`,children:e.label}),(0,f.jsx)(`span`,{className:`gz-npd-rail-count`,children:e.bookIds.size})]})]},e.id)})]}),(0,f.jsxs)(`div`,{className:`gz-npd-gallery`,role:`radiogroup`,"aria-label":`Task type`,children:[at&&(0,f.jsxs)(`section`,{className:`gz-npd-section`,children:[(0,f.jsx)(`div`,{className:`gz-npd-section-head`,children:(0,f.jsx)(`span`,{className:`gz-npd-section-title`,children:`Start fresh`})}),(0,f.jsx)(`div`,{className:`gz-npd-grid`,children:(0,f.jsx)(we,{label:_.generalLabel,description:_.generalDescription,glyph:u.glyph,index:0,active:Ne,onSelect:$e})})]}),ot.map(e=>(0,f.jsxs)(`section`,{className:`gz-npd-section`,children:[(0,f.jsxs)(`div`,{className:`gz-npd-section-head`,children:[(0,f.jsx)(`span`,{className:`gz-npd-section-title`,children:e.title}),e.tagline&&(0,f.jsx)(`span`,{className:`gz-npd-section-tagline`,children:e.tagline})]}),e.books.length>0?(0,f.jsx)(`div`,{className:`gz-npd-grid`,children:e.books.map((e,t)=>(0,f.jsx)(we,{label:e.manifest.name,description:e.manifest.description,glyph:pe(e.manifest),...e.item.iconSvg?{iconSvg:e.item.iconSvg}:{},...e.item.logoUrl?{logoUrl:e.item.logoUrl}:{},suggested:rt(e),index:t+1,active:e.manifest.id===T,onSelect:()=>nt(e)},e.manifest.id))}):(0,f.jsx)(`p`,{className:`gz-npd-empty`,children:ke?Z?`No craftbooks match your search.`:`No craftbooks here yet.`:`Loading craftbooks…`}),e.id===`recommended`&&y.length>Q.length&&(0,f.jsxs)(`button`,{type:`button`,className:`gz-ntd-show-all`,onClick:()=>M(`all`),children:[`Browse all `,y.length,` craftbooks`]})]},e.id))]})]}),(0,f.jsxs)(`div`,{className:`gz-npd-pane-footer gz-npd-pick-footer`,children:[(0,f.jsx)(`p`,{className:`gz-npd-footnote`,children:`Pick one to see what it does — nothing is created until the next screen.`}),(0,f.jsx)(ee,{children:(0,f.jsx)(`button`,{type:`button`,onClick:h,children:`Cancel`})})]})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`header`,{className:`gz-npd-header gz-npd-detail-header`,children:[(0,f.jsxs)(`button`,{type:`button`,className:`gz-npd-back`,onClick:et,children:[(0,f.jsx)(`span`,{"aria-hidden":`true`,children:`‹`}),G?`Craftbooks`:`Back`]}),(0,f.jsxs)(`div`,{className:`gz-npd-detail-id`,children:[(0,f.jsx)(`span`,{className:`gz-npd-detail-art`,"aria-hidden":`true`,children:G?(0,f.jsx)(de,{...G.item.iconSvg?{iconSvg:G.item.iconSvg}:{},...G.item.logoUrl?{logoUrl:G.item.logoUrl}:{},svgClassName:`gz-npd-hero-art-svg`,fallback:(0,f.jsx)(l,{glyph:pe(G.manifest),size:26})}):(0,f.jsx)(l,{glyph:u.glyph,size:26})}),(0,f.jsxs)(`div`,{className:`gz-npd-header-copy`,children:[(0,f.jsx)(`p`,{className:`gz-npd-hero-eyebrow`,children:ut}),(0,f.jsx)(ie,{asChild:!0,children:(0,f.jsx)(`h3`,{className:`gz-npd-hero-name`,children:G?G.manifest.name:_.generalLabel})})]})]}),!Te&&dt&&(0,f.jsxs)(`p`,{className:`gz-ntd-detail-project`,children:[`in `,(0,f.jsx)(`strong`,{children:dt})]})]}),(0,f.jsxs)(`div`,{className:`gz-npd-detail`,"data-blank":G?void 0:`true`,children:[G&&(0,f.jsxs)(`div`,{className:`gz-npd-brief`,children:[(0,f.jsx)(`p`,{className:`gz-npd-brief-lede`,children:G.manifest.description}),G.manifest.basedOn&&(0,f.jsxs)(`p`,{className:`gz-ntd-based-on`,children:[`Based on`,` `,(0,f.jsx)(`a`,{href:G.manifest.basedOn.url,target:`_blank`,rel:`noreferrer`,children:G.manifest.basedOn.name})]}),(0,f.jsxs)(`div`,{className:`gz-ntd-steps`,children:[(0,f.jsxs)(`p`,{className:`gz-npd-give-eyebrow`,children:[G.manifest.steps.length,` step`,G.manifest.steps.length===1?``:`s`]}),(0,f.jsx)(`ol`,{className:`gz-ntd-steps-list`,children:G.manifest.steps.map(e=>(0,f.jsxs)(`li`,{children:[(0,f.jsxs)(`span`,{className:`gz-ntd-step-head`,children:[(0,f.jsx)(`span`,{className:`gz-ntd-step-name`,children:e.name}),e.suggestedRole&&(0,f.jsx)(`span`,{className:`gz-ntd-step-role`,children:e.suggestedRole})]}),e.description&&(0,f.jsx)(`span`,{className:`gz-ntd-step-note`,children:e.description})]},e.id))})]})]}),(0,f.jsxs)(`div`,{className:`gz-npd-setup`,children:[!G&&(0,f.jsx)(`p`,{className:`gz-npd-brief-lede`,children:_.generalDescription}),(0,f.jsxs)(`div`,{className:`gz-npd-pane-form`,children:[(0,f.jsxs)(`label`,{children:[`Title`,(0,f.jsx)(`input`,{value:N,onChange:e=>{P(e.target.value),Le(!0)},placeholder:G?G.manifest.name:`e.g. Ship the landing page`})]}),$.length>0&&G&&(0,f.jsxs)(`div`,{className:`gz-ntd-needs`,children:[(0,f.jsx)(`p`,{className:`gz-npd-give-eyebrow`,children:`Needs setup`}),(0,f.jsx)(ye,{missing:$,onAllInstalled:()=>void Xe(),onCancel:et})]}),ct&&$.length===0&&(0,f.jsxs)(`div`,{className:`gz-npd-params`,children:[(0,f.jsx)(`p`,{className:`gz-npd-give-eyebrow`,children:`Parameters`}),(0,f.jsx)(le,{schema:ct,value:L,onChange:e=>{R(e??{}),U(``)},density:`comfortable`})]}),!G&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`label`,{children:[`Description `,(0,f.jsx)(`span`,{className:`muted`,children:`· a sentence or two`}),(0,f.jsx)(`textarea`,{value:I,onChange:e=>Re(e.target.value),rows:4,placeholder:`What's the problem? What does success look like for the user?`})]}),(0,f.jsxs)(`label`,{children:[`Steps `,(0,f.jsx)(`span`,{className:`muted`,children:`(one per line)`}),(0,f.jsx)(`textarea`,{value:ze,onChange:e=>Be(e.target.value),rows:4})]})]}),(0,f.jsxs)(`label`,{children:[`Assign to`,(0,f.jsxs)(ae,{value:q,onValueChange:e=>{He(e),We(!0)},children:[(0,f.jsx)(oe,{children:(0,f.jsx)(c,{})}),(0,f.jsxs)(ce,{children:[K&&(0,f.jsxs)(s,{value:p,children:[`Auto — the `,K,` for step 1`]}),m.map(e=>(0,f.jsxs)(s,{value:e.id,children:[e.name,e.role?` — ${e.role}`:``]},e.id)),(0,f.jsx)(s,{value:`__user`,children:`Me (no gezel)`})]})]}),q===p?(0,f.jsxs)(`small`,{className:`muted`,children:[`Every step picks its own specialist by role when the task fires. Step 1 goes to the `,K,`, and whoever that turns out to be owns the task.`]}):G&&(0,f.jsx)(`small`,{className:`muted`,children:`Steps that name a role pick their own specialist when the task fires — this only covers steps that name none.`}),q===`__user`&&(0,f.jsx)(`small`,{className:`muted`,children:`Assigned to you — firing won't hand it to a gezel.`})]}),t===`scheduled`&&(0,f.jsxs)(`div`,{className:`gz-ntd-schedule`,children:[(0,f.jsx)(`p`,{className:`gz-npd-give-eyebrow`,children:`Schedule`}),(0,f.jsxs)(`label`,{children:[`Cron expression `,(0,f.jsx)(`span`,{className:`muted`,children:`(UTC, 5-field)`}),(0,f.jsx)(`input`,{value:z,placeholder:`e.g. 0 9 * * 1 — every Monday 09:00`,onChange:e=>Ge(e.target.value)})]}),(0,f.jsxs)(`label`,{children:[`Overlap policy`,(0,f.jsxs)(ae,{value:B,onValueChange:e=>Ke(e),children:[(0,f.jsx)(oe,{children:(0,f.jsx)(c,{})}),(0,f.jsxs)(ce,{children:[(0,f.jsx)(s,{value:`skip`,children:`skip — don't spawn if a prior run is still active`}),(0,f.jsx)(s,{value:`queue`,children:`queue — always spawn, let the runner throttle`}),(0,f.jsx)(s,{value:`concurrent`,children:`concurrent — spawn unconditionally`})]})]})]})]})]})]})]},T??`__general`),(0,f.jsxs)(`div`,{className:`gz-npd-pane-footer gz-npd-detail-footer`,children:[qe?(0,f.jsx)(`p`,{className:`error small gz-npd-submit-error`,role:`alert`,children:qe}):Je&&!Qe?(0,f.jsx)(`p`,{className:`gz-npd-footnote gz-ntd-launch-hint`,children:Je}):(0,f.jsx)(`p`,{className:`gz-npd-footnote`,children:t===`one-time`&&G?`Starts immediately — the first gezel gets to work as soon as you create it.`:_.footnote}),(0,f.jsxs)(ee,{children:[(0,f.jsx)(`button`,{type:`button`,onClick:h,disabled:V,children:`Cancel`}),(0,f.jsx)(`button`,{type:`submit`,className:`primary`,disabled:lt,children:V?t===`one-time`&&G?`Starting…`:`Creating…`:t===`one-time`&&G?`Create & start`:_.submitLabel})]})]})]})})})]})})}function Ce(e,t){let n=e.manifest.name.toLowerCase();return n===t?0:n.startsWith(t)?1:n.split(/\s+/).some(e=>e.startsWith(t))?2:n.includes(t)?3:`${e.manifest.id} ${(e.manifest.tags??[]).join(` `)}`.toLowerCase().includes(t)?4:5}function we({label:e,description:t,active:n,iconSvg:r,logoUrl:i,glyph:a,suggested:o=!1,index:ee,onSelect:te}){return(0,f.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"aria-label":e,className:`gz-npd-card${n?` active`:``}${o?` gz-ntd-card-suggested`:``}`,onClick:te,style:{"--card-i":Math.min(ee,11)},children:[(0,f.jsx)(`span`,{className:`gz-npd-card-mark`,"aria-hidden":`true`,children:(0,f.jsx)(de,{...r?{iconSvg:r}:{},...i?{logoUrl:i}:{},svgClassName:`gz-npd-card-mark-svg`,fallback:(0,f.jsx)(l,{glyph:a,size:22})})}),(0,f.jsx)(`span`,{className:`gz-npd-card-name`,children:e}),(0,f.jsx)(`span`,{className:`gz-npd-card-description`,children:t})]})}export{m as t};
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalCodeEditor-ChmdzmCz.js","assets/rolldown-runtime-aKtaBQYM.js","assets/jsx-runtime-CEpd2cAX.js","assets/preload-helper-Czpn1I53.js","assets/index-DDu8nyO6.js","assets/react-dom-OL4w_gzs.js","assets/dist-DOqbRmFj.js","assets/dist-CJqyWK6E.js","assets/api-C0I7spBl.js","assets/primitives-CWrGZpPI.js","assets/Tabs-jE0Z5Tzd.js","assets/document-companion-aDThLOwl.js","assets/DropdownMenu-DlrvEmoV.js","assets/dist-Q59u9cBl.js","assets/relative-time-B2kBaekd.js","assets/FileTypeIcon-Cwzl1GkZ.js","assets/model-context-DBqdK0PS.js","assets/model-memory-copy-Ds9w1uJE.js","assets/StorageCleanupDialog-3kv9-2mT.js","assets/poppetje-CfaAvFkE.js","assets/safe-svg-image-NbuPaBIv.js","assets/ConfirmDialog-Dt1ed4Fh.js","assets/model-inventory-ykSm_IT5.js","assets/doc-C2Ph2FWI.js","assets/chunk-O7JILDEF-CqcO1qaI.js","assets/chunk-BAOV476U-CEOFYt8X.js","assets/chunk-4VOD55SX-BFSSw0c8.js","assets/chunk-GAZKTT4R-w1SNypWQ.js","assets/chunk-UBFT2CDQ-FexGDigd.js","assets/chunk-XRW6P7IF-BeQQgMVK.js","assets/chunk-7ZAAICW4-BsCpYJH6.js","assets/markdown-ryKA_OmY.js","assets/schemas-BvLZUsGm.js","assets/chunk-6ECMNUIP-BvCy0HUI.js","assets/inlineIconMarker-BQI2HLeD.js","assets/chunk-TT6ENR6T-BOA-qiwP.js","assets/chunk-DQRELU4S--U9FIVtY.js","assets/new-project-meta-ZmDPGYzC.js","assets/chunk-AE3IUKMM-mZjzzO8Z.js","assets/index-DEDUSiCx.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{Jt as r,Sn as i,W as a,ct as o,ft as s}from"./dist-DOqbRmFj.js";import{t as c}from"./api-C0I7spBl.js";import{_ as l,g as u,o as d,v as f,y as p}from"./primitives-CWrGZpPI.js";import{l as m,n as h,o as g,r as _,s as v}from"./DropdownMenu-DlrvEmoV.js";import{n as y,t as b}from"./relative-time-B2kBaekd.js";import{t as x}from"./preload-helper-Czpn1I53.js";import{A as S,C,It as w,dt as T,j as E,p as D,r as O,ut as k,zt as A}from"./index-DDu8nyO6.js";import{t as j}from"./NewTaskDialog-CIXVunZn.js";import{t as M}from"./useShowWorkInProgressFeatures-BtpredG7.js";import{i as N,n as P,r as F}from"./ChatTimelineView-Cg_kLK_U.js";import{a as I,i as L,t as ee}from"./SessionSwitcher-BgZqyiRn.js";import{n as te,t as ne}from"./ProjectTimeline-CTPcn4Kc.js";import{a as re,c as ie,i as ae,l as oe,o as se,s as ce,u as R}from"./chat-thread-memory-CI2-giEq.js";import{r as le,t as z}from"./completion-data--97asQiQ.js";var B=e(t(),1),V=[/<function=([a-zA-Z_][a-zA-Z0-9_]*)/,/<invoke\s+name="([a-zA-Z_][a-zA-Z0-9_]*)/,/"(?:tool|name|function)"\s*:\s*"([a-zA-Z_][a-zA-Z0-9_]*)"/],H=/<function[=\s>]|<tool_call>|<invoke[\s>]|<parameter[=\s]|<\|tool_call\|>/i,U=/<\/?think>|<\|?channel\|?>|(?:^|\n)(?:thought|analysis|commentary)\|/i,W=/!\[[^\]]*\]\(/,ue=/<think>(?![\s\S]*<\/think>)/i,G=/\{\s*"(?:tool|name|function)"\s*:\s*"[a-zA-Z_][a-zA-Z0-9_]*"/g;function de(e){if(!e.includes(`{`))return e;let t=``,n=0;G.lastIndex=0;for(let r=G.exec(e);r;r=G.exec(e)){if(r.index<n)continue;let i=0,a=!1,o=!1,s=-1;for(let t=r.index;t<e.length;t++){let n=e[t];if(o)o=!1;else if(n===`\\`&&a)o=!0;else if(n===`"`)a=!a;else if(!a&&n===`{`)i++;else if(!a&&n===`}`&&(i--,i===0)){s=t+1;break}}t+=e.slice(n,r.index),n=s===-1?e.length:s,G.lastIndex=n}return t+e.slice(n)}function K(e){return e.replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/@\[([^\]]+)\]\([^)]+\)/g,`@$1`).replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`).replace(/[*_~`#>]+/g,``).replace(/\s+/g,` `).trim()}function fe(e){let t=E(e);if(t.length>0)return{name:t[0].name,trusted:!0};for(let t of V){let n=e.match(t);if(n?.[1])return{name:n[1],trusted:!1}}return null}function q(e){if(!e)return``;let t=o(e);if(t)return t;let n=e.search(ue),r=n===-1?e:e.slice(0,n),i=K(de(S(r,{hideMidStreamOpener:!0})));if(i)return i;let a=fe(r);return a&&(a.trusted||k(a.name))?`${T(a.name)}…`:a||H.test(r)?`Using a tool…`:U.test(e)?`Thinking…`:W.test(r)?`Shared an image`:``}function J(e,t){let n=(0,B.useRef)(new Map),r=(0,B.useRef)(new Set),[i,a]=(0,B.useState)(0),o=(0,B.useMemo)(()=>[...new Set(e)].sort().join(`
3
- `),[e]);return(0,B.useEffect)(()=>{for(let[e,t]of[...n.current])t||n.current.delete(e)},[t]),(0,B.useEffect)(()=>{let e=(o?o.split(`
4
- `):[]).filter(e=>!n.current.has(e)&&!r.current.has(e));if(e.length===0)return;let t=!1;for(let t of e)r.current.add(t);return Promise.all(e.map(async e=>{try{let t=await c.getTaskByRef(e);n.current.set(e,t.status===`complete`||t.status===`canceled`)}catch{n.current.set(e,!1)}finally{r.current.delete(e)}})).then(()=>{t||a(e=>e+1)}),()=>{t=!0}},[o,t]),(0,B.useMemo)(()=>{let e=o?o.split(`
5
- `):[];return new Set(e.filter(e=>n.current.get(e)===!0))},[o,i])}var Y=750,pe=2e4,me={inflight:0,errored:1,idle:2};function X(e){let t=Date.parse(e);return Number.isNaN(t)?0:t}function he(e){let t=e.replace(/\s+/g,` `).trim(),n=``;for(let e of t){if(n.length+e.length>200)break;n+=e}return n}function ge(e,t,n){let r=!1,i=e.map(e=>{if(e.id!==t)return e;r=!0;let i=new Set(e.involvedGezelIds??[e.gezelId]);n.from&&i.add(n.from.gezelId);let a=he(n.content);return{...e,lastActivityAt:n.at,involvedGezelIds:[...i],...a?{lastMessagePreview:a}:{}}});return r?i:null}function _e(e){let{sessions:t,inflight:n,errored:r,now:i,pinnedSessionId:a,groupedTaskRefs:o,finishedTaskRefs:s,liveTools:c,maxInline:l=6}=e,u=[],d=new Map,f=t.filter(e=>!e.archived&&!e.taskRef).reduce((e,t)=>!e||X(t.lastActivityAt)>X(e.lastActivityAt)?t:e,null)?.id;for(let e of t){if(e.archived)continue;let t=r.get(e.id)??e.lastTurnError,l=n.has(e.id)?`inflight`:t?`errored`:`idle`,p=l===`inflight`?c?.get(e.id):void 0,m={sessionId:e.id,gezelId:e.gezelId,title:I(L(e.title)),lastActivityAt:e.lastActivityAt,state:l,involvedGezelIds:e.involvedGezelIds&&e.involvedGezelIds.length>0?e.involvedGezelIds:[e.gezelId],...e.lastMessagePreview?{lastMessagePreview:e.lastMessagePreview}:{},...p?{liveToolName:p}:{},...e.taskRef?{taskRef:e.taskRef}:{},...t?{error:t}:{}};if(e.taskRef&&o?.has(e.taskRef)){let t=d.get(e.taskRef);(!t||X(m.lastActivityAt)>X(t.lastActivityAt))&&d.set(e.taskRef,m);continue}let h=a!==void 0&&e.id===a;if(l===`idle`&&!h&&e.taskRef&&s?.has(e.taskRef))continue;let g=e.id===f;l===`idle`&&!h&&!g&&i-X(e.lastActivityAt)>864e5||u.push(m)}u.sort((e,t)=>{let n=me[e.state]-me[t.state];return n===0?X(t.lastActivityAt)-X(e.lastActivityAt):n});let p=u.filter(e=>e.state!==`idle`).length,m=Math.max(l,p);for(let e of[a,f]){if(e===void 0)continue;let t=u.findIndex(t=>t.sessionId===e);t>=m&&(m=t+1)}return{pills:u.slice(0,m),overflow:u.slice(m),taskPills:d}}function ve({projectId:e,gezelId:t,pinnedSessionId:n,groupedTaskRefs:r,refreshKey:i}){let[a,o]=(0,B.useState)([]),s=(0,B.useRef)([]),[l,u]=(0,B.useState)(!0),[d,f]=(0,B.useState)(()=>new Set),[p,m]=(0,B.useState)(()=>new Map),[h,g]=(0,B.useState)(()=>new Map),[_,v]=(0,B.useState)(0),y=(0,B.useCallback)(async()=>{try{let n=await c.listChatSessions({projectId:e,...t?{gezelId:t}:{}});s.current=n.sessions,o(n.sessions)}catch{}finally{u(!1)}},[e,t]),b=(0,B.useCallback)(async()=>{try{let{inflight:n}=await c.listInflightTurns({projectId:e,...t?{gezelId:t}:{}});f(new Set(n.map(e=>e.sessionId)))}catch{}},[e,t]);(0,B.useEffect)(()=>{u(!0),y(),b()},[y,b,i,n]),(0,B.useEffect)(()=>{let e=window.setInterval(()=>void b(),pe);return()=>window.clearInterval(e)},[b]),(0,B.useEffect)(()=>{let e=window.setInterval(()=>v(e=>e+1),6e4);return()=>window.clearInterval(e)},[]),(0,B.useEffect)(()=>{let e=()=>void y();return window.addEventListener(`gezel:session-error-cleared`,e),()=>window.removeEventListener(`gezel:session-error-cleared`,e)},[y]);let x=(0,B.useCallback)((e,t)=>{g(n=>{if(t===null){if(!n.has(e))return n;let t=new Map(n);return t.delete(e),t}if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})},[]),S=(0,B.useRef)(null);(0,B.useEffect)(()=>{let n=new AbortController,r=()=>{S.current!==null&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{S.current=null,y()},Y)};return(async()=>{try{for await(let i of A({url:c.projectEventsUrl(e),headers:c.authHeader(),signal:n.signal,fetch:c.getFetch()})){let{event:e,sessionId:n}=i;if(!(t&&i.gezelId!==t)){if(e.type===`tool_args_delta`||e.type===`tool`?x(n,e.name):(e.type===`complete`||e.type===`done`||e.type===`error`||e.type===`cancelled`)&&x(n,null),e.type===`user_message`){f(e=>{if(e.has(n))return e;let t=new Set(e);return t.add(n),t});let t=ge(s.current,n,e.message);t?(s.current=t,o(t)):y()}else(e.type===`done`||e.type===`error`||e.type===`cancelled`)&&f(e=>{if(!e.has(n))return e;let t=new Set(e);return t.delete(n),t});if(e.type===`error`)m(t=>{let r=new Map(t);return r.set(n,e.error),r});else if(e.type===`complete`){let t=ge(s.current,n,e.message);t&&(s.current=t,o(t)),m(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})}(e.type===`done`||e.type===`complete`)&&r()}}}catch{}})(),()=>{n.abort(),S.current!==null&&(window.clearTimeout(S.current),S.current=null)}},[e,t,y,x]);let C=J((0,B.useMemo)(()=>{let e=new Set;for(let t of a)t.archived||!t.taskRef||r?.has(t.taskRef)||e.add(t.taskRef);return[...e]},[a,r]),i),{pills:w,overflow:T,taskPills:E}=(0,B.useMemo)(()=>_e({sessions:a,inflight:d,errored:p,now:Date.now(),pinnedSessionId:n,liveTools:h,finishedTaskRefs:C,...r?{groupedTaskRefs:r}:{}}),[a,d,p,h,n,r,C,_]);return{pills:w,overflow:T,taskPills:E,loading:l}}var Z=n(),ye=1440*60*1e3;function be(e){let t=Date.parse(e);return Number.isNaN(t)?0:t}function xe({projectId:e,gezelId:t,gezels:n,activeSessionId:r,activeTaskRef:i,activeTerminalThreadId:o,onFocusThread:s,onFocusTask:l,onFocusTerminal:u,onNewTask:d,refreshKey:f,terminalRefreshKey:p}){let{tasks:y,loading:b}=te({projectId:e,refreshKey:f}),{pills:x,overflow:S,taskPills:w,loading:T}=ve({projectId:e,gezelId:t,pinnedSessionId:r,groupedTaskRefs:(0,B.useMemo)(()=>new Set(y.map(e=>e.ref)),[y]),refreshKey:f}),[E,D]=(0,B.useState)([]),O=u!==void 0;(0,B.useEffect)(()=>{if(!O){D([]);return}let t=!1;return c.listTerminalThreads(e).then(e=>{if(t)return;let n=Date.now()-ye;D(e.threads.filter(e=>!e.archived&&be(e.lastActivityAt)>=n))}).catch(()=>{}),()=>{t=!0}},[e,O,p]);let k=(0,B.useMemo)(()=>E.filter(t=>t.projectId===e),[E,e]),A=C(),j=e=>{let t=n.find(t=>t.id===e);return t?a({name:t.name,roleBasedName:t.roleBasedName},A):`someone`},M=e=>[...new Set(e.involvedGezelIds.map(j))].join(`, `),N=[...x,...w.values()],P=N.filter(e=>e.state===`inflight`).length,F=N.filter(e=>e.state===`errored`).length,I=[P>0?`${P} ${P===1?`thread`:`threads`} working`:``,F>0?`${F} needs attention`:``].filter(Boolean).join(`, `),L=!(b||T)&&x.length===0&&k.length===0&&y.length===0,{scrollRef:ee,overflowBar:ne}=Se(x.length+S.length+k.length+y.length+ +!!L);return(0,Z.jsxs)(`div`,{className:`chat-pill-row`,role:`toolbar`,"aria-label":`Threads, terminal windows, and tasks`,children:[(0,Z.jsx)(`output`,{className:`sr-only`,children:I}),(0,Z.jsxs)(`div`,{className:`chat-pill-row-scroller`,children:[(0,Z.jsxs)(`div`,{className:`chat-pill-row-scroll`,ref:ee,onScroll:ne.onScroll,children:[L&&(0,Z.jsx)(`span`,{className:`chat-pill-row-empty muted small`,children:`No recent threads`}),y.map(e=>{let t=w.get(e.ref);return(0,Z.jsx)(Ae,{task:e,latestThread:t,gezels:n,gezelNames:t?M(t):e.assignee.kind===`gezel`?j(e.assignee.gezelId):`You`,active:e.ref===i,onFocus:l},e.ref)}),x.map(e=>(0,Z.jsx)(we,{pill:e,gezels:n,gezelNames:M(e),active:e.sessionId===r,onFocus:s},e.sessionId)),S.length>0&&(0,Z.jsxs)(v,{children:[(0,Z.jsxs)(m,{className:`chat-pill chat-pill-overflow`,children:[`+`,S.length,` more`]}),(0,Z.jsx)(g,{children:(0,Z.jsx)(h,{className:`chat-rail-section-tab-menu chat-pill-overflow-menu`,align:`start`,sideOffset:4,children:S.map(e=>(0,Z.jsx)(_,{onSelect:()=>s(e),className:`chat-pill-overflow-item chat-pill-${e.state}`,children:(0,Z.jsx)(Te,{pill:e,gezelNames:M(e)})},e.sessionId))})})]}),u&&k.map(e=>(0,Z.jsx)(Ce,{thread:e,active:e.id===o,onFocus:u},e.id))]}),ne.node]}),d&&(0,Z.jsx)(`button`,{type:`button`,className:`chat-pill-new-task`,onClick:d,"aria-label":`New task`,title:`New task — pick a craftbook`,children:`Do +`})]})}function Se(e){let t=(0,B.useRef)(null),[n,r]=(0,B.useState)(null),i=(0,B.useCallback)(()=>{let e=t.current;if(!e)return;let{scrollWidth:n,clientWidth:i,scrollLeft:a}=e;if(n-i<2){r(e=>e===null?e:null);return}let o=i/n,s=a/n;r(e=>e&&Math.abs(e.left-s)<5e-4&&Math.abs(e.width-o)<5e-4?e:{left:s,width:o})},[]);return(0,B.useEffect)(()=>{i()},[i,e]),(0,B.useEffect)(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>i());return n.observe(e),()=>n.disconnect()},[i]),{scrollRef:t,overflowBar:{onScroll:i,node:n&&(0,Z.jsx)(`div`,{className:`chat-pill-row-bar`,"aria-hidden":`true`,onPointerDown:e=>{let r=t.current;if(!r||!n)return;let i=e.currentTarget.getBoundingClientRect(),a=(e.clientX-i.left)/i.width<n.left?-r.clientWidth:r.clientWidth;r.scrollBy({left:a,behavior:`smooth`})},children:(0,Z.jsx)(`div`,{className:`chat-pill-row-bar-thumb`,style:{left:`${n.left*100}%`,width:`${n.width*100}%`},onPointerDown:e=>{let n=t.current,r=e.currentTarget.parentElement;if(!n||!r)return;e.preventDefault(),e.stopPropagation();let i=n.scrollWidth/r.clientWidth,a=e.clientX,o=n.scrollLeft,s=e=>{n.scrollLeft=o+(e.clientX-a)*i},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c)}})})}}}function Ce({thread:e,active:t,onFocus:n}){let r=F(e.workingDir),i=$(e.lastActivityAt),a=e.lastCommand?.replace(/\s+/g,` `).trim()||null,o=a?Q(a,40):null;return(0,Z.jsxs)(`button`,{type:`button`,className:`chat-pill chat-pill-thread chat-pill-terminal${t?` is-active`:``}`,"aria-pressed":t,"aria-label":`Terminal ${r}.${a?` Last command: ${a}.`:``} Updated ${i}`,title:`Terminal · ${r}${a?` · last command: ${a}`:``} · updated ${i}`,onClick:()=>n(e),children:[(0,Z.jsx)(`span`,{className:`chat-pill-thread-line chat-pill-thread-title`,children:`Terminal`}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-context`,children:[(0,Z.jsx)(`span`,{className:`terminal-prompt-sigil`,"aria-hidden":`true`,children:`>`}),(0,Z.jsx)(`span`,{className:`chat-pill-message-preview${a?` chat-pill-terminal-command`:``}`,children:o??r})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-update`,children:[a&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`chat-pill-terminal-folder`,children:r}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-updated-at`,title:b(e.lastActivityAt),children:[`Updated `,i]})]})]})}function we({pill:e,gezels:t,gezelNames:n,active:r,onFocus:i}){let a=t.find(t=>t.id===e.gezelId),o=$(e.lastActivityAt),s=ke(e.state),c=Oe(e),l=`${n} · ${e.title} · updated ${o} · ${s}${e.error?`: ${e.error}`:``}`;return(0,Z.jsx)(`button`,{type:`button`,className:`chat-pill chat-pill-thread chat-pill-${e.state}${r?` is-active`:``}`,"aria-pressed":r,"aria-label":`${n}: ${e.title}. ${c}. Updated ${o}. ${s}`,title:l,onClick:()=>i(e),children:(0,Z.jsx)(Te,{pill:e,gezelNames:n,gezel:a})})}function Te({pill:e,gezelNames:t,gezel:n}){let r=Oe(e);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`chat-pill-thread-line chat-pill-thread-title`,children:Q(e.title,40)}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-context`,children:[n&&(0,Z.jsx)(w,{svg:n.icon??null,poppetje:n.poppetje,iconOverride:n.iconOverride,name:t,size:14}),(0,Z.jsx)(`span`,{className:`chat-pill-participants`,children:t}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`}),(0,Z.jsx)(`span`,{className:`chat-pill-message-preview`,children:r})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-update`,children:[(0,Z.jsxs)(`span`,{className:`chat-pill-thread-updated-at`,title:b(e.lastActivityAt),children:[`Updated `,$(e.lastActivityAt)]}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-status`,children:[(0,Z.jsx)(`span`,{className:`chat-pill-dot`,"aria-hidden":`true`}),ke(e.state)]})]})]})}var Ee=30,De=34;function Oe(e){if(e.state===`inflight`&&e.liveToolName)return Q(`${T(e.liveToolName)}…`,De);let t=e.lastMessagePreview?q(e.lastMessagePreview):``;return t?Q(t,Ee):`No messages yet`}function Q(e,t){let n=Array.from(e.trim());return n.length<=t?n.join(``):`${n.slice(0,t-1).join(``)}…`}function ke(e){return e===`inflight`?`Working`:e===`errored`?`Needs attention`:`Ready`}function $(e){return y(e,{style:`long`,fallback:e})}function Ae({task:e,latestThread:t,gezels:n,gezelNames:r,active:i,onFocus:a}){let o=e.assignee.kind===`user`,s=e.assignee.kind===`gezel`?e.assignee.gezelId:null,c=t?n.find(e=>e.id===t.gezelId):s?n.find(e=>e.id===s):void 0,l=t?$(t.lastActivityAt):null,u=t?ke(t.state):`Active`,d=t?Oe(t):`No chat yet`,f=t?`Latest chat with ${r}: ${t.title}. ${d}. Updated ${l}. ${u}`:`${d}. Assigned to ${r}. ${u}`;return(0,Z.jsxs)(`button`,{type:`button`,className:`chat-pill chat-pill-thread chat-pill-task${t?` chat-pill-${t.state}`:``}${i?` is-active`:``}`,"aria-pressed":i,"aria-label":`Task ${e.ref}: ${e.title}. ${f}`,title:t?`${e.ref} · ${e.title} · latest chat: ${t.title} · ${r} · updated ${l} · ${u}${t.error?`: ${t.error}`:``}`:o?`${e.ref} · ${e.title} — assigned to you · no chat yet`:`${e.ref} · ${e.title} · no chat yet`,onClick:()=>a(e),children:[(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-task-title`,children:[(0,Z.jsx)(D,{area:`tasks`,size:13,className:`chat-pill-task-icon`}),(0,Z.jsxs)(`span`,{className:`chat-pill-task-number`,children:[`#`,e.num]}),(0,Z.jsx)(`span`,{className:`chat-pill-label`,children:e.title})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-context`,children:[c&&(0,Z.jsx)(w,{svg:c.icon??null,poppetje:c.poppetje,iconOverride:c.iconOverride,name:r,size:14}),(0,Z.jsx)(`span`,{className:`chat-pill-participants`,children:r}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`}),(0,Z.jsx)(`span`,{className:`chat-pill-message-preview`,children:d})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-update`,children:[(0,Z.jsx)(`span`,{className:`chat-pill-thread-updated-at`,title:t?b(t.lastActivityAt):void 0,children:l?`Updated ${l}`:e.ref}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-status`,children:[t?(0,Z.jsx)(`span`,{className:`chat-pill-dot`,"aria-hidden":`true`}):(0,Z.jsx)(`span`,{className:`task-status-dot task-status-active`,"aria-hidden":`true`}),u]})]})]})}function je({projectId:e,workingDir:t,onChangeWorkingDir:n}){let[r,i]=(0,B.useState)([]),[a,o]=(0,B.useState)(null),[s,l]=(0,B.useState)(!1),u=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(!s&&r.length>0)return;let t=!1;return(async()=>{try{let n=await c.listProjectWorkspace(e,void 0,!0);if(t)return;let r=n.files.filter(e=>e.isDirectory).map(e=>{let t=e.path.split(`/`).length-1;return{path:e.path,name:e.name,depth:t}});r.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path)),i(r)}catch(e){if(t)return;o(e instanceof Error?e.message:String(e))}})(),()=>{t=!0}},[e,s]),(0,B.useEffect)(()=>{if(!s)return;function e(e){u.current?.contains(e.target)||l(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[s]);let d=(0,B.useMemo)(()=>[{path:``,name:`/`,depth:0},...r],[r]),f=F(t);return(0,Z.jsxs)(`div`,{className:`folder-tree-switcher`,ref:u,children:[(0,Z.jsx)(`span`,{className:`folder-tree-label`,children:`Folder:`}),(0,Z.jsxs)(`button`,{type:`button`,className:`folder-tree-trigger`,onClick:()=>l(e=>!e),title:`Pick a working folder`,"aria-expanded":s,children:[(0,Z.jsx)(`span`,{className:`folder-tree-trigger-value`,children:f}),(0,Z.jsx)(p,{className:`folder-tree-trigger-caret`})]}),s&&(0,Z.jsxs)(`div`,{className:`folder-tree-popup`,role:`listbox`,children:[a&&(0,Z.jsx)(`div`,{className:`terminal-error-banner`,children:a}),d.map(e=>{let r=e.path===t;return(0,Z.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":r,className:`folder-tree-node${r?` active`:``}`,style:{paddingLeft:`${.4+e.depth*.9}rem`},onClick:()=>{n(e.path),l(!1)},title:e.path||`/`,children:(0,Z.jsx)(`span`,{children:e.path===``?`/`:e.name})},e.path||`__root__`)})]})]})}function Me(){return(0,Z.jsxs)(`div`,{className:`project-chat project-chat-placeholder`,"aria-busy":`true`,children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:`Loading this project's chat…`}),(0,Z.jsx)(`div`,{className:`project-chat-placeholder-timeline`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`project-chat-compose-shell`,"aria-hidden":`true`,children:(0,Z.jsxs)(`div`,{className:`project-chat-compose-main`,children:[(0,Z.jsx)(`div`,{className:`project-chat-placeholder-band`}),(0,Z.jsx)(`div`,{className:`project-chat-placeholder-entry`})]})})]})}function Ne(e){let t=M(),[n,r]=(0,B.useState)(null),[a,o]=(0,B.useState)([]),[s,l]=(0,B.useState)([]),u=(0,B.useRef)(void 0);(0,B.useEffect)(()=>{let n=!1,a=async()=>{try{let t=await c.getProjectIndex(e);n||r(t)}catch{}},s=async()=>{try{let r=await c.listProjectCraftbooks(e);if(n)return;o(i(r.items,t).flatMap(e=>{let t=e.manifest;return t.kind&&t.kind!==`craftbook-template`||!t.id?[]:[{id:t.id,command:t.command??t.id,name:t.name,description:t.description,paramSchema:t.paramSchema}]}))}catch{}},d=async()=>{try{let t=await c.listProjectTools(e);n||l(t.tools)}catch{}},f=async()=>{n||s();try{let t=await c.getProjectIndexStatus(e);if(n)return;let r=t.meta?.scannedAt;r&&r!==u.current?(u.current=r,await a()):t.state===`never`&&await c.refreshProjectIndex(e).catch(()=>{})}catch{}};a(),s(),d();let p=window.setInterval(f,3e4);return()=>{n=!0,window.clearInterval(p)}},[e,t]),(0,B.useEffect)(()=>{le(e,{index:n,craftbooks:a,mcpTools:s})},[e,n,a,s]),(0,B.useEffect)(()=>()=>z(e),[e])}var Pe=(0,B.lazy)(()=>x(()=>import(`./TerminalCodeEditor-ChmdzmCz.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]))),Fe=`build, test, git status, … — Enter runs, Shift+Enter for newline, ↑/↓ recalls history`,Ie=[{section:`commands`,label:`Commands`,title:`Everyday terminal commands, and the tools installed on this machine`,icon:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`path`,{d:`M2.5 4 L6 8 L2.5 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,Z.jsx)(`path`,{d:`M8 12 H13.5`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`})]})},{section:`scripts`,label:`Scripts`,title:`Scripts this project already defines — package.json, scripts/, launches`,icon:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`rect`,{x:`3`,y:`2`,width:`10`,height:`12`,rx:`1.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`}),(0,Z.jsx)(`path`,{d:`M5.5 5.5h5M5.5 8h5M5.5 10.5h3`,stroke:`currentColor`,strokeWidth:`1.3`,strokeLinecap:`round`})]})},{section:`tasks`,label:`Tasks`,title:`Craftbooks and workspace skills a gezel can run for you`,icon:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`path`,{d:`M2.5 4.5 L4 6 L6.5 3`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,Z.jsx)(`path`,{d:`M8.5 5 H14`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`}),(0,Z.jsx)(`path`,{d:`M2.5 11 L4 12.5 L6.5 9.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,Z.jsx)(`path`,{d:`M8.5 11.5 H14`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}];function Le({projectId:e,workingDir:t,contextRow:n,toolbarTrailing:r,onSent:i,initialInput:a,onChatEscape:o}){let[s]=(0,B.useState)(()=>a??``),[p,m]=(0,B.useState)(null),[h,g]=(0,B.useState)(null),_=(0,B.useRef)(null),v=(0,B.useRef)([]),y=(0,B.useRef)(-1),b=(0,B.useCallback)(e=>{_.current?.setValue(e),g(null)},[]);Ne(e);let x=(0,B.useCallback)(async n=>{let r=n.trim();if(r!==``){_.current?.setValue(``),m(null),v.current.unshift(r),v.current.length>50&&(v.current.length=50),y.current=-1;try{let n=await c.runTerminalCommand(e,{workingDir:t,input:r});i?.(r,n)}catch(e){m(e instanceof Error?e.message:String(e)),_.current?.focus()}}},[e,t,i]),S=(0,B.useCallback)(()=>{let e=_.current;e&&(x(e.getValue()),e.focus())},[x]),C=(0,B.useCallback)(()=>{if(v.current.length===0)return;let e=Math.min(v.current.length-1,y.current+1);y.current=e,_.current?.setValue(v.current[e])},[]),w=(0,B.useCallback)(()=>{if(y.current<0)return;let e=y.current-1;y.current=e,_.current?.setValue(e<0?``:v.current[e])},[]);return(0,Z.jsxs)(`div`,{className:`terminal-composer`,children:[(0,Z.jsxs)(`div`,{className:`terminal-composer-toolbar`,children:[Ie.map(t=>(0,Z.jsxs)(l,{open:h===t.section,onOpenChange:e=>g(e?t.section:null),children:[(0,Z.jsx)(f,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`terminal-toolbar-btn`,title:t.title,"aria-label":t.title,children:[(0,Z.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:t.icon}),t.label]})}),(0,Z.jsx)(u,{className:`terminal-commands-popover`,side:`top`,align:`start`,onCloseAutoFocus:e=>{e.preventDefault(),_.current?.focus()},children:(0,Z.jsx)(R,{projectId:e,section:t.section,onStageCommand:b})})]},t.section)),r]}),n,(0,Z.jsx)(`div`,{className:`terminal-composer-fire-row`,children:(0,Z.jsx)(`button`,{type:`button`,className:`terminal-fire-btn`,"aria-label":`Fire`,title:`Fire — run this command (Enter)`,onClick:S,children:(0,Z.jsx)(d,{})})}),(0,Z.jsxs)(`div`,{className:`terminal-composer-input-wrap`,children:[(0,Z.jsx)(`span`,{className:`terminal-prompt-sigil`,children:`>`}),(0,Z.jsx)(B.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`terminal-composer-input`,"aria-busy":`true`}),children:(0,Z.jsx)(Pe,{ref:_,projectId:e,initialValue:s,placeholder:Fe,onSubmit:e=>void x(e),onHistoryPrev:C,onHistoryNext:w,onChatEscape:o})})]}),p&&(0,Z.jsx)(`div`,{className:`terminal-error-banner`,children:p})]})}var Re=`project`;function ze(e,t){return P(e?.lastHumanActivityAt,t)}function Be({project:e,compact:t=!1}){let[n,r]=(0,B.useState)([]),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(``);(0,B.useEffect)(()=>{c.listGezels().then(e=>{r(e.gezels),a(!0)}).catch(()=>a(!0))},[e.id,e.voormanGezelId,(e.gezelIds??[]).join(`,`)]),(0,B.useEffect)(()=>{s(``),f(null)},[e.id]);let[l,u]=(0,B.useState)(void 0);(0,B.useEffect)(()=>{u(void 0);let t=!1;return c.listChatSessions({projectId:e.id}).then(e=>{if(t)return;let n=e.sessions.filter(e=>!e.archived&&!e.taskRef)[0];u(n?{gezelId:n.gezelId,...n.lastHumanActivityAt?{lastHumanActivityAt:n.lastHumanActivityAt}:{}}:null)}).catch(()=>{t||u(null)}),()=>{t=!0}},[e.id]);let[d,f]=(0,B.useState)(null),p=(0,B.useCallback)(e=>{f(null),s(e)},[]);(0,B.useEffect)(()=>{if(o)return;let t=se(ae(e.id))?.gezelId;if(t&&n.some(e=>e.id===t)){s(t),f(null);return}if(l===void 0)return;let r=ze(l,Date.now())&&l&&n.some(e=>e.id===l.gezelId)?l.gezelId:``,i=n.find(t=>t.id===e.voormanGezelId)?.id??``,a=(e.gezelIds??[]).map(e=>n.find(t=>t.id===e)?.id).find(Boolean)??``,c=r||i||a||n[0]?.id||``;c&&(s(c),f(r?null:c))},[o,l,n,e.id,e.voormanGezelId,e.gezelIds]),(0,B.useEffect)(()=>{o&&ce(ae(e.id),{gezelId:o})},[e.id,o]);let m=n.find(e=>e.id===o);return!i||n.length>0&&!m?(0,Z.jsx)(Me,{}):n.length===0?(0,Z.jsx)(`p`,{className:`muted project-chat-empty`,children:`No gezellen available to chat with yet. Create one from the Gezellen tab.`}):(0,Z.jsx)(`div`,{className:`project-chat`,children:o&&m&&(0,Z.jsx)(Ve,{project:e,selectedGezel:m,recipientGezels:n,isVoorman:m.id===e.voormanGezelId,startFreshThread:m.id===d,onSelectGezel:p,compact:t})})}function Ve({project:e,selectedGezel:t,recipientGezels:n,isVoorman:i,startFreshThread:o,onSelectGezel:l,compact:u}){let[d,f]=(0,B.useState)(``),[p,m]=(0,B.useState)(``),[h,g]=(0,B.useState)(null),[_,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(0),x=C(),S=a({name:t.name,roleBasedName:t.roleBasedName},x),[w,T]=(0,B.useState)(0),[E,D]=(0,B.useState)([]),[k,A]=(0,B.useState)(`chat`),[M,P]=(0,B.useState)(0),F=(0,B.useCallback)(()=>{P(e=>e+1),A(`chat`)},[]),I=O()&&s(e);(0,B.useEffect)(()=>{!I&&k===`terminal`&&F()},[I,k,F]);let[L,te]=(0,B.useState)(``),[ae,R]=(0,B.useState)(``),[le,z]=(0,B.useState)(``),V=(0,B.useCallback)(e=>{z(``),te(e),R(e)},[]),[H,U]=(0,B.useState)(``);(0,B.useEffect)(()=>{k!==`terminal`&&H!==``&&U(``)},[k,H]);let[W,ue]=(0,B.useState)(0),[G,de]=(0,B.useState)(null),[K,fe]=(0,B.useState)(null),q=(0,B.useRef)(null),J=(0,B.useRef)(null),Y=(0,B.useCallback)((e,n,r)=>{n===t.id?g(r):(q.current=e||null,J.current=r,l(n)),f(e)},[t.id,l]),[pe,me]=(0,B.useState)(null),X=(0,B.useCallback)(e=>{e&&me(t=>({sessionId:e,requestKey:(t?.requestKey??0)+1}))},[]),he=(0,B.useCallback)(async e=>{let t={ref:e.ref,...e.activeStepId?{stepId:e.activeStepId}:{}};try{let{sessions:n}=await c.listTaskSessions(e.projectId,e.num),r=n.find(e=>!e.archived);if(r){Y(r.id,r.gezelId,t),X(r.id);return}}catch{}e.assignee.kind===`gezel`&&e.assignee.gezelId?Y(``,e.assignee.gezelId,t):g(t)},[Y,X]),ge=(0,B.useCallback)(e=>{b(e=>e+1),(e.status===`complete`||e.status===`canceled`)&&g(t=>t?.ref===e.ref?null:t)},[]);(0,B.useEffect)(()=>{let n=q.current;q.current=null,f(n??se(re(e.id,t.id))?.sessionId??``),g(J.current),J.current=null},[t.id,e.id]),(0,B.useEffect)(()=>{ce(re(e.id,t.id),{sessionId:d})},[e.id,t.id,d]);let _e=(0,B.useMemo)(()=>ie({role:i?`voorman`:`other`,gezelName:S,gezelGender:t.gender,projectName:e.name,fixedFunctionTool:t.fixedFunction?.tool}),[i,S,t.gender,e.name,t.fixedFunction?.tool]),ve=r(t.gender),ye=I?(0,Z.jsxs)(`div`,{className:`compose-mode-tabs`,role:`tablist`,"aria-label":`Compose surface`,children:[(0,Z.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":k===`chat`,"aria-label":`AI chat`,className:`compose-mode-tab`,onClick:F,title:`AI chat (@-mention to talk to a gezel)`,children:[(0,Z.jsx)(`span`,{className:`compose-mode-tab-glyph`,"aria-hidden":`true`,children:`@`}),`Chat`]}),(0,Z.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":k===`terminal`,className:`compose-mode-tab`,onClick:()=>A(`terminal`),title:`Terminal (run shell commands in this project's workspace)`,children:[(0,Z.jsx)(`span`,{className:`compose-mode-tab-glyph`,"aria-hidden":`true`,children:`>`}),`Terminal`]})]}):null;return(0,Z.jsx)(oe,{projectId:e.id,skillsProjectId:e.id,compact:u,chatKey:`${e.id}:timeline`,onTaskChanged:ge,banner:({onTaskReference:t})=>(0,Z.jsx)(xe,{projectId:e.id,gezels:n,activeSessionId:k===`chat`&&d||void 0,activeTaskRef:k===`chat`?h?.ref??null:null,activeTerminalThreadId:k===`terminal`?le:null,refreshKey:y,terminalRefreshKey:W,onFocusThread:e=>{Y(e.sessionId,e.gezelId,e.taskRef?{ref:e.taskRef}:null),X(e.sessionId)},onFocusTask:e=>{t(e.ref,{focus:!0}),he(e)},onFocusTerminal:I?t=>{V(t.workingDir),z(t.id),A(`terminal`),de(e=>({threadId:t.id,requestKey:(e?.requestKey??0)+1})),c.getTerminalThread(e.id,t.id).then(e=>{let t=[...e.messages].reverse().find(e=>e.cwd!==void 0)?.cwd;t!==void 0&&R(t)}).catch(()=>{})}:void 0,onNewTask:()=>v(!0)}),children:({onToolActivity:r,onArtifactReference:a,onArtifactSeen:s,onWorkspaceReference:c,onWorkspaceSeen:u,recentReferences:g,onOpenReference:y,onTaskReference:x})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ne,{projectId:e.id,activeSessionId:d||void 0,onFocusSession:(e,t)=>Y(e,t,null),onToolActivity:r,onArtifactReference:a,onArtifactSeen:s,onWorkspaceReference:c,onWorkspaceSeen:u,onOpenReference:y,onTaskReference:x,onTerminalWorkingDirChanged:(e,t)=>{R(t)},terminalRefreshKey:W,...K?{terminalSubmission:K}:{},...G?{terminalFocusRequest:G}:{},...pe?{sessionFocusRequest:pe}:{},emptyPlaceholder:i?`Talk to ${S} about running "${e.name}" — planning tasks, delegating, or checking progress.`:`Chat with ${S} about what ${ve.subject} ${ve.presentBe} working on in "${e.name}".`}),(0,Z.jsx)(`div`,{className:`project-chat-compose-shell`,children:(0,Z.jsx)(`div`,{className:`project-chat-compose-main${k===`terminal`?` project-chat-compose-main-terminal`:``}`,children:k===`chat`?(0,Z.jsx)(N,{gezelId:t.id,gezelName:t.name,gezelRoleBasedName:t.roleBasedName,gezelRole:t.role,gezelIcon:t.icon??null,gezelPoppetje:t.poppetje,gezelIconOverride:t.iconOverride,recipientGezels:n,onPrimaryRecipientChange:l,focusRequestKey:M,projectId:e.id,sessionId:d||void 0,...h?{taskRef:h.ref}:{},...h?.stepId?{stepId:h.stepId}:{},onSessionCreated:e=>{f(e),T(e=>e+1)},onToolActivity:r,recentReferences:g,onOpenReference:y,placeholder:_e,draftScope:Re,onPivotToMention:e=>{e!==t.id&&(D(e=>e.includes(t.id)?e:[...e,t.id]),l(e))},passiveCcGezelIds:E,onPassiveCcConsumed:()=>D([]),onTerminalEscape:I?e=>{U(e),A(`terminal`)}:void 0,addressLineTrailing:ye,draftId:p||void 0,onDraftIdChange:e=>m(e??``),belowAddressLine:(0,Z.jsx)(ee,{gezelId:t.id,projectId:e.id,sessionId:d||void 0,...h?{taskRef:h.ref}:{},...h?.stepId?{stepId:h.stepId}:{},onSessionIdChange:e=>f(e??``),onFreshThread:()=>P(e=>e+1),refreshKey:w,activeDraftId:p||void 0,onDraftSelect:e=>m(e??``),draftScope:Re,autoPickNewest:!o||!!h})}):(0,Z.jsx)(Le,{projectId:e.id,workingDir:L,contextRow:(0,Z.jsx)(je,{projectId:e.id,workingDir:ae,onChangeWorkingDir:V}),toolbarTrailing:ye,initialInput:H,onSent:(e,t)=>{z(t.threadId),fe({runId:t.runId,threadId:t.threadId,input:e}),ue(e=>e+1)},onChatEscape:F},`terminal:${e.id}`)})}),(0,Z.jsx)(j,{open:_,defaultProjectId:e.id,projects:[e],gezels:n,projectLocked:!0,onClose:()=>v(!1),onCreated:()=>{v(!1),b(e=>e+1)}})]})})}export{Be as ProjectChat};
@@ -1 +0,0 @@
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-C0I7spBl.js";import{n as i,t as a}from"./relative-time-B2kBaekd.js";import{t as o}from"./ConfirmDialog-Dt1ed4Fh.js";import{r as s}from"./new-project-meta-ZmDPGYzC.js";import{Z as c}from"./index-DDu8nyO6.js";var l=e(t(),1),u=n();function d(e,t){return`connector-${e}-${t}`.replace(/[^a-zA-Z0-9_-]/g,`-`)}function f(e){return e&&/^https:\/\//i.test(e)?e:void 0}function p({required:e}){return e?(0,u.jsx)(`span`,{className:`gz-connector-field-requirement`,"aria-hidden":`true`,children:`Required`}):null}function m({id:e,description:t,helpUrl:n,helpLabel:r}){let i=f(n);return!t&&!i?null:(0,u.jsxs)(`span`,{id:e,className:`gz-connector-field-help`,children:[t,t&&i?` `:``,i&&(0,u.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,children:r??`Learn more`})]})}function h({connectorId:e,fieldKey:t,property:n,required:r,value:i,onChange:a}){let o=d(e,t),s=`${o}-label`,c=`${o}-help`,l=n.title??t,f=n.description?c:void 0;return(0,u.jsxs)(`div`,{className:`gz-connector-field`,children:[(0,u.jsxs)(`label`,{id:s,className:`gz-connector-field-label`,htmlFor:o,children:[(0,u.jsx)(`span`,{children:l}),(0,u.jsx)(p,{required:r})]}),(0,u.jsxs)(`span`,{className:`gz-connector-field-control`,children:[n.type===`boolean`?(0,u.jsx)(`input`,{id:o,type:`checkbox`,"aria-label":l,checked:i===!0,onChange:e=>a(e.target.checked),"aria-describedby":f}):(0,u.jsx)(`input`,{id:o,type:n.type===`integer`||n.type===`number`?`number`:`text`,value:typeof i==`string`?i:``,onChange:e=>a(e.target.value),placeholder:n.type===`array`?`comma,separated`:``,min:n.minimum,max:n.maximum,step:n.type===`integer`?1:void 0,required:r,"aria-label":l,"aria-describedby":f}),(0,u.jsx)(m,{id:c,description:n.description})]})]})}function g({connectorId:e,fieldKey:t,label:n,value:r,onChange:i,required:a=!1,secret:o=!1,description:s,helpUrl:c,helpLabel:l,placeholder:h}){let g=d(e,t),_=`${g}-help`,v=!!(s||f(c));return(0,u.jsxs)(`div`,{className:`gz-connector-field`,children:[(0,u.jsxs)(`label`,{className:`gz-connector-field-label`,htmlFor:g,children:[(0,u.jsx)(`span`,{children:n}),(0,u.jsx)(p,{required:a})]}),(0,u.jsxs)(`span`,{className:`gz-connector-field-control`,children:[(0,u.jsx)(`input`,{id:g,type:o?`password`:`text`,value:r,onChange:e=>i(e.target.value),required:a,autoComplete:o?`off`:void 0,placeholder:h,"aria-label":n,"aria-describedby":v?_:void 0}),(0,u.jsx)(m,{id:_,description:s,helpUrl:c,helpLabel:l})]})]})}function _({connectorId:e,fieldKey:t,label:n,checked:r,onChange:i}){let a=d(e,t);return(0,u.jsxs)(`div`,{className:`gz-connector-field`,children:[(0,u.jsx)(`label`,{className:`gz-connector-field-label`,htmlFor:a,children:(0,u.jsx)(`span`,{children:n})}),(0,u.jsx)(`span`,{className:`gz-connector-field-control gz-connector-checkbox-control`,children:(0,u.jsx)(`input`,{id:a,type:`checkbox`,"aria-label":n,checked:r,onChange:e=>i(e.target.checked)})})]})}function v({title:e,children:t}){return(0,u.jsxs)(`section`,{className:`gz-connector-field-group`,"aria-label":e,children:[(0,u.jsx)(`div`,{className:`gz-connector-field-group-heading`,children:e}),t]})}function y(e){let t={};for(let[n,r]of Object.entries(e.configSchema?.properties??{}))r.default!==void 0&&(t[n]=r.type===`boolean`?r.default===!0:String(r.default));return t}function b({connector:e,config:t,onConfigChange:n,displayName:r,onDisplayNameChange:i,credential:a,onCredentialChange:o,imapHost:s,onImapHostChange:c,imapPort:l,onImapPortChange:d,imapSecure:p,onImapSecureChange:m}){let y=e.secretShape?.kind,b=new Set(e.configSchema?.required??[]),x=Object.entries(e.configSchema?.properties??{}).filter(([,e])=>e.const===void 0),S=([e,t])=>b.has(e)||t[`x-gezel-priority`]===`primary`,C=x.filter(S),w=x.filter(e=>!S(e)),T=e.secretShape?.required===!0||e.secretShape?.[`x-gezel-priority`]===`primary`,E=([r,i])=>(0,u.jsx)(h,{connectorId:e.id,fieldKey:r,property:i,required:b.has(r),value:t[r],onChange:e=>n(r,e)},r),D=y!==`oauth2`&&y!==`imap`&&(0,u.jsx)(g,{connectorId:e.id,fieldKey:`credential`,label:e.secretShape?.label??`API key / token`,value:a,onChange:o,required:e.secretShape?.required===!0,secret:!0,description:e.secretShape?.description,helpUrl:e.secretShape?.helpUrl,helpLabel:e.secretShape?.helpLabel},`credential`),O=y===`imap`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(g,{connectorId:e.id,fieldKey:`imap-host`,label:`IMAP host`,value:s,onChange:c,required:!0,placeholder:`imap.example.com`}),(0,u.jsx)(g,{connectorId:e.id,fieldKey:`credential`,label:`Password / app password`,value:a,onChange:o,required:!0,secret:!0,description:e.secretShape?.description,helpUrl:e.secretShape?.helpUrl,helpLabel:e.secretShape?.helpLabel})]}),k=C.length>0||T||y===`imap`||y===`oauth2`;return(0,u.jsxs)(u.Fragment,{children:[e.setupInstructions&&(0,u.jsxs)(`aside`,{className:`gz-connector-setup-instructions`,children:[(0,u.jsx)(`strong`,{children:e.setupInstructions.title}),e.setupInstructions.description&&(0,u.jsx)(`p`,{children:e.setupInstructions.description}),e.setupInstructions.steps&&e.setupInstructions.steps.length>0&&(0,u.jsx)(`ol`,{children:e.setupInstructions.steps.map(e=>(0,u.jsx)(`li`,{children:e},e))}),f(e.setupInstructions.url)&&(0,u.jsx)(`a`,{href:e.setupInstructions.url,target:`_blank`,rel:`noreferrer`,children:e.setupInstructions.urlLabel??`Open setup instructions`})]}),(0,u.jsxs)(`div`,{className:`gz-connector-config-fields`,children:[k&&(0,u.jsxs)(v,{title:`Connection details`,children:[C.map(E),y===`oauth2`?(0,u.jsx)(`p`,{className:`muted small gz-connector-oauth-note`,children:`You'll authorize this connector in your browser after you click Connect.`}):y===`imap`?O:T?D:null]}),(0,u.jsxs)(v,{title:`Additional settings`,children:[w.map(E),y===`imap`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(g,{connectorId:e.id,fieldKey:`imap-port`,label:`Port`,value:l,onChange:d,placeholder:`993`}),(0,u.jsx)(_,{connectorId:e.id,fieldKey:`imap-tls`,label:`Use TLS`,checked:p,onChange:m})]}),!T&&D,(0,u.jsx)(g,{connectorId:e.id,fieldKey:`display-name`,label:`Display name`,value:r,onChange:i})]})]})]})}var x=/^GEZEL_[A-Z0-9_]{1,120}$/,S=8;function C(e,t){if(!t||typeof t!=`object`)return null;let n=t;if(n.kind!==`oauth2`)return null;let r=typeof n.clientIdEnv==`string`?n.clientIdEnv:``;if(!x.test(r))return null;let i=typeof n.clientSecretEnv==`string`&&n.clientSecretEnv.length>0,a=n.clientSetup&&typeof n.clientSetup==`object`?n.clientSetup:{},o=typeof a.providerLabel==`string`&&a.providerLabel.trim()?a.providerLabel.trim():e,s=typeof a.docsUrl==`string`&&/^https:\/\//.test(a.docsUrl)?a.docsUrl:void 0,c=typeof a.redirectPort==`number`&&Number.isInteger(a.redirectPort)&&a.redirectPort>=1024&&a.redirectPort<=65535?a.redirectPort:void 0,l=typeof a.appTypeNote==`string`&&a.appTypeNote.trim()?a.appTypeNote.trim():void 0,u=typeof a.redirectNote==`string`&&a.redirectNote.trim()?a.redirectNote.trim():void 0,d=Array.isArray(a.steps)?a.steps.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,S):[];return{clientKey:r,hasSecretField:i,secretRequired:i&&a.secretRequired===!0,providerLabel:o,...s?{docsUrl:s}:{},...l?{appTypeNote:l}:{},...c===void 0?{}:{redirectPort:c},...u?{redirectNote:u}:{},...d.length>0?{steps:d}:{}}}function w(e){return`http://127.0.0.1:${e}/callback`}function T(e){let t=e instanceof Error?e.message:typeof e==`string`?e:``;return/oauth is not configured/i.test(t)}function E({requirement:e,registered:t,forceOpenNonce:n,busy:r,onSave:i}){let[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(``),[d,f]=(0,l.useState)(``),[p,m]=(0,l.useState)(``),[h,g]=(0,l.useState)(!1),_=(0,l.useRef)(t);_.current=t;let v=()=>{c(_.current?.clientId??``),f(``),m(``),o(!0)};(0,l.useEffect)(()=>{n&&v()},[n]);let y=e.redirectPort===void 0?null:w(e.redirectPort),b=async()=>{if(y)try{await navigator.clipboard.writeText(y),g(!0),setTimeout(()=>g(!1),1500)}catch{}},x=async()=>{let n=s.trim(),r=d.trim();if(!n){m(`Client ID is required.`);return}if(e.secretRequired&&!r&&!t?.hasSecret){m(`${e.providerLabel} requires a client secret.`);return}m(``);try{await i({clientId:n,...r?{clientSecret:r}:{}})}catch{return}f(``),o(!1)};return a?(0,u.jsxs)(`div`,{className:`gz-oauth-app`,"aria-label":`${e.providerLabel} OAuth app setup`,children:[(0,u.jsxs)(`strong`,{className:`gz-oauth-app-heading`,children:[`Your `,e.providerLabel,` app`]}),(0,u.jsx)(`p`,{className:`muted small`,children:e.appTypeNote??`Create an OAuth app in your ${e.providerLabel} developer settings and paste its client ID here. It is stored on this machine only.`}),e.steps&&(0,u.jsx)(`ol`,{className:`gz-oauth-app-steps`,children:e.steps.map(e=>(0,u.jsx)(`li`,{children:e},e))}),e.docsUrl&&(0,u.jsxs)(`a`,{className:`gz-oauth-app-docs`,href:e.docsUrl,target:`_blank`,rel:`noreferrer`,children:[`Open the `,e.providerLabel,` developer console`]}),(0,u.jsxs)(`div`,{className:`gz-oauth-app-redirect`,children:[(0,u.jsx)(`span`,{children:`Redirect URI to register`}),y?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`span`,{className:`gz-oauth-app-redirect-row`,children:[(0,u.jsx)(`code`,{children:y}),(0,u.jsx)(`button`,{type:`button`,onClick:()=>void b(),title:`Copy the redirect URI`,children:h?`Copied`:`Copy`})]}),e.redirectNote&&(0,u.jsx)(`span`,{className:`muted small`,children:e.redirectNote})]}):(0,u.jsx)(`span`,{className:`muted small`,children:e.redirectNote??`${e.providerLabel} accepts any 127.0.0.1 port, so there is no fixed URI to register — Gezel picks a free port when you connect.`})]}),(0,u.jsxs)(`div`,{className:`gz-oauth-app-fields`,children:[(0,u.jsxs)(`label`,{children:[`Client ID`,(0,u.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),autoComplete:`off`,spellCheck:!1})]}),e.hasSecretField&&(0,u.jsxs)(`label`,{children:[`Client secret`,` `,!e.secretRequired&&(0,u.jsx)(`span`,{className:`muted`,children:`(optional — PKCE public clients don't need one)`}),(0,u.jsx)(`input`,{type:`password`,value:d,onChange:e=>f(e.target.value),autoComplete:`off`,placeholder:t?.hasSecret?`leave blank to keep the saved secret`:``})]})]}),p&&(0,u.jsx)(`p`,{className:`error small`,children:p}),(0,u.jsxs)(`div`,{className:`gz-oauth-app-actions`,children:[(0,u.jsx)(`button`,{type:`button`,onClick:()=>o(!1),disabled:r,children:`Cancel`}),(0,u.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void x(),disabled:r,children:r?`Working…`:`Save & connect`})]})]}):(0,u.jsxs)(`div`,{className:`gz-oauth-app gz-oauth-app-summary`,children:[(0,u.jsx)(`div`,{className:`gz-oauth-app-summary-text`,children:t?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`span`,{children:[`Connects through your `,e.providerLabel,` app`]}),(0,u.jsx)(`code`,{title:t.clientId,children:t.clientId}),t.hasSecret&&(0,u.jsx)(`span`,{children:`· secret saved`})]}):(0,u.jsxs)(`span`,{children:[`Gezel ships no built-in `,e.providerLabel,` client — connecting uses an app you register once on this machine.`]})}),(0,u.jsx)(`button`,{type:`button`,onClick:v,disabled:r,children:t?`Edit`:`Use your own ${e.providerLabel} app`})]})}async function D(e,t,n,i,a){let o=window.__GEZEL__;if(!o?.mailOAuthListen||!o.mailOAuthAwait)throw Error(`Connecting this source needs the Gezel desktop app.`);let{requestId:s,redirectUri:c}=await o.mailOAuthListen(a?.redirectPort===void 0?void 0:{port:a.redirectPort}),{authUrl:l,state:u}=await r.startConnectorOAuth(e,{type:t,redirectUri:c,config:n,...i?{displayName:i}:{}}),d=await o.mailOAuthAwait(s,l);if(`error`in d)throw Error(d.error);await r.completeConnectorOAuth(e,{state:d.state||u,code:d.code})}function O(e){let t=`${e.id} ${(e.tags??[]).join(` `)}`.toLowerCase();return t.includes(`wiki`)?`sheet`:t.includes(`calendar`)?`calendar`:/(mail|gmail|imap|email)/.test(t)?`envelope`:/(github|git)/.test(t)?`branch`:/(issue|linear)/.test(t)?`bubbles`:/(airtable|record|data)/.test(t)?`chart`:`dots`}function k(e){let t=e.secretShape?.kind;return t===`oauth2`?`OAuth`:t===`imap`?`Mail login`:e.secretShape?.required?e.secretShape?.label??`API token`:`Optional token`}function ee({tables:e}){return(0,u.jsx)(`ul`,{className:`gz-connector-tables`,children:e.map(e=>{let t=e.earliestPartition&&e.latestPartition?e.earliestPartition===e.latestPartition?e.earliestPartition:`${e.earliestPartition} → ${e.latestPartition}`:null;return(0,u.jsxs)(`li`,{className:`small muted`,children:[(0,u.jsx)(`strong`,{children:e.table}),` · `,e.rows.toLocaleString(),` `,e.rows===1?`row`:`rows`,t?` · ${t}`:``,e.retentionDays?` · keeps ${e.retentionDays} days`:``,e.schemaInferred?` · schema inferred`:``,e.pendingParts>0?` · tidying up tonight`:``]},e.table)})})}function A(e){return e.completeness===`window`?`Recent window`:`Full mirror`}function j({project:e,onProjectChange:t}){let[n,d]=(0,l.useState)(null),[f,p]=(0,l.useState)(null),[m,h]=(0,l.useState)(``),[g,_]=(0,l.useState)(``),[v,x]=(0,l.useState)(null),[S,w]=(0,l.useState)([]),[j,te]=(0,l.useState)(!1),[ne,re]=(0,l.useState)(!1),[M,N]=(0,l.useState)([]),[P,F]=(0,l.useState)(null),[I,L]=(0,l.useState)({}),[R,z]=(0,l.useState)(``),[B,V]=(0,l.useState)(``),[H,U]=(0,l.useState)(``),[W,G]=(0,l.useState)(``),[K,q]=(0,l.useState)(!0),[ie,ae]=(0,l.useState)({}),[oe,J]=(0,l.useState)(0),Y=(0,l.useCallback)(async()=>{try{let[t,n]=await Promise.all([r.listConnectors(e.id),r.listConnectorActions(e.id)]);d(t),w(n.pending)}catch(e){h(e instanceof Error?e.message:String(e))}},[e.id]),se=(0,l.useCallback)(async t=>{p(t),h(``),_(``);try{let n=await r.commitConnectorAction(e.id,t);_(n.status===`queued-night-shift`?`Held for daytime approval (night shift).`:`Action committed.`),await Y()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null)}},[e.id,Y]),ce=(0,l.useCallback)(async t=>{p(t);try{await r.discardConnectorAction(e.id,t),await Y()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null)}},[e.id,Y]);(0,l.useEffect)(()=>{Y()},[Y]);let X=(0,l.useCallback)(()=>{te(!1),F(null),L({}),z(``),V(``),U(``),G(``),q(!0),J(0)},[]),Z=(0,l.useCallback)(async()=>{let e=await r.listOAuthClients();ae(Object.fromEntries((e.clients??[]).map(e=>[e.key,{clientId:e.clientId,hasSecret:e.hasSecret}])))},[]),le=(0,l.useCallback)(async()=>{te(!0),re(!0),N([]),F(null),h(``),_(``),Z().catch(()=>{});try{let e=await r.listConnectorTypes();N(e.items.map(e=>({...e.manifest,...e.iconSvg?{iconSvg:e.iconSvg}:{},...e.logoUrl?{logoUrl:e.logoUrl}:{}})))}catch(e){h(e instanceof Error?e.message:String(e))}finally{re(!1)}},[Z]),ue=(0,l.useCallback)(async t=>{p(t),h(``),_(``);try{let n=(await r.syncConnector(e.id,t)).result;_(n.error?`Sync error: ${n.error}`:`Synced ${(n.written??0)+(n.quarantined??0)} new record(s).`),await Y()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null)}},[e.id,Y]),de=(0,l.useCallback)(async t=>{p(t);try{await r.unbindConnector(e.id,t),await Y()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null),x(null)}},[e.id,Y]),fe=(0,l.useCallback)(()=>{let e=P?.configSchema?.properties??{},t={};for(let[n,r]of Object.entries(e))if(r.const!==void 0)t[n]=r.const;else if(r.type===`array`){let e=typeof I[n]==`string`?I[n].trim():``;e&&(t[n]=e.split(`,`).map(e=>e.trim()).filter(Boolean))}else if(r.type===`boolean`)typeof I[n]==`boolean`&&(t[n]=I[n]);else if(r.type===`integer`||r.type===`number`){let e=typeof I[n]==`string`?I[n].trim():``;e&&(t[n]=Number(e))}else{let e=typeof I[n]==`string`?I[n].trim():``;e&&(t[n]=e)}return t},[P,I]),Q=(0,l.useMemo)(()=>P?.secretShape?.kind===`oauth2`?C(P.name,P.secretShape):null,[P]),$=(0,l.useCallback)(async()=>{if(!P)return;h(``),_(``);let n=fe(),i=P.secretShape?.kind,a=(P.configSchema?.required??[]).find(e=>{let t=n[e];return t===void 0||t===``||Array.isArray(t)&&t.length===0});if(a){let e=P.configSchema?.properties?.[a]?.title??a;h(`${e} is required.`);return}if(i!==`oauth2`&&i!==`imap`&&P.secretShape?.required&&!B.trim()){h(`${P.secretShape.label??`API key / token`} is required.`);return}p(`add`);try{if(i===`oauth2`)await D(e.id,P.id,n,R.trim()||void 0,Q?.redirectPort===void 0?void 0:{redirectPort:Q.redirectPort});else{let t;i===`imap`?t={host:H.trim(),...W.trim()?{port:Number(W.trim())}:{},secure:K,user:String(n.address??``),pass:B}:B.trim()&&(t=B.trim()),await r.bindConnector(e.id,{type:P.id,...R.trim()?{displayName:R.trim()}:{},config:n,...t===void 0?{}:{credential:t}})}_(`Connector added.`),X(),await Y();try{let n=await r.getProject(e.id);n&&t?.(n)}catch{}}catch(e){let t=e instanceof Error?e.message:String(e);T(t)&&J(e=>e+1),h(t)}finally{p(null)}},[P,e.id,fe,R,B,H,W,K,X,Y,t,Q]),pe=(0,l.useCallback)(async e=>{if(Q){h(``),p(`oauth-app`);try{await r.putOAuthClient(Q.clientKey,e),await Z().catch(()=>{ae(t=>({...t,[Q.clientKey]:{clientId:e.clientId,hasSecret:!!e.clientSecret||(t[Q.clientKey]?.hasSecret??!1)}}))}),J(0)}catch(e){throw h(e instanceof Error?e.message:String(e)),e}finally{p(null)}await $()}},[Q,Z,$]),me=n?.bindings??[],he=P?.secretShape?.kind,ge=e=>{e.id!==P?.id&&(F(e),L(y(e)),z(``),V(``),U(``),G(``),q(!0),h(``),J(0))};return(0,u.jsxs)(`div`,{className:`settings-section`,children:[(0,u.jsxs)(`div`,{className:`gz-mail-header`,children:[(0,u.jsx)(`h3`,{children:`Connections`}),!j&&(0,u.jsx)(`button`,{type:`button`,onClick:()=>void le(),children:`Add connection`})]}),me.length===0&&!j?(0,u.jsx)(`p`,{className:`muted`,children:`No connectors yet. Add one to mirror an external source (email, issues, a data source) into this project as searchable files.`}):(0,u.jsx)(`ul`,{className:`settings-list`,children:me.map(e=>(0,u.jsxs)(`li`,{children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`strong`,{children:e.displayName||e.type}),(0,u.jsxs)(`span`,{className:`muted small`,children:[` · `,e.type]}),(0,u.jsx)(`div`,{className:`small`,children:e.lastError?(0,u.jsxs)(`span`,{className:`error`,children:[`Error: `,e.lastError]}):e.lastSyncedAt?(0,u.jsxs)(`span`,{className:`muted`,title:a(e.lastSyncedAt),children:[`Last synced `,i(e.lastSyncedAt)]}):(0,u.jsx)(`span`,{className:`muted`,children:`Not synced yet`})}),e.tables&&e.tables.length>0?(0,u.jsx)(ee,{tables:e.tables}):null]}),(0,u.jsxs)(`div`,{className:`gz-mail-link-actions`,children:[(0,u.jsx)(`button`,{type:`button`,onClick:()=>void ue(e.id),disabled:f===e.id,children:f===e.id?`Working…`:`Sync now`}),(0,u.jsx)(`button`,{type:`button`,className:`danger`,onClick:()=>x(e.id),disabled:f===e.id,children:`Remove`})]})]},e.id))}),S.length>0&&(0,u.jsxs)(`div`,{className:`settings-subsection`,children:[(0,u.jsx)(`h4`,{children:`Pending actions`}),(0,u.jsx)(`p`,{className:`muted small`,children:`Drafted by a gezel — review, then commit (the live write). You commit; the gezel can't.`}),(0,u.jsx)(`ul`,{className:`settings-list`,children:S.map(e=>(0,u.jsxs)(`li`,{children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`strong`,{children:e.action}),(0,u.jsxs)(`span`,{className:`muted small`,children:[` · `,e.connectorType]}),e.status===`queued`&&(0,u.jsx)(`span`,{className:`badge`,children:` held for daytime`})]}),(0,u.jsxs)(`div`,{className:`gz-mail-link-actions`,children:[(0,u.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void se(e.draftId),disabled:f===e.draftId,children:f===e.draftId?`Working…`:`Commit`}),(0,u.jsx)(`button`,{type:`button`,onClick:()=>void ce(e.draftId),disabled:f===e.draftId,children:`Discard`})]})]},e.draftId))})]}),j&&(0,u.jsxs)(`div`,{className:`gz-connector-picker`,children:[(0,u.jsxs)(`div`,{className:`gz-connector-picker-heading`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`strong`,{children:`Choose a connector`}),(0,u.jsx)(`p`,{className:`muted small`,children:`Pick a source to mirror into this project's searchable files.`})]}),(0,u.jsx)(`span`,{className:`gz-connector-picker-count`,children:ne?`Loading…`:`${M.length} available`})]}),ne?(0,u.jsx)(`div`,{className:`gz-connector-picker-empty muted small`,children:`Gathering connectors…`}):M.length===0?(0,u.jsx)(`div`,{className:`gz-connector-picker-empty muted small`,children:`No connector types are available.`}):(0,u.jsx)(`div`,{className:`gz-connector-grid`,role:`radiogroup`,"aria-label":`Connector type`,children:M.map((e,t)=>(0,u.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":P?.id===e.id,"aria-label":e.name,className:`gz-npd-card gz-connector-card${P?.id===e.id?` active`:``}`,onClick:()=>ge(e),style:{"--card-i":Math.min(t,11)},children:[(0,u.jsx)(`span`,{className:`gz-npd-card-mark`,children:(0,u.jsx)(c,{iconSvg:e.iconSvg,logoUrl:e.logoUrl,svgClassName:`gz-npd-card-mark-svg`,fallback:(0,u.jsx)(s,{glyph:O(e),size:19})})}),(0,u.jsx)(`span`,{className:`gz-npd-card-name`,children:e.name}),(0,u.jsx)(`span`,{className:`gz-npd-card-description`,children:e.description}),(0,u.jsxs)(`span`,{className:`gz-connector-card-meta`,"aria-hidden":`true`,children:[(0,u.jsx)(`span`,{children:k(e)}),(0,u.jsx)(`span`,{children:A(e)})]})]},e.id))}),P&&(0,u.jsxs)(`div`,{className:`gz-mail-link-form gz-connector-config`,"aria-label":`${P.name} setup`,children:[(0,u.jsxs)(`div`,{className:`gz-connector-config-heading`,children:[(0,u.jsx)(`span`,{className:`gz-connector-config-mark`,children:(0,u.jsx)(c,{iconSvg:P.iconSvg,logoUrl:P.logoUrl,svgClassName:`gz-npd-card-mark-svg`,fallback:(0,u.jsx)(s,{glyph:O(P),size:19})})}),(0,u.jsxs)(`div`,{children:[(0,u.jsxs)(`strong`,{children:[`Set up `,P.name]}),(0,u.jsxs)(`div`,{className:`small muted`,children:[k(P),` · `,A(P)]})]})]}),(0,u.jsx)(b,{connector:P,config:I,onConfigChange:(e,t)=>L(n=>({...n,[e]:t})),displayName:R,onDisplayNameChange:z,credential:B,onCredentialChange:V,imapHost:H,onImapHostChange:U,imapPort:W,onImapPortChange:G,imapSecure:K,onImapSecureChange:q}),Q&&(0,u.jsx)(E,{requirement:Q,registered:ie[Q.clientKey]??null,forceOpenNonce:oe,busy:f===`oauth-app`||f===`add`,onSave:pe},P.id)]}),(0,u.jsxs)(`div`,{className:`gz-mail-link-actions gz-connector-picker-actions`,children:[(0,u.jsx)(`button`,{type:`button`,onClick:X,disabled:f===`add`,children:`Cancel`}),P&&(0,u.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void $(),disabled:f===`add`,children:f===`add`?`Working…`:he===`oauth2`?`Connect`:`Add`})]})]}),m&&(0,u.jsx)(`p`,{className:`error small`,children:m}),g&&(0,u.jsx)(`p`,{className:`muted small`,children:g}),(0,u.jsx)(o,{open:v!==null,title:`Remove connector?`,message:`This removes the binding and its stored credential. Synced files stay on disk.`,confirmLabel:`Remove`,danger:!0,onConfirm:()=>{v&&de(v)},onCancel:()=>x(null)})]})}export{j as ProjectConnectionsTab};
@@ -1,7 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProjectChat-BiJRweob.js","assets/rolldown-runtime-aKtaBQYM.js","assets/jsx-runtime-CEpd2cAX.js","assets/dist-DOqbRmFj.js","assets/api-C0I7spBl.js","assets/dist-CJqyWK6E.js","assets/primitives-CWrGZpPI.js","assets/react-dom-OL4w_gzs.js","assets/Tabs-jE0Z5Tzd.js","assets/DropdownMenu-DlrvEmoV.js","assets/dist-Q59u9cBl.js","assets/relative-time-B2kBaekd.js","assets/preload-helper-Czpn1I53.js","assets/index-DDu8nyO6.js","assets/document-companion-aDThLOwl.js","assets/FileTypeIcon-Cwzl1GkZ.js","assets/model-context-DBqdK0PS.js","assets/model-memory-copy-Ds9w1uJE.js","assets/StorageCleanupDialog-3kv9-2mT.js","assets/poppetje-CfaAvFkE.js","assets/safe-svg-image-NbuPaBIv.js","assets/ConfirmDialog-Dt1ed4Fh.js","assets/model-inventory-ykSm_IT5.js","assets/doc-C2Ph2FWI.js","assets/chunk-O7JILDEF-CqcO1qaI.js","assets/chunk-BAOV476U-CEOFYt8X.js","assets/chunk-4VOD55SX-BFSSw0c8.js","assets/chunk-GAZKTT4R-w1SNypWQ.js","assets/chunk-UBFT2CDQ-FexGDigd.js","assets/chunk-XRW6P7IF-BeQQgMVK.js","assets/chunk-7ZAAICW4-BsCpYJH6.js","assets/markdown-ryKA_OmY.js","assets/schemas-BvLZUsGm.js","assets/chunk-6ECMNUIP-BvCy0HUI.js","assets/inlineIconMarker-BQI2HLeD.js","assets/chunk-TT6ENR6T-BOA-qiwP.js","assets/chunk-DQRELU4S--U9FIVtY.js","assets/new-project-meta-ZmDPGYzC.js","assets/chunk-AE3IUKMM-mZjzzO8Z.js","assets/index-DEDUSiCx.css","assets/NewTaskDialog-CIXVunZn.js","assets/GezelJsonEditor-DXXt165-.js","assets/dist-APSIK7H3.js","assets/icons-DWaUNQbT.js","assets/CraftbookToolsetSetup-EuFOiUzR.js","assets/ToolsetConfigForm-gUVMTPR_.js","assets/useShowWorkInProgressFeatures-BtpredG7.js","assets/ChatTimelineView-Cg_kLK_U.js","assets/styles-BvkZd-EV.js","assets/chunk-KGWT454C-v5-l6U5m.js","assets/chunk-V4NBQF5C-D9I4DV9v.js","assets/storage-B-vhjyV2.js","assets/table-fcouR4db.js","assets/dist-BNFgFOsA.js","assets/transform-CmAXy0Ck.js","assets/styles-IQ4adxWr.css","assets/SquisqIntegration-C5l_OPvD.js","assets/outside-in-BmIIeMid.js","assets/chunk-7AWFHP5U-MiVVPFTx.js","assets/jszip.min-DhiFe-R7.js","assets/html-BbQNmJ5X.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-DPK4r8Am.js","assets/microphone-input-5gqW_NKf.js","assets/composer-prefill-CbG_i1Rx.js","assets/SessionSwitcher-BgZqyiRn.js","assets/ProjectTimeline-CTPcn4Kc.js","assets/chat-thread-memory-CI2-giEq.js","assets/useCompactLayout-BDtPQcDh.js","assets/GitDiffView-DrDrSeBb.js","assets/gitCopy-Dcjz17cJ.js","assets/completion-data--97asQiQ.js","assets/ProjectConnectionsTab-CQgaIzuv.js","assets/ProjectMailTab-DLtJdXSL.js","assets/mail-link-CWfsP5Aq.js","assets/DiffpackReviewView-B2a3zgE-.js","assets/MarkdownField-Dugmfr_e.js","assets/useDiffpacks-B0kYhlWQ.js","assets/FileMapView-BKJovLcL.js","assets/HistoryView-CkinzFEC.js","assets/ProjectGithubView-BV2uTNU0.js","assets/useGitSync-DOt-ODiw.js","assets/GithubSignInChip-DT3l6E0Q.js","assets/ProjectOverviewView-ZMs9nL5N.js","assets/WorkspaceIndexPane-DnsOO916.js","assets/TasksView-Dy5Ue4zS.js","assets/TaskTabContent-CG2KmfwV.js","assets/TransformToolbarButton-gzIxUBH7.js","assets/pending-drafts-27ujtQxX.js","assets/NewScriptDialog-TEAd0KLl.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{Bt as r,Gt as i,Ht as a,Nt as o,R as s,Sn as c,T as l,W as u,Wt as d,Xt as f,cn as p,dt as m,kt as h,ln as g,rt as _,vt as v,wt as y,xt as b}from"./dist-DOqbRmFj.js";import{t as x}from"./dist-CJqyWK6E.js";import{t as S}from"./api-C0I7spBl.js";import{i as C,n as w,r as T}from"./Tabs-jE0Z5Tzd.js";import{G as E,H as ee,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-aDThLOwl.js";import{t as j}from"./poppetje-CfaAvFkE.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-BvkZd-EV.js";import{t as F}from"./GezelJsonEditor-DXXt165-.js";import{a as I,i as we,n as L,o as Te,r as Ee,t as De}from"./new-project-meta-ZmDPGYzC.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-DDu8nyO6.js";import"./storage-B-vhjyV2.js";import"./provider-default-BLsHrgzI.js";import{a as Ve,c as He,i as Ue,o as We,r as Ge}from"./SquisqIntegration-C5l_OPvD.js";import{t as Ke}from"./useShowWorkInProgressFeatures-BtpredG7.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-DVyWN0LD.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-BmIIeMid.js";import{n as ft}from"./composer-prefill-CbG_i1Rx.js";import{n as pt,r as W,t as mt}from"./useCompactLayout-BDtPQcDh.js";import{n as ht,r as gt}from"./mail-link-CWfsP5Aq.js";import{t as _t}from"./ToolsetsEditor-J9XxQ5Ms.js";import{t as vt}from"./useDiffpacks-B0kYhlWQ.js";import{i as yt,n as bt,o as xt,r as St,t as Ct}from"./WorkspaceIndexPane-DnsOO916.js";import{n as wt}from"./MemoriesTree-CgFqUNEr.js";import{t as Tt}from"./ProjectGitStatusBar-BgHZ2ijN.js";import{t as Et}from"./markdown-baseline-9B52XlX2.js";import{n as Dt,t as Ot}from"./TransformToolbarButton-gzIxUBH7.js";import{t as kt}from"./GithubSignInChip-DT3l6E0Q.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=u(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=u(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[u(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:i,onClose:o,onAddExisting:s,onCreateTemplate:c}){let[l,d]=(0,G.useState)([]),[f,h]=(0,G.useState)(!1),[g,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(null),[x,C]=(0,G.useState)(``),[w,T]=(0,G.useState)(null),[ae,oe]=(0,G.useState)(``),[se,ce]=(0,G.useState)(),[ue,D]=(0,G.useState)(It),O=_(p(t));(0,G.useEffect)(()=>{if(!e)return;let t=!1;return h(!0),b(null),C(``),T(null),S.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);d([...n.values()])}).catch(e=>{t||b(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 l){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,l]),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)=>u(e,i).localeCompare(u(t,i))),[de,n,i]),k=(0,G.useMemo)(()=>l.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,l]),_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`?u(e.gezel,i):e.template.manifest.name).localeCompare(t.kind===`existing`?u(t.gezel,i):t.template.manifest.name))},[_e,ge,k,fe,i]),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=x.trim().toLocaleLowerCase(),Se=(0,G.useMemo)(()=>M?A.filter(e=>e.kind===`existing`?Rt(e.gezel,M,i):zt(e.template,M)):A,[M,i,A]),N=(0,G.useMemo)(()=>M?be.filter(e=>Rt(e,M,i)):be,[M,be,i]),Ce=(0,G.useMemo)(()=>M?xe.filter(e=>zt(e,M)):xe,[M,xe]),P=()=>{g||o()},F=async e=>{v(!0),b(null);try{await s(e),o()}catch(e){b(e.message)}finally{v(!1)}},I=async(e,t)=>{v(!0),b(null);try{await c(e.manifest.id,t),o()}catch(e){b(e.message)}finally{v(!1)}},we=e=>{if(i){I(e,{name:e.manifest.name});return}let t=r(),n=e.manifest.nameSuggestions??[],a=n.length>0?n[Math.floor(Math.random()*n.length)]:t.name;T(e),oe(a??t.name),ce(t.gender),D(It()),b(null)},L=w&&ae.trim()?a(ue,{key:`project-add-preview:${w.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:w?`Customize ${w.manifest.name}`:`Add Gezel`})}),(0,K.jsx)(E,{className:`muted small`,children:w?`Give this new ${w.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}.`}),y&&(0,K.jsx)(`p`,{className:`error small project-add-gezel-error`,children:y}),w?(0,K.jsxs)(`form`,{className:`project-add-gezel-customize`,onSubmit:e=>{e.preventDefault(),ae.trim()&&I(w,{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 `,w.manifest.name,` `,`template.`]})]}),(0,K.jsxs)(ee,{children:[(0,K.jsx)(`button`,{type:`button`,disabled:g,onClick:()=>{T(null),b(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:x,onChange:e=>C(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=u(e.gezel,i);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:m(`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=u(e,i);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`}),f&&(0,K.jsx)(`p`,{className:`muted small`,children:`Loading roles…`}),!f&&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:m(`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))}):!f&&(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)(ee,{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 S.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 S.enableSuggestedWork(e,{key:t.key,...n?{params:n}:{}});let r=Gt(t,n);r&&await S.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,()=>S.disableSuggestedWork(e,n.key)),onDismiss:()=>void h(n.key,()=>S.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,()=>S.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:r}){let i=e.paramSchema,[a,s]=(0,G.useState)(()=>{let n={},r=i?.properties??{};for(let[i,a]of Object.entries(r)){let r=o(a),s=r?t?.[r]:void 0,c=Fe(a);s===void 0?e.params?.[i]===void 0?c!==void 0&&(n[i]=c):n[i]=e.params[i]:n[i]=s}return n}),c=(0,G.useMemo)(()=>{let e={};for(let[t,n]of Object.entries(a))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},[a]);return(0,K.jsxs)(`form`,{className:`suggested-work-param-form`,onSubmit:e=>{e.preventDefault(),n(c)},children:[i&&(0,K.jsx)(F,{schema:i,value:a,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:r,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??{},r={};for(let[e,i]of Object.entries(n)){let n=o(i),a=t[e];n&&a!==void 0&&a!==``&&(r[n]=a)}return Object.keys(r).length>0?r: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,l]=(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:()=>l(!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=u({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:()=>l(!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 S.listKnowledgeCatalogs().then(t=>{e||r(t.catalogs)}).catch(()=>{}),()=>{e=!0}},[]);let o=(0,G.useCallback)(async n=>{try{t(await S.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,b]=(0,G.useState)(!1),[x,C]=(0,G.useState)(null),[w,T]=(0,G.useState)(`idle`),[E,ee]=(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 S.getConfig().then(t=>{e||b(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||!E||window.open(E,`_blank`,`noopener,noreferrer`)},[O,E]),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(``),C(null),T(`idle`)},[O?.id,d]),(0,G.useEffect)(()=>{y||(C(null),T(`idle`))},[y]);let me=(0,G.useCallback)(e=>{C(e),T(`idle`)},[]),he=(0,G.useCallback)(async()=>{if(x)try{await navigator.clipboard.writeText(sn(x)),T(`copied`)}catch{T(`error`)}},[x]),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 S.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||!E,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:ee,...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&&x?(0,K.jsxs)(`div`,{className:`project-output-debugbar`,children:[_&&(0,K.jsx)(`span`,{className:`project-output-debugbar-error small`,role:`alert`,children:_}),y&&x&&(0,K.jsx)(`output`,{className:`project-output-script-error-label small`,children:x.response?.error??x.transportError??`Script failed`}),(0,K.jsx)(`span`,{className:`project-output-toolbar-spacer`}),y&&x&&(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:w===`copied`?`Copied`:w===`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([S.statProjectWorkspacePath(e,t).catch(()=>null),S.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)({}),[a,o]=(0,G.useState)(null),s=e.properties??{},c=Object.keys(s).filter(e=>!i(e)),u=[...l.map(e=>({id:e.id,label:e.label,description:e.description,options:e.options})),...c.map(e=>({id:e,label:e,description:void 0,options:void 0}))],d=async i=>{let a=n[i];if(!(a===void 0||a===(s[i]??``))){o(null);try{t(await S.updateProject(e.id,{properties:{[i]:a}})),r(e=>{let{[i]:t,...n}=e;return n})}catch(e){o(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)),a&&(0,K.jsx)(`p`,{className:`error small`,children:a})]})}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 g(e.role)??g(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),b=i=>{let a=X(n,i,r);c(i),d(a[0]?.id??``),m||p(Cn(e,t,i))},x=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)}}},S=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(),x()},children:[(0,K.jsx)(ie,{asChild:!0,children:(0,K.jsx)(`h3`,{children:`Assign issue fix`})}),(0,K.jsx)(E,{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=>b(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 ${S.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 `,S.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)(ee,{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=f({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=d(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:m(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(),[a,o]=(0,G.useState)(``),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(`general`),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),[_,v]=(0,G.useState)([]),[y,b]=(0,G.useState)(null),[x,C]=(0,G.useState)({}),[w,T]=(0,G.useState)(``),[E,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:a,nameManuallyEdited:l,about:p,mission:h});Ie.current={name:a,nameManuallyEdited:l,about:p,mission:h};let Le=(0,G.useId)();(0,G.useEffect)(()=>{Ne.current+=1,Pe.current=null,Fe.current?.abort(),Fe.current=null,e&&(o(``),u(!1),f(`general`),m(``),g(``),O(``),Se(null),Ce(null),fe(``),me(`imap`),ge(``),_e(``),ve(``),be(!0),xe(``),b(null),C({}),T(``),ae(`all`),se(`pick`),ue(!1),z(``),je(!1),Me.current=null)},[e]),(0,G.useEffect)(()=>{if(!e)return;let t=!1,n=S.listCatalogItems(`project-type`),r=i?Promise.resolve({items:[]}):S.listCatalogItems(`craftbook-template`);return Promise.all([n,r]).then(([e,n])=>{if(t)return;let r=s(n.items);v(c(e.items,i,r).filter(e=>e.manifest.id!==`email`))}).catch(()=>{t||v([])}),()=>{t=!0}},[e,i]),(0,G.useEffect)(()=>{!i&&d===`email`&&f(`general`)},[d,i]),(0,G.useEffect)(()=>{if(!e||!P){R([]);return}let t=!1;return S.listGitHubRepos().then(e=>{t||R(e.repos)}).catch(()=>{t||R([])}),()=>{t=!0}},[e,P]);let Re=t===`solo`||d===`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 S.previewGitHubRepo(Yn(t),r.signal);if(Ne.current!==n)return;Ce(`drafting`);let i=Ie.current;i.nameManuallyEdited||o(e.repo);let a=i.nameManuallyEdited&&i.name.trim()||e.repo,s=await S.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?`))&&(m(s.about),g(s.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 S.previewFolder(t);e.name&&!l&&o(e.name),e.about&&m(t=>t.trim()?t:e.about??``)}catch{if(!l){let e=t.replace(/[\\/]+$/,``).split(/[\\/]/).pop();e&&o(e)}}},[l]),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=y?_.find(e=>e.manifest.id===y)??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=w.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?_.filter(e=>{let t=e.manifest;return`${t.name} ${t.description} ${t.tags.join(` `)}`.toLowerCase().includes(H)}):_,[H,_]),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||E===`all`?$e:$e.filter(e=>e.cat.id===E),tt=(0,G.useMemo)(()=>De.map(e=>({cat:e,count:Xe.filter(t=>t.category===e.id).length+_.filter(t=>I(t)===e.id).length})).filter(e=>e.count>0),[Xe,_]),nt=V?{source:`catalog`,item:V}:{source:`builtin`,kind:Xe.find(e=>e.id===d)??Xe[0]},rt=Fn(nt),it=(0,G.useCallback)(async e=>{if(e.preventDefault(),oe!==`configure`)return;if(z(``),y&&V){let e=a.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 S.createTypedProject({name:e,...Re?{mode:`solo`}:{},projectType:{typeId:y,params:{...Hn(t),...x}}});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(d===`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 S.createProject({name:e,about:t.about,missionObjectives:t.mission,...Re?{mode:`solo`}:{}}),a=await S.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=a.trim(),i=p.trim(),o=h.trim(),s=D.trim();if(!t){z(`Name is required.`);return}if(d!==`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=d===`github`;if(c&&s&&!Xn(s)){z(`GitHub repo doesn't look right — leave it blank or use owner/repo.`);return}if(d===`folder`&&!j.trim()){z(`Choose a folder for this project.`);return}je(!0);try{await r(await S.createProject({name:t,about:i,missionObjectives:o,...Re?{mode:`solo`}:{},...d===`folder`?{workingDir:j.trim()}:{},...c&&s?{github:{url:Yn(s)}}:{}})),n()}catch(e){z(e.message)}finally{je(!1)}},[a,d,p,h,D,de,pe,he,k,A,ye,j,y,V,x,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:w,onChange:e=>T(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&&E===`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&&E===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&&!y&&e.id===d,...e.soon?{disabled:!0,badge:`Soon`}:{},onSelect:()=>{e.soon||(d===`github`&&e.id!==`github`&&Ue(),f(e.id),ue(!0),b(null),C({}),l||o(``),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===y,...!(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:()=>{d===`github`&&Ue(),b(t.manifest.id),f(`general`),ue(!1);let e=Hn(t.manifest.kind===`project-type`?t.manifest.params:void 0);C(e),l||o(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)(ee,{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:x,onChange:e=>{let t=e??{};C(t),l||o(Wn(V,t))},density:`compact`})}),d===`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 →`})]})]})]}),d===`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.`})]}),d===`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:a,onChange:e=>{o(e.target.value),u(!0)},placeholder:Re?`e.g. Bird-feeder prototype`:`e.g. Eliza's Pet Shop`}),V&&a&&!l&&(0,K.jsx)(`small`,{className:`muted`,children:`Suggested from your choices — edit it anytime.`}),d===`folder`&&a&&!l&&(0,K.jsx)(`small`,{className:`muted`,children:`Suggested from the folder — edit it anytime.`})]}),d===`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.`]})]}),d!==`email`&&!y&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{children:[Re?`Job description`:`About`,` `,(0,K.jsx)(`span`,{className:`muted`,children:d===`folder`?`(optional)`:``}),(0,K.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),placeholder:d===`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:h,onChange:e=>g(e.target.value),placeholder:Ve,rows:3})]})]})]})})]},y??d),(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)(ee,{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 x){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 x))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:S,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:S,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-BiJRweob.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,74])),ir=()=>N(()=>import(`./ProjectConnectionsTab-CQgaIzuv.js`),__vite__mapDeps([75,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-DLtJdXSL.js`),__vite__mapDeps([76,1,2,4,5,3,11,77])),or=()=>N(()=>import(`./DiffpackReviewView-B2a3zgE-.js`),__vite__mapDeps([78,1,2,3,4,5,11,21,6,7,8,72,73,79,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,54,42,55,80])),sr=()=>N(()=>import(`./FileMapView-BKJovLcL.js`),__vite__mapDeps([81,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,54,42,55,79])),cr=()=>N(()=>import(`./HistoryView-CkinzFEC.js`),__vite__mapDeps([82,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-BV2uTNU0.js`),__vite__mapDeps([83,1,2,5,3,4,8,7,6,11,21,72,73,79,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,54,42,55,84,85])),ur=()=>N(()=>import(`./ProjectOverviewView-ZMs9nL5N.js`),__vite__mapDeps([86,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,79,48,49,50,51,52,43,53,54,42,55,87])),dr=()=>N(()=>import(`./TasksView-Dy5Ue4zS.js`),__vite__mapDeps([88,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,89,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,47,66,67,68,69,79,90,91,92])),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=p(e);return!t||!Rr.has(t)}function Br(e){return p(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(),i=(0,G.useRef)(null),a=mt(i),o=t||a,s=Ne(),[c,l]=(0,G.useState)([]),[u,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(!1),[g,x]=(0,G.useState)(void 0),[E,ee]=(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{l((await S.listProjects()).projects)}catch(e){D(e.message)}},[]),yn=(0,G.useMemo)(()=>c.filter(e=>!e.archived),[c]),bn=(0,G.useMemo)(()=>c.filter(e=>e.archived),[c]),xn=(0,G.useMemo)(()=>{if(!u)return[];let e=new Set(u.linkedProjectIds??[]);return c.filter(t=>t.id!==u.id&&!b(t)&&(!t.archived||e.has(t.id)))},[c,u]),Sn=(u?.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}l(e=>e.map(e=>e.id===t.projectId?{...e,...t.project}:e)),f(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`)&&ee(`crew`);let e=()=>{je(`project`),ee(`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&&f(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 S.listGezels()).gezels)}catch(e){console.error(`[ProjectsView] listGezels failed`,e)}},[]),wn=(0,G.useCallback)(async()=>{try{let e=await S.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=u?.id;(0,G.useEffect)(()=>{if(!X){Xt(null);return}let e=!1,t=()=>{S.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(!u)return{managedWritable:!0,nativeWritable:!1,effectiveWritable:!0,codexInUse:!1,claudeInUse:!1,claudeMode:`acceptEdits`};let e=qt?.projectId===u.id?qt.gezels:[];return{...On(u,Gt,e,J),codexInUse:kn(u,Gt,e,J),claudeInUse:An(u,Gt,e,J),claudeMode:jn(u,Gt,e,J)}},[u,Gt,qt,J]),Dn=h(u?.codexPermissionMode??J?.codexCli?.defaultPermissionMode),Mn=(0,G.useCallback)(async e=>{if(!u)return;let t=await S.addGezelToProject(u.id,e);x(e),f(e=>e?.id===u.id?{...e,gezelIds:t.gezelIds}:e)},[u]),Nn=(0,G.useCallback)(async e=>{if(!u)return;let t=await S.removeGezelFromProject(u.id,e);f(e=>e?.id===u.id?{...e,gezelIds:t.gezelIds}:e)},[u]),Pn=(0,G.useCallback)(async(e,t)=>{if(!u)return;let n=u.id,r=await S.createGezelFromTemplate(e,{name:t.name,...t.gender?{gender:t.gender}:{}});if(t.appearanceSeed!==void 0){let{poppetje:e}=await S.rerollGezelPoppetje(r.id,{seed:t.appearanceSeed});r={...r,poppetje:e}}let i=await S.addGezelToProject(n,r.id);x(r.id),Kt(e=>[...e.filter(e=>e.id!==r.id),r]),f(e=>e?.id===n?{...e,gezelIds:i.gezelIds}:e),window.dispatchEvent(new CustomEvent(`gezel:gezel-updated`,{detail:r}))},[u]),Fn=He.workspace,In=He.artifacts,Ln=(0,G.useCallback)(async e=>{let[t,n]=await Promise.all([S.listProjectWorkspace(e,``,!0,{stats:!0,hidden:Fn}),S.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 S.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||!u||zn(u.id)},[L,u,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([S.getProjectIndexStatus(X),S.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 S.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),S.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([S.toolListFileIssues(X,{maxResults:1e3}),Z?S.toolFileReview(X,{path:Z}):Promise.resolve(null)]);ht(e),t&&Ot(t)},[X,Z]),qn=(0,G.useCallback)(async(e,t)=>{X&&(await S.updateBoekwachterIssue(X,{ref:e.ref,...t}),await Kn())},[Kn,X]);(0,G.useEffect)(()=>{if(P!==`packages`||!u){A({}),Ce(null);return}S.listPackageScripts(u.id).then(e=>A(e.scripts)).catch(e=>{console.warn(`[ProjectsView] listPackageScripts failed`,e),A({})}),S.getProjectApprovals(u.id).then(Ce).catch(e=>{console.warn(`[ProjectsView] getProjectApprovals failed`,e),Ce(null)})},[P,u]),(0,G.useEffect)(()=>{H(null)},[L]),(0,G.useEffect)(()=>{if(P!==`about`||!u)return;let e=!1;return(async()=>{try{let t=await S.listWorkspaceWrites(u.id,20);e||sn(t.entries)}catch{}try{let t=await S.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,u]);let Jn=(0,G.useCallback)(async(e,t)=>{if(!u)return;let n=u.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 S.updateProject(u.id,{grantedCredentials:r});f(e),D(null)}catch(e){D(e.message)}},[u,mn]),Yn=(0,G.useCallback)((e,t)=>{if(!u)return;let n=nr(e,t);ft(u.id,n),F(`chat`)},[u]),Xn=(0,G.useCallback)(e=>{u&&(ft(u.id,e),F(`chat`))},[u]),Zn=(0,G.useCallback)(async e=>{let t=await S.getProject(e);f(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 S.readProjectWorkspaceFile(e,t):await S.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&&u&&t.projectId!==u.id||F(`settings`)};return window.addEventListener(`gezel:open-project-settings`,e),()=>window.removeEventListener(`gezel:open-project-settings`,e)},[u]),(0,G.useEffect)(()=>{let e=e=>{let t=e.detail;!t?.path||!t.source||u&&(!t.projectId||t.projectId===u.id)&&(z(u.id),Qn(u.id,t.path,t.source,t.line))};return window.addEventListener(`gezel:open-file`,e),()=>window.removeEventListener(`gezel:open-file`,e)},[u,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(),f(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(!(!u||!te.trim())){ie(`installing…`);try{let e=await S.installPackage(u.id,{name:te.trim()});ie(e.log),f(e.project),ne(``)}catch(e){ie(e.message)}}},[te,u]),rr=(0,G.useCallback)(async e=>{if(!u)return;let t=e.trim();if(t!==(u.github?.url??``))try{if(t===``){let e=await S.updateProject(u.id,{github:null});f(e),dn(`Unlinked.`);return}let e=await S.updateProject(u.id,{github:{url:t}});f(e),dn(`Cloning…`);try{let e=await S.cloneProjectGit(u.id),t=await S.getProject(u.id);f(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}`)}},[u]),ir=(0,G.useCallback)(async e=>{if(!u)return;let t=e.trim()||void 0;if(t!==(u.workingDir??void 0))try{let e=await S.setProjectWorkingDir(u.id,t);f(e),await zn(u.id)}catch(e){console.error(`setProjectWorkingDir failed:`,e)}},[u,zn]),ar=(0,G.useCallback)(async e=>{if(u)try{let t=await S.updateProject(u.id,{managedWorkspaceWritePolicy:e?`allow`:`deny`});f(t)}catch(e){console.error(`updateProject(managedWorkspaceWritePolicy) failed:`,e)}},[u]),or=(0,G.useCallback)(async e=>{if(u)try{let t=await S.updateProject(u.id,{codexPermissionMode:e});f(t)}catch(e){console.error(`updateProject(codexPermissionMode) failed:`,e)}},[u]),sr=(0,G.useCallback)(async e=>{if(u)try{let t=await S.updateProject(u.id,{claudePermissionMode:e});f(t)}catch(e){console.error(`updateProject(claudePermissionMode) failed:`,e)}},[u]),cr=(0,G.useCallback)(async e=>{if(u)try{let t=await S.updateProject(u.id,{indexingEnabled:e});f(t),e&&S.refreshProjectIndex(u.id).catch(()=>{})}catch(e){console.error(`updateProject(indexingEnabled) failed:`,e)}},[u]),lr=(0,G.useCallback)(async e=>{if(u)try{f(await S.updateProject(u.id,{nightlyFixesEnabled:e}))}catch(e){console.error(`updateProject(nightlyFixesEnabled) failed:`,e)}},[u]),ur=(0,G.useCallback)(async(e,t)=>{if(!u||fn)return;let n=u.linkedProjectIds??[],r=t?Array.from(new Set([...n,e])):n.filter(t=>t!==e);pn(!0);try{let e=await S.updateProject(u.id,{linkedProjectIds:r});f(e),l(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,u]),dr=(0,G.useCallback)(async e=>{if(u)try{let t=await S.updateProject(u.id,{nudgeConfig:{...u.nudgeConfig,enabled:!e}});f(t)}catch(e){D(e.message)}},[u]),Cr=(0,G.useCallback)(async(e,t)=>{if(u)try{let n=await S.updateProject(u.id,{tabVisibility:{...u.tabVisibility,[e]:t}});f(n),D(null)}catch(e){D(e.message)}},[u]),Q=(0,G.useCallback)(e=>e===`artifacts`||d(u),[u]),Fr=(0,G.useCallback)(async(e,t)=>{if(!u)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 S.readProjectWorkspaceFile(u.id,r):await S.readProjectArtifact(u.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 S.fetchProjectWorkspaceBlob(u.id,e.path):await S.fetchProjectArtifactBlob(u.id,e.path)).arrayBuffer(),n),o=Ue({projectId:u.id,root:n.companionDirectory,client:S,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(u.id)}let a=it(i,n);return a!==i&&Q(t)&&(t===`workspace`?await S.writeProjectWorkspaceFile(u.id,{path:r,content:a}):await S.writeProjectArtifact(u.id,r,a)),{layout:{...n,markdownPath:r},sourcePath:r,content:a,editingEnabled:at(n.format)&&ct(a)}},[u,Te,R,Q,Ln]),Rr=(0,G.useCallback)(async(e,t)=>{if(!u||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 S.readProjectWorkspaceFile(u.id,e.path):await S.readProjectArtifact(u.id,e.path),r=qe(n.content)?Ye:n.content;H({...n,content:r,source:t})}},[u,Fr]),zr=(0,G.useCallback)(async(e,t)=>{if(!u||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 S.fetchProjectWorkspaceBlob(u.id,n.layout.targetPath):await S.fetchProjectArtifactBlob(u.id,n.layout.targetPath);try{t===`workspace`?await S.writeProjectWorkspaceBinary(u.id,n.layout.backupPath,r,r.type||`application/octet-stream`,{createOnly:!0}):await S.writeProjectArtifactBinary(u.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 S.writeProjectWorkspaceFile(u.id,{path:n.sourcePath,content:i}):await S.writeProjectArtifact(u.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(u.id)}catch(e){D(e instanceof Error?e.message:`Could not enable Markdown editing.`)}},[u,Q,Fr,Ln]),Hr=(0,G.useCallback)(e=>{H(t=>t&&{...t,content:e})},[]),Wr=(0,G.useCallback)(async e=>{if(!u||!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:u.id,root:e.companionDirectory,client:S,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 S.writeProjectWorkspaceFile(u.id,{path:n,content:o}):await S.writeProjectArtifact(u.id,n,o),a){let{PLAYER_BUNDLE:e}=await N(async()=>{let{PLAYER_BUNDLE:e}=await import(`./standalone-source-7QdiNsDW.js`);return{PLAYER_BUNDLE:e}},[]);B.source===`workspace`?await S.writeProjectWorkspaceFile(u.id,{path:a,content:e}):await S.writeProjectArtifact(u.id,a,e)}B.source===`workspace`?await S.writeProjectWorkspaceBinary(u.id,e.targetPath,s.bytes,s.mimeType):await S.writeProjectArtifactBinary(u.id,e.targetPath,s.bytes,s.mimeType),H(e=>e?.path===B.path&&e.source===B.source?{...e,content:o}:e),await zn(u.id);return}Q(B.source)&&(B.source===`workspace`?await S.writeProjectWorkspaceFile(u.id,{path:B.path,content:t}):await S.writeProjectArtifact(u.id,B.path,t))},[u,B,Q,Te,R,zn]);(0,G.useCallback)((e,t)=>u?`/api/projects/${u.id}/${t===`workspace`?`workspace`:`artifacts`}/read?path=${encodeURIComponent(e)}&raw=1`:``,[u]);let Gr=L===`workspace`?Te:R,Yr=L?He[L]:!1,Qr=(0,G.useMemo)(()=>Yr?Gr:Gr.filter(e=>!v(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||!v(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(u?.id??``,L??`artifacts`,{canWrite:u!==null&&L!==null&&Q(L)}),[u,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()=>{u&&await zn(u.id)},[u,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(!u){Ht(null);return}if(typeof u.outputPaneVisible==`boolean`){Lr(u.id);return}let e=Ir(u.id);if(e===null)return;let t=u.id;Ht({projectId:t,visible:e}),S.updateProject(t,{outputPaneVisible:e}).then(e=>{Lr(t),f(n=>n?.id===t?e:n)}).catch(()=>{})},[u?.id]);let pi=u?.projectType;(0,G.useEffect)(()=>{let e=!1;if(!pi){Wt(null);return}return(async()=>{try{let t=await S.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===u?.id?Vt.visible:null,hi=!!u&&(mi??u?.outputPaneVisible??(fi||!!Ut)),gi=(0,G.useCallback)(()=>{if(!u)return;let e=!hi,t=u.id;Ht({projectId:t,visible:e}),S.updateProject(t,{outputPaneVisible:e}).then(e=>{f(n=>n?.id===t?e:n)}).catch(e=>{D(e.message)})},[u,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=o&&De.length>0,Ti=vt(u?.id??``);(0,G.useEffect)(()=>{P===`output`&&!wi&&F(`chat`)},[P,wi]);let Ei=!o&&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(!(!u||u.id==="default"||b(u))&&!p){m(!0);try{let e=await S.updateProject(u.id,{archived:!u.archived});window.dispatchEvent(new CustomEvent(`gezel:project-updated`,{detail:{projectId:u.id,project:e}}))}catch(e){D(e instanceof Error?e.message:String(e))}finally{m(!1)}}},[p,u]),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${u?.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||u||c.length===0)return;let e=null;try{e=window.localStorage.getItem(xr)}catch{e=null}e&&c.some(t=>t.id===e)&&Zn(e)},[n,u,c,Zn]),(0,K.jsxs)(`div`,{ref:i,className:`two-col${I&&!n?` sidebar-collapsed`:``}${n?` detail-only`:``}${o?` is-compact`:``}`,children:[!n&&(0,K.jsx)(Gn,{open:E!==null,mode:E??`crew`,onClose:()=>ee(null),onCreated:er}),u&&q&&(0,K.jsx)(Tn,{path:q.path,issue:q.issue,gezels:Gt,assignedGezelIds:new Set([...u.gezelIds??[],...u.voormanGezelId?[u.voormanGezelId]:[]]),onCancel:()=>Rt(null),onConfirm:async(e,t)=>{await S.fixBoekwachterIssue(u.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:()=>ee(`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:()=>ee(`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&&!u?(0,K.jsx)(`p`,{className:`placeholder`,children:`Pick a project on the left to view it here.`}):u?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`entity-tabs-row project-tabs-row`,children:[!o&&(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)(T,{value:P,onValueChange:e=>F(e),children:(0,K.jsx)(w,{children:[{value:`output`,label:`Output`,show:wi},{value:`chat`,label:`Chat`,show:!0},{value:`overview`,label:`Overview`,show:kr(u,`overview`)},{value:`tasks`,label:`Tasks`,show:kr(u,`tasks`)},{value:`packages`,label:`Approvals`,show:kr(u,`approvals`)},{value:`workspace`,label:`Workspace`,show:kr(u,`workspace`)},{value:`artifacts`,label:`Artifacts`,show:kr(u,`artifacts`)},{value:`proposals`,label:`Proposals`,show:Ti>0},{value:`github`,label:`GitHub`,show:!!u.github?.url},{value:`mail`,label:`Mail`,show:r&&Br(u)},{value:`map`,label:`Village`,show:kr(u,`map`)},{value:`about`,label:`Settings`,show:!0}].filter(e=>e.show).map(e=>o?(0,K.jsx)(C,{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)(C,{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))})}),u.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`:``}${o?` project-body-compact`:``}`,style:Ei?{"--project-output-width":`${(vi*100).toFixed(2)}%`}:void 0,children:[(Ei||Di)&&(0,K.jsx)(on,{projectId:u.id,htmlFiles:De,typePage:Ut??void 0,onClose:Di?()=>F(`chat`):gi,onDebugFrame:Xn},u.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:u,gezels:Gt,boekwachterGezelId:Qt,recentlyAddedGezelId:g,onAddGezel:Mn,onCreateTemplateGezel:Pn,onRemoveGezel:Nn}),(0,K.jsx)(Xr,{projectId:u.id,resourceKey:`project:${u.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:u.about??``,onSave:async e=>{let t=await S.updateProject(u.id,{about:e});return f(n=>n?.id===t.id?{...n,about:e}:n),t}},`${u.id}:about`),(0,K.jsx)(Xr,{projectId:u.id,resourceKey:`project:${u.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:u.missionObjectives??``,onSave:async e=>{let t=await S.updateProject(u.id,{missionObjectives:e});return f(n=>n?.id===t.id?{...n,missionObjectives:e}:n),t}},`${u.id}:mission`),(0,K.jsx)(wt,{projectId:u.id,projectName:u.name},`${u.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:u,onProjectChange:f})})}),(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:u.workingDir?`External: ${u.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&&u.workingDir?rn(!0):ar(t)}}),(0,K.jsx)(`span`,{className:`muted small`,children:u.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:u.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:u.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.`})]})]}),!b(u)&&(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.`,` `,(u.linkedProjectIds??[]).length,` of 32 linked.`]}),(0,K.jsxs)(`div`,{className:`project-tab-settings-grid`,children:[xn.map(e=>{let t=(u.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,d(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:u,onUpdated:f}),(0,K.jsxs)(`div`,{className:`config-label`,style:{marginTop:`0.75rem`},children:[`Project properties`,(0,K.jsx)(vn,{project:u,onProjectChange:f}),(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:[u.github?.url?u.github.checkoutDir?`Linked. Checkout: ${u.github.checkoutDir}${u.github.branch?` (${u.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(u),(0,K.jsx)(`div`,{className:`new-row`,children:(0,K.jsx)(jt,{gezels:Gt,value:u.voormanGezelId,noneLabel:`(no ${Ft(u)})`,ariaLabel:Pt(u),onValueChange:async e=>{let t=await S.updateProject(u.id,{voormanGezelId:e});f(t)}})}),(0,K.jsx)(`small`,{className:`muted`,children:u.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:u.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:u.projectTypeId||`__AUTO__`,onValueChange:async e=>{let t=await S.updateProject(u.id,{projectTypeId:e===`__AUTO__`?null:e});f(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=_(u.detectedProjectType?.id);return e?`Auto-detect (${e.label})`:`Auto-detect`})()}),y().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(u,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.`})]}),u.id!=="default"&&!b(u)&&(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:u.archived?`Restore project`:`Archive project`}),(0,K.jsx)(`small`,{className:`muted`,children:u.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:p,children:p?u.archived?`Restoring…`:`Archiving…`:u.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=(u.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:u.id},subject:u.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:u.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:u.workingDir?(0,K.jsxs)(K.Fragment,{children:[`Gezels will be able to create, modify, and delete files inside`,` `,(0,K.jsx)(`code`,{children:u.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:[u.packages.map(e=>(0,K.jsxs)(`li`,{children:[e.name,` `,(0,K.jsx)(`code`,{children:e.version})]},e.name)),u.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`?u.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 S.refreshProjectIndex(u.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 S.refreshProjectIndex(u.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:u.id,file:B,outsideIn:B.outsideIn,isReadOnly:ci,editorTheme:s,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:u.id,path:B.path,fetchBlob:ai.fetchBlob,onOpen:e=>void Qn(u.id,e,`workspace`)},B.path)]}):Sr(B.path)?(0,K.jsx)(Jr,{projectId:u.id,file:B,isReadOnly:ci,editorTheme:s,onEditorChange:Hr,onSave:Wr,onComplainAboutPreviewError:Yn,toolbarIndexToggle:di,sourceReveal:ui}):(0,K.jsx)(qr,{projectId:u.id,file:B,isReadOnly:ci,editorTheme:s,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:u,compact:o},u.id)}),P===`tasks`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(br,{projectId:u.id})}),P===`proposals`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(hr,{projectId:u.id})}),P===`github`&&u.github?.url&&(0,K.jsx)(Dr,{children:(0,K.jsx)(vr,{project:u,onProjectChange:f})}),r&&P===`mail`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(mr,{project:u,onProjectChange:f})}),P===`map`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(gr,{projectId:u.id})}),P===`overview`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(yr,{projectId:u.id,project:u})})]})]}),(0,K.jsx)(Tt,{projectId:u.id,compact:o,managedWorkspaceWritable:En.managedWritable,onManagedWorkspaceWritesChange:e=>{e&&u.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:u.github?.url?()=>F(`github`):void 0,onAddBoekwachter:Qt?()=>Mn(Qt):void 0,status:u.status??`active`,statusLocked:u.archived===!0,onStatusChange:async e=>{let t=await S.updateProject(u.id,{status:e});f(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:S,referencePrefix:u}):null,[u,s,e,c]),g=(0,G.useMemo)(()=>s?Ge({projectId:e,root:l,client:S,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:S,currentDocumentPath:t.path,source:`project-artifacts`,projectId:e}):null,[s,e,t.path]),b=(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:b,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,b]=(0,G.useState)(null);(0,G.useEffect)(()=>{c?.path===t.path&&u(`source`)},[t.path,c]);let x=ze({resourceKey:`file:${t.source}:${t.path}`,initialValue:t.content,save:async e=>{await a(e)}}),S=(0,G.useCallback)(e=>{i(e),x.update(e)},[i,x.update]),E=(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]),ee=(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)(T,{value:l,onValueChange:e=>u(e),children:(0,K.jsxs)(`div`,{className:`html-file-viewer-bar`,children:[(0,K.jsxs)(w,{children:[(0,K.jsx)(C,{value:`preview`,children:`Preview`}),(0,K.jsx)(C,{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:ee,onUrlReady:b}),p.length>0&&(0,K.jsx)(Yr,{logs:p,collapsed:h,onToggleCollapsed:()=>g(e=>!e),onClear:()=>m([]),...o?{onComplain:E}:{},..._===void 0?{}:{complainBusyAt:_}})]}):(0,K.jsx)(`div`,{className:`editor-wrap`,children:(0,K.jsx)(P,{initialMarkdown:x.desiredValue(),fileName:t.path,onChange:n?void 0:S,height:`100%`,colorScheme:r,showPlayTab:!1,fullWidth:!0,toolbarSlotRight:s,statusBarSlotRight:n?void 0:(0,K.jsx)(He,{autosave:x})},`${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 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{H as r,Rt as i,W as a}from"./dist-DOqbRmFj.js";import{t as o}from"./dist-CJqyWK6E.js";import{t as s}from"./api-C0I7spBl.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-CfaAvFkE.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 D}from"./index-DDu8nyO6.js";import{a as ee,o as te}from"./ChatTimelineView-Cg_kLK_U.js";var O=e(t(),1),k=n(),A=/@\[([^\]]+)\]\(gezel\\?:[^)\s]+\)/g;function j(e){return e.replace(A,(e,t)=>`@${t}`)}function M(e){return e===`New session`?`New thread`:e}function N(e){return!e||e===`New session`}function P(e,t,n){return e.completedAt?`done`:!n&&e.id===t?`active`:`pending`}var ne={done:`Signed off`,active:`Active`,pending:`Waiting its turn`};function F({steps:e,activeStepId:t,selectedStepId:n,onSelect:r,onAddStep:i,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?a(e,f):void 0}};return(0,k.jsx)(E,{variant:`bench`,steps:e,selectedStepId:n,onSelect:r,statusOf:e=>P(e,t,p),stepOf:e=>{let n=P(e,t,p),r=e.assignee??(e.suggestedGezelId?{kind:`gezel`,gezelId:e.suggestedGezelId}:null)??c??null,i,l,h;r?.kind===`user`?i=`You`:r?.kind===`gezel`&&(h=s.find(e=>e.id===r.gezelId),i=h?a(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,k.jsx)(b,{poppetje:h.poppetje,variant:`full`,size:26,svgId:`track-${e.id}`,...i?{title:i}:{}}):void 0,v=p&&n===`pending`?void 0:ne[n],y=e.assignee,x=y?.kind===`user`?`__user`:y?.kind===`gezel`?y.gezelId:`__inherit`,S=m(e),C=u?(0,k.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,k.jsx)(`option`,{value:`__inherit`,children:S?`inherit · ${S}`:`inherit from task`}),(0,k.jsx)(`option`,{value:`__user`,children:`you`}),s.map(e=>(0,k.jsx)(`option`,{value:e.id,children:!f&&e.role?`${e.name} · ${e.role}`:a(e,f)},e.id))]}):void 0;return{..._?{figure:_}:{},...C?{assigneeControl:C}:{},...i?{assigneeName:i}:{},...g?{assigneeRole:g}:{},...v?{statusWord:v}:{}}},onAddStep:i,busy:o,ariaLabel:`Task steps`,addLabel:`add a step`,...p?{terminal:{word:l===`complete`?`Complete`:`Canceled`,tone:l===`complete`?`complete`:`canceled`}}:{}})}var I=100;function L(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 re({status:e,sessionId:t}){let[n,r]=(0,O.useState)(!1),[i,a]=(0,O.useState)(!1),[o,l]=(0,O.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}%`,D=x===null?`${T} in this thread — nothing measured yet`:`This thread fills ${b?`about`:`at least`} ${S}% of its ${T}`,ee=async()=>{if(t){a(!0),l(null);try{await s.compactChatSession(t),r(!1)}catch(e){l(L(e))}finally{a(!1)}}};return(0,k.jsxs)(c,{open:n,onOpenChange:e=>{r(e),e||l(null)},children:[(0,k.jsx)(v,{asChild:!0,children:(0,k.jsxs)(`button`,{type:`button`,className:`context-meter${w?` context-meter-${w}`:``}`,"aria-label":`Thread context: ${D}`,title:D,children:[(0,k.jsx)(`span`,{className:`context-meter-ring-wrap`,children:(0,k.jsxs)(`svg`,{className:`context-meter-ring`,viewBox:`0 0 36 36`,"aria-hidden":`true`,children:[(0,k.jsx)(`circle`,{className:`context-meter-ring-bg`,cx:`18`,cy:`18`,r:`15.5`,fill:`none`,strokeWidth:`5`}),(0,k.jsx)(`circle`,{className:`context-meter-ring-fill`,cx:`18`,cy:`18`,r:`15.5`,fill:`none`,strokeWidth:`5`,pathLength:I,strokeDasharray:`${S} ${I-S}`,strokeDashoffset:`25`,strokeLinecap:`round`})]})}),(0,k.jsx)(`span`,{className:`context-meter-label`,children:E})]})}),(0,k.jsxs)(f,{className:`context-meter-popover`,side:`bottom`,align:`end`,children:[(0,k.jsx)(`div`,{className:`context-meter-popover-header`,children:`This thread’s context`}),(0,k.jsxs)(`dl`,{className:`context-meter-stats`,children:[g&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`dt`,{children:`Model`}),(0,k.jsx)(`dd`,{children:g})]}),(0,k.jsx)(`dt`,{children:`Window`}),(0,k.jsxs)(`dd`,{children:[y(u),` tokens`]}),(0,k.jsx)(`dt`,{children:`In use`}),(0,k.jsx)(`dd`,{children:_===void 0?`Not measured yet`:`${b?`~`:`at least `}${_.toLocaleString()} tokens (${S}%)`}),(0,k.jsx)(`dt`,{children:`Auto-compaction`}),(0,k.jsx)(`dd`,{children:C===void 0?`On`:`At ${C}% full`}),h!==void 0&&h>0&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`dt`,{children:`Compactions`}),(0,k.jsxs)(`dd`,{children:[h,` so far`]})]})]}),e.compactionFailed?(0,k.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,k.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,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`context-meter-action`,onClick:()=>void ee(),disabled:i,children:i?`Compacting…`:`Compact now`}),o&&(0,k.jsx)(`p`,{className:`context-meter-note context-meter-note-warn`,children:o})]})]})]})}var ie=150,ae=1e3,R=`draft:`,oe=`__NEW__`,z=`New thread`,B=`Untitled draft`;function se(){return(0,k.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,focusable:`false`,children:[(0,k.jsx)(`circle`,{cx:`7`,cy:`7`,r:`5.9`,stroke:`currentColor`,strokeWidth:`1.2`}),(0,k.jsx)(`path`,{d:`M7 4.4v5.2M4.4 7h5.2`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`})]})}var ce=(0,k.jsxs)(`span`,{className:`session-row session-row-action`,children:[(0,k.jsx)(se,{}),(0,k.jsx)(`span`,{className:`session-row-title`,children:z})]}),le=5,ue=`sent:`;function V({gezelId:e,projectId:t,sessionId:n,onSessionIdChange:a,onActiveSessionChange:o,onFreshThread:c,refreshKey:f,taskRef:v,stepId:y,autoPickNewest:b=!0,engineLabel:S,activeDraftId:C,onDraftSelect:w,draftScope:T,craftbookRef:E}){let[A,j]=(0,O.useState)([]),[M,P]=(0,O.useState)([]),[ne,F]=(0,O.useState)(new Map),[I,L]=(0,O.useState)(!1),[se,V]=(0,O.useState)([]),[de,H]=(0,O.useState)(new Map),G=(0,O.useRef)(null),ge=(0,O.useRef)(C);ge.current=C;let _e=(0,O.useRef)(async()=>{}),ve=(0,O.useRef)(null),K=`${e}:${t}:${v??``}`,[q,ye]=(0,O.useState)(null),J=(0,O.useCallback)(async()=>{let n=`${e}:${t}:${v??``}`;try{let r;if(v){let t=i(v);if(!t)return[];r=(await s.listTaskSessions(t.projectId,t.num)).sessions.filter(t=>t.gezelId===e)}else r=(await s.listChatSessions({gezelId:e,projectId:t})).sessions.filter(e=>!e.taskRef);let a=r.filter(e=>!e.archived);return j(a),ye(n),a}catch(n){return console.error(`[SessionSwitcher] list sessions failed`,{gezelId:e,projectId:t,taskRef:v,err:n}),[]}},[e,t,v]);(0,O.useEffect)(()=>{G.current=null,j([]),ye(null),J()},[J,f]);let Y=(0,O.useCallback)(e=>(e.taskRef??void 0)===(v??void 0)&&(e.craftbookRef??void 0)===(E??void 0)&&(e.scope??void 0)===(T??void 0),[v,E,T]),X=(0,O.useCallback)(async()=>{try{let{drafts:n}=await s.listPromptDrafts(t,{gezelId:e,status:`draft`}),r=n.filter(Y);P(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])}F(i)}catch{}},[t,e,Y]);_e.current=X,(0,O.useEffect)(()=>{X()},[X]),(0,O.useEffect)(()=>{let e=K;if(q!==e)return;if(n&&A.some(e=>e.id===n)){G.current=e;return}if(G.current===e)return;if(C){G.current=e;return}let t=M[0];if(!(A.length===0&&!t)){if(G.current=e,b&&A.length>0){a(A[0].id);return}t&&(a(void 0),w?.(t.id))}},[A,q,n,K,b,a,C,M,w]),(0,O.useEffect)(()=>{if(q!==K)return;let e=A.find(e=>e.id===n);n&&!e||o?.(e??null)},[A,q,n,K,o]),(0,O.useEffect)(()=>{if(q!==K||!n||A.some(e=>e.id===n))return;let e=`${K}:${n}`;ve.current!==e&&(ve.current=e,J())},[A,q,n,K,J]),(0,O.useEffect)(()=>{let n=new AbortController,r=null,i=!1,a=null,o=()=>{r!==null&&window.clearTimeout(r),r=window.setTimeout(()=>{r=null,J()},ie)},c=()=>{a!==null&&window.clearTimeout(a),a=window.setTimeout(()=>{a=null,_e.current()},ae)};return(async()=>{let r=250;for(;!i;){try{for await(let a of D({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===ge.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;H(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,J]);let be=(0,O.useCallback)(async()=>{L(!0);try{let r=await s.createPromptDraft(t,{gezelId:e,sessionId:n??null,...v?{taskRef:v}:{},...E?{craftbookRef:E}:{},...T?{scope:T}:{}});n?F(e=>{let t=new Map(e);return t.set(n,[r,...e.get(n)??[]]),t}):(P(e=>[r,...e.filter(e=>e.id!==r.id)]),a(void 0)),w?.(r.id)}finally{L(!1)}},[t,e,n,v,E,T,a,w]),xe=(0,O.useCallback)(()=>{w?.(void 0),a(void 0),c?.()},[w,a,c]),Se=(0,O.useCallback)(async(e,r)=>{L(!0);try{await s.deletePromptDraft(t,e),e===C&&w?.(void 0),r&&(await s.archiveChatSession(r),r===n&&a(void 0),await J()),await X()}finally{L(!1)}},[t,C,n,w,a,J,X]),Ce=(0,O.useCallback)(async()=>{if(!n){V([]);return}try{let{drafts:r}=await s.listPromptDrafts(t,{gezelId:e,sessionId:n,status:`sent`});V(r.filter(Y).slice(0,le))}catch{V([])}},[t,e,n,Y]),we=(0,O.useCallback)(async e=>{L(!0);try{let r=await s.duplicatePromptDraft(t,e,{sessionId:n??null});w?.(r.id),await X()}finally{L(!1)}},[t,n,w,X]),Te=(0,O.useCallback)(async e=>{L(!0);try{await s.archiveChatSession(e);let t=await J();e===n&&(w?.(void 0),a(t[0]?.id)),await X()}finally{L(!1)}},[n,J,X,a,w]),Ee=(0,O.useSyncExternalStore)(te,()=>C?ee(C):void 0),De=Ee===void 0?``:r(Ee),Oe=A.length>0,ke=M.length>0,Z=C&&!n&&!M.some(e=>e.id===C)?C:null,Ae=ke||Z!==null||A.some(e=>N(e.title)),je=A.some(e=>!N(e.title)),Me=e=>e.id===C&&De?{...e,title:De}:e,Ne=A.map(e=>{let t=(ne.get(e.id)??[]).map(Me),n=N(e.title),r=n?t[0]:void 0;return{s:e,drafts:t,namer:r,unsent:n,at:W(e,r)}}),Pe=(e,t)=>e.at<t.at?1:e.at>t.at?-1:0,Fe=[...M.map(e=>{let t=Me(e);return{kind:`draft`,draft:t,at:t.updatedAt}}),...Ne.filter(e=>e.unsent).map(e=>({kind:`thread`,...e}))].sort(Pe),Ie=Ne.filter(e=>!e.unsent).sort(Pe),Le=(e,t)=>(0,k.jsx)(`button`,{type:`button`,className:`session-row-archive`,"aria-label":`Archive thread ${U(e,t)}`,title:`Hide this thread from the list. It stays on disk.`,disabled:I,onPointerDown:e=>e.stopPropagation(),onPointerUp:e=>e.stopPropagation(),onClick:t=>{t.preventDefault(),t.stopPropagation(),Te(e.id)},children:`Archive`}),Re=(e,t,n)=>(0,k.jsx)(`button`,{type:`button`,className:`session-row-delete`,"aria-label":`Delete draft ${t}`,title:`Throw this message away`,disabled:I,onPointerDown:e=>e.stopPropagation(),onPointerUp:e=>e.stopPropagation(),onClick:t=>{t.preventDefault(),t.stopPropagation(),Se(e,n)},children:`×`}),ze=(e,t)=>(0,k.jsx)(p,{value:`${R}${e.id}`,textValue:he(e),trailing:Re(e.id,e.title||B),children:me(e,t)},e.id),Be=({s:e,drafts:t,namer:n,unsent:r})=>(0,k.jsxs)(O.Fragment,{children:[(0,k.jsx)(p,{value:e.id,textValue:pe(e,S,n,r),trailing:n?Re(n.id,n.title||B,t.length<=1?e.id:void 0):Le(e,n),children:fe(e,S,n,r)}),t.filter(e=>e.id!==n?.id).map(e=>ze(e,{child:!0,mark:!r}))]},e.id),Ve=De||(Ee===void 0?z:B),He=C&&!n?`${R}${C}`:n&&Oe?n:``,Q=He===``,Ue=Ae||je,$=n?A.find(e=>e.id===n):void 0,We=$?.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,Ge=n?de.get(n):void 0,Ke=Ge?{...We,...Ge}:We;return(0,k.jsxs)(`div`,{className:`gezel-chat-session-header`,children:[(0,k.jsxs)(u,{value:He,onOpenChange:e=>{e&&Ce()},onValueChange:e=>{if(e){if(e.startsWith(ue)){we(e.slice(5));return}if(e===oe){xe();return}if(e.startsWith(R)){let t=e.slice(6),r=[...ne].find(([,e])=>e.some(e=>e.id===t))?.[0];r!==n&&a(r),w?.(t);return}w?.(void 0),a(e)}},disabled:I||Q&&!Ue,children:[(0,k.jsx)(h,{className:`gezel-chat-session-select`,children:(0,k.jsx)(m,{placeholder:z})}),(0,k.jsxs)(g,{className:`gezel-chat-session-menu`,children:[!Q&&(0,k.jsx)(p,{value:oe,textValue:z,children:ce}),!Q&&Ue&&(0,k.jsx)(d,{}),Ae&&(0,k.jsxs)(l,{children:[(0,k.jsx)(_,{children:`Not sent yet`}),Z&&(0,k.jsx)(p,{value:`${R}${Z}`,textValue:Ve,trailing:Re(Z,Ve),children:(0,k.jsx)(`span`,{className:`session-row`,children:(0,k.jsx)(`span`,{className:`session-row-title`,children:Ve})})}),Fe.map(e=>e.kind===`draft`?ze(e.draft,{mark:!1}):Be(e))]}),Ae&&je&&(0,k.jsx)(d,{}),je&&(0,k.jsxs)(l,{children:[(0,k.jsx)(_,{children:`Threads`}),Ie.map(Be)]}),se.length>0&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(d,{}),(0,k.jsxs)(l,{children:[(0,k.jsx)(_,{children:`Recently sent`}),se.map(e=>(0,k.jsx)(p,{value:`${ue}${e.id}`,textValue:`${e.title||B} · use again`,children:(0,k.jsxs)(`span`,{className:`session-row session-row-child`,children:[(0,k.jsx)(`span`,{className:`session-row-title`,children:e.title||B}),(0,k.jsx)(`span`,{className:`session-row-meta`,children:` · use again · sent ${x(e.sentAt??e.updatedAt)}`})]})},e.id))]})]})]})]}),(0,k.jsx)(`button`,{type:`button`,className:`gezel-chat-session-btn`,onClick:xe,disabled:I||Q,title:Q?`Already on a new thread`:`Start a new thread`,children:`+ New thread`}),(0,k.jsx)(re,{status:Ke,sessionId:n}),n&&(0,k.jsx)(`button`,{type:`button`,className:`gezel-chat-session-btn`,onClick:()=>void be(),disabled:I,title:`Start another message in this thread and keep the one you have`,children:`+ Draft`})]})}function de(e){let t=[],n=0,r=0;for(let i of e.matchAll(A)){let a=i.index??0;a>n&&t.push(e.slice(n,a)),t.push((0,k.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 H(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 U(e,t){return t?t.title||B:M(e.title)}function W(e,t){return t&&t.updatedAt>e.lastActivityAt?t.updatedAt:e.lastActivityAt}function fe(e,t,n,r){let i=W(e,n),a=r?` · ${x(i)}`:` · ${x(i)} · ${H(e,t)}`;return(0,k.jsxs)(`span`,{className:`session-row`,children:[(0,k.jsx)(`span`,{className:`session-row-title`,children:de(U(e,n))}),(0,k.jsx)(`span`,{className:`session-row-meta`,title:S(i),children:a})]})}function pe(e,t,n,r){let i=`${j(U(e,n))} · ${x(W(e,n))}`;return r?i:`${i} · ${H(e,t)}`}function me(e,t){return(0,k.jsxs)(`span`,{className:t?.child?`session-row session-row-child`:`session-row`,children:[(0,k.jsx)(`span`,{className:`session-row-title`,children:e.title||B}),t?.mark!==!1&&(0,k.jsx)(`span`,{className:`session-row-draft-mark`,children:`draft`}),(0,k.jsx)(`span`,{className:`session-row-meta`,title:S(e.updatedAt),children:` · ${x(e.updatedAt)}`})]})}function he(e){return`${e.title||B} · draft · ${x(e.updatedAt)}`}export{j as a,M as i,F as n,P as r,V as t};