@openchamber/web 2.6.1 → 2.6.2-canary.20261104.6

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 (107) hide show
  1. package/dist/assets/{AboutDialog-D-IujH5P.js → AboutDialog-BLUUIZML.js} +1 -1
  2. package/dist/assets/{AboutLogo-Bghz4cno.js → AboutLogo-DiHHd_5t.js} +1 -1
  3. package/dist/assets/{ArchiveView-SQdNDg7X.js → ArchiveView-CwhPe3Y_.js} +1 -1
  4. package/dist/assets/{ChangeRequestDiffUnavailable-uZ8LXZIU.js → ChangeRequestDiffUnavailable-3YgjMJtr.js} +1 -1
  5. package/dist/assets/{ChangedPathLabel-BZHIGJ_0.js → ChangedPathLabel-B6Ig547I.js} +1 -1
  6. package/dist/assets/{CommandPalette-DjCVXkJM.js → CommandPalette-BChv7Yci.js} +1 -1
  7. package/dist/assets/{DiffView-CIlNcbDh.js → DiffView-pFcLbagS.js} +1 -1
  8. package/dist/assets/{FilesView-VMk-uSwN.js → FilesView-Bod-r3C6.js} +1 -1
  9. package/dist/assets/{GitView-BIg-1tUn.js → GitView-C4xsLAUw.js} +1 -1
  10. package/dist/assets/{GuestSurfacePane-BUmmCfBg.js → GuestSurfacePane-BTyjXjRj.js} +1 -1
  11. package/dist/assets/{HelpDialog-DlCrl3jK.js → HelpDialog-jRlVnJ_e.js} +1 -1
  12. package/dist/assets/{IntegrationsCatalogView-tZTRIaCg.js → IntegrationsCatalogView-CjJ3sWIM.js} +1 -1
  13. package/dist/assets/{JsonTreeView-D5DVoS6l.js → JsonTreeView-C7EScp5B.js} +1 -1
  14. package/dist/assets/{MarkdownDiffPreview-DoMO0ER1.js → MarkdownDiffPreview-cPqaSgaj.js} +1 -1
  15. package/dist/assets/{MarkdownRendererImpl-D1KCox5d.js → MarkdownRendererImpl-BcJ1sqsU.js} +3 -3
  16. package/dist/assets/{MemoryDebugPanel-X5DD6Cjd.js → MemoryDebugPanel-D0N9KDmI.js} +1 -1
  17. package/dist/assets/{NoteEditor-_UWC0M0H.js → NoteEditor-DxvVLbA7.js} +1 -1
  18. package/dist/assets/{OnboardingScreen-DBSPDpEj.js → OnboardingScreen-CMeQdpeM.js} +1 -1
  19. package/dist/assets/{OpenCodeStatusDialog-e8gdYqEY.js → OpenCodeStatusDialog-BAv0K4eb.js} +1 -1
  20. package/dist/assets/{OverviewView-Cf5_Harr.js → OverviewView-DyDBexdg.js} +1 -1
  21. package/dist/assets/{PatchDiff-DIWEk4tG.js → PatchDiff-CvabHkAC.js} +1 -1
  22. package/dist/assets/{PlanView-CV7_x4Hj.js → PlanView-DPpR2O_F.js} +1 -1
  23. package/dist/assets/{ProjectActionsDialog-B90g1jby.js → ProjectActionsDialog-B96GmKCc.js} +1 -1
  24. package/dist/assets/{ReplyUiBlock-D2m0ZgRL.js → ReplyUiBlock-BuiEYmcz.js} +1 -1
  25. package/dist/assets/{ReviewCards-D--SZYNA.js → ReviewCards-B219SHVL.js} +1 -1
  26. package/dist/assets/{RunOverview-CGv4KD-i.js → RunOverview-6n10wBYl.js} +1 -1
  27. package/dist/assets/{ScheduledTasksDialog-XjiWbQnf.js → ScheduledTasksDialog-CTkrlYii.js} +1 -1
  28. package/dist/assets/{SettingsView-Cz-oULIY.js → SettingsView-CenZZQat.js} +1 -1
  29. package/dist/assets/{SettingsWindow-BHUNfQBn.js → SettingsWindow-HEw9_GIT.js} +1 -1
  30. package/dist/assets/{SidebarSectionsManager-C1YsRka1.js → SidebarSectionsManager-CEl8jV_W.js} +1 -1
  31. package/dist/assets/{SourceBoardView-Cc3LeYUo.js → SourceBoardView-CJZ3s1XD.js} +1 -1
  32. package/dist/assets/{SpaceAccessDialog-f_DzFvFs.js → SpaceAccessDialog-Ngob2qn9.js} +1 -1
  33. package/dist/assets/{SpaceApplyDialog-CddUu8PS.js → SpaceApplyDialog-BxjDC_0D.js} +1 -1
  34. package/dist/assets/{SpaceRow-DnnOnMYM.js → SpaceRow-CckOV1g8.js} +1 -1
  35. package/dist/assets/{SpaceSetupOutput-BzQQtLdO.js → SpaceSetupOutput-lGqiVX-3.js} +1 -1
  36. package/dist/assets/{SpacesView-BZhH9crf.js → SpacesView-CP5k-k3v.js} +1 -1
  37. package/dist/assets/{SubmoduleDiffSummary-D6Wu1QuT.js → SubmoduleDiffSummary-Cdi9S4gX.js} +1 -1
  38. package/dist/assets/{ToolOutputDialog-BkmKHRdh.js → ToolOutputDialog-08mv6_M5.js} +1 -1
  39. package/dist/assets/{ToolPartDiffPreview-BurYz6UW.js → ToolPartDiffPreview-DRL47sfe.js} +1 -1
  40. package/dist/assets/{UiBlock-Bwx-T68z.js → UiBlock-C47vwIuG.js} +1 -1
  41. package/dist/assets/{UsageStatsView-WPrhgORf.js → UsageStatsView-DCpTVWz3.js} +1 -1
  42. package/dist/assets/{WalkthroughView-BMD1xSij.js → WalkthroughView-DeaBPhAn.js} +1 -1
  43. package/dist/assets/{WorktreesView-BFut-2yK.js → WorktreesView-B1YD_EPW.js} +1 -1
  44. package/dist/assets/{appThemeRegistry-Dk6CF03D.js → appThemeRegistry-hfPZ6say.js} +1 -1
  45. package/dist/assets/{ar-CuYBgoCL.js → ar-BrwaPZTB.js} +1 -1
  46. package/dist/assets/{codeHighlight-BYbxdxkk.js → codeHighlight-CXtTq4co.js} +1 -1
  47. package/dist/assets/{computeVirtualFileMetrics-COD-bZRh.js → computeVirtualFileMetrics-vVCRMHlo.js} +2 -2
  48. package/dist/assets/{contextFileOpenGuard-D_Eh6QOM.js → contextFileOpenGuard-BrUXbAMg.js} +1 -1
  49. package/dist/assets/{date-time-KFcfG8FZ.js → date-time-t6mCSZMr.js} +1 -1
  50. package/dist/assets/{de-Jo819vpe.js → de-DM_yQ7AG.js} +1 -1
  51. package/dist/assets/{es-CV0MRSsN.js → es-DMJlwy06.js} +1 -1
  52. package/dist/assets/{fileContentPoller-dM2aYiRt.js → fileContentPoller-B_D2WQHm.js} +1 -1
  53. package/dist/assets/{flexokiTheme-BL4fG_5M.js → flexokiTheme-DJhpTHWO.js} +1 -1
  54. package/dist/assets/{fr-CdmUjdKh.js → fr-BKEy-Z_2.js} +1 -1
  55. package/dist/assets/{he-B0Jv5rnl.js → he-BnqH_lWh.js} +1 -1
  56. package/dist/assets/{highlights-Cz6HBqYD.js → highlights-hXz5ezHu.js} +1 -1
  57. package/dist/assets/{index-BaQtYnl3.js → index-D6cItOu7.js} +1 -1
  58. package/dist/assets/{initializeSharedPreferences-CiaDh0AM.js → initializeSharedPreferences-BKG_0s4E.js} +1 -1
  59. package/dist/assets/{install-T6u73Zz0.js → install-csQoiut9.js} +1 -1
  60. package/dist/assets/{isDiffPlainText-B8tZAZQ4.js → isDiffPlainText-OMACajs1.js} +1 -1
  61. package/dist/assets/{isFilePlainText-CgNXAeJu.js → isFilePlainText-Z9Wi1AQY.js} +1 -1
  62. package/dist/assets/{ja-BGc1V8I_.js → ja-lqTz_4gG.js} +1 -1
  63. package/dist/assets/{katex.min-BM3LOlr3.js → katex.min-B7gF3rmE.js} +4 -4
  64. package/dist/assets/{ko-CadSaTs-.js → ko-DXd5Gg_L.js} +1 -1
  65. package/dist/assets/{main-b_PAxB6R.js → main-D0VV0_-r.js} +4 -4
  66. package/dist/assets/{main-BX74Pq6m.js → main-DC2rz5Pv.js} +2 -2
  67. package/dist/assets/{miniChat-CzVxcGLZ.js → miniChat-C6te7Cha.js} +2 -2
  68. package/dist/assets/{mobile-DfBoGVRE.js → mobile-h7Y89upC.js} +2 -2
  69. package/dist/assets/{nl-Ds8N-7nU.js → nl-X6CZmwET.js} +1 -1
  70. package/dist/assets/{pageTitle-DcFkBvgW.js → pageTitle-CAd4Kwsy.js} +1 -1
  71. package/dist/assets/{parseDiffFromFile-DEaa1di6.js → parseDiffFromFile-BuLpViZg.js} +1 -1
  72. package/dist/assets/{pierreDiffTint-CS5FWjsh.js → pierreDiffTint-Bda-Leur.js} +1 -1
  73. package/dist/assets/{pl-BAAqSvOD.js → pl-CmAyO7EH.js} +1 -1
  74. package/dist/assets/{pt-BR-CxTCCQt5.js → pt-BR-QNheuCzR.js} +1 -1
  75. package/dist/assets/{relocateRestoredSession-C8x_kYRX.js → relocateRestoredSession-hOOmUC2p.js} +2 -2
  76. package/dist/assets/{renderElectronMiniChatApp-Bwgx8afa.js → renderElectronMiniChatApp-Dg-2lMCR.js} +2 -2
  77. package/dist/assets/{renderMarkdownForExport-DzVoMkQY.js → renderMarkdownForExport-Dy3HSiOK.js} +1 -1
  78. package/dist/assets/{renderMobileApp-0o5iW3gX.js → renderMobileApp-BhpguGxm.js} +3 -3
  79. package/dist/assets/{resolveLanguages-O4KbMEYv.js → resolveLanguages-BF-kRWyQ.js} +1 -1
  80. package/dist/assets/{runtimeEndpointReset-IJE1o-nk.js → runtimeEndpointReset-DUwSilpj.js} +8 -8
  81. package/dist/assets/{scheduledTasksApi-Bt4F6fco.js → scheduledTasksApi-jkEn2fUL.js} +1 -1
  82. package/dist/assets/{shiki-DfHQjW4b.js → shiki-D0FPzA_f.js} +1 -1
  83. package/dist/assets/{space-apply-BWMKP1l4.js → space-apply-De-hlG-f.js} +1 -1
  84. package/dist/assets/{space-close-B5_k2AhX.js → space-close-BQzjlZ-w.js} +1 -1
  85. package/dist/assets/{spaceNetwork-Bww_OVgL.js → spaceNetwork-CVVlgvhL.js} +1 -1
  86. package/dist/assets/{stream-tokenizer-B87hBGmH.js → stream-tokenizer-w3w2i3zK.js} +1 -1
  87. package/dist/assets/{textMateThemeFromAppTheme-BA68BaAw.js → textMateThemeFromAppTheme-B38k_gpV.js} +1 -1
  88. package/dist/assets/{tr-vj7L-0nl.js → tr-4WQrywE1.js} +1 -1
  89. package/dist/assets/{uk-DYlYVGgJ.js → uk-Dos-a0OZ.js} +1 -1
  90. package/dist/assets/{useAppFontEffects-UKWR--vP.js → useAppFontEffects-6HvTeJY2.js} +15 -15
  91. package/dist/assets/{useBranchPullRequestRequest-DJNOWuS3.js → useBranchPullRequestRequest-B8yYsqiw.js} +1 -1
  92. package/dist/assets/{useCallableModelProviders-BVbgbn_M.js → useCallableModelProviders-BLdr2CgV.js} +1 -1
  93. package/dist/assets/{useDiffFindSurface-zju_sQ6_.js → useDiffFindSurface-BVO1E6le.js} +1 -1
  94. package/dist/assets/{useGitCleanLine-DA-nRAvz.js → useGitCleanLine-DEZFq7uh.js} +1 -1
  95. package/dist/assets/{useInlineCommentController-DgJBL64V.js → useInlineCommentController-BiX7K5jy.js} +1 -1
  96. package/dist/assets/{useMarkdownLocalAssets-DFwvtvsy.js → useMarkdownLocalAssets-DM7b941V.js} +1 -1
  97. package/dist/assets/{useRootScrollLock-ywfMiLmM.js → useRootScrollLock-BrNPOsn7.js} +2 -2
  98. package/dist/assets/{useWalkthroughReview-DeioHUwn.js → useWalkthroughReview-kBvgTX6M.js} +1 -1
  99. package/dist/assets/{useWholeFileComment-3Adypnae.js → useWholeFileComment-DrynMs0_.js} +1 -1
  100. package/dist/assets/{useWorktreeArchiveActions-D57vyZ1C.js → useWorktreeArchiveActions-CewTlnGF.js} +1 -1
  101. package/dist/assets/{vendor-codemirror-language-data-CVww3XgZ.js → vendor-codemirror-language-data-BJfFTbvV.js} +2 -2
  102. package/dist/assets/{zh-CN-CNdkQtjY.js → zh-CN-C4Ip1vNN.js} +1 -1
  103. package/dist/assets/{zh-TW-njZbI3nO.js → zh-TW-BmwR7rb1.js} +1 -1
  104. package/dist/index.html +2 -2
  105. package/dist/mini-chat.html +2 -2
  106. package/dist/mobile.html +2 -2
  107. package/package.json +3 -3
@@ -1,8 +1,8 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-BIg-1tUn.js","assets/vendor-react--VO_rL_p.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-UKWR--vP.js","assets/katex.min-BM3LOlr3.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-C9tWdk0j.js","assets/vendor-zod-Csf1sqWl.js","assets/vendor-opencode-client-CqFY51gT.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/vendor-streamdown-BbSYZ3NF.js","assets/vendor-markdown-BTUqNk6W.js","assets/vendor-mdast-util-from-markdown-CZHjOE75.js","assets/vendor-micromark-util-decode-numeric-character-reference-CNs1qBpV.js","assets/vendor-micromark-util-decode-string-fHsnqYdj.js","assets/vendor-decode-named-character-reference-C3-224fz.js","assets/vendor-micromark-util-normalize-identifier-C9ANKk3v.js","assets/vendor-micromark-AWM-NZXP.js","assets/vendor-micromark-util-combine-extensions-d8XJZrgA.js","assets/vendor-micromark-util-chunked-DrRIdSP-.js","assets/vendor-micromark-factory-space-PzSHLgmq.js","assets/vendor-micromark-util-character-CW3Cu1MS.js","assets/vendor-micromark-core-commonmark-kzTLNXAm.js","assets/vendor-micromark-util-classify-character-tcLuZZwM.js","assets/vendor-micromark-util-resolve-all-PQCKh0dx.js","assets/vendor-micromark-util-subtokenize-BF1Jf29a.js","assets/vendor-micromark-factory-destination-Sj0xfi0V.js","assets/vendor-micromark-factory-label-amyP0HdC.js","assets/vendor-micromark-factory-title-khnLkZK6.js","assets/vendor-micromark-factory-whitespace-eIB00uTl.js","assets/vendor-micromark-util-html-tag-name-DbKNfynz.js","assets/vendor-unist-util-stringify-position-Ch_qCilz.js","assets/vendor-mdast-util-to-string-C_aolqmU.js","assets/vendor-unist-util-visit-DhPeCsfG.js","assets/vendor-unist-util-visit-parents-DlviEg7Z.js","assets/vendor-unist-util-is-BPZGFiMU.js","assets/vendor-hast-util-raw-DvvLJg15.js","assets/vendor-ungap-structured-clone--gfxRhYI.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-parse5-DwmzEj2o.js","assets/vendor-entities-wUUgTZDW.js","assets/vendor-web-namespaces-bsVAaBS1.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-unist-util-position-60F3QETU.js","assets/vendor-hast-util-from-parse5-Ba3T6RJI.js","assets/vendor-devlop-0Dp3JUBc.js","assets/vendor-property-information-Boo8Xpef.js","assets/vendor-hastscript-BrPNioaz.js","assets/vendor-comma-separated-tokens-CRUGqg4f.js","assets/vendor-space-separated-tokens-D7QSIrTI.js","assets/vendor-hast-util-parse-selector-TXfch5wI.js","assets/vendor-vfile-location-LfEFwJ2h.js","assets/vendor-hast-util-to-parse5-BoysVIPW.js","assets/vendor-hast-util-sanitize-2aGO5ay8.js","assets/vendor-micromark-extension-gfm-CsfPlnlB.js","assets/vendor-micromark-extension-gfm-autolink-literal-BYug7onl.js","assets/vendor-micromark-extension-gfm-footnote-OFl1FCH2.js","assets/vendor-micromark-extension-gfm-strikethrough-CyFiuwBf.js","assets/vendor-micromark-extension-gfm-table-dgw4LfUw.js","assets/vendor-micromark-extension-gfm-task-list-item-Dnadzr9U.js","assets/vendor-mdast-util-gfm-CroMDYLM.js","assets/vendor-mdast-util-gfm-autolink-literal-CTruMtvI.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-mdast-util-find-and-replace-DB9iC-bx.js","assets/vendor-escape-string-regexp-BaJN9MlJ.js","assets/vendor-mdast-util-gfm-footnote-C-csI7OF.js","assets/vendor-mdast-util-gfm-strikethrough-BcskTdio.js","assets/vendor-mdast-util-gfm-table-DhPwQIyj.js","assets/vendor-markdown-table-DvhhVmnL.js","assets/vendor-mdast-util-to-markdown-Cl3qaiyc.js","assets/vendor-longest-streak-CtXnX3Xp.js","assets/vendor-mdast-util-phrasing-4oVbNLC3.js","assets/vendor-mdast-util-gfm-task-list-item-DMU5mK_M.js","assets/vendor-mdast-util-to-hast-CWnLaQSO.js","assets/vendor-micromark-util-sanitize-uri-BbwQ7CLk.js","assets/vendor-trim-lines-D8znQY54.js","assets/vendor-micromark-extension-cjk-friendly-BzZDGrF5.js","assets/vendor-micromark-extension-cjk-friendly-util-D5lVNoxW.js","assets/vendor-get-east-asian-width-CPhS2cOv.js","assets/vendor-micromark-util-symbol-JJPacVTp.js","assets/vendor-mdast-util-to-markdown-cjk-friendly-BZ3pe_qd.js","assets/vendor-micromark-extension-cjk-friendly-gfm-strikethrough-CqW-Ep4M.js","assets/vendor-mdast-util-to-markdown-cjk-friendly-gfm-strikethrough-BdPDQFO7.js","assets/vendor-hast-util-from-html-isomorphic-B0Kn01s9.js","assets/vendor-hast-util-from-dom-DeNf9aYW.js","assets/vendor-katex-DBqql0K7.js","assets/vendor-hast-util-to-text-0GXLnBvt.js","assets/vendor-hast-util-is-element-CuOmiqQi.js","assets/vendor-unist-util-find-after-CMaZmLxc.js","assets/vendor-micromark-extension-math-BRFoDziv.js","assets/vendor-mdast-util-math-wB-IJCL0.js","assets/vendor-remend-r8cP_t-e.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-marked-DN3zOnEe.js","assets/vendor-hast-util-to-jsx-runtime-Bq6JeJCx.js","assets/vendor-style-to-js-CI2G4dgu.js","assets/vendor-style-to-object-BAv4SQXc.js","assets/vendor-inline-style-parser-BlqBsVO4.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-estree-util-is-identifier-name-BgBfM8ME.js","assets/vendor-vfile-message-DqhD22jI.js","assets/vendor-unified-1CQKw2_w.js","assets/vendor-bail-FqpXQuLt.js","assets/vendor-extend-B94qxKr5.js","assets/vendor-is-plain-obj-C1gvLhAf.js","assets/vendor-trough-B_b8ryxu.js","assets/vendor-vfile-BCWrK60u.js","assets/vendor-html-url-attributes-D46m5wfe.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/katex-Dejpsg4Y.css","assets/vendor-base-ui-zhBy6TEG.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-Cy8dRGoy.js","assets/vendor-use-sync-external-store-CfLJGVyr.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-dnd-kit-core-Br1Cs7RV.js","assets/vendor-dnd-kit-utilities-DZ9KbT5S.js","assets/vendor-dnd-kit-accessibility-CYclfhtC.js","assets/vendor-dnd-kit-sortable-DpfLEOLv.js","assets/vendor-tanstack-react-virtual-CqfECoM0.js","assets/vendor-tanstack-virtual-core-BdFnkr_2.js","assets/vendor-framer-motion-C_wK4GIM.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-CjjsURR-.js","assets/vendor-codemirror-state-Cd8udR5z.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-Ciie9ey-.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-8HZTPOnt.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CZEcqU6G.js","assets/vendor-codemirror-streamparser-CmlTsbN2.js","assets/vendor-codemirror-lang-javascript-DmqaSK_j.js","assets/vendor-lezer-javascript-CWSwshuO.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BGedy2gC.js","assets/vendor-codemirror-lang-json-DVAYKmoO.js","assets/vendor-lezer-json-Cn1mncjr.js","assets/vendor-codemirror-lang-css-BLpgXfL2.js","assets/vendor-lezer-css-B2Hx_Nps.js","assets/vendor-codemirror-lang-html-S3jxr3Mo.js","assets/vendor-lezer-html-Cr8K5DGw.js","assets/vendor-codemirror-lang-markdown-D1jveRI5.js","assets/vendor-lezer-markdown-TQKzBB8i.js","assets/vendor-codemirror-language-data-CVww3XgZ.js","assets/vendor-codemirror-lang-python-B-5UC9Ui.js","assets/vendor-lezer-python-BUoImtUb.js","assets/vendor-sonner-Dw26OnzC.js","assets/vendor-cmdk-BtSpU-Io.js","assets/vendor-radix-ui-react-dialog-OIW6VLWw.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-D4RvEbuR.js","assets/vendor-radix-ui-react-context-BbFoxCHu.js","assets/vendor-radix-ui-react-id-aGag8i_5.js","assets/vendor-radix-ui-react-use-layout-effect-B1oLzD-j.js","assets/vendor-radix-ui-react-use-controllable-state-BjnNPGHq.js","assets/vendor-radix-ui-react-dismissable-layer-DpT6mMbO.js","assets/vendor-radix-ui-react-primitive-CrN9dRDb.js","assets/vendor-radix-ui-react-slot-BjbalUfz.js","assets/vendor-radix-ui-react-use-callback-ref-CcC_buIU.js","assets/vendor-radix-ui-react-use-escape-keydown-Cp1WWKTC.js","assets/vendor-radix-ui-react-focus-scope-D1noLHmd.js","assets/vendor-radix-ui-react-portal-BlUEzfrF.js","assets/vendor-radix-ui-react-presence-BGqFfiW4.js","assets/vendor-radix-ui-react-focus-guards-CSS2IbZC.js","assets/vendor-react-remove-scroll-Der_cv-1.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-Clwl9llp.js","assets/vendor-react-style-singleton-D_xJlTqU.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-BdLl6ZIw.js","assets/vendor-use-callback-ref-CXJF1lEr.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-legendapp-list-wfKYGEOv.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeEndpointReset-IJE1o-nk.js","assets/space-apply-BWMKP1l4.js","assets/runtimeEndpointReset-uDNKGwhp.css","assets/useGitCleanLine-DA-nRAvz.js","assets/useBranchPullRequestRequest-DJNOWuS3.js","assets/parseDiffFromFile-DEaa1di6.js","assets/computeVirtualFileMetrics-COD-bZRh.js","assets/themeResolver-DXizngAV.js","assets/vendor-pierre-theming-D_TRfu0q.js","assets/hastToHtml-BHV14OWE.js","assets/vendor-hast-util-to-html-Jw3IXh58.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-diff-C3JhlQdm.js","assets/isDiffPlainText-B8tZAZQ4.js","assets/getFiletypeFromFileName-BgI9McTw.js","assets/pierreDiffTint-CS5FWjsh.js","assets/ReviewCards-D--SZYNA.js","assets/useInlineCommentController-DgJBL64V.js","assets/appThemeRegistry-Dk6CF03D.js","assets/textMateThemeFromAppTheme-BA68BaAw.js","assets/diffsHighlighter-BsxkaI3Q.js","assets/ChangedPathLabel-BZHIGJ_0.js","assets/useRootScrollLock-ywfMiLmM.js","assets/contextFileOpenGuard-D_Eh6QOM.js","assets/WalkthroughView-BMD1xSij.js","assets/ChangeRequestDiffUnavailable-uZ8LXZIU.js","assets/useDiffFindSurface-zju_sQ6_.js","assets/useWalkthroughReview-DeioHUwn.js","assets/useCallableModelProviders-BVbgbn_M.js","assets/useWholeFileComment-3Adypnae.js","assets/DiffView-CIlNcbDh.js","assets/SubmoduleDiffSummary-D6Wu1QuT.js","assets/FilesView-VMk-uSwN.js","assets/flexokiTheme-BL4fG_5M.js","assets/vendor-codemirror-search-Bk6iB2TM.js","assets/vendor-replit-codemirror-vim-BpSlt2iY.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useMarkdownLocalAssets-DFwvtvsy.js","assets/fileContentPoller-dM2aYiRt.js","assets/JsonTreeView-D5DVoS6l.js","assets/useNextRenderData-CVFf78p9.js","assets/isFilePlainText-CgNXAeJu.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/codeHighlight-BYbxdxkk.js","assets/vendor-react-drawio-C6TkEvnS.js","assets/vendor-codemirror-lint-aq8IpR1c.js","assets/scheduledTasksApi-Bt4F6fco.js","assets/GuestSurfacePane-BUmmCfBg.js","assets/SettingsWindow-BHUNfQBn.js","assets/SettingsView-Cz-oULIY.js","assets/install-T6u73Zz0.js","assets/vendor-yaml-CE-D_49-.js","assets/vendor-qrcode-Cl8OheHW.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/pageTitle-DcFkBvgW.js","assets/SpaceRow-DnnOnMYM.js","assets/AboutLogo-Bghz4cno.js","assets/CommandPalette-DjCVXkJM.js","assets/HelpDialog-DlCrl3jK.js","assets/ProjectActionsDialog-B90g1jby.js","assets/OpenCodeStatusDialog-e8gdYqEY.js","assets/RunOverview-CGv4KD-i.js","assets/ScheduledTasksDialog-XjiWbQnf.js","assets/vendor-cron-parser-1X50-i0r.js","assets/vendor-luxon-BZ0puJYg.js","assets/date-time-KFcfG8FZ.js","assets/ArchiveView-SQdNDg7X.js","assets/useWorktreeArchiveActions-D57vyZ1C.js","assets/IntegrationsCatalogView-tZTRIaCg.js","assets/UsageStatsView-WPrhgORf.js","assets/SourceBoardView-Cc3LeYUo.js","assets/OverviewView-Cf5_Harr.js","assets/WorktreesView-BFut-2yK.js","assets/SpacesView-BZhH9crf.js","assets/SpaceAccessDialog-f_DzFvFs.js","assets/spaceNetwork-Bww_OVgL.js","assets/SpaceApplyDialog-CddUu8PS.js","assets/SpaceSetupOutput-BzQQtLdO.js","assets/OnboardingScreen-DBSPDpEj.js","assets/AboutDialog-D-IujH5P.js","assets/MemoryDebugPanel-X5DD6Cjd.js"])))=>i.map(i=>d[i]);
2
- import{f as $e,j as s,R as l,r as qt,a as Hl,h as Tu}from"./vendor-react--VO_rL_p.js";import{bk as Yr,n as Xt,k as ls,ct as Nu,cu as ql,u as X,bi as Bs,aI as ns,aT as Jr,c3 as cs,cv as vi,aO as Qr,cw as Eu,bV as Kl,cx as wt,cy as Iu,bf as qo,l as Si,bg as Zs,bh as Cr,bH as Pu,bl as Gl,cz as ki,bd as ji,cA as Ru,co as Zl,bQ as ra,aR as Xl,cB as Du,cC as ur,cD as Mr,cE as er,cF as Au,cG as Kn,cH as _u,cI as Ko,cJ as xr,cK as Ci,cL as eo,cM as Pn,a_ as Fr,j as zs,cN as Cn,cO as Ou,cP as ks,b as dn,cQ as to,cR as Mu,cS as Gs,cT as Fu,cU as Yl,cV as Lu,cW as $u,cX as Jl,cY as Bu,c6 as zu,bU as Wu,b_ as Uu,bX as Vu,be as Hu,bp as gs,t as Go,bY as qu,cZ as Ku,c_ as Gu,bu as Zo,c$ as Ti,d0 as Zu,bb as Xu,b0 as oa,cn as Ql,d1 as ia,aK as ec,d2 as Yu,v as tc,bZ as Ju,d3 as aa,bA as Ni,d4 as sc,bJ as Qu,aJ as ef,q as tf,m as sf,bj as nc,cb as la,cc as rc,cr as nf,c4 as rf,c8 as ca,d5 as of,d6 as af,bF as lf,bD as cf,d7 as df,bK as uf,ca as ff,d8 as pf,d9 as mf,da as hf,db as da,dc as Co,dd as ua,de as fa,df as gf,bn as pa,dg as bf,dh as xf,bo as ma,di as wf,bE as yf,i as vf,a as Sf}from"./katex.min-BM3LOlr3.js";import{_ as Ot}from"./vendor-vite-runtime-DD1OZmLC.js";import{bt as kf,bu as oc,aC as ic,bv as as,r as ha,bw as jf,aE as Cf,bx as ga,aF as ba,U as ac,W as lc,Y as cc,V as dc,Q as Ei,$ as uc,Z as fc,X as pc,as as Tf,at as Nf,ax as Ef,ay as If,al as Pf,av as Rf,au as Df,N as Af,P as _f,a1 as Of,a0 as Mf,b7 as Ff,by as mc,bz as Tr,bA as hc,bB as Lf,bC as gc,bD as xn,bE as xa,bF as wa,bG as To,bH as ya,aw as Nr,b4 as $f,b5 as Bf,aA as zf,bp as Wf,bq as bc,bI as Uf,b6 as Vf,bJ as Hf,bK as qf,bL as va,bM as No,bN as sn,bO as wn,bP as Kf,bQ as Sa,bR as Gf,bS as Zf,bT as Xf,bU as Yf,bV as Jf,bW as Qf,bX as ep,bY as ka,bZ as tp,b_ as sp,b8 as np,b2 as rp,bo as op,b9 as ip,br as ap,b$ as lp,bk as cp,bl as dp,aD as xc,c0 as up,c1 as fp,c2 as pp,c3 as mp,c4 as hp,bn as gp,c5 as bp,bg as xp,c6 as wp,c7 as yp,bd as vp,bb as Sp,bc as kp,ba as jp,be as Cp,bs as Tp,bj as Np,bi as Ep,bm as Ip,c8 as Pp,c9 as Rp}from"./runtimeEndpointReset-IJE1o-nk.js";import{fM as ja,aM as so,Y as ts,$ as et,cf as fr,Q as Le,ft as Dp,cg as Ap,I as se,fu as _p,u as at,kn as nn,X as ps,ko as Op,av as xs,ay as Ts,aw as Ii,kp as wc,b7 as Ys,fL as yc,fK as Mp,bp as Fp,kq as vc,kr as Lp,ks as $p,bd as pr,ab as Ft,aa as Lt,ac as $t,j3 as Ws,cj as Sc,kt as Bp,ku as zp,b4 as Wp,A as Re,co as kc,jy as Up,kv as jc,bv as Vp,kw as Hp,kx as qp,jj as Cc,ky as Kp,aK as Vs,eJ as Gp,au as Zp,bg as Cs,b2 as no,be as ro,j5 as Tn,bf as oo,kz as Xp,kA as io,kB as Yp,kC as Jp,aL as gn,kD as Qp,eN as Tc,kE as em,hm as mr,hn as ao,ca as Lr,eO as tm,kF as sm,kG as nm,kH as rm,kI as om,kJ as im,kK as am,kL as lm,kM as Pi,kN as cm,kO as dm,kP as um,jB as fm,kQ as pm,bN as Ri,eS as mm,kR as hm,t as tr,q as sr,D as nr,l as rr,F as or,o as $r,B as dt,kS as Rn,a2 as pn,a3 as mn,a4 as hn,a5 as Gt,ad as un,kT as Nc,kU as Di,n as hs,a_ as Qt,kV as Ec,kW as gm,cu as Ic,kX as bm,kY as xm,bE as Es,kZ as wm,bS as fn,k_ as Ca,bK as Er,k$ as ym,fy as vm,b$ as Ai,l0 as Sm,l1 as Pc,l2 as _i,dI as km,di as Br,dO as Rc,dC as Oi,dD as Mi,l3 as Dc,y as Dn,C as Xo,gP as jm,hk as Cm,g_ as Tm,hE as Nm,l4 as Em,gx as Ac,bG as $s,K as Fi,bB as Im,aq as ys,bF as _c,bU as Ta,bT as Vn,gy as Pm,bV as Rm,c6 as Li,c1 as Dm,gA as Eo,l5 as Am,z as _m,bq as Om,br as Mm,bs as Fm,bt as Lm,bu as $m,cS as Na,bL as Oc,bI as zr,l6 as Bm,l7 as zm,l8 as Wm,dz as On,bz as Um,bC as lo,bD as Vm,bH as Hm,aJ as An,ht as qm,bJ as Km,gC as Gm,c0 as co,l9 as Mc,la as Fc,lb as Zm,dv as Xm,dr as Ym,du as Jm,lc as Qm,dE as eh,ds as Ea,ld as th,hN as sh,le as nh,lf as rh,dt as Ia,dN as oh,dx as ih,a$ as ah,lg as lh,lh as ch,li as dh,lj as $i,lk as Bi,ll as uh,lm as fh,ln as ph,lo as mh,lp as hh,k6 as zi,lq as gh,lr as bh,ls as xh,lt as wh,lu as Wi,lv as yh,bA as vh,lw as Sh,lx as kh,aY as Lc,ly as $c,bo as jh,lz as Ch,x as Bc,lA as Th,lB as kn,aI as Nh,ao as Eh,lC as Ih,V as zt,lD as Ph,d3 as Rh,cG as Dh,lE as zc,lF as Ah,lG as Ir,lH as yn,iU as _h,lI as cn,cV as Oh,lJ as Mh,lK as Wc,jI as Uc,eE as uo,dH as Fh,d9 as Lh,lL as Ui,lM as $h,f9 as Js,lN as Vc,bh as Bh,lO as zh,lP as Wh,lQ as Uh,lR as Io,lS as Vh,lT as Hh,em as qh,eF as Kh,gj as Vi,gg as Gh,j4 as Zh,j6 as Xh,lU as ir,gf as Hc,ge as qc,j7 as Yh,j8 as Jh,gh as Qh,eq as eg,aZ as tg,aN as sg,lV as Po,lW as ng,lX as rg,lY as Kc,lZ as Gc,l_ as og,l$ as ig,m0 as Yo,m1 as Ks,dm as ag,m2 as lg,m3 as Pa,m4 as cg,m5 as dg,bc as Wr,m6 as Ra,m7 as ug,m8 as fg,m9 as pg,jn as mg,ma as hg,jo as Da,jp as gg,c_ as bg,cl as Aa,jq as xg,jr as wg,mb as yg,js as vg,mc as Sg,bn as kg,k as jg,jM as Cg,md as Ro,me as _a,fi as Tg,fR as Jo,mf as Zc,ir as fo,mg as Ng,iN as Eg,mh as Ig,mi as Xc,mj as Pg,mk as Yc,ep as Rg,eo as Hi,en as qi,et as Dg,ml as Oa,mm as Ag,mn as _g,er as Og,G as Qo,mo as Jc,bX as Qc,bY as ed,mp as ei,bZ as td,jg as sd,mq as Do,mr as Mg,fQ as Fg,jL as Lg,a0 as $g,ms as Bg,mt as zg,mu as nd,b8 as Ma,eb as Wg,eu as Ug,jd as Vg,mv as Hg,je as qg,mw as Kg,mx as Gg,km as Zg,d4 as Fa,my as Xg,ji as Yg,mz as Jg,k7 as Qg,eX as eb,mA as tb,fb as La,eC as sb,eY as nb,e_ as rb,eZ as ob,f6 as ib,f5 as ab,e$ as lb,k8 as cb,f4 as db,f0 as ub,f1 as fb,f2 as pb,f3 as mb,a as hb,s as gb,b as bb,c as xb,kf as wb,ah as yb,fe as vb,ff as Sb,fg as kb}from"./useAppFontEffects-UKWR--vP.js";import{f as rd,u as od,S as jb,W as id,a as Cb,G as Tb,b as Nb,c as Eb}from"./useRootScrollLock-ywfMiLmM.js";import{h as ad,i as Ur,T as ld,M as cd,D as dd,f as ti}from"./vendor-dnd-kit-core-Br1Cs7RV.js";import{r as Ib,h as Pb,u as ud,S as fd,v as Rb,a as Db}from"./vendor-dnd-kit-sortable-DpfLEOLv.js";import{C as pd}from"./vendor-dnd-kit-utilities-DZ9KbT5S.js";import{S as Ab,M as _b,C as Ob,i as Mb,j as Fb,k as Lb}from"./vendor-base-ui-zhBy6TEG.js";import{a as rn,O as $b,d as Bb,D as zb,b as Wb,v as $a,t as Ba,u as Ub,m as za}from"./contextFileOpenGuard-D_Eh6QOM.js";import{u as si,c as po,p as Vb}from"./vendor-zustand-C9tWdk0j.js";import{o as Qs,s as Ns,n as mo,d as md,f as Hb,e as ar,a as ni}from"./vendor-zod-Csf1sqWl.js";import{u as qb}from"./vendor-tanstack-react-virtual-CqfECoM0.js";import{d as Kb,m as Gb}from"./vendor-tanstack-virtual-core-BdFnkr_2.js";const hd=t=>`${t}|chats`,Zb=(t,e)=>{if(Yr(e))return hd(t);const n=Xt(e);return n?`${t}|${n}`:null},Xb=(t,e,n)=>{const r=Xt(t);return!r||Yr(r)?[]:n.some(o=>Xt(o)===r)?[]:e.filter(o=>!o.parentID&&!o.time?.archived&&Xt(o.directory??null)===r).sort((o,i)=>ja(i)-ja(o)).map(o=>o.id)};function Yb(t){const e=$e.c(37),{directory:n,className:r}=t,{currentTheme:o}=so(),i=ts(e1),a=et(Qb),u=ls(Jb),c=Nu(n);let d;e[0]!==n||e[1]!==u?(d=ql(n,u),e[0]=n,e[1]=u,e[2]=d):d=e[2];const f=d;let p;e[3]!==n||e[4]!==f||e[5]!==i||e[6]!==c||e[7]!==a?(p=f||!n?null:fr(i,a,n,c),e[3]=n,e[4]=f,e[5]=i,e[6]=c,e[7]=a,e[8]=p):p=e[8];const m=p;if(f){let D;e[9]!==r?(D=Le("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),e[9]=r,e[10]=D):D=e[10];let y;return e[11]!==D?(y=s.jsx(se,{name:"chat-4",className:D}),e[11]=D,e[12]=y):y=e[12],y}if(!m)return null;const h=m.icon?Dp[m.icon]:null;let b;e[13]!==m.color?(b=Ap(m.color)??void 0,e[13]=m.color,e[14]=b):b=e[14];const g=b;let x;e[15]!==r||e[16]!==g||e[17]!==h?(x=h?s.jsx(se,{name:h,className:Le("h-3.5 w-3.5 shrink-0",r),style:g?{color:g}:void 0}):s.jsx(se,{name:"folder",className:Le("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),style:g?{color:g}:void 0}),e[15]=r,e[16]=g,e[17]=h,e[18]=x):x=e[18];const w=x;if(!m.iconImage)return w;let T;e[19]!==r?(T=Le("inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",r),e[19]=r,e[20]=T):T=e[20];let k;e[21]!==m.iconBackground?(k=m.iconBackground?{backgroundColor:m.iconBackground}:void 0,e[21]=m.iconBackground,e[22]=k):k=e[22];let E;e[23]!==m.iconImage||e[24]!==m.id?(E={id:m.id,iconImage:m.iconImage},e[23]=m.iconImage,e[24]=m.id,e[25]=E):E=e[25];let F;e[26]!==o.colors.surface.foreground||e[27]!==o.metadata.variant?(F={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[26]=o.colors.surface.foreground,e[27]=o.metadata.variant,e[28]=F):F=e[28];let _;e[29]!==w||e[30]!==E||e[31]!==F?(_=s.jsx(_p,{project:E,options:F,className:"h-full w-full object-contain",fallback:w}),e[29]=w,e[30]=E,e[31]=F,e[32]=_):_=e[32];let A;return e[33]!==T||e[34]!==k||e[35]!==_?(A=s.jsx("span",{className:T,style:k,children:_}),e[33]=T,e[34]=k,e[35]=_,e[36]=A):A=e[36],A}function Jb(t){return t.homeDirectory}function Qb(t){return t.availableWorktreesByProject}function e1(t){return t.projects}const Hn=24,t1=(t,e,n=Hn)=>{const r=e.right-(t.right-n);if(r>0)return r;const o=e.left-(t.left+n);return o<0?o:0},s1=({transform:t})=>({...t,y:0}),n1=16,r1=t=>{if(t.shiftKey||t.ctrlKey||t.metaKey||Math.abs(t.deltaY)<=Math.abs(t.deltaX))return;const e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?t.deltaY*n1:t.deltaY;t.currentTarget.scrollLeft+=Jr(t.currentTarget)?-e:e},o1={Item:({className:t,...e})=>s.jsx(_b,{className:Le($p,t),...e}),Separator:({className:t,...e})=>s.jsx(Ab,{className:Le(Lp,t),...e})},i1=t=>{const e=$e.c(127),{tab:n,tabNumber:r,isActive:o,isPreview:i,suppressControls:a,onSelect:u,onPin:c,onClose:d,renderMenu:f,closeOtherTabs:p,onMenuOpenChangeComplete:m,children:h}=t,{t:b}=at(),g=X(l1);let x;e[0]!==g?(x=Ii("switch_session_tab",g),e[0]=g,e[1]=x):x=e[1];const w=x;let T;e[2]!==r||e[3]!==w?(T=w&&w!==wc&&r<=9?xs(`${w}+${r}`):void 0,e[2]=r,e[3]=w,e[4]=T):T=e[4];const k=T,[E,F]=l.useState(!1);let _;e[5]!==n.id?(_={id:n.id},e[5]=n.id,e[6]=_):_=e[6];const{attributes:A,listeners:D,setNodeRef:y,transform:N,transition:j,isDragging:v}=ud(_);let M;e[7]!==b||e[8]!==n.session.title?(M=n.session.title?.trim()||b("sessions.sidebar.session.untitled"),e[7]=b,e[8]=n.session.title,e[9]=M):M=e[9];const W=M,G=n.id;let O;e[10]!==n.session?(O=Ys(n.session),e[10]=n.session,e[11]=O):O=e[11];const Z=oc(G,O),Q=yc(n.id),B=Q!==null,H=Mp(n.id)&&!o&&!B,P=B||H;let te;e[12]!==u||e[13]!==n?(te=()=>u(n),e[12]=u,e[13]=n,e[14]=te):te=e[14];let J;e[15]!==p||e[16]!==n.id?(J=()=>p(n.id),e[15]=p,e[16]=n.id,e[17]=J):J=e[17];let le,K,U,$,ee,Y,ie,V,fe,Se,Te,ue,Me,Ae,De,Be,we,ve,Pe,he;if(e[18]!==A||e[19]!==h||e[20]!==E||e[21]!==o||e[22]!==Z||e[23]!==v||e[24]!==i||e[25]!==D||e[26]!==d||e[27]!==m||e[28]!==c||e[29]!==u||e[30]!==f||e[31]!==y||e[32]!==g||e[33]!==P||e[34]!==a||e[35]!==b||e[36]!==te||e[37]!==J||e[38]!==n||e[39]!==k||e[40]!==W||e[41]!==N||e[42]!==j||e[43]!==Q){const S={session:n.session,open:E,isActive:o,select:te,closeOtherTabs:J,components:o1};Me=y;let ne;e[64]!==N?(ne=pd.Translate.toString(N),e[64]=N,e[65]=ne):ne=e[65],e[66]!==ne||e[67]!==j?(Ae={transform:ne,transition:j},e[66]=ne,e[67]=j,e[68]=Ae):Ae=e[68];const q=v&&"z-10 opacity-60";e[69]!==q?(De=Le("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",q),e[69]=q,e[70]=De):De=e[70],Be=o?"true":"false",e[71]!==o?(we=o?{"data-active-session-tab":!0}:{},e[71]=o,e[72]=we):we=e[72],ve=A,Pe=D,$=pr,fe=E,Se=F,e[73]!==m?(Te=Ie=>m?.(Ie),e[73]=m,e[74]=Te):Te=e[74];let ke;e[75]!==h||e[76]!==o||e[77]!==Z||e[78]!==i||e[79]!==d||e[80]!==c||e[81]!==u||e[82]!==g||e[83]!==P||e[84]!==a||e[85]!==b||e[86]!==n||e[87]!==W||e[88]!==Q?(ke=s.jsx(Ft,{asChild:!0,children:s.jsx(Ob,{render:Ie=>s.jsx("div",{...Ie,role:"tab","aria-selected":o,tabIndex:o?void 0:0,onClick:o?void 0:()=>u(n),onDoubleClick:i?()=>c(n.id):void 0,onKeyDown:o?void 0:Ne=>{(Ne.key==="Enter"||Ne.key===" ")&&(Ne.preventDefault(),u(n))},onAuxClick:Ne=>{Ne.button===1&&(Ne.preventDefault(),d(n.id))},className:Le("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",o?"bg-interactive-selection text-interactive-selection-foreground":"cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[s.jsxs("span",{className:"relative me-1.5 inline-flex size-3.5 shrink-0 items-center justify-center",children:[s.jsx(Yb,{directory:Ys(n.session),className:Le(!a&&"group-hover/session-tab:opacity-0 group-has-[:focus-visible]/session-tab:opacity-0")}),a?null:s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":b("header.sessionTabs.closeTab"),onClick:Ne=>{Ne.stopPropagation(),d(n.id)},onPointerDown:c1,className:"absolute inset-0 flex items-center justify-center rounded text-muted-foreground opacity-0 hover:text-foreground focus-visible:opacity-100 group-hover/session-tab:opacity-100",children:s.jsx(se,{name:"close",className:"size-3.5"})})}),s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Ws,{label:b("header.sessionTabs.closeTab"),shortcut:o?xs(Bs()?"mod+w":Ts("close_session_tab",g),""):void 0})})]})]}),s.jsx("div",{className:Le("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!a&&"session-tab-title",i&&!a&&"italic"),children:o?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4",children:W})})}),Z?s.jsx(se,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":b("sessions.aiRename.generating")}):P?s.jsx(Sc,{state:Q??"unread",className:"ms-1.5 shrink-0"}):null]})})})}),e[75]=h,e[76]=o,e[77]=Z,e[78]=i,e[79]=d,e[80]=c,e[81]=u,e[82]=g,e[83]=P,e[84]=a,e[85]=b,e[86]=n,e[87]=W,e[88]=Q,e[89]=ke):ke=e[89];let Ee;e[90]!==k||e[91]!==W?(Ee=s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Ws,{label:W,shortcut:k})}),e[90]=k,e[91]=W,e[92]=Ee):Ee=e[92],e[93]!==ke||e[94]!==Ee?(ue=s.jsxs(Lt,{children:[ke,Ee]}),e[93]=ke,e[94]=Ee,e[95]=ue):ue=e[95],U=Mb,K=Fb,V="app-region-no-drag z-50",le=Lb,he="dropdown-menu-content",e[96]===Symbol.for("react.memo_cache_sentinel")?(ee={color:"var(--surface-elevated-foreground)"},Y=Le(Fp,"min-w-[190px]"),e[96]=ee,e[97]=Y):(ee=e[96],Y=e[97]),ie=f(S),e[18]=A,e[19]=h,e[20]=E,e[21]=o,e[22]=Z,e[23]=v,e[24]=i,e[25]=D,e[26]=d,e[27]=m,e[28]=c,e[29]=u,e[30]=f,e[31]=y,e[32]=g,e[33]=P,e[34]=a,e[35]=b,e[36]=te,e[37]=J,e[38]=n,e[39]=k,e[40]=W,e[41]=N,e[42]=j,e[43]=Q,e[44]=le,e[45]=K,e[46]=U,e[47]=$,e[48]=ee,e[49]=Y,e[50]=ie,e[51]=V,e[52]=fe,e[53]=Se,e[54]=Te,e[55]=ue,e[56]=Me,e[57]=Ae,e[58]=De,e[59]=Be,e[60]=we,e[61]=ve,e[62]=Pe,e[63]=he}else le=e[44],K=e[45],U=e[46],$=e[47],ee=e[48],Y=e[49],ie=e[50],V=e[51],fe=e[52],Se=e[53],Te=e[54],ue=e[55],Me=e[56],Ae=e[57],De=e[58],Be=e[59],we=e[60],ve=e[61],Pe=e[62],he=e[63];let Fe;e[98]!==le||e[99]!==ee||e[100]!==Y||e[101]!==ie||e[102]!==he?(Fe=s.jsx(le,{"data-slot":he,style:ee,className:Y,children:ie}),e[98]=le,e[99]=ee,e[100]=Y,e[101]=ie,e[102]=he,e[103]=Fe):Fe=e[103];let _e;e[104]!==K||e[105]!==V||e[106]!==Fe?(_e=s.jsx(K,{className:V,children:Fe}),e[104]=K,e[105]=V,e[106]=Fe,e[107]=_e):_e=e[107];let We;e[108]!==U||e[109]!==_e?(We=s.jsx(U,{children:_e}),e[108]=U,e[109]=_e,e[110]=We):We=e[110];let Xe;e[111]!==$||e[112]!==fe||e[113]!==Se||e[114]!==Te||e[115]!==ue||e[116]!==We?(Xe=s.jsxs($,{open:fe,onOpenChange:Se,onOpenChangeComplete:Te,children:[ue,We]}),e[111]=$,e[112]=fe,e[113]=Se,e[114]=Te,e[115]=ue,e[116]=We,e[117]=Xe):Xe=e[117];let Ve;return e[118]!==Me||e[119]!==Ae||e[120]!==De||e[121]!==Be||e[122]!==we||e[123]!==ve||e[124]!==Pe||e[125]!==Xe?(Ve=s.jsx("div",{ref:Me,style:Ae,className:De,"data-active":Be,...we,...ve,...Pe,children:Xe}),e[118]=Me,e[119]=Ae,e[120]=De,e[121]=Be,e[122]=we,e[123]=ve,e[124]=Pe,e[125]=Xe,e[126]=Ve):Ve=e[126],Ve},a1=t=>{const e=$e.c(109),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,children:i}=t,a=o===void 0?!1:o,{t:u,direction:c}=at(),d=c==="rtl",f=nn(d1),p=nn(u1),m=nn(f1),h=nn(p1),b=nn(m1),g=nn(h1),x=et(g1),w=et(b1),T=ps(x1),k=X(w1),E=nn(y1),F=ps(v1),_=et(S1),A=et(k1),D=et(j1),y=et(C1),N=et(T1),j=et(N1);let v;e[0]!==j?(v=L=>{const ge=j??L.activeProjectId;return L.projects.find(Ce=>Ce.id===ge)?.path??null},e[0]=j,e[1]=v):v=e[1];const M=ts(v),W=kf(x);let G,O;e[2]!==W||e[3]!==_||e[4]!==x||e[5]!==N||e[6]!==y||e[7]!==A||e[8]!==M||e[9]!==m||e[10]!==E||e[11]!==k||e[12]!==F?(G=()=>{if(!k)E(Bp,E1);else{if(!F)return;const L=ns(),ge=!x&&A&&y,Ce=x?_:A&&!y?N??M:null,Je=ge?hd(L):Zb(L,Ce);if(!Je)return;E(Je,()=>Xb(Ce,ps.getState().activeSessions,ts.getState().projects.map(I1)))}x&&m(x,W)},O=[W,_,x,N,y,A,M,m,E,k,F],e[2]=W,e[3]=_,e[4]=x,e[5]=N,e[6]=y,e[7]=A,e[8]=M,e[9]=m,e[10]=E,e[11]=k,e[12]=F,e[13]=G,e[14]=O):(G=e[13],O=e[14]),l.useEffect(G,O);let Z;if(e[15]!==T){Z=new Map;for(const L of T)Z.set(L.id,L);e[15]=T,e[16]=Z}else Z=e[16];const Q=Z;let B;if(e[17]!==Q||e[18]!==f){B=[];for(const L of f){const ge=Q.get(L);ge&&B.push({id:L,session:ge})}e[17]=Q,e[18]=f,e[19]=B}else B=e[19];const oe=B;let H;e[20]!==w?(H=L=>{w(L.id,Ys(L.session))},e[20]=w,e[21]=H):H=e[21];const P=H,te=P1,J=!x&&A;let le;e[22]!==J||e[23]!==D?(le=L=>!J||!D?"":(L.drafts.find(Ce=>Ce.id===D)?.text??"").split(/\r?\n/).find(R1)?.trim()??"",e[22]=J,e[23]=D,e[24]=le):le=e[24];const K=Op(le),U=X(D1),$=A1;let ee;e[25]!==x||e[26]!==J||e[27]!==oe?(ee=oe.some(L=>L.id===x)||J&&oe.length>0,e[25]=x,e[26]=J,e[27]=oe,e[28]=ee):ee=e[28];const Y=ee;let ie,V;e[29]!==Y?(ie=()=>{if(Y)return ic(_1,{current:document.body})},V=[Y],e[29]=Y,e[30]=ie,e[31]=V):(ie=e[30],V=e[31]),l.useEffect(ie,V);let fe;e[32]!==b||e[33]!==x||e[34]!==P||e[35]!==oe?(fe=L=>{if(b(L),x&&x!==L){const ge=oe.find(Ce=>Ce.id===L);ge&&P(ge)}},e[32]=b,e[33]=x,e[34]=P,e[35]=oe,e[36]=fe):fe=e[36];const Se=fe;let Te;e[37]===Symbol.for("react.memo_cache_sentinel")?(Te={activationConstraint:{distance:8}},e[37]=Te):Te=e[37];let ue;e[38]===Symbol.for("react.memo_cache_sentinel")?(ue={activationConstraint:{delay:200,tolerance:6}},e[38]=ue):ue=e[38];const Me=ad(Ur(cd,Te),Ur(ld,ue));let Ae;e[39]!==g?(Ae=L=>{const{active:ge,over:Ce}=L;Ce&&ge.id!==Ce.id&&g(String(ge.id),String(Ce.id))},e[39]=g,e[40]=Ae):Ae=e[40];const De=Ae,Be=l.useRef(null);let we;e[41]===Symbol.for("react.memo_cache_sentinel")?(we={left:!1,right:!1},e[41]=we):we=e[41];const[ve,Pe]=l.useState(we);let he;e[42]===Symbol.for("react.memo_cache_sentinel")?(he=()=>{const L=Be.current;if(!L)return;const ge=L.scrollWidth-L.clientWidth,Ce=Jr(L)?ge+L.scrollLeft:L.scrollLeft,Je=Ce>2,Oe=Ce<ge-2;Pe(me=>me.left===Je&&me.right===Oe?me:{left:Je,right:Oe})},e[42]=he):he=e[42];const Fe=he;let _e;e[43]===Symbol.for("react.memo_cache_sentinel")?(_e=()=>{Fe();const L=Be.current;if(!L||!globalThis.ResizeObserver)return;const ge=new ResizeObserver(Fe);return ge.observe(L),()=>ge.disconnect()},e[43]=_e):_e=e[43];let We;e[44]!==oe.length?(We=[Fe,oe.length],e[44]=oe.length,e[45]=We):We=e[45],l.useEffect(_e,We);let Xe;e[46]===Symbol.for("react.memo_cache_sentinel")?(Xe=()=>{const L=Be.current,ge=L?.querySelector("[data-active-session-tab]");if(!L||!ge)return;const Ce=t1(L.getBoundingClientRect(),ge.getBoundingClientRect());Ce!==0&&(L.scrollLeft=L.scrollLeft+Ce,Fe())},e[46]=Xe):Xe=e[46];let Ve;e[47]!==x?(Ve=[x,Fe],e[47]=x,e[48]=Ve):Ve=e[48],l.useEffect(Xe,Ve);const S=ve.left&&ve.right?`linear-gradient(to right, transparent, black ${Hn}px, black calc(100% - ${Hn}px), transparent)`:ve.left?`linear-gradient(to right, transparent, black ${Hn}px)`:ve.right?`linear-gradient(to right, black calc(100% - ${Hn}px), transparent)`:void 0;let ne;e[49]!==oe?(ne=oe.map(O1),e[49]=oe,e[50]=ne):ne=e[50];const q=ne;let ke;e[51]!==x||e[52]!==oe?(ke=!!x&&!oe.some(L=>L.id===x),e[51]=x,e[52]=oe,e[53]=ke):ke=e[53];const Ee=ke;let Ie;e[54]!==u?(Ie=u("header.sessionTabs.stripAria"),e[54]=u,e[55]=Ie):Ie=e[55];let Ne;e[56]!==S?(Ne=S?{maskImage:S,WebkitMaskImage:S}:void 0,e[56]=S,e[57]=Ne):Ne=e[57];let ze;e[58]===Symbol.for("react.memo_cache_sentinel")?(ze=[s1],e[58]=ze):ze=e[58];const Ue=d?Ib:Pb;let Ge;e[59]!==i||e[60]!==x||e[61]!==Se||e[62]!==P||e[63]!==r||e[64]!==h||e[65]!==p||e[66]!==n||e[67]!==a||e[68]!==oe?(Ge=oe.map((L,ge)=>s.jsx(i1,{tabNumber:ge+1,tab:L,isActive:L.id===x,isPreview:L.id===p,suppressControls:L.id===x&&a,onSelect:P,onPin:h,onClose:te,renderMenu:n,closeOtherTabs:Se,onMenuOpenChangeComplete:r,children:L.id===x?i:null},L.id)),e[59]=i,e[60]=x,e[61]=Se,e[62]=P,e[63]=r,e[64]=h,e[65]=p,e[66]=n,e[67]=a,e[68]=oe,e[69]=Ge):Ge=e[69];let Qe;e[70]!==Ue||e[71]!==Ge||e[72]!==q?(Qe=s.jsx(fd,{items:q,strategy:Ue,children:Ge}),e[70]=Ue,e[71]=Ge,e[72]=q,e[73]=Qe):Qe=e[73];let He;e[74]!==De||e[75]!==Me||e[76]!==Qe?(He=s.jsx(dd,{sensors:Me,collisionDetection:ti,modifiers:ze,onDragEnd:De,children:Qe}),e[74]=De,e[75]=Me,e[76]=Qe,e[77]=He):He=e[77];let Ke;e[78]!==K||e[79]!==J||e[80]!==u?(Ke=J?s.jsxs("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2 text-interactive-selection-foreground","data-active":"true","data-active-session-tab":!0,children:[s.jsx(se,{name:"edit",className:"me-1.5 size-3.5 shrink-0"}),s.jsx("div",{className:"session-tab-title min-w-0 flex-1 overflow-hidden whitespace-nowrap italic",children:s.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4",children:K||u("sessions.switcher.draftTitle")})})]}):null,e[78]=K,e[79]=J,e[80]=u,e[81]=Ke):Ke=e[81];let Ye;e[82]!==i||e[83]!==Ee?(Ye=Ee?s.jsx("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag 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:i})}):null,e[82]=i,e[83]=Ee,e[84]=Ye):Ye=e[84];let it;e[85]!==Ne||e[86]!==He||e[87]!==Ke||e[88]!==Ye?(it=s.jsxs("div",{ref:Be,onScroll:Fe,onWheel:r1,className:"session-tabs-scroll flex min-w-0 flex-initial items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:Ne,children:[He,Ke,Ye]}),e[85]=Ne,e[86]=He,e[87]=Ke,e[88]=Ye,e[89]=it):it=e[89];let bt;e[90]!==u?(bt=u("sessions.sidebar.header.actions.newSession"),e[90]=u,e[91]=bt):bt=e[91];let nt;e[92]===Symbol.for("react.memo_cache_sentinel")?(nt=s.jsx(se,{name:"add",className:"size-4"}),e[92]=nt):nt=e[92];let ft;e[93]!==bt?(ft=s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:$,"aria-label":bt,className:"app-region-no-drag ms-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:nt})}),e[93]=bt,e[94]=ft):ft=e[94];let ae;e[95]!==u?(ae=u("sessions.sidebar.header.actions.newSession"),e[95]=u,e[96]=ae):ae=e[96];let de;e[97]!==U?(de=xs(Ts("new_chat",U),""),e[97]=U,e[98]=de):de=e[98];let be;e[99]!==ae||e[100]!==de?(be=s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Ws,{label:ae,shortcut:de})}),e[99]=ae,e[100]=de,e[101]=be):be=e[101];let C;e[102]!==ft||e[103]!==be?(C=s.jsxs(Lt,{children:[ft,be]}),e[102]=ft,e[103]=be,e[104]=C):C=e[104];let ce;return e[105]!==Ie||e[106]!==it||e[107]!==C?(ce=s.jsxs("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":Ie,children:[it,C]}),e[105]=Ie,e[106]=it,e[107]=C,e[108]=ce):ce=e[108],ce};function l1(t){return t.shortcutOverrides}function c1(t){return t.stopPropagation()}function d1(t){return t.tabIds}function u1(t){return t.previewTabId}function f1(t){return t.ensureTab}function p1(t){return t.pinTab}function m1(t){return t.closeOtherTabs}function h1(t){return t.reorderTabs}function g1(t){return t.currentSessionId}function b1(t){return t.setCurrentSession}function x1(t){return t.activeSessions}function w1(t){return t.sessionTabsPerWorkspace}function y1(t){return t.enterScope}function v1(t){return t.hasLoaded}function S1(t){return t.currentSessionDirectory}function k1(t){return t.newSessionDraft.open}function j1(t){return t.newSessionDraft.workDraftId??null}function C1(t){return t.newSessionDraft.target==="chat"}function T1(t){return t.newSessionDraft.directoryOverride}function N1(t){return t.newSessionDraft.selectedProjectId??null}function E1(){return[]}function I1(t){return t.path}function P1(t){vc(t)}function R1(t){return t.trim()}function D1(t){return t.shortcutOverrides}function A1(){const{currentSessionId:t,newSessionDraft:e,openNewSessionDraft:n}=et.getState(),r=t?ls.getState().currentDirectory:e.directoryOverride;n(r?{directoryOverride:r}:void 0)}function _1(){const t=et.getState().currentSessionId;t?vc(t):zp(-1)}function O1(t){return t.id}function Wa(t){const e=$e.c(37),{sessionId:n,onArchive:r,Item:o}=t,{t:i}=at(),a=X(F1);let u;e[0]!==n?(u=v=>v.currentSessionId===n,e[0]=n,e[1]=u):u=e[1];const c=et(u);let d;e[2]!==a?(d=xs(Ts("archive_current_session",a),""),e[2]=a,e[3]=d):d=e[3];const f=d;let p;e[4]!==n?(p=v=>!!v.entityById.get(n)?.time.archived,e[4]=n,e[5]=p):p=e[5];const m=ps(p);let h;e[6]!==n?(h=v=>{const M=v.entityById.get(n);return!M||Wp(M,v.entityById)},e[6]=n,e[7]=h):h=e[7];const b=ps(h),g=et(M1);let x;e[8]!==n||e[9]!==i||e[10]!==g?(x=async()=>{await g(n)?Re.success(i("sessions.sidebar.session.restore.success")):Re.error(i("sessions.sidebar.session.restore.error"))},e[8]=n,e[9]=i,e[10]=g,e[11]=x):x=e[11];const w=x;if(m&&!b)return null;const T=m?"sessions.sidebar.session.menuHint.restore":"sessions.sidebar.session.menuHint.archive";let k;e[12]!==i||e[13]!==T?(k=i(T),e[12]=i,e[13]=T,e[14]=k):k=e[14];let E;e[15]!==m||e[16]!==r||e[17]!==w?(E=m?()=>{w()}:r,e[15]=m,e[16]=r,e[17]=w,e[18]=E):E=e[18];const F=m?"inbox-unarchive":"inbox-archive";let _;e[19]!==F?(_=s.jsx(se,{name:F,className:"me-1 size-4"}),e[19]=F,e[20]=_):_=e[20];const A=m?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let D;e[21]!==i||e[22]!==A?(D=i(A),e[21]=i,e[22]=A,e[23]=D):D=e[23];let y;e[24]!==f||e[25]!==m||e[26]!==c?(y=!m&&c&&f?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:f}):null,e[24]=f,e[25]=m,e[26]=c,e[27]=y):y=e[27];let N;e[28]!==o||e[29]!==_||e[30]!==D||e[31]!==y||e[32]!==E?(N=s.jsxs(o,{onClick:E,children:[_,D,y]}),e[28]=o,e[29]=_,e[30]=D,e[31]=y,e[32]=E,e[33]=N):N=e[33];let j;return e[34]!==N||e[35]!==k?(j=s.jsx(as,{hint:k,children:N}),e[34]=N,e[35]=k,e[36]=j):j=e[36],j}function M1(t){return t.unarchiveSession}function F1(t){return t.shortcutOverrides}function L1(t){const e=$e.c(17),{session:n,Item:r}=t,{t:o}=at();if(!X($1)||n.parentID||!kc(n))return null;let a;e[0]!==n||e[1]!==o?(a=async()=>{try{await Up(n.id,Ys(n),"done"),jc([n.id])}catch{Re.error(o("sessions.sidebar.session.work.updateFailed"))}},e[0]=n,e[1]=o,e[2]=a):a=e[2];const u=a;let c;e[3]!==o?(c=o("sessions.sidebar.session.menuHint.markDone"),e[3]=o,e[4]=c):c=e[4];let d;e[5]!==u?(d=()=>{u()},e[5]=u,e[6]=d):d=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(se,{name:"check",className:"me-1 size-4"}),e[7]=f):f=e[7];let p;e[8]!==o?(p=o("sessions.sidebar.session.work.markDone"),e[8]=o,e[9]=p):p=e[9];let m;e[10]!==r||e[11]!==d||e[12]!==p?(m=s.jsxs(r,{onClick:d,children:[f,p]}),e[10]=r,e[11]=d,e[12]=p,e[13]=m):m=e[13];let h;return e[14]!==c||e[15]!==m?(h=s.jsx(as,{hint:c,children:m}),e[14]=c,e[15]=m,e[16]=h):h=e[16],h}function $1(t){return t.sessionWorkEnabled}const B1=t=>{const e=Cc(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},z1=(t,e)=>t===null||e===null?t===e:t.state!==e.state?!1:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,gd=()=>{const t=$e.c(4),e=et(W1),n=et(U1)??void 0,r=Vp(e??"",n,B1,z1),{context:o}=Hp(e,n),i=o>0?o:qp;let a;return t[0]!==r||t[1]!==i||t[2]!==e?(a={sessionId:e,fill:r,limit:i},t[0]=r,t[1]=i,t[2]=e,t[3]=a):a=t[3],a};function W1(t){return t.currentSessionId}function U1(t){return t.currentSessionDirectory}const Ua=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),Os=18,ri=2,oi=(Os-ri)/2,Va=2*Math.PI*oi,V1=t=>{const e=$e.c(9),{percent:n,arcColor:r,className:o}=t,i=r===void 0?"currentColor":r,a=Math.min(100,Math.max(0,n));let u;e[0]!==o?(u=Le("shrink-0",o),e[0]=o,e[1]=u):u=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx("circle",{cx:Os/2,cy:Os/2,r:oi,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:ri}),e[2]=c):c=e[2];let d;e[3]!==i||e[4]!==a?(d=a>0?s.jsx("circle",{cx:Os/2,cy:Os/2,r:oi,fill:"none",stroke:i,strokeWidth:ri,strokeLinecap:"round",strokeDasharray:Va,strokeDashoffset:Va*(1-a/100),transform:`rotate(-90 ${Os/2} ${Os/2})`}):null,e[3]=i,e[4]=a,e[5]=d):d=e[5];let f;return e[6]!==u||e[7]!==d?(f=s.jsxs("svg",{viewBox:`0 0 ${Os} ${Os}`,className:u,"aria-hidden":"true",children:[c,d]}),e[6]=u,e[7]=d,e[8]=f):f=e[8],f},bd=()=>{const t=$e.c(16),{t:e}=at(),{sessionId:n,fill:r,limit:o}=gd(),{totalCost:i}=Kp(n);if(!n||!r)return null;let a;t[0]!==r.state||t[1]!==r.totalTokens||t[2]!==e?(a=r.state==="measured"?e("contextUsage.tooltip.usedTokens",{tokens:Ua(r.totalTokens)}):e("contextUsage.compacted.description"),t[0]=r.state,t[1]=r.totalTokens,t[2]=e,t[3]=a):a=t[3];let u;t[4]!==o||t[5]!==e?(u=e("contextUsage.tooltip.contextLimit",{tokens:Ua(o)}),t[4]=o,t[5]=e,t[6]=u):u=t[6];let c;t[7]!==e||t[8]!==i?(c=i!==null&&i>0?[e("contextUsage.tooltip.cost",{cost:rd(i)})]:[],t[7]=e,t[8]=i,t[9]=c):c=t[9];let d;t[10]!==a||t[11]!==u||t[12]!==c?(d=[a,u,...c],t[10]=a,t[11]=u,t[12]=c,t[13]=d):d=t[13];const f=d;let p;return t[14]!==f?(p=s.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-edge pt-1 tabular-nums",children:f.map(H1)}),t[14]=f,t[15]=p):p=t[15],p};function H1(t){return s.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const q1="—",K1={safe:"var(--status-success)",warn:"var(--status-warning)",critical:"var(--status-error)"},G1=t=>{const e=$e.c(35),{buttonClassName:n}=t,{t:r}=at(),{sessionId:o,fill:i,limit:a}=gd(),u=Vs();let c;e[0]!==u?(c=u?cs(u):"",e[0]=u,e[1]=c):c=e[1];const d=c,f=X(X1);let p;e[2]!==d?(p=v=>d!==""&&vi(v.contextPanelByDirectory[d],v.contextSurfaceZones).has("context"),e[2]=d,e[3]=p):p=e[3];const m=X(p);if(!o||!i)return null;const h=i.state==="measured"?i.totalTokens/a*100:null,b=h===null?void 0:K1[Gp(Math.round(h))];let g;e[4]!==d||e[5]!==f?(g=d?()=>f(d,"context"):void 0,e[4]=d,e[5]=f,e[6]=g):g=e[6];let x;e[7]!==r?(x=r("contextUsage.aria.label"),e[7]=r,e[8]=x):x=e[8];const w=m&&"text-foreground";let T;e[9]!==n||e[10]!==w?(T=Le(n,"w-auto gap-1.5 px-1 tabular-nums",w),e[9]=n,e[10]=w,e[11]=T):T=e[11];const k=h??0;let E;e[12]!==b||e[13]!==k?(E=s.jsx(V1,{percent:k,arcColor:b,className:"size-4"}),e[12]=b,e[13]=k,e[14]=E):E=e[14];let F;e[15]!==h?(F=h===null?q1:`${Math.min(h,999).toFixed(1)}%`,e[15]=h,e[16]=F):F=e[16];let _;e[17]!==F?(_=s.jsx("span",{dir:"ltr",className:"typography-meta",children:F}),e[17]=F,e[18]=_):_=e[18];let A;e[19]!==m||e[20]!==_||e[21]!==g||e[22]!==x||e[23]!==T||e[24]!==E?(A=s.jsx(Ft,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:g,"aria-label":x,"aria-pressed":m,className:T,children:[E,_]})}),e[19]=m,e[20]=_,e[21]=g,e[22]=x,e[23]=T,e[24]=E,e[25]=A):A=e[25];let D;e[26]!==m||e[27]!==r?(D=m?null:s.jsx("span",{children:r("chat.workStatus.action.openContext")}),e[26]=m,e[27]=r,e[28]=D):D=e[28];let y;e[29]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(bd,{}),e[29]=y):y=e[29];let N;e[30]!==D?(N=s.jsx($t,{side:"bottom",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[D,y]})}),e[30]=D,e[31]=N):N=e[31];let j;return e[32]!==A||e[33]!==N?(j=s.jsxs(Lt,{children:[A,N]}),e[32]=A,e[33]=N,e[34]=j):j=e[34],j},Z1=l.memo(G1);function X1(t){return t.openContextSurface}const xd=l.createContext(null),wd=()=>l.useContext(xd),Y1=t=>{const e=$e.c(4),n=wd()?.observe;let r,o;e[0]!==t||e[1]!==n?(r=()=>t&&n?n():void 0,o=[t,n],e[0]=t,e[1]=n,e[2]=r,e[3]=o):(r=e[2],o=e[3]),l.useEffect(r,o)},Ha=t=>{const e=$e.c(12),{run:n,showIdle:r,large:o,className:i}=t,a=r===void 0?!1:r,u=o===void 0?!1:o;if(n?.status==="stopping"||n?.status==="waiting-for-preview"){let d;e[0]!==i?(d=Le("size-4 shrink-0 animate-spin text-[var(--status-warning)]",i),e[0]=i,e[1]=d):d=e[1];let f;return e[2]!==d?(f=s.jsx(se,{name:"loader-4",className:d}),e[2]=d,e[3]=f):f=e[3],f}if(n){const d=u?"stop-large":"stop";let f;e[4]!==i?(f=Le("size-4 shrink-0 text-[var(--status-warning)]",i),e[4]=i,e[5]=f):f=e[5];let p;return e[6]!==d||e[7]!==f?(p=s.jsx(se,{name:d,className:f}),e[6]=d,e[7]=f,e[8]=p):p=e[8],p}let c;return e[9]!==i||e[10]!==a?(c=a?s.jsx(se,{name:"play",className:Le("size-4 shrink-0",i)}):null,e[9]=i,e[10]=a,e[11]=c):c=e[11],c},J1=t=>{const e=$e.c(68),{directory:n,buttonClassName:r}=t,{t:o}=at(),i=rn(ex),a=rn(tx),u=rn(sx),c=rn(nx),d=Zp(c),f=rn(rx),p=rn(ox),m=rn(ix);let h,b;e[0]!==f?(h=()=>{f()},b=[f],e[0]=f,e[1]=h,e[2]=b):(h=e[1],b=e[2]),l.useEffect(h,b);const g=Bs()&&Qr();let x;e[3]!==a||e[4]!==i?(x=a.find(U=>U.id===i)??a.find(ax)??a[0]??$b[0],e[3]=a,e[4]=i,e[5]=x):x=e[5];const w=x;if(!g||!n||a.length===0)return null;let T;e[6]!==n?(T=async U=>{await Eu(n,U.id,U.appName)||await Kl(n,U.appName)},e[6]=n,e[7]=T):T=e[7];const k=T;let E;e[8]!==k||e[9]!==m?(E=async U=>{await m(U.id),await k(U)},e[8]=k,e[9]=m,e[10]=E):E=e[10];const F=E;let _;e[11]!==n||e[12]!==o?(_=async()=>{(await no(n)).ok&&Re.success(o("openInApp.toast.pathCopied"))},e[11]=n,e[12]=o,e[13]=_):_=e[13];const A=_;let D;e[14]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx("div",{className:"inline-flex"}),e[14]=D):D=e[14];let y;e[15]!==k||e[16]!==w?(y=()=>{k(w)},e[15]=k,e[16]=w,e[17]=y):y=e[17];let N;e[18]!==d||e[19]!==r?(N=Le(r,d),e[18]=d,e[19]=r,e[20]=N):N=e[20];let j;e[21]!==w.label||e[22]!==o?(j=o("openInApp.actions.openInAria",{app:w.label}),e[21]=w.label,e[22]=o,e[23]=j):j=e[23];let v;e[24]!==w.icon?(v=s.jsx(se,{name:w.icon,className:"size-4"}),e[24]=w.icon,e[25]=v):v=e[25];let M;e[26]!==j||e[27]!==v||e[28]!==y||e[29]!==N?(M=s.jsx(ro,{render:D,children:s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:y,className:N,"aria-label":j,children:v})})}),e[26]=j,e[27]=v,e[28]=y,e[29]=N,e[30]=M):M=e[30];let W;e[31]!==w.label||e[32]!==o?(W=o("openInApp.actions.openInAria",{app:w.label}),e[31]=w.label,e[32]=o,e[33]=W):W=e[33];let G;e[34]!==W?(G=s.jsx($t,{side:"bottom",children:W}),e[34]=W,e[35]=G):G=e[35];let O;e[36]!==M||e[37]!==G?(O=s.jsxs(Lt,{children:[M,G]}),e[36]=M,e[37]=G,e[38]=O):O=e[38];let Z;e[39]!==A?(Z=()=>{A()},e[39]=A,e[40]=Z):Z=e[40];let Q;e[41]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(se,{name:"file-copy",className:"h-4 w-4"}),e[41]=Q):Q=e[41];let B;e[42]!==o?(B=o("openInApp.actions.copyPath"),e[42]=o,e[43]=B):B=e[43];let oe;e[44]!==B?(oe=s.jsx("span",{className:"typography-ui-label text-foreground",children:B}),e[44]=B,e[45]=oe):oe=e[45];let H;e[46]!==Z||e[47]!==oe?(H=s.jsxs(Cs,{className:"flex items-center gap-2",onClick:Z,children:[Q,oe]}),e[46]=Z,e[47]=oe,e[48]=H):H=e[48];let P;e[49]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(Tn,{}),e[49]=P):P=e[49];let te;if(e[50]!==a||e[51]!==F||e[52]!==w.id){let U;e[54]!==F||e[55]!==w.id?(U=$=>s.jsxs(Cs,{className:"flex items-center gap-2",onClick:()=>{F($)},children:[s.jsx(se,{name:$.icon,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:$.label}),w.id===$.id?s.jsx(se,{name:"check",className:"ms-auto h-4 w-4 text-primary"}):null]},$.id),e[54]=F,e[55]=w.id,e[56]=U):U=e[56],te=a.map(U),e[50]=a,e[51]=F,e[52]=w.id,e[53]=te}else te=e[53];let J;e[57]!==u||e[58]!==p||e[59]!==o?(J=u?s.jsxs(Cs,{className:"flex items-center gap-2",onClick:()=>{p(!0)},children:[s.jsx(se,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[57]=u,e[58]=p,e[59]=o,e[60]=J):J=e[60];let le;e[61]!==H||e[62]!==te||e[63]!==J?(le=s.jsxs(oo,{className:"w-56 max-h-[70vh] overflow-y-auto",children:[H,P,te,J]}),e[61]=H,e[62]=te,e[63]=J,e[64]=le):le=e[64];let K;return e[65]!==O||e[66]!==le?(K=s.jsxs(pr,{children:[O,le]}),e[65]=O,e[66]=le,e[67]=K):K=e[67],K},Q1=l.memo(J1);function ex(t){return t.selectedAppId}function tx(t){return t.availableApps}function sx(t){return t.isCacheStale}function nx(t){return t.isScanning}function rx(t){return t.initialize}function ox(t){return t.loadInstalledApps}function ix(t){return t.selectApp}function ax(t){return t.id===Bb}const qn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},lx=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const o=qn(n??"");if(o){const i=fr(t,e,o);if(i)return i}return t.find(i=>i.id===r)??null};function yd(){const t=ts(x=>x.projects),e=ts(x=>x.activeProjectId),n=et(x=>x.availableWorktreesByProject),r=et(x=>x.currentSessionId),o=Xp(r??null),i=et(x=>r?x.worktreeMetadata.get(r)?.path??"":""),a=et(x=>x.newSessionDraft?.open?qn(x.newSessionDraft.bootstrapPendingDirectory??x.newSessionDraft.directoryOverride??""):""),u=et(x=>x.newSessionDraft?.open?x.newSessionDraft.target==="chat":null),c=l.useMemo(()=>qn(i||""),[i]),d=l.useMemo(()=>qn(o||""),[o]),f=c||d||a,p=l.useMemo(()=>lx({projects:t,worktreesByProject:n,directory:f,activeProjectId:e}),[e,f,t,n]),m=l.useMemo(()=>qn(f||p?.path||""),[f,p?.path]),h=l.useMemo(()=>p?{id:p.id,path:p.path}:null,[p]),b=u??Yr(d),g=l.useRef(null);return l.useEffect(()=>{h&&m&&!b&&(g.current={projectRef:h,directory:m})},[m,h,b]),l.useMemo(()=>b?null:h&&m?{projectRef:h,directory:m}:g.current,[h,m,b])}const cx=t=>{const e=$e.c(67),{buttonClassName:n}=t,{t:r}=at(),o=wd(),i=X(px),[a,u]=l.useState(!1),c=X(mx);let d;e[0]!==c?(d=xs(Ts("open_project_actions",c),""),e[0]=c,e[1]=d):d=e[1];const f=d,p=o?.available?o.shown:null;let m;e[2]!==o||e[3]!==p?(m=p&&o?o.runOf(p):null,e[2]=o,e[3]=p,e[4]=m):m=e[4];const h=m;Y1(!0);let b;e[5]!==h?(b=le=>h?le.getDirectoryState(h.directory)?.tabs.find(K=>K.id===h.tabId)?.previewUrl??null:null,e[5]=h,e[6]=b):b=e[6];const g=wt(b);if(!o||!p)return null;let x;e[7]!==p.name||e[8]!==h||e[9]!==r?(x=h?r("projectActions.actions.stopNamedAria",{name:p.name}):r("projectActions.actions.runNamedAria",{name:p.name}),e[7]=p.name,e[8]=h,e[9]=r,e[10]=x):x=e[10];const w=x;let T;e[11]!==n||e[12]!==i||e[13]!==g||e[14]!==h||e[15]!==r?(T=h&&g?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>i(h.directory,g),className:n,"aria-label":r("projectActions.actions.openPreview"),children:s.jsx(se,{name:"global",className:"size-4"})})}),s.jsx($t,{side:"bottom",children:r("projectActions.actions.openPreview")})]}):null,e[11]=n,e[12]=i,e[13]=g,e[14]=h,e[15]=r,e[16]=T):T=e[16];let k;e[17]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx("div",{className:"inline-flex"}),e[17]=k):k=e[17];let E;e[18]!==o||e[19]!==p?(E=()=>o.toggle(p),e[18]=o,e[19]=p,e[20]=E):E=e[20];const F=o.isLoading||h?.status==="stopping",_=a&&"text-foreground";let A;e[21]!==n||e[22]!==_?(A=Le(n,_),e[21]=n,e[22]=_,e[23]=A):A=e[23];let D;e[24]!==p||e[25]!==h?(D=h?s.jsx(Ha,{run:h,large:!0}):s.jsx(se,{name:ha(p),className:"size-4"}),e[24]=p,e[25]=h,e[26]=D):D=e[26];let y;e[27]!==w||e[28]!==A||e[29]!==D||e[30]!==E||e[31]!==F?(y=s.jsx(ro,{render:k,children:s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:E,disabled:F,className:A,"aria-label":w,children:D})})}),e[27]=w,e[28]=A,e[29]=D,e[30]=E,e[31]=F,e[32]=y):y=e[32];let N;e[33]!==w?(N=s.jsx("span",{children:w}),e[33]=w,e[34]=N):N=e[34];let j;e[35]!==r?(j=r("projectActions.header.allActions"),e[35]=r,e[36]=j):j=e[36];let v;e[37]!==f||e[38]!==j?(v=s.jsx("span",{className:"typography-micro text-muted-foreground",children:s.jsx(Ws,{label:j,shortcut:f})}),e[37]=f,e[38]=j,e[39]=v):v=e[39];let M;e[40]!==N||e[41]!==v?(M=s.jsx($t,{side:"bottom",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[N,v]})}),e[40]=N,e[41]=v,e[42]=M):M=e[42];let W;e[43]!==y||e[44]!==M?(W=s.jsxs(Lt,{children:[y,M]}),e[43]=y,e[44]=M,e[45]=W):W=e[45];const G=o.openSettings;let O;e[46]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(se,{name:"add",className:"h-4 w-4"}),e[46]=O):O=e[46];let Z;e[47]!==r?(Z=r("projectActions.actions.addNewAction"),e[47]=r,e[48]=Z):Z=e[48];let Q;e[49]!==Z?(Q=s.jsx("span",{className:"typography-ui-label text-foreground",children:Z}),e[49]=Z,e[50]=Q):Q=e[50];let B;e[51]!==o.openSettings||e[52]!==Q?(B=s.jsxs(Cs,{className:"flex items-center gap-2",onClick:G,children:[O,Q]}),e[51]=o.openSettings,e[52]=Q,e[53]=B):B=e[53];let oe;e[54]===Symbol.for("react.memo_cache_sentinel")?(oe=s.jsx(Tn,{}),e[54]=oe):oe=e[54];let H;e[55]!==o||e[56]!==r?(H=o.actions.map(le=>s.jsxs(Cs,{className:"flex items-center gap-2",onClick:()=>{o.select(le),o.toggle(le)},children:[s.jsx(se,{name:ha(le),className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:le.name}),le.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:r("projectActions.menu.sharedBadge")}):null,s.jsx(Ha,{run:o.runOf(le),className:"ms-auto"})]},le.id)),e[55]=o,e[56]=r,e[57]=H):H=e[57];let P;e[58]!==B||e[59]!==H?(P=s.jsxs(oo,{className:"w-60 max-h-[70vh] overflow-y-auto",children:[B,oe,H]}),e[58]=B,e[59]=H,e[60]=P):P=e[60];let te;e[61]!==W||e[62]!==P?(te=s.jsxs(pr,{onOpenChange:u,children:[W,P]}),e[61]=W,e[62]=P,e[63]=te):te=e[63];let J;return e[64]!==te||e[65]!==T?(J=s.jsxs(s.Fragment,{children:[T,te]}),e[64]=te,e[65]=T,e[66]=J):J=e[66],J},dx=l.memo(cx),ux=t=>{const e=$e.c(8),{buttonClassName:n}=t,r=yd();if(!r)return null;let o;e[0]!==n||e[1]!==r.directory?(o=s.jsx(Q1,{directory:r.directory,buttonClassName:n}),e[0]=n,e[1]=r.directory,e[2]=o):o=e[2];let i;e[3]!==n?(i=s.jsx(dx,{buttonClassName:n}),e[3]=n,e[4]=i):i=e[4];let a;return e[5]!==o||e[6]!==i?(a=s.jsxs(s.Fragment,{children:[o,i]}),e[5]=o,e[6]=i,e[7]=a):a=e[7],a},fx=l.memo(ux);function px(t){return t.openContextPreview}function mx(t){return t.shortcutOverrides}const Ao="--oc-titlebar-controls-width",ii=new Set;let Gn=null;const vd=t=>{Gn===null?t.style.removeProperty(Ao):t.style.getPropertyValue(Ao)!==Gn&&t.style.setProperty(Ao,Gn)},hx=t=>{const e=`${Math.round(t)}px`;e!==Gn&&(Gn=e,ii.forEach(vd))},Sd=t=>{if(t)return ii.add(t),vd(t),()=>{ii.delete(t)}},zn="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground data-[popup-open]:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 transition-colors",vn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},qa=t=>!t.parentId&&!t.archived&&!ki(t.directory),gx=()=>{Iu("ui.header.render");const{t,direction:e}=at(),n=X(z=>z.isSidebarOpen),r=io(),o=X(z=>z.sessionTabsEnabled),i=et(z=>!!z.newSessionDraft?.open),a=et(z=>z.currentSessionId),u=Yp(a??""),c=Jp(a??""),d=ps(si(l.useCallback(z=>{if(!a)return null;const qe=[...z.activeSessions,...z.archivedSessions].find(Tt=>Tt.id===a);if(!qe)return null;const ut=qe;return{title:qe.title??null,directory:ut.directory??null,created:qe.time?.created??null,slug:ut.slug??null,parentId:qe.parentID??null,archived:!!qe.time?.archived}},[a]))),f=ts(si(z=>{if(!z.activeProjectId)return null;const qe=z.projects.find(ut=>ut.id===z.activeProjectId);return qe?{id:qe.id,path:qe.path,label:qe.label}:null})),p=l.useMemo(()=>{if(!f)return null;const z=f.label?.trim();if(z)return z;const qe=f.path.split(/[\\/]/).filter(Boolean);return qe[qe.length-1]??null},[f]),{isMobile:m}=gn(),h=l.useRef(null),[b,g]=l.useState(()=>typeof window>"u"?!1:Bs()),x=l.useMemo(()=>qo(),[]),w=Qp(),[T,k]=l.useState(!1),E=l.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:F,side:_}=od(),A=l.useMemo(()=>{if(typeof window>"u")return null;const z=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof z=="number"&&Number.isFinite(z)&&z>0)return z;if(typeof navigator>"u")return null;const qe=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!qe)return null;const ut=Number.parseInt(qe[1],10),Tt=Number.parseInt(qe[2],10);return Number.isNaN(ut)?null:ut===10?Tt:ut},[]);qt.useEffect(()=>{typeof window>"u"||g(Bs())},[]);const D=l.useMemo(()=>Si(),[]),y=X(z=>z.shortcutOverrides),N=xs(Ts("rename_current_session",y),""),j=X(z=>z.workStatusPanelVisible),v=X(z=>z.workStatusPanelEnabled),M=X(z=>z.setWorkStatusPanelEnabled),W=X(z=>z.workStatusPanelFits),G=X(z=>z.workStatusOverlayOpen),O=X(z=>z.setWorkStatusOverlayOpen),Q=v&&W||G,B=l.useCallback(()=>{if(v&&!W){O(!G);return}M(!v)},[O,M,G,v,W]),oe=a?d??null:null,H=l.useRef(null),[P,te]=l.useState(0);l.useEffect(()=>{if(!a){H.current&&(H.current=null,te(Tt=>Tt+1));return}if(oe){H.current={sessionId:a,session:oe,expiresAt:Date.now()+2e3};return}const z=H.current;if(!z||z.sessionId!==a)return;const qe=z.expiresAt-Date.now();if(qe<=0){H.current=null,te(Tt=>Tt+1);return}const ut=window.setTimeout(()=>{H.current?.sessionId===a&&(H.current=null),te(Tt=>Tt+1)},qe);return()=>{window.clearTimeout(ut)}},[a,oe]);const J=(()=>{if(oe)return oe;if(!a)return null;const z=H.current;return z&&z.sessionId===a&&z.expiresAt>Date.now()?z.session:null})(),le=et(z=>a?z.worktreeMetadata.get(a)?.path??"":""),K=et(z=>a?z.worktreeMetadata.get(a)?.branch?.trim()??null:null),U=Tc(z=>a?z.getAttachment(a):void 0),$=l.useMemo(()=>U?em(U,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,U]),ee=l.useMemo(()=>U?U.legacy?"legacy":U.degraded?"degraded":U.worktreeStatus==="pending"?"pending":U.worktreeStatus==="missing"?"missing":U.worktreeStatus==="invalid"?"invalid":U.attentionReason?"attention":null:null,[U]),Y=l.useMemo(()=>vn(le||""),[le]),ie=l.useMemo(()=>{const z=typeof J?.directory=="string"?J.directory:"";return vn(z||"")},[J?.directory]),V=oc(a??"",ie),fe=et(z=>z.newSessionDraft?.open?vn(z.newSessionDraft.bootstrapPendingDirectory??z.newSessionDraft.directoryOverride??""):""),Se=et(z=>z.newSessionDraft.target),Te=et(z=>z.newSessionDraft.selectedProjectId),ue=et(z=>z.currentSessionDirectory),Me=ls(z=>z.homeDirectory),Ae=mr(),De=l.useMemo(()=>Y||ie||(ao(Ae,fe)??""),[fe,Ae,ie,Y]),Be=et(z=>{const qe=vn(Y||ie||"");if(!qe)return null;for(const ut of z.availableWorktreesByProject.values()){const Vt=Lr(ut,qe)?.branch?.trim();if(Vt)return Vt}return null}),ve=tm(De||null)||K||Be,Pe=i?Se==="chat":ql(ie||ue,Me),he=!Pe&&!j&&!!(p||ve||!i&&ee),Fe=l.useMemo(()=>{if(!a)return p??"OpenChamber";const z=J?.title?.trim();return z&&z.length>0?z:"Untitled Session"},[p,J?.title,a]),_e=sm(),We=et(z=>z.updateSessionTitle),Xe=et(z=>z.archiveSessions),Ve=et(z=>z.deleteSessions),[S,ne]=l.useState(!1),[q,ke]=l.useState(!1),Ee=l.useRef(null),[Ie,Ne]=l.useState(""),[ze,Ue]=l.useState(!1),[Ge,Qe]=l.useState(null),He=ps(z=>Ge&&z.entityById.get(Ge)?.title?.trim()||null)??t("sessions.sidebar.session.untitled"),Ke=l.useRef(null),Ye=l.useCallback(()=>{a&&(Ne(J?.title?.trim()||Fe),ne(!0))},[J?.title,a,Fe]),it=l.useRef(Ye);it.current=Ye;const bt=l.useCallback(z=>{z&&(z.focus(),z.select())},[]);l.useEffect(()=>{if(ke(!1),Qe(null),a&&Ee.current===a){Ee.current=null,it.current();return}ne(!1),Ne("")},[a]);const nt=l.useCallback(async()=>{if(!a)return;const z=Ie.trim();z&&z!==J?.title?.trim()&&await We(a,z),ne(!1)},[J?.title,a,Ie,We]);l.useEffect(()=>{if(!S)return;const z=qe=>{const ut=qe.target;(!ut||!Ke.current?.contains(ut))&&nt()};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[S,nt]);const ft=l.useCallback(z=>{z&&no(z).then(qe=>{Re[qe.ok?"success":"error"](t(qe.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Re.error(t("sessions.sidebar.session.copyId.error")))},[t]),ae=l.useCallback(async()=>{if(!a||!De){Re.error(t("sessions.sidebar.session.export.nothingToExport"));return}const z=await _e({sessionID:a,directory:De}).catch(()=>null);if(!z){Re.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(z.length===0){Re.error(t("sessions.sidebar.session.export.nothingToExport"));return}const qe=nm(z,J?.title??null),ut=rm(J?.title??null);await om(qe,ut)||im(qe,ut),Re.success(t("sessions.sidebar.session.export.success"))},[J?.title,a,_e,De,t]),de=am(),be=l.useMemo(()=>lm(de),[de]),C=l.useCallback(z=>{a&&jf({entry:z,t,session:{id:a,title:J?.title,directory:ie??De},loadRecords:async()=>{if(!De)return null;try{return await _e({sessionID:a,directory:De})}catch{return null}},onLoadFailed:()=>Re.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[J?.title,a,_e,De,ie,t]),ce=l.useCallback(z=>be.map(qe=>s.jsxs(z,{onClick:()=>C(qe),children:[s.jsx(Pi,{icon:qe.icon,iconSrc:qe.iconSrc,className:"me-1 size-4"}),qe.action.label]},`${qe.guest.id}:${qe.action.id}`)),[be,C]),L=u?.type==="busy"||u?.type==="retry",ge=l.useCallback(()=>{if(!a||!ie||L||c)return;const qe=ps.getState().activeSessions.find(ut=>ut.id===a);qe&&cm({kind:"quick",root:qe,descendants:um(qe,[]),sourceDirectory:ie,messages:dm(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[a,L,c,ie,t]),Ce=l.useCallback(async(z,qe)=>{const ut=[qe,...fm(qe,[],z==="delete")],Tt=et.getState().currentSessionId===qe?qe:null;if(z==="delete"){const{failedIds:Mt}=await Ve(ut);Mt.length>0?Re.error(t("sessions.sidebar.session.delete.error")):Re.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:Vt,failedIds:Ht}=await Xe(ut);if(Ht.length>0){Re.error(t("sessions.sidebar.session.archive.error"));return}Re.success(t("sessions.sidebar.session.archive.success"),pm(Vt,Tt,t))},[Xe,Ve,t]),Je=l.useCallback(async()=>{Ge&&(Qe(null),await Ce("delete",Ge))},[Ge,Ce]),Oe=X(z=>z.openGuestPageId),me=Ri(z=>z.guests.find(qe=>qe.id===Oe)),je=X(z=>z.isScheduledTasksDialogOpen),st=X(z=>z.isArchivePageOpen),ye=X(z=>z.isIntegrationsCatalogOpen),ot=X(z=>z.isUsageStatsPageOpen),Ct=X(z=>z.isSourceBoardOpen),xt=X(z=>z.isOverviewOpen),jt=X(z=>z.worktreesPageProjectId),ct=X(z=>z.isolatedSpacesEnabled?z.spacesPageProjectId:null),vt=X(z=>z.runOverviewKey),St=Cf(vt),mt=jt??ct,yt=ts(z=>{if(!mt)return null;const qe=z.projects.find(ut=>ut.id===mt);return qe?.label?.trim()||qe?.path?.split("/").pop()||null}),lt=l.useMemo(()=>me?{title:me.pageTitle??me.name,subtitle:null}:je?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:st?{title:t("sessions.archivePage.title"),subtitle:null}:ye?{title:t("integrationsCatalog.page.title"),subtitle:null}:ot?{title:t("usageStats.title"),subtitle:null}:Ct?{title:t("sourceBoard.title"),subtitle:null}:xt?{title:t("overview.title"),subtitle:null}:jt?{title:t("sessions.worktreesPage.title",{project:yt??""}),subtitle:null}:ct?{title:t("spaces.page.title",{project:yt??""}),subtitle:null}:vt?{title:St??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[me,st,ye,St,vt,je,Ct,xt,ot,ct,yt,t,jt]),Nt=ie||vn(ue||"")||Y,_t=l.useCallback(()=>{Zs("desktop_open_draft_mini_chat_window",{directory:Pe?"":fe,projectId:Pe?null:Te,...Cr()}).catch(z=>{console.warn("[header] failed to open draft mini chat window",z)})},[fe,Te,Pe]),ht=l.useCallback(()=>{if(i){_t();return}a&&Zs("desktop_open_session_mini_chat_window",{sessionId:a,directory:ie||vn(ue||"")||Y,...Cr()}).catch(z=>{console.warn("[header] failed to open session mini chat window",z)})},[a,_t,i,ue,ie,Y]),gt=x&&(i||!!a),Dt=l.useCallback((z,qe)=>{Zs("desktop_open_session_mini_chat_window",{sessionId:z,directory:qe,...Cr()}).catch(ut=>{console.warn("[header] failed to open session mini chat window",ut)})},[]),Kt=zn,Yt=l.useMemo(()=>b&&E&&!T?"88px":w?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!b||F)&&!D?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[b,T,E,w,D,F]),js=(!b||F)&&!D?"calc(0.75rem + var(--oc-wco-right-inset, 0px))":"0.75rem",Wt=e==="rtl",ds=Wt?js:Yt,us=Wt?Yt:js,Jt=F&&_!==Gl(e);qt.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",ds)},[ds]);const Is=n?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",rs=n?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";qt.useEffect(()=>{if(!b||!E){k(!1);return}let z=!1;const qe=async()=>{try{const Tt=await Zs("desktop_is_window_fullscreen");z||k(Tt===!0)}catch{z||k(!1)}},ut=()=>{qe()};return qe(),window.addEventListener("openchamber:window-resized",ut),()=>{z=!0,window.removeEventListener("openchamber:window-resized",ut)}},[b,E]);const os=l.useMemo(()=>!b||!E||A===null?"":A>=26?"h-11":A<=15?"h-14":"",[b,E,A]),Ut=l.useMemo(()=>b&&E&&!T?A!==null&&A<=15?"56px":"44px":"0px",[b,T,E,A]),Hs=l.useMemo(()=>{const qe=`max(${b&&E?"2.75rem":"3rem"}, ${Ut}, var(--oc-wco-titlebar-height, 0px))`,ut=b&&!F||D;if(ut&&Ut==="0px")return{};const Tt={minHeight:qe,height:qe};return!Jt&&(!ut||Wt)&&(Tt.paddingInlineEnd=us),Tt},[Jt,b,E,Wt,D,us,Ut,F]),re=l.useRef(null),Ze=l.useCallback(z=>{!z||z===re.current||(re.current=z,document.documentElement.style.setProperty("--oc-header-height",`${z}px`))},[]),pt=l.useCallback(()=>{typeof document>"u"||Ze(h.current?.getBoundingClientRect().height)},[Ze]);qt.useEffect(()=>{if(typeof window>"u")return;pt();const z=h.current;if(!z||typeof ResizeObserver>"u")return()=>{};let qe=0;const ut=()=>{qe||(qe=requestAnimationFrame(()=>{qe=0,pt()}))},Tt=new ResizeObserver(Vt=>{const Ht=Vt[Vt.length-1];Ze(Ht?.borderBoxSize?.[0]?.blockSize??Ht?.target.getBoundingClientRect().height)});return Tt.observe(z),window.addEventListener("resize",ut),window.addEventListener("orientationchange",ut),()=>{qe&&cancelAnimationFrame(qe),Tt.disconnect(),window.removeEventListener("resize",ut),window.removeEventListener("orientationchange",ut)}},[Ze,pt]),qt.useEffect(()=>{pt()},[pt,m,os]);const kt=l.useCallback(async z=>{const qe=z.target;qe.closest(".app-region-no-drag")||qe.closest("button, a, input, select, textarea")||z.button===0&&b&&await Pu()},[b]);mm({rename_current_session:()=>{if(!a||m)return!1;Ye()},archive_current_session:()=>{if(!a||m||ps.getState().entityById.get(a)?.time.archived)return!1;Ce("archive",a)}});const Pt=l.useCallback(({session:z,open:qe,isActive:ut,select:Tt,closeOtherTabs:Vt,components:Ht})=>{const{Item:Mt,Separator:fs}=Ht,Mn=ut&&!D&&!Pe&&J&&!J.parentId,Fn=ut&&!D&&J&&qa(J);return s.jsxs(s.Fragment,{children:[s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(Mt,{onClick:()=>{ut||Tt(),Ee.current=z.id},children:[s.jsx(se,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename"),ut&&N?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:N}):null]})}),s.jsx(ga,{sessionID:z.id,directory:z.directory,open:qe,Item:Mt}),s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(Mt,{onClick:()=>ft(z.id),children:[s.jsx(se,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),s.jsx(fs,{}),ut?s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(Mt,{onClick:()=>{ae()},children:[s.jsx(se,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}):null,x?s.jsxs(Mt,{onClick:()=>Dt(z.id,ut?Nt:z.directory??""),children:[s.jsx(se,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,ut?ce(Mt):null,Mn?s.jsx(as,{hint:t(c?"sessions.sidebar.session.moveToWorktree.tooltipMoving":L?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:s.jsx("span",{className:"block",children:s.jsxs(Mt,{disabled:!ie||L||c,onClick:ge,className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,Fn?s.jsx(as,{hint:t(L?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveSession.hint"),children:s.jsx("span",{className:"block",children:s.jsxs(Mt,{disabled:!ie||L||c,onClick:()=>Ue(!0),className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveSession.menu")]})})}):null,s.jsx(fs,{}),s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:s.jsxs(Mt,{onClick:Vt,children:[s.jsx(se,{name:"close-circle",className:"me-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]})}),s.jsx(fs,{}),s.jsx(L1,{session:z,Item:Mt}),s.jsx(Wa,{sessionId:z.id,Item:Mt,onArchive:()=>{Ce("archive",z.id)}}),s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(Mt,{className:"text-destructive focus:text-destructive",onClick:()=>Qe(z.id),children:[s.jsx(se,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})},[ft,J,Nt,ae,x,Pe,L,c,D,ge,Dt,ce,N,Ce,ie,t]),Zt=()=>s.jsxs("div",{onMouseDown:kt,className:Le("app-region-drag relative flex h-12 select-none items-center",Jt?"pe-0":"pe-2.5",os),style:Hs,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:Is,transitionDuration:`${r}ms`,transitionTimingFunction:Rn}}),s.jsx("div",{ref:Sd,"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:rs,transitionDuration:`${r}ms`,transitionTimingFunction:Rn}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[lt?s.jsxs(s.Fragment,{children:[s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"icon",className:"app-region-no-drag me-1 size-6 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>X.getState().closeMainSurfaces(),children:s.jsx(se,{name:"arrow-left",className:"size-4"})})}),s.jsx($t,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"me-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-start",children:[s.jsx("span",{className:"truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:lt.title}),lt.subtitle?s.jsx("span",{className:"truncate typography-micro text-[0.65625rem] font-normal leading-tight text-muted-foreground max-w-full",children:lt.subtitle}):null]})]}):D||!o?s.jsxs("div",{className:"app-region-no-drag me-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-start",children:[V?s.jsx(se,{name:"loader-4",className:"me-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,n?null:s.jsxs(Lt,{children:[s.jsx(jb,{align:"start",children:s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",className:Kt,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(se,{name:"history",className:"h-4 w-4"})})})}),s.jsx($t,{side:"bottom",children:s.jsx(Ws,{label:t("sessions.switcher.openAria"),shortcut:xs(Ts("open_session_list",y),"")})})]}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[S?s.jsxs("form",{ref:Ke,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:z=>z.stopPropagation(),onSubmit:z=>{z.preventDefault(),nt()},children:[s.jsx("input",{ref:bt,value:Ie,onChange:z=>Ne(z.target.value),onKeyDown:z=>ba(z,()=>ne(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[0.875rem] 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(se,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>ne(!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(se,{name:"close",className:"size-4"})})]}):i?null:s.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:Fe}),he?s.jsxs("span",{className:Le("flex min-w-0 max-w-full items-center gap-1.5 truncate font-normal leading-tight",i?"typography-ui-label text-[0.875rem] text-foreground":"typography-micro text-[0.65625rem] text-muted-foreground"),children:[p?s.jsx("span",{className:"truncate",children:p}):null,ve?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(se,{name:"git-branch",className:Le("flex-shrink-0 text-muted-foreground",i?"h-3.5 w-3.5":"h-3 w-3")}),s.jsx("span",{className:Le("truncate",i&&"text-muted-foreground"),children:ve})]}):null,!i&&ee?s.jsxs("span",{className:Le("inline-flex min-w-0 items-center gap-0.5",ee==="attention"||ee==="invalid"||ee==="missing"?"text-status-warning":"text-muted-foreground"),children:[s.jsx(se,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:$})]}):null]}):null]}),s.jsx("div",{className:Le("flex h-[1.125rem] shrink-0 items-center justify-center",he?"self-start":"self-center"),children:a&&!i&&!S?s.jsxs(pn,{open:q,onOpenChange:ke,onOpenChangeComplete:z=>{!z&&Ee.current&&Ee.current===a&&(Ee.current=null,Ye())},children:[s.jsx(mn,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"xs",className:"h-[1.125rem] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(se,{name:"more",className:"size-4"})})}),s.jsxs(hn,{align:"end",className:"min-w-[190px]",children:[s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(Gt,{onClick:()=>{Ee.current=a},children:[s.jsx(se,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename"),N?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:N}):null]})}),s.jsx(ga,{sessionID:a,directory:ie,open:q,Item:Gt}),s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(Gt,{onClick:()=>a&&ft(a),children:[s.jsx(se,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),s.jsx(un,{}),s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(Gt,{onClick:()=>{ae()},children:[s.jsx(se,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}),x?s.jsxs(Gt,{onClick:()=>Dt(a,Nt),children:[s.jsx(se,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,ce(Gt),!D&&!Pe&&J&&!J.parentId?s.jsx(as,{hint:t(c?"sessions.sidebar.session.moveToWorktree.tooltipMoving":L?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:s.jsx("span",{className:"block",children:s.jsxs(Gt,{disabled:!ie||L||c,onClick:ge,className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,!D&&J&&qa(J)?s.jsx(as,{hint:t(L?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveSession.hint"),children:s.jsx("span",{className:"block",children:s.jsxs(Gt,{disabled:!ie||L||c,onClick:()=>Ue(!0),className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveSession.menu")]})})}):null,s.jsx(un,{}),s.jsx(Wa,{sessionId:a,Item:Gt,onArchive:()=>{Ce("archive",a)}}),s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(Gt,{className:"text-destructive focus:text-destructive",onClick:()=>{a&&Qe(a)},children:[s.jsx(se,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})]}):null})]}):s.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-start",children:s.jsx(a1,{renderMenu:Pt,suppressActiveTabControls:S,onMenuOpenChangeComplete:z=>{!z&&Ee.current&&Ee.current===a&&(Ee.current=null,Ye())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:S?s.jsxs("form",{ref:Ke,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:z=>z.stopPropagation(),onSubmit:z=>{z.preventDefault(),nt()},children:[s.jsx("input",{ref:bt,value:Ie,onChange:z=>Ne(z.target.value),onKeyDown:z=>ba(z,()=>ne(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[0.8125rem] 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(se,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>ne(!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(se,{name:"close",className:"size-4"})})]}):s.jsx("span",{dir:"auto",className:"block overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4 text-foreground max-w-full",children:i?t("sessions.switcher.draftTitle"):Fe})})})}),lt||D||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!D&&!lt?s.jsxs(s.Fragment,{children:[s.jsx(Z1,{buttonClassName:zn}),s.jsx(fx,{buttonClassName:zn})]}):null,gt?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":t(i?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:ht,className:zn,children:s.jsx(se,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),s.jsx($t,{side:"bottom",children:s.jsx(Ws,{label:t(i?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),shortcut:i?xs(Ts("new_mini_chat",y),""):void 0})})]}):null,D?null:s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":Q,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:B,className:Le(zn,Q&&"text-foreground"),children:s.jsx(se,{name:"list-indefinite",className:"h-4 w-4"})})}),s.jsx($t,{side:"bottom",children:t(v&&!W?G?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":v?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),s.jsx(id,{visible:Jt,position:_})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:h,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:Zt()}),ze&&a&&ie?s.jsx(hm,{open:!0,onOpenChange:Ue,sessionId:a,sourceDirectory:ie}):null,s.jsx(tr,{open:Ge!==null,onOpenChange:z=>{z||Qe(null)},children:s.jsxs(sr,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(nr,{children:[s.jsx(rr,{children:t("sessions.sidebar.dialogs.deleteSession.title")}),s.jsx(or,{children:t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:He})})]}),s.jsxs($r,{children:[s.jsx(dt,{variant:"outline",size:"sm",onClick:()=>Qe(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{variant:"destructive",size:"sm",onClick:()=>{Je()},children:t("sessions.sidebar.bulkActions.delete")})]})]})})]})},Ka=280,Ga=264,Za=500,bx=({isOpen:t,isMobile:e,children:n,className:r,topBar:o,peek:i})=>{const{t:a,direction:u}=at(),c=X(H=>H.sidebarWidth),d=X(H=>H.setSidebarWidth),[f,p]=l.useState(!1),m=l.useRef(0),h=l.useRef(c||Ka),b=l.useRef(null),g=l.useRef(null),x=l.useRef(null),w=l.useRef(null),T=l.useRef(null),k=l.useCallback(H=>Math.min(Za,Math.max(Ga,H)),[]),E=l.useCallback(()=>{const H=T.current;if(H?.isConnected)return H;const P=document.querySelector("[data-titlebar-left-controls]");return T.current=P,P},[]),F=l.useCallback(H=>{const P=w.current;if(!P)return;P.style.width=`${H}px`,P.style.minWidth=`${H}px`,P.style.maxWidth=`${H}px`,P.style.setProperty("--oc-left-sidebar-width",`${H}px`);const te=E();te&&te.style.setProperty("--oc-left-sidebar-width",`${H}px`)},[E]);l.useEffect(()=>{e&&f&&p(!1)},[e,f]),l.useEffect(()=>{f||(b.current=null,g.current=null,x.current?.(),x.current=null)},[f]),l.useEffect(()=>{!t&&f&&p(!1)},[t,f]),l.useEffect(()=>()=>{x.current?.(),x.current=null},[]);const _=Math.min(Za,Math.max(Ga,c||Ka)),A=t?_:0,D=f?b.current??A:A,y=f?D:_;l.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${y}px`);const H=T.current;!f&&H&&H.style.removeProperty("--oc-left-sidebar-width")},[y,f]);const[N,j]=l.useState(!t);t&&N&&j(!1);const v=io(),M=l.useRef(t),W=l.useRef(t);if(l.useLayoutEffect(()=>{M.current=t,W.current!==t&&(W.current=t,Nc(v),t||Di(()=>{M.current||j(!0)}))},[t,v]),e)return null;const G=H=>{if(t){try{H.currentTarget.setPointerCapture(H.pointerId)}catch{}g.current=H.pointerId,p(!0),m.current=H.clientX,h.current=A,b.current=A,F(A),x.current?.(),x.current=Ec(),H.preventDefault()}},O=H=>{if(e||!f||g.current!==H.pointerId)return;const P=(H.clientX-m.current)*(u==="rtl"?-1:1),te=k(h.current+P);b.current!==te&&(b.current=te,F(te))},Z=H=>{if(g.current!==H.pointerId||e)return;try{H.currentTarget.releasePointerCapture(H.pointerId)}catch{}const P=k(b.current??A);g.current=null,b.current=null,p(!1),d(P),x.current?.(),x.current=null},Q=!t&&i?i.state:!1,B=Q!==!1,oe=B&&i&&i.animationMs>0?`${Q==="in"?"oc-sidebar-peek-in":"oc-sidebar-peek-out"} ${i.animationMs}ms ${Rn} forwards`:void 0;return s.jsxs("div",{ref:w,"data-left-sidebar":"",className:Le("relative flex h-full",!B&&"overflow-hidden",f?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",r),style:{width:`${D}px`,minWidth:`${D}px`,maxWidth:`${D}px`,"--oc-left-sidebar-width":`${y}px`,overflowX:B?void 0:"clip",transitionDuration:`${v}ms`,transitionTimingFunction:Rn},children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-0.5px_0_0_0_var(--oc-edge-strong)] rtl:shadow-[inset_0.5px_0_0_0_var(--oc-edge-strong)]","aria-hidden":"true"}),t&&s.jsx("div",{className:Le("absolute inset-e-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",f&&"bg-[var(--interactive-border)]"),onPointerDown:G,onPointerMove:O,onPointerUp:Z,onPointerCancel:Z,onLostPointerCapture:Z,role:"separator","aria-orientation":"vertical","aria-label":a("sidebar.resize.leftPanelAria")}),s.jsxs("aside",{ref:i?.overlayRef,"data-sidebar-peek":B?Q:void 0,className:Le("flex h-full shrink-0 flex-col",B?"absolute inset-s-0 top-0 z-[25] bg-sidebar shadow-xl":"relative z-10 transition-opacity ease-out motion-reduce:transition-none",f&&"pointer-events-none",!t&&!B&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${v}ms`,overflowX:"hidden",contentVisibility:N&&!B?"hidden":void 0,animation:oe,"--oc-peek-offset":u==="rtl"?"100%":"-100%"},inert:!t&&!B||void 0,onPointerEnter:B?i?.overlayHandlers.onPointerEnter:void 0,onPointerLeave:B?i?.overlayHandlers.onPointerLeave:void 0,onAnimationEnd:B?i?.overlayHandlers.onAnimationEnd:void 0,children:[o,s.jsx(hs,{outerClassName:"overlay-scrollbar-wrapper--no-gutter flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Qt,{children:n})})]})]})},xx=()=>{const t=$e.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-start-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",{ref:Sd,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},wx=50,yx=18,vx=300,Sx='[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]',kd=t=>!document.getElementById("root")?.contains(t),kx=t=>{if((Jr(document.documentElement)?window.innerWidth-t.clientX:t.clientX)>yx)return!1;const n=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--oc-header-height"))||48;return t.clientY>=n},Xa=t=>{const e=document.activeElement;return t&&e instanceof HTMLElement&&t.contains(e)&&(e.isContentEditable||e.matches("input, textarea"))?!0:Array.from(document.querySelectorAll(Sx)).some(n=>kd(n)&&n.getClientRects().length>0)},jx=({enabled:t,layoutAnimationMs:e})=>{const[n,r]=l.useState(!1),o=gm()?0:e,i=o>0,a=l.useRef(null),u=l.useRef(null),c=l.useRef(null),d=l.useCallback(()=>{u.current!==null&&clearTimeout(u.current),c.current!==null&&clearTimeout(c.current),u.current=null,c.current=null},[]),f=l.useCallback(()=>{d(),r(b=>b==="in"&&i?"out":!1)},[i,d]),p=l.useCallback(()=>{c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{if(c.current=null,Xa(a.current)){p();return}f()},vx)},[f]),m=l.useCallback(()=>{c.current!==null&&clearTimeout(c.current),c.current=null},[]);l.useEffect(()=>{t||(d(),r(!1))},[d,t]),l.useEffect(()=>d,[d]),l.useEffect(()=>{if(n!=="in")return;const b=w=>{const T=w.target;T instanceof Element&&(a.current?.contains(T)||kd(T)||f())},g=w=>{Ic(w)||w.key!=="Escape"||w.defaultPrevented||Xa(a.current)||f()},x=w=>{w.relatedTarget===null&&p()};return document.addEventListener("pointerdown",b,!0),document.addEventListener("keydown",g),document.addEventListener("pointerout",x),()=>{document.removeEventListener("pointerdown",b,!0),document.removeEventListener("keydown",g),document.removeEventListener("pointerout",x)}},[f,p,n]),l.useEffect(()=>{if(!t||n!==!1)return;const b=()=>{u.current!==null&&clearTimeout(u.current),u.current=null},g=w=>{if(w.pointerType!=="mouse"||w.buttons!==0||!kx(w)){b();return}u.current===null&&(u.current=setTimeout(()=>{u.current=null,r("in")},wx))},x=w=>{w.relatedTarget===null&&b()};return document.addEventListener("pointermove",g,{passive:!0}),document.addEventListener("pointerout",x),()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerout",x),b()}},[t,n]);const h=l.useMemo(()=>({onPointerEnter:()=>{m(),r(b=>b==="out"?"in":b)},onPointerLeave:()=>{n==="in"&&p()},onAnimationEnd:b=>{b.target===b.currentTarget&&r(g=>g==="out"?!1:g)}}),[m,p,n]);return{state:t?n:!1,animationMs:o,overlayRef:a,overlayHandlers:h}},wr="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",Cx=()=>{const t=$e.c(47),{t:e,locale:n,direction:r}=at(),o=X(Tx),i=X(Nx),a=X(Ex),u=l.useRef(null),c=xs(Ts("toggle_sidebar",a)),d=Ix,f=X(Px),{usesFramelessChrome:p,side:m}=od();let h;t[0]!==n?(h=P=>{const te=P.currentTarget.getBoundingClientRect();Zs("desktop_show_app_menu",{x:te.left,y:te.bottom,locale:n}).catch(Rx)},t[0]=n,t[1]=h):h=t[1];const b=h;let g,x;t[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{if(typeof document>"u")return;const P=u.current;if(!P)return;const te=()=>{const le=Math.max(P.getBoundingClientRect().width,P.scrollWidth);hx(le)};if(te(),typeof ResizeObserver>"u")return;const J=new ResizeObserver(te);return J.observe(P),()=>{J.disconnect()}},x=[],t[2]=g,t[3]=x):(g=t[2],x=t[3]),l.useEffect(g,x);const w="",T="app-region-no-drag absolute inset-s-0 top-0 z-30 flex select-none items-center pe-2",k=i?"var(--oc-left-sidebar-width, 100%)":void 0;let E;t[4]!==k?(E={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:k},t[4]=k,t[5]=E):E=t[5];const F="flex min-w-0 items-center gap-2";let _;t[6]!==r||t[7]!==p||t[8]!==m?(_=p&&m===Gl(r)?s.jsx(id,{visible:!0,position:m}):null,t[6]=r,t[7]=p,t[8]=m,t[9]=_):_=t[9];let A;t[10]!==b||t[11]!==e||t[12]!==p?(A=p?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:b,"aria-label":e("header.actions.openAppMenuAria"),className:Le(wr,"shrink-0"),children:s.jsx(se,{name:"menu-2",className:"h-4 w-4"})})}),s.jsx($t,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=b,t[11]=e,t[12]=p,t[13]=A):A=t[13];const D=Lt;let y;t[14]!==e?(y=e("header.actions.openSessionsAria"),t[14]=e,t[15]=y):y=t[15];const N=i&&"text-foreground";let j;t[16]!==N?(j=Le(wr,"shrink-0",N),t[16]=N,t[17]=j):j=t[17];let v;t[18]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(se,{name:"layout-left",className:"h-4 w-4"}),t[18]=v):v=t[18];let M;t[19]!==i||t[20]!==y||t[21]!==j||t[22]!==o?(M=s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":y,"aria-pressed":i,className:j,children:v})}),t[19]=i,t[20]=y,t[21]=j,t[22]=o,t[23]=M):M=t[23];const W=$t,G=e("header.actions.openSessionsWithShortcut",{shortcut:c});let O;t[24]!==G?(O=s.jsx("p",{children:G}),t[24]=G,t[25]=O):O=t[25];let Z;t[26]!==W||t[27]!==O?(Z=s.jsx(W,{children:O}),t[26]=W,t[27]=O,t[28]=Z):Z=t[28];let Q;t[29]!==D||t[30]!==M||t[31]!==Z?(Q=s.jsxs(D,{children:[M,Z]}),t[29]=D,t[30]=M,t[31]=Z,t[32]=Q):Q=t[32];let B;t[33]!==d||t[34]!==i||t[35]!==a||t[36]!==e||t[37]!==f?(B=f?null:i?s.jsxs("button",{type:"button",onClick:d,className:Le(wr,"-ms-1 w-auto min-w-0 ps-1 pe-1.5 font-normal"),children:[s.jsx(se,{name:"chat-new",className:"h-4 w-4 shrink-0"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Le(wr,"-ms-1 shrink-0"),children:s.jsx(se,{name:"chat-new",className:"h-4 w-4"})})}),s.jsx($t,{children:s.jsx(Ws,{label:e("sessions.sidebar.header.actions.newSession"),shortcut:xs(Ts("new_chat",a),"")})})]}),t[33]=d,t[34]=i,t[35]=a,t[36]=e,t[37]=f,t[38]=B):B=t[38];let oe;t[39]!==Q||t[40]!==B||t[41]!==_||t[42]!==A?(oe=s.jsxs("div",{ref:u,className:F,children:[_,A,Q,B]}),t[39]=Q,t[40]=B,t[41]=_,t[42]=A,t[43]=oe):oe=t[43];let H;return t[44]!==oe||t[45]!==E?(H=s.jsx("div",{"data-titlebar-left-controls":w,className:T,style:E,children:oe}),t[44]=oe,t[45]=E,t[46]=H):H=t[46],H};function Tx(t){return t.toggleSidebar}function Nx(t){return t.isSidebarOpen}function Ex(t){return t.shortcutOverrides}function Ix(){X.getState().closeMainSurfaces(),et.getState().openNewSessionDraft()}function Px(t){return t.sessionTabsEnabled&&!(t.isScheduledTasksDialogOpen||t.isArchivePageOpen||t.isIntegrationsCatalogOpen||t.isUsageStatsPageOpen||t.isSourceBoardOpen||t.isOverviewOpen||t.worktreesPageProjectId!==null||t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null||t.runOverviewKey!==null||t.openGuestPageId!==null)}function Rx(t){console.warn("[titlebar] failed to open app menu",t)}function Dx(t,e,n){const r=$e.c(5),[o,i]=l.useState();let a,u;return r[0]!==n||r[1]!==t||r[2]!==e?(a=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let c=!1;return(async()=>{const[d,f]=await Promise.all([bm(t),xm(t)]).catch(Ax);if(c)return;const p=Xt(d),m=Xt(f);if(!p||!m||m===p)return;const h=n||"",b=m.split("/").filter(Boolean).pop()||m;i({source:"sdk",path:m,projectDirectory:p,branch:h,label:h||b,name:b,worktreeRoot:m,worktreeStatus:"ready",headState:h?"branch":"unborn",worktreeSource:"existing"})})(),()=>{c=!0}},u=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=a,r[4]=u):(a=r[3],u=r[4]),l.useEffect(a,u),e??o}function Ax(){return["",""]}const _x=()=>{const t=$e.c(3),e=X(Ox),n=X(Mx);let r;return t[0]!==e||t[1]!==n?(r=()=>{n("integrations"),e(!0)},t[0]=e,t[1]=n,t[2]=r):r=t[2],r};function Ox(t){return t.setSettingsDialogOpen}function Mx(t){return t.setSettingsPage}const Ya="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-edge bg-muted/80",Fx=({className:t,identity:e})=>{const{t:n}=at(),{sourceControl:r}=Es(),o=wm(e),i=ji(e.provider),a=i.label,u=o?.status??null,c=fn(w=>w.setStatus),[d,f]=l.useState(!1),p=l.useCallback(async w=>{if(!(!w||d)){f(!0);try{c(e,await r.authActivate(e,w))}catch(T){console.error("Failed to switch source control account:",T)}finally{f(!1)}}},[e,d,c,r]);if(u?.status!=="connected")return null;const m=u.user.username||null,h=u.user.avatarUrl??null,b=u.accounts,g=m?n("header.sourceControl.connectedWithLogin",{login:m,provider:a}):n("header.sourceControl.connected",{provider:a}),x=h?s.jsx("img",{src:h,alt:m?n("header.sourceControl.avatarWithLogin",{login:m}):n("header.sourceControl.avatar",{provider:a}),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(Ca,{descriptor:i,variant:"fill",className:"h-3.5 w-3.5 text-foreground"});return b.length<=1?s.jsx("div",{className:Le(Ya,t),title:g,children:x}):s.jsxs(pn,{children:[s.jsx(mn,{asChild:!0,children:s.jsx("button",{type:"button",className:Le(Ya,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:g,disabled:d,children:x})}),s.jsxs(hn,{align:"end",className:"w-64",children:[s.jsx(Er,{className:"typography-ui-header font-semibold text-foreground",children:n("header.sourceControl.accountsTitle",{provider:a})}),s.jsx(un,{}),b.map(w=>{const T=w.user,k=!!w.current,E=n(ym(w.source??"oauth"));return s.jsxs(Gt,{className:"gap-2",disabled:d,onSelect:()=>{k||p(w.id)},children:[T?.avatarUrl?s.jsx("img",{src:T.avatarUrl,alt:T.username?n("header.sourceControl.avatarWithLogin",{login:T.username}):n("header.sourceControl.avatar",{provider:a}),className:"h-6 w-6 rounded-full border border-edge 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-edge bg-muted",children:s.jsx(Ca,{descriptor:i,variant:"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:T?.name?.trim()||T.username||i.label}),T.username?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:T.username}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:E})]}):null]}),k?s.jsx(se,{name:"check",className:"h-4 w-4 text-primary"}):null]},w.id)})]})]})},Lx=t=>JSON.stringify(vm(t)),$x=async(t,e)=>{const n=await t.projectUpstream(e);if(!n?.isFork||!n.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,n.upstream.owner,n.upstream.name);return{upstream:n.upstream,branches:r}},jd=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function Bx(t){if(!jd(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function zx(t,e,n){const r=$e.c(18),{sourceControl:o}=Es(),i=ji(t.provider).features.referenceSearch,[a,u]=qt.useState(null);let c;r[0]!==t.bindingRevision||r[1]!==t.provider||r[2]!==t.repositoryId||r[3]!==e?(c=JSON.stringify([t.provider,t.repositoryId,t.bindingRevision,e]),r[0]=t.bindingRevision,r[1]=t.provider,r[2]=t.repositoryId,r[3]=e,r[4]=c):c=r[4];const d=c;let f;r[5]!==t||r[6]!==d||r[7]!==e||r[8]!==i||r[9]!==o?(f=()=>{if(!i)return;let m=!1;return o.references(t,{kind:"pull",query:`#${e}`}).then(h=>{if(m||!h.connected)return;const b=h.items.find(g=>g.kind==="pull"&&g.number===e);b&&u({key:d,pull:b})}).catch(Wx),()=>{m=!0}},r[5]=t,r[6]=d,r[7]=e,r[8]=i,r[9]=o,r[10]=f):f=r[10];let p;return r[11]!==t||r[12]!==d||r[13]!==e||r[14]!==n||r[15]!==i||r[16]!==o?(p=[t,d,e,n,i,o],r[11]=t,r[12]=d,r[13]=e,r[14]=n,r[15]=i,r[16]=o,r[17]=p):p=r[17],qt.useEffect(f,p),a?.key===d?a.pull:null}function Wx(){}const Ux=t=>{const e=$e.c(93),{directory:n,context:r,changeRequest:o,onChanged:i,statusStack:a}=t,{sourceControl:u}=Es(),c=Vs(),d=ts(Vx),[f,p]=qt.useState(0),[m,h]=qt.useState(!1),b=Ai(),g=zx(r,o.number,f);let x;e[0]!==o?(x=Sm(o),e[0]=o,e[1]=x):x=e[1];const w=x;let T;e[2]!==g||e[3]!==w?(T=g?{...w,labels:g.labels,commentCount:g.commentCount}:w,e[2]=g,e[3]=w,e[4]=T):T=e[4];const k=T,[E,F]=qt.useState(null),_=E?.number===o.number?E.sha:null,{detail:A,latest:D,refresh:y}=Pc(n,k,!0,_),N=D.status==="ready"?D.value.pull:null,j=ac(k);let v;e[5]!==i||e[6]!==y?(v=()=>{y(),p(Hx),i()},e[5]=i,e[6]=y,e[7]=v):v=e[7];const M=v,W=lc(k,r,M);let G;e[8]!==r||e[9]!==i||e[10]!==k.number||e[11]!==k.sourceRepo.owner||e[12]!==k.sourceRepo.repo||e[13]!==y||e[14]!==u?(G=async()=>{const q={owner:k.sourceRepo.owner,repo:k.sourceRepo.repo,number:k.number};await u.refreshProviderReads(r,{item:q}).catch(qx),Rc(q),p(Kx),await Promise.all([y(),i()])},e[8]=r,e[9]=i,e[10]=k.number,e[11]=k.sourceRepo.owner,e[12]=k.sourceRepo.repo,e[13]=y,e[14]=u,e[15]=G):G=e[15];const O=G;let Z;e[16]!==k?(Z={source:"repository",reference:k},e[16]=k,e[17]=Z):Z=e[17];const Q=Z,B=c??n;let oe;e[18]!==A||e[19]!==a?(oe=A.status==="ready"&&A.value.pull&&A.value.pull.stack===void 0&&a!==void 0?{status:"ready",value:{...A.value,pull:{...A.value.pull,stack:a}}}:A,e[18]=A,e[19]=a,e[20]=oe):oe=e[20];const H=oe,P=H.status==="ready"?H.value.pull?.stack??null:a??null,te=_i(),J=ts(Gx),le=et(Zx),K=fr(J,le,n),[U,$]=qt.useState(!1);let ee;e[21]===Symbol.for("react.memo_cache_sentinel")?(ee={status:"idle"},e[21]=ee):ee=e[21];const Y=K?()=>$(!0):void 0,ie=N?.submitRequirements,V=D.status==="error",fe=o.mergeable??null;let Se;e[22]!==r||e[23]!==Q||e[24]!==M||e[25]!==P||e[26]!==V||e[27]!==fe||e[28]!==Y||e[29]!==ie?(Se=s.jsx(Ei,{item:Q,project:null,context:r,onStartWorktree:Yx,onChanged:M,worktreeAvailable:!1,stack:P,onStartOnTop:Y,submitRequirements:ie,submitRequirementsUnreadable:V,mergeable:fe}),e[22]=r,e[23]=Q,e[24]=M,e[25]=P,e[26]=V,e[27]=fe,e[28]=Y,e[29]=ie,e[30]=Se):Se=e[30];let Te;e[31]!==o.number||e[32]!==N||e[33]!==_?(Te=N?.revisions?{revisions:N.revisions,selected:_,onSelect:q=>F(q?{number:o.number,sha:q}:null)}:void 0,e[31]=o.number,e[32]=N,e[33]=_,e[34]=Te):Te=e[34];let ue;e[35]!==n||e[36]!==te?(ue=q=>{te(q.url,n)},e[35]=n,e[36]=te,e[37]=ue):ue=e[37];let Me;e[38]===Symbol.for("react.memo_cache_sentinel")?(Me=()=>h(!0),e[38]=Me):Me=e[38];let Ae;e[39]!==j.attachComment||e[40]!==j.attachComments?(Ae={onAttach:j.attachComment,onAttachAll:j.attachComments},e[39]=j.attachComment,e[40]=j.attachComments,e[41]=Ae):Ae=e[41];let De;e[42]!==r||e[43]!==k||e[44]!==M?(De=s.jsx(uc,{reference:k,context:r,onChanged:M}),e[42]=r,e[43]=k,e[44]=M,e[45]=De):De=e[45];let Be;e[46]!==r||e[47]!==A||e[48]!==k||e[49]!==M?(Be=s.jsx(fc,{pull:k,detail:A,context:r,onChanged:M}),e[46]=r,e[47]=A,e[48]=k,e[49]=M,e[50]=Be):Be=e[50];const we=N?.voteLabels;let ve;e[51]!==N?.revisions?(ve=N?.revisions?.at(-1)?.sha,e[51]=N?.revisions,e[52]=ve):ve=e[52];const Pe=_===null;let he;e[53]!==r||e[54]!==k||e[55]!==M||e[56]!==we||e[57]!==ve||e[58]!==Pe?(he=s.jsx(cc,{reference:k,context:r,onRefresh:M,voteLabels:we,latestRevision:ve,onLatestRevision:Pe},k.number),e[53]=r,e[54]=k,e[55]=M,e[56]=we,e[57]=ve,e[58]=Pe,e[59]=he):he=e[59];const Fe=d??"";let _e;e[60]!==B||e[61]!==Fe?(_e={id:Fe,path:B},e[60]=B,e[61]=Fe,e[62]=_e):_e=e[62];let We;e[63]!==r||e[64]!==B||e[65]!==k||e[66]!==_||e[67]!==_e?(We=s.jsx(pc,{pull:k,project:_e,repository:null,context:r,projectOwnsDirectory:Jx,currentDirectory:B,revision:_}),e[63]=r,e[64]=B,e[65]=k,e[66]=_,e[67]=_e,e[68]=We):We=e[68];let Xe;e[69]!==n||e[70]!==Q||e[71]!==b||e[72]!==O||e[73]!==H||e[74]!==Se||e[75]!==Te||e[76]!==ue||e[77]!==Ae||e[78]!==De||e[79]!==Be||e[80]!==he||e[81]!==We||e[82]!==W?(Xe=s.jsx(Oi,{item:Q,directory:n,pullStatus:Mi,trackerDetail:ee,repositoryDetail:H,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:Xx,now:b,footer:Se,revisionChoice:Te,onOpenStackLayer:ue,onOpenChecks:Me,onRefresh:O,commentAttachments:Ae,threadActions:W,labelsControl:De,reviewersControl:Be,reply:he,pullLinks:We}),e[69]=n,e[70]=Q,e[71]=b,e[72]=O,e[73]=H,e[74]=Se,e[75]=Te,e[76]=ue,e[77]=Ae,e[78]=De,e[79]=Be,e[80]=he,e[81]=We,e[82]=W,e[83]=Xe):Xe=e[83];let Ve;e[84]!==j.attachFailedChecks||e[85]!==m||e[86]!==r||e[87]!==k?(Ve=s.jsx(dc,{pull:k,context:r,open:m,onOpenChange:h,onAttachFailed:j.attachFailedChecks}),e[84]=j.attachFailedChecks,e[85]=m,e[86]=r,e[87]=k,e[88]=Ve):Ve=e[88];const S=K?s.jsx(km,{open:U,onOpenChange:$,project:{id:K.id,path:Br(K.path)??K.path},initialSourceBranch:k.head,onWorktreeCreated:Qx}):null;let ne;return e[89]!==Xe||e[90]!==Ve||e[91]!==S?(ne=s.jsxs(s.Fragment,{children:[Xe,Ve,S]}),e[89]=Xe,e[90]=Ve,e[91]=S,e[92]=ne):ne=e[92],ne};function Vx(t){return t.activeProjectId}function Hx(t){return t+1}function qx(){}function Kx(t){return t+1}function Gx(t){return t.projects}function Zx(t){return t.availableWorktreesByProject}function Xx(){}function Yx(){}function Jx(){return!0}function Qx(t){et.getState().openNewSessionDraft({directoryOverride:t,preserveDirectoryOverride:!0})}const ew=/^Change-Id:\s*I[0-9a-f]{40}$/,tw=50,sw=t=>(t.replace(/\r\n/g,`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-C4xsLAUw.js","assets/vendor-react--VO_rL_p.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-6HvTeJY2.js","assets/katex.min-B7gF3rmE.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-C9tWdk0j.js","assets/vendor-zod-Csf1sqWl.js","assets/vendor-opencode-client-CqFY51gT.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/vendor-streamdown-BbSYZ3NF.js","assets/vendor-markdown-BTUqNk6W.js","assets/vendor-mdast-util-from-markdown-CZHjOE75.js","assets/vendor-micromark-util-decode-numeric-character-reference-CNs1qBpV.js","assets/vendor-micromark-util-decode-string-fHsnqYdj.js","assets/vendor-decode-named-character-reference-C3-224fz.js","assets/vendor-micromark-util-normalize-identifier-C9ANKk3v.js","assets/vendor-micromark-AWM-NZXP.js","assets/vendor-micromark-util-combine-extensions-d8XJZrgA.js","assets/vendor-micromark-util-chunked-DrRIdSP-.js","assets/vendor-micromark-factory-space-PzSHLgmq.js","assets/vendor-micromark-util-character-CW3Cu1MS.js","assets/vendor-micromark-core-commonmark-kzTLNXAm.js","assets/vendor-micromark-util-classify-character-tcLuZZwM.js","assets/vendor-micromark-util-resolve-all-PQCKh0dx.js","assets/vendor-micromark-util-subtokenize-BF1Jf29a.js","assets/vendor-micromark-factory-destination-Sj0xfi0V.js","assets/vendor-micromark-factory-label-amyP0HdC.js","assets/vendor-micromark-factory-title-khnLkZK6.js","assets/vendor-micromark-factory-whitespace-eIB00uTl.js","assets/vendor-micromark-util-html-tag-name-DbKNfynz.js","assets/vendor-unist-util-stringify-position-Ch_qCilz.js","assets/vendor-mdast-util-to-string-C_aolqmU.js","assets/vendor-unist-util-visit-DhPeCsfG.js","assets/vendor-unist-util-visit-parents-DlviEg7Z.js","assets/vendor-unist-util-is-BPZGFiMU.js","assets/vendor-hast-util-raw-DvvLJg15.js","assets/vendor-ungap-structured-clone--gfxRhYI.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-parse5-DwmzEj2o.js","assets/vendor-entities-wUUgTZDW.js","assets/vendor-web-namespaces-bsVAaBS1.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-unist-util-position-60F3QETU.js","assets/vendor-hast-util-from-parse5-Ba3T6RJI.js","assets/vendor-devlop-0Dp3JUBc.js","assets/vendor-property-information-Boo8Xpef.js","assets/vendor-hastscript-BrPNioaz.js","assets/vendor-comma-separated-tokens-CRUGqg4f.js","assets/vendor-space-separated-tokens-D7QSIrTI.js","assets/vendor-hast-util-parse-selector-TXfch5wI.js","assets/vendor-vfile-location-LfEFwJ2h.js","assets/vendor-hast-util-to-parse5-BoysVIPW.js","assets/vendor-hast-util-sanitize-2aGO5ay8.js","assets/vendor-micromark-extension-gfm-CsfPlnlB.js","assets/vendor-micromark-extension-gfm-autolink-literal-BYug7onl.js","assets/vendor-micromark-extension-gfm-footnote-OFl1FCH2.js","assets/vendor-micromark-extension-gfm-strikethrough-CyFiuwBf.js","assets/vendor-micromark-extension-gfm-table-dgw4LfUw.js","assets/vendor-micromark-extension-gfm-task-list-item-Dnadzr9U.js","assets/vendor-mdast-util-gfm-CroMDYLM.js","assets/vendor-mdast-util-gfm-autolink-literal-CTruMtvI.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-mdast-util-find-and-replace-DB9iC-bx.js","assets/vendor-escape-string-regexp-BaJN9MlJ.js","assets/vendor-mdast-util-gfm-footnote-C-csI7OF.js","assets/vendor-mdast-util-gfm-strikethrough-BcskTdio.js","assets/vendor-mdast-util-gfm-table-DhPwQIyj.js","assets/vendor-markdown-table-DvhhVmnL.js","assets/vendor-mdast-util-to-markdown-Cl3qaiyc.js","assets/vendor-longest-streak-CtXnX3Xp.js","assets/vendor-mdast-util-phrasing-4oVbNLC3.js","assets/vendor-mdast-util-gfm-task-list-item-DMU5mK_M.js","assets/vendor-mdast-util-to-hast-CWnLaQSO.js","assets/vendor-micromark-util-sanitize-uri-BbwQ7CLk.js","assets/vendor-trim-lines-D8znQY54.js","assets/vendor-micromark-extension-cjk-friendly-BzZDGrF5.js","assets/vendor-micromark-extension-cjk-friendly-util-D5lVNoxW.js","assets/vendor-get-east-asian-width-CPhS2cOv.js","assets/vendor-micromark-util-symbol-JJPacVTp.js","assets/vendor-mdast-util-to-markdown-cjk-friendly-BZ3pe_qd.js","assets/vendor-micromark-extension-cjk-friendly-gfm-strikethrough-CqW-Ep4M.js","assets/vendor-mdast-util-to-markdown-cjk-friendly-gfm-strikethrough-BdPDQFO7.js","assets/vendor-hast-util-from-html-isomorphic-B0Kn01s9.js","assets/vendor-hast-util-from-dom-DeNf9aYW.js","assets/vendor-katex-DBqql0K7.js","assets/vendor-hast-util-to-text-0GXLnBvt.js","assets/vendor-hast-util-is-element-CuOmiqQi.js","assets/vendor-unist-util-find-after-CMaZmLxc.js","assets/vendor-micromark-extension-math-BRFoDziv.js","assets/vendor-mdast-util-math-wB-IJCL0.js","assets/vendor-remend-r8cP_t-e.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-marked-DN3zOnEe.js","assets/vendor-hast-util-to-jsx-runtime-Bq6JeJCx.js","assets/vendor-style-to-js-CI2G4dgu.js","assets/vendor-style-to-object-BAv4SQXc.js","assets/vendor-inline-style-parser-BlqBsVO4.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-estree-util-is-identifier-name-BgBfM8ME.js","assets/vendor-vfile-message-DqhD22jI.js","assets/vendor-unified-1CQKw2_w.js","assets/vendor-bail-FqpXQuLt.js","assets/vendor-extend-B94qxKr5.js","assets/vendor-is-plain-obj-C1gvLhAf.js","assets/vendor-trough-B_b8ryxu.js","assets/vendor-vfile-BCWrK60u.js","assets/vendor-html-url-attributes-D46m5wfe.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/katex-Dejpsg4Y.css","assets/vendor-base-ui-zhBy6TEG.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-Cy8dRGoy.js","assets/vendor-use-sync-external-store-CfLJGVyr.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-dnd-kit-core-Br1Cs7RV.js","assets/vendor-dnd-kit-utilities-DZ9KbT5S.js","assets/vendor-dnd-kit-accessibility-CYclfhtC.js","assets/vendor-dnd-kit-sortable-DpfLEOLv.js","assets/vendor-tanstack-react-virtual-CqfECoM0.js","assets/vendor-tanstack-virtual-core-BdFnkr_2.js","assets/vendor-framer-motion-C_wK4GIM.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-CjjsURR-.js","assets/vendor-codemirror-state-Cd8udR5z.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-Ciie9ey-.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-8HZTPOnt.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CZEcqU6G.js","assets/vendor-codemirror-streamparser-CmlTsbN2.js","assets/vendor-codemirror-lang-javascript-DmqaSK_j.js","assets/vendor-lezer-javascript-CWSwshuO.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BGedy2gC.js","assets/vendor-codemirror-lang-json-DVAYKmoO.js","assets/vendor-lezer-json-Cn1mncjr.js","assets/vendor-codemirror-lang-css-BLpgXfL2.js","assets/vendor-lezer-css-B2Hx_Nps.js","assets/vendor-codemirror-lang-html-S3jxr3Mo.js","assets/vendor-lezer-html-Cr8K5DGw.js","assets/vendor-codemirror-lang-markdown-D1jveRI5.js","assets/vendor-lezer-markdown-TQKzBB8i.js","assets/vendor-codemirror-language-data-BJfFTbvV.js","assets/vendor-codemirror-lang-python-B-5UC9Ui.js","assets/vendor-lezer-python-BUoImtUb.js","assets/vendor-sonner-Dw26OnzC.js","assets/vendor-cmdk-BtSpU-Io.js","assets/vendor-radix-ui-react-dialog-OIW6VLWw.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-D4RvEbuR.js","assets/vendor-radix-ui-react-context-BbFoxCHu.js","assets/vendor-radix-ui-react-id-aGag8i_5.js","assets/vendor-radix-ui-react-use-layout-effect-B1oLzD-j.js","assets/vendor-radix-ui-react-use-controllable-state-BjnNPGHq.js","assets/vendor-radix-ui-react-dismissable-layer-DpT6mMbO.js","assets/vendor-radix-ui-react-primitive-CrN9dRDb.js","assets/vendor-radix-ui-react-slot-BjbalUfz.js","assets/vendor-radix-ui-react-use-callback-ref-CcC_buIU.js","assets/vendor-radix-ui-react-use-escape-keydown-Cp1WWKTC.js","assets/vendor-radix-ui-react-focus-scope-D1noLHmd.js","assets/vendor-radix-ui-react-portal-BlUEzfrF.js","assets/vendor-radix-ui-react-presence-BGqFfiW4.js","assets/vendor-radix-ui-react-focus-guards-CSS2IbZC.js","assets/vendor-react-remove-scroll-Der_cv-1.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-Clwl9llp.js","assets/vendor-react-style-singleton-D_xJlTqU.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-BdLl6ZIw.js","assets/vendor-use-callback-ref-CXJF1lEr.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-legendapp-list-wfKYGEOv.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeEndpointReset-DUwSilpj.js","assets/space-apply-De-hlG-f.js","assets/runtimeEndpointReset-uDNKGwhp.css","assets/useGitCleanLine-DEZFq7uh.js","assets/useBranchPullRequestRequest-B8yYsqiw.js","assets/parseDiffFromFile-BuLpViZg.js","assets/computeVirtualFileMetrics-vVCRMHlo.js","assets/themeResolver-DXizngAV.js","assets/vendor-pierre-theming-D_TRfu0q.js","assets/hastToHtml-BHV14OWE.js","assets/vendor-hast-util-to-html-Jw3IXh58.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-diff-C3JhlQdm.js","assets/isDiffPlainText-OMACajs1.js","assets/getFiletypeFromFileName-BgI9McTw.js","assets/pierreDiffTint-Bda-Leur.js","assets/ReviewCards-B219SHVL.js","assets/useInlineCommentController-BiX7K5jy.js","assets/appThemeRegistry-hfPZ6say.js","assets/textMateThemeFromAppTheme-B38k_gpV.js","assets/diffsHighlighter-BsxkaI3Q.js","assets/ChangedPathLabel-B6Ig547I.js","assets/useRootScrollLock-BrNPOsn7.js","assets/contextFileOpenGuard-BrUXbAMg.js","assets/WalkthroughView-DeaBPhAn.js","assets/ChangeRequestDiffUnavailable-3YgjMJtr.js","assets/useDiffFindSurface-BVO1E6le.js","assets/useWalkthroughReview-kBvgTX6M.js","assets/useCallableModelProviders-BLdr2CgV.js","assets/useWholeFileComment-DrynMs0_.js","assets/DiffView-pFcLbagS.js","assets/SubmoduleDiffSummary-Cdi9S4gX.js","assets/FilesView-Bod-r3C6.js","assets/flexokiTheme-DJhpTHWO.js","assets/vendor-codemirror-search-Bk6iB2TM.js","assets/vendor-replit-codemirror-vim-BpSlt2iY.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useMarkdownLocalAssets-DM7b941V.js","assets/fileContentPoller-B_D2WQHm.js","assets/JsonTreeView-C7EScp5B.js","assets/useNextRenderData-CVFf78p9.js","assets/isFilePlainText-Z9Wi1AQY.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/codeHighlight-CXtTq4co.js","assets/vendor-react-drawio-C6TkEvnS.js","assets/vendor-codemirror-lint-aq8IpR1c.js","assets/scheduledTasksApi-jkEn2fUL.js","assets/GuestSurfacePane-BTyjXjRj.js","assets/SettingsWindow-HEw9_GIT.js","assets/SettingsView-CenZZQat.js","assets/install-csQoiut9.js","assets/vendor-yaml-CE-D_49-.js","assets/vendor-qrcode-Cl8OheHW.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/pageTitle-CAd4Kwsy.js","assets/SpaceRow-CckOV1g8.js","assets/AboutLogo-DiHHd_5t.js","assets/CommandPalette-BChv7Yci.js","assets/HelpDialog-jRlVnJ_e.js","assets/ProjectActionsDialog-B96GmKCc.js","assets/OpenCodeStatusDialog-BAv0K4eb.js","assets/RunOverview-6n10wBYl.js","assets/ScheduledTasksDialog-CTkrlYii.js","assets/vendor-cron-parser-1X50-i0r.js","assets/vendor-luxon-BZ0puJYg.js","assets/date-time-t6mCSZMr.js","assets/ArchiveView-CwhPe3Y_.js","assets/useWorktreeArchiveActions-CewTlnGF.js","assets/IntegrationsCatalogView-CjJ3sWIM.js","assets/UsageStatsView-DCpTVWz3.js","assets/SourceBoardView-CJZ3s1XD.js","assets/OverviewView-DyDBexdg.js","assets/WorktreesView-B1YD_EPW.js","assets/SpacesView-CP5k-k3v.js","assets/SpaceAccessDialog-Ngob2qn9.js","assets/spaceNetwork-CVVlgvhL.js","assets/SpaceApplyDialog-BxjDC_0D.js","assets/SpaceSetupOutput-lGqiVX-3.js","assets/OnboardingScreen-CMeQdpeM.js","assets/AboutDialog-BLUUIZML.js","assets/MemoryDebugPanel-D0N9KDmI.js"])))=>i.map(i=>d[i]);
2
+ import{f as $e,j as s,R as l,r as qt,a as Hl,h as Tu}from"./vendor-react--VO_rL_p.js";import{bk as Yr,n as Xt,k as ls,ct as Nu,cu as ql,u as X,bi as Bs,aI as ns,aT as Jr,c3 as cs,cv as vi,aO as Qr,cw as Eu,bV as Kl,cx as wt,cy as Iu,bf as qo,l as Si,bg as Zs,bh as Cr,bH as Pu,bl as Gl,cz as ki,bd as ji,cA as Ru,co as Zl,bQ as ra,aR as Xl,cB as Du,cC as ur,cD as Mr,cE as er,cF as Au,cG as Kn,cH as _u,cI as Ko,cJ as xr,cK as Ci,cL as eo,cM as Pn,a_ as Fr,j as zs,cN as Cn,cO as Ou,cP as ks,b as dn,cQ as to,cR as Mu,cS as Gs,cT as Fu,cU as Yl,cV as Lu,cW as $u,cX as Jl,cY as Bu,c6 as zu,bU as Wu,b_ as Uu,bX as Vu,be as Hu,bp as gs,t as Go,bY as qu,cZ as Ku,c_ as Gu,bu as Zo,c$ as Ti,d0 as Zu,bb as Xu,b0 as oa,cn as Ql,d1 as ia,aK as ec,d2 as Yu,v as tc,bZ as Ju,d3 as aa,bA as Ni,d4 as sc,bJ as Qu,aJ as ef,q as tf,m as sf,bj as nc,cb as la,cc as rc,cr as nf,c4 as rf,c8 as ca,d5 as of,d6 as af,bF as lf,bD as cf,d7 as df,bK as uf,ca as ff,d8 as pf,d9 as mf,da as hf,db as da,dc as Co,dd as ua,de as fa,df as gf,bn as pa,dg as bf,dh as xf,bo as ma,di as wf,bE as yf,i as vf,a as Sf}from"./katex.min-B7gF3rmE.js";import{_ as Ot}from"./vendor-vite-runtime-DD1OZmLC.js";import{bt as kf,bu as oc,aC as ic,bv as as,r as ha,bw as jf,aE as Cf,bx as ga,aF as ba,U as ac,W as lc,Y as cc,V as dc,Q as Ei,$ as uc,Z as fc,X as pc,as as Tf,at as Nf,ax as Ef,ay as If,al as Pf,av as Rf,au as Df,N as Af,P as _f,a1 as Of,a0 as Mf,b7 as Ff,by as mc,bz as Tr,bA as hc,bB as Lf,bC as gc,bD as xn,bE as xa,bF as wa,bG as To,bH as ya,aw as Nr,b4 as $f,b5 as Bf,aA as zf,bp as Wf,bq as bc,bI as Uf,b6 as Vf,bJ as Hf,bK as qf,bL as va,bM as No,bN as sn,bO as wn,bP as Kf,bQ as Sa,bR as Gf,bS as Zf,bT as Xf,bU as Yf,bV as Jf,bW as Qf,bX as ep,bY as ka,bZ as tp,b_ as sp,b8 as np,b2 as rp,bo as op,b9 as ip,br as ap,b$ as lp,bk as cp,bl as dp,aD as xc,c0 as up,c1 as fp,c2 as pp,c3 as mp,c4 as hp,bn as gp,c5 as bp,bg as xp,c6 as wp,c7 as yp,bd as vp,bb as Sp,bc as kp,ba as jp,be as Cp,bs as Tp,bj as Np,bi as Ep,bm as Ip,c8 as Pp,c9 as Rp}from"./runtimeEndpointReset-DUwSilpj.js";import{fM as ja,aM as so,Y as ts,$ as et,cf as fr,Q as Le,ft as Dp,cg as Ap,I as se,fu as _p,u as at,kn as nn,X as ps,ko as Op,av as xs,ay as Ts,aw as Ii,kp as wc,b7 as Ys,fL as yc,fK as Mp,bp as Fp,kq as vc,kr as Lp,ks as $p,bd as pr,ab as Ft,aa as Lt,ac as $t,j3 as Ws,cj as Sc,kt as Bp,ku as zp,b4 as Wp,A as Re,co as kc,jy as Up,kv as jc,bv as Vp,kw as Hp,kx as qp,jj as Cc,ky as Kp,aK as Vs,eJ as Gp,au as Zp,bg as Cs,b2 as no,be as ro,j5 as Tn,bf as oo,kz as Xp,kA as io,kB as Yp,kC as Jp,aL as gn,kD as Qp,eN as Tc,kE as em,hm as mr,hn as ao,ca as Lr,eO as tm,kF as sm,kG as nm,kH as rm,kI as om,kJ as im,kK as am,kL as lm,kM as Pi,kN as cm,kO as dm,kP as um,jB as fm,kQ as pm,bN as Ri,eS as mm,kR as hm,t as tr,q as sr,D as nr,l as rr,F as or,o as $r,B as dt,kS as Rn,a2 as pn,a3 as mn,a4 as hn,a5 as Gt,ad as un,kT as Nc,kU as Di,n as hs,a_ as Qt,kV as Ec,kW as gm,cu as Ic,kX as bm,kY as xm,bE as Es,kZ as wm,bS as fn,k_ as Ca,bK as Er,k$ as ym,fy as vm,b$ as Ai,l0 as Sm,l1 as Pc,l2 as _i,dI as km,di as Br,dO as Rc,dC as Oi,dD as Mi,l3 as Dc,y as Dn,C as Xo,gP as jm,hk as Cm,g_ as Tm,hE as Nm,l4 as Em,gx as Ac,bG as $s,K as Fi,bB as Im,aq as ys,bF as _c,bU as Ta,bT as Vn,gy as Pm,bV as Rm,c6 as Li,c1 as Dm,gA as Eo,l5 as Am,z as _m,bq as Om,br as Mm,bs as Fm,bt as Lm,bu as $m,cS as Na,bL as Oc,bI as zr,l6 as Bm,l7 as zm,l8 as Wm,dz as On,bz as Um,bC as lo,bD as Vm,bH as Hm,aJ as An,ht as qm,bJ as Km,gC as Gm,c0 as co,l9 as Mc,la as Fc,lb as Zm,dv as Xm,dr as Ym,du as Jm,lc as Qm,dE as eh,ds as Ea,ld as th,hN as sh,le as nh,lf as rh,dt as Ia,dN as oh,dx as ih,a$ as ah,lg as lh,lh as ch,li as dh,lj as $i,lk as Bi,ll as uh,lm as fh,ln as ph,lo as mh,lp as hh,k6 as zi,lq as gh,lr as bh,ls as xh,lt as wh,lu as Wi,lv as yh,bA as vh,lw as Sh,lx as kh,aY as Lc,ly as $c,bo as jh,lz as Ch,x as Bc,lA as Th,lB as kn,aI as Nh,ao as Eh,lC as Ih,V as zt,lD as Ph,d3 as Rh,cG as Dh,lE as zc,lF as Ah,lG as Ir,lH as yn,iU as _h,lI as cn,cV as Oh,lJ as Mh,lK as Wc,jI as Uc,eE as uo,dH as Fh,d9 as Lh,lL as Ui,lM as $h,f9 as Js,lN as Vc,bh as Bh,lO as zh,lP as Wh,lQ as Uh,lR as Io,lS as Vh,lT as Hh,em as qh,eF as Kh,gj as Vi,gg as Gh,j4 as Zh,j6 as Xh,lU as ir,gf as Hc,ge as qc,j7 as Yh,j8 as Jh,gh as Qh,eq as eg,aZ as tg,aN as sg,lV as Po,lW as ng,lX as rg,lY as Kc,lZ as Gc,l_ as og,l$ as ig,m0 as Yo,m1 as Ks,dm as ag,m2 as lg,m3 as Pa,m4 as cg,m5 as dg,bc as Wr,m6 as Ra,m7 as ug,m8 as fg,m9 as pg,jn as mg,ma as hg,jo as Da,jp as gg,c_ as bg,cl as Aa,jq as xg,jr as wg,mb as yg,js as vg,mc as Sg,bn as kg,k as jg,jM as Cg,md as Ro,me as _a,fi as Tg,fR as Jo,mf as Zc,ir as fo,mg as Ng,iN as Eg,mh as Ig,mi as Xc,mj as Pg,mk as Yc,ep as Rg,eo as Hi,en as qi,et as Dg,ml as Oa,mm as Ag,mn as _g,er as Og,G as Qo,mo as Jc,bX as Qc,bY as ed,mp as ei,bZ as td,jg as sd,mq as Do,mr as Mg,fQ as Fg,jL as Lg,a0 as $g,ms as Bg,mt as zg,mu as nd,b8 as Ma,eb as Wg,eu as Ug,jd as Vg,mv as Hg,je as qg,mw as Kg,mx as Gg,km as Zg,d4 as Fa,my as Xg,ji as Yg,mz as Jg,k7 as Qg,eX as eb,mA as tb,fb as La,eC as sb,eY as nb,e_ as rb,eZ as ob,f6 as ib,f5 as ab,e$ as lb,k8 as cb,f4 as db,f0 as ub,f1 as fb,f2 as pb,f3 as mb,a as hb,s as gb,b as bb,c as xb,kf as wb,ah as yb,fe as vb,ff as Sb,fg as kb}from"./useAppFontEffects-6HvTeJY2.js";import{f as rd,u as od,S as jb,W as id,a as Cb,G as Tb,b as Nb,c as Eb}from"./useRootScrollLock-BrNPOsn7.js";import{h as ad,i as Ur,T as ld,M as cd,D as dd,f as ti}from"./vendor-dnd-kit-core-Br1Cs7RV.js";import{r as Ib,h as Pb,u as ud,S as fd,v as Rb,a as Db}from"./vendor-dnd-kit-sortable-DpfLEOLv.js";import{C as pd}from"./vendor-dnd-kit-utilities-DZ9KbT5S.js";import{S as Ab,M as _b,C as Ob,i as Mb,j as Fb,k as Lb}from"./vendor-base-ui-zhBy6TEG.js";import{a as rn,O as $b,d as Bb,D as zb,b as Wb,v as $a,t as Ba,u as Ub,m as za}from"./contextFileOpenGuard-BrUXbAMg.js";import{u as si,c as po,p as Vb}from"./vendor-zustand-C9tWdk0j.js";import{o as Qs,s as Ns,n as mo,d as md,f as Hb,e as ar,a as ni}from"./vendor-zod-Csf1sqWl.js";import{u as qb}from"./vendor-tanstack-react-virtual-CqfECoM0.js";import{d as Kb,m as Gb}from"./vendor-tanstack-virtual-core-BdFnkr_2.js";const hd=t=>`${t}|chats`,Zb=(t,e)=>{if(Yr(e))return hd(t);const n=Xt(e);return n?`${t}|${n}`:null},Xb=(t,e,n)=>{const r=Xt(t);return!r||Yr(r)?[]:n.some(o=>Xt(o)===r)?[]:e.filter(o=>!o.parentID&&!o.time?.archived&&Xt(o.directory??null)===r).sort((o,i)=>ja(i)-ja(o)).map(o=>o.id)};function Yb(t){const e=$e.c(37),{directory:n,className:r}=t,{currentTheme:o}=so(),i=ts(e1),a=et(Qb),u=ls(Jb),c=Nu(n);let d;e[0]!==n||e[1]!==u?(d=ql(n,u),e[0]=n,e[1]=u,e[2]=d):d=e[2];const f=d;let p;e[3]!==n||e[4]!==f||e[5]!==i||e[6]!==c||e[7]!==a?(p=f||!n?null:fr(i,a,n,c),e[3]=n,e[4]=f,e[5]=i,e[6]=c,e[7]=a,e[8]=p):p=e[8];const m=p;if(f){let D;e[9]!==r?(D=Le("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),e[9]=r,e[10]=D):D=e[10];let y;return e[11]!==D?(y=s.jsx(se,{name:"chat-4",className:D}),e[11]=D,e[12]=y):y=e[12],y}if(!m)return null;const h=m.icon?Dp[m.icon]:null;let b;e[13]!==m.color?(b=Ap(m.color)??void 0,e[13]=m.color,e[14]=b):b=e[14];const g=b;let x;e[15]!==r||e[16]!==g||e[17]!==h?(x=h?s.jsx(se,{name:h,className:Le("h-3.5 w-3.5 shrink-0",r),style:g?{color:g}:void 0}):s.jsx(se,{name:"folder",className:Le("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),style:g?{color:g}:void 0}),e[15]=r,e[16]=g,e[17]=h,e[18]=x):x=e[18];const w=x;if(!m.iconImage)return w;let T;e[19]!==r?(T=Le("inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",r),e[19]=r,e[20]=T):T=e[20];let k;e[21]!==m.iconBackground?(k=m.iconBackground?{backgroundColor:m.iconBackground}:void 0,e[21]=m.iconBackground,e[22]=k):k=e[22];let E;e[23]!==m.iconImage||e[24]!==m.id?(E={id:m.id,iconImage:m.iconImage},e[23]=m.iconImage,e[24]=m.id,e[25]=E):E=e[25];let F;e[26]!==o.colors.surface.foreground||e[27]!==o.metadata.variant?(F={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[26]=o.colors.surface.foreground,e[27]=o.metadata.variant,e[28]=F):F=e[28];let _;e[29]!==w||e[30]!==E||e[31]!==F?(_=s.jsx(_p,{project:E,options:F,className:"h-full w-full object-contain",fallback:w}),e[29]=w,e[30]=E,e[31]=F,e[32]=_):_=e[32];let A;return e[33]!==T||e[34]!==k||e[35]!==_?(A=s.jsx("span",{className:T,style:k,children:_}),e[33]=T,e[34]=k,e[35]=_,e[36]=A):A=e[36],A}function Jb(t){return t.homeDirectory}function Qb(t){return t.availableWorktreesByProject}function e1(t){return t.projects}const Hn=24,t1=(t,e,n=Hn)=>{const r=e.right-(t.right-n);if(r>0)return r;const o=e.left-(t.left+n);return o<0?o:0},s1=({transform:t})=>({...t,y:0}),n1=16,r1=t=>{if(t.shiftKey||t.ctrlKey||t.metaKey||Math.abs(t.deltaY)<=Math.abs(t.deltaX))return;const e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?t.deltaY*n1:t.deltaY;t.currentTarget.scrollLeft+=Jr(t.currentTarget)?-e:e},o1={Item:({className:t,...e})=>s.jsx(_b,{className:Le($p,t),...e}),Separator:({className:t,...e})=>s.jsx(Ab,{className:Le(Lp,t),...e})},i1=t=>{const e=$e.c(127),{tab:n,tabNumber:r,isActive:o,isPreview:i,suppressControls:a,onSelect:u,onPin:c,onClose:d,renderMenu:f,closeOtherTabs:p,onMenuOpenChangeComplete:m,children:h}=t,{t:b}=at(),g=X(l1);let x;e[0]!==g?(x=Ii("switch_session_tab",g),e[0]=g,e[1]=x):x=e[1];const w=x;let T;e[2]!==r||e[3]!==w?(T=w&&w!==wc&&r<=9?xs(`${w}+${r}`):void 0,e[2]=r,e[3]=w,e[4]=T):T=e[4];const k=T,[E,F]=l.useState(!1);let _;e[5]!==n.id?(_={id:n.id},e[5]=n.id,e[6]=_):_=e[6];const{attributes:A,listeners:D,setNodeRef:y,transform:N,transition:j,isDragging:v}=ud(_);let M;e[7]!==b||e[8]!==n.session.title?(M=n.session.title?.trim()||b("sessions.sidebar.session.untitled"),e[7]=b,e[8]=n.session.title,e[9]=M):M=e[9];const W=M,G=n.id;let O;e[10]!==n.session?(O=Ys(n.session),e[10]=n.session,e[11]=O):O=e[11];const Z=oc(G,O),Q=yc(n.id),B=Q!==null,H=Mp(n.id)&&!o&&!B,P=B||H;let te;e[12]!==u||e[13]!==n?(te=()=>u(n),e[12]=u,e[13]=n,e[14]=te):te=e[14];let J;e[15]!==p||e[16]!==n.id?(J=()=>p(n.id),e[15]=p,e[16]=n.id,e[17]=J):J=e[17];let le,K,U,$,ee,Y,ie,V,fe,Se,Te,ue,Me,Ae,De,Be,we,ve,Pe,he;if(e[18]!==A||e[19]!==h||e[20]!==E||e[21]!==o||e[22]!==Z||e[23]!==v||e[24]!==i||e[25]!==D||e[26]!==d||e[27]!==m||e[28]!==c||e[29]!==u||e[30]!==f||e[31]!==y||e[32]!==g||e[33]!==P||e[34]!==a||e[35]!==b||e[36]!==te||e[37]!==J||e[38]!==n||e[39]!==k||e[40]!==W||e[41]!==N||e[42]!==j||e[43]!==Q){const S={session:n.session,open:E,isActive:o,select:te,closeOtherTabs:J,components:o1};Me=y;let ne;e[64]!==N?(ne=pd.Translate.toString(N),e[64]=N,e[65]=ne):ne=e[65],e[66]!==ne||e[67]!==j?(Ae={transform:ne,transition:j},e[66]=ne,e[67]=j,e[68]=Ae):Ae=e[68];const q=v&&"z-10 opacity-60";e[69]!==q?(De=Le("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",q),e[69]=q,e[70]=De):De=e[70],Be=o?"true":"false",e[71]!==o?(we=o?{"data-active-session-tab":!0}:{},e[71]=o,e[72]=we):we=e[72],ve=A,Pe=D,$=pr,fe=E,Se=F,e[73]!==m?(Te=Ie=>m?.(Ie),e[73]=m,e[74]=Te):Te=e[74];let ke;e[75]!==h||e[76]!==o||e[77]!==Z||e[78]!==i||e[79]!==d||e[80]!==c||e[81]!==u||e[82]!==g||e[83]!==P||e[84]!==a||e[85]!==b||e[86]!==n||e[87]!==W||e[88]!==Q?(ke=s.jsx(Ft,{asChild:!0,children:s.jsx(Ob,{render:Ie=>s.jsx("div",{...Ie,role:"tab","aria-selected":o,tabIndex:o?void 0:0,onClick:o?void 0:()=>u(n),onDoubleClick:i?()=>c(n.id):void 0,onKeyDown:o?void 0:Ne=>{(Ne.key==="Enter"||Ne.key===" ")&&(Ne.preventDefault(),u(n))},onAuxClick:Ne=>{Ne.button===1&&(Ne.preventDefault(),d(n.id))},className:Le("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",o?"bg-interactive-selection text-interactive-selection-foreground":"cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[s.jsxs("span",{className:"relative me-1.5 inline-flex size-3.5 shrink-0 items-center justify-center",children:[s.jsx(Yb,{directory:Ys(n.session),className:Le(!a&&"group-hover/session-tab:opacity-0 group-has-[:focus-visible]/session-tab:opacity-0")}),a?null:s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":b("header.sessionTabs.closeTab"),onClick:Ne=>{Ne.stopPropagation(),d(n.id)},onPointerDown:c1,className:"absolute inset-0 flex items-center justify-center rounded text-muted-foreground opacity-0 hover:text-foreground focus-visible:opacity-100 group-hover/session-tab:opacity-100",children:s.jsx(se,{name:"close",className:"size-3.5"})})}),s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Ws,{label:b("header.sessionTabs.closeTab"),shortcut:o?xs(Bs()?"mod+w":Ts("close_session_tab",g),""):void 0})})]})]}),s.jsx("div",{className:Le("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!a&&"session-tab-title",i&&!a&&"italic"),children:o?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4",children:W})})}),Z?s.jsx(se,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":b("sessions.aiRename.generating")}):P?s.jsx(Sc,{state:Q??"unread",className:"ms-1.5 shrink-0"}):null]})})})}),e[75]=h,e[76]=o,e[77]=Z,e[78]=i,e[79]=d,e[80]=c,e[81]=u,e[82]=g,e[83]=P,e[84]=a,e[85]=b,e[86]=n,e[87]=W,e[88]=Q,e[89]=ke):ke=e[89];let Ee;e[90]!==k||e[91]!==W?(Ee=s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Ws,{label:W,shortcut:k})}),e[90]=k,e[91]=W,e[92]=Ee):Ee=e[92],e[93]!==ke||e[94]!==Ee?(ue=s.jsxs(Lt,{children:[ke,Ee]}),e[93]=ke,e[94]=Ee,e[95]=ue):ue=e[95],U=Mb,K=Fb,V="app-region-no-drag z-50",le=Lb,he="dropdown-menu-content",e[96]===Symbol.for("react.memo_cache_sentinel")?(ee={color:"var(--surface-elevated-foreground)"},Y=Le(Fp,"min-w-[190px]"),e[96]=ee,e[97]=Y):(ee=e[96],Y=e[97]),ie=f(S),e[18]=A,e[19]=h,e[20]=E,e[21]=o,e[22]=Z,e[23]=v,e[24]=i,e[25]=D,e[26]=d,e[27]=m,e[28]=c,e[29]=u,e[30]=f,e[31]=y,e[32]=g,e[33]=P,e[34]=a,e[35]=b,e[36]=te,e[37]=J,e[38]=n,e[39]=k,e[40]=W,e[41]=N,e[42]=j,e[43]=Q,e[44]=le,e[45]=K,e[46]=U,e[47]=$,e[48]=ee,e[49]=Y,e[50]=ie,e[51]=V,e[52]=fe,e[53]=Se,e[54]=Te,e[55]=ue,e[56]=Me,e[57]=Ae,e[58]=De,e[59]=Be,e[60]=we,e[61]=ve,e[62]=Pe,e[63]=he}else le=e[44],K=e[45],U=e[46],$=e[47],ee=e[48],Y=e[49],ie=e[50],V=e[51],fe=e[52],Se=e[53],Te=e[54],ue=e[55],Me=e[56],Ae=e[57],De=e[58],Be=e[59],we=e[60],ve=e[61],Pe=e[62],he=e[63];let Fe;e[98]!==le||e[99]!==ee||e[100]!==Y||e[101]!==ie||e[102]!==he?(Fe=s.jsx(le,{"data-slot":he,style:ee,className:Y,children:ie}),e[98]=le,e[99]=ee,e[100]=Y,e[101]=ie,e[102]=he,e[103]=Fe):Fe=e[103];let _e;e[104]!==K||e[105]!==V||e[106]!==Fe?(_e=s.jsx(K,{className:V,children:Fe}),e[104]=K,e[105]=V,e[106]=Fe,e[107]=_e):_e=e[107];let We;e[108]!==U||e[109]!==_e?(We=s.jsx(U,{children:_e}),e[108]=U,e[109]=_e,e[110]=We):We=e[110];let Xe;e[111]!==$||e[112]!==fe||e[113]!==Se||e[114]!==Te||e[115]!==ue||e[116]!==We?(Xe=s.jsxs($,{open:fe,onOpenChange:Se,onOpenChangeComplete:Te,children:[ue,We]}),e[111]=$,e[112]=fe,e[113]=Se,e[114]=Te,e[115]=ue,e[116]=We,e[117]=Xe):Xe=e[117];let Ve;return e[118]!==Me||e[119]!==Ae||e[120]!==De||e[121]!==Be||e[122]!==we||e[123]!==ve||e[124]!==Pe||e[125]!==Xe?(Ve=s.jsx("div",{ref:Me,style:Ae,className:De,"data-active":Be,...we,...ve,...Pe,children:Xe}),e[118]=Me,e[119]=Ae,e[120]=De,e[121]=Be,e[122]=we,e[123]=ve,e[124]=Pe,e[125]=Xe,e[126]=Ve):Ve=e[126],Ve},a1=t=>{const e=$e.c(109),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,children:i}=t,a=o===void 0?!1:o,{t:u,direction:c}=at(),d=c==="rtl",f=nn(d1),p=nn(u1),m=nn(f1),h=nn(p1),b=nn(m1),g=nn(h1),x=et(g1),w=et(b1),T=ps(x1),k=X(w1),E=nn(y1),F=ps(v1),_=et(S1),A=et(k1),D=et(j1),y=et(C1),N=et(T1),j=et(N1);let v;e[0]!==j?(v=L=>{const ge=j??L.activeProjectId;return L.projects.find(Ce=>Ce.id===ge)?.path??null},e[0]=j,e[1]=v):v=e[1];const M=ts(v),W=kf(x);let G,O;e[2]!==W||e[3]!==_||e[4]!==x||e[5]!==N||e[6]!==y||e[7]!==A||e[8]!==M||e[9]!==m||e[10]!==E||e[11]!==k||e[12]!==F?(G=()=>{if(!k)E(Bp,E1);else{if(!F)return;const L=ns(),ge=!x&&A&&y,Ce=x?_:A&&!y?N??M:null,Je=ge?hd(L):Zb(L,Ce);if(!Je)return;E(Je,()=>Xb(Ce,ps.getState().activeSessions,ts.getState().projects.map(I1)))}x&&m(x,W)},O=[W,_,x,N,y,A,M,m,E,k,F],e[2]=W,e[3]=_,e[4]=x,e[5]=N,e[6]=y,e[7]=A,e[8]=M,e[9]=m,e[10]=E,e[11]=k,e[12]=F,e[13]=G,e[14]=O):(G=e[13],O=e[14]),l.useEffect(G,O);let Z;if(e[15]!==T){Z=new Map;for(const L of T)Z.set(L.id,L);e[15]=T,e[16]=Z}else Z=e[16];const Q=Z;let B;if(e[17]!==Q||e[18]!==f){B=[];for(const L of f){const ge=Q.get(L);ge&&B.push({id:L,session:ge})}e[17]=Q,e[18]=f,e[19]=B}else B=e[19];const oe=B;let H;e[20]!==w?(H=L=>{w(L.id,Ys(L.session))},e[20]=w,e[21]=H):H=e[21];const P=H,te=P1,J=!x&&A;let le;e[22]!==J||e[23]!==D?(le=L=>!J||!D?"":(L.drafts.find(Ce=>Ce.id===D)?.text??"").split(/\r?\n/).find(R1)?.trim()??"",e[22]=J,e[23]=D,e[24]=le):le=e[24];const K=Op(le),U=X(D1),$=A1;let ee;e[25]!==x||e[26]!==J||e[27]!==oe?(ee=oe.some(L=>L.id===x)||J&&oe.length>0,e[25]=x,e[26]=J,e[27]=oe,e[28]=ee):ee=e[28];const Y=ee;let ie,V;e[29]!==Y?(ie=()=>{if(Y)return ic(_1,{current:document.body})},V=[Y],e[29]=Y,e[30]=ie,e[31]=V):(ie=e[30],V=e[31]),l.useEffect(ie,V);let fe;e[32]!==b||e[33]!==x||e[34]!==P||e[35]!==oe?(fe=L=>{if(b(L),x&&x!==L){const ge=oe.find(Ce=>Ce.id===L);ge&&P(ge)}},e[32]=b,e[33]=x,e[34]=P,e[35]=oe,e[36]=fe):fe=e[36];const Se=fe;let Te;e[37]===Symbol.for("react.memo_cache_sentinel")?(Te={activationConstraint:{distance:8}},e[37]=Te):Te=e[37];let ue;e[38]===Symbol.for("react.memo_cache_sentinel")?(ue={activationConstraint:{delay:200,tolerance:6}},e[38]=ue):ue=e[38];const Me=ad(Ur(cd,Te),Ur(ld,ue));let Ae;e[39]!==g?(Ae=L=>{const{active:ge,over:Ce}=L;Ce&&ge.id!==Ce.id&&g(String(ge.id),String(Ce.id))},e[39]=g,e[40]=Ae):Ae=e[40];const De=Ae,Be=l.useRef(null);let we;e[41]===Symbol.for("react.memo_cache_sentinel")?(we={left:!1,right:!1},e[41]=we):we=e[41];const[ve,Pe]=l.useState(we);let he;e[42]===Symbol.for("react.memo_cache_sentinel")?(he=()=>{const L=Be.current;if(!L)return;const ge=L.scrollWidth-L.clientWidth,Ce=Jr(L)?ge+L.scrollLeft:L.scrollLeft,Je=Ce>2,Oe=Ce<ge-2;Pe(me=>me.left===Je&&me.right===Oe?me:{left:Je,right:Oe})},e[42]=he):he=e[42];const Fe=he;let _e;e[43]===Symbol.for("react.memo_cache_sentinel")?(_e=()=>{Fe();const L=Be.current;if(!L||!globalThis.ResizeObserver)return;const ge=new ResizeObserver(Fe);return ge.observe(L),()=>ge.disconnect()},e[43]=_e):_e=e[43];let We;e[44]!==oe.length?(We=[Fe,oe.length],e[44]=oe.length,e[45]=We):We=e[45],l.useEffect(_e,We);let Xe;e[46]===Symbol.for("react.memo_cache_sentinel")?(Xe=()=>{const L=Be.current,ge=L?.querySelector("[data-active-session-tab]");if(!L||!ge)return;const Ce=t1(L.getBoundingClientRect(),ge.getBoundingClientRect());Ce!==0&&(L.scrollLeft=L.scrollLeft+Ce,Fe())},e[46]=Xe):Xe=e[46];let Ve;e[47]!==x?(Ve=[x,Fe],e[47]=x,e[48]=Ve):Ve=e[48],l.useEffect(Xe,Ve);const S=ve.left&&ve.right?`linear-gradient(to right, transparent, black ${Hn}px, black calc(100% - ${Hn}px), transparent)`:ve.left?`linear-gradient(to right, transparent, black ${Hn}px)`:ve.right?`linear-gradient(to right, black calc(100% - ${Hn}px), transparent)`:void 0;let ne;e[49]!==oe?(ne=oe.map(O1),e[49]=oe,e[50]=ne):ne=e[50];const q=ne;let ke;e[51]!==x||e[52]!==oe?(ke=!!x&&!oe.some(L=>L.id===x),e[51]=x,e[52]=oe,e[53]=ke):ke=e[53];const Ee=ke;let Ie;e[54]!==u?(Ie=u("header.sessionTabs.stripAria"),e[54]=u,e[55]=Ie):Ie=e[55];let Ne;e[56]!==S?(Ne=S?{maskImage:S,WebkitMaskImage:S}:void 0,e[56]=S,e[57]=Ne):Ne=e[57];let ze;e[58]===Symbol.for("react.memo_cache_sentinel")?(ze=[s1],e[58]=ze):ze=e[58];const Ue=d?Ib:Pb;let Ge;e[59]!==i||e[60]!==x||e[61]!==Se||e[62]!==P||e[63]!==r||e[64]!==h||e[65]!==p||e[66]!==n||e[67]!==a||e[68]!==oe?(Ge=oe.map((L,ge)=>s.jsx(i1,{tabNumber:ge+1,tab:L,isActive:L.id===x,isPreview:L.id===p,suppressControls:L.id===x&&a,onSelect:P,onPin:h,onClose:te,renderMenu:n,closeOtherTabs:Se,onMenuOpenChangeComplete:r,children:L.id===x?i:null},L.id)),e[59]=i,e[60]=x,e[61]=Se,e[62]=P,e[63]=r,e[64]=h,e[65]=p,e[66]=n,e[67]=a,e[68]=oe,e[69]=Ge):Ge=e[69];let Qe;e[70]!==Ue||e[71]!==Ge||e[72]!==q?(Qe=s.jsx(fd,{items:q,strategy:Ue,children:Ge}),e[70]=Ue,e[71]=Ge,e[72]=q,e[73]=Qe):Qe=e[73];let He;e[74]!==De||e[75]!==Me||e[76]!==Qe?(He=s.jsx(dd,{sensors:Me,collisionDetection:ti,modifiers:ze,onDragEnd:De,children:Qe}),e[74]=De,e[75]=Me,e[76]=Qe,e[77]=He):He=e[77];let Ke;e[78]!==K||e[79]!==J||e[80]!==u?(Ke=J?s.jsxs("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2 text-interactive-selection-foreground","data-active":"true","data-active-session-tab":!0,children:[s.jsx(se,{name:"edit",className:"me-1.5 size-3.5 shrink-0"}),s.jsx("div",{className:"session-tab-title min-w-0 flex-1 overflow-hidden whitespace-nowrap italic",children:s.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4",children:K||u("sessions.switcher.draftTitle")})})]}):null,e[78]=K,e[79]=J,e[80]=u,e[81]=Ke):Ke=e[81];let Ye;e[82]!==i||e[83]!==Ee?(Ye=Ee?s.jsx("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag 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:i})}):null,e[82]=i,e[83]=Ee,e[84]=Ye):Ye=e[84];let it;e[85]!==Ne||e[86]!==He||e[87]!==Ke||e[88]!==Ye?(it=s.jsxs("div",{ref:Be,onScroll:Fe,onWheel:r1,className:"session-tabs-scroll flex min-w-0 flex-initial items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:Ne,children:[He,Ke,Ye]}),e[85]=Ne,e[86]=He,e[87]=Ke,e[88]=Ye,e[89]=it):it=e[89];let bt;e[90]!==u?(bt=u("sessions.sidebar.header.actions.newSession"),e[90]=u,e[91]=bt):bt=e[91];let nt;e[92]===Symbol.for("react.memo_cache_sentinel")?(nt=s.jsx(se,{name:"add",className:"size-4"}),e[92]=nt):nt=e[92];let ft;e[93]!==bt?(ft=s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:$,"aria-label":bt,className:"app-region-no-drag ms-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:nt})}),e[93]=bt,e[94]=ft):ft=e[94];let ae;e[95]!==u?(ae=u("sessions.sidebar.header.actions.newSession"),e[95]=u,e[96]=ae):ae=e[96];let de;e[97]!==U?(de=xs(Ts("new_chat",U),""),e[97]=U,e[98]=de):de=e[98];let be;e[99]!==ae||e[100]!==de?(be=s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Ws,{label:ae,shortcut:de})}),e[99]=ae,e[100]=de,e[101]=be):be=e[101];let C;e[102]!==ft||e[103]!==be?(C=s.jsxs(Lt,{children:[ft,be]}),e[102]=ft,e[103]=be,e[104]=C):C=e[104];let ce;return e[105]!==Ie||e[106]!==it||e[107]!==C?(ce=s.jsxs("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":Ie,children:[it,C]}),e[105]=Ie,e[106]=it,e[107]=C,e[108]=ce):ce=e[108],ce};function l1(t){return t.shortcutOverrides}function c1(t){return t.stopPropagation()}function d1(t){return t.tabIds}function u1(t){return t.previewTabId}function f1(t){return t.ensureTab}function p1(t){return t.pinTab}function m1(t){return t.closeOtherTabs}function h1(t){return t.reorderTabs}function g1(t){return t.currentSessionId}function b1(t){return t.setCurrentSession}function x1(t){return t.activeSessions}function w1(t){return t.sessionTabsPerWorkspace}function y1(t){return t.enterScope}function v1(t){return t.hasLoaded}function S1(t){return t.currentSessionDirectory}function k1(t){return t.newSessionDraft.open}function j1(t){return t.newSessionDraft.workDraftId??null}function C1(t){return t.newSessionDraft.target==="chat"}function T1(t){return t.newSessionDraft.directoryOverride}function N1(t){return t.newSessionDraft.selectedProjectId??null}function E1(){return[]}function I1(t){return t.path}function P1(t){vc(t)}function R1(t){return t.trim()}function D1(t){return t.shortcutOverrides}function A1(){const{currentSessionId:t,newSessionDraft:e,openNewSessionDraft:n}=et.getState(),r=t?ls.getState().currentDirectory:e.directoryOverride;n(r?{directoryOverride:r}:void 0)}function _1(){const t=et.getState().currentSessionId;t?vc(t):zp(-1)}function O1(t){return t.id}function Wa(t){const e=$e.c(37),{sessionId:n,onArchive:r,Item:o}=t,{t:i}=at(),a=X(F1);let u;e[0]!==n?(u=v=>v.currentSessionId===n,e[0]=n,e[1]=u):u=e[1];const c=et(u);let d;e[2]!==a?(d=xs(Ts("archive_current_session",a),""),e[2]=a,e[3]=d):d=e[3];const f=d;let p;e[4]!==n?(p=v=>!!v.entityById.get(n)?.time.archived,e[4]=n,e[5]=p):p=e[5];const m=ps(p);let h;e[6]!==n?(h=v=>{const M=v.entityById.get(n);return!M||Wp(M,v.entityById)},e[6]=n,e[7]=h):h=e[7];const b=ps(h),g=et(M1);let x;e[8]!==n||e[9]!==i||e[10]!==g?(x=async()=>{await g(n)?Re.success(i("sessions.sidebar.session.restore.success")):Re.error(i("sessions.sidebar.session.restore.error"))},e[8]=n,e[9]=i,e[10]=g,e[11]=x):x=e[11];const w=x;if(m&&!b)return null;const T=m?"sessions.sidebar.session.menuHint.restore":"sessions.sidebar.session.menuHint.archive";let k;e[12]!==i||e[13]!==T?(k=i(T),e[12]=i,e[13]=T,e[14]=k):k=e[14];let E;e[15]!==m||e[16]!==r||e[17]!==w?(E=m?()=>{w()}:r,e[15]=m,e[16]=r,e[17]=w,e[18]=E):E=e[18];const F=m?"inbox-unarchive":"inbox-archive";let _;e[19]!==F?(_=s.jsx(se,{name:F,className:"me-1 size-4"}),e[19]=F,e[20]=_):_=e[20];const A=m?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let D;e[21]!==i||e[22]!==A?(D=i(A),e[21]=i,e[22]=A,e[23]=D):D=e[23];let y;e[24]!==f||e[25]!==m||e[26]!==c?(y=!m&&c&&f?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:f}):null,e[24]=f,e[25]=m,e[26]=c,e[27]=y):y=e[27];let N;e[28]!==o||e[29]!==_||e[30]!==D||e[31]!==y||e[32]!==E?(N=s.jsxs(o,{onClick:E,children:[_,D,y]}),e[28]=o,e[29]=_,e[30]=D,e[31]=y,e[32]=E,e[33]=N):N=e[33];let j;return e[34]!==N||e[35]!==k?(j=s.jsx(as,{hint:k,children:N}),e[34]=N,e[35]=k,e[36]=j):j=e[36],j}function M1(t){return t.unarchiveSession}function F1(t){return t.shortcutOverrides}function L1(t){const e=$e.c(17),{session:n,Item:r}=t,{t:o}=at();if(!X($1)||n.parentID||!kc(n))return null;let a;e[0]!==n||e[1]!==o?(a=async()=>{try{await Up(n.id,Ys(n),"done"),jc([n.id])}catch{Re.error(o("sessions.sidebar.session.work.updateFailed"))}},e[0]=n,e[1]=o,e[2]=a):a=e[2];const u=a;let c;e[3]!==o?(c=o("sessions.sidebar.session.menuHint.markDone"),e[3]=o,e[4]=c):c=e[4];let d;e[5]!==u?(d=()=>{u()},e[5]=u,e[6]=d):d=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(se,{name:"check",className:"me-1 size-4"}),e[7]=f):f=e[7];let p;e[8]!==o?(p=o("sessions.sidebar.session.work.markDone"),e[8]=o,e[9]=p):p=e[9];let m;e[10]!==r||e[11]!==d||e[12]!==p?(m=s.jsxs(r,{onClick:d,children:[f,p]}),e[10]=r,e[11]=d,e[12]=p,e[13]=m):m=e[13];let h;return e[14]!==c||e[15]!==m?(h=s.jsx(as,{hint:c,children:m}),e[14]=c,e[15]=m,e[16]=h):h=e[16],h}function $1(t){return t.sessionWorkEnabled}const B1=t=>{const e=Cc(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},z1=(t,e)=>t===null||e===null?t===e:t.state!==e.state?!1:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,gd=()=>{const t=$e.c(4),e=et(W1),n=et(U1)??void 0,r=Vp(e??"",n,B1,z1),{context:o}=Hp(e,n),i=o>0?o:qp;let a;return t[0]!==r||t[1]!==i||t[2]!==e?(a={sessionId:e,fill:r,limit:i},t[0]=r,t[1]=i,t[2]=e,t[3]=a):a=t[3],a};function W1(t){return t.currentSessionId}function U1(t){return t.currentSessionDirectory}const Ua=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),Os=18,ri=2,oi=(Os-ri)/2,Va=2*Math.PI*oi,V1=t=>{const e=$e.c(9),{percent:n,arcColor:r,className:o}=t,i=r===void 0?"currentColor":r,a=Math.min(100,Math.max(0,n));let u;e[0]!==o?(u=Le("shrink-0",o),e[0]=o,e[1]=u):u=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx("circle",{cx:Os/2,cy:Os/2,r:oi,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:ri}),e[2]=c):c=e[2];let d;e[3]!==i||e[4]!==a?(d=a>0?s.jsx("circle",{cx:Os/2,cy:Os/2,r:oi,fill:"none",stroke:i,strokeWidth:ri,strokeLinecap:"round",strokeDasharray:Va,strokeDashoffset:Va*(1-a/100),transform:`rotate(-90 ${Os/2} ${Os/2})`}):null,e[3]=i,e[4]=a,e[5]=d):d=e[5];let f;return e[6]!==u||e[7]!==d?(f=s.jsxs("svg",{viewBox:`0 0 ${Os} ${Os}`,className:u,"aria-hidden":"true",children:[c,d]}),e[6]=u,e[7]=d,e[8]=f):f=e[8],f},bd=()=>{const t=$e.c(16),{t:e}=at(),{sessionId:n,fill:r,limit:o}=gd(),{totalCost:i}=Kp(n);if(!n||!r)return null;let a;t[0]!==r.state||t[1]!==r.totalTokens||t[2]!==e?(a=r.state==="measured"?e("contextUsage.tooltip.usedTokens",{tokens:Ua(r.totalTokens)}):e("contextUsage.compacted.description"),t[0]=r.state,t[1]=r.totalTokens,t[2]=e,t[3]=a):a=t[3];let u;t[4]!==o||t[5]!==e?(u=e("contextUsage.tooltip.contextLimit",{tokens:Ua(o)}),t[4]=o,t[5]=e,t[6]=u):u=t[6];let c;t[7]!==e||t[8]!==i?(c=i!==null&&i>0?[e("contextUsage.tooltip.cost",{cost:rd(i)})]:[],t[7]=e,t[8]=i,t[9]=c):c=t[9];let d;t[10]!==a||t[11]!==u||t[12]!==c?(d=[a,u,...c],t[10]=a,t[11]=u,t[12]=c,t[13]=d):d=t[13];const f=d;let p;return t[14]!==f?(p=s.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-edge pt-1 tabular-nums",children:f.map(H1)}),t[14]=f,t[15]=p):p=t[15],p};function H1(t){return s.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const q1="—",K1={safe:"var(--status-success)",warn:"var(--status-warning)",critical:"var(--status-error)"},G1=t=>{const e=$e.c(35),{buttonClassName:n}=t,{t:r}=at(),{sessionId:o,fill:i,limit:a}=gd(),u=Vs();let c;e[0]!==u?(c=u?cs(u):"",e[0]=u,e[1]=c):c=e[1];const d=c,f=X(X1);let p;e[2]!==d?(p=v=>d!==""&&vi(v.contextPanelByDirectory[d],v.contextSurfaceZones).has("context"),e[2]=d,e[3]=p):p=e[3];const m=X(p);if(!o||!i)return null;const h=i.state==="measured"?i.totalTokens/a*100:null,b=h===null?void 0:K1[Gp(Math.round(h))];let g;e[4]!==d||e[5]!==f?(g=d?()=>f(d,"context"):void 0,e[4]=d,e[5]=f,e[6]=g):g=e[6];let x;e[7]!==r?(x=r("contextUsage.aria.label"),e[7]=r,e[8]=x):x=e[8];const w=m&&"text-foreground";let T;e[9]!==n||e[10]!==w?(T=Le(n,"w-auto gap-1.5 px-1 tabular-nums",w),e[9]=n,e[10]=w,e[11]=T):T=e[11];const k=h??0;let E;e[12]!==b||e[13]!==k?(E=s.jsx(V1,{percent:k,arcColor:b,className:"size-4"}),e[12]=b,e[13]=k,e[14]=E):E=e[14];let F;e[15]!==h?(F=h===null?q1:`${Math.min(h,999).toFixed(1)}%`,e[15]=h,e[16]=F):F=e[16];let _;e[17]!==F?(_=s.jsx("span",{dir:"ltr",className:"typography-meta",children:F}),e[17]=F,e[18]=_):_=e[18];let A;e[19]!==m||e[20]!==_||e[21]!==g||e[22]!==x||e[23]!==T||e[24]!==E?(A=s.jsx(Ft,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:g,"aria-label":x,"aria-pressed":m,className:T,children:[E,_]})}),e[19]=m,e[20]=_,e[21]=g,e[22]=x,e[23]=T,e[24]=E,e[25]=A):A=e[25];let D;e[26]!==m||e[27]!==r?(D=m?null:s.jsx("span",{children:r("chat.workStatus.action.openContext")}),e[26]=m,e[27]=r,e[28]=D):D=e[28];let y;e[29]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(bd,{}),e[29]=y):y=e[29];let N;e[30]!==D?(N=s.jsx($t,{side:"bottom",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[D,y]})}),e[30]=D,e[31]=N):N=e[31];let j;return e[32]!==A||e[33]!==N?(j=s.jsxs(Lt,{children:[A,N]}),e[32]=A,e[33]=N,e[34]=j):j=e[34],j},Z1=l.memo(G1);function X1(t){return t.openContextSurface}const xd=l.createContext(null),wd=()=>l.useContext(xd),Y1=t=>{const e=$e.c(4),n=wd()?.observe;let r,o;e[0]!==t||e[1]!==n?(r=()=>t&&n?n():void 0,o=[t,n],e[0]=t,e[1]=n,e[2]=r,e[3]=o):(r=e[2],o=e[3]),l.useEffect(r,o)},Ha=t=>{const e=$e.c(12),{run:n,showIdle:r,large:o,className:i}=t,a=r===void 0?!1:r,u=o===void 0?!1:o;if(n?.status==="stopping"||n?.status==="waiting-for-preview"){let d;e[0]!==i?(d=Le("size-4 shrink-0 animate-spin text-[var(--status-warning)]",i),e[0]=i,e[1]=d):d=e[1];let f;return e[2]!==d?(f=s.jsx(se,{name:"loader-4",className:d}),e[2]=d,e[3]=f):f=e[3],f}if(n){const d=u?"stop-large":"stop";let f;e[4]!==i?(f=Le("size-4 shrink-0 text-[var(--status-warning)]",i),e[4]=i,e[5]=f):f=e[5];let p;return e[6]!==d||e[7]!==f?(p=s.jsx(se,{name:d,className:f}),e[6]=d,e[7]=f,e[8]=p):p=e[8],p}let c;return e[9]!==i||e[10]!==a?(c=a?s.jsx(se,{name:"play",className:Le("size-4 shrink-0",i)}):null,e[9]=i,e[10]=a,e[11]=c):c=e[11],c},J1=t=>{const e=$e.c(68),{directory:n,buttonClassName:r}=t,{t:o}=at(),i=rn(ex),a=rn(tx),u=rn(sx),c=rn(nx),d=Zp(c),f=rn(rx),p=rn(ox),m=rn(ix);let h,b;e[0]!==f?(h=()=>{f()},b=[f],e[0]=f,e[1]=h,e[2]=b):(h=e[1],b=e[2]),l.useEffect(h,b);const g=Bs()&&Qr();let x;e[3]!==a||e[4]!==i?(x=a.find(U=>U.id===i)??a.find(ax)??a[0]??$b[0],e[3]=a,e[4]=i,e[5]=x):x=e[5];const w=x;if(!g||!n||a.length===0)return null;let T;e[6]!==n?(T=async U=>{await Eu(n,U.id,U.appName)||await Kl(n,U.appName)},e[6]=n,e[7]=T):T=e[7];const k=T;let E;e[8]!==k||e[9]!==m?(E=async U=>{await m(U.id),await k(U)},e[8]=k,e[9]=m,e[10]=E):E=e[10];const F=E;let _;e[11]!==n||e[12]!==o?(_=async()=>{(await no(n)).ok&&Re.success(o("openInApp.toast.pathCopied"))},e[11]=n,e[12]=o,e[13]=_):_=e[13];const A=_;let D;e[14]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx("div",{className:"inline-flex"}),e[14]=D):D=e[14];let y;e[15]!==k||e[16]!==w?(y=()=>{k(w)},e[15]=k,e[16]=w,e[17]=y):y=e[17];let N;e[18]!==d||e[19]!==r?(N=Le(r,d),e[18]=d,e[19]=r,e[20]=N):N=e[20];let j;e[21]!==w.label||e[22]!==o?(j=o("openInApp.actions.openInAria",{app:w.label}),e[21]=w.label,e[22]=o,e[23]=j):j=e[23];let v;e[24]!==w.icon?(v=s.jsx(se,{name:w.icon,className:"size-4"}),e[24]=w.icon,e[25]=v):v=e[25];let M;e[26]!==j||e[27]!==v||e[28]!==y||e[29]!==N?(M=s.jsx(ro,{render:D,children:s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:y,className:N,"aria-label":j,children:v})})}),e[26]=j,e[27]=v,e[28]=y,e[29]=N,e[30]=M):M=e[30];let W;e[31]!==w.label||e[32]!==o?(W=o("openInApp.actions.openInAria",{app:w.label}),e[31]=w.label,e[32]=o,e[33]=W):W=e[33];let G;e[34]!==W?(G=s.jsx($t,{side:"bottom",children:W}),e[34]=W,e[35]=G):G=e[35];let O;e[36]!==M||e[37]!==G?(O=s.jsxs(Lt,{children:[M,G]}),e[36]=M,e[37]=G,e[38]=O):O=e[38];let Z;e[39]!==A?(Z=()=>{A()},e[39]=A,e[40]=Z):Z=e[40];let Q;e[41]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(se,{name:"file-copy",className:"h-4 w-4"}),e[41]=Q):Q=e[41];let B;e[42]!==o?(B=o("openInApp.actions.copyPath"),e[42]=o,e[43]=B):B=e[43];let oe;e[44]!==B?(oe=s.jsx("span",{className:"typography-ui-label text-foreground",children:B}),e[44]=B,e[45]=oe):oe=e[45];let H;e[46]!==Z||e[47]!==oe?(H=s.jsxs(Cs,{className:"flex items-center gap-2",onClick:Z,children:[Q,oe]}),e[46]=Z,e[47]=oe,e[48]=H):H=e[48];let P;e[49]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(Tn,{}),e[49]=P):P=e[49];let te;if(e[50]!==a||e[51]!==F||e[52]!==w.id){let U;e[54]!==F||e[55]!==w.id?(U=$=>s.jsxs(Cs,{className:"flex items-center gap-2",onClick:()=>{F($)},children:[s.jsx(se,{name:$.icon,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:$.label}),w.id===$.id?s.jsx(se,{name:"check",className:"ms-auto h-4 w-4 text-primary"}):null]},$.id),e[54]=F,e[55]=w.id,e[56]=U):U=e[56],te=a.map(U),e[50]=a,e[51]=F,e[52]=w.id,e[53]=te}else te=e[53];let J;e[57]!==u||e[58]!==p||e[59]!==o?(J=u?s.jsxs(Cs,{className:"flex items-center gap-2",onClick:()=>{p(!0)},children:[s.jsx(se,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[57]=u,e[58]=p,e[59]=o,e[60]=J):J=e[60];let le;e[61]!==H||e[62]!==te||e[63]!==J?(le=s.jsxs(oo,{className:"w-56 max-h-[70vh] overflow-y-auto",children:[H,P,te,J]}),e[61]=H,e[62]=te,e[63]=J,e[64]=le):le=e[64];let K;return e[65]!==O||e[66]!==le?(K=s.jsxs(pr,{children:[O,le]}),e[65]=O,e[66]=le,e[67]=K):K=e[67],K},Q1=l.memo(J1);function ex(t){return t.selectedAppId}function tx(t){return t.availableApps}function sx(t){return t.isCacheStale}function nx(t){return t.isScanning}function rx(t){return t.initialize}function ox(t){return t.loadInstalledApps}function ix(t){return t.selectApp}function ax(t){return t.id===Bb}const qn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},lx=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const o=qn(n??"");if(o){const i=fr(t,e,o);if(i)return i}return t.find(i=>i.id===r)??null};function yd(){const t=ts(x=>x.projects),e=ts(x=>x.activeProjectId),n=et(x=>x.availableWorktreesByProject),r=et(x=>x.currentSessionId),o=Xp(r??null),i=et(x=>r?x.worktreeMetadata.get(r)?.path??"":""),a=et(x=>x.newSessionDraft?.open?qn(x.newSessionDraft.bootstrapPendingDirectory??x.newSessionDraft.directoryOverride??""):""),u=et(x=>x.newSessionDraft?.open?x.newSessionDraft.target==="chat":null),c=l.useMemo(()=>qn(i||""),[i]),d=l.useMemo(()=>qn(o||""),[o]),f=c||d||a,p=l.useMemo(()=>lx({projects:t,worktreesByProject:n,directory:f,activeProjectId:e}),[e,f,t,n]),m=l.useMemo(()=>qn(f||p?.path||""),[f,p?.path]),h=l.useMemo(()=>p?{id:p.id,path:p.path}:null,[p]),b=u??Yr(d),g=l.useRef(null);return l.useEffect(()=>{h&&m&&!b&&(g.current={projectRef:h,directory:m})},[m,h,b]),l.useMemo(()=>b?null:h&&m?{projectRef:h,directory:m}:g.current,[h,m,b])}const cx=t=>{const e=$e.c(67),{buttonClassName:n}=t,{t:r}=at(),o=wd(),i=X(px),[a,u]=l.useState(!1),c=X(mx);let d;e[0]!==c?(d=xs(Ts("open_project_actions",c),""),e[0]=c,e[1]=d):d=e[1];const f=d,p=o?.available?o.shown:null;let m;e[2]!==o||e[3]!==p?(m=p&&o?o.runOf(p):null,e[2]=o,e[3]=p,e[4]=m):m=e[4];const h=m;Y1(!0);let b;e[5]!==h?(b=le=>h?le.getDirectoryState(h.directory)?.tabs.find(K=>K.id===h.tabId)?.previewUrl??null:null,e[5]=h,e[6]=b):b=e[6];const g=wt(b);if(!o||!p)return null;let x;e[7]!==p.name||e[8]!==h||e[9]!==r?(x=h?r("projectActions.actions.stopNamedAria",{name:p.name}):r("projectActions.actions.runNamedAria",{name:p.name}),e[7]=p.name,e[8]=h,e[9]=r,e[10]=x):x=e[10];const w=x;let T;e[11]!==n||e[12]!==i||e[13]!==g||e[14]!==h||e[15]!==r?(T=h&&g?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>i(h.directory,g),className:n,"aria-label":r("projectActions.actions.openPreview"),children:s.jsx(se,{name:"global",className:"size-4"})})}),s.jsx($t,{side:"bottom",children:r("projectActions.actions.openPreview")})]}):null,e[11]=n,e[12]=i,e[13]=g,e[14]=h,e[15]=r,e[16]=T):T=e[16];let k;e[17]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx("div",{className:"inline-flex"}),e[17]=k):k=e[17];let E;e[18]!==o||e[19]!==p?(E=()=>o.toggle(p),e[18]=o,e[19]=p,e[20]=E):E=e[20];const F=o.isLoading||h?.status==="stopping",_=a&&"text-foreground";let A;e[21]!==n||e[22]!==_?(A=Le(n,_),e[21]=n,e[22]=_,e[23]=A):A=e[23];let D;e[24]!==p||e[25]!==h?(D=h?s.jsx(Ha,{run:h,large:!0}):s.jsx(se,{name:ha(p),className:"size-4"}),e[24]=p,e[25]=h,e[26]=D):D=e[26];let y;e[27]!==w||e[28]!==A||e[29]!==D||e[30]!==E||e[31]!==F?(y=s.jsx(ro,{render:k,children:s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:E,disabled:F,className:A,"aria-label":w,children:D})})}),e[27]=w,e[28]=A,e[29]=D,e[30]=E,e[31]=F,e[32]=y):y=e[32];let N;e[33]!==w?(N=s.jsx("span",{children:w}),e[33]=w,e[34]=N):N=e[34];let j;e[35]!==r?(j=r("projectActions.header.allActions"),e[35]=r,e[36]=j):j=e[36];let v;e[37]!==f||e[38]!==j?(v=s.jsx("span",{className:"typography-micro text-muted-foreground",children:s.jsx(Ws,{label:j,shortcut:f})}),e[37]=f,e[38]=j,e[39]=v):v=e[39];let M;e[40]!==N||e[41]!==v?(M=s.jsx($t,{side:"bottom",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[N,v]})}),e[40]=N,e[41]=v,e[42]=M):M=e[42];let W;e[43]!==y||e[44]!==M?(W=s.jsxs(Lt,{children:[y,M]}),e[43]=y,e[44]=M,e[45]=W):W=e[45];const G=o.openSettings;let O;e[46]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(se,{name:"add",className:"h-4 w-4"}),e[46]=O):O=e[46];let Z;e[47]!==r?(Z=r("projectActions.actions.addNewAction"),e[47]=r,e[48]=Z):Z=e[48];let Q;e[49]!==Z?(Q=s.jsx("span",{className:"typography-ui-label text-foreground",children:Z}),e[49]=Z,e[50]=Q):Q=e[50];let B;e[51]!==o.openSettings||e[52]!==Q?(B=s.jsxs(Cs,{className:"flex items-center gap-2",onClick:G,children:[O,Q]}),e[51]=o.openSettings,e[52]=Q,e[53]=B):B=e[53];let oe;e[54]===Symbol.for("react.memo_cache_sentinel")?(oe=s.jsx(Tn,{}),e[54]=oe):oe=e[54];let H;e[55]!==o||e[56]!==r?(H=o.actions.map(le=>s.jsxs(Cs,{className:"flex items-center gap-2",onClick:()=>{o.select(le),o.toggle(le)},children:[s.jsx(se,{name:ha(le),className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:le.name}),le.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:r("projectActions.menu.sharedBadge")}):null,s.jsx(Ha,{run:o.runOf(le),className:"ms-auto"})]},le.id)),e[55]=o,e[56]=r,e[57]=H):H=e[57];let P;e[58]!==B||e[59]!==H?(P=s.jsxs(oo,{className:"w-60 max-h-[70vh] overflow-y-auto",children:[B,oe,H]}),e[58]=B,e[59]=H,e[60]=P):P=e[60];let te;e[61]!==W||e[62]!==P?(te=s.jsxs(pr,{onOpenChange:u,children:[W,P]}),e[61]=W,e[62]=P,e[63]=te):te=e[63];let J;return e[64]!==te||e[65]!==T?(J=s.jsxs(s.Fragment,{children:[T,te]}),e[64]=te,e[65]=T,e[66]=J):J=e[66],J},dx=l.memo(cx),ux=t=>{const e=$e.c(8),{buttonClassName:n}=t,r=yd();if(!r)return null;let o;e[0]!==n||e[1]!==r.directory?(o=s.jsx(Q1,{directory:r.directory,buttonClassName:n}),e[0]=n,e[1]=r.directory,e[2]=o):o=e[2];let i;e[3]!==n?(i=s.jsx(dx,{buttonClassName:n}),e[3]=n,e[4]=i):i=e[4];let a;return e[5]!==o||e[6]!==i?(a=s.jsxs(s.Fragment,{children:[o,i]}),e[5]=o,e[6]=i,e[7]=a):a=e[7],a},fx=l.memo(ux);function px(t){return t.openContextPreview}function mx(t){return t.shortcutOverrides}const Ao="--oc-titlebar-controls-width",ii=new Set;let Gn=null;const vd=t=>{Gn===null?t.style.removeProperty(Ao):t.style.getPropertyValue(Ao)!==Gn&&t.style.setProperty(Ao,Gn)},hx=t=>{const e=`${Math.round(t)}px`;e!==Gn&&(Gn=e,ii.forEach(vd))},Sd=t=>{if(t)return ii.add(t),vd(t),()=>{ii.delete(t)}},zn="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground data-[popup-open]:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 transition-colors",vn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},qa=t=>!t.parentId&&!t.archived&&!ki(t.directory),gx=()=>{Iu("ui.header.render");const{t,direction:e}=at(),n=X(z=>z.isSidebarOpen),r=io(),o=X(z=>z.sessionTabsEnabled),i=et(z=>!!z.newSessionDraft?.open),a=et(z=>z.currentSessionId),u=Yp(a??""),c=Jp(a??""),d=ps(si(l.useCallback(z=>{if(!a)return null;const qe=[...z.activeSessions,...z.archivedSessions].find(Tt=>Tt.id===a);if(!qe)return null;const ut=qe;return{title:qe.title??null,directory:ut.directory??null,created:qe.time?.created??null,slug:ut.slug??null,parentId:qe.parentID??null,archived:!!qe.time?.archived}},[a]))),f=ts(si(z=>{if(!z.activeProjectId)return null;const qe=z.projects.find(ut=>ut.id===z.activeProjectId);return qe?{id:qe.id,path:qe.path,label:qe.label}:null})),p=l.useMemo(()=>{if(!f)return null;const z=f.label?.trim();if(z)return z;const qe=f.path.split(/[\\/]/).filter(Boolean);return qe[qe.length-1]??null},[f]),{isMobile:m}=gn(),h=l.useRef(null),[b,g]=l.useState(()=>typeof window>"u"?!1:Bs()),x=l.useMemo(()=>qo(),[]),w=Qp(),[T,k]=l.useState(!1),E=l.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:F,side:_}=od(),A=l.useMemo(()=>{if(typeof window>"u")return null;const z=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof z=="number"&&Number.isFinite(z)&&z>0)return z;if(typeof navigator>"u")return null;const qe=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!qe)return null;const ut=Number.parseInt(qe[1],10),Tt=Number.parseInt(qe[2],10);return Number.isNaN(ut)?null:ut===10?Tt:ut},[]);qt.useEffect(()=>{typeof window>"u"||g(Bs())},[]);const D=l.useMemo(()=>Si(),[]),y=X(z=>z.shortcutOverrides),N=xs(Ts("rename_current_session",y),""),j=X(z=>z.workStatusPanelVisible),v=X(z=>z.workStatusPanelEnabled),M=X(z=>z.setWorkStatusPanelEnabled),W=X(z=>z.workStatusPanelFits),G=X(z=>z.workStatusOverlayOpen),O=X(z=>z.setWorkStatusOverlayOpen),Q=v&&W||G,B=l.useCallback(()=>{if(v&&!W){O(!G);return}M(!v)},[O,M,G,v,W]),oe=a?d??null:null,H=l.useRef(null),[P,te]=l.useState(0);l.useEffect(()=>{if(!a){H.current&&(H.current=null,te(Tt=>Tt+1));return}if(oe){H.current={sessionId:a,session:oe,expiresAt:Date.now()+2e3};return}const z=H.current;if(!z||z.sessionId!==a)return;const qe=z.expiresAt-Date.now();if(qe<=0){H.current=null,te(Tt=>Tt+1);return}const ut=window.setTimeout(()=>{H.current?.sessionId===a&&(H.current=null),te(Tt=>Tt+1)},qe);return()=>{window.clearTimeout(ut)}},[a,oe]);const J=(()=>{if(oe)return oe;if(!a)return null;const z=H.current;return z&&z.sessionId===a&&z.expiresAt>Date.now()?z.session:null})(),le=et(z=>a?z.worktreeMetadata.get(a)?.path??"":""),K=et(z=>a?z.worktreeMetadata.get(a)?.branch?.trim()??null:null),U=Tc(z=>a?z.getAttachment(a):void 0),$=l.useMemo(()=>U?em(U,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,U]),ee=l.useMemo(()=>U?U.legacy?"legacy":U.degraded?"degraded":U.worktreeStatus==="pending"?"pending":U.worktreeStatus==="missing"?"missing":U.worktreeStatus==="invalid"?"invalid":U.attentionReason?"attention":null:null,[U]),Y=l.useMemo(()=>vn(le||""),[le]),ie=l.useMemo(()=>{const z=typeof J?.directory=="string"?J.directory:"";return vn(z||"")},[J?.directory]),V=oc(a??"",ie),fe=et(z=>z.newSessionDraft?.open?vn(z.newSessionDraft.bootstrapPendingDirectory??z.newSessionDraft.directoryOverride??""):""),Se=et(z=>z.newSessionDraft.target),Te=et(z=>z.newSessionDraft.selectedProjectId),ue=et(z=>z.currentSessionDirectory),Me=ls(z=>z.homeDirectory),Ae=mr(),De=l.useMemo(()=>Y||ie||(ao(Ae,fe)??""),[fe,Ae,ie,Y]),Be=et(z=>{const qe=vn(Y||ie||"");if(!qe)return null;for(const ut of z.availableWorktreesByProject.values()){const Vt=Lr(ut,qe)?.branch?.trim();if(Vt)return Vt}return null}),ve=tm(De||null)||K||Be,Pe=i?Se==="chat":ql(ie||ue,Me),he=!Pe&&!j&&!!(p||ve||!i&&ee),Fe=l.useMemo(()=>{if(!a)return p??"OpenChamber";const z=J?.title?.trim();return z&&z.length>0?z:"Untitled Session"},[p,J?.title,a]),_e=sm(),We=et(z=>z.updateSessionTitle),Xe=et(z=>z.archiveSessions),Ve=et(z=>z.deleteSessions),[S,ne]=l.useState(!1),[q,ke]=l.useState(!1),Ee=l.useRef(null),[Ie,Ne]=l.useState(""),[ze,Ue]=l.useState(!1),[Ge,Qe]=l.useState(null),He=ps(z=>Ge&&z.entityById.get(Ge)?.title?.trim()||null)??t("sessions.sidebar.session.untitled"),Ke=l.useRef(null),Ye=l.useCallback(()=>{a&&(Ne(J?.title?.trim()||Fe),ne(!0))},[J?.title,a,Fe]),it=l.useRef(Ye);it.current=Ye;const bt=l.useCallback(z=>{z&&(z.focus(),z.select())},[]);l.useEffect(()=>{if(ke(!1),Qe(null),a&&Ee.current===a){Ee.current=null,it.current();return}ne(!1),Ne("")},[a]);const nt=l.useCallback(async()=>{if(!a)return;const z=Ie.trim();z&&z!==J?.title?.trim()&&await We(a,z),ne(!1)},[J?.title,a,Ie,We]);l.useEffect(()=>{if(!S)return;const z=qe=>{const ut=qe.target;(!ut||!Ke.current?.contains(ut))&&nt()};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[S,nt]);const ft=l.useCallback(z=>{z&&no(z).then(qe=>{Re[qe.ok?"success":"error"](t(qe.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Re.error(t("sessions.sidebar.session.copyId.error")))},[t]),ae=l.useCallback(async()=>{if(!a||!De){Re.error(t("sessions.sidebar.session.export.nothingToExport"));return}const z=await _e({sessionID:a,directory:De}).catch(()=>null);if(!z){Re.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(z.length===0){Re.error(t("sessions.sidebar.session.export.nothingToExport"));return}const qe=nm(z,J?.title??null),ut=rm(J?.title??null);await om(qe,ut)||im(qe,ut),Re.success(t("sessions.sidebar.session.export.success"))},[J?.title,a,_e,De,t]),de=am(),be=l.useMemo(()=>lm(de),[de]),C=l.useCallback(z=>{a&&jf({entry:z,t,session:{id:a,title:J?.title,directory:ie??De},loadRecords:async()=>{if(!De)return null;try{return await _e({sessionID:a,directory:De})}catch{return null}},onLoadFailed:()=>Re.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[J?.title,a,_e,De,ie,t]),ce=l.useCallback(z=>be.map(qe=>s.jsxs(z,{onClick:()=>C(qe),children:[s.jsx(Pi,{icon:qe.icon,iconSrc:qe.iconSrc,className:"me-1 size-4"}),qe.action.label]},`${qe.guest.id}:${qe.action.id}`)),[be,C]),L=u?.type==="busy"||u?.type==="retry",ge=l.useCallback(()=>{if(!a||!ie||L||c)return;const qe=ps.getState().activeSessions.find(ut=>ut.id===a);qe&&cm({kind:"quick",root:qe,descendants:um(qe,[]),sourceDirectory:ie,messages:dm(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[a,L,c,ie,t]),Ce=l.useCallback(async(z,qe)=>{const ut=[qe,...fm(qe,[],z==="delete")],Tt=et.getState().currentSessionId===qe?qe:null;if(z==="delete"){const{failedIds:Mt}=await Ve(ut);Mt.length>0?Re.error(t("sessions.sidebar.session.delete.error")):Re.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:Vt,failedIds:Ht}=await Xe(ut);if(Ht.length>0){Re.error(t("sessions.sidebar.session.archive.error"));return}Re.success(t("sessions.sidebar.session.archive.success"),pm(Vt,Tt,t))},[Xe,Ve,t]),Je=l.useCallback(async()=>{Ge&&(Qe(null),await Ce("delete",Ge))},[Ge,Ce]),Oe=X(z=>z.openGuestPageId),me=Ri(z=>z.guests.find(qe=>qe.id===Oe)),je=X(z=>z.isScheduledTasksDialogOpen),st=X(z=>z.isArchivePageOpen),ye=X(z=>z.isIntegrationsCatalogOpen),ot=X(z=>z.isUsageStatsPageOpen),Ct=X(z=>z.isSourceBoardOpen),xt=X(z=>z.isOverviewOpen),jt=X(z=>z.worktreesPageProjectId),ct=X(z=>z.isolatedSpacesEnabled?z.spacesPageProjectId:null),vt=X(z=>z.runOverviewKey),St=Cf(vt),mt=jt??ct,yt=ts(z=>{if(!mt)return null;const qe=z.projects.find(ut=>ut.id===mt);return qe?.label?.trim()||qe?.path?.split("/").pop()||null}),lt=l.useMemo(()=>me?{title:me.pageTitle??me.name,subtitle:null}:je?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:st?{title:t("sessions.archivePage.title"),subtitle:null}:ye?{title:t("integrationsCatalog.page.title"),subtitle:null}:ot?{title:t("usageStats.title"),subtitle:null}:Ct?{title:t("sourceBoard.title"),subtitle:null}:xt?{title:t("overview.title"),subtitle:null}:jt?{title:t("sessions.worktreesPage.title",{project:yt??""}),subtitle:null}:ct?{title:t("spaces.page.title",{project:yt??""}),subtitle:null}:vt?{title:St??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[me,st,ye,St,vt,je,Ct,xt,ot,ct,yt,t,jt]),Nt=ie||vn(ue||"")||Y,_t=l.useCallback(()=>{Zs("desktop_open_draft_mini_chat_window",{directory:Pe?"":fe,projectId:Pe?null:Te,...Cr()}).catch(z=>{console.warn("[header] failed to open draft mini chat window",z)})},[fe,Te,Pe]),ht=l.useCallback(()=>{if(i){_t();return}a&&Zs("desktop_open_session_mini_chat_window",{sessionId:a,directory:ie||vn(ue||"")||Y,...Cr()}).catch(z=>{console.warn("[header] failed to open session mini chat window",z)})},[a,_t,i,ue,ie,Y]),gt=x&&(i||!!a),Dt=l.useCallback((z,qe)=>{Zs("desktop_open_session_mini_chat_window",{sessionId:z,directory:qe,...Cr()}).catch(ut=>{console.warn("[header] failed to open session mini chat window",ut)})},[]),Kt=zn,Yt=l.useMemo(()=>b&&E&&!T?"88px":w?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!b||F)&&!D?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[b,T,E,w,D,F]),js=(!b||F)&&!D?"calc(0.75rem + var(--oc-wco-right-inset, 0px))":"0.75rem",Wt=e==="rtl",ds=Wt?js:Yt,us=Wt?Yt:js,Jt=F&&_!==Gl(e);qt.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",ds)},[ds]);const Is=n?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",rs=n?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";qt.useEffect(()=>{if(!b||!E){k(!1);return}let z=!1;const qe=async()=>{try{const Tt=await Zs("desktop_is_window_fullscreen");z||k(Tt===!0)}catch{z||k(!1)}},ut=()=>{qe()};return qe(),window.addEventListener("openchamber:window-resized",ut),()=>{z=!0,window.removeEventListener("openchamber:window-resized",ut)}},[b,E]);const os=l.useMemo(()=>!b||!E||A===null?"":A>=26?"h-11":A<=15?"h-14":"",[b,E,A]),Ut=l.useMemo(()=>b&&E&&!T?A!==null&&A<=15?"56px":"44px":"0px",[b,T,E,A]),Hs=l.useMemo(()=>{const qe=`max(${b&&E?"2.75rem":"3rem"}, ${Ut}, var(--oc-wco-titlebar-height, 0px))`,ut=b&&!F||D;if(ut&&Ut==="0px")return{};const Tt={minHeight:qe,height:qe};return!Jt&&(!ut||Wt)&&(Tt.paddingInlineEnd=us),Tt},[Jt,b,E,Wt,D,us,Ut,F]),re=l.useRef(null),Ze=l.useCallback(z=>{!z||z===re.current||(re.current=z,document.documentElement.style.setProperty("--oc-header-height",`${z}px`))},[]),pt=l.useCallback(()=>{typeof document>"u"||Ze(h.current?.getBoundingClientRect().height)},[Ze]);qt.useEffect(()=>{if(typeof window>"u")return;pt();const z=h.current;if(!z||typeof ResizeObserver>"u")return()=>{};let qe=0;const ut=()=>{qe||(qe=requestAnimationFrame(()=>{qe=0,pt()}))},Tt=new ResizeObserver(Vt=>{const Ht=Vt[Vt.length-1];Ze(Ht?.borderBoxSize?.[0]?.blockSize??Ht?.target.getBoundingClientRect().height)});return Tt.observe(z),window.addEventListener("resize",ut),window.addEventListener("orientationchange",ut),()=>{qe&&cancelAnimationFrame(qe),Tt.disconnect(),window.removeEventListener("resize",ut),window.removeEventListener("orientationchange",ut)}},[Ze,pt]),qt.useEffect(()=>{pt()},[pt,m,os]);const kt=l.useCallback(async z=>{const qe=z.target;qe.closest(".app-region-no-drag")||qe.closest("button, a, input, select, textarea")||z.button===0&&b&&await Pu()},[b]);mm({rename_current_session:()=>{if(!a||m)return!1;Ye()},archive_current_session:()=>{if(!a||m||ps.getState().entityById.get(a)?.time.archived)return!1;Ce("archive",a)}});const Pt=l.useCallback(({session:z,open:qe,isActive:ut,select:Tt,closeOtherTabs:Vt,components:Ht})=>{const{Item:Mt,Separator:fs}=Ht,Mn=ut&&!D&&!Pe&&J&&!J.parentId,Fn=ut&&!D&&J&&qa(J);return s.jsxs(s.Fragment,{children:[s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(Mt,{onClick:()=>{ut||Tt(),Ee.current=z.id},children:[s.jsx(se,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename"),ut&&N?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:N}):null]})}),s.jsx(ga,{sessionID:z.id,directory:z.directory,open:qe,Item:Mt}),s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(Mt,{onClick:()=>ft(z.id),children:[s.jsx(se,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),s.jsx(fs,{}),ut?s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(Mt,{onClick:()=>{ae()},children:[s.jsx(se,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}):null,x?s.jsxs(Mt,{onClick:()=>Dt(z.id,ut?Nt:z.directory??""),children:[s.jsx(se,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,ut?ce(Mt):null,Mn?s.jsx(as,{hint:t(c?"sessions.sidebar.session.moveToWorktree.tooltipMoving":L?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:s.jsx("span",{className:"block",children:s.jsxs(Mt,{disabled:!ie||L||c,onClick:ge,className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,Fn?s.jsx(as,{hint:t(L?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveSession.hint"),children:s.jsx("span",{className:"block",children:s.jsxs(Mt,{disabled:!ie||L||c,onClick:()=>Ue(!0),className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveSession.menu")]})})}):null,s.jsx(fs,{}),s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:s.jsxs(Mt,{onClick:Vt,children:[s.jsx(se,{name:"close-circle",className:"me-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]})}),s.jsx(fs,{}),s.jsx(L1,{session:z,Item:Mt}),s.jsx(Wa,{sessionId:z.id,Item:Mt,onArchive:()=>{Ce("archive",z.id)}}),s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(Mt,{className:"text-destructive focus:text-destructive",onClick:()=>Qe(z.id),children:[s.jsx(se,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})},[ft,J,Nt,ae,x,Pe,L,c,D,ge,Dt,ce,N,Ce,ie,t]),Zt=()=>s.jsxs("div",{onMouseDown:kt,className:Le("app-region-drag relative flex h-12 select-none items-center",Jt?"pe-0":"pe-2.5",os),style:Hs,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:Is,transitionDuration:`${r}ms`,transitionTimingFunction:Rn}}),s.jsx("div",{ref:Sd,"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:rs,transitionDuration:`${r}ms`,transitionTimingFunction:Rn}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[lt?s.jsxs(s.Fragment,{children:[s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"icon",className:"app-region-no-drag me-1 size-6 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>X.getState().closeMainSurfaces(),children:s.jsx(se,{name:"arrow-left",className:"size-4"})})}),s.jsx($t,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"me-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-start",children:[s.jsx("span",{className:"truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:lt.title}),lt.subtitle?s.jsx("span",{className:"truncate typography-micro text-[0.65625rem] font-normal leading-tight text-muted-foreground max-w-full",children:lt.subtitle}):null]})]}):D||!o?s.jsxs("div",{className:"app-region-no-drag me-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-start",children:[V?s.jsx(se,{name:"loader-4",className:"me-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,n?null:s.jsxs(Lt,{children:[s.jsx(jb,{align:"start",children:s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",className:Kt,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(se,{name:"history",className:"h-4 w-4"})})})}),s.jsx($t,{side:"bottom",children:s.jsx(Ws,{label:t("sessions.switcher.openAria"),shortcut:xs(Ts("open_session_list",y),"")})})]}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[S?s.jsxs("form",{ref:Ke,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:z=>z.stopPropagation(),onSubmit:z=>{z.preventDefault(),nt()},children:[s.jsx("input",{ref:bt,value:Ie,onChange:z=>Ne(z.target.value),onKeyDown:z=>ba(z,()=>ne(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[0.875rem] 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(se,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>ne(!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(se,{name:"close",className:"size-4"})})]}):i?null:s.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:Fe}),he?s.jsxs("span",{className:Le("flex min-w-0 max-w-full items-center gap-1.5 truncate font-normal leading-tight",i?"typography-ui-label text-[0.875rem] text-foreground":"typography-micro text-[0.65625rem] text-muted-foreground"),children:[p?s.jsx("span",{className:"truncate",children:p}):null,ve?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(se,{name:"git-branch",className:Le("flex-shrink-0 text-muted-foreground",i?"h-3.5 w-3.5":"h-3 w-3")}),s.jsx("span",{className:Le("truncate",i&&"text-muted-foreground"),children:ve})]}):null,!i&&ee?s.jsxs("span",{className:Le("inline-flex min-w-0 items-center gap-0.5",ee==="attention"||ee==="invalid"||ee==="missing"?"text-status-warning":"text-muted-foreground"),children:[s.jsx(se,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:$})]}):null]}):null]}),s.jsx("div",{className:Le("flex h-[1.125rem] shrink-0 items-center justify-center",he?"self-start":"self-center"),children:a&&!i&&!S?s.jsxs(pn,{open:q,onOpenChange:ke,onOpenChangeComplete:z=>{!z&&Ee.current&&Ee.current===a&&(Ee.current=null,Ye())},children:[s.jsx(mn,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"xs",className:"h-[1.125rem] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(se,{name:"more",className:"size-4"})})}),s.jsxs(hn,{align:"end",className:"min-w-[190px]",children:[s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(Gt,{onClick:()=>{Ee.current=a},children:[s.jsx(se,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename"),N?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:N}):null]})}),s.jsx(ga,{sessionID:a,directory:ie,open:q,Item:Gt}),s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(Gt,{onClick:()=>a&&ft(a),children:[s.jsx(se,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),s.jsx(un,{}),s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(Gt,{onClick:()=>{ae()},children:[s.jsx(se,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}),x?s.jsxs(Gt,{onClick:()=>Dt(a,Nt),children:[s.jsx(se,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,ce(Gt),!D&&!Pe&&J&&!J.parentId?s.jsx(as,{hint:t(c?"sessions.sidebar.session.moveToWorktree.tooltipMoving":L?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:s.jsx("span",{className:"block",children:s.jsxs(Gt,{disabled:!ie||L||c,onClick:ge,className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,!D&&J&&qa(J)?s.jsx(as,{hint:t(L?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveSession.hint"),children:s.jsx("span",{className:"block",children:s.jsxs(Gt,{disabled:!ie||L||c,onClick:()=>Ue(!0),className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveSession.menu")]})})}):null,s.jsx(un,{}),s.jsx(Wa,{sessionId:a,Item:Gt,onArchive:()=>{Ce("archive",a)}}),s.jsx(as,{hint:t("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(Gt,{className:"text-destructive focus:text-destructive",onClick:()=>{a&&Qe(a)},children:[s.jsx(se,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})]}):null})]}):s.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-start",children:s.jsx(a1,{renderMenu:Pt,suppressActiveTabControls:S,onMenuOpenChangeComplete:z=>{!z&&Ee.current&&Ee.current===a&&(Ee.current=null,Ye())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:S?s.jsxs("form",{ref:Ke,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:z=>z.stopPropagation(),onSubmit:z=>{z.preventDefault(),nt()},children:[s.jsx("input",{ref:bt,value:Ie,onChange:z=>Ne(z.target.value),onKeyDown:z=>ba(z,()=>ne(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[0.8125rem] 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(se,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>ne(!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(se,{name:"close",className:"size-4"})})]}):s.jsx("span",{dir:"auto",className:"block overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4 text-foreground max-w-full",children:i?t("sessions.switcher.draftTitle"):Fe})})})}),lt||D||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!D&&!lt?s.jsxs(s.Fragment,{children:[s.jsx(Z1,{buttonClassName:zn}),s.jsx(fx,{buttonClassName:zn})]}):null,gt?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":t(i?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:ht,className:zn,children:s.jsx(se,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),s.jsx($t,{side:"bottom",children:s.jsx(Ws,{label:t(i?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),shortcut:i?xs(Ts("new_mini_chat",y),""):void 0})})]}):null,D?null:s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":Q,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:B,className:Le(zn,Q&&"text-foreground"),children:s.jsx(se,{name:"list-indefinite",className:"h-4 w-4"})})}),s.jsx($t,{side:"bottom",children:t(v&&!W?G?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":v?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),s.jsx(id,{visible:Jt,position:_})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:h,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:Zt()}),ze&&a&&ie?s.jsx(hm,{open:!0,onOpenChange:Ue,sessionId:a,sourceDirectory:ie}):null,s.jsx(tr,{open:Ge!==null,onOpenChange:z=>{z||Qe(null)},children:s.jsxs(sr,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(nr,{children:[s.jsx(rr,{children:t("sessions.sidebar.dialogs.deleteSession.title")}),s.jsx(or,{children:t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:He})})]}),s.jsxs($r,{children:[s.jsx(dt,{variant:"outline",size:"sm",onClick:()=>Qe(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{variant:"destructive",size:"sm",onClick:()=>{Je()},children:t("sessions.sidebar.bulkActions.delete")})]})]})})]})},Ka=280,Ga=264,Za=500,bx=({isOpen:t,isMobile:e,children:n,className:r,topBar:o,peek:i})=>{const{t:a,direction:u}=at(),c=X(H=>H.sidebarWidth),d=X(H=>H.setSidebarWidth),[f,p]=l.useState(!1),m=l.useRef(0),h=l.useRef(c||Ka),b=l.useRef(null),g=l.useRef(null),x=l.useRef(null),w=l.useRef(null),T=l.useRef(null),k=l.useCallback(H=>Math.min(Za,Math.max(Ga,H)),[]),E=l.useCallback(()=>{const H=T.current;if(H?.isConnected)return H;const P=document.querySelector("[data-titlebar-left-controls]");return T.current=P,P},[]),F=l.useCallback(H=>{const P=w.current;if(!P)return;P.style.width=`${H}px`,P.style.minWidth=`${H}px`,P.style.maxWidth=`${H}px`,P.style.setProperty("--oc-left-sidebar-width",`${H}px`);const te=E();te&&te.style.setProperty("--oc-left-sidebar-width",`${H}px`)},[E]);l.useEffect(()=>{e&&f&&p(!1)},[e,f]),l.useEffect(()=>{f||(b.current=null,g.current=null,x.current?.(),x.current=null)},[f]),l.useEffect(()=>{!t&&f&&p(!1)},[t,f]),l.useEffect(()=>()=>{x.current?.(),x.current=null},[]);const _=Math.min(Za,Math.max(Ga,c||Ka)),A=t?_:0,D=f?b.current??A:A,y=f?D:_;l.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${y}px`);const H=T.current;!f&&H&&H.style.removeProperty("--oc-left-sidebar-width")},[y,f]);const[N,j]=l.useState(!t);t&&N&&j(!1);const v=io(),M=l.useRef(t),W=l.useRef(t);if(l.useLayoutEffect(()=>{M.current=t,W.current!==t&&(W.current=t,Nc(v),t||Di(()=>{M.current||j(!0)}))},[t,v]),e)return null;const G=H=>{if(t){try{H.currentTarget.setPointerCapture(H.pointerId)}catch{}g.current=H.pointerId,p(!0),m.current=H.clientX,h.current=A,b.current=A,F(A),x.current?.(),x.current=Ec(),H.preventDefault()}},O=H=>{if(e||!f||g.current!==H.pointerId)return;const P=(H.clientX-m.current)*(u==="rtl"?-1:1),te=k(h.current+P);b.current!==te&&(b.current=te,F(te))},Z=H=>{if(g.current!==H.pointerId||e)return;try{H.currentTarget.releasePointerCapture(H.pointerId)}catch{}const P=k(b.current??A);g.current=null,b.current=null,p(!1),d(P),x.current?.(),x.current=null},Q=!t&&i?i.state:!1,B=Q!==!1,oe=B&&i&&i.animationMs>0?`${Q==="in"?"oc-sidebar-peek-in":"oc-sidebar-peek-out"} ${i.animationMs}ms ${Rn} forwards`:void 0;return s.jsxs("div",{ref:w,"data-left-sidebar":"",className:Le("relative flex h-full",!B&&"overflow-hidden",f?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",r),style:{width:`${D}px`,minWidth:`${D}px`,maxWidth:`${D}px`,"--oc-left-sidebar-width":`${y}px`,overflowX:B?void 0:"clip",transitionDuration:`${v}ms`,transitionTimingFunction:Rn},children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-0.5px_0_0_0_var(--oc-edge-strong)] rtl:shadow-[inset_0.5px_0_0_0_var(--oc-edge-strong)]","aria-hidden":"true"}),t&&s.jsx("div",{className:Le("absolute inset-e-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",f&&"bg-[var(--interactive-border)]"),onPointerDown:G,onPointerMove:O,onPointerUp:Z,onPointerCancel:Z,onLostPointerCapture:Z,role:"separator","aria-orientation":"vertical","aria-label":a("sidebar.resize.leftPanelAria")}),s.jsxs("aside",{ref:i?.overlayRef,"data-sidebar-peek":B?Q:void 0,className:Le("flex h-full shrink-0 flex-col",B?"absolute inset-s-0 top-0 z-[25] bg-sidebar shadow-xl":"relative z-10 transition-opacity ease-out motion-reduce:transition-none",f&&"pointer-events-none",!t&&!B&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${v}ms`,overflowX:"hidden",contentVisibility:N&&!B?"hidden":void 0,animation:oe,"--oc-peek-offset":u==="rtl"?"100%":"-100%"},inert:!t&&!B||void 0,onPointerEnter:B?i?.overlayHandlers.onPointerEnter:void 0,onPointerLeave:B?i?.overlayHandlers.onPointerLeave:void 0,onAnimationEnd:B?i?.overlayHandlers.onAnimationEnd:void 0,children:[o,s.jsx(hs,{outerClassName:"overlay-scrollbar-wrapper--no-gutter flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Qt,{children:n})})]})]})},xx=()=>{const t=$e.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-start-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",{ref:Sd,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},wx=50,yx=18,vx=300,Sx='[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]',kd=t=>!document.getElementById("root")?.contains(t),kx=t=>{if((Jr(document.documentElement)?window.innerWidth-t.clientX:t.clientX)>yx)return!1;const n=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--oc-header-height"))||48;return t.clientY>=n},Xa=t=>{const e=document.activeElement;return t&&e instanceof HTMLElement&&t.contains(e)&&(e.isContentEditable||e.matches("input, textarea"))?!0:Array.from(document.querySelectorAll(Sx)).some(n=>kd(n)&&n.getClientRects().length>0)},jx=({enabled:t,layoutAnimationMs:e})=>{const[n,r]=l.useState(!1),o=gm()?0:e,i=o>0,a=l.useRef(null),u=l.useRef(null),c=l.useRef(null),d=l.useCallback(()=>{u.current!==null&&clearTimeout(u.current),c.current!==null&&clearTimeout(c.current),u.current=null,c.current=null},[]),f=l.useCallback(()=>{d(),r(b=>b==="in"&&i?"out":!1)},[i,d]),p=l.useCallback(()=>{c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{if(c.current=null,Xa(a.current)){p();return}f()},vx)},[f]),m=l.useCallback(()=>{c.current!==null&&clearTimeout(c.current),c.current=null},[]);l.useEffect(()=>{t||(d(),r(!1))},[d,t]),l.useEffect(()=>d,[d]),l.useEffect(()=>{if(n!=="in")return;const b=w=>{const T=w.target;T instanceof Element&&(a.current?.contains(T)||kd(T)||f())},g=w=>{Ic(w)||w.key!=="Escape"||w.defaultPrevented||Xa(a.current)||f()},x=w=>{w.relatedTarget===null&&p()};return document.addEventListener("pointerdown",b,!0),document.addEventListener("keydown",g),document.addEventListener("pointerout",x),()=>{document.removeEventListener("pointerdown",b,!0),document.removeEventListener("keydown",g),document.removeEventListener("pointerout",x)}},[f,p,n]),l.useEffect(()=>{if(!t||n!==!1)return;const b=()=>{u.current!==null&&clearTimeout(u.current),u.current=null},g=w=>{if(w.pointerType!=="mouse"||w.buttons!==0||!kx(w)){b();return}u.current===null&&(u.current=setTimeout(()=>{u.current=null,r("in")},wx))},x=w=>{w.relatedTarget===null&&b()};return document.addEventListener("pointermove",g,{passive:!0}),document.addEventListener("pointerout",x),()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerout",x),b()}},[t,n]);const h=l.useMemo(()=>({onPointerEnter:()=>{m(),r(b=>b==="out"?"in":b)},onPointerLeave:()=>{n==="in"&&p()},onAnimationEnd:b=>{b.target===b.currentTarget&&r(g=>g==="out"?!1:g)}}),[m,p,n]);return{state:t?n:!1,animationMs:o,overlayRef:a,overlayHandlers:h}},wr="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",Cx=()=>{const t=$e.c(47),{t:e,locale:n,direction:r}=at(),o=X(Tx),i=X(Nx),a=X(Ex),u=l.useRef(null),c=xs(Ts("toggle_sidebar",a)),d=Ix,f=X(Px),{usesFramelessChrome:p,side:m}=od();let h;t[0]!==n?(h=P=>{const te=P.currentTarget.getBoundingClientRect();Zs("desktop_show_app_menu",{x:te.left,y:te.bottom,locale:n}).catch(Rx)},t[0]=n,t[1]=h):h=t[1];const b=h;let g,x;t[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{if(typeof document>"u")return;const P=u.current;if(!P)return;const te=()=>{const le=Math.max(P.getBoundingClientRect().width,P.scrollWidth);hx(le)};if(te(),typeof ResizeObserver>"u")return;const J=new ResizeObserver(te);return J.observe(P),()=>{J.disconnect()}},x=[],t[2]=g,t[3]=x):(g=t[2],x=t[3]),l.useEffect(g,x);const w="",T="app-region-no-drag absolute inset-s-0 top-0 z-30 flex select-none items-center pe-2",k=i?"var(--oc-left-sidebar-width, 100%)":void 0;let E;t[4]!==k?(E={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:k},t[4]=k,t[5]=E):E=t[5];const F="flex min-w-0 items-center gap-2";let _;t[6]!==r||t[7]!==p||t[8]!==m?(_=p&&m===Gl(r)?s.jsx(id,{visible:!0,position:m}):null,t[6]=r,t[7]=p,t[8]=m,t[9]=_):_=t[9];let A;t[10]!==b||t[11]!==e||t[12]!==p?(A=p?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:b,"aria-label":e("header.actions.openAppMenuAria"),className:Le(wr,"shrink-0"),children:s.jsx(se,{name:"menu-2",className:"h-4 w-4"})})}),s.jsx($t,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=b,t[11]=e,t[12]=p,t[13]=A):A=t[13];const D=Lt;let y;t[14]!==e?(y=e("header.actions.openSessionsAria"),t[14]=e,t[15]=y):y=t[15];const N=i&&"text-foreground";let j;t[16]!==N?(j=Le(wr,"shrink-0",N),t[16]=N,t[17]=j):j=t[17];let v;t[18]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(se,{name:"layout-left",className:"h-4 w-4"}),t[18]=v):v=t[18];let M;t[19]!==i||t[20]!==y||t[21]!==j||t[22]!==o?(M=s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":y,"aria-pressed":i,className:j,children:v})}),t[19]=i,t[20]=y,t[21]=j,t[22]=o,t[23]=M):M=t[23];const W=$t,G=e("header.actions.openSessionsWithShortcut",{shortcut:c});let O;t[24]!==G?(O=s.jsx("p",{children:G}),t[24]=G,t[25]=O):O=t[25];let Z;t[26]!==W||t[27]!==O?(Z=s.jsx(W,{children:O}),t[26]=W,t[27]=O,t[28]=Z):Z=t[28];let Q;t[29]!==D||t[30]!==M||t[31]!==Z?(Q=s.jsxs(D,{children:[M,Z]}),t[29]=D,t[30]=M,t[31]=Z,t[32]=Q):Q=t[32];let B;t[33]!==d||t[34]!==i||t[35]!==a||t[36]!==e||t[37]!==f?(B=f?null:i?s.jsxs("button",{type:"button",onClick:d,className:Le(wr,"-ms-1 w-auto min-w-0 ps-1 pe-1.5 font-normal"),children:[s.jsx(se,{name:"chat-new",className:"h-4 w-4 shrink-0"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Le(wr,"-ms-1 shrink-0"),children:s.jsx(se,{name:"chat-new",className:"h-4 w-4"})})}),s.jsx($t,{children:s.jsx(Ws,{label:e("sessions.sidebar.header.actions.newSession"),shortcut:xs(Ts("new_chat",a),"")})})]}),t[33]=d,t[34]=i,t[35]=a,t[36]=e,t[37]=f,t[38]=B):B=t[38];let oe;t[39]!==Q||t[40]!==B||t[41]!==_||t[42]!==A?(oe=s.jsxs("div",{ref:u,className:F,children:[_,A,Q,B]}),t[39]=Q,t[40]=B,t[41]=_,t[42]=A,t[43]=oe):oe=t[43];let H;return t[44]!==oe||t[45]!==E?(H=s.jsx("div",{"data-titlebar-left-controls":w,className:T,style:E,children:oe}),t[44]=oe,t[45]=E,t[46]=H):H=t[46],H};function Tx(t){return t.toggleSidebar}function Nx(t){return t.isSidebarOpen}function Ex(t){return t.shortcutOverrides}function Ix(){X.getState().closeMainSurfaces(),et.getState().openNewSessionDraft()}function Px(t){return t.sessionTabsEnabled&&!(t.isScheduledTasksDialogOpen||t.isArchivePageOpen||t.isIntegrationsCatalogOpen||t.isUsageStatsPageOpen||t.isSourceBoardOpen||t.isOverviewOpen||t.worktreesPageProjectId!==null||t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null||t.runOverviewKey!==null||t.openGuestPageId!==null)}function Rx(t){console.warn("[titlebar] failed to open app menu",t)}function Dx(t,e,n){const r=$e.c(5),[o,i]=l.useState();let a,u;return r[0]!==n||r[1]!==t||r[2]!==e?(a=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let c=!1;return(async()=>{const[d,f]=await Promise.all([bm(t),xm(t)]).catch(Ax);if(c)return;const p=Xt(d),m=Xt(f);if(!p||!m||m===p)return;const h=n||"",b=m.split("/").filter(Boolean).pop()||m;i({source:"sdk",path:m,projectDirectory:p,branch:h,label:h||b,name:b,worktreeRoot:m,worktreeStatus:"ready",headState:h?"branch":"unborn",worktreeSource:"existing"})})(),()=>{c=!0}},u=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=a,r[4]=u):(a=r[3],u=r[4]),l.useEffect(a,u),e??o}function Ax(){return["",""]}const _x=()=>{const t=$e.c(3),e=X(Ox),n=X(Mx);let r;return t[0]!==e||t[1]!==n?(r=()=>{n("integrations"),e(!0)},t[0]=e,t[1]=n,t[2]=r):r=t[2],r};function Ox(t){return t.setSettingsDialogOpen}function Mx(t){return t.setSettingsPage}const Ya="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-edge bg-muted/80",Fx=({className:t,identity:e})=>{const{t:n}=at(),{sourceControl:r}=Es(),o=wm(e),i=ji(e.provider),a=i.label,u=o?.status??null,c=fn(w=>w.setStatus),[d,f]=l.useState(!1),p=l.useCallback(async w=>{if(!(!w||d)){f(!0);try{c(e,await r.authActivate(e,w))}catch(T){console.error("Failed to switch source control account:",T)}finally{f(!1)}}},[e,d,c,r]);if(u?.status!=="connected")return null;const m=u.user.username||null,h=u.user.avatarUrl??null,b=u.accounts,g=m?n("header.sourceControl.connectedWithLogin",{login:m,provider:a}):n("header.sourceControl.connected",{provider:a}),x=h?s.jsx("img",{src:h,alt:m?n("header.sourceControl.avatarWithLogin",{login:m}):n("header.sourceControl.avatar",{provider:a}),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(Ca,{descriptor:i,variant:"fill",className:"h-3.5 w-3.5 text-foreground"});return b.length<=1?s.jsx("div",{className:Le(Ya,t),title:g,children:x}):s.jsxs(pn,{children:[s.jsx(mn,{asChild:!0,children:s.jsx("button",{type:"button",className:Le(Ya,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:g,disabled:d,children:x})}),s.jsxs(hn,{align:"end",className:"w-64",children:[s.jsx(Er,{className:"typography-ui-header font-semibold text-foreground",children:n("header.sourceControl.accountsTitle",{provider:a})}),s.jsx(un,{}),b.map(w=>{const T=w.user,k=!!w.current,E=n(ym(w.source??"oauth"));return s.jsxs(Gt,{className:"gap-2",disabled:d,onSelect:()=>{k||p(w.id)},children:[T?.avatarUrl?s.jsx("img",{src:T.avatarUrl,alt:T.username?n("header.sourceControl.avatarWithLogin",{login:T.username}):n("header.sourceControl.avatar",{provider:a}),className:"h-6 w-6 rounded-full border border-edge 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-edge bg-muted",children:s.jsx(Ca,{descriptor:i,variant:"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:T?.name?.trim()||T.username||i.label}),T.username?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:T.username}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:E})]}):null]}),k?s.jsx(se,{name:"check",className:"h-4 w-4 text-primary"}):null]},w.id)})]})]})},Lx=t=>JSON.stringify(vm(t)),$x=async(t,e)=>{const n=await t.projectUpstream(e);if(!n?.isFork||!n.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,n.upstream.owner,n.upstream.name);return{upstream:n.upstream,branches:r}},jd=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function Bx(t){if(!jd(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function zx(t,e,n){const r=$e.c(18),{sourceControl:o}=Es(),i=ji(t.provider).features.referenceSearch,[a,u]=qt.useState(null);let c;r[0]!==t.bindingRevision||r[1]!==t.provider||r[2]!==t.repositoryId||r[3]!==e?(c=JSON.stringify([t.provider,t.repositoryId,t.bindingRevision,e]),r[0]=t.bindingRevision,r[1]=t.provider,r[2]=t.repositoryId,r[3]=e,r[4]=c):c=r[4];const d=c;let f;r[5]!==t||r[6]!==d||r[7]!==e||r[8]!==i||r[9]!==o?(f=()=>{if(!i)return;let m=!1;return o.references(t,{kind:"pull",query:`#${e}`}).then(h=>{if(m||!h.connected)return;const b=h.items.find(g=>g.kind==="pull"&&g.number===e);b&&u({key:d,pull:b})}).catch(Wx),()=>{m=!0}},r[5]=t,r[6]=d,r[7]=e,r[8]=i,r[9]=o,r[10]=f):f=r[10];let p;return r[11]!==t||r[12]!==d||r[13]!==e||r[14]!==n||r[15]!==i||r[16]!==o?(p=[t,d,e,n,i,o],r[11]=t,r[12]=d,r[13]=e,r[14]=n,r[15]=i,r[16]=o,r[17]=p):p=r[17],qt.useEffect(f,p),a?.key===d?a.pull:null}function Wx(){}const Ux=t=>{const e=$e.c(93),{directory:n,context:r,changeRequest:o,onChanged:i,statusStack:a}=t,{sourceControl:u}=Es(),c=Vs(),d=ts(Vx),[f,p]=qt.useState(0),[m,h]=qt.useState(!1),b=Ai(),g=zx(r,o.number,f);let x;e[0]!==o?(x=Sm(o),e[0]=o,e[1]=x):x=e[1];const w=x;let T;e[2]!==g||e[3]!==w?(T=g?{...w,labels:g.labels,commentCount:g.commentCount}:w,e[2]=g,e[3]=w,e[4]=T):T=e[4];const k=T,[E,F]=qt.useState(null),_=E?.number===o.number?E.sha:null,{detail:A,latest:D,refresh:y}=Pc(n,k,!0,_),N=D.status==="ready"?D.value.pull:null,j=ac(k);let v;e[5]!==i||e[6]!==y?(v=()=>{y(),p(Hx),i()},e[5]=i,e[6]=y,e[7]=v):v=e[7];const M=v,W=lc(k,r,M);let G;e[8]!==r||e[9]!==i||e[10]!==k.number||e[11]!==k.sourceRepo.owner||e[12]!==k.sourceRepo.repo||e[13]!==y||e[14]!==u?(G=async()=>{const q={owner:k.sourceRepo.owner,repo:k.sourceRepo.repo,number:k.number};await u.refreshProviderReads(r,{item:q}).catch(qx),Rc(q),p(Kx),await Promise.all([y(),i()])},e[8]=r,e[9]=i,e[10]=k.number,e[11]=k.sourceRepo.owner,e[12]=k.sourceRepo.repo,e[13]=y,e[14]=u,e[15]=G):G=e[15];const O=G;let Z;e[16]!==k?(Z={source:"repository",reference:k},e[16]=k,e[17]=Z):Z=e[17];const Q=Z,B=c??n;let oe;e[18]!==A||e[19]!==a?(oe=A.status==="ready"&&A.value.pull&&A.value.pull.stack===void 0&&a!==void 0?{status:"ready",value:{...A.value,pull:{...A.value.pull,stack:a}}}:A,e[18]=A,e[19]=a,e[20]=oe):oe=e[20];const H=oe,P=H.status==="ready"?H.value.pull?.stack??null:a??null,te=_i(),J=ts(Gx),le=et(Zx),K=fr(J,le,n),[U,$]=qt.useState(!1);let ee;e[21]===Symbol.for("react.memo_cache_sentinel")?(ee={status:"idle"},e[21]=ee):ee=e[21];const Y=K?()=>$(!0):void 0,ie=N?.submitRequirements,V=D.status==="error",fe=o.mergeable??null;let Se;e[22]!==r||e[23]!==Q||e[24]!==M||e[25]!==P||e[26]!==V||e[27]!==fe||e[28]!==Y||e[29]!==ie?(Se=s.jsx(Ei,{item:Q,project:null,context:r,onStartWorktree:Yx,onChanged:M,worktreeAvailable:!1,stack:P,onStartOnTop:Y,submitRequirements:ie,submitRequirementsUnreadable:V,mergeable:fe}),e[22]=r,e[23]=Q,e[24]=M,e[25]=P,e[26]=V,e[27]=fe,e[28]=Y,e[29]=ie,e[30]=Se):Se=e[30];let Te;e[31]!==o.number||e[32]!==N||e[33]!==_?(Te=N?.revisions?{revisions:N.revisions,selected:_,onSelect:q=>F(q?{number:o.number,sha:q}:null)}:void 0,e[31]=o.number,e[32]=N,e[33]=_,e[34]=Te):Te=e[34];let ue;e[35]!==n||e[36]!==te?(ue=q=>{te(q.url,n)},e[35]=n,e[36]=te,e[37]=ue):ue=e[37];let Me;e[38]===Symbol.for("react.memo_cache_sentinel")?(Me=()=>h(!0),e[38]=Me):Me=e[38];let Ae;e[39]!==j.attachComment||e[40]!==j.attachComments?(Ae={onAttach:j.attachComment,onAttachAll:j.attachComments},e[39]=j.attachComment,e[40]=j.attachComments,e[41]=Ae):Ae=e[41];let De;e[42]!==r||e[43]!==k||e[44]!==M?(De=s.jsx(uc,{reference:k,context:r,onChanged:M}),e[42]=r,e[43]=k,e[44]=M,e[45]=De):De=e[45];let Be;e[46]!==r||e[47]!==A||e[48]!==k||e[49]!==M?(Be=s.jsx(fc,{pull:k,detail:A,context:r,onChanged:M}),e[46]=r,e[47]=A,e[48]=k,e[49]=M,e[50]=Be):Be=e[50];const we=N?.voteLabels;let ve;e[51]!==N?.revisions?(ve=N?.revisions?.at(-1)?.sha,e[51]=N?.revisions,e[52]=ve):ve=e[52];const Pe=_===null;let he;e[53]!==r||e[54]!==k||e[55]!==M||e[56]!==we||e[57]!==ve||e[58]!==Pe?(he=s.jsx(cc,{reference:k,context:r,onRefresh:M,voteLabels:we,latestRevision:ve,onLatestRevision:Pe},k.number),e[53]=r,e[54]=k,e[55]=M,e[56]=we,e[57]=ve,e[58]=Pe,e[59]=he):he=e[59];const Fe=d??"";let _e;e[60]!==B||e[61]!==Fe?(_e={id:Fe,path:B},e[60]=B,e[61]=Fe,e[62]=_e):_e=e[62];let We;e[63]!==r||e[64]!==B||e[65]!==k||e[66]!==_||e[67]!==_e?(We=s.jsx(pc,{pull:k,project:_e,repository:null,context:r,projectOwnsDirectory:Jx,currentDirectory:B,revision:_}),e[63]=r,e[64]=B,e[65]=k,e[66]=_,e[67]=_e,e[68]=We):We=e[68];let Xe;e[69]!==n||e[70]!==Q||e[71]!==b||e[72]!==O||e[73]!==H||e[74]!==Se||e[75]!==Te||e[76]!==ue||e[77]!==Ae||e[78]!==De||e[79]!==Be||e[80]!==he||e[81]!==We||e[82]!==W?(Xe=s.jsx(Oi,{item:Q,directory:n,pullStatus:Mi,trackerDetail:ee,repositoryDetail:H,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:Xx,now:b,footer:Se,revisionChoice:Te,onOpenStackLayer:ue,onOpenChecks:Me,onRefresh:O,commentAttachments:Ae,threadActions:W,labelsControl:De,reviewersControl:Be,reply:he,pullLinks:We}),e[69]=n,e[70]=Q,e[71]=b,e[72]=O,e[73]=H,e[74]=Se,e[75]=Te,e[76]=ue,e[77]=Ae,e[78]=De,e[79]=Be,e[80]=he,e[81]=We,e[82]=W,e[83]=Xe):Xe=e[83];let Ve;e[84]!==j.attachFailedChecks||e[85]!==m||e[86]!==r||e[87]!==k?(Ve=s.jsx(dc,{pull:k,context:r,open:m,onOpenChange:h,onAttachFailed:j.attachFailedChecks}),e[84]=j.attachFailedChecks,e[85]=m,e[86]=r,e[87]=k,e[88]=Ve):Ve=e[88];const S=K?s.jsx(km,{open:U,onOpenChange:$,project:{id:K.id,path:Br(K.path)??K.path},initialSourceBranch:k.head,onWorktreeCreated:Qx}):null;let ne;return e[89]!==Xe||e[90]!==Ve||e[91]!==S?(ne=s.jsxs(s.Fragment,{children:[Xe,Ve,S]}),e[89]=Xe,e[90]=Ve,e[91]=S,e[92]=ne):ne=e[92],ne};function Vx(t){return t.activeProjectId}function Hx(t){return t+1}function qx(){}function Kx(t){return t+1}function Gx(t){return t.projects}function Zx(t){return t.availableWorktreesByProject}function Xx(){}function Yx(){}function Jx(){return!0}function Qx(t){et.getState().openNewSessionDraft({directoryOverride:t,preserveDirectoryOverride:!0})}const ew=/^Change-Id:\s*I[0-9a-f]{40}$/,tw=50,sw=t=>(t.replace(/\r\n/g,`
3
3
  `).trim().split(/\n[ \t]*\n/).at(-1)??"").split(`
4
4
  `).some(r=>ew.test(r.trim())),nw=t=>{const e=t[0]??null,n=t.filter(r=>!sw(r.body));return{status:"ready",commits:t.length,subject:e?.message.trim()||null,tip:e?.hash??null,missing:n.length===0?"none":n.length===1&&n[0]===e?"tip":"many",missingCount:n.length}};function rw(t,e,n,r,o){const i=$e.c(15),[a,u]=l.useState(null);let c;i[0]!==e||i[1]!==n||i[2]!==t||i[3]!==o?(c=JSON.stringify([t,e,n,o]),i[0]=e,i[1]=n,i[2]=t,i[3]=o,i[4]=c):c=i[4];const d=c;let f,p;if(i[5]!==e||i[6]!==n||i[7]!==t||i[8]!==r||i[9]!==d?(f=()=>{if(!r||!t||!e||!n)return;let h=!1;return u({key:d,value:{status:"loading"}}),Dc(t,{from:e,to:n,maxCount:tw}).then(b=>{h||u({key:d,value:nw(b.all)})}).catch(()=>{h||u({key:d,value:{status:"error"}})}),()=>{h=!0}},p=[e,n,t,r,d],i[5]=e,i[6]=n,i[7]=t,i[8]=r,i[9]=d,i[10]=f,i[11]=p):(f=i[10],p=i[11]),l.useEffect(f,p),!r)return null;let m;return i[12]!==d||i[13]!==a?(m=a?.key===d?a.value:{status:"loading"},i[12]=d,i[13]=a,i[14]=m):m=i[14],m}const ow=t=>{const e=$e.c(111),{preflight:n,topic:r,onTopicChange:o,hashtags:i,onHashtagsChange:a,wip:u,onWipChange:c,privateChange:d,onPrivateChange:f,onAddChangeId:p,disabled:m}=t,{t:h}=at(),b=n?.status==="ready"?n:null;let g=null;if(b?.commits===0){let V;e[0]!==h?(V=h("gitView.change.push.nothingToPush"),e[0]=h,e[1]=V):V=e[1];let fe;e[2]!==V?(fe=s.jsx("span",{className:"text-muted-foreground",children:V}),e[2]=V,e[3]=fe):fe=e[3],g=fe}else if(b?.missing==="tip"){let V;e[4]!==h?(V=h("gitView.change.changeId.missingTip"),e[4]=h,e[5]=V):V=e[5];let fe;e[6]!==V?(fe=s.jsx("span",{className:"min-w-0 flex-1 text-[var(--status-warning)]",children:V}),e[6]=V,e[7]=fe):fe=e[7];let Se;e[8]!==m||e[9]!==p||e[10]!==h?(Se=p?s.jsx(dt,{size:"xs",variant:"outline",className:"shrink-0",onClick:p,disabled:m,children:h("gitView.change.changeId.add")}):null,e[8]=m,e[9]=p,e[10]=h,e[11]=Se):Se=e[11];let Te;e[12]!==fe||e[13]!==Se?(Te=s.jsxs(s.Fragment,{children:[fe,Se]}),e[12]=fe,e[13]=Se,e[14]=Te):Te=e[14],g=Te}else if(b?.missing==="many"){let V;e[15]!==b.missingCount||e[16]!==h?(V=h("gitView.change.changeId.missingMany",{count:b.missingCount}),e[15]=b.missingCount,e[16]=h,e[17]=V):V=e[17];let fe;e[18]!==V?(fe=s.jsx("span",{className:"text-[var(--status-warning)]",children:V}),e[18]=V,e[19]=fe):fe=e[19],g=fe}else if(n?.status==="error"){let V;e[20]!==h?(V=h("gitView.change.push.readFailed"),e[20]=h,e[21]=V):V=e[21];let fe;e[22]!==V?(fe=s.jsx("span",{className:"text-[var(--status-error-text)]",children:V}),e[22]=V,e[23]=fe):fe=e[23],g=fe}let x;e[24]!==h?(x=h("gitView.change.push.subject"),e[24]=h,e[25]=x):x=e[25];let w;e[26]!==x?(w=s.jsx("div",{className:"typography-micro text-muted-foreground",children:x}),e[26]=x,e[27]=w):w=e[27];const T=b?.subject??void 0;let k;e[28]!==n?.status||e[29]!==b?.subject?(k=b?.subject??(n?.status==="loading"?s.jsx(se,{name:"loader-4",className:"size-3.5 animate-spin text-muted-foreground"}):null),e[28]=n?.status,e[29]=b?.subject,e[30]=k):k=e[30];let E;e[31]!==T||e[32]!==k?(E=s.jsx("div",{className:"min-h-5 truncate typography-ui-label text-foreground",title:T,children:k}),e[31]=T,e[32]=k,e[33]=E):E=e[33];let F;e[34]!==h?(F=h("gitView.change.push.subjectHint"),e[34]=h,e[35]=F):F=e[35];let _;e[36]!==F?(_=s.jsx("div",{className:"typography-micro text-muted-foreground",children:F}),e[36]=F,e[37]=_):_=e[37];let A;e[38]!==w||e[39]!==E||e[40]!==_?(A=s.jsxs("div",{className:"space-y-1",children:[w,E,_]}),e[38]=w,e[39]=E,e[40]=_,e[41]=A):A=e[41];let D;e[42]!==h?(D=h("gitView.change.push.topic"),e[42]=h,e[43]=D):D=e[43];let y;e[44]!==D?(y=s.jsx("div",{className:"typography-micro text-muted-foreground",children:D}),e[44]=D,e[45]=y):y=e[45];let N;e[46]!==o?(N=V=>o(V.target.value),e[46]=o,e[47]=N):N=e[47];let j;e[48]!==h?(j=h("gitView.change.push.optional"),e[48]=h,e[49]=j):j=e[49];let v;e[50]!==m||e[51]!==N||e[52]!==j||e[53]!==r?(v=s.jsx(Dn,{value:r,onChange:N,placeholder:j,disabled:m}),e[50]=m,e[51]=N,e[52]=j,e[53]=r,e[54]=v):v=e[54];let M;e[55]!==y||e[56]!==v?(M=s.jsxs("label",{className:"space-y-1",children:[y,v]}),e[55]=y,e[56]=v,e[57]=M):M=e[57];let W;e[58]!==h?(W=h("gitView.change.push.hashtags"),e[58]=h,e[59]=W):W=e[59];let G;e[60]!==W?(G=s.jsx("div",{className:"typography-micro text-muted-foreground",children:W}),e[60]=W,e[61]=G):G=e[61];let O;e[62]!==a?(O=V=>a(V.target.value),e[62]=a,e[63]=O):O=e[63];let Z;e[64]!==h?(Z=h("gitView.change.push.hashtagsPlaceholder"),e[64]=h,e[65]=Z):Z=e[65];let Q;e[66]!==m||e[67]!==i||e[68]!==O||e[69]!==Z?(Q=s.jsx(Dn,{value:i,onChange:O,placeholder:Z,disabled:m}),e[66]=m,e[67]=i,e[68]=O,e[69]=Z,e[70]=Q):Q=e[70];let B;e[71]!==G||e[72]!==Q?(B=s.jsxs("label",{className:"space-y-1",children:[G,Q]}),e[71]=G,e[72]=Q,e[73]=B):B=e[73];let oe;e[74]!==M||e[75]!==B?(oe=s.jsxs("div",{className:"flex flex-col gap-3",children:[M,B]}),e[74]=M,e[75]=B,e[76]=oe):oe=e[76];let H;e[77]!==h?(H=h("gitView.change.push.wip"),e[77]=h,e[78]=H):H=e[78];let P;e[79]!==m||e[80]!==c||e[81]!==H||e[82]!==u?(P=s.jsx(Xo,{checked:u,onChange:c,disabled:m,ariaLabel:H}),e[79]=m,e[80]=c,e[81]=H,e[82]=u,e[83]=P):P=e[83];let te;e[84]!==h?(te=h("gitView.change.push.wip"),e[84]=h,e[85]=te):te=e[85];let J;e[86]!==P||e[87]!==te?(J=s.jsxs("label",{className:"flex cursor-pointer items-center gap-2 typography-meta text-foreground",children:[P,te]}),e[86]=P,e[87]=te,e[88]=J):J=e[88];let le;e[89]!==h?(le=h("gitView.change.push.private"),e[89]=h,e[90]=le):le=e[90];let K;e[91]!==m||e[92]!==f||e[93]!==d||e[94]!==le?(K=s.jsx(Xo,{checked:d,onChange:f,disabled:m,ariaLabel:le}),e[91]=m,e[92]=f,e[93]=d,e[94]=le,e[95]=K):K=e[95];let U;e[96]!==h?(U=h("gitView.change.push.private"),e[96]=h,e[97]=U):U=e[97];let $;e[98]!==K||e[99]!==U?($=s.jsxs("label",{className:"flex cursor-pointer items-center gap-2 typography-meta text-foreground",children:[K,U]}),e[98]=K,e[99]=U,e[100]=$):$=e[100];let ee;e[101]!==J||e[102]!==$?(ee=s.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[J,$]}),e[101]=J,e[102]=$,e[103]=ee):ee=e[103];let Y;e[104]!==g?(Y=s.jsx("div",{className:"flex min-h-7 items-center gap-2 typography-micro",children:g}),e[104]=g,e[105]=Y):Y=e[105];let ie;return e[106]!==oe||e[107]!==ee||e[108]!==Y||e[109]!==A?(ie=s.jsxs("div",{className:"flex flex-col gap-3",children:[A,oe,ee,Y]}),e[106]=oe,e[107]=ee,e[108]=Y,e[109]=A,e[110]=ie):ie=e[110],ie};function iw(t,e){const{git:n,sourceControl:r}=Es(),{t:o}=at(),i=Tf(),a=Nf({directory:t,branch:e,chooseContributor:i.choose}),u=jm(t,n,r),c=async(m,h)=>{const b=u.start();if(!b)return Re.info(o("gitView.pr.toast.gitBusy")),!1;try{return await h(b),b.isCurrent()}catch(g){if(g instanceof Cm){if(g.code==="stale-runtime")return!1;const x=g.code==="review-option-invalid"?o("gitView.change.push.invalidOption"):a.errorMessage(g);return x?Re.info(x):Re.error(m),!1}return g instanceof Tm||g instanceof Nm?(Re.error(m,{description:g.message||void 0}),!1):(Re.error(m,{description:g instanceof Error?g.message:String(g)}),!1)}finally{b.finish()}},d=()=>c(o("gitView.toast.syncActionFailed",{action:o("gitView.publish.title")}),async m=>{await(await a.prepare("push",{onOperation:m.onOperation}))()}),f=m=>t?c(o("gitView.change.push.toast.failed"),async h=>{await Em({directory:t,git:n,sourceControl:r,review:m,onOperation:h.onOperation})}):Promise.resolve(!1),p=s.jsxs(s.Fragment,{children:[a.context?s.jsx(Ef,{context:a.context,onSelect:a.settle}):null,a.confirmDialog,s.jsx(If,{candidates:i.candidates,onSelect:i.settle})]});return{push:d,pushForReview:f,dialogs:p}}const aw=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"}},lw=(t,e)=>{const{currentSessionId:n,getDirectoryForSession:r}=et.getState(),o=n?r(n):null;!n||!o||Xt(o)!==Xt(t)||Bm(n,o,zm({url:e.url,number:e.number,title:e.title,kind:"pull",linkedAt:Date.now()}),!0).catch(()=>{})},cw=t=>{const e=t?.changeRequest??t?.pr;return e?Wm({state:e.state,draft:e.draft,checksState:(t?.ci?.summary??t?.checks)?.state,mergeable:e.mergeable,mergeableState:e.mergeableState}):null},dw=[2e3,5e3];let Ja=0;const uw=()=>{const t=globalThis.crypto?.randomUUID?.();return t||(Ja+=1,`source-control-${Date.now().toString(36)}-${Ja.toString(36)}`)},fw=(t,e,n)=>JSON.stringify(["create",t,e.provider,e.instance,e.directory,e.repositoryId,e.accountId,e.bindingRevision,e.primaryRemote,...n]),Cd="openchamber:pr-create-as-draft:v1",Qa=()=>{try{return localStorage.getItem(Cd)==="true"}catch{return!1}},pw=t=>{try{localStorage.setItem(Cd,String(t))}catch{}},_o=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),qs=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):""},mw=(t,e)=>{const n=qs(t);if(!n||n.includes("->"))return"";if(e){const o=`${e}/`;return n.startsWith(o)?n.slice(o.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},hw=(t,e)=>`${t}::${e}`,Oo=new Map,el=On;function gw(t,e,n){const r=$e.c(14);let o;r[0]!==n?(o=n?Lx(n):null,r[0]=n,r[1]=o):o=r[1];const i=o;let a;r[2]===Symbol.for("react.memo_cache_sentinel")?(a={contextKey:null,detectedUpstream:null,upstreamBranches:[]},r[2]=a):a=r[2];const[u,c]=l.useState(a);let d,f;r[3]!==i||r[4]!==t||r[5]!==n||r[6]!==e?(d=()=>{if(!t||!n||!i)return;let m=!1;return(async()=>{try{const h=await $x(e,n);m||c({contextKey:i,detectedUpstream:h.upstream,upstreamBranches:h.branches})}catch{}})(),()=>{m=!0}},f=[i,t,n,e],r[3]=i,r[4]=t,r[5]=n,r[6]=e,r[7]=d,r[8]=f):(d=r[7],f=r[8]),l.useEffect(d,f);let p;return r[9]!==i||r[10]!==u.contextKey||r[11]!==u.detectedUpstream||r[12]!==u.upstreamBranches?(p=u.contextKey===i?{detectedUpstream:u.detectedUpstream,upstreamBranches:u.upstreamBranches}:{detectedUpstream:null,upstreamBranches:[]},r[9]=i,r[10]=u.contextKey,r[11]=u.detectedUpstream,r[12]=u.upstreamBranches,r[13]=p):p=r[13],p}const bw=({directory:t,branch:e,baseBranch:n,trackingBranch:r,ahead:o=0,remoteBranches:i=[],onGeneratedDescription:a})=>{const{t:u}=at(),c=Ac(t),d=Ru(),f=Zl(I=>I.byId),p=I=>f.has(I),m=d(c?.provider),h=m.terminology.changeRequest,b=m.features.createByPush,g=l.useCallback((I,xe)=>u($s(I,h),xe),[h,u]),x=_x(),{sourceControl:w,git:T}=Es(),k=Fi(),E=fn(I=>I.entries),{isMobile:F,hasTouchInput:_,screenWidth:A}=gn(),D=X(I=>I.openContextSurface),y=Im(I=>I.requestTarget),N=!F&&A>=768&&!Si(),j=l.useMemo(()=>hw(t,e),[t,e]),v=l.useMemo(()=>Oo.get(j)??null,[j]),M=ys(I=>I.ensureEntry),W=ys(I=>I.setParams),G=ys(I=>I.beginActiveContextsLoad),O=ys(I=>I.commitActiveContexts),Z=ys(I=>I.releaseActiveContexts),Q=l.useId(),B=ys(I=>I.startWatching),oe=ys(I=>I.stopWatching),H=ys(I=>I.refresh),[P,te]=l.useState(()=>v?.title??_o(e)),[J,le]=l.useState(()=>v?.body??""),[K,U]=l.useState(()=>v?.draft??Qa()),[$,ee]=l.useState(()=>v?.additionalContext??""),[Y,ie]=l.useState(()=>v?.targetBaseBranchChosen===!0),[V,fe]=l.useState(()=>{const I=typeof v?.targetBaseBranch=="string"?qs(v.targetBaseBranch):"";return I||qs(n)}),Se=l.useCallback(I=>{ie(!0),fe(I)},[]),[Te,ue]=l.useState(!1),[Me,Ae]=l.useState(!1),[De,Be]=l.useState(""),[we,ve]=l.useState(""),[Pe,he]=l.useState(!1),[Fe,_e]=l.useState(0),[We,Xe]=l.useState(!1),Ve=_c(t,w),S=Ve.scope.runtimeKey;l.useEffect(()=>{if(!t)return;const I=Ve.scope.runtimeKey,xe=G(I,t,Q),pe=Ve.contexts.filter(rt=>Ta(E[Vn(rt)],rt).connected);return O(I,t,Q,xe,pe),()=>{Z(I,t,Q)}},[G,Ve.contexts,Ve.scope.runtimeKey,O,t,Z,E,Q]);const q=Ve.contexts[0]??null,ke=ys(I=>{if(!q||!V)return null;const xe=Pm(I.entries,q,V);if(!xe||xe.defaultBranch===V)return null;const pe=xe.changeRequest??xe.pr??null;return pe?.state==="open"?pe:null}),Ee=fn(I=>c?I.entries[Vn(c)]?.hasChecked===!0:!1),Ie=q?.primaryRemote??null,Ne=l.useMemo(()=>q?Vn(q):"",[q]),ze=fn(I=>I.entries[Ne]),Ue=q?Ta(ze,q):{authChecked:ze?.hasChecked??!1,connected:!1},Ge=Ue.authChecked,[Qe,He]=l.useState(0),[Ke,Ye]=l.useState({key:"",status:"loading",capabilities:null}),[it,bt]=l.useState(!1),{detectedUpstream:nt,upstreamBranches:ft}=gw(t,w,q);l.useEffect(()=>{if(!q)return;let I=!1;const xe=Vn(q);return Ye({key:xe,status:"loading",capabilities:null}),w.capabilities(q).then(pe=>{I||Ye({key:xe,status:"ready",capabilities:pe})}).catch(()=>{I||Ye({key:xe,status:"error",capabilities:null})}),()=>{I=!0}},[Qe,q,w]);const ae=Ke.key===Ne?Ke:null,de=ae?.status==="ready"?ae.capabilities:null;l.useEffect(()=>{bt(!1)},[t]);const C=!!(t&&e&&n&&(e!==n||nt!==null||b)),ce=l.useMemo(()=>q?Rm(q,e):"",[e,q]),L=l.useRef(ce);L.current=ce;const ge=l.useCallback((I,xe)=>I===ns()&&xe===L.current,[]),Ce=ys(I=>I.entries[ce]),Je=l.useMemo(()=>ce?[ce]:[],[ce]);Li(Dm(Je));const Oe=Ce?.isLoading??!1,me=Ue.connected?Ce?.status??null:null,je=Ve.error?g("settings.sourceControl.instance.status.operationFailed"):Ce?.error??null,st=Ce?.isInitialStatusResolved??!1,ye=l.useMemo(()=>{const I=it?null:Ie,xe=new Set;for(const tt of i){const Et=mw(tt,I);!Et||Et==="HEAD"||xe.add(Et)}if(it)for(const tt of ft)tt&&tt!=="HEAD"&&xe.add(tt);const pe=qs(n);pe&&pe!=="HEAD"&&xe.add(pe);const rt=qs(V);return rt&&rt!=="HEAD"&&xe.add(rt),Array.from(xe).sort((tt,Et)=>tt.localeCompare(Et))},[n,i,Ie,V,ft,it]);l.useEffect(()=>{const I=qs(n);if(!V&&I){fe(I);return}if(ye.length!==0&&!ye.includes(V)){const xe=ye.includes(I)?I:ye[0];xe&&fe(xe)}},[ye,n,V]);const ot=l.useRef([]),Ct=l.useRef(new Map),xt=l.useCallback(I=>{const xe=Ct.current.get(I);if(xe?.inFlight)return null;if(xe)return xe.inFlight=!0,xe.key;const pe=uw();return Ct.current.set(I,{key:pe,inFlight:!0}),pe},[]),jt=l.useCallback((I,xe,pe)=>{const rt=Ct.current.get(I);!rt||rt.key!==xe||(pe?rt.inFlight=!1:Ct.current.delete(I))},[]);l.useEffect(()=>{nt&&bt(!0)},[nt]),l.useEffect(()=>{it&&nt?.defaultBranch&&fe(nt.defaultBranch)},[it,nt?.defaultBranch]);const ct=me?.changeRequest??me?.pr??null,vt=me?.identity??q,St=l.useMemo(()=>me?.project??(me?.repo&&vt?{...me.repo,...vt,id:Eo(me.repo.owner,me.repo.repo),name:me.repo.repo}:null),[me?.project,me?.repo,vt]),mt=ct?.state==="merged"||ct?.state==="closed",yt=mt?null:ct,lt=me?.ci?.summary??me?.checks??null,[Nt,_t]=l.useState(!1),ht=l.useRef(!0);l.useEffect(()=>(ht.current=!0,()=>{ht.current=!1}),[]);const gt=l.useCallback(async I=>{await H(ce,I)},[ce,H]),Dt=l.useCallback((I,xe)=>{ot.current.forEach(pe=>{window.clearTimeout(pe)}),ot.current=dw.map(pe=>window.setTimeout(()=>{ge(I,xe)&&H(xe,{force:!0,silent:!0,markInitialResolved:!0})},pe))},[ge,H]),Kt=l.useCallback(async(I,xe,pe)=>{await Bx({error:I,isCurrent:()=>ge(xe,pe),refresh:()=>H(pe,{force:!0,silent:!0,markInitialResolved:!0}),scheduleRefresh:()=>Dt(xe,pe)})},[ge,H,Dt]);l.useEffect(()=>{!q||!ce||(M(ce),W(ce,{directory:t,branch:e,remoteName:q.primaryRemote,canShow:C,identity:q,readContext:q,sourceControl:w,authChecked:Ue.authChecked,connected:Ue.connected}))},[e,C,t,M,ce,q,w,Ue.authChecked,Ue.connected,W]);const Yt=600,js=l.useCallback(async()=>{if(Nt)return;_t(!0);const I=Date.now();try{if(await gt({force:!0}),ct&&me?.repo&&vt){const xe={owner:me.repo.owner,repo:me.repo.repo,number:ct.number};await w.refreshProviderReads(vt,{item:xe}).catch(()=>{})}}finally{const xe=Yt-(Date.now()-I);xe>0&&await new Promise(pe=>window.setTimeout(pe,xe)),ht.current&&_t(!1)}},[Nt,ct,gt,w,me?.repo,vt]);l.useEffect(()=>{if(!(!q||!ce))return B(ce),()=>{oe(ce)}},[ce,q,B,oe]),l.useEffect(()=>{const I=Oo.get(j)??null;te(I?.title??_o(e)),le(I?.body??""),U(I?.draft??Qa());const xe=I?.targetBaseBranchChosen===!0&&!!I.targetBaseBranch;ie(xe),fe(xe&&I?.targetBaseBranch?qs(I.targetBaseBranch):qs(n))},[n,e,j]),l.useEffect(()=>{!q||!ce||!Ue.connected||gt({markInitialResolved:!0})},[ce,q,gt,Ue.connected]),l.useEffect(()=>{!C||!q||!Ue.connected||gt({force:!0,silent:!0,markInitialResolved:!0})},[C,q,gt,Ue.connected]),l.useEffect(()=>{const I=()=>{const pe=ys.getState().entries[ce]?.lastRefreshAt??0;Date.now()-pe>6e4&&gt({force:!0,silent:!0})},xe=()=>{document.visibilityState==="visible"&&I()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",xe),()=>{window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",xe)}},[ce,gt]),l.useEffect(()=>{Ge&&!Ue.connected&&gt({force:!0,silent:!0,markInitialResolved:!0})},[gt,Ue.connected,Ge]),l.useEffect(()=>{!t||!e||Oo.set(j,{title:P,body:J,draft:K,additionalContext:$,targetBaseBranch:V,targetBaseBranchChosen:Y})},[j,P,J,K,$,V,Y,t,e]),l.useEffect(()=>()=>{ot.current.forEach(I=>{window.clearTimeout(I)}),ot.current=[]},[ce,S]),l.useEffect(()=>()=>{Ct.current.clear()},[]);const Wt=it&&nt?.defaultBranchSha?nt.defaultBranchSha:q?`${q.primaryRemote}/${V}`:V;l.useEffect(()=>{if(!t||!e||!Wt)return;let I=!1;return Dc(t,{from:Wt,to:e,maxCount:2}).then(xe=>{const pe=xe.all.length===1?xe.all[0]?.message.trim():"";I||!pe||te(rt=>rt===_o(e)?pe:rt)}).catch(()=>{}),()=>{I=!0}},[e,Wt,t]);const ds=b?me?.localRevision?.uploadedAs===null:!r||o>0,us=iw(t,e),Jt=rw(t,Wt,e,b&&C,Fe),Is=l.useId(),rs=I=>{U(I),pw(I)},os=l.useCallback(async()=>{if(!Te&&t){ue(!0);try{const xe={base:Wt,head:e,...q?.provider?{changeRequestProvider:d(q.provider)}:{}};$&&(xe.context=$);const pe=await Am(t,xe);pe.title?.trim()&&te(pe.title.trim()),pe.body?.trim()&&le(pe.body.trim()),a?.()}catch(I){const xe=I instanceof Error?I.message:String(I);Re.error(g("gitView.pr.toast.generateDescriptionFailed"),{description:xe})}finally{ue(!1)}}},[$,e,Wt,d,t,Te,a,q,g]),Ut=l.useCallback(async()=>{if(de?.changeRequests!==!0){Re.error(g("gitView.pr.toast.createPrFailed"),{description:g("gitView.pr.capabilitiesUnavailable")});return}const I=P.trim();if(!I){Re.error(g("gitView.pr.toast.titleRequired"));return}const xe=V.trim();if(!xe){Re.error(g("gitView.pr.toast.baseBranchRequired"));return}if(!it&&xe===e){Re.error(g("gitView.pr.toast.baseMustDifferFromHead"));return}const pe=it?nt:St;if(!q||!pe){Re.error(g("gitView.pr.toast.createPrFailed"),{description:je??g("gitView.pr.statusUnavailable")});return}if(ds&&(Ae(!0),!await us.push())){Ae(!1);return}const rt=ns(),tt=ce,Et={owner:pe.owner,name:pe.name},Rt=J.trim()?J:void 0,It=it?void 0:q.primaryRemote,At=it?q.primaryRemote:void 0,ws=fw(rt,q,[Et.owner,Et.name,e,xe,I,Rt,K,It,At]),en=xt(ws);if(!en){Ae(!1);return}Ae(!0);let ko=!1,na=!1;try{const Ds={...q,idempotencyKey:en,target:{project:Et,head:e,base:xe},title:I,draft:K};Rt!==void 0&&(Ds.body=Rt),It&&(Ds.remote=It),At&&(Ds.headRemote=At);const tn=await w.changeRequestCreate(Ds);if(na=!0,jt(ws,en,!1),!ge(rt,tt)||(tn.result.stacked===!1?Re.warning(g("stacks.toast.createdNotStacked"),{description:g("stacks.toast.createdNotStackedDescription",{base:xe})}):Re.success(g(tn.result.stacked?"stacks.toast.createdStacked":"gitView.pr.toast.prCreated")),await gt({force:!0}),!ge(rt,tt)))return;const br=ys.getState().entries[tt]?.status,jo=br?.changeRequest??br?.pr;jo&&jo.number===tn.target.number&&lw(t,jo),Dt(rt,tt)}catch(Ds){const tn=Ds instanceof Error?Ds:new Error(String(Ds));ko=jd(tn);const br=tn.message;Re.error(g("gitView.pr.toast.createPrFailed"),{description:br}),ko&&await Kt(tn,rt,tt)}finally{na||jt(ws,en,ko),Ae(!1)}},[xt,J,e,us,nt,t,K,je,jt,ge,ds,ce,q,Kt,gt,Dt,w,de?.changeRequests,St,V,P,it,g]),Hs=async()=>{const I=V.trim();if(!I){Re.error(g("gitView.pr.toast.baseBranchRequired"));return}const xe={target:I,wip:K,private:Pe};De.trim()&&(xe.topic=De.trim());const pe=we.split(/[\s,]+/).filter(Boolean);pe.length>0&&(xe.hashtags=pe),Ae(!0);try{if(!await us.pushForReview(xe))return;Re.success(g("gitView.change.push.toast.pushed")),await gt({force:!0})}finally{Ae(!1)}},re=async I=>{Ae(!0);try{if(!await us.pushForReview({target:I.base}))return;Re.success(g("gitView.change.push.toast.uploaded")),await gt({force:!0})}finally{Ae(!1)}},Ze=T.addChangeIdToHead,pt=async()=>{const I=Jt?.status==="ready"?Jt.tip:null;if(!(!Ze||!I||!await k.confirm({title:g("gitView.change.changeId.confirmTitle"),message:g("gitView.change.changeId.confirmMessage"),action:g("gitView.change.changeId.add")})))try{await Ze(t,I),Re.success(g("gitView.change.changeId.toast.added"))}catch(pe){Re.error(g("gitView.change.changeId.toast.failed"),{description:pe instanceof Error?pe.message:String(pe)})}finally{_e(pe=>pe+1)}},kt="border-0 bg-transparent rounded-none px-4 py-3";if(!C)return s.jsx("section",{className:kt,children:s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[s.jsx("div",{className:"min-w-0 typography-meta text-muted-foreground",children:g("gitView.pullRequest.availableOnFeatureBranches")}),c?s.jsx(Fx,{identity:c}):null]})});const Pt=me?.changeRequest&&me.changeRequest.state==="open"?me.changeRequest:yt&&St&&vt?{...vt,id:`${Eo(St.owner,St.name)}#${yt.number}`,number:yt.number,project:{...vt,id:St.id,owner:St.owner,name:St.name,url:St.url??""},title:yt.title,body:yt.body,url:yt.url,state:yt.state,draft:yt.draft,base:yt.base,head:yt.head,headSha:yt.headSha,mergeable:yt.mergeable,mergeableState:yt.mergeableState}:null;if(Pt&&q){const I=s.jsx(Ux,{directory:t,context:q,changeRequest:Pt,onChanged:()=>gt({force:!0,silent:!0,markInitialResolved:!0}),statusStack:me?.stack});if(!(b&&ds))return s.jsx("div",{className:"h-full min-h-0",children:I});const xe=Pt.revisionNumber!==void 0?Pt.revisionNumber+1:null;return s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-edge-muted px-4 py-2",children:[s.jsx(se,{name:"arrow-up",className:"size-3.5 shrink-0 text-[var(--status-warning)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-micro text-muted-foreground",children:g("gitView.change.push.notUploaded")}),s.jsxs(dt,{size:"sm",className:"shrink-0",onClick:()=>{re(Pt)},disabled:Me,children:[Me?s.jsx(se,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(se,{name:"upload-2",className:"size-4"}),xe!==null?g("gitView.change.push.uploadPatchset",{number:xe}):g("gitView.change.push.uploadNew")]}),us.dialogs]}),s.jsx("div",{className:"min-h-0 flex-1",children:I})]})}const Zt=St?.url||null,is=it&&nt?.url?nt.url:Zt,z=ae?.status==="error",qe=!!me?.connected,ut=!!(!q&&c&&Ve.status==="ready"&&Ee),Tt=!!(vt&&Ge&&me?.connected===!1)||ut,Vt=vt??c,Ht=Vt?d(Vt.provider).label:null,Mt=cw(me),fs=Mt?`var(--pr-${Mt})`:"var(--status-info)",Mn=Mt==="draft"?"git-pr-draft":Mt==="merged"?"git-merge":Mt==="closed"?"git-close-pull-request":"git-pull-request",Fn=ct?[`${ct.state}${ct.draft?" (draft)":""}`,ct.state==="open"&&ct.mergeable===!1?g("gitView.pr.notMergeable"):null,ct.state==="open"&&typeof ct.mergeableState=="string"&&ct.mergeableState&&ct.mergeableState!=="unknown"?ct.mergeableState:null].filter(Boolean).join(" · "):"",yo=lt?lt.total>0?`${lt.success}/${lt.total} ${g("gitView.pr.checks.label")}`:`${lt.state} ${g("gitView.pr.checks.label")}`:"",hr="px-0 py-3 border-b border-edge-muted flex flex-col gap-1",Ln="flex flex-col gap-3 py-3",$n=s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Oe||Nt,onClick:()=>{js()},"aria-label":g("gitView.pr.actions.refreshAria"),children:s.jsx(se,{name:Oe||Nt?"loader-4":"refresh",className:Le("size-4 text-muted-foreground",(Oe||Nt)&&"animate-spin")})})}),s.jsx($t,{children:s.jsx("p",{children:g("gitView.pr.actions.refresh")})})]}),vo=We||$.trim().length>0,Bn=ds?r?o===1?g("gitView.pr.unpushed.one"):g("gitView.pr.unpushed.many",{count:o}):g("gitView.pr.unpushed.unpublished"):null,gr=g(ds?K?"gitView.pr.actions.pushAndCreateDraftPr":"gitView.pr.actions.pushAndCreatePr":K?"gitView.pr.actions.createDraftPr":"gitView.pr.actions.createPr"),So=Me||!qe||de?.changeRequests!==!0||!V.trim()||!it&&V.trim()===e,R=Me||!qe||!V.trim()||Jt?.status!=="ready"||Jt.commits===0||Jt.missing!=="none";return s.jsxs("section",{className:kt,children:[ct?s.jsxs("div",{className:hr,children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsxs(dt,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{el(ct.url)},"aria-label":Ht?g("gitView.pr.actions.openOnProviderAria",{provider:Ht}):g("gitView.header.openPullRequest"),children:[s.jsx(se,{name:Mn,className:"size-4 shrink-0",style:{color:fs}}),Ht?g("gitView.pr.actions.openOnProvider",{provider:Ht}):g("gitView.header.openPullRequest")]}),s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:g("gitView.pullRequest.title")}),s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:ra(d(vt?.provider),ct.number)})]}),s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:$n})]}),s.jsxs("div",{className:"@container/pr-actions 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:fs},children:Fn}),lt?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${aw(lt.state)}`}),yo]}):null,r&&Ie&&r.split("/")[0]!==Ie?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",Ie]}):null]}),s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:N&&q&&p(q.provider)?s.jsxs(dt,{variant:"outline",size:"sm",className:Le("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",Pf),onClick:()=>{y(t,{source:{kind:"pr",number:ct.number,...St?{sourceRepo:{owner:St.owner,repo:St.name}}:{}},context:q}),D(t,"walkthrough")},"aria-label":g("walkthrough.action.open"),children:[s.jsx(se,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:g("walkthrough.action.open")})]}):null})]})]}):null,s.jsxs("div",{className:Ln,children:[z?s.jsxs("div",{className:"space-y-2 rounded-md bg-[var(--status-error-background)] p-3",children:[s.jsx("div",{className:"typography-ui-label text-[var(--status-error)]",children:g("gitView.pr.capabilitiesUnavailable")}),s.jsx(dt,{variant:"outline",size:"sm",onClick:()=>He(I=>I+1),children:g("settings.sourceControl.transport.retry")})]}):null,Tt&&Ht?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:g("gitView.pr.providerNotConnected",{provider:Ht})}),s.jsx(dt,{variant:"outline",size:"sm",onClick:x,className:"w-fit",children:g("gitView.pr.actions.openSettings")})]}):null,je?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:g("gitView.pr.statusUnavailable")}),s.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:je}),Ve.error?s.jsx(dt,{variant:"outline",size:"sm",onClick:()=>{Ve.retry()},disabled:Ve.status==="loading",children:g("settings.sourceControl.transport.retry")}):null,is?s.jsx(dt,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:is,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(se,{name:"external-link",className:"size-4"}),g("gitView.pr.actions.repo")]})}):null]}):null,(yt||!ct&&!st)&&!je&&!Tt&&(Ve.status==="loading"||q)?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(_m,{className:"size-4"}),g("gitView.pr.checkingStatus")]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[ct&&mt?s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md oc-tile-inset px-2.5 py-2",children:[s.jsx(se,{name:ct.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:fs}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:ct.state==="merged"?g("gitView.pr.history.merged",{number:ct.number,base:ct.base||V}):g("gitView.pr.history.closed",{number:ct.number})}),s.jsx(dt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{el(ct.url)},"aria-label":g("gitView.pr.actions.openOnProviderAria",{provider:Ht}),children:s.jsx(se,{name:"external-link",className:"size-3.5"})})]}):null,s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(se,{name:"git-pull-request",className:"size-4 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",title:e,children:e}),s.jsx(se,{name:"arrow-right",className:"size-3.5 shrink-0 text-muted-foreground"}),it&&nt?s.jsx("span",{className:"min-w-0 shrink truncate typography-meta text-muted-foreground",children:Eo(nt.owner,nt.name)}):null,ye.length>0?s.jsxs(Om,{value:V,onValueChange:Se,children:[s.jsx(Mm,{className:"w-auto min-w-0","aria-label":g("gitView.pr.field.baseBranch"),children:s.jsx(Fm,{placeholder:g("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx(Lm,{children:ye.map(I=>s.jsx($m,{value:I,children:I},I))})]}):s.jsx(Dn,{value:V,onChange:I=>Se(I.target.value),placeholder:g("gitView.pr.placeholder.main"),"aria-label":g("gitView.pr.field.baseBranch"),className:"h-7 w-32"}),s.jsxs("div",{className:"ms-auto flex shrink-0 items-center gap-0.5",children:[is?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",asChild:!0,children:s.jsx("a",{href:is,target:"_blank",rel:"noopener noreferrer","aria-label":g("gitView.pr.actions.repo"),children:s.jsx(se,{name:"external-link",className:"size-4 text-muted-foreground"})})})}),s.jsx($t,{children:s.jsx("p",{children:g("gitView.pr.actions.repo")})})]}):null,$n]})]}),ke?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 typography-meta text-muted-foreground",children:[s.jsx(se,{name:"stack",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:g("stacks.create.stacksOn",{reference:ra(d(q?.provider),ke.number)})})]}):null,b?s.jsx(ow,{preflight:Jt,topic:De,onTopicChange:Be,hashtags:we,onHashtagsChange:ve,wip:K,onWipChange:rs,privateChange:Pe,onPrivateChange:he,onAddChangeId:Ze?()=>{pt()}:void 0,disabled:Me}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:g("gitView.pr.field.title")}),s.jsx(Dn,{value:P,onChange:I=>te(I.target.value),placeholder:g("gitView.pr.placeholder.title"),autoCorrect:_?"on":"off",autoCapitalize:_?"sentences":"off",spellCheck:_})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("label",{htmlFor:Is,className:"typography-micro text-muted-foreground",children:g("gitView.pr.field.description")}),s.jsxs("div",{className:"flex items-center",children:[s.jsxs(dt,{variant:"ghost",size:"xs",className:"rounded-e-none",onClick:os,disabled:Te||Me,children:[Te?s.jsx(se,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(se,{name:"ai-generate-2",className:"size-3.5 text-primary"}),g("gitView.commit.generate")]}),s.jsxs(pn,{children:[s.jsx(mn,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"xs",className:"rounded-s-none border-s-0 px-1",disabled:Te||Me,"aria-label":g("gitView.pr.generate.optionsAria"),children:s.jsx(se,{name:"arrow-down-s",className:"size-3.5"})})}),s.jsx(hn,{align:"end",className:"w-60",children:s.jsxs(Gt,{onSelect:()=>Xe(!0),children:[s.jsx(se,{name:"sticky-note",className:"size-4 shrink-0"}),g("gitView.pr.generate.withNotes")]})})]})]})]}),vo?s.jsxs("div",{className:"relative",children:[s.jsx(Na,{value:$,onChange:I=>ee(I.target.value),className:"min-h-[72px] pe-9",placeholder:g("gitView.pr.placeholder.additionalContext"),"aria-label":g("gitView.pr.generate.notesAria"),autoFocus:We&&!$}),s.jsx(dt,{variant:"ghost",size:"xs",className:"absolute inset-e-1.5 top-1.5 h-6 w-6 px-0",onClick:()=>{ee(""),Xe(!1)},"aria-label":g("gitView.pr.generate.removeNotesAria"),children:s.jsx(se,{name:"close",className:"size-3.5"})})]}):null,s.jsx(Na,{id:Is,value:J,onChange:I=>le(I.target.value),className:"min-h-[140px]",placeholder:g("gitView.pr.placeholder.whatChanged"),autoCorrect:_?"on":"off",autoCapitalize:_?"sentences":"off",spellCheck:_})]})]}),Bn&&!b?s.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-[var(--status-warning)]",children:[s.jsx(se,{name:"arrow-up",className:"size-3.5 shrink-0"}),Bn]}):null,s.jsx("div",{className:"flex justify-end",children:b?s.jsxs(dt,{size:"sm",className:"justify-center gap-2",onClick:()=>{Hs()},disabled:R,children:[Me?s.jsx(se,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(se,{name:"upload-2",className:"size-4"}),s.jsx("span",{children:g("gitView.change.push.forReview")})]}):s.jsxs("div",{className:"flex items-center",children:[s.jsxs(dt,{size:"sm",className:"justify-center gap-2 rounded-e-none",onClick:Ut,disabled:So,children:[Me?s.jsx(se,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(se,{name:K?"git-pr-draft":"git-pull-request",className:"size-4"}),s.jsx("span",{children:gr})]}),s.jsxs(pn,{children:[s.jsx(mn,{asChild:!0,children:s.jsx(dt,{size:"sm",className:"rounded-s-none border-s-0 px-1.5",disabled:Me,"aria-label":g("gitView.pr.createKindAria"),children:s.jsx(se,{name:"arrow-down-s",className:"size-4"})})}),s.jsx(hn,{align:"end",className:"w-56",children:s.jsxs(Oc,{value:K?"draft":"ready",onValueChange:I=>rs(I==="draft"),children:[s.jsx(zr,{value:"ready",children:g("gitView.pr.actions.createPr")}),s.jsx(zr,{value:"draft",children:g("gitView.pr.actions.createDraftPr")})]})})]})]})}),us.dialogs,k.dialog]})]})]})},xw=()=>{const t=$e.c(95),{t:e}=at(),{git:n,sourceControl:r}=Es(),o=Vs();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={recheckOnOpen:!0},t[0]=i):i=t[0];const{rootIsGitRepo:a,gitDirectory:u,nestedRepos:c,repositoryOptions:d}=Um(o??null,i),f=lo(u??null),p=Vm(u??null),m=Hm(u??null),h=_c(u,r),{ensureAll:b,ensureNestedRepos:g,selectNestedRepo:x}=An(si(ww)),w=et(yw),T=et(vw),k=et(Sw),E=et(kw);let F;t[1]!==o?(F=Xt(o),t[1]=o,t[2]=F):F=t[2];const _=F;let A;e:{if(!_){A=void 0;break e}let we;t[3]!==E||t[4]!==_||t[5]!==k?(we=Lr(E,_)??Lr(k.values(),_),t[3]=E,t[4]=_,t[5]=k,t[6]=we):we=t[6],A=we}const D=A;let y;t[7]!==w||t[8]!==D||t[9]!==T?.open||t[10]!==k?(y=()=>{if(w)return k.get(w)??D;if(T?.open)return D},t[7]=w,t[8]=D,t[9]=T?.open,t[10]=k,t[11]=y):y=t[11],T?.open;let N;t[12]!==y?(N=y(),t[12]=y,t[13]=N):N=t[13];const j=N;let v;t[14]!==w?(v=we=>w?we.getAttachment(w):void 0,t[14]=w,t[15]=v):v=t[15];const M=Tc(v),W=M&&!M.degraded&&!M.legacy?M.worktreeRoot??void 0:void 0,G=Dx(o,j,f?.current??void 0);let O,Z;t[16]!==b||t[17]!==n||t[18]!==u?(O=()=>{!u||!n||b(u,n)},Z=[u,b,n],t[16]=b,t[17]=n,t[18]=u,t[19]=O,t[20]=Z):(O=t[19],Z=t[20]),l.useEffect(O,Z);const[Q,B]=l.useState(null);let oe;t[21]!==W||t[22]!==G?.projectDirectory?(oe=()=>{const we=W||G?.projectDirectory;if(!we){B(null);return}let ve=!1;return qm(we).then(Pe=>{if(ve)return;const he=Pe.trim();B(he&&he!=="HEAD"?he:null)}).catch(()=>{ve||B(null)}),()=>{ve=!0}},t[21]=W,t[22]=G?.projectDirectory,t[23]=oe):oe=t[23];const H=G?.projectDirectory;let P;t[24]!==W||t[25]!==H?(P=[W,H],t[24]=W,t[25]=H,t[26]=P):P=t[26],l.useEffect(oe,P);let te;e:{if(!p?.all){let ve;t[27]===Symbol.for("react.memo_cache_sentinel")?(ve=[],t[27]=ve):ve=t[27],te=ve;break e}let we;t[28]!==p.all?(we=p.all.filter(jw).sort(),t[28]=p.all,t[29]=we):we=t[29],te=we}const J=te;let le;e:{if(!p?.all){let ve;t[30]===Symbol.for("react.memo_cache_sentinel")?(ve=[],t[30]=ve):ve=t[30],le=ve;break e}let we;t[31]!==p.all?(we=p.all.filter(Cw).map(Tw).sort(),t[31]=p.all,t[32]=we):we=t[32],le=we}const K=le,U=f?.current??null,$=h.contexts[0]?.primaryRemote,ee=$?p?.defaultBranches?.[$]:void 0;let Y;t[33]!==h.contexts[0]||t[34]!==h.read?.repository.remotes||t[35]!==U||t[36]!==ee||t[37]!==J||t[38]!==Q||t[39]!==G?.createdFromBranch?(Y=()=>Df({remoteNames:new Set(h.contexts[0]?.primaryRemote?[h.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(h.read?.repository.remotes.map(Nw)??[]),localBranches:J,worktreeCreatedFromBranch:G?.createdFromBranch,rootBranchHint:Q,defaultBranch:ee,headBranch:U,fallbackToConventional:!1}),t[33]=h.contexts[0],t[34]=h.read?.repository.remotes,t[35]=U,t[36]=ee,t[37]=J,t[38]=Q,t[39]=G?.createdFromBranch,t[40]=Y):Y=t[40],G?.createdFromBranch;let ie;t[41]!==Y?(ie=Y(),t[41]=Y,t[42]=ie):ie=t[42];const fe=Rf(u??null,U,!0,h,p,ie),Se=Xl(Ac(o??null)?.provider);if(!o){let we;t[43]===Symbol.for("react.memo_cache_sentinel")?(we=s.jsx(se,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[43]=we):we=t[43];let ve;t[44]!==Se||t[45]!==e?(ve=e($s("gitView.pullRequest.title",Se)),t[44]=Se,t[45]=e,t[46]=ve):ve=t[46];let Pe;t[47]!==ve?(Pe=s.jsx("div",{className:"typography-ui-header text-foreground",children:ve}),t[47]=ve,t[48]=Pe):Pe=t[48];let he;t[49]!==Se||t[50]!==e?(he=e($s("gitView.pullRequest.createHint",Se)),t[49]=Se,t[50]=e,t[51]=he):he=t[51];let Fe;t[52]!==he?(Fe=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:he}),t[52]=he,t[53]=Fe):Fe=t[53];let _e;return t[54]!==Pe||t[55]!==Fe?(_e=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[we,Pe,Fe]}),t[54]=Pe,t[55]=Fe,t[56]=_e):_e=t[56],_e}if(a===!1&&m!==!0){let we;t[57]!==o||t[58]!==g?(we=()=>{g(o,{force:!0})},t[57]=o,t[58]=g,t[59]=we):we=t[59];let ve;return t[60]!==o||t[61]!==m||t[62]!==c||t[63]!==a||t[64]!==we?(ve=s.jsx(Af,{root:o,rootIsGitRepo:a,resolvedIsGitRepo:m,nestedRepos:c,onRetryDiscovery:we}),t[60]=o,t[61]=m,t[62]=c,t[63]=a,t[64]=we,t[65]=ve):ve=t[65],ve}if(!U){let we;t[66]===Symbol.for("react.memo_cache_sentinel")?(we=s.jsx(se,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[66]=we):we=t[66];let ve;t[67]!==Se||t[68]!==e?(ve=e($s("gitView.pullRequest.title",Se)),t[67]=Se,t[68]=e,t[69]=ve):ve=t[69];let Pe;t[70]!==ve?(Pe=s.jsx("div",{className:"typography-ui-header text-foreground",children:ve}),t[70]=ve,t[71]=Pe):Pe=t[71];let he;t[72]!==Se||t[73]!==e?(he=e($s("gitView.pullRequest.createHint",Se)),t[72]=Se,t[73]=e,t[74]=he):he=t[74];let Fe;t[75]!==he?(Fe=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:he}),t[75]=he,t[76]=Fe):Fe=t[76];let _e;return t[77]!==Pe||t[78]!==Fe?(_e=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[we,Pe,Fe]}),t[77]=Pe,t[78]=Fe,t[79]=_e):_e=t[79],_e}let Te;t[80]!==o||t[81]!==u||t[82]!==d||t[83]!==x?(Te=d?s.jsx("div",{className:"flex shrink-0 items-center border-b border-edge px-4 py-2",children:s.jsx(Km,{repositories:d,selectedRepository:u??null,onSelectRepository:we=>{o&&x(o,we)},repositoryRoot:o??void 0})}):null,t[80]=o,t[81]=u,t[82]=d,t[83]=x,t[84]=Te):Te=t[84];const ue=u??o,Me=f?.tracking??void 0,Ae=f?.ahead??0;let De;t[85]!==fe||t[86]!==U||t[87]!==K||t[88]!==ue||t[89]!==Me||t[90]!==Ae?(De=s.jsx(hs,{as:Gm,outerClassName:"h-full min-h-0 flex-1",className:"h-full",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(bw,{directory:ue,branch:U,baseBranch:fe,trackingBranch:Me,ahead:Ae,remoteBranches:K})}),t[85]=fe,t[86]=U,t[87]=K,t[88]=ue,t[89]=Me,t[90]=Ae,t[91]=De):De=t[91];let Be;return t[92]!==Te||t[93]!==De?(Be=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[Te,De]}),t[92]=Te,t[93]=De,t[94]=Be):Be=t[94],Be};function ww(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function yw(t){return t.currentSessionId}function vw(t){return t.newSessionDraft}function Sw(t){return t.worktreeMetadata}function kw(t){return t.availableWorktrees}function jw(t){return!t.startsWith("remotes/")}function Cw(t){return t.startsWith("remotes/")}function Tw(t){return t.replace(/^remotes\//,"")}function Nw(t){return t.name}const Td=[],Ew=t=>{const e=$e.c(17),n=co(),r=Mc();let o;e[0]!==t.url||e[1]!==r||e[2]!==n?(o=Fc(t.url,n,r),e[0]=t.url,e[1]=r,e[2]=n,e[3]=o):o=e[3];const i=o;_f(t.visible);const{panelDirectory:a,tabId:u,url:c}=t;let d;e[4]!==a||e[5]!==u||e[6]!==c?(d=()=>{nh(a,u)&&(On(c),X.getState().closeContextPanelTab(a,u))},e[4]=a,e[5]=u,e[6]=c,e[7]=d):d=e[7];const f=d;let p;e[8]!==a||e[9]!==u?(p=()=>rh(a,u),e[8]=a,e[9]=u,e[10]=p):p=e[10];const m=p;let h;if(e[11]!==f||e[12]!==t||e[13]!==m||e[14]!==i||e[15]!==c){const b=i?i.source==="tracker"?s.jsx(Pw,{url:c,provider:i.provider,identifier:i.identifier,visible:t.visible,onUnavailable:f,onShown:m}):s.jsx(Iw,{...t,kind:i.kind,onUnavailable:f,onShown:m}):s.jsx(Ki,{url:c});h=s.jsx("div",{className:"h-full min-h-0",children:b}),e[11]=f,e[12]=t,e[13]=m,e[14]=i,e[15]=c,e[16]=h}else h=e[16];return h},Zn=t=>{const e=$e.c(8),{message:n,onRetry:r}=t,{t:o}=at();let i;e[0]!==n?(i=s.jsx("span",{children:n}),e[0]=n,e[1]=i):i=e[1];let a;e[2]!==r||e[3]!==o?(a=r?s.jsx(dt,{size:"sm",variant:"outline",onClick:r,children:o("references.picker.actions.retry")}):null,e[2]=r,e[3]=o,e[4]=a):a=e[4];let u;return e[5]!==i||e[6]!==a?(u=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center typography-meta text-muted-foreground",children:[i,a]}),e[5]=i,e[6]=a,e[7]=u):u=e[7],u},Ki=t=>{const e=$e.c(14),{url:n}=t,{t:r}=at();let o;e[0]!==r?(o=r("contextPanel.tracker.unavailable"),e[0]=r,e[1]=o):o=e[1];let i;e[2]!==o?(i=s.jsx("span",{children:o}),e[2]=o,e[3]=i):i=e[3];let a;e[4]!==n?(a=()=>{On(n)},e[4]=n,e[5]=a):a=e[5];let u;e[6]!==r?(u=r("contextPanel.preview.actions.openExternal"),e[6]=r,e[7]=u):u=e[7];let c;e[8]!==a||e[9]!==u?(c=s.jsx(dt,{size:"sm",variant:"outline",onClick:a,children:u}),e[8]=a,e[9]=u,e[10]=c):c=e[10];let d;return e[11]!==i||e[12]!==c?(d=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center typography-meta text-muted-foreground",children:[i,c]}),e[11]=i,e[12]=c,e[13]=d):d=e[13],d},tl=t=>{const e=$e.c(25),{enabled:n,directory:r,url:o,kind:i,linked:a}=t;let u;e[0]!==r||e[1]!==n||e[2]!==i||e[3]!==a||e[4]!==o?(u={enabled:n,directory:r,kind:i,filter:Ia,query:o,linked:a},e[0]=r,e[1]=n,e[2]=i,e[3]=a,e[4]=o,e[5]=u):u=e[5];const c=Ea(u),d=co();let f;e[6]!==o||e[7]!==d?(f=j=>j.find(v=>oh(v.url,o,d))??null,e[6]=o,e[7]=d,e[8]=f):f=e[8];const p=f;let m;if(e[9]!==i||e[10]!==o||e[11]!==d){const j=i==="issue"?th(o,d):null,v=d.match(o);m=j?.descriptor.terminology.sharedNumberSpace&&v?sh(j,"pull",v.number):null,e[9]=i,e[10]=o,e[11]=d,e[12]=m}else m=e[12];const h=m,b=Rw,[g,x]=qt.useState(null),w=g===o;n&&h&&!w&&b(c)&&!p(c.items)&&x(o);const T=n&&w&&h!==null,k=h??"";let E;e[13]!==r||e[14]!==a||e[15]!==T||e[16]!==k?(E={enabled:T,directory:r,kind:"pull",filter:Ia,query:k,linked:a},e[13]=r,e[14]=a,e[15]=T,e[16]=k,e[17]=E):E=e[17];const F=Ea(E),_=w?F:c;let A;e[18]!==_.items||e[19]!==p?(A=p(_.items),e[18]=_.items,e[19]=p,e[20]=A):A=e[20];const D=A,y=n&&b(_)&&!D;let N;return e[21]!==_||e[22]!==D||e[23]!==y?(N={lookup:_,reference:D,missing:y},e[21]=_,e[22]=D,e[23]=y,e[24]=N):N=e[24],N},Iw=t=>{const e=$e.c(128),{url:n,directory:r,panelDirectory:o,foreign:i,visible:a,kind:u,onUnavailable:c,onShown:d}=t,{t:f}=at(),{sourceControl:p}=Es(),m=ts(Dw),h=Ym(r,n),b=h.directory,g=co(),x=Jm(b),w=x&&x!=="missing"?x:null,T=h.status==="ready";let k;e[0]!==u||e[1]!==b||e[2]!==T||e[3]!==n?(k={enabled:T,directory:b,url:n,kind:u,linked:!1},e[0]=u,e[1]=b,e[2]=T,e[3]=n,e[4]=k):k=e[4];const E=tl(k);let F;e[5]!==n||e[6]!==g?(F=g.match(n),e[5]=n,e[6]=g,e[7]=F):F=e[7];const _=F,A=w!==null&&_?.provider===w.provider&&_.instance===w.instance,D=h.status==="ready"&&!E.reference&&(E.missing||E.lookup.status==="error"&&!h.owned),y=D&&A;let N;e[8]!==u||e[9]!==b||e[10]!==y||e[11]!==n?(N={enabled:y,directory:b,url:n,kind:u,linked:!0},e[8]=u,e[9]=b,e[10]=y,e[11]=n,e[12]=N):N=e[12];const j=tl(N),v=E.reference??j.reference,M=E.reference||!D?E.lookup:j.lookup,W=v?.linked===!0;let G;e[13]!==w||e[14]!==W?(G=w&&W?{...w,linked:!0}:w,e[13]=w,e[14]=W,e[15]=G):G=e[15];const O=G,Z=W?null:O;let Q;if(e[16]!==M.followed||e[17]!==v?.number){let He;e[19]!==v?.number?(He=Ke=>!ih(Ke)&&Ke.number===v?.number,e[19]=v?.number,e[20]=He):He=e[20],Q=M.followed.filter(He),e[16]=M.followed,e[17]=v?.number,e[18]=Q}else Q=e[18];Li(a?Q:Td);const oe=D&&!v&&(!A||j.missing||j.lookup.status==="error");let H,P;e[21]!==c||e[22]!==oe?(H=()=>{oe&&c()},P=[c,oe],e[21]=c,e[22]=oe,e[23]=H,e[24]=P):(H=e[23],P=e[24]),qt.useEffect(H,P);const te=v!==null;let J,le;e[25]!==te||e[26]!==d?(J=()=>{te&&d()},le=[te,d],e[25]=te,e[26]=d,e[27]=J,e[28]=le):(J=e[27],le=e[28]),qt.useEffect(J,le);const{detail:K,refresh:U}=Pc(b,v,!0);let $;e[29]!==v?($=v?[v]:[],e[29]=v,e[30]=$):$=e[30];const ee=Qm(b,$),Y=ac(v),[ie,V]=qt.useState(!1),fe=Ai(),{retry:Se}=M;let Te;e[31]!==U||e[32]!==Se?(Te=()=>Promise.all([U(),Se()]).then(Aw),e[31]=U,e[32]=Se,e[33]=Te):Te=e[33];const ue=Te,Me=lc(v,Z,ue),Ae=_i(),De=K.status==="ready"?K.value.pull?.stack??null:null;let Be;e[34]!==v||e[35]!==ue||e[36]!==p||e[37]!==Z?(Be=async()=>{if(Z&&v){const He={owner:v.sourceRepo.owner,repo:v.sourceRepo.repo,number:v.number};await p.refreshProviderReads(Z,{item:He}).catch(_w),Rc(He)}await ue()},e[34]=v,e[35]=ue,e[36]=p,e[37]=Z,e[38]=Be):Be=e[38];const we=Be;if(!v){if(oe){let Ke;return e[39]!==n?(Ke=s.jsx(Ki,{url:n}),e[39]=n,e[40]=Ke):Ke=e[40],Ke}if(h.status==="failed"){let Ke;e[41]!==f?(Ke=f("gitView.empty.discoverFailed"),e[41]=f,e[42]=Ke):Ke=e[42];let Ye;return e[43]!==h.retry||e[44]!==Ke?(Ye=s.jsx(Zn,{message:Ke,onRetry:h.retry}),e[43]=h.retry,e[44]=Ke,e[45]=Ye):Ye=e[45],Ye}let He;return e[46]!==M.error||e[47]!==M.status||e[48]!==Se||e[49]!==f?(He=M.status==="error"?s.jsx(Zn,{message:M.error??f("contextPanel.tracker.loadFailed"),onRetry:()=>{Se()}}):s.jsx(Zn,{message:f("common.loading")}),e[46]=M.error,e[47]=M.status,e[48]=Se,e[49]=f,e[50]=He):He=e[50],He}let ve;e[51]!==v?(ve={source:"repository",reference:v},e[51]=v,e[52]=ve):ve=e[52];const Pe=ve,he=v.kind==="pull"?v:null;let Fe;e[53]!==he||e[54]!==ee?(Fe=he?ee(he):Mi,e[53]=he,e[54]=ee,e[55]=Fe):Fe=e[55];let _e;e[56]===Symbol.for("react.memo_cache_sentinel")?(_e={status:"idle"},e[56]=_e):_e=e[56];let We;e[57]!==ue?(We=()=>{ue()},e[57]=ue,e[58]=We):We=e[58];let Xe;e[59]!==O||e[60]!==Pe||e[61]!==De||e[62]!==We?(Xe=s.jsx(Ei,{item:Pe,project:null,context:O,onStartWorktree:Mw,onChanged:We,worktreeAvailable:!1,stack:De}),e[59]=O,e[60]=Pe,e[61]=De,e[62]=We,e[63]=Xe):Xe=e[63];let Ve;e[64]!==r||e[65]!==Ae?(Ve=He=>{Ae(He.url,r)},e[64]=r,e[65]=Ae,e[66]=Ve):Ve=e[66];let S;e[67]!==O||e[68]!==he?(S=he&&O?()=>V(!0):void 0,e[67]=O,e[68]=he,e[69]=S):S=e[69];const ne=O?we:void 0;let q;e[70]!==K.status||e[71]!==K.value||e[72]!==Pe||e[73]!==v||e[74]!==ue||e[75]!==Z?(q=v.state!=="merged"&&Z&&(v.kind!=="discussion"||eh(v,K.status==="ready"?K.value.discussion:void 0))?s.jsx(Mf,{item:Pe,context:Z,onChanged:()=>{ue()}}):void 0,e[70]=K.status,e[71]=K.value,e[72]=Pe,e[73]=v,e[74]=ue,e[75]=Z,e[76]=q):q=e[76];let ke;e[77]!==Y.attachComment||e[78]!==Y.attachComments?(ke={onAttach:Y.attachComment,onAttachAll:Y.attachComments},e[77]=Y.attachComment,e[78]=Y.attachComments,e[79]=ke):ke=e[79];let Ee;e[80]!==v||e[81]!==ue||e[82]!==Z?(Ee=Z?s.jsx(uc,{reference:v,context:Z,onChanged:ue}):void 0,e[80]=v,e[81]=ue,e[82]=Z,e[83]=Ee):Ee=e[83];let Ie;e[84]!==K||e[85]!==he||e[86]!==ue||e[87]!==Z?(Ie=he&&Z?s.jsx(fc,{pull:he,detail:K,context:Z,onChanged:ue}):void 0,e[84]=K,e[85]=he,e[86]=ue,e[87]=Z,e[88]=Ie):Ie=e[88];let Ne;e[89]!==K.status||e[90]!==K.value||e[91]!==v||e[92]!==ue||e[93]!==Z?(Ne=Z&&(K.status!=="ready"||K.value.discussion?.canComment!==!1)?s.jsx(cc,{reference:v,context:Z,onRefresh:ue}):void 0,e[89]=K.status,e[90]=K.value,e[91]=v,e[92]=ue,e[93]=Z,e[94]=Ne):Ne=e[94];let ze;e[95]!==m||e[96]!==O||e[97]!==r||e[98]!==i||e[99]!==o||e[100]!==he||e[101]!==b?(ze=he&&O?s.jsx(pc,{pull:he,project:{id:m??"",path:r},repository:b,context:O,projectOwnsDirectory:()=>!i,currentDirectory:o}):null,e[95]=m,e[96]=O,e[97]=r,e[98]=i,e[99]=o,e[100]=he,e[101]=b,e[102]=ze):ze=e[102];let Ue;e[103]!==K||e[104]!==Pe||e[105]!==fe||e[106]!==b||e[107]!==Fe||e[108]!==Xe||e[109]!==Ve||e[110]!==S||e[111]!==ne||e[112]!==q||e[113]!==ke||e[114]!==Ee||e[115]!==Ie||e[116]!==Ne||e[117]!==ze||e[118]!==Me?(Ue=s.jsx(Oi,{item:Pe,directory:b,pullStatus:Fe,trackerDetail:_e,repositoryDetail:K,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:Ow,now:fe,footer:Xe,onOpenStackLayer:Ve,onOpenChecks:S,onRefresh:ne,threadActions:Me,stateMenu:q,commentAttachments:ke,labelsControl:Ee,reviewersControl:Ie,reply:Ne,pullLinks:ze}),e[103]=K,e[104]=Pe,e[105]=fe,e[106]=b,e[107]=Fe,e[108]=Xe,e[109]=Ve,e[110]=S,e[111]=ne,e[112]=q,e[113]=ke,e[114]=Ee,e[115]=Ie,e[116]=Ne,e[117]=ze,e[118]=Me,e[119]=Ue):Ue=e[119];let Ge;e[120]!==Y.attachFailedChecks||e[121]!==ie||e[122]!==O||e[123]!==he?(Ge=he&&O?s.jsx(dc,{pull:he,context:O,open:ie,onOpenChange:V,onAttachFailed:Y.attachFailedChecks}):null,e[120]=Y.attachFailedChecks,e[121]=ie,e[122]=O,e[123]=he,e[124]=Ge):Ge=e[124];let Qe;return e[125]!==Ue||e[126]!==Ge?(Qe=s.jsxs(s.Fragment,{children:[Ue,Ge]}),e[125]=Ue,e[126]=Ge,e[127]=Qe):Qe=e[127],Qe},Pw=t=>{const e=$e.c(50),{url:n,provider:r,identifier:o,visible:i,onUnavailable:a,onShown:u}=t,{t:c}=at(),d=Zm(r);let f;e[0]!==o||e[1]!==r||e[2]!==d?(f=d==="ready"?{provider:r,id:o}:null,e[0]=o,e[1]=r,e[2]=d,e[3]=f):f=e[3];const{detail:p,refresh:m,followed:h}=Xm(f,!0);Li(i?h:Td);const b=_i(),g=Ai(),x=d!=="ready",w=p.status==="error",T=p.status==="ready";let k,E;e[4]!==x||e[5]!==w||e[6]!==a?(k=()=>{(x||w)&&a()},E=[x,w,a],e[4]=x,e[5]=w,e[6]=a,e[7]=k,e[8]=E):(k=e[7],E=e[8]),qt.useEffect(k,E);let F,_;if(e[9]!==u||e[10]!==T?(F=()=>{T&&u()},_=[u,T],e[9]=u,e[10]=T,e[11]=F,e[12]=_):(F=e[11],_=e[12]),qt.useEffect(F,_),x){let O;return e[13]!==n?(O=s.jsx(Ki,{url:n}),e[13]=n,e[14]=O):O=e[14],O}if(p.status==="error"){let O;e[15]!==p.error||e[16]!==c?(O=p.error||c("contextPanel.tracker.loadFailed"),e[15]=p.error,e[16]=c,e[17]=O):O=e[17];let Z;e[18]!==m?(Z=()=>{m()},e[18]=m,e[19]=Z):Z=e[19];let Q;return e[20]!==O||e[21]!==Z?(Q=s.jsx(Zn,{message:O,onRetry:Z}),e[20]=O,e[21]=Z,e[22]=Q):Q=e[22],Q}if(p.status!=="ready"){let O;e[23]!==c?(O=c("common.loading"),e[23]=c,e[24]=O):O=e[24];let Z;return e[25]!==O?(Z=s.jsx(Zn,{message:O}),e[25]=O,e[26]=Z):Z=e[26],Z}let A;e[27]!==p.value||e[28]!==r?(A={source:"tracker",provider:r,item:p.value},e[27]=p.value,e[28]=r,e[29]=A):A=e[29];const D=A;let y;e[30]===Symbol.for("react.memo_cache_sentinel")?(y={status:"idle"},e[30]=y):y=e[30];let N;e[31]!==m?(N=()=>{m()},e[31]=m,e[32]=N):N=e[32];let j;e[33]!==D||e[34]!==N?(j=s.jsx(Ei,{item:D,project:null,context:null,onStartWorktree:Lw,onChanged:N,worktreeAvailable:!1}),e[33]=D,e[34]=N,e[35]=j):j=e[35];let v;e[36]!==m?(v=()=>{m()},e[36]=m,e[37]=v):v=e[37];let M;e[38]!==p.value||e[39]!==v?(M=s.jsx(Of,{item:p.value,onChanged:v}),e[38]=p.value,e[39]=v,e[40]=M):M=e[40];let W;e[41]!==b?(W=O=>{b(O.url,null)},e[41]=b,e[42]=W):W=e[42];let G;return e[43]!==p||e[44]!==D||e[45]!==g||e[46]!==M||e[47]!==W||e[48]!==j?(G=s.jsx(Oi,{item:D,directory:null,pullStatus:Mi,trackerDetail:p,repositoryDetail:y,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:Fw,now:g,footer:j,trackerStateControl:M,onOpenTrackerItem:W}),e[43]=p,e[44]=D,e[45]=g,e[46]=M,e[47]=W,e[48]=j,e[49]=G):G=e[49],G};function Rw(t){return(t.status==="ready"||t.status==="unavailable")&&!t.refreshing}function Dw(t){return t.activeProjectId}function Aw(){}function _w(){}function Ow(){}function Mw(){}function Fw(){}function Lw(){}const Vr=new Map,$w=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},Bw=t=>{const e=t.time?.updated;return typeof e=="number"&&Number.isFinite(e)?e:0},zw=(t,e)=>{if(e.length===0)return Vr;const n=new Set(e),r=new Map,o=new Map;for(const i of t)for(const a of i.session){if(!n.has(a.id))continue;const u=a.title?.trim();if(!u)continue;const c=Bw(a),d=r.get(a.id);d!==void 0&&d>c||(r.set(a.id,c),o.set(a.id,u))}return o.size===0?Vr:o},ho=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,Ww=t=>t.kind==="record",Uw=t=>{const e=$e.c(5),{node:n}=t,r=n.tone==="string"?"text-foreground":"font-mono text-muted-foreground";let o;e[0]!==r?(o=Le("whitespace-pre-wrap break-words",r),e[0]=r,e[1]=o):o=e[1];let i;return e[2]!==n.text||e[3]!==o?(i=s.jsx("span",{dir:"auto",className:o,children:n.text}),e[2]=n.text,e[3]=o,e[4]=i):i=e[4],i},Vw=t=>{const e=$e.c(4),{node:n}=t;let r;e[0]!==n.entries?(r=n.entries.map(Hw),e[0]=n.entries,e[1]=r):r=e[1];let o;return e[2]!==r?(o=s.jsx("dl",{className:"flex flex-col gap-1.5",children:r}),e[2]=r,e[3]=o):o=e[3],o},go=t=>{const e=$e.c(13),{node:n}=t;if(n.kind==="scalar"){let i;return e[0]!==n?(i=s.jsx(Uw,{node:n}),e[0]=n,e[1]=i):i=e[1],i}if(n.kind==="record"){let i;return e[2]!==n?(i=s.jsx(Vw,{node:n}),e[2]=n,e[3]=i):i=e[3],i}if(n.items.length===0){let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("span",{className:"font-mono text-muted-foreground",children:"[]"}),e[4]=i):i=e[4],i}if(n.items.every(Ww)){let i;e[5]!==n.items?(i=n.items.map(qw),e[5]=n.items,e[6]=i):i=e[6];let a;return e[7]!==i?(a=s.jsx("div",{className:"flex flex-col gap-1.5",children:i}),e[7]=i,e[8]=a):a=e[8],a}let r;e[9]!==n.items?(r=n.items.map(Kw),e[9]=n.items,e[10]=r):r=e[10];let o;return e[11]!==r?(o=s.jsx("ul",{className:"flex list-disc flex-col gap-0.5 ps-4",children:r}),e[11]=r,e[12]=o):o=e[12],o},Nd=t=>{const e=$e.c(16),{answer:n}=t,{t:r}=at(),[o,i]=l.useState(!1);if(n.kind==="text"){let p;return e[0]!==n.text?(p=s.jsx(ah,{content:n.text,singleTilde:!1,className:"typography-markdown-body",enableFileReferences:!1}),e[0]=n.text,e[1]=p):p=e[1],p}let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>i(Gw),e[2]=a):a=e[2];let u;e[3]!==o||e[4]!==r?(u=r(o?"workflows.panel.answer.formatted":"workflows.panel.answer.raw"),e[3]=o,e[4]=r,e[5]=u):u=e[5];let c;e[6]!==o||e[7]!==u?(c=s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{type:"button",onClick:a,"aria-pressed":o,className:"typography-micro text-muted-foreground hover:text-foreground",children:u})}),e[6]=o,e[7]=u,e[8]=c):c=e[8];let d;e[9]!==n.tree||e[10]!==n.value||e[11]!==o?(d=o?s.jsx("pre",{dir:"ltr",className:"overflow-x-auto whitespace-pre-wrap break-words font-mono typography-meta text-foreground",children:JSON.stringify(n.value,null,2)}):s.jsx(go,{node:n.tree}),e[9]=n.tree,e[10]=n.value,e[11]=o,e[12]=d):d=e[12];let f;return e[13]!==c||e[14]!==d?(f=s.jsxs("div",{className:"flex flex-col gap-2",children:[c,d]}),e[13]=c,e[14]=d,e[15]=f):f=e[15],f};function Hw(t){const[e,n]=t,r=n.kind==="scalar"&&n.text.length<=60&&!n.text.includes(`
5
- `);return s.jsxs("div",{className:Le("min-w-0",r?"flex items-baseline gap-2":"flex flex-col gap-0.5"),children:[s.jsx("dt",{className:"shrink-0 typography-micro text-muted-foreground",dir:"ltr",children:e}),s.jsx("dd",{className:"min-w-0 typography-meta",children:s.jsx(go,{node:n})})]},e)}function qw(t,e){return s.jsx("div",{className:"oc-tile-inset rounded-lg px-3 py-2",children:s.jsx(go,{node:t})},e)}function Kw(t,e){return s.jsx("li",{className:"typography-meta",children:s.jsx(go,{node:t})},e)}function Gw(t){return!t}const Ed=t=>t.slice(t.indexOf("/")+1),Gi=t=>{const e=$e.c(7),{start:n,end:r,className:o}=t,i=mh(n!==void 0&&r===void 0);if(n===void 0)return null;let a;e[0]!==o?(a=Le("shrink-0 whitespace-nowrap tabular-nums",o),e[0]=o,e[1]=a):a=e[1];const u=(r??i)-n;let c;e[2]!==u?(c=hh(u),e[2]=u,e[3]=c):c=e[3];let d;return e[4]!==a||e[5]!==c?(d=s.jsx("span",{className:a,dir:"auto",children:c}),e[4]=a,e[5]=c,e[6]=d):d=e[6],d},Zw=t=>{const e=t.flatMap(o=>o.startedAt===void 0||o.replayed?[]:[o.startedAt]);if(e.length===0)return{start:void 0,end:void 0};const n=t.some(o=>o.state==="running"||o.state==="queued"),r=t.flatMap(o=>o.endedAt===void 0?[]:[o.endedAt]);return{start:Math.min(...e),end:n?void 0:Math.max(...r,...e)}},Xw=t=>{const e=$e.c(18),{run:n,groups:r}=t,{t:o}=at();let i,a,u,c,d,f;if(e[0]!==r||e[1]!==n||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{const m=r.filter(sy);if(m.length===0){f=null;break e}i=hs,a="overlay-scrollbar-wrapper--no-gutter",u=!1,c="flex gap-1.5 pb-1";let h;e[9]!==n||e[10]!==o?(h=b=>{const g=b.agents.length,x=Zw(b.agents),w=n.state==="running"&&n.currentPhase===b.title;return s.jsxs("div",{className:"oc-tile min-w-[7.5rem] flex-1 rounded-lg px-2.5 py-2",children:[s.jsx("div",{className:Le("truncate typography-meta",w?"font-semibold text-foreground":"text-foreground"),dir:"auto",children:b.title}),s.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 typography-micro text-muted-foreground",children:[g>0?s.jsx("span",{className:"tabular-nums",dir:"auto",children:`${b.done}/${g}`}):s.jsx("span",{children:o("workflows.panel.phase.waiting")}),g>0?s.jsx(Gi,{start:x.start,end:x.end,className:"ms-auto"}):null]}),s.jsx("div",{className:"oc-tile-inset mt-1.5 h-1 overflow-hidden rounded-full",children:g>0?s.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.round(b.done/g*100)}%`,background:b.failed>0?"var(--status-warning)":"var(--status-success)"}}):null})]},b.title)},e[9]=n,e[10]=o,e[11]=h):h=e[11],d=m.map(h)}e[0]=r,e[1]=n,e[2]=o,e[3]=i,e[4]=a,e[5]=u,e[6]=c,e[7]=d,e[8]=f}else i=e[3],a=e[4],u=e[5],c=e[6],d=e[7],f=e[8];if(f!==Symbol.for("react.early_return_sentinel"))return f;let p;return e[12]!==i||e[13]!==a||e[14]!==u||e[15]!==c||e[16]!==d?(p=s.jsx(i,{outerClassName:a,fillContainer:u,className:c,children:d}),e[12]=i,e[13]=a,e[14]=u,e[15]=c,e[16]=d,e[17]=p):p=e[17],p},Yw=t=>{const e=$e.c(30),{run:n,agent:r,onOpenSession:o}=t,{t:i}=at(),[a,u]=l.useState(null),[c,d]=l.useState(!1),[f,p]=l.useState(!1);let m;e[0]!==r.key||e[1]!==n.id?(m=()=>{let E=!0;return d(!1),gh(n.id,r.key).then(F=>{E&&u(F)}).catch(()=>{E&&d(!0)}),()=>{E=!1}},e[0]=r.key,e[1]=n.id,e[2]=m):m=e[2];let h;e[3]!==r.key||e[4]!==r.state||e[5]!==n.id?(h=[r.key,r.state,n.id],e[3]=r.key,e[4]=r.state,e[5]=n.id,e[6]=h):h=e[6],l.useEffect(m,h);let b;e[7]!==r.error||e[8]!==r.state?(b=r.error?s.jsx("p",{className:"typography-meta",style:{color:r.state==="failed"?"var(--status-error)":void 0},children:r.error}):null,e[7]=r.error,e[8]=r.state,e[9]=b):b=e[9];let g;e[10]!==c||e[11]!==i?(g=c?s.jsx("p",{className:"typography-meta text-muted-foreground",children:i("workflows.panel.agent.loadFailed")}):null,e[10]=c,e[11]=i,e[12]=g):g=e[12];let x;e[13]!==a||e[14]!==c||e[15]!==i?(x=!a&&!c?s.jsxs("p",{className:"typography-meta text-muted-foreground",children:[i("workflows.panel.agent.loading"),s.jsx(zi,{})]}):null,e[13]=a,e[14]=c,e[15]=i,e[16]=x):x=e[16];let w;e[17]!==a||e[18]!==f||e[19]!==i?(w=a?s.jsxs(s.Fragment,{children:[s.jsxs("section",{children:[s.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:i("workflows.panel.agent.answer")}),s.jsx("div",{className:"mt-1",children:a.result===void 0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:i("workflows.panel.agent.noAnswer")}):s.jsx(Nd,{answer:a.result})})]}),s.jsxs("section",{children:[s.jsxs("button",{type:"button",onClick:()=>p(ny),"aria-expanded":f,className:"flex items-center gap-1 typography-micro font-medium text-muted-foreground hover:text-foreground",children:[s.jsx(se,{name:"arrow-right-s",className:Le("size-3.5 transition-transform",f&&"rotate-90 rtl:-rotate-90")}),i("workflows.panel.agent.prompt")]}),f?s.jsx(hs,{as:"pre",dir:"auto",outerClassName:"mt-1 max-h-72",className:"whitespace-pre-wrap break-words font-mono typography-micro text-foreground",disableHorizontal:!0,children:a.prompt}):null]})]}):null,e[17]=a,e[18]=f,e[19]=i,e[20]=w):w=e[20];let T;e[21]!==o||e[22]!==i?(T=o?s.jsx("div",{children:s.jsxs(dt,{type:"button",size:"xs",variant:"ghost",onClick:o,children:[s.jsx(se,{name:"chat-4",className:"size-3.5"}),i("workflows.panel.agent.openSession")]})}):null,e[21]=o,e[22]=i,e[23]=T):T=e[23];let k;return e[24]!==b||e[25]!==g||e[26]!==x||e[27]!==w||e[28]!==T?(k=s.jsxs("div",{className:"oc-tile mb-1.5 ms-5 flex flex-col gap-2 rounded-lg px-3 py-2.5",children:[b,g,x,w,T]}),e[24]=b,e[25]=g,e[26]=x,e[27]=w,e[28]=T,e[29]=k):k=e[29],k},Jw=t=>{const e=$e.c(57),{run:n,agent:r,showModel:o,columns:i,open:a,onToggle:u,onOpenSession:c}=t,{t:d}=at();let f,p,m,h,b,g,x,w,T,k,E;if(e[0]!==r||e[1]!==i.tokens||e[2]!==u||e[3]!==a||e[4]!==o||e[5]!==d){const y=fh(r.state),N=ph(r);f="button",h=u,b=a,g=r.label,x="flex h-7 w-full min-w-0 items-center gap-2 rounded-md text-start typography-meta text-foreground/80 hover:text-foreground";const j=y.icon,v=y.color?{color:y.color}:void 0,M=d(y.labelKey);e[17]!==y||e[18]!==v||e[19]!==M?(w=s.jsx(se,{name:j,className:"size-3.5 shrink-0",style:v,"aria-label":M}),e[17]=y,e[18]=v,e[19]=M,e[20]=w):w=e[20],e[21]!==r.label?(T=s.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:r.label}),e[21]=r.label,e[22]=T):T=e[22],e[23]!==r.replayed||e[24]!==d?(k=r.replayed?s.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:d("chat.workflow.agent.reused")}):null,e[23]=r.replayed,e[24]=d,e[25]=k):k=e[25],e[26]!==r.model||e[27]!==o?(E=o&&r.model?s.jsx("span",{className:"oc-tile-inset max-w-[9rem] shrink-0 truncate rounded-full px-1.5 typography-micro text-muted-foreground",title:r.model,dir:"ltr",children:Ed(r.model)}):null,e[26]=r.model,e[27]=o,e[28]=E):E=e[28];const W=r.replayed?void 0:r.startedAt;e[29]!==r.endedAt||e[30]!==W?(p=s.jsx(Gi,{start:W,end:r.endedAt,className:"min-w-12 text-end typography-micro text-muted-foreground"}),e[29]=r.endedAt,e[30]=W,e[31]=p):p=e[31],m=i.tokens?s.jsx("span",{className:"min-w-12 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"auto",children:N===null||r.replayed?"":$i(N)}):null,e[0]=r,e[1]=i.tokens,e[2]=u,e[3]=a,e[4]=o,e[5]=d,e[6]=f,e[7]=p,e[8]=m,e[9]=h,e[10]=b,e[11]=g,e[12]=x,e[13]=w,e[14]=T,e[15]=k,e[16]=E}else f=e[6],p=e[7],m=e[8],h=e[9],b=e[10],g=e[11],x=e[12],w=e[13],T=e[14],k=e[15],E=e[16];let F;e[32]!==r.replayed||e[33]!==r.usage||e[34]!==i.cost?(F=i.cost?s.jsx("span",{className:"min-w-14 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"ltr",children:r.usage&&!r.replayed&&r.usage.cost>0?Bi(r.usage.cost):""}):null,e[32]=r.replayed,e[33]=r.usage,e[34]=i.cost,e[35]=F):F=e[35];let _;e[36]!==f||e[37]!==p||e[38]!==m||e[39]!==F||e[40]!==h||e[41]!==b||e[42]!==g||e[43]!==x||e[44]!==w||e[45]!==T||e[46]!==k||e[47]!==E?(_=s.jsxs("button",{type:f,onClick:h,"aria-expanded":b,title:g,className:x,children:[w,T,k,E,p,m,F]}),e[36]=f,e[37]=p,e[38]=m,e[39]=F,e[40]=h,e[41]=b,e[42]=g,e[43]=x,e[44]=w,e[45]=T,e[46]=k,e[47]=E,e[48]=_):_=e[48];let A;e[49]!==r||e[50]!==c||e[51]!==a||e[52]!==n?(A=a?s.jsx(Yw,{run:n,agent:r,onOpenSession:c}):null,e[49]=r,e[50]=c,e[51]=a,e[52]=n,e[53]=A):A=e[53];let D;return e[54]!==_||e[55]!==A?(D=s.jsxs(s.Fragment,{children:[_,A]}),e[54]=_,e[55]=A,e[56]=D):D=e[56],D},Qw=(t,e)=>{const n=uh(t);if(n.measured===0)return null;const r=[];return e.tokens&&r.push($i(n.tokens)),e.cost&&n.cost>0&&r.push(Bi(n.cost)),r.length>0?r.join(" · "):null},ey=t=>{const e=new Set(t.map(r=>r.model??null)),[n]=e;return e.size===1&&n?Ed(n):null},ty=t=>{const e=$e.c(51),{run:n,directory:r}=t,{t:o}=at();let i;e[0]!==n?(i=lh(n),e[0]=n,e[1]=i):i=e[1];const a=i,u=ch(r),[c,d]=l.useState(ry),[f,p]=l.useState(oy);let m,h,b,g,x,w;if(e[2]!==a||e[3]!==c||e[4]!==u||e[5]!==n||e[6]!==o||e[7]!==f){const E=dh(n),F=E.measured>0,_=E.cost>0;let A,D,y;if(e[14]!==a||e[15]!==c||e[16]!==u||e[17]!==n||e[18]!==o||e[19]!==F||e[20]!==_||e[21]!==f){const N={tokens:F,cost:_},j=n.agents.filter(iy).length,v=ay;x="flex h-full min-h-0 flex-col";let M;e[28]!==a||e[29]!==n?(M=s.jsx(Xw,{run:n,groups:a}),e[28]=a,e[29]=n,e[30]=M):M=e[30];const W=a.map(G=>{if(G.agents.length===0)return null;const O=G.title??"",Z=G.done+G.failed===G.agents.length,B=(n.state==="running"&&Z)===f.has(O),oe=ey(G.agents),H=Qw(G.agents,N);return s.jsxs("section",{className:"mt-3",children:[s.jsxs("button",{type:"button",onClick:()=>v(p,O),"aria-expanded":B,className:"flex h-7 w-full min-w-0 items-center gap-1.5 text-start typography-micro font-medium text-muted-foreground hover:text-foreground",children:[s.jsx(se,{name:"arrow-right-s",className:Le("size-3.5 shrink-0 transition-transform",B&&"rotate-90 rtl:-rotate-90")}),s.jsx("span",{className:"min-w-0 truncate",dir:"auto",children:G.title??o("chat.workflow.phase.unphased")}),oe?s.jsx("span",{className:"min-w-0 truncate font-normal",dir:"ltr",children:`· ${oe}`}):null,H?s.jsx("span",{className:"ms-auto shrink-0 tabular-nums font-normal",dir:"ltr",children:H}):null,s.jsx("span",{className:Le("shrink-0 tabular-nums font-normal",!H&&"ms-auto"),dir:"auto",children:H?`· ${G.done}/${G.agents.length}`:`${G.done}/${G.agents.length}`})]}),B?G.agents.map(P=>{const te=P.sessionId;return s.jsx(Jw,{run:n,agent:P,showModel:oe===null,columns:N,open:c.has(P.key),onToggle:()=>v(d,P.key),onOpenSession:te?()=>u(te,P.label):null},P.key)}):null]},O)});e[31]!==M||e[32]!==W?(w=s.jsxs(hs,{outerClassName:"min-h-0 flex-1",className:"px-3 py-3",disableHorizontal:!0,children:[M,W]}),e[31]=M,e[32]=W,e[33]=w):w=e[33],m="flex shrink-0 flex-wrap items-center gap-x-1.5 border-t border-edge px-3 py-2 typography-micro text-muted-foreground",A="tabular-nums",D="auto",y=o("workflows.panel.summary.agents",{done:j,total:n.agents.length}),e[14]=a,e[15]=c,e[16]=u,e[17]=n,e[18]=o,e[19]=F,e[20]=_,e[21]=f,e[22]=A,e[23]=D,e[24]=y,e[25]=m,e[26]=x,e[27]=w}else A=e[22],D=e[23],y=e[24],m=e[25],x=e[26],w=e[27];e[34]!==A||e[35]!==D||e[36]!==y?(h=s.jsx("span",{className:A,dir:D,children:y}),e[34]=A,e[35]=D,e[36]=y,e[37]=h):h=e[37],e[38]!==n.endedAt||e[39]!==n.startedAt||e[40]!==n.state?(b=n.startedAt!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx(Gi,{start:n.startedAt,end:n.state==="running"?void 0:n.endedAt??n.startedAt})]}):null,e[38]=n.endedAt,e[39]=n.startedAt,e[40]=n.state,e[41]=b):b=e[41],g=E.measured>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{className:"tabular-nums",dir:"auto",children:o("workflows.panel.summary.tokens",{tokens:$i(E.tokens)})}),E.cost>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{className:"tabular-nums",dir:"ltr",children:Bi(E.cost)})]}):null]}):null,e[2]=a,e[3]=c,e[4]=u,e[5]=n,e[6]=o,e[7]=f,e[8]=m,e[9]=h,e[10]=b,e[11]=g,e[12]=x,e[13]=w}else m=e[8],h=e[9],b=e[10],g=e[11],x=e[12],w=e[13];let T;e[42]!==m||e[43]!==h||e[44]!==b||e[45]!==g?(T=s.jsxs("div",{className:m,children:[h,b,g]}),e[42]=m,e[43]=h,e[44]=b,e[45]=g,e[46]=T):T=e[46];let k;return e[47]!==x||e[48]!==w||e[49]!==T?(k=s.jsxs("div",{className:x,children:[w,T]}),e[47]=x,e[48]=w,e[49]=T,e[50]=k):k=e[50],k};function sy(t){return t.title!==null}function ny(t){return!t}function ry(){return new Set}function oy(){return new Set}function iy(t){return t.state==="completed"}function ay(t,e){return t(n=>{const r=new Set(n);return r.has(e)?r.delete(e):r.add(e),r})}const ly={steps:["data-workflows-header-compact","data-workflows-header-tight","data-workflows-header-narrow"]},cy=[{id:"agents",icon:"flow-chart",labelKey:"workflows.panel.view.agents"},{id:"log",icon:"file-list-2",labelKey:"workflows.panel.view.log"},{id:"result",icon:"checkbox-circle",labelKey:"workflows.panel.view.result"},{id:"script",icon:"code-sslash",labelKey:"workflows.panel.view.script"}],dy=1500,uy=(t,e)=>{const n=$e.c(11),[r,o]=l.useState(null),[i,a]=l.useState(null),u=l.useRef(null),c=e!=="agents",d=e==="log"&&t.state==="running"?t.logs.at(-1)?.at??0:0;let f;n[0]!==t.id||n[1]!==c?(f=()=>{if(!c)return;let g=!0;const x=u.current?.runId===t.id?u.current.at:0,w=Math.max(0,x+dy-Date.now()),T=setTimeout(()=>{u.current={runId:t.id,at:Date.now()},Th(t.id).then(k=>{g&&(o(k),a(null))}).catch(()=>{g&&a(t.id)})},w);return()=>{g=!1,clearTimeout(T)}},n[0]=t.id,n[1]=c,n[2]=f):f=n[2];let p;n[3]!==d||n[4]!==t.id||n[5]!==t.state||n[6]!==c?(p=[d,t.id,t.state,c],n[3]=d,n[4]=t.id,n[5]=t.state,n[6]=c,n[7]=p):p=n[7],l.useEffect(f,p);const m=r?.runId===t.id?r:null,h=i===t.id;let b;return n[8]!==m||n[9]!==h?(b={detail:m,failed:h},n[8]=m,n[9]=h,n[10]=b):b=n[10],b},fy=t=>new Intl.DateTimeFormat(Bc(),{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(t),py=t=>{const e=$e.c(8),{run:n,detail:r}=t,{t:o}=at(),i=r?.logs??n.logs;if(i.length===0){let c;e[0]!==o?(c=o("workflows.panel.log.empty"),e[0]=o,e[1]=c):c=e[1];let d;return e[2]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[2]=c,e[3]=d):d=e[3],d}let a;e[4]!==i?(a=i.map(ky),e[4]=i,e[5]=a):a=e[5];let u;return e[6]!==a?(u=s.jsx("ol",{className:"flex flex-col gap-1 px-3 py-3",children:a}),e[6]=a,e[7]=u):u=e[7],u},my=t=>{const e=$e.c(24),{run:n,detail:r,failed:o}=t,{t:i}=at();if(n.error&&(n.state==="failed"||n.state==="stopped")){const c=n.state==="failed"?"var(--status-error)":void 0;let d;e[0]!==c?(d={color:c},e[0]=c,e[1]=d):d=e[1];let f;return e[2]!==n.error||e[3]!==d?(f=s.jsx("p",{className:"px-4 py-6 typography-meta",style:d,children:n.error}),e[2]=n.error,e[3]=d,e[4]=f):f=e[4],f}if(n.state==="awaiting-approval"||n.state==="running"||n.state==="declined"){let c;e[5]!==i?(c=i("workflows.panel.result.pending"),e[5]=i,e[6]=c):c=e[6];let d;return e[7]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[7]=c,e[8]=d):d=e[8],d}if(o&&!r){let c;e[9]!==i?(c=i("workflows.panel.detail.loadFailed"),e[9]=i,e[10]=c):c=e[10];let d;return e[11]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[11]=c,e[12]=d):d=e[12],d}if(!r){let c;e[13]!==i?(c=i("workflows.panel.agent.loading"),e[13]=i,e[14]=c):c=e[14];let d;e[15]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(zi,{}),e[15]=d):d=e[15];let f;return e[16]!==c?(f=s.jsxs("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:[c,d]}),e[16]=c,e[17]=f):f=e[17],f}const{result:a}=r;if(!a||a.kind==="json"&&a.value===null){let c;e[18]!==i?(c=i("workflows.panel.result.none"),e[18]=i,e[19]=c):c=e[19];let d;return e[20]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[20]=c,e[21]=d):d=e[21],d}let u;return e[22]!==a?(u=s.jsx("div",{className:"px-4 py-3",children:s.jsx(Nd,{answer:a})}),e[22]=a,e[23]=u):u=e[23],u},hy=t=>{const e=$e.c(16),{detail:n,failed:r}=t,{t:o}=at();if(!n){let p;e[0]!==r||e[1]!==o?(p=r?o("workflows.panel.detail.loadFailed"):s.jsxs(s.Fragment,{children:[o("workflows.panel.agent.loading"),s.jsx(zi,{})]}),e[0]=r,e[1]=o,e[2]=p):p=e[2];let m;return e[3]!==p?(m=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:p}),e[3]=p,e[4]=m):m=e[4],m}const i=n.args;let a;e[5]!==i?(a=i!=null&&JSON.stringify(i)!=="{}",e[5]=i,e[6]=a):a=e[6];const u=a;let c;e[7]!==i||e[8]!==u||e[9]!==o?(c=u?s.jsxs("section",{children:[s.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:o("workflows.panel.script.args")}),s.jsx(hs,{as:"pre",dir:"ltr",outerClassName:"overlay-scrollbar-wrapper--no-gutter oc-tile mt-1 rounded-lg",fillContainer:!1,className:"px-3 py-2 font-mono typography-micro text-foreground",children:JSON.stringify(i,null,2)})]}):null,e[7]=i,e[8]=u,e[9]=o,e[10]=c):c=e[10];let d;e[11]!==n.script?(d=s.jsx(hs,{as:"pre",dir:"ltr",outerClassName:"overlay-scrollbar-wrapper--no-gutter oc-tile rounded-lg",fillContainer:!1,className:"px-3 py-2 font-mono typography-micro leading-relaxed text-foreground",children:n.script}),e[11]=n.script,e[12]=d):d=e[12];let f;return e[13]!==c||e[14]!==d?(f=s.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3",children:[c,d]}),e[13]=c,e[14]=d,e[15]=f):f=e[15],f},gy=t=>{const e=$e.c(63),{run:n}=t,{t:r}=at(),{pending:o,act:i}=Ch(),a=o===n.id;if(n.state==="awaiting-approval"){let u;e[0]!==i||e[1]!==n.id?(u=()=>i(n.id,"approve"),e[0]=i,e[1]=n.id,e[2]=u):u=e[2];let c;e[3]!==r?(c=r("chat.workflow.action.run"),e[3]=r,e[4]=c):c=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(se,{name:"play",className:"size-3.5"}),e[5]=d):d=e[5];let f;e[6]!==r?(f=r("chat.workflow.action.run"),e[6]=r,e[7]=f):f=e[7];let p;e[8]!==f?(p=s.jsx("span",{className:"workflows-header__action-label",children:f}),e[8]=f,e[9]=p):p=e[9];let m;e[10]!==a||e[11]!==u||e[12]!==c||e[13]!==p?(m=s.jsxs(dt,{type:"button",size:"sm",disabled:a,onClick:u,"aria-label":c,children:[d,p]}),e[10]=a,e[11]=u,e[12]=c,e[13]=p,e[14]=m):m=e[14];let h;e[15]!==i||e[16]!==n.id?(h=()=>i(n.id,"decline"),e[15]=i,e[16]=n.id,e[17]=h):h=e[17];let b;e[18]!==r?(b=r("chat.workflow.action.decline"),e[18]=r,e[19]=b):b=e[19];let g;e[20]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(se,{name:"close",className:"size-3.5"}),e[20]=g):g=e[20];let x;e[21]!==r?(x=r("chat.workflow.action.decline"),e[21]=r,e[22]=x):x=e[22];let w;e[23]!==x?(w=s.jsx("span",{className:"workflows-header__action-label",children:x}),e[23]=x,e[24]=w):w=e[24];let T;e[25]!==a||e[26]!==w||e[27]!==h||e[28]!==b?(T=s.jsxs(dt,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:h,"aria-label":b,children:[g,w]}),e[25]=a,e[26]=w,e[27]=h,e[28]=b,e[29]=T):T=e[29];let k;return e[30]!==T||e[31]!==m?(k=s.jsxs(s.Fragment,{children:[m,T]}),e[30]=T,e[31]=m,e[32]=k):k=e[32],k}if(n.state==="running"){let u;e[33]!==i||e[34]!==n.id?(u=()=>i(n.id,"stop"),e[33]=i,e[34]=n.id,e[35]=u):u=e[35];let c;e[36]!==r?(c=r("chat.workflow.action.stop"),e[36]=r,e[37]=c):c=e[37];let d;e[38]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(se,{name:"stop",className:"size-3.5"}),e[38]=d):d=e[38];let f;e[39]!==r?(f=r("chat.workflow.action.stop"),e[39]=r,e[40]=f):f=e[40];let p;e[41]!==f?(p=s.jsx("span",{className:"workflows-header__action-label",children:f}),e[41]=f,e[42]=p):p=e[42];let m;return e[43]!==a||e[44]!==u||e[45]!==c||e[46]!==p?(m=s.jsxs(dt,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:u,"aria-label":c,children:[d,p]}),e[43]=a,e[44]=u,e[45]=c,e[46]=p,e[47]=m):m=e[47],m}if(n.state==="failed"||n.state==="stopped"){let u;e[48]!==i||e[49]!==n.id?(u=()=>i(n.id,"resume"),e[48]=i,e[49]=n.id,e[50]=u):u=e[50];let c;e[51]!==r?(c=r("chat.workflow.action.resume"),e[51]=r,e[52]=c):c=e[52];let d;e[53]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(se,{name:"restart",className:"size-3.5"}),e[53]=d):d=e[53];let f;e[54]!==r?(f=r("chat.workflow.action.resume"),e[54]=r,e[55]=f):f=e[55];let p;e[56]!==f?(p=s.jsx("span",{className:"workflows-header__action-label",children:f}),e[56]=f,e[57]=p):p=e[57];let m;return e[58]!==a||e[59]!==u||e[60]!==c||e[61]!==p?(m=s.jsxs(dt,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:u,"aria-label":c,children:[d,p]}),e[58]=a,e[59]=u,e[60]=c,e[61]=p,e[62]=m):m=e[62],m}return null},by=()=>{const t=$e.c(2),e=ps(jy);let n;return t[0]!==e?(n={get:r=>e.get(r)?.title},t[0]=e,t[1]=n):n=t[1],n},sl=t=>{const e=$e.c(31),{run:n,selected:r,caption:o,onSelect:i}=t,{t:a}=at();let u,c,d,f,p,m,h;if(e[0]!==i||e[1]!==n.state||e[2]!==a){const E=$c(n.state);c=Gt,h=i,u=se,d=E.icon,f="size-3.5 shrink-0",p=E.color?{color:E.color}:void 0,m=a(E.labelKey),e[0]=i,e[1]=n.state,e[2]=a,e[3]=u,e[4]=c,e[5]=d,e[6]=f,e[7]=p,e[8]=m,e[9]=h}else u=e[3],c=e[4],d=e[5],f=e[6],p=e[7],m=e[8],h=e[9];let b;e[10]!==u||e[11]!==d||e[12]!==f||e[13]!==p||e[14]!==m?(b=s.jsx(u,{name:d,className:f,style:p,"aria-label":m}),e[10]=u,e[11]=d,e[12]=f,e[13]=p,e[14]=m,e[15]=b):b=e[15];let g;e[16]!==n.name?(g=s.jsx("span",{className:"truncate",dir:"auto",children:n.name}),e[16]=n.name,e[17]=g):g=e[17];let x;e[18]!==o?(x=o?s.jsx("span",{className:"truncate typography-micro text-muted-foreground",dir:"auto",children:o}):null,e[18]=o,e[19]=x):x=e[19];let w;e[20]!==g||e[21]!==x?(w=s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[g,x]}),e[20]=g,e[21]=x,e[22]=w):w=e[22];let T;e[23]!==r?(T=r?s.jsx(se,{name:"check",className:"size-3.5 shrink-0"}):null,e[23]=r,e[24]=T):T=e[24];let k;return e[25]!==c||e[26]!==T||e[27]!==h||e[28]!==b||e[29]!==w?(k=s.jsxs(c,{onSelect:h,children:[b,w,T]}),e[25]=c,e[26]=T,e[27]=h,e[28]=b,e[29]=w,e[30]=k):k=e[30],k},xy=t=>{const e=$e.c(56),{runs:n,selected:r,sessionId:o,sessionTitles:i,saved:a,onSelect:u,onRunSaved:c,onDelete:d}=t,{t:f}=at();let p;e[0]!==r.state?(p=$c(r.state),e[0]=r.state,e[1]=p):p=e[1];const m=p;let h,b,g,x,w,T,k;if(e[2]!==m.color||e[3]!==m.icon||e[4]!==u||e[5]!==n||e[6]!==r.id||e[7]!==r.name||e[8]!==o||e[9]!==i||e[10]!==f){const D=n.slice().reverse();let y;e[18]!==o?(y=B=>B.parentSessionId===o,e[18]=o,e[19]=y):y=e[19];const N=D.filter(y);let j;e[20]!==o?(j=B=>B.parentSessionId!==o,e[20]=o,e[21]=j):j=e[21];const v=D.filter(j);b=pn;let M;e[22]!==f?(M=f("workflows.panel.runPicker"),e[22]=f,e[23]=M):M=e[23];let W;e[24]===Symbol.for("react.memo_cache_sentinel")?(W=Le(jh(),"max-w-[14rem] shrink-0"),e[24]=W):W=e[24];let G;e[25]!==m.color?(G=m.color?{color:m.color}:void 0,e[25]=m.color,e[26]=G):G=e[26];let O;e[27]!==m.icon||e[28]!==G?(O=s.jsx(se,{name:m.icon,className:"size-3.5",style:G}),e[27]=m.icon,e[28]=G,e[29]=O):O=e[29];let Z;e[30]!==r.name?(Z=s.jsx("span",{className:"workflows-header__run-name min-w-0 truncate",dir:"auto",children:r.name}),e[30]=r.name,e[31]=Z):Z=e[31];let Q;e[32]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(se,{name:"arrow-down-s",className:"size-4"}),e[32]=Q):Q=e[32],e[33]!==O||e[34]!==Z||e[35]!==M?(k=s.jsx(mn,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":M,className:W,children:[O,Z,Q]})}),e[33]=O,e[34]=Z,e[35]=M,e[36]=k):k=e[36],h=hn,g="start",x="max-h-[min(var(--available-height),28rem)] w-[18rem] max-w-[calc(100vw-2rem)] overflow-y-auto",w=N.length>0?s.jsxs(s.Fragment,{children:[s.jsx(Er,{children:f("workflows.panel.picker.thisSession")}),N.map(B=>s.jsx(sl,{run:B,selected:B.id===r.id,onSelect:()=>u(B.id)},B.id))]}):null,T=v.length>0?s.jsxs(s.Fragment,{children:[N.length>0?s.jsx(un,{}):null,s.jsx(Er,{children:f("workflows.panel.picker.otherSessions")}),v.map(B=>s.jsx(sl,{run:B,selected:B.id===r.id,caption:i.get(B.parentSessionId)||f("workflows.panel.picker.untitledSession"),onSelect:()=>u(B.id)},B.id))]}):null,e[2]=m.color,e[3]=m.icon,e[4]=u,e[5]=n,e[6]=r.id,e[7]=r.name,e[8]=o,e[9]=i,e[10]=f,e[11]=h,e[12]=b,e[13]=g,e[14]=x,e[15]=w,e[16]=T,e[17]=k}else h=e[11],b=e[12],g=e[13],x=e[14],w=e[15],T=e[16],k=e[17];let E;e[37]!==c||e[38]!==a||e[39]!==f?(E=a.length>0?s.jsxs(s.Fragment,{children:[s.jsx(un,{}),s.jsx(Er,{children:f("workflows.panel.picker.saved")}),a.map(D=>s.jsxs(Gt,{disabled:!!D.error,onSelect:()=>c(D.name),title:D.error??D.description,children:[s.jsx(se,{name:"play",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:D.name})]},D.name))]}):null,e[37]=c,e[38]=a,e[39]=f,e[40]=E):E=e[40];let F;e[41]!==d||e[42]!==f?(F=d?s.jsxs(s.Fragment,{children:[s.jsx(un,{}),s.jsxs(Gt,{variant:"destructive",onSelect:d,children:[s.jsx(se,{name:"delete-bin",className:"size-3.5 shrink-0"}),f("workflows.panel.delete.action")]})]}):null,e[41]=d,e[42]=f,e[43]=F):F=e[43];let _;e[44]!==h||e[45]!==g||e[46]!==x||e[47]!==w||e[48]!==T||e[49]!==E||e[50]!==F?(_=s.jsxs(h,{align:g,className:x,children:[w,T,E,F]}),e[44]=h,e[45]=g,e[46]=x,e[47]=w,e[48]=T,e[49]=E,e[50]=F,e[51]=_):_=e[51];let A;return e[52]!==b||e[53]!==k||e[54]!==_?(A=s.jsxs(b,{children:[k,_]}),e[52]=b,e[53]=k,e[54]=_,e[55]=A):A=e[55],A},wy=(t,e,n,r)=>{const o=$e.c(11),{t:i}=at(),{confirm:a,dialog:u}=Fi(),c=Wi(Cy);let d;o[0]!==a||o[1]!==t||o[2]!==e||o[3]!==c||o[4]!==r||o[5]!==n||o[6]!==i?(d=async m=>{if(!(!t||!e||!await a({title:i("workflows.panel.saved.confirmTitle",{name:m}),message:i(n?"workflows.panel.saved.confirmHere":"workflows.panel.saved.confirmNew"),action:i("workflows.panel.saved.confirmAction")})))try{const b=await yh({directory:t,scriptDirectory:e,sessionId:n,name:m});n?c(r,b.runId):(c(b.sessionId,b.runId),et.getState().setCurrentSession(b.sessionId,t))}catch(b){const g=b;Re.error(i("workflows.panel.saved.failed"),{description:g instanceof Error?g.message:void 0})}},o[0]=a,o[1]=t,o[2]=e,o[3]=c,o[4]=r,o[5]=n,o[6]=i,o[7]=d):d=o[7];const f=d;let p;return o[8]!==u||o[9]!==f?(p={run:f,dialog:u},o[8]=u,o[9]=f,o[10]=p):p=o[10],p},yy=t=>{const e=$e.c(23),{saved:n,onRunSaved:r}=t,{t:o}=at();if(n.length===0){let p;e[0]!==o?(p=o("workflows.panel.emptyProject"),e[0]=o,e[1]=p):p=e[1];let m;return e[2]!==p?(m=s.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-meta text-muted-foreground",children:p}),e[2]=p,e[3]=m):m=e[3],m}let i;e[4]!==o?(i=o("workflows.panel.emptyProject"),e[4]=o,e[5]=i):i=e[5];let a;e[6]!==i?(a=s.jsx("p",{className:"typography-meta text-muted-foreground",children:i}),e[6]=i,e[7]=a):a=e[7];let u;e[8]!==o?(u=o("workflows.panel.picker.saved"),e[8]=o,e[9]=u):u=e[9];let c;e[10]!==u?(c=s.jsx("h4",{className:"mt-2 typography-micro font-medium text-muted-foreground",children:u}),e[10]=u,e[11]=c):c=e[11];let d;if(e[12]!==r||e[13]!==n||e[14]!==o){let p;e[16]!==r||e[17]!==o?(p=m=>s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-meta text-foreground",dir:"auto",children:m.name}),m.description||m.error?s.jsx("div",{className:"truncate typography-micro text-muted-foreground",dir:"auto",title:m.error??m.description,children:m.error??m.description}):null]}),s.jsxs(dt,{type:"button",size:"sm",variant:"outline",disabled:!!m.error,onClick:()=>r(m.name),"aria-label":o("workflows.panel.saved.runAria",{name:m.name}),children:[s.jsx(se,{name:"play",className:"size-3.5"}),o("workflows.panel.saved.confirmAction")]})]},m.name),e[16]=r,e[17]=o,e[18]=p):p=e[18],d=n.map(p),e[12]=r,e[13]=n,e[14]=o,e[15]=d}else d=e[15];let f;return e[19]!==a||e[20]!==c||e[21]!==d?(f=s.jsxs("div",{className:"flex flex-col gap-1 px-3 py-3",children:[a,c,d]}),e[19]=a,e[20]=c,e[21]=d,e[22]=f):f=e[22],f},vy=t=>{const e=$e.c(17),{directory:n}=t,r=et(Ty),o=bh(n),i=xh(o),a=wh(o?.savedDirectory??null),u=r??`directory:${n??""}`;let c;e[0]!==u?(c=x=>x.selectedBySession[u],e[0]=u,e[1]=c):c=e[1];const d=Wi(c),{run:f,dialog:p}=wy(n,o?.savedDirectory??null,r,u);let m;e[2]!==i||e[3]!==d||e[4]!==r?(m=i.find(x=>x.id===d)??i.filter(x=>x.parentSessionId===r).at(-1)??i.at(-1)??null,e[2]=i,e[3]=d,e[4]=r,e[5]=m):m=e[5];const h=m;let b;e[6]!==n||e[7]!==h||e[8]!==f||e[9]!==i||e[10]!==a||e[11]!==u||e[12]!==r?(b=h?s.jsx(Sy,{sessionId:r,selectionKey:u,runs:i,saved:a,run:h,directory:n,onRunSaved:x=>{f(x)}}):s.jsx(yy,{saved:a,onRunSaved:x=>{f(x)}}),e[6]=n,e[7]=h,e[8]=f,e[9]=i,e[10]=a,e[11]=u,e[12]=r,e[13]=b):b=e[13];let g;return e[14]!==p||e[15]!==b?(g=s.jsxs(s.Fragment,{children:[p,b]}),e[14]=p,e[15]=b,e[16]=g):g=e[16],g},Sy=t=>{const e=$e.c(58),{sessionId:n,selectionKey:r,runs:o,saved:i,run:a,directory:u,onRunSaved:c}=t,{t:d}=at(),f=Wi(Ny),p=by(),[m,h]=l.useState("agents"),{detail:b,failed:g}=uy(a,m),x=l.useRef(null);vh(x,ly);const{confirm:w,dialog:T}=Fi(),k=a.state==="running"||a.state==="awaiting-approval",E=a.parentSessionId!==n;let F;e[0]!==w||e[1]!==a.id||e[2]!==a.name||e[3]!==a.parentSessionId||e[4]!==d?(F=async()=>{if(await w({title:d("workflows.panel.delete.title",{name:a.name}),message:d("workflows.panel.delete.message"),action:d("workflows.panel.delete.confirm"),destructive:!0}))try{await Sh(a.id),kh.getState().remove(a.parentSessionId,a.id)}catch(P){const te=P;Re.error(d("workflows.panel.delete.failed"),{description:te instanceof Error?te.message:void 0})}},e[0]=w,e[1]=a.id,e[2]=a.name,e[3]=a.parentSessionId,e[4]=d,e[5]=F):F=e[5];const _=F;let A;e[6]!==a.directory||e[7]!==a.id||e[8]!==a.parentSessionId||e[9]!==f?(A=()=>{f(a.parentSessionId,a.id),et.getState().setCurrentSession(a.parentSessionId,a.directory)},e[6]=a.directory,e[7]=a.id,e[8]=a.parentSessionId,e[9]=f,e[10]=A):A=e[10];const D=A;let y;e[11]!==f||e[12]!==r?(y=H=>f(r,H),e[11]=f,e[12]=r,e[13]=y):y=e[13];let N;e[14]!==_||e[15]!==k?(N=k?null:()=>{_()},e[14]=_,e[15]=k,e[16]=N):N=e[16];let j;e[17]!==c||e[18]!==a||e[19]!==o||e[20]!==i||e[21]!==n||e[22]!==p||e[23]!==y||e[24]!==N?(j=s.jsx(xy,{runs:o,selected:a,sessionId:n,sessionTitles:p,saved:i,onSelect:y,onRunSaved:c,onDelete:N}),e[17]=c,e[18]=a,e[19]=o,e[20]=i,e[21]=n,e[22]=p,e[23]=y,e[24]=N,e[25]=j):j=e[25];let v;e[26]!==d?(v=d("workflows.panel.view.label"),e[26]=d,e[27]=v):v=e[27];let M;e[28]!==d||e[29]!==m?(M=cy.map(H=>{const P=H.id===m;return s.jsxs("button",{type:"button",onClick:()=>h(H.id),"aria-current":P?"page":void 0,title:d(H.labelKey),"aria-label":d(H.labelKey),className:Le("flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 transition-colors",P?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground"),children:[s.jsx(se,{name:H.icon,className:"size-3.5 shrink-0"}),s.jsx("span",{className:"workflows-header__label whitespace-nowrap typography-meta",children:d(H.labelKey)})]},H.id)}),e[28]=d,e[29]=m,e[30]=M):M=e[30];let W;e[31]!==v||e[32]!==M?(W=s.jsx("nav",{className:"flex shrink-0 items-center gap-1","aria-label":v,children:M}),e[31]=v,e[32]=M,e[33]=W):W=e[33];let G;e[34]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx("div",{"aria-hidden":!0,className:"min-w-0 flex-1"}),e[34]=G):G=e[34];let O;e[35]!==E||e[36]!==D||e[37]!==a.parentSessionId||e[38]!==p||e[39]!==d?(O=E?s.jsxs(dt,{type:"button",size:"sm",variant:"ghost",onClick:D,"aria-label":d("workflows.panel.agent.openSession"),title:p.get(a.parentSessionId)||d("workflows.panel.picker.untitledSession"),children:[s.jsx(se,{name:"chat-4",className:"size-3.5"}),s.jsx("span",{className:"workflows-header__action-label",children:d("workflows.panel.agent.openSession")})]}):null,e[35]=E,e[36]=D,e[37]=a.parentSessionId,e[38]=p,e[39]=d,e[40]=O):O=e[40];let Z;e[41]!==a?(Z=s.jsx(gy,{run:a}),e[41]=a,e[42]=Z):Z=e[42];let Q;e[43]!==O||e[44]!==Z||e[45]!==j||e[46]!==W?(Q=s.jsx(Lc,{children:s.jsxs("div",{ref:x,className:"workflows-header flex min-w-0 flex-1 flex-nowrap items-center gap-1.5 overflow-hidden ps-1 pe-1",children:[j,W,G,O,Z]})}),e[43]=O,e[44]=Z,e[45]=j,e[46]=W,e[47]=Q):Q=e[47];let B;e[48]!==b||e[49]!==u||e[50]!==g||e[51]!==a||e[52]!==m?(B=m==="agents"?s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(ty,{run:a,directory:u},a.id)}):s.jsxs(hs,{outerClassName:"min-h-0 flex-1",disableHorizontal:!0,children:[m==="log"?s.jsx(py,{run:a,detail:b}):null,m==="result"?s.jsx(my,{run:a,detail:b,failed:g}):null,m==="script"?s.jsx(hy,{detail:b,failed:g}):null]}),e[48]=b,e[49]=u,e[50]=g,e[51]=a,e[52]=m,e[53]=B):B=e[53];let oe;return e[54]!==T||e[55]!==Q||e[56]!==B?(oe=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[T,Q,B]}),e[54]=T,e[55]=Q,e[56]=B,e[57]=oe):oe=e[57],oe};function ky(t,e){return s.jsxs("li",{className:"flex min-w-0 gap-3 typography-meta",children:[s.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",dir:"ltr",children:fy(t.at)}),s.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words text-foreground",dir:"auto",children:t.message})]},`${t.at}-${e}`)}function jy(t){return t.entityById}function Cy(t){return t.select}function Ty(t){return t.currentSessionId}function Ny(t){return t.select}const nl=60,Ey=t=>{try{return new URL(t).origin}catch{return""}},Mo=new Set,Id=po()((t,e)=>({byOrigin:{},resolve:(n,r,o)=>{const i=Ey(n);!i||!r||e().byOrigin[i]||Mo.has(i)||(Mo.add(i),kn("desktop_browser_fetch_favicon",{url:r,webContentsId:o}).then(a=>{const u=typeof a?.dataUrl=="string"?a.dataUrl:"";u&&t(c=>{const d={...c.byOrigin,[i]:u},f=Object.keys(d);if(f.length<=nl)return{byOrigin:d};for(const p of f.slice(0,f.length-nl))delete d[p];return{byOrigin:d}})}).catch(()=>{}).finally(()=>{Mo.delete(i)}))}})),Zi=t=>t,ai=t=>{const e=Zi(t).type;return typeof e=="string"?e:""},Iy=t=>{const e=Zi(t).tool;return typeof e=="string"?e:""},Py=t=>{const e=Zi(t).text;return typeof e=="string"?e:""},Ry=t=>{const e=ai(t);return e==="tool"?Iy(t).trim().toLowerCase()||"tool":e||"unknown"},Dy=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=Ry(n);e.includes(r)||e.push(r)}return e.join(" + ")},Ay=t=>t.replace(/\s+/g," ").trim(),_y=t=>{for(const n of t)if(ai(n)==="text"){const r=Ay(Py(n));if(r.length===0)continue;return r}const e=t.filter(n=>ai(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},Oy=(t,e,n)=>`${n(t)} / ${n(e)}`,My=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Fy=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=My(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}})},Ly=(t,{windowTokens:e,compacted:n=!1})=>{const r=n?0:e,o=Number.isFinite(r)&&r>0?r:0,i=t.user+t.assistant+t.tool+t.other,a=Math.max(o,i);return{user:t.user,assistant:t.assistant,tool:t.tool,other:a-i,total:a}},li={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Pr={user:0,assistant:0,tool:0,other:0},Ms=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,rl=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof n=="number")return{...li,total:Ms(n)};if(!n||typeof n!="object")return li;const r=n,o=Ms(r.input),i=Ms(r.output),a=Ms(r.reasoning),u=Ms(r.cache?.read),c=Ms(r.cache?.write),d=Ms(r.total);return{input:o,output:i,reasoning:a,cacheRead:u,cacheWrite:c,total:d>0?d:o+i+a+u+c}},$y=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},bs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+bs(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+bs(n),0):0,By=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...Pr,assistant:bs(n.text)+bs(n.content)};const o=$y(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:bs(n.input)+bs(n.output)+bs(n.error)+bs(n.call?.input)+bs(n.call?.output)+bs(n.call?.error)+bs(n.raw)+Math.round(bs(n.metadata)*.25)+Math.round(bs(n.state)*.1)+Math.round((Du(t)??0)*.1),other:0}:e==="user"?{user:o.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:o.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:o.length}},ol=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),zy=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",Wy=(t,e)=>{if(t.length===0)return{...Pr};const n=t.reduce((r,o)=>{const i=zy(o);let a={...Pr};for(const u of o.parts)a=ol(a,By(u,i));return ol(r,a)},{...Pr});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)}},ln=t=>t.toLocaleString(Bc()),Uy=(t,e)=>!t||!Number.isFinite(t)?"-":Rh(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Vy=(t,e,n)=>{const r=t.find(i=>i.id===e),o=r?.models?.find(i=>i.id===n);return{providerName:r?.name||e||"-",modelName:o?.name||n||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},Hy=()=>{const t=$e.c(215),{t:e}=at(),n=Nh(),r=X(qy);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={},t[0]=o):o=t[0];const[i,a]=l.useState(o),[u,c]=l.useState(null),d=l.useRef(null),f=et(Ky),p=et(Gy),m=Eh(p??void 0),h=Ih(f??"",p??void 0),b=zt(Zy);let g;t[1]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),a(Xy),c(null)},t[1]=g):g=t[1];let x;t[2]!==p||t[3]!==f?(x=[p,f],t[2]=p,t[3]=f,t[4]=x):x=t[4],l.useEffect(g,x);let w,T;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},T=[],t[5]=w,t[6]=T):(w=t[5],T=t[6]),l.useEffect(w,T);let k;t[7]===Symbol.for("react.memo_cache_sentinel")?(k=async(ye,ot)=>{(await no(ot)).ok?(c(ye),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{c(xt=>xt===ye?null:xt),d.current=null},2e3)):c(null)},t[7]=k):k=t[7];const E=k;let F,_,A,D,y,N,j,v,M,W;if(t[8]!==f||t[9]!==b||t[10]!==h||t[11]!==m){D=f?m.find(ht=>ht.id===f)??null:null,F=h.filter(Yy);let ye;t[22]!==h?(ye=h.filter(Jy),t[22]=h,t[23]=ye):ye=t[23],W=ye;let ot;t[24]!==h?(ot=Cc(h.map(Qy)),t[24]=h,t[25]=ot):ot=t[25];const Ct=ot,xt=Ct?h[Ct.index]??null:null,jt=Ct?.state==="compacted";j=xt?rl(xt):li,_=Ph({input:j.input,cache:{read:j.cacheRead,write:j.cacheWrite}}),v=Number.isFinite(D?.cost)?Ms(D?.cost):F.reduce(ev,0);const ct=xt?.info??null,vt=b,St=ct?.providerID||"",mt=ct?.modelID||"";let yt;t[26]!==St||t[27]!==mt||t[28]!==vt?(yt=Vy(vt,St,mt),t[26]=St,t[27]=mt,t[28]=vt,t[29]=yt):yt=t[29],y=yt,A=y.contextLimit,M=jt?null:A&&A>0?Math.min(999,j.total/A*100):0;const lt=[...h].reverse().find(tv),Nt=lt?.info.role==="system"?lt.info.text:"",_t=Wy(h,Nt);N=Ly(_t,{windowTokens:j.total,compacted:jt}),t[8]=f,t[9]=b,t[10]=h,t[11]=m,t[12]=F,t[13]=_,t[14]=A,t[15]=D,t[16]=y,t[17]=N,t[18]=j,t[19]=v,t[20]=M,t[21]=W}else F=t[12],_=t[13],A=t[14],D=t[15],y=t[16],N=t[17],j=t[18],v=t[19],M=t[20],W=t[21];const G=N,O=h[0]?.info?.time?.created,Z=h.length>0?h[h.length-1]?.info?.time?.created:null;let Q;t[30]!==D?.title||t[31]!==e?(Q=D?.title||e("contextSidebar.session.untitled"),t[30]=D?.title,t[31]=e,t[32]=Q):Q=t[32];const B=D?.time?.created??O??null,oe=Z??D?.time?.created??null;let H;t[33]!==F.length||t[34]!==G||t[35]!==_||t[36]!==A||t[37]!==y||t[38]!==h.length||t[39]!==Q||t[40]!==B||t[41]!==oe||t[42]!==j||t[43]!==v||t[44]!==M||t[45]!==W.length?(H={sessionTitle:Q,messagesCount:h.length,userMessagesCount:W.length,assistantMessagesCount:F.length,createdAt:B,lastActivityAt:oe,providerModel:y,tokenBreakdown:j,usagePercent:M,cacheHitRate:_,totalAssistantCost:v,contextLimit:A,breakdown:G,breakdownTotal:G.total},t[33]=F.length,t[34]=G,t[35]=_,t[36]=A,t[37]=y,t[38]=h.length,t[39]=Q,t[40]=B,t[41]=oe,t[42]=j,t[43]=v,t[44]=M,t[45]=W.length,t[46]=H):H=t[46];const P=H;if(!f){let ye;t[47]!==e?(ye=e("contextSidebar.empty.openSession"),t[47]=e,t[48]=ye):ye=t[48];let ot;return t[49]!==ye?(ot=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:ye}),t[49]=ye,t[50]=ot):ot=t[50],ot}let te;t[51]!==e?(te=e("contextSidebar.breakdown.user"),t[51]=e,t[52]=te):te=t[52];let J;t[53]!==te||t[54]!==P.breakdown.user?(J={key:"user",label:te,value:P.breakdown.user,color:"var(--status-success)"},t[53]=te,t[54]=P.breakdown.user,t[55]=J):J=t[55];let le;t[56]!==e?(le=e("contextSidebar.breakdown.assistant"),t[56]=e,t[57]=le):le=t[57];let K;t[58]!==le||t[59]!==P.breakdown.assistant?(K={key:"assistant",label:le,value:P.breakdown.assistant,color:"var(--primary-base)"},t[58]=le,t[59]=P.breakdown.assistant,t[60]=K):K=t[60];let U;t[61]!==e?(U=e("contextSidebar.breakdown.toolCalls"),t[61]=e,t[62]=U):U=t[62];let $;t[63]!==U||t[64]!==P.breakdown.tool?($={key:"tool",label:U,value:P.breakdown.tool,color:"var(--status-warning)"},t[63]=U,t[64]=P.breakdown.tool,t[65]=$):$=t[65];let ee;t[66]!==e?(ee=e("contextSidebar.breakdown.other"),t[66]=e,t[67]=ee):ee=t[67];let Y;t[68]!==ee||t[69]!==P.breakdown.other?(Y={key:"other",label:ee,value:P.breakdown.other,color:"var(--surface-muted-foreground)"},t[68]=ee,t[69]=P.breakdown.other,t[70]=Y):Y=t[70];let ie;t[71]!==J||t[72]!==K||t[73]!==$||t[74]!==Y?(ie=[J,K,$,Y],t[71]=J,t[72]=K,t[73]=$,t[74]=Y,t[75]=ie):ie=t[75];const V=ie;let fe;t[76]!==n||t[77]!==P.sessionTitle?(fe=n?s.jsx(Lc,{children:s.jsx("div",{className:"flex min-w-0 flex-1 items-center ps-1.5 pe-1",children:s.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-foreground",title:P.sessionTitle,children:P.sessionTitle})})}):null,t[76]=n,t[77]=P.sessionTitle,t[78]=fe):fe=t[78];let Se;t[79]!==n||t[80]!==P.sessionTitle?(Se=n?null:s.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:P.sessionTitle}),t[79]=n,t[80]=P.sessionTitle,t[81]=Se):Se=t[81];const Te=!n&&"mt-1";let ue;t[82]!==Te?(ue=Le(Te,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground"),t[82]=Te,t[83]=ue):ue=t[83];let Me;t[84]!==P.providerModel.modelName||t[85]!==P.providerModel.providerName?(Me=s.jsxs("span",{children:[P.providerModel.providerName," / ",P.providerModel.modelName]}),t[84]=P.providerModel.modelName,t[85]=P.providerModel.providerName,t[86]=Me):Me=t[86];let Ae;t[87]!==r||t[88]!==P.createdAt?(Ae=P.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:Uy(P.createdAt,r)})]}),t[87]=r,t[88]=P.createdAt,t[89]=Ae):Ae=t[89];let De;t[90]!==ue||t[91]!==Me||t[92]!==Ae?(De=s.jsxs("div",{className:ue,children:[Me,Ae]}),t[90]=ue,t[91]=Me,t[92]=Ae,t[93]=De):De=t[93];let Be;t[94]!==Se||t[95]!==De?(Be=s.jsxs("div",{className:"mb-6",children:[Se,De]}),t[94]=Se,t[95]=De,t[96]=Be):Be=t[96];let we;t[97]!==e?(we=e("contextSidebar.section.context"),t[97]=e,t[98]=we):we=t[98];let ve;t[99]!==we?(ve=s.jsx("span",{className:"typography-micro text-muted-foreground",children:we}),t[99]=we,t[100]=ve):ve=t[100];let Pe;t[101]!==P.tokenBreakdown.total||t[102]!==P.usagePercent?(Pe=P.usagePercent===null?"—":ln(P.tokenBreakdown.total),t[101]=P.tokenBreakdown.total,t[102]=P.usagePercent,t[103]=Pe):Pe=t[103];let he;t[104]!==P.contextLimit?(he=P.contextLimit?` / ${ln(P.contextLimit)}`:"",t[104]=P.contextLimit,t[105]=he):he=t[105];let Fe;t[106]!==Pe||t[107]!==he?(Fe=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[Pe,he]}),t[106]=Pe,t[107]=he,t[108]=Fe):Fe=t[108];let _e;t[109]!==ve||t[110]!==Fe?(_e=s.jsxs("div",{className:"flex items-baseline justify-between",children:[ve,Fe]}),t[109]=ve,t[110]=Fe,t[111]=_e):_e=t[111];let We;t[112]!==P.usagePercent?(We=P.usagePercent!==null&&P.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,P.usagePercent)}%`,backgroundColor:P.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[112]=P.usagePercent,t[113]=We):We=t[113];let Xe;t[114]!==We?(Xe=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:We}),t[114]=We,t[115]=Xe):Xe=t[115];let Ve;t[116]!==e||t[117]!==P.usagePercent?(Ve=P.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:P.usagePercent.toFixed(1)}),t[116]=e,t[117]=P.usagePercent,t[118]=Ve):Ve=t[118];let S;t[119]!==Ve?(S=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:Ve}),t[119]=Ve,t[120]=S):S=t[120];let ne;t[121]!==_e||t[122]!==Xe||t[123]!==S?(ne=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[_e,Xe,S]}),t[121]=_e,t[122]=Xe,t[123]=S,t[124]=ne):ne=t[124];let q;t[125]!==e?(q=e("contextSidebar.stats.messages"),t[125]=e,t[126]=q):q=t[126];let ke;t[127]!==P.messagesCount?(ke=ln(P.messagesCount),t[127]=P.messagesCount,t[128]=ke):ke=t[128];let Ee;t[129]!==q||t[130]!==ke?(Ee={label:q,value:ke},t[129]=q,t[130]=ke,t[131]=Ee):Ee=t[131];let Ie;t[132]!==e?(Ie=e("contextSidebar.stats.user"),t[132]=e,t[133]=Ie):Ie=t[133];let Ne;t[134]!==P.userMessagesCount?(Ne=ln(P.userMessagesCount),t[134]=P.userMessagesCount,t[135]=Ne):Ne=t[135];let ze;t[136]!==Ie||t[137]!==Ne?(ze={label:Ie,value:Ne},t[136]=Ie,t[137]=Ne,t[138]=ze):ze=t[138];let Ue;t[139]!==e?(Ue=e("contextSidebar.stats.assistant"),t[139]=e,t[140]=Ue):Ue=t[140];let Ge;t[141]!==P.assistantMessagesCount?(Ge=ln(P.assistantMessagesCount),t[141]=P.assistantMessagesCount,t[142]=Ge):Ge=t[142];let Qe;t[143]!==Ue||t[144]!==Ge?(Qe={label:Ue,value:Ge},t[143]=Ue,t[144]=Ge,t[145]=Qe):Qe=t[145];let He;t[146]!==e?(He=e("contextSidebar.stats.cost"),t[146]=e,t[147]=He):He=t[147];let Ke;t[148]!==P.totalAssistantCost?(Ke=rd(P.totalAssistantCost),t[148]=P.totalAssistantCost,t[149]=Ke):Ke=t[149];let Ye;t[150]!==He||t[151]!==Ke?(Ye={label:He,value:Ke},t[150]=He,t[151]=Ke,t[152]=Ye):Ye=t[152];let it;t[153]!==Ee||t[154]!==ze||t[155]!==Qe||t[156]!==Ye?(it=[Ee,ze,Qe,Ye],t[153]=Ee,t[154]=ze,t[155]=Qe,t[156]=Ye,t[157]=it):it=t[157];const bt=it;let nt;t[158]!==bt?(nt=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:bt.map(sv)}),t[158]=bt,t[159]=nt):nt=t[159];let ft;t[160]!==e?(ft=e("contextSidebar.section.lastAssistantMessage"),t[160]=e,t[161]=ft):ft=t[161];let ae;t[162]!==ft?(ae=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:ft}),t[162]=ft,t[163]=ae):ae=t[163];let de;t[164]!==e||t[165]!==P.cacheHitRate.hasInput||t[166]!==P.cacheHitRate.percent||t[167]!==P.tokenBreakdown.cacheRead||t[168]!==P.tokenBreakdown.cacheWrite||t[169]!==P.tokenBreakdown.input||t[170]!==P.tokenBreakdown.output||t[171]!==P.tokenBreakdown.reasoning?(de=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:P.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:P.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:P.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:P.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:P.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:P.cacheHitRate.hasInput?P.cacheHitRate.percent:null,format:"percent"}].map(nv)}),t[164]=e,t[165]=P.cacheHitRate.hasInput,t[166]=P.cacheHitRate.percent,t[167]=P.tokenBreakdown.cacheRead,t[168]=P.tokenBreakdown.cacheWrite,t[169]=P.tokenBreakdown.input,t[170]=P.tokenBreakdown.output,t[171]=P.tokenBreakdown.reasoning,t[172]=de):de=t[172];let be;t[173]!==ae||t[174]!==de?(be=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[ae,de]}),t[173]=ae,t[174]=de,t[175]=be):be=t[175];let C;t[176]!==V||t[177]!==P.breakdownTotal?(C=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:V.map(ye=>ye.value<=0||P.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${ye.value/P.breakdownTotal*100}%`,backgroundColor:ye.color}},ye.key))}),t[176]=V,t[177]=P.breakdownTotal,t[178]=C):C=t[178];let ce;t[179]!==V||t[180]!==P.breakdownTotal?(ce=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:V.map(ye=>{const ot=P.breakdownTotal>0?ye.value/P.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:ye.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:[ye.label," ",s.jsxs("span",{className:"tabular-nums",children:[ot.toFixed(0),"%"]})]})]},ye.key)})}),t[179]=V,t[180]=P.breakdownTotal,t[181]=ce):ce=t[181];let L;t[182]!==C||t[183]!==ce?(L=s.jsxs("div",{className:"mb-6",children:[C,ce]}),t[182]=C,t[183]=ce,t[184]=L):L=t[184];let ge;t[185]!==e?(ge=e("contextSidebar.section.rawMessages"),t[185]=e,t[186]=ge):ge=t[186];let Ce;t[187]!==ge?(Ce=s.jsx("div",{className:"typography-micro text-muted-foreground",children:ge}),t[187]=ge,t[188]=Ce):Ce=t[188];let Je;if(t[189]!==u||t[190]!==i||t[191]!==h||t[192]!==e||t[193]!==r){let ye;t[195]!==u||t[196]!==i||t[197]!==e||t[198]!==r?(ye=ot=>{const Ct=ot.info.role,xt=Ct==="assistant",jt=Ct==="user",ct=i[ot.info.id]===!0,vt=u===ot.info.id,St=ot.info.time?.created??null,mt=Dy(ot.parts),yt=xt?rl({info:ot.info,parts:ot.parts}):null,lt=jt?_y(ot.parts):"",Nt=Fy(St,r),_t=mt||"—",ht=yt?Oy(yt.input,yt.output,ln):"",gt=Ct||"unknown",Dt=mt?`${gt}: ${mt}`:gt,Kt=ct?JSON.stringify({info:ot.info,parts:ot.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-start hover:bg-[var(--interactive-hover)]","aria-expanded":ct,onClick:()=>{a(Yt=>({...Yt,[ot.info.id]:Yt[ot.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:xt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[jt?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",lt]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:xt?_t:Dt}),xt&&s.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:ht})]}),s.jsx("span",{className:"text-end text-muted-foreground",children:Nt})]})}),ct&&s.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:s.jsxs(hs,{outerClassName:"max-h-[26rem] bg-[var(--surface-background)]",className:"group relative",disableHorizontal:!0,children:[s.jsx("div",{className:"absolute top-1 inset-e-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:Yt=>{Yt.stopPropagation(),E(ot.info.id,Kt)},"aria-label":e(vt?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(vt?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:vt?s.jsx(se,{name:"check",className:"size-3.5"}):s.jsx(se,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Dh,{language:"json",code:Kt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},ot.info.id)},t[195]=u,t[196]=i,t[197]=e,t[198]=r,t[199]=ye):ye=t[199],Je=[...h].reverse().map(ye),t[189]=u,t[190]=i,t[191]=h,t[192]=e,t[193]=r,t[194]=Je}else Je=t[194];let Oe;t[200]!==Je?(Oe=s.jsx("div",{className:"mt-2.5 space-y-1",children:Je}),t[200]=Je,t[201]=Oe):Oe=t[201];let me;t[202]!==Ce||t[203]!==Oe?(me=s.jsxs("div",{children:[Ce,Oe]}),t[202]=Ce,t[203]=Oe,t[204]=me):me=t[204];let je;t[205]!==Be||t[206]!==ne||t[207]!==nt||t[208]!==be||t[209]!==L||t[210]!==me?(je=s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[Be,ne,nt,be,L,me]}),t[205]=Be,t[206]=ne,t[207]=nt,t[208]=be,t[209]=L,t[210]=me,t[211]=je):je=t[211];let st;return t[212]!==fe||t[213]!==je?(st=s.jsxs(hs,{outerClassName:"h-full",className:"bg-background",children:[fe,je]}),t[212]=fe,t[213]=je,t[214]=st):st=t[214],st};function qy(t){return t.timeFormatPreference}function Ky(t){return t.currentSessionId}function Gy(t){return t.currentSessionDirectory}function Zy(t){return t.providers}function Xy(t){return Object.keys(t).length>0?{}:t}function Yy(t){return t.info.role==="assistant"}function Jy(t){return t.info.role==="user"}function Qy(t){return t.info}function ev(t,e){const n=Ms(e.info.cost);return t+n}function tv(t){return t.info.role==="system"}function sv(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",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function nv(t){return s.jsxs("div",{children:[s.jsx("div",{className:"typography-micro text-muted-foreground",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)}%`:ln(t.value):"—"})]},t.label)}const Rr=(t,e)=>{const[n,r]=l.useState(null),o=t?.id??null;return e&&n!==o&&r(o),e||n===null||n===o?t:null},rv=280,ov=.28,iv=240,av=.35,lv=(t,e,n=null)=>{const r=t.left+t.width,o=e.left+e.width,i=e.top+e.height,a=n?n.top:i-Math.min(iv,e.height*av),u=Math.min(rv,t.width*ov,e.width/4),c=e.left-t.left>=1,d=r-o>=1,f=Math.max(0,a-t.top),p=c?e.left:t.left+u,m=d?o:r-u;return{left:{left:t.left,top:t.top,width:p-t.left,height:c?t.height:f},right:{left:m,top:t.top,width:r-m,height:d?t.height:f},bottom:{left:e.left,top:a,width:e.width,height:Math.max(0,i-a)}}},Fo=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,cv=(t,e)=>Fo(t.bottom,e)?"bottom":Fo(t.left,e)?"left":Fo(t.right,e)?"right":null,Us=po(()=>({drag:null,hovered:null})),Dr=t=>{if(!t)return null;const{left:e,top:n,width:r,height:o}=t.getBoundingClientRect();return r>0&&o>0?{left:e,top:n,width:r,height:o}:null},Lo=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),$o=t=>Dr(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),Pd=t=>{const e=Dr(document.querySelector("[data-workspace-row]")),n=Dr(document.querySelector("[data-workspace-chat]"));if(!e||!n)return!1;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=lv(e,n,Dr(r)),i={left:$o("left")??Lo(o.left),right:$o("right")??Lo(o.right),bottom:$o("bottom")??Lo(o.bottom)};return Us.setState({drag:{...t,targets:o,frames:i},hovered:null}),!0},Rd=t=>{const{drag:e,hovered:n}=Us.getState();if(!e)return;const r=cv(e.targets,t);r!==n&&Us.setState({hovered:r})},ci=()=>{Us.getState().drag&&Us.setState({drag:null,hovered:null})},Dd=t=>{const{drag:e,hovered:n}=Us.getState();if(Us.setState({drag:null,hovered:null}),!e||!n)return!1;const r=X.getState();n!==e.from&&r.moveContextSurfaceToZone(e.mode,n);const o=t?cs(t):"";if(o){const i=X.getState();vi(i.contextPanelByDirectory[o],i.contextSurfaceZones).has(e.mode)||i.openContextSurface(o,e.mode)}return!0},Xi=(t,e)=>{let n=!1;const r=i=>{const a={x:i.clientX,y:i.clientY};e(a)?(n||(n=Pd(t)),n&&Rd(a)):n&&(ci(),n=!1)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:i=>(o(),n?(Dd(i),!0):!1),cancel:()=>{o(),n&&ci()}}},il={left:null,right:null,bottom:null},lr=po(()=>({body:il,headerSlot:il})),Ad=(t,e,n)=>{const r=lr.getState()[t];r[e]!==n&&lr.setState({[t]:{...r,[e]:n}})},dv=(t,e)=>Ad("body",t,e),uv=(t,e)=>Ad("headerSlot",t,e),Xn=t=>{const e=l.useRef(t);e.current=t;const[n,r]=l.useState(t),o=l.useCallback(()=>r(e.current),[]);return l.useLayoutEffect(()=>{Di(o)},[t,o]),l.useEffect(()=>()=>zc(o),[o]),n},Bo=t=>{const e=Xn(t);return t||e},fv=ur(()=>Ot(()=>import("./GitView-BIg-1tUn.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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206])).then(t=>({default:t.GitView}))),Yi=320,_d=320,pv=24,mv=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},al=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Yi,Math.round(t))):Ci,hv=t=>t===null?Number.POSITIVE_INFINITY:Math.max(Yi,t-_d),ll=(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},Ar=(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==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):t==="workflows"?e("contextPanel.mode.workflows"):Pn(t)?Ri.getState().guests.find(r=>r.id===Fr(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),gv=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},bv=(t,e,n)=>{if(t.mode==="chat"){const r=ho(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||n("contextPanel.mode.chat")}return t.mode==="browser"?eo(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?gv(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Ar(t.mode,n)},xv=t=>{const e=$e.c(8),{mode:n}=t,r=Ui();let o;if(e[0]!==n||e[1]!==r){let d;e[3]!==n?(d=f=>f.mode===n,e[3]=n,e[4]=d):d=e[4],o=r.find(d),e[0]=n,e[1]=r,e[2]=o}else o=e[2];const i=o,a=i?.icon??$h,u=i?.iconSrc;let c;return e[5]!==a||e[6]!==u?(c=s.jsx(Pi,{icon:a,iconSrc:u,className:"h-3.5 w-3.5"}),e[5]=a,e[6]=u,e[7]=c):c=e[7],c},wv=t=>{const e=$e.c(2),{sessionId:n}=t,r=yc(n);let o;return e[0]!==r?(o=r?s.jsx(Sc,{state:r,className:"h-3.5 w-3.5"}):s.jsx(se,{name:"chat-4",className:"h-3.5 w-3.5"}),e[0]=r,e[1]=o):o=e[1],o},yv=t=>{const e=$e.c(6),{url:n}=t,r=co(),o=Mc();let i;if(e[0]!==o||e[1]!==n||e[2]!==r){const c=n?Fc(n,r,o):null;i=c?c.source==="tracker"?Lh(c.provider).icon:Fh[c.kind]:"git-branch",e[0]=o,e[1]=n,e[2]=r,e[3]=i}else i=e[3];const a=i;let u;return e[4]!==a?(u=s.jsx(se,{name:a,className:"h-3.5 w-3.5"}),e[4]=a,e[5]=u):u=e[5],u},cl=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(uo,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(hc,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(se,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(se,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(yv,{url:t.targetPath});if(t.mode==="notes")return s.jsx(se,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(se,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(se,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="workflows")return s.jsx(se,{name:"flow-chart",className:"h-3.5 w-3.5"});if(t.mode==="chat"){const n=ho(t.dedupeKey);return n?s.jsx(wv,{sessionId:n}):s.jsx(se,{name:"chat-4",className:"h-3.5 w-3.5"})}if(Pn(t.mode))return s.jsx(xv,{mode:t.mode});if(t.mode==="browser"){const n=vv(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(se,{name:"global",className:"h-3.5 w-3.5"})}},vv=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Sv=t=>{const e=Uc(),n=l.useRef(Vr),r=l.useRef(t);r.current=t;const o=t.length>0;return l.useSyncExternalStore(l.useCallback(i=>o?e.subscribeAllSelected(a=>a.session,i):()=>{},[e,o]),l.useCallback(()=>{const i=Array.from(e.children.values(),u=>u.getState()),a=zw(i,r.current);return $w(n.current,a)?n.current:(n.current=a,a)},[e]),()=>Vr)},kv=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,jv=8,Cv='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',Tv=t=>t==="context"||t==="git"||t==="pr"||t==="notes"||t==="workflows",Od=320,Ji=160,di=200,Nv={right:{axis:"x",gutter:"mb-2 ms-2 me-1.5",gutterSize:"0.875rem",handle:"absolute bottom-2 inset-s-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},left:{axis:"x",gutter:"mb-2 ms-1.5 me-2",gutterSize:"0.875rem",handle:"absolute bottom-2 inset-e-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},bottom:{axis:"y",gutter:"mb-2 mt-2",gutterSize:"1rem",handle:"absolute inset-x-0 top-1 z-50 h-2 cursor-row-resize",sizeVariable:"--oc-context-panel-height"}},dl=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Ji,Math.round(t))):Od,Ev=t=>t===null?Number.POSITIVE_INFINITY:Math.max(Ji,t-di),zo=({zone:t="right"})=>{const e=Nv[t],n=io(),r=e.axis==="y",{t:o,direction:i}=at(),a=i==="rtl",u=Vs()??"",c=Xl(Ah(u||null)),d=l.useCallback((re,Ze)=>o($s(re,c),Ze),[c,o]),f=l.useMemo(()=>mv(u),[u]),p=X(re=>f?re.contextPanelByDirectory[f]:void 0),m=X(re=>re.contextSurfaceZones),h=X(re=>re.shortcutOverrides),b=X(re=>re.closeContextZone),g=X(re=>re.closeContextPanelTab),x=X(re=>re.pinContextPanelTab),w=X(re=>re.toggleContextPanelExpanded),T=X(re=>re.setContextZoneSize),k=X(re=>re.setContextZoneExpandedChatSize),E=X(re=>re.setActiveContextPanelTab),F=X(re=>re.reorderContextPanelTabs),_=X(re=>re.contextEditorTreeVisible),A=X(re=>re.contextEditorTreeWidth),D=X(re=>re.setContextEditorTreeWidth),y=X(re=>re.toggleContextEditorTree),N=X(re=>re.contextEditorVisible),j=X(re=>re.toggleContextEditor),v=X(re=>re.fileTreeSide),M=X(re=>re.openNewContextBrowserTab),W=Id(re=>re.byOrigin),[G,O]=l.useState(null),Z=l.useCallback(re=>{O(re),uv(t,re)},[t]),Q=l.useCallback(re=>{dv(t,re)},[t]),B=l.useMemo(()=>p?.tabs??[],[p?.tabs]),oe=p?Mr(p,m,t):null,H=p?er(p,t):Au,P=Ir(re=>re.workStatusReserved),te=Ir(re=>re.workStatusBesidePanel),J=Ir(re=>re.chatCovered),le=t==="bottom"&&J,K=!!(H.isOpen&&oe)&&!le,U=Rr(oe,K),$=l.useMemo(()=>B.some(re=>re.mode==="file"&&re.targetPath),[B]),ee=$&&(N||!_),Y=!r&&U?.mode==="file"&&!ee,ie=!!(K&&H.expanded&&!Y),V=X(re=>re.contextZoneSizes[t]),fe=Y?A:r?dl(V??Od,Number.POSITIVE_INFINITY):al(V??Ci,Number.POSITIVE_INFINITY),Se=l.useCallback((re,Ze)=>r?dl(re,Ev(Ze)):al(re,hv(Ze)),[r]),Te=r?di:_d,ue=X(re=>r?0:re.sidebarWidth),Me=X(re=>re.contextZoneExpandedChatSizes[t]),Ae=Math.max(Te,Me??(r?di:ue)),De=t==="right"?"left":t==="left"?"right":null,Be=X(re=>{if(!De||!f)return 0;const Ze=re.contextPanelByDirectory[f],pt=Ze&&Kn(Ze,re.contextSurfaceZones,De)?Mr(Ze,re.contextSurfaceZones,De):null;return Ze&&pt?_u(Ze,pt,De,re):0}),we=De==="right"&&P&&!J&&Be===0?yn:Be,ve=t==="right"&&P&&!J,Pe=ve&&te&&!ie,[he,Fe]=l.useState(null),_e=l.useRef(null),We=l.useRef(we);We.current=we;const Xe=l.useRef(K);Xe.current=K;const Ve=l.useRef(()=>!1);Ve.current=re=>ie||!Y&&re-We.current-Te<fe;const S=l.useCallback(()=>{let re=_e.current;if(re!==null&&!r&&Xe.current){const Ze=document.querySelector("[data-left-sidebar]");Ze&&(re+=Math.round(Ze.getBoundingClientRect().width-(Number.parseFloat(Ze.style.width)||0)))}Fe(re!==null&&Ve.current(re)?re:null)},[r]),ne=he!==null?he-we:null,q=Y?fe:ie&&ne!==null?Math.max(r?Ji:Yi,ne-Ae):Se(fe,ne),ke=K&&U?.mode==="chat",Ee=l.useMemo(()=>{const re=[];if(!ke)return re;for(const Ze of B){if(Ze.mode!=="chat")continue;const pt=ho(Ze.dedupeKey);pt&&!re.includes(pt)&&re.push(pt)}return re},[ke,B]),Ie=Sv(Ee),[Ne,ze]=l.useState(!1),Ue=l.useRef(0),Ge=l.useRef(q),Qe=l.useRef(null),He=l.useRef(null),Ke=l.useRef(null),Ye=l.useRef(null),it=l.useRef(!1);l.useLayoutEffect(()=>{const re=r?Ke.current?.parentElement:Ke.current?.closest("[data-workspace-row]");if(!re||typeof ResizeObserver>"u")return;const Ze=new ResizeObserver(pt=>{const kt=pt[pt.length-1]?.contentRect,Pt=r?kt?.height:kt?.width;_e.current=Pt?Math.round(Pt):null,Di(S)});return Ze.observe(re),_e.current=(r?re.clientHeight:re.clientWidth)||null,S(),()=>{Ze.disconnect(),zc(S)}},[S,r]);const bt=!r&&K&&(ie||he!==null),nt=X(re=>bt&&re.isSidebarOpen);l.useLayoutEffect(()=>{S()},[S,fe,ie,K,we,nt]),l.useEffect(()=>{if(!K||it.current){it.current=K;return}const re=window.requestAnimationFrame(()=>{Ye.current?.focus({preventScroll:!0})});return it.current=!0,()=>window.cancelAnimationFrame(re)},[K]);const ft=l.useRef(null),ae=l.useRef(null),de=l.useRef(null),be=l.useRef(null),C=l.useRef(!1),ce=l.useRef(null),L=l.useRef(!1),ge=l.useCallback(re=>{const Ze=Ke.current,pt=ce.current;if(!Ze||!pt)return;const kt=r?"height":"width";Ze.style[kt]=L.current?`${re+yn}px`:`min(${re}px, 100%)`,pt.style[kt]=`calc(${re}px - ${e.gutterSize})`},[e.gutterSize,r]),Ce=l.useCallback(()=>{ae.current=null;const re=Qe.current;re!==null&&ge(re)},[ge]);l.useEffect(()=>()=>{ae.current!==null&&cancelAnimationFrame(ae.current),de.current?.(),de.current=null,be.current?.remove(),be.current=null},[]);const Je=l.useCallback(re=>{const Ze=ft.current,pt=Y?Ko(re):Se(re,Ze);return Ze===null?pt:Math.min(pt,Math.max(1,Ze))},[Se,Y]),Oe=l.useCallback(re=>{if(!K||!f)return;He.current=re.pointerId,ze(!0),Ue.current=r?re.clientY:re.clientX,Ge.current=q,Qe.current=q;const Ze=r?Ke.current?.parentElement?.clientHeight:(Ke.current?.closest("[data-workspace-row]")?.clientWidth??0)-We.current-(Pe?yn:0);ft.current=Ze&&Ze>0?Ze:null,be.current?.remove();const pt=document.createElement("div");pt.style.cssText=`position:fixed;inset:0;z-index:2147483647;cursor:${r?"row-resize":"col-resize"}`,document.body.appendChild(pt),be.current=pt,de.current?.(),de.current=Ec(r?"height":"width"),re.preventDefault()},[Pe,f,K,r,q]),me=l.useCallback(()=>{const re=Je(Qe.current??q),Ze=ft.current;ae.current!==null&&(cancelAnimationFrame(ae.current),ae.current=null);const pt=Ke.current,kt=ce.current;if(pt&&kt){const Pt=r?"height":"width";pt.style.setProperty(e.sizeVariable,`${re}px`),pt.style[Pt]=Ut.current,kt.style[Pt]=Hs.current}Qe.current=null,ft.current=null,C.current=!0,be.current?.remove(),be.current=null,Y?D(re):ie?Ze!==null&&k(t,Ze-re):T(t,re),ze(!1),He.current=null,de.current?.(),de.current=null},[Je,e.sizeVariable,ie,Y,r,D,k,T,q,t]);l.useEffect(()=>{if(!Ne)return;const re=kt=>{if(He.current!==kt.pointerId)return;const Pt=r?kt.clientY:kt.clientX,Zt=t==="left"?Pt-Ue.current:Ue.current-Pt,is=!r&&a?-Zt:Zt,z=Je(Ge.current+is);Qe.current!==z&&(Qe.current=z,ae.current===null&&(ae.current=requestAnimationFrame(Ce)))},Ze=kt=>{He.current===kt.pointerId&&me()},pt=()=>{me()};return window.addEventListener("pointermove",re),window.addEventListener("pointerup",Ze),window.addEventListener("pointercancel",Ze),window.addEventListener("blur",pt),()=>{window.removeEventListener("pointermove",re),window.removeEventListener("pointerup",Ze),window.removeEventListener("pointercancel",Ze),window.removeEventListener("blur",pt)}},[Ce,Je,me,Ne,a,r,t]),l.useEffect(()=>{Ne||(Qe.current=null,be.current?.remove(),be.current=null)},[Ne]);const je=l.useCallback(()=>{f&&b(f,t)},[b,f,t]),st=l.useCallback(()=>{f&&w(f,t)},[f,w,t]),ye=U?.mode==="file"||U?.mode==="chat"||U?.mode==="browser"||U?.mode==="pr",ot=l.useMemo(()=>{if(!U)return[];const re=B.filter(Ze=>Ze.mode===U.mode);return U.mode==="pr"?[...re.filter(xr),...re.filter(Ze=>!xr(Ze))]:re},[U,B]),Ct=lo(U?.mode==="pr"&&f?f:null)?.current??null,xt=l.useMemo(()=>{const re=_h(ot.filter(Ze=>Ze.mode==="file").map(Ze=>ll(Ze.targetPath,u)));return ot.map(Ze=>{const pt=xr(Ze),kt=pt?Ct||o("contextPanel.tracker.branchTab"):bv(Ze,Ie,d),Pt=kv(kt,pv),Zt=ll(Ze.targetPath,u);return{id:Ze.id,label:Pt,labelFolder:Ze.mode==="file"?re.get(Zt):void 0,icon:cl(Ze,W),title:Zt?`${kt}: ${Zt}`:kt,closeLabel:o("contextPanel.tab.closeTabAria",{label:Pt}),closable:!pt,preview:Ze.preview}})},[ot,u,W,Ie,o,d,Ct]),jt=U?.mode==="context"?s.jsx(cn,{value:G,children:s.jsx(Hy,{})}):U?.mode==="git"?s.jsx(l.Suspense,{fallback:null,children:s.jsx(cn,{value:G,children:s.jsx(fv,{isActive:K})})}):U?.mode==="pr"?U.targetPath?s.jsx(Ew,{url:U.targetPath,directory:U.targetDirectory??u,panelDirectory:u,tabId:U.id,foreign:!!U.targetDirectory,visible:K},U.id):s.jsx(xw,{}):U?.mode==="notes"?s.jsx(cn,{value:G,children:s.jsx(Ff,{visible:K})}):U?.mode==="workflows"?s.jsx(cn,{value:G,children:s.jsx(vy,{directory:u||null})}):null,ct=U?.mode==="file",vt=ct&&!!U?.targetPath&&ee,St=K&&U&&ye&&!vt&&!xr(U)?U.id:null;l.useEffect(()=>{if(!(!f||!St))return ic(()=>g(f,St),Ke)},[g,f,St]);const mt=X(re=>re.closeContextPanelTabs),yt=l.useCallback(re=>{if(!f)return null;const{id:Ze,index:pt,allIds:kt,close:Pt}=re,Zt=()=>mt(f,kt.filter(fs=>fs!==Ze)),is=kt.slice(0,pt),z=kt.slice(pt+1),qe=()=>mt(f,a?z:is),ut=()=>mt(f,a?is:z),Tt=()=>mt(f,kt),Vt=kt.length>1,Ht=a?pt===kt.length-1:pt===0,Mt=a?pt===0:pt===kt.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Cs,{onClick:Pt,children:[s.jsx(se,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),s.jsx(Tn,{}),s.jsxs(Cs,{onClick:Zt,disabled:!Vt,children:[s.jsx(se,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Cs,{onClick:qe,disabled:Ht,children:[s.jsx(se,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Cs,{onClick:ut,disabled:Mt,children:[s.jsx(se,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),s.jsx(Tn,{}),s.jsxs(Cs,{onClick:Tt,disabled:!Vt,children:[s.jsx(se,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),U?s.jsxs(s.Fragment,{children:[s.jsx(Tn,{}),s.jsx(mc,{mode:U.mode})]}):null]})},[U,mt,f,a,o]),lt=l.useCallback((re,Ze)=>{const pt=B.find(Pt=>Pt.id===re);if(!pt)return null;const kt=Xi({mode:pt.mode,label:Ar(pt.mode,d),from:t},Ze);return{finish:()=>kt.finish(f),cancel:kt.cancel}},[f,d,B,t]),[Nt,_t]=l.useState(null),ht=l.useCallback(re=>{if(!U||re.button!==0||re.pointerType==="touch"||re.target instanceof Element&&re.target.closest(Cv))return;const Ze=U.mode,pt=Ar(Ze,d),kt={x:re.clientX,y:re.clientY};let Pt=!1;const Zt=ut=>{const Tt={x:ut.clientX,y:ut.clientY};!Pt&&(Math.hypot(Tt.x-kt.x,Tt.y-kt.y)<jv||(Pt=Pd({mode:Ze,label:pt,from:t}),!Pt))||Rd(Tt)},is=()=>{window.removeEventListener("pointermove",Zt),window.removeEventListener("pointerup",z),window.removeEventListener("pointercancel",qe),window.removeEventListener("blur",qe)},z=()=>{is(),Pt&&Dd(f)},qe=()=>{is(),Pt&&ci()};window.addEventListener("pointermove",Zt),window.addEventListener("pointerup",z),window.addEventListener("pointercancel",qe),window.addEventListener("blur",qe)},[U,f,d,t]);l.useEffect(()=>{if(Nt)return Nt.addEventListener("pointerdown",ht),()=>Nt.removeEventListener("pointerdown",ht)},[ht,Nt]);const gt=s.jsxs("header",{ref:_t,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[ye?s.jsx(Oh,{items:xt,activeId:U?.id??null,onSelect:re=>{f&&E(f,re)},onClose:re=>{f&&g(f,re)},onReorder:(re,Ze)=>{f&&F(f,re,Ze)},onDoubleClickTab:re=>{f&&x(f,re)},layoutMode:"scrollable",variant:"default",tabContextMenu:yt,onTabDragOut:lt}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3 group-has-[[data-context-panel-toolbar]]/panel-header:hidden",children:[U?cl(U,W):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:U?Ar(U.mode,d):null})]}),s.jsx("div",{ref:Z,className:"flex min-w-0 flex-1 items-stretch ps-1.5 empty:hidden"})]}),s.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 self-start px-1.5",children:[U?.mode==="browser"?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&M(f)},className:"h-7 w-7 p-0",title:o("contextPanel.browser.newTab"),"aria-label":o("contextPanel.browser.newTab"),children:s.jsx(se,{name:"add",className:"h-3.5 w-3.5"})}):null,ct?["left","right"].map(re=>{const Ze=re===v;if(!Ze&&!$)return null;const pt=o(Ze?"contextRail.editorTree.toggle":"contextRail.editor.toggle");return s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:Ze?y:j,className:"h-7 w-7 p-0",title:pt,"aria-label":pt,"aria-pressed":Ze?_:ee,children:s.jsx(se,{name:re==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})},re)}):null,Y?null:s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:st,className:"h-7 w-7 p-0","aria-label":o(ie?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:ie?s.jsx(se,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(se,{name:"fullscreen",className:"h-3.5 w-3.5"})})}),s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Ws,{label:o(ie?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),shortcut:xs(Ts("toggle_context_panel_expanded",h),"")})})]}),s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:je,className:"h-7 w-7 p-0",title:o("contextPanel.actions.closePanel"),"aria-label":o("contextPanel.actions.closePanel"),children:s.jsx(se,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Dt=K?Pe?`calc(var(${e.sizeVariable}) + ${yn}px)`:`min(var(${e.sizeVariable}), 100%)`:ve?`${yn}px`:"0px",Kt=Pe?`${yn}px`:"0px";L.current=Pe;const Yt=t==="bottom"&&Kn(p,m,"left"),js=t==="bottom"&&(P&&!J||Kn(p,m,"right")),Wt=`${K}|${ie}|${ve}|${K&&Pe}|${K?fe:""}`,ds=l.useRef(Wt),us=l.useRef(J),Jt=us.current!==J;l.useLayoutEffect(()=>{us.current=J},[J]),l.useLayoutEffect(()=>{if(ds.current===Wt)return;ds.current=Wt;const re=C.current;!Jt&&!re&&Nc(n)},[Wt,Jt,n]),l.useLayoutEffect(()=>{C.current=!1});const Is=!Tr(K,Xn(K),U?.mode),rs={[e.sizeVariable]:`${q}px`,...r?{height:Dt,maxHeight:"100%"}:{width:Dt,maxWidth:"100%"},transitionDuration:Jt||Ne?"0ms":`${n}ms`,transitionTimingFunction:Rn},os=`calc(var(${e.sizeVariable}) - ${e.gutterSize})`,Ut=l.useRef(Dt);Ut.current=Dt;const Hs=l.useRef(os);return Hs.current=os,s.jsxs("aside",{ref:Ke,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":K?"true":"false",tabIndex:-1,className:Le("flex min-h-0 flex-col overflow-clip bg-background","isolate",r?"relative w-full flex-shrink-0":"relative h-full flex-shrink-0",r?"transition-[height]":"transition-[width]","motion-reduce:transition-none"),style:rs,children:[s.jsx("div",{ref:Ye,tabIndex:-1,className:"absolute size-0 overflow-hidden outline-none"}),t==="right"?s.jsx("div",{ref:Mh,className:Le("absolute inset-y-0 z-0 flex",Pe?"inset-s-0":"inset-e-0",J&&"invisible")}):null,K&&s.jsx("div",{className:e.handle,style:{marginInlineStart:Kt},onPointerDown:Oe,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),s.jsx("div",{ref:ce,"data-zone-card":"",className:Le("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(Yt?"ms-0":"ms-2"),t==="bottom"&&(js?"me-0":"me-1.5"),r?null:"h-[calc(100%-0.5rem)]","oc-panel-edge overflow-hidden rounded-[10px] bg-background",r?"transition-[height,opacity]":"transition-[width,opacity,margin-inline-start]",!K&&"opacity-0",Is&&"pointer-events-none select-none"),style:{...r?{height:os,width:`calc(100% - ${(Yt?0:.5)+(js?0:.375)}rem)`}:{width:os},...t==="right"?{marginInlineStart:`calc(0.5rem + ${Kt})`}:null,transitionDuration:Ne?"0ms":`${n}ms`,transitionTimingFunction:Rn},inert:Is||void 0,children:s.jsxs(Wc.Provider,{value:!0,children:[gt,s.jsx("div",{ref:Q,className:"relative min-h-0 flex-1 overflow-hidden",children:U&&Tv(U.mode)?jt:null})]})})]})},Iv=Qs({port:mo().int().positive(),url:Ns().min(1),command:Ns(),directory:Ns().min(1).optional()}),Pv=t=>{const e=Qs({servers:md(Hb())}).safeParse(t);return e.success?e.data.servers.flatMap(n=>{const r=Iv.safeParse(n);return r.success?[r.data]:[]}):null},Rv=async(t,e)=>{try{const n=await zs("/api/dev-servers",{signal:t,directory:e});if(!n.ok)return{kind:"unavailable"};const r=Pv(await n.json());return r?{kind:"ready",servers:r}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},Dv=async t=>{try{const e=await zs("/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}},Av=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}},_v=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const o=Av(r);o!==null&&!n.has(o)&&n.set(o,r)}return e?e.map(r=>{const o=n.get(r.port);return{url:o??r.url,port:r.port,announced:o!==void 0,directory:r.directory}}).sort((r,o)=>r.announced!==o.announced?r.announced?-1:1:r.port-o.port):[...n.entries()].map(([r,o])=>({url:o,port:r,announced:!0})).sort((r,o)=>r.port-o.port)},Ov=(t,e)=>e===t||e.startsWith(t.endsWith("/")?t:`${t}/`),ul=(t,e)=>{if(!e)return null;let n=null;for(const r of t)Ov(r.path,e)&&(!n||r.path.length>n.path.length)&&(n=r);return n},Mv=t=>t.slice(t.lastIndexOf("/")+1)||t,Fv=({candidates:t,folders:e,directory:n})=>{const r=e.flatMap(c=>{const d=Xt(c.path),f=Xt(c.projectPath);return d&&f?[{path:d,projectPath:f}]:[]}),o=Xt(n),i=o?{path:o,projectPath:ul(r,o)?.projectPath??o}:null,a=i?[...r,i]:r;return t.map(c=>{const d=Xt(c.directory),f=ul(a,d),p=c.announced?0:f&&i&&f.path===i.path?1:f&&i&&f.projectPath===i.projectPath?2:3;return{server:{...c,folderName:f?Mv(f.path):null,outsideWork:d!==null&&f===null&&!c.announced},rank:p}}).sort((c,d)=>c.rank-d.rank||c.server.port-d.server.port).map(c=>c.server)},Lv=t=>({sessionId:t.sessionId,directory:t.directory?cs(t.directory):null}),$v=2e3,Bv=Qs({title:Ns(),settled:ar()}),zv=4e4,Wv=50,Yn=400,ms=new Map,Rs=new Map;let ui=null,fi=null;const cr=new Map;let Fs=null,Xs=null,Jn=null;const Ls=async t=>{try{const e=await zs("/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}},Uv=async(t,e)=>{try{const n=await zs("/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)}},Md=async(t,e=$v)=>{const n=Date.now()+e;for(;!ms.has(t)&&Date.now()<n;)await new Promise(r=>setTimeout(r,Wv));return ms.get(t)??null},Hr=t=>ms.has(t)||Rs.has(t),_n=t=>ms.get(t)??Rs.get(t)??null,pi=()=>[...ms.values(),...[...Rs.values()].filter(t=>!ms.has(t.tabId))],Qi=t=>{const e=fi?_n(fi):null,n=e?.directory===ui?e:null;if(!t.sessionId){if(n)return n.tabId;const i=pi().filter(c=>c.directory===ui),a=i.filter(c=>ms.has(c.tabId)),u=a.length>0?a:i;return u.length>0?u[u.length-1].tabId:null}if(n?.ownerSessionId===t.sessionId)return n.tabId;const r=cr.get(t.sessionId);if(r&&_n(r)?.ownerSessionId===t.sessionId)return r;const o=pi().filter(i=>i.ownerSessionId===t.sessionId);return o.length>0?o[o.length-1].tabId:n&&n.ownerSessionId===null&&(!t.directory||n.directory===t.directory)?n.tabId:null},Vv=t=>{const e=Qi(t);return e&&_n(e)?.ownerSessionId===t.sessionId?e:null},Hv=(t,e)=>{t.sessionId&&_n(e)?.ownerSessionId===t.sessionId&&cr.set(t.sessionId,e)},Fd=async t=>{const e=ms.get(t);if(e)return e;const n=Rs.get(t);return n?(n.wake(),Md(t)):null},Ld=t=>{const e=Qi(t);return pi().filter(n=>!t.sessionId||!t.directory||n.ownerSessionId===t.sessionId||n.directory===t.directory).map(n=>{let r={title:"",url:""};try{r=n.describe()}catch{}const o=n.ownerSessionId===null?"user":n.ownerSessionId===t.sessionId?"you":"another session";return{id:n.tabId,title:r.title,url:r.url,owner:o,active:n.tabId===e}})},$d=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,Bd=t=>`There is no browser tab with id ${t}. Call browser.snapshot to list the open tabs, or omit tabId to use this session's own tab.`,qv=t=>{const e=Ld(t);return"This session has no browser tab of its own, and the user is not looking at a tab of theirs in this session's project. Nothing was changed. Open the page with browser.open, or pass tabId to work in a tab the user points you to."+(e.length>0?` Open tabs:
5
+ `);return s.jsxs("div",{className:Le("min-w-0",r?"flex items-baseline gap-2":"flex flex-col gap-0.5"),children:[s.jsx("dt",{className:"shrink-0 typography-micro text-muted-foreground",dir:"ltr",children:e}),s.jsx("dd",{className:"min-w-0 typography-meta",children:s.jsx(go,{node:n})})]},e)}function qw(t,e){return s.jsx("div",{className:"oc-tile-inset rounded-lg px-3 py-2",children:s.jsx(go,{node:t})},e)}function Kw(t,e){return s.jsx("li",{className:"typography-meta",children:s.jsx(go,{node:t})},e)}function Gw(t){return!t}const Ed=t=>t.slice(t.indexOf("/")+1),Gi=t=>{const e=$e.c(7),{start:n,end:r,className:o}=t,i=mh(n!==void 0&&r===void 0);if(n===void 0)return null;let a;e[0]!==o?(a=Le("shrink-0 whitespace-nowrap tabular-nums",o),e[0]=o,e[1]=a):a=e[1];const u=(r??i)-n;let c;e[2]!==u?(c=hh(u),e[2]=u,e[3]=c):c=e[3];let d;return e[4]!==a||e[5]!==c?(d=s.jsx("span",{className:a,dir:"auto",children:c}),e[4]=a,e[5]=c,e[6]=d):d=e[6],d},Zw=t=>{const e=t.flatMap(o=>o.startedAt===void 0||o.replayed?[]:[o.startedAt]);if(e.length===0)return{start:void 0,end:void 0};const n=t.some(o=>o.state==="running"||o.state==="queued"),r=t.flatMap(o=>o.endedAt===void 0?[]:[o.endedAt]);return{start:Math.min(...e),end:n?void 0:Math.max(...r,...e)}},Xw=t=>{const e=$e.c(18),{run:n,groups:r}=t,{t:o}=at();let i,a,u,c,d,f;if(e[0]!==r||e[1]!==n||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{const m=r.filter(sy);if(m.length===0){f=null;break e}i=hs,a="overlay-scrollbar-wrapper--no-gutter",u=!1,c="flex gap-1.5 pb-1";let h;e[9]!==n||e[10]!==o?(h=b=>{const g=b.agents.length,x=Zw(b.agents),w=n.state==="running"&&n.currentPhase===b.title;return s.jsxs("div",{className:"oc-tile min-w-[7.5rem] flex-1 rounded-lg px-2.5 py-2",children:[s.jsx("div",{className:Le("truncate typography-meta",w?"font-semibold text-foreground":"text-foreground"),dir:"auto",children:b.title}),s.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 typography-micro text-muted-foreground",children:[g>0?s.jsx("span",{className:"tabular-nums",dir:"auto",children:`${b.done}/${g}`}):s.jsx("span",{children:o("workflows.panel.phase.waiting")}),g>0?s.jsx(Gi,{start:x.start,end:x.end,className:"ms-auto"}):null]}),s.jsx("div",{className:"oc-tile-inset mt-1.5 h-1 overflow-hidden rounded-full",children:g>0?s.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.round(b.done/g*100)}%`,background:b.failed>0?"var(--status-warning)":"var(--status-success)"}}):null})]},b.title)},e[9]=n,e[10]=o,e[11]=h):h=e[11],d=m.map(h)}e[0]=r,e[1]=n,e[2]=o,e[3]=i,e[4]=a,e[5]=u,e[6]=c,e[7]=d,e[8]=f}else i=e[3],a=e[4],u=e[5],c=e[6],d=e[7],f=e[8];if(f!==Symbol.for("react.early_return_sentinel"))return f;let p;return e[12]!==i||e[13]!==a||e[14]!==u||e[15]!==c||e[16]!==d?(p=s.jsx(i,{outerClassName:a,fillContainer:u,className:c,children:d}),e[12]=i,e[13]=a,e[14]=u,e[15]=c,e[16]=d,e[17]=p):p=e[17],p},Yw=t=>{const e=$e.c(30),{run:n,agent:r,onOpenSession:o}=t,{t:i}=at(),[a,u]=l.useState(null),[c,d]=l.useState(!1),[f,p]=l.useState(!1);let m;e[0]!==r.key||e[1]!==n.id?(m=()=>{let E=!0;return d(!1),gh(n.id,r.key).then(F=>{E&&u(F)}).catch(()=>{E&&d(!0)}),()=>{E=!1}},e[0]=r.key,e[1]=n.id,e[2]=m):m=e[2];let h;e[3]!==r.key||e[4]!==r.state||e[5]!==n.id?(h=[r.key,r.state,n.id],e[3]=r.key,e[4]=r.state,e[5]=n.id,e[6]=h):h=e[6],l.useEffect(m,h);let b;e[7]!==r.error||e[8]!==r.state?(b=r.error?s.jsx("p",{className:"typography-meta",style:{color:r.state==="failed"?"var(--status-error)":void 0},children:r.error}):null,e[7]=r.error,e[8]=r.state,e[9]=b):b=e[9];let g;e[10]!==c||e[11]!==i?(g=c?s.jsx("p",{className:"typography-meta text-muted-foreground",children:i("workflows.panel.agent.loadFailed")}):null,e[10]=c,e[11]=i,e[12]=g):g=e[12];let x;e[13]!==a||e[14]!==c||e[15]!==i?(x=!a&&!c?s.jsxs("p",{className:"typography-meta text-muted-foreground",children:[i("workflows.panel.agent.loading"),s.jsx(zi,{})]}):null,e[13]=a,e[14]=c,e[15]=i,e[16]=x):x=e[16];let w;e[17]!==a||e[18]!==f||e[19]!==i?(w=a?s.jsxs(s.Fragment,{children:[s.jsxs("section",{children:[s.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:i("workflows.panel.agent.answer")}),s.jsx("div",{className:"mt-1",children:a.result===void 0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:i("workflows.panel.agent.noAnswer")}):s.jsx(Nd,{answer:a.result})})]}),s.jsxs("section",{children:[s.jsxs("button",{type:"button",onClick:()=>p(ny),"aria-expanded":f,className:"flex items-center gap-1 typography-micro font-medium text-muted-foreground hover:text-foreground",children:[s.jsx(se,{name:"arrow-right-s",className:Le("size-3.5 transition-transform",f&&"rotate-90 rtl:-rotate-90")}),i("workflows.panel.agent.prompt")]}),f?s.jsx(hs,{as:"pre",dir:"auto",outerClassName:"mt-1 max-h-72",className:"whitespace-pre-wrap break-words font-mono typography-micro text-foreground",disableHorizontal:!0,children:a.prompt}):null]})]}):null,e[17]=a,e[18]=f,e[19]=i,e[20]=w):w=e[20];let T;e[21]!==o||e[22]!==i?(T=o?s.jsx("div",{children:s.jsxs(dt,{type:"button",size:"xs",variant:"ghost",onClick:o,children:[s.jsx(se,{name:"chat-4",className:"size-3.5"}),i("workflows.panel.agent.openSession")]})}):null,e[21]=o,e[22]=i,e[23]=T):T=e[23];let k;return e[24]!==b||e[25]!==g||e[26]!==x||e[27]!==w||e[28]!==T?(k=s.jsxs("div",{className:"oc-tile mb-1.5 ms-5 flex flex-col gap-2 rounded-lg px-3 py-2.5",children:[b,g,x,w,T]}),e[24]=b,e[25]=g,e[26]=x,e[27]=w,e[28]=T,e[29]=k):k=e[29],k},Jw=t=>{const e=$e.c(57),{run:n,agent:r,showModel:o,columns:i,open:a,onToggle:u,onOpenSession:c}=t,{t:d}=at();let f,p,m,h,b,g,x,w,T,k,E;if(e[0]!==r||e[1]!==i.tokens||e[2]!==u||e[3]!==a||e[4]!==o||e[5]!==d){const y=fh(r.state),N=ph(r);f="button",h=u,b=a,g=r.label,x="flex h-7 w-full min-w-0 items-center gap-2 rounded-md text-start typography-meta text-foreground/80 hover:text-foreground";const j=y.icon,v=y.color?{color:y.color}:void 0,M=d(y.labelKey);e[17]!==y||e[18]!==v||e[19]!==M?(w=s.jsx(se,{name:j,className:"size-3.5 shrink-0",style:v,"aria-label":M}),e[17]=y,e[18]=v,e[19]=M,e[20]=w):w=e[20],e[21]!==r.label?(T=s.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:r.label}),e[21]=r.label,e[22]=T):T=e[22],e[23]!==r.replayed||e[24]!==d?(k=r.replayed?s.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:d("chat.workflow.agent.reused")}):null,e[23]=r.replayed,e[24]=d,e[25]=k):k=e[25],e[26]!==r.model||e[27]!==o?(E=o&&r.model?s.jsx("span",{className:"oc-tile-inset max-w-[9rem] shrink-0 truncate rounded-full px-1.5 typography-micro text-muted-foreground",title:r.model,dir:"ltr",children:Ed(r.model)}):null,e[26]=r.model,e[27]=o,e[28]=E):E=e[28];const W=r.replayed?void 0:r.startedAt;e[29]!==r.endedAt||e[30]!==W?(p=s.jsx(Gi,{start:W,end:r.endedAt,className:"min-w-12 text-end typography-micro text-muted-foreground"}),e[29]=r.endedAt,e[30]=W,e[31]=p):p=e[31],m=i.tokens?s.jsx("span",{className:"min-w-12 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"auto",children:N===null||r.replayed?"":$i(N)}):null,e[0]=r,e[1]=i.tokens,e[2]=u,e[3]=a,e[4]=o,e[5]=d,e[6]=f,e[7]=p,e[8]=m,e[9]=h,e[10]=b,e[11]=g,e[12]=x,e[13]=w,e[14]=T,e[15]=k,e[16]=E}else f=e[6],p=e[7],m=e[8],h=e[9],b=e[10],g=e[11],x=e[12],w=e[13],T=e[14],k=e[15],E=e[16];let F;e[32]!==r.replayed||e[33]!==r.usage||e[34]!==i.cost?(F=i.cost?s.jsx("span",{className:"min-w-14 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"ltr",children:r.usage&&!r.replayed&&r.usage.cost>0?Bi(r.usage.cost):""}):null,e[32]=r.replayed,e[33]=r.usage,e[34]=i.cost,e[35]=F):F=e[35];let _;e[36]!==f||e[37]!==p||e[38]!==m||e[39]!==F||e[40]!==h||e[41]!==b||e[42]!==g||e[43]!==x||e[44]!==w||e[45]!==T||e[46]!==k||e[47]!==E?(_=s.jsxs("button",{type:f,onClick:h,"aria-expanded":b,title:g,className:x,children:[w,T,k,E,p,m,F]}),e[36]=f,e[37]=p,e[38]=m,e[39]=F,e[40]=h,e[41]=b,e[42]=g,e[43]=x,e[44]=w,e[45]=T,e[46]=k,e[47]=E,e[48]=_):_=e[48];let A;e[49]!==r||e[50]!==c||e[51]!==a||e[52]!==n?(A=a?s.jsx(Yw,{run:n,agent:r,onOpenSession:c}):null,e[49]=r,e[50]=c,e[51]=a,e[52]=n,e[53]=A):A=e[53];let D;return e[54]!==_||e[55]!==A?(D=s.jsxs(s.Fragment,{children:[_,A]}),e[54]=_,e[55]=A,e[56]=D):D=e[56],D},Qw=(t,e)=>{const n=uh(t);if(n.measured===0)return null;const r=[];return e.tokens&&r.push($i(n.tokens)),e.cost&&n.cost>0&&r.push(Bi(n.cost)),r.length>0?r.join(" · "):null},ey=t=>{const e=new Set(t.map(r=>r.model??null)),[n]=e;return e.size===1&&n?Ed(n):null},ty=t=>{const e=$e.c(51),{run:n,directory:r}=t,{t:o}=at();let i;e[0]!==n?(i=lh(n),e[0]=n,e[1]=i):i=e[1];const a=i,u=ch(r),[c,d]=l.useState(ry),[f,p]=l.useState(oy);let m,h,b,g,x,w;if(e[2]!==a||e[3]!==c||e[4]!==u||e[5]!==n||e[6]!==o||e[7]!==f){const E=dh(n),F=E.measured>0,_=E.cost>0;let A,D,y;if(e[14]!==a||e[15]!==c||e[16]!==u||e[17]!==n||e[18]!==o||e[19]!==F||e[20]!==_||e[21]!==f){const N={tokens:F,cost:_},j=n.agents.filter(iy).length,v=ay;x="flex h-full min-h-0 flex-col";let M;e[28]!==a||e[29]!==n?(M=s.jsx(Xw,{run:n,groups:a}),e[28]=a,e[29]=n,e[30]=M):M=e[30];const W=a.map(G=>{if(G.agents.length===0)return null;const O=G.title??"",Z=G.done+G.failed===G.agents.length,B=(n.state==="running"&&Z)===f.has(O),oe=ey(G.agents),H=Qw(G.agents,N);return s.jsxs("section",{className:"mt-3",children:[s.jsxs("button",{type:"button",onClick:()=>v(p,O),"aria-expanded":B,className:"flex h-7 w-full min-w-0 items-center gap-1.5 text-start typography-micro font-medium text-muted-foreground hover:text-foreground",children:[s.jsx(se,{name:"arrow-right-s",className:Le("size-3.5 shrink-0 transition-transform",B&&"rotate-90 rtl:-rotate-90")}),s.jsx("span",{className:"min-w-0 truncate",dir:"auto",children:G.title??o("chat.workflow.phase.unphased")}),oe?s.jsx("span",{className:"min-w-0 truncate font-normal",dir:"ltr",children:`· ${oe}`}):null,H?s.jsx("span",{className:"ms-auto shrink-0 tabular-nums font-normal",dir:"ltr",children:H}):null,s.jsx("span",{className:Le("shrink-0 tabular-nums font-normal",!H&&"ms-auto"),dir:"auto",children:H?`· ${G.done}/${G.agents.length}`:`${G.done}/${G.agents.length}`})]}),B?G.agents.map(P=>{const te=P.sessionId;return s.jsx(Jw,{run:n,agent:P,showModel:oe===null,columns:N,open:c.has(P.key),onToggle:()=>v(d,P.key),onOpenSession:te?()=>u(te,P.label):null},P.key)}):null]},O)});e[31]!==M||e[32]!==W?(w=s.jsxs(hs,{outerClassName:"min-h-0 flex-1",className:"px-3 py-3",disableHorizontal:!0,children:[M,W]}),e[31]=M,e[32]=W,e[33]=w):w=e[33],m="flex shrink-0 flex-wrap items-center gap-x-1.5 border-t border-edge px-3 py-2 typography-micro text-muted-foreground",A="tabular-nums",D="auto",y=o("workflows.panel.summary.agents",{done:j,total:n.agents.length}),e[14]=a,e[15]=c,e[16]=u,e[17]=n,e[18]=o,e[19]=F,e[20]=_,e[21]=f,e[22]=A,e[23]=D,e[24]=y,e[25]=m,e[26]=x,e[27]=w}else A=e[22],D=e[23],y=e[24],m=e[25],x=e[26],w=e[27];e[34]!==A||e[35]!==D||e[36]!==y?(h=s.jsx("span",{className:A,dir:D,children:y}),e[34]=A,e[35]=D,e[36]=y,e[37]=h):h=e[37],e[38]!==n.endedAt||e[39]!==n.startedAt||e[40]!==n.state?(b=n.startedAt!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx(Gi,{start:n.startedAt,end:n.state==="running"?void 0:n.endedAt??n.startedAt})]}):null,e[38]=n.endedAt,e[39]=n.startedAt,e[40]=n.state,e[41]=b):b=e[41],g=E.measured>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{className:"tabular-nums",dir:"auto",children:o("workflows.panel.summary.tokens",{tokens:$i(E.tokens)})}),E.cost>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{className:"tabular-nums",dir:"ltr",children:Bi(E.cost)})]}):null]}):null,e[2]=a,e[3]=c,e[4]=u,e[5]=n,e[6]=o,e[7]=f,e[8]=m,e[9]=h,e[10]=b,e[11]=g,e[12]=x,e[13]=w}else m=e[8],h=e[9],b=e[10],g=e[11],x=e[12],w=e[13];let T;e[42]!==m||e[43]!==h||e[44]!==b||e[45]!==g?(T=s.jsxs("div",{className:m,children:[h,b,g]}),e[42]=m,e[43]=h,e[44]=b,e[45]=g,e[46]=T):T=e[46];let k;return e[47]!==x||e[48]!==w||e[49]!==T?(k=s.jsxs("div",{className:x,children:[w,T]}),e[47]=x,e[48]=w,e[49]=T,e[50]=k):k=e[50],k};function sy(t){return t.title!==null}function ny(t){return!t}function ry(){return new Set}function oy(){return new Set}function iy(t){return t.state==="completed"}function ay(t,e){return t(n=>{const r=new Set(n);return r.has(e)?r.delete(e):r.add(e),r})}const ly={steps:["data-workflows-header-compact","data-workflows-header-tight","data-workflows-header-narrow"]},cy=[{id:"agents",icon:"flow-chart",labelKey:"workflows.panel.view.agents"},{id:"log",icon:"file-list-2",labelKey:"workflows.panel.view.log"},{id:"result",icon:"checkbox-circle",labelKey:"workflows.panel.view.result"},{id:"script",icon:"code-sslash",labelKey:"workflows.panel.view.script"}],dy=1500,uy=(t,e)=>{const n=$e.c(11),[r,o]=l.useState(null),[i,a]=l.useState(null),u=l.useRef(null),c=e!=="agents",d=e==="log"&&t.state==="running"?t.logs.at(-1)?.at??0:0;let f;n[0]!==t.id||n[1]!==c?(f=()=>{if(!c)return;let g=!0;const x=u.current?.runId===t.id?u.current.at:0,w=Math.max(0,x+dy-Date.now()),T=setTimeout(()=>{u.current={runId:t.id,at:Date.now()},Th(t.id).then(k=>{g&&(o(k),a(null))}).catch(()=>{g&&a(t.id)})},w);return()=>{g=!1,clearTimeout(T)}},n[0]=t.id,n[1]=c,n[2]=f):f=n[2];let p;n[3]!==d||n[4]!==t.id||n[5]!==t.state||n[6]!==c?(p=[d,t.id,t.state,c],n[3]=d,n[4]=t.id,n[5]=t.state,n[6]=c,n[7]=p):p=n[7],l.useEffect(f,p);const m=r?.runId===t.id?r:null,h=i===t.id;let b;return n[8]!==m||n[9]!==h?(b={detail:m,failed:h},n[8]=m,n[9]=h,n[10]=b):b=n[10],b},fy=t=>new Intl.DateTimeFormat(Bc(),{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(t),py=t=>{const e=$e.c(8),{run:n,detail:r}=t,{t:o}=at(),i=r?.logs??n.logs;if(i.length===0){let c;e[0]!==o?(c=o("workflows.panel.log.empty"),e[0]=o,e[1]=c):c=e[1];let d;return e[2]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[2]=c,e[3]=d):d=e[3],d}let a;e[4]!==i?(a=i.map(ky),e[4]=i,e[5]=a):a=e[5];let u;return e[6]!==a?(u=s.jsx("ol",{className:"flex flex-col gap-1 px-3 py-3",children:a}),e[6]=a,e[7]=u):u=e[7],u},my=t=>{const e=$e.c(24),{run:n,detail:r,failed:o}=t,{t:i}=at();if(n.error&&(n.state==="failed"||n.state==="stopped")){const c=n.state==="failed"?"var(--status-error)":void 0;let d;e[0]!==c?(d={color:c},e[0]=c,e[1]=d):d=e[1];let f;return e[2]!==n.error||e[3]!==d?(f=s.jsx("p",{className:"px-4 py-6 typography-meta",style:d,children:n.error}),e[2]=n.error,e[3]=d,e[4]=f):f=e[4],f}if(n.state==="awaiting-approval"||n.state==="running"||n.state==="declined"){let c;e[5]!==i?(c=i("workflows.panel.result.pending"),e[5]=i,e[6]=c):c=e[6];let d;return e[7]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[7]=c,e[8]=d):d=e[8],d}if(o&&!r){let c;e[9]!==i?(c=i("workflows.panel.detail.loadFailed"),e[9]=i,e[10]=c):c=e[10];let d;return e[11]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[11]=c,e[12]=d):d=e[12],d}if(!r){let c;e[13]!==i?(c=i("workflows.panel.agent.loading"),e[13]=i,e[14]=c):c=e[14];let d;e[15]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(zi,{}),e[15]=d):d=e[15];let f;return e[16]!==c?(f=s.jsxs("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:[c,d]}),e[16]=c,e[17]=f):f=e[17],f}const{result:a}=r;if(!a||a.kind==="json"&&a.value===null){let c;e[18]!==i?(c=i("workflows.panel.result.none"),e[18]=i,e[19]=c):c=e[19];let d;return e[20]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[20]=c,e[21]=d):d=e[21],d}let u;return e[22]!==a?(u=s.jsx("div",{className:"px-4 py-3",children:s.jsx(Nd,{answer:a})}),e[22]=a,e[23]=u):u=e[23],u},hy=t=>{const e=$e.c(16),{detail:n,failed:r}=t,{t:o}=at();if(!n){let p;e[0]!==r||e[1]!==o?(p=r?o("workflows.panel.detail.loadFailed"):s.jsxs(s.Fragment,{children:[o("workflows.panel.agent.loading"),s.jsx(zi,{})]}),e[0]=r,e[1]=o,e[2]=p):p=e[2];let m;return e[3]!==p?(m=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:p}),e[3]=p,e[4]=m):m=e[4],m}const i=n.args;let a;e[5]!==i?(a=i!=null&&JSON.stringify(i)!=="{}",e[5]=i,e[6]=a):a=e[6];const u=a;let c;e[7]!==i||e[8]!==u||e[9]!==o?(c=u?s.jsxs("section",{children:[s.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:o("workflows.panel.script.args")}),s.jsx(hs,{as:"pre",dir:"ltr",outerClassName:"overlay-scrollbar-wrapper--no-gutter oc-tile mt-1 rounded-lg",fillContainer:!1,className:"px-3 py-2 font-mono typography-micro text-foreground",children:JSON.stringify(i,null,2)})]}):null,e[7]=i,e[8]=u,e[9]=o,e[10]=c):c=e[10];let d;e[11]!==n.script?(d=s.jsx(hs,{as:"pre",dir:"ltr",outerClassName:"overlay-scrollbar-wrapper--no-gutter oc-tile rounded-lg",fillContainer:!1,className:"px-3 py-2 font-mono typography-micro leading-relaxed text-foreground",children:n.script}),e[11]=n.script,e[12]=d):d=e[12];let f;return e[13]!==c||e[14]!==d?(f=s.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3",children:[c,d]}),e[13]=c,e[14]=d,e[15]=f):f=e[15],f},gy=t=>{const e=$e.c(63),{run:n}=t,{t:r}=at(),{pending:o,act:i}=Ch(),a=o===n.id;if(n.state==="awaiting-approval"){let u;e[0]!==i||e[1]!==n.id?(u=()=>i(n.id,"approve"),e[0]=i,e[1]=n.id,e[2]=u):u=e[2];let c;e[3]!==r?(c=r("chat.workflow.action.run"),e[3]=r,e[4]=c):c=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(se,{name:"play",className:"size-3.5"}),e[5]=d):d=e[5];let f;e[6]!==r?(f=r("chat.workflow.action.run"),e[6]=r,e[7]=f):f=e[7];let p;e[8]!==f?(p=s.jsx("span",{className:"workflows-header__action-label",children:f}),e[8]=f,e[9]=p):p=e[9];let m;e[10]!==a||e[11]!==u||e[12]!==c||e[13]!==p?(m=s.jsxs(dt,{type:"button",size:"sm",disabled:a,onClick:u,"aria-label":c,children:[d,p]}),e[10]=a,e[11]=u,e[12]=c,e[13]=p,e[14]=m):m=e[14];let h;e[15]!==i||e[16]!==n.id?(h=()=>i(n.id,"decline"),e[15]=i,e[16]=n.id,e[17]=h):h=e[17];let b;e[18]!==r?(b=r("chat.workflow.action.decline"),e[18]=r,e[19]=b):b=e[19];let g;e[20]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(se,{name:"close",className:"size-3.5"}),e[20]=g):g=e[20];let x;e[21]!==r?(x=r("chat.workflow.action.decline"),e[21]=r,e[22]=x):x=e[22];let w;e[23]!==x?(w=s.jsx("span",{className:"workflows-header__action-label",children:x}),e[23]=x,e[24]=w):w=e[24];let T;e[25]!==a||e[26]!==w||e[27]!==h||e[28]!==b?(T=s.jsxs(dt,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:h,"aria-label":b,children:[g,w]}),e[25]=a,e[26]=w,e[27]=h,e[28]=b,e[29]=T):T=e[29];let k;return e[30]!==T||e[31]!==m?(k=s.jsxs(s.Fragment,{children:[m,T]}),e[30]=T,e[31]=m,e[32]=k):k=e[32],k}if(n.state==="running"){let u;e[33]!==i||e[34]!==n.id?(u=()=>i(n.id,"stop"),e[33]=i,e[34]=n.id,e[35]=u):u=e[35];let c;e[36]!==r?(c=r("chat.workflow.action.stop"),e[36]=r,e[37]=c):c=e[37];let d;e[38]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(se,{name:"stop",className:"size-3.5"}),e[38]=d):d=e[38];let f;e[39]!==r?(f=r("chat.workflow.action.stop"),e[39]=r,e[40]=f):f=e[40];let p;e[41]!==f?(p=s.jsx("span",{className:"workflows-header__action-label",children:f}),e[41]=f,e[42]=p):p=e[42];let m;return e[43]!==a||e[44]!==u||e[45]!==c||e[46]!==p?(m=s.jsxs(dt,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:u,"aria-label":c,children:[d,p]}),e[43]=a,e[44]=u,e[45]=c,e[46]=p,e[47]=m):m=e[47],m}if(n.state==="failed"||n.state==="stopped"){let u;e[48]!==i||e[49]!==n.id?(u=()=>i(n.id,"resume"),e[48]=i,e[49]=n.id,e[50]=u):u=e[50];let c;e[51]!==r?(c=r("chat.workflow.action.resume"),e[51]=r,e[52]=c):c=e[52];let d;e[53]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(se,{name:"restart",className:"size-3.5"}),e[53]=d):d=e[53];let f;e[54]!==r?(f=r("chat.workflow.action.resume"),e[54]=r,e[55]=f):f=e[55];let p;e[56]!==f?(p=s.jsx("span",{className:"workflows-header__action-label",children:f}),e[56]=f,e[57]=p):p=e[57];let m;return e[58]!==a||e[59]!==u||e[60]!==c||e[61]!==p?(m=s.jsxs(dt,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:u,"aria-label":c,children:[d,p]}),e[58]=a,e[59]=u,e[60]=c,e[61]=p,e[62]=m):m=e[62],m}return null},by=()=>{const t=$e.c(2),e=ps(jy);let n;return t[0]!==e?(n={get:r=>e.get(r)?.title},t[0]=e,t[1]=n):n=t[1],n},sl=t=>{const e=$e.c(31),{run:n,selected:r,caption:o,onSelect:i}=t,{t:a}=at();let u,c,d,f,p,m,h;if(e[0]!==i||e[1]!==n.state||e[2]!==a){const E=$c(n.state);c=Gt,h=i,u=se,d=E.icon,f="size-3.5 shrink-0",p=E.color?{color:E.color}:void 0,m=a(E.labelKey),e[0]=i,e[1]=n.state,e[2]=a,e[3]=u,e[4]=c,e[5]=d,e[6]=f,e[7]=p,e[8]=m,e[9]=h}else u=e[3],c=e[4],d=e[5],f=e[6],p=e[7],m=e[8],h=e[9];let b;e[10]!==u||e[11]!==d||e[12]!==f||e[13]!==p||e[14]!==m?(b=s.jsx(u,{name:d,className:f,style:p,"aria-label":m}),e[10]=u,e[11]=d,e[12]=f,e[13]=p,e[14]=m,e[15]=b):b=e[15];let g;e[16]!==n.name?(g=s.jsx("span",{className:"truncate",dir:"auto",children:n.name}),e[16]=n.name,e[17]=g):g=e[17];let x;e[18]!==o?(x=o?s.jsx("span",{className:"truncate typography-micro text-muted-foreground",dir:"auto",children:o}):null,e[18]=o,e[19]=x):x=e[19];let w;e[20]!==g||e[21]!==x?(w=s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[g,x]}),e[20]=g,e[21]=x,e[22]=w):w=e[22];let T;e[23]!==r?(T=r?s.jsx(se,{name:"check",className:"size-3.5 shrink-0"}):null,e[23]=r,e[24]=T):T=e[24];let k;return e[25]!==c||e[26]!==T||e[27]!==h||e[28]!==b||e[29]!==w?(k=s.jsxs(c,{onSelect:h,children:[b,w,T]}),e[25]=c,e[26]=T,e[27]=h,e[28]=b,e[29]=w,e[30]=k):k=e[30],k},xy=t=>{const e=$e.c(56),{runs:n,selected:r,sessionId:o,sessionTitles:i,saved:a,onSelect:u,onRunSaved:c,onDelete:d}=t,{t:f}=at();let p;e[0]!==r.state?(p=$c(r.state),e[0]=r.state,e[1]=p):p=e[1];const m=p;let h,b,g,x,w,T,k;if(e[2]!==m.color||e[3]!==m.icon||e[4]!==u||e[5]!==n||e[6]!==r.id||e[7]!==r.name||e[8]!==o||e[9]!==i||e[10]!==f){const D=n.slice().reverse();let y;e[18]!==o?(y=B=>B.parentSessionId===o,e[18]=o,e[19]=y):y=e[19];const N=D.filter(y);let j;e[20]!==o?(j=B=>B.parentSessionId!==o,e[20]=o,e[21]=j):j=e[21];const v=D.filter(j);b=pn;let M;e[22]!==f?(M=f("workflows.panel.runPicker"),e[22]=f,e[23]=M):M=e[23];let W;e[24]===Symbol.for("react.memo_cache_sentinel")?(W=Le(jh(),"max-w-[14rem] shrink-0"),e[24]=W):W=e[24];let G;e[25]!==m.color?(G=m.color?{color:m.color}:void 0,e[25]=m.color,e[26]=G):G=e[26];let O;e[27]!==m.icon||e[28]!==G?(O=s.jsx(se,{name:m.icon,className:"size-3.5",style:G}),e[27]=m.icon,e[28]=G,e[29]=O):O=e[29];let Z;e[30]!==r.name?(Z=s.jsx("span",{className:"workflows-header__run-name min-w-0 truncate",dir:"auto",children:r.name}),e[30]=r.name,e[31]=Z):Z=e[31];let Q;e[32]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(se,{name:"arrow-down-s",className:"size-4"}),e[32]=Q):Q=e[32],e[33]!==O||e[34]!==Z||e[35]!==M?(k=s.jsx(mn,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":M,className:W,children:[O,Z,Q]})}),e[33]=O,e[34]=Z,e[35]=M,e[36]=k):k=e[36],h=hn,g="start",x="max-h-[min(var(--available-height),28rem)] w-[18rem] max-w-[calc(100vw-2rem)] overflow-y-auto",w=N.length>0?s.jsxs(s.Fragment,{children:[s.jsx(Er,{children:f("workflows.panel.picker.thisSession")}),N.map(B=>s.jsx(sl,{run:B,selected:B.id===r.id,onSelect:()=>u(B.id)},B.id))]}):null,T=v.length>0?s.jsxs(s.Fragment,{children:[N.length>0?s.jsx(un,{}):null,s.jsx(Er,{children:f("workflows.panel.picker.otherSessions")}),v.map(B=>s.jsx(sl,{run:B,selected:B.id===r.id,caption:i.get(B.parentSessionId)||f("workflows.panel.picker.untitledSession"),onSelect:()=>u(B.id)},B.id))]}):null,e[2]=m.color,e[3]=m.icon,e[4]=u,e[5]=n,e[6]=r.id,e[7]=r.name,e[8]=o,e[9]=i,e[10]=f,e[11]=h,e[12]=b,e[13]=g,e[14]=x,e[15]=w,e[16]=T,e[17]=k}else h=e[11],b=e[12],g=e[13],x=e[14],w=e[15],T=e[16],k=e[17];let E;e[37]!==c||e[38]!==a||e[39]!==f?(E=a.length>0?s.jsxs(s.Fragment,{children:[s.jsx(un,{}),s.jsx(Er,{children:f("workflows.panel.picker.saved")}),a.map(D=>s.jsxs(Gt,{disabled:!!D.error,onSelect:()=>c(D.name),title:D.error??D.description,children:[s.jsx(se,{name:"play",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:D.name})]},D.name))]}):null,e[37]=c,e[38]=a,e[39]=f,e[40]=E):E=e[40];let F;e[41]!==d||e[42]!==f?(F=d?s.jsxs(s.Fragment,{children:[s.jsx(un,{}),s.jsxs(Gt,{variant:"destructive",onSelect:d,children:[s.jsx(se,{name:"delete-bin",className:"size-3.5 shrink-0"}),f("workflows.panel.delete.action")]})]}):null,e[41]=d,e[42]=f,e[43]=F):F=e[43];let _;e[44]!==h||e[45]!==g||e[46]!==x||e[47]!==w||e[48]!==T||e[49]!==E||e[50]!==F?(_=s.jsxs(h,{align:g,className:x,children:[w,T,E,F]}),e[44]=h,e[45]=g,e[46]=x,e[47]=w,e[48]=T,e[49]=E,e[50]=F,e[51]=_):_=e[51];let A;return e[52]!==b||e[53]!==k||e[54]!==_?(A=s.jsxs(b,{children:[k,_]}),e[52]=b,e[53]=k,e[54]=_,e[55]=A):A=e[55],A},wy=(t,e,n,r)=>{const o=$e.c(11),{t:i}=at(),{confirm:a,dialog:u}=Fi(),c=Wi(Cy);let d;o[0]!==a||o[1]!==t||o[2]!==e||o[3]!==c||o[4]!==r||o[5]!==n||o[6]!==i?(d=async m=>{if(!(!t||!e||!await a({title:i("workflows.panel.saved.confirmTitle",{name:m}),message:i(n?"workflows.panel.saved.confirmHere":"workflows.panel.saved.confirmNew"),action:i("workflows.panel.saved.confirmAction")})))try{const b=await yh({directory:t,scriptDirectory:e,sessionId:n,name:m});n?c(r,b.runId):(c(b.sessionId,b.runId),et.getState().setCurrentSession(b.sessionId,t))}catch(b){const g=b;Re.error(i("workflows.panel.saved.failed"),{description:g instanceof Error?g.message:void 0})}},o[0]=a,o[1]=t,o[2]=e,o[3]=c,o[4]=r,o[5]=n,o[6]=i,o[7]=d):d=o[7];const f=d;let p;return o[8]!==u||o[9]!==f?(p={run:f,dialog:u},o[8]=u,o[9]=f,o[10]=p):p=o[10],p},yy=t=>{const e=$e.c(23),{saved:n,onRunSaved:r}=t,{t:o}=at();if(n.length===0){let p;e[0]!==o?(p=o("workflows.panel.emptyProject"),e[0]=o,e[1]=p):p=e[1];let m;return e[2]!==p?(m=s.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-meta text-muted-foreground",children:p}),e[2]=p,e[3]=m):m=e[3],m}let i;e[4]!==o?(i=o("workflows.panel.emptyProject"),e[4]=o,e[5]=i):i=e[5];let a;e[6]!==i?(a=s.jsx("p",{className:"typography-meta text-muted-foreground",children:i}),e[6]=i,e[7]=a):a=e[7];let u;e[8]!==o?(u=o("workflows.panel.picker.saved"),e[8]=o,e[9]=u):u=e[9];let c;e[10]!==u?(c=s.jsx("h4",{className:"mt-2 typography-micro font-medium text-muted-foreground",children:u}),e[10]=u,e[11]=c):c=e[11];let d;if(e[12]!==r||e[13]!==n||e[14]!==o){let p;e[16]!==r||e[17]!==o?(p=m=>s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-meta text-foreground",dir:"auto",children:m.name}),m.description||m.error?s.jsx("div",{className:"truncate typography-micro text-muted-foreground",dir:"auto",title:m.error??m.description,children:m.error??m.description}):null]}),s.jsxs(dt,{type:"button",size:"sm",variant:"outline",disabled:!!m.error,onClick:()=>r(m.name),"aria-label":o("workflows.panel.saved.runAria",{name:m.name}),children:[s.jsx(se,{name:"play",className:"size-3.5"}),o("workflows.panel.saved.confirmAction")]})]},m.name),e[16]=r,e[17]=o,e[18]=p):p=e[18],d=n.map(p),e[12]=r,e[13]=n,e[14]=o,e[15]=d}else d=e[15];let f;return e[19]!==a||e[20]!==c||e[21]!==d?(f=s.jsxs("div",{className:"flex flex-col gap-1 px-3 py-3",children:[a,c,d]}),e[19]=a,e[20]=c,e[21]=d,e[22]=f):f=e[22],f},vy=t=>{const e=$e.c(17),{directory:n}=t,r=et(Ty),o=bh(n),i=xh(o),a=wh(o?.savedDirectory??null),u=r??`directory:${n??""}`;let c;e[0]!==u?(c=x=>x.selectedBySession[u],e[0]=u,e[1]=c):c=e[1];const d=Wi(c),{run:f,dialog:p}=wy(n,o?.savedDirectory??null,r,u);let m;e[2]!==i||e[3]!==d||e[4]!==r?(m=i.find(x=>x.id===d)??i.filter(x=>x.parentSessionId===r).at(-1)??i.at(-1)??null,e[2]=i,e[3]=d,e[4]=r,e[5]=m):m=e[5];const h=m;let b;e[6]!==n||e[7]!==h||e[8]!==f||e[9]!==i||e[10]!==a||e[11]!==u||e[12]!==r?(b=h?s.jsx(Sy,{sessionId:r,selectionKey:u,runs:i,saved:a,run:h,directory:n,onRunSaved:x=>{f(x)}}):s.jsx(yy,{saved:a,onRunSaved:x=>{f(x)}}),e[6]=n,e[7]=h,e[8]=f,e[9]=i,e[10]=a,e[11]=u,e[12]=r,e[13]=b):b=e[13];let g;return e[14]!==p||e[15]!==b?(g=s.jsxs(s.Fragment,{children:[p,b]}),e[14]=p,e[15]=b,e[16]=g):g=e[16],g},Sy=t=>{const e=$e.c(58),{sessionId:n,selectionKey:r,runs:o,saved:i,run:a,directory:u,onRunSaved:c}=t,{t:d}=at(),f=Wi(Ny),p=by(),[m,h]=l.useState("agents"),{detail:b,failed:g}=uy(a,m),x=l.useRef(null);vh(x,ly);const{confirm:w,dialog:T}=Fi(),k=a.state==="running"||a.state==="awaiting-approval",E=a.parentSessionId!==n;let F;e[0]!==w||e[1]!==a.id||e[2]!==a.name||e[3]!==a.parentSessionId||e[4]!==d?(F=async()=>{if(await w({title:d("workflows.panel.delete.title",{name:a.name}),message:d("workflows.panel.delete.message"),action:d("workflows.panel.delete.confirm"),destructive:!0}))try{await Sh(a.id),kh.getState().remove(a.parentSessionId,a.id)}catch(P){const te=P;Re.error(d("workflows.panel.delete.failed"),{description:te instanceof Error?te.message:void 0})}},e[0]=w,e[1]=a.id,e[2]=a.name,e[3]=a.parentSessionId,e[4]=d,e[5]=F):F=e[5];const _=F;let A;e[6]!==a.directory||e[7]!==a.id||e[8]!==a.parentSessionId||e[9]!==f?(A=()=>{f(a.parentSessionId,a.id),et.getState().setCurrentSession(a.parentSessionId,a.directory)},e[6]=a.directory,e[7]=a.id,e[8]=a.parentSessionId,e[9]=f,e[10]=A):A=e[10];const D=A;let y;e[11]!==f||e[12]!==r?(y=H=>f(r,H),e[11]=f,e[12]=r,e[13]=y):y=e[13];let N;e[14]!==_||e[15]!==k?(N=k?null:()=>{_()},e[14]=_,e[15]=k,e[16]=N):N=e[16];let j;e[17]!==c||e[18]!==a||e[19]!==o||e[20]!==i||e[21]!==n||e[22]!==p||e[23]!==y||e[24]!==N?(j=s.jsx(xy,{runs:o,selected:a,sessionId:n,sessionTitles:p,saved:i,onSelect:y,onRunSaved:c,onDelete:N}),e[17]=c,e[18]=a,e[19]=o,e[20]=i,e[21]=n,e[22]=p,e[23]=y,e[24]=N,e[25]=j):j=e[25];let v;e[26]!==d?(v=d("workflows.panel.view.label"),e[26]=d,e[27]=v):v=e[27];let M;e[28]!==d||e[29]!==m?(M=cy.map(H=>{const P=H.id===m;return s.jsxs("button",{type:"button",onClick:()=>h(H.id),"aria-current":P?"page":void 0,title:d(H.labelKey),"aria-label":d(H.labelKey),className:Le("flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 transition-colors",P?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground"),children:[s.jsx(se,{name:H.icon,className:"size-3.5 shrink-0"}),s.jsx("span",{className:"workflows-header__label whitespace-nowrap typography-meta",children:d(H.labelKey)})]},H.id)}),e[28]=d,e[29]=m,e[30]=M):M=e[30];let W;e[31]!==v||e[32]!==M?(W=s.jsx("nav",{className:"flex shrink-0 items-center gap-1","aria-label":v,children:M}),e[31]=v,e[32]=M,e[33]=W):W=e[33];let G;e[34]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx("div",{"aria-hidden":!0,className:"min-w-0 flex-1"}),e[34]=G):G=e[34];let O;e[35]!==E||e[36]!==D||e[37]!==a.parentSessionId||e[38]!==p||e[39]!==d?(O=E?s.jsxs(dt,{type:"button",size:"sm",variant:"ghost",onClick:D,"aria-label":d("workflows.panel.agent.openSession"),title:p.get(a.parentSessionId)||d("workflows.panel.picker.untitledSession"),children:[s.jsx(se,{name:"chat-4",className:"size-3.5"}),s.jsx("span",{className:"workflows-header__action-label",children:d("workflows.panel.agent.openSession")})]}):null,e[35]=E,e[36]=D,e[37]=a.parentSessionId,e[38]=p,e[39]=d,e[40]=O):O=e[40];let Z;e[41]!==a?(Z=s.jsx(gy,{run:a}),e[41]=a,e[42]=Z):Z=e[42];let Q;e[43]!==O||e[44]!==Z||e[45]!==j||e[46]!==W?(Q=s.jsx(Lc,{children:s.jsxs("div",{ref:x,className:"workflows-header flex min-w-0 flex-1 flex-nowrap items-center gap-1.5 overflow-hidden ps-1 pe-1",children:[j,W,G,O,Z]})}),e[43]=O,e[44]=Z,e[45]=j,e[46]=W,e[47]=Q):Q=e[47];let B;e[48]!==b||e[49]!==u||e[50]!==g||e[51]!==a||e[52]!==m?(B=m==="agents"?s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(ty,{run:a,directory:u},a.id)}):s.jsxs(hs,{outerClassName:"min-h-0 flex-1",disableHorizontal:!0,children:[m==="log"?s.jsx(py,{run:a,detail:b}):null,m==="result"?s.jsx(my,{run:a,detail:b,failed:g}):null,m==="script"?s.jsx(hy,{detail:b,failed:g}):null]}),e[48]=b,e[49]=u,e[50]=g,e[51]=a,e[52]=m,e[53]=B):B=e[53];let oe;return e[54]!==T||e[55]!==Q||e[56]!==B?(oe=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[T,Q,B]}),e[54]=T,e[55]=Q,e[56]=B,e[57]=oe):oe=e[57],oe};function ky(t,e){return s.jsxs("li",{className:"flex min-w-0 gap-3 typography-meta",children:[s.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",dir:"ltr",children:fy(t.at)}),s.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words text-foreground",dir:"auto",children:t.message})]},`${t.at}-${e}`)}function jy(t){return t.entityById}function Cy(t){return t.select}function Ty(t){return t.currentSessionId}function Ny(t){return t.select}const nl=60,Ey=t=>{try{return new URL(t).origin}catch{return""}},Mo=new Set,Id=po()((t,e)=>({byOrigin:{},resolve:(n,r,o)=>{const i=Ey(n);!i||!r||e().byOrigin[i]||Mo.has(i)||(Mo.add(i),kn("desktop_browser_fetch_favicon",{url:r,webContentsId:o}).then(a=>{const u=typeof a?.dataUrl=="string"?a.dataUrl:"";u&&t(c=>{const d={...c.byOrigin,[i]:u},f=Object.keys(d);if(f.length<=nl)return{byOrigin:d};for(const p of f.slice(0,f.length-nl))delete d[p];return{byOrigin:d}})}).catch(()=>{}).finally(()=>{Mo.delete(i)}))}})),Zi=t=>t,ai=t=>{const e=Zi(t).type;return typeof e=="string"?e:""},Iy=t=>{const e=Zi(t).tool;return typeof e=="string"?e:""},Py=t=>{const e=Zi(t).text;return typeof e=="string"?e:""},Ry=t=>{const e=ai(t);return e==="tool"?Iy(t).trim().toLowerCase()||"tool":e||"unknown"},Dy=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=Ry(n);e.includes(r)||e.push(r)}return e.join(" + ")},Ay=t=>t.replace(/\s+/g," ").trim(),_y=t=>{for(const n of t)if(ai(n)==="text"){const r=Ay(Py(n));if(r.length===0)continue;return r}const e=t.filter(n=>ai(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},Oy=(t,e,n)=>`${n(t)} / ${n(e)}`,My=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Fy=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=My(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}})},Ly=(t,{windowTokens:e,compacted:n=!1})=>{const r=n?0:e,o=Number.isFinite(r)&&r>0?r:0,i=t.user+t.assistant+t.tool+t.other,a=Math.max(o,i);return{user:t.user,assistant:t.assistant,tool:t.tool,other:a-i,total:a}},li={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Pr={user:0,assistant:0,tool:0,other:0},Ms=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,rl=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof n=="number")return{...li,total:Ms(n)};if(!n||typeof n!="object")return li;const r=n,o=Ms(r.input),i=Ms(r.output),a=Ms(r.reasoning),u=Ms(r.cache?.read),c=Ms(r.cache?.write),d=Ms(r.total);return{input:o,output:i,reasoning:a,cacheRead:u,cacheWrite:c,total:d>0?d:o+i+a+u+c}},$y=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},bs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+bs(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+bs(n),0):0,By=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...Pr,assistant:bs(n.text)+bs(n.content)};const o=$y(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:bs(n.input)+bs(n.output)+bs(n.error)+bs(n.call?.input)+bs(n.call?.output)+bs(n.call?.error)+bs(n.raw)+Math.round(bs(n.metadata)*.25)+Math.round(bs(n.state)*.1)+Math.round((Du(t)??0)*.1),other:0}:e==="user"?{user:o.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:o.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:o.length}},ol=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),zy=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",Wy=(t,e)=>{if(t.length===0)return{...Pr};const n=t.reduce((r,o)=>{const i=zy(o);let a={...Pr};for(const u of o.parts)a=ol(a,By(u,i));return ol(r,a)},{...Pr});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)}},ln=t=>t.toLocaleString(Bc()),Uy=(t,e)=>!t||!Number.isFinite(t)?"-":Rh(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Vy=(t,e,n)=>{const r=t.find(i=>i.id===e),o=r?.models?.find(i=>i.id===n);return{providerName:r?.name||e||"-",modelName:o?.name||n||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},Hy=()=>{const t=$e.c(215),{t:e}=at(),n=Nh(),r=X(qy);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={},t[0]=o):o=t[0];const[i,a]=l.useState(o),[u,c]=l.useState(null),d=l.useRef(null),f=et(Ky),p=et(Gy),m=Eh(p??void 0),h=Ih(f??"",p??void 0),b=zt(Zy);let g;t[1]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),a(Xy),c(null)},t[1]=g):g=t[1];let x;t[2]!==p||t[3]!==f?(x=[p,f],t[2]=p,t[3]=f,t[4]=x):x=t[4],l.useEffect(g,x);let w,T;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},T=[],t[5]=w,t[6]=T):(w=t[5],T=t[6]),l.useEffect(w,T);let k;t[7]===Symbol.for("react.memo_cache_sentinel")?(k=async(ye,ot)=>{(await no(ot)).ok?(c(ye),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{c(xt=>xt===ye?null:xt),d.current=null},2e3)):c(null)},t[7]=k):k=t[7];const E=k;let F,_,A,D,y,N,j,v,M,W;if(t[8]!==f||t[9]!==b||t[10]!==h||t[11]!==m){D=f?m.find(ht=>ht.id===f)??null:null,F=h.filter(Yy);let ye;t[22]!==h?(ye=h.filter(Jy),t[22]=h,t[23]=ye):ye=t[23],W=ye;let ot;t[24]!==h?(ot=Cc(h.map(Qy)),t[24]=h,t[25]=ot):ot=t[25];const Ct=ot,xt=Ct?h[Ct.index]??null:null,jt=Ct?.state==="compacted";j=xt?rl(xt):li,_=Ph({input:j.input,cache:{read:j.cacheRead,write:j.cacheWrite}}),v=Number.isFinite(D?.cost)?Ms(D?.cost):F.reduce(ev,0);const ct=xt?.info??null,vt=b,St=ct?.providerID||"",mt=ct?.modelID||"";let yt;t[26]!==St||t[27]!==mt||t[28]!==vt?(yt=Vy(vt,St,mt),t[26]=St,t[27]=mt,t[28]=vt,t[29]=yt):yt=t[29],y=yt,A=y.contextLimit,M=jt?null:A&&A>0?Math.min(999,j.total/A*100):0;const lt=[...h].reverse().find(tv),Nt=lt?.info.role==="system"?lt.info.text:"",_t=Wy(h,Nt);N=Ly(_t,{windowTokens:j.total,compacted:jt}),t[8]=f,t[9]=b,t[10]=h,t[11]=m,t[12]=F,t[13]=_,t[14]=A,t[15]=D,t[16]=y,t[17]=N,t[18]=j,t[19]=v,t[20]=M,t[21]=W}else F=t[12],_=t[13],A=t[14],D=t[15],y=t[16],N=t[17],j=t[18],v=t[19],M=t[20],W=t[21];const G=N,O=h[0]?.info?.time?.created,Z=h.length>0?h[h.length-1]?.info?.time?.created:null;let Q;t[30]!==D?.title||t[31]!==e?(Q=D?.title||e("contextSidebar.session.untitled"),t[30]=D?.title,t[31]=e,t[32]=Q):Q=t[32];const B=D?.time?.created??O??null,oe=Z??D?.time?.created??null;let H;t[33]!==F.length||t[34]!==G||t[35]!==_||t[36]!==A||t[37]!==y||t[38]!==h.length||t[39]!==Q||t[40]!==B||t[41]!==oe||t[42]!==j||t[43]!==v||t[44]!==M||t[45]!==W.length?(H={sessionTitle:Q,messagesCount:h.length,userMessagesCount:W.length,assistantMessagesCount:F.length,createdAt:B,lastActivityAt:oe,providerModel:y,tokenBreakdown:j,usagePercent:M,cacheHitRate:_,totalAssistantCost:v,contextLimit:A,breakdown:G,breakdownTotal:G.total},t[33]=F.length,t[34]=G,t[35]=_,t[36]=A,t[37]=y,t[38]=h.length,t[39]=Q,t[40]=B,t[41]=oe,t[42]=j,t[43]=v,t[44]=M,t[45]=W.length,t[46]=H):H=t[46];const P=H;if(!f){let ye;t[47]!==e?(ye=e("contextSidebar.empty.openSession"),t[47]=e,t[48]=ye):ye=t[48];let ot;return t[49]!==ye?(ot=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:ye}),t[49]=ye,t[50]=ot):ot=t[50],ot}let te;t[51]!==e?(te=e("contextSidebar.breakdown.user"),t[51]=e,t[52]=te):te=t[52];let J;t[53]!==te||t[54]!==P.breakdown.user?(J={key:"user",label:te,value:P.breakdown.user,color:"var(--status-success)"},t[53]=te,t[54]=P.breakdown.user,t[55]=J):J=t[55];let le;t[56]!==e?(le=e("contextSidebar.breakdown.assistant"),t[56]=e,t[57]=le):le=t[57];let K;t[58]!==le||t[59]!==P.breakdown.assistant?(K={key:"assistant",label:le,value:P.breakdown.assistant,color:"var(--primary-base)"},t[58]=le,t[59]=P.breakdown.assistant,t[60]=K):K=t[60];let U;t[61]!==e?(U=e("contextSidebar.breakdown.toolCalls"),t[61]=e,t[62]=U):U=t[62];let $;t[63]!==U||t[64]!==P.breakdown.tool?($={key:"tool",label:U,value:P.breakdown.tool,color:"var(--status-warning)"},t[63]=U,t[64]=P.breakdown.tool,t[65]=$):$=t[65];let ee;t[66]!==e?(ee=e("contextSidebar.breakdown.other"),t[66]=e,t[67]=ee):ee=t[67];let Y;t[68]!==ee||t[69]!==P.breakdown.other?(Y={key:"other",label:ee,value:P.breakdown.other,color:"var(--surface-muted-foreground)"},t[68]=ee,t[69]=P.breakdown.other,t[70]=Y):Y=t[70];let ie;t[71]!==J||t[72]!==K||t[73]!==$||t[74]!==Y?(ie=[J,K,$,Y],t[71]=J,t[72]=K,t[73]=$,t[74]=Y,t[75]=ie):ie=t[75];const V=ie;let fe;t[76]!==n||t[77]!==P.sessionTitle?(fe=n?s.jsx(Lc,{children:s.jsx("div",{className:"flex min-w-0 flex-1 items-center ps-1.5 pe-1",children:s.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-foreground",title:P.sessionTitle,children:P.sessionTitle})})}):null,t[76]=n,t[77]=P.sessionTitle,t[78]=fe):fe=t[78];let Se;t[79]!==n||t[80]!==P.sessionTitle?(Se=n?null:s.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:P.sessionTitle}),t[79]=n,t[80]=P.sessionTitle,t[81]=Se):Se=t[81];const Te=!n&&"mt-1";let ue;t[82]!==Te?(ue=Le(Te,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground"),t[82]=Te,t[83]=ue):ue=t[83];let Me;t[84]!==P.providerModel.modelName||t[85]!==P.providerModel.providerName?(Me=s.jsxs("span",{children:[P.providerModel.providerName," / ",P.providerModel.modelName]}),t[84]=P.providerModel.modelName,t[85]=P.providerModel.providerName,t[86]=Me):Me=t[86];let Ae;t[87]!==r||t[88]!==P.createdAt?(Ae=P.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:Uy(P.createdAt,r)})]}),t[87]=r,t[88]=P.createdAt,t[89]=Ae):Ae=t[89];let De;t[90]!==ue||t[91]!==Me||t[92]!==Ae?(De=s.jsxs("div",{className:ue,children:[Me,Ae]}),t[90]=ue,t[91]=Me,t[92]=Ae,t[93]=De):De=t[93];let Be;t[94]!==Se||t[95]!==De?(Be=s.jsxs("div",{className:"mb-6",children:[Se,De]}),t[94]=Se,t[95]=De,t[96]=Be):Be=t[96];let we;t[97]!==e?(we=e("contextSidebar.section.context"),t[97]=e,t[98]=we):we=t[98];let ve;t[99]!==we?(ve=s.jsx("span",{className:"typography-micro text-muted-foreground",children:we}),t[99]=we,t[100]=ve):ve=t[100];let Pe;t[101]!==P.tokenBreakdown.total||t[102]!==P.usagePercent?(Pe=P.usagePercent===null?"—":ln(P.tokenBreakdown.total),t[101]=P.tokenBreakdown.total,t[102]=P.usagePercent,t[103]=Pe):Pe=t[103];let he;t[104]!==P.contextLimit?(he=P.contextLimit?` / ${ln(P.contextLimit)}`:"",t[104]=P.contextLimit,t[105]=he):he=t[105];let Fe;t[106]!==Pe||t[107]!==he?(Fe=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[Pe,he]}),t[106]=Pe,t[107]=he,t[108]=Fe):Fe=t[108];let _e;t[109]!==ve||t[110]!==Fe?(_e=s.jsxs("div",{className:"flex items-baseline justify-between",children:[ve,Fe]}),t[109]=ve,t[110]=Fe,t[111]=_e):_e=t[111];let We;t[112]!==P.usagePercent?(We=P.usagePercent!==null&&P.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,P.usagePercent)}%`,backgroundColor:P.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[112]=P.usagePercent,t[113]=We):We=t[113];let Xe;t[114]!==We?(Xe=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:We}),t[114]=We,t[115]=Xe):Xe=t[115];let Ve;t[116]!==e||t[117]!==P.usagePercent?(Ve=P.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:P.usagePercent.toFixed(1)}),t[116]=e,t[117]=P.usagePercent,t[118]=Ve):Ve=t[118];let S;t[119]!==Ve?(S=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:Ve}),t[119]=Ve,t[120]=S):S=t[120];let ne;t[121]!==_e||t[122]!==Xe||t[123]!==S?(ne=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[_e,Xe,S]}),t[121]=_e,t[122]=Xe,t[123]=S,t[124]=ne):ne=t[124];let q;t[125]!==e?(q=e("contextSidebar.stats.messages"),t[125]=e,t[126]=q):q=t[126];let ke;t[127]!==P.messagesCount?(ke=ln(P.messagesCount),t[127]=P.messagesCount,t[128]=ke):ke=t[128];let Ee;t[129]!==q||t[130]!==ke?(Ee={label:q,value:ke},t[129]=q,t[130]=ke,t[131]=Ee):Ee=t[131];let Ie;t[132]!==e?(Ie=e("contextSidebar.stats.user"),t[132]=e,t[133]=Ie):Ie=t[133];let Ne;t[134]!==P.userMessagesCount?(Ne=ln(P.userMessagesCount),t[134]=P.userMessagesCount,t[135]=Ne):Ne=t[135];let ze;t[136]!==Ie||t[137]!==Ne?(ze={label:Ie,value:Ne},t[136]=Ie,t[137]=Ne,t[138]=ze):ze=t[138];let Ue;t[139]!==e?(Ue=e("contextSidebar.stats.assistant"),t[139]=e,t[140]=Ue):Ue=t[140];let Ge;t[141]!==P.assistantMessagesCount?(Ge=ln(P.assistantMessagesCount),t[141]=P.assistantMessagesCount,t[142]=Ge):Ge=t[142];let Qe;t[143]!==Ue||t[144]!==Ge?(Qe={label:Ue,value:Ge},t[143]=Ue,t[144]=Ge,t[145]=Qe):Qe=t[145];let He;t[146]!==e?(He=e("contextSidebar.stats.cost"),t[146]=e,t[147]=He):He=t[147];let Ke;t[148]!==P.totalAssistantCost?(Ke=rd(P.totalAssistantCost),t[148]=P.totalAssistantCost,t[149]=Ke):Ke=t[149];let Ye;t[150]!==He||t[151]!==Ke?(Ye={label:He,value:Ke},t[150]=He,t[151]=Ke,t[152]=Ye):Ye=t[152];let it;t[153]!==Ee||t[154]!==ze||t[155]!==Qe||t[156]!==Ye?(it=[Ee,ze,Qe,Ye],t[153]=Ee,t[154]=ze,t[155]=Qe,t[156]=Ye,t[157]=it):it=t[157];const bt=it;let nt;t[158]!==bt?(nt=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:bt.map(sv)}),t[158]=bt,t[159]=nt):nt=t[159];let ft;t[160]!==e?(ft=e("contextSidebar.section.lastAssistantMessage"),t[160]=e,t[161]=ft):ft=t[161];let ae;t[162]!==ft?(ae=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:ft}),t[162]=ft,t[163]=ae):ae=t[163];let de;t[164]!==e||t[165]!==P.cacheHitRate.hasInput||t[166]!==P.cacheHitRate.percent||t[167]!==P.tokenBreakdown.cacheRead||t[168]!==P.tokenBreakdown.cacheWrite||t[169]!==P.tokenBreakdown.input||t[170]!==P.tokenBreakdown.output||t[171]!==P.tokenBreakdown.reasoning?(de=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:P.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:P.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:P.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:P.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:P.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:P.cacheHitRate.hasInput?P.cacheHitRate.percent:null,format:"percent"}].map(nv)}),t[164]=e,t[165]=P.cacheHitRate.hasInput,t[166]=P.cacheHitRate.percent,t[167]=P.tokenBreakdown.cacheRead,t[168]=P.tokenBreakdown.cacheWrite,t[169]=P.tokenBreakdown.input,t[170]=P.tokenBreakdown.output,t[171]=P.tokenBreakdown.reasoning,t[172]=de):de=t[172];let be;t[173]!==ae||t[174]!==de?(be=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[ae,de]}),t[173]=ae,t[174]=de,t[175]=be):be=t[175];let C;t[176]!==V||t[177]!==P.breakdownTotal?(C=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:V.map(ye=>ye.value<=0||P.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${ye.value/P.breakdownTotal*100}%`,backgroundColor:ye.color}},ye.key))}),t[176]=V,t[177]=P.breakdownTotal,t[178]=C):C=t[178];let ce;t[179]!==V||t[180]!==P.breakdownTotal?(ce=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:V.map(ye=>{const ot=P.breakdownTotal>0?ye.value/P.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:ye.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:[ye.label," ",s.jsxs("span",{className:"tabular-nums",children:[ot.toFixed(0),"%"]})]})]},ye.key)})}),t[179]=V,t[180]=P.breakdownTotal,t[181]=ce):ce=t[181];let L;t[182]!==C||t[183]!==ce?(L=s.jsxs("div",{className:"mb-6",children:[C,ce]}),t[182]=C,t[183]=ce,t[184]=L):L=t[184];let ge;t[185]!==e?(ge=e("contextSidebar.section.rawMessages"),t[185]=e,t[186]=ge):ge=t[186];let Ce;t[187]!==ge?(Ce=s.jsx("div",{className:"typography-micro text-muted-foreground",children:ge}),t[187]=ge,t[188]=Ce):Ce=t[188];let Je;if(t[189]!==u||t[190]!==i||t[191]!==h||t[192]!==e||t[193]!==r){let ye;t[195]!==u||t[196]!==i||t[197]!==e||t[198]!==r?(ye=ot=>{const Ct=ot.info.role,xt=Ct==="assistant",jt=Ct==="user",ct=i[ot.info.id]===!0,vt=u===ot.info.id,St=ot.info.time?.created??null,mt=Dy(ot.parts),yt=xt?rl({info:ot.info,parts:ot.parts}):null,lt=jt?_y(ot.parts):"",Nt=Fy(St,r),_t=mt||"—",ht=yt?Oy(yt.input,yt.output,ln):"",gt=Ct||"unknown",Dt=mt?`${gt}: ${mt}`:gt,Kt=ct?JSON.stringify({info:ot.info,parts:ot.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-start hover:bg-[var(--interactive-hover)]","aria-expanded":ct,onClick:()=>{a(Yt=>({...Yt,[ot.info.id]:Yt[ot.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:xt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[jt?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",lt]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:xt?_t:Dt}),xt&&s.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:ht})]}),s.jsx("span",{className:"text-end text-muted-foreground",children:Nt})]})}),ct&&s.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:s.jsxs(hs,{outerClassName:"max-h-[26rem] bg-[var(--surface-background)]",className:"group relative",disableHorizontal:!0,children:[s.jsx("div",{className:"absolute top-1 inset-e-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:Yt=>{Yt.stopPropagation(),E(ot.info.id,Kt)},"aria-label":e(vt?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(vt?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:vt?s.jsx(se,{name:"check",className:"size-3.5"}):s.jsx(se,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Dh,{language:"json",code:Kt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},ot.info.id)},t[195]=u,t[196]=i,t[197]=e,t[198]=r,t[199]=ye):ye=t[199],Je=[...h].reverse().map(ye),t[189]=u,t[190]=i,t[191]=h,t[192]=e,t[193]=r,t[194]=Je}else Je=t[194];let Oe;t[200]!==Je?(Oe=s.jsx("div",{className:"mt-2.5 space-y-1",children:Je}),t[200]=Je,t[201]=Oe):Oe=t[201];let me;t[202]!==Ce||t[203]!==Oe?(me=s.jsxs("div",{children:[Ce,Oe]}),t[202]=Ce,t[203]=Oe,t[204]=me):me=t[204];let je;t[205]!==Be||t[206]!==ne||t[207]!==nt||t[208]!==be||t[209]!==L||t[210]!==me?(je=s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[Be,ne,nt,be,L,me]}),t[205]=Be,t[206]=ne,t[207]=nt,t[208]=be,t[209]=L,t[210]=me,t[211]=je):je=t[211];let st;return t[212]!==fe||t[213]!==je?(st=s.jsxs(hs,{outerClassName:"h-full",className:"bg-background",children:[fe,je]}),t[212]=fe,t[213]=je,t[214]=st):st=t[214],st};function qy(t){return t.timeFormatPreference}function Ky(t){return t.currentSessionId}function Gy(t){return t.currentSessionDirectory}function Zy(t){return t.providers}function Xy(t){return Object.keys(t).length>0?{}:t}function Yy(t){return t.info.role==="assistant"}function Jy(t){return t.info.role==="user"}function Qy(t){return t.info}function ev(t,e){const n=Ms(e.info.cost);return t+n}function tv(t){return t.info.role==="system"}function sv(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",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function nv(t){return s.jsxs("div",{children:[s.jsx("div",{className:"typography-micro text-muted-foreground",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)}%`:ln(t.value):"—"})]},t.label)}const Rr=(t,e)=>{const[n,r]=l.useState(null),o=t?.id??null;return e&&n!==o&&r(o),e||n===null||n===o?t:null},rv=280,ov=.28,iv=240,av=.35,lv=(t,e,n=null)=>{const r=t.left+t.width,o=e.left+e.width,i=e.top+e.height,a=n?n.top:i-Math.min(iv,e.height*av),u=Math.min(rv,t.width*ov,e.width/4),c=e.left-t.left>=1,d=r-o>=1,f=Math.max(0,a-t.top),p=c?e.left:t.left+u,m=d?o:r-u;return{left:{left:t.left,top:t.top,width:p-t.left,height:c?t.height:f},right:{left:m,top:t.top,width:r-m,height:d?t.height:f},bottom:{left:e.left,top:a,width:e.width,height:Math.max(0,i-a)}}},Fo=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,cv=(t,e)=>Fo(t.bottom,e)?"bottom":Fo(t.left,e)?"left":Fo(t.right,e)?"right":null,Us=po(()=>({drag:null,hovered:null})),Dr=t=>{if(!t)return null;const{left:e,top:n,width:r,height:o}=t.getBoundingClientRect();return r>0&&o>0?{left:e,top:n,width:r,height:o}:null},Lo=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),$o=t=>Dr(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),Pd=t=>{const e=Dr(document.querySelector("[data-workspace-row]")),n=Dr(document.querySelector("[data-workspace-chat]"));if(!e||!n)return!1;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=lv(e,n,Dr(r)),i={left:$o("left")??Lo(o.left),right:$o("right")??Lo(o.right),bottom:$o("bottom")??Lo(o.bottom)};return Us.setState({drag:{...t,targets:o,frames:i},hovered:null}),!0},Rd=t=>{const{drag:e,hovered:n}=Us.getState();if(!e)return;const r=cv(e.targets,t);r!==n&&Us.setState({hovered:r})},ci=()=>{Us.getState().drag&&Us.setState({drag:null,hovered:null})},Dd=t=>{const{drag:e,hovered:n}=Us.getState();if(Us.setState({drag:null,hovered:null}),!e||!n)return!1;const r=X.getState();n!==e.from&&r.moveContextSurfaceToZone(e.mode,n);const o=t?cs(t):"";if(o){const i=X.getState();vi(i.contextPanelByDirectory[o],i.contextSurfaceZones).has(e.mode)||i.openContextSurface(o,e.mode)}return!0},Xi=(t,e)=>{let n=!1;const r=i=>{const a={x:i.clientX,y:i.clientY};e(a)?(n||(n=Pd(t)),n&&Rd(a)):n&&(ci(),n=!1)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:i=>(o(),n?(Dd(i),!0):!1),cancel:()=>{o(),n&&ci()}}},il={left:null,right:null,bottom:null},lr=po(()=>({body:il,headerSlot:il})),Ad=(t,e,n)=>{const r=lr.getState()[t];r[e]!==n&&lr.setState({[t]:{...r,[e]:n}})},dv=(t,e)=>Ad("body",t,e),uv=(t,e)=>Ad("headerSlot",t,e),Xn=t=>{const e=l.useRef(t);e.current=t;const[n,r]=l.useState(t),o=l.useCallback(()=>r(e.current),[]);return l.useLayoutEffect(()=>{Di(o)},[t,o]),l.useEffect(()=>()=>zc(o),[o]),n},Bo=t=>{const e=Xn(t);return t||e},fv=ur(()=>Ot(()=>import("./GitView-C4xsLAUw.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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206])).then(t=>({default:t.GitView}))),Yi=320,_d=320,pv=24,mv=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},al=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Yi,Math.round(t))):Ci,hv=t=>t===null?Number.POSITIVE_INFINITY:Math.max(Yi,t-_d),ll=(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},Ar=(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==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):t==="workflows"?e("contextPanel.mode.workflows"):Pn(t)?Ri.getState().guests.find(r=>r.id===Fr(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),gv=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},bv=(t,e,n)=>{if(t.mode==="chat"){const r=ho(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||n("contextPanel.mode.chat")}return t.mode==="browser"?eo(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?gv(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Ar(t.mode,n)},xv=t=>{const e=$e.c(8),{mode:n}=t,r=Ui();let o;if(e[0]!==n||e[1]!==r){let d;e[3]!==n?(d=f=>f.mode===n,e[3]=n,e[4]=d):d=e[4],o=r.find(d),e[0]=n,e[1]=r,e[2]=o}else o=e[2];const i=o,a=i?.icon??$h,u=i?.iconSrc;let c;return e[5]!==a||e[6]!==u?(c=s.jsx(Pi,{icon:a,iconSrc:u,className:"h-3.5 w-3.5"}),e[5]=a,e[6]=u,e[7]=c):c=e[7],c},wv=t=>{const e=$e.c(2),{sessionId:n}=t,r=yc(n);let o;return e[0]!==r?(o=r?s.jsx(Sc,{state:r,className:"h-3.5 w-3.5"}):s.jsx(se,{name:"chat-4",className:"h-3.5 w-3.5"}),e[0]=r,e[1]=o):o=e[1],o},yv=t=>{const e=$e.c(6),{url:n}=t,r=co(),o=Mc();let i;if(e[0]!==o||e[1]!==n||e[2]!==r){const c=n?Fc(n,r,o):null;i=c?c.source==="tracker"?Lh(c.provider).icon:Fh[c.kind]:"git-branch",e[0]=o,e[1]=n,e[2]=r,e[3]=i}else i=e[3];const a=i;let u;return e[4]!==a?(u=s.jsx(se,{name:a,className:"h-3.5 w-3.5"}),e[4]=a,e[5]=u):u=e[5],u},cl=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(uo,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(hc,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(se,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(se,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(yv,{url:t.targetPath});if(t.mode==="notes")return s.jsx(se,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(se,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(se,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="workflows")return s.jsx(se,{name:"flow-chart",className:"h-3.5 w-3.5"});if(t.mode==="chat"){const n=ho(t.dedupeKey);return n?s.jsx(wv,{sessionId:n}):s.jsx(se,{name:"chat-4",className:"h-3.5 w-3.5"})}if(Pn(t.mode))return s.jsx(xv,{mode:t.mode});if(t.mode==="browser"){const n=vv(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(se,{name:"global",className:"h-3.5 w-3.5"})}},vv=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Sv=t=>{const e=Uc(),n=l.useRef(Vr),r=l.useRef(t);r.current=t;const o=t.length>0;return l.useSyncExternalStore(l.useCallback(i=>o?e.subscribeAllSelected(a=>a.session,i):()=>{},[e,o]),l.useCallback(()=>{const i=Array.from(e.children.values(),u=>u.getState()),a=zw(i,r.current);return $w(n.current,a)?n.current:(n.current=a,a)},[e]),()=>Vr)},kv=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,jv=8,Cv='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',Tv=t=>t==="context"||t==="git"||t==="pr"||t==="notes"||t==="workflows",Od=320,Ji=160,di=200,Nv={right:{axis:"x",gutter:"mb-2 ms-2 me-1.5",gutterSize:"0.875rem",handle:"absolute bottom-2 inset-s-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},left:{axis:"x",gutter:"mb-2 ms-1.5 me-2",gutterSize:"0.875rem",handle:"absolute bottom-2 inset-e-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},bottom:{axis:"y",gutter:"mb-2 mt-2",gutterSize:"1rem",handle:"absolute inset-x-0 top-1 z-50 h-2 cursor-row-resize",sizeVariable:"--oc-context-panel-height"}},dl=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Ji,Math.round(t))):Od,Ev=t=>t===null?Number.POSITIVE_INFINITY:Math.max(Ji,t-di),zo=({zone:t="right"})=>{const e=Nv[t],n=io(),r=e.axis==="y",{t:o,direction:i}=at(),a=i==="rtl",u=Vs()??"",c=Xl(Ah(u||null)),d=l.useCallback((re,Ze)=>o($s(re,c),Ze),[c,o]),f=l.useMemo(()=>mv(u),[u]),p=X(re=>f?re.contextPanelByDirectory[f]:void 0),m=X(re=>re.contextSurfaceZones),h=X(re=>re.shortcutOverrides),b=X(re=>re.closeContextZone),g=X(re=>re.closeContextPanelTab),x=X(re=>re.pinContextPanelTab),w=X(re=>re.toggleContextPanelExpanded),T=X(re=>re.setContextZoneSize),k=X(re=>re.setContextZoneExpandedChatSize),E=X(re=>re.setActiveContextPanelTab),F=X(re=>re.reorderContextPanelTabs),_=X(re=>re.contextEditorTreeVisible),A=X(re=>re.contextEditorTreeWidth),D=X(re=>re.setContextEditorTreeWidth),y=X(re=>re.toggleContextEditorTree),N=X(re=>re.contextEditorVisible),j=X(re=>re.toggleContextEditor),v=X(re=>re.fileTreeSide),M=X(re=>re.openNewContextBrowserTab),W=Id(re=>re.byOrigin),[G,O]=l.useState(null),Z=l.useCallback(re=>{O(re),uv(t,re)},[t]),Q=l.useCallback(re=>{dv(t,re)},[t]),B=l.useMemo(()=>p?.tabs??[],[p?.tabs]),oe=p?Mr(p,m,t):null,H=p?er(p,t):Au,P=Ir(re=>re.workStatusReserved),te=Ir(re=>re.workStatusBesidePanel),J=Ir(re=>re.chatCovered),le=t==="bottom"&&J,K=!!(H.isOpen&&oe)&&!le,U=Rr(oe,K),$=l.useMemo(()=>B.some(re=>re.mode==="file"&&re.targetPath),[B]),ee=$&&(N||!_),Y=!r&&U?.mode==="file"&&!ee,ie=!!(K&&H.expanded&&!Y),V=X(re=>re.contextZoneSizes[t]),fe=Y?A:r?dl(V??Od,Number.POSITIVE_INFINITY):al(V??Ci,Number.POSITIVE_INFINITY),Se=l.useCallback((re,Ze)=>r?dl(re,Ev(Ze)):al(re,hv(Ze)),[r]),Te=r?di:_d,ue=X(re=>r?0:re.sidebarWidth),Me=X(re=>re.contextZoneExpandedChatSizes[t]),Ae=Math.max(Te,Me??(r?di:ue)),De=t==="right"?"left":t==="left"?"right":null,Be=X(re=>{if(!De||!f)return 0;const Ze=re.contextPanelByDirectory[f],pt=Ze&&Kn(Ze,re.contextSurfaceZones,De)?Mr(Ze,re.contextSurfaceZones,De):null;return Ze&&pt?_u(Ze,pt,De,re):0}),we=De==="right"&&P&&!J&&Be===0?yn:Be,ve=t==="right"&&P&&!J,Pe=ve&&te&&!ie,[he,Fe]=l.useState(null),_e=l.useRef(null),We=l.useRef(we);We.current=we;const Xe=l.useRef(K);Xe.current=K;const Ve=l.useRef(()=>!1);Ve.current=re=>ie||!Y&&re-We.current-Te<fe;const S=l.useCallback(()=>{let re=_e.current;if(re!==null&&!r&&Xe.current){const Ze=document.querySelector("[data-left-sidebar]");Ze&&(re+=Math.round(Ze.getBoundingClientRect().width-(Number.parseFloat(Ze.style.width)||0)))}Fe(re!==null&&Ve.current(re)?re:null)},[r]),ne=he!==null?he-we:null,q=Y?fe:ie&&ne!==null?Math.max(r?Ji:Yi,ne-Ae):Se(fe,ne),ke=K&&U?.mode==="chat",Ee=l.useMemo(()=>{const re=[];if(!ke)return re;for(const Ze of B){if(Ze.mode!=="chat")continue;const pt=ho(Ze.dedupeKey);pt&&!re.includes(pt)&&re.push(pt)}return re},[ke,B]),Ie=Sv(Ee),[Ne,ze]=l.useState(!1),Ue=l.useRef(0),Ge=l.useRef(q),Qe=l.useRef(null),He=l.useRef(null),Ke=l.useRef(null),Ye=l.useRef(null),it=l.useRef(!1);l.useLayoutEffect(()=>{const re=r?Ke.current?.parentElement:Ke.current?.closest("[data-workspace-row]");if(!re||typeof ResizeObserver>"u")return;const Ze=new ResizeObserver(pt=>{const kt=pt[pt.length-1]?.contentRect,Pt=r?kt?.height:kt?.width;_e.current=Pt?Math.round(Pt):null,Di(S)});return Ze.observe(re),_e.current=(r?re.clientHeight:re.clientWidth)||null,S(),()=>{Ze.disconnect(),zc(S)}},[S,r]);const bt=!r&&K&&(ie||he!==null),nt=X(re=>bt&&re.isSidebarOpen);l.useLayoutEffect(()=>{S()},[S,fe,ie,K,we,nt]),l.useEffect(()=>{if(!K||it.current){it.current=K;return}const re=window.requestAnimationFrame(()=>{Ye.current?.focus({preventScroll:!0})});return it.current=!0,()=>window.cancelAnimationFrame(re)},[K]);const ft=l.useRef(null),ae=l.useRef(null),de=l.useRef(null),be=l.useRef(null),C=l.useRef(!1),ce=l.useRef(null),L=l.useRef(!1),ge=l.useCallback(re=>{const Ze=Ke.current,pt=ce.current;if(!Ze||!pt)return;const kt=r?"height":"width";Ze.style[kt]=L.current?`${re+yn}px`:`min(${re}px, 100%)`,pt.style[kt]=`calc(${re}px - ${e.gutterSize})`},[e.gutterSize,r]),Ce=l.useCallback(()=>{ae.current=null;const re=Qe.current;re!==null&&ge(re)},[ge]);l.useEffect(()=>()=>{ae.current!==null&&cancelAnimationFrame(ae.current),de.current?.(),de.current=null,be.current?.remove(),be.current=null},[]);const Je=l.useCallback(re=>{const Ze=ft.current,pt=Y?Ko(re):Se(re,Ze);return Ze===null?pt:Math.min(pt,Math.max(1,Ze))},[Se,Y]),Oe=l.useCallback(re=>{if(!K||!f)return;He.current=re.pointerId,ze(!0),Ue.current=r?re.clientY:re.clientX,Ge.current=q,Qe.current=q;const Ze=r?Ke.current?.parentElement?.clientHeight:(Ke.current?.closest("[data-workspace-row]")?.clientWidth??0)-We.current-(Pe?yn:0);ft.current=Ze&&Ze>0?Ze:null,be.current?.remove();const pt=document.createElement("div");pt.style.cssText=`position:fixed;inset:0;z-index:2147483647;cursor:${r?"row-resize":"col-resize"}`,document.body.appendChild(pt),be.current=pt,de.current?.(),de.current=Ec(r?"height":"width"),re.preventDefault()},[Pe,f,K,r,q]),me=l.useCallback(()=>{const re=Je(Qe.current??q),Ze=ft.current;ae.current!==null&&(cancelAnimationFrame(ae.current),ae.current=null);const pt=Ke.current,kt=ce.current;if(pt&&kt){const Pt=r?"height":"width";pt.style.setProperty(e.sizeVariable,`${re}px`),pt.style[Pt]=Ut.current,kt.style[Pt]=Hs.current}Qe.current=null,ft.current=null,C.current=!0,be.current?.remove(),be.current=null,Y?D(re):ie?Ze!==null&&k(t,Ze-re):T(t,re),ze(!1),He.current=null,de.current?.(),de.current=null},[Je,e.sizeVariable,ie,Y,r,D,k,T,q,t]);l.useEffect(()=>{if(!Ne)return;const re=kt=>{if(He.current!==kt.pointerId)return;const Pt=r?kt.clientY:kt.clientX,Zt=t==="left"?Pt-Ue.current:Ue.current-Pt,is=!r&&a?-Zt:Zt,z=Je(Ge.current+is);Qe.current!==z&&(Qe.current=z,ae.current===null&&(ae.current=requestAnimationFrame(Ce)))},Ze=kt=>{He.current===kt.pointerId&&me()},pt=()=>{me()};return window.addEventListener("pointermove",re),window.addEventListener("pointerup",Ze),window.addEventListener("pointercancel",Ze),window.addEventListener("blur",pt),()=>{window.removeEventListener("pointermove",re),window.removeEventListener("pointerup",Ze),window.removeEventListener("pointercancel",Ze),window.removeEventListener("blur",pt)}},[Ce,Je,me,Ne,a,r,t]),l.useEffect(()=>{Ne||(Qe.current=null,be.current?.remove(),be.current=null)},[Ne]);const je=l.useCallback(()=>{f&&b(f,t)},[b,f,t]),st=l.useCallback(()=>{f&&w(f,t)},[f,w,t]),ye=U?.mode==="file"||U?.mode==="chat"||U?.mode==="browser"||U?.mode==="pr",ot=l.useMemo(()=>{if(!U)return[];const re=B.filter(Ze=>Ze.mode===U.mode);return U.mode==="pr"?[...re.filter(xr),...re.filter(Ze=>!xr(Ze))]:re},[U,B]),Ct=lo(U?.mode==="pr"&&f?f:null)?.current??null,xt=l.useMemo(()=>{const re=_h(ot.filter(Ze=>Ze.mode==="file").map(Ze=>ll(Ze.targetPath,u)));return ot.map(Ze=>{const pt=xr(Ze),kt=pt?Ct||o("contextPanel.tracker.branchTab"):bv(Ze,Ie,d),Pt=kv(kt,pv),Zt=ll(Ze.targetPath,u);return{id:Ze.id,label:Pt,labelFolder:Ze.mode==="file"?re.get(Zt):void 0,icon:cl(Ze,W),title:Zt?`${kt}: ${Zt}`:kt,closeLabel:o("contextPanel.tab.closeTabAria",{label:Pt}),closable:!pt,preview:Ze.preview}})},[ot,u,W,Ie,o,d,Ct]),jt=U?.mode==="context"?s.jsx(cn,{value:G,children:s.jsx(Hy,{})}):U?.mode==="git"?s.jsx(l.Suspense,{fallback:null,children:s.jsx(cn,{value:G,children:s.jsx(fv,{isActive:K})})}):U?.mode==="pr"?U.targetPath?s.jsx(Ew,{url:U.targetPath,directory:U.targetDirectory??u,panelDirectory:u,tabId:U.id,foreign:!!U.targetDirectory,visible:K},U.id):s.jsx(xw,{}):U?.mode==="notes"?s.jsx(cn,{value:G,children:s.jsx(Ff,{visible:K})}):U?.mode==="workflows"?s.jsx(cn,{value:G,children:s.jsx(vy,{directory:u||null})}):null,ct=U?.mode==="file",vt=ct&&!!U?.targetPath&&ee,St=K&&U&&ye&&!vt&&!xr(U)?U.id:null;l.useEffect(()=>{if(!(!f||!St))return ic(()=>g(f,St),Ke)},[g,f,St]);const mt=X(re=>re.closeContextPanelTabs),yt=l.useCallback(re=>{if(!f)return null;const{id:Ze,index:pt,allIds:kt,close:Pt}=re,Zt=()=>mt(f,kt.filter(fs=>fs!==Ze)),is=kt.slice(0,pt),z=kt.slice(pt+1),qe=()=>mt(f,a?z:is),ut=()=>mt(f,a?is:z),Tt=()=>mt(f,kt),Vt=kt.length>1,Ht=a?pt===kt.length-1:pt===0,Mt=a?pt===0:pt===kt.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Cs,{onClick:Pt,children:[s.jsx(se,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),s.jsx(Tn,{}),s.jsxs(Cs,{onClick:Zt,disabled:!Vt,children:[s.jsx(se,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Cs,{onClick:qe,disabled:Ht,children:[s.jsx(se,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Cs,{onClick:ut,disabled:Mt,children:[s.jsx(se,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),s.jsx(Tn,{}),s.jsxs(Cs,{onClick:Tt,disabled:!Vt,children:[s.jsx(se,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),U?s.jsxs(s.Fragment,{children:[s.jsx(Tn,{}),s.jsx(mc,{mode:U.mode})]}):null]})},[U,mt,f,a,o]),lt=l.useCallback((re,Ze)=>{const pt=B.find(Pt=>Pt.id===re);if(!pt)return null;const kt=Xi({mode:pt.mode,label:Ar(pt.mode,d),from:t},Ze);return{finish:()=>kt.finish(f),cancel:kt.cancel}},[f,d,B,t]),[Nt,_t]=l.useState(null),ht=l.useCallback(re=>{if(!U||re.button!==0||re.pointerType==="touch"||re.target instanceof Element&&re.target.closest(Cv))return;const Ze=U.mode,pt=Ar(Ze,d),kt={x:re.clientX,y:re.clientY};let Pt=!1;const Zt=ut=>{const Tt={x:ut.clientX,y:ut.clientY};!Pt&&(Math.hypot(Tt.x-kt.x,Tt.y-kt.y)<jv||(Pt=Pd({mode:Ze,label:pt,from:t}),!Pt))||Rd(Tt)},is=()=>{window.removeEventListener("pointermove",Zt),window.removeEventListener("pointerup",z),window.removeEventListener("pointercancel",qe),window.removeEventListener("blur",qe)},z=()=>{is(),Pt&&Dd(f)},qe=()=>{is(),Pt&&ci()};window.addEventListener("pointermove",Zt),window.addEventListener("pointerup",z),window.addEventListener("pointercancel",qe),window.addEventListener("blur",qe)},[U,f,d,t]);l.useEffect(()=>{if(Nt)return Nt.addEventListener("pointerdown",ht),()=>Nt.removeEventListener("pointerdown",ht)},[ht,Nt]);const gt=s.jsxs("header",{ref:_t,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[ye?s.jsx(Oh,{items:xt,activeId:U?.id??null,onSelect:re=>{f&&E(f,re)},onClose:re=>{f&&g(f,re)},onReorder:(re,Ze)=>{f&&F(f,re,Ze)},onDoubleClickTab:re=>{f&&x(f,re)},layoutMode:"scrollable",variant:"default",tabContextMenu:yt,onTabDragOut:lt}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3 group-has-[[data-context-panel-toolbar]]/panel-header:hidden",children:[U?cl(U,W):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:U?Ar(U.mode,d):null})]}),s.jsx("div",{ref:Z,className:"flex min-w-0 flex-1 items-stretch ps-1.5 empty:hidden"})]}),s.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 self-start px-1.5",children:[U?.mode==="browser"?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&M(f)},className:"h-7 w-7 p-0",title:o("contextPanel.browser.newTab"),"aria-label":o("contextPanel.browser.newTab"),children:s.jsx(se,{name:"add",className:"h-3.5 w-3.5"})}):null,ct?["left","right"].map(re=>{const Ze=re===v;if(!Ze&&!$)return null;const pt=o(Ze?"contextRail.editorTree.toggle":"contextRail.editor.toggle");return s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:Ze?y:j,className:"h-7 w-7 p-0",title:pt,"aria-label":pt,"aria-pressed":Ze?_:ee,children:s.jsx(se,{name:re==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})},re)}):null,Y?null:s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:st,className:"h-7 w-7 p-0","aria-label":o(ie?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:ie?s.jsx(se,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(se,{name:"fullscreen",className:"h-3.5 w-3.5"})})}),s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Ws,{label:o(ie?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),shortcut:xs(Ts("toggle_context_panel_expanded",h),"")})})]}),s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:je,className:"h-7 w-7 p-0",title:o("contextPanel.actions.closePanel"),"aria-label":o("contextPanel.actions.closePanel"),children:s.jsx(se,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Dt=K?Pe?`calc(var(${e.sizeVariable}) + ${yn}px)`:`min(var(${e.sizeVariable}), 100%)`:ve?`${yn}px`:"0px",Kt=Pe?`${yn}px`:"0px";L.current=Pe;const Yt=t==="bottom"&&Kn(p,m,"left"),js=t==="bottom"&&(P&&!J||Kn(p,m,"right")),Wt=`${K}|${ie}|${ve}|${K&&Pe}|${K?fe:""}`,ds=l.useRef(Wt),us=l.useRef(J),Jt=us.current!==J;l.useLayoutEffect(()=>{us.current=J},[J]),l.useLayoutEffect(()=>{if(ds.current===Wt)return;ds.current=Wt;const re=C.current;!Jt&&!re&&Nc(n)},[Wt,Jt,n]),l.useLayoutEffect(()=>{C.current=!1});const Is=!Tr(K,Xn(K),U?.mode),rs={[e.sizeVariable]:`${q}px`,...r?{height:Dt,maxHeight:"100%"}:{width:Dt,maxWidth:"100%"},transitionDuration:Jt||Ne?"0ms":`${n}ms`,transitionTimingFunction:Rn},os=`calc(var(${e.sizeVariable}) - ${e.gutterSize})`,Ut=l.useRef(Dt);Ut.current=Dt;const Hs=l.useRef(os);return Hs.current=os,s.jsxs("aside",{ref:Ke,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":K?"true":"false",tabIndex:-1,className:Le("flex min-h-0 flex-col overflow-clip bg-background","isolate",r?"relative w-full flex-shrink-0":"relative h-full flex-shrink-0",r?"transition-[height]":"transition-[width]","motion-reduce:transition-none"),style:rs,children:[s.jsx("div",{ref:Ye,tabIndex:-1,className:"absolute size-0 overflow-hidden outline-none"}),t==="right"?s.jsx("div",{ref:Mh,className:Le("absolute inset-y-0 z-0 flex",Pe?"inset-s-0":"inset-e-0",J&&"invisible")}):null,K&&s.jsx("div",{className:e.handle,style:{marginInlineStart:Kt},onPointerDown:Oe,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),s.jsx("div",{ref:ce,"data-zone-card":"",className:Le("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(Yt?"ms-0":"ms-2"),t==="bottom"&&(js?"me-0":"me-1.5"),r?null:"h-[calc(100%-0.5rem)]","oc-panel-edge overflow-hidden rounded-[10px] bg-background",r?"transition-[height,opacity]":"transition-[width,opacity,margin-inline-start]",!K&&"opacity-0",Is&&"pointer-events-none select-none"),style:{...r?{height:os,width:`calc(100% - ${(Yt?0:.5)+(js?0:.375)}rem)`}:{width:os},...t==="right"?{marginInlineStart:`calc(0.5rem + ${Kt})`}:null,transitionDuration:Ne?"0ms":`${n}ms`,transitionTimingFunction:Rn},inert:Is||void 0,children:s.jsxs(Wc.Provider,{value:!0,children:[gt,s.jsx("div",{ref:Q,className:"relative min-h-0 flex-1 overflow-hidden",children:U&&Tv(U.mode)?jt:null})]})})]})},Iv=Qs({port:mo().int().positive(),url:Ns().min(1),command:Ns(),directory:Ns().min(1).optional()}),Pv=t=>{const e=Qs({servers:md(Hb())}).safeParse(t);return e.success?e.data.servers.flatMap(n=>{const r=Iv.safeParse(n);return r.success?[r.data]:[]}):null},Rv=async(t,e)=>{try{const n=await zs("/api/dev-servers",{signal:t,directory:e});if(!n.ok)return{kind:"unavailable"};const r=Pv(await n.json());return r?{kind:"ready",servers:r}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},Dv=async t=>{try{const e=await zs("/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}},Av=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}},_v=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const o=Av(r);o!==null&&!n.has(o)&&n.set(o,r)}return e?e.map(r=>{const o=n.get(r.port);return{url:o??r.url,port:r.port,announced:o!==void 0,directory:r.directory}}).sort((r,o)=>r.announced!==o.announced?r.announced?-1:1:r.port-o.port):[...n.entries()].map(([r,o])=>({url:o,port:r,announced:!0})).sort((r,o)=>r.port-o.port)},Ov=(t,e)=>e===t||e.startsWith(t.endsWith("/")?t:`${t}/`),ul=(t,e)=>{if(!e)return null;let n=null;for(const r of t)Ov(r.path,e)&&(!n||r.path.length>n.path.length)&&(n=r);return n},Mv=t=>t.slice(t.lastIndexOf("/")+1)||t,Fv=({candidates:t,folders:e,directory:n})=>{const r=e.flatMap(c=>{const d=Xt(c.path),f=Xt(c.projectPath);return d&&f?[{path:d,projectPath:f}]:[]}),o=Xt(n),i=o?{path:o,projectPath:ul(r,o)?.projectPath??o}:null,a=i?[...r,i]:r;return t.map(c=>{const d=Xt(c.directory),f=ul(a,d),p=c.announced?0:f&&i&&f.path===i.path?1:f&&i&&f.projectPath===i.projectPath?2:3;return{server:{...c,folderName:f?Mv(f.path):null,outsideWork:d!==null&&f===null&&!c.announced},rank:p}}).sort((c,d)=>c.rank-d.rank||c.server.port-d.server.port).map(c=>c.server)},Lv=t=>({sessionId:t.sessionId,directory:t.directory?cs(t.directory):null}),$v=2e3,Bv=Qs({title:Ns(),settled:ar()}),zv=4e4,Wv=50,Yn=400,ms=new Map,Rs=new Map;let ui=null,fi=null;const cr=new Map;let Fs=null,Xs=null,Jn=null;const Ls=async t=>{try{const e=await zs("/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}},Uv=async(t,e)=>{try{const n=await zs("/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)}},Md=async(t,e=$v)=>{const n=Date.now()+e;for(;!ms.has(t)&&Date.now()<n;)await new Promise(r=>setTimeout(r,Wv));return ms.get(t)??null},Hr=t=>ms.has(t)||Rs.has(t),_n=t=>ms.get(t)??Rs.get(t)??null,pi=()=>[...ms.values(),...[...Rs.values()].filter(t=>!ms.has(t.tabId))],Qi=t=>{const e=fi?_n(fi):null,n=e?.directory===ui?e:null;if(!t.sessionId){if(n)return n.tabId;const i=pi().filter(c=>c.directory===ui),a=i.filter(c=>ms.has(c.tabId)),u=a.length>0?a:i;return u.length>0?u[u.length-1].tabId:null}if(n?.ownerSessionId===t.sessionId)return n.tabId;const r=cr.get(t.sessionId);if(r&&_n(r)?.ownerSessionId===t.sessionId)return r;const o=pi().filter(i=>i.ownerSessionId===t.sessionId);return o.length>0?o[o.length-1].tabId:n&&n.ownerSessionId===null&&(!t.directory||n.directory===t.directory)?n.tabId:null},Vv=t=>{const e=Qi(t);return e&&_n(e)?.ownerSessionId===t.sessionId?e:null},Hv=(t,e)=>{t.sessionId&&_n(e)?.ownerSessionId===t.sessionId&&cr.set(t.sessionId,e)},Fd=async t=>{const e=ms.get(t);if(e)return e;const n=Rs.get(t);return n?(n.wake(),Md(t)):null},Ld=t=>{const e=Qi(t);return pi().filter(n=>!t.sessionId||!t.directory||n.ownerSessionId===t.sessionId||n.directory===t.directory).map(n=>{let r={title:"",url:""};try{r=n.describe()}catch{}const o=n.ownerSessionId===null?"user":n.ownerSessionId===t.sessionId?"you":"another session";return{id:n.tabId,title:r.title,url:r.url,owner:o,active:n.tabId===e}})},$d=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,Bd=t=>`There is no browser tab with id ${t}. Call browser.snapshot to list the open tabs, or omit tabId to use this session's own tab.`,qv=t=>{const e=Ld(t);return"This session has no browser tab of its own, and the user is not looking at a tab of theirs in this session's project. Nothing was changed. Open the page with browser.open, or pass tabId to work in a tab the user points you to."+(e.length>0?` Open tabs:
6
6
  ${e.map(r=>`- ${r.id}: ${r.title||r.url||"blank"} (opened by ${r.owner})`).join(`
7
7
  `)}`:"")},Kv=()=>"This session has no browser tab of its own to close. Agent actions never close a tab the user opened. Open a page with browser.open first, or name a tab this session opened with tabId.",Gv=t=>`The browser tab ${t} was not opened by this session, so it was not closed. Agent actions never close a tab the user or another session opened. Name a tab from browser.snapshot whose owner is you.`,Zv=()=>"This browser.close did not come from a session, so there is no tab it opened to close. Nothing was closed.",es=(t,e)=>Uv(t.requestId,t.action==="browser.open"&&e.ok?{...e,data:Object.assign({},e.data,{drivable:Vc()})}:e),Xv=async(t,e,n)=>{if(!e.sessionId){if(!await Ls(t.requestId))return;await es(t,{ok:!1,error:Zv()});return}const r=n??Vv(e);if(r===null){if(await new Promise(a=>setTimeout(a,Yn)),!await Ls(t.requestId))return;await es(t,{ok:!1,error:Kv()});return}if(!Hr(r)){if(ms.size===0&&Rs.size===0&&!Xs)return;if(await new Promise(a=>setTimeout(a,Yn)),!Hr(r)){if(!await Ls(t.requestId))return;await es(t,{ok:!1,error:Bd(r)});return}}const o=_n(r);if(!o||o.ownerSessionId!==e.sessionId){if(!await Ls(t.requestId))return;await es(t,{ok:!1,error:Gv(r)});return}if(!await Ls(t.requestId))return;if(!(Xs?Xs(o.directory,r):!1)){await es(t,{ok:!1,error:Xs?`The browser tab ${r} could not be closed.`:"There is no browser here to close a tab in."});return}e.sessionId&&cr.get(e.sessionId)===r&&cr.delete(e.sessionId),await es(t,{ok:!0,data:{closed:!0,tabId:r}})},Yv=async t=>{const e=t.action==="browser.open",n=t.action==="browser.close",r=Lv(t.context),{tabId:o,...i}=t.parameters,a=o===void 0?null:String(o);if(n){await Xv(t,r,a);return}if(a!==null){if(!Hr(a)){if(ms.size===0&&Rs.size===0&&!Fs)return;if(await new Promise(d=>setTimeout(d,Yn)),Hr(a)){await fl(t,r,a,i);return}if(!await Ls(t.requestId))return;await es(t,{ok:!1,error:Bd(a)});return}await fl(t,r,a,i);return}const u=Qi(r);if(!u&&!(e&&Fs)){if(!r.sessionId||(await new Promise(d=>setTimeout(d,Yn)),!await Ls(t.requestId)))return;await es(t,{ok:!1,error:qv(r)});return}if(!(e&&Fs!==null)&&r.sessionId&&_n(u)?.ownerSessionId!==r.sessionId&&await new Promise(d=>setTimeout(d,Yn)),!!await Ls(t.requestId))try{const d=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!d){await es(t,{ok:!1,error:"url is required"});return}const f=Date.now(),p=e&&Fs?Fs(d,t.context):null;if(e&&!p&&!u){await es(t,{ok:!1,error:"There is no browser here to open the page in."});return}if(p){r.sessionId&&cr.set(r.sessionId,p);const h=typeof t.parameters.viewport=="string"?t.parameters.viewport:"",b=!!h&&h!=="fill",g=Vc();if(!b&&!g){await es(t,{ok:!0,data:{url:d,opened:!0,tabId:p}});return}const x=await Md(p);if(!x&&!b){await es(t,{ok:!0,data:{url:d,opened:!0,tabId:p,settled:!1}});return}if(!x){await es(t,{ok:!0,data:{url:d,opened:!0,tabId:p,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 w=b?await x.run("browser.resize",{viewport:h}):null,T=w&&typeof w=="object"?w.viewport??null:null,k=g?Bv.safeParse(await x.run("browser.settle",{budgetMs:Math.max(0,zv-(Date.now()-f))}).catch(()=>null)):null;await es(t,{ok:!0,data:Object.assign({url:d,opened:!0,tabId:p},b?{viewportApplied:!0,viewport:T}:{},k?k.success?k.data:{settled:!1}:{})});return}const m=await Fd(u);await es(t,m?await zd(m,r,t.action,i):{ok:!1,error:$d(u)})}catch(d){await es(t,{ok:!1,error:d instanceof Error?d.message:String(d)})}},fl=async(t,e,n,r)=>{if(!await Ls(t.requestId))return;Hv(e,n);const o=await Fd(n);await es(t,o?await zd(o,e,t.action,r):{ok:!1,error:$d(n)})},zd=async(t,e,n,r)=>{try{const o=await t.run(n,r);return n==="browser.snapshot"&&Object(o)===o?{ok:!0,data:{...Object(o),tabs:Ld(e)}}:{ok:!0,data:o}}catch(o){return{ok:!1,error:o instanceof Error?o.message:String(o)}}},bo=()=>{Jn||(Jn=Js(t=>{t.type==="browser-control-request"&&Yv({requestId:t.requestId,action:t.action,parameters:t.parameters,context:t.context})}))},xo=()=>{ms.size>0||Rs.size>0||Fs||Xs||!Jn||(Jn(),Jn=null)},Jv=t=>(ms.set(t.tabId,t),bo(),()=>{ms.get(t.tabId)===t&&ms.delete(t.tabId),xo()}),Qv=t=>(Rs.set(t.tabId,t),bo(),()=>{Rs.get(t.tabId)===t&&Rs.delete(t.tabId),xo()}),e0=(t,e)=>{ui=t,e&&(fi=e)},t0=t=>(Fs=t,bo(),()=>{Fs===t&&(Fs=null),xo()}),s0=t=>(Xs=t,bo(),()=>{Xs===t&&(Xs=null),xo()}),n0=50,r0=6,o0=2048,i0=200,Wd=t=>{const e=Cn(String(t??"").trim());if(!e||e.length>o0)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},a0=(t,e)=>{const n=Wd(e.url);if(!n)return t;const r=t.find(a=>a.url===n),o=String(e.title??"").trim().slice(0,i0)||r?.title||"";return[{url:n,title:o,lastVisitedAt:e.at},...t.filter(a=>a.url!==n)].slice(0,n0)},l0=(t,e)=>{const n=Wd(e);return t.filter(r=>r.url!==n)},c0=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Ud=(t,e,n=r0)=>{const r=String(e??"").trim().toLowerCase(),o=[...t].sort((a,u)=>u.lastVisitedAt-a.lastVisitedAt);if(!r)return o.slice(0,n);const i=r.replace(/^https?:\/\//,"");return o.filter(a=>{const u=c0(a);return a.url===r||u===i?!1:u.includes(i)}).slice(0,n)},pl=20,_r=t=>{const e=Xt((t||"").trim());return e?JSON.stringify([ns(),e]):""},d0=t=>{const e=Object.keys(t);if(e.length<=pl)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,o)=>o[1]-r[1]).slice(0,pl);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},Nn=po()(Vb(t=>({byProject:{},recordVisit:(e,n)=>{const r=_r(e);r&&t(o=>{const i=o.byProject[r]??[],a=a0(i,{...n,at:Date.now()});return a===i?o:{byProject:d0({...o.byProject,[r]:a})}})},forget:(e,n)=>{const r=_r(e);r&&t(o=>{const i=o.byProject[r];return i?{byProject:{...o.byProject,[r]:l0(i,n)}}:o})},clear:e=>{const n=_r(e);n&&t(r=>{if(!(n in r.byProject))return r;const o={...r.byProject};return delete o[n],{byProject:o}})}}),{name:"openchamber-browser-history",version:1,storage:Ou(),partialize:t=>({byProject:t.byProject})})),u0=[],Vd=t=>e=>{const n=_r(t);return(n?e.byProject[n]:void 0)??u0},ea=t=>{const e=$e.c(10),{t:n}=at();let r;e[0]!==t?(r=ks(t),e[0]=t,e[1]=r):r=e[1];const o=r;let i;e[2]!==o?(i=d=>o?d.journey?.get(o):void 0,e[2]=o,e[3]=i):i=e[3];const a=dn(i);if(o===null)return null;if(!a){let d;return e[4]!==n?(d=n("contextPanel.browser.spaceAddress"),e[4]=n,e[5]=d):d=e[5],d}let u;e[6]!==a.machine||e[7]!==a.placeId||e[8]!==n?(u=a.machine??(a.placeId==="docker"?n("spaces.create.place.localDocker"):a.placeId),e[6]=a.machine,e[7]=a.placeId,e[8]=n,e[9]=u):u=e[9];const c=u;return`${a.name} · ${c}`},ml=6e3,f0=120,p0=80,m0=32,h0=100,g0=`
8
8
  var MAX_ELEMENTS = ${f0};
@@ -495,4 +495,4 @@ ${t}
495
495
  inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
496
496
  styles: styles
497
497
  };
498
- `),C0=t=>{const e=$e.c(18),{entries:n,activeIndex:r,onSelect:o,onForget:i,onHighlight:a}=t,{t:u}=at();if(n.length===0)return null;let c;e[0]!==u?(c=u("contextPanel.browser.history.label"),e[0]=u,e[1]=c):c=e[1];let d;if(e[2]!==r||e[3]!==n||e[4]!==i||e[5]!==a||e[6]!==o||e[7]!==u){let p;e[9]!==r||e[10]!==i||e[11]!==a||e[12]!==o||e[13]!==u?(p=(m,h)=>s.jsxs("div",{role:"option","aria-selected":h===r,className:Le("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",h===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:b=>{b.preventDefault(),o(m.url)},onPointerEnter:()=>a(h),children:[s.jsx(se,{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:m.title||eo(m.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:m.url})]}),s.jsx("button",{type:"button",className:Le("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":u("contextPanel.browser.history.forget"),title:u("contextPanel.browser.history.forget"),onPointerDown:b=>{b.preventDefault(),b.stopPropagation(),i(m.url)},children:s.jsx(se,{name:"close",className:"size-3","aria-hidden":"true"})})]},m.url),e[9]=r,e[10]=i,e[11]=a,e[12]=o,e[13]=u,e[14]=p):p=e[14],d=n.map(p),e[2]=r,e[3]=n,e[4]=i,e[5]=a,e[6]=o,e[7]=u,e[8]=d}else d=e[8];let f;return e[15]!==c||e[16]!==d?(f=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":c,children:d}),e[15]=c,e[16]=d,e[17]=f):f=e[17],f},vs=t=>{const e=$e.c(17),{icon:n,label:r,onClick:o,disabled:i,pressed:a}=t,u=a?"secondary":"ghost",c=a&&"text-foreground";let d;e[0]!==c?(d=Le("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",c),e[0]=c,e[1]=d):d=e[1];let f;e[2]!==n?(f=s.jsx(se,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=f):f=e[3];let p;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==a||e[8]!==u||e[9]!==d||e[10]!==f?(p=s.jsx(Ft,{asChild:!0,children:s.jsx(dt,{type:"button",variant:u,size:"xs",className:d,onClick:o,disabled:i,"aria-label":r,"aria-pressed":a,children:f})}),e[4]=i,e[5]=r,e[6]=o,e[7]=a,e[8]=u,e[9]=d,e[10]=f,e[11]=p):p=e[11];let m;e[12]!==r?(m=s.jsx($t,{sideOffset:6,children:r}),e[12]=r,e[13]=m):m=e[13];let h;return e[14]!==p||e[15]!==m?(h=s.jsxs(Lt,{children:[p,m]}),e[14]=p,e[15]=m,e[16]=h):h=e[16],h},Hd=t=>{const e=$e.c(110),{address:n,addressMark:r,suggestions:o,onForgetSuggestion:i,onAddressChange:a,onSubmit:u,onBack:c,onForward:d,onReload:f,onOpenExternal:p,canOpenExternal:m,canGoBack:h,canGoForward:b,isLoading:g,onAnnotate:x,onOpenDevTools:w,isAnnotating:T,onHardReload:k,onZoomIn:E,onZoomOut:F,onZoomReset:_,zoomPercent:A,onClearCookies:D,onClearCache:y,onToggleDeviceBar:N,isDeviceBarOpen:j}=t;let v;e[0]!==o?(v=o===void 0?[]:o,e[0]=o,e[1]=v):v=e[1];const M=v,W=m===void 0?!0:m,G=A===void 0?100:A,{t:O}=at(),[Z,Q]=l.useState(!1),[B,oe]=l.useState(-1);let H;e[2]!==Z||e[3]!==M?(H=Z?M:[],e[2]=Z,e[3]=M,e[4]=H):H=e[4];const P=H;let te;e[5]===Symbol.for("react.memo_cache_sentinel")?(te=()=>{oe(-1)},e[5]=te):te=e[5];let J;e[6]!==n||e[7]!==Z?(J=[n,Z],e[6]=n,e[7]=Z,e[8]=J):J=e[8],l.useEffect(te,J);let le;e[9]!==u?(le=He=>{Q(!1),oe(-1),u(He)},e[9]=u,e[10]=le):le=e[10];const K=le;let U;e[11]!==B||e[12]!==K||e[13]!==P?(U=He=>{if(P.length!==0){if(He.key==="ArrowDown"||He.key==="ArrowUp"){He.preventDefault();const Ke=He.key==="ArrowDown"?1:-1,Ye=P.length;oe(it=>{const bt=it+Ke;return bt<-1?Ye-1:bt>=Ye?-1:bt});return}if(He.key==="Escape"&&B>=0){He.preventDefault(),oe(-1);return}if(He.key==="Enter"&&B>=0){He.preventDefault();const Ke=P[B];Ke&&K(Ke.url)}}},e[11]=B,e[12]=K,e[13]=P,e[14]=U):U=e[14];const $=U;let ee;e[15]!==O?(ee=O("contextPanel.browser.back"),e[15]=O,e[16]=ee):ee=e[16];const Y=!h;let ie;e[17]!==c||e[18]!==ee||e[19]!==Y?(ie=s.jsx(vs,{icon:"arrow-left",label:ee,onClick:c,disabled:Y}),e[17]=c,e[18]=ee,e[19]=Y,e[20]=ie):ie=e[20];let V;e[21]!==O?(V=O("contextPanel.browser.forward"),e[21]=O,e[22]=V):V=e[22];const fe=!b;let Se;e[23]!==d||e[24]!==V||e[25]!==fe?(Se=s.jsx(vs,{icon:"arrow-right",label:V,onClick:d,disabled:fe}),e[23]=d,e[24]=V,e[25]=fe,e[26]=Se):Se=e[26];let Te;e[27]!==g||e[28]!==O?(Te=O(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=g,e[28]=O,e[29]=Te):Te=e[29];let ue;e[30]!==f||e[31]!==Te?(ue=s.jsx(vs,{icon:"refresh",label:Te,onClick:f}),e[30]=f,e[31]=Te,e[32]=ue):ue=e[32];let Me;e[33]!==k||e[34]!==O?(Me=k?s.jsx(vs,{icon:"restart",label:O("contextPanel.browser.hardReload"),onClick:k}):null,e[33]=k,e[34]=O,e[35]=Me):Me=e[35];let Ae;e[36]!==n||e[37]!==K?(Ae=He=>{He.preventDefault(),K(n)},e[36]=n,e[37]=K,e[38]=Ae):Ae=e[38];let De;e[39]!==r?(De=r?s.jsx("span",{className:"pointer-events-none absolute inset-s-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",title:r.label,"aria-label":r.label,role:"img",children:s.jsx(se,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[39]=r,e[40]=De):De=e[40];let Be;e[41]!==a?(Be=He=>a(He.target.value),e[41]=a,e[42]=Be):Be=e[42];let we,ve;e[43]===Symbol.for("react.memo_cache_sentinel")?(we=()=>Q(!0),ve=()=>Q(!1),e[43]=we,e[44]=ve):(we=e[43],ve=e[44]);const Pe=P.length>0,he=r&&"ps-8";let Fe;e[45]!==he?(Fe=Le("oc-raised oc-field h-6 w-full rounded-full bg-[var(--surface-elevated)] px-3",he,"typography-micro text-foreground outline-none"),e[45]=he,e[46]=Fe):Fe=e[46];let _e;e[47]!==O?(_e=O("contextPanel.browser.addressAria"),e[47]=O,e[48]=_e):_e=e[48];let We;e[49]!==n||e[50]!==$||e[51]!==Be||e[52]!==Pe||e[53]!==Fe||e[54]!==_e?(We=s.jsx("input",{value:n,onChange:Be,onFocus:we,onBlur:ve,onKeyDown:$,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":Pe,"aria-controls":"openchamber-browser-address-suggestions",className:Fe,"aria-label":_e}),e[49]=n,e[50]=$,e[51]=Be,e[52]=Pe,e[53]=Fe,e[54]=_e,e[55]=We):We=e[55];let Xe;e[56]!==i?(Xe=He=>i?.(He),e[56]=i,e[57]=Xe):Xe=e[57];let Ve;e[58]!==B||e[59]!==K||e[60]!==Xe||e[61]!==P?(Ve=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(C0,{entries:P,activeIndex:B,onSelect:K,onForget:Xe,onHighlight:oe})}),e[58]=B,e[59]=K,e[60]=Xe,e[61]=P,e[62]=Ve):Ve=e[62];let S;e[63]!==Ae||e[64]!==De||e[65]!==We||e[66]!==Ve?(S=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:Ae,children:[De,We,Ve]}),e[63]=Ae,e[64]=De,e[65]=We,e[66]=Ve,e[67]=S):S=e[67];let ne;e[68]!==E||e[69]!==F||e[70]!==_||e[71]!==O||e[72]!==G?(ne=F&&E?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(vs,{icon:"subtract",label:O("contextPanel.browser.zoomOut"),onClick:F}),G!==100&&_?s.jsxs(Lt,{children:[s.jsx(Ft,{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:_,"aria-label":O("contextPanel.browser.zoomReset"),children:[G,"%"]})}),s.jsx($t,{sideOffset:6,children:O("contextPanel.browser.zoomReset")})]}):null,s.jsx(vs,{icon:"add",label:O("contextPanel.browser.zoomIn"),onClick:E})]}):null,e[68]=E,e[69]=F,e[70]=_,e[71]=O,e[72]=G,e[73]=ne):ne=e[73];let q;e[74]!==D||e[75]!==O?(q=D?s.jsx(vs,{icon:"delete-bin",label:O("contextPanel.browser.clearCookies"),onClick:D}):null,e[74]=D,e[75]=O,e[76]=q):q=e[76];let ke;e[77]!==y||e[78]!==O?(ke=y?s.jsx(vs,{icon:"database-2",label:O("contextPanel.browser.clearCache"),onClick:y}):null,e[77]=y,e[78]=O,e[79]=ke):ke=e[79];let Ee;e[80]!==j||e[81]!==N||e[82]!==O?(Ee=N?s.jsx(vs,{icon:"smartphone",label:O("contextPanel.browser.deviceToolbar"),onClick:N,pressed:j}):null,e[80]=j,e[81]=N,e[82]=O,e[83]=Ee):Ee=e[83];let Ie;e[84]!==T||e[85]!==x||e[86]!==O?(Ie=x?s.jsx(vs,{icon:"markup",label:O("contextPanel.browser.annotate.toggle"),onClick:x,pressed:T}):null,e[84]=T,e[85]=x,e[86]=O,e[87]=Ie):Ie=e[87];let Ne;e[88]!==w||e[89]!==O?(Ne=w?s.jsx(vs,{icon:"terminal-box",label:O("contextPanel.browser.devTools"),onClick:w}):null,e[88]=w,e[89]=O,e[90]=Ne):Ne=e[90];let ze;e[91]!==O?(ze=O("contextPanel.browser.openExternal"),e[91]=O,e[92]=ze):ze=e[92];const Ue=!W;let Ge;e[93]!==p||e[94]!==ze||e[95]!==Ue?(Ge=s.jsx(vs,{icon:"external-link",label:ze,onClick:p,disabled:Ue}),e[93]=p,e[94]=ze,e[95]=Ue,e[96]=Ge):Ge=e[96];let Qe;return e[97]!==ie||e[98]!==Se||e[99]!==ue||e[100]!==Me||e[101]!==S||e[102]!==ne||e[103]!==q||e[104]!==ke||e[105]!==Ee||e[106]!==Ie||e[107]!==Ne||e[108]!==Ge?(Qe=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[ie,Se,ue,Me,S,ne,q,ke,Ee,Ie,Ne,Ge]}),e[97]=ie,e[98]=Se,e[99]=ue,e[100]=Me,e[101]=S,e[102]=ne,e[103]=q,e[104]=ke,e[105]=Ee,e[106]=Ie,e[107]=Ne,e[108]=Ge,e[109]=Qe):Qe=e[109],Qe},qr={kind:"fill"},hl=240,T0=3840,qd=[{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}],gl=t=>Number.isFinite(t)?Math.round(Math.min(T0,Math.max(hl,t))):hl,Kr=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Kd=t=>{const e=qd.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},N0=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},E0=(t,e)=>{const n=Kr(t);if(!n)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/n.width,o/n.height);return{width:n.width,height:n.height,scale:i}},I0=["mobile","tablet","desktop","fill"],P0={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},bl=t=>typeof t=="string"&&I0.includes(t),mi=t=>t==="fill"?qr:Kd(P0[t])??qr,yr=t=>{const e=Kr(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=mi(n),o=Kr(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},R0=t=>{const e=$e.c(70),{viewport:n,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:a}=t,{t:u}=at();let c;e[0]!==n?(c=Kr(n),e[0]=n,e[1]=c):c=e[1];const d=c,f=n.kind==="preset"?n.id:"";let p;e[2]!==r||e[3]!==d?(p=(U,$)=>{const ee=Number.parseInt($,10);if(!Number.isFinite(ee))return;const Y=d??{width:1280,height:800};r({kind:"custom",width:gl(U==="width"?ee:Y.width),height:gl(U==="height"?ee:Y.height)})},e[2]=r,e[3]=d,e[4]=p):p=e[4];const m=p;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Le("oc-raised oc-field h-6 w-14 rounded-full bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none"),e[5]=h):h=e[5];const b=h;let g;e[6]!==r?(g=U=>{const $=Kd(U.target.value);r($??qr)},e[6]=r,e[7]=g):g=e[7];let x;e[8]!==u?(x=u("contextPanel.browser.device.preset"),e[8]=u,e[9]=x):x=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=Le("oc-raised oc-field h-6 shrink-0 rounded-full bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none"),e[10]=w):w=e[10];let T;e[11]!==u?(T=u("contextPanel.browser.device.responsive"),e[11]=u,e[12]=T):T=e[12];let k;e[13]!==T?(k=s.jsx("option",{value:"",children:T}),e[13]=T,e[14]=k):k=e[14];let E;e[15]===Symbol.for("react.memo_cache_sentinel")?(E=qd.map(D0),e[15]=E):E=e[15];let F;e[16]!==f||e[17]!==g||e[18]!==x||e[19]!==k?(F=s.jsxs("select",{value:f,onChange:g,"aria-label":x,className:w,children:[k,E]}),e[16]=f,e[17]=g,e[18]=x,e[19]=k,e[20]=F):F=e[20];const _=d?String(d.width):"";let A;e[21]!==m?(A=U=>m("width",U.target.value),e[21]=m,e[22]=A):A=e[22];let D;e[23]!==u?(D=u("contextPanel.browser.device.width"),e[23]=u,e[24]=D):D=e[24];let y;e[25]!==_||e[26]!==A||e[27]!==D?(y=s.jsx("input",{value:_,onChange:A,placeholder:"—",inputMode:"numeric","aria-label":D,className:b}),e[25]=_,e[26]=A,e[27]=D,e[28]=y):y=e[28];let N;e[29]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=N):N=e[29];const j=d?String(d.height):"";let v;e[30]!==m?(v=U=>m("height",U.target.value),e[30]=m,e[31]=v):v=e[31];let M;e[32]!==u?(M=u("contextPanel.browser.device.height"),e[32]=u,e[33]=M):M=e[33];let W;e[34]!==j||e[35]!==v||e[36]!==M?(W=s.jsx("input",{value:j,onChange:v,placeholder:"—",inputMode:"numeric","aria-label":M,className:b}),e[34]=j,e[35]=v,e[36]=M,e[37]=W):W=e[37];let G;e[38]!==r||e[39]!==n?(G=()=>r(N0(n)),e[38]=r,e[39]=n,e[40]=G):G=e[40];const O=!d;let Z;e[41]!==u?(Z=u("contextPanel.browser.device.rotate"),e[41]=u,e[42]=Z):Z=e[42];let Q;e[43]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(se,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=Q):Q=e[43];let B;e[44]!==G||e[45]!==O||e[46]!==Z?(B=s.jsx(Ft,{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:G,disabled:O,"aria-label":Z,children:Q})}),e[44]=G,e[45]=O,e[46]=Z,e[47]=B):B=e[47];let oe;e[48]!==u?(oe=u("contextPanel.browser.device.rotate"),e[48]=u,e[49]=oe):oe=e[49];let H;e[50]!==oe?(H=s.jsx($t,{sideOffset:6,children:oe}),e[50]=oe,e[51]=H):H=e[51];let P;e[52]!==B||e[53]!==H?(P=s.jsxs(Lt,{children:[B,H]}),e[52]=B,e[53]=H,e[54]=P):P=e[54];let te;e[55]!==a||e[56]!==d?(te=d&&a<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(a*100),"%"]}):null,e[55]=a,e[56]=d,e[57]=te):te=e[57];let J;e[58]===Symbol.for("react.memo_cache_sentinel")?(J=["system","light","dark"],e[58]=J):J=e[58];let le;e[59]!==o||e[60]!==i||e[61]!==u?(le=s.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:J.map(U=>s.jsx(dt,{type:"button",variant:o===U?"secondary":"ghost",size:"xs",className:Le("shrink-0 rounded-full px-2.5 typography-micro",o===U?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(U),"aria-pressed":o===U,children:u(U==="system"?"contextPanel.browser.device.schemeSystem":U==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},U))}),e[59]=o,e[60]=i,e[61]=u,e[62]=le):le=e[62];let K;return e[63]!==F||e[64]!==y||e[65]!==W||e[66]!==P||e[67]!==te||e[68]!==le?(K=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[F,y,N,W,P,te,le]}),e[63]=F,e[64]=y,e[65]=W,e[66]=P,e[67]=te,e[68]=le,e[69]=K):K=e[69],K};function D0(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const Gr=new Map,hi=new Set,Gd=()=>{for(const t of hi)t()},Wo=(t,e)=>{const n=t.trim();n&&(e.length===0?Gr.delete(n):Gr.set(n,[...e]),Gd())},A0=t=>{Gr.delete(t.trim())&&Gd()},Zd=[],_0=t=>Gr.get(t.trim())??Zd,O0=t=>(hi.add(t),()=>{hi.delete(t)}),M0=t=>{const e=$e.c(2);let n;return e[0]!==t?(n=()=>_0(t),e[0]=t,e[1]=n):n=e[1],l.useSyncExternalStore(O0,n,F0)};function F0(){return Zd}const Xd="oc.browser.hiddenDevServerPorts.v1",L0=ni(Ns(),md(mo().int().positive())),gi=new Set,Yd=[];let vr=null;const ta=()=>{const t=to().getItem(Xd);if(vr&&vr.raw===t)return vr.value;let e={};if(t!==null)try{const n=L0.safeParse(JSON.parse(t));n.success&&(e=n.data)}catch{e={}}return vr={raw:t,value:e},e},Jd=t=>{to().setItem(Xd,JSON.stringify(t));for(const e of gi)e()},$0=(t=ns())=>ta()[t]??Yd,B0=t=>{const e=ns(),n=ta(),r=n[e]??[];r.includes(t)||Jd({...n,[e]:[...r,t].sort((o,i)=>o-i)})},z0=()=>{const t=ns(),e=ta();if(!e[t])return;const n={...e};delete n[t],Jd(n)},W0=t=>(gi.add(t),()=>{gi.delete(t)}),U0=()=>l.useSyncExternalStore(W0,V0,H0);function V0(){return $0()}function H0(){return Yd}const q0=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},K0=2e3,G0=t=>gc("http://localhost",t),Qd=t=>{const e=$e.c(62),{onOpen:n,directory:r,visible:o}=t,i=r===void 0?"":r,{t:a}=at();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={kind:"loading"},e[0]=u):u=e[0];const[c,d]=l.useState(u),f=M0(i);let p;e[1]!==i?(p=()=>G0(i),e[1]=i,e[2]=p):p=e[2];const[m]=l.useState(p);let h;e[3]!==i?(h=()=>Lf(i),e[3]=i,e[4]=h):h=e[4];const[b]=l.useState(h);let g;e[5]!==i?(g=ki(i),e[5]=i,e[6]=g):g=e[6];const x=g,w=ea(i),T=Mu(i);let k,E;e[7]!==i||e[8]!==T||e[9]!==o?(k=()=>{if(T){d({kind:"ready",servers:[]});return}if(!o)return;let K=!0,U=null;const $=new AbortController,ee=()=>{Rv($.signal,i).then(Y=>{K&&(d(Y),U=setTimeout(ee,K0))})};return ee(),()=>{K=!1,U&&clearTimeout(U),$.abort()}},E=[i,T,o],e[7]=i,e[8]=T,e[9]=o,e[10]=k,e[11]=E):(k=e[10],E=e[11]),l.useEffect(k,E);const F=ts(Z0),_=et(X0);let A;if(e[12]!==F||e[13]!==_){const K=F.map(Y0);let U;e[15]!==_?(U=[..._].flatMap(J0),e[15]=_,e[16]=U):U=e[16],A=[...K,...U],e[12]=F,e[13]=_,e[14]=A}else A=e[14];const D=A;let y;e[17]!==f||e[18]!==i||e[19]!==c.kind||e[20]!==c.servers||e[21]!==D?(y=Fv({candidates:_v({announced:f,discovered:c.kind==="ready"?c.servers:null}),folders:D,directory:i}),e[17]=f,e[18]=i,e[19]=c.kind,e[20]=c.servers,e[21]=D,e[22]=y):y=e[22];const N=y,j=U0(),[v,M]=l.useState(!1);let W;if(e[23]!==N||e[24]!==j||e[25]!==v){let K;e[27]!==j||e[28]!==v?(K=U=>U.announced||!j.includes(U.port)&&(v||!U.outsideWork),e[27]=j,e[28]=v,e[29]=K):K=e[29],W=N.filter(K),e[23]=N,e[24]=j,e[25]=v,e[26]=W}else W=e[26];const G=W,O=N.length-G.length;let Z;e[30]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(Bh,{width:110,height:110,className:"shrink-0 opacity-20"}),e[30]=Z):Z=e[30];let Q;e[31]!==a?(Q=a("contextPanel.browser.empty"),e[31]=a,e[32]=Q):Q=e[32];let B;e[33]!==Q?(B=s.jsx("span",{className:"typography-ui-header text-foreground",children:Q}),e[33]=Q,e[34]=B):B=e[34];let oe;e[35]!==a?(oe=a("contextPanel.browser.emptyHint"),e[35]=a,e[36]=oe):oe=e[36];let H;e[37]!==oe?(H=s.jsx("span",{className:"typography-micro text-muted-foreground",children:oe}),e[37]=oe,e[38]=H):H=e[38];let P;e[39]!==B||e[40]!==H?(P=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[B,H]}),e[39]=B,e[40]=H,e[41]=P):P=e[41];let te;e[42]!==f||e[43]!==N.length||e[44]!==i||e[45]!==O||e[46]!==x||e[47]!==n||e[48]!==m||e[49]!==w||e[50]!==b||e[51]!==a||e[52]!==G?(te=N.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-start text-muted-foreground",children:f.length>0?a("contextPanel.browser.devServers.justStarted"):a("contextPanel.browser.devServers.title")}),m&&!b?s.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx(hs,{outerClassName:"min-h-0",className:"flex flex-col gap-1 pe-0.5",disableHorizontal:!0,children:G.map(K=>s.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[s.jsxs(dt,{type:"button",variant:"outline",size:"sm",className:Le("min-w-0 flex-1 justify-start gap-2",m&&"cursor-default opacity-60"),"aria-disabled":m||void 0,onClick:()=>{m||(A0(i),n(K.url))},children:[x?s.jsx("span",{className:"shrink-0",role:"img","aria-label":w??a("contextPanel.browser.spaceAddress"),title:w??a("contextPanel.browser.spaceAddress"),children:s.jsx(se,{name:"instance",className:"size-3.5","aria-hidden":"true"})}):s.jsx(se,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsxs("span",{className:"truncate",children:[eo(K.url)||K.url,s.jsx("span",{className:"typography-micro text-muted-foreground",children:q0(K.url)})]}),b?s.jsx("span",{className:"ms-auto shrink-0 text-muted-foreground",role:"img","aria-label":a("contextPanel.browser.devServers.spaceOnlyDesktop"),title:a("contextPanel.browser.devServers.spaceOnlyDesktop"),children:s.jsx(se,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):K.folderName?s.jsxs("span",{className:"ms-auto flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",title:K.directory,children:[s.jsx(se,{name:"folder",className:"size-3 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",dir:"auto",children:K.folderName})]}):null]}),K.announced?null:s.jsx(dt,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground opacity-0 group-hover/server:opacity-100 focus-visible:opacity-100",onClick:()=>B0(K.port),"aria-label":a("contextPanel.browser.devServers.hide",{port:K.port}),title:a("contextPanel.browser.devServers.hide",{port:K.port}),children:s.jsx(se,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})]},K.port))}),O>0?s.jsx(dt,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:()=>{z0(),M(!0)},children:O===1?a("contextPanel.browser.devServers.showHiddenSingle",{count:O}):a("contextPanel.browser.devServers.showHiddenPlural",{count:O})}):null]}):null,e[42]=f,e[43]=N.length,e[44]=i,e[45]=O,e[46]=x,e[47]=n,e[48]=m,e[49]=w,e[50]=b,e[51]=a,e[52]=G,e[53]=te):te=e[53];let J;e[54]!==N.length||e[55]!==c.kind||e[56]!==a?(J=N.length===0&&c.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.unavailable")}):null,e[54]=N.length,e[55]=c.kind,e[56]=a,e[57]=J):J=e[57];let le;return e[58]!==P||e[59]!==te||e[60]!==J?(le=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:[Z,P,te,J]}),e[58]=P,e[59]=te,e[60]=J,e[61]=le):le=e[61],le};function Z0(t){return t.projects}function X0(t){return t.availableWorktreesByProject}function Y0(t){return{path:t.path,projectPath:t.path}}function J0(t){const[e,n]=t;return n.map(r=>({path:r.path,projectPath:e}))}const Q0=3e4,eS=3,tS=250,sS={attempts:0,windowStartedAt:null},nS=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=Q0,r=n?0:t.attempts;return r>=eS?null:{delayMs:tS*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},rS=-3,Sr=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",jn=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},oS=(t,{initialUrl:e,onUrlChange:n})=>{const[r,o]=l.useState(e?{kind:"loading",url:e}:zh),[i,a]=l.useState(e),[u,c]=l.useState(""),[d,f]=l.useState(!1),[p,m]=l.useState(!1),h=l.useRef(n);h.current=n;const b=l.useRef(sS);return l.useEffect(()=>{if(!t)return;const g=()=>{try{const N=t.getURL();return Sr(N)?N:""}catch{return""}},x=()=>{try{f(t.canGoBack()),m(t.canGoForward())}catch{}},w=N=>{Sr(N)&&(a(N),h.current(N))},T=()=>{const N=g();o({kind:"loading",url:N})},k=()=>{const N=g();let j="";try{j=t.getTitle()||""}catch{j=""}c(j),w(N),x(),o(v=>v.kind==="failed"?v:{kind:"ready",url:N,title:j})},E=N=>{const j=jn(N);Sr(j.url)&&(w(j.url),x())},F=N=>{const j=jn(N),v=Array.isArray(j.favicons)?j.favicons.find(Boolean):"",M=g();if(!v||!M)return;let W=-1;try{W=t.getWebContentsId()}catch{return}!Number.isFinite(W)||W<0||Id.getState().resolve(M,v,W)},_=N=>{const j=jn(N);typeof j.title=="string"&&c(j.title)},A=N=>{const j=jn(N);if(j.isMainFrame===!1)return;const v=typeof j.errorCode=="number"?j.errorCode:0;v!==rS&&o({kind:"failed",url:Sr(j.validatedURL)?j.validatedURL:g(),code:v,description:typeof j.errorDescription=="string"?j.errorDescription:""})};let D=null;const y=()=>{const N=g(),j=nS(b.current,Date.now());if(!j){o({kind:"failed",url:N,code:0,description:"",crashed:!0});return}b.current=j.state,o({kind:"loading",url:N}),D=setTimeout(()=>{D=null;try{t.reload()}catch{o({kind:"failed",url:N,code:0,description:"",crashed:!0})}},j.delayMs)};t.addEventListener("did-start-loading",T),t.addEventListener("did-stop-loading",k),t.addEventListener("did-navigate",E),t.addEventListener("did-navigate-in-page",E),t.addEventListener("page-title-updated",_),t.addEventListener("page-favicon-updated",F),t.addEventListener("did-fail-load",A),t.addEventListener("render-process-gone",y),t.addEventListener("crashed",y);try{!t.isLoading()&&g()&&k()}catch{}return()=>{D!==null&&clearTimeout(D),t.removeEventListener("render-process-gone",y),t.removeEventListener("crashed",y),t.removeEventListener("did-start-loading",T),t.removeEventListener("did-stop-loading",k),t.removeEventListener("did-navigate",E),t.removeEventListener("did-navigate-in-page",E),t.removeEventListener("page-title-updated",_),t.removeEventListener("page-favicon-updated",F),t.removeEventListener("did-fail-load",A)}},[t]),{status:r,url:i,title:u,canGoBack:d,canGoForward:p}},xl=1e3,eu=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},iS=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},aS=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},lS=(t,e)=>{const n=l.useRef(0),r=l.useRef(0),o=l.useRef(0),i=l.useRef(null),a=l.useCallback(()=>{if(!t||document.activeElement!==t)return;const u=i.current;u&&u.isConnected&&u!==document.body?u.focus({preventScroll:!0}):t.blur()},[t]);return l.useEffect(()=>{if(!t)return;document.activeElement!==t&&(i.current=aS());const u=c=>{if(document.activeElement!==t){i.current=iS(c);return}const d=e.current,f=n.current>r.current||Date.now()<o.current;d&&eu(d)&&!f||r.current>0||a()};return document.addEventListener("focusin",u,!0),()=>document.removeEventListener("focusin",u,!0)},[a,e,t]),l.useCallback(async u=>{const c=t!==null&&document.activeElement===t;let d=!1;const f=()=>{d&&(d=!1,r.current-=1,o.current=Date.now()+xl,!c&&r.current===0&&a())},p=()=>(d||(d=!0,r.current+=1),f);n.current+=1;try{return await u(p)}finally{n.current-=1,o.current=Date.now()+xl,f()}},[a,t])},cS=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),dS=()=>document.visibilityState==="visible",uS=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,kr=.5,fS=-3,pS=4,mS="persist:openchamber-browser",tu=(t,e,n)=>ks(t)!==null&&Jl(e)?{icon:"instance",label:n}:void 0,wl=t=>{const e=ks(t);return e?`openchamber-space-preview:${e}`:mS},yl="openchamber:browser-panel-open-tab",hS=Qs({webContentsId:mo(),url:Ns().min(1),background:ar()}),vl=20,gS=600,bS=2e4,xS=15e3,Sl=500,kl=5e3,wS=3e4,yS=3e3,jl=1e3,vS=250,SS=Qs({quiet:ar()}),kS=()=>new Promise(t=>{let e=0,n=0,r=0,o;const i=d=>{clearTimeout(o),t(d)},a=()=>{e+=1,e>=2?i(!0):requestAnimationFrame(a)},u=()=>{n=e,r=performance.now()+jl,o=setTimeout(c,jl)},c=()=>{e>n||performance.now()-r>vS?u():i(!1)};requestAnimationFrame(a),u()}),jS=t=>{if(!t||eu(t))return()=>{};const e=t.getBoundingClientRect(),n=t.style.cssText;return Object.assign(t.style,{position:"fixed",top:`${e.top}px`,left:`${Math.max(0,Math.min(e.left,window.innerWidth-e.width))}px`,width:`${e.width}px`,height:`${e.height}px`,visibility:"visible",opacity:"0",pointerEvents:"none"}),()=>{t.style.cssText=n}},CS=({initialUrl:t,directory:e,siteDirectory:n,tabID:r,ownerSessionId:o,visible:i})=>{const{t:a}=at(),{currentTheme:u}=so(),c=l.useRef(null),[d,f]=l.useState(null),p=l.useCallback(ae=>{c.current=ae,f(ae)},[]),m=X(ae=>ae.setContextPanelTabTargetPath),h=l.useRef(Cn(t)),b=h.current!==Gs?h.current:"",[g,x]=l.useState(b?null:Gs),w=ea(n),[T,k]=l.useState(b),[E,F]=l.useState(!1),[_,A]=l.useState(!1),[D,y]=l.useState(0),N=l.useRef(0),[j,v]=l.useState(!1),[M,W]=l.useState(qr),G=l.useRef(M);G.current=M;const O=l.useRef([]),[Z,Q]=l.useState("system"),[B,oe]=l.useState({width:0,height:0}),H=l.useRef(null),P=l.useRef(null),te=cs(e),J=l.useRef(!!b&&!Fu(te,r)),le=l.useRef(null);l.useEffect(()=>{Yl(te,r)},[te,r]);const K=l.useRef(!1),U=l.useRef(Date.now()),$=l.useCallback(ae=>{!ae||ae===Gs||!e||!r||m(e,r,ae)},[e,r,m]),ee=oS(d,{initialUrl:b,onUrlChange:l.useCallback(ae=>{const de=xn(ae);k(de),$(de)},[$])}),[Y,ie]=l.useState(null),[V,fe]=l.useState(ks(n)===null);l.useEffect(()=>{const ae=ks(n);if(ae===null){fe(!0);return}let de=!0;return fe(!1),kn("desktop_space_preview_prepare",{spaceId:ae}).then(()=>{de&&fe(!0)}).catch(()=>{de&&ie(b||"http://localhost/")}),()=>{de=!1}},[n,b]);const Se=Wh(e),Te=Uh(),ue=ee.status.kind==="loading",Me=Nn(Vd(n)),Ae=Nn(ae=>ae.recordVisit),De=Nn(ae=>ae.forget);l.useEffect(()=>{ee.status.kind==="ready"&&Ae(n,{url:xn(ee.status.url),title:ee.status.title})},[n,ee.status,Ae]);const Be=l.useMemo(()=>Ud(Me,T),[Me,T]),we=l.useCallback(ae=>{const de=Cn(ae);de!==Gs&&(J.current=!1,k(de),ie(null),xa(de,n).then(be=>{const C=c.current;if(!C){x(be);return}try{C.loadURL(be)}catch{x(be)}}).catch(be=>{be instanceof wa&&ie(de)}))},[n]);l.useEffect(()=>{if(!b)return;let ae=!0;return xa(b,n).then(de=>{ae&&x(de)}).catch(de=>{if(ae){if(de instanceof wa){ie(b),J.current=!1,x(Gs);return}x(b)}}),()=>{ae=!1}},[]);const ve=l.useMemo(()=>({executeJavaScript:async(ae,de)=>{const be=c.current;if(!be)throw new Error("Browser view is not available");return be.executeJavaScript(ae,de)},capturePage:async()=>{const ae=c.current;if(!ae)return null;const de=ae.getWebContentsId();return Number.isFinite(de)?await kn("desktop_browser_capture_page",{webContentsId:de}):null}}),[]),Pe=l.useCallback(()=>{if(E){F(!1),Io(ve);return}if(!ee.url){Re.error(a("contextPanel.browser.annotate.noPage"));return}const ae=Vh(u.metadata.variant==="light"?"light":"dark");F(!0),Hh({host:ve,theme:ae,labels:Te}).then(async de=>{F(!1),de&&await Se(de)}).catch(()=>{F(!1),Re.error(a("contextPanel.browser.annotate.failed"))})},[ve,Se,u,E,ee.url,Te,a]);l.useEffect(()=>{if(!E)return;const ae=de=>{Ic(de)||de.key!=="Escape"||(de.preventDefault(),de.stopImmediatePropagation(),F(!1),Io(ve))};return window.addEventListener("keydown",ae,!0),()=>window.removeEventListener("keydown",ae,!0)},[ve,E]);const he=l.useRef(!1);l.useEffect(()=>{if(!d)return;const ae=()=>{he.current=!0};return d.addEventListener("dom-ready",ae),d.addEventListener("did-fail-load",ae),()=>{d.removeEventListener("dom-ready",ae),d.removeEventListener("did-fail-load",ae)}},[d]);const Fe=l.useCallback(async()=>{const ae=Date.now()+xS;for(;!(c.current&&he.current)&&Date.now()<ae;)await new Promise(de=>setTimeout(de,100));return c.current},[]),_e=l.useCallback(async(ae=8e3)=>{const de=Date.now();for(;;){const be=c.current;if(!be)return!1;let C=!1;try{C=be.isLoading()}catch{return!1}if(!C)return!0;if(Date.now()-de>ae)return!1;await new Promise(ce=>setTimeout(ce,120))}},[]),We=l.useCallback(async(ae,de)=>{const be=S0({quietMs:Sl,maxMs:de});let C;const ce=new Promise(L=>{C=setTimeout(()=>L(null),de+1e3)});try{const L=SS.safeParse(await Promise.race([ae.executeJavaScript(be,!1),ce]));return L.success&&L.data.quiet}catch{return!1}finally{clearTimeout(C)}},[]),Xe=l.useCallback(async(ae,de=wS)=>{const be=Date.now(),C=await _e(Math.min(25e3,Math.max(0,de-kl))),ce=de-(Date.now()-be),L=C&&ce>Sl&&await We(ae,Math.min(kl,ce));let ge="";try{ge=ae.getTitle()||""}catch{ge=""}return{title:ge,settled:L}},[_e,We]),Ve=l.useCallback(async(ae,de,be)=>{const C=await Fe();if(!C)throw new Error("The browser panel is not ready");const ce=()=>{bl(de.viewport)&&(W(mi(de.viewport)),v(!0))};if(ae==="browser.back"||ae==="browser.forward"){const je=ae==="browser.back";if(!(je?C.canGoBack():C.canGoForward()))throw new Error(je?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");je?C.goBack():C.goForward(),await new Promise(ot=>setTimeout(ot,150)),await _e();let ye="";try{ye=C.getTitle()||""}catch{ye=""}return{url:xn(C.getURL()),title:ye}}if(ae==="browser.capture"){const je=jS(H.current);try{if(!await kS())throw new Error("The OpenChamber window is not being drawn (minimized, on a workspace or tab that is not shown, or the screen is locked or off), so nothing can be captured. browser.snapshot still reads the page.");await _e()&&await We(C,yS);const st=await ve.capturePage();if(!st)throw new Error("The page could not be captured");let ye="";try{ye=C.getTitle()||""}catch{ye=""}return{...st,url:xn(C.getURL()),title:ye,viewport:yr(G.current)}}finally{je()}}if(ae==="browser.resize"){if(!bl(de.viewport))throw new Error("viewport is required");return ce(),await new Promise(je=>setTimeout(je,200)),await _e(),{viewport:yr(mi(de.viewport))}}if(ae==="browser.open"){const je=typeof de.url=="string"?de.url:"";if(!je)throw new Error("url is required");return ce(),we(je),await new Promise(st=>setTimeout(st,150)),{url:Cn(je),...await Xe(C),opened:!0,viewport:yr(G.current)}}if(ae==="browser.settle"){const je=mo().safeParse(de.budgetMs);return Xe(C,je.success?je.data:void 0)}await _e();const L=je=>typeof je=="string"&&je?je:void 0,Ce=(()=>{switch(ae){case"browser.snapshot":return b0({selector:L(de.selector)});case"browser.click":return x0({selector:L(de.selector),text:L(de.text)});case"browser.type":return w0({selector:String(de.selector??""),value:String(de.value??""),submit:de.submit===!0});case"browser.select":return y0({selector:String(de.selector??""),label:typeof de.label=="string"?de.label:void 0,value:typeof de.value=="string"?de.value:void 0});case"browser.inspect":return j0({selector:String(de.selector??"")});case"browser.scroll":return v0({selector:L(de.selector),direction:L(de.direction)});default:return null}})();if(!Ce)throw new Error(`Unsupported browser action: ${ae}`);let Je=()=>{};(ae==="browser.click"||ae==="browser.type")&&(await kn("desktop_browser_keep_page_focused",{webContentsId:C.getWebContentsId()}).then(st=>st.focused===!0).catch(()=>!1)||(Je=be(),C.focus({preventScroll:!0})));let Oe;try{Oe=await C.executeJavaScript(Ce,!0)}finally{Je()}if(!Oe||typeof Oe!="object")throw new Error("The page returned no result");const me=Oe;if(me.ok!==!0)throw new Error(typeof me.error=="string"&&me.error?me.error:"Browser action failed");if(ae==="browser.snapshot"){const je=O.current;return{...me,viewport:yr(G.current),...je.length>0?{consoleProblems:[...je]}:{}}}return(ae==="browser.click"||ae==="browser.select"||ae==="browser.type"&&de.submit===!0)&&(await new Promise(je=>setTimeout(je,150)),await _e()),Oe},[ve,we,Xe,_e,We,Fe]),S=lS(d,H),[ne,q]=l.useState(!1),ke=l.useCallback((ae,de)=>(q(!0),S(be=>Ve(ae,de,be))),[S,Ve]),Ee=l.useCallback(()=>{const ae=c.current;if(!ae)return{title:"",url:""};let de="",be="";try{de=ae.getTitle()||""}catch{de=""}try{be=xn(ae.getURL())}catch{be=""}return{title:de,url:be}},[]);l.useEffect(()=>Jv({tabId:r,directory:te,ownerSessionId:o,describe:Ee,run:ke}),[Ee,o,ke,te,r]),l.useEffect(()=>{const ae=ve;return()=>{Io(ae)}},[ve]),l.useEffect(()=>{if(!d)return;const ae=be=>{const C=be;if(typeof C.level!="number"||C.level<2)return;const ce=C.sourceId?`${C.sourceId}${C.line?`:${C.line}`:""}`:"";O.current.push({level:C.level>=3?"error":"warning",message:String(C.message??"").slice(0,400),source:ce}),O.current.length>vl&&O.current.splice(0,O.current.length-vl)},de=()=>{O.current=[]};return d.addEventListener("console-message",ae),d.addEventListener("did-start-loading",de),()=>{d.removeEventListener("console-message",ae),d.removeEventListener("did-start-loading",de)}},[d]);const Ie=l.useRef(new Set),Ne=l.useCallback(ae=>{Ie.current.clear(),we(ae)},[we]),ze=l.useRef(ee.status);ze.current=ee.status;const Ue=l.useRef(!1);ee.status.kind==="ready"&&ee.status.url&&(Ue.current=!0),l.useEffect(()=>Lu(te,r,ae=>{Bu(ze.current,Ue.current)&&Ne(ae)}),[Ne,te,r]),l.useEffect(()=>{if(!d)return;const ae=be=>{const C=jn(be),ce=typeof C.url=="string"?C.url:"";!ce||!ya(ce,n)||(be.preventDefault(),we(ce))},de=be=>{const C=jn(be);if(C.isMainFrame===!1||C.errorCode===-3)return;const ce=typeof C.validatedURL=="string"?C.validatedURL:"";!ce||!ya(ce,n)||Ie.current.has(ce)||(Ie.current.add(ce),we(ce))};return d.addEventListener("will-navigate",ae),d.addEventListener("did-fail-load",de),()=>{d.removeEventListener("will-navigate",ae),d.removeEventListener("did-fail-load",de)}},[n,we,d]),l.useEffect(()=>{if(!d)return;const ae=de=>{if(!(de instanceof CustomEvent))return;const be=hS.safeParse(de.detail);if(!be.success)return;let C=-1;try{C=d.getWebContentsId()}catch{return}be.data.webContentsId===C&&X.getState().openContextBrowser(te,be.data.url,{reveal:!be.data.background})};return window.addEventListener(yl,ae),()=>window.removeEventListener(yl,ae)},[te,d]);const Ge=l.useCallback(ae=>{const de=Math.min(pS,Math.max(fS,ae));N.current=de,y(de);try{c.current?.setZoomLevel(de)}catch{}},[]);l.useEffect(()=>{const ae=de=>{if(!(de instanceof CustomEvent))return;const be=de.detail,C=c.current;!C||document.activeElement!==C||(be==="zoom-in"?Ge(N.current+kr):be==="zoom-out"?Ge(N.current-kr):be==="zoom-reset"&&Ge(0))};return window.addEventListener("openchamber:zoom",ae),()=>window.removeEventListener("openchamber:zoom",ae)},[Ge]);const Qe=l.useCallback(ae=>{kn("desktop_browser_clear_data",{partition:wl(n),cookies:ae==="cookies",cache:ae==="cache"}).then(()=>{Re.success(a(ae==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{c.current?.reloadIgnoringCache()}catch{}}).catch(()=>Re.error(a("contextPanel.browser.clearFailed")))},[n,a]);l.useEffect(()=>{const ae=H.current;if(!ae||typeof ResizeObserver>"u")return;const de=new ResizeObserver(be=>{const C=be[0]?.contentRect;C&&oe({width:C.width,height:C.height})});return de.observe(ae),()=>de.disconnect()},[]);const He=l.useCallback(ae=>{Q(ae);const de=c.current;if(!de)return;let be=-1;try{be=de.getWebContentsId()}catch{return}kn("desktop_browser_set_color_scheme",{webContentsId:be,scheme:ae}).catch(C=>{Q("system"),Re.error(C instanceof Error?C.message:a("contextPanel.browser.device.schemeFailed"))})},[a]),Ke=l.useCallback(()=>{try{ue?c.current?.stop():c.current?.reload()}catch{}},[ue]),Ye=ee.status,it=l.useSyncExternalStore(cS,dS),bt=i&&it||o!==null||ne;l.useEffect(()=>{const ae=L=>{A(!0);const ge=setTimeout(()=>{try{c.current?.reload()}catch{}},L);return()=>clearTimeout(ge)};if(Ye.kind==="loading")return;const de=J.current||le.current===Ye;if(J.current&&(Ye.kind==="failed"||Ye.kind==="ready"&&Ye.url)&&(J.current=!1,le.current=Ye),Ye.kind==="failed"){const L=$u(Ye,{run:P.current,restored:de,watched:bt,now:Date.now()});if(P.current=L.run,L.next==="retry")return ae(L.delayMs);A(L.next==="pause");return}if(P.current=null,Ye.kind!=="ready"||!Ye.url||!Jl(Ye.url)){K.current=!0,A(!1);return}if(de||K.current||Date.now()-U.current>bS){K.current=!0,A(!1);return}let be=!1,C=null;return(ks(n)?Promise.resolve(null):Dv(xn(Ye.url))).then(L=>{if(!be){if(L===null||L<500){K.current=!0,A(!1);return}C=ae(gS)}}),()=>{be=!0,C?.()}},[n,Ye,bt]);const nt=ee.status.kind==="failed"&&!_?ee.status:null,ft=E0(M,B);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Hd,{address:T,onAddressChange:k,onSubmit:Ne,suggestions:Be,onForgetSuggestion:ae=>De(n,ae),onBack:()=>{try{c.current?.goBack()}catch{}},onForward:()=>{try{c.current?.goForward()}catch{}},onReload:Ke,onOpenExternal:()=>{On(ee.url||T)},addressMark:tu(n,T,w??a("contextPanel.browser.spaceAddress")),canOpenExternal:ks(n)===null,canGoBack:ee.canGoBack,canGoForward:ee.canGoForward,isLoading:ue,onAnnotate:Pe,isAnnotating:E,onOpenDevTools:()=>{try{c.current?.openDevTools()}catch{}},onHardReload:()=>{try{c.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>Ge(D+kr),onZoomOut:()=>Ge(D-kr),onZoomReset:()=>Ge(0),zoomPercent:Math.round(Math.pow(1.2,D)*100),onClearCookies:()=>Qe("cookies"),onClearCache:()=>Qe("cache"),onToggleDeviceBar:()=>v(ae=>!ae),isDeviceBarOpen:j}),j?s.jsx(R0,{viewport:M,onViewportChange:W,colorScheme:Z,onColorSchemeChange:He,scale:ft?.scale??1}):null,s.jsxs("div",{ref:H,className:Le("relative min-h-0 flex-1 bg-background",ft&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null&&V?s.jsx("webview",{ref:p,src:g,partition:wl(n),allowpopups:"true",webpreferences:o!==null?"backgroundThrottling=no":void 0,style:ft?{width:`${ft.width}px`,height:`${ft.height}px`,transform:`scale(${ft.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,g!==null&&!b&&!ee.url&&!ue?s.jsx(Qd,{onOpen:Ne,directory:n,visible:i}):null,_?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:a("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.waitingForServerHint")})]}):null,Y?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[ks(n)!==null?s.jsx(se,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,s.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:a(ks(n)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:Y})})]}):null,nt&&!Y?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:nt.crashed?a("contextPanel.browser.crashed"):a("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:nt.crashed?a("contextPanel.browser.crashedHint"):nt.description||a("contextPanel.browser.loadFailedUnknown")})]}):null,ue?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 bg-[var(--primary)]"})}):null]})]})},TS=t=>{const e=$e.c(75),{initialUrl:n,directory:r,siteDirectory:o,tabID:i,visible:a}=t,{t:u}=at(),c=X(ES);let d;e[0]!==n?(d=Cn(n),e[0]=n,e[1]=d):d=e[1];const f=d,p=f!==Gs?f:"",[m,h]=l.useState(p);let b;e[2]!==o||e[3]!==p?(b=To(p,o),e[2]=o,e[3]=p,e[4]=b):b=e[4];const[g,x]=l.useState(b);let w;e[5]!==o||e[6]!==p?(w=gc(p,o)?p:"",e[5]=o,e[6]=p,e[7]=w):w=e[7];const[T,k]=l.useState(w);let E;e[8]!==o?(E=ks(o),e[8]=o,e[9]=E):E=e[9];const F=E!==null,_=ea(o);let A;e[10]!==p?(A=p?[p]:[],e[10]=p,e[11]=A):A=e[11];const[D,y]=l.useState(A),[N,j]=l.useState(p?0:-1),[v,M]=l.useReducer(IS,0);let W,G;e[12]!==i||e[13]!==r?(W=()=>{Yl(cs(r),i)},G=[r,i],e[12]=i,e[13]=r,e[14]=W,e[15]=G):(W=e[14],G=e[15]),l.useEffect(W,G);let O;e[16]!==c||e[17]!==i||e[18]!==r?(O=Be=>{!Be||Be===Gs||!r||!i||c(r,i,Be)},e[16]=c,e[17]=i,e[18]=r,e[19]=O):O=e[19];const Z=O;let Q;e[20]!==o?(Q=Vd(o),e[20]=o,e[21]=Q):Q=e[21];const B=Nn(Q),oe=Nn(PS),H=Nn(RS);let P;e[22]!==m||e[23]!==B?(P=Ud(B,m),e[22]=m,e[23]=B,e[24]=P):P=e[24];const te=P;let J;e[25]!==o||e[26]!==N||e[27]!==Z||e[28]!==oe?(J=Be=>{const we=Cn(Be);if(we===Gs)return;h(we);const ve=To(we,o);x(ve),k(ve?"":we),Z(we),oe(o,{url:we}),y(Pe=>{const he=N>=0?Pe.slice(0,N+1):[];return he[he.length-1]===we?(j(he.length-1),he):(j(he.length),[...he,we])})},e[25]=o,e[26]=N,e[27]=Z,e[28]=oe,e[29]=J):J=e[29];const le=J;let K;e[30]!==o||e[31]!==D||e[32]!==Z?(K=Be=>{const we=D[Be];if(!we)return;j(Be),h(we);const ve=To(we,o);x(ve),k(ve?"":we),Z(we)},e[30]=o,e[31]=D,e[32]=Z,e[33]=K):K=e[33];const U=K;let $;e[34]!==o||e[35]!==H?($=Be=>H(o,Be),e[34]=o,e[35]=H,e[36]=$):$=e[36];let ee,Y;e[37]!==U||e[38]!==N?(ee=()=>U(N-1),Y=()=>U(N+1),e[37]=U,e[38]=N,e[39]=ee,e[40]=Y):(ee=e[39],Y=e[40]);let ie;e[41]!==m||e[42]!==g?(ie=()=>{On(g||m)},e[41]=m,e[42]=g,e[43]=ie):ie=e[43];let V;e[44]!==_||e[45]!==u?(V=_??u("contextPanel.browser.spaceAddress"),e[44]=_,e[45]=u,e[46]=V):V=e[46];let fe;e[47]!==m||e[48]!==o||e[49]!==V?(fe=tu(o,m,V),e[47]=m,e[48]=o,e[49]=V,e[50]=fe):fe=e[50];const Se=!T,Te=N>0,ue=N>=0&&N<D.length-1;let Me;e[51]!==m||e[52]!==le||e[53]!==te||e[54]!==$||e[55]!==ee||e[56]!==Y||e[57]!==ie||e[58]!==fe||e[59]!==Se||e[60]!==Te||e[61]!==ue?(Me=s.jsx(Hd,{address:m,onAddressChange:h,onSubmit:le,suggestions:te,onForgetSuggestion:$,onBack:ee,onForward:Y,onReload:M,onOpenExternal:ie,addressMark:fe,canOpenExternal:Se,canGoBack:Te,canGoForward:ue,isLoading:!1}),e[51]=m,e[52]=le,e[53]=te,e[54]=$,e[55]=ee,e[56]=Y,e[57]=ie,e[58]=fe,e[59]=Se,e[60]=Te,e[61]=ue,e[62]=Me):Me=e[62];let Ae;e[63]!==o||e[64]!==F||e[65]!==g||e[66]!==le||e[67]!==v||e[68]!==u||e[69]!==T||e[70]!==a?(Ae=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:T?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[F?s.jsx(se,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,s.jsx("span",{className:"typography-ui-header text-foreground",children:u(F?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:eo(T)})}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:u("contextPanel.browser.remoteLoopback.hint")})]}):g?s.jsx("iframe",{src:g,title:u("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(Qd,{onOpen:le,directory:o,visible:a})}),e[63]=o,e[64]=F,e[65]=g,e[66]=le,e[67]=v,e[68]=u,e[69]=T,e[70]=a,e[71]=Ae):Ae=e[71];let De;return e[72]!==Me||e[73]!==Ae?(De=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Me,Ae]}),e[72]=Me,e[73]=Ae,e[74]=De):De=e[74],De},NS=t=>{const e=$e.c(3),[n]=l.useState(uS);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(CS,{...t}):s.jsx(TS,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function ES(t){return t.setContextPanelTabTargetPath}function IS(t){return t+1}function PS(t){return t.recordVisit}function RS(t){return t.forget}const DS=t=>{const e=$e.c(13),{zone:n,children:r}=t,[o]=l.useState(AS);let i;e[0]!==n?(i=m=>m.body[n],e[0]=n,e[1]=i):i=e[1];const a=lr(i);let u,c;e[2]!==a||e[3]!==o||e[4]!==n?(u=()=>{const m=a??lr.getState().body[n];if(!m){o.remove();return}if(o.parentElement===m)return;const h=document.activeElement;m.moveBefore&&o.isConnected?m.moveBefore(o,null):m.append(o),h instanceof HTMLElement&&o.contains(h)&&document.activeElement!==h&&h.focus({preventScroll:!0})},c=[a,o,n],e[2]=a,e[3]=o,e[4]=n,e[5]=u,e[6]=c):(u=e[5],c=e[6]),l.useLayoutEffect(u,c);let d,f;e[7]!==o?(d=()=>()=>o.remove(),f=[o],e[7]=o,e[8]=d,e[9]=f):(d=e[8],f=e[9]),l.useLayoutEffect(d,f);let p;return e[10]!==r||e[11]!==o?(p=Hl.createPortal(r,o),e[10]=r,e[11]=o,e[12]=p):p=e[12],p};function AS(){const t=document.createElement("div");return t.style.display="contents",t}const _S=200,su=t=>`${t.path}:${t.line}:${t.column}`,Cl={status:"idle"},OS=t=>{const e=$e.c(9),{searchContents:n,directory:r,query:o,regex:i,includeHidden:a,respectGitignore:u,active:c}=t,[d,f]=l.useState(Cl);let p,m;return e[0]!==c||e[1]!==r||e[2]!==a||e[3]!==o||e[4]!==i||e[5]!==u||e[6]!==n?(p=()=>{if(!c||!n||!r||!o.trim()){f(Cl);return}const h=new AbortController;let b=!1;return f({status:"searching"}),n({directory:r,query:o,regex:i,limit:_S,includeHidden:a,respectGitignore:u,signal:h.signal}).then(g=>{b||f(g.status==="ok"?{status:"results",matches:g.matches,stopped:g.stopped}:g)}).catch(g=>{b||f({status:"failed",message:g instanceof Error?g.message:String(g)})}),()=>{b=!0,h.abort()}},m=[c,r,a,o,i,u,n],e[0]=c,e[1]=r,e[2]=a,e[3]=o,e[4]=i,e[5]=u,e[6]=n,e[7]=p,e[8]=m):(p=e[7],m=e[8]),l.useEffect(p,m),d},on=t=>{const e=$e.c(5),{className:n,children:r}=t;let o;e[0]!==n?(o=Le("px-2 py-1 typography-meta text-muted-foreground",n),e[0]=n,e[1]=o):o=e[1];let i;return e[2]!==r||e[3]!==o?(i=s.jsx("li",{className:o,children:r}),e[2]=r,e[3]=o,e[4]=i):i=e[4],i},MS=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},FS=t=>{const e=$e.c(44),{state:n,activeMatchKey:r,onOpen:o,onDragStart:i,onDragEnd:a}=t,{t:u}=at();switch(n.status){case"idle":return null;case"searching":{let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(se,{name:"loader-4",className:"h-4 w-4 animate-spin"}),e[0]=p):p=e[0];let m;e[1]!==u?(m=u("sidebarFilesTree.state.searching"),e[1]=u,e[2]=m):m=e[2];let h;return e[3]!==m?(h=s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[p,m]}),e[3]=m,e[4]=h):h=e[4],h}case"unavailable":{let p;e[5]!==u?(p=u("sidebarFilesTree.contentSearch.unavailable"),e[5]=u,e[6]=p):p=e[6];let m;return e[7]!==p?(m=s.jsx(on,{children:p}),e[7]=p,e[8]=m):m=e[8],m}case"invalid-pattern":{let p;e[9]!==u?(p=u("sidebarFilesTree.contentSearch.invalidPattern"),e[9]=u,e[10]=p):p=e[10];let m;e[11]!==p?(m=s.jsx("span",{className:"text-[var(--status-error)]",children:p}),e[11]=p,e[12]=m):m=e[12];let h;e[13]!==n.message?(h=s.jsx("span",{className:"font-mono typography-micro",dir:"ltr",children:n.message}),e[13]=n.message,e[14]=h):h=e[14];let b;return e[15]!==m||e[16]!==h?(b=s.jsxs(on,{className:"flex flex-col gap-0.5",children:[m,h]}),e[15]=m,e[16]=h,e[17]=b):b=e[17],b}case"failed":{let p;e[18]!==n.message||e[19]!==u?(p=u("sidebarFilesTree.contentSearch.failed",{message:n.message}),e[18]=n.message,e[19]=u,e[20]=p):p=e[20];let m;return e[21]!==p?(m=s.jsx(on,{className:"text-[var(--status-error)]",children:p}),e[21]=p,e[22]=m):m=e[22],m}}if(n.matches.length===0){let p;return e[23]!==n.stopped||e[24]!==u?(p=n.stopped==="deadline"?s.jsx(on,{children:u("sidebarFilesTree.contentSearch.deadline")}):s.jsx(on,{children:u("sidebarFilesTree.contentSearch.empty")}),e[23]=n.stopped,e[24]=u,e[25]=p):p=e[25],p}let c;if(e[26]!==r||e[27]!==a||e[28]!==i||e[29]!==o||e[30]!==n.matches){let p;e[32]!==r||e[33]!==a||e[34]!==i||e[35]!==o?(p=m=>{const{name:h,directory:b}=MS(m.relativePath),g=su(m),x=r===g;return s.jsx("li",{"data-file-tree-path":m.path,children:s.jsxs("button",{type:"button",onClick:()=>o(m),onDoubleClick:()=>o(m,{pin:!0}),draggable:!!i,onDragStart:i?w=>i(w,m):void 0,onDragEnd:a?w=>a(w,m):void 0,className:Le("flex w-full flex-col gap-0.5 rounded-md px-2 py-1 text-start transition-colors",Vi(x)),title:`${m.relativePath}:${m.line}`,children:[s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsx(uo,{filePath:m.path,className:"size-3.5 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 flex-shrink truncate typography-meta",dir:"auto",children:h}),b?s.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-micro text-muted-foreground",style:{direction:"rtl"},children:`‎${b}‎`}):s.jsx("span",{className:"flex-1"}),s.jsx("span",{className:"flex-shrink-0 typography-micro tabular-nums text-muted-foreground",children:m.line})]}),s.jsxs("span",{className:"block w-full min-w-0 truncate font-mono typography-micro text-muted-foreground",dir:"ltr",children:[m.cutStart?"…":null,s.jsx(qh,{segments:Kh(m.text,m.ranges)})]})]})},g)},e[32]=r,e[33]=a,e[34]=i,e[35]=o,e[36]=p):p=e[36],c=n.matches.map(p),e[26]=r,e[27]=a,e[28]=i,e[29]=o,e[30]=n.matches,e[31]=c}else c=e[31];let d;e[37]!==n.matches.length||e[38]!==n.stopped||e[39]!==u?(d=n.stopped==="limit"?s.jsx(on,{children:u("sidebarFilesTree.contentSearch.limit",{count:n.matches.length})}):n.stopped==="deadline"?s.jsx(on,{children:u("sidebarFilesTree.contentSearch.deadline")}):null,e[37]=n.matches.length,e[38]=n.stopped,e[39]=u,e[40]=d):d=e[40];let f;return e[41]!==c||e[42]!==d?(f=s.jsxs(s.Fragment,{children:[c,d]}),e[41]=c,e[42]=d,e[43]=f):f=e[43],f},Tl=8;let dr=null;const nu=(t,e)=>Math.abs(e.clientX-t.x)<=Tl&&Math.abs(e.clientY-t.y)<=Tl,bi=t=>{dr={x:t.clientX,y:t.clientY}},xi=t=>{const e=dr;return dr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:nu(e,t)},ru=t=>dr!==null&&nu(dr,t);let ou=null;const Uo=t=>{ou=t},iu=()=>ou,Nl=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},au=(t,e,n)=>{const r=e===null?n:e.type==="directory"?e.path:Nl(e.path);return!r||Nl(t.path)===r||t.type==="directory"&&zu(r,t.path,t.path)!==null?null:r},LS=(t,e)=>{const n=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${n}`:`${e}/${n}`},$S=({root:t,childrenByDir:e,expandedPaths:n,loadErrorsByDir:r})=>{const o=[],i=(a,u)=>{for(const c of e[a]??[]){const d=c.type==="directory"&&n.has(c.path);if(o.push({kind:"node",key:c.path,node:c,depth:u,isExpanded:d}),!d)continue;const f=r[c.path];f&&o.push({kind:"error",key:`error:${c.path}`,directory:c.path,depth:u+1,message:f}),i(c.path,u+1)}};return i(t,0),o},BS=(t,e,n)=>{const r=e.filter(o=>o>=0&&o<n&&!t.includes(o));return r.length===0?[...t]:[...t,...r].sort((o,i)=>o-i)},zS=28,En=t=>Array.from(t.types).includes("Files"),Qn=t=>Array.from(t.types).includes(ir)?iu():null,lu=(t,e,n)=>t.getData(ir)===wo(e,n.path),WS=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]:[]})},US=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),Bt=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},wo=(t,e)=>{const n=Bt(e),r=Bt(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},Wn=(t,e)=>{const n=wo(t,e);if(n!==".")return n;const r=Bt(t);return r.split("/").filter(Boolean).pop()??r},Or=t=>{const e=Bt(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},VS=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),HS=new Set(["node_modules"]),qS=t=>HS.has(t),KS=t=>{const e=Bt(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},GS=8,Ps=new Map,sa=t=>JSON.stringify([ns(),t]),ZS=t=>{const e=sa(t),n=Ps.get(e);return n?(n.touchedAt=Date.now(),Ps.delete(e),Ps.set(e,n),n):null},Vo=t=>{const e=sa(t),n=Ps.get(e);if(n)return n.touchedAt=Date.now(),n;if(Ps.size>=GS){const o=Ps.keys().next().value;o!==void 0&&Ps.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Ps.set(e,r),r},XS=t=>{const e=$e.c(131),{node:n,root:r,isExpanded:o,isActive:i,isBrowserClient:a,depth:u,isOpen:c,status:d,badge:f,isDropTarget:p,isDragSource:m,canUpload:h,canMove:b,permissions:g,downloadFile:x,onSelect:w,onToggle:T,onRevealPath:k,onOpenDialog:E,onSetDropTarget:F,onDropFiles:_,onPickFiles:A,onMoveDragChange:D,onSetMoveDropTarget:y,onMoveDrop:N}=t,{t:j}=at(),v=n.type==="directory";let M;e[0]!==v||e[1]!==n.path?(M=v?n.path:Or(n.path),e[0]=v,e[1]=n.path,e[2]=M):M=e[2];const W=M,{canRename:G,canCreateFile:O,canCreateFolder:Z,canDelete:Q,canReveal:B}=g,oe=!v&&!!x,H=B&&!a,P=v&&h,te=G||O||Z||P||Q||oe||H,[J,le]=l.useState(!1),[K,U]=l.useState(!1);let $;e[3]!==te?($=be=>{te&&(be?.preventDefault(),U(!0))},e[3]=te,e[4]=$):$=e[4];const ee=$;let Y;e[5]!==v||e[6]!==n||e[7]!==w||e[8]!==T?(Y=()=>{v?T(n.path):w(n)},e[5]=v,e[6]=n,e[7]=w,e[8]=T,e[9]=Y):Y=e[9];const ie=Y;let V;e[10]!==v||e[11]!==n||e[12]!==w?(V=()=>{v||w(n,{pin:!0})},e[10]=v,e[11]=n,e[12]=w,e[13]=V):V=e[13];const fe=V;let Se;e[14]===Symbol.for("react.memo_cache_sentinel")?(Se=be=>{be.stopPropagation(),U(!1),le(!0)},e[14]=Se):Se=e[14];const Te=Se;let ue;e[15]!==O||e[16]!==Z||e[17]!==Q||e[18]!==G||e[19]!==H||e[20]!==P||e[21]!==x||e[22]!==a||e[23]!==v||e[24]!==n||e[25]!==E||e[26]!==A||e[27]!==k||e[28]!==j?(ue=be=>{const{Item:C,Separator:ce}=be;return s.jsxs(s.Fragment,{children:[G&&s.jsxs(C,{onClick:L=>{L.stopPropagation(),E("rename",n)},children:[s.jsx(se,{name:"edit",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.rename")]}),s.jsxs(C,{onClick:L=>{L.stopPropagation(),no(n.path).then(ge=>{if(ge.ok){Re.success(j("sidebarFilesTree.toast.pathCopied"));return}Re.error(j("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(se,{name:"link",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.copyPath")]}),!v&&x&&s.jsxs(C,{onClick:L=>{L.stopPropagation(),x(n.path).catch(ge=>{console.error("Download failed:",ge),Re.error(j("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(se,{name:"download",className:"me-2 h-4 w-4"})," ",j(a?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),H&&s.jsxs(C,{onClick:L=>{L.stopPropagation(),k(n.path)},children:[s.jsx(se,{name:"folder-received",className:"me-2 h-4 w-4"})," ",j(Xh())]}),!v&&H&&Qr()&&s.jsxs(C,{onClick:L=>{L.stopPropagation(),Kl(n.path).then(ge=>{ge||Re.error(j("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(se,{name:"external-link",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.openInDefaultApp")]}),v&&(O||Z||P)&&s.jsxs(s.Fragment,{children:[s.jsx(ce,{}),O&&s.jsxs(C,{onClick:L=>{L.stopPropagation(),E("createFile",n)},children:[s.jsx(se,{name:"file-add",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.newFile")]}),Z&&s.jsxs(C,{onClick:L=>{L.stopPropagation(),E("createFolder",n)},children:[s.jsx(se,{name:"folder-add",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.newFolder")]}),P&&s.jsxs(C,{onClick:L=>{L.stopPropagation(),A(n.path)},children:[s.jsx(se,{name:"upload-2",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.uploadFiles")]})]}),Q&&s.jsxs(s.Fragment,{children:[s.jsx(ce,{}),s.jsxs(C,{onClick:L=>{L.stopPropagation(),E("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(se,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.delete")]})]})]})},e[15]=O,e[16]=Z,e[17]=Q,e[18]=G,e[19]=H,e[20]=P,e[21]=x,e[22]=a,e[23]=v,e[24]=n,e[25]=E,e[26]=A,e[27]=k,e[28]=j,e[29]=ue):ue=e[29];const Me=ue;let Ae;e[30]!==b||e[31]!==n.path||e[32]!==n.type||e[33]!==D||e[34]!==r?(Ae=be=>{bi(be);const C=wo(r,n.path);!C||C==="."||(be.dataTransfer.setData(ir,C),be.dataTransfer.effectAllowed=b?"copyMove":"copy",b&&D({path:n.path,type:n.type}))},e[30]=b,e[31]=n.path,e[32]=n.type,e[33]=D,e[34]=r,e[35]=Ae):Ae=e[35];const De=Ae;let Be;e[36]!==b||e[37]!==ie||e[38]!==D?(Be=be=>{b&&D(null),xi(be)&&ie()},e[36]=b,e[37]=ie,e[38]=D,e[39]=Be):Be=e[39];const we=Be;let ve;e[40]!==h||e[41]!==F||e[42]!==W?(ve=be=>{!h||!W||!En(be.dataTransfer)||(be.preventDefault(),be.stopPropagation(),be.dataTransfer.dropEffect="copy",F(W))},e[40]=h,e[41]=F,e[42]=W,e[43]=ve):ve=e[43];const Pe=ve;let he;e[44]!==h||e[45]!==F||e[46]!==W?(he=be=>{!h||!W||!En(be.dataTransfer)||be.relatedTarget instanceof Node&&be.currentTarget.contains(be.relatedTarget)||(be.stopPropagation(),F(null))},e[44]=h,e[45]=F,e[46]=W,e[47]=he):he=e[47];const Fe=he;let _e;e[48]!==h||e[49]!==_||e[50]!==W?(_e=be=>{!h||!W||!En(be.dataTransfer)||(be.preventDefault(),be.stopPropagation(),_(W,be.dataTransfer))},e[48]=h,e[49]=_,e[50]=W,e[51]=_e):_e=e[51];const We=_e;let Xe;e[52]!==n.path||e[53]!==n.type||e[54]!==r?(Xe=(be,C)=>ru(be)?null:au(C,{path:n.path,type:n.type},r),e[52]=n.path,e[53]=n.type,e[54]=r,e[55]=Xe):Xe=e[55];const Ve=Xe;let S;e[56]!==b||e[57]!==Ve||e[58]!==Pe||e[59]!==y?(S=be=>{const C=b?Qn(be.dataTransfer):null;if(!C){Pe(be);return}be.stopPropagation();const ce=Ve(be,C);y(ce),ce&&(be.preventDefault(),be.dataTransfer.dropEffect="move")},e[56]=b,e[57]=Ve,e[58]=Pe,e[59]=y,e[60]=S):S=e[60];const ne=S;let q;e[61]!==b||e[62]!==Ve||e[63]!==We||e[64]!==N||e[65]!==y||e[66]!==r?(q=be=>{const C=b?Qn(be.dataTransfer):null;if(!C){We(be);return}be.stopPropagation(),be.preventDefault(),y(null);const ce=Ve(be,C);ce&&lu(be.dataTransfer,r,C)&&N(C,ce)},e[61]=b,e[62]=Ve,e[63]=We,e[64]=N,e[65]=y,e[66]=r,e[67]=q):q=e[67];const ke=q;let Ee;e[68]===Symbol.for("react.memo_cache_sentinel")?(Ee={blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[68]=Ee):Ee=e[68];let Ie;e[69]!==ee||e[70]!==Fe||e[71]!==ne||e[72]!==ke?(Ie=s.jsx("div",{className:"group relative flex items-center typography-meta",style:Ee,onContextMenu:ee,onDragEnter:ne,onDragOver:ne,onDragLeave:Fe,onDrop:ke}),e[69]=ee,e[70]=Fe,e[71]=ne,e[72]=ke,e[73]=Ie):Ie=e[73];let Ne;e[74]!==u?(Ne=s.jsx(Hc,{depth:u}),e[74]=u,e[75]=Ne):Ne=e[75];let ze;e[76]!==i||e[77]!==m||e[78]!==p?(ze=Le("oc-file-tree-row flex w-full items-center gap-1.5 rounded-md py-1 text-start select-none",p?"bg-interactive-selection text-interactive-selection-foreground ring-2 ring-inset ring-primary [--oc-file-tree-row-fill:var(--interactive-selection)] [--oc-file-tree-row-ring:var(--primary)]":Vi(i),m&&"opacity-50"),e[76]=i,e[77]=m,e[78]=p,e[79]=ze):ze=e[79];let Ue;e[80]!==u?(Ue=qc(u),e[80]=u,e[81]=Ue):Ue=e[81];let Ge;e[82]!==Ue?(Ge={paddingInlineStart:Ue},e[82]=Ue,e[83]=Ge):Ge=e[83];let Qe;e[84]!==v||e[85]!==o||e[86]!==n.extension||e[87]!==n.path?(Qe=v?s.jsx(Gh,{expanded:o}):s.jsx(uo,{filePath:n.path,extension:n.extension,className:"ms-0.5 size-3.5"}),e[84]=v,e[85]=o,e[86]=n.extension,e[87]=n.path,e[88]=Qe):Qe=e[88];let He;e[89]!==n.name||e[90]!==n.path?(He=s.jsx("span",{className:"oc-file-tree-row-name typography-meta",title:n.path,children:n.name}),e[89]=n.name,e[90]=n.path,e[91]=He):He=e[91];let Ke;e[92]!==v||e[93]!==c||e[94]!==d?(Ke=!v&&s.jsx(Yh,{isOpen:c,status:d}),e[92]=v,e[93]=c,e[94]=d,e[95]=Ke):Ke=e[95];let Ye;e[96]!==f||e[97]!==v?(Ye=v&&f&&s.jsx(Jh,{badge:f}),e[96]=f,e[97]=v,e[98]=Ye):Ye=e[98];let it;e[99]!==Ke||e[100]!==Ye?(it=s.jsxs(Qh,{className:"pe-2",children:[Ke,Ye]}),e[99]=Ke,e[100]=Ye,e[101]=it):it=e[101];let bt;e[102]!==ee||e[103]!==fe||e[104]!==we||e[105]!==De||e[106]!==ie||e[107]!==ze||e[108]!==Ge||e[109]!==Qe||e[110]!==He||e[111]!==it?(bt=s.jsxs("button",{type:"button",onClick:ie,onDoubleClick:fe,onContextMenu:ee,draggable:!0,onDragStart:De,onDragEnd:we,className:ze,style:Ge,children:[Qe,He,it]}),e[102]=ee,e[103]=fe,e[104]=we,e[105]=De,e[106]=ie,e[107]=ze,e[108]=Ge,e[109]=Qe,e[110]=He,e[111]=it,e[112]=bt):bt=e[112];let nt;e[113]!==J||e[114]!==te||e[115]!==i||e[116]!==p||e[117]!==Me||e[118]!==j?(nt=te&&s.jsx("div",{className:Le("oc-file-tree-row-end -ms-7 w-7 pe-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100",Zh(i||p)),children:s.jsxs(pn,{open:J,onOpenChange:le,children:[s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(mn,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:Te,title:j("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":j("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(se,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx($t,{side:"bottom",sideOffset:6,children:j("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(hn,{align:"end",side:"bottom",onCloseAutoFocus:()=>le(!1),children:Me({Item:Gt,Separator:un})})]})}),e[113]=J,e[114]=te,e[115]=i,e[116]=p,e[117]=Me,e[118]=j,e[119]=nt):nt=e[119];let ft;e[120]!==Ie||e[121]!==Ne||e[122]!==bt||e[123]!==nt?(ft=s.jsxs(ro,{render:Ie,children:[Ne,bt,nt]}),e[120]=Ie,e[121]=Ne,e[122]=bt,e[123]=nt,e[124]=ft):ft=e[124];let ae;e[125]!==Me?(ae=s.jsx(oo,{className:"min-w-[180px]",children:Me({Item:Cs,Separator:Tn})}),e[125]=Me,e[126]=ae):ae=e[126];let de;return e[127]!==K||e[128]!==ft||e[129]!==ae?(de=s.jsxs(pr,{open:K,onOpenChange:U,children:[ft,ae]}),e[127]=K,e[128]=ft,e[129]=ae,e[130]=de):de=e[130],de},YS=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.depth===e.depth&&t.isOpen===e.isOpen&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.isDragSource===e.isDragSource&&t.canUpload===e.canUpload&&t.canMove===e.canMove&&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&&t.onPickFiles===e.onPickFiles&&t.onMoveDragChange===e.onMoveDragChange&&t.onSetMoveDropTarget===e.onSetMoveDropTarget&&t.onMoveDrop===e.onMoveDrop,JS=l.memo(XS,YS),QS=t=>{const e=$e.c(14),{visible:n}=t,r=n===void 0?!0:n,o=An(t2),i=Vs()??"",a=mr();let u,c,d,f;if(e[0]!==a||e[1]!==i||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{if(c=ao(a,i)??"",a?.kind==="preparing"){let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Nr,{}),e[7]=m):m=e[7],f=m;break e}u=e2,d=JSON.stringify([o,c])}e[0]=a,e[1]=i,e[2]=o,e[3]=u,e[4]=c,e[5]=d,e[6]=f}else u=e[3],c=e[4],d=e[5],f=e[6];if(f!==Symbol.for("react.early_return_sentinel"))return f;let p;return e[8]!==u||e[9]!==c||e[10]!==i||e[11]!==d||e[12]!==r?(p=s.jsx(u,{visible:r,currentDirectory:c,panelDirectory:i},d),e[8]=u,e[9]=c,e[10]=i,e[11]=d,e[12]=r,e[13]=p):p=e[13],p},e2=({visible:t,currentDirectory:e,panelDirectory:n})=>{const r=l.useRef(t);r.current=t;const{t:o}=at(),{files:i,runtime:a}=Es(),u=Wu(a.platform),c=Bt(e.trim()),d=Bt(n.trim()),f=sa(c),p=Uu(),m=Vu(),h=Hu(R=>R.searchFiles),b=X(R=>R.openContextFile),g=lo(t?e:null),[x,w]=l.useState(""),T=eg(x,200),k=l.useRef(null),[E,F]=l.useState([]),[_,A]=l.useState(!1),D=!!i.searchContents,[y,N]=l.useState("names"),[j,v]=l.useState(!1),M=D&&y==="contents",W=OS({searchContents:i.searchContents,directory:e,query:T,regex:j,includeHidden:p,respectGitignore:!m,active:t&&M}),G=X(R=>R.openContextFileAtLine),[O,Z]=l.useState(null),[Q,B]=l.useState(null),[oe,H]=l.useState(null),[P,te]=l.useState(null),[J,le]=l.useState(null),{hasTouchOnlyPointer:K}=gn(),U=!!(i.rename&&c)&&!K,$=X(R=>R.confirmFileTreeMove),ee=X(R=>R.setConfirmFileTreeMove),[Y,ie]=l.useState({}),[V,fe]=l.useState({}),Se=l.useRef(new Set),Te=l.useRef(new Map),ue=l.useMemo(()=>new zb,[]);l.useEffect(()=>()=>ue.clear(),[ue]);const Me=l.useRef(null);l.useEffect(()=>{if(B(null),te(null),le(null),!c){ie({}),fe({}),Se.current=new Set;return}const R=ZS(c);R?(ie({...R.childrenByDir}),fe({...R.loadErrorsByDir}),Se.current=new Set(R.loadedDirs)):(ie({}),fe({}),Se.current=new Set)},[c]),l.useEffect(()=>{if(!c)return;const R=Vo(c);R.childrenByDir=Y},[c,Y]),l.useEffect(()=>{if(!c)return;const R=Vo(c);R.loadErrorsByDir=V},[c,V]),l.useEffect(()=>{if(!c)return;const R=Vo(c);R.loadedDirs=new Set(Se.current)},[c,Y,V]),l.useEffect(()=>()=>{if(!c)return;const R=Ps.get(f);R&&R.loadedDirs.size===0&&Object.keys(R.childrenByDir).length===0&&Ps.delete(f)},[f,c]);const Ae=l.useMemo(()=>[],[]),De=l.useMemo(()=>[],[]),Be=gs(R=>c?R.byRoot[c]?.expandedPaths??Ae:Ae),we=l.useMemo(()=>new Set(Be),[Be]),ve=gs(R=>c?R.byRoot[c]?.selectedPath??null:null),Pe=gs(R=>R.setSelectedPath),he=l.useRef(null);l.useEffect(()=>{he.current=ve},[ve]);const Fe=gs(R=>R.addOpenPath),_e=gs(R=>R.removeOpenPathsByPrefix),We=gs(R=>R.toggleExpandedPath),Xe=gs(R=>R.expandPath),Ve=gs(R=>R.collapseAllExpandedPaths),S=X(R=>d?R.contextPanelByDirectory[d]?.tabs??De:De),ne=l.useMemo(()=>new Set(S.map(R=>R.mode==="file"?R.targetPath:null).filter(R=>typeof R=="string"&&R.length>0).map(R=>Bt(R))),[S]),[q,ke]=l.useState(null),[Ee,Ie]=l.useState(null),[Ne,ze]=l.useState(""),[Ue,Ge]=l.useState(!1),Qe=!!i.writeFile,He=!!i.createDirectory,Ke=!!i.rename,Ye=!!i.delete,it=!!i.revealPath,bt=l.useMemo(()=>({canRename:Ke,canCreateFile:Qe,canCreateFolder:He,canDelete:Ye,canReveal:it}),[Ke,Qe,He,Ye,it]),nt=l.useCallback(R=>{i.revealPath&&i.revealPath(R).catch(()=>{Re.error(o("sidebarFilesTree.toast.revealFailed"))})},[i,o]),ft=l.useCallback((R,I)=>{ke(R),Ie(I),ze(R==="rename"&&I.name||""),Ge(!1)},[]),ae=l.useCallback((R,I)=>{const xe=I.filter(pe=>pe&&typeof pe.name=="string"&&pe.name.length>0).filter(pe=>p||!pe.name.startsWith(".")).filter(pe=>m||!qS(pe.name)).map(pe=>{const rt=pe.name,tt=Bt(pe.path||""),Et=tt?VS(tt)?tt:Bt(`${R}/${tt}`):Bt(`${R}/${rt}`),Rt=pe.isDirectory?"directory":"file",It=Rt==="file"&&rt.includes(".")?rt.split(".").pop()?.toLowerCase():void 0;return{name:rt,path:Et,type:Rt,extension:It}});return US(xe)},[m,p]),de=l.useCallback(async(R,I,xe=!1)=>{if(!r.current||I?.())return;const pe=Bt(R.trim());if(!pe||!xe&&Se.current.has(pe))return;const rt=ns();return ue.run(pe,async tt=>{const Et=()=>!tt()||ns()!==rt;try{const Rt=!m,It=i.listDirectory?(await i.listDirectory(pe,{respectGitignore:Rt})).entries:await Go.listLocalDirectory(pe,{respectGitignore:Rt});if(Et())return;Te.current.set(pe,It.length);const At=ae(pe,It);Se.current=new Set(Se.current),Se.current.add(pe),fe(ws=>{if(!ws[pe])return ws;const en={...ws};return delete en[pe],en}),ie(ws=>ws[pe]&&Wb(ws[pe],At)?ws:{...ws,[pe]:At})}catch(Rt){if(Et())return;const It=Rt instanceof Error?Rt.message:String(Rt??"");console.error("Failed to load sidebar directory:",Rt),fe(At=>({...At,[pe]:It}))}},xe)},[ue,i,ae,m]),be=l.useCallback(async()=>{if(!c)return;Me.current?.abort();const R=new AbortController;Me.current=R,ue.clear();try{const xe=(gs.getState().byRoot[c]?.expandedPaths??[]).map(tt=>Bt(tt)).filter(tt=>!!tt&&tt!==c&&tt.startsWith(`${c}/`)),pe=[c,...xe];Se.current=new Set(Se.current);for(const tt of pe)Se.current.delete(tt);fe(tt=>{if(Object.keys(tt).length===0)return tt;const Et={...tt};let Rt=!1;for(const It of pe)It in Et&&(delete Et[It],Rt=!0);return Rt?Et:tt});const rt=()=>R.signal.aborted;await de(c,rt);for(let tt=0;tt<xe.length&&!R.signal.aborted;tt+=3){const Et=xe.slice(tt,tt+3);await Promise.all(Et.map(Rt=>de(Rt,rt)))}}catch(I){if(R.signal.aborted)return;console.error("Failed to refresh sidebar tree:",I)}finally{Me.current===R&&(Me.current=null)}},[ue,de,c]),C=l.useCallback(async R=>{if(!R){await be();return}const I=Bt(R);Se.current=new Set(Se.current),Se.current.delete(I),await de(I,void 0,!0)},[de,be]);l.useEffect(()=>{c&&(Me.current?.abort(),Se.current=new Set,ue.clear(),fe({}),ie(R=>Object.keys(R).length===0?R:{}),de(c))},[ue,de,c,p,m]),l.useEffect(()=>{if(!t||!c||Be.length===0)return;const R=Be.map(pe=>Bt(pe)).filter(pe=>!!pe&&pe!==c&&pe.startsWith(`${c}/`)&&!Se.current.has(pe)&&!ue.has(pe)).sort((pe,rt)=>pe.split("/").length-rt.split("/").length);if(R.length===0)return;let I=!1;const xe=()=>I;return(async()=>{for(let pe=0;pe<R.length&&!I;pe+=3){const rt=R.slice(pe,pe+3);await Promise.all(rt.map(tt=>de(tt,xe)))}})(),()=>{I=!0}},[ue,Be,de,c,t]);const ce=l.useRef(t);l.useEffect(()=>{const R=t&&!ce.current;ce.current=t,R&&be()},[be,t]);const L=l.useCallback(({directories:R})=>{if(!c)return;const I=new Set((gs.getState().byRoot[c]?.expandedPaths??[]).map(It=>Bt(It))),xe=c==="/"?"/":`${c}/`,pe=It=>{for(let At=It;At!==c;At=Or(At))if(!At.startsWith(xe)||!I.has(At))return!1;return!0},rt=It=>{for(let At=It;At===c||At.startsWith(xe);At=Or(At)){if(Se.current.has(At))return At;if(At===c)break}return null},tt=new Set,Et=new Set;for(const It of R??Se.current){const At=rt(Bt(It));At&&(pe(At)?tt:Et).add(At)}Et.size>0&&(Se.current=new Set([...Se.current].filter(It=>!Et.has(It))));const Rt=[...tt].filter(It=>(Te.current.get(It)??0)<=$f);(async()=>{for(let It=0;It<Rt.length;It+=3)await Promise.all(Rt.slice(It,It+3).map(At=>de(At,void 0,!0)))})()},[de,c]);Bf({root:c,active:t,whileInactive:"drop",onChanges:L}),l.useEffect(()=>{if(!t)return;if(!e||M){F([]),A(!1);return}const R=T.trim();if(!R){F([]),A(!1);return}let I=!1;return A(!0),h(e,R,150,{includeHidden:p,respectGitignore:!m,type:"file"}).then(xe=>{if(I)return;const rt=xe.filter(tt=>m||!KS(tt.path)).map(tt=>({name:tt.name,path:Bt(tt.path),type:"file",extension:tt.extension,relativePath:tt.relativePath}));F(rt)}).catch(()=>{I||F([])}).finally(()=>{I||A(!1)}),()=>{I=!0}},[M,e,T,h,p,m,t]);const ge=l.useMemo(()=>{const R=new Map;if(!g?.files)return R;for(const I of g.files)I.index==="A"||I.working_dir==="?"?R.set(I.path,"git-added"):I.index==="D"?R.set(I.path,"git-deleted"):(I.index==="M"||I.working_dir==="M")&&R.set(I.path,"git-modified");return R},[g]),Ce=l.useMemo(()=>{const R=new Map;if(!g?.files||!c)return R;for(const I of g.files){const xe=I.index==="M"||I.working_dir==="M",pe=I.index==="A"||I.working_dir==="?";if(!xe&&!pe)continue;const rt=I.path.split("/");if(rt.length<=1)continue;let tt=c;for(let Et=0;Et<rt.length-1;Et++){tt=`${tt}/${rt[Et]}`;let Rt=R.get(tt);Rt||(Rt={modified:0,added:0},R.set(tt,Rt)),xe&&Rt.modified++,pe&&Rt.added++}}return R},[g,c]),Je=l.useCallback(R=>{if(ge.size===0)return null;const I=R.startsWith(c+"/")?R.slice(c.length+1):R;return ge.get(I)??null},[ge,c]),Oe=l.useCallback(R=>{if(Ce.size===0)return null;const I=Ce.get(R);return I&&I.modified+I.added>0?I:null},[Ce]),me=l.useCallback(async(R,I)=>{if(!c)return;const xe=await $a(i,R.path,{directory:c});if(!xe.ok){Ba(R.path,xe);return}Pe(c,R.path),Fe(c,R.path),b(d,R.path,{preview:!I?.pin&&!X.getState().isMobile})},[Fe,i,b,d,c,Pe]),je=l.useCallback(async(R,I)=>{if(!c)return;const xe=await $a(i,R.path,{directory:c});if(!xe.ok){Ba(R.path,xe);return}Pe(c,R.path),Fe(c,R.path),Z({path:R.path,key:su(R)}),G(d,R.path,R.line,R.column,{preview:!I?.pin&&!X.getState().isMobile})},[Fe,i,G,d,c,Pe]),st=l.useCallback((R,I)=>{bi(R),Uo(null),R.dataTransfer.setData(ir,I.relativePath),R.dataTransfer.effectAllowed="copy"},[]),ye=l.useCallback((R,I)=>{xi(R)&&je(I)},[je]),[ot,Ct]=l.useState(null),xt=l.useCallback(()=>Ct(null),[]),jt=l.useRef(null),ct=Ub(jt,{onSettled:xt}),vt=l.useCallback(async R=>{const I=Bt(R);if(!c)return;const xe=gs.getState().byRoot[c]?.expandedPaths.includes(I)??!1;ct(R,xe,()=>{const pe=Array.from(jt.current?.querySelectorAll("[data-tree-disclosure-path]")??[],rt=>rt.dataset.treeDisclosurePath??"");Ct(xe?null:pe.slice(pe.indexOf(R)+1)),We(c,I)}),Se.current.has(I)||await de(I)},[de,c,We,ct]),{canUpload:St,uploadingDirectory:mt,uploadFiles:yt,pickFiles:lt,uploadElements:Nt}=zf({root:c,refreshDirectory:C}),_t=mt!==null,ht=mt??Q,gt=l.useCallback((R,I)=>{const xe=WS(I);xe.length!==0&&(B(null),yt(R,xe))},[yt]),Dt=l.useCallback(R=>{if(Uo(R),!R){H(null),te(null);return}requestAnimationFrame(()=>{iu()?.path===R.path&&H(R.path)})},[]),Kt=l.useCallback(async(R,I)=>{const xe=LS(R,I),pe=await za(i,{tabs:d,files:c},R.path,xe);if(pe==="conflict"){Re.error(o("sidebarFilesTree.toast.nameTaken",{name:xe.slice(xe.lastIndexOf("/")+1),folder:Wn(c,I)}));return}if(pe==="failed"){Re.error(o("sidebarFilesTree.toast.operationFailed"));return}I!==c&&Xe(c,I),await Promise.all([C(Or(R.path)),C(I)]).catch(()=>{})},[Xe,i,d,C,c,o]),Yt=l.useCallback((R,I)=>{if(X.getState().confirmFileTreeMove){le({source:R,targetDirectory:I});return}Kt(R,I)},[Kt]),js=l.useCallback(()=>{J&&(le(null),Kt(J.source,J.targetDirectory))},[Kt,J]),Wt=l.useCallback((R,I)=>!U||ru(R)?null:au(I,null,c),[U,c]),ds=l.useCallback(R=>{const I=Qn(R.dataTransfer);if(I){const xe=Wt(R,I);if(te(xe),!xe)return;R.preventDefault(),R.dataTransfer.dropEffect="move";return}!St||_t||!c||!En(R.dataTransfer)||(R.preventDefault(),R.dataTransfer.dropEffect="copy",B(c))},[St,Wt,_t,c]),us=l.useCallback(R=>{if(!(R.relatedTarget instanceof Node&&R.currentTarget.contains(R.relatedTarget))){if(Qn(R.dataTransfer)){te(null);return}En(R.dataTransfer)&&B(null)}},[]),Jt=l.useCallback(R=>{const I=Qn(R.dataTransfer);if(I){R.preventDefault(),te(null);const xe=Wt(R,I);xe&&lu(R.dataTransfer,c,I)&&Yt(I,xe);return}!St||_t||!c||!En(R.dataTransfer)||(R.preventDefault(),gt(c,R.dataTransfer))},[St,Wt,gt,Yt,_t,c]),Is=l.useCallback(async R=>{if(R?.preventDefault(),!Ee||!q)return;Ge(!0);const I=()=>Ge(!1),xe=()=>ke(null);if(q==="createFile"){if(!Ne.trim()){Re.error(o("sidebarFilesTree.toast.filenameRequired")),I();return}if(!i.writeFile){Re.error(o("sidebarFilesTree.toast.writeNotSupported")),I();return}const pe=Ee.path,rt=pe?`${pe}/`:"",tt=Bt(`${rt}${Ne.trim()}`);await i.writeFile(tt,"").then(async Et=>{Et.success&&(Re.success(o("sidebarFilesTree.toast.fileCreated")),await C(pe)),xe()}).catch(()=>Re.error(o("sidebarFilesTree.toast.operationFailed"))).finally(I);return}if(q==="createFolder"){if(!Ne.trim()){Re.error(o("sidebarFilesTree.toast.folderNameRequired")),I();return}const pe=Ee.path,rt=pe?`${pe}/`:"",tt=Bt(`${rt}${Ne.trim()}`);await i.createDirectory(tt).then(async Et=>{Et.success&&(Re.success(o("sidebarFilesTree.toast.folderCreated")),await C(pe)),xe()}).catch(()=>Re.error(o("sidebarFilesTree.toast.operationFailed"))).finally(I);return}if(q==="rename"){if(!Ne.trim()){Re.error(o("sidebarFilesTree.toast.nameRequired")),I();return}if(!i.rename){Re.error(o("sidebarFilesTree.toast.renameNotSupported")),I();return}const pe=Ee.path,rt=pe.split("/").slice(0,-1).join("/"),tt=rt?`${rt}/`:"",Et=Ne.trim(),Rt=Bt(`${tt}${Et}`);try{const It=await za(i,{tabs:d,files:c},pe,Rt);It==="moved"?(Re.success(o("sidebarFilesTree.toast.renamedSuccessfully")),await C(rt),xe()):It==="conflict"?Re.error(o("sidebarFilesTree.toast.nameTaken",{name:Et,folder:Wn(c,rt)})):Re.error(o("sidebarFilesTree.toast.operationFailed"))}catch{Re.error(o("sidebarFilesTree.toast.operationFailed"))}finally{I()}return}if(q==="delete"){if(!i.delete){Re.error(o("sidebarFilesTree.toast.deleteNotSupported")),I();return}const pe=Ee.path,rt=pe.split("/").slice(0,-1).join("/");await i.delete(pe).then(async tt=>{tt.success&&(Re.success(o("sidebarFilesTree.toast.deletedSuccessfully")),await C(rt),c&&_e(c,pe),(ve===pe||ve&&ve.startsWith(pe+"/"))&&Pe(c,null)),xe()}).catch(()=>Re.error(o("sidebarFilesTree.toast.operationFailed"))).finally(I);return}I()},[q,Ee,Ne,i,d,C,_e,c,ve,Pe,o]),rs=l.useMemo(()=>c?$S({root:c,childrenByDir:Y,expandedPaths:we,loadErrorsByDir:V}):[],[Y,we,V,c]),os=l.useMemo(()=>new Map(rs.flatMap((R,I)=>R.kind==="node"?[[R.node.path,I]]:[])),[rs]),[Ut,Hs]=l.useState(null),[re,Ze]=l.useState(null),pt=l.useCallback(R=>{jt.current=R,Ze(R)},[]),[kt,Pt]=l.useState(null),Zt=l.useMemo(()=>[oe,kt,...ot??[]].flatMap(R=>R?[os.get(R)??-1]:[]),[kt,oe,ot,os]),is=l.useCallback(R=>BS(Kb(R),Zt,rs.length),[Zt,rs.length]),[z,qe]=l.useState(0);l.useLayoutEffect(()=>{if(!Ut||!re)return;const R=re.getBoundingClientRect().top-Ut.getBoundingClientRect().top+Ut.scrollTop;qe(Math.max(0,Math.round(R)))},[re,Ut]);const ut=l.useRef(null),Tt=l.useRef(new Map),Vt=l.useRef(null),Ht=l.useCallback(R=>{const I=Math.max(0,...Tt.current.values());R.style.setProperty("--oc-file-tree-width",`${I}px`)},[]),Mt=l.useCallback((R,I)=>{const xe=R.dataset.treeRowPath,pe=jt.current;!xe||!pe||I<=pe.clientWidth+.5||Tt.current.get(xe)!==I&&(Tt.current.set(xe,I),Vt.current===null&&(Vt.current=requestAnimationFrame(()=>{Vt.current=null,jt.current&&Ht(jt.current)})))},[Ht]);l.useEffect(()=>()=>{Vt.current!==null&&cancelAnimationFrame(Vt.current)},[]),l.useLayoutEffect(()=>{if(!re)return;const R=Tt.current;for(const pe of R.keys())os.has(pe)||R.delete(pe);const I=Ut?.scrollLeft??0;re.style.removeProperty("--oc-file-tree-width");const xe=re.clientWidth;for(const pe of re.children){const rt=pe instanceof HTMLElement?pe.dataset.treeRowPath:void 0;if(!rt)continue;const tt=pe.getBoundingClientRect().width;tt>xe+.5?R.set(rt,tt):R.delete(rt)}Ht(re),Ut&&(Ut.scrollLeft=I)},[re,os,Ut,Ht]);const fs=qb({count:rs.length,enabled:Ut!==null,getScrollElement:()=>Ut,estimateSize:R=>(rs[R]?.kind==="node"?ut.current:null)??zS,measureElement:(R,I,xe)=>{const pe=Gb(R,I,xe);return R.dataset.treeRowPath&&(ut.current=pe),I&&Mt(R,I.borderBoxSize?.[0]?.inlineSize??R.getBoundingClientRect().width),pe},getItemKey:R=>rs[R]?.key??R,overscan:12,scrollMargin:z,rangeExtractor:is}),Mn=R=>{if(R.kind==="error")return s.jsxs("div",{className:"sticky inset-s-0 flex w-[100cqw] items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingInlineStart:qc(R.depth)},children:[s.jsx(Hc,{depth:R.depth}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:R.message,children:R.message}),s.jsxs(dt,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{C(R.directory)},children:[s.jsx(se,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})]});const{node:I,depth:xe,isExpanded:pe}=R,rt=I.type==="directory";return s.jsx(JS,{node:I,root:c,isExpanded:pe,isActive:ve===I.path,isBrowserClient:u,depth:xe,isOpen:!rt&&ne.has(I.path),status:rt?void 0:Je(I.path),badge:rt?Oe(I.path):void 0,isDropTarget:rt&&(ht===I.path||P===I.path),isDragSource:oe===I.path,canUpload:St&&!_t,canMove:U,permissions:bt,downloadFile:i.downloadFile,onSelect:me,onToggle:vt,onRevealPath:nt,onOpenDialog:ft,onSetDropTarget:B,onDropFiles:gt,onPickFiles:lt,onMoveDragChange:Dt,onSetMoveDropTarget:te,onMoveDrop:Yt})},Fn=l.useCallback(R=>{const I=R.target instanceof Element?R.target.closest("[data-tree-row-path]"):null;Pt(I?.dataset.treeRowPath??null)},[]),yo=l.useCallback(R=>{R.relatedTarget instanceof Node&&R.currentTarget.contains(R.relatedTarget)||Pt(null)},[]);l.useEffect(()=>{const R=he.current;if(!R||!Ut||!re)return;const I=os.get(R);I===void 0||Ut.offsetParent===null||(he.current=null,fs.scrollToIndex(I,{align:"auto"}))});const hr=!!(c&&Y[c]),Ln=c?V[c]:null,$n=T.trim().length>0,vo=!_&&!$n&&E.length===0&&!Ln&&hr&&!!c,Bn=ht?Wn(c,ht):"",gr=P?Wn(c,P):"",So=J?J.source.path.slice(J.source.path.lastIndexOf("/")+1):"";return s.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col border-b border-edge-muted",children:[s.jsx("div",{className:"flex h-8 shrink-0 items-center border-t border-edge-muted px-2",children:s.jsx(tg,{className:"flex-1",start:null,groups:[[(Qe||He||St)&&{id:"add",label:o("sidebarFilesTree.actions.addMenuTitle"),icon:_t?"loader-4":"add",iconClassName:_t?"animate-spin":void 0,menu:s.jsxs(s.Fragment,{children:[Qe?s.jsxs(Gt,{onClick:()=>ft("createFile",{path:e,type:"directory"}),children:[s.jsx(se,{name:"file-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFile")]}):null,He?s.jsxs(Gt,{onClick:()=>ft("createFolder",{path:e,type:"directory"}),children:[s.jsx(se,{name:"folder-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFolder")]}):null,St?s.jsxs(Gt,{disabled:!c||_t,onClick:()=>lt(c),children:[s.jsx(se,{name:"upload-2",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.uploadFiles")]}):null]})},{id:"gitignored",label:o("filesView.tree.actions.showGitignored"),icon:"file-forbid",pressed:m,onSelect:()=>qu(!m)},{id:"refresh",label:o("sidebarFilesTree.actions.refreshTitle"),icon:"refresh",onSelect:()=>{be()}},{id:"collapse-all",label:o("sidebarFilesTree.actions.collapseAllTitle"),icon:"collapse-vertical",onSelect:()=>{c&&Ve(c)}}]]})}),s.jsxs("div",{className:"relative min-w-0 px-2 py-2",children:[D?s.jsxs(pn,{children:[s.jsx(mn,{asChild:!0,children:s.jsxs(dt,{variant:"ghost",size:"sm",className:"absolute inset-s-3 top-3 size-6 p-0 text-muted-foreground hover:text-foreground",title:o("sidebarFilesTree.search.mode.aria"),"aria-label":o("sidebarFilesTree.search.mode.aria"),children:[s.jsx(se,{name:M?"file-search":"search",className:"h-4 w-4"}),s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0.5 end-0.5 size-0 border-[3px] border-b-current border-e-current border-s-transparent border-t-transparent opacity-70"})]})}),s.jsx(hn,{align:"start",side:"bottom",children:s.jsxs(Oc,{value:y,onValueChange:R=>N(R==="contents"?"contents":"names"),children:[s.jsxs(zr,{value:"names",closeOnClick:!0,className:"items-center",children:[s.jsx(se,{name:"search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.names")]}),s.jsxs(zr,{value:"contents",closeOnClick:!0,className:"items-center",children:[s.jsx(se,{name:"file-search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.contents")]})]})})]}):s.jsx(se,{name:"search",className:"pointer-events-none absolute inset-s-4 top-4 h-4 w-4 text-muted-foreground"}),s.jsx(Dn,{ref:k,value:x,onChange:R=>w(R.target.value),placeholder:o(M?"sidebarFilesTree.search.contentsPlaceholder":"sidebarFilesTree.search.placeholder"),className:Le("h-8 ps-8 typography-meta",M?"pe-16":"pe-8")}),M?s.jsx(dt,{variant:"chip",size:"xs","aria-pressed":j,onClick:()=>{v(R=>!R),k.current?.focus()},title:o("sidebarFilesTree.search.regexTitle"),"aria-label":o("sidebarFilesTree.search.regexTitle"),className:"absolute inset-e-3 top-3.5 h-5 min-w-0 px-1 font-mono typography-micro",children:".*"}):null,x.trim().length>0?s.jsx("button",{type:"button","aria-label":o("sidebarFilesTree.search.clearAria"),className:Le("absolute top-4 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",M?"inset-e-10":"inset-e-4"),onClick:()=>{w(""),k.current?.focus()},children:s.jsx(se,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsxs(hs,{ref:Hs,outerClassName:"h-full min-h-0",className:Le("@container px-1.5 py-1.5 [overflow-anchor:none]",(ht===c||P===c)&&"bg-interactive-selection/10"),onDragEnter:ds,onDragOver:ds,onDragLeave:us,onDrop:Jt,children:[s.jsx("ul",{className:"flex flex-col",children:M&&W.status!=="idle"?s.jsx(FS,{state:W,activeMatchKey:O&&O.path===ve?O.key:null,onOpen:je,onDragStart:st,onDragEnd:ye}):_?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(se,{name:"loader-4",className:"h-4 w-4 animate-spin"}),o("sidebarFilesTree.state.searching")]}):$n&&E.length===0?s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("mobile.files.search.empty")}):E.length>0?E.map(R=>{const I=ve===R.path;return s.jsx("li",{"data-file-tree-path":R.path,children:s.jsxs("button",{type:"button",onClick:()=>me(R),onDoubleClick:()=>me(R,{pin:!0}),draggable:!0,onDragStart:xe=>{bi(xe),Uo(null);const pe=R.relativePath||wo(c??"",R.path);!pe||pe==="."||(xe.dataTransfer.setData(ir,pe),xe.dataTransfer.effectAllowed="copy")},onDragEnd:xe=>{xi(xe)&&me(R)},className:Le("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",Vi(I)),title:R.path,children:[s.jsx(uo,{filePath:R.path,extension:R.extension,className:"size-3.5"}),s.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},children:`‎${R.relativePath??R.path}‎`})]})},R.path)}):Ln?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:Ln}),s.jsxs(dt,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{be()},children:[s.jsx(se,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})]}):hr&&c?null:s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("sidebarFilesTree.state.loading")})}),vo?s.jsx("ul",{ref:pt,className:"relative min-w-[max(100%,var(--oc-file-tree-width,0px))]",style:{height:fs.getTotalSize()},onFocus:Fn,onBlur:yo,children:fs.getVirtualItems().map(R=>{const I=rs[R.index];if(!I)return null;const xe=I.kind==="node"?I.node.path:void 0;return s.jsx("li",{ref:fs.measureElement,"data-index":R.index,"data-tree-row-path":xe,"data-tree-disclosure-path":I.kind==="node"?xe:`${I.directory}/`,"data-file-tree-path":I.kind==="node"&&I.node.type==="file"?xe:void 0,className:Le("absolute inset-x-0 top-0",I.kind==="node"&&"min-w-max"),style:{transform:`translateY(${R.start-z}px)`},children:Mn(I)},R.key)})}):null]}),ht?s.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-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(se,{name:_t?"loader-4":"folder-received",className:Le("size-4 flex-shrink-0",_t&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:Bn,children:o(_t?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Bn})})]}):P?s.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-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(se,{name:"folder-received",className:"size-4 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:gr,children:o("sidebarFilesTree.drop.moveTarget",{path:gr})})]}):null]}),Nt,s.jsx(tr,{open:!!q,onOpenChange:R=>!R&&ke(null),children:s.jsxs(sr,{children:[s.jsxs(nr,{children:[s.jsxs(rr,{children:[q==="createFile"&&o("sidebarFilesTree.dialog.createFile.title"),q==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.title"),q==="rename"&&o("sidebarFilesTree.dialog.rename.title"),q==="delete"&&o("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(or,{children:[q==="createFile"&&o("sidebarFilesTree.dialog.createFile.description",{path:Ee?.path??o("sidebarFilesTree.dialog.rootFallback")}),q==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.description",{path:Ee?.path??o("sidebarFilesTree.dialog.rootFallback")}),q==="rename"&&o("sidebarFilesTree.dialog.rename.description",{name:Ee?.name??""}),q==="delete"&&o("sidebarFilesTree.dialog.delete.description",{name:Ee?.name??""})]})]}),q!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Dn,{value:Ne,onChange:R=>ze(R.target.value),placeholder:o(q==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:R=>{R.key==="Enter"&&Is()},autoFocus:!0})}),s.jsxs($r,{children:[s.jsx(dt,{variant:"outline",onClick:()=>ke(null),disabled:Ue,children:o("sidebarFilesTree.dialog.cancel")}),s.jsx(dt,{variant:q==="delete"?"destructive":"default",onClick:()=>{Is()},disabled:Ue||q!=="delete"&&!Ne.trim(),children:Ue?s.jsx(se,{name:"loader-4",className:"size-4 animate-spin"}):o(q==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),s.jsx(tr,{open:J!==null,onOpenChange:R=>{R||le(null)},children:s.jsxs(sr,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(nr,{children:[s.jsx(rr,{children:o("sidebarFilesTree.dialog.move.title")}),s.jsx(or,{children:J?o("sidebarFilesTree.dialog.move.description",{name:So,folder:Wn(c,J.targetDirectory)}):null})]}),s.jsxs($r,{className:"w-full sm:items-center sm:justify-between",children:[s.jsxs("div",{className:"flex cursor-pointer items-center gap-2 typography-meta text-muted-foreground",onClick:()=>ee(!$),children:[s.jsx(Xo,{checked:!$,onChange:R=>ee(!R),ariaLabel:o("sidebarFilesTree.dialog.move.neverAsk")}),s.jsx("span",{children:o("sidebarFilesTree.dialog.move.neverAsk")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(dt,{variant:"ghost",onClick:()=>le(null),children:o("sidebarFilesTree.dialog.cancel")}),s.jsx(dt,{onClick:js,children:o("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function t2(t){return t.runtimeKey}const s2=ur(()=>Ot(()=>import("./WalkthroughView-BMD1xSij.js"),__vite__mapDeps([207,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,208,186,187,188,189,190,191,192,193,194,195,181,182,183,185,196,197,198,199,200,201,202,203,209,210,211,204,212])).then(t=>({default:t.WalkthroughView}))),n2=ur(()=>Ot(()=>import("./DiffView-CIlNcbDh.js"),__vite__mapDeps([213,1,2,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,208,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,186,187,188,189,190,191,192,193,194,195,181,182,183,214,185,196,197,198,199,200,201,202,203,206,209,212])).then(t=>({default:t.DiffView}))),r2=ur(()=>Ot(()=>import("./FilesView-VMk-uSwN.js"),__vite__mapDeps([215,1,2,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,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,216,217,218,219,181,182,183,220,221,200,222,186,187,188,189,190,191,192,193,194,195,223,197,224,225,226,201,202,199,206,227,228,212,203,229])).then(t=>({default:t.FilesView}))),cu=l.lazy(()=>Ot(()=>import("./useAppFontEffects-UKWR--vP.js").then(t=>t.sf),__vite__mapDeps([3,1,2,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.PluginPane}))),El=l.lazy(()=>Ot(()=>import("./GuestSurfacePane-BUmmCfBg.js"),__vite__mapDeps([230,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.GuestSurfacePane}))),du={top:{container:"flex-col",page:"border-b border-border",vertical:!0},bottom:{container:"flex-col-reverse",page:"border-t border-border",vertical:!0},left:{container:"flex-row",page:"border-e border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-s border-border",vertical:!1}},o2=t=>{const e=$e.c(12),{mode:n,docking:r}=t,[o,i]=l.useState(null),a=du[r.dock],u=Math.max(og,o??r.size),c=a.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let d;e[0]!==a.page||e[1]!==c?(d=Le("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",c,a.page),e[0]=a.page,e[1]=c,e[2]=d):d=e[2];let f;e[3]!==a.vertical||e[4]!==u?(f=a.vertical?{height:u}:{width:u},e[3]=a.vertical,e[4]=u,e[5]=f):f=e[5];let p;e[6]!==n?(p=s.jsx(cu,{mode:n,onResize:i}),e[6]=n,e[7]=p):p=e[7];let m;return e[8]!==d||e[9]!==f||e[10]!==p?(m=s.jsx("div",{className:d,style:f,children:p}),e[8]=d,e[9]=f,e[10]=p,e[11]=m):m=e[11],m},Sn=(t,e)=>`${t}\0${e}`,i2=({visible:t,active:e,fill:n=!1,side:r})=>{const{t:o}=at(),i=X(k=>k.contextEditorTreeWidth),a=X(k=>k.setContextEditorTreeWidth),[u,c]=l.useState(!1),d=l.useRef(0),f=l.useRef(i),p=l.useRef(null),m=l.useRef(null),h=l.useRef(null),b=l.useCallback(k=>{const E=h.current;E&&(E.style.width=`${k}px`,E.style.setProperty("--oc-editor-tree-width",`${k}px`))},[]),g=k=>{if(t){try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}m.current=k.pointerId,c(!0),d.current=k.clientX,f.current=i,p.current=i,k.preventDefault()}},x=k=>{if(!u||m.current!==k.pointerId)return;const E=r==="left"?k.clientX-d.current:d.current-k.clientX,F=Jr(k.currentTarget)?-E:E,_=Ko(f.current+F);p.current!==_&&(p.current=_,b(_))},w=k=>{if(m.current!==k.pointerId)return;try{k.currentTarget.releasePointerCapture(k.pointerId)}catch{}const E=Ko(p.current??i);m.current=null,p.current=null,c(!1),a(E)},T=t?i:0;return s.jsxs("div",{ref:h,className:Le("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&(r==="left"?"me-auto":"ms-auto")),style:{width:`${u?p.current??T:T}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${u?p.current??i:i}px`,overflowX:"clip",transitionProperty:u?"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:Le("pointer-events-none absolute inset-y-0 z-20 w-px bg-border",r==="left"?"inset-e-0":"inset-s-0")}),t&&!n&&s.jsx("div",{className:Le("absolute top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",r==="left"?"inset-e-0":"inset-s-0",u&&"bg-[var(--interactive-border)]"),onPointerDown:g,onPointerMove:x,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Le("relative z-10 h-full shrink-0 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-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(QS,{visible:t&&e})})]})},an=t=>{const e=$e.c(12),{zone:n,isOpen:r,interactive:o,hidden:i,className:a,children:u}=t,c=!r||i;let d;e[0]!==u||e[1]!==c?(d=s.jsx(Kc,{paused:c,children:u}),e[0]=u,e[1]=c,e[2]=d):d=e[2];let f;e[3]!==o||e[4]!==d?(f=s.jsx(Wc.Provider,{value:!0,children:s.jsx(Hf.Provider,{value:o,children:d})}),e[3]=o,e[4]=d,e[5]=f):f=e[5];let p;e[6]!==a||e[7]!==f?(p=s.jsx("div",{className:a,children:f}),e[6]=a,e[7]=f,e[8]=p):p=e[8];let m;return e[9]!==p||e[10]!==n?(m=s.jsx(DS,{zone:n,children:p}),e[9]=p,e[10]=n,e[11]=m):m=e[11],m},a2=()=>{const{t}=at(),e=Vs()??"",n=l.useMemo(()=>e?cs(e):"",[e]),r=X(S=>n?S.contextPanelByDirectory[n]:void 0),o=mr(),i=o?.kind==="preparing",a=o?.kind==="ready"?o.directory:null,u=ao(o,e)??"",c=X(S=>S.contextSurfaceZones),d=X(S=>S.contextPanelByDirectory),f=X(S=>S.closeContextPanelTab),p=X(S=>S.closeContextFile),m=X(S=>S.openContextPanelTab),h=X(S=>S.openAgentBrowserTab),b=X(S=>S.openContextFile),g=X(S=>S.contextEditorTreeVisible),x=X(S=>S.contextEditorVisible),w=X(S=>S.fileTreeSide),T=gs(S=>S.setSelectedPath),k=lr(S=>S.headerSlot),E=l.useMemo(()=>r?.tabs??[],[r?.tabs]),F=Ir(S=>S.chatCovered),_=l.useMemo(()=>{const S=ne=>{const q=r?Mr(r,c,ne):null,ke=ne==="bottom"&&F;return{activeTab:q,isOpen:!!(r&&er(r,ne).isOpen&&q)&&!ke}};return{left:S("left"),right:S("right"),bottom:S("bottom")}},[F,r,c]),A={left:{..._.left,activeTab:Rr(_.left.activeTab,_.left.isOpen)},right:{..._.right,activeTab:Rr(_.right.activeTab,_.right.isOpen)},bottom:{..._.bottom,activeTab:Rr(_.bottom.activeTab,_.bottom.isOpen)}},D={left:Bo(A.left.isOpen),right:Bo(A.right.isOpen),bottom:Bo(A.bottom.isOpen)},y=S=>!D[S],N={left:Xn(A.left.isOpen),right:Xn(A.right.isOpen),bottom:Xn(A.bottom.isOpen)},j={left:Tr(A.left.isOpen,N.left,A.left.activeTab?.mode),right:Tr(A.right.isOpen,N.right,A.right.activeTab?.mode),bottom:Tr(A.bottom.isOpen,N.bottom,A.bottom.activeTab?.mode)},v=S=>{const ne=Zo(c,S);return{zone:ne,...A[ne]}},M=v("file"),W=v("chat"),G=v("browser"),O=v("diff"),Z=v("terminal"),Q=v("walkthrough"),[B,oe]=l.useState([]),H=l.useCallback((S,ne)=>{oe(q=>Ku(q,Sn(S,ne)))},[]),P=X(S=>S.liveBrowserTabLimit);l.useEffect(()=>t0((S,ne)=>{const q=ne.directory?cs(ne.directory):n;if(!q)return null;const ke=h(q,S,ne.sessionId);return ke&&H(q,ke),ke}),[n,h,H]),l.useEffect(()=>s0((S,ne)=>X.getState().contextPanelByDirectory[S]?.tabs?.some(ke=>ke.id===ne&&ke.mode==="browser")?(f(S,ne),!0):!1),[f]),l.useEffect(()=>Js(S=>{if(S.type!=="file-open-request")return;const ne=S.directory??e;ne&&b(ne,S.path)}),[e,b]),l.useEffect(()=>Js(S=>{if(S.type!=="plan-open-request")return;const ne=S.directory??e,q=Wf(ne,S.projectId);!ne||!q||X.getState().openProjectKnowledgePlan(ne,sg(q),S.planId)}),[e]);const te=_[G.zone].activeTab,J=te?.mode==="browser"?te.id:null;l.useEffect(()=>{e0(n,J)},[n,J]);const le=_[M.zone].activeTab;l.useEffect(()=>{if(!u||le?.mode!=="file"||!le.targetPath)return;const S=ks(le.targetPath)===ks(u);T(cs(u),le.targetPath,{allowOutsideRoot:!o&&S})},[u,o,le,T]);const K=l.useMemo(()=>E.some(S=>S.mode==="file"&&S.targetPath),[E]),U=l.useMemo(()=>E.some(S=>S.mode==="file"),[E]),$=K&&(x||!g),ee=M.activeTab?.mode==="file",Y=l.useCallback(S=>{n&&p(n,S)},[p,n]),ie=W.isOpen&&W.activeTab?.mode==="chat"?W.activeTab:null,V=ie?ho(ie.dedupeKey):null,fe=l.useMemo(()=>(ie?.targetDirectory?cs(ie.targetDirectory):"")||n||null,[ie?.targetDirectory,n]),Se=l.useMemo(()=>V?{sessionId:V,directory:fe}:null,[V,fe]);l.useEffect(()=>{if(!fe||!V||typeof window>"u")return;const S=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Po(fe,V,!1);return}Gc(V),Po(fe,V,!0)};S();const ne=window.setInterval(S,1e4);return window.addEventListener("focus",S),window.addEventListener("blur",S),document.addEventListener("visibilitychange",S),()=>{window.clearInterval(ne),window.removeEventListener("focus",S),window.removeEventListener("blur",S),document.removeEventListener("visibilitychange",S),Po(fe,V,!1)}},[fe,V]);const Te=O.activeTab,ue=l.useCallback(S=>{!n||Te?.mode!=="diff"||m(n,{mode:"diff",targetPath:Te.targetPath,targetDirectory:Te.targetDirectory,stagedDiff:S==="staged",diffScope:S})},[Te,n,m]),Me=G.isOpen&&G.activeTab?.mode==="browser"?G.activeTab.id:null;l.useEffect(()=>{Me&&n&&H(n,Me)},[n,Me,H]);const{loadedBrowserTabs:Ae,sleepingBrowserTabs:De}=l.useMemo(()=>{const S=new Set(B),ne=new Set;for(const[Ie,Ne]of Object.entries(d))for(const ze of Ne.tabs)ze.mode==="browser"&&ze.ownerSessionId===null&&ne.add(Sn(Ie,ze.id));const q=Gu(B,ne,P),ke=[],Ee=[];for(const[Ie,Ne]of Object.entries(d)){const ze=Ie===n;for(const Ue of Ne.tabs){if(Ue.mode!=="browser")continue;const Ge=Sn(Ie,Ue.id),Qe=Ue.ownerSessionId===null,He=ze&&Ue.id===Me||(Qe?q.has(Ge):S.has(Ge));if(!He&&!ze&&Qe)continue;const Ke={directory:Ie,id:Ue.id,targetPath:Ue.targetPath,ownerSessionId:Ue.ownerSessionId};(He?ke:Ee).push(Ke)}}return ke.sort((Ie,Ne)=>Sn(Ie.directory,Ie.id)<Sn(Ne.directory,Ne.id)?-1:1),{loadedBrowserTabs:ke,sleepingBrowserTabs:Ee}},[d,n,P,B,Me]);l.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const S=De.map(ne=>Qv({tabId:ne.id,directory:ne.directory,ownerSessionId:ne.ownerSessionId,describe:()=>({title:"",url:ne.targetPath??""}),wake:()=>H(ne.directory,ne.id)}));return()=>S.forEach(ne=>ne())},[De,H]);const Be=l.useMemo(()=>E.filter(S=>S.mode==="diff"),[E]),we=l.useMemo(()=>E.find(S=>S.mode==="terminal")??null,[E]),ve=l.useMemo(()=>E.find(S=>S.mode==="walkthrough")??null,[E]),Pe=l.useMemo(()=>E.filter(S=>Pn(S.mode)),[E]),he=Ri(S=>S.guests),Fe=l.useMemo(()=>new Set(he.filter(ng).map(S=>S.id)),[he]),_e=l.useMemo(()=>{const S=new Map;for(const ne of he){const q=rg(ne);q&&S.set(ne.id,q)}return S},[he]),We=Z.zone,Xe=l.useCallback(S=>{const ne=Xi({mode:"terminal",label:t("layout.mainTab.terminal"),from:We},S);return{finish:()=>ne.finish(n),cancel:ne.cancel}},[n,t,We]),Ve=(S,ne)=>ne?k[S]:null;return s.jsxs(s.Fragment,{children:[U?s.jsxs(an,{zone:M.zone,interactive:j[M.zone],isOpen:M.isOpen,hidden:y(M.zone),className:Le("absolute inset-0 flex",w==="left"&&"flex-row-reverse",ee?"flex":"hidden"),children:[i?s.jsx("div",{className:"h-full min-w-0 flex-1",children:s.jsx(Nr,{})}):K||!g?s.jsx("div",{className:Le("h-full min-w-0 flex-1",K&&!$&&"hidden"),children:K?s.jsx(l.Suspense,{fallback:null,children:s.jsx(r2,{mode:"editor-only",visible:!y(M.zone)&&ee&&$,onCloseFile:Y})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(se,{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,i?null:s.jsx(i2,{visible:g,active:M.isOpen&&ee,fill:!$,side:w})]}):null,ie&&V&&Se?s.jsx(an,{zone:W.zone,interactive:j[W.zone],isOpen:W.isOpen,hidden:y(W.zone),className:"absolute inset-0 bg-background",children:s.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:V}),className:"h-full",children:s.jsx(bc,{pinnedSession:Se,readOnly:ie.readOnly})})},ie.id):null,Ae.map(S=>{const ne=S.directory===n&&G.activeTab?.id===S.id,q=S.directory===n?a??S.directory:S.directory;return s.jsx(an,{zone:G.zone,interactive:j[G.zone],isOpen:G.isOpen,hidden:y(G.zone),className:Le("absolute inset-0",!ne&&"invisible pointer-events-none"),children:s.jsx("div",{className:"h-full","aria-hidden":!ne||void 0,children:s.jsx(Kc,{paused:!ne,children:S.directory===n&&i?s.jsx(Nr,{}):s.jsx(NS,{initialUrl:S.targetPath??"",directory:S.directory,siteDirectory:q,tabID:S.id,ownerSessionId:S.ownerSessionId,visible:ne&&G.isOpen},q)})})},Sn(S.directory,S.id))}),Be.map(S=>{const ne=O.activeTab?.id===S.id;return s.jsx(an,{zone:O.zone,interactive:j[O.zone],isOpen:O.isOpen,hidden:y(O.zone),className:Le("absolute inset-0",!ne&&"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(cn,{value:Ve(O.zone,ne),children:i&&!S.targetDirectory?s.jsx(Nr,{}):s.jsx(n2,{directory:S.targetDirectory??a,visible:O.isOpen&&ne,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:S.diffScope??(S.stagedDiff?"staged":null),onDiffScopeChange:ue,targetFilePath:S.targetPath,flushContent:!0})})})},S.id)}),we?s.jsx(an,{zone:Z.zone,interactive:j[Z.zone],isOpen:Z.isOpen,hidden:y(Z.zone),className:Le("absolute inset-0",Z.activeTab?.mode==="terminal"?"block":"hidden"),children:s.jsx(cn,{value:Ve(Z.zone,Z.activeTab?.mode==="terminal"),children:s.jsx(Uf.Provider,{value:Xe,children:s.jsx(Vf,{visible:Z.isOpen&&Z.activeTab?.mode==="terminal",directory:we.targetDirectory,onLastTabClosed:()=>{n&&f(n,we.id)}})})})}):null,ve?s.jsx(an,{zone:Q.zone,interactive:j[Q.zone],isOpen:Q.isOpen,hidden:y(Q.zone),className:Le("absolute inset-0",Q.activeTab?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(cn,{value:Ve(Q.zone,Q.activeTab?.mode==="walkthrough"),children:s.jsx(s2,{directory:ve.targetDirectory??e,visible:Q.isOpen&&Q.activeTab?.mode==="walkthrough"})})})}):null,Pe.map(S=>{if(!Pn(S.mode))return null;const ne=v(S.mode),q=Fr(S.mode),ke=Fe.has(q),Ee=_e.get(q),Ie=ne.activeTab?.id===S.id,Ne=Ie&&ne.isOpen;return ke&&!Ee&&!Ne?null:s.jsx(an,{zone:ne.zone,interactive:j[ne.zone],isOpen:ne.isOpen,hidden:y(ne.zone),className:Le("absolute inset-0",Ie?"block":"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:ke?Ee?s.jsxs("div",{className:Le("flex h-full",du[Ee.dock].container),children:[s.jsx(o2,{mode:S.mode,docking:Ee}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Ne?s.jsx(El,{mode:S.mode}):null})]}):s.jsx(El,{mode:S.mode}):s.jsx(cu,{mode:S.mode})})},S.id)})]})},l2={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},c2=()=>{const t=$e.c(20),{t:e}=at(),n=Us(d2),r=Us(u2),o=l.useRef(null),[i,a]=l.useState(!1);let u,c;t[0]!==n?(u=()=>{if(!n){a(!1);return}const w=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(w)},c=[n],t[0]=n,t[1]=u,t[2]=c):(u=t[1],c=t[2]),l.useEffect(u,c);let d,f;if(t[3]!==n?(d=()=>{if(!n)return;const w=T=>{const k=o.current;k&&(k.style.transform=`translate(${T.clientX+12}px, ${T.clientY+12}px)`)};return window.addEventListener("pointermove",w),()=>window.removeEventListener("pointermove",w)},f=[n],t[3]=n,t[4]=d,t[5]=f):(d=t[4],f=t[5]),l.useEffect(d,f),!n)return null;const p=i?"opacity-100":"opacity-0";let m;t[6]!==p?(m=Le("absolute inset-0 bg-surface-overlay/40 transition-opacity duration-150 ease-out motion-reduce:transition-none",p),t[6]=p,t[7]=m):m=t[7];let h;t[8]!==m?(h=s.jsx("div",{className:m}),t[8]=m,t[9]=h):h=t[9];let b;t[10]!==n.frames||t[11]!==r||t[12]!==e?(b=Ti.map(w=>{const T=n.frames[w];if(T.width<=0||T.height<=0)return null;const k=r===w;return s.jsx("div",{className:Le("absolute flex items-center justify-center rounded-[10px] border transition-colors duration-100",k?"border-primary bg-background/90 text-foreground shadow-sm":"border-border bg-background/80 text-muted-foreground"),style:{left:T.left,top:T.top,width:T.width,height:T.height},children:s.jsx("span",{className:"typography-ui-label",children:e(l2[w])})},w)}),t[10]=n.frames,t[11]=r,t[12]=e,t[13]=b):b=t[13];let g;t[14]!==n.label?(g=s.jsx("div",{ref:o,className:"absolute left-0 top-0 rounded-md border border-border bg-background px-2 py-1 typography-meta text-foreground shadow-sm",children:n.label}),t[14]=n.label,t[15]=g):g=t[15];let x;return t[16]!==h||t[17]!==b||t[18]!==g?(x=Hl.createPortal(s.jsxs("div",{className:"pointer-events-none fixed inset-0 z-[60]","aria-hidden":"true",children:[h,b,g]}),document.body),t[16]=h,t[17]=b,t[18]=g,t[19]=x):x=t[19],x};function d2(t){return t.drag}function u2(t){return t.hovered}const Il=320,f2=({rowWidth:t,leftWidth:e,rightWidth:n,sidebarWidth:r,opening:o})=>{let i=t-e-n;if(i>=Il)return{collapseSidebar:!1,displace:null};const a=r!==null;if(a&&(i+=r),i>=Il)return{collapseSidebar:a,displace:null};const u=o==="left"?"right":"left";return{collapseSidebar:a,displace:(u==="left"?e:n)>0?u:null}},p2=({directoryKey:t,folded:e,readRowWidth:n})=>{const r=x=>{const w=x.contextPanelByDirectory[t];return{left:Kn(w,x.contextSurfaceZones,"left"),right:Kn(w,x.contextSurfaceZones,"right")}},o=(x,w,T)=>{const k=x.contextPanelByDirectory[t];return(T&&k?Mr(k,x.contextSurfaceZones,w):null)?x.contextZoneSizes[w]??Ci:0},i=x=>{const w=x.contextPanelByDirectory[t];return w?Ti.some(T=>er(w,T).expanded&&Zu(w,x,T)):!1};let a=null,u=!1,c=r(X.getState()),d=i(X.getState());const f=x=>{e.current=x,X.getState().setSidebarFoldedForExpandedZone(x==="expanded")},p=x=>{u=!0,X.getState().setSidebarOpen(x),u=!1},m=()=>{f(null),X.getState().isSidebarOpen||p(!0)};!e.current&&X.getState().sidebarFoldedForExpandedZone&&(e.current="expanded");const h=e.current;h&&!(h==="expanded"?d:c[h])&&m(),!e.current&&d&&X.getState().isSidebarOpen&&(f("expanded"),p(!1));const b=(x,w,T)=>{const k=n();if(!k)return;const E=e.current==="expanded",F=f2({rowWidth:E?k-x.sidebarWidth:k,leftWidth:o(x,"left",T.left),rightWidth:o(x,"right",T.right),sidebarWidth:x.isSidebarOpen||E?x.sidebarWidth:null,opening:w});if(F.displace){const _=er(x.contextPanelByDirectory[t],F.displace).activeTabId;_&&(a={side:F.displace,by:w,tabId:_})}F.collapseSidebar&&(f(w),x.isSidebarOpen&&p(!1)),F.displace&&x.closeContextZone(t,F.displace)},g=x=>{if(a?.side===x){e.current===x&&f(a.by);return}const w=a?.by===x?a:null;w&&(a=null),e.current===x&&(w?f(w.side):m()),w&&X.getState().setActiveContextPanelTab(t,w.tabId)};return X.subscribe((x,w)=>{x.isSidebarOpen!==w.isSidebarOpen&&!u&&f(null);const T=r(x),k=i(x),E=c,F=d;c=T,d=k;const _=["left","right"],A=_.filter(y=>T[y]&&!E[y]),D=_.filter(y=>!T[y]&&E[y]);for(const y of D){const N=y==="left"?"right":"left";A.includes(N)&&(e.current===y&&f(N),a?.by===y&&(a=null))}for(const y of D)g(y);for(const y of A)b(x,y,T);k&&!F&&x.isSidebarOpen?(f("expanded"),p(!1)):!k&&F&&e.current==="expanded"&&m()})},m2=()=>{const t=$e.c(5),e=Vs();let n;t[0]!==e?(n=e?cs(e):"",t[0]=e,t[1]=n):n=t[1];const r=n,o=l.useRef(null);let i,a;return t[2]!==r?(i=()=>{if(r)return p2({directoryKey:r,folded:o,readRowWidth:h2})},a=[r],t[2]=r,t[3]=i,t[4]=a):(i=t[3],a=t[4]),l.useEffect(i,a),null};function h2(){return document.querySelector("[data-workspace-row]")?.clientWidth}const g2=t=>{const e=$e.c(54),{open:n,onOpenChange:r}=t,{t:o}=at(),i=X(b2),a=X(x2),u=X(w2),c=X(y2),d=X(v2),f=Ui(),p=X(ig);let m;if(e[0]!==i||e[1]!==f||e[2]!==p){let B;e[4]!==p?(B=oe=>p||oe.id!=="workflows",e[4]=p,e[5]=B):B=e[5],m=Yo(i,f).filter(B),e[0]=i,e[1]=f,e[2]=p,e[3]=m}else m=e[3];const h=m,b=u.length===0;let g;if(e[6]!==u||e[7]!==h){let B;e[9]!==u?(B=oe=>u.includes(oe.id),e[9]=u,e[10]=B):B=e[10],g=h.every(B),e[6]=u,e[7]=h,e[8]=g}else g=e[8];const x=g,w=l.useRef(!1);let T;e[11]!==u||e[12]!==h||e[13]!==o?(T=h.map((B,oe)=>({id:B.id,label:B.label??o(B.labelKey),visible:!u.includes(B.id),groupStart:oe>0&&Ks(h[oe-1])!==Ks(B)})),e[11]=u,e[12]=h,e[13]=o,e[14]=T):T=e[14];const k=T;let E;e[15]!==i||e[16]!==f||e[17]!==a?(E=B=>{const oe=Yo(B,f).map(S2).filter(P=>B.includes(P)),H=new Set(oe);a([...oe,...i.filter(P=>!H.has(P))])},e[15]=i,e[16]=f,e[17]=a,e[18]=E):E=e[18];const F=E;let _;e[19]!==r?(_=(B,oe)=>{if(!B&&oe.reason==="escape-key"&&w.current){oe.cancel(),oe.allowPropagation();return}w.current=!1,r(B)},e[19]=r,e[20]=_):_=e[20];let A;e[21]===Symbol.for("react.memo_cache_sentinel")?(A=B=>{w.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(B.key)&&B.preventBaseUIHandler()},e[21]=A):A=e[21];let D;e[22]!==o?(D=o("contextRail.configure.dialogTitle"),e[22]=o,e[23]=D):D=e[23];let y;e[24]!==D?(y=s.jsx(rr,{children:D}),e[24]=D,e[25]=y):y=e[25];let N;e[26]!==o?(N=o("contextRail.configure.dialogDescription"),e[26]=o,e[27]=N):N=e[27];let j;e[28]!==N?(j=s.jsx(or,{children:N}),e[28]=N,e[29]=j):j=e[29];let v;e[30]!==j||e[31]!==y?(v=s.jsxs(nr,{children:[y,j]}),e[30]=j,e[31]=y,e[32]=v):v=e[32];let M;e[33]!==o?(M=o("contextRail.configure.dragInstructions"),e[33]=o,e[34]=M):M=e[34];let W;e[35]===Symbol.for("react.memo_cache_sentinel")?(W=B=>{w.current=B},e[35]=W):W=e[35];let G;e[36]!==F||e[37]!==k||e[38]!==c||e[39]!==M?(G=s.jsx(qf,{items:k,onVisibleChange:c,onReorder:F,settingsItemPrefix:"layout.context-rail.surface.",dragInstructions:M,onDraggingChange:W}),e[36]=F,e[37]=k,e[38]=c,e[39]=M,e[40]=G):G=e[40];let O;e[41]!==b||e[42]!==x||e[43]!==d||e[44]!==o?(O=b?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[x?s.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(dt,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[41]=b,e[42]=x,e[43]=d,e[44]=o,e[45]=O):O=e[45];let Z;e[46]!==v||e[47]!==G||e[48]!==O?(Z=s.jsxs(sr,{className:"max-w-md",onKeyDown:A,children:[v,G,O]}),e[46]=v,e[47]=G,e[48]=O,e[49]=Z):Z=e[49];let Q;return e[50]!==n||e[51]!==Z||e[52]!==_?(Q=s.jsx(tr,{open:n,onOpenChange:_,children:Z}),e[50]=n,e[51]=Z,e[52]=_,e[53]=Q):Q=e[53],Q};function b2(t){return t.contextRailOrder}function x2(t){return t.setContextRailOrder}function w2(t){return t.contextRailHiddenSurfaces}function y2(t){return t.setContextRailSurfaceVisible}function v2(t){return t.setContextRailHiddenSurfaces}function S2(t){return t.id}const uu=150,k2=500,j2=[],C2=t=>{const e=$e.c(70),{surface:n,isActive:r,showActivityDot:o,label:i,description:a,badgeCount:u,badgeAriaLabel:c,badgeDescription:d,orderNumber:f,showOrderNumber:p,onSelect:m}=t,h=X(E2);let b;e[0]!==h?(b=Ii("switch_context_surface",h),e[0]=h,e[1]=b):b=e[1];const g=b;let x;e[2]!==f||e[3]!==g?(x=g&&g!==wc&&f!=null&&f<=10?xs(`${g}+${f===10?"0":f}`):void 0,e[2]=f,e[3]=g,e[4]=x):x=e[4];const w=x;let T;e[5]!==n.id?(T={id:n.id},e[5]=n.id,e[6]=T):T=e[6];const{attributes:k,listeners:E,setNodeRef:F,transform:_,transition:A,isDragging:D}=ud(T),y=u!=null&&u>0;let N;e[7]!==_?(N=pd.Translate.toString(_),e[7]=_,e[8]=N):N=e[8];let j;e[9]!==N||e[10]!==A?(j={transform:N,transition:A},e[9]=N,e[10]=A,e[11]=j):j=e[11];const v=D&&"z-10 opacity-70";let M;e[12]!==v?(M=Le("relative",v),e[12]=v,e[13]=M):M=e[13];let W;e[14]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx("div",{}),e[14]=W):W=e[14];let G;e[15]!==m||e[16]!==n?(G=()=>m(n),e[15]=m,e[16]=n,e[17]=G):G=e[17];const O=c??i,Z=n.id,Q=r?"text-primary":"text-muted-foreground hover:text-foreground";let B;e[18]!==Q?(B=Le("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",Q),e[18]=Q,e[19]=B):B=e[19];let oe;e[20]!==n.icon||e[21]!==n.iconSrc||e[22]!==n.id?(oe=n.id==="diff"?s.jsx(hc,{className:"h-[17px] w-[17px]"}):s.jsx(Pi,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[17px] w-[17px]"}),e[20]=n.icon,e[21]=n.iconSrc,e[22]=n.id,e[23]=oe):oe=e[23];let H;e[24]!==y||e[25]!==f||e[26]!==o||e[27]!==p?(H=p&&f!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-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:f===10?"0":f}):y?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):o?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[24]=y,e[25]=f,e[26]=o,e[27]=p,e[28]=H):H=e[28];let P;e[29]!==k||e[30]!==r||e[31]!==E||e[32]!==n.id||e[33]!==O||e[34]!==B||e[35]!==oe||e[36]!==H||e[37]!==G?(P=s.jsx(Ft,{asChild:!0,children:s.jsxs("button",{type:"button",...k,...E,onClick:G,"aria-label":O,"aria-pressed":r,"data-context-surface":Z,className:B,children:[oe,H]})}),e[29]=k,e[30]=r,e[31]=E,e[32]=n.id,e[33]=O,e[34]=B,e[35]=oe,e[36]=H,e[37]=G,e[38]=P):P=e[38];let te;e[39]!==h||e[40]!==n.id||e[41]!==w?(te=n.id==="terminal"?xs(Ts("toggle_terminal",h),""):w,e[39]=h,e[40]=n.id,e[41]=w,e[42]=te):te=e[42];let J;e[43]!==i||e[44]!==te?(J=s.jsx(Ws,{label:i,shortcut:te}),e[43]=i,e[44]=te,e[45]=J):J=e[45];let le;e[46]!==a?(le=s.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),e[46]=a,e[47]=le):le=e[47];let K;e[48]!==d?(K=d?s.jsx("span",{className:"typography-micro text-muted-foreground",children:d}):null,e[48]=d,e[49]=K):K=e[49];let U;e[50]!==n.id?(U=n.id==="context"?s.jsx(bd,{}):null,e[50]=n.id,e[51]=U):U=e[51];let $;e[52]!==J||e[53]!==le||e[54]!==K||e[55]!==U?($=s.jsx($t,{side:"left",sideOffset:8,className:"max-w-72 break-words",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[J,le,K,U]})}),e[52]=J,e[53]=le,e[54]=K,e[55]=U,e[56]=$):$=e[56];let ee;e[57]!==P||e[58]!==$?(ee=s.jsx(ro,{render:W,children:s.jsxs(Lt,{delayDuration:uu,children:[P,$]})}),e[57]=P,e[58]=$,e[59]=ee):ee=e[59];let Y;e[60]!==n.mode?(Y=s.jsx(oo,{children:s.jsx(mc,{mode:n.mode})}),e[60]=n.mode,e[61]=Y):Y=e[61];let ie;e[62]!==ee||e[63]!==Y?(ie=s.jsxs(pr,{children:[ee,Y]}),e[62]=ee,e[63]=Y,e[64]=ie):ie=e[64];let V;return e[65]!==F||e[66]!==ie||e[67]!==j||e[68]!==M?(V=s.jsx("div",{ref:F,style:j,className:M,children:ie}),e[65]=F,e[66]=ie,e[67]=j,e[68]=M,e[69]=V):V=e[69],V},T2=t=>{if(!t)return{icon:"ticket-2"};const e=ug(t,"line");return e?{icon:e}:{icon:fg,iconSrc:pg(t)}},N2=()=>{const t=$e.c(122),{t:e}=at(),n=Vs();let r;t[0]!==n?(r=n?cs(n):"",t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=Oe=>o?Oe.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const a=X(i),u=X(I2),c=X(P2),d=X(R2),f=X(D2),p=X(A2),m=X(_2),h=X(O2),b=X(M2),g=Xu();let x;t[4]!==g?(x=Oe=>g.some(me=>me.instances.defaultInstance!==null&&Oe.entries[Vn({provider:me.id,instance:me.instances.defaultInstance})]?.hasChecked===!0),t[4]=g,t[5]=x):x=t[5];const w=fn(x),T=fn(L2),k=ag(o||null),E=ji(k==="none"?null:k??g[0]?.id),F=k==="none"?"pullRequest":E.terminology.changeRequest,{screenWidth:_}=gn(),A=mr(),D=n??null;let y;t[6]!==A||t[7]!==D?(y=ao(A,D),t[6]=A,t[7]=D,t[8]=y):y=t[8];const N=y,j=lg(N),v=lo(j),{git:M}=Es(),W=An($2),G=An(B2);let O,Z;t[9]!==W||t[10]!==G||t[11]!==M||t[12]!==j||t[13]!==N?(O=()=>{if(!M||!N||!j||j===N)return;oa(()=>W(j,M));const Oe=Xt(N),me=Xt(j);return Wr.onGitRefreshHint(je=>{const st=Xt(je.directory);st!==Oe&&st!==me||oa(()=>G(j,M,{silent:!0}))})},Z=[W,G,M,j,N],t[9]=W,t[10]=G,t[11]=M,t[12]=j,t[13]=N,t[14]=O,t[15]=Z):(O=t[14],Z=t[15]),l.useEffect(O,Z);let Q;t[16]!==b?(Q=Ii("switch_context_surface",b),t[16]=b,t[17]=Q):Q=t[17];const B=Q,[oe,H]=l.useState(!1);let P,te;t[18]!==B?(te=()=>{const Oe=new Set;let me=null,je=!1;const st=z2,ye=()=>{Ra(B,Oe)?!je&&me===null&&(me=setTimeout(()=>H(!0),k2)):(je=!1,me!==null&&(clearTimeout(me),me=null),H(!1))},ot=jt=>{if(Oe.add(jt.key.toLowerCase()),st(jt.key)&&Ra(B,Oe)){je=!0,me!==null&&(clearTimeout(me),me=null),H(!1);return}ye()},Ct=jt=>{Oe.delete(jt.key.toLowerCase()),ye()},xt=()=>{Oe.clear(),je=!1,me!==null&&(clearTimeout(me),me=null),H(!1)};return window.addEventListener("keydown",ot,!0),window.addEventListener("keyup",Ct,!0),window.addEventListener("blur",xt),()=>{window.removeEventListener("keydown",ot,!0),window.removeEventListener("keyup",Ct,!0),window.removeEventListener("blur",xt),me!==null&&clearTimeout(me)}},P=[B],t[18]=B,t[19]=P,t[20]=te):(P=t[19],te=t[20]),l.useEffect(te,P);let J;t[21]===Symbol.for("react.memo_cache_sentinel")?(J={activationConstraint:{distance:8}},t[21]=J):J=t[21];let le;t[22]===Symbol.for("react.memo_cache_sentinel")?(le={activationConstraint:{delay:200,tolerance:6}},t[22]=le):le=t[22];const K=ad(Ur(cd,J),Ur(ld,le)),U=Ui(),$=Pa(W2),ee=Pa(U2),Y=a?.tabs??j2,ie=cg(Y,n||null);let V;t[23]!==h||t[24]!==a?(V=vi(a,h),t[23]=h,t[24]=a,t[25]=V):V=t[25];const fe=V,Se=v?.files.length??0;let Te;if(t[26]!==d||t[27]!==c||t[28]!==U||t[29]!==k||t[30]!==_||t[31]!==T||t[32]!==Y||t[33]!==E||t[34]!==ie){let Oe;t[36]!==k||t[37]!==E?(Oe=me=>me.id==="pr"?{...me,...T2(k==="none"?null:E)}:me,t[36]=k,t[37]=E,t[38]=Oe):Oe=t[38],Te=dg({railOrder:c,hiddenSurfaces:d,isVSCode:Si(),screenWidth:_,tabs:Y,sourceControlConnected:T,workflowsShown:ie,extras:U}).map(Oe),t[26]=d,t[27]=c,t[28]=U,t[29]=k,t[30]=_,t[31]=T,t[32]=Y,t[33]=E,t[34]=ie,t[35]=Te}else Te=t[35];const ue=Te;let Me;t[39]!==Y?(Me=Y.some(V2),t[39]=Y,t[40]=Me):Me=t[40];const Ae=Me;let De,Be;t[41]!==m||t[42]!==h||t[43]!==w||t[44]!==o||t[45]!==Ae||t[46]!==fe||t[47]!==T?(De=()=>{!o||!w||T||Ae||!fe.has("pr")||m(o,Zo(h,"pr"))},Be=[m,h,o,w,Ae,fe,T],t[41]=m,t[42]=h,t[43]=w,t[44]=o,t[45]=Ae,t[46]=fe,t[47]=T,t[48]=De,t[49]=Be):(De=t[48],Be=t[49]),l.useEffect(De,Be);const[we,ve]=l.useState(!1),Pe=l.useRef(null),he=l.useRef(null);let Fe;t[50]!==F||t[51]!==ue||t[52]!==e?(Fe=Oe=>{const me=ue.find(st=>st.id===Oe.active.id),je=Pe.current?.getBoundingClientRect().left;!me||je===void 0||(he.current?.cancel(),he.current=Xi({mode:me.mode,label:me.label??e($s(me.labelKey,F)),from:Zo(X.getState().contextSurfaceZones,me.mode)},st=>st.x<je-16))},t[50]=F,t[51]=ue,t[52]=e,t[53]=Fe):Fe=t[53];const _e=Fe;let We;t[54]===Symbol.for("react.memo_cache_sentinel")?(We=()=>{he.current?.cancel(),he.current=null},t[54]=We):We=t[54];const Xe=We;let Ve,S;t[55]===Symbol.for("react.memo_cache_sentinel")?(Ve=()=>()=>he.current?.cancel(),S=[],t[55]=Ve,t[56]=S):(Ve=t[55],S=t[56]),l.useEffect(Ve,S);let ne;t[57]!==o||t[58]!==U||t[59]!==f?(ne=Oe=>{const me=he.current;if(he.current=null,me?.finish(o))return;const{active:je,over:st}=Oe;if(!st||je.id===st.id)return;const ye=Yo(X.getState().contextRailOrder,U),ot=ct=>{const vt=ye.find(St=>St.id===ct);return vt?Ks(vt):null};if(ot(je.id)!==ot(st.id))return;const Ct=ye.map(H2),xt=Ct.indexOf(je.id),jt=Ct.indexOf(st.id);xt===-1||jt===-1||f(Db(Ct,xt,jt))},t[57]=o,t[58]=U,t[59]=f,t[60]=ne):ne=t[60];const q=ne;let ke;if(t[61]!==ue){ke=[];for(const Oe of ue){const me=ke.at(-1);me&&Ks(me[0])===Ks(Oe)?me.push(Oe):ke.push([Oe])}t[61]=ue,t[62]=ke}else ke=t[62];const Ee=ke;let Ie;t[63]!==ue?(Ie=Oe=>{const me=ue.find(st=>st.id===Oe.active.id);if(!me)return ti(Oe);const je=Ks(me);return ti({...Oe,droppableContainers:Oe.droppableContainers.filter(st=>{const ye=ue.find(ot=>ot.id===st.id);return ye!==void 0&&Ks(ye)===je})})},t[63]=ue,t[64]=Ie):Ie=t[64];const Ne=Ie;if(!o)return null;let ze,Ue,Ge,Qe,He,Ke,Ye,it,bt,nt;if(t[65]!==F||t[66]!==Se||t[67]!==ee||t[68]!==Ne||t[69]!==o||t[70]!==Ee||t[71]!==$||t[72]!==q||t[73]!==_e||t[74]!==p||t[75]!==oe||t[76]!==K||t[77]!==fe||t[78]!==e||t[79]!==u){let Oe=0;it=Pe,t[90]!==e?(bt=e("contextRail.aria.rail"),t[90]=e,t[91]=bt):bt=t[91],nt="flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",ze=dd,Ue=K,Ge=Ne,Qe=_e,He=Xe,Ke=q,Ye=Ee.map((me,je)=>s.jsxs(l.Fragment,{children:[je>0?s.jsx("div",{"aria-hidden":"true",className:"h-px w-4 shrink-0 bg-edge-strong"}):null,s.jsx(fd,{items:me.map(q2),strategy:Rb,children:me.map(st=>{Oe=Oe+1;const ye=st.label??e($s(st.labelKey,F)),ot=st.id==="git"&&!u?Se:0,Ct=Pn(st.mode)&&!fe.has(st.mode)?$[Fr(st.mode)]??0:0,xt=ot>0?ot:Ct>0?Ct:null,jt=xt!==null&&ot===0;return s.jsx(C2,{surface:st,isActive:fe.has(st.mode),showActivityDot:!1,label:ye,description:e($s(st.descriptionKey,F)),badgeCount:xt,badgeAriaLabel:xt!==null?e(jt?xt===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":xt===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:ye,count:xt}):null,badgeDescription:xt!==null?e(jt?xt===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":xt===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:xt}):null,orderNumber:Oe,showOrderNumber:oe,onSelect:ct=>{Pn(ct.mode)&&ee(Fr(ct.mode)),p(o,ct.mode)}},st.id)})})]},Ks(me[0]))),t[65]=F,t[66]=Se,t[67]=ee,t[68]=Ne,t[69]=o,t[70]=Ee,t[71]=$,t[72]=q,t[73]=_e,t[74]=p,t[75]=oe,t[76]=K,t[77]=fe,t[78]=e,t[79]=u,t[80]=ze,t[81]=Ue,t[82]=Ge,t[83]=Qe,t[84]=He,t[85]=Ke,t[86]=Ye,t[87]=it,t[88]=bt,t[89]=nt}else ze=t[80],Ue=t[81],Ge=t[82],Qe=t[83],He=t[84],Ke=t[85],Ye=t[86],it=t[87],bt=t[88],nt=t[89];let ft;t[92]!==ze||t[93]!==Ue||t[94]!==Ge||t[95]!==Qe||t[96]!==He||t[97]!==Ke||t[98]!==Ye?(ft=s.jsx(ze,{sensors:Ue,collisionDetection:Ge,onDragStart:Qe,onDragCancel:He,onDragEnd:Ke,children:Ye}),t[92]=ze,t[93]=Ue,t[94]=Ge,t[95]=Qe,t[96]=He,t[97]=Ke,t[98]=Ye,t[99]=ft):ft=t[99];let ae;t[100]!==e?(ae=e("contextRail.configure.open"),t[100]=e,t[101]=ae):ae=t[101];let de;t[102]===Symbol.for("react.memo_cache_sentinel")?(de=()=>ve(!0),t[102]=de):de=t[102];let be;t[103]===Symbol.for("react.memo_cache_sentinel")?(be=s.jsx(se,{name:"equalizer-2",className:"h-[17px] w-[17px]"}),t[103]=be):be=t[103];let C;t[104]!==ae?(C=s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":ae,onClick:de,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground",children:be})}),t[104]=ae,t[105]=C):C=t[105];let ce;t[106]!==e?(ce=e("contextRail.configure.open"),t[106]=e,t[107]=ce):ce=t[107];let L;t[108]!==ce?(L=s.jsx($t,{side:"left",sideOffset:8,children:ce}),t[108]=ce,t[109]=L):L=t[109];let ge;t[110]!==C||t[111]!==L?(ge=s.jsxs(Lt,{delayDuration:uu,children:[C,L]}),t[110]=C,t[111]=L,t[112]=ge):ge=t[112];let Ce;t[113]!==we?(Ce=s.jsx(g2,{open:we,onOpenChange:ve}),t[113]=we,t[114]=Ce):Ce=t[114];let Je;return t[115]!==it||t[116]!==bt||t[117]!==nt||t[118]!==ft||t[119]!==ge||t[120]!==Ce?(Je=s.jsxs("nav",{ref:it,"aria-label":bt,className:nt,children:[ft,ge,Ce]}),t[115]=it,t[116]=bt,t[117]=nt,t[118]=ft,t[119]=ge,t[120]=Ce,t[121]=Je):Je=t[121],Je};function E2(t){return t.shortcutOverrides}function I2(t){return t.workStatusPanelVisible}function P2(t){return t.contextRailOrder}function R2(t){return t.contextRailHiddenSurfaces}function D2(t){return t.setContextRailOrder}function A2(t){return t.openContextSurface}function _2(t){return t.closeContextZone}function O2(t){return t.contextSurfaceZones}function M2(t){return t.shortcutOverrides}function F2(t){return t.status?.status==="connected"}function L2(t){return Object.values(t.entries).some(F2)}function $2(t){return t.ensureStatus}function B2(t){return t.fetchStatus}function z2(t){return t.length===1&&t>="0"&&t<="9"}function W2(t){return t.countByGuest}function U2(t){return t.clearBadge}function V2(t){return t.mode==="pr"&&t.targetPath}function H2(t){return t.id}function q2(t){return t.id}const As=t=>t?s.jsx("span",{className:"oc-title-rest",children:t}):void 0,Ss=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},K2=()=>{const{t}=at(),{git:e,sourceControl:n}=Es(),[r,o]=l.useState(!1),[i,a]=l.useState(null),[u,c]=l.useState([]),[d,f]=l.useState(!1),[p,m]=l.useState(!1),[h,b]=l.useState(!1),[g,x]=l.useState(!1),[w,T]=l.useState(new Set),k=et(S=>S.getWorktreeMetadata),E=et(S=>S.newSessionDraft),F=et(S=>S.setNewSessionDraftTarget),_=et(S=>S.setDraftBootstrapPendingDirectory),A=hg,D=yg,y=et(S=>S.deleteSessions),N=et(S=>S.archiveSessions),j=et(S=>S.unarchiveSessions),v=X(S=>S.showDeletionDialog),M=X(S=>S.setShowDeletionDialog),W=ls(S=>S.currentDirectory),G=ls(S=>S.homeDirectory),O=ts(S=>S.projects),Z=ts(S=>S.activeProjectId),{isMobile:Q,isTablet:B,hasTouchInput:oe}=gn(),H=Q||B||oe,P=l.useMemo(()=>{const ne=(Z?O.find(q=>q.id===Z)??null:null)?.path??W;return Ss(ne)},[Z,W,O]),te=l.useCallback(S=>{const q=Ss(S.projectDirectory)||P;return{id:(O.find(Ee=>Ss(Ee.path)===q)??null)?.id??`path:${q}`,path:q}},[P,O]),J=g&&w.size>0,[le,K]=l.useState(!1),U=i?.mode==="worktree"?i.worktree??u[0]?.metadata??null:null,$=U?.path,ee=U?.branch,Y=U?te(U).path:null;l.useEffect(()=>{if(K(!1),!$||!Y)return;let S=!1;return mg(Y,{path:$,branch:ee??""}).then(ne=>{S||K(ne)}),()=>{S=!0}},[ee,$,Y]);const ie=l.useMemo(()=>{if(!le)return!1;const S=i?.worktree;return S&&typeof S.branch=="string"&&S.branch.trim().length>0?!!S.status?.upstream?.split("/")[0]?.trim():u.length>0&&u.every(({metadata:ne})=>typeof ne.branch=="string"&&ne.branch.trim().length>0&&!!ne.status?.upstream?.split("/")[0]?.trim())},[le,i?.worktree,u]),V=i?.mode==="worktree",fe=h||!V||!ie,Se=h||!V,Te=l.useCallback(S=>{a({sessions:S.sessions,dateLabel:S.dateLabel,mode:S.mode??"session",worktree:S.worktree??null})},[]),ue=l.useCallback(()=>{a(null),c([]),f(!1),m(!1),b(!1),x(!1),T(new Set)},[]),Me=l.useCallback(async S=>{if(S.sessions.length===0)return;if(S.sessions.length===1){const Ee=S.sessions[0];await A(Ee.id)?Re.success(t("sessions.sidebar.session.delete.success")):Re.error(t("sessions.sidebar.session.delete.error"));return}const ne=S.sessions.map(Ee=>Ee.id),{deletedIds:q,failedIds:ke}=await y(ne);if(q.length>0){const Ee=ke.length>0?ke.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:ke.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:ke.length}):S.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:S.dateLabel}):void 0;Re.success(q.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:q.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:q.length}),{description:As(Ee)})}ke.length>0&&Re.error(ke.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:ke.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:ke.length}),{description:As(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[A,y,t]);l.useEffect(()=>Wr.onDirectoryRequest(()=>{o(!0)}),[]),l.useEffect(()=>{if(!i){c([]),f(!1),m(!1),x(!1),T(new Set);return}const S=i.sessions.map(ke=>{const Ee=k(ke.id);return Ee?{session:ke,metadata:Ee}:null}).filter(ke=>!!ke);c(S),f(!1),x(!1),T(new Set);const ne=new Map;if(i.worktree?.path&&ne.set(Ss(i.worktree.path),i.worktree),S.forEach(({metadata:ke})=>{ke.path&&ne.set(Ss(ke.path),ke)}),ne.size===0){x(!0);return}let q=!1;return(async()=>{const ke=new Map,Ee=new Set;await Promise.all(Array.from(ne.entries()).map(async([Ie,Ne])=>{try{const ze=await Da(Ne.path);ke.set(Ie,ze),ze?.isDirty&&Ee.add(Ie)}catch{Ne.status&&(ke.set(Ie,Ne.status),Ne.status.isDirty&&Ee.add(Ie))}})).catch(Ie=>{console.warn("Failed to inspect worktree status before deletion:",Ie)}),!q&&(T(Ee),x(!0),a(Ie=>{if(!Ie?.worktree?.path)return Ie;const Ne=Ss(Ie.worktree.path),ze=ke.get(Ne);if(!ze)return Ie;const Ue=Ie.worktree.status;return Ue?.isDirty===ze.isDirty&&Ue?.ahead===ze.ahead&&Ue?.behind===ze.behind&&Ue?.upstream===ze.upstream?Ie:{...Ie,worktree:{...Ie.worktree,status:ze}}}),c(Ie=>Ie.map(Ne=>{const ze=Ss(Ne.metadata.path),Ue=ke.get(ze);return Ue?{session:Ne.session,metadata:{...Ne.metadata,status:Ue}}:Ne})))})(),()=>{q=!0}},[i,k]),l.useEffect(()=>{ie||f(!1)},[ie]);const Ae=l.useCallback(async(S,ne,q)=>{const ke=d&&ie,Ee=te(S),Ie=Ss(S.path),Ne=Ss(Ee.path);try{await gg(Ee,S,{deleteRemoteBranch:ke,deleteLocalBranch:ne,remoteName:S.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:n}});const ze=Ge=>!!(Ie&&Ge&&bg(Ie,Ge)),Ue=Ss(E?.directoryOverride);return E?.open&&ze(Ue)&&Ne&&(_(null),F({projectId:Ee.id,directoryOverride:Ne},{force:!0})),ze(Ss(W))&&Ne&&ls.getState().setDirectory(Ne,{showOverlay:!1}),!0}catch(ze){return Re.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:q,description:As(ze instanceof Error?ze.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[ie,W,d,te,e,E?.directoryOverride,E?.open,_,F,n,t]),De=l.useCallback((S,ne,q)=>{const ke=d&&ie,Ee=Re.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:Aa(S)}));return xg(S.path),(async()=>{try{const Ie=await wg({sessionIds:ne,removeWorktree:()=>Ae(S,q,Ee),restoreSessions:ze=>j(ze,{undo:!0}),archiveSessions:async ze=>ze.length===1?await D(ze[0])?{archivedIds:ze,failedIds:[]}:{archivedIds:[],failedIds:ze}:N(ze)});if(!Ie.removed)return;jc(ne,{projectId:te(S).id}),Re.success(t(ke?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed"),{id:Ee,description:As(Aa(S))});const{failedIds:Ne}=Ie.archive;Ne.length>0&&Re.error(Ne.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Ne.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:Ne.length}),{description:As(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(Ie){Re.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Ee,description:As(Ie instanceof Error?Ie.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}finally{vg(S.path)}})()},[D,N,ie,d,te,Ae,t,j]),Be=l.useRef(new Set),we=l.useCallback(async(S,ne)=>{const q=Ss(S.path);if(!Be.current.has(q)){Be.current.add(q);try{const ke=await Da(S.path).catch(()=>{});if(!Sg(ke)){Te({sessions:ne,mode:"worktree",worktree:S});return}await De(S,ne.map(Ee=>Ee.id),!0)}finally{Be.current.delete(q)}}},[Te,De]);l.useEffect(()=>Wr.onDeleteRequest(S=>{if(!v&&(S.mode??"session")==="session"){Me(S);return}if(S.mode==="worktree"&&S.skipDialogIfSafe&&S.worktree){we(S.worktree,S.sessions);return}Te(S)}),[Te,v,Me,we]);const ve=l.useCallback(async()=>{if(i){b(!0);try{if(V){const S=i.worktree??u[0]?.metadata;if(!S){Re.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:As(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),b(!1);return}De(S,i.sessions.map(ne=>ne.id),p&&le),ue();return}if(i.sessions.length===1){const S=i.sessions[0];if(!await A(S.id)){Re.error(t("sessions.sidebar.session.delete.error")),b(!1);return}Re.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const S=i.sessions.map(ke=>ke.id),{deletedIds:ne,failedIds:q}=await y(S);if(ne.length>0){const ke=q.length>0?q.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:q.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:q.length}):i.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:i.dateLabel}):void 0;Re.success(ne.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ne.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ne.length}),{description:As(ke),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(q.length>0&&(Re.error(q.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:q.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:q.length}),{description:As(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),ne.length===0)){b(!1);return}}ue()}finally{b(!1)}}},[le,i,u,p,A,y,ue,V,De,t]),Pe=i?.worktree??u[0]?.metadata??null;let he="";if(i?.mode==="worktree"){const S=i.sessions.length;S===0?he=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):S===1?he=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:S}):he=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:S})}else if(i){const S=i.sessions.length;S===1?he=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):he=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:S,dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:S})}const Fe=i?s.jsxs("div",{className:Le(V?"space-y-3":"space-y-2"),children:[i.sessions.length>0&&s.jsxs("div",{className:Le(V?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-edge-muted bg-sidebar/60 p-3"),children:[V&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:i.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:i.sessions.length})]}),s.jsxs("ul",{className:Le(V?"mt-2 space-y-1":"space-y-0.5"),children:[i.sessions.slice(0,5).map(S=>s.jsxs("li",{className:Le(V?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground"),children:[s.jsx("span",{className:Le(!V&&"hidden"),children:"•"}),s.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:S.title||t("sessions.sidebar.session.untitled")})]},S.id)),i.sessions.length>5&&s.jsx("li",{className:Le(V?"px-2.5 py-1 text-xs text-muted-foreground":"typography-micro text-muted-foreground"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:i.sessions.length-5})})]})]}),V?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(se,{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")}),Pe?.label?s.jsx("span",{className:"typography-micro text-muted-foreground",children:Pe.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground break-all",children:Pe?kg(Pe.path,G):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),J&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-edge-muted bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,_e=V&&le?ie?s.jsxs("button",{type:"button",onClick:()=>{fe||f(S=>!S)},disabled:fe,"aria-pressed":d,className:Le("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(se,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(se,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,We=V&&le?s.jsxs("button",{type:"button",onClick:()=>{Se||m(S=>!S)},disabled:Se,"aria-pressed":p,className:Le("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Se?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[p?s.jsx(se,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(se,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Xe=V?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:[We,_e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(dt,{variant:"ghost",onClick:ue,disabled:h,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{variant:"destructive",onClick:ve,disabled:h,children:t(h?"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:()=>M(!v),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":!v,children:[v?s.jsx(se,{name:"checkbox-blank",className:"size-4"}):s.jsx(se,{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:ue,disabled:h,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{variant:"destructive",onClick:ve,disabled:h,children:h?t("sessions.sidebar.sessionDialogs.actions.deleting"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),Ve=V?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[H?s.jsx(jg,{open:!!i,onClose:()=>{h||ue()},title:Ve,footer:s.jsx("div",{className:"flex justify-end gap-2",children:Xe}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[he&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:he}),Fe]})}):s.jsx(tr,{open:!!i,onOpenChange:S=>{if(!S){if(h)return;ue()}},children:s.jsxs(sr,{className:Le(V?"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(nr,{children:[s.jsxs(rr,{className:Le(V&&"flex items-center gap-2"),children:[V&&s.jsx(se,{name:"delete-bin",className:"h-5 w-5"}),Ve]}),he&&s.jsx(or,{children:he})]}),V?s.jsx(hs,{outerClassName:"flex-1 min-h-0",className:"space-y-2",disableHorizontal:!0,children:Fe}):s.jsx("div",{children:Fe}),s.jsx($r,{className:"mt-2 gap-2 pt-1 pb-1",children:Xe})]})}),s.jsx(Cg,{open:r,onOpenChange:o})]})},fu=[{pattern:/^dev(:.*)?$/i},{pattern:/^start$/i},{pattern:/^start:(?:dev|preview|serve)(?::.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],G2=/^(?:(?:dev(?:elopment)?|preview|serve)(?: server)?|(?:start|run)\s+(?:dev(?:elopment)?\s+)?(?:server|preview))(?:\s+\([^)]+\))?$/i,Z2=/^(?:cd\s+(?:"[^"]+"|'[^']+'|[^\s;&|]+)\s*&&\s*)?(?:npm|yarn|pnpm|bun)\s+(?:run\s+)?(?:--shell=bun\s+)?([^\s;&|]+)(?:\s|$)/i,X2=t=>fu.some(({pattern:e})=>e.test(t));async function Y2(t,e,n){if(!t)return null;const r=ek(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const o=tk(n);if(o){const i=await sk(t);return{command:`${i==="npm"?"npm run":i==="yarn"?"yarn":i==="pnpm"?"pnpm":i==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await J2(t)){const o=await Q2(),i=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${i}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${i}/`}}return null}async function J2(t){const e=`${t}/index.html`,n=await Zr(e,t);return typeof n=="string"&&n.trim().length>0}async function Q2(){try{const t=await zs("/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 ek(t){for(const e of t){const n=Z2.exec(e.command.trim())?.[1];if(n&&X2(n)||e.source!=="shared"&&G2.test(e.name.trim()))return e}return null}function tk(t){for(const{pattern:e}of fu)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function sk(t){const e=await Zr(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.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,o]of n){const i=await Zr(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function Zr(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await zs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const n=Ql()?.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 zs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function nk(t){try{const e=await Zr(`${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 rk=/\{(worktree|branch)\}/g,Ho=63,ok=new Set(["main","master"]),pu=t=>/\{(worktree|branch)\}/.test(t??""),ik=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const n=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},mu=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=Ho)return e;const n=await ik(e);return n?`${e.slice(0,Ho-7).replace(/-+$/,"")}-${n}`:e.slice(0,Ho).replace(/-+$/,"")},ak=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},lk=async(t,e,n)=>{const r=n.includes("{branch}"),o=n.includes("{worktree}")?await t.isLinkedWorktree(e):!1;if(!r&&!o)return{branch:null,linkedWorktree:o};const i=await t.getGitStatus(e,{mode:"light"});return{branch:ak(i.current),linkedWorktree:o}},ck=async t=>!t.linkedWorktree||!t.branch||ok.has(t.branch)?"":mu(t.branch.split("/").pop()??""),dk=t=>{const e=t.lastIndexOf("@"),n=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const o=r.lastIndexOf(":"),i=o>=0?r.slice(0,o):r,a=o>=0?r.slice(o):"",u=i.split(".").map(c=>c.replace(/^-+|-+$/g,"")).filter(Boolean);return`${n}${u.join(".")}${a}`},uk=async(t,e)=>{const n={worktree:await ck(e),branch:e.branch?await mu(e.branch):""},r=t.replace(rk,(c,d)=>n[d]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,i="",a="",u=""]=o;return`${i}${dk(a)}${u}`},fk=async(t,e,n)=>pu(e)?uk(e,await lk(t,n,e)):e,hu="oc.projectActions.selectedAction.v1",pk=ni(Ns(),ni(Ns(),Ns())),gu=()=>{const t=to().getItem(hu);if(t===null)return{};try{const e=pk.safeParse(JSON.parse(t));return e.success?e.data:{}}catch{return{}}},Pl=(t,e=ns())=>gu()[e]?.[t]??null,mk=(t,e,n=ns())=>{const r=gu();r[n]?.[t]!==e&&to().setItem(hu,JSON.stringify({...r,[n]:{...r[n],[t]:e}}))},hk=15e3,gk=3e3,bk=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}},xk=({projectRef:t,directory:e,allowMobile:n=!1})=>{const{t:r}=at(),{currentTheme:o}=so(),{terminal:i,runtime:a,git:u}=Es(),c=Vs(),{isMobile:d}=gn(),f=l.useMemo(()=>Bs(),[]),p=va(C=>C.instances),m=va(C=>C.load),h=X(C=>C.terminalShell),b=X(C=>C.terminalLoginShells.includes(C.terminalShell)),g=X(C=>C.setSettingsPage),x=X(C=>C.setSettingsDialogOpen),w=X(C=>C.setSettingsProjectsSelectedId),T=X(C=>C.openContextPreview),k=wt(C=>C.ensureDirectory),E=wt(C=>C.reconcileServerSessions),F=wt(C=>C.setTabLabel),_=wt(C=>C.setTabIconKey),A=wt(C=>C.setActiveTab),D=wt(C=>C.setConnecting),y=wt(C=>C.setTabSessionId),N=wt(C=>C.setTabPurpose),j=wt(C=>C.allocateActionExecution),v=wt(C=>C.setTabLifecycle),M=wt(C=>C.setTabPreviewUrl),W=wt(C=>C.matchesActionExecution),G=wt(C=>C.captureStartedActionMutationRevisions),[O,Z]=l.useState([]),Q=l.useRef(null),[B,oe]=l.useState(()=>t?.id?Pl(t.id):null),[H,P]=l.useState(!1),te=l.useRef({}),J=l.useRef({}),le=l.useRef({}),K=l.useRef(new Set),U=l.useRef(0),[$,ee]=l.useState({}),Y=t?.id??null,ie=t?.path??"";l.useEffect(()=>{oe(Y?Pl(Y):null)},[Y]);const V=l.useMemo(()=>Y?{id:Y,path:ie}:null,[Y,ie]);l.useEffect(()=>{f&&m().catch(()=>{})},[f,m]);const fe=l.useCallback(async C=>{await On(C)},[]),Se=l.useCallback(async()=>{if(!V)return;const C=U.current+1;U.current=C,P(!0);try{const ce=await Ro(V);if(U.current!==C)return;Q.current=ce;const L=ce.projectActions;Z(L)}catch{if(U.current!==C)return}finally{U.current===C&&P(!1)}},[V]),Te=l.useMemo(()=>No(e||V?.path||""),[e,V?.path]),ue=l.useMemo(()=>No(V?.path||""),[V?.path]),Me=l.useMemo(()=>No(c||"")||Te,[c,Te]),Ae=l.useRef(Me);l.useEffect(()=>{Ae.current=Me},[Me]);const De=wt(C=>Te?C.getDirectoryState(Te):void 0),Be=wt(C=>ue&&ue!==Te?C.getDirectoryState(ue):void 0),we=l.useMemo(()=>{const C=Te?[{directory:Te,state:De}]:[];return ue&&ue!==Te&&C.push({directory:ue,state:Be}),C},[De,Te,ue,Be]),ve=l.useMemo(()=>{const C=Te?[Te]:[];return ue&&ue!==Te&&C.push(ue),C},[Te,ue]),Pe=l.useCallback(C=>C.id!==sn&&C.runIn==="parent"&&ue||Te,[Te,ue]),he=l.useCallback((C,ce,L)=>`${C}::${ce}::${L}`,[]),Fe=l.useCallback((C,ce,L=wt.getState())=>C?L.getDirectoryState(C)?.tabs.find(ge=>ge.purpose.type==="project-action"&&ge.purpose.actionId===ce)??null:null,[]),_e=l.useMemo(()=>{const C={};for(const{directory:ce,state:L}of we)for(const ge of L?.tabs??[]){if(ge.purpose.type!=="project-action"||!ge.purpose.executionId||!ge.terminalSessionId||ge.lifecycle==="idle"||ge.lifecycle==="exited")continue;const Ce=wn(ce,ge.purpose.actionId),Je=he(ce,ge.purpose.actionId,ge.purpose.executionId);C[Ce]={directory:ce,actionId:ge.purpose.actionId,tabId:ge.id,sessionId:ge.terminalSessionId,executionId:ge.purpose.executionId,status:ge.lifecycle==="stopping"?"stopping":$[Je]?"waiting-for-preview":"running"}}return C},[he,$,we]),We=l.useCallback((C,ce,L)=>{const ge=wn(C,ce),Ce=he(C,ce,L),Oe=te.current[ge]?.executionId===L,me=globalThis.window,je=st=>{me?.clearTimeout(le.current[st]),delete le.current[st]};Oe&&(delete te.current[ge],je(ge)),J.current[Ce]?.(),delete J.current[Ce],je(Ce),ee(st=>{if(!st[Ce])return st;const ye={...st};return delete ye[Ce],ye})},[he]),Xe=l.useCallback(C=>{J.current[C]?.(),delete J.current[C]},[]),Ve=l.useCallback(C=>{window.clearTimeout(le.current[C]),delete le.current[C]},[]);l.useEffect(()=>{const C=J.current,ce=le.current;return()=>{for(const L of Object.keys(C))Xe(L);for(const L of Object.keys(ce))Ve(L)}},[Ve,Xe]),l.useEffect(()=>{const C=new Set(ve);for(const ce of Object.values(te.current))C.has(ce.directory)||We(ce.directory,ce.actionId,ce.executionId);for(const ce of Object.keys(J.current)){const L=ce.split("::",1)[0]??"";C.has(L)||Xe(ce)}},[We,Xe,ve]);const S=l.useCallback((C,ce)=>{X.getState().openContextPanelTab(C,{mode:"terminal",targetDirectory:ce===C?null:ce})},[]),ne=l.useMemo(()=>({id:sn,name:r("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[r]),q=!d,ke=l.useMemo(()=>q?[...O,ne]:O,[O,ne,q]),Ee=l.useMemo(()=>B?ke.find(C=>C.id===B)??null:null,[ke,B]);l.useEffect(()=>{Se()},[Se]);const[Ie,Ne]=l.useState(0),ze=l.useCallback(()=>(Ne(C=>C+1),()=>Ne(C=>C-1)),[]),Ue=Ie>0;l.useEffect(()=>{if(!Ue)return;const C=ve.map(ce=>Kf(i,ce,G,L=>E(ce,L.sessions,{startedActionMutationRevisions:L.startedActionMutationRevisions})));return()=>{for(const ce of C)ce()}},[G,Ue,E,i,ve]),l.useEffect(()=>{for(const{directory:C,state:ce}of we)if(C)for(const L of ce?.tabs??[]){if(L.purpose.type!=="project-action")continue;const ge=L.purpose.actionId,Ce=ke.find(me=>me.id===ge),Je=Ce?.name??ge,Oe=Ce?.icon||"play";L.label!==Je&&F(C,L.id,Je),L.iconKey!==Oe&&_(C,L.id,Oe)}},[ke,_,F,we]),l.useEffect(()=>{const C=globalThis.window;if(!C)return;const ce=L=>{const ge=L.detail;Y&&(ge?.projectId&&ge.projectId!==Y||Se())};return C.addEventListener(Sa,ce),()=>{C.removeEventListener(Sa,ce)}},[Se,Y]),l.useEffect(()=>{const C=L=>{delete le.current[L];const ge=te.current[L];if(!ge||ge.openedUrl)return;const Ce=he(ge.directory,ge.actionId,ge.executionId),Je=ge.announced;if(Je.length!==0){if(window.clearTimeout(le.current[Ce]),delete le.current[Ce],ge.openedUrl=!0,ee(Oe=>{if(!Oe[Ce])return Oe;const me={...Oe};return delete me[Ce],me}),Je.length===1){Wo(ge.directory,[]),M(ge.directory,ge.tabId,Je[0],{locked:!1,autoOpened:!0}),T(ge.directory,Je[0]);return}ge.offering=!0,Wo(ge.directory,Je),X.getState().openContextSurface(ge.directory,"browser"),Re.info(r("projectActions.toast.multipleServers"))}},ce=()=>{const L=wt.getState(),ge=L.sessions,Ce=_e;for(const[Je,Oe]of Object.entries(Ce)){const je=ge.get(Oe.directory)?.tabs.find(mt=>mt.id===Oe.tabId);if(!je||je.terminalSessionId!==Oe.sessionId){We(Oe.directory,Oe.actionId,Oe.executionId);continue}const st=te.current[Je],ye=st?.executionId===Oe.executionId?st:{hostDirectory:Ae.current||Oe.directory,directory:Oe.directory,tabId:Oe.tabId,actionId:Oe.actionId,executionId:Oe.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};te.current[Je]=ye;const ot=ke.find(mt=>mt.id===Oe.actionId),Ct=L.getBuffer(Oe.directory,Oe.tabId).chunks;if(!ot||Ct.length===0)continue;const xt=Ct.filter(mt=>ye.lastSeenChunkId===null||mt.id>ye.lastSeenChunkId);if(xt.length===0)continue;const jt=xt.map(mt=>mt.data).join(""),ct=`${ye.tail}${jt}`;for(const mt of Qf(ct))ye.proxiedPorts.includes(mt)||ye.proxiedPorts.push(mt);if(ye.openInPreview&&(!ye.openedUrl||ye.offering)){const mt=ep(ct,{proxiedPorts:ye.proxiedPorts,namedAddressesReachable:!ka()}),yt=ye.announced.length;for(const Nt of mt)ye.announced.includes(Nt)||ye.announced.push(Nt);const lt=ye.announced.length-yt;ye.offering&&lt>0?Wo(Oe.directory,ye.announced):!ye.openedUrl&&yt===0&&ye.announced.length>0&&(window.clearTimeout(le.current[Je]),le.current[Je]=window.setTimeout(()=>C(Je),gk))}const vt=!ye.openedUrl&&ot.autoOpenUrl===!0&&!ye.openInPreview?tp(ct,{proxiedPorts:ye.proxiedPorts,namedAddressesReachable:!ka()}):null,St=xt[xt.length-1]?.id??ye.lastSeenChunkId;if(ye.lastSeenChunkId=St,ye.tail=ct.slice(-512),vt)if(ye.openedUrl=!0,ye.openInPreview){const mt=Ce[Je];mt&&(M(mt.directory,mt.tabId,vt,{locked:!1,autoOpened:!1,expectedExecutionId:mt.executionId}),mt.status==="waiting-for-preview"&&ee(yt=>{const lt=he(mt.directory,mt.actionId,mt.executionId);if(!yt[lt])return yt;const Nt={...yt};return delete Nt[lt],Nt}),window.clearTimeout(le.current[Je]),delete le.current[Je],T(mt.directory,vt))}else fe(vt),Re.success(r("projectActions.toast.openedUrlFromOutput"));te.current[Je]=ye}for(const Je of Object.keys(te.current))if(!Ce[Je]){const Oe=te.current[Je],me=Oe?ge.get(Oe.directory)?.tabs.find(st=>st.id===Oe.tabId):void 0;if(me?.purpose.type==="project-action"&&me.purpose.executionId===Oe?.executionId&&!!me.terminalSessionId&&me.lifecycle!=="idle"&&me.lifecycle!=="exited")continue;delete te.current[Je],window.clearTimeout(le.current[Je]),delete le.current[Je]}};return ce(),wt.subscribe((L,ge)=>{(L.sessions!==ge.sessions||L.buffers!==ge.buffers)&&ce()})},[We,Ae,ke,he,T,fe,_e,M,r]),l.useEffect(()=>{for(const{directory:C,state:ce}of we)for(const L of ce?.tabs??[]){if(L.purpose.type!=="project-action"||!L.purpose.executionId||!L.terminalSessionId||L.lifecycle!=="running")continue;const ge=L.purpose.actionId,Ce=L.purpose.executionId,Je=he(C,ge,Ce);if(J.current[Je])continue;const Oe=i.connect(L.terminalSessionId,{onEvent:me=>{if(!W(C,L.id,Ce))return;me.type==="snapshot"&&(wt.getState().replaceBuffer(C,L.id,me.data??"",me.sequence??0,ia(me)),me.status==="running"&&wt.getState().setTabLifecycle(C,L.id,"running",{expectedExecutionId:Ce}),me.status==="exited"&&(wt.getState().setTabLifecycle(C,L.id,"exited",{expectedExecutionId:Ce}),wt.getState().setTabPurpose(C,L.id,{type:"project-action",actionId:ge,executionId:null}),We(C,ge,Ce)));const je=me.type==="data"?me.data??"":"";je&&wt.getState().appendToBuffer(C,L.id,je,me.sequence,me.replayData),me.type==="exit"&&(wt.getState().setTabLifecycle(C,L.id,"exited",{expectedExecutionId:Ce}),wt.getState().setTabPurpose(C,L.id,{type:"project-action",actionId:ge,executionId:null}),We(C,ge,Ce))},onError:(me,je)=>{!je||!W(C,L.id,Ce)||(wt.getState().setTabLifecycle(C,L.id,"exited",{expectedExecutionId:Ce}),wt.getState().setTabSessionId(C,L.id,null,{expectedExecutionId:Ce}),wt.getState().setTabPurpose(C,L.id,{type:"project-action",actionId:ge,executionId:null}),We(C,ge,Ce))}},C);J.current[Je]=Oe.close}},[We,he,W,i,we]);const Ge=l.useCallback(async C=>{const ce=Pe(C);if(!ce)throw new Error(r("projectActions.error.noActiveDirectory"));const L=wn(ce,C.id);k(ce);const ge=wt.getState(),Ce=Fe(ce,C.id,ge),Je=Ce?.id??ge.createTab(ce);F(ce,Je,C.name),_(ce,Je,C.icon||"play"),Ce||N(ce,Je,{type:"project-action",actionId:C.id,executionId:null}),A(ce,Je);const me=wt.getState().getDirectoryState(ce)?.tabs.find(je=>je.id===Je);return{executionDirectory:ce,key:L,tabId:Je,sessionId:me?.terminalSessionId??null,executionId:me?.purpose.type==="project-action"?me.purpose.executionId:null}},[k,Pe,Fe,A,_,F,N,r]),Qe=l.useCallback(async C=>{if(a.isVSCode||!n&&d)return;if(!Te){Re.error(r("projectActions.error.noActiveDirectoryForAction"));return}const ce=wn(Pe(C),C.id),L=_e[ce];if(L&&L.status==="running"||K.current.has(ce))return;K.current.add(ce);let ge=null;try{const Ce=C.id===sn?await(async()=>{const ht=V??{id:"",path:Te},[gt,Dt]=await Promise.all([Ro(ht),nk(Te)]),Kt=await Y2(Te,gt.projectActions,Dt);if(!Kt)throw new Error(r("contextPanel.preview.noDevServer"));return gt.projectActions.find(js=>js.id===Kt.actionId)?.source==="shared"&&!await _a(ht,gt)?null:{id:sn,name:r("projectActions.actions.autoDiscover"),command:Kt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Kt.previewUrlHint||""}})():C;if(!Ce)return;const Je=Ce.autoOpenUrl===!0&&(Ce.openUrl||"").trim().length>0,Oe=!Je&&C.id!==sn,me=Ae.current||Te,{executionDirectory:je,key:st,tabId:ye}=await Ge(Ce),ot=Gf(Ce.command);if(!ot)throw new Error(r("projectActions.error.failedToRunAction"));const Ct=Ce.autoOpenUrl===!0&&f&&(Ce.desktopOpenSshForward||"").trim().length>0,xt=Ce.autoOpenUrl&&Ce.openUrl||"";let jt=!1;const ct=pu(xt)?await fk(u,xt,je).catch(()=>(jt=!0,"")):xt,vt=Ce.autoOpenUrl?bk(ct):null,St=Ce.autoOpenUrl&&f?Zf(Ce.desktopOpenSshForward,p):null;if(i.listSessions){const ht=Fe(je,Ce.id);if(ht?.purpose.type==="project-action"&&ht.purpose.executionId===null){const gt=await Xf(i,je,{captureStartedActionMutationRevisions:G});gt&&E(je,gt.sessions,{startedActionMutationRevisions:gt.startedActionMutationRevisions})}}const mt=Fe(je,Ce.id);let yt,lt;if(mt?.lifecycle==="running"&&mt.terminalSessionId&&mt.purpose.type==="project-action"&&mt.purpose.executionId)yt=mt.terminalSessionId,lt=mt.purpose.executionId;else{const ht=mt?.purpose.type==="project-action"?mt.purpose.executionId:null;ht&&We(je,Ce.id,ht);const gt=j(je,ye,Ce.id);if(!gt)throw new Error(r("projectActions.error.failedToCreateTerminalSession"));ge={directory:je,tabId:ye,id:gt},D(je,ye,!0,{expectedExecutionId:gt});const Dt=await Yf({terminal:i,createOptions:{cwd:je,shell:h,loginShell:b,themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground},command:ot,isRunStillExpected:()=>W(je,ye,gt),purpose:{type:"project-action",actionId:Ce.id,executionId:gt}});if(!W(je,ye,gt)){Dt.sessionId===gt&&await i.close(Dt.sessionId).catch(()=>{});return}lt=Dt.purpose?.type==="project-action"?Dt.purpose.executionId:gt,yt=Dt.sessionId,N(je,ye,{type:"project-action",actionId:Ce.id,executionId:lt}),y(je,ye,yt,{expectedExecutionId:lt}),D(je,ye,!1,{expectedExecutionId:lt})}Oe&&me&&S(me,je),te.current[st]={hostDirectory:me,directory:je,tabId:ye,actionId:Ce.id,executionId:lt,lastSeenChunkId:null,openedUrl:!!St||!!vt||Je,tail:"",openInPreview:Ce.id===sn,announced:[],offering:!1,proxiedPorts:[]};const Nt=he(je,Ce.id,lt);D(je,ye,!0,{expectedExecutionId:lt});const _t=i.connect(yt,{onEvent:ht=>{if(!W(je,ye,lt)||ht.purpose?.type==="project-action"&&ht.purpose.executionId!==lt)return;ht.type==="snapshot"&&(wt.getState().replaceBuffer(je,ye,ht.data??"",ht.sequence??0,ia(ht)),wt.getState().setConnecting(je,ye,!1,{expectedExecutionId:lt}),ht.purpose?.type==="project-action"&&wt.getState().setTabPurpose(je,ye,{type:"project-action",actionId:ht.purpose.actionId,executionId:ht.purpose.executionId}),ht.status==="running"&&wt.getState().setTabLifecycle(je,ye,"running",{expectedExecutionId:lt}),ht.status==="exited"&&(wt.getState().setTabLifecycle(je,ye,"exited",{expectedExecutionId:lt}),wt.getState().setTabPurpose(je,ye,{type:"project-action",actionId:Ce.id,executionId:null}),We(je,Ce.id,lt)));const gt=ht.type==="data"?ht.data??"":"";gt&&wt.getState().appendToBuffer(je,ye,gt,ht.sequence,ht.replayData),ht.type==="exit"&&(wt.getState().setTabLifecycle(je,ye,"exited",{expectedExecutionId:lt}),wt.getState().setConnecting(je,ye,!1,{expectedExecutionId:lt}),wt.getState().setTabPurpose(je,ye,{type:"project-action",actionId:Ce.id,executionId:null}),We(je,Ce.id,lt))},onError:(ht,gt)=>{W(je,ye,lt)&&(wt.getState().setConnecting(je,ye,!1,{expectedExecutionId:lt}),gt&&(wt.getState().setTabLifecycle(je,ye,"exited",{expectedExecutionId:lt}),wt.getState().setTabSessionId(je,ye,null,{expectedExecutionId:lt}),wt.getState().setTabPurpose(je,ye,{type:"project-action",actionId:Ce.id,executionId:null}),We(je,Ce.id,lt)))}},je);if(!W(je,ye,lt)){_t.close();return}J.current[Nt]?.(),J.current[Nt]=_t.close,window.clearTimeout(le.current[Nt]),delete le.current[Nt],Ce.id===sn&&!vt&&(ee(ht=>({...ht,[Nt]:!0})),le.current[Nt]=window.setTimeout(()=>{delete le.current[Nt];const ht=te.current[st];!ht||ht.executionId!==lt||ht.openedUrl||ht.offering||W(je,ye,lt)&&(ee(gt=>{if(!gt[Nt])return gt;const Dt={...gt};return delete Dt[Nt],Dt}),wt.getState().setActiveTab(je,ye),S(ht.hostDirectory,je))},hk)),St?(M(je,ye,null,{locked:!0,expectedExecutionId:lt}),fe(St),Re.success(r("projectActions.toast.openedForwardedUrl"))):vt?(M(je,ye,vt,{locked:!0,autoOpened:!0,expectedExecutionId:lt}),T(me,vt),Re.success(r("projectActions.toast.openedActionUrl"))):jt?(M(je,ye,null,{locked:!0,expectedExecutionId:lt}),Re.error(r("projectActions.error.openUrlTemplateUnresolved"))):Je?(M(je,ye,null,{locked:!0,expectedExecutionId:lt}),Re.error(r("projectActions.error.invalidCustomUrlFormat"))):Ct?(M(je,ye,null,{locked:!0,expectedExecutionId:lt}),Re.error(r("projectActions.error.selectedDesktopSshForwardUnavailable"))):M(je,ye,null,{locked:!1,autoOpened:!1,expectedExecutionId:lt})}catch(Ce){if(ge&&W(ge.directory,ge.tabId,ge.id)){const{directory:Je,tabId:Oe,id:me}=ge;We(Je,C.id,me),v(Je,Oe,"exited",{expectedExecutionId:me}),N(Je,Oe,{type:"project-action",actionId:C.id,executionId:null})}if(Ce instanceof Error&&Ce.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(Ce instanceof Error&&(Ce.message==="COMMAND_MODE_UNSUPPORTED"||Ce.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Re.error(r("projectActions.error.failedToCreateTerminalSession"));return}Re.error(Ce instanceof Error?Ce.message:r("projectActions.error.failedToRunAction"))}finally{K.current.delete(ce)}},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,Ae,p,Ge,u,n,d,f,Te,b,h,fe,T,_e,S,a.isVSCode,Pe,W,We,he,Fe,E,j,G,D,v,N,M,y,V,r,i]),He=l.useCallback(async C=>{const ce=wn(Pe(C),C.id),L=_e[ce];L&&await Jf({terminal:i,sessionId:L.sessionId,isExecutionStillCurrent:()=>W(L.directory,L.tabId,L.executionId),markStopping:()=>{v(L.directory,L.tabId,"stopping",{expectedExecutionId:L.executionId})},restoreRunning:()=>{v(L.directory,L.tabId,"running",{expectedExecutionId:L.executionId})},clearSession:()=>{y(L.directory,L.tabId,null,{expectedExecutionId:L.executionId})},finalizeExit:()=>{v(L.directory,L.tabId,"exited",{expectedExecutionId:L.executionId}),N(L.directory,L.tabId,{type:"project-action",actionId:L.actionId,executionId:null}),We(L.directory,L.actionId,L.executionId)}})},[We,Pe,W,_e,v,N,y,i]),Ke=l.useCallback(async C=>{if(C.source==="shared"&&V){const ce=Q.current?.trust.trusted?Q.current:await Ro(V);if(Q.current=ce,!await _a(V,ce))return;Q.current={...ce,trust:{...ce.trust,trusted:!0}}}await Qe(C)},[Qe,V]),Ye=l.useCallback(C=>_e[wn(Pe(C),C.id)]??null,[Pe,_e]),it=(Ee&&Ye(Ee)?Ee:null)??ke.find(C=>Ye(C)!==null)??Ee??ke[0]??null,bt=l.useCallback(C=>{const ce=Ye(C);if(ce?.status!=="stopping"){if(ce){He(C);return}Ke(C)}},[Ke,Ye,He]),nt=l.useCallback(C=>{Ke(C)},[Ke]),ft=l.useCallback(C=>{He(C)},[He]),ae=l.useCallback(C=>{oe(C.id),Y&&mk(Y,C.id)},[Y]),de=l.useCallback(()=>{V?.id&&(w(V.id),g("projects"),x(!0))},[x,g,w,V?.id]),be=!a.isVSCode&&(n||!d)&&!!V&&!!Te;return l.useMemo(()=>({available:be,actions:be?ke:[],shown:be?it:null,isLoading:H,observe:ze,runOf:Ye,select:ae,run:nt,stop:ft,toggle:bt,openSettings:de}),[be,ke,H,ze,de,nt,Ye,ae,it,ft,bt])},wk=t=>{const e=$e.c(6);let n,r;e[0]!==t?({children:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const o=xk(r);let i;return e[3]!==n||e[4]!==o?(i=s.jsx(xd.Provider,{value:o,children:n}),e[3]=n,e[4]=o,e[5]=i):i=e[5],i},yk=t=>{const e=$e.c(4),{children:n}=t,r=yd(),o=mr(),i=o?.kind==="preparing"?null:r?.projectRef??null,a=o?.kind==="ready"?o.directory:r?.directory??"";let u;return e[0]!==n||e[1]!==a||e[2]!==i?(u=s.jsx(wk,{projectRef:i,directory:a,children:n}),e[0]=n,e[1]=a,e[2]=i,e[3]=u):u=e[3],u};function vk(t){const e=[],n=(r,o)=>{const i=Xt(r);!i||e.some(a=>a.directory===i)||e.push({directory:i,priority:"selected",reason:o})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const Sk=new Map,kk=[],jk=t=>{const e=$e.c(20),{isVSCode:n}=t,r=Uc(),o=ts(Ck),i=ls(Tk),a=et(Nk);let u;e[0]!==n?(u=A=>n?Sk:A.availableWorktreesByProject,e[0]=n,e[1]=u):u=e[1];const c=et(u),d=!n;let f;e[2]!==c||e[3]!==o||e[4]!==d?(f=sp(o,c,{includeWorktrees:d}),e[2]=c,e[3]=o,e[4]=d,e[5]=f):f=e[5];const p=f,m=ps(Ek),h=`session-list-sync:${l.useId()}`;let b,g;e[6]!==h||e[7]!==r||e[8]!==i||e[9]!==a?(b=()=>(r.setBootstrapDemand(h,vk({currentDirectory:i,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(h)),g=[h,r,i,a],e[6]=h,e[7]=r,e[8]=i,e[9]=a,e[10]=b,e[11]=g):(b=e[10],g=e[11]),l.useEffect(b,g);const x=l.useRef(null);let w,T;e[12]!==n||e[13]!==p?(w=()=>{const A=new Set(p),D=x.current;x.current=A;const y=D?[...A].filter(N=>!D.has(N)):n?[...A]:[];y.length&&Zc(y,Jo())},T=[n,p],e[12]=n,e[13]=p,e[14]=w,e[15]=T):(w=e[14],T=e[15]),l.useEffect(w,T);let k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[16]=k):k=e[16],l.useEffect(Ik,k);const E=m!=null,F=m??kk;let _;e[17]!==F||e[18]!==E?(_={enabled:!0,hasAuthoritativeGlobalSessions:E,sessions:F},e[17]=F,e[18]=E,e[19]=_):_=e[19],np(_)};function Ck(t){return t.projects}function Tk(t){return t.currentDirectory}function Nk(t){return t.currentSessionDirectory}function Ek(t){return t.authoritativeSessions}function Ik(){let t=null,e=!1;const n=new Set,r=Js(o=>{if(o.type==="scheduled-task-ran")e=!0;else if(o.type==="session-created")n.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),Tg(Jo());return}const i=[...n];n.clear(),i.length&&Zc(i,Jo())},500)});return()=>{t&&clearTimeout(t),r()}}const Pk=()=>Ot(()=>import("./SettingsWindow-BHUNfQBn.js"),__vite__mapDeps([231,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,232,181,182,183,233,234,216,217,218,219,226,201,188,189,202,235,236,225,211,237,238,239])).then(t=>t.SettingsWindow),Rk=()=>Ot(()=>import("./CommandPalette-DjCVXkJM.js"),__vite__mapDeps([240,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,237,181,182,183,206,205])).then(t=>t.CommandPalette),Dk=()=>Ot(()=>import("./HelpDialog-DlCrl3jK.js"),__vite__mapDeps([241,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>t.HelpDialog),Ak=()=>Ot(()=>import("./ProjectActionsDialog-B90g1jby.js"),__vite__mapDeps([242,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,205,206])).then(t=>t.ProjectActionsDialog),_k=()=>Ot(()=>import("./OpenCodeStatusDialog-e8gdYqEY.js"),__vite__mapDeps([243,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>t.OpenCodeStatusDialog),Ok=()=>Ot(()=>import("./RunOverview-CGv4KD-i.js"),__vite__mapDeps([244,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183])).then(t=>t.RunOverview),Mk=()=>Ot(()=>import("./ScheduledTasksDialog-XjiWbQnf.js"),__vite__mapDeps([245,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,229,246,247,248])).then(t=>t.ScheduledTasksDialog),Fk=()=>Ot(()=>import("./ArchiveView-SQdNDg7X.js"),__vite__mapDeps([249,1,2,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,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,250])).then(t=>t.ArchiveView),Lk=()=>Ot(()=>import("./IntegrationsCatalogView-tZTRIaCg.js"),__vite__mapDeps([251,1,2,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,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,233])).then(t=>t.IntegrationsCatalogView),$k=()=>Ot(()=>import("./UsageStatsView-WPrhgORf.js"),__vite__mapDeps([252,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>t.UsageStatsView),Bk=()=>Ot(()=>import("./SourceBoardView-Cc3LeYUo.js"),__vite__mapDeps([253,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183])).then(t=>t.SourceBoardView),zk=()=>Ot(()=>import("./OverviewView-Cf5_Harr.js"),__vite__mapDeps([254,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183])).then(t=>t.OverviewView),Wk=()=>Ot(()=>import("./WorktreesView-BFut-2yK.js"),__vite__mapDeps([255,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,250])).then(t=>t.WorktreesView),Uk=()=>Ot(()=>import("./SpacesView-BZhH9crf.js"),__vite__mapDeps([256,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,238,181,182,183])).then(t=>t.SpacesView),Vk=()=>Ot(()=>import("./SpaceAccessDialog-f_DzFvFs.js"),__vite__mapDeps([257,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,258])).then(t=>t.SpaceAccessDialog),Hk=()=>Ot(()=>import("./SpaceApplyDialog-CddUu8PS.js"),__vite__mapDeps([259,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,182])).then(t=>t.SpaceApplyDialog),qk=()=>Ot(()=>import("./SpaceSetupOutput-BzQQtLdO.js"),__vite__mapDeps([260,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,258])).then(t=>t.SpaceSetupOutputDialog),_s=()=>X.getState().closeMainSurfaces(),ss=t=>{const e=$e.c(2),{needed:n,load:r,onFailure:o}=t,i=fo(n,r,o);let a;return e[0]!==i?(a=i?s.jsx(i,{}):null,e[0]=i,e[1]=a):a=e[1],a},bu=l.memo(t=>{const e=$e.c(11),{isMobile:n}=t,r=X(Gk),o=!r&&!n,i=io();let a;e[0]!==o||e[1]!==i?(a={enabled:o,layoutAnimationMs:i},e[0]=o,e[1]=i,e[2]=a):a=e[2];const u=jx(a);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(xx,{}),e[3]=c):c=e[3];const d=r||u.state!==!1;let f;e[4]!==d?(f=s.jsx(rp,{isVisible:d}),e[4]=d,e[5]=f):f=e[5];let p;return e[6]!==n||e[7]!==r||e[8]!==u||e[9]!==f?(p=s.jsx(bx,{isOpen:r,isMobile:n,className:"border-border",topBar:c,peek:u,children:f}),e[6]=n,e[7]=r,e[8]=u,e[9]=f,e[10]=p):p=e[10],p});bu.displayName="LeftSidebar";const Kk=()=>{const t=$e.c(111);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],jk(e),op();const n=X(Zk),r=X(Xk),o=X(Yk),i=X(Jk);let a;t[1]!==i?(a=()=>i(!1),t[1]=i,t[2]=a):a=t[2];const u=fo(o,Pk,a),c=X(Qk),d=X(ej),f=X(tj),p=X(sj),m=X(nj),h=X(rj),b=X(oj),g=X(ij),x=X(aj),w=X(lj),T=X(cj),k=X(dj),E=X(uj),F=dn(fj),_=dn(pj),A=dn(mj),D=X(hj),y=Ng();let N;if(t[3]!==y||t[4]!==D){let nt;t[6]!==D?(nt=ft=>ft.id===D,t[6]=D,t[7]=nt):nt=t[7],N=y.find(nt),t[3]=y,t[4]=D,t[5]=N}else N=t[5];const j=N;let v,M;t[8]!==j||t[9]!==D?(v=()=>{D&&!j&&X.getState().setOpenGuestPage(null)},M=[D,j],t[8]=j,t[9]=D,t[10]=v,t[11]=M):(v=t[10],M=t[11]),l.useEffect(v,M);let W;t[12]===Symbol.for("react.memo_cache_sentinel")?(W=[],t[12]=W):W=t[12],l.useEffect(bj,W);let G;t[13]===Symbol.for("react.memo_cache_sentinel")?(G=[],t[13]=G):G=t[13],l.useEffect(xj,G);const O=d||f||p||m||h||b||!!g||x||c||!!j;let Z,Q;t[14]!==O?(Z=()=>{Xc(O)},Q=[O],t[14]=O,t[15]=Z,t[16]=Q):(Z=t[15],Q=t[16]),l.useLayoutEffect(Z,Q);let B;t[17]===Symbol.for("react.memo_cache_sentinel")?(B=[],t[17]=B):B=t[17],l.useEffect(yj,B);let oe;t[18]===Symbol.for("react.memo_cache_sentinel")?(oe=[],t[18]=oe):oe=t[18],l.useEffect(Sj,oe);const{isMobile:H}=gn();ip();let P,te;t[19]!==H||t[20]!==r?(P=()=>{X.getState().isMobile!==H&&r(H)},te=[H,r],t[19]=H,t[20]=r,t[21]=P,t[22]=te):(P=t[21],te=t[22]),l.useEffect(P,te);let J;t[23]!==w?(J=s.jsx(ss,{needed:w,load:Rk,onFailure:kj}),t[23]=w,t[24]=J):J=t[24];let le;t[25]!==T?(le=s.jsx(ss,{needed:T,load:Dk,onFailure:jj}),t[25]=T,t[26]=le):le=t[26];let K;t[27]!==k?(K=s.jsx(ss,{needed:k,load:Ak,onFailure:Cj}),t[27]=k,t[28]=K):K=t[28];let U;t[29]!==E?(U=s.jsx(ss,{needed:E,load:_k,onFailure:Tj}),t[29]=E,t[30]=U):U=t[30];let $,ee;t[31]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(lp,{}),ee=s.jsx(K2,{}),t[31]=$,t[32]=ee):($=t[31],ee=t[32]);let Y;t[33]!==F||t[34]!==_||t[35]!==A||t[36]!==n?(Y=n?s.jsxs(s.Fragment,{children:[s.jsx(ss,{needed:F,load:Vk,onFailure:Nj}),s.jsx(cp,{}),s.jsx(ss,{needed:_,load:Hk,onFailure:Ej}),s.jsx(dp,{}),s.jsx(ss,{needed:A,load:qk,onFailure:Ij})]}):null,t[33]=F,t[34]=_,t[35]=A,t[36]=n,t[37]=Y):Y=t[37];let ie;t[38]===Symbol.for("react.memo_cache_sentinel")?(ie=s.jsx(Cx,{}),t[38]=ie):ie=t[38];let V;t[39]!==H?(V=s.jsx(bu,{isMobile:H}),t[39]=H,t[40]=V):V=t[40];let fe;t[41]===Symbol.for("react.memo_cache_sentinel")?(fe=s.jsx(gx,{}),t[41]=fe):fe=t[41];let Se;t[42]===Symbol.for("react.memo_cache_sentinel")?(Se=s.jsx(zo,{zone:"left"}),t[42]=Se):Se=t[42];const Te=O&&"invisible";let ue;t[43]!==Te?(ue=Le("absolute inset-0",Te),t[43]=Te,t[44]=ue):ue=t[44];const Me=!o&&!O;let Ae;t[45]!==Me?(Ae=s.jsx(Qt,{children:s.jsx(bc,{active:Me})}),t[45]=Me,t[46]=Ae):Ae=t[46];let De;t[47]!==ue||t[48]!==Ae?(De=s.jsx("div",{className:ue,children:Ae}),t[47]=ue,t[48]=Ae,t[49]=De):De=t[49];let Be;t[50]!==c?(Be=s.jsx(Qt,{children:s.jsx(ss,{needed:c,load:Ok,onFailure:_s})}),t[50]=c,t[51]=Be):Be=t[51];let we;t[52]!==d?(we=s.jsx(Qt,{children:s.jsx(ss,{needed:d,load:Mk,onFailure:_s})}),t[52]=d,t[53]=we):we=t[53];let ve;t[54]!==f?(ve=s.jsx(Qt,{children:s.jsx(ss,{needed:f,load:Fk,onFailure:_s})}),t[54]=f,t[55]=ve):ve=t[55];let Pe;t[56]!==p?(Pe=s.jsx(Qt,{children:s.jsx(ss,{needed:p,load:Lk,onFailure:_s})}),t[56]=p,t[57]=Pe):Pe=t[57];let he;t[58]!==m?(he=m&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Qt,{children:s.jsx(ss,{needed:!0,load:$k,onFailure:_s})})}),t[58]=m,t[59]=he):he=t[59];let Fe;t[60]!==h?(Fe=s.jsx(ss,{needed:h,load:Bk,onFailure:_s}),t[60]=h,t[61]=Fe):Fe=t[61];let _e;t[62]!==b?(_e=s.jsx(Qt,{children:s.jsx(ss,{needed:b,load:zk,onFailure:_s})}),t[62]=b,t[63]=_e):_e=t[63];const We=!!g;let Xe;t[64]!==We?(Xe=s.jsx(Qt,{children:s.jsx(ss,{needed:We,load:Wk,onFailure:_s})}),t[64]=We,t[65]=Xe):Xe=t[65];let Ve;t[66]!==x?(Ve=x?s.jsx(Qt,{children:s.jsx(ss,{needed:!0,load:Uk,onFailure:_s})}):null,t[66]=x,t[67]=Ve):Ve=t[67];let S;t[68]!==j?(S=j&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Qt,{children:s.jsx(Eg,{mode:`plugin:${j.id}`,surface:"page",item:null,onDismiss:Pj})})}),t[68]=j,t[69]=S):S=t[69];let ne;t[70]!==De||t[71]!==Be||t[72]!==we||t[73]!==ve||t[74]!==Pe||t[75]!==he||t[76]!==Fe||t[77]!==_e||t[78]!==Xe||t[79]!==Ve||t[80]!==S?(ne=s.jsxs("main",{className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[De,Be,we,ve,Pe,he,Fe,_e,Xe,Ve,S]}),t[70]=De,t[71]=Be,t[72]=we,t[73]=ve,t[74]=Pe,t[75]=he,t[76]=Fe,t[77]=_e,t[78]=Xe,t[79]=Ve,t[80]=S,t[81]=ne):ne=t[81];let q;t[82]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(zo,{zone:"bottom"}),t[82]=q):q=t[82];let ke;t[83]!==ne?(ke=s.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[ne,q]}),t[83]=ne,t[84]=ke):ke=t[84];let Ee,Ie,Ne,ze;t[85]===Symbol.for("react.memo_cache_sentinel")?(Ee=s.jsx(zo,{zone:"right"}),Ie=s.jsx(a2,{}),Ne=s.jsx(c2,{}),ze=s.jsx(m2,{}),t[85]=Ee,t[86]=Ie,t[87]=Ne,t[88]=ze):(Ee=t[85],Ie=t[86],Ne=t[87],ze=t[88]);let Ue;t[89]!==ke?(Ue=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true","data-workspace-row":"true",children:[Se,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:[ke,Ee,Ie,Ne,ze]})]})}),t[89]=ke,t[90]=Ue):Ue=t[90];let Ge;t[91]===Symbol.for("react.memo_cache_sentinel")?(Ge=s.jsx("div",{"data-page-scroll-lock":"true",children:s.jsx(Qt,{children:s.jsx(N2,{})})}),t[91]=Ge):Ge=t[91];let Qe;t[92]===Symbol.for("react.memo_cache_sentinel")?(Qe=s.jsx(Qt,{children:s.jsx(Tb,{})}),t[92]=Qe):Qe=t[92];let He;t[93]!==Ue?(He=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[fe,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Ue,Ge,Qe]})]}),t[93]=Ue,t[94]=He):He=t[94];let Ke;t[95]!==V||t[96]!==He?(Ke=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[V,He]}),t[95]=V,t[96]=He,t[97]=Ke):Ke=t[97];let Ye;t[98]!==u||t[99]!==o||t[100]!==i?(Ye=u?s.jsx(u,{open:o,onOpenChange:i}):null,t[98]=u,t[99]=o,t[100]=i,t[101]=Ye):Ye=t[101];let it;t[102]===Symbol.for("react.memo_cache_sentinel")?(it=null,t[102]=it):it=t[102];let bt;return t[103]!==J||t[104]!==le||t[105]!==K||t[106]!==U||t[107]!==Y||t[108]!==Ke||t[109]!==Ye?(bt=s.jsx(Ig.Provider,{value:!0,children:s.jsx(ap,{children:s.jsx(yk,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[J,le,K,U,$,ee,Y,ie,Ke,Ye,it]})})})}),t[103]=J,t[104]=le,t[105]=K,t[106]=U,t[107]=Y,t[108]=Ke,t[109]=Ye,t[110]=bt):bt=t[110],bt};function Gk(t){return t.isSidebarOpen}function Zk(t){return t.isolatedSpacesEnabled}function Xk(t){return t.setIsMobile}function Yk(t){return t.isSettingsDialogOpen}function Jk(t){return t.setSettingsDialogOpen}function Qk(t){return t.runOverviewKey!==null}function ej(t){return t.isScheduledTasksDialogOpen}function tj(t){return t.isArchivePageOpen}function sj(t){return t.isIntegrationsCatalogOpen}function nj(t){return t.isUsageStatsPageOpen}function rj(t){return t.isSourceBoardOpen}function oj(t){return t.isOverviewOpen}function ij(t){return t.worktreesPageProjectId}function aj(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function lj(t){return t.isCommandPaletteOpen}function cj(t){return t.isHelpDialogOpen}function dj(t){return t.isProjectActionsDialogOpen}function uj(t){return t.isOpenCodeStatusDialogOpen}function fj(t){return t.accessDialog!==null}function pj(t){return t.applyDialog!==null}function mj(t){return t.setupOutputDialog!==null}function hj(t){return t.openGuestPageId}function gj(){return X.getState().setOpenGuestPage(null)}function bj(){return ec(gj)}function xj(){return Cb()}function wj(){return Xc(!1)}function yj(){return wj}function vj(){return X.getState().closeMainSurfaces()}function Sj(){const t=vj,e=et.subscribe((n,r)=>{const o=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,i=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(o||i)&&t()});return()=>{e()}}function kj(){return X.getState().setCommandPaletteOpen(!1)}function jj(){return X.getState().setHelpDialogOpen(!1)}function Cj(){return X.getState().setProjectActionsDialogOpen(!1)}function Tj(){return X.getState().setOpenCodeStatusDialogOpen(!1)}function Nj(){return dn.getState().closeAccessDialog()}function Ej(){return dn.getState().closeApplyDialog()}function Ij(){return dn.getState().closeSetupOutputDialog()}function Pj(){return X.getState().setOpenGuestPage(null)}const wi="openchamber_requests_in_flight",xu=1e3,Rj=300*1e3,Xr=Math.ceil(Rj/xu),Dj=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(wi)==="1"}catch{return!1}},wu=()=>({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 Aj=1;const _j=(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))},Oj=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},yu=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,o)=>r-o),n},In=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),o=Math.floor(r),i=Math.ceil(r);return o===i?t[o]:t[o]+(t[i]-t[o])*(r-o)},Mj=()=>{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,o)=>{const i=Aj++;_j(i,Date.now());try{return await e(r,o)}finally{Oj(i)}};window.fetch=n},Rl=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Un=t=>{t.length>Xr&&t.splice(0,t.length-Xr)},Fj=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=yu(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(In(e,50)),t.p90Samples.push(In(e,90)),t.p99Samples.push(In(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Un(t.samples),Un(t.p50Samples),Un(t.p90Samples),Un(t.p99Samples),Un(t.maxSamples),t.lastSampleAt=Date.now()},Lj=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(Fj,xu))},Dl=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Al=t=>{if(!(typeof window>"u"))try{if(t){Dl(),Rl(),window.localStorage.setItem(wi,"1"),window.__openchamberRequestsInFlight__=wu(),Mj(),Lj();return}window.localStorage.removeItem(wi),Dl(),Rl(),delete window.__openchamberRequestsInFlight__}catch{}},k4=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=wu();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},j4=()=>{if(typeof window>"u")return _l();const t=window.__openchamberRequestsInFlight__;if(!Dj()||!t)return _l();const e=yu(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:In(e,50),ageP90:In(e,90),ageP99:In(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:Xr}},_l=()=>({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:Xr}),$j=(t,e,n)=>Pg(t.filter(r=>!Yc(r)&&!r.parentID),e,n),Bj=()=>$j(ps.getState().activeSessions,qi.getState().ids,Hi.getState().rankById??Rg),zj=(t,e,n)=>{if(t.length===0)return;const r=t.findIndex(i=>i.id===e);let o=n>0?0:t.length-1;return r>=0&&(o=(r+n+t.length)%t.length),t[o]},Wj=()=>{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()??"":""},Uj=async()=>{const t=Wj()||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")},Ol="openchamber:menu-action",Ml="openchamber:check-for-updates",Vj=t=>{const e=$e.c(21),{t:n}=at(),r=et(Hj),o=X(qj),i=X(Kj),a=X(Gj),u=X(Zj),c=X(Xj),d=X(Yj),f=X(Jj),p=xc(Qj),{setThemeMode:m}=so(),h=l.useRef(!1);let b;e[0]!==p?(b=()=>{h.current||(h.current=!0,p().then(e3).finally(()=>{h.current=!1}))},e[0]=p,e[1]=b):b=e[1];const g=b,x=t3;let w;e[2]!==c?(w=D=>{const y=et.getState().currentSessionId,N=zj(Bj(),y,D);N&&(c(!1),et.getState().setCurrentSession(N.id,Ys(N)))},e[2]=c,e[3]=w):w=e[3];const T=w,k=s3;let E;e[4]!==T||e[5]!==t||e[6]!==r||e[7]!==f||e[8]!==i||e[9]!==c||e[10]!==d||e[11]!==m||e[12]!==n||e[13]!==o||e[14]!==a||e[15]!==u?(E=D=>{e:switch(D){case"about":{f(!0);break e}case"settings":{d(!0);break e}case"command-palette":{o();break e}case"quick-open":{i(!0);break e}case"new-session":{c(!1);const y=et.getState(),N=ls.getState().currentDirectory;r(y.currentSessionId&&N?{directoryOverride:N}:void 0);break e}case"new-worktree-session":{c(!1),Og();break e}case"change-workspace":{x();break e}case"toggle-right-sidebar":{const y=ls.getState().currentDirectory;if(!y)break e;const N=X.getState(),j=cs(y),v=N.contextPanelByDirectory[j],M=v?Yu(v.tabs,N.contextSurfaceZones,"right",er(v,"right").activeTabId):null;v?.isOpen?N.closeContextPanel(j):M?N.setActiveContextPanelTab(j,M):N.openContextSurface(j,"git");break e}case"open-right-sidebar-git":{const y=ls.getState().currentDirectory;if(!y)break e;X.getState().openContextSurface(cs(y),"git");break e}case"open-right-sidebar-files":{const y=ls.getState().currentDirectory;if(!y)break e;X.getState().openContextSurface(cs(y),"file");break e}case"toggle-terminal":{const y=ls.getState().currentDirectory;if(!y)break e;X.getState().openContextSurface(cs(y),"terminal");break e}case"toggle-context-panel-expanded":{_g(ls.getState().currentDirectory);break e}case"copy":{const y=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(y)||Uj();break e}case"theme-light":{m("light");break e}case"theme-dark":{m("dark");break e}case"theme-system":{m("system");break e}case"add-selection-to-chat":{Ag();break e}case"toggle-sidebar":{u();break e}case"toggle-memory-debug":{t?.();break e}case"go-back":{Oa(-1);break e}case"go-forward":{Oa(1);break e}case"previous-session":{T(-1);break e}case"next-session":{T(1);break e}case"previous-project":{k(-1);break e}case"next-project":{k(1);break e}case"help-dialog":{a();break e}case"download-logs":Dg().catch(()=>{Re.error(n("openCodeStatusDialog.toast.collectFailed"))})}},e[4]=T,e[5]=t,e[6]=r,e[7]=f,e[8]=i,e[9]=c,e[10]=d,e[11]=m,e[12]=n,e[13]=o,e[14]=a,e[15]=u,e[16]=E):E=e[16];const F=E;let _,A;e[17]!==F||e[18]!==g?(_=()=>{const D=N=>{const j=N.detail;j&&F(j)},y=()=>{g()};return window.addEventListener(Ol,D),window.addEventListener(Ml,y),()=>{window.removeEventListener(Ol,D),window.removeEventListener(Ml,y)}},A=[F,g],e[17]=F,e[18]=g,e[19]=_,e[20]=A):(_=e[19],A=e[20]),l.useEffect(_,A)};function Hj(t){return t.openNewSessionDraft}function qj(t){return t.toggleCommandPalette}function Kj(t){return t.setCommandPaletteOpen}function Gj(t){return t.toggleHelpDialog}function Zj(t){return t.toggleSidebar}function Xj(t){return t.setSessionSwitcherOpen}function Yj(t){return t.setSettingsDialogOpen}function Jj(t){return t.setAboutDialogOpen}function Qj(t){return t.checkForUpdates}function e3(){const{available:t,error:e}=xc.getState();if(e){Re.error("Failed to check for updates",{description:e});return}t||Re.success("You are on the latest version")}function t3(){Wr.requestDirectoryDialog()}function s3(t){const{activeProjectId:e,projects:n,setActiveProject:r}=ts.getState();if(n.length===0)return;const o=n.findIndex(u=>u.id===e);let i=t>0?0:n.length-1;o>=0&&(i=(o+t+n.length)%n.length);const a=n[i];a&&r(a.id)}const Fl=(t,{isAdmitted:e,isPlaced:n,isPinned:r,zones:o})=>!e||t.parentID||t.time?.archived||Yc(t)?!1:n||o.pinned&&r||o.work&&kc(t),n3="openchamber:tray-action",r3=5e3,o3=500,i3=20,Ll=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},$l=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,vu=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},Su=t=>t.title.trim()||"Question",a3=new Set,l3=(t,e)=>Vg(t,e,a3,Hi.getState().rankById),c3=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},d3=(t,e,n,r,o)=>{if(!t)return"";const i=fr(n,r,t),a=e.project?.name,u=i?.label?.trim()||a?.trim()||c3(t),c=Br(t);let d=c&&o.get(c)||"";if(!d){for(const[f,p]of An.getState().directories)if(Br(f)===c){d=p.status?.current??"";break}}if(!d)for(const f of r.values()){const p=c?Lr(f,c):void 0;if(p?.branch){d=p.branch;break}}return d?`${u} · ${d}`:u},u3=()=>{const{dictionary:t}=tf.getState(),e=(c,d)=>sf(t,c,d),{results:n,dropdownProviderIds:r,displayMode:o}=sd.getState(),i=o==="remaining"?"remaining":"usage";if(!r.length)return{mode:i,groups:[]};const a=new Map(n.map(c=>[c.providerId,c])),u=[];for(const c of Hg){if(!r.includes(c.id))continue;const d=a.get(c.id);if(!d||d.configured!==!0)continue;const f=[];for(const[m,h]of Object.entries(d.usage?.windows??{})){const b=i==="remaining"?h.remainingPercent:h.usedPercent;f.push({label:Kg(m),value:qg(h,b,e)})}const p=!d.ok&&d.error?d.error:f.length===0?"No rate limits reported":null;u.push({provider:c.name,rows:f,status:p})}return{mode:i,groups:u}},f3=async()=>{try{if(Qr())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Ju();if(e&&aa(e,t))return"Local OpenChamber";const r=(await Ni()).hosts.find(o=>e?aa(e,sc(o)):!1);return r?.label?.trim()?Qu(r.label.trim()):"Instance"}catch{return""}},p3=()=>{const t=new Map,e=new Map,n=[],r=new Map;let o;try{o=ei()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[i,a]of o.children.entries()){const u=a.getState();u.vcs?.branch&&e.set(Br(i)??i,u.vcs.branch);for(const c of u.session)c?.id&&r.set(c.id,c.title);for(const[c,d]of Object.entries(u.session_status??{})){const f=d?.type,p=f==="busy"?"busy":f==="retry"?"retry":"idle",m=t.get(c);(!m||m==="idle")&&t.set(c,p)}for(const[c,d]of Object.entries(u.permission??{}))for(const f of d??[]){if(!f?.id)continue;const p=f.sessionID||c;n.push({kind:"permission",id:f.id,sessionId:p,sessionTitle:"",label:vu(f),directory:i,canSave:nd(f.save)})}for(const[c,d]of Object.entries(u.form??{}))for(const f of d??[]){if(!f?.id)continue;const p=f.sessionID||c;n.push({kind:"form",id:f.id,sessionId:p,sessionTitle:"",label:Su(f),directory:i,canSave:!1})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},m3=(t,e)=>{const n=ps.getState().activeSessions,r=$g(n),o=y=>r.descendantsOf(y,"active").map(N=>N.id),i=ts.getState().projects,a=et.getState().availableWorktreesByProject,u=qi.getState().ids,c=(y,N)=>{const j=Ys(y),v=Ma(j,i,a);return Yr(j)||y.projectID===ef?Fl(y,{isAdmitted:v,isPlaced:N.chats,isPinned:!1,zones:{pinned:!1,work:!1}}):Fl(y,{isAdmitted:v,isPlaced:ki(j)||fr(i,a,j)!==null,isPinned:Ug(u,y.directory,y.id),zones:N})},d=tc.getState(),f={chats:d.showChatsSection,pinned:d.showPinnedSection,work:X.getState().sessionWorkEnabled&&d.showWorkSection},p={chats:!0,pinned:!0,work:!0},m=Bg(Qo.getState().activeSessionIds,[Jc.getState().runningSessionIds,Qc.getState().sessionIds,ed.getState().bySession.keys()]),h=y=>Wg(y)&&!m.has(y.id),b=X.getState().dockBadgeEnabled?n.filter(y=>h(y)&&c(y,f)):[],g=b.length,x=b.sort((y,N)=>(N.time.idle??N.time.updated)-(y.time.idle??y.time.updated)||y.id.localeCompare(N.id)).slice(0,10).map(y=>({id:y.id,title:y.title,directory:Ys(y)??""}));if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:g,dockUnreadSessions:x};const w=p3(),T=new Map(w.titleById);for(const y of n)y?.id&&y.title&&T.set(y.id,y.title);const k=Qo.getState().statusById,E=y=>{const N=w.statusById.get(y);return N&&N!=="idle"?N:k.get(y)?.status.type??N??"idle"},F=y=>{const N=y.map(j=>E(j));return N.includes("busy")?"busy":N.includes("retry")?"retry":"idle"},_=n.filter(y=>y?.id&&!y.parentID).filter(y=>c(y,p)).slice().sort(l3).slice(0,i3).map(y=>{const N=[y.id,...o(y.id)],j=Ys(y)??"";return{id:y.id,title:y.title||"Untitled session",status:F(N),branch:j?w.branchByDirectory.get(j)??"":"",unseen:h(y)?1:0,hasError:h(y)&&zg(y),directory:j,subtitle:d3(j,y,i,a,w.branchByDirectory)}}),A=w.approvals.map(y=>({...y,sessionTitle:T.get(y.sessionId)||""})),D=new Set(A.map(y=>y.id));for(const[y,N]of td.getState().bySession){const j=T.get(y)||"";for(const v of N.permissions)D.has(v.id)||(D.add(v.id),A.push({kind:"permission",id:v.id,sessionId:y,sessionTitle:j,label:vu(v),directory:N.directory,canSave:nd(v.save)}));for(const v of[...N.forms,...N.pages])D.has(v.id)||(D.add(v.id),A.push({kind:"form",id:v.id,sessionId:y,sessionTitle:j,label:Su(v),directory:N.directory,canSave:!1}))}return{sessions:_,approvals:A.filter(y=>Ma(y.directory,i,a)),instanceName:t,usage:u3(),dockBadgeCount:g,dockUnreadSessions:x}},h3=()=>{l.useEffect(()=>{if(!Ll()||!qo())return;const t=$l();let e=!1,n="",r=null,o="";const i=()=>{if(e)return;const j=m3(o,t),v=JSON.stringify(j);v!==n&&(n=v,Zs("desktop_tray_update",j))},a=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},o3))},u=ps.subscribe(()=>a()),c=Qo.subscribe(()=>a()),d=Jc.subscribe(()=>a()),f=Qc.subscribe(()=>a()),p=ed.subscribe(()=>a()),m=X.subscribe((j,v)=>{(j.dockBadgeEnabled!==v.dockBadgeEnabled||j.sessionWorkEnabled!==v.sessionWorkEnabled)&&a()}),h=ts.subscribe(()=>a()),b=et.subscribe(()=>a()),g=qi.subscribe(()=>a()),x=tc.subscribe((j,v)=>{(j.showChatsSection!==v.showChatsSection||j.showPinnedSection!==v.showPinnedSection||j.showWorkSection!==v.showWorkSection)&&a()}),w=()=>{e=!0,r!==null&&window.clearTimeout(r),u(),c(),d(),f(),p(),m(),h(),b(),g(),x()};if(!t)return i(),w;f3().then(j=>{e||(o=j,i())});const T=new Map,k=()=>{if(e)return;let j;try{j=ei()}catch{return}const v=new Set;for(const[M,W]of j.children.entries())v.add(M),T.has(M)||T.set(M,W.subscribe(()=>a()));for(const[M,W]of T)v.has(M)||(W(),T.delete(M))};let E=null;try{E=ei().subscribeRegistry(()=>{k(),a()})}catch{}k();const F=An.subscribe(()=>a()),_=td.subscribe(()=>a()),A=Hi.subscribe(()=>a()),D=sd.subscribe(()=>a()),y=zt.subscribe((j,v)=>{j.isInitialized&&!v.isInitialized&&Do(!0)});Do(!0);const N=window.setInterval(()=>{k(),i()},r3);return i(),()=>{w(),window.clearInterval(N),F(),_(),A(),D(),y(),E?.();for(const j of T.values())j();T.clear()}},[]),l.useEffect(()=>{if(!Ll()||!qo())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{switch(i.type){case"mark-all-read":Fg().then(()=>Lg()).catch(()=>{});break;case"menu-opened":$l()&&Do();break;case"respond-permission":Mg(i.sessionId,i.id,i.response).catch(()=>{Re.error("Failed to respond to permission request")});break}};let r=null,o=!1;return e(n3,i=>{const a=i?.payload;!a||typeof a!="object"||typeof a.type!="string"||n(a)}).then(i=>{if(o){i();return}r=i,Zs("desktop_tray_actions_ready")}).catch(()=>{}),()=>{o=!0;try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},g3=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,b3=(t,e,n,r)=>r||[t,e,n].filter(Boolean).join("|")||void 0,x3=t=>{t.kind!=="plugin"||!t.title||Re.info(t.title,{id:b3(t.kind,t.title,t.body,t.tag),description:t.body})},w3=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,y3=t=>{const e=$e.c(3),n=!0;let r,o;e[0]!==n?(r=()=>{if(!(Bs()||!nc()||!globalThis.window))return Js(v3)},o=[n],e[0]=n,e[1]=r,e[2]=o):(r=e[1],o=e[2]),l.useEffect(r,o)};function v3(t){if(t.type!=="notification")return;const e=X.getState();if(!e.nativeNotificationsEnabled)return;const n=g3();if(w3(t.payload,n)){x3(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&n)return;Ql()?.notifications?.notifyAgentCompletion(t.payload)}const S3=()=>{const t=$e.c(4),{t:e}=at(),n=X(k3);let r,o;t[0]!==n||t[1]!==e?(r=()=>Js(i=>{i.type==="browser-provider-reset"&&(n("builtin"),Re.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:i.guestName})))}),o=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),l.useEffect(r,o)};function k3(t){return t.setBrowserProvider}const j3=()=>{const t=$e.c(1);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],l.useEffect(T3,e)};function C3(t){t.type==="guests-changed"?Gg():t.type==="event-stream-ready"&&Zg()}function T3(){return Js(C3)}const N3=()=>{const t=$e.c(3),{t:e}=at();let n,r;t[0]!==e?(n=()=>Js(o=>{if(o.type!=="limit-failover")return;const{failover:i}=o,a=zt.getState().providers,u=c=>a.find(d=>d.id===c);if(i.kind==="account"){const c=u(i.providerId)?.name||i.providerId;Re.info(i.fromAccount?e("chat.limitFailover.toast.account",{provider:c,from:i.fromAccount,to:i.toAccount}):e("chat.limitFailover.toast.accountUnknown",{provider:c,to:i.toAccount}));return}Re.info(e("chat.limitFailover.toast.model",{model:Fa(u(i.providerId),i.modelId),fallback:Fa(u(i.toProviderId),i.toModelId)}))}),r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),l.useEffect(n,r)},Bl="relay-limit-reached",E3=()=>{const t=$e.c(3),{t:e}=at();let n,r;t[0]!==e?(n=()=>{const o=()=>{Re.error(e("relayConnection.limitReached.title"),{id:Bl,description:e("relayConnection.limitReached.description"),duration:1/0,action:{label:e("relayConnection.limitReached.retry"),onClick:I3}})};return la(rc()?.getStatus())&&o(),nf(a=>{la(a)?o():(a.state==="connected"||a.state==="idle")&&Re.dismiss(Bl)})},r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),l.useEffect(n,r)};function I3(){return rc()?.retry()}const zl=()=>{rf()||(Xg(),Yg(up.map(t=>t.id)))},P3=(t,e)=>{const n=$e.c(5);let r;n[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const a=window.requestIdleCallback(zl,{timeout:1e4});return()=>window.cancelIdleCallback(a)}const i=setTimeout(zl,3e3);return()=>clearTimeout(i)},n[0]=t,n[1]=r):r=n[1];let o;n[2]!==e||n[3]!==t?(o=[t,e],n[2]=e,n[3]=t,n[4]=o):o=n[4],l.useEffect(r,o)},Wl="pwa-install-toast-shown",Ul="pwa-install-toast-dismissed",R3=()=>{const t=$e.c(6),{browserTab:e}=fp(),{t:n}=at(),r=l.useRef(n);let o,i;t[0]!==n?(o=()=>{r.current=n},i=[n],t[0]=n,t[1]=o,t[2]=i):(o=t[1],i=t[2]),l.useEffect(o,i);let a,u;t[3]!==e?(a=()=>{if(typeof window>"u"||!nc()||!e)return;let c=null,d=null;const f=()=>{d!==null&&(Re.dismiss(d),d=null)},p=async()=>{if(!c)return;const b=c;c=null,f(),await b.prompt();const{outcome:g}=await b.userChoice;g==="accepted"&&Re.success(r.current("pwa.installPrompt.started"))},m=b=>{const g=b;if(typeof g.prompt!="function")return;g.preventDefault(),c=g;const x=ca(),w=of();pp({dismissed:x.getItem(Ul),sessionShown:w.getItem(Wl),hasActiveToast:d!==null})&&(w.setItem(Wl,"true"),d=Re.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{p()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{ca().setItem(Ul,"true"),f()}}}))},h=()=>{c=null,f(),Re.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",m),window.addEventListener("appinstalled",h),()=>{f(),window.removeEventListener("beforeinstallprompt",m),window.removeEventListener("appinstalled",h)}},u=[e],t[3]=e,t[4]=a,t[5]=u):(a=t[4],u=t[5]),l.useEffect(a,u)},ku=()=>globalThis.window?.__OPENCHAMBER_SAFE_START__===!0,D3=()=>{gs.setState({byRoot:{},runtimeSnapshots:{}});const t=X.getState();for(const e of Object.keys(t.contextPanelByDirectory))for(const n of Ti)t.closeContextZone(e,n)},A3=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",ju=async(t,e)=>{const n=(await Ni()).hosts.find(o=>o.id===t);if(!n)throw new Error("host-not-found");if(n.relay){await df(n.id,e);return}const r=uf(sc(n));if(!r)throw new Error("host-not-found");ff({apiBaseUrl:r,clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,runtimeKey:pf(n),sshForwarded:n.sshForwarded===!0})},_3=async t=>{const e=await Ni(),n=await lf(t,e.hosts);await cf({hosts:n.hosts,defaultHostId:e.defaultHostId||n.hostId,initialHostChoiceCompleted:!0}),await ju(n.hostId,{reconnectActive:!0})},O3=async t=>{const e=await af();for(const n of e)try{n.type==="pairing"?await _3(n.link):await ju(n.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",n.type,o),t(A3(o))}},yi="project-config-invalid",M3=()=>{const t=$e.c(9),{t:e}=at(),n=zt(F3);let r;t[0]!==n?(r=m=>m.projectConfigErrors[n],t[0]=n,t[1]=r):r=t[1];const o=zt(r),[i,a]=qt.useState(!1);let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const m=zt.getState(),h=m.activeDirectoryKey;a(!0),Promise.all([m.loadProviders({directory:h,source:"projectConfigError:retry"}),m.loadAgents({directory:h,source:"projectConfigError:retry"})]).finally(()=>a(!1))},t[2]=u):u=t[2];const c=u;let d,f;t[3]!==o||t[4]!==i||t[5]!==e?(d=()=>{if(!o){Re.dismiss(yi);return}Re.error(e("projectConfigError.toast.title"),{id:yi,duration:1/0,description:s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("span",{className:"break-all font-mono typography-meta",children:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&s.jsx(hs,{as:"span",outerClassName:"max-h-40",className:"whitespace-pre-wrap break-words font-mono typography-meta",disableHorizontal:!0,children:o.message}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(i?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:m=>{m.preventDefault(),i||c()}}})},f=[o,i,c,e],t[3]=o,t[4]=i,t[5]=e,t[6]=d,t[7]=f):(d=t[6],f=t[7]),qt.useEffect(d,f);let p;return t[8]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[8]=p):p=t[8],qt.useEffect($3,p),null};function F3(t){return t.activeDirectoryKey}function L3(){Re.dismiss(yi)}function $3(){return L3}const B3="\x1B",z3=new RegExp(`${B3}\\[[0-9;?]*[ -/]*[@-~]`,"g"),jr=Ns().transform(t=>t.replace(z3,"").trim()).nullish(),W3=Qs({isOpenCodeReady:ar().optional(),openCodeRunning:ar().optional(),lastOpenCodeError:jr,opencodeBinaryResolved:jr,lastOpenCodeLaunchDiagnostics:Qs({sourceBinary:jr,binary:jr}).nullish()}),U3=async(t,e=zs)=>{const n=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)throw new Error(`Startup diagnostics request failed (${n.status})`);const r=W3.parse(await n.json());return r.isOpenCodeReady===!0||r.isOpenCodeReady!==!1&&r.openCodeRunning!==!1?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},V3=(t,e)=>{if(t)return"startup.initRecovery.openCodeUnavailable";switch(e?.step){case"serverUnreachable":return"startup.initRecovery.serverUnreachable";case"openCodeUnavailable":return"startup.initRecovery.openCodeUnavailable";case"loadAgents":return"startup.initRecovery.loadAgentsFailed";default:return"startup.initRecovery.unexpected"}},H3=Qs({openchamberVersion:Ns()}),q3=async(t,e=zs)=>{const n=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)return null;const r=H3.safeParse(await n.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},K3=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function G3({version:t}){const{t:e}=at(),[n,r]=l.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const u=await hp();r(u.available&&!u.installBlocked?{kind:"available",info:u}:{kind:"manual",info:u,error:null})}catch(u){r({kind:"manual",info:null,error:u instanceof Error?u.message:null})}},i=n.kind==="manual"?n:null,a=i?.info?.updateCommand||"openchamber update";return s.jsxs("div",{className:"flex w-full flex-col items-center gap-3",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h1",{className:"typography-h1 text-foreground",children:e("startup.serverOutdated.title")}),s.jsx("p",{className:"typography-markdown text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),s.jsxs(dt,{type:"button",onClick:()=>{o()},disabled:n.kind==="checking",children:[s.jsx(se,{name:n.kind==="checking"?"loader":"download",className:n.kind==="checking"?"size-4 animate-spin":"size-4"}),n.kind==="checking"?e("startup.serverOutdated.checking"):e("onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),i&&s.jsxs("div",{className:"w-full space-y-2 text-start",children:[!i.info?.available&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),i.error&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:i.error}),i.info?.installBlocked==="desktop-host"?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:i.info.version||""})}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("onboarding.desktopRecovery.remoteIncompatible.manualUpdate")}),s.jsx("code",{className:"block select-text rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono text-sm text-foreground",children:a})]})]}),s.jsx(mp,{open:n.kind==="available",onOpenChange:u=>{u||r({kind:"idle"})},info:n.kind==="available"?n.info:null,downloading:!1,downloaded:!1,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const Vl=ur(()=>Ot(()=>import("./OnboardingScreen-DBSPDpEj.js"),__vite__mapDeps([261,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.OnboardingScreen}))),Z3=()=>Ot(()=>import("./AboutDialog-D-IujH5P.js"),__vite__mapDeps([262,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,239])).then(t=>t.AboutDialog),X3=()=>Ot(()=>import("./MemoryDebugPanel-X5DD6Cjd.js"),__vite__mapDeps([263,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,205,206])).then(t=>t.MemoryDebugPanel),Y3=()=>{const t=$e.c(6),e=X(s4),n=X(n4);let r;t[0]!==n?(r=()=>n(!1),t[0]=n,t[1]=r):r=t[1];const o=fo(e,Z3,r);if(!o)return null;let i;return t[2]!==o||t[3]!==e||t[4]!==n?(i=s.jsx(o,{open:e,onOpenChange:n}),t[2]=o,t[3]=e,t[4]=n,t[5]=i):i=t[5],i},J3=t=>{const e=$e.c(3),{onClose:n}=t,r=fo(!0,X3,n);let o;return e[0]!==r||e[1]!==n?(o=r?s.jsx(r,{onClose:n}):null,e[0]=r,e[1]=n,e[2]=o):o=e[2],o},Q3=t=>{const e=$e.c(47),{onRetry:n,isRetrying:r}=t,{t:o}=at(),[i,a]=l.useState(null);let u,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const y=new AbortController,N=ns(),j=setTimeout(()=>y.abort(),5e3);return U3(y.signal).then(v=>{!y.signal.aborted&&ns()===N&&a(v)}).catch(r4).finally(()=>clearTimeout(j)),()=>{y.abort(),clearTimeout(j)}},c=[],e[0]=u,e[1]=c):(u=e[0],c=e[1]),l.useEffect(u,c);const[d,f]=l.useState(null);let p,m;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{const y=new AbortController,N=ns(),j=setTimeout(()=>y.abort(),5e3);return q3(y.signal).then(v=>{y.signal.aborted||ns()!==N||f(v&&K3(v)?v:null)}).catch(o4).finally(()=>clearTimeout(j)),()=>{y.abort(),clearTimeout(j)}},m=[],e[2]=p,e[3]=m):(p=e[2],m=e[3]),l.useEffect(p,m);const h=zt(i4),b=i?null:h?.message??null;if(d){let y;e[4]!==d?(y=s.jsx(G3,{version:d}),e[4]=d,e[5]=y):y=e[5];let N;e[6]!==r||e[7]!==o?(N=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=N):N=e[8];let j;e[9]!==r||e[10]!==n||e[11]!==N?(j=s.jsx(dt,{type:"button",variant:"outline",onClick:n,disabled:r,children:N}),e[9]=r,e[10]=n,e[11]=N,e[12]=j):j=e[12];let v;return e[13]!==y||e[14]!==j?(v=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[y,j]})}),e[13]=y,e[14]=j,e[15]=v):v=e[15],v}let g;e[16]!==o?(g=o("startup.initRecovery.title"),e[16]=o,e[17]=g):g=e[17];let x;e[18]!==g?(x=s.jsx("h1",{className:"typography-h1 text-foreground",children:g}),e[18]=g,e[19]=x):x=e[19];let w;e[20]!==i||e[21]!==h||e[22]!==o?(w=o(V3(i,h)),e[20]=i,e[21]=h,e[22]=o,e[23]=w):w=e[23];let T;e[24]!==w?(T=s.jsx("p",{className:"typography-markdown text-muted-foreground",children:w}),e[24]=w,e[25]=T):T=e[25];let k;e[26]!==x||e[27]!==T?(k=s.jsxs("div",{className:"flex flex-col gap-2",children:[x,T]}),e[26]=x,e[27]=T,e[28]=k):k=e[28];let E;e[29]!==b||e[30]!==o?(E=b&&s.jsxs("dl",{className:"w-full min-w-0 text-start","aria-live":"polite",children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.lastError")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono typography-meta text-muted-foreground",children:b})]}),e[29]=b,e[30]=o,e[31]=E):E=e[31];let F;e[32]!==i||e[33]!==o?(F=i&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[i.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:i.binary})]}),i.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:i.error})]})]}),e[32]=i,e[33]=o,e[34]=F):F=e[34];let _;e[35]!==r||e[36]!==o?(_=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[35]=r,e[36]=o,e[37]=_):_=e[37];let A;e[38]!==r||e[39]!==n||e[40]!==_?(A=s.jsx(dt,{type:"button",onClick:n,disabled:r,children:_}),e[38]=r,e[39]=n,e[40]=_,e[41]=A):A=e[41];let D;return e[42]!==E||e[43]!==F||e[44]!==A||e[45]!==k?(D=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[k,E,F,A]})}),e[42]=E,e[43]=F,e[44]=A,e[45]=k,e[46]=D):D=e[46],D};function e4({apis:t}){l.useEffect(()=>Jg(),[]),l.useEffect(()=>{mf("App:mounted"),hf()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=zt($=>$.initializeApp),n=zt($=>$.isInitialized),r=zt($=>$.isConnected),o=zt($=>$.providersLoaded),i=zt($=>$.agentsLoaded),a=zt($=>$.loadProviders),u=zt($=>$.loadAgents),c=et($=>$.error),d=et($=>$.clearError),f=ls($=>$.currentDirectory),p=ls($=>$.isSwitchingDirectory),[m,h]=l.useState(!1),b=fn($=>$.refreshAll),g=Zl($=>$.refresh),[x,w]=l.useState(()=>t.runtime.isVSCode),[T,k]=l.useState(!1),[E,F]=l.useState(0),[_,A]=l.useState(0),[D,y]=l.useState(!1),N=X($=>$.wideChatLayoutEnabled),j=X($=>$.mobileKeyboardMode),v=l.useMemo(()=>Bs(),[]),[M,W]=l.useState(()=>da()),[G,O]=l.useState(()=>{const $=Co();return $!==null?ua({isDesktopShell:!0,bootOutcome:$}):null}),Z=l.useRef(!1),{t:Q}=at(),B=l.useRef(!1);l.useEffect(()=>{if(!n||M!=="valid"||B.current)return;const $=Co();$?.target!=="local"||$.status!=="ok"||!$.sshStartupFallbackHostId||(B.current=!0,Re.error(Q("desktopHostSwitcher.startup.title"),{description:Q("desktopHostSwitcher.startup.fellBackToLocal")}))},[M,n,Q]);const oe=l.useRef(!1);l.useEffect(()=>{!n||!ku()||oe.current||(oe.current=!0,Re.info(Q("desktopSafeStart.title"),{description:Q("desktopSafeStart.description"),duration:1/0}))},[n,Q]),l.useEffect(()=>(fa(m),Al(m),()=>{fa(!1),Al(!1)}),[m]),l.useEffect(()=>{gf(j)},[j]),l.useEffect(()=>{w(t.runtime.isVSCode)},[t.runtime.isVSCode]),l.useEffect(()=>ec($=>{bp($)&&xp($),A(ee=>ee+1),k(!1),F(ee=>ee+1)}),[]),l.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",N),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[N]),l.useEffect(()=>(pa(t),()=>pa(null)),[t]),l.useEffect(()=>{r&&(g(t.sourceControl),b(t.sourceControl,{force:!0}),Qg(t.trackers))},[t.sourceControl,t.trackers,r,b,g,_]),eb();const H=M==="valid",P=G?.screen==="main";l.useEffect(()=>{if(!bf({isDesktopShell:v,bootOutcomeKnown:H}))return;tb();const $=setTimeout(()=>{const ee=document.getElementById("initial-loading");ee&&(ee.classList.add("fade-out"),setTimeout(()=>{ee.remove()},300))},150);return()=>clearTimeout($)},[v,H]),l.useEffect(()=>{if(!v||M!=="malformed")return;const $=document.getElementById("initial-loading");$&&($.textContent="Desktop startup failed — please restart the app.")},[v,M]),l.useEffect(()=>{x||e()},[e,x]),l.useEffect(()=>{if(x||n)return;let $=!0,ee,Y=0;const ie=10,V=1e3,fe=async()=>{if(!$)return;if(Y>=ie){k(!0);return}const Se=zt.getState();if(Se.isInitialized){k(!1);return}Y+=1,await Se.initializeApp();const Te=zt.getState();if(!$)return;if(Te.isInitialized){k(!1);return}if(Y>=ie){k(!0);return}const ue=Math.min(V*Math.pow(2,Y-1),4e3);ee=setTimeout(fe,ue)};return ee=setTimeout(fe,V),()=>{$=!1,ee&&clearTimeout(ee)}},[E,n,x]),l.useEffect(()=>{n&&k(!1)},[n]),l.useEffect(()=>{if(!T)return;const $=document.getElementById("initial-loading");$&&($.classList.add("fade-out"),setTimeout(()=>{$.remove()},300))},[T]),l.useEffect(()=>{if(x||!r||o&&i)return;let $=!0,ee=0;const Y=15,ie=async()=>{const fe=zt.getState();if(!(fe.providersLoaded&&fe.agentsLoaded))try{fe.providersLoaded||await a({source:"startupRecovery"}),zt.getState().agentsLoaded||await u({source:"startupRecovery"})}catch{}};ie();const V=setInterval(()=>{if($){if(++ee>=Y){clearInterval(V);return}ie()}},2e3);return()=>{$=!1,clearInterval(V)}},[r,x,u,a,o,i]),l.useEffect(()=>{p||x||r&&Go.setDirectory(f)},[f,p,r,x]),l.useEffect(()=>{if(typeof window>"u")return;const $=ee=>{const Y=ee.detail,ie=typeof Y?.sessionId=="string"?Y.sessionId.trim():"";if(!ie)return;const V=typeof Y?.directory=="string"&&Y.directory.trim().length>0?Y.directory.trim():null,fe=typeof Y?.messageId=="string"&&Y.messageId.trim()||null;ma(ie,String(Y?.runtimeKey??"").trim(),fe)||La(ie,{directory:V,messageId:fe,requireKnownSession:Y?.requireKnownSession===!0})};return window.addEventListener("openchamber:open-session",$),xf().then(ee=>{for(const Y of ee)ma(Y.sessionId,Y.runtimeKey,Y.messageId)||(Y.requireKnownSession?La(Y.sessionId,{messageId:Y.messageId,requireKnownSession:!0}):sb(Y.sessionId,Y.messageId))}),()=>window.removeEventListener("openchamber:open-session",$)},[]),l.useEffect(()=>{if(!Bs())return;const $=()=>{O3(ee=>{Re.error(Q(ee==="invalid-link"?"settings.remoteInstances.direct.error.invalidConnectLink":ee==="unreachable"?"mobile.connect.error.unreachable":"onboarding.remoteConnection.errors.failedToSaveConnection"))})};return window.addEventListener("openchamber:host-actions-ready",$),$(),()=>window.removeEventListener("openchamber:host-actions-ready",$)},[Q]);const te=l.useRef({attempt:null,running:!1,done:!1});l.useLayoutEffect(()=>{const $=te.current;$.attempt||($.attempt=wp({selectNow:!yp().sessionId}))},[]),l.useEffect(()=>{const $=te.current,ee=()=>{const Y=$.attempt;if(!Y||$.running||$.done)return;const ie=zt.getState().isInitialized;$.running=!0,Y().then(V=>{if($.running=!1,V!=="failed"||ie){$.done=!0;return}zt.getState().isInitialized&&ee()})};ee()},[n]),l.useEffect(()=>{if(typeof window>"u")return;const $=()=>{Zs("desktop_open_draft_mini_chat_window",{directory:"",projectId:null,...Cr()})};return window.addEventListener("openchamber:open-mini-chat",$),()=>window.removeEventListener("openchamber:open-mini-chat",$)},[]),l.useEffect(()=>{if(typeof window>"u")return;const $=()=>{const ee=et.getState().currentSessionId;ee&&Gc(ee)};return window.addEventListener("focus",$),()=>window.removeEventListener("focus",$)},[]),l.useEffect(()=>{if(typeof window>"u")return;const $=ee=>{const Y=ee.detail,ie=typeof Y?.directory=="string"&&Y.directory.trim().length>0?Y.directory.trim():null,V=typeof Y?.projectId=="string"&&Y.projectId.trim().length>0?Y.projectId.trim():null,fe=!!(ie||V);X.getState().setSessionSwitcherOpen(!1),et.getState().openNewSessionDraft({target:fe?"project":"chat",selectedProjectId:fe?V:null,directoryOverride:fe?ie:null,preserveDirectoryOverride:!!ie})};return window.addEventListener("openchamber:open-draft-session",$),()=>window.removeEventListener("openchamber:open-draft-session",$)},[]),l.useEffect(()=>{typeof window>"u"||!n||p||Z.current||(Z.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,p]),nb(),y3(),vp(f||null),S3(),Sp(t.sourceControl),kp(t.trackers),j3(),N3(),rb(),jp(),E3(),P3(n&&r,_),R3(),ob(),Nb(),Cp();const J=l.useCallback(()=>{h($=>!$)},[]);Vj(J),h3(),Eb(!0),l.useEffect(()=>{const $=()=>h(ee=>!ee);return window.addEventListener("openchamber:memory-debug-toggle",$),()=>window.removeEventListener("openchamber:memory-debug-toggle",$)},[]),l.useEffect(()=>{c&&setTimeout(()=>d(),5e3)},[d,c]),l.useEffect(()=>{if(!v||M!=="not-injected")return;let $=!1,ee=0;const Y=200,ie=2e3,V=50,fe=()=>{if($)return;ee++;const Se=da();if(Se!=="not-injected"){if($=!0,W(Se),Se==="valid"){const ue=Co();ue&&O(ua({isDesktopShell:!0,bootOutcome:ue}))}return}const Te=Math.min(Y*Math.pow(1.1,ee),ie);if(ee>=V){const ue=document.getElementById("initial-loading");ue&&!ue.textContent?.includes("taking longer")&&(ue.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(fe,Te)};return window.setTimeout(fe,Y),()=>{$=!0}},[v,M]);const le=l.useCallback(async()=>{if(wf({isDesktopShell:Bs(),isDesktopLocalOriginActive:Qr()})){await yf();return}window.location.reload()},[]),K=l.useCallback(async()=>{if(!D){k(!1),y(!0);try{await zt.getState().initializeApp()}finally{y(!1)}zt.getState().isInitialized||F($=>$+1)}},[D]),U=$=>{if($.screen==="recovery")return $.variant};if(v&&G&&G.screen!=="main"){if(G.screen==="chooser")return s.jsx(Qt,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(l.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Vl,{mode:"first-launch",localAvailable:G.localAvailable!==!1,onCliAvailable:le,onChooseRemote:()=>{}})})})});const $=U(G),ee=G.screen==="recovery"&&"url"in G?G.url:void 0,Y=G.screen==="recovery"&&"hostId"in G?G.hostId:void 0;return s.jsx(Qt,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(l.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Vl,{mode:"recovery",recoveryVariant:$,recoveryHostUrl:ee,recoveryHostLabel:void 0,recoveryHostId:Y,localAvailable:G.localAvailable!==!1,onCliAvailable:le})})})})}return T&&!n&&!x?s.jsx(Qt,{children:s.jsx(Q3,{onRetry:()=>{K()},isRetrying:D},_)}):s.jsx(Qt,{children:s.jsx(ib,{sdk:Go.getSdkClient(),directory:f||"",children:s.jsx(ab,{apis:t,children:s.jsx(Tp,{children:s.jsx(lb,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:v?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(cb,{backgroundWorkEnabled:!0}),s.jsx(Np,{}),s.jsx(M3,{}),s.jsx(Kk,{}),v?s.jsx(Ep,{ready:H&&P}):null,s.jsx(db,{}),s.jsx(ub,{}),s.jsx(fb,{}),s.jsx(pb,{}),s.jsx(mb,{}),s.jsx(Ip,{}),s.jsx(Y3,{}),m&&s.jsx(J3,{onClose:()=>h(!1)})]})})})})},_)})}function t4(t){const e=$e.c(2);let n;return e[0]!==t?(n=s.jsx(gp,{children:s.jsx(e4,{...t})}),e[0]=t,e[1]=n):n=e[1],n}function s4(t){return t.isAboutDialogOpen}function n4(t){return t.setAboutDialogOpen}function r4(){}function o4(){}function i4(t){return t.lastInitFailure}const a4=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();vf();ku()&&D3();Pp();Rp();Sf().then(()=>{hb().catch(t=>{console.error("[main] settings init failed:",t)}),gb(),bb(),xb()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Cu=document.getElementById("root");if(!Cu)throw new Error("Root element not found");wb();Tu.createRoot(Cu).render(s.jsx(qt.StrictMode,{children:s.jsx(yb,{children:s.jsx(vb,{children:s.jsx(Sb,{children:s.jsx(kb,{children:s.jsx(t4,{apis:a4})})})})})}));const C4=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Ha as P,Y1 as a,Dx as b,j4 as g,C4 as m,$j as o,k4 as r,wd as u};
498
+ `),C0=t=>{const e=$e.c(18),{entries:n,activeIndex:r,onSelect:o,onForget:i,onHighlight:a}=t,{t:u}=at();if(n.length===0)return null;let c;e[0]!==u?(c=u("contextPanel.browser.history.label"),e[0]=u,e[1]=c):c=e[1];let d;if(e[2]!==r||e[3]!==n||e[4]!==i||e[5]!==a||e[6]!==o||e[7]!==u){let p;e[9]!==r||e[10]!==i||e[11]!==a||e[12]!==o||e[13]!==u?(p=(m,h)=>s.jsxs("div",{role:"option","aria-selected":h===r,className:Le("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",h===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:b=>{b.preventDefault(),o(m.url)},onPointerEnter:()=>a(h),children:[s.jsx(se,{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:m.title||eo(m.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:m.url})]}),s.jsx("button",{type:"button",className:Le("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":u("contextPanel.browser.history.forget"),title:u("contextPanel.browser.history.forget"),onPointerDown:b=>{b.preventDefault(),b.stopPropagation(),i(m.url)},children:s.jsx(se,{name:"close",className:"size-3","aria-hidden":"true"})})]},m.url),e[9]=r,e[10]=i,e[11]=a,e[12]=o,e[13]=u,e[14]=p):p=e[14],d=n.map(p),e[2]=r,e[3]=n,e[4]=i,e[5]=a,e[6]=o,e[7]=u,e[8]=d}else d=e[8];let f;return e[15]!==c||e[16]!==d?(f=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":c,children:d}),e[15]=c,e[16]=d,e[17]=f):f=e[17],f},vs=t=>{const e=$e.c(17),{icon:n,label:r,onClick:o,disabled:i,pressed:a}=t,u=a?"secondary":"ghost",c=a&&"text-foreground";let d;e[0]!==c?(d=Le("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",c),e[0]=c,e[1]=d):d=e[1];let f;e[2]!==n?(f=s.jsx(se,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=f):f=e[3];let p;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==a||e[8]!==u||e[9]!==d||e[10]!==f?(p=s.jsx(Ft,{asChild:!0,children:s.jsx(dt,{type:"button",variant:u,size:"xs",className:d,onClick:o,disabled:i,"aria-label":r,"aria-pressed":a,children:f})}),e[4]=i,e[5]=r,e[6]=o,e[7]=a,e[8]=u,e[9]=d,e[10]=f,e[11]=p):p=e[11];let m;e[12]!==r?(m=s.jsx($t,{sideOffset:6,children:r}),e[12]=r,e[13]=m):m=e[13];let h;return e[14]!==p||e[15]!==m?(h=s.jsxs(Lt,{children:[p,m]}),e[14]=p,e[15]=m,e[16]=h):h=e[16],h},Hd=t=>{const e=$e.c(110),{address:n,addressMark:r,suggestions:o,onForgetSuggestion:i,onAddressChange:a,onSubmit:u,onBack:c,onForward:d,onReload:f,onOpenExternal:p,canOpenExternal:m,canGoBack:h,canGoForward:b,isLoading:g,onAnnotate:x,onOpenDevTools:w,isAnnotating:T,onHardReload:k,onZoomIn:E,onZoomOut:F,onZoomReset:_,zoomPercent:A,onClearCookies:D,onClearCache:y,onToggleDeviceBar:N,isDeviceBarOpen:j}=t;let v;e[0]!==o?(v=o===void 0?[]:o,e[0]=o,e[1]=v):v=e[1];const M=v,W=m===void 0?!0:m,G=A===void 0?100:A,{t:O}=at(),[Z,Q]=l.useState(!1),[B,oe]=l.useState(-1);let H;e[2]!==Z||e[3]!==M?(H=Z?M:[],e[2]=Z,e[3]=M,e[4]=H):H=e[4];const P=H;let te;e[5]===Symbol.for("react.memo_cache_sentinel")?(te=()=>{oe(-1)},e[5]=te):te=e[5];let J;e[6]!==n||e[7]!==Z?(J=[n,Z],e[6]=n,e[7]=Z,e[8]=J):J=e[8],l.useEffect(te,J);let le;e[9]!==u?(le=He=>{Q(!1),oe(-1),u(He)},e[9]=u,e[10]=le):le=e[10];const K=le;let U;e[11]!==B||e[12]!==K||e[13]!==P?(U=He=>{if(P.length!==0){if(He.key==="ArrowDown"||He.key==="ArrowUp"){He.preventDefault();const Ke=He.key==="ArrowDown"?1:-1,Ye=P.length;oe(it=>{const bt=it+Ke;return bt<-1?Ye-1:bt>=Ye?-1:bt});return}if(He.key==="Escape"&&B>=0){He.preventDefault(),oe(-1);return}if(He.key==="Enter"&&B>=0){He.preventDefault();const Ke=P[B];Ke&&K(Ke.url)}}},e[11]=B,e[12]=K,e[13]=P,e[14]=U):U=e[14];const $=U;let ee;e[15]!==O?(ee=O("contextPanel.browser.back"),e[15]=O,e[16]=ee):ee=e[16];const Y=!h;let ie;e[17]!==c||e[18]!==ee||e[19]!==Y?(ie=s.jsx(vs,{icon:"arrow-left",label:ee,onClick:c,disabled:Y}),e[17]=c,e[18]=ee,e[19]=Y,e[20]=ie):ie=e[20];let V;e[21]!==O?(V=O("contextPanel.browser.forward"),e[21]=O,e[22]=V):V=e[22];const fe=!b;let Se;e[23]!==d||e[24]!==V||e[25]!==fe?(Se=s.jsx(vs,{icon:"arrow-right",label:V,onClick:d,disabled:fe}),e[23]=d,e[24]=V,e[25]=fe,e[26]=Se):Se=e[26];let Te;e[27]!==g||e[28]!==O?(Te=O(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=g,e[28]=O,e[29]=Te):Te=e[29];let ue;e[30]!==f||e[31]!==Te?(ue=s.jsx(vs,{icon:"refresh",label:Te,onClick:f}),e[30]=f,e[31]=Te,e[32]=ue):ue=e[32];let Me;e[33]!==k||e[34]!==O?(Me=k?s.jsx(vs,{icon:"restart",label:O("contextPanel.browser.hardReload"),onClick:k}):null,e[33]=k,e[34]=O,e[35]=Me):Me=e[35];let Ae;e[36]!==n||e[37]!==K?(Ae=He=>{He.preventDefault(),K(n)},e[36]=n,e[37]=K,e[38]=Ae):Ae=e[38];let De;e[39]!==r?(De=r?s.jsx("span",{className:"pointer-events-none absolute inset-s-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",title:r.label,"aria-label":r.label,role:"img",children:s.jsx(se,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[39]=r,e[40]=De):De=e[40];let Be;e[41]!==a?(Be=He=>a(He.target.value),e[41]=a,e[42]=Be):Be=e[42];let we,ve;e[43]===Symbol.for("react.memo_cache_sentinel")?(we=()=>Q(!0),ve=()=>Q(!1),e[43]=we,e[44]=ve):(we=e[43],ve=e[44]);const Pe=P.length>0,he=r&&"ps-8";let Fe;e[45]!==he?(Fe=Le("oc-raised oc-field h-6 w-full rounded-full bg-[var(--surface-elevated)] px-3",he,"typography-micro text-foreground outline-none"),e[45]=he,e[46]=Fe):Fe=e[46];let _e;e[47]!==O?(_e=O("contextPanel.browser.addressAria"),e[47]=O,e[48]=_e):_e=e[48];let We;e[49]!==n||e[50]!==$||e[51]!==Be||e[52]!==Pe||e[53]!==Fe||e[54]!==_e?(We=s.jsx("input",{value:n,onChange:Be,onFocus:we,onBlur:ve,onKeyDown:$,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":Pe,"aria-controls":"openchamber-browser-address-suggestions",className:Fe,"aria-label":_e}),e[49]=n,e[50]=$,e[51]=Be,e[52]=Pe,e[53]=Fe,e[54]=_e,e[55]=We):We=e[55];let Xe;e[56]!==i?(Xe=He=>i?.(He),e[56]=i,e[57]=Xe):Xe=e[57];let Ve;e[58]!==B||e[59]!==K||e[60]!==Xe||e[61]!==P?(Ve=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(C0,{entries:P,activeIndex:B,onSelect:K,onForget:Xe,onHighlight:oe})}),e[58]=B,e[59]=K,e[60]=Xe,e[61]=P,e[62]=Ve):Ve=e[62];let S;e[63]!==Ae||e[64]!==De||e[65]!==We||e[66]!==Ve?(S=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:Ae,children:[De,We,Ve]}),e[63]=Ae,e[64]=De,e[65]=We,e[66]=Ve,e[67]=S):S=e[67];let ne;e[68]!==E||e[69]!==F||e[70]!==_||e[71]!==O||e[72]!==G?(ne=F&&E?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(vs,{icon:"subtract",label:O("contextPanel.browser.zoomOut"),onClick:F}),G!==100&&_?s.jsxs(Lt,{children:[s.jsx(Ft,{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:_,"aria-label":O("contextPanel.browser.zoomReset"),children:[G,"%"]})}),s.jsx($t,{sideOffset:6,children:O("contextPanel.browser.zoomReset")})]}):null,s.jsx(vs,{icon:"add",label:O("contextPanel.browser.zoomIn"),onClick:E})]}):null,e[68]=E,e[69]=F,e[70]=_,e[71]=O,e[72]=G,e[73]=ne):ne=e[73];let q;e[74]!==D||e[75]!==O?(q=D?s.jsx(vs,{icon:"delete-bin",label:O("contextPanel.browser.clearCookies"),onClick:D}):null,e[74]=D,e[75]=O,e[76]=q):q=e[76];let ke;e[77]!==y||e[78]!==O?(ke=y?s.jsx(vs,{icon:"database-2",label:O("contextPanel.browser.clearCache"),onClick:y}):null,e[77]=y,e[78]=O,e[79]=ke):ke=e[79];let Ee;e[80]!==j||e[81]!==N||e[82]!==O?(Ee=N?s.jsx(vs,{icon:"smartphone",label:O("contextPanel.browser.deviceToolbar"),onClick:N,pressed:j}):null,e[80]=j,e[81]=N,e[82]=O,e[83]=Ee):Ee=e[83];let Ie;e[84]!==T||e[85]!==x||e[86]!==O?(Ie=x?s.jsx(vs,{icon:"markup",label:O("contextPanel.browser.annotate.toggle"),onClick:x,pressed:T}):null,e[84]=T,e[85]=x,e[86]=O,e[87]=Ie):Ie=e[87];let Ne;e[88]!==w||e[89]!==O?(Ne=w?s.jsx(vs,{icon:"terminal-box",label:O("contextPanel.browser.devTools"),onClick:w}):null,e[88]=w,e[89]=O,e[90]=Ne):Ne=e[90];let ze;e[91]!==O?(ze=O("contextPanel.browser.openExternal"),e[91]=O,e[92]=ze):ze=e[92];const Ue=!W;let Ge;e[93]!==p||e[94]!==ze||e[95]!==Ue?(Ge=s.jsx(vs,{icon:"external-link",label:ze,onClick:p,disabled:Ue}),e[93]=p,e[94]=ze,e[95]=Ue,e[96]=Ge):Ge=e[96];let Qe;return e[97]!==ie||e[98]!==Se||e[99]!==ue||e[100]!==Me||e[101]!==S||e[102]!==ne||e[103]!==q||e[104]!==ke||e[105]!==Ee||e[106]!==Ie||e[107]!==Ne||e[108]!==Ge?(Qe=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[ie,Se,ue,Me,S,ne,q,ke,Ee,Ie,Ne,Ge]}),e[97]=ie,e[98]=Se,e[99]=ue,e[100]=Me,e[101]=S,e[102]=ne,e[103]=q,e[104]=ke,e[105]=Ee,e[106]=Ie,e[107]=Ne,e[108]=Ge,e[109]=Qe):Qe=e[109],Qe},qr={kind:"fill"},hl=240,T0=3840,qd=[{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}],gl=t=>Number.isFinite(t)?Math.round(Math.min(T0,Math.max(hl,t))):hl,Kr=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Kd=t=>{const e=qd.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},N0=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},E0=(t,e)=>{const n=Kr(t);if(!n)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/n.width,o/n.height);return{width:n.width,height:n.height,scale:i}},I0=["mobile","tablet","desktop","fill"],P0={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},bl=t=>typeof t=="string"&&I0.includes(t),mi=t=>t==="fill"?qr:Kd(P0[t])??qr,yr=t=>{const e=Kr(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=mi(n),o=Kr(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},R0=t=>{const e=$e.c(70),{viewport:n,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:a}=t,{t:u}=at();let c;e[0]!==n?(c=Kr(n),e[0]=n,e[1]=c):c=e[1];const d=c,f=n.kind==="preset"?n.id:"";let p;e[2]!==r||e[3]!==d?(p=(U,$)=>{const ee=Number.parseInt($,10);if(!Number.isFinite(ee))return;const Y=d??{width:1280,height:800};r({kind:"custom",width:gl(U==="width"?ee:Y.width),height:gl(U==="height"?ee:Y.height)})},e[2]=r,e[3]=d,e[4]=p):p=e[4];const m=p;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Le("oc-raised oc-field h-6 w-14 rounded-full bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none"),e[5]=h):h=e[5];const b=h;let g;e[6]!==r?(g=U=>{const $=Kd(U.target.value);r($??qr)},e[6]=r,e[7]=g):g=e[7];let x;e[8]!==u?(x=u("contextPanel.browser.device.preset"),e[8]=u,e[9]=x):x=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=Le("oc-raised oc-field h-6 shrink-0 rounded-full bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none"),e[10]=w):w=e[10];let T;e[11]!==u?(T=u("contextPanel.browser.device.responsive"),e[11]=u,e[12]=T):T=e[12];let k;e[13]!==T?(k=s.jsx("option",{value:"",children:T}),e[13]=T,e[14]=k):k=e[14];let E;e[15]===Symbol.for("react.memo_cache_sentinel")?(E=qd.map(D0),e[15]=E):E=e[15];let F;e[16]!==f||e[17]!==g||e[18]!==x||e[19]!==k?(F=s.jsxs("select",{value:f,onChange:g,"aria-label":x,className:w,children:[k,E]}),e[16]=f,e[17]=g,e[18]=x,e[19]=k,e[20]=F):F=e[20];const _=d?String(d.width):"";let A;e[21]!==m?(A=U=>m("width",U.target.value),e[21]=m,e[22]=A):A=e[22];let D;e[23]!==u?(D=u("contextPanel.browser.device.width"),e[23]=u,e[24]=D):D=e[24];let y;e[25]!==_||e[26]!==A||e[27]!==D?(y=s.jsx("input",{value:_,onChange:A,placeholder:"—",inputMode:"numeric","aria-label":D,className:b}),e[25]=_,e[26]=A,e[27]=D,e[28]=y):y=e[28];let N;e[29]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=N):N=e[29];const j=d?String(d.height):"";let v;e[30]!==m?(v=U=>m("height",U.target.value),e[30]=m,e[31]=v):v=e[31];let M;e[32]!==u?(M=u("contextPanel.browser.device.height"),e[32]=u,e[33]=M):M=e[33];let W;e[34]!==j||e[35]!==v||e[36]!==M?(W=s.jsx("input",{value:j,onChange:v,placeholder:"—",inputMode:"numeric","aria-label":M,className:b}),e[34]=j,e[35]=v,e[36]=M,e[37]=W):W=e[37];let G;e[38]!==r||e[39]!==n?(G=()=>r(N0(n)),e[38]=r,e[39]=n,e[40]=G):G=e[40];const O=!d;let Z;e[41]!==u?(Z=u("contextPanel.browser.device.rotate"),e[41]=u,e[42]=Z):Z=e[42];let Q;e[43]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(se,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=Q):Q=e[43];let B;e[44]!==G||e[45]!==O||e[46]!==Z?(B=s.jsx(Ft,{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:G,disabled:O,"aria-label":Z,children:Q})}),e[44]=G,e[45]=O,e[46]=Z,e[47]=B):B=e[47];let oe;e[48]!==u?(oe=u("contextPanel.browser.device.rotate"),e[48]=u,e[49]=oe):oe=e[49];let H;e[50]!==oe?(H=s.jsx($t,{sideOffset:6,children:oe}),e[50]=oe,e[51]=H):H=e[51];let P;e[52]!==B||e[53]!==H?(P=s.jsxs(Lt,{children:[B,H]}),e[52]=B,e[53]=H,e[54]=P):P=e[54];let te;e[55]!==a||e[56]!==d?(te=d&&a<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(a*100),"%"]}):null,e[55]=a,e[56]=d,e[57]=te):te=e[57];let J;e[58]===Symbol.for("react.memo_cache_sentinel")?(J=["system","light","dark"],e[58]=J):J=e[58];let le;e[59]!==o||e[60]!==i||e[61]!==u?(le=s.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:J.map(U=>s.jsx(dt,{type:"button",variant:o===U?"secondary":"ghost",size:"xs",className:Le("shrink-0 rounded-full px-2.5 typography-micro",o===U?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(U),"aria-pressed":o===U,children:u(U==="system"?"contextPanel.browser.device.schemeSystem":U==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},U))}),e[59]=o,e[60]=i,e[61]=u,e[62]=le):le=e[62];let K;return e[63]!==F||e[64]!==y||e[65]!==W||e[66]!==P||e[67]!==te||e[68]!==le?(K=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[F,y,N,W,P,te,le]}),e[63]=F,e[64]=y,e[65]=W,e[66]=P,e[67]=te,e[68]=le,e[69]=K):K=e[69],K};function D0(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const Gr=new Map,hi=new Set,Gd=()=>{for(const t of hi)t()},Wo=(t,e)=>{const n=t.trim();n&&(e.length===0?Gr.delete(n):Gr.set(n,[...e]),Gd())},A0=t=>{Gr.delete(t.trim())&&Gd()},Zd=[],_0=t=>Gr.get(t.trim())??Zd,O0=t=>(hi.add(t),()=>{hi.delete(t)}),M0=t=>{const e=$e.c(2);let n;return e[0]!==t?(n=()=>_0(t),e[0]=t,e[1]=n):n=e[1],l.useSyncExternalStore(O0,n,F0)};function F0(){return Zd}const Xd="oc.browser.hiddenDevServerPorts.v1",L0=ni(Ns(),md(mo().int().positive())),gi=new Set,Yd=[];let vr=null;const ta=()=>{const t=to().getItem(Xd);if(vr&&vr.raw===t)return vr.value;let e={};if(t!==null)try{const n=L0.safeParse(JSON.parse(t));n.success&&(e=n.data)}catch{e={}}return vr={raw:t,value:e},e},Jd=t=>{to().setItem(Xd,JSON.stringify(t));for(const e of gi)e()},$0=(t=ns())=>ta()[t]??Yd,B0=t=>{const e=ns(),n=ta(),r=n[e]??[];r.includes(t)||Jd({...n,[e]:[...r,t].sort((o,i)=>o-i)})},z0=()=>{const t=ns(),e=ta();if(!e[t])return;const n={...e};delete n[t],Jd(n)},W0=t=>(gi.add(t),()=>{gi.delete(t)}),U0=()=>l.useSyncExternalStore(W0,V0,H0);function V0(){return $0()}function H0(){return Yd}const q0=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},K0=2e3,G0=t=>gc("http://localhost",t),Qd=t=>{const e=$e.c(62),{onOpen:n,directory:r,visible:o}=t,i=r===void 0?"":r,{t:a}=at();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={kind:"loading"},e[0]=u):u=e[0];const[c,d]=l.useState(u),f=M0(i);let p;e[1]!==i?(p=()=>G0(i),e[1]=i,e[2]=p):p=e[2];const[m]=l.useState(p);let h;e[3]!==i?(h=()=>Lf(i),e[3]=i,e[4]=h):h=e[4];const[b]=l.useState(h);let g;e[5]!==i?(g=ki(i),e[5]=i,e[6]=g):g=e[6];const x=g,w=ea(i),T=Mu(i);let k,E;e[7]!==i||e[8]!==T||e[9]!==o?(k=()=>{if(T){d({kind:"ready",servers:[]});return}if(!o)return;let K=!0,U=null;const $=new AbortController,ee=()=>{Rv($.signal,i).then(Y=>{K&&(d(Y),U=setTimeout(ee,K0))})};return ee(),()=>{K=!1,U&&clearTimeout(U),$.abort()}},E=[i,T,o],e[7]=i,e[8]=T,e[9]=o,e[10]=k,e[11]=E):(k=e[10],E=e[11]),l.useEffect(k,E);const F=ts(Z0),_=et(X0);let A;if(e[12]!==F||e[13]!==_){const K=F.map(Y0);let U;e[15]!==_?(U=[..._].flatMap(J0),e[15]=_,e[16]=U):U=e[16],A=[...K,...U],e[12]=F,e[13]=_,e[14]=A}else A=e[14];const D=A;let y;e[17]!==f||e[18]!==i||e[19]!==c.kind||e[20]!==c.servers||e[21]!==D?(y=Fv({candidates:_v({announced:f,discovered:c.kind==="ready"?c.servers:null}),folders:D,directory:i}),e[17]=f,e[18]=i,e[19]=c.kind,e[20]=c.servers,e[21]=D,e[22]=y):y=e[22];const N=y,j=U0(),[v,M]=l.useState(!1);let W;if(e[23]!==N||e[24]!==j||e[25]!==v){let K;e[27]!==j||e[28]!==v?(K=U=>U.announced||!j.includes(U.port)&&(v||!U.outsideWork),e[27]=j,e[28]=v,e[29]=K):K=e[29],W=N.filter(K),e[23]=N,e[24]=j,e[25]=v,e[26]=W}else W=e[26];const G=W,O=N.length-G.length;let Z;e[30]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(Bh,{width:110,height:110,className:"shrink-0 opacity-20"}),e[30]=Z):Z=e[30];let Q;e[31]!==a?(Q=a("contextPanel.browser.empty"),e[31]=a,e[32]=Q):Q=e[32];let B;e[33]!==Q?(B=s.jsx("span",{className:"typography-ui-header text-foreground",children:Q}),e[33]=Q,e[34]=B):B=e[34];let oe;e[35]!==a?(oe=a("contextPanel.browser.emptyHint"),e[35]=a,e[36]=oe):oe=e[36];let H;e[37]!==oe?(H=s.jsx("span",{className:"typography-micro text-muted-foreground",children:oe}),e[37]=oe,e[38]=H):H=e[38];let P;e[39]!==B||e[40]!==H?(P=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[B,H]}),e[39]=B,e[40]=H,e[41]=P):P=e[41];let te;e[42]!==f||e[43]!==N.length||e[44]!==i||e[45]!==O||e[46]!==x||e[47]!==n||e[48]!==m||e[49]!==w||e[50]!==b||e[51]!==a||e[52]!==G?(te=N.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-start text-muted-foreground",children:f.length>0?a("contextPanel.browser.devServers.justStarted"):a("contextPanel.browser.devServers.title")}),m&&!b?s.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx(hs,{outerClassName:"min-h-0",className:"flex flex-col gap-1 pe-0.5",disableHorizontal:!0,children:G.map(K=>s.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[s.jsxs(dt,{type:"button",variant:"outline",size:"sm",className:Le("min-w-0 flex-1 justify-start gap-2",m&&"cursor-default opacity-60"),"aria-disabled":m||void 0,onClick:()=>{m||(A0(i),n(K.url))},children:[x?s.jsx("span",{className:"shrink-0",role:"img","aria-label":w??a("contextPanel.browser.spaceAddress"),title:w??a("contextPanel.browser.spaceAddress"),children:s.jsx(se,{name:"instance",className:"size-3.5","aria-hidden":"true"})}):s.jsx(se,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsxs("span",{className:"truncate",children:[eo(K.url)||K.url,s.jsx("span",{className:"typography-micro text-muted-foreground",children:q0(K.url)})]}),b?s.jsx("span",{className:"ms-auto shrink-0 text-muted-foreground",role:"img","aria-label":a("contextPanel.browser.devServers.spaceOnlyDesktop"),title:a("contextPanel.browser.devServers.spaceOnlyDesktop"),children:s.jsx(se,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):K.folderName?s.jsxs("span",{className:"ms-auto flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",title:K.directory,children:[s.jsx(se,{name:"folder",className:"size-3 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",dir:"auto",children:K.folderName})]}):null]}),K.announced?null:s.jsx(dt,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground opacity-0 group-hover/server:opacity-100 focus-visible:opacity-100",onClick:()=>B0(K.port),"aria-label":a("contextPanel.browser.devServers.hide",{port:K.port}),title:a("contextPanel.browser.devServers.hide",{port:K.port}),children:s.jsx(se,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})]},K.port))}),O>0?s.jsx(dt,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:()=>{z0(),M(!0)},children:O===1?a("contextPanel.browser.devServers.showHiddenSingle",{count:O}):a("contextPanel.browser.devServers.showHiddenPlural",{count:O})}):null]}):null,e[42]=f,e[43]=N.length,e[44]=i,e[45]=O,e[46]=x,e[47]=n,e[48]=m,e[49]=w,e[50]=b,e[51]=a,e[52]=G,e[53]=te):te=e[53];let J;e[54]!==N.length||e[55]!==c.kind||e[56]!==a?(J=N.length===0&&c.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.unavailable")}):null,e[54]=N.length,e[55]=c.kind,e[56]=a,e[57]=J):J=e[57];let le;return e[58]!==P||e[59]!==te||e[60]!==J?(le=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:[Z,P,te,J]}),e[58]=P,e[59]=te,e[60]=J,e[61]=le):le=e[61],le};function Z0(t){return t.projects}function X0(t){return t.availableWorktreesByProject}function Y0(t){return{path:t.path,projectPath:t.path}}function J0(t){const[e,n]=t;return n.map(r=>({path:r.path,projectPath:e}))}const Q0=3e4,eS=3,tS=250,sS={attempts:0,windowStartedAt:null},nS=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=Q0,r=n?0:t.attempts;return r>=eS?null:{delayMs:tS*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},rS=-3,Sr=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",jn=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},oS=(t,{initialUrl:e,onUrlChange:n})=>{const[r,o]=l.useState(e?{kind:"loading",url:e}:zh),[i,a]=l.useState(e),[u,c]=l.useState(""),[d,f]=l.useState(!1),[p,m]=l.useState(!1),h=l.useRef(n);h.current=n;const b=l.useRef(sS);return l.useEffect(()=>{if(!t)return;const g=()=>{try{const N=t.getURL();return Sr(N)?N:""}catch{return""}},x=()=>{try{f(t.canGoBack()),m(t.canGoForward())}catch{}},w=N=>{Sr(N)&&(a(N),h.current(N))},T=()=>{const N=g();o({kind:"loading",url:N})},k=()=>{const N=g();let j="";try{j=t.getTitle()||""}catch{j=""}c(j),w(N),x(),o(v=>v.kind==="failed"?v:{kind:"ready",url:N,title:j})},E=N=>{const j=jn(N);Sr(j.url)&&(w(j.url),x())},F=N=>{const j=jn(N),v=Array.isArray(j.favicons)?j.favicons.find(Boolean):"",M=g();if(!v||!M)return;let W=-1;try{W=t.getWebContentsId()}catch{return}!Number.isFinite(W)||W<0||Id.getState().resolve(M,v,W)},_=N=>{const j=jn(N);typeof j.title=="string"&&c(j.title)},A=N=>{const j=jn(N);if(j.isMainFrame===!1)return;const v=typeof j.errorCode=="number"?j.errorCode:0;v!==rS&&o({kind:"failed",url:Sr(j.validatedURL)?j.validatedURL:g(),code:v,description:typeof j.errorDescription=="string"?j.errorDescription:""})};let D=null;const y=()=>{const N=g(),j=nS(b.current,Date.now());if(!j){o({kind:"failed",url:N,code:0,description:"",crashed:!0});return}b.current=j.state,o({kind:"loading",url:N}),D=setTimeout(()=>{D=null;try{t.reload()}catch{o({kind:"failed",url:N,code:0,description:"",crashed:!0})}},j.delayMs)};t.addEventListener("did-start-loading",T),t.addEventListener("did-stop-loading",k),t.addEventListener("did-navigate",E),t.addEventListener("did-navigate-in-page",E),t.addEventListener("page-title-updated",_),t.addEventListener("page-favicon-updated",F),t.addEventListener("did-fail-load",A),t.addEventListener("render-process-gone",y),t.addEventListener("crashed",y);try{!t.isLoading()&&g()&&k()}catch{}return()=>{D!==null&&clearTimeout(D),t.removeEventListener("render-process-gone",y),t.removeEventListener("crashed",y),t.removeEventListener("did-start-loading",T),t.removeEventListener("did-stop-loading",k),t.removeEventListener("did-navigate",E),t.removeEventListener("did-navigate-in-page",E),t.removeEventListener("page-title-updated",_),t.removeEventListener("page-favicon-updated",F),t.removeEventListener("did-fail-load",A)}},[t]),{status:r,url:i,title:u,canGoBack:d,canGoForward:p}},xl=1e3,eu=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},iS=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},aS=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},lS=(t,e)=>{const n=l.useRef(0),r=l.useRef(0),o=l.useRef(0),i=l.useRef(null),a=l.useCallback(()=>{if(!t||document.activeElement!==t)return;const u=i.current;u&&u.isConnected&&u!==document.body?u.focus({preventScroll:!0}):t.blur()},[t]);return l.useEffect(()=>{if(!t)return;document.activeElement!==t&&(i.current=aS());const u=c=>{if(document.activeElement!==t){i.current=iS(c);return}const d=e.current,f=n.current>r.current||Date.now()<o.current;d&&eu(d)&&!f||r.current>0||a()};return document.addEventListener("focusin",u,!0),()=>document.removeEventListener("focusin",u,!0)},[a,e,t]),l.useCallback(async u=>{const c=t!==null&&document.activeElement===t;let d=!1;const f=()=>{d&&(d=!1,r.current-=1,o.current=Date.now()+xl,!c&&r.current===0&&a())},p=()=>(d||(d=!0,r.current+=1),f);n.current+=1;try{return await u(p)}finally{n.current-=1,o.current=Date.now()+xl,f()}},[a,t])},cS=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),dS=()=>document.visibilityState==="visible",uS=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,kr=.5,fS=-3,pS=4,mS="persist:openchamber-browser",tu=(t,e,n)=>ks(t)!==null&&Jl(e)?{icon:"instance",label:n}:void 0,wl=t=>{const e=ks(t);return e?`openchamber-space-preview:${e}`:mS},yl="openchamber:browser-panel-open-tab",hS=Qs({webContentsId:mo(),url:Ns().min(1),background:ar()}),vl=20,gS=600,bS=2e4,xS=15e3,Sl=500,kl=5e3,wS=3e4,yS=3e3,jl=1e3,vS=250,SS=Qs({quiet:ar()}),kS=()=>new Promise(t=>{let e=0,n=0,r=0,o;const i=d=>{clearTimeout(o),t(d)},a=()=>{e+=1,e>=2?i(!0):requestAnimationFrame(a)},u=()=>{n=e,r=performance.now()+jl,o=setTimeout(c,jl)},c=()=>{e>n||performance.now()-r>vS?u():i(!1)};requestAnimationFrame(a),u()}),jS=t=>{if(!t||eu(t))return()=>{};const e=t.getBoundingClientRect(),n=t.style.cssText;return Object.assign(t.style,{position:"fixed",top:`${e.top}px`,left:`${Math.max(0,Math.min(e.left,window.innerWidth-e.width))}px`,width:`${e.width}px`,height:`${e.height}px`,visibility:"visible",opacity:"0",pointerEvents:"none"}),()=>{t.style.cssText=n}},CS=({initialUrl:t,directory:e,siteDirectory:n,tabID:r,ownerSessionId:o,visible:i})=>{const{t:a}=at(),{currentTheme:u}=so(),c=l.useRef(null),[d,f]=l.useState(null),p=l.useCallback(ae=>{c.current=ae,f(ae)},[]),m=X(ae=>ae.setContextPanelTabTargetPath),h=l.useRef(Cn(t)),b=h.current!==Gs?h.current:"",[g,x]=l.useState(b?null:Gs),w=ea(n),[T,k]=l.useState(b),[E,F]=l.useState(!1),[_,A]=l.useState(!1),[D,y]=l.useState(0),N=l.useRef(0),[j,v]=l.useState(!1),[M,W]=l.useState(qr),G=l.useRef(M);G.current=M;const O=l.useRef([]),[Z,Q]=l.useState("system"),[B,oe]=l.useState({width:0,height:0}),H=l.useRef(null),P=l.useRef(null),te=cs(e),J=l.useRef(!!b&&!Fu(te,r)),le=l.useRef(null);l.useEffect(()=>{Yl(te,r)},[te,r]);const K=l.useRef(!1),U=l.useRef(Date.now()),$=l.useCallback(ae=>{!ae||ae===Gs||!e||!r||m(e,r,ae)},[e,r,m]),ee=oS(d,{initialUrl:b,onUrlChange:l.useCallback(ae=>{const de=xn(ae);k(de),$(de)},[$])}),[Y,ie]=l.useState(null),[V,fe]=l.useState(ks(n)===null);l.useEffect(()=>{const ae=ks(n);if(ae===null){fe(!0);return}let de=!0;return fe(!1),kn("desktop_space_preview_prepare",{spaceId:ae}).then(()=>{de&&fe(!0)}).catch(()=>{de&&ie(b||"http://localhost/")}),()=>{de=!1}},[n,b]);const Se=Wh(e),Te=Uh(),ue=ee.status.kind==="loading",Me=Nn(Vd(n)),Ae=Nn(ae=>ae.recordVisit),De=Nn(ae=>ae.forget);l.useEffect(()=>{ee.status.kind==="ready"&&Ae(n,{url:xn(ee.status.url),title:ee.status.title})},[n,ee.status,Ae]);const Be=l.useMemo(()=>Ud(Me,T),[Me,T]),we=l.useCallback(ae=>{const de=Cn(ae);de!==Gs&&(J.current=!1,k(de),ie(null),xa(de,n).then(be=>{const C=c.current;if(!C){x(be);return}try{C.loadURL(be)}catch{x(be)}}).catch(be=>{be instanceof wa&&ie(de)}))},[n]);l.useEffect(()=>{if(!b)return;let ae=!0;return xa(b,n).then(de=>{ae&&x(de)}).catch(de=>{if(ae){if(de instanceof wa){ie(b),J.current=!1,x(Gs);return}x(b)}}),()=>{ae=!1}},[]);const ve=l.useMemo(()=>({executeJavaScript:async(ae,de)=>{const be=c.current;if(!be)throw new Error("Browser view is not available");return be.executeJavaScript(ae,de)},capturePage:async()=>{const ae=c.current;if(!ae)return null;const de=ae.getWebContentsId();return Number.isFinite(de)?await kn("desktop_browser_capture_page",{webContentsId:de}):null}}),[]),Pe=l.useCallback(()=>{if(E){F(!1),Io(ve);return}if(!ee.url){Re.error(a("contextPanel.browser.annotate.noPage"));return}const ae=Vh(u.metadata.variant==="light"?"light":"dark");F(!0),Hh({host:ve,theme:ae,labels:Te}).then(async de=>{F(!1),de&&await Se(de)}).catch(()=>{F(!1),Re.error(a("contextPanel.browser.annotate.failed"))})},[ve,Se,u,E,ee.url,Te,a]);l.useEffect(()=>{if(!E)return;const ae=de=>{Ic(de)||de.key!=="Escape"||(de.preventDefault(),de.stopImmediatePropagation(),F(!1),Io(ve))};return window.addEventListener("keydown",ae,!0),()=>window.removeEventListener("keydown",ae,!0)},[ve,E]);const he=l.useRef(!1);l.useEffect(()=>{if(!d)return;const ae=()=>{he.current=!0};return d.addEventListener("dom-ready",ae),d.addEventListener("did-fail-load",ae),()=>{d.removeEventListener("dom-ready",ae),d.removeEventListener("did-fail-load",ae)}},[d]);const Fe=l.useCallback(async()=>{const ae=Date.now()+xS;for(;!(c.current&&he.current)&&Date.now()<ae;)await new Promise(de=>setTimeout(de,100));return c.current},[]),_e=l.useCallback(async(ae=8e3)=>{const de=Date.now();for(;;){const be=c.current;if(!be)return!1;let C=!1;try{C=be.isLoading()}catch{return!1}if(!C)return!0;if(Date.now()-de>ae)return!1;await new Promise(ce=>setTimeout(ce,120))}},[]),We=l.useCallback(async(ae,de)=>{const be=S0({quietMs:Sl,maxMs:de});let C;const ce=new Promise(L=>{C=setTimeout(()=>L(null),de+1e3)});try{const L=SS.safeParse(await Promise.race([ae.executeJavaScript(be,!1),ce]));return L.success&&L.data.quiet}catch{return!1}finally{clearTimeout(C)}},[]),Xe=l.useCallback(async(ae,de=wS)=>{const be=Date.now(),C=await _e(Math.min(25e3,Math.max(0,de-kl))),ce=de-(Date.now()-be),L=C&&ce>Sl&&await We(ae,Math.min(kl,ce));let ge="";try{ge=ae.getTitle()||""}catch{ge=""}return{title:ge,settled:L}},[_e,We]),Ve=l.useCallback(async(ae,de,be)=>{const C=await Fe();if(!C)throw new Error("The browser panel is not ready");const ce=()=>{bl(de.viewport)&&(W(mi(de.viewport)),v(!0))};if(ae==="browser.back"||ae==="browser.forward"){const je=ae==="browser.back";if(!(je?C.canGoBack():C.canGoForward()))throw new Error(je?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");je?C.goBack():C.goForward(),await new Promise(ot=>setTimeout(ot,150)),await _e();let ye="";try{ye=C.getTitle()||""}catch{ye=""}return{url:xn(C.getURL()),title:ye}}if(ae==="browser.capture"){const je=jS(H.current);try{if(!await kS())throw new Error("The OpenChamber window is not being drawn (minimized, on a workspace or tab that is not shown, or the screen is locked or off), so nothing can be captured. browser.snapshot still reads the page.");await _e()&&await We(C,yS);const st=await ve.capturePage();if(!st)throw new Error("The page could not be captured");let ye="";try{ye=C.getTitle()||""}catch{ye=""}return{...st,url:xn(C.getURL()),title:ye,viewport:yr(G.current)}}finally{je()}}if(ae==="browser.resize"){if(!bl(de.viewport))throw new Error("viewport is required");return ce(),await new Promise(je=>setTimeout(je,200)),await _e(),{viewport:yr(mi(de.viewport))}}if(ae==="browser.open"){const je=typeof de.url=="string"?de.url:"";if(!je)throw new Error("url is required");return ce(),we(je),await new Promise(st=>setTimeout(st,150)),{url:Cn(je),...await Xe(C),opened:!0,viewport:yr(G.current)}}if(ae==="browser.settle"){const je=mo().safeParse(de.budgetMs);return Xe(C,je.success?je.data:void 0)}await _e();const L=je=>typeof je=="string"&&je?je:void 0,Ce=(()=>{switch(ae){case"browser.snapshot":return b0({selector:L(de.selector)});case"browser.click":return x0({selector:L(de.selector),text:L(de.text)});case"browser.type":return w0({selector:String(de.selector??""),value:String(de.value??""),submit:de.submit===!0});case"browser.select":return y0({selector:String(de.selector??""),label:typeof de.label=="string"?de.label:void 0,value:typeof de.value=="string"?de.value:void 0});case"browser.inspect":return j0({selector:String(de.selector??"")});case"browser.scroll":return v0({selector:L(de.selector),direction:L(de.direction)});default:return null}})();if(!Ce)throw new Error(`Unsupported browser action: ${ae}`);let Je=()=>{};(ae==="browser.click"||ae==="browser.type")&&(await kn("desktop_browser_keep_page_focused",{webContentsId:C.getWebContentsId()}).then(st=>st.focused===!0).catch(()=>!1)||(Je=be(),C.focus({preventScroll:!0})));let Oe;try{Oe=await C.executeJavaScript(Ce,!0)}finally{Je()}if(!Oe||typeof Oe!="object")throw new Error("The page returned no result");const me=Oe;if(me.ok!==!0)throw new Error(typeof me.error=="string"&&me.error?me.error:"Browser action failed");if(ae==="browser.snapshot"){const je=O.current;return{...me,viewport:yr(G.current),...je.length>0?{consoleProblems:[...je]}:{}}}return(ae==="browser.click"||ae==="browser.select"||ae==="browser.type"&&de.submit===!0)&&(await new Promise(je=>setTimeout(je,150)),await _e()),Oe},[ve,we,Xe,_e,We,Fe]),S=lS(d,H),[ne,q]=l.useState(!1),ke=l.useCallback((ae,de)=>(q(!0),S(be=>Ve(ae,de,be))),[S,Ve]),Ee=l.useCallback(()=>{const ae=c.current;if(!ae)return{title:"",url:""};let de="",be="";try{de=ae.getTitle()||""}catch{de=""}try{be=xn(ae.getURL())}catch{be=""}return{title:de,url:be}},[]);l.useEffect(()=>Jv({tabId:r,directory:te,ownerSessionId:o,describe:Ee,run:ke}),[Ee,o,ke,te,r]),l.useEffect(()=>{const ae=ve;return()=>{Io(ae)}},[ve]),l.useEffect(()=>{if(!d)return;const ae=be=>{const C=be;if(typeof C.level!="number"||C.level<2)return;const ce=C.sourceId?`${C.sourceId}${C.line?`:${C.line}`:""}`:"";O.current.push({level:C.level>=3?"error":"warning",message:String(C.message??"").slice(0,400),source:ce}),O.current.length>vl&&O.current.splice(0,O.current.length-vl)},de=()=>{O.current=[]};return d.addEventListener("console-message",ae),d.addEventListener("did-start-loading",de),()=>{d.removeEventListener("console-message",ae),d.removeEventListener("did-start-loading",de)}},[d]);const Ie=l.useRef(new Set),Ne=l.useCallback(ae=>{Ie.current.clear(),we(ae)},[we]),ze=l.useRef(ee.status);ze.current=ee.status;const Ue=l.useRef(!1);ee.status.kind==="ready"&&ee.status.url&&(Ue.current=!0),l.useEffect(()=>Lu(te,r,ae=>{Bu(ze.current,Ue.current)&&Ne(ae)}),[Ne,te,r]),l.useEffect(()=>{if(!d)return;const ae=be=>{const C=jn(be),ce=typeof C.url=="string"?C.url:"";!ce||!ya(ce,n)||(be.preventDefault(),we(ce))},de=be=>{const C=jn(be);if(C.isMainFrame===!1||C.errorCode===-3)return;const ce=typeof C.validatedURL=="string"?C.validatedURL:"";!ce||!ya(ce,n)||Ie.current.has(ce)||(Ie.current.add(ce),we(ce))};return d.addEventListener("will-navigate",ae),d.addEventListener("did-fail-load",de),()=>{d.removeEventListener("will-navigate",ae),d.removeEventListener("did-fail-load",de)}},[n,we,d]),l.useEffect(()=>{if(!d)return;const ae=de=>{if(!(de instanceof CustomEvent))return;const be=hS.safeParse(de.detail);if(!be.success)return;let C=-1;try{C=d.getWebContentsId()}catch{return}be.data.webContentsId===C&&X.getState().openContextBrowser(te,be.data.url,{reveal:!be.data.background})};return window.addEventListener(yl,ae),()=>window.removeEventListener(yl,ae)},[te,d]);const Ge=l.useCallback(ae=>{const de=Math.min(pS,Math.max(fS,ae));N.current=de,y(de);try{c.current?.setZoomLevel(de)}catch{}},[]);l.useEffect(()=>{const ae=de=>{if(!(de instanceof CustomEvent))return;const be=de.detail,C=c.current;!C||document.activeElement!==C||(be==="zoom-in"?Ge(N.current+kr):be==="zoom-out"?Ge(N.current-kr):be==="zoom-reset"&&Ge(0))};return window.addEventListener("openchamber:zoom",ae),()=>window.removeEventListener("openchamber:zoom",ae)},[Ge]);const Qe=l.useCallback(ae=>{kn("desktop_browser_clear_data",{partition:wl(n),cookies:ae==="cookies",cache:ae==="cache"}).then(()=>{Re.success(a(ae==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{c.current?.reloadIgnoringCache()}catch{}}).catch(()=>Re.error(a("contextPanel.browser.clearFailed")))},[n,a]);l.useEffect(()=>{const ae=H.current;if(!ae||typeof ResizeObserver>"u")return;const de=new ResizeObserver(be=>{const C=be[0]?.contentRect;C&&oe({width:C.width,height:C.height})});return de.observe(ae),()=>de.disconnect()},[]);const He=l.useCallback(ae=>{Q(ae);const de=c.current;if(!de)return;let be=-1;try{be=de.getWebContentsId()}catch{return}kn("desktop_browser_set_color_scheme",{webContentsId:be,scheme:ae}).catch(C=>{Q("system"),Re.error(C instanceof Error?C.message:a("contextPanel.browser.device.schemeFailed"))})},[a]),Ke=l.useCallback(()=>{try{ue?c.current?.stop():c.current?.reload()}catch{}},[ue]),Ye=ee.status,it=l.useSyncExternalStore(cS,dS),bt=i&&it||o!==null||ne;l.useEffect(()=>{const ae=L=>{A(!0);const ge=setTimeout(()=>{try{c.current?.reload()}catch{}},L);return()=>clearTimeout(ge)};if(Ye.kind==="loading")return;const de=J.current||le.current===Ye;if(J.current&&(Ye.kind==="failed"||Ye.kind==="ready"&&Ye.url)&&(J.current=!1,le.current=Ye),Ye.kind==="failed"){const L=$u(Ye,{run:P.current,restored:de,watched:bt,now:Date.now()});if(P.current=L.run,L.next==="retry")return ae(L.delayMs);A(L.next==="pause");return}if(P.current=null,Ye.kind!=="ready"||!Ye.url||!Jl(Ye.url)){K.current=!0,A(!1);return}if(de||K.current||Date.now()-U.current>bS){K.current=!0,A(!1);return}let be=!1,C=null;return(ks(n)?Promise.resolve(null):Dv(xn(Ye.url))).then(L=>{if(!be){if(L===null||L<500){K.current=!0,A(!1);return}C=ae(gS)}}),()=>{be=!0,C?.()}},[n,Ye,bt]);const nt=ee.status.kind==="failed"&&!_?ee.status:null,ft=E0(M,B);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Hd,{address:T,onAddressChange:k,onSubmit:Ne,suggestions:Be,onForgetSuggestion:ae=>De(n,ae),onBack:()=>{try{c.current?.goBack()}catch{}},onForward:()=>{try{c.current?.goForward()}catch{}},onReload:Ke,onOpenExternal:()=>{On(ee.url||T)},addressMark:tu(n,T,w??a("contextPanel.browser.spaceAddress")),canOpenExternal:ks(n)===null,canGoBack:ee.canGoBack,canGoForward:ee.canGoForward,isLoading:ue,onAnnotate:Pe,isAnnotating:E,onOpenDevTools:()=>{try{c.current?.openDevTools()}catch{}},onHardReload:()=>{try{c.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>Ge(D+kr),onZoomOut:()=>Ge(D-kr),onZoomReset:()=>Ge(0),zoomPercent:Math.round(Math.pow(1.2,D)*100),onClearCookies:()=>Qe("cookies"),onClearCache:()=>Qe("cache"),onToggleDeviceBar:()=>v(ae=>!ae),isDeviceBarOpen:j}),j?s.jsx(R0,{viewport:M,onViewportChange:W,colorScheme:Z,onColorSchemeChange:He,scale:ft?.scale??1}):null,s.jsxs("div",{ref:H,className:Le("relative min-h-0 flex-1 bg-background",ft&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null&&V?s.jsx("webview",{ref:p,src:g,partition:wl(n),allowpopups:"true",webpreferences:o!==null?"backgroundThrottling=no":void 0,style:ft?{width:`${ft.width}px`,height:`${ft.height}px`,transform:`scale(${ft.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,g!==null&&!b&&!ee.url&&!ue?s.jsx(Qd,{onOpen:Ne,directory:n,visible:i}):null,_?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:a("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.waitingForServerHint")})]}):null,Y?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[ks(n)!==null?s.jsx(se,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,s.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:a(ks(n)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:Y})})]}):null,nt&&!Y?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:nt.crashed?a("contextPanel.browser.crashed"):a("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:nt.crashed?a("contextPanel.browser.crashedHint"):nt.description||a("contextPanel.browser.loadFailedUnknown")})]}):null,ue?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 bg-[var(--primary)]"})}):null]})]})},TS=t=>{const e=$e.c(75),{initialUrl:n,directory:r,siteDirectory:o,tabID:i,visible:a}=t,{t:u}=at(),c=X(ES);let d;e[0]!==n?(d=Cn(n),e[0]=n,e[1]=d):d=e[1];const f=d,p=f!==Gs?f:"",[m,h]=l.useState(p);let b;e[2]!==o||e[3]!==p?(b=To(p,o),e[2]=o,e[3]=p,e[4]=b):b=e[4];const[g,x]=l.useState(b);let w;e[5]!==o||e[6]!==p?(w=gc(p,o)?p:"",e[5]=o,e[6]=p,e[7]=w):w=e[7];const[T,k]=l.useState(w);let E;e[8]!==o?(E=ks(o),e[8]=o,e[9]=E):E=e[9];const F=E!==null,_=ea(o);let A;e[10]!==p?(A=p?[p]:[],e[10]=p,e[11]=A):A=e[11];const[D,y]=l.useState(A),[N,j]=l.useState(p?0:-1),[v,M]=l.useReducer(IS,0);let W,G;e[12]!==i||e[13]!==r?(W=()=>{Yl(cs(r),i)},G=[r,i],e[12]=i,e[13]=r,e[14]=W,e[15]=G):(W=e[14],G=e[15]),l.useEffect(W,G);let O;e[16]!==c||e[17]!==i||e[18]!==r?(O=Be=>{!Be||Be===Gs||!r||!i||c(r,i,Be)},e[16]=c,e[17]=i,e[18]=r,e[19]=O):O=e[19];const Z=O;let Q;e[20]!==o?(Q=Vd(o),e[20]=o,e[21]=Q):Q=e[21];const B=Nn(Q),oe=Nn(PS),H=Nn(RS);let P;e[22]!==m||e[23]!==B?(P=Ud(B,m),e[22]=m,e[23]=B,e[24]=P):P=e[24];const te=P;let J;e[25]!==o||e[26]!==N||e[27]!==Z||e[28]!==oe?(J=Be=>{const we=Cn(Be);if(we===Gs)return;h(we);const ve=To(we,o);x(ve),k(ve?"":we),Z(we),oe(o,{url:we}),y(Pe=>{const he=N>=0?Pe.slice(0,N+1):[];return he[he.length-1]===we?(j(he.length-1),he):(j(he.length),[...he,we])})},e[25]=o,e[26]=N,e[27]=Z,e[28]=oe,e[29]=J):J=e[29];const le=J;let K;e[30]!==o||e[31]!==D||e[32]!==Z?(K=Be=>{const we=D[Be];if(!we)return;j(Be),h(we);const ve=To(we,o);x(ve),k(ve?"":we),Z(we)},e[30]=o,e[31]=D,e[32]=Z,e[33]=K):K=e[33];const U=K;let $;e[34]!==o||e[35]!==H?($=Be=>H(o,Be),e[34]=o,e[35]=H,e[36]=$):$=e[36];let ee,Y;e[37]!==U||e[38]!==N?(ee=()=>U(N-1),Y=()=>U(N+1),e[37]=U,e[38]=N,e[39]=ee,e[40]=Y):(ee=e[39],Y=e[40]);let ie;e[41]!==m||e[42]!==g?(ie=()=>{On(g||m)},e[41]=m,e[42]=g,e[43]=ie):ie=e[43];let V;e[44]!==_||e[45]!==u?(V=_??u("contextPanel.browser.spaceAddress"),e[44]=_,e[45]=u,e[46]=V):V=e[46];let fe;e[47]!==m||e[48]!==o||e[49]!==V?(fe=tu(o,m,V),e[47]=m,e[48]=o,e[49]=V,e[50]=fe):fe=e[50];const Se=!T,Te=N>0,ue=N>=0&&N<D.length-1;let Me;e[51]!==m||e[52]!==le||e[53]!==te||e[54]!==$||e[55]!==ee||e[56]!==Y||e[57]!==ie||e[58]!==fe||e[59]!==Se||e[60]!==Te||e[61]!==ue?(Me=s.jsx(Hd,{address:m,onAddressChange:h,onSubmit:le,suggestions:te,onForgetSuggestion:$,onBack:ee,onForward:Y,onReload:M,onOpenExternal:ie,addressMark:fe,canOpenExternal:Se,canGoBack:Te,canGoForward:ue,isLoading:!1}),e[51]=m,e[52]=le,e[53]=te,e[54]=$,e[55]=ee,e[56]=Y,e[57]=ie,e[58]=fe,e[59]=Se,e[60]=Te,e[61]=ue,e[62]=Me):Me=e[62];let Ae;e[63]!==o||e[64]!==F||e[65]!==g||e[66]!==le||e[67]!==v||e[68]!==u||e[69]!==T||e[70]!==a?(Ae=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:T?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[F?s.jsx(se,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,s.jsx("span",{className:"typography-ui-header text-foreground",children:u(F?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:eo(T)})}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:u("contextPanel.browser.remoteLoopback.hint")})]}):g?s.jsx("iframe",{src:g,title:u("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(Qd,{onOpen:le,directory:o,visible:a})}),e[63]=o,e[64]=F,e[65]=g,e[66]=le,e[67]=v,e[68]=u,e[69]=T,e[70]=a,e[71]=Ae):Ae=e[71];let De;return e[72]!==Me||e[73]!==Ae?(De=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Me,Ae]}),e[72]=Me,e[73]=Ae,e[74]=De):De=e[74],De},NS=t=>{const e=$e.c(3),[n]=l.useState(uS);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(CS,{...t}):s.jsx(TS,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function ES(t){return t.setContextPanelTabTargetPath}function IS(t){return t+1}function PS(t){return t.recordVisit}function RS(t){return t.forget}const DS=t=>{const e=$e.c(13),{zone:n,children:r}=t,[o]=l.useState(AS);let i;e[0]!==n?(i=m=>m.body[n],e[0]=n,e[1]=i):i=e[1];const a=lr(i);let u,c;e[2]!==a||e[3]!==o||e[4]!==n?(u=()=>{const m=a??lr.getState().body[n];if(!m){o.remove();return}if(o.parentElement===m)return;const h=document.activeElement;m.moveBefore&&o.isConnected?m.moveBefore(o,null):m.append(o),h instanceof HTMLElement&&o.contains(h)&&document.activeElement!==h&&h.focus({preventScroll:!0})},c=[a,o,n],e[2]=a,e[3]=o,e[4]=n,e[5]=u,e[6]=c):(u=e[5],c=e[6]),l.useLayoutEffect(u,c);let d,f;e[7]!==o?(d=()=>()=>o.remove(),f=[o],e[7]=o,e[8]=d,e[9]=f):(d=e[8],f=e[9]),l.useLayoutEffect(d,f);let p;return e[10]!==r||e[11]!==o?(p=Hl.createPortal(r,o),e[10]=r,e[11]=o,e[12]=p):p=e[12],p};function AS(){const t=document.createElement("div");return t.style.display="contents",t}const _S=200,su=t=>`${t.path}:${t.line}:${t.column}`,Cl={status:"idle"},OS=t=>{const e=$e.c(9),{searchContents:n,directory:r,query:o,regex:i,includeHidden:a,respectGitignore:u,active:c}=t,[d,f]=l.useState(Cl);let p,m;return e[0]!==c||e[1]!==r||e[2]!==a||e[3]!==o||e[4]!==i||e[5]!==u||e[6]!==n?(p=()=>{if(!c||!n||!r||!o.trim()){f(Cl);return}const h=new AbortController;let b=!1;return f({status:"searching"}),n({directory:r,query:o,regex:i,limit:_S,includeHidden:a,respectGitignore:u,signal:h.signal}).then(g=>{b||f(g.status==="ok"?{status:"results",matches:g.matches,stopped:g.stopped}:g)}).catch(g=>{b||f({status:"failed",message:g instanceof Error?g.message:String(g)})}),()=>{b=!0,h.abort()}},m=[c,r,a,o,i,u,n],e[0]=c,e[1]=r,e[2]=a,e[3]=o,e[4]=i,e[5]=u,e[6]=n,e[7]=p,e[8]=m):(p=e[7],m=e[8]),l.useEffect(p,m),d},on=t=>{const e=$e.c(5),{className:n,children:r}=t;let o;e[0]!==n?(o=Le("px-2 py-1 typography-meta text-muted-foreground",n),e[0]=n,e[1]=o):o=e[1];let i;return e[2]!==r||e[3]!==o?(i=s.jsx("li",{className:o,children:r}),e[2]=r,e[3]=o,e[4]=i):i=e[4],i},MS=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},FS=t=>{const e=$e.c(44),{state:n,activeMatchKey:r,onOpen:o,onDragStart:i,onDragEnd:a}=t,{t:u}=at();switch(n.status){case"idle":return null;case"searching":{let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(se,{name:"loader-4",className:"h-4 w-4 animate-spin"}),e[0]=p):p=e[0];let m;e[1]!==u?(m=u("sidebarFilesTree.state.searching"),e[1]=u,e[2]=m):m=e[2];let h;return e[3]!==m?(h=s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[p,m]}),e[3]=m,e[4]=h):h=e[4],h}case"unavailable":{let p;e[5]!==u?(p=u("sidebarFilesTree.contentSearch.unavailable"),e[5]=u,e[6]=p):p=e[6];let m;return e[7]!==p?(m=s.jsx(on,{children:p}),e[7]=p,e[8]=m):m=e[8],m}case"invalid-pattern":{let p;e[9]!==u?(p=u("sidebarFilesTree.contentSearch.invalidPattern"),e[9]=u,e[10]=p):p=e[10];let m;e[11]!==p?(m=s.jsx("span",{className:"text-[var(--status-error)]",children:p}),e[11]=p,e[12]=m):m=e[12];let h;e[13]!==n.message?(h=s.jsx("span",{className:"font-mono typography-micro",dir:"ltr",children:n.message}),e[13]=n.message,e[14]=h):h=e[14];let b;return e[15]!==m||e[16]!==h?(b=s.jsxs(on,{className:"flex flex-col gap-0.5",children:[m,h]}),e[15]=m,e[16]=h,e[17]=b):b=e[17],b}case"failed":{let p;e[18]!==n.message||e[19]!==u?(p=u("sidebarFilesTree.contentSearch.failed",{message:n.message}),e[18]=n.message,e[19]=u,e[20]=p):p=e[20];let m;return e[21]!==p?(m=s.jsx(on,{className:"text-[var(--status-error)]",children:p}),e[21]=p,e[22]=m):m=e[22],m}}if(n.matches.length===0){let p;return e[23]!==n.stopped||e[24]!==u?(p=n.stopped==="deadline"?s.jsx(on,{children:u("sidebarFilesTree.contentSearch.deadline")}):s.jsx(on,{children:u("sidebarFilesTree.contentSearch.empty")}),e[23]=n.stopped,e[24]=u,e[25]=p):p=e[25],p}let c;if(e[26]!==r||e[27]!==a||e[28]!==i||e[29]!==o||e[30]!==n.matches){let p;e[32]!==r||e[33]!==a||e[34]!==i||e[35]!==o?(p=m=>{const{name:h,directory:b}=MS(m.relativePath),g=su(m),x=r===g;return s.jsx("li",{"data-file-tree-path":m.path,children:s.jsxs("button",{type:"button",onClick:()=>o(m),onDoubleClick:()=>o(m,{pin:!0}),draggable:!!i,onDragStart:i?w=>i(w,m):void 0,onDragEnd:a?w=>a(w,m):void 0,className:Le("flex w-full flex-col gap-0.5 rounded-md px-2 py-1 text-start transition-colors",Vi(x)),title:`${m.relativePath}:${m.line}`,children:[s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsx(uo,{filePath:m.path,className:"size-3.5 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 flex-shrink truncate typography-meta",dir:"auto",children:h}),b?s.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-micro text-muted-foreground",style:{direction:"rtl"},children:`‎${b}‎`}):s.jsx("span",{className:"flex-1"}),s.jsx("span",{className:"flex-shrink-0 typography-micro tabular-nums text-muted-foreground",children:m.line})]}),s.jsxs("span",{className:"block w-full min-w-0 truncate font-mono typography-micro text-muted-foreground",dir:"ltr",children:[m.cutStart?"…":null,s.jsx(qh,{segments:Kh(m.text,m.ranges)})]})]})},g)},e[32]=r,e[33]=a,e[34]=i,e[35]=o,e[36]=p):p=e[36],c=n.matches.map(p),e[26]=r,e[27]=a,e[28]=i,e[29]=o,e[30]=n.matches,e[31]=c}else c=e[31];let d;e[37]!==n.matches.length||e[38]!==n.stopped||e[39]!==u?(d=n.stopped==="limit"?s.jsx(on,{children:u("sidebarFilesTree.contentSearch.limit",{count:n.matches.length})}):n.stopped==="deadline"?s.jsx(on,{children:u("sidebarFilesTree.contentSearch.deadline")}):null,e[37]=n.matches.length,e[38]=n.stopped,e[39]=u,e[40]=d):d=e[40];let f;return e[41]!==c||e[42]!==d?(f=s.jsxs(s.Fragment,{children:[c,d]}),e[41]=c,e[42]=d,e[43]=f):f=e[43],f},Tl=8;let dr=null;const nu=(t,e)=>Math.abs(e.clientX-t.x)<=Tl&&Math.abs(e.clientY-t.y)<=Tl,bi=t=>{dr={x:t.clientX,y:t.clientY}},xi=t=>{const e=dr;return dr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:nu(e,t)},ru=t=>dr!==null&&nu(dr,t);let ou=null;const Uo=t=>{ou=t},iu=()=>ou,Nl=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},au=(t,e,n)=>{const r=e===null?n:e.type==="directory"?e.path:Nl(e.path);return!r||Nl(t.path)===r||t.type==="directory"&&zu(r,t.path,t.path)!==null?null:r},LS=(t,e)=>{const n=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${n}`:`${e}/${n}`},$S=({root:t,childrenByDir:e,expandedPaths:n,loadErrorsByDir:r})=>{const o=[],i=(a,u)=>{for(const c of e[a]??[]){const d=c.type==="directory"&&n.has(c.path);if(o.push({kind:"node",key:c.path,node:c,depth:u,isExpanded:d}),!d)continue;const f=r[c.path];f&&o.push({kind:"error",key:`error:${c.path}`,directory:c.path,depth:u+1,message:f}),i(c.path,u+1)}};return i(t,0),o},BS=(t,e,n)=>{const r=e.filter(o=>o>=0&&o<n&&!t.includes(o));return r.length===0?[...t]:[...t,...r].sort((o,i)=>o-i)},zS=28,En=t=>Array.from(t.types).includes("Files"),Qn=t=>Array.from(t.types).includes(ir)?iu():null,lu=(t,e,n)=>t.getData(ir)===wo(e,n.path),WS=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]:[]})},US=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),Bt=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},wo=(t,e)=>{const n=Bt(e),r=Bt(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},Wn=(t,e)=>{const n=wo(t,e);if(n!==".")return n;const r=Bt(t);return r.split("/").filter(Boolean).pop()??r},Or=t=>{const e=Bt(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},VS=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),HS=new Set(["node_modules"]),qS=t=>HS.has(t),KS=t=>{const e=Bt(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},GS=8,Ps=new Map,sa=t=>JSON.stringify([ns(),t]),ZS=t=>{const e=sa(t),n=Ps.get(e);return n?(n.touchedAt=Date.now(),Ps.delete(e),Ps.set(e,n),n):null},Vo=t=>{const e=sa(t),n=Ps.get(e);if(n)return n.touchedAt=Date.now(),n;if(Ps.size>=GS){const o=Ps.keys().next().value;o!==void 0&&Ps.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Ps.set(e,r),r},XS=t=>{const e=$e.c(131),{node:n,root:r,isExpanded:o,isActive:i,isBrowserClient:a,depth:u,isOpen:c,status:d,badge:f,isDropTarget:p,isDragSource:m,canUpload:h,canMove:b,permissions:g,downloadFile:x,onSelect:w,onToggle:T,onRevealPath:k,onOpenDialog:E,onSetDropTarget:F,onDropFiles:_,onPickFiles:A,onMoveDragChange:D,onSetMoveDropTarget:y,onMoveDrop:N}=t,{t:j}=at(),v=n.type==="directory";let M;e[0]!==v||e[1]!==n.path?(M=v?n.path:Or(n.path),e[0]=v,e[1]=n.path,e[2]=M):M=e[2];const W=M,{canRename:G,canCreateFile:O,canCreateFolder:Z,canDelete:Q,canReveal:B}=g,oe=!v&&!!x,H=B&&!a,P=v&&h,te=G||O||Z||P||Q||oe||H,[J,le]=l.useState(!1),[K,U]=l.useState(!1);let $;e[3]!==te?($=be=>{te&&(be?.preventDefault(),U(!0))},e[3]=te,e[4]=$):$=e[4];const ee=$;let Y;e[5]!==v||e[6]!==n||e[7]!==w||e[8]!==T?(Y=()=>{v?T(n.path):w(n)},e[5]=v,e[6]=n,e[7]=w,e[8]=T,e[9]=Y):Y=e[9];const ie=Y;let V;e[10]!==v||e[11]!==n||e[12]!==w?(V=()=>{v||w(n,{pin:!0})},e[10]=v,e[11]=n,e[12]=w,e[13]=V):V=e[13];const fe=V;let Se;e[14]===Symbol.for("react.memo_cache_sentinel")?(Se=be=>{be.stopPropagation(),U(!1),le(!0)},e[14]=Se):Se=e[14];const Te=Se;let ue;e[15]!==O||e[16]!==Z||e[17]!==Q||e[18]!==G||e[19]!==H||e[20]!==P||e[21]!==x||e[22]!==a||e[23]!==v||e[24]!==n||e[25]!==E||e[26]!==A||e[27]!==k||e[28]!==j?(ue=be=>{const{Item:C,Separator:ce}=be;return s.jsxs(s.Fragment,{children:[G&&s.jsxs(C,{onClick:L=>{L.stopPropagation(),E("rename",n)},children:[s.jsx(se,{name:"edit",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.rename")]}),s.jsxs(C,{onClick:L=>{L.stopPropagation(),no(n.path).then(ge=>{if(ge.ok){Re.success(j("sidebarFilesTree.toast.pathCopied"));return}Re.error(j("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(se,{name:"link",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.copyPath")]}),!v&&x&&s.jsxs(C,{onClick:L=>{L.stopPropagation(),x(n.path).catch(ge=>{console.error("Download failed:",ge),Re.error(j("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(se,{name:"download",className:"me-2 h-4 w-4"})," ",j(a?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),H&&s.jsxs(C,{onClick:L=>{L.stopPropagation(),k(n.path)},children:[s.jsx(se,{name:"folder-received",className:"me-2 h-4 w-4"})," ",j(Xh())]}),!v&&H&&Qr()&&s.jsxs(C,{onClick:L=>{L.stopPropagation(),Kl(n.path).then(ge=>{ge||Re.error(j("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(se,{name:"external-link",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.openInDefaultApp")]}),v&&(O||Z||P)&&s.jsxs(s.Fragment,{children:[s.jsx(ce,{}),O&&s.jsxs(C,{onClick:L=>{L.stopPropagation(),E("createFile",n)},children:[s.jsx(se,{name:"file-add",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.newFile")]}),Z&&s.jsxs(C,{onClick:L=>{L.stopPropagation(),E("createFolder",n)},children:[s.jsx(se,{name:"folder-add",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.newFolder")]}),P&&s.jsxs(C,{onClick:L=>{L.stopPropagation(),A(n.path)},children:[s.jsx(se,{name:"upload-2",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.uploadFiles")]})]}),Q&&s.jsxs(s.Fragment,{children:[s.jsx(ce,{}),s.jsxs(C,{onClick:L=>{L.stopPropagation(),E("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(se,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.delete")]})]})]})},e[15]=O,e[16]=Z,e[17]=Q,e[18]=G,e[19]=H,e[20]=P,e[21]=x,e[22]=a,e[23]=v,e[24]=n,e[25]=E,e[26]=A,e[27]=k,e[28]=j,e[29]=ue):ue=e[29];const Me=ue;let Ae;e[30]!==b||e[31]!==n.path||e[32]!==n.type||e[33]!==D||e[34]!==r?(Ae=be=>{bi(be);const C=wo(r,n.path);!C||C==="."||(be.dataTransfer.setData(ir,C),be.dataTransfer.effectAllowed=b?"copyMove":"copy",b&&D({path:n.path,type:n.type}))},e[30]=b,e[31]=n.path,e[32]=n.type,e[33]=D,e[34]=r,e[35]=Ae):Ae=e[35];const De=Ae;let Be;e[36]!==b||e[37]!==ie||e[38]!==D?(Be=be=>{b&&D(null),xi(be)&&ie()},e[36]=b,e[37]=ie,e[38]=D,e[39]=Be):Be=e[39];const we=Be;let ve;e[40]!==h||e[41]!==F||e[42]!==W?(ve=be=>{!h||!W||!En(be.dataTransfer)||(be.preventDefault(),be.stopPropagation(),be.dataTransfer.dropEffect="copy",F(W))},e[40]=h,e[41]=F,e[42]=W,e[43]=ve):ve=e[43];const Pe=ve;let he;e[44]!==h||e[45]!==F||e[46]!==W?(he=be=>{!h||!W||!En(be.dataTransfer)||be.relatedTarget instanceof Node&&be.currentTarget.contains(be.relatedTarget)||(be.stopPropagation(),F(null))},e[44]=h,e[45]=F,e[46]=W,e[47]=he):he=e[47];const Fe=he;let _e;e[48]!==h||e[49]!==_||e[50]!==W?(_e=be=>{!h||!W||!En(be.dataTransfer)||(be.preventDefault(),be.stopPropagation(),_(W,be.dataTransfer))},e[48]=h,e[49]=_,e[50]=W,e[51]=_e):_e=e[51];const We=_e;let Xe;e[52]!==n.path||e[53]!==n.type||e[54]!==r?(Xe=(be,C)=>ru(be)?null:au(C,{path:n.path,type:n.type},r),e[52]=n.path,e[53]=n.type,e[54]=r,e[55]=Xe):Xe=e[55];const Ve=Xe;let S;e[56]!==b||e[57]!==Ve||e[58]!==Pe||e[59]!==y?(S=be=>{const C=b?Qn(be.dataTransfer):null;if(!C){Pe(be);return}be.stopPropagation();const ce=Ve(be,C);y(ce),ce&&(be.preventDefault(),be.dataTransfer.dropEffect="move")},e[56]=b,e[57]=Ve,e[58]=Pe,e[59]=y,e[60]=S):S=e[60];const ne=S;let q;e[61]!==b||e[62]!==Ve||e[63]!==We||e[64]!==N||e[65]!==y||e[66]!==r?(q=be=>{const C=b?Qn(be.dataTransfer):null;if(!C){We(be);return}be.stopPropagation(),be.preventDefault(),y(null);const ce=Ve(be,C);ce&&lu(be.dataTransfer,r,C)&&N(C,ce)},e[61]=b,e[62]=Ve,e[63]=We,e[64]=N,e[65]=y,e[66]=r,e[67]=q):q=e[67];const ke=q;let Ee;e[68]===Symbol.for("react.memo_cache_sentinel")?(Ee={blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[68]=Ee):Ee=e[68];let Ie;e[69]!==ee||e[70]!==Fe||e[71]!==ne||e[72]!==ke?(Ie=s.jsx("div",{className:"group relative flex items-center typography-meta",style:Ee,onContextMenu:ee,onDragEnter:ne,onDragOver:ne,onDragLeave:Fe,onDrop:ke}),e[69]=ee,e[70]=Fe,e[71]=ne,e[72]=ke,e[73]=Ie):Ie=e[73];let Ne;e[74]!==u?(Ne=s.jsx(Hc,{depth:u}),e[74]=u,e[75]=Ne):Ne=e[75];let ze;e[76]!==i||e[77]!==m||e[78]!==p?(ze=Le("oc-file-tree-row flex w-full items-center gap-1.5 rounded-md py-1 text-start select-none",p?"bg-interactive-selection text-interactive-selection-foreground ring-2 ring-inset ring-primary [--oc-file-tree-row-fill:var(--interactive-selection)] [--oc-file-tree-row-ring:var(--primary)]":Vi(i),m&&"opacity-50"),e[76]=i,e[77]=m,e[78]=p,e[79]=ze):ze=e[79];let Ue;e[80]!==u?(Ue=qc(u),e[80]=u,e[81]=Ue):Ue=e[81];let Ge;e[82]!==Ue?(Ge={paddingInlineStart:Ue},e[82]=Ue,e[83]=Ge):Ge=e[83];let Qe;e[84]!==v||e[85]!==o||e[86]!==n.extension||e[87]!==n.path?(Qe=v?s.jsx(Gh,{expanded:o}):s.jsx(uo,{filePath:n.path,extension:n.extension,className:"ms-0.5 size-3.5"}),e[84]=v,e[85]=o,e[86]=n.extension,e[87]=n.path,e[88]=Qe):Qe=e[88];let He;e[89]!==n.name||e[90]!==n.path?(He=s.jsx("span",{className:"oc-file-tree-row-name typography-meta",title:n.path,children:n.name}),e[89]=n.name,e[90]=n.path,e[91]=He):He=e[91];let Ke;e[92]!==v||e[93]!==c||e[94]!==d?(Ke=!v&&s.jsx(Yh,{isOpen:c,status:d}),e[92]=v,e[93]=c,e[94]=d,e[95]=Ke):Ke=e[95];let Ye;e[96]!==f||e[97]!==v?(Ye=v&&f&&s.jsx(Jh,{badge:f}),e[96]=f,e[97]=v,e[98]=Ye):Ye=e[98];let it;e[99]!==Ke||e[100]!==Ye?(it=s.jsxs(Qh,{className:"pe-2",children:[Ke,Ye]}),e[99]=Ke,e[100]=Ye,e[101]=it):it=e[101];let bt;e[102]!==ee||e[103]!==fe||e[104]!==we||e[105]!==De||e[106]!==ie||e[107]!==ze||e[108]!==Ge||e[109]!==Qe||e[110]!==He||e[111]!==it?(bt=s.jsxs("button",{type:"button",onClick:ie,onDoubleClick:fe,onContextMenu:ee,draggable:!0,onDragStart:De,onDragEnd:we,className:ze,style:Ge,children:[Qe,He,it]}),e[102]=ee,e[103]=fe,e[104]=we,e[105]=De,e[106]=ie,e[107]=ze,e[108]=Ge,e[109]=Qe,e[110]=He,e[111]=it,e[112]=bt):bt=e[112];let nt;e[113]!==J||e[114]!==te||e[115]!==i||e[116]!==p||e[117]!==Me||e[118]!==j?(nt=te&&s.jsx("div",{className:Le("oc-file-tree-row-end -ms-7 w-7 pe-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100",Zh(i||p)),children:s.jsxs(pn,{open:J,onOpenChange:le,children:[s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(mn,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:Te,title:j("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":j("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(se,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx($t,{side:"bottom",sideOffset:6,children:j("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(hn,{align:"end",side:"bottom",onCloseAutoFocus:()=>le(!1),children:Me({Item:Gt,Separator:un})})]})}),e[113]=J,e[114]=te,e[115]=i,e[116]=p,e[117]=Me,e[118]=j,e[119]=nt):nt=e[119];let ft;e[120]!==Ie||e[121]!==Ne||e[122]!==bt||e[123]!==nt?(ft=s.jsxs(ro,{render:Ie,children:[Ne,bt,nt]}),e[120]=Ie,e[121]=Ne,e[122]=bt,e[123]=nt,e[124]=ft):ft=e[124];let ae;e[125]!==Me?(ae=s.jsx(oo,{className:"min-w-[180px]",children:Me({Item:Cs,Separator:Tn})}),e[125]=Me,e[126]=ae):ae=e[126];let de;return e[127]!==K||e[128]!==ft||e[129]!==ae?(de=s.jsxs(pr,{open:K,onOpenChange:U,children:[ft,ae]}),e[127]=K,e[128]=ft,e[129]=ae,e[130]=de):de=e[130],de},YS=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.depth===e.depth&&t.isOpen===e.isOpen&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.isDragSource===e.isDragSource&&t.canUpload===e.canUpload&&t.canMove===e.canMove&&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&&t.onPickFiles===e.onPickFiles&&t.onMoveDragChange===e.onMoveDragChange&&t.onSetMoveDropTarget===e.onSetMoveDropTarget&&t.onMoveDrop===e.onMoveDrop,JS=l.memo(XS,YS),QS=t=>{const e=$e.c(14),{visible:n}=t,r=n===void 0?!0:n,o=An(t2),i=Vs()??"",a=mr();let u,c,d,f;if(e[0]!==a||e[1]!==i||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{if(c=ao(a,i)??"",a?.kind==="preparing"){let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Nr,{}),e[7]=m):m=e[7],f=m;break e}u=e2,d=JSON.stringify([o,c])}e[0]=a,e[1]=i,e[2]=o,e[3]=u,e[4]=c,e[5]=d,e[6]=f}else u=e[3],c=e[4],d=e[5],f=e[6];if(f!==Symbol.for("react.early_return_sentinel"))return f;let p;return e[8]!==u||e[9]!==c||e[10]!==i||e[11]!==d||e[12]!==r?(p=s.jsx(u,{visible:r,currentDirectory:c,panelDirectory:i},d),e[8]=u,e[9]=c,e[10]=i,e[11]=d,e[12]=r,e[13]=p):p=e[13],p},e2=({visible:t,currentDirectory:e,panelDirectory:n})=>{const r=l.useRef(t);r.current=t;const{t:o}=at(),{files:i,runtime:a}=Es(),u=Wu(a.platform),c=Bt(e.trim()),d=Bt(n.trim()),f=sa(c),p=Uu(),m=Vu(),h=Hu(R=>R.searchFiles),b=X(R=>R.openContextFile),g=lo(t?e:null),[x,w]=l.useState(""),T=eg(x,200),k=l.useRef(null),[E,F]=l.useState([]),[_,A]=l.useState(!1),D=!!i.searchContents,[y,N]=l.useState("names"),[j,v]=l.useState(!1),M=D&&y==="contents",W=OS({searchContents:i.searchContents,directory:e,query:T,regex:j,includeHidden:p,respectGitignore:!m,active:t&&M}),G=X(R=>R.openContextFileAtLine),[O,Z]=l.useState(null),[Q,B]=l.useState(null),[oe,H]=l.useState(null),[P,te]=l.useState(null),[J,le]=l.useState(null),{hasTouchOnlyPointer:K}=gn(),U=!!(i.rename&&c)&&!K,$=X(R=>R.confirmFileTreeMove),ee=X(R=>R.setConfirmFileTreeMove),[Y,ie]=l.useState({}),[V,fe]=l.useState({}),Se=l.useRef(new Set),Te=l.useRef(new Map),ue=l.useMemo(()=>new zb,[]);l.useEffect(()=>()=>ue.clear(),[ue]);const Me=l.useRef(null);l.useEffect(()=>{if(B(null),te(null),le(null),!c){ie({}),fe({}),Se.current=new Set;return}const R=ZS(c);R?(ie({...R.childrenByDir}),fe({...R.loadErrorsByDir}),Se.current=new Set(R.loadedDirs)):(ie({}),fe({}),Se.current=new Set)},[c]),l.useEffect(()=>{if(!c)return;const R=Vo(c);R.childrenByDir=Y},[c,Y]),l.useEffect(()=>{if(!c)return;const R=Vo(c);R.loadErrorsByDir=V},[c,V]),l.useEffect(()=>{if(!c)return;const R=Vo(c);R.loadedDirs=new Set(Se.current)},[c,Y,V]),l.useEffect(()=>()=>{if(!c)return;const R=Ps.get(f);R&&R.loadedDirs.size===0&&Object.keys(R.childrenByDir).length===0&&Ps.delete(f)},[f,c]);const Ae=l.useMemo(()=>[],[]),De=l.useMemo(()=>[],[]),Be=gs(R=>c?R.byRoot[c]?.expandedPaths??Ae:Ae),we=l.useMemo(()=>new Set(Be),[Be]),ve=gs(R=>c?R.byRoot[c]?.selectedPath??null:null),Pe=gs(R=>R.setSelectedPath),he=l.useRef(null);l.useEffect(()=>{he.current=ve},[ve]);const Fe=gs(R=>R.addOpenPath),_e=gs(R=>R.removeOpenPathsByPrefix),We=gs(R=>R.toggleExpandedPath),Xe=gs(R=>R.expandPath),Ve=gs(R=>R.collapseAllExpandedPaths),S=X(R=>d?R.contextPanelByDirectory[d]?.tabs??De:De),ne=l.useMemo(()=>new Set(S.map(R=>R.mode==="file"?R.targetPath:null).filter(R=>typeof R=="string"&&R.length>0).map(R=>Bt(R))),[S]),[q,ke]=l.useState(null),[Ee,Ie]=l.useState(null),[Ne,ze]=l.useState(""),[Ue,Ge]=l.useState(!1),Qe=!!i.writeFile,He=!!i.createDirectory,Ke=!!i.rename,Ye=!!i.delete,it=!!i.revealPath,bt=l.useMemo(()=>({canRename:Ke,canCreateFile:Qe,canCreateFolder:He,canDelete:Ye,canReveal:it}),[Ke,Qe,He,Ye,it]),nt=l.useCallback(R=>{i.revealPath&&i.revealPath(R).catch(()=>{Re.error(o("sidebarFilesTree.toast.revealFailed"))})},[i,o]),ft=l.useCallback((R,I)=>{ke(R),Ie(I),ze(R==="rename"&&I.name||""),Ge(!1)},[]),ae=l.useCallback((R,I)=>{const xe=I.filter(pe=>pe&&typeof pe.name=="string"&&pe.name.length>0).filter(pe=>p||!pe.name.startsWith(".")).filter(pe=>m||!qS(pe.name)).map(pe=>{const rt=pe.name,tt=Bt(pe.path||""),Et=tt?VS(tt)?tt:Bt(`${R}/${tt}`):Bt(`${R}/${rt}`),Rt=pe.isDirectory?"directory":"file",It=Rt==="file"&&rt.includes(".")?rt.split(".").pop()?.toLowerCase():void 0;return{name:rt,path:Et,type:Rt,extension:It}});return US(xe)},[m,p]),de=l.useCallback(async(R,I,xe=!1)=>{if(!r.current||I?.())return;const pe=Bt(R.trim());if(!pe||!xe&&Se.current.has(pe))return;const rt=ns();return ue.run(pe,async tt=>{const Et=()=>!tt()||ns()!==rt;try{const Rt=!m,It=i.listDirectory?(await i.listDirectory(pe,{respectGitignore:Rt})).entries:await Go.listLocalDirectory(pe,{respectGitignore:Rt});if(Et())return;Te.current.set(pe,It.length);const At=ae(pe,It);Se.current=new Set(Se.current),Se.current.add(pe),fe(ws=>{if(!ws[pe])return ws;const en={...ws};return delete en[pe],en}),ie(ws=>ws[pe]&&Wb(ws[pe],At)?ws:{...ws,[pe]:At})}catch(Rt){if(Et())return;const It=Rt instanceof Error?Rt.message:String(Rt??"");console.error("Failed to load sidebar directory:",Rt),fe(At=>({...At,[pe]:It}))}},xe)},[ue,i,ae,m]),be=l.useCallback(async()=>{if(!c)return;Me.current?.abort();const R=new AbortController;Me.current=R,ue.clear();try{const xe=(gs.getState().byRoot[c]?.expandedPaths??[]).map(tt=>Bt(tt)).filter(tt=>!!tt&&tt!==c&&tt.startsWith(`${c}/`)),pe=[c,...xe];Se.current=new Set(Se.current);for(const tt of pe)Se.current.delete(tt);fe(tt=>{if(Object.keys(tt).length===0)return tt;const Et={...tt};let Rt=!1;for(const It of pe)It in Et&&(delete Et[It],Rt=!0);return Rt?Et:tt});const rt=()=>R.signal.aborted;await de(c,rt);for(let tt=0;tt<xe.length&&!R.signal.aborted;tt+=3){const Et=xe.slice(tt,tt+3);await Promise.all(Et.map(Rt=>de(Rt,rt)))}}catch(I){if(R.signal.aborted)return;console.error("Failed to refresh sidebar tree:",I)}finally{Me.current===R&&(Me.current=null)}},[ue,de,c]),C=l.useCallback(async R=>{if(!R){await be();return}const I=Bt(R);Se.current=new Set(Se.current),Se.current.delete(I),await de(I,void 0,!0)},[de,be]);l.useEffect(()=>{c&&(Me.current?.abort(),Se.current=new Set,ue.clear(),fe({}),ie(R=>Object.keys(R).length===0?R:{}),de(c))},[ue,de,c,p,m]),l.useEffect(()=>{if(!t||!c||Be.length===0)return;const R=Be.map(pe=>Bt(pe)).filter(pe=>!!pe&&pe!==c&&pe.startsWith(`${c}/`)&&!Se.current.has(pe)&&!ue.has(pe)).sort((pe,rt)=>pe.split("/").length-rt.split("/").length);if(R.length===0)return;let I=!1;const xe=()=>I;return(async()=>{for(let pe=0;pe<R.length&&!I;pe+=3){const rt=R.slice(pe,pe+3);await Promise.all(rt.map(tt=>de(tt,xe)))}})(),()=>{I=!0}},[ue,Be,de,c,t]);const ce=l.useRef(t);l.useEffect(()=>{const R=t&&!ce.current;ce.current=t,R&&be()},[be,t]);const L=l.useCallback(({directories:R})=>{if(!c)return;const I=new Set((gs.getState().byRoot[c]?.expandedPaths??[]).map(It=>Bt(It))),xe=c==="/"?"/":`${c}/`,pe=It=>{for(let At=It;At!==c;At=Or(At))if(!At.startsWith(xe)||!I.has(At))return!1;return!0},rt=It=>{for(let At=It;At===c||At.startsWith(xe);At=Or(At)){if(Se.current.has(At))return At;if(At===c)break}return null},tt=new Set,Et=new Set;for(const It of R??Se.current){const At=rt(Bt(It));At&&(pe(At)?tt:Et).add(At)}Et.size>0&&(Se.current=new Set([...Se.current].filter(It=>!Et.has(It))));const Rt=[...tt].filter(It=>(Te.current.get(It)??0)<=$f);(async()=>{for(let It=0;It<Rt.length;It+=3)await Promise.all(Rt.slice(It,It+3).map(At=>de(At,void 0,!0)))})()},[de,c]);Bf({root:c,active:t,whileInactive:"drop",onChanges:L}),l.useEffect(()=>{if(!t)return;if(!e||M){F([]),A(!1);return}const R=T.trim();if(!R){F([]),A(!1);return}let I=!1;return A(!0),h(e,R,150,{includeHidden:p,respectGitignore:!m,type:"file"}).then(xe=>{if(I)return;const rt=xe.filter(tt=>m||!KS(tt.path)).map(tt=>({name:tt.name,path:Bt(tt.path),type:"file",extension:tt.extension,relativePath:tt.relativePath}));F(rt)}).catch(()=>{I||F([])}).finally(()=>{I||A(!1)}),()=>{I=!0}},[M,e,T,h,p,m,t]);const ge=l.useMemo(()=>{const R=new Map;if(!g?.files)return R;for(const I of g.files)I.index==="A"||I.working_dir==="?"?R.set(I.path,"git-added"):I.index==="D"?R.set(I.path,"git-deleted"):(I.index==="M"||I.working_dir==="M")&&R.set(I.path,"git-modified");return R},[g]),Ce=l.useMemo(()=>{const R=new Map;if(!g?.files||!c)return R;for(const I of g.files){const xe=I.index==="M"||I.working_dir==="M",pe=I.index==="A"||I.working_dir==="?";if(!xe&&!pe)continue;const rt=I.path.split("/");if(rt.length<=1)continue;let tt=c;for(let Et=0;Et<rt.length-1;Et++){tt=`${tt}/${rt[Et]}`;let Rt=R.get(tt);Rt||(Rt={modified:0,added:0},R.set(tt,Rt)),xe&&Rt.modified++,pe&&Rt.added++}}return R},[g,c]),Je=l.useCallback(R=>{if(ge.size===0)return null;const I=R.startsWith(c+"/")?R.slice(c.length+1):R;return ge.get(I)??null},[ge,c]),Oe=l.useCallback(R=>{if(Ce.size===0)return null;const I=Ce.get(R);return I&&I.modified+I.added>0?I:null},[Ce]),me=l.useCallback(async(R,I)=>{if(!c)return;const xe=await $a(i,R.path,{directory:c});if(!xe.ok){Ba(R.path,xe);return}Pe(c,R.path),Fe(c,R.path),b(d,R.path,{preview:!I?.pin&&!X.getState().isMobile})},[Fe,i,b,d,c,Pe]),je=l.useCallback(async(R,I)=>{if(!c)return;const xe=await $a(i,R.path,{directory:c});if(!xe.ok){Ba(R.path,xe);return}Pe(c,R.path),Fe(c,R.path),Z({path:R.path,key:su(R)}),G(d,R.path,R.line,R.column,{preview:!I?.pin&&!X.getState().isMobile})},[Fe,i,G,d,c,Pe]),st=l.useCallback((R,I)=>{bi(R),Uo(null),R.dataTransfer.setData(ir,I.relativePath),R.dataTransfer.effectAllowed="copy"},[]),ye=l.useCallback((R,I)=>{xi(R)&&je(I)},[je]),[ot,Ct]=l.useState(null),xt=l.useCallback(()=>Ct(null),[]),jt=l.useRef(null),ct=Ub(jt,{onSettled:xt}),vt=l.useCallback(async R=>{const I=Bt(R);if(!c)return;const xe=gs.getState().byRoot[c]?.expandedPaths.includes(I)??!1;ct(R,xe,()=>{const pe=Array.from(jt.current?.querySelectorAll("[data-tree-disclosure-path]")??[],rt=>rt.dataset.treeDisclosurePath??"");Ct(xe?null:pe.slice(pe.indexOf(R)+1)),We(c,I)}),Se.current.has(I)||await de(I)},[de,c,We,ct]),{canUpload:St,uploadingDirectory:mt,uploadFiles:yt,pickFiles:lt,uploadElements:Nt}=zf({root:c,refreshDirectory:C}),_t=mt!==null,ht=mt??Q,gt=l.useCallback((R,I)=>{const xe=WS(I);xe.length!==0&&(B(null),yt(R,xe))},[yt]),Dt=l.useCallback(R=>{if(Uo(R),!R){H(null),te(null);return}requestAnimationFrame(()=>{iu()?.path===R.path&&H(R.path)})},[]),Kt=l.useCallback(async(R,I)=>{const xe=LS(R,I),pe=await za(i,{tabs:d,files:c},R.path,xe);if(pe==="conflict"){Re.error(o("sidebarFilesTree.toast.nameTaken",{name:xe.slice(xe.lastIndexOf("/")+1),folder:Wn(c,I)}));return}if(pe==="failed"){Re.error(o("sidebarFilesTree.toast.operationFailed"));return}I!==c&&Xe(c,I),await Promise.all([C(Or(R.path)),C(I)]).catch(()=>{})},[Xe,i,d,C,c,o]),Yt=l.useCallback((R,I)=>{if(X.getState().confirmFileTreeMove){le({source:R,targetDirectory:I});return}Kt(R,I)},[Kt]),js=l.useCallback(()=>{J&&(le(null),Kt(J.source,J.targetDirectory))},[Kt,J]),Wt=l.useCallback((R,I)=>!U||ru(R)?null:au(I,null,c),[U,c]),ds=l.useCallback(R=>{const I=Qn(R.dataTransfer);if(I){const xe=Wt(R,I);if(te(xe),!xe)return;R.preventDefault(),R.dataTransfer.dropEffect="move";return}!St||_t||!c||!En(R.dataTransfer)||(R.preventDefault(),R.dataTransfer.dropEffect="copy",B(c))},[St,Wt,_t,c]),us=l.useCallback(R=>{if(!(R.relatedTarget instanceof Node&&R.currentTarget.contains(R.relatedTarget))){if(Qn(R.dataTransfer)){te(null);return}En(R.dataTransfer)&&B(null)}},[]),Jt=l.useCallback(R=>{const I=Qn(R.dataTransfer);if(I){R.preventDefault(),te(null);const xe=Wt(R,I);xe&&lu(R.dataTransfer,c,I)&&Yt(I,xe);return}!St||_t||!c||!En(R.dataTransfer)||(R.preventDefault(),gt(c,R.dataTransfer))},[St,Wt,gt,Yt,_t,c]),Is=l.useCallback(async R=>{if(R?.preventDefault(),!Ee||!q)return;Ge(!0);const I=()=>Ge(!1),xe=()=>ke(null);if(q==="createFile"){if(!Ne.trim()){Re.error(o("sidebarFilesTree.toast.filenameRequired")),I();return}if(!i.writeFile){Re.error(o("sidebarFilesTree.toast.writeNotSupported")),I();return}const pe=Ee.path,rt=pe?`${pe}/`:"",tt=Bt(`${rt}${Ne.trim()}`);await i.writeFile(tt,"").then(async Et=>{Et.success&&(Re.success(o("sidebarFilesTree.toast.fileCreated")),await C(pe)),xe()}).catch(()=>Re.error(o("sidebarFilesTree.toast.operationFailed"))).finally(I);return}if(q==="createFolder"){if(!Ne.trim()){Re.error(o("sidebarFilesTree.toast.folderNameRequired")),I();return}const pe=Ee.path,rt=pe?`${pe}/`:"",tt=Bt(`${rt}${Ne.trim()}`);await i.createDirectory(tt).then(async Et=>{Et.success&&(Re.success(o("sidebarFilesTree.toast.folderCreated")),await C(pe)),xe()}).catch(()=>Re.error(o("sidebarFilesTree.toast.operationFailed"))).finally(I);return}if(q==="rename"){if(!Ne.trim()){Re.error(o("sidebarFilesTree.toast.nameRequired")),I();return}if(!i.rename){Re.error(o("sidebarFilesTree.toast.renameNotSupported")),I();return}const pe=Ee.path,rt=pe.split("/").slice(0,-1).join("/"),tt=rt?`${rt}/`:"",Et=Ne.trim(),Rt=Bt(`${tt}${Et}`);try{const It=await za(i,{tabs:d,files:c},pe,Rt);It==="moved"?(Re.success(o("sidebarFilesTree.toast.renamedSuccessfully")),await C(rt),xe()):It==="conflict"?Re.error(o("sidebarFilesTree.toast.nameTaken",{name:Et,folder:Wn(c,rt)})):Re.error(o("sidebarFilesTree.toast.operationFailed"))}catch{Re.error(o("sidebarFilesTree.toast.operationFailed"))}finally{I()}return}if(q==="delete"){if(!i.delete){Re.error(o("sidebarFilesTree.toast.deleteNotSupported")),I();return}const pe=Ee.path,rt=pe.split("/").slice(0,-1).join("/");await i.delete(pe).then(async tt=>{tt.success&&(Re.success(o("sidebarFilesTree.toast.deletedSuccessfully")),await C(rt),c&&_e(c,pe),(ve===pe||ve&&ve.startsWith(pe+"/"))&&Pe(c,null)),xe()}).catch(()=>Re.error(o("sidebarFilesTree.toast.operationFailed"))).finally(I);return}I()},[q,Ee,Ne,i,d,C,_e,c,ve,Pe,o]),rs=l.useMemo(()=>c?$S({root:c,childrenByDir:Y,expandedPaths:we,loadErrorsByDir:V}):[],[Y,we,V,c]),os=l.useMemo(()=>new Map(rs.flatMap((R,I)=>R.kind==="node"?[[R.node.path,I]]:[])),[rs]),[Ut,Hs]=l.useState(null),[re,Ze]=l.useState(null),pt=l.useCallback(R=>{jt.current=R,Ze(R)},[]),[kt,Pt]=l.useState(null),Zt=l.useMemo(()=>[oe,kt,...ot??[]].flatMap(R=>R?[os.get(R)??-1]:[]),[kt,oe,ot,os]),is=l.useCallback(R=>BS(Kb(R),Zt,rs.length),[Zt,rs.length]),[z,qe]=l.useState(0);l.useLayoutEffect(()=>{if(!Ut||!re)return;const R=re.getBoundingClientRect().top-Ut.getBoundingClientRect().top+Ut.scrollTop;qe(Math.max(0,Math.round(R)))},[re,Ut]);const ut=l.useRef(null),Tt=l.useRef(new Map),Vt=l.useRef(null),Ht=l.useCallback(R=>{const I=Math.max(0,...Tt.current.values());R.style.setProperty("--oc-file-tree-width",`${I}px`)},[]),Mt=l.useCallback((R,I)=>{const xe=R.dataset.treeRowPath,pe=jt.current;!xe||!pe||I<=pe.clientWidth+.5||Tt.current.get(xe)!==I&&(Tt.current.set(xe,I),Vt.current===null&&(Vt.current=requestAnimationFrame(()=>{Vt.current=null,jt.current&&Ht(jt.current)})))},[Ht]);l.useEffect(()=>()=>{Vt.current!==null&&cancelAnimationFrame(Vt.current)},[]),l.useLayoutEffect(()=>{if(!re)return;const R=Tt.current;for(const pe of R.keys())os.has(pe)||R.delete(pe);const I=Ut?.scrollLeft??0;re.style.removeProperty("--oc-file-tree-width");const xe=re.clientWidth;for(const pe of re.children){const rt=pe instanceof HTMLElement?pe.dataset.treeRowPath:void 0;if(!rt)continue;const tt=pe.getBoundingClientRect().width;tt>xe+.5?R.set(rt,tt):R.delete(rt)}Ht(re),Ut&&(Ut.scrollLeft=I)},[re,os,Ut,Ht]);const fs=qb({count:rs.length,enabled:Ut!==null,getScrollElement:()=>Ut,estimateSize:R=>(rs[R]?.kind==="node"?ut.current:null)??zS,measureElement:(R,I,xe)=>{const pe=Gb(R,I,xe);return R.dataset.treeRowPath&&(ut.current=pe),I&&Mt(R,I.borderBoxSize?.[0]?.inlineSize??R.getBoundingClientRect().width),pe},getItemKey:R=>rs[R]?.key??R,overscan:12,scrollMargin:z,rangeExtractor:is}),Mn=R=>{if(R.kind==="error")return s.jsxs("div",{className:"sticky inset-s-0 flex w-[100cqw] items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingInlineStart:qc(R.depth)},children:[s.jsx(Hc,{depth:R.depth}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:R.message,children:R.message}),s.jsxs(dt,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{C(R.directory)},children:[s.jsx(se,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})]});const{node:I,depth:xe,isExpanded:pe}=R,rt=I.type==="directory";return s.jsx(JS,{node:I,root:c,isExpanded:pe,isActive:ve===I.path,isBrowserClient:u,depth:xe,isOpen:!rt&&ne.has(I.path),status:rt?void 0:Je(I.path),badge:rt?Oe(I.path):void 0,isDropTarget:rt&&(ht===I.path||P===I.path),isDragSource:oe===I.path,canUpload:St&&!_t,canMove:U,permissions:bt,downloadFile:i.downloadFile,onSelect:me,onToggle:vt,onRevealPath:nt,onOpenDialog:ft,onSetDropTarget:B,onDropFiles:gt,onPickFiles:lt,onMoveDragChange:Dt,onSetMoveDropTarget:te,onMoveDrop:Yt})},Fn=l.useCallback(R=>{const I=R.target instanceof Element?R.target.closest("[data-tree-row-path]"):null;Pt(I?.dataset.treeRowPath??null)},[]),yo=l.useCallback(R=>{R.relatedTarget instanceof Node&&R.currentTarget.contains(R.relatedTarget)||Pt(null)},[]);l.useEffect(()=>{const R=he.current;if(!R||!Ut||!re)return;const I=os.get(R);I===void 0||Ut.offsetParent===null||(he.current=null,fs.scrollToIndex(I,{align:"auto"}))});const hr=!!(c&&Y[c]),Ln=c?V[c]:null,$n=T.trim().length>0,vo=!_&&!$n&&E.length===0&&!Ln&&hr&&!!c,Bn=ht?Wn(c,ht):"",gr=P?Wn(c,P):"",So=J?J.source.path.slice(J.source.path.lastIndexOf("/")+1):"";return s.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col border-b border-edge-muted",children:[s.jsx("div",{className:"flex h-8 shrink-0 items-center border-t border-edge-muted px-2",children:s.jsx(tg,{className:"flex-1",start:null,groups:[[(Qe||He||St)&&{id:"add",label:o("sidebarFilesTree.actions.addMenuTitle"),icon:_t?"loader-4":"add",iconClassName:_t?"animate-spin":void 0,menu:s.jsxs(s.Fragment,{children:[Qe?s.jsxs(Gt,{onClick:()=>ft("createFile",{path:e,type:"directory"}),children:[s.jsx(se,{name:"file-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFile")]}):null,He?s.jsxs(Gt,{onClick:()=>ft("createFolder",{path:e,type:"directory"}),children:[s.jsx(se,{name:"folder-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFolder")]}):null,St?s.jsxs(Gt,{disabled:!c||_t,onClick:()=>lt(c),children:[s.jsx(se,{name:"upload-2",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.uploadFiles")]}):null]})},{id:"gitignored",label:o("filesView.tree.actions.showGitignored"),icon:"file-forbid",pressed:m,onSelect:()=>qu(!m)},{id:"refresh",label:o("sidebarFilesTree.actions.refreshTitle"),icon:"refresh",onSelect:()=>{be()}},{id:"collapse-all",label:o("sidebarFilesTree.actions.collapseAllTitle"),icon:"collapse-vertical",onSelect:()=>{c&&Ve(c)}}]]})}),s.jsxs("div",{className:"relative min-w-0 px-2 py-2",children:[D?s.jsxs(pn,{children:[s.jsx(mn,{asChild:!0,children:s.jsxs(dt,{variant:"ghost",size:"sm",className:"absolute inset-s-3 top-3 size-6 p-0 text-muted-foreground hover:text-foreground",title:o("sidebarFilesTree.search.mode.aria"),"aria-label":o("sidebarFilesTree.search.mode.aria"),children:[s.jsx(se,{name:M?"file-search":"search",className:"h-4 w-4"}),s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0.5 end-0.5 size-0 border-[3px] border-b-current border-e-current border-s-transparent border-t-transparent opacity-70"})]})}),s.jsx(hn,{align:"start",side:"bottom",children:s.jsxs(Oc,{value:y,onValueChange:R=>N(R==="contents"?"contents":"names"),children:[s.jsxs(zr,{value:"names",closeOnClick:!0,className:"items-center",children:[s.jsx(se,{name:"search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.names")]}),s.jsxs(zr,{value:"contents",closeOnClick:!0,className:"items-center",children:[s.jsx(se,{name:"file-search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.contents")]})]})})]}):s.jsx(se,{name:"search",className:"pointer-events-none absolute inset-s-4 top-4 h-4 w-4 text-muted-foreground"}),s.jsx(Dn,{ref:k,value:x,onChange:R=>w(R.target.value),placeholder:o(M?"sidebarFilesTree.search.contentsPlaceholder":"sidebarFilesTree.search.placeholder"),className:Le("h-8 ps-8 typography-meta",M?"pe-16":"pe-8")}),M?s.jsx(dt,{variant:"chip",size:"xs","aria-pressed":j,onClick:()=>{v(R=>!R),k.current?.focus()},title:o("sidebarFilesTree.search.regexTitle"),"aria-label":o("sidebarFilesTree.search.regexTitle"),className:"absolute inset-e-3 top-3.5 h-5 min-w-0 px-1 font-mono typography-micro",children:".*"}):null,x.trim().length>0?s.jsx("button",{type:"button","aria-label":o("sidebarFilesTree.search.clearAria"),className:Le("absolute top-4 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",M?"inset-e-10":"inset-e-4"),onClick:()=>{w(""),k.current?.focus()},children:s.jsx(se,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsxs(hs,{ref:Hs,outerClassName:"h-full min-h-0",className:Le("@container px-1.5 py-1.5 [overflow-anchor:none]",(ht===c||P===c)&&"bg-interactive-selection/10"),onDragEnter:ds,onDragOver:ds,onDragLeave:us,onDrop:Jt,children:[s.jsx("ul",{className:"flex flex-col",children:M&&W.status!=="idle"?s.jsx(FS,{state:W,activeMatchKey:O&&O.path===ve?O.key:null,onOpen:je,onDragStart:st,onDragEnd:ye}):_?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(se,{name:"loader-4",className:"h-4 w-4 animate-spin"}),o("sidebarFilesTree.state.searching")]}):$n&&E.length===0?s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("mobile.files.search.empty")}):E.length>0?E.map(R=>{const I=ve===R.path;return s.jsx("li",{"data-file-tree-path":R.path,children:s.jsxs("button",{type:"button",onClick:()=>me(R),onDoubleClick:()=>me(R,{pin:!0}),draggable:!0,onDragStart:xe=>{bi(xe),Uo(null);const pe=R.relativePath||wo(c??"",R.path);!pe||pe==="."||(xe.dataTransfer.setData(ir,pe),xe.dataTransfer.effectAllowed="copy")},onDragEnd:xe=>{xi(xe)&&me(R)},className:Le("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",Vi(I)),title:R.path,children:[s.jsx(uo,{filePath:R.path,extension:R.extension,className:"size-3.5"}),s.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},children:`‎${R.relativePath??R.path}‎`})]})},R.path)}):Ln?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:Ln}),s.jsxs(dt,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{be()},children:[s.jsx(se,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})]}):hr&&c?null:s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("sidebarFilesTree.state.loading")})}),vo?s.jsx("ul",{ref:pt,className:"relative min-w-[max(100%,var(--oc-file-tree-width,0px))]",style:{height:fs.getTotalSize()},onFocus:Fn,onBlur:yo,children:fs.getVirtualItems().map(R=>{const I=rs[R.index];if(!I)return null;const xe=I.kind==="node"?I.node.path:void 0;return s.jsx("li",{ref:fs.measureElement,"data-index":R.index,"data-tree-row-path":xe,"data-tree-disclosure-path":I.kind==="node"?xe:`${I.directory}/`,"data-file-tree-path":I.kind==="node"&&I.node.type==="file"?xe:void 0,className:Le("absolute inset-x-0 top-0",I.kind==="node"&&"min-w-max"),style:{transform:`translateY(${R.start-z}px)`},children:Mn(I)},R.key)})}):null]}),ht?s.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-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(se,{name:_t?"loader-4":"folder-received",className:Le("size-4 flex-shrink-0",_t&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:Bn,children:o(_t?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Bn})})]}):P?s.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-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(se,{name:"folder-received",className:"size-4 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:gr,children:o("sidebarFilesTree.drop.moveTarget",{path:gr})})]}):null]}),Nt,s.jsx(tr,{open:!!q,onOpenChange:R=>!R&&ke(null),children:s.jsxs(sr,{children:[s.jsxs(nr,{children:[s.jsxs(rr,{children:[q==="createFile"&&o("sidebarFilesTree.dialog.createFile.title"),q==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.title"),q==="rename"&&o("sidebarFilesTree.dialog.rename.title"),q==="delete"&&o("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(or,{children:[q==="createFile"&&o("sidebarFilesTree.dialog.createFile.description",{path:Ee?.path??o("sidebarFilesTree.dialog.rootFallback")}),q==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.description",{path:Ee?.path??o("sidebarFilesTree.dialog.rootFallback")}),q==="rename"&&o("sidebarFilesTree.dialog.rename.description",{name:Ee?.name??""}),q==="delete"&&o("sidebarFilesTree.dialog.delete.description",{name:Ee?.name??""})]})]}),q!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Dn,{value:Ne,onChange:R=>ze(R.target.value),placeholder:o(q==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:R=>{R.key==="Enter"&&Is()},autoFocus:!0})}),s.jsxs($r,{children:[s.jsx(dt,{variant:"outline",onClick:()=>ke(null),disabled:Ue,children:o("sidebarFilesTree.dialog.cancel")}),s.jsx(dt,{variant:q==="delete"?"destructive":"default",onClick:()=>{Is()},disabled:Ue||q!=="delete"&&!Ne.trim(),children:Ue?s.jsx(se,{name:"loader-4",className:"size-4 animate-spin"}):o(q==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),s.jsx(tr,{open:J!==null,onOpenChange:R=>{R||le(null)},children:s.jsxs(sr,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(nr,{children:[s.jsx(rr,{children:o("sidebarFilesTree.dialog.move.title")}),s.jsx(or,{children:J?o("sidebarFilesTree.dialog.move.description",{name:So,folder:Wn(c,J.targetDirectory)}):null})]}),s.jsxs($r,{className:"w-full sm:items-center sm:justify-between",children:[s.jsxs("div",{className:"flex cursor-pointer items-center gap-2 typography-meta text-muted-foreground",onClick:()=>ee(!$),children:[s.jsx(Xo,{checked:!$,onChange:R=>ee(!R),ariaLabel:o("sidebarFilesTree.dialog.move.neverAsk")}),s.jsx("span",{children:o("sidebarFilesTree.dialog.move.neverAsk")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(dt,{variant:"ghost",onClick:()=>le(null),children:o("sidebarFilesTree.dialog.cancel")}),s.jsx(dt,{onClick:js,children:o("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function t2(t){return t.runtimeKey}const s2=ur(()=>Ot(()=>import("./WalkthroughView-DeaBPhAn.js"),__vite__mapDeps([207,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,208,186,187,188,189,190,191,192,193,194,195,181,182,183,185,196,197,198,199,200,201,202,203,209,210,211,204,212])).then(t=>({default:t.WalkthroughView}))),n2=ur(()=>Ot(()=>import("./DiffView-pFcLbagS.js"),__vite__mapDeps([213,1,2,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,208,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,186,187,188,189,190,191,192,193,194,195,181,182,183,214,185,196,197,198,199,200,201,202,203,206,209,212])).then(t=>({default:t.DiffView}))),r2=ur(()=>Ot(()=>import("./FilesView-Bod-r3C6.js"),__vite__mapDeps([215,1,2,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,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,216,217,218,219,181,182,183,220,221,200,222,186,187,188,189,190,191,192,193,194,195,223,197,224,225,226,201,202,199,206,227,228,212,203,229])).then(t=>({default:t.FilesView}))),cu=l.lazy(()=>Ot(()=>import("./useAppFontEffects-6HvTeJY2.js").then(t=>t.sf),__vite__mapDeps([3,1,2,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.PluginPane}))),El=l.lazy(()=>Ot(()=>import("./GuestSurfacePane-BTyjXjRj.js"),__vite__mapDeps([230,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.GuestSurfacePane}))),du={top:{container:"flex-col",page:"border-b border-border",vertical:!0},bottom:{container:"flex-col-reverse",page:"border-t border-border",vertical:!0},left:{container:"flex-row",page:"border-e border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-s border-border",vertical:!1}},o2=t=>{const e=$e.c(12),{mode:n,docking:r}=t,[o,i]=l.useState(null),a=du[r.dock],u=Math.max(og,o??r.size),c=a.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let d;e[0]!==a.page||e[1]!==c?(d=Le("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",c,a.page),e[0]=a.page,e[1]=c,e[2]=d):d=e[2];let f;e[3]!==a.vertical||e[4]!==u?(f=a.vertical?{height:u}:{width:u},e[3]=a.vertical,e[4]=u,e[5]=f):f=e[5];let p;e[6]!==n?(p=s.jsx(cu,{mode:n,onResize:i}),e[6]=n,e[7]=p):p=e[7];let m;return e[8]!==d||e[9]!==f||e[10]!==p?(m=s.jsx("div",{className:d,style:f,children:p}),e[8]=d,e[9]=f,e[10]=p,e[11]=m):m=e[11],m},Sn=(t,e)=>`${t}\0${e}`,i2=({visible:t,active:e,fill:n=!1,side:r})=>{const{t:o}=at(),i=X(k=>k.contextEditorTreeWidth),a=X(k=>k.setContextEditorTreeWidth),[u,c]=l.useState(!1),d=l.useRef(0),f=l.useRef(i),p=l.useRef(null),m=l.useRef(null),h=l.useRef(null),b=l.useCallback(k=>{const E=h.current;E&&(E.style.width=`${k}px`,E.style.setProperty("--oc-editor-tree-width",`${k}px`))},[]),g=k=>{if(t){try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}m.current=k.pointerId,c(!0),d.current=k.clientX,f.current=i,p.current=i,k.preventDefault()}},x=k=>{if(!u||m.current!==k.pointerId)return;const E=r==="left"?k.clientX-d.current:d.current-k.clientX,F=Jr(k.currentTarget)?-E:E,_=Ko(f.current+F);p.current!==_&&(p.current=_,b(_))},w=k=>{if(m.current!==k.pointerId)return;try{k.currentTarget.releasePointerCapture(k.pointerId)}catch{}const E=Ko(p.current??i);m.current=null,p.current=null,c(!1),a(E)},T=t?i:0;return s.jsxs("div",{ref:h,className:Le("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&(r==="left"?"me-auto":"ms-auto")),style:{width:`${u?p.current??T:T}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${u?p.current??i:i}px`,overflowX:"clip",transitionProperty:u?"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:Le("pointer-events-none absolute inset-y-0 z-20 w-px bg-border",r==="left"?"inset-e-0":"inset-s-0")}),t&&!n&&s.jsx("div",{className:Le("absolute top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",r==="left"?"inset-e-0":"inset-s-0",u&&"bg-[var(--interactive-border)]"),onPointerDown:g,onPointerMove:x,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Le("relative z-10 h-full shrink-0 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-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(QS,{visible:t&&e})})]})},an=t=>{const e=$e.c(12),{zone:n,isOpen:r,interactive:o,hidden:i,className:a,children:u}=t,c=!r||i;let d;e[0]!==u||e[1]!==c?(d=s.jsx(Kc,{paused:c,children:u}),e[0]=u,e[1]=c,e[2]=d):d=e[2];let f;e[3]!==o||e[4]!==d?(f=s.jsx(Wc.Provider,{value:!0,children:s.jsx(Hf.Provider,{value:o,children:d})}),e[3]=o,e[4]=d,e[5]=f):f=e[5];let p;e[6]!==a||e[7]!==f?(p=s.jsx("div",{className:a,children:f}),e[6]=a,e[7]=f,e[8]=p):p=e[8];let m;return e[9]!==p||e[10]!==n?(m=s.jsx(DS,{zone:n,children:p}),e[9]=p,e[10]=n,e[11]=m):m=e[11],m},a2=()=>{const{t}=at(),e=Vs()??"",n=l.useMemo(()=>e?cs(e):"",[e]),r=X(S=>n?S.contextPanelByDirectory[n]:void 0),o=mr(),i=o?.kind==="preparing",a=o?.kind==="ready"?o.directory:null,u=ao(o,e)??"",c=X(S=>S.contextSurfaceZones),d=X(S=>S.contextPanelByDirectory),f=X(S=>S.closeContextPanelTab),p=X(S=>S.closeContextFile),m=X(S=>S.openContextPanelTab),h=X(S=>S.openAgentBrowserTab),b=X(S=>S.openContextFile),g=X(S=>S.contextEditorTreeVisible),x=X(S=>S.contextEditorVisible),w=X(S=>S.fileTreeSide),T=gs(S=>S.setSelectedPath),k=lr(S=>S.headerSlot),E=l.useMemo(()=>r?.tabs??[],[r?.tabs]),F=Ir(S=>S.chatCovered),_=l.useMemo(()=>{const S=ne=>{const q=r?Mr(r,c,ne):null,ke=ne==="bottom"&&F;return{activeTab:q,isOpen:!!(r&&er(r,ne).isOpen&&q)&&!ke}};return{left:S("left"),right:S("right"),bottom:S("bottom")}},[F,r,c]),A={left:{..._.left,activeTab:Rr(_.left.activeTab,_.left.isOpen)},right:{..._.right,activeTab:Rr(_.right.activeTab,_.right.isOpen)},bottom:{..._.bottom,activeTab:Rr(_.bottom.activeTab,_.bottom.isOpen)}},D={left:Bo(A.left.isOpen),right:Bo(A.right.isOpen),bottom:Bo(A.bottom.isOpen)},y=S=>!D[S],N={left:Xn(A.left.isOpen),right:Xn(A.right.isOpen),bottom:Xn(A.bottom.isOpen)},j={left:Tr(A.left.isOpen,N.left,A.left.activeTab?.mode),right:Tr(A.right.isOpen,N.right,A.right.activeTab?.mode),bottom:Tr(A.bottom.isOpen,N.bottom,A.bottom.activeTab?.mode)},v=S=>{const ne=Zo(c,S);return{zone:ne,...A[ne]}},M=v("file"),W=v("chat"),G=v("browser"),O=v("diff"),Z=v("terminal"),Q=v("walkthrough"),[B,oe]=l.useState([]),H=l.useCallback((S,ne)=>{oe(q=>Ku(q,Sn(S,ne)))},[]),P=X(S=>S.liveBrowserTabLimit);l.useEffect(()=>t0((S,ne)=>{const q=ne.directory?cs(ne.directory):n;if(!q)return null;const ke=h(q,S,ne.sessionId);return ke&&H(q,ke),ke}),[n,h,H]),l.useEffect(()=>s0((S,ne)=>X.getState().contextPanelByDirectory[S]?.tabs?.some(ke=>ke.id===ne&&ke.mode==="browser")?(f(S,ne),!0):!1),[f]),l.useEffect(()=>Js(S=>{if(S.type!=="file-open-request")return;const ne=S.directory??e;ne&&b(ne,S.path)}),[e,b]),l.useEffect(()=>Js(S=>{if(S.type!=="plan-open-request")return;const ne=S.directory??e,q=Wf(ne,S.projectId);!ne||!q||X.getState().openProjectKnowledgePlan(ne,sg(q),S.planId)}),[e]);const te=_[G.zone].activeTab,J=te?.mode==="browser"?te.id:null;l.useEffect(()=>{e0(n,J)},[n,J]);const le=_[M.zone].activeTab;l.useEffect(()=>{if(!u||le?.mode!=="file"||!le.targetPath)return;const S=ks(le.targetPath)===ks(u);T(cs(u),le.targetPath,{allowOutsideRoot:!o&&S})},[u,o,le,T]);const K=l.useMemo(()=>E.some(S=>S.mode==="file"&&S.targetPath),[E]),U=l.useMemo(()=>E.some(S=>S.mode==="file"),[E]),$=K&&(x||!g),ee=M.activeTab?.mode==="file",Y=l.useCallback(S=>{n&&p(n,S)},[p,n]),ie=W.isOpen&&W.activeTab?.mode==="chat"?W.activeTab:null,V=ie?ho(ie.dedupeKey):null,fe=l.useMemo(()=>(ie?.targetDirectory?cs(ie.targetDirectory):"")||n||null,[ie?.targetDirectory,n]),Se=l.useMemo(()=>V?{sessionId:V,directory:fe}:null,[V,fe]);l.useEffect(()=>{if(!fe||!V||typeof window>"u")return;const S=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Po(fe,V,!1);return}Gc(V),Po(fe,V,!0)};S();const ne=window.setInterval(S,1e4);return window.addEventListener("focus",S),window.addEventListener("blur",S),document.addEventListener("visibilitychange",S),()=>{window.clearInterval(ne),window.removeEventListener("focus",S),window.removeEventListener("blur",S),document.removeEventListener("visibilitychange",S),Po(fe,V,!1)}},[fe,V]);const Te=O.activeTab,ue=l.useCallback(S=>{!n||Te?.mode!=="diff"||m(n,{mode:"diff",targetPath:Te.targetPath,targetDirectory:Te.targetDirectory,stagedDiff:S==="staged",diffScope:S})},[Te,n,m]),Me=G.isOpen&&G.activeTab?.mode==="browser"?G.activeTab.id:null;l.useEffect(()=>{Me&&n&&H(n,Me)},[n,Me,H]);const{loadedBrowserTabs:Ae,sleepingBrowserTabs:De}=l.useMemo(()=>{const S=new Set(B),ne=new Set;for(const[Ie,Ne]of Object.entries(d))for(const ze of Ne.tabs)ze.mode==="browser"&&ze.ownerSessionId===null&&ne.add(Sn(Ie,ze.id));const q=Gu(B,ne,P),ke=[],Ee=[];for(const[Ie,Ne]of Object.entries(d)){const ze=Ie===n;for(const Ue of Ne.tabs){if(Ue.mode!=="browser")continue;const Ge=Sn(Ie,Ue.id),Qe=Ue.ownerSessionId===null,He=ze&&Ue.id===Me||(Qe?q.has(Ge):S.has(Ge));if(!He&&!ze&&Qe)continue;const Ke={directory:Ie,id:Ue.id,targetPath:Ue.targetPath,ownerSessionId:Ue.ownerSessionId};(He?ke:Ee).push(Ke)}}return ke.sort((Ie,Ne)=>Sn(Ie.directory,Ie.id)<Sn(Ne.directory,Ne.id)?-1:1),{loadedBrowserTabs:ke,sleepingBrowserTabs:Ee}},[d,n,P,B,Me]);l.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const S=De.map(ne=>Qv({tabId:ne.id,directory:ne.directory,ownerSessionId:ne.ownerSessionId,describe:()=>({title:"",url:ne.targetPath??""}),wake:()=>H(ne.directory,ne.id)}));return()=>S.forEach(ne=>ne())},[De,H]);const Be=l.useMemo(()=>E.filter(S=>S.mode==="diff"),[E]),we=l.useMemo(()=>E.find(S=>S.mode==="terminal")??null,[E]),ve=l.useMemo(()=>E.find(S=>S.mode==="walkthrough")??null,[E]),Pe=l.useMemo(()=>E.filter(S=>Pn(S.mode)),[E]),he=Ri(S=>S.guests),Fe=l.useMemo(()=>new Set(he.filter(ng).map(S=>S.id)),[he]),_e=l.useMemo(()=>{const S=new Map;for(const ne of he){const q=rg(ne);q&&S.set(ne.id,q)}return S},[he]),We=Z.zone,Xe=l.useCallback(S=>{const ne=Xi({mode:"terminal",label:t("layout.mainTab.terminal"),from:We},S);return{finish:()=>ne.finish(n),cancel:ne.cancel}},[n,t,We]),Ve=(S,ne)=>ne?k[S]:null;return s.jsxs(s.Fragment,{children:[U?s.jsxs(an,{zone:M.zone,interactive:j[M.zone],isOpen:M.isOpen,hidden:y(M.zone),className:Le("absolute inset-0 flex",w==="left"&&"flex-row-reverse",ee?"flex":"hidden"),children:[i?s.jsx("div",{className:"h-full min-w-0 flex-1",children:s.jsx(Nr,{})}):K||!g?s.jsx("div",{className:Le("h-full min-w-0 flex-1",K&&!$&&"hidden"),children:K?s.jsx(l.Suspense,{fallback:null,children:s.jsx(r2,{mode:"editor-only",visible:!y(M.zone)&&ee&&$,onCloseFile:Y})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(se,{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,i?null:s.jsx(i2,{visible:g,active:M.isOpen&&ee,fill:!$,side:w})]}):null,ie&&V&&Se?s.jsx(an,{zone:W.zone,interactive:j[W.zone],isOpen:W.isOpen,hidden:y(W.zone),className:"absolute inset-0 bg-background",children:s.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:V}),className:"h-full",children:s.jsx(bc,{pinnedSession:Se,readOnly:ie.readOnly})})},ie.id):null,Ae.map(S=>{const ne=S.directory===n&&G.activeTab?.id===S.id,q=S.directory===n?a??S.directory:S.directory;return s.jsx(an,{zone:G.zone,interactive:j[G.zone],isOpen:G.isOpen,hidden:y(G.zone),className:Le("absolute inset-0",!ne&&"invisible pointer-events-none"),children:s.jsx("div",{className:"h-full","aria-hidden":!ne||void 0,children:s.jsx(Kc,{paused:!ne,children:S.directory===n&&i?s.jsx(Nr,{}):s.jsx(NS,{initialUrl:S.targetPath??"",directory:S.directory,siteDirectory:q,tabID:S.id,ownerSessionId:S.ownerSessionId,visible:ne&&G.isOpen},q)})})},Sn(S.directory,S.id))}),Be.map(S=>{const ne=O.activeTab?.id===S.id;return s.jsx(an,{zone:O.zone,interactive:j[O.zone],isOpen:O.isOpen,hidden:y(O.zone),className:Le("absolute inset-0",!ne&&"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(cn,{value:Ve(O.zone,ne),children:i&&!S.targetDirectory?s.jsx(Nr,{}):s.jsx(n2,{directory:S.targetDirectory??a,visible:O.isOpen&&ne,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:S.diffScope??(S.stagedDiff?"staged":null),onDiffScopeChange:ue,targetFilePath:S.targetPath,flushContent:!0})})})},S.id)}),we?s.jsx(an,{zone:Z.zone,interactive:j[Z.zone],isOpen:Z.isOpen,hidden:y(Z.zone),className:Le("absolute inset-0",Z.activeTab?.mode==="terminal"?"block":"hidden"),children:s.jsx(cn,{value:Ve(Z.zone,Z.activeTab?.mode==="terminal"),children:s.jsx(Uf.Provider,{value:Xe,children:s.jsx(Vf,{visible:Z.isOpen&&Z.activeTab?.mode==="terminal",directory:we.targetDirectory,onLastTabClosed:()=>{n&&f(n,we.id)}})})})}):null,ve?s.jsx(an,{zone:Q.zone,interactive:j[Q.zone],isOpen:Q.isOpen,hidden:y(Q.zone),className:Le("absolute inset-0",Q.activeTab?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(cn,{value:Ve(Q.zone,Q.activeTab?.mode==="walkthrough"),children:s.jsx(s2,{directory:ve.targetDirectory??e,visible:Q.isOpen&&Q.activeTab?.mode==="walkthrough"})})})}):null,Pe.map(S=>{if(!Pn(S.mode))return null;const ne=v(S.mode),q=Fr(S.mode),ke=Fe.has(q),Ee=_e.get(q),Ie=ne.activeTab?.id===S.id,Ne=Ie&&ne.isOpen;return ke&&!Ee&&!Ne?null:s.jsx(an,{zone:ne.zone,interactive:j[ne.zone],isOpen:ne.isOpen,hidden:y(ne.zone),className:Le("absolute inset-0",Ie?"block":"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:ke?Ee?s.jsxs("div",{className:Le("flex h-full",du[Ee.dock].container),children:[s.jsx(o2,{mode:S.mode,docking:Ee}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Ne?s.jsx(El,{mode:S.mode}):null})]}):s.jsx(El,{mode:S.mode}):s.jsx(cu,{mode:S.mode})})},S.id)})]})},l2={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},c2=()=>{const t=$e.c(20),{t:e}=at(),n=Us(d2),r=Us(u2),o=l.useRef(null),[i,a]=l.useState(!1);let u,c;t[0]!==n?(u=()=>{if(!n){a(!1);return}const w=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(w)},c=[n],t[0]=n,t[1]=u,t[2]=c):(u=t[1],c=t[2]),l.useEffect(u,c);let d,f;if(t[3]!==n?(d=()=>{if(!n)return;const w=T=>{const k=o.current;k&&(k.style.transform=`translate(${T.clientX+12}px, ${T.clientY+12}px)`)};return window.addEventListener("pointermove",w),()=>window.removeEventListener("pointermove",w)},f=[n],t[3]=n,t[4]=d,t[5]=f):(d=t[4],f=t[5]),l.useEffect(d,f),!n)return null;const p=i?"opacity-100":"opacity-0";let m;t[6]!==p?(m=Le("absolute inset-0 bg-surface-overlay/40 transition-opacity duration-150 ease-out motion-reduce:transition-none",p),t[6]=p,t[7]=m):m=t[7];let h;t[8]!==m?(h=s.jsx("div",{className:m}),t[8]=m,t[9]=h):h=t[9];let b;t[10]!==n.frames||t[11]!==r||t[12]!==e?(b=Ti.map(w=>{const T=n.frames[w];if(T.width<=0||T.height<=0)return null;const k=r===w;return s.jsx("div",{className:Le("absolute flex items-center justify-center rounded-[10px] border transition-colors duration-100",k?"border-primary bg-background/90 text-foreground shadow-sm":"border-border bg-background/80 text-muted-foreground"),style:{left:T.left,top:T.top,width:T.width,height:T.height},children:s.jsx("span",{className:"typography-ui-label",children:e(l2[w])})},w)}),t[10]=n.frames,t[11]=r,t[12]=e,t[13]=b):b=t[13];let g;t[14]!==n.label?(g=s.jsx("div",{ref:o,className:"absolute left-0 top-0 rounded-md border border-border bg-background px-2 py-1 typography-meta text-foreground shadow-sm",children:n.label}),t[14]=n.label,t[15]=g):g=t[15];let x;return t[16]!==h||t[17]!==b||t[18]!==g?(x=Hl.createPortal(s.jsxs("div",{className:"pointer-events-none fixed inset-0 z-[60]","aria-hidden":"true",children:[h,b,g]}),document.body),t[16]=h,t[17]=b,t[18]=g,t[19]=x):x=t[19],x};function d2(t){return t.drag}function u2(t){return t.hovered}const Il=320,f2=({rowWidth:t,leftWidth:e,rightWidth:n,sidebarWidth:r,opening:o})=>{let i=t-e-n;if(i>=Il)return{collapseSidebar:!1,displace:null};const a=r!==null;if(a&&(i+=r),i>=Il)return{collapseSidebar:a,displace:null};const u=o==="left"?"right":"left";return{collapseSidebar:a,displace:(u==="left"?e:n)>0?u:null}},p2=({directoryKey:t,folded:e,readRowWidth:n})=>{const r=x=>{const w=x.contextPanelByDirectory[t];return{left:Kn(w,x.contextSurfaceZones,"left"),right:Kn(w,x.contextSurfaceZones,"right")}},o=(x,w,T)=>{const k=x.contextPanelByDirectory[t];return(T&&k?Mr(k,x.contextSurfaceZones,w):null)?x.contextZoneSizes[w]??Ci:0},i=x=>{const w=x.contextPanelByDirectory[t];return w?Ti.some(T=>er(w,T).expanded&&Zu(w,x,T)):!1};let a=null,u=!1,c=r(X.getState()),d=i(X.getState());const f=x=>{e.current=x,X.getState().setSidebarFoldedForExpandedZone(x==="expanded")},p=x=>{u=!0,X.getState().setSidebarOpen(x),u=!1},m=()=>{f(null),X.getState().isSidebarOpen||p(!0)};!e.current&&X.getState().sidebarFoldedForExpandedZone&&(e.current="expanded");const h=e.current;h&&!(h==="expanded"?d:c[h])&&m(),!e.current&&d&&X.getState().isSidebarOpen&&(f("expanded"),p(!1));const b=(x,w,T)=>{const k=n();if(!k)return;const E=e.current==="expanded",F=f2({rowWidth:E?k-x.sidebarWidth:k,leftWidth:o(x,"left",T.left),rightWidth:o(x,"right",T.right),sidebarWidth:x.isSidebarOpen||E?x.sidebarWidth:null,opening:w});if(F.displace){const _=er(x.contextPanelByDirectory[t],F.displace).activeTabId;_&&(a={side:F.displace,by:w,tabId:_})}F.collapseSidebar&&(f(w),x.isSidebarOpen&&p(!1)),F.displace&&x.closeContextZone(t,F.displace)},g=x=>{if(a?.side===x){e.current===x&&f(a.by);return}const w=a?.by===x?a:null;w&&(a=null),e.current===x&&(w?f(w.side):m()),w&&X.getState().setActiveContextPanelTab(t,w.tabId)};return X.subscribe((x,w)=>{x.isSidebarOpen!==w.isSidebarOpen&&!u&&f(null);const T=r(x),k=i(x),E=c,F=d;c=T,d=k;const _=["left","right"],A=_.filter(y=>T[y]&&!E[y]),D=_.filter(y=>!T[y]&&E[y]);for(const y of D){const N=y==="left"?"right":"left";A.includes(N)&&(e.current===y&&f(N),a?.by===y&&(a=null))}for(const y of D)g(y);for(const y of A)b(x,y,T);k&&!F&&x.isSidebarOpen?(f("expanded"),p(!1)):!k&&F&&e.current==="expanded"&&m()})},m2=()=>{const t=$e.c(5),e=Vs();let n;t[0]!==e?(n=e?cs(e):"",t[0]=e,t[1]=n):n=t[1];const r=n,o=l.useRef(null);let i,a;return t[2]!==r?(i=()=>{if(r)return p2({directoryKey:r,folded:o,readRowWidth:h2})},a=[r],t[2]=r,t[3]=i,t[4]=a):(i=t[3],a=t[4]),l.useEffect(i,a),null};function h2(){return document.querySelector("[data-workspace-row]")?.clientWidth}const g2=t=>{const e=$e.c(54),{open:n,onOpenChange:r}=t,{t:o}=at(),i=X(b2),a=X(x2),u=X(w2),c=X(y2),d=X(v2),f=Ui(),p=X(ig);let m;if(e[0]!==i||e[1]!==f||e[2]!==p){let B;e[4]!==p?(B=oe=>p||oe.id!=="workflows",e[4]=p,e[5]=B):B=e[5],m=Yo(i,f).filter(B),e[0]=i,e[1]=f,e[2]=p,e[3]=m}else m=e[3];const h=m,b=u.length===0;let g;if(e[6]!==u||e[7]!==h){let B;e[9]!==u?(B=oe=>u.includes(oe.id),e[9]=u,e[10]=B):B=e[10],g=h.every(B),e[6]=u,e[7]=h,e[8]=g}else g=e[8];const x=g,w=l.useRef(!1);let T;e[11]!==u||e[12]!==h||e[13]!==o?(T=h.map((B,oe)=>({id:B.id,label:B.label??o(B.labelKey),visible:!u.includes(B.id),groupStart:oe>0&&Ks(h[oe-1])!==Ks(B)})),e[11]=u,e[12]=h,e[13]=o,e[14]=T):T=e[14];const k=T;let E;e[15]!==i||e[16]!==f||e[17]!==a?(E=B=>{const oe=Yo(B,f).map(S2).filter(P=>B.includes(P)),H=new Set(oe);a([...oe,...i.filter(P=>!H.has(P))])},e[15]=i,e[16]=f,e[17]=a,e[18]=E):E=e[18];const F=E;let _;e[19]!==r?(_=(B,oe)=>{if(!B&&oe.reason==="escape-key"&&w.current){oe.cancel(),oe.allowPropagation();return}w.current=!1,r(B)},e[19]=r,e[20]=_):_=e[20];let A;e[21]===Symbol.for("react.memo_cache_sentinel")?(A=B=>{w.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(B.key)&&B.preventBaseUIHandler()},e[21]=A):A=e[21];let D;e[22]!==o?(D=o("contextRail.configure.dialogTitle"),e[22]=o,e[23]=D):D=e[23];let y;e[24]!==D?(y=s.jsx(rr,{children:D}),e[24]=D,e[25]=y):y=e[25];let N;e[26]!==o?(N=o("contextRail.configure.dialogDescription"),e[26]=o,e[27]=N):N=e[27];let j;e[28]!==N?(j=s.jsx(or,{children:N}),e[28]=N,e[29]=j):j=e[29];let v;e[30]!==j||e[31]!==y?(v=s.jsxs(nr,{children:[y,j]}),e[30]=j,e[31]=y,e[32]=v):v=e[32];let M;e[33]!==o?(M=o("contextRail.configure.dragInstructions"),e[33]=o,e[34]=M):M=e[34];let W;e[35]===Symbol.for("react.memo_cache_sentinel")?(W=B=>{w.current=B},e[35]=W):W=e[35];let G;e[36]!==F||e[37]!==k||e[38]!==c||e[39]!==M?(G=s.jsx(qf,{items:k,onVisibleChange:c,onReorder:F,settingsItemPrefix:"layout.context-rail.surface.",dragInstructions:M,onDraggingChange:W}),e[36]=F,e[37]=k,e[38]=c,e[39]=M,e[40]=G):G=e[40];let O;e[41]!==b||e[42]!==x||e[43]!==d||e[44]!==o?(O=b?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[x?s.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(dt,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[41]=b,e[42]=x,e[43]=d,e[44]=o,e[45]=O):O=e[45];let Z;e[46]!==v||e[47]!==G||e[48]!==O?(Z=s.jsxs(sr,{className:"max-w-md",onKeyDown:A,children:[v,G,O]}),e[46]=v,e[47]=G,e[48]=O,e[49]=Z):Z=e[49];let Q;return e[50]!==n||e[51]!==Z||e[52]!==_?(Q=s.jsx(tr,{open:n,onOpenChange:_,children:Z}),e[50]=n,e[51]=Z,e[52]=_,e[53]=Q):Q=e[53],Q};function b2(t){return t.contextRailOrder}function x2(t){return t.setContextRailOrder}function w2(t){return t.contextRailHiddenSurfaces}function y2(t){return t.setContextRailSurfaceVisible}function v2(t){return t.setContextRailHiddenSurfaces}function S2(t){return t.id}const uu=150,k2=500,j2=[],C2=t=>{const e=$e.c(70),{surface:n,isActive:r,showActivityDot:o,label:i,description:a,badgeCount:u,badgeAriaLabel:c,badgeDescription:d,orderNumber:f,showOrderNumber:p,onSelect:m}=t,h=X(E2);let b;e[0]!==h?(b=Ii("switch_context_surface",h),e[0]=h,e[1]=b):b=e[1];const g=b;let x;e[2]!==f||e[3]!==g?(x=g&&g!==wc&&f!=null&&f<=10?xs(`${g}+${f===10?"0":f}`):void 0,e[2]=f,e[3]=g,e[4]=x):x=e[4];const w=x;let T;e[5]!==n.id?(T={id:n.id},e[5]=n.id,e[6]=T):T=e[6];const{attributes:k,listeners:E,setNodeRef:F,transform:_,transition:A,isDragging:D}=ud(T),y=u!=null&&u>0;let N;e[7]!==_?(N=pd.Translate.toString(_),e[7]=_,e[8]=N):N=e[8];let j;e[9]!==N||e[10]!==A?(j={transform:N,transition:A},e[9]=N,e[10]=A,e[11]=j):j=e[11];const v=D&&"z-10 opacity-70";let M;e[12]!==v?(M=Le("relative",v),e[12]=v,e[13]=M):M=e[13];let W;e[14]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx("div",{}),e[14]=W):W=e[14];let G;e[15]!==m||e[16]!==n?(G=()=>m(n),e[15]=m,e[16]=n,e[17]=G):G=e[17];const O=c??i,Z=n.id,Q=r?"text-primary":"text-muted-foreground hover:text-foreground";let B;e[18]!==Q?(B=Le("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",Q),e[18]=Q,e[19]=B):B=e[19];let oe;e[20]!==n.icon||e[21]!==n.iconSrc||e[22]!==n.id?(oe=n.id==="diff"?s.jsx(hc,{className:"h-[17px] w-[17px]"}):s.jsx(Pi,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[17px] w-[17px]"}),e[20]=n.icon,e[21]=n.iconSrc,e[22]=n.id,e[23]=oe):oe=e[23];let H;e[24]!==y||e[25]!==f||e[26]!==o||e[27]!==p?(H=p&&f!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-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:f===10?"0":f}):y?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):o?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[24]=y,e[25]=f,e[26]=o,e[27]=p,e[28]=H):H=e[28];let P;e[29]!==k||e[30]!==r||e[31]!==E||e[32]!==n.id||e[33]!==O||e[34]!==B||e[35]!==oe||e[36]!==H||e[37]!==G?(P=s.jsx(Ft,{asChild:!0,children:s.jsxs("button",{type:"button",...k,...E,onClick:G,"aria-label":O,"aria-pressed":r,"data-context-surface":Z,className:B,children:[oe,H]})}),e[29]=k,e[30]=r,e[31]=E,e[32]=n.id,e[33]=O,e[34]=B,e[35]=oe,e[36]=H,e[37]=G,e[38]=P):P=e[38];let te;e[39]!==h||e[40]!==n.id||e[41]!==w?(te=n.id==="terminal"?xs(Ts("toggle_terminal",h),""):w,e[39]=h,e[40]=n.id,e[41]=w,e[42]=te):te=e[42];let J;e[43]!==i||e[44]!==te?(J=s.jsx(Ws,{label:i,shortcut:te}),e[43]=i,e[44]=te,e[45]=J):J=e[45];let le;e[46]!==a?(le=s.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),e[46]=a,e[47]=le):le=e[47];let K;e[48]!==d?(K=d?s.jsx("span",{className:"typography-micro text-muted-foreground",children:d}):null,e[48]=d,e[49]=K):K=e[49];let U;e[50]!==n.id?(U=n.id==="context"?s.jsx(bd,{}):null,e[50]=n.id,e[51]=U):U=e[51];let $;e[52]!==J||e[53]!==le||e[54]!==K||e[55]!==U?($=s.jsx($t,{side:"left",sideOffset:8,className:"max-w-72 break-words",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[J,le,K,U]})}),e[52]=J,e[53]=le,e[54]=K,e[55]=U,e[56]=$):$=e[56];let ee;e[57]!==P||e[58]!==$?(ee=s.jsx(ro,{render:W,children:s.jsxs(Lt,{delayDuration:uu,children:[P,$]})}),e[57]=P,e[58]=$,e[59]=ee):ee=e[59];let Y;e[60]!==n.mode?(Y=s.jsx(oo,{children:s.jsx(mc,{mode:n.mode})}),e[60]=n.mode,e[61]=Y):Y=e[61];let ie;e[62]!==ee||e[63]!==Y?(ie=s.jsxs(pr,{children:[ee,Y]}),e[62]=ee,e[63]=Y,e[64]=ie):ie=e[64];let V;return e[65]!==F||e[66]!==ie||e[67]!==j||e[68]!==M?(V=s.jsx("div",{ref:F,style:j,className:M,children:ie}),e[65]=F,e[66]=ie,e[67]=j,e[68]=M,e[69]=V):V=e[69],V},T2=t=>{if(!t)return{icon:"ticket-2"};const e=ug(t,"line");return e?{icon:e}:{icon:fg,iconSrc:pg(t)}},N2=()=>{const t=$e.c(122),{t:e}=at(),n=Vs();let r;t[0]!==n?(r=n?cs(n):"",t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=Oe=>o?Oe.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const a=X(i),u=X(I2),c=X(P2),d=X(R2),f=X(D2),p=X(A2),m=X(_2),h=X(O2),b=X(M2),g=Xu();let x;t[4]!==g?(x=Oe=>g.some(me=>me.instances.defaultInstance!==null&&Oe.entries[Vn({provider:me.id,instance:me.instances.defaultInstance})]?.hasChecked===!0),t[4]=g,t[5]=x):x=t[5];const w=fn(x),T=fn(L2),k=ag(o||null),E=ji(k==="none"?null:k??g[0]?.id),F=k==="none"?"pullRequest":E.terminology.changeRequest,{screenWidth:_}=gn(),A=mr(),D=n??null;let y;t[6]!==A||t[7]!==D?(y=ao(A,D),t[6]=A,t[7]=D,t[8]=y):y=t[8];const N=y,j=lg(N),v=lo(j),{git:M}=Es(),W=An($2),G=An(B2);let O,Z;t[9]!==W||t[10]!==G||t[11]!==M||t[12]!==j||t[13]!==N?(O=()=>{if(!M||!N||!j||j===N)return;oa(()=>W(j,M));const Oe=Xt(N),me=Xt(j);return Wr.onGitRefreshHint(je=>{const st=Xt(je.directory);st!==Oe&&st!==me||oa(()=>G(j,M,{silent:!0}))})},Z=[W,G,M,j,N],t[9]=W,t[10]=G,t[11]=M,t[12]=j,t[13]=N,t[14]=O,t[15]=Z):(O=t[14],Z=t[15]),l.useEffect(O,Z);let Q;t[16]!==b?(Q=Ii("switch_context_surface",b),t[16]=b,t[17]=Q):Q=t[17];const B=Q,[oe,H]=l.useState(!1);let P,te;t[18]!==B?(te=()=>{const Oe=new Set;let me=null,je=!1;const st=z2,ye=()=>{Ra(B,Oe)?!je&&me===null&&(me=setTimeout(()=>H(!0),k2)):(je=!1,me!==null&&(clearTimeout(me),me=null),H(!1))},ot=jt=>{if(Oe.add(jt.key.toLowerCase()),st(jt.key)&&Ra(B,Oe)){je=!0,me!==null&&(clearTimeout(me),me=null),H(!1);return}ye()},Ct=jt=>{Oe.delete(jt.key.toLowerCase()),ye()},xt=()=>{Oe.clear(),je=!1,me!==null&&(clearTimeout(me),me=null),H(!1)};return window.addEventListener("keydown",ot,!0),window.addEventListener("keyup",Ct,!0),window.addEventListener("blur",xt),()=>{window.removeEventListener("keydown",ot,!0),window.removeEventListener("keyup",Ct,!0),window.removeEventListener("blur",xt),me!==null&&clearTimeout(me)}},P=[B],t[18]=B,t[19]=P,t[20]=te):(P=t[19],te=t[20]),l.useEffect(te,P);let J;t[21]===Symbol.for("react.memo_cache_sentinel")?(J={activationConstraint:{distance:8}},t[21]=J):J=t[21];let le;t[22]===Symbol.for("react.memo_cache_sentinel")?(le={activationConstraint:{delay:200,tolerance:6}},t[22]=le):le=t[22];const K=ad(Ur(cd,J),Ur(ld,le)),U=Ui(),$=Pa(W2),ee=Pa(U2),Y=a?.tabs??j2,ie=cg(Y,n||null);let V;t[23]!==h||t[24]!==a?(V=vi(a,h),t[23]=h,t[24]=a,t[25]=V):V=t[25];const fe=V,Se=v?.files.length??0;let Te;if(t[26]!==d||t[27]!==c||t[28]!==U||t[29]!==k||t[30]!==_||t[31]!==T||t[32]!==Y||t[33]!==E||t[34]!==ie){let Oe;t[36]!==k||t[37]!==E?(Oe=me=>me.id==="pr"?{...me,...T2(k==="none"?null:E)}:me,t[36]=k,t[37]=E,t[38]=Oe):Oe=t[38],Te=dg({railOrder:c,hiddenSurfaces:d,isVSCode:Si(),screenWidth:_,tabs:Y,sourceControlConnected:T,workflowsShown:ie,extras:U}).map(Oe),t[26]=d,t[27]=c,t[28]=U,t[29]=k,t[30]=_,t[31]=T,t[32]=Y,t[33]=E,t[34]=ie,t[35]=Te}else Te=t[35];const ue=Te;let Me;t[39]!==Y?(Me=Y.some(V2),t[39]=Y,t[40]=Me):Me=t[40];const Ae=Me;let De,Be;t[41]!==m||t[42]!==h||t[43]!==w||t[44]!==o||t[45]!==Ae||t[46]!==fe||t[47]!==T?(De=()=>{!o||!w||T||Ae||!fe.has("pr")||m(o,Zo(h,"pr"))},Be=[m,h,o,w,Ae,fe,T],t[41]=m,t[42]=h,t[43]=w,t[44]=o,t[45]=Ae,t[46]=fe,t[47]=T,t[48]=De,t[49]=Be):(De=t[48],Be=t[49]),l.useEffect(De,Be);const[we,ve]=l.useState(!1),Pe=l.useRef(null),he=l.useRef(null);let Fe;t[50]!==F||t[51]!==ue||t[52]!==e?(Fe=Oe=>{const me=ue.find(st=>st.id===Oe.active.id),je=Pe.current?.getBoundingClientRect().left;!me||je===void 0||(he.current?.cancel(),he.current=Xi({mode:me.mode,label:me.label??e($s(me.labelKey,F)),from:Zo(X.getState().contextSurfaceZones,me.mode)},st=>st.x<je-16))},t[50]=F,t[51]=ue,t[52]=e,t[53]=Fe):Fe=t[53];const _e=Fe;let We;t[54]===Symbol.for("react.memo_cache_sentinel")?(We=()=>{he.current?.cancel(),he.current=null},t[54]=We):We=t[54];const Xe=We;let Ve,S;t[55]===Symbol.for("react.memo_cache_sentinel")?(Ve=()=>()=>he.current?.cancel(),S=[],t[55]=Ve,t[56]=S):(Ve=t[55],S=t[56]),l.useEffect(Ve,S);let ne;t[57]!==o||t[58]!==U||t[59]!==f?(ne=Oe=>{const me=he.current;if(he.current=null,me?.finish(o))return;const{active:je,over:st}=Oe;if(!st||je.id===st.id)return;const ye=Yo(X.getState().contextRailOrder,U),ot=ct=>{const vt=ye.find(St=>St.id===ct);return vt?Ks(vt):null};if(ot(je.id)!==ot(st.id))return;const Ct=ye.map(H2),xt=Ct.indexOf(je.id),jt=Ct.indexOf(st.id);xt===-1||jt===-1||f(Db(Ct,xt,jt))},t[57]=o,t[58]=U,t[59]=f,t[60]=ne):ne=t[60];const q=ne;let ke;if(t[61]!==ue){ke=[];for(const Oe of ue){const me=ke.at(-1);me&&Ks(me[0])===Ks(Oe)?me.push(Oe):ke.push([Oe])}t[61]=ue,t[62]=ke}else ke=t[62];const Ee=ke;let Ie;t[63]!==ue?(Ie=Oe=>{const me=ue.find(st=>st.id===Oe.active.id);if(!me)return ti(Oe);const je=Ks(me);return ti({...Oe,droppableContainers:Oe.droppableContainers.filter(st=>{const ye=ue.find(ot=>ot.id===st.id);return ye!==void 0&&Ks(ye)===je})})},t[63]=ue,t[64]=Ie):Ie=t[64];const Ne=Ie;if(!o)return null;let ze,Ue,Ge,Qe,He,Ke,Ye,it,bt,nt;if(t[65]!==F||t[66]!==Se||t[67]!==ee||t[68]!==Ne||t[69]!==o||t[70]!==Ee||t[71]!==$||t[72]!==q||t[73]!==_e||t[74]!==p||t[75]!==oe||t[76]!==K||t[77]!==fe||t[78]!==e||t[79]!==u){let Oe=0;it=Pe,t[90]!==e?(bt=e("contextRail.aria.rail"),t[90]=e,t[91]=bt):bt=t[91],nt="flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",ze=dd,Ue=K,Ge=Ne,Qe=_e,He=Xe,Ke=q,Ye=Ee.map((me,je)=>s.jsxs(l.Fragment,{children:[je>0?s.jsx("div",{"aria-hidden":"true",className:"h-px w-4 shrink-0 bg-edge-strong"}):null,s.jsx(fd,{items:me.map(q2),strategy:Rb,children:me.map(st=>{Oe=Oe+1;const ye=st.label??e($s(st.labelKey,F)),ot=st.id==="git"&&!u?Se:0,Ct=Pn(st.mode)&&!fe.has(st.mode)?$[Fr(st.mode)]??0:0,xt=ot>0?ot:Ct>0?Ct:null,jt=xt!==null&&ot===0;return s.jsx(C2,{surface:st,isActive:fe.has(st.mode),showActivityDot:!1,label:ye,description:e($s(st.descriptionKey,F)),badgeCount:xt,badgeAriaLabel:xt!==null?e(jt?xt===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":xt===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:ye,count:xt}):null,badgeDescription:xt!==null?e(jt?xt===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":xt===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:xt}):null,orderNumber:Oe,showOrderNumber:oe,onSelect:ct=>{Pn(ct.mode)&&ee(Fr(ct.mode)),p(o,ct.mode)}},st.id)})})]},Ks(me[0]))),t[65]=F,t[66]=Se,t[67]=ee,t[68]=Ne,t[69]=o,t[70]=Ee,t[71]=$,t[72]=q,t[73]=_e,t[74]=p,t[75]=oe,t[76]=K,t[77]=fe,t[78]=e,t[79]=u,t[80]=ze,t[81]=Ue,t[82]=Ge,t[83]=Qe,t[84]=He,t[85]=Ke,t[86]=Ye,t[87]=it,t[88]=bt,t[89]=nt}else ze=t[80],Ue=t[81],Ge=t[82],Qe=t[83],He=t[84],Ke=t[85],Ye=t[86],it=t[87],bt=t[88],nt=t[89];let ft;t[92]!==ze||t[93]!==Ue||t[94]!==Ge||t[95]!==Qe||t[96]!==He||t[97]!==Ke||t[98]!==Ye?(ft=s.jsx(ze,{sensors:Ue,collisionDetection:Ge,onDragStart:Qe,onDragCancel:He,onDragEnd:Ke,children:Ye}),t[92]=ze,t[93]=Ue,t[94]=Ge,t[95]=Qe,t[96]=He,t[97]=Ke,t[98]=Ye,t[99]=ft):ft=t[99];let ae;t[100]!==e?(ae=e("contextRail.configure.open"),t[100]=e,t[101]=ae):ae=t[101];let de;t[102]===Symbol.for("react.memo_cache_sentinel")?(de=()=>ve(!0),t[102]=de):de=t[102];let be;t[103]===Symbol.for("react.memo_cache_sentinel")?(be=s.jsx(se,{name:"equalizer-2",className:"h-[17px] w-[17px]"}),t[103]=be):be=t[103];let C;t[104]!==ae?(C=s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":ae,onClick:de,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground",children:be})}),t[104]=ae,t[105]=C):C=t[105];let ce;t[106]!==e?(ce=e("contextRail.configure.open"),t[106]=e,t[107]=ce):ce=t[107];let L;t[108]!==ce?(L=s.jsx($t,{side:"left",sideOffset:8,children:ce}),t[108]=ce,t[109]=L):L=t[109];let ge;t[110]!==C||t[111]!==L?(ge=s.jsxs(Lt,{delayDuration:uu,children:[C,L]}),t[110]=C,t[111]=L,t[112]=ge):ge=t[112];let Ce;t[113]!==we?(Ce=s.jsx(g2,{open:we,onOpenChange:ve}),t[113]=we,t[114]=Ce):Ce=t[114];let Je;return t[115]!==it||t[116]!==bt||t[117]!==nt||t[118]!==ft||t[119]!==ge||t[120]!==Ce?(Je=s.jsxs("nav",{ref:it,"aria-label":bt,className:nt,children:[ft,ge,Ce]}),t[115]=it,t[116]=bt,t[117]=nt,t[118]=ft,t[119]=ge,t[120]=Ce,t[121]=Je):Je=t[121],Je};function E2(t){return t.shortcutOverrides}function I2(t){return t.workStatusPanelVisible}function P2(t){return t.contextRailOrder}function R2(t){return t.contextRailHiddenSurfaces}function D2(t){return t.setContextRailOrder}function A2(t){return t.openContextSurface}function _2(t){return t.closeContextZone}function O2(t){return t.contextSurfaceZones}function M2(t){return t.shortcutOverrides}function F2(t){return t.status?.status==="connected"}function L2(t){return Object.values(t.entries).some(F2)}function $2(t){return t.ensureStatus}function B2(t){return t.fetchStatus}function z2(t){return t.length===1&&t>="0"&&t<="9"}function W2(t){return t.countByGuest}function U2(t){return t.clearBadge}function V2(t){return t.mode==="pr"&&t.targetPath}function H2(t){return t.id}function q2(t){return t.id}const As=t=>t?s.jsx("span",{className:"oc-title-rest",children:t}):void 0,Ss=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},K2=()=>{const{t}=at(),{git:e,sourceControl:n}=Es(),[r,o]=l.useState(!1),[i,a]=l.useState(null),[u,c]=l.useState([]),[d,f]=l.useState(!1),[p,m]=l.useState(!1),[h,b]=l.useState(!1),[g,x]=l.useState(!1),[w,T]=l.useState(new Set),k=et(S=>S.getWorktreeMetadata),E=et(S=>S.newSessionDraft),F=et(S=>S.setNewSessionDraftTarget),_=et(S=>S.setDraftBootstrapPendingDirectory),A=hg,D=yg,y=et(S=>S.deleteSessions),N=et(S=>S.archiveSessions),j=et(S=>S.unarchiveSessions),v=X(S=>S.showDeletionDialog),M=X(S=>S.setShowDeletionDialog),W=ls(S=>S.currentDirectory),G=ls(S=>S.homeDirectory),O=ts(S=>S.projects),Z=ts(S=>S.activeProjectId),{isMobile:Q,isTablet:B,hasTouchInput:oe}=gn(),H=Q||B||oe,P=l.useMemo(()=>{const ne=(Z?O.find(q=>q.id===Z)??null:null)?.path??W;return Ss(ne)},[Z,W,O]),te=l.useCallback(S=>{const q=Ss(S.projectDirectory)||P;return{id:(O.find(Ee=>Ss(Ee.path)===q)??null)?.id??`path:${q}`,path:q}},[P,O]),J=g&&w.size>0,[le,K]=l.useState(!1),U=i?.mode==="worktree"?i.worktree??u[0]?.metadata??null:null,$=U?.path,ee=U?.branch,Y=U?te(U).path:null;l.useEffect(()=>{if(K(!1),!$||!Y)return;let S=!1;return mg(Y,{path:$,branch:ee??""}).then(ne=>{S||K(ne)}),()=>{S=!0}},[ee,$,Y]);const ie=l.useMemo(()=>{if(!le)return!1;const S=i?.worktree;return S&&typeof S.branch=="string"&&S.branch.trim().length>0?!!S.status?.upstream?.split("/")[0]?.trim():u.length>0&&u.every(({metadata:ne})=>typeof ne.branch=="string"&&ne.branch.trim().length>0&&!!ne.status?.upstream?.split("/")[0]?.trim())},[le,i?.worktree,u]),V=i?.mode==="worktree",fe=h||!V||!ie,Se=h||!V,Te=l.useCallback(S=>{a({sessions:S.sessions,dateLabel:S.dateLabel,mode:S.mode??"session",worktree:S.worktree??null})},[]),ue=l.useCallback(()=>{a(null),c([]),f(!1),m(!1),b(!1),x(!1),T(new Set)},[]),Me=l.useCallback(async S=>{if(S.sessions.length===0)return;if(S.sessions.length===1){const Ee=S.sessions[0];await A(Ee.id)?Re.success(t("sessions.sidebar.session.delete.success")):Re.error(t("sessions.sidebar.session.delete.error"));return}const ne=S.sessions.map(Ee=>Ee.id),{deletedIds:q,failedIds:ke}=await y(ne);if(q.length>0){const Ee=ke.length>0?ke.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:ke.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:ke.length}):S.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:S.dateLabel}):void 0;Re.success(q.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:q.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:q.length}),{description:As(Ee)})}ke.length>0&&Re.error(ke.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:ke.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:ke.length}),{description:As(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[A,y,t]);l.useEffect(()=>Wr.onDirectoryRequest(()=>{o(!0)}),[]),l.useEffect(()=>{if(!i){c([]),f(!1),m(!1),x(!1),T(new Set);return}const S=i.sessions.map(ke=>{const Ee=k(ke.id);return Ee?{session:ke,metadata:Ee}:null}).filter(ke=>!!ke);c(S),f(!1),x(!1),T(new Set);const ne=new Map;if(i.worktree?.path&&ne.set(Ss(i.worktree.path),i.worktree),S.forEach(({metadata:ke})=>{ke.path&&ne.set(Ss(ke.path),ke)}),ne.size===0){x(!0);return}let q=!1;return(async()=>{const ke=new Map,Ee=new Set;await Promise.all(Array.from(ne.entries()).map(async([Ie,Ne])=>{try{const ze=await Da(Ne.path);ke.set(Ie,ze),ze?.isDirty&&Ee.add(Ie)}catch{Ne.status&&(ke.set(Ie,Ne.status),Ne.status.isDirty&&Ee.add(Ie))}})).catch(Ie=>{console.warn("Failed to inspect worktree status before deletion:",Ie)}),!q&&(T(Ee),x(!0),a(Ie=>{if(!Ie?.worktree?.path)return Ie;const Ne=Ss(Ie.worktree.path),ze=ke.get(Ne);if(!ze)return Ie;const Ue=Ie.worktree.status;return Ue?.isDirty===ze.isDirty&&Ue?.ahead===ze.ahead&&Ue?.behind===ze.behind&&Ue?.upstream===ze.upstream?Ie:{...Ie,worktree:{...Ie.worktree,status:ze}}}),c(Ie=>Ie.map(Ne=>{const ze=Ss(Ne.metadata.path),Ue=ke.get(ze);return Ue?{session:Ne.session,metadata:{...Ne.metadata,status:Ue}}:Ne})))})(),()=>{q=!0}},[i,k]),l.useEffect(()=>{ie||f(!1)},[ie]);const Ae=l.useCallback(async(S,ne,q)=>{const ke=d&&ie,Ee=te(S),Ie=Ss(S.path),Ne=Ss(Ee.path);try{await gg(Ee,S,{deleteRemoteBranch:ke,deleteLocalBranch:ne,remoteName:S.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:n}});const ze=Ge=>!!(Ie&&Ge&&bg(Ie,Ge)),Ue=Ss(E?.directoryOverride);return E?.open&&ze(Ue)&&Ne&&(_(null),F({projectId:Ee.id,directoryOverride:Ne},{force:!0})),ze(Ss(W))&&Ne&&ls.getState().setDirectory(Ne,{showOverlay:!1}),!0}catch(ze){return Re.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:q,description:As(ze instanceof Error?ze.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[ie,W,d,te,e,E?.directoryOverride,E?.open,_,F,n,t]),De=l.useCallback((S,ne,q)=>{const ke=d&&ie,Ee=Re.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:Aa(S)}));return xg(S.path),(async()=>{try{const Ie=await wg({sessionIds:ne,removeWorktree:()=>Ae(S,q,Ee),restoreSessions:ze=>j(ze,{undo:!0}),archiveSessions:async ze=>ze.length===1?await D(ze[0])?{archivedIds:ze,failedIds:[]}:{archivedIds:[],failedIds:ze}:N(ze)});if(!Ie.removed)return;jc(ne,{projectId:te(S).id}),Re.success(t(ke?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed"),{id:Ee,description:As(Aa(S))});const{failedIds:Ne}=Ie.archive;Ne.length>0&&Re.error(Ne.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Ne.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:Ne.length}),{description:As(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(Ie){Re.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Ee,description:As(Ie instanceof Error?Ie.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}finally{vg(S.path)}})()},[D,N,ie,d,te,Ae,t,j]),Be=l.useRef(new Set),we=l.useCallback(async(S,ne)=>{const q=Ss(S.path);if(!Be.current.has(q)){Be.current.add(q);try{const ke=await Da(S.path).catch(()=>{});if(!Sg(ke)){Te({sessions:ne,mode:"worktree",worktree:S});return}await De(S,ne.map(Ee=>Ee.id),!0)}finally{Be.current.delete(q)}}},[Te,De]);l.useEffect(()=>Wr.onDeleteRequest(S=>{if(!v&&(S.mode??"session")==="session"){Me(S);return}if(S.mode==="worktree"&&S.skipDialogIfSafe&&S.worktree){we(S.worktree,S.sessions);return}Te(S)}),[Te,v,Me,we]);const ve=l.useCallback(async()=>{if(i){b(!0);try{if(V){const S=i.worktree??u[0]?.metadata;if(!S){Re.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:As(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),b(!1);return}De(S,i.sessions.map(ne=>ne.id),p&&le),ue();return}if(i.sessions.length===1){const S=i.sessions[0];if(!await A(S.id)){Re.error(t("sessions.sidebar.session.delete.error")),b(!1);return}Re.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const S=i.sessions.map(ke=>ke.id),{deletedIds:ne,failedIds:q}=await y(S);if(ne.length>0){const ke=q.length>0?q.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:q.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:q.length}):i.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:i.dateLabel}):void 0;Re.success(ne.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ne.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ne.length}),{description:As(ke),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(q.length>0&&(Re.error(q.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:q.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:q.length}),{description:As(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),ne.length===0)){b(!1);return}}ue()}finally{b(!1)}}},[le,i,u,p,A,y,ue,V,De,t]),Pe=i?.worktree??u[0]?.metadata??null;let he="";if(i?.mode==="worktree"){const S=i.sessions.length;S===0?he=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):S===1?he=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:S}):he=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:S})}else if(i){const S=i.sessions.length;S===1?he=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):he=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:S,dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:S})}const Fe=i?s.jsxs("div",{className:Le(V?"space-y-3":"space-y-2"),children:[i.sessions.length>0&&s.jsxs("div",{className:Le(V?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-edge-muted bg-sidebar/60 p-3"),children:[V&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:i.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:i.sessions.length})]}),s.jsxs("ul",{className:Le(V?"mt-2 space-y-1":"space-y-0.5"),children:[i.sessions.slice(0,5).map(S=>s.jsxs("li",{className:Le(V?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground"),children:[s.jsx("span",{className:Le(!V&&"hidden"),children:"•"}),s.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:S.title||t("sessions.sidebar.session.untitled")})]},S.id)),i.sessions.length>5&&s.jsx("li",{className:Le(V?"px-2.5 py-1 text-xs text-muted-foreground":"typography-micro text-muted-foreground"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:i.sessions.length-5})})]})]}),V?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(se,{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")}),Pe?.label?s.jsx("span",{className:"typography-micro text-muted-foreground",children:Pe.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground break-all",children:Pe?kg(Pe.path,G):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),J&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-edge-muted bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,_e=V&&le?ie?s.jsxs("button",{type:"button",onClick:()=>{fe||f(S=>!S)},disabled:fe,"aria-pressed":d,className:Le("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(se,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(se,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,We=V&&le?s.jsxs("button",{type:"button",onClick:()=>{Se||m(S=>!S)},disabled:Se,"aria-pressed":p,className:Le("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Se?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[p?s.jsx(se,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(se,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Xe=V?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:[We,_e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(dt,{variant:"ghost",onClick:ue,disabled:h,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{variant:"destructive",onClick:ve,disabled:h,children:t(h?"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:()=>M(!v),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":!v,children:[v?s.jsx(se,{name:"checkbox-blank",className:"size-4"}):s.jsx(se,{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:ue,disabled:h,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{variant:"destructive",onClick:ve,disabled:h,children:h?t("sessions.sidebar.sessionDialogs.actions.deleting"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),Ve=V?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[H?s.jsx(jg,{open:!!i,onClose:()=>{h||ue()},title:Ve,footer:s.jsx("div",{className:"flex justify-end gap-2",children:Xe}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[he&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:he}),Fe]})}):s.jsx(tr,{open:!!i,onOpenChange:S=>{if(!S){if(h)return;ue()}},children:s.jsxs(sr,{className:Le(V?"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(nr,{children:[s.jsxs(rr,{className:Le(V&&"flex items-center gap-2"),children:[V&&s.jsx(se,{name:"delete-bin",className:"h-5 w-5"}),Ve]}),he&&s.jsx(or,{children:he})]}),V?s.jsx(hs,{outerClassName:"flex-1 min-h-0",className:"space-y-2",disableHorizontal:!0,children:Fe}):s.jsx("div",{children:Fe}),s.jsx($r,{className:"mt-2 gap-2 pt-1 pb-1",children:Xe})]})}),s.jsx(Cg,{open:r,onOpenChange:o})]})},fu=[{pattern:/^dev(:.*)?$/i},{pattern:/^start$/i},{pattern:/^start:(?:dev|preview|serve)(?::.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],G2=/^(?:(?:dev(?:elopment)?|preview|serve)(?: server)?|(?:start|run)\s+(?:dev(?:elopment)?\s+)?(?:server|preview))(?:\s+\([^)]+\))?$/i,Z2=/^(?:cd\s+(?:"[^"]+"|'[^']+'|[^\s;&|]+)\s*&&\s*)?(?:npm|yarn|pnpm|bun)\s+(?:run\s+)?(?:--shell=bun\s+)?([^\s;&|]+)(?:\s|$)/i,X2=t=>fu.some(({pattern:e})=>e.test(t));async function Y2(t,e,n){if(!t)return null;const r=ek(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const o=tk(n);if(o){const i=await sk(t);return{command:`${i==="npm"?"npm run":i==="yarn"?"yarn":i==="pnpm"?"pnpm":i==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await J2(t)){const o=await Q2(),i=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${i}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${i}/`}}return null}async function J2(t){const e=`${t}/index.html`,n=await Zr(e,t);return typeof n=="string"&&n.trim().length>0}async function Q2(){try{const t=await zs("/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 ek(t){for(const e of t){const n=Z2.exec(e.command.trim())?.[1];if(n&&X2(n)||e.source!=="shared"&&G2.test(e.name.trim()))return e}return null}function tk(t){for(const{pattern:e}of fu)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function sk(t){const e=await Zr(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.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,o]of n){const i=await Zr(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function Zr(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await zs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const n=Ql()?.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 zs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function nk(t){try{const e=await Zr(`${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 rk=/\{(worktree|branch)\}/g,Ho=63,ok=new Set(["main","master"]),pu=t=>/\{(worktree|branch)\}/.test(t??""),ik=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const n=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},mu=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=Ho)return e;const n=await ik(e);return n?`${e.slice(0,Ho-7).replace(/-+$/,"")}-${n}`:e.slice(0,Ho).replace(/-+$/,"")},ak=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},lk=async(t,e,n)=>{const r=n.includes("{branch}"),o=n.includes("{worktree}")?await t.isLinkedWorktree(e):!1;if(!r&&!o)return{branch:null,linkedWorktree:o};const i=await t.getGitStatus(e,{mode:"light"});return{branch:ak(i.current),linkedWorktree:o}},ck=async t=>!t.linkedWorktree||!t.branch||ok.has(t.branch)?"":mu(t.branch.split("/").pop()??""),dk=t=>{const e=t.lastIndexOf("@"),n=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const o=r.lastIndexOf(":"),i=o>=0?r.slice(0,o):r,a=o>=0?r.slice(o):"",u=i.split(".").map(c=>c.replace(/^-+|-+$/g,"")).filter(Boolean);return`${n}${u.join(".")}${a}`},uk=async(t,e)=>{const n={worktree:await ck(e),branch:e.branch?await mu(e.branch):""},r=t.replace(rk,(c,d)=>n[d]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,i="",a="",u=""]=o;return`${i}${dk(a)}${u}`},fk=async(t,e,n)=>pu(e)?uk(e,await lk(t,n,e)):e,hu="oc.projectActions.selectedAction.v1",pk=ni(Ns(),ni(Ns(),Ns())),gu=()=>{const t=to().getItem(hu);if(t===null)return{};try{const e=pk.safeParse(JSON.parse(t));return e.success?e.data:{}}catch{return{}}},Pl=(t,e=ns())=>gu()[e]?.[t]??null,mk=(t,e,n=ns())=>{const r=gu();r[n]?.[t]!==e&&to().setItem(hu,JSON.stringify({...r,[n]:{...r[n],[t]:e}}))},hk=15e3,gk=3e3,bk=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}},xk=({projectRef:t,directory:e,allowMobile:n=!1})=>{const{t:r}=at(),{currentTheme:o}=so(),{terminal:i,runtime:a,git:u}=Es(),c=Vs(),{isMobile:d}=gn(),f=l.useMemo(()=>Bs(),[]),p=va(C=>C.instances),m=va(C=>C.load),h=X(C=>C.terminalShell),b=X(C=>C.terminalLoginShells.includes(C.terminalShell)),g=X(C=>C.setSettingsPage),x=X(C=>C.setSettingsDialogOpen),w=X(C=>C.setSettingsProjectsSelectedId),T=X(C=>C.openContextPreview),k=wt(C=>C.ensureDirectory),E=wt(C=>C.reconcileServerSessions),F=wt(C=>C.setTabLabel),_=wt(C=>C.setTabIconKey),A=wt(C=>C.setActiveTab),D=wt(C=>C.setConnecting),y=wt(C=>C.setTabSessionId),N=wt(C=>C.setTabPurpose),j=wt(C=>C.allocateActionExecution),v=wt(C=>C.setTabLifecycle),M=wt(C=>C.setTabPreviewUrl),W=wt(C=>C.matchesActionExecution),G=wt(C=>C.captureStartedActionMutationRevisions),[O,Z]=l.useState([]),Q=l.useRef(null),[B,oe]=l.useState(()=>t?.id?Pl(t.id):null),[H,P]=l.useState(!1),te=l.useRef({}),J=l.useRef({}),le=l.useRef({}),K=l.useRef(new Set),U=l.useRef(0),[$,ee]=l.useState({}),Y=t?.id??null,ie=t?.path??"";l.useEffect(()=>{oe(Y?Pl(Y):null)},[Y]);const V=l.useMemo(()=>Y?{id:Y,path:ie}:null,[Y,ie]);l.useEffect(()=>{f&&m().catch(()=>{})},[f,m]);const fe=l.useCallback(async C=>{await On(C)},[]),Se=l.useCallback(async()=>{if(!V)return;const C=U.current+1;U.current=C,P(!0);try{const ce=await Ro(V);if(U.current!==C)return;Q.current=ce;const L=ce.projectActions;Z(L)}catch{if(U.current!==C)return}finally{U.current===C&&P(!1)}},[V]),Te=l.useMemo(()=>No(e||V?.path||""),[e,V?.path]),ue=l.useMemo(()=>No(V?.path||""),[V?.path]),Me=l.useMemo(()=>No(c||"")||Te,[c,Te]),Ae=l.useRef(Me);l.useEffect(()=>{Ae.current=Me},[Me]);const De=wt(C=>Te?C.getDirectoryState(Te):void 0),Be=wt(C=>ue&&ue!==Te?C.getDirectoryState(ue):void 0),we=l.useMemo(()=>{const C=Te?[{directory:Te,state:De}]:[];return ue&&ue!==Te&&C.push({directory:ue,state:Be}),C},[De,Te,ue,Be]),ve=l.useMemo(()=>{const C=Te?[Te]:[];return ue&&ue!==Te&&C.push(ue),C},[Te,ue]),Pe=l.useCallback(C=>C.id!==sn&&C.runIn==="parent"&&ue||Te,[Te,ue]),he=l.useCallback((C,ce,L)=>`${C}::${ce}::${L}`,[]),Fe=l.useCallback((C,ce,L=wt.getState())=>C?L.getDirectoryState(C)?.tabs.find(ge=>ge.purpose.type==="project-action"&&ge.purpose.actionId===ce)??null:null,[]),_e=l.useMemo(()=>{const C={};for(const{directory:ce,state:L}of we)for(const ge of L?.tabs??[]){if(ge.purpose.type!=="project-action"||!ge.purpose.executionId||!ge.terminalSessionId||ge.lifecycle==="idle"||ge.lifecycle==="exited")continue;const Ce=wn(ce,ge.purpose.actionId),Je=he(ce,ge.purpose.actionId,ge.purpose.executionId);C[Ce]={directory:ce,actionId:ge.purpose.actionId,tabId:ge.id,sessionId:ge.terminalSessionId,executionId:ge.purpose.executionId,status:ge.lifecycle==="stopping"?"stopping":$[Je]?"waiting-for-preview":"running"}}return C},[he,$,we]),We=l.useCallback((C,ce,L)=>{const ge=wn(C,ce),Ce=he(C,ce,L),Oe=te.current[ge]?.executionId===L,me=globalThis.window,je=st=>{me?.clearTimeout(le.current[st]),delete le.current[st]};Oe&&(delete te.current[ge],je(ge)),J.current[Ce]?.(),delete J.current[Ce],je(Ce),ee(st=>{if(!st[Ce])return st;const ye={...st};return delete ye[Ce],ye})},[he]),Xe=l.useCallback(C=>{J.current[C]?.(),delete J.current[C]},[]),Ve=l.useCallback(C=>{window.clearTimeout(le.current[C]),delete le.current[C]},[]);l.useEffect(()=>{const C=J.current,ce=le.current;return()=>{for(const L of Object.keys(C))Xe(L);for(const L of Object.keys(ce))Ve(L)}},[Ve,Xe]),l.useEffect(()=>{const C=new Set(ve);for(const ce of Object.values(te.current))C.has(ce.directory)||We(ce.directory,ce.actionId,ce.executionId);for(const ce of Object.keys(J.current)){const L=ce.split("::",1)[0]??"";C.has(L)||Xe(ce)}},[We,Xe,ve]);const S=l.useCallback((C,ce)=>{X.getState().openContextPanelTab(C,{mode:"terminal",targetDirectory:ce===C?null:ce})},[]),ne=l.useMemo(()=>({id:sn,name:r("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[r]),q=!d,ke=l.useMemo(()=>q?[...O,ne]:O,[O,ne,q]),Ee=l.useMemo(()=>B?ke.find(C=>C.id===B)??null:null,[ke,B]);l.useEffect(()=>{Se()},[Se]);const[Ie,Ne]=l.useState(0),ze=l.useCallback(()=>(Ne(C=>C+1),()=>Ne(C=>C-1)),[]),Ue=Ie>0;l.useEffect(()=>{if(!Ue)return;const C=ve.map(ce=>Kf(i,ce,G,L=>E(ce,L.sessions,{startedActionMutationRevisions:L.startedActionMutationRevisions})));return()=>{for(const ce of C)ce()}},[G,Ue,E,i,ve]),l.useEffect(()=>{for(const{directory:C,state:ce}of we)if(C)for(const L of ce?.tabs??[]){if(L.purpose.type!=="project-action")continue;const ge=L.purpose.actionId,Ce=ke.find(me=>me.id===ge),Je=Ce?.name??ge,Oe=Ce?.icon||"play";L.label!==Je&&F(C,L.id,Je),L.iconKey!==Oe&&_(C,L.id,Oe)}},[ke,_,F,we]),l.useEffect(()=>{const C=globalThis.window;if(!C)return;const ce=L=>{const ge=L.detail;Y&&(ge?.projectId&&ge.projectId!==Y||Se())};return C.addEventListener(Sa,ce),()=>{C.removeEventListener(Sa,ce)}},[Se,Y]),l.useEffect(()=>{const C=L=>{delete le.current[L];const ge=te.current[L];if(!ge||ge.openedUrl)return;const Ce=he(ge.directory,ge.actionId,ge.executionId),Je=ge.announced;if(Je.length!==0){if(window.clearTimeout(le.current[Ce]),delete le.current[Ce],ge.openedUrl=!0,ee(Oe=>{if(!Oe[Ce])return Oe;const me={...Oe};return delete me[Ce],me}),Je.length===1){Wo(ge.directory,[]),M(ge.directory,ge.tabId,Je[0],{locked:!1,autoOpened:!0}),T(ge.directory,Je[0]);return}ge.offering=!0,Wo(ge.directory,Je),X.getState().openContextSurface(ge.directory,"browser"),Re.info(r("projectActions.toast.multipleServers"))}},ce=()=>{const L=wt.getState(),ge=L.sessions,Ce=_e;for(const[Je,Oe]of Object.entries(Ce)){const je=ge.get(Oe.directory)?.tabs.find(mt=>mt.id===Oe.tabId);if(!je||je.terminalSessionId!==Oe.sessionId){We(Oe.directory,Oe.actionId,Oe.executionId);continue}const st=te.current[Je],ye=st?.executionId===Oe.executionId?st:{hostDirectory:Ae.current||Oe.directory,directory:Oe.directory,tabId:Oe.tabId,actionId:Oe.actionId,executionId:Oe.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};te.current[Je]=ye;const ot=ke.find(mt=>mt.id===Oe.actionId),Ct=L.getBuffer(Oe.directory,Oe.tabId).chunks;if(!ot||Ct.length===0)continue;const xt=Ct.filter(mt=>ye.lastSeenChunkId===null||mt.id>ye.lastSeenChunkId);if(xt.length===0)continue;const jt=xt.map(mt=>mt.data).join(""),ct=`${ye.tail}${jt}`;for(const mt of Qf(ct))ye.proxiedPorts.includes(mt)||ye.proxiedPorts.push(mt);if(ye.openInPreview&&(!ye.openedUrl||ye.offering)){const mt=ep(ct,{proxiedPorts:ye.proxiedPorts,namedAddressesReachable:!ka()}),yt=ye.announced.length;for(const Nt of mt)ye.announced.includes(Nt)||ye.announced.push(Nt);const lt=ye.announced.length-yt;ye.offering&&lt>0?Wo(Oe.directory,ye.announced):!ye.openedUrl&&yt===0&&ye.announced.length>0&&(window.clearTimeout(le.current[Je]),le.current[Je]=window.setTimeout(()=>C(Je),gk))}const vt=!ye.openedUrl&&ot.autoOpenUrl===!0&&!ye.openInPreview?tp(ct,{proxiedPorts:ye.proxiedPorts,namedAddressesReachable:!ka()}):null,St=xt[xt.length-1]?.id??ye.lastSeenChunkId;if(ye.lastSeenChunkId=St,ye.tail=ct.slice(-512),vt)if(ye.openedUrl=!0,ye.openInPreview){const mt=Ce[Je];mt&&(M(mt.directory,mt.tabId,vt,{locked:!1,autoOpened:!1,expectedExecutionId:mt.executionId}),mt.status==="waiting-for-preview"&&ee(yt=>{const lt=he(mt.directory,mt.actionId,mt.executionId);if(!yt[lt])return yt;const Nt={...yt};return delete Nt[lt],Nt}),window.clearTimeout(le.current[Je]),delete le.current[Je],T(mt.directory,vt))}else fe(vt),Re.success(r("projectActions.toast.openedUrlFromOutput"));te.current[Je]=ye}for(const Je of Object.keys(te.current))if(!Ce[Je]){const Oe=te.current[Je],me=Oe?ge.get(Oe.directory)?.tabs.find(st=>st.id===Oe.tabId):void 0;if(me?.purpose.type==="project-action"&&me.purpose.executionId===Oe?.executionId&&!!me.terminalSessionId&&me.lifecycle!=="idle"&&me.lifecycle!=="exited")continue;delete te.current[Je],window.clearTimeout(le.current[Je]),delete le.current[Je]}};return ce(),wt.subscribe((L,ge)=>{(L.sessions!==ge.sessions||L.buffers!==ge.buffers)&&ce()})},[We,Ae,ke,he,T,fe,_e,M,r]),l.useEffect(()=>{for(const{directory:C,state:ce}of we)for(const L of ce?.tabs??[]){if(L.purpose.type!=="project-action"||!L.purpose.executionId||!L.terminalSessionId||L.lifecycle!=="running")continue;const ge=L.purpose.actionId,Ce=L.purpose.executionId,Je=he(C,ge,Ce);if(J.current[Je])continue;const Oe=i.connect(L.terminalSessionId,{onEvent:me=>{if(!W(C,L.id,Ce))return;me.type==="snapshot"&&(wt.getState().replaceBuffer(C,L.id,me.data??"",me.sequence??0,ia(me)),me.status==="running"&&wt.getState().setTabLifecycle(C,L.id,"running",{expectedExecutionId:Ce}),me.status==="exited"&&(wt.getState().setTabLifecycle(C,L.id,"exited",{expectedExecutionId:Ce}),wt.getState().setTabPurpose(C,L.id,{type:"project-action",actionId:ge,executionId:null}),We(C,ge,Ce)));const je=me.type==="data"?me.data??"":"";je&&wt.getState().appendToBuffer(C,L.id,je,me.sequence,me.replayData),me.type==="exit"&&(wt.getState().setTabLifecycle(C,L.id,"exited",{expectedExecutionId:Ce}),wt.getState().setTabPurpose(C,L.id,{type:"project-action",actionId:ge,executionId:null}),We(C,ge,Ce))},onError:(me,je)=>{!je||!W(C,L.id,Ce)||(wt.getState().setTabLifecycle(C,L.id,"exited",{expectedExecutionId:Ce}),wt.getState().setTabSessionId(C,L.id,null,{expectedExecutionId:Ce}),wt.getState().setTabPurpose(C,L.id,{type:"project-action",actionId:ge,executionId:null}),We(C,ge,Ce))}},C);J.current[Je]=Oe.close}},[We,he,W,i,we]);const Ge=l.useCallback(async C=>{const ce=Pe(C);if(!ce)throw new Error(r("projectActions.error.noActiveDirectory"));const L=wn(ce,C.id);k(ce);const ge=wt.getState(),Ce=Fe(ce,C.id,ge),Je=Ce?.id??ge.createTab(ce);F(ce,Je,C.name),_(ce,Je,C.icon||"play"),Ce||N(ce,Je,{type:"project-action",actionId:C.id,executionId:null}),A(ce,Je);const me=wt.getState().getDirectoryState(ce)?.tabs.find(je=>je.id===Je);return{executionDirectory:ce,key:L,tabId:Je,sessionId:me?.terminalSessionId??null,executionId:me?.purpose.type==="project-action"?me.purpose.executionId:null}},[k,Pe,Fe,A,_,F,N,r]),Qe=l.useCallback(async C=>{if(a.isVSCode||!n&&d)return;if(!Te){Re.error(r("projectActions.error.noActiveDirectoryForAction"));return}const ce=wn(Pe(C),C.id),L=_e[ce];if(L&&L.status==="running"||K.current.has(ce))return;K.current.add(ce);let ge=null;try{const Ce=C.id===sn?await(async()=>{const ht=V??{id:"",path:Te},[gt,Dt]=await Promise.all([Ro(ht),nk(Te)]),Kt=await Y2(Te,gt.projectActions,Dt);if(!Kt)throw new Error(r("contextPanel.preview.noDevServer"));return gt.projectActions.find(js=>js.id===Kt.actionId)?.source==="shared"&&!await _a(ht,gt)?null:{id:sn,name:r("projectActions.actions.autoDiscover"),command:Kt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Kt.previewUrlHint||""}})():C;if(!Ce)return;const Je=Ce.autoOpenUrl===!0&&(Ce.openUrl||"").trim().length>0,Oe=!Je&&C.id!==sn,me=Ae.current||Te,{executionDirectory:je,key:st,tabId:ye}=await Ge(Ce),ot=Gf(Ce.command);if(!ot)throw new Error(r("projectActions.error.failedToRunAction"));const Ct=Ce.autoOpenUrl===!0&&f&&(Ce.desktopOpenSshForward||"").trim().length>0,xt=Ce.autoOpenUrl&&Ce.openUrl||"";let jt=!1;const ct=pu(xt)?await fk(u,xt,je).catch(()=>(jt=!0,"")):xt,vt=Ce.autoOpenUrl?bk(ct):null,St=Ce.autoOpenUrl&&f?Zf(Ce.desktopOpenSshForward,p):null;if(i.listSessions){const ht=Fe(je,Ce.id);if(ht?.purpose.type==="project-action"&&ht.purpose.executionId===null){const gt=await Xf(i,je,{captureStartedActionMutationRevisions:G});gt&&E(je,gt.sessions,{startedActionMutationRevisions:gt.startedActionMutationRevisions})}}const mt=Fe(je,Ce.id);let yt,lt;if(mt?.lifecycle==="running"&&mt.terminalSessionId&&mt.purpose.type==="project-action"&&mt.purpose.executionId)yt=mt.terminalSessionId,lt=mt.purpose.executionId;else{const ht=mt?.purpose.type==="project-action"?mt.purpose.executionId:null;ht&&We(je,Ce.id,ht);const gt=j(je,ye,Ce.id);if(!gt)throw new Error(r("projectActions.error.failedToCreateTerminalSession"));ge={directory:je,tabId:ye,id:gt},D(je,ye,!0,{expectedExecutionId:gt});const Dt=await Yf({terminal:i,createOptions:{cwd:je,shell:h,loginShell:b,themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground},command:ot,isRunStillExpected:()=>W(je,ye,gt),purpose:{type:"project-action",actionId:Ce.id,executionId:gt}});if(!W(je,ye,gt)){Dt.sessionId===gt&&await i.close(Dt.sessionId).catch(()=>{});return}lt=Dt.purpose?.type==="project-action"?Dt.purpose.executionId:gt,yt=Dt.sessionId,N(je,ye,{type:"project-action",actionId:Ce.id,executionId:lt}),y(je,ye,yt,{expectedExecutionId:lt}),D(je,ye,!1,{expectedExecutionId:lt})}Oe&&me&&S(me,je),te.current[st]={hostDirectory:me,directory:je,tabId:ye,actionId:Ce.id,executionId:lt,lastSeenChunkId:null,openedUrl:!!St||!!vt||Je,tail:"",openInPreview:Ce.id===sn,announced:[],offering:!1,proxiedPorts:[]};const Nt=he(je,Ce.id,lt);D(je,ye,!0,{expectedExecutionId:lt});const _t=i.connect(yt,{onEvent:ht=>{if(!W(je,ye,lt)||ht.purpose?.type==="project-action"&&ht.purpose.executionId!==lt)return;ht.type==="snapshot"&&(wt.getState().replaceBuffer(je,ye,ht.data??"",ht.sequence??0,ia(ht)),wt.getState().setConnecting(je,ye,!1,{expectedExecutionId:lt}),ht.purpose?.type==="project-action"&&wt.getState().setTabPurpose(je,ye,{type:"project-action",actionId:ht.purpose.actionId,executionId:ht.purpose.executionId}),ht.status==="running"&&wt.getState().setTabLifecycle(je,ye,"running",{expectedExecutionId:lt}),ht.status==="exited"&&(wt.getState().setTabLifecycle(je,ye,"exited",{expectedExecutionId:lt}),wt.getState().setTabPurpose(je,ye,{type:"project-action",actionId:Ce.id,executionId:null}),We(je,Ce.id,lt)));const gt=ht.type==="data"?ht.data??"":"";gt&&wt.getState().appendToBuffer(je,ye,gt,ht.sequence,ht.replayData),ht.type==="exit"&&(wt.getState().setTabLifecycle(je,ye,"exited",{expectedExecutionId:lt}),wt.getState().setConnecting(je,ye,!1,{expectedExecutionId:lt}),wt.getState().setTabPurpose(je,ye,{type:"project-action",actionId:Ce.id,executionId:null}),We(je,Ce.id,lt))},onError:(ht,gt)=>{W(je,ye,lt)&&(wt.getState().setConnecting(je,ye,!1,{expectedExecutionId:lt}),gt&&(wt.getState().setTabLifecycle(je,ye,"exited",{expectedExecutionId:lt}),wt.getState().setTabSessionId(je,ye,null,{expectedExecutionId:lt}),wt.getState().setTabPurpose(je,ye,{type:"project-action",actionId:Ce.id,executionId:null}),We(je,Ce.id,lt)))}},je);if(!W(je,ye,lt)){_t.close();return}J.current[Nt]?.(),J.current[Nt]=_t.close,window.clearTimeout(le.current[Nt]),delete le.current[Nt],Ce.id===sn&&!vt&&(ee(ht=>({...ht,[Nt]:!0})),le.current[Nt]=window.setTimeout(()=>{delete le.current[Nt];const ht=te.current[st];!ht||ht.executionId!==lt||ht.openedUrl||ht.offering||W(je,ye,lt)&&(ee(gt=>{if(!gt[Nt])return gt;const Dt={...gt};return delete Dt[Nt],Dt}),wt.getState().setActiveTab(je,ye),S(ht.hostDirectory,je))},hk)),St?(M(je,ye,null,{locked:!0,expectedExecutionId:lt}),fe(St),Re.success(r("projectActions.toast.openedForwardedUrl"))):vt?(M(je,ye,vt,{locked:!0,autoOpened:!0,expectedExecutionId:lt}),T(me,vt),Re.success(r("projectActions.toast.openedActionUrl"))):jt?(M(je,ye,null,{locked:!0,expectedExecutionId:lt}),Re.error(r("projectActions.error.openUrlTemplateUnresolved"))):Je?(M(je,ye,null,{locked:!0,expectedExecutionId:lt}),Re.error(r("projectActions.error.invalidCustomUrlFormat"))):Ct?(M(je,ye,null,{locked:!0,expectedExecutionId:lt}),Re.error(r("projectActions.error.selectedDesktopSshForwardUnavailable"))):M(je,ye,null,{locked:!1,autoOpened:!1,expectedExecutionId:lt})}catch(Ce){if(ge&&W(ge.directory,ge.tabId,ge.id)){const{directory:Je,tabId:Oe,id:me}=ge;We(Je,C.id,me),v(Je,Oe,"exited",{expectedExecutionId:me}),N(Je,Oe,{type:"project-action",actionId:C.id,executionId:null})}if(Ce instanceof Error&&Ce.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(Ce instanceof Error&&(Ce.message==="COMMAND_MODE_UNSUPPORTED"||Ce.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Re.error(r("projectActions.error.failedToCreateTerminalSession"));return}Re.error(Ce instanceof Error?Ce.message:r("projectActions.error.failedToRunAction"))}finally{K.current.delete(ce)}},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,Ae,p,Ge,u,n,d,f,Te,b,h,fe,T,_e,S,a.isVSCode,Pe,W,We,he,Fe,E,j,G,D,v,N,M,y,V,r,i]),He=l.useCallback(async C=>{const ce=wn(Pe(C),C.id),L=_e[ce];L&&await Jf({terminal:i,sessionId:L.sessionId,isExecutionStillCurrent:()=>W(L.directory,L.tabId,L.executionId),markStopping:()=>{v(L.directory,L.tabId,"stopping",{expectedExecutionId:L.executionId})},restoreRunning:()=>{v(L.directory,L.tabId,"running",{expectedExecutionId:L.executionId})},clearSession:()=>{y(L.directory,L.tabId,null,{expectedExecutionId:L.executionId})},finalizeExit:()=>{v(L.directory,L.tabId,"exited",{expectedExecutionId:L.executionId}),N(L.directory,L.tabId,{type:"project-action",actionId:L.actionId,executionId:null}),We(L.directory,L.actionId,L.executionId)}})},[We,Pe,W,_e,v,N,y,i]),Ke=l.useCallback(async C=>{if(C.source==="shared"&&V){const ce=Q.current?.trust.trusted?Q.current:await Ro(V);if(Q.current=ce,!await _a(V,ce))return;Q.current={...ce,trust:{...ce.trust,trusted:!0}}}await Qe(C)},[Qe,V]),Ye=l.useCallback(C=>_e[wn(Pe(C),C.id)]??null,[Pe,_e]),it=(Ee&&Ye(Ee)?Ee:null)??ke.find(C=>Ye(C)!==null)??Ee??ke[0]??null,bt=l.useCallback(C=>{const ce=Ye(C);if(ce?.status!=="stopping"){if(ce){He(C);return}Ke(C)}},[Ke,Ye,He]),nt=l.useCallback(C=>{Ke(C)},[Ke]),ft=l.useCallback(C=>{He(C)},[He]),ae=l.useCallback(C=>{oe(C.id),Y&&mk(Y,C.id)},[Y]),de=l.useCallback(()=>{V?.id&&(w(V.id),g("projects"),x(!0))},[x,g,w,V?.id]),be=!a.isVSCode&&(n||!d)&&!!V&&!!Te;return l.useMemo(()=>({available:be,actions:be?ke:[],shown:be?it:null,isLoading:H,observe:ze,runOf:Ye,select:ae,run:nt,stop:ft,toggle:bt,openSettings:de}),[be,ke,H,ze,de,nt,Ye,ae,it,ft,bt])},wk=t=>{const e=$e.c(6);let n,r;e[0]!==t?({children:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const o=xk(r);let i;return e[3]!==n||e[4]!==o?(i=s.jsx(xd.Provider,{value:o,children:n}),e[3]=n,e[4]=o,e[5]=i):i=e[5],i},yk=t=>{const e=$e.c(4),{children:n}=t,r=yd(),o=mr(),i=o?.kind==="preparing"?null:r?.projectRef??null,a=o?.kind==="ready"?o.directory:r?.directory??"";let u;return e[0]!==n||e[1]!==a||e[2]!==i?(u=s.jsx(wk,{projectRef:i,directory:a,children:n}),e[0]=n,e[1]=a,e[2]=i,e[3]=u):u=e[3],u};function vk(t){const e=[],n=(r,o)=>{const i=Xt(r);!i||e.some(a=>a.directory===i)||e.push({directory:i,priority:"selected",reason:o})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const Sk=new Map,kk=[],jk=t=>{const e=$e.c(20),{isVSCode:n}=t,r=Uc(),o=ts(Ck),i=ls(Tk),a=et(Nk);let u;e[0]!==n?(u=A=>n?Sk:A.availableWorktreesByProject,e[0]=n,e[1]=u):u=e[1];const c=et(u),d=!n;let f;e[2]!==c||e[3]!==o||e[4]!==d?(f=sp(o,c,{includeWorktrees:d}),e[2]=c,e[3]=o,e[4]=d,e[5]=f):f=e[5];const p=f,m=ps(Ek),h=`session-list-sync:${l.useId()}`;let b,g;e[6]!==h||e[7]!==r||e[8]!==i||e[9]!==a?(b=()=>(r.setBootstrapDemand(h,vk({currentDirectory:i,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(h)),g=[h,r,i,a],e[6]=h,e[7]=r,e[8]=i,e[9]=a,e[10]=b,e[11]=g):(b=e[10],g=e[11]),l.useEffect(b,g);const x=l.useRef(null);let w,T;e[12]!==n||e[13]!==p?(w=()=>{const A=new Set(p),D=x.current;x.current=A;const y=D?[...A].filter(N=>!D.has(N)):n?[...A]:[];y.length&&Zc(y,Jo())},T=[n,p],e[12]=n,e[13]=p,e[14]=w,e[15]=T):(w=e[14],T=e[15]),l.useEffect(w,T);let k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[16]=k):k=e[16],l.useEffect(Ik,k);const E=m!=null,F=m??kk;let _;e[17]!==F||e[18]!==E?(_={enabled:!0,hasAuthoritativeGlobalSessions:E,sessions:F},e[17]=F,e[18]=E,e[19]=_):_=e[19],np(_)};function Ck(t){return t.projects}function Tk(t){return t.currentDirectory}function Nk(t){return t.currentSessionDirectory}function Ek(t){return t.authoritativeSessions}function Ik(){let t=null,e=!1;const n=new Set,r=Js(o=>{if(o.type==="scheduled-task-ran")e=!0;else if(o.type==="session-created")n.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),Tg(Jo());return}const i=[...n];n.clear(),i.length&&Zc(i,Jo())},500)});return()=>{t&&clearTimeout(t),r()}}const Pk=()=>Ot(()=>import("./SettingsWindow-HEw9_GIT.js"),__vite__mapDeps([231,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,232,181,182,183,233,234,216,217,218,219,226,201,188,189,202,235,236,225,211,237,238,239])).then(t=>t.SettingsWindow),Rk=()=>Ot(()=>import("./CommandPalette-BChv7Yci.js"),__vite__mapDeps([240,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,237,181,182,183,206,205])).then(t=>t.CommandPalette),Dk=()=>Ot(()=>import("./HelpDialog-jRlVnJ_e.js"),__vite__mapDeps([241,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>t.HelpDialog),Ak=()=>Ot(()=>import("./ProjectActionsDialog-B96GmKCc.js"),__vite__mapDeps([242,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,205,206])).then(t=>t.ProjectActionsDialog),_k=()=>Ot(()=>import("./OpenCodeStatusDialog-BAv0K4eb.js"),__vite__mapDeps([243,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>t.OpenCodeStatusDialog),Ok=()=>Ot(()=>import("./RunOverview-6n10wBYl.js"),__vite__mapDeps([244,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183])).then(t=>t.RunOverview),Mk=()=>Ot(()=>import("./ScheduledTasksDialog-CTkrlYii.js"),__vite__mapDeps([245,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,229,246,247,248])).then(t=>t.ScheduledTasksDialog),Fk=()=>Ot(()=>import("./ArchiveView-CwhPe3Y_.js"),__vite__mapDeps([249,1,2,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,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,250])).then(t=>t.ArchiveView),Lk=()=>Ot(()=>import("./IntegrationsCatalogView-CjJ3sWIM.js"),__vite__mapDeps([251,1,2,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,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,233])).then(t=>t.IntegrationsCatalogView),$k=()=>Ot(()=>import("./UsageStatsView-DCpTVWz3.js"),__vite__mapDeps([252,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>t.UsageStatsView),Bk=()=>Ot(()=>import("./SourceBoardView-CJZ3s1XD.js"),__vite__mapDeps([253,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183])).then(t=>t.SourceBoardView),zk=()=>Ot(()=>import("./OverviewView-DyDBexdg.js"),__vite__mapDeps([254,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183])).then(t=>t.OverviewView),Wk=()=>Ot(()=>import("./WorktreesView-B1YD_EPW.js"),__vite__mapDeps([255,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,250])).then(t=>t.WorktreesView),Uk=()=>Ot(()=>import("./SpacesView-CP5k-k3v.js"),__vite__mapDeps([256,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,238,181,182,183])).then(t=>t.SpacesView),Vk=()=>Ot(()=>import("./SpaceAccessDialog-Ngob2qn9.js"),__vite__mapDeps([257,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,258])).then(t=>t.SpaceAccessDialog),Hk=()=>Ot(()=>import("./SpaceApplyDialog-BxjDC_0D.js"),__vite__mapDeps([259,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,182])).then(t=>t.SpaceApplyDialog),qk=()=>Ot(()=>import("./SpaceSetupOutput-lGqiVX-3.js"),__vite__mapDeps([260,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,258])).then(t=>t.SpaceSetupOutputDialog),_s=()=>X.getState().closeMainSurfaces(),ss=t=>{const e=$e.c(2),{needed:n,load:r,onFailure:o}=t,i=fo(n,r,o);let a;return e[0]!==i?(a=i?s.jsx(i,{}):null,e[0]=i,e[1]=a):a=e[1],a},bu=l.memo(t=>{const e=$e.c(11),{isMobile:n}=t,r=X(Gk),o=!r&&!n,i=io();let a;e[0]!==o||e[1]!==i?(a={enabled:o,layoutAnimationMs:i},e[0]=o,e[1]=i,e[2]=a):a=e[2];const u=jx(a);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(xx,{}),e[3]=c):c=e[3];const d=r||u.state!==!1;let f;e[4]!==d?(f=s.jsx(rp,{isVisible:d}),e[4]=d,e[5]=f):f=e[5];let p;return e[6]!==n||e[7]!==r||e[8]!==u||e[9]!==f?(p=s.jsx(bx,{isOpen:r,isMobile:n,className:"border-border",topBar:c,peek:u,children:f}),e[6]=n,e[7]=r,e[8]=u,e[9]=f,e[10]=p):p=e[10],p});bu.displayName="LeftSidebar";const Kk=()=>{const t=$e.c(111);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],jk(e),op();const n=X(Zk),r=X(Xk),o=X(Yk),i=X(Jk);let a;t[1]!==i?(a=()=>i(!1),t[1]=i,t[2]=a):a=t[2];const u=fo(o,Pk,a),c=X(Qk),d=X(ej),f=X(tj),p=X(sj),m=X(nj),h=X(rj),b=X(oj),g=X(ij),x=X(aj),w=X(lj),T=X(cj),k=X(dj),E=X(uj),F=dn(fj),_=dn(pj),A=dn(mj),D=X(hj),y=Ng();let N;if(t[3]!==y||t[4]!==D){let nt;t[6]!==D?(nt=ft=>ft.id===D,t[6]=D,t[7]=nt):nt=t[7],N=y.find(nt),t[3]=y,t[4]=D,t[5]=N}else N=t[5];const j=N;let v,M;t[8]!==j||t[9]!==D?(v=()=>{D&&!j&&X.getState().setOpenGuestPage(null)},M=[D,j],t[8]=j,t[9]=D,t[10]=v,t[11]=M):(v=t[10],M=t[11]),l.useEffect(v,M);let W;t[12]===Symbol.for("react.memo_cache_sentinel")?(W=[],t[12]=W):W=t[12],l.useEffect(bj,W);let G;t[13]===Symbol.for("react.memo_cache_sentinel")?(G=[],t[13]=G):G=t[13],l.useEffect(xj,G);const O=d||f||p||m||h||b||!!g||x||c||!!j;let Z,Q;t[14]!==O?(Z=()=>{Xc(O)},Q=[O],t[14]=O,t[15]=Z,t[16]=Q):(Z=t[15],Q=t[16]),l.useLayoutEffect(Z,Q);let B;t[17]===Symbol.for("react.memo_cache_sentinel")?(B=[],t[17]=B):B=t[17],l.useEffect(yj,B);let oe;t[18]===Symbol.for("react.memo_cache_sentinel")?(oe=[],t[18]=oe):oe=t[18],l.useEffect(Sj,oe);const{isMobile:H}=gn();ip();let P,te;t[19]!==H||t[20]!==r?(P=()=>{X.getState().isMobile!==H&&r(H)},te=[H,r],t[19]=H,t[20]=r,t[21]=P,t[22]=te):(P=t[21],te=t[22]),l.useEffect(P,te);let J;t[23]!==w?(J=s.jsx(ss,{needed:w,load:Rk,onFailure:kj}),t[23]=w,t[24]=J):J=t[24];let le;t[25]!==T?(le=s.jsx(ss,{needed:T,load:Dk,onFailure:jj}),t[25]=T,t[26]=le):le=t[26];let K;t[27]!==k?(K=s.jsx(ss,{needed:k,load:Ak,onFailure:Cj}),t[27]=k,t[28]=K):K=t[28];let U;t[29]!==E?(U=s.jsx(ss,{needed:E,load:_k,onFailure:Tj}),t[29]=E,t[30]=U):U=t[30];let $,ee;t[31]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(lp,{}),ee=s.jsx(K2,{}),t[31]=$,t[32]=ee):($=t[31],ee=t[32]);let Y;t[33]!==F||t[34]!==_||t[35]!==A||t[36]!==n?(Y=n?s.jsxs(s.Fragment,{children:[s.jsx(ss,{needed:F,load:Vk,onFailure:Nj}),s.jsx(cp,{}),s.jsx(ss,{needed:_,load:Hk,onFailure:Ej}),s.jsx(dp,{}),s.jsx(ss,{needed:A,load:qk,onFailure:Ij})]}):null,t[33]=F,t[34]=_,t[35]=A,t[36]=n,t[37]=Y):Y=t[37];let ie;t[38]===Symbol.for("react.memo_cache_sentinel")?(ie=s.jsx(Cx,{}),t[38]=ie):ie=t[38];let V;t[39]!==H?(V=s.jsx(bu,{isMobile:H}),t[39]=H,t[40]=V):V=t[40];let fe;t[41]===Symbol.for("react.memo_cache_sentinel")?(fe=s.jsx(gx,{}),t[41]=fe):fe=t[41];let Se;t[42]===Symbol.for("react.memo_cache_sentinel")?(Se=s.jsx(zo,{zone:"left"}),t[42]=Se):Se=t[42];const Te=O&&"invisible";let ue;t[43]!==Te?(ue=Le("absolute inset-0",Te),t[43]=Te,t[44]=ue):ue=t[44];const Me=!o&&!O;let Ae;t[45]!==Me?(Ae=s.jsx(Qt,{children:s.jsx(bc,{active:Me})}),t[45]=Me,t[46]=Ae):Ae=t[46];let De;t[47]!==ue||t[48]!==Ae?(De=s.jsx("div",{className:ue,children:Ae}),t[47]=ue,t[48]=Ae,t[49]=De):De=t[49];let Be;t[50]!==c?(Be=s.jsx(Qt,{children:s.jsx(ss,{needed:c,load:Ok,onFailure:_s})}),t[50]=c,t[51]=Be):Be=t[51];let we;t[52]!==d?(we=s.jsx(Qt,{children:s.jsx(ss,{needed:d,load:Mk,onFailure:_s})}),t[52]=d,t[53]=we):we=t[53];let ve;t[54]!==f?(ve=s.jsx(Qt,{children:s.jsx(ss,{needed:f,load:Fk,onFailure:_s})}),t[54]=f,t[55]=ve):ve=t[55];let Pe;t[56]!==p?(Pe=s.jsx(Qt,{children:s.jsx(ss,{needed:p,load:Lk,onFailure:_s})}),t[56]=p,t[57]=Pe):Pe=t[57];let he;t[58]!==m?(he=m&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Qt,{children:s.jsx(ss,{needed:!0,load:$k,onFailure:_s})})}),t[58]=m,t[59]=he):he=t[59];let Fe;t[60]!==h?(Fe=s.jsx(ss,{needed:h,load:Bk,onFailure:_s}),t[60]=h,t[61]=Fe):Fe=t[61];let _e;t[62]!==b?(_e=s.jsx(Qt,{children:s.jsx(ss,{needed:b,load:zk,onFailure:_s})}),t[62]=b,t[63]=_e):_e=t[63];const We=!!g;let Xe;t[64]!==We?(Xe=s.jsx(Qt,{children:s.jsx(ss,{needed:We,load:Wk,onFailure:_s})}),t[64]=We,t[65]=Xe):Xe=t[65];let Ve;t[66]!==x?(Ve=x?s.jsx(Qt,{children:s.jsx(ss,{needed:!0,load:Uk,onFailure:_s})}):null,t[66]=x,t[67]=Ve):Ve=t[67];let S;t[68]!==j?(S=j&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Qt,{children:s.jsx(Eg,{mode:`plugin:${j.id}`,surface:"page",item:null,onDismiss:Pj})})}),t[68]=j,t[69]=S):S=t[69];let ne;t[70]!==De||t[71]!==Be||t[72]!==we||t[73]!==ve||t[74]!==Pe||t[75]!==he||t[76]!==Fe||t[77]!==_e||t[78]!==Xe||t[79]!==Ve||t[80]!==S?(ne=s.jsxs("main",{className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[De,Be,we,ve,Pe,he,Fe,_e,Xe,Ve,S]}),t[70]=De,t[71]=Be,t[72]=we,t[73]=ve,t[74]=Pe,t[75]=he,t[76]=Fe,t[77]=_e,t[78]=Xe,t[79]=Ve,t[80]=S,t[81]=ne):ne=t[81];let q;t[82]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(zo,{zone:"bottom"}),t[82]=q):q=t[82];let ke;t[83]!==ne?(ke=s.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[ne,q]}),t[83]=ne,t[84]=ke):ke=t[84];let Ee,Ie,Ne,ze;t[85]===Symbol.for("react.memo_cache_sentinel")?(Ee=s.jsx(zo,{zone:"right"}),Ie=s.jsx(a2,{}),Ne=s.jsx(c2,{}),ze=s.jsx(m2,{}),t[85]=Ee,t[86]=Ie,t[87]=Ne,t[88]=ze):(Ee=t[85],Ie=t[86],Ne=t[87],ze=t[88]);let Ue;t[89]!==ke?(Ue=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true","data-workspace-row":"true",children:[Se,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:[ke,Ee,Ie,Ne,ze]})]})}),t[89]=ke,t[90]=Ue):Ue=t[90];let Ge;t[91]===Symbol.for("react.memo_cache_sentinel")?(Ge=s.jsx("div",{"data-page-scroll-lock":"true",children:s.jsx(Qt,{children:s.jsx(N2,{})})}),t[91]=Ge):Ge=t[91];let Qe;t[92]===Symbol.for("react.memo_cache_sentinel")?(Qe=s.jsx(Qt,{children:s.jsx(Tb,{})}),t[92]=Qe):Qe=t[92];let He;t[93]!==Ue?(He=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[fe,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Ue,Ge,Qe]})]}),t[93]=Ue,t[94]=He):He=t[94];let Ke;t[95]!==V||t[96]!==He?(Ke=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[V,He]}),t[95]=V,t[96]=He,t[97]=Ke):Ke=t[97];let Ye;t[98]!==u||t[99]!==o||t[100]!==i?(Ye=u?s.jsx(u,{open:o,onOpenChange:i}):null,t[98]=u,t[99]=o,t[100]=i,t[101]=Ye):Ye=t[101];let it;t[102]===Symbol.for("react.memo_cache_sentinel")?(it=null,t[102]=it):it=t[102];let bt;return t[103]!==J||t[104]!==le||t[105]!==K||t[106]!==U||t[107]!==Y||t[108]!==Ke||t[109]!==Ye?(bt=s.jsx(Ig.Provider,{value:!0,children:s.jsx(ap,{children:s.jsx(yk,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[J,le,K,U,$,ee,Y,ie,Ke,Ye,it]})})})}),t[103]=J,t[104]=le,t[105]=K,t[106]=U,t[107]=Y,t[108]=Ke,t[109]=Ye,t[110]=bt):bt=t[110],bt};function Gk(t){return t.isSidebarOpen}function Zk(t){return t.isolatedSpacesEnabled}function Xk(t){return t.setIsMobile}function Yk(t){return t.isSettingsDialogOpen}function Jk(t){return t.setSettingsDialogOpen}function Qk(t){return t.runOverviewKey!==null}function ej(t){return t.isScheduledTasksDialogOpen}function tj(t){return t.isArchivePageOpen}function sj(t){return t.isIntegrationsCatalogOpen}function nj(t){return t.isUsageStatsPageOpen}function rj(t){return t.isSourceBoardOpen}function oj(t){return t.isOverviewOpen}function ij(t){return t.worktreesPageProjectId}function aj(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function lj(t){return t.isCommandPaletteOpen}function cj(t){return t.isHelpDialogOpen}function dj(t){return t.isProjectActionsDialogOpen}function uj(t){return t.isOpenCodeStatusDialogOpen}function fj(t){return t.accessDialog!==null}function pj(t){return t.applyDialog!==null}function mj(t){return t.setupOutputDialog!==null}function hj(t){return t.openGuestPageId}function gj(){return X.getState().setOpenGuestPage(null)}function bj(){return ec(gj)}function xj(){return Cb()}function wj(){return Xc(!1)}function yj(){return wj}function vj(){return X.getState().closeMainSurfaces()}function Sj(){const t=vj,e=et.subscribe((n,r)=>{const o=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,i=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(o||i)&&t()});return()=>{e()}}function kj(){return X.getState().setCommandPaletteOpen(!1)}function jj(){return X.getState().setHelpDialogOpen(!1)}function Cj(){return X.getState().setProjectActionsDialogOpen(!1)}function Tj(){return X.getState().setOpenCodeStatusDialogOpen(!1)}function Nj(){return dn.getState().closeAccessDialog()}function Ej(){return dn.getState().closeApplyDialog()}function Ij(){return dn.getState().closeSetupOutputDialog()}function Pj(){return X.getState().setOpenGuestPage(null)}const wi="openchamber_requests_in_flight",xu=1e3,Rj=300*1e3,Xr=Math.ceil(Rj/xu),Dj=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(wi)==="1"}catch{return!1}},wu=()=>({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 Aj=1;const _j=(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))},Oj=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},yu=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,o)=>r-o),n},In=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),o=Math.floor(r),i=Math.ceil(r);return o===i?t[o]:t[o]+(t[i]-t[o])*(r-o)},Mj=()=>{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,o)=>{const i=Aj++;_j(i,Date.now());try{return await e(r,o)}finally{Oj(i)}};window.fetch=n},Rl=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Un=t=>{t.length>Xr&&t.splice(0,t.length-Xr)},Fj=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=yu(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(In(e,50)),t.p90Samples.push(In(e,90)),t.p99Samples.push(In(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Un(t.samples),Un(t.p50Samples),Un(t.p90Samples),Un(t.p99Samples),Un(t.maxSamples),t.lastSampleAt=Date.now()},Lj=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(Fj,xu))},Dl=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Al=t=>{if(!(typeof window>"u"))try{if(t){Dl(),Rl(),window.localStorage.setItem(wi,"1"),window.__openchamberRequestsInFlight__=wu(),Mj(),Lj();return}window.localStorage.removeItem(wi),Dl(),Rl(),delete window.__openchamberRequestsInFlight__}catch{}},k4=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=wu();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},j4=()=>{if(typeof window>"u")return _l();const t=window.__openchamberRequestsInFlight__;if(!Dj()||!t)return _l();const e=yu(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:In(e,50),ageP90:In(e,90),ageP99:In(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:Xr}},_l=()=>({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:Xr}),$j=(t,e,n)=>Pg(t.filter(r=>!Yc(r)&&!r.parentID),e,n),Bj=()=>$j(ps.getState().activeSessions,qi.getState().ids,Hi.getState().rankById??Rg),zj=(t,e,n)=>{if(t.length===0)return;const r=t.findIndex(i=>i.id===e);let o=n>0?0:t.length-1;return r>=0&&(o=(r+n+t.length)%t.length),t[o]},Wj=()=>{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()??"":""},Uj=async()=>{const t=Wj()||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")},Ol="openchamber:menu-action",Ml="openchamber:check-for-updates",Vj=t=>{const e=$e.c(21),{t:n}=at(),r=et(Hj),o=X(qj),i=X(Kj),a=X(Gj),u=X(Zj),c=X(Xj),d=X(Yj),f=X(Jj),p=xc(Qj),{setThemeMode:m}=so(),h=l.useRef(!1);let b;e[0]!==p?(b=()=>{h.current||(h.current=!0,p().then(e3).finally(()=>{h.current=!1}))},e[0]=p,e[1]=b):b=e[1];const g=b,x=t3;let w;e[2]!==c?(w=D=>{const y=et.getState().currentSessionId,N=zj(Bj(),y,D);N&&(c(!1),et.getState().setCurrentSession(N.id,Ys(N)))},e[2]=c,e[3]=w):w=e[3];const T=w,k=s3;let E;e[4]!==T||e[5]!==t||e[6]!==r||e[7]!==f||e[8]!==i||e[9]!==c||e[10]!==d||e[11]!==m||e[12]!==n||e[13]!==o||e[14]!==a||e[15]!==u?(E=D=>{e:switch(D){case"about":{f(!0);break e}case"settings":{d(!0);break e}case"command-palette":{o();break e}case"quick-open":{i(!0);break e}case"new-session":{c(!1);const y=et.getState(),N=ls.getState().currentDirectory;r(y.currentSessionId&&N?{directoryOverride:N}:void 0);break e}case"new-worktree-session":{c(!1),Og();break e}case"change-workspace":{x();break e}case"toggle-right-sidebar":{const y=ls.getState().currentDirectory;if(!y)break e;const N=X.getState(),j=cs(y),v=N.contextPanelByDirectory[j],M=v?Yu(v.tabs,N.contextSurfaceZones,"right",er(v,"right").activeTabId):null;v?.isOpen?N.closeContextPanel(j):M?N.setActiveContextPanelTab(j,M):N.openContextSurface(j,"git");break e}case"open-right-sidebar-git":{const y=ls.getState().currentDirectory;if(!y)break e;X.getState().openContextSurface(cs(y),"git");break e}case"open-right-sidebar-files":{const y=ls.getState().currentDirectory;if(!y)break e;X.getState().openContextSurface(cs(y),"file");break e}case"toggle-terminal":{const y=ls.getState().currentDirectory;if(!y)break e;X.getState().openContextSurface(cs(y),"terminal");break e}case"toggle-context-panel-expanded":{_g(ls.getState().currentDirectory);break e}case"copy":{const y=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(y)||Uj();break e}case"theme-light":{m("light");break e}case"theme-dark":{m("dark");break e}case"theme-system":{m("system");break e}case"add-selection-to-chat":{Ag();break e}case"toggle-sidebar":{u();break e}case"toggle-memory-debug":{t?.();break e}case"go-back":{Oa(-1);break e}case"go-forward":{Oa(1);break e}case"previous-session":{T(-1);break e}case"next-session":{T(1);break e}case"previous-project":{k(-1);break e}case"next-project":{k(1);break e}case"help-dialog":{a();break e}case"download-logs":Dg().catch(()=>{Re.error(n("openCodeStatusDialog.toast.collectFailed"))})}},e[4]=T,e[5]=t,e[6]=r,e[7]=f,e[8]=i,e[9]=c,e[10]=d,e[11]=m,e[12]=n,e[13]=o,e[14]=a,e[15]=u,e[16]=E):E=e[16];const F=E;let _,A;e[17]!==F||e[18]!==g?(_=()=>{const D=N=>{const j=N.detail;j&&F(j)},y=()=>{g()};return window.addEventListener(Ol,D),window.addEventListener(Ml,y),()=>{window.removeEventListener(Ol,D),window.removeEventListener(Ml,y)}},A=[F,g],e[17]=F,e[18]=g,e[19]=_,e[20]=A):(_=e[19],A=e[20]),l.useEffect(_,A)};function Hj(t){return t.openNewSessionDraft}function qj(t){return t.toggleCommandPalette}function Kj(t){return t.setCommandPaletteOpen}function Gj(t){return t.toggleHelpDialog}function Zj(t){return t.toggleSidebar}function Xj(t){return t.setSessionSwitcherOpen}function Yj(t){return t.setSettingsDialogOpen}function Jj(t){return t.setAboutDialogOpen}function Qj(t){return t.checkForUpdates}function e3(){const{available:t,error:e}=xc.getState();if(e){Re.error("Failed to check for updates",{description:e});return}t||Re.success("You are on the latest version")}function t3(){Wr.requestDirectoryDialog()}function s3(t){const{activeProjectId:e,projects:n,setActiveProject:r}=ts.getState();if(n.length===0)return;const o=n.findIndex(u=>u.id===e);let i=t>0?0:n.length-1;o>=0&&(i=(o+t+n.length)%n.length);const a=n[i];a&&r(a.id)}const Fl=(t,{isAdmitted:e,isPlaced:n,isPinned:r,zones:o})=>!e||t.parentID||t.time?.archived||Yc(t)?!1:n||o.pinned&&r||o.work&&kc(t),n3="openchamber:tray-action",r3=5e3,o3=500,i3=20,Ll=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},$l=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,vu=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},Su=t=>t.title.trim()||"Question",a3=new Set,l3=(t,e)=>Vg(t,e,a3,Hi.getState().rankById),c3=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},d3=(t,e,n,r,o)=>{if(!t)return"";const i=fr(n,r,t),a=e.project?.name,u=i?.label?.trim()||a?.trim()||c3(t),c=Br(t);let d=c&&o.get(c)||"";if(!d){for(const[f,p]of An.getState().directories)if(Br(f)===c){d=p.status?.current??"";break}}if(!d)for(const f of r.values()){const p=c?Lr(f,c):void 0;if(p?.branch){d=p.branch;break}}return d?`${u} · ${d}`:u},u3=()=>{const{dictionary:t}=tf.getState(),e=(c,d)=>sf(t,c,d),{results:n,dropdownProviderIds:r,displayMode:o}=sd.getState(),i=o==="remaining"?"remaining":"usage";if(!r.length)return{mode:i,groups:[]};const a=new Map(n.map(c=>[c.providerId,c])),u=[];for(const c of Hg){if(!r.includes(c.id))continue;const d=a.get(c.id);if(!d||d.configured!==!0)continue;const f=[];for(const[m,h]of Object.entries(d.usage?.windows??{})){const b=i==="remaining"?h.remainingPercent:h.usedPercent;f.push({label:Kg(m),value:qg(h,b,e)})}const p=!d.ok&&d.error?d.error:f.length===0?"No rate limits reported":null;u.push({provider:c.name,rows:f,status:p})}return{mode:i,groups:u}},f3=async()=>{try{if(Qr())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Ju();if(e&&aa(e,t))return"Local OpenChamber";const r=(await Ni()).hosts.find(o=>e?aa(e,sc(o)):!1);return r?.label?.trim()?Qu(r.label.trim()):"Instance"}catch{return""}},p3=()=>{const t=new Map,e=new Map,n=[],r=new Map;let o;try{o=ei()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[i,a]of o.children.entries()){const u=a.getState();u.vcs?.branch&&e.set(Br(i)??i,u.vcs.branch);for(const c of u.session)c?.id&&r.set(c.id,c.title);for(const[c,d]of Object.entries(u.session_status??{})){const f=d?.type,p=f==="busy"?"busy":f==="retry"?"retry":"idle",m=t.get(c);(!m||m==="idle")&&t.set(c,p)}for(const[c,d]of Object.entries(u.permission??{}))for(const f of d??[]){if(!f?.id)continue;const p=f.sessionID||c;n.push({kind:"permission",id:f.id,sessionId:p,sessionTitle:"",label:vu(f),directory:i,canSave:nd(f.save)})}for(const[c,d]of Object.entries(u.form??{}))for(const f of d??[]){if(!f?.id)continue;const p=f.sessionID||c;n.push({kind:"form",id:f.id,sessionId:p,sessionTitle:"",label:Su(f),directory:i,canSave:!1})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},m3=(t,e)=>{const n=ps.getState().activeSessions,r=$g(n),o=y=>r.descendantsOf(y,"active").map(N=>N.id),i=ts.getState().projects,a=et.getState().availableWorktreesByProject,u=qi.getState().ids,c=(y,N)=>{const j=Ys(y),v=Ma(j,i,a);return Yr(j)||y.projectID===ef?Fl(y,{isAdmitted:v,isPlaced:N.chats,isPinned:!1,zones:{pinned:!1,work:!1}}):Fl(y,{isAdmitted:v,isPlaced:ki(j)||fr(i,a,j)!==null,isPinned:Ug(u,y.directory,y.id),zones:N})},d=tc.getState(),f={chats:d.showChatsSection,pinned:d.showPinnedSection,work:X.getState().sessionWorkEnabled&&d.showWorkSection},p={chats:!0,pinned:!0,work:!0},m=Bg(Qo.getState().activeSessionIds,[Jc.getState().runningSessionIds,Qc.getState().sessionIds,ed.getState().bySession.keys()]),h=y=>Wg(y)&&!m.has(y.id),b=X.getState().dockBadgeEnabled?n.filter(y=>h(y)&&c(y,f)):[],g=b.length,x=b.sort((y,N)=>(N.time.idle??N.time.updated)-(y.time.idle??y.time.updated)||y.id.localeCompare(N.id)).slice(0,10).map(y=>({id:y.id,title:y.title,directory:Ys(y)??""}));if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:g,dockUnreadSessions:x};const w=p3(),T=new Map(w.titleById);for(const y of n)y?.id&&y.title&&T.set(y.id,y.title);const k=Qo.getState().statusById,E=y=>{const N=w.statusById.get(y);return N&&N!=="idle"?N:k.get(y)?.status.type??N??"idle"},F=y=>{const N=y.map(j=>E(j));return N.includes("busy")?"busy":N.includes("retry")?"retry":"idle"},_=n.filter(y=>y?.id&&!y.parentID).filter(y=>c(y,p)).slice().sort(l3).slice(0,i3).map(y=>{const N=[y.id,...o(y.id)],j=Ys(y)??"";return{id:y.id,title:y.title||"Untitled session",status:F(N),branch:j?w.branchByDirectory.get(j)??"":"",unseen:h(y)?1:0,hasError:h(y)&&zg(y),directory:j,subtitle:d3(j,y,i,a,w.branchByDirectory)}}),A=w.approvals.map(y=>({...y,sessionTitle:T.get(y.sessionId)||""})),D=new Set(A.map(y=>y.id));for(const[y,N]of td.getState().bySession){const j=T.get(y)||"";for(const v of N.permissions)D.has(v.id)||(D.add(v.id),A.push({kind:"permission",id:v.id,sessionId:y,sessionTitle:j,label:vu(v),directory:N.directory,canSave:nd(v.save)}));for(const v of[...N.forms,...N.pages])D.has(v.id)||(D.add(v.id),A.push({kind:"form",id:v.id,sessionId:y,sessionTitle:j,label:Su(v),directory:N.directory,canSave:!1}))}return{sessions:_,approvals:A.filter(y=>Ma(y.directory,i,a)),instanceName:t,usage:u3(),dockBadgeCount:g,dockUnreadSessions:x}},h3=()=>{l.useEffect(()=>{if(!Ll()||!qo())return;const t=$l();let e=!1,n="",r=null,o="";const i=()=>{if(e)return;const j=m3(o,t),v=JSON.stringify(j);v!==n&&(n=v,Zs("desktop_tray_update",j))},a=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},o3))},u=ps.subscribe(()=>a()),c=Qo.subscribe(()=>a()),d=Jc.subscribe(()=>a()),f=Qc.subscribe(()=>a()),p=ed.subscribe(()=>a()),m=X.subscribe((j,v)=>{(j.dockBadgeEnabled!==v.dockBadgeEnabled||j.sessionWorkEnabled!==v.sessionWorkEnabled)&&a()}),h=ts.subscribe(()=>a()),b=et.subscribe(()=>a()),g=qi.subscribe(()=>a()),x=tc.subscribe((j,v)=>{(j.showChatsSection!==v.showChatsSection||j.showPinnedSection!==v.showPinnedSection||j.showWorkSection!==v.showWorkSection)&&a()}),w=()=>{e=!0,r!==null&&window.clearTimeout(r),u(),c(),d(),f(),p(),m(),h(),b(),g(),x()};if(!t)return i(),w;f3().then(j=>{e||(o=j,i())});const T=new Map,k=()=>{if(e)return;let j;try{j=ei()}catch{return}const v=new Set;for(const[M,W]of j.children.entries())v.add(M),T.has(M)||T.set(M,W.subscribe(()=>a()));for(const[M,W]of T)v.has(M)||(W(),T.delete(M))};let E=null;try{E=ei().subscribeRegistry(()=>{k(),a()})}catch{}k();const F=An.subscribe(()=>a()),_=td.subscribe(()=>a()),A=Hi.subscribe(()=>a()),D=sd.subscribe(()=>a()),y=zt.subscribe((j,v)=>{j.isInitialized&&!v.isInitialized&&Do(!0)});Do(!0);const N=window.setInterval(()=>{k(),i()},r3);return i(),()=>{w(),window.clearInterval(N),F(),_(),A(),D(),y(),E?.();for(const j of T.values())j();T.clear()}},[]),l.useEffect(()=>{if(!Ll()||!qo())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{switch(i.type){case"mark-all-read":Fg().then(()=>Lg()).catch(()=>{});break;case"menu-opened":$l()&&Do();break;case"respond-permission":Mg(i.sessionId,i.id,i.response).catch(()=>{Re.error("Failed to respond to permission request")});break}};let r=null,o=!1;return e(n3,i=>{const a=i?.payload;!a||typeof a!="object"||typeof a.type!="string"||n(a)}).then(i=>{if(o){i();return}r=i,Zs("desktop_tray_actions_ready")}).catch(()=>{}),()=>{o=!0;try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},g3=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,b3=(t,e,n,r)=>r||[t,e,n].filter(Boolean).join("|")||void 0,x3=t=>{t.kind!=="plugin"||!t.title||Re.info(t.title,{id:b3(t.kind,t.title,t.body,t.tag),description:t.body})},w3=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,y3=t=>{const e=$e.c(3),n=!0;let r,o;e[0]!==n?(r=()=>{if(!(Bs()||!nc()||!globalThis.window))return Js(v3)},o=[n],e[0]=n,e[1]=r,e[2]=o):(r=e[1],o=e[2]),l.useEffect(r,o)};function v3(t){if(t.type!=="notification")return;const e=X.getState();if(!e.nativeNotificationsEnabled)return;const n=g3();if(w3(t.payload,n)){x3(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&n)return;Ql()?.notifications?.notifyAgentCompletion(t.payload)}const S3=()=>{const t=$e.c(4),{t:e}=at(),n=X(k3);let r,o;t[0]!==n||t[1]!==e?(r=()=>Js(i=>{i.type==="browser-provider-reset"&&(n("builtin"),Re.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:i.guestName})))}),o=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),l.useEffect(r,o)};function k3(t){return t.setBrowserProvider}const j3=()=>{const t=$e.c(1);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],l.useEffect(T3,e)};function C3(t){t.type==="guests-changed"?Gg():t.type==="event-stream-ready"&&Zg()}function T3(){return Js(C3)}const N3=()=>{const t=$e.c(3),{t:e}=at();let n,r;t[0]!==e?(n=()=>Js(o=>{if(o.type!=="limit-failover")return;const{failover:i}=o,a=zt.getState().providers,u=c=>a.find(d=>d.id===c);if(i.kind==="account"){const c=u(i.providerId)?.name||i.providerId;Re.info(i.fromAccount?e("chat.limitFailover.toast.account",{provider:c,from:i.fromAccount,to:i.toAccount}):e("chat.limitFailover.toast.accountUnknown",{provider:c,to:i.toAccount}));return}Re.info(e("chat.limitFailover.toast.model",{model:Fa(u(i.providerId),i.modelId),fallback:Fa(u(i.toProviderId),i.toModelId)}))}),r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),l.useEffect(n,r)},Bl="relay-limit-reached",E3=()=>{const t=$e.c(3),{t:e}=at();let n,r;t[0]!==e?(n=()=>{const o=()=>{Re.error(e("relayConnection.limitReached.title"),{id:Bl,description:e("relayConnection.limitReached.description"),duration:1/0,action:{label:e("relayConnection.limitReached.retry"),onClick:I3}})};return la(rc()?.getStatus())&&o(),nf(a=>{la(a)?o():(a.state==="connected"||a.state==="idle")&&Re.dismiss(Bl)})},r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),l.useEffect(n,r)};function I3(){return rc()?.retry()}const zl=()=>{rf()||(Xg(),Yg(up.map(t=>t.id)))},P3=(t,e)=>{const n=$e.c(5);let r;n[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const a=window.requestIdleCallback(zl,{timeout:1e4});return()=>window.cancelIdleCallback(a)}const i=setTimeout(zl,3e3);return()=>clearTimeout(i)},n[0]=t,n[1]=r):r=n[1];let o;n[2]!==e||n[3]!==t?(o=[t,e],n[2]=e,n[3]=t,n[4]=o):o=n[4],l.useEffect(r,o)},Wl="pwa-install-toast-shown",Ul="pwa-install-toast-dismissed",R3=()=>{const t=$e.c(6),{browserTab:e}=fp(),{t:n}=at(),r=l.useRef(n);let o,i;t[0]!==n?(o=()=>{r.current=n},i=[n],t[0]=n,t[1]=o,t[2]=i):(o=t[1],i=t[2]),l.useEffect(o,i);let a,u;t[3]!==e?(a=()=>{if(typeof window>"u"||!nc()||!e)return;let c=null,d=null;const f=()=>{d!==null&&(Re.dismiss(d),d=null)},p=async()=>{if(!c)return;const b=c;c=null,f(),await b.prompt();const{outcome:g}=await b.userChoice;g==="accepted"&&Re.success(r.current("pwa.installPrompt.started"))},m=b=>{const g=b;if(typeof g.prompt!="function")return;g.preventDefault(),c=g;const x=ca(),w=of();pp({dismissed:x.getItem(Ul),sessionShown:w.getItem(Wl),hasActiveToast:d!==null})&&(w.setItem(Wl,"true"),d=Re.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{p()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{ca().setItem(Ul,"true"),f()}}}))},h=()=>{c=null,f(),Re.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",m),window.addEventListener("appinstalled",h),()=>{f(),window.removeEventListener("beforeinstallprompt",m),window.removeEventListener("appinstalled",h)}},u=[e],t[3]=e,t[4]=a,t[5]=u):(a=t[4],u=t[5]),l.useEffect(a,u)},ku=()=>globalThis.window?.__OPENCHAMBER_SAFE_START__===!0,D3=()=>{gs.setState({byRoot:{},runtimeSnapshots:{}});const t=X.getState();for(const e of Object.keys(t.contextPanelByDirectory))for(const n of Ti)t.closeContextZone(e,n)},A3=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",ju=async(t,e)=>{const n=(await Ni()).hosts.find(o=>o.id===t);if(!n)throw new Error("host-not-found");if(n.relay){await df(n.id,e);return}const r=uf(sc(n));if(!r)throw new Error("host-not-found");ff({apiBaseUrl:r,clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,runtimeKey:pf(n),sshForwarded:n.sshForwarded===!0})},_3=async t=>{const e=await Ni(),n=await lf(t,e.hosts);await cf({hosts:n.hosts,defaultHostId:e.defaultHostId||n.hostId,initialHostChoiceCompleted:!0}),await ju(n.hostId,{reconnectActive:!0})},O3=async t=>{const e=await af();for(const n of e)try{n.type==="pairing"?await _3(n.link):await ju(n.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",n.type,o),t(A3(o))}},yi="project-config-invalid",M3=()=>{const t=$e.c(9),{t:e}=at(),n=zt(F3);let r;t[0]!==n?(r=m=>m.projectConfigErrors[n],t[0]=n,t[1]=r):r=t[1];const o=zt(r),[i,a]=qt.useState(!1);let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const m=zt.getState(),h=m.activeDirectoryKey;a(!0),Promise.all([m.loadProviders({directory:h,source:"projectConfigError:retry"}),m.loadAgents({directory:h,source:"projectConfigError:retry"})]).finally(()=>a(!1))},t[2]=u):u=t[2];const c=u;let d,f;t[3]!==o||t[4]!==i||t[5]!==e?(d=()=>{if(!o){Re.dismiss(yi);return}Re.error(e("projectConfigError.toast.title"),{id:yi,duration:1/0,description:s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("span",{className:"break-all font-mono typography-meta",children:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&s.jsx(hs,{as:"span",outerClassName:"max-h-40",className:"whitespace-pre-wrap break-words font-mono typography-meta",disableHorizontal:!0,children:o.message}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(i?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:m=>{m.preventDefault(),i||c()}}})},f=[o,i,c,e],t[3]=o,t[4]=i,t[5]=e,t[6]=d,t[7]=f):(d=t[6],f=t[7]),qt.useEffect(d,f);let p;return t[8]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[8]=p):p=t[8],qt.useEffect($3,p),null};function F3(t){return t.activeDirectoryKey}function L3(){Re.dismiss(yi)}function $3(){return L3}const B3="\x1B",z3=new RegExp(`${B3}\\[[0-9;?]*[ -/]*[@-~]`,"g"),jr=Ns().transform(t=>t.replace(z3,"").trim()).nullish(),W3=Qs({isOpenCodeReady:ar().optional(),openCodeRunning:ar().optional(),lastOpenCodeError:jr,opencodeBinaryResolved:jr,lastOpenCodeLaunchDiagnostics:Qs({sourceBinary:jr,binary:jr}).nullish()}),U3=async(t,e=zs)=>{const n=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)throw new Error(`Startup diagnostics request failed (${n.status})`);const r=W3.parse(await n.json());return r.isOpenCodeReady===!0||r.isOpenCodeReady!==!1&&r.openCodeRunning!==!1?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},V3=(t,e)=>{if(t)return"startup.initRecovery.openCodeUnavailable";switch(e?.step){case"serverUnreachable":return"startup.initRecovery.serverUnreachable";case"openCodeUnavailable":return"startup.initRecovery.openCodeUnavailable";case"loadAgents":return"startup.initRecovery.loadAgentsFailed";default:return"startup.initRecovery.unexpected"}},H3=Qs({openchamberVersion:Ns()}),q3=async(t,e=zs)=>{const n=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)return null;const r=H3.safeParse(await n.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},K3=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function G3({version:t}){const{t:e}=at(),[n,r]=l.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const u=await hp();r(u.available&&!u.installBlocked?{kind:"available",info:u}:{kind:"manual",info:u,error:null})}catch(u){r({kind:"manual",info:null,error:u instanceof Error?u.message:null})}},i=n.kind==="manual"?n:null,a=i?.info?.updateCommand||"openchamber update";return s.jsxs("div",{className:"flex w-full flex-col items-center gap-3",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h1",{className:"typography-h1 text-foreground",children:e("startup.serverOutdated.title")}),s.jsx("p",{className:"typography-markdown text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),s.jsxs(dt,{type:"button",onClick:()=>{o()},disabled:n.kind==="checking",children:[s.jsx(se,{name:n.kind==="checking"?"loader":"download",className:n.kind==="checking"?"size-4 animate-spin":"size-4"}),n.kind==="checking"?e("startup.serverOutdated.checking"):e("onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),i&&s.jsxs("div",{className:"w-full space-y-2 text-start",children:[!i.info?.available&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),i.error&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:i.error}),i.info?.installBlocked==="desktop-host"?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:i.info.version||""})}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("onboarding.desktopRecovery.remoteIncompatible.manualUpdate")}),s.jsx("code",{className:"block select-text rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono text-sm text-foreground",children:a})]})]}),s.jsx(mp,{open:n.kind==="available",onOpenChange:u=>{u||r({kind:"idle"})},info:n.kind==="available"?n.info:null,downloading:!1,downloaded:!1,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const Vl=ur(()=>Ot(()=>import("./OnboardingScreen-CMeQdpeM.js"),__vite__mapDeps([261,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.OnboardingScreen}))),Z3=()=>Ot(()=>import("./AboutDialog-BLUUIZML.js"),__vite__mapDeps([262,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,239])).then(t=>t.AboutDialog),X3=()=>Ot(()=>import("./MemoryDebugPanel-D0N9KDmI.js"),__vite__mapDeps([263,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,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,205,206])).then(t=>t.MemoryDebugPanel),Y3=()=>{const t=$e.c(6),e=X(s4),n=X(n4);let r;t[0]!==n?(r=()=>n(!1),t[0]=n,t[1]=r):r=t[1];const o=fo(e,Z3,r);if(!o)return null;let i;return t[2]!==o||t[3]!==e||t[4]!==n?(i=s.jsx(o,{open:e,onOpenChange:n}),t[2]=o,t[3]=e,t[4]=n,t[5]=i):i=t[5],i},J3=t=>{const e=$e.c(3),{onClose:n}=t,r=fo(!0,X3,n);let o;return e[0]!==r||e[1]!==n?(o=r?s.jsx(r,{onClose:n}):null,e[0]=r,e[1]=n,e[2]=o):o=e[2],o},Q3=t=>{const e=$e.c(47),{onRetry:n,isRetrying:r}=t,{t:o}=at(),[i,a]=l.useState(null);let u,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const y=new AbortController,N=ns(),j=setTimeout(()=>y.abort(),5e3);return U3(y.signal).then(v=>{!y.signal.aborted&&ns()===N&&a(v)}).catch(r4).finally(()=>clearTimeout(j)),()=>{y.abort(),clearTimeout(j)}},c=[],e[0]=u,e[1]=c):(u=e[0],c=e[1]),l.useEffect(u,c);const[d,f]=l.useState(null);let p,m;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{const y=new AbortController,N=ns(),j=setTimeout(()=>y.abort(),5e3);return q3(y.signal).then(v=>{y.signal.aborted||ns()!==N||f(v&&K3(v)?v:null)}).catch(o4).finally(()=>clearTimeout(j)),()=>{y.abort(),clearTimeout(j)}},m=[],e[2]=p,e[3]=m):(p=e[2],m=e[3]),l.useEffect(p,m);const h=zt(i4),b=i?null:h?.message??null;if(d){let y;e[4]!==d?(y=s.jsx(G3,{version:d}),e[4]=d,e[5]=y):y=e[5];let N;e[6]!==r||e[7]!==o?(N=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=N):N=e[8];let j;e[9]!==r||e[10]!==n||e[11]!==N?(j=s.jsx(dt,{type:"button",variant:"outline",onClick:n,disabled:r,children:N}),e[9]=r,e[10]=n,e[11]=N,e[12]=j):j=e[12];let v;return e[13]!==y||e[14]!==j?(v=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[y,j]})}),e[13]=y,e[14]=j,e[15]=v):v=e[15],v}let g;e[16]!==o?(g=o("startup.initRecovery.title"),e[16]=o,e[17]=g):g=e[17];let x;e[18]!==g?(x=s.jsx("h1",{className:"typography-h1 text-foreground",children:g}),e[18]=g,e[19]=x):x=e[19];let w;e[20]!==i||e[21]!==h||e[22]!==o?(w=o(V3(i,h)),e[20]=i,e[21]=h,e[22]=o,e[23]=w):w=e[23];let T;e[24]!==w?(T=s.jsx("p",{className:"typography-markdown text-muted-foreground",children:w}),e[24]=w,e[25]=T):T=e[25];let k;e[26]!==x||e[27]!==T?(k=s.jsxs("div",{className:"flex flex-col gap-2",children:[x,T]}),e[26]=x,e[27]=T,e[28]=k):k=e[28];let E;e[29]!==b||e[30]!==o?(E=b&&s.jsxs("dl",{className:"w-full min-w-0 text-start","aria-live":"polite",children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.lastError")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono typography-meta text-muted-foreground",children:b})]}),e[29]=b,e[30]=o,e[31]=E):E=e[31];let F;e[32]!==i||e[33]!==o?(F=i&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[i.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:i.binary})]}),i.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:i.error})]})]}),e[32]=i,e[33]=o,e[34]=F):F=e[34];let _;e[35]!==r||e[36]!==o?(_=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[35]=r,e[36]=o,e[37]=_):_=e[37];let A;e[38]!==r||e[39]!==n||e[40]!==_?(A=s.jsx(dt,{type:"button",onClick:n,disabled:r,children:_}),e[38]=r,e[39]=n,e[40]=_,e[41]=A):A=e[41];let D;return e[42]!==E||e[43]!==F||e[44]!==A||e[45]!==k?(D=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[k,E,F,A]})}),e[42]=E,e[43]=F,e[44]=A,e[45]=k,e[46]=D):D=e[46],D};function e4({apis:t}){l.useEffect(()=>Jg(),[]),l.useEffect(()=>{mf("App:mounted"),hf()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=zt($=>$.initializeApp),n=zt($=>$.isInitialized),r=zt($=>$.isConnected),o=zt($=>$.providersLoaded),i=zt($=>$.agentsLoaded),a=zt($=>$.loadProviders),u=zt($=>$.loadAgents),c=et($=>$.error),d=et($=>$.clearError),f=ls($=>$.currentDirectory),p=ls($=>$.isSwitchingDirectory),[m,h]=l.useState(!1),b=fn($=>$.refreshAll),g=Zl($=>$.refresh),[x,w]=l.useState(()=>t.runtime.isVSCode),[T,k]=l.useState(!1),[E,F]=l.useState(0),[_,A]=l.useState(0),[D,y]=l.useState(!1),N=X($=>$.wideChatLayoutEnabled),j=X($=>$.mobileKeyboardMode),v=l.useMemo(()=>Bs(),[]),[M,W]=l.useState(()=>da()),[G,O]=l.useState(()=>{const $=Co();return $!==null?ua({isDesktopShell:!0,bootOutcome:$}):null}),Z=l.useRef(!1),{t:Q}=at(),B=l.useRef(!1);l.useEffect(()=>{if(!n||M!=="valid"||B.current)return;const $=Co();$?.target!=="local"||$.status!=="ok"||!$.sshStartupFallbackHostId||(B.current=!0,Re.error(Q("desktopHostSwitcher.startup.title"),{description:Q("desktopHostSwitcher.startup.fellBackToLocal")}))},[M,n,Q]);const oe=l.useRef(!1);l.useEffect(()=>{!n||!ku()||oe.current||(oe.current=!0,Re.info(Q("desktopSafeStart.title"),{description:Q("desktopSafeStart.description"),duration:1/0}))},[n,Q]),l.useEffect(()=>(fa(m),Al(m),()=>{fa(!1),Al(!1)}),[m]),l.useEffect(()=>{gf(j)},[j]),l.useEffect(()=>{w(t.runtime.isVSCode)},[t.runtime.isVSCode]),l.useEffect(()=>ec($=>{bp($)&&xp($),A(ee=>ee+1),k(!1),F(ee=>ee+1)}),[]),l.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",N),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[N]),l.useEffect(()=>(pa(t),()=>pa(null)),[t]),l.useEffect(()=>{r&&(g(t.sourceControl),b(t.sourceControl,{force:!0}),Qg(t.trackers))},[t.sourceControl,t.trackers,r,b,g,_]),eb();const H=M==="valid",P=G?.screen==="main";l.useEffect(()=>{if(!bf({isDesktopShell:v,bootOutcomeKnown:H}))return;tb();const $=setTimeout(()=>{const ee=document.getElementById("initial-loading");ee&&(ee.classList.add("fade-out"),setTimeout(()=>{ee.remove()},300))},150);return()=>clearTimeout($)},[v,H]),l.useEffect(()=>{if(!v||M!=="malformed")return;const $=document.getElementById("initial-loading");$&&($.textContent="Desktop startup failed — please restart the app.")},[v,M]),l.useEffect(()=>{x||e()},[e,x]),l.useEffect(()=>{if(x||n)return;let $=!0,ee,Y=0;const ie=10,V=1e3,fe=async()=>{if(!$)return;if(Y>=ie){k(!0);return}const Se=zt.getState();if(Se.isInitialized){k(!1);return}Y+=1,await Se.initializeApp();const Te=zt.getState();if(!$)return;if(Te.isInitialized){k(!1);return}if(Y>=ie){k(!0);return}const ue=Math.min(V*Math.pow(2,Y-1),4e3);ee=setTimeout(fe,ue)};return ee=setTimeout(fe,V),()=>{$=!1,ee&&clearTimeout(ee)}},[E,n,x]),l.useEffect(()=>{n&&k(!1)},[n]),l.useEffect(()=>{if(!T)return;const $=document.getElementById("initial-loading");$&&($.classList.add("fade-out"),setTimeout(()=>{$.remove()},300))},[T]),l.useEffect(()=>{if(x||!r||o&&i)return;let $=!0,ee=0;const Y=15,ie=async()=>{const fe=zt.getState();if(!(fe.providersLoaded&&fe.agentsLoaded))try{fe.providersLoaded||await a({source:"startupRecovery"}),zt.getState().agentsLoaded||await u({source:"startupRecovery"})}catch{}};ie();const V=setInterval(()=>{if($){if(++ee>=Y){clearInterval(V);return}ie()}},2e3);return()=>{$=!1,clearInterval(V)}},[r,x,u,a,o,i]),l.useEffect(()=>{p||x||r&&Go.setDirectory(f)},[f,p,r,x]),l.useEffect(()=>{if(typeof window>"u")return;const $=ee=>{const Y=ee.detail,ie=typeof Y?.sessionId=="string"?Y.sessionId.trim():"";if(!ie)return;const V=typeof Y?.directory=="string"&&Y.directory.trim().length>0?Y.directory.trim():null,fe=typeof Y?.messageId=="string"&&Y.messageId.trim()||null;ma(ie,String(Y?.runtimeKey??"").trim(),fe)||La(ie,{directory:V,messageId:fe,requireKnownSession:Y?.requireKnownSession===!0})};return window.addEventListener("openchamber:open-session",$),xf().then(ee=>{for(const Y of ee)ma(Y.sessionId,Y.runtimeKey,Y.messageId)||(Y.requireKnownSession?La(Y.sessionId,{messageId:Y.messageId,requireKnownSession:!0}):sb(Y.sessionId,Y.messageId))}),()=>window.removeEventListener("openchamber:open-session",$)},[]),l.useEffect(()=>{if(!Bs())return;const $=()=>{O3(ee=>{Re.error(Q(ee==="invalid-link"?"settings.remoteInstances.direct.error.invalidConnectLink":ee==="unreachable"?"mobile.connect.error.unreachable":"onboarding.remoteConnection.errors.failedToSaveConnection"))})};return window.addEventListener("openchamber:host-actions-ready",$),$(),()=>window.removeEventListener("openchamber:host-actions-ready",$)},[Q]);const te=l.useRef({attempt:null,running:!1,done:!1});l.useLayoutEffect(()=>{const $=te.current;$.attempt||($.attempt=wp({selectNow:!yp().sessionId}))},[]),l.useEffect(()=>{const $=te.current,ee=()=>{const Y=$.attempt;if(!Y||$.running||$.done)return;const ie=zt.getState().isInitialized;$.running=!0,Y().then(V=>{if($.running=!1,V!=="failed"||ie){$.done=!0;return}zt.getState().isInitialized&&ee()})};ee()},[n]),l.useEffect(()=>{if(typeof window>"u")return;const $=()=>{Zs("desktop_open_draft_mini_chat_window",{directory:"",projectId:null,...Cr()})};return window.addEventListener("openchamber:open-mini-chat",$),()=>window.removeEventListener("openchamber:open-mini-chat",$)},[]),l.useEffect(()=>{if(typeof window>"u")return;const $=()=>{const ee=et.getState().currentSessionId;ee&&Gc(ee)};return window.addEventListener("focus",$),()=>window.removeEventListener("focus",$)},[]),l.useEffect(()=>{if(typeof window>"u")return;const $=ee=>{const Y=ee.detail,ie=typeof Y?.directory=="string"&&Y.directory.trim().length>0?Y.directory.trim():null,V=typeof Y?.projectId=="string"&&Y.projectId.trim().length>0?Y.projectId.trim():null,fe=!!(ie||V);X.getState().setSessionSwitcherOpen(!1),et.getState().openNewSessionDraft({target:fe?"project":"chat",selectedProjectId:fe?V:null,directoryOverride:fe?ie:null,preserveDirectoryOverride:!!ie})};return window.addEventListener("openchamber:open-draft-session",$),()=>window.removeEventListener("openchamber:open-draft-session",$)},[]),l.useEffect(()=>{typeof window>"u"||!n||p||Z.current||(Z.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,p]),nb(),y3(),vp(f||null),S3(),Sp(t.sourceControl),kp(t.trackers),j3(),N3(),rb(),jp(),E3(),P3(n&&r,_),R3(),ob(),Nb(),Cp();const J=l.useCallback(()=>{h($=>!$)},[]);Vj(J),h3(),Eb(!0),l.useEffect(()=>{const $=()=>h(ee=>!ee);return window.addEventListener("openchamber:memory-debug-toggle",$),()=>window.removeEventListener("openchamber:memory-debug-toggle",$)},[]),l.useEffect(()=>{c&&setTimeout(()=>d(),5e3)},[d,c]),l.useEffect(()=>{if(!v||M!=="not-injected")return;let $=!1,ee=0;const Y=200,ie=2e3,V=50,fe=()=>{if($)return;ee++;const Se=da();if(Se!=="not-injected"){if($=!0,W(Se),Se==="valid"){const ue=Co();ue&&O(ua({isDesktopShell:!0,bootOutcome:ue}))}return}const Te=Math.min(Y*Math.pow(1.1,ee),ie);if(ee>=V){const ue=document.getElementById("initial-loading");ue&&!ue.textContent?.includes("taking longer")&&(ue.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(fe,Te)};return window.setTimeout(fe,Y),()=>{$=!0}},[v,M]);const le=l.useCallback(async()=>{if(wf({isDesktopShell:Bs(),isDesktopLocalOriginActive:Qr()})){await yf();return}window.location.reload()},[]),K=l.useCallback(async()=>{if(!D){k(!1),y(!0);try{await zt.getState().initializeApp()}finally{y(!1)}zt.getState().isInitialized||F($=>$+1)}},[D]),U=$=>{if($.screen==="recovery")return $.variant};if(v&&G&&G.screen!=="main"){if(G.screen==="chooser")return s.jsx(Qt,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(l.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Vl,{mode:"first-launch",localAvailable:G.localAvailable!==!1,onCliAvailable:le,onChooseRemote:()=>{}})})})});const $=U(G),ee=G.screen==="recovery"&&"url"in G?G.url:void 0,Y=G.screen==="recovery"&&"hostId"in G?G.hostId:void 0;return s.jsx(Qt,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(l.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Vl,{mode:"recovery",recoveryVariant:$,recoveryHostUrl:ee,recoveryHostLabel:void 0,recoveryHostId:Y,localAvailable:G.localAvailable!==!1,onCliAvailable:le})})})})}return T&&!n&&!x?s.jsx(Qt,{children:s.jsx(Q3,{onRetry:()=>{K()},isRetrying:D},_)}):s.jsx(Qt,{children:s.jsx(ib,{sdk:Go.getSdkClient(),directory:f||"",children:s.jsx(ab,{apis:t,children:s.jsx(Tp,{children:s.jsx(lb,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:v?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(cb,{backgroundWorkEnabled:!0}),s.jsx(Np,{}),s.jsx(M3,{}),s.jsx(Kk,{}),v?s.jsx(Ep,{ready:H&&P}):null,s.jsx(db,{}),s.jsx(ub,{}),s.jsx(fb,{}),s.jsx(pb,{}),s.jsx(mb,{}),s.jsx(Ip,{}),s.jsx(Y3,{}),m&&s.jsx(J3,{onClose:()=>h(!1)})]})})})})},_)})}function t4(t){const e=$e.c(2);let n;return e[0]!==t?(n=s.jsx(gp,{children:s.jsx(e4,{...t})}),e[0]=t,e[1]=n):n=e[1],n}function s4(t){return t.isAboutDialogOpen}function n4(t){return t.setAboutDialogOpen}function r4(){}function o4(){}function i4(t){return t.lastInitFailure}const a4=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();vf();ku()&&D3();Pp();Rp();Sf().then(()=>{hb().catch(t=>{console.error("[main] settings init failed:",t)}),gb(),bb(),xb()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Cu=document.getElementById("root");if(!Cu)throw new Error("Root element not found");wb();Tu.createRoot(Cu).render(s.jsx(qt.StrictMode,{children:s.jsx(yb,{children:s.jsx(vb,{children:s.jsx(Sb,{children:s.jsx(kb,{children:s.jsx(t4,{apis:a4})})})})})}));const C4=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Ha as P,Y1 as a,Dx as b,j4 as g,C4 as m,$j as o,k4 as r,wd as u};