@openchamber/web 1.18.2 → 1.18.4
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/bin/lib/commands-models.js +1 -1
- package/dist/assets/{CodeMirrorCommentWidgets-CxcJ5x9h.js → CodeMirrorCommentWidgets-4qZbrEXU.js} +1 -1
- package/dist/assets/{CommitSection-C9sBBYAJ.js → CommitSection-MJmntVPJ.js} +1 -1
- package/dist/assets/{DiagramEditor-C7nUw7p3.js → DiagramEditor-jnG3Hbxg.js} +1 -1
- package/dist/assets/{DiagramView-cYxZP-HS.js → DiagramView-CFXxgg_a.js} +1 -1
- package/dist/assets/{DiffView-1zd0slLu.js → DiffView-DZIoOnV7.js} +2 -2
- package/dist/assets/FilesView-BKL6YlKG.js +14 -0
- package/dist/assets/{GitView-OSVIn5V1.js → GitView-DBFrDDBv.js} +1 -1
- package/dist/assets/{JsonTreeView-Kgepz4pR.js → JsonTreeView-DLW2Wy1g.js} +1 -1
- package/dist/assets/MarkdownImageGallery-DKIylIK7.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CLv8hxvv.js +12 -0
- package/dist/assets/OnboardingScreen-D2Y6djMw.js +1 -0
- package/dist/assets/{PatchDiff-Cddz02Ya.js → PatchDiff-BuLPx7AN.js} +1 -1
- package/dist/assets/{PierreDiffViewer-B5k0KvPW.js → PierreDiffViewer-BHm4Yr0X.js} +2 -2
- package/dist/assets/{PlanView-BYgHBHDt.js → PlanView-ZYEJn8A_.js} +3 -3
- package/dist/assets/{SessionSwitcherDropdown-ig2OT22Z.js → SessionSwitcherDropdown-rro-SsaO.js} +1 -1
- package/dist/assets/SettingsView-5RmswFZe.js +28 -0
- package/dist/assets/{SettingsWindow-CNHM8ifT.js → SettingsWindow-BZhAYFdS.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DrGeYq2p.js → ToolOutputDialog-Za6V4VMJ.js} +7 -7
- package/dist/assets/{ToolPartDiffPreview-BRmPpe94.js → ToolPartDiffPreview-BL-9ixyC.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-Dcu8Q-5P.js → VirtualizedFileDiff-CwGocYQd.js} +1 -1
- package/dist/assets/{WalkthroughView-HStEYdD2.js → WalkthroughView-5DyvN03T.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-DQE7R9IY.js → computeVirtualFileMetrics-Da00Jg7M.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-B-bSg3P5.js +1 -0
- package/dist/assets/de-u7gSnqWs.js +9 -0
- package/dist/assets/es-T9O7aAOr.js +15 -0
- package/dist/assets/fr-Oor7ewbE.js +13 -0
- package/dist/assets/index-BzIpNlNE.css +1 -0
- package/dist/assets/{index-BgQEgA2a.js → index-C0yNhuZw.js} +1 -1
- package/dist/assets/index-DRpChWux.js +7 -0
- package/dist/assets/{isDiffPlainText-XyBCe4eD.js → isDiffPlainText-D9YpoLrV.js} +1 -1
- package/dist/assets/{isFilePlainText-JbqDfa3n.js → isFilePlainText-gTibdNIe.js} +1 -1
- package/dist/assets/ja-DHpqbVmr.js +15 -0
- package/dist/assets/ko-CwLkS3nx.js +15 -0
- package/dist/assets/{main-LfcbGv7C.js → main-D7UcL3VQ.js} +2 -2
- package/dist/assets/main-DPMd2iKS.js +915 -0
- package/dist/assets/markdownCore-DDrHVneM.js +2 -0
- package/dist/assets/{miniChat-CUp_elRz.js → miniChat-O_GVoEbc.js} +2 -2
- package/dist/assets/{mobile-CBSN7BsH.js → mobile-Br4TtAqc.js} +2 -2
- package/dist/assets/{patchFileDiff-DCIXUHRJ.js → patchFileDiff-KNkxM1C1.js} +2 -2
- package/dist/assets/{pl-tHTP6XQx.js → pl-CcZILN8q.js} +4 -4
- package/dist/assets/pt-BR-DYHhVK6o.js +15 -0
- package/dist/assets/{renderElectronMiniChatApp-eZl-5STF.js → renderElectronMiniChatApp-CJpdxTT1.js} +2 -2
- package/dist/assets/renderMobileApp-toj9cXoh.js +25 -0
- package/dist/assets/runtimeEndpointReset-BVmispdD.js +13 -0
- package/dist/assets/scheduledTasksApi-ByKya3Un.js +1 -0
- package/dist/assets/{shikiHighlight-eU8abJ3T.js → shikiHighlight-C7LTbwFx.js} +1 -1
- package/dist/assets/uk-BA2kZR38.js +15 -0
- package/dist/assets/{useAppFontEffects-Bbpz77To.js → useAppFontEffects-BikB6enL.js} +138 -138
- package/dist/assets/useInlineCommentController-CYPvYJDt.js +2 -0
- package/dist/assets/{vendor-codemirror-language-data-Dzt9rWZZ.js → vendor-codemirror-language-data-CLHw8NWn.js} +2 -2
- package/dist/assets/{vendor-marked-i_gIkIP3.js → vendor-marked-CX41MkDF.js} +1 -1
- package/dist/assets/{web-components-DGvnI0zx.js → web-components-GMc3oR3i.js} +1 -1
- package/dist/assets/zh-CN-dlOQK6v9.js +15 -0
- package/dist/assets/zh-TW-BnqQ-WL5.js +15 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +2 -2
- package/server/index.js +65 -19
- package/server/lib/agent-tool/DOCUMENTATION.md +21 -6
- package/server/lib/agent-tool/runtime.js +90 -16
- package/server/lib/agent-tool/runtime.test.js +86 -0
- package/server/lib/browser-control/DOCUMENTATION.md +50 -0
- package/server/lib/browser-control/broker.js +154 -0
- package/server/lib/browser-control/broker.test.js +191 -0
- package/server/lib/browser-control/routes.js +48 -0
- package/server/lib/browser-control/routes.test.js +108 -0
- package/server/lib/dev-servers/parse.js +203 -0
- package/server/lib/dev-servers/parse.test.js +174 -0
- package/server/lib/dev-servers/routes.js +135 -0
- package/server/lib/dev-tunnel/DOCUMENTATION.md +57 -0
- package/server/lib/dev-tunnel/client.js +193 -0
- package/server/lib/dev-tunnel/runtime.js +189 -0
- package/server/lib/dev-tunnel/tunnel.test.js +291 -0
- package/server/lib/git/credentials.js +0 -33
- package/server/lib/github/DOCUMENTATION.md +1 -1
- package/server/lib/markdown-image-grants/DOCUMENTATION.md +36 -0
- package/server/lib/markdown-image-grants/routes.js +340 -0
- package/server/lib/markdown-image-grants/routes.test.js +221 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +9 -0
- package/server/lib/openchamber-control/actions.js +33 -1
- package/server/lib/openchamber-control/screenshots.js +83 -0
- package/server/lib/openchamber-control/screenshots.test.js +84 -0
- package/server/lib/openchamber-control/service.js +141 -2
- package/server/lib/openchamber-control/service.test.js +55 -0
- package/server/lib/opencode/core-routes.js +31 -52
- package/server/lib/opencode/core-routes.test.js +37 -9
- package/server/lib/opencode/feature-routes-runtime.js +15 -0
- package/server/lib/opencode/server-startup-runtime.js +22 -1
- package/server/lib/opencode/server-startup-runtime.test.js +44 -0
- package/server/lib/opencode/settings-helpers.js +3 -9
- package/server/lib/projects/project-config.js +181 -2
- package/server/lib/projects/project-config.test.js +295 -0
- package/server/lib/quota/DOCUMENTATION.md +4 -2
- package/server/lib/quota/credentials/providers.js +0 -7
- package/server/lib/quota/credentials/store.js +11 -1
- package/server/lib/quota/credentials/store.test.js +9 -1
- package/server/lib/quota/providers/opencode-go.js +35 -35
- package/server/lib/quota/providers/opencode-go.test.js +52 -7
- package/server/lib/quota/routes.js +0 -2
- package/server/lib/relay/DOCUMENTATION.md +2 -0
- package/server/lib/relay/tunnel-host.js +157 -33
- package/server/lib/relay/tunnel-host.test.js +147 -0
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +49 -0
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +488 -0
- package/server/lib/scheduled-tasks/routes.js +6 -0
- package/server/lib/scheduled-tasks/runtime.js +369 -108
- package/server/lib/scheduled-tasks/service.js +7 -1
- package/server/lib/scheduled-tasks/service.test.js +20 -0
- package/server/lib/walkthrough/index.js +0 -2
- package/server/sse-routes.test.js +3 -0
- package/dist/assets/FilesView-WkxsWHBE.js +0 -14
- package/dist/assets/MarkdownRendererImpl-CKAsRfIk.js +0 -12
- package/dist/assets/OnboardingScreen-BCgYA7J5.js +0 -1
- package/dist/assets/SettingsView-e7Fmxnz8.js +0 -28
- package/dist/assets/contextPanelEmbeddedChat-5VGWIT_J.js +0 -1
- package/dist/assets/de-B6t6T54h.js +0 -9
- package/dist/assets/es-DH9NUKge.js +0 -15
- package/dist/assets/fr-Do4t2KmA.js +0 -13
- package/dist/assets/index-B45s9aAX.css +0 -1
- package/dist/assets/index-CNrN5qDs.js +0 -7
- package/dist/assets/ja-DJT9EM80.js +0 -15
- package/dist/assets/ko-CfWRq2p4.js +0 -15
- package/dist/assets/main-B4oBRI9u.js +0 -193
- package/dist/assets/markdownCore-A3_L34oS.js +0 -2
- package/dist/assets/pt-BR-BDEzzltP.js +0 -15
- package/dist/assets/renderMobileApp-DA7wpIBi.js +0 -23
- package/dist/assets/runtimeEndpointReset-D5izT-u5.js +0 -13
- package/dist/assets/scheduledTasksApi-CTJdfSWc.js +0 -1
- package/dist/assets/uk-B6Q32nyk.js +0 -15
- package/dist/assets/useInlineCommentController-D7zs7-BQ.js +0 -2
- package/dist/assets/vendor-zumer-snapdom-Btyu_Xi2.js +0 -8
- package/dist/assets/zh-CN-7MGcwGaC.js +0 -15
- package/dist/assets/zh-TW-CFPfqxlL.js +0 -15
- package/server/lib/preview/proxy-runtime.js +0 -1604
- package/server/lib/preview/proxy-runtime.test.js +0 -528
- package/server/lib/quota/opencode-go-credentials.js +0 -11
- package/server/lib/quota/opencode-go-credentials.test.js +0 -32
- package/server/lib/quota/routes.test.js +0 -40
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BgQEgA2a.js","assets/useAppFontEffects-Bbpz77To.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-CNrN5qDs.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/vendor-zustand-BAGL70zf.js","assets/index-B45s9aAX.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-D_V6hAcE.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-DKpLs02S.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/contextPanelEmbeddedChat-5VGWIT_J.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-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-DUOssd4j.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-DSzLbZiS.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-Bbw3D7r0.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BjbBRsUA.js","assets/vendor-codemirror-lang-json-ryCw7nab.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-VgNqFSH-.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-B3Qe3OpS.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-FGQydhTc.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-Dzt9rWZZ.js","assets/vendor-codemirror-lang-python-N414WYK-.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-ARAOgp1x.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CRSgBxjL.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/computeVirtualFileMetrics-DQE7R9IY.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-JbqDfa3n.js","assets/isDiffPlainText-XyBCe4eD.js","assets/vendor-diff-C3JhlQdm.js","assets/vendor-lru_map-Tstukz9J.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/vendor-ghostty-web-CrxinGGH.js","assets/vendor-capacitor-keyboard-CYccoJjr.js","assets/vendor-capacitor-core-B4EWRrHz.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as Vt}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as Ge,r as Q,j as t,R as l}from"./vendor-react-BUCujlKS.js";import{d_ as Ir,aE as Tr,f as nt,o as Pr,br as Zt,bs as es,bu as ts,I as P,bV as Dr,bR as Ys,g as K,B as Ne,a_ as Wn,aP as Er,t as ve,d$ as Rr,e0 as Ar,e1 as Br,O as Mr,dI as Lr,e2 as Fr,e3 as Or,e4 as Ur,x as rt,e5 as Wr,d4 as $r,d5 as zr,d6 as Vr,k as pt,e6 as _r,dk as $n,e7 as Gr,dl as Hr,bS as ss,cO as Kr,bt as gs,aU as xs,e8 as qr,e9 as Yr,ea as Jr,eb as Qr,ec as Xr,ed as Zr,ee as ea,ef as ta,b as gt,c0 as sa,Z as Js,dh as na,dE as zn,dt as Vn,dv as ra,eg as aa,u as As,cr as oa,eh as Bs,R as ht,cy as ia,ei as Qs,ej as la,ek as ca,el as Xs,em as da,en as ua,eo as ma,ep as fa,aV as ha,eq as pa,aT as Pt,aQ as Dt,aS as Et,bQ as _n,bL as ga,bM as xa,er as ba,bN as ya,bO as wa,bP as Zs,K as Gn,L as va,S as ka,T as ja,Q as Na,es as Hn,v as Sa,w as Ca,et as Ia,eu as en,ev as Ta,ew as Pa,ex as Da,ey as Ea,aW as Mt,aX as Lt,aY as Ft,cm as Ms,cn as Ls,co as Fs,cp as Os,ci as Ct,cj as yt,ez as $t,aO as jt,M as Yt,bv as Ra,bw as _s,eA as tn,U as Gs,al as hs,b$ as Aa,eB as Kn,bT as Ba,dA as Ma,a3 as Hs,eC as ys,l as qn,cS as zt,eD as sn,eE as nn,cQ as rn,bU as La,eF as Fa,eG as Oa,du as Ua,eH as Wa,eI as $a,ae as as,af as an,eJ as za,eK as Va,ca as _a,eL as Ga,eM as Ha,eN as os,eO as Ka,eP as qa,eQ as Ya,eR as on,eS as ln,eT as Ja,cB as Qa,aj as Xa,$ as Za,bJ as eo,eU as Yn,dX as to,db as so,eV as no,eW as ro,eX as ao,bG as oo,cG as io}from"./useAppFontEffects-Bbpz77To.js";import{ag as cn,ah as lo,ai as dn,aj as co,i as uo,ak as mo,C as Jn,Y as fo,r as Nt,u as Ae,y as ho,b as po,q as go,a as ws,d as un,K as Qn,al as xo,am as St,n as bo,l as ns,x as Xn,_ as yo,$ as wo,an as vo,ao as ko,t as _t,ap as jo,aq as No,a5 as So,ar as Ht,as as vs,at as Zn,S as Co,m as Io,w as To}from"./index-CNrN5qDs.js";import{C as Po,c as Do,b as Eo,d as Ro,S as Ao,M as Bo,a as Mo,g as Lo,h as Fo,i as Oo}from"./vendor-base-ui-D_V6hAcE.js";import{c as bs,d as er,p as tr,a as Uo}from"./vendor-zustand-BAGL70zf.js";import{i as sr}from"./contextPanelEmbeddedChat-5VGWIT_J.js";import{toast as mn}from"./vendor-sonner-DFyL3AvE.js";import{f as nr,h as rr,P as ar,k as Wo,D as or,j as ir}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as lr,S as cr,h as $o,a as zo,v as Vo}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as dr}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";const _o=["typescript","javascript","tsx","jsx","json","markdown"],ur={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:"none"},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:"word-alt"}};let fn=null;const mr=()=>(fn??=Promise.all([Vt(()=>import("./index-BgQEgA2a.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])),Vt(()=>import("./workerFactory-tw7cIdmV.js"),[]),Vt(()=>import("./appThemeRegistry-BK0dHKa6.js"),__vite__mapDeps([111,112,98,99,5,83,84,85,86,87,88,89,90,91,92,93,94,95,96]))]).then(([s,e,n])=>({WorkerPoolManager:s.WorkerPoolManager,workerFactory:e.workerFactory,ensurePierreThemeRegistered:n.ensurePierreThemeRegistered})),fn),Jt={},hn=new Set,Us=new Set;let us={light:"pierre-light",dark:"pierre-dark"};const Go=()=>{for(const s of Us)s()},fr=(s,e)=>{e.setRenderOptions({theme:us,lineDiffType:ur[s].lineDiffType})},Ws=s=>{typeof window>"u"||hn.has(s)||(hn.add(s),mr().then(e=>{if(Jt[s])return;const n=ur[s],r=new e.WorkerPoolManager({workerFactory:e.workerFactory,poolSize:n.poolSize,totalASTLRUCacheSize:n.totalASTLRUCacheSize},{theme:{light:"pierre-light",dark:"pierre-dark"},langs:_o,lineDiffType:n.lineDiffType,preferredHighlighter:"shiki-wasm"});r.initialize(),Jt[s]=r,fr(s,r),Go()}))},Ho=s=>(Us.add(s),()=>Us.delete(s)),Ko=s=>{if(!(us.light===s.light&&us.dark===s.dark)){us=s;for(const e of Object.keys(Jt)){const n=Jt[e];n&&fr(e,n)}}},Zc=s=>{const e=Ge.c(15),{children:n}=s,r=Ir();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=cn(!1),e[0]=a):a=e[0];const i=a;let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=cn(!0),e[1]=o):o=e[1];const u=o,f=r?.lightThemeId??i.metadata.id,h=r?.darkThemeId??u.metadata.id;let c;e[2]!==f||e[3]!==r?.availableThemes?(c=r?.availableThemes.find(I=>I.metadata.id===f)??i,e[2]=f,e[3]=r?.availableThemes,e[4]=c):c=e[4];const g=c;let p;e[5]!==h||e[6]!==r?.availableThemes?(p=r?.availableThemes.find(I=>I.metadata.id===h)??u,e[5]=h,e[6]=r?.availableThemes,e[7]=p):p=e[7];const x=p;let d,y;e[8]!==x||e[9]!==g?(d=()=>{let I=!1;return mr().then(A=>{I||(A.ensurePierreThemeRegistered(g),A.ensurePierreThemeRegistered(x),Ko({light:g.metadata.id,dark:x.metadata.id}))}),()=>{I=!0}},y=[x,g],e[8]=x,e[9]=g,e[10]=d,e[11]=y):(d=e[10],y=e[11]),Q.useEffect(d,y);let v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[12]=v):v=e[12],Q.useEffect(Yo,v);let C;return e[13]!==n?(C=t.jsx(t.Fragment,{children:n}),e[13]=n,e[14]=C):C=e[14],C},ed=s=>{const e=Ge.c(5),n=s===void 0?"unified":s;let r;e[0]!==n?(r=()=>Jt[n],e[0]=n,e[1]=r):r=e[1];const a=Q.useSyncExternalStore(Ho,r,Jo);let i,o;return e[2]!==n?(i=()=>{Ws(n)},o=[n],e[2]=n,e[3]=i,e[4]=o):(i=e[3],o=e[4]),Q.useEffect(i,o),a};function qo(){Ws("unified"),Ws("split")}function Yo(){if(typeof window>"u")return;const s=qo;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 Jo(){}const pn="openchamber.update-install-id";function Qo(){if(!(typeof window>"u"||typeof crypto.randomUUID!="function"))try{const s=window.localStorage.getItem(pn)?.trim();if(s)return s;const e=crypto.randomUUID();return window.localStorage.setItem(pn,e),e}catch{return}}function Xo(){if(typeof window>"u")return"unknown";try{const{deviceType:s}=Tr();return s}catch{return"unknown"}}function Zo(){const s=typeof window<"u"?window.__OPENCHAMBER_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 a=typeof navigator<"u"?navigator.userAgent.toLowerCase():"";return a.includes("aarch64")||a.includes("arm64")||a.includes("armv")?"arm64":a.includes("x86_64")||a.includes("x64")||a.includes("amd64")||a.includes("win64")?"x64":"unknown"}function ei(){const s=po();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 ti(s){const e=Ae.getState().reportUsage,n=new URLSearchParams({reportUsage:e?"true":"false"});if(n.set("deviceClass",Xo()),n.set("arch",Zo()),n.set("platform",ei()),e&&(s==="desktop"||s==="mobile")){const r=Qo();r&&n.set("installId",r)}return s==="desktop"?(n.set("appType","desktop-electron"),n.set("instanceMode",ho()?"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 is(s,e){try{const n=ti(s),r=typeof window<"u"?window.__VSCODE_CONFIG__?.extensionVersion:void 0;e?n.set("currentVersion",e):s==="vscode"&&r&&n.set("currentVersion",r);const a=await Nt(`/api/openchamber/update-check?${n.toString()}`,{method:"GET",headers:{Accept:"application/json"},priority:"low"});if(!a.ok)throw new Error(`Server responded with ${a.status}`);const i=await a.json();return{available:i.available??!1,version:i.version,currentVersion:i.currentVersion??"unknown",body:i.body,releaseUrl:i.releaseUrl,downloadUrl:i.downloadUrl,nextSuggestedCheckInSec:typeof i.nextSuggestedCheckInSec=="number"&&Number.isFinite(i.nextSuggestedCheckInSec)?i.nextSuggestedCheckInSec:void 0,packageManager:i.packageManager,updateCommand:i.updateCommand}}catch(n){return console.warn("Failed to check for updates:",n),null}}function si(){return uo()?"mobile":mo()?"desktop":Jn()?"vscode":fo()?"web":null}const gn={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null},ni=bs()((s,e)=>({...gn,checkForUpdates:async()=>{const n=si();if(!n)return null;s({checking:!0,error:null,runtimeType:n});try{let r=null,a=null;if(n==="desktop"){const i="1.18.2",[o,u]=await Promise.allSettled([dn(),is("desktop",i)]),f=o.status==="fulfilled"?o.value:null;return a=u.status==="fulfilled"?u.value?.nextSuggestedCheckInSec??null:null,s({checking:!1,available:f?.available??!1,info:f,lastChecked:Date.now(),nextCheckInSec:a}),a}else n==="web"?(r=await is("web"),a=r?.nextSuggestedCheckInSec??null):n==="vscode"?a=(await is("vscode"))?.nextSuggestedCheckInSec??null:n==="mobile"&&(r=await is("mobile","1.18.2"),a=r?.nextSuggestedCheckInSec??null);return s({checking:!1,available:n==="vscode"?!1:r?.available??!1,info:n==="vscode"?null:r,lastChecked:Date.now(),nextCheckInSec:a}),a}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 a=await dn();if(!a?.available)throw new Error("Update detected, but desktop package is not ready yet. Retry in a moment.");if(s(o=>({info:o.info?{...o.info,...a,body:o.info.body||a.body,available:o.info.available}:a})),!await co(o=>{s({progress:o})}))throw new Error("Desktop update only works on Local instance");s({downloading:!1,downloaded:!0})}catch(a){s({downloading:!1,error:a instanceof Error?a.message:"Failed to download update"})}}},restartToUpdate:async()=>{const{downloaded:n,runtimeType:r}=e();if(!(r!=="desktop"||!n))try{if(!await lo())throw new Error("Desktop restart only works on Local instance")}catch(a){s({error:a instanceof Error?a.message:"Failed to restart"})}},dismiss:()=>{s({available:!1,downloaded:!1,info:null})},reset:()=>{s(gn)}})),xn="https://github.com/openchamber/openchamber/releases";function ri(s){const e=new Date(`${s}T00:00:00`);return Number.isNaN(e.getTime())?s:new Intl.DateTimeFormat(Wn(),{year:"numeric",month:"short",day:"numeric"}).format(e)}function ai(s){return s.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,"").trim()}function bn(s){return s.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,"$1[@$2](https://github.com/$2)")}function oi(s,e){const n=s.split(".").map(a=>Number.parseInt(a,10)),r=e.split(".").map(a=>Number.parseInt(a,10));for(let a=0;a<3;a+=1){const i=Number.isFinite(n[a])?n[a]:0,o=Number.isFinite(r[a])?r[a]:0;if(i!==o)return o-i}return 0}function ii(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((a,i)=>{const o=n[i+1]?.start??s.length,u=s.slice(a.start,o).trim();return{version:a.version,date:a.date,start:a.start,end:o,raw:u}})}const yn=2e3,li=600*1e3;async function ci(){try{const s=await Nt("/api/openchamber/update-install",{method:"POST",headers:{"Content-Type":"application/json"}});return s.ok?{success:!0,autoRestart:(await s.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await s.json().catch(()=>({}))).error||`Server error: ${s.status}`}}catch(s){return{success:!1,error:s instanceof Error?s.message:void 0}}}async function di(){try{return(await Nt("/health",{method:"GET",headers:{Accept:"application/json"}})).ok}catch{return!1}}async function ui(s,e=Math.ceil(li/yn),n=yn){for(let r=0;r<e;r++){try{const a=await Nt("/api/openchamber/update-check?reportUsage=false",{method:"GET",headers:{Accept:"application/json"}});if(a.ok){const i=await a.json().catch(()=>null);if(i&&i.available===!1||i&&typeof i.currentVersion=="string"&&typeof s=="string"&&i.currentVersion!==s)return!0}else if((a.status===401||a.status===403)&&await di())return!0}catch{}await new Promise(a=>setTimeout(a,n))}return!1}const td=({open:s,onOpenChange:e,info:n,downloading:r,downloaded:a,progress:i,error:o,onDownload:u,onRestart:f,runtimeType:h="desktop"})=>{const{t:c}=nt(),[g,p]=Q.useState(!1),[x,d]=Q.useState("idle"),[y,v]=Q.useState(null),C=n?.version?n.releaseUrl||`${xn}/tag/v${n.version}`:xn,I=n?.downloadUrl||C,A=i?.total?Math.round(i.downloaded/i.total*100):0,V=h==="web",w=h==="mobile",N=n?.updateCommand||"openchamber update";Q.useEffect(()=>{s||(d("idle"),v(null))},[s]);const k=async()=>{(await Er(N)).ok&&(p(!0),setTimeout(()=>p(!1),2e3))},M=Q.useCallback(async O=>{await Pr(O)},[]),te=Q.useCallback(async()=>{d("updating"),v(null);const O=await ci();if(!O.success){d("error"),v(O.error||c("updateDialog.error.updateFailed"));return}O.autoRestart&&(d("restarting"),await new Promise(z=>setTimeout(z,2e3))),d("reconnecting"),await ui(n?.currentVersion)?window.location.reload():(d("error"),v(c("updateDialog.error.takingLonger")))},[n?.currentVersion,c]),q=Q.useCallback(()=>{M(I)},[M,I]),L=x!=="idle"&&x!=="error",W=Q.useMemo(()=>{if(!n?.body)return null;const O=n.body.trim();if(!O)return null;const ne=ii(O);if(ne.length===0)return{kind:"raw",title:c("updateDialog.changelog.title"),content:bn(O)};const z=[...ne].sort((de,G)=>oi(de.version,G.version));return{kind:"sections",title:c("updateDialog.changelog.title"),sections:z.map(de=>({version:de.version,dateLabel:ri(de.date),content:bn(ai(de.raw)||O)}))}},[n?.body,c]);return t.jsx(Zt,{open:s,onOpenChange:L?void 0:e,children:t.jsxs(es,{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(ts,{className:"flex items-center gap-2.5",children:[t.jsx(P,{name:"download-cloud",className:"h-5 w-5 text-[var(--primary-base)]"}),t.jsx("span",{className:"text-lg font-semibold text-foreground",children:c(x==="restarting"||x==="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:[V&&L&&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(P,{name:"loader",className:"h-5 w-5 animate-spin text-[var(--primary-base)]"}),t.jsxs("div",{className:"typography-ui-label text-foreground",children:[x==="updating"&&c("updateDialog.status.installingUpdate"),x==="restarting"&&c("updateDialog.status.serverRestarting"),x==="reconnecting"&&c("updateDialog.status.waitingForServer")]})]}),t.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:c("updateDialog.status.autoReloadHint")})]}),W&&!L&&t.jsx("div",{className:"rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 overflow-hidden",children:t.jsx(Dr,{className:"max-h-[400px] p-0",fillContainer:!1,children:W.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",onClickCapture:O=>{const z=O.target.closest("a");z&&z.href&&(O.preventDefault(),O.stopPropagation(),M(z.href))},children:t.jsx(Ys,{content:W.content,disableLinkSafety:!0,enableFileReferences:!1})}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:W.sections.map(O=>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",O.version]}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:O.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",onClickCapture:ne=>{const de=ne.target.closest("a");de&&de.href&&(ne.preventDefault(),ne.stopPropagation(),M(de.href))},children:t.jsx(Ys,{content:O.content,disableLinkSafety:!0,enableFileReferences:!1})})]},O.version))})})}),V&&x==="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(P,{name:"terminal",className:"h-4 w-4"}),t.jsx("span",{children:c("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:N}),t.jsx("button",{onClick:k,className:K("flex items-center justify-center p-2 rounded","text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]","transition-colors",g&&"text-[var(--status-success)]"),title:c(g?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:g?t.jsx(P,{name:"check",className:"h-4 w-4"}):t.jsx(P,{name:"clipboard",className:"h-4 w-4"})})]})]}),!V&&!w&&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:c("updateDialog.status.downloadingPayload")}),t.jsxs("span",{className:"font-mono text-foreground",children:[A,"%"]})]}),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:`${A}%`}})})]}),(o||y)&&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:o||y})})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4",children:[t.jsxs("a",{href:C,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(P,{name:"external-link",className:"h-4 w-4"}),"GitHub"]}),t.jsxs("div",{className:"flex-1 flex justify-end",children:[!V&&!w&&!a&&!r&&t.jsxs("button",{onClick:u,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(P,{name:"download",className:"h-4 w-4"}),c("updateDialog.actions.downloadUpdate")]}),!V&&!w&&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(P,{name:"loader",className:"h-4 w-4 animate-spin"}),c("updateDialog.status.downloading")]}),!V&&!w&&a&&t.jsxs("button",{onClick:f,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(P,{name:"restart",className:"h-4 w-4"}),c("updateDialog.actions.restartToUpdate")]}),w&&t.jsxs(Ne,{onClick:q,size:"default",children:[t.jsx(P,{name:"external-link",className:"h-4 w-4"}),c("updateDialog.actions.openMobileUpdate")]}),V&&!L&&t.jsxs("button",{onClick:te,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(P,{name:"download",className:"h-4 w-4"}),c("updateDialog.actions.updateNow")]}),V&&L&&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(P,{name:"loader",className:"h-4 w-4 animate-spin"}),c("updateDialog.status.updating")]})]})]})]})})},sd=s=>!(s.dismissed==="true"||s.sessionShown==="true"||s.hasActiveToast),mi=s=>!(!s.version||s.seenVersions.has(s.version)||s.dismissedVersion!==null&&s.dismissedVersion===s.version),fi=s=>{if(s===null||typeof s!="object")return"";const e=s.version;return typeof e!="string"?"":e.trim()},hi=s=>!s||s.upgrade?.supported!==!0||s.available!==!0||typeof s.latestVersion!="string"?"":s.latestVersion.trim(),Ut="opencode-update-available",ls="opencode-upgrade-progress",pi=5e3,gi=[1e4,6e4],wn="opencode-update-toast-dismissed-version",nd=()=>{const{t:s}=nt(),e=Ae(o=>o.showOpenCodeUpdateNotifications),n=Q.useRef(new Set),r=Q.useRef(!1);Q.useEffect(()=>{e||ve.dismiss(Ut)},[e]);const a=Q.useCallback(()=>{ve.dismiss(ls),Rr({message:s("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]}).catch(()=>{})},[s]),i=Q.useCallback(async()=>{if(!r.current){r.current=!0,ve.dismiss(Ut),ve.message(s("opencodeUpdate.toast.upgrading.title"),{id:ls,description:s("opencodeUpdate.toast.upgrading.description"),duration:1/0,icon:t.jsx(P,{name:"refresh",className:"h-4 w-4 animate-spin text-muted-foreground"})});try{const o=await Nt("/api/opencode/upgrade",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),u=await o.json().catch(()=>null);if(!o.ok||u?.success===!1)throw new Error(u?.error||o.statusText||s("opencodeUpdate.toast.failed.description"));ve.success(s("opencodeUpdate.toast.updated.title"),{id:ls,description:u?.version?s("opencodeUpdate.toast.updated.descriptionWithVersion",{version:u.version}):s("opencodeUpdate.toast.updated.description"),duration:1/0,icon:t.jsx(P,{name:"check",className:"h-4 w-4 text-[var(--status-success)]"}),action:{label:s("opencodeUpdate.toast.actions.reload"),onClick:a}})}catch(o){ve.error(s("opencodeUpdate.toast.failed.title"),{id:ls,description:o instanceof Error?o.message:s("opencodeUpdate.toast.failed.description"),duration:1/0})}finally{r.current=!1}}},[a,s]);return Q.useEffect(()=>{const o=p=>{if(!Ae.getState().showOpenCodeUpdateNotifications){ve.dismiss(Ut);return}mi({version:p,dismissedVersion:un().getItem(wn),seenVersions:n.current})&&(n.current.add(p),ve.info(s("opencodeUpdate.toast.available.title"),{id:Ut,description:s("opencodeUpdate.toast.available.description",{version:p}),duration:1/0,action:{label:s("opencodeUpdate.toast.actions.update"),onClick:i},cancel:{label:s("opencodeUpdate.toast.actions.dismiss"),onClick:()=>{un().setItem(wn,p),Qn({openCodeUpdateToastDismissedVersion:p}),ve.dismiss(Ut)}}}))};let u=!1;const f=[],h=async(p,x=ws())=>{try{const d=await Nt("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!d.ok)throw new Error(d.statusText||"OpenCode upgrade status check failed");const y=await d.json().catch(()=>null),v=hi(y);!u&&x===ws()&&v&&o(v)}catch{const d=gi[p];!u&&x===ws()&&d!==void 0&&f.push(setTimeout(()=>{h(p+1,x)},d))}},c=p=>{fi(p.detail)&&h(0)};e&&f.push(setTimeout(()=>{h(0)},pi));const g=go(({runtimeKey:p})=>{n.current.clear(),ve.dismiss(Ut),Ae.getState().showOpenCodeUpdateNotifications&&h(0,p)});return window.addEventListener("openchamber:opencode-update-available",c),()=>{u=!0;for(const p of f)clearTimeout(p);g(),window.removeEventListener("openchamber:opencode-update-available",c)}},[i,e,s]),null},rd=()=>{const s=Ge.c(3),[e,n]=l.useState(xi),{isUpdating:r}=e;let a,i;if(s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>Br(n),i=[],s[0]=a,s[1]=i):(a=s[0],i=s[1]),l.useEffect(a,i),!r)return null;let o;return s[2]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-background/90",children:t.jsx(Mr,{width:80,height:80,isAnimated:!0})}),s[2]=o):o=s[2],o};function xi(){return Ar()}class bi extends l.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(Lr,{className:"w-full max-w-md",children:[t.jsx(Fr,{className:"text-center",children:t.jsxs(Or,{className:"flex items-center justify-center gap-2 text-destructive",children:[t.jsx(P,{name:"chat-3",className:"h-5 w-5"}),this.props.texts.title]})}),t.jsxs(Ur,{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(Ne,{onClick:this.handleReset,variant:"outline",className:"flex-1",children:[t.jsx(P,{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 yi(s){const e=Ge.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 a;e[2]!==n?(a=n("chat.errorBoundary.description"),e[2]=n,e[3]=a):a=e[3];let i;e[4]!==n?(i=n("chat.errorBoundary.sessionLabel"),e[4]=n,e[5]=i):i=e[5];let o;e[6]!==n?(o=n("chat.errorBoundary.detailsSummary"),e[6]=n,e[7]=o):o=e[7];let u;e[8]!==n?(u=n("chat.errorBoundary.resetAction"),e[8]=n,e[9]=u):u=e[9];let f;e[10]!==n?(f=n("chat.errorBoundary.persistentHint"),e[10]=n,e[11]=f):f=e[11];let h;e[12]!==r||e[13]!==a||e[14]!==i||e[15]!==o||e[16]!==u||e[17]!==f?(h={title:r,description:a,sessionLabel:i,detailsSummary:o,resetAction:u,persistentHint:f},e[12]=r,e[13]=a,e[14]=i,e[15]=o,e[16]=u,e[17]=f,e[18]=h):h=e[18];let c;return e[19]!==s||e[20]!==h?(c=t.jsx(bi,{...s,texts:h}),e[19]=s,e[20]=h,e[21]=c):c=e[21],c}const ad=s=>{const e=Ge.c(6),{active:n,readOnly:r}=s,a=n===void 0?!0:n,i=r===void 0?!1:r,u=rt(wi)||void 0;let f;e[0]!==a||e[1]!==i?(f=t.jsx(Wr,{active:a,readOnly:i}),e[0]=a,e[1]=i,e[2]=f):f=e[2];let h;return e[3]!==u||e[4]!==f?(h=t.jsx(yi,{sessionId:u,children:f}),e[3]=u,e[4]=f,e[5]=h):h=e[5],h};function wi(s){return s.currentSessionId}function od(s){const e=Ge.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(Po,{...n}),e[2]=n,e[3]=r):r=e[3],r}function id(s){const e=Ge.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(Do,{...n}),e[2]=n,e[3]=r):r=e[3],r}function ld(s){const e=Ge.c(20);let n,r,a,i,o;e[0]!==s?({className:r,positionerClassName:a,children:n,style:o,...i}=s,e[0]=s,e[1]=n,e[2]=r,e[3]=a,e[4]=i,e[5]=o):(n=e[1],r=e[2],a=e[3],i=e[4],o=e[5]);let u;e[6]!==a?(u=K("app-region-no-drag z-50",a),e[6]=a,e[7]=u):u=e[7];let f;e[8]!==o?(f={color:"var(--surface-elevated-foreground)",...o},e[8]=o,e[9]=f):f=e[9];let h;e[10]!==r?(h=K($r,r),e[10]=r,e[11]=h):h=e[11];let c;e[12]!==n||e[13]!==i||e[14]!==f||e[15]!==h?(c=t.jsx(Eo,{"data-slot":"dropdown-menu-content",style:f,className:h,...i,children:n}),e[12]=n,e[13]=i,e[14]=f,e[15]=h,e[16]=c):c=e[16];let g;return e[17]!==u||e[18]!==c?(g=t.jsx(Bo,{children:t.jsx(Mo,{className:u,children:c})}),e[17]=u,e[18]=c,e[19]=g):g=e[19],g}function cd(s){const e=Ge.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 a;e[3]!==n?(a=K(zr,n),e[3]=n,e[4]=a):a=e[4];let i;return e[5]!==r||e[6]!==a?(i=t.jsx(Ro,{className:a,...r}),e[5]=r,e[6]=a,e[7]=i):i=e[7],i}function dd(s){const e=Ge.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 a;e[3]!==n?(a=K(Vr,n),e[3]=n,e[4]=a):a=e[4];let i;return e[5]!==r||e[6]!==a?(i=t.jsx(Ao,{className:a,...r}),e[5]=r,e[6]=a,e[7]=i):i=e[7],i}const vi=Fo,ki=s=>{const e=Ge.c(14);let n,r,a,i;e[0]!==s?({className:a,asChild:n,children:r,...i}=s,e[0]=s,e[1]=n,e[2]=r,e[3]=a,e[4]=i):(n=e[1],r=e[2],a=e[3],i=e[4]);let o;e[5]!==n||e[6]!==r?(o=n&&Q.isValidElement(r)?{render:r}:{children:r},e[5]=n,e[6]=r,e[7]=o):o=e[7];const u=o;let f;e[8]!==a?(f=K("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",a),e[8]=a,e[9]=f):f=e[9];let h;return e[10]!==i||e[11]!==u||e[12]!==f?(h=t.jsx(Lo,{className:f,...i,...u}),e[10]=i,e[11]=u,e[12]=f,e[13]=h):h=e[13],h},ji=s=>{const e=Ge.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 a;e[3]!==n?(a=K("overflow-hidden data-[closed]:animate-collapsible-up data-[open]:animate-collapsible-down",n),e[3]=n,e[4]=a):a=e[4];let i;return e[5]!==r||e[6]!==a?(i=t.jsx(Oo,{className:a,...r}),e[5]=r,e[6]=a,e[7]=i):i=e[7],i},vn=s=>({providerID:s.providerID,modelID:s.modelID,variant:s.variant,agent:s.agent});function Ni(s){const e=Ge.c(131),{t:n}=nt(),{open:r,onOpenChange:a,target:i,projectDirectory:o,submitting:u,allowRunAsGoal:f,onConfirm:h}=s,c=u===void 0?!1:u,g=f===void 0?!1:f;let p;e[0]!==g?(p=g&&!Jn(),e[0]=g,e[1]=p):p=e[1];const x=p,d=pt(Mi),y=pt(Bi),v=_r(Ai),C=pt(Ri),I=pt(Ei),A=pt(Di),V=pt(Pi),w=pt(Ti);let N;e[2]!==w||e[3]!==A||e[4]!==I||e[5]!==V?(N=()=>vn({providerID:I,modelID:A,variant:V,agent:w}),e[2]=w,e[3]=A,e[4]=I,e[5]=V,e[6]=N):N=e[6];const[k,M]=l.useState(N);let te,q;e[7]!==v||e[8]!==y||e[9]!==d||e[10]!==r||e[11]!==o?(te=()=>{r&&(d({directory:o,source:"todoSendDialog"}),y({directory:o}),v())},q=[r,d,y,v,o],e[7]=v,e[8]=y,e[9]=d,e[10]=r,e[11]=o,e[12]=te,e[13]=q):(te=e[12],q=e[13]),l.useEffect(te,q);let L,W;e[14]!==w||e[15]!==A||e[16]!==I||e[17]!==V||e[18]!==r?(L=()=>{r&&M(vn({providerID:I,modelID:A,variant:V,agent:w}))},W=[r,I,A,V,w],e[14]=w,e[15]=A,e[16]=I,e[17]=V,e[18]=r,e[19]=L,e[20]=W):(L=e[19],W=e[20]),l.useEffect(L,W);let O,ne;e[21]!==k.modelID||e[22]!==k.providerID||e[23]!==r||e[24]!==C?(O=()=>{if(!r||C.length===0)return;const m=C.find(xe=>xe.id===k.providerID)??C[0],j=Array.isArray(m?.models)?m.models:[],ee=j.some(xe=>xe.id===k.modelID),ye=j[0]?.id??"";m?.id===k.providerID&&ee||M(xe=>({...xe,providerID:m?.id??"",modelID:ee?xe.modelID:ye,variant:""}))},ne=[r,C,k.providerID,k.modelID],e[21]=k.modelID,e[22]=k.providerID,e[23]=r,e[24]=C,e[25]=O,e[26]=ne):(O=e[25],ne=e[26]),l.useEffect(O,ne);const z=Ii;let de;if(e[27]!==k.modelID||e[28]!==k.providerID||e[29]!==C){let m;e[31]!==k.providerID?(m=ee=>ee.id===k.providerID,e[31]=k.providerID,e[32]=m):m=e[32],de=C.find(m)?.models?.find(ee=>ee.id===k.modelID),e[27]=k.modelID,e[28]=k.providerID,e[29]=C,e[30]=de}else de=e[30];const G=de;let U;e[33]!==G?(U=G?.variants?Object.keys(G.variants):[],e[33]=G,e[34]=U):U=e[34];const R=U,B=R.length>0;let $,H;e[35]!==k.variant||e[36]!==B?($=()=>{B||!k.variant||M(Ci)},H=[B,k.variant],e[35]=k.variant,e[36]=B,e[37]=$,e[38]=H):($=e[37],H=e[38]),l.useEffect($,H);let E;e[39]!==k.modelID||e[40]!==k.providerID?(E=k.providerID.trim().length>0&&k.modelID.trim().length>0,e[39]=k.modelID,e[40]=k.providerID,e[41]=E):E=e[41];const re=E;let ue;e[42]!==re||e[43]!==k||e[44]!==h||e[45]!==c?(ue=()=>{!re||c||h(k)},e[42]=re,e[43]=k,e[44]=h,e[45]=c,e[46]=ue):ue=e[46];const he=ue;let Ce,ke;e[47]!==he||e[48]!==r?(Ce=()=>{if(!r)return;const m=j=>{(j.metaKey||j.ctrlKey)&&j.key==="Enter"&&(j.preventDefault(),he())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},ke=[r,he],e[47]=he,e[48]=r,e[49]=Ce,e[50]=ke):(Ce=e[49],ke=e[50]),l.useEffect(Ce,ke);let J;e[51]!==n||e[52]!==i?(J=n(i==="worktree"?"rightSidebar.contextNotesTodo.sendDialog.title.newWorktree":"rightSidebar.contextNotesTodo.sendDialog.title.newSession"),e[51]=n,e[52]=i,e[53]=J):J=e[53];const be=J;let _;e[54]!==a||e[55]!==c?(_=m=>{c||a(m)},e[54]=a,e[55]=c,e[56]=_):_=e[56];let le;e[57]!==be?(le=t.jsx(gs,{children:t.jsx(ts,{children:be})}),e[57]=be,e[58]=le):le=e[58];let Y;e[59]!==n?(Y=n("chat.modelControls.model"),e[59]=n,e[60]=Y):Y=e[60];let ae;e[61]!==Y?(ae=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:Y}),e[61]=Y,e[62]=ae):ae=e[62];let ce;e[63]===Symbol.for("react.memo_cache_sentinel")?(ce=(m,j)=>{M(ee=>({...ee,providerID:m,modelID:j,variant:""}))},e[63]=ce):ce=e[63];let pe;e[64]!==k.modelID||e[65]!==k.providerID?(pe=t.jsx($n,{providerId:k.providerID,modelId:k.modelID,className:"max-w-[320px] justify-between",dropdownPortalToBody:!0,onChange:ce}),e[64]=k.modelID,e[65]=k.providerID,e[66]=pe):pe=e[66];let D;e[67]!==ae||e[68]!==pe?(D=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[ae,pe]}),e[67]=ae,e[68]=pe,e[69]=D):D=e[69];let F;e[70]!==n?(F=n("sessions.scheduledTasks.editor.thinkingLevel.label"),e[70]=n,e[71]=F):F=e[71];let X;e[72]!==F?(X=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:F}),e[72]=F,e[73]=X):X=e[73];const me=!B;let se;e[74]===Symbol.for("react.memo_cache_sentinel")?(se=m=>M(j=>({...j,variant:m})),e[74]=se):se=e[74];let Se;e[75]!==k.variant||e[76]!==me||e[77]!==R?(Se=t.jsx(Gr,{value:k.variant,options:R,disabled:me,onChange:se}),e[75]=k.variant,e[76]=me,e[77]=R,e[78]=Se):Se=e[78];let Te;e[79]!==X||e[80]!==Se?(Te=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[X,Se]}),e[79]=X,e[80]=Se,e[81]=Te):Te=e[81];let De;e[82]!==n?(De=n("sessions.scheduledTasks.editor.agent.label"),e[82]=n,e[83]=De):De=e[83];let Ue;e[84]!==De?(Ue=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:De}),e[84]=De,e[85]=Ue):Ue=e[85];let Ve;e[86]===Symbol.for("react.memo_cache_sentinel")?(Ve=m=>M(j=>({...j,agent:m})),e[86]=Ve):Ve=e[86];let Me;e[87]!==k.agent?(Me=t.jsx(Hr,{agentName:k.agent,filter:z,dropdownPortalToBody:!0,onChange:Ve}),e[87]=k.agent,e[88]=Me):Me=e[88];let Ze;e[89]!==Ue||e[90]!==Me?(Ze=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[Ue,Me]}),e[89]=Ue,e[90]=Me,e[91]=Ze):Ze=e[91];let Ee;e[92]!==D||e[93]!==Te||e[94]!==Ze?(Ee=t.jsxs("div",{className:"flex flex-col gap-4",children:[D,Te,Ze]}),e[92]=D,e[93]=Te,e[94]=Ze,e[95]=Ee):Ee=e[95];const He=`flex items-center gap-3 ${x?"justify-between":"justify-end"}`;let Le;e[96]!==k.runAsGoal||e[97]!==x||e[98]!==c||e[99]!==n?(Le=x?t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(ss,{checked:k.runAsGoal===!0,onChange:m=>M(j=>({...j,runAsGoal:m})),disabled:c,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:c,onClick:()=>M(Si),children:n("sessions.scheduledTasks.editor.goal.label")})]}):null,e[96]=k.runAsGoal,e[97]=x,e[98]=c,e[99]=n,e[100]=Le):Le=e[100];let ze;e[101]!==a?(ze=()=>a(!1),e[101]=a,e[102]=ze):ze=e[102];let Je;e[103]!==n?(Je=n("rightSidebar.contextNotesTodo.sendDialog.actions.cancel"),e[103]=n,e[104]=Je):Je=e[104];let Be;e[105]!==c||e[106]!==ze||e[107]!==Je?(Be=t.jsx(Ne,{variant:"ghost",size:"sm",onClick:ze,disabled:c,children:Je}),e[105]=c,e[106]=ze,e[107]=Je,e[108]=Be):Be=e[108];const Qe=!re||c;let Ke;e[109]!==c||e[110]!==n?(Ke=n(c?"rightSidebar.contextNotesTodo.sendDialog.actions.sending":"rightSidebar.contextNotesTodo.sendDialog.actions.send"),e[109]=c,e[110]=n,e[111]=Ke):Ke=e[111];let Pe;e[112]!==he||e[113]!==Qe||e[114]!==Ke?(Pe=t.jsx(Ne,{size:"sm",onClick:he,disabled:Qe,children:Ke}),e[112]=he,e[113]=Qe,e[114]=Ke,e[115]=Pe):Pe=e[115];let et;e[116]!==Be||e[117]!==Pe?(et=t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[Be,Pe]}),e[116]=Be,e[117]=Pe,e[118]=et):et=e[118];let $e;e[119]!==He||e[120]!==Le||e[121]!==et?($e=t.jsxs("div",{className:He,children:[Le,et]}),e[119]=He,e[120]=Le,e[121]=et,e[122]=$e):$e=e[122];let b;e[123]!==le||e[124]!==Ee||e[125]!==$e?(b=t.jsxs(es,{className:"max-w-md overflow-visible",children:[le,Ee,$e]}),e[123]=le,e[124]=Ee,e[125]=$e,e[126]=b):b=e[126];let Z;return e[127]!==r||e[128]!==_||e[129]!==b?(Z=t.jsx(Zt,{open:r,onOpenChange:_,children:b}),e[127]=r,e[128]=_,e[129]=b,e[130]=Z):Z=e[130],Z}function Si(s){return{...s,runAsGoal:s.runAsGoal!==!0}}function Ci(s){return{...s,variant:""}}function Ii(s){return Kr(s.mode)}function Ti(s){return s.currentAgentName||""}function Pi(s){return s.currentVariant||""}function Di(s){return s.currentModelId}function Ei(s){return s.currentProviderId}function Ri(s){return s.providers}function Ai(s){return s.loadAgents}function Bi(s){return s.loadAgents}function Mi(s){return s.loadProviders}const Li=280,kn=4,Fi=({transform:s})=>({...s,y:0}),Oi=s=>{const e=Ge.c(18),{id:n,children:r,className:a}=s;let i;e[0]!==n?(i={id:n},e[0]=n,e[1]=i):i=e[1];const{attributes:o,listeners:u,setNodeRef:f,transform:h,transition:c,isDragging:g}=lr(i);let p;e[2]!==h?(p=dr.Transform.toString(h),e[2]=h,e[3]=p):p=e[3];let x;e[4]!==p||e[5]!==c?(x={transform:p,transition:c},e[4]=p,e[5]=c,e[6]=x):x=e[6];const d=g&&"opacity-50";let y;e[7]!==a||e[8]!==d?(y=K("h-full rounded-md",a,d),e[7]=a,e[8]=d,e[9]=y):y=e[9];let v;return e[10]!==o||e[11]!==r||e[12]!==n||e[13]!==u||e[14]!==f||e[15]!==x||e[16]!==y?(v=t.jsx("div",{ref:f,"data-sortable-tab-id":n,style:x,className:y,...o,...u,children:r}),e[10]=o,e[11]=r,e[12]=n,e[13]=u,e[14]=f,e[15]=x,e[16]=y,e[17]=v):v=e[17],v},Ui=s=>{const e=Ge.c(6),{id:n,children:r,className:a}=s;let i;e[0]!==a?(i=K("h-full",a),e[0]=a,e[1]=i):i=e[1];let o;return e[2]!==r||e[3]!==n||e[4]!==i?(o=t.jsx("div",{className:i,"data-sortable-tab-id":n,children:r}),e[2]=r,e[3]=n,e[4]=i,e[5]=o):o=e[5],o},Qt=s=>{const e=Ge.c(133),{items:n,activeId:r,onSelect:a,onClose:i,onReorder:o,layoutMode:u,variant:f,activePillInsetClassName:h,activePillButtonClassName:c,inactiveTabsIconOnly:g,animateActivePill:p,activePillLowercase:x,nonCompositedIndicator:d,className:y}=s,v=u===void 0?"scrollable":u,C=f===void 0?"default":f,I=g===void 0?!1:g,A=x===void 0?!0:x,V=d===void 0?!1:d,{t:w}=nt(),N=Ae(Wi),{isTablet:k}=xs(),M=N||k,te=l.useRef(null);let q;e[0]===Symbol.for("react.memo_cache_sentinel")?(q={left:!1,right:!1},e[0]=q):q=e[0];const[L,W]=l.useState(q);let O;e[1]!==n?(O=n.map($i),e[1]=n,e[2]=O):O=e[2];const ne=O,z=v==="scrollable",de=C==="default",G=C==="active-pill",R=G||C==="animated",B=de,$=R||B,H=G&&z,E=R,re=p??R,ue=typeof o=="function",he=ue?Oi:Ui;let Ce;e[3]===Symbol.for("react.memo_cache_sentinel")?(Ce=new Map,e[3]=Ce):Ce=e[3];const ke=l.useRef(Ce),[J,be]=l.useState(null),[_,le]=l.useState(!1),[Y,ae]=l.useState(null),ce=l.useRef(!1),pe=l.useRef(0),D=l.useRef(r),F=l.useRef(null);let X;e:{if(!$||!Y||!r||Y===r){X=0;break e}const fe=n.findIndex(We=>We.id===Y),ie=n.findIndex(We=>We.id===r);if(fe<0||ie<0){X=0;break e}X=fe>ie?kn:-kn}const me=X;let se;e[4]===Symbol.for("react.memo_cache_sentinel")?(se={activationConstraint:{distance:8}},e[4]=se):se=e[4];const Se=nr(rr(ar,se)),Te=zi;let De;e[5]===Symbol.for("react.memo_cache_sentinel")?(De=(fe,ie)=>{if(ie){ke.current.set(fe,ie);return}ke.current.delete(fe)},e[5]=De):De=e[5];const Ue=De;let Ve;e[6]!==r||e[7]!==$?(Ve=()=>{if(!$||!r){be(Vi);return}const fe=te.current,ie=ke.current.get(r);if(!fe||!ie){be(_i);return}let We=0,it=0,ut=ie;for(;ut&&ut!==fe;)We=We+ut.offsetLeft,it=it+ut.offsetTop,ut=ut.offsetParent;const wt={left:We,top:it,width:ie.offsetWidth,height:ie.offsetHeight};be(Rt=>Te(Rt,wt)?Rt:wt)},e[6]=r,e[7]=$,e[8]=Ve):Ve=e[8];const Me=Ve;let Ze;e[9]!==z?(Ze=()=>{if(!z){W({left:!1,right:!1});return}const fe=te.current;if(!fe){W({left:!1,right:!1});return}W({left:fe.scrollLeft>2,right:fe.scrollLeft+fe.clientWidth<fe.scrollWidth-2})},e[9]=z,e[10]=Ze):Ze=e[10];const Ee=Ze;let He;e[11]!==z||e[12]!==Ee?(He=()=>{if(!z){W({left:!1,right:!1});return}const fe=te.current;if(!fe)return;Ee(),fe.addEventListener("scroll",Ee,{passive:!0});const ie=new ResizeObserver(Ee);return ie.observe(fe),()=>{fe.removeEventListener("scroll",Ee),ie.disconnect()}},e[11]=z,e[12]=Ee,e[13]=He):He=e[13];let Le;e[14]!==z||e[15]!==n.length||e[16]!==Ee?(Le=[z,n.length,Ee],e[14]=z,e[15]=n.length,e[16]=Ee,e[17]=Le):Le=e[17],l.useEffect(He,Le);let ze;e[18]!==r||e[19]!==Me||e[20]!==$?(ze=()=>{if(!$){be(null);return}Me();const fe=te.current;if(!fe)return;const ie=new ResizeObserver(()=>{performance.now()-pe.current>Li&&le(!1),Me()});if(ie.observe(fe),r){const We=ke.current.get(r);We&&ie.observe(We)}return()=>{ie.disconnect()}},e[18]=r,e[19]=Me,e[20]=$,e[21]=ze):ze=e[21];let Je;e[22]!==r||e[23]!==n.length||e[24]!==Me||e[25]!==$?(Je=[r,n.length,Me,$],e[22]=r,e[23]=n.length,e[24]=Me,e[25]=$,e[26]=Je):Je=e[26],l.useEffect(ze,Je);let Be;e[27]!==Me?(Be=()=>{Me()},e[27]=Me,e[28]=Be):Be=e[28],l.useLayoutEffect(Be);let Qe;e[29]!==ne?(Qe=ne.join("\0"),e[29]=ne,e[30]=Qe):Qe=e[30];const Ke=Qe;let Pe,et;e[31]!==r||e[32]!==Ke||e[33]!==$?(Pe=()=>{if(!$){ce.current=!1,le(!1);return}const fe=F.current!==Ke;if(F.current=Ke,!ce.current){ce.current=!0,D.current=r;return}const ie=D.current!==r;if(D.current=r,!ie||fe){le(!1);return}pe.current=performance.now(),le(!0)},et=[r,Ke,$],e[31]=r,e[32]=Ke,e[33]=$,e[34]=Pe,e[35]=et):(Pe=e[34],et=e[35]),l.useLayoutEffect(Pe,et);let $e;e[36]!==r||e[37]!==z||e[38]!==Ee?($e=()=>{if(!z||!r)return;const fe=te.current;if(!fe)return;const ie=window.requestAnimationFrame(()=>{const We=typeof window.CSS?.escape=="function"?window.CSS.escape(r):r.replace(/"/g,'\\"'),it=fe.querySelector(`[data-sortable-tab-id="${We}"]`);it&&(it.scrollIntoView({block:"nearest",inline:"nearest"}),Ee())});return()=>{window.cancelAnimationFrame(ie)}},e[36]=r,e[37]=z,e[38]=Ee,e[39]=$e):$e=e[39];let b;e[40]!==r||e[41]!==z||e[42]!==n.length||e[43]!==Ee?(b=[r,z,n.length,Ee],e[40]=r,e[41]=z,e[42]=n.length,e[43]=Ee,e[44]=b):b=e[44],l.useEffect($e,b);let Z;e[45]!==o?(Z=fe=>{if(!o)return;const{active:ie,over:We}=fe;!We||ie.id===We.id||o(String(ie.id),String(We.id))},e[45]=o,e[46]=Z):Z=e[46];const m=Z;let j;e[47]!==y?(j=K("relative flex h-full min-w-0 flex-1",y),e[47]=y,e[48]=j):j=e[48];let ee;e[49]!==z||e[50]!==L||e[51]!==R?(ee=z&&L.left?t.jsx("div",{className:K("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",R?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[49]=z,e[50]=L,e[51]=R,e[52]=ee):ee=e[52];let ye;e[53]!==z||e[54]!==L||e[55]!==R?(ye=z&&L.right?t.jsx("div",{className:K("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",R?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[53]=z,e[54]=L,e[55]=R,e[56]=ye):ye=e[56];const xe=R?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",Oe=R&&"@container/pill-tabs",tt=R&&"pill-tabs__track",qe=R&&(h??"gap-0.5 py-0.5"),Re=B&&"items-center overflow-y-hidden",S=E&&"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",we=z?"overflow-x-auto scrollbar-none":"overflow-x-hidden";let Ie;e[57]!==xe||e[58]!==Oe||e[59]!==tt||e[60]!==qe||e[61]!==Re||e[62]!==S||e[63]!==we?(Ie=K("relative flex h-full min-w-0 flex-1",xe,Oe,tt,qe,Re,S,we),e[57]=xe,e[58]=Oe,e[59]=tt,e[60]=qe,e[61]=Re,e[62]=S,e[63]=we,e[64]=Ie):Ie=e[64];let Fe;e[65]!==z?(Fe=z?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,e[65]=z,e[66]=Fe):Fe=e[66];let st;e[67]!==w?(st=w("sortableTabsStrip.aria.tabs"),e[67]=w,e[68]=st):st=e[68];let ot;e[69]!==V||e[70]!==me||e[71]!==J||e[72]!==_||e[73]!==re||e[74]!==R?(ot=R&&J?t.jsx("div",{className:K("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)]",re&&_&&(V?"pill-tabs__indicator--is-animated-layout":"pill-tabs__indicator--is-animated")),style:V?{left:`${J.left+me}px`,top:`${J.top}px`,width:`${J.width}px`,height:`${J.height}px`}:{transform:`translate3d(${J.left+me}px, ${J.top}px, 0)`,width:`${J.width}px`,height:`${J.height}px`}}):null,e[69]=V,e[70]=me,e[71]=J,e[72]=_,e[73]=re,e[74]=R,e[75]=ot):ot=e[75];let at;e[76]!==me||e[77]!==J||e[78]!==_||e[79]!==B?(at=B&&J?t.jsx("div",{className:K("pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",_&&"underline-tabs__indicator--is-animated"),style:{transform:`translate3d(${J.left+me}px, 0, 0)`,width:`${J.width}px`},"aria-hidden":!0}):null,e[76]=me,e[77]=J,e[78]=_,e[79]=B,e[80]=at):at=e[80];let dt;if(e[81]!==he||e[82]!==r||e[83]!==c||e[84]!==A||e[85]!==M||e[86]!==I||e[87]!==G||e[88]!==N||e[89]!==z||e[90]!==n||e[91]!==i||e[92]!==a||e[93]!==H||e[94]!==R||e[95]!==$){let fe;e[97]!==he||e[98]!==r||e[99]!==c||e[100]!==A||e[101]!==M||e[102]!==I||e[103]!==G||e[104]!==N||e[105]!==z||e[106]!==i||e[107]!==a||e[108]!==H||e[109]!==R||e[110]!==$?(fe=ie=>{const We=ie.id===r,it=I&&R&&!We&&!!ie.icon,ut=!it,wt=!!ie.icon,Rt=I&&R&&We&&!z&&!H,vt=ie.closable!==!1&&!!i,kt=vt&&!!ie.icon,Tt=z||H?void 0:R?Rt?"flex-none basis-auto":N?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",Ot=vt?mt=>{mt.button===1&&(mt.preventDefault(),mt.stopPropagation(),i?.(ie.id))}:void 0,rs=vt?Gi:void 0;return t.jsx(he,{id:ie.id,className:Tt,children:t.jsxs("div",{ref:mt=>Ue(ie.id,mt),onAuxClick:Ot,onMouseDown:rs,className:K("group flex h-full min-w-0 flex-nowrap items-center",z||H?"shrink-0":R?"w-full":"w-full min-w-0",R?"relative z-10 bg-transparent":We?"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":We,"aria-label":it?ie.title??ie.label:void 0,onClick:()=>a(ie.id),onPointerDown:$?()=>{le(!0),ae(ie.id)}:void 0,onPointerUp:$?()=>ae(null):void 0,onPointerLeave:$?()=>ae(null):void 0,onPointerCancel:$?()=>ae(null):void 0,className:K(R?"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",R&&A?"lowercase":null,R&&(it?"gap-0":"gap-1.5"),R?H?"shrink-0 whitespace-nowrap px-3 text-center":z?"max-w-56 shrink-0 px-3 text-center":it?"px-2 !min-w-0 text-center":Rt?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":z?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",R?c??(G?N?"h-[38px]":"h-[31px]":"h-7"):null,R?We?"text-foreground":"text-muted-foreground hover:text-foreground":null,R?"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:ie.title??ie.label,children:R?t.jsxs(t.Fragment,{children:[wt?t.jsxs("span",{className:"relative flex h-4 w-4 shrink-0 items-center justify-center",children:[t.jsx("span",{className:K("flex items-center justify-center transition-opacity",kt&&(M?"opacity-0":"group-hover:opacity-0")),children:ie.icon}),kt?t.jsx("span",{role:"button",tabIndex:-1,className:K("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",M?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:Hi,onClick:mt=>{mt.stopPropagation(),i?.(ie.id)},"aria-label":ie.closeLabel??`Close ${ie.label} tab`,title:ie.closeLabel??`Close ${ie.label} tab`,children:t.jsx(P,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,ut?t.jsx("span",{className:"animated-tabs__label truncate",children:ie.label}):null]}):t.jsxs("span",{className:K("flex min-w-0 flex-nowrap items-center gap-1.5",!z&&"justify-center"),children:[wt?t.jsxs("span",{className:K("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",We?"text-[var(--primary-base)]":"text-muted-foreground"),children:[t.jsx("span",{className:K("flex items-center justify-center transition-opacity",kt&&(M?"opacity-0":"group-hover:opacity-0")),children:ie.icon}),kt?t.jsx("span",{role:"button",tabIndex:-1,className:K("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",M?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:Ki,onClick:mt=>{mt.stopPropagation(),i?.(ie.id)},"aria-label":ie.closeLabel??`Close ${ie.label} tab`,title:ie.closeLabel??`Close ${ie.label} tab`,children:t.jsx(P,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,t.jsx("span",{className:"truncate leading-[1.2]",children:ie.label})]})}),vt&&!kt?t.jsx("button",{type:"button",onPointerDown:qi,onClick:mt=>{mt.stopPropagation(),i?.(ie.id)},className:K("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",R?"-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",R?We?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":We?"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":ie.closeLabel??`Close ${ie.label} tab`,title:ie.closeLabel??`Close ${ie.label} tab`,children:t.jsx(P,{name:"close",className:"h-3 w-3"})}):null]})},ie.id)},e[97]=he,e[98]=r,e[99]=c,e[100]=A,e[101]=M,e[102]=I,e[103]=G,e[104]=N,e[105]=z,e[106]=i,e[107]=a,e[108]=H,e[109]=R,e[110]=$,e[111]=fe):fe=e[111],dt=n.map(fe),e[81]=he,e[82]=r,e[83]=c,e[84]=A,e[85]=M,e[86]=I,e[87]=G,e[88]=N,e[89]=z,e[90]=n,e[91]=i,e[92]=a,e[93]=H,e[94]=R,e[95]=$,e[96]=dt}else dt=e[96];let _e;e[112]!==Ie||e[113]!==Fe||e[114]!==st||e[115]!==ot||e[116]!==at||e[117]!==dt?(_e=t.jsxs("div",{ref:te,className:Ie,style:Fe,role:"tablist","aria-label":st,children:[ot,at,dt]}),e[112]=Ie,e[113]=Fe,e[114]=st,e[115]=ot,e[116]=at,e[117]=dt,e[118]=_e):_e=e[118];let ft;e[119]!==j||e[120]!==ee||e[121]!==ye||e[122]!==_e?(ft=t.jsxs("div",{className:j,children:[ee,ye,_e]}),e[119]=j,e[120]=ee,e[121]=ye,e[122]=_e,e[123]=ft):ft=e[123];const T=ft;if(!ue)return T;let oe;e[124]===Symbol.for("react.memo_cache_sentinel")?(oe=[Fi],e[124]=oe):oe=e[124];let ge;e[125]!==ne||e[126]!==T?(ge=t.jsx(cr,{items:ne,strategy:$o,children:T}),e[125]=ne,e[126]=T,e[127]=ge):ge=e[127];let Ye;e[128]===Symbol.for("react.memo_cache_sentinel")?(Ye=t.jsx(Wo,{dropAnimation:null}),e[128]=Ye):Ye=e[128];let je;return e[129]!==m||e[130]!==Se||e[131]!==ge?(je=t.jsxs(or,{sensors:Se,collisionDetection:ir,onDragEnd:m,modifiers:oe,children:[ge,Ye]}),e[129]=m,e[130]=Se,e[131]=ge,e[132]=je):je=e[132],je};function Wi(s){return s.isMobile}function $i(s){return s.id}function zi(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 Vi(s){return s===null?s:null}function _i(s){return s===null?s:null}function Gi(s){s.button===1&&s.preventDefault()}function Hi(s){s.stopPropagation()}function Ki(s){s.stopPropagation()}function qi(s){s.stopPropagation()}const Bt=bs()(er(tr((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 Zr();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 Xr();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 Qr();return s({discoveredCredentials:n}),!0}catch(n){return console.error("Failed to discover git credentials:",n),s({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{const n=r=>{if(typeof r!="string")return null;const a=r.trim();return a.length>0?a:null};try{let r=null;if(r===null){const a=bo()?.settings;if(a)try{const o=(await a.load())?.settings||{};r=n(o.defaultGitIdentityId)}catch{}}if(r===null)try{const a=await Nt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(a.ok){const i=await a.json().catch(()=>null);r=n(i?.defaultGitIdentityId)}}catch{}return s({defaultGitIdentityId:r}),!0}catch(r){return console.error("Failed to load default git identity setting:",r),!1}},setDefaultGitIdentityId:async n=>{try{const r=typeof n=="string"?n.trim():"",a=r.length>0?r:"";return await Qn({defaultGitIdentityId:a}),s({defaultGitIdentityId:a.length>0?a: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 St("saving"),await Jr(r),St("saved"),await e().loadProfiles(),!0}catch(r){return St("error"),console.error("Failed to create git identity profile:",r),!1}},updateProfile:async(n,r)=>{try{const a=e().profiles.find(o=>o.id===n);if(!a)throw new Error("Profile not found");const i={...a,...r};return St("saving"),await Yr(n,i),St("saved"),await e().loadProfiles(),!0}catch(a){return St("error"),console.error("Failed to update git identity profile:",a),!1}},deleteProfile:async n=>{try{return St("saving"),await qr(n),St("saved"),e().selectedProfileId===n&&s({selectedProfileId:null}),await e().loadProfiles(),!0}catch(r){return St("error"),console.error("Failed to delete git identity profile:",r),!1}},getProfileById:n=>{const{profiles:r,globalIdentity:a}=e();return n==="global"?a||void 0:r.find(i=>i.id===n)},getUnimportedCredentials:()=>{const{profiles:n,discoveredCredentials:r}=e();return r.filter(a=>!n.some(i=>i.authType==="token"&&i.host===a.host))}}),{name:"git-identities-store",storage:xo(),partialize:s=>({selectedProfileId:s.selectedProfileId})}),{name:"git-identities-store"}));typeof window<"u"&&(window.__zustand_git_identities_store__=Bt);const Xt=ea,It=s=>{const e=Ge.c(11),{title:n,description:r,info:a,settingsItem:i,titleAccessory:o,headerAction:u,children:f,className:h,contentClassName:c,divider:g}=s,p=g===void 0?!0:g;let x;return e[0]!==f||e[1]!==h||e[2]!==c||e[3]!==r||e[4]!==p||e[5]!==u||e[6]!==a||e[7]!==i||e[8]!==n||e[9]!==o?(x=t.jsx(ta,{title:n,description:r,info:a,settingsItem:i,titleAccessory:o,headerAction:u,divider:p,className:h,contentClassName:c,children:f}),e[0]=f,e[1]=h,e[2]=c,e[3]=r,e[4]=p,e[5]=u,e[6]=a,e[7]=i,e[8]=n,e[9]=o,e[10]=x):x=e[10],x},Yi=450,Ji=({projectRef:s=null,sections:e="all"})=>{const{t:n}=nt(),{isMobile:r,isTablet:a}=xs(),i=r||a,o=gt(E=>E.getActiveProject()),u=s?.path??o?.path??null,f=rt(E=>E.getWorktreeMetadata),h=sa(),c=ns(E=>E.homeDirectory),[g,p]=l.useState([]),[x,d]=l.useState(!1),[y,v]=l.useState(!1),[C,I]=l.useState(null),[A,V]=l.useState(null),[w,N]=l.useState([]),[k,M]=l.useState(!1),te=l.useRef(!1),q=l.useMemo(()=>s?.id&&s?.path?{id:s.id,path:s.path}:!o?.id||!u?null:{id:o.id,path:u},[o?.id,u,s?.id,s?.path]),L=l.useCallback(async()=>{if(!(!q||A===!1))try{const E=await Js(q);N(E)}catch{}},[q,A]);l.useEffect(()=>{if(!u)return;let E=!1;return V(null),(async()=>{try{const re=await na(u);if(E)return;V(re)}catch{}})(),()=>{E=!0}},[u]),l.useEffect(()=>{if(!q){N([]),M(!1);return}if(A===!1){N([]),M(!1);return}let E=!1;return M(!0),N([]),(async()=>{try{const re=await Js(q);if(E)return;N(re)}catch{}finally{E||M(!1)}})(),()=>{E=!0}},[q,A]),l.useEffect(()=>{if(!q)return;let E=!1;return v(!0),(async()=>{try{const[re,ue]=await Promise.all([zn(q),Vn(q)]);if(!E){const he=re.length>0?re:[""];p(he),I(JSON.stringify(he)),d(ue)}}catch{E||(p([""]),I(JSON.stringify([""])),d(!1))}finally{E||v(!1)}})(),()=>{E=!0}},[q]);const W=l.useCallback(async E=>{if(!q)return!1;const re=E.filter(ue=>ue.trim().length>0);try{return await ra(q,re)?(I(JSON.stringify(E)),!0):(ve.error(n("settings.openchamber.worktrees.setup.toast.saveFailed")),!1)}catch{return ve.error(n("settings.openchamber.worktrees.setup.toast.saveFailed")),!1}},[q,n]),O=l.useMemo(()=>C===null?!1:C!==JSON.stringify(g),[C,g]);l.useEffect(()=>{if(!O||y||te.current)return;const E=window.setTimeout(()=>{te.current||(te.current=!0,(async()=>{try{await W(g)}finally{te.current=!1}})())},Yi);return()=>{window.clearTimeout(E)}},[O,y,W,g]);const ne=l.useCallback((E,re)=>{p(ue=>{const he=[...ue];return he[E]=re,he})},[]),z=l.useCallback(()=>{p(E=>[...E,""])},[]),de=l.useCallback(E=>{p(re=>{const ue=re.filter((he,Ce)=>Ce!==E);return ue.length>0?ue:[""]})},[]),G=l.useCallback(()=>{!O||te.current||(te.current=!0,(async()=>{try{await W(g)}finally{te.current=!1}})())},[O,W,g]),U=l.useCallback(E=>{d(E),q&&aa(q,E)},[q]),R=l.useCallback(E=>{const re=Y=>Y.replace(/\\/g,"/").replace(/\/+$/,""),ue=re(E.path),he=h.filter(Y=>{const ae=f(Y.id);if(ae?.path&&re(ae.path)===ue)return!0;const ce=Y.directory;return!!(ce&&re(ce)===ue)}),Ce=new Set(he.map(Y=>Y.id)),ke=[...As.getState().activeSessions,...As.getState().archivedSessions],J=Y=>{const ae=ke.filter(pe=>{const D=pe.parentID;return D&&Y.has(D)});if(ae.length===0)return[];const ce=new Set(ae.map(pe=>pe.id));return[...ae,...J(ce)]},be=J(Ce),_=new Set,le=[...he,...be].filter(Y=>_.has(Y.id)?!1:(_.add(Y.id),!0));oa.requestDelete({sessions:le,mode:"worktree",worktree:E})},[h,f]),B=l.useMemo(()=>h.map(E=>E.id).join(","),[h]);l.useEffect(()=>{A&&u&&L()},[B,A,u,L]);const $=t.jsxs(Bs,{children:[n("settings.openchamber.worktrees.setup.tooltipPrefix")," ",t.jsx("code",{className:"font-mono text-xs bg-sidebar-accent/50 px-1 rounded",children:"$ROOT_PROJECT_PATH"})," ",n("settings.openchamber.worktrees.setup.tooltipSuffix")]}),H=t.jsx(Bs,{children:n("settings.openchamber.worktrees.list.tooltip")});return u?A===!1?t.jsx(It,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.state.gitOnly")})}):t.jsxs(t.Fragment,{children:[e==="all"?t.jsx(It,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",titleAccessory:$,children:y?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.setup.loading")}):t.jsxs("div",{className:K("space-y-2",Xt),children:[g.map((E,re)=>t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(ht,{value:E,onChange:ue=>ne(re,ue.target.value),onBlur:G,placeholder:n("settings.openchamber.worktrees.setup.commandPlaceholder"),className:"h-7 min-w-0 flex-1 font-mono text-xs"}),t.jsx(Ne,{type:"button",variant:"ghost",size:"icon",onClick:()=>de(re),className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive","aria-label":n("settings.openchamber.worktrees.setup.removeCommandAria"),children:t.jsx(P,{name:"close",className:"h-4 w-4"})})]},re)),t.jsxs(Ne,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:z,children:[t.jsx(P,{name:"add",className:"h-3.5 w-3.5"}),n("settings.openchamber.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(ss,{checked:x,onChange:U,ariaLabel:n("settings.openchamber.worktrees.setup.waitForCommandsAria")}),t.jsx("span",{className:K("typography-ui-label font-normal",x?"text-foreground":"text-foreground/60"),children:n("settings.openchamber.worktrees.setup.waitForCommands")})]})]})}):null,t.jsx(It,{title:n("settings.openchamber.worktrees.list.title"),titleAccessory:H,children:k?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.list.loading")}):w.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:n("settings.openchamber.worktrees.list.empty")}):t.jsx("div",{className:K("space-y-1",e==="all"&&Xt),children:w.map(E=>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:E.label||E.branch||n("settings.openchamber.worktrees.list.detachedHead")})}),t.jsx("p",{className:"typography-micro truncate text-muted-foreground/60",children:ia(E.path,c)})]}),t.jsx("button",{type:"button",onClick:()=>R(E),className:K("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",i?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":n("settings.openchamber.worktrees.list.deleteWorktreeAria",{name:E.branch||E.label||E.path}),children:t.jsx(P,{name:"delete-bin",className:"h-4 w-4"})})]},E.path))})})]}):t.jsx(It,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.state.selectProject")})})},jn=(s,e)=>e.updatedAtMs-s.updatedAtMs,Nn=bs((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([ua(),Xs()]),a={};for(const i of r.sort(jn))a[i.id]=i;e().listenerReady||await ma(i=>{s(o=>({statusesById:{...o.statusesById,[i.id]:i}}))}),s({instances:n.instances,statusesById:a,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 da();s({importCandidates:n,isImportsLoading:!1})}catch(n){s({isImportsLoading:!1,error:n instanceof Error?n.message:String(n)})}}},refreshStatuses:async()=>{try{const n=await Xs(),r={};for(const a of n.sort(jn))r[a.id]=a;s({statusesById:r})}catch(n){s({error:n instanceof Error?n.message:String(n)})}},setInstances:async n=>{s({isSaving:!0,error:null});try{await ca({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,a=r.some(i=>i.id===n.id)?r.map(i=>i.id===n.id?n:i):[n,...r];await e().setInstances(a)},createFromCommand:async(n,r,a)=>{const i=fa(n,r);a&&a.trim()&&(i.nickname=a.trim()),await e().upsertInstance(i)},removeInstance:async n=>{await Qs(n).catch(()=>{});const r=e().instances.filter(a=>a.id!==n);await e().setInstances(r),s(a=>{const i={...a.statusesById};return delete i[n],{statusesById:i}})},connect:async n=>{s({error:null});try{await la(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 Qs(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})})),hr=[{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"}],pr=Object.fromEntries(hr.map(s=>[s.key,s.Icon])),Qi="openchamber:project-actions-updated",Xi=s=>{const e=(s||"").trim().replace(/\\/g,"/");return e?e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e:""},ud=(s,e)=>`${Xi(s)}::${e}`,Zi=s=>{const e=s.trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},Sn=s=>{if(typeof s!="number"||!Number.isFinite(s))return null;const e=Math.round(s);return e<1||e>65535?null:e},el=(s,e)=>{if(!e.enabled||e.type!=="local")return null;const n=Sn(e.localPort),r=Sn(e.remotePort);if(!n||!r)return null;const a=Zi(e.localHost||s.localForward.bindHost||"127.0.0.1"),i=(e.remoteHost||"127.0.0.1").trim(),o=(s.nickname||s.id||"instance").trim();return{id:`${s.id}::${e.id}`,label:`${o} - ${a}:${n} -> ${i}:${r}`,url:`http://${a}:${n}`}},gr=s=>{const e=[];for(const n of s)if(!(!n?.id||!Array.isArray(n.portForwards)))for(const r of n.portForwards){const a=el(n,r);a&&e.push(a)}return e},md=(s,e)=>{const n=(s||"").trim();return n&&gr(e).find(i=>i.id===n)?.url||null},tl=450,sl=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`action_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,nl=()=>({id:sl(),name:"",command:"",icon:"play"}),rl=({projectRef:s})=>{const{t:e}=nt(),n=l.useMemo(()=>Xn(),[]),r=Nn(N=>N.instances),a=Nn(N=>N.load),[i,o]=l.useState([]),[u,f]=l.useState(!1),[h,c]=l.useState(null),[g,p]=l.useState({}),x=l.useRef(!1),d=l.useRef(null);l.useEffect(()=>{n&&a().catch(()=>{})},[n,a]),l.useEffect(()=>{let N=!1;return f(!0),(async()=>{try{const k=await ha(s);if(N)return;o(k.actions),c(JSON.stringify({actions:k.actions}))}catch{if(N)return;o([]),c(JSON.stringify({actions:[]}))}finally{N||f(!1)}})(),()=>{N=!0}},[s]);const y=l.useMemo(()=>n?gr(r):[],[r,n]),v=l.useMemo(()=>i.some(k=>k.name.trim().length===0||k.command.trim().length===0)?e("settings.projects.actions.validation.fillNameAndCommand"):null,[i,e]),C=l.useMemo(()=>h===null?!1:h!==JSON.stringify({actions:i}),[i,h]),I=l.useCallback(async N=>await pa(s,{actions:N,primaryActionId:null})?(c(JSON.stringify({actions:N})),typeof window<"u"&&window.dispatchEvent(new CustomEvent(Qi,{detail:{projectId:s.id}})),!0):(ve.error(e("settings.projects.actions.toast.saveFailed")),!1),[s,e]);l.useEffect(()=>{if(!C||u||v||x.current)return;const N=window.setTimeout(()=>{x.current||(x.current=!0,(async()=>{try{await I(i)}finally{x.current=!1}})())},tl);return()=>{window.clearTimeout(N)}},[i,C,u,I,v]),l.useEffect(()=>{if(!C||!v||u){v||(d.current=null);return}const N=window.setTimeout(()=>{d.current!==v&&(d.current=v,ve.error(v))},1e3);return()=>{window.clearTimeout(N)}},[C,u,v]);const A=l.useCallback(()=>{const N=nl();o(k=>[...k,N]),p(k=>({...k,[N.id]:!0}))},[]),V=l.useCallback(N=>{o(k=>k.filter(M=>M.id!==N)),p(k=>{const M={...k};return delete M[N],M})},[]),w=l.useCallback((N,k)=>{o(M=>M.map(te=>te.id===N?k(te):te))},[]);return t.jsxs(It,{title:e("settings.projects.actions.title"),info:e("settings.projects.actions.description"),settingsItem:"projects.actions",headerAction:t.jsxs(Ne,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:A,children:[t.jsx(P,{name:"add",className:"h-3.5 w-3.5"}),e("settings.projects.actions.actions.add")]}),contentClassName:"space-y-0",children:[u?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.loading")}):i.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.empty")}):t.jsx("div",{className:K("space-y-0",Xt),children:i.map(N=>{const k=N.icon||"play",M=pr[k]||"play",te=g[N.id]??!1,q=N.name.trim()||e("settings.projects.actions.state.untitled");return t.jsxs(vi,{open:te,onOpenChange:L=>{p(W=>({...W,[N.id]:L}))},className:"py-1.5",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs(ki,{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:[te?t.jsx(P,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):t.jsx(P,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),t.jsx(P,{name:M,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:q})})]}),t.jsx(Ne,{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(N.id),children:t.jsx(P,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(ji,{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(Pt,{children:[t.jsx(Dt,{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(P,{name:M,className:"h-4 w-4"})})}),t.jsx(Et,{align:"start",className:"w-56 p-2",children:t.jsx("div",{className:"grid grid-cols-6 gap-1",children:hr.map(L=>{const W=L.Icon,O=(N.icon||"play")===L.key;return t.jsx("button",{type:"button",onClick:()=>w(N.id,ne=>({...ne,icon:L.key})),className:K("inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]",O&&"border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]"),"aria-label":e("settings.projects.actions.field.iconAria",{icon:L.label}),children:t.jsx(P,{name:W,className:"h-4 w-4"})},L.key)})})})]}),t.jsx(ht,{value:N.name,onChange:L=>w(N.id,W=>({...W,name:L.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(_n,{value:N.command,onChange:L=>w(N.id,W=>({...W,command:L.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:"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":N.autoOpenUrl===!0,onClick:()=>w(N.id,L=>({...L,...L.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:L=>{(L.key===" "||L.key==="Enter")&&(L.preventDefault(),w(N.id,W=>({...W,...W.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[t.jsx(ss,{checked:N.autoOpenUrl===!0,onChange:L=>w(N.id,W=>({...W,...L?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:e("settings.projects.actions.field.autoOpenUrlForAria",{title:q})}),t.jsx("span",{className:"typography-ui-label font-normal text-foreground/80",children:e("settings.projects.actions.field.autoOpenUrlDescription")})]})]}),N.autoOpenUrl===!0?t.jsxs("div",{className:"mt-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ht,{value:N.openUrl||"",onChange:L=>w(N.id,W=>({...W,openUrl:L.target.value})),placeholder:e("settings.projects.actions.field.overrideUrlPlaceholder"),className:"h-7 w-full max-w-[24rem]"}),t.jsx(Bs,{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")}),y.length>0?t.jsxs(ga,{value:N.desktopOpenSshForward&&y.some(L=>L.id===N.desktopOpenSshForward)?N.desktopOpenSshForward:"__none__",onValueChange:L=>{w(N.id,W=>({...W,...L==="__none__"?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:L}}))},children:[t.jsx(xa,{size:ba,className:"w-full",children:t.jsx(ya,{placeholder:e("settings.projects.actions.field.useOutputManualUrl")})}),t.jsxs(wa,{children:[t.jsx(Zs,{value:"__none__",children:e("settings.projects.actions.field.useOutputManualUrl")}),y.map(L=>t.jsx(Zs,{value:L.id,children:L.label},L.id))]})]}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.noDesktopSshForwards")})]}):null]}):null]})]})})]},N.id)})}),v&&i.length>0?t.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:v}):null]})},al=s=>{const e=Ge.c(123),{form:n}=s,{t:r}=nt(),{currentTheme:a}=Gn(),{name:i,setName:o,icon:u,setIcon:f,color:h,setColor:c,iconBackground:g,setIconBackground:p,parsedDefaultModel:x,handleDefaultModelChange:d,isUploadingIcon:y,isRemovingCustomIcon:v,isDiscoveringIcon:C,pendingRemoveImageIcon:I,setPendingRemoveImageIcon:A,pendingUploadIconPreviewUrl:V,setPreviewImageFailed:w,hasPendingUploadImageIcon:N,hasCustomIcon:k,effectiveHasImageIcon:M,hasRemovableImageIcon:te,showImagePreview:q,fileInputRef:L,handleUploadIcon:W,handleRemoveImageIcon:O,handleDiscoverIcon:ne,currentIconImage:z,project:de}=n;if(!de)return null;const G=h?va[h]??null:null;let U;e[0]!==r?(U=r("settings.projects.page.field.projectName"),e[0]=r,e[1]=U):U=e[1];let R;e[2]!==o?(R=b=>o(b.target.value),e[2]=o,e[3]=R):R=e[3];let B;e[4]!==r?(B=r("settings.projects.page.field.projectNamePlaceholder"),e[4]=r,e[5]=B):B=e[5];let $;e[6]===Symbol.for("react.memo_cache_sentinel")?($=K("h-8 rounded-md px-3",Xt),e[6]=$):$=e[6];let H;e[7]!==i||e[8]!==R||e[9]!==B?(H=t.jsx(ht,{value:i,onChange:R,placeholder:B,className:$}),e[7]=i,e[8]=R,e[9]=B,e[10]=H):H=e[10];let E;e[11]!==U||e[12]!==H?(E=t.jsx(It,{title:U,settingsItem:"projects.name",divider:!1,children:H}),e[11]=U,e[12]=H,e[13]=E):E=e[13];let re;e[14]!==r?(re=r("settings.projects.page.field.defaultModel"),e[14]=r,e[15]=re):re=e[15];let ue;e[16]!==r?(ue=r("settings.projects.page.field.defaultModelDescription"),e[16]=r,e[17]=ue):ue=e[17];const he=x.providerId,Ce=x.modelId;let ke;e[18]===Symbol.for("react.memo_cache_sentinel")?(ke=K("h-8 min-h-8 rounded-md px-3 max-w-48",Xt),e[18]=ke):ke=e[18];let J;e[19]!==d||e[20]!==x.modelId||e[21]!==x.providerId?(J=t.jsx($n,{providerId:he,modelId:Ce,onChange:d,className:ke}),e[19]=d,e[20]=x.modelId,e[21]=x.providerId,e[22]=J):J=e[22];let be;e[23]!==J||e[24]!==re||e[25]!==ue?(be=t.jsx(It,{title:re,info:ue,settingsItem:"projects.default-model",children:J}),e[23]=J,e[24]=re,e[25]=ue,e[26]=be):be=e[26];let _;e[27]!==r?(_=r("settings.projects.page.field.accentColor"),e[27]=r,e[28]=_):_=e[28];let le;e[29]!==c?(le=()=>c(null),e[29]=c,e[30]=le):le=e[30];const Y=h===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let ae;e[31]!==Y?(ae=K("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",Y),e[31]=Y,e[32]=ae):ae=e[32];let ce;e[33]!==r?(ce=r("settings.projects.page.field.none"),e[33]=r,e[34]=ce):ce=e[34];let pe;e[35]===Symbol.for("react.memo_cache_sentinel")?(pe=t.jsx(P,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[35]=pe):pe=e[35];let D;e[36]!==le||e[37]!==ae||e[38]!==ce?(D=t.jsx("button",{type:"button",onClick:le,className:ae,title:ce,children:pe}),e[36]=le,e[37]=ae,e[38]=ce,e[39]=D):D=e[39];let F;e[40]!==h||e[41]!==c?(F=ka.map(b=>t.jsx("button",{type:"button",onClick:()=>c(b.key),className:K("h-7 w-7 rounded-md border transition-colors",h===b.key?"border-2 border-foreground ring-1 ring-[var(--primary-base)]/40":"border-transparent hover:border-border/70"),style:{backgroundColor:b.cssVar},title:b.label},b.key)),e[40]=h,e[41]=c,e[42]=F):F=e[42];let X;e[43]!==D||e[44]!==F?(X=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[D,F]}),e[43]=D,e[44]=F,e[45]=X):X=e[45];let me;e[46]!==_||e[47]!==X?(me=t.jsx(It,{title:_,settingsItem:"projects.accent-color",children:X}),e[46]=_,e[47]=X,e[48]=me):me=e[48];let se;e[49]!==r?(se=r("settings.projects.page.field.projectIcon"),e[49]=r,e[50]=se):se=e[50];let Se;e[51]!==W?(Se=b=>{const Z=b.target.files?.[0]??null;W(Z),b.currentTarget.value=""},e[51]=W,e[52]=Se):Se=e[52];let Te;e[53]!==L||e[54]!==Se?(Te=t.jsx("input",{ref:L,type:"file",accept:"image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg",className:"hidden",onChange:Se}),e[53]=L,e[54]=Se,e[55]=Te):Te=e[55];let De;e[56]!==f?(De=()=>f(null),e[56]=f,e[57]=De):De=e[57];const Ue=u===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let Ve;e[58]!==Ue?(Ve=K("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",Ue),e[58]=Ue,e[59]=Ve):Ve=e[59];let Me;e[60]!==r?(Me=r("settings.projects.page.field.none"),e[60]=r,e[61]=Me):Me=e[61];let Ze;e[62]===Symbol.for("react.memo_cache_sentinel")?(Ze=t.jsx(P,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[62]=Ze):Ze=e[62];let Ee;e[63]!==De||e[64]!==Ve||e[65]!==Me?(Ee=t.jsx("button",{type:"button",onClick:De,className:Ve,title:Me,children:Ze}),e[63]=De,e[64]=Ve,e[65]=Me,e[66]=Ee):Ee=e[66];let He;e[67]!==G||e[68]!==u||e[69]!==f?(He=ja.map(b=>{const Z=b.Icon;return t.jsx("button",{type:"button",onClick:()=>f(b.key),className:K("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",u===b.key?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-transparent hover:border-border hover:bg-[var(--surface-muted)]"),title:b.label,children:t.jsx(P,{name:Z,className:"w-4 h-4",style:G&&u===b.key?{color:G}:void 0})},b.key)}),e[67]=G,e[68]=u,e[69]=f,e[70]=He):He=e[70];let Le;e[71]!==Ee||e[72]!==He?(Le=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Ee,He]}),e[71]=Ee,e[72]=He,e[73]=Le):Le=e[73];let ze;e[74]!==z||e[75]!==a||e[76]!==M||e[77]!==N||e[78]!==g||e[79]!==V||e[80]!==de||e[81]!==w||e[82]!==q||e[83]!==r?(ze=M&&q&&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:g?{backgroundColor:g}:void 0,children:N&&V?t.jsx("img",{src:V,alt:"",className:"h-full w-full object-contain",draggable:!1,onError:()=>w(!0)}):t.jsx(Na,{project:{...de,iconImage:z??de.iconImage},options:{themeVariant:a.metadata.variant,iconColor:a.colors.surface.foreground},className:"h-full w-full object-contain",onError:()=>w(!0)})})})]}),e[74]=z,e[75]=a,e[76]=M,e[77]=N,e[78]=g,e[79]=V,e[80]=de,e[81]=w,e[82]=q,e[83]=r,e[84]=ze):ze=e[84];let Je;e[85]!==M||e[86]!==g||e[87]!==p||e[88]!==r?(Je=M&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("input",{type:"color",value:g??"#000000",onChange:b=>p(b.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(ht,{value:g??"",onChange:b=>p(b.target.value),placeholder:"#000000",className:"h-7 w-[8rem]"}),t.jsx(Ne,{type:"button",size:"xs",variant:"outline",onClick:()=>p(null),className:"h-7 w-7 p-0","aria-label":r("settings.projects.page.field.clearIconBackgroundAria"),title:r("settings.projects.page.field.clearBackground"),disabled:!g,children:t.jsx(P,{name:"close",className:"h-3.5 w-3.5"})})]}),e[85]=M,e[86]=g,e[87]=p,e[88]=r,e[89]=Je):Je=e[89];let Be;e[90]!==L||e[91]!==ne||e[92]!==k||e[93]!==C||e[94]!==y||e[95]!==r?(Be=!k&&t.jsxs(t.Fragment,{children:[t.jsx(Ne,{size:"xs",className:"h-6 !font-normal",onClick:()=>L.current?.click(),disabled:y,children:r(y?"settings.projects.page.actions.uploading":"settings.projects.page.actions.uploadIcon")}),t.jsx(Ne,{size:"xs",className:"h-6 !font-normal",variant:"outline",onClick:()=>{ne()},disabled:C,children:r(C?"settings.projects.page.actions.discovering":"settings.projects.page.actions.discoverFavicon")})]}),e[90]=L,e[91]=ne,e[92]=k,e[93]=C,e[94]=y,e[95]=r,e[96]=Be):Be=e[96];let Qe;e[97]!==O||e[98]!==te||e[99]!==v||e[100]!==r?(Qe=te&&t.jsx(Ne,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>{O()},disabled:v,children:r(v?"settings.projects.page.actions.removing":"settings.projects.page.actions.removeProjectIcon")}),e[97]=O,e[98]=te,e[99]=v,e[100]=r,e[101]=Qe):Qe=e[101];let Ke;e[102]!==v||e[103]!==I||e[104]!==A||e[105]!==r?(Ke=I&&t.jsx(Ne,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>A(!1),disabled:v,children:r("settings.projects.page.actions.undoRemove")}),e[102]=v,e[103]=I,e[104]=A,e[105]=r,e[106]=Ke):Ke=e[106];let Pe;e[107]!==Be||e[108]!==Qe||e[109]!==Ke?(Pe=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Be,Qe,Ke]}),e[107]=Be,e[108]=Qe,e[109]=Ke,e[110]=Pe):Pe=e[110];let et;e[111]!==se||e[112]!==Te||e[113]!==Le||e[114]!==ze||e[115]!==Je||e[116]!==Pe?(et=t.jsxs(It,{title:se,settingsItem:"projects.icon",contentClassName:"space-y-3",children:[Te,Le,ze,Je,Pe]}),e[111]=se,e[112]=Te,e[113]=Le,e[114]=ze,e[115]=Je,e[116]=Pe,e[117]=et):et=e[117];let $e;return e[118]!==be||e[119]!==me||e[120]!==et||e[121]!==E?($e=t.jsxs(t.Fragment,{children:[E,be,me,et]}),e[118]=be,e[119]=me,e[120]=et,e[121]=E,e[122]=$e):$e=e[122],$e},ol=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,il=s=>{if(!s)return null;const e=s.trim();return e&&ol.test(e)?e.toLowerCase():null},ll=s=>{const{t:e}=nt(),n=gt(_=>_.uploadProjectIcon),r=gt(_=>_.removeProjectIcon),a=gt(_=>_.discoverProjectIcon),i=gt(_=>s?_.projects.find(le=>le.id===s.id)?.iconImage??null:null),[o,u]=l.useState(""),[f,h]=l.useState(null),[c,g]=l.useState(null),[p,x]=l.useState(null),[d,y]=l.useState(void 0),[v,C]=l.useState(!1),[I,A]=l.useState(!1),[V,w]=l.useState(!1),[N,k]=l.useState(!1),[M,te]=l.useState(null),[q,L]=l.useState(null),[W,O]=l.useState(!1),ne=l.useRef(null),z=l.useCallback(()=>{te(null),L(_=>(_&&URL.revokeObjectURL(_),null))},[]),de=s?.id??null;l.useEffect(()=>{if(!s){u(""),h(null),g(null),x(null),y(void 0);return}u(s.label??""),h(s.icon??null),g(s.color??null),x(s.iconBackground??null),y(s.defaultModel),k(!1),z(),O(!1)},[s,z]),l.useEffect(()=>()=>{z()},[z]);const G=l.useMemo(()=>Hn(d)??{providerId:"",modelId:""},[d]),U=!!s?.iconImage,R=!!(M&&q),B=s?.iconImage?.source==="custom",$=U&&!N||R,H=$,E=!!(s&&U&&!N),re=!W&&(R||E),ue=!!s&&(o.trim()!==(s?.label??"").trim()||f!==(s?.icon??null)||c!==(s?.color??null)||p!==(s?.iconBackground??null)||(d??void 0)!==(s?.defaultModel??void 0)||N||!!M),he=l.useCallback((_,le)=>{y(_&&le?`${_}/${le}`:void 0)},[]),Ce=l.useCallback(_=>{!s||!_||v||(k(!1),O(!1),te(_),L(le=>(le&&URL.revokeObjectURL(le),URL.createObjectURL(_))))},[v,s]),ke=l.useCallback(()=>{!s||!H||I||(R&&z(),k(!!U),O(!1))},[z,R,H,U,I,s]),J=l.useCallback(async()=>{if(!(!s||V)){z(),k(!1),O(!1),w(!0);try{const _=await a(s.id);if(!_.ok){ve.error(_.error||e("settings.projects.page.toast.discoverIconFailed"));return}if(_.skipped){ve.success(e("settings.projects.page.toast.customIconAlreadySet"));return}ve.success(e("settings.projects.page.toast.iconDiscovered"))}finally{w(!1)}}},[z,a,V,s,e]),be=l.useCallback(async _=>{const le=_?.silent===!0;if(!s)return null;const Y=o.trim();if(!Y)return null;if(M){C(!0);const ce=await n(s.id,M);if(C(!1),!ce.ok)return ve.error(ce.error||e("settings.projects.page.toast.uploadIconFailed")),null;le||ve.success(e("settings.projects.page.toast.iconUpdated")),z(),k(!1)}const ae=N&&!!s.iconImage;if(ae){A(!0);const ce=await r(s.id);if(A(!1),!ce.ok)return ve.error(ce.error||e("settings.projects.page.toast.removeIconFailed")),null;le||ve.success(e("settings.projects.page.toast.iconRemoved")),k(!1),x(null)}return{label:Y,icon:f,color:c,iconBackground:il(ae?null:p),defaultModel:d??null}},[z,c,d,f,p,o,N,M,s,r,e,n]);return l.useEffect(()=>{O(!1)},[de,i?.updatedAt]),{name:o,setName:u,icon:f,setIcon:h,color:c,setColor:g,iconBackground:p,setIconBackground:x,defaultModel:d,parsedDefaultModel:G,handleDefaultModelChange:he,isUploadingIcon:v,isRemovingCustomIcon:I,isDiscoveringIcon:V,pendingRemoveImageIcon:N,setPendingRemoveImageIcon:k,pendingUploadIconFile:M,pendingUploadIconPreviewUrl:q,previewImageFailed:W,setPreviewImageFailed:O,hasStoredImageIcon:U,hasPendingUploadImageIcon:R,hasCustomIcon:B,effectiveHasImageIcon:$,hasRemovableImageIcon:H,showStoredImagePreview:E,showImagePreview:re,fileInputRef:ne,clearPendingUploadIcon:z,handleUploadIcon:Ce,handleRemoveImageIcon:ke,handleDiscoverIcon:J,hasChanges:ue,prepareSaveData:be,currentIconImage:i,project:s}},cl=450,dl=(s,e)=>{const{t:n}=nt(),{hasChanges:r,name:a,icon:i,color:o,iconBackground:u,defaultModel:f,pendingRemoveImageIcon:h,pendingUploadIconFile:c,isUploadingIcon:g,isRemovingCustomIcon:p,prepareSaveData:x}=s,d=l.useRef(!1);l.useEffect(()=>{if(!r||!a.trim()||g||p||d.current)return;const y=window.setTimeout(()=>{d.current||(d.current=!0,(async()=>{try{const v=await x({silent:!0});if(v)try{await e(v)}catch{ve.error(n("settings.projects.page.toast.saveFailed"))}}finally{d.current=!1}})())},cl);return()=>{window.clearTimeout(y)}},[o,f,r,i,u,p,g,a,e,h,c,x,n])},fd=s=>{const e=Ge.c(16),{project:n,onIdentitySave:r,showWorktrees:a}=s,i=a===void 0?!0:a,o=ll(n);let u;e:{if(!n){u=null;break e}let y;e[0]!==n.id||e[1]!==n.path?(y={id:n.id,path:n.path},e[0]=n.id,e[1]=n.path,e[2]=y):y=e[2],u=y}const f=u;let h;if(e[3]!==r?(h=async y=>{await r(y)},e[3]=r,e[4]=h):h=e[4],dl(o,h),!n||!f)return null;let g;e[5]!==o?(g=t.jsx(al,{form:o}),e[5]=o,e[6]=g):g=e[6];let p;e[7]!==f?(p=t.jsx(rl,{projectRef:f}),e[7]=f,e[8]=p):p=e[8];let x;e[9]!==f||e[10]!==i?(x=i?t.jsx(Ji,{projectRef:f}):null,e[9]=f,e[10]=i,e[11]=x):x=e[11];let d;return e[12]!==g||e[13]!==p||e[14]!==x?(d=t.jsxs("div",{className:"space-y-0",children:[g,p,x]}),e[12]=g,e[13]=p,e[14]=x,e[15]=d):d=e[15],d},hd=s=>{const e=Ge.c(20),{percent:n,tonePercent:r,className:a,expectedMarkerPercent:i}=s;let o;e[0]!==n?(o=Sa(n)??0,e[0]=n,e[1]=o):o=e[1];const u=o,f=r??n;let h;e[2]!==f?(h=Ca(f),e[2]=f,e[3]=h):h=e[3];const c=h,g=i!=null?Math.max(0,Math.min(100,i)):null;let p;e[4]!==c?(p=c==="critical"?{backgroundColor:"var(--status-error)"}:c==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"},e[4]=c,e[5]=p):p=e[5];const x=p;let d;e[6]!==a?(d=K("relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden",a),e[6]=a,e[7]=d):d=e[7];const y=`${u}%`;let v;e[8]!==x||e[9]!==y?(v={...x,width:y},e[8]=x,e[9]=y,e[10]=v):v=e[10];let C;e[11]!==u||e[12]!==v?(C=t.jsx("div",{className:"h-full transition-all duration-300",style:v,role:"progressbar","aria-valuenow":u,"aria-valuemin":0,"aria-valuemax":100}),e[11]=u,e[12]=v,e[13]=C):C=e[13];let I;e[14]!==g?(I=g!=null&&g>0&&g<100&&t.jsx("div",{className:"absolute top-0 h-full w-0.5 bg-foreground",style:{left:`${g}%`},title:`Expected usage if spread evenly: ${Math.round(g)}% of quota`,"aria-hidden":"true"}),e[14]=g,e[15]=I):I=e[15];let A;return e[16]!==d||e[17]!==C||e[18]!==I?(A=t.jsxs("div",{className:d,children:[C,I]}),e[16]=d,e[17]=C,e[18]=I,e[19]=A):A=e[19],A},pd=s=>{const e=Ge.c(67),{paceInfo:n,className:r,compact:a}=s,i=a===void 0?!1:a,{t:o}=nt();let u;e[0]!==n.status?(u=Ia(n.status),e[0]=n.status,e[1]=u):u=e[1];const f=u;let h;e:{switch(n.status){case"on-track":{let k;e[2]!==o?(k=o("settings.usage.pace.status.onTrack"),e[2]=o,e[3]=k):k=e[3],h=k;break e}case"slightly-fast":{let k;e[4]!==o?(k=o("settings.usage.pace.status.slightlyFast"),e[4]=o,e[5]=k):k=e[5],h=k;break e}case"too-fast":{let k;e[6]!==o?(k=o("settings.usage.pace.status.tooFast"),e[6]=o,e[7]=k):k=e[7],h=k;break e}case"exhausted":{let k;e[8]!==o?(k=o("settings.usage.pace.status.usedUp"),e[8]=o,e[9]=k):k=e[9],h=k;break e}}h=void 0}const c=h;let g;e[10]!==n.predictText||e[11]!==o?(g=o("settings.usage.pace.predictionTooltip",{prediction:n.predictText}),e[10]=n.predictText,e[11]=o,e[12]=g):g=e[12];const p=g;if(i){let k;e[13]!==r?(k=K("flex items-center gap-1.5",r),e[13]=r,e[14]=k):k=e[14];let M;e[15]!==f?(M={backgroundColor:f},e[15]=f,e[16]=M):M=e[16];let te;e[17]!==c||e[18]!==M?(te=t.jsx("div",{className:"h-2 w-2 rounded-full flex-shrink-0",style:M,title:c}),e[17]=c,e[18]=M,e[19]=te):te=e[19];let q;e[20]!==f?(q={color:f},e[20]=f,e[21]=q):q=e[21];const L=n.isExhausted?void 0:p;let W;e[22]!==n.isExhausted||e[23]!==n.predictText||e[24]!==n.remainingSeconds||e[25]!==o?(W=n.isExhausted?t.jsx(t.Fragment,{children:o("settings.usage.pace.wait",{duration:en(n.remainingSeconds)})}):t.jsx(t.Fragment,{children:o("settings.usage.pace.prediction",{prediction:n.predictText})}),e[22]=n.isExhausted,e[23]=n.predictText,e[24]=n.remainingSeconds,e[25]=o,e[26]=W):W=e[26];let O;e[27]!==W||e[28]!==q||e[29]!==L?(O=t.jsx("span",{className:"typography-micro tabular-nums",style:q,title:L,children:W}),e[27]=W,e[28]=q,e[29]=L,e[30]=O):O=e[30];let ne;return e[31]!==O||e[32]!==k||e[33]!==te?(ne=t.jsxs("div",{className:k,children:[te,O]}),e[31]=O,e[32]=k,e[33]=te,e[34]=ne):ne=e[34],ne}let x;e[35]!==r?(x=K("flex items-center justify-between gap-2",r),e[35]=r,e[36]=x):x=e[36];let d;e[37]!==n.isExhausted||e[38]!==n.paceRateText||e[39]!==o?(d=!n.isExhausted&&t.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.usage.pace.rate",{rate:n.paceRateText})}),e[37]=n.isExhausted,e[38]=n.paceRateText,e[39]=o,e[40]=d):d=e[40];let y;e[41]!==d?(y=t.jsx("div",{className:"flex items-center gap-1.5",children:d}),e[41]=d,e[42]=y):y=e[42];let v;e[43]!==f?(v={color:f},e[43]=f,e[44]=v):v=e[44];let C;e[45]!==n.isExhausted||e[46]!==n.predictText||e[47]!==n.remainingSeconds||e[48]!==p||e[49]!==c||e[50]!==o?(C=n.isExhausted?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-medium",children:c}),t.jsx("span",{className:"text-muted-foreground",children:o("settings.usage.pace.waitSeparator")}),t.jsx("span",{className:"font-medium",children:en(n.remainingSeconds)})]}):t.jsxs("span",{title:p,children:[t.jsx("span",{className:"text-muted-foreground",children:o("settings.usage.pace.predictionLabel")}),t.jsx("span",{className:"font-medium",children:n.predictText})]}),e[45]=n.isExhausted,e[46]=n.predictText,e[47]=n.remainingSeconds,e[48]=p,e[49]=c,e[50]=o,e[51]=C):C=e[51];let I;e[52]!==v||e[53]!==C?(I=t.jsx("span",{className:"typography-micro tabular-nums",style:v,children:C}),e[52]=v,e[53]=C,e[54]=I):I=e[54];let A;e[55]!==f?(A={backgroundColor:f},e[55]=f,e[56]=A):A=e[56];let V;e[57]!==c||e[58]!==A?(V=t.jsx("div",{className:"h-2 w-2 rounded-full flex-shrink-0",style:A,title:c}),e[57]=c,e[58]=A,e[59]=V):V=e[59];let w;e[60]!==I||e[61]!==V?(w=t.jsxs("div",{className:"flex items-center gap-1.5",children:[I,V]}),e[60]=I,e[61]=V,e[62]=w):w=e[62];let N;return e[63]!==w||e[64]!==x||e[65]!==y?(N=t.jsxs("div",{className:x,children:[y,w]}),e[63]=w,e[64]=x,e[65]=y,e[66]=N):N=e[66],N},xr=()=>{const s=Ta();return{displayMode:s,installed:s!=="browser",browserTab:s==="browser"}},gd=()=>{const s=Ge.c(2),[e,n]=l.useState(ul);let r,a;return s[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const i=[window.matchMedia("(display-mode: standalone)"),window.matchMedia("(display-mode: minimal-ui)"),window.matchMedia("(display-mode: fullscreen)"),window.matchMedia("(display-mode: window-controls-overlay)")],o=()=>{n(xr())};o();for(const u of i)typeof u.addEventListener=="function"?u.addEventListener("change",o):typeof u.addListener=="function"&&u.addListener(o);return window.addEventListener("appinstalled",o),window.addEventListener("focus",o),()=>{for(const u of i)typeof u.removeEventListener=="function"?u.removeEventListener("change",o):typeof u.removeListener=="function"&&u.removeListener(o);window.removeEventListener("appinstalled",o),window.removeEventListener("focus",o)}},a=[],s[0]=r,s[1]=a):(r=s[0],a=s[1]),l.useEffect(r,a),e};function ul(){return xr()}const ml=[{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","github","identity","identities","ssh","profiles","credentials","keys","commit","gitmoji","oauth","prs","issues"],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}],fl={sessions:"sessions",agents:"agents",commands:"commands",mcp:"mcp",skills:"skills.installed",providers:"providers",usage:"usage","git-identities":"git",settings:"home"};function hl(s){const e=s.trim().toLowerCase();return ml.find(n=>n.slug===e)??null}function pl(s){const e=(s??"").trim().toLowerCase();if(!e)return"home";const n=fl[e];if(n)return n;const r=hl(e);return r?r.slug:"home"}function xd(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"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 gl=["chat","git","diff","terminal","files","diagram"],xl=["settings","agents","commands","skills","providers","usage","git-identities"],xt={SESSION:"session",TAB:"tab",SETTINGS:"settings",FILE:"file"};function Cn(s){const e=bl();return{sessionId:yl(e),tab:wl(e),settingsPath:vl(e),diffFile:kl(e)}}function bl(){if(typeof window>"u")return new URLSearchParams;try{return new URLSearchParams(window.location.search)}catch{return new URLSearchParams}}function yl(s){const e=s.get(xt.SESSION);return!e||e.trim().length===0?null:e.trim()}function wl(s){const e=s.get(xt.TAB);if(!e)return null;const n=e.toLowerCase().trim();return gl.includes(n)?n:null}function vl(s){const e=s.get(xt.SETTINGS);if(!e)return null;const n=e.toLowerCase().trim();return n.length===0?null:n==="openchamber"||n==="general"||n==="preferences"?"home":(xl.includes(n),n)}function kl(s){const e=s.get(xt.FILE);if(!e||e.trim().length===0)return null;try{return decodeURIComponent(e.trim())}catch{return e.trim()}}function In(){if(typeof window>"u")return!1;try{const s=new URLSearchParams(window.location.search);return s.has(xt.SESSION)||s.has(xt.TAB)||s.has(xt.SETTINGS)||s.has(xt.FILE)}catch{return!1}}const jl="chat";function br(s){const e=new URLSearchParams;if(s.sessionId&&s.sessionId.trim().length>0&&e.set(xt.SESSION,s.sessionId),s.isSettingsOpen){const n=s.settingsPath.trim().length>0?s.settingsPath:"home";return e.set(xt.SETTINGS,n),e}return s.tab!==jl&&e.set(xt.TAB,s.tab),s.tab==="diff"&&s.diffFile&&s.diffFile.trim().length>0&&e.set(xt.FILE,s.diffFile),e}function Nl(s,e){const n=typeof window<"u"?window.location.pathname:"/",r=s.toString();return r?`${n}?${r}`:n}function Sl(s){if(typeof window>"u")return!0;try{const e=new URLSearchParams(window.location.search),n=br(s),r=[...e.entries()].sort((i,o)=>i[0].localeCompare(o[0])),a=[...n.entries()].sort((i,o)=>i[0].localeCompare(o[0]));if(r.length!==a.length)return!1;for(let i=0;i<r.length;i++)if(r[i][0]!==a[i][0]||r[i][1]!==a[i][1])return!1;return!0}catch{return!0}}function Tn(s,e={}){if(!(typeof window>"u")&&!(Cl()||sr())&&!(!e.force&&Sl(s)))try{const n=br(s),r=Nl(n);e.replace?window.history.replaceState({...window.history.state,route:s},"",r):window.history.pushState({route:s},"",r)}catch{}}function Cl(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function Il(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function bd(){const s=l.useMemo(()=>Il(),[]),e=l.useMemo(()=>sr(),[]),n=l.useRef(!1),r=l.useRef(!1),a=rt(p=>p.setCurrentSession),i=Ae(p=>p.setActiveMainTab),o=Ae(p=>p.setSettingsDialogOpen),u=Ae(p=>p.setSettingsPage),f=Ae(p=>p.navigateToDiff),h=l.useCallback(async p=>{if(!r.current){r.current=!0;try{if(p.sessionId){const x=rt.getState().currentSessionId;if(p.sessionId!==x){const d=rt.getState().getDirectoryForSession(p.sessionId);a(p.sessionId,d)}}if(p.settingsPath){u(pl(p.settingsPath)),o(!0);return}Ae.getState().isSettingsDialogOpen&&o(!1),p.tab&&i(p.tab),p.diffFile&&(p.tab==="diff"||!p.tab)&&f(p.diffFile)}finally{r.current=!1}}},[a,i,o,u,f]),c=l.useCallback(()=>{const p=rt.getState(),x=Ae.getState();return{sessionId:p.currentSessionId,tab:x.activeMainTab,isSettingsOpen:x.isSettingsDialogOpen,settingsPath:x.settingsPage,diffFile:x.pendingDiffFile}},[]),g=l.useCallback((p={})=>{if(s||e||r.current)return;const x=c();Tn(x,p)},[s,e,c]);l.useEffect(()=>{if(n.current||(n.current=!0,!In()))return;const p=Cn();(async()=>(await h(p),!s&&!e&&Tn({...c(),sessionId:p.sessionId??rt.getState().currentSessionId,tab:p.tab??Ae.getState().activeMainTab,settingsPath:p.settingsPath??Ae.getState().settingsPage,diffFile:p.diffFile??Ae.getState().pendingDiffFile},{replace:!0,force:!0})))()},[h,c,s,e]),l.useEffect(()=>{if(s||e)return;let p=rt.getState().currentSessionId;return rt.subscribe(d=>{const y=d.currentSessionId;y===p||r.current||(p=y,g())})},[s,e,g]),l.useEffect(()=>{if(s||e)return;let p=Ae.getState().activeMainTab,x=Ae.getState().isSettingsDialogOpen,d=Ae.getState().settingsPage,y=Ae.getState().pendingDiffFile;return Ae.subscribe(C=>{if(r.current)return;const I=C.activeMainTab!==p,A=C.isSettingsDialogOpen!==x,V=C.settingsPage!==d,w=C.pendingDiffFile!==y&&C.activeMainTab==="diff";p=C.activeMainTab,x=C.isSettingsDialogOpen,d=C.settingsPage,y=C.pendingDiffFile,(I||A||V||w)&&g()})},[s,e,g]),l.useEffect(()=>{if(typeof window>"u"||s||e)return;const p=()=>{const x=Cn();if(In())h(x);else{const d=Ae.getState();d.isSettingsDialogOpen&&o(!1),d.activeMainTab!=="chat"&&i("chat")}};return window.addEventListener("popstate",p),()=>{window.removeEventListener("popstate",p)}},[h,s,e,i,o])}function yd(){const s=Ge.c(5),e=ni(Pl),n=l.useRef(e);let r,a;s[0]!==e?(r=()=>{n.current=e},a=[e],s[0]=e,s[1]=r,s[2]=a):(r=s[1],a=s[2]),l.useEffect(r,a);let i,o;s[3]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{let u=!1,f=null;const h=Tl,c=g=>{u||(f=window.setTimeout(async()=>{const p=await n.current(),x=typeof p=="number"&&Number.isFinite(p)?h(p):36e5;c(x)},g))};return c(3e3),()=>{u=!0,f!==null&&window.clearTimeout(f)}},o=[],s[3]=i,s[4]=o):(i=s[3],o=s[4]),l.useEffect(i,o)}function Tl(s){const e=Math.round(s*1e3);return Math.max(3e5,Math.min(864e5,e))}function Pl(s){return s.checkForUpdates}const $s=1e3,Kt=60*$s,ks=60*Kt,Dl=(s,e)=>{const n=Math.max(0,s);return n<Kt?e("common.duration.secondsCompact",{seconds:Math.floor(n/$s)}):n<ks?e("common.duration.minutesSecondsCompact",{minutes:Math.floor(n/Kt),seconds:Math.floor(n%Kt/$s)}):e("common.duration.hoursMinutesCompact",{hours:Math.floor(n/ks),minutes:Math.floor(n%ks/Kt)})},El=1e3,wd=s=>{const e=Ge.c(12),{sessionId:n,running:r,className:a}=s,{t:i}=nt(),o=Pa(n),u=Da(n),f=Ea(r,El),h=r?Math.max(0,f-(o??f)):u;if(h===void 0)return null;let c,g;e[0]!==h||e[1]!==r||e[2]!==i?(c=Dl(h,i),g=r?i("sessions.sidebar.session.status.activeFor",{duration:c}):i("sessions.sidebar.session.status.lastTurnDuration",{duration:c}),e[0]=h,e[1]=r,e[2]=i,e[3]=c,e[4]=g):(c=e[3],g=e[4]);const p=g,x=r?"text-primary":"text-[var(--status-info)]";let d;e[5]!==a||e[6]!==x?(d=K("shrink-0 tabular-nums",x,a),e[5]=a,e[6]=x,e[7]=d):d=e[7];let y;return e[8]!==p||e[9]!==c||e[10]!==d?(y=t.jsx("span",{className:d,"aria-label":p,title:p,children:c}),e[8]=p,e[9]=c,e[10]=d,e[11]=y):y=e[11],y},Rl=()=>{const s=Ge.c(14),[e,n]=Q.useState(!1),[r,a]=Q.useState(!1);let i,o;s[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{n(Xn()),a(yo())},o=[],s[0]=i,s[1]=o):(i=s[0],o=s[1]),Q.useEffect(i,o);let u;s[2]!==e?(u=async d=>e?await wo(d):{success:!0,path:d},s[2]=e,s[3]=u):u=s[3];const f=u;let h;s[4]!==e?(h=async d=>e?await vo():{success:!0},s[4]=e,s[5]=h):h=s[5];const c=h;let g;s[6]!==e?(g=async d=>e?await ko():{success:!0},s[6]=e,s[7]=g):g=s[7];const p=g;let x;return s[8]!==r||s[9]!==e||s[10]!==f||s[11]!==c||s[12]!==p?(x={isDesktop:e,canRequestAccess:r,requestAccess:f,startAccessing:c,stopAccessing:p},s[8]=r,s[9]=e,s[10]=f,s[11]=c,s[12]=p,s[13]=x):x=s[13],x},Al=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),Bl=({currentBranch:s,localBranches:e,remoteBranches:n,branchInfo:r,onCheckout:a,onCreate:i,remotes:o=[],disabled:u=!1})=>{const{t:f}=nt(),[h,c]=l.useState(!1),[g,p]=l.useState(""),[x,d]=l.useState(!1),[y,v]=l.useState(!1),[C,I]=l.useState(""),[A,V]=l.useState(!1),w=l.useRef(null),N=l.useCallback(G=>{G.stopPropagation()},[]),k=o.length>1,M=l.useMemo(()=>Al(C),[C]),te=l.useMemo(()=>{const G=g.toLowerCase();return G?e.filter(U=>U.toLowerCase().includes(G)):e},[g,e]),q=l.useMemo(()=>{const G=g.toLowerCase();return G?n.filter(U=>U.toLowerCase().includes(G)):n},[g,n]),L=G=>{if(G===s){c(!1);return}a(G),c(!1),p("")},W=()=>{d(!0),setTimeout(()=>w.current?.focus(),50)},O=async()=>{if(!(!M||A)){if(k){v(!0);return}V(!0);try{await i(M,o[0]),I(""),d(!1),c(!1)}finally{V(!1)}}},ne=async G=>{if(!(!M||A)){V(!0);try{await i(M,G),I(""),d(!1),v(!1),c(!1)}finally{V(!1)}}},z=()=>{v(!1)},de=()=>{I(""),d(!1),v(!1)};return l.useEffect(()=>{h||(p(""),d(!1),v(!1),I(""))},[h]),t.jsxs(Pt,{open:h,onOpenChange:c,children:[t.jsxs(Mt,{children:[t.jsx(Lt,{asChild:!0,children:t.jsx(Dt,{asChild:!0,children:t.jsxs(Ne,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:u,children:[t.jsx(P,{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(P,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),t.jsx(Ft,{sideOffset:8,children:f("gitView.branch.currentBranchTooltip")})]}),t.jsx(Et,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:t.jsxs(Ms,{className:"h-full min-h-0",children:[t.jsx(Ls,{placeholder:f("gitView.branch.searchPlaceholder"),value:g,onValueChange:p,onKeyDown:N}),t.jsxs(Fs,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(Os,{children:f("gitView.branch.empty")}),t.jsx(Ct,{children:y?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:z,disabled:A,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(P,{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:M})," ",f("gitView.branch.pushToSuffix")]})]}),t.jsx("div",{className:"flex flex-col gap-1",children:o.map(G=>t.jsxs("button",{type:"button",onClick:()=>ne(G),disabled:A,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:[A?t.jsx(P,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,G.name]}),t.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:G.pushUrl})]},G.name))})]}):x?t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[t.jsx("input",{ref:w,placeholder:f("gitView.branch.newBranchPlaceholder"),value:C,onChange:G=>I(G.target.value),onClick:G=>G.stopPropagation(),onKeyDown:G=>{N(G),G.key==="Enter"?(G.preventDefault(),O()):G.key==="Escape"&&(G.preventDefault(),de())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:O,disabled:!M||A,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:A?t.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(P,{name:"add",className:"size-4"})}),t.jsx("button",{type:"button",onClick:de,disabled:A,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(P,{name:"close",className:"size-4"})})]}):t.jsxs(yt,{onSelect:W,children:[t.jsx(P,{name:"add",className:"size-4"}),t.jsx("span",{children:f("gitView.branch.create")})]})}),t.jsx($t,{}),t.jsxs(Ct,{heading:f("gitView.branch.localBranches"),children:[te.map(G=>t.jsxs(yt,{onSelect:()=>L(G),children:[t.jsxs("span",{className:"flex flex-1 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:G}),(r?.[G]?.ahead||r?.[G]?.behind)&&t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[r[G].ahead||0," ahead ·"," ",r[G].behind||0," behind"]})]}),s===G&&t.jsx("span",{className:"typography-micro text-primary",children:f("gitView.branch.currentBadge")})]},`local-${G}`)),te.length===0&&t.jsx(yt,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:f("gitView.branch.noLocalBranches")})})]}),t.jsx($t,{}),t.jsxs(Ct,{heading:f("gitView.branch.remoteBranches"),children:[q.map(G=>t.jsx(yt,{onSelect:()=>L(G),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:G})},`remote-${G}`)),q.length===0&&t.jsx(yt,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:f("gitView.branch.noRemoteBranches")})})]})]})]})})]})},Ml=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),Ll=({currentBranch:s,onRename:e,showEditButton:n=!0})=>{const{t:r}=nt(),[a,i]=l.useState(!1),[o,u]=l.useState(s||""),[f,h]=l.useState(!1),c=l.useRef(null),g=()=>{!s||!e||(u(s),i(!0),setTimeout(()=>c.current?.focus(),0))},p=async()=>{if(!s||!e||!o.trim())return;const y=Ml(o);if(y===s){i(!1);return}h(!0);try{await e(s,y),i(!1),u("")}finally{h(!1)}},x=()=>{i(!1),u("")},d=y=>{y.key==="Enter"?(y.preventDefault(),p()):y.key==="Escape"&&(y.preventDefault(),x())};return a?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:y=>{y.preventDefault(),p()},children:[t.jsx(P,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("input",{ref:c,value:o,onChange:y=>u(y.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:d,autoFocus:!0}),t.jsx("button",{type:"submit",disabled:f,"aria-label":r(f?"gitView.branch.renameSaving":"gitView.branch.renameSave"),title:r(f?"gitView.branch.renameSaving":"gitView.branch.renameSave"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:f?t.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(P,{name:"check",className:"size-4"})}),t.jsx("button",{type:"button",onClick:x,disabled:f,"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(P,{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(P,{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(Ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:g,title:r("gitView.branch.renameTitle"),children:t.jsx(P,{name:"edit",className:"size-4"})})]})]})},Fl=s=>{const e=Ge.c(44),{syncAction:n,remotes:r,onFetch:a,onSync:i,onRemoveRemote:o,disabled:u,removingRemoteName:f,aheadCount:h,behindCount:c,trackingRemoteName:g,hasUncommittedChanges:p}=s,x=r===void 0?[]:r,d=f===void 0?null:f,y=h===void 0?0:h,v=c===void 0?0:c,C=p===void 0?!1:p,{t:I}=nt(),A=l.useRef(!1),V=!!d,w=x.find(me=>me.name===g)??x[0],N=v>0&&C,k=u||n!==null||V||!w||N,M=u||n!==null||V||x.length===0,te=y>0||v>0;let q;e[0]!==I?(q=I("gitView.sync.sync"),e[0]=I,e[1]=q):q=e[1];const L=v>0?`↓${v}`:null,W=y>0?`↑${y}`:null;let O;e[2]!==q||e[3]!==L||e[4]!==W?(O=[q,L,W].filter(Boolean),e[2]=q,e[3]=L,e[4]=W,e[5]=O):O=e[5];const ne=O.join(" "),z=N?I("gitView.sync.commitOrStashTooltip"):w?te?I("gitView.sync.syncChangesTooltip",{ahead:y,behind:v}):I("gitView.sync.syncChanges"):I("gitView.sync.noRemoteTooltip"),de=()=>{w&&i(w)},G="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",U=N?0:void 0;let R;e[6]===Symbol.for("react.memo_cache_sentinel")?(R=K("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]=R):R=e[6];let B;e[7]!==I?(B=I("gitView.sync.syncChanges"),e[7]=I,e[8]=B):B=e[8];let $;e[9]!==n?($=n==="sync"?t.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(P,{name:"refresh",className:"size-4"}),e[9]=n,e[10]=$):$=e[10];let H;e[11]!==ne?(H=t.jsx("span",{className:"whitespace-nowrap tabular-nums",children:ne}),e[11]=ne,e[12]=H):H=e[12];let E;e[13]!==de||e[14]!==k||e[15]!==B||e[16]!==$||e[17]!==H?(E=t.jsxs("button",{type:"button",onClick:de,disabled:k,className:R,"aria-label":B,children:[$,H]}),e[13]=de,e[14]=k,e[15]=B,e[16]=$,e[17]=H,e[18]=E):E=e[18];let re;e[19]!==U||e[20]!==E?(re=t.jsx(Lt,{asChild:!0,children:t.jsx("span",{className:"inline-flex",tabIndex:U,children:E})}),e[19]=U,e[20]=E,e[21]=re):re=e[21];let ue;e[22]!==z?(ue=t.jsx(Ft,{sideOffset:8,children:z}),e[22]=z,e[23]=ue):ue=e[23];let he;e[24]!==re||e[25]!==ue?(he=t.jsxs(Mt,{children:[re,ue]}),e[24]=re,e[25]=ue,e[26]=he):he=e[26];const Ce=Pt;let ke;e[27]===Symbol.for("react.memo_cache_sentinel")?(ke=K("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]=ke):ke=e[27];let J;e[28]!==I?(J=I("gitView.sync.moreActionsAria"),e[28]=I,e[29]=J):J=e[29];let be;e[30]===Symbol.for("react.memo_cache_sentinel")?(be=t.jsx(P,{name:"arrow-down-s",className:"size-4"}),e[30]=be):be=e[30];let _;e[31]!==M||e[32]!==J?(_=t.jsx(Dt,{asChild:!0,children:t.jsx("button",{type:"button",className:ke,disabled:M,"aria-label":J,children:be})}),e[31]=M,e[32]=J,e[33]=_):_=e[33];const le=Et,Y="start",ae=-40,ce="w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",pe=x.map(me=>t.jsx(jt,{onSelect:se=>{if(A.current){se.preventDefault(),A.current=!1;return}a(me)},children:t.jsxs("div",{className:"flex w-full items-center gap-2",children:[t.jsx(P,{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:I("gitView.sync.fetchFromRemote",{name:me.name})}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:me.fetchUrl})]})}),o&&me.name!==g?t.jsx(Ne,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:n!==null||V,onPointerDown:se=>{A.current=!0,se.preventDefault(),se.stopPropagation()},onClick:se=>{A.current=!0,se.preventDefault(),se.stopPropagation(),o(me)},"aria-label":I("gitView.header.removeRemoteAria",{name:me.name}),title:I("gitView.header.removeRemoteTitle",{name:me.name}),children:d===me.name?t.jsx(P,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(P,{name:"close",className:"size-3.5"})}):null]})},me.name));let D;e[34]!==le||e[35]!==pe?(D=t.jsx(le,{align:Y,alignOffset:ae,className:ce,children:pe}),e[34]=le,e[35]=pe,e[36]=D):D=e[36];let F;e[37]!==Ce||e[38]!==_||e[39]!==D?(F=t.jsxs(Ce,{children:[_,D]}),e[37]=Ce,e[38]=_,e[39]=D,e[40]=F):F=e[40];let X;return e[41]!==he||e[42]!==F?(X=t.jsxs("div",{className:G,children:[he,F]}),e[41]=he,e[42]=F,e[43]=X):X=e[43],X},Ol={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",user:"user-3",fingerprint:"fingerprint"},Ul={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 yr(s){return s&&Ul[s]||"var(--primary)"}const Pn=s=>{const e=Ge.c(8),{icon:n,className:r,colorToken:a}=s,i=Ol[n??"branch"]??"user-3";let o;e[0]!==a?(o=yr(a),e[0]=a,e[1]=o):o=e[1];let u;e[2]!==o?(u={color:o},e[2]=o,e[3]=u):u=e[3];let f;return e[4]!==r||e[5]!==i||e[6]!==u?(f=t.jsx(P,{name:i,className:r,style:u}),e[4]=r,e[5]=i,e[6]=u,e[7]=f):f=e[7],f},wr=s=>{const e=Ge.c(35),{activeProfile:n,identities:r,onSelect:a,isApplying:i,iconOnly:o}=s,u=o===void 0?!1:o,{t:f}=nt(),h=i||r.length===0,c=n?.color;let g;e[0]!==c?(g=yr(c),e[0]=c,e[1]=g):g=e[1];let p;e[2]!==g?(p={color:g},e[2]=g,e[3]=p):p=e[3];let x;e[4]!==n?.color||e[5]!==n?.icon||e[6]!==i?(x=i?t.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(Pn,{icon:n?.icon,colorToken:n?.color,className:"size-4"}),e[4]=n?.color,e[5]=n?.icon,e[6]=i,e[7]=x):x=e[7];let d;e[8]!==n?.name||e[9]!==u||e[10]!==f?(d=!u&&t.jsx("span",{className:"git-identity-label min-w-0 flex-1 truncate text-left",children:n?.name||f("gitView.header.noIdentity")}),e[8]=n?.name,e[9]=u,e[10]=f,e[11]=d):d=e[11];let y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(P,{name:"arrow-down-s",className:"size-4 opacity-60"}),e[12]=y):y=e[12];let v;e[13]!==h||e[14]!==p||e[15]!==x||e[16]!==d?(v=t.jsx(Lt,{asChild:!0,children:t.jsx(Dt,{asChild:!0,children:t.jsxs(Ne,{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:p,disabled:h,children:[x,d,y]})})}),e[13]=h,e[14]=p,e[15]=x,e[16]=d,e[17]=v):v=e[17];let C;e[18]!==f?(C=f("gitView.header.identityTooltip"),e[18]=f,e[19]=C):C=e[19];let I;e[20]!==C?(I=t.jsx(Ft,{sideOffset:8,children:C}),e[20]=C,e[21]=I):I=e[21];let A;e[22]!==I||e[23]!==v?(A=t.jsxs(Mt,{children:[v,I]}),e[22]=I,e[23]=v,e[24]=A):A=e[24];let V;e[25]!==n?.id||e[26]!==r||e[27]!==a||e[28]!==f?(V=r.length===0?t.jsx("div",{className:"px-2 py-1.5",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:f("gitView.header.noProfiles")})}):r.map(k=>{const M=n?.id===k.id;return t.jsx(jt,{onSelect:()=>a(k),children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Pn,{icon:k.icon,colorToken:k.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:k.name}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:k.userEmail})]}),M?t.jsx(P,{name:"check",className:"ml-auto size-4 text-foreground"}):null]})},k.id)}),e[25]=n?.id,e[26]=r,e[27]=a,e[28]=f,e[29]=V):V=e[29];let w;e[30]!==V?(w=t.jsx(Et,{align:"end",className:"w-64",children:V}),e[30]=V,e[31]=w):w=e[31];let N;return e[32]!==A||e[33]!==w?(N=t.jsxs(Pt,{children:[A,w]}),e[32]=A,e[33]=w,e[34]=N):N=e[34],N},Wl=s=>{const e=Ge.c(21),{comparison:n,trackingBranch:r,tooltipDelayMs:a}=s,i=a===void 0?1e3:a,{t:o}=nt(),u=`${n.remote}/${n.branch}`,f=n.ahead===0&&n.behind===0;let h;e[0]!==o||e[1]!==u||e[2]!==r?(h=r?o("gitView.header.upstreamTooltipTracking",{target:u,tracking:r}):o("gitView.header.upstreamTooltip",{target:u}),e[0]=o,e[1]=u,e[2]=r,e[3]=h):h=e[3];const c=h;let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(P,{name:"git-branch",className:"size-3.5 shrink-0"}),e[4]=g):g=e[4];let p;e[5]!==u?(p=t.jsx("span",{className:"min-w-0 truncate text-foreground/80",children:u}),e[5]=u,e[6]=p):p=e[6];let x;e[7]!==n.ahead||e[8]!==n.behind||e[9]!==f||e[10]!==o?(x=f?t.jsx("span",{className:"tabular-nums text-muted-foreground",children:o("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]=f,e[10]=o,e[11]=x):x=e[11];let d;e[12]!==p||e[13]!==x?(d=t.jsx(Lt,{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:[g,p,x]})}),e[12]=p,e[13]=x,e[14]=d):d=e[14];let y;e[15]!==c?(y=t.jsx(Ft,{sideOffset:8,children:c}),e[15]=c,e[16]=y):y=e[16];let v;return e[17]!==d||e[18]!==y||e[19]!==i?(v=t.jsxs(Mt,{delayDuration:i,children:[d,y]}),e[17]=d,e[18]=y,e[19]=i,e[20]=v):v=e[20],v},vd=s=>{const e=Ge.c(67),{status:n,localBranches:r,remoteBranches:a,branchInfo:i,syncAction:o,remotes:u,onFetch:f,onSync:h,onRemoveRemote:c,removingRemoteName:g,onCheckoutBranch:p,onCreateBranch:x,onRenameBranch:d,activeIdentityProfile:y,availableIdentities:v,onSelectIdentity:C,isApplyingIdentity:I,isWorktreeMode:A,onOpenHistory:V,onOpenGraph:w,onOpenStashes:N,onOpenUpdateBranch:k,onOpenReintegrateCommits:M,pullRequest:te,prChecks:q,onOpenPullRequest:L}=s,{t:W}=nt();if(!n)return null;let O;e[0]!==w||e[1]!==V||e[2]!==M||e[3]!==N||e[4]!==k||e[5]!==W?(O=V||w||N||k?t.jsxs(Pt,{children:[t.jsxs(Mt,{children:[t.jsx(Lt,{asChild:!0,children:t.jsx(Dt,{asChild:!0,children:t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":W("gitView.header.repositoryViews"),children:t.jsx(P,{name:"more-fill",className:"size-4"})})})}),t.jsx(Ft,{sideOffset:8,children:W("gitView.header.repositoryViews")})]}),t.jsxs(Et,{align:"end",children:[V?t.jsxs(jt,{onSelect:V,children:[t.jsx(P,{name:"history",className:"size-4"}),W("gitView.history.title")]}):null,w?t.jsxs(jt,{onSelect:w,children:[t.jsx(P,{name:"git-branch",className:"size-4"}),W("gitView.graph.title")]}):null,N?t.jsxs(jt,{onSelect:N,children:[t.jsx(P,{name:"archive-stack",className:"size-4"}),W("gitView.stashes.title")]}):null,k?t.jsxs(jt,{onSelect:k,children:[t.jsx(P,{name:"git-merge",className:"size-4"}),W("gitView.header.updateBranch")]}):null,M?t.jsxs(jt,{onSelect:M,children:[t.jsx(P,{name:"split-cells-horizontal",className:"size-4"}),W("gitView.integrate.title")]}):null]})]}):null,e[0]=w,e[1]=V,e[2]=M,e[3]=N,e[4]=k,e[5]=W,e[6]=O):O=e[6];let ne;e[7]!==O?(ne=t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:O}),e[7]=O,e[8]=ne):ne=e[8];const z=ne,de=q?q.state==="success"?"var(--status-success)":q.state==="failure"?"var(--status-error)":"var(--status-warning)":null,G=te?te.state==="merged"?"merged":te.state==="closed"?"closed":te.draft?"draft":q?.state==="failure"||te.mergeable===!1||te.mergeableState==="blocked"||te.mergeableState==="dirty"?"blocked":"open":null;let U;e[9]!==L||e[10]!==de||e[11]!==G||e[12]!==te||e[13]!==W?(U=te&&L?t.jsxs(Mt,{children:[t.jsx(Lt,{asChild:!0,children:t.jsxs(Ne,{variant:"ghost",size:"sm",onClick:L,className:"h-8 gap-1.5 px-2 typography-micro",children:[t.jsx(P,{name:"git-pull-request",className:"size-3.5",style:{color:`var(--pr-${G})`}}),t.jsx("span",{className:"tabular-nums text-foreground/80",children:W("gitView.pr.numberLabel",{number:te.number})}),de?t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:de}}):null]})}),t.jsx(Ft,{sideOffset:8,children:W("gitView.header.openPullRequest")})]}):null,e[9]=L,e[10]=de,e[11]=G,e[12]=te,e[13]=W,e[14]=U):U=e[14];const R=U,B=!n;let $;e[15]!==n.tracking?($=n.tracking?.split("/")[0],e[15]=n.tracking,e[16]=$):$=e[16];const H=(n.files?.length??0)>0;let E;e[17]!==f||e[18]!==c||e[19]!==h||e[20]!==u||e[21]!==g||e[22]!==n.ahead||e[23]!==n.behind||e[24]!==o||e[25]!==B||e[26]!==$||e[27]!==H?(E=t.jsx(Fl,{syncAction:o,remotes:u,onFetch:f,onSync:h,onRemoveRemote:c,removingRemoteName:g,disabled:B,iconOnly:!0,aheadCount:n.ahead,behindCount:n.behind,trackingRemoteName:$,hasUncommittedChanges:H}),e[17]=f,e[18]=c,e[19]=h,e[20]=u,e[21]=g,e[22]=n.ahead,e[23]=n.behind,e[24]=o,e[25]=B,e[26]=$,e[27]=H,e[28]=E):E=e[28];const re=E;let ue;e[29]!==n.tracking||e[30]!==n.upstreamComparison?(ue=n.upstreamComparison?t.jsx(Wl,{comparison:n.upstreamComparison,trackingBranch:n.tracking,tooltipDelayMs:1e3}):null,e[29]=n.tracking,e[30]=n.upstreamComparison,e[31]=ue):ue=e[31];const he=ue;let Ce;e[32]!==y||e[33]!==v||e[34]!==I||e[35]!==C?(Ce=t.jsx(wr,{activeProfile:y,identities:v,onSelect:C,isApplying:I,iconOnly:!0}),e[32]=y,e[33]=v,e[34]=I,e[35]=C,e[36]=Ce):Ce=e[36];const ke=Ce;let J;e[37]!==i||e[38]!==A||e[39]!==r||e[40]!==p||e[41]!==x||e[42]!==d||e[43]!==a||e[44]!==u||e[45]!==n.current?(J=t.jsx("div",{className:"min-w-0 flex-1",children:A?t.jsx(Ll,{currentBranch:n.current,onRename:d}):t.jsx(Bl,{currentBranch:n.current,localBranches:r,remoteBranches:a,branchInfo:i,onCheckout:p,onCreate:x,remotes:u})}),e[37]=i,e[38]=A,e[39]=r,e[40]=p,e[41]=x,e[42]=d,e[43]=a,e[44]=u,e[45]=n.current,e[46]=J):J=e[46];let be;e[47]!==ke?(be=t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:ke}),e[47]=ke,e[48]=be):be=e[48];let _;e[49]!==J||e[50]!==be?(_=t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[J,be]}),e[49]=J,e[50]=be,e[51]=_):_=e[51];let le;e[52]!==R?(le=R?t.jsx("div",{className:"shrink-0",children:R}):null,e[52]=R,e[53]=le):le=e[53];let Y;e[54]===Symbol.for("react.memo_cache_sentinel")?(Y=t.jsx("div",{className:"min-w-0 flex-1"}),e[54]=Y):Y=e[54];let ae;e[55]!==he?(ae=he?t.jsx("div",{className:"min-w-0 shrink",children:he}):null,e[55]=he,e[56]=ae):ae=e[56];let ce;e[57]!==re?(ce=t.jsx("div",{className:"shrink-0",children:re}),e[57]=re,e[58]=ce):ce=e[58];let pe;e[59]!==z||e[60]!==le||e[61]!==ae||e[62]!==ce?(pe=t.jsxs("div",{className:"mt-3 flex h-8 min-w-0 items-center gap-2",children:[le,Y,ae,z,ce]}),e[59]=z,e[60]=le,e[61]=ae,e[62]=ce,e[63]=pe):pe=e[63];let D;return e[64]!==_||e[65]!==pe?(D=t.jsxs("header",{className:"@container/git-header px-3 py-2 bg-transparent",children:[_,pe]}),e[64]=_,e[65]=pe,e[66]=D):D=e[66],D},$l=s=>s==="/",ps=s=>s.replace(/\\/g,"/"),Ks=s=>{if(!s||$l(s))return s;let e=s;for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e},Gt=s=>s.endsWith("/"),zl=s=>{const e=s.trim();return!e||Gt(e)?e:`${e}/`},qs=s=>s.lastIndexOf("/"),vr=s=>{if(Gt(s))return s;const e=qs(s);return e<0?s:s.slice(0,e+1)},Vl=s=>{const e=qs(s);return s.slice(e+1)},kr=s=>{const e=Ks(s.trim());if(!e||e==="~"||e==="~/"||e==="/")return null;const n=qs(e);return n<0?null:e.startsWith("~/")&&n<=1?"~/":n===0?"/":`${e.slice(0,n)}/`},_l=s=>Gt(s)&&kr(s)!==null,Gl=(s,e)=>`${vr(s)}${e}/`,At=s=>{if(!s)return null;const e=Ks(ps(s.trim()));return e?e.toLowerCase():null},Dn=(s,e)=>{const n=s.trim();return n==="~"?e:n.startsWith("~/")?`${e}${n.slice(1)}`:n},Hl=s=>typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?s.metaKey&&!s.ctrlKey:s.ctrlKey&&!s.metaKey,js=s=>{if(!s)return;s.focus({preventScroll:!0});const e=s.value.length;s.setSelectionRange(e,e),s.scrollLeft=s.scrollWidth},Kl=async()=>{try{const s=await Nt("/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 ps(e.home.trim())}}catch{}return _t.getFilesystemHome().catch(()=>null)},kd=({open:s,onOpenChange:e})=>{const{t:n}=nt(),r=ns(S=>S.homeDirectory),a=gt(S=>S.projects),i=gt(S=>S.addProject),o=Ae(S=>S.setActiveMainTab),u=Ae(S=>S.setSessionSwitcherOpen),f=rt(S=>S.openNewSessionDraft),h=Bt(S=>S.profiles),c=Bt(S=>S.globalIdentity),g=Bt(S=>S.defaultGitIdentityId),p=Bt(S=>S.loadProfiles),x=Bt(S=>S.loadGlobalIdentity),d=Bt(S=>S.loadDefaultGitIdentityId),{canRequestAccess:y,requestAccess:v,startAccessing:C}=Rl(),{isMobile:I}=xs(),A=l.useRef(null),V=l.useRef(null),w=l.useRef(new Map),[N,k]=l.useState(""),[M,te]=l.useState("~/"),[q,L]=l.useState([]),[W,O]=l.useState(!1),[ne,z]=l.useState(!1),[de,G]=l.useState(null),[U,R]=l.useState(0),[B,$]=l.useState(0),[H,E]=l.useState(!1),[re,ue]=l.useState(!1),[he,Ce]=l.useState(0),[ke,J]=l.useState(!1),[be,_]=l.useState(""),[le,Y]=l.useState(null),[ae,ce]=l.useState(!1),pe=N||r,D=l.useMemo(()=>new Set(a.map(S=>At(S.path)).filter(S=>!!S)),[a]);l.useEffect(()=>{if(!s)return;te("~/"),L([]),$(0),E(!1),ue(!1),J(!1),_(""),Y(null),ce(!1),requestAnimationFrame(()=>js(A.current));let S=!1;return(async()=>{const Ie=await Kl();S||(k(Ie||r||""),requestAnimationFrame(()=>js(A.current)))})(),()=>{S=!0}},[r,s]),l.useEffect(()=>{s&&(p(),x(),d())},[d,p,x,s]);const F=l.useMemo(()=>{const S=new Map;c&&S.set(c.id,c);for(const we of h)S.set(we.id,we);return Array.from(S.values())},[h,c]);l.useEffect(()=>{if(!s||!ke||le!==null)return;const S=typeof g=="string"?g.trim():"";if(S&&F.some(Ie=>Ie.id===S)){Y(S);return}const we=F.find(Ie=>Ie.authType==="ssh"||Ie.sshKey);we&&Y(we.id)},[F,g,ke,s,le]);const X=l.useMemo(()=>F.find(S=>S.id===le)??null,[F,le]),me=l.useMemo(()=>vr(M),[M]),se=l.useMemo(()=>Gt(M)?"":Vl(M),[M]),Se=l.useMemo(()=>pe?Dn(me,pe):"",[me,pe]);l.useEffect(()=>{if(!s||!Se){L([]),G(null);return}let S=!1;return O(!0),z(!1),G(null),_t.listLocalDirectory(Se).then(we=>{if(S)return;z(!1),G(null);const Ie=we.filter(Fe=>Fe.isDirectory).map(Fe=>({name:Fe.name,path:ps(Fe.path)})).sort((Fe,st)=>Fe.name.localeCompare(st.name));L(Ie)}).catch(we=>{if(!S){L([]);const Ie=jo(we)?we.reason:"unknown";G(Ie),z(Ie==="not-found")}}).finally(()=>{S||O(!1)}),()=>{S=!0}},[Se,U,s]);const Te=l.useMemo(()=>{const S=se.toLowerCase(),we=ae||se.startsWith(".");return q.filter(Ie=>Ie.name.toLowerCase().startsWith(S)&&(we||!Ie.name.startsWith(".")))},[se,q,ae]),De=l.useMemo(()=>{const S=[];_l(M)&&S.push({type:"up",value:"browse:up",name:"..",path:kr(M)});for(const we of Te){const Ie=At(we.path);S.push({type:"directory",value:`browse:${we.path}`,name:we.name,path:we.path,disabled:!!(Ie&&D.has(Ie))})}return S},[D,Te,M]);l.useEffect(()=>{$(0)},[M,De.length]);const Ue=l.useMemo(()=>pe?Ks(Dn(M,pe)):"",[pe,M]),Ve=At(Ue),Me=!!(Ve&&D.has(Ve)),Ze=l.useMemo(()=>se?Te.find(S=>S.name===se)??null:null,[se,Te]),Ee=!!(Ue&&!Me&&(de===null||de==="not-found")&&(Gt(M)&&ne||!Gt(M)&&se.trim().length>0&&Ze===null)),He=!H&&!re&&!Me&&de!=="os-permission"&&de!=="invalid-response"&&de!=="unknown"&&!!Ue,Le=He&&be.trim().length>0,ze=De[B]??null,Je=!!(ze&&(ze.type==="up"||ze.type==="directory"&&!ze.disabled)),Be=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl",Qe=n(Me?"directoryExplorerDialog.actions.alreadyAdded":ke?H?"directoryExplorerDialog.actions.cloning":"directoryExplorerDialog.actions.cloneAndAdd":H?"directoryExplorerDialog.actions.adding":Ee?"directoryExplorerDialog.actions.createAndAdd":"directoryExplorerDialog.actions.addProject");l.useLayoutEffect(()=>{const S=V.current;if(!S)return;const we=()=>Ce(Math.ceil(S.getBoundingClientRect().width));if(we(),typeof ResizeObserver>"u")return;const Ie=new ResizeObserver(we);return Ie.observe(S),()=>Ie.disconnect()},[Qe]),l.useLayoutEffect(()=>{const S=A.current;S&&(S.scrollLeft=S.scrollWidth)},[he,M]),l.useLayoutEffect(()=>{s&&js(A.current)},[s]),l.useLayoutEffect(()=>{const S=De[B];S&&w.current.get(S.value)?.scrollIntoView({block:"nearest"})},[B,De]);const Ke=l.useCallback(()=>{e(!1)},[e]),Pe=l.useCallback((S,we)=>{o("chat"),I&&u(!1),f({selectedProjectId:S,directoryOverride:we}),Ke()},[Ke,I,f,o,u]),et=l.useCallback((S,we)=>{S.stopPropagation();const Ie=At(we);if(Ie&&D.has(Ie))return;const Fe=i(we);if(!Fe){ve.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}Pe(Fe.id,Fe.path)},[i,D,Pe,n]),$e=l.useCallback(async S=>{if(!S||H)return;const we=At(S);if(we&&D.has(we))return;let Ie=S;E(!0);try{const Fe=!ke&&Ee&&At(S)===At(Ue);if(ke){const ot=be.trim();if(!ot){ve.error(n("directoryExplorerDialog.toast.cloneUrlRequired"));return}Ie=(await _t.cloneRepository({remoteUrl:ot,destinationPath:S,gitIdentityId:X?.id??null})).path}else Fe&&await _t.createDirectory(S,{asProject:!0});const st=i(Ie);if(!st){ve.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}Pe(st.id,st.path)}catch(Fe){ve.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:Fe instanceof Error?Fe.message:n("directoryExplorerDialog.toast.unknownError")})}finally{E(!1)}},[i,D,be,ke,H,Pe,X?.id,Ee,Ue,n]),b=l.useCallback(S=>{te(zl(S))},[]),Z=l.useCallback(S=>{te(Gl(M,S.name))},[M]),m=l.useCallback(S=>{if(S){if(S.type==="up"){S.path&&b(S.path);return}S.disabled||Z(S)}},[b,Z]),j=l.useCallback(async()=>{if(!(!y||re)){ue(!0);try{const S=await v(Ue);if(!S.success||!S.path){S.error&&S.error!=="Directory selection cancelled"&&ve.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:S.error});return}const we=await C(S.path);if(!we.success){ve.error(n("directoryExplorerDialog.toast.failedToOpenDirectory"),{description:we.error||n("directoryExplorerDialog.toast.desktopCouldNotGrantAccess")});return}await $e(S.path)}catch(S){ve.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:S instanceof Error?S.message:n("directoryExplorerDialog.toast.unknownError")})}finally{ue(!1)}}},[y,$e,re,v,C,n,Ue]),ee=l.useCallback(S=>{if(S.key==="ArrowDown"){S.preventDefault(),$(we=>Math.min(De.length-1,we+1));return}if(S.key==="ArrowUp"){S.preventDefault(),$(we=>Math.max(0,we-1));return}if(S.key==="Enter"){if(S.preventDefault(),Hl(S)){$e(Ue);return}Je&&m(ze);return}S.key==="Backspace"&&M===""&&(S.preventDefault(),Ke())},[m,$e,Ke,Je,ze,M,De.length,Ue]),ye=t.jsxs("button",{type:"button",onClick:()=>ce(S=>!S),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:[ae?t.jsx(P,{name:"checkbox",className:"h-4 w-4 text-primary"}):t.jsx(P,{name:"checkbox-blank",className:"h-4 w-4"}),n("directoryExplorerDialog.toggle.showHidden")]}),xe=t.jsxs("div",{className:"px-2.5 py-1.5",children:[ke?t.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[t.jsx(ht,{value:be,onChange:S=>_(S.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(wr,{activeProfile:X,identities:F,onSelect:S=>Y(S.id),isApplying:H,iconOnly:!0})]}):null,t.jsxs("div",{className:"relative",children:[t.jsx(P,{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(ht,{ref:A,value:M,onChange:S=>te(ps(S.target.value)),onKeyDown:ee,placeholder:n("directoryExplorerDialog.pathInput.placeholder"),className:"border-transparent bg-transparent pl-9 font-mono typography-ui-label shadow-none focus-visible:ring-0",style:!I&&he>0?{paddingRight:`${he+24}px`}:void 0,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),I?null:t.jsx(Ne,{ref:V,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:ke?!Le:!He,onMouseDown:S=>S.preventDefault(),onClick:()=>{$e(Ue)},title:Qe,children:Qe})]})]}),Oe=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("div",{className:"max-h-[min(28rem,58vh)] overflow-y-auto 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")}),W?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.loading")}):de&&de!=="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(de==="os-permission"?"directoryExplorerDialog.browse.permissionDenied":"directoryExplorerDialog.browse.loadFailed")}),t.jsxs("div",{className:"flex items-center gap-2",children:[de==="os-permission"&&y?t.jsx(Ne,{size:"xs",onClick:()=>{j()},disabled:re,children:n("directoryExplorerDialog.browse.grantAccess")}):null,t.jsx(Ne,{variant:"outline",size:"xs",onClick:()=>R(S=>S+1),children:n("directoryExplorerDialog.browse.retry")})]})]}):De.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:De.map((S,we)=>{const Ie=we===B;return t.jsxs("button",{ref:Fe=>{Fe?w.current.set(S.value,Fe):w.current.delete(S.value)},type:"button",disabled:S.type==="directory"&&S.disabled,onMouseEnter:()=>$(we),onMouseDown:Fe=>Fe.preventDefault(),onClick:()=>m(S),className:K("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",Ie&&"bg-interactive-selection text-interactive-selection-foreground",!Ie&&"hover:bg-interactive-hover/50",S.type==="directory"&&S.disabled&&"cursor-not-allowed opacity-45 hover:bg-transparent"),children:[S.type==="up"?t.jsx(P,{name:"arrow-left-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}):t.jsx(P,{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:S.name})}),S.type==="directory"&&S.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")}):S.type==="directory"?t.jsx("button",{type:"button",onMouseDown:Fe=>Fe.stopPropagation(),onClick:Fe=>et(Fe,S.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(P,{name:"add",className:"h-3.5 w-3.5"})}):null]},S.value)})})]})}),tt=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[xe,Oe]}),qe=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(P,{name:"arrow-up-s",className:"h-3.5 w-3.5"}),t.jsx(P,{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(P,{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:Be}),t.jsx(P,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.add")]})]}),Re=()=>t.jsxs(t.Fragment,{children:[I?null:qe,t.jsxs("div",{className:K("flex w-full flex-row justify-end gap-2 sm:w-auto",I&&"justify-stretch"),children:[y?t.jsx(Ne,{variant:"ghost",size:"xs",onClick:j,disabled:H||re||ke,children:n(re?"directoryExplorerDialog.actions.openingFinder":"directoryExplorerDialog.actions.openInFinder")}):null,t.jsx(Ne,{variant:"ghost",size:"xs",onClick:()=>J(S=>!S),disabled:H||re,className:K(I&&"flex-1"),children:n(ke?"directoryExplorerDialog.actions.addLocalProject":"directoryExplorerDialog.actions.cloneRepository")}),I?t.jsx(Ne,{size:"xs",onClick:()=>{$e(Ue)},disabled:ke?!Le:!He,className:"flex-1",children:Qe}):null]})]});return I?t.jsx(Yt,{open:s,onClose:Ke,title:n("directoryExplorerDialog.title"),className:"h-[88dvh] max-h-[720px]",contentMaxHeightClassName:"flex-1",footer:t.jsx("div",{className:"flex flex-col gap-2",children:Re()}),children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[t.jsx("div",{className:"flex justify-end",children:ye}),tt]})}):t.jsx(Zt,{open:s,onOpenChange:e,children:t.jsxs(es,{className:"flex w-full max-w-xl flex-col gap-0 overflow-hidden p-0 sm:max-h-[80vh]",initialFocus:!1,children:[t.jsx(gs,{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(ts,{children:n("directoryExplorerDialog.title")}),t.jsx(Ra,{className:"mt-2",children:n("directoryExplorerDialog.description")})]}),ye]})}),t.jsx("div",{className:"min-h-0 flex-1 px-2 pb-0",children:tt}),t.jsx(_s,{className:"flex w-full flex-col gap-3 px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:Re()})]})})};function En(s){const{localBranches:e,remoteBranches:n,query:r}=s,a=r.trim();if(!a)return{matching:[],otherLocal:e,otherRemote:n};const i=tn(e,a,c=>c),o=tn(n,a,c=>c),u=[],f=i.other,h=o.other;for(const c of i.matching)u.push({label:c,value:c,source:"local"});for(const c of o.matching)u.push({label:c,value:`remotes/${c}`,source:"remote"});return u.sort((c,g)=>{const p=c.label.localeCompare(g.label,void 0,{sensitivity:"accent"});return p!==0?p:c.source!==g.source?c.source.localeCompare(g.source):c.value.localeCompare(g.value)}),{matching:u,otherLocal:f,otherRemote:h}}const Ns="oc:lastWorktreeSourceBranch",ql=({mode:s,sourceBranch:e,linkedPr:n,selectedBranch:r})=>s==="existing-branch"?r||null:n?null:e||null,Yl=({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 Jl({open:s,onOpenChange:e,onSelect:n}){const{t:r}=nt(),a=Ae(D=>D.isMobile),{github:i}=Gs(),o=hs(D=>D.status),u=hs(D=>D.hasChecked),f=Ae(D=>D.setSettingsDialogOpen),h=Ae(D=>D.setSettingsPage),c=gt(D=>D.getActiveProject()),g=c?.path??null,p=Q.useMemo(()=>g&&c?{id:c.id,path:g}:null,[c,g]),[x,d]=Q.useState("issues"),[y,v]=Q.useState(""),[C,I]=Q.useState([]),[A,V]=Q.useState([]),[w,N]=Q.useState(!1),[k,M]=Q.useState(!1),[te,q]=Q.useState(null),[L,W]=Q.useState(null),[O,ne]=Q.useState(null),[z,de]=Q.useState(!1),[G,U]=Q.useState(new Map),[R,B]=Q.useState(1),[$,H]=Q.useState(!1),E=Aa(y,350),re=Q.useCallback(async D=>{if(!(!g||!i)&&!(u&&o?.connected===!1)){N(!0),q(null),B(1),H(!1);try{if(x==="issues"&&i.issuesList){const F=await i.issuesList(g,{page:1,query:D});F.connected===!1?(q(r("session.githubIntegration.error.notConnected")),I([])):(I(F.issues??[]),B(F.page??1),H(!!F.hasMore))}else if(x==="prs"&&i.prsList){const F=await i.prsList(g,{page:1,query:D});F.connected===!1?(q(r("session.githubIntegration.error.notConnected")),V([])):(V(F.prs??[]),B(F.page??1),H(!!F.hasMore))}}catch(F){q(F instanceof Error?F.message:r("session.githubIntegration.error.loadDataFailed"))}finally{N(!1)}}},[g,i,u,o,x,r]);Q.useEffect(()=>{if(!s||!g||u&&o?.connected===!1||!i)return;if(!E.trim()){re();return}const D=new AbortController;N(!0),q(null),B(1),H(!1);const F=x==="issues"&&i.issuesList?i.issuesList(g,{page:1,query:E.trim()}):x==="prs"&&i.prsList?i.prsList(g,{page:1,query:E.trim()}):null;if(!F){N(!1);return}return F.then(X=>{D.signal.aborted||("issues"in X?X.connected===!1?(q(r("session.githubIntegration.error.notConnected")),I([])):(I(X.issues??[]),B(X.page??1),H(!!X.hasMore)):"prs"in X&&(X.connected===!1?(q(r("session.githubIntegration.error.notConnected")),V([])):(V(X.prs??[]),B(X.page??1),H(!!X.hasMore))))}).catch(X=>{D.signal.aborted||q(X instanceof Error?X.message:r("session.githubIntegration.error.loadDataFailed"))}).finally(()=>{D.signal.aborted||N(!1)}),()=>D.abort()},[s,g,i,u,o,x,E,re,r]);const ue=Q.useCallback(async()=>{if(!(!g||!i)&&!(w||k)&&$){M(!0);try{const D=R+1;if(x==="issues"&&i.issuesList){const F=E.trim()?await i.issuesList(g,{page:D,query:E.trim()}):await i.issuesList(g,{page:D});F.connected!==!1&&(I(X=>[...X,...F.issues??[]]),B(F.page??D),H(!!F.hasMore))}else if(x==="prs"&&i.prsList){const F=E.trim()?await i.prsList(g,{page:D,query:E.trim()}):await i.prsList(g,{page:D});F.connected!==!1&&(V(X=>[...X,...F.prs??[]]),B(F.page??D),H(!!F.hasMore))}}catch{}finally{M(!1)}}},[g,i,x,R,$,w,k,E]);Q.useEffect(()=>{if(!s){d("issues"),v(""),I([]),V([]),W(null),ne(null),de(!1),q(null),U(new Map),B(1),H(!1);return}re()},[s,re]);const he=Q.useCallback(async D=>{if(!(!p||!D)&&!G.has(D))try{const X=(await Kn(p,{mode:"new",branchName:D,worktreeName:D})).errors.find(me=>me.code==="branch_in_use");U(me=>new Map(me).set(D,{isValid:!X,error:X?r(X.code==="branch_exists"?"session.githubIntegration.validation.branchAlreadyExists":"session.githubIntegration.validation.branchAlreadyCheckedOut"):null}))}catch{U(F=>new Map(F).set(D,{isValid:!1,error:r("session.githubIntegration.validation.failed")}))}},[p,G,r]);Q.useEffect(()=>{!s||x!=="prs"||A.forEach(D=>{D.head&&he(D.head)})},[s,x,A,he]);const Ce=u&&o?.connected===!0,ke=()=>{h("github"),f(!0)},J=D=>{W(D),ne(null)},be=D=>{ne(D),W(null)},_=()=>{L?n({type:"issue",item:L}):O&&n({type:"pr",item:O,includeDiff:z}),e(!1)},le=()=>{W(null),ne(null),de(!1)},Y=L||O&&G.get(O.head??"")?.isValid!==!1,ae=D=>D.head?G.get(D.head)?.isValid===!1:!0,ce=t.jsx(t.Fragment,{children:Ce?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative mt-2",children:[t.jsx(P,{name:"search",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(ht,{value:y,onChange:D=>v(D.target.value),placeholder:r(x==="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("div",{className:"h-full overflow-y-auto",children:[w&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(P,{name:"loader-4",className:"h-5 w-5 animate-spin text-muted-foreground"})}),te&&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(P,{name:"error-warning",className:"h-4 w-4"}),t.jsx("span",{className:"typography-small",children:te})]})}),!w&&!te&&x==="issues"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[C.length>0?C.map(D=>t.jsx("button",{onClick:()=>J(D),className:K("w-full text-left px-2 py-1.5 rounded transition-colors",L?.number===D.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:["#",D.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-2",children:D.title}),D.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:[D.sourceRepo.owner,"/",D.sourceRepo.repo]}):null]})]})},`${D.sourceRepo?.owner??""}-${D.sourceRepo?.repo??""}-${D.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")}),$&&!k&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{ue()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),k&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(P,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]}),!w&&!te&&x==="prs"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[A.length>0?A.map(D=>{const F=ae(D),X=D.head?G.get(D.head):void 0;return t.jsx("button",{onClick:()=>!F&&be(D),disabled:F,className:K("w-full text-left px-2 py-1.5 rounded transition-colors",O?.number===D.number?"bg-interactive-selection text-interactive-selection-foreground":F?"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:["#",D.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-1",children:D.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[D.head," → ",D.base]}),D.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info",children:[D.sourceRepo.owner,"/",D.sourceRepo.repo]}):null,F&&X?.error&&t.jsx("span",{className:"typography-micro text-destructive",children:X.error})]})]})]})},`${D.sourceRepo?.owner??""}-${D.sourceRepo?.repo??""}-${D.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")}),$&&!k&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{ue()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),k&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(P,{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(P,{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(Ne,{onClick:ke,size:"sm",children:r("session.githubIntegration.connect.action")})]})}),pe=t.jsxs("div",{className:K("w-full",a?"flex flex-col gap-2":"flex flex-row items-center"),children:[t.jsxs("div",{className:K("flex items-center gap-4",a?"w-full justify-center order-1":"flex-1"),children:[!a&&(L||O)&&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(P,{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:L?r("session.githubIntegration.selected.issueNumber",{number:L.number}):r("session.githubIntegration.selected.prNumber",{number:O?.number??""})}),t.jsx("button",{onClick:le,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(P,{name:"close",className:"h-3.5 w-3.5"})})]}),x==="prs"&&O&&t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer h-8",children:[t.jsx(ss,{checked:z,onChange:D=>de(D),ariaLabel:r("session.githubIntegration.includeDiffAria")}),t.jsx("span",{className:"typography-small text-foreground",children:r("session.githubIntegration.includeDiff")})]})]}),t.jsxs("div",{className:K("flex gap-2",a?"w-full order-2":"justify-end"),children:[t.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>e(!1),className:K(a&&"flex-1"),children:r("session.githubIntegration.actions.cancel")}),t.jsx(Ne,{size:"sm",onClick:_,disabled:!Y,className:K(a&&"flex-1"),children:r("session.githubIntegration.actions.select")})]})]});return t.jsx(t.Fragment,{children:a?t.jsx(Yt,{open:s,title:r("session.githubIntegration.title"),onClose:()=>e(!1),footer:Ce?pe:void 0,renderHeader:D=>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")}),D]}),t.jsx("div",{className:"w-full",children:t.jsx(Qt,{items:[{id:"issues",label:r("session.githubIntegration.tabs.issues"),icon:t.jsx(P,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(P,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:x,onSelect:F=>{d(F),v("")},variant:"active-pill",layoutMode:"fit"})}),(L||O)&&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(P,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate flex-1",children:L?r("session.githubIntegration.selected.issueNumber",{number:L.number}):r("session.githubIntegration.selected.prNumber",{number:O?.number??""})}),t.jsx("button",{onClick:le,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(P,{name:"close",className:"h-3.5 w-3.5"})})]})]}),children:ce}):t.jsx(Zt,{open:s,onOpenChange:e,children:t.jsxs(es,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsx(gs,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(ts,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(P,{name:"github",className:"h-5 w-5"}),r("session.githubIntegration.title")]}),t.jsx("div",{className:"w-[220px]",children:t.jsx(Qt,{items:[{id:"issues",label:r("session.githubIntegration.tabs.issues"),icon:t.jsx(P,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(P,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:x,onSelect:D=>{d(D),v("")},variant:"active-pill",layoutMode:"fit"})})]})}),ce,t.jsx(_s,{className:"mt-1",children:pe})]})})})}const qt=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,""),lt=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),Ql=s=>String(s).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"pr-head",Rn=(s,e,n)=>{const r=qt(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 a=n.find(h=>{const c=h.indexOf("/");return c<=0||c>=h.length-1?!1:h.slice(c+1)===r});if(a){const h=a.indexOf("/"),c=a.slice(0,h);return{existingBranch:`remotes/${a}`,setUpstream:!0,upstreamRemote:c,upstreamBranch:r,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${c}/${r}`}}const i=String(s.headLabel||"").split(":")[0]?.trim(),o=s.headRepo?.owner||i||"pr-head",u=`pr-${Ql(o)}`,f=s.headRepo?.sshUrl||s.headRepo?.cloneUrl||"";if(!f)throw new Error("PR head repository URL is unavailable");return{existingBranch:`remotes/${u}/${r}`,setUpstream:!0,upstreamRemote:u,upstreamBranch:r,ensureRemoteName:u,ensureRemoteUrl:f,sourceLabel:`${u}/${r}`}},Xl=s=>{const e={repo:s.repo??null,issue:s.issue,comments:s.comments};return`GitHub issue context (JSON)
|
|
3
|
-
${JSON.stringify(e,null,2)}`},Zl=s=>`GitHub pull request context (JSON)
|
|
4
|
-
${JSON.stringify(s,null,2)}`;function jd({open:s,onOpenChange:e,onWorktreeCreated:n}){const{t:r}=nt(),{github:a,git:i}=Gs(),o=Ae(m=>m.isMobile),u=hs(m=>m.status),f=hs(m=>m.hasChecked),h=gt(m=>m.getActiveProject()),c=h?.path??null,g=Q.useMemo(()=>c&&h?{id:h.id,path:c}:null,[h,c]),[p,x]=Q.useState("new-branch"),[d,y]=Q.useState({branchName:"",worktreeName:"",isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1}),[v,C]=Q.useState({selectedBranch:"",worktreeName:""}),I=Ba(c),A=Ma(c),V=Hs(m=>m.fetchBranches),w=Q.useMemo(()=>I?.all?I.all.filter(m=>!m.startsWith("remotes/")).sort():[],[I]),N=Q.useMemo(()=>I?.all?I.all.filter(m=>m.startsWith("remotes/")).map(m=>m.replace(/^remotes\//,"")).sort():[],[I]),k=rt(m=>m.availableWorktreesByProject),M=Q.useMemo(()=>{if(!c)return new Set;const m=k.get(c)??[];return new Set(m.map(j=>j.name))},[k,c]),te=Q.useCallback((m=10)=>{for(let j=0;j<m;j++){const ee=ys();if(!M.has(ee))return ee}return`${ys()}-${Date.now().toString(36).slice(-4)}`},[M]),[q,L]=Q.useState(!1),[W,O]=Q.useState(!1),[ne,z]=Q.useState(!1),[de,G]=Q.useState(!1),[U,R]=Q.useState(!1),[B,$]=Q.useState(""),[H,E]=Q.useState(""),re=Q.useRef(null),ue=Q.useRef(null),he=Q.useRef(null),Ce=Q.useRef(null),ke=Q.useCallback(m=>{m.stopPropagation()},[]),J=Q.useCallback(m=>{let j=m;for(;j&&j!==document.body;){const{overflowY:ee}=window.getComputedStyle(j);if((ee==="auto"||ee==="scroll")&&j.scrollHeight>j.clientHeight)return j;j=j.parentElement}return null},[]),be=Q.useCallback(m=>{m&&(m.scrollTop=0)},[]),_=Q.useCallback(m=>{const j=m.current?.querySelector('[data-slot="command-list"]')??null;be(j)},[be]),le=Q.useCallback(m=>{const j=J(m.current);be(j)},[J,be]),Y=Q.useMemo(()=>En({localBranches:w,remoteBranches:N,query:B}),[w,N,B]),ae=Q.useMemo(()=>En({localBranches:w,remoteBranches:N,query:H}),[w,N,H]),ce=B.trim().length>0,pe=H.trim().length>0,D=Y.matching.length>0,F=ae.matching.length>0,X=!!(c&&i),me=Q.useCallback(()=>{!c||!i||V(c,i)},[c,i,V]);Q.useEffect(()=>{!s||!c||!i||I?.all||V(c,i)},[s,c,i,I?.all,V]),Q.useEffect(()=>{!W&&!de&&$("")},[W,de]),Q.useEffect(()=>{!ne&&!U&&E("")},[ne,U]),Q.useEffect(()=>{W&&_(re),de&&le(he)},[W,de,B,_,le]),Q.useEffect(()=>{ne&&_(ue),U&&le(Ce)},[ne,U,H,_,le]);const[se,Se]=Q.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[Te,De]=Q.useState(!1),[Ue,Ve]=Q.useState(null),Me=Q.useCallback(()=>{const m=pt.getState(),j=m.getVisibleAgents();if(m.settingsDefaultAgent){const ee=j.find(ye=>ye.name===m.settingsDefaultAgent);if(ee)return ee.name}return j.find(ee=>ee.name==="build")?.name||j[0]?.name},[]),Ze=Q.useCallback(()=>{const m=pt.getState(),j=m.settingsDefaultModel;if(!j)return null;const ee=Hn(j);if(!ee)return null;const{providerId:ye,modelId:xe}=ee;return m.getModelMetadata(ye,xe)?{providerID:ye,modelID:xe}:null},[]),Ee=Q.useCallback((m,j)=>{const ee=pt.getState(),ye=ee.settingsDefaultVariant,xe=ee.currentProviderId===m&&ee.currentModelId===j?ee.currentVariant:void 0,qe=ee.providers.find(Re=>Re.id===m)?.models.find(Re=>Re.id===j)?.variants;if(!qe)return ye||xe||void 0;if(ye&&Object.prototype.hasOwnProperty.call(qe,ye))return ye;if(xe&&Object.prototype.hasOwnProperty.call(qe,xe))return xe},[]),He=Q.useCallback(async m=>{if(!c||!a)return;const j=pt.getState(),ee=qn.getState().lastUsedProvider,ye=Ze(),xe=ye?.providerID||j.currentProviderId||ee?.providerID,Oe=ye?.modelID||j.currentModelId||ee?.modelID,tt=Me()||j.currentAgentName||void 0;if(!xe||!Oe){ve.error(r("session.newWorktree.error.noModelSelected"));return}const qe=Ee(xe,Oe);if(m.issue){if(!a.issueGet||!a.issueComments)return;const Re=await a.issueGet(c,m.issue.number,{sourceRepo:m.issue.sourceRepo??null});if(Re.connected===!1||!Re.repo||!Re.issue)throw new Error("Failed to load issue context");const S=await a.issueComments(c,m.issue.number,{sourceRepo:m.issue.sourceRepo??null});if(S.connected===!1)throw new Error("Failed to load issue comments");const we=await zt("github.issue.review.visible",{issue_number:String(m.issue.number)}),Ie=await zt("github.issue.review.instructions"),Fe=Xl({repo:Re.repo,issue:Re.issue,comments:S.comments??[]});await rt.getState().sendMessage(we,xe,Oe,tt,void 0,void 0,[{text:Ie,synthetic:!0},{text:Fe,synthetic:!0}],qe,void 0,{sessionId:m.sessionId}),sn(m.sessionId,m.directory,nn({url:Re.issue.url,number:Re.issue.number,title:Re.issue.title,kind:"issue",author:Re.issue.author,linkedAt:Date.now()}),!0).catch(()=>{}),ve.success(r("session.newWorktree.toast.sessionFromIssue"));return}if(m.pr){if(!a.prContext)return;const Re=await a.prContext(c,m.pr.number,{sourceRepo:m.pr.sourceRepo??null,includeDiff:m.includeDiff,includeCheckDetails:!1});if(Re.connected===!1||!Re.repo||!Re.pr)throw new Error("Failed to load PR context");const S=await zt("github.pr.review.visible",{pr_number:String(m.pr.number)}),we=await zt("github.pr.review.instructions"),Ie=Zl(Re);await rt.getState().sendMessage(S,xe,Oe,tt,void 0,void 0,[{text:we,synthetic:!0},{text:Ie,synthetic:!0}],qe,void 0,{sessionId:m.sessionId}),sn(m.sessionId,m.directory,nn({url:Re.pr.url,number:Re.pr.number,title:Re.pr.title,kind:"pull",author:Re.pr.author,linkedAt:Date.now()}),!0).catch(()=>{}),ve.success(r("session.newWorktree.toast.sessionFromPr"))}},[a,c,Me,Ze,Ee,r]),Le=p==="new-branch"?d:v;Q.useEffect(()=>{if(!s||!I?.all||!c||d.sourceBranch)return;const m=d.sourceBranch;let j=!1;return(async()=>{try{const ye=await La(c).catch(()=>null);if(j)return;const xe=localStorage.getItem(Ns),{sourceBranch:Oe,shouldClearSavedSourceBranch:tt}=Yl({branches:I.all,savedSourceBranch:xe,rootBranch:ye});if(tt&&localStorage.removeItem(Ns),j||m)return;Oe&&y(qe=>({...qe,sourceBranch:Oe}))}catch{}})(),()=>{j=!0}},[s,I?.all,c,d.sourceBranch]),Q.useLayoutEffect(()=>{if(!s)return;x("new-branch"),C({selectedBranch:"",worktreeName:""}),O(!1),z(!1),G(!1),R(!1),$(""),E(""),Se({isValidating:!1,branchError:null,worktreeError:null,touched:!1});const m=te();y({branchName:m,worktreeName:m,isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1})},[s,te]),Q.useEffect(()=>{if(p!=="new-branch"||!d.isSyncingWorktreeName)return;const m=qt(d.branchName),j=lt(m);y(ee=>({...ee,worktreeName:j}))},[p,d.branchName,d.isSyncingWorktreeName]);const ze=Q.useCallback(async()=>{if(!g||!se.touched||Te)return;Ue&&Ue.abort();const m=new AbortController;Ve(m),Se(j=>({...j,isValidating:!0}));try{const j=p==="new-branch"?d.branchName:v.selectedBranch,ee=Le.worktreeName,ye=qt(j),xe=lt(ee);let Oe=null,tt=null;if(ye||(Oe=r("session.newWorktree.error.branchNameRequired")),xe||(tt=r("session.newWorktree.error.worktreeDirectoryRequired")),ye&&xe){const qe=p==="new-branch"?d.linkedPr:null,Re=qe?Rn(qe,w,N):null,S=await Kn(g,{mode:p==="existing-branch"||Re?"existing":"new",branchName:ye,worktreeName:xe,existingBranch:Re?.existingBranch??(p==="existing-branch"?ye:void 0),...Re?.ensureRemoteName?{ensureRemoteName:Re.ensureRemoteName}:{},...Re?.ensureRemoteUrl?{ensureRemoteUrl:Re.ensureRemoteUrl}:{}});if(m.signal.aborted)return;S.ok||S.errors.forEach(we=>{if(we.code==="worktree_exists"){tt=tt??we.message;return}we.code.startsWith("branch_")&&(Oe=Oe??we.message)})}m.signal.aborted||Se(qe=>({...qe,isValidating:!1,branchError:Oe,worktreeError:tt}))}catch{m.signal.aborted||Se(j=>({...j,isValidating:!1}))}},[g,p,d.branchName,d.linkedPr,v.selectedBranch,Le.worktreeName,w,N,se.touched,Ue,Te,r]),Je=p==="new-branch"?d.branchName:v.selectedBranch;Q.useEffect(()=>{if(!s||!g||!se.touched||Te)return;const m=setTimeout(()=>{ze()},300);return()=>clearTimeout(m)},[Le.worktreeName,Je,s,g,ze,se.touched,Te]);const Be=async()=>{if(!g||!c){ve.error(r("session.newWorktree.error.noActiveProject"));return}Se(xe=>({...xe,touched:!0}));const m=p==="new-branch"?d.branchName:v.selectedBranch,j=Le.worktreeName,ee=qt(m),ye=lt(j);if(!ee){ve.error(r("session.newWorktree.error.branchNameRequired"));return}if(!ye){ve.error(r("session.newWorktree.error.worktreeDirectoryRequired"));return}Ue&&(Ue.abort(),Ve(null)),Se(xe=>({...xe,isValidating:!1,branchError:null,worktreeError:null})),De(!0);try{const xe=p==="new-branch"?d.linkedPr:null,Oe=p==="new-branch"?d.linkedIssue:null,tt=p==="new-branch"?d.linkedPr:null,qe=p==="new-branch"?d.includePrDiff:!1,Re=!!(Oe||tt),S=await zn(g),we=d.sourceBranch;let Ie="";const Fe=(()=>{if(xe){const _e=Rn(xe,w,N);return Ie=_e.sourceLabel,{preferredName:ee||ye,mode:"existing",branchName:ee,worktreeName:ye,existingBranch:_e.existingBranch,setupCommands:S,setUpstream:_e.setUpstream,upstreamRemote:_e.upstreamRemote,upstreamBranch:_e.upstreamBranch,returnAfterDirectoryCreated:!0,..._e.ensureRemoteName?{ensureRemoteName:_e.ensureRemoteName}:{},..._e.ensureRemoteUrl?{ensureRemoteUrl:_e.ensureRemoteUrl}:{}}}return Ie=p==="new-branch"?we:"",{preferredName:ee||ye,mode:p==="existing-branch"?"existing":"new",branchName:p==="existing-branch"?void 0:ee,worktreeName:ye,existingBranch:p==="existing-branch"?ee:void 0,setupCommands:S,returnAfterDirectoryCreated:!0,...we&&p==="new-branch"?{startRef:we}:{}}})(),st=await Fa(c,Fe),ot=await Oa(g,st);let at=null;if(Re){await Vn(g)&&await Ua(ot.path);const _e=Oe?`#${Oe.number} ${Oe.title}`.trim():tt?`#${tt.number} ${tt.title}`.trim():r("session.newWorktree.newSessionTitle"),ft=await Wa(_e,ot.path,null);if(!ft?.id)throw new Error("Failed to create session");at=ft.id,n?.(ot.path,{sessionId:at}),e(!1),De(!1),$a(ft.id,_e).catch(()=>{});try{rt.getState().initializeNewOpenChamberSession(ft.id,pt.getState().agents)}catch{}}else e(!1),De(!1);const dt=ql({mode:p,sourceBranch:d.sourceBranch,linkedPr:!!d.linkedPr,selectedBranch:v.selectedBranch});dt&&localStorage.setItem(Ns,dt),ve.success(r("session.newWorktree.toast.worktreeCreated"),{description:r("session.newWorktree.toast.worktreeCreatedDescription",{target:`${ot.branch||ot.name}${Ie?` ${r("session.newWorktree.fromSource",{source:Ie})}`:""}`})}),at?He({sessionId:at,directory:ot.path,issue:Oe,pr:tt,includeDiff:qe}).catch(_e=>{const ft=_e instanceof Error?_e.message:r("session.newWorktree.error.sendGitHubContextFailed");ve.error(r("session.newWorktree.error.sendGitHubContextFailed"),{description:ft})}):n?.(ot.path)}catch(xe){const Oe=xe instanceof Error?xe.message:r("session.newWorktree.error.createWorktreeFailed");ve.error(r("session.newWorktree.error.createWorktreeFailed"),{description:Oe})}finally{De(!1)}},Qe=m=>{x(m),Se(j=>({...j,touched:!1,branchError:null,worktreeError:null}))},Ke=m=>{if(!m){y(j=>({...j,linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:""}));return}if(m.type==="issue"){const j=m.item,ee=`issue-${j.number}-${ys()}`;y(ye=>({...ye,linkedIssue:j,linkedPr:null,includePrDiff:!1,branchName:ee,worktreeName:lt(ee),isSyncingWorktreeName:!0}))}else if(m.type==="pr"){const j=m.item;y(ee=>({...ee,linkedPr:j,linkedIssue:null,includePrDiff:m.includeDiff??!1,branchName:j.head,worktreeName:lt(j.head),isSyncingWorktreeName:!0}))}},Pe=f&&u?.connected===!0,$e=(p==="existing-branch"?!!v.selectedBranch&&!!v.worktreeName&&!se.branchError&&!se.worktreeError:!!qt(d.branchName)&&!!d.worktreeName&&!se.branchError&&!se.worktreeError)&&!Te,b=()=>{y(m=>({...m,linkedIssue:null,linkedPr:null,branchName:"",includePrDiff:!1,isSyncingWorktreeName:!0}))},Z=t.jsxs("div",{className:K("flex gap-2",o?"flex-col w-full":"flex-row items-center"),children:[t.jsx("div",{className:K("flex items-center gap-1.5 text-destructive",o?"w-full justify-center order-first":"mr-auto"),children:se.touched&&(se.branchError||se.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(P,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:se.branchError||se.worktreeError})]})}),t.jsxs("div",{className:K("flex gap-2",o&&"w-full"),children:[t.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Te,className:K(o&&"flex-1"),children:r("session.newWorktree.actions.cancel")}),t.jsxs(Ne,{size:"sm",onClick:Be,disabled:!$e||Te,className:K("gap-1.5",o&&"flex-1"),children:[Te&&t.jsx(P,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(Te?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]});return t.jsxs(t.Fragment,{children:[o?t.jsxs(Yt,{open:s,title:r("session.newWorktree.title"),onClose:()=>e(!1),footer:Z,children:[t.jsx("div",{className:"w-full mb-4",children:t.jsx(Qt,{items:[{id:"new-branch",label:r("session.newWorktree.mode.newBranch"),icon:t.jsx(P,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(P,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:p,onSelect:m=>Qe(m),variant:"active-pill",layoutMode:"fit",className:"w-full"})}),t.jsxs("div",{className:"space-y-6",children:[p==="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(Ne,{variant:"outline",size:"sm",onClick:()=>G(!0),className:"flex-1 justify-between h-9",children:[t.jsx("span",{className:v.selectedBranch?"text-foreground":"text-muted-foreground",children:v.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(P,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:me,disabled:!X||A,title:r("session.newWorktree.fetchBranches"),children:A?t.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(P,{name:"refresh",className:"size-4"})})]}),t.jsx(Yt,{open:de,title:r("session.newWorktree.selectBranch"),onClose:()=>G(!1),children:t.jsxs("div",{className:"space-y-4",ref:he,children:[t.jsx(ht,{value:B,onChange:m=>$(m.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),A?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&N.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&&D&&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(m=>t.jsx("button",{onClick:()=>{C(j=>({...j,selectedBranch:m.value,worktreeName:lt(m.label)})),Se(j=>({...j,touched:!0})),G(!1)},className:K("w-full text-left px-3 py-2.5 rounded-md transition-colors",v.selectedBranch===m.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:m.label})},`${m.source}-${m.value}`))})]}),ce&&!D&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),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(ce?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:Y.otherLocal.map(m=>t.jsx("button",{onClick:()=>{C(j=>({...j,selectedBranch:m,worktreeName:lt(m)})),Se(j=>({...j,touched:!0})),G(!1)},className:K("w-full text-left px-3 py-2.5 rounded-md transition-colors",v.selectedBranch===m?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:m})},m))})]}),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(ce?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:Y.otherRemote.map(m=>t.jsx("button",{onClick:()=>{C(j=>({...j,selectedBranch:`remotes/${m}`,worktreeName:lt(m)})),Se(j=>({...j,touched:!0})),G(!1)},className:K("w-full text-left px-3 py-2.5 rounded-md transition-colors",v.selectedBranch===`remotes/${m}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:m})},`remotes/${m}`))})]})]})]})})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex flex-col items-start gap-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.branchName")}),p==="new-branch"&&Pe&&t.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>L(!0),className:"gap-1.5 h-7",children:[t.jsx(P,{name:"github",className:"size-4 text-status-success"}),d.linkedIssue||d.linkedPr?r("session.newWorktree.actions.change"):r("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(ht,{value:d.branchName,onChange:m=>{y(j=>({...j,branchName:m.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>Se(m=>({...m,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!d.linkedPr,className:K("h-8",se.touched&&se.branchError&&"border-destructive",d.linkedPr&&"bg-muted text-muted-foreground")}),d.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(P,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:d.linkedPr.head})})]}),d.linkedIssue&&!d.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(P,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:d.linkedIssue.number,title:d.linkedIssue.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")}),p!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const m=lt(p==="new-branch"?d.branchName:"");y(j=>({...j,worktreeName:m,isSyncingWorktreeName:!0}))},disabled:!d.branchName||d.worktreeName===lt(d.branchName),className:K("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",d.worktreeName===lt(d.branchName)||!d.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(P,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:r("session.newWorktree.actions.reset")})]})]}),t.jsx(ht,{value:Le.worktreeName,onChange:m=>{p==="new-branch"?y(j=>({...j,worktreeName:m.target.value,isSyncingWorktreeName:!1})):C(j=>({...j,worktreeName:m.target.value}))},onBlur:()=>Se(m=>({...m,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:K("h-8",se.touched&&se.worktreeError&&"border-destructive")})]}),p==="new-branch"&&!d.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(Ne,{variant:"outline",size:"sm",onClick:()=>R(!0),className:"w-full justify-between h-9",children:[t.jsx("span",{className:d.sourceBranch?"text-foreground":"text-muted-foreground",children:d.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(P,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),d.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:d.sourceBranch})}),t.jsx(Yt,{open:U,title:r("session.newWorktree.selectSourceBranch"),onClose:()=>R(!1),children:t.jsxs("div",{className:"space-y-4",ref:Ce,children:[t.jsx(ht,{value:H,onChange:m=>E(m.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),A?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&N.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&&F&&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:ae.matching.map(m=>t.jsx("button",{onClick:()=>{y(j=>({...j,sourceBranch:m.value})),R(!1)},className:K("w-full text-left px-3 py-2.5 rounded-md transition-colors",d.sourceBranch===m.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:m.label})},`${m.source}-${m.value}`))})]}),pe&&!F&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),ae.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(pe?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:ae.otherLocal.map(m=>t.jsx("button",{onClick:()=>{y(j=>({...j,sourceBranch:m})),R(!1)},className:K("w-full text-left px-3 py-2.5 rounded-md transition-colors",d.sourceBranch===m?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:m})},m))})]}),ae.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(pe?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:ae.otherRemote.map(m=>t.jsx("button",{onClick:()=>{y(j=>({...j,sourceBranch:`remotes/${m}`})),R(!1)},className:K("w-full text-left px-3 py-2.5 rounded-md transition-colors",d.sourceBranch===`remotes/${m}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:m})},`remotes/${m}`))})]})]})]})})]}),(d.linkedIssue||d.linkedPr)&&p==="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(P,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),d.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:d.linkedIssue.number})}),d.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:d.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:d.linkedIssue?.title||d.linkedPr?.title}),t.jsx("a",{href:d.linkedIssue?.url||d.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:m=>m.stopPropagation(),children:t.jsx(P,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:b,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(P,{name:"close",className:"h-3.5 w-3.5"})})]}),d.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:[d.linkedPr.head," → ",d.linkedPr.base]}),d.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(Zt,{open:s,onOpenChange:e,children:t.jsxs(es,{className:"max-w-lg max-h-[80vh] flex flex-col",children:[t.jsx(gs,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(ts,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(P,{name:"git-branch",className:"h-5 w-5"}),r("session.newWorktree.title")]}),t.jsx("div",{className:"w-[280px] shrink-0",children:t.jsx(Qt,{items:[{id:"new-branch",label:r("session.newWorktree.mode.newBranch"),icon:t.jsx(P,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(P,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:p,onSelect:m=>Qe(m),variant:"active-pill",layoutMode:"fit",className:"w-full"})})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto mt-2 space-y-6",children:[p==="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(Pt,{open:W,onOpenChange:O,children:[t.jsx(Dt,{asChild:!0,children:t.jsxs("button",{type:"button",className:K(rn({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:K("truncate",v.selectedBranch?"text-foreground":"text-muted-foreground"),children:v.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(P,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(Et,{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:re,children:t.jsxs(Ms,{shouldFilter:!1,children:[t.jsx(Ls,{placeholder:r("session.newWorktree.searchBranches"),value:B,onValueChange:$,onKeyDown:ke}),t.jsx(Fs,{disableHorizontal:!0,children:A?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&N.length===0?t.jsx(Os,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[ce&&D&&t.jsx(Ct,{heading:r("session.newWorktree.matchingBranches"),children:Y.matching.map(m=>t.jsx(yt,{value:m.value,onSelect:()=>{C(j=>({...j,selectedBranch:m.value,worktreeName:lt(m.label)})),Se(j=>({...j,touched:!0})),O(!1)},children:t.jsx("span",{className:"typography-small break-all",children:m.label})},`${m.source}-${m.value}`))}),ce&&!D&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),Y.otherLocal.length>0&&t.jsxs(t.Fragment,{children:[ce&&t.jsx($t,{}),t.jsx(Ct,{heading:r(ce?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches"),children:Y.otherLocal.map(m=>t.jsx(yt,{value:m,onSelect:()=>{C(j=>({...j,selectedBranch:m,worktreeName:lt(m)})),Se(j=>({...j,touched:!0})),O(!1)},children:t.jsx("span",{className:"typography-small break-all",children:m})},`local-${m}`))})]}),Y.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[(Y.otherLocal.length>0||ce)&&t.jsx($t,{}),t.jsx(Ct,{heading:r(ce?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches"),children:Y.otherRemote.map(m=>t.jsx(yt,{value:`remotes/${m}`,onSelect:()=>{C(j=>({...j,selectedBranch:`remotes/${m}`,worktreeName:lt(m)})),Se(j=>({...j,touched:!0})),O(!1)},children:t.jsx("span",{className:"typography-small break-all",children:m})},`remote-${m}`))})]})]})})]})})]}),t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:me,disabled:!X||A,title:r("session.newWorktree.fetchBranches"),children:A?t.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(P,{name:"refresh",className:"size-4"})})]})]}):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 block font-semibold",children:r("session.newWorktree.branchName")}),p==="new-branch"&&Pe&&t.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>L(!0),className:"gap-1.5 h-7",children:[t.jsx(P,{name:"github",className:"size-4 text-status-success"}),d.linkedIssue||d.linkedPr?r("session.newWorktree.actions.change"):r("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(ht,{value:d.branchName,onChange:m=>{y(j=>({...j,branchName:m.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>Se(m=>({...m,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!d.linkedPr,className:K("h-8",se.touched&&se.branchError&&"border-destructive",d.linkedPr&&"bg-muted text-muted-foreground")}),d.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(P,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:d.linkedPr.head})})]}),d.linkedIssue&&!d.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(P,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:d.linkedIssue.number,title:d.linkedIssue.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")}),p!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const m=lt(p==="new-branch"?d.branchName:"");y(j=>({...j,worktreeName:m,isSyncingWorktreeName:!0}))},disabled:!d.branchName||d.worktreeName===lt(d.branchName),className:K("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",d.worktreeName===lt(d.branchName)||!d.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(P,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:r("session.newWorktree.actions.reset")})]})]}),t.jsx(ht,{value:Le.worktreeName,onChange:m=>{p==="new-branch"?y(j=>({...j,worktreeName:m.target.value,isSyncingWorktreeName:!1})):C(j=>({...j,worktreeName:m.target.value}))},onBlur:()=>Se(m=>({...m,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:K("h-8",se.touched&&se.worktreeError&&"border-destructive")})]}),p==="new-branch"&&!d.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(Pt,{open:ne,onOpenChange:z,children:[t.jsx(Dt,{asChild:!0,children:t.jsxs("button",{type:"button",className:K(rn({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:K("truncate",d.sourceBranch?"text-foreground":"text-muted-foreground"),children:d.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(P,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(Et,{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:ue,children:t.jsxs(Ms,{shouldFilter:!1,children:[t.jsx(Ls,{placeholder:r("session.newWorktree.searchBranches"),value:H,onValueChange:E,onKeyDown:ke}),t.jsx(Fs,{disableHorizontal:!0,children:A?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&N.length===0?t.jsx(Os,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[pe&&F&&t.jsx(Ct,{heading:r("session.newWorktree.matchingBranches"),children:ae.matching.map(m=>t.jsx(yt,{value:m.value,onSelect:()=>{y(j=>({...j,sourceBranch:m.value})),z(!1)},children:t.jsx("span",{className:"typography-small break-all",children:m.label})},`${m.source}-${m.value}`))}),pe&&!F&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),ae.otherLocal.length>0&&t.jsxs(t.Fragment,{children:[pe&&t.jsx($t,{}),t.jsx(Ct,{heading:r(pe?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches"),children:ae.otherLocal.map(m=>t.jsx(yt,{value:m,onSelect:()=>{y(j=>({...j,sourceBranch:m})),z(!1)},children:t.jsx("span",{className:"typography-small break-all",children:m})},`local-${m}`))})]}),ae.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[(ae.otherLocal.length>0||pe)&&t.jsx($t,{}),t.jsx(Ct,{heading:r(pe?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches"),children:ae.otherRemote.map(m=>t.jsx(yt,{value:`remotes/${m}`,onSelect:()=>{y(j=>({...j,sourceBranch:`remotes/${m}`})),z(!1)},children:t.jsx("span",{className:"typography-small break-all",children:m})},`remote-${m}`))})]})]})})]})})]}),d.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:d.sourceBranch})})]}),(d.linkedIssue||d.linkedPr)&&p==="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(P,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),d.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:d.linkedIssue.number})}),d.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:d.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:d.linkedIssue?.title||d.linkedPr?.title}),t.jsx("a",{href:d.linkedIssue?.url||d.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:m=>m.stopPropagation(),children:t.jsx(P,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:b,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(P,{name:"close",className:"h-3.5 w-3.5"})})]}),d.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:[d.linkedPr.head," → ",d.linkedPr.base]}),d.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(_s,{className:"mt-1 flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center gap-1.5 text-destructive",children:se.touched&&(se.branchError||se.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(P,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:se.branchError||se.worktreeError})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Te,children:r("session.newWorktree.actions.cancel")}),t.jsxs(Ne,{size:"sm",onClick:Be,disabled:!$e||Te,className:"gap-1.5",children:[Te&&t.jsx(P,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(Te?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]})]})}),t.jsx(Jl,{open:q,onOpenChange:L,onSelect:Ke})]})}const ec=(s,e)=>{if(!s)return e("mcpDropdown.status.unknown");switch(s.status){case"connected":return e("mcpDropdown.status.connected");case"failed":return e("mcpDropdown.status.failed",{error:s.error||e("mcpDropdown.status.unknownError")});case"needs_auth":return e("mcpDropdown.status.needsAuth");case"needs_client_registration":return e("mcpDropdown.status.needsRegistration",{error:s.error||""});default:return s.status}},tc=s=>{switch(s?.status){case"connected":return"success";case"failed":return"error";case"needs_auth":case"needs_client_registration":return"warning";default:return"default"}},Nd=({active:s,className:e,headerAction:n,listClassName:r,hideHeader:a=!1,mobileListDensity:i=!1})=>{const{t:o}=nt(),f=ns(w=>w.currentDirectory)??null,h=as(w=>w.getStatusForDirectory(f)),c=as(w=>w.refresh),g=as(w=>w.connect),p=as(w=>w.disconnect),x=an(w=>w.mcpServers),d=an(w=>w.loadMcpConfigs),[y,v]=l.useState(!1),[C,I]=l.useState(null);l.useEffect(()=>{c({directory:f,silent:!0})},[c,f]),l.useEffect(()=>{d({force:!0})},[d]),l.useEffect(()=>{s&&Promise.all([c({directory:f,silent:!0}),d({force:!0})])},[s,c,f,d]);const A=l.useMemo(()=>{const w=new Set(Object.keys(h));for(const N of x)N?.name&&w.add(N.name);return Array.from(w).sort((N,k)=>N.localeCompare(k))},[x,h]),V=l.useCallback(w=>{if(w?.preventDefault(),y)return;v(!0);const N=new Promise(k=>setTimeout(k,500));Promise.all([c({directory:f}),N]).finally(()=>{v(!1)})},[y,c,f]);return t.jsxs("div",{className:K("w-full",e),children:[a?null:t.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex items-baseline gap-2",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:o("mcpDropdown.title")}),f&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:f.split("/").pop()||f})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[n,t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",disabled:y,onClick:V,"aria-label":o("mcpDropdown.actions.refreshAria"),children:t.jsx(P,{name:"refresh",className:K("h-4 w-4",y&&"animate-spin")})})]})]})}),t.jsx("div",{className:K("max-h-64 overflow-y-auto",i?"space-y-1 py-3":"px-3 py-2.5",r),children:t.jsxs("div",{className:K(!i&&A.length>0&&"rounded-xl bg-[var(--surface-muted)] p-1.5"),children:[A.map(w=>{const N=h[w],k=tc(N),M=N?.status==="connected",te=C===w,q=ec(N,o);return t.jsxs("div",{className:K("flex items-center justify-between rounded-lg hover:bg-interactive-hover/50",i?"gap-3 px-4 py-3":"gap-2 px-2.5 py-2"),children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs(Mt,{children:[t.jsx(Lt,{asChild:!0,children:t.jsx("span",{className:K("rounded-full flex-shrink-0",i?"h-2.5 w-2.5":"h-2 w-2",k==="success"&&"bg-status-success",k==="error"&&"bg-status-error",k==="warning"&&"bg-status-warning",k==="default"&&"bg-muted-foreground/40"),"aria-label":q})}),t.jsx(Ft,{side:"left",children:t.jsx("p",{children:q})})]}),t.jsx("span",{className:K("truncate",i?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:w})]})}),t.jsx(za,{checked:M,disabled:te,className:"data-[checked]:bg-status-info",onCheckedChange:async L=>{I(w);try{if(!L){await p(w,f);return}const W=h?.[w]?.status;if(W==="needs_auth"||W==="needs_client_registration"){const{opened:O}=await Va({name:w,directory:f});O||mn.error(o("mcpDropdown.toast.authorizeOpenFailed"));return}await g(w,f)}catch(W){mn.error(W instanceof Error?W.message:o("mcpDropdown.toast.authorizeFailed"))}finally{I(null)}}})]},w)}),A.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:o("mcpDropdown.empty.configureInConfig")})]})})]})},zs=5,jr=15,cs=new Map,ms=s=>{const e=Math.sqrt(s/100),n=12*e,r=24*e;return Math.ceil(n+r+1)},sc=(s,e)=>{const n=ms(e);return Math.max(n*zs,Math.min(n*jr,n*s))},nc=async(s,e)=>{const n=await Ja(s.path);return{...s,title:n?.title||s.path.split("/").pop()||e}},rc=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`todo_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,An=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],Bn=(s,e)=>{const n=s.findIndex(r=>r.completed);return n===-1?[...s,e]:[...s.slice(0,n),e,...s.slice(n)]},ac=s=>{const e=Ge.c(20),{id:n,children:r}=s;let a;e[0]!==n?(a={id:n},e[0]=n,e[1]=a):a=e[1];const{attributes:i,listeners:o,setNodeRef:u,setActivatorNodeRef:f,transform:h,transition:c,isDragging:g}=lr(a);let p;e[2]!==h?(p=dr.Transform.toString(h),e[2]=h,e[3]=p):p=e[3];let x;e[4]!==p||e[5]!==c?(x={transform:p,transition:c},e[4]=p,e[5]=c,e[6]=x):x=e[6];const d=g&&"opacity-60";let y;e[7]!==d?(y=K(d),e[7]=d,e[8]=y):y=e[8];let v;e[9]!==i||e[10]!==r||e[11]!==g||e[12]!==o||e[13]!==f?(v=r({attributes:i,listeners:o,setActivatorNodeRef:f,isDragging:g}),e[9]=i,e[10]=r,e[11]=g,e[12]=o,e[13]=f,e[14]=v):v=e[14];let C;return e[15]!==u||e[16]!==x||e[17]!==y||e[18]!==v?(C=t.jsx("li",{ref:u,style:x,className:y,children:v}),e[15]=u,e[16]=x,e[17]=y,e[18]=v,e[19]=C):C=e[19],C},oc=({projectRef:s,projectLabel:e,canCreateWorktree:n=!1,onActionComplete:r,onOpenPlan:a,className:i})=>{const{t:o}=nt(),[u,f]=l.useState(!1),[h,c]=l.useState(""),[g,p]=l.useState([]),[x,d]=l.useState(""),[y,v]=l.useState(null),[C,I]=l.useState(()=>new Set),[A,V]=l.useState([]),[w,N]=l.useState(null),[k,M]=l.useState(!1),[te,q]=l.useState(0),L=l.useRef(!1),W=l.useRef(""),O=l.useRef(null),ne=Ae(b=>b.todoPanelHeight),z=Ae(b=>b.setTodoPanelHeight),de=Ae(b=>b.notesPanelHeight),G=Ae(b=>b.setNotesPanelHeight),[U,R]=l.useState(!1),B=l.useRef(0),$=l.useRef(ne),H=rt(b=>b.currentSessionId),E=rt(b=>b.createSession),re=rt(b=>b.initializeNewOpenChamberSession),ue=rt(b=>b.sendMessage),he=rt(b=>b.setCurrentSession),Ce=_a(b=>b.setPendingInputText),ke=ns(b=>b.currentDirectory),J=Ae(b=>b.openContextPanelTab),be=Ae(b=>b.setActiveMainTab),_=Ae(b=>b.setSessionSwitcherOpen),le=Ae(b=>b.padding),Y=l.useCallback(async(b,Z)=>{if(!s)return!1;const m=s.id,ee=(cs.get(m)??Promise.resolve()).catch(()=>{}).then(()=>Ga(s,{notes:b,todos:Z}));cs.set(m,ee);try{const ye=await ee;return ye||ve.error(o("rightSidebar.contextNotesTodo.toast.saveNotesFailed")),ye}finally{cs.get(m)===ee&&cs.delete(m)}},[s,o]);l.useEffect(()=>{if(!s){c(""),p([]),V([]),d(""),I(new Set);return}let b=!1;return f(!0),(async()=>{try{const Z=await Ha(s),m=await Promise.all(Z.plans.map(j=>nc(j,o("rightSidebar.contextNotesTodo.plan.defaultTitle"))));if(b)return;c(Z.notes),p(An(Z.todos)),V(m),W.current=Z.notes,L.current=!0,d(""),I(new Set)}catch{b||(ve.error(o("rightSidebar.contextNotesTodo.toast.loadNotesFailed")),c(""),p([]),V([]),W.current="",L.current=!0)}finally{b||f(!1)}})(),()=>{b=!0}},[te,s,o]),l.useEffect(()=>{if(!s)return;const b=Z=>{const m=Z.detail;m?.projectId&&m.projectId!==s.id||q(j=>j+1)};return window.addEventListener("openchamber:project-plan-saved",b),window.addEventListener("openchamber:project-notes-updated",b),()=>{window.removeEventListener("openchamber:project-plan-saved",b),window.removeEventListener("openchamber:project-notes-updated",b)}},[s]),l.useEffect(()=>{if(g.length<7)return;const b=sc(g.length,le),Z=ms(le)*zs;ne!==b&&(ne<Z||ne>b)&&z(b)},[g.length,le,ne,z]),l.useEffect(()=>{if(!U)return;const b=m=>{const j=m.clientY-B.current,ee=Math.min(ms(le)*jr,Math.max(ms(le)*zs,$.current+j));z(ee)},Z=()=>{R(!1)};return window.addEventListener("pointermove",b),window.addEventListener("pointerup",Z,{once:!0}),window.addEventListener("pointercancel",Z,{once:!0}),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",Z),window.removeEventListener("pointercancel",Z)}},[U,le,z]);const ae=l.useCallback(b=>{R(!0),B.current=b.clientY,$.current=ne,b.preventDefault()},[ne]),ce=l.useCallback(()=>{O.current!==null&&(window.clearTimeout(O.current),O.current=null)},[]),pe=l.useCallback(()=>{ce(),W.current=h,Y(h,g)},[ce,h,Y,g]);l.useEffect(()=>{if(!(!s||!L.current)&&h!==W.current)return O.current=window.setTimeout(()=>{O.current=null,W.current=h,Y(h,g)},400),()=>{ce()}},[ce,h,Y,s,g]),l.useEffect(()=>()=>ce(),[ce]);const D=l.useCallback(()=>{const b=x.trim();if(!b)return;const Z=Bn(g,{id:rc(),text:b.slice(0,os),completed:!1,createdAt:Date.now()});p(Z),d(""),Y(h,Z)},[x,h,Y,g]),F=l.useCallback(b=>{I(Z=>{const m=new Set(Z);return m.has(b)?m.delete(b):m.add(b),m})},[]),X=l.useCallback((b,Z)=>{const m=g.find(xe=>xe.id===b);if(!m||m.completed===Z)return;const j=g.filter(xe=>xe.id!==b),ee={...m,completed:Z},ye=Z?[...j,ee]:Bn(j,ee);p(ye),Y(h,ye)},[h,Y,g]),me=l.useCallback(b=>{const Z=g.filter(m=>m.id!==b);p(Z),Y(h,Z)},[h,Y,g]),se=l.useCallback(()=>{const b=g.filter(Z=>!Z.completed);b.length!==g.length&&(p(b),Y(h,b))},[h,Y,g]),Se=l.useCallback(b=>{const{active:Z,over:m}=b;if(!m||Z.id===m.id)return;const j=g.findIndex(xe=>xe.id===Z.id),ee=g.findIndex(xe=>xe.id===m.id);if(j===-1||ee===-1)return;const ye=An(zo(g,j,ee));p(ye),Y(h,ye)},[h,Y,g]),Te=nr(rr(ar,{activationConstraint:{distance:8}})),De=x.slice(0,os),Ue=g.reduce((b,Z)=>b+(Z.completed?1:0),0),Ve=l.useCallback(()=>{be("chat"),_(!1)},[be,_]),Me=l.useCallback((b,Z)=>{!s||y||N({kind:"session",todoId:b,todoText:Z})},[s,y]),Ze=l.useCallback(b=>{if(!H){ve.error(o("rightSidebar.contextNotesTodo.toast.noActiveSession"));return}Ve();const Z=`\`\`\`md
|
|
5
|
-
${b}
|
|
6
|
-
\`\`\``;Ce(Z,"append"),ve.success(o("rightSidebar.contextNotesTodo.toast.sentToCurrentSession")),r?.()},[H,r,Ve,Ce,o]),Ee=l.useCallback((b,Z)=>{if(!(!s||y)){if(!n){ve.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}N({kind:"worktree",todoId:b,todoText:Z})}},[n,s,y,o]),He=l.useCallback(async b=>{if(!s||!w)return;const Z=await zt("plan.todo.visible",{todo_text:w.todoText}),j=[{synthetic:!0,text:await zt("plan.todo.instructions",{todo_text:w.todoText})}];M(!0),v(w.todoId);try{Ve();let ee=null,ye=s.path;if(w.kind==="worktree"){if(!n){ve.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}const Oe=await Ka(s.path,qa());if(!Oe?.id)return;ee=Oe.id,ye=Oe.path}else{const Oe=await E(void 0,s.path,null);if(!Oe?.id){ve.error(o("rightSidebar.contextNotesTodo.toast.createSessionFailed"));return}ee=Oe.id,ye=Oe.directory??s.path,re(Oe.id,pt.getState().agents??[])}if(!ee)return;const xe=qn.getState();xe.saveSessionModelSelection(ee,b.providerID,b.modelID),b.agent.trim()&&(xe.saveSessionAgentSelection(ee,b.agent),xe.saveAgentModelForSession(ee,b.agent,b.providerID,b.modelID),xe.saveAgentModelVariantForSession(ee,b.agent,b.providerID,b.modelID,b.variant||void 0)),he(ee,ye),await ue(Z,b.providerID,b.modelID,b.agent.trim()||void 0,void 0,void 0,j,b.variant||void 0),ve.success(w.kind==="worktree"?o("rightSidebar.contextNotesTodo.toast.sentToNewWorktreeSession"):o("rightSidebar.contextNotesTodo.toast.sentToNewSession")),N(null),r?.()}catch(ee){const ye=ee instanceof Error?ee.message:void 0;ve.error(o("rightSidebar.contextNotesTodo.toast.sendTodoFailed"),ye?{description:ye}:void 0)}finally{M(!1),v(null)}},[n,E,re,r,w,s,Ve,ue,he,o]),Le=l.useRef(null),[ze,Je]=l.useState(!1),[Be,Qe]=l.useState(null),Ke=l.useCallback(async b=>{if(!(!s||Be)){Qe(b);try{if(!await Ya(s,b)){ve.error(o("rightSidebar.contextNotesTodo.toast.deletePlanFailed"));return}V(m=>m.filter(j=>j.id!==b)),window.dispatchEvent(new CustomEvent("openchamber:project-plan-saved",{detail:{projectId:s.id}}))}finally{Qe(null)}}},[Be,s,o]),Pe=l.useCallback(async()=>{if(!s||ze)return;const b=await No({defaultPath:s.path,filters:[{name:"Plan files",extensions:["md","markdown","txt"]},{name:"All files",extensions:["*"]}]});if(b.success&&b.path){Je(!0);try{const Z=new URLSearchParams({path:b.path,allowOutsideWorkspace:"true"});b.outsideFileGrant&&Z.set("outsideFileGrant",b.outsideFileGrant);const m=await Nt(`/api/fs/read?${Z.toString()}`,{cache:"no-store"});if(!m.ok){ve.error(o("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"));return}const j=await m.text();if(!j.trim()){ve.error(o("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const ee=b.path.split("/").pop()?.replace(/\.(md|markdown|txt)$/i,"").trim()||"";if(!await on(s,j,ee)){ve.error(o("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}window.dispatchEvent(new CustomEvent("openchamber:project-plan-saved",{detail:{projectId:s.id}})),ve.success(o("rightSidebar.contextNotesTodo.toast.planImported"))}catch(Z){const m=Z instanceof Error?Z.message:void 0;ve.error(o("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),m?{description:m}:void 0)}finally{Je(!1)}}else b.error==="Native file picker not available"&&Le.current?.click()},[ze,s,o]),et=l.useCallback(async b=>{if(!(!s||!b)){Je(!0);try{const Z=await b.text();if(!Z.trim()){ve.error(o("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const m=b.name.replace(/\.(md|markdown|txt)$/i,"").trim();if(!await on(s,Z,m)){ve.error(o("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}window.dispatchEvent(new CustomEvent("openchamber:project-plan-saved",{detail:{projectId:s.id}})),ve.success(o("rightSidebar.contextNotesTodo.toast.planImported"))}catch(Z){const m=Z instanceof Error?Z.message:void 0;ve.error(o("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),m?{description:m}:void 0)}finally{Je(!1)}}},[s,o]),$e=l.useCallback(b=>{if(a){a({path:b.path,title:b.title});return}const Z=s?.path?.trim(),m=ke?.trim()||Z;m&&J(m,{mode:"plan",targetPath:b.path,dedupeKey:b.path,label:b.title})},[ke,a,J,s]);return s?t.jsxs("div",{className:K("w-full min-w-0 space-y-3 p-3",i),children:[t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("h3",{className:"min-w-0 truncate typography-ui-label font-semibold text-foreground",title:s.path,children:o("rightSidebar.contextNotesTodo.notes.title",{project:e?.trim()||s.path.split("/").filter(Boolean).pop()||s.path})}),t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[h.length,"/",ln]})]}),t.jsx(_n,{value:h,onChange:b=>c(b.target.value.slice(0,ln)),onBlur:pe,placeholder:o("rightSidebar.contextNotesTodo.notes.placeholder"),resizedHeight:de,onResizeHeightChange:G,useScrollShadow:!0,scrollShadowSize:56,disabled:u})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-label font-semibold text-foreground",children:o("rightSidebar.contextNotesTodo.todo.title")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:g.length===1?o("rightSidebar.contextNotesTodo.todo.itemsSingle",{count:g.length}):o("rightSidebar.contextNotesTodo.todo.itemsPlural",{count:g.length})}),t.jsx("button",{type:"button",onClick:se,disabled:u||Ue===0,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:o("rightSidebar.contextNotesTodo.todo.clearCompleted")})]}),t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[De.length,"/",os]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(ht,{value:De,onChange:b=>d(b.target.value.slice(0,os)),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),D())},placeholder:o("rightSidebar.contextNotesTodo.todo.inputPlaceholder"),disabled:u,className:"h-8"}),t.jsx("button",{type:"button",onClick:D,disabled:u||De.trim().length===0,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":o("rightSidebar.contextNotesTodo.todo.addAria"),title:o("rightSidebar.contextNotesTodo.todo.addAria"),children:t.jsx(P,{name:"add",className:"h-4 w-4"})})]}),t.jsx("div",{className:K("overflow-y-auto rounded-lg border border-border/60 bg-background/40",U&&"transition-none"),style:g.length<7?void 0:{height:`${ne}px`,maxHeight:`${ne}px`},children:g.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.todo.empty")}):t.jsx(or,{sensors:Te,collisionDetection:ir,onDragEnd:Se,children:t.jsx(cr,{items:g.map(b=>b.id),strategy:Vo,children:t.jsx("ul",{className:"divide-y divide-border/50",children:g.map(b=>{const Z=C.has(b.id);return t.jsx(ac,{id:b.id,children:m=>t.jsxs("div",{className:K("flex gap-1.5 px-2.5 py-1.5",Z?"items-start":"items-center"),children:[t.jsx("button",{type:"button",ref:m.setActivatorNodeRef,...m.attributes,...m.listeners,onClick:j=>{j.preventDefault(),j.stopPropagation()},className:"flex h-6 w-4 flex-shrink-0 touch-none items-center justify-center text-muted-foreground hover:text-foreground","aria-label":o("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:b.text}),title:o("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:b.text}),children:t.jsx(P,{name:"draggable",className:"h-3.5 w-3.5"})}),t.jsx("div",{className:"flex h-6 items-center",children:t.jsx(ss,{checked:b.completed,onChange:j=>X(b.id,j),ariaLabel:o("rightSidebar.contextNotesTodo.todo.actions.markComplete",{text:b.text})})}),t.jsx("button",{type:"button",onClick:()=>F(b.id),className:K("block min-h-6 min-w-0 flex-1 bg-transparent p-0 text-left typography-ui-label leading-normal text-foreground",Z?"whitespace-normal break-words":"overflow-hidden text-ellipsis whitespace-nowrap","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",b.completed&&"text-muted-foreground line-through"),title:Z?void 0:b.text,"aria-label":Z?o("rightSidebar.contextNotesTodo.todo.actions.collapse",{text:b.text}):o("rightSidebar.contextNotesTodo.todo.actions.expand",{text:b.text}),children:b.text}),t.jsxs("div",{className:"flex h-6 items-center gap-0.5",children:[t.jsx("button",{type:"button",onClick:()=>me(b.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":o("rightSidebar.contextNotesTodo.todo.actions.delete",{text:b.text}),title:o("rightSidebar.contextNotesTodo.todo.actions.delete",{text:b.text}),children:t.jsx(P,{name:"delete-bin",className:"h-3.5 w-3.5"})}),t.jsxs(Pt,{children:[t.jsx(Dt,{asChild:!0,children:t.jsx("button",{type:"button",disabled:y===b.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":o("rightSidebar.contextNotesTodo.todo.actions.send",{text:b.text}),title:o("rightSidebar.contextNotesTodo.todo.actions.send",{text:b.text}),children:t.jsx(P,{name:"send-plane",className:"h-3.5 w-3.5"})})}),t.jsxs(Et,{align:"end",className:"w-56",children:[t.jsx(jt,{onClick:()=>Ze(b.text),children:o("rightSidebar.contextNotesTodo.todo.sendMenu.currentSession")}),t.jsx(jt,{onClick:()=>Me(b.id,b.text),children:o("rightSidebar.contextNotesTodo.todo.sendMenu.newSession")}),t.jsx(jt,{onClick:()=>{Ee(b.id,b.text)},disabled:!n,children:o("rightSidebar.contextNotesTodo.todo.sendMenu.newWorktreeSession")})]})]})]})]})},b.id)})})})})}),g.length>=7&&t.jsx("div",{className:K("h-[3px] w-full cursor-row-resize hover:bg-[var(--interactive-border)]/80 transition-colors",U&&"bg-[var(--interactive-border)]"),onPointerDown:ae,role:"separator","aria-orientation":"horizontal","aria-label":o("rightSidebar.contextNotesTodo.todo.resizeAria")})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-label font-semibold text-foreground",children:o("rightSidebar.contextNotesTodo.plans.title")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:A.length===1?o("rightSidebar.contextNotesTodo.plans.filesSingle",{count:A.length}):o("rightSidebar.contextNotesTodo.plans.filesPlural",{count:A.length})})]}),t.jsx("input",{ref:Le,type:"file",accept:".md,.markdown,.txt,text/markdown,text/plain",className:"hidden",onChange:b=>{const Z=b.target.files?.[0]??null;et(Z),b.currentTarget.value=""}}),t.jsx("button",{type:"button",onClick:Pe,disabled:!s||ze,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":o("rightSidebar.contextNotesTodo.plans.importFromFile"),title:o("rightSidebar.contextNotesTodo.plans.importFromFile"),children:t.jsx(P,{name:"add",className:"h-3.5 w-3.5"})})]}),t.jsx("div",{className:"max-h-56 overflow-y-auto rounded-lg border border-border/60 bg-background/40",children:A.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.plans.empty")}):t.jsx("ul",{className:"divide-y divide-border/50",children:A.map(b=>t.jsxs("li",{className:"flex items-center gap-1.5 px-2.5 py-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>$e(b),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.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",children:b.title}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:new Date(b.createdAt).toLocaleDateString(Wn())})]}),t.jsx("button",{type:"button",onClick:()=>{Ke(b.id)},disabled:Be===b.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:o("rightSidebar.contextNotesTodo.plans.deletePlan"),"aria-label":o("rightSidebar.contextNotesTodo.plans.deletePlanWithTitle",{title:b.title}),children:t.jsx(P,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},b.id))})})]}),t.jsx(Ni,{open:w!==null,onOpenChange:b=>{!b&&!k&&N(null)},target:w?.kind??"session",projectDirectory:s?.path??null,submitting:k,onConfirm:He})]}):t.jsx("div",{className:K("w-full min-w-0 p-3",i),children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.empty.selectProject")})})},Sd=s=>{const e=Ge.c(19),{onActionComplete:n,onOpenPlan:r}=s,a=gt(ic),i=gt(lc),o=ns(cc),u=Hs(dc);let f;e:{if(a){let C;e[0]!==a||e[1]!==i?(C=i.find(I=>I.id===a)??i[0]??null,e[0]=a,e[1]=i,e[2]=C):C=e[2],f=C;break e}f=i[0]??null}const h=f;let c;e:{if(!h){c=null;break e}let C;e[3]!==h.id||e[4]!==h.path?(C={id:h.id,path:h.path},e[3]=h.id,e[4]=h.path,e[5]=C):C=e[5],c=C}const g=c;let p;e:{if(!h){p=null;break e}let C;e[6]!==h.label||e[7]!==h.path||e[8]!==o?(C=h.label?.trim()||Qa(h.path,o)||h.path,e[6]=h.label,e[7]=h.path,e[8]=o,e[9]=C):C=e[9],p=C}const x=p;let d;e:{if(!h){d=!1;break e}let C;e[10]!==h.path||e[11]!==u?(C=u.get(h.path)?.isGitRepo,e[10]=h.path,e[11]=u,e[12]=C):C=e[12],d=C===!0}const y=d;let v;return e[13]!==y||e[14]!==n||e[15]!==r||e[16]!==x||e[17]!==g?(v=t.jsx("div",{className:"h-full min-h-0 overflow-auto bg-background",children:t.jsx(oc,{projectRef:g,projectLabel:x,canCreateWorktree:y,onActionComplete:n,onOpenPlan:r})}),e[13]=y,e[14]=n,e[15]=r,e[16]=x,e[17]=g,e[18]=v):v=e[18],v};function ic(s){return s.activeProjectId}function lc(s){return s.projects}function cc(s){return s.homeDirectory}function dc(s){return s.directories}const fs=Object.freeze({chunks:Object.freeze([]),byteLength:0,lastSequence:-1}),Vs=512*1024,uc=new TextEncoder,mc=new TextDecoder,Ss=s=>{const e=uc.encode(s);if(e.byteLength<=Vs)return{text:s,byteLength:e.byteLength};let n=e.byteLength-Vs;for(;n<e.byteLength&&(e[n]&192)===128;)n+=1;const r=e.subarray(n);return{text:mc.decode(r),byteLength:r.byteLength}},Wt=(s,e)=>`${s}\0${e}`,Cs=(s,e)=>{let n=null;for(const r of s.keys())e(r)&&(n??=new Map(s),n.delete(r));return n},fc="terminal-store";let Mn=!1,Ln=0;const ds=()=>typeof globalThis.crypto?.randomUUID=="function"?`tab-${globalThis.crypto.randomUUID()}`:(Ln+=1,`tab-${Date.now().toString(36)}-${Ln.toString(36)}`),Is=s=>typeof s=="object"&&s!==null,hc=s=>{const e=/^tab-(\d+)$/.exec(s);if(!e)return null;const n=Number(e[1]);return Number.isFinite(n)?n:null};function ct(s){let e=s.trim();for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e}const pc=/^Terminal(?: (\d+))?$/,gc=s=>{let e=0;for(const n of s){const r=pc.exec(n.label);if(!r)continue;const a=r[1]?Number.parseInt(r[1],10):1;Number.isSafeInteger(a)&&(e=Math.max(e,a))}return e===0?"Terminal":`Terminal ${e+1}`},Ts=(s,e)=>({id:s,terminalSessionId:null,lifecycle:"idle",label:e,iconKey:null,isConnecting:!1,createdAt:Date.now(),previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1}),Ps=s=>({tabs:[s],activeTabId:s.id}),bt=(s,e)=>s.tabs.findIndex(n=>n.id===e);let Ds=null,Es=null;const xc=s=>{if(Es&&Ds?.sessions===s.sessions&&Ds.nextTabId===s.nextTabId)return Es;const e={sessions:Array.from(s.sessions.entries()).map(([n,r])=>[n,{activeTabId:r.activeTabId,tabs:r.tabs.map(a=>({id:a.id,label:a.label,iconKey:a.iconKey,createdAt:a.createdAt}))}]),nextTabId:s.nextTabId};return Ds={sessions:s.sessions,nextTabId:s.nextTabId},Es=e,e},bc=()=>{const s=Uo(()=>So());if(!s)return;let e=null;return{getItem:n=>s.getItem(n),setItem:(n,r)=>{if(r.state!==e)return e=r.state,s.setItem(n,r)},removeItem:n=>(e=null,s.removeItem(n))}},Xe=bs()(er(tr((s,e)=>({sessions:new Map,buffers:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1,hasHydrated:typeof window>"u",ensureDirectory:n=>{const r=ct(n);r&&s(a=>{if(a.sessions.has(r))return a;const i=new Map(a.sessions),o=ds(),u=Ts(o,"Terminal");return i.set(r,Ps(u)),{sessions:i,nextTabId:a.nextTabId+1}})},getDirectoryState:n=>{const r=ct(n);return e().sessions.get(r)},getActiveTab:n=>{const r=ct(n),a=e().sessions.get(r);if(!a)return;const i=a.activeTabId;return i?a.tabs.find(o=>o.id===i)??a.tabs[0]:a.tabs[0]},getBuffer:(n,r)=>e().buffers.get(Wt(ct(n),r))??fs,createTab:n=>{const r=ct(n);if(!r)return"tab-invalid";const a=ds();return s(i=>{const o=new Map(i.sessions),u=o.get(r),f=i.nextTabId+1,h=gc(u?.tabs??[]),c=Ts(a,h);return u?o.set(r,{...u,tabs:[...u.tabs,c]}):o.set(r,Ps(c)),{sessions:o,nextTabId:f}}),a},setActiveTab:(n,r)=>{const a=ct(n);s(i=>{const o=new Map(i.sessions),u=o.get(a);return!u||u.activeTabId===r||bt(u,r)<0?i:(o.set(a,{...u,activeTabId:r}),{sessions:o})})},setTabLabel:(n,r,a)=>{const i=ct(n),o=a.trim();o&&s(u=>{const f=new Map(u.sessions),h=f.get(i);if(!h)return u;const c=bt(h,r);if(c<0||h.tabs[c]?.label===o)return u;const g=[...h.tabs];return g[c]={...g[c],label:o},f.set(i,{...h,tabs:g}),{sessions:f}})},setTabIconKey:(n,r,a)=>{const i=ct(n);s(o=>{const u=new Map(o.sessions),f=u.get(i);if(!f)return o;const h=bt(f,r);if(h<0)return o;const c=a?.trim()||null;if(f.tabs[h]?.iconKey===c)return o;const g=[...f.tabs];return g[h]={...g[h],iconKey:c},u.set(i,{...f,tabs:g}),{sessions:u}})},closeTab:(n,r)=>{const a=ct(n);s(i=>{const o=new Map(i.sessions),u=o.get(a);if(!u)return i;const f=bt(u,r);if(f<0)return i;const h=u.tabs.filter(y=>y.id!==r),c=Object.fromEntries(Object.entries(i.projectActionRuns).filter(([,y])=>!(y.directory===a&&y.tabId===r))),g=Object.keys(c).length!==Object.keys(i.projectActionRuns).length,p=Wt(a,r),x=i.buffers.has(p)?Cs(i.buffers,y=>y===p):null;if(h.length===0){const y=ds(),v=Ts(y,"Terminal");return o.set(a,Ps(v)),{sessions:o,nextTabId:i.nextTabId+1,...x?{buffers:x}:{},...g?{projectActionRuns:c}:{}}}let d=u.activeTabId;return u.activeTabId===r&&(d=h[Math.min(f,h.length-1)]?.id??h[0]?.id??null),o.set(a,{...u,tabs:h,activeTabId:d}),{sessions:o,...x?{buffers:x}:{},...g?{projectActionRuns:c}:{}}})},setTabSessionId:(n,r,a)=>{const i=ct(n);s(o=>{const u=new Map(o.sessions),f=u.get(i);if(!f)return o;const h=bt(f,r);if(h<0)return o;const c=f.tabs[h],g=a!==null&&c.terminalSessionId!==a,p=a?"running":c.terminalSessionId?"exited":c.lifecycle,x={...c,terminalSessionId:a,lifecycle:p,isConnecting:!1},d=Wt(i,r),y=g&&o.buffers.has(d)?Cs(o.buffers,C=>C===d):null,v=[...f.tabs];return v[h]=x,u.set(i,{...f,tabs:v}),{sessions:u,...y?{buffers:y}:{}}})},setTabLifecycle:(n,r,a)=>{const i=ct(n);s(o=>{const u=new Map(o.sessions),f=u.get(i);if(!f)return o;const h=bt(f,r);if(h<0)return o;const c=[...f.tabs];return c[h]={...c[h],lifecycle:a,isConnecting:!1},u.set(i,{...f,tabs:c}),{sessions:u}})},setConnecting:(n,r,a)=>{const i=ct(n);s(o=>{const u=new Map(o.sessions),f=u.get(i);if(!f)return o;const h=bt(f,r);if(h<0)return o;const c=[...f.tabs];return c[h]={...c[h],isConnecting:a},u.set(i,{...f,tabs:c}),{sessions:u}})},replaceBuffer:(n,r,a,i)=>{const o=ct(n);s(u=>{const f=u.sessions.get(o);if(!f||bt(f,r)<0)return u;const h=Wt(o,r),c=u.buffers.get(h)??fs;if(c.lastSequence>i)return u;const g=Ss(a);if(c.lastSequence===i&&c.byteLength===g.byteLength&&c.chunks.map(d=>d.data).join("")===g.text)return u;const p=u.nextChunkId,x=new Map(u.buffers);return x.set(h,{chunks:g.text?[{id:p,data:g.text,byteLength:g.byteLength}]:[],byteLength:g.byteLength,lastSequence:i}),{buffers:x,nextChunkId:g.text?p+1:p}})},appendToBuffer:(n,r,a,i,o)=>{if(!a)return;const u=ct(n);s(f=>{const h=f.sessions.get(u);if(!h||bt(h,r)<0)return f;const c=Wt(u,r),g=f.buffers.get(c)??fs;if(i!==void 0&&i<=g.lastSequence)return f;const p=f.nextChunkId,x=Ss(a),d=o!==void 0&&o!==a?Ss(o).text:void 0,y={id:p,data:x.text,...d!==void 0?{replayData:d}:{},byteLength:x.byteLength},v=[...g.chunks,y];let C=g.byteLength+y.byteLength;for(;C>Vs&&v.length>1;){const A=v.shift();if(!A)break;C-=A.byteLength}const I=new Map(f.buffers);return I.set(c,{chunks:v,byteLength:C,lastSequence:i??g.lastSequence}),{buffers:I,nextChunkId:p+1}})},setTabPreviewUrl:(n,r,a,i={})=>{const o=ct(n);s(u=>{const f=new Map(u.sessions),h=f.get(o);if(!h)return u;const c=bt(h,r);if(c<0)return u;const g=h.tabs[c],p=i.autoOpened??g.previewAutoOpened,x=i.locked??g.previewUrlLocked;if(g.previewUrl===a&&g.previewAutoOpened===p&&g.previewUrlLocked===x)return u;const d=[...h.tabs];return d[c]={...g,previewUrl:a,previewAutoOpened:p,previewUrlLocked:x},f.set(o,{...h,tabs:d}),{sessions:f}})},markPreviewAutoOpened:(n,r)=>{const a=ct(n);s(i=>{const o=new Map(i.sessions),u=o.get(a);if(!u)return i;const f=bt(u,r);if(f<0)return i;const h=u.tabs[f];if(!h.previewUrl||h.previewAutoOpened)return i;const c=[...u.tabs];return c[f]={...h,previewAutoOpened:!0},o.set(a,{...u,tabs:c}),{sessions:o}})},setProjectActionRun:n=>{s(r=>{const a=r.projectActionRuns[n.key];return a&&a.directory===n.directory&&a.actionId===n.actionId&&a.tabId===n.tabId&&a.sessionId===n.sessionId&&a.status===n.status?r:{projectActionRuns:{...r.projectActionRuns,[n.key]:n}}})},updateProjectActionRunStatus:(n,r)=>{s(a=>{const i=a.projectActionRuns[n];return!i||i.status===r?a:{projectActionRuns:{...a.projectActionRuns,[n]:{...i,status:r}}}})},removeProjectActionRun:n=>{s(r=>{if(!r.projectActionRuns[n])return r;const a={...r.projectActionRuns};return delete a[n],{projectActionRuns:a}})},removeDirectory:n=>{const r=ct(n);s(a=>{const i=new Map(a.sessions);i.delete(r);const o=Wt(r,""),u=Cs(a.buffers,h=>h.startsWith(o)),f=Object.fromEntries(Object.entries(a.projectActionRuns).filter(([,h])=>h.directory!==r));return{sessions:i,...u?{buffers:u}:{},projectActionRuns:f}})},clearAll:()=>{s({sessions:new Map,buffers:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1})}}),{name:fc,storage:bc(),partialize:xc,merge:(s,e)=>{if(!Is(s))return e;const n=Array.isArray(s.sessions)?s.sessions:[],r=new Map;let a=0;for(const u of n){if(!Array.isArray(u)||u.length!==2)continue;const[f,h]=u;if(typeof f!="string"||!Is(h))continue;const c=Array.isArray(h.tabs)?h.tabs:[],g=[],p=new Map;for(const v of c){if(!Is(v))continue;const C=typeof v.id=="string"?v.id:null;if(!C)continue;const I=hc(C);I!==null&&(a=Math.max(a,I));const A=I===null?C:ds();p.set(C,A),g.push({id:A,label:typeof v.label=="string"?v.label:"Terminal",iconKey:typeof v.iconKey=="string"?v.iconKey:null,terminalSessionId:null,lifecycle:"idle",createdAt:typeof v.createdAt=="number"?v.createdAt:Date.now(),isConnecting:!1,previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1})}if(g.length===0)continue;const x=typeof h.activeTabId=="string"?h.activeTabId:null,d=x?p.get(x)??x:null,y=d?g.some(v=>v.id===d):!1;r.set(f,{tabs:g,activeTabId:y?d:g[0].id})}const i=typeof s.nextTabId=="number"&&Number.isFinite(s.nextTabId)?s.nextTabId:1,o=Math.max(e.nextTabId,i,a+1);return{...e,sessions:r,buffers:new Map,nextChunkId:1,nextTabId:o,hasHydrated:!0}}})));if(typeof window<"u"&&!Mn){Mn=!0;const s=Xe.persist,e=()=>{Xe.getState().hasHydrated||Xe.setState({hasHydrated:!0})};s?.hasHydrated?.()?e():s?.onFinishHydration?s.onFinishHydration(e):e()}function yc(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}}function wc(s,e,n,r,a=!1){const o=`${s}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`;return{cursorBlink:!1,cursorStyle:"bar",fontSize:e,fontFamily:o,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:a}}const Rs=["\x1B[0m","\x1B[m"],vc=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 i=n.length<=4?n.slice(0,3).split("").map(o=>o+o).join(""):n.slice(0,6);return[Number.parseInt(i.slice(0,2),16),Number.parseInt(i.slice(2,4),16),Number.parseInt(i.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 a=r.slice(1,4).map(Number);return a.some(i=>i<0||i>255)?null:a},Fn=s=>{const e=vc(s);return e?`\x1B[0;48;2;${e[0]};${e[1]};${e[2]}m`:null},kc=(s,e,n)=>{const r=e+s;if(!n)return{data:r,carry:""};let a=0;const i=Math.max(...Rs.map(f=>f.length))-1;for(let f=1;f<=Math.min(i,r.length);f+=1){const h=r.slice(-f);Rs.some(c=>c.length>h.length&&c.startsWith(h))&&(a=f)}const o=a>0?r.slice(-a):"";let u=a>0?r.slice(0,-a):r;for(const f of Rs)u=u.replaceAll(f,n);return{data:u,carry:o}},jc=(s,e,n,r,a)=>{if(n.width<=0||n.height<=0||r<=0||a<=0)return null;const i=Math.floor((s-n.left)/n.width*r),o=Math.floor((e-n.top)/n.height*a);return{column:Math.max(0,Math.min(r-1,i)),row:Math.max(0,Math.min(a-1,o))}},Nc=(s,e)=>{const n=Math.max(0,Math.min(s.length-1,e)),r=o=>!!(o&&!/^\s+$/u.test(o));if(!r(s[n]))return{startColumn:n,endColumn:n};let a=n,i=n;for(;a>0&&r(s[a-1]);)a-=1;for(;i<s.length-1&&r(s[i+1]);)i+=1;return{startColumn:a,endColumn:i}};let Sc=null;const Cc=()=>Sc??=Vt(()=>import("./vendor-ghostty-web-CrxinGGH.js"),__vite__mapDeps([113,5])).then(async s=>({module:s,ghostty:await s.Ghostty.load()})),Ic=2e3,Tc=()=>{if(typeof window>"u")return Promise.resolve();const s=window.__openchamberEnsureNerdFonts;return typeof s!="function"?Promise.resolve():Promise.race([Promise.resolve(s()).catch(()=>{}),new Promise(e=>setTimeout(e,Ic))]).then(()=>{})},Pc=(s,e,n)=>{if(typeof window>"u"||typeof document>"u")return null;const r=document.createElement("canvas").getContext("2d");if(!r||s.clientWidth<24||s.clientHeight<24)return null;r.font=`${n}px ${e}`;const a=r.measureText("M"),i=Math.ceil(a.width),o=Math.ceil((a.actualBoundingBoxAscent||n*.8)+(a.actualBoundingBoxDescent||n*.2))+2;if(i<1||o<1)return null;const u=window.getComputedStyle(s),f=(Number.parseInt(u.paddingLeft,10)||0)+(Number.parseInt(u.paddingRight,10)||0),h=(Number.parseInt(u.paddingTop,10)||0)+(Number.parseInt(u.paddingBottom,10)||0);return{cols:Math.max(2,Math.floor((s.clientWidth-f-15)/i)),rows:Math.max(1,Math.floor((s.clientHeight-h)/o))}},Nr=l.forwardRef(({sessionKey:s,chunks:e,onInput:n,onResize:r,theme:a,fontFamily:i,fontSize:o,className:u,enableTouchScroll:f=!1,autoFocus:h=!0,isVisible:c=!0},g)=>{const p=l.useRef(null),x=l.useRef(null),d=l.useRef(null),y=l.useRef(n),v=l.useRef(r),C=l.useRef(null),I=l.useRef(null),A=l.useRef(null),V=l.useRef(""),w=l.useRef(""),N=l.useRef(Fn(a.background)),k=l.useRef(!1),M=l.useRef(0),te=l.useRef(c),q=l.useRef(!1),[L,W]=l.useState(0),[O,ne]=l.useState(0);y.current=n,v.current=r,te.current=c,N.current=Fn(a.background),l.useLayoutEffect(()=>{const U=p.current;if(!U)return;const R=Pc(U,i,o);I.current=R,R&&v.current(R.cols,R.rows)},[i,o]);const z=l.useCallback(()=>{const U=p.current,R=x.current;if(!U||!R||!d.current||!te.current)return;const B=U.getBoundingClientRect();if(!(B.width<24||B.height<24))try{d.current.fit();const $={cols:R.cols,rows:R.rows};(!C.current||C.current.cols!==$.cols||C.current.rows!==$.rows)&&(C.current=$,v.current($.cols,$.rows)),q.current||(q.current=!0,W(H=>H+1))}catch{}},[]),de=l.useCallback(()=>{if(k.current||!V.current||!x.current)return;const U=x.current,R=V.current;V.current="";const B=kc(R,w.current,N.current);if(w.current=B.carry,!B.data){V.current&&de();return}k.current=!0;const $=M.current;U.write(B.data,()=>{x.current!==U||M.current!==$||(k.current=!1,V.current&&de())})},[]),G=l.useCallback(()=>{A.current=null,V.current="",w.current="",k.current=!1,M.current+=1;const U=x.current;if(!U){ne(R=>R+1);return}try{U.reset();const R=N.current;R&&U.write(`${R}\x1B[2J\x1B[H`)}catch{ne(R=>R+1)}},[]);return l.useEffect(()=>{const U=p.current;if(!U)return;let R=!1,B=null,$=null,H=null,E=null,re=[];const ue=()=>{B&&te.current&&(B.options.cursorBlink=!0)},he=J=>{J.relatedTarget instanceof Node&&U.contains(J.relatedTarget)||B&&(B.options.cursorBlink=!1)},Ce=()=>{B&&te.current&&U.contains(document.activeElement)&&(B.options.cursorBlink=!0)},ke=()=>{B&&(B.options.cursorBlink=!1)};return U.addEventListener("focusin",ue),U.addEventListener("focusout",he),window.addEventListener("focus",Ce),window.addEventListener("blur",ke),Promise.all([Cc(),Tc()]).then(([{module:J,ghostty:be}])=>{if(R)return;B=new J.Terminal({...wc(i,o,a,be,!1),...I.current??{}});const _=new J.FitAddon;B.loadAddon(_),B.open(U),x.current=B,d.current=_,re=[B.onData(Y=>y.current(Y))],$=new ResizeObserver(()=>{H&&clearTimeout(H),H=setTimeout(z,80)}),$.observe(U),z();const le=N.current;le&&B.write(`${le}\x1B[2J\x1B[H`),E=requestAnimationFrame(z)}),()=>{R=!0;const J=document.activeElement;J instanceof HTMLElement&&U.contains(J)&&(J.blur(),window.Capacitor?.getPlatform?.()==="android"&&Vt(async()=>{const{Keyboard:_}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:_}},__vite__mapDeps([114,115])).then(({Keyboard:_})=>_.hide()).catch(()=>{})),$?.disconnect(),H&&clearTimeout(H),E!==null&&cancelAnimationFrame(E),U.removeEventListener("focusin",ue),U.removeEventListener("focusout",he),window.removeEventListener("focus",Ce),window.removeEventListener("blur",ke),re.forEach(be=>be.dispose()),B?.dispose(),x.current=null,d.current=null,C.current=null,A.current=null,V.current="",w.current="",k.current=!1,M.current+=1,q.current=!1}},[z,i,o,O,a]),l.useEffect(()=>{const U=x.current,R=p.current;!U||!R||(U.options.cursorBlink=c&&document.hasFocus()&&R.contains(document.activeElement))},[c,L]),l.useEffect(()=>{if(!x.current)return;if(e.length===0){A.current!==null&&G();return}const R=A.current;let B=-1;if(R!==null){for(let E=e.length-1;E>=0;E-=1){const re=e[E].id;if(re===R){B=E;break}if(re<R)break}if(B<0){G();return}}const $=B<0,H=B>=0?e.slice(B+1):e;V.current+=H.map(E=>$?E.replayData??E.data:E.data).join(""),A.current=e.at(-1)?.id??null,de()},[e,de,L,G]),l.useEffect(()=>{if(!h||!c)return;const U=requestAnimationFrame(()=>x.current?.focus());return()=>cancelAnimationFrame(U)},[h,c,L,s]),l.useEffect(()=>{const U=p.current;if(!f||!U)return;const R=B=>{const $=B;if(!$.isComposing)switch($.inputType){case"insertText":$.data&&y.current($.data);break;case"insertLineBreak":case"insertParagraph":y.current("\r");break;case"deleteContentBackward":y.current("");break}};return U.addEventListener("beforeinput",R),()=>U.removeEventListener("beforeinput",R)},[f,L]),l.useEffect(()=>{const U=p.current,R=x.current;if(!f||!U||!R)return;let B=null,$=null,H="idle",E=0,re=0,ue=0,he=0,Ce=null;const ke=Math.max(12,o+2),J=()=>{window.Capacitor?.getPlatform?.()==="android"&&Vt(async()=>{const{Keyboard:X}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:X}},__vite__mapDeps([114,115])).then(({Keyboard:X})=>X.show()).catch(()=>{})},be=()=>{$&&(clearTimeout($),$=null)},_=(F,X)=>{const me=U.querySelector("canvas");return me?jc(F,X,me.getBoundingClientRect(),R.cols,R.rows):null},le=(F,X)=>{const me=U.querySelector("canvas");if(!me)return;const se=me.getBoundingClientRect(),Se=se.left+(X.column+.5)/R.cols*se.width,Te=se.top+(X.row+.5)/R.rows*se.height;me.dispatchEvent(new MouseEvent(F,{bubbles:!0,cancelable:!0,button:0,buttons:1,clientX:Se,clientY:Te}))},Y=()=>{document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0,buttons:0}))},ae=F=>{F.pointerType!=="touch"||B!==null||(B=F.pointerId,H="pending",E=F.clientX,re=F.clientY,ue=F.clientY,he=0,Ce=null,U.setPointerCapture(F.pointerId),$=setTimeout(()=>{if($=null,B!==F.pointerId||H!=="pending")return;const X=_(E,re);if(!X)return;const me=R.buffer.active,se=Math.max(0,me.length-R.rows-me.viewportY+X.row),Se=me.getLine(se),Te=Array.from({length:R.cols},(Ve,Me)=>Se?.getCell(Me)?.getChars()??""),De=Nc(Te,X.column),Ue={column:De.startColumn,row:X.row};Ce={column:De.endColumn,row:X.row},H="selecting",le("mousedown",Ue),le("mousemove",Ce)},350))},ce=F=>{if(B!==F.pointerId)return;if(H==="selecting"){const se=_(F.clientX,F.clientY);se&&(!Ce||se.column!==Ce.column||se.row!==Ce.row)&&(Ce=se,le("mousemove",se)),F.cancelable&&F.preventDefault();return}if(H==="pending"){if(Math.hypot(F.clientX-E,F.clientY-re)<8)return;be(),H="scrolling"}if(H!=="scrolling")return;const X=ue-F.clientY;ue=F.clientY,he+=X;const me=Math.trunc(he/ke);me&&(R.scrollLines(me),he-=me*ke),F.cancelable&&F.preventDefault()},pe=F=>{if(B!==F.pointerId)return;const X=H==="pending",me=H==="selecting";be(),U.hasPointerCapture(F.pointerId)&&U.releasePointerCapture(F.pointerId),B=null,H="idle",me&&Y(),X&&(R.focus(),J())},D=F=>{if(B!==F.pointerId)return;const X=H==="selecting";be(),U.hasPointerCapture(F.pointerId)&&U.releasePointerCapture(F.pointerId),B=null,H="idle",X&&Y()};return U.addEventListener("pointerdown",ae),U.addEventListener("pointermove",ce,{passive:!1}),U.addEventListener("pointerup",pe),U.addEventListener("pointercancel",D),()=>{be(),U.removeEventListener("pointerdown",ae),U.removeEventListener("pointermove",ce),U.removeEventListener("pointerup",pe),U.removeEventListener("pointercancel",D)}},[f,o,L]),l.useImperativeHandle(g,()=>({focus:()=>x.current?.focus(),fit:z,getSelection:()=>{const U=x.current,R=U?.getSelectionPosition(),B=U?.getSelection()??"";return!R||!B.trim()?null:{text:B,startLine:R.start.y+1,endLine:R.end.y+1}}}),[z]),t.jsx("div",{ref:p,"data-terminal-owner":"main",className:K("terminal-viewport-container h-full w-full overflow-hidden touch-none",u)})});Nr.displayName="TerminalViewport";const Dc="\x1B",Ec=new RegExp(`${Dc}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Rc=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,Ac=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,Bc=/Serving HTTP on .*? port (\d{2,5})/i,Mc=new Set([".",",",";",":","!","?"]),Lc=s=>{let e=s;for(;e.length>0;){const n=e[e.length-1];if(n===")"||n==="]"||n==="}"||n===">"){const r=n===")"?"(":n==="]"?"[":n==="}"?"{":"<",a=e.slice(0,-1),i=(a.match(new RegExp(`\\${r}`,"g"))||[]).length,o=(a.match(new RegExp(`\\${n}`,"g"))||[]).length;if(i>o)break;e=a;continue}if(Mc.has(n)){e=e.slice(0,-1);continue}break}return e},On=s=>{let e=Lc(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},Fc=s=>{if(!s)return null;const e=s.replace(Ec,""),n=e.match(Bc);if(n?.[1]){const a=Number.parseInt(n[1],10);if(Number.isFinite(a)&&a>0&&a<=65535)return`http://127.0.0.1:${a}/`}const r=e.split(`
|
|
7
|
-
`);for(const a of r){if(!Ac.test(a))continue;const i=Array.from(a.matchAll(Rc));if(i.length===0)continue;const o=i.find(u=>{try{return!!new URL(On(u[1])).port}catch{return!1}});return On((o??i[0])[1])}return null},Oc=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 a=new AbortController,i=window.setTimeout(()=>a.abort(),e);try{const o=await Nt("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:n.toString()}),cache:"no-store",signal:a.signal});return o.ok?(await o.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(i)}},Uc={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},Wc=(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 Uc[s]},Sr=s=>{const e=s[0]?.toUpperCase();return!e||e<"A"||e>"Z"?null:String.fromCharCode(e.charCodeAt(0)&31)},$c=(s,e)=>s&&(e==="ctrl"?Sr(s)??s:s.length===1&&s!=="\x1B"?`\x1B${s}`:s),Un={cols:80,rows:24},Cd=({visible:s})=>{const{t:e}=nt(),{terminal:n,runtime:r}=Gs(),{currentTheme:a}=Gn(),i=l.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:o}=Xa(),u=Ae(T=>T.terminalFontSize),f=Ae(T=>T.terminalShell),h=Ae(T=>T.terminalLoginShells.includes(T.terminalShell)),{isMobile:c,isTablet:g,hasTouchOnlyPointer:p}=xs(),x=c||g,d=(x||p)&&r.platform==="web",y=r.platform!=="vscode",v=Ae(T=>T.showTerminalQuickKeysOnDesktop),C=x||v,I=rt(T=>T.currentSessionId),A=rt(T=>T.newSessionDraft),V=I!==null||A?.open===!0,w=Za()??null,N=Xe(T=>w?T.sessions.get(w):void 0),k=Xe(T=>T.hasHydrated),M=Xe(T=>T.ensureDirectory),te=Xe(T=>T.createTab),q=Xe(T=>T.setActiveTab),L=Xe(T=>T.closeTab),W=Xe(T=>T.setTabSessionId),O=Xe(T=>T.setTabLifecycle),ne=Xe(T=>T.setConnecting),z=Xe(T=>T.appendToBuffer),de=Xe(T=>T.replaceBuffer),G=Xe(T=>T.setTabPreviewUrl),U=eo(T=>T.addDraft),R=Ae(T=>T.openContextPreview),B=l.useMemo(()=>N?y?N.activeTabId??N.tabs[0]?.id??null:N.tabs[0]?.id??null:null,[N,y]),$=l.useMemo(()=>{if(N)return B?N.tabs.find(T=>T.id===B)??N.tabs[0]:N.tabs[0]},[N,B]),H=l.useMemo(()=>(N?.tabs??[]).map(T=>({icon:(()=>{const oe=T.iconKey?pr[T.iconKey]??"terminal":"terminal";return t.jsx(P,{name:oe,className:"h-4 w-4"})})(),id:T.id,label:T.label,title:T.label,closeLabel:e("terminalView.tabs.closeTabTitle")})),[N?.tabs,e]),E=$?.terminalSessionId??null,re=$?.lifecycle??"idle",ue=Xe(T=>w&&B?T.getBuffer(w,B).chunks:fs.chunks),he=$?.isConnecting??!1,Ce=$?.previewUrl??null,[ke,J]=l.useState(null),[be,_]=l.useState(!1),[le,Y]=l.useState(!1),[ae,ce]=l.useState(null),[pe,D]=l.useState(!1),F=l.useRef(null),X=l.useRef(null),me=l.useRef(B),se=l.useRef(E),Se=l.useRef(w),Te=l.useRef(null),De=l.useRef(null),Ue=l.useRef(new Set),Ve=l.useRef(""),Me=l.useRef(new Set),Ze=l.useRef(0),Ee=l.useCallback(()=>{Ve.current="",Me.current.clear(),Ze.current+=1},[]),He=l.useCallback(()=>{d||typeof document<"u"&&!document.hasFocus()||Te.current?.focus()},[d]),Le=l.useCallback(()=>{d||Te.current?.focus()},[d]),Je=Ae(T=>T.activeMainTab)==="terminal",Be=s??Je,[Qe,Ke]=l.useState(Be);l.useEffect(()=>{Be&&Ke(!0)},[Be]),l.useEffect(()=>{se.current=E},[E]),l.useEffect(()=>{!E||!n.updateAppearance||n.updateAppearance(E,i.current).catch(()=>{})},[a.colors.surface.background,a.colors.syntax.base.foreground,a.metadata.variant,n,E]),l.useEffect(()=>{me.current=B,Ee()},[B,Ee]),l.useEffect(()=>{Se.current=w},[w]),l.useEffect(()=>{!C&&ae!==null&&ce(null)},[C,ae,ce]),l.useEffect(()=>{!E&&ae!==null&&ce(null)},[E,ae,ce]);const Pe=l.useCallback(()=>{F.current?.(),F.current=null,X.current=null,Y(!1)},[]);l.useEffect(()=>()=>{Pe(),se.current=null},[Pe]);const et=l.useCallback((T,oe,ge)=>{if(!ge)return;const Ye=`${Ve.current}${ge}`.replace(/\r\n|\r/g,`
|
|
8
|
-
`),je=Ye.split(`
|
|
9
|
-
`),fe=Ye.endsWith(`
|
|
10
|
-
`)?je.join(`
|
|
11
|
-
`):je.slice(0,-1).join(`
|
|
12
|
-
`);if(Ve.current=Ye.endsWith(`
|
|
13
|
-
`)?"":(je[je.length-1]??"").slice(-1024),!fe)return;const ie=Fc(fe);if(!ie||Me.current.has(ie))return;const We=Ze.current;Me.current.add(ie),Oc(ie).then(it=>{if(Me.current.delete(ie),!it||Ze.current!==We)return;const ut=Xe.getState().getDirectoryState(T)?.tabs.find(wt=>wt.id===oe);!ut||ut.previewUrlLocked||ut.previewUrl===ie||G(T,oe,ie,{locked:!1,autoOpened:!1})})},[G]),$e=l.useCallback((T,oe,ge)=>{if(X.current===ge)return;Pe(),X.current=ge;const Ye=n.connect(ge,{onEvent:je=>{if(X.current===ge)switch(je.type){case"snapshot":{ne(T,oe,!1),J(null),_(!1),Y(!1),He(),de(T,oe,je.data??"",je.sequence??0),et(T,oe,je.data??""),je.status==="exited"&&O(T,oe,"exited");break}case"reconnecting":{J(null),_(!1),Y(!0);break}case"data":{je.data&&(z(T,oe,je.data,je.sequence,je.replayData),et(T,oe,je.data));break}case"exit":{const fe=typeof je.exitCode=="number"?je.exitCode:null,ie=typeof je.signal=="number"?je.signal:null,it=!!Xe.getState().getDirectoryState(T)?.tabs.find(ut=>ut.id===oe)?.label?.startsWith("Action:");z(T,oe,e("terminalView.stream.processExitedMessage",{exitCodeSegment:fe!==null?e("terminalView.stream.processExitedWithCode",{exitCode:fe}):"",signalSegment:ie!==null?e("terminalView.stream.processExitedWithSignal",{signal:ie}):""})),O(T,oe,"exited"),ne(T,oe,!1),J(it?null:e("terminalView.error.sessionEnded")),_(!1),Y(!1),Pe();break}}},onError:(je,fe)=>{if(X.current===ge){if(!fe){J(null),_(!1);return}if(Y(!1),je.code==="SESSION_NOT_FOUND"&&!Xe.getState().getDirectoryState(T)?.tabs.find(We=>We.id===oe)?.label?.startsWith("Action:")){J(null),_(!1),ne(T,oe,!1),W(T,oe,null),O(T,oe,"idle"),Pe();return}J(e("terminalView.error.connectionFailed",{message:je.message})),_(!0),ne(T,oe,!1),O(T,oe,"exited"),W(T,oe,null),Pe()}}});F.current=()=>{Ye.close(),X.current=null}},[z,de,Pe,He,et,ne,O,W,e,n]);l.useEffect(()=>{let T=!1;if(!k||!Qe)return;if(!w){J(e(V?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),Pe();return}return(async()=>{const ge=w;if(!Se.current||Se.current!==ge)return;if(!Xe.getState().getDirectoryState(ge)){M(ge);return}const je=Xe.getState().getDirectoryState(ge);if(!je||je.tabs.length===0)return;const fe=y?je.activeTabId??je.tabs[0]?.id??null:je.tabs[0]?.id??null;if(!fe)return;const ie=je.tabs.find(vt=>vt.id===fe)??je.tabs[0],We=ie?.terminalSessionId??null,it=ie?.lifecycle??"idle",ut=!!ie?.label?.startsWith("Action:"),wt=Xe.getState().getBuffer(ge,fe),Rt=wt.byteLength>0||wt.chunks.length>0;if(!We){if(it==="exited"){ne(ge,fe,!1);return}if(ut&&Rt){ne(ge,fe,!1);return}const vt=`${ge}\0${fe}`;if(Ue.current.has(vt))return;const kt=De.current??Un;Ue.current.add(vt),J(null),_(!1),Y(!1),ne(ge,fe,!0);try{const Tt=await n.createSession({cwd:ge,sessionId:fe,cols:kt.cols,rows:kt.rows,shell:f,loginShell:h,...i.current}),Ot=!T&&Se.current===ge&&me.current===fe;if(!Xe.getState().getDirectoryState(ge)?.tabs.find(Cr=>Cr.id===fe)){try{await n.close(Tt.sessionId)}catch{}return}if(W(ge,fe,Tt.sessionId),!Ot)return;const mt=De.current;mt&&(mt.cols!==kt.cols||mt.rows!==kt.rows)&&n.resize({sessionId:Tt.sessionId,...mt}).catch(()=>{});return}catch(Tt){const Ot=Xe.getState().getDirectoryState(ge)?.tabs.find(rs=>rs.id===fe);if(!Ot||Ot.terminalSessionId||(ne(ge,fe,!1),Se.current!==ge||me.current!==fe))return;J(Tt instanceof Error?Tt.message:e("terminalView.error.startSessionFailed")),_(!0),Y(!1);return}finally{Ue.current.delete(vt)}}!We||T||(se.current=We,$e(ge,fe,We))})(),()=>{T=!0,se.current=null,Pe()}},[V,w,E,re,B,Qe,y,k,M,ne,O,W,$e,Pe,e,n,h,f]),l.useEffect(()=>{if(!Be||d)return;if(typeof window>"u"){He();return}const T=window.requestAnimationFrame(()=>{He()});return()=>{window.cancelAnimationFrame(T)}},[B,He,Be,d]);const b=l.useCallback(async()=>{if(!w||pe)return;const T=Xe.getState().getDirectoryState(w),oe=y?B??T?.activeTabId??T?.tabs[0]?.id??null:T?.tabs[0]?.id??null;if(!oe)return;const ge=T?.tabs.find(Ye=>Ye.id===oe)?.terminalSessionId??null;if(!(!ge||!n.restartSession)){D(!0),J(null),_(!1),Y(!1),Pe(),Ee();try{const Ye=De.current??Un,je=await n.restartSession(ge,{cwd:w,shell:f,loginShell:h,...Ye,...i.current});if(Xe.getState().getDirectoryState(w)?.tabs.find(ie=>ie.id===oe)?.terminalSessionId!==ge||(W(w,oe,je.sessionId),O(w,oe,"running"),Se.current!==w||me.current!==oe))return;se.current=je.sessionId,$e(w,oe,je.sessionId)}catch(Ye){if(Xe.getState().getDirectoryState(w)?.tabs.find(fe=>fe.id===oe)?.terminalSessionId!==ge||Se.current!==w||me.current!==oe)return;J(Ye instanceof Error?Ye.message:e("terminalView.error.restartFailed")),_(!1),Y(!1),se.current=ge,$e(w,oe,ge)}finally{D(!1)}}},[B,Pe,w,y,pe,Ee,O,W,$e,e,n,h,f]),Z=l.useCallback(async()=>{await b()},[b]),m=l.useCallback(()=>{if(!w)return;const T=te(w);q(w,T),J(null),_(!1),Y(!1),Pe()},[te,Pe,w,q]),j=l.useCallback(()=>{const T=Te.current?.getSelection(),oe=I??(A?.open?"draft":null);!T||!oe||!$||!w||U({directory:w,sessionKey:oe},{source:"terminal",fileLabel:$.label,startLine:T.startLine,endLine:T.endLine,code:T.text,language:$.terminalSessionId??$.id,text:""})},[$,U,I,w,A?.open]),ee=l.useCallback(T=>{w&&(q(w,T),J(null),_(!1),Y(!1),Pe())},[Pe,w,q]),ye=l.useCallback(T=>{if(!w)return;T===B&&Pe(),J(null),_(!1),Y(!1);const oe=Xe.getState().getDirectoryState(w)?.tabs.find(ge=>ge.id===T)?.terminalSessionId;(async()=>{oe&&await n.close(oe),L(w,T)})().catch(ge=>J(ge instanceof Error?ge.message:e("terminalView.error.sessionEnded")))},[B,L,Pe,w,e,n]),xe=l.useCallback(T=>{if(!T||le)return;let oe=T,ge=!1;ae&&T.length>0&&(oe=$c(T,ae),ge=!0);const Ye=se.current;Ye&&(n.sendInput(Ye,oe).catch(je=>{le||J(je instanceof Error?je.message:e("terminalView.error.sendInputFailed"))}),ge&&(ce(null),Le()))},[ae,Le,le,ce,e,n]),Oe=l.useCallback((T,oe)=>{const ge=De.current;if((!ge||ge.cols!==T||ge.rows!==oe)&&(De.current={cols:T,rows:oe}),!Be)return;const Ye=se.current;Ye&&n.resize({sessionId:Ye,cols:T,rows:oe}).catch(()=>{})},[Be,n]),tt=l.useCallback(T=>{ce(oe=>oe===T?null:T),Le()},[Le,ce]),qe=l.useCallback(T=>{const oe=Wc(T,ae);oe&&(xe(oe),ce(null),Le())},[ae,Le,xe,ce]),Re=l.useMemo(()=>({Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc"}),[]),S=l.useCallback(T=>{if(T.repeat)return;const oe=T.key;if(!oe||oe==="Control"||oe==="Meta"||oe==="Alt"||oe==="Shift")return;const ge=oe.length===1?oe.toLowerCase():oe;if(ge in Re){T.preventDefault(),T.stopPropagation(),qe(Re[ge]);return}if(ae!=="ctrl")return;const Ye=T.code??"",je=oe.length===1&&/[a-zA-Z]/.test(oe)?oe.toUpperCase():Ye.startsWith("Key")&&Ye.length===4?Ye.slice(3).toUpperCase():null;if(je&&je.length===1&&je>="A"&&je<="Z"){const fe=Sr(je);if(!fe)return;T.preventDefault(),T.stopPropagation(),xe(fe),ce(null),Le()}},[ae,Le,qe,xe,Re,ce]);l.useEffect(()=>{if(!(!C||!ae||!E))return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[ae,S,C,E]);const we=l.useMemo(()=>{const T=Ht[vs].stack;if(typeof window>"u")return(Ht[o]??Ht[vs]).stack;const ge=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return ge&&ge.trim().length>0?ge.trim():(Ht[o]??Ht[vs]).stack??T},[o]),Ie=l.useMemo(()=>yc(a),[a]),Fe=`${w??"no-dir"}::${B??"no-tab"}`;if(l.useEffect(()=>{if(!Be||d)return;const T=Te.current;if(!T)return;const oe=()=>{T.fit()};if(typeof window<"u"){const ge=window.requestAnimationFrame(()=>{oe(),He()}),Ye=[220,400].map(je=>window.setTimeout(oe,je));return()=>{window.cancelAnimationFrame(ge),Ye.forEach(je=>window.clearTimeout(je))}}oe()},[He,Be,d,Fe,E]),l.useEffect(()=>{if(!Be||!d)return;let T=null;const oe=()=>{T!==null&&window.cancelAnimationFrame(T),T=window.requestAnimationFrame(()=>{T=null,Te.current?.fit()})};return window.addEventListener("oc:keyboard-settled",oe),()=>{window.removeEventListener("oc:keyboard-settled",oe),T!==null&&window.cancelAnimationFrame(T)}},[Be,Fe,d]),!V)return t.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:e("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:e("terminalView.empty.noWorkingDirectoryForSession")}),t.jsx("button",{onClick:b,className:"rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:e("terminalView.actions.retry")})]});const st=!E||he||pe||le,ot=Qe,at=x?"lg":"xs",dt=x?"w-10 p-0":"w-9 p-0",_e=T=>{x&&T.preventDefault()},ft=t.jsxs(t.Fragment,{children:[t.jsx(Ne,{type:"button",size:at,variant:"outline",onPointerDown:_e,onClick:()=>qe("esc"),disabled:st,children:e("terminalView.quickKeys.escape")}),t.jsxs(Ne,{type:"button",size:at,variant:"outline",className:dt,onPointerDown:_e,onClick:()=>qe("tab"),disabled:st,children:[t.jsx(P,{name:"arrow-right",className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.tabAria")})]}),t.jsxs(Ne,{type:"button",size:at,variant:"chip","aria-pressed":ae==="ctrl",className:x?"px-3":"px-2",onPointerDown:_e,onClick:()=>tt("ctrl"),disabled:st,children:[t.jsx("span",{className:"text-xs font-medium",children:e("terminalView.quickKeys.controlLabel")}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.controlModifierAria")})]}),t.jsxs(Ne,{type:"button",size:at,variant:"chip","aria-pressed":ae==="alt",className:x?"px-3":"px-2",onPointerDown:_e,onClick:()=>tt("alt"),disabled:st,children:[t.jsx("span",{className:"text-xs font-medium",children:e("terminalView.quickKeys.altLabel")}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.altModifierAria")})]}),t.jsxs(Ne,{type:"button",size:at,variant:"outline",className:dt,onPointerDown:_e,onClick:()=>qe("arrow-up"),disabled:st,children:[t.jsx(P,{name:"arrow-up"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowUpAria")})]}),t.jsxs(Ne,{type:"button",size:at,variant:"outline",className:dt,onPointerDown:_e,onClick:()=>qe("arrow-left"),disabled:st,children:[t.jsx(P,{name:"arrow-left"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowLeftAria")})]}),t.jsxs(Ne,{type:"button",size:at,variant:"outline",className:dt,onPointerDown:_e,onClick:()=>qe("arrow-down"),disabled:st,children:[t.jsx(P,{name:"arrow-down"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowDownAria")})]}),t.jsxs(Ne,{type:"button",size:at,variant:"outline",className:dt,onPointerDown:_e,onClick:()=>qe("arrow-right"),disabled:st,children:[t.jsx(P,{name:"arrow-right"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowRightAria")})]}),t.jsxs(Ne,{type:"button",size:at,variant:"outline",className:dt,onPointerDown:_e,onClick:()=>qe("enter"),disabled:st,children:[t.jsx(P,{name:"arrow-go-back"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.enterAria")})]})]});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[t.jsxs("div",{className:K("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:[y&&N?t.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1",children:[t.jsx("div",{className:K("min-w-0 flex-1",x?"h-8":"h-7"),children:t.jsx(Qt,{items:H,activeId:B,onSelect:ee,onClose:ye,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),t.jsx(Ne,{type:"button",size:"xs",variant:"ghost",className:K("shrink-0",x?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:m,title:e("terminalView.tabs.newTabTitle"),children:t.jsx(P,{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(Ne,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{b()},disabled:pe,title:e("terminalView.actions.restart"),"aria-label":e("terminalView.actions.restart"),children:t.jsx(P,{name:"restart",className:"h-4 w-4"})}),t.jsx(Ne,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:j,title:e("terminalView.actions.attachSelection"),"aria-label":e("terminalView.actions.attachSelection"),children:t.jsx(P,{name:"attachment-2",className:"h-4 w-4"})}),Ce?t.jsxs(Ne,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{w&&R(w,Ce)},title:e("terminalView.preview.openTitle"),children:[t.jsx(P,{name:"global",className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"whitespace-nowrap",children:e("terminalView.preview.open")})]}):null]})]}):null,!x&&C&&y&&N?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:ft}):null,!x&&C&&(!y||!N)?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:ft}):null]}),t.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:Ie.background},children:[t.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:ot?t.jsx(Nr,{ref:T=>{Te.current=T},sessionKey:Fe,chunks:ue,onInput:xe,onResize:Oe,theme:Ie,fontFamily:we,fontSize:u,enableTouchScroll:d,autoFocus:Be,isVisible:Be},Fe):null}),!le&&ke&&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:ke}),be&&x&&t.jsx(Ne,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:Z,disabled:pe,title:e("terminalView.actions.hardRestartTitle"),type:"button",children:e("terminalView.actions.hardRestart")})]})]}),x&&C?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:ft})}):null]})},Id=()=>{Zn(),_t.reconnectToRuntimeBaseUrl(),Yn()},Td=s=>{rt.getState().prepareForRuntimeSwitch(s.previousRuntimeKey),Ae.getState().prepareForRuntimeSwitch(s.previousRuntimeKey),s.previousRuntimeKey&&to.getState().stopRunningRunsForRuntime(s.previousRuntimeKey),Zn(),Xe.getState().clearAll(),_t.reconnectToRuntimeBaseUrl(),pt.setState({providers:[],agents:[],isConnected:!1,isInitialized:!1,connectionPhase:"connecting",lastDisconnectReason:null}),gt.getState().resetForRuntimeSwitch(),As.getState().resetForRuntimeSwitch(),so.setState({statusById:new Map}),no(),ro(),ao.getState().reset(),Co.getState().resetForRuntimeSwitch(),Hs.getState().resetForRuntimeSwitch(s.runtimeKey),oo.getState().resetForRuntimeSwitch(),io.getState().resetForRuntimeSwitch(s.runtimeKey),Io.getState().resetForRuntimeSwitch(s.runtimeKey),rt.getState().restoreForRuntimeSwitch(s.runtimeKey),Ae.getState().restoreForRuntimeSwitch(s.runtimeKey),Yn(),queueMicrotask(()=>{To()})};export{ml as A,xd as B,rd as C,kd as D,fd as E,Yl as F,gd as G,sd as H,Bt as I,hl as J,pl as K,Ns as L,Nd as M,jd as N,nd as O,Sd as P,Ni as Q,ed as R,wd as S,Cd as T,td as U,vd as V,Ji as W,Fl as a,Qt as b,Td as c,yd as d,bd as e,ad as f,Zc as g,Nn as h,Xe as i,Qi as j,md as k,pr as l,hd as m,Xi as n,pd as o,vi as p,ki as q,Id as r,ji as s,ud as t,ni as u,ld as v,dd as w,cd as x,id as y,od as z};
|