@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.
- package/dist/NOTICE.md +3 -3
- package/dist/bin/gezeld.js +8471 -5311
- package/dist/handboek-content/technical/building-connected-apps-with-gezel-app-sdk.md +78 -0
- package/dist/handboek-content/whats-new/{1.26250.md → 1.26251.md} +5 -5
- package/dist/index-store/static-index-worker.js +160 -51
- package/dist/index.d.ts +416 -71
- package/dist/index.js +8465 -5305
- package/dist/memory/embed-worker.js +132 -4
- package/dist/memory/image-embed-worker.js +14 -5
- package/dist/providers/mlx/python/cache_persist.py +52 -8
- package/dist/providers/mlx/python/gezel_mlx_server.py +44 -1
- package/dist/providers/mlx/python/qwen4_ple.py +159 -0
- package/dist/providers/mlx/python/spec_decode.py +73 -31
- package/dist/providers/mlx/python/tool_call_stream.py +10 -2
- package/dist/providers/mlx/python/tool_grammar.py +16 -0
- package/dist/ui/assets/{AmbientDashboardCard-DcVHxEdC.js → AmbientDashboardCard-_xnAQGnk.js} +1 -1
- package/dist/ui/assets/{AudioEngineSettings-BFM2S1mm.js → AudioEngineSettings-CgXgbX0i.js} +1 -1
- package/dist/ui/assets/{BenchmarksView-84-YeULA.js → BenchmarksView-BlExZpYA.js} +1 -1
- package/dist/ui/assets/CatalogBrowser-DYXUZQ_t.js +1 -0
- package/dist/ui/assets/{ChannelsSettings-7NAVUk4k.js → ChannelsSettings-EH27HcqZ.js} +1 -1
- package/dist/ui/assets/ChatTimelineView-Dn1TNyVn.js +7 -0
- package/dist/ui/assets/{ConnectedAppsPanel-CIgF4Q3R.js → ConnectedAppsPanel-BROry-Y0.js} +1 -1
- package/dist/ui/assets/CraftbookEditor-B2RNJnFf.js +1 -0
- package/dist/ui/assets/{CraftbookScriptEditorView-Ck5tzj3Y.js → CraftbookScriptEditorView-B-vySmHP.js} +1 -1
- package/dist/ui/assets/{CraftbookTabContent-BWg7FhK_.js → CraftbookTabContent-BW_2KC89.js} +1 -1
- package/dist/ui/assets/{CraftbookToolsetSetup-EuFOiUzR.js → CraftbookToolsetSetup-J7rEa835.js} +1 -1
- package/dist/ui/assets/{CraftbooksView-BIzQ1VVn.js → CraftbooksView-BjBUWPGF.js} +1 -1
- package/dist/ui/assets/DiffpackReviewView-CD4qJmgT.js +1 -0
- package/dist/ui/assets/DocumentDetail-SYozruTJ.js +1 -0
- package/dist/ui/assets/DocumentsView-DE7eL49Z.js +1 -0
- package/dist/ui/assets/{Ds4Settings-9soZCSeO.js → Ds4Settings-DGzc7JcD.js} +1 -1
- package/dist/ui/assets/{EmbeddedChat-Cce7nxXT.js → EmbeddedChat-D92TaJQ8.js} +1 -1
- package/dist/ui/assets/{FaceRecognitionCard-BVZyOwB8.js → FaceRecognitionCard-CB1Dt9X4.js} +1 -1
- package/dist/ui/assets/FileMapView-kVBG22FU.js +1 -0
- package/dist/ui/assets/FoldersSettings-BWFQU5B4.js +1 -0
- package/dist/ui/assets/GezelDetail-Br4v42Nv.js +1 -0
- package/dist/ui/assets/{GezelJsonEditor-DXXt165-.js → GezelJsonEditor-B9XEiW5Y.js} +1 -1
- package/dist/ui/assets/GezellenView-DheEBAy4.js +1 -0
- package/dist/ui/assets/{GildeUpdatesCard-CtY8mUTA.js → GildeUpdatesCard-BeIYv09f.js} +1 -1
- package/dist/ui/assets/{GithubSignInChip-DT3l6E0Q.js → GithubSignInChip-eEGCe9ar.js} +1 -1
- package/dist/ui/assets/{HandboekMediaProvider-ByJ4NAzz.js → HandboekMediaProvider-D0zcbbpf.js} +1 -1
- package/dist/ui/assets/HandboekView-p0BZT1rH.js +1 -0
- package/dist/ui/assets/{HistoryView-CkinzFEC.js → HistoryView-CKWcWW-Y.js} +1 -1
- package/dist/ui/assets/{HomeView-DNBrQnwy.js → HomeView-b_TT5oV3.js} +1 -1
- package/dist/ui/assets/{ImageEngineSettings-BfM9HSd_.js → ImageEngineSettings-CJfk4OJ4.js} +1 -1
- package/dist/ui/assets/{ImageRecognitionSettings-CaSQu5Br.js → ImageRecognitionSettings-DzbvZk5S.js} +1 -1
- package/dist/ui/assets/{IncompleteDownloads-C36lTCMG.js → IncompleteDownloads-C8_XyP8O.js} +1 -1
- package/dist/ui/assets/{KnowledgeCatalogsCard-CK9bqdf6.js → KnowledgeCatalogsCard-CHopG_j-.js} +1 -1
- package/dist/ui/assets/KnowledgeView-CXNKZUJq.js +1 -0
- package/dist/ui/assets/{LlamaCppSettings-CdNMHBbp.js → LlamaCppSettings-ohcM7kes.js} +1 -1
- package/dist/ui/assets/{MarkdownField-Dugmfr_e.js → MarkdownField-BX0qsaFq.js} +1 -1
- package/dist/ui/assets/{MemoriesTree-CgFqUNEr.js → MemoriesTree-BPj5Rod8.js} +1 -1
- package/dist/ui/assets/{MicrophoneSettings-DzDe9y1q.js → MicrophoneSettings-CWjeYnfI.js} +1 -1
- package/dist/ui/assets/MlxSettings-Dq6dRpcl.js +1 -0
- package/dist/ui/assets/{ModelPicker-BVkJhNAH.js → ModelPicker-0Ue-eEKj.js} +1 -1
- package/dist/ui/assets/NewPathDialog-BhAZm9dp.js +1 -0
- package/dist/ui/assets/{NewScriptDialog-TEAd0KLl.js → NewScriptDialog-DuryIe50.js} +1 -1
- package/dist/ui/assets/NewTaskDialog-BX24flMY.js +2 -0
- package/dist/ui/assets/{OllamaSettings-CPy2vxyZ.js → OllamaSettings-Boj8Nd1G.js} +1 -1
- package/dist/ui/assets/ProjectChat-Dhw_M5bq.js +5 -0
- package/dist/ui/assets/ProjectConnectionsTab-BwpMQNrg.js +1 -0
- package/dist/ui/assets/{ProjectGitStatusBar-BgHZ2ijN.js → ProjectGitStatusBar-BORGYx5l.js} +1 -1
- package/dist/ui/assets/{ProjectGithubView-BV2uTNU0.js → ProjectGithubView-CTP1BOMv.js} +1 -1
- package/dist/ui/assets/{ProjectMailTab-DLtJdXSL.js → ProjectMailTab-qFmAeV3M.js} +1 -1
- package/dist/ui/assets/{ProjectOverviewView-ZMs9nL5N.js → ProjectOverviewView-Cq1FsoaT.js} +1 -1
- package/dist/ui/assets/{ProjectTimeline-CTPcn4Kc.js → ProjectTimeline-Cqae2Z92.js} +1 -1
- package/dist/ui/assets/ProjectsView-D0uJjUB-.js +7 -0
- package/dist/ui/assets/{RecommendedBadge-iUoisQBi.js → RecommendedBadge-CN1jEmSn.js} +1 -1
- package/dist/ui/assets/{RemoteServersPanel-CTVJ0IRh.js → RemoteServersPanel-CMakvCCM.js} +1 -1
- package/dist/ui/assets/{ScriptEditorTabs-CCDFZjdC.js → ScriptEditorTabs-st6dJePd.js} +2 -2
- package/dist/ui/assets/{ScriptEditorView-CergLqKj.js → ScriptEditorView-BkySh57_.js} +2 -2
- package/dist/ui/assets/{ScriptsView-v7ckdhDi.js → ScriptsView-7uPKwjDB.js} +1 -1
- package/dist/ui/assets/{SecurityComplianceSettings-Bd0-66Gs.js → SecurityComplianceSettings-Tsv_pXfy.js} +1 -1
- package/dist/ui/assets/SessionSwitcher-D0fSeeHO.js +1 -0
- package/dist/ui/assets/SettingsView-cli_z8ZW.js +3 -0
- package/dist/ui/assets/{SquisqIntegration-C5l_OPvD.js → SquisqIntegration-BTZ1kBlg.js} +1 -1
- package/dist/ui/assets/{StorageCleanupDialog-3kv9-2mT.js → StorageCleanupDialog-CDBjl8JQ.js} +1 -1
- package/dist/ui/assets/{StorageUsageCard-7sWTrZFa.js → StorageUsageCard-DXY1j0dZ.js} +1 -1
- package/dist/ui/assets/TaskTabContent-C0P681SL.js +1 -0
- package/dist/ui/assets/TasksView-Ddwz10ri.js +1 -0
- package/dist/ui/assets/{TerminalCodeEditor-ChmdzmCz.js → TerminalCodeEditor-BkNQ6QoQ.js} +2 -2
- package/dist/ui/assets/ToolsetsEditor-KVigemfL.js +8 -0
- package/dist/ui/assets/{TransformToolbarButton-gzIxUBH7.js → TransformToolbarButton-8wfJR1bO.js} +2 -2
- package/dist/ui/assets/{UnrecognizedModels-0hptopv6.js → UnrecognizedModels-BzdU1clO.js} +1 -1
- package/dist/ui/assets/{VideoEngineSettings-BdNzCEdR.js → VideoEngineSettings-f79ff57u.js} +1 -1
- package/dist/ui/assets/{WorkspaceIndexPane-DnsOO916.js → WorkspaceIndexPane-fu5V6o1W.js} +1 -1
- package/dist/ui/assets/{api-C0I7spBl.js → api-CmrgM5Rf.js} +1 -1
- package/dist/ui/assets/chat-thread-memory-8MCtb17Q.js +1 -0
- package/dist/ui/assets/{chunk-6ECMNUIP-BvCy0HUI.js → chunk-6ECMNUIP-D5AA6ozp.js} +1 -1
- package/dist/ui/assets/{chunk-A6N6IN3I-ofeM4l8g.js → chunk-A6N6IN3I-BpxihS5H.js} +1 -1
- package/dist/ui/assets/{chunk-ATWVNF7D-CYuW1Yc6.js → chunk-ATWVNF7D-CKIWh7bN.js} +1 -1
- package/dist/ui/assets/{chunk-UBFT2CDQ-FexGDigd.js → chunk-CW24CH7I-BD0FIooX.js} +1 -1
- package/dist/ui/assets/{chunk-DXYWKZ52-zxe8pjH4.js → chunk-DXYWKZ52-DMKPZnpo.js} +1 -1
- package/dist/ui/assets/chunk-IIQYS2YH-BtDJt4Xr.js +1 -0
- package/dist/ui/assets/{chunk-KGWT454C-v5-l6U5m.js → chunk-KGWT454C-DsQOBuLg.js} +1 -1
- package/dist/ui/assets/{chunk-Q77KNJIN-BLuPdsQF.js → chunk-Q77KNJIN-BdWizq9s.js} +1 -1
- package/dist/ui/assets/{chunk-USU6HTKB-B_p-YcDp.js → chunk-USU6HTKB-DyGZplh4.js} +1 -1
- package/dist/ui/assets/{chunk-UXEANVBI-Bt0kX-0Z.js → chunk-UXEANVBI-BUBXvqyE.js} +1 -1
- package/dist/ui/assets/{chunk-O7JILDEF-CqcO1qaI.js → chunk-X7BNDUNI-D14WIvlD.js} +2 -2
- package/dist/ui/assets/{chunk-AE3IUKMM-mZjzzO8Z.js → chunk-ZSU5DJLX-CrjQf-vs.js} +1 -1
- package/dist/ui/assets/{container-BI8hxN1N.js → container-iFj1r6Hk.js} +1 -1
- package/dist/ui/assets/csv-Di411Mv-.js +1 -0
- package/dist/ui/assets/data-Q05qqAp4.js +1 -0
- package/dist/ui/assets/{dist-APSIK7H3.js → dist-1FNFiksd.js} +3 -3
- package/dist/ui/assets/dist-BMZhqfv7.js +2 -0
- package/dist/ui/assets/dist-CE5CbmDb.js +225 -0
- package/dist/ui/assets/doc-BHcGsJZd.js +587 -0
- package/dist/ui/assets/{document-import-DPK4r8Am.js → document-import-B2Ya6sbf.js} +1 -1
- package/dist/ui/assets/{docx-DRLuCTaC.js → docx-B8Pwz5Ih.js} +1 -1
- package/dist/ui/assets/{epub-a0p2Xb1b.js → epub-BQ4g8Q9j.js} +1 -1
- package/dist/ui/assets/{export-options-BqYFyzWx.js → export-options-Dylv69b3.js} +1 -1
- package/dist/ui/assets/file-browser-BLOPfnS0.js +5 -0
- package/dist/ui/assets/{html-BbQNmJ5X.js → html-BnA7qFwq.js} +1 -1
- package/dist/ui/assets/icons-CyM7Cg4E.js +1 -0
- package/dist/ui/assets/index-DW6qHqhU.css +1 -0
- package/dist/ui/assets/index-DivKnJyx.js +36 -0
- package/dist/ui/assets/{mail-link-CWfsP5Aq.js → mail-link-NtlcX5OE.js} +1 -1
- package/dist/ui/assets/{markdown-ryKA_OmY.js → markdown-CLKH_zzl.js} +1 -1
- package/dist/ui/assets/markdown-baseline-0dqv9qbV.js +1 -0
- package/dist/ui/assets/materialize-G4WC5UG3-xq2dcwS8.js +1 -0
- package/dist/ui/assets/{monaco-base-C0VTMpv-.js → monaco-base-BSvdAweA.js} +1 -1
- package/dist/ui/assets/{monaco-setup-CX8q88c5.js → monaco-setup-CT7LZ0o_.js} +1 -1
- package/dist/ui/assets/{new-project-meta-ZmDPGYzC.js → new-project-meta-5Y9Blozr.js} +1 -1
- package/dist/ui/assets/outside-in-Msmhxf_U.js +3 -0
- package/dist/ui/assets/{pdf-BHrygJa5.js → pdf-C4BhW3zg.js} +1 -1
- package/dist/ui/assets/{pending-drafts-27ujtQxX.js → pending-drafts-BD227X9H.js} +1 -1
- package/dist/ui/assets/{poppetje-CfaAvFkE.js → poppetje-DvCJO36y.js} +3 -3
- package/dist/ui/assets/{pptx-nDW64jAN.js → pptx-B6uaM2s7.js} +3 -3
- package/dist/ui/assets/{run-export-86KzLZ7R.js → run-export-TscWwR6y.js} +2 -2
- package/dist/ui/assets/{standalone-source-7QdiNsDW.js → standalone-source-Cw9SF7Zk.js} +1 -1
- package/dist/ui/assets/storage-Cmhlwx70.js +1 -0
- package/dist/ui/assets/styles-BjDaWeMA.css +1 -0
- package/dist/ui/assets/styles-CqO-rmOt.js +554 -0
- package/dist/ui/assets/{terminal-monaco-setup-Bar-sYKd.js → terminal-monaco-setup-me523-j-.js} +1 -1
- package/dist/ui/assets/{transform-CmAXy0Ck.js → transform-DxJCwK68.js} +1 -1
- package/dist/ui/assets/{use-local-model-manager-D1yiurrC.js → use-local-model-manager-8wvk-I-y.js} +1 -1
- package/dist/ui/assets/{useCompactLayout-BDtPQcDh.js → useCompactLayout-cm4E9Vja.js} +0 -0
- package/dist/ui/assets/{useCopilotAvailability-BHOfHrfT.js → useCopilotAvailability-D9hglSH_.js} +1 -1
- package/dist/ui/assets/{useDiffpacks-B0kYhlWQ.js → useDiffpacks-1BN2XJWg.js} +1 -1
- package/dist/ui/assets/{useGitSync-DOt-ODiw.js → useGitSync-7m9YA7h5.js} +1 -1
- package/dist/ui/assets/{useShowWorkInProgressFeatures-BtpredG7.js → useShowWorkInProgressFeatures-D6QOaTUT.js} +1 -1
- package/dist/ui/assets/{useTotalRamBytes-B8NFM27w.js → useTotalRamBytes-Durk383U.js} +1 -1
- package/dist/ui/assets/{xlsx-B_pu1ZvY.js → xlsx-BbHA9bxA.js} +1 -1
- package/dist/ui/index.html +15 -15
- package/package.json +12 -11
- package/dist/ui/assets/CatalogBrowser-7_jHy5Q3.js +0 -1
- package/dist/ui/assets/ChatTimelineView-Cg_kLK_U.js +0 -7
- package/dist/ui/assets/CraftbookEditor-BKAIsnXv.js +0 -1
- package/dist/ui/assets/DiffpackReviewView-B2a3zgE-.js +0 -1
- package/dist/ui/assets/DocumentDetail-GCYhwQqV.js +0 -1
- package/dist/ui/assets/DocumentsView-Cm3RaQ5N.js +0 -1
- package/dist/ui/assets/FileMapView-BKJovLcL.js +0 -1
- package/dist/ui/assets/FoldersSettings-CuJd2JdE.js +0 -1
- package/dist/ui/assets/GezelDetail-D_KIPDhQ.js +0 -1
- package/dist/ui/assets/GezellenView-BOOW1QQU.js +0 -1
- package/dist/ui/assets/HandboekView-gRzJcIbJ.js +0 -1
- package/dist/ui/assets/KnowledgeView-DJ3cJVHA.js +0 -1
- package/dist/ui/assets/MlxSettings-45mBFHbA.js +0 -1
- package/dist/ui/assets/NewTaskDialog-CIXVunZn.js +0 -2
- package/dist/ui/assets/ProjectChat-BiJRweob.js +0 -5
- package/dist/ui/assets/ProjectConnectionsTab-CQgaIzuv.js +0 -1
- package/dist/ui/assets/ProjectsView-BUdR76n6.js +0 -7
- package/dist/ui/assets/SessionSwitcher-BgZqyiRn.js +0 -1
- package/dist/ui/assets/SettingsView-DLhOYiR5.js +0 -3
- package/dist/ui/assets/TaskTabContent-CG2KmfwV.js +0 -1
- package/dist/ui/assets/TasksView-Dy5Ue4zS.js +0 -1
- package/dist/ui/assets/ToolsetsEditor-J9XxQ5Ms.js +0 -8
- package/dist/ui/assets/chat-thread-memory-CI2-giEq.js +0 -1
- package/dist/ui/assets/chunk-IIQYS2YH-DEkyBlHg.js +0 -1
- package/dist/ui/assets/csv-B0D9jJG2.js +0 -1
- package/dist/ui/assets/data-BIL84EaT.js +0 -1
- package/dist/ui/assets/dist-CJqyWK6E.js +0 -2
- package/dist/ui/assets/dist-DOqbRmFj.js +0 -225
- package/dist/ui/assets/doc-C2Ph2FWI.js +0 -584
- package/dist/ui/assets/document-companion-aDThLOwl.js +0 -1
- package/dist/ui/assets/file-browser-DVyWN0LD.js +0 -5
- package/dist/ui/assets/icons-DWaUNQbT.js +0 -1
- package/dist/ui/assets/index-DDu8nyO6.js +0 -34
- package/dist/ui/assets/index-DEDUSiCx.css +0 -1
- package/dist/ui/assets/markdown-baseline-9B52XlX2.js +0 -1
- package/dist/ui/assets/materialize-G4WC5UG3-BlZQe-88.js +0 -1
- package/dist/ui/assets/outside-in-BmIIeMid.js +0 -3
- package/dist/ui/assets/storage-B-vhjyV2.js +0 -1
- package/dist/ui/assets/styles-BvkZd-EV.js +0 -550
- package/dist/ui/assets/styles-IQ4adxWr.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./dist-CJqyWK6E.js";import{t as i}from"./api-C0I7spBl.js";import{i as a,n as o,r as s}from"./Tabs-jE0Z5Tzd.js";import"./primitives-CWrGZpPI.js";import{n as c,t as l}from"./relative-time-B2kBaekd.js";import{t as u}from"./ConfirmDialog-Dt1ed4Fh.js";import{r as d,t as f}from"./GitDiffView-DrDrSeBb.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./gitCopy-Dcjz17cJ.js";import{t as y}from"./MarkdownField-Dugmfr_e.js";import{n as b,r as x,t as S}from"./useGitSync-DOt-ODiw.js";import{t as C}from"./GithubSignInChip-DT3l6E0Q.js";var w=e(t(),1),T=n();function E({review:e,onCancel:t,disabled:n}){let[r,i]=(0,w.useState)(!1),a=e.needsAttention===!0,o=e.assigneeName??`A reviewer`,s=e.stepsTotal&&e.stepsTotal>0?`step ${Math.min((e.stepsComplete??0)+1,e.stepsTotal)} of ${e.stepsTotal}`:void 0;return(0,T.jsxs)(`div`,{className:`gh-review-status-card ${a?`gh-review-status-attention`:`gh-review-status-running`}`,children:[(0,T.jsxs)(`div`,{className:`gh-review-status-main`,children:[(0,T.jsxs)(`strong`,{children:[g(e.kind),` · `,e.branch]}),(0,T.jsx)(`span`,{children:a?v.reviewNeedsAttention:(0,T.jsxs)(T.Fragment,{children:[o,` `,v.reviewRunning]})}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(e.createdAt),children:[p(e.filesChanged,`file`),s?` · ${s}`:``,e.activeStepName?` · ${e.activeStepName}`:``,` · started ${m(e.createdAt)}`]})]}),(0,T.jsx)(`button`,{type:`button`,className:`gh-review-stop small`,onClick:()=>i(!0),disabled:n,children:v.reviewStop}),(0,T.jsx)(u,{open:r,title:v.reviewStopTitle,message:v.reviewStopBody,confirmLabel:v.reviewStopConfirm,danger:!0,onConfirm:()=>{i(!1),t(e.id)},onCancel:()=>i(!1)})]})}var D=()=>{};function O({projectId:e,reviews:t,busy:n,changesCount:r,branch:a,defaultBranch:o,onStart:s,onCancel:c}){let u=t.filter(e=>e.status===`running`),d=t.filter(e=>e.status!==`running`),f=u.some(e=>e.kind===`commit`),h=u.some(e=>e.kind===`pr`),[_,b]=(0,w.useState)(null),x=(0,w.useMemo)(()=>d.find(e=>e.id===_)??d.find(e=>e.status===`complete`)??null,[d,_]),[S,C]=(0,w.useState)(null);(0,w.useEffect)(()=>{if(!x||x.status!==`complete`){C(null);return}let t=!1;return i.readProjectArtifact(e,x.reportPath).then(e=>{t||C({id:x.id,content:e.content})}).catch(()=>{t||C({id:x.id,content:null})}),()=>{t=!0}},[e,x]);let O=o?`Checks everything on ${a??`this branch`} against ${o}.`:v.reviewPrHint;return(0,T.jsxs)(`div`,{className:`gh-review-layout`,children:[(0,T.jsxs)(`div`,{className:`gh-review-rail`,children:[(0,T.jsxs)(`div`,{className:`gh-review-kickoff-row`,children:[(0,T.jsxs)(`div`,{className:`gh-review-card`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:()=>s(`commit`),disabled:n!==``||f||r===0,children:n===`start-commit`?`Starting…`:`✨ ${v.reviewCommitButton}`}),(0,T.jsx)(`p`,{className:`muted small`,children:r===0?v.reviewNothingCommit:v.reviewCommitHint})]}),(0,T.jsxs)(`div`,{className:`gh-review-card`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:()=>s(`pr`),disabled:n!==``||h,children:n===`start-pr`?`Starting…`:`✨ ${v.reviewPrButton}`}),(0,T.jsx)(`p`,{className:`muted small`,children:O})]})]}),u.map(e=>(0,T.jsx)(E,{review:e,onCancel:c,disabled:n!==``},e.id)),(0,T.jsxs)(`div`,{className:`gh-review-history`,children:[d.length===0&&u.length===0&&(0,T.jsx)(`p`,{className:`muted`,children:v.reviewHistoryEmpty}),d.map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`gh-review-history-item${x?.id===e.id?` is-selected`:``}`,onClick:()=>b(e.id),children:[(0,T.jsx)(`span`,{className:`gh-review-outcome-chip gh-review-outcome-${e.status}`,children:e.status===`complete`?`Reviewed`:e.status===`canceled`?`Stopped`:`Issue`}),(0,T.jsxs)(`span`,{className:`gh-review-history-title`,children:[g(e.kind),` · `,e.branch]}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(e.settledAt??e.createdAt),children:[p(e.filesChanged,`file`),` · `,m(e.settledAt??e.createdAt)]})]},e.id))]})]}),(0,T.jsx)(`div`,{className:`gh-review-report`,children:x&&x.status===`complete`?S?.id===x.id?S.content===null?(0,T.jsx)(`p`,{className:`muted`,children:v.reviewReportMissing}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`gh-review-report-header`,children:[(0,T.jsx)(`code`,{className:`gh-changes-diff-path`,title:x.reportPath,children:x.reportPath}),(0,T.jsx)(`button`,{type:`button`,className:`small`,onClick:()=>window.dispatchEvent(new CustomEvent(`gezel:open-file`,{detail:{projectId:e,path:x.reportPath,source:`artifacts`}})),children:v.reviewOpenInArtifacts})]}),(0,T.jsx)(y,{value:S.content,readOnly:!0,onCommit:D},`${x.id}:${x.reportPath}`)]}):(0,T.jsx)(`p`,{className:`muted`,children:v.reviewReportLoading}):(0,T.jsx)(`p`,{className:`placeholder`,children:u.length>0?`The report will appear here when the review finishes.`:`Pick a finished review to read its report.`})})]})}function k({projectId:e,path:t,kind:n,busy:r,onResolve:a}){let[o,s]=(0,w.useState)(null),[c,l]=(0,w.useState)(null),[u,d]=(0,w.useState)({step:`idle`});(0,w.useEffect)(()=>{s(null),l(null),d({step:`idle`});let n=!1;return i.getProjectGitConflictVersions(e,t).then(e=>{n||s(e)}).catch(e=>{n||l(e instanceof Error?e.message:String(e))}),()=>{n=!0}},[e,t]);let f=async()=>{d({step:`combining`});try{let n=await i.aiResolveProjectGitConflict(e,t);d({step:`preview`,content:n.merged})}catch(e){l(e instanceof Error?e.message:String(e)),d({step:`idle`})}};if(c)return(0,T.jsx)(`p`,{className:`error gh-conflict-error`,children:c});if(!o)return(0,T.jsx)(`p`,{className:`muted gh-conflict-loading`,children:`Loading…`});let p=!o.binary&&!o.tooLarge&&o.ours!==void 0&&o.theirs!==void 0;return u.step===`combining`?(0,T.jsx)(`p`,{className:`muted gh-conflict-loading`,children:v.conflictAiBusy}):u.step===`preview`||u.step===`editing`?(0,T.jsxs)(`div`,{className:`gh-conflict-ai-preview`,children:[(0,T.jsx)(`h4`,{children:v.conflictAiPreviewTitle}),u.step===`editing`?(0,T.jsx)(`textarea`,{className:`gh-conflict-ai-editor`,value:u.content,onChange:e=>d({step:`editing`,content:e.target.value}),"aria-label":`Edit the combined version`}):(0,T.jsx)(`pre`,{className:`gh-conflict-content`,children:u.content}),(0,T.jsxs)(`div`,{className:`gh-conflict-actions`,children:[(0,T.jsx)(`button`,{type:`button`,className:`primary`,disabled:r,onClick:()=>void a(`custom`,u.content),children:v.conflictAiUse}),u.step===`preview`?(0,T.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>d({step:`editing`,content:u.content}),children:v.conflictAiEdit}):null,(0,T.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>d({step:`idle`}),children:v.conflictAiBack})]})]}):(0,T.jsxs)(`div`,{className:`gh-conflict-file`,children:[(o.binary||o.tooLarge)&&(0,T.jsx)(`p`,{className:`muted small`,children:o.binary?`This file isn't text, so it can't be combined — pick one version.`:`This file is too large to preview — pick one version.`}),(0,T.jsxs)(`section`,{className:`gh-conflict-card`,children:[(0,T.jsxs)(`header`,{children:[(0,T.jsx)(`strong`,{children:v.conflictMineTitle}),n===`deleted-by-us`&&(0,T.jsx)(`span`,{className:`muted small`,children:`You deleted this file`})]}),o.ours!==void 0&&!o.binary&&!o.tooLarge&&(0,T.jsx)(`pre`,{className:`gh-conflict-content`,children:o.ours}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,disabled:r,onClick:()=>void a(`mine`),children:n===`deleted-by-us`?`Keep my version (stays deleted)`:v.conflictMineButton})]}),(0,T.jsxs)(`section`,{className:`gh-conflict-card`,children:[(0,T.jsxs)(`header`,{children:[(0,T.jsx)(`strong`,{children:v.conflictTheirsTitle}),n===`deleted-by-them`&&(0,T.jsx)(`span`,{className:`muted small`,children:`GitHub deleted this file`})]}),o.theirs!==void 0&&!o.binary&&!o.tooLarge&&(0,T.jsx)(`pre`,{className:`gh-conflict-content`,children:o.theirs}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,disabled:r,onClick:()=>void a(`theirs`),children:n===`deleted-by-them`?`Keep GitHub's version (deletes it)`:v.conflictTheirsButton})]}),p&&(0,T.jsx)(`div`,{className:`gh-conflict-ai-cta`,children:(0,T.jsxs)(`button`,{type:`button`,className:`gh-conflict-ai-button`,disabled:r,onClick:f,children:[`✨ `,v.conflictAiButton]})})]})}var A={mine:`Kept yours`,theirs:`Kept GitHub's`,combined:`Combined`};function j({projectId:e,resumed:t,showToast:n,onFinished:r,onExited:a}){let[o,s]=(0,w.useState)(null),[c,l]=(0,w.useState)(new Map),[d,f]=(0,w.useState)(null),[m,h]=(0,w.useState)(``),[g,_]=(0,w.useState)(!1);(0,w.useEffect)(()=>{let t=!1;return i.getProjectGitMergeState(e).then(e=>{if(!t){if(!e.inMerge){a();return}s(e.conflicts),f(e.conflicts[0]?.path??null)}}).catch(()=>{t||a()}),()=>{t=!0}},[e,a]);let y=(0,w.useCallback)(async(t,r,a)=>{h(`resolve`);try{await i.resolveProjectGitConflict(e,{path:t,choice:r,...a===void 0?{}:{content:a}}),l(e=>{let n=new Map(e);return n.set(t,r===`custom`?`combined`:r),n}),f(()=>(o??[]).filter(e=>e.path!==t&&!c.has(e.path))[0]?.path??null),b(e)}catch(e){n(`err`,e instanceof Error?e.message:String(e))}finally{h(``)}},[e,o,c,n]),x=(0,w.useCallback)(async()=>{h(`finish`);try{await i.completeProjectGitMerge(e),b(e),n(`ok`,v.conflictFinishToast),r()}catch(e){n(`err`,e instanceof Error?e.message:String(e)),h(``)}},[e,n,r]),S=(0,w.useCallback)(async()=>{h(`cancel`);try{await i.abandonProjectGitMerge(e),b(e),a()}catch(e){n(`err`,e instanceof Error?e.message:String(e)),h(``)}},[e,n,a]);if(o===null)return(0,T.jsx)(`p`,{className:`muted gh-conflict-loading`,children:`Loading…`});let C=o.filter(e=>c.has(e.path)).length,E=C===o.length,D=o.find(e=>e.path===d)??null;return(0,T.jsxs)(`div`,{className:`gh-conflicts`,children:[(0,T.jsxs)(`header`,{className:`gh-conflicts-header`,children:[(0,T.jsxs)(`h3`,{children:[`Your changes and GitHub's changes overlap in `,p(o.length,`file`)]}),(0,T.jsx)(`p`,{className:`muted`,children:t?v.conflictResume:v.conflictSub})]}),(0,T.jsxs)(`div`,{className:`gh-conflicts-body`,children:[(0,T.jsx)(`ul`,{className:`gh-conflicts-rail`,children:o.map(e=>{let t=c.get(e.path);return(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{type:`button`,className:`gh-conflicts-rail-item${e.path===d?` is-selected`:``}`,onClick:()=>f(e.path),children:[(0,T.jsx)(`span`,{className:`gh-conflicts-dot${t?` is-resolved`:``}`,"aria-hidden":!0,children:t?`✓`:`○`}),(0,T.jsx)(`span`,{className:`gh-conflicts-rail-path`,title:e.path,children:e.path.split(`/`).pop()}),t&&(0,T.jsx)(`span`,{className:`muted small`,children:A[t]})]})},e.path)})}),(0,T.jsx)(`div`,{className:`gh-conflicts-detail`,children:D?c.has(D.path)?(0,T.jsxs)(`p`,{className:`muted gh-conflict-settled`,children:[A[c.get(D.path)],` for `,(0,T.jsx)(`code`,{children:D.path}),`. To change your mind, cancel the sync and start over.`]}):(0,T.jsx)(k,{projectId:e,path:D.path,kind:D.kind,busy:m!==``,onResolve:(e,t)=>void y(D.path,e,t)}):(0,T.jsx)(`p`,{className:`muted gh-conflict-settled`,children:E?`All files are sorted out — press Finish sync.`:`Pick a file on the left.`})})]}),(0,T.jsxs)(`footer`,{className:`gh-conflicts-footer`,children:[(0,T.jsxs)(`span`,{className:`muted small`,children:[C,` of `,o.length,` sorted out`]}),(0,T.jsxs)(`div`,{className:`gh-conflicts-footer-actions`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:()=>_(!0),disabled:m!==``,children:v.conflictCancel}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void x(),disabled:!E||m!==``,children:m===`finish`?`Finishing…`:v.conflictFinish})]})]}),(0,T.jsx)(u,{open:g,title:v.conflictCancelTitle,message:v.conflictCancelBody,confirmLabel:v.conflictCancelConfirm,cancelLabel:v.conflictCancelKeep,danger:!0,onConfirm:async()=>{_(!1),await S()},onCancel:()=>_(!1)})]})}var M={modified:`M`,added:`A`,deleted:`D`,renamed:`R`,conflicted:`!`};function N({changes:e,selectedPath:t,onSelect:n,onDiscard:r,disabled:i}){return(0,T.jsx)(`ul`,{className:`gh-changes-list`,children:e.map(e=>{let a=e.path.split(`/`),o=a.pop()??e.path,s=a.join(`/`);return(0,T.jsxs)(`li`,{className:e.path===t?`is-selected`:``,children:[(0,T.jsxs)(`button`,{type:`button`,className:`gh-changes-row`,onClick:()=>n(e.path),disabled:i,children:[(0,T.jsx)(`span`,{className:`gh-change-kind gh-change-kind-${e.kind}`,title:_(e.kind),"aria-label":_(e.kind),children:M[e.kind]??`M`}),(0,T.jsxs)(`span`,{className:`gh-change-name`,title:e.path,children:[o,s&&(0,T.jsx)(`span`,{className:`gh-change-dir`,children:s})]}),e.binary?(0,T.jsx)(`span`,{className:`gh-change-counts muted small`,children:`binary`}):(e.additions!==void 0||e.deletions!==void 0)&&(0,T.jsxs)(`span`,{className:`gh-change-counts small`,children:[(e.additions??0)>0&&(0,T.jsxs)(`span`,{className:`gh-change-add`,children:[`+`,e.additions]}),(e.deletions??0)>0&&(0,T.jsxs)(`span`,{className:`gh-change-rem`,children:[`−`,e.deletions]})]})]}),(0,T.jsx)(`button`,{type:`button`,className:`gh-change-discard`,title:`Undo changes to ${o}`,"aria-label":`Undo changes to ${o}`,onClick:()=>r(e),disabled:i,children:`↩`})]},e.path)})})}var P=`gezel:git-also-sync`;function F({projectId:e,changes:t,busy:n,onSave:r}){let[a,o]=(0,w.useState)(``),[s,c]=(0,w.useState)(!1),[l,u]=(0,w.useState)(()=>{try{return window.localStorage.getItem(P)!==`false`}catch{return!0}}),d=(0,w.useRef)(!1),f=(0,w.useRef)(0),p=(0,w.useMemo)(()=>t.map(e=>`${e.path}:${e.additions??``}/${e.deletions??``}`).join(`;`),[t]),m=(0,w.useCallback)(async n=>{if(t.length===0||!n&&d.current)return;let r=++f.current;c(!0);try{let t=await i.suggestProjectGitMessage(e);if(r!==f.current||!n&&d.current)return;t.message&&(o(t.message),d.current=!1)}catch{}finally{r===f.current&&c(!1)}},[e,t.length]);(0,w.useEffect)(()=>{if(t.length===0){o(e=>d.current?e:``);return}let e=window.setTimeout(()=>void m(!1),800);return()=>window.clearTimeout(e)},[p,t.length,m]);let g=(0,w.useCallback)(async()=>{await r(a.trim()||h(t),l),o(``),d.current=!1},[a,t,l,r]),_=(0,w.useCallback)(e=>{u(e);try{window.localStorage.setItem(P,String(e))}catch{}},[]);return(0,T.jsxs)(`div`,{className:`gh-save-box`,children:[(0,T.jsxs)(`div`,{className:`gh-save-textarea-wrap`,children:[(0,T.jsx)(`textarea`,{className:`gh-save-message${s?` is-suggesting`:``}`,value:a,placeholder:s?`Writing a description…`:v.savePlaceholder,rows:2,onChange:e=>{o(e.target.value),d.current=e.target.value.trim().length>0},disabled:n,"aria-label":`Describe what you changed`}),(0,T.jsx)(`button`,{type:`button`,className:`gh-save-suggest`,title:`Let AI write the description`,"aria-label":`Let AI write the description`,onClick:()=>void m(!0),disabled:n||s||t.length===0,children:`✨`})]}),(0,T.jsxs)(`label`,{className:`gh-save-also-sync small`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>_(e.target.checked),disabled:n}),v.saveAlsoSync]}),(0,T.jsx)(`button`,{type:`button`,className:`gh-save-button primary`,onClick:()=>void g(),disabled:n||t.length===0,children:n?`Saving…`:l?v.saveAndSyncButton:v.saveButton})]})}function I({projectId:e,onSyncRequested:t,syncing:n,lastSyncedAt:r,showToast:a,onReviewRequested:o,onBranchReviewRequested:s,reviewBusy:c}){let[d,h]=(0,w.useState)(null),[g,y]=(0,w.useState)(!1),[x,C]=(0,w.useState)(null),[E,D]=(0,w.useState)(null),[O,k]=(0,w.useState)(``),[A,j]=(0,w.useState)(null),[M,P]=(0,w.useState)(!1),I=(0,w.useRef)(new Map),L=(0,w.useCallback)(async()=>{try{let t=await i.getProjectGitChanges(e);I.current.clear(),h(t.changes),y(t.truncated),C(e=>e&&t.changes.some(t=>t.path===e)?e:t.changes[0]?.path??null)}catch{}},[e]);(0,w.useEffect)(()=>{L();let t=window.setInterval(()=>void L(),15e3),n=t=>{t.detail?.projectId===e&&L()};return window.addEventListener(S,n),()=>{window.clearInterval(t),window.removeEventListener(S,n)}},[L,e]),(0,w.useEffect)(()=>{if(!x){D(null);return}let t=I.current.get(x);if(t){D(t);return}let n=!1;return D(null),i.getProjectGitFileDiff(e,x).then(e=>{I.current.set(x,e),n||D(e)}).catch(()=>{n||D({path:x,kind:`modified`,binary:!1,truncated:!1,diff:``})}),()=>{n=!0}},[e,x]);let R=(0,w.useCallback)(async(n,r)=>{k(`save`);try{await i.commitProjectGit(e,n),a(`ok`,v.saveToast),await L(),b(e),r&&t()}catch(e){a(`err`,`Save failed: ${e instanceof Error?e.message:String(e)}`)}finally{k(``)}},[e,L,a,t]),z=(0,w.useCallback)(async t=>{k(`discard`);try{a(`ok`,`Undid ${p((await i.discardProjectGitChanges(e,t)).discarded,`change`)}.`),await L(),b(e)}catch(e){a(`err`,`Undo failed: ${e instanceof Error?e.message:String(e)}`)}finally{k(``)}},[e,L,a]),B=d?.find(e=>e.path===x)??null;return d===null?(0,T.jsx)(`p`,{className:`muted gh-changes-loading`,children:`Loading changes…`}):d.length===0?(0,T.jsxs)(`div`,{className:`gh-changes-empty`,children:[(0,T.jsx)(`div`,{className:`gh-changes-empty-title`,children:v.changesEmptyTitle}),(0,T.jsx)(`p`,{className:`muted`,children:v.changesEmptyBody}),(0,T.jsx)(`button`,{type:`button`,onClick:t,disabled:n,children:n?`Syncing…`:`Sync`}),s&&(0,T.jsxs)(`button`,{type:`button`,onClick:s,disabled:c===!0,children:[`✨ `,v.reviewPrButton]}),r&&(0,T.jsxs)(`p`,{className:`muted small`,title:l(r),children:[`Last synced `,m(r)]})]}):(0,T.jsxs)(`div`,{className:`gh-changes-layout`,children:[(0,T.jsxs)(`div`,{className:`gh-changes-rail`,children:[(0,T.jsxs)(`div`,{className:`gh-changes-rail-header`,children:[(0,T.jsx)(`strong`,{children:p(d.length,`changed file`)}),o&&(0,T.jsx)(`button`,{type:`button`,className:`gh-review-rail-button small`,onClick:o,disabled:O!==``||c===!0,title:v.reviewCommitHint,children:v.reviewRailButton}),(0,T.jsx)(`button`,{type:`button`,className:`gh-changes-discard-all small`,onClick:()=>P(!0),disabled:O!==``,children:`Undo all…`})]}),g&&(0,T.jsxs)(`p`,{className:`muted small gh-changes-truncated`,children:[`Showing the first `,d.length,` files.`]}),(0,T.jsx)(`div`,{className:`gh-changes-rail-list`,children:(0,T.jsx)(N,{changes:d,selectedPath:x,onSelect:C,onDiscard:j,disabled:O!==``})}),(0,T.jsx)(F,{projectId:e,changes:d,busy:O===`save`,onSave:R})]}),(0,T.jsx)(`div`,{className:`gh-changes-diff-pane`,children:B?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`gh-changes-diff-header`,children:[(0,T.jsx)(`code`,{className:`gh-changes-diff-path`,title:B.path,children:B.path}),(0,T.jsx)(`span`,{className:`muted small`,children:_(B.kind)}),!B.binary&&(B.additions!==void 0||B.deletions!==void 0)&&(0,T.jsxs)(`span`,{className:`small`,children:[(0,T.jsxs)(`span`,{className:`gh-change-add`,children:[`+`,B.additions??0]}),` `,(0,T.jsxs)(`span`,{className:`gh-change-rem`,children:[`−`,B.deletions??0]})]})]}),E?(0,T.jsx)(f,{diff:E.diff,kind:E.kind,oldPath:E.oldPath,binary:E.binary,truncated:E.truncated}):(0,T.jsx)(`p`,{className:`muted gh-changes-loading`,children:`Loading…`})]}):(0,T.jsx)(`p`,{className:`placeholder`,children:`Pick a file to see what changed.`})}),(0,T.jsx)(u,{open:A!==null,title:`Undo changes to ${A?(e=>e.split(`/`).pop()??e)(A.path):``}?`,message:`This puts the file back to how it was at your last save. This can't be undone.`,confirmLabel:`Undo changes`,danger:!0,onConfirm:async()=>{let e=A;j(null),e&&await z({paths:[e.path]})},onCancel:()=>j(null)}),(0,T.jsx)(u,{open:M,title:`Undo all changes?`,message:`This puts all ${p(d.length,`file`)} back to how they were at your last save. This can't be undone.`,confirmLabel:`Undo everything`,danger:!0,onConfirm:async()=>{P(!1),await z({all:!0})},onCancel:()=>P(!1)})]})}var L=50;function R({projectId:e}){let[t,n]=(0,w.useState)(null),[r,a]=(0,w.useState)(!1),[o,s]=(0,w.useState)(null),[c,u]=(0,w.useState)(null),[h,g]=(0,w.useState)(!1),_=(0,w.useCallback)(async t=>{let r=await i.getProjectGitLog(e,{limit:L,skip:t});a(r.hasMore),n(e=>t===0?r.commits:[...e??[],...r.commits])},[e]);if((0,w.useEffect)(()=>{n(null),s(null),u(null),_(0).catch(()=>n([]))},[_]),(0,w.useEffect)(()=>{if(!o){u(null);return}let t=!1;return u(null),i.getProjectGitCommit(e,o).then(e=>{t||u(e)}).catch(()=>{t||u(null)}),()=>{t=!0}},[e,o]),t===null)return(0,T.jsx)(`p`,{className:`muted gh-timeline-loading`,children:`Loading…`});if(t.length===0)return(0,T.jsx)(`p`,{className:`muted gh-timeline-empty`,children:v.timelineEmpty});let y=c?.diff?d(c.diff):[];return(0,T.jsxs)(`div`,{className:`gh-timeline-layout`,children:[(0,T.jsxs)(`div`,{className:`gh-timeline-rail`,children:[(0,T.jsx)(`ul`,{className:`gh-timeline-list`,children:t.map(e=>(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{type:`button`,className:`gh-timeline-item${e.sha===o?` is-selected`:``}`,onClick:()=>s(e.sha),children:[(0,T.jsx)(`span`,{className:`gh-timeline-subject`,children:e.subject}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(e.date),children:[e.author,` saved `,p(e.filesChanged,`file`),` · `,m(e.date)]})]})},e.sha))}),r&&(0,T.jsx)(`button`,{type:`button`,className:`gh-timeline-more`,disabled:h,onClick:()=>{g(!0),_(t.length).finally(()=>g(!1))},children:h?`Loading…`:`Show earlier saves`})]}),(0,T.jsx)(`div`,{className:`gh-timeline-detail`,children:o===null?(0,T.jsx)(`p`,{className:`placeholder`,children:`Pick a save to see what changed.`}):c===null?(0,T.jsx)(`p`,{className:`muted gh-timeline-loading`,children:`Loading…`}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`gh-timeline-detail-header`,children:[(0,T.jsx)(`strong`,{children:c.subject}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(c.date),children:[c.author,` · `,m(c.date)]})]}),y.length===0?(0,T.jsx)(`p`,{className:`muted`,children:`Sync point — this save combined changes that are each shown separately.`}):y.map(e=>(0,T.jsxs)(`div`,{className:`gh-timeline-file`,children:[e.path&&(0,T.jsx)(`div`,{className:`gh-timeline-file-path`,children:(0,T.jsx)(`code`,{children:e.path})}),(0,T.jsx)(f,{diff:e.diff})]},e.path||`diff`)),c.truncated&&(0,T.jsx)(`p`,{className:`muted small`,children:v.diffBig})]})})]})}function z({projectId:e}){let[t,n]=(0,w.useState)(null),[r,a]=(0,w.useState)(null),[o,s]=(0,w.useState)(null);return(0,w.useEffect)(()=>{n(null),a(null),s(null);let t=!1;return i.listProjectGitHubPulls(e).then(e=>{t||n(e.pulls)}).catch(e=>{t||(n([]),s(e instanceof Error?e.message:String(e)))}),()=>{t=!0}},[e]),(0,T.jsxs)(`div`,{className:`project-files-layout`,children:[(0,T.jsxs)(`div`,{className:`file-tree-panel`,children:[o&&(0,T.jsx)(`p`,{className:`error`,style:{padding:`0.5rem`},children:o}),t===null&&(0,T.jsx)(`p`,{className:`muted`,style:{padding:`0.5rem`},children:`Loading…`}),t&&t.length===0&&!o&&(0,T.jsx)(`p`,{className:`muted`,style:{padding:`0.5rem`},children:`No open pull requests.`}),t&&t.length>0&&(0,T.jsx)(`ul`,{className:`pr-list`,style:{listStyle:`none`,padding:0,margin:0},children:t.map(e=>(0,T.jsx)(`li`,{style:{borderBottom:`1px solid var(--border-color, #eee)`},children:(0,T.jsxs)(`button`,{type:`button`,className:r===e.number?`active`:``,onClick:()=>a(e.number),style:{display:`block`,width:`100%`,textAlign:`left`,padding:`0.5rem 0.6rem`,background:`transparent`,border:`none`,cursor:`pointer`},children:[(0,T.jsxs)(`div`,{style:{fontWeight:500},children:[`#`,e.number,` `,e.title,` `,e.draft&&(0,T.jsx)(`em`,{className:`muted`,children:`(draft)`})]}),(0,T.jsxs)(`div`,{className:`muted small`,children:[`by `,e.author,` — `,e.headRef,` → `,e.baseRef]})]})},e.number))})]}),(0,T.jsx)(`div`,{className:`file-viewer-panel`,children:r===null?(0,T.jsx)(`p`,{className:`placeholder`,style:{padding:`2rem`},children:`Select a pull request to view its details.`}):(0,T.jsx)(B,{projectId:e,num:r})})]})}function B({projectId:e,num:t}){let[n,r]=(0,w.useState)(null),[a,o]=(0,w.useState)(null),[s,u]=(0,w.useState)(null),[d,f]=(0,w.useState)(null);return(0,w.useEffect)(()=>{r(null),o(null),u(null),f(null);let n=!1;return(async()=>{try{let[a,s,c]=await Promise.all([i.getProjectGitHubPull(e,t),V(e,t),i.listProjectGitHubPullComments(e,t)]);if(n)return;r(a),o(s),u(c.comments)}catch(e){n||f(e.message)}})(),()=>{n=!0}},[e,t]),d?(0,T.jsx)(`p`,{className:`error`,style:{padding:`1rem`},children:d}):n?(0,T.jsxs)(`div`,{style:{padding:`0.5rem 0.75rem`,overflow:`auto`,height:`calc(100vh - 320px)`},children:[(0,T.jsxs)(`h3`,{style:{marginTop:0},children:[`#`,n.number,` `,n.title]}),(0,T.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`by `,n.author,` — `,n.headRef,` → `,n.baseRef,` —`,` `,(0,T.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,children:`view on GitHub`})]}),(0,T.jsxs)(`p`,{className:`muted small`,children:[n.merged?`merged`:n.state,` · `,n.changedFiles,` files · +`,n.additions,` −`,n.deletions]}),n.body&&(0,T.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`,background:`var(--code-bg, #f6f8fa)`,padding:`0.5rem`,borderRadius:4},children:n.body}),(0,T.jsx)(`h4`,{children:`Files changed`}),a&&a.length===0&&(0,T.jsx)(`p`,{className:`muted small`,children:`No files.`}),a&&a.length>0&&(0,T.jsx)(`ul`,{style:{listStyle:`none`,padding:0},children:a.map(e=>(0,T.jsx)(`li`,{style:{marginBottom:`0.5rem`},children:(0,T.jsxs)(`details`,{children:[(0,T.jsxs)(`summary`,{children:[(0,T.jsx)(`code`,{children:e.filename}),` `,(0,T.jsxs)(`span`,{className:`muted small`,children:[e.status,` +`,e.additions,` −`,e.deletions]})]}),e.patch?(0,T.jsx)(`pre`,{style:{background:`var(--code-bg, #f6f8fa)`,padding:`0.5rem`,overflow:`auto`,fontSize:`0.8rem`},children:e.patch}):(0,T.jsx)(`p`,{className:`muted small`,children:`No patch returned (binary or too large).`})]})},e.filename))}),(0,T.jsx)(`h4`,{children:`Comments`}),s&&s.length===0&&(0,T.jsx)(`p`,{className:`muted small`,children:`No comments yet.`}),s&&s.length>0&&(0,T.jsx)(`ul`,{style:{listStyle:`none`,padding:0},children:s.map(e=>(0,T.jsxs)(`li`,{style:{marginBottom:`0.75rem`,borderLeft:`3px solid var(--border-color, #ddd)`,paddingLeft:`0.5rem`},children:[(0,T.jsxs)(`div`,{className:`muted small`,children:[(0,T.jsx)(`strong`,{children:e.author}),` · `,e.kind,e.path&&(0,T.jsxs)(T.Fragment,{children:[` `,`on `,(0,T.jsx)(`code`,{children:e.path})]}),` · `,(0,T.jsx)(`span`,{title:l(e.createdAt),children:c(e.createdAt)})]}),(0,T.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`,margin:0,fontFamily:`inherit`},children:e.body})]},e.id))})]}):(0,T.jsx)(`p`,{className:`muted`,style:{padding:`1rem`},children:`Loading…`})}async function V(e,t){let n=[],r=0;for(;;){let a=await i.listProjectGitHubPullFiles(e,t,{offset:r,limit:200,includePatch:!0});if(n.push(...a.files),!a.hasMore||a.nextOffset===void 0)return n;r=a.nextOffset}}var H=5e3,U=3e4;function W(e){let t=e instanceof Error?e.message:String(e);return t.includes(`REVIEW_IN_PROGRESS`)?v.reviewAlreadyRunning:t.includes(`NO_DEFAULT_BRANCH`)?v.reviewNoDefaultBranch:t.includes(`DETACHED_HEAD`)?v.reviewDetachedHead:t}function G(e,t){let[n,r]=(0,w.useState)([]),[a,o]=(0,w.useState)(``),s=(0,w.useRef)(n);s.current=n;let c=(0,w.useCallback)(async()=>{try{let t=await i.listProjectCodeReviews(e);r(t.reviews)}catch{}},[e]),l=n.some(e=>e.status===`running`);(0,w.useEffect)(()=>{c();let t=window.setInterval(()=>void c(),l?H:U),n=t=>{t.detail?.projectId===e&&c()};return window.addEventListener(S,n),()=>{window.clearInterval(t),window.removeEventListener(S,n)}},[c,e,l]);let u=(0,w.useCallback)(async n=>{o(n===`commit`?`start-commit`:`start-pr`);try{let a=await i.startProjectCodeReview(e,{kind:n});return r(e=>[a.review,...e.filter(e=>e.id!==a.review.id)]),t(`ok`,v.reviewStartedToast),!0}catch(e){return(e instanceof Error?e.message:String(e)).includes(`NOTHING_TO_REVIEW`)?t(`err`,n===`commit`?v.reviewNothingCommit:v.reviewNothingPr):t(`err`,W(e)),!1}finally{o(``)}},[e,t]),d=(0,w.useCallback)(async n=>{o(`cancel`);try{let a=await i.cancelProjectCodeReview(e,n);r(e=>e.map(e=>e.id===a.review.id?a.review:e)),t(`ok`,v.reviewCanceledToast)}catch(e){t(`err`,W(e))}finally{o(``)}},[e,t]);return{reviews:n,running:n.filter(e=>e.status===`running`),start:u,cancel:d,busy:a,refresh:c}}function K({project:e,onProjectChange:t}){let[n,r]=(0,w.useState)(`changes`),[c,l]=(0,w.useState)(null),[d,f]=(0,w.useState)(null),[p,m]=(0,w.useState)(``),[h,g]=(0,w.useState)(null),[_,y]=(0,w.useState)(!1),[b,E]=(0,w.useState)(!1),[D,k]=(0,w.useState)(!1),A=(0,w.useRef)(!1),M=(0,w.useCallback)((e,t)=>{g({kind:e,text:t}),window.setTimeout(()=>g(null),5e3)},[]),N=(0,w.useCallback)(async()=>{try{let t=await i.getProjectGitStatus(e.id);l(t)}catch(e){f(e.message)}},[e.id]),{reviews:P,running:F,start:L,cancel:B,busy:V}=G(e.id,M),H=(0,w.useCallback)(e=>{L(e).then(e=>{e&&r(`review`)})},[L]),{sync:U,syncing:W}=x(e.id,{onToast:M,onConflicts:()=>{r(`changes`),N()},onNeedsSave:()=>{r(`changes`),y(!0)},onAuth:()=>E(!0)}),K=(0,w.useCallback)(async()=>{A.current=!0,(await U())?.state===`synced`&&(E(!1),k(!1)),await N()},[U,N]),J=(0,w.useCallback)(e=>{e&&(E(!1),N())},[N]);(0,w.useEffect)(()=>{f(null),r(`changes`),E(!1),k(!1),A.current=!1,N()},[e.id,N]),(0,w.useEffect)(()=>{let t=window.setInterval(()=>void N(),3e4),n=t=>{t.detail?.projectId===e.id&&N()};return window.addEventListener(S,n),()=>{window.clearInterval(t),window.removeEventListener(S,n)}},[N,e.id]);let Y=c?.exists===!0;(0,w.useEffect)(()=>{if(!Y)return;let t=()=>i.fetchProjectGit(e.id).then(()=>N()).catch(e=>{q(e)&&E(!0)});t();let n=window.setInterval(()=>void t(),3e5);return()=>window.clearInterval(n)},[Y,e.id,N]);let X=(0,w.useCallback)(async()=>{m(`Downloading…`),f(null);try{await i.cloneProjectGit(e.id),t(await i.getProject(e.id)),await N()}catch(e){f(e.message)}finally{m(``)}},[e.id,N,t]),Z=c&&!c.exists,ee=c?(c.credentialSource??(c.hasPat?`pat`:`none`))===`none`:!1,Q=c?.mergeInProgress===!0,te=c?.behind??0,$=c?.changesCount??0;return(0,T.jsxs)(`div`,{className:`project-github`,children:[(0,T.jsxs)(`div`,{className:`github-toolbar`,children:[(0,T.jsx)(`strong`,{children:e.github?.url}),p&&(0,T.jsx)(`span`,{className:`status`,children:p})]}),(ee||b)&&(0,T.jsxs)(`div`,{className:`github-banner gh-banner-warn`,children:[b?`GitHub needs you to sign in again.`:`No GitHub sign-in found. Public repositories still work; sign in for private repositories, pull requests, and sending changes.`,` `,(0,T.jsx)(C,{onChange:J,compact:!0})]}),!Q&&te>0&&!D&&(0,T.jsxs)(`div`,{className:`github-banner gh-banner-nudge`,children:[(0,T.jsx)(`span`,{children:v.nudgeBanner}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void K(),disabled:W,children:W?`Syncing…`:`Sync`}),(0,T.jsx)(`button`,{type:`button`,className:`gh-banner-dismiss`,"aria-label":`Dismiss`,onClick:()=>k(!0),children:`✕`})]}),d&&(0,T.jsx)(`p`,{className:`error`,children:d}),Z?(0,T.jsxs)(`div`,{className:`gh-clone-state`,children:[(0,T.jsx)(`p`,{children:`This project lives on GitHub but isn't on this computer yet.`}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void X(),disabled:!!p,children:`Download project`})]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(s,{value:n,onValueChange:e=>r(e),children:(0,T.jsxs)(o,{children:[(0,T.jsxs)(a,{value:`changes`,children:[`Changes`,$>0&&(0,T.jsx)(`span`,{className:`gh-tab-badge`,children:$})]}),(0,T.jsx)(a,{value:`timeline`,children:`Timeline`}),(0,T.jsx)(a,{value:`prs`,children:`Pull requests`}),(0,T.jsxs)(a,{value:`review`,children:[v.reviewTabLabel,F.length>0&&(0,T.jsx)(`span`,{className:`gh-tab-badge`,children:F.length})]})]})}),n===`changes`&&(Q?(0,T.jsx)(j,{projectId:e.id,resumed:!A.current,showToast:M,onFinished:()=>{N(),K()},onExited:()=>void N()}):(0,T.jsx)(I,{projectId:e.id,onSyncRequested:()=>void K(),syncing:W,lastSyncedAt:c?.github?.lastSyncedAt,showToast:M,onReviewRequested:()=>H(`commit`),onBranchReviewRequested:()=>H(`pr`),reviewBusy:V!==``||F.some(e=>e.kind===`commit`)})),n===`timeline`&&(0,T.jsx)(R,{projectId:e.id}),n===`prs`&&(0,T.jsx)(z,{projectId:e.id}),n===`review`&&(0,T.jsx)(O,{projectId:e.id,reviews:P,busy:V,changesCount:$,branch:c?.branch,defaultBranch:c?.defaultBranch??c?.github?.defaultBranch,onStart:e=>void L(e),onCancel:e=>void B(e)})]}),h&&(0,T.jsx)(`output`,{className:`project-git-toast project-git-toast-${h.kind}`,children:h.text}),(0,T.jsx)(u,{open:_,title:v.needsSaveTitle,message:v.needsSaveBody,confirmLabel:v.needsSaveConfirm,cancelLabel:v.needsSaveCancel,onConfirm:()=>{y(!1),r(`changes`)},onCancel:()=>y(!1)})]})}function q(e){return!(e instanceof r)||!e.details||typeof e.details!=`object`?!1:`code`in e.details&&e.details.code===`MISSING_PAT`}export{K as ProjectGitHubView};
|
|
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"./dist-BMZhqfv7.js";import{t as i}from"./api-CmrgM5Rf.js";import{i as a,n as o,r as s}from"./Tabs-jE0Z5Tzd.js";import"./primitives-CWrGZpPI.js";import{n as c,t as l}from"./relative-time-B2kBaekd.js";import{t as u}from"./ConfirmDialog-Dt1ed4Fh.js";import{r as d,t as f}from"./GitDiffView-DrDrSeBb.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./gitCopy-Dcjz17cJ.js";import{t as y}from"./MarkdownField-BX0qsaFq.js";import{n as b,r as x,t as S}from"./useGitSync-7m9YA7h5.js";import{t as C}from"./GithubSignInChip-eEGCe9ar.js";var w=e(t(),1),T=n();function E({review:e,onCancel:t,disabled:n}){let[r,i]=(0,w.useState)(!1),a=e.needsAttention===!0,o=e.assigneeName??`A reviewer`,s=e.stepsTotal&&e.stepsTotal>0?`step ${Math.min((e.stepsComplete??0)+1,e.stepsTotal)} of ${e.stepsTotal}`:void 0;return(0,T.jsxs)(`div`,{className:`gh-review-status-card ${a?`gh-review-status-attention`:`gh-review-status-running`}`,children:[(0,T.jsxs)(`div`,{className:`gh-review-status-main`,children:[(0,T.jsxs)(`strong`,{children:[g(e.kind),` · `,e.branch]}),(0,T.jsx)(`span`,{children:a?v.reviewNeedsAttention:(0,T.jsxs)(T.Fragment,{children:[o,` `,v.reviewRunning]})}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(e.createdAt),children:[p(e.filesChanged,`file`),s?` · ${s}`:``,e.activeStepName?` · ${e.activeStepName}`:``,` · started ${m(e.createdAt)}`]})]}),(0,T.jsx)(`button`,{type:`button`,className:`gh-review-stop small`,onClick:()=>i(!0),disabled:n,children:v.reviewStop}),(0,T.jsx)(u,{open:r,title:v.reviewStopTitle,message:v.reviewStopBody,confirmLabel:v.reviewStopConfirm,danger:!0,onConfirm:()=>{i(!1),t(e.id)},onCancel:()=>i(!1)})]})}var D=()=>{};function O({projectId:e,reviews:t,busy:n,changesCount:r,branch:a,defaultBranch:o,onStart:s,onCancel:c}){let u=t.filter(e=>e.status===`running`),d=t.filter(e=>e.status!==`running`),f=u.some(e=>e.kind===`commit`),h=u.some(e=>e.kind===`pr`),[_,b]=(0,w.useState)(null),x=(0,w.useMemo)(()=>d.find(e=>e.id===_)??d.find(e=>e.status===`complete`)??null,[d,_]),[S,C]=(0,w.useState)(null);(0,w.useEffect)(()=>{if(!x||x.status!==`complete`){C(null);return}let t=!1;return i.readProjectArtifact(e,x.reportPath).then(e=>{t||C({id:x.id,content:e.content})}).catch(()=>{t||C({id:x.id,content:null})}),()=>{t=!0}},[e,x]);let O=o?`Checks everything on ${a??`this branch`} against ${o}.`:v.reviewPrHint;return(0,T.jsxs)(`div`,{className:`gh-review-layout`,children:[(0,T.jsxs)(`div`,{className:`gh-review-rail`,children:[(0,T.jsxs)(`div`,{className:`gh-review-kickoff-row`,children:[(0,T.jsxs)(`div`,{className:`gh-review-card`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:()=>s(`commit`),disabled:n!==``||f||r===0,children:n===`start-commit`?`Starting…`:`✨ ${v.reviewCommitButton}`}),(0,T.jsx)(`p`,{className:`muted small`,children:r===0?v.reviewNothingCommit:v.reviewCommitHint})]}),(0,T.jsxs)(`div`,{className:`gh-review-card`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:()=>s(`pr`),disabled:n!==``||h,children:n===`start-pr`?`Starting…`:`✨ ${v.reviewPrButton}`}),(0,T.jsx)(`p`,{className:`muted small`,children:O})]})]}),u.map(e=>(0,T.jsx)(E,{review:e,onCancel:c,disabled:n!==``},e.id)),(0,T.jsxs)(`div`,{className:`gh-review-history`,children:[d.length===0&&u.length===0&&(0,T.jsx)(`p`,{className:`muted`,children:v.reviewHistoryEmpty}),d.map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`gh-review-history-item${x?.id===e.id?` is-selected`:``}`,onClick:()=>b(e.id),children:[(0,T.jsx)(`span`,{className:`gh-review-outcome-chip gh-review-outcome-${e.status}`,children:e.status===`complete`?`Reviewed`:e.status===`canceled`?`Stopped`:`Issue`}),(0,T.jsxs)(`span`,{className:`gh-review-history-title`,children:[g(e.kind),` · `,e.branch]}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(e.settledAt??e.createdAt),children:[p(e.filesChanged,`file`),` · `,m(e.settledAt??e.createdAt)]})]},e.id))]})]}),(0,T.jsx)(`div`,{className:`gh-review-report`,children:x&&x.status===`complete`?S?.id===x.id?S.content===null?(0,T.jsx)(`p`,{className:`muted`,children:v.reviewReportMissing}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`gh-review-report-header`,children:[(0,T.jsx)(`code`,{className:`gh-changes-diff-path`,title:x.reportPath,children:x.reportPath}),(0,T.jsx)(`button`,{type:`button`,className:`small`,onClick:()=>window.dispatchEvent(new CustomEvent(`gezel:open-file`,{detail:{projectId:e,path:x.reportPath,source:`artifacts`}})),children:v.reviewOpenInArtifacts})]}),(0,T.jsx)(y,{value:S.content,readOnly:!0,onCommit:D},`${x.id}:${x.reportPath}`)]}):(0,T.jsx)(`p`,{className:`muted`,children:v.reviewReportLoading}):(0,T.jsx)(`p`,{className:`placeholder`,children:u.length>0?`The report will appear here when the review finishes.`:`Pick a finished review to read its report.`})})]})}function k({projectId:e,path:t,kind:n,busy:r,onResolve:a}){let[o,s]=(0,w.useState)(null),[c,l]=(0,w.useState)(null),[u,d]=(0,w.useState)({step:`idle`});(0,w.useEffect)(()=>{s(null),l(null),d({step:`idle`});let n=!1;return i.getProjectGitConflictVersions(e,t).then(e=>{n||s(e)}).catch(e=>{n||l(e instanceof Error?e.message:String(e))}),()=>{n=!0}},[e,t]);let f=async()=>{d({step:`combining`});try{let n=await i.aiResolveProjectGitConflict(e,t);d({step:`preview`,content:n.merged})}catch(e){l(e instanceof Error?e.message:String(e)),d({step:`idle`})}};if(c)return(0,T.jsx)(`p`,{className:`error gh-conflict-error`,children:c});if(!o)return(0,T.jsx)(`p`,{className:`muted gh-conflict-loading`,children:`Loading…`});let p=!o.binary&&!o.tooLarge&&o.ours!==void 0&&o.theirs!==void 0;return u.step===`combining`?(0,T.jsx)(`p`,{className:`muted gh-conflict-loading`,children:v.conflictAiBusy}):u.step===`preview`||u.step===`editing`?(0,T.jsxs)(`div`,{className:`gh-conflict-ai-preview`,children:[(0,T.jsx)(`h4`,{children:v.conflictAiPreviewTitle}),u.step===`editing`?(0,T.jsx)(`textarea`,{className:`gh-conflict-ai-editor`,value:u.content,onChange:e=>d({step:`editing`,content:e.target.value}),"aria-label":`Edit the combined version`}):(0,T.jsx)(`pre`,{className:`gh-conflict-content`,children:u.content}),(0,T.jsxs)(`div`,{className:`gh-conflict-actions`,children:[(0,T.jsx)(`button`,{type:`button`,className:`primary`,disabled:r,onClick:()=>void a(`custom`,u.content),children:v.conflictAiUse}),u.step===`preview`?(0,T.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>d({step:`editing`,content:u.content}),children:v.conflictAiEdit}):null,(0,T.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>d({step:`idle`}),children:v.conflictAiBack})]})]}):(0,T.jsxs)(`div`,{className:`gh-conflict-file`,children:[(o.binary||o.tooLarge)&&(0,T.jsx)(`p`,{className:`muted small`,children:o.binary?`This file isn't text, so it can't be combined — pick one version.`:`This file is too large to preview — pick one version.`}),(0,T.jsxs)(`section`,{className:`gh-conflict-card`,children:[(0,T.jsxs)(`header`,{children:[(0,T.jsx)(`strong`,{children:v.conflictMineTitle}),n===`deleted-by-us`&&(0,T.jsx)(`span`,{className:`muted small`,children:`You deleted this file`})]}),o.ours!==void 0&&!o.binary&&!o.tooLarge&&(0,T.jsx)(`pre`,{className:`gh-conflict-content`,children:o.ours}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,disabled:r,onClick:()=>void a(`mine`),children:n===`deleted-by-us`?`Keep my version (stays deleted)`:v.conflictMineButton})]}),(0,T.jsxs)(`section`,{className:`gh-conflict-card`,children:[(0,T.jsxs)(`header`,{children:[(0,T.jsx)(`strong`,{children:v.conflictTheirsTitle}),n===`deleted-by-them`&&(0,T.jsx)(`span`,{className:`muted small`,children:`GitHub deleted this file`})]}),o.theirs!==void 0&&!o.binary&&!o.tooLarge&&(0,T.jsx)(`pre`,{className:`gh-conflict-content`,children:o.theirs}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,disabled:r,onClick:()=>void a(`theirs`),children:n===`deleted-by-them`?`Keep GitHub's version (deletes it)`:v.conflictTheirsButton})]}),p&&(0,T.jsx)(`div`,{className:`gh-conflict-ai-cta`,children:(0,T.jsxs)(`button`,{type:`button`,className:`gh-conflict-ai-button`,disabled:r,onClick:f,children:[`✨ `,v.conflictAiButton]})})]})}var A={mine:`Kept yours`,theirs:`Kept GitHub's`,combined:`Combined`};function j({projectId:e,resumed:t,showToast:n,onFinished:r,onExited:a}){let[o,s]=(0,w.useState)(null),[c,l]=(0,w.useState)(new Map),[d,f]=(0,w.useState)(null),[m,h]=(0,w.useState)(``),[g,_]=(0,w.useState)(!1);(0,w.useEffect)(()=>{let t=!1;return i.getProjectGitMergeState(e).then(e=>{if(!t){if(!e.inMerge){a();return}s(e.conflicts),f(e.conflicts[0]?.path??null)}}).catch(()=>{t||a()}),()=>{t=!0}},[e,a]);let y=(0,w.useCallback)(async(t,r,a)=>{h(`resolve`);try{await i.resolveProjectGitConflict(e,{path:t,choice:r,...a===void 0?{}:{content:a}}),l(e=>{let n=new Map(e);return n.set(t,r===`custom`?`combined`:r),n}),f(()=>(o??[]).filter(e=>e.path!==t&&!c.has(e.path))[0]?.path??null),b(e)}catch(e){n(`err`,e instanceof Error?e.message:String(e))}finally{h(``)}},[e,o,c,n]),x=(0,w.useCallback)(async()=>{h(`finish`);try{await i.completeProjectGitMerge(e),b(e),n(`ok`,v.conflictFinishToast),r()}catch(e){n(`err`,e instanceof Error?e.message:String(e)),h(``)}},[e,n,r]),S=(0,w.useCallback)(async()=>{h(`cancel`);try{await i.abandonProjectGitMerge(e),b(e),a()}catch(e){n(`err`,e instanceof Error?e.message:String(e)),h(``)}},[e,n,a]);if(o===null)return(0,T.jsx)(`p`,{className:`muted gh-conflict-loading`,children:`Loading…`});let C=o.filter(e=>c.has(e.path)).length,E=C===o.length,D=o.find(e=>e.path===d)??null;return(0,T.jsxs)(`div`,{className:`gh-conflicts`,children:[(0,T.jsxs)(`header`,{className:`gh-conflicts-header`,children:[(0,T.jsxs)(`h3`,{children:[`Your changes and GitHub's changes overlap in `,p(o.length,`file`)]}),(0,T.jsx)(`p`,{className:`muted`,children:t?v.conflictResume:v.conflictSub})]}),(0,T.jsxs)(`div`,{className:`gh-conflicts-body`,children:[(0,T.jsx)(`ul`,{className:`gh-conflicts-rail`,children:o.map(e=>{let t=c.get(e.path);return(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{type:`button`,className:`gh-conflicts-rail-item${e.path===d?` is-selected`:``}`,onClick:()=>f(e.path),children:[(0,T.jsx)(`span`,{className:`gh-conflicts-dot${t?` is-resolved`:``}`,"aria-hidden":!0,children:t?`✓`:`○`}),(0,T.jsx)(`span`,{className:`gh-conflicts-rail-path`,title:e.path,children:e.path.split(`/`).pop()}),t&&(0,T.jsx)(`span`,{className:`muted small`,children:A[t]})]})},e.path)})}),(0,T.jsx)(`div`,{className:`gh-conflicts-detail`,children:D?c.has(D.path)?(0,T.jsxs)(`p`,{className:`muted gh-conflict-settled`,children:[A[c.get(D.path)],` for `,(0,T.jsx)(`code`,{children:D.path}),`. To change your mind, cancel the sync and start over.`]}):(0,T.jsx)(k,{projectId:e,path:D.path,kind:D.kind,busy:m!==``,onResolve:(e,t)=>void y(D.path,e,t)}):(0,T.jsx)(`p`,{className:`muted gh-conflict-settled`,children:E?`All files are sorted out — press Finish sync.`:`Pick a file on the left.`})})]}),(0,T.jsxs)(`footer`,{className:`gh-conflicts-footer`,children:[(0,T.jsxs)(`span`,{className:`muted small`,children:[C,` of `,o.length,` sorted out`]}),(0,T.jsxs)(`div`,{className:`gh-conflicts-footer-actions`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:()=>_(!0),disabled:m!==``,children:v.conflictCancel}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void x(),disabled:!E||m!==``,children:m===`finish`?`Finishing…`:v.conflictFinish})]})]}),(0,T.jsx)(u,{open:g,title:v.conflictCancelTitle,message:v.conflictCancelBody,confirmLabel:v.conflictCancelConfirm,cancelLabel:v.conflictCancelKeep,danger:!0,onConfirm:async()=>{_(!1),await S()},onCancel:()=>_(!1)})]})}var M={modified:`M`,added:`A`,deleted:`D`,renamed:`R`,conflicted:`!`};function N({changes:e,selectedPath:t,onSelect:n,onDiscard:r,disabled:i}){return(0,T.jsx)(`ul`,{className:`gh-changes-list`,children:e.map(e=>{let a=e.path.split(`/`),o=a.pop()??e.path,s=a.join(`/`);return(0,T.jsxs)(`li`,{className:e.path===t?`is-selected`:``,children:[(0,T.jsxs)(`button`,{type:`button`,className:`gh-changes-row`,onClick:()=>n(e.path),disabled:i,children:[(0,T.jsx)(`span`,{className:`gh-change-kind gh-change-kind-${e.kind}`,title:_(e.kind),"aria-label":_(e.kind),children:M[e.kind]??`M`}),(0,T.jsxs)(`span`,{className:`gh-change-name`,title:e.path,children:[o,s&&(0,T.jsx)(`span`,{className:`gh-change-dir`,children:s})]}),e.binary?(0,T.jsx)(`span`,{className:`gh-change-counts muted small`,children:`binary`}):(e.additions!==void 0||e.deletions!==void 0)&&(0,T.jsxs)(`span`,{className:`gh-change-counts small`,children:[(e.additions??0)>0&&(0,T.jsxs)(`span`,{className:`gh-change-add`,children:[`+`,e.additions]}),(e.deletions??0)>0&&(0,T.jsxs)(`span`,{className:`gh-change-rem`,children:[`−`,e.deletions]})]})]}),(0,T.jsx)(`button`,{type:`button`,className:`gh-change-discard`,title:`Undo changes to ${o}`,"aria-label":`Undo changes to ${o}`,onClick:()=>r(e),disabled:i,children:`↩`})]},e.path)})})}var P=`gezel:git-also-sync`;function F({projectId:e,changes:t,busy:n,onSave:r}){let[a,o]=(0,w.useState)(``),[s,c]=(0,w.useState)(!1),[l,u]=(0,w.useState)(()=>{try{return window.localStorage.getItem(P)!==`false`}catch{return!0}}),d=(0,w.useRef)(!1),f=(0,w.useRef)(0),p=(0,w.useMemo)(()=>t.map(e=>`${e.path}:${e.additions??``}/${e.deletions??``}`).join(`;`),[t]),m=(0,w.useCallback)(async n=>{if(t.length===0||!n&&d.current)return;let r=++f.current;c(!0);try{let t=await i.suggestProjectGitMessage(e);if(r!==f.current||!n&&d.current)return;t.message&&(o(t.message),d.current=!1)}catch{}finally{r===f.current&&c(!1)}},[e,t.length]);(0,w.useEffect)(()=>{if(t.length===0){o(e=>d.current?e:``);return}let e=window.setTimeout(()=>void m(!1),800);return()=>window.clearTimeout(e)},[p,t.length,m]);let g=(0,w.useCallback)(async()=>{await r(a.trim()||h(t),l),o(``),d.current=!1},[a,t,l,r]),_=(0,w.useCallback)(e=>{u(e);try{window.localStorage.setItem(P,String(e))}catch{}},[]);return(0,T.jsxs)(`div`,{className:`gh-save-box`,children:[(0,T.jsxs)(`div`,{className:`gh-save-textarea-wrap`,children:[(0,T.jsx)(`textarea`,{className:`gh-save-message${s?` is-suggesting`:``}`,value:a,placeholder:s?`Writing a description…`:v.savePlaceholder,rows:2,onChange:e=>{o(e.target.value),d.current=e.target.value.trim().length>0},disabled:n,"aria-label":`Describe what you changed`}),(0,T.jsx)(`button`,{type:`button`,className:`gh-save-suggest`,title:`Let AI write the description`,"aria-label":`Let AI write the description`,onClick:()=>void m(!0),disabled:n||s||t.length===0,children:`✨`})]}),(0,T.jsxs)(`label`,{className:`gh-save-also-sync small`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>_(e.target.checked),disabled:n}),v.saveAlsoSync]}),(0,T.jsx)(`button`,{type:`button`,className:`gh-save-button primary`,onClick:()=>void g(),disabled:n||t.length===0,children:n?`Saving…`:l?v.saveAndSyncButton:v.saveButton})]})}function I({projectId:e,onSyncRequested:t,syncing:n,lastSyncedAt:r,showToast:a,onReviewRequested:o,onBranchReviewRequested:s,reviewBusy:c}){let[d,h]=(0,w.useState)(null),[g,y]=(0,w.useState)(!1),[x,C]=(0,w.useState)(null),[E,D]=(0,w.useState)(null),[O,k]=(0,w.useState)(``),[A,j]=(0,w.useState)(null),[M,P]=(0,w.useState)(!1),I=(0,w.useRef)(new Map),L=(0,w.useCallback)(async()=>{try{let t=await i.getProjectGitChanges(e);I.current.clear(),h(t.changes),y(t.truncated),C(e=>e&&t.changes.some(t=>t.path===e)?e:t.changes[0]?.path??null)}catch{}},[e]);(0,w.useEffect)(()=>{L();let t=window.setInterval(()=>void L(),15e3),n=t=>{t.detail?.projectId===e&&L()};return window.addEventListener(S,n),()=>{window.clearInterval(t),window.removeEventListener(S,n)}},[L,e]),(0,w.useEffect)(()=>{if(!x){D(null);return}let t=I.current.get(x);if(t){D(t);return}let n=!1;return D(null),i.getProjectGitFileDiff(e,x).then(e=>{I.current.set(x,e),n||D(e)}).catch(()=>{n||D({path:x,kind:`modified`,binary:!1,truncated:!1,diff:``})}),()=>{n=!0}},[e,x]);let R=(0,w.useCallback)(async(n,r)=>{k(`save`);try{await i.commitProjectGit(e,n),a(`ok`,v.saveToast),await L(),b(e),r&&t()}catch(e){a(`err`,`Save failed: ${e instanceof Error?e.message:String(e)}`)}finally{k(``)}},[e,L,a,t]),z=(0,w.useCallback)(async t=>{k(`discard`);try{a(`ok`,`Undid ${p((await i.discardProjectGitChanges(e,t)).discarded,`change`)}.`),await L(),b(e)}catch(e){a(`err`,`Undo failed: ${e instanceof Error?e.message:String(e)}`)}finally{k(``)}},[e,L,a]),B=d?.find(e=>e.path===x)??null;return d===null?(0,T.jsx)(`p`,{className:`muted gh-changes-loading`,children:`Loading changes…`}):d.length===0?(0,T.jsxs)(`div`,{className:`gh-changes-empty`,children:[(0,T.jsx)(`div`,{className:`gh-changes-empty-title`,children:v.changesEmptyTitle}),(0,T.jsx)(`p`,{className:`muted`,children:v.changesEmptyBody}),(0,T.jsx)(`button`,{type:`button`,onClick:t,disabled:n,children:n?`Syncing…`:`Sync`}),s&&(0,T.jsxs)(`button`,{type:`button`,onClick:s,disabled:c===!0,children:[`✨ `,v.reviewPrButton]}),r&&(0,T.jsxs)(`p`,{className:`muted small`,title:l(r),children:[`Last synced `,m(r)]})]}):(0,T.jsxs)(`div`,{className:`gh-changes-layout`,children:[(0,T.jsxs)(`div`,{className:`gh-changes-rail`,children:[(0,T.jsxs)(`div`,{className:`gh-changes-rail-header`,children:[(0,T.jsx)(`strong`,{children:p(d.length,`changed file`)}),o&&(0,T.jsx)(`button`,{type:`button`,className:`gh-review-rail-button small`,onClick:o,disabled:O!==``||c===!0,title:v.reviewCommitHint,children:v.reviewRailButton}),(0,T.jsx)(`button`,{type:`button`,className:`gh-changes-discard-all small`,onClick:()=>P(!0),disabled:O!==``,children:`Undo all…`})]}),g&&(0,T.jsxs)(`p`,{className:`muted small gh-changes-truncated`,children:[`Showing the first `,d.length,` files.`]}),(0,T.jsx)(`div`,{className:`gh-changes-rail-list`,children:(0,T.jsx)(N,{changes:d,selectedPath:x,onSelect:C,onDiscard:j,disabled:O!==``})}),(0,T.jsx)(F,{projectId:e,changes:d,busy:O===`save`,onSave:R})]}),(0,T.jsx)(`div`,{className:`gh-changes-diff-pane`,children:B?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`gh-changes-diff-header`,children:[(0,T.jsx)(`code`,{className:`gh-changes-diff-path`,title:B.path,children:B.path}),(0,T.jsx)(`span`,{className:`muted small`,children:_(B.kind)}),!B.binary&&(B.additions!==void 0||B.deletions!==void 0)&&(0,T.jsxs)(`span`,{className:`small`,children:[(0,T.jsxs)(`span`,{className:`gh-change-add`,children:[`+`,B.additions??0]}),` `,(0,T.jsxs)(`span`,{className:`gh-change-rem`,children:[`−`,B.deletions??0]})]})]}),E?(0,T.jsx)(f,{diff:E.diff,kind:E.kind,oldPath:E.oldPath,binary:E.binary,truncated:E.truncated}):(0,T.jsx)(`p`,{className:`muted gh-changes-loading`,children:`Loading…`})]}):(0,T.jsx)(`p`,{className:`placeholder`,children:`Pick a file to see what changed.`})}),(0,T.jsx)(u,{open:A!==null,title:`Undo changes to ${A?(e=>e.split(`/`).pop()??e)(A.path):``}?`,message:`This puts the file back to how it was at your last save. This can't be undone.`,confirmLabel:`Undo changes`,danger:!0,onConfirm:async()=>{let e=A;j(null),e&&await z({paths:[e.path]})},onCancel:()=>j(null)}),(0,T.jsx)(u,{open:M,title:`Undo all changes?`,message:`This puts all ${p(d.length,`file`)} back to how they were at your last save. This can't be undone.`,confirmLabel:`Undo everything`,danger:!0,onConfirm:async()=>{P(!1),await z({all:!0})},onCancel:()=>P(!1)})]})}var L=50;function R({projectId:e}){let[t,n]=(0,w.useState)(null),[r,a]=(0,w.useState)(!1),[o,s]=(0,w.useState)(null),[c,u]=(0,w.useState)(null),[h,g]=(0,w.useState)(!1),_=(0,w.useCallback)(async t=>{let r=await i.getProjectGitLog(e,{limit:L,skip:t});a(r.hasMore),n(e=>t===0?r.commits:[...e??[],...r.commits])},[e]);if((0,w.useEffect)(()=>{n(null),s(null),u(null),_(0).catch(()=>n([]))},[_]),(0,w.useEffect)(()=>{if(!o){u(null);return}let t=!1;return u(null),i.getProjectGitCommit(e,o).then(e=>{t||u(e)}).catch(()=>{t||u(null)}),()=>{t=!0}},[e,o]),t===null)return(0,T.jsx)(`p`,{className:`muted gh-timeline-loading`,children:`Loading…`});if(t.length===0)return(0,T.jsx)(`p`,{className:`muted gh-timeline-empty`,children:v.timelineEmpty});let y=c?.diff?d(c.diff):[];return(0,T.jsxs)(`div`,{className:`gh-timeline-layout`,children:[(0,T.jsxs)(`div`,{className:`gh-timeline-rail`,children:[(0,T.jsx)(`ul`,{className:`gh-timeline-list`,children:t.map(e=>(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{type:`button`,className:`gh-timeline-item${e.sha===o?` is-selected`:``}`,onClick:()=>s(e.sha),children:[(0,T.jsx)(`span`,{className:`gh-timeline-subject`,children:e.subject}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(e.date),children:[e.author,` saved `,p(e.filesChanged,`file`),` · `,m(e.date)]})]})},e.sha))}),r&&(0,T.jsx)(`button`,{type:`button`,className:`gh-timeline-more`,disabled:h,onClick:()=>{g(!0),_(t.length).finally(()=>g(!1))},children:h?`Loading…`:`Show earlier saves`})]}),(0,T.jsx)(`div`,{className:`gh-timeline-detail`,children:o===null?(0,T.jsx)(`p`,{className:`placeholder`,children:`Pick a save to see what changed.`}):c===null?(0,T.jsx)(`p`,{className:`muted gh-timeline-loading`,children:`Loading…`}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`gh-timeline-detail-header`,children:[(0,T.jsx)(`strong`,{children:c.subject}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(c.date),children:[c.author,` · `,m(c.date)]})]}),y.length===0?(0,T.jsx)(`p`,{className:`muted`,children:`Sync point — this save combined changes that are each shown separately.`}):y.map(e=>(0,T.jsxs)(`div`,{className:`gh-timeline-file`,children:[e.path&&(0,T.jsx)(`div`,{className:`gh-timeline-file-path`,children:(0,T.jsx)(`code`,{children:e.path})}),(0,T.jsx)(f,{diff:e.diff})]},e.path||`diff`)),c.truncated&&(0,T.jsx)(`p`,{className:`muted small`,children:v.diffBig})]})})]})}function z({projectId:e}){let[t,n]=(0,w.useState)(null),[r,a]=(0,w.useState)(null),[o,s]=(0,w.useState)(null);return(0,w.useEffect)(()=>{n(null),a(null),s(null);let t=!1;return i.listProjectGitHubPulls(e).then(e=>{t||n(e.pulls)}).catch(e=>{t||(n([]),s(e instanceof Error?e.message:String(e)))}),()=>{t=!0}},[e]),(0,T.jsxs)(`div`,{className:`project-files-layout`,children:[(0,T.jsxs)(`div`,{className:`file-tree-panel`,children:[o&&(0,T.jsx)(`p`,{className:`error`,style:{padding:`0.5rem`},children:o}),t===null&&(0,T.jsx)(`p`,{className:`muted`,style:{padding:`0.5rem`},children:`Loading…`}),t&&t.length===0&&!o&&(0,T.jsx)(`p`,{className:`muted`,style:{padding:`0.5rem`},children:`No open pull requests.`}),t&&t.length>0&&(0,T.jsx)(`ul`,{className:`pr-list`,style:{listStyle:`none`,padding:0,margin:0},children:t.map(e=>(0,T.jsx)(`li`,{style:{borderBottom:`1px solid var(--border-color, #eee)`},children:(0,T.jsxs)(`button`,{type:`button`,className:r===e.number?`active`:``,onClick:()=>a(e.number),style:{display:`block`,width:`100%`,textAlign:`left`,padding:`0.5rem 0.6rem`,background:`transparent`,border:`none`,cursor:`pointer`},children:[(0,T.jsxs)(`div`,{style:{fontWeight:500},children:[`#`,e.number,` `,e.title,` `,e.draft&&(0,T.jsx)(`em`,{className:`muted`,children:`(draft)`})]}),(0,T.jsxs)(`div`,{className:`muted small`,children:[`by `,e.author,` — `,e.headRef,` → `,e.baseRef]})]})},e.number))})]}),(0,T.jsx)(`div`,{className:`file-viewer-panel`,children:r===null?(0,T.jsx)(`p`,{className:`placeholder`,style:{padding:`2rem`},children:`Select a pull request to view its details.`}):(0,T.jsx)(B,{projectId:e,num:r})})]})}function B({projectId:e,num:t}){let[n,r]=(0,w.useState)(null),[a,o]=(0,w.useState)(null),[s,u]=(0,w.useState)(null),[d,f]=(0,w.useState)(null);return(0,w.useEffect)(()=>{r(null),o(null),u(null),f(null);let n=!1;return(async()=>{try{let[a,s,c]=await Promise.all([i.getProjectGitHubPull(e,t),V(e,t),i.listProjectGitHubPullComments(e,t)]);if(n)return;r(a),o(s),u(c.comments)}catch(e){n||f(e.message)}})(),()=>{n=!0}},[e,t]),d?(0,T.jsx)(`p`,{className:`error`,style:{padding:`1rem`},children:d}):n?(0,T.jsxs)(`div`,{style:{padding:`0.5rem 0.75rem`,overflow:`auto`,height:`calc(100vh - 320px)`},children:[(0,T.jsxs)(`h3`,{style:{marginTop:0},children:[`#`,n.number,` `,n.title]}),(0,T.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`by `,n.author,` — `,n.headRef,` → `,n.baseRef,` —`,` `,(0,T.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,children:`view on GitHub`})]}),(0,T.jsxs)(`p`,{className:`muted small`,children:[n.merged?`merged`:n.state,` · `,n.changedFiles,` files · +`,n.additions,` −`,n.deletions]}),n.body&&(0,T.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`,background:`var(--code-bg, #f6f8fa)`,padding:`0.5rem`,borderRadius:4},children:n.body}),(0,T.jsx)(`h4`,{children:`Files changed`}),a&&a.length===0&&(0,T.jsx)(`p`,{className:`muted small`,children:`No files.`}),a&&a.length>0&&(0,T.jsx)(`ul`,{style:{listStyle:`none`,padding:0},children:a.map(e=>(0,T.jsx)(`li`,{style:{marginBottom:`0.5rem`},children:(0,T.jsxs)(`details`,{children:[(0,T.jsxs)(`summary`,{children:[(0,T.jsx)(`code`,{children:e.filename}),` `,(0,T.jsxs)(`span`,{className:`muted small`,children:[e.status,` +`,e.additions,` −`,e.deletions]})]}),e.patch?(0,T.jsx)(`pre`,{style:{background:`var(--code-bg, #f6f8fa)`,padding:`0.5rem`,overflow:`auto`,fontSize:`0.8rem`},children:e.patch}):(0,T.jsx)(`p`,{className:`muted small`,children:`No patch returned (binary or too large).`})]})},e.filename))}),(0,T.jsx)(`h4`,{children:`Comments`}),s&&s.length===0&&(0,T.jsx)(`p`,{className:`muted small`,children:`No comments yet.`}),s&&s.length>0&&(0,T.jsx)(`ul`,{style:{listStyle:`none`,padding:0},children:s.map(e=>(0,T.jsxs)(`li`,{style:{marginBottom:`0.75rem`,borderLeft:`3px solid var(--border-color, #ddd)`,paddingLeft:`0.5rem`},children:[(0,T.jsxs)(`div`,{className:`muted small`,children:[(0,T.jsx)(`strong`,{children:e.author}),` · `,e.kind,e.path&&(0,T.jsxs)(T.Fragment,{children:[` `,`on `,(0,T.jsx)(`code`,{children:e.path})]}),` · `,(0,T.jsx)(`span`,{title:l(e.createdAt),children:c(e.createdAt)})]}),(0,T.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`,margin:0,fontFamily:`inherit`},children:e.body})]},e.id))})]}):(0,T.jsx)(`p`,{className:`muted`,style:{padding:`1rem`},children:`Loading…`})}async function V(e,t){let n=[],r=0;for(;;){let a=await i.listProjectGitHubPullFiles(e,t,{offset:r,limit:200,includePatch:!0});if(n.push(...a.files),!a.hasMore||a.nextOffset===void 0)return n;r=a.nextOffset}}var H=5e3,U=3e4;function W(e){let t=e instanceof Error?e.message:String(e);return t.includes(`REVIEW_IN_PROGRESS`)?v.reviewAlreadyRunning:t.includes(`NO_DEFAULT_BRANCH`)?v.reviewNoDefaultBranch:t.includes(`DETACHED_HEAD`)?v.reviewDetachedHead:t}function G(e,t){let[n,r]=(0,w.useState)([]),[a,o]=(0,w.useState)(``),s=(0,w.useRef)(n);s.current=n;let c=(0,w.useCallback)(async()=>{try{let t=await i.listProjectCodeReviews(e);r(t.reviews)}catch{}},[e]),l=n.some(e=>e.status===`running`);(0,w.useEffect)(()=>{c();let t=window.setInterval(()=>void c(),l?H:U),n=t=>{t.detail?.projectId===e&&c()};return window.addEventListener(S,n),()=>{window.clearInterval(t),window.removeEventListener(S,n)}},[c,e,l]);let u=(0,w.useCallback)(async n=>{o(n===`commit`?`start-commit`:`start-pr`);try{let a=await i.startProjectCodeReview(e,{kind:n});return r(e=>[a.review,...e.filter(e=>e.id!==a.review.id)]),t(`ok`,v.reviewStartedToast),!0}catch(e){return(e instanceof Error?e.message:String(e)).includes(`NOTHING_TO_REVIEW`)?t(`err`,n===`commit`?v.reviewNothingCommit:v.reviewNothingPr):t(`err`,W(e)),!1}finally{o(``)}},[e,t]),d=(0,w.useCallback)(async n=>{o(`cancel`);try{let a=await i.cancelProjectCodeReview(e,n);r(e=>e.map(e=>e.id===a.review.id?a.review:e)),t(`ok`,v.reviewCanceledToast)}catch(e){t(`err`,W(e))}finally{o(``)}},[e,t]);return{reviews:n,running:n.filter(e=>e.status===`running`),start:u,cancel:d,busy:a,refresh:c}}function K({project:e,onProjectChange:t}){let[n,r]=(0,w.useState)(`changes`),[c,l]=(0,w.useState)(null),[d,f]=(0,w.useState)(null),[p,m]=(0,w.useState)(``),[h,g]=(0,w.useState)(null),[_,y]=(0,w.useState)(!1),[b,E]=(0,w.useState)(!1),[D,k]=(0,w.useState)(!1),A=(0,w.useRef)(!1),M=(0,w.useCallback)((e,t)=>{g({kind:e,text:t}),window.setTimeout(()=>g(null),5e3)},[]),N=(0,w.useCallback)(async()=>{try{let t=await i.getProjectGitStatus(e.id);l(t)}catch(e){f(e.message)}},[e.id]),{reviews:P,running:F,start:L,cancel:B,busy:V}=G(e.id,M),H=(0,w.useCallback)(e=>{L(e).then(e=>{e&&r(`review`)})},[L]),{sync:U,syncing:W}=x(e.id,{onToast:M,onConflicts:()=>{r(`changes`),N()},onNeedsSave:()=>{r(`changes`),y(!0)},onAuth:()=>E(!0)}),K=(0,w.useCallback)(async()=>{A.current=!0,(await U())?.state===`synced`&&(E(!1),k(!1)),await N()},[U,N]),J=(0,w.useCallback)(e=>{e&&(E(!1),N())},[N]);(0,w.useEffect)(()=>{f(null),r(`changes`),E(!1),k(!1),A.current=!1,N()},[e.id,N]),(0,w.useEffect)(()=>{let t=window.setInterval(()=>void N(),3e4),n=t=>{t.detail?.projectId===e.id&&N()};return window.addEventListener(S,n),()=>{window.clearInterval(t),window.removeEventListener(S,n)}},[N,e.id]);let Y=c?.exists===!0;(0,w.useEffect)(()=>{if(!Y)return;let t=()=>i.fetchProjectGit(e.id).then(()=>N()).catch(e=>{q(e)&&E(!0)});t();let n=window.setInterval(()=>void t(),3e5);return()=>window.clearInterval(n)},[Y,e.id,N]);let X=(0,w.useCallback)(async()=>{m(`Downloading…`),f(null);try{await i.cloneProjectGit(e.id),t(await i.getProject(e.id)),await N()}catch(e){f(e.message)}finally{m(``)}},[e.id,N,t]),Z=c&&!c.exists,ee=c?(c.credentialSource??(c.hasPat?`pat`:`none`))===`none`:!1,Q=c?.mergeInProgress===!0,te=c?.behind??0,$=c?.changesCount??0;return(0,T.jsxs)(`div`,{className:`project-github`,children:[(0,T.jsxs)(`div`,{className:`github-toolbar`,children:[(0,T.jsx)(`strong`,{children:e.github?.url}),p&&(0,T.jsx)(`span`,{className:`status`,children:p})]}),(ee||b)&&(0,T.jsxs)(`div`,{className:`github-banner gh-banner-warn`,children:[b?`GitHub needs you to sign in again.`:`No GitHub sign-in found. Public repositories still work; sign in for private repositories, pull requests, and sending changes.`,` `,(0,T.jsx)(C,{onChange:J,compact:!0})]}),!Q&&te>0&&!D&&(0,T.jsxs)(`div`,{className:`github-banner gh-banner-nudge`,children:[(0,T.jsx)(`span`,{children:v.nudgeBanner}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void K(),disabled:W,children:W?`Syncing…`:`Sync`}),(0,T.jsx)(`button`,{type:`button`,className:`gh-banner-dismiss`,"aria-label":`Dismiss`,onClick:()=>k(!0),children:`✕`})]}),d&&(0,T.jsx)(`p`,{className:`error`,children:d}),Z?(0,T.jsxs)(`div`,{className:`gh-clone-state`,children:[(0,T.jsx)(`p`,{children:`This project lives on GitHub but isn't on this computer yet.`}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void X(),disabled:!!p,children:`Download project`})]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(s,{value:n,onValueChange:e=>r(e),children:(0,T.jsxs)(o,{children:[(0,T.jsxs)(a,{value:`changes`,children:[`Changes`,$>0&&(0,T.jsx)(`span`,{className:`gh-tab-badge`,children:$})]}),(0,T.jsx)(a,{value:`timeline`,children:`Timeline`}),(0,T.jsx)(a,{value:`prs`,children:`Pull requests`}),(0,T.jsxs)(a,{value:`review`,children:[v.reviewTabLabel,F.length>0&&(0,T.jsx)(`span`,{className:`gh-tab-badge`,children:F.length})]})]})}),n===`changes`&&(Q?(0,T.jsx)(j,{projectId:e.id,resumed:!A.current,showToast:M,onFinished:()=>{N(),K()},onExited:()=>void N()}):(0,T.jsx)(I,{projectId:e.id,onSyncRequested:()=>void K(),syncing:W,lastSyncedAt:c?.github?.lastSyncedAt,showToast:M,onReviewRequested:()=>H(`commit`),onBranchReviewRequested:()=>H(`pr`),reviewBusy:V!==``||F.some(e=>e.kind===`commit`)})),n===`timeline`&&(0,T.jsx)(R,{projectId:e.id}),n===`prs`&&(0,T.jsx)(z,{projectId:e.id}),n===`review`&&(0,T.jsx)(O,{projectId:e.id,reviews:P,busy:V,changesCount:$,branch:c?.branch,defaultBranch:c?.defaultBranch??c?.github?.defaultBranch,onStart:e=>void L(e),onCancel:e=>void B(e)})]}),h&&(0,T.jsx)(`output`,{className:`project-git-toast project-git-toast-${h.kind}`,children:h.text}),(0,T.jsx)(u,{open:_,title:v.needsSaveTitle,message:v.needsSaveBody,confirmLabel:v.needsSaveConfirm,cancelLabel:v.needsSaveCancel,onConfirm:()=>{y(!1),r(`changes`)},onCancel:()=>y(!1)})]})}function q(e){return!(e instanceof r)||!e.details||typeof e.details!=`object`?!1:`code`in e.details&&e.details.code===`MISSING_PAT`}export{K as ProjectGitHubView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-
|
|
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-CmrgM5Rf.js";import{n as i,t as a}from"./relative-time-B2kBaekd.js";import{i as o,n as s,r as c,t as l}from"./mail-link-NtlcX5OE.js";var u=e(t(),1),d=n(),f=e=>e.type.startsWith(`mail-`);function p({project:e,onProjectChange:t}){let[n,p]=(0,u.useState)(null),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(``),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(!1),[S,C]=(0,u.useState)(`imap`),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(``),[O,k]=(0,u.useState)(``),[A,j]=(0,u.useState)(``),[M,N]=(0,u.useState)(!0),P=(0,u.useCallback)(async()=>{try{p(await r.listConnectors(e.id))}catch(e){_(e instanceof Error?e.message:String(e))}},[e.id]);(0,u.useEffect)(()=>{P()},[P]);let F=(0,u.useCallback)(()=>{C(`imap`),T(``),D(``),k(``),j(``),N(!0)},[]),I=(0,u.useCallback)(async()=>{h(!0),_(``),y(``);try{let t=(n?.bindings??[]).filter(f),i=(await Promise.all(t.map(t=>r.syncConnector(e.id,t.id).then(e=>e.result).catch(()=>({}))))).reduce((e,t)=>e+(t.written??0)+(t.quarantined??0),0);y(i>0?`Synced ${i} new message(s).`:`Synced — no new mail.`),await P()}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}},[e.id,n,P]),L=(0,u.useCallback)(async()=>{_(``),y(``);let n=w.trim();if(!o(n)){_(`Enter a valid email address.`);return}if(S===`imap`&&(!E.trim()||!A)){_(`IMAP needs a host and a password.`);return}h(!0);try{S===`imap`?await c(e.id,{address:n,host:E.trim(),...O.trim()?{port:Number(O.trim())}:{},secure:M,pass:A}):await s(e.id,S,n),y(`Mailbox linked.`),x(!1),F(),await P();try{let n=await r.getProject(e.id);n&&t?.(n)}catch{}}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}},[e.id,S,w,E,O,A,M,P,t,F]),R=(n?.bindings??[]).filter(f);return(0,d.jsxs)(`div`,{className:`gz-mail-tab`,children:[(0,d.jsxs)(`div`,{className:`gz-mail-header`,children:[(0,d.jsx)(`h3`,{children:`Mail`}),R.length>0&&(0,d.jsx)(`button`,{type:`button`,onClick:()=>void I(),disabled:m,children:m?`Working…`:`Sync now`})]}),R.length===0?(0,d.jsx)(`p`,{className:`muted`,children:`No mailbox linked yet. Connect one to start syncing mail into this project as searchable files.`}):(0,d.jsx)(`ul`,{className:`gz-mail-accounts`,children:R.map(e=>(0,d.jsxs)(`li`,{className:`gz-mail-account`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`strong`,{children:e.displayName??e.id}),(0,d.jsxs)(`span`,{className:`muted small`,children:[` · `,e.type.replace(/^mail-/,``)]})]}),(0,d.jsx)(`div`,{className:`small`,children:e.lastError?(0,d.jsxs)(`span`,{className:`error`,children:[`Error: `,e.lastError]}):e.lastSyncedAt?(0,d.jsxs)(`span`,{className:`muted`,title:a(e.lastSyncedAt),children:[`Last synced `,i(e.lastSyncedAt)]}):(0,d.jsx)(`span`,{className:`muted`,children:`Not synced yet`})})]},e.id))}),b?(0,d.jsxs)(`div`,{className:`gz-mail-link-form`,children:[(0,d.jsxs)(`div`,{className:`gz-type-field`,children:[(0,d.jsx)(`span`,{className:`gz-type-field-label`,children:`Provider`}),(0,d.jsx)(`div`,{className:`gz-type-picker`,role:`radiogroup`,"aria-label":`Mail provider`,children:l.map(e=>(0,d.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.id===S,className:`gz-type-chip${e.id===S?` active`:``}`,onClick:()=>C(e.id),children:e.label},e.id))})]}),(0,d.jsxs)(`label`,{children:[`Email address`,(0,d.jsx)(`input`,{type:`email`,value:w,onChange:e=>T(e.target.value),placeholder:`you@example.com`,autoComplete:`email`})]}),S===`imap`?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`label`,{children:[`IMAP host`,(0,d.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),placeholder:`imap.example.com`})]}),(0,d.jsxs)(`div`,{className:`gz-imap-row`,children:[(0,d.jsxs)(`label`,{className:`gz-imap-port`,children:[`Port `,(0,d.jsx)(`span`,{className:`muted`,children:`(optional)`}),(0,d.jsx)(`input`,{value:O,onChange:e=>k(e.target.value),placeholder:`993`,inputMode:`numeric`})]}),(0,d.jsxs)(`label`,{className:`gz-imap-tls`,children:[(0,d.jsx)(`input`,{type:`checkbox`,checked:M,onChange:e=>N(e.target.checked)}),`Use TLS`]})]}),(0,d.jsxs)(`label`,{children:[`Password / app password`,(0,d.jsx)(`input`,{type:`password`,value:A,onChange:e=>j(e.target.value),autoComplete:`off`})]})]}):(0,d.jsxs)(`p`,{className:`muted small`,children:[`You'll authorize `,l.find(e=>e.id===S)?.label,` in your browser — a window opens when you click Connect.`]}),(0,d.jsxs)(`div`,{className:`gz-mail-link-actions`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>{x(!1),F(),_(``)},disabled:m,children:`Cancel`}),(0,d.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void L(),disabled:m,children:m?`Connecting…`:S===`imap`?`Link`:`Connect`})]})]}):(0,d.jsx)(`button`,{type:`button`,className:`gz-mail-connect`,onClick:()=>{x(!0),_(``),y(``)},children:`Connect a mailbox`}),g&&(0,d.jsx)(`p`,{className:`error small`,children:g}),v&&(0,d.jsx)(`p`,{className:`muted small`,children:v})]})}export{p as ProjectMailTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{it as r,ln as i}from"./dist-CE5CbmDb.js";import{t as a}from"./api-CmrgM5Rf.js";import{t as o}from"./ConfirmDialog-Dt1ed4Fh.js";import{g as s}from"./index-DivKnJyx.js";import{t as c}from"./MarkdownField-BX0qsaFq.js";import{a as l,i as u}from"./WorkspaceIndexPane-fu5V6o1W.js";var d=e(t(),1),f=n();function p({projectId:e}){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(null),[s,c]=(0,d.useState)(``),[u,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(null),g=(0,d.useCallback)(async()=>{try{n(await a.listPeople(e))}catch{n(null)}},[e]);(0,d.useEffect)(()=>{g()},[g]);let _=(0,d.useCallback)(t=>a.fetchProjectWorkspaceBlob(e,t),[e]),v=(0,d.useCallback)(async t=>{let n=s.trim();if(i(null),!(!n||n===t.label)){h(null);try{await a.renamePerson(e,t.entityId,n),await g()}catch(e){h(e instanceof Error?e.message:String(e))}}},[s,e,g]),y=(0,d.useCallback)(async()=>{if(u){h(null);try{await a.forgetPerson(e,u.entityId),p(null),await g()}catch(e){h(e instanceof Error?e.message:String(e))}}},[u,e,g]);return!t?.available||t.people.length===0?null:(0,f.jsxs)(`section`,{className:`people-panel`,children:[(0,f.jsx)(`h3`,{children:`People`}),(0,f.jsx)(`p`,{className:`muted small`,children:`Recognized locally from photos in this project. Name someone once and search can find them everywhere.`}),(0,f.jsx)(`div`,{className:`people-grid`,children:t.people.map(e=>(0,f.jsxs)(`div`,{className:`people-card`,children:[(0,f.jsx)(`div`,{className:`people-card-photo`,children:e.exemplar?(0,f.jsx)(l,{path:e.exemplar.path,fetchBlob:_,alt:e.label}):(0,f.jsx)(`span`,{className:`similar-thumb-fallback`,children:e.label.slice(0,1)})}),r===e.entityId?(0,f.jsx)(`input`,{className:`people-card-rename`,value:s,ref:e=>e?.focus(),onChange:e=>c(e.target.value),onBlur:()=>void v(e),onKeyDown:t=>{t.key===`Enter`&&v(e),t.key===`Escape`&&i(null)},"aria-label":`Name for ${e.label}`}):(0,f.jsx)(`button`,{type:`button`,className:`people-card-name`,title:`Who is this?`,onClick:()=>{c(/^Person \d+$/.test(e.label)?``:e.label),i(e.entityId)},children:e.label}),(0,f.jsxs)(`span`,{className:`muted small`,children:[e.count,` photo`,e.count===1?``:`s`]}),(0,f.jsx)(`button`,{type:`button`,className:`people-card-forget`,onClick:()=>p(e),children:`Forget`})]},e.entityId))}),m&&(0,f.jsx)(`p`,{className:`error small`,children:m}),(0,f.jsx)(o,{open:u!==null,title:`Forget ${u?.label??`this person`}?`,message:`They disappear from People and search, and new photos of them stay unlisted. This does not delete any photos. To erase all face data instead, use Settings.`,confirmLabel:`Forget`,danger:!0,onConfirm:y,onCancel:()=>p(null)})]})}function m({label:e,hint:t,children:n,testId:r}){return(0,f.jsxs)(`section`,{"data-testid":r,children:[(0,f.jsxs)(`div`,{className:`home-workshop-rail-head`,children:[(0,f.jsx)(`div`,{className:`home-workshop-eyebrow`,style:{whiteSpace:`nowrap`},children:e}),t&&(0,f.jsx)(`div`,{className:`home-workshop-rail-hint`,children:t})]}),n]})}var h=()=>void 0;function g(e){let t=e.filter(e=>!e.isDirectory&&/^reports\/digest-\d{4}-W\d{2}\.md$/.test(e.path)).map(e=>e.path).sort();return t[t.length-1]??null}function _({projectId:e,project:t}){let[n,o]=(0,d.useState)(null),[l,_]=(0,d.useState)(null),[v,y]=(0,d.useState)([]),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)([]);(0,d.useEffect)(()=>{let t=!1;return o(null),x(null),C([]),a.toolMapRepo(e,{}).then(e=>{t||o(e)}).catch(()=>{t||o(null)}),a.getProjectIndexStatus(e).then(e=>{t||_(e)}).catch(()=>void 0),a.listHistory({projectId:e,limit:8}).then(e=>{t||y(e.entries)}).catch(()=>void 0),a.toolListTables(e).then(e=>{t||C(e.tables)}).catch(()=>void 0),a.listProjectArtifacts(e,`reports`,!0).then(async n=>{let r=g(n.files);if(!r||t)return;let i=await a.readProjectArtifact(e,r);t||x({path:r,content:i.content})}).catch(()=>void 0),()=>{t=!0}},[e]);let w=i(t),T=w?r(w)?.label??w:null,E=(n?.areas??[]).filter(e=>e.purpose),D=l?.state===`indexing`,O=l?.state===`disabled`,k=l?.aiScanPending===!0,A=l?.enrichment?.reviews?.pending??0;return(0,f.jsxs)(`div`,{className:`project-overview`,children:[(0,f.jsxs)(`div`,{className:`project-overview-head`,children:[(0,f.jsxs)(`div`,{className:`project-overview-title`,children:[(0,f.jsx)(s,{project:t,size:24,className:`project-overview-icon`}),(0,f.jsx)(`h2`,{children:t.name})]}),(0,f.jsxs)(`div`,{className:`project-overview-meta`,children:[T&&(0,f.jsx)(`span`,{className:`project-overview-chip`,children:T}),n?.indexed&&(0,f.jsxs)(`span`,{className:`project-overview-chip muted`,children:[n.fileCount,` files indexed`]}),(D||k)&&(0,f.jsx)(`span`,{className:`project-overview-chip pending`,children:u(l)})]})]}),!n?.indexed&&O&&(0,f.jsxs)(`p`,{className:`muted`,children:[`Workspace indexing is off for this project.`,` `,(0,f.jsx)(`button`,{type:`button`,className:`project-index-panel-link`,onClick:()=>window.dispatchEvent(new CustomEvent(`gezel:open-project-settings`,{detail:{projectId:e}})),children:`Turn it on in Project Settings`}),`.`]}),!n?.indexed&&!O&&(0,f.jsx)(`p`,{className:`muted`,children:`The boekwachter hasn't scanned this workspace yet. The map, folder notes, and architecture summary appear here once indexing runs.`}),n?.architecture&&(0,f.jsx)(m,{label:`Architecture`,testId:`overview-architecture`,children:(0,f.jsx)(`p`,{className:`project-overview-architecture`,children:n.architecture})}),n?.indexed&&!n.architecture&&(0,f.jsx)(m,{label:`Architecture`,children:(0,f.jsx)(`p`,{className:`muted small`,children:`Not written yet — the boekwachter distills an architecture note after it has summarized the files (idle time or Night Shift).`})}),n?.health&&(0,f.jsxs)(m,{label:`Health`,testId:`overview-health`,children:[(0,f.jsxs)(`div`,{className:`project-overview-chips`,children:[(0,f.jsxs)(`span`,{className:`project-overview-chip`,children:[`avg `,n.health.avgHealth,`/10`]}),(0,f.jsxs)(`span`,{className:`project-overview-chip muted`,children:[n.health.reviewedFiles,`/`,n.health.eligibleFiles,` files reviewed`]}),n.health.majorIssues>0&&(0,f.jsxs)(`span`,{className:`project-overview-chip pending`,children:[n.health.majorIssues,` major issue`,n.health.majorIssues===1?``:`s`]}),n.health.minorIssues>0&&(0,f.jsxs)(`span`,{className:`project-overview-chip muted`,children:[n.health.minorIssues,` minor`]})]}),A>0&&(0,f.jsxs)(`p`,{className:`muted small`,children:[`The boekwachter is still reviewing — `,A,` file`,A===1?``:`s`,` to go. Scores are its opinion, not a verdict.`]}),n.health.worstFiles.length>0&&(0,f.jsx)(`ul`,{className:`project-overview-areas`,children:n.health.worstFiles.map(t=>(0,f.jsxs)(`li`,{children:[(0,f.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>window.dispatchEvent(new CustomEvent(`gezel:open-file`,{detail:{projectId:e,path:t.path,source:`workspace`}})),children:(0,f.jsx)(`code`,{children:t.path})}),(0,f.jsxs)(`span`,{className:`muted small`,children:[` `,t.health,`/10`]}),t.reason&&(0,f.jsx)(`div`,{className:`muted small`,children:t.reason})]},t.path))})]}),E.length>0&&(0,f.jsx)(m,{label:`Areas`,testId:`overview-areas`,children:(0,f.jsx)(`ul`,{className:`project-overview-areas`,children:E.slice(0,10).map(e=>(0,f.jsxs)(`li`,{children:[(0,f.jsx)(`code`,{children:e.path===`.`?`(root)`:`${e.path}/`}),(0,f.jsxs)(`span`,{className:`muted small`,children:[` `,e.fileCount,` files`]}),(0,f.jsx)(`div`,{children:e.purpose})]},e.path))})}),n&&(n.languages.length>0||n.entryPoints.length>0)&&(0,f.jsxs)(m,{label:`Shape`,children:[n.languages.length>0&&(0,f.jsx)(`div`,{className:`project-overview-chips`,children:n.languages.slice(0,8).map(e=>(0,f.jsxs)(`span`,{className:`project-overview-chip muted`,children:[e.lang,` · `,e.fileCount]},e.lang))}),n.entryPoints.length>0&&(0,f.jsxs)(`p`,{className:`small`,children:[`Entry points:`,` `,n.entryPoints.slice(0,6).map((e,t)=>(0,f.jsxs)(`span`,{children:[t>0&&`, `,(0,f.jsx)(`code`,{children:e})]},e))]})]}),(0,f.jsx)(p,{projectId:e}),v.length>0&&(0,f.jsx)(m,{label:`Recent activity`,testId:`overview-activity`,children:(0,f.jsx)(`ul`,{className:`project-overview-activity`,children:v.map(e=>(0,f.jsxs)(`li`,{children:[(0,f.jsx)(`span`,{className:`muted small`,children:(e.entryType===`event`?e.at:e.lastActivityAt).slice(0,10)}),` `,e.entryType===`event`?e.summary:`Chat: ${e.title}`]},e.id))})}),S.length>0&&(0,f.jsx)(m,{label:`Data tables`,hint:`${S.length} table${S.length===1?``:`s`}`,children:(0,f.jsx)(`ul`,{className:`project-overview-tables`,children:S.map(e=>(0,f.jsxs)(`li`,{className:`small`,children:[(0,f.jsx)(`strong`,{children:e.table}),` `,(0,f.jsxs)(`span`,{className:`muted`,children:[e.rows.toLocaleString(),` `,e.rows===1?`row`:`rows`,` · `,e.columns,` columns`,e.origin===`workspace`?` · from ${e.source}`:` · ${e.source}`,e.schemaInferred?` · schema inferred`:``]})]},`${e.origin}:${e.table}`))})}),b&&(0,f.jsxs)(m,{label:`Latest weekly digest`,hint:b.path,children:[(0,f.jsx)(`div`,{className:`project-overview-digest`,children:(0,f.jsx)(c,{value:b.content,readOnly:!0,onCommit:h},b.path)}),(0,f.jsx)(`button`,{type:`button`,className:`project-overview-open-digest`,onClick:()=>window.dispatchEvent(new CustomEvent(`gezel:open-file`,{detail:{projectId:e,path:b.path,source:`artifacts`}})),children:`Open in artifacts`})]})]})}export{_ as ProjectOverviewView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{zt as r}from"./dist-CE5CbmDb.js";import{t as i}from"./api-CmrgM5Rf.js";import{qt as a}from"./index-DivKnJyx.js";import{t as o}from"./ChatTimelineView-Dn1TNyVn.js";var s=e(t(),1),c=750,l=15e3;function u({projectId:e,refreshKey:t}){let[n,r]=(0,s.useState)([]),[o,u]=(0,s.useState)([]),[d,f]=(0,s.useState)(!0),p=(0,s.useCallback)(async()=>{try{let t=await i.listProjectTasks(e,{status:`active`});r(t.tasks),u(t.waiting??[])}catch{}finally{f(!1)}},[e]);(0,s.useEffect)(()=>{f(!0),p()},[p,t]);let m=(0,s.useRef)(null);(0,s.useEffect)(()=>{let t=new AbortController,n=()=>{m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>{m.current=null,p()},c)};return(async()=>{try{for await(let r of a({url:i.projectEventsUrl(e),headers:i.authHeader(),signal:t.signal,fetch:i.getFetch()}))r.event.type===`task_event`&&n()}catch{}})(),()=>{t.abort(),m.current!==null&&(window.clearTimeout(m.current),m.current=null)}},[e,p]);let h=o.length>0;return(0,s.useEffect)(()=>{if(!h)return;let e=window.setInterval(()=>void p(),l);return()=>window.clearInterval(e)},[h,p]),{tasks:n,waiting:o,loading:d}}function d(e){let{tasks:t,waiting:n,gezelId:r,taskRef:i}=e;if(n.length===0)return[];let a=new Map(t.map(e=>[e.ref,e])),o=[];for(let e of n){if(i&&e.ref!==i||r&&e.gezelId!==r)continue;let t=a.get(e.ref);t&&o.push({task:t,wait:e})}return o.sort((e,t)=>Date.parse(e.wait.since)-Date.parse(t.wait.since)),o}var f=n();function p({projectId:e,gezelId:t,taskRef:n,activeSessionId:a,onFocusSession:c,onToolActivity:l,onArtifactReference:p,onArtifactSeen:h,onWorkspaceReference:g,onWorkspaceSeen:_,onOpenReference:v,onTaskReference:y,emptyPlaceholder:b,onTerminalWorkingDirChanged:x,terminalRefreshKey:S,terminalSubmission:C,terminalFocusRequest:w,sessionFocusRequest:T}){let E=(0,s.useCallback)(r=>i.listProjectTimeline(e,{...r,...t?{gezelId:t}:{},...n?{taskRef:n}:{}}),[e,t,n]),D=(0,s.useCallback)(()=>t?i.gezelEventsUrl(t):i.projectEventsUrl(e),[e,t]),O=(0,s.useCallback)(()=>i.terminalEventsUrl(e),[e]),k=(0,s.useMemo)(()=>t?{projectId:e,gezelId:t}:{projectId:e},[e,t]),[A,j]=(0,s.useState)(m),[M,N]=(0,s.useState)(0);(0,s.useEffect)(()=>{if(!n){j(m);return}let e=r(n);if(!e){j(m);return}let t=!1;return i.listTaskSessions(e.projectId,e.num).then(e=>{t||j(new Set(e.sessions.filter(e=>!e.archived).map(e=>e.id)))}).catch(()=>{}),()=>{t=!0}},[n,M]);let P=(0,s.useMemo)(()=>{if(n)return!a||A.has(a)?A:new Set([...A,a])},[n,A,a]),F=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{F.current!==null&&(window.clearTimeout(F.current),F.current=null)},[]);let I=(0,s.useCallback)(()=>{F.current===null&&(F.current=window.setTimeout(()=>{F.current=null,N(e=>e+1)},500))},[]),{tasks:L,waiting:R}=u({projectId:e}),z=(0,s.useMemo)(()=>d({tasks:L,waiting:R,gezelId:t,taskRef:n}),[L,R,t,n]);return(0,f.jsx)(o,{scopeKey:n?`project:${e}:task:${n}`:t?`project:${e}:gezel:${t}`:`project:${e}`,activeSessionId:a,onFocusSession:c,onToolActivity:l,onArtifactReference:p,onArtifactSeen:h,onWorkspaceReference:g,onWorkspaceSeen:_,onOpenReference:v,...y?{onTaskReference:y}:{},queuedTasks:z,emptyPlaceholder:b,loadTimeline:E,streamUrl:D,...t||n?{}:{terminalStreamUrl:O},...S===void 0?{}:{terminalRefreshKey:S},...C?{terminalSubmission:C}:{},...w?{terminalFocusRequest:w}:{},...T?{sessionFocusRequest:T}:{},...t||n||!x?{}:{onTerminalWorkingDirChanged:x},inflightScope:k,...P?{scopedSessionIds:P,onUnknownSession:I}:{}})}var m=new Set;export{u as n,p as t};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProjectChat-Dhw_M5bq.js","assets/rolldown-runtime-aKtaBQYM.js","assets/jsx-runtime-CEpd2cAX.js","assets/dist-CE5CbmDb.js","assets/api-CmrgM5Rf.js","assets/dist-BMZhqfv7.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-DivKnJyx.js","assets/NewPathDialog-BhAZm9dp.js","assets/FileTypeIcon-Cwzl1GkZ.js","assets/model-context-DBqdK0PS.js","assets/model-memory-copy-Ds9w1uJE.js","assets/StorageCleanupDialog-CDBjl8JQ.js","assets/poppetje-DvCJO36y.js","assets/safe-svg-image-NbuPaBIv.js","assets/ConfirmDialog-Dt1ed4Fh.js","assets/model-inventory-ykSm_IT5.js","assets/doc-BHcGsJZd.js","assets/chunk-X7BNDUNI-D14WIvlD.js","assets/chunk-BAOV476U-CEOFYt8X.js","assets/chunk-4VOD55SX-BFSSw0c8.js","assets/chunk-GAZKTT4R-w1SNypWQ.js","assets/chunk-CW24CH7I-BD0FIooX.js","assets/chunk-XRW6P7IF-BeQQgMVK.js","assets/chunk-7ZAAICW4-BsCpYJH6.js","assets/markdown-CLKH_zzl.js","assets/schemas-BvLZUsGm.js","assets/chunk-6ECMNUIP-D5AA6ozp.js","assets/inlineIconMarker-BQI2HLeD.js","assets/chunk-TT6ENR6T-BOA-qiwP.js","assets/chunk-DQRELU4S--U9FIVtY.js","assets/new-project-meta-5Y9Blozr.js","assets/chunk-ZSU5DJLX-CrjQf-vs.js","assets/index-DW6qHqhU.css","assets/NewTaskDialog-BX24flMY.js","assets/GezelJsonEditor-B9XEiW5Y.js","assets/dist-1FNFiksd.js","assets/icons-CyM7Cg4E.js","assets/CraftbookToolsetSetup-J7rEa835.js","assets/ToolsetConfigForm-gUVMTPR_.js","assets/useShowWorkInProgressFeatures-D6QOaTUT.js","assets/ChatTimelineView-Dn1TNyVn.js","assets/styles-CqO-rmOt.js","assets/chunk-KGWT454C-DsQOBuLg.js","assets/chunk-V4NBQF5C-D9I4DV9v.js","assets/storage-Cmhlwx70.js","assets/table-fcouR4db.js","assets/dist-BNFgFOsA.js","assets/transform-DxJCwK68.js","assets/styles-BjDaWeMA.css","assets/SquisqIntegration-BTZ1kBlg.js","assets/outside-in-Msmhxf_U.js","assets/chunk-7AWFHP5U-MiVVPFTx.js","assets/jszip.min-DhiFe-R7.js","assets/html-BnA7qFwq.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-B2Ya6sbf.js","assets/microphone-input-5gqW_NKf.js","assets/composer-prefill-CbG_i1Rx.js","assets/SessionSwitcher-D0fSeeHO.js","assets/ProjectTimeline-Cqae2Z92.js","assets/chat-thread-memory-8MCtb17Q.js","assets/useCompactLayout-cm4E9Vja.js","assets/GitDiffView-DrDrSeBb.js","assets/gitCopy-Dcjz17cJ.js","assets/completion-data--97asQiQ.js","assets/ProjectConnectionsTab-BwpMQNrg.js","assets/ProjectMailTab-qFmAeV3M.js","assets/mail-link-NtlcX5OE.js","assets/DiffpackReviewView-CD4qJmgT.js","assets/MarkdownField-BX0qsaFq.js","assets/useDiffpacks-1BN2XJWg.js","assets/FileMapView-kVBG22FU.js","assets/HistoryView-CKWcWW-Y.js","assets/ProjectGithubView-CTP1BOMv.js","assets/useGitSync-7m9YA7h5.js","assets/GithubSignInChip-eEGCe9ar.js","assets/ProjectOverviewView-Cq1FsoaT.js","assets/WorkspaceIndexPane-fu5V6o1W.js","assets/TasksView-Ddwz10ri.js","assets/TaskTabContent-C0P681SL.js","assets/TransformToolbarButton-8wfJR1bO.js","assets/pending-drafts-BD227X9H.js","assets/NewScriptDialog-DuryIe50.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{At as r,Gt as i,Kt as a,Pt as o,R as s,St as c,T as l,Tt as u,Ut as d,Vt as f,W as p,Zt as m,ft as h,it as g,ln as _,un as v,wn as y,yt as b}from"./dist-CE5CbmDb.js";import{t as x}from"./dist-BMZhqfv7.js";import{t as S}from"./api-CmrgM5Rf.js";import{i as C,n as w,r as ee}from"./Tabs-jE0Z5Tzd.js";import{G as T,H as te,J as ne,K as re,W as ie,Y as ae,d as oe,l as se,m as ce,p as le,q as ue,s as de,y as E}from"./primitives-CWrGZpPI.js";import{_ as D,c as fe,d as pe,f as me,h as he,i as ge,l as _e,m as O,p as ve,u as k,y as ye}from"./NewPathDialog-BhAZm9dp.js";import{t as be}from"./poppetje-DvCJO36y.js";import{n as xe,t as Se}from"./relative-time-B2kBaekd.js";import{t as Ce}from"./ConfirmDialog-Dt1ed4Fh.js";import{t as A}from"./preload-helper-Czpn1I53.js";import{l as j,t as M}from"./styles-CqO-rmOt.js";import{t as we}from"./GezelJsonEditor-B9XEiW5Y.js";import{a as N,i as P,n as F,o as Te,r as I,t as Ee}from"./new-project-meta-5Y9Blozr.js";import{Ct as De,O as Oe,Wt as ke,Z as Ae,_ as je,_t as L,a as Me,at as R,d as Ne,g as Pe,j as Fe,n as Ie,q as Le,rt as Re,t as z,u as ze,v as Be}from"./index-DivKnJyx.js";import"./storage-Cmhlwx70.js";import"./provider-default-BLsHrgzI.js";import{a as Ve,c as He,i as Ue,o as We,r as Ge}from"./SquisqIntegration-BTZ1kBlg.js";import{t as Ke}from"./useShowWorkInProgressFeatures-D6QOaTUT.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-BLOPfnS0.js";import{a as nt,c as rt,d as it,f as at,l as ot,n as st,r as ct,s as lt,t as ut,u as dt}from"./outside-in-Msmhxf_U.js";import{n as ft}from"./composer-prefill-CbG_i1Rx.js";import{n as pt,r as W,t as mt}from"./useCompactLayout-cm4E9Vja.js";import{n as ht,r as gt}from"./mail-link-NtlcX5OE.js";import{t as _t}from"./ToolsetsEditor-KVigemfL.js";import{t as vt}from"./useDiffpacks-1BN2XJWg.js";import{i as yt,n as bt,o as xt,r as St,t as Ct}from"./WorkspaceIndexPane-fu5V6o1W.js";import{n as wt}from"./MemoriesTree-BPj5Rod8.js";import{t as Tt}from"./ProjectGitStatusBar-BORGYx5l.js";import{t as Et}from"./markdown-baseline-0dqv9qbV.js";import{n as Dt,t as Ot}from"./TransformToolbarButton-8wfJR1bO.js";import{t as kt}from"./GithubSignInChip-eEGCe9ar.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=Fe(),l=e.find(e=>e.id===t),u=[`gezel-picker-trigger`,s].filter(Boolean).join(` `);return(0,K.jsxs)(oe,{value:l?.id??At,disabled:o,onValueChange:e=>n(e===At?null:e),children:[(0,K.jsx)(le,{className:u,"aria-label":a,children:(0,K.jsx)(ce,{children:l?(0,K.jsx)(Mt,{gezel:l,roleBasedNameOnly:c}):(0,K.jsx)(`span`,{className:`gezel-picker-empty`,children:r??i})})}),(0,K.jsxs)(de,{className:`gezel-picker-menu`,children:[r&&(0,K.jsx)(se,{value:At,children:r}),e.map(e=>(0,K.jsx)(se,{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=p(e,t);return(0,K.jsxs)(`span`,{className:`gezel-picker-option`,children:[(0,K.jsx)(ke,{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=p(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[p(e,n),e.role??``].some(e=>e.toLocaleLowerCase().includes(t))}function zt(e,t){return[e.manifest.name,e.manifest.role,e.manifest.description,...e.manifest.tags].some(e=>e.toLocaleLowerCase().includes(t))}function Bt({open:e,project:t,gezels:n,roleBasedNameOnlyMode:r,onClose:i,onAddExisting:a,onCreateTemplate:o}){let[s,c]=(0,G.useState)([]),[l,u]=(0,G.useState)(!1),[m,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(null),[x,C]=(0,G.useState)(``),[w,ee]=(0,G.useState)(null),[oe,se]=(0,G.useState)(``),[ce,le]=(0,G.useState)(),[de,E]=(0,G.useState)(It),D=g(_(t));(0,G.useEffect)(()=>{if(!e)return;let t=!1;return u(!0),b(null),C(``),ee(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);c([...n.values()])}).catch(e=>{t||b(e.message)}).finally(()=>{t||u(!1)}),()=>{t=!0}},[e]);let fe=(0,G.useMemo)(()=>new Set([...t.gezelIds??[],...t.voormanGezelId?[t.voormanGezelId]:[]]),[t.gezelIds,t.voormanGezelId]),pe=(0,G.useMemo)(()=>{let e=new Map,t=0;for(let n of D?.gezelRoles.default??[])e.set(n.templateId,{...n,tier:`default`,rank:t++});for(let n of D?.gezelRoles.suggested??[])e.has(n.templateId)||e.set(n.templateId,{...n,tier:`suggested`,rank:t++});return e},[D]),me=(0,G.useMemo)(()=>{let e=new Map;for(let t of s){let n=pe.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},[pe,s]),he=(0,G.useMemo)(()=>new Set(n.flatMap(e=>e.templateId?[e.templateId]:[])),[n]),ge=(0,G.useMemo)(()=>new Set(n.flatMap(e=>[e.role,e.roleBasedName].map(q).filter(Boolean))),[n]),_e=(0,G.useMemo)(()=>n.filter(e=>!fe.has(e.id)&&e.scope!==`project`).sort((e,t)=>p(e,r).localeCompare(p(t,r))),[fe,n,r]),O=(0,G.useMemo)(()=>s.filter(e=>!he.has(e.manifest.id)&&!ge.has(q(e.manifest.role))&&!ge.has(q(e.manifest.name))).sort((e,t)=>e.manifest.name.localeCompare(t.manifest.name)),[ge,he,s]),ve=(0,G.useCallback)(e=>{if(e.templateId){let t=pe.get(e.templateId);if(t)return t}for(let t of[q(e.role),q(e.roleBasedName)]){let e=me.get(t);if(e)return e}},[me,pe]),k=(0,G.useMemo)(()=>{let e=[];for(let t of _e){let n=ve(t);n&&e.push({kind:`existing`,gezel:t,affinity:n})}for(let t of O){let n=pe.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`?p(e.gezel,r):e.template.manifest.name).localeCompare(t.kind===`existing`?p(t.gezel,r):t.template.manifest.name))},[ve,_e,O,pe,r]),ye=(0,G.useMemo)(()=>new Set(k.flatMap(e=>e.kind===`existing`?[e.gezel.id]:[])),[k]),xe=(0,G.useMemo)(()=>new Set(k.flatMap(e=>e.kind===`template`?[e.template.manifest.id]:[])),[k]),Se=(0,G.useMemo)(()=>_e.filter(e=>!ye.has(e.id)),[_e,ye]),Ce=(0,G.useMemo)(()=>O.filter(e=>!xe.has(e.manifest.id)),[O,xe]),A=x.trim().toLocaleLowerCase(),j=(0,G.useMemo)(()=>A?k.filter(e=>e.kind===`existing`?Rt(e.gezel,A,r):zt(e.template,A)):k,[A,r,k]),M=(0,G.useMemo)(()=>A?Se.filter(e=>Rt(e,A,r)):Se,[A,Se,r]),we=(0,G.useMemo)(()=>A?Ce.filter(e=>zt(e,A)):Ce,[A,Ce]),N=()=>{m||i()},P=async e=>{v(!0),b(null);try{await a(e),i()}catch(e){b(e.message)}finally{v(!1)}},F=async(e,t)=>{v(!0),b(null);try{await o(e.manifest.id,t),i()}catch(e){b(e.message)}finally{v(!1)}},Te=e=>{if(r){F(e,{name:e.manifest.name});return}let t=f(),n=e.manifest.nameSuggestions??[],i=n.length>0?n[Math.floor(Math.random()*n.length)]:t.name;ee(e),se(i??t.name),le(t.gender),E(It()),b(null)},I=w&&oe.trim()?d(de,{key:`project-add-preview:${w.manifest.id}`,name:oe.trim(),gender:ce}):null;return(0,K.jsx)(ne,{open:e,onOpenChange:e=>!e&&N(),children:(0,K.jsxs)(ue,{children:[(0,K.jsx)(re,{}),(0,K.jsxs)(ie,{className:`project-add-gezel-dialog`,children:[(0,K.jsx)(ae,{asChild:!0,children:(0,K.jsx)(`h3`,{children:w?`Customize ${w.manifest.name}`:`Add Gezel`})}),(0,K.jsx)(T,{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(),oe.trim()&&F(w,{name:oe.trim(),...ce?{gender:ce}:{},appearanceSeed:de})},children:[(0,K.jsx)(`div`,{className:`project-add-gezel-preview`,"aria-hidden":`true`,children:I&&(0,K.jsx)(be,{poppetje:I,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:oe,onChange:e=>se(e.target.value),disabled:m})]}),(0,K.jsx)(`button`,{type:`button`,className:`subtle`,disabled:m,onClick:()=>E(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)(te,{children:[(0,K.jsx)(`button`,{type:`button`,disabled:m,onClick:()=>{ee(null),b(null)},children:`Back`}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:m||!oe.trim(),children:m?`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:m})]}),(0,K.jsxs)(`div`,{className:`project-add-gezel-options`,children:[j.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`}),D&&(0,K.jsxs)(`p`,{className:`muted small project-add-gezel-section-hint`,children:[D.label,` projects often benefit from these roles.`]}),(0,K.jsx)(`ul`,{className:`project-add-gezel-list`,children:j.map(e=>{let t=e.affinity.tier==="default"?`Core role`:`Suggested`;if(e.kind===`existing`){let n=p(e.gezel,r);return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:`project-add-gezel-option`,disabled:m,onClick:()=>void P(e.gezel.id),children:[(0,K.jsx)(ke,{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:m,onClick:()=>Te(e.template),children:[(0,K.jsx)(ke,{poppetje:h(`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`}),M.length>0?(0,K.jsx)(`ul`,{className:`project-add-gezel-list`,children:M.map(e=>{let t=p(e,r);return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:`project-add-gezel-option`,disabled:m,onClick:()=>void P(e.id),children:[(0,K.jsx)(ke,{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:Se.length>0?`No workshop gezels match that search.`:k.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`}),l&&(0,K.jsx)(`p`,{className:`muted small`,children:`Loading roles…`}),!l&&we.length>0?(0,K.jsx)(`ul`,{className:`project-add-gezel-list`,children:we.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:`project-add-gezel-option`,disabled:m,onClick:()=>Te(e),children:[(0,K.jsx)(ke,{poppetje:h(`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))}):!l&&(0,K.jsx)(`p`,{className:`muted small project-add-gezel-empty`,children:Ce.length>0?`No new roles match that search.`:k.some(e=>e.kind===`template`)?`No other role types are available.`:`Every role type already has a gezel.`})]})]}),(0,K.jsx)(te,{children:(0,K.jsx)(`button`,{type:`button`,onClick:N,disabled:m,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=L(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)(we,{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=Fe(),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[f,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)){d(!0),m(null);try{await n(t.id)}catch(e){m(e.message)}finally{d(!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=p({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)(ke,{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:u||!o,onClick:()=>void v(`remove`),children:u?`Updating…`:`Remove Boekwachter`}):(0,K.jsx)(`button`,{type:`button`,className:`subtle`,disabled:u||!g||!i,onClick:()=>void v(`add`),children:u?`Updating…`:g?`Add ${g.name}`:`No Boekwachter available`})]}),f&&(0,K.jsx)(`p`,{className:`error small project-autonomous-role-error`,children:f}),(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,ee]=(0,G.useState)(`idle`),[T,te]=(0,G.useState)(null),ne=(0,G.useRef)([]),re=(0,G.useRef)(null),ie=(0,G.useRef)(null),ae=mt(ie,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 ue=(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]),E=(n?ue[0]:void 0)??(s?ue.find(e=>e.source===`workspace`&&e.path===s):void 0)??ue.find(e=>e.source===`workspace`),D=ue.find(e=>e.id===a)??E??null,fe=(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(z,e),()=>{window.removeEventListener(z,e),Ie(!1)}},[]),(0,G.useEffect)(()=>{Ie(p)},[p]);let pe=(0,G.useCallback)(()=>{!D||!T||window.open(T,`_blank`,`noopener,noreferrer`)},[D,T]),me=(0,G.useCallback)(e=>{let t=[...ne.current,e];ne.current=t.length>200?t.slice(-200):t},[]);(0,G.useEffect)(()=>{ne.current=[],v(``),C(null),ee(`idle`)},[D?.id,d]),(0,G.useEffect)(()=>{y||(C(null),ee(`idle`))},[y]);let he=(0,G.useCallback)(e=>{C(e),ee(`idle`)},[]),ge=(0,G.useCallback)(async()=>{if(x)try{await navigator.clipboard.writeText(sn(x)),ee(`copied`)}catch{ee(`error`)}},[x]),_e=(0,G.useCallback)(async()=>{if(!D||h)return;let t=window.__GEZEL__?.capturePageRegion;if(!t){v(`Screenshots need the desktop app.`);return}let n=re.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(D.path,s,ne.current);i?.(c)}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[e,D,h,i]),O=[{key:`reload`,label:`Reload`,icon:(0,K.jsx)(Zt,{}),onClick:fe,disabled:!D,title:`Reload the preview`,ariaLabel:`Reload the preview`},{key:`open`,label:`Open in browser`,icon:(0,K.jsx)(Qt,{}),onClick:pe,disabled:!D||!T,title:`Open in your default browser`,ariaLabel:`Open in your default browser`},{key:`maximize`,label:p?`Restore`:`Maximize`,icon:p?(0,K.jsx)(en,{}):(0,K.jsx)($t,{}),onClick:()=>m(e=>!e),title:p?`Restore (F5)`:`Maximize (F5)`,ariaLabel:p?`Restore output pane`:`Maximize output pane`}];p||O.push({key:`close`,label:`Hide output`,icon:(0,K.jsx)(tn,{}),onClick:r,title:`Hide output pane`,ariaLabel:`Hide output pane`});let ve=(0,K.jsxs)(`div`,{className:`project-output-toolbar`,ref:ie,children:[ue.length>0&&(0,K.jsxs)(oe,{value:D?.id,onValueChange:e=>o(e),children:[(0,K.jsx)(le,{className:`project-output-picker${ae?` is-compact`:``}`,"aria-label":D?`Choose output page. Current page: ${D.label}`:`Choose output page`,children:ae?(0,K.jsx)(`span`,{className:`project-output-picker-icon`,"aria-hidden":`true`,children:(0,K.jsx)(rn,{})}):(0,K.jsx)(ce,{placeholder:l?`Detecting…`:`Select a target…`})}),(0,K.jsx)(de,{children:ue.map(e=>(0,K.jsx)(se,{value:e.id,textValue:e.label,children:e.label},e.id))})]}),(0,K.jsx)(`span`,{className:`project-output-toolbar-spacer`}),ae?(0,K.jsx)(an,{actions:O}):O.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))]}),k=D?(0,K.jsx)(W,{projectId:e,path:D.path,source:D.source,title:D.label,className:`project-output-iframe`,refreshKey:d,onLog:me,onUrlReady:te,...D.source===`type`&&n?.pageTools?.length?{pageTools:n.pageTools}:{},...y?{onPageScriptError:he}:{},onRequestRefresh:fe}):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.`]})}),ye=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 ge(),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:_e,disabled:!D||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:[ve,(0,K.jsx)(`div`,{ref:re,className:`project-output-pane-body`,children:k}),ye]})}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(``),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)({}),[i,o]=(0,G.useState)(null),s=e.properties??{},c=Object.keys(s).filter(e=>!a(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)),i&&(0,K.jsx)(`p`,{className:`error small`,children:i})]})}var Y=[{id:`developer`,label:`Developer`,canonical:[`developer`,`web-developer`]},{id:`writer`,label:`Writer`,canonical:[`copywriter`]},{id:`designer`,label:`Designer`,canonical:[`designer`]},{id:`researcher`,label:`Researcher`,canonical:[`researcher`]}],yn=new Set([`adoc`,`asciidoc`,`markdown`,`md`,`mdx`,`rst`,`tex`,`txt`]),bn=new Set([`ai`,`avif`,`bmp`,`fig`,`gif`,`ico`,`jpeg`,`jpg`,`pdf`,`png`,`psd`,`sketch`,`svg`,`webp`]),xn=new Set([`csv`,`ods`,`parquet`,`tsv`,`xls`,`xlsx`]);function Sn(e){let t=e.split(`/`).pop()?.toLowerCase()??``,n=t.includes(`.`)?t.split(`.`).pop()??``:``;return yn.has(n)?`writer`:bn.has(n)?`designer`:xn.has(n)?`researcher`:`developer`}function Cn(e,t,n){if(t.stale){let r=t.line==null?``:` It was previously reported near line ${t.line}.`;return`@${n}, can you address ${t.ref} in ${e}: ${t.message}${r} The file has changed since this was reported, so please verify it against the current file before editing.`}let r=t.line==null?``:` at line ${t.line}`;return`@${n}, can you address ${t.ref} in ${e}${r}: ${t.message}`}function wn(e){return v(e.role)??v(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)(ne,{open:!0,onOpenChange:e=>!e&&!g&&i(),children:(0,K.jsxs)(ue,{children:[(0,K.jsx)(re,{}),(0,K.jsx)(ie,{className:`workspace-issue-fix-dialog`,children:(0,K.jsxs)(`form`,{className:`workspace-issue-fix-form`,onSubmit:e=>{e.preventDefault(),x()},children:[(0,K.jsx)(ae,{asChild:!0,children:(0,K.jsx)(`h3`,{children:`Assign issue fix`})}),(0,K.jsx)(T,{className:`muted small`,children:`This creates an assigned task and starts its specialist chat immediately. Your files aren’t touched — the fix arrives as a change proposal you review and apply.`}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{children:`Assigned role`}),(0,K.jsx)(`select`,{value:s,onChange:e=>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)(te,{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=m({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 a=i(e),{nativeWritable:o,managedSurfaceAvailable:s}=Dn(e,t,n,r);return{managedWritable:a,nativeWritable:o,effectiveWritable:o||a&&s}}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(N(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)(R,{...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)(I,{glyph:e.source===`catalog`?P(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)(be,{poppetje:h(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)(I,{glyph:e.glyph,size:15}),e.text]},e.text)),a.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(I,{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)(R,{...a?{iconSvg:a}:{},...o?{logoUrl:o}:{},svgClassName:`gz-npd-card-mark-svg`,fallback:(0,K.jsx)(I,{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)(``),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(`general`),[f,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(``),[g,_]=(0,G.useState)([]),[v,b]=(0,G.useState)(null),[x,C]=(0,G.useState)({}),[w,ee]=(0,G.useState)(``),[T,oe]=(0,G.useState)(`all`),[se,ce]=(0,G.useState)(`pick`),[le,de]=(0,G.useState)(!1),[E,D]=(0,G.useState)(``),[fe,pe]=(0,G.useState)(``),[me,he]=(0,G.useState)(`imap`),[ge,_e]=(0,G.useState)(``),[O,ve]=(0,G.useState)(``),[k,ye]=(0,G.useState)(``),[be,xe]=(0,G.useState)(!0),[Se,Ce]=(0,G.useState)(``),[A,j]=(0,G.useState)(null),[M,Te]=(0,G.useState)(null),[De,Oe]=(0,G.useState)(null),[ke,Ae]=(0,G.useState)([]),[je,L]=(0,G.useState)(``),[Me,R]=(0,G.useState)(!1),Ne=(0,G.useRef)(null),Pe=(0,G.useRef)(0),Fe=(0,G.useRef)(null),Ie=(0,G.useRef)(null),Le=(0,G.useRef)({name:a,nameManuallyEdited:c,about:f,mission:m});Le.current={name:a,nameManuallyEdited:c,about:f,mission:m};let Re=(0,G.useId)();(0,G.useEffect)(()=>{Pe.current+=1,Fe.current=null,Ie.current?.abort(),Ie.current=null,e&&(o(``),l(!1),d(`general`),p(``),h(``),D(``),j(null),Te(null),pe(``),he(`imap`),_e(``),ve(``),ye(``),xe(!0),Ce(``),b(null),C({}),ee(``),oe(`all`),ce(`pick`),de(!1),L(``),R(!1),Ne.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);_(y(e.items,i,r).filter(e=>e.manifest.id!==`email`))}).catch(()=>{t||_([])}),()=>{t=!0}},[e,i]),(0,G.useEffect)(()=>{!i&&u===`email`&&d(`general`)},[u,i]),(0,G.useEffect)(()=>{if(!e||!De){Ae([]);return}let t=!1;return S.listGitHubRepos().then(e=>{t||Ae(e.repos)}).catch(()=>{t||Ae([])}),()=>{t=!0}},[e,De]);let z=t===`solo`||u===`folder`,ze=z?`New Job`:`New Project`,Be=z?`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=z?`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)(()=>{Pe.current+=1,Fe.current=null,Ie.current?.abort(),Ie.current=null,Te(null)},[]),We=(0,G.useCallback)(()=>{ce(`pick`),L(``)},[]),Ge=(0,G.useCallback)(e=>{Ue(),j(null),D(e)},[Ue]),qe=(0,G.useCallback)(async e=>{let t=(e??E).trim();if(!t){j(null);return}if(!Xn(t)){j({message:`Looks incomplete — enter owner/repo (e.g. bendyline/squisq).`});return}if(Ne.current===t){j(null);return}if(!De){j({message:`Sign in to GitHub to auto-fill About and Mission objectives from this repo.`});return}if(Fe.current===t)return;j(null);let n=Pe.current+1,r=new AbortController;Pe.current=n,Fe.current=t,Ie.current=r,Te(`reading`);try{let e=await S.previewGitHubRepo(Yn(t),r.signal);if(Pe.current!==n)return;Te(`drafting`);let i=Le.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(Pe.current!==n)return;let c=Le.current,l=c.about.trim().length>0,u=c.mission.trim().length>0;(!l&&!u||window.confirm(`Replace the current About and Mission objectives with text drafted from this repo?`))&&(p(s.about),h(s.missionObjectives),Ne.current=t)}catch(e){if(Pe.current!==n)return;let t=Qn(e);j({message:`Couldn't read this repo: ${Zn(e)}`,...t?{fixUrl:t}:{}})}finally{Pe.current===n&&(Fe.current=null,Ie.current=null,Te(null))}},[E,De]),Je=(0,G.useCallback)(async e=>{Ce(e);let t=e.trim();if(t)try{let e=await S.previewFolder(t);e.name&&!c&&o(e.name),e.about&&p(t=>t.trim()?t:e.about??``)}catch{if(!c){let e=t.replace(/[\\/]+$/,``).split(/[\\/]/).pop();e&&o(e)}}},[c]),B=(0,G.useCallback)(async()=>{let e=window.__GEZEL__?.selectDirectory;if(e)try{let t=await e({title:`Choose a project folder`});t&&await Je(t)}catch{}},[Je]),V=v?g.find(e=>e.manifest.id===v)??null:null,Ye=V?.manifest.kind===`project-type`?V.manifest.params:void 0,Xe=(0,G.useMemo)(()=>F.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?g.filter(e=>{let t=e.manifest;return`${t.name} ${t.description} ${t.tags.join(` `)}`.toLowerCase().includes(H)}):g,[H,g]),Qe=H.length>0,$e=(0,G.useMemo)(()=>Ee.map(e=>({cat:e,builtins:Ze.filter(t=>t.category===e.id),types:U.filter(t=>N(t)===e.id)})).filter(e=>e.builtins.length+e.types.length>0),[Ze,U]),et=Qe||T===`all`?$e:$e.filter(e=>e.cat.id===T),tt=(0,G.useMemo)(()=>Ee.map(e=>({cat:e,count:Xe.filter(t=>t.category===e.id).length+g.filter(t=>N(t)===e.id).length})).filter(e=>e.count>0),[Xe,g]),nt=V?{source:`catalog`,item:V}:{source:`builtin`,kind:Xe.find(e=>e.id===u)??Xe[0]},rt=Fn(nt),it=(0,G.useCallback)(async e=>{if(e.preventDefault(),se!==`configure`)return;if(L(``),v&&V){let e=a.trim();if(!e){L(`Name is required.`);return}R(!0);try{let t=V.manifest.kind===`project-type`?V.manifest.params:void 0,{project:i,applied:a}=await S.createTypedProject({name:e,...z?{mode:`solo`}:{},projectType:{typeId:v,params:{...Hn(t),...x}}});a.gezelsCreated.length>0&&window.dispatchEvent(new CustomEvent(`gezel:gezel-updated`)),await r(i),n()}catch(e){L(e.message)}finally{R(!1)}return}if(u===`email`){let e=fe.trim();if(!Vn(e)){L(`Enter a valid email address — it becomes the project name.`);return}if(me===`imap`&&(!ge.trim()||!k)){L(`IMAP needs at least a host and a password.`);return}R(!0);try{let t=Bn(e),i=await S.createProject({name:e,about:t.about,missionObjectives:t.mission,...z?{mode:`solo`}:{}}),a=await S.updateProject(i.id,{projectTypeId:`email`}).catch(()=>i);me===`imap`?await gt(i.id,{address:e,host:ge.trim(),...O.trim()?{port:Number(O.trim())}:{},secure:be,pass:k}).catch(e=>console.warn(`mail link failed:`,e)):await ht(i.id,me,e).catch(e=>console.warn(`mail OAuth failed:`,e)),await r(a),n()}catch(e){L(e.message)}finally{R(!1)}return}let t=a.trim(),i=f.trim(),o=m.trim(),s=E.trim();if(!t){L(`Name is required.`);return}if(u!==`folder`&&!i){L(z?`Job description is required — what you want done, what is in scope, what is out.`:`About is required — who this project is for, what's in scope, what's out.`);return}let c=u===`github`;if(c&&s&&!Xn(s)){L(`GitHub repo doesn't look right — leave it blank or use owner/repo.`);return}if(u===`folder`&&!Se.trim()){L(`Choose a folder for this project.`);return}R(!0);try{await r(await S.createProject({name:t,about:i,missionObjectives:o,...z?{mode:`solo`}:{},...u===`folder`?{workingDir:Se.trim()}:{},...c&&s?{github:{url:Yn(s)}}:{}})),n()}catch(e){L(e.message)}finally{R(!1)}},[a,u,f,m,E,fe,me,ge,O,k,be,Se,v,V,x,z,se,n,r]);return(0,K.jsx)(ne,{open:e,onOpenChange:e=>{e||n()},children:(0,K.jsxs)(ue,{children:[(0,K.jsx)(re,{}),(0,K.jsx)(ie,{className:`gz-npd gz-npd-step-${se}`,children:(0,K.jsx)(`form`,{onSubmit:it,style:{display:`contents`},children:se===`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)(ae,{asChild:!0,children:(0,K.jsx)(`h3`,{children:ze})}),(0,K.jsx)(`p`,{className:`gz-npd-header-sub`,children:z?`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=>ee(e.target.value),placeholder:`Search types…`})]})]}),(0,K.jsxs)(`div`,{className:`gz-npd-body`,children:[(0,K.jsxs)(`nav`,{className:`gz-npd-rail`,"aria-label":`Project type categories`,children:[(0,K.jsx)(`button`,{type:`button`,className:`gz-npd-rail-item${!Qe&&T===`all`?` active`:``}`,onClick:()=>oe(`all`),children:(0,K.jsx)(`span`,{className:`gz-npd-rail-label`,children:`All`})}),tt.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`gz-npd-rail-item${!Qe&&T===e.cat.id?` active`:``}`,onClick:()=>oe(e.cat.id),children:[(0,K.jsx)(I,{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:le&&!v&&e.id===u,...e.soon?{disabled:!0,badge:`Soon`}:{},onSelect:()=>{e.soon||(u===`github`&&e.id!==`github`&&Ue(),d(e.id),de(!0),b(null),C({}),c||o(``),L(``),ce(`configure`))}},e.id)),e.types.map((t,n)=>(0,K.jsx)(Rn,{label:t.manifest.name,description:t.manifest.description,glyph:P(t),index:e.builtins.length+n,active:t.manifest.id===v,...!(t.manifest.kind===`project-type`&&t.manifest.icon)&&t.iconSvg?{iconSvg:t.iconSvg}:{},...!(t.manifest.kind===`project-type`&&t.manifest.icon)&&t.logoUrl?{logoUrl:t.logoUrl}:{},onSelect:()=>{u===`github`&&Ue(),b(t.manifest.id),d(`general`),de(!1);let e=Hn(t.manifest.kind===`project-type`?t.manifest.params:void 0);C(e),c||o(Wn(t,e)),L(``),ce(`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)(te,{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)(ae,{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)(we,{schema:Ye,value:x,onChange:e=>{let t=e??{};C(t),c||o(Wn(V,t))},density:`compact`})}),u===`github`&&(0,K.jsxs)(`div`,{className:`gz-npd-field`,children:[(0,K.jsxs)(`span`,{className:`gz-new-project-github-label`,children:[(0,K.jsxs)(`label`,{htmlFor:Re,children:[`GitHub repository `,(0,K.jsx)(`span`,{className:`muted`,children:`(optional)`})]}),(0,K.jsx)(kt,{onChange:Oe,compact:!0})]}),(0,K.jsx)(qn,{inputId:Re,value:E,onChange:Ge,onBlur:()=>void qe(),onSelect:e=>{Ge(e),qe(e)},repos:ke}),M&&(0,K.jsx)(Kn,{phase:M,onCancel:Ue}),!M&&A&&(0,K.jsxs)(`small`,{className:`error`,children:[A.message,A.fixUrl&&(0,K.jsxs)(K.Fragment,{children:[` `,(0,K.jsx)(`a`,{href:A.fixUrl,target:`_blank`,rel:`noopener noreferrer`,children:`Open GitHub authorization page →`})]})]})]}),u===`folder`&&(0,K.jsxs)(`label`,{children:[`Folder`,(0,K.jsxs)(`div`,{className:`gz-folder-row`,children:[(0,K.jsx)(`input`,{value:Se,onChange:e=>Ce(e.target.value),onBlur:()=>void Je(Se),placeholder:He}),window.__GEZEL__?.selectDirectory&&(0,K.jsx)(`button`,{type:`button`,className:`gz-folder-browse`,onClick:()=>void B(),children:`Browse…`})]}),(0,K.jsx)(`small`,{className:`muted`,children:`Gezels read — and, with permission, write — files in this folder.`})]}),u===`email`?(0,K.jsxs)(`label`,{children:[`Email address`,(0,K.jsx)(`input`,{type:`email`,value:fe,onChange:e=>pe(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),l(!0)},placeholder:z?`e.g. Bird-feeder prototype`:`e.g. Eliza's Pet Shop`}),V&&a&&!c&&(0,K.jsx)(`small`,{className:`muted`,children:`Suggested from your choices — edit it anytime.`}),u===`folder`&&a&&!c&&(0,K.jsx)(`small`,{className:`muted`,children:`Suggested from the folder — edit it anytime.`})]}),u===`email`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`gz-type-field`,children:[(0,K.jsx)(`span`,{className:`gz-type-field-label`,children:`Provider`}),(0,K.jsx)(`div`,{className:`gz-type-picker`,role:`radiogroup`,"aria-label":`Mail provider`,children:zn.map(e=>{let t=e.id===me;return(0,K.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t,className:`gz-type-chip${t?` active`:``}`,onClick:()=>he(e.id),children:e.label},e.id)})})]}),me===`imap`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{children:[`IMAP host`,(0,K.jsx)(`input`,{value:ge,onChange:e=>_e(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:O,onChange:e=>ve(e.target.value),placeholder:`993`,inputMode:`numeric`})]}),(0,K.jsxs)(`label`,{className:`gz-imap-tls`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:be,onChange:e=>xe(e.target.checked)}),`Use TLS`]})]}),(0,K.jsxs)(`label`,{children:[`Password / app password`,(0,K.jsx)(`input`,{type:`password`,value:k,onChange:e=>ye(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===me)?.label,` connects via OAuth. Create the project, then click `,(0,K.jsx)(`strong`,{children:`Connect`}),` in its Mail tab to authorize in the browser. Synced messages become searchable files; sending is consent-gated.`]})]}),u!==`email`&&!v&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{children:[z?`Job description`:`About`,` `,(0,K.jsx)(`span`,{className:`muted`,children:u===`folder`?`(optional)`:``}),(0,K.jsx)(`textarea`,{value:f,onChange:e=>p(e.target.value),placeholder:u===`folder`?`Optional. Auto-filled from the folder's AGENTS.md or CLAUDE.md if it has one — or add your own notes about what's here.`:Be,rows:4})]}),(0,K.jsxs)(`label`,{children:[`Mission objectives `,(0,K.jsx)(`span`,{className:`muted`,children:`(optional)`}),(0,K.jsx)(`textarea`,{value:m,onChange:e=>h(e.target.value),placeholder:Ve,rows:3})]})]})]})})]},v??u),(0,K.jsxs)(`div`,{className:`gz-npd-pane-footer gz-npd-detail-footer`,children:[je?(0,K.jsx)(`p`,{className:`error small gz-npd-submit-error`,role:`alert`,children:je}):(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)(te,{children:[(0,K.jsx)(`button`,{type:`button`,onClick:n,disabled:Me,children:`Cancel`}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:Me,children:Me?`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)(ke,{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)(E,{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=Oe({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)(()=>Ne(l),[l]),h=(0,G.useMemo)(()=>Ve(p,m),[p,m]),g=(0,G.useMemo)(()=>Le(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)(M,{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=()=>A(()=>import(`./ProjectChat-Dhw_M5bq.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=()=>A(()=>import(`./ProjectConnectionsTab-BwpMQNrg.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=()=>A(()=>import(`./ProjectMailTab-qFmAeV3M.js`),__vite__mapDeps([76,1,2,4,5,3,11,77])),or=()=>A(()=>import(`./DiffpackReviewView-CD4qJmgT.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=()=>A(()=>import(`./FileMapView-kVBG22FU.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=()=>A(()=>import(`./HistoryView-CKWcWW-Y.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=()=>A(()=>import(`./ProjectGithubView-CTP1BOMv.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=()=>A(()=>import(`./ProjectOverviewView-Cq1FsoaT.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=()=>A(()=>import(`./TasksView-Ddwz10ri.js`),__vite__mapDeps([88,1,2,3,4,5,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=_(e);return!t||!Rr.has(t)}function Br(e){return _(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,a=Ke(),o=(0,G.useRef)(null),s=mt(o),l=t||s,d=De(),[f,p]=(0,G.useState)([]),[m,h]=(0,G.useState)(null),[_,v]=(0,G.useState)(!1),[y,x]=(0,G.useState)(void 0),[T,te]=(0,G.useState)(null),[ne,re]=(0,G.useState)(``),[ie,ae]=(0,G.useState)(``),[ue,E]=(0,G.useState)(null),[be,j]=(0,G.useState)({}),[M,we]=(0,G.useState)(null),[N,P]=(0,G.useState)(`chat`);(0,G.useEffect)(()=>{!a&&N===`mail`&&P(`about`)},[a,N]);let[F,Te]=(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`,F?`1`:`0`)}catch{}},[F]);let I=N===`workspace`?`workspace`:N===`artifacts`?`artifacts`:null,[Ee,Oe]=(0,G.useState)([]),[ke,L]=(0,G.useState)([]),[R,Ne]=(0,G.useState)([]),[Fe,Ie]=(0,G.useState)(!1),[Le,z]=(0,G.useState)(!1),[ze,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{p((await S.listProjects()).projects)}catch(e){E(e.message)}},[]),yn=(0,G.useMemo)(()=>f.filter(e=>!e.archived),[f]),bn=(0,G.useMemo)(()=>f.filter(e=>e.archived),[f]),xn=(0,G.useMemo)(()=>{if(!m)return[];let e=new Set(m.linkedProjectIds??[]);return f.filter(t=>t.id!==m.id&&!c(t)&&(!t.archived||e.has(t.id)))},[f,m]),Sn=(m?.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}p(e=>e.map(e=>e.id===t.projectId?{...e,...t.project}:e)),h(e=>e?.id===t.projectId?t.project:e)}};return window.addEventListener(`gezel:project-updated`,e),()=>window.removeEventListener(`gezel:project-updated`,e)},[Y]),(0,G.useEffect)(()=>{if(n)return;Me(`project`)&&te(`crew`);let e=()=>{Me(`project`),te(`crew`)};return window.addEventListener(`gezel:new-project`,e),()=>window.removeEventListener(`gezel:new-project`,e)},[n]),(0,G.useEffect)(()=>{let e=e=>{let t=e.detail?.projectId;Y(),t&&h(e=>e?.id===t?null:e)};return window.addEventListener(`gezel:project-deleted`,e),()=>window.removeEventListener(`gezel:project-deleted`,e)},[Y]);let Cn=(0,G.useCallback)(async()=>{try{Kt((await 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=m?.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(!m)return{managedWritable:!0,nativeWritable:!1,effectiveWritable:!0,codexInUse:!1,claudeInUse:!1,claudeMode:`acceptEdits`};let e=qt?.projectId===m.id?qt.gezels:[];return{...On(m,Gt,e,J),codexInUse:kn(m,Gt,e,J),claudeInUse:An(m,Gt,e,J),claudeMode:jn(m,Gt,e,J)}},[m,Gt,qt,J]),Dn=r(m?.codexPermissionMode??J?.codexCli?.defaultPermissionMode),Mn=(0,G.useCallback)(async e=>{if(!m)return;let t=await S.addGezelToProject(m.id,e);x(e),h(e=>e?.id===m.id?{...e,gezelIds:t.gezelIds}:e)},[m]),Nn=(0,G.useCallback)(async e=>{if(!m)return;let t=await S.removeGezelFromProject(m.id,e);h(e=>e?.id===m.id?{...e,gezelIds:t.gezelIds}:e)},[m]),Pn=(0,G.useCallback)(async(e,t)=>{if(!m)return;let n=m.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]),h(e=>e?.id===n?{...e,gezelIds:i.gezelIds}:e),window.dispatchEvent(new CustomEvent(`gezel:gezel-updated`,{detail:r}))},[m]),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})]);Oe(t.files),Ne(n.files),Ie(t.truncated===!0),z(n.truncated===!0)},[Fn,In]),Rn=(0,G.useCallback)(async e=>{let t=await S.listProjectWorkspaceHtmlPages(e);L(t.files.map(e=>e.path))},[]),zn=(0,G.useCallback)(async e=>{await Promise.all([Ln(e),Rn(e)])},[Ln,Rn]);(0,G.useEffect)(()=>{I===null||!m||zn(m.id)},[I,m,zn]),(0,G.useEffect)(()=>{if(I!==`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)}},[I,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=k(window.localStorage.getItem(he(X,`workspace`)),`workspace`),t=k(window.localStorage.getItem(he(X,`artifacts`)),`artifacts`),n=window.localStorage.getItem(O(X,`workspace`))===`1`,r=window.localStorage.getItem(O(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(he(X,e),t)}catch{}},[X]),Vn=(0,G.useCallback)((e,t)=>{if(We(n=>({...n,[e]:t})),X)try{window.localStorage.setItem(O(X,e),t?`1`:`0`)}catch{}},[X]),Hn=ze.workspace,Un=U?.meta?.scannedAt;(0,G.useEffect)(()=>{if(I!==`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}},[I,Hn,X,Un,Fn]);let Z=I===`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(N!==`packages`||!m){j({}),we(null);return}S.listPackageScripts(m.id).then(e=>j(e.scripts)).catch(e=>{console.warn(`[ProjectsView] listPackageScripts failed`,e),j({})}),S.getProjectApprovals(m.id).then(we).catch(e=>{console.warn(`[ProjectsView] getProjectApprovals failed`,e),we(null)})},[N,m]),(0,G.useEffect)(()=>{H(null)},[I]),(0,G.useEffect)(()=>{if(N!==`about`||!m)return;let e=!1;return(async()=>{try{let t=await S.listWorkspaceWrites(m.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}},[N,m]);let Jn=(0,G.useCallback)(async(e,t)=>{if(!m)return;let n=m.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){E(`Configure an HTTPS destination for ${e} before granting it.`);return}try{let e=await S.updateProject(m.id,{grantedCredentials:r});h(e),E(null)}catch(e){E(e.message)}},[m,mn]),Yn=(0,G.useCallback)((e,t)=>{if(!m)return;let n=nr(e,t);ft(m.id,n),P(`chat`)},[m]),Xn=(0,G.useCallback)(e=>{m&&(ft(m.id,e),P(`chat`))},[m]),Zn=(0,G.useCallback)(async e=>{let t=await S.getProject(e);h(t),H(null),Oe([]),L([]),Ne([]),Lt(!1),P(`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)=>{P(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&&m&&t.projectId!==m.id||P(`settings`)};return window.addEventListener(`gezel:open-project-settings`,e),()=>window.removeEventListener(`gezel:open-project-settings`,e)},[m]),(0,G.useEffect)(()=>{let e=e=>{let t=e.detail;!t?.path||!t.source||m&&(!t.projectId||t.projectId===m.id)&&(Re(m.id),Qn(m.id,t.path,t.source,t.line))};return window.addEventListener(`gezel:open-file`,e),()=>window.removeEventListener(`gezel:open-file`,e)},[m,Qn]),(0,G.useEffect)(()=>{e&&Zn(e).then(()=>{let t=Re(e);t&&Qn(e,t.path,t.source,t.line)})},[e,Zn,Qn]);let er=(0,G.useCallback)(async e=>{await Y(),h(e),H(null),Oe([]),L([]),Ne([]),Lt(!1),P(`chat`),tn(``),ln(``),dn(``),await Rn(e.id)},[Y,Rn]),tr=(0,G.useCallback)(async()=>{if(!(!m||!ne.trim())){ae(`installing…`);try{let e=await S.installPackage(m.id,{name:ne.trim()});ae(e.log),h(e.project),re(``)}catch(e){ae(e.message)}}},[ne,m]),rr=(0,G.useCallback)(async e=>{if(!m)return;let t=e.trim();if(t!==(m.github?.url??``))try{if(t===``){let e=await S.updateProject(m.id,{github:null});h(e),dn(`Unlinked.`);return}let e=await S.updateProject(m.id,{github:{url:t}});h(e),dn(`Cloning…`);try{let e=await S.cloneProjectGit(m.id),t=await S.getProject(m.id);h(t),dn(e.adopted?`Adopted existing checkout.`:`Cloned.`)}catch(e){let t=e.message||`clone failed`;dn(`Linked, but clone failed: ${t}`)}}catch(e){dn(`save failed: ${e.message}`)}},[m]),ir=(0,G.useCallback)(async e=>{if(!m)return;let t=e.trim()||void 0;if(t!==(m.workingDir??void 0))try{let e=await S.setProjectWorkingDir(m.id,t);h(e),await zn(m.id)}catch(e){console.error(`setProjectWorkingDir failed:`,e)}},[m,zn]),ar=(0,G.useCallback)(async e=>{if(m)try{let t=await S.updateProject(m.id,{managedWorkspaceWritePolicy:e?`allow`:`deny`});h(t)}catch(e){console.error(`updateProject(managedWorkspaceWritePolicy) failed:`,e)}},[m]),or=(0,G.useCallback)(async e=>{if(m)try{let t=await S.updateProject(m.id,{codexPermissionMode:e});h(t)}catch(e){console.error(`updateProject(codexPermissionMode) failed:`,e)}},[m]),sr=(0,G.useCallback)(async e=>{if(m)try{let t=await S.updateProject(m.id,{claudePermissionMode:e});h(t)}catch(e){console.error(`updateProject(claudePermissionMode) failed:`,e)}},[m]),cr=(0,G.useCallback)(async e=>{if(m)try{let t=await S.updateProject(m.id,{indexingEnabled:e});h(t),e&&S.refreshProjectIndex(m.id).catch(()=>{})}catch(e){console.error(`updateProject(indexingEnabled) failed:`,e)}},[m]),lr=(0,G.useCallback)(async e=>{if(m)try{h(await S.updateProject(m.id,{nightlyFixesEnabled:e}))}catch(e){console.error(`updateProject(nightlyFixesEnabled) failed:`,e)}},[m]),ur=(0,G.useCallback)(async(e,t)=>{if(!m||fn)return;let n=m.linkedProjectIds??[],r=t?Array.from(new Set([...n,e])):n.filter(t=>t!==e);pn(!0);try{let e=await S.updateProject(m.id,{linkedProjectIds:r});h(e),p(t=>t.map(t=>t.id===e.id?{...t,...e}:t))}catch(e){E(e instanceof Error?e.message:String(e))}finally{pn(!1)}},[fn,m]),dr=(0,G.useCallback)(async e=>{if(m)try{let t=await S.updateProject(m.id,{nudgeConfig:{...m.nudgeConfig,enabled:!e}});h(t)}catch(e){E(e.message)}},[m]),Cr=(0,G.useCallback)(async(e,t)=>{if(m)try{let n=await S.updateProject(m.id,{tabVisibility:{...m.tabVisibility,[e]:t}});h(n),E(null)}catch(e){E(e.message)}},[m]),Q=(0,G.useCallback)(e=>e===`artifacts`||i(m),[m]),Fr=(0,G.useCallback)(async(e,t)=>{if(!m)throw Error(`Open a project before viewing this document.`);let n=rt(e.path);if(!n)throw Error(`This file does not support a Markdown companion.`);let r=ut(n,(t===`workspace`?Ee:R).filter(e=>!e.isDirectory).map(e=>e.path)),i;if(r)i=(t===`workspace`?await S.readProjectWorkspaceFile(m.id,r):await S.readProjectArtifact(m.id,r)).content;else{if(!Q(t))throw Error(`Enable workspace writes for this external project before importing its Markdown companion.`);let a=await st(await(t===`workspace`?await S.fetchProjectWorkspaceBlob(m.id,e.path):await S.fetchProjectArtifactBlob(m.id,e.path)).arrayBuffer(),n),o=Ue({projectId:m.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(m.id)}let a=at(i,n);return a!==i&&Q(t)&&(t===`workspace`?await S.writeProjectWorkspaceFile(m.id,{path:r,content:a}):await S.writeProjectArtifact(m.id,r,a)),{layout:{...n,markdownPath:r},sourcePath:r,content:a,editingEnabled:dt(n.format)&&ct(a)}},[m,Ee,R,Q,Ln]),Rr=(0,G.useCallback)(async(e,t)=>{if(!m||e.isDirectory)return;if(rt(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}}),E(null)}catch(e){E(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(m.id,e.path):await S.readProjectArtifact(m.id,e.path),r=qe(n.content)?Ye:n.content;H({...n,content:r,source:t})}},[m,Fr]),zr=(0,G.useCallback)(async(e,t)=>{if(!m||e.isDirectory)return;let n=rt(e.path);if(!n||!dt(n.format)){E(`CSV data previews are read-only.`);return}if(!Q(t)){E(`Enable workspace writes before allowing Markdown editing.`);return}try{let n=await Fr(e,t),r=t===`workspace`?await S.fetchProjectWorkspaceBlob(m.id,n.layout.targetPath):await S.fetchProjectArtifactBlob(m.id,n.layout.targetPath);try{t===`workspace`?await S.writeProjectWorkspaceBinary(m.id,n.layout.backupPath,r,r.type||`application/octet-stream`,{createOnly:!0}):await S.writeProjectArtifactBinary(m.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=it(n.content,n.layout);t===`workspace`?await S.writeProjectWorkspaceFile(m.id,{path:n.sourcePath,content:i}):await S.writeProjectArtifact(m.id,n.sourcePath,i),H({path:e.path,content:i,source:t,outsideIn:{layout:n.layout,sourcePath:n.sourcePath,editingEnabled:!0}}),E(null),await Ln(m.id)}catch(e){E(e instanceof Error?e.message:`Could not enable Markdown editing.`)}},[m,Q,Fr,Ln]),Hr=(0,G.useCallback)(e=>{H(t=>t&&{...t,content:e})},[]),Wr=(0,G.useCallback)(async e=>{if(!m||!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:m.id,root:e.companionDirectory,client:S,primaryDocumentFilename:wr(n),source:B.source})),i=B.source===`workspace`?Ee:R,a=e.format===`html`?ot(e.targetPath,new Set(i.filter(e=>e.isDirectory).map(e=>e.path.replace(/^\/+/,``)))):void 0,o=at(t,e),s=await lt(o,e,r,a?nt(e.parentDirectory,a):void 0);if(B.source===`workspace`?await S.writeProjectWorkspaceFile(m.id,{path:n,content:o}):await S.writeProjectArtifact(m.id,n,o),a){let{PLAYER_BUNDLE:e}=await A(async()=>{let{PLAYER_BUNDLE:e}=await import(`./standalone-source-Cw9SF7Zk.js`);return{PLAYER_BUNDLE:e}},[]);B.source===`workspace`?await S.writeProjectWorkspaceFile(m.id,{path:a,content:e}):await S.writeProjectArtifact(m.id,a,e)}B.source===`workspace`?await S.writeProjectWorkspaceBinary(m.id,e.targetPath,s.bytes,s.mimeType):await S.writeProjectArtifactBinary(m.id,e.targetPath,s.bytes,s.mimeType),H(e=>e?.path===B.path&&e.source===B.source?{...e,content:o}:e),await zn(m.id);return}Q(B.source)&&(B.source===`workspace`?await S.writeProjectWorkspaceFile(m.id,{path:B.path,content:t}):await S.writeProjectArtifact(m.id,B.path,t))},[m,B,Q,Ee,R,zn]);(0,G.useCallback)((e,t)=>m?`/api/projects/${m.id}/${t===`workspace`?`workspace`:`artifacts`}/read?path=${encodeURIComponent(e)}&raw=1`:``,[m]);let Gr=I===`workspace`?Ee:R,Yr=I?He[I]:!1,Qr=(0,G.useMemo)(()=>Yr?Gr:Gr.filter(e=>!b(e.path)),[Gr,Yr]),$=I?ze[I]:`tree-alpha`,$r=(0,G.useMemo)(()=>$===`flat-modified`?I===`workspace`&&Ge&&Ge.length>0?Ge.filter(e=>Yr||!b(e.path)).map(e=>ve(e.path,e.mtimeMs)).sort(pe):Qr.filter(e=>!e.isDirectory).slice().sort(pe):[],[$,I,Ge,Qr,Yr]),ei=(0,G.useMemo)(()=>_e(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`&&I===`workspace`&&Ge!==null&&Ge.length>0,ii=(0,G.useMemo)(()=>$===`flat-issues`||$===`flat-criticality`?{entries:ni,emptyMessage:`No open review issues.`,onSelect:e=>{I&&(Rr(e,I),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:me(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:Se(new Date(e.mtimeMs)),children:D(new Date(e.mtimeMs).toISOString())})}:null,[$,I,ni,$r,ri,ti,Rr]),ai=(0,G.useMemo)(()=>Qe(m?.id??``,I??`artifacts`,{canWrite:m!==null&&I!==null&&Q(I)}),[m,I,Q]),oi=(0,G.useCallback)(e=>{if(!e){H(null);return}I&&Rr(ve(e),I)},[I,Rr]),si=et({source:ai,entries:Gr,selectedPath:B?.path??null,onSelectPath:oi,refresh:(0,G.useCallback)(async()=>{m&&await zn(m.id)},[m,zn])}),ci=B?.outsideIn?!B.outsideIn.editingEnabled||!Q(B.source):!I||!Q(I),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)(()=>ke.some(e=>/(^|\/)index\.html?$/i.test(e)),[ke]);(0,G.useEffect)(()=>{if(!m){Ht(null);return}if(typeof m.outputPaneVisible==`boolean`){Lr(m.id);return}let e=Ir(m.id);if(e===null)return;let t=m.id;Ht({projectId:t,visible:e}),S.updateProject(t,{outputPaneVisible:e}).then(e=>{Lr(t),h(n=>n?.id===t?e:n)}).catch(()=>{})},[m?.id]);let pi=m?.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===m?.id?Vt.visible:null,hi=!!m&&(mi??m?.outputPaneVisible??(fi||!!Ut)),gi=(0,G.useCallback)(()=>{if(!m)return;let e=!hi,t=m.id;Ht({projectId:t,visible:e}),S.updateProject(t,{outputPaneVisible:e}).then(e=>{h(n=>n?.id===t?e:n)}).catch(e=>{E(e.message)})},[m,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=l&&ke.length>0,Ti=vt(m?.id??``);(0,G.useEffect)(()=>{N===`output`&&!wi&&P(`chat`)},[N,wi]);let Ei=!l&&hi,Di=wi&&N===`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(!(!m||m.id==="default"||c(m))&&!_){v(!0);try{let e=await S.updateProject(m.id,{archived:!m.archived});window.dispatchEvent(new CustomEvent(`gezel:project-updated`,{detail:{projectId:m.id,project:e}}))}catch(e){E(e instanceof Error?e.message:String(e))}finally{v(!1)}}},[_,m]),Ai=(e,t)=>e.map(e=>(0,K.jsx)(Be,{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${m?.id===e.id?` active`:``}`,onClick:()=>Oi(e.id),title:e.name,"aria-label":F?e.name:void 0,children:[(0,K.jsx)(Pe,{project:e,size:18,className:`project-rail-mark`}),!F&&(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`})]})]}),!F&&(0,K.jsx)(je,{project:e,onDeleted:()=>void Y(),onChanged:()=>void Y()})]})},e.id));return(0,G.useEffect)(()=>{if(n||m||f.length===0)return;let e=null;try{e=window.localStorage.getItem(xr)}catch{e=null}e&&f.some(t=>t.id===e)&&Zn(e)},[n,m,f,Zn]),(0,K.jsxs)(`div`,{ref:o,className:`two-col${F&&!n?` sidebar-collapsed`:``}${n?` detail-only`:``}${l?` is-compact`:``}`,children:[!n&&(0,K.jsx)(Gn,{open:T!==null,mode:T??`crew`,onClose:()=>te(null),onCreated:er}),m&&q&&(0,K.jsx)(Tn,{path:q.path,issue:q.issue,gezels:Gt,assignedGezelIds:new Set([...m.gezelIds??[],...m.voormanGezelId?[m.voormanGezelId]:[]]),onCancel:()=>Rt(null),onConfirm:async(e,t)=>{await S.fixBoekwachterIssue(m.id,{ref:q.issue.ref,gezelId:e,message:t}),await Kn(),Rt(null),P(`chat`)}},`${q.path}:${q.issue.category}:${q.issue.message}`),!n&&(0,K.jsxs)(`aside`,{className:`side${F?` collapsed`:``}`,children:[(0,K.jsxs)(`div`,{className:`area-toolbar`,children:[!F&&(0,K.jsx)(`button`,{type:`button`,className:`area-toolbar-btn`,onClick:()=>te(`crew`),children:`+ New Project`}),(0,K.jsx)(`button`,{type:`button`,className:`area-toolbar-toggle`,onClick:()=>Te(e=>!e),title:F?`Expand project list`:`Collapse project list`,"aria-label":F?`Expand project list`:`Collapse project list`,children:F?`›`:`‹`})]}),F&&(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:()=>te(`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${F?` 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)})]}),ue&&!F&&(0,K.jsx)(`p`,{className:`error`,children:ue})]}),(0,K.jsx)(`section`,{className:`main`,children:!n&&!m?(0,K.jsx)(`p`,{className:`placeholder`,children:`Pick a project on the left to view it here.`}):m?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`entity-tabs-row project-tabs-row`,children:[!l&&(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)(ee,{value:N,onValueChange:e=>P(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(m,`overview`)},{value:`tasks`,label:`Tasks`,show:kr(m,`tasks`)},{value:`packages`,label:`Approvals`,show:kr(m,`approvals`)},{value:`workspace`,label:`Workspace`,show:kr(m,`workspace`)},{value:`artifacts`,label:`Artifacts`,show:kr(m,`artifacts`)},{value:`proposals`,label:`Proposals`,show:Ti>0},{value:`github`,label:`GitHub`,show:!!m.github?.url},{value:`mail`,label:`Mail`,show:a&&Br(m)},{value:`map`,label:`Village`,show:kr(m,`map`)},{value:`about`,label:`Settings`,show:!0}].filter(e=>e.show).map(e=>l?(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))})}),m.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`:``}${l?` project-body-compact`:``}`,style:Ei?{"--project-output-width":`${(vi*100).toFixed(2)}%`}:void 0,children:[(Ei||Di)&&(0,K.jsx)(on,{projectId:m.id,htmlFiles:ke,typePage:Ut??void 0,onClose:Di?()=>P(`chat`):gi,onDebugFrame:Xn},m.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:[N===`about`&&(0,K.jsxs)(`div`,{className:`project-about-page`,children:[(0,K.jsx)(Jt,{project:m,gezels:Gt,boekwachterGezelId:Qt,recentlyAddedGezelId:y,onAddGezel:Mn,onCreateTemplateGezel:Pn,onRemoveGezel:Nn}),(0,K.jsx)(Xr,{projectId:m.id,resourceKey:`project:${m.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:m.about??``,onSave:async e=>{let t=await S.updateProject(m.id,{about:e});return h(n=>n?.id===t.id?{...n,about:e}:n),t}},`${m.id}:about`),(0,K.jsx)(Xr,{projectId:m.id,resourceKey:`project:${m.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:m.missionObjectives??``,onSave:async e=>{let t=await S.updateProject(m.id,{missionObjectives:e});return h(n=>n?.id===t.id?{...n,missionObjectives:e}:n),t}},`${m.id}:mission`),(0,K.jsx)(wt,{projectId:m.id,projectName:m.name},`${m.id}:memories`),a&&(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:m,onProjectChange:h})})}),(0,K.jsxs)(`section`,{id:`project-about-settings`,className:`project-about-section project-about-anchor`,children:[(0,K.jsx)(`h3`,{className:`project-about-section-title`,children:`Settings`}),(0,K.jsxs)(`div`,{className:`project-config`,children:[(0,K.jsxs)(`label`,{className:`config-label`,children:[`Working directory`,(0,K.jsxs)(`div`,{className:`new-row`,children:[(0,K.jsx)(`input`,{placeholder:`External path (leave blank for internal)`,value:en,onChange:e=>tn(e.target.value),onBlur:()=>void ir(en)}),window.__GEZEL__?.selectDirectory&&(0,K.jsx)(`button`,{type:`button`,onClick:async()=>{let e=await window.__GEZEL__?.selectDirectory?.({title:`Choose working directory`,defaultPath:en||void 0});e&&(tn(e),ir(e))},title:`Browse for folder`,children:`Browse…`})]}),(0,K.jsx)(`small`,{className:`muted`,children:m.workingDir?`External: ${m.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&&m.workingDir?rn(!0):ar(t)}}),(0,K.jsx)(`span`,{className:`muted small`,children:m.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:m.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:m.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.`})]})]}),!c(m)&&(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.`,` `,(m.linkedProjectIds??[]).length,` of 32 linked.`]}),(0,K.jsxs)(`div`,{className:`project-tab-settings-grid`,children:[xn.map(e=>{let t=(m.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,i(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:m,onUpdated:h}),(0,K.jsxs)(`div`,{className:`config-label`,style:{marginTop:`0.75rem`},children:[`Project properties`,(0,K.jsx)(vn,{project:m,onProjectChange:h}),(0,K.jsx)(`small`,{className:`muted`,children:`Shared values gezellen and recurring craftbooks draw from — set the designated language once and every translation run uses it.`})]}),(0,K.jsxs)(`label`,{className:`config-label`,style:{marginTop:`0.75rem`},children:[`GitHub repository`,(0,K.jsx)(`div`,{className:`new-row`,children:(0,K.jsx)(`input`,{placeholder:`https://github.com/owner/repo`,value:cn,onChange:e=>ln(e.target.value),onBlur:()=>void rr(cn)})}),(0,K.jsxs)(`small`,{className:`muted`,children:[m.github?.url?m.github.checkoutDir?`Linked. Checkout: ${m.github.checkoutDir}${m.github.branch?` (${m.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(m),(0,K.jsx)(`div`,{className:`new-row`,children:(0,K.jsx)(jt,{gezels:Gt,value:m.voormanGezelId,noneLabel:`(no ${Ft(m)})`,ariaLabel:Pt(m),onValueChange:async e=>{let t=await S.updateProject(m.id,{voormanGezelId:e});h(t)}})}),(0,K.jsx)(`small`,{className:`muted`,children:m.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:m.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)(oe,{value:m.projectTypeId||`__AUTO__`,onValueChange:async e=>{let t=await S.updateProject(m.id,{projectTypeId:e===`__AUTO__`?null:e});h(t)},children:[(0,K.jsx)(le,{children:(0,K.jsx)(ce,{})}),(0,K.jsxs)(de,{children:[(0,K.jsx)(se,{value:`__AUTO__`,children:(()=>{let e=g(m.detectedProjectType?.id);return e?`Auto-detect (${e.label})`:`Auto-detect`})()}),u().map(e=>(0,K.jsx)(se,{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(m,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.`})]}),m.id!=="default"&&!c(m)&&(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:m.archived?`Restore project`:`Archive project`}),(0,K.jsx)(`small`,{className:`muted`,children:m.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:_,children:_?m.archived?`Restoring…`:`Archiving…`:m.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=(m.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:Se(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:m.id},subject:m.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:m.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`}),a&&(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)(Ce,{open:nn,title:`Enable workspace writes?`,message:m.workingDir?(0,K.jsxs)(K.Fragment,{children:[`Gezels will be able to create, modify, and delete files inside`,` `,(0,K.jsx)(`code`,{children:m.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)}),N===`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:[M?.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}`)),(!M||M.npmApproved.length===0)&&(0,K.jsx)(`li`,{className:`muted`,children:`No project-specific npm approvals yet.`})]}),M&&M.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:M.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:[M&&Object.entries(M.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}`)),(!M||Object.keys(M.scriptApprovals).length===0)&&(0,K.jsx)(`li`,{className:`muted`,children:`No script approvals on file yet.`})]}),M&&Object.keys(M.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(M.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:ne,onChange:e=>re(e.target.value)}),(0,K.jsx)(`button`,{type:`button`,onClick:tr,children:`Install`})]}),(0,K.jsxs)(`ul`,{children:[m.packages.map(e=>(0,K.jsxs)(`li`,{children:[e.name,` `,(0,K.jsx)(`code`,{children:e.version})]},e.name)),m.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(be).map(([e,t])=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`strong`,{children:e}),`: `,(0,K.jsx)(`code`,{children:t})]},e)),Object.keys(be).length===0&&(0,K.jsx)(`li`,{className:`muted`,children:`no scripts defined in package.json`})]}),ie&&(0,K.jsx)(`pre`,{className:`log`,children:ie})]}),I!==null&&(0,K.jsx)(tt,{source:ai,layoutClassName:`project-files-layout-${I}`,entries:Qr,truncated:(I===`workspace`?Fe:Le)&&!ri,viewMode:$,modes:I===`workspace`?fe:ge,onViewModeChange:e=>Bn(I,e),showHidden:Yr,onShowHiddenChange:e=>Vn(I,e),selectedPath:B?.path,onSelect:e=>void Rr(e,I),emptyMessage:I===`workspace`?m.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:I===`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:rt(e.path);return e.isDirectory||!t||!dt(t.format)||B?.path===e.path&&B.source===I&&B.outsideIn?.editingEnabled?[]:[{label:`Allow editing via markdown`,disabled:!Q(I),onSelect:()=>zr(e,I)}]},headerExtra:I===`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:I===`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(m.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(m.id).then(e=>pt(e.status)).catch(()=>{}),children:`Index now`})]})]}):void 0,extraPane:I===`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=>Ae({kind:`task`,ref:e})}):void 0,viewer:B?B.outsideIn?(0,K.jsx)($n,{projectId:m.id,file:B,outsideIn:B.outsideIn,isReadOnly:ci,editorTheme:d,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:m.id,path:B.path,fetchBlob:ai.fetchBlob,onOpen:e=>void Qn(m.id,e,`workspace`)},B.path)]}):Sr(B.path)?(0,K.jsx)(Jr,{projectId:m.id,file:B,isReadOnly:ci,editorTheme:d,onEditorChange:Hr,onSave:Wr,onComplainAboutPreviewError:Yn,toolbarIndexToggle:di,sourceReveal:ui}):(0,K.jsx)(qr,{projectId:m.id,file:B,isReadOnly:ci,editorTheme:d,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.`})}),N===`chat`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(fr,{project:m,compact:l},m.id)}),N===`tasks`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(br,{projectId:m.id})}),N===`proposals`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(hr,{projectId:m.id})}),N===`github`&&m.github?.url&&(0,K.jsx)(Dr,{children:(0,K.jsx)(vr,{project:m,onProjectChange:h})}),a&&N===`mail`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(mr,{project:m,onProjectChange:h})}),N===`map`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(gr,{projectId:m.id})}),N===`overview`&&(0,K.jsx)(Dr,{children:(0,K.jsx)(yr,{projectId:m.id,project:m})})]})]}),(0,K.jsx)(Tt,{projectId:m.id,compact:l,managedWorkspaceWritable:En.managedWritable,onManagedWorkspaceWritesChange:e=>{e&&m.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:m.github?.url?()=>P(`github`):void 0,onAddBoekwachter:Qt?()=>Mn(Qt):void 0,status:m.status??`active`,statusLocked:m.archived===!0,onStatusChange:async e=>{let t=await S.updateProject(m.id,{status:e});h(t)}})]}):(0,K.jsx)(_n,{})})]})}function Kr({request:e}){let{activeView:t,setActiveView:n,monacoEditor:r}=j();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)(()=>ze(t.path),[t.path]),f=(0,G.useMemo)(()=>Ne(t.path),[t.path]),p=Oe({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)(M,{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=Oe({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]),T=(0,G.useCallback)(async e=>{if(o){v(e.at);try{await o(e,{path:t.path,source:t.source})}finally{v(void 0)}}},[o,t.path,t.source]),te=(0,G.useCallback)(e=>{m(t=>[e,...t].slice(0,50)),g(!1)},[]),ne=(0,G.useCallback)(()=>{f(e=>e+1),m([])},[]),re=(0,G.useCallback)(()=>{y&&window.open(y,`_blank`,`noopener,noreferrer`)},[y]);return(0,K.jsxs)(`div`,{className:`html-file-viewer`,children:[(0,K.jsx)(ee,{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:ne,className:`html-file-viewer-refresh`,title:`Reload the preview`,children:`Refresh`}),(0,K.jsx)(`button`,{type:`button`,onClick:re,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:te,onUrlReady:b}),p.length>0&&(0,K.jsx)(Yr,{logs:p,collapsed:h,onToggleCollapsed:()=>g(e=>!e),onClear:()=>m([]),...o?{onComplain:T}:{},..._===void 0?{}:{complainBusyAt:_}})]}):(0,K.jsx)(`div`,{className:`editor-wrap`,children:(0,K.jsx)(M,{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=De(),c=Oe({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)(M,{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};
|