@aiworker/web 1.23.0 → 1.23.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/assets/{CodeMirrorCommentWidgets-B1Gizi3a.js → CodeMirrorCommentWidgets-COGJG0Iv.js} +1 -1
- package/dist/assets/DiffView-BviYY3zL.js +4 -0
- package/dist/assets/{DirtyBranchSwitchDialog-aig6zJjg.js → DirtyBranchSwitchDialog-C26DvfVJ.js} +1 -1
- package/dist/assets/FilesView-D0ZU_nCt.js +13 -0
- package/dist/assets/{GitView-BXsS3jG6.js → GitView-CYgiDRH-.js} +4 -4
- package/dist/assets/{JsonTreeView-D_hpXBnF.js → JsonTreeView-GsV9UScz.js} +1 -1
- package/dist/assets/{LinearIssuesView-BoUiLQG1.js → LinearIssuesView-shqUS8nl.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-B_B_a9KS.js → MarkdownImageGallery-CQSTFp6m.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-xgyyLiBM.js → MarkdownRendererImpl-DJWP3A8X.js} +2 -2
- package/dist/assets/{OnboardingScreen-DIp84OWt.js → OnboardingScreen-CTuu4lgo.js} +1 -1
- package/dist/assets/{PatchDiff-8p6nLJaU.js → PatchDiff-Dp53v2pl.js} +1 -1
- package/dist/assets/{PierreDiffViewer-DjC8nTk9.js → PierreDiffViewer-B5l0djPS.js} +1 -1
- package/dist/assets/PlanView-CLUWkGiG.js +5 -0
- package/dist/assets/SettingsView-CojPQVHx.js +28 -0
- package/dist/assets/{SettingsWindow-Cpb4hM6q.js → SettingsWindow-DbgEnZ6T.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DfaKZXNU.js → ToolOutputDialog-Du-RZj-a.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-DtZLzrSK.js → ToolPartDiffPreview-HBLSokoe.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-C8i9HpTB.js → VirtualizedFileDiff-Bzp3hClU.js} +4 -4
- package/dist/assets/WalkthroughView-CpgA4s9w.js +4 -0
- package/dist/assets/{computeVirtualFileMetrics-BBI7ZwrC.js → computeVirtualFileMetrics-CI1PC_z2.js} +2 -2
- package/dist/assets/de-BX8b4hDD.js +10 -0
- package/dist/assets/es-e98cS-yM.js +16 -0
- package/dist/assets/fr-BOiqxJAs.js +14 -0
- package/dist/assets/index-BD8ILbxF.js +40 -0
- package/dist/assets/{index-jXSK5RrB.js → index-Cmn74sw-.js} +1 -1
- package/dist/assets/index-zhgg-SDz.css +1 -0
- package/dist/assets/{isDiffPlainText-B_x_rVon.js → isDiffPlainText-DVralkU-.js} +1 -1
- package/dist/assets/{isFilePlainText-DW_xMer1.js → isFilePlainText-CgTREsRX.js} +1 -1
- package/dist/assets/ja-aoO55hGu.js +16 -0
- package/dist/assets/{ko-idhXGF8j.js → ko-BGzFLogk.js} +3 -3
- package/dist/assets/{main-CzdPuL0s.js → main-BgfXQ-4g.js} +2 -2
- package/dist/assets/main-DGYUWmIt.js +930 -0
- package/dist/assets/{markdownCore-Cn4Tyejo.js → markdownCore-BesaNs_G.js} +3 -3
- package/dist/assets/{miniChat-CCkqKOLp.js → miniChat-DHKXp-_I.js} +2 -2
- package/dist/assets/{mobile-mvxTo055.js → mobile-lXQ08VnX.js} +2 -2
- package/dist/assets/patchFileDiff-i1lTtNbn.js +13 -0
- package/dist/assets/{pl-CGZWUqZJ.js → pl-B5x19laq.js} +3 -3
- package/dist/assets/pt-BR-C3oU51Il.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-CuO4ue6B.js +2 -0
- package/dist/assets/renderMobileApp-B3zFlHy4.js +25 -0
- package/dist/assets/runtimeEndpointReset-BLzrtrmj.js +41 -0
- package/dist/assets/scheduledTasksApi-BEuUF_cj.js +1 -0
- package/dist/assets/{shikiHighlight-CRl0SUC9.js → shikiHighlight-ctlcPvvx.js} +1 -1
- package/dist/assets/surface-COKb77Ua.js +1 -0
- package/dist/assets/tr-C0QQa7et.js +7 -0
- package/dist/assets/uk-CqLSe9wT.js +16 -0
- package/dist/assets/{useAppFontEffects-CPKeOpUo.js → useAppFontEffects-B6OfEypo.js} +153 -155
- package/dist/assets/useGitComparison-BXZXEAW6.js +1 -0
- package/dist/assets/{useInlineCommentController-BiWz4AVb.js → useInlineCommentController-CgbrpEWu.js} +2 -2
- package/dist/assets/{useRootScrollLock-BS4-kr7P.js → useRootScrollLock-Me41OjBT.js} +1 -1
- package/dist/assets/{vendor-base-ui-DdV8vhHn.js → vendor-base-ui-BY_5qla_.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-Bg4AEeCr.js → vendor-codemirror-language-data-SJuFp0a0.js} +2 -2
- package/dist/assets/vendor-legendapp-list-BuBPBC3R.js +1 -0
- package/dist/assets/{vendor-zod-BPAANqvH.js → vendor-zod-B6551dwG.js} +2 -2
- package/dist/assets/{web-components-z7hfnS8n.js → web-components-D8GS8Ork.js} +1 -1
- package/dist/assets/zh-CN-iJEie4d6.js +16 -0
- package/dist/assets/zh-TW-CyslEwlK.js +16 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +1 -1
- package/server/index.js +3 -13
- package/server/lib/agent-memory/runtime.js +7 -2
- package/server/lib/agent-memory/runtime.test.js +22 -0
- package/server/lib/event-stream/DOCUMENTATION.md +3 -0
- package/server/lib/event-stream/global-hub.js +29 -4
- package/server/lib/event-stream/global-hub.test.js +22 -0
- package/server/lib/event-stream/global-ws-bridge.js +15 -18
- package/server/lib/event-stream/protocol.js +21 -7
- package/server/lib/event-stream/runtime.js +9 -6
- package/server/lib/event-stream/runtime.test.js +60 -0
- package/server/lib/git/DOCUMENTATION.md +10 -1
- package/server/lib/git/routes.js +21 -8
- package/server/lib/git/routes.test.js +78 -0
- package/server/lib/git/service.js +159 -4
- package/server/lib/git/service.test.js +74 -0
- package/server/lib/github/DOCUMENTATION.md +5 -0
- package/server/lib/github/routes.js +2 -2
- package/server/lib/message-queue/DOCUMENTATION.md +7 -0
- package/server/lib/message-queue/runtime.js +13 -0
- package/server/lib/message-queue/runtime.test.js +31 -1
- package/server/lib/notifications/DOCUMENTATION.md +1 -1
- package/server/lib/notifications/emitter-runtime.js +4 -3
- package/server/lib/opencode/DOCUMENTATION.md +18 -4
- package/server/lib/opencode/env-runtime.js +5 -1
- package/server/lib/opencode/env-runtime.test.js +72 -0
- package/server/lib/opencode/feature-routes-runtime.js +15 -1
- package/server/lib/opencode/lifecycle.js +4 -3
- package/server/lib/opencode/lifecycle.test.js +29 -0
- package/server/lib/opencode/managed-plugin-config.js +1 -1
- package/server/lib/opencode/proxy.js +33 -0
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +11 -1
- package/server/lib/opencode/settings-registry.json +3 -0
- package/server/lib/opencode/settings-runtime.js +36 -9
- package/server/lib/opencode/settings-runtime.test.js +158 -2
- package/server/lib/project-context/DOCUMENTATION.md +13 -3
- package/server/lib/project-context/runtime.js +8 -2
- package/server/lib/project-context/runtime.test.js +54 -0
- package/server/lib/projects/DOCUMENTATION.md +2 -1
- package/server/lib/projects/project-config.js +38 -9
- package/server/lib/projects/project-config.test.js +97 -0
- package/server/lib/projects/project-id.js +26 -0
- package/server/lib/relay/DOCUMENTATION.md +20 -0
- package/server/lib/relay/host-client.js +7 -0
- package/server/lib/relay/host-client.test.js +14 -0
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +9 -1
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +28 -0
- package/server/lib/scheduled-tasks/runtime.js +12 -2
- package/server/lib/scheduled-tasks/runtime.test.js +53 -0
- package/server/lib/session-assist/DOCUMENTATION.md +131 -66
- package/server/lib/session-assist/context.js +127 -0
- package/server/lib/session-assist/context.test.js +132 -0
- package/server/lib/session-assist/prompt.js +54 -0
- package/server/lib/session-assist/runtime.js +111 -257
- package/server/lib/session-assist/runtime.test.js +203 -0
- package/server/lib/walkthrough/DOCUMENTATION.md +15 -5
- package/server/lib/walkthrough/pr-source.test.js +21 -0
- package/server/lib/walkthrough/pull-request.js +7 -4
- package/server/lib/walkthrough/pull-request.test.js +16 -0
- package/server/lib/walkthrough/routes.js +19 -0
- package/server/lib/walkthrough/routes.test.js +26 -0
- package/server/lib/walkthrough/sources.js +13 -2
- package/server/opencode-worktree-readiness.test.js +130 -0
- package/dist/assets/DiffView-DXjVsEOw.js +0 -4
- package/dist/assets/FilesView-CJdG0-wk.js +0 -17
- package/dist/assets/PlanView-CJTmOF6I.js +0 -5
- package/dist/assets/SettingsView-DD-JqIJx.js +0 -28
- package/dist/assets/WalkthroughView-DeKMvZlL.js +0 -4
- package/dist/assets/de-DCrsQ5zS.js +0 -10
- package/dist/assets/es-Dwv4YfH6.js +0 -16
- package/dist/assets/fr-BCWg4Cnx.js +0 -14
- package/dist/assets/index-B68h5S5B.css +0 -1
- package/dist/assets/index-DVwMarHI.js +0 -39
- package/dist/assets/ja-Bruw3RYC.js +0 -16
- package/dist/assets/main-BkyaQhJX.js +0 -930
- package/dist/assets/patchFileDiff-Csk4iNUi.js +0 -13
- package/dist/assets/pt-BR-B8V7u7tA.js +0 -16
- package/dist/assets/renderElectronMiniChatApp-BxoyujA5.js +0 -2
- package/dist/assets/renderMobileApp-B48CsP4r.js +0 -25
- package/dist/assets/runtimeEndpointReset-Bg5gx18H.js +0 -17
- package/dist/assets/scheduledTasksApi-BW0Etzwz.js +0 -1
- package/dist/assets/surface-oMvhsog3.js +0 -1
- package/dist/assets/tr-BK_KiO2V.js +0 -7
- package/dist/assets/uk-CG74xV8N.js +0 -16
- package/dist/assets/useGitComparison-DH220WmO.js +0 -1
- package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +0 -1
- package/dist/assets/zh-CN-T4AXofZI.js +0 -16
- package/dist/assets/zh-TW-Dte40sxp.js +0 -16
- package/server/lib/mcp-reconnect/DOCUMENTATION.md +0 -55
- package/server/lib/mcp-reconnect/runtime.js +0 -122
- package/server/lib/mcp-reconnect/runtime.test.js +0 -140
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-jXSK5RrB.js","assets/useAppFontEffects-CPKeOpUo.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-DVwMarHI.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-zod-BPAANqvH.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-B68h5S5B.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-DdV8vhHn.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/contextPanelEmbeddedChat-BdA6bdky.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-Bg4AEeCr.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-gg7YLRW7.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/computeVirtualFileMetrics-BBI7ZwrC.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/isFilePlainText-DW_xMer1.js","assets/isDiffPlainText-B_x_rVon.js","assets/vendor-diff-C3JhlQdm.js","assets/vendor-lru_map-Tstukz9J.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/PlanView-CJTmOF6I.js","assets/shikiHighlight-CRl0SUC9.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useInlineCommentController-BiWz4AVb.js","assets/CodeMirrorCommentWidgets-B1Gizi3a.js","assets/vendor-capacitor-keyboard-CYccoJjr.js","assets/vendor-capacitor-core-B4EWRrHz.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as ts}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as _e,r as ae,j as t,R as c}from"./vendor-react-BUCujlKS.js";import{ef as Eo,eg as zn,ca as Ir,cb as Tr,a$ as Ro,f as nt,o as Dr,bL as Es,bM as Rs,bO as As,I as E,bR as Js,c4 as Un,h as re,B as ve,bm as Pr,g as Er,t as ge,eh as Ao,ei as Mo,ej as Lo,O as Bo,dZ as Fo,ek as Oo,el as $o,em as Vo,y as ut,en as Wo,l as Tt,eo as zo,dz as Rr,ep as Uo,dA as _o,c5 as hs,cY as Go,bN as Ys,bh as Ho,bk as Ko,bj as qo,eq as Jo,bb as bs,er as Yo,es as Qo,et as Xo,eu as Zo,ev as ea,ew as ta,ex as sa,ey as na,b as Et,ce as ra,a3 as _n,bn as oa,bc as Rn,ez as Cs,dK as sn,eA as aa,eB as Ar,eC as ia,u as Xt,cK as la,eD as zs,T as Nt,ds as ca,eE as Gn,eF as da,eG as ua,eH as Hn,eI as ma,eJ as fa,eK as ha,eL as pa,eM as nn,ao as Ht,ap as Kt,ar as qt,c3 as Qs,b_ as Us,b$ as _s,eN as ga,eO as xn,c0 as bn,c1 as Gs,c2 as Zt,N as Mr,eP as xa,Q as ba,eQ as ya,eR as Hs,eS as wa,U as va,V as ja,S as Sa,eT as Lr,eU as Na,e5 as ka,r as Br,W as Xs,eV as Ca,eW as Ia,eX as Ta,a1 as yn,eY as Da,M as ms,a7 as ps,a8 as gs,a9 as xs,cF as wn,cG as vn,cH as jn,cI as Sn,cA as Lt,cB as Mt,eZ as ks,b9 as Bt,bI as Nn,bP as Pa,bQ as An,aB as Is,cc as Ea,e_ as Fr,aC as kn,af as Ra,dP as Aa,ai as Mn,e$ as Bs,m as Or,c$ as _t,f0 as Ma,f1 as rn,f2 as La,f3 as Kn,aq as qn,f4 as Ba,c6 as Fa,dT as Oa,dH as $a,dI as Va,dJ as Wa,f5 as za,f6 as Ua,cE as _a,$ as Ga,H as Ha,c as Ka,d as qa,cV as Ja,f7 as $r,_ as Vr,X as Ya,e6 as At,f8 as Qa,f9 as Xa,fa as Wr,a0 as Zs,fb as Rt,fc as Cn,fd as Za,fe as zr,ff as Fs,cm as ei,fg as ti,fh as si,fi as ni,fj as ri,fk as oi,dk as ai,dw as ii,Z as In,bf as li,d5 as ci,fl as di,az as ui,ac as mi,bY as fi,fm as Ur,ec as hi,fn as pi,fo as gi,fp as xi,fq as bi,bV as yi,d3 as wi,n as vi,a5 as ji,fr as Si}from"./useAppFontEffects-CPKeOpUo.js";import{aw as Ni,ax as Jn,ay as ki,i as Ci,az as Ii,K as _r,aa as Ti,h as Jt,u as Ke,E as Di,b as Pi,z as Gr,a as Gt,d as Yn,q as Hr,a2 as Ei,aA as Wt,aB as Ri,n as ys,D as Kr,H as mt,ae as Ai,af as Mi,aC as Li,aD as Bi,N as Ks,A as fs,a1 as Fi,aE as Oi,ac as Ln,aF as $i,I as Vi,aG as vs,aH as on,aI as qr,aJ as Wi,a0 as zi,t as Ui,C as _i}from"./index-DVwMarHI.js";import{o as Bn,s as Yt,b as Jr,l as Gi,r as Hi,c as Ki}from"./vendor-zod-BPAANqvH.js";import{g as qi,h as Ji,i as Yi,d as Qi,C as Xi,c as Zi,M as el,S as tl,a as sl,b as nl}from"./vendor-base-ui-DdV8vhHn.js";import{c as Fn,d as rl,p as ol}from"./vendor-zustand-BAGL70zf.js";import{toast as al}from"./vendor-sonner-DFyL3AvE.js";import{i as Yr}from"./contextPanelEmbeddedChat-BdA6bdky.js";import{f as Qr,h as Xr,P as Zr,k as il,D as eo,j as to}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as so,S as no,h as ll,v as cl,a as dl}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as ro}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";const ul=["typescript","javascript","tsx","jsx","json","markdown"],oo={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:"none"},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:"word-alt"}};let Qn=null;const ao=()=>(Qn??=Promise.all([ts(()=>import("./index-jXSK5RrB.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,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112])),ts(()=>import("./workerFactory-tw7cIdmV.js"),[]),ts(()=>import("./appThemeRegistry-BK0dHKa6.js"),__vite__mapDeps([113,114,100,101,5,85,86,87,88,89,90,91,92,93,94,95,96,97,98]))]).then(([s,e,n])=>({WorkerPoolManager:s.WorkerPoolManager,workerFactory:e.workerFactory,ensurePierreThemeRegistered:n.ensurePierreThemeRegistered})),Qn),Ts={},Xn=new Set,Tn=new Set;let Ws={light:"pierre-light",dark:"pierre-dark"};const ml=()=>{for(const s of Tn)s()},io=(s,e)=>{e.setRenderOptions({theme:Ws,lineDiffType:oo[s].lineDiffType})},Dn=s=>{typeof window>"u"||Xn.has(s)||(Xn.add(s),ao().then(e=>{if(Ts[s])return;const n=oo[s],r=new e.WorkerPoolManager({workerFactory:e.workerFactory,poolSize:n.poolSize,totalASTLRUCacheSize:n.totalASTLRUCacheSize},{theme:{light:"pierre-light",dark:"pierre-dark"},langs:ul,lineDiffType:n.lineDiffType,preferredHighlighter:"shiki-wasm"});r.initialize(),Ts[s]=r,io(s,r),ml()}))},fl=s=>(Tn.add(s),()=>Tn.delete(s)),hl=s=>{if(!(Ws.light===s.light&&Ws.dark===s.dark)){Ws=s;for(const e of Object.keys(Ts)){const n=Ts[e];n&&io(e,n)}}},Xm=s=>{const e=_e.c(15),{children:n}=s,r=Eo();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=zn(!1),e[0]=o):o=e[0];const a=o;let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=zn(!0),e[1]=i):i=e[1];const d=i,l=r?.lightThemeId??a.metadata.id,m=r?.darkThemeId??d.metadata.id;let u;e[2]!==l||e[3]!==r?.availableThemes?(u=r?.availableThemes.find(S=>S.metadata.id===l)??a,e[2]=l,e[3]=r?.availableThemes,e[4]=u):u=e[4];const f=u;let b;e[5]!==m||e[6]!==r?.availableThemes?(b=r?.availableThemes.find(S=>S.metadata.id===m)??d,e[5]=m,e[6]=r?.availableThemes,e[7]=b):b=e[7];const h=b;let x,g;e[8]!==h||e[9]!==f?(x=()=>{let S=!1;return ao().then(M=>{S||(M.ensurePierreThemeRegistered(f),M.ensurePierreThemeRegistered(h),hl({light:f.metadata.id,dark:h.metadata.id}))}),()=>{S=!0}},g=[h,f],e[8]=h,e[9]=f,e[10]=x,e[11]=g):(x=e[10],g=e[11]),ae.useEffect(x,g);let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[12]=j):j=e[12],ae.useEffect(gl,j);let p;return e[13]!==n?(p=t.jsx(t.Fragment,{children:n}),e[13]=n,e[14]=p):p=e[14],p},Zm=s=>{const e=_e.c(5),n=s===void 0?"unified":s;let r;e[0]!==n?(r=()=>Ts[n],e[0]=n,e[1]=r):r=e[1];const o=ae.useSyncExternalStore(fl,r,xl);let a,i;return e[2]!==n?(a=()=>{Dn(n)},i=[n],e[2]=n,e[3]=a,e[4]=i):(a=e[3],i=e[4]),ae.useEffect(a,i),o};function pl(){Dn("unified"),Dn("split")}function gl(){if(typeof window>"u")return;const s=pl;if(typeof window.requestIdleCallback=="function"){const n=window.requestIdleCallback(s,{timeout:5e3});return()=>window.cancelIdleCallback(n)}const e=window.setTimeout(s,2e3);return()=>window.clearTimeout(e)}function xl(){}const an=(s,e)=>Ir(Tr.getState().dictionary,s,e),bl=s=>{const e=s.message.toLowerCase();return e.includes("code signature")||e.includes("did not pass validation")||e.includes("code requirement")||e.includes("not signed")?"signature":e.includes("command is disabled")?"updater-disabled":"unknown"},yl=s=>{const e=bl(s);return e==="signature"?an("updateDialog.error.signatureRejected"):e==="updater-disabled"?an("updateDialog.error.updaterDisabled"):s.message.trim()||an("updateDialog.error.restartFailed")},Zn="aiworker.update-install-id";function wl(){if(!(typeof window>"u"||typeof crypto.randomUUID!="function"))try{const s=window.localStorage.getItem(Zn)?.trim();if(s)return s;const e=crypto.randomUUID();return window.localStorage.setItem(Zn,e),e}catch{return}}function vl(){if(typeof window>"u")return"unknown";try{const{deviceType:s}=Ro();return s}catch{return"unknown"}}function jl(){const s=typeof window<"u"?window.__AIWORKER_ELECTRON__?.arch?.toLowerCase?.():void 0;if(s==="arm64"||s==="aarch64")return"arm64";if(s==="x64"||s==="amd64"||s==="x86_64")return"x64";const e=typeof window<"u"?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e==="arm64"||e==="aarch64")return"arm64";if(e==="x64"||e==="amd64"||e==="x86_64")return"x64";const r=(typeof navigator<"u"?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(r==="arm"||r==="arm64"||r==="aarch64")return"arm64";if(r==="x86"||r==="x64"||r==="amd64")return"x64";const o=typeof navigator<"u"?navigator.userAgent.toLowerCase():"";return o.includes("aarch64")||o.includes("arm64")||o.includes("armv")?"arm64":o.includes("x86_64")||o.includes("x64")||o.includes("amd64")||o.includes("win64")?"x64":"unknown"}function Sl(){const s=Pi();if(s==="android"||s==="ios")return s;if(typeof navigator>"u")return"web";const e=(navigator.platform||"").toLowerCase();return e.includes("mac")?"macos":e.includes("win")?"windows":e.includes("linux")?"linux":"web"}function Nl(s){const e=Ke.getState().reportUsage,n=new URLSearchParams({reportUsage:e?"true":"false"});if(n.set("deviceClass",vl()),n.set("arch",jl()),n.set("platform",Sl()),e&&(s==="desktop"||s==="mobile")){const r=wl();r&&n.set("installId",r)}return s==="desktop"?(n.set("appType","desktop-electron"),n.set("instanceMode",Di()?"local":"remote"),n):s==="vscode"?(n.set("appType","vscode"),n.set("instanceMode","local"),n):s==="mobile"?(n.set("appType","mobile-capacitor"),n.set("instanceMode","remote"),n):(n.set("appType","web"),n.set("instanceMode","unknown"),n)}async function Os(s,e){try{const n=Nl(s),r=typeof window<"u"?window.__VSCODE_CONFIG__?.extensionVersion:void 0;e?n.set("currentVersion",e):s==="vscode"&&r&&n.set("currentVersion",r);const o=await Jt(`/api/openchamber/update-check?${n.toString()}`,{method:"GET",headers:{Accept:"application/json"},priority:"low"});if(!o.ok)throw new Error(`Server responded with ${o.status}`);const a=await o.json();return{available:a.available??!1,version:a.version,currentVersion:a.currentVersion??"unknown",body:a.body,releaseUrl:a.releaseUrl,downloadUrl:a.downloadUrl,nextSuggestedCheckInSec:typeof a.nextSuggestedCheckInSec=="number"&&Number.isFinite(a.nextSuggestedCheckInSec)?a.nextSuggestedCheckInSec:void 0,packageManager:a.packageManager,updateCommand:a.updateCommand}}catch(n){return console.warn("Failed to check for updates:",n),null}}function kl(){return Ci()?"mobile":Ii()?"desktop":_r()?"vscode":Ti()?"web":null}const er={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null},Cl=Fn()((s,e)=>({...er,checkForUpdates:async()=>{const n=kl();if(!n)return null;s({checking:!0,error:null,runtimeType:n});try{let r=null,o=null;if(n==="desktop"){const a="1.23.0",[i,d]=await Promise.allSettled([Jn(),Os("desktop",a)]),l=i.status==="fulfilled"?i.value:null;return o=d.status==="fulfilled"?d.value?.nextSuggestedCheckInSec??null:null,s({checking:!1,available:l?.available??!1,info:l,lastChecked:Date.now(),nextCheckInSec:o}),o}else n==="web"?(r=await Os("web"),o=r?.nextSuggestedCheckInSec??null):n==="vscode"?o=(await Os("vscode"))?.nextSuggestedCheckInSec??null:n==="mobile"&&(r=await Os("mobile","1.23.0"),o=r?.nextSuggestedCheckInSec??null);return s({checking:!1,available:n==="vscode"?!1:r?.available??!1,info:n==="vscode"?null:r,lastChecked:Date.now(),nextCheckInSec:o}),o}catch(r){return s({checking:!1,error:r instanceof Error?r.message:"Failed to check for updates"}),null}},downloadUpdate:async()=>{const{available:n,runtimeType:r}=e();if(!(r!=="desktop"||!n)){s({downloading:!0,error:null,progress:null});try{const o=await Jn();if(!o?.available)throw new Error("Update detected, but desktop package is not ready yet. Retry in a moment.");if(s(i=>({info:i.info?{...i.info,...o,body:i.info.body||o.body,available:i.info.available}:o})),!await ki(i=>{s({progress:i})}))throw new Error("Desktop update only works on Local instance");s({downloading:!1,downloaded:!0})}catch(o){s({downloading:!1,error:o instanceof Error?o.message:"Failed to download update"})}}},restartToUpdate:async()=>{const{downloaded:n,runtimeType:r}=e();if(!(r!=="desktop"||!n)){s({error:null});try{if(!await Ni())throw new Error(Ir(Tr.getState().dictionary,"updateDialog.error.restartUnavailable"))}catch(o){s({error:yl(o instanceof Error?o:new Error(String(o)))})}}},dismiss:()=>{s({available:!1,downloaded:!1,info:null})},reset:()=>{s(er)}})),Il=Bn({success:Gi(!0),autoRestart:Jr().optional(),updateOwner:Yt().optional(),version:Yt().min(1).optional()}),Tl=Bn({available:Jr(),currentVersion:Yt().optional(),error:Yt().optional()}),lo=Bn({error:Yt(),code:Yt().optional()});async function Dl(s=Jt){try{const e=await s("/api/openchamber/update-install",{method:"POST",headers:{"Content-Type":"application/json"}}),n=await e.json();if(!e.ok){const a=lo.safeParse(n);return{success:!1,error:a.success?a.data.error:void 0}}const r=Il.safeParse(n);if(!r.success)return{success:!1};const o=r.data;return o.updateOwner==="electron-updater"?o.version?{success:!0,autoRestart:o.autoRestart!==!1,target:{owner:"electron",version:o.version}}:{success:!1}:{success:!0,autoRestart:o.autoRestart!==!1,target:{owner:"package-manager"}}}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function Pl(s,e,{fetchUpdate:n=Jt,maxWaitMs:r=600*1e3,intervalMs:o=2e3}={}){const a=Date.now()+r;for(;Date.now()<a;){const i=AbortSignal.timeout(Math.max(1,Math.min(1e4,a-Date.now())));try{const l=await n("/api/openchamber/update-check?appType=web&reportUsage=false&updateStatus=true",{method:"GET",headers:{Accept:"application/json"},signal:i});if(l.ok){const m=Tl.safeParse(await l.json());if(m.success&&!m.data.error){const u=m.data;if(s.owner==="electron"?u.currentVersion===s.version:u.available===!1||e!==void 0&&u.currentVersion!==void 0&&u.currentVersion!==e)return{status:"applied"}}}else{const m=lo.safeParse(await l.json().catch(()=>null));if(m.success&&m.data.code==="DESKTOP_UPDATE_RESTART_FAILED")return{status:"failed",error:m.data.error};if(s.owner==="package-manager"&&(l.status===401||l.status===403)&&(await n("/health",{headers:{Accept:"application/json"},signal:i})).ok)return{status:"applied"}}}catch{}const d=a-Date.now();d>0&&await new Promise(l=>setTimeout(l,Math.min(o,d)))}return{status:"timeout"}}const tr="https://roweb.cn/roweb/openchamber/releases";function El(s){const e=new Date(`${s}T00:00:00`);return Number.isNaN(e.getTime())?s:new Intl.DateTimeFormat(Pr(),{year:"numeric",month:"short",day:"numeric"}).format(e)}function Rl(s){return s.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,"").trim()}function sr(s){return s.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,"$1[@$2](https://github.com/$2)")}function Al(s,e){const n=s.split(".").map(o=>Number.parseInt(o,10)),r=e.split(".").map(o=>Number.parseInt(o,10));for(let o=0;o<3;o+=1){const a=Number.isFinite(n[o])?n[o]:0,i=Number.isFinite(r[o])?r[o]:0;if(a!==i)return i-a}return 0}function Ml(s){const e=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[];let r;for(;(r=e.exec(s))!==null;)n.push({version:r[1]??"",date:r[2]??"",start:r.index});return n.length===0?[]:n.map((o,a)=>{const i=n[a+1]?.start??s.length,d=s.slice(o.start,i).trim();return{version:o.version,date:o.date,start:o.start,end:i,raw:d}})}const ef=({open:s,onOpenChange:e,info:n,downloading:r,downloaded:o,progress:a,error:i,onDownload:d,onRestart:l,runtimeType:m="desktop"})=>{const{t:u}=nt(),[f,b]=ae.useState(!1),[h,x]=ae.useState("idle"),[g,j]=ae.useState(null),p=n?.version?n.releaseUrl||`${tr}/tag/v${n.version}`:tr,S=n?.downloadUrl||p,M=a?.total?Math.round(a.downloaded/a.total*100):0,R=m==="web",F=m==="mobile",U=n?.updateCommand||"aiworker update";ae.useEffect(()=>{s||(x("idle"),j(null))},[s]);const T=async()=>{(await Er(U)).ok&&(b(!0),setTimeout(()=>b(!1),2e3))},w=ae.useCallback(async B=>{await Dr(B)},[]),H=ae.useCallback(async()=>{x("updating"),j(null);const B=await Dl();if(!B.success){x("error"),j(B.error||u("updateDialog.error.updateFailed"));return}B.autoRestart&&(x("restarting"),await new Promise(J=>setTimeout(J,2e3))),x("reconnecting");const G=await Pl(B.target,n?.currentVersion);G.status==="applied"?window.location.reload():(x("error"),j(G.status==="failed"?G.error:u("updateDialog.error.takingLonger")))},[n?.currentVersion,u]),P=ae.useCallback(()=>{w(S)},[w,S]),N=h!=="idle"&&h!=="error",$=ae.useMemo(()=>{if(!n?.body)return null;const B=n.body.trim();if(!B)return null;const G=Ml(B);if(G.length===0)return{kind:"raw",title:u("updateDialog.changelog.title"),content:sr(B)};const J=[...G].sort((L,_)=>Al(L.version,_.version));return{kind:"sections",title:u("updateDialog.changelog.title"),sections:J.map(L=>({version:L.version,dateLabel:El(L.date),content:sr(Rl(L.raw)||B)}))}},[n?.body,u]);return t.jsx(Es,{open:s,onOpenChange:N?void 0:e,children:t.jsxs(Rs,{className:"max-w-4xl p-5 bg-background border-[var(--interactive-border)]",showCloseButton:!0,children:[t.jsxs("div",{className:"flex items-center mb-1",children:[t.jsxs(As,{className:"flex items-center gap-2.5",children:[t.jsx(E,{name:"download-cloud",className:"h-5 w-5 text-[var(--primary-base)]"}),t.jsx("span",{className:"text-lg font-semibold text-foreground",children:u(h==="restarting"||h==="reconnecting"?"updateDialog.header.updating":"updateDialog.header.updateAvailable")})]}),(n?.currentVersion||n?.version)&&t.jsxs("div",{className:"flex items-center gap-2 font-mono text-sm ml-3",children:[n?.currentVersion&&t.jsx("span",{className:"text-muted-foreground",children:n.currentVersion}),n?.currentVersion&&n?.version&&t.jsx("span",{className:"text-muted-foreground/50",children:"→"}),n?.version&&t.jsx("span",{className:"text-[var(--primary-base)] font-medium",children:n.version})]})]}),t.jsxs("div",{className:"space-y-2",children:[R&&N&&t.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(E,{name:"loader",className:"h-5 w-5 animate-spin text-[var(--primary-base)]"}),t.jsxs("div",{className:"typography-ui-label text-foreground",children:[h==="updating"&&u("updateDialog.status.installingUpdate"),h==="restarting"&&u("updateDialog.status.serverRestarting"),h==="reconnecting"&&u("updateDialog.status.waitingForServer")]})]}),t.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:u("updateDialog.status.autoReloadHint")})]}),$&&!N&&t.jsx("div",{className:"rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 overflow-hidden",children:t.jsx(Js,{className:"max-h-[400px] p-0",fillContainer:!1,children:$.kind==="raw"?t.jsx("div",{className:"p-4 typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline [&_h3]:!mt-4 [&_h3]:!mb-1.5 [&_h3]:!text-xs [&_h3]:!font-medium [&_h3]:!uppercase [&_h3]:!tracking-wide [&_h3]:!text-muted-foreground [&_h3:first-child]:!mt-0",onClickCapture:B=>{const J=B.target.closest("a");J&&J.href&&(B.preventDefault(),B.stopPropagation(),w(J.href))},children:t.jsx(Un,{content:$.content,disableLinkSafety:!0,enableFileReferences:!1})}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:$.sections.map(B=>t.jsxs("div",{className:"p-4",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.jsxs("span",{className:"typography-ui-label font-mono text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-1.5 py-0.5 rounded",children:["v",B.version]}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:B.dateLabel})]}),t.jsx("div",{className:"typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline [&_h3]:!mt-4 [&_h3]:!mb-1.5 [&_h3]:!text-xs [&_h3]:!font-medium [&_h3]:!uppercase [&_h3]:!tracking-wide [&_h3]:!text-muted-foreground [&_h3:first-child]:!mt-0",onClickCapture:G=>{const L=G.target.closest("a");L&&L.href&&(G.preventDefault(),G.stopPropagation(),w(L.href))},children:t.jsx(Un,{content:B.content,disableLinkSafety:!0,enableFileReferences:!1})})]},B.version))})})}),R&&n?.packageManager!=="electron"&&h==="error"&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(E,{name:"terminal",className:"h-4 w-4"}),t.jsx("span",{children:u("updateDialog.fallback.updateViaTerminal")})]}),t.jsxs("div",{className:"flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]",children:[t.jsx("code",{className:"flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap",children:U}),t.jsx("button",{onClick:T,className:re("flex items-center justify-center p-2 rounded","text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]","transition-colors",f&&"text-[var(--status-success)]"),title:u(f?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:f?t.jsx(E,{name:"check",className:"h-4 w-4"}):t.jsx(E,{name:"clipboard",className:"h-4 w-4"})})]})]}),!R&&!F&&r&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:u("updateDialog.status.downloadingPayload")}),t.jsxs("span",{className:"font-mono text-foreground",children:[M,"%"]})]}),t.jsx("div",{className:"h-1.5 bg-[var(--surface-subtle)] rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-[var(--primary-base)] transition-all duration-300",style:{width:`${M}%`}})})]}),(i||g)&&t.jsx("div",{className:"p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg",children:t.jsx("p",{className:"text-sm text-[var(--status-error)]",children:i||g})})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4",children:[t.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors shrink-0",children:[t.jsx(E,{name:"external-link",className:"h-4 w-4"}),"GitHub"]}),t.jsxs("div",{className:"flex-1 flex justify-end",children:[!R&&!F&&!o&&!r&&t.jsxs("button",{onClick:d,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(E,{name:"download",className:"h-4 w-4"}),u("updateDialog.actions.downloadUpdate")]}),!R&&!F&&r&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(E,{name:"loader",className:"h-4 w-4 animate-spin"}),u("updateDialog.status.downloading")]}),!R&&!F&&o&&t.jsxs("button",{onClick:l,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--status-success)] text-white hover:opacity-90 transition-opacity",children:[t.jsx(E,{name:"restart",className:"h-4 w-4"}),u("updateDialog.actions.restartToUpdate")]}),F&&t.jsxs(ve,{onClick:P,size:"default",children:[t.jsx(E,{name:"external-link",className:"h-4 w-4"}),u("updateDialog.actions.openMobileUpdate")]}),R&&!N&&t.jsxs("button",{onClick:H,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(E,{name:"download",className:"h-4 w-4"}),u("updateDialog.actions.updateNow")]}),R&&N&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(E,{name:"loader",className:"h-4 w-4 animate-spin"}),u("updateDialog.status.updating")]})]})]})]})})},tf=s=>!(s.dismissed==="true"||s.sessionShown==="true"||s.hasActiveToast),Ll=s=>!(!s.version||s.seenVersions.has(s.version)||s.dismissedVersion!==null&&s.dismissedVersion===s.version),Bl=s=>{if(s===null||typeof s!="object")return"";const e=s.version;return typeof e!="string"?"":e.trim()},Fl=s=>!s||s.upgrade?.supported!==!0||s.available!==!0||typeof s.latestVersion!="string"?"":s.latestVersion.trim(),us="opencode-update-available",$s="opencode-upgrade-progress",Ol=5e3,$l=[1e4,6e4],nr="opencode-update-toast-dismissed-version",sf=()=>{const{t:s}=nt(),e=Ke(i=>i.showOpenCodeUpdateNotifications),n=ae.useRef(new Set),r=ae.useRef(!1);ae.useEffect(()=>{e||ge.dismiss(us)},[e]);const o=ae.useCallback(()=>{ge.dismiss($s),Ao({message:s("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]}).catch(()=>{})},[s]),a=ae.useCallback(async()=>{if(!r.current){r.current=!0,ge.dismiss(us),ge.message(s("opencodeUpdate.toast.upgrading.title"),{id:$s,description:s("opencodeUpdate.toast.upgrading.description"),duration:1/0,icon:t.jsx(E,{name:"refresh",className:"h-4 w-4 animate-spin text-muted-foreground"})});try{const i=await Jt("/api/opencode/upgrade",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),d=await i.json().catch(()=>null);if(!i.ok||d?.success===!1)throw new Error(d?.error||i.statusText||s("opencodeUpdate.toast.failed.description"));ge.success(s("opencodeUpdate.toast.updated.title"),{id:$s,description:d?.version?s("opencodeUpdate.toast.updated.descriptionWithVersion",{version:d.version}):s("opencodeUpdate.toast.updated.description"),duration:1/0,icon:t.jsx(E,{name:"check",className:"h-4 w-4 text-[var(--status-success)]"}),action:{label:s("opencodeUpdate.toast.actions.reload"),onClick:o}})}catch(i){ge.error(s("opencodeUpdate.toast.failed.title"),{id:$s,description:i instanceof Error?i.message:s("opencodeUpdate.toast.failed.description"),duration:1/0})}finally{r.current=!1}}},[o,s]);return ae.useEffect(()=>{const i=b=>{if(!Ke.getState().showOpenCodeUpdateNotifications){ge.dismiss(us);return}Ll({version:b,dismissedVersion:Yn().getItem(nr),seenVersions:n.current})&&(n.current.add(b),ge.info(s("opencodeUpdate.toast.available.title"),{id:us,description:s("opencodeUpdate.toast.available.description",{version:b}),duration:1/0,action:{label:s("opencodeUpdate.toast.actions.update"),onClick:a},cancel:{label:s("opencodeUpdate.toast.actions.dismiss"),onClick:()=>{Yn().setItem(nr,b),Hr({openCodeUpdateToastDismissedVersion:b}),ge.dismiss(us)}}}))};let d=!1;const l=[],m=async(b,h=Gt())=>{try{const x=await Jt("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!x.ok)throw new Error(x.statusText||"OpenCode upgrade status check failed");const g=await x.json().catch(()=>null),j=Fl(g);!d&&h===Gt()&&j&&i(j)}catch{const x=$l[b];!d&&h===Gt()&&x!==void 0&&l.push(setTimeout(()=>{m(b+1,h)},x))}},u=b=>{Bl(b.detail)&&m(0)};e&&l.push(setTimeout(()=>{m(0)},Ol));const f=Gr(({runtimeKey:b})=>{n.current.clear(),ge.dismiss(us),Ke.getState().showOpenCodeUpdateNotifications&&m(0,b)});return window.addEventListener("aiworker:opencode-update-available",u),()=>{d=!0;for(const b of l)clearTimeout(b);f(),window.removeEventListener("aiworker:opencode-update-available",u)}},[a,e,s]),null},nf=()=>{const s=_e.c(3),[e,n]=c.useState(Vl),{isUpdating:r}=e;let o,a;if(s[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>Lo(n),a=[],s[0]=o,s[1]=a):(o=s[0],a=s[1]),c.useEffect(o,a),!r)return null;let i;return s[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-background/90",children:t.jsx(Bo,{width:80,height:80,isAnimated:!0})}),s[2]=i):i=s[2],i};function Vl(){return Mo()}class Wl extends c.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){this.setState({error:e,errorInfo:n})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?t.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:t.jsxs(Fo,{className:"w-full max-w-md",children:[t.jsx(Oo,{className:"text-center",children:t.jsxs($o,{className:"flex items-center justify-center gap-2 text-destructive",children:[t.jsx(E,{name:"chat-3",className:"h-5 w-5"}),this.props.texts.title]})}),t.jsxs(Vo,{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground text-center",children:this.props.texts.description}),this.props.sessionId&&t.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:[this.props.texts.sessionLabel,": ",this.props.sessionId]}),this.state.error&&t.jsxs("details",{className:"text-xs font-mono bg-muted p-3 rounded",children:[t.jsx("summary",{className:"cursor-pointer hover:bg-interactive-hover/80",children:this.props.texts.detailsSummary}),t.jsx("pre",{className:"mt-2 max-h-48 overflow-auto",children:this.state.error.toString()})]}),t.jsx("div",{className:"flex gap-2",children:t.jsxs(ve,{onClick:this.handleReset,variant:"outline",className:"flex-1",children:[t.jsx(E,{name:"restart",className:"h-4 w-4 mr-2"}),this.props.texts.resetAction]})}),t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:this.props.texts.persistentHint})]})]})}):this.props.children}}function zl(s){const e=_e.c(22),{t:n}=nt();let r;e[0]!==n?(r=n("chat.errorBoundary.title"),e[0]=n,e[1]=r):r=e[1];let o;e[2]!==n?(o=n("chat.errorBoundary.description"),e[2]=n,e[3]=o):o=e[3];let a;e[4]!==n?(a=n("chat.errorBoundary.sessionLabel"),e[4]=n,e[5]=a):a=e[5];let i;e[6]!==n?(i=n("chat.errorBoundary.detailsSummary"),e[6]=n,e[7]=i):i=e[7];let d;e[8]!==n?(d=n("chat.errorBoundary.resetAction"),e[8]=n,e[9]=d):d=e[9];let l;e[10]!==n?(l=n("chat.errorBoundary.persistentHint"),e[10]=n,e[11]=l):l=e[11];let m;e[12]!==r||e[13]!==o||e[14]!==a||e[15]!==i||e[16]!==d||e[17]!==l?(m={title:r,description:o,sessionLabel:a,detailsSummary:i,resetAction:d,persistentHint:l},e[12]=r,e[13]=o,e[14]=a,e[15]=i,e[16]=d,e[17]=l,e[18]=m):m=e[18];let u;return e[19]!==s||e[20]!==m?(u=t.jsx(Wl,{...s,texts:m}),e[19]=s,e[20]=m,e[21]=u):u=e[21],u}const rf=s=>{const e=_e.c(8),{active:n,messagesEnabled:r,readOnly:o,initialAllowPromptingSubagentSessions:a}=s,i=n===void 0?!0:n,d=o===void 0?!1:o,m=ut(Ul)||void 0;let u;e[0]!==i||e[1]!==a||e[2]!==r||e[3]!==d?(u=t.jsx(Wo,{active:i,messagesEnabled:r,readOnly:d,initialAllowPromptingSubagentSessions:a}),e[0]=i,e[1]=a,e[2]=r,e[3]=d,e[4]=u):u=e[4];let f;return e[5]!==m||e[6]!==u?(f=t.jsx(zl,{sessionId:m,children:u}),e[5]=m,e[6]=u,e[7]=f):f=e[7],f};function Ul(s){return s.currentSessionId}const _l=qi,Gl=s=>{const e=_e.c(14);let n,r,o,a;e[0]!==s?({className:o,asChild:n,children:r,...a}=s,e[0]=s,e[1]=n,e[2]=r,e[3]=o,e[4]=a):(n=e[1],r=e[2],o=e[3],a=e[4]);let i;e[5]!==n||e[6]!==r?(i=n&&ae.isValidElement(r)?{render:r}:{children:r},e[5]=n,e[6]=r,e[7]=i):i=e[7];const d=i;let l;e[8]!==o?(l=re("flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",o),e[8]=o,e[9]=l):l=e[9];let m;return e[10]!==a||e[11]!==d||e[12]!==l?(m=t.jsx(Ji,{className:l,...a,...d}),e[10]=a,e[11]=d,e[12]=l,e[13]=m):m=e[13],m},Hl=s=>{const e=_e.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=re("transition-opacity duration-100 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0","motion-reduce:transition-none",n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(Yi,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a},rr=s=>({providerID:s.providerID,modelID:s.modelID,variant:s.variant,agent:s.agent});function Kl(s){const e=_e.c(131),{t:n}=nt(),{open:r,onOpenChange:o,target:a,projectDirectory:i,submitting:d,allowRunAsGoal:l,onConfirm:m}=s,u=d===void 0?!1:d,f=l===void 0?!1:l;let b;e[0]!==f?(b=f&&!_r(),e[0]=f,e[1]=b):b=e[1];const h=b,x=Tt(rc),g=Tt(nc),j=zo(sc),p=Tt(tc),S=Tt(ec),M=Tt(Zl),R=Tt(Xl),F=Tt(Ql);let U;e[2]!==F||e[3]!==M||e[4]!==S||e[5]!==R?(U=()=>rr({providerID:S,modelID:M,variant:R,agent:F}),e[2]=F,e[3]=M,e[4]=S,e[5]=R,e[6]=U):U=e[6];const[T,w]=c.useState(U);let H,P;e[7]!==j||e[8]!==g||e[9]!==x||e[10]!==r||e[11]!==i?(H=()=>{r&&(x({directory:i,source:"todoSendDialog"}),g({directory:i}),j())},P=[r,x,g,j,i],e[7]=j,e[8]=g,e[9]=x,e[10]=r,e[11]=i,e[12]=H,e[13]=P):(H=e[12],P=e[13]),c.useEffect(H,P);let N,$;e[14]!==F||e[15]!==M||e[16]!==S||e[17]!==R||e[18]!==r?(N=()=>{r&&w(rr({providerID:S,modelID:M,variant:R,agent:F}))},$=[r,S,M,R,F],e[14]=F,e[15]=M,e[16]=S,e[17]=R,e[18]=r,e[19]=N,e[20]=$):(N=e[19],$=e[20]),c.useEffect(N,$);let B,G;e[21]!==T.modelID||e[22]!==T.providerID||e[23]!==r||e[24]!==p?(B=()=>{if(!r||p.length===0)return;const $e=p.find(et=>et.id===T.providerID)??p[0],He=Array.isArray($e?.models)?$e.models:[],at=He.some(et=>et.id===T.modelID),xe=He[0]?.id??"";$e?.id===T.providerID&&at||w(et=>({...et,providerID:$e?.id??"",modelID:at?et.modelID:xe,variant:""}))},G=[r,p,T.providerID,T.modelID],e[21]=T.modelID,e[22]=T.providerID,e[23]=r,e[24]=p,e[25]=B,e[26]=G):(B=e[25],G=e[26]),c.useEffect(B,G);const J=Yl;let L;if(e[27]!==T.modelID||e[28]!==T.providerID||e[29]!==p){let $e;e[31]!==T.providerID?($e=at=>at.id===T.providerID,e[31]=T.providerID,e[32]=$e):$e=e[32],L=p.find($e)?.models?.find(at=>at.id===T.modelID),e[27]=T.modelID,e[28]=T.providerID,e[29]=p,e[30]=L}else L=e[30];const _=L;let se;e[33]!==_?(se=_?.variants?Object.keys(_.variants):[],e[33]=_,e[34]=se):se=e[34];const ne=se,V=ne.length>0;let ee,C;e[35]!==T.variant||e[36]!==V?(ee=()=>{V||!T.variant||w(Jl)},C=[V,T.variant],e[35]=T.variant,e[36]=V,e[37]=ee,e[38]=C):(ee=e[37],C=e[38]),c.useEffect(ee,C);let W;e[39]!==T.modelID||e[40]!==T.providerID?(W=T.providerID.trim().length>0&&T.modelID.trim().length>0,e[39]=T.modelID,e[40]=T.providerID,e[41]=W):W=e[41];const O=W;let A;e[42]!==O||e[43]!==T||e[44]!==m||e[45]!==u?(A=()=>{!O||u||m(T)},e[42]=O,e[43]=T,e[44]=m,e[45]=u,e[46]=A):A=e[46];const z=A;let v,Z;e[47]!==z||e[48]!==r?(v=()=>{if(!r)return;const $e=He=>{(He.metaKey||He.ctrlKey)&&He.key==="Enter"&&(He.preventDefault(),z())};return window.addEventListener("keydown",$e),()=>window.removeEventListener("keydown",$e)},Z=[r,z],e[47]=z,e[48]=r,e[49]=v,e[50]=Z):(v=e[49],Z=e[50]),c.useEffect(v,Z);let X;e[51]!==n||e[52]!==a?(X=n(a==="worktree"?"rightSidebar.contextNotesTodo.sendDialog.title.newWorktree":"rightSidebar.contextNotesTodo.sendDialog.title.newSession"),e[51]=n,e[52]=a,e[53]=X):X=e[53];const ie=X;let je;e[54]!==o||e[55]!==u?(je=$e=>{u||o($e)},e[54]=o,e[55]=u,e[56]=je):je=e[56];let de;e[57]!==ie?(de=t.jsx(Ys,{children:t.jsx(As,{children:ie})}),e[57]=ie,e[58]=de):de=e[58];let Re;e[59]!==n?(Re=n("chat.modelControls.model"),e[59]=n,e[60]=Re):Re=e[60];let le;e[61]!==Re?(le=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:Re}),e[61]=Re,e[62]=le):le=e[62];let me;e[63]===Symbol.for("react.memo_cache_sentinel")?(me=($e,He)=>{w(at=>({...at,providerID:$e,modelID:He,variant:""}))},e[63]=me):me=e[63];let Te;e[64]!==T.modelID||e[65]!==T.providerID?(Te=t.jsx(Rr,{providerId:T.providerID,modelId:T.modelID,className:"max-w-[320px] justify-between",dropdownPortalToBody:!0,onChange:me}),e[64]=T.modelID,e[65]=T.providerID,e[66]=Te):Te=e[66];let k;e[67]!==le||e[68]!==Te?(k=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[le,Te]}),e[67]=le,e[68]=Te,e[69]=k):k=e[69];let Y;e[70]!==n?(Y=n("sessions.scheduledTasks.editor.thinkingLevel.label"),e[70]=n,e[71]=Y):Y=e[71];let q;e[72]!==Y?(q=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:Y}),e[72]=Y,e[73]=q):q=e[73];const ce=!V;let pe;e[74]===Symbol.for("react.memo_cache_sentinel")?(pe=$e=>w(He=>({...He,variant:$e})),e[74]=pe):pe=e[74];let Q;e[75]!==T.variant||e[76]!==ce||e[77]!==ne?(Q=t.jsx(Uo,{value:T.variant,options:ne,disabled:ce,onChange:pe}),e[75]=T.variant,e[76]=ce,e[77]=ne,e[78]=Q):Q=e[78];let ue;e[79]!==q||e[80]!==Q?(ue=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[q,Q]}),e[79]=q,e[80]=Q,e[81]=ue):ue=e[81];let Ee;e[82]!==n?(Ee=n("sessions.scheduledTasks.editor.agent.label"),e[82]=n,e[83]=Ee):Ee=e[83];let Pe;e[84]!==Ee?(Pe=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:Ee}),e[84]=Ee,e[85]=Pe):Pe=e[85];let he;e[86]===Symbol.for("react.memo_cache_sentinel")?(he=$e=>w(He=>({...He,agent:$e})),e[86]=he):he=e[86];let Ie;e[87]!==T.agent?(Ie=t.jsx(_o,{agentName:T.agent,filter:J,dropdownPortalToBody:!0,onChange:he}),e[87]=T.agent,e[88]=Ie):Ie=e[88];let ke;e[89]!==Pe||e[90]!==Ie?(ke=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[Pe,Ie]}),e[89]=Pe,e[90]=Ie,e[91]=ke):ke=e[91];let Le;e[92]!==k||e[93]!==ue||e[94]!==ke?(Le=t.jsxs("div",{className:"flex flex-col gap-4",children:[k,ue,ke]}),e[92]=k,e[93]=ue,e[94]=ke,e[95]=Le):Le=e[95];const Ge=`flex items-center gap-3 ${h?"justify-between":"justify-end"}`;let Je;e[96]!==T.runAsGoal||e[97]!==h||e[98]!==u||e[99]!==n?(Je=h?t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(hs,{checked:T.runAsGoal===!0,onChange:$e=>w(He=>({...He,runAsGoal:$e})),disabled:u,ariaLabel:n("sessions.scheduledTasks.editor.goal.aria")}),t.jsx("button",{type:"button",className:"truncate typography-ui-label text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:u,onClick:()=>w(ql),children:n("sessions.scheduledTasks.editor.goal.label")})]}):null,e[96]=T.runAsGoal,e[97]=h,e[98]=u,e[99]=n,e[100]=Je):Je=e[100];let Ve;e[101]!==o?(Ve=()=>o(!1),e[101]=o,e[102]=Ve):Ve=e[102];let Ye;e[103]!==n?(Ye=n("rightSidebar.contextNotesTodo.sendDialog.actions.cancel"),e[103]=n,e[104]=Ye):Ye=e[104];let Qe;e[105]!==u||e[106]!==Ve||e[107]!==Ye?(Qe=t.jsx(ve,{variant:"ghost",size:"sm",onClick:Ve,disabled:u,children:Ye}),e[105]=u,e[106]=Ve,e[107]=Ye,e[108]=Qe):Qe=e[108];const st=!O||u;let qe;e[109]!==u||e[110]!==n?(qe=n(u?"rightSidebar.contextNotesTodo.sendDialog.actions.sending":"rightSidebar.contextNotesTodo.sendDialog.actions.send"),e[109]=u,e[110]=n,e[111]=qe):qe=e[111];let Xe;e[112]!==z||e[113]!==st||e[114]!==qe?(Xe=t.jsx(ve,{size:"sm",onClick:z,disabled:st,children:qe}),e[112]=z,e[113]=st,e[114]=qe,e[115]=Xe):Xe=e[115];let ot;e[116]!==Qe||e[117]!==Xe?(ot=t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[Qe,Xe]}),e[116]=Qe,e[117]=Xe,e[118]=ot):ot=e[118];let Ze;e[119]!==Ge||e[120]!==Je||e[121]!==ot?(Ze=t.jsxs("div",{className:Ge,children:[Je,ot]}),e[119]=Ge,e[120]=Je,e[121]=ot,e[122]=Ze):Ze=e[122];let Ne;e[123]!==de||e[124]!==Le||e[125]!==Ze?(Ne=t.jsxs(Rs,{className:"max-w-md overflow-visible",children:[de,Le,Ze]}),e[123]=de,e[124]=Le,e[125]=Ze,e[126]=Ne):Ne=e[126];let ze;return e[127]!==r||e[128]!==je||e[129]!==Ne?(ze=t.jsx(Es,{open:r,onOpenChange:je,children:Ne}),e[127]=r,e[128]=je,e[129]=Ne,e[130]=ze):ze=e[130],ze}function ql(s){return{...s,runAsGoal:s.runAsGoal!==!0}}function Jl(s){return{...s,variant:""}}function Yl(s){return Go(s.mode)}function Ql(s){return s.currentAgentName||""}function Xl(s){return s.currentVariant||""}function Zl(s){return s.currentModelId}function ec(s){return s.currentProviderId}function tc(s){return s.providers}function sc(s){return s.loadAgents}function nc(s){return s.loadAgents}function rc(s){return s.loadProviders}function oc(s){const e=_e.c(4);let n;e[0]!==s?({...n}=s,e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=t.jsx(Qi,{...n}),e[2]=n,e[3]=r):r=e[3],r}function ac(s){const e=_e.c(4);let n;e[0]!==s?({...n}=s,e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=t.jsx(Xi,{...n}),e[2]=n,e[3]=r):r=e[3],r}function ic(s){const e=_e.c(22);let n,r,o,a,i,d;if(e[0]!==s){const{className:x,positionerClassName:g,children:j,style:p,onKeyDown:S,...M}=s;r=x,o=g,n=j,i=p,a=M,d=R=>{S?.(R),Jo(R,F=>{R.currentTarget.dispatchEvent(new KeyboardEvent("keydown",{key:F,bubbles:!0,cancelable:!0}))})},e[0]=s,e[1]=n,e[2]=r,e[3]=o,e[4]=a,e[5]=i,e[6]=d}else n=e[1],r=e[2],o=e[3],a=e[4],i=e[5],d=e[6];const l=d;let m;e[7]!==o?(m=re("app-region-no-drag z-50",o),e[7]=o,e[8]=m):m=e[8];let u;e[9]!==i?(u={color:"var(--surface-elevated-foreground)",...i},e[9]=i,e[10]=u):u=e[10];let f;e[11]!==r?(f=re(Ho,r),e[11]=r,e[12]=f):f=e[12];let b;e[13]!==n||e[14]!==l||e[15]!==a||e[16]!==u||e[17]!==f?(b=t.jsx(Zi,{"data-slot":"dropdown-menu-content",style:u,className:f,...a,onKeyDown:l,children:n}),e[13]=n,e[14]=l,e[15]=a,e[16]=u,e[17]=f,e[18]=b):b=e[18];let h;return e[19]!==m||e[20]!==b?(h=t.jsx(sl,{children:t.jsx(nl,{className:m,children:b})}),e[19]=m,e[20]=b,e[21]=h):h=e[21],h}function of(s){const e=_e.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=re(Ko,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(el,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}function af(s){const e=_e.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=re(qo,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(tl,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}const lc=280,or=4,cc=({transform:s})=>({...s,y:0}),dc=s=>{const e=_e.c(18),{id:n,children:r,className:o}=s;let a;e[0]!==n?(a={id:n},e[0]=n,e[1]=a):a=e[1];const{attributes:i,listeners:d,setNodeRef:l,transform:m,transition:u,isDragging:f}=so(a);let b;e[2]!==m?(b=ro.Transform.toString(m),e[2]=m,e[3]=b):b=e[3];let h;e[4]!==b||e[5]!==u?(h={transform:b,transition:u},e[4]=b,e[5]=u,e[6]=h):h=e[6];const x=f&&"opacity-50";let g;e[7]!==o||e[8]!==x?(g=re("h-full rounded-md",o,x),e[7]=o,e[8]=x,e[9]=g):g=e[9];let j;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==d||e[14]!==l||e[15]!==h||e[16]!==g?(j=t.jsx("div",{ref:l,"data-sortable-tab-id":n,style:h,className:g,...i,...d,children:r}),e[10]=i,e[11]=r,e[12]=n,e[13]=d,e[14]=l,e[15]=h,e[16]=g,e[17]=j):j=e[17],j},uc=s=>{const e=_e.c(6),{id:n,children:r,className:o}=s;let a;e[0]!==o?(a=re("h-full",o),e[0]=o,e[1]=a):a=e[1];let i;return e[2]!==r||e[3]!==n||e[4]!==a?(i=t.jsx("div",{className:a,"data-sortable-tab-id":n,children:r}),e[2]=r,e[3]=n,e[4]=a,e[5]=i):i=e[5],i},Ds=s=>{const e=_e.c(137),{items:n,activeId:r,onSelect:o,onClose:a,onReorder:i,layoutMode:d,variant:l,activePillInsetClassName:m,activePillButtonClassName:u,inactiveTabsIconOnly:f,animateActivePill:b,activePillLowercase:h,nonCompositedIndicator:x,tabContextMenu:g,className:j}=s,p=d===void 0?"scrollable":d,S=l===void 0?"default":l,M=f===void 0?!1:f,R=h===void 0?!0:h,F=x===void 0?!1:x,{t:U}=nt(),T=Ke(mc),{isTablet:w}=bs(),H=T||w,P=c.useRef(null);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N={left:!1,right:!1},e[0]=N):N=e[0];const[$,B]=c.useState(N);let G;e[1]!==n?(G=n.map(fc),e[1]=n,e[2]=G):G=e[2];const J=G,L=p==="scrollable",_=S==="default",se=S==="active-pill",V=se||S==="animated",ee=_,C=V||ee,W=se&&L,O=V,A=b??V,z=typeof i=="function",v=z?dc:uc;let Z;e[3]===Symbol.for("react.memo_cache_sentinel")?(Z=new Map,e[3]=Z):Z=e[3];const X=c.useRef(Z),[ie,je]=c.useState(null),[de,Re]=c.useState(!1),[le,me]=c.useState(null),Te=c.useRef(!1),k=c.useRef(0),Y=c.useRef(r),q=c.useRef(null);let ce;e:{if(!C||!le||!r||le===r){ce=0;break e}const We=n.findIndex(Be=>Be.id===le),fe=n.findIndex(Be=>Be.id===r);if(We<0||fe<0){ce=0;break e}ce=We>fe?or:-or}const pe=ce;let Q;e[4]===Symbol.for("react.memo_cache_sentinel")?(Q={activationConstraint:{distance:8}},e[4]=Q):Q=e[4];const ue=Qr(Xr(Zr,Q)),Ee=hc;let Pe;e[5]===Symbol.for("react.memo_cache_sentinel")?(Pe=(We,fe)=>{if(fe){X.current.set(We,fe);return}X.current.delete(We)},e[5]=Pe):Pe=e[5];const he=Pe;let Ie;e[6]!==r||e[7]!==C?(Ie=()=>{if(!C||!r){je(pc);return}const We=P.current,fe=X.current.get(r);if(!We||!fe){je(gc);return}let Be=0,tt=0,ht=fe;for(;ht&&ht!==We;)Be=Be+ht.offsetLeft,tt=tt+ht.offsetTop,ht=ht.offsetParent;const It={left:Be,top:tt,width:fe.offsetWidth,height:fe.offsetHeight};je(D=>Ee(D,It)?D:It)},e[6]=r,e[7]=C,e[8]=Ie):Ie=e[8];const ke=Ie;let Le;e[9]!==L?(Le=()=>{if(!L){B({left:!1,right:!1});return}const We=P.current;if(!We){B({left:!1,right:!1});return}B({left:We.scrollLeft>2,right:We.scrollLeft+We.clientWidth<We.scrollWidth-2})},e[9]=L,e[10]=Le):Le=e[10];const Ge=Le;let Je;e[11]!==L||e[12]!==Ge?(Je=()=>{if(!L){B({left:!1,right:!1});return}const We=P.current;if(!We)return;Ge(),We.addEventListener("scroll",Ge,{passive:!0});const fe=new ResizeObserver(Ge);return fe.observe(We),()=>{We.removeEventListener("scroll",Ge),fe.disconnect()}},e[11]=L,e[12]=Ge,e[13]=Je):Je=e[13];let Ve;e[14]!==L||e[15]!==n.length||e[16]!==Ge?(Ve=[L,n.length,Ge],e[14]=L,e[15]=n.length,e[16]=Ge,e[17]=Ve):Ve=e[17],c.useEffect(Je,Ve);let Ye;e[18]!==r||e[19]!==ke||e[20]!==C?(Ye=()=>{if(!C){je(null);return}ke();const We=P.current;if(!We)return;const fe=new ResizeObserver(()=>{performance.now()-k.current>lc&&Re(!1),ke()});if(fe.observe(We),r){const Be=X.current.get(r);Be&&fe.observe(Be)}return()=>{fe.disconnect()}},e[18]=r,e[19]=ke,e[20]=C,e[21]=Ye):Ye=e[21];let Qe;e[22]!==r||e[23]!==n.length||e[24]!==ke||e[25]!==C?(Qe=[r,n.length,ke,C],e[22]=r,e[23]=n.length,e[24]=ke,e[25]=C,e[26]=Qe):Qe=e[26],c.useEffect(Ye,Qe);let st;e[27]!==ke?(st=()=>{ke()},e[27]=ke,e[28]=st):st=e[28],c.useLayoutEffect(st);let qe;e[29]!==J?(qe=J.join("\0"),e[29]=J,e[30]=qe):qe=e[30];const Xe=qe;let ot,Ze;e[31]!==r||e[32]!==Xe||e[33]!==C?(ot=()=>{if(!C){Te.current=!1,Re(!1);return}const We=q.current!==Xe;if(q.current=Xe,!Te.current){Te.current=!0,Y.current=r;return}const fe=Y.current!==r;if(Y.current=r,!fe||We){Re(!1);return}k.current=performance.now(),Re(!0)},Ze=[r,Xe,C],e[31]=r,e[32]=Xe,e[33]=C,e[34]=ot,e[35]=Ze):(ot=e[34],Ze=e[35]),c.useLayoutEffect(ot,Ze);let Ne;e[36]!==r||e[37]!==L||e[38]!==Ge?(Ne=()=>{if(!L||!r)return;const We=P.current;if(!We)return;const fe=window.requestAnimationFrame(()=>{const Be=typeof window.CSS?.escape=="function"?window.CSS.escape(r):r.replace(/"/g,'\\"'),tt=We.querySelector(`[data-sortable-tab-id="${Be}"]`);tt&&(tt.scrollIntoView({block:"nearest",inline:"nearest"}),Ge())});return()=>{window.cancelAnimationFrame(fe)}},e[36]=r,e[37]=L,e[38]=Ge,e[39]=Ne):Ne=e[39];let ze;e[40]!==r||e[41]!==L||e[42]!==n.length||e[43]!==Ge?(ze=[r,L,n.length,Ge],e[40]=r,e[41]=L,e[42]=n.length,e[43]=Ge,e[44]=ze):ze=e[44],c.useEffect(Ne,ze);let $e;e[45]!==i?($e=We=>{if(!i)return;const{active:fe,over:Be}=We;!Be||fe.id===Be.id||i(String(fe.id),String(Be.id))},e[45]=i,e[46]=$e):$e=e[46];const He=$e;let at;e[47]!==j?(at=re("relative flex h-full min-w-0 flex-1",j),e[47]=j,e[48]=at):at=e[48];let xe;e[49]!==L||e[50]!==$||e[51]!==V?(xe=L&&$.left?t.jsx("div",{className:re("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",V?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[49]=L,e[50]=$,e[51]=V,e[52]=xe):xe=e[52];let et;e[53]!==L||e[54]!==$||e[55]!==V?(et=L&&$.right?t.jsx("div",{className:re("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",V?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[53]=L,e[54]=$,e[55]=V,e[56]=et):et=e[56];const pt=V?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",gt=V&&"@container/pill-tabs",yt=V&&"pill-tabs__track",Dt=V&&(m??"gap-0.5 py-0.5"),y=ee&&"items-center overflow-y-hidden",K=O&&"rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_4%,transparent)] p-0.5 gap-0.5",Ae=L?"overflow-x-auto scrollbar-none":"overflow-x-hidden";let Ue;e[57]!==pt||e[58]!==gt||e[59]!==yt||e[60]!==Dt||e[61]!==y||e[62]!==K||e[63]!==Ae?(Ue=re("relative flex h-full min-w-0 flex-1",pt,gt,yt,Dt,y,K,Ae),e[57]=pt,e[58]=gt,e[59]=yt,e[60]=Dt,e[61]=y,e[62]=K,e[63]=Ae,e[64]=Ue):Ue=e[64];let I;e[65]!==L?(I=L?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,e[65]=L,e[66]=I):I=e[66];let oe;e[67]!==U?(oe=U("sortableTabsStrip.aria.tabs"),e[67]=U,e[68]=oe):oe=e[68];let ye;e[69]!==F||e[70]!==pe||e[71]!==ie||e[72]!==de||e[73]!==A||e[74]!==V?(ye=V&&ie?t.jsx("div",{className:re("pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[var(--surface-elevated)]","border border-[color-mix(in_srgb,var(--foreground)_7%,transparent)]","shadow-[0_1px_2px_color-mix(in_srgb,var(--foreground)_10%,transparent),0_2px_6px_color-mix(in_srgb,var(--foreground)_6%,transparent)]",A&&de&&(F?"pill-tabs__indicator--is-animated-layout":"pill-tabs__indicator--is-animated")),style:F?{left:`${ie.left+pe}px`,top:`${ie.top}px`,width:`${ie.width}px`,height:`${ie.height}px`}:{transform:`translate3d(${ie.left+pe}px, ${ie.top}px, 0)`,width:`${ie.width}px`,height:`${ie.height}px`}}):null,e[69]=F,e[70]=pe,e[71]=ie,e[72]=de,e[73]=A,e[74]=V,e[75]=ye):ye=e[75];let Se;e[76]!==pe||e[77]!==ie||e[78]!==de||e[79]!==ee?(Se=ee&&ie?t.jsx("div",{className:re("pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",de&&"underline-tabs__indicator--is-animated"),style:{transform:`translate3d(${ie.left+pe}px, 0, 0)`,width:`${ie.width}px`},"aria-hidden":!0}):null,e[76]=pe,e[77]=ie,e[78]=de,e[79]=ee,e[80]=Se):Se=e[80];let Ce;if(e[81]!==v||e[82]!==r||e[83]!==u||e[84]!==R||e[85]!==H||e[86]!==M||e[87]!==se||e[88]!==T||e[89]!==L||e[90]!==J||e[91]!==n||e[92]!==a||e[93]!==o||e[94]!==g||e[95]!==W||e[96]!==V||e[97]!==C){let We;e[99]!==v||e[100]!==r||e[101]!==u||e[102]!==R||e[103]!==H||e[104]!==M||e[105]!==se||e[106]!==T||e[107]!==L||e[108]!==J||e[109]!==a||e[110]!==o||e[111]!==g||e[112]!==W||e[113]!==V||e[114]!==C?(We=(fe,Be)=>{const tt=fe.id===r,ht=M&&V&&!tt&&!!fe.icon,It=!ht,D=!!fe.icon,te=M&&V&&tt&&!L&&!W,we=fe.closable!==!1&&!!a,Oe=we&&!!fe.icon,Me=L||W?void 0:V?te?"flex-none basis-auto":T?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",De=we?dt=>{dt.button===1&&(dt.preventDefault(),dt.stopPropagation(),a?.(fe.id))}:void 0,lt=we?xc:void 0,ft=!T&&g?g({id:fe.id,index:Be,isActive:tt,allIds:J,close:()=>a?.(fe.id)}):null,Pt=t.jsxs("div",{ref:dt=>he(fe.id,dt),onAuxClick:De,onMouseDown:lt,className:re("group flex h-full min-w-0 flex-nowrap items-center",L||W?"shrink-0":V?"w-full":"w-full min-w-0",V?"relative z-10 bg-transparent":tt?"relative z-10 bg-transparent text-foreground":"relative z-10 bg-transparent text-muted-foreground hover:text-foreground"),children:[t.jsx("button",{type:"button",role:"tab","aria-selected":tt,"aria-label":ht?fe.title??fe.label:void 0,onClick:()=>o(fe.id),onPointerDown:C?()=>{Re(!0),me(fe.id)}:void 0,onPointerUp:C?()=>me(null):void 0,onPointerLeave:C?()=>me(null):void 0,onPointerCancel:C?()=>me(null):void 0,className:re(V?"animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0":"flex h-full min-w-0 flex-nowrap items-center typography-micro",V&&R?"lowercase":null,V&&(ht?"gap-0":"gap-1.5"),V?W?"shrink-0 whitespace-nowrap px-3 text-center":L?"max-w-56 shrink-0 px-3 text-center":ht?"px-2 !min-w-0 text-center":te?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":L?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",V?u??(se?T?"h-[38px]":"h-[31px]":"h-7"):null,V?tt?"text-foreground":"text-muted-foreground hover:text-foreground":null,V?"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background":null),title:fe.title??fe.label,children:V?t.jsxs(t.Fragment,{children:[D?t.jsxs("span",{className:"relative flex h-4 w-4 shrink-0 items-center justify-center",children:[t.jsx("span",{className:re("flex items-center justify-center transition-opacity",Oe&&(H?"opacity-0":"group-hover:opacity-0")),children:fe.icon}),Oe?t.jsx("span",{role:"button",tabIndex:-1,className:re("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",H?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:bc,onClick:dt=>{dt.stopPropagation(),a?.(fe.id)},"aria-label":fe.closeLabel??`Close ${fe.label} tab`,title:fe.closeLabel??`Close ${fe.label} tab`,children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,It?t.jsx("span",{className:"animated-tabs__label truncate",children:fe.label}):null]}):t.jsxs("span",{className:re("flex min-w-0 flex-nowrap items-center gap-1.5",!L&&"justify-center"),children:[D?t.jsxs("span",{className:re("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",tt?"text-[var(--primary-base)]":"text-muted-foreground"),children:[t.jsx("span",{className:re("flex items-center justify-center transition-opacity",Oe&&(H?"opacity-0":"group-hover:opacity-0")),children:fe.icon}),Oe?t.jsx("span",{role:"button",tabIndex:-1,className:re("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",H?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:yc,onClick:dt=>{dt.stopPropagation(),a?.(fe.id)},"aria-label":fe.closeLabel??`Close ${fe.label} tab`,title:fe.closeLabel??`Close ${fe.label} tab`,children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,t.jsx("span",{className:"truncate leading-[1.2]",children:fe.label})]})}),we&&!Oe?t.jsx("button",{type:"button",onPointerDown:wc,onClick:dt=>{dt.stopPropagation(),a?.(fe.id)},className:re("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",V?"-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md":"aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1",V?tt?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":tt?"text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100"),"aria-label":fe.closeLabel??`Close ${fe.label} tab`,title:fe.closeLabel??`Close ${fe.label} tab`,children:t.jsx(E,{name:"close",className:"h-3 w-3"})}):null]});return t.jsx(v,{id:fe.id,className:Me,children:ft?t.jsxs(oc,{children:[t.jsx(ac,{render:dt=>t.jsx("div",{...dt,className:re("flex h-full min-w-0",dt.className),children:Pt})}),t.jsx(ic,{className:"w-52",children:ft})]}):Pt},fe.id)},e[99]=v,e[100]=r,e[101]=u,e[102]=R,e[103]=H,e[104]=M,e[105]=se,e[106]=T,e[107]=L,e[108]=J,e[109]=a,e[110]=o,e[111]=g,e[112]=W,e[113]=V,e[114]=C,e[115]=We):We=e[115],Ce=n.map(We),e[81]=v,e[82]=r,e[83]=u,e[84]=R,e[85]=H,e[86]=M,e[87]=se,e[88]=T,e[89]=L,e[90]=J,e[91]=n,e[92]=a,e[93]=o,e[94]=g,e[95]=W,e[96]=V,e[97]=C,e[98]=Ce}else Ce=e[98];let Fe;e[116]!==Ue||e[117]!==I||e[118]!==oe||e[119]!==ye||e[120]!==Se||e[121]!==Ce?(Fe=t.jsxs("div",{ref:P,className:Ue,style:I,role:"tablist","aria-label":oe,children:[ye,Se,Ce]}),e[116]=Ue,e[117]=I,e[118]=oe,e[119]=ye,e[120]=Se,e[121]=Ce,e[122]=Fe):Fe=e[122];let it;e[123]!==at||e[124]!==xe||e[125]!==et||e[126]!==Fe?(it=t.jsxs("div",{className:at,children:[xe,et,Fe]}),e[123]=at,e[124]=xe,e[125]=et,e[126]=Fe,e[127]=it):it=e[127];const ct=it;if(!z)return ct;let jt;e[128]===Symbol.for("react.memo_cache_sentinel")?(jt=[cc],e[128]=jt):jt=e[128];let vt;e[129]!==J||e[130]!==ct?(vt=t.jsx(no,{items:J,strategy:ll,children:ct}),e[129]=J,e[130]=ct,e[131]=vt):vt=e[131];let xt;e[132]===Symbol.for("react.memo_cache_sentinel")?(xt=t.jsx(il,{dropAnimation:null}),e[132]=xt):xt=e[132];let bt;return e[133]!==He||e[134]!==ue||e[135]!==vt?(bt=t.jsxs(eo,{sensors:ue,collisionDetection:to,onDragEnd:He,modifiers:jt,children:[vt,xt]}),e[133]=He,e[134]=ue,e[135]=vt,e[136]=bt):bt=e[136],bt};function mc(s){return s.isMobile}function fc(s){return s.id}function hc(s,e){return!s||!e?s===e:Math.abs(s.left-e.left)<.5&&Math.abs(s.top-e.top)<.5&&Math.abs(s.width-e.width)<.5&&Math.abs(s.height-e.height)<.5}function pc(s){return s===null?s:null}function gc(s){return s===null?s:null}function xc(s){s.button===1&&s.preventDefault()}function bc(s){s.stopPropagation()}function yc(s){s.stopPropagation()}function wc(s){s.stopPropagation()}const Qt=Fn()(rl(ol((s,e)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:n=>{s({selectedProfileId:n})},loadProfiles:async()=>{s({isLoading:!0});const n=e().profiles;try{const r=await ta();return s({profiles:r,isLoading:!1}),!0}catch(r){return console.error("Failed to load git identity profiles:",r),s({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{const n=await ea();if(n&&n.userName&&n.userEmail){const r={id:"global",name:"Global Identity",userName:n.userName,userEmail:n.userEmail,authType:n.sshCommand?"ssh":void 0,sshKey:n.sshCommand?n.sshCommand.replace("ssh -i ",""):null,color:"info",icon:"fingerprint"};s({globalIdentity:r})}else s({globalIdentity:null});return!0}catch(n){return console.error("Failed to load global git identity:",n),s({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{const n=await Zo();return s({discoveredCredentials:n}),!0}catch(n){return console.error("Failed to discover git credentials:",n),s({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{try{const r=(await Ri())?.defaultGitIdentityId?.trim()||null;return s({defaultGitIdentityId:r}),!0}catch(n){return console.error("Failed to load default git identity setting:",n),!1}},setDefaultGitIdentityId:async n=>{try{const r=typeof n=="string"?n.trim():"",o=r.length>0?r:"";return await Hr({defaultGitIdentityId:o}),s({defaultGitIdentityId:o.length>0?o:null}),!0}catch(r){return console.error("Failed to save default git identity setting:",r),!1}},createProfile:async n=>{try{const r={...n,id:n.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:n.color||"keyword",icon:n.icon||"branch"};return Wt("saving"),await Xo(r),Wt("saved"),await e().loadProfiles(),!0}catch(r){return Wt("error"),console.error("Failed to create git identity profile:",r),!1}},updateProfile:async(n,r)=>{try{const o=e().profiles.find(i=>i.id===n);if(!o)throw new Error("Profile not found");const a={...o,...r};return Wt("saving"),await Qo(n,a),Wt("saved"),await e().loadProfiles(),!0}catch(o){return Wt("error"),console.error("Failed to update git identity profile:",o),!1}},deleteProfile:async n=>{try{return Wt("saving"),await Yo(n),Wt("saved"),e().selectedProfileId===n&&s({selectedProfileId:null}),await e().loadProfiles(),!0}catch(r){return Wt("error"),console.error("Failed to delete git identity profile:",r),!1}},getProfileById:n=>{const{profiles:r,globalIdentity:o}=e();return n==="global"?o||void 0:r.find(a=>a.id===n)},getUnimportedCredentials:()=>{const{profiles:n,discoveredCredentials:r}=e();return r.filter(o=>!n.some(a=>a.authType==="token"&&a.host===o.host))}}),{name:"git-identities-store",storage:Ei(),partialize:s=>({selectedProfileId:s.selectedProfileId})}),{name:"git-identities-store"}));typeof window<"u"&&(window.__zustand_git_identities_store__=Qt);const Ps=sa,Ft=s=>{const e=_e.c(11),{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:d,children:l,className:m,contentClassName:u,divider:f}=s,b=f===void 0?!0:f;let h;return e[0]!==l||e[1]!==m||e[2]!==u||e[3]!==r||e[4]!==b||e[5]!==d||e[6]!==o||e[7]!==a||e[8]!==n||e[9]!==i?(h=t.jsx(na,{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:d,divider:b,className:m,contentClassName:u,children:l}),e[0]=l,e[1]=m,e[2]=u,e[3]=r,e[4]=b,e[5]=d,e[6]=o,e[7]=a,e[8]=n,e[9]=i,e[10]=h):h=e[10],h},vc=450,jc=({projectRef:s=null,sections:e="all"})=>{const{t:n}=nt(),{isMobile:r,isTablet:o}=bs(),a=r||o,i=Et(Q=>Q.getActiveProject()),d=s?.path??i?.path??null,l=ut(Q=>Q.getWorktreeMetadata),m=ra(),u=ys(Q=>Q.homeDirectory),[f,b]=c.useState([]),[h,x]=c.useState([]),[g,j]=c.useState(""),[p,S]=c.useState(!1),[M,R]=c.useState(!1),[F,U]=c.useState(!1),[T,w]=c.useState(!1),[H,P]=c.useState(0),[N,$]=c.useState(!1),[B,G]=c.useState(!1),[J,L]=c.useState(null),[_,se]=c.useState(null),[ne,V]=c.useState([]),[ee,C]=c.useState(!1),W=c.useRef(!1),O=c.useMemo(()=>s?.id&&s?.path?{id:s.id,path:s.path}:!i?.id||!d?null:{id:i.id,path:d},[i?.id,d,s?.id,s?.path]),A=c.useCallback(async()=>{if(!(!O||_===!1))try{const Q=await _n(O);V(Q)}catch{}},[O,_]);c.useEffect(()=>{if(!d)return;let Q=!1;return se(null),(async()=>{try{const ue=await oa(d);if(Q)return;se(ue)}catch{}})(),()=>{Q=!0}},[d]),c.useEffect(()=>{if(!O){V([]),C(!1);return}if(_===!1){V([]),C(!1);return}let Q=!1;return C(!0),V([]),(async()=>{try{const ue=await _n(O);if(Q)return;V(ue)}catch{}finally{Q||C(!1)}})(),()=>{Q=!0}},[O,_]),c.useEffect(()=>{if(!O)return;let Q=!1;return G(!0),(async()=>{try{const ue=await Rn(O);if(!Q){const Ee=ue.personal.setupWorktree,Pe=Ee.length>0?Ee:[""];b(Pe),x(ue.shared.setupWorktree),j(ue.shared.path),S(ue.personal.setupWorktreeMode==="replace"),R(ue.trust.hash!==null&&ue.trust.trusted),L(JSON.stringify(Pe)),$(ue.setupWorktreeWait)}}catch{Q||(b([""]),x([]),L(JSON.stringify([""])),$(!1))}finally{Q||G(!1)}})(),()=>{Q=!0}},[O,H]);const z=c.useCallback(()=>P(Q=>Q+1),[]),v=c.useCallback(async Q=>{if(!O||T)return;const ue=f[Q]?.trim();if(ue){w(!0);try{if(!await Cs(O,{setupWorktree:[...h.filter(Pe=>Pe!==ue),ue]})){ge.error(n("settings.projects.shared.toast.shareFailed"));return}await sn(O,f.filter((Pe,he)=>he!==Q)),z()}finally{w(!1)}}},[T,O,z,f,h,n]),Z=c.useCallback(async Q=>{if(!(!O||T)){w(!0);try{if(!await Cs(O,{setupWorktree:h.filter(Ee=>Ee!==Q)})){ge.error(n("settings.projects.shared.toast.shareFailed"));return}await sn(O,[...f.filter(Ee=>Ee.trim().length>0),Q]),z()}finally{w(!1)}}},[T,O,z,f,h,n]),X=c.useCallback(async()=>{if(O){U(!0);try{await aa(O)&&R(!1)}finally{U(!1)}}},[O]),ie=c.useCallback(async Q=>{O&&(S(Q),await Ar(O,{setupWorktreeMode:Q?"replace":"append"})||(ge.error(n("settings.aiworker.worktrees.setup.toast.saveFailed")),S(!Q)))},[O,n]),je=c.useCallback(async Q=>{if(!O)return!1;const ue=Q.filter(Ee=>Ee.trim().length>0);try{return await sn(O,ue)?(L(JSON.stringify(Q)),!0):(ge.error(n("settings.aiworker.worktrees.setup.toast.saveFailed")),!1)}catch{return ge.error(n("settings.aiworker.worktrees.setup.toast.saveFailed")),!1}},[O,n]),de=c.useMemo(()=>J===null?!1:J!==JSON.stringify(f),[J,f]);c.useEffect(()=>{if(!de||B||W.current)return;const Q=window.setTimeout(()=>{W.current||(W.current=!0,(async()=>{try{await je(f)}finally{W.current=!1}})())},vc);return()=>{window.clearTimeout(Q)}},[de,B,je,f]);const Re=c.useCallback((Q,ue)=>{b(Ee=>{const Pe=[...Ee];return Pe[Q]=ue,Pe})},[]),le=c.useCallback(()=>{b(Q=>[...Q,""])},[]),me=c.useCallback(Q=>{b(ue=>{const Ee=ue.filter((Pe,he)=>he!==Q);return Ee.length>0?Ee:[""]})},[]),Te=c.useCallback(()=>{!de||W.current||(W.current=!0,(async()=>{try{await je(f)}finally{W.current=!1}})())},[de,je,f]),k=c.useCallback(Q=>{$(Q),O&&ia(O,Q)},[O]),Y=c.useCallback(Q=>{const ue=Ve=>Ve.replace(/\\/g,"/").replace(/\/+$/,""),Ee=ue(Q.path),Pe=m.filter(Ve=>{const Ye=l(Ve.id);if(Ye?.path&&ue(Ye.path)===Ee)return!0;const Qe=Ve.directory;return!!(Qe&&ue(Qe)===Ee)}),he=new Set(Pe.map(Ve=>Ve.id)),Ie=[...Xt.getState().activeSessions,...Xt.getState().archivedSessions],ke=Ve=>{const Ye=Ie.filter(st=>{const qe=st.parentID;return qe&&Ve.has(qe)});if(Ye.length===0)return[];const Qe=new Set(Ye.map(st=>st.id));return[...Ye,...ke(Qe)]},Le=ke(he),Ge=new Set,Je=[...Pe,...Le].filter(Ve=>Ge.has(Ve.id)?!1:(Ge.add(Ve.id),!0));la.requestDelete({sessions:Je,mode:"worktree",worktree:Q})},[m,l]),q=c.useMemo(()=>m.map(Q=>Q.id).join(","),[m]);c.useEffect(()=>{_&&d&&A()},[q,_,d,A]);const ce=t.jsxs(zs,{children:[n("settings.aiworker.worktrees.setup.tooltipPrefix")," ",t.jsx("code",{className:"font-mono text-xs bg-sidebar-accent/50 px-1 rounded",children:"$ROOT_PROJECT_PATH"})," ",n("settings.aiworker.worktrees.setup.tooltipSuffix")]}),pe=t.jsx(zs,{children:n("settings.aiworker.worktrees.list.tooltip")});return d?_===!1?t.jsx(Ft,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.aiworker.worktrees.state.gitOnly")})}):t.jsxs(t.Fragment,{children:[e==="all"?t.jsx(Ft,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",titleAccessory:ce,children:B?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.aiworker.worktrees.setup.loading")}):t.jsxs("div",{className:re("space-y-2",Ps),children:[h.length>0?t.jsxs("div",{className:"space-y-1 pb-1",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.projects.shared.commandsFromRepo",{path:g})}),h.map((Q,ue)=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:re("min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",p&&"line-through opacity-60"),children:Q}),t.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:n("settings.projects.shared.badge")}),t.jsx(ve,{type:"button",variant:"ghost",size:"xs",className:"!font-normal shrink-0",disabled:T,title:n("settings.projects.shared.actions.makePersonalTitle"),onClick:()=>{Z(Q)},children:n("settings.projects.shared.actions.makePersonal")})]},`shared-${ue}`)),M?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-meta text-muted-foreground",children:n("settings.projects.shared.trusted")}),t.jsx(ve,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",disabled:F,onClick:()=>{X()},children:n("settings.projects.shared.resetTrust")})]}):null,t.jsxs("label",{"data-settings-item":"projects.worktree.setup.replace",className:"flex cursor-pointer items-center gap-2 py-1",children:[t.jsx(hs,{checked:p,onChange:Q=>{ie(Q)},ariaLabel:n("settings.projects.shared.replaceModeAria")}),t.jsx("span",{className:re("typography-ui-label font-normal",p?"text-foreground":"text-foreground/60"),children:n("settings.projects.shared.replaceMode")})]})]}):null,f.map((Q,ue)=>t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(Nt,{value:Q,onChange:Ee=>Re(ue,Ee.target.value),onBlur:Te,placeholder:n("settings.aiworker.worktrees.setup.commandPlaceholder"),className:"h-7 min-w-0 flex-1 font-mono text-xs"}),Q.trim()?t.jsx(ve,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-7 shrink-0",disabled:T||de,title:de?n("settings.projects.shared.actions.shareAfterSave"):n("settings.projects.shared.actions.shareTitle",{path:g||".aiworker/project.json"}),onClick:()=>{v(ue)},children:n("settings.projects.shared.actions.share")}):null,t.jsx(ve,{type:"button",variant:"ghost",size:"icon",onClick:()=>me(ue),className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive","aria-label":n("settings.aiworker.worktrees.setup.removeCommandAria"),children:t.jsx(E,{name:"close",className:"h-4 w-4"})})]},ue)),t.jsxs(ve,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:le,children:[t.jsx(E,{name:"add",className:"h-3.5 w-3.5"}),n("settings.aiworker.worktrees.setup.addCommand")]}),t.jsxs("label",{"data-settings-item":"projects.worktree.setup.wait",className:"flex cursor-pointer items-center gap-2 py-1",children:[t.jsx(hs,{checked:N,onChange:k,ariaLabel:n("settings.aiworker.worktrees.setup.waitForCommandsAria")}),t.jsx("span",{className:re("typography-ui-label font-normal",N?"text-foreground":"text-foreground/60"),children:n("settings.aiworker.worktrees.setup.waitForCommands")})]})]})}):null,t.jsx(Ft,{title:n("settings.aiworker.worktrees.list.title"),titleAccessory:pe,children:ee?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.aiworker.worktrees.list.loading")}):ne.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:n("settings.aiworker.worktrees.list.empty")}):t.jsx("div",{className:re("space-y-1",e==="all"&&Ps),children:ne.map(Q=>t.jsxs("div",{className:"group flex w-full items-center gap-2 py-1.5",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"flex min-w-0 items-center gap-2",children:t.jsx("p",{className:"typography-meta min-w-0 truncate text-foreground",children:Q.label||Q.branch||n("settings.aiworker.worktrees.list.detachedHead")})}),t.jsx("p",{className:"typography-micro truncate text-muted-foreground/60",children:ca(Q.path,u)})]}),t.jsx("button",{type:"button",onClick:()=>Y(Q),className:re("flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",a?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":n("settings.aiworker.worktrees.list.deleteWorktreeAria",{name:Q.branch||Q.label||Q.path}),children:t.jsx(E,{name:"delete-bin",className:"h-4 w-4"})})]},Q.path))})})]}):t.jsx(Ft,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.aiworker.worktrees.state.selectProject")})})},ar=(s,e)=>e.updatedAtMs-s.updatedAtMs,ir=Fn((s,e)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!e().isLoading){s({isLoading:!0,error:null});try{const[n,r]=await Promise.all([fa(),Hn()]),o={};for(const a of r.sort(ar))o[a.id]=a;e().listenerReady||await ha(a=>{s(i=>({statusesById:{...i.statusesById,[a.id]:a}}))}),s({instances:n.instances,statusesById:o,isLoading:!1,initialized:!0,listenerReady:!0})}catch(n){s({isLoading:!1,error:n instanceof Error?n.message:String(n)})}}},loadImports:async()=>{if(!e().isImportsLoading){s({isImportsLoading:!0,error:null});try{const n=await ma();s({importCandidates:n,isImportsLoading:!1})}catch(n){s({isImportsLoading:!1,error:n instanceof Error?n.message:String(n)})}}},refreshStatuses:async()=>{try{const n=await Hn(),r={};for(const o of n.sort(ar))r[o.id]=o;s({statusesById:r})}catch(n){s({error:n instanceof Error?n.message:String(n)})}},setInstances:async n=>{s({isSaving:!0,error:null});try{await ua({instances:n}),s({instances:n,isSaving:!1}),await e().refreshStatuses()}catch(r){throw s({isSaving:!1,error:r instanceof Error?r.message:String(r)}),r}},upsertInstance:async n=>{const r=e().instances,o=r.some(a=>a.id===n.id)?r.map(a=>a.id===n.id?n:a):[n,...r];await e().setInstances(o)},createFromCommand:async(n,r,o)=>{const a=pa(n,r);o&&o.trim()&&(a.nickname=o.trim()),await e().upsertInstance(a)},removeInstance:async n=>{await Gn(n).catch(()=>{});const r=e().instances.filter(o=>o.id!==n);await e().setInstances(r),s(o=>{const a={...o.statusesById};return delete a[n],{statusesById:a}})},connect:async n=>{s({error:null});try{await da(n),await e().refreshStatuses()}catch(r){throw s({error:r instanceof Error?r.message:String(r)}),r}},disconnect:async n=>{s({error:null});try{await Gn(n),await e().refreshStatuses()}catch(r){throw s({error:r instanceof Error?r.message:String(r)}),r}},retry:async n=>{await e().connect(n)},getStatus:n=>e().statusesById[n]||null,clearError:()=>s({error:null})})),On=[{key:"play",label:"Play",Icon:"play"},{key:"build",label:"Build",Icon:"hammer"},{key:"lint",label:"Lint",Icon:"checkbox-circle"},{key:"terminal",label:"Terminal",Icon:"terminal-box"},{key:"tools",label:"Tools",Icon:"tools"},{key:"bug",label:"Bug",Icon:"bug"},{key:"flask",label:"Flask",Icon:"flask"},{key:"rocket",label:"Rocket",Icon:"rocket"},{key:"code",label:"Code",Icon:"code"},{key:"server",label:"Server",Icon:"server"},{key:"branch",label:"Branch",Icon:"git-branch"},{key:"search",label:"Search",Icon:"search"},{key:"settings",label:"Settings",Icon:"settings-3"},{key:"brain",label:"Brain",Icon:"brain-ai-3"},{key:"stack",label:"Stack",Icon:"stack"},{key:"robot",label:"Robot",Icon:"robot-2"},{key:"command",label:"Command",Icon:"command"},{key:"file",label:"File",Icon:"file-text"}],lr=Object.fromEntries(On.map(s=>[s.key,s.Icon])),cr="aiworker:project-actions-updated",Sc=s=>{const e=(s||"").trim().replace(/\\/g,"/");return e?e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e:""},lf=(s,e)=>`${Sc(s)}::${e}`,Nc=s=>{const e=s.trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},dr=s=>{if(typeof s!="number"||!Number.isFinite(s))return null;const e=Math.round(s);return e<1||e>65535?null:e},kc=(s,e)=>{if(!e.enabled||e.type!=="local")return null;const n=dr(e.localPort),r=dr(e.remotePort);if(!n||!r)return null;const o=Nc(e.localHost||s.localForward.bindHost||"127.0.0.1"),a=(e.remoteHost||"127.0.0.1").trim(),i=(s.nickname||s.id||"instance").trim();return{id:`${s.id}::${e.id}`,label:`${i} - ${o}:${n} -> ${a}:${r}`,url:`http://${o}:${n}`}},co=s=>{const e=[];for(const n of s)if(!(!n?.id||!Array.isArray(n.portForwards)))for(const r of n.portForwards){const o=kc(n,r);o&&e.push(o)}return e},cf=(s,e)=>{const n=(s||"").trim();return n&&co(e).find(a=>a.id===n)?.url||null},Cc=450,ln="__project__",Ic=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`action_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,Tc=()=>({id:Ic(),name:"",command:"",icon:"play"}),Dc=({projectRef:s})=>{const{t:e}=nt(),n=c.useMemo(()=>Kr(),[]),r=ir(C=>C.instances),o=ir(C=>C.load),[a,i]=c.useState([]),[d,l]=c.useState([]),[m,u]=c.useState(null),[f,b]=c.useState([]),[h,x]=c.useState(!1),g=c.useRef(0),[j,p]=c.useState(0),[S,M]=c.useState(!1),[R,F]=c.useState(null),[U,T]=c.useState({}),w=c.useRef(!1),H=c.useRef(null);c.useEffect(()=>{n&&o().catch(()=>{})},[n,o]),c.useEffect(()=>{let C=!1;return M(!0),(async()=>{try{const W=await Rn(s);if(C)return;i(W.personal.projectActions),l(W.shared.projectActions),u({path:W.shared.path,status:W.shared.status,reason:W.shared.reason}),b(W.personal.hiddenSharedActionIds),F(JSON.stringify({actions:W.personal.projectActions}))}catch{if(C)return;i([]),l([]),u(null),b([]),F(JSON.stringify({actions:[]}))}finally{C||M(!1)}})(),()=>{C=!0}},[s,j]);const P=c.useCallback(()=>{g.current+=1,p(g.current)},[]),N=c.useCallback(()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent(cr,{detail:{projectId:s.id}}))},[s.id]),$=c.useCallback(async C=>{if(!h){x(!0);try{if(!await Cs(s,{projectActions:[...d.filter(O=>O.id!==C.id),C]})){ge.error(e("settings.projects.shared.toast.shareFailed"));return}await nn(s,{actions:a.filter(O=>O.id!==C.id),primaryActionId:null}),P(),N()}finally{x(!1)}}},[a,h,N,s,P,d,e]),B=c.useCallback(async C=>{if(!h){x(!0);try{if(!await Cs(s,{projectActions:d.filter(O=>O.id!==C.id)})){ge.error(e("settings.projects.shared.toast.shareFailed"));return}await nn(s,{actions:[...a.filter(O=>O.id!==C.id),C],primaryActionId:null}),P(),N()}finally{x(!1)}}},[a,h,N,s,P,d,e]),G=c.useCallback(async(C,W)=>{const O=W?[...f.filter(A=>A!==C),C]:f.filter(A=>A!==C);if(b(O),!await Ar(s,{hiddenSharedActionIds:O})){ge.error(e("settings.projects.actions.toast.saveFailed")),b(f);return}N()},[f,N,s,e]),J=c.useMemo(()=>n?co(r):[],[r,n]),L=c.useMemo(()=>a.some(W=>W.name.trim().length===0||W.command.trim().length===0)?e("settings.projects.actions.validation.fillNameAndCommand"):null,[a,e]),_=c.useMemo(()=>R===null?!1:R!==JSON.stringify({actions:a}),[a,R]),se=c.useCallback(async C=>await nn(s,{actions:C,primaryActionId:null})?(F(JSON.stringify({actions:C})),typeof window<"u"&&window.dispatchEvent(new CustomEvent(cr,{detail:{projectId:s.id}})),!0):(ge.error(e("settings.projects.actions.toast.saveFailed")),!1),[s,e]);c.useEffect(()=>{if(!_||S||L||w.current)return;const C=window.setTimeout(()=>{w.current||(w.current=!0,(async()=>{try{await se(a)}finally{w.current=!1}})())},Cc);return()=>{window.clearTimeout(C)}},[a,_,S,se,L]),c.useEffect(()=>{if(!_||!L||S){L||(H.current=null);return}const C=window.setTimeout(()=>{H.current!==L&&(H.current=L,ge.error(L))},1e3);return()=>{window.clearTimeout(C)}},[_,S,L]);const ne=c.useCallback(()=>{const C=Tc();i(W=>[...W,C]),T(W=>({...W,[C.id]:!0}))},[]),V=c.useCallback(C=>{i(W=>W.filter(O=>O.id!==C)),T(W=>{const O={...W};return delete O[C],O})},[]),ee=c.useCallback((C,W)=>{i(O=>O.map(A=>A.id===C?W(A):A))},[]);return t.jsxs(Ft,{title:e("settings.projects.actions.title"),info:e("settings.projects.actions.description"),settingsItem:"projects.actions",headerAction:t.jsxs(ve,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:ne,children:[t.jsx(E,{name:"add",className:"h-3.5 w-3.5"}),e("settings.projects.actions.actions.add")]}),contentClassName:"space-y-0",children:[!S&&m?.status==="invalid"?t.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:e("settings.projects.shared.invalid",{path:m.path,reason:m.reason??""})}):null,!S&&d.length>0&&m?t.jsxs("div",{className:re("space-y-0 pb-1.5",Ps),children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.shared.actionsFromRepo",{path:m.path})}),d.map(C=>{const W=C.icon||"play",O=lr[W]||"play",A=f.includes(C.id);return t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsx(E,{name:O,className:re("h-4 w-4 shrink-0 text-muted-foreground",A&&"opacity-50")}),t.jsx("span",{className:re("typography-ui-label truncate",A?"text-muted-foreground":"text-foreground"),children:C.name}),t.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:e(A?"settings.projects.shared.hiddenBadge":"settings.projects.shared.badge")}),t.jsx("span",{className:"min-w-0 flex-1 typography-meta font-mono text-muted-foreground truncate",children:C.command}),t.jsx(ve,{type:"button",variant:"ghost",size:"xs",className:"!font-normal shrink-0",disabled:h,title:e(A?"settings.projects.shared.actions.showTitle":"settings.projects.shared.actions.hideTitle"),onClick:()=>{G(C.id,!A)},children:e(A?"settings.projects.shared.actions.show":"settings.projects.shared.actions.hide")}),t.jsx(ve,{type:"button",variant:"ghost",size:"xs",className:"!font-normal shrink-0",disabled:h,title:e("settings.projects.shared.actions.makePersonalTitle"),onClick:()=>{B(C)},children:e("settings.projects.shared.actions.makePersonal")})]},C.id)})]}):null,S?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.loading")}):a.length===0&&d.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.empty")}):a.length===0?null:t.jsx("div",{className:re("space-y-0",Ps),children:a.map(C=>{const W=C.icon||"play",O=lr[W]||"play",A=U[C.id]??!1,z=C.name.trim()||e("settings.projects.actions.state.untitled");return t.jsxs(_l,{open:A,onOpenChange:v=>{T(Z=>({...Z,[C.id]:v}))},className:"py-1.5",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs(Gl,{className:"group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",children:[A?t.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):t.jsx(E,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),t.jsx(E,{name:O,className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:z})})]}),C.name.trim()&&C.command.trim()?t.jsx(ve,{type:"button",variant:"ghost",size:"xs",className:"!font-normal shrink-0",disabled:h||_,title:_?e("settings.projects.shared.actions.shareAfterSave"):e("settings.projects.shared.actions.shareTitle",{path:m?.path??".aiworker/project.json"}),onClick:()=>{$(C)},children:e("settings.projects.shared.actions.share")}):null,t.jsx(ve,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>V(C.id),children:t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(Hl,{className:"pt-1.5",children:t.jsxs("div",{className:"space-y-2 pb-4 pl-3 pr-1",children:[t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsxs(Ht,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]","aria-label":e("settings.projects.actions.field.selectIconAria"),children:t.jsx(E,{name:O,className:"h-4 w-4"})})}),t.jsx(qt,{align:"start",className:"w-56 p-2",children:t.jsx("div",{className:"grid grid-cols-6 gap-1",children:On.map(v=>{const Z=v.Icon,X=(C.icon||"play")===v.key;return t.jsx("button",{type:"button",onClick:()=>ee(C.id,ie=>({...ie,icon:v.key})),className:re("inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]",X&&"border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]"),"aria-label":e("settings.projects.actions.field.iconAria",{icon:v.label}),children:t.jsx(E,{name:Z,className:"h-4 w-4"})},v.key)})})})]}),t.jsx(Nt,{value:C.name,onChange:v=>ee(C.id,Z=>({...Z,name:v.target.value})),placeholder:e("settings.projects.actions.field.actionNamePlaceholder"),className:"h-7 flex-1 min-w-0"})]}),t.jsxs("div",{className:"py-1",children:[t.jsx("p",{className:"typography-meta mb-0.5 text-muted-foreground",children:e("settings.projects.actions.field.command")}),t.jsx(Qs,{value:C.command,onChange:v=>ee(C.id,Z=>({...Z,command:v.target.value})),placeholder:e("settings.projects.actions.field.commandPlaceholder"),className:"min-h-[88px] w-full font-mono text-xs"})]}),t.jsxs("div",{className:"py-1",children:[t.jsxs("div",{className:"mb-0.5 flex items-center gap-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.runIn.label")}),t.jsx(zs,{contentClassName:"max-w-xs",children:e("settings.projects.actions.runIn.info")})]}),t.jsxs(Us,{value:C.runIn==="parent"?ln:"worktree",onValueChange:v=>{ee(C.id,Z=>v===ln?{...Z,runIn:"parent"}:{...Z,runIn:void 0})},children:[t.jsx(_s,{size:xn,className:ga,"aria-label":e("settings.projects.actions.runIn.aria"),children:t.jsx(bn,{children:v=>e(v==="worktree"?"settings.projects.actions.runIn.worktree":"settings.projects.actions.runIn.project")})}),t.jsxs(Gs,{children:[t.jsx(Zt,{value:ln,children:e("settings.projects.actions.runIn.project")}),t.jsx(Zt,{value:"worktree",children:e("settings.projects.actions.runIn.worktree")})]})]})]}),t.jsxs("div",{className:"py-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:e("settings.projects.actions.field.autoOpenUrl")}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2",role:"button",tabIndex:0,"aria-pressed":C.autoOpenUrl===!0,onClick:()=>ee(C.id,v=>({...v,...v.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:v=>{(v.key===" "||v.key==="Enter")&&(v.preventDefault(),ee(C.id,Z=>({...Z,...Z.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[t.jsx(hs,{checked:C.autoOpenUrl===!0,onChange:v=>ee(C.id,Z=>({...Z,...v?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:e("settings.projects.actions.field.autoOpenUrlForAria",{title:z})}),t.jsx("span",{className:"typography-ui-label font-normal text-foreground/80",children:e("settings.projects.actions.field.autoOpenUrlDescription")})]})]}),C.autoOpenUrl===!0?t.jsxs("div",{className:"mt-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Nt,{value:C.openUrl||"",onChange:v=>ee(C.id,Z=>({...Z,openUrl:v.target.value})),placeholder:e("settings.projects.actions.field.overrideUrlPlaceholder"),className:"h-7 w-full max-w-[24rem]"}),t.jsx(zs,{contentClassName:"max-w-xs",children:e("settings.projects.actions.field.overrideUrlTooltip")})]}),n?t.jsxs("div",{className:"mt-2",children:[t.jsx("p",{className:"typography-meta mb-0.5 text-muted-foreground",children:e("settings.projects.actions.field.desktopSshForward")}),J.length>0?t.jsxs(Us,{value:C.desktopOpenSshForward&&J.some(v=>v.id===C.desktopOpenSshForward)?C.desktopOpenSshForward:"__none__",onValueChange:v=>{ee(C.id,Z=>({...Z,...v==="__none__"?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:v}}))},children:[t.jsx(_s,{size:xn,className:"w-full",children:t.jsx(bn,{placeholder:e("settings.projects.actions.field.useOutputManualUrl")})}),t.jsxs(Gs,{children:[t.jsx(Zt,{value:"__none__",children:e("settings.projects.actions.field.useOutputManualUrl")}),J.map(v=>t.jsx(Zt,{value:v.id,children:v.label},v.id))]})]}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.noDesktopSshForwards")})]}):null]}):null]})]})})]},C.id)})}),L&&a.length>0?t.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:L}):null]})},cn="__default__",uo=s=>s.charAt(0).toUpperCase()+s.slice(1),Pc=s=>{const e=_e.c(138),{form:n}=s,{t:r}=nt(),{currentTheme:o}=Mr(),a=Tt(Ec),{name:i,setName:d,icon:l,setIcon:m,color:u,setColor:f,iconBackground:b,setIconBackground:h,parsedDefaultModel:x,defaultVariant:g,handleDefaultModelChange:j,handleDefaultVariantChange:p,isUploadingIcon:S,isRemovingCustomIcon:M,isDiscoveringIcon:R,pendingRemoveImageIcon:F,setPendingRemoveImageIcon:U,pendingUploadIconPreviewUrl:T,setPreviewImageFailed:w,hasPendingUploadImageIcon:H,hasCustomIcon:P,effectiveHasImageIcon:N,hasRemovableImageIcon:$,showImagePreview:B,fileInputRef:G,handleUploadIcon:J,handleRemoveImageIcon:L,handleDiscoverIcon:_,currentIconImage:se,project:ne}=n;let V;e:{const{providerId:xe,modelId:et}=x;if(!xe||!et){let gt;e[0]===Symbol.for("react.memo_cache_sentinel")?(gt=[],e[0]=gt):gt=e[0],V=gt;break e}let pt;if(e[1]!==et||e[2]!==xe||e[3]!==a){const gt=a.find(yt=>yt.id===xe)?.models.find(yt=>yt.id===et);pt=xa(gt),e[1]=et,e[2]=xe,e[3]=a,e[4]=pt}else pt=e[4];V=pt}const ee=V;if(!ne)return null;const C=u?ba[u]??null:null;let W;e[5]!==r?(W=r("settings.projects.page.field.projectName"),e[5]=r,e[6]=W):W=e[6];let O;e[7]!==d?(O=xe=>d(xe.target.value),e[7]=d,e[8]=O):O=e[8];let A;e[9]!==r?(A=r("settings.projects.page.field.projectNamePlaceholder"),e[9]=r,e[10]=A):A=e[10];let z;e[11]===Symbol.for("react.memo_cache_sentinel")?(z=re("h-8 rounded-md px-3",Ps),e[11]=z):z=e[11];let v;e[12]!==i||e[13]!==O||e[14]!==A?(v=t.jsx(Nt,{value:i,onChange:O,placeholder:A,className:z}),e[12]=i,e[13]=O,e[14]=A,e[15]=v):v=e[15];let Z;e[16]!==W||e[17]!==v?(Z=t.jsx(Ft,{title:W,settingsItem:"projects.name",divider:!1,children:v}),e[16]=W,e[17]=v,e[18]=Z):Z=e[18];let X;e[19]!==r?(X=r("settings.projects.page.section.chatDefaults"),e[19]=r,e[20]=X):X=e[20];let ie;e[21]!==r?(ie=r("settings.projects.page.section.chatDefaultsDescription"),e[21]=r,e[22]=ie):ie=e[22];let je;e[23]!==r?(je=r("settings.projects.page.field.projectModel"),e[23]=r,e[24]=je):je=e[24];let de;e[25]!==j||e[26]!==x.modelId||e[27]!==x.providerId?(de=t.jsx(Rr,{providerId:x.providerId,modelId:x.modelId,onChange:j,className:ya}),e[25]=j,e[26]=x.modelId,e[27]=x.providerId,e[28]=de):de=e[28];let Re;e[29]!==je||e[30]!==de?(Re=t.jsx(Hs,{settingsItem:"projects.default-model",label:je,children:de}),e[29]=je,e[30]=de,e[31]=Re):Re=e[31];let le;e[32]!==ee||e[33]!==g||e[34]!==p||e[35]!==r?(le=ee.length>0?t.jsx(Hs,{settingsItem:"projects.default-thinking",label:r("settings.projects.page.field.projectThinking"),children:t.jsxs(Us,{value:g??cn,onValueChange:xe=>p(xe===cn?void 0:xe),children:[t.jsx(_s,{size:xn,className:wa,"aria-label":r("settings.projects.page.field.projectThinking"),children:t.jsx(bn,{children:g?uo(g):r("settings.projects.page.option.thinkingDefault")})}),t.jsxs(Gs,{children:[t.jsx(Zt,{value:cn,children:r("settings.projects.page.option.thinkingDefault")}),ee.map(Rc)]})]})}):null,e[32]=ee,e[33]=g,e[34]=p,e[35]=r,e[36]=le):le=e[36];let me;e[37]!==Re||e[38]!==le||e[39]!==X||e[40]!==ie?(me=t.jsxs(Ft,{title:X,info:ie,contentClassName:"space-y-0",children:[Re,le]}),e[37]=Re,e[38]=le,e[39]=X,e[40]=ie,e[41]=me):me=e[41];let Te;e[42]!==r?(Te=r("settings.projects.page.field.accentColor"),e[42]=r,e[43]=Te):Te=e[43];let k;e[44]!==f?(k=()=>f(null),e[44]=f,e[45]=k):k=e[45];const Y=u===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let q;e[46]!==Y?(q=re("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",Y),e[46]=Y,e[47]=q):q=e[47];let ce;e[48]!==r?(ce=r("settings.projects.page.field.none"),e[48]=r,e[49]=ce):ce=e[49];let pe;e[50]===Symbol.for("react.memo_cache_sentinel")?(pe=t.jsx(E,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[50]=pe):pe=e[50];let Q;e[51]!==k||e[52]!==q||e[53]!==ce?(Q=t.jsx("button",{type:"button",onClick:k,className:q,title:ce,children:pe}),e[51]=k,e[52]=q,e[53]=ce,e[54]=Q):Q=e[54];let ue;e[55]!==u||e[56]!==f?(ue=va.map(xe=>t.jsx("button",{type:"button",onClick:()=>f(xe.key),className:re("h-7 w-7 rounded-md border transition-colors",u===xe.key?"border-2 border-foreground ring-1 ring-[var(--primary-base)]/40":"border-transparent hover:border-border/70"),style:{backgroundColor:xe.cssVar},title:xe.label},xe.key)),e[55]=u,e[56]=f,e[57]=ue):ue=e[57];let Ee;e[58]!==Q||e[59]!==ue?(Ee=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Q,ue]}),e[58]=Q,e[59]=ue,e[60]=Ee):Ee=e[60];let Pe;e[61]!==Te||e[62]!==Ee?(Pe=t.jsx(Ft,{title:Te,settingsItem:"projects.accent-color",children:Ee}),e[61]=Te,e[62]=Ee,e[63]=Pe):Pe=e[63];let he;e[64]!==r?(he=r("settings.projects.page.field.projectIcon"),e[64]=r,e[65]=he):he=e[65];let Ie;e[66]!==J?(Ie=xe=>{const et=xe.target.files?.[0]??null;J(et),xe.currentTarget.value=""},e[66]=J,e[67]=Ie):Ie=e[67];let ke;e[68]!==G||e[69]!==Ie?(ke=t.jsx("input",{ref:G,type:"file",accept:"image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg",className:"hidden",onChange:Ie}),e[68]=G,e[69]=Ie,e[70]=ke):ke=e[70];let Le;e[71]!==m?(Le=()=>m(null),e[71]=m,e[72]=Le):Le=e[72];const Ge=l===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let Je;e[73]!==Ge?(Je=re("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",Ge),e[73]=Ge,e[74]=Je):Je=e[74];let Ve;e[75]!==r?(Ve=r("settings.projects.page.field.none"),e[75]=r,e[76]=Ve):Ve=e[76];let Ye;e[77]===Symbol.for("react.memo_cache_sentinel")?(Ye=t.jsx(E,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[77]=Ye):Ye=e[77];let Qe;e[78]!==Le||e[79]!==Je||e[80]!==Ve?(Qe=t.jsx("button",{type:"button",onClick:Le,className:Je,title:Ve,children:Ye}),e[78]=Le,e[79]=Je,e[80]=Ve,e[81]=Qe):Qe=e[81];let st;e[82]!==C||e[83]!==l||e[84]!==m?(st=ja.map(xe=>{const et=xe.Icon;return t.jsx("button",{type:"button",onClick:()=>m(xe.key),className:re("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",l===xe.key?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-transparent hover:border-border hover:bg-[var(--surface-muted)]"),title:xe.label,children:t.jsx(E,{name:et,className:"w-4 h-4",style:C&&l===xe.key?{color:C}:void 0})},xe.key)}),e[82]=C,e[83]=l,e[84]=m,e[85]=st):st=e[85];let qe;e[86]!==Qe||e[87]!==st?(qe=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Qe,st]}),e[86]=Qe,e[87]=st,e[88]=qe):qe=e[88];let Xe;e[89]!==se||e[90]!==o||e[91]!==N||e[92]!==H||e[93]!==b||e[94]!==T||e[95]!==ne||e[96]!==w||e[97]!==B||e[98]!==r?(Xe=N&&B&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-meta text-muted-foreground",children:r("settings.projects.page.field.preview")}),t.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1",children:t.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:b?{backgroundColor:b}:void 0,children:H&&T?t.jsx("img",{src:T,alt:"",className:"h-full w-full object-contain",draggable:!1,onError:()=>w(!0)}):t.jsx(Sa,{project:{...ne,iconImage:se??ne.iconImage},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"h-full w-full object-contain",onError:()=>w(!0)})})})]}),e[89]=se,e[90]=o,e[91]=N,e[92]=H,e[93]=b,e[94]=T,e[95]=ne,e[96]=w,e[97]=B,e[98]=r,e[99]=Xe):Xe=e[99];let ot;e[100]!==N||e[101]!==b||e[102]!==h||e[103]!==r?(ot=N&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("input",{type:"color",value:b??"#000000",onChange:xe=>h(xe.target.value),className:"h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1","aria-label":r("settings.projects.page.field.projectIconBackgroundAria")}),t.jsx(Nt,{value:b??"",onChange:xe=>h(xe.target.value),placeholder:"#000000",className:"h-7 w-[8rem]"}),t.jsx(ve,{type:"button",size:"xs",variant:"outline",onClick:()=>h(null),className:"h-7 w-7 p-0","aria-label":r("settings.projects.page.field.clearIconBackgroundAria"),title:r("settings.projects.page.field.clearBackground"),disabled:!b,children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),e[100]=N,e[101]=b,e[102]=h,e[103]=r,e[104]=ot):ot=e[104];let Ze;e[105]!==G||e[106]!==_||e[107]!==P||e[108]!==R||e[109]!==S||e[110]!==r?(Ze=!P&&t.jsxs(t.Fragment,{children:[t.jsx(ve,{size:"xs",className:"h-6 !font-normal",onClick:()=>G.current?.click(),disabled:S,children:r(S?"settings.projects.page.actions.uploading":"settings.projects.page.actions.uploadIcon")}),t.jsx(ve,{size:"xs",className:"h-6 !font-normal",variant:"outline",onClick:()=>{_()},disabled:R,children:r(R?"settings.projects.page.actions.discovering":"settings.projects.page.actions.discoverFavicon")})]}),e[105]=G,e[106]=_,e[107]=P,e[108]=R,e[109]=S,e[110]=r,e[111]=Ze):Ze=e[111];let Ne;e[112]!==L||e[113]!==$||e[114]!==M||e[115]!==r?(Ne=$&&t.jsx(ve,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>{L()},disabled:M,children:r(M?"settings.projects.page.actions.removing":"settings.projects.page.actions.removeProjectIcon")}),e[112]=L,e[113]=$,e[114]=M,e[115]=r,e[116]=Ne):Ne=e[116];let ze;e[117]!==M||e[118]!==F||e[119]!==U||e[120]!==r?(ze=F&&t.jsx(ve,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>U(!1),disabled:M,children:r("settings.projects.page.actions.undoRemove")}),e[117]=M,e[118]=F,e[119]=U,e[120]=r,e[121]=ze):ze=e[121];let $e;e[122]!==Ze||e[123]!==Ne||e[124]!==ze?($e=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Ze,Ne,ze]}),e[122]=Ze,e[123]=Ne,e[124]=ze,e[125]=$e):$e=e[125];let He;e[126]!==he||e[127]!==ke||e[128]!==qe||e[129]!==Xe||e[130]!==ot||e[131]!==$e?(He=t.jsxs(Ft,{title:he,settingsItem:"projects.icon",contentClassName:"space-y-3",children:[ke,qe,Xe,ot,$e]}),e[126]=he,e[127]=ke,e[128]=qe,e[129]=Xe,e[130]=ot,e[131]=$e,e[132]=He):He=e[132];let at;return e[133]!==me||e[134]!==Pe||e[135]!==He||e[136]!==Z?(at=t.jsxs(t.Fragment,{children:[Z,me,Pe,He]}),e[133]=me,e[134]=Pe,e[135]=He,e[136]=Z,e[137]=at):at=e[137],at};function Ec(s){return s.providers}function Rc(s){return t.jsx(Zt,{value:s,children:uo(s)},s)}const Ac=({projectRef:s})=>{const{t:e}=nt(),[n,r]=c.useState(null),[o,a]=c.useState(""),[i,d]=c.useState(!1);c.useEffect(()=>{let u=!1;return Rn(s).then(f=>{u||(r(f),a(f.shared.plansDir??""))}),()=>{u=!0}},[s]);const l=c.useCallback(async()=>{if(!n)return;const u=o.trim();if(u!==(n.shared.plansDir??"")){d(!0);try{const f=await Cs(s,{plansDir:u||null});if(!f){al.error(e("settings.projects.shared.toast.shareFailed")),a(n.shared.plansDir??"");return}r(f),a(f.shared.plansDir??"")}finally{d(!1)}}},[o,s,n,e]);if(!n)return null;const m=n.shared.status==="invalid"?e("settings.projects.shared.invalid",{path:n.shared.path,reason:n.shared.reason??""}):n.shared.status==="ok"?e("settings.projects.shared.status.ok"):e("settings.projects.shared.status.missing");return t.jsxs(Ft,{title:e("settings.projects.shared.title"),info:e("settings.projects.shared.description"),settingsItem:"projects.shared",children:[t.jsx(Hs,{label:e("settings.projects.shared.file"),children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[t.jsx("span",{className:"truncate font-mono text-xs text-foreground",children:n.shared.path}),t.jsx("span",{className:n.shared.status==="invalid"?"typography-meta text-[var(--status-warning)]":"typography-meta text-muted-foreground",children:m})]})}),t.jsx(Hs,{label:e("settings.projects.shared.plansDir"),info:e("settings.projects.shared.plansDirInfo"),settingsItem:"projects.shared.plansDir",children:t.jsx(Nt,{value:o,onChange:u=>a(u.target.value),onBlur:()=>{l()},onKeyDown:u=>{u.key==="Enter"&&u.currentTarget.blur()},placeholder:e("settings.projects.shared.plansDirPlaceholder"),"aria-label":e("settings.projects.shared.plansDirAria"),disabled:i,className:"h-8 rounded-md px-3 font-mono text-xs"})})]})},Mc=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Lc=s=>{if(!s)return null;const e=s.trim();return e&&Mc.test(e)?e.toLowerCase():null},Bc=s=>{const{t:e}=nt(),n=Et(le=>le.uploadProjectIcon),r=Et(le=>le.removeProjectIcon),o=Et(le=>le.discoverProjectIcon),a=Et(le=>s?le.projects.find(me=>me.id===s.id)?.iconImage??null:null),[i,d]=c.useState(""),[l,m]=c.useState(null),[u,f]=c.useState(null),[b,h]=c.useState(null),[x,g]=c.useState(void 0),[j,p]=c.useState(void 0),[S,M]=c.useState(!1),[R,F]=c.useState(!1),[U,T]=c.useState(!1),[w,H]=c.useState(!1),[P,N]=c.useState(null),[$,B]=c.useState(null),[G,J]=c.useState(!1),L=c.useRef(null),_=c.useCallback(()=>{N(null),B(le=>(le&&URL.revokeObjectURL(le),null))},[]),se=s?.id??null;c.useEffect(()=>{if(!s){d(""),m(null),f(null),h(null),g(void 0),p(void 0);return}d(s.label??""),m(s.icon??null),f(s.color??null),h(s.iconBackground??null),g(s.defaultModel),p(s.defaultVariant),H(!1),_(),J(!1)},[s,_]),c.useEffect(()=>()=>{_()},[_]);const ne=c.useMemo(()=>Lr(x)??{providerId:"",modelId:""},[x]),V=!!s?.iconImage,ee=!!(P&&$),C=s?.iconImage?.source==="custom",W=V&&!w||ee,O=W,A=!!(s&&V&&!w),z=!G&&(ee||A),v=!!s&&(i.trim()!==(s?.label??"").trim()||l!==(s?.icon??null)||u!==(s?.color??null)||b!==(s?.iconBackground??null)||(x??void 0)!==(s?.defaultModel??void 0)||(j??void 0)!==(s?.defaultVariant??void 0)||w||!!P),Z=c.useCallback((le,me)=>{g(le&&me?`${le}/${me}`:void 0),p(void 0)},[]),X=c.useCallback(le=>{p(le)},[]),ie=c.useCallback(le=>{!s||!le||S||(H(!1),J(!1),N(le),B(me=>(me&&URL.revokeObjectURL(me),URL.createObjectURL(le))))},[S,s]),je=c.useCallback(()=>{!s||!O||R||(ee&&_(),H(!!V),J(!1))},[_,ee,O,V,R,s]),de=c.useCallback(async()=>{if(!(!s||U)){_(),H(!1),J(!1),T(!0);try{const le=await o(s.id);if(!le.ok){ge.error(le.error||e("settings.projects.page.toast.discoverIconFailed"));return}if(le.skipped){ge.success(e("settings.projects.page.toast.customIconAlreadySet"));return}ge.success(e("settings.projects.page.toast.iconDiscovered"))}finally{T(!1)}}},[_,o,U,s,e]),Re=c.useCallback(async le=>{const me=le?.silent===!0;if(!s)return null;const Te=i.trim();if(!Te)return null;if(P){M(!0);const Y=await n(s.id,P);if(M(!1),!Y.ok)return ge.error(Y.error||e("settings.projects.page.toast.uploadIconFailed")),null;me||ge.success(e("settings.projects.page.toast.iconUpdated")),_(),H(!1)}const k=w&&!!s.iconImage;if(k){F(!0);const Y=await r(s.id);if(F(!1),!Y.ok)return ge.error(Y.error||e("settings.projects.page.toast.removeIconFailed")),null;me||ge.success(e("settings.projects.page.toast.iconRemoved")),H(!1),h(null)}return{label:Te,icon:l,color:u,iconBackground:Lc(k?null:b),defaultModel:x??null,defaultVariant:x?j??null:null}},[_,u,x,j,l,b,i,w,P,s,r,e,n]);return c.useEffect(()=>{J(!1)},[se,a?.updatedAt]),{name:i,setName:d,icon:l,setIcon:m,color:u,setColor:f,iconBackground:b,setIconBackground:h,defaultModel:x,defaultVariant:j,parsedDefaultModel:ne,handleDefaultModelChange:Z,handleDefaultVariantChange:X,isUploadingIcon:S,isRemovingCustomIcon:R,isDiscoveringIcon:U,pendingRemoveImageIcon:w,setPendingRemoveImageIcon:H,pendingUploadIconFile:P,pendingUploadIconPreviewUrl:$,previewImageFailed:G,setPreviewImageFailed:J,hasStoredImageIcon:V,hasPendingUploadImageIcon:ee,hasCustomIcon:C,effectiveHasImageIcon:W,hasRemovableImageIcon:O,showStoredImagePreview:A,showImagePreview:z,fileInputRef:L,clearPendingUploadIcon:_,handleUploadIcon:ie,handleRemoveImageIcon:je,handleDiscoverIcon:de,hasChanges:v,prepareSaveData:Re,currentIconImage:a,project:s}},Fc=450,Oc=(s,e)=>{const{t:n}=nt(),{hasChanges:r,name:o,icon:a,color:i,iconBackground:d,defaultModel:l,pendingRemoveImageIcon:m,pendingUploadIconFile:u,isUploadingIcon:f,isRemovingCustomIcon:b,prepareSaveData:h}=s,x=c.useRef(!1);c.useEffect(()=>{if(!r||!o.trim()||f||b||x.current)return;const g=window.setTimeout(()=>{x.current||(x.current=!0,(async()=>{try{const j=await h({silent:!0});if(j)try{await e(j)}catch{ge.error(n("settings.projects.page.toast.saveFailed"))}}finally{x.current=!1}})())},Fc);return()=>{window.clearTimeout(g)}},[i,l,r,a,d,b,f,o,e,m,u,h,n])},df=s=>{const e=_e.c(19),{project:n,onIdentitySave:r,showWorktrees:o}=s,a=o===void 0?!0:o,i=Bc(n);let d;e:{if(!n){d=null;break e}let j;e[0]!==n.id||e[1]!==n.path?(j={id:n.id,path:n.path},e[0]=n.id,e[1]=n.path,e[2]=j):j=e[2],d=j}const l=d;let m;if(e[3]!==r?(m=async j=>{await r(j)},e[3]=r,e[4]=m):m=e[4],Oc(i,m),!n||!l)return null;let f;e[5]!==i?(f=t.jsx(Pc,{form:i}),e[5]=i,e[6]=f):f=e[6];let b;e[7]!==l?(b=t.jsx(Dc,{projectRef:l}),e[7]=l,e[8]=b):b=e[8];let h;e[9]!==l||e[10]!==a?(h=a?t.jsx(jc,{projectRef:l}):null,e[9]=l,e[10]=a,e[11]=h):h=e[11];let x;e[12]!==l?(x=t.jsx(Ac,{projectRef:l}),e[12]=l,e[13]=x):x=e[13];let g;return e[14]!==f||e[15]!==b||e[16]!==h||e[17]!==x?(g=t.jsxs("div",{className:"space-y-0",children:[f,b,h,x]}),e[14]=f,e[15]=b,e[16]=h,e[17]=x,e[18]=g):g=e[18],g},mo=()=>{const s=Na();return{displayMode:s,installed:s!=="browser",browserTab:s==="browser"}},uf=()=>{const s=_e.c(2),[e,n]=c.useState($c);let r,o;return s[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=[window.matchMedia("(display-mode: standalone)"),window.matchMedia("(display-mode: minimal-ui)"),window.matchMedia("(display-mode: fullscreen)"),window.matchMedia("(display-mode: window-controls-overlay)")],i=()=>{n(mo())};i();for(const d of a)typeof d.addEventListener=="function"?d.addEventListener("change",i):typeof d.addListener=="function"&&d.addListener(i);return window.addEventListener("appinstalled",i),window.addEventListener("focus",i),()=>{for(const d of a)typeof d.removeEventListener=="function"?d.removeEventListener("change",i):typeof d.removeListener=="function"&&d.removeListener(i);window.removeEventListener("appinstalled",i),window.removeEventListener("focus",i)}},o=[],s[0]=r,s[1]=o):(r=s[0],o=s[1]),c.useEffect(r,o),e};function $c(){return mo()}const Vc=[{slug:"home",title:"Settings",group:"general",kind:"single",description:"Search and jump to common pages.",keywords:["search","settings"]},{slug:"general",title:"General",group:"general",kind:"single",keywords:["general","startup","launch at login","autostart","tray","password","passkey","security","privacy","telemetry","transport","network","lan","binary","cli"]},{slug:"projects",title:"Projects",group:"projects",kind:"split",keywords:["project","projects","worktree","worktrees","repo","repository","directory"]},{slug:"remote-instances",title:"Remote Instances",group:"projects",kind:"single",keywords:["ssh","remote","instances","tunnels","forwarding","connection"],isAvailable:s=>!s.isVSCode},{slug:"providers",title:"Providers",group:"opencode",kind:"split",keywords:["provider","providers","models","model","api key","api keys","openai","anthropic","ollama","credentials"]},{slug:"usage",title:"Usage",group:"general",kind:"split",keywords:["quota","billing","tokens","usage","limits"]},{slug:"agents",title:"Agents",group:"opencode",kind:"split",keywords:["agent","agents","prompts","tools","permissions"]},{slug:"behavior",title:"Behavior",group:"opencode",kind:"single",keywords:["behavior","agents.md","system prompt","global rules","instructions","override"]},{slug:"commands",title:"Commands",group:"opencode",kind:"split",keywords:["command","commands","slash","macros","automation"]},{slug:"mcp",title:"MCP",group:"opencode",kind:"split",keywords:["mcp","model context protocol","servers","tools","remote","stdio"]},{slug:"plugins",title:"Plugins",group:"opencode",kind:"split",keywords:["plugin","plugins","extensions","addons","npm","opencode-wakatime"]},{slug:"skills.installed",title:"Skills",group:"content",kind:"split",keywords:["skill","skills","instructions","install","catalog"]},{slug:"skills.catalog",title:"Skills Catalog",group:"content",kind:"single",keywords:["install","catalog","external","repository","skills catalog"]},{slug:"git",title:"Git",group:"projects",kind:"single",keywords:["git","identity","identities","ssh","profiles","credentials","keys","commit","gitmoji"],isAvailable:s=>!s.isVSCode},{slug:"appearance",title:"Appearance",group:"general",kind:"single",keywords:["theme","font","spacing","padding","corner radius","radius","input bar","keyboard","viewport","mobile","terminal","pwa","install name","app shortcuts"]},{slug:"chat",title:"Chat",group:"general",kind:"single",keywords:["tools","diff","reasoning","dotfiles","draft","queue","output","copy","image","split messages","message actions"]},{slug:"shortcuts",title:"Shortcuts",group:"general",kind:"single",keywords:["keyboard","hotkeys","shortcuts","bindings"],isAvailable:s=>!s.isVSCode},{slug:"sessions",title:"Sessions",group:"general",kind:"single",keywords:["defaults","default agent","default model","retention","memory","limits","zen"]},{slug:"magic-prompts",title:"Magic Prompts",group:"content",kind:"split",keywords:["prompts","templates","git","github","review","commit","pull request"],isAvailable:s=>!s.isVSCode},{slug:"snippets",title:"Snippets",group:"content",kind:"split",keywords:["prompt","templates","multi-run","strategy","approach"]},{slug:"notifications",title:"Notifications",group:"general",kind:"single",keywords:["alerts","native","summary","summarization"]},{slug:"voice",title:"Voice",group:"general",kind:"single",keywords:["tts","speech","voice"],isAvailable:s=>!s.isVSCode},{slug:"tunnel",title:"External Tunnel",group:"projects",kind:"single",keywords:["tunnel","external","cloudflare","qr","remote","mobile","share"],isAvailable:s=>!s.isVSCode},{slug:"about",title:"About",group:"general",kind:"single",keywords:["about","version","updates","release","changelog"],isAvailable:s=>s.isMobile&&!s.isVSCode},{slug:"integrations",title:"Integrations",group:"general",kind:"single",keywords:["integration","connect","oauth","github","linear"],isAvailable:s=>!s.isVSCode}],Wc={sessions:"sessions",agents:"agents",commands:"commands",mcp:"mcp",skills:"skills.installed",providers:"providers",usage:"usage","git-identities":"git",settings:"home"};function zc(s){const e=s.trim().toLowerCase();return Vc.find(n=>n.slug===e)??null}function Uc(s){const e=(s??"").trim().toLowerCase();if(!e)return"home";const n=Wc[e];if(n)return n;const r=zc(e);return r?r.slug:"home"}function mf(s){switch(s){case"general":return"settings-3";case"projects":return"folders";case"remote-instances":return"computer";case"appearance":return"palette";case"chat":return"chat-ai-3";case"magic-prompts":return"ai-generate-2";case"snippets":return"chat-thread";case"notifications":return"notification-3";case"shortcuts":return"command";case"sessions":return"chat-history";case"providers":return"cloud";case"agents":return"ai-agent";case"behavior":return"brain";case"commands":return"slash-commands-2";case"mcp":return null;case"plugins":return"plug-2";case"skills.installed":return"book-open";case"skills.catalog":return"book";case"git":return"git-branch";case"integrations":return"plug";case"usage":return"bar-chart-2";case"voice":return"mic";case"tunnel":return"home-office";case"about":return"information";case"home":return null;default:return"robot-2"}}const _c=["chat","git","diff","terminal","files"],Gc=["settings","agents","commands","skills","providers","usage","git-identities"],Ot={SESSION:"session",TAB:"tab",SETTINGS:"settings",FILE:"file"};function ur(s){const e=Hc();return{sessionId:Kc(e),tab:qc(e),settingsPath:Jc(e),diffFile:Yc(e)}}function Hc(){if(typeof window>"u")return new URLSearchParams;try{return new URLSearchParams(window.location.search)}catch{return new URLSearchParams}}function Kc(s){const e=s.get(Ot.SESSION);return!e||e.trim().length===0?null:e.trim()}function qc(s){const e=s.get(Ot.TAB);if(!e)return null;const n=e.toLowerCase().trim();return _c.includes(n)?n:null}function Jc(s){const e=s.get(Ot.SETTINGS);if(!e)return null;const n=e.toLowerCase().trim();return n.length===0?null:n==="aiworker"||n==="general"||n==="preferences"?"home":(Gc.includes(n),n)}function Yc(s){const e=s.get(Ot.FILE);if(!e||e.trim().length===0)return null;try{return decodeURIComponent(e.trim())}catch{return e.trim()}}function mr(){if(typeof window>"u")return!1;try{const s=new URLSearchParams(window.location.search);return s.has(Ot.SESSION)||s.has(Ot.TAB)||s.has(Ot.SETTINGS)||s.has(Ot.FILE)}catch{return!1}}function fo(s){const e=new URLSearchParams;if(s.sessionId&&s.sessionId.trim().length>0&&e.set(Ot.SESSION,s.sessionId),s.isSettingsOpen){const n=s.settingsPath.trim().length>0?s.settingsPath:"home";return e.set(Ot.SETTINGS,n),e}return e}function Qc(s,e){const n=typeof window<"u"?window.location.pathname:"/",r=s.toString();return r?`${n}?${r}`:n}function Xc(s){if(typeof window>"u")return!0;try{const e=new URLSearchParams(window.location.search),n=fo(s),r=[...e.entries()].sort((a,i)=>a[0].localeCompare(i[0])),o=[...n.entries()].sort((a,i)=>a[0].localeCompare(i[0]));if(r.length!==o.length)return!1;for(let a=0;a<r.length;a++)if(r[a][0]!==o[a][0]||r[a][1]!==o[a][1])return!1;return!0}catch{return!0}}function fr(s,e={}){if(!(typeof window>"u")&&!(Zc()||Yr())&&!(!e.force&&Xc(s)))try{const n=fo(s),r=Qc(n);e.replace?window.history.replaceState({...window.history.state,route:s},"",r):window.history.pushState({route:s},"",r)}catch{}}function Zc(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}async function ed(s){const e=s.trim();if(!e)return;const n=ut.getState();n.currentSessionId!==e&&n.setCurrentSession(e,n.getDirectoryForSession(e));const r=await ka().catch(()=>null);if(!r)return;const o=ut.getState();if(o.currentSessionId!==e)return;const a=[...r.activeSessions,...r.archivedSessions].find(d=>d.id===e);if(!a)return;const i=Br(a);!i||i===o.currentSessionDirectory||o.setCurrentSession(e,i)}function td(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function ff(){const s=c.useMemo(()=>td(),[]),e=c.useMemo(()=>Yr(),[]),n=c.useRef(!1),r=c.useRef(!1),o=Ke(u=>u.setSettingsDialogOpen),a=Ke(u=>u.setSettingsPage),i=Ke(u=>u.navigateToDiff),d=c.useCallback(async u=>{if(!r.current){r.current=!0;try{if(u.sessionId&&await ed(u.sessionId),u.settingsPath){a(Uc(u.settingsPath)),o(!0);return}if(Ke.getState().isSettingsDialogOpen&&o(!1),u.tab&&u.tab!=="chat"){const f=ys.getState().currentDirectory;if(f){const b=u.tab==="files"?"file":u.tab;Ke.getState().openContextSurface(f,b)}}u.diffFile&&(u.tab==="diff"||!u.tab)&&i(u.diffFile)}finally{r.current=!1}}},[o,a,i]),l=c.useCallback(()=>{const u=ut.getState(),f=Ke.getState();return{sessionId:u.currentSessionId,isSettingsOpen:f.isSettingsDialogOpen,settingsPath:f.settingsPage}},[]),m=c.useCallback((u={})=>{if(s||e||r.current)return;const f=l();fr(f,u)},[s,e,l]);c.useEffect(()=>{if(n.current||(n.current=!0,!mr()))return;const u=ur();(async()=>(await d(u),!s&&!e&&fr({...l(),sessionId:u.sessionId??ut.getState().currentSessionId,settingsPath:u.settingsPath??Ke.getState().settingsPage},{replace:!0,force:!0})))()},[d,l,s,e]),c.useEffect(()=>{if(s||e)return;let u=ut.getState().currentSessionId;return ut.subscribe(b=>{const h=b.currentSessionId;h===u||r.current||(u=h,m())})},[s,e,m]),c.useEffect(()=>{if(s||e)return;let u=Ke.getState().isSettingsDialogOpen,f=Ke.getState().settingsPage;return Ke.subscribe(h=>{if(r.current)return;const x=h.isSettingsDialogOpen!==u,g=h.settingsPage!==f;u=h.isSettingsDialogOpen,f=h.settingsPage,(x||g)&&m()})},[s,e,m]),c.useEffect(()=>{if(typeof window>"u"||s||e)return;const u=()=>{const f=ur();mr()?d(f):Ke.getState().isSettingsDialogOpen&&o(!1)};return window.addEventListener("popstate",u),()=>{window.removeEventListener("popstate",u)}},[d,s,e,o])}const sd=600*1e3,hf=()=>{const s=_e.c(3),{terminal:e}=Xs();let n,r;s[0]!==e?(n=()=>{if(!e.touchSessions)return;const o=()=>{if(globalThis.navigator?.onLine===!1)return;const i=[];for(const d of mt.getState().sessions.values())for(const l of d.tabs)l.terminalSessionId&&l.lifecycle!=="exited"&&i.push(l.terminalSessionId);i.length>0&&e.touchSessions?.(i).catch(nd)};o();const a=setInterval(o,sd);return()=>clearInterval(a)},r=[e],s[0]=e,s[1]=n,s[2]=r):(n=s[1],r=s[2]),c.useEffect(n,r)};function nd(){}function pf(){const s=_e.c(5),e=Cl(od),n=c.useRef(e);let r,o;s[0]!==e?(r=()=>{n.current=e},o=[e],s[0]=e,s[1]=r,s[2]=o):(r=s[1],o=s[2]),c.useEffect(r,o);let a,i;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{let d=!1,l=null;const m=rd,u=f=>{d||(l=window.setTimeout(async()=>{const b=await n.current(),h=typeof b=="number"&&Number.isFinite(b)?m(b):36e5;u(h)},f))};return u(3e3),()=>{d=!0,l!==null&&window.clearTimeout(l)}},i=[],s[3]=a,s[4]=i):(a=s[3],i=s[4]),c.useEffect(a,i)}function rd(s){const e=Math.round(s*1e3);return Math.max(3e5,Math.min(864e5,e))}function od(s){return s.checkForUpdates}const Pn=1e3,Ss=60*Pn,dn=60*Ss,ad=(s,e)=>{const n=Math.max(0,s);return n<Ss?e("common.duration.secondsCompact",{seconds:Math.floor(n/Pn)}):n<dn?e("common.duration.minutesSecondsCompact",{minutes:Math.floor(n/Ss),seconds:Math.floor(n%Ss/Pn)}):e("common.duration.hoursMinutesCompact",{hours:Math.floor(n/dn),minutes:Math.floor(n%dn/Ss)})},id=1e3,gf=s=>{const e=_e.c(12),{sessionId:n,running:r,className:o}=s,{t:a}=nt(),i=Ca(n),d=Ia(n),l=Ta(r,id),m=r?Math.max(0,l-(i??l)):d;if(m===void 0)return null;let u,f;e[0]!==m||e[1]!==r||e[2]!==a?(u=ad(m,a),f=r?a("sessions.sidebar.session.status.activeFor",{duration:u}):a("sessions.sidebar.session.status.lastTurnDuration",{duration:u}),e[0]=m,e[1]=r,e[2]=a,e[3]=u,e[4]=f):(u=e[3],f=e[4]);const b=f,h=r?"text-primary":"text-[var(--status-info)]";let x;e[5]!==o||e[6]!==h?(x=re("shrink-0 tabular-nums",h,o),e[5]=o,e[6]=h,e[7]=x):x=e[7];let g;return e[8]!==b||e[9]!==u||e[10]!==x?(g=t.jsx("span",{className:x,"aria-label":b,title:b,children:u}),e[8]=b,e[9]=u,e[10]=x,e[11]=g):g=e[11],g},ld=()=>{const s=_e.c(14),[e,n]=ae.useState(!1),[r,o]=ae.useState(!1);let a,i;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{n(Kr()),o(Ai())},i=[],s[0]=a,s[1]=i):(a=s[0],i=s[1]),ae.useEffect(a,i);let d;s[2]!==e?(d=async x=>e?await Mi(x):{success:!0,path:x},s[2]=e,s[3]=d):d=s[3];const l=d;let m;s[4]!==e?(m=async x=>e?await Li():{success:!0},s[4]=e,s[5]=m):m=s[5];const u=m;let f;s[6]!==e?(f=async x=>e?await Bi():{success:!0},s[6]=e,s[7]=f):f=s[7];const b=f;let h;return s[8]!==r||s[9]!==e||s[10]!==l||s[11]!==u||s[12]!==b?(h={isDesktop:e,canRequestAccess:r,requestAccess:l,startAccessing:u,stopAccessing:b},s[8]=r,s[9]=e,s[10]=l,s[11]=u,s[12]=b,s[13]=h):h=s[13],h},ho="aiworker:recent-git-branches:v1",po=5,cd=Hi(Yt(),Ki(Yt())),go=s=>{const e=Ks(s);return e?`${Gt()}:${e}`:null},xo=()=>{try{const s=localStorage.getItem(ho),e=cd.safeParse(s?JSON.parse(s):null);return e.success?Object.fromEntries(Object.entries(e.data).map(([n,r])=>[n,r.slice(0,po)])):{}}catch{return{}}},hr=s=>{const e=go(s);return e?xo()[e]??[]:[]},pr=(s,e)=>{const n=go(s);if(!n||!e)return[];const r=xo(),o=[e,...(r[n]??[]).filter(a=>a!==e)].slice(0,po);try{localStorage.setItem(ho,JSON.stringify({...r,[n]:o}))}catch{}return o},dd=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),ud=({currentBranch:s,localBranches:e,remoteBranches:n,branchInfo:r,currentBranchAhead:o=0,onCheckout:a,onCreate:i,remotes:d=[],disabled:l=!1,directory:m,switchBlockedNotice:u=null})=>{const{t:f}=nt(),{isMobile:b}=bs(),[h,x]=c.useState(!1),[g,j]=c.useState(""),[p,S]=c.useState(!1),[M,R]=c.useState(!1),[F,U]=c.useState(""),[T,w]=c.useState(!1),[H,P]=c.useState(()=>hr(m)),[N,$]=c.useState({}),B=c.useRef(null),G=c.useCallback(A=>{A.stopPropagation()},[]),J=d.length>1,L=c.useMemo(()=>dd(F),[F]),_=c.useMemo(()=>yn(e,g,A=>[A]),[g,e]),se=c.useMemo(()=>yn(n,g,A=>[A]),[g,n]),ne=A=>{if(A===s){x(!1);return}P(pr(m,A)),a(A),x(!1),j("")},V=()=>{S(!0),setTimeout(()=>B.current?.focus(),50)},ee=async()=>{if(!(!L||T)){if(J){R(!0);return}w(!0);try{await i(L,d[0]),U(""),S(!1),x(!1)}finally{w(!1)}}},C=async A=>{if(!(!L||T)){w(!0);try{await i(L,A),U(""),S(!1),R(!1),x(!1)}finally{w(!1)}}},W=()=>{R(!1)},O=()=>{U(""),S(!1),R(!1)};if(c.useEffect(()=>{h||(j(""),S(!1),R(!1),U(""))},[h]),c.useEffect(()=>{m&&P(s?pr(m,s):hr(m))},[s,m]),c.useEffect(()=>{if(!h)return;const A=H.filter(v=>e.includes(v)).slice(0,5);if(A.length===0)return $({});let z=!1;return Da(m,A).then(({counts:v})=>{z||$(v)}).catch(()=>{z||$({})}),()=>{z=!0}},[m,h,e,H]),b){const A=H.filter(v=>e.includes(v)),z=(v,Z=!1)=>{const X=N[v]??(v===s?o:0),ie=X===1?f("gitView.branch.unpushedSingle"):f("gitView.branch.unpushedPlural",{count:X});return t.jsxs("button",{type:"button",onClick:()=>ne(v),className:"flex w-full items-center gap-2 rounded-lg px-2 py-2.5 text-left typography-ui-label hover:bg-interactive-hover",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate",children:v}),X>0?t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-muted-foreground",title:ie,"aria-label":ie,children:[t.jsx(E,{name:"arrow-up",className:"size-3","aria-hidden":"true"}),t.jsx("span",{"aria-hidden":"true",children:X})]}):null,s===v?t.jsx(E,{name:"check",className:"size-4 shrink-0 text-primary"}):null]},`${Z?"remote":"local"}-${v}`)};return t.jsxs(t.Fragment,{children:[t.jsxs(ve,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:l,onClick:()=>x(!0),children:[t.jsx(E,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:s||f("gitView.branch.detachedHead")}),t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60"})]}),t.jsx(ms,{open:h,title:f("gitView.branch.currentBranchTooltip"),onClose:()=>x(!1),children:t.jsxs("div",{className:"flex flex-col gap-2 px-3 pb-4 pt-1",children:[t.jsx("input",{autoFocus:!0,value:g,onChange:v=>j(v.target.value),placeholder:f("gitView.branch.searchPlaceholder"),className:"h-9 w-full rounded-lg border border-border bg-transparent px-3 typography-meta outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-primary"}),u?t.jsxs("div",{className:"flex items-start gap-2 px-2 py-1",children:[t.jsx(E,{name:"alert",className:"mt-0.5 size-3.5 shrink-0 text-[var(--status-warning)]","aria-hidden":"true"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:u})]}):null,A.length>0?t.jsxs("section",{children:[t.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:f("gitView.branch.recentBranches")}),A.map(v=>z(v))]}):null,t.jsxs("section",{children:[t.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:f("gitView.branch.localBranches")}),_.map(v=>z(v))]}),t.jsxs("section",{children:[t.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:f("gitView.branch.remoteBranches")}),se.map(v=>z(v,!0))]})]})})]})}return t.jsxs(Ht,{open:h,onOpenChange:x,children:[t.jsxs(ps,{children:[t.jsx(gs,{asChild:!0,children:t.jsx(Kt,{asChild:!0,children:t.jsxs(ve,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:l,children:[t.jsx(E,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:s||f("gitView.branch.detachedHead")}),t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),t.jsx(xs,{sideOffset:8,children:f("gitView.branch.currentBranchTooltip")})]}),t.jsx(qt,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:t.jsxs(wn,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(vn,{placeholder:f("gitView.branch.searchPlaceholder"),value:g,onValueChange:j,onKeyDown:G}),u?t.jsxs("div",{className:"flex items-start gap-2 border-b border-border/60 px-3 py-2",children:[t.jsx(E,{name:"alert",className:"mt-0.5 size-3.5 shrink-0 text-[var(--status-warning)]","aria-hidden":"true"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:u})]}):null,t.jsxs(jn,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(Sn,{children:f("gitView.branch.empty")}),t.jsx(Lt,{children:M?t.jsxs("div",{className:"px-2 py-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("button",{type:"button",onClick:W,disabled:T,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(E,{name:"arrow-left",className:"size-4"})}),t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[f("gitView.branch.pushToPrefix")," ",t.jsx("span",{className:"text-foreground font-medium",children:L})," ",f("gitView.branch.pushToSuffix")]})]}),t.jsx("div",{className:"flex flex-col gap-1",children:d.map(A=>t.jsxs("button",{type:"button",onClick:()=>C(A),disabled:T,className:"flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50",children:[t.jsxs("span",{className:"typography-ui-label text-foreground",children:[T?t.jsx(E,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,A.name]}),t.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:A.pushUrl})]},A.name))})]}):p?t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[t.jsx("input",{ref:B,placeholder:f("gitView.branch.newBranchPlaceholder"),value:F,onChange:A=>U(A.target.value),onClick:A=>A.stopPropagation(),onKeyDown:A=>{G(A),A.key==="Enter"?(A.preventDefault(),ee()):A.key==="Escape"&&(A.preventDefault(),O())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:ee,disabled:!L||T,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:T?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"add",className:"size-4"})}),t.jsx("button",{type:"button",onClick:O,disabled:T,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(E,{name:"close",className:"size-4"})})]}):t.jsxs(Mt,{onSelect:V,children:[t.jsx(E,{name:"add",className:"size-4"}),t.jsx("span",{children:f("gitView.branch.create")})]})}),t.jsx(ks,{}),H.filter(A=>e.includes(A)).length>0?t.jsxs(t.Fragment,{children:[t.jsx(Lt,{heading:f("gitView.branch.recentBranches"),children:H.filter(A=>e.includes(A)).map(A=>t.jsxs(Mt,{onSelect:()=>ne(A),children:[t.jsxs("span",{className:"flex flex-1 items-center gap-2 min-w-0",children:[t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:A}),(()=>{const z=N[A]??(A===s?o:0),v=z===1?f("gitView.branch.unpushedSingle"):f("gitView.branch.unpushedPlural",{count:z});return z>0?t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full px-1.5 py-0.5 typography-micro text-muted-foreground",title:v,"aria-label":v,children:[t.jsx(E,{name:"arrow-up",className:"size-3","aria-hidden":"true"}),t.jsx("span",{"aria-hidden":"true",children:z})]}):null})()]}),s===A?t.jsx("span",{className:"typography-micro text-primary",children:f("gitView.branch.currentBadge")}):null]},`recent-${A}`))}),t.jsx(ks,{})]}):null,t.jsxs(Lt,{heading:f("gitView.branch.localBranches"),children:[_.map(A=>t.jsxs(Mt,{onSelect:()=>ne(A),children:[t.jsxs("span",{className:"flex flex-1 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:A}),(r?.[A]?.ahead||r?.[A]?.behind)&&t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[r[A].ahead||0," ahead ·"," ",r[A].behind||0," behind"]})]}),s===A&&t.jsx("span",{className:"typography-micro text-primary",children:f("gitView.branch.currentBadge")})]},`local-${A}`)),_.length===0&&t.jsx(Mt,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:f("gitView.branch.noLocalBranches")})})]}),t.jsx(ks,{}),t.jsxs(Lt,{heading:f("gitView.branch.remoteBranches"),children:[se.map(A=>t.jsx(Mt,{onSelect:()=>ne(A),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:A})},`remote-${A}`)),se.length===0&&t.jsx(Mt,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:f("gitView.branch.noRemoteBranches")})})]})]})]})})]})},md=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),fd=({currentBranch:s,onRename:e,showEditButton:n=!0})=>{const{t:r}=nt(),[o,a]=c.useState(!1),[i,d]=c.useState(s||""),[l,m]=c.useState(!1),u=c.useRef(null),f=()=>{!s||!e||(d(s),a(!0),setTimeout(()=>u.current?.focus(),0))},b=async()=>{if(!s||!e||!i.trim())return;const g=md(i);if(g===s){a(!1);return}m(!0);try{await e(s,g),a(!1),d("")}finally{m(!1)}},h=()=>{a(!1),d("")},x=g=>{g.key==="Enter"?(g.preventDefault(),b()):g.key==="Escape"&&(g.preventDefault(),h())};return o?t.jsx("div",{className:"flex items-center gap-2 rounded-md bg-primary/12 px-2 py-1 h-8",children:t.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:g=>{g.preventDefault(),b()},children:[t.jsx(E,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("input",{ref:u,value:i,onChange:g=>d(g.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",placeholder:r("gitView.branch.namePlaceholder"),onKeyDown:x,autoFocus:!0}),t.jsx("button",{type:"submit",disabled:l,"aria-label":r(l?"gitView.branch.renameSaving":"gitView.branch.renameSave"),title:r(l?"gitView.branch.renameSaving":"gitView.branch.renameSave"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:l?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"check",className:"size-4"})}),t.jsx("button",{type:"button",onClick:h,disabled:l,"aria-label":r("gitView.branch.renameCancel"),title:r("gitView.branch.renameCancel"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(E,{name:"close",className:"size-4"})})]})}):t.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5 px-2 py-1 h-8",children:[t.jsx(E,{name:"git-branch",className:"size-4 text-primary shrink-0"}),t.jsxs("div",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[t.jsx("span",{className:"truncate typography-ui-label font-normal text-foreground",children:s||r("gitView.branch.detachedHead")}),n&&e&&s&&t.jsx(ve,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:f,title:r("gitView.branch.renameTitle"),children:t.jsx(E,{name:"edit",className:"size-4"})})]})]})},hd=s=>{const e=_e.c(44),{syncAction:n,remotes:r,onFetch:o,onSync:a,onRemoveRemote:i,disabled:d,removingRemoteName:l,aheadCount:m,behindCount:u,trackingRemoteName:f,hasUncommittedChanges:b}=s,h=r===void 0?[]:r,x=l===void 0?null:l,g=m===void 0?0:m,j=u===void 0?0:u,p=b===void 0?!1:b,{t:S}=nt(),M=c.useRef(!1),R=!!x,F=h.find(ce=>ce.name===f)??h[0],U=j>0&&p,T=d||n!==null||R||!F||U,w=d||n!==null||R||h.length===0,H=g>0||j>0;let P;e[0]!==S?(P=S("gitView.sync.sync"),e[0]=S,e[1]=P):P=e[1];const N=j>0?`↓${j}`:null,$=g>0?`↑${g}`:null;let B;e[2]!==P||e[3]!==N||e[4]!==$?(B=[P,N,$].filter(Boolean),e[2]=P,e[3]=N,e[4]=$,e[5]=B):B=e[5];const G=B.join(" "),J=U?S("gitView.sync.commitOrStashTooltip"):F?H?S("gitView.sync.syncChangesTooltip",{ahead:g,behind:j}):S("gitView.sync.syncChanges"):S("gitView.sync.noRemoteTooltip"),L=()=>{F&&a(F)},_="inline-flex items-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] border border-border/60 bg-[var(--surface-elevated)] overflow-hidden",se=U?0:void 0;let ne;e[6]===Symbol.for("react.memo_cache_sentinel")?(ne=re("inline-flex h-7 items-center gap-1.5 px-2 typography-ui-label font-medium text-foreground","transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),e[6]=ne):ne=e[6];let V;e[7]!==S?(V=S("gitView.sync.syncChanges"),e[7]=S,e[8]=V):V=e[8];let ee;e[9]!==n?(ee=n==="sync"?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"refresh",className:"size-4"}),e[9]=n,e[10]=ee):ee=e[10];let C;e[11]!==G?(C=t.jsx("span",{className:"whitespace-nowrap tabular-nums",children:G}),e[11]=G,e[12]=C):C=e[12];let W;e[13]!==L||e[14]!==T||e[15]!==V||e[16]!==ee||e[17]!==C?(W=t.jsxs("button",{type:"button",onClick:L,disabled:T,className:ne,"aria-label":V,children:[ee,C]}),e[13]=L,e[14]=T,e[15]=V,e[16]=ee,e[17]=C,e[18]=W):W=e[18];let O;e[19]!==se||e[20]!==W?(O=t.jsx(gs,{asChild:!0,children:t.jsx("span",{className:"inline-flex",tabIndex:se,children:W})}),e[19]=se,e[20]=W,e[21]=O):O=e[21];let A;e[22]!==J?(A=t.jsx(xs,{sideOffset:8,children:J}),e[22]=J,e[23]=A):A=e[23];let z;e[24]!==O||e[25]!==A?(z=t.jsxs(ps,{children:[O,A]}),e[24]=O,e[25]=A,e[26]=z):z=e[26];const v=Ht;let Z;e[27]===Symbol.for("react.memo_cache_sentinel")?(Z=re("inline-flex h-7 w-6 items-center justify-center border-l border-[var(--interactive-border)] text-muted-foreground","transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),e[27]=Z):Z=e[27];let X;e[28]!==S?(X=S("gitView.sync.moreActionsAria"),e[28]=S,e[29]=X):X=e[29];let ie;e[30]===Symbol.for("react.memo_cache_sentinel")?(ie=t.jsx(E,{name:"arrow-down-s",className:"size-4"}),e[30]=ie):ie=e[30];let je;e[31]!==w||e[32]!==X?(je=t.jsx(Kt,{asChild:!0,children:t.jsx("button",{type:"button",className:Z,disabled:w,"aria-label":X,children:ie})}),e[31]=w,e[32]=X,e[33]=je):je=e[33];const de=qt,Re="start",le=-40,me="w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",Te=h.map(ce=>t.jsx(Bt,{onSelect:pe=>{if(M.current){pe.preventDefault(),M.current=!1;return}o(ce)},children:t.jsxs("div",{className:"flex w-full items-center gap-2",children:[t.jsx(E,{name:"refresh",className:"size-4 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:S("gitView.sync.fetchFromRemote",{name:ce.name})}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:ce.fetchUrl})]})}),i&&ce.name!==f?t.jsx(ve,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:n!==null||R,onPointerDown:pe=>{M.current=!0,pe.preventDefault(),pe.stopPropagation()},onClick:pe=>{M.current=!0,pe.preventDefault(),pe.stopPropagation(),i(ce)},"aria-label":S("gitView.header.removeRemoteAria",{name:ce.name}),title:S("gitView.header.removeRemoteTitle",{name:ce.name}),children:x===ce.name?t.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(E,{name:"close",className:"size-3.5"})}):null]})},ce.name));let k;e[34]!==de||e[35]!==Te?(k=t.jsx(de,{align:Re,alignOffset:le,className:me,children:Te}),e[34]=de,e[35]=Te,e[36]=k):k=e[36];let Y;e[37]!==v||e[38]!==je||e[39]!==k?(Y=t.jsxs(v,{children:[je,k]}),e[37]=v,e[38]=je,e[39]=k,e[40]=Y):Y=e[40];let q;return e[41]!==z||e[42]!==Y?(q=t.jsxs("div",{className:_,children:[z,Y]}),e[41]=z,e[42]=Y,e[43]=q):q=e[43],q},pd=s=>{const e=_e.c(27),{repositories:n,selectedRepository:r,onSelectRepository:o,repositoryRoot:a}=s,{t:i}=nt();let d;e[0]!==a?(d=M=>{const R=`${a??""}/`;return M.startsWith(R)?M.slice(R.length):M},e[0]=a,e[1]=d):d=e[1];const l=d,m=r??void 0;let u;e[2]!==o?(u=M=>{M&&o(M)},e[2]=o,e[3]=u):u=e[3];let f;e[4]!==i?(f=i("gitView.empty.selectRepositoryPlaceholder"),e[4]=i,e[5]=f):f=e[5];let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(E,{name:"folder-3",className:"size-4 text-muted-foreground"}),e[6]=b):b=e[6];let h;e[7]!==l||e[8]!==r?(h=r?l(r):"",e[7]=l,e[8]=r,e[9]=h):h=e[9];let x;e[10]!==h?(x=t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:h}),e[10]=h,e[11]=x):x=e[11];let g;e[12]!==f||e[13]!==x?(g=t.jsxs(_s,{size:"sm",className:"max-w-[13rem] gap-1.5 px-2 py-1","aria-label":f,children:[b,x]}),e[12]=f,e[13]=x,e[14]=g):g=e[14];let j;if(e[15]!==l||e[16]!==n){let M;e[18]!==l?(M=R=>t.jsx(Zt,{value:R,children:t.jsx("span",{className:"truncate",children:l(R)})},R),e[18]=l,e[19]=M):M=e[19],j=n.map(M),e[15]=l,e[16]=n,e[17]=j}else j=e[17];let p;e[20]!==j?(p=t.jsx(Gs,{align:"start",children:j}),e[20]=j,e[21]=p):p=e[21];let S;return e[22]!==p||e[23]!==m||e[24]!==u||e[25]!==g?(S=t.jsxs(Us,{value:m,onValueChange:u,children:[g,p]}),e[22]=p,e[23]=m,e[24]=u,e[25]=g,e[26]=S):S=e[26],S},gd={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",user:"user-3",fingerprint:"fingerprint"},xd={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)",success:"var(--status-success)",info:"var(--status-info)",warning:"var(--status-warning)"};function bo(s){return s&&xd[s]||"var(--primary)"}const gr=s=>{const e=_e.c(8),{icon:n,className:r,colorToken:o}=s,a=gd[n??"branch"]??"user-3";let i;e[0]!==o?(i=bo(o),e[0]=o,e[1]=i):i=e[1];let d;e[2]!==i?(d={color:i},e[2]=i,e[3]=d):d=e[3];let l;return e[4]!==r||e[5]!==a||e[6]!==d?(l=t.jsx(E,{name:a,className:r,style:d}),e[4]=r,e[5]=a,e[6]=d,e[7]=l):l=e[7],l},yo=s=>{const e=_e.c(35),{activeProfile:n,identities:r,onSelect:o,isApplying:a,iconOnly:i}=s,d=i===void 0?!1:i,{t:l}=nt(),m=a||r.length===0,u=n?.color;let f;e[0]!==u?(f=bo(u),e[0]=u,e[1]=f):f=e[1];let b;e[2]!==f?(b={color:f},e[2]=f,e[3]=b):b=e[3];let h;e[4]!==n?.color||e[5]!==n?.icon||e[6]!==a?(h=a?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(gr,{icon:n?.icon,colorToken:n?.color,className:"size-4"}),e[4]=n?.color,e[5]=n?.icon,e[6]=a,e[7]=h):h=e[7];let x;e[8]!==n?.name||e[9]!==d||e[10]!==l?(x=!d&&t.jsx("span",{className:"git-identity-label min-w-0 flex-1 truncate text-left",children:n?.name||l("gitView.header.noIdentity")}),e[8]=n?.name,e[9]=d,e[10]=l,e[11]=x):x=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60"}),e[12]=g):g=e[12];let j;e[13]!==m||e[14]!==b||e[15]!==h||e[16]!==x?(j=t.jsx(gs,{asChild:!0,children:t.jsx(Kt,{asChild:!0,children:t.jsxs(ve,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-[15rem] justify-start gap-1.5 px-2 py-1 typography-ui-label",style:b,disabled:m,children:[h,x,g]})})}),e[13]=m,e[14]=b,e[15]=h,e[16]=x,e[17]=j):j=e[17];let p;e[18]!==l?(p=l("gitView.header.identityTooltip"),e[18]=l,e[19]=p):p=e[19];let S;e[20]!==p?(S=t.jsx(xs,{sideOffset:8,children:p}),e[20]=p,e[21]=S):S=e[21];let M;e[22]!==S||e[23]!==j?(M=t.jsxs(ps,{children:[j,S]}),e[22]=S,e[23]=j,e[24]=M):M=e[24];let R;e[25]!==n?.id||e[26]!==r||e[27]!==o||e[28]!==l?(R=r.length===0?t.jsx("div",{className:"px-2 py-1.5",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:l("gitView.header.noProfiles")})}):r.map(T=>{const w=n?.id===T.id;return t.jsx(Bt,{onSelect:()=>o(T),children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(gr,{icon:T.icon,colorToken:T.color,className:"size-4"}),t.jsxs("span",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:T.name}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:T.userEmail})]}),w?t.jsx(E,{name:"check",className:"ml-auto size-4 text-foreground"}):null]})},T.id)}),e[25]=n?.id,e[26]=r,e[27]=o,e[28]=l,e[29]=R):R=e[29];let F;e[30]!==R?(F=t.jsx(qt,{align:"end",className:"w-64",children:R}),e[30]=R,e[31]=F):F=e[31];let U;return e[32]!==M||e[33]!==F?(U=t.jsxs(Ht,{children:[M,F]}),e[32]=M,e[33]=F,e[34]=U):U=e[34],U},bd=s=>{const e=_e.c(21),{comparison:n,trackingBranch:r,tooltipDelayMs:o}=s,a=o===void 0?1e3:o,{t:i}=nt(),d=`${n.remote}/${n.branch}`,l=n.ahead===0&&n.behind===0;let m;e[0]!==i||e[1]!==d||e[2]!==r?(m=r?i("gitView.header.upstreamTooltipTracking",{target:d,tracking:r}):i("gitView.header.upstreamTooltip",{target:d}),e[0]=i,e[1]=d,e[2]=r,e[3]=m):m=e[3];const u=m;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(E,{name:"git-branch",className:"size-3.5 shrink-0"}),e[4]=f):f=e[4];let b;e[5]!==d?(b=t.jsx("span",{className:"min-w-0 truncate text-foreground/80",children:d}),e[5]=d,e[6]=b):b=e[6];let h;e[7]!==n.ahead||e[8]!==n.behind||e[9]!==l||e[10]!==i?(h=l?t.jsx("span",{className:"tabular-nums text-muted-foreground",children:i("gitView.header.upstreamSynced")}):t.jsxs("span",{className:"inline-flex items-center gap-1 tabular-nums",children:[n.ahead>0?t.jsxs("span",{className:"text-[var(--status-info)]",children:["↑",n.ahead]}):null,n.behind>0?t.jsxs("span",{className:"text-[var(--status-warning)]",children:["↓",n.behind]}):null]}),e[7]=n.ahead,e[8]=n.behind,e[9]=l,e[10]=i,e[11]=h):h=e[11];let x;e[12]!==b||e[13]!==h?(x=t.jsx(gs,{asChild:!0,children:t.jsxs("div",{className:"inline-flex h-8 max-w-full items-center gap-1.5 rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 typography-micro text-muted-foreground",children:[f,b,h]})}),e[12]=b,e[13]=h,e[14]=x):x=e[14];let g;e[15]!==u?(g=t.jsx(xs,{sideOffset:8,children:u}),e[15]=u,e[16]=g):g=e[16];let j;return e[17]!==x||e[18]!==g||e[19]!==a?(j=t.jsxs(ps,{delayDuration:a,children:[x,g]}),e[17]=x,e[18]=g,e[19]=a,e[20]=j):j=e[20],j},xf=s=>{const e=_e.c(84),{directory:n,status:r,localBranches:o,remoteBranches:a,branchInfo:i,syncAction:d,remotes:l,onFetch:m,onSync:u,onRemoveRemote:f,removingRemoteName:b,onCheckoutBranch:h,onCreateBranch:x,onRenameBranch:g,activeIdentityProfile:j,availableIdentities:p,onSelectIdentity:S,isApplyingIdentity:M,isWorktreeMode:R,onOpenHistory:F,onOpenGraph:U,onOpenStashes:T,onOpenUpdateBranch:w,onOpenReintegrateCommits:H,pullRequest:P,prChecks:N,onOpenPullRequest:$,repositoryOptions:B,selectedRepository:G,onSelectRepository:J,repositoryRoot:L}=s,{t:_}=nt(),{isMobile:se}=bs();if(!r)return null;let ne;e[0]!==B?(ne=B??[],e[0]=B,e[1]=ne):ne=e[1];let V;e[2]!==ne?(V=ne.filter(Boolean),e[2]=ne,e[3]=V):V=e[3];const ee=V;let C;e[4]!==U||e[5]!==F||e[6]!==H||e[7]!==T||e[8]!==w||e[9]!==_?(C=F||U||T||w?t.jsxs(Ht,{children:[t.jsxs(ps,{children:[t.jsx(gs,{asChild:!0,children:t.jsx(Kt,{asChild:!0,children:t.jsx(ve,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":_("gitView.header.repositoryViews"),children:t.jsx(E,{name:"more-fill",className:"size-4"})})})}),t.jsx(xs,{sideOffset:8,children:_("gitView.header.repositoryViews")})]}),t.jsxs(qt,{align:"end",children:[F?t.jsxs(Bt,{onSelect:F,children:[t.jsx(E,{name:"history",className:"size-4"}),_("gitView.history.title")]}):null,U?t.jsxs(Bt,{onSelect:U,children:[t.jsx(E,{name:"git-branch",className:"size-4"}),_("gitView.graph.title")]}):null,T?t.jsxs(Bt,{onSelect:T,children:[t.jsx(E,{name:"archive-stack",className:"size-4"}),_("gitView.stashes.title")]}):null,w?t.jsxs(Bt,{onSelect:w,children:[t.jsx(E,{name:"git-merge",className:"size-4"}),_("gitView.header.updateBranch")]}):null,H?t.jsxs(Bt,{onSelect:H,children:[t.jsx(E,{name:"split-cells-horizontal",className:"size-4"}),_("gitView.integrate.title")]}):null]})]}):null,e[4]=U,e[5]=F,e[6]=H,e[7]=T,e[8]=w,e[9]=_,e[10]=C):C=e[10];let W;e[11]!==C?(W=t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:C}),e[11]=C,e[12]=W):W=e[12];const O=W,A=N?N.state==="success"?"var(--status-success)":N.state==="failure"?"var(--status-error)":"var(--status-warning)":null,z=P?P.state==="merged"?"merged":P.state==="closed"?"closed":P.draft?"draft":N?.state==="failure"||P.mergeable===!1||P.mergeableState==="blocked"||P.mergeableState==="dirty"?"blocked":"open":null;let v;e[13]!==$||e[14]!==A||e[15]!==z||e[16]!==P||e[17]!==_?(v=P&&$?t.jsxs(ps,{children:[t.jsx(gs,{asChild:!0,children:t.jsxs(ve,{variant:"ghost",size:"sm",onClick:$,className:"h-8 gap-1.5 px-2 typography-micro",children:[t.jsx(E,{name:"git-pull-request",className:"size-3.5",style:{color:`var(--pr-${z})`}}),t.jsx("span",{className:"tabular-nums text-foreground/80",children:_("gitView.pr.numberLabel",{number:P.number})}),A?t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:A}}):null]})}),t.jsx(xs,{sideOffset:8,children:_("gitView.header.openPullRequest")})]}):null,e[13]=$,e[14]=A,e[15]=z,e[16]=P,e[17]=_,e[18]=v):v=e[18];const Z=v,X=!r;let ie;e[19]!==r.tracking?(ie=r.tracking?.split("/")[0],e[19]=r.tracking,e[20]=ie):ie=e[20];const je=(r.files?.length??0)>0;let de;e[21]!==m||e[22]!==f||e[23]!==u||e[24]!==l||e[25]!==b||e[26]!==r.ahead||e[27]!==r.behind||e[28]!==d||e[29]!==X||e[30]!==ie||e[31]!==je?(de=t.jsx(hd,{syncAction:d,remotes:l,onFetch:m,onSync:u,onRemoveRemote:f,removingRemoteName:b,disabled:X,iconOnly:!0,aheadCount:r.ahead,behindCount:r.behind,trackingRemoteName:ie,hasUncommittedChanges:je}),e[21]=m,e[22]=f,e[23]=u,e[24]=l,e[25]=b,e[26]=r.ahead,e[27]=r.behind,e[28]=d,e[29]=X,e[30]=ie,e[31]=je,e[32]=de):de=e[32];const Re=de;let le;e[33]!==r.tracking||e[34]!==r.upstreamComparison?(le=r.upstreamComparison?t.jsx(bd,{comparison:r.upstreamComparison,trackingBranch:r.tracking,tooltipDelayMs:1e3}):null,e[33]=r.tracking,e[34]=r.upstreamComparison,e[35]=le):le=e[35];const me=le;let Te;e[36]!==j||e[37]!==p||e[38]!==M||e[39]!==S?(Te=t.jsx(yo,{activeProfile:j,identities:p,onSelect:S,isApplying:M,iconOnly:!0}),e[36]=j,e[37]=p,e[38]=M,e[39]=S,e[40]=Te):Te=e[40];const k=Te;let Y;e[41]!==i||e[42]!==n||e[43]!==se||e[44]!==R||e[45]!==o||e[46]!==h||e[47]!==x||e[48]!==g||e[49]!==a||e[50]!==l||e[51]!==r.ahead||e[52]!==r.current||e[53]!==r.files?.length||e[54]!==_?(Y=R&&!se?t.jsx(fd,{currentBranch:r.current,onRename:g}):t.jsx(ud,{directory:n,currentBranch:r.current,localBranches:o,remoteBranches:a,branchInfo:i,currentBranchAhead:r.ahead,onCheckout:h,onCreate:x,remotes:l,switchBlockedNotice:(r.files?.length??0)>0?_("gitView.branch.switchBlockedNotice"):null}),e[41]=i,e[42]=n,e[43]=se,e[44]=R,e[45]=o,e[46]=h,e[47]=x,e[48]=g,e[49]=a,e[50]=l,e[51]=r.ahead,e[52]=r.current,e[53]=r.files?.length,e[54]=_,e[55]=Y):Y=e[55];let q;e[56]!==J||e[57]!==ee||e[58]!==L||e[59]!==G?(q=ee.length>0&&J?t.jsx(pd,{repositories:ee,selectedRepository:G??null,onSelectRepository:J,repositoryRoot:L}):null,e[56]=J,e[57]=ee,e[58]=L,e[59]=G,e[60]=q):q=e[60];let ce;e[61]!==Y||e[62]!==q?(ce=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[Y,q]}),e[61]=Y,e[62]=q,e[63]=ce):ce=e[63];let pe;e[64]!==k?(pe=t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:k}),e[64]=k,e[65]=pe):pe=e[65];let Q;e[66]!==ce||e[67]!==pe?(Q=t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[ce,pe]}),e[66]=ce,e[67]=pe,e[68]=Q):Q=e[68];let ue;e[69]!==Z?(ue=Z?t.jsx("div",{className:"shrink-0",children:Z}):null,e[69]=Z,e[70]=ue):ue=e[70];let Ee;e[71]===Symbol.for("react.memo_cache_sentinel")?(Ee=t.jsx("div",{className:"min-w-0 flex-1"}),e[71]=Ee):Ee=e[71];let Pe;e[72]!==me?(Pe=me?t.jsx("div",{className:"min-w-0 shrink",children:me}):null,e[72]=me,e[73]=Pe):Pe=e[73];let he;e[74]!==Re?(he=t.jsx("div",{className:"shrink-0",children:Re}),e[74]=Re,e[75]=he):he=e[75];let Ie;e[76]!==O||e[77]!==ue||e[78]!==Pe||e[79]!==he?(Ie=t.jsxs("div",{className:"mt-3 flex h-8 min-w-0 items-center gap-2",children:[ue,Ee,Pe,O,he]}),e[76]=O,e[77]=ue,e[78]=Pe,e[79]=he,e[80]=Ie):Ie=e[80];let ke;return e[81]!==Q||e[82]!==Ie?(ke=t.jsxs("header",{className:"@container/git-header px-3 py-2 bg-transparent",children:[Q,Ie]}),e[81]=Q,e[82]=Ie,e[83]=ke):ke=e[83],ke},yd=s=>s==="/",qs=s=>s.replace(/\\/g,"/"),$n=s=>{if(!s||yd(s))return s;let e=s;for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e},es=s=>s.endsWith("/"),wd=s=>{const e=s.trim();return!e||es(e)?e:`${e}/`},Vn=s=>s.lastIndexOf("/"),wo=s=>{if(es(s))return s;const e=Vn(s);return e<0?s:s.slice(0,e+1)},vd=s=>{const e=Vn(s);return s.slice(e+1)},vo=s=>{const e=$n(s.trim());if(!e||e==="~"||e==="~/"||e==="/")return null;const n=Vn(e);return n<0?null:e.startsWith("~/")&&n<=1?"~/":n===0?"/":`${e.slice(0,n)}/`},jd=s=>es(s)&&vo(s)!==null,Sd=(s,e)=>`${wo(s)}${e}/`,zt=s=>{if(!s)return null;const e=$n(qs(s.trim()));return e?e.toLowerCase():null},xr=(s,e)=>{const n=s.trim();return n==="~"?e:n.startsWith("~/")?`${e}${n.slice(1)}`:n},Nd=s=>typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?s.metaKey&&!s.ctrlKey:s.ctrlKey&&!s.metaKey,un=s=>{if(!s)return;s.focus({preventScroll:!0});const e=s.value.length;s.setSelectionRange(e,e),s.scrollLeft=s.scrollWidth},kd=async()=>{try{const s=await Jt("/api/fs/home",{method:"GET",headers:{Accept:"application/json"}});if(s.ok){const e=await s.json();if(typeof e.home=="string"&&e.home.trim().length>0)return qs(e.home.trim())}}catch{}return fs.getFilesystemHome().catch(()=>null)},bf=({open:s,onOpenChange:e})=>{const{t:n}=nt(),r=ys(I=>I.homeDirectory),o=Et(I=>I.projects),a=Et(I=>I.addProject),i=Ke(I=>I.setSessionSwitcherOpen),d=ut(I=>I.openNewSessionDraft),l=Et(I=>I.addProjects),m=Qt(I=>I.profiles),u=Qt(I=>I.globalIdentity),f=Qt(I=>I.defaultGitIdentityId),b=Qt(I=>I.loadProfiles),h=Qt(I=>I.loadGlobalIdentity),x=Qt(I=>I.loadDefaultGitIdentityId),{canRequestAccess:g,requestAccess:j,startAccessing:p}=ld(),{isMobile:S}=bs(),M=c.useRef(null),R=c.useRef(null),F=c.useRef(new Map),[U,T]=c.useState(""),[w,H]=c.useState("~/"),[P,N]=c.useState([]),[$,B]=c.useState(!1),[G,J]=c.useState(!1),[L,_]=c.useState(null),[se,ne]=c.useState(0),[V,ee]=c.useState(0),[C,W]=c.useState(!1),[O,A]=c.useState(!1),[z,v]=c.useState(0),[Z,X]=c.useState(!1),[ie,je]=c.useState(""),[de,Re]=c.useState(null),[le,me]=c.useState(!1),[Te,k]=c.useState([]),Y=U||r,q=c.useMemo(()=>new Set(o.map(I=>zt(I.path)).filter(I=>!!I)),[o]);c.useEffect(()=>{if(!s)return;H("~/"),N([]),ee(0),W(!1),A(!1),X(!1),je(""),Re(null),me(!1),k([]),requestAnimationFrame(()=>un(M.current));let I=!1;return(async()=>{const ye=await kd();I||(T(ye||r||""),requestAnimationFrame(()=>un(M.current)))})(),()=>{I=!0}},[r,s]),c.useEffect(()=>{s&&(b(),h(),x())},[x,b,h,s]);const ce=c.useMemo(()=>{const I=new Map;u&&I.set(u.id,u);for(const oe of m)I.set(oe.id,oe);return Array.from(I.values())},[m,u]);c.useEffect(()=>{if(!s||!Z||de!==null)return;const I=typeof f=="string"?f.trim():"";if(I&&ce.some(ye=>ye.id===I)){Re(I);return}const oe=ce.find(ye=>ye.authType==="ssh"||ye.sshKey);oe&&Re(oe.id)},[ce,f,Z,s,de]);const pe=c.useMemo(()=>ce.find(I=>I.id===de)??null,[ce,de]),Q=c.useMemo(()=>wo(w),[w]),ue=c.useMemo(()=>es(w)?"":vd(w),[w]),Ee=c.useMemo(()=>Y?xr(Q,Y):"",[Q,Y]);c.useEffect(()=>{if(!s||!Ee){N([]),_(null);return}let I=!1;return B(!0),J(!1),_(null),fs.listLocalDirectory(Ee).then(oe=>{if(I)return;J(!1),_(null);const ye=oe.filter(Se=>Se.isDirectory).map(Se=>({name:Se.name,path:qs(Se.path)})).sort((Se,Ce)=>Se.name.localeCompare(Ce.name));N(ye)}).catch(oe=>{if(!I){N([]);const ye=Fi(oe)?oe.reason:"unknown";_(ye),J(ye==="not-found")}}).finally(()=>{I||B(!1)}),()=>{I=!0}},[Ee,se,s]);const Pe=c.useMemo(()=>{const I=ue.toLowerCase(),oe=le||ue.startsWith(".");return P.filter(ye=>ye.name.toLowerCase().startsWith(I)&&(oe||!ye.name.startsWith(".")))},[ue,P,le]),he=c.useMemo(()=>{const I=[];jd(w)&&I.push({type:"up",value:"browse:up",name:"..",path:vo(w)});for(const oe of Pe){const ye=zt(oe.path);I.push({type:"directory",value:`browse:${oe.path}`,name:oe.name,path:oe.path,disabled:!!(ye&&q.has(ye))})}return I},[q,Pe,w]);c.useEffect(()=>{ee(0)},[w,he.length]),c.useEffect(()=>{k([])},[Ee]);const Ie=c.useMemo(()=>Te.filter(I=>{const oe=zt(I);return!!(oe&&!q.has(oe))}),[q,Te]),ke=c.useCallback(I=>{k(oe=>oe.includes(I)?oe.filter(ye=>ye!==I):[...oe,I])},[]),Le=c.useMemo(()=>Y?$n(xr(w,Y)):"",[Y,w]),Ge=zt(Le),Je=!!(Ge&&q.has(Ge)),Ve=c.useMemo(()=>ue?Pe.find(I=>I.name===ue)??null:null,[ue,Pe]),Ye=!!(Le&&!Je&&(L===null||L==="not-found")&&(es(w)&&G||!es(w)&&ue.trim().length>0&&Ve===null)),Qe=!C&&!O&&L!=="os-permission"&&L!=="invalid-response"&&L!=="unknown"&&(!Z&&Ie.length>0||!Je&&!!Le),st=Qe&&ie.trim().length>0,qe=he[V]??null,Xe=!!(qe&&(qe.type==="up"||qe.type==="directory")),ot=Nn("mod"),Ze=!Z&&Ie.length>0?n("directoryExplorerDialog.actions.addSelected"):n(Je?"directoryExplorerDialog.actions.alreadyAdded":Z?C?"directoryExplorerDialog.actions.cloning":"directoryExplorerDialog.actions.cloneAndAdd":C?"directoryExplorerDialog.actions.adding":Ye?"directoryExplorerDialog.actions.createAndAdd":"directoryExplorerDialog.actions.addProject");c.useLayoutEffect(()=>{const I=R.current;if(!I)return;const oe=()=>v(Math.ceil(I.getBoundingClientRect().width));if(oe(),typeof ResizeObserver>"u")return;const ye=new ResizeObserver(oe);return ye.observe(I),()=>ye.disconnect()},[Ze]),c.useLayoutEffect(()=>{const I=M.current;I&&(I.scrollLeft=I.scrollWidth)},[z,w]),c.useLayoutEffect(()=>{s&&un(M.current)},[s]),c.useLayoutEffect(()=>{const I=he[V];I&&F.current.get(I.value)?.scrollIntoView({block:"nearest"})},[V,he]);const Ne=c.useCallback(()=>{e(!1)},[e]),ze=c.useCallback((I,oe)=>{S&&i(!1),d({selectedProjectId:I,directoryOverride:oe}),Ne()},[Ne,S,d,i]),$e=c.useCallback(async(I,oe)=>{I.stopPropagation();const ye=zt(oe);if(ye&&q.has(ye))return;const Se=await a(oe);if(!Se){ge.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}ze(Se.id,Se.path)},[a,q,ze,n]),He=c.useCallback(async I=>{if(C)return;const oe=zt(I),ye=Z?[]:Te.filter(Ce=>{const Fe=zt(Ce);return!!(Fe&&!q.has(Fe))});if(ye.length===0&&(!I||oe&&q.has(oe)))return;let Se=I;W(!0);try{const Ce=!Z&&Ye&&zt(I)===zt(Le);if(Z){const it=ie.trim();if(!it){ge.error(n("directoryExplorerDialog.toast.cloneUrlRequired"));return}Se=(await fs.cloneRepository({remoteUrl:it,destinationPath:I,gitIdentityId:pe?.id??null})).path}else if(ye.length>0){const it=await l(ye);if(it.length===0){ge.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}ge.success(n("directoryExplorerDialog.toast.addedProjects",{count:it.length})),k([]),Ne();return}else Ce&&await fs.createDirectory(I,{asProject:!0});const Fe=await a(Se);if(!Fe){ge.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}ze(Fe.id,Fe.path)}catch(Ce){ge.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:Ce instanceof Error?Ce.message:n("directoryExplorerDialog.toast.unknownError")})}finally{W(!1)}},[a,l,q,ie,Ne,Z,C,ze,pe?.id,Te,Ye,Le,n]),at=c.useCallback(I=>{H(wd(I))},[]),xe=c.useCallback(I=>{H(Sd(w,I.name))},[w]),et=c.useCallback(I=>{if(I){if(I.type==="up"){I.path&&at(I.path);return}xe(I)}},[at,xe]),pt=c.useCallback(async()=>{if(!(!g||O)){A(!0);try{const I=await j(Le);if(!I.success||!I.path){I.error&&I.error!=="Directory selection cancelled"&&ge.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:I.error});return}const oe=await p(I.path);if(!oe.success){ge.error(n("directoryExplorerDialog.toast.failedToOpenDirectory"),{description:oe.error||n("directoryExplorerDialog.toast.desktopCouldNotGrantAccess")});return}k([]),await He(I.path)}catch(I){ge.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:I instanceof Error?I.message:n("directoryExplorerDialog.toast.unknownError")})}finally{A(!1)}}},[g,He,O,j,p,n,Le]),gt=c.useCallback(I=>{if(I.key==="ArrowDown"){I.preventDefault(),ee(oe=>Math.min(he.length-1,oe+1));return}if(I.key==="ArrowUp"){I.preventDefault(),ee(oe=>Math.max(0,oe-1));return}if(I.key===" "){if(es(w)){I.preventDefault(),qe&&qe.type==="directory"&&!qe.disabled&&ke(qe.path);return}return}if(I.key==="Enter"){if(I.preventDefault(),Nd(I)){He(Le);return}Xe&&et(qe);return}I.key==="Backspace"&&w===""&&(I.preventDefault(),Ne())},[et,He,Ne,Xe,qe,w,he.length,Le,ke]),yt=t.jsxs("button",{type:"button",onClick:()=>me(I=>!I),className:"flex flex-shrink-0 items-center gap-2 rounded-lg px-2 py-1 typography-meta text-muted-foreground transition-colors hover:bg-interactive-hover/40",children:[le?t.jsx(E,{name:"checkbox",className:"h-4 w-4 text-primary"}):t.jsx(E,{name:"checkbox-blank",className:"h-4 w-4"}),n("directoryExplorerDialog.toggle.showHidden")]}),Dt=t.jsxs("div",{className:"px-2.5 py-1.5",children:[Z?t.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[t.jsx(Nt,{value:ie,onChange:I=>je(I.target.value),placeholder:n("directoryExplorerDialog.clone.remoteUrlPlaceholder"),className:"min-w-0 flex-1 border-border/60 bg-[var(--surface-elevated)] font-mono typography-ui-label shadow-none",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),t.jsx(yo,{activeProfile:pe,identities:ce,onSelect:I=>Re(I.id),isApplying:C,iconOnly:!0})]}):null,t.jsxs("div",{className:"relative",children:[t.jsx(E,{name:"folder-add",className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/80"}),t.jsx(Nt,{ref:M,value:w,onChange:I=>H(qs(I.target.value)),onKeyDown:gt,placeholder:n("directoryExplorerDialog.pathInput.placeholder"),className:"border-transparent bg-transparent pl-9 font-mono typography-ui-label shadow-none focus-visible:ring-0",style:!S&&z>0?{paddingRight:`${z+24}px`}:void 0,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),S?null:t.jsx(ve,{ref:R,variant:"outline",size:"xs",tabIndex:-1,className:"absolute right-1.5 top-1/2 h-7 -translate-y-1/2 gap-1 px-2 typography-meta",disabled:Z?!st:!Qe,onMouseDown:I=>I.preventDefault(),onClick:()=>{He(Le)},title:Ze,children:Ze})]})]}),y=t.jsx("div",{className:"relative min-h-0 flex-1 overflow-hidden rounded-xl border border-border/60 bg-[var(--surface-elevated)] shadow-sm",children:t.jsxs(Js,{outerClassName:"max-h-[min(28rem,58vh)]",className:"p-2",children:[t.jsx("div",{className:"px-2 pb-1 pt-0.5 typography-meta font-medium uppercase tracking-wide text-muted-foreground/80",children:n("directoryExplorerDialog.browse.directories")}),$?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.loading")}):L&&L!=="not-found"?t.jsxs("div",{className:"flex flex-col items-center gap-3 px-4 py-10 text-center",children:[t.jsx("div",{className:"typography-ui-label text-status-error",children:n(L==="os-permission"?"directoryExplorerDialog.browse.permissionDenied":"directoryExplorerDialog.browse.loadFailed")}),t.jsxs("div",{className:"flex items-center gap-2",children:[L==="os-permission"&&g?t.jsx(ve,{size:"xs",onClick:()=>{pt()},disabled:O,children:n("directoryExplorerDialog.browse.grantAccess")}):null,t.jsx(ve,{variant:"outline",size:"xs",onClick:()=>ne(I=>I+1),children:n("directoryExplorerDialog.browse.retry")})]})]}):he.length===0?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.empty")}):t.jsx("div",{className:"space-y-0.5",children:he.map((I,oe)=>{const ye=oe===V;return t.jsxs("button",{ref:Se=>{Se?F.current.set(I.value,Se):F.current.delete(I.value)},type:"button",onMouseEnter:()=>ee(oe),onMouseDown:Se=>Se.preventDefault(),onClick:()=>et(I),className:re("flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",ye&&"bg-interactive-selection text-interactive-selection-foreground",!ye&&"hover:bg-interactive-hover/50",I.type==="directory"&&I.disabled&&"opacity-45"),children:[I.type==="up"?t.jsx(E,{name:"arrow-left-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}):t.jsx(E,{name:"folder-6",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}),t.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:t.jsx("span",{className:"truncate typography-ui-label text-foreground",children:I.name})}),I.type==="directory"&&I.disabled?t.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 typography-meta text-muted-foreground",children:n("directoryExplorerDialog.browse.addedBadge")}):I.type==="directory"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onMouseDown:Se=>Se.stopPropagation(),onClick:Se=>{Se.stopPropagation(),ke(I.path)},title:n("directoryExplorerDialog.browse.selectForAdd"),"aria-label":n("directoryExplorerDialog.browse.selectForAdd"),"aria-pressed":Te.includes(I.path),className:"flex-shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",children:t.jsx(E,{name:Te.includes(I.path)?"checkbox":"checkbox-blank",className:"h-4 w-4"})}),t.jsx("button",{type:"button",onMouseDown:Se=>Se.stopPropagation(),onClick:Se=>$e(Se,I.path),className:"flex-shrink-0 rounded-full p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",title:n("directoryExplorerDialog.browse.quickAdd"),children:t.jsx(E,{name:"add",className:"h-3.5 w-3.5"})})]}):null]},I.value)})})]})}),K=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[Dt,y]}),Ae=t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-micro text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(E,{name:"arrow-up-s",className:"h-3.5 w-3.5"}),t.jsx(E,{name:"arrow-down-s",className:"-ml-1 h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.navigate")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(E,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.select")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{children:ot}),t.jsx(E,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.add")]})]}),Ue=()=>t.jsxs(t.Fragment,{children:[S?null:Ae,t.jsxs("div",{className:re("flex w-full flex-row justify-end gap-2 sm:w-auto",S&&"justify-stretch"),children:[g?t.jsx(ve,{variant:"ghost",size:"xs",onClick:pt,disabled:C||O||Z,children:n(O?"directoryExplorerDialog.actions.openingFinder":"directoryExplorerDialog.actions.openInFinder")}):null,t.jsx(ve,{variant:"ghost",size:"xs",onClick:()=>{X(I=>!I),k([])},disabled:C||O,className:re(S&&"flex-1"),children:n(Z?"directoryExplorerDialog.actions.addLocalProject":"directoryExplorerDialog.actions.cloneRepository")}),S?t.jsx(ve,{size:"xs",onClick:()=>{He(Le)},disabled:Z?!st:!Qe,className:"flex-1",children:Ze}):null]})]});return S?t.jsx(ms,{open:s,onClose:Ne,title:n("directoryExplorerDialog.title"),className:"h-[88dvh] max-h-[720px]",contentMaxHeightClassName:"flex-1",footer:t.jsx("div",{className:"flex flex-col gap-2",children:Ue()}),children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[t.jsx("div",{className:"flex justify-end",children:yt}),K]})}):t.jsx(Es,{open:s,onOpenChange:e,children:t.jsxs(Rs,{className:"flex w-full max-w-xl flex-col gap-0 overflow-hidden p-0 sm:max-h-[80vh]",initialFocus:!1,children:[t.jsx(Ys,{className:"px-5 pb-2 pt-5",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx(As,{children:n("directoryExplorerDialog.title")}),t.jsx(Pa,{className:"mt-2",children:n("directoryExplorerDialog.description")})]}),yt]})}),t.jsx("div",{className:"min-h-0 flex-1 px-2 pb-0",children:K}),t.jsx(An,{className:"flex w-full flex-col gap-3 px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:Ue()})]})})};function br(s){const{localBranches:e,remoteBranches:n,query:r}=s,o=r.trim();if(!o)return{matching:[],otherLocal:e,otherRemote:n};const a=[...e.map(l=>({label:l,value:l,source:"local"})),...n.map(l=>({label:l,value:`remotes/${l}`,source:"remote"}))],i=yn(a,o,l=>[l.label]),d=new Set(i);return{matching:i,otherLocal:a.filter(l=>l.source==="local"&&!d.has(l)).map(l=>l.label),otherRemote:a.filter(l=>l.source==="remote"&&!d.has(l)).map(l=>l.label)}}const mn="oc:lastWorktreeSourceBranch",Cd=({mode:s,sourceBranch:e,linkedPr:n,selectedBranch:r})=>s==="existing-branch"?r||null:n?null:e||null,Id=({branches:s,savedSourceBranch:e,rootBranch:n})=>!!(e&&s.includes(e))&&e?{sourceBranch:e,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&s.includes(n)?n:s.includes("main")?"main":s.includes("master")?"master":s[0]??"",shouldClearSavedSourceBranch:!!e};function Td({open:s,onOpenChange:e,onSelect:n}){const{t:r}=nt(),o=Ke(k=>k.isMobile),{github:a}=Xs(),i=Is(k=>k.status),d=Is(k=>k.hasChecked),l=Ke(k=>k.setSettingsDialogOpen),m=Ke(k=>k.setSettingsPage),u=Et(k=>k.getActiveProject()),f=u?.path??null,b=ae.useMemo(()=>f&&u?{id:u.id,path:f}:null,[u,f]),[h,x]=ae.useState("issues"),[g,j]=ae.useState(""),[p,S]=ae.useState([]),[M,R]=ae.useState([]),[F,U]=ae.useState(!1),[T,w]=ae.useState(!1),[H,P]=ae.useState(null),[N,$]=ae.useState(null),[B,G]=ae.useState(null),[J,L]=ae.useState(!1),[_,se]=ae.useState(new Map),[ne,V]=ae.useState(1),[ee,C]=ae.useState(!1),W=Ea(g,350),O=ae.useCallback(async k=>{if(!(!f||!a)&&!(d&&i?.connected===!1)){U(!0),P(null),V(1),C(!1);try{if(h==="issues"&&a.issuesList){const Y=await a.issuesList(f,{page:1,query:k});Y.connected===!1?(P(r("session.githubIntegration.error.notConnected")),S([])):(S(Y.issues??[]),V(Y.page??1),C(!!Y.hasMore))}else if(h==="prs"&&a.prsList){const Y=await a.prsList(f,{page:1,query:k});Y.connected===!1?(P(r("session.githubIntegration.error.notConnected")),R([])):(R(Y.prs??[]),V(Y.page??1),C(!!Y.hasMore))}}catch(Y){P(Y instanceof Error?Y.message:r("session.githubIntegration.error.loadDataFailed"))}finally{U(!1)}}},[f,a,d,i,h,r]);ae.useEffect(()=>{if(!s||!f||d&&i?.connected===!1||!a)return;if(!W.trim()){O();return}const k=new AbortController;U(!0),P(null),V(1),C(!1);const Y=h==="issues"&&a.issuesList?a.issuesList(f,{page:1,query:W.trim()}):h==="prs"&&a.prsList?a.prsList(f,{page:1,query:W.trim()}):null;if(!Y){U(!1);return}return Y.then(q=>{k.signal.aborted||("issues"in q?q.connected===!1?(P(r("session.githubIntegration.error.notConnected")),S([])):(S(q.issues??[]),V(q.page??1),C(!!q.hasMore)):"prs"in q&&(q.connected===!1?(P(r("session.githubIntegration.error.notConnected")),R([])):(R(q.prs??[]),V(q.page??1),C(!!q.hasMore))))}).catch(q=>{k.signal.aborted||P(q instanceof Error?q.message:r("session.githubIntegration.error.loadDataFailed"))}).finally(()=>{k.signal.aborted||U(!1)}),()=>k.abort()},[s,f,a,d,i,h,W,O,r]);const A=ae.useCallback(async()=>{if(!(!f||!a)&&!(F||T)&&ee){w(!0);try{const k=ne+1;if(h==="issues"&&a.issuesList){const Y=W.trim()?await a.issuesList(f,{page:k,query:W.trim()}):await a.issuesList(f,{page:k});Y.connected!==!1&&(S(q=>[...q,...Y.issues??[]]),V(Y.page??k),C(!!Y.hasMore))}else if(h==="prs"&&a.prsList){const Y=W.trim()?await a.prsList(f,{page:k,query:W.trim()}):await a.prsList(f,{page:k});Y.connected!==!1&&(R(q=>[...q,...Y.prs??[]]),V(Y.page??k),C(!!Y.hasMore))}}catch{}finally{w(!1)}}},[f,a,h,ne,ee,F,T,W]);ae.useEffect(()=>{if(!s){x("issues"),j(""),S([]),R([]),$(null),G(null),L(!1),P(null),se(new Map),V(1),C(!1);return}O()},[s,O]);const z=ae.useCallback(async k=>{if(!(!b||!k)&&!_.has(k))try{const q=(await Fr(b,{mode:"new",branchName:k,worktreeName:k})).errors.find(ce=>ce.code==="branch_in_use");se(ce=>new Map(ce).set(k,{isValid:!q,error:q?r(q.code==="branch_exists"?"session.githubIntegration.validation.branchAlreadyExists":"session.githubIntegration.validation.branchAlreadyCheckedOut"):null}))}catch{se(Y=>new Map(Y).set(k,{isValid:!1,error:r("session.githubIntegration.validation.failed")}))}},[b,_,r]);ae.useEffect(()=>{!s||h!=="prs"||M.forEach(k=>{k.head&&z(k.head)})},[s,h,M,z]);const v=d&&i?.connected===!0,Z=()=>{m("integrations"),l(!0)},X=k=>{$(k),G(null)},ie=k=>{G(k),$(null)},je=()=>{N?n({type:"issue",item:N}):B&&n({type:"pr",item:B,includeDiff:J}),e(!1)},de=()=>{$(null),G(null),L(!1)},Re=N||B&&_.get(B.head??"")?.isValid!==!1,le=k=>k.head?_.get(k.head)?.isValid===!1:!0,me=t.jsx(t.Fragment,{children:v?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative mt-2",children:[t.jsx(E,{name:"search",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(Nt,{value:g,onChange:k=>j(k.target.value),placeholder:r(h==="issues"?"session.githubIntegration.search.issuesPlaceholder":"session.githubIntegration.search.prsPlaceholder"),className:"h-8 pl-9"})]}),t.jsx("div",{className:"mt-2 h-[300px] overflow-hidden",children:t.jsxs(Js,{outerClassName:"h-full",disableHorizontal:!0,children:[F&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(E,{name:"loader-4",className:"h-5 w-5 animate-spin text-muted-foreground"})}),H&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-destructive/10 text-destructive",children:[t.jsx(E,{name:"error-warning",className:"h-4 w-4"}),t.jsx("span",{className:"typography-small",children:H})]})}),!F&&!H&&h==="issues"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[p.length>0?p.map(k=>t.jsx("button",{onClick:()=>X(k),className:re("w-full text-left px-2 py-1.5 rounded transition-colors",N?.number===k.number?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"text-muted-foreground shrink-0 typography-micro",children:["#",k.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-2",children:k.title}),k.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info mt-0.5 inline-block",children:[k.sourceRepo.owner,"/",k.sourceRepo.repo]}):null]})]})},`${k.sourceRepo?.owner??""}-${k.sourceRepo?.repo??""}-${k.number}`)):t.jsx("div",{className:"flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground",children:r("session.githubIntegration.empty.noIssuesFound")}),ee&&!T&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>{A()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),T&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]}),!F&&!H&&h==="prs"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[M.length>0?M.map(k=>{const Y=le(k),q=k.head?_.get(k.head):void 0;return t.jsx("button",{onClick:()=>!Y&&ie(k),disabled:Y,className:re("w-full text-left px-2 py-1.5 rounded transition-colors",B?.number===k.number?"bg-interactive-selection text-interactive-selection-foreground":Y?"opacity-50 cursor-not-allowed":"hover:bg-interactive-hover"),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"text-muted-foreground shrink-0 typography-micro",children:["#",k.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-1",children:k.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[k.head," → ",k.base]}),k.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info",children:[k.sourceRepo.owner,"/",k.sourceRepo.repo]}):null,Y&&q?.error&&t.jsx("span",{className:"typography-micro text-destructive",children:q.error})]})]})]})},`${k.sourceRepo?.owner??""}-${k.sourceRepo?.repo??""}-${k.number}`)}):t.jsx("div",{className:"flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground",children:r("session.githubIntegration.empty.noPullRequestsFound")}),ee&&!T&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>{A()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),T&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]})]})})]}):t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 gap-4",children:[t.jsx(E,{name:"github",className:"h-12 w-12 text-muted-foreground"}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:r("session.githubIntegration.connect.title")}),t.jsx("p",{className:"typography-small text-muted-foreground mt-1",children:r("session.githubIntegration.connect.description")})]}),t.jsx(ve,{onClick:Z,size:"sm",children:r("session.githubIntegration.connect.action")})]})}),Te=t.jsxs("div",{className:re("w-full",o?"flex flex-col gap-2":"flex flex-row items-center"),children:[t.jsxs("div",{className:re("flex items-center gap-4",o?"w-full justify-center order-1":"flex-1"),children:[!o&&(N||B)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 h-8 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate max-w-[150px]",children:N?r("session.githubIntegration.selected.issueNumber",{number:N.number}):r("session.githubIntegration.selected.prNumber",{number:B?.number??""})}),t.jsx("button",{onClick:de,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),h==="prs"&&B&&t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer h-8",children:[t.jsx(hs,{checked:J,onChange:k=>L(k),ariaLabel:r("session.githubIntegration.includeDiffAria")}),t.jsx("span",{className:"typography-small text-foreground",children:r("session.githubIntegration.includeDiff")})]})]}),t.jsxs("div",{className:re("flex gap-2",o?"w-full order-2":"justify-end"),children:[t.jsx(ve,{variant:"outline",size:"sm",onClick:()=>e(!1),className:re(o&&"flex-1"),children:r("session.githubIntegration.actions.cancel")}),t.jsx(ve,{size:"sm",onClick:je,disabled:!Re,className:re(o&&"flex-1"),children:r("session.githubIntegration.actions.select")})]})]});return t.jsx(t.Fragment,{children:o?t.jsx(ms,{open:s,title:r("session.githubIntegration.title"),onClose:()=>e(!1),footer:v?Te:void 0,renderHeader:k=>t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2 border-b border-border/40",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:r("session.githubIntegration.title")}),k]}),t.jsx("div",{className:"w-full",children:t.jsx(Ds,{items:[{id:"issues",label:r("session.githubIntegration.tabs.issues"),icon:t.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(E,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:h,onSelect:Y=>{x(Y),j("")},variant:"active-pill",layoutMode:"fit"})}),(N||B)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate flex-1",children:N?r("session.githubIntegration.selected.issueNumber",{number:N.number}):r("session.githubIntegration.selected.prNumber",{number:B?.number??""})}),t.jsx("button",{onClick:de,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]})]}),children:me}):t.jsx(Es,{open:s,onOpenChange:e,children:t.jsxs(Rs,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsx(Ys,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(As,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(E,{name:"github",className:"h-5 w-5"}),r("session.githubIntegration.title")]}),t.jsx("div",{className:"w-[220px]",children:t.jsx(Ds,{items:[{id:"issues",label:r("session.githubIntegration.tabs.issues"),icon:t.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(E,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:h,onSelect:k=>{x(k),j("")},variant:"active-pill",layoutMode:"fit"})})]})}),me,t.jsx(An,{className:"mt-1",children:Te})]})})})}const Ns=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,""),Dd=s=>String(s).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"pr-head",yr=(s,e,n)=>{const r=Ns(s.head||"");if(!r)throw new Error("PR head branch is missing");if(e.includes(r))return{existingBranch:r,setUpstream:void 0,upstreamRemote:void 0,upstreamBranch:void 0,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:r};const o=n.find(m=>{const u=m.indexOf("/");return u<=0||u>=m.length-1?!1:m.slice(u+1)===r});if(o){const m=o.indexOf("/"),u=o.slice(0,m);return{existingBranch:`remotes/${o}`,setUpstream:!0,upstreamRemote:u,upstreamBranch:r,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${u}/${r}`}}const a=String(s.headLabel||"").split(":")[0]?.trim(),i=s.headRepo?.owner||a||"pr-head",d=`pr-${Dd(i)}`,l=s.headRepo?.cloneUrl||s.headRepo?.sshUrl||"";if(!l)throw new Error("PR head repository URL is unavailable. The fork may have been deleted; push the branch to a reachable repository and try again.");return{existingBranch:`remotes/${d}/${r}`,setUpstream:!0,upstreamRemote:d,upstreamBranch:r,ensureRemoteName:d,ensureRemoteUrl:l,sourceLabel:`${d}/${r}`}},St=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,"").split("/").join("-").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"").slice(0,80),Pd=s=>{const e={repo:s.repo??null,issue:s.issue,comments:s.comments};return`GitHub issue context (JSON)
|
|
3
|
-
${JSON.stringify(e,null,2)}`},Ed=s=>`GitHub pull request context (JSON)
|
|
4
|
-
${JSON.stringify(s,null,2)}`,Rd=s=>{const e={issue:s.issue,comments:s.comments};return`Linear issue context (JSON)
|
|
5
|
-
${JSON.stringify(e,null,2)}`};function yf({open:s,onOpenChange:e,onWorktreeCreated:n}){const{t:r}=nt(),{github:o,git:a,linear:i}=Xs(),d=Ke(y=>y.isMobile),l=Is(y=>y.status),m=Is(y=>y.hasChecked),u=kn(y=>y.status),f=kn(y=>y.hasChecked),b=Et(y=>y.getActiveProject()),h=b?.path??null,x=ae.useMemo(()=>h&&b?{id:b.id,path:h}:null,[b,h]),[g,j]=ae.useState("new-branch"),[p,S]=ae.useState({branchName:"",worktreeName:"",isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1}),[M,R]=ae.useState({selectedBranch:"",worktreeName:""}),F=Ra(h),U=Aa(h),T=Mn(y=>y.fetchBranches),w=ae.useMemo(()=>F?.all?F.all.filter(y=>!y.startsWith("remotes/")).sort():[],[F]),H=ae.useMemo(()=>F?.all?F.all.filter(y=>y.startsWith("remotes/")).map(y=>y.replace(/^remotes\//,"")).sort():[],[F]),P=ut(y=>y.availableWorktreesByProject),N=ae.useMemo(()=>{if(!h)return new Set;const y=P.get(h)??[];return new Set(y.map(K=>K.name))},[P,h]),$=ae.useCallback((y=10)=>{for(let K=0;K<y;K++){const Ae=Bs();if(!N.has(Ae))return Ae}return`${Bs()}-${Date.now().toString(36).slice(-4)}`},[N]),[B,G]=ae.useState(!1),[J,L]=ae.useState(!1),[_,se]=ae.useState(!1),[ne,V]=ae.useState(!1),[ee,C]=ae.useState(!1),[W,O]=ae.useState(!1),[A,z]=ae.useState(""),[v,Z]=ae.useState(""),X=ae.useRef(null),ie=ae.useRef(null),je=ae.useRef(null),de=ae.useRef(null),Re=ae.useCallback(y=>{y.stopPropagation()},[]),le=ae.useCallback(y=>{let K=y;for(;K&&K!==document.body;){const{overflowY:Ae}=window.getComputedStyle(K);if((Ae==="auto"||Ae==="scroll")&&K.scrollHeight>K.clientHeight)return K;K=K.parentElement}return null},[]),me=ae.useCallback(y=>{y&&(y.scrollTop=0)},[]),Te=ae.useCallback(y=>{const K=y.current?.querySelector('[data-slot="command-list"]')??null;me(K)},[me]),k=ae.useCallback(y=>{const K=le(y.current);me(K)},[le,me]),Y=ae.useMemo(()=>br({localBranches:w,remoteBranches:H,query:A}),[w,H,A]),q=ae.useMemo(()=>br({localBranches:w,remoteBranches:H,query:v}),[w,H,v]),ce=A.trim().length>0,pe=v.trim().length>0,Q=Y.matching.length>0,ue=q.matching.length>0,Ee=!!(h&&a),Pe=ae.useCallback(()=>{!h||!a||T(h,a)},[h,a,T]);ae.useEffect(()=>{!s||!h||!a||F?.all||T(h,a)},[s,h,a,F?.all,T]),ae.useEffect(()=>{!_&&!ee&&z("")},[_,ee]),ae.useEffect(()=>{!ne&&!W&&Z("")},[ne,W]),ae.useEffect(()=>{_&&Te(X),ee&&k(je)},[_,ee,A,Te,k]),ae.useEffect(()=>{ne&&Te(ie),W&&k(de)},[ne,W,v,Te,k]);const[he,Ie]=ae.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[ke,Le]=ae.useState(!1),[Ge,Je]=ae.useState(null),Ve=ae.useRef(!1),Ye=ae.useCallback(()=>{const y=Tt.getState(),K=y.getVisibleAgents();if(y.settingsDefaultAgent){const Ae=K.find(Ue=>Ue.name===y.settingsDefaultAgent);if(Ae)return Ae.name}return K.find(Ae=>Ae.name==="build")?.name||K[0]?.name},[]),Qe=ae.useCallback(()=>{const y=Tt.getState(),K=y.settingsDefaultModel;if(!K)return null;const Ae=Lr(K);if(!Ae)return null;const{providerId:Ue,modelId:I}=Ae;return y.getModelMetadata(Ue,I)?{providerID:Ue,modelID:I}:null},[]),st=ae.useCallback((y,K)=>{const Ae=Tt.getState(),Ue=Ae.settingsDefaultVariant,I=Ae.currentProviderId===y&&Ae.currentModelId===K?Ae.currentVariant:void 0,Se=Ae.providers.find(Ce=>Ce.id===y)?.models.find(Ce=>Ce.id===K)?.variants;if(!Se)return Ue||I||void 0;if(Ue&&Object.prototype.hasOwnProperty.call(Se,Ue))return Ue;if(I&&Object.prototype.hasOwnProperty.call(Se,I))return I},[]),qe=ae.useCallback(async y=>{const K=Tt.getState(),Ae=Or.getState().lastUsedProvider,Ue=Qe(),I=Ue?.providerID||K.currentProviderId||Ae?.providerID,oe=Ue?.modelID||K.currentModelId||Ae?.modelID,ye=Ye()||K.currentAgentName||void 0;if(!I||!oe){ge.error(r("session.newWorktree.error.noModelSelected"));return}const Se=st(I,oe);if(y.linearIssue){if(!i?.issueGet)return;const Ce=await i.issueGet(y.linearIssue.identifier);if(Ce.connected===!1||!Ce.issue)throw new Error("Failed to load issue context");const Fe=Ce.issue,it=Fe.comments??[],ct=Fe.assignee?.displayName||Fe.assignee?.name,jt=await _t("linear.issue.review.visible",{identifier:Fe.identifier}),vt=await _t("linear.issue.review.instructions"),xt=Rd({issue:Fe,comments:it});Ma(i,{sessionId:y.sessionId,issueIdentifier:Fe.identifier}),await ut.getState().sendMessage(jt,I,oe,ye,void 0,void 0,[{text:vt,synthetic:!0},{text:xt,synthetic:!0}],Se,void 0,{sessionId:y.sessionId,directory:y.directory}),rn(y.sessionId,y.directory,La({identifier:Fe.identifier,title:Fe.title,url:Fe.url,author:ct?{login:ct,avatarUrl:Fe.assignee?.avatarUrl||void 0}:y.linearIssue.author,linkedAt:Date.now()}),!0).catch(()=>{}),ge.success(r("session.newWorktree.toast.sessionFromIssue"));return}if(!(!h||!o)){if(y.issue){if(!o.issueGet||!o.issueComments)return;const Ce=await o.issueGet(h,y.issue.number,{sourceRepo:y.issue.sourceRepo??null});if(Ce.connected===!1||!Ce.repo||!Ce.issue)throw new Error("Failed to load issue context");const Fe=await o.issueComments(h,y.issue.number,{sourceRepo:y.issue.sourceRepo??null});if(Fe.connected===!1)throw new Error("Failed to load issue comments");const it=await _t("github.issue.review.visible",{issue_number:String(y.issue.number)}),ct=await _t("github.issue.review.instructions"),jt=Pd({repo:Ce.repo,issue:Ce.issue,comments:Fe.comments??[]});await ut.getState().sendMessage(it,I,oe,ye,void 0,void 0,[{text:ct,synthetic:!0},{text:jt,synthetic:!0}],Se,void 0,{sessionId:y.sessionId}),rn(y.sessionId,y.directory,Kn({url:Ce.issue.url,number:Ce.issue.number,title:Ce.issue.title,kind:"issue",author:Ce.issue.author,linkedAt:Date.now()}),!0).catch(()=>{}),ge.success(r("session.newWorktree.toast.sessionFromIssue"));return}if(y.pr){if(!o.prContext)return;const Ce=await o.prContext(h,y.pr.number,{sourceRepo:y.pr.sourceRepo??null,includeDiff:y.includeDiff,includeCheckDetails:!1});if(Ce.connected===!1||!Ce.repo||!Ce.pr)throw new Error("Failed to load PR context");const Fe=await _t("github.pr.review.visible",{pr_number:String(y.pr.number)}),it=await _t("github.pr.review.instructions"),ct=Ed(Ce);await ut.getState().sendMessage(Fe,I,oe,ye,void 0,void 0,[{text:it,synthetic:!0},{text:ct,synthetic:!0}],Se,void 0,{sessionId:y.sessionId}),rn(y.sessionId,y.directory,Kn({url:Ce.pr.url,number:Ce.pr.number,title:Ce.pr.title,kind:"pull",author:Ce.pr.author,linkedAt:Date.now()}),!0).catch(()=>{}),ge.success(r("session.newWorktree.toast.sessionFromPr"))}}},[o,i,h,Ye,Qe,st,r]),Xe=g==="new-branch"?p:M;ae.useEffect(()=>{if(!s||!F?.all||!h||p.sourceBranch)return;const y=p.sourceBranch;let K=!1;return(async()=>{try{const Ue=await Fa(h).catch(()=>null);if(K)return;const I=localStorage.getItem(mn),{sourceBranch:oe,shouldClearSavedSourceBranch:ye}=Id({branches:F.all,savedSourceBranch:I,rootBranch:Ue});if(ye&&localStorage.removeItem(mn),K||y)return;oe&&S(Se=>({...Se,sourceBranch:oe}))}catch{}})(),()=>{K=!0}},[s,F?.all,h,p.sourceBranch]),ae.useLayoutEffect(()=>{if(!s){Ve.current=!1;return}if(Ve.current)return;Ve.current=!0,j("new-branch"),R({selectedBranch:"",worktreeName:""}),se(!1),V(!1),C(!1),O(!1),z(""),Z(""),Ie({isValidating:!1,branchError:null,worktreeError:null,touched:!1});const y=$();S({branchName:y,worktreeName:y,isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1})},[s,$]),ae.useEffect(()=>{if(g!=="new-branch"||!p.isSyncingWorktreeName)return;const y=Ns(p.branchName),K=St(y);S(Ae=>({...Ae,worktreeName:K}))},[g,p.branchName,p.isSyncingWorktreeName]);const ot=ae.useCallback(async()=>{if(!x||!he.touched||ke)return;Ge&&Ge.abort();const y=new AbortController;Je(y),Ie(K=>({...K,isValidating:!0}));try{const K=g==="new-branch"?p.branchName:M.selectedBranch,Ae=Xe.worktreeName,Ue=Ns(K),I=St(Ae);let oe=null,ye=null;if(Ue||(oe=r("session.newWorktree.error.branchNameRequired")),I||(ye=r("session.newWorktree.error.worktreeDirectoryRequired")),Ue&&I){const Se=g==="new-branch"?p.linkedPr:null,Ce=Se?yr(Se,w,H):null,Fe={mode:g==="existing-branch"||Ce?"existing":"new",branchName:Ue,worktreeName:I,existingBranch:Ce?.existingBranch??(g==="existing-branch"?Ue:void 0)};Ce?.ensureRemoteName&&(Fe.ensureRemoteName=Ce.ensureRemoteName),Ce?.ensureRemoteUrl&&(Fe.ensureRemoteUrl=Ce.ensureRemoteUrl);const it=await Fr(x,Fe);if(y.signal.aborted)return;it.ok||it.errors.forEach(ct=>{if(ct.code==="worktree_exists"){ye=ye??ct.message;return}ct.code.startsWith("branch_")&&(oe=oe??ct.message)})}y.signal.aborted||Ie(Se=>({...Se,isValidating:!1,branchError:oe,worktreeError:ye}))}catch{y.signal.aborted||Ie(K=>({...K,isValidating:!1}))}},[x,g,p.branchName,p.linkedPr,M.selectedBranch,Xe.worktreeName,w,H,he.touched,Ge,ke,r]),Ze=g==="new-branch"?p.branchName:M.selectedBranch;ae.useEffect(()=>{if(!s||!x||!he.touched||ke)return;const y=setTimeout(()=>{ot()},300);return()=>clearTimeout(y)},[Xe.worktreeName,Ze,s,x,ot,he.touched,ke]);const Ne=async()=>{if(!x||!h){ge.error(r("session.newWorktree.error.noActiveProject"));return}Ie(I=>({...I,touched:!0}));const y=g==="new-branch"?p.branchName:M.selectedBranch,K=Xe.worktreeName,Ae=Ns(y),Ue=St(K);if(!Ae){ge.error(r("session.newWorktree.error.branchNameRequired"));return}if(!Ue){ge.error(r("session.newWorktree.error.worktreeDirectoryRequired"));return}Ge&&(Ge.abort(),Je(null)),Ie(I=>({...I,isValidating:!1,branchError:null,worktreeError:null})),Le(!0);try{const I=g==="new-branch"?p.linkedPr:null,oe=g==="new-branch"?p.linkedIssue:null,ye=g==="new-branch"?p.linkedLinearIssue:null,Se=g==="new-branch"?p.linkedPr:null,Ce=g==="new-branch"?p.includePrDiff:!1,Fe=!!(oe||Se||ye),it=await Oa(x),ct=p.sourceBranch;let jt="";const vt=(()=>{if(I){const Be=yr(I,w,H);jt=Be.sourceLabel;const tt={preferredName:Ae||Ue,mode:"existing",branchName:Ae,worktreeName:Ue,existingBranch:Be.existingBranch,setupCommands:it,setUpstream:Be.setUpstream,upstreamRemote:Be.upstreamRemote,upstreamBranch:Be.upstreamBranch,returnAfterDirectoryCreated:!0};return Be.ensureRemoteName&&(tt.ensureRemoteName=Be.ensureRemoteName),Be.ensureRemoteUrl&&(tt.ensureRemoteUrl=Be.ensureRemoteUrl),tt}jt=g==="new-branch"?ct:"";const fe={preferredName:Ae||Ue,mode:g==="existing-branch"?"existing":"new",branchName:g==="existing-branch"?void 0:Ae,worktreeName:Ue,existingBranch:g==="existing-branch"?Ae:void 0,setupCommands:it,returnAfterDirectoryCreated:!0};return ct&&g==="new-branch"&&(fe.startRef=ct),fe})(),xt=await $a(x,vt);let bt=null;if(Fe){await Va(x)&&await Wa(xt.path);const fe=ye?`${ye.identifier} ${ye.title}`.trim():oe?`#${oe.number} ${oe.title}`.trim():Se?`#${Se.number} ${Se.title}`.trim():r("session.newWorktree.newSessionTitle"),Be=await za(fe,xt.path,null);if(!Be?.id)throw new Error("Failed to create session");bt=Be.id,n?.(xt.path,{sessionId:bt}),e(!1),Le(!1),Ua(Be.id,fe).catch(()=>{});try{ut.getState().initializeNewAiWorkerSession(Be.id,Tt.getState().agents)}catch{}}else e(!1),Le(!1);const We=Cd({mode:g,sourceBranch:p.sourceBranch,linkedPr:!!p.linkedPr,selectedBranch:M.selectedBranch});We&&localStorage.setItem(mn,We),ge.success(r("session.newWorktree.toast.worktreeCreated"),{description:r("session.newWorktree.toast.worktreeCreatedDescription",{target:`${xt.branch||xt.name}${jt?` ${r("session.newWorktree.fromSource",{source:jt})}`:""}`})}),bt?qe({sessionId:bt,directory:xt.path,issue:oe,pr:Se,linearIssue:ye,includeDiff:Ce}).catch(fe=>{const Be=r(ye?"session.newWorktree.error.sendLinearContextFailed":"session.newWorktree.error.sendGitHubContextFailed"),tt=fe instanceof Error?fe.message:Be;ge.error(Be,{description:tt})}):n?.(xt.path)}catch(I){const oe=I instanceof Error?I.message:r("session.newWorktree.error.createWorktreeFailed");ge.error(r("session.newWorktree.error.createWorktreeFailed"),{description:oe})}finally{Le(!1)}},ze=y=>{j(y),Ie(K=>({...K,touched:!1,branchError:null,worktreeError:null}))},$e=y=>{if(!y){S(K=>({...K,linkedIssue:null,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1,branchName:""}));return}if(y.type==="issue"){const K=y.item,Ae=`issue-${K.number}-${Bs()}`;S(Ue=>({...Ue,linkedIssue:K,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1,branchName:Ae,worktreeName:St(Ae),isSyncingWorktreeName:!0}))}else if(y.type==="pr"){const K=y.item;S(Ae=>({...Ae,linkedPr:K,linkedIssue:null,linkedLinearIssue:null,includePrDiff:y.includeDiff??!1,branchName:K.head,worktreeName:St(K.head),isSyncingWorktreeName:!0}))}},He=y=>{const K=`issue-${y.identifier}-${Bs()}`;S(Ae=>({...Ae,linkedLinearIssue:{identifier:y.identifier,title:y.title,url:y.url,author:y.author},linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:K,worktreeName:St(K),isSyncingWorktreeName:!0}))},at=m&&l?.connected===!0,xe=!!i&&f&&u?.connected===!0,pt=(g==="existing-branch"?!!M.selectedBranch&&!!M.worktreeName&&!he.branchError&&!he.worktreeError:!!Ns(p.branchName)&&!!p.worktreeName&&!he.branchError&&!he.worktreeError)&&!ke,gt=()=>{S(y=>({...y,linkedIssue:null,linkedPr:null,linkedLinearIssue:null,branchName:"",includePrDiff:!1,isSyncingWorktreeName:!0}))},yt=g==="new-branch"&&(at||xe)?t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[at&&t.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>G(!0),className:"h-8 w-8 px-0",title:r("session.newWorktree.actions.startFromGitHubIssuePr"),"aria-label":r("session.newWorktree.actions.startFromGitHubIssuePr"),children:t.jsx(E,{name:"github",className:"size-4 text-status-success"})}),xe&&t.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>L(!0),className:"h-8 w-8 px-0",title:r("session.newWorktree.actions.startFromLinearIssue"),"aria-label":r("session.newWorktree.actions.startFromLinearIssue"),children:t.jsx(E,{name:"linear",className:"size-4"})})]}):null,Dt=t.jsxs("div",{className:re("flex gap-2",d?"flex-col w-full":"flex-row items-center"),children:[t.jsx("div",{className:re("flex items-center gap-1.5 text-destructive",d?"w-full justify-center order-first":"mr-auto"),children:he.touched&&(he.branchError||he.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(E,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:he.branchError||he.worktreeError})]})}),t.jsxs("div",{className:re("flex gap-2",d&&"w-full"),children:[t.jsx(ve,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:ke,className:re(d&&"flex-1"),children:r("session.newWorktree.actions.cancel")}),t.jsxs(ve,{size:"sm",onClick:Ne,disabled:!pt||ke,className:re("gap-1.5",d&&"flex-1"),children:[ke&&t.jsx(E,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(ke?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]});return t.jsxs(t.Fragment,{children:[d?t.jsxs(ms,{open:s,title:r("session.newWorktree.title"),onClose:()=>e(!1),footer:Dt,children:[t.jsx("div",{className:"w-full mb-4",children:t.jsx(Ds,{items:[{id:"new-branch",label:r("session.newWorktree.mode.newBranch"),icon:t.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(E,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:g,onSelect:y=>{(y==="new-branch"||y==="existing-branch")&&ze(y)},variant:"active-pill",layoutMode:"fit",className:"w-full"})}),t.jsxs("div",{className:"space-y-6",children:[g==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(ve,{variant:"outline",size:"sm",onClick:()=>C(!0),className:"flex-1 justify-between h-9",children:[t.jsx("span",{className:M.selectedBranch?"text-foreground":"text-muted-foreground",children:M.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(E,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(ve,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:Pe,disabled:!Ee||U,title:r("session.newWorktree.fetchBranches"),children:U?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"refresh",className:"size-4"})})]}),t.jsx(ms,{open:ee,title:r("session.newWorktree.selectBranch"),onClose:()=>C(!1),children:t.jsxs("div",{className:"space-y-4",ref:je,children:[t.jsx(Nt,{value:A,onChange:y=>z(y.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),U?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&H.length===0?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noBranchesFound")}):t.jsxs("div",{className:"space-y-4",children:[ce&&Q&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:Y.matching.map(y=>t.jsx("button",{onClick:()=>{R(K=>({...K,selectedBranch:y.value,worktreeName:St(y.label)})),Ie(K=>({...K,touched:!0})),C(!1)},className:re("w-full text-left px-3 py-2.5 rounded-md transition-colors",M.selectedBranch===y.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y.label})},`${y.source}-${y.value}`))})]}),ce&&!Q&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!ce&&Y.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:Y.otherLocal.map(y=>t.jsx("button",{onClick:()=>{R(K=>({...K,selectedBranch:y,worktreeName:St(y)})),Ie(K=>({...K,touched:!0})),C(!1)},className:re("w-full text-left px-3 py-2.5 rounded-md transition-colors",M.selectedBranch===y?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y})},y))})]}),!ce&&Y.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:Y.otherRemote.map(y=>t.jsx("button",{onClick:()=>{R(K=>({...K,selectedBranch:`remotes/${y}`,worktreeName:St(y)})),Ie(K=>({...K,touched:!0})),C(!1)},className:re("w-full text-left px-3 py-2.5 rounded-md transition-colors",M.selectedBranch===`remotes/${y}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y})},`remotes/${y}`))})]})]})]})})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold shrink-0",children:r("session.newWorktree.branchName")}),yt]}),t.jsx(Nt,{value:p.branchName,onChange:y=>{S(K=>({...K,branchName:y.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null,linkedLinearIssue:null}))},onBlur:()=>Ie(y=>({...y,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!p.linkedPr,className:re("h-8",he.touched&&he.branchError&&"border-destructive",p.linkedPr&&"bg-muted text-muted-foreground")}),p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:p.linkedPr.head})})]}),p.linkedIssue&&!p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:p.linkedIssue.number,title:p.linkedIssue.title})})]}),p.linkedLinearIssue&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromLinearIssue",{identifier:p.linkedLinearIssue.identifier,title:p.linkedLinearIssue.title})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold",children:r("session.newWorktree.worktreeDirectory")}),g!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const y=St(g==="new-branch"?p.branchName:"");S(K=>({...K,worktreeName:y,isSyncingWorktreeName:!0}))},disabled:!p.branchName||p.worktreeName===St(p.branchName),className:re("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",p.worktreeName===St(p.branchName)||!p.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:r("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(E,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:r("session.newWorktree.actions.reset")})]})]}),t.jsx(Nt,{value:Xe.worktreeName,onChange:y=>{g==="new-branch"?S(K=>({...K,worktreeName:y.target.value,isSyncingWorktreeName:!1})):R(K=>({...K,worktreeName:y.target.value}))},onBlur:()=>Ie(y=>({...y,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:re("h-8",he.touched&&he.worktreeError&&"border-destructive")})]}),g==="new-branch"&&!p.linkedPr&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.sourceBranch")}),t.jsxs(ve,{variant:"outline",size:"sm",onClick:()=>O(!0),className:"w-full justify-between h-9",children:[t.jsx("span",{className:p.sourceBranch?"text-foreground":"text-muted-foreground",children:p.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(E,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),p.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:p.sourceBranch})}),t.jsx(ms,{open:W,title:r("session.newWorktree.selectSourceBranch"),onClose:()=>O(!1),children:t.jsxs("div",{className:"space-y-4",ref:de,children:[t.jsx(Nt,{value:v,onChange:y=>Z(y.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),U?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&H.length===0?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noBranchesFound")}):t.jsxs("div",{className:"space-y-4",children:[pe&&ue&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:q.matching.map(y=>t.jsx("button",{onClick:()=>{S(K=>({...K,sourceBranch:y.value})),O(!1)},className:re("w-full text-left px-3 py-2.5 rounded-md transition-colors",p.sourceBranch===y.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y.label})},`${y.source}-${y.value}`))})]}),pe&&!ue&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!pe&&q.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:q.otherLocal.map(y=>t.jsx("button",{onClick:()=>{S(K=>({...K,sourceBranch:y})),O(!1)},className:re("w-full text-left px-3 py-2.5 rounded-md transition-colors",p.sourceBranch===y?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y})},y))})]}),!pe&&q.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:q.otherRemote.map(y=>t.jsx("button",{onClick:()=>{S(K=>({...K,sourceBranch:`remotes/${y}`})),O(!1)},className:re("w-full text-left px-3 py-2.5 rounded-md transition-colors",p.sourceBranch===`remotes/${y}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y})},`remotes/${y}`))})]})]})]})})]}),(p.linkedIssue||p.linkedPr||p.linkedLinearIssue)&&g==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(E,{name:p.linkedLinearIssue?"linear":"github",className:re("h-3.5 w-3.5 shrink-0",p.linkedLinearIssue?"text-foreground":"text-status-success")}),p.linkedLinearIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:p.linkedLinearIssue.identifier}),p.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:p.linkedIssue.number})}),p.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:p.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:p.linkedLinearIssue?.title||p.linkedIssue?.title||p.linkedPr?.title}),t.jsx("a",{href:p.linkedLinearIssue?.url||p.linkedIssue?.url||p.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:y=>y.stopPropagation(),children:t.jsx(E,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:gt,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 pl-5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[p.linkedPr.head," → ",p.linkedPr.base]}),p.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:r("session.newWorktree.includeDiffBadge")})]})]})]})]}):t.jsx(Es,{open:s,onOpenChange:e,children:t.jsxs(Rs,{className:"max-w-lg max-h-[80vh] flex flex-col",children:[t.jsx(Ys,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(As,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(E,{name:"git-branch",className:"h-5 w-5"}),r("session.newWorktree.title")]}),t.jsx("div",{className:"w-[280px] shrink-0",children:t.jsx(Ds,{items:[{id:"new-branch",label:r("session.newWorktree.mode.newBranch"),icon:t.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(E,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:g,onSelect:y=>{(y==="new-branch"||y==="existing-branch")&&ze(y)},variant:"active-pill",layoutMode:"fit",className:"w-full"})})]})}),t.jsxs(Js,{outerClassName:"flex-1 mt-2",className:"space-y-6",disableHorizontal:!0,children:[g==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Ht,{open:_,onOpenChange:se,children:[t.jsx(Kt,{asChild:!0,children:t.jsxs("button",{type:"button",className:re(qn({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:re("truncate",M.selectedBranch?"text-foreground":"text-muted-foreground"),children:M.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(qt,{align:"start",sideOffset:6,portalToBody:!0,className:"w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",ref:X,children:t.jsxs(wn,{shouldFilter:!1,children:[t.jsx(vn,{placeholder:r("session.newWorktree.searchBranches"),value:A,onValueChange:z,onKeyDown:Re}),t.jsx(jn,{disableHorizontal:!0,children:U?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&H.length===0?t.jsx(Sn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[ce&&Q&&t.jsx(Lt,{heading:r("session.newWorktree.matchingBranches"),children:Y.matching.map(y=>t.jsx(Mt,{value:y.value,onSelect:()=>{R(K=>({...K,selectedBranch:y.value,worktreeName:St(y.label)})),Ie(K=>({...K,touched:!0})),se(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y.label})},`${y.source}-${y.value}`))}),ce&&!Q&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!ce&&Y.otherLocal.length>0&&t.jsx(t.Fragment,{children:t.jsx(Lt,{heading:r("session.newWorktree.localBranches"),children:Y.otherLocal.map(y=>t.jsx(Mt,{value:y,onSelect:()=>{R(K=>({...K,selectedBranch:y,worktreeName:St(y)})),Ie(K=>({...K,touched:!0})),se(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y})},`local-${y}`))})}),!ce&&Y.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[Y.otherLocal.length>0&&t.jsx(ks,{}),t.jsx(Lt,{heading:r("session.newWorktree.remoteBranches"),children:Y.otherRemote.map(y=>t.jsx(Mt,{value:`remotes/${y}`,onSelect:()=>{R(K=>({...K,selectedBranch:`remotes/${y}`,worktreeName:St(y)})),Ie(K=>({...K,touched:!0})),se(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y})},`remote-${y}`))})]})]})})]})})]}),t.jsx(ve,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:Pe,disabled:!Ee||U,title:r("session.newWorktree.fetchBranches"),children:U?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"refresh",className:"size-4"})})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold shrink-0",children:r("session.newWorktree.branchName")}),yt]}),t.jsx(Nt,{value:p.branchName,onChange:y=>{S(K=>({...K,branchName:y.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null,linkedLinearIssue:null}))},onBlur:()=>Ie(y=>({...y,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!p.linkedPr,className:re("h-8",he.touched&&he.branchError&&"border-destructive",p.linkedPr&&"bg-muted text-muted-foreground")}),p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:p.linkedPr.head})})]}),p.linkedIssue&&!p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:p.linkedIssue.number,title:p.linkedIssue.title})})]}),p.linkedLinearIssue&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromLinearIssue",{identifier:p.linkedLinearIssue.identifier,title:p.linkedLinearIssue.title})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold",children:r("session.newWorktree.worktreeDirectory")}),g!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const y=St(g==="new-branch"?p.branchName:"");S(K=>({...K,worktreeName:y,isSyncingWorktreeName:!0}))},disabled:!p.branchName||p.worktreeName===St(p.branchName),className:re("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",p.worktreeName===St(p.branchName)||!p.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:r("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(E,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:r("session.newWorktree.actions.reset")})]})]}),t.jsx(Nt,{value:Xe.worktreeName,onChange:y=>{g==="new-branch"?S(K=>({...K,worktreeName:y.target.value,isSyncingWorktreeName:!1})):R(K=>({...K,worktreeName:y.target.value}))},onBlur:()=>Ie(y=>({...y,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:re("h-8",he.touched&&he.worktreeError&&"border-destructive")})]}),g==="new-branch"&&!p.linkedPr&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.sourceBranch")}),t.jsxs(Ht,{open:ne,onOpenChange:V,children:[t.jsx(Kt,{asChild:!0,children:t.jsxs("button",{type:"button",className:re(qn({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:re("truncate",p.sourceBranch?"text-foreground":"text-muted-foreground"),children:p.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(qt,{align:"start",portalToBody:!0,className:"w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",ref:ie,children:t.jsxs(wn,{shouldFilter:!1,children:[t.jsx(vn,{placeholder:r("session.newWorktree.searchBranches"),value:v,onValueChange:Z,onKeyDown:Re}),t.jsx(jn,{disableHorizontal:!0,children:U?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&H.length===0?t.jsx(Sn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[pe&&ue&&t.jsx(Lt,{heading:r("session.newWorktree.matchingBranches"),children:q.matching.map(y=>t.jsx(Mt,{value:y.value,onSelect:()=>{S(K=>({...K,sourceBranch:y.value})),V(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y.label})},`${y.source}-${y.value}`))}),pe&&!ue&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!pe&&q.otherLocal.length>0&&t.jsx(t.Fragment,{children:t.jsx(Lt,{heading:r("session.newWorktree.localBranches"),children:q.otherLocal.map(y=>t.jsx(Mt,{value:y,onSelect:()=>{S(K=>({...K,sourceBranch:y})),V(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y})},`local-${y}`))})}),!pe&&q.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[q.otherLocal.length>0&&t.jsx(ks,{}),t.jsx(Lt,{heading:r("session.newWorktree.remoteBranches"),children:q.otherRemote.map(y=>t.jsx(Mt,{value:`remotes/${y}`,onSelect:()=>{S(K=>({...K,sourceBranch:`remotes/${y}`})),V(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y})},`remote-${y}`))})]})]})})]})})]}),p.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:p.sourceBranch})})]}),(p.linkedIssue||p.linkedPr||p.linkedLinearIssue)&&g==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(E,{name:p.linkedLinearIssue?"linear":"github",className:re("h-3.5 w-3.5 shrink-0",p.linkedLinearIssue?"text-foreground":"text-status-success")}),p.linkedLinearIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:p.linkedLinearIssue.identifier}),p.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:p.linkedIssue.number})}),p.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:p.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:p.linkedLinearIssue?.title||p.linkedIssue?.title||p.linkedPr?.title}),t.jsx("a",{href:p.linkedLinearIssue?.url||p.linkedIssue?.url||p.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:y=>y.stopPropagation(),children:t.jsx(E,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:gt,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 pl-5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[p.linkedPr.head," → ",p.linkedPr.base]}),p.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:r("session.newWorktree.includeDiffBadge")})]})]})]}),t.jsxs(An,{className:"mt-1 flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center gap-1.5 text-destructive",children:he.touched&&(he.branchError||he.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(E,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:he.branchError||he.worktreeError})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ve,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:ke,children:r("session.newWorktree.actions.cancel")}),t.jsxs(ve,{size:"sm",onClick:Ne,disabled:!pt||ke,className:"gap-1.5",children:[ke&&t.jsx(E,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(ke?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]})]})}),t.jsx(Td,{open:B,onOpenChange:G,onSelect:$e}),t.jsx(Ba,{open:J,onOpenChange:L,mode:"select",onSelect:He})]})}const Ad=2880*60*1e3,Md=s=>!!s.parentID,Ld=s=>!!s.time?.archived,Bd=s=>{const e=s.time?.updated,n=s.time?.created;return typeof e=="number"&&Number.isFinite(e)?e:typeof n=="number"&&Number.isFinite(n)?n:0},Fd=(s,e,n=Date.now())=>{const r=n-Ad;return s.filter(o=>Ld(o)||Md(o)?!1:e.has(o.id)||Bd(o)>=r)},wf=({sessions:s,getSessionLocation:e,getSessionNode:n,query:r})=>[{key:"active-now",items:s.flatMap(o=>{const a=typeof o.title=="string"?o.title.toLowerCase():"",i=r.trim().toLowerCase();if(!(i.startsWith("ses_")?o.id.toLowerCase()===i:!r||a.includes(r)))return[];const m=e(o.id);return[{node:n?.(o)??{session:o,children:[],worktree:null},projectId:m?.projectId??null,groupDirectory:m?.groupDirectory??o.directory??null,secondaryMeta:m?{projectLabel:m.projectLabel,branchLabel:m.branchLabel}:null}]})}],jo=s=>s.parentID??null,Od=(s,e)=>{const n=[],r=[];for(const o of s)if(!_a(o)){if(Ga(o.directory)){if(e)continue;r.push(o);continue}n.push(o)}return{projectSessions:n,chatSessions:r}},$d=new Set,Vd=(s,e,n)=>{if(s.time?.archived)return!0;const r=Ks(Br(s))?.toLowerCase();return!r||e.size===0?!n:e.has(r)},Wd=(s,e)=>{const n=[...s],r=new Set(s.map(o=>o.id));for(const o of e)r.has(o.id)||(r.add(o.id),n.push(o));return n},zd=(s,e)=>{const n=[],r=new Set([e]),o=a=>{for(const i of s.get(a)??[])r.has(i.id)||(r.add(i.id),n.push(i.id),o(i.id))};return o(e),n},Ud=({globalActiveSessions:s,liveSessions:e,knownDirectories:n,isVSCode:r,globalStructure:o})=>{$r("sidebarStructureBuilds");const i=Wd(s??[],e),d=Od(i,r),l=d.projectSessions.filter(g=>Vd(g,n,r)),m=[...l,...d.chatSessions],u=new Map(m.map(g=>[g.id,g])),f=new Set(l.map(g=>g.id)),b=o?.activeRootIds??[],h=new Set(b),x=[...b.flatMap(g=>{if(!f.has(g))return[];const j=u.get(g);return j?[j]:[]}),...l.filter(g=>!h.has(g.id)&&!jo(g))];return{chatSessionIds:new Set(d.chatSessions.map(g=>g.id)),projectSessions:l,rootSessions:x,sessionById:u,sessions:m,hierarchy:o?{rootIds:o.activeRootIds,childrenByParentId:o.activeChildrenByParentId}:void 0}},_d=(s,e,n)=>{const r=Vr(s.sessions,e,n,s.hierarchy),o=new Map;for(const a of r){const i=jo(a);if(!i)continue;const d=o.get(i)??[];d.push(a),o.set(i,d)}return{chatSessions:r.filter(a=>s.chatSessionIds.has(a.id)),childrenMap:o,orderedSessions:r}},vf=s=>{const e=_e.c(33),{knownDirectories:n,isVSCode:r,isVisible:o}=s,a=Xt(Gd),i=Xt(Hd),d=Xt(Kd),l=Xt(qd),m=Ha(),u=Ka(Jd);let f;e[0]!==o?(f=N=>o?N.rankById:Ya,e[0]=o,e[1]=f):f=e[1];const b=qa(f);let h;e[2]!==a||e[3]!==i||e[4]!==r||e[5]!==n||e[6]!==m?(h=Ud({globalActiveSessions:a,globalStructure:i,liveSessions:m,knownDirectories:n,isVSCode:r}),e[2]=a,e[3]=i,e[4]=r,e[5]=n,e[6]=m,e[7]=h):h=e[7];const x=h;let g;e[8]!==u||e[9]!==b||e[10]!==x?(g=_d(x,u,b),e[8]=u,e[9]=b,e[10]=x,e[11]=g):g=e[11];const j=g,{chatSessions:p,orderedSessions:S}=j,M=x.projectSessions;let R;e[12]!==d||e[13]!==x.sessions?(R=new Map([...x.sessions,...d].map(Yd)),e[12]=d,e[13]=x.sessions,e[14]=R):R=e[14];const F=R;let U;if(e[15]!==d||e[16]!==j.childrenMap){U=new Map(j.childrenMap);for(const N of d){const $=N.parentID;if(!$)continue;const B=U.get($)??[];B.push(N),U.set($,B)}e[15]=d,e[16]=j.childrenMap,e[17]=U}else U=e[17];const T=U;let w;e[18]!==T||e[19]!==F?(w=(N,$)=>zd(T,N).filter(B=>$.includeArchived||!F.get(B)?.time?.archived),e[18]=T,e[19]=F,e[20]=w):w=e[20];const H=w;let P;return e[21]!==d||e[22]!==p||e[23]!==T||e[24]!==H||e[25]!==l||e[26]!==m||e[27]!==S||e[28]!==u||e[29]!==b||e[30]!==M||e[31]!==x.rootSessions?(P={archivedSessions:d,childrenMap:T,chatSessions:p,getDescendantIds:H,hasAuthoritativeGlobalSessions:l,liveSessions:m,orderedSessions:S,pinnedSessionIds:u,sessionOrderRanks:b,sessions:M,rootSessions:x.rootSessions},e[21]=d,e[22]=p,e[23]=T,e[24]=H,e[25]=l,e[26]=m,e[27]=S,e[28]=u,e[29]=b,e[30]=M,e[31]=x.rootSessions,e[32]=P):P=e[32],P},jf=s=>{const e=_e.c(9),{enabled:n,isVSCode:r,pinnedSessionIds:o,sessionOrderRanks:a,sessions:i}=s;let d;e[0]!==n||e[1]!==r?(d=u=>n&&!r?u.activeSessionIds:$d,e[0]=n,e[1]=r,e[2]=d):d=e[2];const l=Ja(d);let m;e:{if(!n||r){let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=[],e[3]=f):f=e[3],m=f;break e}$r("recentCandidatesVisited",i.length);let u;e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==i?(u=Vr(Fd(i,l),o,a),e[4]=l,e[5]=o,e[6]=a,e[7]=i,e[8]=u):u=e[8],m=u}return m};function Gd(s){return s.activeSessions}function Hd(s){return s.structure}function Kd(s){return s.archivedSessions}function qd(s){return s.status==="ready"}function Jd(s){return s.ids}function Yd(s){return[s.id,s]}const wr=(s,e)=>(s.label||s.path).toLowerCase().localeCompare((e.label||e.path).toLowerCase()),Sf=(s,e,n)=>{const r=[...s];switch(e){case"a-z":r.sort(wr);break;case"z-a":r.sort((o,a)=>wr(a,o));break;case"date-added":r.sort((o,a)=>(a.addedAt??0)-(o.addedAt??0));break;case"recent":r.sort((o,a)=>(a.lastOpenedAt??0)-(o.lastOpenedAt??0));break;case"manual":{const o=new Map(n.map((a,i)=>[a,i]));r.sort((a,i)=>(o.get(a.id)??1/0)-(o.get(i.id)??1/0));break}}return r},Wn=(s,e)=>s==="global"?"global":`project:${e??""}`,So=(s,e)=>s.createdAt>e?"new":s.updatedAt>e?"changed":null,vr=(s,e)=>s.reduce((n,r)=>So(r,e)?n+1:n,0),No=s=>{const e=_e.c(29),{expanded:n,onToggleExpanded:r,header:o,children:a,actions:i,footer:d,expandLabel:l}=s,{t:m}=nt(),u=!n&&"cursor-pointer hover:border-[var(--interactive-border)] hover:bg-interactive-hover/30";let f;e[0]!==u?(f=re("flex flex-col gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 py-1.5",u),e[0]=u,e[1]=f):f=e[1];const b=n?void 0:r;let h;e[2]!==n||e[3]!==r?(h=n?void 0:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),r())},e[2]=n,e[3]=r,e[4]=h):h=e[4];const x=n?void 0:"button",g=n?void 0:0,j=n?void 0:l;let p;e[5]!==a||e[6]!==o?(p=t.jsxs("div",{className:"min-w-0 flex-1",children:[o,a]}),e[5]=a,e[6]=o,e[7]=p):p=e[7];let S;e[8]!==n||e[9]!==r||e[10]!==m?(S=n?t.jsx("button",{type:"button",onClick:r,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":m("rightSidebar.contextNotesTodo.notes.actions.collapse"),title:m("rightSidebar.contextNotesTodo.notes.actions.collapse"),children:t.jsx(E,{name:"arrow-up-s",className:"h-3.5 w-3.5"})}):null,e[8]=n,e[9]=r,e[10]=m,e[11]=S):S=e[11];let M;e[12]!==i||e[13]!==S?(M=t.jsxs("div",{className:"flex flex-shrink-0 flex-col items-center gap-0.5",onClick:Qd,onKeyDown:Xd,children:[S,i]}),e[12]=i,e[13]=S,e[14]=M):M=e[14];let R;e[15]!==M||e[16]!==p?(R=t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[p,M]}),e[15]=M,e[16]=p,e[17]=R):R=e[17];let F;e[18]!==d?(F=d?t.jsx("div",{className:"min-w-0",children:d}):null,e[18]=d,e[19]=F):F=e[19];let U;return e[20]!==R||e[21]!==F||e[22]!==f||e[23]!==b||e[24]!==h||e[25]!==x||e[26]!==g||e[27]!==j?(U=t.jsxs("li",{className:f,onClick:b,onKeyDown:h,role:x,tabIndex:g,"aria-label":j,children:[R,F]}),e[20]=R,e[21]=F,e[22]=f,e[23]=b,e[24]=h,e[25]=x,e[26]=g,e[27]=j,e[28]=U):U=e[28],U};function Qd(s){return s.stopPropagation()}function Xd(s){return s.stopPropagation()}const Zd=s=>{const e=_e.c(52),{entry:n,badge:r,expanded:o,onToggleExpanded:a,onSave:i,onDelete:d}=s,{t:l}=nt(),[m,u]=c.useState(n.title),[f,b]=c.useState(n.body);let h,x;e[0]!==n.body||e[1]!==n.title||e[2]!==o?(h=()=>{o||(u(n.title),b(n.body))},x=[n.body,n.title,o],e[0]=n.body,e[1]=n.title,e[2]=o,e[3]=h,e[4]=x):(h=e[3],x=e[4]),c.useEffect(h,x);let g;e[5]!==f||e[6]!==n.body||e[7]!==n.title||e[8]!==i||e[9]!==m?(g=()=>{const J=m.trim(),L=f.trim();if(!J||!L){u(n.title),b(n.body);return}J===n.title&&L===n.body||i({title:J,body:L})},e[5]=f,e[6]=n.body,e[7]=n.title,e[8]=i,e[9]=m,e[10]=g):g=e[10];const j=g,p=`rightSidebar.contextNotesTodo.memory.type.${n.type}`;let S;e[11]!==l||e[12]!==p?(S=l(p),e[11]=l,e[12]=p,e[13]=S):S=e[13];const M=S;let R;e[14]!==j||e[15]!==o||e[16]!==a?(R=()=>{o&&j(),a()},e[14]=j,e[15]=o,e[16]=a,e[17]=R):R=e[17];const F=n.title;let U;e[18]!==n.flagged||e[19]!==l?(U=n.flagged?t.jsxs("span",{className:"flex items-center gap-1 text-[var(--status-error)]",children:[t.jsx(E,{name:"error-warning",className:"h-3 w-3 flex-shrink-0"}),l("rightSidebar.contextNotesTodo.memory.flagged")]}):null,e[18]=n.flagged,e[19]=l,e[20]=U):U=e[20];let T;e[21]!==U||e[22]!==M?(T=t.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 typography-micro text-muted-foreground",children:[M,U]}),e[21]=U,e[22]=M,e[23]=T):T=e[23];let w;e[24]!==r||e[25]!==l?(w=r?t.jsx("span",{className:re("mb-0.5 mr-1.5 inline-block rounded-full px-1.5 py-px typography-micro font-medium",r==="new"?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--status-warning)]/15 text-[var(--status-warning)]"),children:l(r==="new"?"rightSidebar.contextNotesTodo.memory.badge.new":"rightSidebar.contextNotesTodo.memory.badge.changed")}):null,e[24]=r,e[25]=l,e[26]=w):w=e[26];let H;e[27]!==l?(H=l("rightSidebar.contextNotesTodo.memory.actions.delete"),e[27]=l,e[28]=H):H=e[28];let P;e[29]!==l?(P=l("rightSidebar.contextNotesTodo.memory.actions.delete"),e[29]=l,e[30]=P):P=e[30];let N;e[31]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[31]=N):N=e[31];let $;e[32]!==d||e[33]!==H||e[34]!==P?($=t.jsx("button",{type:"button",onClick:d,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":H,title:P,children:N}),e[32]=d,e[33]=H,e[34]=P,e[35]=$):$=e[35];let B;e[36]!==f||e[37]!==j||e[38]!==n.body||e[39]!==n.title||e[40]!==o||e[41]!==l||e[42]!==m?(B=o?t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(Nt,{value:m,onChange:J=>u(J.target.value.slice(0,Qa)),onBlur:j,"aria-label":l("rightSidebar.contextNotesTodo.memory.actions.editTitle"),className:"h-7 typography-ui-label"}),t.jsx(Qs,{simple:!0,rows:Math.min(20,Math.max(3,f.split(`
|
|
6
|
-
`).length+1)),value:f,onChange:J=>b(J.target.value.slice(0,Xa)),onBlur:j,"aria-label":l("rightSidebar.contextNotesTodo.memory.actions.editBody"),className:"min-h-0 w-full resize-none bg-transparent p-0 typography-meta leading-normal text-muted-foreground focus-visible:outline-none focus-visible:ring-0"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:n.title}),t.jsx("p",{className:"line-clamp-2 whitespace-pre-wrap break-words typography-meta text-muted-foreground",children:n.body})]}),e[36]=f,e[37]=j,e[38]=n.body,e[39]=n.title,e[40]=o,e[41]=l,e[42]=m,e[43]=B):B=e[43];let G;return e[44]!==n.title||e[45]!==o||e[46]!==w||e[47]!==$||e[48]!==B||e[49]!==R||e[50]!==T?(G=t.jsx(No,{expanded:o,onToggleExpanded:R,expandLabel:F,footer:T,header:w,actions:$,children:B}),e[44]=n.title,e[45]=o,e[46]=w,e[47]=$,e[48]=B,e[49]=R,e[50]=T,e[51]=G):G=e[51],G},eu=s=>{const e=_e.c(59),{projectPath:n,query:r}=s,{t:o}=nt(),[a,i]=c.useState("project"),[d,l]=c.useState(null),m=At(tu);let u;e[0]!==n?(u=X=>Wr(X,n),e[0]=n,e[1]=u):u=e[1];const f=At(u),b=At(su),h=At(nu),x=At(ru),g=At(ou),j=Ke(au),p=a==="global"?m:f,S=a==="global"?b:h;let M;e[2]!==n||e[3]!==a?(M=Wn(a,n),e[2]=n,e[3]=a,e[4]=M):M=e[4];const R=M;let F;e[5]!==R?(F=X=>X.agentMemoryViewedAt[R]??0,e[5]=R,e[6]=F):F=e[6];const U=Ke(F),T=c.useRef(U),[w,H]=c.useState(U);let P,N;e[7]!==j||e[8]!==R?(P=()=>(T.current=Ke.getState().agentMemoryViewedAt[R]??0,H(T.current),()=>{j(R,Date.now())}),N=[j,R],e[7]=j,e[8]=R,e[9]=P,e[10]=N):(P=e[9],N=e[10]),c.useEffect(P,N);let $;if(e[11]!==p||e[12]!==r){let X;e[14]!==r?(X=ie=>Zs([ie.title,ie.body],r),e[14]=r,e[15]=X):X=e[15],$=p.filter(X),e[11]=p,e[12]=r,e[13]=$}else $=e[13];const B=$;let G;e[16]!==x||e[17]!==a||e[18]!==o?(G=async X=>{if(!await x(a,X)){const ie=At.getState().error;ge.error(o("rightSidebar.contextNotesTodo.memory.toast.deleteFailed"),ie?{description:ie}:void 0)}},e[16]=x,e[17]=a,e[18]=o,e[19]=G):G=e[19];const J=G;let L;e[20]!==g||e[21]!==a||e[22]!==o?(L=async(X,ie)=>{if(!await g(a,X,ie)){const je=At.getState().error;ge.error(o("rightSidebar.contextNotesTodo.memory.toast.saveFailed"),je?{description:je}:void 0)}},e[20]=g,e[21]=a,e[22]=o,e[23]=L):L=e[23];const _=L;let se;e[24]!==o?(se=o("rightSidebar.contextNotesTodo.memory.scope.project"),e[24]=o,e[25]=se):se=e[25];let ne;e[26]!==f.length||e[27]!==se?(ne={id:"project",label:se,count:f.length},e[26]=f.length,e[27]=se,e[28]=ne):ne=e[28];let V;e[29]!==o?(V=o("rightSidebar.contextNotesTodo.memory.scope.global"),e[29]=o,e[30]=V):V=e[30];let ee;e[31]!==m.length||e[32]!==V?(ee={id:"global",label:V,count:m.length},e[31]=m.length,e[32]=V,e[33]=ee):ee=e[33];let C;e[34]!==ne||e[35]!==ee?(C=[ne,ee],e[34]=ne,e[35]=ee,e[36]=C):C=e[36];const W=C;let O;e[37]!==o?(O=o("rightSidebar.contextNotesTodo.memory.scope.label"),e[37]=o,e[38]=O):O=e[38];let A;e[39]!==a||e[40]!==W?(A=W.map(X=>t.jsx(ve,{type:"button",variant:"chip",size:"xs","aria-pressed":a===X.id,className:"!font-normal",onClick:()=>i(X.id),children:`${X.label} ${X.count}`},X.id)),e[39]=a,e[40]=W,e[41]=A):A=e[41];let z;e[42]!==O||e[43]!==A?(z=t.jsx("div",{role:"group","aria-label":O,className:"flex items-center gap-1",children:A}),e[42]=O,e[43]=A,e[44]=z):z=e[44];let v;e[45]!==w||e[46]!==d||e[47]!==J||e[48]!==_||e[49]!==n||e[50]!==r||e[51]!==a||e[52]!==S||e[53]!==o||e[54]!==B?(v=a==="project"&&!n?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.memory.empty.noProject")}):S?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.memory.empty.unavailable")}):B.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r.trim()?o("rightSidebar.contextNotesTodo.memory.empty.noMatches"):o("rightSidebar.contextNotesTodo.memory.empty.nothing")}):t.jsx("ul",{className:"flex flex-col gap-1.5",children:B.map(X=>t.jsx(Zd,{entry:X,badge:So(X,w),expanded:d===X.id,onToggleExpanded:()=>l(d===X.id?null:X.id),onSave:ie=>{_(X.id,ie)},onDelete:()=>{J(X.id)}},X.id))}),e[45]=w,e[46]=d,e[47]=J,e[48]=_,e[49]=n,e[50]=r,e[51]=a,e[52]=S,e[53]=o,e[54]=B,e[55]=v):v=e[55];let Z;return e[56]!==z||e[57]!==v?(Z=t.jsxs("div",{className:"flex flex-col gap-2",children:[z,v]}),e[56]=z,e[57]=v,e[58]=Z):Z=e[58],Z};function tu(s){return s.global}function su(s){return s.globalFailed}function nu(s){return s.projectFailed}function ru(s){return s.deleteEntry}function ou(s){return s.saveEntry}function au(s){return s.markAgentMemoryViewed}const iu=400,lu=s=>{const e=_e.c(61),{note:n,pinned:r,expanded:o,onToggleExpanded:a,onSaveBody:i,onTogglePinned:d,onDelete:l}=s,{t:m}=nt(),[u,f]=c.useState(n.body),b=c.useRef(n.body),h=c.useRef(null);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null)},e[0]=x):x=e[0];const g=x;let j,p;e[1]!==u||e[2]!==n.body?(j=()=>{n.body!==b.current&&u===b.current&&(b.current=n.body,f(n.body))},p=[u,n.body],e[1]=u,e[2]=n.body,e[3]=j,e[4]=p):(j=e[3],p=e[4]),c.useEffect(j,p);let S,M;e[5]!==u||e[6]!==i?(S=()=>{if(u!==b.current)return h.current=window.setTimeout(()=>{h.current=null,u.trim()&&(b.current=u,i(u))},iu),g},M=[g,u,i],e[5]=u,e[6]=i,e[7]=S,e[8]=M):(S=e[7],M=e[8]),c.useEffect(S,M);let R,F;e[9]===Symbol.for("react.memo_cache_sentinel")?(R=()=>g,F=[g],e[9]=R,e[10]=F):(R=e[9],F=e[10]),c.useEffect(R,F);let U;e[11]!==u||e[12]!==i?(U=()=>{if(g(),u!==b.current){if(!u.trim()){f(b.current);return}b.current=u,i(u)}},e[11]=u,e[12]=i,e[13]=U):U=e[13];const T=U;let w;e[14]!==n.source||e[15]!==m?(w=n.source==="selection"?m("rightSidebar.contextNotesTodo.notes.source.selection"):n.source==="agent"?m("rightSidebar.contextNotesTodo.notes.source.agent"):null,e[14]=n.source,e[15]=m,e[16]=w):w=e[16];const H=w;let P;e[17]!==m?(P=m("rightSidebar.contextNotesTodo.notes.actions.expand"),e[17]=m,e[18]=P):P=e[18];let N;e[19]!==H?(N=H?t.jsx("span",{className:"typography-micro text-muted-foreground",children:H}):null,e[19]=H,e[20]=N):N=e[20];const $=r?"text-primary":"text-muted-foreground hover:text-foreground";let B;e[21]!==$?(B=re("inline-flex h-6 w-6 items-center justify-center rounded-md hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",$),e[21]=$,e[22]=B):B=e[22];let G;e[23]!==r||e[24]!==m?(G=m(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[23]=r,e[24]=m,e[25]=G):G=e[25];let J;e[26]!==r||e[27]!==m?(J=m(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[26]=r,e[27]=m,e[28]=J):J=e[28];const L=r?"pushpin-2-fill":"pushpin";let _;e[29]!==L?(_=t.jsx(E,{name:L,className:"h-3.5 w-3.5"}),e[29]=L,e[30]=_):_=e[30];let se;e[31]!==d||e[32]!==r||e[33]!==B||e[34]!==G||e[35]!==J||e[36]!==_?(se=t.jsx("button",{type:"button",onClick:d,className:B,"aria-pressed":r,"aria-label":G,title:J,children:_}),e[31]=d,e[32]=r,e[33]=B,e[34]=G,e[35]=J,e[36]=_,e[37]=se):se=e[37];let ne;e[38]!==m?(ne=m("rightSidebar.contextNotesTodo.notes.actions.delete"),e[38]=m,e[39]=ne):ne=e[39];let V;e[40]!==m?(V=m("rightSidebar.contextNotesTodo.notes.actions.delete"),e[40]=m,e[41]=V):V=e[41];let ee;e[42]===Symbol.for("react.memo_cache_sentinel")?(ee=t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[42]=ee):ee=e[42];let C;e[43]!==l||e[44]!==ne||e[45]!==V?(C=t.jsx("button",{type:"button",onClick:l,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":ne,title:V,children:ee}),e[43]=l,e[44]=ne,e[45]=V,e[46]=C):C=e[46];let W;e[47]!==se||e[48]!==C?(W=t.jsxs(t.Fragment,{children:[se,C]}),e[47]=se,e[48]=C,e[49]=W):W=e[49];let O;e[50]!==u||e[51]!==o||e[52]!==T?(O=o?t.jsx(Qs,{simple:!0,autoFocus:!0,rows:Math.min(20,Math.max(3,u.split(`
|
|
7
|
-
`).length+1)),value:u,onChange:z=>f(z.target.value.slice(0,Cn)),onBlur:T,className:"min-h-0 w-full resize-none bg-transparent p-0 typography-ui-label leading-normal text-foreground focus-visible:outline-none focus-visible:ring-0"}):t.jsx("p",{className:"line-clamp-3 whitespace-pre-wrap break-words typography-ui-label leading-normal text-foreground",title:u,children:u}),e[50]=u,e[51]=o,e[52]=T,e[53]=O):O=e[53];let A;return e[54]!==o||e[55]!==a||e[56]!==P||e[57]!==N||e[58]!==W||e[59]!==O?(A=t.jsx(No,{expanded:o,onToggleExpanded:a,expandLabel:P,footer:N,actions:W,children:O}),e[54]=o,e[55]=a,e[56]=P,e[57]=N,e[58]=W,e[59]=O,e[60]=A):A=e[60],A},cu=s=>{const e=_e.c(69),{projectRef:n,notes:r,disabled:o,query:a,pinnedNoteIds:i,onTogglePinned:d}=s,{t:l}=nt(),[m,u]=c.useState(""),[f,b]=c.useState(null),h=Ke(du),x=Ke(uu),g=Rt(mu),j=Rt(fu),p=Rt(hu);let S;if(e[0]!==r||e[1]!==a){let v;e[3]!==a?(v=Z=>Zs([Z.body],a),e[3]=a,e[4]=v):v=e[4],S=r.filter(v),e[0]=r,e[1]=a,e[2]=S}else S=e[2];const M=S;let R;e[5]!==n?(R=v=>{const Z=Rt.getState().getEntry(n).error;ge.error(v,Z?{description:Z}:void 0)},e[5]=n,e[6]=R):R=e[6];const F=R;let U;e[7]!==m||e[8]!==g||e[9]!==n||e[10]!==F||e[11]!==l?(U=async()=>{const v=m.trim();if(!v)return;if(!await g(n,{body:v})){F(l("rightSidebar.contextNotesTodo.toast.createNoteFailed"));return}u("")},e[7]=m,e[8]=g,e[9]=n,e[10]=F,e[11]=l,e[12]=U):U=e[12];const T=U;let w;e[13]!==p||e[14]!==n||e[15]!==F||e[16]!==l?(w=async v=>{await p(n,v)||F(l("rightSidebar.contextNotesTodo.toast.deleteNoteFailed"))},e[13]=p,e[14]=n,e[15]=F,e[16]=l,e[17]=w):w=e[17];const H=w;let P;e[18]!==d||e[19]!==F||e[20]!==l?(P=async(v,Z)=>{await d(v,Z)||F(l("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))},e[18]=d,e[19]=F,e[20]=l,e[21]=P):P=e[21];const N=P;let $;e[22]!==n||e[23]!==F||e[24]!==j||e[25]!==l?($=(v,Z)=>{j(n,v,Z).then(X=>{X||F(l("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[22]=n,e[23]=F,e[24]=j,e[25]=l,e[26]=$):$=e[26];const B=$;let G;e[27]===Symbol.for("react.memo_cache_sentinel")?(G=v=>u(v.target.value.slice(0,Cn)),e[27]=G):G=e[27];let J;e[28]!==l?(J=l("rightSidebar.contextNotesTodo.notes.placeholder"),e[28]=l,e[29]=J):J=e[29];let L;e[30]!==m.length?(L=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[m.length,"/",Cn]}),e[30]=m.length,e[31]=L):L=e[31];let _;e[32]!==T?(_=()=>{T()},e[32]=T,e[33]=_):_=e[33];let se;e[34]!==m||e[35]!==o?(se=o||m.trim().length===0,e[34]=m,e[35]=o,e[36]=se):se=e[36];let ne;e[37]!==l?(ne=l("rightSidebar.contextNotesTodo.notes.addAria"),e[37]=l,e[38]=ne):ne=e[38];let V;e[39]!==l?(V=l("rightSidebar.contextNotesTodo.notes.addAria"),e[39]=l,e[40]=V):V=e[40];let ee;e[41]===Symbol.for("react.memo_cache_sentinel")?(ee=t.jsx(E,{name:"add",className:"h-4 w-4"}),e[41]=ee):ee=e[41];let C;e[42]!==_||e[43]!==se||e[44]!==ne||e[45]!==V?(C=t.jsx("button",{type:"button",onClick:_,disabled:se,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-40","aria-label":ne,title:V,children:ee}),e[42]=_,e[43]=se,e[44]=ne,e[45]=V,e[46]=C):C=e[46];let W;e[47]!==C||e[48]!==L?(W=t.jsxs(t.Fragment,{children:[L,C]}),e[47]=C,e[48]=L,e[49]=W):W=e[49];let O;e[50]!==m||e[51]!==o||e[52]!==h||e[53]!==x||e[54]!==W||e[55]!==J?(O=t.jsx(Qs,{value:m,onChange:G,placeholder:J,resizedHeight:h,onResizeHeightChange:x,useScrollShadow:!0,scrollShadowSize:56,disabled:o,endSlot:W}),e[50]=m,e[51]=o,e[52]=h,e[53]=x,e[54]=W,e[55]=J,e[56]=O):O=e[56];let A;e[57]!==f||e[58]!==H||e[59]!==B||e[60]!==N||e[61]!==i||e[62]!==a||e[63]!==l||e[64]!==M?(A=t.jsx("div",{children:M.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:a.trim()?l("rightSidebar.contextNotesTodo.search.noResults",{query:a.trim()}):l("rightSidebar.contextNotesTodo.notes.empty")}):t.jsx("ul",{className:"flex flex-col gap-1.5",children:M.map(v=>t.jsx(lu,{note:v,pinned:i.has(v.id),expanded:f===v.id,onToggleExpanded:()=>b(Z=>Z===v.id?null:v.id),onSaveBody:Z=>B(v.id,Z),onTogglePinned:()=>{N(v.id,!i.has(v.id))},onDelete:()=>{H(v.id)}},v.id))})}),e[57]=f,e[58]=H,e[59]=B,e[60]=N,e[61]=i,e[62]=a,e[63]=l,e[64]=M,e[65]=A):A=e[65];let z;return e[66]!==O||e[67]!==A?(z=t.jsxs("div",{className:"space-y-2",children:[O,A]}),e[66]=O,e[67]=A,e[68]=z):z=e[68],z};function du(s){return s.notesPanelHeight}function uu(s){return s.setNotesPanelHeight}function mu(s){return s.createNote}function fu(s){return s.saveNoteBody}function hu(s){return s.deleteNote}const pu=({projectRef:s,plans:e,query:n,onOpenPlan:r,pinnedPlanIds:o,onTogglePinned:a})=>{const{t:i}=nt(),d=c.useRef(null),[l,m]=c.useState(!1),[u,f]=c.useState(null),b=Rt(N=>N.createPlan),h=Rt(N=>N.deletePlan),x=Rt(N=>N.movePlan),[g,j]=c.useState(null),p=c.useCallback(async N=>{if(g)return;const $=N.source==="shared"?"unshare":"share";j(N.id);try{if(!await x(s,N.id,$)){const G=Rt.getState().getEntry(s).error;ge.error(i("rightSidebar.contextNotesTodo.toast.movePlanFailed"),G?{description:G}:void 0)}}finally{j(null)}},[x,g,s,i]),S=ys(N=>N.currentDirectory),M=Ke(N=>N.openContextPanelTab),R=c.useCallback(async N=>{if(!u){f(N);try{await h(s,N)||ge.error(i("rightSidebar.contextNotesTodo.toast.deletePlanFailed"))}finally{f(null)}}},[u,s,h,i]),F=c.useCallback(async(N,$)=>{if(!N.trim()){ge.error(i("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const B=Za(N,$||i("rightSidebar.contextNotesTodo.plan.defaultTitle"));if(!await b(s,{title:B.title,body:B.body})){ge.error(i("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}ge.success(i("rightSidebar.contextNotesTodo.toast.planImported"))},[b,s,i]),U=c.useCallback(async()=>{if(l)return;const N=await Oi({defaultPath:s.path,filters:[{name:"Plan files",extensions:["md","markdown","txt"]},{name:"All files",extensions:["*"]}]});if(N.success&&N.path){m(!0);try{const $=new URLSearchParams({path:N.path,allowOutsideWorkspace:"true"});N.outsideFileGrant&&$.set("outsideFileGrant",N.outsideFileGrant);const B=await Jt(`/api/fs/read?${$.toString()}`,{cache:"no-store"});if(!B.ok){ge.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"));return}const G=await B.text(),J=N.path.split("/").pop()?.replace(/\.(md|markdown|txt)$/i,"").trim()||"";await F(G,J)}catch($){const B=$ instanceof Error?$.message:void 0;ge.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),B?{description:B}:void 0)}finally{m(!1)}return}N.error==="Native file picker not available"&&d.current?.click()},[F,l,s.path,i]),T=c.useCallback(async N=>{if(N){m(!0);try{const $=await N.text(),B=N.name.replace(/\.(md|markdown|txt)$/i,"").trim();await F($,B)}catch($){const B=$ instanceof Error?$.message:void 0;ge.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),B?{description:B}:void 0)}finally{m(!1)}}},[F,i]),w=c.useCallback(async(N,$)=>{if(!await a(N,$)){const G=Rt.getState().getEntry(s).error;ge.error(i("rightSidebar.contextNotesTodo.toast.updatePlanFailed"),G?{description:G}:void 0)}},[a,s,i]),H=c.useMemo(()=>e.filter(N=>Zs([N.title],n)),[e,n]),P=c.useCallback(N=>{if(r){r({id:N.id,title:N.title,projectRef:s});return}const $=S?.trim()||s.path.trim();$&&M($,{mode:"plan",projectPlanId:N.id,projectPlanRef:s,dedupeKey:`plan:${zr(s)}:${N.id}`,label:N.title})},[S,r,M,s]);return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsx("input",{ref:d,type:"file",accept:".md,.markdown,.txt,text/markdown,text/plain",className:"hidden",onChange:N=>{const $=N.target.files?.[0]??null;T($),N.currentTarget.value=""}}),t.jsx("button",{type:"button",onClick:U,disabled:l,className:"inline-flex h-6 w-6 items-center justify-center rounded-md border border-border/70 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":i("rightSidebar.contextNotesTodo.plans.importFromFile"),title:i("rightSidebar.contextNotesTodo.plans.importFromFile"),children:t.jsx(E,{name:"add",className:"h-3.5 w-3.5"})})]}),t.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:H.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:n.trim()?i("rightSidebar.contextNotesTodo.search.noResults",{query:n.trim()}):i("rightSidebar.contextNotesTodo.plans.empty")}):t.jsx("ul",{className:"divide-y divide-border/50",children:H.map(N=>t.jsxs("li",{className:"flex items-center gap-1.5 px-2.5 py-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>P(N),className:"flex min-w-0 flex-1 items-center justify-between gap-3 rounded-md px-1.5 py-1 text-left hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",children:N.title}),N.source==="shared"?t.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:i("rightSidebar.contextNotesTodo.plans.sharedBadge")}):null]}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:new Date(N.createdAt).toLocaleDateString(Pr())})]}),t.jsx("button",{type:"button",onClick:()=>{p(N)},disabled:g===N.id,className:"inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",title:N.source==="shared"?i("rightSidebar.contextNotesTodo.plans.makePersonal"):i("rightSidebar.contextNotesTodo.plans.share"),"aria-label":N.source==="shared"?i("rightSidebar.contextNotesTodo.plans.makePersonal"):i("rightSidebar.contextNotesTodo.plans.share"),children:t.jsx(E,{name:N.source==="shared"?"user":"team",className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button",onClick:()=>{w(N.id,!o.has(N.id))},className:re("inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",o.has(N.id)?"text-primary":"text-muted-foreground hover:text-foreground"),"aria-pressed":o.has(N.id),"aria-label":o.has(N.id)?i("rightSidebar.contextNotesTodo.notes.actions.unpin"):i("rightSidebar.contextNotesTodo.notes.actions.pin"),title:o.has(N.id)?i("rightSidebar.contextNotesTodo.notes.actions.unpin"):i("rightSidebar.contextNotesTodo.notes.actions.pin"),children:t.jsx(E,{name:"pushpin",className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button",onClick:()=>{R(N.id)},disabled:u===N.id,className:"inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",title:i("rightSidebar.contextNotesTodo.plans.deletePlan"),"aria-label":i("rightSidebar.contextNotesTodo.plans.deletePlanWithTitle",{title:N.title}),children:t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},N.id))})})]})},gu=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`todo_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,xu=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],jr=(s,e)=>{const n=s.findIndex(r=>r.completed);return n===-1?[...s,e]:[...s.slice(0,n),e,...s.slice(n)]},bu=s=>{const e=_e.c(20),{id:n,children:r}=s;let o;e[0]!==n?(o={id:n},e[0]=n,e[1]=o):o=e[1];const{attributes:a,listeners:i,setNodeRef:d,setActivatorNodeRef:l,transform:m,transition:u,isDragging:f}=so(o);let b;e[2]!==m?(b=ro.Transform.toString(m),e[2]=m,e[3]=b):b=e[3];let h;e[4]!==b||e[5]!==u?(h={transform:b,transition:u},e[4]=b,e[5]=u,e[6]=h):h=e[6];const x=f&&"opacity-60";let g;e[7]!==x?(g=re(x),e[7]=x,e[8]=g):g=e[8];let j;e[9]!==a||e[10]!==r||e[11]!==f||e[12]!==i||e[13]!==l?(j=r({attributes:a,listeners:i,setActivatorNodeRef:l,isDragging:f}),e[9]=a,e[10]=r,e[11]=f,e[12]=i,e[13]=l,e[14]=j):j=e[14];let p;return e[15]!==d||e[16]!==h||e[17]!==g||e[18]!==j?(p=t.jsx("li",{ref:d,style:h,className:g,children:j}),e[15]=d,e[16]=h,e[17]=g,e[18]=j,e[19]=p):p=e[19],p},yu=s=>{const e=_e.c(82),{todos:n,query:r,disabled:o,canCreateWorktree:a,sendingTodoId:i,onPersistTodos:d,onSendToCurrentSession:l,onSendToNewSession:m,onSendToNewWorktreeSession:u}=s,{t:f}=nt(),[b,h]=c.useState(""),[x,g]=c.useState(wu);let j;e[0]!==b||e[1]!==d||e[2]!==n?(j=()=>{const k=b.trim();k&&(d(jr(n,{id:gu(),text:k.slice(0,Fs),completed:!1,createdAt:Date.now()})),h(""))},e[0]=b,e[1]=d,e[2]=n,e[3]=j):j=e[3];const p=j;let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=k=>{g(Y=>{const q=new Set(Y);return q.has(k)?q.delete(k):q.add(k),q})},e[4]=S):S=e[4];const M=S;let R;e[5]!==d||e[6]!==n?(R=(k,Y)=>{const q=n.find(Q=>Q.id===k);if(!q||q.completed===Y)return;const ce=n.filter(Q=>Q.id!==k),pe={...q,completed:Y};d(Y?[...ce,pe]:jr(ce,pe))},e[5]=d,e[6]=n,e[7]=R):R=e[7];const F=R;let U;e[8]!==d||e[9]!==n?(U=k=>{d(n.filter(Y=>Y.id!==k))},e[8]=d,e[9]=n,e[10]=U):U=e[10];const T=U;let w;e[11]!==d||e[12]!==n?(w=()=>{const k=n.filter(vu);k.length!==n.length&&d(k)},e[11]=d,e[12]=n,e[13]=w):w=e[13];const H=w;let P;e[14]!==d||e[15]!==n?(P=k=>{const{active:Y,over:q}=k;if(!q||Y.id===q.id)return;const ce=n.findIndex(Q=>Q.id===Y.id),pe=n.findIndex(Q=>Q.id===q.id);ce===-1||pe===-1||d(xu(dl(n,ce,pe)))},e[14]=d,e[15]=n,e[16]=P):P=e[16];const N=P;let $;e[17]===Symbol.for("react.memo_cache_sentinel")?($={activationConstraint:{distance:8}},e[17]=$):$=e[17];const B=Qr(Xr(Zr,$));let G;e[18]!==b?(G=b.slice(0,Fs),e[18]=b,e[19]=G):G=e[19];const J=G;let L;e[20]!==n?(L=n.reduce(ju,0),e[20]=n,e[21]=L):L=e[21];const _=L;let se;if(e[22]!==r||e[23]!==n){let k;e[25]!==r?(k=Y=>Zs([Y.text],r),e[25]=r,e[26]=k):k=e[26],se=n.filter(k),e[22]=r,e[23]=n,e[24]=se}else se=e[24];const ne=se,V=o||_===0;let ee;e[27]!==f?(ee=f("rightSidebar.contextNotesTodo.todo.clearCompleted"),e[27]=f,e[28]=ee):ee=e[28];let C;e[29]!==H||e[30]!==V||e[31]!==ee?(C=t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{type:"button",onClick:H,disabled:V,className:"typography-meta rounded-md px-1.5 py-0.5 text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",children:ee})}),e[29]=H,e[30]=V,e[31]=ee,e[32]=C):C=e[32];let W;e[33]!==J.length?(W=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[J.length,"/",Fs]}),e[33]=J.length,e[34]=W):W=e[34];let O;e[35]!==C||e[36]!==W?(O=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[C,W]}),e[35]=C,e[36]=W,e[37]=O):O=e[37];let A;e[38]===Symbol.for("react.memo_cache_sentinel")?(A=k=>h(k.target.value.slice(0,Fs)),e[38]=A):A=e[38];let z;e[39]!==p?(z=k=>{k.key==="Enter"&&(k.preventDefault(),p())},e[39]=p,e[40]=z):z=e[40];let v;e[41]!==f?(v=f("rightSidebar.contextNotesTodo.todo.inputPlaceholder"),e[41]=f,e[42]=v):v=e[42];let Z;e[43]!==o||e[44]!==z||e[45]!==v||e[46]!==J?(Z=t.jsx(Nt,{value:J,onChange:A,onKeyDown:z,placeholder:v,disabled:o,className:"h-8"}),e[43]=o,e[44]=z,e[45]=v,e[46]=J,e[47]=Z):Z=e[47];let X;e[48]!==o||e[49]!==J?(X=o||J.trim().length===0,e[48]=o,e[49]=J,e[50]=X):X=e[50];let ie;e[51]!==f?(ie=f("rightSidebar.contextNotesTodo.todo.addAria"),e[51]=f,e[52]=ie):ie=e[52];let je;e[53]!==f?(je=f("rightSidebar.contextNotesTodo.todo.addAria"),e[53]=f,e[54]=je):je=e[54];let de;e[55]===Symbol.for("react.memo_cache_sentinel")?(de=t.jsx(E,{name:"add",className:"h-4 w-4"}),e[55]=de):de=e[55];let Re;e[56]!==p||e[57]!==X||e[58]!==ie||e[59]!==je?(Re=t.jsx("button",{type:"button",onClick:p,disabled:X,className:"inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border border-border/70 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":ie,title:je,children:de}),e[56]=p,e[57]=X,e[58]=ie,e[59]=je,e[60]=Re):Re=e[60];let le;e[61]!==Z||e[62]!==Re?(le=t.jsxs("div",{className:"flex items-center gap-1.5",children:[Z,Re]}),e[61]=Z,e[62]=Re,e[63]=le):le=e[63];let me;e[64]!==a||e[65]!==x||e[66]!==T||e[67]!==N||e[68]!==F||e[69]!==l||e[70]!==m||e[71]!==u||e[72]!==r||e[73]!==i||e[74]!==f||e[75]!==B||e[76]!==ne?(me=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:ne.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:r.trim()?f("rightSidebar.contextNotesTodo.search.noResults",{query:r.trim()}):f("rightSidebar.contextNotesTodo.todo.empty")}):t.jsx(eo,{sensors:B,collisionDetection:to,onDragEnd:N,children:t.jsx(no,{items:ne.map(Su),strategy:cl,children:t.jsx("ul",{className:"divide-y divide-border/50",children:ne.map(k=>{const Y=x.has(k.id);return t.jsx(bu,{id:k.id,children:q=>t.jsxs("div",{className:re("flex gap-1.5 px-2.5 py-1.5",Y?"items-start":"items-center"),children:[t.jsx("button",{type:"button",ref:q.setActivatorNodeRef,...q.attributes,...q.listeners,onClick:Nu,className:"flex h-6 w-4 flex-shrink-0 touch-none items-center justify-center text-muted-foreground hover:text-foreground","aria-label":f("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:k.text}),title:f("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:k.text}),children:t.jsx(E,{name:"draggable",className:"h-3.5 w-3.5"})}),t.jsx("div",{className:"flex h-6 items-center",children:t.jsx(hs,{checked:k.completed,onChange:ce=>F(k.id,ce),ariaLabel:f("rightSidebar.contextNotesTodo.todo.actions.markComplete",{text:k.text})})}),t.jsx("button",{type:"button",onClick:()=>M(k.id),className:re("block min-h-6 min-w-0 flex-1 bg-transparent p-0 text-left typography-ui-label leading-normal text-foreground",Y?"whitespace-normal break-words":"overflow-hidden text-ellipsis whitespace-nowrap","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",k.completed&&"text-muted-foreground line-through"),title:Y?void 0:k.text,"aria-label":Y?f("rightSidebar.contextNotesTodo.todo.actions.collapse",{text:k.text}):f("rightSidebar.contextNotesTodo.todo.actions.expand",{text:k.text}),children:k.text}),t.jsxs("div",{className:"flex h-6 items-center gap-0.5",children:[t.jsx("button",{type:"button",onClick:()=>T(k.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":f("rightSidebar.contextNotesTodo.todo.actions.delete",{text:k.text}),title:f("rightSidebar.contextNotesTodo.todo.actions.delete",{text:k.text}),children:t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})}),t.jsxs(Ht,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx("button",{type:"button",disabled:i===k.id,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":f("rightSidebar.contextNotesTodo.todo.actions.send",{text:k.text}),title:f("rightSidebar.contextNotesTodo.todo.actions.send",{text:k.text}),children:t.jsx(E,{name:"send-plane",className:"h-3.5 w-3.5"})})}),t.jsxs(qt,{align:"end",className:"w-56",children:[t.jsx(Bt,{onClick:()=>l(k.text),children:f("rightSidebar.contextNotesTodo.todo.sendMenu.currentSession")}),t.jsx(Bt,{onClick:()=>m(k.id,k.text),children:f("rightSidebar.contextNotesTodo.todo.sendMenu.newSession")}),t.jsx(Bt,{onClick:()=>u(k.id,k.text),disabled:!a,children:f("rightSidebar.contextNotesTodo.todo.sendMenu.newWorktreeSession")})]})]})]})]})},k.id)})})})})}),e[64]=a,e[65]=x,e[66]=T,e[67]=N,e[68]=F,e[69]=l,e[70]=m,e[71]=u,e[72]=r,e[73]=i,e[74]=f,e[75]=B,e[76]=ne,e[77]=me):me=e[77];let Te;return e[78]!==O||e[79]!==le||e[80]!==me?(Te=t.jsxs("div",{className:"space-y-2",children:[O,le,me]}),e[78]=O,e[79]=le,e[80]=me,e[81]=Te):Te=e[81],Te};function wu(){return new Set}function vu(s){return!s.completed}function ju(s,e){return s+(e.completed?1:0)}function Su(s){return s.id}function Nu(s){s.preventDefault(),s.stopPropagation()}const ku=s=>{const{projectRef:e,canCreateWorktree:n,onActionComplete:r}=s,{t:o}=nt(),[a,i]=c.useState(null),[d,l]=c.useState(!1),[m,u]=c.useState(null),f=ut(w=>w.currentSessionId),b=ut(w=>w.createSession),h=ut(w=>w.initializeNewAiWorkerSession),x=ut(w=>w.sendMessage),g=ut(w=>w.setCurrentSession),j=ei(w=>w.setPendingInputText),p=Ke(w=>w.setSessionSwitcherOpen),S=c.useCallback(()=>{p(!1)},[p]),M=c.useCallback(w=>{if(!f){ge.error(o("rightSidebar.contextNotesTodo.toast.noActiveSession"));return}S();const H=`\`\`\`md
|
|
8
|
-
${w}
|
|
9
|
-
\`\`\``;j(H,"append"),ge.success(o("rightSidebar.contextNotesTodo.toast.sentToCurrentSession")),r?.()},[f,r,S,j,o]),R=c.useCallback((w,H)=>{!e||m||i({kind:"session",todoId:w,todoText:H})},[e,m]),F=c.useCallback((w,H)=>{if(!(!e||m)){if(!n){ge.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}i({kind:"worktree",todoId:w,todoText:H})}},[n,e,m,o]),U=c.useCallback(async w=>{if(!e||!a)return;const H=await _t("plan.todo.visible",{todo_text:a.todoText}),N=[{synthetic:!0,text:await _t("plan.todo.instructions",{todo_text:a.todoText})}];l(!0),u(a.todoId);try{S();let $=null,B=e.path;if(a.kind==="worktree"){if(!n){ge.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}const J=await ti(e.path,si());if(!J?.id)return;$=J.id,B=J.path}else{const J=await b(void 0,e.path,null);if(!J?.id){ge.error(o("rightSidebar.contextNotesTodo.toast.createSessionFailed"));return}$=J.id,B=J.directory??e.path,h(J.id,Tt.getState().agents??[])}if(!$)return;const G=Or.getState();G.saveSessionModelSelection($,w.providerID,w.modelID),w.agent.trim()&&(G.saveSessionAgentSelection($,w.agent),G.saveAgentModelForSession($,w.agent,w.providerID,w.modelID),G.saveAgentModelVariantForSession($,w.agent,w.providerID,w.modelID,w.variant||void 0)),g($,B),await x(H,w.providerID,w.modelID,w.agent.trim()||void 0,void 0,void 0,N,w.variant||void 0),ge.success(a.kind==="worktree"?o("rightSidebar.contextNotesTodo.toast.sentToNewWorktreeSession"):o("rightSidebar.contextNotesTodo.toast.sentToNewSession")),i(null),r?.()}catch($){const B=$ instanceof Error?$.message:void 0;ge.error(o("rightSidebar.contextNotesTodo.toast.sendTodoFailed"),B?{description:B}:void 0)}finally{l(!1),u(null)}},[n,b,h,r,a,e,S,x,g,o]),T=c.useCallback(()=>{d||i(null)},[d]);return{pendingSendTarget:a,isSubmitting:d,sendingTodoId:m,sendToCurrentSession:M,sendToNewSession:R,sendToNewWorktreeSession:F,confirmSend:U,closeDialog:T}},Cu=c.lazy(()=>ts(()=>import("./PlanView-CJTmOF6I.js"),__vite__mapDeps([115,2,3,4,5,6,7,8,9,116,57,58,59,60,61,62,79,55,56,63,117,118,119,1,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,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,120,121,113,114,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98])).then(s=>({default:s.PlanView}))),Sr=["notes","todos","plans","memory"],Iu=120,Tu=320,fn=s=>Math.min(Tu,Math.max(Iu,Math.round(s))),Du=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],js=(s,e)=>s.toLowerCase().includes(e),Pu=s=>{const e=_e.c(242),{projectRef:n,projectLabel:r,canCreateWorktree:o,onActionComplete:a,onOpenPlan:i,className:d}=s,l=o===void 0?!1:o,{t:m}=nt();let u;e[0]!==n?(u=zr(n),e[0]=n,e[1]=u):u=e[1];const f=u;let b;e[2]!==f?(b=be=>(f?be.entries[f]:void 0)??ni,e[2]=f,e[3]=b):b=e[3];const h=Rt(b),x=Rt(Eu),g=Rt(Ru),j=ut(Au),p=ut(Mu),S=ut(Lu),M=ut(Bu);let R;e[4]===Symbol.for("react.memo_cache_sentinel")?(R={notes:[],plans:[]},e[4]=R):R=e[4];const[F,U]=c.useState(R);let T,w;e[5]!==p||e[6]!==j||e[7]!==S.open||e[8]!==S.projectContextPins?(T=()=>{if(S.open){U(S.projectContextPins??{notes:[],plans:[]});return}let be=!1;return ri(p,j).then(rt=>{be||U({notes:rt.notes.map(Fu),plans:rt.plans.map(Ou)})}),()=>{be=!0}},w=[p,j,S.open,S.projectContextPins],e[5]=p,e[6]=j,e[7]=S.open,e[8]=S.projectContextPins,e[9]=T,e[10]=w):(T=e[9],w=e[10]),c.useEffect(T,w);let H;e[11]!==p||e[12]!==j||e[13]!==S.open||e[14]!==M?(H=async(be,rt,Ct)=>{if(S.open)return M(be,rt,Ct),!0;if(!j||!p)return!1;const Vt=await oi(p,j,be,rt,Ct);return Vt?(U(Vt),!0):!1},e[11]=p,e[12]=j,e[13]=S.open,e[14]=M,e[15]=H):H=e[15];const P=H;let N;e[16]!==F.notes?(N=new Set(F.notes),e[16]=F.notes,e[17]=N):N=e[17];const $=N;let B;e[18]!==F.plans?(B=new Set(F.plans),e[18]=F.plans,e[19]=B):B=e[19];const G=B,J=Ke($u),L=At(Vu),_=J&&!L,se=At(Wu);let ne;e[20]!==n?.path?(ne=be=>Wr(be,n?.path??null),e[20]=n?.path,e[21]=ne):ne=e[21];const V=At(ne),ee=Ke(zu),C=Ke(Uu),W=Ke(_u);let O;e[22]!==C?(O=Sr.includes(C)?C:"notes",e[22]=C,e[23]=O):O=e[23];const A=O,z=A==="memory"&&!_?"notes":A,[v,Z]=c.useState(""),[X,ie]=c.useState(null);let je;e[24]!==v?(je=v.trim().toLowerCase(),e[24]=v,e[25]=je):je=e[25];const de=je;let Re;e[26]!==h.todos?(Re=Du(h.todos),e[26]=h.todos,e[27]=Re):Re=e[27];const le=Re,me=h.loading&&!h.loaded;let Te;e[28]!==se||e[29]!==V?(Te=[...se,...V],e[28]=se,e[29]=V,e[30]=Te):Te=e[30];const k=Te;let Y;e:{if(!de){let wt;e[31]!==h.notes.length||e[32]!==h.plans.length||e[33]!==k.length||e[34]!==le.length?(wt={notes:h.notes.length,todos:le.length,plans:h.plans.length,memory:k.length},e[31]=h.notes.length,e[32]=h.plans.length,e[33]=k.length,e[34]=le.length,e[35]=wt):wt=e[35],Y=wt;break e}let be;if(e[36]!==h.notes||e[37]!==de){let wt;e[39]!==de?(wt=ws=>js(ws.body,de),e[39]=de,e[40]=wt):wt=e[40],be=h.notes.filter(wt),e[36]=h.notes,e[37]=de,e[38]=be}else be=e[38];const rt=be.length;let Ct;if(e[41]!==le||e[42]!==de){let wt;e[44]!==de?(wt=ws=>js(ws.text,de),e[44]=de,e[45]=wt):wt=e[45],Ct=le.filter(wt),e[41]=le,e[42]=de,e[43]=Ct}else Ct=e[43];const Vt=Ct.length;let cs;if(e[46]!==h.plans||e[47]!==de){let wt;e[49]!==de?(wt=ws=>js(ws.title,de),e[49]=de,e[50]=wt):wt=e[50],cs=h.plans.filter(wt),e[46]=h.plans,e[47]=de,e[48]=cs}else cs=e[48];const Po=cs.length;let ds;e[51]!==k||e[52]!==de?(ds=k.filter(wt=>js(wt.title,de)||js(wt.body,de)),e[51]=k,e[52]=de,e[53]=ds):ds=e[53];let Ls;e[54]!==be.length||e[55]!==Ct.length||e[56]!==cs.length||e[57]!==ds.length?(Ls={notes:rt,todos:Vt,plans:Po,memory:ds.length},e[54]=be.length,e[55]=Ct.length,e[56]=cs.length,e[57]=ds.length,e[58]=Ls):Ls=e[58],Y=Ls}const q=Y,ce=Ke(Gu);let pe;e[59]!==n?.path?(pe=be=>be.agentMemoryViewedAt[Wn("project",n?.path??null)]??0,e[59]=n?.path,e[60]=pe):pe=e[60];const Q=Ke(pe),ue=vr(se,ce)+vr(V,Q),Ee=Ke(Hu),Pe=Ke(Ku),[he,Ie]=c.useState(!1),[ke,Le]=c.useState(null),Ge=ke??Ee;let Je;e[61]!==Ge?(Je=fn(Ge),e[61]=Ge,e[62]=Je):Je=e[62];const Ve=Je;let Ye;e[63]!==Ve?(Ye=be=>{be.currentTarget.setPointerCapture(be.pointerId),Ie(!0),Le(Ve)},e[63]=Ve,e[64]=Ye):Ye=e[64];const Qe=Ye;let st;e[65]===Symbol.for("react.memo_cache_sentinel")?(st=be=>{if(!be.currentTarget.hasPointerCapture(be.pointerId))return;const rt=be.currentTarget.closest("nav")?.getBoundingClientRect().right??0;Le(fn(rt-be.clientX))},e[65]=st):st=e[65];const qe=st;let Xe;e[66]!==Pe?(Xe=be=>{be.currentTarget.hasPointerCapture(be.pointerId)&&be.currentTarget.releasePointerCapture(be.pointerId),Ie(!1),Le(rt=>(rt!==null&&Pe(fn(rt)),null))},e[66]=Pe,e[67]=Xe):Xe=e[67];const ot=Xe;let Ze;e[68]!==l||e[69]!==a||e[70]!==n?(Ze={projectRef:n,canCreateWorktree:l,onActionComplete:a},e[68]=l,e[69]=a,e[70]=n,e[71]=Ze):Ze=e[71];const Ne=ku(Ze);let ze,$e;e[72]!==x||e[73]!==n?(ze=()=>{n&&x(n)},$e=[x,n],e[72]=x,e[73]=n,e[74]=ze,e[75]=$e):(ze=e[74],$e=e[75]),c.useEffect(ze,$e);const He=c.useRef(null);let at,xe;e[76]!==h.error||e[77]!==h.loaded||e[78]!==m?(at=()=>{if(!h.error){He.current=null;return}He.current!==h.error&&(He.current=h.error,h.loaded||ge.error(m("rightSidebar.contextNotesTodo.toast.loadNotesFailed")))},xe=[h.error,h.loaded,m],e[76]=h.error,e[77]=h.loaded,e[78]=m,e[79]=at,e[80]=xe):(at=e[79],xe=e[80]),c.useEffect(at,xe);let et;e[81]===Symbol.for("react.memo_cache_sentinel")?(et=()=>{ie(null)},e[81]=et):et=e[81];let pt;e[82]!==f?(pt=[f],e[82]=f,e[83]=pt):pt=e[83],c.useEffect(et,pt);let gt,yt;e[84]!==z?(gt=()=>{z!=="plans"&&ie(null)},yt=[z],e[84]=z,e[85]=gt,e[86]=yt):(gt=e[85],yt=e[86]),c.useEffect(gt,yt);let Dt;e[87]===Symbol.for("react.memo_cache_sentinel")?(Dt=()=>{Z("")},e[87]=Dt):Dt=e[87];let y;e[88]!==f?(y=[f],e[88]=f,e[89]=y):y=e[89],c.useEffect(Dt,y);let K,Ae;e[90]!==z||e[91]!==q||e[92]!==W||e[93]!==de?(K=()=>{if(!de||q[z]>0)return;const be=Sr.find(rt=>q[rt]>0);be&&W(be)},Ae=[z,q,W,de],e[90]=z,e[91]=q,e[92]=W,e[93]=de,e[94]=K,e[95]=Ae):(K=e[94],Ae=e[95]),c.useEffect(K,Ae);let Ue;e[96]!==n||e[97]!==g||e[98]!==m?(Ue=be=>{n&&g(n,be).then(rt=>{rt||ge.error(m("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[96]=n,e[97]=g,e[98]=m,e[99]=Ue):Ue=e[99];const I=Ue;let oe;e[100]!==m?(oe=m("rightSidebar.contextNotesTodo.tabs.notes"),e[100]=m,e[101]=oe):oe=e[101];const ye=String(q.notes);let Se;e[102]!==oe||e[103]!==ye?(Se={id:"notes",icon:"sticky-note",label:oe,count:ye},e[102]=oe,e[103]=ye,e[104]=Se):Se=e[104];let Ce;e[105]!==m?(Ce=m("rightSidebar.contextNotesTodo.tabs.todos"),e[105]=m,e[106]=Ce):Ce=e[106];const Fe=String(q.todos);let it;e[107]!==Ce||e[108]!==Fe?(it={id:"todos",icon:"checkbox-circle",label:Ce,count:Fe},e[107]=Ce,e[108]=Fe,e[109]=it):it=e[109];let ct;e[110]!==m?(ct=m("rightSidebar.contextNotesTodo.tabs.plans"),e[110]=m,e[111]=ct):ct=e[111];const jt=String(q.plans);let vt;e[112]!==ct||e[113]!==jt?(vt={id:"plans",icon:"file-text",label:ct,count:jt},e[112]=ct,e[113]=jt,e[114]=vt):vt=e[114];let xt;e[115]!==q.memory||e[116]!==ue||e[117]!==_||e[118]!==m?(xt=_?[{id:"memory",icon:"brain-4",label:m("rightSidebar.contextNotesTodo.tabs.memory"),count:ue>0?`${ue}/${q.memory}`:String(q.memory)}]:[],e[115]=q.memory,e[116]=ue,e[117]=_,e[118]=m,e[119]=xt):xt=e[119];let bt;e[120]!==Se||e[121]!==it||e[122]!==vt||e[123]!==xt?(bt=[Se,it,vt,...xt],e[120]=Se,e[121]=it,e[122]=vt,e[123]=xt,e[124]=bt):bt=e[124];const We=bt;if(!n){let be;e[125]!==d?(be=re("w-full min-w-0 p-3",d),e[125]=d,e[126]=be):be=e[126];let rt;e[127]!==m?(rt=m("rightSidebar.contextNotesTodo.empty.selectProject"),e[127]=m,e[128]=rt):rt=e[128];let Ct;e[129]!==rt?(Ct=t.jsx("p",{className:"typography-meta text-muted-foreground",children:rt}),e[129]=rt,e[130]=Ct):Ct=e[130];let Vt;return e[131]!==be||e[132]!==Ct?(Vt=t.jsx("div",{className:be,children:Ct}),e[131]=be,e[132]=Ct,e[133]=Vt):Vt=e[133],Vt}let fe;e[134]!==r||e[135]!==n.path?(fe=r?.trim()||n.path.split("/").filter(Boolean).pop()||n.path,e[134]=r,e[135]=n.path,e[136]=fe):fe=e[136];const Be=fe;let tt;e[137]!==d?(tt=re("flex h-full min-h-0 w-full min-w-0 flex-col",d),e[137]=d,e[138]=tt):tt=e[138];let ht;e[139]!==X||e[140]!==m?(ht=X?t.jsx("button",{type:"button",onClick:()=>ie(null),className:"inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":m("rightSidebar.contextNotesTodo.plans.actions.back"),title:m("rightSidebar.contextNotesTodo.plans.actions.back"),children:t.jsx(E,{name:"arrow-left-s",className:"h-4 w-4"})}):null,e[139]=X,e[140]=m,e[141]=ht):ht=e[141];let It;e[142]!==n.path||e[143]!==Be?(It=t.jsx("h3",{className:"min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",title:n.path,children:Be}),e[142]=n.path,e[143]=Be,e[144]=It):It=e[144];let D;e[145]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e[145]=D):D=e[145];let te;e[146]===Symbol.for("react.memo_cache_sentinel")?(te=be=>Z(be.target.value),e[146]=te):te=e[146];let we;e[147]!==m?(we=m("rightSidebar.contextNotesTodo.search.placeholder"),e[147]=m,e[148]=we):we=e[148];let Oe;e[149]!==v||e[150]!==we?(Oe=t.jsx(Nt,{value:v,onChange:te,placeholder:we,className:"h-8 pl-7 pr-7"}),e[149]=v,e[150]=we,e[151]=Oe):Oe=e[151];let Me;e[152]!==v||e[153]!==m?(Me=v?t.jsx("button",{type:"button",onClick:()=>Z(""),className:"absolute right-1.5 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":m("rightSidebar.contextNotesTodo.search.clear"),title:m("rightSidebar.contextNotesTodo.search.clear"),children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null,e[152]=v,e[153]=m,e[154]=Me):Me=e[154];let De;e[155]!==Oe||e[156]!==Me?(De=t.jsxs("div",{className:"relative w-40 flex-shrink-0",children:[D,Oe,Me]}),e[155]=Oe,e[156]=Me,e[157]=De):De=e[157];let lt;e[158]!==ht||e[159]!==It||e[160]!==De?(lt=t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2 p-3 pb-2",children:[ht,It,De]}),e[158]=ht,e[159]=It,e[160]=De,e[161]=lt):lt=e[161];let ft;e[162]!==z||e[163]!==ee||e[164]!==We||e[165]!==W||e[166]!==m?(ft=ee?t.jsx("nav",{className:"flex flex-shrink-0 items-center gap-1.5 overflow-x-auto px-3 pb-2","aria-label":m("rightSidebar.contextNotesTodo.sections.label"),children:We.map(be=>{const rt=z===be.id;return t.jsxs("button",{type:"button",onClick:()=>W(be.id),"aria-current":rt?"page":void 0,className:re("flex flex-shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",rt?"border-transparent bg-interactive-active text-foreground":"border-[var(--interactive-border)] text-muted-foreground"),children:[t.jsx(E,{name:be.icon,className:"h-4 w-4 flex-shrink-0"}),rt?t.jsx("span",{className:"whitespace-nowrap typography-meta",children:be.label}):null,t.jsx("span",{className:"typography-micro text-muted-foreground",children:be.count})]},be.id)})}):null,e[162]=z,e[163]=ee,e[164]=We,e[165]=W,e[166]=m,e[167]=ft):ft=e[167];const Pt=X?"overflow-hidden":"overflow-y-auto";let dt;e[168]!==Pt?(dt=re("min-h-0 min-w-0 flex-1 p-3",Pt),e[168]=Pt,e[169]=dt):dt=e[169];let kt;e[170]!==z||e[171]!==h.notes||e[172]!==me||e[173]!==$||e[174]!==n||e[175]!==v||e[176]!==P?(kt=z==="notes"?t.jsx(cu,{projectRef:n,notes:h.notes,disabled:me,query:v,pinnedNoteIds:$,onTogglePinned:(be,rt)=>P("note",be,rt)}):null,e[170]=z,e[171]=h.notes,e[172]=me,e[173]=$,e[174]=n,e[175]=v,e[176]=P,e[177]=kt):kt=e[177];let $t;e[178]!==z||e[179]!==l||e[180]!==I||e[181]!==me||e[182]!==v||e[183]!==Ne.sendToCurrentSession||e[184]!==Ne.sendToNewSession||e[185]!==Ne.sendToNewWorktreeSession||e[186]!==Ne.sendingTodoId||e[187]!==le?($t=z==="todos"?t.jsx(yu,{todos:le,query:v,disabled:me,canCreateWorktree:l,sendingTodoId:Ne.sendingTodoId,onPersistTodos:I,onSendToCurrentSession:Ne.sendToCurrentSession,onSendToNewSession:Ne.sendToNewSession,onSendToNewWorktreeSession:Ne.sendToNewWorktreeSession}):null,e[178]=z,e[179]=l,e[180]=I,e[181]=me,e[182]=v,e[183]=Ne.sendToCurrentSession,e[184]=Ne.sendToNewSession,e[185]=Ne.sendToNewWorktreeSession,e[186]=Ne.sendingTodoId,e[187]=le,e[188]=$t):$t=e[188];let Ut;e[189]!==z||e[190]!==_||e[191]!==n.path||e[192]!==v?(Ut=z==="memory"&&_?t.jsx(eu,{projectPath:n.path,query:v}):null,e[189]=z,e[190]=_,e[191]=n.path,e[192]=v,e[193]=Ut):Ut=e[193];let ss;e[194]!==z||e[195]!==h.plans||e[196]!==i||e[197]!==X||e[198]!==G||e[199]!==n||e[200]!==v||e[201]!==P?(ss=z==="plans"&&!X?t.jsx(pu,{projectRef:n,plans:h.plans,query:v,pinnedPlanIds:G,onTogglePinned:(be,rt)=>P("plan",be,rt),onOpenPlan:i??ie}):null,e[194]=z,e[195]=h.plans,e[196]=i,e[197]=X,e[198]=G,e[199]=n,e[200]=v,e[201]=P,e[202]=ss):ss=e[202];let ns;e[203]!==z||e[204]!==X||e[205]!==n?(ns=z==="plans"&&X&&n?t.jsx(c.Suspense,{fallback:null,children:t.jsx(Cu,{savedProjectPlan:{projectRef:n,planId:X.id},onNavigatedToChat:()=>ie(null)})}):null,e[203]=z,e[204]=X,e[205]=n,e[206]=ns):ns=e[206];let rs;e[207]!==dt||e[208]!==kt||e[209]!==$t||e[210]!==Ut||e[211]!==ss||e[212]!==ns?(rs=t.jsxs("div",{className:dt,children:[kt,$t,Ut,ss,ns]}),e[207]=dt,e[208]=kt,e[209]=$t,e[210]=Ut,e[211]=ss,e[212]=ns,e[213]=rs):rs=e[213];let os;e[214]!==z||e[215]!==ot||e[216]!==Qe||e[217]!==ee||e[218]!==he||e[219]!==We||e[220]!==W||e[221]!==Ve||e[222]!==m?(os=ee?null:t.jsxs("nav",{className:"relative flex flex-shrink-0 flex-col gap-0.5 overflow-y-auto border-l border-[var(--interactive-border)] p-2",style:{width:`${Ve}px`},"aria-label":m("rightSidebar.contextNotesTodo.sections.label"),children:[t.jsx("div",{className:re("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",he&&"bg-[var(--interactive-border)]"),onPointerDown:Qe,onPointerMove:qe,onPointerUp:ot,onPointerCancel:ot,role:"separator","aria-orientation":"vertical","aria-label":m("rightSidebar.contextNotesTodo.sections.resize")}),We.map(be=>{const rt=z===be.id;return t.jsxs("button",{type:"button",onClick:()=>W(be.id),"aria-current":rt?"page":void 0,className:re("flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",rt?"bg-interactive-active text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),style:{minHeight:0},children:[t.jsx(E,{name:be.icon,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:be.label}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:be.count})]},be.id)})]}),e[214]=z,e[215]=ot,e[216]=Qe,e[217]=ee,e[218]=he,e[219]=We,e[220]=W,e[221]=Ve,e[222]=m,e[223]=os):os=e[223];let as;e[224]!==rs||e[225]!==os?(as=t.jsxs("div",{className:"flex min-h-0 flex-1",children:[rs,os]}),e[224]=rs,e[225]=os,e[226]=as):as=e[226];const en=Ne.pendingSendTarget!==null;let is;e[227]!==Ne?(is=be=>{be||Ne.closeDialog()},e[227]=Ne,e[228]=is):is=e[228];const tn=Ne.pendingSendTarget?.kind??"session";let ls;e[229]!==n.path||e[230]!==Ne.confirmSend||e[231]!==Ne.isSubmitting||e[232]!==en||e[233]!==is||e[234]!==tn?(ls=t.jsx(Kl,{open:en,onOpenChange:is,target:tn,projectDirectory:n.path,submitting:Ne.isSubmitting,onConfirm:Ne.confirmSend}),e[229]=n.path,e[230]=Ne.confirmSend,e[231]=Ne.isSubmitting,e[232]=en,e[233]=is,e[234]=tn,e[235]=ls):ls=e[235];let Ms;return e[236]!==tt||e[237]!==lt||e[238]!==ft||e[239]!==as||e[240]!==ls?(Ms=t.jsxs("div",{className:tt,children:[lt,ft,as,ls]}),e[236]=tt,e[237]=lt,e[238]=ft,e[239]=as,e[240]=ls,e[241]=Ms):Ms=e[241],Ms};function Eu(s){return s.load}function Ru(s){return s.saveTodos}function Au(s){return s.currentSessionId}function Mu(s){return s.currentSessionDirectory}function Lu(s){return s.newSessionDraft}function Bu(s){return s.setDraftProjectContextPin}function Fu(s){return s.id}function Ou(s){return s.id}function $u(s){return s.agentMemoryFeatureAvailable&&s.agentMemoryToolEnabled}function Vu(s){return s.disabled}function Wu(s){return s.global}function zu(s){return s.isMobile}function Uu(s){return s.projectContextTab}function _u(s){return s.setProjectContextTab}function Gu(s){return s.agentMemoryViewedAt[Wn("global",null)]??0}function Hu(s){return s.projectContextSidebarWidth}function Ku(s){return s.setProjectContextSidebarWidth}const qu=({projects:s,worktreesByProject:e,directory:n,activeProjectId:r,chatDraftOpen:o,chatDraftTarget:a,homeDirectory:i})=>{const d=ai(n)??ii(i),l=Ks(n),m=Ks(d);if((o?a==="chat":!!(l&&m&&(l===m||l.startsWith(`${m}/`))))&&d)return{id:In,path:d};const f=li(s,e,n);if(f)return{id:f.id,path:f.path};if(l)return null;const b=s.find(h=>h.id===r)??null;return b?{id:b.id,path:b.path}:null},Ju=s=>{const e=_e.c(8),n=Et(Yu),r=Et(Qu),o=ys(Xu),a=ut(Zu),i=ut(em),d=ut(tm);let l;return e[0]!==r||e[1]!==i||e[2]!==d||e[3]!==s||e[4]!==o||e[5]!==n||e[6]!==a?(l=qu({projects:n,worktreesByProject:a,directory:s,activeProjectId:r,chatDraftOpen:i,chatDraftTarget:d,homeDirectory:o}),e[0]=r,e[1]=i,e[2]=d,e[3]=s,e[4]=o,e[5]=n,e[6]=a,e[7]=l):l=e[7],l};function Yu(s){return s.projects}function Qu(s){return s.activeProjectId}function Xu(s){return s.homeDirectory}function Zu(s){return s.availableWorktreesByProject}function em(s){return s.newSessionDraft.open}function tm(s){return s.newSessionDraft.target}const Nf=s=>{const e=_e.c(18),{onActionComplete:n,onOpenPlan:r}=s,o=ys(sm),{t:a}=nt(),i=Mn(nm),d=ut(rm),l=Ju(d),m=Et(om);let u;e[0]!==l||e[1]!==m?(u=l?m.find(p=>p.id===l.id)??null:null,e[0]=l,e[1]=m,e[2]=u):u=e[2];const f=u;let b;e:{if(!l){b=null;break e}if(l.id===In){let S;e[3]!==a?(S=a("sessions.sidebar.activity.chatsTitle"),e[3]=a,e[4]=S):S=e[4],b=S;break e}let p;e[5]!==o||e[6]!==f?.label||e[7]!==l.path?(p=f?.label?.trim()||ci(l.path,o)||l.path,e[5]=o,e[6]=f?.label,e[7]=l.path,e[8]=p):p=e[8],b=p}const h=b;let x;e:{if(!l||l.id===In){x=!1;break e}let p;e[9]!==i||e[10]!==l.path?(p=i.get(l.path)?.isGitRepo,e[9]=i,e[10]=l.path,e[11]=p):p=e[11],x=p===!0}const g=x;let j;return e[12]!==g||e[13]!==n||e[14]!==r||e[15]!==h||e[16]!==l?(j=t.jsx("div",{className:"h-full min-h-0 overflow-hidden bg-background",children:t.jsx(Pu,{projectRef:l,projectLabel:h,canCreateWorktree:g,onActionComplete:n,onOpenPlan:r})}),e[12]=g,e[13]=n,e[14]=r,e[15]=h,e[16]=l,e[17]=j):j=e[17],j};function sm(s){return s.homeDirectory}function nm(s){return s.directories}function rm(s){return s.currentSessionDirectory}function om(s){return s.projects}function am(s){const{colors:e}=s,n=e.syntax.base;return{background:e.surface.background,foreground:n.foreground,cursor:e.interactive.cursor,cursorAccent:e.surface.background,selectionBackground:e.interactive.selection,selectionForeground:e.interactive.selectionForeground,selectionInactiveBackground:e.interactive.selection+"50",black:e.surface.muted,red:e.status.error,green:e.status.success,yellow:e.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:e.status.error,brightGreen:e.status.success,brightYellow:e.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:e.surface.elevatedForeground}}const im=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Vs=s=>{const e=s.trim(),n=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e)?.[1];if(n){const d=n.length<=4?n.slice(0,3).split("").map(l=>l+l).join(""):n.slice(0,6);return{r:Number.parseInt(d.slice(0,2),16),g:Number.parseInt(d.slice(2,4),16),b:Number.parseInt(d.slice(4,6),16)}}const r=/^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})(?:\s*[,/]\s*[\d.]+)?\s*\)$/i.exec(e);if(!r)return null;const[o,a,i]=r.slice(1,4).map(Number);return[o,a,i].some(d=>d===void 0||d<0||d>255)?null:{r:o??0,g:a??0,b:i??0}};function Nr(s){const e=Vs(s.background)??{r:0,g:0,b:0},n=Vs(s.foreground)??{r:255,g:255,b:255};return{background:e,foreground:n,cursor:Vs(s.cursor)??n,palette:im.map(r=>Vs(s[r])??n),selectionBackground:s.selectionBackground}}function lm(s,e){if(s.length===0)return{reset:e!==null,replay:!1,pending:[]};if(e===null)return{reset:!1,replay:!0,pending:s};let n=-1;for(let r=s.length-1;r>=0;r-=1){const o=s[r].id;if(o===e){n=r;break}if(o<e)break}return n<0?{reset:!0,replay:!0,pending:s}:{reset:!1,replay:!1,pending:s.slice(n+1)}}const cm=async(s,e)=>{const{GhosttyTerminalSurface:n}=await ts(async()=>{const{GhosttyTerminalSurface:r}=await import("./surface-oMvhsog3.js");return{GhosttyTerminalSurface:r}},[]);return n.create(s,e)},dm=2e3,um=s=>new Promise(e=>{const n=setTimeout(e,dm);di(s).finally(()=>{clearTimeout(n),e()})}),kr=4,mm=(s,e,n)=>{const r=s.ownerDocument.createElement("canvas").getContext("2d");if(!r||s.clientWidth<24||s.clientHeight<24)return null;r.font=`${n}px ${e}`;const o=r.measureText("M"),a=o.width,i=(o.actualBoundingBoxAscent||n*.8)+(o.actualBoundingBoxDescent||n*.2),d=Math.max(1,Math.round(n*1.35),Math.ceil(i));return a<1||d<1?null:{cols:Math.max(2,Math.floor((s.clientWidth-kr*2)/a)),rows:Math.max(1,Math.floor((s.clientHeight-kr*2)/d))}},ko=c.forwardRef(({sessionKey:s,chunks:e,onInput:n,onResize:r,onProvisionalSize:o,theme:a,monoFont:i,fontFamily:d,fontSize:l,className:m,enableTouchScroll:u=!1,autoFocus:f=!0,isVisible:b=!0,createSurface:h=cm},x)=>{const{t:g}=nt(),j=c.useRef(null),p=c.useRef(null),S=c.useRef(n),M=c.useRef(r),R=c.useRef(o),F=c.useRef(null),U=c.useRef(b),T=c.useRef({input:"",scrollbar:""}),[w,H]=c.useState(0);return S.current=n,M.current=r,R.current=o,U.current=b,T.current={input:g("terminalView.viewport.inputAria"),scrollbar:g("terminalView.viewport.scrollbarAria")},c.useLayoutEffect(()=>{const P=j.current;if(!P)return;const N=mm(P,d,l);N&&(R.current??M.current)(N.cols,N.rows)},[d,l]),c.useEffect(()=>{const P=j.current;if(!P)return;let N=!1,$=null;const B=a,G={family:d,size:l},J=i,L=!u;return(async()=>{if(await um(J),N)return;let _;try{_=await h(P,{theme:Nr(B),font:G,get visible(){return U.current},labels:T.current,handleTouchPointer:L,onData:se=>S.current(se),onResize:(se,ne)=>M.current(se,ne),onLinkActivate:se=>{Dr(se)}})}catch(se){console.error("[terminal] failed to initialize the terminal renderer",se);return}if(N){_.dispose();return}$=_,p.current=_,_.setVisible(U.current),H(se=>se+1)})(),()=>{N=!0;const _=document.activeElement;_ instanceof HTMLElement&&P.contains(_)&&(_.blur(),window.Capacitor?.getPlatform?.()==="android"&&ts(async()=>{const{Keyboard:ne}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:ne}},__vite__mapDeps([122,123])).then(({Keyboard:ne})=>ne.hide()).catch(()=>{})),$?.dispose(),$=null,p.current=null,F.current=null}},[h]),c.useEffect(()=>{p.current?.setTheme(Nr(a))},[a,w]),c.useEffect(()=>{p.current?.setFont({family:d,size:l})},[d,l,w]),c.useEffect(()=>{p.current?.setVisible(b)},[b,w]),c.useEffect(()=>{const P=p.current;if(!P)return;const{reset:N,replay:$,pending:B}=lm(e,F.current);if($){const[G,...J]=B;P.resetAndWrite(G?G.replayData??G.data:"",G?.size);const L=J.map(_=>_.replayData??_.data).join("");L&&P.write(L)}else N?P.resetAndWrite(""):B.length>0&&P.write(B.map(G=>G.data).join(""));F.current=e.at(-1)?.id??null},[e,w]),c.useEffect(()=>{if(!f||!b)return;const P=requestAnimationFrame(()=>p.current?.focus());return()=>cancelAnimationFrame(P)},[f,b,w,s]),c.useEffect(()=>{const P=j.current,N=p.current;if(!u||!P||!N)return;let $=null,B=null,G="idle",J=0,L=0,_=0,se=0;const ne=Math.max(12,Math.round(l*1.35)),V=()=>{window.Capacitor?.getPlatform?.()==="android"&&ts(async()=>{const{Keyboard:Z}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:Z}},__vite__mapDeps([122,123])).then(({Keyboard:Z})=>Z.show()).catch(()=>{})},ee=()=>{B&&(clearTimeout(B),B=null)},C=v=>{v.pointerType!=="touch"||$!==null||($=v.pointerId,G="pending",J=v.clientX,L=v.clientY,_=v.clientY,se=0,P.setPointerCapture(v.pointerId),B=setTimeout(()=>{B=null,!($!==v.pointerId||G!=="pending")&&N.selectWordAt(J,L)&&(G="selecting")},350))},W=v=>{if($!==v.pointerId)return;if(G==="selecting"){N.extendSelectionTo(v.clientX,v.clientY),v.cancelable&&v.preventDefault();return}if(G==="pending"){if(Math.hypot(v.clientX-J,v.clientY-L)<8)return;ee(),G="scrolling"}if(G!=="scrolling")return;const Z=_-v.clientY;_=v.clientY,se+=Z;const X=Math.trunc(se/ne);X&&(N.scrollLines(X),se-=X*ne),v.cancelable&&v.preventDefault()},O=(v,Z)=>{if($!==v.pointerId)return;const X=Z&&G==="pending";ee(),P.hasPointerCapture(v.pointerId)&&P.releasePointerCapture(v.pointerId),$=null,G="idle",X&&(N.focus(),V())},A=v=>O(v,!0),z=v=>O(v,!1);return P.addEventListener("pointerdown",C),P.addEventListener("pointermove",W,{passive:!1}),P.addEventListener("pointerup",A),P.addEventListener("pointercancel",z),()=>{ee(),P.removeEventListener("pointerdown",C),P.removeEventListener("pointermove",W),P.removeEventListener("pointerup",A),P.removeEventListener("pointercancel",z)}},[u,l,w]),c.useImperativeHandle(x,()=>({focus:()=>p.current?.focus(),fit:()=>{const P=p.current;P&&(P.fit(),P.refresh())},getSelection:()=>{const P=p.current,N=P?.getSelectionPosition(),$=P?.getSelection()??"";return!N||!$.trim()?null:{text:$,startLine:N.start.y+1,endLine:N.end.y+1}}}),[]),t.jsx("div",{ref:j,"data-terminal-owner":"main",className:re("terminal-viewport-container relative h-full w-full overflow-hidden touch-none",m)})});ko.displayName="TerminalViewport";const fm="\x1B",Co=new RegExp(`${fm}\\[[0-9;?]*[ -/]*[@-~]`,"g"),hm=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,pm=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,gm=/Serving HTTP on .*? port (\d{2,5})/i,xm=new Set([".",",",";",":","!","?"]),Io=s=>{let e=s;for(;e.length>0;){const n=e[e.length-1];if(n===")"||n==="]"||n==="}"||n===">"){const r=n===")"?"(":n==="]"?"[":n==="}"?"{":"<",o=e.slice(0,-1),a=(o.match(new RegExp(`\\${r}`,"g"))||[]).length,i=(o.match(new RegExp(`\\${n}`,"g"))||[]).length;if(a>i)break;e=o;continue}if(xm.has(n)){e=e.slice(0,-1);continue}break}return e},En=s=>{let e=Io(s);return e=e.replace("0.0.0.0","127.0.0.1"),e=e.replace("[::1]","127.0.0.1"),e=e.replace("[::]","127.0.0.1"),e},bm=s=>{if(!s)return[];const e=s.replace(Co,""),n=[],r=new Set,o=i=>{r.has(i)||(r.add(i),n.push(i))},a=e.match(gm);if(a?.[1]){const i=Number.parseInt(a[1],10);Number.isFinite(i)&&i>0&&i<=65535&&o(`http://127.0.0.1:${i}/`)}for(const i of e.split(`
|
|
10
|
-
`)){if(!pm.test(i))continue;const d=Array.from(i.matchAll(hm));if(d.length===0)continue;const l=d.find(m=>{try{return!!new URL(En(m[1])).port}catch{return!1}});o(En((l??d[0])[1]))}return n},To=s=>bm(s)[0]??null,ym=async(s,e=1500)=>{if(!s||typeof window>"u")return!1;let n;try{n=new URL(s)}catch{return!1}if(n.protocol!=="http:"&&n.protocol!=="https:")return!1;const r=n.hostname.toLowerCase();if(r!=="localhost"&&r!=="127.0.0.1"&&r!=="0.0.0.0"&&r!=="::1"&&r!=="::")return!1;const o=new AbortController,a=window.setTimeout(()=>o.abort(),e);try{const i=await Jt("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:n.toString()}),cache:"no-store",signal:o.signal});return i.ok?(await i.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(a)}},wm=/https?:\/\/[^\s<>'"`]+/gi,kf=(s,{requireAnnounced:e=!1}={})=>{const n=To(s);if(n)return n;if(e)return null;const r=String(s||"").replace(Co,""),o=[];for(const d of r.match(wm)??[])try{const l=new URL(Io(d));l.port&&o.push(l)}catch{}if(o.length===0)return null;const a=d=>{const l=d.hostname.toLowerCase();return(l==="localhost"||l==="127.0.0.1"||l==="0.0.0.0"||l==="::1"?50:0)-(d.search||d.hash?10:0)};let i=o[0];for(const d of o.slice(1))a(d)>a(i)&&(i=d);return En(i.toString())},vm={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},jm=(s,e)=>{if(e&&s.startsWith("arrow-")){const n=e==="ctrl"?"5":"3",r={"arrow-up":"A","arrow-down":"B","arrow-right":"C","arrow-left":"D"}[s];return`\x1B[1;${n}${r}`}return vm[s]},Do=s=>{const e=s[0]?.toUpperCase();return!e||e<"A"||e>"Z"?null:String.fromCharCode(e.charCodeAt(0)&31)},Sm=(s,e)=>s&&(e==="ctrl"?Do(s)??s:s.length===1&&s!=="\x1B"?`\x1B${s}`:s),Nm="COMMAND_MODE_UNSUPPORTED",km="PROJECT_ACTION_RUN_CANCELLED",Cm="PROJECT_ACTION_PURPOSE_UNSUPPORTED",Im=s=>new Error(s),Tm=async(s,e)=>{try{await s.close(e)}catch{}},hn=async(s,e,n,r)=>{throw e.sessionId===n&&await Tm(s,e.sessionId),Im(r)},Dm=s=>{const e=s.trim().replace(/\r\n|\r/g,`
|
|
11
|
-
`);let n="";for(let r=0;r<e.length;r+=1){const o=e.charCodeAt(r);o>=0&&o<=8||o===11||o===12||o>=14&&o<=31||o===127||(n+=e[r])}return n},Pm=s=>s.mode==="command",Em=s=>s?.type==="project-action",Rm=(s,e)=>Em(s)&&s.actionId===e&&s.executionId.trim().length>0,Cf=async({terminal:s,createOptions:e,command:n,isRunStillExpected:r,purpose:o})=>{const a=await s.createSession({...e,sessionId:o.executionId,mode:"command",command:Dm(n),purpose:o});return Pm(a)||await hn(s,a,o.executionId,Nm),Rm(a.purpose,o.actionId)||await hn(s,a,o.executionId,Cm),r()||await hn(s,a,o.executionId,km),a},Am=(s,e,n)=>new Promise(r=>{let o=!1,a=null,i=null;const d=l=>{o||(o=!0,i&&clearTimeout(i),a?.close(),r(l))};a=s.connect(e,{onEvent:l=>{(l.type==="exit"||l.type==="snapshot"&&l.status==="exited")&&d(!0)},onError:(l,m)=>{m&&d(!0)}}),o?a.close():i=setTimeout(()=>d(!1),n)}),If=async({terminal:s,sessionId:e,isExecutionStillCurrent:n,markStopping:r,restoreRunning:o,clearSession:a,finalizeExit:i,timeoutMs:d=1e3})=>{r();const l=Am(s,e,d);try{n()&&await s.sendInput(e,"")}catch{}const m=await l;if(n()){if(!m){let u=!1;if(s.forceKill)try{n()&&await s.forceKill({sessionId:e})}catch{u=!0}else try{n()&&await s.close(e)}catch{u=!0}if(!n())return;if(u){o();return}a()}n()&&i()}},pn=new WeakMap,Mm=(s,e,n={})=>{if(!s.listSessions)return Promise.resolve(null);const r=Ln(e),o=Gt(),a=`${o}\0${r}`;let i=pn.get(s);i||(i=new Map,pn.set(s,i));const d=i.get(a);if(d)return d;const l=n.captureStartedActionMutationRevisions?.(r)??new Map,m=s.listSessions(r).then(u=>o===Gt()?{sessions:u,startedActionMutationRevisions:l}:null).catch(()=>null).finally(()=>{i.get(a)===m&&(i.delete(a),i.size===0&&pn.delete(s))});return i.set(a,m),m},Lm=s=>{const e=new Map;for(const n of s){const r=Ln(n.cwd),o=e.get(r);o?o.push(n):e.set(r,[n])}return e},Bm=5e3,gn=new WeakMap,Fm=(s,e,n,r)=>{if(!s.listSessions)return()=>{};const o=Ln(e);let a=gn.get(s);if(!a){const d=new Map;let l=!1,m=!1,u=!1,f=!1,b=null,h=0;const x=()=>document.visibilityState!=="hidden"&&navigator.onLine!==!1,g=()=>{b!==null&&clearTimeout(b),b=null},j=()=>{if(g(),!(l||!x())){if(m){u=!0;return}f||(f=!0,queueMicrotask(()=>{if(f=!1,l||!x())return;m=!0,u=!1;const M=h,R=Gt(),F=new Map(d);Mm(s,"",{captureStartedActionMutationRevisions:()=>{const U=new Map;for(const[T,w]of F)for(const[H,P]of w.capture(T))U.set(H,P);return U}}).then(U=>{if(l||h!==M||R!==Gt()||!U)return;const T=Lm(U.sessions);for(const[w,H]of F){if(d.get(w)!==H)continue;const P=w?T.get(w)??[]:U.sessions;for(const N of H.listeners)N({...U,sessions:P})}}).finally(()=>{m=!1,!(l||!x())&&(u?j():b=setTimeout(j,Bm))})}))}},p=()=>{h+=1,j()};window.addEventListener("focus",j),window.addEventListener("online",j),window.addEventListener("offline",g),document.addEventListener("visibilitychange",j);const S=Gr(p);a={scopes:d,refresh:j,close:()=>{l=!0,g(),window.removeEventListener("focus",j),window.removeEventListener("online",j),window.removeEventListener("offline",g),document.removeEventListener("visibilitychange",j),S()}},gn.set(s,a)}let i=a.scopes.get(o);return i||(i={listeners:new Set,capture:n},a.scopes.set(o,i),a.refresh()),i.listeners.add(r),()=>{i.listeners.delete(r),!(i.listeners.size>0)&&(a.scopes.delete(o),!(a.scopes.size>0)&&(a.close(),gn.delete(s)))}},Cr={cols:80,rows:24},Om=s=>{const e=_e.c(25),{directory:n,tabId:r,isActive:o,isTerminalVisible:a,registerController:i,onInput:d,onResize:l,onProvisionalSize:m,theme:u,monoFont:f,fontFamily:b,fontSize:h,enableTouchScroll:x}=s;let g;e[0]!==n||e[1]!==r?(g=H=>H.getBuffer(n,r).chunks,e[0]=n,e[1]=r,e[2]=g):g=e[2];const j=mt(g),p=`${n}::${r}`,S=!o&&"hidden";let M;e[3]!==S?(M=re("h-full w-full",S),e[3]=S,e[4]=M):M=e[4];let R;e[5]!==i||e[6]!==r?(R=H=>i(r,H),e[5]=i,e[6]=r,e[7]=R):R=e[7];const F=a&&o,U=a&&o;let T;e[8]!==j||e[9]!==x||e[10]!==b||e[11]!==h||e[12]!==f||e[13]!==d||e[14]!==m||e[15]!==l||e[16]!==R||e[17]!==F||e[18]!==U||e[19]!==u||e[20]!==p?(T=t.jsx(ko,{ref:R,sessionKey:p,chunks:j,onInput:d,onResize:l,onProvisionalSize:m,theme:u,monoFont:f,fontFamily:b,fontSize:h,enableTouchScroll:x,autoFocus:F,isVisible:U}),e[8]=j,e[9]=x,e[10]=b,e[11]=h,e[12]=f,e[13]=d,e[14]=m,e[15]=l,e[16]=R,e[17]=F,e[18]=U,e[19]=u,e[20]=p,e[21]=T):T=e[21];let w;return e[22]!==M||e[23]!==T?(w=t.jsx("div",{className:M,children:T}),e[22]=M,e[23]=T,e[24]=w):w=e[24],w},$m=s=>On.find(n=>n.key===s)?.Icon??"terminal",Tf=({visible:s,directory:e})=>{const{t:n}=nt(),{terminal:r,runtime:o}=Xs(),{currentTheme:a}=Mr(),i=c.useRef({themeMode:"dark",terminalBackground:"",terminalForeground:""});i.current={themeMode:a.metadata.variant==="light"?"light":"dark",terminalBackground:a.colors.surface.background,terminalForeground:a.colors.syntax.base.foreground};const{monoFont:d}=ui(),l=Ke(D=>D.terminalFontSize),m=Ke(D=>D.terminalShell),u=Ke(D=>D.terminalLoginShells.includes(D.terminalShell)),{isMobile:f,isTablet:b,hasTouchOnlyPointer:h}=bs(),x=f||b,g=(x||h)&&o.platform==="web",j=o.platform!=="vscode",p=Ke(D=>D.showTerminalQuickKeysOnDesktop),S=x||p,M=ut(D=>D.currentSessionId),R=ut(D=>D.newSessionDraft),F=M!==null||R?.open===!0,U=mi()??null,T=e??null,w=T||U,H=T!==null,P=mt(D=>w?D.getDirectoryState(w):void 0),N=mt(D=>D.hasHydrated),$=mt(D=>D.ensureDirectory),B=mt(D=>D.createTab),G=mt(D=>D.setActiveTab),J=mt(D=>D.closeTab),L=mt(D=>D.setTabSessionId),_=mt(D=>D.reconcileServerSessions),se=mt(D=>D.captureStartedActionMutationRevisions),ne=mt(D=>D.setTabLifecycle),V=mt(D=>D.setConnecting),ee=mt(D=>D.appendToBuffer),C=mt(D=>D.replaceBuffer),W=mt(D=>D.setTabPreviewUrl),O=fi(D=>D.addDraft),A=Ke(D=>D.openContextPreview),z=c.useMemo(()=>P?j?P.activeTabId??P.tabs[0]?.id??null:P.tabs[0]?.id??null:null,[P,j]),v=c.useMemo(()=>{if(P)return z?P.tabs.find(D=>D.id===z)??P.tabs[0]:P.tabs[0]},[P,z]),Z=c.useMemo(()=>(P?.tabs??[]).map(D=>({icon:(()=>{const te=D.purpose.type==="project-action"&&$i.has(D.lifecycle),we=te?"loader-4":$m(D.iconKey);return t.jsx(E,{name:we,className:re("h-4 w-4",te&&"animate-spin text-muted-foreground motion-reduce:animate-none")})})(),id:D.id,label:D.label,title:D.label,closeLabel:n("terminalView.tabs.closeTabTitle")})),[P?.tabs,n]),X=v?.terminalSessionId??null,ie=v?.lifecycle??"idle",je=v?.purpose.type==="project-action",de=v?.isConnecting??!1,Re=v?.previewUrl??null,[le,me]=c.useState(null),[Te,k]=c.useState(!1),[Y,q]=c.useState(!1),[ce,pe]=c.useState(null),[Q,ue]=c.useState(!1),Ee=c.useRef(null),Pe=c.useRef(null),he=c.useRef(z),Ie=c.useRef(X),ke=c.useRef(w),Le=c.useRef(null),Ge=c.useRef(new Map),Je=c.useRef(null),Ve=c.useRef(null),Ye=c.useRef(!1),Qe=c.useRef(new Set),st=c.useRef(""),qe=c.useRef(new Set),Xe=c.useRef(0),ot=c.useCallback(()=>{st.current="",qe.current.clear(),Xe.current+=1},[]),Ze=c.useCallback(()=>{g||typeof document<"u"&&!document.hasFocus()||Le.current?.focus()},[g]),Ne=c.useCallback(()=>{g||Le.current?.focus()},[g]),ze=s??!1;Ye.current=ze;const[$e,He]=c.useState(ze);c.useEffect(()=>{ze&&He(!0)},[ze]),c.useEffect(()=>{Ie.current=X},[X]),c.useEffect(()=>{!X||!r.updateAppearance||r.updateAppearance(X,i.current).catch(()=>{})},[a.colors.surface.background,a.colors.syntax.base.foreground,a.metadata.variant,r,X]),c.useEffect(()=>{he.current=z,ot()},[z,ot]),c.useLayoutEffect(()=>{Le.current=z?Ge.current.get(z)??null:null},[z]);const at=c.useCallback((D,te)=>{te?Ge.current.set(D,te):Ge.current.delete(D),D===he.current&&(Le.current=te)},[]);c.useEffect(()=>{ke.current=w},[w]),c.useEffect(()=>{if(!(!N||!w||!ze))return Fm(r,w,se,D=>{_(w,D.sessions,{startedActionMutationRevisions:D.startedActionMutationRevisions})})},[se,ze,N,w,r,_]),c.useEffect(()=>{!S&&ce!==null&&pe(null)},[S,ce,pe]),c.useEffect(()=>{!X&&ce!==null&&pe(null)},[X,ce,pe]);const xe=c.useCallback(()=>{Ee.current?.(),Ee.current=null,Pe.current=null,q(!1)},[]);c.useEffect(()=>()=>{xe(),Ie.current=null},[xe]);const et=c.useCallback((D,te,we)=>{if(!we)return;const Oe=`${st.current}${we}`.replace(/\r\n|\r/g,`
|
|
12
|
-
`),Me=Oe.split(`
|
|
13
|
-
`),De=Oe.endsWith(`
|
|
14
|
-
`)?Me.join(`
|
|
15
|
-
`):Me.slice(0,-1).join(`
|
|
16
|
-
`);if(st.current=Oe.endsWith(`
|
|
17
|
-
`)?"":(Me[Me.length-1]??"").slice(-1024),!De)return;const lt=To(De);if(!lt||qe.current.has(lt))return;const ft=Xe.current;qe.current.add(lt),ym(lt).then(Pt=>{if(qe.current.delete(lt),!Pt||Xe.current!==ft)return;const dt=mt.getState().getDirectoryState(D)?.tabs.find(kt=>kt.id===te);!dt||dt.previewUrlLocked||dt.previewUrl===lt||W(D,te,lt,{locked:!1,autoOpened:!1})})},[W]),pt=c.useCallback((D,te,we)=>{if(Pe.current===we)return;xe(),Pe.current=we;const Oe=()=>Pe.current===we&&mt.getState().getDirectoryState(D)?.tabs.some(De=>De.id===te&&De.terminalSessionId===we),Me=r.connect(we,{onEvent:De=>{if(Oe())switch(De.type){case"snapshot":{V(D,te,!1),me(null),k(!1),q(!1),Ze(),C(D,te,De.data??"",De.sequence??0,Vi(De)),et(D,te,De.data??""),De.status==="exited"&&ne(D,te,"exited");break}case"reconnecting":{me(null),k(!1),q(!0);break}case"data":{De.data&&(ee(D,te,De.data,De.sequence,De.replayData),et(D,te,De.data));break}case"exit":{const lt=typeof De.exitCode=="number"?De.exitCode:null,ft=typeof De.signal=="number"?De.signal:null,dt=mt.getState().getDirectoryState(D)?.tabs.find(kt=>kt.id===te)?.purpose.type==="project-action";ee(D,te,n("terminalView.stream.processExitedMessage",{exitCodeSegment:lt!==null?n("terminalView.stream.processExitedWithCode",{exitCode:lt}):"",signalSegment:ft!==null?n("terminalView.stream.processExitedWithSignal",{signal:ft}):""})),ne(D,te,"exited"),V(D,te,!1),me(dt?null:n("terminalView.error.sessionEnded")),k(!1),q(!1),xe();break}}},onError:(De,lt)=>{if(!Oe())return;if(!lt){me(null),k(!1);return}if(q(!1),De.code==="SESSION_NOT_FOUND"&&mt.getState().getDirectoryState(D)?.tabs.find(dt=>dt.id===te)?.purpose.type!=="project-action"){me(null),k(!1),V(D,te,!1),L(D,te,null),ne(D,te,"idle"),xe();return}const ft=De.code==="SUPERSEDED";me(ft?null:n("terminalView.error.connectionFailed",{message:De.message})),k(!ft),V(D,te,!1),ne(D,te,"exited"),L(D,te,null),xe()}});Ee.current=()=>{Me.close(),Pe.current=null}},[ee,C,xe,Ze,et,V,ne,L,n,r]),gt=c.useCallback(async(D,te,we)=>{const Oe=`${D}\0${te}`;if(!Qe.current.has(Oe)){Qe.current.add(Oe),me(null),k(!1),q(!1),V(D,te,!0);try{const Me=await r.createSession({cwd:D,sessionId:te,cols:we.cols,rows:we.rows,shell:m,loginShell:u,...i.current}),De=ke.current===D&&he.current===te;if(!mt.getState().getDirectoryState(D)?.tabs.find(Pt=>Pt.id===te)){try{await r.close(Me.sessionId)}catch{}return}if(L(D,te,Me.sessionId),!De)return;const ft=Je.current;ft&&(ft.cols!==we.cols||ft.rows!==we.rows)&&r.resize({sessionId:Me.sessionId,...ft}).catch(()=>{});return}catch(Me){const De=mt.getState().getDirectoryState(D)?.tabs.find(lt=>lt.id===te);if(!De||De.terminalSessionId||(V(D,te,!1),ke.current!==D||he.current!==te))return;me(Me instanceof Error?Me.message:n("terminalView.error.startSessionFailed")),k(!0),q(!1);return}finally{Qe.current.delete(Oe)}}},[V,L,n,r,u,m]);c.useEffect(()=>{let D=!1;if(!N||!$e)return;if(!w){me(n(F?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),xe();return}return(async()=>{const we=w;if(!ke.current||ke.current!==we)return;if(!mt.getState().getDirectoryState(we)){if(H)return;$(we);return}const Me=mt.getState().getDirectoryState(we);if(!Me||Me.tabs.length===0)return;const De=j?Me.activeTabId??Me.tabs[0]?.id??null:Me.tabs[0]?.id??null;if(!De)return;const lt=Me.tabs.find(kt=>kt.id===De)??Me.tabs[0],ft=lt?.terminalSessionId??null,Pt=lt?.lifecycle??"idle",dt=lt?.purpose.type==="project-action";if(!ft){if(Pt==="exited"){V(we,De,!1);return}if(dt){V(we,De,!1);return}const kt=Ve.current,$t=kt&&kt.tabId===De?{cols:kt.cols,rows:kt.rows}:null;if(Ye.current&&!$t)return;const Ut=$t??Je.current??Cr;gt(we,De,Ut);return}!ft||D||(Ie.current=ft,pt(we,De,ft))})(),()=>{D=!0,Ie.current=null,xe()}},[F,w,H,X,ie,z,$e,gt,j,N,$,V,ne,L,pt,xe,n,r,u,m]),c.useEffect(()=>{if(!ze||g)return;if(typeof window>"u"){Ze();return}const D=window.requestAnimationFrame(()=>{Ze()});return()=>{window.cancelAnimationFrame(D)}},[z,Ze,ze,g]);const yt=c.useCallback(async()=>{if(!w||Q||je)return;const D=mt.getState().getDirectoryState(w),te=j?z??D?.activeTabId??D?.tabs[0]?.id??null:D?.tabs[0]?.id??null;if(!te)return;const we=D?.tabs.find(Oe=>Oe.id===te)?.terminalSessionId??null;if(!(!we||!r.restartSession)){ue(!0),me(null),k(!1),q(!1),xe(),ot();try{const Oe=Je.current??Cr,Me=await r.restartSession(we,{cwd:w,shell:m,loginShell:u,...Oe,...i.current});if(mt.getState().getDirectoryState(w)?.tabs.find(lt=>lt.id===te)?.terminalSessionId!==we||(L(w,te,Me.sessionId),ne(w,te,"running"),ke.current!==w||he.current!==te))return;Ie.current=Me.sessionId,pt(w,te,Me.sessionId)}catch(Oe){if(mt.getState().getDirectoryState(w)?.tabs.find(De=>De.id===te)?.terminalSessionId!==we||ke.current!==w||he.current!==te)return;me(Oe instanceof Error?Oe.message:n("terminalView.error.restartFailed")),k(!1),q(!1),Ie.current=we,pt(w,te,we)}finally{ue(!1)}}},[z,xe,w,j,je,Q,ot,ne,L,pt,n,r,u,m]),Dt=c.useCallback(async()=>{await yt()},[yt]),y=c.useCallback(()=>{if(!w)return;const D=B(w);G(w,D),me(null),k(!1),q(!1),xe()},[B,xe,w,G]),K=c.useCallback(()=>{const D=Le.current?.getSelection(),te=M??(R?.open?"draft":null);!D||!te||!v||!U||O({directory:U,sessionKey:te},{source:"terminal",fileLabel:v.label,startLine:D.startLine,endLine:D.endLine,code:D.text,language:"",terminalId:v.terminalSessionId??v.id,text:""})},[v,O,U,M,R?.open]),Ae=c.useCallback(()=>{const D=Le.current?.getSelection();D?.text&&Er(D.text).then(te=>{te.ok?ge.success(n("terminalView.toast.selectionCopied")):ge.error(n("terminalView.toast.copyFailed"))})},[n]),Ue=c.useCallback(D=>{w&&(G(w,D),me(null),k(!1),q(!1),xe())},[xe,w,G]),I=c.useCallback(D=>{if(!w)return;D===z&&xe(),me(null),k(!1),q(!1);const te=mt.getState().getDirectoryState(w)?.tabs.find(we=>we.id===D)?.terminalSessionId;(async()=>{te&&await r.close(te),J(w,D)})().catch(we=>me(we instanceof Error?we.message:n("terminalView.error.sessionEnded")))},[z,J,xe,w,n,r]),oe=c.useCallback(D=>{if(!D||Y)return;let te=D,we=!1;ce&&D.length>0&&(te=Sm(D,ce),we=!0);const Oe=Ie.current;Oe&&(r.sendInput(Oe,te).catch(Me=>{Y||me(Me instanceof Error?Me.message:n("terminalView.error.sendInputFailed"))}),we&&(pe(null),Ne()))},[ce,Ne,Y,pe,n,r]),ye=c.useCallback((D,te)=>{Je.current={cols:D,rows:te}},[]),Se=c.useCallback((D,te)=>{const we=Je.current;(!we||we.cols!==D||we.rows!==te)&&(Je.current={cols:D,rows:te});const Oe=he.current,Me=ke.current;if(Oe&&(Ve.current={tabId:Oe,cols:D,rows:te}),!ze)return;const De=Oe&&Me?mt.getState().getDirectoryState(Me)?.tabs.find(ft=>ft.id===Oe):void 0;if(De&&Me&&Oe&&!De.terminalSessionId&&De.lifecycle!=="exited"&&De.purpose.type!=="project-action"){gt(Me,Oe,{cols:D,rows:te});return}const lt=Ie.current;lt&&r.resize({sessionId:lt,cols:D,rows:te}).catch(()=>{})},[gt,ze,r]),Ce=c.useCallback(D=>{pe(te=>te===D?null:D),Ne()},[Ne,pe]),Fe=c.useCallback(D=>{const te=jm(D,ce);te&&(oe(te),pe(null),Ne())},[ce,Ne,oe,pe]),it=c.useMemo(()=>({Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc"}),[]),ct=c.useCallback(D=>{if(D.repeat)return;const te=D.key;if(!te||te==="Control"||te==="Meta"||te==="Alt"||te==="Shift")return;const we=te.length===1?te.toLowerCase():te;if(we in it){D.preventDefault(),D.stopPropagation(),Fe(it[we]);return}if(ce!=="ctrl")return;const Oe=D.code??"",Me=te.length===1&&/[a-zA-Z]/.test(te)?te.toUpperCase():Oe.startsWith("Key")&&Oe.length===4?Oe.slice(3).toUpperCase():null;if(Me&&Me.length===1&&Me>="A"&&Me<="Z"){const De=Do(Me);if(!De)return;D.preventDefault(),D.stopPropagation(),oe(De),pe(null),Ne()}},[ce,Ne,Fe,oe,it,pe]);c.useEffect(()=>{if(!(!S||!ce||!X))return window.addEventListener("keydown",ct),()=>window.removeEventListener("keydown",ct)},[ce,ct,S,X]);const jt=c.useMemo(()=>{const D=vs[on].stack;if(typeof window>"u")return(vs[d]??vs[on]).stack;const we=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return we&&we.trim().length>0?we.trim():(vs[d]??vs[on]).stack??D},[d]),vt=c.useMemo(()=>am(a),[a]),xt=`${w??"no-dir"}::${z??"no-tab"}`;if(c.useEffect(()=>{if(!ze||g)return;const D=Le.current;if(!D)return;const te=()=>{D.fit()};if(typeof window<"u"){const we=window.requestAnimationFrame(()=>{te(),Ze()}),Oe=[220,400].map(Me=>window.setTimeout(te,Me));return()=>{window.cancelAnimationFrame(we),Oe.forEach(Me=>window.clearTimeout(Me))}}te()},[Ze,ze,g,xt,X]),c.useEffect(()=>{if(!ze||!g)return;let D=null;const te=()=>{D!==null&&window.cancelAnimationFrame(D),D=window.requestAnimationFrame(()=>{D=null,Le.current?.fit()})};return window.addEventListener("oc:keyboard-settled",te),()=>{window.removeEventListener("oc:keyboard-settled",te),D!==null&&window.cancelAnimationFrame(D)}},[ze,xt,g]),!F)return t.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:n("terminalView.empty.selectSession")});if(!w)return t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[t.jsx("p",{children:n("terminalView.empty.noWorkingDirectoryForSession")}),t.jsx("button",{onClick:yt,className:"rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:n("terminalView.actions.retry")})]});const bt=!X||de||Q||Y,We=$e,fe=j?(P?.tabs??[]).map(D=>D.id):z?[z]:[],Be=x?"lg":"xs",tt=x?"w-10 p-0":"w-9 p-0",ht=D=>{x&&D.preventDefault()},It=t.jsxs(t.Fragment,{children:[t.jsx(ve,{type:"button",size:Be,variant:"outline",onPointerDown:ht,onClick:()=>Fe("esc"),disabled:bt,children:n("terminalView.quickKeys.escape")}),t.jsxs(ve,{type:"button",size:Be,variant:"outline",className:tt,onPointerDown:ht,onClick:()=>Fe("tab"),disabled:bt,children:[t.jsx(E,{name:"arrow-right",className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.tabAria")})]}),t.jsxs(ve,{type:"button",size:Be,variant:"chip","aria-pressed":ce==="ctrl",className:x?"px-3":"px-2",onPointerDown:ht,onClick:()=>Ce("ctrl"),disabled:bt,children:[t.jsx("span",{className:"text-xs font-medium",children:Nn("ctrl")}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.controlModifierAria")})]}),t.jsxs(ve,{type:"button",size:Be,variant:"chip","aria-pressed":ce==="alt",className:x?"px-3":"px-2",onPointerDown:ht,onClick:()=>Ce("alt"),disabled:bt,children:[t.jsx("span",{className:"text-xs font-medium",children:Nn("alt")}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.altModifierAria")})]}),t.jsxs(ve,{type:"button",size:Be,variant:"outline",className:tt,onPointerDown:ht,onClick:()=>Fe("arrow-up"),disabled:bt,children:[t.jsx(E,{name:"arrow-up"}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.arrowUpAria")})]}),t.jsxs(ve,{type:"button",size:Be,variant:"outline",className:tt,onPointerDown:ht,onClick:()=>Fe("arrow-left"),disabled:bt,children:[t.jsx(E,{name:"arrow-left"}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.arrowLeftAria")})]}),t.jsxs(ve,{type:"button",size:Be,variant:"outline",className:tt,onPointerDown:ht,onClick:()=>Fe("arrow-down"),disabled:bt,children:[t.jsx(E,{name:"arrow-down"}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.arrowDownAria")})]}),t.jsxs(ve,{type:"button",size:Be,variant:"outline",className:tt,onPointerDown:ht,onClick:()=>Fe("arrow-right"),disabled:bt,children:[t.jsx(E,{name:"arrow-right"}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.arrowRightAria")})]}),t.jsxs(ve,{type:"button",size:Be,variant:"outline",className:tt,onPointerDown:ht,onClick:()=>Fe("enter"),disabled:bt,children:[t.jsx(E,{name:"arrow-go-back"}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.enterAria")})]})]});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[t.jsxs("div",{className:re("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",x?"px-3 py-1.5":"pl-3 pr-1.5 py-1"),children:[j&&P?t.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1",children:[t.jsx("div",{className:re("min-w-0 flex-1",x?"h-8":"h-7"),children:t.jsx(Ds,{items:Z,activeId:z,onSelect:Ue,onClose:I,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),t.jsx(ve,{type:"button",size:"xs",variant:"ghost",className:re("shrink-0",x?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:y,title:n("terminalView.tabs.newTabTitle"),children:t.jsx(E,{name:"add",className:`${x?"h-[18px] w-[18px]":"h-4 w-4"}`})}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-visible",children:[t.jsx(ve,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{yt()},disabled:Q||je,title:n("terminalView.actions.restart"),"aria-label":n("terminalView.actions.restart"),children:t.jsx(E,{name:"restart",className:"h-4 w-4"})}),t.jsx(ve,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:K,title:n("terminalView.actions.attachSelection"),"aria-label":n("terminalView.actions.attachSelection"),children:t.jsx(E,{name:"attachment-2",className:"h-4 w-4"})}),t.jsx(ve,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:Ae,title:n("terminalView.actions.copySelection"),"aria-label":n("terminalView.actions.copySelection"),children:t.jsx(E,{name:"file-copy",className:"h-4 w-4"})}),Re?t.jsxs(ve,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{U&&A(U,Re)},title:n("terminalView.preview.openTitle"),children:[t.jsx(E,{name:"global",className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"whitespace-nowrap",children:n("terminalView.preview.open")})]}):null]})]}):null,!x&&S&&j&&P?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:It}):null,!x&&S&&(!j||!P)?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:It}):null]}),t.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:vt.background},children:[t.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:We?fe.map(D=>t.jsx(Om,{directory:w,tabId:D,isActive:D===z,isTerminalVisible:ze,registerController:at,onInput:oe,onResize:Se,onProvisionalSize:ye,theme:vt,monoFont:d,fontFamily:jt,fontSize:l,enableTouchScroll:g},`${w}::${D}`)):null}),!Y&&le&&t.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2",children:[t.jsx("span",{children:le}),Te&&x&&t.jsx(ve,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:Dt,disabled:Q,title:n("terminalView.actions.hardRestartTitle"),type:"button",children:n("terminalView.actions.hardRestart")})]})]}),x&&S?t.jsx("div",{className:"shrink-0 overflow-x-auto border-t border-border/40 bg-[var(--surface-background)] px-2 pt-1.5 pb-[max(0.375rem,calc(var(--oc-app-bottom-safe,0px)-var(--oc-keyboard-inset,0px)))] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:t.jsx("div",{className:"flex min-w-max items-center gap-1.5",children:It})}):null]})},Df=s=>s.replace(/^refs\/(heads|remotes)\//,"").replace(/^remotes\//,""),Pf=s=>{const{remoteNames:e,localBranches:n,worktreeCreatedFromBranch:r,rootBranchHint:o,defaultBranch:a,headBranch:i}=s,d=typeof i=="string"?i.trim():"",l=h=>{if(!h)return"";let x=h.trim();if(!x||x==="HEAD")return"";if(n.includes(x))return x;x.startsWith("refs/heads/")&&(x=x.slice(11)),x.startsWith("heads/")&&(x=x.slice(6)),x.startsWith("remotes/")&&(x=x.slice(8));const g=x.indexOf("/");if(g>0){const j=x.slice(0,g);if(e.has(j)){const p=x.slice(g+1).trim();p&&(x=p)}}return x},m=h=>{const x=l(typeof h=="string"?h:"");return x&&x!==d?x:""},u=m(r);if(u)return u;const f=m(o);if(f)return f;const b=m(a);return b||(n.includes("main")?"main":n.includes("master")?"master":n.includes("develop")?"develop":"main")},Ef=s=>{const e=_e.c(31),{rootIsGitRepo:n,resolvedIsGitRepo:r,nestedRepos:o,onRetryDiscovery:a,emptyStateFooter:i}=s,{t:d}=nt();if(n!==!1||r===!0)return null;if(o==null){let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(E,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),e[0]=f):f=e[0];let b;e[1]!==o||e[2]!==d?(b=d(o===null?"gitView.empty.discoverFailed":"gitView.empty.discoveringRepositories"),e[1]=o,e[2]=d,e[3]=b):b=e[3];let h;e[4]!==b?(h=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:b}),e[4]=b,e[5]=h):h=e[5];let x;e[6]!==o||e[7]!==a||e[8]!==d?(x=o===null?t.jsxs(ve,{type:"button",variant:"outline",size:"sm",className:"mt-3 gap-1.5",onClick:a,children:[t.jsx(E,{name:"refresh",className:"size-4"}),d("gitView.empty.retryDiscovery")]}):null,e[6]=o,e[7]=a,e[8]=d,e[9]=x):x=e[9];let g;return e[10]!==h||e[11]!==x?(g=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[f,h,x]}),e[10]=h,e[11]=x,e[12]=g):g=e[12],g}if(o==="unsupported"||o.length===0){let f;e[13]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(E,{name:"git-branch",className:"mb-3 size-6 text-muted-foreground"}),e[13]=f):f=e[13];let b;e[14]!==d?(b=d("gitView.empty.notGitRepository"),e[14]=d,e[15]=b):b=e[15];let h;e[16]!==b?(h=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:b}),e[16]=b,e[17]=h):h=e[17];let x;e[18]!==d?(x=d("gitView.empty.notGitRepositoryDescription"),e[18]=d,e[19]=x):x=e[19];let g;e[20]!==x?(g=t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:x}),e[20]=x,e[21]=g):g=e[21];let j;return e[22]!==i||e[23]!==h||e[24]!==g?(j=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[f,h,g,i]}),e[22]=i,e[23]=h,e[24]=g,e[25]=j):j=e[25],j}let l;e[26]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(E,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),e[26]=l):l=e[26];let m;e[27]!==d?(m=d("gitView.loading.checkingRepository"),e[27]=d,e[28]=m):m=e[28];let u;return e[29]!==m?(u=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[l,t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:m})]}),e[29]=m,e[30]=u):u=e[30],u},Rf=()=>{qr(),fs.reconnectToRuntimeBaseUrl(),Ur()},Af=s=>{ut.getState().prepareForRuntimeSwitch(s.previousRuntimeKey),s.previousRuntimeKey&&hi.getState().stopRunningRunsForRuntime(s.previousRuntimeKey),qr(),mt.getState().clearAll(),fs.reconnectToRuntimeBaseUrl(),Tt.setState({providers:[],agents:[],isConnected:!1,isInitialized:!1,connectionPhase:"connecting",lastDisconnectReason:null}),Et.getState().resetForRuntimeSwitch(),Rt.getState().reset(),Xt.getState().resetForRuntimeSwitch(),pi(new Map),gi(),xi(),bi.getState().reset(),Wi.getState().resetForRuntimeSwitch(s.previousRuntimeKey),zi.getState().resetForRuntimeSwitch(),Mn.getState().resetForRuntimeSwitch(s.runtimeKey),yi.getState().resetForRuntimeSwitch(),wi.getState().resetForRuntimeSwitch(s.runtimeKey),Ui.getState().resetForRuntimeSwitch(s.runtimeKey),kn.getState().resetForRuntimeSwitch(),Is.getState().resetForRuntimeSwitch(),vi.getState().resetForRuntimeSwitch(),ji.getState().resetForRuntimeSwitch(),Si.getState().resetForRuntimeSwitch(),At.getState().reset(),Ke.getState().applyLinearIssueListFiltersForRuntime(),ut.getState().restoreForRuntimeSwitch(s.runtimeKey),Ur(),queueMicrotask(()=>{_i()})};export{jc as $,kf as A,ud as B,nf as C,bf as D,On as E,_l as F,Hl as G,Gl as H,Pf as I,ic as J,af as K,of as L,ac as M,yf as N,sf as O,Nf as P,oc as Q,Vc as R,gf as S,Tf as T,ef as U,mf as V,df as W,Lm as X,wf as Y,vf as Z,jf as _,hd as a,mn as a0,Id as a1,Ju as a2,uf as a3,tf as a4,Qt as a5,zc as a6,Uc as a7,Kl as a8,Zm as a9,xf as aa,Df as b,pd as c,Ef as d,Ds as e,Af as f,pf as g,ff as h,hf as i,rf as j,Xm as k,ir as l,cr as m,Sc as n,Fm as o,Od as p,Dm as q,Rf as r,Sf as s,lf as t,Cl as u,cf as v,Mm as w,Cf as x,If as y,bm as z};
|