@openchamber/web 1.21.0 → 1.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/bin/cli.test.js +35 -0
  2. package/bin/lib/DOCUMENTATION.md +12 -0
  3. package/bin/lib/cli-settings-accessors.js +111 -0
  4. package/bin/lib/cli-settings-accessors.test.js +189 -0
  5. package/bin/lib/cli-startup.js +29 -9
  6. package/bin/lib/commands-connect-url.js +12 -14
  7. package/dist/assets/{CodeMirrorCommentWidgets-C2BopIs3.js → CodeMirrorCommentWidgets-BGj8TJxW.js} +1 -1
  8. package/dist/assets/CommitSection-DwGiXyjf.js +1 -0
  9. package/dist/assets/{DiffView-D5cvbEPb.js → DiffView-Db6bjVv1.js} +3 -3
  10. package/dist/assets/FilesView-DQOa7Lgz.js +17 -0
  11. package/dist/assets/GitView-CHzJxTi0.js +6 -0
  12. package/dist/assets/{JsonTreeView-osju7J70.js → JsonTreeView-CggOsLot.js} +1 -1
  13. package/dist/assets/MarkdownImageGallery-DoZpaHev.js +1 -0
  14. package/dist/assets/MarkdownRendererImpl-B5Y5xCOz.js +12 -0
  15. package/dist/assets/{OnboardingScreen-w2VG4fWY.js → OnboardingScreen-C98d69Fp.js} +1 -1
  16. package/dist/assets/{PatchDiff-Dan3mADn.js → PatchDiff-DJYMUiXA.js} +1 -1
  17. package/dist/assets/{PierreDiffViewer-CGoI2v0q.js → PierreDiffViewer-CY2bx_SB.js} +3 -3
  18. package/dist/assets/PlanView-PkiOY_9H.js +5 -0
  19. package/dist/assets/SettingsView-D-K3ELCM.js +28 -0
  20. package/dist/assets/{SettingsWindow-DXF-MTHG.js → SettingsWindow-oyOm2fHR.js} +1 -1
  21. package/dist/assets/{ToolOutputDialog-DrCa1JRk.js → ToolOutputDialog-lKyeQTPL.js} +6 -6
  22. package/dist/assets/{ToolPartDiffPreview-B_tfvlNF.js → ToolPartDiffPreview-C7kBQNAA.js} +2 -2
  23. package/dist/assets/{VirtualizedFileDiff-CN_BctrR.js → VirtualizedFileDiff-BP7ebDFF.js} +1 -1
  24. package/dist/assets/{WalkthroughView-D9Q4lr5x.js → WalkthroughView-MuJodAHD.js} +2 -2
  25. package/dist/assets/{computeVirtualFileMetrics-Gi1d5eU1.js → computeVirtualFileMetrics-CZ0xPeaT.js} +1 -1
  26. package/dist/assets/{contextPanelEmbeddedChat-CpzVNWAv.js → contextPanelEmbeddedChat-C9abMBTb.js} +1 -1
  27. package/dist/assets/de-CEoCz3j6.js +9 -0
  28. package/dist/assets/es-DwyXCqaL.js +15 -0
  29. package/dist/assets/{fr-5qJM0nFS.js → fr-CS7Csln9.js} +5 -5
  30. package/dist/assets/index-CUKcHnUA.css +1 -0
  31. package/dist/assets/{index-Brm3X9rs.js → index-CaPAjwXQ.js} +1 -1
  32. package/dist/assets/index-DIvDEKE-.js +7 -0
  33. package/dist/assets/{isDiffPlainText-pH9kAJQH.js → isDiffPlainText-ZBvDxhVB.js} +1 -1
  34. package/dist/assets/{isFilePlainText-CVKy_dgB.js → isFilePlainText-DiLRrkJr.js} +1 -1
  35. package/dist/assets/ja-vnwqLcx6.js +15 -0
  36. package/dist/assets/ko-CXuSfZv5.js +15 -0
  37. package/dist/assets/{main-vUCh0VB0.js → main-D5RWr6sJ.js} +2 -2
  38. package/dist/assets/main-DLlfDjQ_.js +926 -0
  39. package/dist/assets/{markdown-shiki.worker-CKGJ1J33.js → markdown-shiki.worker-D5fBU-lw.js} +5 -5
  40. package/dist/assets/markdownCore-CcTcLsQF.js +3 -0
  41. package/dist/assets/{miniChat-BlzGEYgE.js → miniChat-CqR3icsk.js} +2 -2
  42. package/dist/assets/{mobile-CkX6H-IT.js → mobile-RN_UTTlB.js} +2 -2
  43. package/dist/assets/{patchFileDiff-BCTsE43U.js → patchFileDiff-CjRR5ESs.js} +3 -3
  44. package/dist/assets/pl-BJxry0Mi.js +15 -0
  45. package/dist/assets/pt-BR-DxLmkhdv.js +15 -0
  46. package/dist/assets/{renderElectronMiniChatApp-CJYe_KOL.js → renderElectronMiniChatApp-1wC94fQK.js} +2 -2
  47. package/dist/assets/renderMobileApp-ltva2Plg.js +25 -0
  48. package/dist/assets/runtimeEndpointReset-D6SmNZaP.js +15 -0
  49. package/dist/assets/{scheduledTasksApi-CAGPh_gZ.js → scheduledTasksApi-mjMDet_H.js} +1 -1
  50. package/dist/assets/{shikiHighlight-BgTPSITe.js → shikiHighlight-fGmFkxAM.js} +1 -1
  51. package/dist/assets/tr-5Mk_hQ2Q.js +6 -0
  52. package/dist/assets/uk-ClgQjmlw.js +15 -0
  53. package/dist/assets/{useAppFontEffects-Cll4gnsh.js → useAppFontEffects-KP8_yiGW.js} +143 -141
  54. package/dist/assets/{useInlineCommentController-DFFv0hae.js → useInlineCommentController-HIjtuhxD.js} +2 -2
  55. package/dist/assets/useRootScrollLock-BSiQ5F75.js +1 -0
  56. package/dist/assets/{vendor-base-ui-_6j2xOWl.js → vendor-base-ui-BeMD8X_w.js} +1 -1
  57. package/dist/assets/{vendor-codemirror-language-data-DkQX2EBa.js → vendor-codemirror-language-data-DrTPkHl4.js} +2 -2
  58. package/dist/assets/{vendor-floating-ui-core-CXmKXOXc.js → vendor-floating-ui-core-PuGzNPnN.js} +1 -1
  59. package/dist/assets/{vendor-floating-ui-dom-WyXykhNi.js → vendor-floating-ui-dom-BTvzWks8.js} +1 -1
  60. package/dist/assets/{vendor-floating-ui-react-dom-DKpLs02S.js → vendor-floating-ui-react-dom-DxYCWdHj.js} +1 -1
  61. package/dist/assets/{vendor-floating-ui-utils-BzXdqYpP.js → vendor-floating-ui-utils-D6FqdtJt.js} +1 -1
  62. package/dist/assets/vendor-linkify-it-DZCzzDkK.js +1 -0
  63. package/dist/assets/vendor-marked-linkify-it-CXI_LHIE.js +1 -0
  64. package/dist/assets/vendor-uc.micro-BAd0H0z4.js +1 -0
  65. package/dist/assets/{web-components-DLnGY4fs.js → web-components-DOXvU-tB.js} +1 -1
  66. package/dist/assets/zh-CN-Ba6y8H-i.js +15 -0
  67. package/dist/assets/zh-TW-Dv8yyhN1.js +15 -0
  68. package/dist/index.html +5 -5
  69. package/dist/mini-chat.html +3 -3
  70. package/dist/mobile.html +3 -3
  71. package/dist/site.webmanifest +1 -1
  72. package/dist/sw.js +1 -1
  73. package/package.json +2 -2
  74. package/public/site.webmanifest +1 -1
  75. package/server/index.js +2 -2
  76. package/server/lib/cloudflare-tunnel.js +1 -1
  77. package/server/lib/fs/DOCUMENTATION.md +1 -0
  78. package/server/lib/fs/routes.js +21 -0
  79. package/server/lib/fs/routes.test.js +89 -3
  80. package/server/lib/git/DOCUMENTATION.md +4 -3
  81. package/server/lib/git/service.js +128 -6
  82. package/server/lib/git/service.test.js +191 -1
  83. package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
  84. package/server/lib/markdown-image-grants/routes.js +3 -1
  85. package/server/lib/markdown-image-grants/routes.test.js +14 -0
  86. package/server/lib/openchamber-sessions/routes.js +4 -1
  87. package/server/lib/openchamber-sessions/routes.test.js +23 -0
  88. package/server/lib/opencode/env-runtime.js +17 -1
  89. package/server/lib/opencode/env-runtime.test.js +56 -0
  90. package/server/lib/opencode/lifecycle.js +48 -9
  91. package/server/lib/opencode/lifecycle.test.js +125 -1
  92. package/server/lib/opencode/managed-process-registry.d.ts +13 -0
  93. package/server/lib/opencode/managed-process-registry.js +213 -163
  94. package/server/lib/opencode/managed-process-registry.test.mjs +285 -0
  95. package/server/lib/opencode/project-directory-runtime.js +16 -11
  96. package/server/lib/opencode/project-directory-runtime.test.js +32 -12
  97. package/server/lib/opencode/pwa-manifest-routes.js +1 -1
  98. package/server/lib/opencode/routes-upgrade.test.js +96 -12
  99. package/server/lib/opencode/routes.js +53 -5
  100. package/server/lib/opencode/settings-helpers.js +3 -0
  101. package/server/lib/opencode/settings-helpers.test.js +10 -0
  102. package/server/lib/opencode/theme-runtime.js +1 -1
  103. package/server/lib/opencode/theme-runtime.test.js +129 -0
  104. package/server/lib/quota/DOCUMENTATION.md +19 -0
  105. package/server/lib/quota/providers/copilot.js +26 -10
  106. package/server/lib/quota/providers/copilot.test.js +78 -0
  107. package/server/lib/small-model/DOCUMENTATION.md +11 -5
  108. package/server/lib/small-model/call.js +64 -20
  109. package/server/lib/small-model/call.test.js +184 -2
  110. package/server/lib/tunnels/install-help.js +2 -2
  111. package/server/lib/tunnels/install-help.test.js +9 -0
  112. package/server/lib/walkthrough/languages.js +1 -0
  113. package/dist/assets/CommitSection-HJeMUAWb.js +0 -1
  114. package/dist/assets/FilesView-DPU8aNPL.js +0 -17
  115. package/dist/assets/GitView-Ct6xWrVH.js +0 -6
  116. package/dist/assets/MarkdownImageGallery-EujHSZ2M.js +0 -1
  117. package/dist/assets/MarkdownRendererImpl-CPzu4kIr.js +0 -12
  118. package/dist/assets/PlanView-Dgg-WTEc.js +0 -4
  119. package/dist/assets/SessionSwitcherDropdown-CJTrc8K7.js +0 -1
  120. package/dist/assets/SettingsView-D9yRuFZw.js +0 -28
  121. package/dist/assets/de-B_LdJwEM.js +0 -9
  122. package/dist/assets/es-CubfsAYV.js +0 -15
  123. package/dist/assets/index-BW82eK5v.css +0 -1
  124. package/dist/assets/index-rlLjZUM5.js +0 -7
  125. package/dist/assets/ja-DJYIBUlH.js +0 -15
  126. package/dist/assets/ko-DcUBkB7y.js +0 -15
  127. package/dist/assets/main-DLBxKIoX.js +0 -926
  128. package/dist/assets/markdownCore-DG6GHLF4.js +0 -3
  129. package/dist/assets/pl-rB6BLcio.js +0 -15
  130. package/dist/assets/pt-BR-DcwtlO-o.js +0 -15
  131. package/dist/assets/renderMobileApp-hQJTnr8B.js +0 -25
  132. package/dist/assets/runtimeEndpointReset-BDh7r8BL.js +0 -15
  133. package/dist/assets/uk-INZlFD9A.js +0 -15
  134. package/dist/assets/zh-CN-Dzda8xa1.js +0 -15
  135. package/dist/assets/zh-TW-Cwn3rNYZ.js +0 -15
@@ -0,0 +1,15 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CaPAjwXQ.js","assets/useAppFontEffects-KP8_yiGW.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-DIvDEKE-.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-zod-BLfBSgBh.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-CUKcHnUA.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-BeMD8X_w.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/contextPanelEmbeddedChat-C9abMBTb.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-DrTPkHl4.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-gg7YLRW7.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/computeVirtualFileMetrics-CZ0xPeaT.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-DiLRrkJr.js","assets/isDiffPlainText-ZBvDxhVB.js","assets/vendor-diff-C3JhlQdm.js","assets/vendor-lru_map-Tstukz9J.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/PlanView-PkiOY_9H.js","assets/shikiHighlight-fGmFkxAM.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useInlineCommentController-HIjtuhxD.js","assets/CodeMirrorCommentWidgets-BGj8TJxW.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 Jt}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as We,r as ce,j as t,R as h}from"./vendor-react-BUCujlKS.js";import{e7 as jo,c4 as yr,c5 as wr,aQ as No,f as nt,o as ko,bE as ks,bF as Is,bH as Cs,I as E,c0 as Io,bY as Bn,h as le,B as Ce,b9 as vr,g as Co,t as je,e8 as To,e9 as Do,ea as Po,O as Eo,dR as Ro,eb as Ao,ec as Bo,ed as Mo,y as st,ee as Lo,l as Nt,ef as Fo,dr as Sr,eg as Oo,ds as $o,bZ as Ts,cO as Uo,bG as zs,b4 as Wo,b7 as _o,b6 as zo,bo as Vs,eh as Vo,ei as Go,ej as Ho,ek as Ko,el as qo,em as Yo,en as Jo,eo as Qo,b as It,c8 as Xo,a2 as Mn,ba as Zo,dL as jr,dA as Nr,dC as ea,ep as ta,u as qt,cB as sa,eq as mn,S as yt,dh as na,er as Ln,es as ra,et as oa,eu as Fn,ev as aa,ew as ia,ex as la,ey as ca,bK as da,ez as ua,b2 as zt,a$ as Vt,b1 as Gt,bX as Gs,bS as kr,bT as Ir,eA as Cr,bU as Tr,bV as Dr,bW as Os,L as Pr,N as fa,eB as ma,eC as On,eD as ha,T as pa,U as ga,R as xa,eE as Er,eF as ba,eG as ya,eH as wa,eI as va,a0 as hn,a6 as ms,a7 as hs,a8 as ps,cw as pn,cx as gn,cy as xn,cz as bn,cr as Ut,cs as Pt,eJ as $s,a_ as At,bB as yn,M as Ss,bI as Sa,bJ as Tn,V as Dn,as as Us,c6 as ja,eK as Rr,b_ as Na,dH as ka,af as Pn,eL as Js,m as Ar,cS as us,eM as $n,eN as Un,cQ as Wn,b$ as Ia,eO as Ca,eP as Ta,dB as Da,eQ as Pa,eR as Ea,cv as Ra,_ as Aa,H as Ba,c as Ma,d as La,cL as Fa,eS as Br,Z as Mr,r as Oa,W as $a,d_ as Dt,eT as Ua,eU as Wa,eV as Lr,$ as Hs,eW as Et,eX as wn,eY as _a,eZ as Fr,e_ as Es,cd as za,e$ as Va,f0 as Ga,f1 as Ha,f2 as Ka,f3 as qa,da as Ya,dm as Ja,Y as vn,dW as Qa,cY as Xa,aq as Za,ab as ei,bQ as ti,f4 as Or,e4 as si,f5 as ni,f6 as ri,f7 as oi,f8 as ai,bN as ii,cW as li}from"./useAppFontEffects-KP8_yiGW.js";import{ak as _n,al as ci,am as zn,an as di,i as ui,ao as fi,F as $r,_ as mi,r as Mt,u as Ue,A as hi,b as pi,v as gi,a as Qs,d as Vn,$ as Ur,W as xi,ap as Ot,o as bi,m as gs,z as Wr,a2 as yi,a3 as wi,aq as vi,ar as Si,w as fs,U as ji,H as Sn,as as Ni,a9 as ki,at as bs,au as Xs,av as _r,T as Ii,n as Ci,y as Ti}from"./index-DIvDEKE-.js";import{g as Di,h as Pi,i as Ei,d as Ri,C as Ai,c as Bi,M as Mi,S as Li,a as Fi,b as Oi}from"./vendor-base-ui-BeMD8X_w.js";import{c as Ks,d as zr,p as Vr,a as $i}from"./vendor-zustand-BAGL70zf.js";import{i as Gr}from"./contextPanelEmbeddedChat-C9abMBTb.js";import{f as Hr,h as Kr,P as qr,k as Ui,D as Yr,j as Jr}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as Qr,S as Xr,h as Wi,v as _i,a as zi}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Zr}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";const Vi=["typescript","javascript","tsx","jsx","json","markdown"],eo={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:"none"},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:"word-alt"}};let Gn=null;const to=()=>(Gn??=Promise.all([Jt(()=>import("./index-CaPAjwXQ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112])),Jt(()=>import("./workerFactory-tw7cIdmV.js"),[]),Jt(()=>import("./appThemeRegistry-BK0dHKa6.js"),__vite__mapDeps([113,114,100,101,5,85,86,87,88,89,90,91,92,93,94,95,96,97,98]))]).then(([s,e,n])=>({WorkerPoolManager:s.WorkerPoolManager,workerFactory:e.workerFactory,ensurePierreThemeRegistered:n.ensurePierreThemeRegistered})),Gn),js={},Hn=new Set,jn=new Set;let Ls={light:"pierre-light",dark:"pierre-dark"};const Gi=()=>{for(const s of jn)s()},so=(s,e)=>{e.setRenderOptions({theme:Ls,lineDiffType:eo[s].lineDiffType})},Nn=s=>{typeof window>"u"||Hn.has(s)||(Hn.add(s),to().then(e=>{if(js[s])return;const n=eo[s],r=new e.WorkerPoolManager({workerFactory:e.workerFactory,poolSize:n.poolSize,totalASTLRUCacheSize:n.totalASTLRUCacheSize},{theme:{light:"pierre-light",dark:"pierre-dark"},langs:Vi,lineDiffType:n.lineDiffType,preferredHighlighter:"shiki-wasm"});r.initialize(),js[s]=r,so(s,r),Gi()}))},Hi=s=>(jn.add(s),()=>jn.delete(s)),Ki=s=>{if(!(Ls.light===s.light&&Ls.dark===s.dark)){Ls=s;for(const e of Object.keys(js)){const n=js[e];n&&so(e,n)}}},wf=s=>{const e=We.c(15),{children:n}=s,r=jo();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=_n(!1),e[0]=o):o=e[0];const a=o;let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=_n(!0),e[1]=i):i=e[1];const d=i,l=r?.lightThemeId??a.metadata.id,c=r?.darkThemeId??d.metadata.id;let u;e[2]!==l||e[3]!==r?.availableThemes?(u=r?.availableThemes.find(k=>k.metadata.id===l)??a,e[2]=l,e[3]=r?.availableThemes,e[4]=u):u=e[4];const m=u;let g;e[5]!==c||e[6]!==r?.availableThemes?(g=r?.availableThemes.find(k=>k.metadata.id===c)??d,e[5]=c,e[6]=r?.availableThemes,e[7]=g):g=e[7];const p=g;let f,b;e[8]!==p||e[9]!==m?(f=()=>{let k=!1;return to().then(A=>{k||(A.ensurePierreThemeRegistered(m),A.ensurePierreThemeRegistered(p),Ki({light:m.metadata.id,dark:p.metadata.id}))}),()=>{k=!0}},b=[p,m],e[8]=p,e[9]=m,e[10]=f,e[11]=b):(f=e[10],b=e[11]),ce.useEffect(f,b);let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=[],e[12]=w):w=e[12],ce.useEffect(Yi,w);let C;return e[13]!==n?(C=t.jsx(t.Fragment,{children:n}),e[13]=n,e[14]=C):C=e[14],C},vf=s=>{const e=We.c(5),n=s===void 0?"unified":s;let r;e[0]!==n?(r=()=>js[n],e[0]=n,e[1]=r):r=e[1];const o=ce.useSyncExternalStore(Hi,r,Ji);let a,i;return e[2]!==n?(a=()=>{Nn(n)},i=[n],e[2]=n,e[3]=a,e[4]=i):(a=e[3],i=e[4]),ce.useEffect(a,i),o};function qi(){Nn("unified"),Nn("split")}function Yi(){if(typeof window>"u")return;const s=qi;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 Ji(){}const Zs=(s,e)=>yr(wr.getState().dictionary,s,e),Qi=s=>{const e=s.message.toLowerCase();return e.includes("code signature")||e.includes("did not pass validation")||e.includes("code requirement")||e.includes("not signed")?"signature":e.includes("command is disabled")?"updater-disabled":"unknown"},Xi=s=>{const e=Qi(s);return e==="signature"?Zs("updateDialog.error.signatureRejected"):e==="updater-disabled"?Zs("updateDialog.error.updaterDisabled"):s.message.trim()||Zs("updateDialog.error.restartFailed")},Kn="openchamber.update-install-id";function Zi(){if(!(typeof window>"u"||typeof crypto.randomUUID!="function"))try{const s=window.localStorage.getItem(Kn)?.trim();if(s)return s;const e=crypto.randomUUID();return window.localStorage.setItem(Kn,e),e}catch{return}}function el(){if(typeof window>"u")return"unknown";try{const{deviceType:s}=No();return s}catch{return"unknown"}}function tl(){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 o=typeof navigator<"u"?navigator.userAgent.toLowerCase():"";return o.includes("aarch64")||o.includes("arm64")||o.includes("armv")?"arm64":o.includes("x86_64")||o.includes("x64")||o.includes("amd64")||o.includes("win64")?"x64":"unknown"}function sl(){const s=pi();if(s==="android"||s==="ios")return s;if(typeof navigator>"u")return"web";const e=(navigator.platform||"").toLowerCase();return e.includes("mac")?"macos":e.includes("win")?"windows":e.includes("linux")?"linux":"web"}function nl(s){const e=Ue.getState().reportUsage,n=new URLSearchParams({reportUsage:e?"true":"false"});if(n.set("deviceClass",el()),n.set("arch",tl()),n.set("platform",sl()),e&&(s==="desktop"||s==="mobile")){const r=Zi();r&&n.set("installId",r)}return s==="desktop"?(n.set("appType","desktop-electron"),n.set("instanceMode",hi()?"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 Rs(s,e){try{const n=nl(s),r=typeof window<"u"?window.__VSCODE_CONFIG__?.extensionVersion:void 0;e?n.set("currentVersion",e):s==="vscode"&&r&&n.set("currentVersion",r);const o=await Mt(`/api/openchamber/update-check?${n.toString()}`,{method:"GET",headers:{Accept:"application/json"},priority:"low"});if(!o.ok)throw new Error(`Server responded with ${o.status}`);const a=await o.json();return{available:a.available??!1,version:a.version,currentVersion:a.currentVersion??"unknown",body:a.body,releaseUrl:a.releaseUrl,downloadUrl:a.downloadUrl,nextSuggestedCheckInSec:typeof a.nextSuggestedCheckInSec=="number"&&Number.isFinite(a.nextSuggestedCheckInSec)?a.nextSuggestedCheckInSec:void 0,packageManager:a.packageManager,updateCommand:a.updateCommand}}catch(n){return console.warn("Failed to check for updates:",n),null}}function rl(){return ui()?"mobile":fi()?"desktop":$r()?"vscode":mi()?"web":null}const qn={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null},ol=Ks()((s,e)=>({...qn,checkForUpdates:async()=>{const n=rl();if(!n)return null;s({checking:!0,error:null,runtimeType:n});try{let r=null,o=null;if(n==="desktop"){const a="1.21.1",[i,d]=await Promise.allSettled([zn(),Rs("desktop",a)]),l=i.status==="fulfilled"?i.value:null;return o=d.status==="fulfilled"?d.value?.nextSuggestedCheckInSec??null:null,s({checking:!1,available:l?.available??!1,info:l,lastChecked:Date.now(),nextCheckInSec:o}),o}else n==="web"?(r=await Rs("web"),o=r?.nextSuggestedCheckInSec??null):n==="vscode"?o=(await Rs("vscode"))?.nextSuggestedCheckInSec??null:n==="mobile"&&(r=await Rs("mobile","1.21.1"),o=r?.nextSuggestedCheckInSec??null);return s({checking:!1,available:n==="vscode"?!1:r?.available??!1,info:n==="vscode"?null:r,lastChecked:Date.now(),nextCheckInSec:o}),o}catch(r){return s({checking:!1,error:r instanceof Error?r.message:"Failed to check for updates"}),null}},downloadUpdate:async()=>{const{available:n,runtimeType:r}=e();if(!(r!=="desktop"||!n)){s({downloading:!0,error:null,progress:null});try{const o=await zn();if(!o?.available)throw new Error("Update detected, but desktop package is not ready yet. Retry in a moment.");if(s(i=>({info:i.info?{...i.info,...o,body:i.info.body||o.body,available:i.info.available}:o})),!await di(i=>{s({progress:i})}))throw new Error("Desktop update only works on Local instance");s({downloading:!1,downloaded:!0})}catch(o){s({downloading:!1,error:o instanceof Error?o.message:"Failed to download update"})}}},restartToUpdate:async()=>{const{downloaded:n,runtimeType:r}=e();if(!(r!=="desktop"||!n)){s({error:null});try{if(!await ci())throw new Error(yr(wr.getState().dictionary,"updateDialog.error.restartUnavailable"))}catch(o){s({error:Xi(o instanceof Error?o:new Error(String(o)))})}}},dismiss:()=>{s({available:!1,downloaded:!1,info:null})},reset:()=>{s(qn)}})),Yn="https://github.com/openchamber/openchamber/releases";function al(s){const e=new Date(`${s}T00:00:00`);return Number.isNaN(e.getTime())?s:new Intl.DateTimeFormat(vr(),{year:"numeric",month:"short",day:"numeric"}).format(e)}function il(s){return s.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,"").trim()}function Jn(s){return s.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,"$1[@$2](https://github.com/$2)")}function ll(s,e){const n=s.split(".").map(o=>Number.parseInt(o,10)),r=e.split(".").map(o=>Number.parseInt(o,10));for(let o=0;o<3;o+=1){const a=Number.isFinite(n[o])?n[o]:0,i=Number.isFinite(r[o])?r[o]:0;if(a!==i)return i-a}return 0}function cl(s){const e=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[];let r;for(;(r=e.exec(s))!==null;)n.push({version:r[1]??"",date:r[2]??"",start:r.index});return n.length===0?[]:n.map((o,a)=>{const i=n[a+1]?.start??s.length,d=s.slice(o.start,i).trim();return{version:o.version,date:o.date,start:o.start,end:i,raw:d}})}const Qn=2e3,dl=600*1e3;async function ul(){try{const s=await Mt("/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 fl(){try{return(await Mt("/health",{method:"GET",headers:{Accept:"application/json"}})).ok}catch{return!1}}async function ml(s,e=Math.ceil(dl/Qn),n=Qn){for(let r=0;r<e;r++){try{const o=await Mt("/api/openchamber/update-check?reportUsage=false",{method:"GET",headers:{Accept:"application/json"}});if(o.ok){const a=await o.json().catch(()=>null);if(a&&a.available===!1||a&&typeof a.currentVersion=="string"&&typeof s=="string"&&a.currentVersion!==s)return!0}else if((o.status===401||o.status===403)&&await fl())return!0}catch{}await new Promise(o=>setTimeout(o,n))}return!1}const Sf=({open:s,onOpenChange:e,info:n,downloading:r,downloaded:o,progress:a,error:i,onDownload:d,onRestart:l,runtimeType:c="desktop"})=>{const{t:u}=nt(),[m,g]=ce.useState(!1),[p,f]=ce.useState("idle"),[b,w]=ce.useState(null),C=n?.version?n.releaseUrl||`${Yn}/tag/v${n.version}`:Yn,k=n?.downloadUrl||C,A=a?.total?Math.round(a.downloaded/a.total*100):0,M=c==="web",j=c==="mobile",N=n?.updateCommand||"openchamber update";ce.useEffect(()=>{s||(f("idle"),w(null))},[s]);const y=async()=>{(await Co(N)).ok&&(g(!0),setTimeout(()=>g(!1),2e3))},S=ce.useCallback(async _=>{await ko(_)},[]),O=ce.useCallback(async()=>{f("updating"),w(null);const _=await ul();if(!_.success){f("error"),w(_.error||u("updateDialog.error.updateFailed"));return}_.autoRestart&&(f("restarting"),await new Promise(H=>setTimeout(H,2e3))),f("reconnecting"),await ml(n?.currentVersion)?window.location.reload():(f("error"),w(u("updateDialog.error.takingLonger")))},[n?.currentVersion,u]),W=ce.useCallback(()=>{S(k)},[S,k]),B=p!=="idle"&&p!=="error",F=ce.useMemo(()=>{if(!n?.body)return null;const _=n.body.trim();if(!_)return null;const te=cl(_);if(te.length===0)return{kind:"raw",title:u("updateDialog.changelog.title"),content:Jn(_)};const H=[...te].sort((z,G)=>ll(z.version,G.version));return{kind:"sections",title:u("updateDialog.changelog.title"),sections:H.map(z=>({version:z.version,dateLabel:al(z.date),content:Jn(il(z.raw)||_)}))}},[n?.body,u]);return t.jsx(ks,{open:s,onOpenChange:B?void 0:e,children:t.jsxs(Is,{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(Cs,{className:"flex items-center gap-2.5",children:[t.jsx(E,{name:"download-cloud",className:"h-5 w-5 text-[var(--primary-base)]"}),t.jsx("span",{className:"text-lg font-semibold text-foreground",children:u(p==="restarting"||p==="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:[M&&B&&t.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(E,{name:"loader",className:"h-5 w-5 animate-spin text-[var(--primary-base)]"}),t.jsxs("div",{className:"typography-ui-label text-foreground",children:[p==="updating"&&u("updateDialog.status.installingUpdate"),p==="restarting"&&u("updateDialog.status.serverRestarting"),p==="reconnecting"&&u("updateDialog.status.waitingForServer")]})]}),t.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:u("updateDialog.status.autoReloadHint")})]}),F&&!B&&t.jsx("div",{className:"rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 overflow-hidden",children:t.jsx(Io,{className:"max-h-[400px] p-0",fillContainer:!1,children:F.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:_=>{const H=_.target.closest("a");H&&H.href&&(_.preventDefault(),_.stopPropagation(),S(H.href))},children:t.jsx(Bn,{content:F.content,disableLinkSafety:!0,enableFileReferences:!1})}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:F.sections.map(_=>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",_.version]}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:_.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:te=>{const z=te.target.closest("a");z&&z.href&&(te.preventDefault(),te.stopPropagation(),S(z.href))},children:t.jsx(Bn,{content:_.content,disableLinkSafety:!0,enableFileReferences:!1})})]},_.version))})})}),M&&p==="error"&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(E,{name:"terminal",className:"h-4 w-4"}),t.jsx("span",{children:u("updateDialog.fallback.updateViaTerminal")})]}),t.jsxs("div",{className:"flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]",children:[t.jsx("code",{className:"flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap",children:N}),t.jsx("button",{onClick:y,className:le("flex items-center justify-center p-2 rounded","text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]","transition-colors",m&&"text-[var(--status-success)]"),title:u(m?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:m?t.jsx(E,{name:"check",className:"h-4 w-4"}):t.jsx(E,{name:"clipboard",className:"h-4 w-4"})})]})]}),!M&&!j&&r&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:u("updateDialog.status.downloadingPayload")}),t.jsxs("span",{className:"font-mono text-foreground",children:[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}%`}})})]}),(i||b)&&t.jsx("div",{className:"p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg",children:t.jsx("p",{className:"text-sm text-[var(--status-error)]",children:i||b})})]}),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(E,{name:"external-link",className:"h-4 w-4"}),"GitHub"]}),t.jsxs("div",{className:"flex-1 flex justify-end",children:[!M&&!j&&!o&&!r&&t.jsxs("button",{onClick:d,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(E,{name:"download",className:"h-4 w-4"}),u("updateDialog.actions.downloadUpdate")]}),!M&&!j&&r&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(E,{name:"loader",className:"h-4 w-4 animate-spin"}),u("updateDialog.status.downloading")]}),!M&&!j&&o&&t.jsxs("button",{onClick:l,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--status-success)] text-white hover:opacity-90 transition-opacity",children:[t.jsx(E,{name:"restart",className:"h-4 w-4"}),u("updateDialog.actions.restartToUpdate")]}),j&&t.jsxs(Ce,{onClick:W,size:"default",children:[t.jsx(E,{name:"external-link",className:"h-4 w-4"}),u("updateDialog.actions.openMobileUpdate")]}),M&&!B&&t.jsxs("button",{onClick:O,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(E,{name:"download",className:"h-4 w-4"}),u("updateDialog.actions.updateNow")]}),M&&B&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(E,{name:"loader",className:"h-4 w-4 animate-spin"}),u("updateDialog.status.updating")]})]})]})]})})},jf=s=>!(s.dismissed==="true"||s.sessionShown==="true"||s.hasActiveToast),hl=s=>!(!s.version||s.seenVersions.has(s.version)||s.dismissedVersion!==null&&s.dismissedVersion===s.version),pl=s=>{if(s===null||typeof s!="object")return"";const e=s.version;return typeof e!="string"?"":e.trim()},gl=s=>!s||s.upgrade?.supported!==!0||s.available!==!0||typeof s.latestVersion!="string"?"":s.latestVersion.trim(),ds="opencode-update-available",As="opencode-upgrade-progress",xl=5e3,bl=[1e4,6e4],Xn="opencode-update-toast-dismissed-version",Nf=()=>{const{t:s}=nt(),e=Ue(i=>i.showOpenCodeUpdateNotifications),n=ce.useRef(new Set),r=ce.useRef(!1);ce.useEffect(()=>{e||je.dismiss(ds)},[e]);const o=ce.useCallback(()=>{je.dismiss(As),To({message:s("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]}).catch(()=>{})},[s]),a=ce.useCallback(async()=>{if(!r.current){r.current=!0,je.dismiss(ds),je.message(s("opencodeUpdate.toast.upgrading.title"),{id:As,description:s("opencodeUpdate.toast.upgrading.description"),duration:1/0,icon:t.jsx(E,{name:"refresh",className:"h-4 w-4 animate-spin text-muted-foreground"})});try{const i=await Mt("/api/opencode/upgrade",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),d=await i.json().catch(()=>null);if(!i.ok||d?.success===!1)throw new Error(d?.error||i.statusText||s("opencodeUpdate.toast.failed.description"));je.success(s("opencodeUpdate.toast.updated.title"),{id:As,description:d?.version?s("opencodeUpdate.toast.updated.descriptionWithVersion",{version:d.version}):s("opencodeUpdate.toast.updated.description"),duration:1/0,icon:t.jsx(E,{name:"check",className:"h-4 w-4 text-[var(--status-success)]"}),action:{label:s("opencodeUpdate.toast.actions.reload"),onClick:o}})}catch(i){je.error(s("opencodeUpdate.toast.failed.title"),{id:As,description:i instanceof Error?i.message:s("opencodeUpdate.toast.failed.description"),duration:1/0})}finally{r.current=!1}}},[o,s]);return ce.useEffect(()=>{const i=g=>{if(!Ue.getState().showOpenCodeUpdateNotifications){je.dismiss(ds);return}hl({version:g,dismissedVersion:Vn().getItem(Xn),seenVersions:n.current})&&(n.current.add(g),je.info(s("opencodeUpdate.toast.available.title"),{id:ds,description:s("opencodeUpdate.toast.available.description",{version:g}),duration:1/0,action:{label:s("opencodeUpdate.toast.actions.update"),onClick:a},cancel:{label:s("opencodeUpdate.toast.actions.dismiss"),onClick:()=>{Vn().setItem(Xn,g),Ur({openCodeUpdateToastDismissedVersion:g}),je.dismiss(ds)}}}))};let d=!1;const l=[],c=async(g,p=Qs())=>{try{const f=await Mt("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!f.ok)throw new Error(f.statusText||"OpenCode upgrade status check failed");const b=await f.json().catch(()=>null),w=gl(b);!d&&p===Qs()&&w&&i(w)}catch{const f=bl[g];!d&&p===Qs()&&f!==void 0&&l.push(setTimeout(()=>{c(g+1,p)},f))}},u=g=>{pl(g.detail)&&c(0)};e&&l.push(setTimeout(()=>{c(0)},xl));const m=gi(({runtimeKey:g})=>{n.current.clear(),je.dismiss(ds),Ue.getState().showOpenCodeUpdateNotifications&&c(0,g)});return window.addEventListener("openchamber:opencode-update-available",u),()=>{d=!0;for(const g of l)clearTimeout(g);m(),window.removeEventListener("openchamber:opencode-update-available",u)}},[a,e,s]),null},kf=()=>{const s=We.c(3),[e,n]=h.useState(yl),{isUpdating:r}=e;let o,a;if(s[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>Po(n),a=[],s[0]=o,s[1]=a):(o=s[0],a=s[1]),h.useEffect(o,a),!r)return null;let i;return s[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-background/90",children:t.jsx(Eo,{width:80,height:80,isAnimated:!0})}),s[2]=i):i=s[2],i};function yl(){return Do()}class wl extends h.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(Ro,{className:"w-full max-w-md",children:[t.jsx(Ao,{className:"text-center",children:t.jsxs(Bo,{className:"flex items-center justify-center gap-2 text-destructive",children:[t.jsx(E,{name:"chat-3",className:"h-5 w-5"}),this.props.texts.title]})}),t.jsxs(Mo,{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(Ce,{onClick:this.handleReset,variant:"outline",className:"flex-1",children:[t.jsx(E,{name:"restart",className:"h-4 w-4 mr-2"}),this.props.texts.resetAction]})}),t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:this.props.texts.persistentHint})]})]})}):this.props.children}}function vl(s){const e=We.c(22),{t:n}=nt();let r;e[0]!==n?(r=n("chat.errorBoundary.title"),e[0]=n,e[1]=r):r=e[1];let o;e[2]!==n?(o=n("chat.errorBoundary.description"),e[2]=n,e[3]=o):o=e[3];let a;e[4]!==n?(a=n("chat.errorBoundary.sessionLabel"),e[4]=n,e[5]=a):a=e[5];let i;e[6]!==n?(i=n("chat.errorBoundary.detailsSummary"),e[6]=n,e[7]=i):i=e[7];let d;e[8]!==n?(d=n("chat.errorBoundary.resetAction"),e[8]=n,e[9]=d):d=e[9];let l;e[10]!==n?(l=n("chat.errorBoundary.persistentHint"),e[10]=n,e[11]=l):l=e[11];let c;e[12]!==r||e[13]!==o||e[14]!==a||e[15]!==i||e[16]!==d||e[17]!==l?(c={title:r,description:o,sessionLabel:a,detailsSummary:i,resetAction:d,persistentHint:l},e[12]=r,e[13]=o,e[14]=a,e[15]=i,e[16]=d,e[17]=l,e[18]=c):c=e[18];let u;return e[19]!==s||e[20]!==c?(u=t.jsx(wl,{...s,texts:c}),e[19]=s,e[20]=c,e[21]=u):u=e[21],u}const If=s=>{const e=We.c(8),{active:n,messagesEnabled:r,readOnly:o,initialAllowPromptingSubagentSessions:a}=s,i=n===void 0?!0:n,d=o===void 0?!1:o,c=st(Sl)||void 0;let u;e[0]!==i||e[1]!==a||e[2]!==r||e[3]!==d?(u=t.jsx(Lo,{active:i,messagesEnabled:r,readOnly:d,initialAllowPromptingSubagentSessions:a}),e[0]=i,e[1]=a,e[2]=r,e[3]=d,e[4]=u):u=e[4];let m;return e[5]!==c||e[6]!==u?(m=t.jsx(vl,{sessionId:c,children:u}),e[5]=c,e[6]=u,e[7]=m):m=e[7],m};function Sl(s){return s.currentSessionId}const jl=Di,Nl=s=>{const e=We.c(14);let n,r,o,a;e[0]!==s?({className:o,asChild:n,children:r,...a}=s,e[0]=s,e[1]=n,e[2]=r,e[3]=o,e[4]=a):(n=e[1],r=e[2],o=e[3],a=e[4]);let i;e[5]!==n||e[6]!==r?(i=n&&ce.isValidElement(r)?{render:r}:{children:r},e[5]=n,e[6]=r,e[7]=i):i=e[7];const d=i;let l;e[8]!==o?(l=le("flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",o),e[8]=o,e[9]=l):l=e[9];let c;return e[10]!==a||e[11]!==d||e[12]!==l?(c=t.jsx(Pi,{className:l,...a,...d}),e[10]=a,e[11]=d,e[12]=l,e[13]=c):c=e[13],c},kl=s=>{const e=We.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=le("transition-opacity duration-100 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0","motion-reduce:transition-none",n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(Ei,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a},Zn=s=>({providerID:s.providerID,modelID:s.modelID,variant:s.variant,agent:s.agent});function Il(s){const e=We.c(131),{t:n}=nt(),{open:r,onOpenChange:o,target:a,projectDirectory:i,submitting:d,allowRunAsGoal:l,onConfirm:c}=s,u=d===void 0?!1:d,m=l===void 0?!1:l;let g;e[0]!==m?(g=m&&!$r(),e[0]=m,e[1]=g):g=e[1];const p=g,f=Nt(Fl),b=Nt(Ll),w=Fo(Ml),C=Nt(Bl),k=Nt(Al),A=Nt(Rl),M=Nt(El),j=Nt(Pl);let N;e[2]!==j||e[3]!==A||e[4]!==k||e[5]!==M?(N=()=>Zn({providerID:k,modelID:A,variant:M,agent:j}),e[2]=j,e[3]=A,e[4]=k,e[5]=M,e[6]=N):N=e[6];const[y,S]=h.useState(N);let O,W;e[7]!==w||e[8]!==b||e[9]!==f||e[10]!==r||e[11]!==i?(O=()=>{r&&(f({directory:i,source:"todoSendDialog"}),b({directory:i}),w())},W=[r,f,b,w,i],e[7]=w,e[8]=b,e[9]=f,e[10]=r,e[11]=i,e[12]=O,e[13]=W):(O=e[12],W=e[13]),h.useEffect(O,W);let B,F;e[14]!==j||e[15]!==A||e[16]!==k||e[17]!==M||e[18]!==r?(B=()=>{r&&S(Zn({providerID:k,modelID:A,variant:M,agent:j}))},F=[r,k,A,M,j],e[14]=j,e[15]=A,e[16]=k,e[17]=M,e[18]=r,e[19]=B,e[20]=F):(B=e[19],F=e[20]),h.useEffect(B,F);let _,te;e[21]!==y.modelID||e[22]!==y.providerID||e[23]!==r||e[24]!==C?(_=()=>{if(!r||C.length===0)return;const x=C.find(Se=>Se.id===y.providerID)??C[0],R=Array.isArray(x?.models)?x.models:[],be=R.some(Se=>Se.id===y.modelID),fe=R[0]?.id??"";x?.id===y.providerID&&be||S(Se=>({...Se,providerID:x?.id??"",modelID:be?Se.modelID:fe,variant:""}))},te=[r,C,y.providerID,y.modelID],e[21]=y.modelID,e[22]=y.providerID,e[23]=r,e[24]=C,e[25]=_,e[26]=te):(_=e[25],te=e[26]),h.useEffect(_,te);const H=Dl;let z;if(e[27]!==y.modelID||e[28]!==y.providerID||e[29]!==C){let x;e[31]!==y.providerID?(x=be=>be.id===y.providerID,e[31]=y.providerID,e[32]=x):x=e[32],z=C.find(x)?.models?.find(be=>be.id===y.modelID),e[27]=y.modelID,e[28]=y.providerID,e[29]=C,e[30]=z}else z=e[30];const G=z;let U;e[33]!==G?(U=G?.variants?Object.keys(G.variants):[],e[33]=G,e[34]=U):U=e[34];const q=U,T=q.length>0;let V,L;e[35]!==y.variant||e[36]!==T?(V=()=>{T||!y.variant||S(Tl)},L=[T,y.variant],e[35]=y.variant,e[36]=T,e[37]=V,e[38]=L):(V=e[37],L=e[38]),h.useEffect(V,L);let D;e[39]!==y.modelID||e[40]!==y.providerID?(D=y.providerID.trim().length>0&&y.modelID.trim().length>0,e[39]=y.modelID,e[40]=y.providerID,e[41]=D):D=e[41];const K=D;let re;e[42]!==K||e[43]!==y||e[44]!==c||e[45]!==u?(re=()=>{!K||u||c(y)},e[42]=K,e[43]=y,e[44]=c,e[45]=u,e[46]=re):re=e[46];const X=re;let Y,oe;e[47]!==X||e[48]!==r?(Y=()=>{if(!r)return;const x=R=>{(R.metaKey||R.ctrlKey)&&R.key==="Enter"&&(R.preventDefault(),X())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},oe=[r,X],e[47]=X,e[48]=r,e[49]=Y,e[50]=oe):(Y=e[49],oe=e[50]),h.useEffect(Y,oe);let Z;e[51]!==n||e[52]!==a?(Z=n(a==="worktree"?"rightSidebar.contextNotesTodo.sendDialog.title.newWorktree":"rightSidebar.contextNotesTodo.sendDialog.title.newSession"),e[51]=n,e[52]=a,e[53]=Z):Z=e[53];const ee=Z;let pe;e[54]!==o||e[55]!==u?(pe=x=>{u||o(x)},e[54]=o,e[55]=u,e[56]=pe):pe=e[56];let se;e[57]!==ee?(se=t.jsx(zs,{children:t.jsx(Cs,{children:ee})}),e[57]=ee,e[58]=se):se=e[58];let de;e[59]!==n?(de=n("chat.modelControls.model"),e[59]=n,e[60]=de):de=e[60];let Q;e[61]!==de?(Q=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:de}),e[61]=de,e[62]=Q):Q=e[62];let ae;e[63]===Symbol.for("react.memo_cache_sentinel")?(ae=(x,R)=>{S(be=>({...be,providerID:x,modelID:R,variant:""}))},e[63]=ae):ae=e[63];let ue;e[64]!==y.modelID||e[65]!==y.providerID?(ue=t.jsx(Sr,{providerId:y.providerID,modelId:y.modelID,className:"max-w-[320px] justify-between",dropdownPortalToBody:!0,onChange:ae}),e[64]=y.modelID,e[65]=y.providerID,e[66]=ue):ue=e[66];let v;e[67]!==Q||e[68]!==ue?(v=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[Q,ue]}),e[67]=Q,e[68]=ue,e[69]=v):v=e[69];let $;e[70]!==n?($=n("sessions.scheduledTasks.editor.thinkingLevel.label"),e[70]=n,e[71]=$):$=e[71];let J;e[72]!==$?(J=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:$}),e[72]=$,e[73]=J):J=e[73];const he=!T;let ie;e[74]===Symbol.for("react.memo_cache_sentinel")?(ie=x=>S(R=>({...R,variant:x})),e[74]=ie):ie=e[74];let ve;e[75]!==y.variant||e[76]!==he||e[77]!==q?(ve=t.jsx(Oo,{value:y.variant,options:q,disabled:he,onChange:ie}),e[75]=y.variant,e[76]=he,e[77]=q,e[78]=ve):ve=e[78];let Ne;e[79]!==J||e[80]!==ve?(Ne=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[J,ve]}),e[79]=J,e[80]=ve,e[81]=Ne):Ne=e[81];let Ve;e[82]!==n?(Ve=n("sessions.scheduledTasks.editor.agent.label"),e[82]=n,e[83]=Ve):Ve=e[83];let Le;e[84]!==Ve?(Le=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:Ve}),e[84]=Ve,e[85]=Le):Le=e[85];let Ye;e[86]===Symbol.for("react.memo_cache_sentinel")?(Ye=x=>S(R=>({...R,agent:x})),e[86]=Ye):Ye=e[86];let Xe;e[87]!==y.agent?(Xe=t.jsx($o,{agentName:y.agent,filter:H,dropdownPortalToBody:!0,onChange:Ye}),e[87]=y.agent,e[88]=Xe):Xe=e[88];let ze;e[89]!==Le||e[90]!==Xe?(ze=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[Le,Xe]}),e[89]=Le,e[90]=Xe,e[91]=ze):ze=e[91];let Fe;e[92]!==v||e[93]!==Ne||e[94]!==ze?(Fe=t.jsxs("div",{className:"flex flex-col gap-4",children:[v,Ne,ze]}),e[92]=v,e[93]=Ne,e[94]=ze,e[95]=Fe):Fe=e[95];const Ge=`flex items-center gap-3 ${p?"justify-between":"justify-end"}`;let Ae;e[96]!==y.runAsGoal||e[97]!==p||e[98]!==u||e[99]!==n?(Ae=p?t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ts,{checked:y.runAsGoal===!0,onChange:x=>S(R=>({...R,runAsGoal:x})),disabled:u,ariaLabel:n("sessions.scheduledTasks.editor.goal.aria")}),t.jsx("button",{type:"button",className:"truncate typography-ui-label text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:u,onClick:()=>S(Cl),children:n("sessions.scheduledTasks.editor.goal.label")})]}):null,e[96]=y.runAsGoal,e[97]=p,e[98]=u,e[99]=n,e[100]=Ae):Ae=e[100];let _e;e[101]!==o?(_e=()=>o(!1),e[101]=o,e[102]=_e):_e=e[102];let Oe;e[103]!==n?(Oe=n("rightSidebar.contextNotesTodo.sendDialog.actions.cancel"),e[103]=n,e[104]=Oe):Oe=e[104];let Ze;e[105]!==u||e[106]!==_e||e[107]!==Oe?(Ze=t.jsx(Ce,{variant:"ghost",size:"sm",onClick:_e,disabled:u,children:Oe}),e[105]=u,e[106]=_e,e[107]=Oe,e[108]=Ze):Ze=e[108];const at=!K||u;let De;e[109]!==u||e[110]!==n?(De=n(u?"rightSidebar.contextNotesTodo.sendDialog.actions.sending":"rightSidebar.contextNotesTodo.sendDialog.actions.send"),e[109]=u,e[110]=n,e[111]=De):De=e[111];let Je;e[112]!==X||e[113]!==at||e[114]!==De?(Je=t.jsx(Ce,{size:"sm",onClick:X,disabled:at,children:De}),e[112]=X,e[113]=at,e[114]=De,e[115]=Je):Je=e[115];let et;e[116]!==Ze||e[117]!==Je?(et=t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[Ze,Je]}),e[116]=Ze,e[117]=Je,e[118]=et):et=e[118];let Ke;e[119]!==Ge||e[120]!==Ae||e[121]!==et?(Ke=t.jsxs("div",{className:Ge,children:[Ae,et]}),e[119]=Ge,e[120]=Ae,e[121]=et,e[122]=Ke):Ke=e[122];let ke;e[123]!==se||e[124]!==Fe||e[125]!==Ke?(ke=t.jsxs(Is,{className:"max-w-md overflow-visible",children:[se,Fe,Ke]}),e[123]=se,e[124]=Fe,e[125]=Ke,e[126]=ke):ke=e[126];let rt;return e[127]!==r||e[128]!==pe||e[129]!==ke?(rt=t.jsx(ks,{open:r,onOpenChange:pe,children:ke}),e[127]=r,e[128]=pe,e[129]=ke,e[130]=rt):rt=e[130],rt}function Cl(s){return{...s,runAsGoal:s.runAsGoal!==!0}}function Tl(s){return{...s,variant:""}}function Dl(s){return Uo(s.mode)}function Pl(s){return s.currentAgentName||""}function El(s){return s.currentVariant||""}function Rl(s){return s.currentModelId}function Al(s){return s.currentProviderId}function Bl(s){return s.providers}function Ml(s){return s.loadAgents}function Ll(s){return s.loadAgents}function Fl(s){return s.loadProviders}function Ol(s){const e=We.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(Ri,{...n}),e[2]=n,e[3]=r):r=e[3],r}function $l(s){const e=We.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(Ai,{...n}),e[2]=n,e[3]=r):r=e[3],r}function Ul(s){const e=We.c(20);let n,r,o,a,i;e[0]!==s?({className:r,positionerClassName:o,children:n,style:i,...a}=s,e[0]=s,e[1]=n,e[2]=r,e[3]=o,e[4]=a,e[5]=i):(n=e[1],r=e[2],o=e[3],a=e[4],i=e[5]);let d;e[6]!==o?(d=le("app-region-no-drag z-50",o),e[6]=o,e[7]=d):d=e[7];let l;e[8]!==i?(l={color:"var(--surface-elevated-foreground)",...i},e[8]=i,e[9]=l):l=e[9];let c;e[10]!==r?(c=le(Wo,r),e[10]=r,e[11]=c):c=e[11];let u;e[12]!==n||e[13]!==a||e[14]!==l||e[15]!==c?(u=t.jsx(Bi,{"data-slot":"dropdown-menu-content",style:l,className:c,...a,children:n}),e[12]=n,e[13]=a,e[14]=l,e[15]=c,e[16]=u):u=e[16];let m;return e[17]!==d||e[18]!==u?(m=t.jsx(Fi,{children:t.jsx(Oi,{className:d,children:u})}),e[17]=d,e[18]=u,e[19]=m):m=e[19],m}function Cf(s){const e=We.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=le(_o,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(Mi,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}function Tf(s){const e=We.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=le(zo,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(Li,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}const Wl=280,er=4,_l=({transform:s})=>({...s,y:0}),zl=s=>{const e=We.c(18),{id:n,children:r,className:o}=s;let a;e[0]!==n?(a={id:n},e[0]=n,e[1]=a):a=e[1];const{attributes:i,listeners:d,setNodeRef:l,transform:c,transition:u,isDragging:m}=Qr(a);let g;e[2]!==c?(g=Zr.Transform.toString(c),e[2]=c,e[3]=g):g=e[3];let p;e[4]!==g||e[5]!==u?(p={transform:g,transition:u},e[4]=g,e[5]=u,e[6]=p):p=e[6];const f=m&&"opacity-50";let b;e[7]!==o||e[8]!==f?(b=le("h-full rounded-md",o,f),e[7]=o,e[8]=f,e[9]=b):b=e[9];let w;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==d||e[14]!==l||e[15]!==p||e[16]!==b?(w=t.jsx("div",{ref:l,"data-sortable-tab-id":n,style:p,className:b,...i,...d,children:r}),e[10]=i,e[11]=r,e[12]=n,e[13]=d,e[14]=l,e[15]=p,e[16]=b,e[17]=w):w=e[17],w},Vl=s=>{const e=We.c(6),{id:n,children:r,className:o}=s;let a;e[0]!==o?(a=le("h-full",o),e[0]=o,e[1]=a):a=e[1];let i;return e[2]!==r||e[3]!==n||e[4]!==a?(i=t.jsx("div",{className:a,"data-sortable-tab-id":n,children:r}),e[2]=r,e[3]=n,e[4]=a,e[5]=i):i=e[5],i},Ns=s=>{const e=We.c(137),{items:n,activeId:r,onSelect:o,onClose:a,onReorder:i,layoutMode:d,variant:l,activePillInsetClassName:c,activePillButtonClassName:u,inactiveTabsIconOnly:m,animateActivePill:g,activePillLowercase:p,nonCompositedIndicator:f,tabContextMenu:b,className:w}=s,C=d===void 0?"scrollable":d,k=l===void 0?"default":l,A=m===void 0?!1:m,M=p===void 0?!0:p,j=f===void 0?!1:f,{t:N}=nt(),y=Ue(Gl),{isTablet:S}=Vs(),O=y||S,W=h.useRef(null);let B;e[0]===Symbol.for("react.memo_cache_sentinel")?(B={left:!1,right:!1},e[0]=B):B=e[0];const[F,_]=h.useState(B);let te;e[1]!==n?(te=n.map(Hl),e[1]=n,e[2]=te):te=e[2];const H=te,z=C==="scrollable",G=k==="default",U=k==="active-pill",T=U||k==="animated",V=G,L=T||V,D=U&&z,K=T,re=g??T,X=typeof i=="function",Y=X?zl:Vl;let oe;e[3]===Symbol.for("react.memo_cache_sentinel")?(oe=new Map,e[3]=oe):oe=e[3];const Z=h.useRef(oe),[ee,pe]=h.useState(null),[se,de]=h.useState(!1),[Q,ae]=h.useState(null),ue=h.useRef(!1),v=h.useRef(0),$=h.useRef(r),J=h.useRef(null);let he;e:{if(!L||!Q||!r||Q===r){he=0;break e}const Pe=n.findIndex(ot=>ot.id===Q),xe=n.findIndex(ot=>ot.id===r);if(Pe<0||xe<0){he=0;break e}he=Pe>xe?er:-er}const ie=he;let ve;e[4]===Symbol.for("react.memo_cache_sentinel")?(ve={activationConstraint:{distance:8}},e[4]=ve):ve=e[4];const Ne=Hr(Kr(qr,ve)),Ve=Kl;let Le;e[5]===Symbol.for("react.memo_cache_sentinel")?(Le=(Pe,xe)=>{if(xe){Z.current.set(Pe,xe);return}Z.current.delete(Pe)},e[5]=Le):Le=e[5];const Ye=Le;let Xe;e[6]!==r||e[7]!==L?(Xe=()=>{if(!L||!r){pe(ql);return}const Pe=W.current,xe=Z.current.get(r);if(!Pe||!xe){pe(Yl);return}let ot=0,lt=0,pt=xe;for(;pt&&pt!==Pe;)ot=ot+pt.offsetLeft,lt=lt+pt.offsetTop,pt=pt.offsetParent;const xt={left:ot,top:lt,width:xe.offsetWidth,height:xe.offsetHeight};pe(St=>Ve(St,xt)?St:xt)},e[6]=r,e[7]=L,e[8]=Xe):Xe=e[8];const ze=Xe;let Fe;e[9]!==z?(Fe=()=>{if(!z){_({left:!1,right:!1});return}const Pe=W.current;if(!Pe){_({left:!1,right:!1});return}_({left:Pe.scrollLeft>2,right:Pe.scrollLeft+Pe.clientWidth<Pe.scrollWidth-2})},e[9]=z,e[10]=Fe):Fe=e[10];const Ge=Fe;let Ae;e[11]!==z||e[12]!==Ge?(Ae=()=>{if(!z){_({left:!1,right:!1});return}const Pe=W.current;if(!Pe)return;Ge(),Pe.addEventListener("scroll",Ge,{passive:!0});const xe=new ResizeObserver(Ge);return xe.observe(Pe),()=>{Pe.removeEventListener("scroll",Ge),xe.disconnect()}},e[11]=z,e[12]=Ge,e[13]=Ae):Ae=e[13];let _e;e[14]!==z||e[15]!==n.length||e[16]!==Ge?(_e=[z,n.length,Ge],e[14]=z,e[15]=n.length,e[16]=Ge,e[17]=_e):_e=e[17],h.useEffect(Ae,_e);let Oe;e[18]!==r||e[19]!==ze||e[20]!==L?(Oe=()=>{if(!L){pe(null);return}ze();const Pe=W.current;if(!Pe)return;const xe=new ResizeObserver(()=>{performance.now()-v.current>Wl&&de(!1),ze()});if(xe.observe(Pe),r){const ot=Z.current.get(r);ot&&xe.observe(ot)}return()=>{xe.disconnect()}},e[18]=r,e[19]=ze,e[20]=L,e[21]=Oe):Oe=e[21];let Ze;e[22]!==r||e[23]!==n.length||e[24]!==ze||e[25]!==L?(Ze=[r,n.length,ze,L],e[22]=r,e[23]=n.length,e[24]=ze,e[25]=L,e[26]=Ze):Ze=e[26],h.useEffect(Oe,Ze);let at;e[27]!==ze?(at=()=>{ze()},e[27]=ze,e[28]=at):at=e[28],h.useLayoutEffect(at);let De;e[29]!==H?(De=H.join("\0"),e[29]=H,e[30]=De):De=e[30];const Je=De;let et,Ke;e[31]!==r||e[32]!==Je||e[33]!==L?(et=()=>{if(!L){ue.current=!1,de(!1);return}const Pe=J.current!==Je;if(J.current=Je,!ue.current){ue.current=!0,$.current=r;return}const xe=$.current!==r;if($.current=r,!xe||Pe){de(!1);return}v.current=performance.now(),de(!0)},Ke=[r,Je,L],e[31]=r,e[32]=Je,e[33]=L,e[34]=et,e[35]=Ke):(et=e[34],Ke=e[35]),h.useLayoutEffect(et,Ke);let ke;e[36]!==r||e[37]!==z||e[38]!==Ge?(ke=()=>{if(!z||!r)return;const Pe=W.current;if(!Pe)return;const xe=window.requestAnimationFrame(()=>{const ot=typeof window.CSS?.escape=="function"?window.CSS.escape(r):r.replace(/"/g,'\\"'),lt=Pe.querySelector(`[data-sortable-tab-id="${ot}"]`);lt&&(lt.scrollIntoView({block:"nearest",inline:"nearest"}),Ge())});return()=>{window.cancelAnimationFrame(xe)}},e[36]=r,e[37]=z,e[38]=Ge,e[39]=ke):ke=e[39];let rt;e[40]!==r||e[41]!==z||e[42]!==n.length||e[43]!==Ge?(rt=[r,z,n.length,Ge],e[40]=r,e[41]=z,e[42]=n.length,e[43]=Ge,e[44]=rt):rt=e[44],h.useEffect(ke,rt);let x;e[45]!==i?(x=Pe=>{if(!i)return;const{active:xe,over:ot}=Pe;!ot||xe.id===ot.id||i(String(xe.id),String(ot.id))},e[45]=i,e[46]=x):x=e[46];const R=x;let be;e[47]!==w?(be=le("relative flex h-full min-w-0 flex-1",w),e[47]=w,e[48]=be):be=e[48];let fe;e[49]!==z||e[50]!==F||e[51]!==T?(fe=z&&F.left?t.jsx("div",{className:le("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",T?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[49]=z,e[50]=F,e[51]=T,e[52]=fe):fe=e[52];let Se;e[53]!==z||e[54]!==F||e[55]!==T?(Se=z&&F.right?t.jsx("div",{className:le("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",T?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[53]=z,e[54]=F,e[55]=T,e[56]=Se):Se=e[56];const Be=T?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",Re=T&&"@container/pill-tabs",qe=T&&"pill-tabs__track",Ee=T&&(c??"gap-0.5 py-0.5"),ft=V&&"items-center overflow-y-hidden",ct=K&&"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",ut=z?"overflow-x-auto scrollbar-none":"overflow-x-hidden";let it;e[57]!==Be||e[58]!==Re||e[59]!==qe||e[60]!==Ee||e[61]!==ft||e[62]!==ct||e[63]!==ut?(it=le("relative flex h-full min-w-0 flex-1",Be,Re,qe,Ee,ft,ct,ut),e[57]=Be,e[58]=Re,e[59]=qe,e[60]=Ee,e[61]=ft,e[62]=ct,e[63]=ut,e[64]=it):it=e[64];let P;e[65]!==z?(P=z?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,e[65]=z,e[66]=P):P=e[66];let me;e[67]!==N?(me=N("sortableTabsStrip.aria.tabs"),e[67]=N,e[68]=me):me=e[68];let Ie;e[69]!==j||e[70]!==ie||e[71]!==ee||e[72]!==se||e[73]!==re||e[74]!==T?(Ie=T&&ee?t.jsx("div",{className:le("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&&se&&(j?"pill-tabs__indicator--is-animated-layout":"pill-tabs__indicator--is-animated")),style:j?{left:`${ee.left+ie}px`,top:`${ee.top}px`,width:`${ee.width}px`,height:`${ee.height}px`}:{transform:`translate3d(${ee.left+ie}px, ${ee.top}px, 0)`,width:`${ee.width}px`,height:`${ee.height}px`}}):null,e[69]=j,e[70]=ie,e[71]=ee,e[72]=se,e[73]=re,e[74]=T,e[75]=Ie):Ie=e[75];let Te;e[76]!==ie||e[77]!==ee||e[78]!==se||e[79]!==V?(Te=V&&ee?t.jsx("div",{className:le("pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",se&&"underline-tabs__indicator--is-animated"),style:{transform:`translate3d(${ee.left+ie}px, 0, 0)`,width:`${ee.width}px`},"aria-hidden":!0}):null,e[76]=ie,e[77]=ee,e[78]=se,e[79]=V,e[80]=Te):Te=e[80];let Me;if(e[81]!==Y||e[82]!==r||e[83]!==u||e[84]!==M||e[85]!==O||e[86]!==A||e[87]!==U||e[88]!==y||e[89]!==z||e[90]!==H||e[91]!==n||e[92]!==a||e[93]!==o||e[94]!==b||e[95]!==D||e[96]!==T||e[97]!==L){let Pe;e[99]!==Y||e[100]!==r||e[101]!==u||e[102]!==M||e[103]!==O||e[104]!==A||e[105]!==U||e[106]!==y||e[107]!==z||e[108]!==H||e[109]!==a||e[110]!==o||e[111]!==b||e[112]!==D||e[113]!==T||e[114]!==L?(Pe=(xe,ot)=>{const lt=xe.id===r,pt=A&&T&&!lt&&!!xe.icon,xt=!pt,St=!!xe.icon,kt=A&&T&&lt&&!z&&!D,wt=xe.closable!==!1&&!!a,jt=wt&&!!xe.icon,Ct=z||D?void 0:T?kt?"flex-none basis-auto":y?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",Rt=wt?ht=>{ht.button===1&&(ht.preventDefault(),ht.stopPropagation(),a?.(xe.id))}:void 0,_t=wt?Jl:void 0,Lt=!y&&b?b({id:xe.id,index:ot,isActive:lt,allIds:H,close:()=>a?.(xe.id)}):null,Qt=t.jsxs("div",{ref:ht=>Ye(xe.id,ht),onAuxClick:Rt,onMouseDown:_t,className:le("group flex h-full min-w-0 flex-nowrap items-center",z||D?"shrink-0":T?"w-full":"w-full min-w-0",T?"relative z-10 bg-transparent":lt?"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":lt,"aria-label":pt?xe.title??xe.label:void 0,onClick:()=>o(xe.id),onPointerDown:L?()=>{de(!0),ae(xe.id)}:void 0,onPointerUp:L?()=>ae(null):void 0,onPointerLeave:L?()=>ae(null):void 0,onPointerCancel:L?()=>ae(null):void 0,className:le(T?"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",T&&M?"lowercase":null,T&&(pt?"gap-0":"gap-1.5"),T?D?"shrink-0 whitespace-nowrap px-3 text-center":z?"max-w-56 shrink-0 px-3 text-center":pt?"px-2 !min-w-0 text-center":kt?"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",T?u??(U?y?"h-[38px]":"h-[31px]":"h-7"):null,T?lt?"text-foreground":"text-muted-foreground hover:text-foreground":null,T?"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:xe.title??xe.label,children:T?t.jsxs(t.Fragment,{children:[St?t.jsxs("span",{className:"relative flex h-4 w-4 shrink-0 items-center justify-center",children:[t.jsx("span",{className:le("flex items-center justify-center transition-opacity",jt&&(O?"opacity-0":"group-hover:opacity-0")),children:xe.icon}),jt?t.jsx("span",{role:"button",tabIndex:-1,className:le("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",O?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:Ql,onClick:ht=>{ht.stopPropagation(),a?.(xe.id)},"aria-label":xe.closeLabel??`Close ${xe.label} tab`,title:xe.closeLabel??`Close ${xe.label} tab`,children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,xt?t.jsx("span",{className:"animated-tabs__label truncate",children:xe.label}):null]}):t.jsxs("span",{className:le("flex min-w-0 flex-nowrap items-center gap-1.5",!z&&"justify-center"),children:[St?t.jsxs("span",{className:le("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",lt?"text-[var(--primary-base)]":"text-muted-foreground"),children:[t.jsx("span",{className:le("flex items-center justify-center transition-opacity",jt&&(O?"opacity-0":"group-hover:opacity-0")),children:xe.icon}),jt?t.jsx("span",{role:"button",tabIndex:-1,className:le("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",O?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:Xl,onClick:ht=>{ht.stopPropagation(),a?.(xe.id)},"aria-label":xe.closeLabel??`Close ${xe.label} tab`,title:xe.closeLabel??`Close ${xe.label} tab`,children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,t.jsx("span",{className:"truncate leading-[1.2]",children:xe.label})]})}),wt&&!jt?t.jsx("button",{type:"button",onPointerDown:Zl,onClick:ht=>{ht.stopPropagation(),a?.(xe.id)},className:le("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",T?"-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",T?lt?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":lt?"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":xe.closeLabel??`Close ${xe.label} tab`,title:xe.closeLabel??`Close ${xe.label} tab`,children:t.jsx(E,{name:"close",className:"h-3 w-3"})}):null]});return t.jsx(Y,{id:xe.id,className:Ct,children:Lt?t.jsxs(Ol,{children:[t.jsx($l,{render:ht=>t.jsx("div",{...ht,className:le("flex h-full min-w-0",ht.className),children:Qt})}),t.jsx(Ul,{className:"w-52",children:Lt})]}):Qt},xe.id)},e[99]=Y,e[100]=r,e[101]=u,e[102]=M,e[103]=O,e[104]=A,e[105]=U,e[106]=y,e[107]=z,e[108]=H,e[109]=a,e[110]=o,e[111]=b,e[112]=D,e[113]=T,e[114]=L,e[115]=Pe):Pe=e[115],Me=n.map(Pe),e[81]=Y,e[82]=r,e[83]=u,e[84]=M,e[85]=O,e[86]=A,e[87]=U,e[88]=y,e[89]=z,e[90]=H,e[91]=n,e[92]=a,e[93]=o,e[94]=b,e[95]=D,e[96]=T,e[97]=L,e[98]=Me}else Me=e[98];let I;e[116]!==it||e[117]!==P||e[118]!==me||e[119]!==Ie||e[120]!==Te||e[121]!==Me?(I=t.jsxs("div",{ref:W,className:it,style:P,role:"tablist","aria-label":me,children:[Ie,Te,Me]}),e[116]=it,e[117]=P,e[118]=me,e[119]=Ie,e[120]=Te,e[121]=Me,e[122]=I):I=e[122];let ne;e[123]!==be||e[124]!==fe||e[125]!==Se||e[126]!==I?(ne=t.jsxs("div",{className:be,children:[fe,Se,I]}),e[123]=be,e[124]=fe,e[125]=Se,e[126]=I,e[127]=ne):ne=e[127];const ge=ne;if(!X)return ge;let He;e[128]===Symbol.for("react.memo_cache_sentinel")?(He=[_l],e[128]=He):He=e[128];let ye;e[129]!==H||e[130]!==ge?(ye=t.jsx(Xr,{items:H,strategy:Wi,children:ge}),e[129]=H,e[130]=ge,e[131]=ye):ye=e[131];let $e;e[132]===Symbol.for("react.memo_cache_sentinel")?($e=t.jsx(Ui,{dropAnimation:null}),e[132]=$e):$e=e[132];let dt;return e[133]!==R||e[134]!==Ne||e[135]!==ye?(dt=t.jsxs(Yr,{sensors:Ne,collisionDetection:Jr,onDragEnd:R,modifiers:He,children:[ye,$e]}),e[133]=R,e[134]=Ne,e[135]=ye,e[136]=dt):dt=e[136],dt};function Gl(s){return s.isMobile}function Hl(s){return s.id}function Kl(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 ql(s){return s===null?s:null}function Yl(s){return s===null?s:null}function Jl(s){s.button===1&&s.preventDefault()}function Ql(s){s.stopPropagation()}function Xl(s){s.stopPropagation()}function Zl(s){s.stopPropagation()}const Kt=Ks()(zr(Vr((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 Yo();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 qo();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 Ko();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 o=r.trim();return o.length>0?o:null};try{let r=null;if(r===null){const o=bi()?.settings;if(o)try{const i=(await o.load())?.settings||{};r=n(i.defaultGitIdentityId)}catch{}}if(r===null)try{const o=await Mt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(o.ok){const a=await o.json().catch(()=>null);r=n(a?.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():"",o=r.length>0?r:"";return await Ur({defaultGitIdentityId:o}),s({defaultGitIdentityId:o.length>0?o:null}),!0}catch(r){return console.error("Failed to save default git identity setting:",r),!1}},createProfile:async n=>{try{const r={...n,id:n.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:n.color||"keyword",icon:n.icon||"branch"};return Ot("saving"),await Ho(r),Ot("saved"),await e().loadProfiles(),!0}catch(r){return Ot("error"),console.error("Failed to create git identity profile:",r),!1}},updateProfile:async(n,r)=>{try{const o=e().profiles.find(i=>i.id===n);if(!o)throw new Error("Profile not found");const a={...o,...r};return Ot("saving"),await Go(n,a),Ot("saved"),await e().loadProfiles(),!0}catch(o){return Ot("error"),console.error("Failed to update git identity profile:",o),!1}},deleteProfile:async n=>{try{return Ot("saving"),await Vo(n),Ot("saved"),e().selectedProfileId===n&&s({selectedProfileId:null}),await e().loadProfiles(),!0}catch(r){return Ot("error"),console.error("Failed to delete git identity profile:",r),!1}},getProfileById:n=>{const{profiles:r,globalIdentity:o}=e();return n==="global"?o||void 0:r.find(a=>a.id===n)},getUnimportedCredentials:()=>{const{profiles:n,discoveredCredentials:r}=e();return r.filter(o=>!n.some(a=>a.authType==="token"&&a.host===o.host))}}),{name:"git-identities-store",storage:xi(),partialize:s=>({selectedProfileId:s.selectedProfileId})}),{name:"git-identities-store"}));typeof window<"u"&&(window.__zustand_git_identities_store__=Kt);const Ws=Jo,Wt=s=>{const e=We.c(11),{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:d,children:l,className:c,contentClassName:u,divider:m}=s,g=m===void 0?!0:m;let p;return e[0]!==l||e[1]!==c||e[2]!==u||e[3]!==r||e[4]!==g||e[5]!==d||e[6]!==o||e[7]!==a||e[8]!==n||e[9]!==i?(p=t.jsx(Qo,{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:d,divider:g,className:c,contentClassName:u,children:l}),e[0]=l,e[1]=c,e[2]=u,e[3]=r,e[4]=g,e[5]=d,e[6]=o,e[7]=a,e[8]=n,e[9]=i,e[10]=p):p=e[10],p},ec=450,tc=({projectRef:s=null,sections:e="all"})=>{const{t:n}=nt(),{isMobile:r,isTablet:o}=Vs(),a=r||o,i=It(D=>D.getActiveProject()),d=s?.path??i?.path??null,l=st(D=>D.getWorktreeMetadata),c=Xo(),u=gs(D=>D.homeDirectory),[m,g]=h.useState([]),[p,f]=h.useState(!1),[b,w]=h.useState(!1),[C,k]=h.useState(null),[A,M]=h.useState(null),[j,N]=h.useState([]),[y,S]=h.useState(!1),O=h.useRef(!1),W=h.useMemo(()=>s?.id&&s?.path?{id:s.id,path:s.path}:!i?.id||!d?null:{id:i.id,path:d},[i?.id,d,s?.id,s?.path]),B=h.useCallback(async()=>{if(!(!W||A===!1))try{const D=await Mn(W);N(D)}catch{}},[W,A]);h.useEffect(()=>{if(!d)return;let D=!1;return M(null),(async()=>{try{const K=await Zo(d);if(D)return;M(K)}catch{}})(),()=>{D=!0}},[d]),h.useEffect(()=>{if(!W){N([]),S(!1);return}if(A===!1){N([]),S(!1);return}let D=!1;return S(!0),N([]),(async()=>{try{const K=await Mn(W);if(D)return;N(K)}catch{}finally{D||S(!1)}})(),()=>{D=!0}},[W,A]),h.useEffect(()=>{if(!W)return;let D=!1;return w(!0),(async()=>{try{const[K,re]=await Promise.all([jr(W),Nr(W)]);if(!D){const X=K.length>0?K:[""];g(X),k(JSON.stringify(X)),f(re)}}catch{D||(g([""]),k(JSON.stringify([""])),f(!1))}finally{D||w(!1)}})(),()=>{D=!0}},[W]);const F=h.useCallback(async D=>{if(!W)return!1;const K=D.filter(re=>re.trim().length>0);try{return await ea(W,K)?(k(JSON.stringify(D)),!0):(je.error(n("settings.openchamber.worktrees.setup.toast.saveFailed")),!1)}catch{return je.error(n("settings.openchamber.worktrees.setup.toast.saveFailed")),!1}},[W,n]),_=h.useMemo(()=>C===null?!1:C!==JSON.stringify(m),[C,m]);h.useEffect(()=>{if(!_||b||O.current)return;const D=window.setTimeout(()=>{O.current||(O.current=!0,(async()=>{try{await F(m)}finally{O.current=!1}})())},ec);return()=>{window.clearTimeout(D)}},[_,b,F,m]);const te=h.useCallback((D,K)=>{g(re=>{const X=[...re];return X[D]=K,X})},[]),H=h.useCallback(()=>{g(D=>[...D,""])},[]),z=h.useCallback(D=>{g(K=>{const re=K.filter((X,Y)=>Y!==D);return re.length>0?re:[""]})},[]),G=h.useCallback(()=>{!_||O.current||(O.current=!0,(async()=>{try{await F(m)}finally{O.current=!1}})())},[_,F,m]),U=h.useCallback(D=>{f(D),W&&ta(W,D)},[W]),q=h.useCallback(D=>{const K=de=>de.replace(/\\/g,"/").replace(/\/+$/,""),re=K(D.path),X=c.filter(de=>{const Q=l(de.id);if(Q?.path&&K(Q.path)===re)return!0;const ae=de.directory;return!!(ae&&K(ae)===re)}),Y=new Set(X.map(de=>de.id)),oe=[...qt.getState().activeSessions,...qt.getState().archivedSessions],Z=de=>{const Q=oe.filter(ue=>{const v=ue.parentID;return v&&de.has(v)});if(Q.length===0)return[];const ae=new Set(Q.map(ue=>ue.id));return[...Q,...Z(ae)]},ee=Z(Y),pe=new Set,se=[...X,...ee].filter(de=>pe.has(de.id)?!1:(pe.add(de.id),!0));sa.requestDelete({sessions:se,mode:"worktree",worktree:D})},[c,l]),T=h.useMemo(()=>c.map(D=>D.id).join(","),[c]);h.useEffect(()=>{A&&d&&B()},[T,A,d,B]);const V=t.jsxs(mn,{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")]}),L=t.jsx(mn,{children:n("settings.openchamber.worktrees.list.tooltip")});return d?A===!1?t.jsx(Wt,{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(Wt,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",titleAccessory:V,children:b?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.setup.loading")}):t.jsxs("div",{className:le("space-y-2",Ws),children:[m.map((D,K)=>t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(yt,{value:D,onChange:re=>te(K,re.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(Ce,{type:"button",variant:"ghost",size:"icon",onClick:()=>z(K),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(E,{name:"close",className:"h-4 w-4"})})]},K)),t.jsxs(Ce,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:H,children:[t.jsx(E,{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(Ts,{checked:p,onChange:U,ariaLabel:n("settings.openchamber.worktrees.setup.waitForCommandsAria")}),t.jsx("span",{className:le("typography-ui-label font-normal",p?"text-foreground":"text-foreground/60"),children:n("settings.openchamber.worktrees.setup.waitForCommands")})]})]})}):null,t.jsx(Wt,{title:n("settings.openchamber.worktrees.list.title"),titleAccessory:L,children:y?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.list.loading")}):j.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:n("settings.openchamber.worktrees.list.empty")}):t.jsx("div",{className:le("space-y-1",e==="all"&&Ws),children:j.map(D=>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:D.label||D.branch||n("settings.openchamber.worktrees.list.detachedHead")})}),t.jsx("p",{className:"typography-micro truncate text-muted-foreground/60",children:na(D.path,u)})]}),t.jsx("button",{type:"button",onClick:()=>q(D),className:le("flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",a?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":n("settings.openchamber.worktrees.list.deleteWorktreeAria",{name:D.branch||D.label||D.path}),children:t.jsx(E,{name:"delete-bin",className:"h-4 w-4"})})]},D.path))})})]}):t.jsx(Wt,{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")})})},tr=(s,e)=>e.updatedAtMs-s.updatedAtMs,sr=Ks((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([ia(),Fn()]),o={};for(const a of r.sort(tr))o[a.id]=a;e().listenerReady||await la(a=>{s(i=>({statusesById:{...i.statusesById,[a.id]:a}}))}),s({instances:n.instances,statusesById:o,isLoading:!1,initialized:!0,listenerReady:!0})}catch(n){s({isLoading:!1,error:n instanceof Error?n.message:String(n)})}}},loadImports:async()=>{if(!e().isImportsLoading){s({isImportsLoading:!0,error:null});try{const n=await aa();s({importCandidates:n,isImportsLoading:!1})}catch(n){s({isImportsLoading:!1,error:n instanceof Error?n.message:String(n)})}}},refreshStatuses:async()=>{try{const n=await Fn(),r={};for(const o of n.sort(tr))r[o.id]=o;s({statusesById:r})}catch(n){s({error:n instanceof Error?n.message:String(n)})}},setInstances:async n=>{s({isSaving:!0,error:null});try{await oa({instances:n}),s({instances:n,isSaving:!1}),await e().refreshStatuses()}catch(r){throw s({isSaving:!1,error:r instanceof Error?r.message:String(r)}),r}},upsertInstance:async n=>{const r=e().instances,o=r.some(a=>a.id===n.id)?r.map(a=>a.id===n.id?n:a):[n,...r];await e().setInstances(o)},createFromCommand:async(n,r,o)=>{const a=ca(n,r);o&&o.trim()&&(a.nickname=o.trim()),await e().upsertInstance(a)},removeInstance:async n=>{await Ln(n).catch(()=>{});const r=e().instances.filter(o=>o.id!==n);await e().setInstances(r),s(o=>{const a={...o.statusesById};return delete a[n],{statusesById:a}})},connect:async n=>{s({error:null});try{await ra(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 Ln(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})})),no=[{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"}],ro=Object.fromEntries(no.map(s=>[s.key,s.Icon])),sc="openchamber:project-actions-updated",nc=s=>{const e=(s||"").trim().replace(/\\/g,"/");return e?e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e:""},Df=(s,e)=>`${nc(s)}::${e}`,rc=s=>{const e=s.trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},nr=s=>{if(typeof s!="number"||!Number.isFinite(s))return null;const e=Math.round(s);return e<1||e>65535?null:e},oc=(s,e)=>{if(!e.enabled||e.type!=="local")return null;const n=nr(e.localPort),r=nr(e.remotePort);if(!n||!r)return null;const o=rc(e.localHost||s.localForward.bindHost||"127.0.0.1"),a=(e.remoteHost||"127.0.0.1").trim(),i=(s.nickname||s.id||"instance").trim();return{id:`${s.id}::${e.id}`,label:`${i} - ${o}:${n} -> ${a}:${r}`,url:`http://${o}:${n}`}},oo=s=>{const e=[];for(const n of s)if(!(!n?.id||!Array.isArray(n.portForwards)))for(const r of n.portForwards){const o=oc(n,r);o&&e.push(o)}return e},Pf=(s,e)=>{const n=(s||"").trim();return n&&oo(e).find(a=>a.id===n)?.url||null},ac=450,ic=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`action_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,lc=()=>({id:ic(),name:"",command:"",icon:"play"}),cc=({projectRef:s})=>{const{t:e}=nt(),n=h.useMemo(()=>Wr(),[]),r=sr(N=>N.instances),o=sr(N=>N.load),[a,i]=h.useState([]),[d,l]=h.useState(!1),[c,u]=h.useState(null),[m,g]=h.useState({}),p=h.useRef(!1),f=h.useRef(null);h.useEffect(()=>{n&&o().catch(()=>{})},[n,o]),h.useEffect(()=>{let N=!1;return l(!0),(async()=>{try{const y=await da(s);if(N)return;i(y.actions),u(JSON.stringify({actions:y.actions}))}catch{if(N)return;i([]),u(JSON.stringify({actions:[]}))}finally{N||l(!1)}})(),()=>{N=!0}},[s]);const b=h.useMemo(()=>n?oo(r):[],[r,n]),w=h.useMemo(()=>a.some(y=>y.name.trim().length===0||y.command.trim().length===0)?e("settings.projects.actions.validation.fillNameAndCommand"):null,[a,e]),C=h.useMemo(()=>c===null?!1:c!==JSON.stringify({actions:a}),[a,c]),k=h.useCallback(async N=>await ua(s,{actions:N,primaryActionId:null})?(u(JSON.stringify({actions:N})),typeof window<"u"&&window.dispatchEvent(new CustomEvent(sc,{detail:{projectId:s.id}})),!0):(je.error(e("settings.projects.actions.toast.saveFailed")),!1),[s,e]);h.useEffect(()=>{if(!C||d||w||p.current)return;const N=window.setTimeout(()=>{p.current||(p.current=!0,(async()=>{try{await k(a)}finally{p.current=!1}})())},ac);return()=>{window.clearTimeout(N)}},[a,C,d,k,w]),h.useEffect(()=>{if(!C||!w||d){w||(f.current=null);return}const N=window.setTimeout(()=>{f.current!==w&&(f.current=w,je.error(w))},1e3);return()=>{window.clearTimeout(N)}},[C,d,w]);const A=h.useCallback(()=>{const N=lc();i(y=>[...y,N]),g(y=>({...y,[N.id]:!0}))},[]),M=h.useCallback(N=>{i(y=>y.filter(S=>S.id!==N)),g(y=>{const S={...y};return delete S[N],S})},[]),j=h.useCallback((N,y)=>{i(S=>S.map(O=>O.id===N?y(O):O))},[]);return t.jsxs(Wt,{title:e("settings.projects.actions.title"),info:e("settings.projects.actions.description"),settingsItem:"projects.actions",headerAction:t.jsxs(Ce,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:A,children:[t.jsx(E,{name:"add",className:"h-3.5 w-3.5"}),e("settings.projects.actions.actions.add")]}),contentClassName:"space-y-0",children:[d?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.loading")}):a.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.empty")}):t.jsx("div",{className:le("space-y-0",Ws),children:a.map(N=>{const y=N.icon||"play",S=ro[y]||"play",O=m[N.id]??!1,W=N.name.trim()||e("settings.projects.actions.state.untitled");return t.jsxs(jl,{open:O,onOpenChange:B=>{g(F=>({...F,[N.id]:B}))},className:"py-1.5",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs(Nl,{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:[O?t.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):t.jsx(E,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),t.jsx(E,{name:S,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:W})})]}),t.jsx(Ce,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>M(N.id),children:t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(kl,{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(zt,{children:[t.jsx(Vt,{asChild:!0,children:t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]","aria-label":e("settings.projects.actions.field.selectIconAria"),children:t.jsx(E,{name:S,className:"h-4 w-4"})})}),t.jsx(Gt,{align:"start",className:"w-56 p-2",children:t.jsx("div",{className:"grid grid-cols-6 gap-1",children:no.map(B=>{const F=B.Icon,_=(N.icon||"play")===B.key;return t.jsx("button",{type:"button",onClick:()=>j(N.id,te=>({...te,icon:B.key})),className:le("inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]",_&&"border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]"),"aria-label":e("settings.projects.actions.field.iconAria",{icon:B.label}),children:t.jsx(E,{name:F,className:"h-4 w-4"})},B.key)})})})]}),t.jsx(yt,{value:N.name,onChange:B=>j(N.id,F=>({...F,name:B.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(Gs,{value:N.command,onChange:B=>j(N.id,F=>({...F,command:B.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:()=>j(N.id,B=>({...B,...B.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:B=>{(B.key===" "||B.key==="Enter")&&(B.preventDefault(),j(N.id,F=>({...F,...F.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[t.jsx(Ts,{checked:N.autoOpenUrl===!0,onChange:B=>j(N.id,F=>({...F,...B?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:e("settings.projects.actions.field.autoOpenUrlForAria",{title:W})}),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(yt,{value:N.openUrl||"",onChange:B=>j(N.id,F=>({...F,openUrl:B.target.value})),placeholder:e("settings.projects.actions.field.overrideUrlPlaceholder"),className:"h-7 w-full max-w-[24rem]"}),t.jsx(mn,{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")}),b.length>0?t.jsxs(kr,{value:N.desktopOpenSshForward&&b.some(B=>B.id===N.desktopOpenSshForward)?N.desktopOpenSshForward:"__none__",onValueChange:B=>{j(N.id,F=>({...F,...B==="__none__"?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:B}}))},children:[t.jsx(Ir,{size:Cr,className:"w-full",children:t.jsx(Tr,{placeholder:e("settings.projects.actions.field.useOutputManualUrl")})}),t.jsxs(Dr,{children:[t.jsx(Os,{value:"__none__",children:e("settings.projects.actions.field.useOutputManualUrl")}),b.map(B=>t.jsx(Os,{value:B.id,children:B.label},B.id))]})]}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.noDesktopSshForwards")})]}):null]}):null]})]})})]},N.id)})}),w&&a.length>0?t.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:w}):null]})},dc=s=>{if(!s)return[];const e=s.variants;return e?Object.keys(e):[]},en="__default__",ao=s=>s.charAt(0).toUpperCase()+s.slice(1),uc=s=>{const e=We.c(138),{form:n}=s,{t:r}=nt(),{currentTheme:o}=Pr(),a=Nt(fc),{name:i,setName:d,icon:l,setIcon:c,color:u,setColor:m,iconBackground:g,setIconBackground:p,parsedDefaultModel:f,defaultVariant:b,handleDefaultModelChange:w,handleDefaultVariantChange:C,isUploadingIcon:k,isRemovingCustomIcon:A,isDiscoveringIcon:M,pendingRemoveImageIcon:j,setPendingRemoveImageIcon:N,pendingUploadIconPreviewUrl:y,setPreviewImageFailed:S,hasPendingUploadImageIcon:O,hasCustomIcon:W,effectiveHasImageIcon:B,hasRemovableImageIcon:F,showImagePreview:_,fileInputRef:te,handleUploadIcon:H,handleRemoveImageIcon:z,handleDiscoverIcon:G,currentIconImage:U,project:q}=n;let T;e:{const{providerId:fe,modelId:Se}=f;if(!fe||!Se){let Re;e[0]===Symbol.for("react.memo_cache_sentinel")?(Re=[],e[0]=Re):Re=e[0],T=Re;break e}let Be;if(e[1]!==Se||e[2]!==fe||e[3]!==a){const Re=a.find(qe=>qe.id===fe)?.models.find(qe=>qe.id===Se);Be=dc(Re),e[1]=Se,e[2]=fe,e[3]=a,e[4]=Be}else Be=e[4];T=Be}const V=T;if(!q)return null;const L=u?fa[u]??null:null;let D;e[5]!==r?(D=r("settings.projects.page.field.projectName"),e[5]=r,e[6]=D):D=e[6];let K;e[7]!==d?(K=fe=>d(fe.target.value),e[7]=d,e[8]=K):K=e[8];let re;e[9]!==r?(re=r("settings.projects.page.field.projectNamePlaceholder"),e[9]=r,e[10]=re):re=e[10];let X;e[11]===Symbol.for("react.memo_cache_sentinel")?(X=le("h-8 rounded-md px-3",Ws),e[11]=X):X=e[11];let Y;e[12]!==i||e[13]!==K||e[14]!==re?(Y=t.jsx(yt,{value:i,onChange:K,placeholder:re,className:X}),e[12]=i,e[13]=K,e[14]=re,e[15]=Y):Y=e[15];let oe;e[16]!==D||e[17]!==Y?(oe=t.jsx(Wt,{title:D,settingsItem:"projects.name",divider:!1,children:Y}),e[16]=D,e[17]=Y,e[18]=oe):oe=e[18];let Z;e[19]!==r?(Z=r("settings.projects.page.section.chatDefaults"),e[19]=r,e[20]=Z):Z=e[20];let ee;e[21]!==r?(ee=r("settings.projects.page.section.chatDefaultsDescription"),e[21]=r,e[22]=ee):ee=e[22];let pe;e[23]!==r?(pe=r("settings.projects.page.field.projectModel"),e[23]=r,e[24]=pe):pe=e[24];let se;e[25]!==w||e[26]!==f.modelId||e[27]!==f.providerId?(se=t.jsx(Sr,{providerId:f.providerId,modelId:f.modelId,onChange:w,className:ma}),e[25]=w,e[26]=f.modelId,e[27]=f.providerId,e[28]=se):se=e[28];let de;e[29]!==pe||e[30]!==se?(de=t.jsx(On,{settingsItem:"projects.default-model",label:pe,children:se}),e[29]=pe,e[30]=se,e[31]=de):de=e[31];let Q;e[32]!==V||e[33]!==b||e[34]!==C||e[35]!==r?(Q=V.length>0?t.jsx(On,{settingsItem:"projects.default-thinking",label:r("settings.projects.page.field.projectThinking"),children:t.jsxs(kr,{value:b??en,onValueChange:fe=>C(fe===en?void 0:fe),children:[t.jsx(Ir,{size:Cr,className:ha,"aria-label":r("settings.projects.page.field.projectThinking"),children:t.jsx(Tr,{children:b?ao(b):r("settings.projects.page.option.thinkingDefault")})}),t.jsxs(Dr,{children:[t.jsx(Os,{value:en,children:r("settings.projects.page.option.thinkingDefault")}),V.map(mc)]})]})}):null,e[32]=V,e[33]=b,e[34]=C,e[35]=r,e[36]=Q):Q=e[36];let ae;e[37]!==de||e[38]!==Q||e[39]!==Z||e[40]!==ee?(ae=t.jsxs(Wt,{title:Z,info:ee,contentClassName:"space-y-0",children:[de,Q]}),e[37]=de,e[38]=Q,e[39]=Z,e[40]=ee,e[41]=ae):ae=e[41];let ue;e[42]!==r?(ue=r("settings.projects.page.field.accentColor"),e[42]=r,e[43]=ue):ue=e[43];let v;e[44]!==m?(v=()=>m(null),e[44]=m,e[45]=v):v=e[45];const $=u===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let J;e[46]!==$?(J=le("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",$),e[46]=$,e[47]=J):J=e[47];let he;e[48]!==r?(he=r("settings.projects.page.field.none"),e[48]=r,e[49]=he):he=e[49];let ie;e[50]===Symbol.for("react.memo_cache_sentinel")?(ie=t.jsx(E,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[50]=ie):ie=e[50];let ve;e[51]!==v||e[52]!==J||e[53]!==he?(ve=t.jsx("button",{type:"button",onClick:v,className:J,title:he,children:ie}),e[51]=v,e[52]=J,e[53]=he,e[54]=ve):ve=e[54];let Ne;e[55]!==u||e[56]!==m?(Ne=pa.map(fe=>t.jsx("button",{type:"button",onClick:()=>m(fe.key),className:le("h-7 w-7 rounded-md border transition-colors",u===fe.key?"border-2 border-foreground ring-1 ring-[var(--primary-base)]/40":"border-transparent hover:border-border/70"),style:{backgroundColor:fe.cssVar},title:fe.label},fe.key)),e[55]=u,e[56]=m,e[57]=Ne):Ne=e[57];let Ve;e[58]!==ve||e[59]!==Ne?(Ve=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[ve,Ne]}),e[58]=ve,e[59]=Ne,e[60]=Ve):Ve=e[60];let Le;e[61]!==ue||e[62]!==Ve?(Le=t.jsx(Wt,{title:ue,settingsItem:"projects.accent-color",children:Ve}),e[61]=ue,e[62]=Ve,e[63]=Le):Le=e[63];let Ye;e[64]!==r?(Ye=r("settings.projects.page.field.projectIcon"),e[64]=r,e[65]=Ye):Ye=e[65];let Xe;e[66]!==H?(Xe=fe=>{const Se=fe.target.files?.[0]??null;H(Se),fe.currentTarget.value=""},e[66]=H,e[67]=Xe):Xe=e[67];let ze;e[68]!==te||e[69]!==Xe?(ze=t.jsx("input",{ref:te,type:"file",accept:"image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg",className:"hidden",onChange:Xe}),e[68]=te,e[69]=Xe,e[70]=ze):ze=e[70];let Fe;e[71]!==c?(Fe=()=>c(null),e[71]=c,e[72]=Fe):Fe=e[72];const Ge=l===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let Ae;e[73]!==Ge?(Ae=le("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",Ge),e[73]=Ge,e[74]=Ae):Ae=e[74];let _e;e[75]!==r?(_e=r("settings.projects.page.field.none"),e[75]=r,e[76]=_e):_e=e[76];let Oe;e[77]===Symbol.for("react.memo_cache_sentinel")?(Oe=t.jsx(E,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[77]=Oe):Oe=e[77];let Ze;e[78]!==Fe||e[79]!==Ae||e[80]!==_e?(Ze=t.jsx("button",{type:"button",onClick:Fe,className:Ae,title:_e,children:Oe}),e[78]=Fe,e[79]=Ae,e[80]=_e,e[81]=Ze):Ze=e[81];let at;e[82]!==L||e[83]!==l||e[84]!==c?(at=ga.map(fe=>{const Se=fe.Icon;return t.jsx("button",{type:"button",onClick:()=>c(fe.key),className:le("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",l===fe.key?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-transparent hover:border-border hover:bg-[var(--surface-muted)]"),title:fe.label,children:t.jsx(E,{name:Se,className:"w-4 h-4",style:L&&l===fe.key?{color:L}:void 0})},fe.key)}),e[82]=L,e[83]=l,e[84]=c,e[85]=at):at=e[85];let De;e[86]!==Ze||e[87]!==at?(De=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Ze,at]}),e[86]=Ze,e[87]=at,e[88]=De):De=e[88];let Je;e[89]!==U||e[90]!==o||e[91]!==B||e[92]!==O||e[93]!==g||e[94]!==y||e[95]!==q||e[96]!==S||e[97]!==_||e[98]!==r?(Je=B&&_&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-meta text-muted-foreground",children:r("settings.projects.page.field.preview")}),t.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1",children:t.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:g?{backgroundColor:g}:void 0,children:O&&y?t.jsx("img",{src:y,alt:"",className:"h-full w-full object-contain",draggable:!1,onError:()=>S(!0)}):t.jsx(xa,{project:{...q,iconImage:U??q.iconImage},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"h-full w-full object-contain",onError:()=>S(!0)})})})]}),e[89]=U,e[90]=o,e[91]=B,e[92]=O,e[93]=g,e[94]=y,e[95]=q,e[96]=S,e[97]=_,e[98]=r,e[99]=Je):Je=e[99];let et;e[100]!==B||e[101]!==g||e[102]!==p||e[103]!==r?(et=B&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("input",{type:"color",value:g??"#000000",onChange:fe=>p(fe.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(yt,{value:g??"",onChange:fe=>p(fe.target.value),placeholder:"#000000",className:"h-7 w-[8rem]"}),t.jsx(Ce,{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(E,{name:"close",className:"h-3.5 w-3.5"})})]}),e[100]=B,e[101]=g,e[102]=p,e[103]=r,e[104]=et):et=e[104];let Ke;e[105]!==te||e[106]!==G||e[107]!==W||e[108]!==M||e[109]!==k||e[110]!==r?(Ke=!W&&t.jsxs(t.Fragment,{children:[t.jsx(Ce,{size:"xs",className:"h-6 !font-normal",onClick:()=>te.current?.click(),disabled:k,children:r(k?"settings.projects.page.actions.uploading":"settings.projects.page.actions.uploadIcon")}),t.jsx(Ce,{size:"xs",className:"h-6 !font-normal",variant:"outline",onClick:()=>{G()},disabled:M,children:r(M?"settings.projects.page.actions.discovering":"settings.projects.page.actions.discoverFavicon")})]}),e[105]=te,e[106]=G,e[107]=W,e[108]=M,e[109]=k,e[110]=r,e[111]=Ke):Ke=e[111];let ke;e[112]!==z||e[113]!==F||e[114]!==A||e[115]!==r?(ke=F&&t.jsx(Ce,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>{z()},disabled:A,children:r(A?"settings.projects.page.actions.removing":"settings.projects.page.actions.removeProjectIcon")}),e[112]=z,e[113]=F,e[114]=A,e[115]=r,e[116]=ke):ke=e[116];let rt;e[117]!==A||e[118]!==j||e[119]!==N||e[120]!==r?(rt=j&&t.jsx(Ce,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>N(!1),disabled:A,children:r("settings.projects.page.actions.undoRemove")}),e[117]=A,e[118]=j,e[119]=N,e[120]=r,e[121]=rt):rt=e[121];let x;e[122]!==Ke||e[123]!==ke||e[124]!==rt?(x=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Ke,ke,rt]}),e[122]=Ke,e[123]=ke,e[124]=rt,e[125]=x):x=e[125];let R;e[126]!==Ye||e[127]!==ze||e[128]!==De||e[129]!==Je||e[130]!==et||e[131]!==x?(R=t.jsxs(Wt,{title:Ye,settingsItem:"projects.icon",contentClassName:"space-y-3",children:[ze,De,Je,et,x]}),e[126]=Ye,e[127]=ze,e[128]=De,e[129]=Je,e[130]=et,e[131]=x,e[132]=R):R=e[132];let be;return e[133]!==ae||e[134]!==Le||e[135]!==R||e[136]!==oe?(be=t.jsxs(t.Fragment,{children:[oe,ae,Le,R]}),e[133]=ae,e[134]=Le,e[135]=R,e[136]=oe,e[137]=be):be=e[137],be};function fc(s){return s.providers}function mc(s){return t.jsx(Os,{value:s,children:ao(s)},s)}const hc=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,pc=s=>{if(!s)return null;const e=s.trim();return e&&hc.test(e)?e.toLowerCase():null},gc=s=>{const{t:e}=nt(),n=It(Q=>Q.uploadProjectIcon),r=It(Q=>Q.removeProjectIcon),o=It(Q=>Q.discoverProjectIcon),a=It(Q=>s?Q.projects.find(ae=>ae.id===s.id)?.iconImage??null:null),[i,d]=h.useState(""),[l,c]=h.useState(null),[u,m]=h.useState(null),[g,p]=h.useState(null),[f,b]=h.useState(void 0),[w,C]=h.useState(void 0),[k,A]=h.useState(!1),[M,j]=h.useState(!1),[N,y]=h.useState(!1),[S,O]=h.useState(!1),[W,B]=h.useState(null),[F,_]=h.useState(null),[te,H]=h.useState(!1),z=h.useRef(null),G=h.useCallback(()=>{B(null),_(Q=>(Q&&URL.revokeObjectURL(Q),null))},[]),U=s?.id??null;h.useEffect(()=>{if(!s){d(""),c(null),m(null),p(null),b(void 0),C(void 0);return}d(s.label??""),c(s.icon??null),m(s.color??null),p(s.iconBackground??null),b(s.defaultModel),C(s.defaultVariant),O(!1),G(),H(!1)},[s,G]),h.useEffect(()=>()=>{G()},[G]);const q=h.useMemo(()=>Er(f)??{providerId:"",modelId:""},[f]),T=!!s?.iconImage,V=!!(W&&F),L=s?.iconImage?.source==="custom",D=T&&!S||V,K=D,re=!!(s&&T&&!S),X=!te&&(V||re),Y=!!s&&(i.trim()!==(s?.label??"").trim()||l!==(s?.icon??null)||u!==(s?.color??null)||g!==(s?.iconBackground??null)||(f??void 0)!==(s?.defaultModel??void 0)||(w??void 0)!==(s?.defaultVariant??void 0)||S||!!W),oe=h.useCallback((Q,ae)=>{b(Q&&ae?`${Q}/${ae}`:void 0),C(void 0)},[]),Z=h.useCallback(Q=>{C(Q)},[]),ee=h.useCallback(Q=>{!s||!Q||k||(O(!1),H(!1),B(Q),_(ae=>(ae&&URL.revokeObjectURL(ae),URL.createObjectURL(Q))))},[k,s]),pe=h.useCallback(()=>{!s||!K||M||(V&&G(),O(!!T),H(!1))},[G,V,K,T,M,s]),se=h.useCallback(async()=>{if(!(!s||N)){G(),O(!1),H(!1),y(!0);try{const Q=await o(s.id);if(!Q.ok){je.error(Q.error||e("settings.projects.page.toast.discoverIconFailed"));return}if(Q.skipped){je.success(e("settings.projects.page.toast.customIconAlreadySet"));return}je.success(e("settings.projects.page.toast.iconDiscovered"))}finally{y(!1)}}},[G,o,N,s,e]),de=h.useCallback(async Q=>{const ae=Q?.silent===!0;if(!s)return null;const ue=i.trim();if(!ue)return null;if(W){A(!0);const $=await n(s.id,W);if(A(!1),!$.ok)return je.error($.error||e("settings.projects.page.toast.uploadIconFailed")),null;ae||je.success(e("settings.projects.page.toast.iconUpdated")),G(),O(!1)}const v=S&&!!s.iconImage;if(v){j(!0);const $=await r(s.id);if(j(!1),!$.ok)return je.error($.error||e("settings.projects.page.toast.removeIconFailed")),null;ae||je.success(e("settings.projects.page.toast.iconRemoved")),O(!1),p(null)}return{label:ue,icon:l,color:u,iconBackground:pc(v?null:g),defaultModel:f??null,defaultVariant:f?w??null:null}},[G,u,f,w,l,g,i,S,W,s,r,e,n]);return h.useEffect(()=>{H(!1)},[U,a?.updatedAt]),{name:i,setName:d,icon:l,setIcon:c,color:u,setColor:m,iconBackground:g,setIconBackground:p,defaultModel:f,defaultVariant:w,parsedDefaultModel:q,handleDefaultModelChange:oe,handleDefaultVariantChange:Z,isUploadingIcon:k,isRemovingCustomIcon:M,isDiscoveringIcon:N,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:O,pendingUploadIconFile:W,pendingUploadIconPreviewUrl:F,previewImageFailed:te,setPreviewImageFailed:H,hasStoredImageIcon:T,hasPendingUploadImageIcon:V,hasCustomIcon:L,effectiveHasImageIcon:D,hasRemovableImageIcon:K,showStoredImagePreview:re,showImagePreview:X,fileInputRef:z,clearPendingUploadIcon:G,handleUploadIcon:ee,handleRemoveImageIcon:pe,handleDiscoverIcon:se,hasChanges:Y,prepareSaveData:de,currentIconImage:a,project:s}},xc=450,bc=(s,e)=>{const{t:n}=nt(),{hasChanges:r,name:o,icon:a,color:i,iconBackground:d,defaultModel:l,pendingRemoveImageIcon:c,pendingUploadIconFile:u,isUploadingIcon:m,isRemovingCustomIcon:g,prepareSaveData:p}=s,f=h.useRef(!1);h.useEffect(()=>{if(!r||!o.trim()||m||g||f.current)return;const b=window.setTimeout(()=>{f.current||(f.current=!0,(async()=>{try{const w=await p({silent:!0});if(w)try{await e(w)}catch{je.error(n("settings.projects.page.toast.saveFailed"))}}finally{f.current=!1}})())},xc);return()=>{window.clearTimeout(b)}},[i,l,r,a,d,g,m,o,e,c,u,p,n])},Ef=s=>{const e=We.c(16),{project:n,onIdentitySave:r,showWorktrees:o}=s,a=o===void 0?!0:o,i=gc(n);let d;e:{if(!n){d=null;break e}let b;e[0]!==n.id||e[1]!==n.path?(b={id:n.id,path:n.path},e[0]=n.id,e[1]=n.path,e[2]=b):b=e[2],d=b}const l=d;let c;if(e[3]!==r?(c=async b=>{await r(b)},e[3]=r,e[4]=c):c=e[4],bc(i,c),!n||!l)return null;let m;e[5]!==i?(m=t.jsx(uc,{form:i}),e[5]=i,e[6]=m):m=e[6];let g;e[7]!==l?(g=t.jsx(cc,{projectRef:l}),e[7]=l,e[8]=g):g=e[8];let p;e[9]!==l||e[10]!==a?(p=a?t.jsx(tc,{projectRef:l}):null,e[9]=l,e[10]=a,e[11]=p):p=e[11];let f;return e[12]!==m||e[13]!==g||e[14]!==p?(f=t.jsxs("div",{className:"space-y-0",children:[m,g,p]}),e[12]=m,e[13]=g,e[14]=p,e[15]=f):f=e[15],f},io=()=>{const s=ba();return{displayMode:s,installed:s!=="browser",browserTab:s==="browser"}},Rf=()=>{const s=We.c(2),[e,n]=h.useState(yc);let r,o;return s[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=[window.matchMedia("(display-mode: standalone)"),window.matchMedia("(display-mode: minimal-ui)"),window.matchMedia("(display-mode: fullscreen)"),window.matchMedia("(display-mode: window-controls-overlay)")],i=()=>{n(io())};i();for(const d of a)typeof d.addEventListener=="function"?d.addEventListener("change",i):typeof d.addListener=="function"&&d.addListener(i);return window.addEventListener("appinstalled",i),window.addEventListener("focus",i),()=>{for(const d of a)typeof d.removeEventListener=="function"?d.removeEventListener("change",i):typeof d.removeListener=="function"&&d.removeListener(i);window.removeEventListener("appinstalled",i),window.removeEventListener("focus",i)}},o=[],s[0]=r,s[1]=o):(r=s[0],o=s[1]),h.useEffect(r,o),e};function yc(){return io()}const wc=[{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},{slug:"integrations",title:"Integrations",group:"general",kind:"single",keywords:["integration","plugin","provider","oauth","claude","cursor","command code","connect","discord","telegram","messenger"]}],vc={sessions:"sessions",agents:"agents",commands:"commands",mcp:"mcp",skills:"skills.installed",providers:"providers",usage:"usage","git-identities":"git",settings:"home"};function Sc(s){const e=s.trim().toLowerCase();return wc.find(n=>n.slug===e)??null}function jc(s){const e=(s??"").trim().toLowerCase();if(!e)return"home";const n=vc[e];if(n)return n;const r=Sc(e);return r?r.slug:"home"}function Af(s){switch(s){case"general":return"settings-3";case"projects":return"folders";case"remote-instances":return"computer";case"appearance":return"palette";case"chat":return"chat-ai-3";case"magic-prompts":return"ai-generate-2";case"snippets":return"chat-thread";case"notifications":return"notification-3";case"shortcuts":return"command";case"sessions":return"chat-history";case"providers":return"cloud";case"agents":return"ai-agent";case"behavior":return"brain";case"commands":return"slash-commands-2";case"mcp":return null;case"plugins":return"plug-2";case"skills.installed":return"book-open";case"skills.catalog":return"book";case"git":return"git-branch";case"integrations":return"plug";case"usage":return"bar-chart-2";case"voice":return"mic";case"tunnel":return"home-office";case"about":return"information";case"home":return null;default:return"robot-2"}}const Nc=["chat","git","diff","terminal","files"],kc=["settings","agents","commands","skills","providers","usage","git-identities"],Bt={SESSION:"session",TAB:"tab",SETTINGS:"settings",FILE:"file"};function rr(s){const e=Ic();return{sessionId:Cc(e),tab:Tc(e),settingsPath:Dc(e),diffFile:Pc(e)}}function Ic(){if(typeof window>"u")return new URLSearchParams;try{return new URLSearchParams(window.location.search)}catch{return new URLSearchParams}}function Cc(s){const e=s.get(Bt.SESSION);return!e||e.trim().length===0?null:e.trim()}function Tc(s){const e=s.get(Bt.TAB);if(!e)return null;const n=e.toLowerCase().trim();return Nc.includes(n)?n:null}function Dc(s){const e=s.get(Bt.SETTINGS);if(!e)return null;const n=e.toLowerCase().trim();return n.length===0?null:n==="openchamber"||n==="general"||n==="preferences"?"home":(kc.includes(n),n)}function Pc(s){const e=s.get(Bt.FILE);if(!e||e.trim().length===0)return null;try{return decodeURIComponent(e.trim())}catch{return e.trim()}}function or(){if(typeof window>"u")return!1;try{const s=new URLSearchParams(window.location.search);return s.has(Bt.SESSION)||s.has(Bt.TAB)||s.has(Bt.SETTINGS)||s.has(Bt.FILE)}catch{return!1}}function lo(s){const e=new URLSearchParams;if(s.sessionId&&s.sessionId.trim().length>0&&e.set(Bt.SESSION,s.sessionId),s.isSettingsOpen){const n=s.settingsPath.trim().length>0?s.settingsPath:"home";return e.set(Bt.SETTINGS,n),e}return e}function Ec(s,e){const n=typeof window<"u"?window.location.pathname:"/",r=s.toString();return r?`${n}?${r}`:n}function Rc(s){if(typeof window>"u")return!0;try{const e=new URLSearchParams(window.location.search),n=lo(s),r=[...e.entries()].sort((a,i)=>a[0].localeCompare(i[0])),o=[...n.entries()].sort((a,i)=>a[0].localeCompare(i[0]));if(r.length!==o.length)return!1;for(let a=0;a<r.length;a++)if(r[a][0]!==o[a][0]||r[a][1]!==o[a][1])return!1;return!0}catch{return!0}}function ar(s,e={}){if(!(typeof window>"u")&&!(Ac()||Gr())&&!(!e.force&&Rc(s)))try{const n=lo(s),r=Ec(n);e.replace?window.history.replaceState({...window.history.state,route:s},"",r):window.history.pushState({route:s},"",r)}catch{}}function Ac(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function Bc(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function Bf(){const s=h.useMemo(()=>Bc(),[]),e=h.useMemo(()=>Gr(),[]),n=h.useRef(!1),r=h.useRef(!1),o=st(m=>m.setCurrentSession),a=Ue(m=>m.setSettingsDialogOpen),i=Ue(m=>m.setSettingsPage),d=Ue(m=>m.navigateToDiff),l=h.useCallback(async m=>{if(!r.current){r.current=!0;try{if(m.sessionId){const g=st.getState().currentSessionId;if(m.sessionId!==g){const p=st.getState().getDirectoryForSession(m.sessionId);o(m.sessionId,p)}}if(m.settingsPath){i(jc(m.settingsPath)),a(!0);return}if(Ue.getState().isSettingsDialogOpen&&a(!1),m.tab&&m.tab!=="chat"){const g=gs.getState().currentDirectory;if(g){const p=m.tab==="files"?"file":m.tab;Ue.getState().openContextSurface(g,p)}}m.diffFile&&(m.tab==="diff"||!m.tab)&&d(m.diffFile)}finally{r.current=!1}}},[o,a,i,d]),c=h.useCallback(()=>{const m=st.getState(),g=Ue.getState();return{sessionId:m.currentSessionId,isSettingsOpen:g.isSettingsDialogOpen,settingsPath:g.settingsPage}},[]),u=h.useCallback((m={})=>{if(s||e||r.current)return;const g=c();ar(g,m)},[s,e,c]);h.useEffect(()=>{if(n.current||(n.current=!0,!or()))return;const m=rr();(async()=>(await l(m),!s&&!e&&ar({...c(),sessionId:m.sessionId??st.getState().currentSessionId,settingsPath:m.settingsPath??Ue.getState().settingsPage},{replace:!0,force:!0})))()},[l,c,s,e]),h.useEffect(()=>{if(s||e)return;let m=st.getState().currentSessionId;return st.subscribe(p=>{const f=p.currentSessionId;f===m||r.current||(m=f,u())})},[s,e,u]),h.useEffect(()=>{if(s||e)return;let m=Ue.getState().isSettingsDialogOpen,g=Ue.getState().settingsPage;return Ue.subscribe(f=>{if(r.current)return;const b=f.isSettingsDialogOpen!==m,w=f.settingsPage!==g;m=f.isSettingsDialogOpen,g=f.settingsPage,(b||w)&&u()})},[s,e,u]),h.useEffect(()=>{if(typeof window>"u"||s||e)return;const m=()=>{const g=rr();or()?l(g):Ue.getState().isSettingsDialogOpen&&a(!1)};return window.addEventListener("popstate",m),()=>{window.removeEventListener("popstate",m)}},[l,s,e,a])}function Mf(){const s=We.c(5),e=ol(Lc),n=h.useRef(e);let r,o;s[0]!==e?(r=()=>{n.current=e},o=[e],s[0]=e,s[1]=r,s[2]=o):(r=s[1],o=s[2]),h.useEffect(r,o);let a,i;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{let d=!1,l=null;const c=Mc,u=m=>{d||(l=window.setTimeout(async()=>{const g=await n.current(),p=typeof g=="number"&&Number.isFinite(g)?c(g):36e5;u(p)},m))};return u(3e3),()=>{d=!0,l!==null&&window.clearTimeout(l)}},i=[],s[3]=a,s[4]=i):(a=s[3],i=s[4]),h.useEffect(a,i)}function Mc(s){const e=Math.round(s*1e3);return Math.max(3e5,Math.min(864e5,e))}function Lc(s){return s.checkForUpdates}const kn=1e3,ws=60*kn,tn=60*ws,Fc=(s,e)=>{const n=Math.max(0,s);return n<ws?e("common.duration.secondsCompact",{seconds:Math.floor(n/kn)}):n<tn?e("common.duration.minutesSecondsCompact",{minutes:Math.floor(n/ws),seconds:Math.floor(n%ws/kn)}):e("common.duration.hoursMinutesCompact",{hours:Math.floor(n/tn),minutes:Math.floor(n%tn/ws)})},Oc=1e3,Lf=s=>{const e=We.c(12),{sessionId:n,running:r,className:o}=s,{t:a}=nt(),i=ya(n),d=wa(n),l=va(r,Oc),c=r?Math.max(0,l-(i??l)):d;if(c===void 0)return null;let u,m;e[0]!==c||e[1]!==r||e[2]!==a?(u=Fc(c,a),m=r?a("sessions.sidebar.session.status.activeFor",{duration:u}):a("sessions.sidebar.session.status.lastTurnDuration",{duration:u}),e[0]=c,e[1]=r,e[2]=a,e[3]=u,e[4]=m):(u=e[3],m=e[4]);const g=m,p=r?"text-primary":"text-[var(--status-info)]";let f;e[5]!==o||e[6]!==p?(f=le("shrink-0 tabular-nums",p,o),e[5]=o,e[6]=p,e[7]=f):f=e[7];let b;return e[8]!==g||e[9]!==u||e[10]!==f?(b=t.jsx("span",{className:f,"aria-label":g,title:g,children:u}),e[8]=g,e[9]=u,e[10]=f,e[11]=b):b=e[11],b},$c=()=>{const s=We.c(14),[e,n]=ce.useState(!1),[r,o]=ce.useState(!1);let a,i;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{n(Wr()),o(yi())},i=[],s[0]=a,s[1]=i):(a=s[0],i=s[1]),ce.useEffect(a,i);let d;s[2]!==e?(d=async f=>e?await wi(f):{success:!0,path:f},s[2]=e,s[3]=d):d=s[3];const l=d;let c;s[4]!==e?(c=async f=>e?await vi():{success:!0},s[4]=e,s[5]=c):c=s[5];const u=c;let m;s[6]!==e?(m=async f=>e?await Si():{success:!0},s[6]=e,s[7]=m):m=s[7];const g=m;let p;return s[8]!==r||s[9]!==e||s[10]!==l||s[11]!==u||s[12]!==g?(p={isDesktop:e,canRequestAccess:r,requestAccess:l,startAccessing:u,stopAccessing:g},s[8]=r,s[9]=e,s[10]=l,s[11]=u,s[12]=g,s[13]=p):p=s[13],p},Uc=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),Wc=({currentBranch:s,localBranches:e,remoteBranches:n,branchInfo:r,onCheckout:o,onCreate:a,remotes:i=[],disabled:d=!1})=>{const{t:l}=nt(),[c,u]=h.useState(!1),[m,g]=h.useState(""),[p,f]=h.useState(!1),[b,w]=h.useState(!1),[C,k]=h.useState(""),[A,M]=h.useState(!1),j=h.useRef(null),N=h.useCallback(G=>{G.stopPropagation()},[]),y=i.length>1,S=h.useMemo(()=>Uc(C),[C]),O=h.useMemo(()=>hn(e,m,G=>[G]),[m,e]),W=h.useMemo(()=>hn(n,m,G=>[G]),[m,n]),B=G=>{if(G===s){u(!1);return}o(G),u(!1),g("")},F=()=>{f(!0),setTimeout(()=>j.current?.focus(),50)},_=async()=>{if(!(!S||A)){if(y){w(!0);return}M(!0);try{await a(S,i[0]),k(""),f(!1),u(!1)}finally{M(!1)}}},te=async G=>{if(!(!S||A)){M(!0);try{await a(S,G),k(""),f(!1),w(!1),u(!1)}finally{M(!1)}}},H=()=>{w(!1)},z=()=>{k(""),f(!1),w(!1)};return h.useEffect(()=>{c||(g(""),f(!1),w(!1),k(""))},[c]),t.jsxs(zt,{open:c,onOpenChange:u,children:[t.jsxs(ms,{children:[t.jsx(hs,{asChild:!0,children:t.jsx(Vt,{asChild:!0,children:t.jsxs(Ce,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:d,children:[t.jsx(E,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:s||l("gitView.branch.detachedHead")}),t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),t.jsx(ps,{sideOffset:8,children:l("gitView.branch.currentBranchTooltip")})]}),t.jsx(Gt,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:t.jsxs(pn,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(gn,{placeholder:l("gitView.branch.searchPlaceholder"),value:m,onValueChange:g,onKeyDown:N}),t.jsxs(xn,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(bn,{children:l("gitView.branch.empty")}),t.jsx(Ut,{children:b?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:H,disabled:A,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(E,{name:"arrow-left",className:"size-4"})}),t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[l("gitView.branch.pushToPrefix")," ",t.jsx("span",{className:"text-foreground font-medium",children:S})," ",l("gitView.branch.pushToSuffix")]})]}),t.jsx("div",{className:"flex flex-col gap-1",children:i.map(G=>t.jsxs("button",{type:"button",onClick:()=>te(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(E,{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))})]}):p?t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[t.jsx("input",{ref:j,placeholder:l("gitView.branch.newBranchPlaceholder"),value:C,onChange:G=>k(G.target.value),onClick:G=>G.stopPropagation(),onKeyDown:G=>{N(G),G.key==="Enter"?(G.preventDefault(),_()):G.key==="Escape"&&(G.preventDefault(),z())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:_,disabled:!S||A,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:A?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"add",className:"size-4"})}),t.jsx("button",{type:"button",onClick:z,disabled:A,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(E,{name:"close",className:"size-4"})})]}):t.jsxs(Pt,{onSelect:F,children:[t.jsx(E,{name:"add",className:"size-4"}),t.jsx("span",{children:l("gitView.branch.create")})]})}),t.jsx($s,{}),t.jsxs(Ut,{heading:l("gitView.branch.localBranches"),children:[O.map(G=>t.jsxs(Pt,{onSelect:()=>B(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:l("gitView.branch.currentBadge")})]},`local-${G}`)),O.length===0&&t.jsx(Pt,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:l("gitView.branch.noLocalBranches")})})]}),t.jsx($s,{}),t.jsxs(Ut,{heading:l("gitView.branch.remoteBranches"),children:[W.map(G=>t.jsx(Pt,{onSelect:()=>B(G),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:G})},`remote-${G}`)),W.length===0&&t.jsx(Pt,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:l("gitView.branch.noRemoteBranches")})})]})]})]})})]})},_c=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),zc=({currentBranch:s,onRename:e,showEditButton:n=!0})=>{const{t:r}=nt(),[o,a]=h.useState(!1),[i,d]=h.useState(s||""),[l,c]=h.useState(!1),u=h.useRef(null),m=()=>{!s||!e||(d(s),a(!0),setTimeout(()=>u.current?.focus(),0))},g=async()=>{if(!s||!e||!i.trim())return;const b=_c(i);if(b===s){a(!1);return}c(!0);try{await e(s,b),a(!1),d("")}finally{c(!1)}},p=()=>{a(!1),d("")},f=b=>{b.key==="Enter"?(b.preventDefault(),g()):b.key==="Escape"&&(b.preventDefault(),p())};return o?t.jsx("div",{className:"flex items-center gap-2 rounded-md bg-primary/12 px-2 py-1 h-8",children:t.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:b=>{b.preventDefault(),g()},children:[t.jsx(E,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("input",{ref:u,value:i,onChange:b=>d(b.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:f,autoFocus:!0}),t.jsx("button",{type:"submit",disabled:l,"aria-label":r(l?"gitView.branch.renameSaving":"gitView.branch.renameSave"),title:r(l?"gitView.branch.renameSaving":"gitView.branch.renameSave"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:l?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"check",className:"size-4"})}),t.jsx("button",{type:"button",onClick:p,disabled:l,"aria-label":r("gitView.branch.renameCancel"),title:r("gitView.branch.renameCancel"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(E,{name:"close",className:"size-4"})})]})}):t.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5 px-2 py-1 h-8",children:[t.jsx(E,{name:"git-branch",className:"size-4 text-primary shrink-0"}),t.jsxs("div",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[t.jsx("span",{className:"truncate typography-ui-label font-normal text-foreground",children:s||r("gitView.branch.detachedHead")}),n&&e&&s&&t.jsx(Ce,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:m,title:r("gitView.branch.renameTitle"),children:t.jsx(E,{name:"edit",className:"size-4"})})]})]})},Vc=s=>{const e=We.c(44),{syncAction:n,remotes:r,onFetch:o,onSync:a,onRemoveRemote:i,disabled:d,removingRemoteName:l,aheadCount:c,behindCount:u,trackingRemoteName:m,hasUncommittedChanges:g}=s,p=r===void 0?[]:r,f=l===void 0?null:l,b=c===void 0?0:c,w=u===void 0?0:u,C=g===void 0?!1:g,{t:k}=nt(),A=h.useRef(!1),M=!!f,j=p.find(he=>he.name===m)??p[0],N=w>0&&C,y=d||n!==null||M||!j||N,S=d||n!==null||M||p.length===0,O=b>0||w>0;let W;e[0]!==k?(W=k("gitView.sync.sync"),e[0]=k,e[1]=W):W=e[1];const B=w>0?`↓${w}`:null,F=b>0?`↑${b}`:null;let _;e[2]!==W||e[3]!==B||e[4]!==F?(_=[W,B,F].filter(Boolean),e[2]=W,e[3]=B,e[4]=F,e[5]=_):_=e[5];const te=_.join(" "),H=N?k("gitView.sync.commitOrStashTooltip"):j?O?k("gitView.sync.syncChangesTooltip",{ahead:b,behind:w}):k("gitView.sync.syncChanges"):k("gitView.sync.noRemoteTooltip"),z=()=>{j&&a(j)},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 q;e[6]===Symbol.for("react.memo_cache_sentinel")?(q=le("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]=q):q=e[6];let T;e[7]!==k?(T=k("gitView.sync.syncChanges"),e[7]=k,e[8]=T):T=e[8];let V;e[9]!==n?(V=n==="sync"?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"refresh",className:"size-4"}),e[9]=n,e[10]=V):V=e[10];let L;e[11]!==te?(L=t.jsx("span",{className:"whitespace-nowrap tabular-nums",children:te}),e[11]=te,e[12]=L):L=e[12];let D;e[13]!==z||e[14]!==y||e[15]!==T||e[16]!==V||e[17]!==L?(D=t.jsxs("button",{type:"button",onClick:z,disabled:y,className:q,"aria-label":T,children:[V,L]}),e[13]=z,e[14]=y,e[15]=T,e[16]=V,e[17]=L,e[18]=D):D=e[18];let K;e[19]!==U||e[20]!==D?(K=t.jsx(hs,{asChild:!0,children:t.jsx("span",{className:"inline-flex",tabIndex:U,children:D})}),e[19]=U,e[20]=D,e[21]=K):K=e[21];let re;e[22]!==H?(re=t.jsx(ps,{sideOffset:8,children:H}),e[22]=H,e[23]=re):re=e[23];let X;e[24]!==K||e[25]!==re?(X=t.jsxs(ms,{children:[K,re]}),e[24]=K,e[25]=re,e[26]=X):X=e[26];const Y=zt;let oe;e[27]===Symbol.for("react.memo_cache_sentinel")?(oe=le("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]=oe):oe=e[27];let Z;e[28]!==k?(Z=k("gitView.sync.moreActionsAria"),e[28]=k,e[29]=Z):Z=e[29];let ee;e[30]===Symbol.for("react.memo_cache_sentinel")?(ee=t.jsx(E,{name:"arrow-down-s",className:"size-4"}),e[30]=ee):ee=e[30];let pe;e[31]!==S||e[32]!==Z?(pe=t.jsx(Vt,{asChild:!0,children:t.jsx("button",{type:"button",className:oe,disabled:S,"aria-label":Z,children:ee})}),e[31]=S,e[32]=Z,e[33]=pe):pe=e[33];const se=Gt,de="start",Q=-40,ae="w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",ue=p.map(he=>t.jsx(At,{onSelect:ie=>{if(A.current){ie.preventDefault(),A.current=!1;return}o(he)},children:t.jsxs("div",{className:"flex w-full items-center gap-2",children:[t.jsx(E,{name:"refresh",className:"size-4 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:k("gitView.sync.fetchFromRemote",{name:he.name})}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:he.fetchUrl})]})}),i&&he.name!==m?t.jsx(Ce,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:n!==null||M,onPointerDown:ie=>{A.current=!0,ie.preventDefault(),ie.stopPropagation()},onClick:ie=>{A.current=!0,ie.preventDefault(),ie.stopPropagation(),i(he)},"aria-label":k("gitView.header.removeRemoteAria",{name:he.name}),title:k("gitView.header.removeRemoteTitle",{name:he.name}),children:f===he.name?t.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(E,{name:"close",className:"size-3.5"})}):null]})},he.name));let v;e[34]!==se||e[35]!==ue?(v=t.jsx(se,{align:de,alignOffset:Q,className:ae,children:ue}),e[34]=se,e[35]=ue,e[36]=v):v=e[36];let $;e[37]!==Y||e[38]!==pe||e[39]!==v?($=t.jsxs(Y,{children:[pe,v]}),e[37]=Y,e[38]=pe,e[39]=v,e[40]=$):$=e[40];let J;return e[41]!==X||e[42]!==$?(J=t.jsxs("div",{className:G,children:[X,$]}),e[41]=X,e[42]=$,e[43]=J):J=e[43],J},Gc={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",user:"user-3",fingerprint:"fingerprint"},Hc={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 co(s){return s&&Hc[s]||"var(--primary)"}const ir=s=>{const e=We.c(8),{icon:n,className:r,colorToken:o}=s,a=Gc[n??"branch"]??"user-3";let i;e[0]!==o?(i=co(o),e[0]=o,e[1]=i):i=e[1];let d;e[2]!==i?(d={color:i},e[2]=i,e[3]=d):d=e[3];let l;return e[4]!==r||e[5]!==a||e[6]!==d?(l=t.jsx(E,{name:a,className:r,style:d}),e[4]=r,e[5]=a,e[6]=d,e[7]=l):l=e[7],l},uo=s=>{const e=We.c(35),{activeProfile:n,identities:r,onSelect:o,isApplying:a,iconOnly:i}=s,d=i===void 0?!1:i,{t:l}=nt(),c=a||r.length===0,u=n?.color;let m;e[0]!==u?(m=co(u),e[0]=u,e[1]=m):m=e[1];let g;e[2]!==m?(g={color:m},e[2]=m,e[3]=g):g=e[3];let p;e[4]!==n?.color||e[5]!==n?.icon||e[6]!==a?(p=a?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(ir,{icon:n?.icon,colorToken:n?.color,className:"size-4"}),e[4]=n?.color,e[5]=n?.icon,e[6]=a,e[7]=p):p=e[7];let f;e[8]!==n?.name||e[9]!==d||e[10]!==l?(f=!d&&t.jsx("span",{className:"git-identity-label min-w-0 flex-1 truncate text-left",children:n?.name||l("gitView.header.noIdentity")}),e[8]=n?.name,e[9]=d,e[10]=l,e[11]=f):f=e[11];let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60"}),e[12]=b):b=e[12];let w;e[13]!==c||e[14]!==g||e[15]!==p||e[16]!==f?(w=t.jsx(hs,{asChild:!0,children:t.jsx(Vt,{asChild:!0,children:t.jsxs(Ce,{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:g,disabled:c,children:[p,f,b]})})}),e[13]=c,e[14]=g,e[15]=p,e[16]=f,e[17]=w):w=e[17];let C;e[18]!==l?(C=l("gitView.header.identityTooltip"),e[18]=l,e[19]=C):C=e[19];let k;e[20]!==C?(k=t.jsx(ps,{sideOffset:8,children:C}),e[20]=C,e[21]=k):k=e[21];let A;e[22]!==k||e[23]!==w?(A=t.jsxs(ms,{children:[w,k]}),e[22]=k,e[23]=w,e[24]=A):A=e[24];let M;e[25]!==n?.id||e[26]!==r||e[27]!==o||e[28]!==l?(M=r.length===0?t.jsx("div",{className:"px-2 py-1.5",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:l("gitView.header.noProfiles")})}):r.map(y=>{const S=n?.id===y.id;return t.jsx(At,{onSelect:()=>o(y),children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(ir,{icon:y.icon,colorToken:y.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:y.name}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:y.userEmail})]}),S?t.jsx(E,{name:"check",className:"ml-auto size-4 text-foreground"}):null]})},y.id)}),e[25]=n?.id,e[26]=r,e[27]=o,e[28]=l,e[29]=M):M=e[29];let j;e[30]!==M?(j=t.jsx(Gt,{align:"end",className:"w-64",children:M}),e[30]=M,e[31]=j):j=e[31];let N;return e[32]!==A||e[33]!==j?(N=t.jsxs(zt,{children:[A,j]}),e[32]=A,e[33]=j,e[34]=N):N=e[34],N},Kc=s=>{const e=We.c(21),{comparison:n,trackingBranch:r,tooltipDelayMs:o}=s,a=o===void 0?1e3:o,{t:i}=nt(),d=`${n.remote}/${n.branch}`,l=n.ahead===0&&n.behind===0;let c;e[0]!==i||e[1]!==d||e[2]!==r?(c=r?i("gitView.header.upstreamTooltipTracking",{target:d,tracking:r}):i("gitView.header.upstreamTooltip",{target:d}),e[0]=i,e[1]=d,e[2]=r,e[3]=c):c=e[3];const u=c;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(E,{name:"git-branch",className:"size-3.5 shrink-0"}),e[4]=m):m=e[4];let g;e[5]!==d?(g=t.jsx("span",{className:"min-w-0 truncate text-foreground/80",children:d}),e[5]=d,e[6]=g):g=e[6];let p;e[7]!==n.ahead||e[8]!==n.behind||e[9]!==l||e[10]!==i?(p=l?t.jsx("span",{className:"tabular-nums text-muted-foreground",children:i("gitView.header.upstreamSynced")}):t.jsxs("span",{className:"inline-flex items-center gap-1 tabular-nums",children:[n.ahead>0?t.jsxs("span",{className:"text-[var(--status-info)]",children:["↑",n.ahead]}):null,n.behind>0?t.jsxs("span",{className:"text-[var(--status-warning)]",children:["↓",n.behind]}):null]}),e[7]=n.ahead,e[8]=n.behind,e[9]=l,e[10]=i,e[11]=p):p=e[11];let f;e[12]!==g||e[13]!==p?(f=t.jsx(hs,{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:[m,g,p]})}),e[12]=g,e[13]=p,e[14]=f):f=e[14];let b;e[15]!==u?(b=t.jsx(ps,{sideOffset:8,children:u}),e[15]=u,e[16]=b):b=e[16];let w;return e[17]!==f||e[18]!==b||e[19]!==a?(w=t.jsxs(ms,{delayDuration:a,children:[f,b]}),e[17]=f,e[18]=b,e[19]=a,e[20]=w):w=e[20],w},Ff=s=>{const e=We.c(67),{status:n,localBranches:r,remoteBranches:o,branchInfo:a,syncAction:i,remotes:d,onFetch:l,onSync:c,onRemoveRemote:u,removingRemoteName:m,onCheckoutBranch:g,onCreateBranch:p,onRenameBranch:f,activeIdentityProfile:b,availableIdentities:w,onSelectIdentity:C,isApplyingIdentity:k,isWorktreeMode:A,onOpenHistory:M,onOpenGraph:j,onOpenStashes:N,onOpenUpdateBranch:y,onOpenReintegrateCommits:S,pullRequest:O,prChecks:W,onOpenPullRequest:B}=s,{t:F}=nt();if(!n)return null;let _;e[0]!==j||e[1]!==M||e[2]!==S||e[3]!==N||e[4]!==y||e[5]!==F?(_=M||j||N||y?t.jsxs(zt,{children:[t.jsxs(ms,{children:[t.jsx(hs,{asChild:!0,children:t.jsx(Vt,{asChild:!0,children:t.jsx(Ce,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":F("gitView.header.repositoryViews"),children:t.jsx(E,{name:"more-fill",className:"size-4"})})})}),t.jsx(ps,{sideOffset:8,children:F("gitView.header.repositoryViews")})]}),t.jsxs(Gt,{align:"end",children:[M?t.jsxs(At,{onSelect:M,children:[t.jsx(E,{name:"history",className:"size-4"}),F("gitView.history.title")]}):null,j?t.jsxs(At,{onSelect:j,children:[t.jsx(E,{name:"git-branch",className:"size-4"}),F("gitView.graph.title")]}):null,N?t.jsxs(At,{onSelect:N,children:[t.jsx(E,{name:"archive-stack",className:"size-4"}),F("gitView.stashes.title")]}):null,y?t.jsxs(At,{onSelect:y,children:[t.jsx(E,{name:"git-merge",className:"size-4"}),F("gitView.header.updateBranch")]}):null,S?t.jsxs(At,{onSelect:S,children:[t.jsx(E,{name:"split-cells-horizontal",className:"size-4"}),F("gitView.integrate.title")]}):null]})]}):null,e[0]=j,e[1]=M,e[2]=S,e[3]=N,e[4]=y,e[5]=F,e[6]=_):_=e[6];let te;e[7]!==_?(te=t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:_}),e[7]=_,e[8]=te):te=e[8];const H=te,z=W?W.state==="success"?"var(--status-success)":W.state==="failure"?"var(--status-error)":"var(--status-warning)":null,G=O?O.state==="merged"?"merged":O.state==="closed"?"closed":O.draft?"draft":W?.state==="failure"||O.mergeable===!1||O.mergeableState==="blocked"||O.mergeableState==="dirty"?"blocked":"open":null;let U;e[9]!==B||e[10]!==z||e[11]!==G||e[12]!==O||e[13]!==F?(U=O&&B?t.jsxs(ms,{children:[t.jsx(hs,{asChild:!0,children:t.jsxs(Ce,{variant:"ghost",size:"sm",onClick:B,className:"h-8 gap-1.5 px-2 typography-micro",children:[t.jsx(E,{name:"git-pull-request",className:"size-3.5",style:{color:`var(--pr-${G})`}}),t.jsx("span",{className:"tabular-nums text-foreground/80",children:F("gitView.pr.numberLabel",{number:O.number})}),z?t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:z}}):null]})}),t.jsx(ps,{sideOffset:8,children:F("gitView.header.openPullRequest")})]}):null,e[9]=B,e[10]=z,e[11]=G,e[12]=O,e[13]=F,e[14]=U):U=e[14];const q=U,T=!n;let V;e[15]!==n.tracking?(V=n.tracking?.split("/")[0],e[15]=n.tracking,e[16]=V):V=e[16];const L=(n.files?.length??0)>0;let D;e[17]!==l||e[18]!==u||e[19]!==c||e[20]!==d||e[21]!==m||e[22]!==n.ahead||e[23]!==n.behind||e[24]!==i||e[25]!==T||e[26]!==V||e[27]!==L?(D=t.jsx(Vc,{syncAction:i,remotes:d,onFetch:l,onSync:c,onRemoveRemote:u,removingRemoteName:m,disabled:T,iconOnly:!0,aheadCount:n.ahead,behindCount:n.behind,trackingRemoteName:V,hasUncommittedChanges:L}),e[17]=l,e[18]=u,e[19]=c,e[20]=d,e[21]=m,e[22]=n.ahead,e[23]=n.behind,e[24]=i,e[25]=T,e[26]=V,e[27]=L,e[28]=D):D=e[28];const K=D;let re;e[29]!==n.tracking||e[30]!==n.upstreamComparison?(re=n.upstreamComparison?t.jsx(Kc,{comparison:n.upstreamComparison,trackingBranch:n.tracking,tooltipDelayMs:1e3}):null,e[29]=n.tracking,e[30]=n.upstreamComparison,e[31]=re):re=e[31];const X=re;let Y;e[32]!==b||e[33]!==w||e[34]!==k||e[35]!==C?(Y=t.jsx(uo,{activeProfile:b,identities:w,onSelect:C,isApplying:k,iconOnly:!0}),e[32]=b,e[33]=w,e[34]=k,e[35]=C,e[36]=Y):Y=e[36];const oe=Y;let Z;e[37]!==a||e[38]!==A||e[39]!==r||e[40]!==g||e[41]!==p||e[42]!==f||e[43]!==o||e[44]!==d||e[45]!==n.current?(Z=t.jsx("div",{className:"min-w-0 flex-1",children:A?t.jsx(zc,{currentBranch:n.current,onRename:f}):t.jsx(Wc,{currentBranch:n.current,localBranches:r,remoteBranches:o,branchInfo:a,onCheckout:g,onCreate:p,remotes:d})}),e[37]=a,e[38]=A,e[39]=r,e[40]=g,e[41]=p,e[42]=f,e[43]=o,e[44]=d,e[45]=n.current,e[46]=Z):Z=e[46];let ee;e[47]!==oe?(ee=t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:oe}),e[47]=oe,e[48]=ee):ee=e[48];let pe;e[49]!==Z||e[50]!==ee?(pe=t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[Z,ee]}),e[49]=Z,e[50]=ee,e[51]=pe):pe=e[51];let se;e[52]!==q?(se=q?t.jsx("div",{className:"shrink-0",children:q}):null,e[52]=q,e[53]=se):se=e[53];let de;e[54]===Symbol.for("react.memo_cache_sentinel")?(de=t.jsx("div",{className:"min-w-0 flex-1"}),e[54]=de):de=e[54];let Q;e[55]!==X?(Q=X?t.jsx("div",{className:"min-w-0 shrink",children:X}):null,e[55]=X,e[56]=Q):Q=e[56];let ae;e[57]!==K?(ae=t.jsx("div",{className:"shrink-0",children:K}),e[57]=K,e[58]=ae):ae=e[58];let ue;e[59]!==H||e[60]!==se||e[61]!==Q||e[62]!==ae?(ue=t.jsxs("div",{className:"mt-3 flex h-8 min-w-0 items-center gap-2",children:[se,de,Q,H,ae]}),e[59]=H,e[60]=se,e[61]=Q,e[62]=ae,e[63]=ue):ue=e[63];let v;return e[64]!==pe||e[65]!==ue?(v=t.jsxs("header",{className:"@container/git-header px-3 py-2 bg-transparent",children:[pe,ue]}),e[64]=pe,e[65]=ue,e[66]=v):v=e[66],v},qc=s=>s==="/",_s=s=>s.replace(/\\/g,"/"),En=s=>{if(!s||qc(s))return s;let e=s;for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e},Yt=s=>s.endsWith("/"),Yc=s=>{const e=s.trim();return!e||Yt(e)?e:`${e}/`},Rn=s=>s.lastIndexOf("/"),fo=s=>{if(Yt(s))return s;const e=Rn(s);return e<0?s:s.slice(0,e+1)},Jc=s=>{const e=Rn(s);return s.slice(e+1)},mo=s=>{const e=En(s.trim());if(!e||e==="~"||e==="~/"||e==="/")return null;const n=Rn(e);return n<0?null:e.startsWith("~/")&&n<=1?"~/":n===0?"/":`${e.slice(0,n)}/`},Qc=s=>Yt(s)&&mo(s)!==null,Xc=(s,e)=>`${fo(s)}${e}/`,$t=s=>{if(!s)return null;const e=En(_s(s.trim()));return e?e.toLowerCase():null},lr=(s,e)=>{const n=s.trim();return n==="~"?e:n.startsWith("~/")?`${e}${n.slice(1)}`:n},Zc=s=>typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?s.metaKey&&!s.ctrlKey:s.ctrlKey&&!s.metaKey,sn=s=>{if(!s)return;s.focus({preventScroll:!0});const e=s.value.length;s.setSelectionRange(e,e),s.scrollLeft=s.scrollWidth},ed=async()=>{try{const s=await Mt("/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 _s(e.home.trim())}}catch{}return fs.getFilesystemHome().catch(()=>null)},Of=({open:s,onOpenChange:e})=>{const{t:n}=nt(),r=gs(P=>P.homeDirectory),o=It(P=>P.projects),a=It(P=>P.addProject),i=Ue(P=>P.setSessionSwitcherOpen),d=st(P=>P.openNewSessionDraft),l=It(P=>P.addProjects),c=Kt(P=>P.profiles),u=Kt(P=>P.globalIdentity),m=Kt(P=>P.defaultGitIdentityId),g=Kt(P=>P.loadProfiles),p=Kt(P=>P.loadGlobalIdentity),f=Kt(P=>P.loadDefaultGitIdentityId),{canRequestAccess:b,requestAccess:w,startAccessing:C}=$c(),{isMobile:k}=Vs(),A=h.useRef(null),M=h.useRef(null),j=h.useRef(new Map),[N,y]=h.useState(""),[S,O]=h.useState("~/"),[W,B]=h.useState([]),[F,_]=h.useState(!1),[te,H]=h.useState(!1),[z,G]=h.useState(null),[U,q]=h.useState(0),[T,V]=h.useState(0),[L,D]=h.useState(!1),[K,re]=h.useState(!1),[X,Y]=h.useState(0),[oe,Z]=h.useState(!1),[ee,pe]=h.useState(""),[se,de]=h.useState(null),[Q,ae]=h.useState(!1),[ue,v]=h.useState([]),$=N||r,J=h.useMemo(()=>new Set(o.map(P=>$t(P.path)).filter(P=>!!P)),[o]);h.useEffect(()=>{if(!s)return;O("~/"),B([]),V(0),D(!1),re(!1),Z(!1),pe(""),de(null),ae(!1),v([]),requestAnimationFrame(()=>sn(A.current));let P=!1;return(async()=>{const Ie=await ed();P||(y(Ie||r||""),requestAnimationFrame(()=>sn(A.current)))})(),()=>{P=!0}},[r,s]),h.useEffect(()=>{s&&(g(),p(),f())},[f,g,p,s]);const he=h.useMemo(()=>{const P=new Map;u&&P.set(u.id,u);for(const me of c)P.set(me.id,me);return Array.from(P.values())},[c,u]);h.useEffect(()=>{if(!s||!oe||se!==null)return;const P=typeof m=="string"?m.trim():"";if(P&&he.some(Ie=>Ie.id===P)){de(P);return}const me=he.find(Ie=>Ie.authType==="ssh"||Ie.sshKey);me&&de(me.id)},[he,m,oe,s,se]);const ie=h.useMemo(()=>he.find(P=>P.id===se)??null,[he,se]),ve=h.useMemo(()=>fo(S),[S]),Ne=h.useMemo(()=>Yt(S)?"":Jc(S),[S]),Ve=h.useMemo(()=>$?lr(ve,$):"",[ve,$]);h.useEffect(()=>{if(!s||!Ve){B([]),G(null);return}let P=!1;return _(!0),H(!1),G(null),fs.listLocalDirectory(Ve).then(me=>{if(P)return;H(!1),G(null);const Ie=me.filter(Te=>Te.isDirectory).map(Te=>({name:Te.name,path:_s(Te.path)})).sort((Te,Me)=>Te.name.localeCompare(Me.name));B(Ie)}).catch(me=>{if(!P){B([]);const Ie=ji(me)?me.reason:"unknown";G(Ie),H(Ie==="not-found")}}).finally(()=>{P||_(!1)}),()=>{P=!0}},[Ve,U,s]);const Le=h.useMemo(()=>{const P=Ne.toLowerCase(),me=Q||Ne.startsWith(".");return W.filter(Ie=>Ie.name.toLowerCase().startsWith(P)&&(me||!Ie.name.startsWith(".")))},[Ne,W,Q]),Ye=h.useMemo(()=>{const P=[];Qc(S)&&P.push({type:"up",value:"browse:up",name:"..",path:mo(S)});for(const me of Le){const Ie=$t(me.path);P.push({type:"directory",value:`browse:${me.path}`,name:me.name,path:me.path,disabled:!!(Ie&&J.has(Ie))})}return P},[J,Le,S]);h.useEffect(()=>{V(0)},[S,Ye.length]),h.useEffect(()=>{v([])},[Ve]);const Xe=h.useMemo(()=>ue.filter(P=>{const me=$t(P);return!!(me&&!J.has(me))}),[J,ue]),ze=h.useCallback(P=>{v(me=>me.includes(P)?me.filter(Ie=>Ie!==P):[...me,P])},[]),Fe=h.useMemo(()=>$?En(lr(S,$)):"",[$,S]),Ge=$t(Fe),Ae=!!(Ge&&J.has(Ge)),_e=h.useMemo(()=>Ne?Le.find(P=>P.name===Ne)??null:null,[Ne,Le]),Oe=!!(Fe&&!Ae&&(z===null||z==="not-found")&&(Yt(S)&&te||!Yt(S)&&Ne.trim().length>0&&_e===null)),Ze=!L&&!K&&z!=="os-permission"&&z!=="invalid-response"&&z!=="unknown"&&(!oe&&Xe.length>0||!Ae&&!!Fe),at=Ze&&ee.trim().length>0,De=Ye[T]??null,Je=!!(De&&(De.type==="up"||De.type==="directory")),et=yn("mod"),Ke=!oe&&Xe.length>0?n("directoryExplorerDialog.actions.addSelected"):n(Ae?"directoryExplorerDialog.actions.alreadyAdded":oe?L?"directoryExplorerDialog.actions.cloning":"directoryExplorerDialog.actions.cloneAndAdd":L?"directoryExplorerDialog.actions.adding":Oe?"directoryExplorerDialog.actions.createAndAdd":"directoryExplorerDialog.actions.addProject");h.useLayoutEffect(()=>{const P=M.current;if(!P)return;const me=()=>Y(Math.ceil(P.getBoundingClientRect().width));if(me(),typeof ResizeObserver>"u")return;const Ie=new ResizeObserver(me);return Ie.observe(P),()=>Ie.disconnect()},[Ke]),h.useLayoutEffect(()=>{const P=A.current;P&&(P.scrollLeft=P.scrollWidth)},[X,S]),h.useLayoutEffect(()=>{s&&sn(A.current)},[s]),h.useLayoutEffect(()=>{const P=Ye[T];P&&j.current.get(P.value)?.scrollIntoView({block:"nearest"})},[T,Ye]);const ke=h.useCallback(()=>{e(!1)},[e]),rt=h.useCallback((P,me)=>{k&&i(!1),d({selectedProjectId:P,directoryOverride:me}),ke()},[ke,k,d,i]),x=h.useCallback(async(P,me)=>{P.stopPropagation();const Ie=$t(me);if(Ie&&J.has(Ie))return;const Te=await a(me);if(!Te){je.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}rt(Te.id,Te.path)},[a,J,rt,n]),R=h.useCallback(async P=>{if(L)return;const me=$t(P),Ie=oe?[]:ue.filter(Me=>{const I=$t(Me);return!!(I&&!J.has(I))});if(Ie.length===0&&(!P||me&&J.has(me)))return;let Te=P;D(!0);try{const Me=!oe&&Oe&&$t(P)===$t(Fe);if(oe){const ne=ee.trim();if(!ne){je.error(n("directoryExplorerDialog.toast.cloneUrlRequired"));return}Te=(await fs.cloneRepository({remoteUrl:ne,destinationPath:P,gitIdentityId:ie?.id??null})).path}else if(Ie.length>0){const ne=await l(Ie);if(ne.length===0){je.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}je.success(n("directoryExplorerDialog.toast.addedProjects",{count:ne.length})),v([]),ke();return}else Me&&await fs.createDirectory(P,{asProject:!0});const I=await a(Te);if(!I){je.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}rt(I.id,I.path)}catch(Me){je.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:Me instanceof Error?Me.message:n("directoryExplorerDialog.toast.unknownError")})}finally{D(!1)}},[a,l,J,ee,ke,oe,L,rt,ie?.id,ue,Oe,Fe,n]),be=h.useCallback(P=>{O(Yc(P))},[]),fe=h.useCallback(P=>{O(Xc(S,P.name))},[S]),Se=h.useCallback(P=>{if(P){if(P.type==="up"){P.path&&be(P.path);return}fe(P)}},[be,fe]),Be=h.useCallback(async()=>{if(!(!b||K)){re(!0);try{const P=await w(Fe);if(!P.success||!P.path){P.error&&P.error!=="Directory selection cancelled"&&je.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:P.error});return}const me=await C(P.path);if(!me.success){je.error(n("directoryExplorerDialog.toast.failedToOpenDirectory"),{description:me.error||n("directoryExplorerDialog.toast.desktopCouldNotGrantAccess")});return}v([]),await R(P.path)}catch(P){je.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:P instanceof Error?P.message:n("directoryExplorerDialog.toast.unknownError")})}finally{re(!1)}}},[b,R,K,w,C,n,Fe]),Re=h.useCallback(P=>{if(P.key==="ArrowDown"){P.preventDefault(),V(me=>Math.min(Ye.length-1,me+1));return}if(P.key==="ArrowUp"){P.preventDefault(),V(me=>Math.max(0,me-1));return}if(P.key===" "){if(Yt(S)){P.preventDefault(),De&&De.type==="directory"&&!De.disabled&&ze(De.path);return}return}if(P.key==="Enter"){if(P.preventDefault(),Zc(P)){R(Fe);return}Je&&Se(De);return}P.key==="Backspace"&&S===""&&(P.preventDefault(),ke())},[Se,R,ke,Je,De,S,Ye.length,Fe,ze]),qe=t.jsxs("button",{type:"button",onClick:()=>ae(P=>!P),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:[Q?t.jsx(E,{name:"checkbox",className:"h-4 w-4 text-primary"}):t.jsx(E,{name:"checkbox-blank",className:"h-4 w-4"}),n("directoryExplorerDialog.toggle.showHidden")]}),Ee=t.jsxs("div",{className:"px-2.5 py-1.5",children:[oe?t.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[t.jsx(yt,{value:ee,onChange:P=>pe(P.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(uo,{activeProfile:ie,identities:he,onSelect:P=>de(P.id),isApplying:L,iconOnly:!0})]}):null,t.jsxs("div",{className:"relative",children:[t.jsx(E,{name:"folder-add",className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/80"}),t.jsx(yt,{ref:A,value:S,onChange:P=>O(_s(P.target.value)),onKeyDown:Re,placeholder:n("directoryExplorerDialog.pathInput.placeholder"),className:"border-transparent bg-transparent pl-9 font-mono typography-ui-label shadow-none focus-visible:ring-0",style:!k&&X>0?{paddingRight:`${X+24}px`}:void 0,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),k?null:t.jsx(Ce,{ref:M,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:oe?!at:!Ze,onMouseDown:P=>P.preventDefault(),onClick:()=>{R(Fe)},title:Ke,children:Ke})]})]}),ft=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")}),F?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.loading")}):z&&z!=="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(z==="os-permission"?"directoryExplorerDialog.browse.permissionDenied":"directoryExplorerDialog.browse.loadFailed")}),t.jsxs("div",{className:"flex items-center gap-2",children:[z==="os-permission"&&b?t.jsx(Ce,{size:"xs",onClick:()=>{Be()},disabled:K,children:n("directoryExplorerDialog.browse.grantAccess")}):null,t.jsx(Ce,{variant:"outline",size:"xs",onClick:()=>q(P=>P+1),children:n("directoryExplorerDialog.browse.retry")})]})]}):Ye.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:Ye.map((P,me)=>{const Ie=me===T;return t.jsxs("button",{ref:Te=>{Te?j.current.set(P.value,Te):j.current.delete(P.value)},type:"button",onMouseEnter:()=>V(me),onMouseDown:Te=>Te.preventDefault(),onClick:()=>Se(P),className:le("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",P.type==="directory"&&P.disabled&&"opacity-45"),children:[P.type==="up"?t.jsx(E,{name:"arrow-left-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}):t.jsx(E,{name:"folder-6",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}),t.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:t.jsx("span",{className:"truncate typography-ui-label text-foreground",children:P.name})}),P.type==="directory"&&P.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")}):P.type==="directory"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onMouseDown:Te=>Te.stopPropagation(),onClick:Te=>{Te.stopPropagation(),ze(P.path)},title:n("directoryExplorerDialog.browse.selectForAdd"),"aria-label":n("directoryExplorerDialog.browse.selectForAdd"),"aria-pressed":ue.includes(P.path),className:"flex-shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",children:t.jsx(E,{name:ue.includes(P.path)?"checkbox":"checkbox-blank",className:"h-4 w-4"})}),t.jsx("button",{type:"button",onMouseDown:Te=>Te.stopPropagation(),onClick:Te=>x(Te,P.path),className:"flex-shrink-0 rounded-full p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",title:n("directoryExplorerDialog.browse.quickAdd"),children:t.jsx(E,{name:"add",className:"h-3.5 w-3.5"})})]}):null]},P.value)})})]})}),ct=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[Ee,ft]}),ut=t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-micro text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(E,{name:"arrow-up-s",className:"h-3.5 w-3.5"}),t.jsx(E,{name:"arrow-down-s",className:"-ml-1 h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.navigate")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(E,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.select")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{children:et}),t.jsx(E,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.add")]})]}),it=()=>t.jsxs(t.Fragment,{children:[k?null:ut,t.jsxs("div",{className:le("flex w-full flex-row justify-end gap-2 sm:w-auto",k&&"justify-stretch"),children:[b?t.jsx(Ce,{variant:"ghost",size:"xs",onClick:Be,disabled:L||K||oe,children:n(K?"directoryExplorerDialog.actions.openingFinder":"directoryExplorerDialog.actions.openInFinder")}):null,t.jsx(Ce,{variant:"ghost",size:"xs",onClick:()=>{Z(P=>!P),v([])},disabled:L||K,className:le(k&&"flex-1"),children:n(oe?"directoryExplorerDialog.actions.addLocalProject":"directoryExplorerDialog.actions.cloneRepository")}),k?t.jsx(Ce,{size:"xs",onClick:()=>{R(Fe)},disabled:oe?!at:!Ze,className:"flex-1",children:Ke}):null]})]});return k?t.jsx(Ss,{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:it()}),children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[t.jsx("div",{className:"flex justify-end",children:qe}),ct]})}):t.jsx(ks,{open:s,onOpenChange:e,children:t.jsxs(Is,{className:"flex w-full max-w-xl flex-col gap-0 overflow-hidden p-0 sm:max-h-[80vh]",initialFocus:!1,children:[t.jsx(zs,{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(Cs,{children:n("directoryExplorerDialog.title")}),t.jsx(Sa,{className:"mt-2",children:n("directoryExplorerDialog.description")})]}),qe]})}),t.jsx("div",{className:"min-h-0 flex-1 px-2 pb-0",children:ct}),t.jsx(Tn,{className:"flex w-full flex-col gap-3 px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:it()})]})})};function cr(s){const{localBranches:e,remoteBranches:n,query:r}=s,o=r.trim();if(!o)return{matching:[],otherLocal:e,otherRemote:n};const a=[...e.map(l=>({label:l,value:l,source:"local"})),...n.map(l=>({label:l,value:`remotes/${l}`,source:"remote"}))],i=hn(a,o,l=>[l.label]),d=new Set(i);return{matching:i,otherLocal:a.filter(l=>l.source==="local"&&!d.has(l)).map(l=>l.label),otherRemote:a.filter(l=>l.source==="remote"&&!d.has(l)).map(l=>l.label)}}const nn="oc:lastWorktreeSourceBranch",td=({mode:s,sourceBranch:e,linkedPr:n,selectedBranch:r})=>s==="existing-branch"?r||null:n?null:e||null,sd=({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 nd({open:s,onOpenChange:e,onSelect:n}){const{t:r}=nt(),o=Ue(v=>v.isMobile),{github:a}=Dn(),i=Us(v=>v.status),d=Us(v=>v.hasChecked),l=Ue(v=>v.setSettingsDialogOpen),c=Ue(v=>v.setSettingsPage),u=It(v=>v.getActiveProject()),m=u?.path??null,g=ce.useMemo(()=>m&&u?{id:u.id,path:m}:null,[u,m]),[p,f]=ce.useState("issues"),[b,w]=ce.useState(""),[C,k]=ce.useState([]),[A,M]=ce.useState([]),[j,N]=ce.useState(!1),[y,S]=ce.useState(!1),[O,W]=ce.useState(null),[B,F]=ce.useState(null),[_,te]=ce.useState(null),[H,z]=ce.useState(!1),[G,U]=ce.useState(new Map),[q,T]=ce.useState(1),[V,L]=ce.useState(!1),D=ja(b,350),K=ce.useCallback(async v=>{if(!(!m||!a)&&!(d&&i?.connected===!1)){N(!0),W(null),T(1),L(!1);try{if(p==="issues"&&a.issuesList){const $=await a.issuesList(m,{page:1,query:v});$.connected===!1?(W(r("session.githubIntegration.error.notConnected")),k([])):(k($.issues??[]),T($.page??1),L(!!$.hasMore))}else if(p==="prs"&&a.prsList){const $=await a.prsList(m,{page:1,query:v});$.connected===!1?(W(r("session.githubIntegration.error.notConnected")),M([])):(M($.prs??[]),T($.page??1),L(!!$.hasMore))}}catch($){W($ instanceof Error?$.message:r("session.githubIntegration.error.loadDataFailed"))}finally{N(!1)}}},[m,a,d,i,p,r]);ce.useEffect(()=>{if(!s||!m||d&&i?.connected===!1||!a)return;if(!D.trim()){K();return}const v=new AbortController;N(!0),W(null),T(1),L(!1);const $=p==="issues"&&a.issuesList?a.issuesList(m,{page:1,query:D.trim()}):p==="prs"&&a.prsList?a.prsList(m,{page:1,query:D.trim()}):null;if(!$){N(!1);return}return $.then(J=>{v.signal.aborted||("issues"in J?J.connected===!1?(W(r("session.githubIntegration.error.notConnected")),k([])):(k(J.issues??[]),T(J.page??1),L(!!J.hasMore)):"prs"in J&&(J.connected===!1?(W(r("session.githubIntegration.error.notConnected")),M([])):(M(J.prs??[]),T(J.page??1),L(!!J.hasMore))))}).catch(J=>{v.signal.aborted||W(J instanceof Error?J.message:r("session.githubIntegration.error.loadDataFailed"))}).finally(()=>{v.signal.aborted||N(!1)}),()=>v.abort()},[s,m,a,d,i,p,D,K,r]);const re=ce.useCallback(async()=>{if(!(!m||!a)&&!(j||y)&&V){S(!0);try{const v=q+1;if(p==="issues"&&a.issuesList){const $=D.trim()?await a.issuesList(m,{page:v,query:D.trim()}):await a.issuesList(m,{page:v});$.connected!==!1&&(k(J=>[...J,...$.issues??[]]),T($.page??v),L(!!$.hasMore))}else if(p==="prs"&&a.prsList){const $=D.trim()?await a.prsList(m,{page:v,query:D.trim()}):await a.prsList(m,{page:v});$.connected!==!1&&(M(J=>[...J,...$.prs??[]]),T($.page??v),L(!!$.hasMore))}}catch{}finally{S(!1)}}},[m,a,p,q,V,j,y,D]);ce.useEffect(()=>{if(!s){f("issues"),w(""),k([]),M([]),F(null),te(null),z(!1),W(null),U(new Map),T(1),L(!1);return}K()},[s,K]);const X=ce.useCallback(async v=>{if(!(!g||!v)&&!G.has(v))try{const J=(await Rr(g,{mode:"new",branchName:v,worktreeName:v})).errors.find(he=>he.code==="branch_in_use");U(he=>new Map(he).set(v,{isValid:!J,error:J?r(J.code==="branch_exists"?"session.githubIntegration.validation.branchAlreadyExists":"session.githubIntegration.validation.branchAlreadyCheckedOut"):null}))}catch{U($=>new Map($).set(v,{isValid:!1,error:r("session.githubIntegration.validation.failed")}))}},[g,G,r]);ce.useEffect(()=>{!s||p!=="prs"||A.forEach(v=>{v.head&&X(v.head)})},[s,p,A,X]);const Y=d&&i?.connected===!0,oe=()=>{c("github"),l(!0)},Z=v=>{F(v),te(null)},ee=v=>{te(v),F(null)},pe=()=>{B?n({type:"issue",item:B}):_&&n({type:"pr",item:_,includeDiff:H}),e(!1)},se=()=>{F(null),te(null),z(!1)},de=B||_&&G.get(_.head??"")?.isValid!==!1,Q=v=>v.head?G.get(v.head)?.isValid===!1:!0,ae=t.jsx(t.Fragment,{children:Y?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative mt-2",children:[t.jsx(E,{name:"search",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(yt,{value:b,onChange:v=>w(v.target.value),placeholder:r(p==="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:[j&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(E,{name:"loader-4",className:"h-5 w-5 animate-spin text-muted-foreground"})}),O&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-destructive/10 text-destructive",children:[t.jsx(E,{name:"error-warning",className:"h-4 w-4"}),t.jsx("span",{className:"typography-small",children:O})]})}),!j&&!O&&p==="issues"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[C.length>0?C.map(v=>t.jsx("button",{onClick:()=>Z(v),className:le("w-full text-left px-2 py-1.5 rounded transition-colors",B?.number===v.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:["#",v.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-2",children:v.title}),v.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:[v.sourceRepo.owner,"/",v.sourceRepo.repo]}):null]})]})},`${v.sourceRepo?.owner??""}-${v.sourceRepo?.repo??""}-${v.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")}),V&&!y&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{re()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),y&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]}),!j&&!O&&p==="prs"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[A.length>0?A.map(v=>{const $=Q(v),J=v.head?G.get(v.head):void 0;return t.jsx("button",{onClick:()=>!$&&ee(v),disabled:$,className:le("w-full text-left px-2 py-1.5 rounded transition-colors",_?.number===v.number?"bg-interactive-selection text-interactive-selection-foreground":$?"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:["#",v.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-1",children:v.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[v.head," → ",v.base]}),v.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info",children:[v.sourceRepo.owner,"/",v.sourceRepo.repo]}):null,$&&J?.error&&t.jsx("span",{className:"typography-micro text-destructive",children:J.error})]})]})]})},`${v.sourceRepo?.owner??""}-${v.sourceRepo?.repo??""}-${v.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")}),V&&!y&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{re()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),y&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]})]})})]}):t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 gap-4",children:[t.jsx(E,{name:"github",className:"h-12 w-12 text-muted-foreground"}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:r("session.githubIntegration.connect.title")}),t.jsx("p",{className:"typography-small text-muted-foreground mt-1",children:r("session.githubIntegration.connect.description")})]}),t.jsx(Ce,{onClick:oe,size:"sm",children:r("session.githubIntegration.connect.action")})]})}),ue=t.jsxs("div",{className:le("w-full",o?"flex flex-col gap-2":"flex flex-row items-center"),children:[t.jsxs("div",{className:le("flex items-center gap-4",o?"w-full justify-center order-1":"flex-1"),children:[!o&&(B||_)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 h-8 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate max-w-[150px]",children:B?r("session.githubIntegration.selected.issueNumber",{number:B.number}):r("session.githubIntegration.selected.prNumber",{number:_?.number??""})}),t.jsx("button",{onClick:se,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),p==="prs"&&_&&t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer h-8",children:[t.jsx(Ts,{checked:H,onChange:v=>z(v),ariaLabel:r("session.githubIntegration.includeDiffAria")}),t.jsx("span",{className:"typography-small text-foreground",children:r("session.githubIntegration.includeDiff")})]})]}),t.jsxs("div",{className:le("flex gap-2",o?"w-full order-2":"justify-end"),children:[t.jsx(Ce,{variant:"outline",size:"sm",onClick:()=>e(!1),className:le(o&&"flex-1"),children:r("session.githubIntegration.actions.cancel")}),t.jsx(Ce,{size:"sm",onClick:pe,disabled:!de,className:le(o&&"flex-1"),children:r("session.githubIntegration.actions.select")})]})]});return t.jsx(t.Fragment,{children:o?t.jsx(Ss,{open:s,title:r("session.githubIntegration.title"),onClose:()=>e(!1),footer:Y?ue:void 0,renderHeader:v=>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")}),v]}),t.jsx("div",{className:"w-full",children:t.jsx(Ns,{items:[{id:"issues",label:r("session.githubIntegration.tabs.issues"),icon:t.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(E,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:p,onSelect:$=>{f($),w("")},variant:"active-pill",layoutMode:"fit"})}),(B||_)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate flex-1",children:B?r("session.githubIntegration.selected.issueNumber",{number:B.number}):r("session.githubIntegration.selected.prNumber",{number:_?.number??""})}),t.jsx("button",{onClick:se,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]})]}),children:ae}):t.jsx(ks,{open:s,onOpenChange:e,children:t.jsxs(Is,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsx(zs,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Cs,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(E,{name:"github",className:"h-5 w-5"}),r("session.githubIntegration.title")]}),t.jsx("div",{className:"w-[220px]",children:t.jsx(Ns,{items:[{id:"issues",label:r("session.githubIntegration.tabs.issues"),icon:t.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(E,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:p,onSelect:v=>{f(v),w("")},variant:"active-pill",layoutMode:"fit"})})]})}),ae,t.jsx(Tn,{className:"mt-1",children:ue})]})})})}const vs=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,""),rd=s=>String(s).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"pr-head",dr=(s,e,n)=>{const r=vs(s.head||"");if(!r)throw new Error("PR head branch is missing");if(e.includes(r))return{existingBranch:r,setUpstream:void 0,upstreamRemote:void 0,upstreamBranch:void 0,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:r};const o=n.find(c=>{const u=c.indexOf("/");return u<=0||u>=c.length-1?!1:c.slice(u+1)===r});if(o){const c=o.indexOf("/"),u=o.slice(0,c);return{existingBranch:`remotes/${o}`,setUpstream:!0,upstreamRemote:u,upstreamBranch:r,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${u}/${r}`}}const a=String(s.headLabel||"").split(":")[0]?.trim(),i=s.headRepo?.owner||a||"pr-head",d=`pr-${rd(i)}`,l=s.headRepo?.cloneUrl||s.headRepo?.sshUrl||"";if(!l)throw new Error("PR head repository URL is unavailable. The fork may have been deleted; push the branch to a reachable repository and try again.");return{existingBranch:`remotes/${d}/${r}`,setUpstream:!0,upstreamRemote:d,upstreamBranch:r,ensureRemoteName:d,ensureRemoteUrl:l,sourceLabel:`${d}/${r}`}},bt=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),od=s=>{const e={repo:s.repo??null,issue:s.issue,comments:s.comments};return`GitHub issue context (JSON)
3
+ ${JSON.stringify(e,null,2)}`},ad=s=>`GitHub pull request context (JSON)
4
+ ${JSON.stringify(s,null,2)}`;function $f({open:s,onOpenChange:e,onWorktreeCreated:n}){const{t:r}=nt(),{github:o,git:a}=Dn(),i=Ue(x=>x.isMobile),d=Us(x=>x.status),l=Us(x=>x.hasChecked),c=It(x=>x.getActiveProject()),u=c?.path??null,m=ce.useMemo(()=>u&&c?{id:c.id,path:u}:null,[c,u]),[g,p]=ce.useState("new-branch"),[f,b]=ce.useState({branchName:"",worktreeName:"",isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1}),[w,C]=ce.useState({selectedBranch:"",worktreeName:""}),k=Na(u),A=ka(u),M=Pn(x=>x.fetchBranches),j=ce.useMemo(()=>k?.all?k.all.filter(x=>!x.startsWith("remotes/")).sort():[],[k]),N=ce.useMemo(()=>k?.all?k.all.filter(x=>x.startsWith("remotes/")).map(x=>x.replace(/^remotes\//,"")).sort():[],[k]),y=st(x=>x.availableWorktreesByProject),S=ce.useMemo(()=>{if(!u)return new Set;const x=y.get(u)??[];return new Set(x.map(R=>R.name))},[y,u]),O=ce.useCallback((x=10)=>{for(let R=0;R<x;R++){const be=Js();if(!S.has(be))return be}return`${Js()}-${Date.now().toString(36).slice(-4)}`},[S]),[W,B]=ce.useState(!1),[F,_]=ce.useState(!1),[te,H]=ce.useState(!1),[z,G]=ce.useState(!1),[U,q]=ce.useState(!1),[T,V]=ce.useState(""),[L,D]=ce.useState(""),K=ce.useRef(null),re=ce.useRef(null),X=ce.useRef(null),Y=ce.useRef(null),oe=ce.useCallback(x=>{x.stopPropagation()},[]),Z=ce.useCallback(x=>{let R=x;for(;R&&R!==document.body;){const{overflowY:be}=window.getComputedStyle(R);if((be==="auto"||be==="scroll")&&R.scrollHeight>R.clientHeight)return R;R=R.parentElement}return null},[]),ee=ce.useCallback(x=>{x&&(x.scrollTop=0)},[]),pe=ce.useCallback(x=>{const R=x.current?.querySelector('[data-slot="command-list"]')??null;ee(R)},[ee]),se=ce.useCallback(x=>{const R=Z(x.current);ee(R)},[Z,ee]),de=ce.useMemo(()=>cr({localBranches:j,remoteBranches:N,query:T}),[j,N,T]),Q=ce.useMemo(()=>cr({localBranches:j,remoteBranches:N,query:L}),[j,N,L]),ae=T.trim().length>0,ue=L.trim().length>0,v=de.matching.length>0,$=Q.matching.length>0,J=!!(u&&a),he=ce.useCallback(()=>{!u||!a||M(u,a)},[u,a,M]);ce.useEffect(()=>{!s||!u||!a||k?.all||M(u,a)},[s,u,a,k?.all,M]),ce.useEffect(()=>{!F&&!z&&V("")},[F,z]),ce.useEffect(()=>{!te&&!U&&D("")},[te,U]),ce.useEffect(()=>{F&&pe(K),z&&se(X)},[F,z,T,pe,se]),ce.useEffect(()=>{te&&pe(re),U&&se(Y)},[te,U,L,pe,se]);const[ie,ve]=ce.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[Ne,Ve]=ce.useState(!1),[Le,Ye]=ce.useState(null),Xe=ce.useCallback(()=>{const x=Nt.getState(),R=x.getVisibleAgents();if(x.settingsDefaultAgent){const be=R.find(fe=>fe.name===x.settingsDefaultAgent);if(be)return be.name}return R.find(be=>be.name==="build")?.name||R[0]?.name},[]),ze=ce.useCallback(()=>{const x=Nt.getState(),R=x.settingsDefaultModel;if(!R)return null;const be=Er(R);if(!be)return null;const{providerId:fe,modelId:Se}=be;return x.getModelMetadata(fe,Se)?{providerID:fe,modelID:Se}:null},[]),Fe=ce.useCallback((x,R)=>{const be=Nt.getState(),fe=be.settingsDefaultVariant,Se=be.currentProviderId===x&&be.currentModelId===R?be.currentVariant:void 0,qe=be.providers.find(Ee=>Ee.id===x)?.models.find(Ee=>Ee.id===R)?.variants;if(!qe)return fe||Se||void 0;if(fe&&Object.prototype.hasOwnProperty.call(qe,fe))return fe;if(Se&&Object.prototype.hasOwnProperty.call(qe,Se))return Se},[]),Ge=ce.useCallback(async x=>{if(!u||!o)return;const R=Nt.getState(),be=Ar.getState().lastUsedProvider,fe=ze(),Se=fe?.providerID||R.currentProviderId||be?.providerID,Be=fe?.modelID||R.currentModelId||be?.modelID,Re=Xe()||R.currentAgentName||void 0;if(!Se||!Be){je.error(r("session.newWorktree.error.noModelSelected"));return}const qe=Fe(Se,Be);if(x.issue){if(!o.issueGet||!o.issueComments)return;const Ee=await o.issueGet(u,x.issue.number,{sourceRepo:x.issue.sourceRepo??null});if(Ee.connected===!1||!Ee.repo||!Ee.issue)throw new Error("Failed to load issue context");const ft=await o.issueComments(u,x.issue.number,{sourceRepo:x.issue.sourceRepo??null});if(ft.connected===!1)throw new Error("Failed to load issue comments");const ct=await us("github.issue.review.visible",{issue_number:String(x.issue.number)}),ut=await us("github.issue.review.instructions"),it=od({repo:Ee.repo,issue:Ee.issue,comments:ft.comments??[]});await st.getState().sendMessage(ct,Se,Be,Re,void 0,void 0,[{text:ut,synthetic:!0},{text:it,synthetic:!0}],qe,void 0,{sessionId:x.sessionId}),$n(x.sessionId,x.directory,Un({url:Ee.issue.url,number:Ee.issue.number,title:Ee.issue.title,kind:"issue",author:Ee.issue.author,linkedAt:Date.now()}),!0).catch(()=>{}),je.success(r("session.newWorktree.toast.sessionFromIssue"));return}if(x.pr){if(!o.prContext)return;const Ee=await o.prContext(u,x.pr.number,{sourceRepo:x.pr.sourceRepo??null,includeDiff:x.includeDiff,includeCheckDetails:!1});if(Ee.connected===!1||!Ee.repo||!Ee.pr)throw new Error("Failed to load PR context");const ft=await us("github.pr.review.visible",{pr_number:String(x.pr.number)}),ct=await us("github.pr.review.instructions"),ut=ad(Ee);await st.getState().sendMessage(ft,Se,Be,Re,void 0,void 0,[{text:ct,synthetic:!0},{text:ut,synthetic:!0}],qe,void 0,{sessionId:x.sessionId}),$n(x.sessionId,x.directory,Un({url:Ee.pr.url,number:Ee.pr.number,title:Ee.pr.title,kind:"pull",author:Ee.pr.author,linkedAt:Date.now()}),!0).catch(()=>{}),je.success(r("session.newWorktree.toast.sessionFromPr"))}},[o,u,Xe,ze,Fe,r]),Ae=g==="new-branch"?f:w;ce.useEffect(()=>{if(!s||!k?.all||!u||f.sourceBranch)return;const x=f.sourceBranch;let R=!1;return(async()=>{try{const fe=await Ia(u).catch(()=>null);if(R)return;const Se=localStorage.getItem(nn),{sourceBranch:Be,shouldClearSavedSourceBranch:Re}=sd({branches:k.all,savedSourceBranch:Se,rootBranch:fe});if(Re&&localStorage.removeItem(nn),R||x)return;Be&&b(qe=>({...qe,sourceBranch:Be}))}catch{}})(),()=>{R=!0}},[s,k?.all,u,f.sourceBranch]),ce.useLayoutEffect(()=>{if(!s)return;p("new-branch"),C({selectedBranch:"",worktreeName:""}),_(!1),H(!1),G(!1),q(!1),V(""),D(""),ve({isValidating:!1,branchError:null,worktreeError:null,touched:!1});const x=O();b({branchName:x,worktreeName:x,isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1})},[s,O]),ce.useEffect(()=>{if(g!=="new-branch"||!f.isSyncingWorktreeName)return;const x=vs(f.branchName),R=bt(x);b(be=>({...be,worktreeName:R}))},[g,f.branchName,f.isSyncingWorktreeName]);const _e=ce.useCallback(async()=>{if(!m||!ie.touched||Ne)return;Le&&Le.abort();const x=new AbortController;Ye(x),ve(R=>({...R,isValidating:!0}));try{const R=g==="new-branch"?f.branchName:w.selectedBranch,be=Ae.worktreeName,fe=vs(R),Se=bt(be);let Be=null,Re=null;if(fe||(Be=r("session.newWorktree.error.branchNameRequired")),Se||(Re=r("session.newWorktree.error.worktreeDirectoryRequired")),fe&&Se){const qe=g==="new-branch"?f.linkedPr:null,Ee=qe?dr(qe,j,N):null,ft=await Rr(m,{mode:g==="existing-branch"||Ee?"existing":"new",branchName:fe,worktreeName:Se,existingBranch:Ee?.existingBranch??(g==="existing-branch"?fe:void 0),...Ee?.ensureRemoteName?{ensureRemoteName:Ee.ensureRemoteName}:{},...Ee?.ensureRemoteUrl?{ensureRemoteUrl:Ee.ensureRemoteUrl}:{}});if(x.signal.aborted)return;ft.ok||ft.errors.forEach(ct=>{if(ct.code==="worktree_exists"){Re=Re??ct.message;return}ct.code.startsWith("branch_")&&(Be=Be??ct.message)})}x.signal.aborted||ve(qe=>({...qe,isValidating:!1,branchError:Be,worktreeError:Re}))}catch{x.signal.aborted||ve(R=>({...R,isValidating:!1}))}},[m,g,f.branchName,f.linkedPr,w.selectedBranch,Ae.worktreeName,j,N,ie.touched,Le,Ne,r]),Oe=g==="new-branch"?f.branchName:w.selectedBranch;ce.useEffect(()=>{if(!s||!m||!ie.touched||Ne)return;const x=setTimeout(()=>{_e()},300);return()=>clearTimeout(x)},[Ae.worktreeName,Oe,s,m,_e,ie.touched,Ne]);const Ze=async()=>{if(!m||!u){je.error(r("session.newWorktree.error.noActiveProject"));return}ve(Se=>({...Se,touched:!0}));const x=g==="new-branch"?f.branchName:w.selectedBranch,R=Ae.worktreeName,be=vs(x),fe=bt(R);if(!be){je.error(r("session.newWorktree.error.branchNameRequired"));return}if(!fe){je.error(r("session.newWorktree.error.worktreeDirectoryRequired"));return}Le&&(Le.abort(),Ye(null)),ve(Se=>({...Se,isValidating:!1,branchError:null,worktreeError:null})),Ve(!0);try{const Se=g==="new-branch"?f.linkedPr:null,Be=g==="new-branch"?f.linkedIssue:null,Re=g==="new-branch"?f.linkedPr:null,qe=g==="new-branch"?f.includePrDiff:!1,Ee=!!(Be||Re),ft=await jr(m),ct=f.sourceBranch;let ut="";const it=(()=>{if(Se){const Me=dr(Se,j,N);return ut=Me.sourceLabel,{preferredName:be||fe,mode:"existing",branchName:be,worktreeName:fe,existingBranch:Me.existingBranch,setupCommands:ft,setUpstream:Me.setUpstream,upstreamRemote:Me.upstreamRemote,upstreamBranch:Me.upstreamBranch,returnAfterDirectoryCreated:!0,...Me.ensureRemoteName?{ensureRemoteName:Me.ensureRemoteName}:{},...Me.ensureRemoteUrl?{ensureRemoteUrl:Me.ensureRemoteUrl}:{}}}return ut=g==="new-branch"?ct:"",{preferredName:be||fe,mode:g==="existing-branch"?"existing":"new",branchName:g==="existing-branch"?void 0:be,worktreeName:fe,existingBranch:g==="existing-branch"?be:void 0,setupCommands:ft,returnAfterDirectoryCreated:!0,...ct&&g==="new-branch"?{startRef:ct}:{}}})(),P=await Ca(u,it),me=await Ta(m,P);let Ie=null;if(Ee){await Nr(m)&&await Da(me.path);const Me=Be?`#${Be.number} ${Be.title}`.trim():Re?`#${Re.number} ${Re.title}`.trim():r("session.newWorktree.newSessionTitle"),I=await Pa(Me,me.path,null);if(!I?.id)throw new Error("Failed to create session");Ie=I.id,n?.(me.path,{sessionId:Ie}),e(!1),Ve(!1),Ea(I.id,Me).catch(()=>{});try{st.getState().initializeNewOpenChamberSession(I.id,Nt.getState().agents)}catch{}}else e(!1),Ve(!1);const Te=td({mode:g,sourceBranch:f.sourceBranch,linkedPr:!!f.linkedPr,selectedBranch:w.selectedBranch});Te&&localStorage.setItem(nn,Te),je.success(r("session.newWorktree.toast.worktreeCreated"),{description:r("session.newWorktree.toast.worktreeCreatedDescription",{target:`${me.branch||me.name}${ut?` ${r("session.newWorktree.fromSource",{source:ut})}`:""}`})}),Ie?Ge({sessionId:Ie,directory:me.path,issue:Be,pr:Re,includeDiff:qe}).catch(Me=>{const I=Me instanceof Error?Me.message:r("session.newWorktree.error.sendGitHubContextFailed");je.error(r("session.newWorktree.error.sendGitHubContextFailed"),{description:I})}):n?.(me.path)}catch(Se){const Be=Se instanceof Error?Se.message:r("session.newWorktree.error.createWorktreeFailed");je.error(r("session.newWorktree.error.createWorktreeFailed"),{description:Be})}finally{Ve(!1)}},at=x=>{p(x),ve(R=>({...R,touched:!1,branchError:null,worktreeError:null}))},De=x=>{if(!x){b(R=>({...R,linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:""}));return}if(x.type==="issue"){const R=x.item,be=`issue-${R.number}-${Js()}`;b(fe=>({...fe,linkedIssue:R,linkedPr:null,includePrDiff:!1,branchName:be,worktreeName:bt(be),isSyncingWorktreeName:!0}))}else if(x.type==="pr"){const R=x.item;b(be=>({...be,linkedPr:R,linkedIssue:null,includePrDiff:x.includeDiff??!1,branchName:R.head,worktreeName:bt(R.head),isSyncingWorktreeName:!0}))}},Je=l&&d?.connected===!0,Ke=(g==="existing-branch"?!!w.selectedBranch&&!!w.worktreeName&&!ie.branchError&&!ie.worktreeError:!!vs(f.branchName)&&!!f.worktreeName&&!ie.branchError&&!ie.worktreeError)&&!Ne,ke=()=>{b(x=>({...x,linkedIssue:null,linkedPr:null,branchName:"",includePrDiff:!1,isSyncingWorktreeName:!0}))},rt=t.jsxs("div",{className:le("flex gap-2",i?"flex-col w-full":"flex-row items-center"),children:[t.jsx("div",{className:le("flex items-center gap-1.5 text-destructive",i?"w-full justify-center order-first":"mr-auto"),children:ie.touched&&(ie.branchError||ie.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(E,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:ie.branchError||ie.worktreeError})]})}),t.jsxs("div",{className:le("flex gap-2",i&&"w-full"),children:[t.jsx(Ce,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Ne,className:le(i&&"flex-1"),children:r("session.newWorktree.actions.cancel")}),t.jsxs(Ce,{size:"sm",onClick:Ze,disabled:!Ke||Ne,className:le("gap-1.5",i&&"flex-1"),children:[Ne&&t.jsx(E,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(Ne?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]});return t.jsxs(t.Fragment,{children:[i?t.jsxs(Ss,{open:s,title:r("session.newWorktree.title"),onClose:()=>e(!1),footer:rt,children:[t.jsx("div",{className:"w-full mb-4",children:t.jsx(Ns,{items:[{id:"new-branch",label:r("session.newWorktree.mode.newBranch"),icon:t.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(E,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:g,onSelect:x=>at(x),variant:"active-pill",layoutMode:"fit",className:"w-full"})}),t.jsxs("div",{className:"space-y-6",children:[g==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Ce,{variant:"outline",size:"sm",onClick:()=>G(!0),className:"flex-1 justify-between h-9",children:[t.jsx("span",{className:w.selectedBranch?"text-foreground":"text-muted-foreground",children:w.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(E,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(Ce,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:he,disabled:!J||A,title:r("session.newWorktree.fetchBranches"),children:A?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"refresh",className:"size-4"})})]}),t.jsx(Ss,{open:z,title:r("session.newWorktree.selectBranch"),onClose:()=>G(!1),children:t.jsxs("div",{className:"space-y-4",ref:X,children:[t.jsx(yt,{value:T,onChange:x=>V(x.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")}):j.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:[ae&&v&&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:de.matching.map(x=>t.jsx("button",{onClick:()=>{C(R=>({...R,selectedBranch:x.value,worktreeName:bt(x.label)})),ve(R=>({...R,touched:!0})),G(!1)},className:le("w-full text-left px-3 py-2.5 rounded-md transition-colors",w.selectedBranch===x.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:x.label})},`${x.source}-${x.value}`))})]}),ae&&!v&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!ae&&de.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:de.otherLocal.map(x=>t.jsx("button",{onClick:()=>{C(R=>({...R,selectedBranch:x,worktreeName:bt(x)})),ve(R=>({...R,touched:!0})),G(!1)},className:le("w-full text-left px-3 py-2.5 rounded-md transition-colors",w.selectedBranch===x?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:x})},x))})]}),!ae&&de.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:de.otherRemote.map(x=>t.jsx("button",{onClick:()=>{C(R=>({...R,selectedBranch:`remotes/${x}`,worktreeName:bt(x)})),ve(R=>({...R,touched:!0})),G(!1)},className:le("w-full text-left px-3 py-2.5 rounded-md transition-colors",w.selectedBranch===`remotes/${x}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:x})},`remotes/${x}`))})]})]})]})})]}):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")}),g==="new-branch"&&Je&&t.jsxs(Ce,{variant:"outline",size:"sm",onClick:()=>B(!0),className:"gap-1.5 h-7",children:[t.jsx(E,{name:"github",className:"size-4 text-status-success"}),f.linkedIssue||f.linkedPr?r("session.newWorktree.actions.change"):r("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(yt,{value:f.branchName,onChange:x=>{b(R=>({...R,branchName:x.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>ve(x=>({...x,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!f.linkedPr,className:le("h-8",ie.touched&&ie.branchError&&"border-destructive",f.linkedPr&&"bg-muted text-muted-foreground")}),f.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:f.linkedPr.head})})]}),f.linkedIssue&&!f.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:f.linkedIssue.number,title:f.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")}),g!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const x=bt(g==="new-branch"?f.branchName:"");b(R=>({...R,worktreeName:x,isSyncingWorktreeName:!0}))},disabled:!f.branchName||f.worktreeName===bt(f.branchName),className:le("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",f.worktreeName===bt(f.branchName)||!f.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:r("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(E,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:r("session.newWorktree.actions.reset")})]})]}),t.jsx(yt,{value:Ae.worktreeName,onChange:x=>{g==="new-branch"?b(R=>({...R,worktreeName:x.target.value,isSyncingWorktreeName:!1})):C(R=>({...R,worktreeName:x.target.value}))},onBlur:()=>ve(x=>({...x,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:le("h-8",ie.touched&&ie.worktreeError&&"border-destructive")})]}),g==="new-branch"&&!f.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(Ce,{variant:"outline",size:"sm",onClick:()=>q(!0),className:"w-full justify-between h-9",children:[t.jsx("span",{className:f.sourceBranch?"text-foreground":"text-muted-foreground",children:f.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(E,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),f.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:f.sourceBranch})}),t.jsx(Ss,{open:U,title:r("session.newWorktree.selectSourceBranch"),onClose:()=>q(!1),children:t.jsxs("div",{className:"space-y-4",ref:Y,children:[t.jsx(yt,{value:L,onChange:x=>D(x.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")}):j.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:[ue&&$&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:Q.matching.map(x=>t.jsx("button",{onClick:()=>{b(R=>({...R,sourceBranch:x.value})),q(!1)},className:le("w-full text-left px-3 py-2.5 rounded-md transition-colors",f.sourceBranch===x.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:x.label})},`${x.source}-${x.value}`))})]}),ue&&!$&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!ue&&Q.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:Q.otherLocal.map(x=>t.jsx("button",{onClick:()=>{b(R=>({...R,sourceBranch:x})),q(!1)},className:le("w-full text-left px-3 py-2.5 rounded-md transition-colors",f.sourceBranch===x?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:x})},x))})]}),!ue&&Q.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:Q.otherRemote.map(x=>t.jsx("button",{onClick:()=>{b(R=>({...R,sourceBranch:`remotes/${x}`})),q(!1)},className:le("w-full text-left px-3 py-2.5 rounded-md transition-colors",f.sourceBranch===`remotes/${x}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:x})},`remotes/${x}`))})]})]})]})})]}),(f.linkedIssue||f.linkedPr)&&g==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(E,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),f.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:f.linkedIssue.number})}),f.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:f.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:f.linkedIssue?.title||f.linkedPr?.title}),t.jsx("a",{href:f.linkedIssue?.url||f.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:x=>x.stopPropagation(),children:t.jsx(E,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:ke,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),f.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:[f.linkedPr.head," → ",f.linkedPr.base]}),f.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(ks,{open:s,onOpenChange:e,children:t.jsxs(Is,{className:"max-w-lg max-h-[80vh] flex flex-col",children:[t.jsx(zs,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Cs,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(E,{name:"git-branch",className:"h-5 w-5"}),r("session.newWorktree.title")]}),t.jsx("div",{className:"w-[280px] shrink-0",children:t.jsx(Ns,{items:[{id:"new-branch",label:r("session.newWorktree.mode.newBranch"),icon:t.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(E,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:g,onSelect:x=>at(x),variant:"active-pill",layoutMode:"fit",className:"w-full"})})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto mt-2 space-y-6",children:[g==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(zt,{open:F,onOpenChange:_,children:[t.jsx(Vt,{asChild:!0,children:t.jsxs("button",{type:"button",className:le(Wn({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:le("truncate",w.selectedBranch?"text-foreground":"text-muted-foreground"),children:w.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(Gt,{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:K,children:t.jsxs(pn,{shouldFilter:!1,children:[t.jsx(gn,{placeholder:r("session.newWorktree.searchBranches"),value:T,onValueChange:V,onKeyDown:oe}),t.jsx(xn,{disableHorizontal:!0,children:A?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):j.length===0&&N.length===0?t.jsx(bn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[ae&&v&&t.jsx(Ut,{heading:r("session.newWorktree.matchingBranches"),children:de.matching.map(x=>t.jsx(Pt,{value:x.value,onSelect:()=>{C(R=>({...R,selectedBranch:x.value,worktreeName:bt(x.label)})),ve(R=>({...R,touched:!0})),_(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x.label})},`${x.source}-${x.value}`))}),ae&&!v&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!ae&&de.otherLocal.length>0&&t.jsx(t.Fragment,{children:t.jsx(Ut,{heading:r("session.newWorktree.localBranches"),children:de.otherLocal.map(x=>t.jsx(Pt,{value:x,onSelect:()=>{C(R=>({...R,selectedBranch:x,worktreeName:bt(x)})),ve(R=>({...R,touched:!0})),_(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x})},`local-${x}`))})}),!ae&&de.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[de.otherLocal.length>0&&t.jsx($s,{}),t.jsx(Ut,{heading:r("session.newWorktree.remoteBranches"),children:de.otherRemote.map(x=>t.jsx(Pt,{value:`remotes/${x}`,onSelect:()=>{C(R=>({...R,selectedBranch:`remotes/${x}`,worktreeName:bt(x)})),ve(R=>({...R,touched:!0})),_(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x})},`remote-${x}`))})]})]})})]})})]}),t.jsx(Ce,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:he,disabled:!J||A,title:r("session.newWorktree.fetchBranches"),children:A?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"refresh",className:"size-4"})})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.branchName")}),g==="new-branch"&&Je&&t.jsxs(Ce,{variant:"outline",size:"sm",onClick:()=>B(!0),className:"gap-1.5 h-7",children:[t.jsx(E,{name:"github",className:"size-4 text-status-success"}),f.linkedIssue||f.linkedPr?r("session.newWorktree.actions.change"):r("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(yt,{value:f.branchName,onChange:x=>{b(R=>({...R,branchName:x.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>ve(x=>({...x,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!f.linkedPr,className:le("h-8",ie.touched&&ie.branchError&&"border-destructive",f.linkedPr&&"bg-muted text-muted-foreground")}),f.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:f.linkedPr.head})})]}),f.linkedIssue&&!f.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:f.linkedIssue.number,title:f.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")}),g!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const x=bt(g==="new-branch"?f.branchName:"");b(R=>({...R,worktreeName:x,isSyncingWorktreeName:!0}))},disabled:!f.branchName||f.worktreeName===bt(f.branchName),className:le("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",f.worktreeName===bt(f.branchName)||!f.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:r("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(E,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:r("session.newWorktree.actions.reset")})]})]}),t.jsx(yt,{value:Ae.worktreeName,onChange:x=>{g==="new-branch"?b(R=>({...R,worktreeName:x.target.value,isSyncingWorktreeName:!1})):C(R=>({...R,worktreeName:x.target.value}))},onBlur:()=>ve(x=>({...x,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:le("h-8",ie.touched&&ie.worktreeError&&"border-destructive")})]}),g==="new-branch"&&!f.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(zt,{open:te,onOpenChange:H,children:[t.jsx(Vt,{asChild:!0,children:t.jsxs("button",{type:"button",className:le(Wn({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:le("truncate",f.sourceBranch?"text-foreground":"text-muted-foreground"),children:f.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(Gt,{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:re,children:t.jsxs(pn,{shouldFilter:!1,children:[t.jsx(gn,{placeholder:r("session.newWorktree.searchBranches"),value:L,onValueChange:D,onKeyDown:oe}),t.jsx(xn,{disableHorizontal:!0,children:A?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):j.length===0&&N.length===0?t.jsx(bn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[ue&&$&&t.jsx(Ut,{heading:r("session.newWorktree.matchingBranches"),children:Q.matching.map(x=>t.jsx(Pt,{value:x.value,onSelect:()=>{b(R=>({...R,sourceBranch:x.value})),H(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x.label})},`${x.source}-${x.value}`))}),ue&&!$&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!ue&&Q.otherLocal.length>0&&t.jsx(t.Fragment,{children:t.jsx(Ut,{heading:r("session.newWorktree.localBranches"),children:Q.otherLocal.map(x=>t.jsx(Pt,{value:x,onSelect:()=>{b(R=>({...R,sourceBranch:x})),H(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x})},`local-${x}`))})}),!ue&&Q.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[Q.otherLocal.length>0&&t.jsx($s,{}),t.jsx(Ut,{heading:r("session.newWorktree.remoteBranches"),children:Q.otherRemote.map(x=>t.jsx(Pt,{value:`remotes/${x}`,onSelect:()=>{b(R=>({...R,sourceBranch:`remotes/${x}`})),H(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x})},`remote-${x}`))})]})]})})]})})]}),f.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:f.sourceBranch})})]}),(f.linkedIssue||f.linkedPr)&&g==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(E,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),f.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:f.linkedIssue.number})}),f.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:f.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:f.linkedIssue?.title||f.linkedPr?.title}),t.jsx("a",{href:f.linkedIssue?.url||f.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:x=>x.stopPropagation(),children:t.jsx(E,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:ke,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),f.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:[f.linkedPr.head," → ",f.linkedPr.base]}),f.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(Tn,{className:"mt-1 flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center gap-1.5 text-destructive",children:ie.touched&&(ie.branchError||ie.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(E,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:ie.branchError||ie.worktreeError})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ce,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Ne,children:r("session.newWorktree.actions.cancel")}),t.jsxs(Ce,{size:"sm",onClick:Ze,disabled:!Ke||Ne,className:"gap-1.5",children:[Ne&&t.jsx(E,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(Ne?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]})]})}),t.jsx(nd,{open:W,onOpenChange:B,onSelect:De})]})}const id=2880*60*1e3,ld=s=>!!s.parentID,cd=s=>!!s.time?.archived,dd=s=>{const e=s.time?.updated,n=s.time?.created;return typeof e=="number"&&Number.isFinite(e)?e:typeof n=="number"&&Number.isFinite(n)?n:0},ud=(s,e,n=Date.now())=>{const r=n-id;return s.filter(o=>cd(o)||ld(o)?!1:e.has(o.id)||dd(o)>=r)},Uf=({sessions:s,getSessionLocation:e,getSessionNode:n,query:r})=>[{key:"active-now",items:s.flatMap(o=>{const a=typeof o.title=="string"?o.title.toLowerCase():"";if(r&&!a.includes(r))return[];const i=e(o.id);return[{node:n?.(o)??{session:o,children:[],worktree:null},projectId:i?.projectId??null,groupDirectory:i?.groupDirectory??o.directory??null,secondaryMeta:i?{projectLabel:i.projectLabel,branchLabel:i.branchLabel}:null}]})}],ho=s=>s.parentID??null,fd=(s,e)=>{const n=[],r=[];for(const o of s)if(!Ra(o)){if(Aa(o.directory)){if(e)continue;r.push(o);continue}n.push(o)}return{projectSessions:n,chatSessions:r}},md=new Set,hd=(s,e,n)=>{if(s.time?.archived)return!0;const r=Sn(Oa(s))?.toLowerCase();return!r||e.size===0?!n:e.has(r)},pd=(s,e)=>{const n=[...s],r=new Set(s.map(o=>o.id));for(const o of e)r.has(o.id)||(r.add(o.id),n.push(o));return n},gd=(s,e)=>{const n=[],r=new Set([e]),o=a=>{for(const i of s.get(a)??[])r.has(i.id)||(r.add(i.id),n.push(i.id),o(i.id))};return o(e),n},xd=({globalActiveSessions:s,liveSessions:e,knownDirectories:n,isVSCode:r,globalStructure:o})=>{Br("sidebarStructureBuilds");const i=pd(s??[],e),d=fd(i,r),l=d.projectSessions.filter(b=>hd(b,n,r)),c=[...l,...d.chatSessions],u=new Map(c.map(b=>[b.id,b])),m=new Set(l.map(b=>b.id)),g=o?.activeRootIds??[],p=new Set(g),f=[...g.flatMap(b=>{if(!m.has(b))return[];const w=u.get(b);return w?[w]:[]}),...l.filter(b=>!p.has(b.id)&&!ho(b))];return{chatSessionIds:new Set(d.chatSessions.map(b=>b.id)),projectSessions:l,rootSessions:f,sessionById:u,sessions:c,hierarchy:o?{rootIds:o.activeRootIds,childrenByParentId:o.activeChildrenByParentId}:void 0}},bd=(s,e,n)=>{const r=Mr(s.sessions,e,n,s.hierarchy),o=new Map;for(const a of r){const i=ho(a);if(!i)continue;const d=o.get(i)??[];d.push(a),o.set(i,d)}return{chatSessions:r.filter(a=>s.chatSessionIds.has(a.id)),childrenMap:o,orderedSessions:r}},Wf=s=>{const e=We.c(33),{knownDirectories:n,isVSCode:r,isVisible:o}=s,a=qt(yd),i=qt(wd),d=qt(vd),l=qt(Sd),c=Ba(),u=Ma(jd);let m;e[0]!==o?(m=B=>o?B.rankById:$a,e[0]=o,e[1]=m):m=e[1];const g=La(m);let p;e[2]!==a||e[3]!==i||e[4]!==r||e[5]!==n||e[6]!==c?(p=xd({globalActiveSessions:a,globalStructure:i,liveSessions:c,knownDirectories:n,isVSCode:r}),e[2]=a,e[3]=i,e[4]=r,e[5]=n,e[6]=c,e[7]=p):p=e[7];const f=p;let b;e[8]!==u||e[9]!==g||e[10]!==f?(b=bd(f,u,g),e[8]=u,e[9]=g,e[10]=f,e[11]=b):b=e[11];const w=b,{chatSessions:C,orderedSessions:k}=w,A=f.projectSessions;let M;e[12]!==d||e[13]!==f.sessions?(M=new Map([...f.sessions,...d].map(Nd)),e[12]=d,e[13]=f.sessions,e[14]=M):M=e[14];const j=M;let N;if(e[15]!==d||e[16]!==w.childrenMap){N=new Map(w.childrenMap);for(const B of d){const F=B.parentID;if(!F)continue;const _=N.get(F)??[];_.push(B),N.set(F,_)}e[15]=d,e[16]=w.childrenMap,e[17]=N}else N=e[17];const y=N;let S;e[18]!==y||e[19]!==j?(S=(B,F)=>gd(y,B).filter(_=>F.includeArchived||!j.get(_)?.time?.archived),e[18]=y,e[19]=j,e[20]=S):S=e[20];const O=S;let W;return e[21]!==d||e[22]!==C||e[23]!==y||e[24]!==O||e[25]!==l||e[26]!==c||e[27]!==k||e[28]!==u||e[29]!==g||e[30]!==A||e[31]!==f.rootSessions?(W={archivedSessions:d,childrenMap:y,chatSessions:C,getDescendantIds:O,hasAuthoritativeGlobalSessions:l,liveSessions:c,orderedSessions:k,pinnedSessionIds:u,sessionOrderRanks:g,sessions:A,rootSessions:f.rootSessions},e[21]=d,e[22]=C,e[23]=y,e[24]=O,e[25]=l,e[26]=c,e[27]=k,e[28]=u,e[29]=g,e[30]=A,e[31]=f.rootSessions,e[32]=W):W=e[32],W},_f=s=>{const e=We.c(9),{enabled:n,isVSCode:r,pinnedSessionIds:o,sessionOrderRanks:a,sessions:i}=s;let d;e[0]!==n||e[1]!==r?(d=u=>n&&!r?u.activeSessionIds:md,e[0]=n,e[1]=r,e[2]=d):d=e[2];const l=Fa(d);let c;e:{if(!n||r){let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[3]=m):m=e[3],c=m;break e}Br("recentCandidatesVisited",i.length);let u;e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==i?(u=Mr(ud(i,l),o,a),e[4]=l,e[5]=o,e[6]=a,e[7]=i,e[8]=u):u=e[8],c=u}return c};function yd(s){return s.activeSessions}function wd(s){return s.structure}function vd(s){return s.archivedSessions}function Sd(s){return s.status==="ready"}function jd(s){return s.ids}function Nd(s){return[s.id,s]}const An=(s,e)=>s==="global"?"global":`project:${e??""}`,po=(s,e)=>s.createdAt>e?"new":s.updatedAt>e?"changed":null,ur=(s,e)=>s.reduce((n,r)=>po(r,e)?n+1:n,0),go=s=>{const e=We.c(29),{expanded:n,onToggleExpanded:r,header:o,children:a,actions:i,footer:d,expandLabel:l}=s,{t:c}=nt(),u=!n&&"cursor-pointer hover:border-[var(--interactive-border)] hover:bg-interactive-hover/30";let m;e[0]!==u?(m=le("flex flex-col gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 py-1.5",u),e[0]=u,e[1]=m):m=e[1];const g=n?void 0:r;let p;e[2]!==n||e[3]!==r?(p=n?void 0:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),r())},e[2]=n,e[3]=r,e[4]=p):p=e[4];const f=n?void 0:"button",b=n?void 0:0,w=n?void 0:l;let C;e[5]!==a||e[6]!==o?(C=t.jsxs("div",{className:"min-w-0 flex-1",children:[o,a]}),e[5]=a,e[6]=o,e[7]=C):C=e[7];let k;e[8]!==n||e[9]!==r||e[10]!==c?(k=n?t.jsx("button",{type:"button",onClick:r,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":c("rightSidebar.contextNotesTodo.notes.actions.collapse"),title:c("rightSidebar.contextNotesTodo.notes.actions.collapse"),children:t.jsx(E,{name:"arrow-up-s",className:"h-3.5 w-3.5"})}):null,e[8]=n,e[9]=r,e[10]=c,e[11]=k):k=e[11];let A;e[12]!==i||e[13]!==k?(A=t.jsxs("div",{className:"flex flex-shrink-0 flex-col items-center gap-0.5",onClick:kd,onKeyDown:Id,children:[k,i]}),e[12]=i,e[13]=k,e[14]=A):A=e[14];let M;e[15]!==A||e[16]!==C?(M=t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[C,A]}),e[15]=A,e[16]=C,e[17]=M):M=e[17];let j;e[18]!==d?(j=d?t.jsx("div",{className:"min-w-0",children:d}):null,e[18]=d,e[19]=j):j=e[19];let N;return e[20]!==M||e[21]!==j||e[22]!==m||e[23]!==g||e[24]!==p||e[25]!==f||e[26]!==b||e[27]!==w?(N=t.jsxs("li",{className:m,onClick:g,onKeyDown:p,role:f,tabIndex:b,"aria-label":w,children:[M,j]}),e[20]=M,e[21]=j,e[22]=m,e[23]=g,e[24]=p,e[25]=f,e[26]=b,e[27]=w,e[28]=N):N=e[28],N};function kd(s){return s.stopPropagation()}function Id(s){return s.stopPropagation()}const Cd=s=>{const e=We.c(52),{entry:n,badge:r,expanded:o,onToggleExpanded:a,onSave:i,onDelete:d}=s,{t:l}=nt(),[c,u]=h.useState(n.title),[m,g]=h.useState(n.body);let p,f;e[0]!==n.body||e[1]!==n.title||e[2]!==o?(p=()=>{o||(u(n.title),g(n.body))},f=[n.body,n.title,o],e[0]=n.body,e[1]=n.title,e[2]=o,e[3]=p,e[4]=f):(p=e[3],f=e[4]),h.useEffect(p,f);let b;e[5]!==m||e[6]!==n.body||e[7]!==n.title||e[8]!==i||e[9]!==c?(b=()=>{const H=c.trim(),z=m.trim();if(!H||!z){u(n.title),g(n.body);return}H===n.title&&z===n.body||i({title:H,body:z})},e[5]=m,e[6]=n.body,e[7]=n.title,e[8]=i,e[9]=c,e[10]=b):b=e[10];const w=b,C=`rightSidebar.contextNotesTodo.memory.type.${n.type}`;let k;e[11]!==l||e[12]!==C?(k=l(C),e[11]=l,e[12]=C,e[13]=k):k=e[13];const A=k;let M;e[14]!==w||e[15]!==o||e[16]!==a?(M=()=>{o&&w(),a()},e[14]=w,e[15]=o,e[16]=a,e[17]=M):M=e[17];const j=n.title;let N;e[18]!==n.flagged||e[19]!==l?(N=n.flagged?t.jsxs("span",{className:"flex items-center gap-1 text-[var(--status-error)]",children:[t.jsx(E,{name:"error-warning",className:"h-3 w-3 flex-shrink-0"}),l("rightSidebar.contextNotesTodo.memory.flagged")]}):null,e[18]=n.flagged,e[19]=l,e[20]=N):N=e[20];let y;e[21]!==N||e[22]!==A?(y=t.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 typography-micro text-muted-foreground",children:[A,N]}),e[21]=N,e[22]=A,e[23]=y):y=e[23];let S;e[24]!==r||e[25]!==l?(S=r?t.jsx("span",{className:le("mb-0.5 mr-1.5 inline-block rounded-full px-1.5 py-px typography-micro font-medium",r==="new"?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--status-warning)]/15 text-[var(--status-warning)]"),children:l(r==="new"?"rightSidebar.contextNotesTodo.memory.badge.new":"rightSidebar.contextNotesTodo.memory.badge.changed")}):null,e[24]=r,e[25]=l,e[26]=S):S=e[26];let O;e[27]!==l?(O=l("rightSidebar.contextNotesTodo.memory.actions.delete"),e[27]=l,e[28]=O):O=e[28];let W;e[29]!==l?(W=l("rightSidebar.contextNotesTodo.memory.actions.delete"),e[29]=l,e[30]=W):W=e[30];let B;e[31]===Symbol.for("react.memo_cache_sentinel")?(B=t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[31]=B):B=e[31];let F;e[32]!==d||e[33]!==O||e[34]!==W?(F=t.jsx("button",{type:"button",onClick:d,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":O,title:W,children:B}),e[32]=d,e[33]=O,e[34]=W,e[35]=F):F=e[35];let _;e[36]!==m||e[37]!==w||e[38]!==n.body||e[39]!==n.title||e[40]!==o||e[41]!==l||e[42]!==c?(_=o?t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(yt,{value:c,onChange:H=>u(H.target.value.slice(0,Ua)),onBlur:w,"aria-label":l("rightSidebar.contextNotesTodo.memory.actions.editTitle"),className:"h-7 typography-ui-label"}),t.jsx(Gs,{simple:!0,rows:Math.min(20,Math.max(3,m.split(`
5
+ `).length+1)),value:m,onChange:H=>g(H.target.value.slice(0,Wa)),onBlur:w,"aria-label":l("rightSidebar.contextNotesTodo.memory.actions.editBody"),className:"min-h-0 w-full resize-none bg-transparent p-0 typography-meta leading-normal text-muted-foreground focus-visible:outline-none focus-visible:ring-0"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:n.title}),t.jsx("p",{className:"line-clamp-2 whitespace-pre-wrap break-words typography-meta text-muted-foreground",children:n.body})]}),e[36]=m,e[37]=w,e[38]=n.body,e[39]=n.title,e[40]=o,e[41]=l,e[42]=c,e[43]=_):_=e[43];let te;return e[44]!==n.title||e[45]!==o||e[46]!==S||e[47]!==F||e[48]!==_||e[49]!==M||e[50]!==y?(te=t.jsx(go,{expanded:o,onToggleExpanded:M,expandLabel:j,footer:y,header:S,actions:F,children:_}),e[44]=n.title,e[45]=o,e[46]=S,e[47]=F,e[48]=_,e[49]=M,e[50]=y,e[51]=te):te=e[51],te},Td=s=>{const e=We.c(59),{projectPath:n,query:r}=s,{t:o}=nt(),[a,i]=h.useState("project"),[d,l]=h.useState(null),c=Dt(Dd);let u;e[0]!==n?(u=Z=>Lr(Z,n),e[0]=n,e[1]=u):u=e[1];const m=Dt(u),g=Dt(Pd),p=Dt(Ed),f=Dt(Rd),b=Dt(Ad),w=Ue(Bd),C=a==="global"?c:m,k=a==="global"?g:p;let A;e[2]!==n||e[3]!==a?(A=An(a,n),e[2]=n,e[3]=a,e[4]=A):A=e[4];const M=A;let j;e[5]!==M?(j=Z=>Z.agentMemoryViewedAt[M]??0,e[5]=M,e[6]=j):j=e[6];const N=Ue(j),y=h.useRef(N),[S,O]=h.useState(N);let W,B;e[7]!==w||e[8]!==M?(W=()=>(y.current=Ue.getState().agentMemoryViewedAt[M]??0,O(y.current),()=>{w(M,Date.now())}),B=[w,M],e[7]=w,e[8]=M,e[9]=W,e[10]=B):(W=e[9],B=e[10]),h.useEffect(W,B);let F;if(e[11]!==C||e[12]!==r){let Z;e[14]!==r?(Z=ee=>Hs([ee.title,ee.body],r),e[14]=r,e[15]=Z):Z=e[15],F=C.filter(Z),e[11]=C,e[12]=r,e[13]=F}else F=e[13];const _=F;let te;e[16]!==f||e[17]!==a||e[18]!==o?(te=async Z=>{if(!await f(a,Z)){const ee=Dt.getState().error;je.error(o("rightSidebar.contextNotesTodo.memory.toast.deleteFailed"),ee?{description:ee}:void 0)}},e[16]=f,e[17]=a,e[18]=o,e[19]=te):te=e[19];const H=te;let z;e[20]!==b||e[21]!==a||e[22]!==o?(z=async(Z,ee)=>{if(!await b(a,Z,ee)){const pe=Dt.getState().error;je.error(o("rightSidebar.contextNotesTodo.memory.toast.saveFailed"),pe?{description:pe}:void 0)}},e[20]=b,e[21]=a,e[22]=o,e[23]=z):z=e[23];const G=z;let U;e[24]!==o?(U=o("rightSidebar.contextNotesTodo.memory.scope.project"),e[24]=o,e[25]=U):U=e[25];let q;e[26]!==m.length||e[27]!==U?(q={id:"project",label:U,count:m.length},e[26]=m.length,e[27]=U,e[28]=q):q=e[28];let T;e[29]!==o?(T=o("rightSidebar.contextNotesTodo.memory.scope.global"),e[29]=o,e[30]=T):T=e[30];let V;e[31]!==c.length||e[32]!==T?(V={id:"global",label:T,count:c.length},e[31]=c.length,e[32]=T,e[33]=V):V=e[33];let L;e[34]!==q||e[35]!==V?(L=[q,V],e[34]=q,e[35]=V,e[36]=L):L=e[36];const D=L;let K;e[37]!==o?(K=o("rightSidebar.contextNotesTodo.memory.scope.label"),e[37]=o,e[38]=K):K=e[38];let re;e[39]!==a||e[40]!==D?(re=D.map(Z=>t.jsx(Ce,{type:"button",variant:"chip",size:"xs","aria-pressed":a===Z.id,className:"!font-normal",onClick:()=>i(Z.id),children:`${Z.label} ${Z.count}`},Z.id)),e[39]=a,e[40]=D,e[41]=re):re=e[41];let X;e[42]!==K||e[43]!==re?(X=t.jsx("div",{role:"group","aria-label":K,className:"flex items-center gap-1",children:re}),e[42]=K,e[43]=re,e[44]=X):X=e[44];let Y;e[45]!==S||e[46]!==d||e[47]!==H||e[48]!==G||e[49]!==n||e[50]!==r||e[51]!==a||e[52]!==k||e[53]!==o||e[54]!==_?(Y=a==="project"&&!n?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.memory.empty.noProject")}):k?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.memory.empty.unavailable")}):_.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r.trim()?o("rightSidebar.contextNotesTodo.memory.empty.noMatches"):o("rightSidebar.contextNotesTodo.memory.empty.nothing")}):t.jsx("ul",{className:"flex flex-col gap-1.5",children:_.map(Z=>t.jsx(Cd,{entry:Z,badge:po(Z,S),expanded:d===Z.id,onToggleExpanded:()=>l(d===Z.id?null:Z.id),onSave:ee=>{G(Z.id,ee)},onDelete:()=>{H(Z.id)}},Z.id))}),e[45]=S,e[46]=d,e[47]=H,e[48]=G,e[49]=n,e[50]=r,e[51]=a,e[52]=k,e[53]=o,e[54]=_,e[55]=Y):Y=e[55];let oe;return e[56]!==X||e[57]!==Y?(oe=t.jsxs("div",{className:"flex flex-col gap-2",children:[X,Y]}),e[56]=X,e[57]=Y,e[58]=oe):oe=e[58],oe};function Dd(s){return s.global}function Pd(s){return s.globalFailed}function Ed(s){return s.projectFailed}function Rd(s){return s.deleteEntry}function Ad(s){return s.saveEntry}function Bd(s){return s.markAgentMemoryViewed}const Md=400,Ld=s=>{const e=We.c(61),{note:n,pinned:r,expanded:o,onToggleExpanded:a,onSaveBody:i,onTogglePinned:d,onDelete:l}=s,{t:c}=nt(),[u,m]=h.useState(n.body),g=h.useRef(n.body),p=h.useRef(null);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null)},e[0]=f):f=e[0];const b=f;let w,C;e[1]!==u||e[2]!==n.body?(w=()=>{n.body!==g.current&&u===g.current&&(g.current=n.body,m(n.body))},C=[u,n.body],e[1]=u,e[2]=n.body,e[3]=w,e[4]=C):(w=e[3],C=e[4]),h.useEffect(w,C);let k,A;e[5]!==u||e[6]!==i?(k=()=>{if(u!==g.current)return p.current=window.setTimeout(()=>{p.current=null,u.trim()&&(g.current=u,i(u))},Md),b},A=[b,u,i],e[5]=u,e[6]=i,e[7]=k,e[8]=A):(k=e[7],A=e[8]),h.useEffect(k,A);let M,j;e[9]===Symbol.for("react.memo_cache_sentinel")?(M=()=>b,j=[b],e[9]=M,e[10]=j):(M=e[9],j=e[10]),h.useEffect(M,j);let N;e[11]!==u||e[12]!==i?(N=()=>{if(b(),u!==g.current){if(!u.trim()){m(g.current);return}g.current=u,i(u)}},e[11]=u,e[12]=i,e[13]=N):N=e[13];const y=N;let S;e[14]!==n.source||e[15]!==c?(S=n.source==="selection"?c("rightSidebar.contextNotesTodo.notes.source.selection"):n.source==="agent"?c("rightSidebar.contextNotesTodo.notes.source.agent"):null,e[14]=n.source,e[15]=c,e[16]=S):S=e[16];const O=S;let W;e[17]!==c?(W=c("rightSidebar.contextNotesTodo.notes.actions.expand"),e[17]=c,e[18]=W):W=e[18];let B;e[19]!==O?(B=O?t.jsx("span",{className:"typography-micro text-muted-foreground",children:O}):null,e[19]=O,e[20]=B):B=e[20];const F=r?"text-primary":"text-muted-foreground hover:text-foreground";let _;e[21]!==F?(_=le("inline-flex h-6 w-6 items-center justify-center rounded-md hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",F),e[21]=F,e[22]=_):_=e[22];let te;e[23]!==r||e[24]!==c?(te=c(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[23]=r,e[24]=c,e[25]=te):te=e[25];let H;e[26]!==r||e[27]!==c?(H=c(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[26]=r,e[27]=c,e[28]=H):H=e[28];const z=r?"pushpin-2-fill":"pushpin";let G;e[29]!==z?(G=t.jsx(E,{name:z,className:"h-3.5 w-3.5"}),e[29]=z,e[30]=G):G=e[30];let U;e[31]!==d||e[32]!==r||e[33]!==_||e[34]!==te||e[35]!==H||e[36]!==G?(U=t.jsx("button",{type:"button",onClick:d,className:_,"aria-pressed":r,"aria-label":te,title:H,children:G}),e[31]=d,e[32]=r,e[33]=_,e[34]=te,e[35]=H,e[36]=G,e[37]=U):U=e[37];let q;e[38]!==c?(q=c("rightSidebar.contextNotesTodo.notes.actions.delete"),e[38]=c,e[39]=q):q=e[39];let T;e[40]!==c?(T=c("rightSidebar.contextNotesTodo.notes.actions.delete"),e[40]=c,e[41]=T):T=e[41];let V;e[42]===Symbol.for("react.memo_cache_sentinel")?(V=t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[42]=V):V=e[42];let L;e[43]!==l||e[44]!==q||e[45]!==T?(L=t.jsx("button",{type:"button",onClick:l,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":q,title:T,children:V}),e[43]=l,e[44]=q,e[45]=T,e[46]=L):L=e[46];let D;e[47]!==U||e[48]!==L?(D=t.jsxs(t.Fragment,{children:[U,L]}),e[47]=U,e[48]=L,e[49]=D):D=e[49];let K;e[50]!==u||e[51]!==o||e[52]!==y?(K=o?t.jsx(Gs,{simple:!0,autoFocus:!0,rows:Math.min(20,Math.max(3,u.split(`
6
+ `).length+1)),value:u,onChange:X=>m(X.target.value.slice(0,wn)),onBlur:y,className:"min-h-0 w-full resize-none bg-transparent p-0 typography-ui-label leading-normal text-foreground focus-visible:outline-none focus-visible:ring-0"}):t.jsx("p",{className:"line-clamp-3 whitespace-pre-wrap break-words typography-ui-label leading-normal text-foreground",title:u,children:u}),e[50]=u,e[51]=o,e[52]=y,e[53]=K):K=e[53];let re;return e[54]!==o||e[55]!==a||e[56]!==W||e[57]!==B||e[58]!==D||e[59]!==K?(re=t.jsx(go,{expanded:o,onToggleExpanded:a,expandLabel:W,footer:B,actions:D,children:K}),e[54]=o,e[55]=a,e[56]=W,e[57]=B,e[58]=D,e[59]=K,e[60]=re):re=e[60],re},Fd=s=>{const e=We.c(69),{projectRef:n,notes:r,disabled:o,query:a,pinnedNoteIds:i,onTogglePinned:d}=s,{t:l}=nt(),[c,u]=h.useState(""),[m,g]=h.useState(null),p=Ue(Od),f=Ue($d),b=Et(Ud),w=Et(Wd),C=Et(_d);let k;if(e[0]!==r||e[1]!==a){let Y;e[3]!==a?(Y=oe=>Hs([oe.body],a),e[3]=a,e[4]=Y):Y=e[4],k=r.filter(Y),e[0]=r,e[1]=a,e[2]=k}else k=e[2];const A=k;let M;e[5]!==n?(M=Y=>{const oe=Et.getState().getEntry(n).error;je.error(Y,oe?{description:oe}:void 0)},e[5]=n,e[6]=M):M=e[6];const j=M;let N;e[7]!==c||e[8]!==b||e[9]!==n||e[10]!==j||e[11]!==l?(N=async()=>{const Y=c.trim();if(!Y)return;if(!await b(n,{body:Y})){j(l("rightSidebar.contextNotesTodo.toast.createNoteFailed"));return}u("")},e[7]=c,e[8]=b,e[9]=n,e[10]=j,e[11]=l,e[12]=N):N=e[12];const y=N;let S;e[13]!==C||e[14]!==n||e[15]!==j||e[16]!==l?(S=async Y=>{await C(n,Y)||j(l("rightSidebar.contextNotesTodo.toast.deleteNoteFailed"))},e[13]=C,e[14]=n,e[15]=j,e[16]=l,e[17]=S):S=e[17];const O=S;let W;e[18]!==d||e[19]!==j||e[20]!==l?(W=async(Y,oe)=>{await d(Y,oe)||j(l("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))},e[18]=d,e[19]=j,e[20]=l,e[21]=W):W=e[21];const B=W;let F;e[22]!==n||e[23]!==j||e[24]!==w||e[25]!==l?(F=(Y,oe)=>{w(n,Y,oe).then(Z=>{Z||j(l("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[22]=n,e[23]=j,e[24]=w,e[25]=l,e[26]=F):F=e[26];const _=F;let te;e[27]===Symbol.for("react.memo_cache_sentinel")?(te=Y=>u(Y.target.value.slice(0,wn)),e[27]=te):te=e[27];let H;e[28]!==l?(H=l("rightSidebar.contextNotesTodo.notes.placeholder"),e[28]=l,e[29]=H):H=e[29];let z;e[30]!==c.length?(z=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[c.length,"/",wn]}),e[30]=c.length,e[31]=z):z=e[31];let G;e[32]!==y?(G=()=>{y()},e[32]=y,e[33]=G):G=e[33];let U;e[34]!==c||e[35]!==o?(U=o||c.trim().length===0,e[34]=c,e[35]=o,e[36]=U):U=e[36];let q;e[37]!==l?(q=l("rightSidebar.contextNotesTodo.notes.addAria"),e[37]=l,e[38]=q):q=e[38];let T;e[39]!==l?(T=l("rightSidebar.contextNotesTodo.notes.addAria"),e[39]=l,e[40]=T):T=e[40];let V;e[41]===Symbol.for("react.memo_cache_sentinel")?(V=t.jsx(E,{name:"add",className:"h-4 w-4"}),e[41]=V):V=e[41];let L;e[42]!==G||e[43]!==U||e[44]!==q||e[45]!==T?(L=t.jsx("button",{type:"button",onClick:G,disabled:U,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-40","aria-label":q,title:T,children:V}),e[42]=G,e[43]=U,e[44]=q,e[45]=T,e[46]=L):L=e[46];let D;e[47]!==L||e[48]!==z?(D=t.jsxs(t.Fragment,{children:[z,L]}),e[47]=L,e[48]=z,e[49]=D):D=e[49];let K;e[50]!==c||e[51]!==o||e[52]!==p||e[53]!==f||e[54]!==D||e[55]!==H?(K=t.jsx(Gs,{value:c,onChange:te,placeholder:H,resizedHeight:p,onResizeHeightChange:f,useScrollShadow:!0,scrollShadowSize:56,disabled:o,endSlot:D}),e[50]=c,e[51]=o,e[52]=p,e[53]=f,e[54]=D,e[55]=H,e[56]=K):K=e[56];let re;e[57]!==m||e[58]!==O||e[59]!==_||e[60]!==B||e[61]!==i||e[62]!==a||e[63]!==l||e[64]!==A?(re=t.jsx("div",{children:A.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:a.trim()?l("rightSidebar.contextNotesTodo.search.noResults",{query:a.trim()}):l("rightSidebar.contextNotesTodo.notes.empty")}):t.jsx("ul",{className:"flex flex-col gap-1.5",children:A.map(Y=>t.jsx(Ld,{note:Y,pinned:i.has(Y.id),expanded:m===Y.id,onToggleExpanded:()=>g(oe=>oe===Y.id?null:Y.id),onSaveBody:oe=>_(Y.id,oe),onTogglePinned:()=>{B(Y.id,!i.has(Y.id))},onDelete:()=>{O(Y.id)}},Y.id))})}),e[57]=m,e[58]=O,e[59]=_,e[60]=B,e[61]=i,e[62]=a,e[63]=l,e[64]=A,e[65]=re):re=e[65];let X;return e[66]!==K||e[67]!==re?(X=t.jsxs("div",{className:"space-y-2",children:[K,re]}),e[66]=K,e[67]=re,e[68]=X):X=e[68],X};function Od(s){return s.notesPanelHeight}function $d(s){return s.setNotesPanelHeight}function Ud(s){return s.createNote}function Wd(s){return s.saveNoteBody}function _d(s){return s.deleteNote}const zd=({projectRef:s,plans:e,query:n,onOpenPlan:r,pinnedPlanIds:o,onTogglePinned:a})=>{const{t:i}=nt(),d=h.useRef(null),[l,c]=h.useState(!1),[u,m]=h.useState(null),g=Et(y=>y.createPlan),p=Et(y=>y.deletePlan),f=gs(y=>y.currentDirectory),b=Ue(y=>y.openContextPanelTab),w=h.useCallback(async y=>{if(!u){m(y);try{await p(s,y)||je.error(i("rightSidebar.contextNotesTodo.toast.deletePlanFailed"))}finally{m(null)}}},[u,s,p,i]),C=h.useCallback(async(y,S)=>{if(!y.trim()){je.error(i("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const O=_a(y,S||i("rightSidebar.contextNotesTodo.plan.defaultTitle"));if(!await g(s,{title:O.title,body:O.body})){je.error(i("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}je.success(i("rightSidebar.contextNotesTodo.toast.planImported"))},[g,s,i]),k=h.useCallback(async()=>{if(l)return;const y=await Ni({defaultPath:s.path,filters:[{name:"Plan files",extensions:["md","markdown","txt"]},{name:"All files",extensions:["*"]}]});if(y.success&&y.path){c(!0);try{const S=new URLSearchParams({path:y.path,allowOutsideWorkspace:"true"});y.outsideFileGrant&&S.set("outsideFileGrant",y.outsideFileGrant);const O=await Mt(`/api/fs/read?${S.toString()}`,{cache:"no-store"});if(!O.ok){je.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"));return}const W=await O.text(),B=y.path.split("/").pop()?.replace(/\.(md|markdown|txt)$/i,"").trim()||"";await C(W,B)}catch(S){const O=S instanceof Error?S.message:void 0;je.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),O?{description:O}:void 0)}finally{c(!1)}return}y.error==="Native file picker not available"&&d.current?.click()},[C,l,s.path,i]),A=h.useCallback(async y=>{if(y){c(!0);try{const S=await y.text(),O=y.name.replace(/\.(md|markdown|txt)$/i,"").trim();await C(S,O)}catch(S){const O=S instanceof Error?S.message:void 0;je.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),O?{description:O}:void 0)}finally{c(!1)}}},[C,i]),M=h.useCallback(async(y,S)=>{if(!await a(y,S)){const W=Et.getState().getEntry(s).error;je.error(i("rightSidebar.contextNotesTodo.toast.updatePlanFailed"),W?{description:W}:void 0)}},[a,s,i]),j=h.useMemo(()=>e.filter(y=>Hs([y.title],n)),[e,n]),N=h.useCallback(y=>{if(r){r({id:y.id,title:y.title,projectRef:s});return}const S=f?.trim()||s.path.trim();S&&b(S,{mode:"plan",projectPlanId:y.id,projectPlanRef:s,dedupeKey:`plan:${Fr(s)}:${y.id}`,label:y.title})},[f,r,b,s]);return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsx("input",{ref:d,type:"file",accept:".md,.markdown,.txt,text/markdown,text/plain",className:"hidden",onChange:y=>{const S=y.target.files?.[0]??null;A(S),y.currentTarget.value=""}}),t.jsx("button",{type:"button",onClick:k,disabled:l,className:"inline-flex h-6 w-6 items-center justify-center rounded-md border border-border/70 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":i("rightSidebar.contextNotesTodo.plans.importFromFile"),title:i("rightSidebar.contextNotesTodo.plans.importFromFile"),children:t.jsx(E,{name:"add",className:"h-3.5 w-3.5"})})]}),t.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:j.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:n.trim()?i("rightSidebar.contextNotesTodo.search.noResults",{query:n.trim()}):i("rightSidebar.contextNotesTodo.plans.empty")}):t.jsx("ul",{className:"divide-y divide-border/50",children:j.map(y=>t.jsxs("li",{className:"flex items-center gap-1.5 px-2.5 py-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>N(y),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:y.title}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:new Date(y.createdAt).toLocaleDateString(vr())})]}),t.jsx("button",{type:"button",onClick:()=>{M(y.id,!o.has(y.id))},className:le("inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",o.has(y.id)?"text-primary":"text-muted-foreground hover:text-foreground"),"aria-pressed":o.has(y.id),"aria-label":o.has(y.id)?i("rightSidebar.contextNotesTodo.notes.actions.unpin"):i("rightSidebar.contextNotesTodo.notes.actions.pin"),title:o.has(y.id)?i("rightSidebar.contextNotesTodo.notes.actions.unpin"):i("rightSidebar.contextNotesTodo.notes.actions.pin"),children:t.jsx(E,{name:"pushpin",className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button",onClick:()=>{w(y.id)},disabled:u===y.id,className:"inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",title:i("rightSidebar.contextNotesTodo.plans.deletePlan"),"aria-label":i("rightSidebar.contextNotesTodo.plans.deletePlanWithTitle",{title:y.title}),children:t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},y.id))})})]})},Vd=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`todo_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,Gd=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],fr=(s,e)=>{const n=s.findIndex(r=>r.completed);return n===-1?[...s,e]:[...s.slice(0,n),e,...s.slice(n)]},Hd=s=>{const e=We.c(20),{id:n,children:r}=s;let o;e[0]!==n?(o={id:n},e[0]=n,e[1]=o):o=e[1];const{attributes:a,listeners:i,setNodeRef:d,setActivatorNodeRef:l,transform:c,transition:u,isDragging:m}=Qr(o);let g;e[2]!==c?(g=Zr.Transform.toString(c),e[2]=c,e[3]=g):g=e[3];let p;e[4]!==g||e[5]!==u?(p={transform:g,transition:u},e[4]=g,e[5]=u,e[6]=p):p=e[6];const f=m&&"opacity-60";let b;e[7]!==f?(b=le(f),e[7]=f,e[8]=b):b=e[8];let w;e[9]!==a||e[10]!==r||e[11]!==m||e[12]!==i||e[13]!==l?(w=r({attributes:a,listeners:i,setActivatorNodeRef:l,isDragging:m}),e[9]=a,e[10]=r,e[11]=m,e[12]=i,e[13]=l,e[14]=w):w=e[14];let C;return e[15]!==d||e[16]!==p||e[17]!==b||e[18]!==w?(C=t.jsx("li",{ref:d,style:p,className:b,children:w}),e[15]=d,e[16]=p,e[17]=b,e[18]=w,e[19]=C):C=e[19],C},Kd=s=>{const e=We.c(82),{todos:n,query:r,disabled:o,canCreateWorktree:a,sendingTodoId:i,onPersistTodos:d,onSendToCurrentSession:l,onSendToNewSession:c,onSendToNewWorktreeSession:u}=s,{t:m}=nt(),[g,p]=h.useState(""),[f,b]=h.useState(qd);let w;e[0]!==g||e[1]!==d||e[2]!==n?(w=()=>{const v=g.trim();v&&(d(fr(n,{id:Vd(),text:v.slice(0,Es),completed:!1,createdAt:Date.now()})),p(""))},e[0]=g,e[1]=d,e[2]=n,e[3]=w):w=e[3];const C=w;let k;e[4]===Symbol.for("react.memo_cache_sentinel")?(k=v=>{b($=>{const J=new Set($);return J.has(v)?J.delete(v):J.add(v),J})},e[4]=k):k=e[4];const A=k;let M;e[5]!==d||e[6]!==n?(M=(v,$)=>{const J=n.find(ve=>ve.id===v);if(!J||J.completed===$)return;const he=n.filter(ve=>ve.id!==v),ie={...J,completed:$};d($?[...he,ie]:fr(he,ie))},e[5]=d,e[6]=n,e[7]=M):M=e[7];const j=M;let N;e[8]!==d||e[9]!==n?(N=v=>{d(n.filter($=>$.id!==v))},e[8]=d,e[9]=n,e[10]=N):N=e[10];const y=N;let S;e[11]!==d||e[12]!==n?(S=()=>{const v=n.filter(Yd);v.length!==n.length&&d(v)},e[11]=d,e[12]=n,e[13]=S):S=e[13];const O=S;let W;e[14]!==d||e[15]!==n?(W=v=>{const{active:$,over:J}=v;if(!J||$.id===J.id)return;const he=n.findIndex(ve=>ve.id===$.id),ie=n.findIndex(ve=>ve.id===J.id);he===-1||ie===-1||d(Gd(zi(n,he,ie)))},e[14]=d,e[15]=n,e[16]=W):W=e[16];const B=W;let F;e[17]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{distance:8}},e[17]=F):F=e[17];const _=Hr(Kr(qr,F));let te;e[18]!==g?(te=g.slice(0,Es),e[18]=g,e[19]=te):te=e[19];const H=te;let z;e[20]!==n?(z=n.reduce(Jd,0),e[20]=n,e[21]=z):z=e[21];const G=z;let U;if(e[22]!==r||e[23]!==n){let v;e[25]!==r?(v=$=>Hs([$.text],r),e[25]=r,e[26]=v):v=e[26],U=n.filter(v),e[22]=r,e[23]=n,e[24]=U}else U=e[24];const q=U,T=o||G===0;let V;e[27]!==m?(V=m("rightSidebar.contextNotesTodo.todo.clearCompleted"),e[27]=m,e[28]=V):V=e[28];let L;e[29]!==O||e[30]!==T||e[31]!==V?(L=t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{type:"button",onClick:O,disabled:T,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:V})}),e[29]=O,e[30]=T,e[31]=V,e[32]=L):L=e[32];let D;e[33]!==H.length?(D=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[H.length,"/",Es]}),e[33]=H.length,e[34]=D):D=e[34];let K;e[35]!==L||e[36]!==D?(K=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[L,D]}),e[35]=L,e[36]=D,e[37]=K):K=e[37];let re;e[38]===Symbol.for("react.memo_cache_sentinel")?(re=v=>p(v.target.value.slice(0,Es)),e[38]=re):re=e[38];let X;e[39]!==C?(X=v=>{v.key==="Enter"&&(v.preventDefault(),C())},e[39]=C,e[40]=X):X=e[40];let Y;e[41]!==m?(Y=m("rightSidebar.contextNotesTodo.todo.inputPlaceholder"),e[41]=m,e[42]=Y):Y=e[42];let oe;e[43]!==o||e[44]!==X||e[45]!==Y||e[46]!==H?(oe=t.jsx(yt,{value:H,onChange:re,onKeyDown:X,placeholder:Y,disabled:o,className:"h-8"}),e[43]=o,e[44]=X,e[45]=Y,e[46]=H,e[47]=oe):oe=e[47];let Z;e[48]!==o||e[49]!==H?(Z=o||H.trim().length===0,e[48]=o,e[49]=H,e[50]=Z):Z=e[50];let ee;e[51]!==m?(ee=m("rightSidebar.contextNotesTodo.todo.addAria"),e[51]=m,e[52]=ee):ee=e[52];let pe;e[53]!==m?(pe=m("rightSidebar.contextNotesTodo.todo.addAria"),e[53]=m,e[54]=pe):pe=e[54];let se;e[55]===Symbol.for("react.memo_cache_sentinel")?(se=t.jsx(E,{name:"add",className:"h-4 w-4"}),e[55]=se):se=e[55];let de;e[56]!==C||e[57]!==Z||e[58]!==ee||e[59]!==pe?(de=t.jsx("button",{type:"button",onClick:C,disabled:Z,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":ee,title:pe,children:se}),e[56]=C,e[57]=Z,e[58]=ee,e[59]=pe,e[60]=de):de=e[60];let Q;e[61]!==oe||e[62]!==de?(Q=t.jsxs("div",{className:"flex items-center gap-1.5",children:[oe,de]}),e[61]=oe,e[62]=de,e[63]=Q):Q=e[63];let ae;e[64]!==a||e[65]!==f||e[66]!==y||e[67]!==B||e[68]!==j||e[69]!==l||e[70]!==c||e[71]!==u||e[72]!==r||e[73]!==i||e[74]!==m||e[75]!==_||e[76]!==q?(ae=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:q.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:r.trim()?m("rightSidebar.contextNotesTodo.search.noResults",{query:r.trim()}):m("rightSidebar.contextNotesTodo.todo.empty")}):t.jsx(Yr,{sensors:_,collisionDetection:Jr,onDragEnd:B,children:t.jsx(Xr,{items:q.map(Qd),strategy:_i,children:t.jsx("ul",{className:"divide-y divide-border/50",children:q.map(v=>{const $=f.has(v.id);return t.jsx(Hd,{id:v.id,children:J=>t.jsxs("div",{className:le("flex gap-1.5 px-2.5 py-1.5",$?"items-start":"items-center"),children:[t.jsx("button",{type:"button",ref:J.setActivatorNodeRef,...J.attributes,...J.listeners,onClick:Xd,className:"flex h-6 w-4 flex-shrink-0 touch-none items-center justify-center text-muted-foreground hover:text-foreground","aria-label":m("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:v.text}),title:m("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:v.text}),children:t.jsx(E,{name:"draggable",className:"h-3.5 w-3.5"})}),t.jsx("div",{className:"flex h-6 items-center",children:t.jsx(Ts,{checked:v.completed,onChange:he=>j(v.id,he),ariaLabel:m("rightSidebar.contextNotesTodo.todo.actions.markComplete",{text:v.text})})}),t.jsx("button",{type:"button",onClick:()=>A(v.id),className:le("block min-h-6 min-w-0 flex-1 bg-transparent p-0 text-left typography-ui-label leading-normal text-foreground",$?"whitespace-normal break-words":"overflow-hidden text-ellipsis whitespace-nowrap","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",v.completed&&"text-muted-foreground line-through"),title:$?void 0:v.text,"aria-label":$?m("rightSidebar.contextNotesTodo.todo.actions.collapse",{text:v.text}):m("rightSidebar.contextNotesTodo.todo.actions.expand",{text:v.text}),children:v.text}),t.jsxs("div",{className:"flex h-6 items-center gap-0.5",children:[t.jsx("button",{type:"button",onClick:()=>y(v.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":m("rightSidebar.contextNotesTodo.todo.actions.delete",{text:v.text}),title:m("rightSidebar.contextNotesTodo.todo.actions.delete",{text:v.text}),children:t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})}),t.jsxs(zt,{children:[t.jsx(Vt,{asChild:!0,children:t.jsx("button",{type:"button",disabled:i===v.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":m("rightSidebar.contextNotesTodo.todo.actions.send",{text:v.text}),title:m("rightSidebar.contextNotesTodo.todo.actions.send",{text:v.text}),children:t.jsx(E,{name:"send-plane",className:"h-3.5 w-3.5"})})}),t.jsxs(Gt,{align:"end",className:"w-56",children:[t.jsx(At,{onClick:()=>l(v.text),children:m("rightSidebar.contextNotesTodo.todo.sendMenu.currentSession")}),t.jsx(At,{onClick:()=>c(v.id,v.text),children:m("rightSidebar.contextNotesTodo.todo.sendMenu.newSession")}),t.jsx(At,{onClick:()=>u(v.id,v.text),disabled:!a,children:m("rightSidebar.contextNotesTodo.todo.sendMenu.newWorktreeSession")})]})]})]})]})},v.id)})})})})}),e[64]=a,e[65]=f,e[66]=y,e[67]=B,e[68]=j,e[69]=l,e[70]=c,e[71]=u,e[72]=r,e[73]=i,e[74]=m,e[75]=_,e[76]=q,e[77]=ae):ae=e[77];let ue;return e[78]!==K||e[79]!==Q||e[80]!==ae?(ue=t.jsxs("div",{className:"space-y-2",children:[K,Q,ae]}),e[78]=K,e[79]=Q,e[80]=ae,e[81]=ue):ue=e[81],ue};function qd(){return new Set}function Yd(s){return!s.completed}function Jd(s,e){return s+(e.completed?1:0)}function Qd(s){return s.id}function Xd(s){s.preventDefault(),s.stopPropagation()}const Zd=s=>{const{projectRef:e,canCreateWorktree:n,onActionComplete:r}=s,{t:o}=nt(),[a,i]=h.useState(null),[d,l]=h.useState(!1),[c,u]=h.useState(null),m=st(S=>S.currentSessionId),g=st(S=>S.createSession),p=st(S=>S.initializeNewOpenChamberSession),f=st(S=>S.sendMessage),b=st(S=>S.setCurrentSession),w=za(S=>S.setPendingInputText),C=Ue(S=>S.setSessionSwitcherOpen),k=h.useCallback(()=>{C(!1)},[C]),A=h.useCallback(S=>{if(!m){je.error(o("rightSidebar.contextNotesTodo.toast.noActiveSession"));return}k();const O=`\`\`\`md
7
+ ${S}
8
+ \`\`\``;w(O,"append"),je.success(o("rightSidebar.contextNotesTodo.toast.sentToCurrentSession")),r?.()},[m,r,k,w,o]),M=h.useCallback((S,O)=>{!e||c||i({kind:"session",todoId:S,todoText:O})},[e,c]),j=h.useCallback((S,O)=>{if(!(!e||c)){if(!n){je.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}i({kind:"worktree",todoId:S,todoText:O})}},[n,e,c,o]),N=h.useCallback(async S=>{if(!e||!a)return;const O=await us("plan.todo.visible",{todo_text:a.todoText}),B=[{synthetic:!0,text:await us("plan.todo.instructions",{todo_text:a.todoText})}];l(!0),u(a.todoId);try{k();let F=null,_=e.path;if(a.kind==="worktree"){if(!n){je.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}const H=await Va(e.path,Ga());if(!H?.id)return;F=H.id,_=H.path}else{const H=await g(void 0,e.path,null);if(!H?.id){je.error(o("rightSidebar.contextNotesTodo.toast.createSessionFailed"));return}F=H.id,_=H.directory??e.path,p(H.id,Nt.getState().agents??[])}if(!F)return;const te=Ar.getState();te.saveSessionModelSelection(F,S.providerID,S.modelID),S.agent.trim()&&(te.saveSessionAgentSelection(F,S.agent),te.saveAgentModelForSession(F,S.agent,S.providerID,S.modelID),te.saveAgentModelVariantForSession(F,S.agent,S.providerID,S.modelID,S.variant||void 0)),b(F,_),await f(O,S.providerID,S.modelID,S.agent.trim()||void 0,void 0,void 0,B,S.variant||void 0),je.success(a.kind==="worktree"?o("rightSidebar.contextNotesTodo.toast.sentToNewWorktreeSession"):o("rightSidebar.contextNotesTodo.toast.sentToNewSession")),i(null),r?.()}catch(F){const _=F instanceof Error?F.message:void 0;je.error(o("rightSidebar.contextNotesTodo.toast.sendTodoFailed"),_?{description:_}:void 0)}finally{l(!1),u(null)}},[n,g,p,r,a,e,k,f,b,o]),y=h.useCallback(()=>{d||i(null)},[d]);return{pendingSendTarget:a,isSubmitting:d,sendingTodoId:c,sendToCurrentSession:A,sendToNewSession:M,sendToNewWorktreeSession:j,confirmSend:N,closeDialog:y}},eu=h.lazy(()=>Jt(()=>import("./PlanView-PkiOY_9H.js"),__vite__mapDeps([115,2,3,4,5,6,7,8,9,116,57,58,59,60,61,62,79,55,56,63,117,118,119,1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,120,121,113,114,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98])).then(s=>({default:s.PlanView}))),mr=["notes","todos","plans","memory"],tu=120,su=320,rn=s=>Math.min(su,Math.max(tu,Math.round(s))),nu=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],ys=(s,e)=>s.toLowerCase().includes(e),ru=s=>{const e=We.c(242),{projectRef:n,projectLabel:r,canCreateWorktree:o,onActionComplete:a,onOpenPlan:i,className:d}=s,l=o===void 0?!1:o,{t:c}=nt();let u;e[0]!==n?(u=Fr(n),e[0]=n,e[1]=u):u=e[1];const m=u;let g;e[2]!==m?(g=we=>(m?we.entries[m]:void 0)??Ha,e[2]=m,e[3]=g):g=e[3];const p=Et(g),f=Et(ou),b=Et(au),w=st(iu),C=st(lu),k=st(cu),A=st(du);let M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M={notes:[],plans:[]},e[4]=M):M=e[4];const[j,N]=h.useState(M);let y,S;e[5]!==C||e[6]!==w||e[7]!==k.open||e[8]!==k.projectContextPins?(y=()=>{if(k.open){N(k.projectContextPins??{notes:[],plans:[]});return}let we=!1;return Ka(C,w).then(Qe=>{we||N({notes:Qe.notes.map(uu),plans:Qe.plans.map(fu)})}),()=>{we=!0}},S=[C,w,k.open,k.projectContextPins],e[5]=C,e[6]=w,e[7]=k.open,e[8]=k.projectContextPins,e[9]=y,e[10]=S):(y=e[9],S=e[10]),h.useEffect(y,S);let O;e[11]!==C||e[12]!==w||e[13]!==k.open||e[14]!==A?(O=async(we,Qe,vt)=>{if(k.open)return A(we,Qe,vt),!0;if(!w||!C)return!1;const Ft=await qa(C,w,we,Qe,vt);return Ft?(N(Ft),!0):!1},e[11]=C,e[12]=w,e[13]=k.open,e[14]=A,e[15]=O):O=e[15];const W=O;let B;e[16]!==j.notes?(B=new Set(j.notes),e[16]=j.notes,e[17]=B):B=e[17];const F=B;let _;e[18]!==j.plans?(_=new Set(j.plans),e[18]=j.plans,e[19]=_):_=e[19];const te=_,H=Ue(mu),z=Dt(hu),G=H&&!z,U=Dt(pu);let q;e[20]!==n?.path?(q=we=>Lr(we,n?.path??null),e[20]=n?.path,e[21]=q):q=e[21];const T=Dt(q),V=Ue(gu),L=Ue(xu),D=Ue(bu);let K;e[22]!==L?(K=mr.includes(L)?L:"notes",e[22]=L,e[23]=K):K=e[23];const re=K,X=re==="memory"&&!G?"notes":re,[Y,oe]=h.useState(""),[Z,ee]=h.useState(null);let pe;e[24]!==Y?(pe=Y.trim().toLowerCase(),e[24]=Y,e[25]=pe):pe=e[25];const se=pe;let de;e[26]!==p.todos?(de=nu(p.todos),e[26]=p.todos,e[27]=de):de=e[27];const Q=de,ae=p.loading&&!p.loaded;let ue;e[28]!==U||e[29]!==T?(ue=[...U,...T],e[28]=U,e[29]=T,e[30]=ue):ue=e[30];const v=ue;let $;e:{if(!se){let mt;e[31]!==p.notes.length||e[32]!==p.plans.length||e[33]!==v.length||e[34]!==Q.length?(mt={notes:p.notes.length,todos:Q.length,plans:p.plans.length,memory:v.length},e[31]=p.notes.length,e[32]=p.plans.length,e[33]=v.length,e[34]=Q.length,e[35]=mt):mt=e[35],$=mt;break e}let we;if(e[36]!==p.notes||e[37]!==se){let mt;e[39]!==se?(mt=xs=>ys(xs.body,se),e[39]=se,e[40]=mt):mt=e[40],we=p.notes.filter(mt),e[36]=p.notes,e[37]=se,e[38]=we}else we=e[38];const Qe=we.length;let vt;if(e[41]!==Q||e[42]!==se){let mt;e[44]!==se?(mt=xs=>ys(xs.text,se),e[44]=se,e[45]=mt):mt=e[45],vt=Q.filter(mt),e[41]=Q,e[42]=se,e[43]=vt}else vt=e[43];const Ft=vt.length;let ls;if(e[46]!==p.plans||e[47]!==se){let mt;e[49]!==se?(mt=xs=>ys(xs.title,se),e[49]=se,e[50]=mt):mt=e[50],ls=p.plans.filter(mt),e[46]=p.plans,e[47]=se,e[48]=ls}else ls=e[48];const So=ls.length;let cs;e[51]!==v||e[52]!==se?(cs=v.filter(mt=>ys(mt.title,se)||ys(mt.body,se)),e[51]=v,e[52]=se,e[53]=cs):cs=e[53];let Ps;e[54]!==we.length||e[55]!==vt.length||e[56]!==ls.length||e[57]!==cs.length?(Ps={notes:Qe,todos:Ft,plans:So,memory:cs.length},e[54]=we.length,e[55]=vt.length,e[56]=ls.length,e[57]=cs.length,e[58]=Ps):Ps=e[58],$=Ps}const J=$,he=Ue(yu);let ie;e[59]!==n?.path?(ie=we=>we.agentMemoryViewedAt[An("project",n?.path??null)]??0,e[59]=n?.path,e[60]=ie):ie=e[60];const ve=Ue(ie),Ne=ur(U,he)+ur(T,ve),Ve=Ue(wu),Le=Ue(vu),[Ye,Xe]=h.useState(!1),[ze,Fe]=h.useState(null),Ge=ze??Ve;let Ae;e[61]!==Ge?(Ae=rn(Ge),e[61]=Ge,e[62]=Ae):Ae=e[62];const _e=Ae;let Oe;e[63]!==_e?(Oe=we=>{we.currentTarget.setPointerCapture(we.pointerId),Xe(!0),Fe(_e)},e[63]=_e,e[64]=Oe):Oe=e[64];const Ze=Oe;let at;e[65]===Symbol.for("react.memo_cache_sentinel")?(at=we=>{if(!we.currentTarget.hasPointerCapture(we.pointerId))return;const Qe=we.currentTarget.closest("nav")?.getBoundingClientRect().right??0;Fe(rn(Qe-we.clientX))},e[65]=at):at=e[65];const De=at;let Je;e[66]!==Le?(Je=we=>{we.currentTarget.hasPointerCapture(we.pointerId)&&we.currentTarget.releasePointerCapture(we.pointerId),Xe(!1),Fe(Qe=>(Qe!==null&&Le(rn(Qe)),null))},e[66]=Le,e[67]=Je):Je=e[67];const et=Je;let Ke;e[68]!==l||e[69]!==a||e[70]!==n?(Ke={projectRef:n,canCreateWorktree:l,onActionComplete:a},e[68]=l,e[69]=a,e[70]=n,e[71]=Ke):Ke=e[71];const ke=Zd(Ke);let rt,x;e[72]!==f||e[73]!==n?(rt=()=>{n&&f(n)},x=[f,n],e[72]=f,e[73]=n,e[74]=rt,e[75]=x):(rt=e[74],x=e[75]),h.useEffect(rt,x);const R=h.useRef(null);let be,fe;e[76]!==p.error||e[77]!==p.loaded||e[78]!==c?(be=()=>{if(!p.error){R.current=null;return}R.current!==p.error&&(R.current=p.error,p.loaded||je.error(c("rightSidebar.contextNotesTodo.toast.loadNotesFailed")))},fe=[p.error,p.loaded,c],e[76]=p.error,e[77]=p.loaded,e[78]=c,e[79]=be,e[80]=fe):(be=e[79],fe=e[80]),h.useEffect(be,fe);let Se;e[81]===Symbol.for("react.memo_cache_sentinel")?(Se=()=>{ee(null)},e[81]=Se):Se=e[81];let Be;e[82]!==m?(Be=[m],e[82]=m,e[83]=Be):Be=e[83],h.useEffect(Se,Be);let Re,qe;e[84]!==X?(Re=()=>{X!=="plans"&&ee(null)},qe=[X],e[84]=X,e[85]=Re,e[86]=qe):(Re=e[85],qe=e[86]),h.useEffect(Re,qe);let Ee;e[87]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>{oe("")},e[87]=Ee):Ee=e[87];let ft;e[88]!==m?(ft=[m],e[88]=m,e[89]=ft):ft=e[89],h.useEffect(Ee,ft);let ct,ut;e[90]!==X||e[91]!==J||e[92]!==D||e[93]!==se?(ct=()=>{if(!se||J[X]>0)return;const we=mr.find(Qe=>J[Qe]>0);we&&D(we)},ut=[X,J,D,se],e[90]=X,e[91]=J,e[92]=D,e[93]=se,e[94]=ct,e[95]=ut):(ct=e[94],ut=e[95]),h.useEffect(ct,ut);let it;e[96]!==n||e[97]!==b||e[98]!==c?(it=we=>{n&&b(n,we).then(Qe=>{Qe||je.error(c("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[96]=n,e[97]=b,e[98]=c,e[99]=it):it=e[99];const P=it;let me;e[100]!==c?(me=c("rightSidebar.contextNotesTodo.tabs.notes"),e[100]=c,e[101]=me):me=e[101];const Ie=String(J.notes);let Te;e[102]!==me||e[103]!==Ie?(Te={id:"notes",icon:"sticky-note",label:me,count:Ie},e[102]=me,e[103]=Ie,e[104]=Te):Te=e[104];let Me;e[105]!==c?(Me=c("rightSidebar.contextNotesTodo.tabs.todos"),e[105]=c,e[106]=Me):Me=e[106];const I=String(J.todos);let ne;e[107]!==Me||e[108]!==I?(ne={id:"todos",icon:"checkbox-circle",label:Me,count:I},e[107]=Me,e[108]=I,e[109]=ne):ne=e[109];let ge;e[110]!==c?(ge=c("rightSidebar.contextNotesTodo.tabs.plans"),e[110]=c,e[111]=ge):ge=e[111];const He=String(J.plans);let ye;e[112]!==ge||e[113]!==He?(ye={id:"plans",icon:"file-text",label:ge,count:He},e[112]=ge,e[113]=He,e[114]=ye):ye=e[114];let $e;e[115]!==J.memory||e[116]!==Ne||e[117]!==G||e[118]!==c?($e=G?[{id:"memory",icon:"brain-4",label:c("rightSidebar.contextNotesTodo.tabs.memory"),count:Ne>0?`${Ne}/${J.memory}`:String(J.memory)}]:[],e[115]=J.memory,e[116]=Ne,e[117]=G,e[118]=c,e[119]=$e):$e=e[119];let dt;e[120]!==Te||e[121]!==ne||e[122]!==ye||e[123]!==$e?(dt=[Te,ne,ye,...$e],e[120]=Te,e[121]=ne,e[122]=ye,e[123]=$e,e[124]=dt):dt=e[124];const Pe=dt;if(!n){let we;e[125]!==d?(we=le("w-full min-w-0 p-3",d),e[125]=d,e[126]=we):we=e[126];let Qe;e[127]!==c?(Qe=c("rightSidebar.contextNotesTodo.empty.selectProject"),e[127]=c,e[128]=Qe):Qe=e[128];let vt;e[129]!==Qe?(vt=t.jsx("p",{className:"typography-meta text-muted-foreground",children:Qe}),e[129]=Qe,e[130]=vt):vt=e[130];let Ft;return e[131]!==we||e[132]!==vt?(Ft=t.jsx("div",{className:we,children:vt}),e[131]=we,e[132]=vt,e[133]=Ft):Ft=e[133],Ft}let xe;e[134]!==r||e[135]!==n.path?(xe=r?.trim()||n.path.split("/").filter(Boolean).pop()||n.path,e[134]=r,e[135]=n.path,e[136]=xe):xe=e[136];const ot=xe;let lt;e[137]!==d?(lt=le("flex h-full min-h-0 w-full min-w-0 flex-col",d),e[137]=d,e[138]=lt):lt=e[138];let pt;e[139]!==Z||e[140]!==c?(pt=Z?t.jsx("button",{type:"button",onClick:()=>ee(null),className:"inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":c("rightSidebar.contextNotesTodo.plans.actions.back"),title:c("rightSidebar.contextNotesTodo.plans.actions.back"),children:t.jsx(E,{name:"arrow-left-s",className:"h-4 w-4"})}):null,e[139]=Z,e[140]=c,e[141]=pt):pt=e[141];let xt;e[142]!==n.path||e[143]!==ot?(xt=t.jsx("h3",{className:"min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",title:n.path,children:ot}),e[142]=n.path,e[143]=ot,e[144]=xt):xt=e[144];let St;e[145]===Symbol.for("react.memo_cache_sentinel")?(St=t.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e[145]=St):St=e[145];let kt;e[146]===Symbol.for("react.memo_cache_sentinel")?(kt=we=>oe(we.target.value),e[146]=kt):kt=e[146];let wt;e[147]!==c?(wt=c("rightSidebar.contextNotesTodo.search.placeholder"),e[147]=c,e[148]=wt):wt=e[148];let jt;e[149]!==Y||e[150]!==wt?(jt=t.jsx(yt,{value:Y,onChange:kt,placeholder:wt,className:"h-8 pl-7 pr-7"}),e[149]=Y,e[150]=wt,e[151]=jt):jt=e[151];let Ct;e[152]!==Y||e[153]!==c?(Ct=Y?t.jsx("button",{type:"button",onClick:()=>oe(""),className:"absolute right-1.5 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":c("rightSidebar.contextNotesTodo.search.clear"),title:c("rightSidebar.contextNotesTodo.search.clear"),children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null,e[152]=Y,e[153]=c,e[154]=Ct):Ct=e[154];let Rt;e[155]!==jt||e[156]!==Ct?(Rt=t.jsxs("div",{className:"relative w-40 flex-shrink-0",children:[St,jt,Ct]}),e[155]=jt,e[156]=Ct,e[157]=Rt):Rt=e[157];let _t;e[158]!==pt||e[159]!==xt||e[160]!==Rt?(_t=t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2 p-3 pb-2",children:[pt,xt,Rt]}),e[158]=pt,e[159]=xt,e[160]=Rt,e[161]=_t):_t=e[161];let Lt;e[162]!==X||e[163]!==V||e[164]!==Pe||e[165]!==D||e[166]!==c?(Lt=V?t.jsx("nav",{className:"flex flex-shrink-0 items-center gap-1.5 overflow-x-auto px-3 pb-2","aria-label":c("rightSidebar.contextNotesTodo.sections.label"),children:Pe.map(we=>{const Qe=X===we.id;return t.jsxs("button",{type:"button",onClick:()=>D(we.id),"aria-current":Qe?"page":void 0,className:le("flex flex-shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Qe?"border-transparent bg-interactive-active text-foreground":"border-[var(--interactive-border)] text-muted-foreground"),children:[t.jsx(E,{name:we.icon,className:"h-4 w-4 flex-shrink-0"}),Qe?t.jsx("span",{className:"whitespace-nowrap typography-meta",children:we.label}):null,t.jsx("span",{className:"typography-micro text-muted-foreground",children:we.count})]},we.id)})}):null,e[162]=X,e[163]=V,e[164]=Pe,e[165]=D,e[166]=c,e[167]=Lt):Lt=e[167];const Qt=Z?"overflow-hidden":"overflow-y-auto";let ht;e[168]!==Qt?(ht=le("min-h-0 min-w-0 flex-1 p-3",Qt),e[168]=Qt,e[169]=ht):ht=e[169];let Xt;e[170]!==X||e[171]!==p.notes||e[172]!==ae||e[173]!==F||e[174]!==n||e[175]!==Y||e[176]!==W?(Xt=X==="notes"?t.jsx(Fd,{projectRef:n,notes:p.notes,disabled:ae,query:Y,pinnedNoteIds:F,onTogglePinned:(we,Qe)=>W("note",we,Qe)}):null,e[170]=X,e[171]=p.notes,e[172]=ae,e[173]=F,e[174]=n,e[175]=Y,e[176]=W,e[177]=Xt):Xt=e[177];let Zt;e[178]!==X||e[179]!==l||e[180]!==P||e[181]!==ae||e[182]!==Y||e[183]!==ke.sendToCurrentSession||e[184]!==ke.sendToNewSession||e[185]!==ke.sendToNewWorktreeSession||e[186]!==ke.sendingTodoId||e[187]!==Q?(Zt=X==="todos"?t.jsx(Kd,{todos:Q,query:Y,disabled:ae,canCreateWorktree:l,sendingTodoId:ke.sendingTodoId,onPersistTodos:P,onSendToCurrentSession:ke.sendToCurrentSession,onSendToNewSession:ke.sendToNewSession,onSendToNewWorktreeSession:ke.sendToNewWorktreeSession}):null,e[178]=X,e[179]=l,e[180]=P,e[181]=ae,e[182]=Y,e[183]=ke.sendToCurrentSession,e[184]=ke.sendToNewSession,e[185]=ke.sendToNewWorktreeSession,e[186]=ke.sendingTodoId,e[187]=Q,e[188]=Zt):Zt=e[188];let es;e[189]!==X||e[190]!==G||e[191]!==n.path||e[192]!==Y?(es=X==="memory"&&G?t.jsx(Td,{projectPath:n.path,query:Y}):null,e[189]=X,e[190]=G,e[191]=n.path,e[192]=Y,e[193]=es):es=e[193];let ts;e[194]!==X||e[195]!==p.plans||e[196]!==i||e[197]!==Z||e[198]!==te||e[199]!==n||e[200]!==Y||e[201]!==W?(ts=X==="plans"&&!Z?t.jsx(zd,{projectRef:n,plans:p.plans,query:Y,pinnedPlanIds:te,onTogglePinned:(we,Qe)=>W("plan",we,Qe),onOpenPlan:i??ee}):null,e[194]=X,e[195]=p.plans,e[196]=i,e[197]=Z,e[198]=te,e[199]=n,e[200]=Y,e[201]=W,e[202]=ts):ts=e[202];let ss;e[203]!==X||e[204]!==Z||e[205]!==n?(ss=X==="plans"&&Z&&n?t.jsx(h.Suspense,{fallback:null,children:t.jsx(eu,{savedProjectPlan:{projectRef:n,planId:Z.id},onNavigatedToChat:()=>ee(null)})}):null,e[203]=X,e[204]=Z,e[205]=n,e[206]=ss):ss=e[206];let ns;e[207]!==ht||e[208]!==Xt||e[209]!==Zt||e[210]!==es||e[211]!==ts||e[212]!==ss?(ns=t.jsxs("div",{className:ht,children:[Xt,Zt,es,ts,ss]}),e[207]=ht,e[208]=Xt,e[209]=Zt,e[210]=es,e[211]=ts,e[212]=ss,e[213]=ns):ns=e[213];let rs;e[214]!==X||e[215]!==et||e[216]!==Ze||e[217]!==V||e[218]!==Ye||e[219]!==Pe||e[220]!==D||e[221]!==_e||e[222]!==c?(rs=V?null:t.jsxs("nav",{className:"relative flex flex-shrink-0 flex-col gap-0.5 overflow-y-auto border-l border-[var(--interactive-border)] p-2",style:{width:`${_e}px`},"aria-label":c("rightSidebar.contextNotesTodo.sections.label"),children:[t.jsx("div",{className:le("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",Ye&&"bg-[var(--interactive-border)]"),onPointerDown:Ze,onPointerMove:De,onPointerUp:et,onPointerCancel:et,role:"separator","aria-orientation":"vertical","aria-label":c("rightSidebar.contextNotesTodo.sections.resize")}),Pe.map(we=>{const Qe=X===we.id;return t.jsxs("button",{type:"button",onClick:()=>D(we.id),"aria-current":Qe?"page":void 0,className:le("flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Qe?"bg-interactive-active text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),style:{minHeight:0},children:[t.jsx(E,{name:we.icon,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:we.label}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:we.count})]},we.id)})]}),e[214]=X,e[215]=et,e[216]=Ze,e[217]=V,e[218]=Ye,e[219]=Pe,e[220]=D,e[221]=_e,e[222]=c,e[223]=rs):rs=e[223];let os;e[224]!==ns||e[225]!==rs?(os=t.jsxs("div",{className:"flex min-h-0 flex-1",children:[ns,rs]}),e[224]=ns,e[225]=rs,e[226]=os):os=e[226];const qs=ke.pendingSendTarget!==null;let as;e[227]!==ke?(as=we=>{we||ke.closeDialog()},e[227]=ke,e[228]=as):as=e[228];const Ys=ke.pendingSendTarget?.kind??"session";let is;e[229]!==n.path||e[230]!==ke.confirmSend||e[231]!==ke.isSubmitting||e[232]!==qs||e[233]!==as||e[234]!==Ys?(is=t.jsx(Il,{open:qs,onOpenChange:as,target:Ys,projectDirectory:n.path,submitting:ke.isSubmitting,onConfirm:ke.confirmSend}),e[229]=n.path,e[230]=ke.confirmSend,e[231]=ke.isSubmitting,e[232]=qs,e[233]=as,e[234]=Ys,e[235]=is):is=e[235];let Ds;return e[236]!==lt||e[237]!==_t||e[238]!==Lt||e[239]!==os||e[240]!==is?(Ds=t.jsxs("div",{className:lt,children:[_t,Lt,os,is]}),e[236]=lt,e[237]=_t,e[238]=Lt,e[239]=os,e[240]=is,e[241]=Ds):Ds=e[241],Ds};function ou(s){return s.load}function au(s){return s.saveTodos}function iu(s){return s.currentSessionId}function lu(s){return s.currentSessionDirectory}function cu(s){return s.newSessionDraft}function du(s){return s.setDraftProjectContextPin}function uu(s){return s.id}function fu(s){return s.id}function mu(s){return s.agentMemoryFeatureAvailable&&s.agentMemoryToolEnabled}function hu(s){return s.disabled}function pu(s){return s.global}function gu(s){return s.isMobile}function xu(s){return s.projectContextTab}function bu(s){return s.setProjectContextTab}function yu(s){return s.agentMemoryViewedAt[An("global",null)]??0}function wu(s){return s.projectContextSidebarWidth}function vu(s){return s.setProjectContextSidebarWidth}const Su=({projects:s,worktreesByProject:e,directory:n,activeProjectId:r,chatDraftOpen:o,chatDraftTarget:a,homeDirectory:i})=>{const d=Ya(n)??Ja(i),l=Sn(n),c=Sn(d);if((o?a==="chat":!!(l&&c&&(l===c||l.startsWith(`${c}/`))))&&d)return{id:vn,path:d};const m=Qa(s,e,n);if(m)return{id:m.id,path:m.path};if(l)return null;const g=s.find(p=>p.id===r)??null;return g?{id:g.id,path:g.path}:null},ju=s=>{const e=We.c(8),n=It(Nu),r=It(ku),o=gs(Iu),a=st(Cu),i=st(Tu),d=st(Du);let l;return e[0]!==r||e[1]!==i||e[2]!==d||e[3]!==s||e[4]!==o||e[5]!==n||e[6]!==a?(l=Su({projects:n,worktreesByProject:a,directory:s,activeProjectId:r,chatDraftOpen:i,chatDraftTarget:d,homeDirectory:o}),e[0]=r,e[1]=i,e[2]=d,e[3]=s,e[4]=o,e[5]=n,e[6]=a,e[7]=l):l=e[7],l};function Nu(s){return s.projects}function ku(s){return s.activeProjectId}function Iu(s){return s.homeDirectory}function Cu(s){return s.availableWorktreesByProject}function Tu(s){return s.newSessionDraft.open}function Du(s){return s.newSessionDraft.target}const zf=s=>{const e=We.c(18),{onActionComplete:n,onOpenPlan:r}=s,o=gs(Pu),{t:a}=nt(),i=Pn(Eu),d=st(Ru),l=ju(d),c=It(Au);let u;e[0]!==l||e[1]!==c?(u=l?c.find(C=>C.id===l.id)??null:null,e[0]=l,e[1]=c,e[2]=u):u=e[2];const m=u;let g;e:{if(!l){g=null;break e}if(l.id===vn){let k;e[3]!==a?(k=a("sessions.sidebar.activity.chatsTitle"),e[3]=a,e[4]=k):k=e[4],g=k;break e}let C;e[5]!==o||e[6]!==m?.label||e[7]!==l.path?(C=m?.label?.trim()||Xa(l.path,o)||l.path,e[5]=o,e[6]=m?.label,e[7]=l.path,e[8]=C):C=e[8],g=C}const p=g;let f;e:{if(!l||l.id===vn){f=!1;break e}let C;e[9]!==i||e[10]!==l.path?(C=i.get(l.path)?.isGitRepo,e[9]=i,e[10]=l.path,e[11]=C):C=e[11],f=C===!0}const b=f;let w;return e[12]!==b||e[13]!==n||e[14]!==r||e[15]!==p||e[16]!==l?(w=t.jsx("div",{className:"h-full min-h-0 overflow-hidden bg-background",children:t.jsx(ru,{projectRef:l,projectLabel:p,canCreateWorktree:b,onActionComplete:n,onOpenPlan:r})}),e[12]=b,e[13]=n,e[14]=r,e[15]=p,e[16]=l,e[17]=w):w=e[17],w};function Pu(s){return s.homeDirectory}function Eu(s){return s.directories}function Ru(s){return s.currentSessionDirectory}function Au(s){return s.projects}const Fs=Object.freeze({chunks:Object.freeze([]),byteLength:0,lastSequence:-1}),In=512*1024,Bu=new TextEncoder,Mu=new TextDecoder,on=s=>{const e=Bu.encode(s);if(e.byteLength<=In)return{text:s,byteLength:e.byteLength};let n=e.byteLength-In;for(;n<e.byteLength&&(e[n]&192)===128;)n+=1;const r=e.subarray(n);return{text:Mu.decode(r),byteLength:r.byteLength}},Ht=(s,e)=>`${s}\0${e}`,an=(s,e)=>{let n=null;for(const r of s.keys())e(r)&&(n??=new Map(s),n.delete(r));return n},Lu="terminal-store";let hr=!1,pr=0;const Bs=()=>typeof globalThis.crypto?.randomUUID=="function"?`tab-${globalThis.crypto.randomUUID()}`:(pr+=1,`tab-${Date.now().toString(36)}-${pr.toString(36)}`),ln=s=>typeof s=="object"&&s!==null,Fu=s=>{const e=/^tab-(\d+)$/.exec(s);if(!e)return null;const n=Number(e[1]);return Number.isFinite(n)?n:null};function gt(s){let e=s.trim();for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e}const Ou=/^Terminal(?: (\d+))?$/,gr=s=>{let e=0;for(const n of s){const r=Ou.exec(n.label);if(!r)continue;const o=r[1]?Number.parseInt(r[1],10):1;Number.isSafeInteger(o)&&(e=Math.max(e,o))}return e===0?"Terminal":`Terminal ${e+1}`},Ms=(s,e)=>({id:s,terminalSessionId:null,lifecycle:"idle",label:e,iconKey:null,isConnecting:!1,createdAt:Date.now(),previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1}),cn=s=>({tabs:[s],activeTabId:s.id}),Tt=(s,e)=>s.tabs.findIndex(n=>n.id===e);let dn=null,un=null;const $u=s=>{if(un&&dn?.sessions===s.sessions&&dn.nextTabId===s.nextTabId)return un;const e={sessions:Array.from(s.sessions.entries()).map(([n,r])=>[n,{activeTabId:r.activeTabId,tabs:r.tabs.map(o=>({id:o.id,label:o.label,iconKey:o.iconKey,createdAt:o.createdAt}))}]),nextTabId:s.nextTabId};return dn={sessions:s.sessions,nextTabId:s.nextTabId},un=e,e},Uu=()=>{const s=$i(()=>ki());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))}},tt=Ks()(zr(Vr((s,e)=>({sessions:new Map,buffers:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1,hasHydrated:typeof window>"u",ensureDirectory:n=>{const r=gt(n);r&&s(o=>{if(o.sessions.has(r))return o;const a=new Map(o.sessions),i=Bs(),d=Ms(i,"Terminal");return a.set(r,cn(d)),{sessions:a,nextTabId:o.nextTabId+1}})},getDirectoryState:n=>{const r=gt(n);return e().sessions.get(r)},getActiveTab:n=>{const r=gt(n),o=e().sessions.get(r);if(!o)return;const a=o.activeTabId;return a?o.tabs.find(i=>i.id===a)??o.tabs[0]:o.tabs[0]},getBuffer:(n,r)=>e().buffers.get(Ht(gt(n),r))??Fs,createTab:n=>{const r=gt(n);if(!r)return"tab-invalid";const o=Bs();return s(a=>{const i=new Map(a.sessions),d=i.get(r),l=a.nextTabId+1,c=gr(d?.tabs??[]),u=Ms(o,c);return d?i.set(r,{...d,tabs:[...d.tabs,u]}):i.set(r,cn(u)),{sessions:i,nextTabId:l}}),o},adoptServerSessions:(n,r)=>{const o=gt(n);!o||r.length===0||s(a=>{const i=a.sessions.get(o),d=new Set;for(const f of i?.tabs??[])d.add(f.id),f.terminalSessionId&&d.add(f.terminalSessionId);const l=r.filter(f=>!d.has(f.sessionId));if(l.length===0)return a;const c=[...i?.tabs??[]],u=c.length===1&&c[0].terminalSessionId===null&&c[0].lifecycle==="idle"&&!a.buffers.has(Ht(o,c[0].id))?c[0]:null;u&&(c.length=0);for(const f of l){const b={...Ms(f.sessionId,u&&c.length===0?u.label:gr(c)),terminalSessionId:f.sessionId,lifecycle:f.status,createdAt:f.createdAt??Date.now()};c.push(b)}const m=i?.activeTabId??null,g=m&&c.some(f=>f.id===m)?m:c[0]?.id??null,p=new Map(a.sessions);return p.set(o,{tabs:c,activeTabId:g}),{sessions:p}})},setActiveTab:(n,r)=>{const o=gt(n);s(a=>{const i=new Map(a.sessions),d=i.get(o);return!d||d.activeTabId===r||Tt(d,r)<0?a:(i.set(o,{...d,activeTabId:r}),{sessions:i})})},setTabLabel:(n,r,o)=>{const a=gt(n),i=o.trim();i&&s(d=>{const l=new Map(d.sessions),c=l.get(a);if(!c)return d;const u=Tt(c,r);if(u<0||c.tabs[u]?.label===i)return d;const m=[...c.tabs];return m[u]={...m[u],label:i},l.set(a,{...c,tabs:m}),{sessions:l}})},setTabIconKey:(n,r,o)=>{const a=gt(n);s(i=>{const d=new Map(i.sessions),l=d.get(a);if(!l)return i;const c=Tt(l,r);if(c<0)return i;const u=o?.trim()||null;if(l.tabs[c]?.iconKey===u)return i;const m=[...l.tabs];return m[c]={...m[c],iconKey:u},d.set(a,{...l,tabs:m}),{sessions:d}})},closeTab:(n,r)=>{const o=gt(n);s(a=>{const i=new Map(a.sessions),d=i.get(o);if(!d)return a;const l=Tt(d,r);if(l<0)return a;const c=d.tabs.filter(b=>b.id!==r),u=Object.fromEntries(Object.entries(a.projectActionRuns).filter(([,b])=>!(b.directory===o&&b.tabId===r))),m=Object.keys(u).length!==Object.keys(a.projectActionRuns).length,g=Ht(o,r),p=a.buffers.has(g)?an(a.buffers,b=>b===g):null;if(c.length===0){const b=Bs(),w=Ms(b,"Terminal");return i.set(o,cn(w)),{sessions:i,nextTabId:a.nextTabId+1,...p?{buffers:p}:{},...m?{projectActionRuns:u}:{}}}let f=d.activeTabId;return d.activeTabId===r&&(f=c[Math.min(l,c.length-1)]?.id??c[0]?.id??null),i.set(o,{...d,tabs:c,activeTabId:f}),{sessions:i,...p?{buffers:p}:{},...m?{projectActionRuns:u}:{}}})},setTabSessionId:(n,r,o)=>{const a=gt(n);s(i=>{const d=new Map(i.sessions),l=d.get(a);if(!l)return i;const c=Tt(l,r);if(c<0)return i;const u=l.tabs[c],m=o!==null&&u.terminalSessionId!==o,g=o?"running":u.terminalSessionId?"exited":u.lifecycle,p={...u,terminalSessionId:o,lifecycle:g,isConnecting:!1},f=Ht(a,r),b=m&&i.buffers.has(f)?an(i.buffers,C=>C===f):null,w=[...l.tabs];return w[c]=p,d.set(a,{...l,tabs:w}),{sessions:d,...b?{buffers:b}:{}}})},setTabLifecycle:(n,r,o)=>{const a=gt(n);s(i=>{const d=new Map(i.sessions),l=d.get(a);if(!l)return i;const c=Tt(l,r);if(c<0)return i;const u=[...l.tabs];return u[c]={...u[c],lifecycle:o,isConnecting:!1},d.set(a,{...l,tabs:u}),{sessions:d}})},setConnecting:(n,r,o)=>{const a=gt(n);s(i=>{const d=new Map(i.sessions),l=d.get(a);if(!l)return i;const c=Tt(l,r);if(c<0)return i;const u=[...l.tabs];return u[c]={...u[c],isConnecting:o},d.set(a,{...l,tabs:u}),{sessions:d}})},replaceBuffer:(n,r,o,a)=>{const i=gt(n);s(d=>{const l=d.sessions.get(i);if(!l||Tt(l,r)<0)return d;const c=Ht(i,r),u=d.buffers.get(c)??Fs;if(u.lastSequence>a)return d;const m=on(o);if(u.lastSequence===a&&u.byteLength===m.byteLength&&u.chunks.map(f=>f.data).join("")===m.text)return d;const g=d.nextChunkId,p=new Map(d.buffers);return p.set(c,{chunks:m.text?[{id:g,data:m.text,byteLength:m.byteLength}]:[],byteLength:m.byteLength,lastSequence:a}),{buffers:p,nextChunkId:m.text?g+1:g}})},appendToBuffer:(n,r,o,a,i)=>{if(!o)return;const d=gt(n);s(l=>{const c=l.sessions.get(d);if(!c||Tt(c,r)<0)return l;const u=Ht(d,r),m=l.buffers.get(u)??Fs;if(a!==void 0&&a<=m.lastSequence)return l;const g=l.nextChunkId,p=on(o),f=i!==void 0&&i!==o?on(i).text:void 0,b={id:g,data:p.text,...f!==void 0?{replayData:f}:{},byteLength:p.byteLength},w=[...m.chunks,b];let C=m.byteLength+b.byteLength;for(;C>In&&w.length>1;){const A=w.shift();if(!A)break;C-=A.byteLength}const k=new Map(l.buffers);return k.set(u,{chunks:w,byteLength:C,lastSequence:a??m.lastSequence}),{buffers:k,nextChunkId:g+1}})},setTabPreviewUrl:(n,r,o,a={})=>{const i=gt(n);s(d=>{const l=new Map(d.sessions),c=l.get(i);if(!c)return d;const u=Tt(c,r);if(u<0)return d;const m=c.tabs[u],g=a.autoOpened??m.previewAutoOpened,p=a.locked??m.previewUrlLocked;if(m.previewUrl===o&&m.previewAutoOpened===g&&m.previewUrlLocked===p)return d;const f=[...c.tabs];return f[u]={...m,previewUrl:o,previewAutoOpened:g,previewUrlLocked:p},l.set(i,{...c,tabs:f}),{sessions:l}})},markPreviewAutoOpened:(n,r)=>{const o=gt(n);s(a=>{const i=new Map(a.sessions),d=i.get(o);if(!d)return a;const l=Tt(d,r);if(l<0)return a;const c=d.tabs[l];if(!c.previewUrl||c.previewAutoOpened)return a;const u=[...d.tabs];return u[l]={...c,previewAutoOpened:!0},i.set(o,{...d,tabs:u}),{sessions:i}})},setProjectActionRun:n=>{s(r=>{const o=r.projectActionRuns[n.key];return o&&o.directory===n.directory&&o.actionId===n.actionId&&o.tabId===n.tabId&&o.sessionId===n.sessionId&&o.status===n.status?r:{projectActionRuns:{...r.projectActionRuns,[n.key]:n}}})},updateProjectActionRunStatus:(n,r)=>{s(o=>{const a=o.projectActionRuns[n];return!a||a.status===r?o:{projectActionRuns:{...o.projectActionRuns,[n]:{...a,status:r}}}})},removeProjectActionRun:n=>{s(r=>{if(!r.projectActionRuns[n])return r;const o={...r.projectActionRuns};return delete o[n],{projectActionRuns:o}})},removeDirectory:n=>{const r=gt(n);s(o=>{const a=new Map(o.sessions);a.delete(r);const i=Ht(r,""),d=an(o.buffers,c=>c.startsWith(i)),l=Object.fromEntries(Object.entries(o.projectActionRuns).filter(([,c])=>c.directory!==r));return{sessions:a,...d?{buffers:d}:{},projectActionRuns:l}})},clearAll:()=>{s({sessions:new Map,buffers:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1})}}),{name:Lu,storage:Uu(),partialize:$u,merge:(s,e)=>{if(!ln(s))return e;const n=Array.isArray(s.sessions)?s.sessions:[],r=new Map;let o=0;for(const d of n){if(!Array.isArray(d)||d.length!==2)continue;const[l,c]=d;if(typeof l!="string"||!ln(c))continue;const u=Array.isArray(c.tabs)?c.tabs:[],m=[],g=new Map;for(const w of u){if(!ln(w))continue;const C=typeof w.id=="string"?w.id:null;if(!C)continue;const k=Fu(C);k!==null&&(o=Math.max(o,k));const A=k===null?C:Bs();g.set(C,A),m.push({id:A,label:typeof w.label=="string"?w.label:"Terminal",iconKey:typeof w.iconKey=="string"?w.iconKey:null,terminalSessionId:null,lifecycle:"idle",createdAt:typeof w.createdAt=="number"?w.createdAt:Date.now(),isConnecting:!1,previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1})}if(m.length===0)continue;const p=typeof c.activeTabId=="string"?c.activeTabId:null,f=p?g.get(p)??p:null,b=f?m.some(w=>w.id===f):!1;r.set(l,{tabs:m,activeTabId:b?f:m[0].id})}const a=typeof s.nextTabId=="number"&&Number.isFinite(s.nextTabId)?s.nextTabId:1,i=Math.max(e.nextTabId,a,o+1);return{...e,sessions:r,buffers:new Map,nextChunkId:1,nextTabId:i,hasHydrated:!0}}})));if(typeof window<"u"&&!hr){hr=!0;const s=tt.persist,e=()=>{tt.getState().hasHydrated||tt.setState({hasHydrated:!0})};s?.hasHydrated?.()?e():s?.onFinishHydration?s.onFinishHydration(e):e()}function Wu(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 _u(s,e,n,r,o=!1){const i=`${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:i,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:o}}const fn=["\x1B[0m","\x1B[m"],zu=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 a=n.length<=4?n.slice(0,3).split("").map(i=>i+i).join(""):n.slice(0,6);return[Number.parseInt(a.slice(0,2),16),Number.parseInt(a.slice(2,4),16),Number.parseInt(a.slice(4,6),16)]}const r=/^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})(?:\s*[,/]\s*[\d.]+)?\s*\)$/i.exec(e);if(!r)return null;const o=r.slice(1,4).map(Number);return o.some(a=>a<0||a>255)?null:o},xr=s=>{const e=zu(s);return e?`\x1B[0;48;2;${e[0]};${e[1]};${e[2]}m`:null},Vu=(s,e,n)=>{const r=e+s;if(!n)return{data:r,carry:""};let o=0;const a=Math.max(...fn.map(l=>l.length))-1;for(let l=1;l<=Math.min(a,r.length);l+=1){const c=r.slice(-l);fn.some(u=>u.length>c.length&&u.startsWith(c))&&(o=l)}const i=o>0?r.slice(-o):"";let d=o>0?r.slice(0,-o):r;for(const l of fn)d=d.replaceAll(l,n);return{data:d,carry:i}},Gu=(s,e,n,r,o)=>{if(n.width<=0||n.height<=0||r<=0||o<=0)return null;const a=Math.floor((s-n.left)/n.width*r),i=Math.floor((e-n.top)/n.height*o);return{column:Math.max(0,Math.min(r-1,a)),row:Math.max(0,Math.min(o-1,i))}},Hu=(s,e)=>{const n=Math.max(0,Math.min(s.length-1,e)),r=i=>!!(i&&!/^\s+$/u.test(i));if(!r(s[n]))return{startColumn:n,endColumn:n};let o=n,a=n;for(;o>0&&r(s[o-1]);)o-=1;for(;a<s.length-1&&r(s[a+1]);)a+=1;return{startColumn:o,endColumn:a}};let Ku=null;const qu=()=>Ku??=Jt(()=>import("./vendor-ghostty-web-CrxinGGH.js"),__vite__mapDeps([122,5])).then(async s=>({module:s,ghostty:await s.Ghostty.load()})),Yu=2e3,Ju=()=>{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,Yu))]).then(()=>{})},Qu=(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 o=r.measureText("M"),a=Math.ceil(o.width),i=Math.ceil((o.actualBoundingBoxAscent||n*.8)+(o.actualBoundingBoxDescent||n*.2))+2;if(a<1||i<1)return null;const d=window.getComputedStyle(s),l=(Number.parseInt(d.paddingLeft,10)||0)+(Number.parseInt(d.paddingRight,10)||0),c=(Number.parseInt(d.paddingTop,10)||0)+(Number.parseInt(d.paddingBottom,10)||0);return{cols:Math.max(2,Math.floor((s.clientWidth-l-15)/a)),rows:Math.max(1,Math.floor((s.clientHeight-c)/i))}},xo=h.forwardRef(({sessionKey:s,chunks:e,onInput:n,onResize:r,theme:o,fontFamily:a,fontSize:i,className:d,enableTouchScroll:l=!1,autoFocus:c=!0,isVisible:u=!0},m)=>{const g=h.useRef(null),p=h.useRef(null),f=h.useRef(null),b=h.useRef(n),w=h.useRef(r),C=h.useRef(null),k=h.useRef(null),A=h.useRef(null),M=h.useRef(""),j=h.useRef(""),N=h.useRef(xr(o.background)),y=h.useRef(!1),S=h.useRef(0),O=h.useRef(u),W=h.useRef(!1),[B,F]=h.useState(0),[_,te]=h.useState(0);b.current=n,w.current=r,O.current=u,N.current=xr(o.background),h.useLayoutEffect(()=>{const U=g.current;if(!U)return;const q=Qu(U,a,i);k.current=q,q&&w.current(q.cols,q.rows)},[a,i]);const H=h.useCallback(()=>{const U=g.current,q=p.current;if(!U||!q||!f.current||!O.current)return;const T=U.getBoundingClientRect();if(!(T.width<24||T.height<24))try{f.current.fit();const V={cols:q.cols,rows:q.rows};(!C.current||C.current.cols!==V.cols||C.current.rows!==V.rows)&&(C.current=V,w.current(V.cols,V.rows)),W.current||(W.current=!0,F(L=>L+1))}catch{}},[]),z=h.useCallback(()=>{if(y.current||!M.current||!p.current)return;const U=p.current,q=M.current;M.current="";const T=Vu(q,j.current,N.current);if(j.current=T.carry,!T.data){M.current&&z();return}y.current=!0;const V=S.current;U.write(T.data,()=>{p.current!==U||S.current!==V||(y.current=!1,M.current&&z())})},[]),G=h.useCallback(()=>{A.current=null,M.current="",j.current="",y.current=!1,S.current+=1;const U=p.current;if(!U){te(q=>q+1);return}try{U.reset();const q=N.current;q&&U.write(`${q}\x1B[2J\x1B[H`)}catch{te(q=>q+1)}},[]);return h.useEffect(()=>{const U=g.current;if(!U)return;let q=!1,T=null,V=null,L=null,D=null,K=[];const re=()=>{T&&O.current&&(T.options.cursorBlink=!0)},X=Z=>{Z.relatedTarget instanceof Node&&U.contains(Z.relatedTarget)||T&&(T.options.cursorBlink=!1)},Y=()=>{T&&O.current&&U.contains(document.activeElement)&&(T.options.cursorBlink=!0)},oe=()=>{T&&(T.options.cursorBlink=!1)};return U.addEventListener("focusin",re),U.addEventListener("focusout",X),window.addEventListener("focus",Y),window.addEventListener("blur",oe),Promise.all([qu(),Ju()]).then(([{module:Z,ghostty:ee}])=>{if(q)return;T=new Z.Terminal({..._u(a,i,o,ee,!1),...k.current??{}});const pe=new Z.FitAddon;T.loadAddon(pe),T.open(U),U.setAttribute("autocapitalize","off"),U.setAttribute("autocorrect","off"),U.setAttribute("spellcheck","false"),p.current=T,f.current=pe,K=[T.onData(de=>b.current(de))],V=new ResizeObserver(()=>{L&&clearTimeout(L),L=setTimeout(H,80)}),V.observe(U),H();const se=N.current;se&&T.write(`${se}\x1B[2J\x1B[H`),D=requestAnimationFrame(H)}),()=>{q=!0;const Z=document.activeElement;Z instanceof HTMLElement&&U.contains(Z)&&(Z.blur(),window.Capacitor?.getPlatform?.()==="android"&&Jt(async()=>{const{Keyboard:pe}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:pe}},__vite__mapDeps([123,124])).then(({Keyboard:pe})=>pe.hide()).catch(()=>{})),V?.disconnect(),L&&clearTimeout(L),D!==null&&cancelAnimationFrame(D),U.removeEventListener("focusin",re),U.removeEventListener("focusout",X),window.removeEventListener("focus",Y),window.removeEventListener("blur",oe),K.forEach(ee=>ee.dispose()),T?.dispose(),p.current=null,f.current=null,C.current=null,A.current=null,M.current="",j.current="",y.current=!1,S.current+=1,W.current=!1}},[H,a,i,_,o]),h.useEffect(()=>{const U=p.current,q=g.current;!U||!q||(U.options.cursorBlink=u&&document.hasFocus()&&q.contains(document.activeElement))},[u,B]),h.useEffect(()=>{if(!p.current)return;if(e.length===0){A.current!==null&&G();return}const q=A.current;let T=-1;if(q!==null){for(let D=e.length-1;D>=0;D-=1){const K=e[D].id;if(K===q){T=D;break}if(K<q)break}if(T<0){G();return}}const V=T<0,L=T>=0?e.slice(T+1):e;M.current+=L.map(D=>V?D.replayData??D.data:D.data).join(""),A.current=e.at(-1)?.id??null,z()},[e,z,B,G]),h.useEffect(()=>{if(!c||!u)return;const U=requestAnimationFrame(()=>p.current?.focus());return()=>cancelAnimationFrame(U)},[c,u,B,s]),h.useEffect(()=>{const U=g.current;if(!l||!U)return;const q=T=>{const V=T;if(!V.isComposing)switch(V.inputType){case"insertText":V.data&&b.current(V.data);break;case"insertLineBreak":case"insertParagraph":b.current("\r");break;case"deleteContentBackward":b.current("");break}};return U.addEventListener("beforeinput",q),()=>U.removeEventListener("beforeinput",q)},[l,B]),h.useEffect(()=>{const U=g.current,q=p.current;if(!l||!U||!q)return;let T=null,V=null,L="idle",D=0,K=0,re=0,X=0,Y=null;const oe=Math.max(12,i+2),Z=()=>{window.Capacitor?.getPlatform?.()==="android"&&Jt(async()=>{const{Keyboard:J}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:J}},__vite__mapDeps([123,124])).then(({Keyboard:J})=>J.show()).catch(()=>{})},ee=()=>{V&&(clearTimeout(V),V=null)},pe=($,J)=>{const he=U.querySelector("canvas");return he?Gu($,J,he.getBoundingClientRect(),q.cols,q.rows):null},se=($,J)=>{const he=U.querySelector("canvas");if(!he)return;const ie=he.getBoundingClientRect(),ve=ie.left+(J.column+.5)/q.cols*ie.width,Ne=ie.top+(J.row+.5)/q.rows*ie.height;he.dispatchEvent(new MouseEvent($,{bubbles:!0,cancelable:!0,button:0,buttons:1,clientX:ve,clientY:Ne}))},de=()=>{document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0,buttons:0}))},Q=$=>{$.pointerType!=="touch"||T!==null||(T=$.pointerId,L="pending",D=$.clientX,K=$.clientY,re=$.clientY,X=0,Y=null,U.setPointerCapture($.pointerId),V=setTimeout(()=>{if(V=null,T!==$.pointerId||L!=="pending")return;const J=pe(D,K);if(!J)return;const he=q.buffer.active,ie=Math.max(0,he.length-q.rows-he.viewportY+J.row),ve=he.getLine(ie),Ne=Array.from({length:q.cols},(Ye,Xe)=>ve?.getCell(Xe)?.getChars()??""),Ve=Hu(Ne,J.column),Le={column:Ve.startColumn,row:J.row};Y={column:Ve.endColumn,row:J.row},L="selecting",se("mousedown",Le),se("mousemove",Y)},350))},ae=$=>{if(T!==$.pointerId)return;if(L==="selecting"){const ie=pe($.clientX,$.clientY);ie&&(!Y||ie.column!==Y.column||ie.row!==Y.row)&&(Y=ie,se("mousemove",ie)),$.cancelable&&$.preventDefault();return}if(L==="pending"){if(Math.hypot($.clientX-D,$.clientY-K)<8)return;ee(),L="scrolling"}if(L!=="scrolling")return;const J=re-$.clientY;re=$.clientY,X+=J;const he=Math.trunc(X/oe);he&&(q.scrollLines(he),X-=he*oe),$.cancelable&&$.preventDefault()},ue=$=>{if(T!==$.pointerId)return;const J=L==="pending",he=L==="selecting";ee(),U.hasPointerCapture($.pointerId)&&U.releasePointerCapture($.pointerId),T=null,L="idle",he&&de(),J&&(q.focus(),Z())},v=$=>{if(T!==$.pointerId)return;const J=L==="selecting";ee(),U.hasPointerCapture($.pointerId)&&U.releasePointerCapture($.pointerId),T=null,L="idle",J&&de()};return U.addEventListener("pointerdown",Q),U.addEventListener("pointermove",ae,{passive:!1}),U.addEventListener("pointerup",ue),U.addEventListener("pointercancel",v),()=>{ee(),U.removeEventListener("pointerdown",Q),U.removeEventListener("pointermove",ae),U.removeEventListener("pointerup",ue),U.removeEventListener("pointercancel",v)}},[l,i,B]),h.useImperativeHandle(m,()=>({focus:()=>p.current?.focus(),fit:H,getSelection:()=>{const U=p.current,q=U?.getSelectionPosition(),T=U?.getSelection()??"";return!q||!T.trim()?null:{text:T,startLine:q.start.y+1,endLine:q.end.y+1}}}),[H]),t.jsx("div",{ref:g,"data-terminal-owner":"main",className:le("terminal-viewport-container h-full w-full overflow-hidden touch-none",d)})});xo.displayName="TerminalViewport";const Xu="\x1B",bo=new RegExp(`${Xu}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Zu=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,ef=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,tf=/Serving HTTP on .*? port (\d{2,5})/i,sf=new Set([".",",",";",":","!","?"]),yo=s=>{let e=s;for(;e.length>0;){const n=e[e.length-1];if(n===")"||n==="]"||n==="}"||n===">"){const r=n===")"?"(":n==="]"?"[":n==="}"?"{":"<",o=e.slice(0,-1),a=(o.match(new RegExp(`\\${r}`,"g"))||[]).length,i=(o.match(new RegExp(`\\${n}`,"g"))||[]).length;if(a>i)break;e=o;continue}if(sf.has(n)){e=e.slice(0,-1);continue}break}return e},Cn=s=>{let e=yo(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},nf=s=>{if(!s)return[];const e=s.replace(bo,""),n=[],r=new Set,o=i=>{r.has(i)||(r.add(i),n.push(i))},a=e.match(tf);if(a?.[1]){const i=Number.parseInt(a[1],10);Number.isFinite(i)&&i>0&&i<=65535&&o(`http://127.0.0.1:${i}/`)}for(const i of e.split(`
9
+ `)){if(!ef.test(i))continue;const d=Array.from(i.matchAll(Zu));if(d.length===0)continue;const l=d.find(c=>{try{return!!new URL(Cn(c[1])).port}catch{return!1}});o(Cn((l??d[0])[1]))}return n},wo=s=>nf(s)[0]??null,rf=async(s,e=1500)=>{if(!s||typeof window>"u")return!1;let n;try{n=new URL(s)}catch{return!1}if(n.protocol!=="http:"&&n.protocol!=="https:")return!1;const r=n.hostname.toLowerCase();if(r!=="localhost"&&r!=="127.0.0.1"&&r!=="0.0.0.0"&&r!=="::1"&&r!=="::")return!1;const o=new AbortController,a=window.setTimeout(()=>o.abort(),e);try{const i=await Mt("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:n.toString()}),cache:"no-store",signal:o.signal});return i.ok?(await i.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(a)}},of=/https?:\/\/[^\s<>'"`]+/gi,Vf=(s,{requireAnnounced:e=!1}={})=>{const n=wo(s);if(n)return n;if(e)return null;const r=String(s||"").replace(bo,""),o=[];for(const d of r.match(of)??[])try{const l=new URL(yo(d));l.port&&o.push(l)}catch{}if(o.length===0)return null;const a=d=>{const l=d.hostname.toLowerCase();return(l==="localhost"||l==="127.0.0.1"||l==="0.0.0.0"||l==="::1"?50:0)-(d.search||d.hash?10:0)};let i=o[0];for(const d of o.slice(1))a(d)>a(i)&&(i=d);return Cn(i.toString())},af={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},lf=(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 af[s]},vo=s=>{const e=s[0]?.toUpperCase();return!e||e<"A"||e>"Z"?null:String.fromCharCode(e.charCodeAt(0)&31)},cf=(s,e)=>s&&(e==="ctrl"?vo(s)??s:s.length===1&&s!=="\x1B"?`\x1B${s}`:s),br={cols:80,rows:24},Gf=({visible:s})=>{const{t:e}=nt(),{terminal:n,runtime:r}=Dn(),{currentTheme:o}=Pr(),a=h.useRef({themeMode:"dark",terminalBackground:"",terminalForeground:""});a.current={themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground};const{monoFont:i}=Za(),d=Ue(I=>I.terminalFontSize),l=Ue(I=>I.terminalShell),c=Ue(I=>I.terminalLoginShells.includes(I.terminalShell)),{isMobile:u,isTablet:m,hasTouchOnlyPointer:g}=Vs(),p=u||m,f=(p||g)&&r.platform==="web",b=r.platform!=="vscode",w=Ue(I=>I.showTerminalQuickKeysOnDesktop),C=p||w,k=st(I=>I.currentSessionId),A=st(I=>I.newSessionDraft),M=k!==null||A?.open===!0,j=ei()??null,N=tt(I=>j?I.sessions.get(j):void 0),y=tt(I=>I.hasHydrated),S=tt(I=>I.ensureDirectory),O=tt(I=>I.createTab),W=tt(I=>I.setActiveTab),B=tt(I=>I.closeTab),F=tt(I=>I.setTabSessionId),_=tt(I=>I.adoptServerSessions),te=tt(I=>I.setTabLifecycle),H=tt(I=>I.setConnecting),z=tt(I=>I.appendToBuffer),G=tt(I=>I.replaceBuffer),U=tt(I=>I.setTabPreviewUrl),q=ti(I=>I.addDraft),T=Ue(I=>I.openContextPreview),V=h.useMemo(()=>N?b?N.activeTabId??N.tabs[0]?.id??null:N.tabs[0]?.id??null:null,[N,b]),L=h.useMemo(()=>{if(N)return V?N.tabs.find(I=>I.id===V)??N.tabs[0]:N.tabs[0]},[N,V]),D=h.useMemo(()=>(N?.tabs??[]).map(I=>({icon:(()=>{const ne=I.iconKey?ro[I.iconKey]??"terminal":"terminal";return t.jsx(E,{name:ne,className:"h-4 w-4"})})(),id:I.id,label:I.label,title:I.label,closeLabel:e("terminalView.tabs.closeTabTitle")})),[N?.tabs,e]),K=L?.terminalSessionId??null,re=L?.lifecycle??"idle",X=tt(I=>j&&V?I.getBuffer(j,V).chunks:Fs.chunks),Y=L?.isConnecting??!1,oe=L?.previewUrl??null,[Z,ee]=h.useState(null),[pe,se]=h.useState(!1),[de,Q]=h.useState(!1),[ae,ue]=h.useState(null),[v,$]=h.useState(!1),J=h.useRef(null),he=h.useRef(null),ie=h.useRef(V),ve=h.useRef(K),Ne=h.useRef(j),Ve=h.useRef(null),Le=h.useRef(null),Ye=h.useRef(new Set),Xe=h.useRef(""),ze=h.useRef(new Set),Fe=h.useRef(0),Ge=h.useCallback(()=>{Xe.current="",ze.current.clear(),Fe.current+=1},[]),Ae=h.useCallback(()=>{f||typeof document<"u"&&!document.hasFocus()||Ve.current?.focus()},[f]),_e=h.useCallback(()=>{f||Ve.current?.focus()},[f]),Oe=s??!1,[Ze,at]=h.useState(Oe);h.useEffect(()=>{Oe&&at(!0)},[Oe]),h.useEffect(()=>{ve.current=K},[K]),h.useEffect(()=>{!K||!n.updateAppearance||n.updateAppearance(K,a.current).catch(()=>{})},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,n,K]),h.useEffect(()=>{ie.current=V,Ge()},[V,Ge]),h.useEffect(()=>{Ne.current=j},[j]),h.useEffect(()=>{if(!y||!j||!n.listSessions)return;let I=!1;const ne=j;return n.listSessions(ne).then(ge=>{I||Ne.current!==ne||_(ne,ge)}).catch(()=>{}),()=>{I=!0}},[y,j,n,_]),h.useEffect(()=>{if(!n.touchSessions)return;const I=()=>{if(typeof navigator<"u"&&!navigator.onLine)return;const ge=[];for(const He of tt.getState().sessions.values())for(const ye of He.tabs)ye.terminalSessionId&&ge.push(ye.terminalSessionId);ge.length>0&&n.touchSessions?.(ge).catch(()=>{})};I();const ne=setInterval(I,600*1e3);return()=>clearInterval(ne)},[n]),h.useEffect(()=>{!C&&ae!==null&&ue(null)},[C,ae,ue]),h.useEffect(()=>{!K&&ae!==null&&ue(null)},[K,ae,ue]);const De=h.useCallback(()=>{J.current?.(),J.current=null,he.current=null,Q(!1)},[]);h.useEffect(()=>()=>{De(),ve.current=null},[De]);const Je=h.useCallback((I,ne,ge)=>{if(!ge)return;const He=`${Xe.current}${ge}`.replace(/\r\n|\r/g,`
10
+ `),ye=He.split(`
11
+ `),$e=He.endsWith(`
12
+ `)?ye.join(`
13
+ `):ye.slice(0,-1).join(`
14
+ `);if(Xe.current=He.endsWith(`
15
+ `)?"":(ye[ye.length-1]??"").slice(-1024),!$e)return;const dt=wo($e);if(!dt||ze.current.has(dt))return;const Pe=Fe.current;ze.current.add(dt),rf(dt).then(xe=>{if(ze.current.delete(dt),!xe||Fe.current!==Pe)return;const ot=tt.getState().getDirectoryState(I)?.tabs.find(lt=>lt.id===ne);!ot||ot.previewUrlLocked||ot.previewUrl===dt||U(I,ne,dt,{locked:!1,autoOpened:!1})})},[U]),et=h.useCallback((I,ne,ge)=>{if(he.current===ge)return;De(),he.current=ge;const He=n.connect(ge,{onEvent:ye=>{if(he.current===ge)switch(ye.type){case"snapshot":{H(I,ne,!1),ee(null),se(!1),Q(!1),Ae(),G(I,ne,ye.data??"",ye.sequence??0),Je(I,ne,ye.data??""),ye.status==="exited"&&te(I,ne,"exited");break}case"reconnecting":{ee(null),se(!1),Q(!0);break}case"data":{ye.data&&(z(I,ne,ye.data,ye.sequence,ye.replayData),Je(I,ne,ye.data));break}case"exit":{const $e=typeof ye.exitCode=="number"?ye.exitCode:null,dt=typeof ye.signal=="number"?ye.signal:null,xe=!!tt.getState().getDirectoryState(I)?.tabs.find(ot=>ot.id===ne)?.label?.startsWith("Action:");z(I,ne,e("terminalView.stream.processExitedMessage",{exitCodeSegment:$e!==null?e("terminalView.stream.processExitedWithCode",{exitCode:$e}):"",signalSegment:dt!==null?e("terminalView.stream.processExitedWithSignal",{signal:dt}):""})),te(I,ne,"exited"),H(I,ne,!1),ee(xe?null:e("terminalView.error.sessionEnded")),se(!1),Q(!1),De();break}}},onError:(ye,$e)=>{if(he.current===ge){if(!$e){ee(null),se(!1);return}if(Q(!1),ye.code==="SESSION_NOT_FOUND"&&!tt.getState().getDirectoryState(I)?.tabs.find(Pe=>Pe.id===ne)?.label?.startsWith("Action:")){ee(null),se(!1),H(I,ne,!1),F(I,ne,null),te(I,ne,"idle"),De();return}ee(e("terminalView.error.connectionFailed",{message:ye.message})),se(!0),H(I,ne,!1),te(I,ne,"exited"),F(I,ne,null),De()}}});J.current=()=>{He.close(),he.current=null}},[z,G,De,Ae,Je,H,te,F,e,n]);h.useEffect(()=>{let I=!1;if(!y||!Ze)return;if(!j){ee(e(M?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),De();return}return(async()=>{const ge=j;if(!Ne.current||Ne.current!==ge)return;if(!tt.getState().getDirectoryState(ge)){S(ge);return}const ye=tt.getState().getDirectoryState(ge);if(!ye||ye.tabs.length===0)return;const $e=b?ye.activeTabId??ye.tabs[0]?.id??null:ye.tabs[0]?.id??null;if(!$e)return;const dt=ye.tabs.find(xt=>xt.id===$e)??ye.tabs[0],Pe=dt?.terminalSessionId??null,xe=dt?.lifecycle??"idle",ot=!!dt?.label?.startsWith("Action:"),lt=tt.getState().getBuffer(ge,$e),pt=lt.byteLength>0||lt.chunks.length>0;if(!Pe){if(xe==="exited"){H(ge,$e,!1);return}if(ot&&pt){H(ge,$e,!1);return}const xt=`${ge}\0${$e}`;if(Ye.current.has(xt))return;const St=Le.current??br;Ye.current.add(xt),ee(null),se(!1),Q(!1),H(ge,$e,!0);try{const kt=await n.createSession({cwd:ge,sessionId:$e,cols:St.cols,rows:St.rows,shell:l,loginShell:c,...a.current}),wt=!I&&Ne.current===ge&&ie.current===$e;if(!tt.getState().getDirectoryState(ge)?.tabs.find(Rt=>Rt.id===$e)){try{await n.close(kt.sessionId)}catch{}return}if(F(ge,$e,kt.sessionId),!wt)return;const Ct=Le.current;Ct&&(Ct.cols!==St.cols||Ct.rows!==St.rows)&&n.resize({sessionId:kt.sessionId,...Ct}).catch(()=>{});return}catch(kt){const wt=tt.getState().getDirectoryState(ge)?.tabs.find(jt=>jt.id===$e);if(!wt||wt.terminalSessionId||(H(ge,$e,!1),Ne.current!==ge||ie.current!==$e))return;ee(kt instanceof Error?kt.message:e("terminalView.error.startSessionFailed")),se(!0),Q(!1);return}finally{Ye.current.delete(xt)}}!Pe||I||(ve.current=Pe,et(ge,$e,Pe))})(),()=>{I=!0,ve.current=null,De()}},[M,j,K,re,V,Ze,b,y,S,H,te,F,et,De,e,n,c,l]),h.useEffect(()=>{if(!Oe||f)return;if(typeof window>"u"){Ae();return}const I=window.requestAnimationFrame(()=>{Ae()});return()=>{window.cancelAnimationFrame(I)}},[V,Ae,Oe,f]);const Ke=h.useCallback(async()=>{if(!j||v)return;const I=tt.getState().getDirectoryState(j),ne=b?V??I?.activeTabId??I?.tabs[0]?.id??null:I?.tabs[0]?.id??null;if(!ne)return;const ge=I?.tabs.find(He=>He.id===ne)?.terminalSessionId??null;if(!(!ge||!n.restartSession)){$(!0),ee(null),se(!1),Q(!1),De(),Ge();try{const He=Le.current??br,ye=await n.restartSession(ge,{cwd:j,shell:l,loginShell:c,...He,...a.current});if(tt.getState().getDirectoryState(j)?.tabs.find(dt=>dt.id===ne)?.terminalSessionId!==ge||(F(j,ne,ye.sessionId),te(j,ne,"running"),Ne.current!==j||ie.current!==ne))return;ve.current=ye.sessionId,et(j,ne,ye.sessionId)}catch(He){if(tt.getState().getDirectoryState(j)?.tabs.find($e=>$e.id===ne)?.terminalSessionId!==ge||Ne.current!==j||ie.current!==ne)return;ee(He instanceof Error?He.message:e("terminalView.error.restartFailed")),se(!1),Q(!1),ve.current=ge,et(j,ne,ge)}finally{$(!1)}}},[V,De,j,b,v,Ge,te,F,et,e,n,c,l]),ke=h.useCallback(async()=>{await Ke()},[Ke]),rt=h.useCallback(()=>{if(!j)return;const I=O(j);W(j,I),ee(null),se(!1),Q(!1),De()},[O,De,j,W]),x=h.useCallback(()=>{const I=Ve.current?.getSelection(),ne=k??(A?.open?"draft":null);!I||!ne||!L||!j||q({directory:j,sessionKey:ne},{source:"terminal",fileLabel:L.label,startLine:I.startLine,endLine:I.endLine,code:I.text,language:"",terminalId:L.terminalSessionId??L.id,text:""})},[L,q,k,j,A?.open]),R=h.useCallback(I=>{j&&(W(j,I),ee(null),se(!1),Q(!1),De())},[De,j,W]),be=h.useCallback(I=>{if(!j)return;I===V&&De(),ee(null),se(!1),Q(!1);const ne=tt.getState().getDirectoryState(j)?.tabs.find(ge=>ge.id===I)?.terminalSessionId;(async()=>{ne&&await n.close(ne),B(j,I)})().catch(ge=>ee(ge instanceof Error?ge.message:e("terminalView.error.sessionEnded")))},[V,B,De,j,e,n]),fe=h.useCallback(I=>{if(!I||de)return;let ne=I,ge=!1;ae&&I.length>0&&(ne=cf(I,ae),ge=!0);const He=ve.current;He&&(n.sendInput(He,ne).catch(ye=>{de||ee(ye instanceof Error?ye.message:e("terminalView.error.sendInputFailed"))}),ge&&(ue(null),_e()))},[ae,_e,de,ue,e,n]),Se=h.useCallback((I,ne)=>{const ge=Le.current;if((!ge||ge.cols!==I||ge.rows!==ne)&&(Le.current={cols:I,rows:ne}),!Oe)return;const He=ve.current;He&&n.resize({sessionId:He,cols:I,rows:ne}).catch(()=>{})},[Oe,n]),Be=h.useCallback(I=>{ue(ne=>ne===I?null:I),_e()},[_e,ue]),Re=h.useCallback(I=>{const ne=lf(I,ae);ne&&(fe(ne),ue(null),_e())},[ae,_e,fe,ue]),qe=h.useMemo(()=>({Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc"}),[]),Ee=h.useCallback(I=>{if(I.repeat)return;const ne=I.key;if(!ne||ne==="Control"||ne==="Meta"||ne==="Alt"||ne==="Shift")return;const ge=ne.length===1?ne.toLowerCase():ne;if(ge in qe){I.preventDefault(),I.stopPropagation(),Re(qe[ge]);return}if(ae!=="ctrl")return;const He=I.code??"",ye=ne.length===1&&/[a-zA-Z]/.test(ne)?ne.toUpperCase():He.startsWith("Key")&&He.length===4?He.slice(3).toUpperCase():null;if(ye&&ye.length===1&&ye>="A"&&ye<="Z"){const $e=vo(ye);if(!$e)return;I.preventDefault(),I.stopPropagation(),fe($e),ue(null),_e()}},[ae,_e,Re,fe,qe,ue]);h.useEffect(()=>{if(!(!C||!ae||!K))return window.addEventListener("keydown",Ee),()=>window.removeEventListener("keydown",Ee)},[ae,Ee,C,K]);const ft=h.useMemo(()=>{const I=bs[Xs].stack;if(typeof window>"u")return(bs[i]??bs[Xs]).stack;const ge=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return ge&&ge.trim().length>0?ge.trim():(bs[i]??bs[Xs]).stack??I},[i]),ct=h.useMemo(()=>Wu(o),[o]),ut=`${j??"no-dir"}::${V??"no-tab"}`;if(h.useEffect(()=>{if(!Oe||f)return;const I=Ve.current;if(!I)return;const ne=()=>{I.fit()};if(typeof window<"u"){const ge=window.requestAnimationFrame(()=>{ne(),Ae()}),He=[220,400].map(ye=>window.setTimeout(ne,ye));return()=>{window.cancelAnimationFrame(ge),He.forEach(ye=>window.clearTimeout(ye))}}ne()},[Ae,Oe,f,ut,K]),h.useEffect(()=>{if(!Oe||!f)return;let I=null;const ne=()=>{I!==null&&window.cancelAnimationFrame(I),I=window.requestAnimationFrame(()=>{I=null,Ve.current?.fit()})};return window.addEventListener("oc:keyboard-settled",ne),()=>{window.removeEventListener("oc:keyboard-settled",ne),I!==null&&window.cancelAnimationFrame(I)}},[Oe,ut,f]),!M)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(!j)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:Ke,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 it=!K||Y||v||de,P=Ze,me=p?"lg":"xs",Ie=p?"w-10 p-0":"w-9 p-0",Te=I=>{p&&I.preventDefault()},Me=t.jsxs(t.Fragment,{children:[t.jsx(Ce,{type:"button",size:me,variant:"outline",onPointerDown:Te,onClick:()=>Re("esc"),disabled:it,children:e("terminalView.quickKeys.escape")}),t.jsxs(Ce,{type:"button",size:me,variant:"outline",className:Ie,onPointerDown:Te,onClick:()=>Re("tab"),disabled:it,children:[t.jsx(E,{name:"arrow-right",className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.tabAria")})]}),t.jsxs(Ce,{type:"button",size:me,variant:"chip","aria-pressed":ae==="ctrl",className:p?"px-3":"px-2",onPointerDown:Te,onClick:()=>Be("ctrl"),disabled:it,children:[t.jsx("span",{className:"text-xs font-medium",children:yn("ctrl")}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.controlModifierAria")})]}),t.jsxs(Ce,{type:"button",size:me,variant:"chip","aria-pressed":ae==="alt",className:p?"px-3":"px-2",onPointerDown:Te,onClick:()=>Be("alt"),disabled:it,children:[t.jsx("span",{className:"text-xs font-medium",children:yn("alt")}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.altModifierAria")})]}),t.jsxs(Ce,{type:"button",size:me,variant:"outline",className:Ie,onPointerDown:Te,onClick:()=>Re("arrow-up"),disabled:it,children:[t.jsx(E,{name:"arrow-up"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowUpAria")})]}),t.jsxs(Ce,{type:"button",size:me,variant:"outline",className:Ie,onPointerDown:Te,onClick:()=>Re("arrow-left"),disabled:it,children:[t.jsx(E,{name:"arrow-left"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowLeftAria")})]}),t.jsxs(Ce,{type:"button",size:me,variant:"outline",className:Ie,onPointerDown:Te,onClick:()=>Re("arrow-down"),disabled:it,children:[t.jsx(E,{name:"arrow-down"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowDownAria")})]}),t.jsxs(Ce,{type:"button",size:me,variant:"outline",className:Ie,onPointerDown:Te,onClick:()=>Re("arrow-right"),disabled:it,children:[t.jsx(E,{name:"arrow-right"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowRightAria")})]}),t.jsxs(Ce,{type:"button",size:me,variant:"outline",className:Ie,onPointerDown:Te,onClick:()=>Re("enter"),disabled:it,children:[t.jsx(E,{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:le("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",p?"px-3 py-1.5":"pl-3 pr-1.5 py-1"),children:[b&&N?t.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1",children:[t.jsx("div",{className:le("min-w-0 flex-1",p?"h-8":"h-7"),children:t.jsx(Ns,{items:D,activeId:V,onSelect:R,onClose:be,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),t.jsx(Ce,{type:"button",size:"xs",variant:"ghost",className:le("shrink-0",p?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:rt,title:e("terminalView.tabs.newTabTitle"),children:t.jsx(E,{name:"add",className:`${p?"h-[18px] w-[18px]":"h-4 w-4"}`})}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-visible",children:[t.jsx(Ce,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{Ke()},disabled:v,title:e("terminalView.actions.restart"),"aria-label":e("terminalView.actions.restart"),children:t.jsx(E,{name:"restart",className:"h-4 w-4"})}),t.jsx(Ce,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:x,title:e("terminalView.actions.attachSelection"),"aria-label":e("terminalView.actions.attachSelection"),children:t.jsx(E,{name:"attachment-2",className:"h-4 w-4"})}),oe?t.jsxs(Ce,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{j&&T(j,oe)},title:e("terminalView.preview.openTitle"),children:[t.jsx(E,{name:"global",className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"whitespace-nowrap",children:e("terminalView.preview.open")})]}):null]})]}):null,!p&&C&&b&&N?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:Me}):null,!p&&C&&(!b||!N)?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:Me}):null]}),t.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:ct.background},children:[t.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:P?t.jsx(xo,{ref:I=>{Ve.current=I},sessionKey:ut,chunks:X,onInput:fe,onResize:Se,theme:ct,fontFamily:ft,fontSize:d,enableTouchScroll:f,autoFocus:Oe,isVisible:Oe},ut):null}),!de&&Z&&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:Z}),pe&&p&&t.jsx(Ce,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:ke,disabled:v,title:e("terminalView.actions.hardRestartTitle"),type:"button",children:e("terminalView.actions.hardRestart")})]})]}),p&&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:Me})}):null]})},Hf=()=>{_r(),fs.reconnectToRuntimeBaseUrl(),Or()},Kf=s=>{st.getState().prepareForRuntimeSwitch(s.previousRuntimeKey),s.previousRuntimeKey&&si.getState().stopRunningRunsForRuntime(s.previousRuntimeKey),_r(),tt.getState().clearAll(),fs.reconnectToRuntimeBaseUrl(),Nt.setState({providers:[],agents:[],isConnected:!1,isInitialized:!1,connectionPhase:"connecting",lastDisconnectReason:null}),It.getState().resetForRuntimeSwitch(),Et.getState().reset(),qt.getState().resetForRuntimeSwitch(),ni(new Map),ri(),oi(),ai.getState().reset(),Ii.getState().resetForRuntimeSwitch(),Pn.getState().resetForRuntimeSwitch(s.runtimeKey),ii.getState().resetForRuntimeSwitch(),li.getState().resetForRuntimeSwitch(s.runtimeKey),Ci.getState().resetForRuntimeSwitch(s.runtimeKey),st.getState().restoreForRuntimeSwitch(s.runtimeKey),Or(),queueMicrotask(()=>{Ti()})};export{Ol as A,wc as B,kf as C,Of as D,Af as E,Ef as F,Uf as G,Wf as H,_f as I,sd as J,ju as K,nn as L,Rf as M,$f as N,Nf as O,zf as P,jf as Q,Kt as R,Lf as S,Gf as T,Sf as U,Sc as V,tc as W,jc as X,Il as Y,vf as Z,Ff as _,Vc as a,Ns as b,Kf as c,Mf as d,Bf as e,If as f,wf as g,sr as h,tt as i,sc as j,Pf as k,ro as l,nf as m,nc as n,Vf as o,fd as p,jl as q,Hf as r,kl as s,Df as t,ol as u,Nl as v,Ul as w,Tf as x,Cf as y,$l as z};