@openchamber/web 1.24.1 → 1.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/bin/cli.test.js +22 -0
  2. package/bin/lib/commands-status.js +5 -0
  3. package/dist/assets/{CodeMirrorCommentWidgets-DvUH815P.js → CodeMirrorCommentWidgets-B_vBPQYm.js} +1 -1
  4. package/dist/assets/DiffView-Ce0oBXXQ.js +4 -0
  5. package/dist/assets/{FilesView-D0bM9FVB.js → FilesView-DtXueAWP.js} +5 -5
  6. package/dist/assets/{GitView-Bxuv3dfP.js → GitView-k0hUF8KB.js} +4 -4
  7. package/dist/assets/{GuestAttachDialog-B0u3Q5uO.js → GuestAttachDialog-DIf2U85Z.js} +1 -1
  8. package/dist/assets/{JsonTreeView-BBVPFM5K.js → JsonTreeView-4AnJ04Pw.js} +1 -1
  9. package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  10. package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  11. package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  12. package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  13. package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  14. package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  15. package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  16. package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  17. package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  18. package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  19. package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  20. package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  21. package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  22. package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  23. package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  24. package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  25. package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  26. package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  27. package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  28. package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  29. package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  30. package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  31. package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  32. package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  33. package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  34. package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  35. package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  36. package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  37. package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  38. package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  39. package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  40. package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  41. package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  42. package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  43. package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  44. package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  45. package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  46. package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  47. package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  48. package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  49. package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  50. package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  51. package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  52. package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  53. package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  54. package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  55. package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  56. package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  57. package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  58. package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  59. package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  60. package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  61. package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  62. package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  63. package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  64. package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  65. package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  66. package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  67. package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  68. package/dist/assets/{LinearIssuesView-UI1FcSC8.js → LinearIssuesView-z_9p2GuO.js} +1 -1
  69. package/dist/assets/{MarkdownImageGallery-CUJxH8Le.js → MarkdownImageGallery-BC-BNN-s.js} +1 -1
  70. package/dist/assets/{MarkdownRendererImpl-D5BZOg8X.js → MarkdownRendererImpl-DyaBTUbH.js} +6 -6
  71. package/dist/assets/{OnboardingScreen-5Gou9cGD.js → OnboardingScreen-DKU_yTb6.js} +1 -1
  72. package/dist/assets/{PatchDiff-C4rE5k6z.js → PatchDiff-DpGmHRnV.js} +1 -1
  73. package/dist/assets/PierreDiffViewer-CgLl_tp7.js +210 -0
  74. package/dist/assets/{PlanView-u2yi5XGJ.js → PlanView-CrfB4qqY.js} +4 -4
  75. package/dist/assets/{PluginPane-QxjsKYeO.js → PluginPane-B5cn-jPy.js} +1 -1
  76. package/dist/assets/{SettingsView-Fo5ZqMaT.js → SettingsView-DMKKwezx.js} +12 -12
  77. package/dist/assets/{SettingsWindow-HVDVANjJ.js → SettingsWindow-DwbnVzOC.js} +1 -1
  78. package/dist/assets/{SubmoduleDiffSummary-D3hzkybB.js → SubmoduleDiffSummary-hkGcvs0E.js} +1 -1
  79. package/dist/assets/{ToolOutputDialog-3J6IRayW.js → ToolOutputDialog-DuoIOc0j.js} +6 -6
  80. package/dist/assets/{ToolPartDiffPreview-DarxPjSd.js → ToolPartDiffPreview-t1Bvq_2Y.js} +2 -2
  81. package/dist/assets/{VirtualizedFileDiff-CZgXWHjU.js → VirtualizedFileDiff-BK4aU5qJ.js} +4 -4
  82. package/dist/assets/{WalkthroughView-wSpED5L4.js → WalkthroughView-Bk6TPNFw.js} +2 -2
  83. package/dist/assets/{appThemeRegistry-Cf8KitzT.js → appThemeRegistry-DnOVbJjF.js} +1 -1
  84. package/dist/assets/{commitAndPush-DZnzlhvc.js → commitAndPush-DLWNZkkY.js} +1 -1
  85. package/dist/assets/{computeVirtualFileMetrics-VYnT_A2h.js → computeVirtualFileMetrics-BVTujWSX.js} +1 -1
  86. package/dist/assets/{de-BM_8EDD3.js → de-zEHaAIi3.js} +4 -4
  87. package/dist/assets/{es-CxZjlqpo.js → es-CBDgEzgk.js} +3 -3
  88. package/dist/assets/{fr-VCixCnMW.js → fr-DjiTptT_.js} +4 -4
  89. package/dist/assets/{index-B9Hvzjwl.css → index-AgOdanig.css} +1 -1
  90. package/dist/assets/index-B-2_X4DD.js +40 -0
  91. package/dist/assets/{index-3U4CtS9b.js → index-CkA4p2IK.js} +1 -1
  92. package/dist/assets/{isDiffPlainText-ImDG3Uhg.js → isDiffPlainText-D3yX_vx4.js} +1 -1
  93. package/dist/assets/{isFilePlainText-D_YDVYDb.js → isFilePlainText-CZR9TcHV.js} +1 -1
  94. package/dist/assets/{ja-CZ5k_GyD.js → ja-CerMgj3r.js} +4 -4
  95. package/dist/assets/{ko-7YM3A1Xh.js → ko-DHYDAze5.js} +4 -4
  96. package/dist/assets/main-BDka4W43.js +896 -0
  97. package/dist/assets/main-Dl7Dyge_.js +2 -0
  98. package/dist/assets/{markdownCore-DHvqMxPn.js → markdownCore-DFmr0rUR.js} +4 -4
  99. package/dist/assets/miniChat-CLKQPPpO.js +2 -0
  100. package/dist/assets/mobile--giD2Q1L.js +2 -0
  101. package/dist/assets/{patchFileDiff-DDQ6Rq5e.js → patchFileDiff-DRh-AQvd.js} +3 -3
  102. package/dist/assets/{pl-BcgDO_w5.js → pl-BTB_93bq.js} +4 -4
  103. package/dist/assets/{pt-BR-CU2u_1q5.js → pt-BR-BwA3oyCK.js} +3 -3
  104. package/dist/assets/renderElectronMiniChatApp-DmB7zpVK.js +2 -0
  105. package/dist/assets/{renderMobileApp-D0Y8DtkA.js → renderMobileApp-pMfOuQfl.js} +7 -7
  106. package/dist/assets/runtimeEndpointReset-Gqhmkm3U.js +25 -0
  107. package/dist/assets/{scheduledTasksApi-D8pq6gQz.js → scheduledTasksApi-CeRAIUmW.js} +1 -1
  108. package/dist/assets/{shikiHighlight-1imXsir9.js → shikiHighlight-BfjuB3CD.js} +1 -1
  109. package/dist/assets/{textMateThemeFromAppTheme-Dgqc63LZ.js → textMateThemeFromAppTheme-BP60t9SX.js} +1 -1
  110. package/dist/assets/{tr-DuYhOzNe.js → tr-CcPsJoNM.js} +3 -3
  111. package/dist/assets/{uk-Cuk7-uvq.js → uk-B68WibXi.js} +3 -3
  112. package/dist/assets/{useAppFontEffects-BItUWdo4.js → useAppFontEffects-DcdrFv2Z.js} +144 -144
  113. package/dist/assets/{useInlineCommentController-CkbKsm7m.js → useInlineCommentController-Cq4SUjsA.js} +2 -2
  114. package/dist/assets/{useRootScrollLock-vmzxZjWA.js → useRootScrollLock-CSdR6Wnm.js} +2 -2
  115. package/dist/assets/{vendor-codemirror-language-data-BDyxuqK4.js → vendor-codemirror-language-data-BFm1Ju2w.js} +2 -2
  116. package/dist/assets/vendor-katex-Cp579UoJ.css +1 -0
  117. package/dist/assets/{vendor-zod-fZppILAM.js → vendor-zod-CgAdXWZO.js} +4 -4
  118. package/dist/assets/{web-components-D7FinaeH.js → web-components-2vo9YsZc.js} +1 -1
  119. package/dist/assets/{zh-CN-CUWoiRHd.js → zh-CN-DbFHYXwP.js} +3 -3
  120. package/dist/assets/{zh-TW-CQ8EBSBN.js → zh-TW-DmXAwdty.js} +3 -3
  121. package/dist/index.html +6 -4
  122. package/dist/mini-chat.html +6 -4
  123. package/dist/mobile.html +6 -4
  124. package/package.json +4 -4
  125. package/server/index.js +3 -0
  126. package/server/lib/agent-tool/DOCUMENTATION.md +17 -4
  127. package/server/lib/agent-tool/runtime.js +62 -15
  128. package/server/lib/agent-tool/runtime.test.js +88 -2
  129. package/server/lib/fs/DOCUMENTATION.md +2 -1
  130. package/server/lib/fs/routes.js +56 -4
  131. package/server/lib/fs/routes.test.js +116 -0
  132. package/server/lib/git/DOCUMENTATION.md +2 -2
  133. package/server/lib/git/service.js +94 -9
  134. package/server/lib/git/service.test.js +18 -0
  135. package/server/lib/message-queue/DOCUMENTATION.md +4 -1
  136. package/server/lib/message-queue/runtime.js +16 -1
  137. package/server/lib/message-queue/runtime.test.js +21 -5
  138. package/server/lib/notifications/routes.js +5 -0
  139. package/server/lib/openchamber-sessions/routes.js +18 -18
  140. package/server/lib/openchamber-sessions/routes.test.js +49 -0
  141. package/server/lib/opencode/DOCUMENTATION.md +1 -1
  142. package/server/lib/opencode/bootstrap-runtime.js +1 -0
  143. package/server/lib/opencode/session-runtime.js +68 -0
  144. package/server/lib/opencode/session-runtime.test.js +43 -0
  145. package/server/lib/projects/project-config.js +2 -2
  146. package/server/lib/realtime-proxy-terminal.test.js +150 -0
  147. package/server/lib/realtime-proxy.js +2 -0
  148. package/server/lib/routing/DOCUMENTATION.md +5 -3
  149. package/server/lib/scheduled-tasks/runtime.js +2 -2
  150. package/server/lib/scheduled-tasks/runtime.test.js +14 -0
  151. package/server/lib/small-model/DOCUMENTATION.md +14 -2
  152. package/server/lib/small-model/call.js +37 -6
  153. package/server/lib/small-model/call.test.js +182 -0
  154. package/server/lib/terminal/DOCUMENTATION.md +21 -2
  155. package/server/lib/terminal/runtime.js +10 -3
  156. package/server/lib/terminal/runtime.test.js +22 -0
  157. package/server/lib/terminal/shutdown.js +106 -0
  158. package/server/lib/terminal/shutdown.test.js +84 -0
  159. package/server/lib/tts/service.test.js +78 -0
  160. package/dist/assets/DiffView-DkC3xlRJ.js +0 -4
  161. package/dist/assets/PierreDiffViewer-ByRVu6ss.js +0 -161
  162. package/dist/assets/index-DLHQogv8.js +0 -40
  163. package/dist/assets/main-CycplCph.js +0 -2
  164. package/dist/assets/main-DFYTCx5o.js +0 -896
  165. package/dist/assets/miniChat-DIQKfY2V.js +0 -2
  166. package/dist/assets/mobile-BMwz5q-m.js +0 -2
  167. package/dist/assets/renderElectronMiniChatApp-3_d6g6CU.js +0 -2
  168. package/dist/assets/runtimeEndpointReset-DhC3REb2.js +0 -25
  169. /package/dist/assets/{vendor-katex-k3Ppq1Ha.js → vendor-katex-CHD9BdDO.js} +0 -0
@@ -1,896 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-wSpED5L4.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-BItUWdo4.js","assets/index-DLHQogv8.js","assets/vendor-zod-fZppILAM.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-B9Hvzjwl.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-CsXYnR5c.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-ClYN8CzB.js","assets/vendor-tanstack-virtual-core-BewVQryB.js","assets/contextPanelEmbeddedChat-CirXEPJq.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-BDyxuqK4.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-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/patchFileDiff-DDQ6Rq5e.js","assets/runtimeEndpointReset-DhC3REb2.js","assets/GuestAttachDialog-B0u3Q5uO.js","assets/PluginPane-QxjsKYeO.js","assets/VirtualizedFileDiff-CZgXWHjU.js","assets/web-components-D7FinaeH.js","assets/computeVirtualFileMetrics-VYnT_A2h.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/isDiffPlainText-ImDG3Uhg.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-ByRVu6ss.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-CkbKsm7m.js","assets/appThemeRegistry-Cf8KitzT.js","assets/textMateThemeFromAppTheme-Dgqc63LZ.js","assets/useRootScrollLock-vmzxZjWA.js","assets/scheduledTasksApi-D8pq6gQz.js","assets/vendor-cron-parser-CUcP7OfX.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-DkC3xlRJ.js","assets/SubmoduleDiffSummary-D3hzkybB.js","assets/FilesView-D0bM9FVB.js","assets/shikiHighlight-1imXsir9.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-BBVPFM5K.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-D_YDVYDb.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-DvUH815P.js","assets/GitView-Bxuv3dfP.js","assets/commitAndPush-DZnzlhvc.js","assets/LinearIssuesView-UI1FcSC8.js","assets/PlanView-u2yi5XGJ.js","assets/SettingsWindow-HVDVANjJ.js","assets/SettingsView-Fo5ZqMaT.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/OnboardingScreen-5Gou9cGD.js"])))=>i.map(i=>d[i]);
2
- import{f as et,R as c,j as s,r as xt,c as _m,h as Lm}from"./vendor-react-BUCujlKS.js";import{E as vn,F as qo,H as $m,I as zm,h as ms,x as Od,u as De,J as Bt,K as cl,a as as,A as eo,o as gt,L as Qs,N as Yr,O as Kn,P as Bd,Q as Wm,R as Km,S as Vm,T as Um,U as Fd,n as os,V as zn,W as Qr,e as En,X as Hm,Y as Gm,Z as qm,_ as Ym,$ as _d,v as bn,B as Xs,a0 as Qm,a1 as Xm,a2 as dl,a3 as Jm,a4 as ja,a5 as Zm,a6 as Ld,f as eh,a7 as tr,a8 as Ti,a9 as th,aa as Ei,ab as fr,ac as ka,d as Eo,t as $r,q as hs,ad as $d,ae as sh,af as nh,ag as Ri,ah as zd,ai as Wd,i as rh,aj as vo,ak as So,al as oh,am as ul,an as ih,ao as ah,ap as lh,aq as ch,ar as fl,as as ml,at as hl,au as pl,av as dh,z as gl,aw as uh,ax as fh,ay as mh,C as hh,D as ph}from"./index-DLHQogv8.js";import{_ as On}from"./vendor-vite-runtime-DD1OZmLC.js";import{v as xl,w as ui,x as un,y as Mi,z as bl,E as gh,F as xh,G as bh,H as yh,I as wh,J as vh,K as Sh,L as jh,M as Ca,b as kh,c as Kd,U as Vd,h as Oi,j as Ud,Q as Ch,i as Nh,f as Ah,R as Hd,V as Bi,W as Jn,X as Gd,Y as qd,P as Dh,T as Ph,Z as Ih,_ as Th,$ as Eh,a as Yd,a0 as Rh,S as yl,r as Mh,a1 as Oh,a2 as Bh,a3 as Fh,a4 as wl,u as Ur,s as _h,N as Lh,D as $h,a5 as zh,a6 as vl,a7 as Wh,o as Kh,m as Vh,q as Qd,t as Uh,a8 as Hh,a9 as Gh,aa as qh,l as Yh,n as Qh,O as Xd,A as Xh,C as Jh}from"./runtimeEndpointReset-DhC3REb2.js";import{f as vt,h as Me,be as Kt,I as M,g as wn,t as _e,aq as Ls,bf as Rs,as as $s,ap as zs,S as ar,Z as Cn,af as lr,bg as Vn,o as Yo,bh as Sl,bi as Zh,bj as ep,aa as Dt,ab as Pt,ac as It,b as Gt,z as Ze,H as tp,bk as Jd,bl as io,u as _s,C as Na,r as Ps,D as Zd,bm as Fi,bn as sp,bo as eu,bp as tu,bq as np,br as rp,bs as jl,bt as kl,bu as Qo,bv as su,bw as nu,bx as op,by as Cl,bz as ip,bA as ap,bB as Aa,bC as _i,bD as lp,bE as cp,Q as ru,bF as dp,l as Yt,bG as up,n as hr,bH as ou,bI as fp,p as mp,bJ as iu,bK as hp,bL as pp,bM as gp,bN as au,bO as lu,bP as Nl,bQ as cu,bR as du,bS as uu,bT as fu,bU as mu,bV as hu,bW as to,bX as pu,aF as Da,bY as sr,bZ as so,b_ as xp,b$ as vs,c0 as Ss,c1 as Ws,c2 as Is,c3 as Ts,c4 as Sn,B as dt,c5 as jn,ay as Ds,c6 as bp,c7 as yp,aD as Rn,c8 as zr,c9 as Ys,ca as Xo,cb as gu,cc as Li,cd as $i,ce as zi,cf as wp,cg as Ms,ch as Os,ci as Ns,cj as Bs,ck as is,W as In,cl as pr,cm as Al,cn as br,co as xu,R as Jo,ag as vp,ah as Pa,ai as bu,J as yu,K as Mn,cp as Zo,a5 as Ia,cq as Sp,cr as jp,aw as kp,cs as Cp,ct as wu,cu as Np,cv as Ap,ax as Ta,cw as Dp,cx as vu,cy as yr,cz as Su,cA as Pp,s as Ip,cB as Tp,cC as no,cD as Ep,aL as ro,cE as Rp,cF as mr,O as ju,cG as Mp,cH as Op,cI as Un,cJ as Bp,cK as Fp,aA as _p,cL as fi,cM as ku,cN as Ea,cO as Lp,cP as Cu,cQ as $p,aE as Wi,cR as Ki,cS as Dl,cT as zp,cU as Pl,cV as Wr,c as Xr,d as Ra,a1 as Wp,cW as Nu,cX as Tr,cY as Kr,cZ as Kp,c_ as Vp,c$ as Up,_ as Ma,az as Hp,d0 as Gp,d1 as qp,d2 as Yp,d3 as Qp,d4 as Au,d5 as hn,d6 as Xp,d7 as Du,d8 as Jp,d9 as Vi,da as Zp,db as Pu,dc as ps,dd as eg,de as tg,df as sg,dg as Iu,dh as ng,di as Oa,dj as Tu,a3 as Ro,dk as Ui,dl as Ba,a as Fa,a2 as rg,dm as Il,dn as Hi,dp as Eu,dq as og,ar as Ru,dr as ig,P as Gi,L as ag,ds as Tl,dt as lg,du as El,dv as cg,dw as dg,dx as ug,dy as ss,dz as fg,dA as Wn,dB as _a,dC as Mu,dD as mg,dE as Ou,dF as Bu,dG as hg,E as pg,dH as gg,dI as xg,dJ as bg,dK as Rl,dL as yg,dM as wg,dN as Fu,F as vg,dO as Sg,dP as jg,dQ as jo,dR as kg,dS as Cg,dT as Ng,dU as Ag,e as La,U as $a,T as za,V as Wa,dV as ei,dW as Dg,dX as Jr,a0 as Pg,dY as Ig,dZ as Ml,d_ as Tg,d$ as Eg,e0 as Rg,aY as Ol,a7 as Bl,a6 as Fl,e1 as Mg,aT as qi,e2 as Og,M as Bg,N as mi,e3 as Fg,e4 as _g,e5 as _u,e6 as Lu,e7 as $u,e8 as Lg,G as Ka,e9 as $g,a4 as zg,ea as Wg,eb as Kg,ec as Vg,ed as Ug,ee as Hg,ef as Gg,eg as qg,eh as Yg,ei as Mo,aj as Qg,ej as Xg,ek as _l,el as Jg,em as Zg,en as ex,eo as tx,ep as Oo,eq as sx,er as Ll,es as nx,et as rx,eu as ox,ev as ix,ew as ax,ex as lx,ey as ko,ez as cx,i as dx,eA as ux,eB as fx,eC as mx,eD as hx,a8 as px,eE as gx,eF as xx,eG as bx,eH as yx,eI as $l,eJ as wx,aM as vx,aN as Sx,aP as jx,aO as kx,aR as zl,aS as Wl,aV as Kl,aW as Vl,aU as zu,aX as Wu,eK as Cx,b9 as Nx,ba as Ax,bb as Dx,bc as Px,bd as Ix,b3 as Tx,b5 as Ex,b6 as Rx,b7 as Mx,b8 as Ox}from"./useAppFontEffects-BItUWdo4.js";import{u as Ku,S as Ul,C as Bx,t as Fx,W as Vu,f as _x,G as Lx,a as $x}from"./useRootScrollLock-vmzxZjWA.js";import{u as Gn,O as Hl,D as zx,a as Wx,b as Kx,n as Vx,f as Ux,c as Gl,s as Hx,d as Gx,e as qx,r as Yx}from"./scheduledTasksApi-D8pq6gQz.js";import{f as ti,h as Tn,T as si,M as ni,D as ri,j as oi,d as Qx,b as Xx,k as Jx,i as Zx}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as ii,S as Va,h as eb,a as Uu,v as Hu,s as tb}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as ai}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as Gu,M as qu,C as Yu,a as Yi,b as Qi,c as Xi,d as Qu,e as sb,f as nb}from"./vendor-base-ui-CsXYnR5c.js";import{c as Ar,u as ir,d as Xu,p as rb}from"./vendor-zustand-BAGL70zf.js";import{g as ob,a as ib,E as Ju,b as ab,c as lb,d as cb,e as db,i as ub}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as fb}from"./PluginPane-QxjsKYeO.js";import{c as Ua,s as Nr,r as Zu}from"./vendor-zod-fZppILAM.js";import{u as mb}from"./vendor-tanstack-react-virtual-ClYN8CzB.js";import{d as hb}from"./vendor-tanstack-virtual-core-BewVQryB.js";import{d as ef}from"./vendor-cron-parser-CUcP7OfX.js";const pb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",gb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",hi=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?pb:t.id==="terminal"?gb:void 0}),ql=t=>{const e=et.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const u=a,d=r||i;if(d&&!o){let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>l(!0),e[2]=g):g=e[2];let b;return e[3]!==d?(b=s.jsx("img",{src:d,alt:"",className:"h-4 w-4 rounded-sm",onError:g}),e[3]=d,e[4]=b):b=e[4],b}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Me("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let m;return e[6]!==u?(m=s.jsx("span",{className:h,children:u}),e[6]=u,e[7]=m):m=e[7],m},xb=t=>{const e=et.c(75),{directory:n,className:r}=t,{t:i}=vt(),o=Gn(bb),l=Gn(yb),a=Gn(wb),u=Gn(vb),d=Gn(Sb),h=Gn(jb),m=Gn(kb);let g,b;e[0]!==d?(g=()=>{d()},b=[d],e[0]=d,e[1]=g,e[2]=b):(g=e[1],b=e[2]),c.useEffect(g,b);const y=vn()&&qo();let S;e:{let ve;e[3]!==l||e[4]!==o?(ve=l.find(xe=>xe.id===o)??l.find(Cb)??l[0]??Hl[0],e[3]=l,e[4]=o,e[5]=ve):ve=e[5];const ye=ve;if(ye){let xe;e[6]!==ye?(xe=hi(ye),e[6]=ye,e[7]=xe):xe=e[7],S=xe;break e}let Pe;e[8]===Symbol.for("react.memo_cache_sentinel")?(Pe=hi(Hl[0]),e[8]=Pe):Pe=e[8],S=Pe}const w=S;if(!y||!n||l.length===0)return null;let f;e[9]!==n?(f=async ve=>{await $m(n,ve.id,ve.appName)||await zm(n,ve.appName)},e[9]=n,e[10]=f):f=e[10];const x=f;let v;e[11]!==x||e[12]!==m?(v=async ve=>{await m(ve.id),await x(ve)},e[11]=x,e[12]=m,e[13]=v):v=e[13];const p=v;let N;e[14]!==n||e[15]!==i?(N=async()=>{(await wn(n)).ok&&_e.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=N):N=e[16];const C=N;let k;e[17]!==r?(k=Me("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=k):k=e[18];let D;e[19]!==x||e[20]!==w?(D=()=>{x(w)},e[19]=x,e[20]=w,e[21]=D):D=e[21];const I=u&&"animate-pulse";let A;e[22]!==I?(A=Me("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",I),e[22]=I,e[23]=A):A=e[23];let P;e[24]!==w.label||e[25]!==i?(P=i("openInApp.actions.openInAria",{app:w.label}),e[24]=w.label,e[25]=i,e[26]=P):P=e[26];let T;e[27]!==w.fallbackIconDataUrl||e[28]!==w.iconDataUrl||e[29]!==w.label?(T=s.jsx(ql,{label:w.label,iconDataUrl:w.iconDataUrl,fallbackIconDataUrl:w.fallbackIconDataUrl}),e[27]=w.fallbackIconDataUrl,e[28]=w.iconDataUrl,e[29]=w.label,e[30]=T):T=e[30];let _;e[31]!==A||e[32]!==P||e[33]!==T||e[34]!==D?(_=s.jsx("button",{type:"button",onClick:D,className:A,"aria-label":P,children:T}),e[31]=A,e[32]=P,e[33]=T,e[34]=D,e[35]=_):_=e[35];let L;e[36]===Symbol.for("react.memo_cache_sentinel")?(L=Me("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=L):L=e[36];let W;e[37]!==i?(W=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=W):W=e[38];let O;e[39]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(M,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=O):O=e[39];let $;e[40]!==W?($=s.jsx(Ls,{asChild:!0,children:s.jsx("button",{type:"button",className:L,"aria-label":W,children:O})}),e[40]=W,e[41]=$):$=e[41];let j;e[42]!==C?(j=()=>{C()},e[42]=C,e[43]=j):j=e[43];let E;e[44]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(M,{name:"file-copy",className:"h-4 w-4"}),e[44]=E):E=e[44];let K;e[45]!==i?(K=i("openInApp.actions.copyPath"),e[45]=i,e[46]=K):K=e[46];let ee;e[47]!==K?(ee=s.jsx("span",{className:"typography-ui-label text-foreground",children:K}),e[47]=K,e[48]=ee):ee=e[48];let J;e[49]!==j||e[50]!==ee?(J=s.jsxs(Kt,{className:"flex items-center gap-2",onClick:j,children:[E,ee]}),e[49]=j,e[50]=ee,e[51]=J):J=e[51];let ne;e[52]===Symbol.for("react.memo_cache_sentinel")?(ne=s.jsx(Rs,{}),e[52]=ne):ne=e[52];let ue;if(e[53]!==l||e[54]!==p||e[55]!==w.id){let ve;e[57]!==p||e[58]!==w.id?(ve=ye=>{const Pe=hi(ye);return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{p(ye)},children:[s.jsx(ql,{label:ye.label,iconDataUrl:ye.iconDataUrl,fallbackIconDataUrl:Pe.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:ye.label}),w.id===ye.id?s.jsx(M,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},ye.id)},e[57]=p,e[58]=w.id,e[59]=ve):ve=e[59],ue=l.map(ve),e[53]=l,e[54]=p,e[55]=w.id,e[56]=ue}else ue=e[56];let X;e[60]!==a||e[61]!==h||e[62]!==i?(X=a?s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(M,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=h,e[62]=i,e[63]=X):X=e[63];let te;e[64]!==J||e[65]!==ue||e[66]!==X?(te=s.jsxs($s,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[J,ne,ue,X]}),e[64]=J,e[65]=ue,e[66]=X,e[67]=te):te=e[67];let fe;e[68]!==$||e[69]!==te?(fe=s.jsxs(zs,{children:[$,te]}),e[68]=$,e[69]=te,e[70]=fe):fe=e[70];let je;return e[71]!==_||e[72]!==fe||e[73]!==k?(je=s.jsxs("div",{className:k,children:[_,fe]}),e[71]=_,e[72]=fe,e[73]=k,e[74]=je):je=e[74],je};function bb(t){return t.selectedAppId}function yb(t){return t.availableApps}function wb(t){return t.isCacheStale}function vb(t){return t.isScanning}function Sb(t){return t.initialize}function jb(t){return t.loadInstalledApps}function kb(t){return t.selectApp}function Cb(t){return t.id===zx}const Bo=new Map,Ji=new Set,tf=()=>{for(const t of Ji)t()},pi=(t,e)=>{const n=t.trim();n&&(e.length===0?Bo.delete(n):Bo.set(n,[...e]),tf())},Nb=t=>{Bo.delete(t.trim())&&tf()},sf=[],Ab=t=>Bo.get(t.trim())??sf,Db=t=>(Ji.add(t),()=>{Ji.delete(t)}),Pb=t=>{const e=et.c(2);let n;return e[0]!==t?(n=()=>Ab(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(Db,n,Ib)};function Ib(){return sf}const Tb=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Eb=["dev","start","preview","serve"];async function Rb(t,e,n){if(!t)return null;const r=Bb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Fb(n);if(i){const o=await _b(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await Mb(t)){const i=await Ob(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function Mb(t){const e=`${t}/index.html`,n=await Fo(e,t);return typeof n=="string"&&n.trim().length>0}async function Ob(){try{const t=await ms("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Bb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Eb.some(i=>n.includes(i)))return e}return null}function Fb(t){for(const{pattern:e}of Tb)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function _b(t){const e=await Fo(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of n){const o=await Fo(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Fo(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ms(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Od()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await ms(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Lb(t){try{const e=await Fo(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const mn="__openchamber_auto_discover_preview__",$b=15e3,zb=3e3,gi=t=>t.id===mn?"scan-2":jh.find(n=>n.key===t.icon)?.Icon??"play",Wb=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},Kb=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=vt(),{currentTheme:l}=ar(),{terminal:a,runtime:u}=Cn(),d=lr(),{isMobile:h}=Vn(),m=c.useMemo(()=>vn(),[]),g=xl(U=>U.instances),b=xl(U=>U.load),y=De(U=>U.terminalShell),S=De(U=>U.terminalLoginShells.includes(U.terminalShell)),w=De(U=>U.setSettingsPage),f=De(U=>U.setSettingsDialogOpen),x=De(U=>U.setSettingsProjectsSelectedId),v=De(U=>U.openContextPreview),p=Bt(U=>U.ensureDirectory),N=Bt(U=>U.reconcileServerSessions),C=Bt(U=>U.setTabLabel),k=Bt(U=>U.setTabIconKey),D=Bt(U=>U.setActiveTab),I=Bt(U=>U.setConnecting),A=Bt(U=>U.setTabSessionId),P=Bt(U=>U.setTabPurpose),T=Bt(U=>U.allocateActionExecution),_=Bt(U=>U.setTabLifecycle),L=Bt(U=>U.setTabPreviewUrl),W=Bt(U=>U.matchesActionExecution),O=Bt(U=>U.captureStartedActionMutationRevisions),[$,j]=c.useState([]),E=c.useRef(null),[K,ee]=c.useState(null),[J,ne]=c.useState(!1),ue=c.useRef({}),X=c.useRef({}),te=c.useRef({}),fe=c.useRef(new Set),je=c.useRef(0),[ve,ye]=c.useState({}),Pe=t?.id??null,xe=t?.path??"",R=c.useMemo(()=>Pe?{id:Pe,path:xe}:null,[Pe,xe]);c.useEffect(()=>{m&&b().catch(()=>{})},[m,b]);const Y=c.useCallback(async U=>{await Yo(U)},[]),ie=c.useCallback(async()=>{if(!R)return;const U=je.current+1;je.current=U,ne(!0);try{const Z=await Sl(R);if(je.current!==U)return;E.current=Z;const ke=Z.projectActions;j(ke),ee(Te=>Te===mn||Te&&ke.some(We=>We.id===Te)?Te:null)}catch{if(je.current!==U)return}finally{je.current===U&&ne(!1)}},[R]),H=c.useMemo(()=>ui(e||R?.path||""),[e,R?.path]),me=c.useMemo(()=>ui(R?.path||""),[R?.path]),pe=c.useMemo(()=>ui(d||"")||H,[d,H]),re=c.useRef(pe);c.useEffect(()=>{re.current=pe},[pe]);const de=Bt(U=>H?U.getDirectoryState(H):void 0),B=Bt(U=>me&&me!==H?U.getDirectoryState(me):void 0),F=c.useMemo(()=>{const U=H?[{directory:H,state:de}]:[];return me&&me!==H&&U.push({directory:me,state:B}),U},[de,H,me,B]),he=c.useMemo(()=>{const U=H?[H]:[];return me&&me!==H&&U.push(me),U},[H,me]),Se=c.useCallback(U=>U.id!==mn&&U.runIn==="parent"&&me||H,[H,me]),Re=c.useCallback((U,Z,ke)=>`${U}::${Z}::${ke}`,[]),le=c.useCallback((U,Z,ke=Bt.getState())=>U?ke.getDirectoryState(U)?.tabs.find(Te=>Te.purpose.type==="project-action"&&Te.purpose.actionId===Z)??null:null,[]),se=c.useMemo(()=>{const U={};for(const{directory:Z,state:ke}of F)for(const Te of ke?.tabs??[]){if(Te.purpose.type!=="project-action"||!Te.purpose.executionId||!Te.terminalSessionId||Te.lifecycle==="idle"||Te.lifecycle==="exited")continue;const We=un(Z,Te.purpose.actionId),Je=Re(Z,Te.purpose.actionId,Te.purpose.executionId);U[We]={directory:Z,actionId:Te.purpose.actionId,tabId:Te.id,sessionId:Te.terminalSessionId,executionId:Te.purpose.executionId,status:Te.lifecycle==="stopping"?"stopping":ve[Je]?"waiting-for-preview":"running"}}return U},[Re,ve,F]),q=c.useCallback((U,Z,ke)=>{const Te=un(U,Z),We=Re(U,Z,ke),nt=ue.current[Te]?.executionId===ke,rt=globalThis.window,Ye=Nt=>{rt?.clearTimeout(te.current[Nt]),delete te.current[Nt]};nt&&(delete ue.current[Te],Ye(Te)),X.current[We]?.(),delete X.current[We],Ye(We),ye(Nt=>{if(!Nt[We])return Nt;const Ke={...Nt};return delete Ke[We],Ke})},[Re]),z=c.useCallback(U=>{X.current[U]?.(),delete X.current[U]},[]),ae=c.useCallback(U=>{window.clearTimeout(te.current[U]),delete te.current[U]},[]);c.useEffect(()=>{const U=X.current,Z=te.current;return()=>{for(const ke of Object.keys(U))z(ke);for(const ke of Object.keys(Z))ae(ke)}},[ae,z]),c.useEffect(()=>{const U=new Set(he);for(const Z of Object.values(ue.current))U.has(Z.directory)||q(Z.directory,Z.actionId,Z.executionId);for(const Z of Object.keys(X.current)){const ke=Z.split("::",1)[0]??"";U.has(ke)||z(Z)}},[q,z,he]);const ce=c.useCallback((U,Z)=>{De.getState().openContextPanelTab(U,{mode:"terminal",targetDirectory:Z===U?null:Z})},[]),Ne=c.useMemo(()=>K?$.find(U=>U.id===K)??null:null,[$,K]),we=c.useMemo(()=>({id:mn,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),$e=!h,Oe=c.useMemo(()=>$e?[we,...$]:$,[$,we,$e]);c.useEffect(()=>{ie()},[ie]),c.useEffect(()=>{const U=he.map(Z=>Mi(a,Z,O,ke=>N(Z,ke.sessions,{startedActionMutationRevisions:ke.startedActionMutationRevisions})));return()=>{for(const Z of U)Z()}},[O,N,a,he]),c.useEffect(()=>{for(const{directory:U,state:Z}of F)if(U)for(const ke of Z?.tabs??[]){if(ke.purpose.type!=="project-action")continue;const Te=ke.purpose.actionId,We=Oe.find(rt=>rt.id===Te),Je=We?.name??Te,nt=We?.icon||"play";ke.label!==Je&&C(U,ke.id,Je),ke.iconKey!==nt&&k(U,ke.id,nt)}},[Oe,k,C,F]),c.useEffect(()=>{const U=globalThis.window;if(!U)return;const Z=ke=>{const Te=ke.detail;Pe&&(Te?.projectId&&Te.projectId!==Pe||ie())};return U.addEventListener(bl,Z),()=>{U.removeEventListener(bl,Z)}},[ie,Pe]),c.useEffect(()=>{K&&(K===mn&&$e||$.some(U=>U.id===K)||ee(null))},[$,$e,K]),c.useEffect(()=>{const U=ke=>{delete te.current[ke];const Te=ue.current[ke];if(!Te||Te.openedUrl)return;const We=Re(Te.directory,Te.actionId,Te.executionId),Je=Te.announced;if(Je.length!==0){if(window.clearTimeout(te.current[We]),delete te.current[We],Te.openedUrl=!0,ye(nt=>{if(!nt[We])return nt;const rt={...nt};return delete rt[We],rt}),Je.length===1){pi(Te.directory,[]),L(Te.directory,Te.tabId,Je[0],{locked:!1,autoOpened:!0}),v(Te.directory,Je[0]);return}Te.offering=!0,pi(Te.directory,Je),De.getState().openContextSurface(Te.directory,"browser"),_e.info(o("projectActions.toast.multipleServers"))}},Z=()=>{const ke=Bt.getState(),Te=ke.sessions,We=se;for(const[Je,nt]of Object.entries(We)){const Ye=Te.get(nt.directory)?.tabs.find(pt=>pt.id===nt.tabId);if(!Ye||Ye.terminalSessionId!==nt.sessionId){q(nt.directory,nt.actionId,nt.executionId);continue}const Nt=ue.current[Je],Ke=Nt?.executionId===nt.executionId?Nt:{hostDirectory:re.current||nt.directory,directory:nt.directory,tabId:nt.tabId,actionId:nt.actionId,executionId:nt.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};ue.current[Je]=Ke;const Tt=Oe.find(pt=>pt.id===nt.actionId),Ce=ke.getBuffer(nt.directory,nt.tabId).chunks;if(!Tt||Ce.length===0)continue;const ft=Ce.filter(pt=>Ke.lastSeenChunkId===null||pt.id>Ke.lastSeenChunkId);if(ft.length===0)continue;const bt=ft.map(pt=>pt.data).join(""),jt=`${Ke.tail}${bt}`;if(Ke.openInPreview&&(!Ke.openedUrl||Ke.offering)){const pt=vh(jt),Be=Ke.announced.length;for(const qe of pt)Ke.announced.includes(qe)||Ke.announced.push(qe);const ze=Ke.announced.length-Be;Ke.offering&&ze>0?pi(nt.directory,Ke.announced):!Ke.openedUrl&&Be===0&&Ke.announced.length>0&&(window.clearTimeout(te.current[Je]),te.current[Je]=window.setTimeout(()=>U(Je),zb))}const Ge=!Ke.openedUrl&&Tt.autoOpenUrl===!0&&!Ke.openInPreview?Sh(jt):null,Le=ft[ft.length-1]?.id??Ke.lastSeenChunkId;if(Ke.lastSeenChunkId=Le,Ke.tail=jt.slice(-512),Ge)if(Ke.openedUrl=!0,Ke.openInPreview){const pt=We[Je];pt&&(L(pt.directory,pt.tabId,Ge,{locked:!1,autoOpened:!1,expectedExecutionId:pt.executionId}),pt.status==="waiting-for-preview"&&ye(Be=>{const ze=Re(pt.directory,pt.actionId,pt.executionId);if(!Be[ze])return Be;const qe={...Be};return delete qe[ze],qe}),window.clearTimeout(te.current[Je]),delete te.current[Je],v(pt.directory,Ge))}else Y(Ge),_e.success(o("projectActions.toast.openedUrlFromOutput"));ue.current[Je]=Ke}for(const Je of Object.keys(ue.current))if(!We[Je]){const nt=ue.current[Je],rt=nt?Te.get(nt.directory)?.tabs.find(Nt=>Nt.id===nt.tabId):void 0;if(rt?.purpose.type==="project-action"&&rt.purpose.executionId===nt?.executionId&&!!rt.terminalSessionId&&rt.lifecycle!=="idle"&&rt.lifecycle!=="exited")continue;delete ue.current[Je],window.clearTimeout(te.current[Je]),delete te.current[Je]}};return Z(),Bt.subscribe((ke,Te)=>{(ke.sessions!==Te.sessions||ke.buffers!==Te.buffers)&&Z()})},[q,re,Oe,Re,v,Y,se,L,o]),c.useEffect(()=>{for(const{directory:U,state:Z}of F)for(const ke of Z?.tabs??[]){if(ke.purpose.type!=="project-action"||!ke.purpose.executionId||!ke.terminalSessionId||ke.lifecycle!=="running")continue;const Te=ke.purpose.actionId,We=ke.purpose.executionId,Je=Re(U,Te,We);if(X.current[Je])continue;const nt=a.connect(ke.terminalSessionId,{onEvent:rt=>{if(!W(U,ke.id,We))return;rt.type==="snapshot"&&(Bt.getState().replaceBuffer(U,ke.id,rt.data??"",rt.sequence??0,cl(rt)),rt.status==="running"&&Bt.getState().setTabLifecycle(U,ke.id,"running",{expectedExecutionId:We}),rt.status==="exited"&&(Bt.getState().setTabLifecycle(U,ke.id,"exited",{expectedExecutionId:We}),Bt.getState().setTabPurpose(U,ke.id,{type:"project-action",actionId:Te,executionId:null}),q(U,Te,We)));const Ye=rt.type==="data"?rt.data??"":"";Ye&&Bt.getState().appendToBuffer(U,ke.id,Ye,rt.sequence,rt.replayData),rt.type==="exit"&&(Bt.getState().setTabLifecycle(U,ke.id,"exited",{expectedExecutionId:We}),Bt.getState().setTabPurpose(U,ke.id,{type:"project-action",actionId:Te,executionId:null}),q(U,Te,We))},onError:(rt,Ye)=>{!Ye||!W(U,ke.id,We)||(Bt.getState().setTabLifecycle(U,ke.id,"exited",{expectedExecutionId:We}),Bt.getState().setTabSessionId(U,ke.id,null,{expectedExecutionId:We}),Bt.getState().setTabPurpose(U,ke.id,{type:"project-action",actionId:Te,executionId:null}),q(U,Te,We))}});X.current[Je]=nt.close}},[q,Re,W,a,F]);const ge=c.useCallback(async U=>{const Z=Se(U);if(!Z)throw new Error(o("projectActions.error.noActiveDirectory"));const ke=un(Z,U.id);p(Z);const Te=Bt.getState(),We=le(Z,U.id,Te),Je=We?.id??Te.createTab(Z);C(Z,Je,U.name),k(Z,Je,U.icon||"play"),We||P(Z,Je,{type:"project-action",actionId:U.id,executionId:null}),D(Z,Je);const rt=Bt.getState().getDirectoryState(Z)?.tabs.find(Ye=>Ye.id===Je);return{executionDirectory:Z,key:ke,tabId:Je,sessionId:rt?.terminalSessionId??null,executionId:rt?.purpose.type==="project-action"?rt.purpose.executionId:null}},[p,Se,le,D,k,C,P,o]),He=c.useCallback(async U=>{if(u.isVSCode||!i&&h)return;if(!H){_e.error(o("projectActions.error.noActiveDirectoryForAction"));return}const Z=un(Se(U),U.id),ke=se[Z];if(ke&&ke.status==="running"||fe.current.has(Z))return;fe.current.add(Z);let Te=null;try{const We=U.id===mn?await(async()=>{const[ze,qe]=await Promise.all([Zh({id:R?.id??"",path:H}),Lb(H)]),tt=await Rb(H,ze.actions,qe);if(!tt)throw new Error(o("contextPanel.preview.noDevServer"));return{id:mn,name:o("projectActions.actions.autoDiscover"),command:tt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:tt.previewUrlHint||""}})():U,Je=We.autoOpenUrl===!0&&(We.openUrl||"").trim().length>0,nt=!Je&&U.id!==mn,rt=re.current||H,{executionDirectory:Ye,key:Nt,tabId:Ke}=await ge(We),Tt=gh(We.command);if(!Tt)throw new Error(o("projectActions.error.failedToRunAction"));const Ce=We.autoOpenUrl===!0&&m&&(We.desktopOpenSshForward||"").trim().length>0,ft=We.autoOpenUrl?Wb(We.openUrl):null,bt=We.autoOpenUrl&&m?xh(We.desktopOpenSshForward,g):null;if(a.listSessions){const ze=le(Ye,We.id);if(ze?.purpose.type==="project-action"&&ze.purpose.executionId===null){const qe=await bh(a,Ye,{captureStartedActionMutationRevisions:O});qe&&N(Ye,qe.sessions,{startedActionMutationRevisions:qe.startedActionMutationRevisions})}}const jt=le(Ye,We.id);let Ge,Le;if(jt?.lifecycle==="running"&&jt.terminalSessionId&&jt.purpose.type==="project-action"&&jt.purpose.executionId)Ge=jt.terminalSessionId,Le=jt.purpose.executionId;else{const ze=jt?.purpose.type==="project-action"?jt.purpose.executionId:null;ze&&q(Ye,We.id,ze);const qe=T(Ye,Ke,We.id);if(!qe)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));Te={directory:Ye,tabId:Ke,id:qe},I(Ye,Ke,!0,{expectedExecutionId:qe});const tt=await yh({terminal:a,createOptions:{cwd:Ye,shell:y,loginShell:S,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:Tt,isRunStillExpected:()=>W(Ye,Ke,qe),purpose:{type:"project-action",actionId:We.id,executionId:qe}});if(!W(Ye,Ke,qe)){tt.sessionId===qe&&await a.close(tt.sessionId).catch(()=>{});return}Le=tt.purpose?.type==="project-action"?tt.purpose.executionId:qe,Ge=tt.sessionId,P(Ye,Ke,{type:"project-action",actionId:We.id,executionId:Le}),A(Ye,Ke,Ge,{expectedExecutionId:Le}),I(Ye,Ke,!1,{expectedExecutionId:Le})}nt&&rt&&ce(rt,Ye),ue.current[Nt]={hostDirectory:rt,directory:Ye,tabId:Ke,actionId:We.id,executionId:Le,lastSeenChunkId:null,openedUrl:!!bt||!!ft||Je,tail:"",openInPreview:We.id===mn,announced:[],offering:!1};const pt=Re(Ye,We.id,Le);I(Ye,Ke,!0,{expectedExecutionId:Le});const Be=a.connect(Ge,{onEvent:ze=>{if(!W(Ye,Ke,Le)||ze.purpose?.type==="project-action"&&ze.purpose.executionId!==Le)return;ze.type==="snapshot"&&(Bt.getState().replaceBuffer(Ye,Ke,ze.data??"",ze.sequence??0,cl(ze)),Bt.getState().setConnecting(Ye,Ke,!1,{expectedExecutionId:Le}),ze.purpose?.type==="project-action"&&Bt.getState().setTabPurpose(Ye,Ke,{type:"project-action",actionId:ze.purpose.actionId,executionId:ze.purpose.executionId}),ze.status==="running"&&Bt.getState().setTabLifecycle(Ye,Ke,"running",{expectedExecutionId:Le}),ze.status==="exited"&&(Bt.getState().setTabLifecycle(Ye,Ke,"exited",{expectedExecutionId:Le}),Bt.getState().setTabPurpose(Ye,Ke,{type:"project-action",actionId:We.id,executionId:null}),q(Ye,We.id,Le)));const qe=ze.type==="data"?ze.data??"":"";qe&&Bt.getState().appendToBuffer(Ye,Ke,qe,ze.sequence,ze.replayData),ze.type==="exit"&&(Bt.getState().setTabLifecycle(Ye,Ke,"exited",{expectedExecutionId:Le}),Bt.getState().setConnecting(Ye,Ke,!1,{expectedExecutionId:Le}),Bt.getState().setTabPurpose(Ye,Ke,{type:"project-action",actionId:We.id,executionId:null}),q(Ye,We.id,Le))},onError:(ze,qe)=>{W(Ye,Ke,Le)&&(Bt.getState().setConnecting(Ye,Ke,!1,{expectedExecutionId:Le}),qe&&(Bt.getState().setTabLifecycle(Ye,Ke,"exited",{expectedExecutionId:Le}),Bt.getState().setTabSessionId(Ye,Ke,null,{expectedExecutionId:Le}),Bt.getState().setTabPurpose(Ye,Ke,{type:"project-action",actionId:We.id,executionId:null}),q(Ye,We.id,Le)))}});if(!W(Ye,Ke,Le)){Be.close();return}X.current[pt]?.(),X.current[pt]=Be.close,window.clearTimeout(te.current[pt]),delete te.current[pt],We.id===mn&&!ft&&(ye(ze=>({...ze,[pt]:!0})),te.current[pt]=window.setTimeout(()=>{delete te.current[pt];const ze=ue.current[Nt];!ze||ze.executionId!==Le||ze.openedUrl||ze.offering||W(Ye,Ke,Le)&&(ye(qe=>{if(!qe[pt])return qe;const tt={...qe};return delete tt[pt],tt}),Bt.getState().setActiveTab(Ye,Ke),ce(ze.hostDirectory,Ye))},$b)),bt?(L(Ye,Ke,null,{locked:!0,expectedExecutionId:Le}),Y(bt),_e.success(o("projectActions.toast.openedForwardedUrl"))):ft?(L(Ye,Ke,ft,{locked:!0,autoOpened:!0,expectedExecutionId:Le}),v(rt,ft),_e.success(o("projectActions.toast.openedActionUrl"))):Je?(L(Ye,Ke,null,{locked:!0,expectedExecutionId:Le}),_e.error(o("projectActions.error.invalidCustomUrlFormat"))):Ce?(L(Ye,Ke,null,{locked:!0,expectedExecutionId:Le}),_e.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):L(Ye,Ke,null,{locked:!1,autoOpened:!1,expectedExecutionId:Le})}catch(We){if(Te&&W(Te.directory,Te.tabId,Te.id)){const{directory:Je,tabId:nt,id:rt}=Te;q(Je,U.id,rt),_(Je,nt,"exited",{expectedExecutionId:rt}),P(Je,nt,{type:"project-action",actionId:U.id,executionId:null})}if(We instanceof Error&&We.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(We instanceof Error&&(We.message==="COMMAND_MODE_UNSUPPORTED"||We.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){_e.error(o("projectActions.error.failedToCreateTerminalSession"));return}_e.error(We instanceof Error?We.message:o("projectActions.error.failedToRunAction"))}finally{fe.current.delete(Z)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,re,g,ge,i,h,m,H,S,y,Y,v,se,ce,u.isVSCode,Se,W,q,Re,le,N,T,O,I,_,P,L,A,R?.id,o,a]),V=c.useCallback(async U=>{const Z=un(Se(U),U.id),ke=se[Z];ke&&await wh({terminal:a,sessionId:ke.sessionId,isExecutionStillCurrent:()=>W(ke.directory,ke.tabId,ke.executionId),markStopping:()=>{_(ke.directory,ke.tabId,"stopping",{expectedExecutionId:ke.executionId})},restoreRunning:()=>{_(ke.directory,ke.tabId,"running",{expectedExecutionId:ke.executionId})},clearSession:()=>{A(ke.directory,ke.tabId,null,{expectedExecutionId:ke.executionId})},finalizeExit:()=>{_(ke.directory,ke.tabId,"exited",{expectedExecutionId:ke.executionId}),P(ke.directory,ke.tabId,{type:"project-action",actionId:ke.actionId,executionId:null}),q(ke.directory,ke.actionId,ke.executionId)}})},[q,Se,W,se,_,P,A,a]),Ae=c.useCallback(()=>{const U=Ne??Oe[0];if(!U)return;const Z=un(Se(U),U.id),ke=se[Z];if(ke?.status!=="stopping"){if(ke){V(U);return}He(U)}},[Oe,Se,He,se,Ne,V]),Ie=c.useCallback(async U=>{if(U.source==="shared"&&R){const Z=E.current?.trust.trusted?E.current:await Sl(R);if(E.current=Z,!await ep(R,Z))return;E.current={...Z,trust:{...Z.trust,trusted:!0}}}await He(U)},[He,R]),Fe=c.useCallback((U,Z=!1)=>{if(ee(U.id),!Z){Ie(U);return}const ke=un(Se(U),U.id),Te=se[ke];if(Te?.status!=="stopping"){if(Te){V(U);return}Ie(U)}},[Se,Ie,se,V]),st=c.useCallback(()=>{R?.id&&(x(R.id),w("projects"),f(!0))},[f,w,x,R?.id]),lt=Ne??Oe[0]??null,it=lt?se[un(Se(lt),lt.id)]:null,mt=Bt(U=>it?U.getDirectoryState(it.directory)?.tabs.find(Z=>Z.id===it.tabId)?.previewUrl??null:null);if(u.isVSCode||!i&&h||!R||!H)return null;const St=Ne??Oe[0]??null;if(!St)return null;const ht=gi(St),Xe=un(Se(St),St.id),Ct=se[Xe],Mt=Ct?.status==="stopping",be=Ct?.status==="waiting-for-preview",Ue=!!(Ct&&mt),ut=()=>{!Ct||!mt||v(Ct.directory,mt)},G=St.id===mn;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:J||Mt,className:Me("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-not-allowed",n),onClick:Ae,"aria-label":Ct?o("projectActions.actions.stopNamedAria",{name:St.name}):o("projectActions.actions.runNamedAria",{name:St.name}),children:Mt||be?s.jsx(M,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):Ct?s.jsx(M,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(M,{name:ht,className:"h-5 w-5"})})}),G?s.jsx(It,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Ue?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.openPreview"),onClick:ut,children:s.jsx(M,{name:"global",className:"h-4 w-4"})})}),s.jsx(It,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(zs,{children:[s.jsx(Ls,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(M,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs($s,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Kt,{className:"flex items-center gap-2",onClick:st,children:[s.jsx(M,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Rs,{}),Oe.map(U=>{const Z=gi(U),ke=un(Se(U),U.id),Te=se[ke],We=!!Te,Je=Te?.status==="stopping";return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{Fe(U,!0)},children:[s.jsx(M,{name:Z,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:U.name}),U.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Je||Te?.status==="waiting-for-preview"?s.jsx(M,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):We?s.jsx(M,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},U.id)})]})]})]}):s.jsxs("div",{className:Me("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ae,disabled:J||Mt,className:Me("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed"),"aria-label":Ct?o("projectActions.actions.stopNamedAria",{name:St.name}):o("projectActions.actions.runNamedAria",{name:St.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:Mt||be?s.jsx(M,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ct?s.jsx(M,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(M,{name:ht,className:"h-4 w-4"})})})}),G?s.jsx(It,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Ue?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ut,className:Me(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(M,{name:"global",className:"h-4 w-4"})})}),s.jsx(It,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(zs,{children:[s.jsx(Ls,{asChild:!0,children:s.jsx("button",{type:"button",className:Me(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(M,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs($s,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Kt,{className:"flex items-center gap-2",onClick:st,children:[s.jsx(M,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Rs,{}),Oe.map(U=>{const Z=gi(U),ke=un(Se(U),U.id),Te=se[ke],We=!!Te,Je=Te?.status==="stopping";return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{Fe(U,!0)},children:[s.jsx(M,{name:Z,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:U.name}),U.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Je||Te?.status==="waiting-for-preview"?s.jsx(M,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):We?s.jsx(M,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},U.id)})]})]})]})},Vr=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Vb=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=Vr(n??"");if(i){const o=Jd(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function Ub(){const t=Gt(y=>y.projects),e=Gt(y=>y.activeProjectId),n=Ze(y=>y.availableWorktreesByProject),r=Ze(y=>y.currentSessionId),i=tp(r??null),o=Ze(y=>r?y.worktreeMetadata.get(r)?.path??"":""),l=Ze(y=>y.newSessionDraft?.open?Vr(y.newSessionDraft.bootstrapPendingDirectory??y.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>Vr(o||""),[o]),u=c.useMemo(()=>{const y=typeof i?.directory=="string"?i.directory:"";return Vr(y||"")},[i?.directory]),d=a||u||l,h=c.useMemo(()=>Vb({projects:t,worktreesByProject:n,directory:d,activeProjectId:e}),[e,d,t,n]),m=c.useMemo(()=>Vr(d||h?.path||""),[d,h?.path]),g=c.useMemo(()=>h?{id:h.id,path:h.path}:null,[h]),b=c.useRef(null);return c.useEffect(()=>{g&&m&&(b.current={projectRef:g,directory:m})},[m,g]),c.useMemo(()=>g&&m?{projectRef:g,directory:m}:b.current,[g,m])}const Hb=({transform:t})=>({...t,y:0}),Gb={Item:Kt,Separator:Rs},qb={Item:({className:t,...e})=>s.jsx(qu,{className:Me(tu,t),...e}),Separator:({className:t,...e})=>s.jsx(Gu,{className:Me(eu,t),...e})},Yb=t=>{const e=et.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:u,onMenuOpenChangeComplete:d,children:h}=t,{t:m}=vt(),[g,b]=c.useState(!1),[y,S]=c.useState(!1),[w,f]=c.useState(!1);let x;e[0]!==n.id?(x={id:n.id},e[0]=n.id,e[1]=x):x=e[1];const{attributes:v,listeners:p,setNodeRef:N,transform:C,transition:k,isDragging:D}=ii(x);let I;e[2]!==m||e[3]!==n.session.title?(I=n.session.title?.trim()||m("sessions.sidebar.session.untitled"),e[2]=m,e[3]=n.session.title,e[4]=I):I=e[4];const A=I,P=!i&&(g||y),T=Na(n.id),_=n.id;let L;e[5]!==n.session?(L=Ps(n.session),e[5]=n.session,e[6]=L):L=e[6];const W=Ca(_,L),O=T?.type==="busy"||T?.type==="retry",j=Zd(n.id)>0&&!r&&!O,E=O||j;let K;e[7]!==O||e[8]!==m?(K=m(O?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=O,e[8]=m,e[9]=K):K=e[9];const ee=K;let J;e[10]!==u||e[11]!==w||e[12]!==r||e[13]!==g||e[14]!==o||e[15]!==n?(J=pe=>({session:n.session,open:g||w,isActive:r,select:()=>o(n),closeOtherTabs:()=>u(n.id),components:pe}),e[10]=u,e[11]=w,e[12]=r,e[13]=g,e[14]=o,e[15]=n,e[16]=J):J=e[16];const ne=J;let ue;e[17]!==C?(ue=ai.Translate.toString(C),e[17]=C,e[18]=ue):ue=e[18];let X;e[19]!==ue||e[20]!==k?(X={transform:ue,transition:k},e[19]=ue,e[20]=k,e[21]=X):X=e[21];const te=D&&"z-10 opacity-60";let fe;e[22]!==te?(fe=Me("session-tab-slot flex h-7 w-44 shrink-0 touch-none",te),e[22]=te,e[23]=fe):fe=e[23];const je=r?"true":"false";let ve;e[24]!==r?(ve=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=ve):ve=e[25];let ye;e[26]!==d?(ye=pe=>d?.(pe),e[26]=d,e[27]=ye):ye=e[27];let Pe;e[28]!==h||e[29]!==ee||e[30]!==r||e[31]!==W||e[32]!==O||e[33]!==ne||e[34]!==g||e[35]!==l||e[36]!==d||e[37]!==o||e[38]!==P||e[39]!==a||e[40]!==E||e[41]!==i||e[42]!==m||e[43]!==n||e[44]!==A?(Pe=s.jsx(Yu,{render:pe=>s.jsxs("div",{...pe,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:re=>{(re.key==="Enter"||re.key===" ")&&(re.preventDefault(),o(n))},onAuxClick:re=>{re.button===1&&(re.preventDefault(),l(n.id))},"data-controls-open":P?"true":"false",className:Me("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection text-interactive-selection-foreground":Me("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",P&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Me("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",P&&"pr-10"),children:[s.jsx("div",{className:Me("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:A})})}),W?s.jsx(M,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":m("sessions.aiRename.generating")}):E?s.jsx("span",{className:Me("ml-1.5 h-1.5 w-1.5 shrink-0 rounded-full",O?"bg-primary":"bg-[var(--status-info)]",!i&&"group-hover/session-tab:opacity-0",P&&"opacity-0"),"aria-label":ee}):null]}),i?null:s.jsxs("div",{onClick:Xb,onPointerDown:Jb,className:Me("absolute right-1 top-1/2 hidden -translate-y-1/2 items-center gap-0.5","opacity-0 transition-opacity duration-150","group-hover/session-tab:flex group-hover/session-tab:opacity-100",P&&"flex opacity-100"),children:[s.jsxs(zs,{open:g,onOpenChange:re=>{b(re),re&&S(!0)},onOpenChangeComplete:re=>{re||S(!1),d?.(re)},children:[s.jsx(Ls,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":m("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"more",className:"size-4"})})}),s.jsx($s,{align:"start",className:"min-w-[190px]",children:a(ne(Gb))})]}),s.jsx("button",{type:"button","aria-label":m("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]})]})}),e[28]=h,e[29]=ee,e[30]=r,e[31]=W,e[32]=O,e[33]=ne,e[34]=g,e[35]=l,e[36]=d,e[37]=o,e[38]=P,e[39]=a,e[40]=E,e[41]=i,e[42]=m,e[43]=n,e[44]=A,e[45]=Pe):Pe=e[45];let xe,R;e[46]===Symbol.for("react.memo_cache_sentinel")?(xe={color:"var(--surface-elevated-foreground)"},R=Me(Fi,"min-w-[190px]"),e[46]=xe,e[47]=R):(xe=e[46],R=e[47]);let Y;e[48]!==ne||e[49]!==a?(Y=a(ne(qb)),e[48]=ne,e[49]=a,e[50]=Y):Y=e[50];let ie;e[51]!==Y?(ie=s.jsx(Yi,{children:s.jsx(Qi,{className:"app-region-no-drag z-50",children:s.jsx(Xi,{"data-slot":"dropdown-menu-content",style:xe,className:R,children:Y})})}),e[51]=Y,e[52]=ie):ie=e[52];let H;e[53]!==w||e[54]!==ye||e[55]!==Pe||e[56]!==ie?(H=s.jsxs(Qu,{open:w,onOpenChange:f,onOpenChangeComplete:ye,children:[Pe,ie]}),e[53]=w,e[54]=ye,e[55]=Pe,e[56]=ie,e[57]=H):H=e[57];let me;return e[58]!==v||e[59]!==p||e[60]!==N||e[61]!==fe||e[62]!==je||e[63]!==ve||e[64]!==H||e[65]!==X?(me=s.jsx("div",{ref:N,style:X,className:fe,"data-active":je,...ve,...v,...p,children:H}),e[58]=v,e[59]=p,e[60]=N,e[61]=fe,e[62]=je,e[63]=ve,e[64]=H,e[65]=X,e[66]=me):me=e[66],me},Qb=t=>{const e=et.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=vt(),u=io(Zb),d=io(ey),h=io(ty),m=io(sy),g=Ze(ny),b=Ze(ry),y=_s(oy);let S,w;e[0]!==g||e[1]!==d?(S=()=>{g&&d(g)},w=[g,d],e[0]=g,e[1]=d,e[2]=S,e[3]=w):(S=e[2],w=e[3]),c.useEffect(S,w);let f;if(e[4]!==y){f=new Map;for(const re of y)f.set(re.id,re);e[4]=y,e[5]=f}else f=e[5];const x=f;let v;if(e[6]!==x||e[7]!==u){v=[];for(const re of u){const de=x.get(re);de&&v.push({id:re,session:de})}e[6]=x,e[7]=u,e[8]=v}else v=e[8];const p=v;let N;e[9]!==b?(N=re=>{b(re.id,Ps(re.session))},e[9]=b,e[10]=N):N=e[10];const C=N,k=iy;let D;e[11]!==h||e[12]!==g||e[13]!==C||e[14]!==p?(D=re=>{if(h(re),g&&g!==re){const de=p.find(B=>B.id===re);de&&C(de)}},e[11]=h,e[12]=g,e[13]=C,e[14]=p,e[15]=D):D=e[15];const I=D;let A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A={activationConstraint:{distance:8}},e[16]=A):A=e[16];let P;e[17]===Symbol.for("react.memo_cache_sentinel")?(P={activationConstraint:{delay:200,tolerance:6}},e[17]=P):P=e[17];const T=ti(Tn(ni,A),Tn(si,P));let _;e[18]!==m?(_=re=>{const{active:de,over:B}=re;B&&de.id!==B.id&&m(String(de.id),String(B.id))},e[18]=m,e[19]=_):_=e[19];const L=_,W=c.useRef(null);let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O={left:!1,right:!1},e[20]=O):O=e[20];const[$,j]=c.useState(O);let E;e[21]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const re=W.current;if(!re)return;const de=re.scrollLeft>2,B=re.scrollLeft+re.clientWidth<re.scrollWidth-2;j(F=>F.left===de&&F.right===B?F:{left:de,right:B})},e[21]=E):E=e[21];const K=E;let ee;e[22]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>{K();const re=W.current;if(!re||!globalThis.ResizeObserver)return;const de=new ResizeObserver(K);return de.observe(re),()=>de.disconnect()},e[22]=ee):ee=e[22];let J;e[23]!==p.length?(J=[K,p.length],e[23]=p.length,e[24]=J):J=e[24],c.useEffect(ee,J);let ne;e[25]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>{W.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=ne):ne=e[25];let ue;e[26]!==g?(ue=[g],e[26]=g,e[27]=ue):ue=e[27],c.useEffect(ne,ue);const X=$.left&&$.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":$.left?"linear-gradient(to right, transparent, black 24px)":$.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let te;e[28]!==p?(te=p.map(ay),e[28]=p,e[29]=te):te=e[29];const fe=te;let je;e[30]!==g||e[31]!==p?(je=!g||!p.some(re=>re.id===g),e[30]=g,e[31]=p,e[32]=je):je=e[32];const ve=je;let ye;e[33]!==a?(ye=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=ye):ye=e[34];let Pe;e[35]!==X?(Pe=X?{maskImage:X,WebkitMaskImage:X}:void 0,e[35]=X,e[36]=Pe):Pe=e[36];let xe;e[37]===Symbol.for("react.memo_cache_sentinel")?(xe=[Hb],e[37]=xe):xe=e[37];let R;e[38]!==o||e[39]!==g||e[40]!==I||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==p?(R=p.map(re=>s.jsx(Yb,{tab:re,isActive:re.id===g,suppressControls:re.id===g&&l,onSelect:C,onClose:k,renderMenu:n,closeOtherTabs:I,onMenuOpenChangeComplete:r,children:re.id===g?o:null},re.id)),e[38]=o,e[39]=g,e[40]=I,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=p,e[46]=R):R=e[46];let Y;e[47]!==R||e[48]!==fe?(Y=s.jsx(Va,{items:fe,strategy:eb,children:R}),e[47]=R,e[48]=fe,e[49]=Y):Y=e[49];let ie;e[50]!==L||e[51]!==T||e[52]!==Y?(ie=s.jsx(ri,{sensors:T,collisionDetection:oi,modifiers:xe,onDragEnd:L,children:Y}),e[50]=L,e[51]=T,e[52]=Y,e[53]=ie):ie=e[53];let H;e[54]!==o||e[55]!==ve?(H=ve?s.jsx("div",{role:"tab","aria-selected":!0,className:"session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[54]=o,e[55]=ve,e[56]=H):H=e[56];let me;e[57]!==Pe||e[58]!==ie||e[59]!==H?(me=s.jsxs("div",{ref:W,onScroll:K,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:Pe,children:[ie,H]}),e[57]=Pe,e[58]=ie,e[59]=H,e[60]=me):me=e[60];let pe;return e[61]!==ye||e[62]!==me?(pe=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":ye,children:me}),e[61]=ye,e[62]=me,e[63]=pe):pe=e[63],pe};function Xb(t){return t.stopPropagation()}function Jb(t){return t.stopPropagation()}function Zb(t){return t.tabIds}function ey(t){return t.ensureTab}function ty(t){return t.closeOtherTabs}function sy(t){return t.reorderTabs}function ny(t){return t.currentSessionId}function ry(t){return t.setCurrentSession}function oy(t){return t.activeSessions}function iy(t){sp(t)}function ay(t){return t.id}const nf=async t=>{const{entry:e,session:n}=t,r=as(),i={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(np(e.action)&&rp(e.guest,"conversation"))){await jl(e,kl(e.action.id,i),t.t,r);return}let l=!1;const a=eo(()=>{l=!0});let u;try{u=await t.loadRecords()}finally{a()}if(!l){if(!u){t.onLoadFailed();return}await jl(e,kl(e.action.id,i,u),t.t,r)}};function Zi(t){const e=et.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=vt(),{pending:a,disabled:u,hint:d,run:h}=kh(n,r,i),m=a?"loader-4":"ai-generate-2",g=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let b;e[0]!==m||e[1]!==g?(b=s.jsx(M,{name:m,className:g}),e[0]=m,e[1]=g,e[2]=b):b=e[2];let y;e[3]!==l?(y=l("sessions.aiRename.action"),e[3]=l,e[4]=y):y=e[4];let S;e[5]!==o||e[6]!==u||e[7]!==h||e[8]!==b||e[9]!==y?(S=s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:u,onClick:h,className:"w-full",children:[b,y]})})}),e[5]=o,e[6]=u,e[7]=h,e[8]=b,e[9]=y,e[10]=S):S=e[10];let w;e[11]!==d?(w=s.jsx(It,{side:"right",children:d}),e[11]=d,e[12]=w):w=e[12];let f;return e[13]!==S||e[14]!==w?(f=s.jsxs(Dt,{children:[S,w]}),e[13]=S,e[14]=w,e[15]=f):f=e[15],f}const ea=(t,e)=>({success:t(e.success),failure:t(e.failure),sourceVerificationFailed:t("sessions.sidebar.session.moveToWorktree.sourceVerificationFailed"),applyChangesFailed:t("sessions.sidebar.session.moveToWorktree.applyChangesFailed"),changesMayBeInDestination:t("sessions.sidebar.session.moveToWorktree.changesMayBeInDestination")}),Hn=Ar(()=>({pendingSessionIds:new Set,requestingSessionIds:new Set,confirmation:null})),rf=t=>{const e=et.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t)||r.requestingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],Hn(n)},ly=()=>Hn(by),of=()=>Hn.getState().confirmation,Ha=t=>{Hn.setState(e=>e.confirmation===t?e:{...e,confirmation:t})},Yl=(t,e)=>{Hn.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{...n,pendingSessionIds:r}})},gr=(t,e)=>{Hn.setState(n=>{if(n.requestingSessionIds.has(t)===e)return n;const r=new Set(n.requestingSessionIds);return e?r.add(t):r.delete(t),{...n,requestingSessionIds:r}})},cy="Unable to apply your changes in the destination directory",dy=t=>t.status===400&&t.message.includes(cy),uy=async(t,e)=>{try{const u=(await su(t,{mode:"light"})).current?.trim();if(u)return u}catch{}const n=gt(t),r=gt(e)??e,i=Ze.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>gt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},Ql=t=>{for(const e of t){const n=ip(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class af extends Error{changesMayBeInDestination;constructor(e,n,r){super(e,{cause:n}),this.name="IncompleteRollbackError",this.changesMayBeInDestination=r}}const fy=(t,e,n)=>{const r=e.map(({sessionId:i,error:o})=>`${i}: ${o.message}`).join(", ");return new af(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${r}`,{moveError:t,rollbackFailures:e},n)},my=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(ap(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await nu(o,n,e,!1),Ze.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i};class lf extends Error{constructor(e){super(e.message,{cause:e}),this.name="ChangesMayBeInDestinationError"}}const Xl=async(t,e,n)=>{try{await ru(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},Jl=async(t,e)=>{const n=e?[t,e]:[t];try{await Aa(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},cf=async(t,e)=>{if(Hn.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Yl(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,Ze.getState().getWorktreeMetadata(a.id)]));Ql(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,u]of n.entries()){Ql(n.slice(a));const d=u.id===t.root.id&&t.moveChanges;try{await nu(u,t.sourceDirectory,i.directory,d)}catch(h){throw d&&op(h)&&(l=!0),h}o.push(u),u.id!==t.root.id&&Ze.getState().setWorktreeMetadata(u.id,Cl(i.metadata))}}catch(a){const u=a instanceof Error?a:new Error(String(a)),d=await my(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await Jl(t.sourceDirectory,i?.directory),d.length>0)throw fy(u,d,l);if(l)throw new lf(u);if(i?.onMoveFailure)return i.onMoveFailure(u);throw u}return Ze.getState().setWorktreeMetadata(t.root.id,Cl(i.metadata)),await Jl(t.sourceDirectory,i.directory),i.directory}finally{Yl(t.root.id,!1)}},hy=async t=>{const e=gt(t.sourceDirectory)??t.sourceDirectory,n=gt(t.destination.path)??t.destination.path;if(e===n)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return cf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},py=async t=>cf(t,async()=>{const e=_i(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await Qo(t.sourceDirectory)?await uy(t.sourceDirectory,e.path):null,r=await lp(e,n?{startRef:n}:{});try{await cp(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return Xl(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>Xl(e,r,i)}}),gy=(t,e,n)=>e instanceof lf?t.changesMayBeInDestination:e instanceof af&&e.changesMayBeInDestination?`${e.message} ${t.changesMayBeInDestination}`:n&&dy(e)?t.applyChangesFailed:e.message,ta=(t,e)=>{(t.kind==="existing"?hy({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination,moveChanges:e}):py({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,moveChanges:e})).then(()=>_e.success(t.messages.success)).catch(r=>{const i=r instanceof Error?r:new Error(String(r));_e.error(t.messages.failure,{description:gy(t.messages,i,e)})})},xy=()=>{const t=of();t&&(gr(t.intent.root.id,!1),Ha(null))},df=t=>{const e=of();if(!e)return;const{intent:n}=e;Ha(null),gr(n.root.id,!1),ta(n,t)},sa=t=>{const e=Hn.getState();e.confirmation||e.pendingSessionIds.has(t.root.id)||e.requestingSessionIds.has(t.root.id)||(gr(t.root.id,!0),(async()=>{try{if(!await Qo(t.sourceDirectory)){gr(t.root.id,!1),ta(t,!1);return}const r=await su(t.sourceDirectory);if(r.isClean){gr(t.root.id,!1),ta(t,!1);return}const i=r.files.filter(o=>{const l=o.index.trim();return l!==""&&l!=="?"}).length;Ha({intent:t,dirtyFileCount:r.files.length,stagedFileCount:i})}catch{_e.error(t.messages.failure,{description:t.messages.sourceVerificationFailed}),gr(t.root.id,!1)}})())};function by(t){return t.confirmation}const _o="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",yy=c.memo(function(e){const n=et.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:u,iconClassName:d,pressed:h}=e,m=r===void 0?!0:r,g=h===void 0?!1:h;if(!m)return null;const b=a??_o,y=g&&"bg-interactive-selection text-interactive-selection-foreground";let S;n[0]!==b||n[1]!==y?(S=Me(b,y),n[0]=b,n[1]=y,n[2]=S):S=n[2];const w=d??"h-[18px] w-[18px]";let f;n[3]!==u||n[4]!==w?(f=s.jsx(M,{name:u,className:w}),n[3]=u,n[4]=w,n[5]=f):f=n[5];let x;n[6]!==o||n[7]!==l||n[8]!==g||n[9]!==S||n[10]!==f?(x=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":g,className:S,children:f})}),n[6]=o,n[7]=l,n[8]=g,n[9]=S,n[10]=f,n[11]=x):x=n[11];let v;n[12]!==i?(v=s.jsx(It,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=v):v=n[13];let p;return n[14]!==x||n[15]!==v?(p=s.jsxs(Dt,{children:[x,v]}),n[14]=x,n[15]=v,n[16]=p):p=n[16],p}),wy=c.memo(function(e){const n=et.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:u,shortcutLabel:d,remoteUpdateInfo:h,remoteUpdateChecking:m,remoteUpdateError:g,onOpenRemoteUpdate:b}=e,{t:y}=vt();let S;n[0]!==u||n[1]!==a?(S=T=>{a(T),T&&u()},n[0]=u,n[1]=a,n[2]=S):S=n[2];let w;n[3]!==i||n[4]!==r||n[5]!==y?(w=r?y("header.services.openWithCurrent",{current:i}):y("header.services.open"),n[3]=i,n[4]=r,n[5]=y,n[6]=w):w=n[6];const f=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let x;n[7]!==f?(x=Me(_o,f),n[7]=f,n[8]=x):x=n[8];let v;n[9]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(M,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=v):v=n[9];let p;n[10]!==i||n[11]!==r?(p=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=p):p=n[12];let N;n[13]!==w||n[14]!==x||n[15]!==p?(N=s.jsx(Pt,{asChild:!0,children:s.jsx(Ls,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":w,className:x,children:[v,p]})})}),n[13]=w,n[14]=x,n[15]=p,n[16]=N):N=n[16];let C;n[17]!==i||n[18]!==d||n[19]!==y?(C=y("header.services.tooltip.currentInstance",{current:i,toggle:d("toggle_services_menu")}),n[17]=i,n[18]=d,n[19]=y,n[20]=C):C=n[20];let k;n[21]!==C?(k=s.jsx(It,{children:s.jsx("p",{children:C})}),n[21]=C,n[22]=k):k=n[22];let D;n[23]!==N||n[24]!==k?(D=s.jsxs(Dt,{children:[N,k]}),n[23]=N,n[24]=k,n[25]=D):D=n[25];let I;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==b||n[30]!==m||n[31]!==g||n[32]!==h||n[33]!==a||n[34]!==y?(I=r?s.jsxs("div",{children:[o?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:y("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:h?.available?y("header.services.remoteUpdate.available",{version:h.version||""}):m?y("header.services.remoteUpdate.checking"):g||y("header.services.remoteUpdate.upToDate")})]}),h?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:b,children:y("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(dp,{embedded:!0,open:l,onOpenChange:Sy,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=b,n[30]=m,n[31]=g,n[32]=h,n[33]=a,n[34]=y,n[35]=I):I=n[35];let A;n[36]!==I?(A=s.jsx($s,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:I}),n[36]=I,n[37]=A):A=n[37];let P;return n[38]!==l||n[39]!==S||n[40]!==D||n[41]!==A?(P=s.jsxs(zs,{open:l,onOpenChange:S,children:[D,A]}),n[38]=l,n[39]=S,n[40]=D,n[41]=A,n[42]=P):P=n[42],P}),An=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Zl=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,vy=()=>{Qs("ui.header.render");const{t}=vt(),e=De(Q=>Q.isSidebarOpen),n=De(Q=>Q.openContextOverview),r=De(Q=>Q.closeContextPanel),i=De(Q=>Q.shortcutOverrides),o=De(Q=>Q.sessionTabsEnabled),l=Yt(Q=>Q.getCurrentModel),a=Ze(Q=>Q.getContextUsage),u=Ze(Q=>!!Q.newSessionDraft?.open),d=Ze(Q=>Q.currentSessionId),h=up(d??""),m=Na(d??""),g=rf(d??""),b=_s(ir(c.useCallback(Q=>{if(!d)return null;const Ve=[...Q.activeSessions,...Q.archivedSessions].find(Rt=>Rt.id===d);if(!Ve)return null;const at=Ve;return{title:Ve.title??null,directory:at.directory??null,created:Ve.time?.created??null,slug:at.slug??null,shareUrl:Ve.share?.url??null,parentId:Ve.parentID??null}},[d]))),y=Gt(ir(Q=>{if(!Q.activeProjectId)return null;const Ve=Q.projects.find(at=>at.id===Q.activeProjectId);return Ve?{id:Ve.id,path:Ve.path,label:Ve.label}:null})),S=c.useMemo(()=>{if(!y)return null;const Q=y.label?.trim();if(Q)return Q;const Ve=y.path.split(/[\\/]/).filter(Boolean);return Ve[Ve.length-1]??null},[y]),w=hr(Q=>Q.loadSettings),{isMobile:f}=Vn(),x=c.useRef(null),[v,p]=c.useState(()=>typeof window>"u"?!1:vn()),N=c.useMemo(()=>Yr(),[]),C=ou(),[k,D]=c.useState(!1),I=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:A,side:P}=Ku(),T=c.useMemo(()=>{if(typeof window>"u")return null;const Q=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof Q=="number"&&Number.isFinite(Q)&&Q>0)return Q;if(typeof navigator>"u")return null;const Ve=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Ve)return null;const at=Number.parseInt(Ve[1],10),Rt=Number.parseInt(Ve[2],10);return Number.isNaN(at)?null:at===10?Rt:at},[]);xt.useEffect(()=>{typeof window>"u"||p(vn())},[]);const _=l(),L=_&&typeof _.limit=="object"&&_.limit!==null?_.limit:null,W=L&&typeof L.context=="number"?L.context:0,O=L&&typeof L.output=="number"?L.output:0,$=a(W,O),[j,E]=c.useState(null),K=!d||h;xt.useEffect(()=>{if(!d){E(Q=>Q===null?Q:null);return}if($){E(Q=>fp(Q,$)?Q:$);return}K&&E(Q=>Q===null?Q:null)},[$,d,K]);const[ee,J]=c.useState(!1),[ne,ue]=c.useState("Local"),[X,te]=c.useState(!0),[fe,je]=c.useState(!1),[ve,ye]=c.useState(null),[Pe,xe]=c.useState(!1),[R,Y]=c.useState(null),ie=c.useMemo(()=>Kn(),[]),H=De(Q=>Q.workStatusPanelVisible),me=De(Q=>Q.workStatusPanelEnabled),pe=De(Q=>Q.setWorkStatusPanelEnabled),re=De(Q=>Q.workStatusPanelFits),de=De(Q=>Q.workStatusOverlayOpen),B=De(Q=>Q.setWorkStatusOverlayOpen),he=me&&re||de,Se=c.useCallback(()=>{if(me&&!re){B(!de);return}pe(!me)},[B,pe,de,me,re]),Re=!ie&&!H&&!!j,le=c.useCallback(async()=>{if(!(typeof window>"u"||!v))try{if(qo()){ue("Local"),te(!0);return}te(!1);const Q=await Bd(),Ve=Wm(),at=Km([Vm(Ve),...Q.hosts]);if(at.id===Um){ue("Local"),te(!0);return}ue(Fd(at.label.trim()||"Instance"))}catch{ue("Local"),te(!0)}},[v]);xt.useEffect(()=>(le(),eo(()=>{le()})),[le]);const se=c.useCallback(async()=>{if(X){ye(null),Y(null);return}xe(!0),Y(null);try{const Q=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),Ve=await ms(`/api/openchamber/update-check?${Q.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!Ve.ok)throw new Error(`Server responded with ${Ve.status}`);const at=await Ve.json();ye({available:at.available??!1,version:at.version,currentVersion:at.currentVersion??"unknown",body:at.body,nextSuggestedCheckInSec:typeof at.nextSuggestedCheckInSec=="number"?at.nextSuggestedCheckInSec:void 0,packageManager:at.packageManager,updateCommand:at.updateCommand})}catch(Q){ye(null),Y(Q instanceof Error?Q.message:t("header.services.remoteUpdate.error"))}finally{xe(!1)}},[X,t]);c.useEffect(()=>{ye(null),Y(null),je(!1)},[X,ne]),c.useEffect(()=>{if(!v||X)return;const Q=3e3,Ve=3600*1e3;let at=!1,Rt=null;const Vt=Ut=>{Rt=window.setTimeout(()=>{if(at||typeof document<"u"&&document.visibilityState!=="visible"){Vt(Ve);return}se().finally(()=>{at||Vt(Ve)})},Ut)};return Vt(Q),()=>{at=!0,Rt!==null&&window.clearTimeout(Rt)}},[se,X,ne,v]);const q=c.useCallback(()=>{if(ve?.available){je(!0);return}se()},[se,ve?.available]);mp(),c.useEffect(()=>{w()},[w]);const z=d?b??null:null,ae=c.useRef(null),[ce,Ne]=c.useState(0);c.useEffect(()=>{if(!d){ae.current&&(ae.current=null,Ne(Rt=>Rt+1));return}if(z){ae.current={sessionId:d,session:z,expiresAt:Date.now()+2e3};return}const Q=ae.current;if(!Q||Q.sessionId!==d)return;const Ve=Q.expiresAt-Date.now();if(Ve<=0){ae.current=null,Ne(Rt=>Rt+1);return}const at=window.setTimeout(()=>{ae.current?.sessionId===d&&(ae.current=null),Ne(Rt=>Rt+1)},Ve);return()=>{window.clearTimeout(at)}},[d,z]);const we=(()=>{if(z)return z;if(!d)return null;const Q=ae.current;return Q&&Q.sessionId===d&&Q.expiresAt>Date.now()?Q.session:null})(),$e=Ze(Q=>d?Q.worktreeMetadata.get(d)?.path??"":""),Oe=Ze(Q=>d?Q.worktreeMetadata.get(d)?.branch?.trim()??null:null),ge=iu(Q=>d?Q.getAttachment(d):void 0),He=c.useMemo(()=>ge?hp(ge,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,ge]),V=c.useMemo(()=>ge?ge.legacy?"legacy":ge.degraded?"degraded":ge.worktreeStatus==="pending"?"pending":ge.worktreeStatus==="missing"?"missing":ge.worktreeStatus==="invalid"?"invalid":ge.attentionReason?"attention":null:null,[ge]),Ae=c.useMemo(()=>An($e||""),[$e]),Ie=c.useMemo(()=>{const Q=typeof we?.directory=="string"?we.directory:"";return An(Q||"")},[we?.directory]),Fe=Ca(d??"",Ie),st=Ze(Q=>Q.newSessionDraft?.open?An(Q.newSessionDraft.bootstrapPendingDirectory??Q.newSessionDraft.directoryOverride??""):""),lt=Ze(Q=>Q.newSessionDraft.target),it=Ze(Q=>Q.newSessionDraft.selectedProjectId),mt=Ze(Q=>Q.currentSessionDirectory),St=os(Q=>Q.homeDirectory),ht=c.useMemo(()=>Ae||Ie||st,[st,Ie,Ae]),Xe=De(c.useCallback(Q=>{const Ve=An(ht||"");return Ve?Zl(Q.contextPanelByDirectory[Ve]):null},[ht])),Ct=Ze(Q=>{const Ve=An(Ae||Ie||"");if(!Ve)return null;for(const at of Q.availableWorktreesByProject.values()){const Vt=at.find(Ut=>An(Ut.path)===Ve)?.branch?.trim();if(Vt)return Vt}return null}),be=pp(ht||null)||Oe||Ct,Ue=u?lt==="chat":gp(Ie||mt,St),ut=!Ue&&!H&&!!(S||be||!u&&V),G=c.useMemo(()=>{if(!d)return S??"OpenChamber";const Q=we?.title?.trim();return Q&&Q.length>0?Q:"Untitled Session"},[S,we?.title,d]),U=au(ht||void 0,{bootstrap:!1}),Z=lu(),ke=Ze(Q=>Q.updateSessionTitle),Te=Ze(Q=>Q.shareSession),We=Ze(Q=>Q.unshareSession),Je=Ze(Q=>Q.archiveSessions),nt=Ze(Q=>Q.deleteSessions),[rt,Ye]=c.useState(!1),[Nt,Ke]=c.useState(!1),Tt=c.useRef(null),[Ce,ft]=c.useState(""),[bt,jt]=c.useState(null),Ge=c.useRef(null),Le=c.useCallback(()=>{d&&(ft(we?.title?.trim()||G),Ye(!0))},[we?.title,d,G]),pt=c.useRef(Le);pt.current=Le;const Be=c.useCallback(Q=>{Q&&(Q.focus(),Q.select())},[]);c.useEffect(()=>{if(Ke(!1),jt(null),d&&Tt.current===d){Tt.current=null,pt.current();return}Ye(!1),ft("")},[d]);const ze=c.useCallback(async()=>{if(!d)return;const Q=Ce.trim();Q&&Q!==we?.title?.trim()&&await ke(d,Q),Ye(!1)},[we?.title,d,Ce,ke]);c.useEffect(()=>{if(!rt)return;const Q=Ve=>{const at=Ve.target;(!at||!Ge.current?.contains(at))&&ze()};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[rt,ze]);const qe=c.useCallback(Q=>{Q&&wn(Q).then(Ve=>{_e[Ve.ok?"success":"error"](t(Ve.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(t("sessions.sidebar.session.copyId.error")))},[t]),tt=c.useCallback(async Q=>{if(!Q)return;const Ve=await Te(Q);if(Ve?.share?.url){const at=await wn(Ve.share.url);_e[at.ok?"success":"warning"](t("sessions.sidebar.session.share.successTitle"),{description:t(at.ok?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")});return}_e.error(t("sessions.sidebar.session.share.error"))},[Te,t]),yt=c.useCallback(Q=>{Q&&wn(Q).then(Ve=>{_e[Ve.ok?"success":"error"](t(Ve.ok?"sessions.sidebar.session.menu.copied":"sessions.sidebar.session.share.copyUrlError"))}).catch(()=>_e.error(t("sessions.sidebar.session.share.copyUrlError")))},[t]),Ot=c.useCallback(async Q=>{if(!Q)return;const Ve=await We(Q);_e[Ve?"success":"error"](t(Ve?"sessions.sidebar.session.unshare.success":"sessions.sidebar.session.unshare.error"))},[t,We]),Ht=c.useCallback(async()=>{if(!d||!ht){_e.error(t("sessions.sidebar.session.export.nothingToExport"));return}try{await Z.loadCompleteHistory(d,ht)}catch{_e.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}const Q=Nl(U.getState(),d).list;if(Q.length===0){_e.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Ve=cu(Q,we?.title??null),at=du(we?.title??null);await uu(Ve,at)||fu(Ve,at),_e.success(t("sessions.sidebar.session.export.success"))},[we?.title,d,U,ht,Z,t]),_t=mu(),zt=c.useMemo(()=>hu(_t),[_t]),Wt=c.useCallback(Q=>{d&&nf({entry:Q,t,session:{id:d,title:we?.title,directory:Ie??ht},loadRecords:async()=>{if(!ht)return null;try{await Z.loadCompleteHistory(d,ht)}catch{return null}return Nl(U.getState(),d).list},onLoadFailed:()=>_e.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[we?.title,d,U,ht,Ie,Z,t]),Jt=c.useCallback(Q=>zt.map(Ve=>s.jsxs(Q,{onClick:()=>Wt(Ve),children:[s.jsx(to,{icon:Ve.icon,iconSrc:Ve.iconSrc,className:"mr-1 size-4"}),Ve.action.label]},`${Ve.guest.id}:${Ve.action.id}`)),[zt,Wt]),es=m?.type==="busy"||m?.type==="retry",Qt=c.useCallback(()=>{if(!d||!Ie||es||g)return;const Q=_s.getState().activeSessions,Ve=Q.find(Vt=>Vt.id===d);if(!Ve)return;const at=[],Rt=[d];for(let Vt=0;Vt<Rt.length;Vt+=1){const Ut=Rt[Vt];for(const Xt of Q)Xt.parentID===Ut&&(at.push(Xt),Rt.push(Xt.id))}sa({kind:"quick",root:Ve,descendants:at,sourceDirectory:Ie,messages:ea(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,es,g,Ie,t]),qt=c.useCallback(async()=>{if(!bt)return;const Q=bt.action,Ve=[bt.sessionId,...Kd(bt.sessionId,[],Q==="delete")];if(jt(null),(Q==="archive"?await Je(Ve):await nt(Ve)).failedIds.length>0){_e.error(t(Q==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}_e.success(t(Q==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[Je,nt,bt,t]),Et=De(Q=>Q.openGuestPageId),wt=pu(Q=>Q.guests.find(Ve=>Ve.id===Et)),cs=De(Q=>Q.isScheduledTasksDialogOpen),xs=De(Q=>Q.isArchivePageOpen),ds=De(Q=>Q.worktreesPageProjectId),us=De(Q=>Q.isMultiRunLauncherOpen),ln=Gt(Q=>{if(!ds)return null;const Ve=Q.projects.find(at=>at.id===ds);return Ve?.label?.trim()||Ve?.path?.split("/").pop()||null}),js=c.useMemo(()=>wt?{title:wt.pageTitle??wt.name,subtitle:null}:cs?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:xs?{title:t("sessions.archivePage.title"),subtitle:null}:ds?{title:t("sessions.worktreesPage.title",{project:ln??""}),subtitle:null}:us?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[wt,xs,us,cs,t,ds,ln]),pn=c.useMemo(()=>An(ht||y?.path||""),[y?.path,ht]),gn=Ub(),Js=Da(Q=>Q.planModeEnabled),cn=Ze(Q=>Q.isSessionPlanAvailable),ns=Js&&d?cn(d):!1,ks=c.useRef("");c.useEffect(()=>{if(!Js||!d)return;const Q=`${d||"none"}:${Ie||"none"}:${we?.created||0}:${we?.slug||"none"}`;ks.current!==Q&&(ks.current=Q)},[Js,ns,we?.slug,we?.created,d,Ie]);const Ks=c.useCallback(()=>{zn("desktop_open_draft_mini_chat_window",{directory:Ue?"":st,projectId:Ue?null:it,apiBaseUrl:En(),clientToken:Qr()}).catch(Q=>{console.warn("[header] failed to open draft mini chat window",Q)})},[st,it,Ue]),Vs=c.useCallback(()=>{if(u){Ks();return}d&&zn("desktop_open_session_mini_chat_window",{sessionId:d,directory:Ie||An(mt||"")||Ae,apiBaseUrl:En(),clientToken:Qr()}).catch(Q=>{console.warn("[header] failed to open session mini chat window",Q)})},[d,Ks,u,mt,Ie,Ae]),As=c.useCallback(()=>{const Q=An(ht||"");if(!Q)return;const Ve=De.getState().contextPanelByDirectory[Q];if(Zl(Ve)==="context"){r(Q);return}n(Q)},[r,n,ht]),Zs=Xe==="context",gs=_o,dn=c.useMemo(()=>v&&I&&!k?"88px":C?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!v||A)&&!ie?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[v,k,I,C,ie,A]);xt.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",dn)},[dn]);const xn=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Nn=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";xt.useEffect(()=>{if(!v||!I){D(!1);return}let Q=!1;const Ve=async()=>{try{const Rt=await zn("desktop_is_window_fullscreen");Q||D(Rt===!0)}catch{Q||D(!1)}},at=()=>{Ve()};return Ve(),window.addEventListener("openchamber:window-resized",at),()=>{Q=!0,window.removeEventListener("openchamber:window-resized",at)}},[v,I]);const en=c.useMemo(()=>!v||!I||T===null?"":T>=26?"h-12":T<=15?"h-14":"",[v,I,T]),Us=c.useMemo(()=>{if(!(v&&!A||ie)&&!(A&&P==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[v,ie,A,P]),oe=c.useCallback(()=>{if(typeof document>"u")return;const Q=x.current?.getBoundingClientRect().height;Q&&document.documentElement.style.setProperty("--oc-header-height",`${Q}px`)},[]);xt.useEffect(()=>{if(typeof window>"u")return;oe();const Q=x.current;if(!Q||typeof ResizeObserver>"u")return()=>{};let Ve=0;const at=()=>{Ve||(Ve=requestAnimationFrame(()=>{Ve=0,oe()}))},Rt=new ResizeObserver(at);return Rt.observe(Q),window.addEventListener("resize",at),window.addEventListener("orientationchange",at),()=>{Ve&&cancelAnimationFrame(Ve),Rt.disconnect(),window.removeEventListener("resize",at),window.removeEventListener("orientationchange",at)}},[oe]),xt.useEffect(()=>{oe()},[oe,f,en]);const Qe=c.useCallback(async Q=>{const Ve=Q.target;Ve.closest(".app-region-no-drag")||Ve.closest("button, a, input, select, textarea")||Q.button===0&&v&&await Hm()},[v]),ct=c.useCallback(Q=>sr(so(Q,i)),[i]);xp({rename_current_session:()=>{if(!d||f)return!1;Le()},toggle_services_menu:()=>{if(ee){J(!1);return}J(!0),le()}});const kt=s.jsxs(s.Fragment,{children:[gn?s.jsx(Kb,{projectRef:gn.projectRef,directory:gn.directory,className:"mr-2"}):null,s.jsx(xb,{directory:pn,className:"mr-1"}),v?s.jsx(wy,{isDesktopApp:v,currentInstanceLabel:ne,currentInstanceIsLocal:X,isDesktopServicesOpen:ee,setIsDesktopServicesOpen:J,refreshCurrentInstanceLabel:le,shortcutLabel:ct,remoteUpdateInfo:ve,remoteUpdateChecking:Pe,remoteUpdateError:R,onOpenRemoteUpdate:q}):null]}),$t=N&&(u||!!d),Ft=c.useCallback(({session:Q,open:Ve,isActive:at,select:Rt,closeOtherTabs:Vt,components:Ut})=>{const{Item:Xt,Separator:Hs}=Ut,Gs=Q.share?.url??null,cr=at&&!ie&&!Ue&&we&&!we.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(Xt,{onClick:()=>{at||Rt(),Tt.current=Q.id},children:[s.jsx(M,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(Zi,{sessionID:Q.id,directory:Q.directory,open:Ve,Item:Xt}),s.jsxs(Xt,{onClick:()=>qe(Q.id),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Hs,{}),Gs?s.jsxs(s.Fragment,{children:[s.jsxs(Xt,{onClick:()=>yt(Gs),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Xt,{onClick:()=>{Ot(Q.id)},children:[s.jsx(M,{name:"link-unlink-m",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Xt,{onClick:()=>{tt(Q.id)},children:[s.jsx(M,{name:"share-2",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.share")]}),at?s.jsxs(Xt,{onClick:()=>{Ht()},children:[s.jsx(M,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,at?Jt(Xt):null,cr?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Xt,{disabled:!Ie||es||g,onClick:Qt,className:"w-full",children:[s.jsx(M,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(It,{side:"right",className:"max-w-72",children:t(g?"sessions.sidebar.session.moveToWorktree.tooltipMoving":es?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Hs,{}),s.jsxs(Xt,{onClick:Vt,children:[s.jsx(M,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(Hs,{}),s.jsxs(Xt,{onClick:()=>jt({action:"archive",sessionId:Q.id}),children:[s.jsx(M,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Xt,{className:"text-destructive focus:text-destructive",onClick:()=>jt({action:"delete",sessionId:Q.id}),children:[s.jsx(M,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[qe,yt,we,Ht,Ue,es,g,ie,Qt,Jt,Ie,tt,t,Ot]),ot=()=>s.jsxs("div",{onMouseDown:Qe,className:Me("app-region-drag relative flex h-12 select-none items-center",A&&P==="right"?"pr-0":"pr-3",en),style:Us,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:xn}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:Nn}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[js?s.jsxs(s.Fragment,{children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>De.getState().closeMainSurfaces(),children:s.jsx(M,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(It,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:js.title}),js.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:js.subtitle}):null]})]}):ie||!o?s.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[Fe?s.jsx(M,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:s.jsx(Ul,{align:"start",children:s.jsx("button",{type:"button",className:gs,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(M,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[rt?s.jsxs("form",{ref:Ge,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:Q=>Q.stopPropagation(),onSubmit:Q=>{Q.preventDefault(),ze()},children:[s.jsx("input",{ref:Be,value:Ce,onChange:Q=>ft(Q.target.value),onKeyDown:Q=>Oi(Q,()=>Ye(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ye(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:u?t("sessions.switcher.draftTitle"):G}),ut?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[S?s.jsx("span",{className:"truncate",children:S}):null,be?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(M,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:be})]}):null,!u&&V?s.jsxs("span",{className:Me("inline-flex min-w-0 items-center gap-0.5",V==="attention"||V==="invalid"||V==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(M,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:He})]}):null]}):null]}),s.jsx("div",{className:Me("flex h-[18px] shrink-0 items-center justify-center",ut?"self-start":"self-center"),children:d&&!u&&!rt?s.jsxs(zs,{open:Nt,onOpenChange:Ke,onOpenChangeComplete:Q=>{!Q&&Tt.current&&Tt.current===d&&(Tt.current=null,Le())},children:[s.jsx(Ls,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(M,{name:"more",className:"size-4"})})}),s.jsxs($s,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Kt,{onClick:()=>{Tt.current=d},children:[s.jsx(M,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(Zi,{sessionID:d,directory:Ie,open:Nt,Item:Kt}),s.jsxs(Kt,{onClick:()=>d&&qe(d),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Rs,{}),we?.shareUrl?s.jsxs(s.Fragment,{children:[s.jsxs(Kt,{onClick:()=>yt(we?.shareUrl),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Kt,{onClick:()=>{d&&Ot(d)},children:[s.jsx(M,{name:"link-unlink-m",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Kt,{onClick:()=>{d&&tt(d)},children:[s.jsx(M,{name:"share-2",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.share")]}),s.jsxs(Kt,{onClick:()=>{Ht()},children:[s.jsx(M,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),Jt(Kt),!ie&&!Ue&&we&&!we.parentId?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Kt,{disabled:!Ie||es||g,onClick:Qt,className:"w-full",children:[s.jsx(M,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(It,{side:"right",className:"max-w-72",children:t(g?"sessions.sidebar.session.moveToWorktree.tooltipMoving":es?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Rs,{}),s.jsxs(Kt,{onClick:()=>{d&&jt({action:"archive",sessionId:d})},children:[s.jsx(M,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Kt,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&jt({action:"delete",sessionId:d})},children:[s.jsx(M,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):s.jsxs("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:s.jsx(Ul,{align:"start",children:s.jsx("button",{type:"button",className:gs,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(M,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(Qb,{renderMenu:Ft,suppressActiveTabControls:rt,onMenuOpenChangeComplete:Q=>{!Q&&Tt.current&&Tt.current===d&&(Tt.current=null,Le())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:rt?s.jsxs("form",{ref:Ge,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:Q=>Q.stopPropagation(),onSubmit:Q=>{Q.preventDefault(),ze()},children:[s.jsx("input",{ref:Be,value:Ce,onChange:Q=>ft(Q.target.value),onKeyDown:Q=>Oi(Q,()=>Ye(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ye(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:u?t("sessions.switcher.draftTitle"):G})})})]}),js||ie||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Re&&j?s.jsx(Bx,{reading:Fx(j),contextLimit:j.contextLimit,outputLimit:j.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:As,pressed:Zs,className:$t?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(yy,{visible:$t,title:t(u?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(u?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Vs,className:Me(gs,"mr-1"),Icon:"picture-in-picture-2"}),ie?null:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":he,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:Se,className:Me(_o,"mr-1",he?"text-foreground":"text-muted-foreground/50"),children:s.jsx(M,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(It,{side:"bottom",children:t(me&&!re?de?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":me?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),kt,s.jsx(Vu,{visible:A&&P==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:x,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:ot()}),s.jsx(vs,{open:bt!==null,onOpenChange:Q=>{Q||jt(null)},children:s.jsxs(Ss,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:bt?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Ts,{children:bt?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:G}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:G})})]}),s.jsxs(Sn,{children:[s.jsx(dt,{variant:"outline",size:"sm",onClick:()=>jt(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{variant:"destructive",size:"sm",onClick:()=>{qt()},children:bt?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(Vd,{open:fe,onOpenChange:je,info:ve,downloading:!1,downloaded:!1,progress:null,error:R,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function Sy(){}const ec=280,tc=168,sc=500,jy=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=vt(),l=De(k=>k.sidebarWidth),a=De(k=>k.setSidebarWidth),[u,d]=c.useState(!1),h=c.useRef(0),m=c.useRef(l||ec),g=c.useRef(null),b=c.useRef(null),y=c.useRef(null),S=c.useCallback(k=>Math.min(sc,Math.max(tc,k)),[]),w=c.useCallback(k=>{const D=y.current;D&&(D.style.width=`${k}px`,D.style.minWidth=`${k}px`,D.style.maxWidth=`${k}px`,D.style.setProperty("--oc-left-sidebar-width",`${k}px`))},[]);if(c.useEffect(()=>{e&&u&&d(!1)},[e,u]),c.useEffect(()=>{u||(g.current=null,b.current=null)},[u]),e)return null;const f=Math.min(sc,Math.max(tc,l||ec)),x=t?f:0,v=k=>{if(t){try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}b.current=k.pointerId,d(!0),h.current=k.clientX,m.current=x,g.current=x,w(x),k.preventDefault()}},p=k=>{if(e||!u||b.current!==k.pointerId)return;const D=k.clientX-h.current,I=S(m.current+D);g.current!==I&&(g.current=I,w(I))},N=k=>{if(b.current!==k.pointerId||e)return;try{k.currentTarget.releasePointerCapture(k.pointerId)}catch{}const D=S(g.current??x);b.current=null,g.current=null,d(!1),a(D)},C=u?g.current??x:x;return s.jsxs("aside",{ref:y,className:Me("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${C}px`,minWidth:`${C}px`,maxWidth:`${C}px`,"--oc-left-sidebar-width":`${u?C:f}px`,overflowX:"clip",transitionProperty:u?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||x===0,children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&s.jsx("div",{className:Me("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",u&&"bg-[var(--interactive-border)]"),onPointerDown:v,onPointerMove:p,onPointerUp:N,onPointerCancel:N,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Me("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",u&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(jn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Ds,{children:n})})]})]})},ky=()=>{const t=et.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},nc="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:bg-interactive-hover transition-colors",Cy=()=>{const t=et.c(32),{t:e}=vt(),n=De(Ny),r=De(Ay),i=c.useRef(null),o=sr(so("toggle_sidebar",r)),{usesFramelessChrome:l,side:a}=Ku(),u=Py;let d,h;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{if(typeof document>"u")return;const T=i.current;if(!T)return;const _=()=>{const W=Math.max(T.getBoundingClientRect().width,T.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(W)}px`)};if(_(),typeof ResizeObserver>"u")return;const L=new ResizeObserver(_);return L.observe(T),()=>{L.disconnect()}},h=[],t[0]=d,t[1]=h):(d=t[0],h=t[1]),c.useEffect(d,h);const m="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let g;t[2]===Symbol.for("react.memo_cache_sentinel")?(g={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=g):g=t[2];const b="flex items-center gap-2";let y;t[3]!==l||t[4]!==a?(y=l&&a==="left"?s.jsx(Vu,{visible:!0,position:"left"}):null,t[3]=l,t[4]=a,t[5]=y):y=t[5];let S;t[6]!==e||t[7]!==l?(S=l?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,"aria-label":e("header.actions.openAppMenuAria"),className:Me(nc,"shrink-0"),children:s.jsx(M,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(It,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=l,t[8]=S):S=t[8];const w=Dt;let f;t[9]!==e?(f=e("header.actions.openSessionsAria"),t[9]=e,t[10]=f):f=t[10];let x,v;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=Me(nc,"shrink-0"),v=s.jsx(M,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=x,t[12]=v):(x=t[11],v=t[12]);let p;t[13]!==f||t[14]!==n?(p=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":f,className:x,children:v})}),t[13]=f,t[14]=n,t[15]=p):p=t[15];const N=It,C=e("header.actions.openSessionsWithShortcut",{shortcut:o});let k;t[16]!==C?(k=s.jsx("p",{children:C}),t[16]=C,t[17]=k):k=t[17];let D;t[18]!==N||t[19]!==k?(D=s.jsx(N,{children:k}),t[18]=N,t[19]=k,t[20]=D):D=t[20];let I;t[21]!==w||t[22]!==p||t[23]!==D?(I=s.jsxs(w,{children:[p,D]}),t[21]=w,t[22]=p,t[23]=D,t[24]=I):I=t[24];let A;t[25]!==I||t[26]!==y||t[27]!==S?(A=s.jsxs("div",{ref:i,className:b,children:[y,S,I]}),t[25]=I,t[26]=y,t[27]=S,t[28]=A):A=t[28];let P;return t[29]!==A||t[30]!==g?(P=s.jsx("div",{className:m,style:g,children:A}),t[29]=A,t[30]=g,t[31]=P):P=t[31],P};function Ny(t){return t.toggleSidebar}function Ay(t){return t.shortcutOverrides}function Dy(t){console.warn("[titlebar] failed to open app menu",t)}function Py(t){const e=t.currentTarget.getBoundingClientRect();zn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(Dy)}function uf(t){const e=et.c(5),{className:n}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(M,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let u;return e[3]!==i?(u=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=u):u=e[4],u}const rc=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Iy(t,e,n){const r=et.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let u=!1;return(async()=>{const[d,h]=await Promise.all([bp(t),yp(t)]).catch(Ty);if(u)return;const m=rc(d),g=rc(h);if(!m||!g||g===m)return;const b=n||"",y=g.split("/").filter(Boolean).pop()||g;o({source:"sdk",path:g,projectDirectory:m,branch:b,label:b||y,name:y,worktreeRoot:g,worktreeStatus:"ready",headState:b?"branch":"unborn",worktreeSource:"existing"})})(),()=>{u=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function Ty(){return["",""]}const oc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Ey=async(t,e)=>{if(t)return t.authActivate(e);const n=await ms("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw new Error(r?.error||n.statusText);return r},ic=({className:t})=>{const{t:e}=vt(),{github:n}=Cn(),r=Rn(b=>b.status),i=Rn(b=>b.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async b=>{if(!(!b||o)){l(!0);try{i(await Ey(n,b))}catch(y){console.error("Failed to switch GitHub account:",y)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const u=r.user?.login??null,d=r.user?.avatarUrl??null,h=r.accounts??[],m=u?e("header.github.connectedWithLogin",{login:u}):e("header.github.connected"),g=d?s.jsx("img",{src:d,alt:u?e("header.github.avatarWithLogin",{login:u}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(M,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return h.length<=1?s.jsx("div",{className:Me(oc,t),title:m,children:g}):s.jsxs(zs,{children:[s.jsx(Ls,{asChild:!0,children:s.jsx("button",{type:"button",className:Me(oc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:m,disabled:o,children:g})}),s.jsxs($s,{align:"end",className:"w-64",children:[s.jsx(zr,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(Rs,{}),h.map(b=>{const y=b.user,S=!!b.current,w=b.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(Kt,{className:"gap-2",disabled:o,onSelect:()=>{S||a(b.id)},children:[y?.avatarUrl?s.jsx("img",{src:y.avatarUrl,alt:y.login?e("header.github.avatarWithLogin",{login:y.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(M,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:y?.name?.trim()||y?.login||"GitHub"}),y?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:y.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:w})]}):null]}),S?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},b.id)})]})]})};class li extends Error{code;model;requiredChars;availableChars;constructor(e,n={}){super(e),this.name="WalkthroughError",this.code=n.code,this.model=n.model,this.requiredChars=n.requiredChars,this.availableChars=n.availableChars}}const ci="/api/walkthrough",ff=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),mf=()=>new li("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),Ry=t=>!ff(t)&&(t.ok||t.status===404),Ga=async(t,e)=>{if(Ry(t))throw mf();const n=await t.json().catch(()=>null);throw new li(typeof n?.error=="string"?n.error:e,{code:typeof n?.code=="string"?n.code:void 0,model:n?.model??void 0,requiredChars:typeof n?.requiredChars=="number"?n.requiredChars:void 0,availableChars:typeof n?.availableChars=="number"?n.availableChars:void 0})},hf=async t=>{if(!ff(t))throw mf();try{return await t.json()}catch{throw new li("The server returned a malformed walkthrough response")}};async function My(t,e,n={}){const r=await ms(ci,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?hf(r):Ga(r,"Failed to load walkthrough")}async function Oy(t,e,n={}){const r=await ms(`${ci}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:n.force===!0,...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?hf(r):Ga(r,"Failed to generate walkthrough")}async function By(t,e){const n=await ms(`${ci}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await Ga(n,"Failed to cancel walkthrough generation")}async function Fy(t,e,n){const r=await ms(`${ci}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const Er={status:"idle",stage:null,result:null,readiness:null,error:null},_y=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:t.sourceRepo?`pr:${t.sourceRepo.owner}/${t.sourceRepo.repo}:${t.number}`:`pr:${t.number}`,Bn=(t,e)=>`${as()}\0${t}\0${_y(e)}`,ac=t=>t instanceof li?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},nn=new Map,Rr=new Map,Ly=1e3,$y=Ar()(Xu((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=Bn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[Bn(n,r)],selectModel:(n,r,i)=>{const o=Bn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[Bn(n,r)],requestSource:(n,r)=>{t(i=>({requestedSource:{...i.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const i={...r.requestedSource};return delete i[n],{requestedSource:i}})},getEntry:(n,r)=>e().entries[Bn(n,r)]??Er,load:async(n,r,i={})=>{if(!n)return;const o=Bn(n,r);if(e().entries[o]?.status==="generating")return;nn.get(o)?.abort();const a=new AbortController;nn.set(o,a),t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Er,status:"loading",error:null}}}));try{const u=await My(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{status:"ready",stage:null,result:u,readiness:u.readiness??null,error:null}}})),u.generating&&e().generate(n,r,{language:i.language})}catch(u){if(a.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Er,status:"error",stage:null,error:ac(u)}}}))}finally{nn.get(o)===a&&nn.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=Bn(n,r);nn.get(o)?.abort();const l=new AbortController;nn.set(o,l),t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Er,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const u=Rr.get(o);u!==void 0&&(clearInterval(u),Rr.delete(o))};a(),Rr.set(o,setInterval(()=>{Fy(n,r).then(u=>{!u||l.signal.aborted||t(d=>{const h=d.entries[o];return!h||h.status!=="generating"||h.stage===u?d:{entries:{...d.entries,[o]:{...h,stage:u}}}})}).catch(()=>{})},Ly));try{const u=await Oy(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{status:"ready",stage:null,result:u,readiness:d.entries[o]?.readiness??null,error:null}}}))}catch(u){if(l.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Er,status:"error",stage:null,error:ac(u)}}}))}finally{a(),nn.get(o)===l&&nn.delete(o)}},cancel:(n,r)=>{const i=Bn(n,r);By(n,r).catch(()=>{}),nn.get(i)?.abort(),nn.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const n of nn.values())n.abort();nn.clear();for(const n of Rr.values())clearInterval(n);Rr.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),zy="border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]",Wy=3e4,lc=20,pf=(t,e)=>JSON.stringify([as(),t,e]),Ky=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,i]=e;return typeof n!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:n,directory:r,number:i}}catch{return null}},cc=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),ao=new Map,Vy=t=>{const e=Object.entries(t);return e.length<=lc?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,lc))},dc=Ar()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=pf(r,i),a=o?.includeCheckDetails??!1,u=e().entries[l],d=u&&u.result&&Date.now()-u.fetchedAt<Wy&&(u.hasCheckDetails||!a);if(!o?.force&&d)return u.result;const h=`${l}::${a?"details":"plain"}`,g=ao.get(`${l}::details`)??(a?null:ao.get(h));if(g&&!o?.force)return g;const b=(async()=>{t(y=>({entries:{...y.entries,[l]:{...y.entries[l]??cc(),isLoading:!0,error:null}}}));try{const y=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(S=>({entries:Vy({...S.entries,[l]:{result:y,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),y}catch(y){const S=y instanceof Error?y.message:"Failed to load pull request context";return t(w=>({entries:{...w.entries,[l]:{...w.entries[l]??cc(),isLoading:!1,error:S}}})),null}finally{ao.delete(h)}})();return ao.set(h,b),b},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const u=Ky(l);u&&u.directory===n&&(r==null||u.number===r)||(o[l]=a)}return{entries:o}})}})),Uy=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!n||o.startedAt<n)&&(n=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},Hy=35e3,xi=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},bi=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},uc=t=>{switch(t){case"success":return"bg-[color:var(--status-success)]";case"failure":return"bg-[color:var(--status-error)]";case"pending":return"bg-[color:var(--status-warning)]";default:return"bg-muted-foreground/40"}},Gy=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const n=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",i=e.mergeable===!1||r==="blocked"||r==="dirty";return n||i?"blocked":"open"},qy=[2e3,5e3],Yy=600,fc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),_n=t=>{let e=t.trim();return e?(e.startsWith("refs/heads/")&&(e=e.slice(11)),e.startsWith("heads/")&&(e=e.slice(6)),e.startsWith("remotes/")&&(e=e.slice(8)),e):""},Qy=(t,e)=>{const n=_n(t);if(!n||n.includes("->"))return"";if(e){const i=`${e}/`;return n.startsWith(i)?n.slice(i.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},Xy=(t,e)=>`${t}::${e}`,qa=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},yi=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const o=t.find(l=>l.name===n);if(o)return o}const r=qa(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},Jy=t=>t.startsWith("pr-"),Zy=(t,e)=>{const n=qa(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return n&&o(r.get(n)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!Jy(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Mr=new Map,lo=Yo;function e1(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const u=await e.repoUpstream(t);if(a||!u?.isFork||!u.upstream||(r(u.upstream),!e.repoBranches))return;try{const d=await e.repoBranches(u.upstream.owner,u.upstream.repo);a||o(d)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const t1=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=vt(),u=De(oe=>oe.timeFormatPreference),{github:d}=Cn(),h=Rn(oe=>oe.status),m=Rn(oe=>oe.hasChecked),g=De(oe=>oe.setSettingsDialogOpen),b=De(oe=>oe.setSettingsPage),y=Ze(oe=>oe.currentSessionId),S=Ze(oe=>!!oe.newSessionDraft?.open),{isMobile:w,hasTouchInput:f,screenWidth:x}=Vn(),v=De(oe=>oe.openContextSurface),p=$y(oe=>oe.requestSource),N=!w&&x>=768&&!Kn(),C=c.useCallback(()=>{b("integrations"),g(!0)},[g,b]),k=c.useMemo(()=>Xy(t,e),[t,e]),D=c.useMemo(()=>Mr.get(k)??null,[k]),I=Ys(oe=>oe.ensureEntry),A=Ys(oe=>oe.setParams),P=Ys(oe=>oe.startWatching),T=Ys(oe=>oe.stopWatching),_=Ys(oe=>oe.refresh),L=Ys(oe=>oe.updateStatus),[W,O]=c.useState(()=>D?.title??fc(e)),[$,j]=c.useState(()=>D?.body??""),[E,K]=c.useState(()=>D?.draft??!1),[ee,J]=c.useState(()=>D?.additionalContext??""),[ne,ue]=c.useState(()=>{const oe=typeof D?.targetBaseBranch=="string"?_n(D.targetBaseBranch):"";return oe||_n(n)}),[X,te]=c.useState("squash"),[fe,je]=c.useState(!1),[ve,ye]=c.useState(!1),[Pe,xe]=c.useState(!1),[R,Y]=c.useState(!1),[ie,H]=c.useState(!1),[me,pe]=c.useState(!1),[re,de]=c.useState(null),[B,F]=c.useState(""),[he,Se]=c.useState(""),[Re,le]=c.useState(!1),[se,q]=c.useState(!1),[z,ae]=c.useState(()=>yi(i,{selectedRemoteName:D?.selectedRemoteName,trackingBranch:r})),[ce,Ne]=c.useState(!1),{detectedUpstream:we,upstreamBranches:$e}=e1(t,d);c.useEffect(()=>{Ne(!1)},[t]);const Oe=i.some(oe=>oe.name==="upstream"),He=!!(t&&e&&n&&(e!==n||(Oe||we!==null))),V=c.useMemo(()=>Xo(t,e,z?.name??null),[t,e,z?.name]),Ae=Ys(oe=>oe.entries[V]),Ie=Ae?.isLoading??!1,Fe=Ae?.status??null,st=Ae?.error??null,lt=Ae?.isInitialStatusResolved??!1,it=c.useMemo(()=>{const oe=ce?null:z?.name?.trim()||null,Qe=new Set;for(const $t of o){const Ft=Qy($t,oe);!Ft||Ft==="HEAD"||Qe.add(Ft)}if(ce)for(const $t of $e)$t&&$t!=="HEAD"&&Qe.add($t);const ct=_n(n);ct&&ct!=="HEAD"&&Qe.add(ct);const kt=_n(ne);return kt&&kt!=="HEAD"&&Qe.add(kt),Array.from(Qe).sort(($t,Ft)=>$t.localeCompare(Ft))},[n,o,z?.name,ne,$e,ce]);c.useEffect(()=>{if(i.length===0){z&&ae(null);return}(!z||!i.some(oe=>oe.name===z.name))&&ae(yi(i,{selectedRemoteName:D?.selectedRemoteName,trackingBranch:r}))},[D?.selectedRemoteName,i,z,r]),c.useEffect(()=>{const oe=_n(n);if(!ne&&oe){ue(oe);return}if(it.length!==0&&!it.includes(ne)){const Qe=it.includes(oe)?oe:it[0];Qe&&ue(Qe)}},[it,n,ne]);const[mt,St]=c.useState(()=>D?.activeSegment??"overview"),[ht,Xe]=c.useState(new Set),[Ct,Mt]=c.useState(new Set),be=c.useRef(new Set),Ue=c.useRef(null),ut=c.useRef(!1),G=c.useRef(new Set),U=c.useRef([]);c.useEffect(()=>{we&&!Oe&&Ne(!0)},[we,Oe]),c.useEffect(()=>{ce&&we?.defaultBranch&&ue(we.defaultBranch)},[ce,we?.defaultBranch]);const Z=Fe?.pr??null,ke=Z?.state==="merged"||Z?.state==="closed",Te=ke?null:Z,We=Te?pf(t,Te.number):null,Je=dc(oe=>We?oe.entries[We]:void 0),nt=dc(oe=>oe.ensure),rt=Je?.result??null,Ye=Je?.isLoading??!1,Nt=c.useCallback(oe=>{St(oe);const Qe=Mr.get(k);Qe&&Mr.set(k,{...Qe,activeSegment:oe})},[k]);c.useEffect(()=>{!Te||!d?.prContext||mt==="overview"||nt(d,t,Te.number,{includeCheckDetails:mt==="checks",sourceRepo:Fe?.repo??null})},[mt,t,nt,d,Te,Fe?.repo]);const Ke=Fe?.checks??null,Tt=(Ke?.pending??0)>0,Ce=rt?.checkRuns??null,ft=rt?.fetchedAt;c.useEffect(()=>{if(!Ce||Ce.length===0)return;const oe=Uy(Ce);L(V,Qe=>{if(!Qe?.pr||typeof ft=="number"&&typeof Qe.fetchedAt=="number"&&ft<Qe.fetchedAt)return Qe;const ct=Qe.checks;return ct&&ct.state===oe.state&&ct.total===oe.total&&ct.success===oe.success&&ct.failure===oe.failure&&ct.pending===oe.pending&&ct.inProgress===oe.inProgress&&ct.queued===oe.queued&&ct.startedAt===oe.startedAt?Qe:{...Qe,checks:oe,...typeof ft=="number"?{fetchedAt:ft}:{}}})},[Ce,ft,V,L]),c.useEffect(()=>{if(mt!=="checks"||!Tt||!Z||!d?.prContext)return;const oe=window.setInterval(()=>{nt(d,t,Z.number,{includeCheckDetails:!0,sourceRepo:Fe?.repo??null,force:!0})},Hy);return()=>window.clearInterval(oe)},[mt,Tt,t,nt,d,Z,Fe?.repo]);const[bt,jt]=c.useState(()=>Date.now());c.useEffect(()=>{if(!Tt)return;jt(Date.now());const oe=window.setInterval(()=>jt(Date.now()),3e4);return()=>window.clearInterval(oe)},[Tt]);const Ge=Z?`${t}#${Z.number}`:null,Le=!!(Ge&&re===Ge);c.useEffect(()=>{if(!d?.prContext||!Z||typeof Z.body=="string"&&Z.body.length>0)return;const oe=`${t}#${Z.number}`;if(be.current.has(oe))return;be.current.add(oe),de(oe);let Qe=!1;return nt(d,t,Z.number,{sourceRepo:Fe?.repo??null}).then(ct=>{if(Qe)return;const kt=ct?.pr;kt&&L(V,$t=>!$t?.pr||$t.pr.number!==Z.number?$t:{...$t,pr:{...$t.pr,body:kt.body||""}})}).catch(()=>{}).finally(()=>{Qe||de(ct=>ct===oe?null:ct)}),()=>{Qe=!0}},[t,nt,d,Z,V,Fe?.repo,L]),c.useEffect(()=>{if(!Z){pe(!1),F(""),Se(""),Ue.current=null;return}const oe=Ue.current!==null&&Ue.current!==Z.number;oe&&pe(!1),(!me||oe)&&(F(Z.title||""),Se(Z.body||"")),Ue.current=Z.number},[me,Z]);const pt=c.useCallback(oe=>{if(!oe)return"";const Qe=Date.parse(oe);return Number.isFinite(Qe)?gu(Qe,u,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):oe},[u]),Be=c.useMemo(()=>{const oe=h?.user?.login;return typeof oe=="string"?oe.trim():""},[h]),ze=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),qe=c.useCallback(oe=>{const Qe=Be.toLowerCase(),ct=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return oe.replace(ct,(kt,$t,Ft)=>{const ot=`@${Ft}`,At=Ft.toLowerCase();return`${$t}[${ot}](https://github.com/${At}${Qe&&At===Qe?"?oc-self-mention=1":""})`})},[Be]),tt=c.useMemo(()=>{const oe=(rt?.issueComments??[]).map(kt=>({id:`issue-${kt.id}`,body:kt.body||"",authorName:kt.author?.name||kt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:kt.author?.login||null,avatarUrl:kt.author?.avatarUrl||null,createdAt:kt.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),Qe=(rt?.reviewComments??[]).map(kt=>({id:`review-${kt.id}`,body:kt.body||"",authorName:kt.author?.name||kt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:kt.author?.login||null,avatarUrl:kt.author?.avatarUrl||null,createdAt:kt.createdAt,context:a("gitView.pr.comments.reviewContext"),path:kt.path||null,line:kt.line??null})),ct=[...oe,...Qe];return ct.sort((kt,$t)=>{const Ft=kt.createdAt?Date.parse(kt.createdAt):0,ot=$t.createdAt?Date.parse($t.createdAt):0,At=Number.isFinite(Ft)?Ft:0,Q=Number.isFinite(ot)?ot:0;return At-Q}),ct},[rt,a]),yt=c.useCallback(()=>{const oe=y??(S?"draft":null);return oe?{directory:t,sessionKey:oe}:(_e.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[y,t,S,a]),Ot=c.useCallback((oe,Qe)=>{const ct=Qe.authorLogin?`@${Qe.authorLogin}`:Qe.authorName,kt=Qe.path?` · ${Qe.path}${Qe.line?`:${Qe.line}`:""}`:"";Li.getState().addDraft(oe,{source:"pr-comment",fileLabel:`PR #${Z?.number??""} ${ct}${kt}`,startLine:Qe.line??0,endLine:Qe.line??0,code:Qe.body,language:"markdown",text:""})},[Z?.number]),Ht=c.useCallback((oe,Qe)=>{const ct=oe.status||"unknown",kt=oe.conclusion??void 0,$t=kt?`${ct} / ${kt}`:ct,Ft=oe.app?.name||oe.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:Qe?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[Qe?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:oe.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:Ft?`${Ft} · ${$t}`:$t})]}),oe.detailsUrl?s.jsx(dt,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:oe.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(M,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),oe.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:oe.output.title}):null,oe.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:oe.output.summary}):null,oe.output?.text?s.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:oe.output.text}):null,Array.isArray(oe.annotations)&&oe.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",oe.annotations.length>20?` (showing 20/${oe.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:oe.annotations.slice(0,20).map((ot,At)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[ot.title||ot.level||"Issue",ot.path?` · ${ot.path}`:"",typeof ot.startLine=="number"?`:${ot.startLine}`:"",typeof ot.endLine=="number"&&ot.endLine!==ot.startLine?`-${ot.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:ot.message}),ot.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:ot.rawDetails}):null]},`${ot.path||"file"}:${ot.startLine||At}:${At}`))})]}):null,oe.job?.steps&&oe.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:oe.job.steps.map((ot,At)=>{const Q=(ot.conclusion||"").toLowerCase(),Ve=Q&&!["success","neutral","skipped"].includes(Q),at=`${oe.id??"run"}:${oe.job?.jobId??"job"}:${ot.number??At}:${ot.name}`,Rt=ht.has(at);return Ve?s.jsxs($i,{open:Rt,children:[s.jsxs("button",{type:"button",onClick:()=>{Xe(Vt=>{const Ut=new Set(Vt);return Ut.has(at)?Ut.delete(at):Ut.add(at),Ut})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(Ve?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[Rt?s.jsx(M,{name:"arrow-down-s",className:"size-4"}):s.jsx(M,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:ot.name}),ot.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:ot.conclusion}):null]}),s.jsx(zi,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof ot.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",ot.number]}):null,ot.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",ot.status]}):null,ot.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",ot.conclusion]}):null,ot.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",pt(ot.startedAt)]}):null,ot.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",pt(ot.completedAt)]}):null]})})]},at):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:ot.name}),ot.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:ot.conclusion}):null]},at)})})]}):null]})},[ht,pt,a]),[_t,zt]=c.useState(!1),[Wt,Jt]=c.useState(!1),es=c.useCallback(async()=>{if(!d?.prContext){_e.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!Z)return;const oe=yt();if(oe){zt(!0);try{const Qe=await nt(d,t,Z.number,{includeCheckDetails:!0,sourceRepo:Fe?.repo??null});if(!Qe){_e.error(a("gitView.pr.toast.loadChecksFailed"));return}const kt=(Qe.checkRuns??[]).filter(Ft=>bi(Ft.conclusion));if(kt.length===0){_e.message(a("gitView.pr.toast.noFailedChecks"));return}const $t=Li.getState();for(const Ft of kt){const ot=(Ft.annotations??[]).map(Ve=>[[Ve.level,Ve.title].filter(Boolean).join(" "),Ve.path?`${Ve.path}${typeof Ve.startLine=="number"?`:${Ve.startLine}`:""}`:null,Ve.message,Ve.rawDetails].filter(Boolean).join(`
3
- `)),At=(Ft.job?.steps??[]).filter(Ve=>bi(Ve.conclusion)).map(Ve=>`step ${Ve.number??"?"}: ${Ve.name} → ${Ve.conclusion}`),Q=[`check: ${Ft.job?.workflowName?`${Ft.job.workflowName} / ${Ft.name}`:Ft.name}`,`status: ${Ft.status??"unknown"} / ${Ft.conclusion??"unknown"}`,Ft.detailsUrl?`url: ${Ft.detailsUrl}`:null,Ft.output?.title?`title: ${Ft.output.title}`:null,Ft.output?.summary?`summary:
4
- ${Ft.output.summary}`:null,At.length>0?`failed steps:
5
- ${At.join(`
6
- `)}`:null,ot.length>0?`annotations:
7
- ${ot.join(`
8
- ---
9
- `)}`:null].filter(Boolean).join(`
10
-
11
- `);$t.addDraft(oe,{source:"pr-check",fileLabel:`PR #${Z.number} · ${Ft.name}`,startLine:0,endLine:0,code:Q,language:"text",text:""})}}catch(Qe){const ct=Qe instanceof Error?Qe.message:String(Qe);_e.error(a("gitView.pr.toast.loadChecksFailed"),{description:ct})}finally{zt(!1)}}},[t,nt,d,Z,yt,Fe?.repo,a]),Qt=c.useCallback(async()=>{if(!d?.prContext){_e.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!Z)return;const oe=yt();if(oe){Jt(!0);try{if(!await nt(d,t,Z.number,{sourceRepo:Fe?.repo??null})){_e.error(a("gitView.pr.toast.loadPrCommentsFailed"));return}if(tt.length===0){_e.message(a("gitView.pr.toast.noPrComments"));return}for(const ct of tt)Ot(oe,ct)}catch(Qe){const ct=Qe instanceof Error?Qe.message:String(Qe);_e.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:ct})}finally{Jt(!1)}}},[Ot,t,nt,d,Z,yt,Fe?.repo,a,tt]),qt=c.useCallback(async oe=>{const Qe=yt();Qe&&Ot(Qe,oe)},[Ot,yt]),Et=c.useCallback(async oe=>{await _(V,oe)},[V,_]),[wt,cs]=c.useState(!1),xs=c.useRef(!0);c.useEffect(()=>(xs.current=!0,()=>{xs.current=!1}),[]);const ds=c.useCallback(async()=>{if(wt)return;cs(!0);const oe=Date.now();try{await Et({force:!0})}finally{const Qe=Yy-(Date.now()-oe);Qe>0&&await new Promise(ct=>window.setTimeout(ct,Qe)),xs.current&&cs(!1)}},[wt,Et]),us=c.useCallback(()=>{U.current.forEach(oe=>{window.clearTimeout(oe)}),U.current=qy.map(oe=>window.setTimeout(()=>{Et({force:!0,silent:!0,markInitialResolved:!0})},oe))},[Et]);c.useEffect(()=>{if(!d?.prStatus||!He||i.length<=1||ut.current||Fe?.pr)return;const oe=`${k}::${z?.name??""}`;if(G.current.has(oe))return;G.current.add(oe);const Qe=Zy(i,r).filter($t=>$t.name!==z?.name);if(Qe.length===0)return;let ct=!1;return(async()=>{for(const $t of Qe){if(ct)return;try{if(!(await d.prStatus(t,e,$t.name))?.pr)continue;if(ct)return;ae(ot=>ot?.name===$t.name?ot:$t);return}catch{}}})(),()=>{ct=!0}},[e,He,t,d,i,z?.name,k,Fe?.pr,r]),c.useEffect(()=>{I(V),A(V,{directory:t,branch:e,remoteName:z?.name??null,canShow:He,github:d,githubAuthChecked:m,githubConnected:h?.connected??null})},[e,He,t,I,d,m,h?.connected,V,z?.name,A]),c.useEffect(()=>(P(V),()=>{T(V)}),[V,P,T]),c.useEffect(()=>{const oe=Mr.get(k)??null;O(oe?.title??fc(e)),j(oe?.body??""),K(oe?.draft??!1),ue(oe?.targetBaseBranch?_n(oe.targetBaseBranch):_n(n));const Qe=yi(i,{selectedRemoteName:oe?.selectedRemoteName,trackingBranch:r});ae(ct=>ct?.name===Qe?.name?ct:Qe)},[n,e,i,k,r]),c.useEffect(()=>{Et({markInitialResolved:!0})},[V,Et]),c.useEffect(()=>{!He||!z?.name||Et({force:!0,silent:!0,markInitialResolved:!0})},[He,Et,z?.name]),c.useEffect(()=>{const oe=Fe?.resolvedRemoteName?.trim();if(!oe||ut.current)return;const Qe=i.find(ct=>ct.name===oe);Qe&&ae(ct=>ct?.name===Qe.name?ct:Qe)},[i,Fe?.resolvedRemoteName]),c.useEffect(()=>{const oe=()=>{const ct=Ys.getState().entries[V]?.lastRefreshAt??0;Date.now()-ct>6e4&&Et({force:!0,silent:!0})},Qe=()=>{document.visibilityState==="visible"&&oe()};return window.addEventListener("focus",oe),document.addEventListener("visibilitychange",Qe),()=>{window.removeEventListener("focus",oe),document.removeEventListener("visibilitychange",Qe)}},[V,Et]),c.useEffect(()=>{m&&h?.connected===!1&&Et({force:!0,silent:!0,markInitialResolved:!0})},[m,h,Et]),c.useEffect(()=>{!t||!e||Mr.set(k,{title:W,body:$,draft:E,additionalContext:ee,targetBaseBranch:ne,selectedRemoteName:z?.name,activeSegment:mt})},[k,W,$,E,ee,ne,z?.name,t,e,mt]),c.useEffect(()=>{const oe=U.current;return()=>{oe.forEach(Qe=>{window.clearTimeout(Qe)}),U.current=[]}},[]);const ln=c.useCallback(async()=>{if(!fe&&t){je(!0);try{const Qe={base:ce&&we?.defaultBranchSha?we.defaultBranchSha:ne,head:e};ee&&(Qe.context=ee);const ct=await wp(t,Qe);ct.title?.trim()&&O(ct.title.trim()),ct.body?.trim()&&j(ct.body.trim()),l?.()}catch(oe){const Qe=oe instanceof Error?oe.message:String(oe);_e.error(a("gitView.pr.toast.generateDescriptionFailed"),{description:Qe})}finally{je(!1)}}},[ee,e,we?.defaultBranchSha,t,fe,l,ne,a,ce]),js=c.useCallback(async()=>{if(!d?.prCreate){_e.error(a("gitView.pr.toast.githubApiUnavailable"));return}const oe=W.trim();if(!oe){_e.error(a("gitView.pr.toast.titleRequired"));return}const Qe=ne.trim();if(!Qe){_e.error(a("gitView.pr.toast.baseBranchRequired"));return}if(!ce&&Qe===e){_e.error(a("gitView.pr.toast.baseMustDifferFromHead"));return}ye(!0);try{const ct=qa(r),kt=ce&&we,$t=await d.prCreate({directory:t,title:oe,head:e,base:Qe,...$.trim()?{body:$}:{},draft:E,...kt?{targetRepo:{owner:we.owner,repo:we.repo},headRemote:"origin"}:{...z?{remote:z.name}:{},...ct&&ct!==z?.name?{headRemote:ct}:{}}});_e.success(a("gitView.pr.toast.prCreated")),L(V,Ft=>Ft&&{...Ft,pr:$t}),await Et({force:!0}),us()}catch(ct){const kt=ct instanceof Error?ct.message:String(ct);_e.error(a("gitView.pr.toast.createPrFailed"),{description:kt})}finally{ye(!1)}},[$,e,we,t,E,d,V,Et,us,z,ne,W,r,L,ce,a]),pn=c.useCallback(async oe=>{if(!d?.prMerge){_e.error(a("gitView.pr.toast.githubApiUnavailable"));return}Y(!0);try{const Qe=await d.prMerge({directory:t,number:oe.number,method:X});Qe.merged?_e.success(a("gitView.pr.toast.prMerged")):_e.message(a("gitView.pr.toast.prNotMerged"),{description:Qe.message||a("gitView.pr.notMergeable")}),await Et({force:!0}),us()}catch(Qe){const ct=Qe instanceof Error?Qe.message:String(Qe);_e.error(a("gitView.pr.toast.mergeFailed"),{description:ct}),oe.url&&lo(oe.url)}finally{Y(!1)}},[t,d,X,Et,us,a]),gn=c.useCallback(async oe=>{if(!d?.prReady){_e.error(a("gitView.pr.toast.githubApiUnavailable"));return}H(!0);try{await d.prReady({directory:t,number:oe.number}),_e.success(a("gitView.pr.toast.markedReady")),await Et({force:!0}),us()}catch(Qe){const ct=Qe instanceof Error?Qe.message:String(Qe);_e.error(a("gitView.pr.toast.markReadyFailed"),{description:ct}),oe.url&&lo(oe.url)}finally{H(!1)}},[t,d,Et,us,a]),Js=c.useCallback(async oe=>{if(!d?.prUpdate){_e.error(a("gitView.pr.toast.githubApiUnavailable"));return}const Qe=B.trim();if(!Qe){_e.error(a("gitView.pr.toast.titleRequired"));return}xe(!0);try{const ct=await d.prUpdate({directory:t,number:oe.number,title:Qe,body:he});L(V,kt=>kt&&{...kt,pr:{...kt.pr??oe,...ct}}),pe(!1),_e.success(a("gitView.pr.toast.prUpdated")),await Et({force:!0}),us()}catch(ct){const kt=ct instanceof Error?ct.message:String(ct);_e.error(a("gitView.pr.toast.updatePrFailed"),{description:kt})}finally{xe(!1)}},[t,he,B,d,V,Et,us,L,a]);if(!He)return s.jsx("section",{className:"border-0 bg-transparent rounded-none",children:s.jsxs("div",{className:"space-y-1 pt-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("gitView.pullRequest.title")}),s.jsx(ic,{})]}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pullRequest.availableOnFeatureBranches")})]})});const cn=Fe?.repo?.url||null,ns=ce&&we?.url?we.url:cn,ks=!!Fe?.canMerge,Ks=!!Fe?.connected,Vs=m&&Fe?.connected===!1,As=Gy(Fe),Zs=As?`var(--pr-${As})`:"var(--status-info)",gs=As==="draft"?"git-pr-draft":As==="merged"?"git-merge":As==="closed"?"git-close-pull-request":"git-pull-request",dn=Z?[`${Z.state}${Z.draft?" (draft)":""}`,Z.mergeable===!1?a("gitView.pr.notMergeable"):null,Z.state==="open"&&typeof Z.mergeableState=="string"&&Z.mergeableState&&Z.mergeableState!=="unknown"?Z.mergeableState:null].filter(Boolean).join(" · "):"",xn=Ke?Ke.total>0?`${Ke.success}/${Ke.total} ${a("gitView.pr.checks.label")}`:`${Ke.state} ${a("gitView.pr.checks.label")}`:"";return s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[s.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex flex-col gap-1",children:[s.jsxs("div",{className:"@container/pr-actions flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[Z?s.jsxs(dt,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{lo(Z.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:[s.jsx(M,{name:gs,className:"size-4 shrink-0",style:{color:Zs}}),a("gitView.pr.actions.openOnGitHub")]}):s.jsx(M,{name:gs,className:"size-4 shrink-0",style:{color:"var(--surface-muted-foreground)"}}),s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:a("gitView.pullRequest.title")}),Z?s.jsxs("span",{className:"typography-meta text-muted-foreground truncate",children:["#",Z.number]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[Z&&N?s.jsxs(dt,{variant:"outline",size:"sm",className:Me("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",zy),onClick:()=>{p(t,{kind:"pr",number:Z.number,sourceRepo:Fe?.repo?{owner:Fe.repo.owner,repo:Fe.repo.repo}:void 0}),v(t,"walkthrough")},"aria-label":a("walkthrough.action.open"),children:[s.jsx(M,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}):null,s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Ie||wt,onClick:()=>{ds()},"aria-label":a("gitView.pr.actions.refreshAria"),children:Ie||wt?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):s.jsx(M,{name:"refresh",className:"size-4 text-muted-foreground"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.refresh")})})]}),s.jsx(ic,{className:"h-7 w-7"})]})]}),Z?s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{style:{color:Zs},children:dn}),Ke?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${uc(Ke.state)}`}),xn]}):null,r&&z&&r.split("/")[0]!==z.name?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",z.name]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[ks&&Z.draft&&Z.state==="open"?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(dt,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>gn(Z),disabled:ie||R||Pe||me,"aria-label":a("gitView.pr.actions.markReadyAria"),children:ie?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"checkbox-circle",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.markReady")})})]}):null,ks?s.jsxs(s.Fragment,{children:[s.jsxs(Ms,{value:X,onValueChange:oe=>te(oe),disabled:R||Z.state!=="open",children:[s.jsx(Os,{size:"sm",className:"h-7 w-auto min-w-0",children:s.jsx(Ns,{})}),s.jsxs(Bs,{children:[s.jsx(is,{value:"squash",children:a("gitView.pr.mergeMethod.squash")}),s.jsx(is,{value:"merge",children:a("gitView.pr.mergeMethod.merge")}),s.jsx(is,{value:"rebase",children:a("gitView.pr.mergeMethod.rebase")})]})]}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(dt,{size:"sm",className:"h-7 w-7 px-0",onClick:()=>pn(Z),disabled:R||ie||Z.state!=="open"||Z.draft||Pe||me,"aria-label":a("gitView.pr.actions.mergePrAria"),children:R?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"git-merge",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.mergePr")})})]})]}):null]})]}):null]}),s.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[Vs?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.pr.githubNotConnected")}),s.jsx(dt,{variant:"outline",size:"sm",onClick:C,className:"w-fit",children:a("gitView.pr.actions.openSettings")})]}):null,st?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.statusUnavailable")}),s.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:st}),ns?s.jsx(dt,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:ns,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(M,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!Z&&!lt&&!st&&!Vs?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.pr.checkingStatus")]}):Z&&!ke?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"h-8 min-w-0",children:s.jsx(Ud,{className:"h-full",items:[{id:"overview",label:a("gitView.pr.segment.overview")},{id:"checks",label:Ke&&Ke.total>0?`${a("gitView.pr.segment.checks")} ${Ke.success}/${Ke.total}`:a("gitView.pr.segment.checks"),icon:Ke?s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${uc(Ke.state)}`}):void 0},{id:"comments",label:rt?`${a("gitView.pr.segment.comments")} ${(rt.issueComments?.length??0)+(rt.reviewComments?.length??0)}`:a("gitView.pr.segment.comments")}],activeId:mt,onSelect:oe=>Nt(oe),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),mt==="overview"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[ks&&Z.draft?s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.draftMustBeReady")}):null,ks?null:s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.noMergePermission")}),s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("div",{className:"min-w-0 flex-1",children:me?s.jsx(In,{value:B,onChange:oe=>F(oe.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:f?"on":"off",autoCapitalize:f?"sentences":"off",spellCheck:f}):s.jsx("div",{className:"typography-markdown text-xl font-semibold text-foreground break-words leading-snug",children:Z.title})}),Z.state==="open"?s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:me?s.jsxs(s.Fragment,{children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(dt,{variant:"outline",size:"sm",className:"h-9 w-9 px-0",onClick:()=>{pe(!1),F(Z.title||""),Se(Z.body||"")},disabled:Pe,"aria-label":a("gitView.pr.actions.cancelEditingAria"),children:s.jsx(M,{name:"close",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.cancelEditing")})})]}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(dt,{size:"sm",className:"h-9 w-9 px-0",onClick:()=>Js(Z),disabled:Pe||!B.trim(),"aria-label":a("gitView.pr.actions.savePrAria"),children:Pe?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"check",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.savePr")})})]})]}):s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(dt,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>pe(!0),"aria-label":a("gitView.pr.actions.editPrAria"),children:s.jsx(M,{name:"edit",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.editPr")})})]})}):null]}),me?s.jsx(pr,{value:he,onChange:oe=>Se(oe.target.value),outerClassName:"min-h-[60vh]",placeholder:a("gitView.pr.placeholder.description"),autoCorrect:f?"on":"off",autoCapitalize:f?"sentences":"off",spellCheck:f}):null,me?null:Z.body?.trim()?s.jsx(Al,{content:Z.body,className:"typography-markdown-body min-w-0 text-muted-foreground break-words",enableFileReferences:!1}):s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:a(Le?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,mt==="checks"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[Ke&&Ke.total>0?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-muted/40",children:[Ke.success>0?s.jsx("div",{className:"bg-[color:var(--status-success)]",style:{width:`${Ke.success/Ke.total*100}%`}}):null,Ke.failure>0?s.jsx("div",{className:"bg-[color:var(--status-error)]",style:{width:`${Ke.failure/Ke.total*100}%`}}):null,Ke.pending>0?s.jsx("div",{className:"bg-[color:var(--status-warning)]",style:{width:`${Ke.pending/Ke.total*100}%`}}):null]}),s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Ke.success,"/",Ke.total," ",a("gitView.pr.checks.label")]}),(Ke.inProgress??0)>0?s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-[var(--status-warning)]",children:[s.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}),xi(Ke.startedAt,void 0,bt)]}):null]}):null,Ke?.failure?s.jsxs(dt,{variant:"outline",size:"sm",className:"w-fit gap-1.5 border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)]",onClick:es,disabled:_t,"aria-label":a("gitView.pr.actions.resolveFailedChecksAria"),children:[_t?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"ai-generate-2",className:"size-4"}),a("gitView.pr.actions.resolveFailedChecks")]}):null,(rt?.checkRuns?.length??0)>0?s.jsx("div",{className:"flex flex-col gap-1.5",children:(rt?.checkRuns??[]).map((oe,Qe)=>{const ct=`${oe.id??"run"}:${oe.name}:${Qe}`,kt=oe.status==="in_progress",$t=oe.status==="queued",Ft=bi(oe.conclusion),ot=Ct.has(ct),At=!!(oe.output?.title||oe.output?.summary||oe.output?.text||(oe.annotations?.length??0)>0||(oe.job?.steps?.length??0)>0||oe.detailsUrl),Q=oe.job?.workflowName,Ve=kt?xi(oe.startedAt,void 0,bt):xi(oe.startedAt,oe.completedAt);return s.jsxs("div",{className:Me("rounded-md border border-border/40",Ft&&"border-[var(--status-error-border)]"),children:[s.jsxs("button",{type:"button",disabled:!At,onClick:()=>{Mt(at=>{const Rt=new Set(at);return Rt.has(ct)?Rt.delete(ct):Rt.add(ct),Rt})},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left disabled:cursor-default",children:[kt?s.jsx(M,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-warning)]"}):$t?s.jsx(M,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):Ft?s.jsx(M,{name:"close-circle",className:"size-4 shrink-0 text-[var(--status-error)]"}):s.jsx(M,{name:"checkbox-circle",className:"size-4 shrink-0 text-[var(--status-success)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:Q&&Q!==oe.name?`${Q} / ${oe.name}`:oe.name}),Ve?s.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:Ve}):null,At?s.jsx(M,{name:"arrow-down-s",className:Me("size-4 shrink-0 text-muted-foreground transition-transform",ot&&"rotate-180")}):null]}),ot&&At?s.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:Ht(oe,{hideHeader:!0})}):null]},ct)})}):Ye?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.checkDetails.empty")})]}):null,mt==="comments"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[tt.length>0?s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(dt,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)]",onClick:Qt,disabled:Wt,"aria-label":a("gitView.pr.actions.shareCommentsAria"),children:[Wt?s.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(M,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.comments.addAll")]})}):null,tt.length>0?s.jsx("div",{className:"relative pl-3",children:s.jsx("div",{children:tt.map((oe,Qe)=>{const ct=(oe.authorName||"?").charAt(0).toUpperCase(),kt=Qe===tt.length-1;return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[kt?null:s.jsx("div",{className:"absolute left-4 top-[2.375rem] bottom-[0.375rem] w-px bg-border/60"}),s.jsx("div",{className:"absolute left-0 top-0 z-10 flex size-8 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-surface-elevated text-xs text-muted-foreground",children:oe.avatarUrl?s.jsx("img",{src:oe.avatarUrl,alt:oe.authorName,className:"h-full w-full object-cover"}):s.jsx("span",{children:ct})}),s.jsxs("div",{className:"rounded-lg bg-surface-elevated px-3 pt-0 pb-3 space-y-2",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1 typography-micro text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-1 sm:gap-y-1",children:[s.jsxs("span",{className:"text-foreground whitespace-nowrap",children:[oe.authorName,oe.authorLogin&&oe.authorLogin!==oe.authorName?` · @${oe.authorLogin}`:""]}),oe.createdAt?s.jsx("span",{className:"whitespace-nowrap",children:pt(oe.createdAt)}):null,s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsxs(dt,{variant:"ghost",size:"sm",className:"h-6 px-0 has-[>svg]:px-0 sm:px-2 sm:has-[>svg]:px-2.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)] justify-start",onClick:()=>{qt(oe)},"aria-label":a("gitView.pr.actions.sendCommentToAgentAria"),children:[s.jsx(M,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.actions.sendToAgent")]})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.sendCommentToAgent")})})]})]}),s.jsxs("div",{className:"typography-micro text-muted-foreground",children:[oe.context,oe.path?` · ${oe.path}`:"",oe.line?`:${oe.line}`:""]}),s.jsx(Al,{content:qe(oe.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",ze].filter(Boolean).join(" "),enableFileReferences:!1})]})]},oe.id)})})}):Ye&&!rt?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.comments.empty")})]}):null]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[Z&&ke?s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border/60 bg-surface-muted/40 px-2.5 py-2",children:[s.jsx(M,{name:Z.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:Zs}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:Z.state==="merged"?a("gitView.pr.history.merged",{number:Z.number,base:Z.base||ne}):a("gitView.pr.history.closed",{number:Z.number})}),s.jsx(dt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{lo(Z.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:s.jsx(M,{name:"external-link",className:"size-3.5"})})]}):null,s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.createTitle")}),s.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," ",s.jsx("span",{className:"opacity-60",children:"(local)"})," → ",ne," ",s.jsxs("span",{className:"opacity-60",children:["(",ce&&we?"upstream":"remote",")"]})]})]}),ns?s.jsx(dt,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:ns,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(M,{name:"external-link",className:"size-4"}),a("gitView.pr.actions.repo")]})}):null]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.title")}),s.jsx(In,{value:W,onChange:oe=>O(oe.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:f?"on":"off",autoCapitalize:f?"sentences":"off",spellCheck:f})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.baseBranch")}),it.length>0?s.jsxs(Ms,{value:ne,onValueChange:ue,children:[s.jsx(Os,{size:"lg",children:s.jsx(Ns,{placeholder:a("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx(Bs,{children:it.map(oe=>s.jsx(is,{value:oe,children:oe},oe))})]}):s.jsx(In,{value:ne,onChange:oe=>ue(oe.target.value),placeholder:a("gitView.pr.placeholder.main")})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.description")}),s.jsx(pr,{value:$,onChange:oe=>j(oe.target.value),className:"min-h-[110px]",placeholder:a("gitView.pr.placeholder.whatChanged"),autoCorrect:f?"on":"off",autoCapitalize:f?"sentences":"off",spellCheck:f})]}),s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":E,onClick:()=>K(oe=>!oe),onKeyDown:oe=>{(oe.key===" "||oe.key==="Enter")&&(oe.preventDefault(),K(Qe=>!Qe))},children:[s.jsx(br,{size:"sm",checked:E,onChange:oe=>K(oe),ariaLabel:a("gitView.pr.actions.toggleDraftAria")}),s.jsx("span",{className:"typography-ui-label text-foreground select-none",children:a("gitView.pr.field.draft")})]}),w?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx(dt,{variant:"outline",size:"sm",onClick:()=>q(!0),children:ee.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),ee.trim()&&s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"inline-flex items-center rounded-full bg-[var(--interactive-selection)] px-2 py-0.5 text-xs text-[var(--interactive-selection-foreground)]",children:a("gitView.pr.additionalContext.added")})})]}):s.jsxs($i,{open:Re,onOpenChange:le,children:[s.jsxs(xu,{className:"flex w-full items-center justify-between rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-3 py-2 hover:bg-[var(--interactive-hover)]",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx("span",{className:"typography-micro text-[var(--primary-base)]",children:Re?a("gitView.pr.actions.hide"):ee.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),s.jsx(zi,{children:s.jsxs("div",{className:"mt-2 space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:[s.jsx(pr,{value:ee,onChange:oe=>J(oe.target.value),className:"min-h-[100px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext")}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})})]}),s.jsx(Jo,{open:se,onClose:()=>q(!1),title:a("gitView.pr.additionalContext.title"),footer:s.jsx(dt,{size:"sm",onClick:()=>q(!1),className:"w-full",children:a("gitView.common.done")}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(pr,{value:ee,onChange:oe=>J(oe.target.value),className:"min-h-[200px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext"),autoFocus:!0}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(dt,{variant:"outline",size:"sm",onClick:ln,disabled:fe||ve,children:[fe?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"ai-generate-2",className:"size-4 text-primary"}),a("gitView.commit.generate")]}),s.jsx("div",{className:"flex-1"}),s.jsxs(dt,{size:"sm",className:"min-w-[7.5rem] justify-center gap-2",onClick:js,disabled:ve||!Ks||!ne.trim()||!ce&&ne.trim()===e,children:[s.jsx("span",{className:"inline-flex size-4 items-center justify-center",children:ve?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"git-pull-request",className:"size-4"})}),s.jsx("span",{children:a("gitView.pr.actions.createPr")})]})]})]})]})]})},wi=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/,""),co=new Map,uo=new Map,Fn=t=>`${as()}::${t}`,s1=()=>{const t=et.c(115),{t:e}=vt(),{git:n}=Cn(),r=lr(),{rootIsGitRepo:i,gitDirectory:o,nestedRepos:l}=vp(r??null),a=Pa(o??null),u=bu(o??null),d=yu(o??null),{ensureAll:h,ensureNestedRepos:m,selectNestedRepo:g}=Mn(ir(n1)),b=Ze(r1),y=Ze(o1),S=Ze(i1),w=Ze(a1);let f;t[0]!==r?(f=wi(r),t[0]=r,t[1]=f):f=t[1];const x=f;let v;if(t[2]!==w||t[3]!==x||t[4]!==S){e:{if(!x){v=void 0;break e}let z;if(t[6]!==w||t[7]!==x){let ce;t[9]!==x?(ce=Ne=>wi(Ne.path)===x,t[9]=x,t[10]=ce):ce=t[10],z=w.find(ce),t[6]=w,t[7]=x,t[8]=z}else z=t[8];const ae=z;if(ae){v=ae;break e}for(const ce of S.values())if(wi(ce.path)===x){v=ce;break e}v=void 0}t[2]=w,t[3]=x,t[4]=S,t[5]=v}else v=t[5];const p=v;let N;t[11]!==b||t[12]!==p||t[13]!==y?.open||t[14]!==S?(N=()=>{if(b)return S.get(b)??p;if(y?.open)return p},t[11]=b,t[12]=p,t[13]=y?.open,t[14]=S,t[15]=N):N=t[15],y?.open;let C;t[16]!==N?(C=N(),t[16]=N,t[17]=C):C=t[17];const k=C;let D;t[18]!==b?(D=z=>b?z.getAttachment(b):void 0,t[18]=b,t[19]=D):D=t[19];const I=iu(D),A=I&&!I.degraded&&!I.legacy?I.worktreeRoot??void 0:void 0,P=Iy(r,k,a?.current??void 0);let T,_;t[20]!==h||t[21]!==n||t[22]!==o?(T=()=>{!o||!n||h(o,n)},_=[o,h,n],t[20]=h,t[21]=n,t[22]=o,t[23]=T,t[24]=_):(T=t[23],_=t[24]),c.useEffect(T,_);const[L,W]=c.useState(null);let O;t[25]!==A||t[26]!==P?.projectDirectory?(O=()=>{const z=A||P?.projectDirectory;if(!z){W(null);return}let ae=!1;return Zo(z).then(ce=>{if(ae)return;const Ne=ce.trim();W(Ne&&Ne!=="HEAD"?Ne:null)}).catch(()=>{ae||W(null)}),()=>{ae=!0}},t[25]=A,t[26]=P?.projectDirectory,t[27]=O):O=t[27];const $=P?.projectDirectory;let j;t[28]!==A||t[29]!==$?(j=[A,$],t[28]=A,t[29]=$,t[30]=j):j=t[30],c.useEffect(O,j);let E;t[31]!==o?(E=()=>(o?co.get(Fn(o)):void 0)??[],t[31]=o,t[32]=E):E=t[32];const[K,ee]=c.useState(E);let J;t[33]!==o?(J=()=>(o?uo.get(Fn(o)):void 0)??null,t[33]=o,t[34]=J):J=t[34];const[ne,ue]=c.useState(J);let X,te;t[35]!==n||t[36]!==o?(X=()=>{if(!o||!n?.getRemotes){ee([]);return}ee(co.get(Fn(o))??[]);let z=!1;return n.getRemotes(o).then(ae=>{z||(co.set(Fn(o),ae??[]),ee(ae??[]))}).catch(()=>{z||ee(co.get(Fn(o))??[])}),()=>{z=!0}},te=[o,n],t[35]=n,t[36]=o,t[37]=X,t[38]=te):(X=t[37],te=t[38]),c.useEffect(X,te);let fe,je;t[39]!==n||t[40]!==o?(fe=()=>{if(!o||!n?.getRemoteUrl){ue(null);return}ue(uo.get(Fn(o))??null);let z=!1;return n.getRemoteUrl(o).then(ae=>{z||(uo.set(Fn(o),ae),ue(ae))}).catch(()=>{z||ue(uo.get(Fn(o))??null)}),()=>{z=!0}},je=[o,n],t[39]=n,t[40]=o,t[41]=fe,t[42]=je):(fe=t[41],je=t[42]),c.useEffect(fe,je);let ve;e:{if(!u?.all){let ae;t[43]===Symbol.for("react.memo_cache_sentinel")?(ae=[],t[43]=ae):ae=t[43],ve=ae;break e}let z;t[44]!==u.all?(z=u.all.filter(l1).sort(),t[44]=u.all,t[45]=z):z=t[45],ve=z}const ye=ve;let Pe;e:{if(!u?.all){let ae;t[46]===Symbol.for("react.memo_cache_sentinel")?(ae=[],t[46]=ae):ae=t[46],Pe=ae;break e}let z;t[47]!==u.all?(z=u.all.filter(c1).map(d1).sort(),t[47]=u.all,t[48]=z):z=t[48],Pe=z}const xe=Pe;let R;t[49]!==xe||t[50]!==ne||t[51]!==K||t[52]!==a?.tracking?(R=()=>{if(K.length>0)return K;const z=new Set,ae=a?.tracking?.trim();ae&&ae.includes("/")&&z.add(ae.split("/")[0]);for(const ce of xe){const Ne=ce.indexOf("/");Ne>0&&z.add(ce.slice(0,Ne))}return z.size===0&&ne&&z.add("origin"),Array.from(z).map(ce=>({name:ce,fetchUrl:ne??"",pushUrl:ne??""}))},t[49]=xe,t[50]=ne,t[51]=K,t[52]=a?.tracking,t[53]=R):R=t[53],a?.tracking;let Y;t[54]!==R?(Y=R(),t[54]=R,t[55]=Y):Y=t[55];const ie=Y,H=a?.current??null;a?.tracking;let me;t[56]!==a?.tracking?(me=a?.tracking?.trim().split("/")[0],t[56]=a?.tracking,t[57]=me):me=t[57];const pe=me,re=(pe&&u?.defaultBranches?.[pe])??u?.defaultBranches?.origin;let de;t[58]!==H||t[59]!==re||t[60]!==ie||t[61]!==ye||t[62]!==L||t[63]!==P?.createdFromBranch?(de=()=>Ch({remoteNames:new Set(ie.map(u1)),localBranches:ye,worktreeCreatedFromBranch:P?.createdFromBranch,rootBranchHint:L,defaultBranch:re,headBranch:H}),t[58]=H,t[59]=re,t[60]=ie,t[61]=ye,t[62]=L,t[63]=P?.createdFromBranch,t[64]=de):de=t[64],P?.createdFromBranch;let B;t[65]!==de?(B=de(),t[65]=de,t[66]=B):B=t[66];const F=B;if(!r){let z;t[67]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(M,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[67]=z):z=t[67];let ae;t[68]!==e?(ae=e("gitView.pullRequest.title"),t[68]=e,t[69]=ae):ae=t[69];let ce;t[70]!==ae?(ce=s.jsx("div",{className:"typography-ui-header text-foreground",children:ae}),t[70]=ae,t[71]=ce):ce=t[71];let Ne;t[72]!==e?(Ne=e("gitView.pullRequest.createHint"),t[72]=e,t[73]=Ne):Ne=t[73];let we;t[74]!==Ne?(we=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Ne}),t[74]=Ne,t[75]=we):we=t[75];let $e;return t[76]!==ce||t[77]!==we?($e=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[z,ce,we]}),t[76]=ce,t[77]=we,t[78]=$e):$e=t[78],$e}if(i===!1&&d!==!0){let z;t[79]!==r||t[80]!==m?(z=()=>{m(r,{force:!0})},t[79]=r,t[80]=m,t[81]=z):z=t[81];let ae;return t[82]!==d||t[83]!==l||t[84]!==i||t[85]!==z?(ae=s.jsx(Nh,{rootIsGitRepo:i,resolvedIsGitRepo:d,nestedRepos:l,onRetryDiscovery:z}),t[82]=d,t[83]=l,t[84]=i,t[85]=z,t[86]=ae):ae=t[86],ae}if(!H){let z;t[87]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(M,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[87]=z):z=t[87];let ae;t[88]!==e?(ae=e("gitView.pullRequest.title"),t[88]=e,t[89]=ae):ae=t[89];let ce;t[90]!==ae?(ce=s.jsx("div",{className:"typography-ui-header text-foreground",children:ae}),t[90]=ae,t[91]=ce):ce=t[91];let Ne;t[92]!==e?(Ne=e("gitView.pullRequest.createHint"),t[92]=e,t[93]=Ne):Ne=t[93];let we;t[94]!==Ne?(we=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Ne}),t[94]=Ne,t[95]=we):we=t[95];let $e;return t[96]!==ce||t[97]!==we?($e=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[z,ce,we]}),t[96]=ce,t[97]=we,t[98]=$e):$e=t[98],$e}const he=i===!1&&Array.isArray(l)&&l.length>0;let Se;t[99]!==r||t[100]!==o||t[101]!==l||t[102]!==g||t[103]!==he?(Se=he?s.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:s.jsx(Ah,{repositories:l,selectedRepository:o??null,onSelectRepository:z=>{r&&g(r,z)},repositoryRoot:r??void 0})}):null,t[99]=r,t[100]=o,t[101]=l,t[102]=g,t[103]=he,t[104]=Se):Se=t[104];const Re=o??r,le=a?.tracking??void 0;let se;t[105]!==F||t[106]!==H||t[107]!==xe||t[108]!==K||t[109]!==Re||t[110]!==le?(se=s.jsx(jn,{as:Ia,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(t1,{directory:Re,branch:H,baseBranch:F,trackingBranch:le,remotes:K,remoteBranches:xe})}),t[105]=F,t[106]=H,t[107]=xe,t[108]=K,t[109]=Re,t[110]=le,t[111]=se):se=t[111];let q;return t[112]!==Se||t[113]!==se?(q=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[Se,se]}),t[112]=Se,t[113]=se,t[114]=q):q=t[114],q};function n1(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function r1(t){return t.currentSessionId}function o1(t){return t.newSessionDraft}function i1(t){return t.worktreeMetadata}function a1(t){return t.availableWorktrees}function l1(t){return!t.startsWith("remotes/")}function c1(t){return t.startsWith("remotes/")}function d1(t){return t.replace(/^remotes\//,"")}function u1(t){return t.name}const na=2e4,f1=(t,e)=>{if(!t)return 1;let n=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&(n+=1,n>e))return n;return n},fo=(t,e)=>Np(Ap.getState().dictionary,t,e),m1=t=>{const n=(t instanceof Error?t.message:String(t??"")).toLowerCase();return n.includes("file not found")||n.includes("not found")||n.includes("enoent")||n.includes("no such file")||n.includes("does not exist")?"missing":"unreadable"},h1=async(t,e,n)=>{if(t.readFile)return(await t.readFile(e,{optional:!0,directory:n?.directory})).content??"";const r=new URLSearchParams({path:e,optional:"true"});n?.directory&&r.set("directory",n.directory);const i=await ms(`/api/fs/read?${r.toString()}`,{cache:"no-store",headers:n?.directory?{"x-opencode-directory":n.directory}:void 0});if(!i.ok){const o=await i.json().catch(()=>({error:i.statusText}));throw new Error(o.error||"Failed to read file")}return i.text()},gf=async(t,e,n)=>{if(Sp(e)||jp(e)||kp(e))return{ok:!0};try{const r=await h1(t,e,n);return Cp(r)?{ok:!1,reason:"binary"}:f1(r,na)>na?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:m1(r)}}},xf=t=>{if(t==="too-large"){const e=na.toLocaleString(wu());return fo("contextFileOpen.failure.tooLarge",{count:e})}return fo(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},mc=8;let ra=null;const bf=t=>{ra={x:t.clientX,y:t.clientY}},yf=t=>{const e=ra;return ra=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Math.abs(t.clientX-e.x)<=mc&&Math.abs(t.clientY-e.y)<=mc},hc=3,wr=t=>Array.from(t.types).includes("Files"),p1=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(n=>{if(n.kind!=="file"||n.webkitGetAsEntry()?.isDirectory)return[];const r=n.getAsFile();return r?[r]:[]})},pc=t=>{const e=t.name;return!e||e==="."||e===".."||e.includes("/")||e.includes("\\")?null:e},g1=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),fs=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Ya=(t,e)=>{const n=fs(e),r=fs(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},x1=(t,e)=>{const n=Ya(t,e);if(n!==".")return n;const r=fs(t);return r.split("/").filter(Boolean).pop()??r},b1=t=>{const e=fs(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},y1=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),w1=new Set(["node_modules"]),v1=t=>w1.has(t),S1=t=>{const e=fs(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},j1=8,yn=new Map,Qa=t=>JSON.stringify([as(),t]),k1=t=>{const e=Qa(t),n=yn.get(e);return n?(n.touchedAt=Date.now(),yn.delete(e),yn.set(e,n),n):null},vi=t=>{const e=Qa(t),n=yn.get(e);if(n)return n.touchedAt=Date.now(),n;if(yn.size>=j1){const i=yn.keys().next().value;i!==void 0&&yn.delete(i)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return yn.set(e,r),r},wf=(t,e)=>s.jsx(Ta,{filePath:t,extension:e}),C1=t=>{const e=et.c(3),{status:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=r):r=e[0];const i=r[n];let o;return e[1]!==i?(o=s.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:i}}),e[1]=i,e[2]=o):o=e[2],o},N1=t=>{const e=et.c(88),{node:n,root:r,isExpanded:i,isActive:o,isBrowserClient:l,status:a,badge:u,isDropTarget:d,canUpload:h,permissions:m,downloadFile:g,onSelect:b,onToggle:y,onRevealPath:S,onOpenDialog:w,onSetDropTarget:f,onDropFiles:x}=t,{t:v}=vt(),p=n.type==="directory";let N;e[0]!==p||e[1]!==n.path?(N=p?n.path:b1(n.path),e[0]=p,e[1]=n.path,e[2]=N):N=e[2];const C=N,{canRename:k,canCreateFile:D,canCreateFolder:I,canDelete:A,canReveal:P}=m,T=!p&&!!g,_=P&&!l,L=k||D||I||A||T||_,[W,O]=c.useState(!1),[$,j]=c.useState(!1);let E;e[3]!==L?(E=ae=>{L&&(ae?.preventDefault(),j(!0))},e[3]=L,e[4]=E):E=e[4];const K=E;let ee;e[5]!==p||e[6]!==n||e[7]!==b||e[8]!==y?(ee=()=>{p?y(n.path):b(n)},e[5]=p,e[6]=n,e[7]=b,e[8]=y,e[9]=ee):ee=e[9];const J=ee;let ne;e[10]===Symbol.for("react.memo_cache_sentinel")?(ne=ae=>{ae.stopPropagation(),j(!1),O(!0)},e[10]=ne):ne=e[10];const ue=ne;let X;e[11]!==D||e[12]!==I||e[13]!==A||e[14]!==k||e[15]!==_||e[16]!==g||e[17]!==l||e[18]!==p||e[19]!==n||e[20]!==w||e[21]!==S||e[22]!==v?(X=ae=>{const{Item:ce,Separator:Ne}=ae;return s.jsxs(s.Fragment,{children:[k&&s.jsxs(ce,{onClick:we=>{we.stopPropagation(),w("rename",n)},children:[s.jsx(M,{name:"edit",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.rename")]}),s.jsxs(ce,{onClick:we=>{we.stopPropagation(),wn(n.path).then($e=>{if($e.ok){_e.success(v("sidebarFilesTree.toast.pathCopied"));return}_e.error(v("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(M,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.copyPath")]}),!p&&g&&s.jsxs(ce,{onClick:we=>{we.stopPropagation(),g(n.path).catch($e=>{console.error("Download failed:",$e),_e.error(v("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(M,{name:"download",className:"mr-2 h-4 w-4"})," ",v(l?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),_&&s.jsxs(ce,{onClick:we=>{we.stopPropagation(),S(n.path)},children:[s.jsx(M,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",v(Dp())]}),p&&(D||I)&&s.jsxs(s.Fragment,{children:[s.jsx(Ne,{}),D&&s.jsxs(ce,{onClick:we=>{we.stopPropagation(),w("createFile",n)},children:[s.jsx(M,{name:"file-add",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.newFile")]}),I&&s.jsxs(ce,{onClick:we=>{we.stopPropagation(),w("createFolder",n)},children:[s.jsx(M,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.newFolder")]})]}),A&&s.jsxs(s.Fragment,{children:[s.jsx(Ne,{}),s.jsxs(ce,{onClick:we=>{we.stopPropagation(),w("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(M,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.delete")]})]})]})},e[11]=D,e[12]=I,e[13]=A,e[14]=k,e[15]=_,e[16]=g,e[17]=l,e[18]=p,e[19]=n,e[20]=w,e[21]=S,e[22]=v,e[23]=X):X=e[23];const te=X;let fe;e[24]!==n.path||e[25]!==r?(fe=ae=>{bf(ae);const ce=Ya(r,n.path);!ce||ce==="."||(ae.dataTransfer.setData("application/x-openchamber-file-path",ce),ae.dataTransfer.effectAllowed="copy")},e[24]=n.path,e[25]=r,e[26]=fe):fe=e[26];const je=fe;let ve;e[27]!==J?(ve=ae=>{yf(ae)&&J()},e[27]=J,e[28]=ve):ve=e[28];const ye=ve;let Pe;e[29]!==h||e[30]!==f||e[31]!==C?(Pe=ae=>{!h||!C||!wr(ae.dataTransfer)||(ae.preventDefault(),ae.stopPropagation(),ae.dataTransfer.dropEffect="copy",f(C))},e[29]=h,e[30]=f,e[31]=C,e[32]=Pe):Pe=e[32];const xe=Pe;let R;e[33]!==h||e[34]!==f||e[35]!==C?(R=ae=>{!h||!C||!wr(ae.dataTransfer)||ae.relatedTarget instanceof Node&&ae.currentTarget.contains(ae.relatedTarget)||(ae.stopPropagation(),f(null))},e[33]=h,e[34]=f,e[35]=C,e[36]=R):R=e[36];const Y=R;let ie;e[37]!==h||e[38]!==x||e[39]!==C?(ie=ae=>{!h||!C||!wr(ae.dataTransfer)||(ae.preventDefault(),ae.stopPropagation(),x(C,ae.dataTransfer))},e[37]=h,e[38]=x,e[39]=C,e[40]=ie):ie=e[40];const H=ie;let me;e[41]===Symbol.for("react.memo_cache_sentinel")?(me={contentVisibility:"auto",blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[41]=me):me=e[41];let pe;e[42]!==K||e[43]!==Y||e[44]!==xe||e[45]!==H?(pe=s.jsx("div",{className:"group relative flex items-center typography-meta",style:me,onContextMenu:K,onDragEnter:xe,onDragOver:xe,onDragLeave:Y,onDrop:H}),e[42]=K,e[43]=Y,e[44]=xe,e[45]=H,e[46]=pe):pe=e[46];const re=d?"bg-interactive-selection ring-2 ring-inset ring-primary":o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let de;e[47]!==re?(de=Me("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",re),e[47]=re,e[48]=de):de=e[48];let B;e[49]!==p||e[50]!==i||e[51]!==n.extension||e[52]!==n.path?(B=p?i?s.jsx(M,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):s.jsx(M,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):wf(n.path,n.extension),e[49]=p,e[50]=i,e[51]=n.extension,e[52]=n.path,e[53]=B):B=e[53];let F;e[54]!==n.name||e[55]!==n.path?(F=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[54]=n.name,e[55]=n.path,e[56]=F):F=e[56];let he;e[57]!==p||e[58]!==a?(he=!p&&a&&s.jsx(C1,{status:a}),e[57]=p,e[58]=a,e[59]=he):he=e[59];let Se;e[60]!==u||e[61]!==p?(Se=p&&u&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[u.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",u.modified]}),u.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",u.added]})]}),e[60]=u,e[61]=p,e[62]=Se):Se=e[62];let Re;e[63]!==K||e[64]!==ye||e[65]!==je||e[66]!==J||e[67]!==de||e[68]!==B||e[69]!==F||e[70]!==he||e[71]!==Se?(Re=s.jsxs("button",{type:"button",onClick:J,onContextMenu:K,draggable:!0,onDragStart:je,onDragEnd:ye,className:de,children:[B,F,he,Se]}),e[63]=K,e[64]=ye,e[65]=je,e[66]=J,e[67]=de,e[68]=B,e[69]=F,e[70]=he,e[71]=Se,e[72]=Re):Re=e[72];let le;e[73]!==W||e[74]!==L||e[75]!==te||e[76]!==v?(le=L&&s.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:s.jsxs(zs,{open:W,onOpenChange:O,children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(Ls,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:ue,title:v("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":v("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(M,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:v("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx($s,{align:"end",side:"bottom",onCloseAutoFocus:()=>O(!1),children:te({Item:Kt,Separator:Rs})})]})}),e[73]=W,e[74]=L,e[75]=te,e[76]=v,e[77]=le):le=e[77];let se;e[78]!==pe||e[79]!==Re||e[80]!==le?(se=s.jsxs(Gd,{render:pe,children:[Re,le]}),e[78]=pe,e[79]=Re,e[80]=le,e[81]=se):se=e[81];let q;e[82]!==te?(q=s.jsx(Hd,{className:"min-w-[180px]",children:te({Item:Jn,Separator:Bi})}),e[82]=te,e[83]=q):q=e[83];let z;return e[84]!==$||e[85]!==se||e[86]!==q?(z=s.jsxs(qd,{open:$,onOpenChange:j,children:[se,q]}),e[84]=$,e[85]=se,e[86]=q,e[87]=z):z=e[87],z},A1=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.canUpload===e.canUpload&&t.permissions===e.permissions&&t.downloadFile===e.downloadFile&&t.onSelect===e.onSelect&&t.onToggle===e.onToggle&&t.onRevealPath===e.onRevealPath&&t.onOpenDialog===e.onOpenDialog&&t.onSetDropTarget===e.onSetDropTarget&&t.onDropFiles===e.onDropFiles,D1=c.memo(N1,A1),P1=t=>{const e=et.c(6),{visible:n}=t,r=n===void 0?!0:n,i=Mn(T1),o=lr();let l;e[0]!==o||e[1]!==i?(l=JSON.stringify([i,o]),e[0]=o,e[1]=i,e[2]=l):l=e[2];let a;return e[3]!==l||e[4]!==r?(a=s.jsx(I1,{visible:r},l),e[3]=l,e[4]=r,e[5]=a):a=e[5],a},I1=({visible:t})=>{const e=c.useRef(t);e.current=t;const{t:n}=vt(),{files:r,runtime:i}=Cn(),o=Gm(i.platform),l=lr()??"",a=fs(l.trim()),u=Qa(a),d=qm(),h=Ym(),m=_d(be=>be.searchFiles),g=De(be=>be.openContextFile),b=Pa(t?l:null),[y,S]=c.useState(""),w=vu(y,200),f=c.useRef(null),[x,v]=c.useState([]),[p,N]=c.useState(!1),[C,k]=c.useState(null),[D,I]=c.useState(!1),[A,P]=c.useState(null),T=c.useRef(!1),_=c.useRef(a);_.current=a;const[L,W]=c.useState({}),[O,$]=c.useState({}),j=c.useRef(new Set),E=c.useMemo(()=>new Wx,[]);c.useEffect(()=>()=>E.clear(),[E]);const K=c.useRef(null);c.useEffect(()=>{if(k(null),P(null),!a){W({}),$({}),j.current=new Set;return}const be=k1(a);be?(W({...be.childrenByDir}),$({...be.loadErrorsByDir}),j.current=new Set(be.loadedDirs)):(W({}),$({}),j.current=new Set)},[a]),c.useEffect(()=>{if(!a)return;const be=vi(a);be.childrenByDir=L},[a,L]),c.useEffect(()=>{if(!a)return;const be=vi(a);be.loadErrorsByDir=O},[a,O]),c.useEffect(()=>{if(!a)return;const be=vi(a);be.loadedDirs=new Set(j.current)},[a,L,O]),c.useEffect(()=>()=>{if(!a)return;const be=yn.get(u);be&&be.loadedDirs.size===0&&Object.keys(be.childrenByDir).length===0&&yn.delete(u)},[u,a]);const ee=c.useMemo(()=>[],[]),J=c.useMemo(()=>[],[]),ne=bn(be=>a?be.byRoot[a]?.expandedPaths??ee:ee),ue=c.useMemo(()=>new Set(ne),[ne]),X=bn(be=>a?be.byRoot[a]?.selectedPath??null:null),te=bn(be=>be.setSelectedPath),fe=bn(be=>be.addOpenPath),je=bn(be=>be.removeOpenPathsByPrefix),ve=bn(be=>be.toggleExpandedPath),ye=bn(be=>be.collapseAllExpandedPaths),Pe=De(be=>a?be.contextPanelByDirectory[a]?.tabs??J:J),xe=c.useMemo(()=>new Set(Pe.map(be=>be.mode==="file"?be.targetPath:null).filter(be=>typeof be=="string"&&be.length>0).map(be=>fs(be))),[Pe]),[R,Y]=c.useState(null),[ie,H]=c.useState(null),[me,pe]=c.useState(""),[re,de]=c.useState(!1),B=!!r.writeFile,F=!!r.createDirectory,he=!!r.rename,Se=!!r.delete,Re=!!r.revealPath,le=!!r.uploadFile,se=c.useMemo(()=>({canRename:he,canCreateFile:B,canCreateFolder:F,canDelete:Se,canReveal:Re}),[he,B,F,Se,Re]),q=c.useCallback(be=>{r.revealPath&&r.revealPath(be).catch(()=>{_e.error(n("sidebarFilesTree.toast.revealFailed"))})},[r,n]),z=c.useCallback((be,Ue)=>{Y(be),H(Ue),pe(be==="rename"&&Ue.name||""),de(!1)},[]),ae=c.useCallback((be,Ue)=>{const ut=Ue.filter(G=>G&&typeof G.name=="string"&&G.name.length>0).filter(G=>d||!G.name.startsWith(".")).filter(G=>h||!v1(G.name)).map(G=>{const U=G.name,Z=fs(G.path||""),ke=Z?y1(Z)?Z:fs(`${be}/${Z}`):fs(`${be}/${U}`),Te=G.isDirectory?"directory":"file",We=Te==="file"&&U.includes(".")?U.split(".").pop()?.toLowerCase():void 0;return{name:U,path:ke,type:Te,extension:We}});return g1(ut)},[h,d]),ce=c.useCallback(async(be,Ue,ut=!1)=>{if(!e.current||Ue?.())return;const G=fs(be.trim());if(!G||!ut&&j.current.has(G))return;const U=as();return E.run(G,async Z=>{const ke=()=>!Z()||as()!==U;try{const Te=r.listDirectory?(await r.listDirectory(G)).entries:await Xs.listLocalDirectory(G);if(ke())return;const We=ae(G,Te);j.current=new Set(j.current),j.current.add(G),$(Je=>{if(!Je[G])return Je;const nt={...Je};return delete nt[G],nt}),W(Je=>Je[G]&&Kx(Je[G],We)?Je:{...Je,[G]:We})}catch(Te){if(ke())return;const We=Te instanceof Error?Te.message:String(Te??"");console.error("Failed to load sidebar directory:",Te),$(Je=>({...Je,[G]:We}))}},ut)},[E,r,ae]),Ne=c.useCallback(async()=>{if(!a)return;K.current?.abort();const be=new AbortController;K.current=be,E.clear();try{const ut=(bn.getState().byRoot[a]?.expandedPaths??[]).map(Z=>fs(Z)).filter(Z=>!!Z&&Z!==a&&Z.startsWith(`${a}/`)),G=[a,...ut];j.current=new Set(j.current);for(const Z of G)j.current.delete(Z);$(Z=>{if(Object.keys(Z).length===0)return Z;const ke={...Z};let Te=!1;for(const We of G)We in ke&&(delete ke[We],Te=!0);return Te?ke:Z});const U=()=>be.signal.aborted;await ce(a,U);for(let Z=0;Z<ut.length&&!be.signal.aborted;Z+=3){const ke=ut.slice(Z,Z+3);await Promise.all(ke.map(Te=>ce(Te,U)))}}catch(Ue){if(be.signal.aborted)return;console.error("Failed to refresh sidebar tree:",Ue)}finally{K.current===be&&(K.current=null)}},[E,ce,a]),we=c.useCallback(async be=>{if(!be){await Ne();return}const Ue=fs(be);j.current=new Set(j.current),j.current.delete(Ue),await ce(Ue,void 0,!0)},[ce,Ne]);c.useEffect(()=>{a&&(K.current?.abort(),j.current=new Set,E.clear(),$({}),W(be=>Object.keys(be).length===0?be:{}),ce(a))},[E,ce,a,d,h]),c.useEffect(()=>{if(!t||!a||ne.length===0)return;const be=ne.map(G=>fs(G)).filter(G=>!!G&&G!==a&&G.startsWith(`${a}/`)&&!j.current.has(G)&&!E.has(G)).sort((G,U)=>G.split("/").length-U.split("/").length);if(be.length===0)return;let Ue=!1;const ut=()=>Ue;return(async()=>{for(let G=0;G<be.length&&!Ue;G+=3){const U=be.slice(G,G+3);await Promise.all(U.map(Z=>ce(Z,ut)))}})(),()=>{Ue=!0}},[E,ne,ce,a,t]);const $e=c.useRef(t);c.useEffect(()=>{const be=t&&!$e.current;$e.current=t,be&&Ne()},[Ne,t]),c.useEffect(()=>{if(!t)return;if(!l){v([]),N(!1);return}const be=w.trim();if(!be){v([]),N(!1);return}let Ue=!1;return N(!0),m(l,be,150,{includeHidden:d,respectGitignore:!h,type:"file"}).then(ut=>{if(Ue)return;const U=ut.filter(Z=>h||!S1(Z.path)).map(Z=>({name:Z.name,path:fs(Z.path),type:"file",extension:Z.extension,relativePath:Z.relativePath}));v(U)}).catch(()=>{Ue||v([])}).finally(()=>{Ue||N(!1)}),()=>{Ue=!0}},[l,w,m,d,h,t]);const Oe=c.useMemo(()=>{const be=new Map;if(!b?.files)return be;for(const Ue of b.files)Ue.index==="A"||Ue.working_dir==="?"?be.set(Ue.path,"git-added"):Ue.index==="D"?be.set(Ue.path,"git-deleted"):(Ue.index==="M"||Ue.working_dir==="M")&&be.set(Ue.path,"git-modified");return be},[b]),ge=c.useMemo(()=>{const be=new Map;if(!b?.files||!a)return be;for(const Ue of b.files){const ut=Ue.index==="M"||Ue.working_dir==="M",G=Ue.index==="A"||Ue.working_dir==="?";if(!ut&&!G)continue;const U=Ue.path.split("/");if(U.length<=1)continue;let Z=a;for(let ke=0;ke<U.length-1;ke++){Z=`${Z}/${U[ke]}`;let Te=be.get(Z);Te||(Te={modified:0,added:0},be.set(Z,Te)),ut&&Te.modified++,G&&Te.added++}}return be},[b,a]),He=c.useCallback(be=>{if(xe.has(be))return"open";if(Oe.size===0)return null;const Ue=be.startsWith(a+"/")?be.slice(a.length+1):be;return Oe.get(Ue)??null},[xe,Oe,a]),V=c.useCallback(be=>{if(ge.size===0)return null;const Ue=ge.get(be);return Ue&&Ue.modified+Ue.added>0?Ue:null},[ge]),Ae=c.useCallback(async be=>{if(!a)return;const Ue=await gf(r,be.path,{directory:a});if(!Ue.ok){_e.error(xf(Ue.reason));return}te(a,be.path),fe(a,be.path),g(a,be.path)},[fe,r,g,a,te]),Ie=c.useCallback(async be=>{const Ue=fs(be);a&&(ve(a,Ue),j.current.has(Ue)||await ce(Ue))},[ce,a,ve]),Fe=c.useCallback(async(be,Ue,ut=!1)=>{const G=r.uploadFile;if(!G||Ue.length===0||T.current||!a)return;const U=a,Z=as();T.current=!0,I(!0),k(be),ut&&P(null);const ke=[];for(let Ye=0;Ye<Ue.length;Ye+=hc){const Nt=Ue.slice(Ye,Ye+hc),Ke=await Promise.all(Nt.map(async Tt=>{const Ce=pc(Tt);if(!Ce||as()!==Z)return"failed";try{return(await G(fs(`${be}/${Ce}`),Tt,{directory:U,overwrite:ut})).success?"uploaded":"failed"}catch(ft){return!ut&&Qm(ft)&&ft.reason==="already-exists"?"conflict":"failed"}}));ke.push(...Ke)}const Te=ke.filter(Ye=>Ye==="uploaded").length,We=ke.filter(Ye=>Ye==="failed").length,Je=Ue.filter((Ye,Nt)=>ke[Nt]==="conflict"),nt=Ue.flatMap((Ye,Nt)=>{const Ke=pc(Ye);return ke[Nt]==="uploaded"&&Ke?[fs(`${be}/${Ke}`)]:[]}),rt=_.current===U&&as()===Z;try{nt.length>0&&Vx({runtimeKey:Z,paths:nt}),Te>0&&rt&&await we(be),Te>0&&_e.success(n(Je.length>0?"sidebarFilesTree.toast.uploadedWithoutConflicts":"sidebarFilesTree.toast.uploaded")),We>0&&_e.error(n("sidebarFilesTree.toast.uploadFailed")),Je.length>0&&rt&&P({directory:be,files:Je,runtimeKey:Z,workspaceRoot:U})}finally{T.current=!1,I(!1),k(null)}},[r.uploadFile,we,a,n]),st=c.useCallback((be,Ue)=>{const ut=p1(Ue);ut.length!==0&&Fe(be,ut)},[Fe]),lt=c.useCallback(be=>{!le||T.current||!a||!wr(be.dataTransfer)||(be.preventDefault(),be.dataTransfer.dropEffect="copy",k(a))},[le,a]),it=c.useCallback(be=>{wr(be.dataTransfer)&&(be.relatedTarget instanceof Node&&be.currentTarget.contains(be.relatedTarget)||k(null))},[]),mt=c.useCallback(be=>{!le||T.current||!a||!wr(be.dataTransfer)||(be.preventDefault(),st(a,be.dataTransfer))},[le,st,a]),St=c.useCallback(async be=>{if(be?.preventDefault(),!ie||!R)return;de(!0);const Ue=()=>de(!1),ut=()=>Y(null);if(R==="createFile"){if(!me.trim()){_e.error(n("sidebarFilesTree.toast.filenameRequired")),Ue();return}if(!r.writeFile){_e.error(n("sidebarFilesTree.toast.writeNotSupported")),Ue();return}const G=ie.path,U=G?`${G}/`:"",Z=fs(`${U}${me.trim()}`);await r.writeFile(Z,"").then(async ke=>{ke.success&&(_e.success(n("sidebarFilesTree.toast.fileCreated")),await we(G)),ut()}).catch(()=>_e.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ue);return}if(R==="createFolder"){if(!me.trim()){_e.error(n("sidebarFilesTree.toast.folderNameRequired")),Ue();return}const G=ie.path,U=G?`${G}/`:"",Z=fs(`${U}${me.trim()}`);await r.createDirectory(Z).then(async ke=>{ke.success&&(_e.success(n("sidebarFilesTree.toast.folderCreated")),await we(G)),ut()}).catch(()=>_e.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ue);return}if(R==="rename"){if(!me.trim()){_e.error(n("sidebarFilesTree.toast.nameRequired")),Ue();return}if(!r.rename){_e.error(n("sidebarFilesTree.toast.renameNotSupported")),Ue();return}const G=ie.path,U=G.split("/").slice(0,-1).join("/"),Z=U?`${U}/`:"",ke=fs(`${Z}${me.trim()}`);await r.rename(G,ke).then(async Te=>{Te.success&&(_e.success(n("sidebarFilesTree.toast.renamedSuccessfully")),await we(U),a&&je(a,G),(X===G||X&&X.startsWith(`${G}/`))&&te(a,null)),ut()}).catch(()=>_e.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ue);return}if(R==="delete"){if(!r.delete){_e.error(n("sidebarFilesTree.toast.deleteNotSupported")),Ue();return}const G=ie.path,U=G.split("/").slice(0,-1).join("/");await r.delete(G).then(async Z=>{Z.success&&(_e.success(n("sidebarFilesTree.toast.deletedSuccessfully")),await we(U),a&&je(a,G),(X===G||X&&X.startsWith(G+"/"))&&te(a,null)),ut()}).catch(()=>_e.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ue);return}Ue()},[R,ie,me,r,we,je,a,X,te,n]);function ht(be,Ue){const ut=L[be]??[];return ut.map((G,U)=>{const Z=G.type==="directory",ke=Z&&ue.has(G.path),Te=X===G.path,We=U===ut.length-1;return s.jsxs("li",{className:"relative",children:[Ue>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),We&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),s.jsx(D1,{node:G,root:a,isExpanded:ke,isActive:Te,isBrowserClient:o,status:Z?void 0:He(G.path),badge:Z?V(G.path):void 0,isDropTarget:Z&&C===G.path,canUpload:le&&!D,permissions:se,downloadFile:r.downloadFile,onSelect:Ae,onToggle:Ie,onRevealPath:q,onOpenDialog:z,onSetDropTarget:k,onDropFiles:st}),Z&&ke&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[O[G.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:O[G.path],children:O[G.path]}),s.jsxs(dt,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{we(G.path)},children:[s.jsx(M,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):null,ht(G.path,Ue+1)]})]},G.path)})}const Xe=!!(a&&L[a]),Ct=a?O[a]:null,Mt=C?x1(a,C):"";return s.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[B&&s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(dt,{variant:"ghost",size:"sm",onClick:()=>z("createFile",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.newFileTitle"),"aria-label":n("sidebarFilesTree.actions.newFileTitle"),children:s.jsx(M,{name:"file-add",className:"h-4 w-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFileTitle")})]}),F&&s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(dt,{variant:"ghost",size:"sm",onClick:()=>z("createFolder",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.newFolderTitle"),"aria-label":n("sidebarFilesTree.actions.newFolderTitle"),children:s.jsx(M,{name:"folder-add",className:"h-4 w-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFolderTitle")})]}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(dt,{variant:"ghost",size:"sm",onClick:()=>{Ne()},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.refreshTitle"),"aria-label":n("sidebarFilesTree.actions.refreshTitle"),children:s.jsx(M,{name:"refresh",className:"h-4 w-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.refreshTitle")})]}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(dt,{variant:"ghost",size:"sm",onClick:()=>{a&&ye(a)},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":n("sidebarFilesTree.actions.collapseAllTitle"),children:s.jsx(M,{name:"collapse-vertical",className:"h-4 w-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.collapseAllTitle")})]})]}),s.jsxs("div",{className:"relative min-w-0",children:[s.jsx(M,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),s.jsx(In,{ref:f,value:y,onChange:be=>S(be.target.value),placeholder:n("sidebarFilesTree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),y.trim().length>0?s.jsx("button",{type:"button","aria-label":n("sidebarFilesTree.search.clearAria"),className:"absolute right-2 top-2 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{S(""),f.current?.focus()},children:s.jsx(M,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx(jn,{outerClassName:"h-full min-h-0",className:Me("p-2",C===a&&"bg-interactive-selection/10"),onDragEnter:lt,onDragOver:lt,onDragLeave:it,onDrop:mt,children:s.jsx("ul",{className:"flex flex-col",children:p?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(M,{name:"loader-4",className:"h-4 w-4 animate-spin"}),n("sidebarFilesTree.state.searching")]}):x.length>0?x.map(be=>{const Ue=X===be.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>Ae(be),draggable:!0,onDragStart:ut=>{bf(ut);const G=be.relativePath||Ya(a??"",be.path);!G||G==="."||(ut.dataTransfer.setData("application/x-openchamber-file-path",G),ut.dataTransfer.effectAllowed="copy")},onDragEnd:ut=>{yf(ut)&&Ae(be)},className:Me("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",Ue?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:be.path,children:[wf(be.path,be.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:be.relativePath??be.path})]})},be.path)}):Ct?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:Ct}),s.jsxs(dt,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Ne()},children:[s.jsx(M,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):Xe&&a?ht(a,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:n("sidebarFilesTree.state.loading")})})}),C?s.jsxs("div",{className:"pointer-events-none absolute left-2 right-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(M,{name:D?"loader-4":"folder-received",className:Me("size-4 flex-shrink-0",D&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:Mt,children:n(D?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Mt})})]}):null]}),s.jsx(vs,{open:!!A,onOpenChange:be=>!be&&P(null),children:s.jsxs(Ss,{children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:n("sidebarFilesTree.dialog.uploadConflicts.title")}),s.jsx(Ts,{children:n("sidebarFilesTree.dialog.uploadConflicts.description",{path:A?.directory??""})})]}),s.jsx(jn,{outerClassName:"max-h-52",className:"flex flex-col gap-1 pr-2",children:A?.files.map((be,Ue)=>s.jsx("div",{className:"truncate rounded-md bg-muted px-2 py-1 typography-meta",title:be.name,children:be.name},`${be.name}-${be.size}-${Ue}`))}),s.jsxs(Sn,{children:[s.jsx(dt,{variant:"outline",onClick:()=>P(null),disabled:D,children:n("sidebarFilesTree.dialog.cancel")}),s.jsx(dt,{onClick:()=>{if(A){if(A.runtimeKey!==as()||A.workspaceRoot!==a){P(null);return}Fe(A.directory,A.files,!0)}},disabled:D,children:n("sidebarFilesTree.dialog.uploadConflicts.replace")})]})]})}),s.jsx(vs,{open:!!R,onOpenChange:be=>!be&&Y(null),children:s.jsxs(Ss,{children:[s.jsxs(Ws,{children:[s.jsxs(Is,{children:[R==="createFile"&&n("sidebarFilesTree.dialog.createFile.title"),R==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.title"),R==="rename"&&n("sidebarFilesTree.dialog.rename.title"),R==="delete"&&n("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(Ts,{children:[R==="createFile"&&n("sidebarFilesTree.dialog.createFile.description",{path:ie?.path??n("sidebarFilesTree.dialog.rootFallback")}),R==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.description",{path:ie?.path??n("sidebarFilesTree.dialog.rootFallback")}),R==="rename"&&n("sidebarFilesTree.dialog.rename.description",{name:ie?.name??""}),R==="delete"&&n("sidebarFilesTree.dialog.delete.description",{name:ie?.name??""})]})]}),R!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(In,{value:me,onChange:be=>pe(be.target.value),placeholder:n(R==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:be=>{be.key==="Enter"&&St()},autoFocus:!0})}),s.jsxs(Sn,{children:[s.jsx(dt,{variant:"outline",onClick:()=>Y(null),disabled:re,children:n("sidebarFilesTree.dialog.cancel")}),s.jsx(dt,{variant:R==="delete"?"destructive":"default",onClick:()=>{St()},disabled:re||R!=="delete"&&!me.trim(),children:re?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):n(R==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})};function T1(t){return t.runtimeKey}const gc=60,E1=t=>{try{return new URL(t).origin}catch{return""}},Si=new Set,vf=Ar()((t,e)=>({byOrigin:{},resolve:(n,r)=>{const i=E1(n);!i||!r||e().byOrigin[i]||Si.has(i)||(Si.add(i),yr("desktop_browser_fetch_favicon",{url:r}).then(o=>{const l=typeof o?.dataUrl=="string"?o.dataUrl:"";l&&t(a=>{const u={...a.byOrigin,[i]:l},d=Object.keys(u);if(d.length<=gc)return{byOrigin:u};for(const h of d.slice(0,d.length-gc))delete u[h];return{byOrigin:u}})}).catch(()=>{}).finally(()=>{Si.delete(i)}))}})),Xa=t=>t,oa=t=>{const e=Xa(t).type;return typeof e=="string"?e:""},R1=t=>{const e=Xa(t).tool;return typeof e=="string"?e:""},M1=t=>{const e=Xa(t).text;return typeof e=="string"?e:""},O1=t=>{const e=oa(t);return e==="tool"?R1(t).trim().toLowerCase()||"tool":e||"unknown"},B1=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=O1(n);e.includes(r)||e.push(r)}return e.join(" + ")},F1=t=>t.replace(/\s+/g," ").trim(),_1=t=>{for(const n of t)if(oa(n)==="text"){const r=F1(M1(n));if(r.length===0)continue;return r}const e=t.filter(n=>oa(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},L1=(t,e,n)=>`${n(t)} / ${n(e)}`,$1=t=>{if(t==="12h")return!0;if(t==="24h")return!1},z1=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=$1(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:n===!1?"2-digit":"numeric",minute:"2-digit",...n===void 0?{}:{hour12:n}})},ia={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Co={user:0,assistant:0,tool:0,other:0},Ln=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,xc=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(h=>h.tokens!==void 0)?.tokens;if(typeof n=="number")return{...ia,total:Ln(n)};if(!n||typeof n!="object")return ia;const r=n,i=Ln(r.input),o=Ln(r.output),l=Ln(r.reasoning),a=Ln(r.cache?.read),u=Ln(r.cache?.write),d=Ln(r.total);return{input:i,output:o,reasoning:l,cacheRead:a,cacheWrite:u,total:d>0?d:i+o+l+a+u}},W1=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},qs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+qs(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+qs(n),0):0,K1=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...Co,assistant:qs(n.text)+qs(n.content)};const i=W1(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:qs(n.input)+qs(n.output)+qs(n.error)+qs(n.call?.input)+qs(n.call?.output)+qs(n.call?.error)+qs(n.raw)+Math.round(qs(n.metadata)*.25)+Math.round(qs(n.state)*.1),other:0}:e==="user"?{user:i.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:i.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:i.length}},bc=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),V1=t=>{const e=no(t.info);return e.isUser?"user":e.role==="assistant"?"assistant":e.role==="tool"?"tool":"other"},U1=(t,e)=>{if(t.length===0)return{...Co};const n=t.reduce((r,i)=>{const o=V1(i);let l={...Co};for(const a of i.parts)l=bc(l,K1(a,o));return bc(r,l)},{...Co});return n.user+=e.length,{user:Math.ceil(n.user/4),assistant:Math.ceil(n.assistant/4),tool:Math.ceil(n.tool/4),other:Math.ceil(n.other/4)}},Qn=t=>t.toLocaleString(wu()),H1=(t,e)=>!t||!Number.isFinite(t)?"-":gu(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),G1=(t,e,n)=>{const r=t.find(o=>o.id===e),i=r?.models?.find(o=>o.id===n);return{providerName:r?.name||e||"-",modelName:i?.name||n||"-",contextLimit:typeof i?.limit?.context=="number"?i.limit.context:null}},q1=()=>{const t=et.c(209),{t:e}=vt(),n=De(Y1);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0];const[i,o]=c.useState(r),[l,a]=c.useState(null),u=c.useRef(null),d=Ze(Q1),h=Ze(X1),m=Su(h??void 0),g=Pp(d??"",h??void 0),b=Yt(J1);let y;t[1]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null),o(Z1),a(null)},t[1]=y):y=t[1];let S;t[2]!==h||t[3]!==d?(S=[h,d],t[2]=h,t[3]=d,t[4]=S):S=t[4],c.useEffect(y,S);let w,f;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},f=[],t[5]=w,t[6]=f):(w=t[5],f=t[6]),c.useEffect(w,f);let x;t[7]===Symbol.for("react.memo_cache_sentinel")?(x=async(Ge,Le)=>{(await wn(Le)).ok?(a(Ge),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{a(Be=>Be===Ge?null:Be),u.current=null},2e3)):a(null)},t[7]=x):x=t[7];const v=x;let p;t[8]!==d||t[9]!==m?(p=d?m.find(Ge=>Ge.id===d)??null:null,t[8]=d,t[9]=m,t[10]=p):p=t[10];const N=p;let C,k,D,I,A,P,T;if(t[11]!==g){C=g.filter(ew),T=g.filter(tw);const Ge=Ip(g.map(sw));D=Ge?g[Ge.index]??null:null,I=Ge?.state==="compacted";let Le;t[19]!==D?(P=D?xc(D):ia,Le=Tp({input:P.input,cache:{read:P.cacheRead,write:P.cacheWrite}}),t[19]=D,t[20]=Le,t[21]=P):(Le=t[20],P=t[21]),k=Le,A=C.reduce(nw,0),t[11]=g,t[12]=C,t[13]=k,t[14]=D,t[15]=I,t[16]=A,t[17]=P,t[18]=T}else C=t[12],k=t[13],D=t[14],I=t[15],A=t[16],P=t[17],T=t[18];const _=A,L=D?.info??null,W=b,O=L?.providerID||"",$=L?.modelID||"";let j;t[22]!==$||t[23]!==W||t[24]!==O?(j=G1(W,O,$),t[22]=$,t[23]=W,t[24]=O,t[25]=j):j=t[25];const E=j,K=E.contextLimit,ee=I?null:K&&K>0?Math.min(999,P.total/K*100):0;let J;if(t[26]!==g){const Ge=[...g].reverse().find(rw)?.info?.system||"";J=U1(g,Ge),t[26]=g,t[27]=J}else J=t[27];const ne=J,ue=ne.user,X=ne.assistant,te=ne.tool,fe=Math.max(0,P.input-ue-X-te),je=ue+X+te+fe,ve=g[0]?.info?.time?.created,ye=g.length>0?g[g.length-1]?.info?.time?.created:null;let Pe;t[28]!==N?.title||t[29]!==e?(Pe=N?.title||e("contextSidebar.session.untitled"),t[28]=N?.title,t[29]=e,t[30]=Pe):Pe=t[30];const xe=N?.time?.created??ve??null,R=ye??N?.time?.created??null;let Y;t[31]!==X||t[32]!==fe||t[33]!==te||t[34]!==ue?(Y={user:ue,assistant:X,tool:te,other:fe},t[31]=X,t[32]=fe,t[33]=te,t[34]=ue,t[35]=Y):Y=t[35];let ie;t[36]!==C.length||t[37]!==je||t[38]!==k||t[39]!==K||t[40]!==E||t[41]!==g.length||t[42]!==Pe||t[43]!==xe||t[44]!==R||t[45]!==Y||t[46]!==P||t[47]!==_||t[48]!==ee||t[49]!==T.length?(ie={sessionTitle:Pe,messagesCount:g.length,userMessagesCount:T.length,assistantMessagesCount:C.length,createdAt:xe,lastActivityAt:R,providerModel:E,tokenBreakdown:P,usagePercent:ee,cacheHitRate:k,totalAssistantCost:_,contextLimit:K,breakdown:Y,breakdownTotal:je},t[36]=C.length,t[37]=je,t[38]=k,t[39]=K,t[40]=E,t[41]=g.length,t[42]=Pe,t[43]=xe,t[44]=R,t[45]=Y,t[46]=P,t[47]=_,t[48]=ee,t[49]=T.length,t[50]=ie):ie=t[50];const H=ie;if(!d){let Ge;t[51]!==e?(Ge=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=Ge):Ge=t[52];let Le;return t[53]!==Ge?(Le=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:Ge}),t[53]=Ge,t[54]=Le):Le=t[54],Le}let me;t[55]!==e?(me=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=me):me=t[56];let pe;t[57]!==me||t[58]!==H.breakdown.user?(pe={key:"user",label:me,value:H.breakdown.user,color:"var(--status-success)"},t[57]=me,t[58]=H.breakdown.user,t[59]=pe):pe=t[59];let re;t[60]!==e?(re=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=re):re=t[61];let de;t[62]!==re||t[63]!==H.breakdown.assistant?(de={key:"assistant",label:re,value:H.breakdown.assistant,color:"var(--primary-base)"},t[62]=re,t[63]=H.breakdown.assistant,t[64]=de):de=t[64];let B;t[65]!==e?(B=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=B):B=t[66];let F;t[67]!==B||t[68]!==H.breakdown.tool?(F={key:"tool",label:B,value:H.breakdown.tool,color:"var(--status-warning)"},t[67]=B,t[68]=H.breakdown.tool,t[69]=F):F=t[69];let he;t[70]!==e?(he=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=he):he=t[71];let Se;t[72]!==he||t[73]!==H.breakdown.other?(Se={key:"other",label:he,value:H.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=he,t[73]=H.breakdown.other,t[74]=Se):Se=t[74];let Re;t[75]!==pe||t[76]!==de||t[77]!==F||t[78]!==Se?(Re=[pe,de,F,Se],t[75]=pe,t[76]=de,t[77]=F,t[78]=Se,t[79]=Re):Re=t[79];const le=Re;let se;t[80]!==H.sessionTitle?(se=s.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:H.sessionTitle}),t[80]=H.sessionTitle,t[81]=se):se=t[81];let q;t[82]!==H.providerModel.modelName||t[83]!==H.providerModel.providerName?(q=s.jsxs("span",{children:[H.providerModel.providerName," / ",H.providerModel.modelName]}),t[82]=H.providerModel.modelName,t[83]=H.providerModel.providerName,t[84]=q):q=t[84];let z;t[85]!==n||t[86]!==H.createdAt?(z=H.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:H1(H.createdAt,n)})]}),t[85]=n,t[86]=H.createdAt,t[87]=z):z=t[87];let ae;t[88]!==q||t[89]!==z?(ae=s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70",children:[q,z]}),t[88]=q,t[89]=z,t[90]=ae):ae=t[90];let ce;t[91]!==se||t[92]!==ae?(ce=s.jsxs("div",{className:"mb-6",children:[se,ae]}),t[91]=se,t[92]=ae,t[93]=ce):ce=t[93];let Ne;t[94]!==e?(Ne=e("contextSidebar.section.context"),t[94]=e,t[95]=Ne):Ne=t[95];let we;t[96]!==Ne?(we=s.jsx("span",{className:"typography-micro text-muted-foreground",children:Ne}),t[96]=Ne,t[97]=we):we=t[97];let $e;t[98]!==H.tokenBreakdown.total||t[99]!==H.usagePercent?($e=H.usagePercent===null?"—":Qn(H.tokenBreakdown.total),t[98]=H.tokenBreakdown.total,t[99]=H.usagePercent,t[100]=$e):$e=t[100];let Oe;t[101]!==H.contextLimit?(Oe=H.contextLimit?` / ${Qn(H.contextLimit)}`:"",t[101]=H.contextLimit,t[102]=Oe):Oe=t[102];let ge;t[103]!==$e||t[104]!==Oe?(ge=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[$e,Oe]}),t[103]=$e,t[104]=Oe,t[105]=ge):ge=t[105];let He;t[106]!==we||t[107]!==ge?(He=s.jsxs("div",{className:"flex items-baseline justify-between",children:[we,ge]}),t[106]=we,t[107]=ge,t[108]=He):He=t[108];let V;t[109]!==H.usagePercent?(V=H.usagePercent!==null&&H.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,H.usagePercent)}%`,backgroundColor:H.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[109]=H.usagePercent,t[110]=V):V=t[110];let Ae;t[111]!==V?(Ae=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:V}),t[111]=V,t[112]=Ae):Ae=t[112];let Ie;t[113]!==e||t[114]!==H.usagePercent?(Ie=H.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:H.usagePercent.toFixed(1)}),t[113]=e,t[114]=H.usagePercent,t[115]=Ie):Ie=t[115];let Fe;t[116]!==Ie?(Fe=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:Ie}),t[116]=Ie,t[117]=Fe):Fe=t[117];let st;t[118]!==He||t[119]!==Ae||t[120]!==Fe?(st=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[He,Ae,Fe]}),t[118]=He,t[119]=Ae,t[120]=Fe,t[121]=st):st=t[121];let lt;t[122]!==e?(lt=e("contextSidebar.stats.messages"),t[122]=e,t[123]=lt):lt=t[123];let it;t[124]!==H.messagesCount?(it=Qn(H.messagesCount),t[124]=H.messagesCount,t[125]=it):it=t[125];let mt;t[126]!==lt||t[127]!==it?(mt={label:lt,value:it},t[126]=lt,t[127]=it,t[128]=mt):mt=t[128];let St;t[129]!==e?(St=e("contextSidebar.stats.user"),t[129]=e,t[130]=St):St=t[130];let ht;t[131]!==H.userMessagesCount?(ht=Qn(H.userMessagesCount),t[131]=H.userMessagesCount,t[132]=ht):ht=t[132];let Xe;t[133]!==St||t[134]!==ht?(Xe={label:St,value:ht},t[133]=St,t[134]=ht,t[135]=Xe):Xe=t[135];let Ct;t[136]!==e?(Ct=e("contextSidebar.stats.assistant"),t[136]=e,t[137]=Ct):Ct=t[137];let Mt;t[138]!==H.assistantMessagesCount?(Mt=Qn(H.assistantMessagesCount),t[138]=H.assistantMessagesCount,t[139]=Mt):Mt=t[139];let be;t[140]!==Ct||t[141]!==Mt?(be={label:Ct,value:Mt},t[140]=Ct,t[141]=Mt,t[142]=be):be=t[142];let Ue;t[143]!==e?(Ue=e("contextSidebar.stats.cost"),t[143]=e,t[144]=Ue):Ue=t[144];let ut;t[145]!==H.totalAssistantCost?(ut=_x(H.totalAssistantCost),t[145]=H.totalAssistantCost,t[146]=ut):ut=t[146];let G;t[147]!==Ue||t[148]!==ut?(G={label:Ue,value:ut},t[147]=Ue,t[148]=ut,t[149]=G):G=t[149];let U;t[150]!==mt||t[151]!==Xe||t[152]!==be||t[153]!==G?(U=[mt,Xe,be,G],t[150]=mt,t[151]=Xe,t[152]=be,t[153]=G,t[154]=U):U=t[154];const Z=U;let ke;t[155]!==Z?(ke=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:Z.map(ow)}),t[155]=Z,t[156]=ke):ke=t[156];let Te;t[157]!==e?(Te=e("contextSidebar.section.lastAssistantMessage"),t[157]=e,t[158]=Te):Te=t[158];let We;t[159]!==Te?(We=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:Te}),t[159]=Te,t[160]=We):We=t[160];let Je;t[161]!==e||t[162]!==H.cacheHitRate.hasInput||t[163]!==H.cacheHitRate.percent||t[164]!==H.tokenBreakdown.cacheRead||t[165]!==H.tokenBreakdown.cacheWrite||t[166]!==H.tokenBreakdown.input||t[167]!==H.tokenBreakdown.output||t[168]!==H.tokenBreakdown.reasoning?(Je=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:H.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:H.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:H.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:H.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:H.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:H.cacheHitRate.hasInput?H.cacheHitRate.percent:null,format:"percent"}].map(iw)}),t[161]=e,t[162]=H.cacheHitRate.hasInput,t[163]=H.cacheHitRate.percent,t[164]=H.tokenBreakdown.cacheRead,t[165]=H.tokenBreakdown.cacheWrite,t[166]=H.tokenBreakdown.input,t[167]=H.tokenBreakdown.output,t[168]=H.tokenBreakdown.reasoning,t[169]=Je):Je=t[169];let nt;t[170]!==We||t[171]!==Je?(nt=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[We,Je]}),t[170]=We,t[171]=Je,t[172]=nt):nt=t[172];let rt;t[173]!==le||t[174]!==H.breakdownTotal?(rt=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:le.map(Ge=>Ge.value<=0||H.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${Ge.value/H.breakdownTotal*100}%`,backgroundColor:Ge.color}},Ge.key))}),t[173]=le,t[174]=H.breakdownTotal,t[175]=rt):rt=t[175];let Ye;t[176]!==le||t[177]!==H.breakdownTotal?(Ye=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:le.map(Ge=>{const Le=H.breakdownTotal>0?Ge.value/H.breakdownTotal*100:0;return s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:Ge.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[Ge.label," ",s.jsxs("span",{className:"tabular-nums",children:[Le.toFixed(0),"%"]})]})]},Ge.key)})}),t[176]=le,t[177]=H.breakdownTotal,t[178]=Ye):Ye=t[178];let Nt;t[179]!==rt||t[180]!==Ye?(Nt=s.jsxs("div",{className:"mb-6",children:[rt,Ye]}),t[179]=rt,t[180]=Ye,t[181]=Nt):Nt=t[181];let Ke;t[182]!==e?(Ke=e("contextSidebar.section.rawMessages"),t[182]=e,t[183]=Ke):Ke=t[183];let Tt;t[184]!==Ke?(Tt=s.jsx("div",{className:"typography-micro text-muted-foreground",children:Ke}),t[184]=Ke,t[185]=Tt):Tt=t[185];let Ce;if(t[186]!==l||t[187]!==i||t[188]!==g||t[189]!==e||t[190]!==n){let Ge;t[192]!==l||t[193]!==i||t[194]!==e||t[195]!==n?(Ge=Le=>{const Be=no(Le.info).role,ze=Be==="assistant",qe=Be==="user",tt=i[Le.info.id]===!0,yt=l===Le.info.id,Ot=Le.info.time?.created??null,Ht=B1(Le.parts),_t=ze?xc({info:Le.info,parts:Le.parts}):null,zt=qe?_1(Le.parts):"",Wt=z1(Ot,n),Jt=Ht||"—",es=_t?L1(_t.input,_t.output,Qn):"",Qt=Be||"unknown",qt=Ht?`${Qt}: ${Ht}`:Qt,Et=tt?JSON.stringify({info:Le.info,parts:Le.parts},null,2):"";return s.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[s.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]","aria-expanded":tt,onClick:()=>{o(wt=>({...wt,[Le.info.id]:wt[Le.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:ze?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[qe?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",zt]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:ze?Jt:qt}),ze&&s.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:es})]}),s.jsx("span",{className:"text-right text-muted-foreground",children:Wt})]})}),tt&&s.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:s.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[s.jsx("div",{className:"absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:s.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:wt=>{wt.stopPropagation(),v(Le.info.id,Et)},"aria-label":e(yt?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(yt?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:yt?s.jsx(M,{name:"check",className:"size-3.5"}):s.jsx(M,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Ep,{language:"json",code:Et,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},Le.info.id)},t[192]=l,t[193]=i,t[194]=e,t[195]=n,t[196]=Ge):Ge=t[196],Ce=[...g].reverse().map(Ge),t[186]=l,t[187]=i,t[188]=g,t[189]=e,t[190]=n,t[191]=Ce}else Ce=t[191];let ft;t[197]!==Ce?(ft=s.jsx("div",{className:"mt-2.5 space-y-1",children:Ce}),t[197]=Ce,t[198]=ft):ft=t[198];let bt;t[199]!==Tt||t[200]!==ft?(bt=s.jsxs("div",{children:[Tt,ft]}),t[199]=Tt,t[200]=ft,t[201]=bt):bt=t[201];let jt;return t[202]!==ce||t[203]!==st||t[204]!==ke||t[205]!==nt||t[206]!==Nt||t[207]!==bt?(jt=s.jsx(jn,{outerClassName:"h-full",className:"bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[ce,st,ke,nt,Nt,bt]})}),t[202]=ce,t[203]=st,t[204]=ke,t[205]=nt,t[206]=Nt,t[207]=bt,t[208]=jt):jt=t[208],jt};function Y1(t){return t.timeFormatPreference}function Q1(t){return t.currentSessionId}function X1(t){return t.currentSessionDirectory}function J1(t){return t.providers}function Z1(t){return Object.keys(t).length>0?{}:t}function ew(t){return no(t.info).role==="assistant"}function tw(t){return no(t.info).isUser}function sw(t){return t.info}function nw(t,e){const n=Ln(e.info.cost);return t+n}function rw(t){return no(t.info).isUser&&typeof t.info.system=="string"}function ow(t){return s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function iw(t){return s.jsxs("div",{children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value!==null&&t.value!==void 0?t.format==="percent"?`${t.value.toFixed(1)}%`:Qn(t.value):"—"})]},t.label)}const Sf=new Set(["localhost","127.0.0.1","0.0.0.0","::1","[::1]"]),aw=t=>{const e=t.split("/")[0]?.split("?")[0]??"",n=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0]??"";return Sf.has(n.toLowerCase())},an="about:blank",vr=t=>{const e=t.trim();if(!e)return an;const n=e.includes("://")?e:`${aw(e)?"http":"https"}://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?an:r.toString()}catch{return an}},Dr=t=>{try{return Sf.has(new URL(t).hostname.toLowerCase())}catch{return!1}},Ja=t=>{if(!t||t===an)return"";try{return new URL(t).host||t}catch{return t}},lw=new Set([-2,-7,-101,-102,-104,-109,-118,-324]),cw=(t,e)=>lw.has(t)&&Dr(e),dw=t=>{if(!t||typeof t!="object")return!1;const e=t;return typeof e.port=="number"&&Number.isFinite(e.port)&&typeof e.url=="string"&&e.url.length>0&&typeof e.command=="string"},uw=async t=>{try{const e=await ms("/api/dev-servers",{signal:t});if(!e.ok)return{kind:"unavailable"};const n=await e.json();if(!n||typeof n!="object")return{kind:"unavailable"};const r=n.servers;return Array.isArray(r)?{kind:"ready",servers:r.filter(dw)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},fw=async t=>{try{const e=await ms("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const n=await e.json();if(!n||typeof n!="object")return null;const r=n.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},mw=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:null}catch{return null}},hw=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const i=mw(r);i!==null&&!n.has(i)&&n.set(i,r)}return e?e.map(r=>{const i=n.get(r.port);return{url:i??r.url,port:r.port,announced:i!==void 0}}).sort((r,i)=>r.announced!==i.announced?r.announced?-1:1:r.port-i.port):[...n.entries()].map(([r,i])=>({url:i,port:r,announced:!0})).sort((r,i)=>r.port-i.port)},aa="__openchamberBrowserAnnotationActive",pw=`(() => {
12
- try {
13
- var host = document.querySelector('[data-openchamber-annotation]');
14
- if (host && host.parentNode) host.parentNode.removeChild(host);
15
- } catch (error) { /* page navigated away */ }
16
- try {
17
- var cursor = document.getElementById('openchamber-annotation-cursor');
18
- if (cursor && cursor.parentNode) cursor.parentNode.removeChild(cursor);
19
- } catch (error) { /* page navigated away */ }
20
- try { delete window['${aa}']; } catch (error) { /* non-configurable */ }
21
- })();`,gw=(t,e)=>{const n=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
22
- var CONFIG = ${n};
23
- var THEME = CONFIG.theme;
24
- var LABELS = CONFIG.labels;
25
- var OVERLAY_ATTR = 'data-openchamber-annotation';
26
- var Z_OVERLAY = 2147483646;
27
- var MAX_TEXT = 400;
28
- var MIN_RECT = 3;
29
- var EDITOR_GAP = 10;
30
-
31
- try {
32
- var stale = document.querySelector('[' + OVERLAY_ATTR + ']');
33
- if (stale && stale.parentNode) stale.parentNode.removeChild(stale);
34
- } catch (error) { /* nothing to clean */ }
35
-
36
- window['${aa}'] = true;
37
-
38
- var counter = 0;
39
- var nextId = function (prefix) { counter += 1; return prefix + '-' + counter; };
40
-
41
- var selected = null;
42
- var regions = [];
43
- var strokes = [];
44
- var tool = 'select';
45
- var settled = false;
46
-
47
- // ---------------------------------------------------------------- geometry
48
-
49
- var rectFrom = function (domRect) {
50
- return { x: domRect.left, y: domRect.top, width: domRect.width, height: domRect.height };
51
- };
52
- var normalizeRect = function (ax, ay, bx, by) {
53
- return { x: Math.min(ax, bx), y: Math.min(ay, by), width: Math.abs(bx - ax), height: Math.abs(by - ay) };
54
- };
55
- var usableRect = function (rect) { return rect.width >= MIN_RECT && rect.height >= MIN_RECT; };
56
-
57
- // ------------------------------------------------------------- description
58
-
59
- var isOverlayNode = function (element) {
60
- var node = element;
61
- while (node) {
62
- if (node.nodeType === 1 && node.hasAttribute && node.hasAttribute(OVERLAY_ATTR)) return true;
63
- node = node.parentNode || (node.host || null);
64
- }
65
- return false;
66
- };
67
-
68
- var elementFromPoint = function (x, y) {
69
- var found = document.elementFromPoint(x, y);
70
- if (!found || isOverlayNode(found)) return null;
71
- return found;
72
- };
73
-
74
- var selectorPart = function (element) {
75
- var part = element.tagName.toLowerCase();
76
- if (element.id) return part + '#' + element.id;
77
- var className = typeof element.className === 'string' ? element.className.trim() : '';
78
- if (className) {
79
- var first = className.split(/\s+/).filter(Boolean).slice(0, 2).join('.');
80
- if (first) part += '.' + first;
81
- }
82
- return part;
83
- };
84
-
85
- var buildSelector = function (element) {
86
- if (element.id) return '#' + element.id;
87
- var parts = [];
88
- var node = element;
89
- var depth = 0;
90
- while (node && node.nodeType === 1 && depth < 5) {
91
- var part = selectorPart(node);
92
- var parent = node.parentElement;
93
- if (parent) {
94
- var siblings = Array.prototype.filter.call(parent.children, function (child) {
95
- return child.tagName === node.tagName;
96
- });
97
- if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
98
- }
99
- parts.unshift(part);
100
- if (node.id) break;
101
- node = parent;
102
- depth += 1;
103
- }
104
- return parts.join(' > ');
105
- };
106
-
107
- var INTERESTING_ATTRS = ['id', 'class', 'name', 'type', 'href', 'src', 'alt', 'title', 'role', 'placeholder', 'aria-label', 'data-testid'];
108
- var STYLE_PROPS = [
109
- 'display', 'position', 'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontFamily',
110
- 'lineHeight', 'padding', 'margin', 'border', 'borderRadius', 'width', 'height', 'opacity',
111
- 'zIndex', 'flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign'
112
- ];
113
-
114
- var describe = function (element) {
115
- var computed = window.getComputedStyle(element);
116
- var attributes = {};
117
- for (var i = 0; i < INTERESTING_ATTRS.length; i += 1) {
118
- var name = INTERESTING_ATTRS[i];
119
- var value = element.getAttribute(name);
120
- if (value) attributes[name] = String(value).slice(0, 200);
121
- }
122
- var computedStyle = {};
123
- for (var j = 0; j < STYLE_PROPS.length; j += 1) {
124
- var prop = STYLE_PROPS[j];
125
- computedStyle[prop] = String(computed[prop] == null ? '' : computed[prop]);
126
- }
127
- var ancestry = [];
128
- var node = element.parentElement;
129
- var depth = 0;
130
- while (node && node.nodeType === 1 && depth < 4) {
131
- var entry = { tag: node.tagName.toLowerCase(), selectorPart: selectorPart(node) };
132
- if (node.id) entry.id = node.id;
133
- var cls = typeof node.className === 'string' ? node.className.trim() : '';
134
- if (cls) entry.className = cls.slice(0, 200);
135
- ancestry.unshift(entry);
136
- node = node.parentElement;
137
- depth += 1;
138
- }
139
- var box = element.getBoundingClientRect();
140
- var text = (element.textContent == null ? '' : String(element.textContent)).replace(/\s+/g, ' ').trim();
141
- return {
142
- tag: element.tagName.toLowerCase(),
143
- text: text.slice(0, MAX_TEXT),
144
- selector: buildSelector(element),
145
- path: ancestry.map(function (e) { return e.selectorPart; }).concat([selectorPart(element)]).join(' > '),
146
- bounds: rectFrom(box),
147
- center: { x: box.left + box.width / 2, y: box.top + box.height / 2 },
148
- attributes: attributes,
149
- computedStyle: computedStyle,
150
- ancestry: ancestry
151
- };
152
- };
153
-
154
- // ------------------------------------------------------------------ chrome
155
-
156
- var host = document.createElement('div');
157
- host.setAttribute(OVERLAY_ATTR, '');
158
- host.style.cssText = 'position:fixed;inset:0;z-index:' + Z_OVERLAY + ';pointer-events:none';
159
- var shadow = host.attachShadow({ mode: 'closed' });
160
-
161
- var style = document.createElement('style');
162
- style.textContent = [
163
- ':host{all:initial}',
164
- '*{box-sizing:border-box;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}',
165
- '.layer{position:fixed;inset:0;pointer-events:none}',
166
- '.box{position:fixed;left:0;top:0;display:none;pointer-events:none;border:1.5px solid ' + THEME.primary + ';background:' + THEME.primarySoft + ';border-radius:2px}',
167
- '.label{position:fixed;left:0;top:0;display:none;pointer-events:none;padding:1px 6px;border-radius:4px;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';font-size:11px;line-height:17px;white-space:nowrap;font-weight:600}',
168
- '.tools{position:fixed;top:14px;left:50%;transform:translateX(-50%);display:flex;gap:2px;padding:4px;border-radius:999px;border:1px solid ' + THEME.border + ';background:' + THEME.glassSurface + ';-webkit-backdrop-filter:' + THEME.glassFilter + ';backdrop-filter:' + THEME.glassFilter + ';box-shadow:0 6px 20px rgba(0,0,0,.24);pointer-events:auto}',
169
- '.tools button{appearance:none;border:none;background:transparent;color:' + THEME.mutedText + ';border-radius:999px;padding:5px 14px;font-size:12px;line-height:18px;font-weight:500;cursor:pointer;white-space:nowrap}',
170
- '.tools button:hover{background:' + THEME.primaryFaint + '}',
171
- '.tools button[aria-pressed="true"]{background:' + THEME.primarySoft + ';color:' + THEME.primary + ';font-weight:600}',
172
- '.editor{position:fixed;left:0;top:0;display:none;align-items:center;gap:8px;width:min(420px,calc(100vw - 24px));padding:6px;padding-left:16px;border-radius:22px;border:1px solid ' + THEME.border + ';background:' + THEME.glassSurface + ';-webkit-backdrop-filter:' + THEME.glassFilter + ';backdrop-filter:' + THEME.glassFilter + ';box-shadow:0 8px 28px rgba(0,0,0,.3);pointer-events:auto}',
173
- '.editor textarea{flex:1;min-width:0;resize:none;border:none;background:transparent;color:' + THEME.text + ';font-size:13px;line-height:20px;outline:none;padding:6px 0;min-height:32px;max-height:104px;display:block}',
174
- '.editor textarea::placeholder{color:' + THEME.mutedText + '}',
175
- '.editor button{appearance:none;border:none;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';border-radius:999px;width:32px;height:32px;padding:0;display:flex;align-items:center;justify-content:center;flex-shrink:0;cursor:pointer}',
176
- '.editor button svg{width:16px;height:16px;display:block}',
177
- '.editor button[disabled]{opacity:.5;cursor:default}'
178
- ].join('');
179
- shadow.appendChild(style);
180
-
181
- var cursorStyle = document.createElement('style');
182
- cursorStyle.id = 'openchamber-annotation-cursor';
183
- document.head.appendChild(cursorStyle);
184
- var setCursor = function (value) {
185
- cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
186
- };
187
-
188
- var svgNS = 'http://www.w3.org/2000/svg';
189
- var svg = document.createElementNS(svgNS, 'svg');
190
- svg.setAttribute('class', 'layer');
191
- svg.style.overflow = 'visible';
192
- shadow.appendChild(svg);
193
-
194
- var hoverBox = document.createElement('div');
195
- hoverBox.className = 'box';
196
- var hoverLabel = document.createElement('div');
197
- hoverLabel.className = 'label';
198
- var marqueeBox = document.createElement('div');
199
- marqueeBox.className = 'box';
200
- shadow.append(hoverBox, hoverLabel, marqueeBox);
201
-
202
- var positionBox = function (node, rect) {
203
- node.style.display = 'block';
204
- node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
205
- node.style.width = rect.width + 'px';
206
- node.style.height = rect.height + 'px';
207
- };
208
-
209
- var tools = document.createElement('div');
210
- tools.className = 'tools';
211
- shadow.appendChild(tools);
212
-
213
- var toolButtons = {};
214
- [['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
215
- var button = document.createElement('button');
216
- button.type = 'button';
217
- button.textContent = entry[1];
218
- button.addEventListener('click', function () { setTool(entry[0]); });
219
- toolButtons[entry[0]] = button;
220
- tools.appendChild(button);
221
- });
222
-
223
- var editor = document.createElement('div');
224
- editor.className = 'editor';
225
- shadow.appendChild(editor);
226
-
227
- var comment = document.createElement('textarea');
228
- comment.rows = 1;
229
- comment.placeholder = LABELS.commentPlaceholder;
230
- var submit = document.createElement('button');
231
- submit.type = 'button';
232
- // Icon-only attach button (Remix attachment-2), matching the chat comment
233
- // input; the localized label stays available to assistive tech.
234
- submit.setAttribute('aria-label', LABELS.submit);
235
- submit.title = LABELS.submit;
236
- submit.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M14.8287 7.75737L9.1718 13.4142C8.78127 13.8047 8.78127 14.4379 9.1718 14.8284C9.56232 15.219 10.1955 15.219 10.586 14.8284L16.2429 9.17158C17.4144 8.00001 17.4144 6.10052 16.2429 4.92894C15.0713 3.75737 13.1718 3.75737 12.0002 4.92894L6.34337 10.5858C4.39075 12.5384 4.39075 15.7042 6.34337 17.6569C8.29599 19.6095 11.4618 19.6095 13.4144 17.6569L19.0713 12L20.4855 13.4142L14.8287 19.0711C12.095 21.8047 7.66283 21.8047 4.92916 19.0711C2.19549 16.3374 2.19549 11.9053 4.92916 9.17158L10.586 3.51473C12.5386 1.56211 15.7045 1.56211 17.6571 3.51473C19.6097 5.46735 19.6097 8.63317 17.6571 10.5858L12.0002 16.2427C10.8287 17.4142 8.92916 17.4142 7.75759 16.2427C6.58601 15.0711 6.58601 13.1716 7.75759 12L13.4144 6.34316L14.8287 7.75737Z" fill="currentColor"/></svg>';
237
- editor.append(comment, submit);
238
-
239
- /**
240
- * Grows the box with its content.
241
- *
242
- * A hidden element reports scrollHeight 0, so measuring one collapses the
243
- * field to nothing — which is what left a sliver of a click target and an
244
- * invisible caret. Measuring only while visible, and never below the CSS
245
- * min-height, keeps it usable.
246
- */
247
- var resizeComment = function () {
248
- if (editor.style.display === 'none') return;
249
- comment.style.height = 'auto';
250
- comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
251
- };
252
- comment.addEventListener('input', resizeComment);
253
-
254
- // -------------------------------------------------------------- selection
255
-
256
- var lastTargetRect = null;
257
-
258
- /** Places the comment box under whatever was just marked, kept on screen. */
259
- var positionEditor = function () {
260
- if (!lastTargetRect) {
261
- editor.style.display = 'none';
262
- return;
263
- }
264
- var wasHidden = editor.style.display === 'none';
265
- editor.style.display = 'flex';
266
- // Measured now that it is laid out, not while it was still hidden.
267
- if (wasHidden) resizeComment();
268
- var box = editor.getBoundingClientRect();
269
- var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
270
- var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
271
- // Above the target when there is no room below, so the box is never left
272
- // half off the bottom of the page.
273
- if (top + box.height > window.innerHeight - 8) {
274
- top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
275
- }
276
- left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
277
- editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
278
- };
279
-
280
- /** Focus after layout: focusing a zero-height field puts the caret nowhere. */
281
- var focusComment = function () {
282
- requestAnimationFrame(function () {
283
- try {
284
- comment.focus({ preventScroll: true });
285
- comment.setSelectionRange(comment.value.length, comment.value.length);
286
- } catch (error) { /* field went away */ }
287
- });
288
- };
289
-
290
- var hasTargets = function () {
291
- return Boolean(selected) || regions.length > 0 || strokes.length > 0;
292
- };
293
-
294
- var syncChrome = function () {
295
- submit.disabled = !hasTargets();
296
- if (!hasTargets()) {
297
- lastTargetRect = null;
298
- editor.style.display = 'none';
299
- return;
300
- }
301
- positionEditor();
302
- };
303
-
304
- var syncSelectionVisuals = function () {
305
- if (!selected) return;
306
- var rect = rectFrom(selected.element.getBoundingClientRect());
307
- if (!usableRect(rect)) {
308
- selected.outline.style.display = 'none';
309
- selected.badge.style.display = 'none';
310
- return;
311
- }
312
- positionBox(selected.outline, rect);
313
- selected.badge.style.display = 'block';
314
- selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
315
- lastTargetRect = rect;
316
- };
317
-
318
- var dropSelection = function () {
319
- if (!selected) return;
320
- selected.outline.remove();
321
- selected.badge.remove();
322
- selected = null;
323
- };
324
-
325
- var selectElement = function (element) {
326
- var wasSelected = selected && selected.element === element;
327
- dropSelection();
328
- if (wasSelected) {
329
- // Clicking the chosen element again clears it, so a misclick costs one
330
- // click rather than starting over.
331
- lastTargetRect = null;
332
- syncChrome();
333
- return;
334
- }
335
- var outline = document.createElement('div');
336
- outline.className = 'box';
337
- var badge = document.createElement('div');
338
- badge.className = 'label';
339
- badge.textContent = selectorPart(element);
340
- shadow.append(outline, badge);
341
- selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
342
- syncSelectionVisuals();
343
- syncChrome();
344
- focusComment();
345
- };
346
-
347
- var setTool = function (next) {
348
- tool = next;
349
- hoverBox.style.display = 'none';
350
- hoverLabel.style.display = 'none';
351
- marqueeBox.style.display = 'none';
352
- setCursor(next === 'select' ? '' : 'crosshair');
353
- for (var key in toolButtons) {
354
- if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
355
- toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
356
- }
357
- }
358
- };
359
-
360
- // ------------------------------------------------------------- interaction
361
-
362
- var drag = null;
363
-
364
- var onPointerMove = function (event) {
365
- if (drag) {
366
- if (drag.kind === 'marquee') {
367
- drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
368
- positionBox(marqueeBox, drag.rect);
369
- } else if (drag.kind === 'draw') {
370
- drag.points.push({ x: event.clientX, y: event.clientY });
371
- drag.path.setAttribute('d', drag.points.map(function (point, index) {
372
- return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
373
- }).join(' '));
374
- }
375
- return;
376
- }
377
-
378
- if (tool !== 'select') return;
379
- var element = elementFromPoint(event.clientX, event.clientY);
380
- if (!element) {
381
- hoverBox.style.display = 'none';
382
- hoverLabel.style.display = 'none';
383
- return;
384
- }
385
- var rect = rectFrom(element.getBoundingClientRect());
386
- positionBox(hoverBox, rect);
387
- hoverLabel.textContent = selectorPart(element);
388
- hoverLabel.style.display = 'block';
389
- hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
390
- };
391
-
392
- var onPointerDown = function (event) {
393
- if (event.button !== 0) return;
394
- if (isOverlayNode(event.target)) return;
395
- event.preventDefault();
396
- event.stopPropagation();
397
-
398
- if (tool === 'select') {
399
- var element = elementFromPoint(event.clientX, event.clientY);
400
- if (element) selectElement(element);
401
- return;
402
- }
403
-
404
- if (tool === 'marquee') {
405
- drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
406
- return;
407
- }
408
-
409
- var path = document.createElementNS(svgNS, 'path');
410
- path.setAttribute('fill', 'none');
411
- path.setAttribute('stroke', THEME.primary);
412
- path.setAttribute('stroke-width', '2.5');
413
- path.setAttribute('stroke-linecap', 'round');
414
- path.setAttribute('stroke-linejoin', 'round');
415
- svg.appendChild(path);
416
- drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
417
- };
418
-
419
- var onPointerUp = function () {
420
- if (!drag) return;
421
- var finished = drag;
422
- drag = null;
423
-
424
- if (finished.kind === 'marquee') {
425
- marqueeBox.style.display = 'none';
426
- var rect = finished.rect;
427
- if (!rect || !usableRect(rect)) return;
428
- // A region marks an area, not the elements inside it: expanding it into a
429
- // selection made the result depend on the page's markup rather than on
430
- // what was drawn.
431
- regions.push({ id: nextId('region'), rect: rect });
432
- var outline = document.createElementNS(svgNS, 'rect');
433
- outline.setAttribute('x', String(rect.x));
434
- outline.setAttribute('y', String(rect.y));
435
- outline.setAttribute('width', String(rect.width));
436
- outline.setAttribute('height', String(rect.height));
437
- outline.style.fill = THEME.primarySoft;
438
- outline.setAttribute('stroke', THEME.primary);
439
- outline.setAttribute('stroke-width', '1.5');
440
- outline.setAttribute('rx', '2');
441
- svg.appendChild(outline);
442
- lastTargetRect = rect;
443
- syncChrome();
444
- focusComment();
445
- return;
446
- }
447
-
448
- var points = finished.points;
449
- if (points.length < 2) {
450
- if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
451
- return;
452
- }
453
- var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
454
- for (var p = 1; p < points.length; p += 1) {
455
- minX = Math.min(minX, points[p].x);
456
- minY = Math.min(minY, points[p].y);
457
- maxX = Math.max(maxX, points[p].x);
458
- maxY = Math.max(maxY, points[p].y);
459
- }
460
- var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
461
- strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
462
- lastTargetRect = bounds;
463
- syncChrome();
464
- focusComment();
465
- };
466
-
467
- /**
468
- * Swallows the page's own mouse handling while annotating.
469
- *
470
- * Blocking pointerdown is not enough: a click still follows it, so marking a
471
- * button pressed that button and marking a link navigated away from the page
472
- * being annotated. These are the events that reach page code, so these are
473
- * the ones that have to stop.
474
- */
475
- var blockPageInteraction = function (event) {
476
- if (isOverlayNode(event.target)) return;
477
- event.preventDefault();
478
- event.stopPropagation();
479
- };
480
- var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
481
-
482
- var onScrollOrResize = function () {
483
- syncSelectionVisuals();
484
- positionEditor();
485
- };
486
-
487
- var onKeyDown = function (event) {
488
- if (event.isComposing || event.keyCode === 229) return;
489
- if (event.key === 'Escape') {
490
- event.preventDefault();
491
- event.stopImmediatePropagation();
492
- finish(null);
493
- }
494
- };
495
-
496
- var onCommentKeyDown = function (event) {
497
- // Do not let the annotated page treat typed letters as its own shortcuts.
498
- event.stopPropagation();
499
- // WebKit can report the composition-confirming Enter as keyCode 229.
500
- if (event.isComposing || event.keyCode === 229) return;
501
- if (event.key === 'Enter' && !event.shiftKey) {
502
- event.preventDefault();
503
- attach();
504
- }
505
- };
506
-
507
- document.addEventListener('pointermove', onPointerMove, true);
508
- document.addEventListener('pointerdown', onPointerDown, true);
509
- document.addEventListener('pointerup', onPointerUp, true);
510
- BLOCKED_EVENTS.forEach(function (name) {
511
- window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
512
- });
513
- window.addEventListener('scroll', onScrollOrResize, true);
514
- window.addEventListener('resize', onScrollOrResize, true);
515
- window.addEventListener('keydown', onKeyDown, true);
516
- comment.addEventListener('keydown', onCommentKeyDown);
517
-
518
- // ------------------------------------------------------------------ finish
519
-
520
- var teardown = function () {
521
- document.removeEventListener('pointermove', onPointerMove, true);
522
- document.removeEventListener('pointerdown', onPointerDown, true);
523
- document.removeEventListener('pointerup', onPointerUp, true);
524
- BLOCKED_EVENTS.forEach(function (name) {
525
- window.removeEventListener(name, blockPageInteraction, true);
526
- });
527
- window.removeEventListener('scroll', onScrollOrResize, true);
528
- window.removeEventListener('resize', onScrollOrResize, true);
529
- window.removeEventListener('keydown', onKeyDown, true);
530
- comment.removeEventListener('keydown', onCommentKeyDown);
531
- setCursor('');
532
- if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
533
- if (host.parentNode) host.parentNode.removeChild(host);
534
- try { delete window['${aa}']; } catch (error) { /* non-configurable */ }
535
- };
536
-
537
- var finish = function (payload) {
538
- if (settled) return;
539
- settled = true;
540
- teardown();
541
- // Removing the chrome is not enough: the host screenshots this page right
542
- // after we resolve, and the compositor can still hold a frame containing
543
- // our outlines. Yield two frames so the page has actually repainted.
544
- requestAnimationFrame(function () {
545
- requestAnimationFrame(function () { resolve(payload); });
546
- });
547
- };
548
-
549
- var attach = function () {
550
- if (!hasTargets()) return;
551
- finish({
552
- id: 'annotation-' + Date.now(),
553
- pageUrl: String(location.href),
554
- pageTitle: String(document.title || ''),
555
- viewport: { width: window.innerWidth, height: window.innerHeight },
556
- devicePixelRatio: window.devicePixelRatio || 1,
557
- comment: comment.value,
558
- // Zero or one element, never more. Kept as a list so elements, regions
559
- // and strokes stay one uniform shape for everything downstream.
560
- elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
561
- regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
562
- strokes: strokes.map(function (entry) {
563
- return { id: entry.id, points: entry.points, bounds: entry.bounds };
564
- })
565
- });
566
- };
567
-
568
- submit.addEventListener('click', attach);
569
-
570
- (document.body || document.documentElement).appendChild(host);
571
- setTool('select');
572
- syncChrome();
573
- });`},xw={kind:"idle"},kn=t=>typeof t=="object"&&t!==null,Pn=t=>typeof t=="number"&&Number.isFinite(t),yc=t=>kn(t)&&Object.values(t).every(e=>typeof e=="string"),Za=t=>kn(t)&&Pn(t.x)&&Pn(t.y)&&Pn(t.width)&&Pn(t.height),jf=t=>kn(t)&&Pn(t.x)&&Pn(t.y),bw=t=>kn(t)&&typeof t.tag=="string"&&typeof t.selectorPart=="string"&&(t.id===void 0||typeof t.id=="string")&&(t.className===void 0||typeof t.className=="string"),yw=t=>kn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&Za(t.bounds)&&jf(t.center)&&yc(t.attributes)&&yc(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(bw),ww=t=>kn(t)&&typeof t.id=="string"&&yw(t.element),vw=t=>kn(t)&&typeof t.id=="string"&&Za(t.rect),Sw=t=>kn(t)&&typeof t.id=="string"&&Za(t.bounds)&&Array.isArray(t.points)&&t.points.every(jf),jw=t=>kn(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&kn(t.viewport)&&Pn(t.viewport.width)&&Pn(t.viewport.height)&&Pn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(ww)&&Array.isArray(t.regions)&&t.regions.every(vw)&&Array.isArray(t.strokes)&&t.strokes.every(Sw),kw=1600,Cw=t=>new Promise((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>n(new Error("Failed to decode browser page capture")),r.src=t}),Nw=async({base64:t,mime:e,captureWidth:n,captureHeight:r,cssWidth:i,cssHeight:o,payload:l,accentColor:a,accentFill:u})=>{if(!t)return null;try{const d=await Cw(`data:${e};base64,${t}`),h=Math.max(1,d.naturalWidth||n),m=Math.max(1,d.naturalHeight||r),g=h/Math.max(1,i||h),b=m/Math.max(1,o||m),y=Math.min(1,kw/h),S=document.createElement("canvas");S.width=Math.max(1,Math.floor(h*y)),S.height=Math.max(1,Math.floor(m*y));const w=S.getContext("2d");if(!w)return null;w.scale(y,y),w.drawImage(d,0,0,h,m);const f=N=>({x:N.x*g,y:N.y*b,width:N.width*g,height:N.height*b}),x=Math.max(2,2.5*g/Math.max(y,.2));w.strokeStyle=a,w.fillStyle=u;const v=N=>{const C=f(N);w.lineWidth=x,w.fillRect(C.x,C.y,C.width,C.height),w.strokeRect(C.x,C.y,C.width,C.height)};for(const N of l.elements)v(N.element.bounds);for(const N of l.regions)v(N.rect);for(const N of l.strokes)N.points.length<2||(w.beginPath(),N.points.forEach((C,k)=>{const D=C.x*g,I=C.y*b;k===0?w.moveTo(D,I):w.lineTo(D,I)}),w.lineCap="round",w.lineJoin="round",w.lineWidth=x*1.4,w.stroke());const p=await new Promise(N=>S.toBlob(N,"image/jpeg",.85));return p?new File([p],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},Aw="({ width: window.innerWidth, height: window.innerHeight })",Dw=async t=>{try{const e=await t.executeJavaScript(Aw,!0);if(!e||typeof e!="object")return null;const n=e;return typeof n.width!="number"||typeof n.height!="number"||!Number.isFinite(n.width)||!Number.isFinite(n.height)?null:{width:n.width,height:n.height}}catch{return null}},No=async t=>{try{await t.executeJavaScript(pw,!1)}catch{}},Pw=async({host:t,theme:e,labels:n})=>{const r=gw(e,n),i=await t.executeJavaScript(r,!0);if(i==null)return null;if(!jw(i))return await No(t),null;const o=i;try{const l=await Dw(t)??o.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:o,screenshot:null};const u=await Nw({base64:a.base64,mime:a.mime||"image/jpeg",captureWidth:a.width,captureHeight:a.height,cssWidth:l.width,cssHeight:l.height,payload:o,accentColor:e.primary,accentFill:e.primarySoft});return{payload:o,screenshot:u}}catch{return{payload:o,screenshot:null}}},rn={colorScheme:"dark",primary:"rgb(59, 130, 246)",primarySoft:"rgba(59, 130, 246, 0.16)",primaryFaint:"rgba(59, 130, 246, 0.10)",primaryContrast:"rgb(255, 255, 255)",surface:"rgb(24, 24, 27)",surfaceElevated:"rgb(32, 32, 36)",glassSurface:"rgba(32, 32, 36, 0.64)",glassFilter:"blur(26px) saturate(1.16)",border:"rgba(255, 255, 255, 0.14)",text:"rgb(244, 244, 245)",mutedText:"rgba(244, 244, 245, 0.62)"},Iw=()=>{if(typeof document>"u"||!document.body)return null;const t=document.createElement("div");return t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;pointer-events:none",document.body.appendChild(t),{read:e=>{t.style.backgroundColor="",t.style.backgroundColor=e;const n=window.getComputedStyle(t).backgroundColor;return n&&n!=="rgba(0, 0, 0, 0)"?n:""},readVariable:e=>window.getComputedStyle(document.documentElement).getPropertyValue(e).trim(),dispose:()=>t.remove()}},Tw=t=>{const e=Iw();if(!e)return{...rn,colorScheme:t};try{const n=(a,u)=>e.read(`var(${a})`)||u,r=(a,u,d)=>e.read(`color-mix(in srgb, var(${a}) ${u}%, transparent)`)||d,i=e.readVariable("--oc-glass-tooltip-opacity")||"62%",o=e.readVariable("--oc-glass-blur")||"26px",l=e.readVariable("--oc-glass-saturation")||"1.16";return{colorScheme:t,glassSurface:e.read(`color-mix(in srgb, var(--surface-elevated) ${i}, transparent)`)||rn.glassSurface,glassFilter:`blur(${o}) saturate(${l})`,primary:n("--primary",rn.primary),primarySoft:r("--primary",16,rn.primarySoft),primaryFaint:r("--primary",10,rn.primaryFaint),primaryContrast:n("--primary-foreground",rn.primaryContrast),surface:n("--surface-background",rn.surface),surfaceElevated:n("--surface-elevated",rn.surfaceElevated),border:n("--border",rn.border),text:n("--foreground",rn.text),mutedText:n("--muted-foreground",rn.mutedText)}}catch{return{...rn,colorScheme:t}}finally{e.dispose()}},Ew=2e3,Rw=50;let nr=null,Sr=null,Hr=null;const Mw=async t=>{try{const e=await ms("/api/browser-control/claim",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t})});return e.ok?(await e.json())?.granted===!0:!1}catch{return!1}},ur=async(t,e)=>{try{const n=await ms("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});n.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${n.status}); the agent will see this action time out`)}catch(n){console.warn(`[browser-control] could not deliver the result for ${t}:`,n)}},Ow=async(t=Ew)=>{const e=Date.now()+t;for(;!nr&&Date.now()<e;)await new Promise(n=>setTimeout(n,Rw));return nr},Bw=async t=>{const e=t.action==="browser.open",n=nr;if(!(!n&&!(e&&Sr))&&await Mw(t.requestId))try{if(e&&!n){const i=typeof t.parameters.url=="string"?t.parameters.url:"";if(!i){await ur(t.requestId,{ok:!1,error:"url is required"});return}Sr?.(i);const o=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!o||o==="fill"){await ur(t.requestId,{ok:!0,data:{url:i,opened:!0}});return}const l=await Ow();if(!l){await ur(t.requestId,{ok:!0,data:{url:i,opened:!0,viewportApplied:!1,note:"The panel had no browser view yet, so the viewport was not applied. Call browser.resize now that one exists."}});return}const a=await l.run("browser.resize",{viewport:o}),u=a&&typeof a=="object"?a.viewport??null:null;await ur(t.requestId,{ok:!0,data:{url:i,opened:!0,viewportApplied:!0,viewport:u}});return}const r=await n.run(t.action,t.parameters);await ur(t.requestId,{ok:!0,data:r})}catch(r){await ur(t.requestId,{ok:!1,error:r instanceof Error?r.message:String(r)})}},kf=()=>{Hr||(Hr=ro(t=>{t.type==="browser-control-request"&&Bw({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},Cf=()=>{nr||Sr||!Hr||(Hr(),Hr=null)},Fw=t=>(nr=t,kf(),()=>{nr===t&&(nr=null),Cf()}),_w=t=>(Sr=t,kf(),()=>{Sr===t&&(Sr=null),Cf()}),Lw=50,$w=6,zw=2048,Ww=200,Nf=t=>{const e=vr(String(t??"").trim());if(!e||e.length>zw)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},Kw=(t,e)=>{const n=Nf(e.url);if(!n)return t;const r=t.find(l=>l.url===n),i=String(e.title??"").trim().slice(0,Ww)||r?.title||"";return[{url:n,title:i,lastVisitedAt:e.at},...t.filter(l=>l.url!==n)].slice(0,Lw)},Vw=(t,e)=>{const n=Nf(e);return t.filter(r=>r.url!==n)},Uw=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Af=(t,e,n=$w)=>{const r=String(e??"").trim().toLowerCase(),i=[...t].sort((l,a)=>a.lastVisitedAt-l.lastVisitedAt);if(!r)return i.slice(0,n);const o=r.replace(/^https?:\/\//,"");return i.filter(l=>{const a=Uw(l);return l.url===r||a===o?!1:a.includes(o)}).slice(0,n)},wc=20,Ao=t=>{const e=gt((t||"").trim());return e?JSON.stringify([as(),e]):""},Hw=t=>{const e=Object.keys(t);if(e.length<=wc)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,i)=>i[1]-r[1]).slice(0,wc);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},jr=Ar()(rb(t=>({byProject:{},recordVisit:(e,n)=>{const r=Ao(e);r&&t(i=>{const o=i.byProject[r]??[],l=Kw(o,{...n,at:Date.now()});return l===o?i:{byProject:Hw({...i.byProject,[r]:l})}})},forget:(e,n)=>{const r=Ao(e);r&&t(i=>{const o=i.byProject[r];return o?{byProject:{...i.byProject,[r]:Vw(o,n)}}:i})},clear:e=>{const n=Ao(e);n&&t(r=>{if(!(n in r.byProject))return r;const i={...r.byProject};return delete i[n],{byProject:i}})}}),{name:"openchamber-browser-history",version:1,storage:Xm(),partialize:t=>({byProject:t.byProject})})),Gw=[],Df=t=>e=>{const n=Ao(t);return(n?e.byProject[n]:void 0)??Gw},la=new Map,di=new Map,rr=new Map,or=new Set,qw=async(t,e)=>{if(!dl()){or.delete(t),mr(t,{type:"close"});return}if(await Jm(En()),!or.has(t)||!dl())return;const n=ja().websocket(`/api/dev-tunnel?port=${e}`),r=Zm(n);rr.set(t,r),r.binaryType="arraybuffer",r.onopen=()=>mr(t,{type:"ready"}),r.onmessage=i=>mr(t,{type:"data",data:i.data instanceof ArrayBuffer?i.data:new TextEncoder().encode(i.data)}),r.onerror=()=>mr(t,{type:"close"}),r.onclose=()=>{or.delete(t),rr.delete(t),mr(t,{type:"close"})}};Rp(({connectionId:t,remotePort:e,message:n})=>{switch(n.type){case"data":{const r=rr.get(t);r&&n.data&&r.send(n.data);return}case"close":or.delete(t),rr.get(t)?.close(),rr.delete(t);return;case"connect":or.add(t),qw(t,e).catch(()=>{or.delete(t),mr(t,{type:"close"})})}});const Pf=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,If=t=>{if(!t)return!1;try{const e=new URL(t,typeof window<"u"?window.location.href:void 0),n=typeof window<"u"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"";return n&&e.origin===n?!1:!Dr(e.toString())}catch{return!1}},Tf=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:0}catch{return 0}},vc=(t,e)=>{try{const n=new URL(t);return n.protocol="http:",n.hostname="127.0.0.1",n.port=String(e),n.toString()}catch{return t}},Sc=(t,e)=>{try{di.set(e,new URL(t).origin)}catch{}};class Gr extends Error{constructor(e){super(e),this.name="DevTunnelUnavailableError"}}const jc=async t=>{if(!t||!Pf()||!Dr(t))return t;const e=En();if(!If(e))return t;const n=Tf(t);if(!n)return t;const r=`${e}|${n}`,i=la.get(r);if(i)return Sc(t,i),vc(t,i);try{const o=await yr("desktop_dev_tunnel_open",{baseUrl:e,port:n,relay:eh(),targetKey:as(),clientToken:Qr(),requestHeaders:Ld()});if(!o||!Number.isInteger(o.localPort)||o.localPort<=0)throw new Gr(t);return la.set(r,o.localPort),Sc(t,o.localPort),vc(t,o.localPort)}catch(o){throw o instanceof Gr?o:new Gr(t)}},kc=t=>{if(!t||!Pf()||!Dr(t)||!If(En()))return!1;const e=Tf(t);return e>0&&!di.has(e)},Or=t=>{if(!t)return t;try{const e=new URL(t);if(e.hostname!=="127.0.0.1")return t;const n=di.get(Number.parseInt(e.port||"0",10));return n?`${n}${e.pathname}${e.search}${e.hash}`:t}catch{return t}},Yw=()=>{la.clear(),di.clear(),or.clear();for(const t of rr.values())t.close();rr.clear(),yr("desktop_relay_dev_tunnel_close_all").catch(()=>{})};typeof window<"u"&&eo(Yw);const Cc=6e3,Qw=120,Xw=80,Jw=`
574
- var MAX_ELEMENTS = ${Qw};
575
- var MAX_LABEL_CHARS = ${Xw};
576
- var visible = function (element) {
577
- var rect = element.getBoundingClientRect();
578
- if (rect.width < 1 || rect.height < 1) return false;
579
- var style = window.getComputedStyle(element);
580
- return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
581
- };
582
- var label = function (element) {
583
- var aria = element.getAttribute('aria-label');
584
- if (aria) return aria.trim();
585
- var value = element.getAttribute('value');
586
- var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
587
- if (text) return text.slice(0, MAX_LABEL_CHARS);
588
- if (value) return String(value).slice(0, MAX_LABEL_CHARS);
589
- var placeholder = element.getAttribute('placeholder');
590
- return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
591
- };
592
- var isUnique = function (selector) {
593
- try {
594
- return document.querySelectorAll(selector).length === 1;
595
- } catch (error) {
596
- return false;
597
- }
598
- };
599
-
600
- /**
601
- * Names an element by what it is, falling back to where it sits.
602
- *
603
- * A positional chain like 'main > section:nth-of-type(3) > div > a' survives
604
- * only until the markup shifts, and says nothing about what it points at.
605
- * Anything the page states about identity — an id, a test id, an accessible
606
- * name — outlives edits and reads as the thing it selects. The chain remains
607
- * as the last resort, because something always has to work.
608
- */
609
- var cssPath = function (element) {
610
- var tag = element.tagName.toLowerCase();
611
-
612
- if (element.id) {
613
- var byId = '#' + CSS.escape(element.id);
614
- if (isUnique(byId)) return byId;
615
- }
616
- var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
617
- for (var a = 0; a < stableAttrs.length; a += 1) {
618
- var value = element.getAttribute(stableAttrs[a]);
619
- if (!value) continue;
620
- var raw = String(value);
621
- // A value containing a quote would need escaping for no real gain: such
622
- // attributes are rare, and the positional chain still covers them.
623
- if (raw.indexOf('"') !== -1) continue;
624
- var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
625
- if (isUnique(byAttr)) return byAttr;
626
- }
627
- var className = typeof element.className === 'string' ? element.className.trim() : '';
628
- if (className) {
629
- var classes = className.split(/\\s+/).filter(Boolean);
630
- for (var c = 0; c < classes.length; c += 1) {
631
- var byClass = tag + '.' + CSS.escape(classes[c]);
632
- if (isUnique(byClass)) return byClass;
633
- }
634
- }
635
-
636
- var parts = [];
637
- var node = element;
638
- var depth = 0;
639
- while (node && node.nodeType === 1 && depth < 6) {
640
- var part = node.tagName.toLowerCase();
641
- var parent = node.parentElement;
642
- if (!parent) { parts.unshift(part); break; }
643
- var siblings = Array.prototype.filter.call(parent.children, function (child) {
644
- return child.tagName === node.tagName;
645
- });
646
- if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
647
- parts.unshift(part);
648
- if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
649
- node = parent;
650
- depth += 1;
651
- }
652
- return parts.join(' > ');
653
- };
654
-
655
- /** What a screen reader would announce, or '' when there is nothing to say. */
656
- var accessibleName = function (element) {
657
- var aria = element.getAttribute('aria-label');
658
- if (aria && aria.trim()) return aria.trim();
659
- var labelled = element.getAttribute('aria-labelledby');
660
- if (labelled) {
661
- var source = document.getElementById(labelled.split(/\\s+/)[0]);
662
- if (source && (source.innerText || '').trim()) return source.innerText.trim();
663
- }
664
- var title = element.getAttribute('title');
665
- if (title && title.trim()) return title.trim();
666
- var alt = element.getAttribute('alt');
667
- if (alt && alt.trim()) return alt.trim();
668
- var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
669
- if (text) return text;
670
- var value = element.getAttribute('value');
671
- return value && String(value).trim() ? String(value).trim() : '';
672
- };
673
- var findByText = function (needle) {
674
- var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
675
- var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
676
- var exact = null;
677
- var partial = null;
678
- for (var i = 0; i < candidates.length; i += 1) {
679
- var element = candidates[i];
680
- if (!visible(element)) continue;
681
- var text = label(element).toLowerCase();
682
- if (!text) continue;
683
- if (text === wanted) { exact = element; break; }
684
- if (!partial && text.indexOf(wanted) !== -1) partial = element;
685
- }
686
- return exact || partial;
687
- };
688
- `,oo=t=>`(() => {
689
- ${Jw}
690
- ${t}
691
- })()`,Zw=({selector:t}={})=>oo(`
692
- var scopeSelector = ${JSON.stringify(t??"")};
693
- var root = document;
694
- if (scopeSelector) {
695
- try { root = document.querySelector(scopeSelector); }
696
- catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
697
- if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
698
- }
699
- var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
700
- var elements = [];
701
- var visibleTotal = 0;
702
- for (var i = 0; i < interactive.length; i += 1) {
703
- var element = interactive[i];
704
- if (!visible(element)) continue;
705
- visibleTotal += 1;
706
- if (elements.length >= MAX_ELEMENTS) continue;
707
-
708
- var rect = element.getBoundingClientRect();
709
- // Empty and default-valued fields are left out rather than serialized as
710
- // "" and false. Repeated across a hundred entries that overhead dwarfed
711
- // the information it carried.
712
- var entry = {
713
- selector: cssPath(element),
714
- tag: element.tagName.toLowerCase(),
715
- bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
716
- };
717
- // The list covers the whole document so anything can be clicked without
718
- // scrolling to it first, which means bounds alone do not say what is on
719
- // screen — a negative y reads as a bug otherwise.
720
- if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
721
- var type = element.getAttribute('type');
722
- if (type) entry.type = type;
723
- var role = element.getAttribute('role');
724
- if (role) entry.role = role;
725
- var labelText = label(element);
726
- if (labelText) entry.label = labelText;
727
- if (element.disabled === true) entry.disabled = true;
728
- // Flagged rather than described: reporting the accessible name of every
729
- // element would cost more than it tells, while its absence on something
730
- // clickable is a defect worth naming.
731
- if (!accessibleName(element)) entry.missingAccessibleName = true;
732
- elements.push(entry);
733
- }
734
- var body = document.body ? (document.body.innerText || '') : '';
735
- var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
736
- var docEl = document.documentElement;
737
- var result = {
738
- ok: true,
739
- url: String(location.href),
740
- title: String(document.title || ''),
741
- scope: scopeSelector || 'document',
742
- scrollY: Math.round(window.scrollY),
743
- maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
744
- text: text.slice(0, ${Cc}),
745
- elements: elements
746
- };
747
- // State what was dropped. A capped list that reports only its own length
748
- // reads as the whole page, and the agent acts as if it had seen everything.
749
- if (text.length > ${Cc}) {
750
- result.textTruncated = true;
751
- result.textTotalChars = text.length;
752
- }
753
- if (visibleTotal > elements.length) {
754
- result.elementsTruncated = true;
755
- result.interactiveElementsOnPage = visibleTotal;
756
- }
757
- return result;
758
- `),ev=({selector:t,text:e})=>oo(`
759
- var selector = ${JSON.stringify(t??"")};
760
- var text = ${JSON.stringify(e??"")};
761
- var target = null;
762
- if (selector) {
763
- try { target = document.querySelector(selector); }
764
- catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
765
- if (!target) return { ok: false, error: 'No element matches ' + selector };
766
- } else {
767
- target = findByText(text);
768
- if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
769
- }
770
- if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
771
- target.scrollIntoView({ block: 'center', inline: 'center' });
772
- target.click();
773
- return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
774
- `),tv=({selector:t,value:e,submit:n})=>oo(`
775
- var selector = ${JSON.stringify(t)};
776
- var value = ${JSON.stringify(e)};
777
- var target = null;
778
- try { target = document.querySelector(selector); }
779
- catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
780
- if (!target) return { ok: false, error: 'No element matches ' + selector };
781
-
782
- var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
783
- if (!editable) return { ok: false, error: selector + ' is not a text field' };
784
- if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
785
-
786
- target.scrollIntoView({ block: 'center' });
787
- target.focus();
788
- if (target.isContentEditable) {
789
- target.textContent = value;
790
- } else {
791
- // Frameworks track the value through the native setter; assigning the
792
- // property directly leaves React and friends unaware of the change.
793
- var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
794
- var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
795
- if (setter && setter.set) setter.set.call(target, value);
796
- else target.value = value;
797
- }
798
- target.dispatchEvent(new Event('input', { bubbles: true }));
799
- target.dispatchEvent(new Event('change', { bubbles: true }));
800
-
801
- if (${n?"true":"false"}) {
802
- var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
803
- target.dispatchEvent(new KeyboardEvent('keydown', enter));
804
- target.dispatchEvent(new KeyboardEvent('keyup', enter));
805
- var form = target.form;
806
- if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
807
- }
808
- return { ok: true, selector: cssPath(target), url: String(location.href) };
809
- `),sv=({selector:t,direction:e})=>oo(`
810
- var selector = ${JSON.stringify(t??"")};
811
- var direction = ${JSON.stringify(e??"")};
812
-
813
- var settle = function (extra) {
814
- return new Promise(function (resolve) {
815
- requestAnimationFrame(function () {
816
- requestAnimationFrame(function () {
817
- var doc = document.documentElement;
818
- var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
819
- var scrollY = Math.round(window.scrollY);
820
- var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
821
- result.atTop = scrollY <= 1;
822
- result.atBottom = scrollY >= maxScrollY - 1;
823
- for (var key in extra) {
824
- if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
825
- }
826
- resolve(result);
827
- });
828
- });
829
- });
830
- };
831
-
832
- if (selector) {
833
- var target = null;
834
- try { target = document.querySelector(selector); }
835
- catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
836
- if (!target) return { ok: false, error: 'No element matches ' + selector };
837
- // Instant on purpose: the page's own smooth scrolling would still be
838
- // animating when the next action runs against it.
839
- target.scrollIntoView({ block: 'center', behavior: 'instant' });
840
- return settle({ scrolledTo: cssPath(target) });
841
- }
842
-
843
- var doc = document.documentElement;
844
- var page = Math.round(window.innerHeight * 0.85);
845
- var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
846
- if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
847
- else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
848
- else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
849
- else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
850
- else return { ok: false, error: 'Unknown scroll direction: ' + direction };
851
- return settle({ direction: direction });
852
- `),nv=["color","background-color","background-image","opacity","font-family","font-size","font-weight","line-height","letter-spacing","text-align","border-radius","border-width","border-style","border-color","box-shadow","display","position","width","height","padding","margin","gap","flex-direction","justify-content","align-items","z-index","overflow","visibility"],rv=({selector:t})=>oo(`
853
- var selector = ${JSON.stringify(t)};
854
- var target = null;
855
- try { target = document.querySelector(selector); }
856
- catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
857
- if (!target) return { ok: false, error: 'No element matches ' + selector };
858
-
859
- var computed = window.getComputedStyle(target);
860
- var styles = {};
861
- var props = ${JSON.stringify(nv)};
862
- for (var i = 0; i < props.length; i += 1) {
863
- var value = computed.getPropertyValue(props[i]);
864
- if (value) styles[props[i]] = String(value).trim();
865
- }
866
-
867
- var rect = target.getBoundingClientRect();
868
- return {
869
- ok: true,
870
- selector: cssPath(target),
871
- tag: target.tagName.toLowerCase(),
872
- label: label(target),
873
- bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
874
- inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
875
- styles: styles
876
- };
877
- `),ov=t=>{const e=et.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=vt();if(n.length===0)return null;let u;e[0]!==a?(u=a("contextPanel.browser.history.label"),e[0]=a,e[1]=u):u=e[1];let d;if(e[2]!==r||e[3]!==n||e[4]!==o||e[5]!==l||e[6]!==i||e[7]!==a){let m;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(m=(g,b)=>s.jsxs("div",{role:"option","aria-selected":b===r,className:Me("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",b===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:y=>{y.preventDefault(),i(g.url)},onPointerEnter:()=>l(b),children:[s.jsx(M,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-micro text-foreground",children:g.title||Ja(g.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:g.url})]}),s.jsx("button",{type:"button",className:Me("shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity","hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"),"aria-label":a("contextPanel.browser.history.forget"),title:a("contextPanel.browser.history.forget"),onPointerDown:y=>{y.preventDefault(),y.stopPropagation(),o(g.url)},children:s.jsx(M,{name:"close",className:"size-3","aria-hidden":"true"})})]},g.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=m):m=e[14],d=n.map(m),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=d}else d=e[8];let h;return e[15]!==u||e[16]!==d?(h=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":u,children:d}),e[15]=u,e[16]=d,e[17]=h):h=e[17],h},on=t=>{const e=et.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",u=l&&"text-foreground";let d;e[0]!==u?(d=Me("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",u),e[0]=u,e[1]=d):d=e[1];let h;e[2]!==n?(h=s.jsx(M,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=h):h=e[3];let m;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==d||e[10]!==h?(m=s.jsx(Pt,{asChild:!0,children:s.jsx(dt,{type:"button",variant:a,size:"xs",className:d,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:h})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=d,e[10]=h,e[11]=m):m=e[11];let g;e[12]!==r?(g=s.jsx(It,{sideOffset:6,children:r}),e[12]=r,e[13]=g):g=e[13];let b;return e[14]!==m||e[15]!==g?(b=s.jsxs(Dt,{children:[m,g]}),e[14]=m,e[15]=g,e[16]=b):b=e[16],b},Ef=t=>{const e=et.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:u,onReload:d,onOpenExternal:h,canGoBack:m,canGoForward:g,isLoading:b,onAnnotate:y,onOpenDevTools:S,isAnnotating:w,onHardReload:f,onZoomIn:x,onZoomOut:v,onZoomReset:p,zoomPercent:N,onClearCookies:C,onClearCache:k,onToggleDeviceBar:D,isDeviceBarOpen:I}=t;let A;e[0]!==r?(A=r===void 0?[]:r,e[0]=r,e[1]=A):A=e[1];const P=A,T=N===void 0?100:N,{t:_}=vt(),[L,W]=c.useState(!1),[O,$]=c.useState(-1);let j;e[2]!==L||e[3]!==P?(j=L?P:[],e[2]=L,e[3]=P,e[4]=j):j=e[4];const E=j;let K;e[5]===Symbol.for("react.memo_cache_sentinel")?(K=()=>{$(-1)},e[5]=K):K=e[5];let ee;e[6]!==n||e[7]!==L?(ee=[n,L],e[6]=n,e[7]=L,e[8]=ee):ee=e[8],c.useEffect(K,ee);let J;e[9]!==l?(J=Oe=>{W(!1),$(-1),l(Oe)},e[9]=l,e[10]=J):J=e[10];const ne=J;let ue;e[11]!==O||e[12]!==ne||e[13]!==E?(ue=Oe=>{if(E.length!==0){if(Oe.key==="ArrowDown"||Oe.key==="ArrowUp"){Oe.preventDefault();const ge=Oe.key==="ArrowDown"?1:-1,He=E.length;$(V=>{const Ae=V+ge;return Ae<-1?He-1:Ae>=He?-1:Ae});return}if(Oe.key==="Escape"&&O>=0){Oe.preventDefault(),$(-1);return}if(Oe.key==="Enter"&&O>=0){Oe.preventDefault();const ge=E[O];ge&&ne(ge.url)}}},e[11]=O,e[12]=ne,e[13]=E,e[14]=ue):ue=e[14];const X=ue;let te;e[15]!==_?(te=_("contextPanel.browser.back"),e[15]=_,e[16]=te):te=e[16];const fe=!m;let je;e[17]!==a||e[18]!==fe||e[19]!==te?(je=s.jsx(on,{icon:"arrow-left",label:te,onClick:a,disabled:fe}),e[17]=a,e[18]=fe,e[19]=te,e[20]=je):je=e[20];let ve;e[21]!==_?(ve=_("contextPanel.browser.forward"),e[21]=_,e[22]=ve):ve=e[22];const ye=!g;let Pe;e[23]!==u||e[24]!==ve||e[25]!==ye?(Pe=s.jsx(on,{icon:"arrow-right",label:ve,onClick:u,disabled:ye}),e[23]=u,e[24]=ve,e[25]=ye,e[26]=Pe):Pe=e[26];let xe;e[27]!==b||e[28]!==_?(xe=_(b?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=b,e[28]=_,e[29]=xe):xe=e[29];let R;e[30]!==d||e[31]!==xe?(R=s.jsx(on,{icon:"refresh",label:xe,onClick:d}),e[30]=d,e[31]=xe,e[32]=R):R=e[32];let Y;e[33]!==f||e[34]!==_?(Y=f?s.jsx(on,{icon:"restart",label:_("contextPanel.browser.hardReload"),onClick:f}):null,e[33]=f,e[34]=_,e[35]=Y):Y=e[35];let ie;e[36]!==n||e[37]!==ne?(ie=Oe=>{Oe.preventDefault(),ne(n)},e[36]=n,e[37]=ne,e[38]=ie):ie=e[38];let H;e[39]!==o?(H=Oe=>o(Oe.target.value),e[39]=o,e[40]=H):H=e[40];let me,pe;e[41]===Symbol.for("react.memo_cache_sentinel")?(me=()=>W(!0),pe=()=>W(!1),e[41]=me,e[42]=pe):(me=e[41],pe=e[42]);const re=E.length>0;let de;e[43]===Symbol.for("react.memo_cache_sentinel")?(de=Me("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[43]=de):de=e[43];let B;e[44]!==_?(B=_("contextPanel.browser.addressAria"),e[44]=_,e[45]=B):B=e[45];let F;e[46]!==n||e[47]!==X||e[48]!==H||e[49]!==re||e[50]!==B?(F=s.jsx("input",{value:n,onChange:H,onFocus:me,onBlur:pe,onKeyDown:X,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":re,"aria-controls":"openchamber-browser-address-suggestions",className:de,"aria-label":B}),e[46]=n,e[47]=X,e[48]=H,e[49]=re,e[50]=B,e[51]=F):F=e[51];let he;e[52]!==i?(he=Oe=>i?.(Oe),e[52]=i,e[53]=he):he=e[53];let Se;e[54]!==O||e[55]!==ne||e[56]!==he||e[57]!==E?(Se=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(ov,{entries:E,activeIndex:O,onSelect:ne,onForget:he,onHighlight:$})}),e[54]=O,e[55]=ne,e[56]=he,e[57]=E,e[58]=Se):Se=e[58];let Re;e[59]!==ie||e[60]!==F||e[61]!==Se?(Re=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:ie,children:[F,Se]}),e[59]=ie,e[60]=F,e[61]=Se,e[62]=Re):Re=e[62];let le;e[63]!==x||e[64]!==v||e[65]!==p||e[66]!==_||e[67]!==T?(le=v&&x?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(on,{icon:"subtract",label:_("contextPanel.browser.zoomOut"),onClick:v}),T!==100&&p?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsxs(dt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:p,"aria-label":_("contextPanel.browser.zoomReset"),children:[T,"%"]})}),s.jsx(It,{sideOffset:6,children:_("contextPanel.browser.zoomReset")})]}):null,s.jsx(on,{icon:"add",label:_("contextPanel.browser.zoomIn"),onClick:x})]}):null,e[63]=x,e[64]=v,e[65]=p,e[66]=_,e[67]=T,e[68]=le):le=e[68];let se;e[69]!==C||e[70]!==_?(se=C?s.jsx(on,{icon:"delete-bin",label:_("contextPanel.browser.clearCookies"),onClick:C}):null,e[69]=C,e[70]=_,e[71]=se):se=e[71];let q;e[72]!==k||e[73]!==_?(q=k?s.jsx(on,{icon:"database-2",label:_("contextPanel.browser.clearCache"),onClick:k}):null,e[72]=k,e[73]=_,e[74]=q):q=e[74];let z;e[75]!==I||e[76]!==D||e[77]!==_?(z=D?s.jsx(on,{icon:"smartphone",label:_("contextPanel.browser.deviceToolbar"),onClick:D,pressed:I}):null,e[75]=I,e[76]=D,e[77]=_,e[78]=z):z=e[78];let ae;e[79]!==w||e[80]!==y||e[81]!==_?(ae=y?s.jsx(on,{icon:"markup",label:_("contextPanel.browser.annotate.toggle"),onClick:y,pressed:w}):null,e[79]=w,e[80]=y,e[81]=_,e[82]=ae):ae=e[82];let ce;e[83]!==S||e[84]!==_?(ce=S?s.jsx(on,{icon:"terminal-box",label:_("contextPanel.browser.devTools"),onClick:S}):null,e[83]=S,e[84]=_,e[85]=ce):ce=e[85];let Ne;e[86]!==_?(Ne=_("contextPanel.browser.openExternal"),e[86]=_,e[87]=Ne):Ne=e[87];let we;e[88]!==h||e[89]!==Ne?(we=s.jsx(on,{icon:"external-link",label:Ne,onClick:h}),e[88]=h,e[89]=Ne,e[90]=we):we=e[90];let $e;return e[91]!==je||e[92]!==Pe||e[93]!==R||e[94]!==Y||e[95]!==Re||e[96]!==le||e[97]!==se||e[98]!==q||e[99]!==z||e[100]!==ae||e[101]!==ce||e[102]!==we?($e=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[je,Pe,R,Y,Re,le,se,q,z,ae,ce,we]}),e[91]=je,e[92]=Pe,e[93]=R,e[94]=Y,e[95]=Re,e[96]=le,e[97]=se,e[98]=q,e[99]=z,e[100]=ae,e[101]=ce,e[102]=we,e[103]=$e):$e=e[103],$e},Lo={kind:"fill"},Nc=240,iv=3840,Rf=[{id:"iphone-se",label:"iPhone SE",width:375,height:667},{id:"iphone-14",label:"iPhone 14",width:390,height:844},{id:"iphone-14-pro-max",label:"iPhone 14 Pro Max",width:430,height:932},{id:"pixel-7",label:"Pixel 7",width:412,height:915},{id:"ipad-mini",label:"iPad mini",width:768,height:1024},{id:"ipad-pro",label:"iPad Pro",width:1024,height:1366},{id:"laptop",label:"Laptop",width:1280,height:800},{id:"desktop",label:"Desktop",width:1440,height:900}],Ac=t=>Number.isFinite(t)?Math.round(Math.min(iv,Math.max(Nc,t))):Nc,$o=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Mf=t=>{const e=Rf.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},av=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},lv=(t,e)=>{const n=$o(t);if(!n)return null;const r=Math.max(1,e.width),i=Math.max(1,e.height),o=Math.min(1,r/n.width,i/n.height);return{width:n.width,height:n.height,scale:o}},cv=["mobile","tablet","desktop","fill"],dv={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Dc=t=>typeof t=="string"&&cv.includes(t),ca=t=>t==="fill"?Lo:Mf(dv[t])??Lo,mo=t=>{const e=$o(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=ca(n),i=$o(r);if(i&&i.width===e.width&&i.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},uv=t=>{const e=et.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=vt();let u;e[0]!==n?(u=$o(n),e[0]=n,e[1]=u):u=e[1];const d=u,h=n.kind==="preset"?n.id:"";let m;e[2]!==r||e[3]!==d?(m=(fe,je)=>{const ve=Number.parseInt(je,10);if(!Number.isFinite(ve))return;const ye=d??{width:1280,height:800};r({kind:"custom",width:Ac(fe==="width"?ve:ye.width),height:Ac(fe==="height"?ve:ye.height)})},e[2]=r,e[3]=d,e[4]=m):m=e[4];const g=m;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=Me("h-6 w-14 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[5]=b):b=e[5];const y=b;let S;e[6]!==r?(S=fe=>{const je=Mf(fe.target.value);r(je??Lo)},e[6]=r,e[7]=S):S=e[7];let w;e[8]!==a?(w=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=w):w=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=Me("h-6 shrink-0 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[10]=f):f=e[10];let x;e[11]!==a?(x=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=x):x=e[12];let v;e[13]!==x?(v=s.jsx("option",{value:"",children:x}),e[13]=x,e[14]=v):v=e[14];let p;e[15]===Symbol.for("react.memo_cache_sentinel")?(p=Rf.map(fv),e[15]=p):p=e[15];let N;e[16]!==h||e[17]!==S||e[18]!==w||e[19]!==v?(N=s.jsxs("select",{value:h,onChange:S,"aria-label":w,className:f,children:[v,p]}),e[16]=h,e[17]=S,e[18]=w,e[19]=v,e[20]=N):N=e[20];const C=d?String(d.width):"";let k;e[21]!==g?(k=fe=>g("width",fe.target.value),e[21]=g,e[22]=k):k=e[22];let D;e[23]!==a?(D=a("contextPanel.browser.device.width"),e[23]=a,e[24]=D):D=e[24];let I;e[25]!==C||e[26]!==k||e[27]!==D?(I=s.jsx("input",{value:C,onChange:k,placeholder:"—",inputMode:"numeric","aria-label":D,className:y}),e[25]=C,e[26]=k,e[27]=D,e[28]=I):I=e[28];let A;e[29]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=A):A=e[29];const P=d?String(d.height):"";let T;e[30]!==g?(T=fe=>g("height",fe.target.value),e[30]=g,e[31]=T):T=e[31];let _;e[32]!==a?(_=a("contextPanel.browser.device.height"),e[32]=a,e[33]=_):_=e[33];let L;e[34]!==P||e[35]!==T||e[36]!==_?(L=s.jsx("input",{value:P,onChange:T,placeholder:"—",inputMode:"numeric","aria-label":_,className:y}),e[34]=P,e[35]=T,e[36]=_,e[37]=L):L=e[37];let W;e[38]!==r||e[39]!==n?(W=()=>r(av(n)),e[38]=r,e[39]=n,e[40]=W):W=e[40];const O=!d;let $;e[41]!==a?($=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=$):$=e[42];let j;e[43]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(M,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=j):j=e[43];let E;e[44]!==W||e[45]!==O||e[46]!==$?(E=s.jsx(Pt,{asChild:!0,children:s.jsx(dt,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:W,disabled:O,"aria-label":$,children:j})}),e[44]=W,e[45]=O,e[46]=$,e[47]=E):E=e[47];let K;e[48]!==a?(K=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=K):K=e[49];let ee;e[50]!==K?(ee=s.jsx(It,{sideOffset:6,children:K}),e[50]=K,e[51]=ee):ee=e[51];let J;e[52]!==E||e[53]!==ee?(J=s.jsxs(Dt,{children:[E,ee]}),e[52]=E,e[53]=ee,e[54]=J):J=e[54];let ne;e[55]!==l||e[56]!==d?(ne=d&&l<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=d,e[57]=ne):ne=e[57];let ue;e[58]===Symbol.for("react.memo_cache_sentinel")?(ue=["system","light","dark"],e[58]=ue):ue=e[58];let X;e[59]!==i||e[60]!==o||e[61]!==a?(X=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:ue.map(fe=>s.jsx(dt,{type:"button",variant:i===fe?"secondary":"ghost",size:"xs",className:Me("shrink-0 rounded-full px-2.5 typography-micro",i===fe?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(fe),"aria-pressed":i===fe,children:a(fe==="system"?"contextPanel.browser.device.schemeSystem":fe==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},fe))}),e[59]=i,e[60]=o,e[61]=a,e[62]=X):X=e[62];let te;return e[63]!==N||e[64]!==I||e[65]!==L||e[66]!==J||e[67]!==ne||e[68]!==X?(te=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[N,I,A,L,J,ne,X]}),e[63]=N,e[64]=I,e[65]=L,e[66]=J,e[67]=ne,e[68]=X,e[69]=te):te=e[69],te};function fv(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const mv=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},hv=2e3,pv=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=En();if(!t)return!1;try{return!Dr(new URL(t,window.location.href).toString())}catch{return!1}},Of=t=>{const e=et.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=vt();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,u]=c.useState(l),d=Pb(i),[h]=c.useState(pv);let m,g;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{let I=!0,A=null;const P=new AbortController,T=()=>{uw(P.signal).then(_=>{I&&(u(_),A=setTimeout(T,hv))})};return T(),()=>{I=!1,A&&clearTimeout(A),P.abort()}},g=[],e[1]=m,e[2]=g):(m=e[1],g=e[2]),c.useEffect(m,g);const b=a.kind==="ready"?a.servers:null;let y;e[3]!==d||e[4]!==b?(y=hw({announced:d,discovered:b}),e[3]=d,e[4]=b,e[5]=y):y=e[5];const S=y;let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(ju,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=w):w=e[6];let f;e[7]!==o?(f=o("contextPanel.browser.empty"),e[7]=o,e[8]=f):f=e[8];let x;e[9]!==f?(x=s.jsx("span",{className:"typography-ui-header text-foreground",children:f}),e[9]=f,e[10]=x):x=e[10];let v;e[11]!==o?(v=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=v):v=e[12];let p;e[13]!==v?(p=s.jsx("span",{className:"typography-micro text-muted-foreground",children:v}),e[13]=v,e[14]=p):p=e[14];let N;e[15]!==p||e[16]!==x?(N=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[x,p]}),e[15]=p,e[16]=x,e[17]=N):N=e[17];let C;e[18]!==d||e[19]!==S||e[20]!==i||e[21]!==n||e[22]!==h||e[23]!==o?(C=S.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-left text-muted-foreground",children:d.length>0?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),h?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:S.map(I=>s.jsxs(dt,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{Nb(i),n(I.url)},children:[s.jsx(M,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:Ja(I.url)||I.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:mv(I.url)})]},I.port))})]}):null,e[18]=d,e[19]=S,e[20]=i,e[21]=n,e[22]=h,e[23]=o,e[24]=C):C=e[24];let k;e[25]!==S.length||e[26]!==a.kind||e[27]!==o?(k=S.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=S.length,e[26]=a.kind,e[27]=o,e[28]=k):k=e[28];let D;return e[29]!==N||e[30]!==C||e[31]!==k?(D=s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[w,N,C,k]}),e[29]=N,e[30]=C,e[31]=k,e[32]=D):D=e[32],D},Fs=t=>Math.round(t),gv=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,u])=>`${a}="${u}"`).join(" "),i=t.ancestry.map(a=>a.selectorPart).join(" > "),o=t.computedStyle,l=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,i?`- Ancestry: ${i}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${Fs(l.x)}, y=${Fs(l.y)}, width=${Fs(l.width)}, height=${Fs(l.height)}`,`- Styles: display=${o.display??""}; position=${o.position??""}; font=${o.fontWeight??""} ${o.fontSize??""} / ${o.lineHeight??""} ${o.fontFamily??""}; color=${o.color??""}; background=${o.backgroundColor??""}`].filter(a=>typeof a=="string")},xv=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${Fs(n.x)}, y=${Fs(n.y)}, width=${Fs(n.width)}, height=${Fs(n.height)}`},bv=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Fs(n.x)}, y=${Fs(n.y)}, width=${Fs(n.width)}, height=${Fs(n.height)}`},yv=({payload:t,screenshotAttached:e,intro:n})=>{const r=n.replace(/[.:]+$/g,""),i=t.comment.trim(),o=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${Fs(t.viewport.width)}x${Fs(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,i?`Comment: ${i}`:null];for(const[l,a]of t.elements.entries())o.push("",...gv(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(xv(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(bv(l,a)))),o.filter(l=>typeof l=="string").join(`
878
- `)},wv=t=>{const e=et.c(7),{t:n}=vt(),r=Ze(Sv),i=Ze(jv),o=Li(kv),l=Mp(Cv);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async u=>{const d=r??(i?"draft":null);if(!d){_e.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(u.screenshot)try{await l(u.screenshot),h=!0}catch{h=!1}o({directory:t,sessionKey:d},{source:"preview-annotation",fileLabel:u.payload.pageUrl||"browser",startLine:1,endLine:1,code:yv({payload:u.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),_e.success(n("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=n,e[6]=a):a=e[6],a},vv=()=>{const t=et.c(16),{t:e}=vt();let n;t[0]!==e?(n=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:n,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function Sv(t){return t.currentSessionId}function jv(t){return t.newSessionDraft?.open}function kv(t){return t.addDraft}function Cv(t){return t.addAttachedFile}const Nv=3e4,Av=3,Dv=250,Pv={attempts:0,windowStartedAt:null},Iv=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=Nv,r=n?0:t.attempts;return r>=Av?null:{delayMs:Dv*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Tv=-3,ho=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",xr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Ev=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:xw),[o,l]=c.useState(e),[a,u]=c.useState(""),[d,h]=c.useState(!1),[m,g]=c.useState(!1),b=c.useRef(n);b.current=n;const y=c.useRef(Pv);return c.useEffect(()=>{if(!t)return;const S=()=>{try{const A=t.getURL();return ho(A)?A:""}catch{return""}},w=()=>{try{h(t.canGoBack()),g(t.canGoForward())}catch{}},f=A=>{ho(A)&&(l(A),b.current(A))},x=()=>{const A=S();i({kind:"loading",url:A})},v=()=>{const A=S();let P="";try{P=t.getTitle()||""}catch{P=""}u(P),f(A),w(),i(T=>T.kind==="failed"&&T.url===A?T:{kind:"ready",url:A,title:P})},p=A=>{const P=xr(A);ho(P.url)&&(f(P.url),w())},N=A=>{const P=xr(A),T=Array.isArray(P.favicons)?P.favicons.find(Boolean):"",_=S();T&&_&&vf.getState().resolve(_,T)},C=A=>{const P=xr(A);typeof P.title=="string"&&u(P.title)},k=A=>{const P=xr(A);if(P.isMainFrame===!1)return;const T=typeof P.errorCode=="number"?P.errorCode:0;T!==Tv&&i({kind:"failed",url:ho(P.validatedURL)?P.validatedURL:S(),code:T,description:typeof P.errorDescription=="string"?P.errorDescription:""})};let D=null;const I=()=>{const A=S(),P=Iv(y.current,Date.now());if(!P){i({kind:"failed",url:A,code:0,description:"",crashed:!0});return}y.current=P.state,i({kind:"loading",url:A}),D=setTimeout(()=>{D=null;try{t.reload()}catch{i({kind:"failed",url:A,code:0,description:"",crashed:!0})}},P.delayMs)};t.addEventListener("did-start-loading",x),t.addEventListener("did-stop-loading",v),t.addEventListener("did-navigate",p),t.addEventListener("did-navigate-in-page",p),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",N),t.addEventListener("did-fail-load",k),t.addEventListener("render-process-gone",I),t.addEventListener("crashed",I);try{!t.isLoading()&&S()&&v()}catch{}return()=>{D!==null&&clearTimeout(D),t.removeEventListener("render-process-gone",I),t.removeEventListener("crashed",I),t.removeEventListener("did-start-loading",x),t.removeEventListener("did-stop-loading",v),t.removeEventListener("did-navigate",p),t.removeEventListener("did-navigate-in-page",p),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",N),t.removeEventListener("did-fail-load",k)}},[t]),{status:r,url:o,title:a,canGoBack:d,canGoForward:m}},Rv=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Mv=4e4,po=.5,Ov=-3,Bv=4,Fv="persist:openchamber-browser",Pc=20,_v=600,Lv=2e4,$v=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=vt(),{currentTheme:i}=ar(),o=c.useRef(null),[l,a]=c.useState(null),u=c.useCallback(le=>{o.current=le,a(le)},[]),d=De(le=>le.setContextPanelTabTargetPath),h=c.useRef(vr(t)),m=h.current!==an?h.current:"",[g,b]=c.useState(m?null:an),[y,S]=c.useState(m),[w,f]=c.useState(!1),[x,v]=c.useState(!1),[p,N]=c.useState(0),C=c.useRef(0),[k,D]=c.useState(!1),[I,A]=c.useState(Lo),P=c.useRef(I);P.current=I;const T=c.useRef([]),[_,L]=c.useState("system"),[W,O]=c.useState({width:0,height:0}),$=c.useRef(null),j=c.useRef(null),E=c.useRef(!1),K=c.useRef(Date.now()),ee=c.useCallback(le=>{!le||le===an||!e||!n||d(e,n,le)},[e,n,d]),J=Ev(l,{initialUrl:m,onUrlChange:c.useCallback(le=>{const se=Or(le);S(se),ee(se)},[ee])}),[ne,ue]=c.useState(null),X=wv(e),te=vv(),fe=J.status.kind==="loading",je=jr(Df(e)),ve=jr(le=>le.recordVisit),ye=jr(le=>le.forget);c.useEffect(()=>{J.status.kind==="ready"&&ve(e,{url:Or(J.status.url),title:J.status.title})},[e,J.status,ve]);const Pe=c.useMemo(()=>Af(je,y),[je,y]),xe=c.useCallback(le=>{const se=vr(le);se!==an&&(S(se),ue(null),jc(se).then(q=>{const z=o.current;if(!z){b(q);return}try{z.loadURL(q)}catch{b(q)}}).catch(q=>{q instanceof Gr&&ue(se)}))},[]);c.useEffect(()=>{if(!m)return;let le=!0;return jc(m).then(se=>{le&&b(se)}).catch(se=>{if(le){if(se instanceof Gr){ue(m),b(an);return}b(m)}}),()=>{le=!1}},[]);const R=c.useMemo(()=>({executeJavaScript:async(le,se)=>{const q=o.current;if(!q)throw new Error("Browser view is not available");return q.executeJavaScript(le,se)},capturePage:async()=>{const le=o.current;if(!le)return null;const se=le.getWebContentsId();return Number.isFinite(se)?await yr("desktop_browser_capture_page",{webContentsId:se}):null}}),[]),Y=c.useCallback(()=>{if(w){f(!1),No(R);return}if(!J.url){_e.error(r("contextPanel.browser.annotate.noPage"));return}const le=Tw(i.metadata.variant==="light"?"light":"dark");f(!0),Pw({host:R,theme:le,labels:te}).then(async se=>{f(!1),se&&await X(se)}).catch(()=>{f(!1),_e.error(r("contextPanel.browser.annotate.failed"))})},[R,X,i,w,J.url,te,r]);c.useEffect(()=>{if(!w)return;const le=se=>{Op(se)||se.key!=="Escape"||(se.preventDefault(),se.stopImmediatePropagation(),f(!1),No(R))};return window.addEventListener("keydown",le,!0),()=>window.removeEventListener("keydown",le,!0)},[R,w]);const ie=c.useCallback(async(le=8e3)=>{const se=Date.now();for(;;){const q=o.current;if(!q)return!1;let z=!1;try{z=q.isLoading()}catch{return!1}if(!z)return!0;if(Date.now()-se>le)return!1;await new Promise(ae=>setTimeout(ae,120))}},[]),H=c.useCallback(async(le,se)=>{const q=o.current;if(!q)throw new Error("The browser panel is not ready");const z=()=>{Dc(se.viewport)&&(A(ca(se.viewport)),D(!0))};if(le==="browser.back"||le==="browser.forward"){const Oe=le==="browser.back";if(!(Oe?q.canGoBack():q.canGoForward()))throw new Error(Oe?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Oe?q.goBack():q.goForward(),await new Promise(V=>setTimeout(V,150)),await ie();let He="";try{He=q.getTitle()||""}catch{He=""}return{url:Or(q.getURL()),title:He}}if(le==="browser.capture"){De.getState().openContextBrowser(e,q.getURL());const Oe=Date.now()+1200;let ge=0,He=0;for(;He<2&&Date.now()<Oe;){const Ie=q.getBoundingClientRect().width;He=Ie>=2&&Math.abs(Ie-ge)<.5?He+1:0,ge=Ie,await new Promise(Fe=>setTimeout(Fe,50))}await new Promise(Ie=>{requestAnimationFrame(()=>requestAnimationFrame(()=>Ie()))}),await ie();const V=await R.capturePage();if(!V)throw new Error("The page could not be captured");let Ae="";try{Ae=q.getTitle()||""}catch{Ae=""}return{...V,url:Or(q.getURL()),title:Ae,viewport:mo(P.current)}}if(le==="browser.resize"){if(!Dc(se.viewport))throw new Error("viewport is required");return z(),await new Promise(Oe=>setTimeout(Oe,200)),await ie(),{viewport:mo(ca(se.viewport))}}if(le==="browser.open"){const Oe=typeof se.url=="string"?se.url:"";if(!Oe)throw new Error("url is required");z(),xe(Oe),await new Promise(V=>setTimeout(V,150));const ge=await ie(25e3);let He="";try{He=q.getTitle()||""}catch{He=""}return{url:vr(Oe),title:He,opened:!0,settled:ge,viewport:mo(P.current)}}await ie();const ae=Oe=>typeof Oe=="string"&&Oe?Oe:void 0,Ne=(()=>{switch(le){case"browser.snapshot":return Zw({selector:ae(se.selector)});case"browser.click":return ev({selector:ae(se.selector),text:ae(se.text)});case"browser.type":return tv({selector:String(se.selector??""),value:String(se.value??""),submit:se.submit===!0});case"browser.inspect":return rv({selector:String(se.selector??"")});case"browser.scroll":return sv({selector:ae(se.selector),direction:ae(se.direction)});default:return null}})();if(!Ne)throw new Error(`Unsupported browser action: ${le}`);const we=await q.executeJavaScript(Ne,!0);if(!we||typeof we!="object")throw new Error("The page returned no result");const $e=we;if($e.ok!==!0)throw new Error(typeof $e.error=="string"&&$e.error?$e.error:"Browser action failed");if(le==="browser.snapshot"){const Oe=T.current;return{...$e,viewport:mo(P.current),...Oe.length>0?{consoleProblems:[...Oe]}:{}}}return(le==="browser.click"||le==="browser.type"&&se.submit===!0)&&(await new Promise(Oe=>setTimeout(Oe,150)),await ie()),we},[R,e,xe,ie]);c.useEffect(()=>Fw({run:H}),[H]),c.useEffect(()=>{const le=R;return()=>{No(le)}},[R]),c.useEffect(()=>{if(!l)return;const le=q=>{const z=q;if(typeof z.level!="number"||z.level<2)return;const ae=z.sourceId?`${z.sourceId}${z.line?`:${z.line}`:""}`:"";T.current.push({level:z.level>=3?"error":"warning",message:String(z.message??"").slice(0,400),source:ae}),T.current.length>Pc&&T.current.splice(0,T.current.length-Pc)},se=()=>{T.current=[]};return l.addEventListener("console-message",le),l.addEventListener("did-start-loading",se),()=>{l.removeEventListener("console-message",le),l.removeEventListener("did-start-loading",se)}},[l]);const me=c.useRef(new Set),pe=c.useCallback(le=>{me.current.clear(),xe(le)},[xe]);c.useEffect(()=>{if(!l)return;const le=q=>{const z=xr(q),ae=typeof z.url=="string"?z.url:"";!ae||!kc(ae)||(q.preventDefault(),xe(ae))},se=q=>{const z=xr(q);if(z.isMainFrame===!1||z.errorCode===-3)return;const ae=typeof z.validatedURL=="string"?z.validatedURL:"";!ae||!kc(ae)||me.current.has(ae)||(me.current.add(ae),xe(ae))};return l.addEventListener("will-navigate",le),l.addEventListener("did-fail-load",se),()=>{l.removeEventListener("will-navigate",le),l.removeEventListener("did-fail-load",se)}},[xe,l]),c.useEffect(()=>{if(!l)return;const le=se=>{const q=se.detail;se.preventDefault(),q?.url&&xe(q.url)};return l.addEventListener("new-window",le),()=>l.removeEventListener("new-window",le)},[xe,l]);const re=c.useCallback(le=>{const se=Math.min(Bv,Math.max(Ov,le));C.current=se,N(se);try{o.current?.setZoomLevel(se)}catch{}},[]);c.useEffect(()=>{const le=se=>{if(!(se instanceof CustomEvent))return;const q=se.detail,z=o.current;!z||document.activeElement!==z||(q==="zoom-in"?re(C.current+po):q==="zoom-out"?re(C.current-po):q==="zoom-reset"&&re(0))};return window.addEventListener("openchamber:zoom",le),()=>window.removeEventListener("openchamber:zoom",le)},[re]);const de=c.useCallback(le=>{yr("desktop_browser_clear_data",{partition:Fv,cookies:le==="cookies",cache:le==="cache"}).then(()=>{_e.success(r(le==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>_e.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const le=$.current;if(!le||typeof ResizeObserver>"u")return;const se=new ResizeObserver(q=>{const z=q[0]?.contentRect;z&&O({width:z.width,height:z.height})});return se.observe(le),()=>se.disconnect()},[]);const B=c.useCallback(le=>{L(le);const se=o.current;if(!se)return;let q=-1;try{q=se.getWebContentsId()}catch{return}yr("desktop_browser_set_color_scheme",{webContentsId:q,scheme:le}).catch(z=>{L("system"),_e.error(z instanceof Error?z.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),F=c.useCallback(()=>{try{fe?o.current?.stop():o.current?.reload()}catch{}},[fe]),he=J.status;c.useEffect(()=>{const le=()=>{v(!0);const z=setTimeout(()=>{try{o.current?.reload()}catch{}},_v);return()=>clearTimeout(z)};if(he.kind==="failed"){if(!cw(he.code,he.url)){v(!1);return}const z=Date.now(),ae=j.current?.url===he.url?j.current:{url:he.url,startedAt:z};if(j.current=ae,z-ae.startedAt>Mv){v(!1);return}return le()}if(he.kind==="loading")return;if(j.current=null,he.kind!=="ready"||!he.url||!Dr(he.url)){E.current=!0,v(!1);return}if(E.current||Date.now()-K.current>Lv){E.current=!0,v(!1);return}let se=!1,q=null;return fw(Or(he.url)).then(z=>{if(!se){if(z===null||z<500){E.current=!0,v(!1);return}q=le()}}),()=>{se=!0,q?.()}},[he]);const Se=J.status.kind==="failed"&&!x?J.status:null,Re=lv(I,W);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Ef,{address:y,onAddressChange:S,onSubmit:pe,suggestions:Pe,onForgetSuggestion:le=>ye(e,le),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:F,onOpenExternal:()=>{Yo(J.url||y)},canGoBack:J.canGoBack,canGoForward:J.canGoForward,isLoading:fe,onAnnotate:Y,isAnnotating:w,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>re(p+po),onZoomOut:()=>re(p-po),onZoomReset:()=>re(0),zoomPercent:Math.round(Math.pow(1.2,p)*100),onClearCookies:()=>de("cookies"),onClearCache:()=>de("cache"),onToggleDeviceBar:()=>D(le=>!le),isDeviceBarOpen:k}),k?s.jsx(uv,{viewport:I,onViewportChange:A,colorScheme:_,onColorSchemeChange:B,scale:Re?.scale??1}):null,s.jsxs("div",{ref:$,className:Me("relative min-h-0 flex-1 bg-background",Re&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null?s.jsx("webview",{ref:u,src:g,partition:"persist:openchamber-browser",allowpopups:!0,style:Re?{width:`${Re.width}px`,height:`${Re.height}px`,transform:`scale(${Re.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,g!==null&&!m&&!J.url&&!fe?s.jsx(Of,{onOpen:pe,directory:e}):null,x?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,ne?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:ne})})]}):null,Se&&!ne?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:Se.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:Se.crashed?r("contextPanel.browser.crashedHint"):Se.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,fe?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},zv=t=>{const e=et.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=vt(),l=De(Kv);let a;e[0]!==n?(a=vr(n),e[0]=n,e[1]=a):a=e[1];const u=a,d=u!==an?u:"",[h,m]=c.useState(d),[g,b]=c.useState(d);let y;e[2]!==d?(y=d?[d]:[],e[2]=d,e[3]=y):y=e[3];const[S,w]=c.useState(y),[f,x]=c.useState(d?0:-1),[v,p]=c.useReducer(Vv,0);let N;e[4]!==r||e[5]!==l||e[6]!==i?(N=te=>{!te||te===an||!r||!i||l(r,i,te)},e[4]=r,e[5]=l,e[6]=i,e[7]=N):N=e[7];const C=N;let k;e[8]!==r?(k=Df(r),e[8]=r,e[9]=k):k=e[9];const D=jr(k),I=jr(Uv),A=jr(Hv);let P;e[10]!==h||e[11]!==D?(P=Af(D,h),e[10]=h,e[11]=D,e[12]=P):P=e[12];const T=P;let _;e[13]!==r||e[14]!==f||e[15]!==C||e[16]!==I?(_=te=>{const fe=vr(te);fe!==an&&(m(fe),b(fe),C(fe),I(r,{url:fe}),w(je=>{const ve=f>=0?je.slice(0,f+1):[];return ve[ve.length-1]===fe?(x(ve.length-1),ve):(x(ve.length),[...ve,fe])}))},e[13]=r,e[14]=f,e[15]=C,e[16]=I,e[17]=_):_=e[17];const L=_;let W;e[18]!==S||e[19]!==C?(W=te=>{const fe=S[te];fe&&(x(te),m(fe),b(fe),C(fe))},e[18]=S,e[19]=C,e[20]=W):W=e[20];const O=W;let $;e[21]!==r||e[22]!==A?($=te=>A(r,te),e[21]=r,e[22]=A,e[23]=$):$=e[23];let j,E;e[24]!==O||e[25]!==f?(E=()=>O(f-1),j=()=>O(f+1),e[24]=O,e[25]=f,e[26]=j,e[27]=E):(j=e[26],E=e[27]);let K;e[28]!==h||e[29]!==g?(K=()=>{Yo(g||h)},e[28]=h,e[29]=g,e[30]=K):K=e[30];const ee=f>0,J=f>=0&&f<S.length-1;let ne;e[31]!==h||e[32]!==L||e[33]!==T||e[34]!==j||e[35]!==K||e[36]!==ee||e[37]!==J||e[38]!==$||e[39]!==E?(ne=s.jsx(Ef,{address:h,onAddressChange:m,onSubmit:L,suggestions:T,onForgetSuggestion:$,onBack:E,onForward:j,onReload:p,onOpenExternal:K,canGoBack:ee,canGoForward:J,isLoading:!1}),e[31]=h,e[32]=L,e[33]=T,e[34]=j,e[35]=K,e[36]=ee,e[37]=J,e[38]=$,e[39]=E,e[40]=ne):ne=e[40];let ue;e[41]!==g||e[42]!==L||e[43]!==v||e[44]!==o?(ue=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:g?s.jsx("iframe",{src:g,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${v}`):s.jsx(Of,{onOpen:L})}),e[41]=g,e[42]=L,e[43]=v,e[44]=o,e[45]=ue):ue=e[45];let X;return e[46]!==ne||e[47]!==ue?(X=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[ne,ue]}),e[46]=ne,e[47]=ue,e[48]=X):X=e[48],X},Wv=t=>{const e=et.c(3),[n]=c.useState(Rv);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx($v,{...t}):s.jsx(zv,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function Kv(t){return t.setContextPanelTabTargetPath}function Vv(t){return t+1}function Uv(t){return t.recordVisit}function Hv(t){return t.forget}const Gv=Un(()=>On(()=>import("./WalkthroughView-wSpED5L4.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,113,114,115,116,117,118,119,120,121,122,123,124,125])).then(t=>({default:t.WalkthroughView}))),qv=Un(()=>On(()=>import("./DiffView-DkC3xlRJ.js"),__vite__mapDeps([126,1,2,4,5,6,7,8,9,83,3,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,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,113,114,115,116,127,117,118,119,120,121,122,123,124,125])).then(t=>({default:t.DiffView}))),Yv=Un(()=>On(()=>import("./FilesView-D0bM9FVB.js"),__vite__mapDeps([128,1,2,4,5,6,7,8,9,3,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,84,85,86,129,130,131,132,133,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,113,114,134,135,120,121,118,123,136,119,137])).then(t=>({default:t.FilesView}))),Qv=Un(()=>On(()=>import("./GitView-Bxuv3dfP.js"),__vite__mapDeps([138,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,84,85,86,139,117,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,113,114,87,115,116,118,119,120,121,122,123,124,125])).then(t=>({default:t.GitView}))),Xv=Un(()=>On(()=>import("./LinearIssuesView-UI1FcSC8.js"),__vite__mapDeps([140,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])).then(t=>({default:t.LinearIssuesView}))),Jv=Un(()=>On(()=>import("./PlanView-u2yi5XGJ.js"),__vite__mapDeps([141,1,2,4,5,6,7,8,9,129,57,58,59,60,61,62,79,55,56,63,130,131,132,3,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,119,137,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,84,85,86])).then(t=>({default:t.PlanView}))),Zv=c.lazy(()=>On(()=>import("./PluginPane-QxjsKYeO.js").then(t=>t.k),__vite__mapDeps([86,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])).then(t=>({default:t.PluginPane}))),eS=320,tS=1400,Bf=600,sS=100,nS=24,zo=new Map,rS=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Ic=t=>Number.isFinite(t)?Math.min(tS,Math.max(eS,Math.round(t))):Bf,oS=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},iS=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},Ff=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="linear"?e("contextPanel.mode.linear"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):tr(t)?pu.getState().guests.find(r=>r.id===Ei(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),aS=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},lS=(t,e,n)=>{if(t.mode==="chat"){const r=da(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||n("contextPanel.mode.chat")}return t.mode==="browser"?Ja(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?aS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Ff(t.mode,n)},cS=t=>{const e=et.c(8),{mode:n}=t,r=Ea();let i;if(e[0]!==n||e[1]!==r){let d;e[3]!==n?(d=h=>h.mode===n,e[3]=n,e[4]=d):d=e[4],i=r.find(d),e[0]=n,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??Lp,a=o?.iconSrc;let u;return e[5]!==l||e[6]!==a?(u=s.jsx(to,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=u):u=e[7],u},Tc=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Ta,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(uf,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(M,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(M,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(M,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(M,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(M,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(M,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(M,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(M,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(M,{name:"chat-4",className:"h-3.5 w-3.5"});if(tr(t.mode))return s.jsx(cS,{mode:t.mode});if(t.mode==="browser"){const n=dS(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(M,{name:"global",className:"h-3.5 w-3.5"})}},dS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},uS=({visible:t,active:e,fill:n=!1})=>{const{t:r}=vt(),i=De(x=>x.contextEditorTreeWidth),o=De(x=>x.setContextEditorTreeWidth),[l,a]=c.useState(!1),u=c.useRef(0),d=c.useRef(i),h=c.useRef(null),m=c.useRef(null),g=c.useRef(null),b=c.useCallback(x=>{const v=g.current;v&&(v.style.width=`${x}px`,v.style.setProperty("--oc-editor-tree-width",`${x}px`))},[]),y=x=>{if(t){try{x.currentTarget.setPointerCapture(x.pointerId)}catch{}m.current=x.pointerId,a(!0),u.current=x.clientX,d.current=i,h.current=i,x.preventDefault()}},S=x=>{if(!l||m.current!==x.pointerId)return;const v=u.current-x.clientX,p=Ti(d.current+v);h.current!==p&&(h.current=p,b(p))},w=x=>{if(m.current!==x.pointerId)return;try{x.currentTarget.releasePointerCapture(x.pointerId)}catch{}const v=Ti(h.current??i);m.current=null,h.current=null,a(!1),o(v)},f=t?i:0;return s.jsxs("div",{ref:g,className:Me("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${l?h.current??f:f}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${l?h.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:Me("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",l&&"bg-[var(--interactive-border)]"),onPointerDown:y,onPointerMove:S,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Me("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(P1,{visible:t&&e})})]})},da=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,fS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},mS=(t,e)=>{if(e.length===0)return zo;const n=new Set(e),r=new Map;for(const i of t){if(!n.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?zo:r},hS=(t,e)=>{const n=au(t),r=c.useRef(zo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=mS(n.getState().session,i.current);return fS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>zo)},pS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,gS=()=>{const{t}=vt(),e=lr()??"",n=c.useMemo(()=>rS(e),[e]),r=De(G=>n?G.contextPanelByDirectory[n]:void 0),i=De(G=>G.closeContextPanel),o=De(G=>G.closeContextPanelTab),l=De(G=>G.openContextPanelTab),a=De(G=>G.toggleContextPanelExpanded),u=De(G=>G.setContextPanelWidth),d=De(G=>G.setActiveContextPanelTab),h=De(G=>G.openContextBrowser);c.useEffect(()=>{if(e)return _w(G=>h(e,G))},[e,h]);const m=De(G=>G.reorderContextPanelTabs),g=bn(G=>G.setSelectedPath),b=De(G=>G.contextEditorTreeVisible),y=De(G=>G.contextEditorTreeWidth),S=De(G=>G.setContextEditorTreeWidth),w=De(G=>G.toggleContextEditorTree),f=De(G=>G.contextEditorVisible),x=De(G=>G.toggleContextEditor),v=De(G=>G.openNewContextBrowserTab),p=vf(G=>G.byOrigin),N=De(G=>G.allowPromptingSubagentSessions),{themeMode:C,setThemeMode:k,lightThemeId:D,darkThemeId:I,currentTheme:A}=ar(),P=c.useMemo(()=>r?.tabs??[],[r?.tabs]),T=P.find(G=>G.id===r?.activeTabId)??P[P.length-1]??null,_=!!(r?.isOpen&&T),[L,W]=c.useState(null),O=c.useMemo(()=>P.some(G=>G.mode==="file"&&G.targetPath),[P]),$=O&&(f||!b),j=T?.mode??null,E=j==="file"&&!$,K=!!(_&&r?.expanded&&!E),ee=j?r?.widthByMode?.[j]:void 0,J=j?r?.widthFractionByMode?.[j]:void 0,ne=j?Bp(j):.5,ue=L??(typeof window<"u"?window.innerWidth:Bf*2),X=J!=null&&L!=null?Math.round(J*L):ee,te=E?y:Ic(X??Math.round(ne*ue));c.useEffect(()=>{!n||!j||E||J!=null||ee==null||L==null||u(n,j,ee,L)},[j,L,n,E,ee,J,u]);const fe=c.useMemo(()=>{const G=[];for(const U of P){if(U.mode!=="chat")continue;const Z=da(U.dedupeKey);Z&&!G.includes(Z)&&G.push(Z)}return G},[P]),je=hS(n||void 0,fe),[ve,ye]=c.useState(!1),Pe=c.useRef(0),xe=c.useRef(te),R=c.useRef(null),Y=c.useRef(null),ie=c.useRef(null),H=c.useRef(new Map),me=c.useRef(new Map),pe=c.useRef(!1);c.useLayoutEffect(()=>{const G=ie.current?.parentElement;if(!G||typeof ResizeObserver>"u")return;const U=new ResizeObserver(()=>{W(G.clientWidth||null)});return U.observe(G),W(G.clientWidth||null),()=>U.disconnect()},[]),c.useEffect(()=>{if(!_||pe.current){pe.current=_;return}const G=window.requestAnimationFrame(()=>{ie.current?.focus({preventScroll:!0})});return pe.current=!0,()=>window.cancelAnimationFrame(G)},[_]);const re=c.useRef(null),de=c.useRef(null),B=c.useCallback(()=>{de.current=null;const G=ie.current,U=R.current;!G||U===null||G.style.setProperty("--oc-context-panel-width",`${U}px`)},[]);c.useEffect(()=>()=>{de.current!==null&&clearTimeout(de.current)},[]);const F=c.useCallback(G=>{const U=E?Ti(G):Ic(G),Z=re.current;return Z===null?U:Math.min(U,Math.max(1,Z))},[E]),he=c.useCallback(G=>{!_||K||!n||(Y.current=G.pointerId,ye(!0),Pe.current=G.clientX,xe.current=te,R.current=te,re.current=oS(ie.current),document.documentElement.style.cursor="col-resize",G.preventDefault())},[n,K,_,te]),Se=c.useCallback(()=>{const G=F(R.current??te),U=re.current;R.current=null,re.current=null,de.current!==null&&(clearTimeout(de.current),de.current=null),document.documentElement.style.cursor="",E?S(G):n&&j&&u(n,j,G,U??void 0),ye(!1),Y.current=null},[j,F,n,E,S,u,te]);c.useEffect(()=>{if(!ve)return;const G=ke=>{if(Y.current!==ke.pointerId)return;const Te=Pe.current-ke.clientX,We=F(xe.current+Te);R.current!==We&&(R.current=We,de.current===null&&(de.current=setTimeout(B,sS)))},U=ke=>{Y.current===ke.pointerId&&Se()},Z=()=>{Se()};return window.addEventListener("pointermove",G),window.addEventListener("pointerup",U),window.addEventListener("pointercancel",U),window.addEventListener("blur",Z),()=>{window.removeEventListener("pointermove",G),window.removeEventListener("pointerup",U),window.removeEventListener("pointercancel",U),window.removeEventListener("blur",Z)}},[B,F,Se,ve]),c.useEffect(()=>{ve||(R.current=null,document.documentElement.style.cursor="")},[ve]);const Re=c.useCallback(()=>{n&&i(n)},[i,n]),le=c.useCallback(()=>{n&&a(n)},[n,a]),se=c.useCallback(G=>{G.key==="Escape"&&(G.target instanceof Node&&!G.currentTarget.contains(G.target)||Fp(G.target)||_p(G.target)||(G.preventDefault(),G.stopPropagation(),Re()))},[Re]);c.useEffect(()=>{if(!(!n||!T)&&T.mode==="file"&&T.targetPath){g(n,T.targetPath,{allowOutsideRoot:!0});return}},[T,n,g]);const q=c.useMemo(()=>P.filter(G=>G.mode==="chat"),[P]),z=_&&T?.mode==="chat"?T.id:null,ae=_&&T?.mode==="chat"?da(T.dedupeKey):null,ce=ob(q,z);c.useEffect(()=>{if(!_||!n||!ae||typeof window>"u")return;const G=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){fi(n,ae,!1);return}ku(ae),fi(n,ae,!0)};G();const U=window.setInterval(G,1e4);return window.addEventListener("focus",G),window.addEventListener("blur",G),document.addEventListener("visibilitychange",G),()=>{window.clearInterval(U),window.removeEventListener("focus",G),window.removeEventListener("blur",G),document.removeEventListener("visibilitychange",G),fi(n,ae,!1)}},[ae,n,_]);const Ne=c.useCallback((G,U,Z)=>ib(me.current,G,U,n||null,Z,{mode:C,lightThemeId:D,darkThemeId:I,currentTheme:A},{allowPromptingSubagentSessions:N}),[N,A,I,n,D,C]),we=ce&&ae?Ne(ce.id,ae,ce.readOnly):null;c.useEffect(()=>{const G=new Set(P.map(U=>U.id));for(const U of me.current.keys())G.has(U)||me.current.delete(U)},[P]);const $e=c.useCallback(G=>{!n||T?.mode!=="diff"||l(n,{mode:"diff",targetPath:T.targetPath,stagedDiff:G==="staged",diffScope:G})},[T,n,l]),Oe=c.useCallback(()=>{if(typeof window>"u")return;const G={themeMode:C,lightThemeId:D,darkThemeId:I,currentTheme:A};for(const U of H.current.values()){const Z=U.contentWindow;Z&&Z.postMessage({type:"openchamber:theme-sync",payload:G},window.location.origin)}},[A,I,D,C]),ge=c.useCallback(()=>{if(typeof window>"u")return;const G={allowPromptingSubagentSessions:N};for(const U of H.current.values()){const Z=U.contentWindow;Z&&Z.postMessage({type:"openchamber:chat-settings-sync",payload:G},window.location.origin)}},[N]),He=c.useCallback((G,U,Z)=>{const ke=U.contentWindow;ke&&ke.postMessage({type:Ju,payload:{visible:z===G}},Z)},[z]),V=c.useCallback(()=>{if(!(typeof window>"u"))for(const[G,U]of H.current.entries())He(G,U,window.location.origin)},[He]);c.useEffect(()=>{if(typeof window>"u")return;const G=U=>{if(U.origin!==window.location.origin)return;const Z=Array.from(H.current.entries()).find(([,nt])=>nt.contentWindow===U.source);if(!Z)return;const ke=U.data;if(ke?.type===ab){const[nt,rt]=Z;He(nt,rt,U.origin);return}if(ke?.type===lb){if(typeof ke.requestId!="string"||!ke.requestId)return;const nt=as(),rt={apiBaseUrl:En(),clientToken:Qr(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:Ld(),relayHostId:nt.startsWith("host:")?nt.slice(5):"",relay:th()??void 0};U.source?.postMessage({type:cb,requestId:ke.requestId,payload:rt},U.origin);return}if(ke?.type==="openchamber:theme-sync-request"){Oe();return}if(ke?.type==="openchamber:chat-settings-request"){ge();return}if(ke?.type!=="openchamber:cycle-theme-request")return;const Te=["light","dark","system"],Je=(Te.indexOf(C)+1)%Te.length;k(Te[Je])};return window.addEventListener("message",G),()=>window.removeEventListener("message",G)},[ge,He,Oe,k,C]),c.useLayoutEffect(()=>{P.some(U=>U.mode==="chat")&&(Oe(),ge(),V())},[I,D,ge,V,Oe,P,C]);const Ae=T?.mode==="file"||T?.mode==="chat"||T?.mode==="browser",Ie=c.useMemo(()=>T?P.filter(G=>G.mode===T.mode):[],[T,P]),Fe=c.useMemo(()=>Ie.map(G=>{const U=lS(G,je,t),Z=pS(U,nS),ke=iS(G.targetPath,e);return{id:G.id,label:Z,icon:Tc(G,p),title:ke?`${U}: ${ke}`:U,closeLabel:t("contextPanel.tab.closeTabAria",{label:Z})}}),[Ie,e,p,je,t]),st=T?.mode==="context"?s.jsx(q1,{}):T?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Qv,{isActive:_})}):T?.mode==="pr"?s.jsx(s1,{}):T?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Xv,{})}):T?.mode==="notes"?s.jsx(Dh,{}):T?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Jv,{targetPath:T.targetPath,savedProjectPlan:T.projectPlanId&&T.projectPlanRef?{projectRef:T.projectPlanRef,planId:T.projectPlanId}:null})}):null,lt=c.useMemo(()=>P.filter(G=>G.mode==="browser"),[P]),it=c.useMemo(()=>P.filter(G=>G.mode==="diff"),[P]),mt=c.useMemo(()=>P.find(G=>G.mode==="terminal")??null,[P]),St=c.useMemo(()=>P.some(G=>G.mode==="walkthrough"),[P]),ht=c.useMemo(()=>P.filter(G=>tr(G.mode)),[P]),Xe=c.useMemo(()=>P.some(G=>G.mode==="file"),[P]),Ct=T?.mode==="file",Mt=De(G=>G.closeContextPanelTabs),be=c.useCallback(G=>{if(!n)return null;const{id:U,index:Z,allIds:ke,close:Te}=G,We=()=>Mt(n,ke.filter(Tt=>Tt!==U)),Je=()=>Mt(n,ke.slice(0,Z)),nt=()=>Mt(n,ke.slice(Z+1)),rt=()=>Mt(n,ke),Ye=ke.length>1,Nt=Z===0,Ke=Z===ke.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Jn,{onClick:Te,children:[s.jsx(M,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Bi,{}),s.jsxs(Jn,{onClick:We,disabled:!Ye,children:[s.jsx(M,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Jn,{onClick:Je,disabled:Nt,children:[s.jsx(M,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Jn,{onClick:nt,disabled:Ke,children:[s.jsx(M,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Bi,{}),s.jsxs(Jn,{onClick:rt,disabled:!Ye,children:[s.jsx(M,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[Mt,n,t]),Ue=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[Ae?s.jsx(Ud,{items:Fe,activeId:T?.id??null,onSelect:G=>{n&&d(n,G)},onClose:G=>{n&&o(n,G)},onReorder:(G,U)=>{n&&m(n,G,U)},layoutMode:"scrollable",variant:"default",tabContextMenu:be}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[T?Tc(T,p):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:T?Ff(T.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[T?.mode==="browser"?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&v(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(M,{name:"add",className:"h-3.5 w-3.5"})}):null,Ct&&O?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:x,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":$,children:s.jsx(M,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,Ct?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:w,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":b,children:s.jsx(M,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,E?null:s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:le,className:"h-7 w-7 p-0",title:t(K?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(K?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:K?s.jsx(M,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(M,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:Re,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]})]}),ut=_?K?{"--oc-context-panel-width":L!==null?`${L}px`:"100%",width:L!==null?`${L}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${te}px`}:{"--oc-context-panel-width":`${te}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:ie,"data-context-panel":"true",tabIndex:-1,inert:!_||void 0,className:Me("flex min-h-0 flex-col overflow-hidden bg-background",K?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!_&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:se,style:ut,children:[_&&!K&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),_&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!K&&s.jsx("div",{className:Me("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",ve&&"bg-[var(--interactive-border)]"),onPointerDown:he,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Me("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!_&&"pointer-events-none select-none opacity-0"),style:{width:K?L!==null?`${L}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!_,children:[Ue,s.jsxs("div",{className:Me("relative min-h-0 flex-1 overflow-hidden",ve&&"pointer-events-none"),children:[Xe?s.jsxs("div",{className:Me("absolute inset-0 flex",Ct?"flex":"hidden"),children:[O||!b?s.jsx("div",{className:Me("h-full min-w-0 flex-1",O&&!$&&"hidden"),children:O?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Yv,{mode:"editor-only",visible:_&&Ct&&$})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(M,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,s.jsx(uS,{visible:b,active:_&&Ct,fill:!$})]}):null,ce&&ae&&we?s.jsx("iframe",{ref:G=>{if(!G){H.current.delete(ce.id);return}H.current.set(ce.id,G)},src:we,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:ae}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{Oe(),ge(),V()}},ce.id):null,lt.map(G=>s.jsx("div",{className:Me("absolute inset-0",T?.id!==G.id&&"hidden"),children:s.jsx(Wv,{initialUrl:G.targetPath??"",directory:n,tabID:G.id})},G.id)),it.map(G=>s.jsx("div",{className:Me("absolute inset-0",T?.id!==G.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(qv,{visible:_&&T?.id===G.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:G.diffScope??(G.stagedDiff?"staged":"working"),onDiffScopeChange:$e,targetFilePath:G.targetPath,flushContent:!0})})},G.id)),mt?s.jsx("div",{className:Me("absolute inset-0",T?.mode==="terminal"?"block":"hidden"),children:s.jsx(Ph,{visible:_&&T?.mode==="terminal",directory:mt.targetDirectory})}):null,St?s.jsx("div",{className:Me("absolute inset-0",T?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Gv,{directory:e,visible:_&&T?.mode==="walkthrough"})})}):null,ht.map(G=>tr(G.mode)?s.jsx("div",{className:Me("absolute inset-0",T?.id===G.id?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Zv,{mode:G.mode})})},G.id):null),T?.mode!=="chat"&&!Ct&&T?.mode!=="browser"&&T?.mode!=="diff"&&T?.mode!=="terminal"&&T?.mode!=="walkthrough"&&!(T&&tr(T.mode))?st:null]})]})]})},xS=t=>{const e=et.c(43),{open:n,onOpenChange:r}=t,{t:i}=vt(),o=De(bS),l=De(yS),a=De(wS),u=De(vS),d=Ea();let h;e[0]!==o||e[1]!==d?(h=Cu(o,d),e[0]=o,e[1]=d,e[2]=h):h=e[2];const m=h,g=l.length===0;let b;if(e[3]!==l||e[4]!==m){let I;e[6]!==l?(I=A=>l.includes(A.id),e[6]=l,e[7]=I):I=e[7],b=m.every(I),e[3]=l,e[4]=m,e[5]=b}else b=e[5];const y=b;let S;e[8]!==i?(S=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=S):S=e[9];let w;e[10]!==S?(w=s.jsx(Is,{children:S}),e[10]=S,e[11]=w):w=e[11];let f;e[12]!==i?(f=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=f):f=e[13];let x;e[14]!==f?(x=s.jsx(Ts,{children:f}),e[14]=f,e[15]=x):x=e[15];let v;e[16]!==w||e[17]!==x?(v=s.jsxs(Ws,{children:[w,x]}),e[16]=w,e[17]=x,e[18]=v):v=e[18];let p;if(e[19]!==l||e[20]!==a||e[21]!==m||e[22]!==i){let I;e[24]!==l||e[25]!==a||e[26]!==i?(I=A=>s.jsx($p,{settingsItem:`layout.context-rail.surface.${A.id}`,checked:!l.includes(A.id),onChange:P=>a(A.id,P),label:A.label??i(A.labelKey),ariaLabel:A.label??i(A.labelKey)},A.id),e[24]=l,e[25]=a,e[26]=i,e[27]=I):I=e[27],p=m.map(I),e[19]=l,e[20]=a,e[21]=m,e[22]=i,e[23]=p}else p=e[23];let N;e[28]!==p?(N=s.jsx("div",{className:"flex flex-col",children:p}),e[28]=p,e[29]=N):N=e[29];let C;e[30]!==g||e[31]!==y||e[32]!==u||e[33]!==i?(C=g?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[y?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(dt,{variant:"link",size:"xs",onClick:()=>u([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=g,e[31]=y,e[32]=u,e[33]=i,e[34]=C):C=e[34];let k;e[35]!==C||e[36]!==v||e[37]!==N?(k=s.jsxs(Ss,{className:"max-w-md",children:[v,N,C]}),e[35]=C,e[36]=v,e[37]=N,e[38]=k):k=e[38];let D;return e[39]!==r||e[40]!==n||e[41]!==k?(D=s.jsx(vs,{open:n,onOpenChange:r,children:k}),e[39]=r,e[40]=n,e[41]=k,e[42]=D):D=e[42],D};function bS(t){return t.contextRailOrder}function yS(t){return t.contextRailHiddenSurfaces}function wS(t){return t.setContextRailSurfaceVisible}function vS(t){return t.setContextRailHiddenSurfaces}const _f=150,SS=500,jS=[],kS=t=>t>99?"99+":String(t),CS=t=>{const e=et.c(52),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:u,badgeDescription:d,orderNumber:h,showOrderNumber:m,onSelect:g}=t;let b;e[0]!==n.id?(b={id:n.id},e[0]=n.id,e[1]=b):b=e[1];const{attributes:y,listeners:S,setNodeRef:w,transform:f,transition:x,isDragging:v}=ii(b);let p;e[2]!==a?(p=a!=null&&a>0?kS(a):null,e[2]=a,e[3]=p):p=e[3];const N=p;let C;e[4]!==f?(C=ai.Translate.toString(f),e[4]=f,e[5]=C):C=e[5];let k;e[6]!==C||e[7]!==x?(k={transform:C,transition:x},e[6]=C,e[7]=x,e[8]=k):k=e[8];const D=v&&"z-10 opacity-70";let I;e[9]!==D?(I=Me("relative",D),e[9]=D,e[10]=I):I=e[10];let A;e[11]!==g||e[12]!==n?(A=()=>g(n),e[11]=g,e[12]=n,e[13]=A):A=e[13];const P=u??o,T=r?"text-primary":"text-muted-foreground hover:text-foreground";let _;e[14]!==T?(_=Me("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",T),e[14]=T,e[15]=_):_=e[15];let L;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?(L=n.id==="diff"?s.jsx(uf,{className:"h-[18px] w-[18px]"}):s.jsx(to,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.iconSrc,e[18]=n.id,e[19]=L):L=e[19];let W;e[20]!==N||e[21]!==h||e[22]!==i||e[23]!==m?(W=m&&h!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:h===10?"0":h}):N?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:N}):i?s.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[20]=N,e[21]=h,e[22]=i,e[23]=m,e[24]=W):W=e[24];let O;e[25]!==y||e[26]!==r||e[27]!==S||e[28]!==_||e[29]!==L||e[30]!==W||e[31]!==A||e[32]!==P?(O=s.jsx(Pt,{asChild:!0,children:s.jsxs("button",{type:"button",...y,...S,onClick:A,"aria-label":P,"aria-pressed":r,className:_,children:[L,W]})}),e[25]=y,e[26]=r,e[27]=S,e[28]=_,e[29]=L,e[30]=W,e[31]=A,e[32]=P,e[33]=O):O=e[33];let $;e[34]!==o?($=s.jsx("span",{children:o}),e[34]=o,e[35]=$):$=e[35];let j;e[36]!==l?(j=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=j):j=e[37];let E;e[38]!==d?(E=d?s.jsx("span",{className:"typography-micro text-muted-foreground",children:d}):null,e[38]=d,e[39]=E):E=e[39];let K;e[40]!==$||e[41]!==j||e[42]!==E?(K=s.jsx(It,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[$,j,E]})}),e[40]=$,e[41]=j,e[42]=E,e[43]=K):K=e[43];let ee;e[44]!==O||e[45]!==K?(ee=s.jsxs(Dt,{delayDuration:_f,children:[O,K]}),e[44]=O,e[45]=K,e[46]=ee):ee=e[46];let J;return e[47]!==w||e[48]!==ee||e[49]!==k||e[50]!==I?(J=s.jsx("div",{ref:w,style:k,className:I,children:ee}),e[47]=w,e[48]=ee,e[49]=k,e[50]=I,e[51]=J):J=e[51],J},NS=()=>{const t=et.c(92),{t:e}=vt(),n=lr();let r;t[0]!==n?(r=n?fr(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=le=>i?le.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=De(o),a=De(AS),u=De(DS),d=De(PS),h=De(IS),m=De(TS),g=De(ES),b=De(RS),y=Da(MS),S=Wi(OS),w=Wi(BS),f=Rn(FS),x=Rn(_S),{screenWidth:v}=Vn(),p=Pa(i||null);let N;t[4]!==b?(N=Ki("switch_context_surface",b),t[4]=b,t[5]=N):N=t[5];const C=N,[k,D]=c.useState(!1);let I,A;t[6]!==C?(I=()=>{const le=new Set;let se=null,q=!1;const z=LS,ae=()=>{Pl(C,le)?!q&&se===null&&(se=setTimeout(()=>D(!0),SS)):(q=!1,se!==null&&(clearTimeout(se),se=null),D(!1))},ce=$e=>{if(le.add($e.key.toLowerCase()),z($e.key)&&Pl(C,le)){q=!0,se!==null&&(clearTimeout(se),se=null),D(!1);return}ae()},Ne=$e=>{le.delete($e.key.toLowerCase()),ae()},we=()=>{le.clear(),q=!1,se!==null&&(clearTimeout(se),se=null),D(!1)};return window.addEventListener("keydown",ce,!0),window.addEventListener("keyup",Ne,!0),window.addEventListener("blur",we),()=>{window.removeEventListener("keydown",ce,!0),window.removeEventListener("keyup",Ne,!0),window.removeEventListener("blur",we),se!==null&&clearTimeout(se)}},A=[C],t[6]=C,t[7]=I,t[8]=A):(I=t[7],A=t[8]),c.useEffect(I,A);let P;t[9]===Symbol.for("react.memo_cache_sentinel")?(P={activationConstraint:{distance:8}},t[9]=P):P=t[9];let T;t[10]===Symbol.for("react.memo_cache_sentinel")?(T={activationConstraint:{delay:200,tolerance:6}},t[10]=T):T=t[10];const _=ti(Tn(ni,P),Tn(si,T)),L=Ea(),W=Dl($S),O=Dl(zS),$=l?.tabs??jS;let j;t[11]!==l?.activeTabId||t[12]!==$?(j=$.find(le=>le.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=$,t[13]=j):j=t[13];const E=j,K=l?.isOpen?E?.mode??null:null,ee=p?.files.length??0;let J;t[14]!==d||t[15]!==u||t[16]!==x||t[17]!==L||t[18]!==w||t[19]!==y||t[20]!==v||t[21]!==$?(J=zp({railOrder:u,hiddenSurfaces:d,planModeEnabled:y,isVSCode:Kn(),screenWidth:v,tabs:$,linearConnected:w,githubConnected:x,extras:L}),t[14]=d,t[15]=u,t[16]=x,t[17]=L,t[18]=w,t[19]=y,t[20]=v,t[21]=$,t[22]=J):J=t[22];const ne=J;let ue,X;t[23]!==K||t[24]!==g||t[25]!==i||t[26]!==S||t[27]!==w?(X=()=>{!i||!S||w||K!=="linear"||g(i)},ue=[K,g,i,S,w],t[23]=K,t[24]=g,t[25]=i,t[26]=S,t[27]=w,t[28]=ue,t[29]=X):(ue=t[28],X=t[29]),c.useEffect(X,ue);let te,fe;t[30]!==K||t[31]!==g||t[32]!==i||t[33]!==f||t[34]!==x?(te=()=>{!i||!f||x||K!=="pr"||g(i)},fe=[K,g,i,f,x],t[30]=K,t[31]=g,t[32]=i,t[33]=f,t[34]=x,t[35]=te,t[36]=fe):(te=t[35],fe=t[36]),c.useEffect(te,fe);const[je,ve]=c.useState(!1);let ye;t[37]!==L||t[38]!==h?(ye=le=>{const{active:se,over:q}=le;if(!q||se.id===q.id)return;const z=Cu(De.getState().contextRailOrder,L).map(WS),ae=z.indexOf(se.id),ce=z.indexOf(q.id);ae===-1||ce===-1||h(Uu(z,ae,ce))},t[37]=L,t[38]=h,t[39]=ye):ye=t[39];const Pe=ye;if(!i)return null;let xe;t[40]!==e?(xe=e("contextRail.aria.rail"),t[40]=e,t[41]=xe):xe=t[41];let R;t[42]!==ne?(R=ne.map(KS),t[42]=ne,t[43]=R):R=t[43];let Y;if(t[44]!==K||t[45]!==ee||t[46]!==O||t[47]!==i||t[48]!==W||t[49]!==m||t[50]!==k||t[51]!==ne||t[52]!==e||t[53]!==a){let le;t[55]!==K||t[56]!==ee||t[57]!==O||t[58]!==i||t[59]!==W||t[60]!==m||t[61]!==k||t[62]!==e||t[63]!==a?(le=(se,q)=>{const z=se.label??e(se.labelKey),ae=se.id==="git"&&!a?ee:0,ce=tr(se.mode)&&K!==se.mode?W[Ei(se.mode)]??0:0,Ne=ae>0?ae:ce>0?ce:null,we=Ne!==null&&ae===0;return s.jsx(CS,{surface:se,isActive:K===se.mode,showActivityDot:!1,label:z,description:e(se.descriptionKey),badgeCount:Ne,badgeAriaLabel:Ne!==null?e(we?Ne===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":Ne===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:z,count:Ne}):null,badgeDescription:Ne!==null?e(we?Ne===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":Ne===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:Ne}):null,orderNumber:q+1,showOrderNumber:k,onSelect:$e=>{tr($e.mode)&&O(Ei($e.mode)),m(i,$e.mode)}},se.id)},t[55]=K,t[56]=ee,t[57]=O,t[58]=i,t[59]=W,t[60]=m,t[61]=k,t[62]=e,t[63]=a,t[64]=le):le=t[64],Y=ne.map(le),t[44]=K,t[45]=ee,t[46]=O,t[47]=i,t[48]=W,t[49]=m,t[50]=k,t[51]=ne,t[52]=e,t[53]=a,t[54]=Y}else Y=t[54];let ie;t[65]!==R||t[66]!==Y?(ie=s.jsx(Va,{items:R,strategy:Hu,children:Y}),t[65]=R,t[66]=Y,t[67]=ie):ie=t[67];let H;t[68]!==Pe||t[69]!==_||t[70]!==ie?(H=s.jsx(ri,{sensors:_,collisionDetection:oi,onDragEnd:Pe,children:ie}),t[68]=Pe,t[69]=_,t[70]=ie,t[71]=H):H=t[71];let me;t[72]!==e?(me=e("contextRail.configure.open"),t[72]=e,t[73]=me):me=t[73];let pe;t[74]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>ve(!0),t[74]=pe):pe=t[74];let re;t[75]===Symbol.for("react.memo_cache_sentinel")?(re=s.jsx(M,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=re):re=t[75];let de;t[76]!==me?(de=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":me,onClick:pe,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:re})}),t[76]=me,t[77]=de):de=t[77];let B;t[78]!==e?(B=e("contextRail.configure.open"),t[78]=e,t[79]=B):B=t[79];let F;t[80]!==B?(F=s.jsx(It,{side:"left",sideOffset:8,children:B}),t[80]=B,t[81]=F):F=t[81];let he;t[82]!==de||t[83]!==F?(he=s.jsxs(Dt,{delayDuration:_f,children:[de,F]}),t[82]=de,t[83]=F,t[84]=he):he=t[84];let Se;t[85]!==je?(Se=s.jsx(xS,{open:je,onOpenChange:ve}),t[85]=je,t[86]=Se):Se=t[86];let Re;return t[87]!==xe||t[88]!==H||t[89]!==he||t[90]!==Se?(Re=s.jsxs("nav",{"aria-label":xe,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[H,he,Se]}),t[87]=xe,t[88]=H,t[89]=he,t[90]=Se,t[91]=Re):Re=t[91],Re};function AS(t){return t.workStatusPanelVisible}function DS(t){return t.contextRailOrder}function PS(t){return t.contextRailHiddenSurfaces}function IS(t){return t.setContextRailOrder}function TS(t){return t.openContextSurface}function ES(t){return t.closeContextPanel}function RS(t){return t.shortcutOverrides}function MS(t){return t.planModeEnabled}function OS(t){return t.hasChecked}function BS(t){return t.status?.connected===!0}function FS(t){return t.hasChecked}function _S(t){return t.status?.connected===!0}function LS(t){return t.length===1&&t>="0"&&t<="9"}function $S(t){return t.countByGuest}function zS(t){return t.clearBadge}function WS(t){return t.id}function KS(t){return t.id}const VS=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),US=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Wr(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),HS=new Set,GS=[],ua=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},qS=()=>{const t=et.c(183),{t:e}=vt(),n=De(YS),r=De(QS),i=De(XS),o=De(JS),l=De(ZS),a=De(e0),u=De(t0),d=De(s0),h=De(n0),m=De(r0),g=De(o0),b=De(i0),y=De(a0),S=Ze(l0),w=Ze(c0),f=Ze(d0),x=Xr(u0);let v;t[0]!==n?(v=Ge=>n?Ge.activeSessions:GS,t[0]=n,t[1]=v):v=t[1];const p=_s(v);let N;t[2]!==n?(N=Ge=>n?Ge.ids:HS,t[2]=n,t[3]=N):N=t[3];const C=Xr(N);let k;t[4]!==n?(k=Ge=>n?Ge.rankById:Ma,t[4]=n,t[5]=k):k=t[5];const D=Ra(k),I=os(f0),A=Gt(m0),P=Gt(h0),T=lr(),_=_d(p0),{files:L,git:W}=Cn(),O=Mn(g0),{isMobile:$}=Vn();let j;t[6]!==T?(j=T?ua(T):null,t[6]=T,t[7]=j):j=t[7];const E=j,[K,ee]=c.useState(""),ne=vu(K,200).trim();let ue;t[8]!==K?(ue=K.trim(),t[8]=K,t[9]=ue):ue=t[9];const X=ue;let te,fe;t[10]!==n?(te=()=>{n&&ee("")},fe=[n],t[10]=n,t[11]=te,t[12]=fe):(te=t[11],fe=t[12]),c.useEffect(te,fe);let je,ve;t[13]!==p||t[14]!==O||t[15]!==W||t[16]!==n?(je=()=>{if(!n||!W)return;const Ge=setTimeout(()=>{const Le=new Set;for(const pt of p){const Be=Ps(pt);!Be||Le.has(Be)||(Le.add(Be),O(Be,W))}},0);return()=>clearTimeout(Ge)},ve=[n,p,W,O],t[13]=p,t[14]=O,t[15]=W,t[16]=n,t[17]=je,t[18]=ve):(je=t[17],ve=t[18]),c.useEffect(je,ve);let ye;t[19]!==r?(ye=()=>r(!1),t[19]=r,t[20]=ye):ye=t[20];const Pe=ye;let xe;t[21]!==Pe?(xe=Ge=>()=>{Pe(),Ge()},t[21]=Pe,t[22]=xe):xe=t[22];const R=xe;let Y;t[23]!==A?.id||t[24]!==A?.path||t[25]!==I||t[26]!==f||t[27]!==$||t[28]!==u||t[29]!==d||t[30]!==g||t[31]!==S||t[32]!==R||t[33]!==b||t[34]!==y||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==x||t[39]!==a?(Y=()=>{const Ge=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(M,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:R(()=>{l(!1),S()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(M,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:R(x0)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(M,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:R(b0)},{id:"toggle-sidebar",title:e($?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(M,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e($?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:R(()=>{if($){const{isSessionSwitcherOpen:Le}=De.getState();l(!Le)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(M,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:R(()=>{I&&d(I,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(M,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:R(()=>{I&&u(I)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(M,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:R(y0)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(M,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:R(w0)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(M,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:R(()=>i(!0))}];return Ge.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(M,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:R(()=>{f&&I&&x({directory:I,sessionId:f})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(M,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:R(()=>{f&&wn(f).then(Le=>{if(Le.ok){_e.success(e("sessions.sidebar.session.copyId.success"));return}_e.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(M,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:R(()=>{l(!1),g()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(M,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:R(()=>{l(!1),b(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(M,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:R(()=>{I&&(y("notes"),d(I,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(M,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:R(()=>{I&&(y("todos"),d(I,"notes"))})}),Ge.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(M,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:R(v0)}),Yr()&&Ge.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(M,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:R(()=>{zn("desktop_open_draft_mini_chat_window",{directory:ua(I||A?.path||""),projectId:A?.id??null}).catch(S0)})}),Ge},t[23]=A?.id,t[24]=A?.path,t[25]=I,t[26]=f,t[27]=$,t[28]=u,t[29]=d,t[30]=g,t[31]=S,t[32]=R,t[33]=b,t[34]=y,t[35]=l,t[36]=i,t[37]=e,t[38]=x,t[39]=a,t[40]=Y):Y=t[40],A?.id,A?.path;let ie;t[41]!==Y?(ie=Y(),t[41]=Y,t[42]=ie):ie=t[42];const H=ie,me=De(j0);let pe;t[43]===Symbol.for("react.memo_cache_sentinel")?(pe=vn(),t[43]=pe):pe=t[43];const re=pe;let de,B;t[44]===Symbol.for("react.memo_cache_sentinel")?(de=Kn(),B=!re&&ka(),t[44]=de,t[45]=B):(de=t[44],B=t[45]);let F;t[46]!==$||t[47]!==me?(F={isVSCode:de,isWeb:B,isDesktop:re,isMobile:$,routingAvailable:me},t[46]=$,t[47]=me,t[48]=F):F=t[48];const he=F;let Se;if(t[49]!==R||t[50]!==i||t[51]!==o||t[52]!==he){let Ge;t[54]!==he?(Ge=pt=>pt.isAvailable?pt.isAvailable(he):!0,t[54]=he,t[55]=Ge):Ge=t[55];let Le;t[56]!==R||t[57]!==i||t[58]!==o?(Le=pt=>{const Be=Th(pt.slug)??"settings-3",ze=(pt.keywords??[]).join(" ");return{id:`settings:${pt.slug}`,title:pt.title,icon:pt.slug==="mcp"?s.jsx(Hp,{className:"mr-2 h-4 w-4"}):s.jsx(M,{name:Be,className:"mr-2 h-4 w-4"}),searchText:`${pt.title} ${pt.group} ${ze}`,onSelect:R(()=>{o(pt.slug),i(!0)})}},t[56]=R,t[57]=i,t[58]=o,t[59]=Le):Le=t[59],Se=Ih.filter(k0).filter(Ge).map(Le),t[49]=R,t[50]=i,t[51]=o,t[52]=he,t[53]=Se}else Se=t[53];const Re=Se;let le;if(t[60]!==p||t[61]!==C||t[62]!==D){const Ge=p.filter(C0);le=Wp(Ge,C,D),t[60]=p,t[61]=C,t[62]=D,t[63]=le}else le=t[63];const se=le,q=Nu(),z=Ze(N0);let ae;t[64]!==q||t[65]!==z?(ae=(Ge,Le)=>{const pt=z.get(Ge);return pt?.branch?pt.branch.trim()||null:Le&&q.get(Le)?.trim()||null},t[64]=q,t[65]=z,t[66]=ae):ae=t[66];const ce=ae;let Ne;t[67]===Symbol.for("react.memo_cache_sentinel")?(Ne=[],t[67]=Ne):Ne=t[67];const[we,$e]=c.useState(Ne),[Oe,ge]=c.useState(""),He=VS(E,ne);let V;t[68]!==E||t[69]!==He||t[70]!==n||t[71]!==_||t[72]!==$e||t[73]!==ge||t[74]!==ne?(V=()=>{if(!n){$e([]),ge("");return}if(!He){$e([]),ge("");return}if(!E){$e([]),ge("");return}let Ge=!1;return _(E,ne,40,{type:"file"}).then(Le=>{Ge||($e(Le.map(A0)),ge(He))}).catch(()=>{Ge||($e([]),ge(He))}),()=>{Ge=!0}},t[68]=E,t[69]=He,t[70]=n,t[71]=_,t[72]=$e,t[73]=ge,t[74]=ne,t[75]=V):V=t[75];let Ae;t[76]!==E||t[77]!==He||t[78]!==n||t[79]!==_||t[80]!==ne?(Ae=[n,E,ne,He,_],t[76]=E,t[77]=He,t[78]=n,t[79]=_,t[80]=ne,t[81]=Ae):Ae=t[81],c.useEffect(V,Ae);const Ie=X.length>0;let Fe;e:{if(!Ie){let Le;t[82]!==H?(Le=H.filter(D0).map(P0),t[82]=H,t[83]=Le):Le=t[83],Fe=Le;break e}let Ge;t[84]!==H||t[85]!==X?(Ge=Wr(H,X,I0,{limit:7,noFuzzy:!0}),t[84]=H,t[85]=X,t[86]=Ge):Ge=t[86],Fe=Ge}const st=Fe;let lt;e:{if(!Ie){let Le;t[87]===Symbol.for("react.memo_cache_sentinel")?(Le=[],t[87]=Le):Le=t[87],lt=Le;break e}let Ge;t[88]!==X||t[89]!==Re?(Ge=Wr(Re,X,T0,{limit:7,noFuzzy:!0}),t[88]=X,t[89]=Re,t[90]=Ge):Ge=t[90],lt=Ge}const it=lt;let mt;e:{if(!Ie){let Le;t[91]!==se?(Le=se.slice(0,5).map(E0),t[91]=se,t[92]=Le):Le=t[92],mt=Le;break e}let Ge;t[93]!==X||t[94]!==se?(Ge=Wr(se,X,R0,{limit:7,threshold:.2}),t[93]=X,t[94]=se,t[95]=Ge):Ge=t[95],mt=Ge}const St=mt;let ht;e:{if(!n){let Le;t[96]===Symbol.for("react.memo_cache_sentinel")?(Le=[],t[96]=Le):Le=t[96],ht=Le;break e}let Ge;t[97]!==we||t[98]!==Oe||t[99]!==He||t[100]!==ne?(Ge=US(we,ne,He,Oe),t[97]=we,t[98]=Oe,t[99]=He,t[100]=ne,t[101]=Ge):Ge=t[101],ht=Ge}const Xe=ht,Ct=n&&He.length>0&&Oe!==He;let Mt;e:{if(!Ie){let Le;t[102]===Symbol.for("react.memo_cache_sentinel")?(Le=[],t[102]=Le):Le=t[102],Mt=Le;break e}let Ge;if(t[103]!==X||t[104]!==P){const Le=P.map(M0);Ge=Wr(Le,X,O0,{limit:7,threshold:.4}),t[103]=X,t[104]=P,t[105]=Ge}else Ge=t[105];Mt=Ge}const be=Mt;let Ue,ut,G,U,Z,ke,Te,We,Je,nt,rt,Ye,Nt,Ke;if(t[106]!==ce||t[107]!==Pe||t[108]!==E||t[109]!==L||t[110]!==Ie||t[111]!==n||t[112]!==h||t[113]!==S||t[114]!==K||t[115]!==st||t[116]!==Xe||t[117]!==be||t[118]!==St||t[119]!==it||t[120]!==r||t[121]!==w||t[122]!==m||t[123]!==e){const Ge=st.map(B0),Le=it.map(F0),pt=St.map(_0),Be=Ie?Xe.map(L0):[],ze=Ie?be.map($0):[];let qe;e:{if(!Ie){qe=["commands","sessions"];break e}const Et=z0,wt=[{key:"commands",score:Et(st)},{key:"settings",score:Et(it)},{key:"sessions",score:Et(St)},{key:"files",score:Et(Xe)},{key:"projects",score:Et(be)}];wt.sort(W0),qe=wt.map(K0)}const tt=qe,yt=Et=>{Pe(),w(Et.id,Ps(Et))},Ot=async Et=>{if(!E)return;const wt=await gf(L,Et,{directory:E});if(!wt.ok){_e.error(xf(wt.reason));return}h(E,Et),Pe()},Ht=(Et,wt)=>{Pe(),S({selectedProjectId:Et,directoryOverride:wt})},_t=Et=>sr(so(Et,m));U=vs,Ye=n,Nt=r;let zt;t[138]!==e?(zt=e("commandPalette.title"),t[138]=e,t[139]=zt):zt=t[139];let Wt;t[140]!==zt?(Wt=s.jsx(Is,{children:zt}),t[140]=zt,t[141]=Wt):Wt=t[141];let Jt;t[142]!==e?(Jt=e("commandPalette.description"),t[142]=e,t[143]=Jt):Jt=t[143];let es;t[144]!==Jt?(es=s.jsx(Ts,{children:Jt}),t[144]=Jt,t[145]=es):es=t[145],t[146]!==Wt||t[147]!==es?(Ke=s.jsxs(Ws,{className:"sr-only",children:[Wt,es]}),t[146]=Wt,t[147]=es,t[148]=Ke):Ke=t[148],G=Ss,nt="overflow-hidden p-0",rt=!0,ut=Gp,Te=!1,We="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta";let Qt;t[149]!==e?(Qt=e("commandPalette.input.placeholder"),t[149]=e,t[150]=Qt):Qt=t[150],t[151]!==K||t[152]!==Qt?(Je=s.jsx(qp,{value:K,onValueChange:ee,placeholder:Qt}),t[151]=K,t[152]=Qt,t[153]=Je):Je=t[153],Ue=Yp;let qt;t[154]!==e?(qt=e("commandPalette.empty.noResults"),t[154]=e,t[155]=qt):qt=t[155],t[156]!==qt?(Z=s.jsx(Qp,{children:qt}),t[156]=qt,t[157]=Z):Z=t[157],ke=tt.map(Et=>Et==="commands"&&Ge.length>0?s.jsx(Tr,{children:Ge.map(wt=>s.jsxs(Kr,{value:wt.id,onSelect:wt.onSelect,children:[wt.icon,s.jsx("span",{children:wt.title}),wt.shortcutId?s.jsx(Kp,{children:_t(wt.shortcutId)}):null]},wt.id))},"commands"):Et==="settings"&&Le.length>0?s.jsx(Tr,{children:Le.map(V0)},"settings"):Et==="sessions"&&pt.length>0?s.jsx(Tr,{children:pt.map(wt=>{const cs=wt.title||e("commandPalette.session.untitled"),xs=Ps(wt),ds=ce(wt.id,xs);return s.jsxs(Kr,{value:`session:${wt.id}`,onSelect:()=>yt(wt),children:[s.jsx(M,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:cs}),ds?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(M,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:ds})]}):null]},wt.id)})},"sessions"):Et==="files"&&Be.length>0?s.jsx(Tr,{children:Be.map(wt=>{const cs=Vp(wt.relativePath||wt.name,{maxLength:80});return s.jsxs(Kr,{value:`file:${wt.path}`,onSelect:()=>{Ot(wt.path)},children:[s.jsx(Ta,{filePath:wt.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":wt.relativePath,children:cs})]},`file:${wt.path}`)})},"files"):Et==="projects"&&ze.length>0?s.jsx(Tr,{children:ze.map(wt=>{const cs=wt.displayName;return s.jsxs(Kr,{value:`project:${wt.id}`,onSelect:()=>Ht(wt.id,wt.path),children:[s.jsx(M,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:cs}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:wt.path})]},`project:${wt.id}`)})},"projects"):null),t[106]=ce,t[107]=Pe,t[108]=E,t[109]=L,t[110]=Ie,t[111]=n,t[112]=h,t[113]=S,t[114]=K,t[115]=st,t[116]=Xe,t[117]=be,t[118]=St,t[119]=it,t[120]=r,t[121]=w,t[122]=m,t[123]=e,t[124]=Ue,t[125]=ut,t[126]=G,t[127]=U,t[128]=Z,t[129]=ke,t[130]=Te,t[131]=We,t[132]=Je,t[133]=nt,t[134]=rt,t[135]=Ye,t[136]=Nt,t[137]=Ke}else Ue=t[124],ut=t[125],G=t[126],U=t[127],Z=t[128],ke=t[129],Te=t[130],We=t[131],Je=t[132],nt=t[133],rt=t[134],Ye=t[135],Nt=t[136],Ke=t[137];let Tt;t[158]!==Ct||t[159]!==e?(Tt=Ct?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[158]=Ct,t[159]=e,t[160]=Tt):Tt=t[160];let Ce;t[161]!==Ue||t[162]!==Z||t[163]!==ke||t[164]!==Tt?(Ce=s.jsxs(Ue,{children:[Z,ke,Tt]}),t[161]=Ue,t[162]=Z,t[163]=ke,t[164]=Tt,t[165]=Ce):Ce=t[165];let ft;t[166]!==ut||t[167]!==Te||t[168]!==We||t[169]!==Je||t[170]!==Ce?(ft=s.jsxs(ut,{shouldFilter:Te,className:We,children:[Je,Ce]}),t[166]=ut,t[167]=Te,t[168]=We,t[169]=Je,t[170]=Ce,t[171]=ft):ft=t[171];let bt;t[172]!==G||t[173]!==nt||t[174]!==rt||t[175]!==ft?(bt=s.jsx(G,{className:nt,showCloseButton:rt,children:ft}),t[172]=G,t[173]=nt,t[174]=rt,t[175]=ft,t[176]=bt):bt=t[176];let jt;return t[177]!==U||t[178]!==Ye||t[179]!==Nt||t[180]!==Ke||t[181]!==bt?(jt=s.jsxs(U,{open:Ye,onOpenChange:Nt,children:[Ke,bt]}),t[177]=U,t[178]=Ye,t[179]=Nt,t[180]=Ke,t[181]=bt,t[182]=jt):jt=t[182],jt};function YS(t){return t.isCommandPaletteOpen}function QS(t){return t.setCommandPaletteOpen}function XS(t){return t.setSettingsDialogOpen}function JS(t){return t.setSettingsPage}function ZS(t){return t.setSessionSwitcherOpen}function e0(t){return t.toggleSidebar}function t0(t){return t.openContextOverview}function s0(t){return t.openContextSurface}function n0(t){return t.openContextFile}function r0(t){return t.shortcutOverrides}function o0(t){return t.openMultiRunLauncher}function i0(t){return t.setArchivePageOpen}function a0(t){return t.setProjectContextTab}function l0(t){return t.openNewSessionDraft}function c0(t){return t.setCurrentSession}function d0(t){return t.currentSessionId}function u0(t){return t.toggle}function f0(t){return t.currentDirectory}function m0(t){return t.getActiveProject()}function h0(t){return t.projects}function p0(t){return t.searchFiles}function g0(t){return t.ensureStatus}function x0(){Au()}function b0(){hn.requestDirectoryDialog()}function y0(){Xp.invoke("cycle_theme")}function w0(){Du()}function v0(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function S0(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function j0(t){return t.routingFeatureAvailable}function k0(t){return t.slug!=="home"}function C0(t){return!Up(t)}function N0(t){return t.worktreeMetadata}function A0(t){return{path:ua(t.path),name:t.name,relativePath:t.relativePath}}function D0(t){return!t.secondary}function P0(t){return{item:t,score:0}}function I0(t){return t.searchText}function T0(t){return t.searchText}function E0(t){return{item:t,score:0}}function R0(t){return t.title||""}function M0(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function O0(t){return t.searchText}function B0(t){return t.item}function F0(t){return t.item}function _0(t){return t.item}function L0(t){return t.item}function $0(t){return t.item}function z0(t){return t.length?t[0].score:1/0}function W0(t,e){return t.score-e.score}function K0(t){return t.key}function V0(t){return s.jsxs(Kr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const Ec=(t,e,n)=>sr(so(t,e),n),U0=()=>{const t=et.c(74),{t:e}=vt(),n=De(H0),r=De(G0),i=De(q0);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=Kn(),t[0]=o):o=t[0];const l=o;let a,u,d,h,m,g,b,y,S,w,f,x;if(t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==e){const j=[{categoryKey:"helpDialog.section.navigationCommands",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[sr("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${sr(Ki("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${sr(Ki("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];d=vs,f=n,x=r,u=Ss,S="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let E;t[17]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(M,{name:"command",className:"h-5 w-5"}),t[17]=E):E=t[17];let K;t[18]!==e?(K=e("helpDialog.title"),t[18]=e,t[19]=K):K=t[19];let ee;t[20]!==K?(ee=s.jsxs(Is,{className:"flex items-center gap-2",children:[E,K]}),t[20]=K,t[21]=ee):ee=t[21];let J;t[22]!==e?(J=e("helpDialog.description"),t[22]=e,t[23]=J):J=t[23];let ne;t[24]!==J?(ne=s.jsx(Ts,{children:J}),t[24]=J,t[25]=ne):ne=t[25],t[26]!==ee||t[27]!==ne?(w=s.jsxs(Ws,{children:[ee,ne]}),t[26]=ee,t[27]=ne,t[28]=w):w=t[28],a=jn,g="flex-1 min-h-0 mt-3",b="pr-1",y=!0,h="space-y-4",m=j.map(ue=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(ue.categoryKey)}),s.jsx("div",{className:"space-y-1",children:ue.items.filter(X=>!(l&&X.id==="toggle_prompt_navigator")).map(X=>{const te=X.id?Jp(X.id):void 0,fe=X.descriptionKey??(te?.customizable?te.settingsLabelKey:void 0);if(!fe||X.id&&!so(X.id,i))return null;const je=X.id?Ec(X.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(X.keys)?X.keys:X.keys.split(" / ");return s.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[X.icon&&s.jsx(M,{name:X.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(fe)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(je)?je:[je]).map((ve,ye)=>s.jsxs(c.Fragment,{children:[ye>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:ve})]},`${ve}-${ye}`))})]},X.id||fe)})})]},ue.categoryKey)),t[1]=n,t[2]=r,t[3]=i,t[4]=e,t[5]=a,t[6]=u,t[7]=d,t[8]=h,t[9]=m,t[10]=g,t[11]=b,t[12]=y,t[13]=S,t[14]=w,t[15]=f,t[16]=x}else a=t[5],u=t[6],d=t[7],h=t[8],m=t[9],g=t[10],b=t[11],y=t[12],S=t[13],w=t[14],f=t[15],x=t[16];let v;t[29]!==h||t[30]!==m?(v=s.jsx("div",{className:h,children:m}),t[29]=h,t[30]=m,t[31]=v):v=t[31];let p;t[32]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(M,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[32]=p):p=t[32];let N;t[33]!==e?(N=e("helpDialog.proTips.title"),t[33]=e,t[34]=N):N=t[34];let C;t[35]!==N?(C=s.jsx("p",{className:"font-medium mb-1",children:N}),t[35]=N,t[36]=C):C=t[36];let k;t[37]!==i||t[38]!==e?(k=e("helpDialog.proTips.commandPalette",{shortcut:Ec("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))}),t[37]=i,t[38]=e,t[39]=k):k=t[39];let D;t[40]!==k?(D=s.jsxs("li",{children:["• ",k]}),t[40]=k,t[41]=D):D=t[41];let I;t[42]!==e?(I=e("helpDialog.proTips.recentSessions"),t[42]=e,t[43]=I):I=t[43];let A;t[44]!==I?(A=s.jsxs("li",{children:["• ",I]}),t[44]=I,t[45]=A):A=t[45];let P;t[46]!==e?(P=e("helpDialog.proTips.leaderSequences"),t[46]=e,t[47]=P):P=t[47];let T;t[48]!==P?(T=s.jsxs("li",{children:["• ",P]}),t[48]=P,t[49]=T):T=t[49];let _;t[50]!==D||t[51]!==A||t[52]!==T?(_=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[D,A,T]}),t[50]=D,t[51]=A,t[52]=T,t[53]=_):_=t[53];let L;t[54]!==C||t[55]!==_?(L=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[p,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[C,_]})]})}),t[54]=C,t[55]=_,t[56]=L):L=t[56];let W;t[57]!==a||t[58]!==v||t[59]!==L||t[60]!==g||t[61]!==b||t[62]!==y?(W=s.jsxs(a,{outerClassName:g,className:b,disableHorizontal:y,children:[v,L]}),t[57]=a,t[58]=v,t[59]=L,t[60]=g,t[61]=b,t[62]=y,t[63]=W):W=t[63];let O;t[64]!==u||t[65]!==W||t[66]!==S||t[67]!==w?(O=s.jsxs(u,{className:S,children:[w,W]}),t[64]=u,t[65]=W,t[66]=S,t[67]=w,t[68]=O):O=t[68];let $;return t[69]!==d||t[70]!==O||t[71]!==f||t[72]!==x?($=s.jsx(d,{open:f,onOpenChange:x,children:O}),t[69]=d,t[70]=O,t[71]=f,t[72]=x,t[73]=$):$=t[73],$};function H0(t){return t.isHelpDialogOpen}function G0(t){return t.setHelpDialogOpen}function q0(t){return t.shortcutOverrides}const Y0=()=>{const t=et.c(32),{t:e}=vt(),n=De(Q0),r=De(X0),i=De(J0);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await wn(i)).ok){_e.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}_e.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let u;t[5]!==a?(u=s.jsx(Is,{children:a}),t[5]=a,t[6]=u):u=t[6];let d;t[7]!==e?(d=e("openCodeStatusDialog.description"),t[7]=e,t[8]=d):d=t[8];let h;t[9]!==d?(h=s.jsx(Ts,{children:d}),t[9]=d,t[10]=h):h=t[10];let m;t[11]!==u||t[12]!==h?(m=s.jsxs(Ws,{children:[u,h]}),t[11]=u,t[12]=h,t[13]=m):m=t[13];let g;t[14]!==e?(g=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=g):g=t[15];let b;t[16]!==l||t[17]!==g?(b=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:g})}),t[16]=l,t[17]=g,t[18]=b):b=t[18];let y;t[19]!==i||t[20]!==e?(y=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=y):y=t[21];let S;t[22]!==y?(S=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:y}),t[22]=y,t[23]=S):S=t[23];let w;t[24]!==m||t[25]!==b||t[26]!==S?(w=s.jsxs(Ss,{className:"max-w-2xl",children:[m,b,S]}),t[24]=m,t[25]=b,t[26]=S,t[27]=w):w=t[27];let f;return t[28]!==n||t[29]!==r||t[30]!==w?(f=s.jsx(vs,{open:n,onOpenChange:r,children:w}),t[28]=n,t[29]=r,t[30]=w,t[31]=f):f=t[31],f};function Q0(t){return t.isOpenCodeStatusDialogOpen}function X0(t){return t.setOpenCodeStatusDialogOpen}function J0(t){return t.openCodeStatusText}const Z0=t=>{const e=et.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let u,d;e[0]!==a||e[1]!==r||e[2]!==o?(u=()=>{if(!a||!r||typeof window>"u")return;const y=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(y)},d=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=u,e[4]=d):(u=e[3],d=e[4]),c.useEffect(u,d);let h,m;e[5]!==a||e[6]!==o||e[7]!==i?(h=()=>{if(!a||typeof window>"u")return;const y=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",y),()=>window.removeEventListener("openchamber:sidebar-session-search",y)},m=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=h,e[9]=m):(h=e[8],m=e[9]),c.useEffect(h,m);let g,b;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(g=()=>{if(!a||!r||typeof document>"u")return;const y=S=>{l.current&&(l.current.contains(S.target)||i(!1))};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},b=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=g,e[15]=b):(g=e[14],b=e[15]),c.useEffect(g,b)},ej=t=>{const e=et.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const u=new Map(l.map(tj)),d=[];a.forEach(g=>{const b=u.get(g);b&&(d.push(b),u.delete(g))});const h=[],m=[];return l.forEach(g=>{u.has(g.id)&&(g.isArchivedBucket?m.push(g):h.push(g))}),[...h,...d,...m]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function tj(t){return[t.id,t]}const go="oc.sessions.projectCollapse",Rc="oc.sessions.groupOrder",Mc="oc.sessions.groupCollapse",Oc=t=>{if(!t)return new Set;try{const e=Ua(Nr()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},sj=t=>{if(!t)return new Map;try{const e=Zu(Nr(),Ua(Nr())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,i]of Object.entries(e.data))n.set(r,i);return n}catch{return new Map}},nj=t=>{const e=et.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Eo(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>Oc(o.getItem(go)),e[1]=l):l=e[1];const[a,u]=c.useState(l);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>Oc(o.getItem(Mc)),e[2]=d):d=e[2];const[h,m]=c.useState(d);let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=()=>sj(o.getItem(Rc)),e[3]=g):g=e[3];const[b,y]=c.useState(g),S=c.useRef(0),w=c.useRef(!1),f=c.useRef(!1),x=c.useRef(null),v=c.useRef(null);let p;e[4]!==n?(p=()=>{if(n)return;const ye=v.current;if(v.current=null,x.current=null,!ye)return;const{projects:Pe}=Gt.getState(),xe=Pe.map(R=>({...R,sidebarCollapsed:ye.has(R.id)}));$r({projects:xe}).catch(rj)},e[4]=n,e[5]=p):p=e[5];const N=p;let C;e[6]!==N||e[7]!==n?(C=ye=>{!globalThis.window||n||(v.current=ye,x.current!==null&&window.clearTimeout(x.current),x.current=window.setTimeout(()=>{N()},700))},e[6]=N,e[7]=n,e[8]=C):C=e[8];const k=C;let D,I;e[9]===Symbol.for("react.memo_cache_sentinel")?(D=()=>()=>{globalThis.window&&x.current!==null&&window.clearTimeout(x.current),x.current=null,v.current=null},I=[],e[9]=D,e[10]=I):(D=e[9],I=e[10]),c.useEffect(D,I);let A,P;e[11]!==b?(P=()=>{if(f.current)try{o.setItem(Rc,JSON.stringify(Object.fromEntries(b.entries())))}catch{}},A=[b,o],e[11]=b,e[12]=A,e[13]=P):(A=e[12],P=e[13]),c.useEffect(P,A);let T,_;e[14]!==h?(T=()=>{if(w.current)try{o.setItem(Mc,JSON.stringify(Array.from(h)))}catch{}},_=[h,o],e[14]=h,e[15]=T,e[16]=_):(T=e[15],_=e[16]),c.useEffect(T,_);let L;e[17]!==r||e[18]!==k?(L=()=>{S.current=Date.now()+150,w.current=!0,m(new Set),u(()=>{const ye=new Set(r.map(oj));try{o.setItem(go,JSON.stringify(Array.from(ye)))}catch{}return k(ye),ye})},e[17]=r,e[18]=k,e[19]=L):L=e[19];const W=L;let O;e[20]!==k?(O=()=>{S.current=Date.now()+150,w.current=!0,m(new Set),u(()=>{const ye=new Set;try{o.setItem(go,JSON.stringify([]))}catch{}return k(ye),ye})},e[20]=k,e[21]=O):O=e[21];const $=O;let j;e[22]!==k?(j=ye=>{S.current=Date.now()+150,u(Pe=>{const xe=new Set(Pe);xe.has(ye)?xe.delete(ye):xe.add(ye);try{o.setItem(go,JSON.stringify(Array.from(xe)))}catch{}return k(xe),xe})},e[22]=k,e[23]=j):j=e[23];const E=j;let K;e[24]===Symbol.for("react.memo_cache_sentinel")?(K=ye=>{w.current=!0,m(Pe=>{const xe=new Set(Pe);return xe.has(ye)?xe.delete(ye):xe.add(ye),xe})},e[24]=K):K=e[24];const ee=K;let J;e[25]===Symbol.for("react.memo_cache_sentinel")?(J=ye=>{f.current=!0,y(ye)},e[25]=J):J=e[25];const ne=J,{getOrderedGroups:ue}=ej(b);let X;e[26]!==h||e[27]!==a||e[28]!==b?(X={collapsedProjects:a,collapsedGroups:h,groupOrderByProject:b},e[26]=h,e[27]=a,e[28]=b,e[29]=X):X=e[29];const te=X;let fe;e[30]!==W||e[31]!==$||e[32]!==ue||e[33]!==k||e[34]!==E?(fe={setCollapsedProjects:u,toggleProject:E,collapseAllProjects:W,expandAllProjects:$,scheduleCollapsedProjectsPersist:k,setCollapsedGroups:m,toggleGroup:ee,setGroupOrderByProject:ne,getOrderedGroups:ue},e[30]=W,e[31]=$,e[32]=ue,e[33]=k,e[34]=E,e[35]=fe):fe=e[35];const je=fe;let ve;return e[36]!==je||e[37]!==te?(ve={state:te,actions:je},e[36]=je,e[37]=te,e[38]=ve):ve=e[38],ve};function rj(){}function oj(t){return t.id}const ij=5*6e4,aj=t=>{const e=et.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:u}=Cn(),d=Mn(lj);let h,m;e[0]!==a||e[1]!==d||e[2]!==u||e[3]!==n||e[4]!==o?(h=()=>{if(!a||!u||n.length===0){o(new Map);return}n.forEach(C=>{Vi(()=>d(C.normalizedPath,u))})},m=[a,n,u,d,o],e[0]=a,e[1]=d,e[2]=u,e[3]=n,e[4]=o,e[5]=h,e[6]=m):(h=e[5],m=e[6]),c.useEffect(h,m);let g,b;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(g=()=>{if(!a)return;const C=new Map;n.forEach(k=>{C.set(k.id,i.get(k.normalizedPath)?.isGitRepo??null)}),o(C)},b=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=g,e[12]=b):(g=e[11],b=e[12]),c.useEffect(g,b);let y;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=k=>{const D=i.get(k.normalizedPath)?.branch??"";return`${k.id}:${D}`},e[16]=i,e[17]=C):C=e[17],y=n.map(C).join("|"),e[13]=i,e[14]=n,e[15]=y}else y=e[15];const S=y;let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w=new Map,e[18]=w):w=e[18];const f=c.useRef(w);let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=new Map,e[19]=x):x=e[19];const v=c.useRef(x);let p;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(p=()=>{if(!a)return;let C=!1;const k=setTimeout(()=>{(async()=>{const I=new Set(n.map(cj));for(const W of f.current.keys())I.has(W)||(f.current.delete(W),v.current.delete(W));const A=Date.now(),P=n.filter(W=>{const O=i.get(W.normalizedPath);if(O?.isGitRepo===!1)return f.current.delete(W.id),v.current.delete(W.id),!1;if(O?.isGitRepo!==!0||O.branch===null)return!1;const $=O.branch.trim(),j=`${W.normalizedPath}\0${$}`,E=f.current.get(W.id);if(E===j){const K=v.current.get(W.id);return K&&(K.at=A),!1}return!(E!==void 0&&A-(v.current.get(W.id)?.at??0)<ij)});if(P.length===0)return;const T=await Zp(P,2,async W=>{const O=i.get(W.normalizedPath)?.branch?.trim()??"",$=`${W.normalizedPath}\0${O}`,j=await Vi(()=>Zo(W.normalizedPath,O?{knownBranch:O}:void 0)).catch(dj);return{id:W.id,inputKey:$,branch:j}});if(C)return;const _=T.filter(uj);if(_.length===0)return;const L=Date.now();l(W=>{const O=new Map(W);return _.forEach($=>{const{id:j,branch:E}=$;E&&O.set(j,E)}),O}),_.forEach(W=>{const{id:O,inputKey:$,branch:j}=W;f.current.set(O,$),j&&v.current.set(O,{branch:j,at:L})})})()},150);return()=>{C=!0,clearTimeout(k)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=p):p=e[24];let N;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==S||e[29]!==l?(N=[a,n,S,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=S,e[29]=l,e[30]=N):N=e[30],c.useEffect(p,N)};function lj(t){return t.ensureStatus}function cj(t){return t.id}function dj(){return null}function uj(t){return t.branch}const fj=t=>{const e=et.c(10),{open:n,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==n||e[2]!==i?(l=n&&i?s.jsx(Eh,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=s.jsx(Ss,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(jn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let u;return e[6]!==r||e[7]!==n||e[8]!==a?(u=s.jsx(vs,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=u):u=e[9],u};function mj(t){const e=et.c(218),{t:n}=vt(),r=Pu(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:u,onOpenMultiRun:d,canOpenMultiRun:h,onOpenArchive:m,headerActionIconClass:g,headerActionButtonClass:b,isSessionSearchOpen:y,setIsSessionSearchOpen:S,sessionSearchInputRef:w,sessionSearchQuery:f,setSessionSearchQuery:x,hasSessionSearchQuery:v,searchMatchCount:p,collapseAllProjects:N,expandAllProjects:C}=t,k=ps(Aj),D=ps(Nj),I=hs(Cj),A=hs(kj),P=hs(jj),T=hs(Sj),_=hs(vj),L=hs(wj),W=hs(yj),O=hs(bj),$=hs(xj),j=hs(gj),E=o&&$==="single";if(i)return null;let K;e[0]!==b?(K=Me(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=b,e[1]=K):K=e[1];let ee;e[2]!==n?(ee=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=ee):ee=e[3];let J;e[4]!==g?(J=s.jsx(M,{name:"folder-add",className:g}),e[4]=g,e[5]=J):J=e[5];let ne;e[6]!==a||e[7]!==K||e[8]!==ee||e[9]!==J?(ne=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:K,"aria-label":ee,children:J})}),e[6]=a,e[7]=K,e[8]=ee,e[9]=J,e[10]=ne):ne=e[10];let ue;e[11]!==n?(ue=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=ue):ue=e[12];let X;e[13]!==ue?(X=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ue})}),e[13]=ue,e[14]=X):X=e[14];let te;e[15]!==ne||e[16]!==X?(te=s.jsxs(Dt,{children:[ne,X]}),e[15]=ne,e[16]=X,e[17]=te):te=e[17];let fe;e[18]!==b?(fe=Me(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=b,e[19]=fe):fe=e[19];let je;e[20]!==n?(je=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=je):je=e[21];let ve;e[22]!==g?(ve=s.jsx(M,{name:"calendar-schedule",className:g}),e[22]=g,e[23]=ve):ve=e[23];let ye;e[24]!==u||e[25]!==fe||e[26]!==je||e[27]!==ve?(ye=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:fe,"aria-label":je,children:ve})}),e[24]=u,e[25]=fe,e[26]=je,e[27]=ve,e[28]=ye):ye=e[28];let Pe;e[29]!==n?(Pe=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=Pe):Pe=e[30];let xe;e[31]!==Pe?(xe=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Pe})}),e[31]=Pe,e[32]=xe):xe=e[32];let R;e[33]!==ye||e[34]!==xe?(R=s.jsxs(Dt,{children:[ye,xe]}),e[33]=ye,e[34]=xe,e[35]=R):R=e[35];let Y;e[36]!==b?(Y=Me(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=b,e[37]=Y):Y=e[37];let ie;e[38]!==n?(ie=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=ie):ie=e[39];const H=!h;let me;e[40]!==g?(me=s.jsx(sg,{className:g}),e[40]=g,e[41]=me):me=e[41];let pe;e[42]!==d||e[43]!==Y||e[44]!==ie||e[45]!==H||e[46]!==me?(pe=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:Y,"aria-label":ie,disabled:H,children:me})}),e[42]=d,e[43]=Y,e[44]=ie,e[45]=H,e[46]=me,e[47]=pe):pe=e[47];let re;e[48]!==n?(re=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=re):re=e[49];let de;e[50]!==re?(de=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:re})}),e[50]=re,e[51]=de):de=e[51];let B;e[52]!==pe||e[53]!==de?(B=s.jsxs(Dt,{children:[pe,de]}),e[52]=pe,e[53]=de,e[54]=B):B=e[54];let F;e[55]!==b?(F=Me(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=b,e[56]=F):F=e[56];let he;e[57]!==n?(he=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=he):he=e[58];let Se;e[59]!==g?(Se=s.jsx(M,{name:"archive",className:g}),e[59]=g,e[60]=Se):Se=e[60];let Re;e[61]!==m||e[62]!==F||e[63]!==he||e[64]!==Se?(Re=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,className:F,"aria-label":he,children:Se})}),e[61]=m,e[62]=F,e[63]=he,e[64]=Se,e[65]=Re):Re=e[65];let le;e[66]!==n?(le=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=le):le=e[67];let se;e[68]!==le?(se=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:le})}),e[68]=le,e[69]=se):se=e[69];let q;e[70]!==Re||e[71]!==se?(q=s.jsxs(Dt,{children:[Re,se]}),e[70]=Re,e[71]=se,e[72]=q):q=e[72];let z;e[73]!==r||e[74]!==g||e[75]!==n?(z=r.length>0&&s.jsxs(zs,{children:[s.jsx(Ls,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(M,{name:"apps",className:g})})}),s.jsxs($s,{align:"start",children:[s.jsx(zr,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(pj)]})]}),e[73]=r,e[74]=g,e[75]=n,e[76]=z):z=e[76];let ae;e[77]!==R||e[78]!==B||e[79]!==q||e[80]!==z||e[81]!==te?(ae=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[te,R,B,q,z]}),e[77]=R,e[78]=B,e[79]=q,e[80]=z,e[81]=te,e[82]=ae):ae=e[82];let ce;e[83]!==S?(ce=()=>S(hj),e[83]=S,e[84]=ce):ce=e[84];let Ne;e[85]!==b?(Ne=Me(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[85]=b,e[86]=Ne):Ne=e[86];let we;e[87]!==n?(we=n("sessions.sidebar.header.actions.searchSessions"),e[87]=n,e[88]=we):we=e[88];let $e;e[89]!==g?($e=s.jsx(M,{name:"search",className:g}),e[89]=g,e[90]=$e):$e=e[90];let Oe;e[91]!==y||e[92]!==ce||e[93]!==Ne||e[94]!==we||e[95]!==$e?(Oe=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ce,className:Ne,"aria-label":we,"aria-expanded":y,children:$e})}),e[91]=y,e[92]=ce,e[93]=Ne,e[94]=we,e[95]=$e,e[96]=Oe):Oe=e[96];let ge;e[97]!==n?(ge=n("sessions.sidebar.header.actions.searchSessions"),e[97]=n,e[98]=ge):ge=e[98];let He;e[99]!==ge?(He=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ge})}),e[99]=ge,e[100]=He):He=e[100];let V;e[101]!==Oe||e[102]!==He?(V=s.jsxs(Dt,{children:[Oe,He]}),e[101]=Oe,e[102]=He,e[103]=V):V=e[103];const Ae=k&&"bg-interactive-hover text-primary";let Ie;e[104]!==b||e[105]!==Ae?(Ie=Me(b,"text-muted-foreground hover:text-foreground hover:bg-transparent",Ae),e[104]=b,e[105]=Ae,e[106]=Ie):Ie=e[106];let Fe;e[107]!==k||e[108]!==n?(Fe=n(k?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[107]=k,e[108]=n,e[109]=Fe):Fe=e[109];let st;e[110]!==g?(st=s.jsx(M,{name:"checkbox-multiple",className:g}),e[110]=g,e[111]=st):st=e[111];let lt;e[112]!==k||e[113]!==Ie||e[114]!==Fe||e[115]!==st||e[116]!==D?(lt=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:D,className:Ie,"aria-label":Fe,"aria-pressed":k,children:st})}),e[112]=k,e[113]=Ie,e[114]=Fe,e[115]=st,e[116]=D,e[117]=lt):lt=e[117];let it;e[118]!==k||e[119]!==n?(it=n(k?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[118]=k,e[119]=n,e[120]=it):it=e[120];let mt;e[121]!==it?(mt=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:it})}),e[121]=it,e[122]=mt):mt=e[122];let St;e[123]!==lt||e[124]!==mt?(St=s.jsxs(Dt,{children:[lt,mt]}),e[123]=lt,e[124]=mt,e[125]=St):St=e[125];let ht;e[126]!==b?(ht=Me(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[126]=b,e[127]=ht):ht=e[127];let Xe;e[128]!==n?(Xe=n("sessions.sidebar.header.displayMode.label"),e[128]=n,e[129]=Xe):Xe=e[129];let Ct;e[130]!==g?(Ct=s.jsx(M,{name:"equalizer-2",className:g}),e[130]=g,e[131]=Ct):Ct=e[131];let Mt;e[132]!==ht||e[133]!==Xe||e[134]!==Ct?(Mt=s.jsx(Pt,{asChild:!0,children:s.jsx(Ls,{asChild:!0,children:s.jsx("button",{type:"button",className:ht,"aria-label":Xe,children:Ct})})}),e[132]=ht,e[133]=Xe,e[134]=Ct,e[135]=Mt):Mt=e[135];let be;e[136]!==n?(be=n("sessions.sidebar.header.displayMode.label"),e[136]=n,e[137]=be):be=e[137];let Ue;e[138]!==be?(Ue=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:be})}),e[138]=be,e[139]=Ue):Ue=e[139];let ut;e[140]!==Mt||e[141]!==Ue?(ut=s.jsxs(Dt,{children:[Mt,Ue]}),e[140]=Mt,e[141]=Ue,e[142]=ut):ut=e[142];let G;e[143]!==n?(G=n("sessions.sidebar.header.actions.sortProjects"),e[143]=n,e[144]=G):G=e[144];let U;e[145]!==G?(U=s.jsx(zr,{children:G}),e[145]=G,e[146]=U):U=e[146];let Z;e[147]!==P||e[148]!==T||e[149]!==n?(Z=[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(ze=>{const[qe,tt]=ze;return s.jsxs(Kt,{onClick:()=>{T(qe),$r({sidebarProjectSortOrder:qe})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(tt)}),P===qe?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},qe)}),e[147]=P,e[148]=T,e[149]=n,e[150]=Z):Z=e[150];let ke;e[151]===Symbol.for("react.memo_cache_sentinel")?(ke=s.jsx(Rs,{}),e[151]=ke):ke=e[151];let Te;e[152]!==$||e[153]!==j||e[154]!==o||e[155]!==n?(Te=o?s.jsxs(s.Fragment,{children:[s.jsx(zr,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(ze=>{const[qe,tt]=ze;return s.jsxs(Kt,{onClick:()=>{j(qe),$r({sidebarProjectDisplayMode:qe})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(tt)}),$===qe?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},qe)}),s.jsx(Rs,{})]}):null,e[152]=$,e[153]=j,e[154]=o,e[155]=n,e[156]=Te):Te=e[156];let We;e[157]!==n?(We=n("sessions.sidebar.header.grouping.label"),e[157]=n,e[158]=We):We=e[158];let Je;e[159]!==We?(Je=s.jsx(zr,{children:We}),e[159]=We,e[160]=Je):Je=e[160];let nt;e[161]!==_||e[162]!==L||e[163]!==n?(nt=[["by-worktree","sessions.sidebar.header.grouping.byWorktree"],["flat","sessions.sidebar.header.grouping.flat"]].map(ze=>{const[qe,tt]=ze;return s.jsxs(Kt,{onClick:()=>{L(qe),$r({sidebarSessionGroupingMode:qe})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(tt)}),_===qe?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},qe)}),e[161]=_,e[162]=L,e[163]=n,e[164]=nt):nt=e[164];let rt;e[165]===Symbol.for("react.memo_cache_sentinel")?(rt=s.jsx(Rs,{}),e[165]=rt):rt=e[165];let Ye;e[166]!==E||e[167]!==l||e[168]!==I||e[169]!==n||e[170]!==A?(Ye=l&&!E?s.jsxs(Kt,{onClick:()=>{A(),$r({sidebarShowRecentSection:!I})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),I?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[166]=E,e[167]=l,e[168]=I,e[169]=n,e[170]=A,e[171]=Ye):Ye=e[171];let Nt;e[172]!==n?(Nt=n("sessions.sidebar.header.displayMode.stickyHeaders"),e[172]=n,e[173]=Nt):Nt=e[173];let Ke;e[174]!==Nt?(Ke=s.jsx("span",{children:Nt}),e[174]=Nt,e[175]=Ke):Ke=e[175];let Tt;e[176]!==W?(Tt=W?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null,e[176]=W,e[177]=Tt):Tt=e[177];let Ce;e[178]!==Ke||e[179]!==Tt||e[180]!==O?(Ce=s.jsxs(Kt,{onClick:O,className:"flex items-center justify-between",children:[Ke,Tt]}),e[178]=Ke,e[179]=Tt,e[180]=O,e[181]=Ce):Ce=e[181];let ft;e[182]!==N||e[183]!==C||e[184]!==E||e[185]!==n?(ft=E?null:s.jsxs(s.Fragment,{children:[s.jsx(Rs,{}),s.jsxs(Kt,{onClick:N,className:"flex items-center gap-2",children:[s.jsx(M,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Kt,{onClick:C,className:"flex items-center gap-2",children:[s.jsx(M,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}),e[182]=N,e[183]=C,e[184]=E,e[185]=n,e[186]=ft):ft=e[186];let bt;e[187]!==U||e[188]!==Z||e[189]!==Te||e[190]!==Je||e[191]!==nt||e[192]!==Ye||e[193]!==Ce||e[194]!==ft?(bt=s.jsxs($s,{align:"end",className:"min-w-[180px]",children:[U,Z,ke,Te,Je,nt,rt,Ye,Ce,ft]}),e[187]=U,e[188]=Z,e[189]=Te,e[190]=Je,e[191]=nt,e[192]=Ye,e[193]=Ce,e[194]=ft,e[195]=bt):bt=e[195];let jt;e[196]!==ut||e[197]!==bt?(jt=s.jsxs(zs,{children:[ut,bt]}),e[196]=ut,e[197]=bt,e[198]=jt):jt=e[198];let Ge;e[199]!==V||e[200]!==St||e[201]!==jt?(Ge=s.jsxs("div",{className:"flex items-center gap-1.5",children:[V,St,jt]}),e[199]=V,e[200]=St,e[201]=jt,e[202]=Ge):Ge=e[202];let Le;e[203]!==ae||e[204]!==Ge?(Le=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[ae,Ge]}),e[203]=ae,e[204]=Ge,e[205]=Le):Le=e[205];let pt;e[206]!==v||e[207]!==y||e[208]!==p||e[209]!==w||e[210]!==f||e[211]!==S||e[212]!==x||e[213]!==n?(pt=y?s.jsxs("div",{className:"pb-1",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between px-0.5 typography-micro text-muted-foreground/80",children:[v?s.jsx("span",{children:p===1?n("sessions.sidebar.header.search.matchCountSingle",{count:p}):n("sessions.sidebar.header.search.matchCountPlural",{count:p})}):s.jsx("span",{}),s.jsx("span",{children:n("sessions.sidebar.header.search.escapeHint")})]}),s.jsx(Yd,{inputRef:w,value:f,onSearch:x,onClose:()=>S(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear")})]}):null,e[206]=v,e[207]=y,e[208]=p,e[209]=w,e[210]=f,e[211]=S,e[212]=x,e[213]=n,e[214]=pt):pt=e[214];let Be;return e[215]!==Le||e[216]!==pt?(Be=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:s.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[Le,pt]})}),e[215]=Le,e[216]=pt,e[217]=Be):Be=e[217],Be}function hj(t){return!t}function pj(t){return s.jsxs(Kt,{onSelect:()=>De.getState().setOpenGuestPage(t.id),children:[s.jsx(to,{icon:tg(t.icon),iconSrc:eg(t.id,t.icon,ja().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function gj(t){return t.setProjectDisplayMode}function xj(t){return t.projectDisplayMode}function bj(t){return t.toggleStickyZoneHeaders}function yj(t){return t.stickyZoneHeaders}function wj(t){return t.setSessionGroupingMode}function vj(t){return t.sessionGroupingMode}function Sj(t){return t.setProjectSortOrder}function jj(t){return t.projectSortOrder}function kj(t){return t.toggleRecentSection}function Cj(t){return t.showRecentSection}function Nj(t){return t.toggleMode}function Aj(t){return t.enabled}function Dj(t){const e=et.c(8),{t:n}=vt(),r=t.onNewSession;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(M,{name:"chat-new",className:"h-4 w-4 flex-shrink-0"}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("sessions.sidebar.header.actions.newSession"),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==o?(l=s.jsx("span",{className:"truncate",children:o}),e[3]=o,e[4]=l):l=e[4];let a;return e[5]!==t.onNewSession||e[6]!==l?(a=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 pt-1.5",children:s.jsxs("button",{type:"button",onClick:r,className:"flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 text-left typography-ui-label font-normal text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[i,l]})}),e[5]=t.onNewSession,e[6]=l,e[7]=a):a=e[7],a}const ji="inline-flex h-8 w-8 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-ring";function Pj(t){const e=et.c(13),{onOpenSettings:n,onOpenShortcuts:r,onOpenAbout:i,onOpenUpdate:o,showRuntimeButtons:l,showUpdateButton:a}=t,u=l===void 0?!0:l,d=a===void 0?!0:a,{t:h}=vt();if(!u&&!d)return null;let m;e[0]!==i||e[1]!==n||e[2]!==r||e[3]!==u||e[4]!==h?(m=u?s.jsxs(s.Fragment,{children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:ji,"aria-label":h("sessions.sidebar.footer.actions.settings"),children:s.jsx(M,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:ji,"aria-label":h("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(M,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:ji,"aria-label":h("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(M,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=i,e[1]=n,e[2]=r,e[3]=u,e[4]=h,e[5]=m):m=e[5];let g;e[6]!==o||e[7]!==d||e[8]!==h?(g=d?s.jsx(dt,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:o,children:h("sessions.sidebar.footer.actions.update")}):null,e[6]=o,e[7]=d,e[8]=h,e[9]=g):g=e[9];let b;return e[10]!==m||e[11]!==g?(b=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[m,g]}),e[10]=m,e[11]=g,e[12]=b):b=e[12],b}const Ij=t=>{for(const e of t.sessions.values())if(e.tabs.some($d))return!0;return!1},Tj=()=>{const t=et.c(4),{terminal:e}=Cn(),n=Bt(Ij);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=Ej,l=Rj;if(n)return Mi(e,"",l,o);let a=Mj;return a=Mi(e,"",l,u=>{o(u),a()}),()=>a()},i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function Ej(t){const e=Bt.getState(),n=Rh(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const i of r)e.reconcileServerSessions(i,n.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function Rj(){return new Map(Bt.getState().actionMutationRevisions)}function Mj(){}const Oj=t=>{const e=et.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:u,foldersMap:d,createFolder:h,addSessionToFolder:m}=t,g=r===void 0?!0:r;let b,y;e[0]!==m||e[1]!==h||e[2]!==g||e[3]!==d||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==u?(b=()=>{!g||o||!l||a||n.forEach(S=>{if(u.has(S.normalizedPath))return;const w=Iu(S.normalizedPath),f=i.archivedSessionsByProject.get(S.id)??[],x=d[w]??[],v=new Map(x.map(Bj));f.forEach(p=>{const N=ng(p,S.normalizedPath),C=N.toLowerCase();let k=v.get(C);k||(k=h(w,N),v.set(C,k)),k.sessionIds.includes(p.id)||m(w,k.id,p.id)})})},y=[n,g,i,o,l,a,u,d,h,m],e[0]=m,e[1]=h,e[2]=g,e[3]=d,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=u,e[10]=b,e[11]=y):(b=e[10],y=e[11]),c.useEffect(b,y)};function Bj(t){return[t.name.toLowerCase(),t]}function Fj({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const d=!!(e&&Array.from(i.entries()).some(([h,m])=>h!==t&&m.has(e)));if(e&&r&&!d)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const u=(o&&r.has(o)?o:null)??l;return!u||u===e?{kind:"none"}:{kind:"select-session",sessionId:u}}const _j=t=>{const e=et.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:u,newSessionDraftOpen:d,mobileVariant:h,openNewSessionDraft:m,setSessionSwitcherOpen:g}=t;let b,y;if(e[0]!==n){y=new Map,b=new Map;const C=(k,D,I,A)=>{y.has(k)||y.set(k,new Map);const P=y.get(k);A.forEach(T=>{const _=gt(T.worktree?.path??T.session.directory??I??D);P.set(T.session.id,{directory:_}),b.has(k)||b.set(k,{id:T.session.id,directory:_}),T.children.length>0&&C(k,D,_,T.children)})};n.forEach(k=>{k.groups.forEach(D=>{C(k.project.id,k.project.normalizedPath,D.directory,D.sessions)})}),e[0]=n,e[1]=b,e[2]=y}else b=e[1],y=e[2];let S;e[3]!==b||e[4]!==y?(S={metaByProject:y,firstSessionByProject:b},e[3]=b,e[4]=y,e[5]=S):S=e[5];const w=S,f=c.useRef(null);let x,v;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==u||e[11]!==h||e[12]!==d||e[13]!==m||e[14]!==n||e[15]!==w||e[16]!==o||e[17]!==g?(x=()=>{if(!r||d||De.getState().isNewWorktreeDialogOpen||f.current===r)return;const C=n.find(A=>A.project.id===r);if(!C)return;const k=w.metaByProject.get(r);if(l&&k&&k.has(l)){f.current=r,o(A=>{if(A.get(r)===l)return A;const P=new Map(A);return P.set(r,l),P});return}const D=Fj({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:k,metaByProject:w.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:w.firstSessionByProject.get(r)?.id??null});if(D.kind==="preserve-current"){a===r&&(f.current=r);return}if(f.current=r,D.kind==="open-draft"){h&&g(!1),m({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(D.kind!=="select-session")return;const I=k?.get(D.sessionId)?.directory??null;u(D.sessionId,I)},v=[r,i,l,a,u,d,h,m,n,w,g,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=u,e[11]=h,e[12]=d,e[13]=m,e[14]=n,e[15]=w,e[16]=o,e[17]=g,e[18]=x,e[19]=v):(x=e[18],v=e[19]),c.useLayoutEffect(x,v);let p,N;e[20]!==r||e[21]!==l||e[22]!==w||e[23]!==o?(p=()=>{if(!r||!l)return;const C=w.metaByProject.get(r);!C||!C.has(l)||o(k=>{if(k.get(r)===l)return k;const D=new Map(k);return D.set(r,l),D})},N=[r,l,w,o],e[20]=r,e[21]=l,e[22]=w,e[23]=o,e[24]=p,e[25]=N):(p=e[24],N=e[25]),c.useEffect(p,N)},Lj=t=>{const e=et.c(20);let n,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o):(n=e[1],r=e[2],i=e[3],o=e[4]);const l=Ze($j),a=Ze(zj);let u;e[5]!==l||e[6]!==o?(u=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=u):u=e[7];const d=u;let h;e[8]!==r?(h=()=>new Map(r),e[8]=r,e[9]=h):h=e[9];const[m,g]=c.useState(h);let b;e[10]!==m||e[11]!==n||e[12]!==l||e[13]!==d||e[14]!==a?(b={...n,activeSessionByProject:m,setActiveSessionByProject:g,currentSessionId:l,currentSessionOwnerProjectId:d,newSessionDraftOpen:a},e[10]=m,e[11]=n,e[12]=l,e[13]=d,e[14]=a,e[15]=b):b=e[15],_j(b);let y,S;return e[16]!==m||e[17]!==i?(y=()=>{i(m)},S=[m,i],e[16]=m,e[17]=i,e[18]=y,e[19]=S):(y=e[18],S=e[19]),c.useEffect(y,S),null};function $j(t){return t.currentSessionId}function zj(t){return!!t.newSessionDraft?.open}const Bc={selected:0,"active-project":1,expanded:2,visible:3,background:4};function Lf(t){const e=new Map,n=(r,i,o)=>{const l=gt(r??null);if(!l)return;const a=e.get(l);a&&Bc[a.priority]<=Bc[i]||e.set(l,{directory:l,priority:i,reason:o})};for(const r of t.knownDirectories??[])n(r,"background","known-project");n(t.activeProjectDirectory,"active-project","project-expanded");for(const r of t.projectSections??[]){const i=!t.collapsedProjects.has(r.project.id);let o="background";r.project.id===t.activeProjectId?o="active-project":i&&(o="expanded"),n(r.project.normalizedPath,o,i?"project-expanded":"known-project");for(const l of r.groups){if(!l.directory||l.isArchivedBucket||l.isMain)continue;const a=i&&!t.collapsedGroups.has(`${r.project.id}:${l.id}`);let u="background";a?u="expanded":i&&(u="visible"),n(l.directory,u,a?"worktree-expanded":"known-worktree")}}return n(t.currentDirectory,"selected","current-directory"),n(t.currentSessionDirectory,"selected","selected-session"),[...e.values()]}const Wj=(t,e)=>t?e.kind!==t.kind?e.kind==="project":e.projectRoot.length!==t.projectRoot.length?e.projectRoot.length>t.projectRoot.length:e.projectId.localeCompare(t.projectId)<0:!0,Fc=(t,e,n)=>{Wj(t.get(e),n)&&t.set(e,n)},Kj=t=>{const e=t;return gt(e.directory)??gt(e.project?.worktree)},Vj=(t,e,n,r,i=[])=>{const o=new Map,l=new Map;for(const y of e){const S=gt(y.normalizedPath);if(!S)continue;const w=l.get(S);(!w||y.id.localeCompare(w.id)<0)&&l.set(S,y),Fc(o,S,{projectId:y.id,projectRoot:S,scopeDirectory:S,kind:"project"})}if(!r)for(const[y,S]of n){const w=gt(y),f=w?l.get(w):void 0;if(!(!f||!w))for(const x of S){const v=gt(x.path);v&&Fc(o,v,{projectId:f.id,projectRoot:w,scopeDirectory:v,kind:"worktree"})}}const a=new Map,u=new Map,d=new Map,h=new Map,m=new Map,g=y=>{if(!y)return null;if(a.has(y))return a.get(y)??null;if(r){const x=o.get(y)??null;return a.set(y,x),x}const S=[];let w=y,f=null;for(;w;){if(a.has(w)){f=a.get(w)??null;break}if(S.push(w),f=o.get(w)??null,f)break;w=sh(w)}for(const x of S)a.set(x,f);return f},b=(y,S,w)=>{for(const f of y){const x=g(Kj(f));if(!x)continue;u.set(f.id,x);const v=S.get(x.projectId);if(v?v.push(f):S.set(x.projectId,[f]),!w)continue;const p=w.get(x.scopeDirectory);p?p.add(f.id):w.set(x.scopeDirectory,new Set([f.id]))}};return b(t,d,m),b(i,h),{bySessionId:u,sessionsByProject:d,archivedSessionsByProject:h,sessionsByScope:m,directoryResolutions:a.size}},Uj=t=>{const e=et.c(7),{ownership:n}=t;let r;e[0]!==n?(r=u=>n.sessionsByProject.get(u)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=u=>n.archivedSessionsByProject.get(u)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},Xn=(t,e)=>`${t}\0${e}`,kr=(t,e)=>t??Oa(e)??gt(e??null),Zr=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??gt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},el=t=>t.startsWith("__archived__:"),Hj=(t,e)=>t.map(n=>{const r=gt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
879
- `),Gj=[],qj=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:u,buildGroupedSessions:d,hasSessionSearchQuery:h,normalizedSessionSearchQuery:m,filterSessionNodesForSearch:g,buildGroupSearchText:b,foldersMap:y,standaloneGroups:S}=t,w=c.useRef(new Map),f=c.useMemo(()=>{const I=w.current,A=new Map;let P=0,T=0;const _=(W,O)=>W.length===O.length&&W.every(($,j)=>$===O[j]),L=e.map(W=>{const O=n(W.id),$=r(W.id),j=i.get(W.normalizedPath)??Gj,E=o.has(W.id)?!!o.get(W.id):u,K=l.get(W.id)??null,ee=Hj(j,a),J=I.get(W.id);if(J&&J.project===W&&_(J.activeSessions,O)&&_(J.archivedSessions,$)&&J.availableWorktrees===j&&J.rootBranch===K&&J.worktreeBranchesKey===ee&&J.isRepo===E&&J.buildGroupedSessions===d)return P+=1,A.set(W.id,J),J.section;if(T+=1,J){const te=J.project!==W?"project":_(J.activeSessions,O)?_(J.archivedSessions,$)?J.availableWorktrees!==j?"worktrees":J.rootBranch!==K?"branch":J.worktreeBranchesKey!==ee?"worktreeBranches":J.isRepo!==E?"repo":"builder":"archived":"sessions";Qs(`ui.sidebar.project_section.rebuilt_reason.${te}`)}const ne=Tu([...O,...$]),ue=d(ne,W.normalizedPath,j,K,E),X={project:W,groups:ue};return A.set(W.id,{project:W,activeSessions:O,archivedSessions:$,availableWorktrees:j,rootBranch:K,worktreeBranchesKey:ee,isRepo:E,buildGroupedSessions:d,section:X}),X});return w.current=A,P>0&&Qs("ui.sidebar.project_section.reused",P),T>0&&Qs("ui.sidebar.project_section.rebuilt",T),L},[e,n,r,i,o,u,d,l,a]),x=c.useMemo(()=>f,[f]),v=c.useMemo(()=>{const I=new WeakMap;if(!h)return I;const A=m.trim().toLowerCase(),P=A.startsWith("ses_"),T=L=>L.reduce((W,O)=>W+(!P||O.session.id.toLowerCase()===A?1:0)+T(O.children),0),_=L=>{const W=g(L.sessions,m),O=T(W),$=!P&&Ro([b(L)],m),j=Zr(L).flatMap(({scopeKey:K})=>y[K]??[]),E=P?0:j.filter(K=>Ro([K.name],m)).length;I.set(L,{filteredNodes:W,matchedSessionCount:O,folderNameMatchCount:E,groupMatches:$,hasMatch:$||O>0||E>0})};return x.forEach(L=>{L.groups.forEach(_)}),S.forEach(_),I},[h,x,S,g,m,b,y]),p=c.useMemo(()=>h?x.map(I=>({...I,groups:I.groups.filter(A=>v.get(A)?.hasMatch===!0)})).filter(I=>I.groups.length>0):x,[h,x,v]),N=h?p:x,C=c.useRef(new WeakMap),k=c.useMemo(()=>{const I=C.current;return N.map(A=>{const P=I.get(A);if(P&&P.query===m)return P.section;const T=A.groups.filter(E=>!E.isArchivedBucket),_=A.groups.filter(E=>E.isArchivedBucket),L=T.flatMap(E=>h?v.get(E)?.filteredNodes??[]:E.sessions),W=T.map(E=>({scopeKey:E.folderScopeKey??gt(E.directory??null),directory:E.directory??null})).filter(E=>!!E.scopeKey),O=T.find(E=>E.isMain)??null,$={id:"flat",label:O?.label??"",branch:O?.branch??null,description:O?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:O?.directory??A.project.normalizedPath,folderScopeKey:O?.folderScopeKey??A.project.normalizedPath,folderScopes:W,sessions:L};if(h){const E=T.map(K=>v.get(K)).filter(K=>!!K);v.set($,{filteredNodes:L,matchedSessionCount:E.reduce((K,ee)=>K+ee.matchedSessionCount,0),folderNameMatchCount:E.reduce((K,ee)=>K+ee.folderNameMatchCount,0),groupMatches:E.some(K=>K.groupMatches),hasMatch:E.some(K=>K.hasMatch)})}const j={project:A.project,groups:[$,..._]};return I.set(A,{query:m,section:j}),j})},[v,h,m,N]),D=c.useMemo(()=>{if(!h)return 0;const I=(P,T)=>{const _=v.get(T);if(!_)return P;const L=_.folderNameMatchCount+(_.groupMatches?1:0);return P+_.matchedSessionCount+L},A=N.reduce((P,T)=>T.groups.reduce(I,P),0);return S.reduce(I,A)},[h,N,S,v]);return{projectSections:f,visibleProjectSections:x,groupSearchDataByGroup:v,searchableProjectSections:p,sectionsForRender:N,flatSectionsForRender:k,searchMatchCount:D}},Yj=180,_c=150,Qj=2,Xj=8,Lc=[-1,1,-2,2],ki=t=>`${t.directory}
880
- ${t.sessionId}`,Jj=t=>t?.directory?.trim()||null,Zj=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:i})=>{const o=c.useRef(new Map),l=c.useRef([]),a=c.useRef(new Set),u=c.useRef(0),d=c.useMemo(()=>Kn(),[]),h=c.useCallback(()=>{u.current+=1,l.current=[],o.current.forEach(b=>window.clearTimeout(b)),o.current.clear()},[]),m=c.useCallback(()=>{if(!(!t||d))for(;a.current.size<Qj&&l.current.length>0;){const b=l.current.shift();if(!b)break;if(b.generation!==u.current||Ze.getState().currentSessionId===b.sessionId||Ui(b.sessionId,b.directory).renderable)continue;const S=ki(b);a.current.add(S),i({directory:b.directory,sessionID:b.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(S),m()})}},[t,d,i]),g=c.useCallback(b=>{const y=b?.id,S=Jj(b);if(!t||d||!y||!S||y===e)return;const w={sessionId:y,directory:S,generation:u.current},f=ki(w);if(Ui(y,S).renderable||a.current.has(f)||l.current.some(p=>ki(p)===f))return;const x=o.current.get(f);x!==void 0&&window.clearTimeout(x);const v=window.setTimeout(()=>{if(o.current.delete(f),w.generation!==u.current)return;const p=l.current;p.length>=Xj&&p.shift(),p.push(w),m()},Yj);o.current.set(f,v)},[e,t,d,m]);c.useEffect(()=>{h()},[h,e,t,d]),c.useEffect(()=>{if(!t||d||!e||n.length===0)return;const b=window.setTimeout(()=>{const y=n.findIndex(S=>S.id===e);if(!(y<0))for(const S of Lc)g(n[y+S])},_c);return()=>window.clearTimeout(b)},[e,t,d,g,n]),c.useEffect(()=>{if(!t||d||!e||r.length===0)return;const b=window.setTimeout(()=>{const y=r.findIndex(S=>S.id===e);if(!(y<0))for(const S of Lc)g(r[y+S])},_c);return()=>window.clearTimeout(b)},[e,t,d,r,g]),c.useEffect(()=>h,[h])},e2=t=>{const e=et.c(3),n=Ze(t2);let r;return e[0]!==t||e[1]!==n?(r={...t,currentSessionId:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],Zj(r),null};function t2(t){return t.currentSessionId}const s2=(t,e)=>{const n=new Set,r=new Set,i=(o,l)=>{n.add(o.session.id),(!l||e)&&r.add(o.session.id),o.children.forEach(a=>i(a,!0))};return t.forEach(o=>i(o,!1)),{active:n,unread:r}},tl=t=>{const e=et.c(12),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==o||e[1]!==n?(l=o?n:[],e[0]=o,e[1]=n,e[2]=l):l=e[2];let a;e[3]!==r||e[4]!==l?(a=s2(l,r),e[3]=r,e[4]=l,e[5]=a):a=e[5];const u=a;let d;e[6]!==o||e[7]!==u.active?(d=b=>{if(!o)return null;for(const y of u.active){const S=b.statusById.get(y)?.status.type;if(S==="busy"||S==="retry")return"active"}return null},e[6]=o,e[7]=u.active,e[8]=d):d=e[8];const h=Ba(d);let m;e[9]!==o||e[10]!==u.unread?(m=b=>{if(!o)return null;for(const y of u.unread)if((b.index.session.unseenCount[y]??0)>0)return"unread";return null},e[9]=o,e[10]=u.unread,e[11]=m):m=e[11];const g=Fa(m);return h??g};function $f(t){const e=et.c(6),{state:n,activeLabel:r,unreadLabel:i,className:o}=t,l=n==="active"?r:i,a=n==="active"?"bg-primary":"bg-[var(--status-info)]";let u;e[0]!==o||e[1]!==a?(u=Me("h-1.5 w-1.5 shrink-0 rounded-full",a,o),e[0]=o,e[1]=a,e[2]=u):u=e[2];let d;return e[3]!==l||e[4]!==u?(d=s.jsx("span",{className:u,"aria-label":l,title:l}),e[3]=l,e[4]=u,e[5]=d):d=e[5],d}const n2=t=>{const e=et.c(11),{nodes:n,includeUnreadSubtasks:r}=t,{t:i}=vt();let o;e[0]!==r||e[1]!==n?(o={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=tl(o);if(!l)return null;let a;e[3]!==i?(a=i("sessions.sidebar.session.status.active"),e[3]=i,e[4]=a):a=e[4];let u;e[5]!==i?(u=i("sessions.sidebar.session.status.unread"),e[5]=i,e[6]=u):u=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==u?(d=s.jsx($f,{state:l,activeLabel:a,unreadLabel:u}),e[7]=l,e[8]=a,e[9]=u,e[10]=d):d=e[10],d},r2=t=>{const e=et.c(83),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:u,onRename:d,onDelete:h,children:m,renderBody:g,mobileVariant:b,alwaysShowActions:y,isRenaming:S,renameDraft:w,onRenameDraftChange:f,onRenameSave:x,onRenameCancel:v,droppableRef:p,isDropTarget:N,onNewSession:C,depth:k,hideActions:D,archivedBucket:I}=t,A=a===void 0?null:a,P=g===void 0?!0:g,_=y===void 0?b===void 0?!1:b:y,L=S===void 0?!1:S,W=w===void 0?"":w,O=N===void 0?!1:N,$=D===void 0?!1:D,j=I===void 0?!1:I,{t:E}=vt(),[K,ee]=c.useState(!1),[J,ne]=c.useState(""),ue=c.useRef(null),X=L||K,te=L?W:J;let fe;e[0]!==n.name?(fe=()=>{ne(n.name),ee(!0)},e[0]=n.name,e[1]=fe):fe=e[1];const je=fe;let ve;e[2]!==te||e[3]!==n.name||e[4]!==L||e[5]!==d||e[6]!==x?(ve=()=>{const ge=te.trim();ge&&ge!==n.name&&d(ge),L&&x&&x(),ee(!1),ne("")},e[2]=te,e[3]=n.name,e[4]=L,e[5]=d,e[6]=x,e[7]=ve):ve=e[7];const ye=ve;let Pe;e[8]!==L||e[9]!==v?(Pe=()=>{L&&v&&v(),ee(!1),ne("")},e[8]=L,e[9]=v,e[10]=Pe):Pe=e[10];const xe=Pe;let R;e[11]!==L||e[12]!==f?(R=ge=>{L&&f?f(ge):ne(ge)},e[11]=L,e[12]=f,e[13]=R):R=e[13];const Y=R;let ie,H;e[14]!==L?(ie=()=>{if(!L)return;const ge=()=>{const Ae=ue.current;Ae&&(Ae.focus(),Ae.select())},He=requestAnimationFrame(ge),V=window.setTimeout(ge,0);return()=>{cancelAnimationFrame(He),window.clearTimeout(V)}},H=[L],e[14]=L,e[15]=ie,e[16]=H):(ie=e[15],H=e[16]),c.useEffect(ie,H);const me=l?"folder":"folder-open",pe=O&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let re;e[17]!==pe?(re=Me("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",pe),e[17]=pe,e[18]=re):re=e[18];let de;e[19]!==u||e[20]!==X?(de=X?void 0:ge=>{ge.currentTarget.blur(),u()},e[19]=u,e[20]=X,e[21]=de):de=e[21];const B=X?void 0:"button",F=X?void 0:0;let he;e[22]!==u||e[23]!==X?(he=X?void 0:ge=>{(ge.key==="Enter"||ge.key===" ")&&(ge.preventDefault(),u())},e[22]=u,e[23]=X,e[24]=he):he=e[24];let Se;e[25]!==n.name||e[26]!==l||e[27]!==E?(Se=l?E("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):E("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=E,e[28]=Se):Se=e[28];const Re=j?_?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":_?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let le;e[29]!==Re?(le=Me("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",Re),e[29]=Re,e[30]=le):le=e[30];const se=O?"text-primary":"text-muted-foreground";let q;e[31]!==se?(q=Me("h-3.5 w-3.5 flex-shrink-0",se),e[31]=se,e[32]=q):q=e[32];let z;e[33]!==me||e[34]!==q?(z=s.jsx(M,{name:me,className:q}),e[33]=me,e[34]=q,e[35]=z):z=e[35];let ae;e[36]!==A||e[37]!==r||e[38]!==te||e[39]!==n.name||e[40]!==xe||e[41]!==Y||e[42]!==ye||e[43]!==l||e[44]!==O||e[45]!==X||e[46]!==i||e[47]!==E?(ae=X?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:o2,onMouseDown:i2,onSubmit:ge=>{ge.preventDefault(),ye()},children:[s.jsx("input",{ref:ue,value:te,onChange:ge=>Y(ge.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:E("sessions.sidebar.folderItem.namePlaceholder"),onClick:a2,onPointerDown:l2,onMouseDown:c2,onKeyDown:ge=>{if(ge.key==="Escape"){ge.stopPropagation(),xe();return}(ge.key===" "||ge.key==="Enter")&&ge.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:d2,onPointerDown:u2,onMouseDown:f2,children:s.jsx(M,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:ge=>{ge.stopPropagation(),xe()},onPointerDown:m2,onMouseDown:h2,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:Me("typography-ui-label font-semibold truncate",O?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(It,{side:"right",sideOffset:8,className:"max-w-xs",children:r??n.name})]}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",i.length]}),A?s.jsx($f,{state:A,activeLabel:E("sessions.sidebar.session.status.active"),unreadLabel:E("sessions.sidebar.session.status.unread")}):null,l?s.jsx(M,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(M,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=A,e[37]=r,e[38]=te,e[39]=n.name,e[40]=xe,e[41]=Y,e[42]=ye,e[43]=l,e[44]=O,e[45]=X,e[46]=i,e[47]=E,e[48]=ae):ae=e[48];let ce;e[49]!==le||e[50]!==z||e[51]!==ae?(ce=s.jsxs("div",{className:le,children:[z,ae]}),e[49]=le,e[50]=z,e[51]=ae,e[52]=ce):ce=e[52];let Ne;e[53]!==_||e[54]!==j||e[55]!==n.name||e[56]!==je||e[57]!==$||e[58]!==h||e[59]!==C||e[60]!==X||e[61]!==E?(Ne=!X&&(!$||j)?s.jsx("div",{className:Me("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",_?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-focus-within/folder:opacity-100 group-focus-within/folder:pointer-events-auto"),children:s.jsxs("div",{className:"flex items-center gap-0.5",children:[!j&&C?s.jsx("button",{type:"button",onClick:ge=>{ge.stopPropagation(),C()},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-ring","aria-label":E("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:E("sessions.sidebar.project.actions.newSession"),children:s.jsx(M,{name:"add",className:"h-3.5 w-3.5"})}):null,j?null:s.jsx("button",{type:"button",onClick:ge=>{ge.stopPropagation(),je()},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-ring","aria-label":E("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(M,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:ge=>{ge.stopPropagation(),h()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":j?E("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):E("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=_,e[54]=j,e[55]=n.name,e[56]=je,e[57]=$,e[58]=h,e[59]=C,e[60]=X,e[61]=E,e[62]=Ne):Ne=e[62];let we;e[63]!==p||e[64]!==re||e[65]!==de||e[66]!==B||e[67]!==F||e[68]!==he||e[69]!==Se||e[70]!==ce||e[71]!==Ne?(we=s.jsxs("div",{ref:p,className:re,onClick:de,role:B,tabIndex:F,onKeyDown:he,"aria-label":Se,children:[ce,Ne]}),e[63]=p,e[64]=re,e[65]=de,e[66]=B,e[67]=F,e[68]=he,e[69]=Se,e[70]=ce,e[71]=Ne,e[72]=we):we=e[72];let $e;e[73]!==m||e[74]!==l||e[75]!==P||e[76]!==i||e[77]!==o||e[78]!==E?($e=!l&&P?s.jsxs("div",{className:"pb-1",children:[o,i.length>0?m:o?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:E("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[73]=m,e[74]=l,e[75]=P,e[76]=i,e[77]=o,e[78]=E,e[79]=$e):$e=e[79];let Oe;return e[80]!==we||e[81]!==$e?(Oe=s.jsxs("div",{className:"oc-folder",children:[we,$e]}),e[80]=we,e[81]=$e,e[82]=Oe):Oe=e[82],Oe},zf=c.memo(r2);function o2(t){return t.stopPropagation()}function i2(t){return t.stopPropagation()}function a2(t){return t.stopPropagation()}function l2(t){return t.stopPropagation()}function c2(t){return t.stopPropagation()}function d2(t){return t.stopPropagation()}function u2(t){return t.stopPropagation()}function f2(t){return t.stopPropagation()}function m2(t){return t.stopPropagation()}function h2(t){return t.stopPropagation()}function p2(t){const e=et.c(11);let n,r,i;e[0]!==t?({notifyOnSubtasks:r,activityNodes:n,...i}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);const o=i.isCollapsed&&!i.archivedBucket;let l;e[4]!==n||e[5]!==r||e[6]!==o?(l={nodes:n,includeUnreadSubtasks:r,enabled:o},e[4]=n,e[5]=r,e[6]=o,e[7]=l):l=e[7];const a=tl(l);let u;return e[8]!==a||e[9]!==i?(u=s.jsx(zf,{...i,collapsedActivityState:a}),e[8]=a,e[9]=i,e[10]=u):u=e[10],u}const Wo=t=>{const e=et.c(13),{directory:n,className:r}=t,{t:i}=vt();let o;e[0]!==n?(o=nh(n),e[0]=n,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=S=>S.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Bt(a)?.tabs.some($d))return null;let h;e[4]!==i?(h=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=h):h=e[5];const m=h;let g;e[6]!==r?(g=Me("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=g):g=e[7];let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(M,{name:"pulse",className:"size-3.5"}),e[8]=b):b=e[8];let y;return e[9]!==l||e[10]!==m||e[11]!==g?(y=s.jsx("span",{className:g,role:"img","aria-label":m,title:m,"data-action-directory":l,children:b}),e[9]=l,e[10]=m,e[11]=g,e[12]=y):y=e[12],y},g2=t=>{const e=et.c(19),{sessionId:n,dragKey:r,ownerKey:i,sessionDirectory:o,sessionTitle:l,archivedBucket:a,children:u}=t,d=i===void 0?null:i,h=a===void 0?!1:a,m=`session-drag:${r??n}`;let g;e[0]!==h||e[1]!==d||e[2]!==o||e[3]!==n||e[4]!==l?(g={type:"session",sessionId:n,ownerKey:d,sessionDirectory:o,sessionTitle:l,archivedBucket:h},e[0]=h,e[1]=d,e[2]=o,e[3]=n,e[4]=l,e[5]=g):g=e[5];let b;e[6]!==h||e[7]!==m||e[8]!==g?(b={id:m,disabled:h,data:g},e[6]=h,e[7]=m,e[8]=g,e[9]=b):b=e[9];const{attributes:y,listeners:S,setNodeRef:w,isDragging:f}=Qx(b);let x;e[10]!==S?(x=C=>{C.stopPropagation(),S?.onPointerDown&&S.onPointerDown(C)},e[10]=S,e[11]=x):x=e[11];const v=x,p=`touch-pan-y select-none${f?" opacity-30":""}`;let N;return e[12]!==y||e[13]!==u||e[14]!==v||e[15]!==S||e[16]!==w||e[17]!==p?(N=s.jsx("div",{ref:w,...y,...S,onPointerDown:v,className:p,children:u}),e[12]=y,e[13]=u,e[14]=v,e[15]=S,e[16]=w,e[17]=p,e[18]=N):N=e[18],N},Wf=t=>{const e=et.c(20),{folderId:n,scopeKey:r,ownerKey:i,disabled:o,children:l}=t,a=o===void 0?!1:o;let u;e[0]!==n||e[1]!==r?(u=Xn(r,n),e[0]=n,e[1]=r,e[2]=u):u=e[2];const d=`folder-drop:${u}`;let h;e[3]!==a||e[4]!==r?(h=a||el(r),e[3]=a,e[4]=r,e[5]=h):h=e[5];let m;e[6]!==n||e[7]!==i||e[8]!==r?(m={type:"folder",folderId:n,scopeKey:r,ownerKey:i},e[6]=n,e[7]=i,e[8]=r,e[9]=m):m=e[9];let g;e[10]!==d||e[11]!==h||e[12]!==m?(g={id:d,disabled:h,data:m},e[10]=d,e[11]=h,e[12]=m,e[13]=g):g=e[13];const{setNodeRef:b,isOver:y}=Xx(g);let S;e[14]!==l||e[15]!==y||e[16]!==b?(S=l(b,y),e[14]=l,e[15]=y,e[16]=b,e[17]=S):S=e[17];let w;return e[18]!==S?(w=s.jsx(s.Fragment,{children:S}),e[18]=S,e[19]=w):w=e[19],w},x2=t=>{const e=et.c(22),{scopeKey:n,ownerKey:r,hasFolders:i,onSessionDroppedOnFolder:o,children:l}=t,a=r===void 0?null:r;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{distance:8}},e[0]=u):u=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={activationConstraint:{delay:200,tolerance:6}},e[1]=d):d=e[1];const h=ti(Tn(ni,u),Tn(si,d)),[m,g]=c.useState(null),[b,y]=c.useState("Session"),[S,w]=c.useState(null),[f,x]=c.useState(null);if(!n){let A;return e[2]!==l?(A=s.jsx(s.Fragment,{children:l}),e[2]=l,e[3]=A):A=e[3],A}let v;e[4]!==o||e[5]!==a?(v=A=>{g(null),w(null),x(null);const{active:P,over:T}=A;if(!T)return;const _=P.data.current,L=T.data.current;_?.type!=="session"||!_.sessionId||!_.ownerKey||_.archivedBucket===!0||a&&_.ownerKey!==a||L?.type!=="folder"||!L.folderId||!L.scopeKey||!L.ownerKey||el(L.scopeKey)||L.ownerKey!==_.ownerKey||o(_.sessionId,{folderId:L.folderId,scopeKey:L.scopeKey,ownerKey:L.ownerKey},_.ownerKey)},e[4]=o,e[5]=a,e[6]=v):v=e[6];const p=v;let N,C;e[7]===Symbol.for("react.memo_cache_sentinel")?(N=A=>{const P=A.active.data.current;if(P?.type==="session"&&P.sessionId){g(P.sessionId),y(P.sessionTitle??"Session");const T=A.active.rect.current.initial?.width,_=A.active.rect.current.initial?.height;w(T??null),x(_??null)}},C=()=>{g(null),w(null),x(null)},e[7]=N,e[8]=C):(N=e[7],C=e[8]);let k;e[9]!==f||e[10]!==m||e[11]!==b||e[12]!==S||e[13]!==i?(k=m&&i?s.jsxs("div",{style:{width:S?`${S}px`:"auto",height:f?`${f}px`:"auto"},className:"flex items-center rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1 shadow-none pointer-events-none",children:[s.jsx(M,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),s.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:b})]}):null,e[9]=f,e[10]=m,e[11]=b,e[12]=S,e[13]=i,e[14]=k):k=e[14];let D;e[15]!==k?(D=s.jsx(Jx,{children:k}),e[15]=k,e[16]=D):D=e[16];let I;return e[17]!==l||e[18]!==p||e[19]!==h||e[20]!==D?(I=s.jsxs(ri,{sensors:h,collisionDetection:oi,onDragStart:N,onDragCancel:C,onDragEnd:p,children:[l,D]}),e[17]=l,e[18]=p,e[19]=h,e[20]=D,e[21]=I):I=e[21],I},Kf=c.createContext(null),b2=({entries:t,descendantIds:e,sessionsById:n,children:r})=>{const i=c.useRef(t),o=c.useRef(e),l=c.useRef(n);i.current=t,o.current=e,l.current=n;const a=c.useRef(null);return a.current===null&&(a.current={getEntries:()=>i.current,getDescendantIds:()=>o.current,getSessionsById:()=>l.current}),s.jsx(Kf.Provider,{value:a.current,children:r})},Vf=()=>c.useContext(Kf),y2=(t,e,n)=>{const r=t[0];if(!r)return null;const i=n??r.scopeKey,o=[],l=new Set;for(const a of t){if(i&&a.scopeKey!==i)continue;const u=a.descendantRange,d=u?[a.id,...e.slice(u[0],u[1])]:[a.id];for(const h of d)l.has(h)||(l.add(h),o.push(h))}return o.length>0?{ids:o,scopeKey:i}:null},Uf=(t,e)=>{if(t.size===0)return!1;for(const n of t)if(!e.get(n)?.time?.archived)return!1;return!0},$c=(t,e,n)=>{if(!e)return;const r=i=>{let o=i.session.id===e;for(const l of i.children)o=r(l)||o;return o&&n.add(i.session.id),o};for(const i of t)r(i)},$n=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if($n(n,e))return!0;return!1},w2=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!rg(r),v2=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,S2=(t,e,n)=>{const r=new Map,i=o=>{const l=Ps(o.session)??gt(o.worktree?.path)??n;if(l){const a=r.get(l)??[];a.push(o.session.id),r.set(l,a)}if(!(o===t&&e))for(const a of o.children)i(a)};return i(t),[...r].map(([o,l])=>({directory:o,sessionIDs:l}))},fa=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const i=new Set;let o=r.session.parentID??null;for(;o&&!i.has(o);){if(n.has(o)&&e.has(o))return!1;i.add(o),o=e.get(o)?.session?.parentID??null}return!0})},Hf=t=>{const e=new Map(t.map(l=>[l.id,l])),n=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}const r=new Set,i=[],o=l=>{if(r.has(l.id))return;i.push(l);const a=[l.id];for(;a.length>0;){const u=a.pop();if(!(!u||r.has(u))){r.add(u);for(const d of n.get(u)??[])a.push(d.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},Gf=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(d=>[d.id,d])),i=new Map,o=new Set;for(const d of t){if(d.parentId&&!r.has(d.parentId)){o.add(d.id);continue}if(d.parentId){const g=i.get(d.parentId)??[];g.push(d.id),i.set(d.parentId,g)}const h=new Set;let m=d.id;for(;m;){if(h.has(m)){o.add(d.id);break}h.add(m),m=r.get(m)?.parentId}}const l=new Set,a=new Set,u=d=>{if(l.has(d))return!0;if(a.has(d))return!1;const h=r.get(d);if(!h)return!1;a.add(d);let m=o.has(d);return!m&&e.archivedBucket&&h.nodeCount===0?m=(i.get(d)??[]).some(u):(!m&&!e.searchQuery&&(m=!0),!m&&(h.nodeCount>0||!n&&Ro([h.name],e.searchQuery))&&(m=!0),m||(m=(i.get(d)??[]).some(u))),a.delete(d),m&&l.add(d),m};return t.forEach(d=>u(d.id)),new Set(t.filter(d=>l.has(d.id)).map(d=>d.id))},zc=new WeakMap;let Wc=1;const j2=t=>{const e=zc.get(t);if(e!==void 0)return e;const n=Wc;return Wc+=1,zc.set(t,n),n},Ko=t=>t.children.length===0?"":t.children.map(n=>{const r=j2(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Ko(n)}`}).join("|"),qf=(t,e,n,r,i,o)=>{const l=as(),a=(u,d)=>{if(u.session.id!==d.session.id||u.children.length!==d.children.length)return!0;const h=u.session.directory??i,m=d.session.directory??o,g=Il(l,h??"",u.session.id),b=Il(l,m??"",d.session.id);return(g?n.has(g):!1)!==(b?r.has(b):!1)?!0:u.children.some((y,S)=>a(y,d.children[S]))};return a(t,e)},k2=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,Vo=(t,e,n,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const l=a=>{if(`${n}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const d of a.children)if(l(d))return!0;return!1};return t.forEach(a=>l(a)),o};let ma=!1;const ha=new Set;let Kc=!1;function C2(){for(const t of ha)t()}function sl(t){ma!==t&&(ma=t,C2())}function N2(t){t.key==="Shift"&&sl(!0)}function A2(t){t.key==="Shift"&&sl(!1)}function D2(){sl(!1)}function P2(){Kc||typeof window>"u"||(Kc=!0,window.addEventListener("keydown",N2),window.addEventListener("keyup",A2),window.addEventListener("blur",D2))}function I2(t){return P2(),ha.add(t),()=>{ha.delete(t)}}function T2(){return ma}function E2(){return!1}function R2(){return xt.useSyncExternalStore(I2,T2,E2)}const M2=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,Yf=/^g[1-9]\d*$/,Br=(t,e,n,r,i)=>{if(!M2.test(t)||e!==void 0&&!Yf.test(e)||!n?.trim()||!r?.trim()||n!==n.trim()||r!==r.trim())return null;if(i===void 0)return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!1};if(i==="fusion")return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!0};if(!/^\d+$/.test(i))return null;const o=Number.parseInt(i,10);return!Number.isSafeInteger(o)||o<=0?null:{groupSlug:t,runGroup:e,providerID:n,modelID:r,index:o,fusion:!1}},Do=t=>{if(!t)return null;const e=t.split("/");if(e.length<3||e.length>5)return null;const[n]=e;if(e.length===3)return Br(n,void 0,e[1],e[2],void 0);if(e.length===4){const[,a,u,d]=e;return Yf.test(a)?Br(n,a,u,d,void 0):Br(n,void 0,a,u,d)}const[,r,i,o,l]=e;return r===""?Br(n,void 0,i,o,l):Br(n,r,i,o,l)},O2=t=>{const e=[t.groupSlug];return t.runGroup&&e.push(t.runGroup),e.push(t.providerID,t.modelID),t.index!==void 0&&e.push(String(t.index)),e.join("/")},B2=(t,e,n,r)=>{const i=[t];return r&&i.push(r),i.push(e,n,"fusion"),i.join("/")},Qf=t=>{const e=et.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:u}=vt(),d=Yt(F2),h=Yt(_2),m=Yt(L2);let g;e[0]!==d?(g=d(),e[0]=d,e[1]=g):g=e[1];const b=g;let y;e[2]!==b?(y=b.filter($2),e[2]=b,e[3]=y):y=e[3];const S=y;let w,f;e[4]!==b.length||e[5]!==h?(w=()=>{b.length===0&&h()},f=[b.length,h],e[4]=b.length,e[5]=h,e[6]=w,e[7]=f):(w=e[6],f=e[7]),c.useEffect(w,f);let x,v;e[8]!==m||e[9]!==o||e[10]!==r||e[11]!==S||e[12]!==n?(x=()=>{if(o)return;const T=n.trim();if(T.length>0&&S.some(W=>W.name===T))return;const _=typeof m=="string"&&m.trim().length>0?m.trim():null;if(_&&S.some(W=>W.name===_)){r(_);return}const L=S[0]?.name;L&&r(L)},v=[m,o,r,S,n],e[8]=m,e[9]=o,e[10]=r,e[11]=S,e[12]=n,e[13]=x,e[14]=v):(x=e[13],v=e[14]),c.useEffect(x,v);const p=n.trim().length>0?n:void 0;let N;e[15]!==i?(N=Me("max-w-full",i),e[15]=i,e[16]=N):N=e[16];let C;e[17]!==u?(C=u("multirun.agentSelector.placeholder"),e[17]=u,e[18]=C):C=e[18];let k;e[19]!==C?(k=s.jsx(Ns,{placeholder:C}),e[19]=C,e[20]=k):k=e[20];let D;e[21]!==l||e[22]!==N||e[23]!==k?(D=s.jsx(Os,{id:l,size:"lg",className:N,children:k}),e[21]=l,e[22]=N,e[23]=k,e[24]=D):D=e[24];let I;e[25]!==S?(I=S.length>0&&s.jsx(Hi,{children:S.map(z2)}),e[25]=S,e[26]=I):I=e[26];let A;e[27]!==a||e[28]!==I?(A=s.jsx(Bs,{fitContent:!0,portalToBody:a,children:I}),e[27]=a,e[28]=I,e[29]=A):A=e[29];let P;return e[30]!==o||e[31]!==r||e[32]!==p||e[33]!==D||e[34]!==A?(P=s.jsxs(Ms,{value:p,onValueChange:r,disabled:o,children:[D,A]}),e[30]=o,e[31]=r,e[32]=p,e[33]=D,e[34]=A,e[35]=P):P=e[35],P};function F2(t){return t.getVisibleAgents}function _2(t){return t.loadAgents}function L2(t){return t.currentAgentName}function $2(t){return Eu(t.mode)}function z2(t){return s.jsx(is,{value:t.name,className:"w-auto whitespace-nowrap",children:t.name},t.name)}const W2="h-7",qr=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,K2=t=>{const e=et.c(12),{model:n,instanceIndex:r,totalSameModel:i,onRemove:o}=t,l=n.displayName||`${n.providerID}/${n.modelID}`,a=i>1?`${l} (${r})`:l;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=Me("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",W2),e[0]=u):u=e[0];let d;e[1]!==n.providerID?(d=s.jsx(Gi,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=d):d=e[2];let h;e[3]!==a?(h=s.jsx("span",{className:"typography-meta font-medium truncate max-w-[140px]",children:a}),e[3]=a,e[4]=h):h=e[4];let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(M,{name:"close",className:"h-3.5 w-3.5"}),e[5]=m):m=e[5];let g;e[6]!==o?(g=s.jsx("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground ml-0.5",children:m}),e[6]=o,e[7]=g):g=e[7];let b;return e[8]!==d||e[9]!==h||e[10]!==g?(b=s.jsxs("div",{className:u,children:[d,h,g]}),e[8]=d,e[9]=h,e[10]=g,e[11]=b):b=e[11],b},Xf=t=>{const e=et.c(120),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:u,maxModels:d,addButtonClassName:h,dropdownSide:m,dropdownClassName:g,containerClassName:b,triggerIcon:y}=t,S=u===void 0?!0:u,w=m===void 0?"top":m,{t:f}=vt(),x=Yt(V2),v=Yt(U2),p=De(H2),N=De(G2),{favoriteModelsList:C,recentModelsList:k}=og(),D=De(q2),I=De(Y2),[A,P]=c.useState(!1),[T,_]=c.useState(""),[L,W]=c.useState(null),O=c.useRef(null),$=c.useRef(null),j=d===1,E=d===void 0||n.length<d||j;let K;if(e[0]!==n){K=new Map;for(const Fe of n){const st=`${Fe.providerID}:${Fe.modelID}`;K.set(st,(K.get(st)||0)+1)}e[0]=n,e[1]=K}else K=e[1];const ee=K;let J;e[2]!==n?(J=Fe=>n.filter(lt=>lt.providerID===Fe.providerID&&lt.modelID===Fe.modelID).findIndex(lt=>lt.instanceId===Fe.instanceId)+1,e[2]=n,e[3]=J):J=e[3];const ne=J;let ue,X;e[4]!==w||e[5]!==A?(ue=()=>{if(!A||!$.current)return;const Fe=$.current.getBoundingClientRect();if(w==="bottom"){const ht=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-Fe.bottom-16-112;W(Math.max(160,Math.min(320,ht)));return}let st=$.current.parentElement;for(;st&&!st.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const mt=getComputedStyle(st);if(mt.overflow==="auto"||mt.overflow==="hidden"||mt.overflowY==="auto"||mt.overflowY==="hidden")break;st=st.parentElement}const lt=st?st.getBoundingClientRect().top:0,it=Fe.top-lt-16;W(Math.max(150,Math.min(300,it)))},X=[w,A],e[4]=w,e[5]=A,e[6]=ue,e[7]=X):(ue=e[6],X=e[7]),c.useEffect(ue,X);let te,fe;e[8]!==E||e[9]!==A?(te=()=>{!E&&A&&(P(!1),_(""))},fe=[E,A],e[8]=E,e[9]=A,e[10]=te,e[11]=fe):(te=e[10],fe=e[11]),c.useEffect(te,fe);let je,ve;e[12]!==A?(je=()=>{if(!A)return;const Fe=st=>{O.current&&!O.current.contains(st.target)&&(P(!1),_(""))};return document.addEventListener("mousedown",Fe),()=>document.removeEventListener("mousedown",Fe)},ve=[A],e[12]=A,e[13]=je,e[14]=ve):(je=e[13],ve=e[14]),c.useEffect(je,ve);let ye;e[15]!==j||e[16]!==r||e[17]!==o||e[18]!==n.length?(ye=Fe=>{const st={providerID:Fe.providerID,modelID:Fe.modelID,displayName:Fe.model.name||Fe.modelID,instanceId:qr()};j&&n.length>0&&o?o(0,st):r(st),j&&(P(!1),_(""))},e[15]=j,e[16]=r,e[17]=o,e[18]=n.length,e[19]=ye):ye=e[19];const Pe=ye;let xe;e[20]!==f?(xe=f("multirun.modelMultiSelect.search.placeholder"),e[20]=f,e[21]=xe):xe=e[21];let R;e[22]!==f?(R=f("multirun.modelMultiSelect.search.noResults"),e[22]=f,e[23]=R):R=e[23];let Y;e[24]!==f?(Y=f("multirun.modelMultiSelect.sections.favorites"),e[24]=f,e[25]=Y):Y=e[25];let ie;e[26]!==f?(ie=f("multirun.modelMultiSelect.sections.recent"),e[26]=f,e[27]=ie):ie=e[27];let H;e[28]!==f?(H=f("multirun.modelMultiSelect.keyboard.hint"),e[28]=f,e[29]=H):H=e[29];let me;e[30]!==f?(me=f("settings.agents.modelSelector.actions.favorite"),e[30]=f,e[31]=me):me=e[31];let pe;e[32]!==f?(pe=f("settings.agents.modelSelector.actions.unfavorite"),e[32]=f,e[33]=pe):pe=e[33];let re;e[34]!==f?(re=f("chat.modelControls.capabilities"),e[34]=f,e[35]=re):re=e[35];let de;e[36]!==f?(de=f("chat.modelControls.capability.toolCalling"),e[36]=f,e[37]=de):de=e[37];let B;e[38]!==f?(B=f("chat.modelControls.capability.reasoning"),e[38]=f,e[39]=B):B=e[39];let F;e[40]!==f?(F=f("chat.modelControls.input"),e[40]=f,e[41]=F):F=e[41];let he;e[42]!==f?(he=f("chat.modelControls.output"),e[42]=f,e[43]=he):he=e[43];let Se;e[44]!==f?(Se=f("chat.modelControls.costPerMillion"),e[44]=f,e[45]=Se):Se=e[45];let Re;e[46]!==xe||e[47]!==R||e[48]!==Y||e[49]!==ie||e[50]!==H||e[51]!==me||e[52]!==pe||e[53]!==re||e[54]!==de||e[55]!==B||e[56]!==F||e[57]!==he||e[58]!==Se?(Re={searchPlaceholder:xe,noResults:R,favorites:Y,recent:ie,keyboardHint:H,favorite:me,unfavorite:pe,capabilities:re,capabilityToolCalling:de,capabilityReasoning:B,input:F,output:he,costPerMillion:Se},e[46]=xe,e[47]=R,e[48]=Y,e[49]=ie,e[50]=H,e[51]=me,e[52]=pe,e[53]=re,e[54]=de,e[55]=B,e[56]=F,e[57]=he,e[58]=Se,e[59]=Re):Re=e[59];const le=Re;let se;e[60]!==b?(se=Me("relative",b),e[60]=b,e[61]=se):se=e[61];const q=A?"":void 0;let z;e[62]!==h?(z=Me(Ru({size:"default"}),"w-fit",h),e[62]=h,e[63]=z):z=e[63];const ae=!E;let ce;e[64]!==A?(ce=()=>{P(!A)},e[64]=A,e[65]=ce):ce=e[65];let Ne;e[66]!==y?(Ne=y??s.jsx(M,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=y,e[67]=Ne):Ne=e[67];let we;e[68]!==a||e[69]!==f?(we=a??f("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=f,e[70]=we):we=e[70];let $e;e[71]!==q||e[72]!==z||e[73]!==ae||e[74]!==ce||e[75]!==Ne||e[76]!==we?($e=s.jsxs("button",{ref:$,type:"button","data-popup-open":q,className:z,disabled:ae,onClick:ce,children:[Ne,we]}),e[71]=q,e[72]=z,e[73]=ae,e[74]=ce,e[75]=Ne,e[76]=we,e[77]=$e):$e=e[77];let Oe;e[78]!==L||e[79]!==E||e[80]!==g||e[81]!==w||e[82]!==C||e[83]!==Pe||e[84]!==D||e[85]!==N||e[86]!==A||e[87]!==le||e[88]!==ee||e[89]!==v||e[90]!==I||e[91]!==x||e[92]!==k||e[93]!==T||e[94]!==p?(Oe=A?s.jsx("div",{className:Me("absolute left-0 z-50 w-[min(420px,calc(100vw-2rem))] max-w-[calc(100vw-2rem)] flex flex-col overflow-hidden rounded-xl border border-border/50 shadow-lg",w==="top"?"bottom-full mb-1":"top-full mt-1",g),style:{background:"linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))"},children:s.jsx(ig,{providers:x,providerOrder:I,favoriteModels:C,recentModels:k,modelsMetadata:v,hiddenModels:D,searchQuery:T,onSearchQueryChange:_,onSelect:Pe,labels:le,selectionCount:Fe=>ee.get(`${Fe.providerID}:${Fe.modelID}`)||0,disabled:!E,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:L?`${L}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:A,isFavorite:Fe=>N(Fe.providerID,Fe.modelID),onToggleFavorite:Fe=>p(Fe.providerID,Fe.modelID),onEscape:()=>{P(!1),_("")}})}):null,e[78]=L,e[79]=E,e[80]=g,e[81]=w,e[82]=C,e[83]=Pe,e[84]=D,e[85]=N,e[86]=A,e[87]=le,e[88]=ee,e[89]=v,e[90]=I,e[91]=x,e[92]=k,e[93]=T,e[94]=p,e[95]=Oe):Oe=e[95];let ge;e[96]!==se||e[97]!==$e||e[98]!==Oe?(ge=s.jsxs("div",{className:se,ref:O,children:[$e,Oe]}),e[96]=se,e[97]=$e,e[98]=Oe,e[99]=ge):ge=e[99];let He;e[100]!==ne||e[101]!==ee||e[102]!==i||e[103]!==o||e[104]!==x||e[105]!==n||e[106]!==S||e[107]!==f?(He=S&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((Fe,st)=>{const lt=`${Fe.providerID}:${Fe.modelID}`,it=ee.get(lt)||1,mt=ne(Fe),ht=x.find(be=>be.id===Fe.providerID)?.models?.find(be=>be.id===Fe.modelID),Xe=ht?.variants?Object.keys(ht.variants):[],Ct=Xe.length>0,Mt=Fe.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(K2,{model:Fe,instanceIndex:mt,totalSameModel:it,onRemove:()=>i(st)}),Ct&&s.jsxs(Ms,{value:Mt,onValueChange:be=>{if(!o)return;o(st,{...Fe,variant:be==="__default__"?void 0:be})},children:[s.jsxs(Os,{size:"sm",className:"gap-1.5",children:[s.jsx(M,{name:"brain-ai-3",className:Me("h-3.5 w-3.5 flex-shrink-0",Mt==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(Ns,{placeholder:f("multirun.modelMultiSelect.variant.placeholder"),children:be=>be==="__default__"?f("multirun.modelMultiSelect.variant.default"):be})]}),s.jsxs(Bs,{fitContent:!0,children:[s.jsx(is,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:f("multirun.modelMultiSelect.variant.default")}),Xe.map(Q2)]})]})]},Fe.instanceId)})}),e[100]=ne,e[101]=ee,e[102]=i,e[103]=o,e[104]=x,e[105]=n,e[106]=S,e[107]=f,e[108]=He):He=e[108];let V;e[109]!==ge||e[110]!==He?(V=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[ge,He]}),e[109]=ge,e[110]=He,e[111]=V):V=e[111];let Ae;e[112]!==d||e[113]!==l||e[114]!==n.length||e[115]!==f?(Ae=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:d!==void 0?f("multirun.modelMultiSelect.validation.minToMax",{min:l,max:d}):f("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[112]=d,e[113]=l,e[114]=n.length,e[115]=f,e[116]=Ae):Ae=e[116];let Ie;return e[117]!==V||e[118]!==Ae?(Ie=s.jsxs("div",{className:"space-y-2",children:[V,Ae]}),e[117]=V,e[118]=Ae,e[119]=Ie):Ie=e[119],Ie};function V2(t){return t.providers}function U2(t){return t.modelsMetadata}function H2(t){return t.toggleFavoriteModel}function G2(t){return t.isFavoriteModel}function q2(t){return t.hiddenModels}function Y2(t){return t.providerOrder}function Q2(t){return s.jsx(is,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const X2=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
881
-
882
- --- RESULT ${n+1}: ${r} ---
883
- ${e.trim()}
884
- --- END RESULT ${n+1} ---`},Vc=(t,e)=>Ze.getState().getWorktreeMetadata(t)?.projectDirectory??e,J2=async t=>{const e=t.directory??void 0,n=lg(t.session.id,e);if(n.length===0&&t.directory){const i=(await Xs.withDirectory(t.directory,()=>Xs.getSdkClient().session.messages({sessionID:t.session.id,directory:t.directory??void 0,limit:50}))).data??[];for(let o=i.length-1;o>=0;o-=1){const l=i[o];if(l.info?.role==="assistant")return El(l.parts??[]).trim()}return""}for(let r=n.length-1;r>=0;r-=1){const i=n[r];if(i.role==="assistant")return El(cg(i.id,e)).trim()}return""};function Z2({session:t,open:e,onOpenChange:n}){const{t:r}=vt(),i=ag(),o=_s(j=>j.activeSessions),l=_s(j=>j.archivedSessions),a=Yt(j=>j.providers),u=Yt(j=>j.currentProviderId),d=Yt(j=>j.currentModelId),h=Yt(j=>j.currentAgentName),[m,g]=c.useState(u??""),[b,y]=c.useState(d??""),[S,w]=c.useState(()=>u&&d?[{providerID:u,modelID:d,instanceId:qr()}]:[]),[f,x]=c.useState(""),[v,p]=c.useState(h??""),[N,C]=c.useState([]),[k,D]=c.useState(!1),I=c.useMemo(()=>Do(t.title),[t.title]),A=c.useMemo(()=>{const j=new Map;for(const E of i)j.set(E.id,E);for(const E of o)j.set(E.id,E);for(const E of l)j.set(E.id,E);return t.id&&j.set(t.id,t),Array.from(j.values())},[o,l,i,t]);c.useEffect(()=>{if(!e||!I)return;const j=Ze.getState().getDirectoryForSession(t.id),E=Vc(t.id,j),K=A.map(ee=>{const J=Do(ee.title);if(!J||J.groupSlug!==I.groupSlug||J.fusion||(J.runGroup??null)!==(I.runGroup??null))return null;const ne=Ze.getState().getDirectoryForSession(ee.id)??Ps(ee),ue=Vc(ee.id,ne);return E&&ue&&E!==ue?null:{session:ee,directory:ne,projectDirectory:ue}}).filter(ee=>ee!==null).sort((ee,J)=>(ee.session.time?.created??0)-(J.session.time?.created??0));C(K)},[A,e,I,t.id]);const T=a.find(j=>j.id===m)?.models.find(j=>j.id===b),_=T?.variants?Object.keys(T.variants):[],L=!!(I&&m&&b&&N.length>0&&!k),W=c.useCallback(j=>{w([j]),g(j.providerID),y(j.modelID),x("")},[]),O=S[0]?.displayName||S[0]?.modelID||r("multirun.fusion.model.placeholder"),$=async()=>{if(!(!I||!m||!b)){D(!0);try{const j=await Promise.all(N.map(X=>J2(X))),E=N.map((X,te)=>({source:X,text:j[te]??""})).filter(X=>X.text.trim().length>0);if(E.length===0){_e.error(r("multirun.fusion.toast.noOutputs"));return}const K=N[0]?.projectDirectory??N[0]?.directory??null,ee=B2(I.groupSlug,m,b,I.runGroup),[J,ne]=await Promise.all([Tl("session.fusion.visible"),Tl("session.fusion.instructions")]),ue=await Ze.getState().createSession(ee,K,null);if(!ue)throw new Error("Failed to create fusion session");Ze.getState().setCurrentSession(ue.id,K),n(!1),await Xs.sendMessage({id:ue.id,providerID:m,modelID:b,variant:f||void 0,agent:v||void 0,text:J,additionalParts:[{text:ne,synthetic:!0},...E.map((X,te)=>({text:X2(X.source,X.text,te),synthetic:!0})),{text:`
885
-
886
- --- FUSION INPUTS END ---
887
- Now write the final fused answer.`,synthetic:!0}],directory:K??Xs.getDirectory()})}catch(j){console.error("[MultiRunFusion] Failed to start fusion",j),_e.error(r("multirun.fusion.toast.failed"))}finally{D(!1)}}};return s.jsx(vs,{open:e,onOpenChange:n,children:s.jsxs(Ss,{className:"max-w-xl overflow-visible",children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:r("multirun.fusion.title")}),s.jsx(Ts,{children:r("multirun.fusion.description")})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"max-w-full",children:s.jsx(Xf,{selectedModels:S,onAdd:W,onUpdate:(j,E)=>W(E),onRemove:()=>{w([]),g(""),y(""),x("")},maxModels:1,addButtonLabel:O,showChips:!1,addButtonClassName:"w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start",dropdownSide:"bottom",dropdownClassName:"w-[min(28rem,calc(100vw-8rem))]",triggerIcon:m?s.jsx(Gi,{providerId:m,className:"h-3.5 w-3.5 mr-1"}):void 0})}),_.length>0?s.jsxs(Ms,{value:f||"__default__",onValueChange:j=>x(j==="__default__"?"":j),children:[s.jsxs(Os,{size:"lg",className:"w-fit",children:[s.jsx(M,{name:"brain-ai-3",className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx(Ns,{children:j=>j==="__default__"?r("multirun.modelMultiSelect.variant.default"):j})]}),s.jsxs(Bs,{fitContent:!0,portalToBody:!0,children:[s.jsx(is,{value:"__default__",children:r("multirun.modelMultiSelect.variant.default")}),_.map(j=>s.jsx(is,{value:j,children:j},j))]})]}):null,s.jsx(Qf,{value:v,onChange:p,portalToBody:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta font-medium text-foreground",children:r("multirun.fusion.sources.label",{count:N.length})}),s.jsx("div",{className:"max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1",children:N.map(j=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta",children:[s.jsx(Gi,{providerId:Do(j.session.title)?.providerID??"",className:"h-4 w-4"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:j.session.title||j.session.id}),s.jsx("button",{type:"button",onClick:()=>C(E=>E.filter(K=>K.session.id!==j.session.id)),className:"text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"h-4 w-4"})})]},j.session.id))})]}),s.jsxs(Sn,{children:[s.jsx(dt,{variant:"ghost",onClick:()=>n(!1),children:r("multirun.fusion.actions.cancel")}),s.jsx(dt,{onClick:$,disabled:!L,children:r(k?"multirun.fusion.actions.starting":"multirun.fusion.actions.start")})]})]})})}function ek(t){const e=et.c(7);let n,r,i,o,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("path",{d:"M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),r=s.jsx("path",{d:"M9.25 7.25 12 4.5l2.75 2.75",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),i=s.jsx("circle",{cx:"4",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),o=s.jsx("circle",{cx:"12",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),l=s.jsx("circle",{cx:"20",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),e[0]=n,e[1]=r,e[2]=i,e[3]=o,e[4]=l):(n=e[0],r=e[1],i=e[2],o=e[3],l=e[4]);let a;return e[5]!==t?(a=s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...t,children:[n,r,i,o,l]}),e[5]=t,e[6]=a):a=e[6],a}const Jf=async(t,e,n)=>{const r=n.getRuntimeKey(),i=gt(t.path);if(!i)throw new Error("Unable to resolve worktree project");const o=await n.listProjectWorktrees(t,{force:!0});if(n.getRuntimeKey()!==r)throw new Error("Runtime changed during worktree refresh");const l=n.getCurrentProjects(),a=l.find(y=>y.id===t.id)??null;if(!a||gt(a.path??null)!==i)throw new Error("Project removed during worktree refresh");const u=nl({rawWorktreesByProjectRef:n.rawWorktreesByProjectRef,publishedWorktreesByProject:n.getPublishedWorktreesByProject(),runtimeKey:r}),d=o.map(y=>Uo(y));d.sort((y,S)=>Zf({metadata:y},{metadata:S}));const h=dg(u.worktreesByProject,i,d,e?.projectDirectory);tk(n.rawWorktreesByProjectRef,r),n.rawWorktreesByProjectRef.current={runtimeKey:r,revision:n.rawWorktreesByProjectRef.current.revision,worktreesByProject:h};const m=n.getPublishedWorktreesByProject(),g=ug(n.partitionWorktreesByRegisteredProject(l,h),m),b=[...g.values()].flat();return n.recordWorktreesSeen(b.map(y=>y.path),n.now()),n.worktreeMapsEqual(g,m)||n.publishTopology({availableWorktrees:b,availableWorktreesByProject:g}),d},tk=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),sk=t=>new Map([...t.entries()].map(([e,n])=>[e,n.map(r=>Uo(r))])),nl=t=>((t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey||t.rawWorktreesByProjectRef.current.worktreesByProject.size===0&&t.publishedWorktreesByProject.size>0)&&(t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.rawWorktreesByProjectRef.current.runtimeKey===t.runtimeKey?t.rawWorktreesByProjectRef.current.revision:0,worktreesByProject:sk(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),Zf=(t,e)=>{const n=t.metadata.branch||t.metadata.name||t.metadata.label||t.metadata.path,r=e.metadata.branch||e.metadata.name||e.metadata.label||e.metadata.path,i=n.localeCompare(r,void 0,{sensitivity:"base"});return i!==0?i:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},Uc=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Uo=t=>({...t,path:gt(t.path)??t.path,projectDirectory:gt(t.projectDirectory)??t.projectDirectory,worktreeRoot:gt(t.worktreeRoot??t.path)??t.worktreeRoot}),Hc=t=>{const{currentWorktree:e,path:n,projectDirectory:r,projectRootBranch:i}=t,l=gt(e?.path??null)===n,a=l?e?.branch??"":i??"",u={path:n,projectDirectory:r,branch:a,label:l?e?.label||e?.branch||e?.name||Uc(n):i||Uc(n),name:l?e?.name:void 0,worktreeRoot:l?gt(e?.worktreeRoot??n)??n:n,worktreeStatus:l?e?.worktreeStatus??"ready":"ready",worktreeSource:l?e?.worktreeSource??"existing":"existing",headState:l?e?.headState:i?"branch":void 0};return l&&e?{...e,...u}:u},Gc=t=>{const e=gt(t.projectPath??null),n=gt(t.sourceDirectory??null)??gt(t.currentWorktree?.path??null),r=gt(t.discoveredWorktrees.find(h=>gt(h.projectDirectory??null))?.projectDirectory??null),i=gt(t.currentWorktree?.projectDirectory??null),o=r??i??e,l=new Map,a=h=>{const m=gt(h.metadata.path??null);!m||l.has(m)||l.set(m,{...h,metadata:Uo({...h.metadata,path:m})})};for(const h of t.discoveredWorktrees){const m=gt(h.path??null);m&&a({metadata:Uo({...h,path:m,projectDirectory:gt(h.projectDirectory??null)??o??e??m}),isPrimary:o===m,isCurrent:n===m})}o&&!l.has(o)&&a({metadata:Hc({path:o,projectDirectory:o,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:n===o}),n&&!l.has(n)&&a({metadata:Hc({path:n,projectDirectory:o??e??n,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:o===n,isCurrent:!0});const u=[],d=[];for(const h of l.values()){if(h.isPrimary){u.push(h);continue}d.push(h)}return u.sort((h,m)=>h.metadata.path.localeCompare(m.metadata.path,void 0,{sensitivity:"base"})),d.sort(Zf),[...u,...d]},nk=(t,e)=>{const n=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),i=nl({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:n}),l=(t.projectId?e.projects.find(d=>d.id===t.projectId)??null:null)??(t.sourceDirectory?e.resolveProject(t.sourceDirectory):null),a=gt(l?.path??null);return{cachedTargets:Gc({projectPath:a,discoveredWorktrees:a?i.worktreesByProject.get(a)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!l||!a)throw new Error("Unable to resolve worktree project");const d=await Jf(l,t.currentWorktree,e);return Gc({projectPath:a,discoveredWorktrees:d,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},rk=t=>{if(t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey)return!1;if(t.rawWorktreesByProjectRef.current.revision!==t.capturedRevision)return t.requestRediscovery(),!1;const e=t.partitionWorktreesByRegisteredProject(t.projects,t.nextRawWorktreesByProject),n=[...e.values()].flat();return t.recordWorktreesSeen(n.map(r=>r.path),t.now()),t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.capturedRevision,worktreesByProject:new Map(t.nextRawWorktreesByProject)},t.worktreeMapsEqual(e,t.publishedWorktreesByProject)||t.publishTopology({availableWorktrees:n,availableWorktreesByProject:e}),!0},ok=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),ik=(t,e)=>gt(t.worktree?.path??null)===gt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,pa=6,xo=14,qc=pa+14+6,Ci=new WeakMap,ak=t=>{const e=t.closest("[data-session-row]"),n=e?.closest(".overlay-scrollbar-container");if(!e||!n)return;Ci.get(n)?.();const r=e.getBoundingClientRect().top;let i=3,o=!1,l=null;const a=()=>{o=!0,l!==null&&window.cancelAnimationFrame(l),l=null,Ci.delete(n),n.removeEventListener("wheel",a),n.removeEventListener("touchstart",a)},u=()=>{if(o||!e.isConnected||!n.isConnected){a();return}const d=e.getBoundingClientRect().top-r;if(Math.abs(d)>.5&&(n.scrollTop+=d,Qs("ui.sidebar.selection_scroll_anchor_adjustment")),i-=1,i<=0){a();return}l=window.requestAnimationFrame(u)};n.addEventListener("wheel",a,{passive:!0}),n.addEventListener("touchstart",a,{passive:!0}),Ci.set(n,a),l=window.requestAnimationFrame(u)},lk=c.memo(function(e){const n=et.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:l,onPointerDown:a,onMouseDown:u,onArchive:d,onDelete:h}=e,m=R2(),g=m?i:r;let b;n[0]!==d||n[1]!==h||n[2]!==m?(b=C=>{if(m||C.shiftKey){h(C);return}d(C)},n[0]=d,n[1]=h,n[2]=m,n[3]=b):b=n[3];const y=b,S=m?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let w;n[4]!==o||n[5]!==S?(w=Me("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",S,o),n[4]=o,n[5]=S,n[6]=w):w=n[6];const f=m?"delete-bin":"archive";let x;n[7]!==l||n[8]!==f?(x=s.jsx(M,{name:f,className:l}),n[7]=l,n[8]=f,n[9]=x):x=n[9];let v;n[10]!==y||n[11]!==g||n[12]!==u||n[13]!==a||n[14]!==w||n[15]!==x?(v=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",className:w,"aria-label":g,onPointerDown:a,onMouseDown:u,onClick:y,onKeyDown:xk,children:x})}),n[10]=y,n[11]=g,n[12]=u,n[13]=a,n[14]=w,n[15]=x,n[16]=v):v=n[16];let p;n[17]!==g?(p=s.jsx(It,{side:"left",sideOffset:8,children:g}),n[17]=g,n[18]=p):p=n[18];let N;return n[19]!==v||n[20]!==p?(N=s.jsxs(Dt,{children:[v,p]}),n[19]=v,n[20]=p,n[21]=N):N=n[21],N});function ck(t){Qs("ui.sidebar_session_node.render");const{t:e}=vt(),{node:n,depth:r=0,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:u=!1,pinnedSessionIds:d,expandedParents:h,hasSessionSearchQuery:m,normalizedSessionSearchQuery:g,notifyOnSubtasks:b,editingId:y,editingRowKey:S,setEditingId:w,setEditingRowKey:f,editTitle:x,setEditTitle:v,handleSaveEdit:p,handleCancelEdit:N,toggleParent:C,handleSessionSelect:k,handleSessionDoubleClick:D,handleShareSession:I,copiedSessionId:A,handleCopyShareUrl:P,handleCopySessionId:T,handleUnshareSession:_,openSidebarMenuKey:L,setOpenSidebarMenuKey:W,createFolderAndStartRename:O,handleDeleteSession:$,handleRestoreSession:j,startSessionWorktreeMenuLoad:E,mobileVariant:K,alwaysShowActions:ee,secondaryMeta:J,renderContext:ne="project",rowKey:ue,dragKey:X,children:te}=t,fe=Xr(Ee=>Ee.toggle),je=ss(Ee=>Ee.getFoldersForScope),ve=ss(Ee=>Ee.getSessionFolderId),ye=ss(Ee=>Ee.removeSessionFromFolder),Pe=ss(Ee=>Ee.addSessionToFolder),xe=De(Ee=>Ee.openContextPanelTab),R=c.useMemo(()=>Kn(),[]),Y=c.useMemo(()=>Yr(),[]),ie=c.useContext(fg),H=R?"group-hover:opacity-100 group-hover:pointer-events-auto":"group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto",me=R?"group-hover:opacity-0":"group-hover:opacity-0 group-focus-within:opacity-0",pe=R,re=!u&&!K,de=R?re&&pe?"group-hover:pr-18":re||pe?"group-hover:pr-14":"group-hover:pr-8":re?"group-hover:pr-7 group-focus-within:pr-7":"group-hover:pr-3 group-focus-within:pr-3",B=re?"pr-13":"pr-7",F=R?re?"pr-18":"pr-14":re?"pr-7":"pr-3",he=c.useRef(!1),[Se,Re]=c.useState(!1),le=c.useRef(y);le.current=y;const se=c.useRef(null),q=c.useRef(!1),z=c.useRef(p);z.current=p;const ae=x,ce=c.useRef(ae);ce.current=ae;const Ne=c.useRef(null),we=c.useRef(!1),$e=c.useRef(null),Oe=c.useRef(null),ge=n.session,He=ge,V=Gt(c.useCallback(Ee=>{if(J?.projectLabel||!o)return null;const Lt=Ee.projects.find(Zt=>Zt.id===o);return Lt?Lt.label?.trim()||Wn(gt(Lt.path)??Lt.path,null)||Lt.path:null},[o,J?.projectLabel])),Ae=J?.projectLabel??(V?_a(V):null),Ie=J?.branchLabel??n.worktree?.branch??null,Fe=c.useMemo(()=>{if(R)return null;const Ee=n.worktree?.branch?.trim(),Lt=gt(n.worktree?.path??null);return Ee&&Lt?Xo(Lt,Ee):null},[R,n.worktree]),st=Mu(Fe),lt=st?`var(--pr-${st.visualState})`:void 0,it=hs(Ee=>Ee.sessionGroupingMode),mt=!!Ie&&(ne==="recent"||it==="flat"),St=c.useMemo(()=>{if(!st)return null;switch(st.visualState){case"merged":return e("sessions.sidebar.group.pr.status.merged");case"open":return st.canMerge===!0||st.mergeableState==="clean"||st.checks?.state==="success"?e("sessions.sidebar.group.pr.status.readyToMerge"):e("sessions.sidebar.group.pr.status.open");case"blocked":return st.mergeableState==="dirty"?e("sessions.sidebar.group.pr.status.mergeConflicts"):e("sessions.sidebar.group.pr.status.mergeBlocked");case"draft":return e("sessions.sidebar.group.pr.status.draft");case"closed":return e("sessions.sidebar.group.pr.status.closed");default:return null}},[st,e]),ht=Ze(Ee=>Ee.currentSessionId===ge.id),Xe=gt(ge.directory??null)??gt(i??null),Ct=a!==void 0?a:o??Xe??null,Mt=mg(),be=Ou(),Ue=R,ut=ps(Ee=>Ee.enabled),G=ps(c.useCallback(Ee=>Ee.selectedIds.has(ge.id),[ge.id])),U=ps(Ee=>Ee.toggleSelected),Z=ps(Ee=>Ee.setRange),ke=Vf(),Te=ue??ge.id,We=y===ge.id&&S===Te,Je=c.useCallback(Ee=>{const Lt=[],Zt=ls=>{ls.children.forEach(ys=>{Lt.push(ys.session.id),Zt(ys)})};return Zt(Ee),Lt},[]),nt=c.useCallback(Ee=>{const Lt=[],Zt=ls=>{ls.children.forEach(ys=>{Lt.push(ys.session),Zt(ys)})};return Zt(Ee),Lt},[]),[rt,Ye]=c.useState(!1),[Nt,Ke]=c.useState(!0),Tt=`${ne}:${u?"archived":"active"}:${ge.id}`,Ce=ue?`session-menu:${ue}`:Tt,ft=ue?`session-context:${ue}`:null,bt=Bu(c.useCallback(Ee=>!!Ee.sessionMemoryState.get(hg(ge.id))?.isZombie,[ge.id])),Ge=Na(ge.id)?.type??"idle",Le=Ge==="busy"||Ge==="retry",pt=pg(ge.id,Le),Be=rf(ge.id),ze=Ca(ge.id,Xe),qe=Be||ze,tt=n.worktree??Ze.getState().getWorktreeMetadata(ge.id)??null,[yt,Ot]=c.useState([]),[Ht,_t]=c.useState(!1),[zt,Wt]=c.useState(!1),Jt=c.useRef(!1),es=c.useRef(0),Qt=gg(ge.id,Xe??void 0,{bootstrap:!1}),qt=xg(He),Et=qt?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(Rl[qt.status]),"aria-label":e(Rl[qt.status]),children:s.jsx(M,{name:"target",className:"h-3 w-3",style:{color:bg[qt.status]}})}):null,wt=He.title||e("sessions.sidebar.session.untitled"),cs=n.children.length>0,xs=yg(d,Xe,ge.id),ds=Tt,us=m?!0:h.has(ds),ln=c.useMemo(()=>S2(n,us,Xe),[us,n,Xe]),js=wg(ln),pn=!!He.parentID,Js=Zd(ge.id)>0&&(!pn||b),cn=He.time?.updated||He.time?.created||Date.now(),ns=Fu(cn),ks=vg(cn),Ks=L===Ce,[Vs,As]=c.useState(!1),Zs=ft?L===ft:Vs,gs=Ks||Zs,dn=c.useMemo(()=>Do(He.title)!==null,[He.title]),[xn,Nn]=c.useState(!1),en=c.useMemo(()=>Je(n).length,[Je,n]),Us=c.useCallback(async Ee=>{const Lt=[];let Zt=0;for(const ls of Ee)try{if(!Xe)throw new Error("Session directory is required for export");const ys=await Mt({directory:Xe,sessionID:ls.session.id});if(!ys)throw new Error("Session runtime changed during export");const ts=ls.session.title||e("sessions.sidebar.session.export.untitledSubagent"),tn=ls.session.agent,rs=await Us(ls.children);Zt+=rs.skipped,Lt.push({title:ts,agent:tn,records:ys,children:rs.children})}catch{Zt+=Je(ls).length+1}return{children:Lt,skipped:Zt}},[Je,Mt,Xe,e]),oe=c.useCallback(Ee=>{Ee<=0||_e.warning(Ee===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:Ee}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:Ee}))},[e]),Qe=c.useCallback(async Ee=>{if(!Xe){_e.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Lt=await Mt({directory:Xe,sessionID:ge.id}).catch(()=>null);if(!Lt){_e.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Lt.length===0){_e.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Zt,ls=0;if(Ee&&n.children.length>0){const rs=await Us(n.children);Zt=rs.children,ls=rs.skipped}const ys=cu(Lt,He.title??null,Zt),ts=du(He.title??null),tn=await uu(ys,ts);if(tn){_e.success(e("sessions.sidebar.session.export.success"),{action:{label:e(jg()),onClick:()=>{Sg(tn).then(rs=>{rs||_e.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),oe(ls);return}fu(ys,ts),_e.success(e("sessions.sidebar.session.export.success")),oe(ls)},[Us,Mt,n.children,He.title,ge.id,Xe,oe,e]),ct=mu(),kt=c.useMemo(()=>hu(ct),[ct]),$t=c.useCallback(Ee=>{nf({entry:Ee,t:e,session:{id:ge.id,title:He.title,directory:Xe},loadRecords:()=>Xe?Mt({directory:Xe,sessionID:ge.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>_e.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[Mt,He.title,ge.id,Xe,e]),Ft=c.useCallback(async()=>{if(n.children.length>0){Ke(!0),Ye(!0);return}await Qe(!1)},[Qe,n.children.length]),ot=c.useCallback(()=>{Xe&&zn("desktop_open_session_mini_chat_window",{sessionId:ge.id,directory:Xe,apiBaseUrl:En(),clientToken:Qr()}).catch(Ee=>{console.warn("[session-sidebar] failed to open mini chat window",Ee)})},[ge.id,Xe]);if(c.useEffect(()=>{if(!We)return;const Ee=Lt=>{const ls=(Lt.target instanceof HTMLElement?Lt.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(Te)}"]`);Oe.current&&!ls&&z.current(ce.current)};return document.addEventListener("mousedown",Ee),()=>document.removeEventListener("mousedown",Ee)},[We,Te]),c.useLayoutEffect(()=>{if(!We){Ne.current===Te&&(Ne.current=null);return}Ne.current!==Te&&(Ne.current=Te,we.current=!0)},[x,We,Te]),c.useLayoutEffect(()=>{if(!We||!we.current)return;const Ee=$e.current;!Ee||Ee.value!==x||(we.current=!1,Ee.focus(),Ee.select())},[x,We,ae]),We)return s.jsx("div",{style:{paddingLeft:qc+r*xo},className:"group relative my-0.5 flex items-center rounded-sm py-1 pr-1.5",children:s.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:s.jsxs("form",{ref:Oe,"data-session-rename-form":Te,className:"flex w-full items-center gap-2",onSubmit:Ee=>{Ee.preventDefault(),p(ae)},children:[s.jsx("input",{ref:$e,value:ae,onChange:Ee=>v(Ee.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:e("sessions.sidebar.session.menu.rename"),onKeyDown:Ee=>Oi(Ee,N)}),s.jsx("button",{type:"submit","aria-label":e("sessions.sidebar.session.rename.save"),title:e("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:N,"aria-label":e("sessions.sidebar.session.rename.cancel"),title:e("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]})})},ge.id);const At=Qt.length,Q=js===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:js}),Ve=k2({actionsAlwaysVisible:ee&&!R,menuOpen:gs,hideOnHoverClass:me}),at=!qe&&!Le&&Js&&!ht,Rt=Le||at,Vt=e(Le?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),Ut=s.jsx("span",{className:Me("h-1.5 w-1.5 rounded-full",Le?"bg-primary":"bg-[var(--status-info)]"),"aria-label":Vt,title:Vt}),Xt=(Le||at)&&pt,Hs=!ee&&cs&&(qe||Rt||xs),Gs=xs&&!qe&&!Rt,cr=s.jsx(M,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),xm=qe||Rt||Gs?s.jsx("span",{style:{left:pa+r*xo},className:Me("pointer-events-none absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center transition-opacity",Hs?"opacity-100 group-hover:opacity-0 group-focus-within:opacity-0":""),children:qe?s.jsx(M,{name:"loader-4",className:"h-3 w-3 animate-spin text-primary","aria-label":e(ze?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}):Rt?Ut:Gs?cr:null}):null,bm=cs&&!ee&&(qe||Rt||xs),ym=cs?s.jsx("span",{role:"button",tabIndex:0,onClick:Ee=>{Ee.stopPropagation(),Ee.currentTarget.blur(),C(ds)},onKeyDown:Ee=>{(Ee.key==="Enter"||Ee.key===" ")&&(Ee.preventDefault(),Ee.stopPropagation(),C(ds))},style:{minWidth:14,minHeight:14,left:pa+r*xo},className:Me("absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",bm?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto":""),"aria-label":e(us?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:us?s.jsx(M,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(M,{name:"arrow-right-s",className:"h-3 w-3"})}):null,rl=bt?s.jsx(M,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,wm=Ee=>{if(Ee){As(!1),W(Ce);return}!se.current&&L===Ce&&W(null)},ol=Ee=>{if(!Ee&&se.current){const{id:Lt,title:Zt}=se.current;se.current=null,w(Lt),f(Te),v(Zt)}!Ee&&(L===Ce||L===ft)&&W(null)},vm=Ee=>{if(!ft){As(Ee);return}Ee?W(ft):!se.current&&L===ft&&W(null)},Sm=Ee=>{Ee.preventDefault(),Ee.stopPropagation(),W(Ks?null:Ce)},jm=Ee=>{Ee.preventDefault(),Ee.stopPropagation()},km=Ee=>{Ee.preventDefault(),Ee.stopPropagation()},Cm=Ee=>{Ee.preventDefault(),Ee.stopPropagation()},Nm=Ee=>{Ee.preventDefault(),Ee.stopPropagation()},Am=Ee=>{Ee.preventDefault(),Ee.stopPropagation(),W(null),$(ge,{archivedBucket:u})},Dm=Ee=>{Ee.preventDefault(),Ee.stopPropagation(),W(null),$(ge,{archivedBucket:u,hardDelete:!0,skipConfirm:!0})},Pm=Ee=>{Ee.preventDefault(),Ee.stopPropagation()},Im=Ee=>{Ee.preventDefault(),Ee.stopPropagation()},Tm=Ee=>{Ee.preventDefault(),Ee.stopPropagation(),ie?.vscode?.executeCommand("openchamber.openSessionInEditor",ge.id,wt)},il=Ee=>{if(he.current){he.current=!1;return}if(ut){if(Ee?.preventDefault(),Ee?.stopPropagation(),Ee?.shiftKey){const Lt=ke?.getEntries(),Zt=Lt??Array.from(document.querySelectorAll("[data-session-row]")).map(ts=>ts.getAttribute("data-session-row")).filter(ts=>!!ts).map(ts=>({id:ts,rowKey:ts,scopeKey:Ct,archived:u})),ls=Lt?ps.getState().anchorRowKey:ps.getState().anchorId,ys=new Map;ys.set(ge.id,Je(n)),Z(ls,Te,Zt,ke?.getDescendantIds()??[],Ct,ys);return}U(ge.id,Ct,Je(n),Te);return}Ee?.currentTarget&&ak(Ee.currentTarget),k(ge.id,Xe)},Em=Ee=>{Ee.defaultPrevented||(Ee.target instanceof HTMLElement?Ee.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||il(Ee)},Rm=Ee=>{(Ee.button===2||Ee.button===0&&Ee.ctrlKey&&!ut)&&(he.current=!0)},Mm=Ee=>{K&&Ee.pointerType==="touch"&&Re(!0),Ee.button===0&&!ht&&!ut&&!Ue&&Xe&&!Ui(ge.id,Xe).renderable&&be({directory:Xe,sessionID:ge.id}).catch(()=>{})},al=Ee=>{K&&Ee.pointerType==="touch"&&Re(!1)},Om=Ee=>{Jt.current=Ee,es.current+=1;const Lt=es.current;if(!Ee){_t(!1),Wt(!1);return}const Zt=E({projectId:o??null,sourceDirectory:Xe,currentWorktree:tt});Ot(Zt.cachedTargets),_t(!0),Wt(!1),Zt.refreshTargets.then(ls=>{!Jt.current||es.current!==Lt||(Ot(ls),_t(!1),Wt(!1))}).catch(()=>{!Jt.current||es.current!==Lt||(_t(!1),Wt(!0))})},ll=({Item:Ee,Separator:Lt,Sub:Zt,SubTrigger:ls,SubContent:ys})=>s.jsxs(s.Fragment,{children:[s.jsxs(Ee,{onClick:()=>{se.current={id:ge.id,title:wt}},className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsx(Zi,{sessionID:ge.id,directory:Xe,open:gs,Item:Ee}),s.jsxs(Ee,{onClick:()=>T(ge.id),className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]}),s.jsxs(Ee,{onClick:()=>Xe&&fe({directory:Xe,sessionId:ge.id}),className:"[&>svg]:mr-1",children:[xs?s.jsx(M,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(M,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(xs?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),He.share?s.jsxs(s.Fragment,{children:[s.jsx(Ee,{onClick:()=>{He.share?.url&&P(He.share.url,ge.id)},className:"[&>svg]:mr-1",children:A===ge.id?s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"check",className:"mr-1 h-4 w-4",style:{color:"var(--status-success)"}}),e("sessions.sidebar.session.menu.copied")]}):s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyLink")]})}),s.jsxs(Ee,{onClick:()=>_(ge.id),className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"link-unlink-m",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Ee,{onClick:()=>I(He),className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"share-2",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.share")]}),s.jsxs(Ee,{onClick:()=>{Ft()},className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),kt.map(ts=>s.jsxs(Ee,{onClick:()=>$t(ts),className:"[&>svg]:mr-1",children:[s.jsx(to,{icon:ts.icon,iconSrc:ts.iconSrc,className:"mr-1 size-4"}),ts.action.label]},`${ts.guest.id}:${ts.action.id}`)),w2({isSubtaskSession:pn,archivedBucket:!!u,isVSCode:R,sessionDirectory:Xe})?(()=>{const ts=v2({sessionDirectory:Xe,isStreaming:Le,isMovingToWorktree:Be}),tn=ok({targets:yt,isRefreshing:Ht,loadFailed:zt});return s.jsxs(Zt,{onOpenChange:Om,children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsxs(ls,{disabled:ts,className:"w-full [&>svg]:mr-1","data-session-worktree-submenu-trigger":ge.id,children:[s.jsx(M,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]})}),s.jsx(It,{side:"right",className:"max-w-72",children:e(Be?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Le?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltipTargets")})]}),s.jsxs(ys,{className:"min-w-[220px]","data-session-worktree-submenu":ge.id,children:[yt.map(rs=>{const sn=gt(rs.metadata.path??null)??rs.metadata.path,Ir=rs.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):rs.metadata.label||rs.metadata.branch||rs.metadata.name||rs.metadata.path,bs=rs.isCurrent||rs.metadata.worktreeStatus!=="ready";return s.jsxs(Ee,{disabled:bs,title:rs.metadata.path,"data-session-worktree-target":sn,onClick:()=>{bs||!Xe||sa({kind:"existing",root:He,descendants:nt(n),sourceDirectory:Xe,destination:rs.metadata,messages:ea(e,{success:"sessions.sidebar.session.moveToWorktree.existingSuccess",failure:"sessions.sidebar.session.moveToWorktree.existingFailed"})})},children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate",children:[s.jsx("span",{className:"truncate",children:Ir}),rs.isCurrent?s.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),rs.isCurrent?s.jsx(M,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},sn)}),tn.refreshState==="loading"?s.jsx(Ee,{disabled:!0,"data-session-worktree-refresh-state":"loading",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.refreshing")}):null,tn.refreshState==="error"?s.jsx(Ee,{disabled:!0,"data-session-worktree-refresh-state":"error",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.loadFailed")}):null,s.jsx(Lt,{}),s.jsxs(Ee,{disabled:ts,"data-session-worktree-new-action":"true",onClick:()=>{ts||!Xe||sa({kind:"quick",root:He,descendants:nt(n),sourceDirectory:Xe,messages:ea(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,dn?s.jsxs(Ee,{onClick:()=>Nn(!0),className:"[&>svg]:mr-1",children:[s.jsx(ek,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.runFusion")]}):null,Xe&&!u?(()=>{const ts=[],tn=bs=>{const Cs=gt(bs??null);Cs&&!ts.includes(Cs)&&ts.push(Cs)};if(o&&!R){const bs=Gt.getState().projects.find(dr=>dr.id===o),Cs=gt(bs?.path??null);tn(Cs),Cs&&(Ze.getState().availableWorktreesByProject.get(Cs)??[]).forEach(dr=>tn(dr.path))}tn(Oa(Xe)),tn(Xe);const rs=ts.flatMap(bs=>je(bs).map(Cs=>({scope:bs,folder:Cs}))),sn=rs.find(({scope:bs,folder:Cs})=>ve(bs,ge.id)===Cs.id)??null,Ir=ts[0]??Xe;return s.jsxs(s.Fragment,{children:[s.jsx(Lt,{}),s.jsxs(Zt,{children:[s.jsxs(ls,{className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),s.jsxs(ys,{className:"min-w-[180px]",children:[rs.length===0?s.jsx(Ee,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):rs.map(({scope:bs,folder:Cs})=>{const dr=sn?.folder.id===Cs.id;return s.jsxs(Ee,{onClick:()=>{if(dr){ye(bs,ge.id);return}sn&&sn.scope!==bs&&ye(sn.scope,ge.id),Pe(bs,Cs.id,ge.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:Cs.name}),dr?s.jsx(M,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},Cs.id)}),s.jsx(Lt,{}),s.jsxs(Ee,{onClick:()=>{const bs=O(Ir);bs&&(q.current=!0,sn&&sn.scope!==Ir&&ye(sn.scope,ge.id),Pe(Ir,bs.id,ge.id))},children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),sn?s.jsxs(Ee,{onClick:()=>{ye(sn.scope,ge.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(M,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,R?null:s.jsxs(Ee,{disabled:!Xe,onClick:()=>{Xe&&xe(Xe,{mode:"chat",dedupeKey:`session:${ge.id}`,label:wt,sessionTitleFallback:wt})},className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"chat-4",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")}),s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:e("sessions.sidebar.session.menu.betaBadge")})]}),Y?s.jsxs(Ee,{disabled:!Xe,onClick:ot,className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(Lt,{}),u?null:s.jsxs(Ee,{className:"[&>svg]:mr-1",onClick:()=>$(ge,{archivedBucket:u}),children:[s.jsx(M,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),u?s.jsxs(Ee,{className:"[&>svg]:mr-1",onClick:()=>j(ge),children:[s.jsx(M,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]}):null,s.jsxs(Ee,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>$(ge,{archivedBucket:u,hardDelete:!0}),children:[s.jsx(M,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),Bm=s.jsx($s,{align:"end",className:"min-w-[180px]",finalFocus:()=>q.current?(q.current=!1,!1):!le.current,children:ll({Item:Kt,Separator:Rs,Sub:Cg,SubTrigger:Ng,SubContent:Ag})}),Fm=s.jsx(Yi,{children:s.jsx(Qi,{className:"app-region-no-drag z-50",children:s.jsx(Xi,{"data-slot":"dropdown-menu-content",finalFocus:()=>q.current?(q.current=!1,!1):!le.current,style:{color:"var(--surface-elevated-foreground)"},className:Me(Fi,"min-w-[180px]"),children:ll({Item:({className:Ee,...Lt})=>s.jsx(qu,{className:Me(tu,Ee),...Lt}),Separator:({className:Ee,...Lt})=>s.jsx(Gu,{className:Me(eu,Ee),...Lt}),Sub:sb,SubTrigger:({className:Ee,children:Lt,...Zt})=>s.jsxs(nb,{className:Me(kg,Ee),...Zt,children:[Lt,s.jsx(M,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:Ee,children:Lt,...Zt})=>s.jsx(Yi,{children:s.jsx(Qi,{className:"app-region-no-drag z-50",children:s.jsx(Xi,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Me(Fi,Ee),...Zt,children:Lt})})})})})})});return s.jsxs(c.Fragment,{children:[s.jsx(g2,{sessionId:ge.id,dragKey:X??Te,ownerKey:l??Ct,sessionDirectory:Xe??null,sessionTitle:wt,archivedBucket:u,children:s.jsxs(Qu,{open:Zs,onOpenChange:vm,onOpenChangeComplete:ol,children:[s.jsxs(Yu,{render:s.jsx("div",{"data-session-row":ge.id,"data-session-scope":Ct??"","data-session-archived":u?"1":"0","aria-current":ht?"page":void 0,onClick:Em,style:{paddingLeft:qc+r*xo},className:Me("group relative my-0.5 flex cursor-pointer items-center rounded-md py-1 pr-1.5",(ht||G)&&"bg-interactive-selection text-interactive-selection-foreground",G&&"ring-1 ring-inset ring-border")}),children:[xm,ym,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button","aria-pressed":ut?G:void 0,onPointerDown:Mm,onPointerUp:al,onPointerCancel:al,onMouseDown:Rm,onClick:Ee=>il(Ee),onDoubleClick:Ee=>{Ee.stopPropagation(),D(ge.id,wt)},className:Me("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring text-foreground select-none transition-[padding]",Se&&"bg-interactive-hover/70",ee?R?de:B:gs?F:de),children:s.jsxs("div",{className:"flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",children:[s.jsx("div",{className:Me("block min-w-0 flex-1 truncate typography-ui-label font-normal",ht||G?"text-interactive-selection-foreground":Js?"text-foreground":"text-foreground/80"),children:jo(wt,g)}),!u&&Xe&&(ne==="recent"||it==="flat"&&n.worktree&&gt(n.worktree.path)!==gt(n.worktree.projectDirectory))?s.jsx(Wo,{directory:Xe,className:ee?void 0:gs?"mr-1":R?"group-hover:mr-1":"group-hover:mr-1 group-focus-within:mr-1"}):null,ee?s.jsx("span",{className:"ml-2 inline-flex flex-shrink-0 items-center gap-1 typography-micro text-muted-foreground/75",children:Xt?s.jsx(yl,{sessionId:ge.id,running:Le}):s.jsxs(s.Fragment,{children:[Et,mt?s.jsx(M,{name:"git-branch",className:Me("h-3 w-3",!lt&&"text-muted-foreground/60"),style:lt?{color:lt}:void 0}):null,ks]})}):Xt||Et||mt||ne==="recent"?s.jsx("div",{className:Me("relative ml-1 flex h-4 flex-shrink-0 items-center justify-end",gs?"hidden":R?"group-hover:hidden":"group-hover:hidden group-focus-within:hidden"),children:s.jsx("span",{className:"inline-flex items-center gap-1 whitespace-nowrap text-right",children:Xt?s.jsx(yl,{sessionId:ge.id,running:Le,className:"typography-micro"}):s.jsxs(s.Fragment,{children:[Et,mt?s.jsx(M,{name:"git-branch",className:Me("h-3 w-3",!lt&&"text-muted-foreground/60"),style:lt?{color:lt}:void 0}):null,ne==="recent"?s.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:ks}):null]})})}):null,At>0?s.jsxs("span",{className:Me("inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",Ve),title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(M,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:At})]}):null,js>0?s.jsxs("span",{className:Me("inline-flex items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info flex-shrink-0",Ve),title:Q,"aria-label":Q,children:[s.jsx(M,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:js})]}):null]})})}),R?null:s.jsx(It,{side:"right",sideOffset:8,className:"max-w-xs text-left",children:s.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-left text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:wt}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:ns,children:ks})]}),Ae?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(M,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:Ae})]}):null,Ie?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(M,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:lt?{color:lt}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:Ie})]}):null,st&&St?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(M,{name:"git-pull-request",className:"h-3 w-3 flex-shrink-0",style:lt?{color:lt}:void 0}),s.jsxs("span",{className:"min-w-0 truncate",style:lt?{color:lt}:void 0,children:["#",st.number," · ",St]})]}):null]})})]})}),rl&&!K?s.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 z-10",children:rl}):null,s.jsxs("div",{className:Me("absolute right-0 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",gs||ee&&!R?"opacity-100":Me("opacity-0",H)),children:[re?s.jsx(lk,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:ee?"h-6 w-6":"h-4 w-4",iconSizeClass:ee?"h-3.5 w-3.5":"h-2.5 w-2.5",onPointerDown:Cm,onMouseDown:Nm,onArchive:Am,onDelete:Dm}):null,pe?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",className:Me("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",ee?"h-6 w-6":"h-4 w-4"),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:Pm,onMouseDown:Im,onClick:Tm,onKeyDown:Ee=>Ee.stopPropagation(),children:s.jsx(M,{name:"external-link",className:Me(ee?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),s.jsx(It,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs(zs,{open:Ks,onOpenChange:wm,onOpenChangeComplete:ol,children:[s.jsx(Ls,{asChild:!0,children:s.jsx("button",{type:"button",className:Me("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",ee?"h-6 w-6 opacity-100":gs?"h-4 w-4 opacity-100":Me("h-4 w-4 opacity-0",H)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:jm,onMouseDown:km,onClick:Sm,onKeyDown:Ee=>Ee.stopPropagation(),children:s.jsx(M,{name:"more-2",className:Me(ee?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),Bm]})]})]}),Fm]})}),cs&&us?te:null,s.jsx(vs,{open:rt,onOpenChange:Ye,children:s.jsxs(Ss,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(Ts,{children:en===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:en}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:en})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Nt,onChange:Ee=>Ke(Ee.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(Sn,{children:[s.jsx(dt,{type:"button",onClick:()=>Ye(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{type:"button",onClick:()=>{Ye(!1),Qe(Nt)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})}),dn?s.jsx(Z2,{session:He,open:xn,onOpenChange:Nn}):null]},ge.id)}const Yc=t=>gt(t.session.directory??null),dk=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),uk=t=>{if(!t.openSidebarMenuKey)return null;if(t.rowKey&&(t.openSidebarMenuKey===`session-menu:${t.rowKey}`||t.openSidebarMenuKey===`session-context:${t.rowKey}`))return t.node.session.id;const e=t.archivedBucket?"archived":"active",n=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(n)?t.openSidebarMenuKey.slice(n.length):null},Qc=t=>t.menuOpenSessionId??uk(t),bo=(t,e,n)=>e?n.has(t.node.session.id)?!0:$n(t.node,e):!1,ga=(t,e,n,r,i)=>{if(t.session.id!==e.session.id)return!0;const o=i(t);if(n.has(o)!==r.has(o)||t.children.length!==e.children.length)return!0;for(let l=0;l<t.children.length;l+=1)if(ga(t.children[l],e.children[l],n,r,i))return!0;return!1},fk=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return ga(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${t.renderContext??"project"}:${n}:${i.session.id}`)||ga(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${e.renderContext??"project"}:${r}:${i.session.id}`)},mk=(t,e)=>t.id===e.id&&t.title===e.title&&t.directory===e.directory&&t.parentID===e.parentID&&t.share?.url===e.share?.url&&t.time?.created===e.time?.created&&t.time?.updated===e.time?.updated&&t.time?.archived===e.time?.archived,hk=(t,e)=>{if(t.node.session.id!==e.node.session.id||!mk(t.node.session,e.node.session)||!ik(t.node,e.node))return"node";if(t.depth!==e.depth)return"depth";if(t.groupDirectory!==e.groupDirectory)return"groupDirectory";if(t.projectId!==e.projectId)return"projectId";if(t.archivedBucket!==e.archivedBucket)return"archivedBucket";if((t.renderContext??"project")!==(e.renderContext??"project"))return"renderContext";if(t.mobileVariant!==e.mobileVariant)return"mobileVariant";if(t.alwaysShowActions!==e.alwaysShowActions)return"alwaysShowActions";if(t.hasSessionSearchQuery!==e.hasSessionSearchQuery)return"hasSessionSearchQuery";if(t.normalizedSessionSearchQuery!==e.normalizedSessionSearchQuery)return"normalizedSessionSearchQuery";if(t.notifyOnSubtasks!==e.notifyOnSubtasks)return"notifyOnSubtasks";if(t.nodeStructureKey!==e.nodeStructureKey)return"nodeStructureKey";if(t.relativeTimeTick!==e.relativeTimeTick)return"relativeTimeTick";if(Yc(t.node)!==Yc(e.node))return"nodeDirectory";if(!dk(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&qf(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&fk(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(bo(t,t.editingId,t.subtreeContainsEditing)||bo(e,e.editingId,e.subtreeContainsEditing)))return"editingId";if(t.editingRowKey!==e.editingRowKey&&(t.editingRowKey===t.rowKey||e.editingRowKey===e.rowKey))return"editingRowKey";if(t.editTitle!==e.editTitle&&(bo(t,t.editingId,t.subtreeContainsEditing)||bo(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.copiedSessionId!==e.copiedSessionId&&($n(t.node,t.copiedSessionId)||$n(e.node,e.copiedSessionId)))return"copiedSessionId";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=Qc(t),i=Qc(e);if($n(t.node,r)||$n(e.node,i))return"openSidebarMenuKey"}return t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&t.setEditTitle===e.setEditTitle&&t.handleSaveEdit===e.handleSaveEdit&&t.handleCancelEdit===e.handleCancelEdit&&t.toggleParent===e.toggleParent&&t.handleSessionSelect===e.handleSessionSelect&&t.handleSessionDoubleClick===e.handleSessionDoubleClick&&t.handleShareSession===e.handleShareSession&&t.handleCopyShareUrl===e.handleCopyShareUrl&&t.handleCopySessionId===e.handleCopySessionId&&t.handleUnshareSession===e.handleUnshareSession&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.handleDeleteSession===e.handleDeleteSession&&t.handleRestoreSession===e.handleRestoreSession&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.children===e.children?null:"callbacks"},pk=(t,e)=>{const n=hk(t,e);return n===null?!0:(Qs(`ui.sidebar_session_node.props_changed.${n}`),!1)},gk=c.memo(ck,pk);function xk(t){return t.stopPropagation()}const bk=t=>{const{t:e}=vt(),n=c.useRef(null),r=c.useRef(t.editingId),i=c.useRef(t.editTitle),o=c.useRef(t.deleteSessionConfirm);r.current=t.editingId,i.current=t.editTitle,o.current=t.deleteSessionConfirm;const l=De(te=>te.setSessionSwitcherOpen),a=Ze(te=>te.setCurrentSession),u=Ze(te=>te.updateSessionTitle),d=Ze(te=>te.shareSession),h=Ze(te=>te.unshareSession),m=Ze(te=>te.deleteSession),g=Ze(te=>te.deleteSessions),b=Ze(te=>te.archiveSession),y=Ze(te=>te.archiveSessions),S=Ze(te=>te.unarchiveSession),{mobileVariant:w,allowReselect:f,onSessionSelected:x,resetSessionSearch:v,descendantIds:p,showDeletionDialog:N,setDeleteSessionConfirm:C,setEditingId:k,setEditingRowKey:D,editingSessionId:I,editingOccurrenceKey:A,setEditTitle:P,setCopiedSessionId:T}=t;c.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]);const _=c.useCallback((te,fe)=>{if(Ri("navigation.session_select"),De.getState().closeMainSurfaces(),w&&l(!1),te===Ze.getState().currentSessionId){f&&x?.(te),v();return}Ri("navigation.session_state_set"),a(te,fe??null),x?.(te),v()},[f,w,x,v,a,l]),L=c.useCallback((te,fe)=>{k(te),D(A),P(fe)},[A,P,k,D]),W=c.useCallback(async te=>{if(!r.current)return;const je=(te??i.current).trim();je&&await u(I,je),k(null),D(null),P("")},[I,P,k,D,u]),O=c.useCallback(()=>{k(null),D(null),P("")},[P,k,D]),$=c.useCallback(async(te,fe)=>{try{return(await wn(te)).ok?(T(fe),n.current&&clearTimeout(n.current),n.current=window.setTimeout(()=>{T(null),n.current=null},2e3),!0):!1}catch{return!1}},[T]),j=c.useCallback(async te=>{const fe=await d(te.id);if(!fe?.share?.url){_e.error(e("sessions.sidebar.session.share.error"));return}const je=await $(fe.share.url,te.id);_e[je?"success":"warning"](e("sessions.sidebar.session.share.successTitle"),{description:e(je?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")})},[$,d,e]),E=c.useCallback((te,fe)=>{$(te,fe).then(je=>{je||_e.error(e("sessions.sidebar.session.share.copyUrlError"))})},[$,e]),K=c.useCallback(te=>{wn(te).then(fe=>{if(fe.ok){_e.success(e("sessions.sidebar.session.copyId.success"));return}_e.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(e("sessions.sidebar.session.copyId.error")))},[e]),ee=c.useCallback(async te=>{await h(te)?_e.success(e("sessions.sidebar.session.unshare.success")):_e.error(e("sessions.sidebar.session.unshare.error"))},[e,h]),J=c.useCallback(async(te,fe,je)=>{const ve=fe?.archivedBucket===!0||fe?.hardDelete===!0,ye=je?.descendantIds??p;await Mh(ve?"delete":"archive",te,ye,{archiveSession:b,archiveSessions:y,deleteSession:m,deleteSessions:g},e)},[b,y,m,g,p,e]),ne=c.useCallback((te,fe)=>{const je=fe?.archivedBucket===!0||fe?.hardDelete===!0,ve=Kd(te.id,p,je);if(!N||fe?.skipConfirm===!0){J(te,fe,{descendantIds:ve});return}C({session:te,descendantCount:ve.length,descendantIds:ve,archivedBucket:je})},[p,J,C,N]),ue=c.useCallback(async()=>{const te=o.current;if(!te)return;const{session:fe,archivedBucket:je,descendantIds:ve}=te;C(null),await J(fe,{archivedBucket:je},{descendantIds:ve})},[J,C]),X=c.useCallback(async te=>{await S(te.id)?_e.success(e("sessions.sidebar.session.restore.success")):_e.error(e("sessions.sidebar.session.restore.error"))},[e,S]);return c.useMemo(()=>({handleSessionSelect:_,handleSessionDoubleClick:L,handleSaveEdit:W,handleCancelEdit:O,handleShareSession:j,handleCopyShareUrl:E,handleCopySessionId:K,handleUnshareSession:ee,handleDeleteSession:ne,handleRestoreSession:X,confirmDeleteSession:ue}),[O,K,E,ne,X,W,L,_,j,ee,ue])};function yk(t){const e=et.c(71),{t:n}=vt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t;let u,d,h,m,g,b,y,S,w,f;if(e[0]!==i||e[1]!==n||e[2]!==r){const E=n("sessions.sidebar.session.untitled");m=vs,w=!!r,e[13]!==i?(f=ee=>{ee||i(null)},e[13]=i,e[14]=f):f=e[14],h=Ss,y=!1,S="max-w-sm gap-5",d=Ws;let K;e[15]!==n||e[16]!==r?.archivedBucket?(K=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=K):K=e[17],e[18]!==K?(b=s.jsx(Is,{children:K}),e[18]=K,e[19]=b):b=e[19],u=Ts,g=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||E,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||E,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||E,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||E,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||E}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||E}),e[0]=i,e[1]=n,e[2]=r,e[3]=u,e[4]=d,e[5]=h,e[6]=m,e[7]=g,e[8]=b,e[9]=y,e[10]=S,e[11]=w,e[12]=f}else u=e[3],d=e[4],h=e[5],m=e[6],g=e[7],b=e[8],y=e[9],S=e[10],w=e[11],f=e[12];let x;e[20]!==u||e[21]!==g?(x=s.jsx(u,{children:g}),e[20]=u,e[21]=g,e[22]=x):x=e[22];let v;e[23]!==d||e[24]!==b||e[25]!==x?(v=s.jsxs(d,{children:[b,x]}),e[23]=d,e[24]=b,e[25]=x,e[26]=v):v=e[26];let p;e[27]!==l||e[28]!==o?(p=()=>l(!o),e[27]=l,e[28]=o,e[29]=p):p=e[29];const N=!o;let C;e[30]!==o?(C=o?s.jsx(M,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(M,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=o,e[31]=C):C=e[31];let k;e[32]!==n?(k=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=k):k=e[33];let D;e[34]!==C||e[35]!==k||e[36]!==p||e[37]!==N?(D=s.jsxs("button",{type:"button",onClick:p,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":N,children:[C,k]}),e[34]=C,e[35]=k,e[36]=p,e[37]=N,e[38]=D):D=e[38];let I;e[39]!==i?(I=()=>i(null),e[39]=i,e[40]=I):I=e[40];let A;e[41]!==n?(A=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=A):A=e[42];let P;e[43]!==I||e[44]!==A?(P=s.jsx("button",{type:"button",onClick:I,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:A}),e[43]=I,e[44]=A,e[45]=P):P=e[45];let T;e[46]!==a?(T=()=>{a()},e[46]=a,e[47]=T):T=e[47];let _;e[48]!==n||e[49]!==r?.archivedBucket?(_=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=_):_=e[50];let L;e[51]!==T||e[52]!==_?(L=s.jsx("button",{type:"button",onClick:T,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:_}),e[51]=T,e[52]=_,e[53]=L):L=e[53];let W;e[54]!==P||e[55]!==L?(W=s.jsxs("div",{className:"flex items-center gap-2",children:[P,L]}),e[54]=P,e[55]=L,e[56]=W):W=e[56];let O;e[57]!==D||e[58]!==W?(O=s.jsxs(Sn,{className:"w-full sm:items-center sm:justify-between",children:[D,W]}),e[57]=D,e[58]=W,e[59]=O):O=e[59];let $;e[60]!==h||e[61]!==y||e[62]!==O||e[63]!==S||e[64]!==v?($=s.jsxs(h,{showCloseButton:y,className:S,children:[v,O]}),e[60]=h,e[61]=y,e[62]=O,e[63]=S,e[64]=v,e[65]=$):$=e[65];let j;return e[66]!==m||e[67]!==$||e[68]!==w||e[69]!==f?(j=s.jsx(m,{open:w,onOpenChange:f,children:$}),e[66]=m,e[67]=$,e[68]=w,e[69]=f,e[70]=j):j=e[70],j}function wk(t){const e=et.c(57),{t:n}=vt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t,u=r?.archivedBucket===!0,d=r?.sessionCount??0;let h;e[0]!==u||e[1]!==d||e[2]!==n?(h=n(u?d===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":d===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=u,e[1]=d,e[2]=n,e[3]=h):h=e[3];const m=h;let g;e[4]!==u||e[5]!==d||e[6]!==n?(g=u?d===1?n("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:d}):n("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:d}):d===1?n("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:d}):n("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:d}),e[4]=u,e[5]=d,e[6]=n,e[7]=g):g=e[7];const b=g,y=!!r;let S;e[8]!==i?(S=j=>{j||i(null)},e[8]=i,e[9]=S):S=e[9];let w;e[10]!==m?(w=s.jsx(Is,{children:m}),e[10]=m,e[11]=w):w=e[11];let f;e[12]!==b?(f=s.jsx(Ts,{children:b}),e[12]=b,e[13]=f):f=e[13];let x;e[14]!==w||e[15]!==f?(x=s.jsxs(Ws,{children:[w,f]}),e[14]=w,e[15]=f,e[16]=x):x=e[16];let v;e[17]!==l||e[18]!==o?(v=()=>l(!o),e[17]=l,e[18]=o,e[19]=v):v=e[19];const p=!o;let N;e[20]!==o?(N=o?s.jsx(M,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(M,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=o,e[21]=N):N=e[21];let C;e[22]!==n?(C=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=C):C=e[23];let k;e[24]!==C||e[25]!==v||e[26]!==p||e[27]!==N?(k=s.jsxs("button",{type:"button",onClick:v,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":p,children:[N,C]}),e[24]=C,e[25]=v,e[26]=p,e[27]=N,e[28]=k):k=e[28];let D;e[29]!==i?(D=()=>i(null),e[29]=i,e[30]=D):D=e[30];let I;e[31]!==n?(I=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=I):I=e[32];let A;e[33]!==D||e[34]!==I?(A=s.jsx("button",{type:"button",onClick:D,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:I}),e[33]=D,e[34]=I,e[35]=A):A=e[35];let P;e[36]!==a?(P=()=>{a()},e[36]=a,e[37]=P):P=e[37];let T;e[38]!==u||e[39]!==n?(T=n(u?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=u,e[39]=n,e[40]=T):T=e[40];let _;e[41]!==P||e[42]!==T?(_=s.jsx("button",{type:"button",onClick:P,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:T}),e[41]=P,e[42]=T,e[43]=_):_=e[43];let L;e[44]!==A||e[45]!==_?(L=s.jsxs("div",{className:"flex items-center gap-2",children:[A,_]}),e[44]=A,e[45]=_,e[46]=L):L=e[46];let W;e[47]!==k||e[48]!==L?(W=s.jsxs(Sn,{className:"w-full sm:items-center sm:justify-between",children:[k,L]}),e[47]=k,e[48]=L,e[49]=W):W=e[49];let O;e[50]!==W||e[51]!==x?(O=s.jsxs(Ss,{showCloseButton:!1,className:"max-w-sm gap-5",children:[x,W]}),e[50]=W,e[51]=x,e[52]=O):O=e[52];let $;return e[53]!==y||e[54]!==O||e[55]!==S?($=s.jsx(vs,{open:y,onOpenChange:S,children:O}),e[53]=y,e[54]=O,e[55]=S,e[56]=$):$=e[56],$}function em(t){const e=et.c(36),{t:n}=vt(),{value:r,setValue:i,onConfirm:o}=t,l=!!r;let a;e[0]!==i?(a=N=>{N||i(null)},e[0]=i,e[1]=a):a=e[1];let u;e[2]!==n?(u=n("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=n,e[3]=u):u=e[3];let d;e[4]!==u?(d=s.jsx(Is,{children:u}),e[4]=u,e[5]=d):d=e[5];let h;e[6]!==n||e[7]!==r?(h=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):n("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=n,e[7]=r,e[8]=h):h=e[8];let m;e[9]!==h?(m=s.jsx(Ts,{children:h}),e[9]=h,e[10]=m):m=e[10];let g;e[11]!==d||e[12]!==m?(g=s.jsxs(Ws,{children:[d,m]}),e[11]=d,e[12]=m,e[13]=g):g=e[13];let b;e[14]!==i?(b=()=>i(null),e[14]=i,e[15]=b):b=e[15];let y;e[16]!==n?(y=n("sessions.sidebar.dialogs.cancel"),e[16]=n,e[17]=y):y=e[17];let S;e[18]!==b||e[19]!==y?(S=s.jsx("button",{type:"button",onClick:b,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:y}),e[18]=b,e[19]=y,e[20]=S):S=e[20];let w;e[21]!==n?(w=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=w):w=e[22];let f;e[23]!==o||e[24]!==w?(f=s.jsx("button",{type:"button",onClick:o,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:w}),e[23]=o,e[24]=w,e[25]=f):f=e[25];let x;e[26]!==f||e[27]!==S?(x=s.jsxs(Sn,{children:[S,f]}),e[26]=f,e[27]=S,e[28]=x):x=e[28];let v;e[29]!==x||e[30]!==g?(v=s.jsxs(Ss,{showCloseButton:!1,className:"max-w-sm gap-5",children:[g,x]}),e[29]=x,e[30]=g,e[31]=v):v=e[31];let p;return e[32]!==l||e[33]!==a||e[34]!==v?(p=s.jsx(vs,{open:l,onOpenChange:a,children:v}),e[32]=l,e[33]=a,e[34]=v,e[35]=p):p=e[35],p}const vk=new Set;function Ho(t){const e=et.c(120),{node:n,depth:r,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:u,secondaryMeta:d,renderContext:h,rowKey:m,dragKey:g,renderExtras:b,pinnedSessionIds:y,expandedParents:S,hasSessionSearchQuery:w,normalizedSessionSearchQuery:f,notifyOnSubtasks:x,editingId:v,editingRowKey:p,setEditingId:N,setEditingRowKey:C,editTitle:k,setEditTitle:D,toggleParent:I,openSidebarMenuKey:A,setOpenSidebarMenuKey:P,allowReselect:T,onSessionSelected:_,resetSessionSearch:L,deleteSessionConfirm:W,setDeleteSessionConfirm:O,startFolderRename:$,copiedSessionId:j,setCopiedSessionId:E,startSessionWorktreeMenuLoad:K,mobileVariant:ee,alwaysShowActions:J,renderChildren:ne}=t,ue=r===void 0?0:r,X=u===void 0?!1:u,te=h===void 0?"project":h,fe=ne===void 0?!0:ne,je=m??`${te}:${X?"archived":"active"}:${n.session.id}`,ve=ss(Ck),ye=ss(kk),Pe=De(jk),xe=De(Sk);let R;if(e[0]!==n){R=[];const $e=Oe=>Oe.children.forEach(ge=>{R.push(ge.session.id),$e(ge)});$e(n),e[0]=n,e[1]=R}else R=e[1];const Y=R.join(`
888
- `);let ie;e[2]!==Y?(ie=Y?Y.split(`
889
- `):[],e[2]=Y,e[3]=ie):ie=e[3];const H=ie;let me;e[4]!==ve||e[5]!==$||e[6]!==ye?(me=($e,Oe)=>{if(!$e)return null;Oe&&ss.getState().collapsedFolderIds.has(Oe)&&ye(Oe);const ge=ve($e,"New folder",Oe);return $($e,ge),ge},e[4]=ve,e[5]=$,e[6]=ye,e[7]=me):me=e[7];const pe=me;let re;e[8]!==T||e[9]!==j||e[10]!==W||e[11]!==H||e[12]!==k||e[13]!==v||e[14]!==je||e[15]!==ee||e[16]!==n.session.id||e[17]!==_||e[18]!==L||e[19]!==E||e[20]!==O||e[21]!==D||e[22]!==N||e[23]!==C||e[24]!==Pe?(re={mobileVariant:ee,allowReselect:T,onSessionSelected:_,resetSessionSearch:L,descendantIds:H,showDeletionDialog:Pe,setDeleteSessionConfirm:O,deleteSessionConfirm:W,editingId:v,setEditingId:N,setEditingRowKey:C,editingSessionId:n.session.id,editingOccurrenceKey:je,editTitle:k,setEditTitle:D,copiedSessionId:j,setCopiedSessionId:E},e[8]=T,e[9]=j,e[10]=W,e[11]=H,e[12]=k,e[13]=v,e[14]=je,e[15]=ee,e[16]=n.session.id,e[17]=_,e[18]=L,e[19]=E,e[20]=O,e[21]=D,e[22]=N,e[23]=C,e[24]=Pe,e[25]=re):re=e[25];const de=bk(re),B=b?.childRenderExtrasFor,F=n.session.directory??i;let he;e[26]!==X||e[27]!==o||e[28]!==te||e[29]!==F?(he={groupDirectory:F,projectId:o,archivedBucket:X,renderContext:te},e[26]=X,e[27]=o,e[28]=te,e[29]=F,e[30]=he):he=e[30];const Se=he,Re=g??m??n.session.id,le=b?.subtreeContainsEditing??vk,se=b?.menuOpenSessionId??null,q=b?.nodeStructureKey??"",z=b?.relativeTimeTick;let ae;e[31]!==T||e[32]!==J||e[33]!==Se||e[34]!==B||e[35]!==j||e[36]!==W||e[37]!==ue||e[38]!==k||e[39]!==v||e[40]!==p||e[41]!==S||e[42]!==l||e[43]!==w||e[44]!==ee||e[45]!==n.children||e[46]!==f||e[47]!==x||e[48]!==_||e[49]!==A||e[50]!==y||e[51]!==fe||e[52]!==L||e[53]!==a||e[54]!==E||e[55]!==O||e[56]!==D||e[57]!==N||e[58]!==C||e[59]!==P||e[60]!==$||e[61]!==K||e[62]!==I?(ae=fe?n.children.map($e=>s.jsx(Ho,{node:$e,pinnedSessionIds:y,expandedParents:S,hasSessionSearchQuery:w,normalizedSessionSearchQuery:f,notifyOnSubtasks:x,editingId:v,editingRowKey:p,setEditingId:N,setEditingRowKey:C,editTitle:k,copiedSessionId:j,setEditTitle:D,toggleParent:I,openSidebarMenuKey:A,setOpenSidebarMenuKey:P,allowReselect:T,onSessionSelected:_,resetSessionSearch:L,deleteSessionConfirm:W,setDeleteSessionConfirm:O,startFolderRename:$,setCopiedSessionId:E,startSessionWorktreeMenuLoad:K,mobileVariant:ee,alwaysShowActions:J,depth:ue+1,folderOwnerKey:l,selectionScopeKey:a,...Se,renderExtras:B?.($e)},$e.session.id)):null,e[31]=T,e[32]=J,e[33]=Se,e[34]=B,e[35]=j,e[36]=W,e[37]=ue,e[38]=k,e[39]=v,e[40]=p,e[41]=S,e[42]=l,e[43]=w,e[44]=ee,e[45]=n.children,e[46]=f,e[47]=x,e[48]=_,e[49]=A,e[50]=y,e[51]=fe,e[52]=L,e[53]=a,e[54]=E,e[55]=O,e[56]=D,e[57]=N,e[58]=C,e[59]=P,e[60]=$,e[61]=K,e[62]=I,e[63]=ae):ae=e[63];let ce;e[64]!==J||e[65]!==X||e[66]!==j||e[67]!==pe||e[68]!==ue||e[69]!==k||e[70]!==v||e[71]!==p||e[72]!==je||e[73]!==S||e[74]!==l||e[75]!==i||e[76]!==w||e[77]!==ee||e[78]!==n||e[79]!==f||e[80]!==x||e[81]!==A||e[82]!==y||e[83]!==o||e[84]!==te||e[85]!==d||e[86]!==a||e[87]!==de.handleCancelEdit||e[88]!==de.handleCopySessionId||e[89]!==de.handleCopyShareUrl||e[90]!==de.handleDeleteSession||e[91]!==de.handleRestoreSession||e[92]!==de.handleSaveEdit||e[93]!==de.handleSessionDoubleClick||e[94]!==de.handleSessionSelect||e[95]!==de.handleShareSession||e[96]!==de.handleUnshareSession||e[97]!==D||e[98]!==N||e[99]!==C||e[100]!==P||e[101]!==K||e[102]!==Re||e[103]!==le||e[104]!==se||e[105]!==q||e[106]!==z||e[107]!==ae||e[108]!==I?(ce=s.jsx(gk,{expandedParents:S,hasSessionSearchQuery:w,normalizedSessionSearchQuery:f,notifyOnSubtasks:x,editingId:v,editingRowKey:p,setEditingId:N,setEditingRowKey:C,editTitle:k,setEditTitle:D,handleSaveEdit:de.handleSaveEdit,handleCancelEdit:de.handleCancelEdit,toggleParent:I,handleSessionSelect:de.handleSessionSelect,handleSessionDoubleClick:de.handleSessionDoubleClick,handleShareSession:de.handleShareSession,copiedSessionId:j,handleCopyShareUrl:de.handleCopyShareUrl,handleCopySessionId:de.handleCopySessionId,handleUnshareSession:de.handleUnshareSession,openSidebarMenuKey:A,setOpenSidebarMenuKey:P,createFolderAndStartRename:pe,handleDeleteSession:de.handleDeleteSession,handleRestoreSession:de.handleRestoreSession,startSessionWorktreeMenuLoad:K,mobileVariant:ee,alwaysShowActions:J,pinnedSessionIds:y,node:n,depth:ue,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:X,secondaryMeta:d,renderContext:te,rowKey:je,dragKey:Re,subtreeContainsEditing:le,menuOpenSessionId:se,nodeStructureKey:q,relativeTimeTick:z,children:ae}),e[64]=J,e[65]=X,e[66]=j,e[67]=pe,e[68]=ue,e[69]=k,e[70]=v,e[71]=p,e[72]=je,e[73]=S,e[74]=l,e[75]=i,e[76]=w,e[77]=ee,e[78]=n,e[79]=f,e[80]=x,e[81]=A,e[82]=y,e[83]=o,e[84]=te,e[85]=d,e[86]=a,e[87]=de.handleCancelEdit,e[88]=de.handleCopySessionId,e[89]=de.handleCopyShareUrl,e[90]=de.handleDeleteSession,e[91]=de.handleRestoreSession,e[92]=de.handleSaveEdit,e[93]=de.handleSessionDoubleClick,e[94]=de.handleSessionSelect,e[95]=de.handleShareSession,e[96]=de.handleUnshareSession,e[97]=D,e[98]=N,e[99]=C,e[100]=P,e[101]=K,e[102]=Re,e[103]=le,e[104]=se,e[105]=q,e[106]=z,e[107]=ae,e[108]=I,e[109]=ce):ce=e[109];let Ne;e[110]!==W||e[111]!==n.session.id||e[112]!==de.confirmDeleteSession||e[113]!==O||e[114]!==xe||e[115]!==Pe?(Ne=W?.session.id===n.session.id?s.jsx(yk,{value:W,setValue:O,showDeletionDialog:Pe,setShowDeletionDialog:xe,onConfirm:de.confirmDeleteSession}):null,e[110]=W,e[111]=n.session.id,e[112]=de.confirmDeleteSession,e[113]=O,e[114]=xe,e[115]=Pe,e[116]=Ne):Ne=e[116];let we;return e[117]!==ce||e[118]!==Ne?(we=s.jsxs(s.Fragment,{children:[ce,Ne]}),e[117]=ce,e[118]=Ne,e[119]=we):we=e[119],we}function Sk(t){return t.setShowDeletionDialog}function jk(t){return t.showDeletionDialog}function kk(t){return t.toggleFolderCollapse}function Ck(t){return t.createFolder}const Nk=24,Ak=t=>Array.from({length:Math.min(t,Nk)},(e,n)=>n),Dk=(t,e,n)=>{const r=new Set(t);for(const i of e)i>=0&&i<n&&r.add(i);return[...r].sort((i,o)=>i-o)},Pk=(t,e)=>t.find(n=>n.end>e)?.index??0;function Xc(t,e){return e?.kind==="activity-header"||e?.kind==="project-header"||e?.kind==="group-header"&&t.kind!=="project-header"?"pb-2":void 0}function Ik({model:t,scrollElement:e,pinnedRowIndexes:n,renderRow:r,onFirstVisibleIndexChange:i}){const o=t.rows,l=c.useCallback(()=>e,[e]),a=c.useCallback(w=>o[w]?.estimateSize??32,[o]),u=c.useCallback(w=>o[w]?.key??w,[o]),d=c.useCallback(w=>Dk(hb(w),n,o.length),[n,o.length]),h=mb({count:o.length,enabled:e!==null,getScrollElement:l,estimateSize:a,getItemKey:u,overscan:8,rangeExtractor:d}),m=h.getVirtualItems(),g=e?h.getTotalSize():0,b=e?Math.max(g-e.clientHeight,0):0,y=e?Math.min(e.scrollTop,b):0,S=Pk(m,y);if(c.useLayoutEffect(()=>{i(S)},[S,i]),!e){const w=Ak(o.length),f=w.reduce((v,p)=>v+(o[p]?.estimateSize??0),0),x=o.reduce((v,p)=>v+p.estimateSize,0);return s.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[w.map(v=>{const p=o[v];return p?s.jsx("div",{className:Xc(p,o[v+1]),children:r(p,v)},p.key):null}),x>f?s.jsx("div",{"aria-hidden":"true",style:{height:x-f}}):null]})}return s.jsx("div",{"data-sidebar-virtual-ready":"true",style:{height:g,position:"relative"},children:m.map(w=>{const f=o[w.index];return f?s.jsx("div",{className:`[&_[data-session-row]]:my-px ${Xc(f,o[w.index+1])??""}`,"data-index":w.index,"data-sidebar-virtual-start":w.start,ref:h.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${w.start}px)`},children:r(f,w.index)},f.key):null})})}const Tk=t=>{const e=et.c(33),{activityKey:n,collapsed:r,forceExpanded:i,alwaysShowActions:o,onToggle:l,onNewChat:a}=t,{t:u}=vt(),d=n==="chats",h=i?void 0:l,m=d?"pr-10":"pr-3.5";let g;e[0]!==m?(g=Me("group flex w-full items-center gap-1.5 py-1 pl-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",m),e[0]=m,e[1]=g):g=e[1];const b=!r,y=d?"chat-4":"history",S=!i&&"group-hover:hidden";let w;e[2]!==S?(w=Me("h-3.5 w-3.5 text-muted-foreground/80",S),e[2]=S,e[3]=w):w=e[3];let f;e[4]!==y||e[5]!==w?(f=s.jsx(M,{name:y,className:w}),e[4]=y,e[5]=w,e[6]=f):f=e[6];let x;e[7]!==r||e[8]!==i?(x=i?null:s.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:s.jsx(M,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}),e[7]=r,e[8]=i,e[9]=x):x=e[9];let v;e[10]!==f||e[11]!==x?(v=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[f,x]}),e[10]=f,e[11]=x,e[12]=v):v=e[12];const p=d?"sessions.sidebar.activity.chatsTitle":"sessions.sidebar.activity.recentTitle";let N;e[13]!==u||e[14]!==p?(N=u(p),e[13]=u,e[14]=p,e[15]=N):N=e[15];let C;e[16]!==N?(C=s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:N}),e[16]=N,e[17]=C):C=e[17];let k;e[18]!==i||e[19]!==h||e[20]!==v||e[21]!==C||e[22]!==g||e[23]!==b?(k=s.jsxs("button",{type:"button",onClick:h,disabled:i,className:g,"aria-expanded":b,children:[v,C]}),e[18]=i,e[19]=h,e[20]=v,e[21]=C,e[22]=g,e[23]=b,e[24]=k):k=e[24];let D;e[25]!==o||e[26]!==d||e[27]!==a||e[28]!==u?(D=d?s.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),a()},className:Me("absolute right-0.5 top-1/2 z-10 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",o?"opacity-100":"opacity-0 pointer-events-none group-hover/chats:opacity-100 group-hover/chats:pointer-events-auto group-focus-within/chats:opacity-100 group-focus-within/chats:pointer-events-auto"),"aria-label":u("sessions.sidebar.header.actions.newSession"),children:s.jsx(M,{name:"add",className:"h-4 w-4"})}):null,e[25]=o,e[26]=d,e[27]=a,e[28]=u,e[29]=D):D=e[29];let I;return e[30]!==k||e[31]!==D?(I=s.jsxs("div",{className:"relative group/chats -ml-2.5 -mr-2",children:[k,D]}),e[30]=k,e[31]=D,e[32]=I):I=e[32],I},Ek=(t,e)=>{const n=t.groups.find(o=>o.isMain&&o.sessions.length>0)??t.groups.find(o=>o.sessions.length>0)??t.groups.find(o=>o.isMain)??t.groups[0];if(!n)return[];const r=t.groups.find(o=>o.isArchivedBucket&&o.id!==n.id);return(e.mainWorkspaceOnly?[n,...r?[r]:[]]:[...t.groups.find(o=>o.isMain)?[t.groups.find(o=>o.isMain)]:[],...t.groups.filter(o=>!o.isMain)]).map(o=>({group:o,groupKey:`${t.project.id}:${o.id}`,projectId:t.project.id,hideGroupLabel:e.mainWorkspaceOnly?o.id===n.id:o.isMain}))},Rk=[],Mk=32,yo=32,qn=28,Jc=(t,e,n,r)=>{const i=r.get(t.session.id),o=r.get(e.session.id);if(i!==void 0||o!==void 0){if(i===void 0)return 1;if(o===void 0)return-1;if(i!==o)return i-o}return La(t.session,e.session,n,Ma)},Zc=t=>{const e=new Map,n=new Map,r=[],i=new WeakMap,o=t.map(l=>({node:l,visited:!1})).reverse();for(;o.length>0;){const l=o.pop();if(!l)continue;if(!l.visited){e.set(l.node.session.id,l.node),n.set(l.node.session.id,l.node.session);const u=r.length;r.push(l.node.session.id),i.set(l.node,[u,u+1]),o.push({node:l.node,visited:!0});for(let d=l.node.children.length-1;d>=0;d-=1){const h=l.node.children[d];h&&o.push({node:h,visited:!1})}continue}const a=i.get(l.node);a&&i.set(l.node,Object.freeze([a[0],r.length]))}return{byId:e,sessionsById:n,preorderIds:Object.freeze(r),subtreeRangeByNode:i}},Ok=(t,e,n)=>`${t}:${e?"archived":"active"}:${n}`,Bk=(t,e)=>{let n=null;for(const r of t){if(r.rowIndex>e)break;n=r}return n},Fk=t=>{const e=[],n=[],r=[],i=[],o=[],l=new Map,a=new Map,u=t.mode==="search",d=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds);let h=0;const g=[...[...t.authoritativeSections.flatMap(p=>p.groups.flatMap(N=>N.sessions)),...t.chatGroup?.sessions??[]]];for(;g.length>0;){const p=g.pop();p&&(l.set(p.session.id,p.session),g.push(...p.children))}const b=p=>{const N=a.get(p)??0;return a.set(p,N+1),N===0?p:`${p}:${N}`},y=p=>{e.push(Object.freeze(p))},S=p=>{const N=[...p.nodes].reverse().map(C=>({node:C,depth:0,directory:p.groupDirectory}));for(;N.length>0;){const C=N.pop();if(!C)continue;const k=b(`${p.containerKey}:session:${C.node.session.id}`),D=C.node.session.directory??C.directory;l.set(C.node.session.id,C.node.session),y({kind:"session",key:k,estimateSize:Mk,node:C.node,depth:C.depth,projectId:p.projectId,groupDirectory:C.directory,ownerKey:p.ownerKey,selectionScopeKey:p.selectionScopeKey,archived:p.archived,renderContext:p.renderContext,secondaryMeta:p.secondaryMeta??null});const I=p.indexedNodes?.subtreeRangeByNode.get(C.node),A=I&&I[1]>I[0]+1?Object.freeze([(p.selectionPoolOffset??0)+I[0]+1,(p.selectionPoolOffset??0)+I[1]]):void 0;if(n.push(Object.freeze({id:C.node.session.id,rowKey:k,scopeKey:p.selectionScopeKey,archived:p.archived,descendantRange:A})),!(!u&&!t.expandedParents.has(Ok(p.renderContext,p.archived,C.node.session.id))))for(let P=C.node.children.length-1;P>=0;P-=1){const T=C.node.children[P];T&&N.push({node:T,depth:C.depth+1,directory:D})}}},w=(p,N,C,k)=>{const D=t.groupSearchDataByGroup.get(p);if(u&&D?.hasMatch!==!0)return;u&&D&&(h+=D.matchedSessionCount+D.folderNameMatchCount+(D.groupMatches?1:0));const I=[...u?D?.filteredNodes??[]:p.sessions].sort((Y,ie)=>Jc(Y,ie,d,t.sessionOrderIndex)),A=Zc(I),P=r.length;r.push(...A.preorderIds);for(const[Y,ie]of A.sessionsById)l.set(Y,ie);const T=kr(C,p.directory),_=!u&&t.collapsedGroups.has(N);if(!k){const Y=A.preorderIds.flatMap(ie=>A.sessionsById.get(ie)??[]);y({kind:"group-header",key:`${N}:header`,estimateSize:yo,group:p,groupKey:N,projectId:C,collapsed:_,forceExpanded:u,allSessions:Object.freeze(Y)})}if(_)return;const L=Zr(p).flatMap(({scopeKey:Y,directory:ie})=>(t.foldersMap[Y]??Rk).map(H=>({folder:H,scopeKey:Y,scopeDirectory:ie,ownerKey:T,nodes:fa(H.sessionIds,A.byId).sort((me,pe)=>Jc(me,pe,d,t.sessionOrderIndex))}))),W=Gf(L.map(Y=>({id:Y.folder.id,name:Y.folder.name,parentId:Y.folder.parentId,nodeCount:Y.nodes.length})),{archivedBucket:p.isArchivedBucket===!0,searchQuery:u?t.normalizedQuery:""}),O=L.filter(Y=>W.has(Y.folder.id)),$=new Map(O.map(Y=>[Xn(Y.scopeKey,Y.folder.id),Y])),j=new Map;for(const Y of O){if(!Y.folder.parentId)continue;const ie=Xn(Y.scopeKey,Y.folder.parentId),H=j.get(ie)??[];H.push(Y),j.set(ie,H)}const E=Hf(O.map(Y=>({...Y.folder,scopeKey:Y.scopeKey}))).map(Y=>$.get(Xn(Y.scopeKey??"",Y.id))).filter(Y=>!!Y),K=new Set(O.flatMap(Y=>Y.folder.sessionIds)),ee=I.filter(Y=>!K.has(Y.session.id)),J=new Map,ne=E.map(Y=>({folder:Y,visited:!1})),ue=new Set;for(;ne.length>0;){const Y=ne.pop();if(!Y)continue;const ie=Xn(Y.folder.scopeKey,Y.folder.folder.id);if(!Y.visited){if(ue.has(ie))continue;ue.add(ie),ne.push({folder:Y.folder,visited:!0});for(const me of j.get(ie)??[])ne.push({folder:me,visited:!1});continue}const H=Y.folder.nodes.flatMap(me=>{const pe=A.subtreeRangeByNode.get(me);return pe?A.preorderIds.slice(pe[0],pe[1]).flatMap(re=>A.sessionsById.get(re)??[]):[me.session]});for(const me of j.get(ie)??[])H.push(...J.get(Xn(me.scopeKey,me.folder.id))??[]);J.set(ie,Object.freeze(H))}const X=new Set,te=(Y,ie)=>{const H=Xn(Y.scopeKey,Y.folder.id);if(X.has(H))return;X.add(H);const me=ie?`${ie} / ${Y.folder.name}`:Y.folder.name,pe=`${N}:folder:${H}`,re=!u&&t.collapsedFolders.has(Y.folder.id),de=J.get(H)??[],B=re&&!p.isArchivedBucket?fa([...new Set(de.map(Se=>Se.id))],A.byId):[],F=T?t.folderAuthorityByOwner.get(T):void 0,he=!!T&&!p.isArchivedBucket&&!el(Y.scopeKey)&&F?.complete===!0&&F.scopeKeys.includes(Y.scopeKey);if(y({kind:"folder-header",key:pe,estimateSize:yo,group:p,folder:Y.folder,displayName:me,scopeKey:Y.scopeKey,scopeDirectory:Y.scopeDirectory,ownerKey:T,nodes:Y.nodes,activityNodes:B,projectId:C,archived:p.isArchivedBucket===!0,collapsed:re,forceExpanded:u,deleteSessions:de,subFolderCount:j.get(H)?.length??0,dropEnabled:he}),T&&o.push(Object.freeze({rowKey:pe,scopeKey:Y.scopeKey,folderId:Y.folder.id,ownerKey:T,enabled:he})),!re){S({nodes:Y.nodes,containerKey:pe,projectId:C,groupDirectory:Y.scopeDirectory??p.directory,ownerKey:T,selectionScopeKey:T,archived:p.isArchivedBucket===!0,renderContext:"project",indexedNodes:A,selectionPoolOffset:P});for(const Se of j.get(H)??[])te(Se,me)}};for(const Y of E)te(Y,"");const fe=C?t.sessionBatchSize:void 0,je=fe??(t.hideDirectoryControls?10:5),ve=fe??7,ye=Math.max(je,t.visibleCountByContainer.get(N)??je),Pe=p.isArchivedBucket||u?ee:ee.slice(0,ye);S({nodes:Pe,containerKey:N,projectId:C,groupDirectory:p.directory,ownerKey:T,selectionScopeKey:T,archived:p.isArchivedBucket===!0,renderContext:"project",indexedNodes:A,selectionPoolOffset:P});const xe=ee.length-Pe.length;!u&&!p.isArchivedBucket&&xe>0?y({kind:"show-control",key:`${N}:more`,estimateSize:qn,control:"more",containerKey:N,currentCount:Pe.length,increment:ve}):!u&&!p.isArchivedBucket&&ee.length>je&&xe===0&&y({kind:"show-control",key:`${N}:fewer`,estimateSize:qn,control:"fewer",containerKey:N,currentCount:Pe.length,increment:ve});const R=t.groupStatusByKey.get(N);I.length===0&&O.length===0?R&&R.state!=="ready"?y({kind:"status",key:`${N}:status`,estimateSize:qn,status:R,group:p,groupKey:N}):y({kind:"empty",key:`${N}:empty`,estimateSize:qn,emptyKind:p.isArchivedBucket?"archived":"group",group:p}):R&&R.state!=="ready"&&R.state!=="loading"&&y({kind:"status",key:`${N}:status`,estimateSize:qn,status:R,group:p,groupKey:N})},f=p=>{const N=!u&&t.collapsedActivities.has(p),C=e.length;return y({kind:"activity-header",key:`activity:${p}:header`,estimateSize:yo,activityKey:p,collapsed:N,forceExpanded:u}),i.push(Object.freeze({rowIndex:C,kind:"activity",id:p})),N};if(t.chatGroup){const p=t.groupSearchDataByGroup.get(t.chatGroup);(!u||p?.hasMatch===!0)&&(f("chats")||w(t.chatGroup,"activity:chats",null,!0))}if(t.showRecentSection)for(const p of t.recentSections){if(p.items.length===0||f("active-now"))continue;const C=`activity:${p.key}`,k=7,D=Math.max(k,t.visibleCountByContainer.get(C)??k),I=u?p.items:p.items.slice(0,D);for(const P of I){const T=Zc([P.node]),_=r.length;r.push(...T.preorderIds),S({nodes:[P.node],containerKey:C,projectId:P.projectId,groupDirectory:P.groupDirectory,ownerKey:kr(P.projectId,P.groupDirectory),selectionScopeKey:kr(P.projectId,P.groupDirectory),archived:!1,renderContext:"recent",secondaryMeta:P.secondaryMeta,indexedNodes:T,selectionPoolOffset:_}),u&&(h+=1)}const A=p.items.length-I.length;!u&&A>0?y({kind:"show-control",key:`${C}:more`,estimateSize:qn,control:"more",containerKey:C,currentCount:I.length,increment:7}):!u&&p.items.length>k&&y({kind:"show-control",key:`${C}:fewer`,estimateSize:qn,control:"fewer",containerKey:C,currentCount:I.length,increment:7})}let x=t.singleProjectMode?t.sections.filter(p=>p.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const p=x.find(N=>N.project.id===t.activeProjectId)??x[0];x=p?[p]:[]}for(const p of x){const N=!u&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(p.project.id);if(!t.showOnlyMainWorkspace){const k=e.length;y({kind:"project-header",key:`project:${p.project.id}:header`,estimateSize:yo,section:p,collapsed:N,forceExpanded:u}),i.push(Object.freeze({rowIndex:k,kind:"project",id:p.project.id}))}if(N)continue;const C=Ek(p,{mainWorkspaceOnly:t.showOnlyMainWorkspace});for(const k of C)w(k.group,k.groupKey,k.projectId,k.hideGroupLabel)}e.length===0&&y({kind:"empty",key:u?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:u?"search":"sidebar"});const v=new Map;return e.forEach((p,N)=>v.set(p.key,N)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(n),selectionDescendantIds:Object.freeze(r),rowIndexByKey:v,stickyHeaders:Object.freeze(i),folderDropTargets:Object.freeze(o),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:l,searchMatchCount:u?h:0})},tm=c.createContext(null);function ed(t){let e=0,n=t;for(;n;){e+=n.offsetTop;const o=n.offsetParent;n=o instanceof HTMLElement?o:null}const r=t.closest("[data-sidebar-virtual-start]"),i=Number(r?.dataset.sidebarVirtualStart??"0");return e+(Number.isFinite(i)?i:0)}function _k(t){const e=et.c(14),{enabled:n,suspended:r,layoutKey:i,scrollRef:o,children:l}=t,a=r===void 0?!1:r,u=i===void 0?"":i;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,e[0]=d):d=e[0];const h=c.useRef(d),m=c.useRef(null);let g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=x=>(h.current.add(x),m.current?.(),()=>{h.current.delete(x),m.current?.()}),e[1]=g):g=e[1];const b=g;let y;e[2]!==n||e[3]!==o||e[4]!==a?(y=()=>{const x=o.current;if(!n||a||!x)return;const v=document.createElement("div");v.dataset.sidebarCrossfadeLayer="true",v.className="pointer-events-none sticky top-0 z-30 h-0",v.style.marginBlock="0px",x.prepend(v);let p=null,N=null,C=null,k=0;const D=new Set;let I=[];const A=window.matchMedia("(prefers-reduced-motion: reduce)"),P=$k,T=()=>{C?.cancel(),C=null,N?.remove(),N=null},_=()=>{let j=null,E=-1/0;for(const{entry:K,top:ee}of I)ee<=x.scrollTop&&ee>=E&&(E=ee,j=K);if(p!==j){if(T(),p&&j&&!A.matches){const K=p.host.cloneNode(!0);K instanceof HTMLElement&&(K.inert=!0,K.setAttribute("aria-hidden","true"),K.querySelectorAll("[id]").forEach(Lk),K.className="pointer-events-none absolute inset-x-0 top-0 z-30",N=K)}p&&(P(p,p.slot),p.slot.style.removeProperty("height")),p=j,v.hidden=!j,j&&(j.slot.style.height=`${j.host.getBoundingClientRect().height}px`,P(j,v),N&&(v.append(N),C=N.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),C.onfinish=T))}},L=()=>{p&&(p.slot.style.height=`${p.host.getBoundingClientRect().height}px`);const j=ed(x)+x.clientTop;I=Array.from(h.current,E=>({entry:E,top:ed(E.slot)-j})),_()},W=new ResizeObserver(L),O=new MutationObserver(()=>{cancelAnimationFrame(k),k=requestAnimationFrame(L)});W.observe(x);const $=()=>{O.disconnect();for(const j of D)h.current.has(j)||(W.unobserve(j.host),j.slot.parentElement&&W.unobserve(j.slot.parentElement),D.delete(j));for(const j of h.current){const E=j.slot.closest("[data-sidebar-virtual-start]");E&&O.observe(E,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),D.has(j)||(W.observe(j.host),j.slot.parentElement&&W.observe(j.slot.parentElement),D.add(j))}cancelAnimationFrame(k),k=requestAnimationFrame(L)};return m.current=$,x.addEventListener("scroll",_,{passive:!0}),$(),L(),()=>{m.current=null,cancelAnimationFrame(k),x.removeEventListener("scroll",_),W.disconnect(),O.disconnect(),T(),v.hidden=!0,p&&(P(p,p.slot),p.slot.style.removeProperty("height")),v.remove()}},e[2]=n,e[3]=o,e[4]=a,e[5]=y):y=e[5];let S;e[6]!==n||e[7]!==u||e[8]!==o||e[9]!==a?(S=[n,a,u,o],e[6]=n,e[7]=u,e[8]=o,e[9]=a,e[10]=S):S=e[10],c.useLayoutEffect(y,S);const w=n?b:null;let f;return e[11]!==l||e[12]!==w?(f=s.jsx(tm.Provider,{value:w,children:l}),e[11]=l,e[12]=w,e[13]=f):f=e[13],f}function Lk(t){return t.removeAttribute("id")}function $k(t,e){const n=document.activeElement,r=n instanceof HTMLElement&&t.host.contains(n);e.moveBefore&&e.isConnected&&t.host.isConnected?e.moveBefore(t.host,null):e.append(t.host),r&&n.focus({preventScroll:!0})}function zk(t){const e=et.c(15);let n,r;e[0]!==t?({register:r,...n}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const i=c.useRef(null),[o]=c.useState(Wk);let l,a;e[3]!==o||e[4]!==r?(l=()=>{const g=i.current;if(!g)return;g.append(o);const b=r({slot:g,host:o});return()=>{b(),o.remove()}},a=[o,r],e[3]=o,e[4]=r,e[5]=l,e[6]=a):(l=e[5],a=e[6]),c.useLayoutEffect(l,a);let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("div",{ref:i}),e[7]=u):u=e[7];let d;e[8]!==n?(d=s.jsx("div",{...n}),e[8]=n,e[9]=d):d=e[9];let h;e[10]!==o||e[11]!==d?(h=_m.createPortal(d,o),e[10]=o,e[11]=d,e[12]=h):h=e[12];let m;return e[13]!==h?(m=s.jsxs(s.Fragment,{children:[u,h]}),e[13]=h,e[14]=m):m=e[14],m}function Wk(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function sm(t){const e=et.c(3),n=c.useContext(tm);let r;return e[0]!==t||e[1]!==n?(r=n?s.jsx(zk,{...t,register:n}):s.jsx("div",{...t}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r}const Ni=t=>{const e=et.c(22),{id:n,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:l,projectIconBackground:a,isCollapsed:u,alwaysShowActions:d}=t,h=d===void 0?!1:d,{currentTheme:m}=ar(),g=i?$a[i]:null,b=o?za[o]??null:null,y=u!==void 0,S=y?h?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let w;e[0]!==h||e[1]!==y||e[2]!==u?(w=y?s.jsx("span",{className:Me("h-3.5 w-3.5 items-center justify-center text-muted-foreground",h?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:s.jsx(M,{name:u?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=h,e[1]=y,e[2]=u,e[3]=w):w=e[3];let f;e[4]!==h||e[5]!==m||e[6]!==y||e[7]!==b||e[8]!==S||e[9]!==n||e[10]!==a||e[11]!==l||e[12]!==g?(f=l?s.jsx("span",{className:Me("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",y&&h?"hidden":"inline-flex",S),style:a?{backgroundColor:a}:void 0,children:s.jsx(Wa,{project:{id:n,iconImage:l},options:{themeVariant:m.metadata.variant,iconColor:m.colors.surface.foreground},className:"h-full w-full object-contain",fallback:g?s.jsx(M,{name:g,className:"h-3.5 w-3.5",style:b?{color:b}:void 0}):s.jsx(M,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:b?{color:b}:void 0})})}):g?s.jsx(M,{name:g,className:Me("h-3.5 w-3.5",S),style:b?{color:b}:void 0}):s.jsx(M,{name:"folder",className:Me("h-3.5 w-3.5 text-muted-foreground/80",S),style:b?{color:b}:void 0}),e[4]=h,e[5]=m,e[6]=y,e[7]=b,e[8]=S,e[9]=n,e[10]=a,e[11]=l,e[12]=g,e[13]=f):f=e[13];let x;e[14]!==w||e[15]!==f?(x=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[w,f]}),e[14]=w,e[15]=f,e[16]=x):x=e[16];let v;e[17]!==r?(v=s.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=v):v=e[18];let p;return e[19]!==x||e[20]!==v?(p=s.jsxs(s.Fragment,{children:[x,v]}),e[19]=x,e[20]=v,e[21]=p):p=e[21],p},Kk=t=>{const e=et.c(61),{id:n,disabled:r,projectLabel:i,projectDescription:o,projectDirectory:l,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h,isCollapsed:m,isRepo:g,hideDirectoryControls:b,alwaysShowActions:y,onToggle:S,onNewSession:w,onNewWorktreeSession:f,onManageWorktrees:x,onRenameStart:v,onClose:p,children:N,showCreateButtons:C,hideHeader:k,statusIndicator:D,openSidebarMenuKey:I,setOpenSidebarMenuKey:A,projectPickerOptions:P,onProjectSelect:T}=t,_=r===void 0?!1:r,L=C===void 0?!0:C,W=k===void 0?!1:k,O=D===void 0?null:D,{t:$}=vt(),j=hs(Hk);let E;e[0]!==_||e[1]!==n?(E={id:n,disabled:_},e[0]=_,e[1]=n,e[2]=E):E=e[2];const{attributes:K,listeners:ee,setNodeRef:J,transform:ne,transition:ue,isDragging:X}=ii(E),te=c.useRef(!1),fe=`project:${n}`,je=I===fe,[ve,ye]=c.useState(!1),Pe=!!(P&&T);let xe;e[3]!==fe||e[4]!==A?(xe=z=>{z&&ye(!1),A(z?fe:null)},e[3]=fe,e[4]=A,e[5]=xe):xe=e[5];const R=xe;let Y;e[6]!==b||e[7]!==g||e[8]!==p||e[9]!==x||e[10]!==w||e[11]!==v||e[12]!==L||e[13]!==$?(Y=z=>s.jsxs(s.Fragment,{children:[L&&!g&&!b&&w&&s.jsxs(z,{onClick:w,children:[s.jsx(M,{name:"add",className:"mr-1.5 h-4 w-4"}),$("sessions.sidebar.project.actions.newSession")]}),g&&!b&&x&&s.jsxs(z,{onClick:x,children:[s.jsx(M,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),$("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(z,{onClick:v,children:[s.jsx(M,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),$("sessions.sidebar.project.actions.edit")]}),s.jsxs(z,{onClick:p,className:"text-destructive focus:text-destructive",children:[s.jsx(M,{name:"close",className:"mr-1.5 h-4 w-4"}),$("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=b,e[7]=g,e[8]=p,e[9]=x,e[10]=w,e[11]=v,e[12]=L,e[13]=$,e[14]=Y):Y=e[14];const ie=Y,H=Gk,me=qk,pe=Yk;let re;e[15]===Symbol.for("react.memo_cache_sentinel")?(re=z=>{(z.button===2||z.button===0&&z.ctrlKey)&&(te.current=!0)},e[15]=re):re=e[15];const de=re;let B;e[16]!==S?(B=z=>{if(z.currentTarget.blur(),te.current){te.current=!1;return}S()},e[16]=S,e[17]=B):B=e[17];const F=B;let he;e[18]!==ne?(he=ai.Transform.toString(ne),e[18]=ne,e[19]=he):he=e[19];let Se;e[20]!==he||e[21]!==ue?(Se={transform:he,transition:ue},e[20]=he,e[21]=ue,e[22]=Se):Se=e[22];const Re=X&&"opacity-30";let le;e[23]!==Re?(le=Me("relative",Re),e[23]=Re,e[24]=le):le=e[24];let se;e[25]!==y||e[26]!==K||e[27]!==R||e[28]!==F||e[29]!==b||e[30]!==W||e[31]!==n||e[32]!==m||e[33]!==ve||e[34]!==je||e[35]!==Pe||e[36]!==g||e[37]!==ee||e[38]!==w||e[39]!==f||e[40]!==T||e[41]!==u||e[42]!==o||e[43]!==l||e[44]!==a||e[45]!==h||e[46]!==d||e[47]!==i||e[48]!==P||e[49]!==ie||e[50]!==L||e[51]!==O||e[52]!==j||e[53]!==$?(se=W?null:s.jsx(s.Fragment,{children:s.jsxs(qd,{open:ve,onOpenChange:ye,children:[s.jsx(Gd,{render:s.jsx(sm,{className:Me("-ml-2.5 -mr-2 text-left group/project select-none",j&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":j?"true":void 0,onContextMenu:z=>{b||(z.preventDefault(),ye(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...K,children:[Pe?s.jsxs(zs,{children:[s.jsx(Ls,{asChild:!0,children:s.jsxs("button",{type:"button",className:Me("flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-[padding]",g&&!b?y||je?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":y||je?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":$("sessions.sidebar.project.selectAria",{project:i}),children:[s.jsx(Ni,{id:n,projectLabel:i,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h}),s.jsx(M,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),l?s.jsx(Wo,{directory:l,className:"ml-auto"}):null]})}),s.jsx($s,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:P?.map(z=>s.jsxs(Kt,{onClick:()=>T?.(z.id),className:"flex items-center justify-between gap-3",title:z.projectDescription,children:[s.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:s.jsx(Ni,{...z})}),z.id===n?s.jsx(M,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},z.id))})]}):s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:de,onClick:F,...ee,className:Me("flex-1 min-w-0 flex items-center gap-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-md cursor-grab active:cursor-grabbing transition-[padding]",g&&!b?y||je?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":y||je?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(Ni,{id:n,projectLabel:i,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h,isCollapsed:m,alwaysShowActions:y}),O?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:O}):null,l?s.jsx(Wo,{directory:l,className:"ml-auto"}):null]})}),s.jsx(It,{side:"right",sideOffset:8,children:o})]}),s.jsxs("div",{className:Me("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",L?"right-7":"right-0.5"),children:[L&&g&&!b&&f?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),f()},className:Me("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground transition-opacity",y?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":$("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(M,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:$("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,b?null:s.jsxs(zs,{open:je,onOpenChange:R,children:[s.jsx(Ls,{asChild:!0,children:s.jsx("button",{type:"button",className:Me("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground",je?"opacity-100 pointer-events-auto":y?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":$("sessions.sidebar.project.actions.projectMenu"),onPointerDown:me,onMouseDown:pe,onClick:H,children:s.jsx(M,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx($s,{align:"end",className:"min-w-[180px]",children:ie(Kt)})]})]}),L&&w?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),w()},className:Me("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",y?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":$(g?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(M,{name:"add",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:$(g?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(Hd,{className:"min-w-[180px]",children:ie(Jn)})]})}),e[25]=y,e[26]=K,e[27]=R,e[28]=F,e[29]=b,e[30]=W,e[31]=n,e[32]=m,e[33]=ve,e[34]=je,e[35]=Pe,e[36]=g,e[37]=ee,e[38]=w,e[39]=f,e[40]=T,e[41]=u,e[42]=o,e[43]=l,e[44]=a,e[45]=h,e[46]=d,e[47]=i,e[48]=P,e[49]=ie,e[50]=L,e[51]=O,e[52]=j,e[53]=$,e[54]=se):se=e[54];let q;return e[55]!==N||e[56]!==J||e[57]!==Se||e[58]!==le||e[59]!==se?(q=s.jsxs("div",{ref:J,style:Se,className:le,children:[se,N]}),e[55]=N,e[56]=J,e[57]=Se,e[58]=le,e[59]=se,e[60]=q):q=e[60],q},Vk=t=>{const e=et.c(21),{id:n,disabled:r,children:i}=t,o=r===void 0?!1:r;let l;e[0]!==o||e[1]!==n?(l={id:n,disabled:o},e[0]=o,e[1]=n,e[2]=l):l=e[2];const{listeners:a,setNodeRef:u,setActivatorNodeRef:d,transform:h,transition:m,isDragging:g}=ii(l);let b;e[3]!==a||e[4]!==d?(b={listeners:a,setActivatorNodeRef:d},e[3]=a,e[4]=d,e[5]=b):b=e[5];const y=b;let S;e[6]!==h?(S=ai.Transform.toString(h),e[6]=h,e[7]=S):S=e[7];let w;e[8]!==S||e[9]!==m?(w={transform:S,transition:m},e[8]=S,e[9]=m,e[10]=w):w=e[10];const f=g&&"opacity-50";let x;e[11]!==f?(x=Me("space-y-0.5 rounded-md",f),e[11]=f,e[12]=x):x=e[12];let v;e[13]!==i||e[14]!==y?(v=i(y),e[13]=i,e[14]=y,e[15]=v):v=e[15];let p;return e[16]!==u||e[17]!==w||e[18]!==x||e[19]!==v?(p=s.jsx("div",{ref:u,style:w,className:x,children:v}),e[16]=u,e[17]=w,e[18]=x,e[19]=v,e[20]=p):p=e[20],p},Uk=c.memo(Vk);function Hk(t){return t.stickyZoneHeaders}function Gk(t){t.stopPropagation()}function qk(t){t.stopPropagation()}function Yk(t){t.stopPropagation()}const td=[],Qk=t=>{const e=et.c(6),{nodes:n,includeUnreadSubtasks:r,children:i}=t;let o;e[0]!==r||e[1]!==n?(o={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=tl(o);let a;return e[3]!==i||e[4]!==l?(a=i(l),e[3]=i,e[4]=l,e[5]=a):a=e[5],a},Fr=(t,e)=>e?t.sessions.some(n=>$n(n,e)):!1,Xk=(t,e,n)=>t.sessions.some(r=>qf(r,r,e,n,t.directory,t.directory)),Jk=(t,e,n)=>{const r=i=>{const o=i.session.id;return e.get(o)!==n.get(o)?!0:i.children.some(r)};return t.sessions.some(r)},Zk=(t,e,n)=>{const r=t.isArchivedBucket?"archived":"active",i=o=>{const l=`project:${r}:${o.session.id}`;return e.has(l)!==n.has(l)?!0:o.children.some(i)};return t.sessions.some(i)},e3=(t,e)=>{if(t.group!==e.group||t.groupKey!==e.groupKey||t.projectId!==e.projectId||t.hideGroupLabel!==e.hideGroupLabel||t.compactBodyPadding!==e.compactBodyPadding||t.groupSearchDataByGroup!==e.groupSearchDataByGroup||t.visibleSessionCount!==e.visibleSessionCount||t.sessionBatchSize!==e.sessionBatchSize||t.collapsedGroups!==e.collapsedGroups&&t.collapsedGroups.has(t.groupKey)!==e.collapsedGroups.has(e.groupKey)||t.pinnedSessionIds!==e.pinnedSessionIds&&Xk(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&Jk(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&Zk(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Fr(e.group,t.editingId)||Fr(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&Fr(e.group,e.editingId)||t.copiedSessionId!==e.copiedSessionId&&(Fr(e.group,t.copiedSessionId)||Fr(e.group,e.copiedSessionId)))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=e.group.isArchivedBucket===!0,r=Vo(e.group.sessions,t.openSidebarMenuKey,"project",n),i=Vo(e.group.sessions,e.openSidebarMenuKey,"project",n);if(r||i)return!1}if(t.folderRename!==e.folderRename){const n=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??gt(e.group.directory??null)];if(n.includes(t.folderRename?.scopeKey??null)||n.includes(e.folderRename?.scopeKey??null))return!1}return t.hasSessionSearchQuery===e.hasSessionSearchQuery&&t.normalizedSessionSearchQuery===e.normalizedSessionSearchQuery&&t.hideDirectoryControls===e.hideDirectoryControls&&t.showMoreGroupSessions===e.showMoreGroupSessions&&t.resetGroupSessionLimit===e.resetGroupSessionLimit&&t.mobileVariant===e.mobileVariant&&t.alwaysShowActions===e.alwaysShowActions&&t.setActiveProjectIdOnly===e.setActiveProjectIdOnly&&t.setSessionSwitcherOpen===e.setSessionSwitcherOpen&&t.openNewSessionDraft===e.openNewSessionDraft&&t.onToggleCollapsedGroup===e.onToggleCollapsedGroup&&t.dragHandleProps===e.dragHandleProps&&t.renderBody===e.renderBody&&t.notifyOnSubtasks===e.notifyOnSubtasks&&t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&t.setEditTitle===e.setEditTitle&&t.toggleParent===e.toggleParent&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.allowReselect===e.allowReselect&&t.onSessionSelected===e.onSessionSelected&&t.resetSessionSearch===e.resetSessionSearch&&t.deleteSessionConfirm===e.deleteSessionConfirm&&t.setDeleteSessionConfirm===e.setDeleteSessionConfirm&&t.startFolderRename===e.startFolderRename&&t.setCopiedSessionId===e.setCopiedSessionId&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.setFolderRenameDraft===e.setFolderRenameDraft&&t.clearFolderRename===e.clearFolderRename};function t3(t){const{t:e}=vt(),{group:n,groupKey:r,projectId:i,hideGroupLabel:o,renderBody:l=!0,hasSessionSearchQuery:a,normalizedSessionSearchQuery:u,groupSearchDataByGroup:d,visibleSessionCount:h,sessionBatchSize:m,collapsedGroups:g,hideDirectoryControls:b,showMoreGroupSessions:y,resetGroupSessionLimit:S,mobileVariant:w,alwaysShowActions:f,activeProjectId:x,setActiveProjectIdOnly:v,setSessionSwitcherOpen:p,openNewSessionDraft:N,pinnedSessionIds:C,sessionOrderIndex:k,notifyOnSubtasks:D,onToggleCollapsedGroup:I,dragHandleProps:A,compactBodyPadding:P=!1,expandedParents:T,editingId:_,editingRowKey:L,openSidebarMenuKey:W,editTitle:O,copiedSessionId:$,folderRename:j,setFolderRenameDraft:E,clearFolderRename:K}=t,ee=ss(Be=>Be.toggleFolderCollapse),J=ss(Be=>Be.renameFolder),ne=ss(Be=>Be.deleteFolder),ue=ss(Be=>Be.addSessionToFolder),X=De(Be=>Be.showDeletionDialog),[te,fe]=c.useState(null),je=c.useCallback((Be,ze)=>{const qe=k.get(Be.session.id),tt=k.get(ze.session.id);if(qe!==void 0||tt!==void 0){if(qe===void 0)return 1;if(tt===void 0)return-1;if(qe!==tt)return qe-tt}return La(Be.session,ze.session,C,Ma)},[C,k]),ve=a?d.get(n):null,ye=a?!1:g.has(r),Pe=c.useMemo(()=>{if(n.isMain||n.isArchivedBucket||o)return null;const Be=gt(n.directory??null),ze=n.branch?.trim();return Be&&ze?Xo(Be,ze):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,o]),xe=Mu(Pe),R=xe?`var(--pr-${xe.visualState})`:void 0,Y=ei(),ie=c.useMemo(()=>{const Be=n.folderScopes?.map(ze=>gt(ze.directory))??[gt(n.directory??null)];return[...new Set(Be.filter(ze=>!!ze))]},[n.directory,n.folderScopes]);c.useSyncExternalStore(c.useCallback(Be=>ie.length>0?Y.subscribeBootstrap(Be):()=>{},[ie.length,Y]),c.useCallback(()=>ie.map(Be=>`${Be}\0${Y.getBootstrapState(Be)??""}\0${Y.getBootstrapFailure(Be)??""}\0${Y.getInitializationState(Be)??""}\0${Y.getInitializationFailure(Be)??""}`).join(""),[ie,Y]),c.useCallback(()=>"",[]));const H=ie.some(Be=>{const ze=Y.getBootstrapState(Be);return ze==="queued"||ze==="running"}),me=ie.find(Be=>Y.getBootstrapState(Be)==="failed"||Y.getInitializationState(Be)==="failed")??null,pe=me!==null&&Y.getBootstrapState(me)==="failed",re=me?pe?Y.getBootstrapFailure(me):Y.getInitializationFailure(me):void 0,de=re==="os-permission"&&zd(),[B,F]=c.useState(!1),he=c.useCallback(()=>{me&&Y.requestBootstrap({directory:me,priority:ye?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[Y,me,n.isMain,ye]),Se=c.useCallback(async()=>{if(!(!me||!de||B)){F(!0);try{(await Wd(me)).success&&he()}finally{F(!1)}}},[de,me,B,he]),Re=m??(b?10:5),le=Math.max(Re,h??Re),se=a?ve?.groupMatches===!0:!1,q=a,z=c.useMemo(()=>[...q?ve?.filteredNodes??[]:n.sessions].sort(je),[je,n.sessions,ve?.filteredNodes,q]),ae=n.folderScopeKey??gt(n.directory??null),ce=kr(i,n.directory),Ne=c.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:ae?[{scopeKey:ae,directory:n.directory??null}]:[],[ae,n.directory,n.folderScopes]),we=ss(ir(c.useCallback(Be=>Ne.map(({scopeKey:ze})=>Be.foldersMap[ze]??td),[Ne]))),$e=c.useMemo(()=>Ne.flatMap(({scopeKey:Be,directory:ze},qe)=>(we[qe]??td).map(yt=>({folder:yt,scopeKey:Be,scopeDirectory:ze}))),[we,Ne]),Oe=ss(ir(c.useCallback(Be=>new Set(we.flatMap(ze=>ze.filter(qe=>Be.collapsedFolderIds.has(qe.id)).map(qe=>qe.id))),[we]))),ge=c.useMemo(()=>{const Be=new Map,ze=qe=>{qe.forEach(tt=>{Be.set(tt.session.id,tt),tt.children.length>0&&ze(tt.children)})};return ze(z),Be},[z]),He=c.useMemo(()=>$e.map(({folder:Be,scopeKey:ze,scopeDirectory:qe})=>{const tt=fa(Be.sessionIds,ge).sort(je);return{folder:Be,scopeKey:ze,scopeDirectory:qe,nodes:tt}}),[$e,ge,je]),V=c.useMemo(()=>{const Be=Gf(He.map(({folder:ze,nodes:qe})=>({id:ze.id,name:ze.name,parentId:ze.parentId,nodeCount:qe.length})),{archivedBucket:n.isArchivedBucket===!0,searchQuery:a?u:""});return He.filter(({folder:ze})=>Be.has(ze.id))},[He,n.isArchivedBucket,a,u]),Ae=_,Ie=W,Fe=c.useMemo(()=>new Set(V.flatMap(Be=>Be.folder.sessionIds)),[V]),st=c.useMemo(()=>z.filter(Be=>!Fe.has(Be.session.id)),[z,Fe]),lt=c.useMemo(()=>{const Be=new Map(V.map(ze=>[ze.folder.id,ze]));return Hf(V.map(ze=>ze.folder)).map(ze=>Be.get(ze.id)).filter(ze=>!!ze)},[V]),it=c.useMemo(()=>{const Be=new Map;return V.forEach(ze=>{if(!ze.folder.parentId)return;const qe=Be.get(ze.folder.parentId)??[];qe.push(ze),Be.set(ze.folder.parentId,qe)}),Be},[V]),mt=c.useMemo(()=>{const Be=new Map(V.map(tt=>[tt.folder.id,tt])),ze=new Map,qe=(tt,yt)=>{const Ot=ze.get(tt);if(Ot!==void 0)return Ot;if(yt.has(tt))return[];yt.add(tt);const Ht=Be.get(tt),_t=Ht?[...Ht.nodes]:[];for(const zt of it.get(tt)??[])_t.push(...qe(zt.folder.id,yt));return ze.set(tt,_t),_t};return V.forEach(({folder:tt})=>qe(tt.id,new Set)),ze},[V,it]),St="project",ht=c.useMemo(()=>{const Be=new Set;return $c(z,Ae,Be),V.forEach(({nodes:ze})=>{$c(ze,Ae,Be)}),Be},[z,V,Ae]),Xe=c.useMemo(()=>{if(!Ie)return null;const Be=Vo(z,Ie,St,!!n.isArchivedBucket);if(Be)return Be;for(const{nodes:ze}of V){const qe=Vo(ze,Ie,St,!!n.isArchivedBucket);if(qe)return qe}return null},[Ie,z,V,n.isArchivedBucket]),Ct=c.useCallback(Be=>{const ze=new WeakMap,qe=tt=>{ze.set(tt,Ko(tt));for(const yt of tt.children)qe(yt)};return Be.forEach(qe),ze},[]),Mt=c.useMemo(()=>Ct(z),[Ct,z]),be=c.useMemo(()=>{const Be=new WeakMap;return V.forEach(({nodes:ze})=>{ze.forEach(qe=>Be.set(qe,Ko(qe)))}),Be},[V]),Ue=c.useCallback(Be=>Mt.get(Be)??be.get(Be)??"",[Mt,be]),ut=c.useCallback(Be=>({subtreeContainsEditing:ht,menuOpenSessionId:Xe,nodeStructureKey:Ue(Be)}),[ht,Xe,Ue]),G=st.length,U=n.isArchivedBucket||a?st:st.slice(0,le),Z=G-U.length,ke=!n.isArchivedBucket&&!a&&G>Re&&Z===0,Te=c.useCallback(Be=>{const ze=[],qe=tt=>{tt.forEach(yt=>{ze.push(yt.session),yt.children.length>0&&qe(yt.children)})};return qe(Be),ze},[]),We=c.useMemo(()=>Te(z),[Te,z]),Je=c.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const Be=new Map,ze=new Map;for(const{folder:tt}of V){if(!tt.parentId)continue;const yt=ze.get(tt.parentId)??[];yt.push(tt.id),ze.set(tt.parentId,yt)}const qe=(tt,yt)=>{if(yt.has(tt))return[];yt.add(tt);const Ot=V.find(({folder:zt})=>zt.id===tt),Ht=Ot?Te(Ot.nodes):[],_t=ze.get(tt)??[];for(const zt of _t)Ht.push(...qe(zt,yt));return Ht};for(const{folder:tt}of V)Be.set(tt.id,qe(tt.id,new Set));return Be},[V,Te,n.isArchivedBucket]);if(a&&!se&&lt.length===0&&st.length===0)return null;const nt=!n.isMain&&!!n.branch,rt=n.branch&&Dg(n.branch,n.label)?{label:n.branch}:null,Ye=ye?s.jsx(n2,{nodes:z,includeUnreadSubtasks:D}):null,Nt=(Be,ze)=>{const{folder:qe,scopeKey:tt,scopeDirectory:yt,nodes:Ot}=Be,Ht=Je.get(qe.id)??[],_t=j?.folderId===qe.id&&j?.scopeKey===tt,zt=a?!1:Oe.has(qe.id),Wt=Jt=>s.jsx(Wf,{folderId:qe.id,scopeKey:tt,ownerKey:ce,children:(es,Qt)=>s.jsx(zf,{folder:qe,displayName:ze,sessions:Ot,isCollapsed:zt,collapsedActivityState:Jt,onToggle:()=>ee(qe.id),onRename:qt=>{J(tt,qe.id,qt)},onDelete:()=>{if(n.isArchivedBucket){hn.requestDelete({sessions:Ht,mode:"session"});return}if(!X){ne(tt,qe.id);return}const qt=V.filter(({folder:wt})=>wt.parentId===qe.id).length,Et=Ot.length;fe({scopeKey:tt,folderId:qe.id,folderName:qe.name,subFolderCount:qt,sessionCount:Et})},groupDirectory:yt??n.directory,projectId:i,mobileVariant:w,alwaysShowActions:f,isRenaming:_t,renameDraft:_t?j?.draft:void 0,onRenameDraftChange:E,onRenameSave:()=>{const qt=j?.draft.trim()??"";qt&&J(tt,qe.id,qt),K()},onRenameCancel:K,droppableRef:es,isDropTarget:Qt,depth:0,onNewSession:()=>{i&&i!==x&&v(i),w&&p(!1),N({selectedProjectId:i,directoryOverride:yt??n.directory,targetFolderId:qe.id,target:n.draftTarget})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0,children:Ot.map(qt=>s.jsx(Ho,{node:qt,pinnedSessionIds:C,expandedParents:T,hasSessionSearchQuery:a,normalizedSessionSearchQuery:u,notifyOnSubtasks:D,editingId:_,editingRowKey:L,editTitle:O,copiedSessionId:$,openSidebarMenuKey:W,mobileVariant:w,alwaysShowActions:f,groupDirectory:yt??n.directory,projectId:i,folderOwnerKey:ce,selectionScopeKey:ce,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:ht,menuOpenSessionId:Xe,nodeStructureKey:Ue(qt),childRenderExtrasFor:ut},setEditingId:t.setEditingId,setEditingRowKey:t.setEditingRowKey,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,resetSessionSearch:t.resetSessionSearch,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},qt.session.id))})},qe.id);return zt?s.jsx(Qk,{nodes:mt.get(qe.id)??Ot,includeUnreadSubtasks:D,children:Wt},qe.id):Wt(null)},Ke=()=>{const Be=new Map;for(const yt of V){const Ot=yt.folder.parentId;if(!Ot)continue;const Ht=Be.get(Ot);Ht?Ht.push(yt):Be.set(Ot,[yt])}const ze=[],qe=new Set,tt=(yt,Ot)=>{if(qe.has(yt.folder.id))return;qe.add(yt.folder.id);const Ht=Ot?`${Ot} / ${yt.folder.name}`:yt.folder.name;ze.push(Nt(yt,Ht)),!(!a&&Oe.has(yt.folder.id))&&(Be.get(yt.folder.id)??[]).forEach(zt=>tt(zt,Ht))};return lt.forEach(yt=>tt(yt,"")),ze},Tt=!!(!n.isMain&&n.worktree),Ce=n.worktree?.worktreeStatus==="missing"?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:e("sessions.sidebar.group.worktreeMissing"),"aria-label":e("sessions.sidebar.group.worktreeMissing"),children:s.jsx(M,{name:"alert",className:"h-3 w-3"})}):null,ft=f?Tt?"pr-14":"pr-7":Tt?"pr-2 group-hover/gh:pr-14 group-focus-within/gh:pr-14":"pr-2 group-hover/gh:pr-7 group-focus-within/gh:pr-7",bt=me?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(re==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":pe?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),de?s.jsx(dt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:B,onClick:()=>{Se()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(dt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:he,children:e("sessions.sidebar.group.empty.retry")})]}):null,jt=Be=>s.jsx(Ho,{node:Be,pinnedSessionIds:C,expandedParents:T,hasSessionSearchQuery:a,normalizedSessionSearchQuery:u,notifyOnSubtasks:D,editingId:_,editingRowKey:L,editTitle:O,copiedSessionId:$,openSidebarMenuKey:W,mobileVariant:w,alwaysShowActions:f,groupDirectory:n.directory,projectId:i,folderOwnerKey:ce,selectionScopeKey:ce,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:ht,menuOpenSessionId:Xe,nodeStructureKey:Ue(Be),childRenderExtrasFor:ut},setEditingId:t.setEditingId,setEditingRowKey:t.setEditingRowKey,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,resetSessionSearch:t.resetSessionSearch,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},Be.session.id),Ge=s.jsxs(x2,{scopeKey:Ne[0]?.scopeKey??ae,ownerKey:ce,hasFolders:V.length>0,onSessionDroppedOnFolder:(Be,ze)=>{const qe=V.find(({folder:yt,scopeKey:Ot})=>yt.id===ze.folderId&&Ot===ze.scopeKey);if(!qe)return;const tt=ss.getState();for(const{scopeKey:yt}of Ne)yt!==qe.scopeKey&&tt.getSessionFolderId(yt,Be)&&tt.removeSessionFromFolder(yt,Be);ue(qe.scopeKey,ze.folderId,Be)},children:[Ke(),U.map(jt),G===0&&V.length===0?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:n.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):H?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(M,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):bt||(n.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,G>0&&bt?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:bt}):null,Z>0?s.jsx("button",{type:"button",onClick:()=>y(r,U.length,m??7),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,ke?s.jsx("button",{type:"button",onClick:()=>S(r),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),Le="pb-2",pt=s.jsx(em,{value:te,setValue:fe,onConfirm:()=>{const Be=te;Be&&(ne(Be.scopeKey,Be.folderId),fe(null))}});return o?l?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:Me("oc-group-body",Le),children:Ge})}),pt]}):null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"oc-group",children:[s.jsxs("div",{className:Me("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),onClick:()=>I(r),role:"button",tabIndex:0,onKeyDown:Be=>{(Be.key==="Enter"||Be.key===" ")&&(Be.preventDefault(),I(r))},"aria-label":ye?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!ye,children:[s.jsxs("div",{ref:A?.setActivatorNodeRef,className:Me("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",ft),...A?.listeners??{},children:[s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",children:[s.jsx("p",{className:"typography-ui-label font-normal truncate text-foreground/92",children:n.isArchivedBucket?s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(M,{name:"archive",className:Me("h-3.5 w-3.5 shrink-0 text-muted-foreground",f?"hidden":"group-hover/gh:hidden")}),s.jsx("span",{className:Me("text-muted-foreground h-3.5 w-3.5 items-center justify-center",f?"inline-flex":"hidden group-hover/gh:inline-flex"),children:ye?s.jsx(M,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(M,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:jo(n.label,u)}),Ce,Ye]}):!n.isMain||n.worktree?s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(M,{name:"git-branch",className:Me("h-3.5 w-3.5 shrink-0",!R&&"text-muted-foreground",f?"hidden":"group-hover/gh:hidden"),style:R?{color:R}:void 0}),s.jsx("span",{className:Me("text-muted-foreground h-3.5 w-3.5 items-center justify-center",f?"inline-flex":"hidden group-hover/gh:inline-flex"),children:ye?s.jsx(M,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(M,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 truncate typography-ui-label font-semibold text-muted-foreground",children:jo(n.label,u)}),Ce,Ye,xe?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:R?{color:R}:void 0,children:["#",xe.number]}):null]}):s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsx("span",{className:"min-w-0 truncate",children:jo(n.label,u)}),Ye]})}),nt&&rt?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(M,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(M,{name:"git-branch",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-muted-foreground/80",children:rt.label})]}):null]}),!n.isArchivedBucket&&n.directory?s.jsx(Wo,{directory:n.directory,className:"self-center"}):null]}),n.isArchivedBucket&&We.length>0?s.jsx("div",{className:Me("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",f?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Be=>{Be.stopPropagation(),hn.requestDelete({sessions:We,mode:"session"})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.deleteArchivedInGroupAria",{label:n.label}),children:s.jsx(M,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,n.directory&&!n.isMain&&n.worktree?s.jsx("div",{className:Me("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",f?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Be=>{Be.stopPropagation(),hn.requestDelete({sessions:We,mode:"worktree",worktree:n.worktree})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.deleteGroupAria",{label:n.label}),children:s.jsx(M,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteWorktree")})})]})}):null,n.directory?s.jsx("div",{className:Me("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",f?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Be=>{Be.stopPropagation(),i&&i!==x&&v(i),w&&p(!1),N({selectedProjectId:i,directoryOverride:n.directory})},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-ring","aria-label":e("sessions.sidebar.group.actions.newDraftInGroupAria",{label:n.label}),children:s.jsx(M,{name:"add",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]}),!ye&&l?s.jsx("div",{className:Me("oc-group-body",Le),children:Ge}):null]}),pt]})}const s3=c.memo(t3,e3),Ai=({projectId:t,mobileVariant:e,closeMobileSwitcher:n,setActiveProjectIdOnly:r,setSessionSwitcherOpen:i})=>{t&&r(t),e&&n&&i(!1)},sd=(t,e)=>_a(t.label?.trim()||Wn(t.normalizedPath,e)||t.normalizedPath);function n3(t){const e=et.c(99),{model:n,view:r,actions:i}=t;Qs("ui.sidebar_projects_list.render");const{t:o}=vt(),l=ei(),a=ss(h3),u=ss(m3),d=ss(f3),h=ss(u3),m=De(d3),[g,b]=c.useState(null),[y,S]=c.useState(null),[w,f]=c.useState(null),[x,v]=c.useState(null),[p,N]=c.useState(!1),C=c.useRef(null);let k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k={activationConstraint:{distance:8}},e[0]=k):k=e[0];let D;e[1]===Symbol.for("react.memo_cache_sentinel")?(D={activationConstraint:{delay:200,tolerance:6}},e[1]=D):D=e[1];let I;e[2]===Symbol.for("react.memo_cache_sentinel")?(I={coordinateGetter:tb},e[2]=I):I=e[2];const A=ti(Tn(ni,k),Tn(si,D),Tn(Zx,I));let P;e[3]===Symbol.for("react.memo_cache_sentinel")?(P=B=>{C.current=B,v(B)},e[3]=P):P=e[3];const T=P;let _;if(e[4]!==n.projectSections||e[5]!==r.homeDirectory){let B;e[7]!==r.homeDirectory?(B=F=>({id:F.project.id,projectLabel:sd(F.project,r.homeDirectory),projectDescription:Jr(F.project.normalizedPath,r.homeDirectory),projectIcon:F.project.icon,projectColor:F.project.color,projectIconImage:F.project.iconImage,projectIconBackground:F.project.iconBackground}),e[7]=r.homeDirectory,e[8]=B):B=e[8],_=n.projectSections.map(B),e[4]=n.projectSections,e[5]=r.homeDirectory,e[6]=_}else _=e[6];const L=_;let W;e:{if(!r.stickyZoneHeaders){W=-1;break e}let B;if(e[9]!==n.rowModel.stickyHeaders||e[10]!==y){let F;e[12]!==y?(F=he=>`${he.kind}:${he.id}`===y,e[12]=y,e[13]=F):F=e[13],B=n.rowModel.stickyHeaders.findIndex(F),e[9]=n.rowModel.stickyHeaders,e[10]=y,e[11]=B}else B=e[11];W=B}const O=W;let $;if(e[14]!==w||e[15]!==n.groupProps.editingRowKey||e[16]!==n.rowModel.rowIndexByKey||e[17]!==n.rowModel.rows||e[18]!==n.rowModel.stickyHeaders||e[19]!==n.state.openSidebarMenuKey||e[20]!==O){if($=new Set,w){let B;e[22]!==w||e[23]!==n.rowModel.rowIndexByKey?(B=n.rowModel.rowIndexByKey.get(w),e[22]=w,e[23]=n.rowModel.rowIndexByKey,e[24]=B):B=e[24];const F=B;F!==void 0&&$.add(F)}for(let B=0;B<n.rowModel.rows.length;B=B+1,B){const F=n.rowModel.rows[B];F?.kind==="session"&&(n.groupProps.editingRowKey===F.key||n.state.openSidebarMenuKey===`session-menu:${F.key}`||n.state.openSidebarMenuKey===`session-context:${F.key}`)&&$.add(B)}if(O>=0){const B=Math.max(0,O-1),F=Math.min(n.rowModel.stickyHeaders.length-1,O+1);for(let he=B;he<=F;he=he+1,he){const Se=n.rowModel.stickyHeaders[he];Se&&$.add(Se.rowIndex)}}e[14]=w,e[15]=n.groupProps.editingRowKey,e[16]=n.rowModel.rowIndexByKey,e[17]=n.rowModel.rows,e[18]=n.rowModel.stickyHeaders,e[19]=n.state.openSidebarMenuKey,e[20]=O,e[21]=$}else $=e[21];const j=$;let E;e[25]!==n.rowModel.stickyHeaders||e[26]!==r.stickyZoneHeaders?(E=B=>{const F=r.stickyZoneHeaders?Bk(n.rowModel.stickyHeaders,B):null,he=F?`${F.kind}:${F.id}`:null;S(Se=>Se===he?Se:he)},e[25]=n.rowModel.stickyHeaders,e[26]=r.stickyZoneHeaders,e[27]=E):E=e[27];const K=E;let ee;e[28]!==l||e[29]!==o?(ee=B=>{const F=()=>{B.status.directory&&l.requestBootstrap({directory:B.status.directory,priority:"expanded",reason:B.group.isMain?"project-expanded":"worktree-expanded",force:!0})},he=async()=>{if(!B.status.directory)return;(await Wd(B.status.directory)).success&&F()};let Se;e:switch(B.status.state){case"permission-denied":{Se=o("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{Se=o("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{Se=o("sessions.sidebar.group.empty.initializationFailed");break e}default:Se=o("sessions.sidebar.group.empty.loadingSessions")}return s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[B.status.state==="loading"?s.jsx(M,{name:"loader-4",className:"size-3 animate-spin"}):null,Se,B.status.canGrantAccess?s.jsx(dt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{he()},children:o("sessions.sidebar.group.empty.grantAccess")}):null,B.status.state!=="loading"?s.jsx(dt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:F,children:o("sessions.sidebar.group.empty.retry")}):null]})})},e[28]=l,e[29]=o,e[30]=ee):ee=e[30];const J=ee;let ne;e[31]!==i||e[32]!==d||e[33]!==n.emptyState||e[34]!==n.groupProps||e[35]!==n.projectRepoStatus||e[36]!==n.searchEmptyState||e[37]!==n.singleProjectMode||e[38]!==n.state||e[39]!==L||e[40]!==u||e[41]!==J||e[42]!==m||e[43]!==o||e[44]!==a||e[45]!==r.alwaysShowActions||e[46]!==r.hideDirectoryControls||e[47]!==r.homeDirectory||e[48]!==r.mobileVariant||e[49]!==r.projectSortOrder||e[50]!==r.stickyZoneHeaders?(ne=B=>{if(B.kind==="activity-header")return s.jsx(sm,{className:r.stickyZoneHeaders?"sticky top-0 z-20 bg-sidebar":void 0,"data-sidebar-sticky-header":r.stickyZoneHeaders?"true":void 0,children:s.jsx(Tk,{activityKey:B.activityKey,collapsed:B.collapsed,forceExpanded:B.forceExpanded,alwaysShowActions:r.alwaysShowActions,onToggle:()=>n.state.setCollapsedActivityKeys(F=>{const he=new Set(F);return he.has(B.activityKey)?he.delete(B.activityKey):he.add(B.activityKey),he}),onNewChat:()=>{De.getState().closeMainSurfaces(),r.mobileVariant&&i.setSessionSwitcherOpen(!1),i.openNewSessionDraft({selectedProjectId:Pg,directoryOverride:null})}})});if(B.kind==="project-header"){const F=B.section.project,he=sd(F,r.homeDirectory);return s.jsx(Kk,{id:F.id,disabled:n.singleProjectMode||B.forceExpanded||n.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:he,projectDescription:Jr(F.normalizedPath,r.homeDirectory),projectDirectory:F.normalizedPath,projectIcon:F.icon,projectColor:F.color,projectIconImage:F.iconImage,projectIconBackground:F.iconBackground,isCollapsed:B.collapsed,isRepo:!!n.projectRepoStatus.get(F.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:B.collapsed?i.renderProjectStatusIndicator?.(F.id,B.section.groups):null,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,projectPickerOptions:n.singleProjectMode?L:void 0,onProjectSelect:n.singleProjectMode?i.setSingleProjectId:void 0,onToggle:()=>{!B.forceExpanded&&!n.singleProjectMode&&i.toggleProject(F.id)},onNewSession:()=>{Ai({projectId:F.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:F.id,directoryOverride:F.normalizedPath})},onNewWorktreeSession:()=>{Ai({projectId:F.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewWorktreeDialog()},onManageWorktrees:()=>i.openWorktreesPage(F.id),onRenameStart:()=>i.openProjectEditDialog(F.id),onClose:()=>i.removeProject(F.id),showCreateButtons:!0})}if(B.kind==="group-header")return s.jsx(Uk,{id:B.groupKey,disabled:B.forceExpanded||n.state.editingId!==null,children:F=>s.jsx(s3,{...n.groupProps,...i.group,group:B.group,groupKey:B.groupKey,projectId:B.projectId,visibleSessionCount:n.state.visibleSessionCountByGroup.get(B.groupKey),editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,dragHandleProps:F,renderBody:!1})});if(B.kind==="folder-header"){const F=n.groupProps.folderRename?.folderId===B.folder.id&&n.groupProps.folderRename.scopeKey===B.scopeKey;return s.jsx(Wf,{folderId:B.folder.id,scopeKey:B.scopeKey,ownerKey:B.ownerKey,disabled:!B.dropEnabled,children:(he,Se)=>s.jsx(p2,{notifyOnSubtasks:n.groupProps.notifyOnSubtasks,activityNodes:B.activityNodes,folder:B.folder,displayName:B.displayName,sessions:B.nodes,isCollapsed:B.collapsed,onToggle:B.forceExpanded?c3:()=>a(B.folder.id),onRename:Re=>u(B.scopeKey,B.folder.id,Re),onDelete:()=>{B.archived?hn.requestDelete({sessions:[...B.deleteSessions],mode:"session"}):m?b({scopeKey:B.scopeKey,folderId:B.folder.id,folderName:B.folder.name,subFolderCount:B.subFolderCount,sessionCount:B.nodes.length}):d(B.scopeKey,B.folder.id)},renderBody:!1,groupDirectory:B.scopeDirectory??B.group.directory,projectId:B.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:F,renameDraft:F?n.groupProps.folderRename?.draft:void 0,onRenameDraftChange:n.groupProps.setFolderRenameDraft,onRenameSave:()=>{const Re=n.groupProps.folderRename?.draft.trim();Re&&u(B.scopeKey,B.folder.id,Re),n.groupProps.clearFolderRename()},onRenameCancel:n.groupProps.clearFolderRename,droppableRef:he,isDropTarget:Se,onNewSession:()=>{Ai({projectId:B.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:B.projectId,directoryOverride:B.scopeDirectory??B.group.directory,targetFolderId:B.folder.id,target:B.group.draftTarget})},archivedBucket:B.archived})})}if(B.kind==="session"){const F=new Set;return $n(B.node,n.state.editingId)&&F.add(B.node.session.id),s.jsx("div",{onFocusCapture:()=>f(B.key),onBlurCapture:()=>f(he=>he===B.key?null:he),children:s.jsx(Ho,{...n.groupProps,node:B.node,depth:B.depth,groupDirectory:B.groupDirectory,projectId:B.projectId,folderOwnerKey:B.ownerKey,selectionScopeKey:B.selectionScopeKey,archivedBucket:B.archived,renderContext:B.renderContext,rowKey:B.key,dragKey:B.key,secondaryMeta:B.secondaryMeta,renderChildren:!1,editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:F,menuOpenSessionId:n.state.openSidebarMenuKey===`session-menu:${B.key}`||n.state.openSidebarMenuKey===`session-context:${B.key}`?B.node.session.id:null,nodeStructureKey:Ko(B.node)}})})}return B.kind==="show-control"?s.jsx("button",{type:"button",className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",onClick:()=>{B.containerKey.startsWith("activity:")?n.state.setVisibleActivityCountByKey(F=>{const he=new Map(F);return B.control==="more"?he.set(B.containerKey,B.currentCount+B.increment):he.delete(B.containerKey),he}):B.control==="more"?i.group.showMoreGroupSessions(B.containerKey,B.currentCount,B.increment):i.group.resetGroupSessionLimit(B.containerKey)},children:o(B.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")}):B.kind==="status"?J(B):B.emptyKind==="sidebar"?n.emptyState:B.emptyKind==="search"?n.searchEmptyState:s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:B.emptyKind==="archived"?o("sessions.sidebar.group.empty.noArchivedSessions"):B.group?.emptyMessage??o("sessions.sidebar.group.empty.noSessionsInWorkspace")})},e[31]=i,e[32]=d,e[33]=n.emptyState,e[34]=n.groupProps,e[35]=n.projectRepoStatus,e[36]=n.searchEmptyState,e[37]=n.singleProjectMode,e[38]=n.state,e[39]=L,e[40]=u,e[41]=J,e[42]=m,e[43]=o,e[44]=a,e[45]=r.alwaysShowActions,e[46]=r.hideDirectoryControls,e[47]=r.homeDirectory,e[48]=r.mobileVariant,e[49]=r.projectSortOrder,e[50]=r.stickyZoneHeaders,e[51]=ne):ne=e[51];const ue=ne;let X;e[52]!==n.rowModel.rows?(X=n.rowModel.rows.flatMap(l3),e[52]=n.rowModel.rows,e[53]=X):X=e[53];const te=X;let fe;e[54]!==n.sectionsForRender?(fe=new Set(n.sectionsForRender.map(a3)),e[54]=n.sectionsForRender,e[55]=fe):fe=e[55];const je=fe;let ve;e[56]!==n.rowModel.stickyHeaders?(ve=n.rowModel.stickyHeaders.map(i3).join(""),e[56]=n.rowModel.stickyHeaders,e[57]=ve):ve=e[57];const ye=ve;let Pe;e[58]!==je?(Pe=B=>{N(je.has(String(B.active.id)))},e[58]=je,e[59]=Pe):Pe=e[59];let xe;e[60]===Symbol.for("react.memo_cache_sentinel")?(xe=()=>N(!1),e[60]=xe):xe=e[60];let R;e[61]!==i||e[62]!==h||e[63]!==n.rowModel.folderAuthorityByOwner||e[64]!==n.rowModel.folderDropTargets||e[65]!==n.rowModel.rows||e[66]!==n.sectionsForRender||e[67]!==n.state||e[68]!==r.hasSessionSearchQuery||e[69]!==r.projectSortOrder?(R=B=>{if(N(!1),!B.over)return;const F=B.active.data.current,he=B.over.data.current;if(F?.type==="session"&&F.sessionId&&F.ownerKey&&F.archivedBucket!==!0&&he?.type==="folder"&&he.folderId&&he.scopeKey&&he.ownerKey===F.ownerKey){const Oe=n.rowModel.folderDropTargets.find(V=>V.folderId===he.folderId&&V.scopeKey===he.scopeKey&&V.ownerKey===F.ownerKey),ge=n.rowModel.folderAuthorityByOwner.get(F.ownerKey);if(!Oe?.enabled||ge?.complete!==!0)return;const He=ss.getState();for(const V of ge.scopeKeys)V!==he.scopeKey&&He.removeSessionFromFolder(V,F.sessionId);h(he.scopeKey,he.folderId,F.sessionId);return}if(r.hasSessionSearchQuery||n.state.editingId!==null||B.active.id===B.over.id)return;const Se=String(B.active.id),Re=String(B.over.id),le=n.sectionsForRender.map(o3),se=le.indexOf(Se),q=le.indexOf(Re);if(se>=0&&q>=0&&r.projectSortOrder==="manual"){i.reorderProjects(se,q);return}const z=n.rowModel.rows.find(Oe=>Oe.kind==="group-header"&&Oe.groupKey===Se),ae=n.rowModel.rows.find(Oe=>Oe.kind==="group-header"&&Oe.groupKey===Re);if(!z||!ae||z.projectId!==ae.projectId||!z.projectId)return;const ce=z.projectId,Ne=n.sectionsForRender.find(Oe=>Oe.project.id===ce);if(!Ne)return;const we=Ne.groups.findIndex(Oe=>Oe.id===z.group.id),$e=Ne.groups.findIndex(Oe=>Oe.id===ae.group.id);we<0||$e<0||i.setGroupOrderByProject(Oe=>new Map(Oe).set(ce,Uu(Ne.groups,we,$e).map(r3)))},e[61]=i,e[62]=h,e[63]=n.rowModel.folderAuthorityByOwner,e[64]=n.rowModel.folderDropTargets,e[65]=n.rowModel.rows,e[66]=n.sectionsForRender,e[67]=n.state,e[68]=r.hasSessionSearchQuery,e[69]=r.projectSortOrder,e[70]=R):R=e[70];let Y;e[71]!==K||e[72]!==n.rowModel||e[73]!==j||e[74]!==ue||e[75]!==x?(Y=s.jsx(Ik,{model:n.rowModel,scrollElement:x,pinnedRowIndexes:j,renderRow:ue,onFirstVisibleIndexChange:K}),e[71]=K,e[72]=n.rowModel,e[73]=j,e[74]=ue,e[75]=x,e[76]=Y):Y=e[76];let ie;e[77]!==te||e[78]!==Y?(ie=s.jsx(Va,{items:te,strategy:Hu,children:Y}),e[77]=te,e[78]=Y,e[79]=ie):ie=e[79];let H;e[80]!==A||e[81]!==Pe||e[82]!==R||e[83]!==ie?(H=s.jsx(jn,{ref:T,useScrollShadow:!0,hideTopScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:"oc-sidebar-scroller pb-1 pl-2.5 pr-2 [overflow-anchor:none]",children:s.jsx(ri,{sensors:A,collisionDetection:oi,onDragStart:Pe,onDragCancel:xe,onDragEnd:R,children:ie})}),e[80]=A,e[81]=Pe,e[82]=R,e[83]=ie,e[84]=H):H=e[84];let me;e[85]!==p||e[86]!==H||e[87]!==r.stickyZoneHeaders||e[88]!==ye?(me=s.jsx(_k,{enabled:r.stickyZoneHeaders,suspended:p,layoutKey:ye,scrollRef:C,children:H}),e[85]=p,e[86]=H,e[87]=r.stickyZoneHeaders,e[88]=ye,e[89]=me):me=e[89];let pe;e[90]!==d||e[91]!==g?(pe=()=>{g&&(d(g.scopeKey,g.folderId),b(null))},e[90]=d,e[91]=g,e[92]=pe):pe=e[92];let re;e[93]!==g||e[94]!==pe?(re=s.jsx(em,{value:g,setValue:b,onConfirm:pe}),e[93]=g,e[94]=pe,e[95]=re):re=e[95];let de;return e[96]!==me||e[97]!==re?(de=s.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[me,re]}),e[96]=me,e[97]=re,e[98]=de):de=e[98],de}function r3(t){return t.id}function o3(t){return t.project.id}function i3(t){const{kind:e,id:n,rowIndex:r}=t;return`${e}:${n}:${r}`}function a3(t){return t.project.id}function l3(t){return t.kind==="project-header"?[t.section.project.id]:t.kind==="group-header"?[t.groupKey]:[]}function c3(){}function d3(t){return t.showDeletionDialog}function u3(t){return t.addSessionToFolder}function f3(t){return t.deleteFolder}function m3(t){return t.renameFolder}function h3(t){return t.toggleFolderCollapse}const p3=c.memo(n3),xa=new Map,nd=(t,e)=>{for(const n of t){const r=gt(n??null);r&&!xa.has(r)&&xa.set(r,e)}},rd=t=>{const e=gt(t??null);return e?xa.get(e)??0:0},_r=t=>!!t.time?.archived,g3=t=>{const{t:e}=vt(),n=c.useRef(t.gitBranches);n.current=t.gitBranches;const r=c.useCallback(a=>[a.label,a.branch??"",a.description??"",a.directory??""].join(" ").toLowerCase(),[]),i=c.useCallback(a=>{const u=gt(a.directory??null)??"";return`${(a.title||e("sessions.sidebar.session.untitled")).trim()} ${u}`.toLowerCase()},[e]),o=c.useCallback((a,u)=>{if(!u)return a;const d=u.trim().toLowerCase(),h=d.startsWith("ses_");return a.flatMap(m=>{if(h&&_r(m.session))return[];if(h?m.session.id.toLowerCase()===d:Ro([i(m.session)],u))return[m];const b=o(m.children,u);return b.length===0?[]:[{...m,children:b}]})},[i]),l=c.useCallback((a,u,d,h,m)=>{const g=gt(u??null),b=Tu(a),y=new Map(b.map(O=>[O.id,O])),S=new Map;b.forEach(O=>{const $=O.parentID;if(!$)return;const j=y.get($);if(!j||_r(j)!==_r(O))return;const E=S.get($)??[];E.push(O),S.set($,E)});const w=new Map;d.forEach(O=>{if(O.path){const $=gt(O.path)??O.path;w.set($,O)}});const f=O=>{const $=gt(O.directory??null),j=t.worktreeMetadata.get(O.id)??null;if(j)return j;if($){const E=w.get($)??null;if(E&&$!==g)return E}return null},x=new Set,v=O=>{x.add(O.id);const $=S.get(O.id)??[],j=[];for(const E of $)x.has(E.id)||j.push(v(E));return{session:O,children:j,worktree:f(O)}},p=b.filter(O=>{const $=O.parentID;if(!$)return!0;const j=y.get($);return j?_r(j)!==_r(O):!0}),N=[],C=O=>{x.has(O.id)||N.push(v(O))};p.forEach(C),b.forEach(C);const k=new Map,D="__archived__",I=O=>{if(O.time?.archived)return D;if(t.isVSCode)return g??"__project_root__";const j=gt(t.worktreeMetadata.get(O.id)?.path??null)??Ps(O);return j?j!==g&&w.has(j)?j:j===g?g??"__project_root__":D:D};N.forEach(O=>{const $=I(O.session);k.has($)||k.set($,[]),k.get($)?.push(O)});const A=g??"__project_root__",P=[{id:"root",label:m&&h&&h!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:h}):e("sessions.sidebar.grouping.projectRoot"),branch:h??null,description:g?Jr(g,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:g,folderScopeKey:g,sessions:k.get(A)??[]}],T=new Map;d.forEach(O=>{const $=gt(O.path)??O.path,j=k.get($)??[],E=j.length>0,K=j.reduce((ee,J)=>{const ne=Ig(J.session,t.sessionOrderRanks);return Number.isFinite(ne)?Math.max(ee,ne):ee},0);T.set($,{hasActiveSession:E,lastUpdatedAt:K})});const _=[...d].sort((O,$)=>{const j=gt(O.path)??O.path,E=gt($.path)??$.path,K=T.get(j)??{hasActiveSession:!1,lastUpdatedAt:0},ee=T.get(E)??{hasActiveSession:!1,lastUpdatedAt:0};if(K.hasActiveSession!==ee.hasActiveSession)return K.hasActiveSession?-1:1;if(K.hasActiveSession&&ee.hasActiveSession)return ee.lastUpdatedAt-K.lastUpdatedAt;const J=rd(O.path),ne=rd($.path);if(J!==ne)return ne-J;const ue=(O.label||O.branch||O.name||O.path||"").toLowerCase(),X=($.label||$.branch||$.name||$.path||"").toLowerCase();return ue.localeCompare(X)});(t.isVSCode?[]:_).forEach(O=>{const $=gt(O.path)??O.path,j=n.current.get($)?.trim()||null,E=O.branch?.trim()||null,ee=!!(j&&E&&O.label&&Ml(O.label)===Ml(E))?j:O.label||O.name||Wn($,t.homeDirectory)||$;P.push({id:`worktree:${$}`,label:ee,branch:j||E,description:Jr($,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:O,directory:$,folderScopeKey:$,sessions:k.get($)??[]})});const W=k.get(D)??[];return W.length>0&&P.push({id:"archived",label:e("sessions.sidebar.grouping.archived"),branch:null,description:e("sessions.sidebar.grouping.archivedDescription"),isMain:!1,isArchivedBucket:!0,worktree:null,directory:null,folderScopeKey:!t.isVSCode&&g?Iu(g):null,sessions:W}),P},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.isVSCode,e]);return{buildGroupSearchText:r,buildSessionSearchText:i,filterSessionNodesForSearch:o,buildGroupedSessions:l}},x3=t=>{const e=et.c(51),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:u,canRemoveFromFolder:d,onRestore:h,onDelete:m,onDone:g}=t,{t:b}=vt(),y=!!r&&!o;let S;e[0]!==o||e[1]!==b?(S=b(o?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[0]=o,e[1]=b,e[2]=S):S=e[2];const w=S;let f;e[3]!==n||e[4]!==b?(f=b("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[3]=n,e[4]=b,e[5]=f):f=e[5];let x;e[6]!==f?(x=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:f}),e[6]=f,e[7]=x):x=e[7];let v;e[8]!==y||e[9]!==d||e[10]!==a||e[11]!==l||e[12]!==u||e[13]!==i||e[14]!==b?(v=y?s.jsxs(zs,{children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(Ls,{asChild:!0,children:s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 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-ring","aria-label":b("sessions.sidebar.bulkActions.moveToFolder"),children:s.jsx(M,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs($s,{align:"end",className:"min-w-[180px]",children:[i.length===0?s.jsx(Kt,{disabled:!0,className:"text-muted-foreground",children:b("sessions.sidebar.folders.none")}):i.map(j=>s.jsx(Kt,{onClick:()=>l(j.id),children:s.jsx("span",{className:"flex-1 truncate",children:j.name})},j.id)),s.jsx(Rs,{}),s.jsxs(Kt,{onClick:a,children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"}),b("sessions.sidebar.folders.newFolderEllipsis")]}),d?s.jsxs(Kt,{onClick:u,className:"text-destructive focus:text-destructive",children:[s.jsx(M,{name:"close",className:"mr-1 h-4 w-4"}),b("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[8]=y,e[9]=d,e[10]=a,e[11]=l,e[12]=u,e[13]=i,e[14]=b,e[15]=v):v=e[15];let p;e[16]!==o||e[17]!==h||e[18]!==b?(p=o?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,className:"inline-flex h-7 w-7 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-ring","aria-label":b("sessions.sidebar.bulkActions.restore"),children:s.jsx(M,{name:"inbox-unarchive",className:"h-4 w-4"})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.restore")})})]}):null,e[16]=o,e[17]=h,e[18]=b,e[19]=p):p=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=Me("inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50"),e[20]=N):N=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(M,{name:"delete-bin",className:"h-4 w-4"}),e[21]=C):C=e[21];let k;e[22]!==w||e[23]!==m?(k=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,className:N,"aria-label":w,children:C})}),e[22]=w,e[23]=m,e[24]=k):k=e[24];let D;e[25]!==w?(D=s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:w})}),e[25]=w,e[26]=D):D=e[26];let I;e[27]!==k||e[28]!==D?(I=s.jsxs(Dt,{children:[k,D]}),e[27]=k,e[28]=D,e[29]=I):I=e[29];let A;e[30]!==b?(A=b("sessions.sidebar.header.actions.exitSelection"),e[30]=b,e[31]=A):A=e[31];let P;e[32]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(M,{name:"close",className:"h-4 w-4"}),e[32]=P):P=e[32];let T;e[33]!==g||e[34]!==A?(T=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:g,className:"inline-flex h-7 w-7 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-ring","aria-label":A,children:P})}),e[33]=g,e[34]=A,e[35]=T):T=e[35];let _;e[36]!==b?(_=b("sessions.sidebar.header.actions.exitSelection"),e[36]=b,e[37]=_):_=e[37];let L;e[38]!==_?(L=s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:_})}),e[38]=_,e[39]=L):L=e[39];let W;e[40]!==T||e[41]!==L?(W=s.jsxs(Dt,{children:[T,L]}),e[40]=T,e[41]=L,e[42]=W):W=e[42];let O;e[43]!==I||e[44]!==W||e[45]!==v||e[46]!==p?(O=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[v,p,I,W]}),e[43]=I,e[44]=W,e[45]=v,e[46]=p,e[47]=O):O=e[47];let $;return e[48]!==O||e[49]!==x?($=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5",children:[x,O]}),e[48]=O,e[49]=x,e[50]=$):$=e[50],$},od=new Map,b3=(t,e)=>{if(!t)return[];const n=e(t);return n.length>0?n.map(r=>r.scopeKey):[t]},y3=(t,e)=>{const n=t.sessionIds.filter(o=>e.has(o));if(n.length===0)return{ready:!1,value:null};const r=Uf(new Set(n),e),i={sessionIds:n,sessionCount:n.length,archivedBucket:r};return{ready:n.length===t.sessionIds.length&&r===t.archivedBucket,value:i}},w3=t=>{const e=et.c(77),{t:n}=vt(),{isInlineEditing:r,showDeletionDialog:i,foldersMap:o,getFolderScopesForProject:l,addSessionsToFolder:a,removeSessionsFromFolders:u,createFolderAndStartRename:d,archiveSessions:h,unarchiveSessions:m,deleteSessions:g,bulkDeleteConfirm:b,setBulkDeleteConfirm:y}=t,S=ps(v3),w=ps(S3),f=w>0,x=ps(j3),v=ps(k3),p=Vf(),N=C3,C=N3;let k;e[0]!==f||e[1]!==p||e[2]!==x?(k=f&&Uf(x,p?.getSessionsById()??od),e[0]=f,e[1]=p,e[2]=x,e[3]=k):k=e[3];const D=k;let I;e:{if(v){I=v;break e}I=null}const A=I;let P;e[4]!==A||e[5]!==l?(P=b3(A,l),e[4]=A,e[5]=l,e[6]=P):P=e[6];const T=P;let _;if(e[7]!==o||e[8]!==T){let pe;e[10]!==o?(pe=re=>o[re]??[],e[10]=o,e[11]=pe):pe=e[11],_=T.flatMap(pe),e[7]=o,e[8]=T,e[9]=_}else _=e[9];const L=_;let W;e[12]!==o||e[13]!==T?(W=pe=>{for(const re of T)if((o[re]??[]).some(de=>de.id===pe))return re;return null},e[12]=o,e[13]=T,e[14]=W):W=e[14];const O=W;let $;e:{if(!f){$=!1;break e}for(const pe of T)for(const re of o[pe]??[])for(const de of re.sessionIds)if(x.has(de)){$=!0;break e}$=!1}const j=$;let E;e[15]!==a||e[16]!==u||e[17]!==x||e[18]!==T?(E=(pe,re)=>{const de=Array.from(x);for(const B of T)B!==pe&&u(B,de);a(pe,re,de)},e[15]=a,e[16]=u,e[17]=x,e[18]=T,e[19]=E):E=e[19];const K=E;let ee;e[20]!==f||e[21]!==K||e[22]!==O?(ee=pe=>{if(!f)return;const re=O(pe);re&&K(re,pe)},e[20]=f,e[21]=K,e[22]=O,e[23]=ee):ee=e[23];const J=ee;let ne;e[24]!==d||e[25]!==f||e[26]!==K||e[27]!==T?(ne=()=>{const pe=T[0];if(!pe||!f)return;const re=d(pe);re&&K(pe,re.id)},e[24]=d,e[25]=f,e[26]=K,e[27]=T,e[28]=ne):ne=e[28];const ue=ne;let X;e[29]!==f||e[30]!==u||e[31]!==x||e[32]!==T?(X=()=>{if(!f)return;const pe=Array.from(x);for(const re of T)u(re,pe)},e[29]=f,e[30]=u,e[31]=x,e[32]=T,e[33]=X):X=e[33];const te=X;let fe;e[34]!==h||e[35]!==g||e[36]!==n?(fe=async(pe,re)=>{if(pe.length!==0)if(re){const{deletedIds:de,failedIds:B}=await g(pe);de.length>0&&_e.success(de.length===1?n("sessions.sidebar.bulkActions.deletedSingle",{count:de.length}):n("sessions.sidebar.bulkActions.deletedPlural",{count:de.length})),B.length>0&&_e.error(B.length===1?n("sessions.sidebar.bulkActions.failedDeleteSingle",{count:B.length}):n("sessions.sidebar.bulkActions.failedDeletePlural",{count:B.length})),ps.getState().removeMany(de)}else{const{archivedIds:de,failedIds:B}=await h(pe);de.length>0&&_e.success(de.length===1?n("sessions.sidebar.bulkActions.archivedSingle",{count:de.length}):n("sessions.sidebar.bulkActions.archivedPlural",{count:de.length})),B.length>0&&_e.error(B.length===1?n("sessions.sidebar.bulkActions.failedArchiveSingle",{count:B.length}):n("sessions.sidebar.bulkActions.failedArchivePlural",{count:B.length})),ps.getState().removeMany(de)}},e[34]=h,e[35]=g,e[36]=n,e[37]=fe):fe=e[37];const je=fe;let ve;e[38]!==D||e[39]!==je||e[40]!==f||e[41]!==x||e[42]!==y||e[43]!==i?(ve=()=>{if(!f)return;const pe=Array.from(x);if(!i){je(pe,D);return}y({sessionIds:pe,sessionCount:pe.length,archivedBucket:D})},e[38]=D,e[39]=je,e[40]=f,e[41]=x,e[42]=y,e[43]=i,e[44]=ve):ve=e[44];const ye=ve;let Pe;e[45]!==D||e[46]!==f||e[47]!==x||e[48]!==n||e[49]!==m?(Pe=async()=>{if(!f||!D)return;const pe=Array.from(x),{restoredIds:re,failedIds:de}=await m(pe);re.length>0&&_e.success(re.length===1?n("sessions.sidebar.bulkActions.restoredSingle",{count:re.length}):n("sessions.sidebar.bulkActions.restoredPlural",{count:re.length})),de.length>0&&_e.error(de.length===1?n("sessions.sidebar.bulkActions.failedRestoreSingle",{count:de.length}):n("sessions.sidebar.bulkActions.failedRestorePlural",{count:de.length})),ps.getState().removeMany(re)},e[45]=D,e[46]=f,e[47]=x,e[48]=n,e[49]=m,e[50]=Pe):Pe=e[50];const xe=Pe;let R;e[51]!==b||e[52]!==je||e[53]!==p||e[54]!==y?(R=async()=>{if(!b)return;const pe=p?.getSessionsById()??od,re=y3(b,pe);if(!re.ready){y(re.value);return}y(null),await je(re.value.sessionIds,re.value.archivedBucket)},e[51]=b,e[52]=je,e[53]=p,e[54]=y,e[55]=R):R=e[55];const Y=R;let ie,H;e[56]!==b||e[57]!==ye||e[58]!==r||e[59]!==p||e[60]!==S?(ie=()=>{if(!S)return;const pe=/Macintosh|Mac OS X/.test(navigator.userAgent||""),re=de=>{if(b||r)return;const B=de.target instanceof HTMLElement?de.target:null;if(B&&(B.tagName==="INPUT"||B.tagName==="TEXTAREA"||B.isContentEditable))return;const F=pe?de.metaKey:de.ctrlKey;if(de.key==="Escape"){de.preventDefault(),ps.getState().disable();return}if(F&&de.key==="Backspace"){de.preventDefault(),ye();return}if(F&&(de.key==="a"||de.key==="A")){const he=y2(p?.getEntries()??[],p?.getDescendantIds()??[],ps.getState().scopeKey);if(!he)return;de.preventDefault(),ps.getState().replaceAll(he.ids,he.scopeKey)}};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},H=[b,ye,r,p,S],e[56]=b,e[57]=ye,e[58]=r,e[59]=p,e[60]=S,e[61]=ie,e[62]=H):(ie=e[61],H=e[62]),c.useEffect(ie,H);let me;return e[63]!==j||e[64]!==L||e[65]!==D||e[66]!==Y||e[67]!==A||e[68]!==ue||e[69]!==ye||e[70]!==J||e[71]!==te||e[72]!==xe||e[73]!==f||e[74]!==w||e[75]!==S?(me={selectionModeEnabled:S,hasSelection:f,selectedIdsSize:w,bulkScopeIsArchived:D,derivedSelectionScope:A,bulkScopeFolders:L,bulkCanRemoveFromFolder:j,handleToggleSelectionMode:N,handleExitSelectionMode:C,handleBulkMoveToFolder:J,handleBulkCreateFolderAndMove:ue,handleBulkRemoveFromFolder:te,handleBulkDelete:ye,handleBulkRestore:xe,confirmBulkDelete:Y},e[63]=j,e[64]=L,e[65]=D,e[66]=Y,e[67]=A,e[68]=ue,e[69]=ye,e[70]=J,e[71]=te,e[72]=xe,e[73]=f,e[74]=w,e[75]=S,e[76]=me):me=e[76],me};function v3(t){return t.enabled}function S3(t){return t.selectedIds.size}function j3(t){return t.selectedIds}function k3(t){return t.scopeKey}function C3(){ps.getState().toggleMode()}function N3(){ps.getState().disable()}function A3(t){const e=et.c(37),{getFolderScopesForProject:n,isInlineEditing:r,startFolderRename:i}=t,[o,l]=c.useState(null),a=De(B3),u=De(O3),d=ss(M3),h=ss(R3),m=ss(E3),g=ss(T3),b=Ze(I3),y=Ze(P3),S=Ze(D3);let w;e[0]!==h||e[1]!==i?(w=C=>{const k=h(C,"New folder");return i(C,k),k},e[0]=h,e[1]=i,e[2]=w):w=e[2];let f;e[3]!==m||e[4]!==b||e[5]!==o||e[6]!==S||e[7]!==d||e[8]!==n||e[9]!==r||e[10]!==g||e[11]!==a||e[12]!==w||e[13]!==y?(f={isInlineEditing:r,showDeletionDialog:a,foldersMap:d,getFolderScopesForProject:n,addSessionsToFolder:m,removeSessionsFromFolders:g,createFolderAndStartRename:w,archiveSessions:b,unarchiveSessions:y,deleteSessions:S,bulkDeleteConfirm:o,setBulkDeleteConfirm:l},e[3]=m,e[4]=b,e[5]=o,e[6]=S,e[7]=d,e[8]=n,e[9]=r,e[10]=g,e[11]=a,e[12]=w,e[13]=y,e[14]=f):f=e[14];const x=w3(f);let v;e[15]!==x.bulkCanRemoveFromFolder||e[16]!==x.bulkScopeFolders||e[17]!==x.bulkScopeIsArchived||e[18]!==x.derivedSelectionScope||e[19]!==x.handleBulkCreateFolderAndMove||e[20]!==x.handleBulkDelete||e[21]!==x.handleBulkMoveToFolder||e[22]!==x.handleBulkRemoveFromFolder||e[23]!==x.handleBulkRestore||e[24]!==x.handleExitSelectionMode||e[25]!==x.hasSelection||e[26]!==x.selectedIdsSize||e[27]!==x.selectionModeEnabled?(v=x.selectionModeEnabled&&x.hasSelection?s.jsx(x3,{selectedCount:x.selectedIdsSize,scopeKey:x.derivedSelectionScope,scopeFolders:x.bulkScopeFolders,archivedBucket:x.bulkScopeIsArchived,onMoveToFolder:x.handleBulkMoveToFolder,onCreateFolderAndMove:x.handleBulkCreateFolderAndMove,onRemoveFromFolder:x.handleBulkRemoveFromFolder,canRemoveFromFolder:x.bulkCanRemoveFromFolder,onRestore:x.handleBulkRestore,onDelete:x.handleBulkDelete,onDone:x.handleExitSelectionMode}):null,e[15]=x.bulkCanRemoveFromFolder,e[16]=x.bulkScopeFolders,e[17]=x.bulkScopeIsArchived,e[18]=x.derivedSelectionScope,e[19]=x.handleBulkCreateFolderAndMove,e[20]=x.handleBulkDelete,e[21]=x.handleBulkMoveToFolder,e[22]=x.handleBulkRemoveFromFolder,e[23]=x.handleBulkRestore,e[24]=x.handleExitSelectionMode,e[25]=x.hasSelection,e[26]=x.selectedIdsSize,e[27]=x.selectionModeEnabled,e[28]=v):v=e[28];let p;e[29]!==x.confirmBulkDelete||e[30]!==o||e[31]!==u||e[32]!==a?(p=s.jsx(wk,{value:o,setValue:l,showDeletionDialog:a,setShowDeletionDialog:u,onConfirm:x.confirmBulkDelete}),e[29]=x.confirmBulkDelete,e[30]=o,e[31]=u,e[32]=a,e[33]=p):p=e[33];let N;return e[34]!==v||e[35]!==p?(N=s.jsxs(s.Fragment,{children:[v,p]}),e[34]=v,e[35]=p,e[36]=N):N=e[36],N}function D3(t){return t.deleteSessions}function P3(t){return t.unarchiveSessions}function I3(t){return t.archiveSessions}function T3(t){return t.removeSessionsFromFolders}function E3(t){return t.addSessionsToFolder}function R3(t){return t.createFolder}function M3(t){return t.foldersMap}function O3(t){return t.setShowDeletionDialog}function B3(t){return t.showDeletionDialog}const nm="oc.sessions.expandedParents.v3",F3=Ua(Nr()),_3=()=>{try{const t=globalThis.localStorage.getItem(nm);if(t===null)return new Set;const e=F3.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},L3=()=>{const[t,e]=c.useState(_3),n=c.useRef(t);n.current=t;const r=c.useCallback(i=>{const o=Tg(n.current,i);n.current=o,e(o);try{globalThis.localStorage.setItem(nm,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},$3=t=>{const e=et.c(20),{childStores:n,sections:r,chatGroup:i,canGrantAccess:o}=t;let l;e[0]!==i||e[1]!==r?(l=[...r.flatMap(z3),...i?[{key:"activity:chats",group:i}]:[]].map(V3),e[0]=i,e[1]=r,e[2]=l):l=e[2];const a=l;let u;e[3]!==a?(u=new Set(a.flatMap(U3)),e[3]=a,e[4]=u):u=e[4];let d;e[5]!==u?(d=[...u],e[5]=u,e[6]=d):d=e[6];const h=d;let m;e[7]!==n||e[8]!==h.length?(m=f=>h.length>0?n.subscribeBootstrap(f):H3,e[7]=n,e[8]=h.length,e[9]=m):m=e[9];let g;e[10]!==n||e[11]!==h?(g=()=>h.map(f=>`${f}\0${n.getBootstrapState(f)??""}\0${n.getBootstrapFailure(f)??""}\0${n.getInitializationState(f)??""}\0${n.getInitializationFailure(f)??""}`).join(""),e[10]=n,e[11]=h,e[12]=g):g=e[12];const b=c.useSyncExternalStore(m,g,G3);let y;if(e[13]!==o||e[14]!==n||e[15]!==a){y=new Map;for(const{key:f,directories:x}of a){const v=x.find(p=>n.getBootstrapState(p)==="failed"||n.getInitializationState(p)==="failed");if(v){const p=n.getBootstrapState(v)==="failed",N=p?n.getBootstrapFailure(v):n.getInitializationFailure(v);y.set(f,{state:N==="os-permission"?"permission-denied":p?"load-failed":"initialization-failed",directory:v,canGrantAccess:N==="os-permission"&&o})}else{const p=x.some(N=>{const C=n.getBootstrapState(N);return C==="queued"||C==="running"});y.set(f,{state:p?"loading":"ready",directory:x[0]??null,canGrantAccess:!1})}}e[13]=o,e[14]=n,e[15]=a,e[16]=y}else y=e[16];const S=y;let w;return e[17]!==b||e[18]!==S?(w={groupStatusByKey:S,bootstrapSnapshot:b},e[17]=b,e[18]=S,e[19]=w):w=e[19],w};function z3(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function W3(t){return gt(t.directory)}function K3(t){return!!t}function V3(t){const{key:e,group:n}=t;return{key:e,directories:Zr(n).map(W3).filter(K3)}}function U3(t){return t.directories}function H3(){}function G3(){return""}const q3=5*6e4,Y3=[],Q3=t=>!t.parentID,X3=t=>{const e=et.c(297),{topology:n,view:r,actions:i}=t;let o,l,a,u,d;e[0]!==i?({alwaysShowActions:o,notifyOnSubtasks:l,projectViewActions:a,rowActions:u,...d}=i,e[0]=i,e[1]=o,e[2]=l,e[3]=a,e[4]=u,e[5]=d):(o=e[1],l=e[2],a=e[3],u=e[4],d=e[5]);const h=ss(Z3),m=ss(e4),g=ss(t4),b=ss(s4),y=r.projectView,{getOrderedGroups:S,setGroupOrderByProject:w,toggleGroup:f,toggleProject:x}=a;let v;e[6]!==n.isVSCode||e[7]!==n.knownDirectories?(v={knownDirectories:n.knownDirectories,isVSCode:n.isVSCode,isVisible:!0},e[6]=n.isVSCode,e[7]=n.knownDirectories,e[8]=v):v=e[8];const p=Oh(v);let N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=new Map,e[9]=N):N=e[9];const[C,k]=c.useState(N);let D;e[10]===Symbol.for("react.memo_cache_sentinel")?(D=new Set,e[10]=D):D=e[10];const[I,A]=c.useState(D);let P;e[11]===Symbol.for("react.memo_cache_sentinel")?(P=new Map,e[11]=P):P=e[11];const[T,_]=c.useState(P);let L;e[12]===Symbol.for("react.memo_cache_sentinel")?(L=(ot,At,Q)=>{const Ve=Q===void 0?7:Q;k(at=>new Map(at).set(ot,At+Ve))},e[12]=L):L=e[12];const W=L;let O;e[13]===Symbol.for("react.memo_cache_sentinel")?(O=ot=>{k(At=>{if(!At.has(ot))return At;const Q=new Map(At);return Q.delete(ot),Q})},e[13]=O):O=e[13];const $=O,j=hs(n4),E=hs(r4),K=hs(o4),ee=hs(i4);let J;e[14]!==n.isVSCode?(J=!n.isVSCode&&!rh(),e[14]=n.isVSCode,e[15]=J):J=e[15];const ue=J&&E==="single",X=j&&!ue;let te;e[16]!==p.pinnedSessionIds||e[17]!==p.rootSessions||e[18]!==p.sessionOrderRanks||e[19]!==X||e[20]!==n.isVSCode?(te={enabled:X,isVSCode:n.isVSCode,pinnedSessionIds:p.pinnedSessionIds,sessionOrderRanks:p.sessionOrderRanks,sessions:p.rootSessions},e[16]=p.pinnedSessionIds,e[17]=p.rootSessions,e[18]=p.sessionOrderRanks,e[19]=X,e[20]=n.isVSCode,e[21]=te):te=e[21];const fe=Bh(te),[je,ve]=c.useState(null),[ye,Pe]=c.useState(null),[xe,R]=c.useState(""),[Y,ie]=c.useState(null),[H,me]=c.useState(null),[pe,re]=c.useState(null),[de,B]=c.useState(null);let F;e[22]===Symbol.for("react.memo_cache_sentinel")?(F=(ot,At)=>{B({scopeKey:ot,folderId:At.id,draft:At.name})},e[22]=F):F=e[22];const he=F;let Se;e[23]===Symbol.for("react.memo_cache_sentinel")?(Se=ot=>{B(At=>At?{...At,draft:ot}:null)},e[23]=Se):Se=e[23];const Re=Se;let le;e[24]===Symbol.for("react.memo_cache_sentinel")?(le=()=>B(null),e[24]=le):le=e[24];const se=le,{expandedParents:q,toggleParent:z}=L3(),ae=Ze(a4);let ce;e[25]!==ae?(ce=(ot,At)=>{ot!==Ze.getState().currentSessionId&&ae(ot,At)},e[25]=ae,e[26]=ce):ce=e[26];const Ne=ce,we=Ou();let $e;e[27]!==p.pinnedSessionIds||e[28]!==p.sessionOrderRanks||e[29]!==n.gitBranches||e[30]!==n.isVSCode||e[31]!==n.worktreeMetadata||e[32]!==r.homeDirectory?($e={homeDirectory:r.homeDirectory,worktreeMetadata:n.worktreeMetadata,pinnedSessionIds:p.pinnedSessionIds,sessionOrderRanks:p.sessionOrderRanks,gitBranches:n.gitBranches,isVSCode:n.isVSCode},e[27]=p.pinnedSessionIds,e[28]=p.sessionOrderRanks,e[29]=n.gitBranches,e[30]=n.isVSCode,e[31]=n.worktreeMetadata,e[32]=r.homeDirectory,e[33]=$e):$e=e[33];const{buildGroupedSessions:Oe,filterSessionNodesForSearch:ge,buildGroupSearchText:He}=g3($e);let V;e[34]!==p.archivedSessions||e[35]!==p.sessions||e[36]!==n.availableWorktreesByProject||e[37]!==n.isVSCode||e[38]!==n.projects?(V=Vj(p.sessions,n.projects,n.availableWorktreesByProject,n.isVSCode,p.archivedSessions),e[34]=p.archivedSessions,e[35]=p.sessions,e[36]=n.availableWorktreesByProject,e[37]=n.isVSCode,e[38]=n.projects,e[39]=V):V=e[39];const Ae=V;let Ie;e[40]!==Ae?(Ie={ownership:Ae},e[40]=Ae,e[41]=Ie):Ie=e[41];const{getSessionsForProject:Fe,getArchivedSessionsForProject:st}=Uj(Ie);let lt;e:{if(n.isVSCode){lt=null;break e}let ot;e[42]!==p.chatSessions||e[43]!==r.homeDirectory?(ot=Eg(r.homeDirectory)??p.chatSessions.map(l4).find(Boolean)??null,e[42]=p.chatSessions,e[43]=r.homeDirectory,e[44]=ot):ot=e[44];const At=ot;if(!At){lt=null;break e}let Q;if(e[45]!==At||e[46]!==p.chatSessions){const Vt=[At,...p.chatSessions.map(c4).filter(Boolean)];let Ut;e[48]!==Vt?(Ut=new Set(Vt),e[48]=Vt,e[49]=Ut):Ut=e[49],Q=Array.from(Ut).filter(d4).map(u4),e[45]=At,e[46]=p.chatSessions,e[47]=Q}else Q=e[47];const Ve=Q;let at;if(e[50]!==p.chatSessions||e[51]!==p.childrenMap){let Vt;e[53]!==p.childrenMap?(Vt=Ut=>wl(p.childrenMap,Ut),e[53]=p.childrenMap,e[54]=Vt):Vt=e[54],at=p.chatSessions.filter(f4).map(Vt),e[50]=p.chatSessions,e[51]=p.childrenMap,e[52]=at}else at=e[52];let Rt;e[55]!==At||e[56]!==Ve||e[57]!==at?(Rt={id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:At,folderScopeKey:At,folderScopes:Ve,draftTarget:"chat",sessions:at},e[55]=At,e[56]=Ve,e[57]=at,e[58]=Rt):Rt=e[58],lt=Rt}const it=lt;let mt;e[59]!==it?(mt=it?[it]:Y3,e[59]=it,e[60]=mt):mt=e[60];const St=mt;let ht;e[61]!==He||e[62]!==Oe||e[63]!==ge||e[64]!==h||e[65]!==st||e[66]!==Fe||e[67]!==St||e[68]!==n.availableWorktreesByProject||e[69]!==n.gitBranches||e[70]!==n.lastRepoStatus||e[71]!==n.projectRepoStatus||e[72]!==n.projectRootBranches||e[73]!==n.projects||e[74]!==r.hasSessionSearchQuery||e[75]!==r.normalizedSessionSearchQuery?(ht={normalizedProjects:n.projects,getSessionsForProject:Fe,getArchivedSessionsForProject:st,availableWorktreesByProject:n.availableWorktreesByProject,projectRepoStatus:n.projectRepoStatus,projectRootBranches:n.projectRootBranches,gitBranches:n.gitBranches,lastRepoStatus:n.lastRepoStatus,buildGroupedSessions:Oe,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,filterSessionNodesForSearch:ge,buildGroupSearchText:He,foldersMap:h,standaloneGroups:St},e[61]=He,e[62]=Oe,e[63]=ge,e[64]=h,e[65]=st,e[66]=Fe,e[67]=St,e[68]=n.availableWorktreesByProject,e[69]=n.gitBranches,e[70]=n.lastRepoStatus,e[71]=n.projectRepoStatus,e[72]=n.projectRootBranches,e[73]=n.projects,e[74]=r.hasSessionSearchQuery,e[75]=r.normalizedSessionSearchQuery,e[76]=ht):ht=e[76];const{projectSections:Xe,groupSearchDataByGroup:Ct,sectionsForRender:Mt,flatSectionsForRender:be}=qj(ht),Ue=r.onSearchMatchCountChange;let ut,G;e[77]!==Ue?(ut=()=>()=>Ue(0),G=[Ue],e[77]=Ue,e[78]=ut,e[79]=G):(ut=e[78],G=e[79]),c.useEffect(ut,G);const U=ei(),Z=`session-collection-expansion:${c.useId()}`;let ke,Te;e[80]!==U||e[81]!==Z||e[82]!==Xe||e[83]!==y.collapsedGroups||e[84]!==y.collapsedProjects||e[85]!==r.activeProjectId?(ke=()=>(U.setBootstrapDemand(Z,Lf({projectSections:Xe,activeProjectId:r.activeProjectId,collapsedProjects:y.collapsedProjects,collapsedGroups:y.collapsedGroups,currentDirectory:null,currentSessionDirectory:null})),()=>U.clearBootstrapDemand(Z)),Te=[U,Z,Xe,y.collapsedProjects,y.collapsedGroups,r.activeProjectId],e[80]=U,e[81]=Z,e[82]=Xe,e[83]=y.collapsedGroups,e[84]=y.collapsedProjects,e[85]=r.activeProjectId,e[86]=ke,e[87]=Te):(ke=e[86],Te=e[87]),c.useEffect(ke,Te);const We=r.useGroupedSections?Mt:be;let Je;e[88]!==We||e[89]!==r.showInlineArchived?(Je=r.showInlineArchived?We:We.map(p4),e[88]=We,e[89]=r.showInlineArchived,e[90]=Je):Je=e[90];const nt=Je;let rt;e[91]!==be?(rt=ot=>be.find(Q=>Q.project.id===ot)?.groups.find(g4)?.folderScopes??[],e[91]=be,e[92]=rt):rt=e[92];const Ye=rt;let Nt;e[93]!==b||e[94]!==p.hasAuthoritativeGlobalSessions||e[95]!==g||e[96]!==h||e[97]!==Ae||e[98]!==n.projects||e[99]!==r.isSessionsLoading||e[100]!==r.isWorktreeTopologyLoading||e[101]!==r.unresolvedWorktreeProjectPaths?(Nt={enabled:!0,normalizedProjects:n.projects,ownership:Ae,isSessionsLoading:r.isSessionsLoading,hasAuthoritativeGlobalSessions:p.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:r.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:r.unresolvedWorktreeProjectPaths,foldersMap:h,createFolder:g,addSessionToFolder:b},e[93]=b,e[94]=p.hasAuthoritativeGlobalSessions,e[95]=g,e[96]=h,e[97]=Ae,e[98]=n.projects,e[99]=r.isSessionsLoading,e[100]=r.isWorktreeTopologyLoading,e[101]=r.unresolvedWorktreeProjectPaths,e[102]=Nt):Nt=e[102],Oj(Nt);const{github:Ke}=Cn(),Tt=Rn(x4),Ce=Rn(b4),ft=Ys(y4),bt=Ys(w4),jt=Ys(v4);let Ge;e[103]===Symbol.for("react.memo_cache_sentinel")?(Ge=new Set,e[103]=Ge):Ge=e[103];const Le=c.useRef(Ge);let pt;e[104]!==ft||e[105]!==Ke||e[106]!==Ce||e[107]!==Tt||e[108]!==Xe||e[109]!==y.collapsedProjects||e[110]!==jt||e[111]!==bt||e[112]!==n.gitBranches?(pt=()=>{if(!Ke||!Ce||!Tt?.connected)return;const ot=new Map,At=Date.now();Xe.forEach(Q=>{y.collapsedProjects.has(Q.project.id)||Q.groups.forEach(Ve=>{if(Ve.isArchivedBucket||Ve.isMain)return;const at=gt(Ve.directory??null),Rt=Ve.branch?.trim()||n.gitBranches.get(at||"")?.trim();if(!at||!Rt)return;const Vt=Xo(at,Rt),Ut=Ys.getState().entries[Vt],Xt=Ut?.status?.pr?.state==="closed"||Ut?.status?.pr?.state==="merged",Hs=`${at}::${Rt}`,Gs=Math.max(Ut?.lastRefreshAt??0,Ut?.lastDiscoveryPollAt??0),cr=!!(Ut?.isInitialStatusResolved&&(!Ut.status?.pr||Xt)&&(!Le.current.has(Hs)||At-Gs>=q3));(!Ut||!Ut.isInitialStatusResolved||cr)&&(cr&&Le.current.add(Hs),ot.set(Vt,{directory:at,branch:Rt}))})}),ot.forEach((Q,Ve)=>{ft(Ve),bt(Ve,{...Q,remoteName:null,canShow:!0,github:Ke,githubAuthChecked:Ce,githubConnected:Tt.connected})}),ot.size&&jt([...ot.values()],{silent:!0,markInitialResolved:!0})},e[104]=ft,e[105]=Ke,e[106]=Ce,e[107]=Tt,e[108]=Xe,e[109]=y.collapsedProjects,e[110]=jt,e[111]=bt,e[112]=n.gitBranches,e[113]=pt):pt=e[113];const Be=Tt?.connected;let ze;e[114]!==ft||e[115]!==Ke||e[116]!==Ce||e[117]!==Xe||e[118]!==y.collapsedProjects||e[119]!==jt||e[120]!==bt||e[121]!==Be||e[122]!==n.gitBranches?(ze=[ft,Ke,Ce,Be,Xe,y.collapsedProjects,jt,bt,n.gitBranches],e[114]=ft,e[115]=Ke,e[116]=Ce,e[117]=Xe,e[118]=y.collapsedProjects,e[119]=jt,e[120]=bt,e[121]=Be,e[122]=n.gitBranches,e[123]=ze):ze=e[123],c.useEffect(pt,ze);let qe;e[124]!==p.orderedSessions?(qe=new Map(p.orderedSessions.map(S4)),e[124]=p.orderedSessions,e[125]=qe):qe=e[125];const tt=qe;let yt;if(e[126]!==S||e[127]!==nt){let ot;e[129]!==S?(ot=At=>{const Q=S(At.project.id,At.groups);return Q===At.groups?At:{...At,groups:Q}},e[129]=S,e[130]=ot):ot=e[130],yt=nt.map(ot),e[126]=S,e[127]=nt,e[128]=yt}else yt=e[128];const Ot=yt;let Ht;if(e[131]!==p.childrenMap||e[132]!==fe||e[133]!==n.availableWorktreesByProject||e[134]!==n.gitBranches||e[135]!==n.projects||e[136]!==r.hasSessionSearchQuery||e[137]!==r.homeDirectory||e[138]!==r.normalizedSessionSearchQuery){const ot=new Map;for(const Q of fe){const Ve=gt(Q.directory??null);if(!Ve)continue;let at=null,Rt=-1;for(const Hs of n.projects){const Gs=gt(Hs.normalizedPath);Gs&&(Ve===Gs||Ve.startsWith(`${Gs}/`))&&Gs.length>Rt&&(at=Hs,Rt=Gs.length)}if(!at)continue;const Vt=n.availableWorktreesByProject.get(at.normalizedPath)?.find(Hs=>gt(Hs.path)===Ve),Ut=_a(at.label?.trim()||Wn(at.normalizedPath,r.homeDirectory)||at.normalizedPath),Xt=Vt?.branch?.trim()||n.gitBranches.get(Ve)?.trim()||null;ot.set(Q.id,{projectId:at.id,groupDirectory:Ve,projectLabel:Ut,branchLabel:Xt&&Xt!=="HEAD"&&Xt!==Ut?Xt:null})}let At;e[140]!==p.childrenMap?(At=Q=>wl(p.childrenMap,Q),e[140]=p.childrenMap,e[141]=At):At=e[141],Ht=Fh({sessions:fe,getSessionLocation:Q=>ot.get(Q)??null,getSessionNode:At,query:r.hasSessionSearchQuery?r.normalizedSessionSearchQuery:""}),e[131]=p.childrenMap,e[132]=fe,e[133]=n.availableWorktreesByProject,e[134]=n.gitBranches,e[135]=n.projects,e[136]=r.hasSessionSearchQuery,e[137]=r.homeDirectory,e[138]=r.normalizedSessionSearchQuery,e[139]=Ht}else Ht=e[139];const _t=Ht;let zt;e[142]===Symbol.for("react.memo_cache_sentinel")?(zt=zd(),e[142]=zt):zt=e[142];let Wt;e[143]!==it||e[144]!==U||e[145]!==Ot?(Wt={childStores:U,sections:Ot,chatGroup:it,canGrantAccess:zt},e[143]=it,e[144]=U,e[145]=Ot,e[146]=Wt):Wt=e[146];const{groupStatusByKey:Jt,bootstrapSnapshot:es}=$3(Wt);let Qt;e[147]!==Xe||e[148]!==K||e[149]!==ue||e[150]!==r.activeProjectId?(Qt=null,ue&&(Xe.some(ot=>ot.project.id===K)?Qt=K:Xe.some(ot=>ot.project.id===r.activeProjectId)?Qt=r.activeProjectId:Qt=Xe[0]?.project.id??null),e[147]=Xe,e[148]=K,e[149]=ue,e[150]=r.activeProjectId,e[151]=Qt):Qt=e[151];const qt=ue&&!r.useGroupedSections?20:void 0;let Et;e[152]!==i.startSessionWorktreeMenuLoad||e[153]!==o||e[154]!==p.pinnedSessionIds||e[155]!==pe||e[156]!==H||e[157]!==xe||e[158]!==je||e[159]!==ye||e[160]!==q||e[161]!==de||e[162]!==Ct||e[163]!==l||e[164]!==y.collapsedGroups||e[165]!==u.allowReselect||e[166]!==u.onSessionSelected||e[167]!==u.resetSessionSearch||e[168]!==tt||e[169]!==qt||e[170]!==z||e[171]!==r.activeProjectId||e[172]!==r.hasSessionSearchQuery||e[173]!==r.hideDirectoryControls||e[174]!==r.mobileVariant||e[175]!==r.normalizedSessionSearchQuery?(Et={hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,groupSearchDataByGroup:Ct,collapsedGroups:y.collapsedGroups,hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:o,activeProjectId:r.activeProjectId,notifyOnSubtasks:l,pinnedSessionIds:p.pinnedSessionIds,sessionOrderIndex:tt,expandedParents:q,editingId:je,editingRowKey:ye,editTitle:xe,copiedSessionId:pe,sessionBatchSize:qt,setEditingId:ve,setEditingRowKey:Pe,setEditTitle:R,toggleParent:z,allowReselect:u.allowReselect,onSessionSelected:u.onSessionSelected,resetSessionSearch:u.resetSessionSearch,deleteSessionConfirm:H,setDeleteSessionConfirm:me,startFolderRename:he,setCopiedSessionId:re,startSessionWorktreeMenuLoad:i.startSessionWorktreeMenuLoad,folderRename:de,setFolderRenameDraft:Re,clearFolderRename:se},e[152]=i.startSessionWorktreeMenuLoad,e[153]=o,e[154]=p.pinnedSessionIds,e[155]=pe,e[156]=H,e[157]=xe,e[158]=je,e[159]=ye,e[160]=q,e[161]=de,e[162]=Ct,e[163]=l,e[164]=y.collapsedGroups,e[165]=u.allowReselect,e[166]=u.onSessionSelected,e[167]=u.resetSessionSearch,e[168]=tt,e[169]=qt,e[170]=z,e[171]=r.activeProjectId,e[172]=r.hasSessionSearchQuery,e[173]=r.hideDirectoryControls,e[174]=r.mobileVariant,e[175]=r.normalizedSessionSearchQuery,e[176]=Et):Et=e[176];const wt=Et;let cs;e[177]!==d.openNewSessionDraft||e[178]!==d.setActiveProjectIdOnly||e[179]!==d.setSessionSwitcherOpen||e[180]!==f?(cs={showMoreGroupSessions:W,resetGroupSessionLimit:$,setActiveProjectIdOnly:d.setActiveProjectIdOnly,setSessionSwitcherOpen:d.setSessionSwitcherOpen,openNewSessionDraft:d.openNewSessionDraft,onToggleCollapsedGroup:f},e[177]=d.openNewSessionDraft,e[178]=d.setActiveProjectIdOnly,e[179]=d.setSessionSwitcherOpen,e[180]=f,e[181]=cs):cs=e[181];const xs=cs;let ds;if(e[182]!==it||e[183]!==U||e[184]!==p.hasAuthoritativeGlobalSessions||e[185]!==Ot){ds=new Map;for(const ot of Ot)for(const At of ot.groups){const Q=kr(ot.project.id,At.directory);if(!Q)continue;const Ve=Zr(At),at=ds.get(Q),Rt=[...new Set([...at?.scopeKeys??[],...Ve.map(j4)])],Vt=p.hasAuthoritativeGlobalSessions&&Ve.every(Ut=>{const Xt=gt(Ut.directory);return!Xt||U.getBootstrapState(Xt)==="complete"});ds.set(Q,{scopeKeys:Rt,complete:(at?.complete??!0)&&Vt})}if(it){let ot;e[187]!==it.directory?(ot=kr(null,it.directory),e[187]=it.directory,e[188]=ot):ot=e[188];const At=ot;if(At){let Q;e[189]!==it?(Q=Zr(it).map(k4),e[189]=it,e[190]=Q):Q=e[190];let Ve;e[191]!==p.hasAuthoritativeGlobalSessions||e[192]!==Q?(Ve={scopeKeys:Q,complete:p.hasAuthoritativeGlobalSessions},e[191]=p.hasAuthoritativeGlobalSessions,e[192]=Q,e[193]=Ve):Ve=e[193],ds.set(At,Ve)}}e[182]=it,e[183]=U,e[184]=p.hasAuthoritativeGlobalSessions,e[185]=Ot,e[186]=ds}else ds=e[186];const us=ds;let ln;e[194]!==T||e[195]!==C?(ln=new Map([...C,...T]),e[194]=T,e[195]=C,e[196]=ln):ln=e[196];const js=ln,pn=r.hasSessionSearchQuery?"search":"normal",gn=j&&!ue,Js=ue&&!r.useGroupedSections?20:void 0;let cn;e[197]!==it||e[198]!==I||e[199]!==m||e[200]!==p.pinnedSessionIds||e[201]!==q||e[202]!==us||e[203]!==h||e[204]!==Ct||e[205]!==Jt||e[206]!==Ot||e[207]!==Xe||e[208]!==y.collapsedGroups||e[209]!==y.collapsedProjects||e[210]!==_t||e[211]!==Qt||e[212]!==tt||e[213]!==ue||e[214]!==pn||e[215]!==gn||e[216]!==Js||e[217]!==r.activeProjectId||e[218]!==r.hideDirectoryControls||e[219]!==r.normalizedSessionSearchQuery||e[220]!==r.showOnlyMainWorkspace||e[221]!==js?(cn=Fk({mode:pn,sections:Ot,authoritativeSections:Xe,chatGroup:it,recentSections:_t,showRecentSection:gn,foldersMap:h,groupSearchDataByGroup:Ct,normalizedQuery:r.normalizedSessionSearchQuery,collapsedProjects:y.collapsedProjects,collapsedGroups:y.collapsedGroups,collapsedFolders:m,collapsedActivities:I,expandedParents:q,visibleCountByContainer:js,pinnedSessionIds:p.pinnedSessionIds,sessionOrderIndex:tt,groupStatusByKey:Jt,folderAuthorityByOwner:us,activeProjectId:r.activeProjectId,singleProjectMode:ue,singleProjectId:Qt,showOnlyMainWorkspace:r.showOnlyMainWorkspace,hideDirectoryControls:r.hideDirectoryControls,sessionBatchSize:Js}),e[197]=it,e[198]=I,e[199]=m,e[200]=p.pinnedSessionIds,e[201]=q,e[202]=us,e[203]=h,e[204]=Ct,e[205]=Jt,e[206]=Ot,e[207]=Xe,e[208]=y.collapsedGroups,e[209]=y.collapsedProjects,e[210]=_t,e[211]=Qt,e[212]=tt,e[213]=ue,e[214]=pn,e[215]=gn,e[216]=Js,e[217]=r.activeProjectId,e[218]=r.hideDirectoryControls,e[219]=r.normalizedSessionSearchQuery,e[220]=r.showOnlyMainWorkspace,e[221]=js,e[222]=cn):cn=e[222];const ns=cn;let ks,Ks;e[223]!==Ue||e[224]!==ns.searchMatchCount?(ks=()=>{Ue(ns.searchMatchCount)},Ks=[Ue,ns.searchMatchCount],e[223]=Ue,e[224]=ns.searchMatchCount,e[225]=ks,e[226]=Ks):(ks=e[225],Ks=e[226]),c.useEffect(ks,Ks);let Vs;e[227]!==I||e[228]!==je||e[229]!==Y||e[230]!==T||e[231]!==C?(Vs={editingId:je,openSidebarMenuKey:Y,setOpenSidebarMenuKey:ie,visibleSessionCountByGroup:C,collapsedActivityKeys:I,setCollapsedActivityKeys:A,visibleActivityCountByKey:T,setVisibleActivityCountByKey:_},e[227]=I,e[228]=je,e[229]=Y,e[230]=T,e[231]=C,e[232]=Vs):Vs=e[232];let As;e[233]!==wt||e[234]!==Ot||e[235]!==Xe||e[236]!==ns||e[237]!==ue||e[238]!==Vs||e[239]!==n.projectRepoStatus||e[240]!==r.emptyState||e[241]!==r.searchEmptyState?(As={rowModel:ns,sectionsForRender:Ot,projectSections:Xe,singleProjectMode:ue,emptyState:r.emptyState,searchEmptyState:r.searchEmptyState,projectRepoStatus:n.projectRepoStatus,state:Vs,groupProps:wt},e[233]=wt,e[234]=Ot,e[235]=Xe,e[236]=ns,e[237]=ue,e[238]=Vs,e[239]=n.projectRepoStatus,e[240]=r.emptyState,e[241]=r.searchEmptyState,e[242]=As):As=e[242];const Zs=As;let gs;e[243]!==o||e[244]!==r.hasSessionSearchQuery||e[245]!==r.hideDirectoryControls||e[246]!==r.homeDirectory||e[247]!==r.mobileVariant||e[248]!==r.projectSortOrder||e[249]!==r.stickyZoneHeaders?(gs={homeDirectory:r.homeDirectory,hasSessionSearchQuery:r.hasSessionSearchQuery,hideDirectoryControls:r.hideDirectoryControls,stickyZoneHeaders:r.stickyZoneHeaders,mobileVariant:r.mobileVariant,alwaysShowActions:o,projectSortOrder:r.projectSortOrder},e[243]=o,e[244]=r.hasSessionSearchQuery,e[245]=r.hideDirectoryControls,e[246]=r.homeDirectory,e[247]=r.mobileVariant,e[248]=r.projectSortOrder,e[249]=r.stickyZoneHeaders,e[250]=gs):gs=e[250];const dn=gs;let xn;e[251]!==xs||e[252]!==d.openNewSessionDraft||e[253]!==d.openNewWorktreeDialog||e[254]!==d.openProjectEditDialog||e[255]!==d.openWorktreesPage||e[256]!==d.removeProject||e[257]!==d.renderProjectStatusIndicator||e[258]!==d.reorderProjects||e[259]!==d.setActiveProjectIdOnly||e[260]!==d.setSessionSwitcherOpen||e[261]!==w||e[262]!==ee||e[263]!==x?(xn={group:xs,toggleProject:x,setActiveProjectIdOnly:d.setActiveProjectIdOnly,setSessionSwitcherOpen:d.setSessionSwitcherOpen,openNewSessionDraft:d.openNewSessionDraft,openNewWorktreeDialog:d.openNewWorktreeDialog,openWorktreesPage:d.openWorktreesPage,openProjectEditDialog:d.openProjectEditDialog,removeProject:d.removeProject,reorderProjects:d.reorderProjects,setGroupOrderByProject:w,renderProjectStatusIndicator:d.renderProjectStatusIndicator,setSingleProjectId:ee},e[251]=xs,e[252]=d.openNewSessionDraft,e[253]=d.openNewWorktreeDialog,e[254]=d.openProjectEditDialog,e[255]=d.openWorktreesPage,e[256]=d.removeProject,e[257]=d.renderProjectStatusIndicator,e[258]=d.reorderProjects,e[259]=d.setActiveProjectIdOnly,e[260]=d.setSessionSwitcherOpen,e[261]=w,e[262]=ee,e[263]=x,e[264]=xn):xn=e[264];const Nn=xn;let en;e[265]===Symbol.for("react.memo_cache_sentinel")?(en=s.jsx(Tj,{}),e[265]=en):en=e[265];let Us;e[266]!==i.initialActiveSessionByProject||e[267]!==i.openNewSessionDraft||e[268]!==i.persistActiveSessionByProject||e[269]!==i.setSessionSwitcherOpen||e[270]!==Ae.bySessionId||e[271]!==Xe||e[272]!==Ne||e[273]!==r.activeProjectId||e[274]!==r.mobileVariant?(Us=s.jsx(Lj,{projectSections:Xe,activeProjectId:r.activeProjectId,initialActiveSessionByProject:i.initialActiveSessionByProject,persistActiveSessionByProject:i.persistActiveSessionByProject,mobileVariant:r.mobileVariant,openNewSessionDraft:i.openNewSessionDraft,setSessionSwitcherOpen:i.setSessionSwitcherOpen,sessionOwnerBySessionId:Ae.bySessionId,handleSessionSelect:Ne}),e[266]=i.initialActiveSessionByProject,e[267]=i.openNewSessionDraft,e[268]=i.persistActiveSessionByProject,e[269]=i.setSessionSwitcherOpen,e[270]=Ae.bySessionId,e[271]=Xe,e[272]=Ne,e[273]=r.activeProjectId,e[274]=r.mobileVariant,e[275]=Us):Us=e[275];let oe;e[276]!==p.orderedSessions||e[277]!==we||e[278]!==fe?(oe=s.jsx(e2,{sortedSessions:p.orderedSessions,recentSessions:fe,prefetchSession:we}),e[276]=p.orderedSessions,e[277]=we,e[278]=fe,e[279]=oe):oe=e[279];let Qe;e[280]!==Nn||e[281]!==Zs||e[282]!==dn?(Qe=s.jsx(p3,{model:Zs,view:dn,actions:Nn}),e[280]=Nn,e[281]=Zs,e[282]=dn,e[283]=Qe):Qe=e[283];const ct=je!==null;let kt;e[284]!==Ye||e[285]!==ct?(kt=s.jsx(A3,{getFolderScopesForProject:Ye,isInlineEditing:ct,startFolderRename:he}),e[284]=Ye,e[285]=ct,e[286]=kt):kt=e[286];let $t;e[287]!==ns.selectionDescendantIds||e[288]!==ns.selectionEntries||e[289]!==ns.sessionById||e[290]!==Qe||e[291]!==kt?($t=s.jsxs(b2,{entries:ns.selectionEntries,descendantIds:ns.selectionDescendantIds,sessionsById:ns.sessionById,children:[Qe,kt]}),e[287]=ns.selectionDescendantIds,e[288]=ns.selectionEntries,e[289]=ns.sessionById,e[290]=Qe,e[291]=kt,e[292]=$t):$t=e[292];let Ft;return e[293]!==Us||e[294]!==oe||e[295]!==$t?(Ft=s.jsxs(s.Fragment,{children:[en,Us,oe,$t]}),e[293]=Us,e[294]=oe,e[295]=$t,e[296]=Ft):Ft=e[296],Ft},J3=t=>{const e=et.c(2);let n;return e[0]!==t?(n=t.view.isVisible?s.jsx(X3,{...t}):null,e[0]=t,e[1]=n):n=e[1],n};function Z3(t){return t.foldersMap}function e4(t){return t.collapsedFolderIds}function t4(t){return t.createFolder}function s4(t){return t.addSessionToFolder}function n4(t){return t.showRecentSection}function r4(t){return t.projectDisplayMode}function o4(t){return t.singleProjectId}function i4(t){return t.setSingleProjectId}function a4(t){return t.setCurrentSession}function l4(t){return Oa(t.directory)}function c4(t){return gt(t.directory??null)}function d4(t){return!!t}function u4(t){return{scopeKey:t,directory:t}}function f4(t){return!t.time?.archived&&Q3(t)}function m4(t){return t.isArchivedBucket}function h4(t){return!t.isArchivedBucket}function p4(t){return t.groups.some(m4)?{...t,groups:t.groups.filter(h4)}:t}function g4(t){return!t.isArchivedBucket}function x4(t){return t.status}function b4(t){return t.hasChecked}function y4(t){return t.ensureEntry}function w4(t){return t.setParams}function v4(t){return t.refreshTargets}function S4(t,e){return[t.id,e]}function j4(t){return t.scopeKey}function k4(t){return t.scopeKey}const rm=(t,e,n)=>{const r=new Set;for(const i of t){const o=gt(i.path);o&&r.add(o)}if(n?.includeWorktrees===!1)return r;for(const i of e.values())for(const o of i){const l=gt(o.path);l&&r.add(l)}return r},id="oc.sessions.activeSessionByProject",C4=[],N4=Zu(Nr(),Nr().min(1).catch("")),A4=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{Ri("react.session_sidebar_render"),Qs("ui.session_sidebar.render"),Qs(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),Qs(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=vt(),[a,u]=c.useState(!1),[d,h]=c.useState(""),m=c.useCallback(()=>{h(""),u(!1)},[]),[g,b]=c.useState(0),y=c.useRef(null),S=c.useRef(null),[w,f]=c.useState(null),x=c.useMemo(()=>Eo(),[]),[v,p]=c.useState(new Map),N=De(Ce=>Ce.isNewWorktreeDialogOpen),C=De(Ce=>Ce.setNewWorktreeDialogOpen),[k,D]=c.useState(!1),I=c.useMemo(()=>{try{const Ce=x.getItem(id);if(!Ce)return new Map;const ft=N4.safeParse(JSON.parse(Ce));if(!ft.success)return new Map;const bt=new Map;return Object.entries(ft.data).forEach(([jt,Ge])=>{Ge&&bt.set(jt,Ge)}),bt}catch{return new Map}},[x]),A=c.useCallback(Ce=>{try{x.setItem(id,JSON.stringify(Object.fromEntries(Ce.entries())))}catch{}},[x]),[P,T]=c.useState(new Map),_=os(Ce=>Ce.homeDirectory),L=Gt(Ce=>Ce.projects),W=Gt(Ce=>Ce.activeProjectId),O=Gt(Ce=>Ce.removeProject),$=Gt(Ce=>Ce.setActiveProjectIdOnly),j=Gt(Ce=>Ce.updateProjectMeta),E=Gt(Ce=>Ce.reorderProjects),K=De(Ce=>Ce.setSettingsDialogOpen),ee=De(Ce=>Ce.toggleHelpDialog),J=De(Ce=>Ce.setAboutDialogOpen),ne=De(Ce=>Ce.setSessionSwitcherOpen),ue=De(Ce=>Ce.setScheduledTasksDialogOpen),X=De(Ce=>Ce.setArchivePageOpen),te=De(Ce=>Ce.setWorktreesPageProjectId),fe=De(Ce=>Ce.openMultiRunLauncher),je=De(Ce=>Ce.notifyOnSubtasks),ve=c.useMemo(()=>d.trim().toLowerCase(),[d]),ye=ve.length>0;Z0({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:u,sessionSearchInputRef:S,sessionSearchContainerRef:y});const Pe=Nu(t),xe=c.useMemo(()=>Kn(),[]),R=Ze(Ce=>Ce.setCurrentSession),Y=Ze(Ce=>Ce.worktreeMetadata),ie=Ze(Ce=>Ce.availableWorktreesByProject),H=Ze(Ce=>Ce.openNewSessionDraft),me=c.useMemo(()=>rm(L,ie,{includeWorktrees:!xe}),[ie,xe,L]),pe=c.useCallback(Ce=>{De.getState().closeMainSurfaces(),H(Ce),xe&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[xe,H]),re=Ur(ir(Ce=>({checkForUpdates:Ce.checkForUpdates,available:Ce.available,runtimeType:Ce.runtimeType,info:Ce.info,downloading:Ce.downloading,downloaded:Ce.downloaded,progress:Ce.progress,error:Ce.error,downloadUpdate:Ce.downloadUpdate,restartToUpdate:Ce.restartToUpdate}))),de=as(),B=c.useMemo(()=>`${de}|${L.map(Ce=>`${Ce.id}:${gt(Ce.path)??""}`).join("|")}`,[L,de]),[F,he]=c.useState(xe?B:null),[Se,Re]=c.useReducer(Ce=>Ce+1,0),le=!xe&&F!==B,[se,q]=c.useState(new Set),z=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let Ce=!1;return(async()=>{const bt=de,jt=Gt.getState().projects;if(Ze.setState({worktreeDiscoveryByProject:new Map(jt.map(_t=>[gt(_t.path)??_t.path,"loading"]))}),jt.length===0||xe){Ce||(z.current={runtimeKey:null,revision:0,worktreesByProject:new Map},q(new Set),he(B));return}const Ge=Ze.getState().availableWorktreesByProject,Le=nl({rawWorktreesByProjectRef:z,publishedWorktreesByProject:Ge,runtimeKey:bt}),pt=Le.revision,Be=new Map(Le.worktreesByProject),ze=new Set,qe=3;let tt=0;const yt=Array.from({length:qe},async()=>{for(;;){const _t=tt;if(tt+=1,_t>=jt.length)return;const zt=jt[_t],Wt=gt(zt.path);if(Wt)try{const Jt=await Vi(async()=>Mn.getState().directories.get(Wt)?.isGitRepo??await Qo(Wt)?Fl({id:zt.id,path:Wt}):null);if(Jt===null){Be.delete(Wt);continue}if(Ce)return;Jt.length===0?Be.delete(Wt):Be.set(Wt,Jt)}catch{ze.add(Wt)}}});if(await Promise.all(yt),Ce||as()!==bt)return;const Ot=new Set(jt.map(_t=>gt(_t.path)).filter(Boolean));for(const _t of Be.keys())Ot.has(_t)||Be.delete(_t);rk({rawWorktreesByProjectRef:z,runtimeKey:bt,capturedRevision:pt,nextRawWorktreesByProject:Be,publishedWorktreesByProject:Ge,partitionWorktreesByRegisteredProject:Bl,projects:jt,worktreeMapsEqual:Ol,recordWorktreesSeen:nd,publishTopology:_t=>{Ze.setState(_t)},requestRediscovery:()=>{Re()},now:()=>Date.now()})&&(q(ze),Ze.setState({worktreeDiscoveryByProject:new Map(jt.map(_t=>{const zt=gt(_t.path)??_t.path;return[zt,ze.has(zt)?"error":"ready"]}))}),he(B))})(),()=>{Ce=!0}},[xe,B,de,Se]);const ae=c.useMemo(()=>vn(),[]),{isTablet:ce}=Vn(),Ne=e||ce,we=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noSessions.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noSessions.description")})]}),[l]),$e=c.useMemo(()=>L.find(Ce=>Ce.id===w)??null,[L,w]),Oe=c.useCallback(Ce=>{w&&j(w,{label:Ce.label,icon:Ce.icon,color:Ce.color,iconBackground:Ce.iconBackground,defaultAgent:Ce.defaultAgent??null,defaultModel:Ce.defaultModel??null,defaultVariant:Ce.defaultVariant??null})},[w,j]),ge=c.useCallback(()=>{C(!0)},[C]),He=c.useCallback(()=>{const Ce=Ur.getState();if(Ce.available&&Ce.info){D(!0);return}re.checkForUpdates().then(()=>{const{available:ft,error:bt}=Ur.getState();if(bt){_e.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:bt});return}if(!ft){_e.success(l("sessions.sidebar.updateCheck.latestVersion"));return}D(!0)})},[l,re]),V=c.useCallback(()=>{e&&ne(!1),K(!0)},[e,ne,K]),Ae=re.available&&(re.runtimeType==="desktop"||re.runtimeType==="web"),Ie=c.useCallback(()=>{hn.requestDirectoryDialog()},[]),Fe=c.useMemo(()=>L.flatMap(Ce=>{const ft=gt(Ce.path);return ft?[{id:Ce.id,path:Ce.path,label:Ce.label,normalizedPath:ft,icon:Ce.icon??void 0,color:Ce.color??void 0,iconImage:Ce.iconImage??void 0,iconBackground:Ce.iconBackground??void 0,addedAt:Ce.addedAt,lastOpenedAt:Ce.lastOpenedAt,sidebarCollapsed:Ce.sidebarCollapsed}]:[]}),[L]),st=c.useMemo(()=>Fe.map(Ce=>Ce.normalizedPath),[Fe]),lt=Rg(t?st:C4);aj({enabled:t,normalizedProjects:Fe,gitRepoStatus:lt,setProjectRepoStatus:p,setProjectRootBranches:T});const it=Ze(Ce=>Ce.isLoading),mt=c.useRef(!1);W&&v.has(W)&&(mt.current=!!v.get(W));const St=hs(Ce=>Ce.showArchivedSessions),ht=hs(Ce=>Ce.projectSortOrder),Xe=hs(Ce=>Ce.stickyZoneHeaders),Ct=Gt(Ce=>Ce.manualProjectOrder),Mt={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:l,isTablet:ce,projects:L,activeProjectId:W,manualProjectOrder:Ct,worktreeMetadata:Y,availableWorktreesByProject:ie,gitBranches:Pe,gitRepoStatus:lt,updateStore:re,showArchivedSessions:St,projectSortOrder:ht,projectRepoStatus:v,projectRootBranches:P,resolvedWorktreeTopologyKey:F,unresolvedWorktreeProjectPaths:se,isSessionSearchOpen:a,sessionSearchQuery:d,editingProjectDialogId:w,updateDialogOpen:k},be=c.useRef(null),Ue=be.current;if(Ue){let Ce=!1;for(const ft of Object.keys(Mt))Object.is(Ue[ft],Mt[ft])||(Qs(`ui.session_sidebar.source.${ft}`),Ce=!0);Ce||Qs("ui.session_sidebar.source.parent_or_context")}be.current=Mt;const ut=c.useMemo(()=>_h(Fe,ht,Ct),[Fe,ht,Ct]),G=nj({isVSCode:xe,projects:ut}),U=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noMatches.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noMatches.description")})]}),[l]),Z=xe&&St,Te=hs(Ce=>Ce.sessionGroupingMode)==="by-worktree"&&!xe,nt=e?"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed":"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed",rt="h-4.5 w-4.5",Ye=c.useCallback(()=>{e&&ne(!1),fe()},[e,fe,ne]),Nt=c.useMemo(()=>({projects:L,getCurrentProjects:()=>Gt.getState().projects,rawWorktreesByProjectRef:z,getPublishedWorktreesByProject:()=>Ze.getState().availableWorktreesByProject,resolveProject:Ce=>_i(Ce),listProjectWorktrees:Fl,partitionWorktreesByRegisteredProject:Bl,worktreeMapsEqual:Ol,recordWorktreesSeen:nd,publishTopology:Ce=>{Ze.setState(Ce)},getRuntimeKey:as,now:()=>Date.now()}),[L]),Ke=c.useCallback(Ce=>{const ft=Ce.projectId?L.find(bt=>bt.id===Ce.projectId)??null:Ce.sourceDirectory?_i(Ce.sourceDirectory):null;return nk(Ce,{...Nt,projectRootBranch:ft?P.get(ft.id)??null:null})},[P,L,Nt]);c.useEffect(()=>{if(!xe)return ro(Ce=>{if(Ce.type==="session-created"){Re();return}if(Ce.type==="worktree-changed")for(const ft of Mg(Ce.directories)){const bt=gt(ft.path),jt=as(),Ge=Le=>{!bt||as()!==jt||Ze.setState(pt=>({worktreeDiscoveryByProject:new Map(pt.worktreeDiscoveryByProject).set(bt,Le)}))};Ge("loading"),Jf(ft,null,Nt).then(()=>{!bt||as()!==jt||(Ge("ready"),q(Le=>{if(!Le.has(bt))return Le;const pt=new Set(Le);return pt.delete(bt),pt}))}).catch(()=>{!bt||as()!==jt||(Ge("error"),q(Le=>new Set(Le).add(bt)))})}})},[xe,Nt]);const Tt=c.useCallback(()=>{De.getState().closeMainSurfaces(),e&&ne(!1),H()},[e,H,ne]);return s.jsx(qi,{delay:400,closeDelay:0,timeout:300,children:s.jsxs("div",{ref:y,className:Me("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[!i&&!xe?s.jsx(Dj,{onNewSession:Tt}):null,s.jsx(mj,{hideDirectoryControls:i,showProjectDisplayControls:!xe,showRecentControls:!xe,handleOpenDirectoryDialog:Ie,onOpenScheduled:()=>{e&&ne(!1),ue(!0)},onOpenMultiRun:Ye,canOpenMultiRun:L.length>0,onOpenArchive:()=>{e&&ne(!1),X(!0)},headerActionIconClass:rt,headerActionButtonClass:nt,isSessionSearchOpen:a,setIsSessionSearchOpen:u,sessionSearchInputRef:S,sessionSearchQuery:d,setSessionSearchQuery:h,hasSessionSearchQuery:ye,searchMatchCount:g,collapseAllProjects:G.actions.collapseAllProjects,expandAllProjects:G.actions.expandAllProjects}),s.jsx(J3,{topology:{projects:ut,availableWorktreesByProject:ie,knownDirectories:me,isVSCode:xe,worktreeMetadata:Y,gitBranches:Pe,projectRepoStatus:v,projectRootBranches:P,lastRepoStatus:mt.current},view:{isVisible:t,hasSessionSearchQuery:ye,normalizedSessionSearchQuery:ve,activeProjectId:W,showInlineArchived:Z,useGroupedSections:Te,homeDirectory:_,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:ae,stickyZoneHeaders:Xe,projectSortOrder:ht,emptyState:we,searchEmptyState:U,isSessionsLoading:it,isWorktreeTopologyLoading:le,unresolvedWorktreeProjectPaths:se,projectView:G.state,onSearchMatchCountChange:b},actions:{rowActions:{allowReselect:r,onSessionSelected:n,resetSessionSearch:m},alwaysShowActions:Ne,notifyOnSubtasks:je,setActiveProjectIdOnly:$,setSessionSwitcherOpen:ne,openNewSessionDraft:pe,openNewWorktreeDialog:ge,openWorktreesPage:Ce=>{e&&ne(!1),te(Ce)},openProjectEditDialog:f,removeProject:O,reorderProjects:E,startSessionWorktreeMenuLoad:Ke,initialActiveSessionByProject:I,persistActiveSessionByProject:A,projectViewActions:G.actions}}),s.jsx(Pj,{onOpenSettings:V,onOpenShortcuts:ee,onOpenAbout:()=>J(!0),onOpenUpdate:He,showRuntimeButtons:!xe,showUpdateButton:Ae}),s.jsx(Vd,{open:k,onOpenChange:D,info:re.info,downloading:re.downloading,downloaded:re.downloaded,progress:re.progress,error:re.error,onDownload:re.downloadUpdate,onRestart:re.restartToUpdate,runtimeType:re.runtimeType}),s.jsx(fj,{open:!!$e,onOpenChange:Ce=>{Ce||f(null)},project:$e,onSave:Oe}),s.jsx(Lh,{open:N,onOpenChange:C,onWorktreeCreated:(Ce,ft)=>{if(De.getState().closeMainSurfaces(),e&&ne(!1),ft?.sessionId){R(ft.sessionId,Ce);return}H({directoryOverride:Ce,preserveDirectoryOverride:!0})}})]})})},D4=c.memo(A4),Dn=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,fn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},P4=()=>{const{t}=vt(),[e,n]=c.useState(!1),[r,i]=c.useState(!1),[o,l]=c.useState(null),[a,u]=c.useState([]),[d,h]=c.useState(!1),[m,g]=c.useState(!1),[b,y]=c.useState(!1),[S,w]=c.useState(!1),[f,x]=c.useState(new Set),v=Ze(F=>F.getWorktreeMetadata),p=Ze(F=>F.newSessionDraft),N=Ze(F=>F.setNewSessionDraftTarget),C=Ze(F=>F.setDraftBootstrapPendingDirectory),k=Og,D=Ze(F=>F.deleteSessions),I=Ze(F=>F.archiveSessions),A=De(F=>F.showDeletionDialog),P=De(F=>F.setShowDeletionDialog),T=os(F=>F.currentDirectory),_=os(F=>F.homeDirectory),L=os(F=>F.isHomeReady),W=Gt(F=>F.projects),O=Gt(F=>F.activeProjectId),{isMobile:$,isTablet:j,hasTouchInput:E}=Vn(),K=$||j||E,ee=c.useMemo(()=>{const he=(O?W.find(Se=>Se.id===O)??null:null)?.path??T;return fn(he)},[O,T,W]),J=c.useCallback(F=>{const Se=fn(F.projectDirectory)||ee;return{id:(W.find(le=>fn(le.path)===Se)??null)?.id??`path:${Se}`,path:Se}},[ee,W]),ne=S&&f.size>0,ue=c.useMemo(()=>{const F=o?.worktree;return F&&typeof F.branch=="string"&&F.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:he})=>typeof he.branch=="string"&&he.branch.trim().length>0)},[o?.worktree,a]),X=o?.mode==="worktree",te=X,fe=b||!X||!ue,je=b||!X;c.useEffect(()=>{r||!L||W.length>0||(i(!0),n(!0))},[r,L,W.length]);const ve=c.useCallback(F=>{l({sessions:F.sessions,dateLabel:F.dateLabel,mode:F.mode??"session",worktree:F.worktree??null})},[]),ye=c.useCallback(()=>{l(null),u([]),h(!1),g(!1),y(!1),w(!1),x(new Set)},[]),Pe=c.useCallback(async F=>{if(F.sessions.length===0)return;if(F.sessions.length===1){const le=F.sessions[0];await k(le.id)?_e.success(t("sessions.sidebar.session.delete.success")):_e.error(t("sessions.sidebar.session.delete.error"));return}const he=F.sessions.map(le=>le.id),{deletedIds:Se,failedIds:Re}=await D(he);if(Se.length>0){const le=Re.length>0?Re.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Re.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Re.length}):F.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:F.dateLabel}):void 0;_e.success(Se.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Se.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Se.length}),{description:Dn(le)})}Re.length>0&&_e.error(Re.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Re.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Re.length}),{description:Dn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[k,D,t]);c.useEffect(()=>hn.onDeleteRequest(F=>{if(!A&&(F.mode??"session")==="session"){Pe(F);return}ve(F)}),[ve,A,Pe]),c.useEffect(()=>hn.onDirectoryRequest(()=>{n(!0)}),[]),c.useEffect(()=>{if(!o){u([]),h(!1),g(!1),w(!1),x(new Set);return}const F=o.sessions.map(Re=>{const le=v(Re.id);return le?{session:Re,metadata:le}:null}).filter(Re=>!!Re);u(F),h(!1),w(!1),x(new Set);const he=new Map;if(o.worktree?.path&&he.set(fn(o.worktree.path),o.worktree),F.forEach(({metadata:Re})=>{Re.path&&he.set(fn(Re.path),Re)}),he.size===0){w(!0);return}let Se=!1;return(async()=>{const Re=new Map,le=new Set;await Promise.all(Array.from(he.entries()).map(async([se,q])=>{try{const z=await Bg(q.path);Re.set(se,z),z?.isDirty&&le.add(se)}catch{q.status&&(Re.set(se,q.status),q.status.isDirty&&le.add(se))}})).catch(se=>{console.warn("Failed to inspect worktree status before deletion:",se)}),!Se&&(x(le),w(!0),l(se=>{if(!se?.worktree?.path)return se;const q=fn(se.worktree.path),z=Re.get(q);if(!z)return se;const ae=se.worktree.status;return ae?.isDirty===z.isDirty&&ae?.ahead===z.ahead&&ae?.behind===z.behind&&ae?.upstream===z.upstream?se:{...se,worktree:{...se.worktree,status:z}}}),u(se=>se.map(q=>{const z=fn(q.metadata.path),ae=Re.get(z);return ae?{session:q.session,metadata:{...q.metadata,status:ae}}:q})))})(),()=>{Se=!0}},[o,v]),c.useEffect(()=>{ue||h(!1)},[ue]);const xe=c.useCallback(async(F,he,Se)=>{const Re=d&&ue,le=J(F),se=fn(F.path),q=fn(le.path);try{await ru(le,F,{deleteRemoteBranch:Re,deleteLocalBranch:he});const z=fn(p?.directoryOverride);return p?.open&&se&&z===se&&q&&(C(null),N({projectId:le.id,directoryOverride:q},{force:!0})),fn(T)===se&&q&&os.getState().setDirectory(q,{showOverlay:!1}),!0}catch(z){return _e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:mi(F)}),{id:Se,description:Dn(z instanceof Error?z.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[ue,T,d,J,p?.directoryOverride,p?.open,C,N,t]),R=c.useCallback((F,he,Se)=>{const Re=d&&ue,le=_e.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:mi(F)}));(async()=>{try{if(he.length>0){const{failedIds:z}=await I(he);if(z.length>0){_e.error(z.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:z.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:z.length}),{id:le,description:Dn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))});return}}if(!await xe(F,Se,le))return;const q=t(Re?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");_e.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:mi(F)}),{id:le,description:Dn(q)})}catch(se){_e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:le,description:Dn(se instanceof Error?se.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}})()},[I,ue,d,xe,t]),Y=c.useCallback(async()=>{if(o){y(!0);try{const F=te,he=F&&d,Se=F&&m;if(X&&o.worktree){R(o.worktree,o.sessions.map(Re=>Re.id),Se),ye();return}if(o.sessions.length===1){const Re=o.sessions[0];if(!await k(Re.id)){_e.error(t("sessions.sidebar.session.delete.error")),y(!1);return}const se=!X&&F?t(he?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;_e.success(t("sessions.sidebar.session.delete.success"),{description:Dn(se),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const Re=o.sessions.map(z=>z.id);let le=[],se=[];const q=await D(Re);if(le=q.deletedIds,se=q.failedIds,le.length>0){const z=!X&&F?t(he?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,ce=[se.length>0?se.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:se.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:se.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0,z].filter(Boolean).join(" ");_e.success(le.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:le.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:le.length}),{description:Dn(ce||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(se.length>0&&(_e.error(se.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:se.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:se.length}),{description:Dn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),le.length===0)){y(!1);return}}ye()}finally{y(!1)}}},[o,d,m,k,D,ye,te,X,R,t]),ie=o?.worktree??a[0]?.metadata??null,H=o?o.mode==="worktree"?o.sessions.length===0?t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):o.sessions.length===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:o.sessions.length}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:o.sessions.length}):o.sessions.length===1?o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:o.sessions.length,dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:o.sessions.length}):"",me=o?s.jsxs("div",{className:Me(X?"space-y-3":"space-y-2"),children:[o.sessions.length>0&&s.jsxs("div",{className:Me(X?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[X&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:o.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:o.sessions.length})]}),s.jsxs("ul",{className:Me(X?"mt-2 space-y-1":"space-y-0.5"),children:[o.sessions.slice(0,5).map(F=>s.jsxs("li",{className:Me(X?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground/80"),children:[s.jsx("span",{className:Me(!X&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:F.title||t("sessions.sidebar.session.untitled")})]},F.id)),o.sessions.length>5&&s.jsx("li",{className:Me(X?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:o.sessions.length-5})})]})]}),X?s.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(M,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),ie?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:ie.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:ie?Jr(ie.path,_):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),ne&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,pe=X?ue?s.jsxs("button",{type:"button",onClick:()=>{fe||h(F=>!F)},disabled:fe,className:Me("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",fe?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[d?s.jsx(M,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(M,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,re=X?s.jsxs("button",{type:"button",onClick:()=>{je||g(F=>!F)},disabled:je,className:Me("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",je?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[m?s.jsx(M,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(M,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,de=X?s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[re,pe]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(dt,{variant:"ghost",onClick:ye,disabled:b,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{variant:"destructive",onClick:Y,disabled:b,children:t(b?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>P(!A),className:"inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":!A,children:[A?s.jsx(M,{name:"checkbox-blank",className:"size-4"}):s.jsx(M,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(dt,{variant:"ghost",onClick:ye,disabled:b,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{variant:"destructive",onClick:Y,disabled:b,children:b?t("sessions.sidebar.sessionDialogs.actions.deleting"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),B=X?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[K?s.jsx(Jo,{open:!!o,onClose:()=>{b||ye()},title:B,footer:s.jsx("div",{className:"flex justify-end gap-2",children:de}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[H&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:H}),me]})}):s.jsx(vs,{open:!!o,onOpenChange:F=>{if(!F){if(b)return;ye()}},children:s.jsxs(Ss,{className:Me(X?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs(Ws,{children:[s.jsxs(Is,{className:Me(X&&"flex items-center gap-2"),children:[X&&s.jsx(M,{name:"delete-bin",className:"h-5 w-5"}),B]}),H&&s.jsx(Ts,{children:H})]}),s.jsx("div",{className:Me(X&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:me}),s.jsx(Sn,{className:"mt-2 gap-2 pt-1 pb-1",children:de})]})}),s.jsx($h,{open:e,onOpenChange:n})]})};function I4(t){const e=et.c(64),{t:n}=vt(),{value:r,onMoveSessionOnly:i,onMoveAllChanges:o,onCancel:l}=t,a=!!r;let u;e[0]!==l?(u=$=>{$||l()},e[0]=l,e[1]=u):u=e[1];let d;e[2]!==n?(d=n("sessions.sidebar.session.moveToWorktree.confirm.title"),e[2]=n,e[3]=d):d=e[3];let h;e[4]!==d?(h=s.jsx(Is,{children:d}),e[4]=d,e[5]=h):h=e[5];const m=r?.dirtyFileCount??0;let g;e[6]!==n||e[7]!==m?(g=n("sessions.sidebar.session.moveToWorktree.confirm.changedFiles",{count:m}),e[6]=n,e[7]=m,e[8]=g):g=e[8];let b;e[9]!==n?(b=n("sessions.sidebar.session.moveToWorktree.confirm.ownership"),e[9]=n,e[10]=b):b=e[10];let y;e[11]!==g||e[12]!==b?(y=s.jsxs(Ts,{children:[g," ",b]}),e[11]=g,e[12]=b,e[13]=y):y=e[13];let S;e[14]!==h||e[15]!==y?(S=s.jsxs(Ws,{children:[h,y]}),e[14]=h,e[15]=y,e[16]=S):S=e[16];let w;e[17]!==n?(w=n("sessions.sidebar.session.moveToWorktree.confirm.sessionOnlyHelp"),e[17]=n,e[18]=w):w=e[18];let f;e[19]!==w?(f=s.jsx("p",{children:w}),e[19]=w,e[20]=f):f=e[20];let x;e[21]!==n?(x=n("sessions.sidebar.session.moveToWorktree.confirm.allChangesHelp"),e[21]=n,e[22]=x):x=e[22];let v;e[23]!==x?(v=s.jsx("p",{children:x}),e[23]=x,e[24]=v):v=e[24];let p;e[25]!==n||e[26]!==r?(p=r&&r.stagedFileCount>0?s.jsx("p",{"data-session-worktree-move-staged-warning":"true",children:n("sessions.sidebar.session.moveToWorktree.confirm.stagedWarning")}):null,e[25]=n,e[26]=r,e[27]=p):p=e[27];let N;e[28]!==n?(N=n("sessions.sidebar.session.moveToWorktree.confirm.baseWarning"),e[28]=n,e[29]=N):N=e[29];let C;e[30]!==N?(C=s.jsx("p",{children:N}),e[30]=N,e[31]=C):C=e[31];let k;e[32]!==f||e[33]!==v||e[34]!==p||e[35]!==C?(k=s.jsxs("div",{className:"space-y-2 typography-ui-label text-muted-foreground",children:[f,v,p,C]}),e[32]=f,e[33]=v,e[34]=p,e[35]=C,e[36]=k):k=e[36];let D;e[37]!==n?(D=n("sessions.sidebar.session.moveToWorktree.confirm.cancel"),e[37]=n,e[38]=D):D=e[38];let I;e[39]!==l||e[40]!==D?(I=s.jsx(dt,{type:"button",variant:"neutral","data-session-worktree-move-action":"cancel",onClick:l,children:D}),e[39]=l,e[40]=D,e[41]=I):I=e[41];let A;e[42]!==n?(A=n("sessions.sidebar.session.moveToWorktree.confirm.allChanges"),e[42]=n,e[43]=A):A=e[43];let P;e[44]!==o||e[45]!==A?(P=s.jsx(dt,{type:"button",variant:"outline","data-session-worktree-move-action":"all-changes",onClick:o,children:A}),e[44]=o,e[45]=A,e[46]=P):P=e[46];let T;e[47]!==n?(T=n("sessions.sidebar.session.moveToWorktree.confirm.sessionOnly"),e[47]=n,e[48]=T):T=e[48];let _;e[49]!==i||e[50]!==T?(_=s.jsx(dt,{type:"button",autoFocus:!0,"data-session-worktree-move-action":"session-only",onClick:i,children:T}),e[49]=i,e[50]=T,e[51]=_):_=e[51];let L;e[52]!==I||e[53]!==P||e[54]!==_?(L=s.jsxs(Sn,{className:"gap-2 sm:justify-end",children:[I,P,_]}),e[52]=I,e[53]=P,e[54]=_,e[55]=L):L=e[55];let W;e[56]!==k||e[57]!==L||e[58]!==S?(W=s.jsxs(Ss,{id:"session-worktree-move-confirm-dialog",showCloseButton:!1,className:"max-w-md gap-5",children:[S,k,L]}),e[56]=k,e[57]=L,e[58]=S,e[59]=W):W=e[59];let O;return e[60]!==a||e[61]!==u||e[62]!==W?(O=s.jsx(vs,{open:a,onOpenChange:u,children:W}),e[60]=a,e[61]=u,e[62]=W,e[63]=O):O=e[63],O}function om(t){if(!t||!t.trim())return{valid:!1,error:"required"};try{return ef.CronExpressionParser.parse(t),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Invalid cron expression"}}}function T4(t,e,n=4){try{const r=e?{tz:e,currentDate:new Date}:{currentDate:new Date},i=ef.CronExpressionParser.parse(t,r),o=[];for(let l=0;l<n;l+=1){const a=i.next();a&&o.push(a.toDate())}return o}catch{return[]}}const E4=[{expression:"*/5 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.every5min"},{expression:"0 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.everyHour"},{expression:"0 9 * * 1",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.monday9am"},{expression:"0 9,17 * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.9am5pm"},{expression:"0 0 1 * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.firstOfMonth"}],R4={"Europe/Kiev":"Europe/Kyiv","Asia/Calcutta":"Asia/Kolkata","Asia/Saigon":"Asia/Ho_Chi_Minh","Asia/Rangoon":"Asia/Yangon","Asia/Katmandu":"Asia/Kathmandu","America/Godthab":"America/Nuuk","Atlantic/Faeroe":"Atlantic/Faroe","Pacific/Enderbury":"Pacific/Kanton"},er=t=>R4[t]??t,im=[0,1,2,3,4,5,6],ad="flex h-6 w-6 cursor-pointer items-center justify-center text-foreground transition-none outline-none focus:outline-none flex-shrink-0",ba=typeof Intl<"u"&&typeof Intl.supportedValuesOf=="function"?[...new Set(Intl.supportedValuesOf("timeZone").map(er))]:["UTC","Europe/Kyiv","Europe/London","Europe/Berlin","America/New_York","America/Los_Angeles","Asia/Tokyo"],ld=()=>{const t=new Date,e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},Po=t=>{const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),i=Number(e[3]),o=new Date(n,r-1,i);return Number.isNaN(o.getTime())||o.getFullYear()!==n||o.getMonth()!==r-1||o.getDate()!==i?null:o},cd=t=>{const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},M4=(t,e,n)=>{const r=Po(t);return r?new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(r):e},dd=(t,e)=>new Date(t.getFullYear(),t.getMonth()+e,1),O4=(t,e)=>{const n=t.getFullYear(),r=t.getMonth(),l=(new Date(n,r,1).getDay()-e+7)%7,a=new Date(n,r+1,0).getDate(),u=new Date(n,r,0).getDate(),d=[];for(let h=0;h<42;h+=1){const m=h-l+1;if(m<=0){const g=u+m;d.push({date:new Date(n,r-1,g),inCurrentMonth:!1});continue}if(m>a){d.push({date:new Date(n,r+1,m-a),inCurrentMonth:!1});continue}d.push({date:new Date(n,r,m),inCurrentMonth:!0})}return d},B4=t=>{const e=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(t);if(!e)return{hour24:"00",hour12:"12",minute:"00",meridiem:"AM"};const n=Number(e[1]),r=e[2],i=n>=12?"PM":"AM",o=n%12===0?12:n%12;return{hour24:String(n).padStart(2,"0"),hour12:String(o).padStart(2,"0"),minute:r,meridiem:i}},Yn=(t,e,n)=>{const r=Number(t),i=Number(e),o=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,l=Number.isFinite(i)?Math.min(59,Math.max(0,i)):0;let a=o%12;return n==="PM"&&(a+=12),`${String(a).padStart(2,"0")}:${String(l).padStart(2,"0")}`},Pr=(t,e)=>{const{max:n,min:r=0,loop:i=!1}=e;let o=Number.parseInt(t,10);return Number.isFinite(o)?(i?(o>n&&(o=r),o<r&&(o=n)):(o>n&&(o=n),o<r&&(o=r)),String(o).padStart(2,"0")):"00"},ud=t=>/^(0[1-9]|1[0-2])$/.test(t)?t:Pr(t,{min:1,max:12}),wo=t=>/^[0-5][0-9]$/.test(t)?t:Pr(t,{max:59}),F4=(t,e)=>Pr(String(Number.parseInt(t,10)+e),{min:1,max:12,loop:!0}),fd=(t,e)=>Pr(String(Number.parseInt(t,10)+e),{min:0,max:59,loop:!0}),_4=t=>{try{const e=Intl.Locale;if(typeof e!="function")return 1;const r=new e(t).weekInfo?.firstDay;return typeof r!="number"?1:r%7}catch{return 1}},L4=t=>{try{const e=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions();return typeof e.hour12=="boolean"?!e.hour12:e.hourCycle==="h23"||e.hourCycle==="h24"}catch{return!0}},$4=t=>{const e=new Intl.DateTimeFormat(t,{weekday:"short"}),n=new Date(2023,0,1);return im.map(r=>e.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+r)))},z4=(t,e)=>[...t.slice(e),...t.slice(0,e)],Es=t=>{const e=et.c(6),{htmlFor:n,required:r,children:i}=t;let o;e[0]!==r?(o=r&&s.jsx("span",{className:"ml-0.5 text-destructive",children:"*"}),e[0]=r,e[1]=o):o=e[1];let l;return e[2]!==i||e[3]!==n||e[4]!==o?(l=s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,o]})}),e[2]=i,e[3]=n,e[4]=o,e[5]=l):l=e[5],l},md=t=>{const e=et.c(84),{value:n,onChange:r,use24Hour:i,hourAriaLabel:o,minuteAriaLabel:l,periodAriaLabel:a,amLabel:u,pmLabel:d}=t;let h;e[0]!==n?(h=B4(n),e[0]=n,e[1]=h):h=e[1];const m=h,g=xt.useRef(null),b=xt.useRef(null),[y,S]=xt.useState(null),[w,f]=xt.useState(null),x=xt.useRef(null),v=xt.useRef(null);let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=F=>{x.current=F,S(F)},e[2]=p):p=e[2];const N=p;let C;e[3]===Symbol.for("react.memo_cache_sentinel")?(C=F=>{v.current=F,f(F)},e[3]=C):C=e[3];const k=C,D=q4,I=Y4,A=Q4;let P;e[4]!==r||e[5]!==m.meridiem||e[6]!==m.minute||e[7]!==i?(P=F=>{const he=F.replace(/\D/g,"").slice(0,2);N(he),he.length===2&&(r(i?A(D(he),m.minute):Yn(ud(he),m.minute,m.meridiem)),N(null),b.current?.focus())},e[4]=r,e[5]=m.meridiem,e[6]=m.minute,e[7]=i,e[8]=P):P=e[8];const T=P;let _;e[9]!==r||e[10]!==m.meridiem||e[11]!==m.minute||e[12]!==i?(_=()=>{const F=x.current;if(F!==null&&(N(null),F.length!==0)){if(i){r(A(D(F.padStart(2,"0")),m.minute));return}r(Yn(ud(F.padStart(2,"0")),m.minute,m.meridiem))}},e[9]=r,e[10]=m.meridiem,e[11]=m.minute,e[12]=i,e[13]=_):_=e[13];const L=_;let W;e[14]!==r||e[15]!==m.hour12||e[16]!==m.hour24||e[17]!==m.meridiem||e[18]!==i?(W=F=>{const he=F.replace(/\D/g,"").slice(0,2);k(he),he.length===2&&(r(i?A(m.hour24,wo(he)):Yn(m.hour12,wo(he),m.meridiem)),k(null))},e[14]=r,e[15]=m.hour12,e[16]=m.hour24,e[17]=m.meridiem,e[18]=i,e[19]=W):W=e[19];const O=W;let $;e[20]!==r||e[21]!==m.hour12||e[22]!==m.hour24||e[23]!==m.meridiem||e[24]!==i?($=()=>{const F=v.current;F!==null&&(k(null),F.length!==0&&r(i?A(m.hour24,wo(F.padStart(2,"0"))):Yn(m.hour12,wo(F.padStart(2,"0")),m.meridiem)))},e[20]=r,e[21]=m.hour12,e[22]=m.hour24,e[23]=m.meridiem,e[24]=i,e[25]=$):$=e[25];const j=$;let E;e[26]!==r||e[27]!==m.hour12||e[28]!==m.hour24||e[29]!==m.meridiem||e[30]!==m.minute||e[31]!==i?(E=F=>r(i?A(I(m.hour24,F),m.minute):Yn(F4(m.hour12,F),m.minute,m.meridiem)),e[26]=r,e[27]=m.hour12,e[28]=m.hour24,e[29]=m.meridiem,e[30]=m.minute,e[31]=i,e[32]=E):E=e[32];const K=E;let ee;e[33]!==r||e[34]!==m.hour12||e[35]!==m.hour24||e[36]!==m.meridiem||e[37]!==m.minute||e[38]!==i?(ee=F=>r(i?A(m.hour24,fd(m.minute,F)):Yn(m.hour12,fd(m.minute,F),m.meridiem)),e[33]=r,e[34]=m.hour12,e[35]=m.hour24,e[36]=m.meridiem,e[37]=m.minute,e[38]=i,e[39]=ee):ee=e[39];const J=ee;let ne;e[40]!==r||e[41]!==m.hour12||e[42]!==m.meridiem||e[43]!==m.minute?(ne=F=>{F!==m.meridiem&&r(Yn(m.hour12,m.minute,F))},e[40]=r,e[41]=m.hour12,e[42]=m.meridiem,e[43]=m.minute,e[44]=ne):ne=e[44];const ue=ne;let X;e[45]!==L||e[46]!==K?(X=F=>{if(F.key==="ArrowRight"){F.preventDefault(),L(),b.current?.focus();return}(F.key==="ArrowUp"||F.key==="ArrowDown")&&(F.preventDefault(),N(null),K(F.key==="ArrowUp"?1:-1))},e[45]=L,e[46]=K,e[47]=X):X=e[47];const te=X;let fe;e[48]!==j||e[49]!==J?(fe=F=>{if(F.key==="ArrowLeft"&&(F.currentTarget.selectionStart??0)===0){F.preventDefault(),j(),g.current?.focus();return}(F.key==="ArrowUp"||F.key==="ArrowDown")&&(F.preventDefault(),k(null),J(F.key==="ArrowUp"?1:-1))},e[48]=j,e[49]=J,e[50]=fe):fe=e[50];const je=fe,ve=i?"px-2":"pl-2 pr-1";let ye;e[51]!==ve?(ye=Me("oc-surface-elevated inline-flex h-9 w-fit items-center gap-1 rounded-md border border-border bg-surface-elevated focus-within:ring-1 focus-within:ring-ring focus-within:border-ring",ve),e[51]=ve,e[52]=ye):ye=e[52];const Pe=y??(i?m.hour24:m.hour12);let xe;e[53]!==T?(xe=F=>T(F.target.value),e[53]=T,e[54]=xe):xe=e[54];let R;e[55]===Symbol.for("react.memo_cache_sentinel")?(R=()=>N(""),e[55]=R):R=e[55];let Y;e[56]!==L||e[57]!==o||e[58]!==te||e[59]!==Pe||e[60]!==xe?(Y=s.jsx("input",{ref:g,inputMode:"numeric",value:Pe,onChange:xe,onKeyDown:te,onFocus:R,onBlur:L,maxLength:2,"aria-label":o,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[56]=L,e[57]=o,e[58]=te,e[59]=Pe,e[60]=xe,e[61]=Y):Y=e[61];let ie;e[62]===Symbol.for("react.memo_cache_sentinel")?(ie=s.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:":"}),e[62]=ie):ie=e[62];const H=w??m.minute;let me;e[63]!==O?(me=F=>O(F.target.value),e[63]=O,e[64]=me):me=e[64];let pe;e[65]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>k(""),e[65]=pe):pe=e[65];let re;e[66]!==j||e[67]!==l||e[68]!==je||e[69]!==H||e[70]!==me?(re=s.jsx("input",{ref:b,inputMode:"numeric",value:H,onChange:me,onKeyDown:je,onFocus:pe,onBlur:j,maxLength:2,"aria-label":l,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[66]=j,e[67]=l,e[68]=je,e[69]=H,e[70]=me,e[71]=re):re=e[71];let de;e[72]!==u||e[73]!==m.meridiem||e[74]!==a||e[75]!==d||e[76]!==ue||e[77]!==i?(de=i?null:s.jsxs(Ms,{value:m.meridiem,onValueChange:F=>ue(F),children:[s.jsx(Os,{"aria-label":a,className:"ml-1 h-7 w-fit border-0 bg-transparent pl-2 pr-1 shadow-none hover:bg-interactive-hover focus:ring-0",children:s.jsx(Ns,{})}),s.jsxs(Bs,{children:[s.jsx(is,{value:"AM",children:u}),s.jsx(is,{value:"PM",children:d})]})]}),e[72]=u,e[73]=m.meridiem,e[74]=a,e[75]=d,e[76]=ue,e[77]=i,e[78]=de):de=e[78];let B;return e[79]!==ye||e[80]!==Y||e[81]!==re||e[82]!==de?(B=s.jsxs("div",{className:ye,children:[Y,ie,re,de]}),e[79]=ye,e[80]=Y,e[81]=re,e[82]=de,e[83]=B):B=e[83],B},hd=t=>new Date(t.getFullYear(),t.getMonth(),1),W4=()=>{const t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate())},pd=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),K4=t=>{if(!t)return["09:00"];const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(i=>typeof i=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(i)).map(i=>i.trim()),r=Array.from(new Set(n)).sort((i,o)=>i.localeCompare(o));return r.length>0?r:["09:00"]},gd=(t,e)=>{const n=er(Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC");return t?{id:t.id,name:t.name,enabled:t.enabled,schedule:{kind:t.schedule.kind==="cron"?"cron":t.schedule.kind==="once"?"once":t.schedule.kind==="weekly"?"weekly":"daily",times:K4(t),onceDate:typeof t.schedule.date=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.date)?t.schedule.date:ld(),onceTime:typeof t.schedule.time=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.time)?t.schedule.time:"09:00",weekdays:Array.isArray(t.schedule.weekdays)?t.schedule.weekdays:[1],timezone:er(t.schedule.timezone||n),cronExpression:t.schedule.kind==="cron"&&typeof t.schedule.cron=="string"?t.schedule.cron:""},execution:{prompt:t.execution.prompt,providerID:t.execution.providerID,modelID:t.execution.modelID,variant:t.execution.variant||"",agent:t.execution.agent||"",goalEnabled:t.execution.goalEnabled===!0,goalTokenBudget:typeof t.execution.goalTokenBudget=="number"&&t.execution.goalTokenBudget>0?t.execution.goalTokenBudget:null,permissionAutoAccept:t.execution.permissionAutoAccept===!0},state:t.state}:{name:"",enabled:!0,schedule:{kind:"daily",times:["09:00"],onceDate:ld(),onceTime:"09:00",weekdays:[1],timezone:n,cronExpression:""},execution:{prompt:"",providerID:e.providerID,modelID:e.modelID,variant:e.variant,agent:e.agent,goalEnabled:!1,goalTokenBudget:null,permissionAutoAccept:!1}}},V4=(t,e)=>{if(!t.name.trim())return e("sessions.scheduledTasks.editor.validation.taskNameRequired");if(!t.execution.prompt.trim())return e("sessions.scheduledTasks.editor.validation.promptRequired");if(!t.execution.providerID.trim()||!t.execution.modelID.trim())return e("sessions.scheduledTasks.editor.validation.modelRequired");if(t.schedule.kind==="once"){if(!/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.onceDate))return e("sessions.scheduledTasks.editor.validation.dateFormat");if(!/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.onceTime))return e("sessions.scheduledTasks.editor.validation.timeFormat")}else if(t.schedule.kind==="cron"){if(!t.schedule.cronExpression.trim())return e("sessions.scheduledTasks.editor.validation.cronRequired");if(!om(t.schedule.cronExpression).valid)return e("sessions.scheduledTasks.editor.validation.cronInvalid")}else if(t.schedule.times.filter(r=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(r)).length===0)return e("sessions.scheduledTasks.editor.validation.atLeastOneTime");return t.schedule.kind==="weekly"&&t.schedule.weekdays.length===0?e("sessions.scheduledTasks.editor.validation.atLeastOneWeekday"):t.schedule.timezone.trim()?null:e("sessions.scheduledTasks.editor.validation.timezoneRequired")},U4=t=>{const e=t.filter(n=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(n));return Array.from(new Set(e)).sort((n,r)=>n.localeCompare(r))},H4=t=>{const e=et.c(64),{draft:n,setDraft:r,locale:i,t:o}=t,l=n.schedule.cronExpression;let a;e[0]!==l?(a=l.trim()?om(l):null,e[0]=l,e[1]=a):a=e[1];const u=a;let d;e:{if(!u?.valid||!l.trim()){let E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=[],e[2]=E):E=e[2],d=E;break e}let j;e[3]!==l||e[4]!==n.schedule.timezone?(j=T4(l,n.schedule.timezone),e[3]=l,e[4]=n.schedule.timezone,e[5]=j):j=e[5],d=j}const h=d;let m;e[6]!==n.schedule.timezone||e[7]!==i?(m=j=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(j),e[6]=n.schedule.timezone,e[7]=i,e[8]=m):m=e[8];const g=m;let b;e[9]!==o?(b=o("sessions.scheduledTasks.editor.cronExpression.label"),e[9]=o,e[10]=b):b=e[10];let y;e[11]!==b?(y=s.jsx(Es,{htmlFor:"sched-cron",required:!0,children:b}),e[11]=b,e[12]=y):y=e[12];let S;e[13]!==r?(S=j=>r(E=>({...E,schedule:{...E.schedule,cronExpression:j.target.value}})),e[13]=r,e[14]=S):S=e[14];let w;e[15]!==o?(w=o("sessions.scheduledTasks.editor.cronExpression.placeholder"),e[15]=o,e[16]=w):w=e[16];let f;e[17]!==l||e[18]!==S||e[19]!==w?(f=s.jsx(In,{id:"sched-cron",value:l,onChange:S,placeholder:w,className:"w-full max-w-xs font-mono"}),e[17]=l,e[18]=S,e[19]=w,e[20]=f):f=e[20];let x;e[21]!==l||e[22]!==u||e[23]!==o?(x=u&&!u.valid&&l.trim()?s.jsx("span",{className:"typography-micro text-destructive",children:o("sessions.scheduledTasks.editor.validation.cronInvalid")}):null,e[21]=l,e[22]=u,e[23]=o,e[24]=x):x=e[24];let v;e[25]!==y||e[26]!==f||e[27]!==x?(v=s.jsxs("div",{className:"flex flex-col gap-1",children:[y,f,x]}),e[25]=y,e[26]=f,e[27]=x,e[28]=v):v=e[28];let p;e[29]!==g||e[30]!==h||e[31]!==o?(p=h.length>0?s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:o("sessions.scheduledTasks.editor.cronExpression.nextRuns")}),s.jsx("span",{className:"typography-micro text-foreground",children:h.map(g).join(", ")})]}):null,e[29]=g,e[30]=h,e[31]=o,e[32]=p):p=e[32];let N;e[33]!==o?(N=o("sessions.scheduledTasks.editor.cronExpression.examples"),e[33]=o,e[34]=N):N=e[34];let C;e[35]!==N?(C=s.jsx("span",{className:"typography-meta text-muted-foreground",children:N}),e[35]=N,e[36]=C):C=e[36];let k;e[37]!==r||e[38]!==o?(k=E4.map(j=>s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 typography-micro text-foreground hover:bg-interactive-hover",onClick:()=>r(E=>({...E,schedule:{...E.schedule,cronExpression:j.expression}})),children:[s.jsx("span",{className:"font-mono",children:j.expression}),s.jsx("span",{className:"text-muted-foreground",children:o(j.labelKey)})]},j.expression)),e[37]=r,e[38]=o,e[39]=k):k=e[39];let D;e[40]!==k?(D=s.jsx("div",{className:"flex flex-wrap gap-1.5",children:k}),e[40]=k,e[41]=D):D=e[41];let I;e[42]!==C||e[43]!==D?(I=s.jsxs("div",{className:"flex flex-col gap-1",children:[C,D]}),e[42]=C,e[43]=D,e[44]=I):I=e[44];let A;e[45]!==o?(A=o("sessions.scheduledTasks.editor.timezone.label"),e[45]=o,e[46]=A):A=e[46];let P;e[47]!==A?(P=s.jsx(Es,{children:A}),e[47]=A,e[48]=P):P=e[48];let T;e[49]!==r?(T=j=>{r(E=>({...E,schedule:{...E.schedule,timezone:j}}))},e[49]=r,e[50]=T):T=e[50];let _;e[51]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ns,{})}),e[51]=_):_=e[51];let L;e[52]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(Bs,{children:ba.map(X4)}),e[52]=L):L=e[52];let W;e[53]!==n.schedule.timezone||e[54]!==T?(W=s.jsxs(Ms,{value:n.schedule.timezone,onValueChange:T,children:[_,L]}),e[53]=n.schedule.timezone,e[54]=T,e[55]=W):W=e[55];let O;e[56]!==P||e[57]!==W?(O=s.jsxs("div",{className:"flex flex-col gap-1",children:[P,W]}),e[56]=P,e[57]=W,e[58]=O):O=e[58];let $;return e[59]!==v||e[60]!==p||e[61]!==I||e[62]!==O?($=s.jsxs("div",{className:"flex flex-col gap-3",children:[v,p,I,O]}),e[59]=v,e[60]=p,e[61]=I,e[62]=O,e[63]=$):$=e[63],$};function G4(t){const{open:e,task:n,onOpenChange:r,onSave:i}=t,{t:o,locale:l}=vt(),a=Yt(V=>V.loadProviders),u=Yt(V=>V.loadAgents),d=Yt(V=>V.providers),h=Yt(V=>V.currentProviderId),m=Yt(V=>V.currentModelId),g=Yt(V=>V.currentVariant||""),b=Yt(V=>V.currentAgentName||""),y=De(V=>V.timeFormatPreference),S=De(V=>V.weekStartPreference),w=De(V=>V.isMobile),[f,x]=xt.useState(()=>gd(n,{providerID:h,modelID:m,variant:g,agent:b})),[v,p]=xt.useState(!1),[N,C]=xt.useState(!1),[k,D]=xt.useState(!1),[I,A]=xt.useState(""),[P,T]=xt.useState(!1),[_,L]=xt.useState(""),[W,O]=xt.useState(!1),[$,j]=xt.useState(""),[E,K]=xt.useState(()=>{const V=Po(n?.schedule?.date||"")||new Date;return new Date(V.getFullYear(),V.getMonth(),1)}),ee=xt.useRef(null),J=xt.useRef(null),ne=xt.useRef(null),ue=xt.useRef(null),X=xt.useRef(null),te=xt.useMemo(()=>L4(l),[l]),fe=xt.useMemo(()=>_4(l),[l]),je=xt.useMemo(()=>y==="24h"?!0:y==="12h"?!1:te,[y,te]),ve=xt.useMemo(()=>S==="sunday"?0:S==="monday"?1:fe,[S,fe]),ye=xt.useMemo(()=>{const V=$4(l);return z4(im.map(Ae=>({value:Ae,label:V[Ae]||""})),ve)},[l,ve]);xt.useEffect(()=>{e&&(a({source:"scheduledTaskEditor"}),u({source:"scheduledTaskEditor"}))},[e,a,u]),xt.useEffect(()=>{if(!e)return;x(gd(n,{providerID:h,modelID:m,variant:g,agent:b}));const V=Po(n?.schedule?.date||"")||new Date;K(new Date(V.getFullYear(),V.getMonth(),1)),C(!1),T(!1),D(!1),L(""),A("")},[e,n,h,m,g,b]),xt.useEffect(()=>{if(!N)return;const V=Ae=>{ee.current&&!ee.current.contains(Ae.target)&&C(!1)};return document.addEventListener("mousedown",V),()=>{document.removeEventListener("mousedown",V)}},[N]);const Pe=xt.useMemo(()=>{const Ae=d.find(Ie=>Ie.id===f.execution.providerID)?.models?.find(Ie=>Ie.id===f.execution.modelID);return Ae?.variants?Object.keys(Ae.variants):[]},[d,f.execution.providerID,f.execution.modelID]),xe=Pe.length>0,R=xt.useMemo(()=>!xe||!f.execution.variant?"__default":Pe.includes(f.execution.variant)?f.execution.variant:"__default",[f.execution.variant,xe,Pe]);xt.useEffect(()=>{xe||!f.execution.variant||x(V=>({...V,execution:{...V.execution,variant:""}}))},[xe,f.execution.variant]);const Y=xt.useCallback((V,Ae)=>{x(Ie=>{const Fe=new Set(Ie.schedule.weekdays);return Ae?Fe.add(V):Fe.delete(V),{...Ie,schedule:{...Ie.schedule,weekdays:Array.from(Fe).sort((st,lt)=>st-lt)}}})},[]),ie=xt.useCallback((V,Ae)=>{x(Ie=>{const Fe=Ie.schedule.times.slice();return Fe[V]=Ae,{...Ie,schedule:{...Ie.schedule,times:Fe}}})},[]),H=xt.useCallback(V=>{x(Ae=>{const Ie=Ae.schedule.times.filter((Fe,st)=>st!==V);return{...Ae,schedule:{...Ae.schedule,times:Ie.length>0?Ie:["09:00"]}}})},[]),me=xt.useCallback(()=>{x(V=>({...V,schedule:{...V.schedule,times:[...V.schedule.times,"12:00"]}}))},[]),pe=xt.useMemo(()=>W4(),[]),re=xt.useMemo(()=>hd(pe),[pe]),de=xt.useMemo(()=>{const V=Po(f.schedule.onceDate);return V?pd(V,pe)?o("sessions.scheduledTasks.editor.date.today"):new Intl.DateTimeFormat(l,{weekday:"short"}).format(V):null},[f.schedule.onceDate,l,o,pe]),B=xt.useMemo(()=>hd(E).getTime()<=re.getTime(),[E,re]),F=xt.useMemo(()=>ye.map(V=>V.label),[ye]),he=xt.useCallback(V=>{x(Ae=>({...Ae,schedule:{...Ae.schedule,onceDate:V}}))},[]),Se=xt.useCallback((V,Ae)=>{if(V.startsWith("/")){const lt=V.indexOf(" "),it=V.indexOf(`
890
- `),mt=Math.min(lt===-1?V.length:lt,it===-1?V.length:it);if(Ae<=mt&&lt===-1){L(V.substring(1,mt)),T(!0),D(!1),O(!1);return}}T(!1);const Ie=V.substring(0,Ae),Fe=Ie.lastIndexOf("#");if(Fe!==-1){const lt=Fe>0?Ie[Fe-1]:null,it=Ie.substring(Fe+1);if((!lt||/\s/.test(lt))&&!it.includes(" ")&&!it.includes(`
891
- `)){j(it),O(!0),D(!1);return}}O(!1);const st=Ie.lastIndexOf("@");if(st!==-1){const lt=st>0?Ie[st-1]:null,it=Ie.substring(st+1);(!lt||/\s/.test(lt))&&!it.includes(" ")&&!it.includes(`
892
- `)?(A(it),D(!0)):D(!1);return}D(!1)},[]),Re=xt.useCallback(V=>{x(Ae=>({...Ae,execution:{...Ae.execution,prompt:V}}))},[]),le=xt.useCallback(V=>{const Ae=f.execution.prompt,Fe=J.current?.selectionStart??Ae.length,lt=Ae.substring(0,Fe).lastIndexOf("@"),it=V.relativePath&&V.relativePath.trim().length>0?V.relativePath.trim():V.path||V.name,mt=lt!==-1?lt:Fe,St=`${Ae.substring(0,mt)}@${it} ${Ae.substring(Fe)}`,ht=mt+it.length+2;Re(St),D(!1),A(""),requestAnimationFrame(()=>{const Xe=J.current;Xe&&(Xe.selectionStart=ht,Xe.selectionEnd=ht,Xe.focus()),Se(St,ht)})},[f.execution.prompt,Re,Se]),se=xt.useCallback(V=>{const Ae=f.execution.prompt,Fe=J.current?.selectionStart??Ae.length,lt=Ae.substring(0,Fe).lastIndexOf("@"),it=lt!==-1?lt:Fe,mt=`${Ae.substring(0,it)}@${V} ${Ae.substring(Fe)}`,St=it+V.length+2;Re(mt),D(!1),A(""),requestAnimationFrame(()=>{const ht=J.current;ht&&(ht.selectionStart=St,ht.selectionEnd=St,ht.focus()),Se(mt,St)})},[f.execution.prompt,Re,Se]),q=xt.useCallback(V=>{const Ae=`/${V.name} `;Re(Ae),T(!1),L(""),O(!1),requestAnimationFrame(()=>{const Ie=J.current;Ie&&(Ie.focus(),Ie.selectionStart=Ie.value.length,Ie.selectionEnd=Ie.value.length),Se(Ae,Ae.length)})},[Re,Se]),z=xt.useCallback((V,Ae)=>{const Ie=f.execution.prompt,st=J.current?.selectionStart??Ie.length,it=Ie.substring(0,st).lastIndexOf("#"),mt=it!==-1?it:st,St=`${Ie.substring(0,mt)}#${Ae} ${Ie.substring(st)}`,ht=mt+Ae.length+2;Re(St),O(!1),j(""),requestAnimationFrame(()=>{const Xe=J.current;Xe&&(Xe.selectionStart=ht,Xe.selectionEnd=ht,Xe.focus()),Se(St,ht)})},[f.execution.prompt,Re,Se]),ae=xt.useCallback(V=>{if(P&&ue.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")){V.preventDefault(),ue.current.handleKeyDown(V.key);return}k&&ne.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")&&(V.preventDefault(),ne.current.handleKeyDown(V.key)),W&&X.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")&&(V.preventDefault(),X.current.handleKeyDown(V.key))},[P,k,W]),ce=xt.useCallback(async()=>{const V=V4(f,o);if(V){_e.error(V);return}const Ae={...f.id?{id:f.id}:{},name:f.name.trim(),enabled:f.enabled,schedule:{kind:f.schedule.kind,timezone:f.schedule.timezone.trim(),...f.schedule.kind==="cron"?{cron:f.schedule.cronExpression.trim()}:f.schedule.kind==="once"?{date:f.schedule.onceDate,time:f.schedule.onceTime}:{times:U4(f.schedule.times),...f.schedule.kind==="weekly"?{weekdays:f.schedule.weekdays}:{}}},execution:{prompt:f.execution.prompt,providerID:f.execution.providerID,modelID:f.execution.modelID,...f.execution.variant.trim()?{variant:f.execution.variant.trim()}:{},...f.execution.agent.trim()?{agent:f.execution.agent.trim()}:{},...f.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...f.execution.goalEnabled?{goalEnabled:!0}:{},...f.execution.goalEnabled&&f.execution.goalTokenBudget?{goalTokenBudget:f.execution.goalTokenBudget}:{}},...f.state?{state:f.state}:{}};p(!0);try{await i(Ae),r(!1)}catch(Ie){_e.error(Ie instanceof Error?Ie.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{p(!1)}},[f,r,i,o]),Ne=xt.useId(),we=xt.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),$e=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),Oe=o("sessions.scheduledTasks.editor.description"),ge=s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Es,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(In,{id:"sched-name",value:f.name,onChange:V=>x(Ae=>({...Ae,name:V.target.value})),placeholder:o("sessions.scheduledTasks.editor.taskName.placeholder"),maxLength:80,className:"w-full sm:max-w-[220px]"})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(Ms,{value:f.schedule.kind,onValueChange:V=>{x(Ae=>({...Ae,schedule:{...Ae.schedule,kind:V,...V==="cron"&&!Ae.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ns,{children:V=>o(V==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":V==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":V==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(Bs,{children:[s.jsx(is,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(is,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(is,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(is,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),f.schedule.kind==="cron"?s.jsx(H4,{draft:f,setDraft:x,locale:l,t:o}):f.schedule.kind==="once"?s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",ref:ee,children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:Me(Ru({size:"default"}),"w-fit max-w-full"),onClick:()=>C(V=>!V),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(M,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:M4(f.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(M,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),N?s.jsxs("div",{className:"oc-surface-elevated absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-surface-elevated p-3 shadow-sm",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>K(V=>dd(V,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:B,children:s.jsx(M,{name:"arrow-left-s",className:"h-4 w-4"})}),s.jsx("div",{className:"typography-ui-label text-foreground",children:new Intl.DateTimeFormat(l,{month:"long",year:"numeric"}).format(E)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>K(V=>dd(V,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(M,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:F.map((V,Ae)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:V},`${V}-${Ae}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:O4(E,ve).map(({date:V,inCurrentMonth:Ae})=>{const Ie=cd(V),Fe=Ie===f.schedule.onceDate,st=pd(V,pe),lt=V.getTime()<pe.getTime(),it=Fe?"bg-interactive-selection text-interactive-selection-foreground":lt?"text-muted-foreground/40":Ae?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{lt||(he(Ie),C(!1))},disabled:lt,className:["h-8 rounded-md typography-ui-label",it,st&&!Fe?"ring-1 ring-inset ring-ring bg-interactive-selection text-interactive-selection-foreground":"",lt?"cursor-not-allowed opacity-45":""].join(" "),children:V.getDate()},Ie)})}),s.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:de||""}),s.jsx(dt,{type:"button",size:"xs",variant:"ghost",onClick:()=>{he(cd(pe)),K(new Date(pe.getFullYear(),pe.getMonth(),1))},children:o("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(md,{value:f.schedule.onceTime,use24Hour:je,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:V=>x(Ae=>({...Ae,schedule:{...Ae.schedule,onceTime:V}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Ms,{value:f.schedule.timezone,onValueChange:V=>{x(Ae=>({...Ae,schedule:{...Ae.schedule,timezone:V}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ns,{})}),s.jsx(Bs,{children:ba.map(V=>s.jsx(is,{value:V,children:V},V))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[f.schedule.kind==="weekly"?s.jsxs("div",{className:"flex flex-col gap-1 sm:col-span-2",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:ye.map(V=>{const Ae=f.schedule.weekdays.includes(V.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",Ae?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(br,{checked:Ae,onChange:Ie=>Y(V.value,Ie),ariaLabel:V.label}),s.jsx("button",{type:"button",onClick:()=>Y(V.value,!Ae),className:"group-hover:text-foreground",children:V.label})]},V.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:f.schedule.times.map((V,Ae)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(md,{value:V,use24Hour:je,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:Ie=>ie(Ae,Ie)}),f.schedule.times.length>1?s.jsx(dt,{type:"button",size:"icon",variant:"ghost",onClick:()=>H(Ae),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(M,{name:"close",className:"h-4 w-4"})}):null]},Ae))}),s.jsx("div",{children:s.jsxs(dt,{type:"button",size:"sm",variant:"outline",onClick:me,children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"})," ",o("sessions.scheduledTasks.editor.times.add")]})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Ms,{value:f.schedule.timezone,onValueChange:V=>{x(Ae=>({...Ae,schedule:{...Ae.schedule,timezone:V}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ns,{})}),s.jsx(Bs,{children:ba.map(V=>s.jsx(is,{value:V,children:V},V))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Es,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(Fg,{providerId:f.execution.providerID,modelId:f.execution.modelID,onChange:(V,Ae)=>{x(Ie=>({...Ie,execution:{...Ie.execution,providerID:V,modelID:Ae,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(Ms,{value:R,disabled:!xe,onValueChange:V=>{x(Ae=>({...Ae,execution:{...Ae.execution,variant:V==="__default"?"":V}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ns,{children:V=>V==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):V})}),s.jsxs(Bs,{children:[s.jsx(is,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),Pe.map(V=>s.jsx(is,{value:V,children:V},V))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(_g,{agentName:f.execution.agent,filter:V=>Eu(V.mode),onChange:V=>x(Ae=>({...Ae,execution:{...Ae.execution,agent:V}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Es,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(pr,{id:"sched-prompt",ref:J,value:f.execution.prompt,onChange:V=>{const Ae=V.target.value;Re(Ae);const Ie=V.target.selectionStart??Ae.length;Se(Ae,Ie)},onKeyDown:ae,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),P?s.jsx(_u,{ref:ue,searchQuery:_,onCommandSelect:q,onClose:()=>T(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,k?s.jsx(Lu,{ref:ne,searchQuery:I,onFileSelect:le,onAgentSelect:se,onClose:()=>D(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,W?s.jsx($u,{ref:X,searchQuery:$,onSnippetSelect:z,onClose:()=>O(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null]})]}),f.execution.goalEnabled?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-2",children:[s.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-2",children:[s.jsx(br,{checked:f.execution.goalTokenBudget!==null,onChange:V=>x(Ae=>({...Ae,execution:{...Ae.execution,goalTokenBudget:V?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),f.execution.goalTokenBudget!==null?s.jsx(Lg,{value:f.execution.goalTokenBudget,onValueChange:V=>{typeof V=="number"&&Number.isFinite(V)&&V>0&&x(Ae=>({...Ae,execution:{...Ae.execution,goalTokenBudget:Math.floor(V)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),He=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("label",{className:"inline-flex items-center gap-2",children:[s.jsx(br,{checked:f.enabled,onChange:V=>x(Ae=>({...Ae,enabled:V})),ariaLabel:o("sessions.scheduledTasks.editor.enabled.aria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.enabled.label")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",className:Me(ad),onClick:()=>x(V=>({...V,execution:{...V.execution,permissionAutoAccept:!V.execution.permissionAutoAccept}})),"aria-pressed":f.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:f.execution.permissionAutoAccept?s.jsx(M,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(M,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(It,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",className:Me(ad,f.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>x(V=>({...V,execution:{...V.execution,goalEnabled:!V.execution.goalEnabled}})),"aria-pressed":f.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:f.execution.goalEnabled?s.jsx(M,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(M,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(It,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:v,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(dt,{type:"button",size:"sm",onClick:ce,disabled:v,children:o(v?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return w?s.jsx(Jo,{open:e,title:$e,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:V=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:$e}),V]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:Oe})]}),footer:He,children:ge}):s.jsx(vs,{open:e,onOpenChange:V=>{!V&&we()||r(V)},children:s.jsxs(Ss,{"aria-describedby":Ne,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Ts,{id:Ne,className:"sr-only",children:Oe}),s.jsx("header",{className:"shrink-0 px-4 sm:px-6 pt-5 pb-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[s.jsx(Is,{className:"typography-ui-label font-medium text-foreground",children:$e}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:Oe})]})}),s.jsx(Ia,{className:"flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5",children:ge})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsx("div",{className:"mx-auto w-full max-w-2xl",children:He})})]})})}function q4(t){return Pr(t,{min:0,max:23})}function Y4(t,e){return Pr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function Q4(t,e){const n=Number(t),r=Number(e),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,o=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`}function X4(t){return s.jsx(is,{value:t,children:t},t)}const J4=t=>{const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(r=>typeof r=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(r));return Array.from(new Set(n)).sort((r,i)=>r.localeCompare(i))},Z4=(t,e)=>{const n=J4(t).join(", ")||"--:--",r=i=>e(i===0?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sun":i===1?"sessions.scheduledTasks.dialog.schedule.weekdayShort.mon":i===2?"sessions.scheduledTasks.dialog.schedule.weekdayShort.tue":i===3?"sessions.scheduledTasks.dialog.schedule.weekdayShort.wed":i===4?"sessions.scheduledTasks.dialog.schedule.weekdayShort.thu":i===5?"sessions.scheduledTasks.dialog.schedule.weekdayShort.fri":i===6?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sat":"sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown");if(t.schedule.kind==="daily")return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.dailyWithTimezone",{time:n,timezone:er(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.daily",{time:n});if(t.schedule.kind==="weekly"){const i=Array.isArray(t.schedule.weekdays)?t.schedule.weekdays.map(o=>r(o)).join(", "):"";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone",{days:i,time:n,timezone:er(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.weekly",{days:i,time:n})}if(t.schedule.kind==="once"){const i=typeof t.schedule.date=="string"&&t.schedule.date.trim().length>0?t.schedule.date:e("sessions.scheduledTasks.dialog.schedule.unknownDate"),o=typeof t.schedule.time=="string"&&t.schedule.time.trim().length>0?t.schedule.time:"--:--";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.onceWithTimezone",{date:i,time:o,timezone:er(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.once",{date:i,time:o})}return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.cronWithTimezone",{cron:t.schedule.cron||"",timezone:er(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},eC=(t,e)=>!t||!Number.isFinite(t)?"":$g(t,e),xd=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),i=6e4,o=60*i,l=24*o,a=n>=0;if(r<i)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<o){const m=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:m}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:m})}if(r<l){const m=Math.floor(r/o),g=Math.round(r%o/i),b=g>0?`${m}h ${g}m`:`${m}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:b}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:b})}const u=Math.floor(r/l),d=Math.round(r%l/o),h=d>0?`${u}d ${d}h`:`${u}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:h}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:h})},tC={success:{tone:"success",Icon:"checkbox-circle"},error:{tone:"error",Icon:"error-warning"},running:{tone:"warning",Icon:"loader-4",spin:!0},idle:{tone:"muted",Icon:"pulse"}},sC=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function nC(){const{t}=vt(),e=De(j=>j.isScheduledTasksDialogOpen),n=De(j=>j.setScheduledTasksDialogOpen),r=De(j=>j.isMobile),i=De(j=>j.timeFormatPreference),o=Gt(j=>j.projects),l=Gt(j=>j.getActiveProject()),a=os(j=>j.homeDirectory),{currentTheme:u}=ar(),[d,h]=xt.useState(""),[m,g]=xt.useState([]),[b,y]=xt.useState(!0),[S,w]=xt.useState(!1),[f,x]=xt.useState(null),[v,p]=xt.useState(null),N=xt.useMemo(()=>o.find(j=>j.id===d)||null,[o,d]),C=xt.useCallback(j=>{const E=j.label?.trim()||Wn(j.path,a||void 0),K=j.icon?$a[j.icon]:null,ee=j.color?za[j.color]:void 0,J=K?s.jsx(M,{name:K,className:"h-3.5 w-3.5 shrink-0",style:ee?{color:ee}:void 0}):s.jsx(M,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:ee?{color:ee}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[j.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:j.iconBackground?{backgroundColor:j.iconBackground}:void 0,children:s.jsx(Wa,{project:{id:j.id,iconImage:j.iconImage??null},options:{themeVariant:u.metadata.variant,iconColor:u.colors.surface.foreground},className:"h-full w-full object-contain",fallback:J})}):J,s.jsx("span",{className:"truncate",children:E})]})},[a,u.metadata.variant,u.colors.surface.foreground]),k=xt.useCallback(async(j,E)=>{if(!j){g([]);return}E?.silent||y(!0);try{const K=await Ux(j);K.sort((ee,J)=>{if(ee.enabled!==J.enabled)return ee.enabled?-1:1;const ne=ee.name.localeCompare(J.name);return ne!==0?ne:(ee.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(J.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),g(K)}catch(K){_e.error(K instanceof Error?K.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),E?.silent||g([])}finally{E?.silent||y(!1)}},[t]);xt.useEffect(()=>{if(!e)return;const j=l?.id||o[0]?.id||"";h(j),j?k(j):(g([]),y(!1))},[e,l,o,k]),xt.useEffect(()=>{if(!e)return;let j=null;const E=ro(K=>{K.type==="scheduled-task-ran"&&K.projectId===d&&(j&&clearTimeout(j),j=setTimeout(()=>{k(d,{silent:!0})},400))});return()=>{j&&clearTimeout(j),E()}},[e,d,k]);const D=xt.useCallback(async j=>{if(!d)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await Gl(d,j),await k(d),_e.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[d,k,t]),I=xt.useCallback(async(j,E)=>{if(d){p(j.id),g(K=>K.map(ee=>ee.id===j.id?{...ee,enabled:E}:ee));try{j.loopFile?await Hx(d,j.id,E):await Gl(d,{...j,enabled:E}),await k(d,{silent:!0})}catch(K){_e.error(K instanceof Error?K.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await k(d,{silent:!0})}finally{p(null)}}},[d,k,t]),A=xt.useCallback(async j=>{if(!(!d||!window.confirm(j.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:j.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:j.name})))){p(j.id);try{j.loopFile?await Gx(d,j.id):await qx(d,j.id),await k(d,{silent:!0}),_e.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(K){_e.error(K instanceof Error?K.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{p(null)}}},[d,k,t]),P=xt.useCallback(j=>{if(!j.loopFile){x(j),w(!0);return}N?.path&&(n(!1),bn.getState().setSelectedPath(N.path,j.loopFile,{allowOutsideRoot:!0}),De.getState().openContextFile(N.path,j.loopFile))},[N?.path,n]),T=xt.useCallback(async j=>{if(d){p(j.id);try{const{sessionId:E,persistError:K}=await Yx(d,j.id);if(await Promise.all([k(d,{silent:!0}),Ka()]),K?_e.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):_e.success(t("sessions.scheduledTasks.dialog.toast.started")),E){const ee=o.find(J=>J.id===d);Ze.getState().setCurrentSession(E,ee?.path??null)}}catch(E){_e.error(E instanceof Error?E.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{p(null)}}},[d,o,k,t]),_=s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.label")}),s.jsxs(Ms,{value:d||"__none",onValueChange:j=>{const E=j==="__none"?"":j;h(E),E?k(E):g([])},children:[s.jsx(Os,{size:"lg",className:r?"w-full":void 0,children:N?s.jsx(Ns,{children:C(N)}):s.jsx(Ns,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(Bs,{children:[o.length===0?s.jsx(is,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(j=>s.jsx(is,{value:j.id,children:C(j)},j.id))]})]})]}),L=()=>{x(null),w(!0)},W=j=>{h(j),j?k(j):g([])},O=s.jsx("div",{className:"min-h-[280px]",children:b?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(M,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):m.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground",children:t(d?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:m.map(j=>{const E=v===j.id,K=j.state?.lastStatus||"idle",ee=tC[K],J=t(K==="success"?"sessions.scheduledTasks.dialog.status.success":K==="error"?"sessions.scheduledTasks.dialog.status.error":K==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),ne=j.state?.nextRunAt,ue=j.state?.lastRunAt;return s.jsxs("div",{className:Me("rounded-lg border border-border p-4 transition-opacity"),children:[s.jsxs("div",{className:Me("min-w-0",!j.enabled&&"opacity-60"),children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:j.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:Z4(j,t)}),j.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:j.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:j.loopFile})}):null]}),s.jsxs("div",{className:Me("mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",!j.enabled&&"opacity-60"),children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(M,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),ne?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:xd(ne,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:eC(ne,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(M,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),K==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(M,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):ue?s.jsxs(s.Fragment,{children:[ee.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${ee.tone})`},children:[s.jsx(M,{name:ee.Icon,className:"h-3.5 w-3.5"}),J]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:xd(ue,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),j.state?.lastError?s.jsxs("div",{className:Me("mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",!j.enabled&&"opacity-60"),style:sC("error"),children:[s.jsx(M,{name:"error-warning",className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 break-words",children:j.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:Me("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",j.enabled?"text-foreground":"text-muted-foreground",E&&"cursor-not-allowed opacity-50"),children:[s.jsx(br,{checked:j.enabled,onChange:X=>{I(j,X)},ariaLabel:j.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:j.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:j.name}),disabled:E}),j.enabled?t("sessions.scheduledTasks.dialog.taskToggle.enabled"):t("sessions.scheduledTasks.dialog.taskToggle.paused")]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(dt,{variant:"outline",size:"sm",onClick:()=>{T(j)},disabled:E,children:[s.jsx(M,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(dt,{variant:"outline",size:"sm",onClick:()=>P(j),disabled:E,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:j.name}),children:[s.jsx(M,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(dt,{variant:"destructive",size:"sm",onClick:()=>{A(j)},disabled:E,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:j.name}),children:s.jsx(M,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},j.id)})})}),$=s.jsxs("div",{className:"space-y-4",children:[_,O]});return s.jsxs(s.Fragment,{children:[r?s.jsx(Jo,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:j=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:t("sessions.scheduledTasks.dialog.title")}),j]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(dt,{className:"w-full",onClick:L,disabled:!d,children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:$}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-surface-elevated",children:s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:"flex w-60 flex-shrink-0 flex-col border-r border-border/50",children:s.jsx("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:o.length===0?s.jsx("div",{className:"px-2 py-2 typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.empty")}):o.map(j=>s.jsx("button",{type:"button",onClick:()=>W(j.id),className:Me("flex w-full min-w-0 items-center rounded-md px-2 py-1.5 text-left typography-ui-label focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",d===j.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:C(j)},j.id))})}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("div",{className:"flex items-center px-6 pt-3",children:s.jsxs(dt,{size:"sm",onClick:L,disabled:!d,children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]})}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-4",children:s.jsx("div",{className:"mx-auto w-full max-w-3xl",children:O})})]})]})}):null,s.jsx(G4,{open:S,task:f,onOpenChange:w,onSave:D})]})}const Io=100;function rC(){const t=et.c(108),{t:e}=vt(),n=De(mC),r=De(fC),i=Ze(uC),o=Ze(dC),l=os(cC);let a;t[0]!==n?(a=ne=>n?ne.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const u=_s(ir(a)),[d,h]=c.useState(""),[m,g]=c.useState(null),[b,y]=c.useState(Io);let S;t[2]!==d?(S=d.trim().toLowerCase(),t[2]=d,t[3]=S):S=t[3];const w=S;let f;e:{if(!n){let ue;t[4]===Symbol.for("react.memo_cache_sentinel")?(ue=[],t[4]=ue):ue=t[4],f=ue;break e}let ne;t[5]!==u?(ne=[...u].sort(lC),t[5]=u,t[6]=ne):ne=t[6],f=ne}const x=f;let v;if(t[7]!==l||t[8]!==x||t[9]!==e){const ne=new Map;for(const ue of x){const X=gt(Ps(ue))??"",te=ne.get(X);if(te){te.sessions.push(ue);continue}ne.set(X,{directory:X,label:X?Wn(X,l)||X:e("sessions.archivePage.otherProjects"),sessions:[ue]})}v=[...ne.values()].sort(aC),t[7]=l,t[8]=x,t[9]=e,t[10]=v}else v=t[10];const p=v;let N;e:{if(w){if(w.startsWith("ses_")){let X;if(t[11]!==w||t[12]!==x){let te;t[14]!==w?(te=fe=>fe.id.toLowerCase()===w,t[14]=w,t[15]=te):te=t[15],X=x.filter(te),t[11]=w,t[12]=x,t[13]=X}else X=t[13];N=X;break e}let ue;t[16]!==w||t[17]!==x?(ue=zg(x,w,iC),t[16]=w,t[17]=x,t[18]=ue):ue=t[18],N=ue;break e}if(m===null){N=x;break e}let ne;t[19]!==p||t[20]!==m?(ne=p.find(ue=>ue.directory===m)?.sessions??[],t[19]=p,t[20]=m,t[21]=ne):ne=t[21],N=ne}const C=N;let k,D,I,A,P,T,_,L,W,O;if(t[22]!==u.length||t[23]!==p||t[24]!==C||t[25]!==l||t[26]!==w||t[27]!==n||t[28]!==d||t[29]!==m||t[30]!==i||t[31]!==r||t[32]!==e||t[33]!==o||t[34]!==b){P=Symbol.for("react.early_return_sentinel");e:{const ne=C.slice(0,b);k=C.length-ne.length;const ue=u.length;let X;t[45]===Symbol.for("react.memo_cache_sentinel")?(X=B=>{g(B),y(Io)},t[45]=X):X=t[45];const te=X;let fe;t[46]!==i||t[47]!==r?(fe=B=>{const F=gt(Ps(B));i(B.id,F??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=fe):fe=t[48];const je=fe;let ve;t[49]!==e||t[50]!==o?(ve=B=>{o(B.id).then(F=>{F?_e.success(e("sessions.sidebar.session.restore.success")):_e.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=ve):ve=t[51];const ye=ve;if(!n){P=null;break e}let Pe;t[52]!==e?(Pe=(B,F,he,Se,Re,le,se)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:Re,title:le,className:Me("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left typography-ui-label transition-[padding] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",se?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",Se?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:F}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:he})]}),se?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>hn.requestDelete({sessions:se,mode:"session"}),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/dir:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteProjectAria",{label:F}),children:s.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},B),t[52]=e,t[53]=Pe):Pe=t[53];const xe=Pe;A="absolute inset-0 z-10 flex flex-col bg-background",D="flex min-h-0 flex-1";let R;if(t[54]!==xe||t[55]!==m||t[56]!==e||t[57]!==ue){let B;t[59]===Symbol.for("react.memo_cache_sentinel")?(B=()=>te(null),t[59]=B):B=t[59],R=xe("__all__",e("sessions.archivePage.allDirectories"),ue,m===null,B),t[54]=xe,t[55]=m,t[56]=e,t[57]=ue,t[58]=R}else R=t[58];let Y;if(t[60]!==p||t[61]!==xe||t[62]!==m){let B;t[64]!==xe||t[65]!==m?(B=F=>xe(F.directory||"__none__",F.label,F.sessions.length,m===F.directory,()=>te(F.directory),F.directory||void 0,F.sessions),t[64]=xe,t[65]=m,t[66]=B):B=t[66],Y=p.map(B),t[60]=p,t[61]=xe,t[62]=m,t[63]=Y}else Y=t[63];t[67]!==R||t[68]!==Y?(I=s.jsx("div",{className:"flex w-64 flex-shrink-0 flex-col border-r border-border/50",children:s.jsxs("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:[R,Y]})}),t[67]=R,t[68]=Y,t[69]=I):I=t[69],W="flex min-w-0 flex-1 flex-col";let ie;t[70]===Symbol.for("react.memo_cache_sentinel")?(ie=B=>{h(B),y(Io)},t[70]=ie):ie=t[70];let H;t[71]!==e?(H=e("sessions.archivePage.searchPlaceholder"),t[71]=e,t[72]=H):H=t[72];let me;t[73]!==e?(me=e("sessions.sidebar.header.search.clear"),t[73]=e,t[74]=me):me=t[74];let pe;t[75]!==d||t[76]!==H||t[77]!==me?(pe=s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(Yd,{value:d,onSearch:ie,placeholder:H,clearLabel:me})}),t[75]=d,t[76]=H,t[77]=me,t[78]=pe):pe=t[78];let re;t[79]!==C.length||t[80]!==e?(re=C.length===1?e("sessions.archivePage.countSingle",{count:C.length}):e("sessions.archivePage.countPlural",{count:C.length}),t[79]=C.length,t[80]=e,t[81]=re):re=t[81];let de;t[82]!==re?(de=s.jsx("span",{className:"flex h-8 flex-shrink-0 items-center self-start typography-micro text-muted-foreground",children:re}),t[82]=re,t[83]=de):de=t[83],t[84]!==pe||t[85]!==de?(O=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[pe,de]}),t[84]=pe,t[85]=de,t[86]=O):O=t[86],L="min-h-0 flex-1 overflow-y-auto px-6 py-3",T="mx-auto w-full max-w-3xl space-y-0.5",_=ne.length===0?s.jsx("div",{className:"py-10 text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label font-semibold",children:e(w?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):ne.map(B=>{const F=gt(Ps(B))??"",he=F?Wn(F,l)||F:null;return s.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-3 rounded-md py-1 pl-2 pr-2 transition-[padding] hover:bg-interactive-hover/40 hover:pr-14 focus-within:pr-14",onClick:()=>je(B),role:"button",tabIndex:0,onKeyDown:Se=>{(Se.key==="Enter"||Se.key===" ")&&(Se.preventDefault(),je(B))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:B.title||e("sessions.sidebar.session.untitled")}),w&&he?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:F,children:he}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Fu(B.time?.archived??B.time?.updated??B.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),ye(B)},className:"absolute right-7 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-foreground group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.restoreSessionAria",{title:B.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(M,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),hn.requestDelete({sessions:[B],mode:"session"})},className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-destructive group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteSessionAria",{title:B.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},B.id)})}t[22]=u.length,t[23]=p,t[24]=C,t[25]=l,t[26]=w,t[27]=n,t[28]=d,t[29]=m,t[30]=i,t[31]=r,t[32]=e,t[33]=o,t[34]=b,t[35]=k,t[36]=D,t[37]=I,t[38]=A,t[39]=P,t[40]=T,t[41]=_,t[42]=L,t[43]=W,t[44]=O}else k=t[35],D=t[36],I=t[37],A=t[38],P=t[39],T=t[40],_=t[41],L=t[42],W=t[43],O=t[44];if(P!==Symbol.for("react.early_return_sentinel"))return P;let $;t[87]!==k||t[88]!==e?($=k>0?s.jsx("button",{type:"button",onClick:()=>y(oC),className:"mt-1 flex items-center justify-start rounded-md px-2 py-1 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,t[87]=k,t[88]=e,t[89]=$):$=t[89];let j;t[90]!==$||t[91]!==T||t[92]!==_?(j=s.jsxs("div",{className:T,children:[_,$]}),t[90]=$,t[91]=T,t[92]=_,t[93]=j):j=t[93];let E;t[94]!==j||t[95]!==L?(E=s.jsx("div",{className:L,children:j}),t[94]=j,t[95]=L,t[96]=E):E=t[96];let K;t[97]!==E||t[98]!==W||t[99]!==O?(K=s.jsxs("div",{className:W,children:[O,E]}),t[97]=E,t[98]=W,t[99]=O,t[100]=K):K=t[100];let ee;t[101]!==D||t[102]!==I||t[103]!==K?(ee=s.jsxs("div",{className:D,children:[I,K]}),t[101]=D,t[102]=I,t[103]=K,t[104]=ee):ee=t[104];let J;return t[105]!==A||t[106]!==ee?(J=s.jsx("div",{className:A,children:ee}),t[105]=A,t[106]=ee,t[107]=J):J=t[107],J}function oC(t){return t+Io}function iC(t){return[t.title]}function aC(t,e){return e.sessions.length-t.sessions.length}function lC(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function cC(t){return t.homeDirectory}function dC(t){return t.unarchiveSession}function uC(t){return t.setCurrentSession}function fC(t){return t.setArchivePageOpen}function mC(t){return t.isArchivePageOpen}function hC(){const t=et.c(18),{t:e}=vt(),n=De(xC),r=De(gC),i=Gt(pC);let o;t[0]!==n?(o=b=>b.projects.find(y=>y.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=Gt(o);if(!n||!l)return null;let a;t[2]!==l.id||t[3]!==i||t[4]!==r?(a=()=>{i(l.id),r(!0)},t[2]=l.id,t[3]=i,t[4]=r,t[5]=a):a=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(M,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=u):u=t[6];let d;t[7]!==e?(d=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=d):d=t[8];let h;t[9]!==a||t[10]!==d?(h=s.jsx("div",{className:"flex items-center",children:s.jsxs(dt,{size:"sm",onClick:a,children:[u,d]})}),t[9]=a,t[10]=d,t[11]=h):h=t[11];let m;t[12]!==l.id||t[13]!==l.path?(m=s.jsx(zh,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=m):m=t[14];let g;return t[15]!==h||t[16]!==m?(g=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[h,m]})})}),t[15]=h,t[16]=m,t[17]=g):g=t[17],g}function pC(t){return t.setActiveProjectIdOnly}function gC(t){return t.setNewWorktreeDialogOpen}function xC(t){return t.worktreesPageProjectId}const ya=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").substring(0,50),bC=(t,e)=>{const n=ya(t),r=ya(e);return`${n}-${r}`.substring(0,60)},bd=(t,e)=>`${t}/${e}`,yC=t=>{const e=t.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},yd=(t,e)=>{const n=yC(e),r=t.directory,i=typeof r=="string"&&r.trim().length>0?t:{...t,directory:n};Yg(t.id,n),Ze.getState().markSessionAsOpenChamberCreated(t.id),_s.getState().upsertSession(i);try{Mo().ensureChild(n,{bootstrap:!1}).setState(l=>{const a=l.session.findIndex(d=>d.id===t.id);if(a>=0&&l.session[a]===i)return l;const u=a>=0?l.session.map((d,h)=>h===a?i:d):[...l.session,i].sort((d,h)=>d.id.localeCompare(h.id));return{session:u,sessionTotal:Math.max(l.sessionTotal,u.length),limit:Math.max(l.limit,u.length)}})}catch{}return i},wC=()=>{const t=Gt.getState(),e=t.activeProjectId;if(!e)return null;const n=t.projects.find(i=>i.id===e);if(n?.path)return{id:n.id,path:n.path};const r=os.getState().currentDirectory??null;if(r&&r.trim().length>0){const i=r.replace(/\\/g,"/").replace(/\/+$/,"")||r;return{id:`path:${i}`,path:i}}return null},Di=Ar()(Xu(t=>({isLoading:!1,error:null,createMultiRun:async e=>{const n=e.name.trim(),{groups:r,agent:i,files:o,setupCommands:l}=e;if(!n)return t({error:"Group name is required"}),null;if(!r||r.length===0)return t({error:"At least one run group is required"}),null;for(let a=0;a<r.length;a++){if(!r[a].prompt.trim())return t({error:`Group ${a+1}: prompt is required`}),null;if(r[a].models.length<1)return t({error:`Group ${a+1}: select at least 1 model`}),null}t({isLoading:!0,error:null});try{const a=wC();if(!a)return t({error:"Select a project",isLoading:!1}),null;const u=a.path,h=await Qo(u)&&e.isolateRuns!==!1,m=ya(n),g=h?await Zo(u):void 0,b=h?await Wg(u):null,y=[],S=l?.filter(p=>p.trim().length>0)??[];for(let p=0;p<r.length;p++){const N=r[p],C=N.prompt,k=new Map;for(const I of N.models){const A=`${I.providerID}:${I.modelID}`;k.set(A,(k.get(A)||0)+1)}const D=new Map;for(const I of N.models){const A=`${I.providerID}:${I.modelID}`,P=k.get(A)||1,T=(D.get(A)||0)+1;D.set(A,T);const _=bC(I.providerID,I.modelID),L=r.length>1?`g${p+1}`:void 0,W=P>1?bd(m,`${_}/${T}`):bd(m,_),O=L?`${L}/${W}`:W,$=O2({groupSlug:m,runGroup:L,providerID:I.providerID,modelID:I.modelID,index:P>1?T:void 0});try{if(!h){const ee=await Xs.withDirectory(u,()=>Xs.createSession({title:$}));yd(ee,u),y.push({sessionId:ee.id,worktreePath:u,providerID:I.providerID,modelID:I.modelID,variant:I.variant,prompt:C});continue}const j=await Kg(a,{preferredName:O,mode:"new",branchName:O,worktreeName:O,startRef:e.worktreeBaseBranch||"HEAD",setupCommands:S,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:b}),E={...j,createdFromBranch:g,kind:"standard"};await Vg(a)&&await Ug(j.path);const K=await Xs.withDirectory(j.path,()=>Xs.createSession({title:$}));yd(K,j.path),Ze.getState().setWorktreeMetadata(K.id,E),y.push({sessionId:K.id,worktreePath:j.path,providerID:I.providerID,modelID:I.modelID,variant:I.variant,prompt:C})}catch(j){console.warn("[MultiRun] Failed to create session:",j)}}}const w=l?.filter(p=>p.trim().length>0)??[];w.length>0&&Hg(a,w).catch(()=>{console.warn("[MultiRun] Failed to save worktree setup commands")});const f=y.map(p=>p.sessionId),x=y[0]?.sessionId??null;if(f.length===0)return t({error:"Failed to create any sessions",isLoading:!1}),null;const v=o?.map(p=>({type:"file",mime:p.mime,filename:p.filename,url:p.url}));return(async()=>{try{const p=Gg.getState().expandText;await Promise.allSettled(y.map(async N=>{try{const C=await p(N.prompt).catch(()=>N.prompt);await qg({sessionId:N.sessionId,directory:N.worktreePath,content:C,providerID:N.providerID,modelID:N.modelID,variant:N.variant,agent:i,files:v})}catch(C){console.warn("[MultiRun] Failed to start run:",C)}}))}catch(p){console.warn("[MultiRun] Failed to start runs:",p)}})(),t({isLoading:!1}),{groupSlug:m,sessionIds:f,firstSessionId:x}}catch(a){return t({error:a instanceof Error?a.message:"Failed to create Multi-Run",isLoading:!1}),null}},clearError:()=>{t({error:null})}}),{name:"multirun-store"}));function am(t){const e=et.c(30),{git:n}=Cn(),r=bu(t),i=yu(t),o=Qg(t),l=Xg(t),a=Mn(CC),u=Mn(kC);let d,h;e[0]!==t||e[1]!==u||e[2]!==n||e[3]!==i||e[4]!==o?(d=()=>{!t||!n||i!==null||o||u(t,n,{silent:!0})},h=[t,n,u,i,o],e[0]=t,e[1]=u,e[2]=n,e[3]=i,e[4]=o,e[5]=d,e[6]=h):(d=e[5],h=e[6]),c.useEffect(d,h);let m;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==i?(m=()=>{!t||!n||i===!0&&(r?.all||a(t,n))},e[7]=r?.all,e[8]=t,e[9]=a,e[10]=n,e[11]=i,e[12]=m):m=e[12];const g=r?.all;let b;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==i||e[17]!==g?(b=[t,n,i,g,a],e[13]=t,e[14]=a,e[15]=n,e[16]=i,e[17]=g,e[18]=b):b=e[18],c.useEffect(m,b);const y=o||i===!0&&l;let S;e:{if(!r?.all){let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[19]=k):k=e[19],S=k;break e}let C;e[20]!==r.all?(C=r.all.filter(jC).sort(),e[20]=r.all,e[21]=C):C=e[21],S=C}const w=S;let f;e:{if(!r?.all){let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[22]=k):k=e[22],f=k;break e}let C;e[23]!==r.all?(C=r.all.filter(SC).map(vC).sort(),e[23]=r.all,e[24]=C):C=e[24],f=C}const x=f;let v;e:{if(!t){v=null;break e}if(i!==null){v=i;break e}if(y){v=null;break e}v=r?.all?!0:null}const p=v;let N;return e[25]!==p||e[26]!==y||e[27]!==w||e[28]!==x?(N={localBranches:w,remoteBranches:x,isLoading:y,isGitRepository:p},e[25]=p,e[26]=y,e[27]=w,e[28]=x,e[29]=N):N=e[29],N}function vC(t){return t.replace(/^remotes\//,"")}function SC(t){return t.startsWith("remotes/")}function jC(t){return!t.startsWith("remotes/")}function kC(t){return t.fetchStatus}function CC(t){return t.fetchBranches}const NC=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=vt(),{localBranches:a,remoteBranches:u,isLoading:d,isGitRepository:h}=am(t),m=c.useMemo(()=>[...a,...u.map(b=>`remotes/${b}`)],[a,u]);c.useEffect(()=>{if(i||d||m.length===0||e&&m.includes(e))return;const b=e;let y=!1;return(async()=>{try{const w=t?await Zo(t).catch(()=>null):null;if(y)return;const f=localStorage.getItem(vl),{sourceBranch:x,shouldClearSavedSourceBranch:v}=Wh({branches:m,savedSourceBranch:f,rootBranch:w});if(v&&localStorage.removeItem(vl),y||b&&m.includes(b))return;x&&n(x)}catch{}})(),()=>{y=!0}},[m,t,i,d,n,e]);const g=i||!h||d;return s.jsxs("div",{children:[s.jsxs(Ms,{value:e,onValueChange:n,disabled:g,children:[s.jsx(Os,{id:o,size:"lg",className:Me("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(Ns,{placeholder:l(d?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(Bs,{className:"max-h-[280px] max-w-[320px]",children:d?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.loadingBranches")}):a.length===0&&u.length===0?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[a.length>0&&s.jsxs(Hi,{children:[s.jsx(_l,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.localBranches")}),a.map(b=>s.jsx(is,{value:b,className:"whitespace-normal break-all",children:b},b))]}),a.length>0&&u.length>0&&s.jsx(Jg,{}),u.length>0&&s.jsxs(Hi,{children:[s.jsx(_l,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.remoteBranches")}),u.map(b=>s.jsx(is,{value:`remotes/${b}`,className:"whitespace-normal break-all",children:b},`remotes/${b}`))]})]})})]}),h===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:l("multiRun.branchSelector.status.notInGitRepository")})]})},AC=10*1024*1024,To=t=>{const e=et.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",tabIndex:-1,className:"inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors",children:s.jsx(M,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let i;return e[1]!==n?(i=s.jsxs(Dt,{children:[r,s.jsx(It,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=i):i=e[2],i},Zn=t=>{const e=et.c(9),{htmlFor:n,required:r,children:i,info:o}=t;let l;e[0]!==r?(l=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=l):l=e[1];let a;e[2]!==i||e[3]!==n||e[4]!==l?(a=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,l]}),e[2]=i,e[3]=n,e[4]=l,e[5]=a):a=e[5];const u=o&&o;let d;return e[6]!==a||e[7]!==u?(d=s.jsxs("div",{className:"flex items-center gap-1.5",children:[a,u]}),e[6]=a,e[7]=u,e[8]=d):d=e[8],d},DC=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:i}=vt(),[o,l]=c.useState(""),[a,u]=c.useState(()=>[{id:qr(),prompt:"",models:[]}]),[d,h]=c.useState(""),[m,g]=c.useState([]),[b,y]=c.useState(!1),[S,w]=c.useState([]),[f,x]=c.useState(!1),[v,p]=c.useState(!1),[N,C]=c.useState(!0),k=c.useRef(null),D=os(q=>q.currentDirectory??null),I=os(q=>q.homeDirectory??null),A=c.useMemo(()=>{if(typeof window>"u")return null;const q=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof q=="string"&&q.trim().length>0?q.trim():null},[]),P=Gt(q=>q.activeProjectId),T=Gt(q=>q.setActiveProjectIdOnly),_=Gt(q=>q.projects),[L,W]=c.useState(()=>P??null);c.useEffect(()=>{if(P){W(P);return}!L&&_.length>0&&W(_[0].id)},[P,_,L]);const O=c.useMemo(()=>L?_.find(q=>q.id===L)??null:null,[_,L]),$=O?.path??D,j=c.useCallback(q=>{W(q),q!==P&&T(q)},[P,T]),{currentTheme:E}=ar(),K=c.useCallback(q=>{const z=q.label?.trim()||Wn(q.path,I),ae=q.icon?$a[q.icon]:null,ce=q.color?za[q.color]:void 0,Ne=ae?s.jsx(M,{name:ae,className:"h-3.5 w-3.5 shrink-0",style:ce?{color:ce}:void 0}):s.jsx(M,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:ce?{color:ce}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[q.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:q.iconBackground?{backgroundColor:q.iconBackground}:void 0,children:s.jsx(Wa,{project:{id:q.id,iconImage:q.iconImage??null},options:{themeVariant:E.metadata.variant,iconColor:E.colors.surface.foreground},className:"h-full w-full object-contain",fallback:Ne})}):Ne,s.jsx("span",{className:"truncate",children:z})]})},[I,E.metadata.variant,E.colors.surface.foreground]),ee=c.useMemo(()=>{if(O?.path)return{id:O.id,path:O.path};const q=D??A;return q?{id:`path:${q}`,path:q}:null},[O,D,A]),[J]=c.useState(()=>typeof window<"u"?vn():!1),ne=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),ue=ou(),X=c.useMemo(()=>{if(typeof window>"u")return null;const q=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof q=="number"&&Number.isFinite(q)&&q>0)return q;if(typeof navigator>"u")return null;const z=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!z)return null;const ae=Number.parseInt(z[1],10),ce=Number.parseInt(z[2],10);return Number.isNaN(ae)?null:ae===10?ce:ae},[]),te=c.useMemo(()=>J&&ne||ue?"pl-[88px]":"pl-3",[J,ne,ue]),fe=c.useMemo(()=>!J||!ne||X===null?"":X>=26?"h-12":X<=15?"h-14":"",[J,ne,X]),je=c.useCallback(async q=>{q.target.closest("button, a, input, select, textarea")||q.button===0&&J&&await Zg()},[J]);c.useEffect(()=>{if(!n)return;const q=z=>{z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),n())};return window.addEventListener("keydown",q,!0),()=>window.removeEventListener("keydown",q,!0)},[n]);const[ve,ye]=c.useState(""),{isLoading:Pe,isGitRepository:xe}=am($),R=c.useRef(!1),Y=xe===!0,ie=Y&&N;c.useEffect(()=>{if(xe===!1){R.current=!0,C(!1);return}xe===!0&&R.current&&(R.current=!1,C(!0))},[xe]);const H=Di(q=>q.createMultiRun),me=Di(q=>q.error),pe=Di(q=>q.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&u(q=>{const z=[...q];return z.length>0&&!z[0].prompt.trim()&&(z[0]={...z[0],prompt:t}),z})},[t]),c.useEffect(()=>{if(!ee)return;let q=!1;return p(!0),(async()=>{try{const z=await ex(ee);q||w(z)}catch{}finally{q||p(!1)}})(),()=>{q=!0}},[ee]);const re=c.useCallback((q,z)=>{u(ae=>ae.map(ce=>ce.id===q?{...ce,...z}:ce))},[]),de=c.useCallback(q=>{u(z=>z.filter(ae=>ae.id!==q))},[]),B=c.useCallback(()=>{u(q=>[...q,{id:qr(),prompt:"",models:[]}])},[]),F=async q=>{const z=q.target.files;if(!z)return;let ae=0;for(let ce=0;ce<z.length;ce++){const Ne=z[ce];if(Ne.size>AC){_e.error(i("multirun.launcher.toast.fileTooLarge",{fileName:Ne.name}));continue}try{const we=await new Promise(($e,Oe)=>{const ge=new FileReader;ge.onload=()=>$e(ge.result),ge.onerror=Oe,ge.readAsDataURL(Ne)});g($e=>[...$e,{id:qr(),filename:Ne.name,mimeType:Ne.type||"application/octet-stream",size:Ne.size,dataUrl:we}]),ae++}catch(we){console.error("File attach failed",we),_e.error(i("multirun.launcher.toast.attachFailed",{fileName:Ne.name}))}}ae>0&&_e.success(ae===1?i("multirun.launcher.toast.attachedSingle",{count:ae}):i("multirun.launcher.toast.attachedPlural",{count:ae})),k.current&&(k.current.value="")},he=q=>{g(z=>z.filter(ae=>ae.id!==q))},Se=c.useMemo(()=>a.reduce((q,z)=>q+z.models.length,0),[a]),Re=async q=>{q.preventDefault();const z=a.filter(ae=>ae.prompt.trim()&&ae.models.length>=1);if(z.length!==0&&!(Se<1)){y(!0),pe();try{L&&L!==P&&T(L);const ae=m.map(Oe=>({mime:Oe.mimeType,filename:Oe.filename,url:Oe.dataUrl})),ce=S.filter(Oe=>Oe.trim().length>0),Ne=z.map(Oe=>({prompt:Oe.prompt.trim(),models:Oe.models.map(ge=>({providerID:ge.providerID,modelID:ge.modelID,displayName:ge.displayName,variant:ge.variant}))})),we={name:o.trim(),groups:Ne,agent:d||void 0,worktreeBaseBranch:ie?ve:void 0,isolateRuns:ie,files:ae.length>0?ae:void 0,setupCommands:ce.length>0?ce:void 0},$e=await H(we);$e&&($e.firstSessionId&&Ze.getState().setCurrentSession($e.firstSessionId),e?.())}finally{y(!1)}}},le=!!(o.trim()&&a.some(q=>q.prompt.trim()&&q.models.length>=1)&&Se>=1&&$&&!Pe&&(xe===!1||!ie||ve)),se=S.filter(q=>q.trim()).length;return s.jsxs("form",{onSubmit:Re,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:je,className:Me("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",te,fe),style:{borderColor:"var(--interactive-border)"},children:[s.jsx("h1",{className:"typography-ui-label font-medium",children:i("multirun.launcher.title")}),n&&s.jsx("div",{className:"absolute right-0 flex items-center pr-3",children:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":i("multirun.launcher.actions.closeEsc"),className:"inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring app-region-no-drag",children:s.jsx(M,{name:"close",className:"h-5 w-5"})})}),s.jsx(It,{children:s.jsx("p",{children:i("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(Ia,{className:"flex-1 min-h-0 overflow-auto",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 py-5",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Zn,{htmlFor:"multirun-project",required:!0,children:i("multirun.launcher.project.label")}),_.length>0?s.jsxs(Ms,{value:L??void 0,onValueChange:j,children:[s.jsx(Os,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:O?s.jsx(Ns,{children:K(O)}):s.jsx(Ns,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(Bs,{fitContent:!0,children:_.map(q=>s.jsx(is,{value:q.id,className:"max-w-[24rem]",children:K(q)},q.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:i("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Zn,{htmlFor:"group-name",required:!0,info:s.jsx(To,{children:i("multirun.launcher.groupName.info")}),children:i("multirun.launcher.groupName.label")}),s.jsx(In,{id:"group-name",value:o,onChange:q=>l(q.target.value),placeholder:i("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Zn,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(To,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx(NC,{directory:$,value:ve,onChange:ye,disabled:!ie,id:"multirun-worktree-base-branch"}),s.jsxs("label",{className:"mt-1.5 flex w-fit items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(br,{checked:N,onChange:C,disabled:!Y,ariaLabel:i("multirun.launcher.isolateRuns.label")}),s.jsx("span",{children:i("multirun.launcher.isolateRuns.label")})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Zn,{htmlFor:"multirun-agent",info:s.jsx(To,{children:i("multirun.launcher.agent.info")}),children:i("multirun.launcher.agent.label")}),s.jsx(Qf,{value:d,onChange:h,id:"multirun-agent"})]})]}),s.jsxs($i,{open:f,onOpenChange:x,children:[s.jsxs(xu,{className:"w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group",children:[s.jsx(M,{name:"terminal",className:"h-3.5 w-3.5 text-muted-foreground/70"}),s.jsx("span",{className:"typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors",children:i("multirun.launcher.setupCommands.label")}),se>0&&s.jsx("span",{className:"inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium",style:{backgroundColor:"var(--primary-base)",color:"var(--primary-foreground)",fontSize:"0.625rem",lineHeight:1},children:se}),s.jsx(M,{name:"arrow-down-s",className:Me("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",f&&"rotate-180")})]}),s.jsx(zi,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:v?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:i("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[S.map((q,z)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(In,{value:q,onChange:ae=>{const ce=[...S];ce[z]=ae.target.value,w(ce)},placeholder:i("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>w(S.filter((ae,ce)=>ce!==z)),className:"flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]},`${q}-${z}`)),s.jsxs("button",{type:"button",onClick:()=>w([...S,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(M,{name:"add",className:"h-3 w-3"}),i("multirun.launcher.setupCommands.addCommand")]})]})})})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Zn,{htmlFor:"prompt",required:!0,children:i("multirun.launcher.attachments.label")}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("input",{ref:k,type:"file",multiple:!0,className:"hidden",onChange:F,accept:"*/*"}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>k.current?.click(),className:"inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(M,{name:"attachment-2",className:"h-3 w-3"}),i("multirun.launcher.attachments.attach")]})}),s.jsx(It,{children:i("multirun.launcher.attachments.tooltip")})]}),m.map(q=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border",style:{backgroundColor:"var(--surface-elevated)",borderColor:"var(--interactive-border)"},children:[q.mimeType.startsWith("image/")?s.jsx(M,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(M,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:q.filename,children:q.filename}),s.jsx("button",{type:"button",onClick:()=>he(q.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(M,{name:"close",className:"h-3 w-3"})})]},q.id))]})]}),a.map((q,z)=>s.jsx(PC,{group:q,groupIndex:z,canRemove:a.length>1,onUpdate:re,onRemove:de},q.id)),s.jsxs("button",{type:"button",onClick:B,className:"flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),i("multirun.launcher.groups.addGroup")]}),me&&s.jsx("div",{className:"px-3 py-2 rounded-lg typography-meta",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderWidth:1,borderColor:"var(--status-error-border)"},children:me})]})})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl flex items-center justify-end gap-2",children:[!ie&&xe!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(M,{name:"information",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:i("multirun.launcher.project.gitRequired")})]}):null,!r&&n?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:n,children:i("multirun.launcher.actions.cancel")}):null,s.jsx(dt,{type:"submit",size:"sm",disabled:!le||b,children:b?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:Se})})})]})})]})},PC=t=>{const e=et.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=vt(),[u,d]=c.useState(!1),[h,m]=c.useState(""),[g,b]=c.useState(!1),[y,S]=c.useState(""),[w,f]=c.useState(!1),[x,v]=c.useState(""),p=c.useRef(null),N=c.useRef(null),C=c.useRef(null),k=c.useRef(null);let D;e[0]!==n.id||e[1]!==n.models||e[2]!==o?(D=ce=>{o(n.id,{models:[...n.models,ce]})},e[0]=n.id,e[1]=n.models,e[2]=o,e[3]=D):D=e[3];const I=D;let A;e[4]!==n.id||e[5]!==n.models||e[6]!==o?(A=ce=>{o(n.id,{models:n.models.filter((Ne,we)=>we!==ce)})},e[4]=n.id,e[5]=n.models,e[6]=o,e[7]=A):A=e[7];const P=A;let T;e[8]!==n.id||e[9]!==n.models||e[10]!==o?(T=(ce,Ne)=>{o(n.id,{models:n.models.map((we,$e)=>$e===ce?Ne:we)})},e[8]=n.id,e[9]=n.models,e[10]=o,e[11]=T):T=e[11];const _=T;let L;e[12]===Symbol.for("react.memo_cache_sentinel")?(L=(ce,Ne)=>{if(ce.startsWith("/")){const ge=ce.indexOf(" "),He=ce.indexOf(`
893
- `),V=Math.min(ge===-1?ce.length:ge,He===-1?ce.length:He);if(Ne<=V&&ge===-1){S(ce.substring(1,V)),b(!0),d(!1),f(!1);return}}b(!1);const we=ce.substring(0,Ne),$e=we.lastIndexOf("#");if($e!==-1){const ge=$e>0?we[$e-1]:null,He=we.substring($e+1);if((!ge||/\s/.test(ge))&&!He.includes(" ")&&!He.includes(`
894
- `)){v(He),f(!0),d(!1);return}}f(!1);const Oe=we.lastIndexOf("@");if(Oe!==-1){const ge=Oe>0?we[Oe-1]:null,He=we.substring(Oe+1);(!ge||/\s/.test(ge))&&!He.includes(" ")&&!He.includes(`
895
- `)?(m(He),d(!0)):d(!1);return}d(!1)},e[12]=L):L=e[12];const W=L;let O;e[13]!==n.id||e[14]!==o?(O=ce=>{o(n.id,{prompt:ce})},e[13]=n.id,e[14]=o,e[15]=O):O=e[15];const $=O;let j;e[16]!==n.prompt||e[17]!==$?(j=ce=>{const Ne=n.prompt,$e=p.current?.selectionStart??Ne.length,ge=Ne.substring(0,$e).lastIndexOf("@"),He=ce.relativePath&&ce.relativePath.trim().length>0?ce.relativePath.trim():ce.path||ce.name,V=ge!==-1?ge:$e,Ae=`${Ne.substring(0,V)}@${He} ${Ne.substring($e)}`,Ie=V+He.length+2;$(Ae),d(!1),m(""),requestAnimationFrame(()=>{const Fe=p.current;Fe&&(Fe.selectionStart=Ie,Fe.selectionEnd=Ie,Fe.focus()),W(Ae,Ie)})},e[16]=n.prompt,e[17]=$,e[18]=j):j=e[18];const E=j;let K;e[19]!==n.prompt||e[20]!==$?(K=ce=>{const Ne=n.prompt,$e=p.current?.selectionStart??Ne.length,ge=Ne.substring(0,$e).lastIndexOf("@"),He=ge!==-1?ge:$e,V=`${Ne.substring(0,He)}@${ce} ${Ne.substring($e)}`,Ae=He+ce.length+2;$(V),d(!1),m(""),requestAnimationFrame(()=>{const Ie=p.current;Ie&&(Ie.selectionStart=Ae,Ie.selectionEnd=Ae,Ie.focus()),W(V,Ae)})},e[19]=n.prompt,e[20]=$,e[21]=K):K=e[21];const ee=K;let J;e[22]!==$?(J=ce=>{const Ne=`/${ce.name} `;$(Ne),b(!1),S(""),f(!1),requestAnimationFrame(()=>{const we=p.current;we&&(we.focus(),we.selectionStart=we.value.length,we.selectionEnd=we.value.length),W(Ne,Ne.length)})},e[22]=$,e[23]=J):J=e[23];const ne=J;let ue;e[24]!==n.prompt||e[25]!==$?(ue=(ce,Ne)=>{const we=n.prompt,Oe=p.current?.selectionStart??we.length,He=we.substring(0,Oe).lastIndexOf("#"),V=He!==-1?He:Oe,Ae=`${we.substring(0,V)}#${Ne} ${we.substring(Oe)}`,Ie=V+Ne.length+2;$(Ae),f(!1),v(""),requestAnimationFrame(()=>{const Fe=p.current;Fe&&(Fe.selectionStart=Ie,Fe.selectionEnd=Ie,Fe.focus()),W(Ae,Ie)})},e[24]=n.prompt,e[25]=$,e[26]=ue):ue=e[26];const X=ue;let te;e[27]!==g||e[28]!==u||e[29]!==w?(te=ce=>{if(g&&C.current&&(ce.key==="Enter"||ce.key==="ArrowUp"||ce.key==="ArrowDown"||ce.key==="Escape"||ce.key==="Tab")){ce.preventDefault(),C.current.handleKeyDown(ce.key);return}u&&N.current&&(ce.key==="Enter"||ce.key==="ArrowUp"||ce.key==="ArrowDown"||ce.key==="Escape"||ce.key==="Tab")&&(ce.preventDefault(),N.current.handleKeyDown(ce.key)),w&&k.current&&(ce.key==="Enter"||ce.key==="ArrowUp"||ce.key==="ArrowDown"||ce.key==="Escape"||ce.key==="Tab")&&(ce.preventDefault(),k.current.handleKeyDown(ce.key))},e[27]=g,e[28]=u,e[29]=w,e[30]=te):te=e[30];const fe=te,je=r+1;let ve;e[31]!==a||e[32]!==je?(ve=a("multirun.launcher.groups.groupLabel",{index:je}),e[31]=a,e[32]=je,e[33]=ve):ve=e[33];let ye;e[34]!==ve?(ye=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:ve}),e[34]=ve,e[35]=ye):ye=e[35];let Pe;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(Pe=i&&s.jsx("button",{type:"button",onClick:()=>l(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":a("multirun.launcher.groups.removeGroup"),children:s.jsx(M,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=Pe):Pe=e[40];let xe;e[41]!==ye||e[42]!==Pe?(xe=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ye,Pe]}),e[41]=ye,e[42]=Pe,e[43]=xe):xe=e[43];let R;e[44]!==a?(R=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=R):R=e[45];let Y;e[46]!==R?(Y=s.jsx(Zn,{required:!0,children:R}),e[46]=R,e[47]=Y):Y=e[47];const ie=n.prompt;let H;e[48]!==$?(H=ce=>{const Ne=ce.target.value;$(Ne);const we=ce.target.selectionStart??Ne.length;W(Ne,we)},e[48]=$,e[49]=H):H=e[49];let me;e[50]!==a?(me=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=me):me=e[51];let pe;e[52]!==n.prompt||e[53]!==fe||e[54]!==H||e[55]!==me?(pe=s.jsx(pr,{ref:p,value:ie,onChange:H,onKeyDown:fe,placeholder:me,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=fe,e[54]=H,e[55]=me,e[56]=pe):pe=e[56];let re;e[57]!==y||e[58]!==ne||e[59]!==g?(re=g?s.jsx(_u,{ref:C,searchQuery:y,onCommandSelect:ne,onClose:()=>b(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=y,e[58]=ne,e[59]=g,e[60]=re):re=e[60];let de;e[61]!==ee||e[62]!==E||e[63]!==h||e[64]!==u?(de=u?s.jsx(Lu,{ref:N,searchQuery:h,onFileSelect:E,onAgentSelect:ee,onClose:()=>d(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=ee,e[62]=E,e[63]=h,e[64]=u,e[65]=de):de=e[65];let B;e[66]!==X||e[67]!==w||e[68]!==x?(B=w?s.jsx($u,{ref:k,searchQuery:x,onSnippetSelect:X,onClose:()=>f(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=X,e[67]=w,e[68]=x,e[69]=B):B=e[69];let F;e[70]!==pe||e[71]!==re||e[72]!==de||e[73]!==B?(F=s.jsxs("div",{className:"relative",children:[pe,re,de,B]}),e[70]=pe,e[71]=re,e[72]=de,e[73]=B,e[74]=F):F=e[74];let he;e[75]!==Y||e[76]!==F?(he=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[Y,F]}),e[75]=Y,e[76]=F,e[77]=he):he=e[77];let Se;e[78]!==a?(Se=a("multirun.launcher.models.info"),e[78]=a,e[79]=Se):Se=e[79];let Re;e[80]!==Se?(Re=s.jsx(To,{children:Se}),e[80]=Se,e[81]=Re):Re=e[81];let le;e[82]!==a?(le=a("multirun.launcher.models.label"),e[82]=a,e[83]=le):le=e[83];let se;e[84]!==Re||e[85]!==le?(se=s.jsx(Zn,{required:!0,info:Re,children:le}),e[84]=Re,e[85]=le,e[86]=se):se=e[86];let q;e[87]!==n.models||e[88]!==I||e[89]!==P||e[90]!==_?(q=s.jsx(Xf,{selectedModels:n.models,onAdd:I,onRemove:P,onUpdate:_,minModels:1}),e[87]=n.models,e[88]=I,e[89]=P,e[90]=_,e[91]=q):q=e[91];let z;e[92]!==se||e[93]!==q?(z=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[se,q]}),e[92]=se,e[93]=q,e[94]=z):z=e[94];let ae;return e[95]!==xe||e[96]!==he||e[97]!==z?(ae=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[xe,he,z]}),e[95]=xe,e[96]=he,e[97]=z,e[98]=ae):ae=e[98],ae},IC=t=>{const e=new Map;for(const n of t){const r=Ps(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},TC=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},EC=t=>{const e=et.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,u;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const d=as(),h=IC(i),m=l.current?.runtimeKey===d?l.current.identities:null;for(const g of TC(m,h))tx({runtimeKey:d,...g});l.current={runtimeKey:d,identities:h}},u=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=u):(a=e[3],u=e[4]),c.useEffect(a,u)},RC=new Map,MC=t=>{const e=et.c(26),{isVSCode:n}=t,r=ei(),i=Gt(OC),o=Gt(BC),l=os(FC),a=Ze(_C);let u;e[0]!==n?(u=A=>n?RC:A.availableWorktreesByProject,e[0]=n,e[1]=u):u=e[1];const d=Ze(u),h=!n;let m;e[2]!==d||e[3]!==i||e[4]!==h?(m=rm(i,d,{includeWorktrees:h}),e[2]=d,e[3]=i,e[4]=h,e[5]=m):m=e[5];const g=m,b=_s(LC),y=_s($C),S=_s(zC),w=`session-list-sync:${c.useId()}`;let f,x;e[6]!==o||e[7]!==w||e[8]!==r||e[9]!==l||e[10]!==a||e[11]!==g||e[12]!==i?(f=()=>(r.setBootstrapDemand(w,Lf({knownDirectories:g,activeProjectDirectory:gt(i.find(A=>A.id===o)?.path??null),activeProjectId:o,collapsedProjects:new Set,collapsedGroups:new Set,currentDirectory:l,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(w)),x=[o,w,r,l,a,g,i],e[6]=o,e[7]=w,e[8]=r,e[9]=l,e[10]=a,e[11]=g,e[12]=i,e[13]=f,e[14]=x):(f=e[13],x=e[14]),c.useEffect(f,x);const v=c.useRef(null);let p,N;e[15]!==n||e[16]!==g?(p=()=>{const A=new Set(g),P=v.current;v.current=A;const T=P?[...A].filter(_=>!P.has(_)):n?[...A]:[];T.length&&Aa(T,Oo())},N=[n,g],e[15]=n,e[16]=g,e[17]=p,e[18]=N):(p=e[17],N=e[18]),c.useEffect(p,N);let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[19]=C):C=e[19],c.useEffect(WC,C);let k;e[20]!==y||e[21]!==b?(k=[...b,...y],e[20]=y,e[21]=b,e[22]=k):k=e[22];const D=k;let I;e[23]!==D||e[24]!==S?(I={enabled:!0,hasAuthoritativeGlobalSessions:S,sessions:D},e[23]=D,e[24]=S,e[25]=I):I=e[25],EC(I)};function OC(t){return t.projects}function BC(t){return t.activeProjectId}function FC(t){return t.currentDirectory}function _C(t){return t.currentSessionDirectory}function LC(t){return t.activeSessions}function $C(t){return t.archivedSessions}function zC(t){return t.status==="ready"}function WC(){let t=null,e=!1;const n=new Set,r=ro(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")n.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),Ka(Oo());return}const o=[...n];n.clear(),o.length&&Aa(o,Oo())},500)});return()=>{t&&clearTimeout(t),r()}}const KC=Un(()=>On(()=>import("./SettingsWindow-HVDVANjJ.js"),__vite__mapDeps([142,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,143,84,85,86,144,129,130,131,132,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,145,146,147])).then(t=>({default:t.SettingsWindow}))),VC=()=>{const t=et.c(72);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],MC(e),Kh();const n=De(UC),r=De(HC),i=De(GC),o=De(qC),[l,a]=c.useState(!1);let u,d;t[1]!==i?(u=()=>{i&&a(!0)},d=[i],t[1]=i,t[2]=u,t[3]=d):(u=t[2],d=t[3]),c.useEffect(u,d);const h=De(YC),m=De(QC),g=De(XC),b=De(JC),y=De(ZC),S=De(e5),w=De(t5),f=Pu();let x;if(t[4]!==f||t[5]!==w){let F;t[7]!==w?(F=he=>he.id===w,t[7]=w,t[8]=F):F=t[8],x=f.find(F),t[4]=f,t[5]=w,t[6]=x}else x=t[6];const v=x;let p,N;t[9]!==v||t[10]!==w?(p=()=>{w&&!v&&De.getState().setOpenGuestPage(null)},N=[w,v],t[9]=v,t[10]=w,t[11]=p,t[12]=N):(p=t[11],N=t[12]),c.useEffect(p,N);let C;t[13]===Symbol.for("react.memo_cache_sentinel")?(C=[],t[13]=C):C=t[13],c.useEffect(n5,C);const k=b||y||!!S||h||!!v;let D;t[14]===Symbol.for("react.memo_cache_sentinel")?(D=[],t[14]=D):D=t[14],c.useEffect(o5,D);const{isMobile:I}=Vn();Vh();const A=ly();let P,T;t[15]!==I||t[16]!==r?(P=()=>{De.getState().isMobile!==I&&r(I)},T=[I,r],t[15]=I,t[16]=r,t[17]=P,t[18]=T):(P=t[17],T=t[18]),c.useEffect(P,T);let _,L,W,O;t[19]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(qS,{}),L=s.jsx(U0,{}),W=s.jsx(Y0,{}),O=s.jsx(P4,{}),t[19]=_,t[20]=L,t[21]=W,t[22]=O):(_=t[19],L=t[20],W=t[21],O=t[22]);let $;t[23]!==A?($=s.jsx(I4,{value:A,onMoveSessionOnly:i5,onMoveAllChanges:a5,onCancel:xy}),t[23]=A,t[24]=$):$=t[24];let j;t[25]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(Cy,{}),t[25]=j):j=t[25];let E;t[26]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(ky,{}),t[26]=E):E=t[26];let K;t[27]!==n?(K=s.jsx(D4,{isVisible:n}),t[27]=n,t[28]=K):K=t[28];let ee;t[29]!==I||t[30]!==n||t[31]!==K?(ee=s.jsx(jy,{isOpen:n,isMobile:I,className:"border-border",topBar:E,children:K}),t[29]=I,t[30]=n,t[31]=K,t[32]=ee):ee=t[32];let J;t[33]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(vy,{}),t[33]=J):J=t[33];const ne=k&&"invisible";let ue;t[34]!==ne?(ue=Me("absolute inset-0",ne),t[34]=ne,t[35]=ue):ue=t[35];const X=!i&&!k;let te;t[36]!==X?(te=s.jsx(Ds,{children:s.jsx(Qd,{active:X})}),t[36]=X,t[37]=te):te=t[37];let fe;t[38]!==ue||t[39]!==te?(fe=s.jsx("div",{className:ue,children:te}),t[38]=ue,t[39]=te,t[40]=fe):fe=t[40];let je;t[41]!==h||t[42]!==g||t[43]!==m?(je=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Ds,{children:s.jsx(DC,{isWindowed:!0,initialPrompt:g,onCreated:()=>m(!1),onCancel:()=>m(!1)})})}),t[41]=h,t[42]=g,t[43]=m,t[44]=je):je=t[44];let ve;t[45]===Symbol.for("react.memo_cache_sentinel")?(ve=s.jsx(Ds,{children:s.jsx(nC,{})}),t[45]=ve):ve=t[45];let ye;t[46]===Symbol.for("react.memo_cache_sentinel")?(ye=s.jsx(Ds,{children:s.jsx(rC,{})}),t[46]=ye):ye=t[46];let Pe;t[47]===Symbol.for("react.memo_cache_sentinel")?(Pe=s.jsx(Ds,{children:s.jsx(hC,{})}),t[47]=Pe):Pe=t[47];let xe;t[48]!==v?(xe=v&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Ds,{children:s.jsx(fb,{mode:`plugin:${v.id}`,surface:"page",item:null,onDismiss:l5})})}),t[48]=v,t[49]=xe):xe=t[49];let R;t[50]!==fe||t[51]!==je||t[52]!==xe?(R=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[fe,je,ve,ye,Pe,xe]}),t[50]=fe,t[51]=je,t[52]=xe,t[53]=R):R=t[53];let Y;t[54]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(gS,{}),t[54]=Y):Y=t[54];let ie;t[55]!==R?(ie=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[R,Y]})})}),t[55]=R,t[56]=ie):ie=t[56];let H;t[57]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(Ds,{children:s.jsx(NS,{})})}),t[57]=H):H=t[57];let me;t[58]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(Ds,{children:s.jsx(Lx,{})}),t[58]=me):me=t[58];let pe;t[59]!==ie?(pe=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[J,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[ie,H,me]})]}),t[59]=ie,t[60]=pe):pe=t[60];let re;t[61]!==ee||t[62]!==pe?(re=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[ee,pe]}),t[61]=ee,t[62]=pe,t[63]=re):re=t[63];let de;t[64]!==i||t[65]!==o||t[66]!==l?(de=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(KC,{open:i,onOpenChange:o})}):null,t[64]=i,t[65]=o,t[66]=l,t[67]=de):de=t[67];let B;return t[68]!==$||t[69]!==re||t[70]!==de?(B=s.jsx(Uh,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[_,L,W,O,$,j,re,de]})}),t[68]=$,t[69]=re,t[70]=de,t[71]=B):B=t[71],B};function UC(t){return t.isSidebarOpen}function HC(t){return t.setIsMobile}function GC(t){return t.isSettingsDialogOpen}function qC(t){return t.setSettingsDialogOpen}function YC(t){return t.isMultiRunLauncherOpen}function QC(t){return t.setMultiRunLauncherOpen}function XC(t){return t.multiRunLauncherPrefillPrompt}function JC(t){return t.isScheduledTasksDialogOpen}function ZC(t){return t.isArchivePageOpen}function e5(t){return t.worktreesPageProjectId}function t5(t){return t.openGuestPageId}function s5(){return De.getState().setOpenGuestPage(null)}function n5(){return eo(s5)}function r5(){return De.getState().closeMainSurfaces()}function o5(){const t=r5,e=Ze.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function i5(){return df(!1)}function a5(){return df(!0)}function l5(){return De.getState().setOpenGuestPage(null)}const lm=12,c5=[{id:"left",x:22,y:58,delay:0,radius:120,colorVar:"--status-success"},{id:"center",x:50,y:42,delay:120,radius:150,colorVar:"--primary-base"},{id:"right",x:78,y:55,delay:200,radius:130,colorVar:"--status-info"}],d5=t=>{const e=et.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,u=r===void 0?0:r,d=o===void 0?900:o,h=l===void 0?c5:l,m=xt.useRef(!1);let g,b;e[0]!==n||e[1]!==a?(g=()=>{!n&&m.current&&a?.(),n&&(m.current=!0)},b=[n,a],e[0]=n,e[1]=a,e[2]=g,e[3]=b):(g=e[2],b=e[3]),xt.useEffect(g,b);let y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y=Array.from({length:lm},u5),e[4]=y):y=e[4];const S=y;if(!n)return null;let w;e[5]!==i?(w=Me("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=w):w=e[6];let f;if(e[7]!==u||e[8]!==h||e[9]!==d){let v;e[11]!==u||e[12]!==d?(v=p=>{const N={"--burst-delay":`${p.delay}ms`,"--burst-x":`${p.x}%`,"--burst-y":`${p.y}%`,"--firework-color":`var(${p.colorVar})`,"--firework-duration":`${d}ms`};return s.jsx("div",{className:"firework-burst",style:N,children:S.map((C,k)=>{const D=C.x*p.radius,I=C.y*p.radius,A={"--translate-x":`${D}px`,"--translate-y":`${I}px`,"--particle-delay":`${C.delay}ms`,color:`var(${p.colorVar})`};return s.jsx("span",{className:"firework-particle",style:A},`${p.id}-${k}-${u}`)})},`${p.id}-${u}`)},e[11]=u,e[12]=d,e[13]=v):v=e[13],f=h.map(v),e[7]=u,e[8]=h,e[9]=d,e[10]=f}else f=e[10];let x;return e[14]!==u||e[15]!==w||e[16]!==f?(x=s.jsx("div",{className:w,"aria-hidden":"true","data-burst-key":u,children:f}),e[14]=u,e[15]=w,e[16]=f,e[17]=x):x=e[17],x};function u5(t,e){const n=Math.PI*2*e/lm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const f5=t=>{const e=et.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=xt.useState(o),u=xt.useRef(null);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{u.current&&(window.clearTimeout(u.current),u.current=null)},e[3]=d):d=e[3];const h=d;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{h(),a(m5)},e[4]=m):m=e[4];const g=m;let b;e[5]!==i?(b=()=>{h(),a(h5),u.current=window.setTimeout(()=>{a(p5),u.current=null},i)},e[5]=i,e[6]=b):b=e[6];const y=b;let S,w;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=()=>()=>h(),w=[h],e[7]=S,e[8]=w):(S=e[7],w=e[8]),xt.useEffect(S,w);let f;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==y?(f={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:y,dismissFireworks:g},e[9]=l.cycle,e[10]=l.isActive,e[11]=y,e[12]=f):f=e[12],f};function m5(t){return t.isActive?{...t,isActive:!1}:t}function h5(t){return{isActive:!0,cycle:t.cycle+1}}function p5(t){return t.isActive?{...t,isActive:!1}:t}const cm=c.createContext(void 0),g5=t=>{const e=et.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=f5();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const u=a;let d;e[3]!==i||e[4]!==r?(d=s.jsx(d5,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let h;return e[6]!==n||e[7]!==d||e[8]!==u?(h=s.jsxs(cm.Provider,{value:u,children:[n,d]}),e[6]=n,e[7]=d,e[8]=u,e[9]=h):h=e[9],h},tA=()=>{const t=c.useContext(cm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},wa="openchamber_requests_in_flight",dm=1e3,x5=300*1e3,Go=Math.ceil(x5/dm),b5=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(wa)==="1"}catch{return!1}},um=()=>({enabled:!0,startedAt:Date.now(),inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],peakAgeMs:0,inFlightStarts:new Map,sampleCount:0,lastSampleAt:null,fetchWrapped:!1,originalFetch:null,sampleTimer:null});let y5=1;const w5=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},v5=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},fm=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,i)=>r-i),n},Cr=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},S5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=y5++;w5(o,Date.now());try{return await e(r,i)}finally{v5(o)}};window.fetch=n},wd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Lr=t=>{t.length>Go&&t.splice(0,t.length-Go)},j5=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=fm(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(Cr(e,50)),t.p90Samples.push(Cr(e,90)),t.p99Samples.push(Cr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Lr(t.samples),Lr(t.p50Samples),Lr(t.p90Samples),Lr(t.p99Samples),Lr(t.maxSamples),t.lastSampleAt=Date.now()},k5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(j5,dm))},vd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Sd=t=>{if(!(typeof window>"u"))try{if(t){vd(),wd(),window.localStorage.setItem(wa,"1"),window.__openchamberRequestsInFlight__=um(),S5(),k5();return}window.localStorage.removeItem(wa),vd(),wd(),delete window.__openchamberRequestsInFlight__}catch{}},C5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=um();t.startedAt=e.startedAt,t.inFlight=e.inFlight,t.peak=e.peak,t.totalStarted=e.totalStarted,t.totalSettled=e.totalSettled,t.samples=e.samples,t.p50Samples=e.p50Samples,t.p90Samples=e.p90Samples,t.p99Samples=e.p99Samples,t.maxSamples=e.maxSamples,t.peakAgeMs=e.peakAgeMs,t.inFlightStarts=e.inFlightStarts,t.sampleCount=e.sampleCount,t.lastSampleAt=e.lastSampleAt},va=()=>{if(typeof window>"u")return jd();const t=window.__openchamberRequestsInFlight__;if(!b5()||!t)return jd();const e=fm(t);return{enabled:!0,startedAt:t.startedAt,durationMs:Math.max(0,Date.now()-t.startedAt),inFlight:t.inFlight,peak:t.peak,totalStarted:t.totalStarted,totalSettled:t.totalSettled,samples:t.samples.slice(),ageP50:Cr(e,50),ageP90:Cr(e,90),ageP99:Cr(e,99),ageMax:e.length>0?e[e.length-1]:0,peakAgeMs:t.peakAgeMs,p50Samples:t.p50Samples.slice(),p90Samples:t.p90Samples.slice(),p99Samples:t.p99Samples.slice(),maxSamples:t.maxSamples.slice(),sampleCount:t.sampleCount,lastSampleAt:t.lastSampleAt,windowSeconds:Go}},jd=()=>({enabled:!1,startedAt:null,durationMs:0,inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],ageP50:0,ageP90:0,ageP99:0,ageMax:0,peakAgeMs:0,p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],sampleCount:0,lastSampleAt:null,windowSeconds:Go});function N5(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const mm=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},Sa=t=>`${(t/1e3).toFixed(2)} s`,ws=t=>{const e=et.c(8),{label:n,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==n?(o=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r?(l=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=s.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},kd=t=>{const e=et.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=vt();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==n){const a=r.entries.slice(0,12);let u;e[8]!==r.entries?(u=r.entries.reduce(P5,0),e[8]=r.entries,e[9]=u):u=e[9];const d=u;let h;e[10]!==n?(h=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=h):h=e[11];let m;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(m=r.startedAt?mm(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=m):m=e[15];let g;e[16]!==m?(g=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:m}),e[16]=m,e[17]=g):g=e[17];let b;e[18]!==h||e[19]!==g?(b=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,g]}),e[18]=h,e[19]=g,e[20]=b):b=e[20];let y;e[21]!==o?(y=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=y):y=e[22];let S;e[23]!==r.entries.length||e[24]!==y?(S=s.jsx(ws,{label:y,value:r.entries.length}),e[23]=r.entries.length,e[24]=y,e[25]=S):S=e[25];let w;e[26]!==o?(w=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=w):w=e[27];let f;e[28]!==w||e[29]!==d?(f=s.jsx(ws,{label:w,value:d}),e[28]=w,e[29]=d,e[30]=f):f=e[30];let x;e[31]!==o?(x=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=x):x=e[32];let v;e[33]!==r.lastUpdatedAt||e[34]!==o?(v=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=v):v=e[35];let p;e[36]!==x||e[37]!==v?(p=s.jsx(ws,{label:x,value:v}),e[36]=x,e[37]=v,e[38]=p):p=e[38];let N;e[39]!==f||e[40]!==p||e[41]!==S?(N=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[S,f,p]}),e[39]=f,e[40]=p,e[41]=S,e[42]=N):N=e[42],l=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[b,N,a.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:i}):s.jsx(jn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(C=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:C.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:o("memoryDebugPanel.metric.countValue",{value:C.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:C.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:C.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:C.total})})]})]},C.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=n,e[7]=l}else l=e[7];return l},Cd=t=>{const e=et.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,u=n.reduce(I5,0),d=r>0?52/r:0;let h;e[0]!==u||e[1]!==a?(h=p=>a-u+p,e[0]=u,e[1]=a,e[2]=h):h=e[2];const m=h;let g;e[3]!==d?(g=p=>56-p*d,e[3]=d,e[4]=g):g=e[4];const b=g;let y;e[5]!==l?(y=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=y):y=e[6];const S=`0 0 ${a} 56`;let w;e[7]!==a?(w=s.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=w):w=e[8];let f;if(e[9]!==n||e[10]!==m||e[11]!==b){let p;e[13]!==m||e[14]!==b?(p=(N,C)=>{const k=N.samples.length;if(k===0)return null;const D=N.samples.map((A,P)=>`${m(P)},${b(A).toFixed(2)}`),I=`M ${D.join(" L ")}`;return s.jsxs(c.Fragment,{children:[N.filled?s.jsx("path",{d:`M ${m(0)},56 L ${D.join(" L ")} L ${m(k-1)},56 Z`,fill:`color-mix(in srgb, ${N.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:I,fill:"none",stroke:N.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=m,e[14]=b,e[15]=p):p=e[15],f=n.map(p),e[9]=n,e[10]=m,e[11]=b,e[12]=f}else f=e[12];let x;e[16]!==o||e[17]!==S||e[18]!==w||e[19]!==f?(x=s.jsxs("svg",{viewBox:S,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[w,f]}),e[16]=o,e[17]=S,e[18]=w,e[19]=f,e[20]=x):x=e[20];let v;return e[21]!==y||e[22]!==x?(v=s.jsxs("div",{className:"relative w-full",children:[y,x]}),e[21]=y,e[22]=x,e[23]=v):v=e[23],v},A5=t=>{const e=et.c(100),{onClose:n}=t,{t:r}=vt(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),u=Ze(T5),d=Bu(E5),h=Su(),m=sx(R5),g=Ys(M5),[b,y]=c.useState(O5),[S,w]=c.useState(B5),[f,x]=c.useState(F5),v=[{label:"p50",current:f.ageP50,samples:f.p50Samples,color:"var(--status-success)"},{label:"p90",current:f.ageP90,samples:f.p90Samples,color:"var(--status-info)"},{label:"p99",current:f.ageP99,samples:f.p99Samples,color:"var(--status-warning)"},{label:"max",current:f.ageMax,samples:f.maxSamples,color:"var(--status-error)"}];let p;e[0]!==f.samples?(p=f.samples.reduce(_5,0),e[0]=f.samples,e[1]=p):p=e[1];const N=p,C=v.reduce($5,0);let k;e[2]!==b.entries?(k=new Map,b.entries.forEach(Ie=>{k.set(Ie.metric,Ie.count)}),e[2]=b.entries,e[3]=k):k=e[3];let D;e[4]!==k?(D=k.get("ui.message_list.render")??0,e[4]=k,e[5]=D):D=e[5];let I;e[6]!==k?(I=k.get("ui.message_list.render.streaming")??0,e[6]=k,e[7]=I):I=e[7];let A;e[8]!==k?(A=k.get("ui.chat_message.render")??0,e[8]=k,e[9]=A):A=e[9];let P;e[10]!==k?(P=k.get("ui.chat_message.render.streaming")??0,e[10]=k,e[11]=P):P=e[11];let T;e[12]!==k?(T=k.get("ui.chat_message.render.static_during_stream")??0,e[12]=k,e[13]=T):T=e[13];let _;e[14]!==k?(_=k.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=k,e[15]=_):_=e[15];let L;e[16]!==D||e[17]!==I||e[18]!==A||e[19]!==P||e[20]!==T||e[21]!==_?(L={messageListRender:D,messageListRenderStreaming:I,chatMessageRender:A,chatMessageRenderStreaming:P,chatMessageRenderStaticDuringStream:T,chatMessageRenderStaticOutsideActiveTurnDuringStream:_},e[16]=D,e[17]=I,e[18]=A,e[19]=P,e[20]=T,e[21]=_,e[22]=L):L=e[22];const W=L;let O,$;e[23]===Symbol.for("react.memo_cache_sentinel")?($=()=>{const Ie=()=>{y(vo()),w(So()),x(va())};Ie();const Fe=window.setInterval(Ie,500);return()=>window.clearInterval(Fe)},O=[],e[23]=O,e[24]=$):(O=e[23],$=e[24]),c.useEffect($,O);let j,E;e[25]!==l?(j=()=>{if(l==="idle")return;const Ie=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Ie)},E=[l],e[25]=l,e[26]=j,e[27]=E):(j=e[26],E=e[27]),c.useEffect(j,E);let K=0,ee=0,J=0;for(const Ie of Object.keys(m)){const Fe=m[Ie]??[];ee=ee+Fe.length;for(const st of Fe)st.role==="user"?J=J+1:st.role==="assistant"&&(K=K+1)}let ne;e[28]!==K||e[29]!==ee||e[30]!==J?(ne={assistant:K,total:ee,user:J},e[28]=K,e[29]=ee,e[30]=J,e[31]=ne):ne=e[31];const ue=ne;let X;if(e[32]!==u||e[33]!==m||e[34]!==d||e[35]!==h||e[36]!==r){let Ie;e[38]!==u||e[39]!==m||e[40]!==d||e[41]!==r?(Ie=Fe=>{const st=m[Fe.id]??[];let lt=0,it=0;for(const St of st)St.role==="user"?it=it+1:St.role==="assistant"&&(lt=lt+1);const mt=d.get(Fe.id);return{id:Fe.id,title:Fe.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:lt,messageCount:st.length,userMessageCount:it,isStreaming:mt?.isStreaming||!1,isZombie:mt?.isZombie||!1,backgroundCount:mt?.backgroundMessageCount||0,lastAccessed:mt?.lastAccessedAt||0,isCurrent:Fe.id===u}},e[38]=u,e[39]=m,e[40]=d,e[41]=r,e[42]=Ie):Ie=e[42],X=h.map(Ie).sort(z5),e[32]=u,e[33]=m,e[34]=d,e[35]=h,e[36]=r,e[37]=X}else X=e[37];const te=X;let fe;e[43]!==m?(fe=Object.keys(m),e[43]=m,e[44]=fe):fe=e[44];const je=fe.length;let ve;e[45]===Symbol.for("react.memo_cache_sentinel")?(ve=async()=>{try{const Ie={generatedAt:new Date().toISOString(),ui:vo(),vscode:So()};await navigator.clipboard.writeText(JSON.stringify(Ie,null,2)),a("copied")}catch{a("error")}},e[45]=ve):ve=e[45];const ye=ve,Pe=rx,xe="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let R;e[46]===Symbol.for("react.memo_cache_sentinel")?(R={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=R):R=e[46];let Y;e[47]!==i?(Y=N5(i),e[47]=i,e[48]=Y):Y=e[48];let ie;e[49]!==Y?(ie=s.jsx(M,{name:Y,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=Y,e[50]=ie):ie=e[50];let H;e[51]!==r?(H=r("memoryDebugPanel.title"),e[51]=r,e[52]=H):H=e[52];let me;e[53]!==H?(me=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:H}),e[53]=H,e[54]=me):me=e[54];let pe;e[55]!==ie||e[56]!==me?(pe=s.jsxs("div",{className:"flex items-center gap-2",children:[ie,me]}),e[55]=ie,e[56]=me,e[57]=pe):pe=e[57];let re;e[58]!==i?(re=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(dt,{size:"xs",variant:"ghost",onClick:ye,children:s.jsx(M,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(dt,{size:"xs",variant:"ghost",onClick:()=>{oh(),y(vo()),w(So())},children:s.jsx(M,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=re):re=e[59];let de;e[60]!==i?(de=i==="requests"?s.jsx(dt,{size:"xs",variant:"ghost",onClick:()=>{C5(),x(va())},children:s.jsx(M,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=de):de=e[61];let B;e[62]!==n?(B=n?s.jsx(dt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(M,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=B):B=e[63];let F;e[64]!==re||e[65]!==de||e[66]!==B?(F=s.jsxs("div",{className:"flex items-center gap-1",children:[re,de,B]}),e[64]=re,e[65]=de,e[66]=B,e[67]=F):F=e[67];let he;e[68]!==pe||e[69]!==F?(he=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[pe,F]}),e[68]=pe,e[69]=F,e[70]=he):he=e[70];let Se;e[71]===Symbol.for("react.memo_cache_sentinel")?(Se={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=Se):Se=e[71];const Re=i==="memory"?"secondary":"ghost";let le;e[72]===Symbol.for("react.memo_cache_sentinel")?(le=()=>o("memory"),e[72]=le):le=e[72];let se;e[73]!==r?(se=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=se):se=e[74];let q;e[75]!==Re||e[76]!==se?(q=s.jsx(dt,{size:"sm",variant:Re,className:"flex-1",onClick:le,children:se}),e[75]=Re,e[76]=se,e[77]=q):q=e[77];const z=i==="streaming"?"secondary":"ghost";let ae;e[78]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>o("streaming"),e[78]=ae):ae=e[78];let ce;e[79]!==r?(ce=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=ce):ce=e[80];let Ne;e[81]!==z||e[82]!==ce?(Ne=s.jsx(dt,{size:"sm",variant:z,className:"flex-1",onClick:ae,children:ce}),e[81]=z,e[82]=ce,e[83]=Ne):Ne=e[83];const we=i==="requests"?"secondary":"ghost";let $e;e[84]===Symbol.for("react.memo_cache_sentinel")?($e=()=>o("requests"),e[84]=$e):$e=e[84];let Oe;e[85]!==r?(Oe=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=Oe):Oe=e[86];let ge;e[87]!==we||e[88]!==Oe?(ge=s.jsx(dt,{size:"sm",variant:we,className:"flex-1",onClick:$e,children:Oe}),e[87]=we,e[88]=Oe,e[89]=ge):ge=e[89];let He;e[90]!==q||e[91]!==Ne||e[92]!==ge?(He=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:Se,children:[q,Ne,ge]}),e[90]=q,e[91]=Ne,e[92]=ge,e[93]=He):He=e[93];const V=i==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(ws,{label:r("memoryDebugPanel.metric.totalMessages"),value:ue.total}),s.jsx(ws,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${je} / ${Ll.MAX_SESSIONS}`}),s.jsx(ws,{label:r("memoryDebugPanel.metric.userMessages"),value:ue.user}),s.jsx(ws,{label:r("memoryDebugPanel.metric.assistantMessages"),value:ue.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:nx()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:Ll.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:g})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(jn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:te.map(Ie=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Ie.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:Ie.title}),Ie.isStreaming?s.jsx(M,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Ie.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:Ie.assistantMessageCount,user:Ie.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Ie.messageCount})}),Ie.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Ie.backgroundCount]}):null]})]},Ie.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(dt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(W5),currentSessionId:u,cachedSessions:Object.keys(m),messageRoleCounts:ue,sessionMessageRoleCounts:te.map(K5),memoryStates:Object.fromEntries(d)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(It,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(dt,{size:"xs",variant:"outline",onClick:ye,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(ws,{label:r("memoryDebugPanel.metric.uiMetrics"),value:b.entries.length}),s.jsx(ws,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:S.entries.length}),s.jsx(ws,{label:r("memoryDebugPanel.metric.messageListRenders"),value:W.messageListRender}),s.jsx(ws,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:W.messageListRenderStreaming}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:W.chatMessageRender}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:W.chatMessageRenderStreaming}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:W.chatMessageRenderStaticDuringStream}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:W.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(kd,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:b,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),S.entries.length>0?s.jsx(kd,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:S,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(ws,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${f.totalSettled} / ${f.totalStarted}`}),s.jsx(ws,{label:r("memoryDebugPanel.requests.tracking"),value:f.startedAt?mm(f.durationMs):r("memoryDebugPanel.common.idle")})]}),f.samples.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:f.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:f.peak})]})]}),s.jsx(Cd,{series:[{samples:f.samples,color:"var(--status-info)",filled:!0}],peak:N,windowSeconds:f.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:f.peak}),maxLabel:`${N}`}),s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Sa(f.peakAgeMs)})]}),s.jsx(Cd,{series:v.map(V5),peak:C,windowSeconds:f.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:Sa(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:v.map(U5)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:f.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let Ae;return e[94]!==Pe||e[95]!==R||e[96]!==he||e[97]!==He||e[98]!==V?(Ae=s.jsxs(Pe,{className:xe,style:R,children:[he,He,V]}),e[94]=Pe,e[95]=R,e[96]=he,e[97]=He,e[98]=V,e[99]=Ae):Ae=e[99],Ae},D5=A5;function P5(t,e){return t+e.count}function I5(t,e){return Math.max(t,e.samples.length)}function T5(t){return t.currentSessionId}function E5(t){return t.sessionMemoryState}function R5(t){return t.message}function M5(t){return t.totalRequestCount}function O5(){return vo()}function B5(){return So()}function F5(){return va()}function _5(t,e){return Math.max(t,e)}function L5(t,e){return Math.max(t,e)}function $5(t,e){return e.samples.reduce(L5,t)}function z5(t,e){return e.lastAccessed-t.lastAccessed}function W5(t){return{id:t.id,title:t.title}}function K5(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function V5(t){return{samples:t.samples,color:t.color}}function U5(t){return s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Sa(t.current)})]},t.label)}const H5=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},G5=async()=>{const t=H5()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Nd="openchamber:menu-action",Pi="openchamber:check-for-updates",q5=t=>{const e=Ze(f=>f.openNewSessionDraft),n=De(f=>f.toggleCommandPalette),r=De(f=>f.setCommandPaletteOpen),i=De(f=>f.toggleHelpDialog),o=De(f=>f.toggleSidebar),l=De(f=>f.setSessionSwitcherOpen),a=De(f=>f.setSettingsDialogOpen),u=De(f=>f.setAboutDialogOpen),d=Ur(f=>f.checkForUpdates),{setThemeMode:h}=ar(),m=c.useRef(!1),g=c.useCallback(()=>{m.current||(m.current=!0,d().then(()=>{const{available:f,error:x}=Ur.getState();if(x){_e.error("Failed to check for updates",{description:x});return}f||_e.success("You are on the latest version")}).finally(()=>{m.current=!1}))},[d]),b=c.useCallback(()=>{hn.requestDirectoryDialog()},[]),y=c.useCallback(f=>{const x=ox();if(x.length===0)return;const v=Ze.getState().currentSessionId,p=x.findIndex(k=>k.id===v);let N=f>0?0:x.length-1;p>=0&&(N=(p+f+x.length)%x.length);const C=x[N];C&&(l(!1),Ze.getState().setCurrentSession(C.id))},[l]),S=c.useCallback(f=>{const{activeProjectId:x,projects:v,setActiveProject:p}=Gt.getState();if(v.length===0)return;const N=v.findIndex(D=>D.id===x);let C=f>0?0:v.length-1;N>=0&&(C=(N+f+v.length)%v.length);const k=v[C];k&&p(k.id)},[]),w=c.useCallback(f=>{switch(f){case"about":u(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const x=Ze.getState(),v=os.getState().currentDirectory;e(x.currentSessionId&&v?{directoryOverride:v}:void 0)}break;case"new-worktree-session":l(!1),Au();break;case"change-workspace":b();break;case"toggle-right-sidebar":{const x=os.getState().currentDirectory;if(!x)break;const v=De.getState(),p=fr(x),N=v.contextPanelByDirectory[p];N?.isOpen?v.closeContextPanel(p):N?.activeTabId?v.setActiveContextPanelTab(p,N.activeTabId):v.openContextSurface(p,"git");break}case"open-right-sidebar-git":{const x=os.getState().currentDirectory;if(!x)break;De.getState().openContextSurface(fr(x),"git");break}case"open-right-sidebar-files":{const x=os.getState().currentDirectory;if(!x)break;De.getState().openContextSurface(fr(x),"file");break}case"toggle-terminal":{const x=os.getState().currentDirectory;if(!x)break;De.getState().openContextSurface(fr(x),"terminal");break}case"toggle-terminal-expanded":{const x=os.getState().currentDirectory;if(!x)break;const v=fr(x),p=De.getState(),N=p.contextPanelByDirectory[v];(N?.isOpen?N.tabs.find(k=>k.id===N.activeTabId)?.mode:null)!=="terminal"&&p.openContextSurface(v,"terminal"),p.toggleContextPanelExpanded(v);break}case"copy":{const x=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(x)||G5();break}case"theme-light":h("light");break;case"theme-dark":h("dark");break;case"theme-system":h("system");break;case"add-selection-to-chat":ix();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":os.getState().goBack();break;case"go-forward":os.getState().goForward();break;case"previous-session":y(-1);break;case"next-session":y(1);break;case"previous-project":S(-1);break;case"next-project":S(1);break;case"help-dialog":i();break;case"download-logs":{Du().catch(()=>{_e.error("Failed to collect OpenCode status")});break}}},[b,S,y,t,e,u,l,r,a,h,n,i,o]);c.useEffect(()=>{const f=v=>{const p=v.detail;p&&w(p)},x=()=>{g()};return window.addEventListener(Nd,f),window.addEventListener(Pi,x),()=>{window.removeEventListener(Nd,f),window.removeEventListener(Pi,x)}},[w,g]),c.useEffect(()=>{if(typeof window>"u")return;const x=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof x!="function")return;let v=null,p=null;return x("openchamber:menu-action",N=>{const C=N?.payload;typeof C=="string"&&w(C)}).then(N=>{v=N}).catch(()=>{}),x("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Pi))}).then(N=>{p=N}).catch(()=>{}),()=>{(async()=>{try{const C=v?.();C instanceof Promise&&await C}catch{}try{const C=p?.();C instanceof Promise&&await C}catch{}})()}},[w])},Y5="openchamber:tray-action",Ad=5e3,Q5=500,hm=20,Dd=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Pd=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,X5=t=>{const e=typeof t.permission=="string"?t.permission:"Permission",n=Array.isArray(t.patterns)?t.patterns.find(r=>typeof r=="string"&&r.trim()):"";return n?`${e}: ${n}`:e},J5=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},pm=(t,e)=>La(t,e,Xr.getState().ids,Ra.getState().rankById),Z5=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},eN=(t,e,n,r,i)=>{if(!t)return"";const o=Jd(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||Z5(t),u=ko(t);let d=u&&i.get(u)||"";if(!d){for(const[h,m]of Mn.getState().directories)if(ko(h)===u){d=m.status?.current??"";break}}if(!d)for(const h of r.values()){const m=h.find(g=>ko(g.path)===u);if(m?.branch){d=m.branch;break}}return d?`${a} · ${d}`:a},tN=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=hr.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of cx){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const u=[];for(const[h,m]of Object.entries(a.usage?.windows??{})){const g=r==="remaining"?m.remainingPercent:m.usedPercent;u.push({label:ux(h),value:dx(m.valueLabel,g)})}const d=!a.ok&&a.error?a.error:u.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:u,status:d})}return{mode:r,groups:o}},sN=async()=>{try{if(qo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=En();if(e&&ul(e,t))return"Local OpenChamber";const r=(await Bd()).hosts.find(i=>e?ul(e,ih(i)):!1);return r?.label?.trim()?Fd(r.label.trim()):"Instance"}catch{return""}},nN=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=Mo()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(ko(o)??o,a.vcs.branch);for(const u of a.session)u?.id&&r.set(u.id,u.title);for(const[u,d]of Object.entries(a.session_status??{})){const h=d?.type,m=h==="busy"?"busy":h==="retry"?"retry":"idle",g=t.get(u);(!g||g==="idle")&&t.set(u,m)}for(const[u,d]of Object.entries(a.permission??{}))for(const h of d??[]){if(!h?.id)continue;const m=h.sessionID||u;n.push({kind:"permission",id:h.id,sessionId:m,sessionTitle:"",label:X5(h),directory:o})}for(const[u,d]of Object.entries(a.question??{}))for(const h of d??[]){if(!h?.id)continue;const m=h.sessionID||u;n.push({kind:"question",id:h.id,sessionId:m,sessionTitle:"",label:J5(h),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},rN=()=>{const t=_s.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort(pm).slice(0,hm).forEach(r=>{const i=Ps(r);i&&e.add(i)});const n=new Map;for(const r of t){if(!r?.id)continue;const i=Ps(r);if(!i||!e.has(i))continue;const o=n.get(i)??[];o.push(r.id),n.set(i,o)}return n},oN=(t,e)=>{const n=Fa.getState().index.session,r=_s.getState().activeSessions,i=new Map;for(const f of r)if(f?.id&&f.parentID){const x=i.get(f.parentID)??[];x.push(f.id),i.set(f.parentID,x)}const o=f=>{const x=[],v=[...i.get(f)??[]],p=new Set;for(;v.length;){const N=v.pop();p.has(N)||(p.add(N),x.push(N),v.push(...i.get(N)??[]))}return x},l=De.getState();let a=0;if(l.dockBadgeEnabled)for(const f of r){if(!f?.id||f.parentID)continue;let x=n.unseenCount[f.id]??0;x===0&&l.notifyOnSubtasks&&(x=o(f.id).reduce((v,p)=>v+(n.unseenCount[p]??0),0)),x>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const u=nN(),d=new Map(u.titleById);for(const f of r)f?.id&&f.title&&d.set(f.id,f.title);const h=Ba.getState().statusById,m=f=>{const x=u.statusById.get(f);return x&&x!=="idle"?x:h.get(f)?.status.type??x??"idle"},g=f=>{const x=f.map(v=>m(v));return x.includes("busy")?"busy":x.includes("retry")?"retry":"idle"},b=Gt.getState().projects,y=Ze.getState().availableWorktreesByProject,S=r.filter(f=>f?.id&&!f.parentID).slice().sort(pm).slice(0,hm).map(f=>{const x=[f.id,...o(f.id)],v=Ps(f)??"";return{id:f.id,title:f.title||"Untitled session",status:g(x),branch:v?u.branchByDirectory.get(v)??"":"",unseen:x.reduce((p,N)=>p+(n.unseenCount[N]??0),0),hasError:x.some(p=>n.unseenHasError[p]??!1),directory:v,subtitle:eN(v,f,b,y,u.branchByDirectory)}}),w=u.approvals.map(f=>({...f,sessionTitle:d.get(f.sessionId)||""}));return{sessions:S,approvals:w,instanceName:t,usage:tN(),dockBadgeCount:a}},iN=()=>{c.useEffect(()=>{if(!Dd()||!Yr())return;const t=Pd();let e=!1,n="",r=null,i="";const o=()=>{if(e)return;const D=oN(i,t),I=JSON.stringify(D);I!==n&&(n=I,zn("desktop_tray_update",D))},l=async()=>{const D=rN();await Promise.all([...D.entries()].map(async([I,A])=>{const P=await Xs.getSessionStatusForDirectory(I).catch(()=>null);e||P===null||ax(I,P,A)}))},a=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},Q5))},u=Fa.subscribe(()=>a()),d=_s.subscribe(()=>a()),h=De.subscribe((D,I)=>{(D.dockBadgeEnabled!==I.dockBadgeEnabled||D.notifyOnSubtasks!==I.notifyOnSubtasks)&&a()}),m=()=>{e=!0,r!==null&&window.clearTimeout(r),u(),d(),h()};if(!t)return o(),m;sN().then(D=>{e||(i=D,o())});const g=new Map,b=()=>{if(e)return;let D;try{D=Mo()}catch{return}const I=new Set;for(const[A,P]of D.children.entries())I.add(A),g.has(A)||g.set(A,P.subscribe(()=>a()));for(const[A,P]of g)I.has(A)||(P(),g.delete(A))};let y=null;try{y=Mo().subscribeRegistry(()=>{b(),a()})}catch{}b();const S=Gt.subscribe(()=>a()),w=Ze.subscribe(()=>a()),f=Mn.subscribe(()=>a()),x=Ba.subscribe(()=>a()),v=Ra.subscribe(()=>a()),p=Xr.subscribe(()=>a());l();const N=window.setInterval(()=>{l()},Ad),C=hr.subscribe(()=>a());hr.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:D,results:I}=hr.getState();D.length>0&&D.some(P=>!I.some(T=>T.providerId===P))&&hr.getState().fetchQuotas(D)});const k=window.setInterval(()=>{b(),o()},Ad);return o(),()=>{m(),window.clearInterval(k),window.clearInterval(N),S(),w(),f(),x(),v(),p(),C(),y?.();for(const D of g.values())D();g.clear()}},[]),c.useEffect(()=>{if(!Dd()||!Pd()||!Yr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&lx(i.sessionId,i.id,i.response).catch(()=>{_e.error("Failed to respond to permission request")})};let r=null;return e(Y5,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||n(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},aN=45e3,lN=(t,e,n=window.setInterval.bind(window),r=window.clearInterval.bind(window))=>{t();const i=n(e,aN);return()=>r(i)},cN=t=>{const e=et.c(3);let n,r;e[0]!==t?(n=()=>{if(t)return lN(dN,uN)},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function dN(){fx(Oo())}function uN(){Ka()}const fN="/api/notifications/stream",mN=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),hN=t=>{if(!t||typeof t!="object")return null;const e=t,n=e.properties&&typeof e.properties=="object"?e.properties:null;return e.type!=="openchamber:notification"||!n?null:{title:typeof n.title=="string"?n.title:void 0,body:typeof n.body=="string"?n.body:void 0,tag:typeof n.tag=="string"?n.tag:void 0}},pN=t=>{const e=et.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!n||vn()||!ka()||typeof window>"u"||typeof EventSource>"u")return;const o=new EventSource(ja().sse(fN));return o.onmessage=gN,()=>{o.close()}},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function gN(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=De.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&mN())return;const r=hN(e);if(!r)return;Od()?.notifications?.notifyAgentCompletion(r)}const xN=6e4,bN=t=>{const e=et.c(10),n=De(yN),r=mx(wN),o=Hh(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:xN})},a=[n,r,o],e[0]=n,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let u,d;e[5]!==n||e[6]!==r||e[7]!==o?(u=()=>{if(n)return ro(h=>{h.type==="agent-memory-changed"&&r(o)})},d=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=u,e[9]=d):(u=e[8],d=e[9]),c.useEffect(u,d)};function yN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function wN(t){return t.load}const Id="pwa-install-toast-shown",Td="pwa-install-toast-dismissed",vN=()=>{const t=et.c(6),{browserTab:e}=Gh(),{t:n}=vt(),r=c.useRef(n);let i,o;t[0]!==n?(i=()=>{r.current=n},o=[n],t[0]=n,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!ka()||!e)return;let u=null,d=null;const h=()=>{d!==null&&(_e.dismiss(d),d=null)},m=async()=>{if(!u)return;const y=u;u=null,h(),await y.prompt();const{outcome:S}=await y.userChoice;S==="accepted"&&_e.success(r.current("pwa.installPrompt.started"))},g=y=>{const S=y;if(typeof S.prompt!="function")return;S.preventDefault(),u=S;const w=Eo(),f=ah();qh({dismissed:w.getItem(Td),sessionShown:f.getItem(Id),hasActiveToast:d!==null})&&(f.setItem(Id,"true"),d=_e.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{m()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Eo().setItem(Td,"true"),h()}}}))},b=()=>{u=null,h(),_e.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",g),window.addEventListener("appinstalled",b),()=>{h(),window.removeEventListener("beforeinstallprompt",g),window.removeEventListener("appinstalled",b)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},SN=({open:t,onOpenChange:e})=>{const{t:n}=vt(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[u,d]=c.useState(!1),[h,m]=c.useState(!1),[g,b]=c.useState(null),[y,S]=c.useState(!1);c.useCallback(async()=>{},[g,u,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const x=await ms("/api/system/info");if(x.ok){const v=await x.json();if(typeof v.openchamberVersion=="string"&&v.openchamberVersion.trim()){o(v.openchamberVersion);return}}}catch{}o(await hx())})()},[t]),c.useEffect(()=>{if(!t)return;let f=!1;return(async()=>{try{const v=await ms("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!v.ok)return;const p=await v.json().catch(()=>null),N=typeof p?.currentVersion=="string"?p.currentVersion.trim():"";!f&&N&&a(N)}catch{}})(),()=>{f=!0}},[t]),c.useEffect(()=>{{b(null),S(!1);return}},[t,r]);const w=i;return s.jsx(vs,{open:t,onOpenChange:e,children:s.jsx(Ss,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(ju,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[w&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:w})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(M,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(M,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(M,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},Ed=t=>{if(!(typeof window>"u")){if(t){window.location.href="openchamber://focus/mcp-auth";return}window.location.replace("/")}},Ii=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},jN=(t,e)=>{const n=t instanceof Error?t.message:e;return/oauth state required/i.test(n)?"Authorization session expired or was cleared during reload. Return to OpenChamber and click Authorize again.":n},kN=()=>{const t=px(a=>a.completeAuth),[e,n]=c.useState("working"),[r,i]=c.useState(!1),[o,l]=c.useState("Completing MCP authorization...");return c.useEffect(()=>{if(typeof window>"u"){n("error"),l("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),u=Ii(a,"code"),d=gx(a),h=xx(a),m=Ii(a,"error"),g=Ii(a,"error_description");if(m){h&&ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(g??m);return}(async()=>{try{if(!u)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");let b=d,y=!1;if(h){const S=await ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`);if(S.ok){const w=await S.json().catch(()=>null);y=w?.origin===bx,i(y),!b&&w?.name?.trim()&&(b={name:w.name.trim(),directory:typeof w.directory=="string"&&w.directory.trim()?w.directory.trim():null})}}if(!b?.name)throw new Error("Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");await t(b.name,u,b.directory),h&&await ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("success"),y&&Ed(!0),l("Authorization completed. You can close this tab and return to OpenChamber.")}catch(b){h&&await ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(jN(b,"Failed to complete MCP authorization."))}})()},[t]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground",children:s.jsxs("div",{className:"w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm",children:[s.jsxs("div",{className:"space-y-3 text-center",children:[s.jsx("h1",{className:yx,children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"}),s.jsx("p",{className:Me("typography-body",e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]"),children:o})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx(dt,{type:"button",onClick:()=>Ed(r),children:"Return to OpenChamber"})})]})})},Rd=Un(()=>On(()=>import("./OnboardingScreen-5Gou9cGD.js"),__vite__mapDeps([148,1,2,4,5,6,7,8,9,3,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])).then(t=>({default:t.OnboardingScreen}))),CN=()=>{const t=et.c(3),e=De(TN),n=De(EN);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(SN,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},NN=t=>{const e=et.c(21),{onRetry:n,isRetrying:r}=t,{t:i}=vt();let o;e[0]!==i?(o=i("startup.initRecovery.title"),e[0]=i,e[1]=o):o=e[1];let l;e[2]!==o?(l=s.jsx("h1",{className:"typography-title text-foreground",children:o}),e[2]=o,e[3]=l):l=e[3];let a;e[4]!==i?(a=i("startup.initRecovery.description"),e[4]=i,e[5]=a):a=e[5];let u;e[6]!==a?(u=s.jsx("p",{className:"typography-body text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let d;e[8]!==l||e[9]!==u?(d=s.jsxs("div",{className:"flex flex-col gap-2",children:[l,u]}),e[8]=l,e[9]=u,e[10]=d):d=e[10];let h;e[11]!==r||e[12]!==i?(h=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=i,e[13]=h):h=e[13];let m;e[14]!==r||e[15]!==n||e[16]!==h?(m=s.jsx(dt,{type:"button",onClick:n,disabled:r,children:h}),e[14]=r,e[15]=n,e[16]=h,e[17]=m):m=e[17];let g;return e[18]!==d||e[19]!==m?(g=s.jsx("div",{className:"flex h-full items-center justify-center bg-background px-6 text-foreground",children:s.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[d,m]})}),e[18]=d,e[19]=m,e[20]=g):g=e[20],g},Md=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",AN=()=>{if(typeof window>"u"||!ub())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},DN=()=>typeof window>"u"?!1:window.location.pathname===Cx,PN=t=>{const e=et.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=os(RN),l=Ze(MN),a=Ze(ON),u=lu(),d=c.useRef(null);let h;e[0]!==n.directory?(h=Md(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const m=h;let g;e[2]!==o?(g=Md(o),e[2]=o,e[3]=g):g=e[3];const b=g;let y,S;if(e[4]!==b||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==m||e[9]!==r||e[10]!==a||e[11]!==u?(y=()=>{if(r||m&&b!==m)return;const N=`${m}
896
- ${n.sessionId}`;d.current===N&&l||(d.current=N,a(n.sessionId,n.directory),u.ensureSessionRenderable(n.sessionId,!0))},S=[b,l,n.directory,n.sessionId,m,r,a,u],e[4]=b,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=m,e[9]=r,e[10]=a,e[11]=u,e[12]=y,e[13]=S):(y=e[12],S=e[13]),c.useEffect(y,S),m&&b!==m)return null;let w;e[14]!==i?(w=s.jsx(zu,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=w):w=e[15];let f;e[16]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(Xd,{}),e[16]=f):f=e[16];let x;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(x=s.jsx(Qd,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=x):x=e[20];let v;e[21]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(Wu,{}),e[21]=v):v=e[21];let p;return e[22]!==w||e[23]!==x?(p=s.jsxs(s.Fragment,{children:[w,f,x,v]}),e[22]=w,e[23]=x,e[24]=p):p=e[24],p};function IN({apis:t}){c.useEffect(()=>{lh("App:mounted"),ch()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Yt(R=>R.initializeApp),n=Yt(R=>R.isInitialized),r=Yt(R=>R.isConnected),i=Yt(R=>R.providers.length),o=Yt(R=>R.agents.length),l=Yt(R=>R.loadProviders),a=Yt(R=>R.loadAgents),u=Ze(R=>R.error),d=Ze(R=>R.clearError),h=os(R=>R.currentDirectory),m=os(R=>R.setDirectory),g=os(R=>R.isSwitchingDirectory),[b,y]=c.useState(!1),S=Rn(R=>R.refreshStatus),w=Wi(R=>R.refreshStatus),[f,x]=c.useState(()=>t.runtime.isVSCode),[v,p]=c.useState(!1),[N,C]=c.useState(!1),[k,D]=c.useState(0),[I,A]=c.useState(0),[P,T]=c.useState(!1),_=De(R=>R.wideChatLayoutEnabled),L=De(R=>R.mobileKeyboardMode),W=c.useMemo(()=>vn(),[]),O=Da(R=>R.setPlanModeEnabled),[$,j]=c.useState(()=>fl()),[E,K]=c.useState(()=>{const R=ml();return R!==null?hl({isDesktopShell:!0,bootOutcome:R}):null}),ee=c.useRef(!1),J=c.useMemo(()=>AN(),[]),ne=!J||v,ue=c.useMemo(()=>DN(),[]);c.useEffect(()=>(pl(b),Sd(b),()=>{pl(!1),Sd(!1)}),[b]),c.useEffect(()=>{dh(L)},[L]),c.useEffect(()=>{x(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>eo(R=>{Yh(R),A(Y=>Y+1),C(!1),D(Y=>Y+1)}),[]);const X=$l(R=>{const Y=as();return Object.values(R.runsByOriginalSessionID).filter(ie=>ie.status==="running"&&ie.runtimeKey===Y).map(ie=>`${ie.originalSessionID}:${ie.phase}:${ie.lastForwardedMessageID??""}:${ie.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(J)return;const R=as(),Y=Object.values($l.getState().runsByOriginalSessionID).filter(ie=>ie.status==="running"&&ie.runtimeKey===R);for(const ie of Y)wx(ie.originalSessionID)},[X,J,I]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",_),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[_]),c.useEffect(()=>(gl(t),()=>gl(null)),[t]),c.useEffect(()=>{J||(S(t.github,{force:!0}),w(t.linear,{force:!0}))},[t.github,t.linear,J,r,S,w,I]),vx();const te=$==="valid",fe=E?.screen==="main";c.useEffect(()=>{if(!uh({isDesktopShell:W,isInitialized:n,bootOutcomeKnown:te,bootViewIsMain:fe}))return;const R=setTimeout(()=>{const Y=document.getElementById("initial-loading");Y&&(Y.classList.add("fade-out"),setTimeout(()=>{Y.remove()},300))},150);return()=>clearTimeout(R)},[W,n,te,fe]),c.useEffect(()=>{if(!W||$!=="malformed")return;const R=document.getElementById("initial-loading");R&&(R.textContent="Desktop startup failed — please restart the app.")},[W,$]),c.useEffect(()=>{if(W)return;const R=setTimeout(()=>{const Y=document.getElementById("initial-loading");Y&&!n&&(Y.classList.add("fade-out"),setTimeout(()=>{Y.remove()},300))},5e3);return()=>clearTimeout(R)},[W,n]),c.useEffect(()=>{let R=!1;return(async()=>{const ie=await ms("/health",{method:"GET"}).catch(()=>null);if(!ie||!ie.ok||R)return;const H=await ie.json().catch(()=>null);if(!H||R)return;const me=H.planModeExperimentalEnabled;O(me===!0||me===1||me==="1"||me==="true")})(),()=>{R=!0}},[O]),c.useEffect(()=>{f||e()},[e,f]),c.useEffect(()=>{if(f||n)return;let R=!0,Y,ie=0;const H=10,me=1e3,pe=async()=>{if(!R)return;if(ie>=H){C(!0);return}const re=Yt.getState();if(re.isInitialized){C(!1);return}ie+=1,await re.initializeApp();const de=Yt.getState();if(!R)return;if(de.isInitialized){C(!1);return}if(ie>=H){C(!0);return}const B=Math.min(me*Math.pow(2,ie-1),16e3);Y=setTimeout(pe,B)};return Y=setTimeout(pe,me),()=>{R=!1,Y&&clearTimeout(Y)}},[k,n,f]),c.useEffect(()=>{n&&C(!1)},[n]),c.useEffect(()=>{if(!N)return;const R=document.getElementById("initial-loading");R&&(R.classList.add("fade-out"),setTimeout(()=>{R.remove()},300))},[N]),c.useEffect(()=>{if(f||!r||i>0&&o>0)return;let R=!0,Y=0;const ie=15,H=async()=>{const pe=Yt.getState();if(!(pe.providers.length>0&&pe.agents.length>0))try{pe.providers.length===0&&await l({source:"startupRecovery"}),Yt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};H();const me=setInterval(()=>{if(R){if(++Y>=ie){clearInterval(me);return}H()}},2e3);return()=>{R=!1,clearInterval(me)}},[r,f,a,l,i,o]),c.useEffect(()=>{g||f||r&&Xs.setDirectory(h)},[h,g,r,f]),c.useEffect(()=>{if(!J||typeof window>"u")return;const R=H=>{p(H?.visible===!0)},Y=H=>{if(H.origin!==window.location.origin||H.source!==window.parent)return;const me=H.data;me?.type===Ju&&R(me.payload)},ie=window;return ie.__openchamberSetEmbeddedVisibility=R,window.addEventListener("message",Y),db(),()=>{window.removeEventListener("message",Y),ie.__openchamberSetEmbeddedVisibility===R&&delete ie.__openchamberSetEmbeddedVisibility}},[J]),c.useEffect(()=>{!J?.directory||f||h!==J.directory&&m(J.directory,{showOverlay:!1})},[h,J,f,m]),c.useEffect(()=>{if(!J||typeof window>"u")return;const R=Y=>{Y.storageArea===window.localStorage&&Y.key==="ui-store"&&De.persist.rehydrate()};return window.addEventListener("storage",R),()=>{window.removeEventListener("storage",R)}},[J]),c.useEffect(()=>{if(typeof window>"u")return;const R=Y=>{const ie=Y.detail,H=typeof ie?.sessionId=="string"?ie.sessionId.trim():"";if(!H)return;const me=typeof ie?.directory=="string"&&ie.directory.trim().length>0?ie.directory.trim():null;Ze.getState().setCurrentSession(H,me)};return window.addEventListener("openchamber:open-session",R),()=>window.removeEventListener("openchamber:open-session",R)},[]),c.useEffect(()=>{if(typeof window>"u")return;const R=()=>{zn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",R),()=>window.removeEventListener("openchamber:open-mini-chat",R)},[]),c.useEffect(()=>{if(typeof window>"u")return;const R=()=>{const Y=Ze.getState().currentSessionId;Y&&ku(Y)};return window.addEventListener("focus",R),()=>window.removeEventListener("focus",R)},[]),c.useEffect(()=>{if(typeof window>"u")return;const R=Y=>{const ie=Y.detail,H=typeof ie?.directory=="string"&&ie.directory.trim().length>0?ie.directory.trim():null,me=typeof ie?.projectId=="string"&&ie.projectId.trim().length>0?ie.projectId.trim():null,pe=!!(H||me);De.getState().setSessionSwitcherOpen(!1),Ze.getState().openNewSessionDraft({target:pe?"project":"chat",selectedProjectId:pe?me:null,directoryOverride:pe?H:null,preserveDirectoryOverride:!!H})};return window.addEventListener("openchamber:open-draft-session",R),()=>window.removeEventListener("openchamber:open-draft-session",R)},[]),c.useEffect(()=>{typeof window>"u"||!n||g||ee.current||(ee.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,g]),Sx({enabled:ne}),pN({enabled:ne}),bN(h||null),jx(),vN(),kx(),$x(),Qh();const je=c.useCallback(()=>{y(R=>!R)},[]);q5(je),iN(),cN(!J),c.useEffect(()=>{if(J)return;const R=()=>y(Y=>!Y);return window.addEventListener("openchamber:memory-debug-toggle",R),()=>window.removeEventListener("openchamber:memory-debug-toggle",R)},[J]),c.useEffect(()=>{J||u&&setTimeout(()=>d(),5e3)},[d,J,u]),c.useEffect(()=>{if(!W||$!=="not-injected")return;let R=!1,Y=0;const ie=200,H=2e3,me=50,pe=()=>{if(R)return;Y++;const re=fl();if(re!=="not-injected"){if(R=!0,j(re),re==="valid"){const B=ml();B&&K(hl({isDesktopShell:!0,bootOutcome:B}))}return}const de=Math.min(ie*Math.pow(1.1,Y),H);if(Y>=me){const B=document.getElementById("initial-loading");B&&!B.textContent?.includes("taking longer")&&(B.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(pe,de)};return window.setTimeout(pe,ie),()=>{R=!0}},[W,$]);const ve=c.useCallback(async()=>{if(fh({isDesktopShell:vn(),isDesktopLocalOriginActive:qo()})){await mh();return}window.location.reload()},[]),ye=c.useCallback(async()=>{if(!P){C(!1),T(!0);try{await Yt.getState().initializeApp()}finally{T(!1)}Yt.getState().isInitialized||D(R=>R+1)}},[P]),Pe=R=>{if(R.screen==="recovery")return R.variant};if(W&&E&&E.screen!=="main"){if(E.screen==="chooser")return s.jsx(Ds,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Rd,{mode:"first-launch",localAvailable:E.localAvailable!==!1,onCliAvailable:ve,onChooseRemote:()=>{}})})})});const R=Pe(E),Y=E.screen==="recovery"&&"url"in E?E.url:void 0;return s.jsx(Ds,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Rd,{mode:"recovery",recoveryVariant:R,recoveryHostUrl:Y,recoveryHostLabel:void 0,localAvailable:E.localAvailable!==!1,onCliAvailable:ve})})})})}if(J)return s.jsx(Ds,{children:s.jsx(zl,{sdk:Xs.getSdkClient(),directory:h||"",children:s.jsx(Wl,{apis:t,children:s.jsx(qi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(PN,{embeddedSessionChat:J,isVSCodeRuntime:f,embeddedBackgroundWorkEnabled:ne}),s.jsx(Kl,{}),s.jsx(Vl,{})]})})})},I)});if(ue)return s.jsx(Ds,{children:s.jsx(kN,{})});if(N&&!n&&!f&&!J)return s.jsx(Ds,{children:s.jsx(NN,{onRetry:()=>{ye()},isRetrying:P})});const xe=!n&&!W;return s.jsx(Ds,{children:s.jsx(zl,{sdk:Xs.getSdkClient(),directory:h||"",children:s.jsx(Wl,{apis:t,children:s.jsx(g5,{children:s.jsx(qi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:W?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(zu,{embeddedBackgroundWorkEnabled:ne}),s.jsx(Xd,{}),s.jsx(VC,{}),s.jsx(Xh,{ready:n&&(!W||te&&fe)}),s.jsx(Wu,{}),s.jsx(Kl,{}),s.jsx(Vl,{}),!xe&&s.jsxs(s.Fragment,{children:[s.jsx(Jh,{}),s.jsx(CN,{}),b&&s.jsx(D5,{onClose:()=>y(!1)})]})]})})})})},I)})}function TN(t){return t.isAboutDialogOpen}function EN(t){return t.setAboutDialogOpen}function RN(t){return t.currentDirectory}function MN(t){return t.currentSessionId}function ON(t){return t.setCurrentSession}const BN=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Nx();hh().then(()=>{Promise.all([ph(),Ax()]).catch(t=>{console.error("[main] settings init failed:",t)}),Dx(),Px(),Ix()}).catch(t=>{console.error("[main] appearance init failed:",t)});const gm=document.getElementById("root");if(!gm)throw new Error("Root element not found");Tx();Lm.createRoot(gm).render(s.jsx(xt.StrictMode,{children:s.jsx(Ex,{children:s.jsx(Rx,{children:s.jsx(Mx,{children:s.jsx(Ox,{children:s.jsx(IN,{apis:BN})})})})})}));const sA=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{zy as W,Iy as a,tA as b,xf as g,sA as m,$y as u,gf as v};