@openchamber/web 2.7.2 → 2.7.3-canary.20261115.21

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 (103) hide show
  1. package/dist/assets/{AboutDialog-l-zrh7nU.js → AboutDialog-gL1x0YFW.js} +1 -1
  2. package/dist/assets/{AboutLogo-K3wdJM69.js → AboutLogo-cbKkZDLU.js} +1 -1
  3. package/dist/assets/{ArchiveView-DjRZQdOo.js → ArchiveView-0QjF07oK.js} +1 -1
  4. package/dist/assets/{ChangeRequestDiffUnavailable-BtH6Ad8g.js → ChangeRequestDiffUnavailable-kfarKKvU.js} +1 -1
  5. package/dist/assets/{CommandPalette-C7Uc4nDE.js → CommandPalette-D4bXVkJf.js} +1 -1
  6. package/dist/assets/{DataFileArtifact-DtnZXuug.js → DataFileArtifact-DWC11mPC.js} +1 -1
  7. package/dist/assets/{DiffView-CS0gR_am.js → DiffView-CSSPNDYJ.js} +1 -1
  8. package/dist/assets/{FilesView-tcU8_bnh.js → FilesView-D0FOaLpo.js} +3 -3
  9. package/dist/assets/{GitView-Ccs7O5Rf.js → GitView-CJl97ZjN.js} +1 -1
  10. package/dist/assets/{GuestPanelContent-CJ_wlnNr.js → GuestPanelContent-BCxvKv4H.js} +1 -1
  11. package/dist/assets/{HelpDialog-iH44R9qu.js → HelpDialog-DjficTGt.js} +1 -1
  12. package/dist/assets/{IntegrationsCatalogView-D9icTaJt.js → IntegrationsCatalogView-BvS1pCRR.js} +1 -1
  13. package/dist/assets/{JsonTreeView-BjPbJlHc.js → JsonTreeView-DQ6XLAW4.js} +1 -1
  14. package/dist/assets/{MarkdownDiffPreview-gCh_8R1F.js → MarkdownDiffPreview-C8KpNQaC.js} +1 -1
  15. package/dist/assets/{MarkdownRendererImpl-fohUB8r2.js → MarkdownRendererImpl-B1SjhV-G.js} +4 -4
  16. package/dist/assets/{MemoryDebugPanel-fX9cD8th.js → MemoryDebugPanel-BWT5owg7.js} +1 -1
  17. package/dist/assets/{NoteEditor-CTPSChrc.js → NoteEditor-DfHpXxIN.js} +1 -1
  18. package/dist/assets/{OfficeArtifact-BRviGdkx.js → OfficeArtifact-BAYHzDft.js} +2 -2
  19. package/dist/assets/{OfficeDocumentDiff-Hp2baXgN.js → OfficeDocumentDiff-Csvxzve7.js} +1 -1
  20. package/dist/assets/{OnboardingScreen-CDhZHMEt.js → OnboardingScreen-NWWMu7OG.js} +1 -1
  21. package/dist/assets/{OpenCodeStatusDialog-CBiLhgh9.js → OpenCodeStatusDialog-DtnVfNI4.js} +1 -1
  22. package/dist/assets/{OverviewView-DmNAg498.js → OverviewView-BXMN0Z8_.js} +1 -1
  23. package/dist/assets/{PatchDiff-rhuT-3au.js → PatchDiff-DxGkHtIk.js} +1 -1
  24. package/dist/assets/{PlanView-VhIl4wzm.js → PlanView-DE4sxgkq.js} +1 -1
  25. package/dist/assets/{ProjectActionsDialog-B_jMMuJ0.js → ProjectActionsDialog-C5q25ipO.js} +1 -1
  26. package/dist/assets/{ReceivedPagePanel-CCDFxXT4.js → ReceivedPagePanel-CfXyzCii.js} +5 -5
  27. package/dist/assets/{ReplyCommand-CUHB1iPz.js → ReplyCommand-OczgxN8d.js} +1 -1
  28. package/dist/assets/{ReplyUiBlock-TNOJJ_HH.js → ReplyUiBlock-D1HJeVU_.js} +1 -1
  29. package/dist/assets/{ReviewCards-UN_E9jl0.js → ReviewCards-D7jBPhS_.js} +1 -1
  30. package/dist/assets/{RunOverview-C7FUT8DD.js → RunOverview-BDblAbDp.js} +1 -1
  31. package/dist/assets/{ScheduledTasksDialog-DdXypryy.js → ScheduledTasksDialog-NDtZLq5t.js} +1 -1
  32. package/dist/assets/{SettingsView-uSZDjIcc.js → SettingsView-UjifxDq7.js} +1 -1
  33. package/dist/assets/{SettingsWindow-CoijA05f.js → SettingsWindow-D2K9vSYk.js} +1 -1
  34. package/dist/assets/{SidebarSectionsManager-d6IaYpHW.js → SidebarSectionsManager-QqwIUOdu.js} +1 -1
  35. package/dist/assets/{SourceBoardView-BrQkCEgn.js → SourceBoardView-CKJDJ2f4.js} +1 -1
  36. package/dist/assets/{SpaceAccessDialog-CymnxxLO.js → SpaceAccessDialog-G331hiT_.js} +1 -1
  37. package/dist/assets/{SpaceApplyDialog-DVJkF4lG.js → SpaceApplyDialog-x0rDuJEc.js} +1 -1
  38. package/dist/assets/{SpaceRow-CJFX1Zsr.js → SpaceRow-CsS43yrt.js} +1 -1
  39. package/dist/assets/{SpaceSetupOutput-Btttdq6K.js → SpaceSetupOutput-BEXQGXPw.js} +1 -1
  40. package/dist/assets/{SpacesView-GxzOEIeI.js → SpacesView-DFcnInBv.js} +1 -1
  41. package/dist/assets/{SubmoduleDiffSummary-D0Nj5PJN.js → SubmoduleDiffSummary-CTqIH0Cp.js} +1 -1
  42. package/dist/assets/{TableArtifact-DiRnrtL5.js → TableArtifact-Beve8fiv.js} +1 -1
  43. package/dist/assets/{ToolOutputDialog-DnvhhdiH.js → ToolOutputDialog-Bn2g6tIX.js} +1 -1
  44. package/dist/assets/{ToolPartDiffPreview-CHdkL7BJ.js → ToolPartDiffPreview-mgtjJMMz.js} +1 -1
  45. package/dist/assets/{UiBlock-CvZ92eyw.js → UiBlock-DkgJyZVl.js} +2 -2
  46. package/dist/assets/{UsageStatsView-Dbo3dCgC.js → UsageStatsView-CLJFagDC.js} +1 -1
  47. package/dist/assets/{WalkthroughView-l9TMdlPB.js → WalkthroughView-Dm4-RaV3.js} +1 -1
  48. package/dist/assets/{WorktreesView-DNa5Soxq.js → WorktreesView-DyZy4OjB.js} +1 -1
  49. package/dist/assets/{appThemeRegistry-C3TUDJ7r.js → appThemeRegistry-C4Av1s90.js} +1 -1
  50. package/dist/assets/{codeHighlight-DyrRLTkb.js → codeHighlight-Bmb7zcc2.js} +1 -1
  51. package/dist/assets/{columnWidthMemory-D0i9Kdhi.js → columnWidthMemory-D8H-O0YE.js} +1 -1
  52. package/dist/assets/{computeVirtualFileMetrics-YMtW3BEg.js → computeVirtualFileMetrics-Bc_YiqAD.js} +2 -2
  53. package/dist/assets/{contextFileOpenGuard-USev-3h1.js → contextFileOpenGuard-D-HtBtn6.js} +1 -1
  54. package/dist/assets/{date-time-DSQbTMhf.js → date-time-DfmOsLQo.js} +1 -1
  55. package/dist/assets/{diffsHighlighter-DZ_8ZCaS.js → diffsHighlighter-CFc933Ip.js} +1 -1
  56. package/dist/assets/{documentClient-5O0az-Ma.js → documentClient-D-gfZAFK.js} +2 -2
  57. package/dist/assets/{documentHost-BqOqnqk5.js → documentHost-fBeQzdlp.js} +1 -1
  58. package/dist/assets/{editorCodeMetrics-a0NLS65y.js → editorCodeMetrics-CNBjOGNA.js} +1 -1
  59. package/dist/assets/{fileContentPoller-B8a010z5.js → fileContentPoller-DRoVO_sh.js} +1 -1
  60. package/dist/assets/{flexokiTheme-DJaL_u7G.js → flexokiTheme-CcqiI7j-.js} +1 -1
  61. package/dist/assets/{highlights-CSy_17b-.js → highlights-_5vZZ38i.js} +1 -1
  62. package/dist/assets/{index-CvHejcGo.js → index-BbbQXJ_t.js} +1 -1
  63. package/dist/assets/{initializeSharedPreferences-MLG8op-A.js → initializeSharedPreferences-B1ISDxLb.js} +1 -1
  64. package/dist/assets/{install-NTaAzPnj.js → install-DY6TBn2e.js} +1 -1
  65. package/dist/assets/{install-request-D5VhmtWC.js → install-request-CzRei4tp.js} +1 -1
  66. package/dist/assets/{isDiffPlainText-B6ZzF_T5.js → isDiffPlainText-Cx5SgKlQ.js} +1 -1
  67. package/dist/assets/{isFilePlainText-Bitg2337.js → isFilePlainText-Bcn3vV6J.js} +1 -1
  68. package/dist/assets/{katex.min-B3YMLLh4.js → katex.min-DklPh68d.js} +3 -3
  69. package/dist/assets/{main-Bqwtrv5m.js → main-D0ACoTpS.js} +2 -2
  70. package/dist/assets/{main-B61P9v4A.js → main-QZk4AKac.js} +4 -4
  71. package/dist/assets/{miniChat-CZx_2XHj.js → miniChat-DeYRMPYt.js} +2 -2
  72. package/dist/assets/{mobile-DiLdHL_W.js → mobile-DjT3KVMo.js} +2 -2
  73. package/dist/assets/{moveWorkspacePath-CpN2DOGn.js → moveWorkspacePath-DibtVw_Q.js} +1 -1
  74. package/dist/assets/{officeDocument-Ca0s-jYd.js → officeDocument-CBwDUdTr.js} +1 -1
  75. package/dist/assets/{parseDiffFromFile-CL7WjMrZ.js → parseDiffFromFile-D28_u-uC.js} +1 -1
  76. package/dist/assets/{pierreDiffTint-C4cPKKnP.js → pierreDiffTint-CLCzflgS.js} +1 -1
  77. package/dist/assets/{relocateRestoredSession-Bw3yb1_0.js → relocateRestoredSession-BPqdEuzx.js} +2 -2
  78. package/dist/assets/{renderElectronMiniChatApp-DB0hWKLa.js → renderElectronMiniChatApp-C0v7P53f.js} +2 -2
  79. package/dist/assets/{renderMarkdownForExport-CICPn_1e.js → renderMarkdownForExport-DvKl_kjS.js} +1 -1
  80. package/dist/assets/{renderMobileApp-CYhEWO14.js → renderMobileApp-EVllBWS5.js} +3 -3
  81. package/dist/assets/{resolveLanguages-gKOTFspE.js → resolveLanguages-DqxtADuz.js} +1 -1
  82. package/dist/assets/{scheduledTasksApi-C1TDMoZd.js → scheduledTasksApi-v463mt0u.js} +1 -1
  83. package/dist/assets/{shiki-B0-fz3dN.js → shiki-3oNYFbTw.js} +1 -1
  84. package/dist/assets/{space-apply-DnoCDzwj.js → space-apply-j71ap5Rs.js} +1 -1
  85. package/dist/assets/{space-close-Bqfdl7kv.js → space-close-Bj32J79L.js} +1 -1
  86. package/dist/assets/{spaceNetwork-D5Fcyb33.js → spaceNetwork-BV5W32NY.js} +1 -1
  87. package/dist/assets/{stream-tokenizer-FniCZxxb.js → stream-tokenizer-wGP5G2_C.js} +1 -1
  88. package/dist/assets/{useAppFontEffects-CpxtKEGw.js → useAppFontEffects-BDLOJuy5.js} +15 -15
  89. package/dist/assets/{useBranchPullRequestRequest-DVy6rEsu.js → useBranchPullRequestRequest-DMiPjfPQ.js} +1 -1
  90. package/dist/assets/{useCallableModelProviders-DngJbZnV.js → useCallableModelProviders-aGFpVUZL.js} +1 -1
  91. package/dist/assets/{useDiffFindSurface-DY6lBBpH.js → useDiffFindSurface-mA0rc6AR.js} +1 -1
  92. package/dist/assets/{useGitCleanLine-CxdK3EQ3.js → useGitCleanLine-BwAypcLn.js} +1 -1
  93. package/dist/assets/{useInlineCommentController-Z8ADSR8f.js → useInlineCommentController-Wnopn0Ar.js} +1 -1
  94. package/dist/assets/{useMarkdownLocalAssets-CZIMWgjn.js → useMarkdownLocalAssets-BjT607tF.js} +1 -1
  95. package/dist/assets/{useRootScrollLock-C9UIEqnb.js → useRootScrollLock-DPhGk2Eu.js} +1 -1
  96. package/dist/assets/{useWalkthroughReview-BWxwaV05.js → useWalkthroughReview-BrULG_dy.js} +1 -1
  97. package/dist/assets/{useWholeFileComment-zterYCFS.js → useWholeFileComment-CQj6q_QX.js} +1 -1
  98. package/dist/assets/{useWorktreeArchiveActions-CKnDdsvh.js → useWorktreeArchiveActions-CpegLYyZ.js} +1 -1
  99. package/dist/assets/{vendor-codemirror-language-data-BI6j-q9C.js → vendor-codemirror-language-data-CFvXza4M.js} +2 -2
  100. package/dist/index.html +3 -3
  101. package/dist/mini-chat.html +2 -2
  102. package/dist/mobile.html +2 -2
  103. package/package.json +3 -3
@@ -1,8 +1,8 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-Ccs7O5Rf.js","assets/vendor-react--VO_rL_p.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-CpxtKEGw.js","assets/katex.min-B3YMLLh4.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-C9tWdk0j.js","assets/vendor-zod-DV_WH382.js","assets/vendor-opencode-client-NJGkA1Ku.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-BWbKx7qU.css","assets/vendor-base-ui-CHqK1aDI.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-Bw3q1rnq.js","assets/vendor-tanstack-virtual-core-B4TJYmIq.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-BI6j-q9C.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-iLtL-MFj.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/ReceivedPagePanel-CCDFxXT4.js","assets/space-apply-DnoCDzwj.js","assets/ReceivedPagePanel-uDNKGwhp.css","assets/useGitCleanLine-CxdK3EQ3.js","assets/useBranchPullRequestRequest-DVy6rEsu.js","assets/parseDiffFromFile-CL7WjMrZ.js","assets/computeVirtualFileMetrics-YMtW3BEg.js","assets/themeResolver-DjCwdtoe.js","assets/vendor-pierre-theming-Dn546TCS.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-B6ZzF_T5.js","assets/getFiletypeFromFileName-BgI9McTw.js","assets/pierreDiffTint-C4cPKKnP.js","assets/ReviewCards-UN_E9jl0.js","assets/useInlineCommentController-Z8ADSR8f.js","assets/appThemeRegistry-C3TUDJ7r.js","assets/diffsHighlighter-DZ_8ZCaS.js","assets/editorCodeMetrics-a0NLS65y.js","assets/OfficeDocumentDiff-Hp2baXgN.js","assets/document-attachments-CIZjaOGe.js","assets/vendor-fflate-DB4_FQr-.js","assets/documentClient-5O0az-Ma.js","assets/useRootScrollLock-C9UIEqnb.js","assets/moveWorkspacePath-CpN2DOGn.js","assets/contextFileOpenGuard-USev-3h1.js","assets/install-request-D5VhmtWC.js","assets/WalkthroughView-l9TMdlPB.js","assets/ChangeRequestDiffUnavailable-BtH6Ad8g.js","assets/useDiffFindSurface-DY6lBBpH.js","assets/useWalkthroughReview-BWxwaV05.js","assets/useCallableModelProviders-DngJbZnV.js","assets/useWholeFileComment-zterYCFS.js","assets/DiffView-CS0gR_am.js","assets/SubmoduleDiffSummary-D0Nj5PJN.js","assets/FilesView-tcU8_bnh.js","assets/flexokiTheme-DJaL_u7G.js","assets/vendor-codemirror-search-CWqbGraJ.js","assets/vendor-replit-codemirror-vim-DTiXsOdM.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useMarkdownLocalAssets-CZIMWgjn.js","assets/fileContentPoller-B8a010z5.js","assets/JsonTreeView-BjPbJlHc.js","assets/useNextRenderData-CVFf78p9.js","assets/isFilePlainText-Bitg2337.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/codeHighlight-DyrRLTkb.js","assets/vendor-react-drawio-C6TkEvnS.js","assets/vendor-codemirror-lint-aq8IpR1c.js","assets/scheduledTasksApi-C1TDMoZd.js","assets/GuestPanelContent-CJ_wlnNr.js","assets/SettingsWindow-CoijA05f.js","assets/SettingsView-uSZDjIcc.js","assets/install-NTaAzPnj.js","assets/vendor-yaml-CE-D_49-.js","assets/vendor-qrcode-Cl8OheHW.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/SpaceRow-CJFX1Zsr.js","assets/AboutLogo-K3wdJM69.js","assets/pageTitle-BT3-HFbv.js","assets/CommandPalette-C7Uc4nDE.js","assets/HelpDialog-iH44R9qu.js","assets/ProjectActionsDialog-B_jMMuJ0.js","assets/OpenCodeStatusDialog-CBiLhgh9.js","assets/RunOverview-C7FUT8DD.js","assets/ScheduledTasksDialog-DdXypryy.js","assets/vendor-cron-parser-1X50-i0r.js","assets/vendor-luxon-BZ0puJYg.js","assets/date-time-DSQbTMhf.js","assets/ArchiveView-DjRZQdOo.js","assets/useWorktreeArchiveActions-CKnDdsvh.js","assets/IntegrationsCatalogView-D9icTaJt.js","assets/UsageStatsView-Dbo3dCgC.js","assets/SourceBoardView-BrQkCEgn.js","assets/OverviewView-DmNAg498.js","assets/WorktreesView-DNa5Soxq.js","assets/SpacesView-GxzOEIeI.js","assets/SpaceAccessDialog-CymnxxLO.js","assets/spaceNetwork-D5Fcyb33.js","assets/SpaceApplyDialog-DVJkF4lG.js","assets/SpaceSetupOutput-Btttdq6K.js","assets/OnboardingScreen-CDhZHMEt.js","assets/AboutDialog-l-zrh7nU.js","assets/MemoryDebugPanel-fX9cD8th.js"])))=>i.map(i=>d[i]);
2
- import{f as qe,j as n,R as c,r as Kt,a as yc,h as gf}from"./vendor-react--VO_rL_p.js";import{l as qt,bS as xf,bT as vc,u as K,aA as As,m as zn,W as Xt,Y as mo,n as ts,V as bf,aM as ho,bp as ds,bU as za,_ as go,bV as wf,bb as Sc,bW as Ct,bX as yf,ax as eo,ay as on,az as ca,aY as vf,aN as kc,as as Wa,bY as Sf,bd as jc,b5 as ki,a1 as Tc,bZ as kf,b_ as Tr,b$ as to,c0 as lr,c1 as jf,c2 as Qn,c3 as Tf,c4 as da,c5 as Or,c6 as Va,c7 as xo,bI as wn,af as er,j as Ms,c8 as Rn,c9 as Cf,ca as ks,b as yn,cb as Cr,cc as Cc,cd as Ef,ce as nn,cf as If,cg as Ec,ch as Nf,ci as Pf,cj as Rf,ck as Ic,cl as Df,bs as _f,ba as Af,bk as Of,bf as Mf,aw as Ff,aC as gs,v as ua,bg as Lf,cm as $f,cn as Bf,aH as fa,co as zf,cp as Wf,cq as Ua,cr as Vf,ap as Uf,a7 as ji,bM as Nc,cs as Ti,a6 as Pc,ct as Hf,cu as Kf,w as Rc,bj as qf,cv as Ci,aR as Ha,cw as Dc,a_ as Gf,a5 as Zf,t as Xf,q as Yf,aB as _c,by as Ei,bz as Ac,bP as Jf,bq as Qf,bu as Ii,cx as ep,cy as tp,aW as sp,aU as np,cz as rp,a$ as op,bx as ap,cA as ip,cB as lp,cC as cp,cD as Ni,cE as Bo,cF as Pi,cG as Ri,cH as dp,aP as Di,cI as up,cJ as fp,aQ as _i,cK as pp,aV as mp,i as hp,a as gp}from"./katex.min-B3YMLLh4.js";import{_ as Vt}from"./vendor-vite-runtime-DD1OZmLC.js";import{c1 as xp,c2 as Oc,c3 as bp,c4 as wp,c5 as yp,r as Ka,c6 as vp,c7 as Sp,c8 as kp,c9 as jp,ca as Tp,aX as Cp,cb as Ep,a_ as Ai,cc as Ip,bC as Np,a9 as Mc,ab as Fc,ah as Lc,ad as $c,aa as Bc,a8 as qa,ag as zc,ae as Wc,ac as Vc,aJ as Pp,aK as Rp,aO as Dp,aP as _p,aQ as Ap,aM as Op,J as Mp,aL as Fp,N as Lp,a7 as $p,ai as Bp,bB as zp,cd as Uc,ce as Vr,cf as Wp,cg as Vp,ch as Hc,ci as Js,cj as Oi,ck as Mi,cl as zo,cm as Fi,M as Up,am as Hp,aN as Ur,by as Kp,bz as qp,aS as Gp,bZ as Kc,cn as Zp,bA as Xp,b_ as Yp,co as Jp,cp as Qp,cq as Li,cr as em,cs as tm,ct as sm,cu as nm,cv as rm,cw as om,cx as am,cy as $i,cz as im,cA as lm,cB as cm,cC as dm,cD as um,bD as fm,bx as pm,bX as mm,bE as hm,b$ as gm,cE as xm,bT as bm,bU as wm,aV as qc,cF as ym,cG as vm,cH as Sm,cI as km,cJ as jm,bW as Tm,cK as Cm,bP as Em,bY as Im,bQ as Nm,cL as Pm,bM as Rm,bL as Dm,bG as _m,bH as Am,bI as Om,bJ as Mm,bK as Fm,bF as Lm,bN as $m,cM as Bm,c0 as zm,bS as Wm,bR as Vm,bV as Um,cN as Hm,cO as Km}from"./ReceivedPagePanel-CCDFxXT4.js";import{bl as bo,Z as Yt,a0 as it,cT as Er,a2 as Ye,fL as qm,cU as Gm,I as ue,fM as Zm,u as gt,l$ as fn,Y as os,m0 as Xm,az as bs,aD as Es,aA as Ga,m1 as Gc,b4 as Hs,f$ as Zc,fZ as Ym,f_ as Jm,m2 as Xc,be as Ir,af as Pt,ae as Rt,ag as Dt,kh as qs,cX as Yc,bg as Nr,m3 as Qm,m4 as eh,m5 as th,m6 as sh,m7 as nh,_ as rh,m8 as oh,m9 as Jc,d0 as Za,b7 as ah,$ as ih,ma as lh,A as Fe,bF as ch,mb as dh,mc as uh,kv as Qc,md as fh,bO as Zs,gg as ph,ay as mh,bh as Ts,bb as wo,bf as yo,bt as Dn,me as hh,aE as gh,aF as xh,aK as Bi,mf as vo,P as Tn,mg as bh,gl as ed,mh as wh,io as Pr,ip as So,cO as so,gm as yh,kV as vh,mi as Sh,bo as cr,gu as td,mj as kh,t as dr,q as ur,D as fr,l as pr,F as mr,o as no,B as yt,mk as Mn,a5 as Sn,a6 as kn,a7 as jn,ml as sd,mm as hr,n as ps,cn as Jt,mn as nd,mo as jh,da as rd,mp as Th,mq as Ch,mr as Eh,bS as Is,ms as Ih,cs as vn,mt as zi,bY as Hr,ad as tr,mu as Nh,a8 as Ks,g3 as Ph,cD as Xa,mv as Rh,mw as od,mx as Ya,er as Dh,e3 as ro,ey as ad,el as Ja,em as Qa,my as id,aU as es,y as Fn,C as pa,hQ as _h,il as Ah,h$ as Oh,iG as Mh,mz as Fh,hw as ld,bU as Us,K as ei,bN as Lh,au as vs,bT as cd,cu as Wi,ct as Xn,hx as $h,cv as Bh,cK as ko,cF as zh,hz as Wo,mA as Wh,z as dd,aW as ud,aX as fd,aY as pd,aZ as md,a_ as ti,aT as Vi,bZ as hd,bW as oo,mB as Vh,mC as Uh,mD as Hh,b0 as Wn,bL as Kh,bP as jo,bR as qh,bV as Gh,bQ as Ln,iv as Zh,bX as Xh,hC as Yh,cE as To,mE as gd,mF as xd,mG as Jh,ef as Qh,eb as eg,ee as tg,mH as sg,en as ng,ec as Ui,mI as rg,iQ as og,mJ as ag,mK as ig,ed as Hi,ex as lg,eh as cg,co as dg,mL as ug,mM as fg,mN as pg,mO as si,mP as ni,mQ as mg,mR as hg,mS as gg,mT as xg,mU as bg,lE as ri,mV as wg,mW as yg,mX as vg,mY as Sg,mZ as oi,m_ as kg,bM as jg,m$ as Tg,n0 as Cg,b$ as bd,n1 as wd,bv as Eg,n2 as Ig,x as yd,n3 as Ng,n4 as en,c8 as Pg,bK as Rg,as as Dg,n5 as _g,V as Ut,n6 as Ag,n7 as Og,dO as Mg,n8 as ai,n9 as Fg,na as Kr,nb as In,nc as Lg,k4 as $g,nd as bn,eu as Bg,ne as zg,nf as vd,l0 as Sd,fb as Co,ng as Wg,eq as Vg,dV as Ug,nh as ii,ni as Hg,cJ as Kg,cH as qg,nj as Gg,nk as Vo,d9 as li,fN as $n,nl as kd,dC as qr,cm as jd,bm as Zg,nm as Xg,nn as Yg,no as Jg,hq as Td,np as Mr,nq as Qg,nr as e1,ns as t1,nt as s1,nu as n1,nv as r1,nw as Ki,nx as o1,ny as a1,nz as i1,hi as ci,d2 as l1,hf as c1,ki as d1,kj as u1,db as f1,nA as gr,he as Cd,hd as Ed,kk as p1,kl as m1,hg as h1,d3 as g1,eS as x1,lN as b1,ca as w1,nB as Uo,lt as y1,ls as v1,nC as Id,nD as Nd,nE as S1,nF as ma,nG as sn,e7 as k1,kf as j1,lr as qi,nH as T1,nI as C1,lq as E1,lp as I1,nJ as N1,bd as xr,nK as Gi,nL as P1,nM as R1,nN as D1,kA as _1,kB as A1,nO as O1,kC as Zi,nP as M1,kD as Xi,kE as F1,dG as L1,nQ as $1,nR as B1,nS as z1,bu as W1,k as V1,l5 as U1,cZ as Ho,kF as H1,kG as K1,nT as Yi,kH as q1,d1 as G1,kK as Z1,kI as X1,kJ as Y1,nU as Ko,nV as qo,nW as pn,nX as Nn,nY as Ji,nZ as Qi,n_ as J1,n$ as Q1,lZ as ex,kY as di,eP as Rr,kS as tx,o0 as sx,o1 as Pd,fB as nx,o2 as ha,o3 as Rd,jE as Eo,l2 as rx,dn as ox,o4 as ax,o5 as Dd,gj as ix,o6 as lx,o7 as _d,eR as cx,eQ as ui,o8 as dx,o9 as el,oa as ux,ob as fx,eT as px,G as ga,oc as Ad,cx as Od,cy as Md,cz as Fd,cA as Ld,od as xa,cB as $d,kr as Bd,oe as Go,of as mx,og as hx,l4 as gx,a1 as xx,oh as bx,oi as wx,oj as zd,b5 as tl,fu as yx,km as vx,ok as Sx,kp as kx,lA as jx,dP as sl,ol as Tx,kt as Cx,om as Ex,lF as Ix,gz as Nx,on as Px,gP as nl,bc as Rx,gA as Dx,gC as _x,gB as Ax,gL as Ox,gK as Mx,gE as Fx,lG as Lx,gJ as $x,gF as Bx,gG as zx,gH as Wx,gI as Vx,a as Ux,s as Hx,b as Kx,c as qx,gS as Gx,al as Zx,gU as Xx,gV as Yx,gW as Jx}from"./useAppFontEffects-CpxtKEGw.js";import{f as Wd,u as Vd,S as Qx,W as Ud,a as eb,b as tb}from"./useRootScrollLock-C9UIEqnb.js";import{h as Hd,i as ao,T as Kd,M as qd,D as Gd,f as ba}from"./vendor-dnd-kit-core-Br1Cs7RV.js";import{r as sb,h as nb,u as Zd,S as Xd,v as rb,a as ob}from"./vendor-dnd-kit-sortable-DpfLEOLv.js";import{C as Yd}from"./vendor-dnd-kit-utilities-DZ9KbT5S.js";import{C as ab}from"./vendor-base-ui-CHqK1aDI.js";import{a as mn,O as ib,d as lb,D as cb,b as db,u as ub,m as rl}from"./moveWorkspacePath-CpN2DOGn.js";import{u as wa,c as Io,p as fb}from"./vendor-zustand-C9tWdk0j.js";import{o as Mt,s as It,n as as,c as Cn,h as Jd,e as ss,_ as Qd,j as an,l as br,a as wr,f as pb}from"./vendor-zod-DV_WH382.js";import{u as mb}from"./vendor-tanstack-react-virtual-Bw3q1rnq.js";import{v as ol,t as al}from"./contextFileOpenGuard-USev-3h1.js";import{d as hb,m as gb}from"./vendor-tanstack-virtual-core-B4TJYmIq.js";import{r as xb}from"./install-request-D5VhmtWC.js";function bb(t){const e=qe.c(37),{directory:s,className:r}=t,{currentTheme:o}=bo(),a=Yt(vb),i=it(yb),u=qt(wb),d=xf(s);let l;e[0]!==s||e[1]!==u?(l=vc(s,u),e[0]=s,e[1]=u,e[2]=l):l=e[2];const f=l;let m;e[3]!==s||e[4]!==f||e[5]!==a||e[6]!==d||e[7]!==i?(m=f||!s?null:Er(a,i,s,d),e[3]=s,e[4]=f,e[5]=a,e[6]=d,e[7]=i,e[8]=m):m=e[8];const p=m;if(f){let B;e[9]!==r?(B=Ye("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),e[9]=r,e[10]=B):B=e[10];let T;return e[11]!==B?(T=n.jsx(ue,{name:"chat-4",className:B}),e[11]=B,e[12]=T):T=e[12],T}if(!p)return null;const h=p.icon?qm[p.icon]:null;let x;e[13]!==p.color?(x=Gm(p.color)??void 0,e[13]=p.color,e[14]=x):x=e[14];const g=x;let v;e[15]!==r||e[16]!==g||e[17]!==h?(v=h?n.jsx(ue,{name:h,className:Ye("h-3.5 w-3.5 shrink-0",r),style:g?{color:g}:void 0}):n.jsx(ue,{name:"folder",className:Ye("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]=v):v=e[18];const y=v;if(!p.iconImage)return y;let C;e[19]!==r?(C=Ye("inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",r),e[19]=r,e[20]=C):C=e[20];let S;e[21]!==p.iconBackground?(S=p.iconBackground?{backgroundColor:p.iconBackground}:void 0,e[21]=p.iconBackground,e[22]=S):S=e[22];let N;e[23]!==p.iconImage||e[24]!==p.id?(N={id:p.id,iconImage:p.iconImage},e[23]=p.iconImage,e[24]=p.id,e[25]=N):N=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]!==y||e[30]!==N||e[31]!==F?(_=n.jsx(Zm,{project:N,options:F,className:"h-full w-full object-contain",fallback:y}),e[29]=y,e[30]=N,e[31]=F,e[32]=_):_=e[32];let M;return e[33]!==C||e[34]!==S||e[35]!==_?(M=n.jsx("span",{className:C,style:S,children:_}),e[33]=C,e[34]=S,e[35]=_,e[36]=M):M=e[36],M}function wb(t){return t.homeDirectory}function yb(t){return t.availableWorktreesByProject}function vb(t){return t.projects}const Yn=24,Sb=(t,e,s=Yn)=>{const r=e.right-(t.right-s);if(r>0)return r;const o=e.left-(t.left+s);return o<0?o:0},kb=({transform:t})=>({...t,y:0}),jb=16,Tb=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*jb:t.deltaY;t.currentTarget.scrollLeft+=mo(t.currentTarget)?-e:e},Cb=t=>{const e=qe.c(118),{tab:s,tabNumber:r,isActive:o,isPreview:a,suppressControls:i,onSelect:u,onPin:d,onClose:l,renderMenu:f,closeOtherTabs:m,onMenuOpenChangeComplete:p,menuReturnsFocus:h,children:x}=t,{t:g}=gt(),v=K(Ib);let y;e[0]!==v?(y=Ga("switch_session_tab",v),e[0]=v,e[1]=y):y=e[1];const C=y;let S;e[2]!==r||e[3]!==C?(S=C&&C!==Gc&&r<=9?bs(`${C}+${r}`):void 0,e[2]=r,e[3]=C,e[4]=S):S=e[4];const N=S,[F,_]=c.useState(false);let M;e[5]!==s.id?(M={id:s.id},e[5]=s.id,e[6]=M):M=e[6];const{attributes:B,listeners:T,setNodeRef:I,transform:b,transition:w,isDragging:j}=Zd(M);let R;e[7]!==g||e[8]!==s.session.title?(R=s.session.title?.trim()||g("sessions.sidebar.session.untitled"),e[7]=g,e[8]=s.session.title,e[9]=R):R=e[9];const L=R,E=s.id;let D;e[10]!==s.session?(D=Hs(s.session),e[10]=s.session,e[11]=D):D=e[11];const U=Oc(E,D),V=Zc(s.id),J=V!==null,W=Ym(s.id),G=Jm(s.id),$=J||W&&(!o||G)&&!J;let re;e[12]!==u||e[13]!==s?(re=()=>u(s),e[12]=u,e[13]=s,e[14]=re):re=e[14];let H;e[15]!==m||e[16]!==s.id?(H=()=>m(s.id),e[15]=m,e[16]=s.id,e[17]=H):H=e[17];let P,ee,oe,de,he,Z,ce,ae,te,pe,Te,Ae,Pe,ze,Oe,me;if(e[18]!==B||e[19]!==x||e[20]!==F||e[21]!==o||e[22]!==U||e[23]!==j||e[24]!==a||e[25]!==W||e[26]!==T||e[27]!==h||e[28]!==l||e[29]!==p||e[30]!==d||e[31]!==u||e[32]!==f||e[33]!==I||e[34]!==v||e[35]!==$||e[36]!==i||e[37]!==g||e[38]!==re||e[39]!==H||e[40]!==s||e[41]!==N||e[42]!==L||e[43]!==b||e[44]!==w||e[45]!==V){const We={session:s.session,open:F,isActive:o,select:re,closeOtherTabs:H,components:bp};te=I;let _e;e[62]!==b?(_e=Yd.Translate.toString(b),e[62]=b,e[63]=_e):_e=e[63],e[64]!==_e||e[65]!==w?(pe={transform:_e,transition:w},e[64]=_e,e[65]=w,e[66]=pe):pe=e[66];const Ue=j&&"z-10 opacity-60";e[67]!==Ue?(Te=Ye("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",Ue),e[67]=Ue,e[68]=Te):Te=e[68],Ae=o?"true":"false",e[69]!==o?(Pe=o?{"data-active-session-tab":true}:{},e[69]=o,e[70]=Pe):Pe=e[70],ze=B,Oe=T,ee=Ir,he=F,Z=_,e[71]!==p?(ce=ot=>p?.(ot),e[71]=p,e[72]=ce):ce=e[72];let Xe;e[73]!==x||e[74]!==o||e[75]!==U||e[76]!==a||e[77]!==W||e[78]!==l||e[79]!==d||e[80]!==u||e[81]!==v||e[82]!==$||e[83]!==i||e[84]!==g||e[85]!==s||e[86]!==L||e[87]!==V?(Xe=n.jsx(Pt,{asChild:true,children:n.jsx(ab,{render:ot=>n.jsx("div",{...ot,role:"tab","aria-selected":o,tabIndex:o?void 0:0,onClick:ye=>{if(ye.altKey){wp(s.id,W,g);return}const Ve=Hs(s.session);if(ye.shiftKey&&Ve&&!zn()){yp(s.id,Ve,L);return}o||u(s)},onDoubleClick:a?()=>d(s.id):void 0,onKeyDown:o?void 0:ye=>{(ye.key==="Enter"||ye.key===" ")&&(ye.preventDefault(),u(s))},onAuxClick:ye=>{ye.button===1&&(ye.preventDefault(),l(s.id))},className:Ye("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:n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[n.jsxs("span",{className:"relative me-1.5 inline-flex size-3.5 shrink-0 items-center justify-center",children:[n.jsx(bb,{directory:Hs(s.session),className:Ye(!i&&"group-hover/session-tab:opacity-0 group-has-[:focus-visible]/session-tab:opacity-0")}),i?null:n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button","aria-label":g("header.sessionTabs.closeTab"),onClick:ye=>{ye.stopPropagation(),l(s.id)},onPointerDown:Nb,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:n.jsx(ue,{name:"close",className:"size-3.5"})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:n.jsx(qs,{label:g("header.sessionTabs.closeTab"),shortcut:o?bs(As()?"mod+w":Es("close_session_tab",v),""):void 0})})]})]}),n.jsx("div",{className:Ye("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title",a&&!i&&"italic"),children:o?x:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:n.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:L})})}),U?n.jsx(ue,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":g("sessions.aiRename.generating")}):$?n.jsx(Yc,{state:V??"unread",className:"ms-1.5 shrink-0"}):null]})})})}),e[73]=x,e[74]=o,e[75]=U,e[76]=a,e[77]=W,e[78]=l,e[79]=d,e[80]=u,e[81]=v,e[82]=$,e[83]=i,e[84]=g,e[85]=s,e[86]=L,e[87]=V,e[88]=Xe):Xe=e[88];let Me;e[89]!==N||e[90]!==L?(Me=n.jsx(Dt,{side:"bottom",sideOffset:6,children:n.jsx(qs,{label:L,shortcut:N})}),e[89]=N,e[90]=L,e[91]=Me):Me=e[91],e[92]!==Xe||e[93]!==Me?(ae=n.jsxs(Rt,{children:[Xe,Me]}),e[92]=Xe,e[93]=Me,e[94]=ae):ae=e[94],P=Nr,e[95]!==h?(me=()=>h?.()??true,e[95]=h,e[96]=me):me=e[96],oe="min-w-[190px]",de=f(We),e[18]=B,e[19]=x,e[20]=F,e[21]=o,e[22]=U,e[23]=j,e[24]=a,e[25]=W,e[26]=T,e[27]=h,e[28]=l,e[29]=p,e[30]=d,e[31]=u,e[32]=f,e[33]=I,e[34]=v,e[35]=$,e[36]=i,e[37]=g,e[38]=re,e[39]=H,e[40]=s,e[41]=N,e[42]=L,e[43]=b,e[44]=w,e[45]=V,e[46]=P,e[47]=ee,e[48]=oe,e[49]=de,e[50]=he,e[51]=Z,e[52]=ce,e[53]=ae,e[54]=te,e[55]=pe,e[56]=Te,e[57]=Ae,e[58]=Pe,e[59]=ze,e[60]=Oe,e[61]=me}else P=e[46],ee=e[47],oe=e[48],de=e[49],he=e[50],Z=e[51],ce=e[52],ae=e[53],te=e[54],pe=e[55],Te=e[56],Ae=e[57],Pe=e[58],ze=e[59],Oe=e[60],me=e[61];let be;e[97]!==P||e[98]!==oe||e[99]!==de||e[100]!==me?(be=n.jsx(P,{finalFocus:me,className:oe,children:de}),e[97]=P,e[98]=oe,e[99]=de,e[100]=me,e[101]=be):be=e[101];let Ce;e[102]!==ee||e[103]!==he||e[104]!==Z||e[105]!==ce||e[106]!==ae||e[107]!==be?(Ce=n.jsxs(ee,{open:he,onOpenChange:Z,onOpenChangeComplete:ce,children:[ae,be]}),e[102]=ee,e[103]=he,e[104]=Z,e[105]=ce,e[106]=ae,e[107]=be,e[108]=Ce):Ce=e[108];let $e;return e[109]!==te||e[110]!==pe||e[111]!==Te||e[112]!==Ae||e[113]!==Pe||e[114]!==ze||e[115]!==Oe||e[116]!==Ce?($e=n.jsx("div",{ref:te,style:pe,className:Te,"data-active":Ae,...Pe,...ze,...Oe,children:Ce}),e[109]=te,e[110]=pe,e[111]=Te,e[112]=Ae,e[113]=Pe,e[114]=ze,e[115]=Oe,e[116]=Ce,e[117]=$e):$e=e[117],$e},Eb=t=>{const e=qe.c(110),{renderMenu:s,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,menuReturnsFocus:a,children:i}=t,u=o===void 0?false:o,{t:d,direction:l}=gt(),f=l==="rtl",m=fn(Pb),p=fn(Rb),h=fn(Db),x=fn(_b),g=fn(Ab),v=fn(Ob),y=it(Mb),C=it(Fb),S=os(Lb),N=K($b),F=fn(Bb),_=os(zb),M=it(Wb),B=it(Vb),T=it(Ub),I=it(Hb),b=it(Kb),w=it(qb);let j;e[0]!==w?(j=ie=>{const xe=w??ie.activeProjectId;return ie.projects.find(Le=>Le.id===xe)?.path??null},e[0]=w,e[1]=j):j=e[1];const R=Yt(j),L=xp(y);let E,D;e[2]!==L||e[3]!==M||e[4]!==y||e[5]!==b||e[6]!==I||e[7]!==B||e[8]!==R||e[9]!==h||e[10]!==F||e[11]!==N||e[12]!==_?(E=()=>{if(!N)F(Qm,Gb);else{if(!_)return;const ie=Xt(),xe=!y&&B&&I,Le=y?M:B&&!I?b??R:null,Ke=xe?eh(ie):th(ie,Le);if(!Ke)return;F(Ke,()=>sh(Le,os.getState().activeSessions,Yt.getState().projects.map(Zb)))}y&&h(y,L)},D=[L,M,y,b,I,B,R,h,F,N,_],e[2]=L,e[3]=M,e[4]=y,e[5]=b,e[6]=I,e[7]=B,e[8]=R,e[9]=h,e[10]=F,e[11]=N,e[12]=_,e[13]=E,e[14]=D):(E=e[13],D=e[14]),c.useEffect(E,D);let U;if(e[15]!==S){U=new Map;for(const ie of S)U.set(ie.id,ie);e[15]=S,e[16]=U}else U=e[16];const V=U;let J;if(e[17]!==V||e[18]!==m){J=[];for(const ie of m){const xe=V.get(ie);xe&&J.push({id:ie,session:xe})}e[17]=V,e[18]=m,e[19]=J}else J=e[19];const W=J;let G;e[20]!==C?(G=ie=>{C(ie.id,Hs(ie.session))},e[20]=C,e[21]=G):G=e[21];const le=G,$=Xb,re=!y&&B;let H;e[22]!==re||e[23]!==T?(H=ie=>!re||!T?"":(ie.drafts.find(Le=>Le.id===T)?.text??"").split(/\r?\n/).find(Yb)?.trim()??"",e[22]=re,e[23]=T,e[24]=H):H=e[24];const P=Xm(H),ee=K(Jb),oe=Qb;let de;e[25]!==y||e[26]!==re||e[27]!==W?(de=W.some(ie=>ie.id===y)||re&&W.length>0,e[25]=y,e[26]=re,e[27]=W,e[28]=de):de=e[28];const he=de;let Z,ce;e[29]!==he?(Z=()=>{if(he)return Ka(ew,{current:document.body})},ce=[he],e[29]=he,e[30]=Z,e[31]=ce):(Z=e[30],ce=e[31]),c.useEffect(Z,ce);let ae;e[32]!==g||e[33]!==y||e[34]!==le||e[35]!==W?(ae=ie=>{if(g(ie),y&&y!==ie){const xe=W.find(Le=>Le.id===ie);xe&&le(xe)}},e[32]=g,e[33]=y,e[34]=le,e[35]=W,e[36]=ae):ae=e[36];const te=ae;let pe;e[37]===Symbol.for("react.memo_cache_sentinel")?(pe={activationConstraint:{distance:8}},e[37]=pe):pe=e[37];let Te;e[38]===Symbol.for("react.memo_cache_sentinel")?(Te={activationConstraint:{delay:200,tolerance:6}},e[38]=Te):Te=e[38];const Ae=Hd(ao(qd,pe),ao(Kd,Te));let Pe;e[39]!==v?(Pe=ie=>{const{active:xe,over:Le}=ie;Le&&xe.id!==Le.id&&v(String(xe.id),String(Le.id))},e[39]=v,e[40]=Pe):Pe=e[40];const ze=Pe,Oe=c.useRef(null);let me;e[41]===Symbol.for("react.memo_cache_sentinel")?(me={left:false,right:false},e[41]=me):me=e[41];const[be,Ce]=c.useState(me);let $e;e[42]===Symbol.for("react.memo_cache_sentinel")?($e=()=>{const ie=Oe.current;if(!ie)return;const xe=ie.scrollWidth-ie.clientWidth,Le=mo(ie)?xe+ie.scrollLeft:ie.scrollLeft,Ke=Le>2,ve=Le<xe-2;Ce(je=>je.left===Ke&&je.right===ve?je:{left:Ke,right:ve})},e[42]=$e):$e=e[42];const We=$e;let _e;e[43]===Symbol.for("react.memo_cache_sentinel")?(_e=()=>{We();const ie=Oe.current;if(!ie||!globalThis.ResizeObserver)return;const xe=new ResizeObserver(We);return xe.observe(ie),()=>xe.disconnect()},e[43]=_e):_e=e[43];let Ue;e[44]!==W.length?(Ue=[We,W.length],e[44]=W.length,e[45]=Ue):Ue=e[45],c.useEffect(_e,Ue);let Xe;e[46]===Symbol.for("react.memo_cache_sentinel")?(Xe=()=>{const ie=Oe.current,xe=ie?.querySelector("[data-active-session-tab]");if(!ie||!xe)return;const Le=Sb(ie.getBoundingClientRect(),xe.getBoundingClientRect());Le!==0&&(ie.scrollLeft=ie.scrollLeft+Le,We())},e[46]=Xe):Xe=e[46];let Me;e[47]!==y?(Me=[y,We],e[47]=y,e[48]=Me):Me=e[48],c.useEffect(Xe,Me);const ot=be.left&&be.right?`linear-gradient(to right, transparent, black ${Yn}px, black calc(100% - ${Yn}px), transparent)`:be.left?`linear-gradient(to right, transparent, black ${Yn}px)`:be.right?`linear-gradient(to right, black calc(100% - ${Yn}px), transparent)`:void 0;let ye;e[49]!==W?(ye=W.map(tw),e[49]=W,e[50]=ye):ye=e[50];const Ve=ye;let lt;e[51]!==y||e[52]!==W?(lt=!!y&&!W.some(ie=>ie.id===y),e[51]=y,e[52]=W,e[53]=lt):lt=e[53];const ct=lt;let st;e[54]!==d?(st=d("header.sessionTabs.stripAria"),e[54]=d,e[55]=st):st=e[55];let k;e[56]!==ot?(k=ot?{maskImage:ot,WebkitMaskImage:ot}:void 0,e[56]=ot,e[57]=k):k=e[57];let Y;e[58]===Symbol.for("react.memo_cache_sentinel")?(Y=[kb],e[58]=Y):Y=e[58];const Ne=f?sb:nb;let Re;e[59]!==i||e[60]!==y||e[61]!==te||e[62]!==le||e[63]!==a||e[64]!==r||e[65]!==x||e[66]!==p||e[67]!==s||e[68]!==u||e[69]!==W?(Re=W.map((ie,xe)=>n.jsx(Cb,{tabNumber:xe+1,tab:ie,isActive:ie.id===y,isPreview:ie.id===p,suppressControls:ie.id===y&&u,onSelect:le,onPin:x,onClose:$,renderMenu:s,closeOtherTabs:te,onMenuOpenChangeComplete:r,menuReturnsFocus:a,children:ie.id===y?i:null},ie.id)),e[59]=i,e[60]=y,e[61]=te,e[62]=le,e[63]=a,e[64]=r,e[65]=x,e[66]=p,e[67]=s,e[68]=u,e[69]=W,e[70]=Re):Re=e[70];let Ie;e[71]!==Ne||e[72]!==Re||e[73]!==Ve?(Ie=n.jsx(Xd,{items:Ve,strategy:Ne,children:Re}),e[71]=Ne,e[72]=Re,e[73]=Ve,e[74]=Ie):Ie=e[74];let Ee;e[75]!==ze||e[76]!==Ae||e[77]!==Ie?(Ee=n.jsx(Gd,{sensors:Ae,collisionDetection:ba,modifiers:Y,onDragEnd:ze,children:Ie}),e[75]=ze,e[76]=Ae,e[77]=Ie,e[78]=Ee):Ee=e[78];let Ge;e[79]!==P||e[80]!==re||e[81]!==d?(Ge=re?n.jsxs("div",{role:"tab","aria-selected":true,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":true,children:[n.jsx(ue,{name:"edit",className:"me-1.5 size-3.5 shrink-0"}),n.jsx("div",{className:"session-tab-title min-w-0 flex-1 overflow-hidden whitespace-nowrap italic",children:n.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:P||d("sessions.switcher.draftTitle")})})]}):null,e[79]=P,e[80]=re,e[81]=d,e[82]=Ge):Ge=e[82];let Be;e[83]!==i||e[84]!==ct?(Be=ct?n.jsx("div",{role:"tab","aria-selected":true,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:n.jsx("div",{className:"min-w-0 flex-1",children:i})}):null,e[83]=i,e[84]=ct,e[85]=Be):Be=e[85];let Ze;e[86]!==k||e[87]!==Ee||e[88]!==Ge||e[89]!==Be?(Ze=n.jsxs("div",{ref:Oe,onScroll:We,onWheel:Tb,className:"session-tabs-scroll flex min-w-0 flex-initial items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:k,children:[Ee,Ge,Be]}),e[86]=k,e[87]=Ee,e[88]=Ge,e[89]=Be,e[90]=Ze):Ze=e[90];let et;e[91]!==d?(et=d("sessions.sidebar.header.actions.newSession"),e[91]=d,e[92]=et):et=e[92];let wt;e[93]===Symbol.for("react.memo_cache_sentinel")?(wt=n.jsx(ue,{name:"add",className:"size-4"}),e[93]=wt):wt=e[93];let Qe;e[94]!==et?(Qe=n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:oe,"aria-label":et,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:wt})}),e[94]=et,e[95]=Qe):Qe=e[95];let dt;e[96]!==d?(dt=d("sessions.sidebar.header.actions.newSession"),e[96]=d,e[97]=dt):dt=e[97];let at;e[98]!==ee?(at=bs(Es("new_chat",ee),""),e[98]=ee,e[99]=at):at=e[99];let z;e[100]!==dt||e[101]!==at?(z=n.jsx(Dt,{side:"bottom",sideOffset:6,children:n.jsx(qs,{label:dt,shortcut:at})}),e[100]=dt,e[101]=at,e[102]=z):z=e[102];let fe;e[103]!==Qe||e[104]!==z?(fe=n.jsxs(Rt,{children:[Qe,z]}),e[103]=Qe,e[104]=z,e[105]=fe):fe=e[105];let ke;return e[106]!==st||e[107]!==Ze||e[108]!==fe?(ke=n.jsxs("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":st,children:[Ze,fe]}),e[106]=st,e[107]=Ze,e[108]=fe,e[109]=ke):ke=e[109],ke};function Ib(t){return t.shortcutOverrides}function Nb(t){return t.stopPropagation()}function Pb(t){return t.tabIds}function Rb(t){return t.previewTabId}function Db(t){return t.ensureTab}function _b(t){return t.pinTab}function Ab(t){return t.closeOtherTabs}function Ob(t){return t.reorderTabs}function Mb(t){return t.currentSessionId}function Fb(t){return t.setCurrentSession}function Lb(t){return t.activeSessions}function $b(t){return t.sessionTabsPerWorkspace}function Bb(t){return t.enterScope}function zb(t){return t.hasLoaded}function Wb(t){return t.currentSessionDirectory}function Vb(t){return t.newSessionDraft.open}function Ub(t){return t.newSessionDraft.workDraftId??null}function Hb(t){return t.newSessionDraft.target==="chat"}function Kb(t){return t.newSessionDraft.directoryOverride}function qb(t){return t.newSessionDraft.selectedProjectId??null}function Gb(){return[]}function Zb(t){return t.path}function Xb(t){Xc(t)}function Yb(t){return t.trim()}function Jb(t){return t.shortcutOverrides}function Qb(){const{currentSessionId:t,newSessionDraft:e,openNewSessionDraft:s}=it.getState(),r=t?qt.getState().currentDirectory:e.directoryOverride;s(r?{directoryOverride:r}:void 0)}function ew(){const t=it.getState().currentSessionId;t?Xc(t):nh(-1)}function tw(t){return t.id}const sw=(t,e)=>{const s=!!t.time?.archived,r=e.projects.flatMap(u=>{const d=ts(u.path);return d?[{id:u.id,normalizedPath:d}]:[]}),a=rh(s?[]:[t],r,e.availableWorktreesByProject,e.isVSCode,s?[t]:[],e.authoritativeProjects,e.spaces).bySessionId.get(t.id),i=oh(e.activeSessions,e.resolveLegacyScope).runKeyBySessionId.has(t.id);return{projectId:a?.projectId??null,folderOwnerKey:vp(t,a,i),ownsWork:!i&&(!a||a.kind==="project")&&Jc(t,e.lookup)===null}},nw=(t,e)=>{const s=new Map(e.map(u=>[u.id,u])),r=new Map;for(const u of e){if(u.parentID||u.time?.archived)continue;const d=Jc(u,f=>s.get(f));if(!d)continue;const l=r.get(d);l?l.push(u):r.set(d,[u])}const o=[],a=new Set,i=[t];for(;i.length>0;){const u=i.pop();!u||a.has(u.id)||(a.add(u.id),Za(u)&&o.push(u),i.push(...r.get(u.id)??[]))}return o};function il({sessionId:t,open:e,slots:s,onRename:r,onExport:o,onMoveSession:a,onArchive:i,onDelete:u}){const{t:d}=gt(),l=c.useMemo(()=>zn(),[]),f=os(b=>b.entityById.get(t)),m=os(b=>{const w=b.entityById.get(t);return!w||ah(w,b.entityById)}),p=os(b=>b.activeSessions),h=it(b=>b.unarchiveSession),x=it(b=>b.availableWorktreesByProject),g=it(b=>b.worktreeMetadata),v=K(b=>b.sessionWorkEnabled),y=Yt(b=>b.projects),C=ih(b=>b.projects),S=bf(!l),N=Sp(b=>b.load),F=c.useMemo(()=>f?sw(f,{projects:y,availableWorktreesByProject:x,authoritativeProjects:C,spaces:S,isVSCode:l,activeSessions:p,resolveLegacyScope:b=>ts(g.get(b.id)?.projectDirectory??b.directory??null),lookup:b=>os.getState().entityById.get(b)}):null,[p,C,x,l,y,f,S,g]);if(!f||!F)return null;const _=!!f.time?.archived,M=ts(f.directory??null),B=v&&F.ownsWork&&!_&&!f.parentID&&!ho(f.directory),T=B?nw(f,p):[],I=async()=>{await h(f.id)?Fe.success(d("sessions.sidebar.session.restore.success")):Fe.error(d("sessions.sidebar.session.restore.error"))};return n.jsx(kp,{session:f,directory:M,open:e,slots:s,archived:_,pinned:lh(f),work:B?{inWork:T.length>0,toggle:()=>{jp(f.id,M,T,d)}}:null,projectId:F.projectId,currentWorktree:it.getState().getWorktreeMetadata(f.id)??null,descendants:[],startWorktreeLoad:N,folders:F.folderOwnerKey?{ownerKey:F.folderOwnerKey,projectId:F.projectId}:null,onRename:r,onExport:()=>o(f,M),onMoveSession:()=>{M&&a(f.id,M)},onArchive:i,onRestore:_&&m?()=>{I()}:null,onDelete:u})}const rw=t=>{const e=Qc(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},ow=(t,e)=>t===null||e===null?t===e:t.state!==e.state?false:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,eu=()=>{const t=qe.c(4),e=it(aw),s=it(iw)??void 0,r=ch(e??"",s,rw,ow),{context:o}=dh(e,s),a=o>0?o:uh;let i;return t[0]!==r||t[1]!==a||t[2]!==e?(i={sessionId:e,fill:r,limit:a},t[0]=r,t[1]=a,t[2]=e,t[3]=i):i=t[3],i};function aw(t){return t.currentSessionId}function iw(t){return t.currentSessionDirectory}const ll=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),zs=18,ya=2,va=(zs-ya)/2,cl=2*Math.PI*va,lw=t=>{const e=qe.c(9),{percent:s,arcColor:r,className:o}=t,a=r===void 0?"currentColor":r,i=Math.min(100,Math.max(0,s));let u;e[0]!==o?(u=Ye("shrink-0",o),e[0]=o,e[1]=u):u=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("circle",{cx:zs/2,cy:zs/2,r:va,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:ya}),e[2]=d):d=e[2];let l;e[3]!==a||e[4]!==i?(l=i>0?n.jsx("circle",{cx:zs/2,cy:zs/2,r:va,fill:"none",stroke:a,strokeWidth:ya,strokeLinecap:"round",strokeDasharray:cl,strokeDashoffset:cl*(1-i/100),transform:`rotate(-90 ${zs/2} ${zs/2})`}):null,e[3]=a,e[4]=i,e[5]=l):l=e[5];let f;return e[6]!==u||e[7]!==l?(f=n.jsxs("svg",{viewBox:`0 0 ${zs} ${zs}`,className:u,"aria-hidden":"true",children:[d,l]}),e[6]=u,e[7]=l,e[8]=f):f=e[8],f},tu=()=>{const t=qe.c(16),{t:e}=gt(),{sessionId:s,fill:r,limit:o}=eu(),{totalCost:a}=fh(s);if(!s||!r)return null;let i;t[0]!==r.state||t[1]!==r.totalTokens||t[2]!==e?(i=r.state==="measured"?e("contextUsage.tooltip.usedTokens",{tokens:ll(r.totalTokens)}):e("contextUsage.compacted.description"),t[0]=r.state,t[1]=r.totalTokens,t[2]=e,t[3]=i):i=t[3];let u;t[4]!==o||t[5]!==e?(u=e("contextUsage.tooltip.contextLimit",{tokens:ll(o)}),t[4]=o,t[5]=e,t[6]=u):u=t[6];let d;t[7]!==e||t[8]!==a?(d=a!==null&&a>0?[e("contextUsage.tooltip.cost",{cost:Wd(a)})]:[],t[7]=e,t[8]=a,t[9]=d):d=t[9];let l;t[10]!==i||t[11]!==u||t[12]!==d?(l=[i,u,...d],t[10]=i,t[11]=u,t[12]=d,t[13]=l):l=t[13];const f=l;let m;return t[14]!==f?(m=n.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-edge pt-1 tabular-nums",children:f.map(cw)}),t[14]=f,t[15]=m):m=t[15],m};function cw(t){return n.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const dw="\u2014",uw={safe:"var(--muted-foreground)",warn:"var(--status-warning)",critical:"var(--status-error)"},fw=t=>{const e=qe.c(35),{buttonClassName:s}=t,{t:r}=gt(),{sessionId:o,fill:a,limit:i}=eu(),u=Zs();let d;e[0]!==u?(d=u?ds(u):"",e[0]=u,e[1]=d):d=e[1];const l=d,f=K(mw);let m;e[2]!==l?(m=j=>l!==""&&za(j.contextPanelByDirectory[l],j.contextSurfaceZones).has("context"),e[2]=l,e[3]=m):m=e[3];const p=K(m),h=K(hw);if(!o||!a||h)return null;const x=a.state==="measured"?a.totalTokens/i*100:null,g=x===null?void 0:uw[ph(Math.round(x))];let v;e[4]!==l||e[5]!==f?(v=l?()=>f(l,"context"):void 0,e[4]=l,e[5]=f,e[6]=v):v=e[6];let y;e[7]!==r?(y=r("contextUsage.aria.label"),e[7]=r,e[8]=y):y=e[8];const C=p&&"text-foreground";let S;e[9]!==s||e[10]!==C?(S=Ye(s,"w-auto gap-1.5 px-1 tabular-nums",C),e[9]=s,e[10]=C,e[11]=S):S=e[11];const N=x??0;let F;e[12]!==g||e[13]!==N?(F=n.jsx(lw,{percent:N,arcColor:g,className:"size-4"}),e[12]=g,e[13]=N,e[14]=F):F=e[14];let _;e[15]!==x?(_=x===null?dw:`${Math.min(x,999).toFixed(1)}%`,e[15]=x,e[16]=_):_=e[16];let M;e[17]!==_?(M=n.jsx("span",{dir:"ltr",className:"typography-meta",children:_}),e[17]=_,e[18]=M):M=e[18];let B;e[19]!==p||e[20]!==M||e[21]!==v||e[22]!==y||e[23]!==S||e[24]!==F?(B=n.jsx(Pt,{asChild:true,children:n.jsxs("button",{type:"button",onClick:v,"aria-label":y,"aria-pressed":p,className:S,children:[F,M]})}),e[19]=p,e[20]=M,e[21]=v,e[22]=y,e[23]=S,e[24]=F,e[25]=B):B=e[25];let T;e[26]!==p||e[27]!==r?(T=p?null:n.jsx("span",{children:r("chat.workStatus.action.openContext")}),e[26]=p,e[27]=r,e[28]=T):T=e[28];let I;e[29]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(tu,{}),e[29]=I):I=e[29];let b;e[30]!==T?(b=n.jsx(Dt,{side:"bottom",children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[T,I]})}),e[30]=T,e[31]=b):b=e[31];let w;return e[32]!==B||e[33]!==b?(w=n.jsxs(Rt,{children:[B,b]}),e[32]=B,e[33]=b,e[34]=w):w=e[34],w},pw=c.memo(fw);function mw(t){return t.openContextSurface}function hw(t){return t.workStatusPanelVisible&&!t.workStatusHiddenSections.includes("session")}const dl=t=>{const e=qe.c(12),{run:s,showIdle:r,large:o,className:a}=t,i=r===void 0?false:r,u=o===void 0?false:o;if(s?.status==="stopping"||s?.status==="waiting-for-preview"){let l;e[0]!==a?(l=Ye("size-4 shrink-0 animate-spin text-[var(--status-warning)]",a),e[0]=a,e[1]=l):l=e[1];let f;return e[2]!==l?(f=n.jsx(ue,{name:"loader-4",className:l}),e[2]=l,e[3]=f):f=e[3],f}if(s){const l=u?"stop-large":"stop";let f;e[4]!==a?(f=Ye("size-4 shrink-0 text-[var(--status-error)]",a),e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==l||e[7]!==f?(m=n.jsx(ue,{name:l,className:f}),e[6]=l,e[7]=f,e[8]=m):m=e[8],m}let d;return e[9]!==a||e[10]!==i?(d=i?n.jsx(ue,{name:"play",className:Ye("size-4 shrink-0",a)}):null,e[9]=a,e[10]=i,e[11]=d):d=e[11],d},gw=t=>{const e=qe.c(68),{directory:s,buttonClassName:r}=t,{t:o}=gt(),a=mn(bw),i=mn(ww),u=mn(yw),d=mn(vw),l=mh(d),f=mn(Sw),m=mn(kw),p=mn(jw);let h,x;e[0]!==f?(h=()=>{f()},x=[f],e[0]=f,e[1]=h,e[2]=x):(h=e[1],x=e[2]),c.useEffect(h,x);const g=As()&&go();let v;e[3]!==i||e[4]!==a?(v=i.find(P=>P.id===a)??i.find(Tw)??i[0]??ib[0],e[3]=i,e[4]=a,e[5]=v):v=e[5];const y=v;if(!g||!s||i.length===0)return null;let C;e[6]!==s?(C=async P=>{await wf(s,P.id,P.appName)||await Sc(s,P.appName)},e[6]=s,e[7]=C):C=e[7];const S=C;let N;e[8]!==S||e[9]!==p?(N=async P=>{await p(P.id),await S(P)},e[8]=S,e[9]=p,e[10]=N):N=e[10];const F=N;let _;e[11]!==s||e[12]!==o?(_=async()=>{(await wo(s)).ok&&Fe.success(o("openInApp.toast.pathCopied"))},e[11]=s,e[12]=o,e[13]=_):_=e[13];const M=_;let B;e[14]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx("div",{className:"inline-flex"}),e[14]=B):B=e[14];let T;e[15]!==S||e[16]!==y?(T=()=>{S(y)},e[15]=S,e[16]=y,e[17]=T):T=e[17];let I;e[18]!==l||e[19]!==r?(I=Ye(r,l),e[18]=l,e[19]=r,e[20]=I):I=e[20];let b;e[21]!==y.label||e[22]!==o?(b=o("openInApp.actions.openInAria",{app:y.label}),e[21]=y.label,e[22]=o,e[23]=b):b=e[23];let w;e[24]!==y.icon?(w=n.jsx(ue,{name:y.icon,className:"size-4"}),e[24]=y.icon,e[25]=w):w=e[25];let j;e[26]!==b||e[27]!==w||e[28]!==T||e[29]!==I?(j=n.jsx(yo,{render:B,children:n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:T,className:I,"aria-label":b,children:w})})}),e[26]=b,e[27]=w,e[28]=T,e[29]=I,e[30]=j):j=e[30];let R;e[31]!==y.label||e[32]!==o?(R=o("openInApp.actions.openInAria",{app:y.label}),e[31]=y.label,e[32]=o,e[33]=R):R=e[33];let L;e[34]!==R?(L=n.jsx(Dt,{side:"bottom",children:R}),e[34]=R,e[35]=L):L=e[35];let E;e[36]!==j||e[37]!==L?(E=n.jsxs(Rt,{children:[j,L]}),e[36]=j,e[37]=L,e[38]=E):E=e[38];let D;e[39]!==M?(D=()=>{M()},e[39]=M,e[40]=D):D=e[40];let U;e[41]===Symbol.for("react.memo_cache_sentinel")?(U=n.jsx(ue,{name:"file-copy",className:"h-4 w-4"}),e[41]=U):U=e[41];let V;e[42]!==o?(V=o("openInApp.actions.copyPath"),e[42]=o,e[43]=V):V=e[43];let J;e[44]!==V?(J=n.jsx("span",{className:"typography-ui-label text-foreground",children:V}),e[44]=V,e[45]=J):J=e[45];let W;e[46]!==D||e[47]!==J?(W=n.jsxs(Ts,{className:"flex items-center gap-2",onClick:D,children:[U,J]}),e[46]=D,e[47]=J,e[48]=W):W=e[48];let G;e[49]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(Dn,{}),e[49]=G):G=e[49];let le;if(e[50]!==i||e[51]!==F||e[52]!==y.id){let P;e[54]!==F||e[55]!==y.id?(P=ee=>n.jsxs(Ts,{className:"flex items-center gap-2",onClick:()=>{F(ee)},children:[n.jsx(ue,{name:ee.icon,className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:ee.label}),y.id===ee.id?n.jsx(ue,{name:"check",className:"ms-auto h-4 w-4 text-primary"}):null]},ee.id),e[54]=F,e[55]=y.id,e[56]=P):P=e[56],le=i.map(P),e[50]=i,e[51]=F,e[52]=y.id,e[53]=le}else le=e[53];let $;e[57]!==u||e[58]!==m||e[59]!==o?($=u?n.jsxs(Ts,{className:"flex items-center gap-2",onClick:()=>{m(true)},children:[n.jsx(ue,{name:"refresh",className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[57]=u,e[58]=m,e[59]=o,e[60]=$):$=e[60];let re;e[61]!==W||e[62]!==le||e[63]!==$?(re=n.jsxs(Nr,{className:"w-56 max-h-[70vh] overflow-y-auto",children:[W,G,le,$]}),e[61]=W,e[62]=le,e[63]=$,e[64]=re):re=e[64];let H;return e[65]!==E||e[66]!==re?(H=n.jsxs(Ir,{children:[E,re]}),e[65]=E,e[66]=re,e[67]=H):H=e[67],H},xw=c.memo(gw);function bw(t){return t.selectedAppId}function ww(t){return t.availableApps}function yw(t){return t.isCacheStale}function vw(t){return t.isScanning}function Sw(t){return t.initialize}function kw(t){return t.loadInstalledApps}function jw(t){return t.selectApp}function Tw(t){return t.id===lb}const Jn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Cw=({projects:t,worktreesByProject:e,directory:s,activeProjectId:r})=>{const o=Jn(s??"");if(o){const a=Er(t,e,o);if(a)return a}return t.find(a=>a.id===r)??null};function su(){const t=Yt(v=>v.projects),e=Yt(v=>v.activeProjectId),s=it(v=>v.availableWorktreesByProject),r=it(v=>v.currentSessionId),o=hh(r??null),a=it(v=>r?v.worktreeMetadata.get(r)?.path??"":""),i=it(v=>v.newSessionDraft?.open?Jn(v.newSessionDraft.bootstrapPendingDirectory??v.newSessionDraft.directoryOverride??""):""),u=it(v=>v.newSessionDraft?.open?v.newSessionDraft.target==="chat":null),d=c.useMemo(()=>Jn(a||""),[a]),l=c.useMemo(()=>Jn(o||""),[o]),f=d||l||i,m=c.useMemo(()=>Cw({projects:t,worktreesByProject:s,directory:f,activeProjectId:e}),[e,f,t,s]),p=c.useMemo(()=>Jn(f||m?.path||""),[f,m?.path]),h=c.useMemo(()=>m?{id:m.id,path:m.path}:null,[m]),x=u??ho(l),g=c.useRef(null);return c.useEffect(()=>{h&&p&&!x&&(g.current={projectRef:h,directory:p})},[p,h,x]),c.useMemo(()=>x?null:h&&p?{projectRef:h,directory:p}:g.current,[h,p,x])}const Ew=t=>{const e=qe.c(67),{buttonClassName:s}=t,{t:r}=gt(),o=gh(),a=K(Rw),[i,u]=c.useState(false),d=K(Dw);let l;e[0]!==d?(l=bs(Es("open_project_actions",d),""),e[0]=d,e[1]=l):l=e[1];const f=l,m=o?.available?o.shown:null;let p;e[2]!==o||e[3]!==m?(p=m&&o?o.runOf(m):null,e[2]=o,e[3]=m,e[4]=p):p=e[4];const h=p;xh(true);let x;e[5]!==h?(x=re=>h?re.getDirectoryState(h.directory)?.tabs.find(H=>H.id===h.tabId)?.previewUrl??null:null,e[5]=h,e[6]=x):x=e[6];const g=Ct(x);if(!o||!m)return null;let v;e[7]!==m.name||e[8]!==h||e[9]!==r?(v=h?r("projectActions.actions.stopNamedAria",{name:m.name}):r("projectActions.actions.runNamedAria",{name:m.name}),e[7]=m.name,e[8]=h,e[9]=r,e[10]=v):v=e[10];const y=v;let C;e[11]!==s||e[12]!==a||e[13]!==g||e[14]!==h||e[15]!==r?(C=h&&g?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:()=>a(h.directory,g),className:s,"aria-label":r("projectActions.actions.openPreview"),children:n.jsx(ue,{name:"global",className:"size-4"})})}),n.jsx(Dt,{side:"bottom",children:r("projectActions.actions.openPreview")})]}):null,e[11]=s,e[12]=a,e[13]=g,e[14]=h,e[15]=r,e[16]=C):C=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("div",{className:"inline-flex"}),e[17]=S):S=e[17];let N;e[18]!==o||e[19]!==m?(N=()=>o.toggle(m),e[18]=o,e[19]=m,e[20]=N):N=e[20];const F=o.isLoading||h?.status==="stopping",_=i&&"text-foreground";let M;e[21]!==s||e[22]!==_?(M=Ye(s,_),e[21]=s,e[22]=_,e[23]=M):M=e[23];let B;e[24]!==m||e[25]!==h?(B=h?n.jsx(dl,{run:h,large:true}):n.jsx(ue,{name:Bi(m),className:"size-4"}),e[24]=m,e[25]=h,e[26]=B):B=e[26];let T;e[27]!==y||e[28]!==M||e[29]!==B||e[30]!==N||e[31]!==F?(T=n.jsx(yo,{render:S,children:n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:N,disabled:F,className:M,"aria-label":y,children:B})})}),e[27]=y,e[28]=M,e[29]=B,e[30]=N,e[31]=F,e[32]=T):T=e[32];let I;e[33]!==y?(I=n.jsx("span",{children:y}),e[33]=y,e[34]=I):I=e[34];let b;e[35]!==r?(b=r("projectActions.header.allActions"),e[35]=r,e[36]=b):b=e[36];let w;e[37]!==f||e[38]!==b?(w=n.jsx("span",{className:"typography-micro text-muted-foreground",children:n.jsx(qs,{label:b,shortcut:f})}),e[37]=f,e[38]=b,e[39]=w):w=e[39];let j;e[40]!==I||e[41]!==w?(j=n.jsx(Dt,{side:"bottom",children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[I,w]})}),e[40]=I,e[41]=w,e[42]=j):j=e[42];let R;e[43]!==T||e[44]!==j?(R=n.jsxs(Rt,{children:[T,j]}),e[43]=T,e[44]=j,e[45]=R):R=e[45];const L=o.openSettings;let E;e[46]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(ue,{name:"add",className:"h-4 w-4"}),e[46]=E):E=e[46];let D;e[47]!==r?(D=r("projectActions.actions.addNewAction"),e[47]=r,e[48]=D):D=e[48];let U;e[49]!==D?(U=n.jsx("span",{className:"typography-ui-label text-foreground",children:D}),e[49]=D,e[50]=U):U=e[50];let V;e[51]!==o.openSettings||e[52]!==U?(V=n.jsxs(Ts,{className:"flex items-center gap-2",onClick:L,children:[E,U]}),e[51]=o.openSettings,e[52]=U,e[53]=V):V=e[53];let J;e[54]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx(Dn,{}),e[54]=J):J=e[54];let W;e[55]!==o||e[56]!==r?(W=o.actions.map(re=>n.jsxs(Ts,{className:"flex items-center gap-2",onClick:()=>{o.select(re),o.toggle(re)},children:[n.jsx(ue,{name:Bi(re),className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground truncate",children:re.name}),re.source==="shared"?n.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,n.jsx(dl,{run:o.runOf(re),className:"ms-auto"})]},re.id)),e[55]=o,e[56]=r,e[57]=W):W=e[57];let G;e[58]!==V||e[59]!==W?(G=n.jsxs(Nr,{className:"w-60 max-h-[70vh] overflow-y-auto",children:[V,J,W]}),e[58]=V,e[59]=W,e[60]=G):G=e[60];let le;e[61]!==R||e[62]!==G?(le=n.jsxs(Ir,{onOpenChange:u,children:[R,G]}),e[61]=R,e[62]=G,e[63]=le):le=e[63];let $;return e[64]!==le||e[65]!==C?($=n.jsxs(n.Fragment,{children:[C,le]}),e[64]=le,e[65]=C,e[66]=$):$=e[66],$},Iw=c.memo(Ew),Nw=t=>{const e=qe.c(8),{buttonClassName:s}=t,r=su();if(!r)return null;let o;e[0]!==s||e[1]!==r.directory?(o=n.jsx(xw,{directory:r.directory,buttonClassName:s}),e[0]=s,e[1]=r.directory,e[2]=o):o=e[2];let a;e[3]!==s?(a=n.jsx(Iw,{buttonClassName:s}),e[3]=s,e[4]=a):a=e[4];let i;return e[5]!==o||e[6]!==a?(i=n.jsxs(n.Fragment,{children:[o,a]}),e[5]=o,e[6]=a,e[7]=i):i=e[7],i},Pw=c.memo(Nw);function Rw(t){return t.openContextPreview}function Dw(t){return t.shortcutOverrides}const Zo="--oc-titlebar-controls-width",Sa=new Set;let sr=null;const nu=t=>{sr===null?t.style.removeProperty(Zo):t.style.getPropertyValue(Zo)!==sr&&t.style.setProperty(Zo,sr)},_w=t=>{const e=`${Math.round(t)}px`;e!==sr&&(sr=e,Sa.forEach(nu))},ru=t=>{if(t)return Sa.add(t),nu(t),()=>{Sa.delete(t)}},Kn="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",qn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Aw=()=>{yf("ui.header.render");const{t,direction:e}=gt(),s=K(X=>X.isSidebarOpen),r=vo(),o=K(X=>X.sessionTabsEnabled),a=it(X=>!!X.newSessionDraft?.open),i=it(X=>X.currentSessionId),u=os(wa(c.useCallback(X=>{if(!i)return null;const mt=[...X.activeSessions,...X.archivedSessions].find($t=>$t.id===i);if(!mt)return null;const jt=mt;return{title:mt.title??null,directory:jt.directory??null,created:mt.time?.created??null,slug:jt.slug??null}},[i]))),d=Yt(wa(X=>{if(!X.activeProjectId)return null;const mt=X.projects.find(jt=>jt.id===X.activeProjectId);return mt?{id:mt.id,path:mt.path,label:mt.label}:null})),l=c.useMemo(()=>{if(!d)return null;const X=d.label?.trim();if(X)return X;const mt=d.path.split(/[\\/]/).filter(Boolean);return mt[mt.length-1]??null},[d]),{isMobile:f}=Tn(),m=c.useRef(null),[p,h]=c.useState(()=>typeof window>"u"?false:As()),x=c.useMemo(()=>eo(),[]),g=bh(),[v,y]=c.useState(false),C=c.useMemo(()=>typeof navigator>"u"?false:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:S,side:N}=Vd(),F=c.useMemo(()=>{if(typeof window>"u")return null;const X=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof X=="number"&&Number.isFinite(X)&&X>0)return X;if(typeof navigator>"u")return null;const mt=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!mt)return null;const jt=Number.parseInt(mt[1],10),$t=Number.parseInt(mt[2],10);return Number.isNaN(jt)?null:jt===10?$t:jt},[]);Kt.useEffect(()=>{typeof window>"u"||h(As())},[]);const _=c.useMemo(()=>zn(),[]),M=K(X=>X.shortcutOverrides),B=K(X=>X.workStatusPanelVisible),T=K(X=>X.workStatusPanelEnabled),I=K(X=>X.setWorkStatusPanelEnabled),b=K(X=>X.workStatusPanelFits),w=K(X=>X.workStatusOverlayOpen),j=K(X=>X.setWorkStatusOverlayOpen),L=T&&b||w,E=c.useCallback(()=>{if(T&&!b){j(!w);return}I(!T)},[j,I,w,T,b]),D=i?u??null:null,U=c.useRef(null),[V,J]=c.useState(0);c.useEffect(()=>{if(!i){U.current&&(U.current=null,J($t=>$t+1));return}if(D){U.current={sessionId:i,session:D,expiresAt:Date.now()+2e3};return}const X=U.current;if(!X||X.sessionId!==i)return;const mt=X.expiresAt-Date.now();if(mt<=0){U.current=null,J($t=>$t+1);return}const jt=window.setTimeout(()=>{U.current?.sessionId===i&&(U.current=null),J($t=>$t+1)},mt);return()=>{window.clearTimeout(jt)}},[i,D]);const W=(()=>{if(D)return D;if(!i)return null;const X=U.current;return X&&X.sessionId===i&&X.expiresAt>Date.now()?X.session:null})(),G=it(X=>i?X.worktreeMetadata.get(i)?.path??"":""),le=it(X=>i?X.worktreeMetadata.get(i)?.branch?.trim()??null:null),$=ed(X=>i?X.getAttachment(i):void 0),re=c.useMemo(()=>$?wh($,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,$]),H=c.useMemo(()=>$?$.legacy?"legacy":$.degraded?"degraded":$.worktreeStatus==="pending"?"pending":$.worktreeStatus==="missing"?"missing":$.worktreeStatus==="invalid"?"invalid":$.attentionReason?"attention":null:null,[$]),P=c.useMemo(()=>qn(G||""),[G]),ee=c.useMemo(()=>{const X=typeof W?.directory=="string"?W.directory:"";return qn(X||"")},[W?.directory]),oe=Oc(i??"",ee),de=it(X=>X.newSessionDraft?.open?qn(X.newSessionDraft.bootstrapPendingDirectory??X.newSessionDraft.directoryOverride??""):""),he=it(X=>X.newSessionDraft.target),Z=it(X=>X.newSessionDraft.selectedProjectId),ce=it(X=>X.currentSessionDirectory),ae=qt(X=>X.homeDirectory),te=Pr(),pe=c.useMemo(()=>P||ee||(So(te,de)??""),[de,te,ee,P]),Te=it(X=>{const mt=qn(P||ee||"");if(!mt)return null;for(const jt of X.availableWorktreesByProject.values()){const Q=so(jt,mt)?.branch?.trim();if(Q)return Q}return null}),Pe=yh(pe||null)||le||Te,ze=a?he==="chat":vc(ee||ce,ae),Oe=!ze&&!B&&!!(l||Pe||!a&&H),me=c.useMemo(()=>{if(!i)return l??"OpenChamber";const X=W?.title?.trim();return X&&X.length>0?X:"Untitled Session"},[l,W?.title,i]),be=it(X=>X.updateSessionTitle),Ce=it(X=>X.archiveSessions),$e=it(X=>X.deleteSessions),[We,_e]=c.useState(false),[Ue,Xe]=c.useState(false),Me=c.useRef(null),[ot,ye]=c.useState(""),[Ve,lt]=c.useState(null),ct=Tp(),[st,k]=c.useState(null),Y=os(X=>st&&X.entityById.get(st)?.title?.trim()||null)??t("sessions.sidebar.session.untitled"),Ne=c.useRef(null),Re=c.useRef(false);Re.current=We;const Ie=c.useCallback(()=>{i&&(Re.current=true,ye(W?.title?.trim()||me),_e(true))},[W?.title,i,me]),Ee=c.useRef(Ie);Ee.current=Ie;const Ge=c.useCallback(X=>{X&&(X.focus(),X.select())},[]);c.useEffect(()=>{if(Xe(false),k(null),i&&Me.current===i){Me.current=null,Ee.current();return}_e(false),ye("")},[i]);const Be=c.useCallback(async()=>{if(!i)return;const X=ot.trim();X&&X!==W?.title?.trim()&&await be(i,X),_e(false)},[W?.title,i,ot,be]);c.useEffect(()=>{if(!We)return;const X=mt=>{const jt=mt.target;(!jt||!Ne.current?.contains(jt))&&Be()};return document.addEventListener("mousedown",X),()=>document.removeEventListener("mousedown",X)},[We,Be]);const Ze=c.useCallback(async(X,mt)=>{const jt=[mt,...vh(mt,[],X==="delete")],$t=it.getState().currentSessionId===mt?mt:null;if(X==="delete"){const{failedIds:St}=await $e(jt);St.length>0?Fe.error(t("sessions.sidebar.session.delete.error")):Fe.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:Q,failedIds:tt}=await Ce(jt);if(tt.length>0){Fe.error(t("sessions.sidebar.session.archive.error"));return}Fe.success(t("sessions.sidebar.session.archive.success"),Sh(Q,$t,t))},[Ce,$e,t]),et=c.useCallback(async()=>{st&&(k(null),await Ze("delete",st))},[st,Ze]),wt=K(X=>X.openGuestPageId),Qe=cr(X=>X.guests.find(mt=>mt.id===wt)),dt=K(X=>X.isScheduledTasksDialogOpen),at=K(X=>X.isArchivePageOpen),z=K(X=>X.isIntegrationsCatalogOpen),fe=K(X=>X.isUsageStatsPageOpen),ke=K(X=>X.isSourceBoardOpen),ie=K(X=>X.isOverviewOpen),xe=K(X=>X.worktreesPageProjectId),Le=K(X=>X.isolatedSpacesEnabled?X.spacesPageProjectId:null),Ke=K(X=>X.runOverviewKey),ve=Cp(Ke),je=xe??Le,vt=Yt(X=>{if(!je)return null;const mt=X.projects.find(jt=>jt.id===je);return mt?.label?.trim()||mt?.path?.split("/").pop()||null}),ne=c.useMemo(()=>Qe?{title:Qe.pageTitle??Qe.name,subtitle:null}:dt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:at?{title:t("sessions.archivePage.title"),subtitle:null}:z?{title:t("integrationsCatalog.page.title"),subtitle:null}:fe?{title:t("usageStats.title"),subtitle:null}:ke?{title:t("sourceBoard.title"),subtitle:null}:ie?{title:t("overview.title"),subtitle:null}:xe?{title:t("sessions.worktreesPage.title",{project:vt??""}),subtitle:null}:Le?{title:t("spaces.page.title",{project:vt??""}),subtitle:null}:Ke?{title:ve??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[Qe,at,z,ve,Ke,dt,ke,ie,fe,Le,vt,t,xe]),Je=c.useCallback(()=>{on("desktop_open_draft_mini_chat_window",{directory:ze?"":de,projectId:ze?null:Z,...ca()}).catch(X=>{console.warn("[header] failed to open draft mini chat window",X)})},[de,Z,ze]),kt=c.useCallback(()=>{if(a){Je();return}i&&on("desktop_open_session_mini_chat_window",{sessionId:i,directory:ee||qn(ce||"")||P,...ca()}).catch(X=>{console.warn("[header] failed to open session mini chat window",X)})},[i,Je,a,ce,ee,P]),bt=x&&(a||!!i),_t=Kn,He=c.useMemo(()=>p&&C&&!v?"88px":g?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!p||S)&&!_?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[p,v,C,g,_,S]),pt=(!p||S)&&!_?"calc(0.625rem + var(--oc-wco-right-inset, 0px))":"0.625rem",q=e==="rtl",se=q?pt:He,De=q?He:pt,we=S&&N!==kc(e);Kt.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",se)},[se]);const rt=s?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",ft=s?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";Kt.useEffect(()=>{if(!p||!C){y(false);return}let X=false;const mt=async()=>{try{const $t=await on("desktop_is_window_fullscreen");X||y($t===true)}catch{X||y(false)}},jt=()=>{mt()};return mt(),window.addEventListener("openchamber:window-resized",jt),()=>{X=true,window.removeEventListener("openchamber:window-resized",jt)}},[p,C]);const nt=c.useMemo(()=>!p||!C||F===null?"":F>=26?"h-11":F<=15?"h-14":"",[p,C,F]),ut=c.useMemo(()=>p&&C&&!v?F!==null&&F<=15?"56px":"44px":"0px",[p,v,C,F]),Nt=c.useMemo(()=>{const mt=`max(${p&&C?"2.75rem":"3rem"}, ${ut}, var(--oc-wco-titlebar-height, 0px))`,jt=p&&!S||_;if(jt&&ut==="0px")return{};const $t={minHeight:mt,height:mt};return!we&&(!jt||q)&&($t.paddingInlineEnd=De),$t},[we,p,C,q,_,De,ut,S]),Et=c.useRef(null),Ft=c.useCallback(X=>{!X||X===Et.current||(Et.current=X,document.documentElement.style.setProperty("--oc-header-height",`${X}px`))},[]),Wt=c.useCallback(()=>{typeof document>"u"||Ft(m.current?.getBoundingClientRect().height)},[Ft]);Kt.useEffect(()=>{if(typeof window>"u")return;Wt();const X=m.current;if(!X||typeof ResizeObserver>"u")return()=>{};let mt=0;const jt=()=>{mt||(mt=requestAnimationFrame(()=>{mt=0,Wt()}))},$t=new ResizeObserver(Q=>{const tt=Q[Q.length-1];Ft(tt?.borderBoxSize?.[0]?.blockSize??tt?.target.getBoundingClientRect().height)});return $t.observe(X),window.addEventListener("resize",jt),window.addEventListener("orientationchange",jt),()=>{mt&&cancelAnimationFrame(mt),$t.disconnect(),window.removeEventListener("resize",jt),window.removeEventListener("orientationchange",jt)}},[Ft,Wt]),Kt.useEffect(()=>{Wt()},[Wt,f,nt]);const is=c.useCallback(async X=>{const mt=X.target;mt.closest(".app-region-no-drag")||mt.closest("button, a, input, select, textarea")||X.button===0&&p&&await vf()},[p]);td({rename_current_session:()=>{if(!i||f)return false;Ie()},archive_current_session:()=>{if(!i||f||os.getState().entityById.get(i)?.time.archived)return false;Ze("archive",i)}});const Gt=c.useCallback((X,mt)=>{lt({sessionId:X,directory:mt})},[]),ns=ct.requestExport,ms=c.useCallback(({session:X,open:mt,isActive:jt,select:$t,closeOtherTabs:Q,components:tt})=>{const{Item:St,Separator:Tt}=tt;return n.jsxs(n.Fragment,{children:[n.jsx(Ep,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:n.jsxs(St,{onClick:Q,className:"[&>svg]:me-1",children:[n.jsx(ue,{name:"close-circle",className:"me-1 h-4 w-4"}),t("header.sessionTabs.closeOtherTabs")]})}),n.jsx(Tt,{}),n.jsx(il,{sessionId:X.id,open:mt,slots:tt,onRename:()=>{jt||$t(),Me.current=X.id},onExport:ns,onMoveSession:Gt,onArchive:()=>{Ze("archive",X.id)},onDelete:()=>k(X.id)})]})},[ns,Gt,Ze,t]),Ns=()=>n.jsxs("div",{onMouseDown:is,className:Ye("app-region-drag relative flex h-12 select-none items-center",we?"pe-0":"pe-2.5",nt),style:Nt,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[n.jsx("div",{"aria-hidden":true,className:"shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:rt,transitionDuration:`${r}ms`,transitionTimingFunction:Mn}}),n.jsx("div",{ref:ru,"aria-hidden":true,className:"app-region-no-drag shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:ft,transitionDuration:`${r}ms`,transitionTimingFunction:Mn}}),n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[ne?n.jsxs(n.Fragment,{children:[n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{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:()=>K.getState().closeMainSurfaces(),children:n.jsx(ue,{name:"arrow-left",className:"size-4"})})}),n.jsx(Dt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),n.jsxs("div",{className:"me-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-start",children:[n.jsx("span",{className:"truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:ne.title}),ne.subtitle?n.jsx("span",{className:"truncate typography-micro text-[0.65625rem] font-normal leading-tight text-muted-foreground max-w-full",children:ne.subtitle}):null]})]}):_||!o?n.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:[oe?n.jsx(ue,{name:"loader-4",className:"me-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,s?null:n.jsxs(Rt,{children:[n.jsx(Qx,{align:"start",children:n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",className:_t,"aria-label":t("sessions.switcher.openAria"),children:n.jsx(ue,{name:"history",className:"h-4 w-4"})})})}),n.jsx(Dt,{side:"bottom",children:n.jsx(qs,{label:t("sessions.switcher.openAria"),shortcut:bs(Es("open_session_list",M),"")})})]}),n.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[We?n.jsxs("form",{ref:Ne,"data-session-rename-form":"header",className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:X=>X.stopPropagation(),onSubmit:X=>{X.preventDefault(),Be()},children:[n.jsx("input",{ref:Ge,value:ot,onChange:X=>ye(X.target.value),onKeyDown:X=>Ai(X,()=>_e(false)),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"}),n.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:n.jsx(ue,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>_e(false),"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:n.jsx(ue,{name:"close",className:"size-4"})})]}):a?null:n.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:me}),Oe?n.jsxs("span",{className:Ye("flex min-w-0 max-w-full items-center gap-1.5 truncate font-normal leading-tight",a?"typography-ui-label text-[0.875rem] text-foreground":"typography-micro text-[0.65625rem] text-muted-foreground"),children:[l?n.jsx("span",{dir:"auto",className:"truncate",children:l}):null,Pe?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx(ue,{name:"git-branch",className:Ye("flex-shrink-0 text-muted-foreground",a?"h-3.5 w-3.5":"h-3 w-3")}),n.jsx("span",{dir:"ltr",className:Ye("truncate",a&&"text-muted-foreground"),children:Pe})]}):null,!a&&H?n.jsxs("span",{className:Ye("inline-flex min-w-0 items-center gap-0.5",H==="attention"||H==="invalid"||H==="missing"?"text-status-warning":"text-muted-foreground"),children:[n.jsx(ue,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"truncate",children:re})]}):null]}):null]}),n.jsx("div",{className:Ye("flex h-[1.125rem] shrink-0 items-center justify-center",Oe?"self-start":"self-center"),children:i&&!a&&!We?n.jsxs(Sn,{open:Ue,onOpenChange:Xe,onOpenChangeComplete:X=>{!X&&Me.current&&Me.current===i&&(Me.current=null,Ie())},children:[n.jsx(kn,{asChild:true,children:n.jsx(yt,{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:n.jsx(ue,{name:"more",className:"size-4"})})}),n.jsx(jn,{align:"end",className:"min-w-[190px]",children:n.jsx(il,{sessionId:i,open:Ue,slots:Ip,onRename:()=>{Me.current=i},onExport:ns,onMoveSession:Gt,onArchive:()=>{Ze("archive",i)},onDelete:()=>k(i)})})]}):null})]}):n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-start",children:n.jsx(Eb,{renderMenu:ms,suppressActiveTabControls:We,menuReturnsFocus:()=>!Re.current,onMenuOpenChangeComplete:X=>{!X&&Me.current&&Me.current===i&&(Me.current=null,Ie())},children:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:We?n.jsxs("form",{ref:Ne,"data-session-rename-form":"header",className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:X=>X.stopPropagation(),onSubmit:X=>{X.preventDefault(),Be()},children:[n.jsx("input",{ref:Ge,value:ot,onChange:X=>ye(X.target.value),onKeyDown:X=>Ai(X,()=>_e(false)),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"}),n.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:n.jsx(ue,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>_e(false),"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:n.jsx(ue,{name:"close",className:"size-4"})})]}):n.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:a?t("sessions.switcher.draftTitle"):me})})})}),ne||_||!o?n.jsx("div",{className:"flex-1"}):null,n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!_&&!ne?n.jsxs(n.Fragment,{children:[n.jsx(pw,{buttonClassName:Kn}),n.jsx(Pw,{buttonClassName:Kn})]}):null,bt?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button","aria-label":t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:kt,className:Kn,children:n.jsx(ue,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),n.jsx(Dt,{side:"bottom",children:n.jsx(qs,{label:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),shortcut:a?bs(Es("new_mini_chat",M),""):void 0})})]}):null,_?null:n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":L,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:E,className:Ye(Kn,L&&"oc-selected text-interactive-selection-foreground hover:text-interactive-selection-foreground"),children:n.jsx(ue,{name:"panel-card",className:"h-4 w-4"})})}),n.jsx(Dt,{side:"bottom",children:t(T&&!b?w?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":T?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),n.jsx(Ud,{visible:we,position:N})]})]})]});return n.jsxs(n.Fragment,{children:[n.jsx("header",{ref:m,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:Ns()}),Ve?n.jsx(kh,{open:true,onOpenChange:X=>{X||lt(null)},sessionId:Ve.sessionId,sourceDirectory:Ve.directory}):null,ct.dialog,n.jsx(dr,{open:st!==null,onOpenChange:X=>{X||k(null)},children:n.jsxs(ur,{showCloseButton:false,className:"max-w-sm gap-5",children:[n.jsxs(fr,{children:[n.jsx(pr,{children:t("sessions.sidebar.dialogs.deleteSession.title")}),n.jsx(mr,{children:t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Y})})]}),n.jsxs(no,{children:[n.jsx(yt,{variant:"outline",size:"sm",onClick:()=>k(null),children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(yt,{variant:"destructive",size:"sm",onClick:()=>{et()},children:t("sessions.sidebar.bulkActions.delete")})]})]})})]})},ul=280,fl=264,pl=500,Ow=({isOpen:t,isMobile:e,children:s,className:r,topBar:o,peek:a})=>{const{t:i,direction:u}=gt(),d=K(W=>W.sidebarWidth),l=K(W=>W.setSidebarWidth),[f,m]=c.useState(false),p=c.useRef(0),h=c.useRef(d||ul),x=c.useRef(null),g=c.useRef(null),v=c.useRef(null),y=c.useRef(null),C=c.useRef(null),S=c.useCallback(W=>Math.min(pl,Math.max(fl,W)),[]),N=c.useCallback(()=>{const W=C.current;if(W?.isConnected)return W;const G=document.querySelector("[data-titlebar-left-controls]");return C.current=G,G},[]),F=c.useCallback(W=>{const G=y.current;if(!G)return;G.style.width=`${W}px`,G.style.minWidth=`${W}px`,G.style.maxWidth=`${W}px`,G.style.setProperty("--oc-left-sidebar-width",`${W}px`);const le=N();le&&le.style.setProperty("--oc-left-sidebar-width",`${W}px`)},[N]);c.useEffect(()=>{e&&f&&m(false)},[e,f]),c.useEffect(()=>{f||(x.current=null,g.current=null,v.current?.(),v.current=null)},[f]),c.useEffect(()=>{!t&&f&&m(false)},[t,f]),c.useEffect(()=>()=>{v.current?.(),v.current=null},[]);const _=Math.min(pl,Math.max(fl,d||ul)),M=t?_:0,B=f?x.current??M:M,T=f?B:_;c.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${T}px`);const W=C.current;!f&&W&&W.style.removeProperty("--oc-left-sidebar-width")},[T,f]);const[I,b]=c.useState(!t);t&&I&&b(false);const w=vo(),j=c.useRef(t),R=c.useRef(t);if(c.useLayoutEffect(()=>{j.current=t,R.current!==t&&(R.current=t,sd(w),t||hr(()=>{j.current||b(true)}))},[t,w]),e)return null;const L=W=>{if(t){try{W.currentTarget.setPointerCapture(W.pointerId)}catch{}g.current=W.pointerId,m(true),p.current=W.clientX,h.current=M,x.current=M,F(M),v.current?.(),v.current=nd(),W.preventDefault()}},E=W=>{if(e||!f||g.current!==W.pointerId)return;const G=(W.clientX-p.current)*(u==="rtl"?-1:1),le=S(h.current+G);x.current!==le&&(x.current=le,F(le))},D=W=>{if(g.current!==W.pointerId||e)return;try{W.currentTarget.releasePointerCapture(W.pointerId)}catch{}const G=S(x.current??M);g.current=null,x.current=null,m(false),l(G),v.current?.(),v.current=null},U=!t&&a?a.state:false,V=U!==false,J=V&&a&&a.animationMs>0?`${U==="in"?"oc-sidebar-peek-in":"oc-sidebar-peek-out"} ${a.animationMs}ms ${Mn} forwards`:void 0;return n.jsxs("div",{ref:y,"data-left-sidebar":"",className:Ye("relative flex h-full",!V&&"overflow-hidden",f?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",r),style:{width:`${B}px`,minWidth:`${B}px`,maxWidth:`${B}px`,"--oc-left-sidebar-width":`${T}px`,overflowX:V?void 0:"clip",transitionDuration:`${w}ms`,transitionTimingFunction:Mn},children:[t&&n.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&&n.jsx("div",{className:Ye("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:L,onPointerMove:E,onPointerUp:D,onPointerCancel:D,onLostPointerCapture:D,role:"separator","aria-orientation":"vertical","aria-label":i("sidebar.resize.leftPanelAria")}),n.jsxs("aside",{ref:a?.overlayRef,"data-sidebar-peek":V?U:void 0,className:Ye("flex h-full shrink-0 flex-col",V?"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&&!V&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${w}ms`,overflowX:"hidden",contentVisibility:I&&!V?"hidden":void 0,animation:J,"--oc-peek-offset":u==="rtl"?"100%":"-100%"},inert:!t&&!V||void 0,onPointerEnter:V?a?.overlayHandlers.onPointerEnter:void 0,onPointerLeave:V?a?.overlayHandlers.onPointerLeave:void 0,onAnimationEnd:V?a?.overlayHandlers.onAnimationEnd:void 0,children:[o,n.jsx(ps,{outerClassName:"overlay-scrollbar-wrapper--no-gutter flex-1 min-h-0",disableHorizontal:true,children:n.jsx(Jt,{children:s})})]})]})},Mw=t=>{const e=qe.c(5),{actionsSlotRef:s}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={height:"var(--oc-header-height, 3rem)"},e[0]=r):r=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{"aria-hidden":true,className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-start-inset, 0.75rem)"}}),e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{"aria-hidden":true,ref:ru,className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),e[2]=a):a=e[2];let i;return e[3]!==s?(i=n.jsxs("div",{className:"flex shrink-0",style:r,children:[o,a,n.jsx("div",{className:"app-region-drag flex min-w-0 flex-1 items-center justify-end",children:n.jsx("div",{ref:s,className:"app-region-no-drag flex items-center"})})]}),e[3]=s,e[4]=i):i=e[4],i},Fw=50,Lw=18,$w=300,Bw='[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]',ou=t=>!document.getElementById("root")?.contains(t),zw=t=>{if((mo(document.documentElement)?window.innerWidth-t.clientX:t.clientX)>Lw)return false;const s=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--oc-header-height"))||48;return t.clientY>=s},ml=t=>{const e=document.activeElement;return t&&e instanceof HTMLElement&&t.contains(e)&&(e.isContentEditable||e.matches("input, textarea"))?true:Array.from(document.querySelectorAll(Bw)).some(s=>ou(s)&&s.getClientRects().length>0)},Ww=({enabled:t,layoutAnimationMs:e})=>{const[s,r]=c.useState(false),o=jh()?0:e,a=o>0,i=c.useRef(null),u=c.useRef(null),d=c.useRef(null),l=c.useCallback(()=>{u.current!==null&&clearTimeout(u.current),d.current!==null&&clearTimeout(d.current),u.current=null,d.current=null},[]),f=c.useCallback(()=>{l(),r(x=>x==="in"&&a?"out":false)},[a,l]),m=c.useCallback(()=>{d.current!==null&&clearTimeout(d.current),d.current=setTimeout(()=>{if(d.current=null,ml(i.current)){m();return}f()},$w)},[f]),p=c.useCallback(()=>{d.current!==null&&clearTimeout(d.current),d.current=null},[]);c.useEffect(()=>{t||(l(),r(false))},[l,t]),c.useEffect(()=>l,[l]),c.useEffect(()=>{if(s!=="in")return;const x=y=>{const C=y.target;C instanceof Element&&(i.current?.contains(C)||ou(C)||f())},g=y=>{rd(y)||y.key!=="Escape"||y.defaultPrevented||ml(i.current)||f()},v=y=>{y.relatedTarget===null&&m()};return document.addEventListener("pointerdown",x,true),document.addEventListener("keydown",g),document.addEventListener("pointerout",v),()=>{document.removeEventListener("pointerdown",x,true),document.removeEventListener("keydown",g),document.removeEventListener("pointerout",v)}},[f,m,s]),c.useEffect(()=>{if(!t||s!==false)return;const x=()=>{u.current!==null&&clearTimeout(u.current),u.current=null},g=y=>{if(y.pointerType!=="mouse"||y.buttons!==0||!zw(y)){x();return}u.current===null&&(u.current=setTimeout(()=>{u.current=null,r("in")},Fw))},v=y=>{y.relatedTarget===null&&x()};return document.addEventListener("pointermove",g,{passive:true}),document.addEventListener("pointerout",v),()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerout",v),x()}},[t,s]);const h=c.useMemo(()=>({onPointerEnter:()=>{p(),r(x=>x==="out"?"in":x)},onPointerLeave:()=>{s==="in"&&m()},onAnimationEnd:x=>{x.target===x.currentTarget&&r(g=>g==="out"?false:g)}}),[p,m,s]);return{state:t?s:false,animationMs:o,overlayRef:i,overlayHandlers:h}},Xo="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",Vw=()=>{const t=qe.c(46),{t:e,locale:s,direction:r}=gt(),o=K(Uw),a=K(Hw),i=K(Kw),u=c.useRef(null),d=bs(Es("toggle_sidebar",i)),l=qw,f=K(Gw),{usesFramelessChrome:m,side:p}=Vd();let h;t[0]!==s?(h=G=>{const le=G.currentTarget.getBoundingClientRect();on("desktop_show_app_menu",{x:le.left,y:le.bottom,locale:s}).catch(Zw)},t[0]=s,t[1]=h):h=t[1];const x=h;let g,v;t[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{if(typeof document>"u")return;const G=u.current;if(!G)return;const le=()=>{const re=Math.max(G.getBoundingClientRect().width,G.scrollWidth);_w(re)};if(le(),typeof ResizeObserver>"u")return;const $=new ResizeObserver(le);return $.observe(G),()=>{$.disconnect()}},v=[],t[2]=g,t[3]=v):(g=t[2],v=t[3]),c.useEffect(g,v);const y="",C="app-region-no-drag absolute inset-s-0 top-0 z-30 flex select-none items-center pe-2",S=a?"var(--oc-left-sidebar-width, 100%)":void 0;let N;t[4]!==S?(N={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:S},t[4]=S,t[5]=N):N=t[5];const F="flex min-w-0 items-center gap-2";let _;t[6]!==r||t[7]!==m||t[8]!==p?(_=m&&p===kc(r)?n.jsx(Ud,{visible:true,position:p}):null,t[6]=r,t[7]=m,t[8]=p,t[9]=_):_=t[9];let M;t[10]!==x||t[11]!==e||t[12]!==m?(M=m?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:x,"aria-label":e("header.actions.openAppMenuAria"),className:Ye(Xo,"shrink-0"),children:n.jsx(ue,{name:"menu-2",className:"h-4 w-4"})})}),n.jsx(Dt,{children:n.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=x,t[11]=e,t[12]=m,t[13]=M):M=t[13];const B=Rt;let T;t[14]!==e?(T=e("header.actions.openSessionsAria"),t[14]=e,t[15]=T):T=t[15];const I=a&&"text-foreground";let b;t[16]!==I?(b=Ye(Xo,"shrink-0",I),t[16]=I,t[17]=b):b=t[17];let w;t[18]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(ue,{name:"panel-left",className:"h-4 w-4"}),t[18]=w):w=t[18];let j;t[19]!==a||t[20]!==T||t[21]!==b||t[22]!==o?(j=n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":T,"aria-pressed":a,className:b,children:w})}),t[19]=a,t[20]=T,t[21]=b,t[22]=o,t[23]=j):j=t[23];const R=Dt,L=e("header.actions.openSessionsWithShortcut",{shortcut:d});let E;t[24]!==L?(E=n.jsx("p",{children:L}),t[24]=L,t[25]=E):E=t[25];let D;t[26]!==R||t[27]!==E?(D=n.jsx(R,{children:E}),t[26]=R,t[27]=E,t[28]=D):D=t[28];let U;t[29]!==B||t[30]!==j||t[31]!==D?(U=n.jsxs(B,{children:[j,D]}),t[29]=B,t[30]=j,t[31]=D,t[32]=U):U=t[32];let V;t[33]!==l||t[34]!==i||t[35]!==e||t[36]!==f?(V=f?null:n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:l,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Ye(Xo,"-ms-1 shrink-0"),children:n.jsx(ue,{name:"edit-box",className:"h-4 w-4"})})}),n.jsx(Dt,{children:n.jsx(qs,{label:e("sessions.sidebar.header.actions.newSession"),shortcut:bs(Es("new_chat",i),"")})})]}),t[33]=l,t[34]=i,t[35]=e,t[36]=f,t[37]=V):V=t[37];let J;t[38]!==U||t[39]!==V||t[40]!==_||t[41]!==M?(J=n.jsxs("div",{ref:u,className:F,children:[_,M,U,V]}),t[38]=U,t[39]=V,t[40]=_,t[41]=M,t[42]=J):J=t[42];let W;return t[43]!==J||t[44]!==N?(W=n.jsx("div",{"data-titlebar-left-controls":y,className:C,style:N,children:J}),t[43]=J,t[44]=N,t[45]=W):W=t[45],W};function Uw(t){return t.toggleSidebar}function Hw(t){return t.isSidebarOpen}function Kw(t){return t.shortcutOverrides}function qw(){K.getState().closeMainSurfaces(),it.getState().openNewSessionDraft()}function Gw(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 Zw(t){console.warn("[titlebar] failed to open app menu",t)}function Xw(){const t=qe.c(2),e=Th();let s;return t[0]!==e?(s=n.jsx("div",{className:"h-full min-h-0 overflow-y-auto",children:n.jsx(Np,{onOpen:(r,o)=>e(r.receivedId,o)})}),t[0]=e,t[1]=s):s=t[1],s}function Yw(t,e,s){const r=qe.c(5),[o,a]=c.useState();let i,u;return r[0]!==s||r[1]!==t||r[2]!==e?(i=()=>{if(e){a(void 0);return}if(!t){a(void 0);return}a(void 0);let d=false;return(async()=>{const[l,f]=await Promise.all([Ch(t),Eh(t)]).catch(Jw);if(d)return;const m=ts(l),p=ts(f);if(!m||!p||p===m)return;const h=s||"",x=p.split("/").filter(Boolean).pop()||p;a({source:"sdk",path:p,projectDirectory:m,branch:h,label:h||x,name:x,worktreeRoot:p,worktreeStatus:"ready",headState:h?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=true}},u=[t,e,s],r[0]=s,r[1]=t,r[2]=e,r[3]=i,r[4]=u):(i=r[3],u=r[4]),c.useEffect(i,u),e??o}function Jw(){return["",""]}const Qw=()=>{const t=qe.c(3),e=K(ey),s=K(ty);let r;return t[0]!==e||t[1]!==s?(r=()=>{s("integrations"),e(true)},t[0]=e,t[1]=s,t[2]=r):r=t[2],r};function ey(t){return t.setSettingsDialogOpen}function ty(t){return t.setSettingsPage}const hl="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-edge bg-muted/80",sy=({className:t,identity:e})=>{const{t:s}=gt(),{sourceControl:r}=Is(),o=Ih(e),a=Wa(e.provider),i=a.label,u=o?.status??null,d=vn(y=>y.setStatus),[l,f]=c.useState(false),m=c.useCallback(async y=>{if(!(!y||l)){f(true);try{d(e,await r.authActivate(e,y))}catch(C){console.error("Failed to switch source control account:",C)}finally{f(false)}}},[e,l,d,r]);if(u?.status!=="connected")return null;const p=u.user.username||null,h=u.user.avatarUrl??null,x=u.accounts,g=p?s("header.sourceControl.connectedWithLogin",{login:p,provider:i}):s("header.sourceControl.connected",{provider:i}),v=h?n.jsx("img",{src:h,alt:p?s("header.sourceControl.avatarWithLogin",{login:p}):s("header.sourceControl.avatar",{provider:i}),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx(zi,{descriptor:a,variant:"fill",className:"h-3.5 w-3.5 text-foreground"});return x.length<=1?n.jsx("div",{className:Ye(hl,t),title:g,children:v}):n.jsxs(Sn,{children:[n.jsx(kn,{asChild:true,children:n.jsx("button",{type:"button",className:Ye(hl,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:g,disabled:l,children:v})}),n.jsxs(jn,{align:"end",className:"w-64",children:[n.jsx(Hr,{className:"typography-ui-header font-semibold text-foreground",children:s("header.sourceControl.accountsTitle",{provider:i})}),n.jsx(tr,{}),x.map(y=>{const C=y.user,S=!!y.current,N=s(Nh(y.source??"oauth"));return n.jsxs(Ks,{className:"gap-2",disabled:l,onSelect:()=>{S||m(y.id)},children:[C?.avatarUrl?n.jsx("img",{src:C.avatarUrl,alt:C.username?s("header.sourceControl.avatarWithLogin",{login:C.username}):s("header.sourceControl.avatar",{provider:i}),className:"h-6 w-6 rounded-full border border-edge bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-edge bg-muted",children:n.jsx(zi,{descriptor:a,variant:"fill",className:"h-3 w-3 text-muted-foreground"})}),n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:C?.name?.trim()||C.username||a.label}),C.username?n.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[n.jsx("span",{className:"font-mono",children:C.username}),n.jsx("span",{className:"mx-1 opacity-50",children:"\xB7"}),n.jsx("span",{children:N})]}):null]}),S?n.jsx(ue,{name:"check",className:"h-4 w-4 text-primary"}):null]},y.id)})]})]})},ny=t=>JSON.stringify(Ph(t)),ry=async(t,e)=>{const s=await t.projectUpstream(e);if(!s?.isFork||!s.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,s.upstream.owner,s.upstream.name);return{upstream:s.upstream,branches:r}},au=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function oy(t){if(!au(t.error)||!t.isCurrent())return false;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),true}function ay(t,e,s){const r=qe.c(18),{sourceControl:o}=Is(),a=Wa(t.provider).features.referenceSearch,[i,u]=Kt.useState(null);let d;r[0]!==t.bindingRevision||r[1]!==t.provider||r[2]!==t.repositoryId||r[3]!==e?(d=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]=d):d=r[4];const l=d;let f;r[5]!==t||r[6]!==l||r[7]!==e||r[8]!==a||r[9]!==o?(f=()=>{if(!a)return;let p=false;return o.references(t,{kind:"pull",query:`#${e}`}).then(h=>{if(p||!h.connected)return;const x=h.items.find(g=>g.kind==="pull"&&g.number===e);x&&u({key:l,pull:x})}).catch(iy),()=>{p=true}},r[5]=t,r[6]=l,r[7]=e,r[8]=a,r[9]=o,r[10]=f):f=r[10];let m;return r[11]!==t||r[12]!==l||r[13]!==e||r[14]!==s||r[15]!==a||r[16]!==o?(m=[t,l,e,s,a,o],r[11]=t,r[12]=l,r[13]=e,r[14]=s,r[15]=a,r[16]=o,r[17]=m):m=r[17],Kt.useEffect(f,m),i?.key===l?i.pull:null}function iy(){}const ly=t=>{const e=qe.c(99),{directory:s,context:r,changeRequest:o,onChanged:a,statusStack:i}=t,{sourceControl:u}=Is(),d=Zs(),l=Yt(cy),[f,m]=Kt.useState(0),[p,h]=Kt.useState(false),x=Xa(),g=ay(r,o.number,f);let v;e[0]!==o?(v=Rh(o),e[0]=o,e[1]=v):v=e[1];const y=v;let C;e[2]!==g||e[3]!==y?(C=g?{...y,labels:g.labels,commentCount:g.commentCount}:y,e[2]=g,e[3]=y,e[4]=C):C=e[4];const S=C,[N,F]=Kt.useState(null),_=N?.number===o.number?N.sha:null,{detail:M,latest:B,refresh:T}=od(s,S,true,_),I=B.status==="ready"?B.value.pull:null,b=Mc(S);let w;e[5]!==a||e[6]!==T?(w=()=>{T(),m(dy),a()},e[5]=a,e[6]=T,e[7]=w):w=e[7];const j=w,R=Fc(S,r,j);let L;e[8]!==r||e[9]!==a||e[10]!==S.number||e[11]!==S.sourceRepo.owner||e[12]!==S.sourceRepo.repo||e[13]!==T||e[14]!==u?(L=async()=>{const Ve={owner:S.sourceRepo.owner,repo:S.sourceRepo.repo,number:S.number};await u.refreshProviderReads(r,{item:Ve}).catch(uy),ad(Ve),m(fy),await Promise.all([T(),a()])},e[8]=r,e[9]=a,e[10]=S.number,e[11]=S.sourceRepo.owner,e[12]=S.sourceRepo.repo,e[13]=T,e[14]=u,e[15]=L):L=e[15];const E=L;let D;e[16]!==S?(D={source:"repository",reference:S},e[16]=S,e[17]=D):D=e[17];const U=D,V=d??s;let J;e[18]!==M||e[19]!==i?(J=M.status==="ready"&&M.value.pull&&M.value.pull.stack===void 0&&i!==void 0?{status:"ready",value:{...M.value,pull:{...M.value.pull,stack:i}}}:M,e[18]=M,e[19]=i,e[20]=J):J=e[20];const W=J,G=W.status==="ready"?W.value.pull?.stack??null:i??null,le=Ya(),$=Yt(py),re=it(my),H=Er($,re,s),[P,ee]=Kt.useState(false);let oe;e[21]===Symbol.for("react.memo_cache_sentinel")?(oe={status:"idle"},e[21]=oe):oe=e[21];const de=H?()=>ee(true):void 0,he=I?.submitRequirements,Z=B.status==="error",ce=o.mergeable??null;let ae;e[22]!==r||e[23]!==U||e[24]!==j||e[25]!==G||e[26]!==Z||e[27]!==ce||e[28]!==de||e[29]!==he?(ae=n.jsx(qa,{item:U,project:null,context:r,onStartWorktree:gy,onChanged:j,worktreeAvailable:false,stack:G,onStartOnTop:de,submitRequirements:he,submitRequirementsUnreadable:Z,mergeable:ce}),e[22]=r,e[23]=U,e[24]=j,e[25]=G,e[26]=Z,e[27]=ce,e[28]=de,e[29]=he,e[30]=ae):ae=e[30];let te;e[31]!==o.number||e[32]!==I||e[33]!==_?(te=I?.revisions?{revisions:I.revisions,selected:_,onSelect:Ve=>F(Ve?{number:o.number,sha:Ve}:null)}:void 0,e[31]=o.number,e[32]=I,e[33]=_,e[34]=te):te=e[34];let pe;e[35]!==s||e[36]!==le?(pe=Ve=>{le(Ve.url,s)},e[35]=s,e[36]=le,e[37]=pe):pe=e[37];let Te;e[38]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>h(true),e[38]=Te):Te=e[38];let Ae;e[39]!==r||e[40]!==U||e[41]!==S.state||e[42]!==j?(Ae=S.state!=="merged"?n.jsx(Lc,{item:U,context:r,onChanged:j}):void 0,e[39]=r,e[40]=U,e[41]=S.state,e[42]=j,e[43]=Ae):Ae=e[43];let Pe;e[44]!==b.attachComment||e[45]!==b.attachComments?(Pe={onAttach:b.attachComment,onAttachAll:b.attachComments},e[44]=b.attachComment,e[45]=b.attachComments,e[46]=Pe):Pe=e[46];let ze;e[47]!==r||e[48]!==S||e[49]!==j?(ze=n.jsx(zc,{reference:S,context:r,onChanged:j}),e[47]=r,e[48]=S,e[49]=j,e[50]=ze):ze=e[50];let Oe;e[51]!==r||e[52]!==M||e[53]!==S||e[54]!==j?(Oe=n.jsx(Wc,{pull:S,detail:M,context:r,onChanged:j}),e[51]=r,e[52]=M,e[53]=S,e[54]=j,e[55]=Oe):Oe=e[55];const me=I?.voteLabels;let be;e[56]!==I?.revisions?(be=I?.revisions?.at(-1)?.sha,e[56]=I?.revisions,e[57]=be):be=e[57];const Ce=_===null;let $e;e[58]!==r||e[59]!==S||e[60]!==j||e[61]!==me||e[62]!==be||e[63]!==Ce?($e=n.jsx($c,{reference:S,context:r,onRefresh:j,voteLabels:me,latestRevision:be,onLatestRevision:Ce},S.number),e[58]=r,e[59]=S,e[60]=j,e[61]=me,e[62]=be,e[63]=Ce,e[64]=$e):$e=e[64];const We=l??"";let _e;e[65]!==V||e[66]!==We?(_e={id:We,path:V},e[65]=V,e[66]=We,e[67]=_e):_e=e[67];let Ue;e[68]!==r||e[69]!==V||e[70]!==S||e[71]!==_||e[72]!==_e?(Ue=n.jsx(Vc,{pull:S,project:_e,repository:null,context:r,projectOwnsDirectory:xy,currentDirectory:V,revision:_}),e[68]=r,e[69]=V,e[70]=S,e[71]=_,e[72]=_e,e[73]=Ue):Ue=e[73];let Xe;e[74]!==s||e[75]!==U||e[76]!==x||e[77]!==E||e[78]!==W||e[79]!==ae||e[80]!==te||e[81]!==pe||e[82]!==Ae||e[83]!==Pe||e[84]!==ze||e[85]!==Oe||e[86]!==$e||e[87]!==Ue||e[88]!==R?(Xe=n.jsx(Ja,{item:U,directory:s,pullStatus:Qa,trackerDetail:oe,repositoryDetail:W,purpose:"attach",pinned:true,includeDiff:false,onIncludeDiffChange:hy,now:x,footer:ae,revisionChoice:te,onOpenStackLayer:pe,onOpenChecks:Te,onRefresh:E,stateMenu:Ae,commentAttachments:Pe,threadActions:R,labelsControl:ze,reviewersControl:Oe,reply:$e,pullLinks:Ue}),e[74]=s,e[75]=U,e[76]=x,e[77]=E,e[78]=W,e[79]=ae,e[80]=te,e[81]=pe,e[82]=Ae,e[83]=Pe,e[84]=ze,e[85]=Oe,e[86]=$e,e[87]=Ue,e[88]=R,e[89]=Xe):Xe=e[89];let Me;e[90]!==b.attachFailedChecks||e[91]!==p||e[92]!==r||e[93]!==S?(Me=n.jsx(Bc,{pull:S,context:r,open:p,onOpenChange:h,onAttachFailed:b.attachFailedChecks}),e[90]=b.attachFailedChecks,e[91]=p,e[92]=r,e[93]=S,e[94]=Me):Me=e[94];const ot=H?n.jsx(Dh,{open:P,onOpenChange:ee,project:{id:H.id,path:ro(H.path)??H.path},initialSourceBranch:S.head,onWorktreeCreated:by}):null;let ye;return e[95]!==Xe||e[96]!==Me||e[97]!==ot?(ye=n.jsxs(n.Fragment,{children:[Xe,Me,ot]}),e[95]=Xe,e[96]=Me,e[97]=ot,e[98]=ye):ye=e[98],ye};function cy(t){return t.activeProjectId}function dy(t){return t+1}function uy(){}function fy(t){return t+1}function py(t){return t.projects}function my(t){return t.availableWorktreesByProject}function hy(){}function gy(){}function xy(){return true}function by(t){it.getState().openNewSessionDraft({directoryOverride:t,preserveDirectoryOverride:true})}const wy=/^Change-Id:\s*I[0-9a-f]{40}$/,yy=50,vy=t=>(t.replace(/\r\n/g,`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-CJl97ZjN.js","assets/vendor-react--VO_rL_p.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-BDLOJuy5.js","assets/katex.min-DklPh68d.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-C9tWdk0j.js","assets/vendor-zod-DV_WH382.js","assets/vendor-opencode-client-NJGkA1Ku.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-BWbKx7qU.css","assets/vendor-base-ui-CHqK1aDI.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-Bw3q1rnq.js","assets/vendor-tanstack-virtual-core-B4TJYmIq.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-CFvXza4M.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-iLtL-MFj.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/ReceivedPagePanel-CfXyzCii.js","assets/space-apply-j71ap5Rs.js","assets/ReceivedPagePanel-uDNKGwhp.css","assets/useGitCleanLine-BwAypcLn.js","assets/useBranchPullRequestRequest-DMiPjfPQ.js","assets/parseDiffFromFile-D28_u-uC.js","assets/computeVirtualFileMetrics-Bc_YiqAD.js","assets/themeResolver-DjCwdtoe.js","assets/vendor-pierre-theming-Dn546TCS.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-Cx5SgKlQ.js","assets/getFiletypeFromFileName-BgI9McTw.js","assets/pierreDiffTint-CLCzflgS.js","assets/ReviewCards-D7jBPhS_.js","assets/useInlineCommentController-Wnopn0Ar.js","assets/appThemeRegistry-C4Av1s90.js","assets/diffsHighlighter-CFc933Ip.js","assets/editorCodeMetrics-CNBjOGNA.js","assets/OfficeDocumentDiff-Csvxzve7.js","assets/document-attachments-CIZjaOGe.js","assets/vendor-fflate-DB4_FQr-.js","assets/documentClient-D-gfZAFK.js","assets/useRootScrollLock-DPhGk2Eu.js","assets/moveWorkspacePath-DibtVw_Q.js","assets/contextFileOpenGuard-D-HtBtn6.js","assets/install-request-CzRei4tp.js","assets/WalkthroughView-Dm4-RaV3.js","assets/ChangeRequestDiffUnavailable-kfarKKvU.js","assets/useDiffFindSurface-mA0rc6AR.js","assets/useWalkthroughReview-BrULG_dy.js","assets/useCallableModelProviders-aGFpVUZL.js","assets/useWholeFileComment-CQj6q_QX.js","assets/DiffView-CSSPNDYJ.js","assets/SubmoduleDiffSummary-CTqIH0Cp.js","assets/FilesView-D0FOaLpo.js","assets/flexokiTheme-CcqiI7j-.js","assets/vendor-codemirror-search-CWqbGraJ.js","assets/vendor-replit-codemirror-vim-DTiXsOdM.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useMarkdownLocalAssets-BjT607tF.js","assets/fileContentPoller-DRoVO_sh.js","assets/JsonTreeView-DQ6XLAW4.js","assets/useNextRenderData-CVFf78p9.js","assets/isFilePlainText-Bcn3vV6J.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/codeHighlight-Bmb7zcc2.js","assets/vendor-react-drawio-C6TkEvnS.js","assets/vendor-codemirror-lint-aq8IpR1c.js","assets/scheduledTasksApi-v463mt0u.js","assets/GuestPanelContent-BCxvKv4H.js","assets/SettingsWindow-D2K9vSYk.js","assets/SettingsView-UjifxDq7.js","assets/install-DY6TBn2e.js","assets/vendor-yaml-CE-D_49-.js","assets/vendor-qrcode-Cl8OheHW.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/SpaceRow-CsS43yrt.js","assets/AboutLogo-cbKkZDLU.js","assets/pageTitle-BT3-HFbv.js","assets/CommandPalette-D4bXVkJf.js","assets/HelpDialog-DjficTGt.js","assets/ProjectActionsDialog-C5q25ipO.js","assets/OpenCodeStatusDialog-DtnVfNI4.js","assets/RunOverview-BDblAbDp.js","assets/ScheduledTasksDialog-NDtZLq5t.js","assets/vendor-cron-parser-1X50-i0r.js","assets/vendor-luxon-BZ0puJYg.js","assets/date-time-DfmOsLQo.js","assets/ArchiveView-0QjF07oK.js","assets/useWorktreeArchiveActions-CpegLYyZ.js","assets/IntegrationsCatalogView-BvS1pCRR.js","assets/UsageStatsView-CLJFagDC.js","assets/SourceBoardView-CKJDJ2f4.js","assets/OverviewView-BXMN0Z8_.js","assets/WorktreesView-DyZy4OjB.js","assets/SpacesView-DFcnInBv.js","assets/SpaceAccessDialog-G331hiT_.js","assets/spaceNetwork-BV5W32NY.js","assets/SpaceApplyDialog-x0rDuJEc.js","assets/SpaceSetupOutput-BEXQGXPw.js","assets/OnboardingScreen-NWWMu7OG.js","assets/AboutDialog-gL1x0YFW.js","assets/MemoryDebugPanel-BWT5owg7.js"])))=>i.map(i=>d[i]);
2
+ import{f as qe,j as n,R as c,r as Kt,a as yc,h as gf}from"./vendor-react--VO_rL_p.js";import{l as qt,bS as xf,bT as vc,u as K,aA as As,m as zn,W as Xt,Y as mo,n as ts,V as bf,aM as ho,bp as ds,bU as za,_ as go,bV as wf,bb as Sc,bW as Ct,bX as yf,ax as eo,ay as on,az as ca,aY as vf,aN as kc,as as Wa,bY as Sf,bd as jc,b5 as ki,a1 as Tc,bZ as kf,b_ as Tr,b$ as to,c0 as lr,c1 as jf,c2 as Qn,c3 as Tf,c4 as da,c5 as Or,c6 as Va,c7 as xo,bI as wn,af as er,j as Ms,c8 as Rn,c9 as Cf,ca as ks,b as yn,cb as Cr,cc as Cc,cd as Ef,ce as nn,cf as If,cg as Ec,ch as Nf,ci as Pf,cj as Rf,ck as Ic,cl as Df,bs as _f,ba as Af,bk as Of,bf as Mf,aw as Ff,aC as gs,v as ua,bg as Lf,cm as $f,cn as Bf,aH as fa,co as zf,cp as Wf,cq as Ua,cr as Vf,ap as Uf,a7 as ji,bM as Nc,cs as Ti,a6 as Pc,ct as Hf,cu as Kf,w as Rc,bj as qf,cv as Ci,aR as Ha,cw as Dc,a_ as Gf,a5 as Zf,t as Xf,q as Yf,aB as _c,by as Ei,bz as Ac,bP as Jf,bq as Qf,bu as Ii,cx as ep,cy as tp,aW as sp,aU as np,cz as rp,a$ as op,bx as ap,cA as ip,cB as lp,cC as cp,cD as Ni,cE as Bo,cF as Pi,cG as Ri,cH as dp,aP as Di,cI as up,cJ as fp,aQ as _i,cK as pp,aV as mp,i as hp,a as gp}from"./katex.min-DklPh68d.js";import{_ as Vt}from"./vendor-vite-runtime-DD1OZmLC.js";import{c1 as xp,c2 as Oc,c3 as bp,c4 as wp,c5 as yp,r as Ka,c6 as vp,c7 as Sp,c8 as kp,c9 as jp,ca as Tp,aX as Cp,cb as Ep,a_ as Ai,cc as Ip,bC as Np,a9 as Mc,ab as Fc,ah as Lc,ad as $c,aa as Bc,a8 as qa,ag as zc,ae as Wc,ac as Vc,aJ as Pp,aK as Rp,aO as Dp,aP as _p,aQ as Ap,aM as Op,J as Mp,aL as Fp,N as Lp,a7 as $p,ai as Bp,bB as zp,cd as Uc,ce as Vr,cf as Wp,cg as Vp,ch as Hc,ci as Js,cj as Oi,ck as Mi,cl as zo,cm as Fi,M as Up,am as Hp,aN as Ur,by as Kp,bz as qp,aS as Gp,bZ as Kc,cn as Zp,bA as Xp,b_ as Yp,co as Jp,cp as Qp,cq as Li,cr as em,cs as tm,ct as sm,cu as nm,cv as rm,cw as om,cx as am,cy as $i,cz as im,cA as lm,cB as cm,cC as dm,cD as um,bD as fm,bx as pm,bX as mm,bE as hm,b$ as gm,cE as xm,bT as bm,bU as wm,aV as qc,cF as ym,cG as vm,cH as Sm,cI as km,cJ as jm,bW as Tm,cK as Cm,bP as Em,bY as Im,bQ as Nm,cL as Pm,bM as Rm,bL as Dm,bG as _m,bH as Am,bI as Om,bJ as Mm,bK as Fm,bF as Lm,bN as $m,cM as Bm,c0 as zm,bS as Wm,bR as Vm,bV as Um,cN as Hm,cO as Km}from"./ReceivedPagePanel-CfXyzCii.js";import{bl as bo,Z as Yt,a0 as it,cT as Er,a2 as Ye,fL as qm,cU as Gm,I as ue,fM as Zm,u as gt,l$ as fn,Y as os,m0 as Xm,az as bs,aD as Es,aA as Ga,m1 as Gc,b4 as Hs,f$ as Zc,fZ as Ym,f_ as Jm,m2 as Xc,be as Ir,af as Pt,ae as Rt,ag as Dt,kh as qs,cX as Yc,bg as Nr,m3 as Qm,m4 as eh,m5 as th,m6 as sh,m7 as nh,_ as rh,m8 as oh,m9 as Jc,d0 as Za,b7 as ah,$ as ih,ma as lh,A as Fe,bF as ch,mb as dh,mc as uh,kv as Qc,md as fh,bO as Zs,gg as ph,ay as mh,bh as Ts,bb as wo,bf as yo,bt as Dn,me as hh,aE as gh,aF as xh,aK as Bi,mf as vo,P as Tn,mg as bh,gl as ed,mh as wh,io as Pr,ip as So,cO as so,gm as yh,kV as vh,mi as Sh,bo as cr,gu as td,mj as kh,t as dr,q as ur,D as fr,l as pr,F as mr,o as no,B as yt,mk as Mn,a5 as Sn,a6 as kn,a7 as jn,ml as sd,mm as hr,n as ps,cn as Jt,mn as nd,mo as jh,da as rd,mp as Th,mq as Ch,mr as Eh,bS as Is,ms as Ih,cs as vn,mt as zi,bY as Hr,ad as tr,mu as Nh,a8 as Ks,g3 as Ph,cD as Xa,mv as Rh,mw as od,mx as Ya,er as Dh,e3 as ro,ey as ad,el as Ja,em as Qa,my as id,aU as es,y as Fn,C as pa,hQ as _h,il as Ah,h$ as Oh,iG as Mh,mz as Fh,hw as ld,bU as Us,K as ei,bN as Lh,au as vs,bT as cd,cu as Wi,ct as Xn,hx as $h,cv as Bh,cK as ko,cF as zh,hz as Wo,mA as Wh,z as dd,aW as ud,aX as fd,aY as pd,aZ as md,a_ as ti,aT as Vi,bZ as hd,bW as oo,mB as Vh,mC as Uh,mD as Hh,b0 as Wn,bL as Kh,bP as jo,bR as qh,bV as Gh,bQ as Ln,iv as Zh,bX as Xh,hC as Yh,cE as To,mE as gd,mF as xd,mG as Jh,ef as Qh,eb as eg,ee as tg,mH as sg,en as ng,ec as Ui,mI as rg,iQ as og,mJ as ag,mK as ig,ed as Hi,ex as lg,eh as cg,co as dg,mL as ug,mM as fg,mN as pg,mO as si,mP as ni,mQ as mg,mR as hg,mS as gg,mT as xg,mU as bg,lE as ri,mV as wg,mW as yg,mX as vg,mY as Sg,mZ as oi,m_ as kg,bM as jg,m$ as Tg,n0 as Cg,b$ as bd,n1 as wd,bv as Eg,n2 as Ig,x as yd,n3 as Ng,n4 as en,c8 as Pg,bK as Rg,as as Dg,n5 as _g,V as Ut,n6 as Ag,n7 as Og,dO as Mg,n8 as ai,n9 as Fg,na as Kr,nb as In,nc as Lg,k4 as $g,nd as bn,eu as Bg,ne as zg,nf as vd,l0 as Sd,fb as Co,ng as Wg,eq as Vg,dV as Ug,nh as ii,ni as Hg,cJ as Kg,cH as qg,nj as Gg,nk as Vo,d9 as li,fN as $n,nl as kd,dC as qr,cm as jd,bm as Zg,nm as Xg,nn as Yg,no as Jg,hq as Td,np as Mr,nq as Qg,nr as e1,ns as t1,nt as s1,nu as n1,nv as r1,nw as Ki,nx as o1,ny as a1,nz as i1,hi as ci,d2 as l1,hf as c1,ki as d1,kj as u1,db as f1,nA as gr,he as Cd,hd as Ed,kk as p1,kl as m1,hg as h1,d3 as g1,eS as x1,lN as b1,ca as w1,nB as Uo,lt as y1,ls as v1,nC as Id,nD as Nd,nE as S1,nF as ma,nG as sn,e7 as k1,kf as j1,lr as qi,nH as T1,nI as C1,lq as E1,lp as I1,nJ as N1,bd as xr,nK as Gi,nL as P1,nM as R1,nN as D1,kA as _1,kB as A1,nO as O1,kC as Zi,nP as M1,kD as Xi,kE as F1,dG as L1,nQ as $1,nR as B1,nS as z1,bu as W1,k as V1,l5 as U1,cZ as Ho,kF as H1,kG as K1,nT as Yi,kH as q1,d1 as G1,kK as Z1,kI as X1,kJ as Y1,nU as Ko,nV as qo,nW as pn,nX as Nn,nY as Ji,nZ as Qi,n_ as J1,n$ as Q1,lZ as ex,kY as di,eP as Rr,kS as tx,o0 as sx,o1 as Pd,fB as nx,o2 as ha,o3 as Rd,jE as Eo,l2 as rx,dn as ox,o4 as ax,o5 as Dd,gj as ix,o6 as lx,o7 as _d,eR as cx,eQ as ui,o8 as dx,o9 as el,oa as ux,ob as fx,eT as px,G as ga,oc as Ad,cx as Od,cy as Md,cz as Fd,cA as Ld,od as xa,cB as $d,kr as Bd,oe as Go,of as mx,og as hx,l4 as gx,a1 as xx,oh as bx,oi as wx,oj as zd,b5 as tl,fu as yx,km as vx,ok as Sx,kp as kx,lA as jx,dP as sl,ol as Tx,kt as Cx,om as Ex,lF as Ix,gz as Nx,on as Px,gP as nl,bc as Rx,gA as Dx,gC as _x,gB as Ax,gL as Ox,gK as Mx,gE as Fx,lG as Lx,gJ as $x,gF as Bx,gG as zx,gH as Wx,gI as Vx,a as Ux,s as Hx,b as Kx,c as qx,gS as Gx,al as Zx,gU as Xx,gV as Yx,gW as Jx}from"./useAppFontEffects-BDLOJuy5.js";import{f as Wd,u as Vd,S as Qx,W as Ud,a as eb,b as tb}from"./useRootScrollLock-DPhGk2Eu.js";import{h as Hd,i as ao,T as Kd,M as qd,D as Gd,f as ba}from"./vendor-dnd-kit-core-Br1Cs7RV.js";import{r as sb,h as nb,u as Zd,S as Xd,v as rb,a as ob}from"./vendor-dnd-kit-sortable-DpfLEOLv.js";import{C as Yd}from"./vendor-dnd-kit-utilities-DZ9KbT5S.js";import{C as ab}from"./vendor-base-ui-CHqK1aDI.js";import{a as mn,O as ib,d as lb,D as cb,b as db,u as ub,m as rl}from"./moveWorkspacePath-DibtVw_Q.js";import{u as wa,c as Io,p as fb}from"./vendor-zustand-C9tWdk0j.js";import{o as Mt,s as It,n as as,c as Cn,h as Jd,e as ss,_ as Qd,j as an,l as br,a as wr,f as pb}from"./vendor-zod-DV_WH382.js";import{u as mb}from"./vendor-tanstack-react-virtual-Bw3q1rnq.js";import{v as ol,t as al}from"./contextFileOpenGuard-D-HtBtn6.js";import{d as hb,m as gb}from"./vendor-tanstack-virtual-core-B4TJYmIq.js";import{r as xb}from"./install-request-CzRei4tp.js";function bb(t){const e=qe.c(37),{directory:s,className:r}=t,{currentTheme:o}=bo(),a=Yt(vb),i=it(yb),u=qt(wb),d=xf(s);let l;e[0]!==s||e[1]!==u?(l=vc(s,u),e[0]=s,e[1]=u,e[2]=l):l=e[2];const f=l;let m;e[3]!==s||e[4]!==f||e[5]!==a||e[6]!==d||e[7]!==i?(m=f||!s?null:Er(a,i,s,d),e[3]=s,e[4]=f,e[5]=a,e[6]=d,e[7]=i,e[8]=m):m=e[8];const p=m;if(f){let B;e[9]!==r?(B=Ye("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),e[9]=r,e[10]=B):B=e[10];let T;return e[11]!==B?(T=n.jsx(ue,{name:"chat-4",className:B}),e[11]=B,e[12]=T):T=e[12],T}if(!p)return null;const h=p.icon?qm[p.icon]:null;let x;e[13]!==p.color?(x=Gm(p.color)??void 0,e[13]=p.color,e[14]=x):x=e[14];const g=x;let v;e[15]!==r||e[16]!==g||e[17]!==h?(v=h?n.jsx(ue,{name:h,className:Ye("h-3.5 w-3.5 shrink-0",r),style:g?{color:g}:void 0}):n.jsx(ue,{name:"folder",className:Ye("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]=v):v=e[18];const y=v;if(!p.iconImage)return y;let C;e[19]!==r?(C=Ye("inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",r),e[19]=r,e[20]=C):C=e[20];let S;e[21]!==p.iconBackground?(S=p.iconBackground?{backgroundColor:p.iconBackground}:void 0,e[21]=p.iconBackground,e[22]=S):S=e[22];let N;e[23]!==p.iconImage||e[24]!==p.id?(N={id:p.id,iconImage:p.iconImage},e[23]=p.iconImage,e[24]=p.id,e[25]=N):N=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]!==y||e[30]!==N||e[31]!==F?(_=n.jsx(Zm,{project:N,options:F,className:"h-full w-full object-contain",fallback:y}),e[29]=y,e[30]=N,e[31]=F,e[32]=_):_=e[32];let M;return e[33]!==C||e[34]!==S||e[35]!==_?(M=n.jsx("span",{className:C,style:S,children:_}),e[33]=C,e[34]=S,e[35]=_,e[36]=M):M=e[36],M}function wb(t){return t.homeDirectory}function yb(t){return t.availableWorktreesByProject}function vb(t){return t.projects}const Yn=24,Sb=(t,e,s=Yn)=>{const r=e.right-(t.right-s);if(r>0)return r;const o=e.left-(t.left+s);return o<0?o:0},kb=({transform:t})=>({...t,y:0}),jb=16,Tb=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*jb:t.deltaY;t.currentTarget.scrollLeft+=mo(t.currentTarget)?-e:e},Cb=t=>{const e=qe.c(118),{tab:s,tabNumber:r,isActive:o,isPreview:a,suppressControls:i,onSelect:u,onPin:d,onClose:l,renderMenu:f,closeOtherTabs:m,onMenuOpenChangeComplete:p,menuReturnsFocus:h,children:x}=t,{t:g}=gt(),v=K(Ib);let y;e[0]!==v?(y=Ga("switch_session_tab",v),e[0]=v,e[1]=y):y=e[1];const C=y;let S;e[2]!==r||e[3]!==C?(S=C&&C!==Gc&&r<=9?bs(`${C}+${r}`):void 0,e[2]=r,e[3]=C,e[4]=S):S=e[4];const N=S,[F,_]=c.useState(false);let M;e[5]!==s.id?(M={id:s.id},e[5]=s.id,e[6]=M):M=e[6];const{attributes:B,listeners:T,setNodeRef:I,transform:b,transition:w,isDragging:j}=Zd(M);let R;e[7]!==g||e[8]!==s.session.title?(R=s.session.title?.trim()||g("sessions.sidebar.session.untitled"),e[7]=g,e[8]=s.session.title,e[9]=R):R=e[9];const L=R,E=s.id;let D;e[10]!==s.session?(D=Hs(s.session),e[10]=s.session,e[11]=D):D=e[11];const U=Oc(E,D),V=Zc(s.id),J=V!==null,W=Ym(s.id),G=Jm(s.id),$=J||W&&(!o||G)&&!J;let re;e[12]!==u||e[13]!==s?(re=()=>u(s),e[12]=u,e[13]=s,e[14]=re):re=e[14];let H;e[15]!==m||e[16]!==s.id?(H=()=>m(s.id),e[15]=m,e[16]=s.id,e[17]=H):H=e[17];let P,ee,oe,de,he,Z,ce,ae,te,pe,Te,Ae,Pe,ze,Oe,me;if(e[18]!==B||e[19]!==x||e[20]!==F||e[21]!==o||e[22]!==U||e[23]!==j||e[24]!==a||e[25]!==W||e[26]!==T||e[27]!==h||e[28]!==l||e[29]!==p||e[30]!==d||e[31]!==u||e[32]!==f||e[33]!==I||e[34]!==v||e[35]!==$||e[36]!==i||e[37]!==g||e[38]!==re||e[39]!==H||e[40]!==s||e[41]!==N||e[42]!==L||e[43]!==b||e[44]!==w||e[45]!==V){const We={session:s.session,open:F,isActive:o,select:re,closeOtherTabs:H,components:bp};te=I;let _e;e[62]!==b?(_e=Yd.Translate.toString(b),e[62]=b,e[63]=_e):_e=e[63],e[64]!==_e||e[65]!==w?(pe={transform:_e,transition:w},e[64]=_e,e[65]=w,e[66]=pe):pe=e[66];const Ue=j&&"z-10 opacity-60";e[67]!==Ue?(Te=Ye("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",Ue),e[67]=Ue,e[68]=Te):Te=e[68],Ae=o?"true":"false",e[69]!==o?(Pe=o?{"data-active-session-tab":true}:{},e[69]=o,e[70]=Pe):Pe=e[70],ze=B,Oe=T,ee=Ir,he=F,Z=_,e[71]!==p?(ce=ot=>p?.(ot),e[71]=p,e[72]=ce):ce=e[72];let Xe;e[73]!==x||e[74]!==o||e[75]!==U||e[76]!==a||e[77]!==W||e[78]!==l||e[79]!==d||e[80]!==u||e[81]!==v||e[82]!==$||e[83]!==i||e[84]!==g||e[85]!==s||e[86]!==L||e[87]!==V?(Xe=n.jsx(Pt,{asChild:true,children:n.jsx(ab,{render:ot=>n.jsx("div",{...ot,role:"tab","aria-selected":o,tabIndex:o?void 0:0,onClick:ye=>{if(ye.altKey){wp(s.id,W,g);return}const Ve=Hs(s.session);if(ye.shiftKey&&Ve&&!zn()){yp(s.id,Ve,L);return}o||u(s)},onDoubleClick:a?()=>d(s.id):void 0,onKeyDown:o?void 0:ye=>{(ye.key==="Enter"||ye.key===" ")&&(ye.preventDefault(),u(s))},onAuxClick:ye=>{ye.button===1&&(ye.preventDefault(),l(s.id))},className:Ye("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:n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[n.jsxs("span",{className:"relative me-1.5 inline-flex size-3.5 shrink-0 items-center justify-center",children:[n.jsx(bb,{directory:Hs(s.session),className:Ye(!i&&"group-hover/session-tab:opacity-0 group-has-[:focus-visible]/session-tab:opacity-0")}),i?null:n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button","aria-label":g("header.sessionTabs.closeTab"),onClick:ye=>{ye.stopPropagation(),l(s.id)},onPointerDown:Nb,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:n.jsx(ue,{name:"close",className:"size-3.5"})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:n.jsx(qs,{label:g("header.sessionTabs.closeTab"),shortcut:o?bs(As()?"mod+w":Es("close_session_tab",v),""):void 0})})]})]}),n.jsx("div",{className:Ye("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title",a&&!i&&"italic"),children:o?x:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:n.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:L})})}),U?n.jsx(ue,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":g("sessions.aiRename.generating")}):$?n.jsx(Yc,{state:V??"unread",className:"ms-1.5 shrink-0"}):null]})})})}),e[73]=x,e[74]=o,e[75]=U,e[76]=a,e[77]=W,e[78]=l,e[79]=d,e[80]=u,e[81]=v,e[82]=$,e[83]=i,e[84]=g,e[85]=s,e[86]=L,e[87]=V,e[88]=Xe):Xe=e[88];let Me;e[89]!==N||e[90]!==L?(Me=n.jsx(Dt,{side:"bottom",sideOffset:6,children:n.jsx(qs,{label:L,shortcut:N})}),e[89]=N,e[90]=L,e[91]=Me):Me=e[91],e[92]!==Xe||e[93]!==Me?(ae=n.jsxs(Rt,{children:[Xe,Me]}),e[92]=Xe,e[93]=Me,e[94]=ae):ae=e[94],P=Nr,e[95]!==h?(me=()=>h?.()??true,e[95]=h,e[96]=me):me=e[96],oe="min-w-[190px]",de=f(We),e[18]=B,e[19]=x,e[20]=F,e[21]=o,e[22]=U,e[23]=j,e[24]=a,e[25]=W,e[26]=T,e[27]=h,e[28]=l,e[29]=p,e[30]=d,e[31]=u,e[32]=f,e[33]=I,e[34]=v,e[35]=$,e[36]=i,e[37]=g,e[38]=re,e[39]=H,e[40]=s,e[41]=N,e[42]=L,e[43]=b,e[44]=w,e[45]=V,e[46]=P,e[47]=ee,e[48]=oe,e[49]=de,e[50]=he,e[51]=Z,e[52]=ce,e[53]=ae,e[54]=te,e[55]=pe,e[56]=Te,e[57]=Ae,e[58]=Pe,e[59]=ze,e[60]=Oe,e[61]=me}else P=e[46],ee=e[47],oe=e[48],de=e[49],he=e[50],Z=e[51],ce=e[52],ae=e[53],te=e[54],pe=e[55],Te=e[56],Ae=e[57],Pe=e[58],ze=e[59],Oe=e[60],me=e[61];let be;e[97]!==P||e[98]!==oe||e[99]!==de||e[100]!==me?(be=n.jsx(P,{finalFocus:me,className:oe,children:de}),e[97]=P,e[98]=oe,e[99]=de,e[100]=me,e[101]=be):be=e[101];let Ce;e[102]!==ee||e[103]!==he||e[104]!==Z||e[105]!==ce||e[106]!==ae||e[107]!==be?(Ce=n.jsxs(ee,{open:he,onOpenChange:Z,onOpenChangeComplete:ce,children:[ae,be]}),e[102]=ee,e[103]=he,e[104]=Z,e[105]=ce,e[106]=ae,e[107]=be,e[108]=Ce):Ce=e[108];let $e;return e[109]!==te||e[110]!==pe||e[111]!==Te||e[112]!==Ae||e[113]!==Pe||e[114]!==ze||e[115]!==Oe||e[116]!==Ce?($e=n.jsx("div",{ref:te,style:pe,className:Te,"data-active":Ae,...Pe,...ze,...Oe,children:Ce}),e[109]=te,e[110]=pe,e[111]=Te,e[112]=Ae,e[113]=Pe,e[114]=ze,e[115]=Oe,e[116]=Ce,e[117]=$e):$e=e[117],$e},Eb=t=>{const e=qe.c(110),{renderMenu:s,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,menuReturnsFocus:a,children:i}=t,u=o===void 0?false:o,{t:d,direction:l}=gt(),f=l==="rtl",m=fn(Pb),p=fn(Rb),h=fn(Db),x=fn(_b),g=fn(Ab),v=fn(Ob),y=it(Mb),C=it(Fb),S=os(Lb),N=K($b),F=fn(Bb),_=os(zb),M=it(Wb),B=it(Vb),T=it(Ub),I=it(Hb),b=it(Kb),w=it(qb);let j;e[0]!==w?(j=ie=>{const xe=w??ie.activeProjectId;return ie.projects.find(Le=>Le.id===xe)?.path??null},e[0]=w,e[1]=j):j=e[1];const R=Yt(j),L=xp(y);let E,D;e[2]!==L||e[3]!==M||e[4]!==y||e[5]!==b||e[6]!==I||e[7]!==B||e[8]!==R||e[9]!==h||e[10]!==F||e[11]!==N||e[12]!==_?(E=()=>{if(!N)F(Qm,Gb);else{if(!_)return;const ie=Xt(),xe=!y&&B&&I,Le=y?M:B&&!I?b??R:null,Ke=xe?eh(ie):th(ie,Le);if(!Ke)return;F(Ke,()=>sh(Le,os.getState().activeSessions,Yt.getState().projects.map(Zb)))}y&&h(y,L)},D=[L,M,y,b,I,B,R,h,F,N,_],e[2]=L,e[3]=M,e[4]=y,e[5]=b,e[6]=I,e[7]=B,e[8]=R,e[9]=h,e[10]=F,e[11]=N,e[12]=_,e[13]=E,e[14]=D):(E=e[13],D=e[14]),c.useEffect(E,D);let U;if(e[15]!==S){U=new Map;for(const ie of S)U.set(ie.id,ie);e[15]=S,e[16]=U}else U=e[16];const V=U;let J;if(e[17]!==V||e[18]!==m){J=[];for(const ie of m){const xe=V.get(ie);xe&&J.push({id:ie,session:xe})}e[17]=V,e[18]=m,e[19]=J}else J=e[19];const W=J;let G;e[20]!==C?(G=ie=>{C(ie.id,Hs(ie.session))},e[20]=C,e[21]=G):G=e[21];const le=G,$=Xb,re=!y&&B;let H;e[22]!==re||e[23]!==T?(H=ie=>!re||!T?"":(ie.drafts.find(Le=>Le.id===T)?.text??"").split(/\r?\n/).find(Yb)?.trim()??"",e[22]=re,e[23]=T,e[24]=H):H=e[24];const P=Xm(H),ee=K(Jb),oe=Qb;let de;e[25]!==y||e[26]!==re||e[27]!==W?(de=W.some(ie=>ie.id===y)||re&&W.length>0,e[25]=y,e[26]=re,e[27]=W,e[28]=de):de=e[28];const he=de;let Z,ce;e[29]!==he?(Z=()=>{if(he)return Ka(ew,{current:document.body})},ce=[he],e[29]=he,e[30]=Z,e[31]=ce):(Z=e[30],ce=e[31]),c.useEffect(Z,ce);let ae;e[32]!==g||e[33]!==y||e[34]!==le||e[35]!==W?(ae=ie=>{if(g(ie),y&&y!==ie){const xe=W.find(Le=>Le.id===ie);xe&&le(xe)}},e[32]=g,e[33]=y,e[34]=le,e[35]=W,e[36]=ae):ae=e[36];const te=ae;let pe;e[37]===Symbol.for("react.memo_cache_sentinel")?(pe={activationConstraint:{distance:8}},e[37]=pe):pe=e[37];let Te;e[38]===Symbol.for("react.memo_cache_sentinel")?(Te={activationConstraint:{delay:200,tolerance:6}},e[38]=Te):Te=e[38];const Ae=Hd(ao(qd,pe),ao(Kd,Te));let Pe;e[39]!==v?(Pe=ie=>{const{active:xe,over:Le}=ie;Le&&xe.id!==Le.id&&v(String(xe.id),String(Le.id))},e[39]=v,e[40]=Pe):Pe=e[40];const ze=Pe,Oe=c.useRef(null);let me;e[41]===Symbol.for("react.memo_cache_sentinel")?(me={left:false,right:false},e[41]=me):me=e[41];const[be,Ce]=c.useState(me);let $e;e[42]===Symbol.for("react.memo_cache_sentinel")?($e=()=>{const ie=Oe.current;if(!ie)return;const xe=ie.scrollWidth-ie.clientWidth,Le=mo(ie)?xe+ie.scrollLeft:ie.scrollLeft,Ke=Le>2,ve=Le<xe-2;Ce(je=>je.left===Ke&&je.right===ve?je:{left:Ke,right:ve})},e[42]=$e):$e=e[42];const We=$e;let _e;e[43]===Symbol.for("react.memo_cache_sentinel")?(_e=()=>{We();const ie=Oe.current;if(!ie||!globalThis.ResizeObserver)return;const xe=new ResizeObserver(We);return xe.observe(ie),()=>xe.disconnect()},e[43]=_e):_e=e[43];let Ue;e[44]!==W.length?(Ue=[We,W.length],e[44]=W.length,e[45]=Ue):Ue=e[45],c.useEffect(_e,Ue);let Xe;e[46]===Symbol.for("react.memo_cache_sentinel")?(Xe=()=>{const ie=Oe.current,xe=ie?.querySelector("[data-active-session-tab]");if(!ie||!xe)return;const Le=Sb(ie.getBoundingClientRect(),xe.getBoundingClientRect());Le!==0&&(ie.scrollLeft=ie.scrollLeft+Le,We())},e[46]=Xe):Xe=e[46];let Me;e[47]!==y?(Me=[y,We],e[47]=y,e[48]=Me):Me=e[48],c.useEffect(Xe,Me);const ot=be.left&&be.right?`linear-gradient(to right, transparent, black ${Yn}px, black calc(100% - ${Yn}px), transparent)`:be.left?`linear-gradient(to right, transparent, black ${Yn}px)`:be.right?`linear-gradient(to right, black calc(100% - ${Yn}px), transparent)`:void 0;let ye;e[49]!==W?(ye=W.map(tw),e[49]=W,e[50]=ye):ye=e[50];const Ve=ye;let lt;e[51]!==y||e[52]!==W?(lt=!!y&&!W.some(ie=>ie.id===y),e[51]=y,e[52]=W,e[53]=lt):lt=e[53];const ct=lt;let st;e[54]!==d?(st=d("header.sessionTabs.stripAria"),e[54]=d,e[55]=st):st=e[55];let k;e[56]!==ot?(k=ot?{maskImage:ot,WebkitMaskImage:ot}:void 0,e[56]=ot,e[57]=k):k=e[57];let Y;e[58]===Symbol.for("react.memo_cache_sentinel")?(Y=[kb],e[58]=Y):Y=e[58];const Ne=f?sb:nb;let Re;e[59]!==i||e[60]!==y||e[61]!==te||e[62]!==le||e[63]!==a||e[64]!==r||e[65]!==x||e[66]!==p||e[67]!==s||e[68]!==u||e[69]!==W?(Re=W.map((ie,xe)=>n.jsx(Cb,{tabNumber:xe+1,tab:ie,isActive:ie.id===y,isPreview:ie.id===p,suppressControls:ie.id===y&&u,onSelect:le,onPin:x,onClose:$,renderMenu:s,closeOtherTabs:te,onMenuOpenChangeComplete:r,menuReturnsFocus:a,children:ie.id===y?i:null},ie.id)),e[59]=i,e[60]=y,e[61]=te,e[62]=le,e[63]=a,e[64]=r,e[65]=x,e[66]=p,e[67]=s,e[68]=u,e[69]=W,e[70]=Re):Re=e[70];let Ie;e[71]!==Ne||e[72]!==Re||e[73]!==Ve?(Ie=n.jsx(Xd,{items:Ve,strategy:Ne,children:Re}),e[71]=Ne,e[72]=Re,e[73]=Ve,e[74]=Ie):Ie=e[74];let Ee;e[75]!==ze||e[76]!==Ae||e[77]!==Ie?(Ee=n.jsx(Gd,{sensors:Ae,collisionDetection:ba,modifiers:Y,onDragEnd:ze,children:Ie}),e[75]=ze,e[76]=Ae,e[77]=Ie,e[78]=Ee):Ee=e[78];let Ge;e[79]!==P||e[80]!==re||e[81]!==d?(Ge=re?n.jsxs("div",{role:"tab","aria-selected":true,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":true,children:[n.jsx(ue,{name:"edit",className:"me-1.5 size-3.5 shrink-0"}),n.jsx("div",{className:"session-tab-title min-w-0 flex-1 overflow-hidden whitespace-nowrap italic",children:n.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:P||d("sessions.switcher.draftTitle")})})]}):null,e[79]=P,e[80]=re,e[81]=d,e[82]=Ge):Ge=e[82];let Be;e[83]!==i||e[84]!==ct?(Be=ct?n.jsx("div",{role:"tab","aria-selected":true,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:n.jsx("div",{className:"min-w-0 flex-1",children:i})}):null,e[83]=i,e[84]=ct,e[85]=Be):Be=e[85];let Ze;e[86]!==k||e[87]!==Ee||e[88]!==Ge||e[89]!==Be?(Ze=n.jsxs("div",{ref:Oe,onScroll:We,onWheel:Tb,className:"session-tabs-scroll flex min-w-0 flex-initial items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:k,children:[Ee,Ge,Be]}),e[86]=k,e[87]=Ee,e[88]=Ge,e[89]=Be,e[90]=Ze):Ze=e[90];let et;e[91]!==d?(et=d("sessions.sidebar.header.actions.newSession"),e[91]=d,e[92]=et):et=e[92];let wt;e[93]===Symbol.for("react.memo_cache_sentinel")?(wt=n.jsx(ue,{name:"add",className:"size-4"}),e[93]=wt):wt=e[93];let Qe;e[94]!==et?(Qe=n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:oe,"aria-label":et,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:wt})}),e[94]=et,e[95]=Qe):Qe=e[95];let dt;e[96]!==d?(dt=d("sessions.sidebar.header.actions.newSession"),e[96]=d,e[97]=dt):dt=e[97];let at;e[98]!==ee?(at=bs(Es("new_chat",ee),""),e[98]=ee,e[99]=at):at=e[99];let z;e[100]!==dt||e[101]!==at?(z=n.jsx(Dt,{side:"bottom",sideOffset:6,children:n.jsx(qs,{label:dt,shortcut:at})}),e[100]=dt,e[101]=at,e[102]=z):z=e[102];let fe;e[103]!==Qe||e[104]!==z?(fe=n.jsxs(Rt,{children:[Qe,z]}),e[103]=Qe,e[104]=z,e[105]=fe):fe=e[105];let ke;return e[106]!==st||e[107]!==Ze||e[108]!==fe?(ke=n.jsxs("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":st,children:[Ze,fe]}),e[106]=st,e[107]=Ze,e[108]=fe,e[109]=ke):ke=e[109],ke};function Ib(t){return t.shortcutOverrides}function Nb(t){return t.stopPropagation()}function Pb(t){return t.tabIds}function Rb(t){return t.previewTabId}function Db(t){return t.ensureTab}function _b(t){return t.pinTab}function Ab(t){return t.closeOtherTabs}function Ob(t){return t.reorderTabs}function Mb(t){return t.currentSessionId}function Fb(t){return t.setCurrentSession}function Lb(t){return t.activeSessions}function $b(t){return t.sessionTabsPerWorkspace}function Bb(t){return t.enterScope}function zb(t){return t.hasLoaded}function Wb(t){return t.currentSessionDirectory}function Vb(t){return t.newSessionDraft.open}function Ub(t){return t.newSessionDraft.workDraftId??null}function Hb(t){return t.newSessionDraft.target==="chat"}function Kb(t){return t.newSessionDraft.directoryOverride}function qb(t){return t.newSessionDraft.selectedProjectId??null}function Gb(){return[]}function Zb(t){return t.path}function Xb(t){Xc(t)}function Yb(t){return t.trim()}function Jb(t){return t.shortcutOverrides}function Qb(){const{currentSessionId:t,newSessionDraft:e,openNewSessionDraft:s}=it.getState(),r=t?qt.getState().currentDirectory:e.directoryOverride;s(r?{directoryOverride:r}:void 0)}function ew(){const t=it.getState().currentSessionId;t?Xc(t):nh(-1)}function tw(t){return t.id}const sw=(t,e)=>{const s=!!t.time?.archived,r=e.projects.flatMap(u=>{const d=ts(u.path);return d?[{id:u.id,normalizedPath:d}]:[]}),a=rh(s?[]:[t],r,e.availableWorktreesByProject,e.isVSCode,s?[t]:[],e.authoritativeProjects,e.spaces).bySessionId.get(t.id),i=oh(e.activeSessions,e.resolveLegacyScope).runKeyBySessionId.has(t.id);return{projectId:a?.projectId??null,folderOwnerKey:vp(t,a,i),ownsWork:!i&&(!a||a.kind==="project")&&Jc(t,e.lookup)===null}},nw=(t,e)=>{const s=new Map(e.map(u=>[u.id,u])),r=new Map;for(const u of e){if(u.parentID||u.time?.archived)continue;const d=Jc(u,f=>s.get(f));if(!d)continue;const l=r.get(d);l?l.push(u):r.set(d,[u])}const o=[],a=new Set,i=[t];for(;i.length>0;){const u=i.pop();!u||a.has(u.id)||(a.add(u.id),Za(u)&&o.push(u),i.push(...r.get(u.id)??[]))}return o};function il({sessionId:t,open:e,slots:s,onRename:r,onExport:o,onMoveSession:a,onArchive:i,onDelete:u}){const{t:d}=gt(),l=c.useMemo(()=>zn(),[]),f=os(b=>b.entityById.get(t)),m=os(b=>{const w=b.entityById.get(t);return!w||ah(w,b.entityById)}),p=os(b=>b.activeSessions),h=it(b=>b.unarchiveSession),x=it(b=>b.availableWorktreesByProject),g=it(b=>b.worktreeMetadata),v=K(b=>b.sessionWorkEnabled),y=Yt(b=>b.projects),C=ih(b=>b.projects),S=bf(!l),N=Sp(b=>b.load),F=c.useMemo(()=>f?sw(f,{projects:y,availableWorktreesByProject:x,authoritativeProjects:C,spaces:S,isVSCode:l,activeSessions:p,resolveLegacyScope:b=>ts(g.get(b.id)?.projectDirectory??b.directory??null),lookup:b=>os.getState().entityById.get(b)}):null,[p,C,x,l,y,f,S,g]);if(!f||!F)return null;const _=!!f.time?.archived,M=ts(f.directory??null),B=v&&F.ownsWork&&!_&&!f.parentID&&!ho(f.directory),T=B?nw(f,p):[],I=async()=>{await h(f.id)?Fe.success(d("sessions.sidebar.session.restore.success")):Fe.error(d("sessions.sidebar.session.restore.error"))};return n.jsx(kp,{session:f,directory:M,open:e,slots:s,archived:_,pinned:lh(f),work:B?{inWork:T.length>0,toggle:()=>{jp(f.id,M,T,d)}}:null,projectId:F.projectId,currentWorktree:it.getState().getWorktreeMetadata(f.id)??null,descendants:[],startWorktreeLoad:N,folders:F.folderOwnerKey?{ownerKey:F.folderOwnerKey,projectId:F.projectId}:null,onRename:r,onExport:()=>o(f,M),onMoveSession:()=>{M&&a(f.id,M)},onArchive:i,onRestore:_&&m?()=>{I()}:null,onDelete:u})}const rw=t=>{const e=Qc(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},ow=(t,e)=>t===null||e===null?t===e:t.state!==e.state?false:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,eu=()=>{const t=qe.c(4),e=it(aw),s=it(iw)??void 0,r=ch(e??"",s,rw,ow),{context:o}=dh(e,s),a=o>0?o:uh;let i;return t[0]!==r||t[1]!==a||t[2]!==e?(i={sessionId:e,fill:r,limit:a},t[0]=r,t[1]=a,t[2]=e,t[3]=i):i=t[3],i};function aw(t){return t.currentSessionId}function iw(t){return t.currentSessionDirectory}const ll=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),zs=18,ya=2,va=(zs-ya)/2,cl=2*Math.PI*va,lw=t=>{const e=qe.c(9),{percent:s,arcColor:r,className:o}=t,a=r===void 0?"currentColor":r,i=Math.min(100,Math.max(0,s));let u;e[0]!==o?(u=Ye("shrink-0",o),e[0]=o,e[1]=u):u=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("circle",{cx:zs/2,cy:zs/2,r:va,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:ya}),e[2]=d):d=e[2];let l;e[3]!==a||e[4]!==i?(l=i>0?n.jsx("circle",{cx:zs/2,cy:zs/2,r:va,fill:"none",stroke:a,strokeWidth:ya,strokeLinecap:"round",strokeDasharray:cl,strokeDashoffset:cl*(1-i/100),transform:`rotate(-90 ${zs/2} ${zs/2})`}):null,e[3]=a,e[4]=i,e[5]=l):l=e[5];let f;return e[6]!==u||e[7]!==l?(f=n.jsxs("svg",{viewBox:`0 0 ${zs} ${zs}`,className:u,"aria-hidden":"true",children:[d,l]}),e[6]=u,e[7]=l,e[8]=f):f=e[8],f},tu=()=>{const t=qe.c(16),{t:e}=gt(),{sessionId:s,fill:r,limit:o}=eu(),{totalCost:a}=fh(s);if(!s||!r)return null;let i;t[0]!==r.state||t[1]!==r.totalTokens||t[2]!==e?(i=r.state==="measured"?e("contextUsage.tooltip.usedTokens",{tokens:ll(r.totalTokens)}):e("contextUsage.compacted.description"),t[0]=r.state,t[1]=r.totalTokens,t[2]=e,t[3]=i):i=t[3];let u;t[4]!==o||t[5]!==e?(u=e("contextUsage.tooltip.contextLimit",{tokens:ll(o)}),t[4]=o,t[5]=e,t[6]=u):u=t[6];let d;t[7]!==e||t[8]!==a?(d=a!==null&&a>0?[e("contextUsage.tooltip.cost",{cost:Wd(a)})]:[],t[7]=e,t[8]=a,t[9]=d):d=t[9];let l;t[10]!==i||t[11]!==u||t[12]!==d?(l=[i,u,...d],t[10]=i,t[11]=u,t[12]=d,t[13]=l):l=t[13];const f=l;let m;return t[14]!==f?(m=n.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-edge pt-1 tabular-nums",children:f.map(cw)}),t[14]=f,t[15]=m):m=t[15],m};function cw(t){return n.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const dw="\u2014",uw={safe:"var(--muted-foreground)",warn:"var(--status-warning)",critical:"var(--status-error)"},fw=t=>{const e=qe.c(35),{buttonClassName:s}=t,{t:r}=gt(),{sessionId:o,fill:a,limit:i}=eu(),u=Zs();let d;e[0]!==u?(d=u?ds(u):"",e[0]=u,e[1]=d):d=e[1];const l=d,f=K(mw);let m;e[2]!==l?(m=j=>l!==""&&za(j.contextPanelByDirectory[l],j.contextSurfaceZones).has("context"),e[2]=l,e[3]=m):m=e[3];const p=K(m),h=K(hw);if(!o||!a||h)return null;const x=a.state==="measured"?a.totalTokens/i*100:null,g=x===null?void 0:uw[ph(Math.round(x))];let v;e[4]!==l||e[5]!==f?(v=l?()=>f(l,"context"):void 0,e[4]=l,e[5]=f,e[6]=v):v=e[6];let y;e[7]!==r?(y=r("contextUsage.aria.label"),e[7]=r,e[8]=y):y=e[8];const C=p&&"text-foreground";let S;e[9]!==s||e[10]!==C?(S=Ye(s,"w-auto gap-1.5 px-1 tabular-nums",C),e[9]=s,e[10]=C,e[11]=S):S=e[11];const N=x??0;let F;e[12]!==g||e[13]!==N?(F=n.jsx(lw,{percent:N,arcColor:g,className:"size-4"}),e[12]=g,e[13]=N,e[14]=F):F=e[14];let _;e[15]!==x?(_=x===null?dw:`${Math.min(x,999).toFixed(1)}%`,e[15]=x,e[16]=_):_=e[16];let M;e[17]!==_?(M=n.jsx("span",{dir:"ltr",className:"typography-meta",children:_}),e[17]=_,e[18]=M):M=e[18];let B;e[19]!==p||e[20]!==M||e[21]!==v||e[22]!==y||e[23]!==S||e[24]!==F?(B=n.jsx(Pt,{asChild:true,children:n.jsxs("button",{type:"button",onClick:v,"aria-label":y,"aria-pressed":p,className:S,children:[F,M]})}),e[19]=p,e[20]=M,e[21]=v,e[22]=y,e[23]=S,e[24]=F,e[25]=B):B=e[25];let T;e[26]!==p||e[27]!==r?(T=p?null:n.jsx("span",{children:r("chat.workStatus.action.openContext")}),e[26]=p,e[27]=r,e[28]=T):T=e[28];let I;e[29]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(tu,{}),e[29]=I):I=e[29];let b;e[30]!==T?(b=n.jsx(Dt,{side:"bottom",children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[T,I]})}),e[30]=T,e[31]=b):b=e[31];let w;return e[32]!==B||e[33]!==b?(w=n.jsxs(Rt,{children:[B,b]}),e[32]=B,e[33]=b,e[34]=w):w=e[34],w},pw=c.memo(fw);function mw(t){return t.openContextSurface}function hw(t){return t.workStatusPanelVisible&&!t.workStatusHiddenSections.includes("session")}const dl=t=>{const e=qe.c(12),{run:s,showIdle:r,large:o,className:a}=t,i=r===void 0?false:r,u=o===void 0?false:o;if(s?.status==="stopping"||s?.status==="waiting-for-preview"){let l;e[0]!==a?(l=Ye("size-4 shrink-0 animate-spin text-[var(--status-warning)]",a),e[0]=a,e[1]=l):l=e[1];let f;return e[2]!==l?(f=n.jsx(ue,{name:"loader-4",className:l}),e[2]=l,e[3]=f):f=e[3],f}if(s){const l=u?"stop-large":"stop";let f;e[4]!==a?(f=Ye("size-4 shrink-0 text-[var(--status-error)]",a),e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==l||e[7]!==f?(m=n.jsx(ue,{name:l,className:f}),e[6]=l,e[7]=f,e[8]=m):m=e[8],m}let d;return e[9]!==a||e[10]!==i?(d=i?n.jsx(ue,{name:"play",className:Ye("size-4 shrink-0",a)}):null,e[9]=a,e[10]=i,e[11]=d):d=e[11],d},gw=t=>{const e=qe.c(68),{directory:s,buttonClassName:r}=t,{t:o}=gt(),a=mn(bw),i=mn(ww),u=mn(yw),d=mn(vw),l=mh(d),f=mn(Sw),m=mn(kw),p=mn(jw);let h,x;e[0]!==f?(h=()=>{f()},x=[f],e[0]=f,e[1]=h,e[2]=x):(h=e[1],x=e[2]),c.useEffect(h,x);const g=As()&&go();let v;e[3]!==i||e[4]!==a?(v=i.find(P=>P.id===a)??i.find(Tw)??i[0]??ib[0],e[3]=i,e[4]=a,e[5]=v):v=e[5];const y=v;if(!g||!s||i.length===0)return null;let C;e[6]!==s?(C=async P=>{await wf(s,P.id,P.appName)||await Sc(s,P.appName)},e[6]=s,e[7]=C):C=e[7];const S=C;let N;e[8]!==S||e[9]!==p?(N=async P=>{await p(P.id),await S(P)},e[8]=S,e[9]=p,e[10]=N):N=e[10];const F=N;let _;e[11]!==s||e[12]!==o?(_=async()=>{(await wo(s)).ok&&Fe.success(o("openInApp.toast.pathCopied"))},e[11]=s,e[12]=o,e[13]=_):_=e[13];const M=_;let B;e[14]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx("div",{className:"inline-flex"}),e[14]=B):B=e[14];let T;e[15]!==S||e[16]!==y?(T=()=>{S(y)},e[15]=S,e[16]=y,e[17]=T):T=e[17];let I;e[18]!==l||e[19]!==r?(I=Ye(r,l),e[18]=l,e[19]=r,e[20]=I):I=e[20];let b;e[21]!==y.label||e[22]!==o?(b=o("openInApp.actions.openInAria",{app:y.label}),e[21]=y.label,e[22]=o,e[23]=b):b=e[23];let w;e[24]!==y.icon?(w=n.jsx(ue,{name:y.icon,className:"size-4"}),e[24]=y.icon,e[25]=w):w=e[25];let j;e[26]!==b||e[27]!==w||e[28]!==T||e[29]!==I?(j=n.jsx(yo,{render:B,children:n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:T,className:I,"aria-label":b,children:w})})}),e[26]=b,e[27]=w,e[28]=T,e[29]=I,e[30]=j):j=e[30];let R;e[31]!==y.label||e[32]!==o?(R=o("openInApp.actions.openInAria",{app:y.label}),e[31]=y.label,e[32]=o,e[33]=R):R=e[33];let L;e[34]!==R?(L=n.jsx(Dt,{side:"bottom",children:R}),e[34]=R,e[35]=L):L=e[35];let E;e[36]!==j||e[37]!==L?(E=n.jsxs(Rt,{children:[j,L]}),e[36]=j,e[37]=L,e[38]=E):E=e[38];let D;e[39]!==M?(D=()=>{M()},e[39]=M,e[40]=D):D=e[40];let U;e[41]===Symbol.for("react.memo_cache_sentinel")?(U=n.jsx(ue,{name:"file-copy",className:"h-4 w-4"}),e[41]=U):U=e[41];let V;e[42]!==o?(V=o("openInApp.actions.copyPath"),e[42]=o,e[43]=V):V=e[43];let J;e[44]!==V?(J=n.jsx("span",{className:"typography-ui-label text-foreground",children:V}),e[44]=V,e[45]=J):J=e[45];let W;e[46]!==D||e[47]!==J?(W=n.jsxs(Ts,{className:"flex items-center gap-2",onClick:D,children:[U,J]}),e[46]=D,e[47]=J,e[48]=W):W=e[48];let G;e[49]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(Dn,{}),e[49]=G):G=e[49];let le;if(e[50]!==i||e[51]!==F||e[52]!==y.id){let P;e[54]!==F||e[55]!==y.id?(P=ee=>n.jsxs(Ts,{className:"flex items-center gap-2",onClick:()=>{F(ee)},children:[n.jsx(ue,{name:ee.icon,className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:ee.label}),y.id===ee.id?n.jsx(ue,{name:"check",className:"ms-auto h-4 w-4 text-primary"}):null]},ee.id),e[54]=F,e[55]=y.id,e[56]=P):P=e[56],le=i.map(P),e[50]=i,e[51]=F,e[52]=y.id,e[53]=le}else le=e[53];let $;e[57]!==u||e[58]!==m||e[59]!==o?($=u?n.jsxs(Ts,{className:"flex items-center gap-2",onClick:()=>{m(true)},children:[n.jsx(ue,{name:"refresh",className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[57]=u,e[58]=m,e[59]=o,e[60]=$):$=e[60];let re;e[61]!==W||e[62]!==le||e[63]!==$?(re=n.jsxs(Nr,{className:"w-56 max-h-[70vh] overflow-y-auto",children:[W,G,le,$]}),e[61]=W,e[62]=le,e[63]=$,e[64]=re):re=e[64];let H;return e[65]!==E||e[66]!==re?(H=n.jsxs(Ir,{children:[E,re]}),e[65]=E,e[66]=re,e[67]=H):H=e[67],H},xw=c.memo(gw);function bw(t){return t.selectedAppId}function ww(t){return t.availableApps}function yw(t){return t.isCacheStale}function vw(t){return t.isScanning}function Sw(t){return t.initialize}function kw(t){return t.loadInstalledApps}function jw(t){return t.selectApp}function Tw(t){return t.id===lb}const Jn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Cw=({projects:t,worktreesByProject:e,directory:s,activeProjectId:r})=>{const o=Jn(s??"");if(o){const a=Er(t,e,o);if(a)return a}return t.find(a=>a.id===r)??null};function su(){const t=Yt(v=>v.projects),e=Yt(v=>v.activeProjectId),s=it(v=>v.availableWorktreesByProject),r=it(v=>v.currentSessionId),o=hh(r??null),a=it(v=>r?v.worktreeMetadata.get(r)?.path??"":""),i=it(v=>v.newSessionDraft?.open?Jn(v.newSessionDraft.bootstrapPendingDirectory??v.newSessionDraft.directoryOverride??""):""),u=it(v=>v.newSessionDraft?.open?v.newSessionDraft.target==="chat":null),d=c.useMemo(()=>Jn(a||""),[a]),l=c.useMemo(()=>Jn(o||""),[o]),f=d||l||i,m=c.useMemo(()=>Cw({projects:t,worktreesByProject:s,directory:f,activeProjectId:e}),[e,f,t,s]),p=c.useMemo(()=>Jn(f||m?.path||""),[f,m?.path]),h=c.useMemo(()=>m?{id:m.id,path:m.path}:null,[m]),x=u??ho(l),g=c.useRef(null);return c.useEffect(()=>{h&&p&&!x&&(g.current={projectRef:h,directory:p})},[p,h,x]),c.useMemo(()=>x?null:h&&p?{projectRef:h,directory:p}:g.current,[h,p,x])}const Ew=t=>{const e=qe.c(67),{buttonClassName:s}=t,{t:r}=gt(),o=gh(),a=K(Rw),[i,u]=c.useState(false),d=K(Dw);let l;e[0]!==d?(l=bs(Es("open_project_actions",d),""),e[0]=d,e[1]=l):l=e[1];const f=l,m=o?.available?o.shown:null;let p;e[2]!==o||e[3]!==m?(p=m&&o?o.runOf(m):null,e[2]=o,e[3]=m,e[4]=p):p=e[4];const h=p;xh(true);let x;e[5]!==h?(x=re=>h?re.getDirectoryState(h.directory)?.tabs.find(H=>H.id===h.tabId)?.previewUrl??null:null,e[5]=h,e[6]=x):x=e[6];const g=Ct(x);if(!o||!m)return null;let v;e[7]!==m.name||e[8]!==h||e[9]!==r?(v=h?r("projectActions.actions.stopNamedAria",{name:m.name}):r("projectActions.actions.runNamedAria",{name:m.name}),e[7]=m.name,e[8]=h,e[9]=r,e[10]=v):v=e[10];const y=v;let C;e[11]!==s||e[12]!==a||e[13]!==g||e[14]!==h||e[15]!==r?(C=h&&g?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:()=>a(h.directory,g),className:s,"aria-label":r("projectActions.actions.openPreview"),children:n.jsx(ue,{name:"global",className:"size-4"})})}),n.jsx(Dt,{side:"bottom",children:r("projectActions.actions.openPreview")})]}):null,e[11]=s,e[12]=a,e[13]=g,e[14]=h,e[15]=r,e[16]=C):C=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("div",{className:"inline-flex"}),e[17]=S):S=e[17];let N;e[18]!==o||e[19]!==m?(N=()=>o.toggle(m),e[18]=o,e[19]=m,e[20]=N):N=e[20];const F=o.isLoading||h?.status==="stopping",_=i&&"text-foreground";let M;e[21]!==s||e[22]!==_?(M=Ye(s,_),e[21]=s,e[22]=_,e[23]=M):M=e[23];let B;e[24]!==m||e[25]!==h?(B=h?n.jsx(dl,{run:h,large:true}):n.jsx(ue,{name:Bi(m),className:"size-4"}),e[24]=m,e[25]=h,e[26]=B):B=e[26];let T;e[27]!==y||e[28]!==M||e[29]!==B||e[30]!==N||e[31]!==F?(T=n.jsx(yo,{render:S,children:n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:N,disabled:F,className:M,"aria-label":y,children:B})})}),e[27]=y,e[28]=M,e[29]=B,e[30]=N,e[31]=F,e[32]=T):T=e[32];let I;e[33]!==y?(I=n.jsx("span",{children:y}),e[33]=y,e[34]=I):I=e[34];let b;e[35]!==r?(b=r("projectActions.header.allActions"),e[35]=r,e[36]=b):b=e[36];let w;e[37]!==f||e[38]!==b?(w=n.jsx("span",{className:"typography-micro text-muted-foreground",children:n.jsx(qs,{label:b,shortcut:f})}),e[37]=f,e[38]=b,e[39]=w):w=e[39];let j;e[40]!==I||e[41]!==w?(j=n.jsx(Dt,{side:"bottom",children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[I,w]})}),e[40]=I,e[41]=w,e[42]=j):j=e[42];let R;e[43]!==T||e[44]!==j?(R=n.jsxs(Rt,{children:[T,j]}),e[43]=T,e[44]=j,e[45]=R):R=e[45];const L=o.openSettings;let E;e[46]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(ue,{name:"add",className:"h-4 w-4"}),e[46]=E):E=e[46];let D;e[47]!==r?(D=r("projectActions.actions.addNewAction"),e[47]=r,e[48]=D):D=e[48];let U;e[49]!==D?(U=n.jsx("span",{className:"typography-ui-label text-foreground",children:D}),e[49]=D,e[50]=U):U=e[50];let V;e[51]!==o.openSettings||e[52]!==U?(V=n.jsxs(Ts,{className:"flex items-center gap-2",onClick:L,children:[E,U]}),e[51]=o.openSettings,e[52]=U,e[53]=V):V=e[53];let J;e[54]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx(Dn,{}),e[54]=J):J=e[54];let W;e[55]!==o||e[56]!==r?(W=o.actions.map(re=>n.jsxs(Ts,{className:"flex items-center gap-2",onClick:()=>{o.select(re),o.toggle(re)},children:[n.jsx(ue,{name:Bi(re),className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground truncate",children:re.name}),re.source==="shared"?n.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,n.jsx(dl,{run:o.runOf(re),className:"ms-auto"})]},re.id)),e[55]=o,e[56]=r,e[57]=W):W=e[57];let G;e[58]!==V||e[59]!==W?(G=n.jsxs(Nr,{className:"w-60 max-h-[70vh] overflow-y-auto",children:[V,J,W]}),e[58]=V,e[59]=W,e[60]=G):G=e[60];let le;e[61]!==R||e[62]!==G?(le=n.jsxs(Ir,{onOpenChange:u,children:[R,G]}),e[61]=R,e[62]=G,e[63]=le):le=e[63];let $;return e[64]!==le||e[65]!==C?($=n.jsxs(n.Fragment,{children:[C,le]}),e[64]=le,e[65]=C,e[66]=$):$=e[66],$},Iw=c.memo(Ew),Nw=t=>{const e=qe.c(8),{buttonClassName:s}=t,r=su();if(!r)return null;let o;e[0]!==s||e[1]!==r.directory?(o=n.jsx(xw,{directory:r.directory,buttonClassName:s}),e[0]=s,e[1]=r.directory,e[2]=o):o=e[2];let a;e[3]!==s?(a=n.jsx(Iw,{buttonClassName:s}),e[3]=s,e[4]=a):a=e[4];let i;return e[5]!==o||e[6]!==a?(i=n.jsxs(n.Fragment,{children:[o,a]}),e[5]=o,e[6]=a,e[7]=i):i=e[7],i},Pw=c.memo(Nw);function Rw(t){return t.openContextPreview}function Dw(t){return t.shortcutOverrides}const Zo="--oc-titlebar-controls-width",Sa=new Set;let sr=null;const nu=t=>{sr===null?t.style.removeProperty(Zo):t.style.getPropertyValue(Zo)!==sr&&t.style.setProperty(Zo,sr)},_w=t=>{const e=`${Math.round(t)}px`;e!==sr&&(sr=e,Sa.forEach(nu))},ru=t=>{if(t)return Sa.add(t),nu(t),()=>{Sa.delete(t)}},Kn="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",qn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Aw=()=>{yf("ui.header.render");const{t,direction:e}=gt(),s=K(X=>X.isSidebarOpen),r=vo(),o=K(X=>X.sessionTabsEnabled),a=it(X=>!!X.newSessionDraft?.open),i=it(X=>X.currentSessionId),u=os(wa(c.useCallback(X=>{if(!i)return null;const mt=[...X.activeSessions,...X.archivedSessions].find($t=>$t.id===i);if(!mt)return null;const jt=mt;return{title:mt.title??null,directory:jt.directory??null,created:mt.time?.created??null,slug:jt.slug??null}},[i]))),d=Yt(wa(X=>{if(!X.activeProjectId)return null;const mt=X.projects.find(jt=>jt.id===X.activeProjectId);return mt?{id:mt.id,path:mt.path,label:mt.label}:null})),l=c.useMemo(()=>{if(!d)return null;const X=d.label?.trim();if(X)return X;const mt=d.path.split(/[\\/]/).filter(Boolean);return mt[mt.length-1]??null},[d]),{isMobile:f}=Tn(),m=c.useRef(null),[p,h]=c.useState(()=>typeof window>"u"?false:As()),x=c.useMemo(()=>eo(),[]),g=bh(),[v,y]=c.useState(false),C=c.useMemo(()=>typeof navigator>"u"?false:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:S,side:N}=Vd(),F=c.useMemo(()=>{if(typeof window>"u")return null;const X=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof X=="number"&&Number.isFinite(X)&&X>0)return X;if(typeof navigator>"u")return null;const mt=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!mt)return null;const jt=Number.parseInt(mt[1],10),$t=Number.parseInt(mt[2],10);return Number.isNaN(jt)?null:jt===10?$t:jt},[]);Kt.useEffect(()=>{typeof window>"u"||h(As())},[]);const _=c.useMemo(()=>zn(),[]),M=K(X=>X.shortcutOverrides),B=K(X=>X.workStatusPanelVisible),T=K(X=>X.workStatusPanelEnabled),I=K(X=>X.setWorkStatusPanelEnabled),b=K(X=>X.workStatusPanelFits),w=K(X=>X.workStatusOverlayOpen),j=K(X=>X.setWorkStatusOverlayOpen),L=T&&b||w,E=c.useCallback(()=>{if(T&&!b){j(!w);return}I(!T)},[j,I,w,T,b]),D=i?u??null:null,U=c.useRef(null),[V,J]=c.useState(0);c.useEffect(()=>{if(!i){U.current&&(U.current=null,J($t=>$t+1));return}if(D){U.current={sessionId:i,session:D,expiresAt:Date.now()+2e3};return}const X=U.current;if(!X||X.sessionId!==i)return;const mt=X.expiresAt-Date.now();if(mt<=0){U.current=null,J($t=>$t+1);return}const jt=window.setTimeout(()=>{U.current?.sessionId===i&&(U.current=null),J($t=>$t+1)},mt);return()=>{window.clearTimeout(jt)}},[i,D]);const W=(()=>{if(D)return D;if(!i)return null;const X=U.current;return X&&X.sessionId===i&&X.expiresAt>Date.now()?X.session:null})(),G=it(X=>i?X.worktreeMetadata.get(i)?.path??"":""),le=it(X=>i?X.worktreeMetadata.get(i)?.branch?.trim()??null:null),$=ed(X=>i?X.getAttachment(i):void 0),re=c.useMemo(()=>$?wh($,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,$]),H=c.useMemo(()=>$?$.legacy?"legacy":$.degraded?"degraded":$.worktreeStatus==="pending"?"pending":$.worktreeStatus==="missing"?"missing":$.worktreeStatus==="invalid"?"invalid":$.attentionReason?"attention":null:null,[$]),P=c.useMemo(()=>qn(G||""),[G]),ee=c.useMemo(()=>{const X=typeof W?.directory=="string"?W.directory:"";return qn(X||"")},[W?.directory]),oe=Oc(i??"",ee),de=it(X=>X.newSessionDraft?.open?qn(X.newSessionDraft.bootstrapPendingDirectory??X.newSessionDraft.directoryOverride??""):""),he=it(X=>X.newSessionDraft.target),Z=it(X=>X.newSessionDraft.selectedProjectId),ce=it(X=>X.currentSessionDirectory),ae=qt(X=>X.homeDirectory),te=Pr(),pe=c.useMemo(()=>P||ee||(So(te,de)??""),[de,te,ee,P]),Te=it(X=>{const mt=qn(P||ee||"");if(!mt)return null;for(const jt of X.availableWorktreesByProject.values()){const Q=so(jt,mt)?.branch?.trim();if(Q)return Q}return null}),Pe=yh(pe||null)||le||Te,ze=a?he==="chat":vc(ee||ce,ae),Oe=!ze&&!B&&!!(l||Pe||!a&&H),me=c.useMemo(()=>{if(!i)return l??"OpenChamber";const X=W?.title?.trim();return X&&X.length>0?X:"Untitled Session"},[l,W?.title,i]),be=it(X=>X.updateSessionTitle),Ce=it(X=>X.archiveSessions),$e=it(X=>X.deleteSessions),[We,_e]=c.useState(false),[Ue,Xe]=c.useState(false),Me=c.useRef(null),[ot,ye]=c.useState(""),[Ve,lt]=c.useState(null),ct=Tp(),[st,k]=c.useState(null),Y=os(X=>st&&X.entityById.get(st)?.title?.trim()||null)??t("sessions.sidebar.session.untitled"),Ne=c.useRef(null),Re=c.useRef(false);Re.current=We;const Ie=c.useCallback(()=>{i&&(Re.current=true,ye(W?.title?.trim()||me),_e(true))},[W?.title,i,me]),Ee=c.useRef(Ie);Ee.current=Ie;const Ge=c.useCallback(X=>{X&&(X.focus(),X.select())},[]);c.useEffect(()=>{if(Xe(false),k(null),i&&Me.current===i){Me.current=null,Ee.current();return}_e(false),ye("")},[i]);const Be=c.useCallback(async()=>{if(!i)return;const X=ot.trim();X&&X!==W?.title?.trim()&&await be(i,X),_e(false)},[W?.title,i,ot,be]);c.useEffect(()=>{if(!We)return;const X=mt=>{const jt=mt.target;(!jt||!Ne.current?.contains(jt))&&Be()};return document.addEventListener("mousedown",X),()=>document.removeEventListener("mousedown",X)},[We,Be]);const Ze=c.useCallback(async(X,mt)=>{const jt=[mt,...vh(mt,[],X==="delete")],$t=it.getState().currentSessionId===mt?mt:null;if(X==="delete"){const{failedIds:St}=await $e(jt);St.length>0?Fe.error(t("sessions.sidebar.session.delete.error")):Fe.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:Q,failedIds:tt}=await Ce(jt);if(tt.length>0){Fe.error(t("sessions.sidebar.session.archive.error"));return}Fe.success(t("sessions.sidebar.session.archive.success"),Sh(Q,$t,t))},[Ce,$e,t]),et=c.useCallback(async()=>{st&&(k(null),await Ze("delete",st))},[st,Ze]),wt=K(X=>X.openGuestPageId),Qe=cr(X=>X.guests.find(mt=>mt.id===wt)),dt=K(X=>X.isScheduledTasksDialogOpen),at=K(X=>X.isArchivePageOpen),z=K(X=>X.isIntegrationsCatalogOpen),fe=K(X=>X.isUsageStatsPageOpen),ke=K(X=>X.isSourceBoardOpen),ie=K(X=>X.isOverviewOpen),xe=K(X=>X.worktreesPageProjectId),Le=K(X=>X.isolatedSpacesEnabled?X.spacesPageProjectId:null),Ke=K(X=>X.runOverviewKey),ve=Cp(Ke),je=xe??Le,vt=Yt(X=>{if(!je)return null;const mt=X.projects.find(jt=>jt.id===je);return mt?.label?.trim()||mt?.path?.split("/").pop()||null}),ne=c.useMemo(()=>Qe?{title:Qe.pageTitle??Qe.name,subtitle:null}:dt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:at?{title:t("sessions.archivePage.title"),subtitle:null}:z?{title:t("integrationsCatalog.page.title"),subtitle:null}:fe?{title:t("usageStats.title"),subtitle:null}:ke?{title:t("sourceBoard.title"),subtitle:null}:ie?{title:t("overview.title"),subtitle:null}:xe?{title:t("sessions.worktreesPage.title",{project:vt??""}),subtitle:null}:Le?{title:t("spaces.page.title",{project:vt??""}),subtitle:null}:Ke?{title:ve??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[Qe,at,z,ve,Ke,dt,ke,ie,fe,Le,vt,t,xe]),Je=c.useCallback(()=>{on("desktop_open_draft_mini_chat_window",{directory:ze?"":de,projectId:ze?null:Z,...ca()}).catch(X=>{console.warn("[header] failed to open draft mini chat window",X)})},[de,Z,ze]),kt=c.useCallback(()=>{if(a){Je();return}i&&on("desktop_open_session_mini_chat_window",{sessionId:i,directory:ee||qn(ce||"")||P,...ca()}).catch(X=>{console.warn("[header] failed to open session mini chat window",X)})},[i,Je,a,ce,ee,P]),bt=x&&(a||!!i),_t=Kn,He=c.useMemo(()=>p&&C&&!v?"88px":g?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!p||S)&&!_?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[p,v,C,g,_,S]),pt=(!p||S)&&!_?"calc(0.625rem + var(--oc-wco-right-inset, 0px))":"0.625rem",q=e==="rtl",se=q?pt:He,De=q?He:pt,we=S&&N!==kc(e);Kt.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",se)},[se]);const rt=s?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",ft=s?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";Kt.useEffect(()=>{if(!p||!C){y(false);return}let X=false;const mt=async()=>{try{const $t=await on("desktop_is_window_fullscreen");X||y($t===true)}catch{X||y(false)}},jt=()=>{mt()};return mt(),window.addEventListener("openchamber:window-resized",jt),()=>{X=true,window.removeEventListener("openchamber:window-resized",jt)}},[p,C]);const nt=c.useMemo(()=>!p||!C||F===null?"":F>=26?"h-11":F<=15?"h-14":"",[p,C,F]),ut=c.useMemo(()=>p&&C&&!v?F!==null&&F<=15?"56px":"44px":"0px",[p,v,C,F]),Nt=c.useMemo(()=>{const mt=`max(${p&&C?"2.75rem":"3rem"}, ${ut}, var(--oc-wco-titlebar-height, 0px))`,jt=p&&!S||_;if(jt&&ut==="0px")return{};const $t={minHeight:mt,height:mt};return!we&&(!jt||q)&&($t.paddingInlineEnd=De),$t},[we,p,C,q,_,De,ut,S]),Et=c.useRef(null),Ft=c.useCallback(X=>{!X||X===Et.current||(Et.current=X,document.documentElement.style.setProperty("--oc-header-height",`${X}px`))},[]),Wt=c.useCallback(()=>{typeof document>"u"||Ft(m.current?.getBoundingClientRect().height)},[Ft]);Kt.useEffect(()=>{if(typeof window>"u")return;Wt();const X=m.current;if(!X||typeof ResizeObserver>"u")return()=>{};let mt=0;const jt=()=>{mt||(mt=requestAnimationFrame(()=>{mt=0,Wt()}))},$t=new ResizeObserver(Q=>{const tt=Q[Q.length-1];Ft(tt?.borderBoxSize?.[0]?.blockSize??tt?.target.getBoundingClientRect().height)});return $t.observe(X),window.addEventListener("resize",jt),window.addEventListener("orientationchange",jt),()=>{mt&&cancelAnimationFrame(mt),$t.disconnect(),window.removeEventListener("resize",jt),window.removeEventListener("orientationchange",jt)}},[Ft,Wt]),Kt.useEffect(()=>{Wt()},[Wt,f,nt]);const is=c.useCallback(async X=>{const mt=X.target;mt.closest(".app-region-no-drag")||mt.closest("button, a, input, select, textarea")||X.button===0&&p&&await vf()},[p]);td({rename_current_session:()=>{if(!i||f)return false;Ie()},archive_current_session:()=>{if(!i||f||os.getState().entityById.get(i)?.time.archived)return false;Ze("archive",i)}});const Gt=c.useCallback((X,mt)=>{lt({sessionId:X,directory:mt})},[]),ns=ct.requestExport,ms=c.useCallback(({session:X,open:mt,isActive:jt,select:$t,closeOtherTabs:Q,components:tt})=>{const{Item:St,Separator:Tt}=tt;return n.jsxs(n.Fragment,{children:[n.jsx(Ep,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:n.jsxs(St,{onClick:Q,className:"[&>svg]:me-1",children:[n.jsx(ue,{name:"close-circle",className:"me-1 h-4 w-4"}),t("header.sessionTabs.closeOtherTabs")]})}),n.jsx(Tt,{}),n.jsx(il,{sessionId:X.id,open:mt,slots:tt,onRename:()=>{jt||$t(),Me.current=X.id},onExport:ns,onMoveSession:Gt,onArchive:()=>{Ze("archive",X.id)},onDelete:()=>k(X.id)})]})},[ns,Gt,Ze,t]),Ns=()=>n.jsxs("div",{onMouseDown:is,className:Ye("app-region-drag relative flex h-12 select-none items-center",we?"pe-0":"pe-2.5",nt),style:Nt,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[n.jsx("div",{"aria-hidden":true,className:"shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:rt,transitionDuration:`${r}ms`,transitionTimingFunction:Mn}}),n.jsx("div",{ref:ru,"aria-hidden":true,className:"app-region-no-drag shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:ft,transitionDuration:`${r}ms`,transitionTimingFunction:Mn}}),n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[ne?n.jsxs(n.Fragment,{children:[n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{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:()=>K.getState().closeMainSurfaces(),children:n.jsx(ue,{name:"arrow-left",className:"size-4"})})}),n.jsx(Dt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),n.jsxs("div",{className:"me-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-start",children:[n.jsx("span",{className:"truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:ne.title}),ne.subtitle?n.jsx("span",{className:"truncate typography-micro text-[0.65625rem] font-normal leading-tight text-muted-foreground max-w-full",children:ne.subtitle}):null]})]}):_||!o?n.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:[oe?n.jsx(ue,{name:"loader-4",className:"me-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,s?null:n.jsxs(Rt,{children:[n.jsx(Qx,{align:"start",children:n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",className:_t,"aria-label":t("sessions.switcher.openAria"),children:n.jsx(ue,{name:"history",className:"h-4 w-4"})})})}),n.jsx(Dt,{side:"bottom",children:n.jsx(qs,{label:t("sessions.switcher.openAria"),shortcut:bs(Es("open_session_list",M),"")})})]}),n.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[We?n.jsxs("form",{ref:Ne,"data-session-rename-form":"header",className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:X=>X.stopPropagation(),onSubmit:X=>{X.preventDefault(),Be()},children:[n.jsx("input",{ref:Ge,value:ot,onChange:X=>ye(X.target.value),onKeyDown:X=>Ai(X,()=>_e(false)),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"}),n.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:n.jsx(ue,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>_e(false),"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:n.jsx(ue,{name:"close",className:"size-4"})})]}):a?null:n.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:me}),Oe?n.jsxs("span",{className:Ye("flex min-w-0 max-w-full items-center gap-1.5 truncate font-normal leading-tight",a?"typography-ui-label text-[0.875rem] text-foreground":"typography-micro text-[0.65625rem] text-muted-foreground"),children:[l?n.jsx("span",{dir:"auto",className:"truncate",children:l}):null,Pe?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx(ue,{name:"git-branch",className:Ye("flex-shrink-0 text-muted-foreground",a?"h-3.5 w-3.5":"h-3 w-3")}),n.jsx("span",{dir:"ltr",className:Ye("truncate",a&&"text-muted-foreground"),children:Pe})]}):null,!a&&H?n.jsxs("span",{className:Ye("inline-flex min-w-0 items-center gap-0.5",H==="attention"||H==="invalid"||H==="missing"?"text-status-warning":"text-muted-foreground"),children:[n.jsx(ue,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"truncate",children:re})]}):null]}):null]}),n.jsx("div",{className:Ye("flex h-[1.125rem] shrink-0 items-center justify-center",Oe?"self-start":"self-center"),children:i&&!a&&!We?n.jsxs(Sn,{open:Ue,onOpenChange:Xe,onOpenChangeComplete:X=>{!X&&Me.current&&Me.current===i&&(Me.current=null,Ie())},children:[n.jsx(kn,{asChild:true,children:n.jsx(yt,{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:n.jsx(ue,{name:"more",className:"size-4"})})}),n.jsx(jn,{align:"end",className:"min-w-[190px]",children:n.jsx(il,{sessionId:i,open:Ue,slots:Ip,onRename:()=>{Me.current=i},onExport:ns,onMoveSession:Gt,onArchive:()=>{Ze("archive",i)},onDelete:()=>k(i)})})]}):null})]}):n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-start",children:n.jsx(Eb,{renderMenu:ms,suppressActiveTabControls:We,menuReturnsFocus:()=>!Re.current,onMenuOpenChangeComplete:X=>{!X&&Me.current&&Me.current===i&&(Me.current=null,Ie())},children:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:We?n.jsxs("form",{ref:Ne,"data-session-rename-form":"header",className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:X=>X.stopPropagation(),onSubmit:X=>{X.preventDefault(),Be()},children:[n.jsx("input",{ref:Ge,value:ot,onChange:X=>ye(X.target.value),onKeyDown:X=>Ai(X,()=>_e(false)),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"}),n.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:n.jsx(ue,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>_e(false),"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:n.jsx(ue,{name:"close",className:"size-4"})})]}):n.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:a?t("sessions.switcher.draftTitle"):me})})})}),ne||_||!o?n.jsx("div",{className:"flex-1"}):null,n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!_&&!ne?n.jsxs(n.Fragment,{children:[n.jsx(pw,{buttonClassName:Kn}),n.jsx(Pw,{buttonClassName:Kn})]}):null,bt?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button","aria-label":t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:kt,className:Kn,children:n.jsx(ue,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),n.jsx(Dt,{side:"bottom",children:n.jsx(qs,{label:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),shortcut:a?bs(Es("new_mini_chat",M),""):void 0})})]}):null,_?null:n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":L,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:E,className:Ye(Kn,L&&"oc-selected text-interactive-selection-foreground hover:text-interactive-selection-foreground"),children:n.jsx(ue,{name:"panel-card",className:"h-4 w-4"})})}),n.jsx(Dt,{side:"bottom",children:t(T&&!b?w?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":T?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),n.jsx(Ud,{visible:we,position:N})]})]})]});return n.jsxs(n.Fragment,{children:[n.jsx("header",{ref:m,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:Ns()}),Ve?n.jsx(kh,{open:true,onOpenChange:X=>{X||lt(null)},sessionId:Ve.sessionId,sourceDirectory:Ve.directory}):null,ct.dialog,n.jsx(dr,{open:st!==null,onOpenChange:X=>{X||k(null)},children:n.jsxs(ur,{showCloseButton:false,className:"max-w-sm gap-5",children:[n.jsxs(fr,{children:[n.jsx(pr,{children:t("sessions.sidebar.dialogs.deleteSession.title")}),n.jsx(mr,{children:t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Y})})]}),n.jsxs(no,{children:[n.jsx(yt,{variant:"outline",size:"sm",onClick:()=>k(null),children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(yt,{variant:"destructive",size:"sm",onClick:()=>{et()},children:t("sessions.sidebar.bulkActions.delete")})]})]})})]})},ul=280,fl=264,pl=500,Ow=({isOpen:t,isMobile:e,children:s,className:r,topBar:o,peek:a})=>{const{t:i,direction:u}=gt(),d=K(W=>W.sidebarWidth),l=K(W=>W.setSidebarWidth),[f,m]=c.useState(false),p=c.useRef(0),h=c.useRef(d||ul),x=c.useRef(null),g=c.useRef(null),v=c.useRef(null),y=c.useRef(null),C=c.useRef(null),S=c.useCallback(W=>Math.min(pl,Math.max(fl,W)),[]),N=c.useCallback(()=>{const W=C.current;if(W?.isConnected)return W;const G=document.querySelector("[data-titlebar-left-controls]");return C.current=G,G},[]),F=c.useCallback(W=>{const G=y.current;if(!G)return;G.style.width=`${W}px`,G.style.minWidth=`${W}px`,G.style.maxWidth=`${W}px`,G.style.setProperty("--oc-left-sidebar-width",`${W}px`);const le=N();le&&le.style.setProperty("--oc-left-sidebar-width",`${W}px`)},[N]);c.useEffect(()=>{e&&f&&m(false)},[e,f]),c.useEffect(()=>{f||(x.current=null,g.current=null,v.current?.(),v.current=null)},[f]),c.useEffect(()=>{!t&&f&&m(false)},[t,f]),c.useEffect(()=>()=>{v.current?.(),v.current=null},[]);const _=Math.min(pl,Math.max(fl,d||ul)),M=t?_:0,B=f?x.current??M:M,T=f?B:_;c.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${T}px`);const W=C.current;!f&&W&&W.style.removeProperty("--oc-left-sidebar-width")},[T,f]);const[I,b]=c.useState(!t);t&&I&&b(false);const w=vo(),j=c.useRef(t),R=c.useRef(t);if(c.useLayoutEffect(()=>{j.current=t,R.current!==t&&(R.current=t,sd(w),t||hr(()=>{j.current||b(true)}))},[t,w]),e)return null;const L=W=>{if(t){try{W.currentTarget.setPointerCapture(W.pointerId)}catch{}g.current=W.pointerId,m(true),p.current=W.clientX,h.current=M,x.current=M,F(M),v.current?.(),v.current=nd(),W.preventDefault()}},E=W=>{if(e||!f||g.current!==W.pointerId)return;const G=(W.clientX-p.current)*(u==="rtl"?-1:1),le=S(h.current+G);x.current!==le&&(x.current=le,F(le))},D=W=>{if(g.current!==W.pointerId||e)return;try{W.currentTarget.releasePointerCapture(W.pointerId)}catch{}const G=S(x.current??M);g.current=null,x.current=null,m(false),l(G),v.current?.(),v.current=null},U=!t&&a?a.state:false,V=U!==false,J=V&&a&&a.animationMs>0?`${U==="in"?"oc-sidebar-peek-in":"oc-sidebar-peek-out"} ${a.animationMs}ms ${Mn} forwards`:void 0;return n.jsxs("div",{ref:y,"data-left-sidebar":"",className:Ye("relative flex h-full",!V&&"overflow-hidden",f?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",r),style:{width:`${B}px`,minWidth:`${B}px`,maxWidth:`${B}px`,"--oc-left-sidebar-width":`${T}px`,overflowX:V?void 0:"clip",transitionDuration:`${w}ms`,transitionTimingFunction:Mn},children:[t&&n.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&&n.jsx("div",{className:Ye("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:L,onPointerMove:E,onPointerUp:D,onPointerCancel:D,onLostPointerCapture:D,role:"separator","aria-orientation":"vertical","aria-label":i("sidebar.resize.leftPanelAria")}),n.jsxs("aside",{ref:a?.overlayRef,"data-sidebar-peek":V?U:void 0,className:Ye("flex h-full shrink-0 flex-col",V?"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&&!V&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${w}ms`,overflowX:"hidden",contentVisibility:I&&!V?"hidden":void 0,animation:J,"--oc-peek-offset":u==="rtl"?"100%":"-100%"},inert:!t&&!V||void 0,onPointerEnter:V?a?.overlayHandlers.onPointerEnter:void 0,onPointerLeave:V?a?.overlayHandlers.onPointerLeave:void 0,onAnimationEnd:V?a?.overlayHandlers.onAnimationEnd:void 0,children:[o,n.jsx(ps,{outerClassName:"overlay-scrollbar-wrapper--no-gutter flex-1 min-h-0",disableHorizontal:true,children:n.jsx(Jt,{children:s})})]})]})},Mw=t=>{const e=qe.c(5),{actionsSlotRef:s}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={height:"var(--oc-header-height, 3rem)"},e[0]=r):r=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{"aria-hidden":true,className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-start-inset, 0.75rem)"}}),e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{"aria-hidden":true,ref:ru,className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),e[2]=a):a=e[2];let i;return e[3]!==s?(i=n.jsxs("div",{className:"flex shrink-0",style:r,children:[o,a,n.jsx("div",{className:"app-region-drag flex min-w-0 flex-1 items-center justify-end",children:n.jsx("div",{ref:s,className:"app-region-no-drag flex items-center"})})]}),e[3]=s,e[4]=i):i=e[4],i},Fw=50,Lw=18,$w=300,Bw='[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]',ou=t=>!document.getElementById("root")?.contains(t),zw=t=>{if((mo(document.documentElement)?window.innerWidth-t.clientX:t.clientX)>Lw)return false;const s=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--oc-header-height"))||48;return t.clientY>=s},ml=t=>{const e=document.activeElement;return t&&e instanceof HTMLElement&&t.contains(e)&&(e.isContentEditable||e.matches("input, textarea"))?true:Array.from(document.querySelectorAll(Bw)).some(s=>ou(s)&&s.getClientRects().length>0)},Ww=({enabled:t,layoutAnimationMs:e})=>{const[s,r]=c.useState(false),o=jh()?0:e,a=o>0,i=c.useRef(null),u=c.useRef(null),d=c.useRef(null),l=c.useCallback(()=>{u.current!==null&&clearTimeout(u.current),d.current!==null&&clearTimeout(d.current),u.current=null,d.current=null},[]),f=c.useCallback(()=>{l(),r(x=>x==="in"&&a?"out":false)},[a,l]),m=c.useCallback(()=>{d.current!==null&&clearTimeout(d.current),d.current=setTimeout(()=>{if(d.current=null,ml(i.current)){m();return}f()},$w)},[f]),p=c.useCallback(()=>{d.current!==null&&clearTimeout(d.current),d.current=null},[]);c.useEffect(()=>{t||(l(),r(false))},[l,t]),c.useEffect(()=>l,[l]),c.useEffect(()=>{if(s!=="in")return;const x=y=>{const C=y.target;C instanceof Element&&(i.current?.contains(C)||ou(C)||f())},g=y=>{rd(y)||y.key!=="Escape"||y.defaultPrevented||ml(i.current)||f()},v=y=>{y.relatedTarget===null&&m()};return document.addEventListener("pointerdown",x,true),document.addEventListener("keydown",g),document.addEventListener("pointerout",v),()=>{document.removeEventListener("pointerdown",x,true),document.removeEventListener("keydown",g),document.removeEventListener("pointerout",v)}},[f,m,s]),c.useEffect(()=>{if(!t||s!==false)return;const x=()=>{u.current!==null&&clearTimeout(u.current),u.current=null},g=y=>{if(y.pointerType!=="mouse"||y.buttons!==0||!zw(y)){x();return}u.current===null&&(u.current=setTimeout(()=>{u.current=null,r("in")},Fw))},v=y=>{y.relatedTarget===null&&x()};return document.addEventListener("pointermove",g,{passive:true}),document.addEventListener("pointerout",v),()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerout",v),x()}},[t,s]);const h=c.useMemo(()=>({onPointerEnter:()=>{p(),r(x=>x==="out"?"in":x)},onPointerLeave:()=>{s==="in"&&m()},onAnimationEnd:x=>{x.target===x.currentTarget&&r(g=>g==="out"?false:g)}}),[p,m,s]);return{state:t?s:false,animationMs:o,overlayRef:i,overlayHandlers:h}},Xo="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",Vw=()=>{const t=qe.c(46),{t:e,locale:s,direction:r}=gt(),o=K(Uw),a=K(Hw),i=K(Kw),u=c.useRef(null),d=bs(Es("toggle_sidebar",i)),l=qw,f=K(Gw),{usesFramelessChrome:m,side:p}=Vd();let h;t[0]!==s?(h=G=>{const le=G.currentTarget.getBoundingClientRect();on("desktop_show_app_menu",{x:le.left,y:le.bottom,locale:s}).catch(Zw)},t[0]=s,t[1]=h):h=t[1];const x=h;let g,v;t[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{if(typeof document>"u")return;const G=u.current;if(!G)return;const le=()=>{const re=Math.max(G.getBoundingClientRect().width,G.scrollWidth);_w(re)};if(le(),typeof ResizeObserver>"u")return;const $=new ResizeObserver(le);return $.observe(G),()=>{$.disconnect()}},v=[],t[2]=g,t[3]=v):(g=t[2],v=t[3]),c.useEffect(g,v);const y="",C="app-region-no-drag absolute inset-s-0 top-0 z-30 flex select-none items-center pe-2",S=a?"var(--oc-left-sidebar-width, 100%)":void 0;let N;t[4]!==S?(N={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:S},t[4]=S,t[5]=N):N=t[5];const F="flex min-w-0 items-center gap-2";let _;t[6]!==r||t[7]!==m||t[8]!==p?(_=m&&p===kc(r)?n.jsx(Ud,{visible:true,position:p}):null,t[6]=r,t[7]=m,t[8]=p,t[9]=_):_=t[9];let M;t[10]!==x||t[11]!==e||t[12]!==m?(M=m?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:x,"aria-label":e("header.actions.openAppMenuAria"),className:Ye(Xo,"shrink-0"),children:n.jsx(ue,{name:"menu-2",className:"h-4 w-4"})})}),n.jsx(Dt,{children:n.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=x,t[11]=e,t[12]=m,t[13]=M):M=t[13];const B=Rt;let T;t[14]!==e?(T=e("header.actions.openSessionsAria"),t[14]=e,t[15]=T):T=t[15];const I=a&&"text-foreground";let b;t[16]!==I?(b=Ye(Xo,"shrink-0",I),t[16]=I,t[17]=b):b=t[17];let w;t[18]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(ue,{name:"panel-left",className:"h-4 w-4"}),t[18]=w):w=t[18];let j;t[19]!==a||t[20]!==T||t[21]!==b||t[22]!==o?(j=n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":T,"aria-pressed":a,className:b,children:w})}),t[19]=a,t[20]=T,t[21]=b,t[22]=o,t[23]=j):j=t[23];const R=Dt,L=e("header.actions.openSessionsWithShortcut",{shortcut:d});let E;t[24]!==L?(E=n.jsx("p",{children:L}),t[24]=L,t[25]=E):E=t[25];let D;t[26]!==R||t[27]!==E?(D=n.jsx(R,{children:E}),t[26]=R,t[27]=E,t[28]=D):D=t[28];let U;t[29]!==B||t[30]!==j||t[31]!==D?(U=n.jsxs(B,{children:[j,D]}),t[29]=B,t[30]=j,t[31]=D,t[32]=U):U=t[32];let V;t[33]!==l||t[34]!==i||t[35]!==e||t[36]!==f?(V=f?null:n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:l,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Ye(Xo,"-ms-1 shrink-0"),children:n.jsx(ue,{name:"edit-box",className:"h-4 w-4"})})}),n.jsx(Dt,{children:n.jsx(qs,{label:e("sessions.sidebar.header.actions.newSession"),shortcut:bs(Es("new_chat",i),"")})})]}),t[33]=l,t[34]=i,t[35]=e,t[36]=f,t[37]=V):V=t[37];let J;t[38]!==U||t[39]!==V||t[40]!==_||t[41]!==M?(J=n.jsxs("div",{ref:u,className:F,children:[_,M,U,V]}),t[38]=U,t[39]=V,t[40]=_,t[41]=M,t[42]=J):J=t[42];let W;return t[43]!==J||t[44]!==N?(W=n.jsx("div",{"data-titlebar-left-controls":y,className:C,style:N,children:J}),t[43]=J,t[44]=N,t[45]=W):W=t[45],W};function Uw(t){return t.toggleSidebar}function Hw(t){return t.isSidebarOpen}function Kw(t){return t.shortcutOverrides}function qw(){K.getState().closeMainSurfaces(),it.getState().openNewSessionDraft()}function Gw(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 Zw(t){console.warn("[titlebar] failed to open app menu",t)}function Xw(){const t=qe.c(2),e=Th();let s;return t[0]!==e?(s=n.jsx("div",{className:"h-full min-h-0 overflow-y-auto",children:n.jsx(Np,{onOpen:(r,o)=>e(r.receivedId,o)})}),t[0]=e,t[1]=s):s=t[1],s}function Yw(t,e,s){const r=qe.c(5),[o,a]=c.useState();let i,u;return r[0]!==s||r[1]!==t||r[2]!==e?(i=()=>{if(e){a(void 0);return}if(!t){a(void 0);return}a(void 0);let d=false;return(async()=>{const[l,f]=await Promise.all([Ch(t),Eh(t)]).catch(Jw);if(d)return;const m=ts(l),p=ts(f);if(!m||!p||p===m)return;const h=s||"",x=p.split("/").filter(Boolean).pop()||p;a({source:"sdk",path:p,projectDirectory:m,branch:h,label:h||x,name:x,worktreeRoot:p,worktreeStatus:"ready",headState:h?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=true}},u=[t,e,s],r[0]=s,r[1]=t,r[2]=e,r[3]=i,r[4]=u):(i=r[3],u=r[4]),c.useEffect(i,u),e??o}function Jw(){return["",""]}const Qw=()=>{const t=qe.c(3),e=K(ey),s=K(ty);let r;return t[0]!==e||t[1]!==s?(r=()=>{s("integrations"),e(true)},t[0]=e,t[1]=s,t[2]=r):r=t[2],r};function ey(t){return t.setSettingsDialogOpen}function ty(t){return t.setSettingsPage}const hl="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-edge bg-muted/80",sy=({className:t,identity:e})=>{const{t:s}=gt(),{sourceControl:r}=Is(),o=Ih(e),a=Wa(e.provider),i=a.label,u=o?.status??null,d=vn(y=>y.setStatus),[l,f]=c.useState(false),m=c.useCallback(async y=>{if(!(!y||l)){f(true);try{d(e,await r.authActivate(e,y))}catch(C){console.error("Failed to switch source control account:",C)}finally{f(false)}}},[e,l,d,r]);if(u?.status!=="connected")return null;const p=u.user.username||null,h=u.user.avatarUrl??null,x=u.accounts,g=p?s("header.sourceControl.connectedWithLogin",{login:p,provider:i}):s("header.sourceControl.connected",{provider:i}),v=h?n.jsx("img",{src:h,alt:p?s("header.sourceControl.avatarWithLogin",{login:p}):s("header.sourceControl.avatar",{provider:i}),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx(zi,{descriptor:a,variant:"fill",className:"h-3.5 w-3.5 text-foreground"});return x.length<=1?n.jsx("div",{className:Ye(hl,t),title:g,children:v}):n.jsxs(Sn,{children:[n.jsx(kn,{asChild:true,children:n.jsx("button",{type:"button",className:Ye(hl,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:g,disabled:l,children:v})}),n.jsxs(jn,{align:"end",className:"w-64",children:[n.jsx(Hr,{className:"typography-ui-header font-semibold text-foreground",children:s("header.sourceControl.accountsTitle",{provider:i})}),n.jsx(tr,{}),x.map(y=>{const C=y.user,S=!!y.current,N=s(Nh(y.source??"oauth"));return n.jsxs(Ks,{className:"gap-2",disabled:l,onSelect:()=>{S||m(y.id)},children:[C?.avatarUrl?n.jsx("img",{src:C.avatarUrl,alt:C.username?s("header.sourceControl.avatarWithLogin",{login:C.username}):s("header.sourceControl.avatar",{provider:i}),className:"h-6 w-6 rounded-full border border-edge bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-edge bg-muted",children:n.jsx(zi,{descriptor:a,variant:"fill",className:"h-3 w-3 text-muted-foreground"})}),n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:C?.name?.trim()||C.username||a.label}),C.username?n.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[n.jsx("span",{className:"font-mono",children:C.username}),n.jsx("span",{className:"mx-1 opacity-50",children:"\xB7"}),n.jsx("span",{children:N})]}):null]}),S?n.jsx(ue,{name:"check",className:"h-4 w-4 text-primary"}):null]},y.id)})]})]})},ny=t=>JSON.stringify(Ph(t)),ry=async(t,e)=>{const s=await t.projectUpstream(e);if(!s?.isFork||!s.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,s.upstream.owner,s.upstream.name);return{upstream:s.upstream,branches:r}},au=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function oy(t){if(!au(t.error)||!t.isCurrent())return false;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),true}function ay(t,e,s){const r=qe.c(18),{sourceControl:o}=Is(),a=Wa(t.provider).features.referenceSearch,[i,u]=Kt.useState(null);let d;r[0]!==t.bindingRevision||r[1]!==t.provider||r[2]!==t.repositoryId||r[3]!==e?(d=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]=d):d=r[4];const l=d;let f;r[5]!==t||r[6]!==l||r[7]!==e||r[8]!==a||r[9]!==o?(f=()=>{if(!a)return;let p=false;return o.references(t,{kind:"pull",query:`#${e}`}).then(h=>{if(p||!h.connected)return;const x=h.items.find(g=>g.kind==="pull"&&g.number===e);x&&u({key:l,pull:x})}).catch(iy),()=>{p=true}},r[5]=t,r[6]=l,r[7]=e,r[8]=a,r[9]=o,r[10]=f):f=r[10];let m;return r[11]!==t||r[12]!==l||r[13]!==e||r[14]!==s||r[15]!==a||r[16]!==o?(m=[t,l,e,s,a,o],r[11]=t,r[12]=l,r[13]=e,r[14]=s,r[15]=a,r[16]=o,r[17]=m):m=r[17],Kt.useEffect(f,m),i?.key===l?i.pull:null}function iy(){}const ly=t=>{const e=qe.c(99),{directory:s,context:r,changeRequest:o,onChanged:a,statusStack:i}=t,{sourceControl:u}=Is(),d=Zs(),l=Yt(cy),[f,m]=Kt.useState(0),[p,h]=Kt.useState(false),x=Xa(),g=ay(r,o.number,f);let v;e[0]!==o?(v=Rh(o),e[0]=o,e[1]=v):v=e[1];const y=v;let C;e[2]!==g||e[3]!==y?(C=g?{...y,labels:g.labels,commentCount:g.commentCount}:y,e[2]=g,e[3]=y,e[4]=C):C=e[4];const S=C,[N,F]=Kt.useState(null),_=N?.number===o.number?N.sha:null,{detail:M,latest:B,refresh:T}=od(s,S,true,_),I=B.status==="ready"?B.value.pull:null,b=Mc(S);let w;e[5]!==a||e[6]!==T?(w=()=>{T(),m(dy),a()},e[5]=a,e[6]=T,e[7]=w):w=e[7];const j=w,R=Fc(S,r,j);let L;e[8]!==r||e[9]!==a||e[10]!==S.number||e[11]!==S.sourceRepo.owner||e[12]!==S.sourceRepo.repo||e[13]!==T||e[14]!==u?(L=async()=>{const Ve={owner:S.sourceRepo.owner,repo:S.sourceRepo.repo,number:S.number};await u.refreshProviderReads(r,{item:Ve}).catch(uy),ad(Ve),m(fy),await Promise.all([T(),a()])},e[8]=r,e[9]=a,e[10]=S.number,e[11]=S.sourceRepo.owner,e[12]=S.sourceRepo.repo,e[13]=T,e[14]=u,e[15]=L):L=e[15];const E=L;let D;e[16]!==S?(D={source:"repository",reference:S},e[16]=S,e[17]=D):D=e[17];const U=D,V=d??s;let J;e[18]!==M||e[19]!==i?(J=M.status==="ready"&&M.value.pull&&M.value.pull.stack===void 0&&i!==void 0?{status:"ready",value:{...M.value,pull:{...M.value.pull,stack:i}}}:M,e[18]=M,e[19]=i,e[20]=J):J=e[20];const W=J,G=W.status==="ready"?W.value.pull?.stack??null:i??null,le=Ya(),$=Yt(py),re=it(my),H=Er($,re,s),[P,ee]=Kt.useState(false);let oe;e[21]===Symbol.for("react.memo_cache_sentinel")?(oe={status:"idle"},e[21]=oe):oe=e[21];const de=H?()=>ee(true):void 0,he=I?.submitRequirements,Z=B.status==="error",ce=o.mergeable??null;let ae;e[22]!==r||e[23]!==U||e[24]!==j||e[25]!==G||e[26]!==Z||e[27]!==ce||e[28]!==de||e[29]!==he?(ae=n.jsx(qa,{item:U,project:null,context:r,onStartWorktree:gy,onChanged:j,worktreeAvailable:false,stack:G,onStartOnTop:de,submitRequirements:he,submitRequirementsUnreadable:Z,mergeable:ce}),e[22]=r,e[23]=U,e[24]=j,e[25]=G,e[26]=Z,e[27]=ce,e[28]=de,e[29]=he,e[30]=ae):ae=e[30];let te;e[31]!==o.number||e[32]!==I||e[33]!==_?(te=I?.revisions?{revisions:I.revisions,selected:_,onSelect:Ve=>F(Ve?{number:o.number,sha:Ve}:null)}:void 0,e[31]=o.number,e[32]=I,e[33]=_,e[34]=te):te=e[34];let pe;e[35]!==s||e[36]!==le?(pe=Ve=>{le(Ve.url,s)},e[35]=s,e[36]=le,e[37]=pe):pe=e[37];let Te;e[38]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>h(true),e[38]=Te):Te=e[38];let Ae;e[39]!==r||e[40]!==U||e[41]!==S.state||e[42]!==j?(Ae=S.state!=="merged"?n.jsx(Lc,{item:U,context:r,onChanged:j}):void 0,e[39]=r,e[40]=U,e[41]=S.state,e[42]=j,e[43]=Ae):Ae=e[43];let Pe;e[44]!==b.attachComment||e[45]!==b.attachComments?(Pe={onAttach:b.attachComment,onAttachAll:b.attachComments},e[44]=b.attachComment,e[45]=b.attachComments,e[46]=Pe):Pe=e[46];let ze;e[47]!==r||e[48]!==S||e[49]!==j?(ze=n.jsx(zc,{reference:S,context:r,onChanged:j}),e[47]=r,e[48]=S,e[49]=j,e[50]=ze):ze=e[50];let Oe;e[51]!==r||e[52]!==M||e[53]!==S||e[54]!==j?(Oe=n.jsx(Wc,{pull:S,detail:M,context:r,onChanged:j}),e[51]=r,e[52]=M,e[53]=S,e[54]=j,e[55]=Oe):Oe=e[55];const me=I?.voteLabels;let be;e[56]!==I?.revisions?(be=I?.revisions?.at(-1)?.sha,e[56]=I?.revisions,e[57]=be):be=e[57];const Ce=_===null;let $e;e[58]!==r||e[59]!==S||e[60]!==j||e[61]!==me||e[62]!==be||e[63]!==Ce?($e=n.jsx($c,{reference:S,context:r,onRefresh:j,voteLabels:me,latestRevision:be,onLatestRevision:Ce},S.number),e[58]=r,e[59]=S,e[60]=j,e[61]=me,e[62]=be,e[63]=Ce,e[64]=$e):$e=e[64];const We=l??"";let _e;e[65]!==V||e[66]!==We?(_e={id:We,path:V},e[65]=V,e[66]=We,e[67]=_e):_e=e[67];let Ue;e[68]!==r||e[69]!==V||e[70]!==S||e[71]!==_||e[72]!==_e?(Ue=n.jsx(Vc,{pull:S,project:_e,repository:null,context:r,projectOwnsDirectory:xy,currentDirectory:V,revision:_}),e[68]=r,e[69]=V,e[70]=S,e[71]=_,e[72]=_e,e[73]=Ue):Ue=e[73];let Xe;e[74]!==s||e[75]!==U||e[76]!==x||e[77]!==E||e[78]!==W||e[79]!==ae||e[80]!==te||e[81]!==pe||e[82]!==Ae||e[83]!==Pe||e[84]!==ze||e[85]!==Oe||e[86]!==$e||e[87]!==Ue||e[88]!==R?(Xe=n.jsx(Ja,{item:U,directory:s,pullStatus:Qa,trackerDetail:oe,repositoryDetail:W,purpose:"attach",pinned:true,includeDiff:false,onIncludeDiffChange:hy,now:x,footer:ae,revisionChoice:te,onOpenStackLayer:pe,onOpenChecks:Te,onRefresh:E,stateMenu:Ae,commentAttachments:Pe,threadActions:R,labelsControl:ze,reviewersControl:Oe,reply:$e,pullLinks:Ue}),e[74]=s,e[75]=U,e[76]=x,e[77]=E,e[78]=W,e[79]=ae,e[80]=te,e[81]=pe,e[82]=Ae,e[83]=Pe,e[84]=ze,e[85]=Oe,e[86]=$e,e[87]=Ue,e[88]=R,e[89]=Xe):Xe=e[89];let Me;e[90]!==b.attachFailedChecks||e[91]!==p||e[92]!==r||e[93]!==S?(Me=n.jsx(Bc,{pull:S,context:r,open:p,onOpenChange:h,onAttachFailed:b.attachFailedChecks}),e[90]=b.attachFailedChecks,e[91]=p,e[92]=r,e[93]=S,e[94]=Me):Me=e[94];const ot=H?n.jsx(Dh,{open:P,onOpenChange:ee,project:{id:H.id,path:ro(H.path)??H.path},initialSourceBranch:S.head,onWorktreeCreated:by}):null;let ye;return e[95]!==Xe||e[96]!==Me||e[97]!==ot?(ye=n.jsxs(n.Fragment,{children:[Xe,Me,ot]}),e[95]=Xe,e[96]=Me,e[97]=ot,e[98]=ye):ye=e[98],ye};function cy(t){return t.activeProjectId}function dy(t){return t+1}function uy(){}function fy(t){return t+1}function py(t){return t.projects}function my(t){return t.availableWorktreesByProject}function hy(){}function gy(){}function xy(){return true}function by(t){it.getState().openNewSessionDraft({directoryOverride:t,preserveDirectoryOverride:true})}const wy=/^Change-Id:\s*I[0-9a-f]{40}$/,yy=50,vy=t=>(t.replace(/\r\n/g,`
3
3
  `).trim().split(/\n[ \t]*\n/).at(-1)??"").split(`
4
4
  `).some(r=>wy.test(r.trim())),Sy=t=>{const e=t[0]??null,s=t.filter(r=>!vy(r.body));return{status:"ready",commits:t.length,subject:e?.message.trim()||null,tip:e?.hash??null,missing:s.length===0?"none":s.length===1&&s[0]===e?"tip":"many",missingCount:s.length}};function ky(t,e,s,r,o){const a=qe.c(15),[i,u]=c.useState(null);let d;a[0]!==e||a[1]!==s||a[2]!==t||a[3]!==o?(d=JSON.stringify([t,e,s,o]),a[0]=e,a[1]=s,a[2]=t,a[3]=o,a[4]=d):d=a[4];const l=d;let f,m;if(a[5]!==e||a[6]!==s||a[7]!==t||a[8]!==r||a[9]!==l?(f=()=>{if(!r||!t||!e||!s)return;let h=false;return u({key:l,value:{status:"loading"}}),id(t,{from:e,to:s,maxCount:yy}).then(x=>{h||u({key:l,value:Sy(x.all)})}).catch(()=>{h||u({key:l,value:{status:"error"}})}),()=>{h=true}},m=[e,s,t,r,l],a[5]=e,a[6]=s,a[7]=t,a[8]=r,a[9]=l,a[10]=f,a[11]=m):(f=a[10],m=a[11]),c.useEffect(f,m),!r)return null;let p;return a[12]!==l||a[13]!==i?(p=i?.key===l?i.value:{status:"loading"},a[12]=l,a[13]=i,a[14]=p):p=a[14],p}const jy=t=>{const e=qe.c(111),{preflight:s,topic:r,onTopicChange:o,hashtags:a,onHashtagsChange:i,wip:u,onWipChange:d,privateChange:l,onPrivateChange:f,onAddChangeId:m,disabled:p}=t,{t:h}=gt(),x=s?.status==="ready"?s:null;let g=null;if(x?.commits===0){let Z;e[0]!==h?(Z=h("gitView.change.push.nothingToPush"),e[0]=h,e[1]=Z):Z=e[1];let ce;e[2]!==Z?(ce=n.jsx("span",{className:"text-muted-foreground",children:Z}),e[2]=Z,e[3]=ce):ce=e[3],g=ce}else if(x?.missing==="tip"){let Z;e[4]!==h?(Z=h("gitView.change.changeId.missingTip"),e[4]=h,e[5]=Z):Z=e[5];let ce;e[6]!==Z?(ce=n.jsx("span",{className:"min-w-0 flex-1 text-[var(--status-warning)]",children:Z}),e[6]=Z,e[7]=ce):ce=e[7];let ae;e[8]!==p||e[9]!==m||e[10]!==h?(ae=m?n.jsx(es,{sideOffset:8,label:h("contextTooltips.git.addChangeId"),className:"shrink-0",children:n.jsx(yt,{size:"xs",variant:"outline",className:"shrink-0",onClick:m,disabled:p,children:h("gitView.change.changeId.add")})}):null,e[8]=p,e[9]=m,e[10]=h,e[11]=ae):ae=e[11];let te;e[12]!==ce||e[13]!==ae?(te=n.jsxs(n.Fragment,{children:[ce,ae]}),e[12]=ce,e[13]=ae,e[14]=te):te=e[14],g=te}else if(x?.missing==="many"){let Z;e[15]!==x.missingCount||e[16]!==h?(Z=h("gitView.change.changeId.missingMany",{count:x.missingCount}),e[15]=x.missingCount,e[16]=h,e[17]=Z):Z=e[17];let ce;e[18]!==Z?(ce=n.jsx("span",{className:"text-[var(--status-warning)]",children:Z}),e[18]=Z,e[19]=ce):ce=e[19],g=ce}else if(s?.status==="error"){let Z;e[20]!==h?(Z=h("gitView.change.push.readFailed"),e[20]=h,e[21]=Z):Z=e[21];let ce;e[22]!==Z?(ce=n.jsx("span",{className:"text-[var(--status-error-text)]",children:Z}),e[22]=Z,e[23]=ce):ce=e[23],g=ce}let v;e[24]!==h?(v=h("gitView.change.push.subject"),e[24]=h,e[25]=v):v=e[25];let y;e[26]!==v?(y=n.jsx("div",{className:"typography-micro text-muted-foreground",children:v}),e[26]=v,e[27]=y):y=e[27];const C=x?.subject??void 0;let S;e[28]!==s?.status||e[29]!==x?.subject?(S=x?.subject??(s?.status==="loading"?n.jsx(ue,{name:"loader-4",className:"size-3.5 animate-spin text-muted-foreground"}):null),e[28]=s?.status,e[29]=x?.subject,e[30]=S):S=e[30];let N;e[31]!==C||e[32]!==S?(N=n.jsx("div",{className:"min-h-5 truncate typography-ui-label text-foreground",title:C,children:S}),e[31]=C,e[32]=S,e[33]=N):N=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?(_=n.jsx("div",{className:"typography-micro text-muted-foreground",children:F}),e[36]=F,e[37]=_):_=e[37];let M;e[38]!==y||e[39]!==N||e[40]!==_?(M=n.jsxs("div",{className:"space-y-1",children:[y,N,_]}),e[38]=y,e[39]=N,e[40]=_,e[41]=M):M=e[41];let B;e[42]!==h?(B=h("gitView.change.push.topic"),e[42]=h,e[43]=B):B=e[43];let T;e[44]!==B?(T=n.jsx("div",{className:"typography-micro text-muted-foreground",children:B}),e[44]=B,e[45]=T):T=e[45];let I;e[46]!==o?(I=Z=>o(Z.target.value),e[46]=o,e[47]=I):I=e[47];let b;e[48]!==h?(b=h("gitView.change.push.optional"),e[48]=h,e[49]=b):b=e[49];let w;e[50]!==p||e[51]!==I||e[52]!==b||e[53]!==r?(w=n.jsx(Fn,{value:r,onChange:I,placeholder:b,disabled:p}),e[50]=p,e[51]=I,e[52]=b,e[53]=r,e[54]=w):w=e[54];let j;e[55]!==T||e[56]!==w?(j=n.jsxs("label",{className:"space-y-1",children:[T,w]}),e[55]=T,e[56]=w,e[57]=j):j=e[57];let R;e[58]!==h?(R=h("gitView.change.push.hashtags"),e[58]=h,e[59]=R):R=e[59];let L;e[60]!==R?(L=n.jsx("div",{className:"typography-micro text-muted-foreground",children:R}),e[60]=R,e[61]=L):L=e[61];let E;e[62]!==i?(E=Z=>i(Z.target.value),e[62]=i,e[63]=E):E=e[63];let D;e[64]!==h?(D=h("gitView.change.push.hashtagsPlaceholder"),e[64]=h,e[65]=D):D=e[65];let U;e[66]!==p||e[67]!==a||e[68]!==E||e[69]!==D?(U=n.jsx(Fn,{value:a,onChange:E,placeholder:D,disabled:p}),e[66]=p,e[67]=a,e[68]=E,e[69]=D,e[70]=U):U=e[70];let V;e[71]!==L||e[72]!==U?(V=n.jsxs("label",{className:"space-y-1",children:[L,U]}),e[71]=L,e[72]=U,e[73]=V):V=e[73];let J;e[74]!==j||e[75]!==V?(J=n.jsxs("div",{className:"flex flex-col gap-3",children:[j,V]}),e[74]=j,e[75]=V,e[76]=J):J=e[76];let W;e[77]!==h?(W=h("gitView.change.push.wip"),e[77]=h,e[78]=W):W=e[78];let G;e[79]!==p||e[80]!==d||e[81]!==W||e[82]!==u?(G=n.jsx(pa,{checked:u,onChange:d,disabled:p,ariaLabel:W}),e[79]=p,e[80]=d,e[81]=W,e[82]=u,e[83]=G):G=e[83];let le;e[84]!==h?(le=h("gitView.change.push.wip"),e[84]=h,e[85]=le):le=e[85];let $;e[86]!==G||e[87]!==le?($=n.jsxs("label",{className:"flex cursor-pointer items-center gap-2 typography-meta text-foreground",children:[G,le]}),e[86]=G,e[87]=le,e[88]=$):$=e[88];let re;e[89]!==h?(re=h("gitView.change.push.private"),e[89]=h,e[90]=re):re=e[90];let H;e[91]!==p||e[92]!==f||e[93]!==l||e[94]!==re?(H=n.jsx(pa,{checked:l,onChange:f,disabled:p,ariaLabel:re}),e[91]=p,e[92]=f,e[93]=l,e[94]=re,e[95]=H):H=e[95];let P;e[96]!==h?(P=h("gitView.change.push.private"),e[96]=h,e[97]=P):P=e[97];let ee;e[98]!==H||e[99]!==P?(ee=n.jsxs("label",{className:"flex cursor-pointer items-center gap-2 typography-meta text-foreground",children:[H,P]}),e[98]=H,e[99]=P,e[100]=ee):ee=e[100];let oe;e[101]!==$||e[102]!==ee?(oe=n.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[$,ee]}),e[101]=$,e[102]=ee,e[103]=oe):oe=e[103];let de;e[104]!==g?(de=n.jsx("div",{className:"flex min-h-7 items-center gap-2 typography-micro",children:g}),e[104]=g,e[105]=de):de=e[105];let he;return e[106]!==J||e[107]!==oe||e[108]!==de||e[109]!==M?(he=n.jsxs("div",{className:"flex flex-col gap-3",children:[M,J,oe,de]}),e[106]=J,e[107]=oe,e[108]=de,e[109]=M,e[110]=he):he=e[110],he};function Ty(t,e){const{git:s,sourceControl:r}=Is(),{t:o}=gt(),a=Pp(),i=Rp({directory:t,branch:e,chooseContributor:a.choose}),u=_h(t,s,r),d=async(p,h)=>{const x=u.start();if(!x)return Fe.info(o("gitView.pr.toast.gitBusy")),false;try{return await h(x),x.isCurrent()}catch(g){if(g instanceof Ah){if(g.code==="stale-runtime")return false;const v=g.code==="review-option-invalid"?o("gitView.change.push.invalidOption"):i.errorMessage(g);return v?Fe.info(v):Fe.error(p),false}return g instanceof Oh||g instanceof Mh?(Fe.error(p,{description:g.message||void 0}),false):(Fe.error(p,{description:g instanceof Error?Ap(g,o):String(g)}),false)}finally{x.finish()}},l=()=>d(o("gitView.toast.syncActionFailed",{action:o("gitView.publish.title")}),async p=>{await(await i.prepare("push",{onOperation:p.onOperation}))()}),f=p=>t?d(o("gitView.change.push.toast.failed"),async h=>{await Fh({directory:t,git:s,sourceControl:r,review:p,onOperation:h.onOperation})}):Promise.resolve(false),m=n.jsxs(n.Fragment,{children:[i.context?n.jsx(Dp,{context:i.context,onSelect:i.settle}):null,i.confirmDialog,n.jsx(_p,{candidates:a.candidates,onSelect:a.settle})]});return{push:l,pushForReview:f,dialogs:m}}const Cy=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"}},Ey=(t,e)=>{const{currentSessionId:s,getDirectoryForSession:r}=it.getState(),o=s?r(s):null;!s||!o||ts(o)!==ts(t)||Vh(s,o,Uh({url:e.url,number:e.number,title:e.title,kind:"pull",linkedAt:Date.now()}),true).catch(()=>{})},Iy=t=>{const e=t?.changeRequest??t?.pr;return e?Hh({state:e.state,draft:e.draft,checksState:(t?.ci?.summary??t?.checks)?.state,mergeable:e.mergeable,mergeableState:e.mergeableState}):null},Ny=[2e3,5e3];let gl=0;const Py=()=>{const t=globalThis.crypto?.randomUUID?.();return t||(gl+=1,`source-control-${Date.now().toString(36)}-${gl.toString(36)}`)},Ry=(t,e,s)=>JSON.stringify(["create",t,e.provider,e.instance,e.directory,e.repositoryId,e.accountId,e.bindingRevision,e.primaryRemote,...s]),iu="openchamber:pr-create-as-draft:v1",xl=()=>{try{return localStorage.getItem(iu)==="true"}catch{return false}},Dy=t=>{try{localStorage.setItem(iu,String(t))}catch{}},Yo=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),tn=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):""},_y=(t,e)=>{const s=tn(t);if(!s||s.includes("->"))return"";if(e){const o=`${e}/`;return s.startsWith(o)?s.slice(o.length).trim():""}const r=s.indexOf("/");return r>0?s.slice(r+1).trim():s},Ay=(t,e)=>`${t}::${e}`,Jo=new Map,bl=Wn;function Oy(t,e,s){const r=qe.c(14);let o;r[0]!==s?(o=s?ny(s):null,r[0]=s,r[1]=o):o=r[1];const a=o;let i;r[2]===Symbol.for("react.memo_cache_sentinel")?(i={contextKey:null,detectedUpstream:null,upstreamBranches:[]},r[2]=i):i=r[2];const[u,d]=c.useState(i);let l,f;r[3]!==a||r[4]!==t||r[5]!==s||r[6]!==e?(l=()=>{if(!t||!s||!a)return;let p=false;return(async()=>{try{const h=await ry(e,s);p||d({contextKey:a,detectedUpstream:h.upstream,upstreamBranches:h.branches})}catch{}})(),()=>{p=true}},f=[a,t,s,e],r[3]=a,r[4]=t,r[5]=s,r[6]=e,r[7]=l,r[8]=f):(l=r[7],f=r[8]),c.useEffect(l,f);let m;return r[9]!==a||r[10]!==u.contextKey||r[11]!==u.detectedUpstream||r[12]!==u.upstreamBranches?(m=u.contextKey===a?{detectedUpstream:u.detectedUpstream,upstreamBranches:u.upstreamBranches}:{detectedUpstream:null,upstreamBranches:[]},r[9]=a,r[10]=u.contextKey,r[11]=u.detectedUpstream,r[12]=u.upstreamBranches,r[13]=m):m=r[13],m}const My=({directory:t,branch:e,baseBranch:s,trackingBranch:r,ahead:o=0,remoteBranches:a=[],onGeneratedDescription:i})=>{const{t:u}=gt(),d=ld(t),l=Sf(),f=jc(A=>A.byId),m=A=>f.has(A),p=l(d?.provider),h=p.terminology.changeRequest,x=p.features.createByPush,g=c.useCallback((A,Se)=>u(Us(A,h),Se),[h,u]),v=Qw(),{sourceControl:y,git:C}=Is(),S=ei(),N=vn(A=>A.entries),{isMobile:F,hasTouchInput:_,screenWidth:M}=Tn(),B=K(A=>A.openContextSurface),T=Lh(A=>A.requestTarget),I=!F&&M>=768&&!zn(),b=c.useMemo(()=>Ay(t,e),[t,e]),w=c.useMemo(()=>Jo.get(b)??null,[b]),j=vs(A=>A.ensureEntry),R=vs(A=>A.setParams),L=vs(A=>A.beginActiveContextsLoad),E=vs(A=>A.commitActiveContexts),D=vs(A=>A.releaseActiveContexts),U=c.useId(),V=vs(A=>A.startWatching),J=vs(A=>A.stopWatching),W=vs(A=>A.refresh),[G,le]=c.useState(()=>w?.title??Yo(e)),[$,re]=c.useState(()=>w?.body??""),[H,P]=c.useState(()=>w?.draft??xl()),[ee,oe]=c.useState(()=>w?.additionalContext??""),[de,he]=c.useState(()=>w?.targetBaseBranchChosen===true),[Z,ce]=c.useState(()=>{const A=typeof w?.targetBaseBranch=="string"?tn(w.targetBaseBranch):"";return A||tn(s)}),ae=c.useCallback(A=>{he(true),ce(A)},[]),[te,pe]=c.useState(false),[Te,Ae]=c.useState(false),[Pe,ze]=c.useState(""),[Oe,me]=c.useState(""),[be,Ce]=c.useState(false),[$e,We]=c.useState(0),[_e,Ue]=c.useState(false),Xe=cd(t,y),Me=Xe.scope.runtimeKey;c.useEffect(()=>{if(!t)return;const A=Xe.scope.runtimeKey,Se=L(A,t,U),ge=Xe.contexts.filter(xt=>Wi(N[Xn(xt)],xt).connected);return E(A,t,U,Se,ge),()=>{D(A,t,U)}},[L,Xe.contexts,Xe.scope.runtimeKey,E,t,D,N,U]);const ye=Xe.contexts[0]??null,Ve=vs(A=>{if(!ye||!Z)return null;const Se=$h(A.entries,ye,Z);if(!Se||Se.defaultBranch===Z)return null;const ge=Se.changeRequest??Se.pr??null;return ge?.state==="open"?ge:null}),lt=vn(A=>d?A.entries[Xn(d)]?.hasChecked===true:false),ct=ye?.primaryRemote??null,st=c.useMemo(()=>ye?Xn(ye):"",[ye]),k=vn(A=>A.entries[st]),Y=ye?Wi(k,ye):{authChecked:k?.hasChecked??false,connected:false},Ne=Y.authChecked,[Re,Ie]=c.useState(0),[Ee,Ge]=c.useState({key:"",status:"loading",capabilities:null}),[Be,Ze]=c.useState(false),{detectedUpstream:et,upstreamBranches:wt}=Oy(t,y,ye);c.useEffect(()=>{if(!ye)return;let A=false;const Se=Xn(ye);return Ge({key:Se,status:"loading",capabilities:null}),y.capabilities(ye).then(ge=>{A||Ge({key:Se,status:"ready",capabilities:ge})}).catch(()=>{A||Ge({key:Se,status:"error",capabilities:null})}),()=>{A=true}},[Re,ye,y]);const Qe=Ee.key===st?Ee:null,dt=Qe?.status==="ready"?Qe.capabilities:null;c.useEffect(()=>{Ze(false)},[t]);const z=!!(t&&e&&s&&(e!==s||et!==null||x)),fe=c.useMemo(()=>ye?Bh(ye,e):"",[e,ye]),ke=c.useRef(fe);ke.current=fe;const ie=c.useCallback((A,Se)=>A===Xt()&&Se===ke.current,[]),xe=vs(A=>A.entries[fe]),Le=c.useMemo(()=>fe?[fe]:[],[fe]);ko(zh(Le));const Ke=xe?.isLoading??false,ve=Y.connected?xe?.status??null:null,je=Xe.error?g("settings.sourceControl.instance.status.operationFailed"):xe?.error??null,vt=xe?.isInitialStatusResolved??false,ne=c.useMemo(()=>{const A=Be?null:ct,Se=new Set;for(const ht of a){const At=_y(ht,A);!At||At==="HEAD"||Se.add(At)}if(Be)for(const ht of wt)ht&&ht!=="HEAD"&&Se.add(ht);const ge=tn(s);ge&&ge!=="HEAD"&&Se.add(ge);const xt=tn(Z);return xt&&xt!=="HEAD"&&Se.add(xt),Array.from(Se).sort((ht,At)=>ht.localeCompare(At))},[s,a,ct,Z,wt,Be]);c.useEffect(()=>{const A=tn(s);if(!Z&&A){ce(A);return}if(ne.length!==0&&!ne.includes(Z)){const Se=ne.includes(A)?A:ne[0];Se&&ce(Se)}},[ne,s,Z]);const Je=c.useRef([]),kt=c.useRef(new Map),bt=c.useCallback(A=>{const Se=kt.current.get(A);if(Se?.inFlight)return null;if(Se)return Se.inFlight=true,Se.key;const ge=Py();return kt.current.set(A,{key:ge,inFlight:true}),ge},[]),_t=c.useCallback((A,Se,ge)=>{const xt=kt.current.get(A);!xt||xt.key!==Se||(ge?xt.inFlight=false:kt.current.delete(A))},[]);c.useEffect(()=>{et&&Ze(true)},[et]),c.useEffect(()=>{Be&&et?.defaultBranch&&ce(et.defaultBranch)},[Be,et?.defaultBranch]);const He=ve?.changeRequest??ve?.pr??null,pt=ve?.identity??ye,q=c.useMemo(()=>ve?.project??(ve?.repo&&pt?{...ve.repo,...pt,id:Wo(ve.repo.owner,ve.repo.repo),name:ve.repo.repo}:null),[ve?.project,ve?.repo,pt]),se=He?.state==="merged"||He?.state==="closed",De=se?null:He,we=ve?.ci?.summary??ve?.checks??null,[rt,ft]=c.useState(false),nt=c.useRef(true);c.useEffect(()=>(nt.current=true,()=>{nt.current=false}),[]);const ut=c.useCallback(async A=>{await W(fe,A)},[fe,W]),Nt=c.useCallback((A,Se)=>{Je.current.forEach(ge=>{window.clearTimeout(ge)}),Je.current=Ny.map(ge=>window.setTimeout(()=>{ie(A,Se)&&W(Se,{force:true,silent:true,markInitialResolved:true})},ge))},[ie,W]),Et=c.useCallback(async(A,Se,ge)=>{await oy({error:A,isCurrent:()=>ie(Se,ge),refresh:()=>W(ge,{force:true,silent:true,markInitialResolved:true}),scheduleRefresh:()=>Nt(Se,ge)})},[ie,W,Nt]);c.useEffect(()=>{!ye||!fe||(j(fe),R(fe,{directory:t,branch:e,remoteName:ye.primaryRemote,canShow:z,identity:ye,readContext:ye,sourceControl:y,authChecked:Y.authChecked,connected:Y.connected}))},[e,z,t,j,fe,ye,y,Y.authChecked,Y.connected,R]);const Ft=600,Wt=c.useCallback(async()=>{if(rt)return;ft(true);const A=Date.now();try{if(await ut({force:true}),He&&ve?.repo&&pt){const Se={owner:ve.repo.owner,repo:ve.repo.repo,number:He.number};await y.refreshProviderReads(pt,{item:Se}).catch(()=>{})}}finally{const Se=Ft-(Date.now()-A);Se>0&&await new Promise(ge=>window.setTimeout(ge,Se)),nt.current&&ft(false)}},[rt,He,ut,y,ve?.repo,pt]);c.useEffect(()=>{if(!(!ye||!fe))return V(fe),()=>{J(fe)}},[fe,ye,V,J]),c.useEffect(()=>{const A=Jo.get(b)??null;le(A?.title??Yo(e)),re(A?.body??""),P(A?.draft??xl());const Se=A?.targetBaseBranchChosen===true&&!!A.targetBaseBranch;he(Se),ce(Se&&A?.targetBaseBranch?tn(A.targetBaseBranch):tn(s))},[s,e,b]),c.useEffect(()=>{!ye||!fe||!Y.connected||ut({markInitialResolved:true})},[fe,ye,ut,Y.connected]),c.useEffect(()=>{!z||!ye||!Y.connected||ut({force:true,silent:true,markInitialResolved:true})},[z,ye,ut,Y.connected]),c.useEffect(()=>{const A=()=>{const ge=vs.getState().entries[fe]?.lastRefreshAt??0;Date.now()-ge>6e4&&ut({force:true,silent:true})},Se=()=>{document.visibilityState==="visible"&&A()};return window.addEventListener("focus",A),document.addEventListener("visibilitychange",Se),()=>{window.removeEventListener("focus",A),document.removeEventListener("visibilitychange",Se)}},[fe,ut]),c.useEffect(()=>{Ne&&!Y.connected&&ut({force:true,silent:true,markInitialResolved:true})},[ut,Y.connected,Ne]),c.useEffect(()=>{!t||!e||Jo.set(b,{title:G,body:$,draft:H,additionalContext:ee,targetBaseBranch:Z,targetBaseBranchChosen:de})},[b,G,$,H,ee,Z,de,t,e]),c.useEffect(()=>()=>{Je.current.forEach(A=>{window.clearTimeout(A)}),Je.current=[]},[fe,Me]),c.useEffect(()=>()=>{kt.current.clear()},[]);const is=Be&&et?.defaultBranchSha?et.defaultBranchSha:ye?`${ye.primaryRemote}/${Z}`:Z;c.useEffect(()=>{if(!t||!e||!is)return;let A=false;return id(t,{from:is,to:e,maxCount:2}).then(Se=>{const ge=Se.all.length===1?Se.all[0]?.message.trim():"";A||!ge||le(xt=>xt===Yo(e)?ge:xt)}).catch(()=>{}),()=>{A=true}},[e,is,t]);const Gt=x?ve?.localRevision?.uploadedAs===null:!r||o>0,ns=Ty(t,e),ms=ky(t,is,e,x&&z,$e),Ns=c.useId(),Fs=A=>{P(A),Dy(A)},X=c.useCallback(async()=>{if(!te&&t){pe(true);try{const Se={base:is,head:e,...ye?.provider?{changeRequestProvider:l(ye.provider)}:{}};ee&&(Se.context=ee);const ge=await Wh(t,Se);ge.title?.trim()&&le(ge.title.trim()),ge.body?.trim()&&re(ge.body.trim()),i?.()}catch(A){const Se=A instanceof Error?A.message:String(A);Fe.error(g("gitView.pr.toast.generateDescriptionFailed"),{description:Se})}finally{pe(false)}}},[ee,e,is,l,t,te,i,ye,g]),mt=c.useCallback(async()=>{if(dt?.changeRequests!==true){Fe.error(g("gitView.pr.toast.createPrFailed"),{description:g("gitView.pr.capabilitiesUnavailable")});return}const A=G.trim();if(!A){Fe.error(g("gitView.pr.toast.titleRequired"));return}const Se=Z.trim();if(!Se){Fe.error(g("gitView.pr.toast.baseBranchRequired"));return}if(!Be&&Se===e){Fe.error(g("gitView.pr.toast.baseMustDifferFromHead"));return}const ge=Be?et:q;if(!ye||!ge){Fe.error(g("gitView.pr.toast.createPrFailed"),{description:je??g("gitView.pr.statusUnavailable")});return}if(Gt&&(Ae(true),!await ns.push())){Ae(false);return}const xt=Xt(),ht=fe,At={owner:ge.owner,name:ge.name},Lt=$.trim()?$:void 0,Ot=Be?void 0:ye.primaryRemote,zt=Be?ye.primaryRemote:void 0,ys=Ry(xt,ye,[At.owner,At.name,e,Se,A,Lt,H,Ot,zt]),dn=bt(ys);if(!dn){Ae(false);return}Ae(true);let Lo=false,Si=false;try{const Ls={...ye,idempotencyKey:dn,target:{project:At,head:e,base:Se},title:A,draft:H};Lt!==void 0&&(Ls.body=Lt),Ot&&(Ls.remote=Ot),zt&&(Ls.headRemote=zt);const un=await y.changeRequestCreate(Ls);if(Si=true,_t(ys,dn,false),!ie(xt,ht)||(un.result.stacked===false?Fe.warning(g("stacks.toast.createdNotStacked"),{description:g("stacks.toast.createdNotStackedDescription",{base:Se})}):Fe.success(g(un.result.stacked?"stacks.toast.createdStacked":"gitView.pr.toast.prCreated")),await ut({force:true}),!ie(xt,ht)))return;const Ar=vs.getState().entries[ht]?.status,$o=Ar?.changeRequest??Ar?.pr;$o&&$o.number===un.target.number&&Ey(t,$o),Nt(xt,ht)}catch(Ls){const un=Ls instanceof Error?Ls:new Error(String(Ls));Lo=au(un);const Ar=un.message;Fe.error(g("gitView.pr.toast.createPrFailed"),{description:Ar}),Lo&&await Et(un,xt,ht)}finally{Si||_t(ys,dn,Lo),Ae(false)}},[bt,$,e,ns,et,t,H,je,_t,ie,Gt,fe,ye,Et,ut,Nt,y,dt?.changeRequests,q,Z,G,Be,g]),jt=async()=>{const A=Z.trim();if(!A){Fe.error(g("gitView.pr.toast.baseBranchRequired"));return}const Se={target:A,wip:H,private:be};Pe.trim()&&(Se.topic=Pe.trim());const ge=Oe.split(/[\s,]+/).filter(Boolean);ge.length>0&&(Se.hashtags=ge),Ae(true);try{if(!await ns.pushForReview(Se))return;Fe.success(g("gitView.change.push.toast.pushed")),await ut({force:true})}finally{Ae(false)}},$t=async A=>{Ae(true);try{if(!await ns.pushForReview({target:A.base}))return;Fe.success(g("gitView.change.push.toast.uploaded")),await ut({force:true})}finally{Ae(false)}},Q=C.addChangeIdToHead,tt=async()=>{const A=ms?.status==="ready"?ms.tip:null;if(!(!Q||!A||!await S.confirm({title:g("gitView.change.changeId.confirmTitle"),message:g("gitView.change.changeId.confirmMessage"),action:g("gitView.change.changeId.add")})))try{await Q(t,A),Fe.success(g("gitView.change.changeId.toast.added"))}catch(ge){Fe.error(g("gitView.change.changeId.toast.failed"),{description:ge instanceof Error?ge.message:String(ge)})}finally{We(ge=>ge+1)}},St="border-0 bg-transparent rounded-none px-4 py-3";if(!z)return n.jsx("section",{className:St,children:n.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[n.jsx("div",{className:"min-w-0 typography-meta text-muted-foreground",children:g("gitView.pullRequest.availableOnFeatureBranches")}),d?n.jsx(sy,{identity:d}):null]})});const Tt=ve?.changeRequest&&ve.changeRequest.state==="open"?ve.changeRequest:De&&q&&pt?{...pt,id:`${Wo(q.owner,q.name)}#${De.number}`,number:De.number,project:{...pt,id:q.id,owner:q.owner,name:q.name,url:q.url??""},title:De.title,body:De.body,url:De.url,state:De.state,draft:De.draft,base:De.base,head:De.head,headSha:De.headSha,mergeable:De.mergeable,mergeableState:De.mergeableState}:null;if(Tt&&ye){const A=n.jsx(ly,{directory:t,context:ye,changeRequest:Tt,onChanged:()=>ut({force:true,silent:true,markInitialResolved:true}),statusStack:ve?.stack});if(!(x&&Gt))return n.jsx("div",{className:"h-full min-h-0",children:A});const Se=Tt.revisionNumber!==void 0?Tt.revisionNumber+1:null;return n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-edge-muted px-4 py-2",children:[n.jsx(ue,{name:"arrow-up",className:"size-3.5 shrink-0 text-[var(--status-warning)]"}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-micro text-muted-foreground",children:g("gitView.change.push.notUploaded")}),n.jsx(es,{sideOffset:8,label:g("contextTooltips.git.uploadPatchset"),className:"shrink-0",children:n.jsxs(yt,{size:"sm",className:"shrink-0",onClick:()=>{$t(Tt)},disabled:Te,children:[Te?n.jsx(ue,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(ue,{name:"upload-2",className:"size-4"}),Se!==null?g("gitView.change.push.uploadPatchset",{number:Se}):g("gitView.change.push.uploadNew")]})}),ns.dialogs]}),n.jsx("div",{className:"min-h-0 flex-1",children:A})]})}const Bt=q?.url||null,Zt=Be&&et?.url?et.url:Bt,js=Qe?.status==="error",us=!!ve?.connected,Ps=!!(!ye&&d&&Xe.status==="ready"&&lt),Rs=!!(pt&&Ne&&ve?.connected===false)||Ps,hs=pt??d,ls=hs?l(hs.provider).label:null,ws=Iy(ve),cn=ws?`var(--pr-${ws})`:"var(--status-info)",Ys=ws==="draft"?"git-pr-draft":ws==="merged"?"git-merge":ws==="closed"?"git-close-pull-request":"git-pull-request",En=ls?g("gitView.pr.actions.openOnProviderAria",{provider:ls}):g("gitView.header.openPullRequest"),Ao=He?[g(He.state==="merged"?"sessions.sidebar.group.pr.status.merged":He.state==="closed"?"sessions.sidebar.group.pr.status.closed":He.draft?"sessions.sidebar.group.pr.status.draft":"sessions.sidebar.group.pr.status.open"),He.state==="open"&&He.mergeable===false?g("gitView.pr.notMergeable"):null,He.state==="open"&&typeof He.mergeableState=="string"&&He.mergeableState&&He.mergeableState!=="unknown"?He.mergeableState:null].filter(Boolean).join(" \xB7 "):"",Oo=we?we.total>0?`${we.success}/${we.total} ${g("gitView.pr.checks.label")}`:`${we.state} ${g("gitView.pr.checks.label")}`:"",Dr="px-0 py-3 border-b border-edge-muted flex flex-col gap-1",Vn="flex flex-col gap-3 py-3",Un=n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Ke||rt,onClick:()=>{Wt()},"aria-label":g("gitView.pr.actions.refreshAria"),children:n.jsx(ue,{name:Ke||rt?"loader-4":"refresh",className:Ye("size-4 text-muted-foreground",(Ke||rt)&&"animate-spin")})})}),n.jsx(Dt,{children:n.jsx("p",{children:g("gitView.pr.actions.refresh")})})]}),Mo=_e||ee.trim().length>0,Hn=Gt?r?o===1?g("gitView.pr.unpushed.one"):g("gitView.pr.unpushed.many",{count:o}):g("gitView.pr.unpushed.unpublished"):null,_r=g(Gt?H?"gitView.pr.actions.pushAndCreateDraftPr":"gitView.pr.actions.pushAndCreatePr":H?"gitView.pr.actions.createDraftPr":"gitView.pr.actions.createPr"),Fo=Te||!us||dt?.changeRequests!==true||!Z.trim()||!Be&&Z.trim()===e,O=Te||!us||!Z.trim()||ms?.status!=="ready"||ms.commits===0||ms.missing!=="none";return n.jsxs("section",{className:St,children:[He?n.jsxs("div",{className:Dr,children:[n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(es,{sideOffset:8,label:En,className:"shrink-0",children:n.jsxs(yt,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{bl(He.url)},"aria-label":En,children:[n.jsx(ue,{name:Ys,className:"size-4 shrink-0",style:{color:cn}}),ls?g("gitView.pr.actions.openOnProvider",{provider:ls}):g("gitView.header.openPullRequest")]})}),n.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:g("gitView.pullRequest.title")}),n.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:ki(l(pt?.provider),He.number)})]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:Un})]}),n.jsxs("div",{className:"@container/pr-actions flex min-w-0 items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[n.jsx("span",{style:{color:cn},children:Ao}),we?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:`h-2 w-2 rounded-full ${Cy(we.state)}`}),Oo]}):null,r&&ct&&r.split("/")[0]!==ct?n.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," \u2192 ",ct]}):null]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:I&&ye&&m(ye.provider)?n.jsx(es,{sideOffset:8,label:g("contextTooltips.git.walkthrough"),className:"shrink-0",children:n.jsxs(yt,{variant:"outline",size:"sm",className:"pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",onClick:()=>{T(t,{source:{kind:"pr",number:He.number,...q?{sourceRepo:{owner:q.owner,repo:q.name}}:{}},context:ye}),B(t,"walkthrough")},"aria-label":g("walkthrough.action.open"),children:[n.jsx(ue,{name:"route",className:"size-4"}),n.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:g("walkthrough.action.open")})]})}):null})]})]}):null,n.jsxs("div",{className:Vn,children:[js?n.jsxs("div",{className:"space-y-2 rounded-md bg-[var(--status-error-background)] p-3",children:[n.jsx("div",{className:"typography-ui-label text-[var(--status-error)]",children:g("gitView.pr.capabilitiesUnavailable")}),n.jsx(yt,{variant:"outline",size:"sm",onClick:()=>Ie(A=>A+1),children:g("settings.sourceControl.transport.retry")})]}):null,Rs&&ls?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-meta text-muted-foreground",children:g("gitView.pr.providerNotConnected",{provider:ls})}),n.jsx(yt,{variant:"outline",size:"sm",onClick:v,className:"w-fit",children:g("gitView.pr.actions.openSettings")})]}):null,je?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-ui-label text-foreground",children:g("gitView.pr.statusUnavailable")}),n.jsx("div",{dir:"auto",className:"typography-meta text-muted-foreground break-words",children:je}),Xe.error?n.jsx(yt,{variant:"outline",size:"sm",onClick:()=>{Xe.retry()},disabled:Xe.status==="loading",children:g("settings.sourceControl.transport.retry")}):null,Zt?n.jsx(yt,{variant:"outline",size:"sm",asChild:true,className:"w-fit",children:n.jsxs("a",{href:Zt,target:"_blank",rel:"noopener noreferrer",children:[n.jsx(ue,{name:"external-link",className:"size-4"}),g("gitView.pr.actions.repo")]})}):null]}):null,(De||!He&&!vt)&&!je&&!Rs&&(Xe.status==="loading"||ye)?n.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[n.jsx(dd,{className:"size-4"}),g("gitView.pr.checkingStatus")]}):n.jsxs("div",{className:"flex flex-col gap-3",children:[He&&se?n.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md oc-tile-inset px-2.5 py-2",children:[n.jsx(ue,{name:He.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:cn}}),n.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:He.state==="merged"?g("gitView.pr.history.merged",{number:He.number,base:He.base||Z}):g("gitView.pr.history.closed",{number:He.number})}),n.jsx(es,{sideOffset:8,label:En,className:"shrink-0",children:n.jsx(yt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{bl(He.url)},"aria-label":En,children:n.jsx(ue,{name:"external-link",className:"size-3.5"})})})]}):null,n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx(ue,{name:"git-pull-request",className:"size-4 shrink-0 text-muted-foreground"}),n.jsx("span",{dir:"ltr",className:"min-w-0 truncate typography-ui-label text-foreground",title:e,children:e}),n.jsx(ue,{name:"arrow-right",className:"size-3.5 shrink-0 text-muted-foreground"}),Be&&et?n.jsx("span",{className:"min-w-0 shrink truncate typography-meta text-muted-foreground",children:Wo(et.owner,et.name)}):null,ne.length>0?n.jsxs(ud,{value:Z,onValueChange:ae,children:[n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(fd,{className:"w-auto min-w-0","aria-label":g("gitView.pr.field.baseBranch"),children:n.jsx(pd,{placeholder:g("gitView.pr.placeholder.selectBaseBranch")})})}),n.jsx(Dt,{children:n.jsx("p",{children:g("gitView.pr.field.baseBranch")})})]}),n.jsx(md,{children:ne.map(A=>n.jsx(ti,{value:A,children:A},A))})]}):n.jsx(Fn,{value:Z,onChange:A=>ae(A.target.value),placeholder:g("gitView.pr.placeholder.main"),"aria-label":g("gitView.pr.field.baseBranch"),className:"h-7 w-32"}),n.jsxs("div",{className:"ms-auto flex shrink-0 items-center gap-0.5",children:[Zt?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",asChild:true,children:n.jsx("a",{href:Zt,target:"_blank",rel:"noopener noreferrer","aria-label":g("gitView.pr.actions.repo"),children:n.jsx(ue,{name:"external-link",className:"size-4 text-muted-foreground"})})})}),n.jsx(Dt,{children:n.jsx("p",{children:g("gitView.pr.actions.repo")})})]}):null,Un]})]}),Ve?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 typography-meta text-muted-foreground",children:[n.jsx(ue,{name:"stack",className:"size-3.5 shrink-0"}),n.jsx("span",{className:"truncate",children:g("stacks.create.stacksOn",{reference:ki(l(ye?.provider),Ve.number)})})]}):null,x?n.jsx(jy,{preflight:ms,topic:Pe,onTopicChange:ze,hashtags:Oe,onHashtagsChange:me,wip:H,onWipChange:Fs,privateChange:be,onPrivateChange:Ce,onAddChangeId:Q?()=>{tt()}:void 0,disabled:Te}):n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"space-y-1",children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:g("gitView.pr.field.title")}),n.jsx(Fn,{value:G,onChange:A=>le(A.target.value),placeholder:g("gitView.pr.placeholder.title"),autoCorrect:_?"on":"off",autoCapitalize:_?"sentences":"off",spellCheck:_})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("label",{htmlFor:Ns,className:"typography-micro text-muted-foreground",children:g("gitView.pr.field.description")}),n.jsxs("div",{className:"flex items-center",children:[n.jsx(es,{sideOffset:8,label:g("contextTooltips.git.generateDescription"),children:n.jsxs(yt,{variant:"ghost",size:"xs",className:"rounded-e-none",onClick:X,disabled:te||Te,children:[te?n.jsx(ue,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(ue,{name:"ai-generate-2",className:"size-3.5 text-primary"}),g("gitView.commit.generate")]})}),n.jsxs(Sn,{children:[n.jsx(es,{sideOffset:8,label:g("gitView.pr.generate.optionsAria"),children:n.jsx(kn,{asChild:true,children:n.jsx(yt,{variant:"ghost",size:"xs",className:"rounded-s-none border-s-0 px-1",disabled:te||Te,"aria-label":g("gitView.pr.generate.optionsAria"),children:n.jsx(ue,{name:"arrow-down-s",className:"size-3.5"})})})}),n.jsx(jn,{align:"end",className:"w-60",children:n.jsxs(Ks,{onSelect:()=>Ue(true),children:[n.jsx(ue,{name:"sticky-note",className:"size-4 shrink-0"}),g("gitView.pr.generate.withNotes")]})})]})]})]}),Mo?n.jsxs("div",{className:"relative",children:[n.jsx(Vi,{value:ee,onChange:A=>oe(A.target.value),className:"min-h-[72px] pe-9",placeholder:g("gitView.pr.placeholder.additionalContext"),"aria-label":g("gitView.pr.generate.notesAria"),autoFocus:_e&&!ee}),n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{variant:"ghost",size:"xs",className:"absolute inset-e-1.5 top-1.5 h-6 w-6 px-0",onClick:()=>{oe(""),Ue(false)},"aria-label":g("gitView.pr.generate.removeNotesAria"),children:n.jsx(ue,{name:"close",className:"size-3.5"})})}),n.jsx(Dt,{children:n.jsx("p",{children:g("gitView.pr.generate.removeNotesAria")})})]})]}):null,n.jsx(Vi,{id:Ns,value:$,onChange:A=>re(A.target.value),className:"min-h-[140px]",placeholder:g("gitView.pr.placeholder.whatChanged"),autoCorrect:_?"on":"off",autoCapitalize:_?"sentences":"off",spellCheck:_})]})]}),Hn&&!x?n.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-[var(--status-warning)]",children:[n.jsx(ue,{name:"arrow-up",className:"size-3.5 shrink-0"}),Hn]}):null,n.jsx("div",{className:"flex justify-end",children:x?n.jsx(es,{sideOffset:8,label:g("contextTooltips.git.pushForReview"),children:n.jsxs(yt,{size:"sm",className:"justify-center gap-2",onClick:()=>{jt()},disabled:O,children:[Te?n.jsx(ue,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(ue,{name:"upload-2",className:"size-4"}),n.jsx("span",{children:g("gitView.change.push.forReview")})]})}):n.jsxs("div",{className:"flex items-center",children:[n.jsx(es,{sideOffset:8,label:g("contextTooltips.git.createChangeRequest"),children:n.jsxs(yt,{size:"sm",className:"justify-center gap-2 rounded-e-none",onClick:mt,disabled:Fo,children:[Te?n.jsx(ue,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(ue,{name:H?"git-pr-draft":"git-pull-request",className:"size-4"}),n.jsx("span",{children:_r})]})}),n.jsxs(Sn,{children:[n.jsx(es,{sideOffset:8,label:g("gitView.pr.createKindAria"),children:n.jsx(kn,{asChild:true,children:n.jsx(yt,{size:"sm",className:"rounded-s-none border-s-0 px-1.5",disabled:Te,"aria-label":g("gitView.pr.createKindAria"),children:n.jsx(ue,{name:"arrow-down-s",className:"size-4"})})})}),n.jsx(jn,{align:"end",className:"w-56",children:n.jsxs(hd,{value:H?"draft":"ready",onValueChange:A=>Fs(A==="draft"),children:[n.jsx(oo,{value:"ready",children:g("gitView.pr.actions.createPr")}),n.jsx(oo,{value:"draft",children:g("gitView.pr.actions.createDraftPr")})]})})]})]})}),ns.dialogs,S.dialog]})]})]})},Fy=()=>{const t=qe.c(98),{t:e}=gt(),{git:s,sourceControl:r}=Is(),o=Zs();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a={recheckOnOpen:true},t[0]=a):a=t[0];const{rootIsGitRepo:i,gitDirectory:u,nestedRepos:d,repositoryOptions:l,unreadable:f}=Kh(o??null,a),m=jo(u??null),p=qh(u??null),h=Gh(u??null),x=cd(u,r),{ensureAll:g,ensureNestedRepos:v,selectNestedRepo:y}=Ln(wa(Ly)),C=it($y),S=it(By),N=it(zy),F=it(Wy);let _;t[1]!==o?(_=ts(o),t[1]=o,t[2]=_):_=t[2];const M=_;let B;e:{if(!M){B=void 0;break e}let me;t[3]!==F||t[4]!==M||t[5]!==N?(me=so(F,M)??so(N.values(),M),t[3]=F,t[4]=M,t[5]=N,t[6]=me):me=t[6],B=me}const T=B;let I;t[7]!==C||t[8]!==T||t[9]!==S?.open||t[10]!==N?(I=()=>{if(C)return N.get(C)??T;if(S?.open)return T},t[7]=C,t[8]=T,t[9]=S?.open,t[10]=N,t[11]=I):I=t[11],S?.open;let b;t[12]!==I?(b=I(),t[12]=I,t[13]=b):b=t[13];const w=b;let j;t[14]!==C?(j=me=>C?me.getAttachment(C):void 0,t[14]=C,t[15]=j):j=t[15];const R=ed(j),L=R&&!R.degraded&&!R.legacy?R.worktreeRoot??void 0:void 0,E=Yw(o,w,m?.current??void 0);let D,U;t[16]!==g||t[17]!==s||t[18]!==u?(D=()=>{!u||!s||g(u,s)},U=[u,g,s],t[16]=g,t[17]=s,t[18]=u,t[19]=D,t[20]=U):(D=t[19],U=t[20]),c.useEffect(D,U);const[V,J]=c.useState(null);let W;t[21]!==L||t[22]!==E?.projectDirectory?(W=()=>{const me=L||E?.projectDirectory;if(!me){J(null);return}let be=false;return Zh(me).then(Ce=>{if(be)return;const $e=Ce.trim();J($e&&$e!=="HEAD"?$e:null)}).catch(()=>{be||J(null)}),()=>{be=true}},t[21]=L,t[22]=E?.projectDirectory,t[23]=W):W=t[23];const G=E?.projectDirectory;let le;t[24]!==L||t[25]!==G?(le=[L,G],t[24]=L,t[25]=G,t[26]=le):le=t[26],c.useEffect(W,le);let $;e:{if(!p?.all){let be;t[27]===Symbol.for("react.memo_cache_sentinel")?(be=[],t[27]=be):be=t[27],$=be;break e}let me;t[28]!==p.all?(me=p.all.filter(Vy).sort(),t[28]=p.all,t[29]=me):me=t[29],$=me}const re=$;let H;e:{if(!p?.all){let be;t[30]===Symbol.for("react.memo_cache_sentinel")?(be=[],t[30]=be):be=t[30],H=be;break e}let me;t[31]!==p.all?(me=p.all.filter(Uy).map(Hy).sort(),t[31]=p.all,t[32]=me):me=t[32],H=me}const P=H,ee=m?.current??null,oe=x.contexts[0]?.primaryRemote,de=oe?p?.defaultBranches?.[oe]:void 0;let he;t[33]!==x.contexts[0]||t[34]!==x.read?.repository.remotes||t[35]!==ee||t[36]!==de||t[37]!==re||t[38]!==V||t[39]!==E?.createdFromBranch?(he=()=>Fp({remoteNames:new Set(x.contexts[0]?.primaryRemote?[x.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(x.read?.repository.remotes.map(Ky)??[]),localBranches:re,worktreeCreatedFromBranch:E?.createdFromBranch,rootBranchHint:V,defaultBranch:de,headBranch:ee,fallbackToConventional:false}),t[33]=x.contexts[0],t[34]=x.read?.repository.remotes,t[35]=ee,t[36]=de,t[37]=re,t[38]=V,t[39]=E?.createdFromBranch,t[40]=he):he=t[40],E?.createdFromBranch;let Z;t[41]!==he?(Z=he(),t[41]=he,t[42]=Z):Z=t[42];const ae=Op(u??null,ee,true,x,p,Z),te=Tc(ld(o??null)?.provider);if(!o){let me;t[43]===Symbol.for("react.memo_cache_sentinel")?(me=n.jsx(ue,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[43]=me):me=t[43];let be;t[44]!==te||t[45]!==e?(be=e(Us("gitView.pullRequest.title",te)),t[44]=te,t[45]=e,t[46]=be):be=t[46];let Ce;t[47]!==be?(Ce=n.jsx("div",{className:"typography-ui-header text-foreground",children:be}),t[47]=be,t[48]=Ce):Ce=t[48];let $e;t[49]!==te||t[50]!==e?($e=e(Us("gitView.pullRequest.createHint",te)),t[49]=te,t[50]=e,t[51]=$e):$e=t[51];let We;t[52]!==$e?(We=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:$e}),t[52]=$e,t[53]=We):We=t[53];let _e;return t[54]!==Ce||t[55]!==We?(_e=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[me,Ce,We]}),t[54]=Ce,t[55]=We,t[56]=_e):_e=t[56],_e}if(f){let me;return t[57]!==f.directory||t[58]!==f.message?(me=n.jsx(Mp,{directory:f.directory,message:f.message}),t[57]=f.directory,t[58]=f.message,t[59]=me):me=t[59],me}if(i===false&&h!==true){let me;t[60]!==o||t[61]!==v?(me=()=>{v(o,{force:true})},t[60]=o,t[61]=v,t[62]=me):me=t[62];let be;return t[63]!==o||t[64]!==h||t[65]!==d||t[66]!==i||t[67]!==me?(be=n.jsx(Lp,{root:o,rootIsGitRepo:i,resolvedIsGitRepo:h,nestedRepos:d,onRetryDiscovery:me}),t[63]=o,t[64]=h,t[65]=d,t[66]=i,t[67]=me,t[68]=be):be=t[68],be}if(!ee){let me;t[69]===Symbol.for("react.memo_cache_sentinel")?(me=n.jsx(ue,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[69]=me):me=t[69];let be;t[70]!==te||t[71]!==e?(be=e(Us("gitView.pullRequest.title",te)),t[70]=te,t[71]=e,t[72]=be):be=t[72];let Ce;t[73]!==be?(Ce=n.jsx("div",{className:"typography-ui-header text-foreground",children:be}),t[73]=be,t[74]=Ce):Ce=t[74];let $e;t[75]!==te||t[76]!==e?($e=e(Us("gitView.pullRequest.createHint",te)),t[75]=te,t[76]=e,t[77]=$e):$e=t[77];let We;t[78]!==$e?(We=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:$e}),t[78]=$e,t[79]=We):We=t[79];let _e;return t[80]!==Ce||t[81]!==We?(_e=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[me,Ce,We]}),t[80]=Ce,t[81]=We,t[82]=_e):_e=t[82],_e}let pe;t[83]!==o||t[84]!==u||t[85]!==l||t[86]!==y?(pe=l?n.jsx("div",{className:"flex shrink-0 items-center border-b border-edge px-4 py-2",children:n.jsx(Xh,{repositories:l,selectedRepository:u??null,onSelectRepository:me=>{o&&y(o,me)},repositoryRoot:o??void 0})}):null,t[83]=o,t[84]=u,t[85]=l,t[86]=y,t[87]=pe):pe=t[87];const Te=u??o,Ae=m?.tracking??void 0,Pe=m?.ahead??0;let ze;t[88]!==ae||t[89]!==ee||t[90]!==P||t[91]!==Te||t[92]!==Ae||t[93]!==Pe?(ze=n.jsx(ps,{as:Yh,outerClassName:"h-full min-h-0 flex-1",className:"h-full",disableHorizontal:true,preventOverscroll:true,children:n.jsx(My,{directory:Te,branch:ee,baseBranch:ae,trackingBranch:Ae,ahead:Pe,remoteBranches:P})}),t[88]=ae,t[89]=ee,t[90]=P,t[91]=Te,t[92]=Ae,t[93]=Pe,t[94]=ze):ze=t[94];let Oe;return t[95]!==pe||t[96]!==ze?(Oe=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[pe,ze]}),t[95]=pe,t[96]=ze,t[97]=Oe):Oe=t[97],Oe};function Ly(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function $y(t){return t.currentSessionId}function By(t){return t.newSessionDraft}function zy(t){return t.worktreeMetadata}function Wy(t){return t.availableWorktrees}function Vy(t){return!t.startsWith("remotes/")}function Uy(t){return t.startsWith("remotes/")}function Hy(t){return t.replace(/^remotes\//,"")}function Ky(t){return t.name}const lu=[],qy=t=>{const e=qe.c(17),s=To(),r=gd();let o;e[0]!==t.url||e[1]!==r||e[2]!==s?(o=xd(t.url,s,r),e[0]=t.url,e[1]=r,e[2]=s,e[3]=o):o=e[3];const a=o;$p(t.visible);const{panelDirectory:i,tabId:u,url:d}=t;let l;e[4]!==i||e[5]!==u||e[6]!==d?(l=()=>{ag(i,u)&&(Wn(d),K.getState().closeContextPanelTab(i,u))},e[4]=i,e[5]=u,e[6]=d,e[7]=l):l=e[7];const f=l;let m;e[8]!==i||e[9]!==u?(m=()=>ig(i,u),e[8]=i,e[9]=u,e[10]=m):m=e[10];const p=m;let h;if(e[11]!==f||e[12]!==t||e[13]!==p||e[14]!==a||e[15]!==d){const x=a?a.source==="tracker"?n.jsx(Zy,{url:d,provider:a.provider,identifier:a.identifier,visible:t.visible,onUnavailable:f,onShown:p}):n.jsx(Gy,{...t,kind:a.kind,onUnavailable:f,onShown:p}):n.jsx(fi,{url:d});h=n.jsx("div",{className:"h-full min-h-0",children:x}),e[11]=f,e[12]=t,e[13]=p,e[14]=a,e[15]=d,e[16]=h}else h=e[16];return h},nr=t=>{const e=qe.c(8),{message:s,onRetry:r}=t,{t:o}=gt();let a;e[0]!==s?(a=n.jsx("span",{children:s}),e[0]=s,e[1]=a):a=e[1];let i;e[2]!==r||e[3]!==o?(i=r?n.jsx(yt,{size:"sm",variant:"outline",onClick:r,children:o("references.picker.actions.retry")}):null,e[2]=r,e[3]=o,e[4]=i):i=e[4];let u;return e[5]!==a||e[6]!==i?(u=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center typography-meta text-muted-foreground",children:[a,i]}),e[5]=a,e[6]=i,e[7]=u):u=e[7],u},fi=t=>{const e=qe.c(14),{url:s}=t,{t:r}=gt();let o;e[0]!==r?(o=r("contextPanel.tracker.unavailable"),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==o?(a=n.jsx("span",{children:o}),e[2]=o,e[3]=a):a=e[3];let i;e[4]!==s?(i=()=>{Wn(s)},e[4]=s,e[5]=i):i=e[5];let u;e[6]!==r?(u=r("contextPanel.preview.actions.openExternal"),e[6]=r,e[7]=u):u=e[7];let d;e[8]!==i||e[9]!==u?(d=n.jsx(yt,{size:"sm",variant:"outline",onClick:i,children:u}),e[8]=i,e[9]=u,e[10]=d):d=e[10];let l;return e[11]!==a||e[12]!==d?(l=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center typography-meta text-muted-foreground",children:[a,d]}),e[11]=a,e[12]=d,e[13]=l):l=e[13],l},wl=t=>{const e=qe.c(25),{enabled:s,directory:r,url:o,kind:a,linked:i}=t;let u;e[0]!==r||e[1]!==s||e[2]!==a||e[3]!==i||e[4]!==o?(u={enabled:s,directory:r,kind:a,filter:Hi,query:o,linked:i},e[0]=r,e[1]=s,e[2]=a,e[3]=i,e[4]=o,e[5]=u):u=e[5];const d=Ui(u),l=To();let f;e[6]!==o||e[7]!==l?(f=b=>b.find(w=>lg(w.url,o,l))??null,e[6]=o,e[7]=l,e[8]=f):f=e[8];const m=f;let p;if(e[9]!==a||e[10]!==o||e[11]!==l){const b=a==="issue"?rg(o,l):null,w=l.match(o);p=b?.descriptor.terminology.sharedNumberSpace&&w?og(b,"pull",w.number):null,e[9]=a,e[10]=o,e[11]=l,e[12]=p}else p=e[12];const h=p,x=Xy,[g,v]=Kt.useState(null),y=g===o;s&&h&&!y&&x(d)&&!m(d.items)&&v(o);const C=s&&y&&h!==null,S=h??"";let N;e[13]!==r||e[14]!==i||e[15]!==C||e[16]!==S?(N={enabled:C,directory:r,kind:"pull",filter:Hi,query:S,linked:i},e[13]=r,e[14]=i,e[15]=C,e[16]=S,e[17]=N):N=e[17];const F=Ui(N),_=y?F:d;let M;e[18]!==_.items||e[19]!==m?(M=m(_.items),e[18]=_.items,e[19]=m,e[20]=M):M=e[20];const B=M,T=s&&x(_)&&!B;let I;return e[21]!==_||e[22]!==B||e[23]!==T?(I={lookup:_,reference:B,missing:T},e[21]=_,e[22]=B,e[23]=T,e[24]=I):I=e[24],I},Gy=t=>{const e=qe.c(128),{url:s,directory:r,panelDirectory:o,foreign:a,visible:i,kind:u,onUnavailable:d,onShown:l}=t,{t:f}=gt(),{sourceControl:m}=Is(),p=Yt(Yy),h=eg(r,s),x=h.directory,g=To(),v=tg(x),y=v&&v!=="missing"?v:null,C=h.status==="ready";let S;e[0]!==u||e[1]!==x||e[2]!==C||e[3]!==s?(S={enabled:C,directory:x,url:s,kind:u,linked:false},e[0]=u,e[1]=x,e[2]=C,e[3]=s,e[4]=S):S=e[4];const N=wl(S);let F;e[5]!==s||e[6]!==g?(F=g.match(s),e[5]=s,e[6]=g,e[7]=F):F=e[7];const _=F,M=y!==null&&_?.provider===y.provider&&_.instance===y.instance,B=h.status==="ready"&&!N.reference&&(N.missing||N.lookup.status==="error"&&!h.owned),T=B&&M;let I;e[8]!==u||e[9]!==x||e[10]!==T||e[11]!==s?(I={enabled:T,directory:x,url:s,kind:u,linked:true},e[8]=u,e[9]=x,e[10]=T,e[11]=s,e[12]=I):I=e[12];const b=wl(I),w=N.reference??b.reference,j=N.reference||!B?N.lookup:b.lookup,R=w?.linked===true;let L;e[13]!==y||e[14]!==R?(L=y&&R?{...y,linked:true}:y,e[13]=y,e[14]=R,e[15]=L):L=e[15];const E=L,D=R?null:E;let U;if(e[16]!==j.followed||e[17]!==w?.number){let Ie;e[19]!==w?.number?(Ie=Ee=>!cg(Ee)&&Ee.number===w?.number,e[19]=w?.number,e[20]=Ie):Ie=e[20],U=j.followed.filter(Ie),e[16]=j.followed,e[17]=w?.number,e[18]=U}else U=e[18];ko(i?U:lu);const J=B&&!w&&(!M||b.missing||b.lookup.status==="error");let W,G;e[21]!==d||e[22]!==J?(W=()=>{J&&d()},G=[d,J],e[21]=d,e[22]=J,e[23]=W,e[24]=G):(W=e[23],G=e[24]),Kt.useEffect(W,G);const le=w!==null;let $,re;e[25]!==le||e[26]!==l?($=()=>{le&&l()},re=[le,l],e[25]=le,e[26]=l,e[27]=$,e[28]=re):($=e[27],re=e[28]),Kt.useEffect($,re);const{detail:H,refresh:P}=od(x,w,true);let ee;e[29]!==w?(ee=w?[w]:[],e[29]=w,e[30]=ee):ee=e[30];const oe=sg(x,ee),de=Mc(w),[he,Z]=Kt.useState(false),ce=Xa(),{retry:ae}=j;let te;e[31]!==P||e[32]!==ae?(te=()=>Promise.all([P(),ae()]).then(Jy),e[31]=P,e[32]=ae,e[33]=te):te=e[33];const pe=te,Te=Fc(w,D,pe),Ae=Ya(),Pe=H.status==="ready"?H.value.pull?.stack??null:null;let ze;e[34]!==w||e[35]!==pe||e[36]!==m||e[37]!==D?(ze=async()=>{if(D&&w){const Ie={owner:w.sourceRepo.owner,repo:w.sourceRepo.repo,number:w.number};await m.refreshProviderReads(D,{item:Ie}).catch(Qy),ad(Ie)}await pe()},e[34]=w,e[35]=pe,e[36]=m,e[37]=D,e[38]=ze):ze=e[38];const Oe=ze;if(!w){if(J){let Ee;return e[39]!==s?(Ee=n.jsx(fi,{url:s}),e[39]=s,e[40]=Ee):Ee=e[40],Ee}if(h.status==="failed"){let Ee;e[41]!==f?(Ee=f("gitView.empty.discoverFailed"),e[41]=f,e[42]=Ee):Ee=e[42];let Ge;return e[43]!==h.retry||e[44]!==Ee?(Ge=n.jsx(nr,{message:Ee,onRetry:h.retry}),e[43]=h.retry,e[44]=Ee,e[45]=Ge):Ge=e[45],Ge}let Ie;return e[46]!==j.error||e[47]!==j.status||e[48]!==ae||e[49]!==f?(Ie=j.status==="error"?n.jsx(nr,{message:j.error??f("contextPanel.tracker.loadFailed"),onRetry:()=>{ae()}}):n.jsx(nr,{message:f("common.loading")}),e[46]=j.error,e[47]=j.status,e[48]=ae,e[49]=f,e[50]=Ie):Ie=e[50],Ie}let me;e[51]!==w?(me={source:"repository",reference:w},e[51]=w,e[52]=me):me=e[52];const be=me,Ce=w.kind==="pull"?w:null;let $e;e[53]!==Ce||e[54]!==oe?($e=Ce?oe(Ce):Qa,e[53]=Ce,e[54]=oe,e[55]=$e):$e=e[55];let We;e[56]===Symbol.for("react.memo_cache_sentinel")?(We={status:"idle"},e[56]=We):We=e[56];let _e;e[57]!==pe?(_e=()=>{pe()},e[57]=pe,e[58]=_e):_e=e[58];let Ue;e[59]!==E||e[60]!==be||e[61]!==Pe||e[62]!==_e?(Ue=n.jsx(qa,{item:be,project:null,context:E,onStartWorktree:tv,onChanged:_e,worktreeAvailable:false,stack:Pe}),e[59]=E,e[60]=be,e[61]=Pe,e[62]=_e,e[63]=Ue):Ue=e[63];let Xe;e[64]!==r||e[65]!==Ae?(Xe=Ie=>{Ae(Ie.url,r)},e[64]=r,e[65]=Ae,e[66]=Xe):Xe=e[66];let Me;e[67]!==E||e[68]!==Ce?(Me=Ce&&E?()=>Z(true):void 0,e[67]=E,e[68]=Ce,e[69]=Me):Me=e[69];const ot=E?Oe:void 0;let ye;e[70]!==H.status||e[71]!==H.value||e[72]!==be||e[73]!==w||e[74]!==pe||e[75]!==D?(ye=w.state!=="merged"&&D&&(w.kind!=="discussion"||ng(w,H.status==="ready"?H.value.discussion:void 0))?n.jsx(Lc,{item:be,context:D,onChanged:()=>{pe()}}):void 0,e[70]=H.status,e[71]=H.value,e[72]=be,e[73]=w,e[74]=pe,e[75]=D,e[76]=ye):ye=e[76];let Ve;e[77]!==de.attachComment||e[78]!==de.attachComments?(Ve={onAttach:de.attachComment,onAttachAll:de.attachComments},e[77]=de.attachComment,e[78]=de.attachComments,e[79]=Ve):Ve=e[79];let lt;e[80]!==w||e[81]!==pe||e[82]!==D?(lt=D?n.jsx(zc,{reference:w,context:D,onChanged:pe}):void 0,e[80]=w,e[81]=pe,e[82]=D,e[83]=lt):lt=e[83];let ct;e[84]!==H||e[85]!==Ce||e[86]!==pe||e[87]!==D?(ct=Ce&&D?n.jsx(Wc,{pull:Ce,detail:H,context:D,onChanged:pe}):void 0,e[84]=H,e[85]=Ce,e[86]=pe,e[87]=D,e[88]=ct):ct=e[88];let st;e[89]!==H.status||e[90]!==H.value||e[91]!==w||e[92]!==pe||e[93]!==D?(st=D&&(H.status!=="ready"||H.value.discussion?.canComment!==false)?n.jsx($c,{reference:w,context:D,onRefresh:pe}):void 0,e[89]=H.status,e[90]=H.value,e[91]=w,e[92]=pe,e[93]=D,e[94]=st):st=e[94];let k;e[95]!==p||e[96]!==E||e[97]!==r||e[98]!==a||e[99]!==o||e[100]!==Ce||e[101]!==x?(k=Ce&&E?n.jsx(Vc,{pull:Ce,project:{id:p??"",path:r},repository:x,context:E,projectOwnsDirectory:()=>!a,currentDirectory:o}):null,e[95]=p,e[96]=E,e[97]=r,e[98]=a,e[99]=o,e[100]=Ce,e[101]=x,e[102]=k):k=e[102];let Y;e[103]!==H||e[104]!==be||e[105]!==ce||e[106]!==x||e[107]!==$e||e[108]!==Ue||e[109]!==Xe||e[110]!==Me||e[111]!==ot||e[112]!==ye||e[113]!==Ve||e[114]!==lt||e[115]!==ct||e[116]!==st||e[117]!==k||e[118]!==Te?(Y=n.jsx(Ja,{item:be,directory:x,pullStatus:$e,trackerDetail:We,repositoryDetail:H,purpose:"attach",pinned:true,includeDiff:false,onIncludeDiffChange:ev,now:ce,footer:Ue,onOpenStackLayer:Xe,onOpenChecks:Me,onRefresh:ot,threadActions:Te,stateMenu:ye,commentAttachments:Ve,labelsControl:lt,reviewersControl:ct,reply:st,pullLinks:k}),e[103]=H,e[104]=be,e[105]=ce,e[106]=x,e[107]=$e,e[108]=Ue,e[109]=Xe,e[110]=Me,e[111]=ot,e[112]=ye,e[113]=Ve,e[114]=lt,e[115]=ct,e[116]=st,e[117]=k,e[118]=Te,e[119]=Y):Y=e[119];let Ne;e[120]!==de.attachFailedChecks||e[121]!==he||e[122]!==E||e[123]!==Ce?(Ne=Ce&&E?n.jsx(Bc,{pull:Ce,context:E,open:he,onOpenChange:Z,onAttachFailed:de.attachFailedChecks}):null,e[120]=de.attachFailedChecks,e[121]=he,e[122]=E,e[123]=Ce,e[124]=Ne):Ne=e[124];let Re;return e[125]!==Y||e[126]!==Ne?(Re=n.jsxs(n.Fragment,{children:[Y,Ne]}),e[125]=Y,e[126]=Ne,e[127]=Re):Re=e[127],Re},Zy=t=>{const e=qe.c(50),{url:s,provider:r,identifier:o,visible:a,onUnavailable:i,onShown:u}=t,{t:d}=gt(),l=Jh(r);let f;e[0]!==o||e[1]!==r||e[2]!==l?(f=l==="ready"?{provider:r,id:o}:null,e[0]=o,e[1]=r,e[2]=l,e[3]=f):f=e[3];const{detail:m,refresh:p,followed:h}=Qh(f,true);ko(a?h:lu);const x=Ya(),g=Xa(),v=l!=="ready",y=m.status==="error",C=m.status==="ready";let S,N;e[4]!==v||e[5]!==y||e[6]!==i?(S=()=>{(v||y)&&i()},N=[v,y,i],e[4]=v,e[5]=y,e[6]=i,e[7]=S,e[8]=N):(S=e[7],N=e[8]),Kt.useEffect(S,N);let F,_;if(e[9]!==u||e[10]!==C?(F=()=>{C&&u()},_=[u,C],e[9]=u,e[10]=C,e[11]=F,e[12]=_):(F=e[11],_=e[12]),Kt.useEffect(F,_),v){let E;return e[13]!==s?(E=n.jsx(fi,{url:s}),e[13]=s,e[14]=E):E=e[14],E}if(m.status==="error"){let E;e[15]!==m.error||e[16]!==d?(E=m.error||d("contextPanel.tracker.loadFailed"),e[15]=m.error,e[16]=d,e[17]=E):E=e[17];let D;e[18]!==p?(D=()=>{p()},e[18]=p,e[19]=D):D=e[19];let U;return e[20]!==E||e[21]!==D?(U=n.jsx(nr,{message:E,onRetry:D}),e[20]=E,e[21]=D,e[22]=U):U=e[22],U}if(m.status!=="ready"){let E;e[23]!==d?(E=d("common.loading"),e[23]=d,e[24]=E):E=e[24];let D;return e[25]!==E?(D=n.jsx(nr,{message:E}),e[25]=E,e[26]=D):D=e[26],D}let M;e[27]!==m.value||e[28]!==r?(M={source:"tracker",provider:r,item:m.value},e[27]=m.value,e[28]=r,e[29]=M):M=e[29];const B=M;let T;e[30]===Symbol.for("react.memo_cache_sentinel")?(T={status:"idle"},e[30]=T):T=e[30];let I;e[31]!==p?(I=()=>{p()},e[31]=p,e[32]=I):I=e[32];let b;e[33]!==B||e[34]!==I?(b=n.jsx(qa,{item:B,project:null,context:null,onStartWorktree:nv,onChanged:I,worktreeAvailable:false}),e[33]=B,e[34]=I,e[35]=b):b=e[35];let w;e[36]!==p?(w=()=>{p()},e[36]=p,e[37]=w):w=e[37];let j;e[38]!==m.value||e[39]!==w?(j=n.jsx(Bp,{item:m.value,onChanged:w}),e[38]=m.value,e[39]=w,e[40]=j):j=e[40];let R;e[41]!==x?(R=E=>{x(E.url,null)},e[41]=x,e[42]=R):R=e[42];let L;return e[43]!==m||e[44]!==B||e[45]!==g||e[46]!==j||e[47]!==R||e[48]!==b?(L=n.jsx(Ja,{item:B,directory:null,pullStatus:Qa,trackerDetail:m,repositoryDetail:T,purpose:"attach",pinned:true,includeDiff:false,onIncludeDiffChange:sv,now:g,footer:b,trackerStateControl:j,onOpenTrackerItem:R}),e[43]=m,e[44]=B,e[45]=g,e[46]=j,e[47]=R,e[48]=b,e[49]=L):L=e[49],L};function Xy(t){return(t.status==="ready"||t.status==="unavailable")&&!t.refreshing}function Yy(t){return t.activeProjectId}function Jy(){}function Qy(){}function ev(){}function tv(){}function sv(){}function nv(){}const io=new Map,rv=(t,e)=>{if(t.size!==e.size)return false;for(const[s,r]of t)if(e.get(s)!==r)return false;return true},ov=t=>{const e=t.time?.updated;return typeof e=="number"&&Number.isFinite(e)?e:0},av=(t,e)=>{if(e.length===0)return io;const s=new Set(e),r=new Map,o=new Map;for(const a of t)for(const i of a.session){if(!s.has(i.id))continue;const u=i.title?.trim();if(!u)continue;const d=ov(i),l=r.get(i.id);l!==void 0&&l>d||(r.set(i.id,d),o.set(i.id,u))}return o.size===0?io:o},No=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,iv=t=>t.kind==="record",lv=t=>{const e=qe.c(5),{node:s}=t,r=s.tone==="string"?"text-foreground":"font-mono text-muted-foreground";let o;e[0]!==r?(o=Ye("whitespace-pre-wrap break-words",r),e[0]=r,e[1]=o):o=e[1];let a;return e[2]!==s.text||e[3]!==o?(a=n.jsx("span",{dir:"auto",className:o,children:s.text}),e[2]=s.text,e[3]=o,e[4]=a):a=e[4],a},cv=t=>{const e=qe.c(4),{node:s}=t;let r;e[0]!==s.entries?(r=s.entries.map(dv),e[0]=s.entries,e[1]=r):r=e[1];let o;return e[2]!==r?(o=n.jsx("dl",{className:"flex flex-col gap-1.5",children:r}),e[2]=r,e[3]=o):o=e[3],o},Po=t=>{const e=qe.c(13),{node:s}=t;if(s.kind==="scalar"){let a;return e[0]!==s?(a=n.jsx(lv,{node:s}),e[0]=s,e[1]=a):a=e[1],a}if(s.kind==="record"){let a;return e[2]!==s?(a=n.jsx(cv,{node:s}),e[2]=s,e[3]=a):a=e[3],a}if(s.items.length===0){let a;return e[4]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("span",{className:"font-mono text-muted-foreground",children:"[]"}),e[4]=a):a=e[4],a}if(s.items.every(iv)){let a;e[5]!==s.items?(a=s.items.map(uv),e[5]=s.items,e[6]=a):a=e[6];let i;return e[7]!==a?(i=n.jsx("div",{className:"flex flex-col gap-1.5",children:a}),e[7]=a,e[8]=i):i=e[8],i}let r;e[9]!==s.items?(r=s.items.map(fv),e[9]=s.items,e[10]=r):r=e[10];let o;return e[11]!==r?(o=n.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},cu=t=>{const e=qe.c(24),{answer:s}=t,{t:r}=gt(),[o,a]=c.useState(false);if(s.kind==="text"){let g;return e[0]!==s.text?(g=n.jsx(dg,{content:s.text,singleTilde:false,className:"typography-markdown-body",enableFileReferences:false}),e[0]=s.text,e[1]=g):g=e[1],g}let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=()=>a(pv),e[2]=i):i=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 d;e[6]!==o||e[7]!==u?(d=n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",onClick:i,"aria-pressed":o,className:"typography-micro text-muted-foreground hover:text-foreground",children:u})}),e[6]=o,e[7]=u,e[8]=d):d=e[8];const l=o?"contextTooltips.workspace.workflow.answerFormatted":"contextTooltips.workspace.workflow.answerRaw";let f;e[9]!==r||e[10]!==l?(f=r(l),e[9]=r,e[10]=l,e[11]=f):f=e[11];let m;e[12]!==f?(m=n.jsx(Dt,{sideOffset:6,children:f}),e[12]=f,e[13]=m):m=e[13];let p;e[14]!==d||e[15]!==m?(p=n.jsx("div",{className:"flex justify-end",children:n.jsxs(Rt,{children:[d,m]})}),e[14]=d,e[15]=m,e[16]=p):p=e[16];let h;e[17]!==s.tree||e[18]!==s.value||e[19]!==o?(h=o?n.jsx("pre",{dir:"ltr",className:"overflow-x-auto whitespace-pre-wrap break-words font-mono typography-meta text-foreground",children:JSON.stringify(s.value,null,2)}):n.jsx(Po,{node:s.tree}),e[17]=s.tree,e[18]=s.value,e[19]=o,e[20]=h):h=e[20];let x;return e[21]!==p||e[22]!==h?(x=n.jsxs("div",{className:"flex flex-col gap-2",children:[p,h]}),e[21]=p,e[22]=h,e[23]=x):x=e[23],x};function dv(t){const[e,s]=t,r=s.kind==="scalar"&&s.text.length<=60&&!s.text.includes(`
5
- `);return n.jsxs("div",{className:Ye("min-w-0",r?"flex items-baseline gap-2":"flex flex-col gap-0.5"),children:[n.jsx("dt",{className:"shrink-0 typography-micro text-muted-foreground",dir:"ltr",children:e}),n.jsx("dd",{className:"min-w-0 typography-meta",children:n.jsx(Po,{node:s})})]},e)}function uv(t,e){return n.jsx("div",{className:"oc-tile-inset rounded-lg px-3 py-2",children:n.jsx(Po,{node:t})},e)}function fv(t,e){return n.jsx("li",{className:"typography-meta",children:n.jsx(Po,{node:t})},e)}function pv(t){return!t}const du=t=>t.slice(t.indexOf("/")+1),pi=t=>{const e=qe.c(7),{start:s,end:r,className:o}=t,a=xg(s!==void 0&&r===void 0);if(s===void 0)return null;let i;e[0]!==o?(i=Ye("shrink-0 whitespace-nowrap tabular-nums",o),e[0]=o,e[1]=i):i=e[1];const u=(r??a)-s;let d;e[2]!==u?(d=bg(u),e[2]=u,e[3]=d):d=e[3];let l;return e[4]!==i||e[5]!==d?(l=n.jsx("span",{className:i,dir:"auto",children:d}),e[4]=i,e[5]=d,e[6]=l):l=e[6],l},mv=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 s=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:s?void 0:Math.max(...r,...e)}},hv=t=>{const e=qe.c(18),{run:s,groups:r}=t,{t:o}=gt();let a,i,u,d,l,f;if(e[0]!==r||e[1]!==s||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{const p=r.filter(vv);if(p.length===0){f=null;break e}a=ps,i="overlay-scrollbar-wrapper--no-gutter",u=false,d="flex gap-1.5 pb-1";let h;e[9]!==s||e[10]!==o?(h=x=>{const g=x.agents.length,v=mv(x.agents),y=s.state==="running"&&s.currentPhase===x.title;return n.jsxs("div",{className:"oc-tile min-w-[7.5rem] flex-1 rounded-lg px-2.5 py-2",children:[n.jsx("div",{className:Ye("truncate typography-meta",y?"font-semibold text-foreground":"text-foreground"),dir:"auto",children:x.title}),n.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 typography-micro text-muted-foreground",children:[g>0?n.jsx("span",{className:"tabular-nums",dir:"auto",children:`${x.done}/${g}`}):n.jsx("span",{children:o("workflows.panel.phase.waiting")}),g>0?n.jsx(pi,{start:v.start,end:v.end,className:"ms-auto"}):null]}),n.jsx("div",{className:"oc-tile-inset mt-1.5 h-1 overflow-hidden rounded-full",children:g>0?n.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.round(x.done/g*100)}%`,background:x.failed>0?"var(--status-warning)":"var(--status-success)"}}):null})]},x.title)},e[9]=s,e[10]=o,e[11]=h):h=e[11],l=p.map(h)}e[0]=r,e[1]=s,e[2]=o,e[3]=a,e[4]=i,e[5]=u,e[6]=d,e[7]=l,e[8]=f}else a=e[3],i=e[4],u=e[5],d=e[6],l=e[7],f=e[8];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;return e[12]!==a||e[13]!==i||e[14]!==u||e[15]!==d||e[16]!==l?(m=n.jsx(a,{outerClassName:i,fillContainer:u,className:d,children:l}),e[12]=a,e[13]=i,e[14]=u,e[15]=d,e[16]=l,e[17]=m):m=e[17],m},gv=t=>{const e=qe.c(30),{run:s,agent:r,onOpenSession:o}=t,{t:a}=gt(),[i,u]=c.useState(null),[d,l]=c.useState(false),[f,m]=c.useState(false);let p;e[0]!==r.key||e[1]!==s.id?(p=()=>{let N=true;return l(false),wg(s.id,r.key).then(F=>{N&&u(F)}).catch(()=>{N&&l(true)}),()=>{N=false}},e[0]=r.key,e[1]=s.id,e[2]=p):p=e[2];let h;e[3]!==r.key||e[4]!==r.state||e[5]!==s.id?(h=[r.key,r.state,s.id],e[3]=r.key,e[4]=r.state,e[5]=s.id,e[6]=h):h=e[6],c.useEffect(p,h);let x;e[7]!==r.error||e[8]!==r.state?(x=r.error?n.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]=x):x=e[9];let g;e[10]!==d||e[11]!==a?(g=d?n.jsx("p",{className:"typography-meta text-muted-foreground",children:a("workflows.panel.agent.loadFailed")}):null,e[10]=d,e[11]=a,e[12]=g):g=e[12];let v;e[13]!==i||e[14]!==d||e[15]!==a?(v=!i&&!d?n.jsxs("p",{className:"typography-meta text-muted-foreground",children:[a("workflows.panel.agent.loading"),n.jsx(ri,{})]}):null,e[13]=i,e[14]=d,e[15]=a,e[16]=v):v=e[16];let y;e[17]!==i||e[18]!==f||e[19]!==a?(y=i?n.jsxs(n.Fragment,{children:[n.jsxs("section",{children:[n.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:a("workflows.panel.agent.answer")}),n.jsx("div",{className:"mt-1",children:i.result===void 0?n.jsx("p",{className:"typography-meta text-muted-foreground",children:a("workflows.panel.agent.noAnswer")}):n.jsx(cu,{answer:i.result})})]}),n.jsxs("section",{children:[n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsxs("button",{type:"button",onClick:()=>m(Sv),"aria-expanded":f,className:"flex items-center gap-1 typography-micro font-medium text-muted-foreground hover:text-foreground",children:[n.jsx(ue,{name:"arrow-right-s",className:Ye("size-3.5 transition-transform",f&&"rotate-90 rtl:-rotate-90")}),a("workflows.panel.agent.prompt")]})}),n.jsx(Dt,{sideOffset:6,children:a(f?"contextTooltips.workspace.workflow.promptHide":"contextTooltips.workspace.workflow.promptShow")})]}),f?n.jsx(ps,{as:"pre",dir:"auto",outerClassName:"mt-1 max-h-72",className:"whitespace-pre-wrap break-words font-mono typography-micro text-foreground",disableHorizontal:true,children:i.prompt}):null]})]}):null,e[17]=i,e[18]=f,e[19]=a,e[20]=y):y=e[20];let C;e[21]!==o||e[22]!==a?(C=o?n.jsx("div",{children:n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsxs(yt,{type:"button",size:"xs",variant:"ghost",onClick:o,children:[n.jsx(ue,{name:"chat-4",className:"size-3.5"}),a("workflows.panel.agent.openSession")]})}),n.jsx(Dt,{sideOffset:6,children:a("contextTooltips.workspace.workflow.agentSession")})]})}):null,e[21]=o,e[22]=a,e[23]=C):C=e[23];let S;return e[24]!==x||e[25]!==g||e[26]!==v||e[27]!==y||e[28]!==C?(S=n.jsxs("div",{className:"oc-tile mb-1.5 ms-5 flex flex-col gap-2 rounded-lg px-3 py-2.5",children:[x,g,v,y,C]}),e[24]=x,e[25]=g,e[26]=v,e[27]=y,e[28]=C,e[29]=S):S=e[29],S},xv=t=>{const e=qe.c(57),{run:s,agent:r,showModel:o,columns:a,open:i,onToggle:u,onOpenSession:d}=t,{t:l}=gt();let f,m,p,h,x,g,v,y,C,S,N;if(e[0]!==r||e[1]!==a.tokens||e[2]!==u||e[3]!==i||e[4]!==o||e[5]!==l){const T=hg(r.state),I=gg(r);f="button",h=u,x=i,g=r.label,v="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 b=T.icon,w=T.color?{color:T.color}:void 0,j=l(T.labelKey);e[17]!==T||e[18]!==w||e[19]!==j?(y=n.jsx(ue,{name:b,className:"size-3.5 shrink-0",style:w,"aria-label":j}),e[17]=T,e[18]=w,e[19]=j,e[20]=y):y=e[20],e[21]!==r.label?(C=n.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:r.label}),e[21]=r.label,e[22]=C):C=e[22],e[23]!==r.replayed||e[24]!==l?(S=r.replayed?n.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:l("chat.workflow.agent.reused")}):null,e[23]=r.replayed,e[24]=l,e[25]=S):S=e[25],e[26]!==r.model||e[27]!==o?(N=o&&r.model?n.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:du(r.model)}):null,e[26]=r.model,e[27]=o,e[28]=N):N=e[28];const R=r.replayed?void 0:r.startedAt;e[29]!==r.endedAt||e[30]!==R?(m=n.jsx(pi,{start:R,end:r.endedAt,className:"min-w-12 text-end typography-micro text-muted-foreground"}),e[29]=r.endedAt,e[30]=R,e[31]=m):m=e[31],p=a.tokens?n.jsx("span",{className:"min-w-12 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"auto",children:I===null||r.replayed?"":si(I)}):null,e[0]=r,e[1]=a.tokens,e[2]=u,e[3]=i,e[4]=o,e[5]=l,e[6]=f,e[7]=m,e[8]=p,e[9]=h,e[10]=x,e[11]=g,e[12]=v,e[13]=y,e[14]=C,e[15]=S,e[16]=N}else f=e[6],m=e[7],p=e[8],h=e[9],x=e[10],g=e[11],v=e[12],y=e[13],C=e[14],S=e[15],N=e[16];let F;e[32]!==r.replayed||e[33]!==r.usage||e[34]!==a.cost?(F=a.cost?n.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?ni(r.usage.cost):""}):null,e[32]=r.replayed,e[33]=r.usage,e[34]=a.cost,e[35]=F):F=e[35];let _;e[36]!==f||e[37]!==m||e[38]!==p||e[39]!==F||e[40]!==h||e[41]!==x||e[42]!==g||e[43]!==v||e[44]!==y||e[45]!==C||e[46]!==S||e[47]!==N?(_=n.jsxs("button",{type:f,onClick:h,"aria-expanded":x,title:g,className:v,children:[y,C,S,N,m,p,F]}),e[36]=f,e[37]=m,e[38]=p,e[39]=F,e[40]=h,e[41]=x,e[42]=g,e[43]=v,e[44]=y,e[45]=C,e[46]=S,e[47]=N,e[48]=_):_=e[48];let M;e[49]!==r||e[50]!==d||e[51]!==i||e[52]!==s?(M=i?n.jsx(gv,{run:s,agent:r,onOpenSession:d}):null,e[49]=r,e[50]=d,e[51]=i,e[52]=s,e[53]=M):M=e[53];let B;return e[54]!==_||e[55]!==M?(B=n.jsxs(n.Fragment,{children:[_,M]}),e[54]=_,e[55]=M,e[56]=B):B=e[56],B},bv=(t,e)=>{const s=mg(t);if(s.measured===0)return null;const r=[];return e.tokens&&r.push(si(s.tokens)),e.cost&&s.cost>0&&r.push(ni(s.cost)),r.length>0?r.join(" \xB7 "):null},wv=t=>{const e=new Set(t.map(r=>r.model??null)),[s]=e;return e.size===1&&s?du(s):null},yv=t=>{const e=qe.c(51),{run:s,directory:r}=t,{t:o}=gt();let a;e[0]!==s?(a=ug(s),e[0]=s,e[1]=a):a=e[1];const i=a,u=fg(r),[d,l]=c.useState(kv),[f,m]=c.useState(jv);let p,h,x,g,v,y;if(e[2]!==i||e[3]!==d||e[4]!==u||e[5]!==s||e[6]!==o||e[7]!==f){const N=pg(s),F=N.measured>0,_=N.cost>0;let M,B,T;if(e[14]!==i||e[15]!==d||e[16]!==u||e[17]!==s||e[18]!==o||e[19]!==F||e[20]!==_||e[21]!==f){const I={tokens:F,cost:_},b=s.agents.filter(Tv).length,w=Cv;v="flex h-full min-h-0 flex-col";let j;e[28]!==i||e[29]!==s?(j=n.jsx(hv,{run:s,groups:i}),e[28]=i,e[29]=s,e[30]=j):j=e[30];const R=i.map(L=>{if(L.agents.length===0)return null;const E=L.title??"",D=L.done+L.failed===L.agents.length,V=(s.state==="running"&&D)===f.has(E),J=wv(L.agents),W=bv(L.agents,I);return n.jsxs("section",{className:"mt-3",children:[n.jsxs("button",{type:"button",onClick:()=>w(m,E),"aria-expanded":V,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:[n.jsx(ue,{name:"arrow-right-s",className:Ye("size-3.5 shrink-0 transition-transform",V&&"rotate-90 rtl:-rotate-90")}),n.jsx("span",{className:"min-w-0 truncate",dir:"auto",children:L.title??o("chat.workflow.phase.unphased")}),J?n.jsx("span",{className:"min-w-0 truncate font-normal",dir:"ltr",children:`\xB7 ${J}`}):null,W?n.jsx("span",{className:"ms-auto shrink-0 tabular-nums font-normal",dir:"ltr",children:W}):null,n.jsx("span",{className:Ye("shrink-0 tabular-nums font-normal",!W&&"ms-auto"),dir:"auto",children:W?`\xB7 ${L.done}/${L.agents.length}`:`${L.done}/${L.agents.length}`})]}),V?L.agents.map(G=>{const le=G.sessionId;return n.jsx(xv,{run:s,agent:G,showModel:J===null,columns:I,open:d.has(G.key),onToggle:()=>w(l,G.key),onOpenSession:le?()=>u(le,G.label):null},G.key)}):null]},E)});e[31]!==j||e[32]!==R?(y=n.jsxs(ps,{outerClassName:"min-h-0 flex-1",className:"px-3 py-3",disableHorizontal:true,children:[j,R]}),e[31]=j,e[32]=R,e[33]=y):y=e[33],p="flex shrink-0 flex-wrap items-center gap-x-1.5 border-t border-edge px-3 py-2 typography-micro text-muted-foreground",M="tabular-nums",B="auto",T=o("workflows.panel.summary.agents",{done:b,total:s.agents.length}),e[14]=i,e[15]=d,e[16]=u,e[17]=s,e[18]=o,e[19]=F,e[20]=_,e[21]=f,e[22]=M,e[23]=B,e[24]=T,e[25]=p,e[26]=v,e[27]=y}else M=e[22],B=e[23],T=e[24],p=e[25],v=e[26],y=e[27];e[34]!==M||e[35]!==B||e[36]!==T?(h=n.jsx("span",{className:M,dir:B,children:T}),e[34]=M,e[35]=B,e[36]=T,e[37]=h):h=e[37],e[38]!==s.endedAt||e[39]!==s.startedAt||e[40]!==s.state?(x=s.startedAt!==void 0?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":true,children:"\xB7"}),n.jsx(pi,{start:s.startedAt,end:s.state==="running"?void 0:s.endedAt??s.startedAt})]}):null,e[38]=s.endedAt,e[39]=s.startedAt,e[40]=s.state,e[41]=x):x=e[41],g=N.measured>0?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":true,children:"\xB7"}),n.jsx("span",{className:"tabular-nums",dir:"auto",children:o("workflows.panel.summary.tokens",{tokens:si(N.tokens)})}),N.cost>0?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":true,children:"\xB7"}),n.jsx("span",{className:"tabular-nums",dir:"ltr",children:ni(N.cost)})]}):null]}):null,e[2]=i,e[3]=d,e[4]=u,e[5]=s,e[6]=o,e[7]=f,e[8]=p,e[9]=h,e[10]=x,e[11]=g,e[12]=v,e[13]=y}else p=e[8],h=e[9],x=e[10],g=e[11],v=e[12],y=e[13];let C;e[42]!==p||e[43]!==h||e[44]!==x||e[45]!==g?(C=n.jsxs("div",{className:p,children:[h,x,g]}),e[42]=p,e[43]=h,e[44]=x,e[45]=g,e[46]=C):C=e[46];let S;return e[47]!==v||e[48]!==y||e[49]!==C?(S=n.jsxs("div",{className:v,children:[y,C]}),e[47]=v,e[48]=y,e[49]=C,e[50]=S):S=e[50],S};function vv(t){return t.title!==null}function Sv(t){return!t}function kv(){return new Set}function jv(){return new Set}function Tv(t){return t.state==="completed"}function Cv(t,e){return t(s=>{const r=new Set(s);return r.has(e)?r.delete(e):r.add(e),r})}const Ev={steps:["data-workflows-header-compact","data-workflows-header-tight","data-workflows-header-narrow"]},Iv=[{id:"agents",icon:"flow-chart",labelKey:"workflows.panel.view.agents",tooltipKey:"contextTooltips.workspace.workflow.view.agents"},{id:"log",icon:"file-list-2",labelKey:"workflows.panel.view.log",tooltipKey:"contextTooltips.workspace.workflow.view.log"},{id:"result",icon:"checkbox-circle",labelKey:"workflows.panel.view.result",tooltipKey:"contextTooltips.workspace.workflow.view.result"},{id:"script",icon:"code-sslash",labelKey:"workflows.panel.view.script",tooltipKey:"contextTooltips.workspace.workflow.view.script"}],Nv=1500,Pv=(t,e)=>{const s=qe.c(11),[r,o]=c.useState(null),[a,i]=c.useState(null),u=c.useRef(null),d=e!=="agents",l=e==="log"&&t.state==="running"?t.logs.at(-1)?.at??0:0;let f;s[0]!==t.id||s[1]!==d?(f=()=>{if(!d)return;let g=true;const v=u.current?.runId===t.id?u.current.at:0,y=Math.max(0,v+Nv-Date.now()),C=setTimeout(()=>{u.current={runId:t.id,at:Date.now()},Ng(t.id).then(S=>{g&&(o(S),i(null))}).catch(()=>{g&&i(t.id)})},y);return()=>{g=false,clearTimeout(C)}},s[0]=t.id,s[1]=d,s[2]=f):f=s[2];let m;s[3]!==l||s[4]!==t.id||s[5]!==t.state||s[6]!==d?(m=[l,t.id,t.state,d],s[3]=l,s[4]=t.id,s[5]=t.state,s[6]=d,s[7]=m):m=s[7],c.useEffect(f,m);const p=r?.runId===t.id?r:null,h=a===t.id;let x;return s[8]!==p||s[9]!==h?(x={detail:p,failed:h},s[8]=p,s[9]=h,s[10]=x):x=s[10],x},Rv=t=>new Intl.DateTimeFormat(yd(),{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(t),Dv=t=>{const e=qe.c(8),{run:s,detail:r}=t,{t:o}=gt(),a=r?.logs??s.logs;if(a.length===0){let d;e[0]!==o?(d=o("workflows.panel.log.empty"),e[0]=o,e[1]=d):d=e[1];let l;return e[2]!==d?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:d}),e[2]=d,e[3]=l):l=e[3],l}let i;e[4]!==a?(i=a.map(Wv),e[4]=a,e[5]=i):i=e[5];let u;return e[6]!==i?(u=n.jsx("ol",{className:"flex flex-col gap-1 px-3 py-3",children:i}),e[6]=i,e[7]=u):u=e[7],u},_v=t=>{const e=qe.c(24),{run:s,detail:r,failed:o}=t,{t:a}=gt();if(s.error&&(s.state==="failed"||s.state==="stopped")){const d=s.state==="failed"?"var(--status-error)":void 0;let l;e[0]!==d?(l={color:d},e[0]=d,e[1]=l):l=e[1];let f;return e[2]!==s.error||e[3]!==l?(f=n.jsx("p",{dir:"auto",className:"px-4 py-6 typography-meta",style:l,children:s.error}),e[2]=s.error,e[3]=l,e[4]=f):f=e[4],f}if(s.state==="awaiting-approval"||s.state==="running"||s.state==="declined"){let d;e[5]!==a?(d=a("workflows.panel.result.pending"),e[5]=a,e[6]=d):d=e[6];let l;return e[7]!==d?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:d}),e[7]=d,e[8]=l):l=e[8],l}if(o&&!r){let d;e[9]!==a?(d=a("workflows.panel.detail.loadFailed"),e[9]=a,e[10]=d):d=e[10];let l;return e[11]!==d?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:d}),e[11]=d,e[12]=l):l=e[12],l}if(!r){let d;e[13]!==a?(d=a("workflows.panel.agent.loading"),e[13]=a,e[14]=d):d=e[14];let l;e[15]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(ri,{}),e[15]=l):l=e[15];let f;return e[16]!==d?(f=n.jsxs("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:[d,l]}),e[16]=d,e[17]=f):f=e[17],f}const{result:i}=r;if(!i||i.kind==="json"&&i.value===null){let d;e[18]!==a?(d=a("workflows.panel.result.none"),e[18]=a,e[19]=d):d=e[19];let l;return e[20]!==d?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:d}),e[20]=d,e[21]=l):l=e[21],l}let u;return e[22]!==i?(u=n.jsx("div",{className:"px-4 py-3",children:n.jsx(cu,{answer:i})}),e[22]=i,e[23]=u):u=e[23],u},Av=t=>{const e=qe.c(16),{detail:s,failed:r}=t,{t:o}=gt();if(!s){let m;e[0]!==r||e[1]!==o?(m=r?o("workflows.panel.detail.loadFailed"):n.jsxs(n.Fragment,{children:[o("workflows.panel.agent.loading"),n.jsx(ri,{})]}),e[0]=r,e[1]=o,e[2]=m):m=e[2];let p;return e[3]!==m?(p=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:m}),e[3]=m,e[4]=p):p=e[4],p}const a=s.args;let i;e[5]!==a?(i=a!=null&&JSON.stringify(a)!=="{}",e[5]=a,e[6]=i):i=e[6];const u=i;let d;e[7]!==a||e[8]!==u||e[9]!==o?(d=u?n.jsxs("section",{children:[n.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:o("workflows.panel.script.args")}),n.jsx(ps,{as:"pre",dir:"ltr",outerClassName:"overlay-scrollbar-wrapper--no-gutter oc-tile mt-1 rounded-lg",fillContainer:false,className:"px-3 py-2 font-mono typography-micro text-foreground",children:JSON.stringify(a,null,2)})]}):null,e[7]=a,e[8]=u,e[9]=o,e[10]=d):d=e[10];let l;e[11]!==s.script?(l=n.jsx(ps,{as:"pre",dir:"ltr",outerClassName:"overlay-scrollbar-wrapper--no-gutter oc-tile rounded-lg",fillContainer:false,className:"px-3 py-2 font-mono typography-micro leading-relaxed text-foreground",children:s.script}),e[11]=s.script,e[12]=l):l=e[12];let f;return e[13]!==d||e[14]!==l?(f=n.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3",children:[d,l]}),e[13]=d,e[14]=l,e[15]=f):f=e[15],f},Ov=t=>{const e=qe.c(83),{run:s}=t,{t:r}=gt(),{pending:o,act:a}=Ig(),i=o===s.id;if(s.state==="awaiting-approval"){let u;e[0]!==r?(u=r("contextTooltips.workspace.workflow.approve"),e[0]=r,e[1]=u):u=e[1];let d;e[2]!==a||e[3]!==s.id?(d=()=>a(s.id,"approve"),e[2]=a,e[3]=s.id,e[4]=d):d=e[4];let l;e[5]!==r?(l=r("chat.workflow.action.run"),e[5]=r,e[6]=l):l=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(ue,{name:"play",className:"size-3.5"}),e[7]=f):f=e[7];let m;e[8]!==r?(m=r("chat.workflow.action.run"),e[8]=r,e[9]=m):m=e[9];let p;e[10]!==m?(p=n.jsx("span",{className:"workflows-header__action-label",children:m}),e[10]=m,e[11]=p):p=e[11];let h;e[12]!==i||e[13]!==d||e[14]!==l||e[15]!==p?(h=n.jsxs(yt,{type:"button",size:"sm",disabled:i,onClick:d,"aria-label":l,children:[f,p]}),e[12]=i,e[13]=d,e[14]=l,e[15]=p,e[16]=h):h=e[16];let x;e[17]!==u||e[18]!==h?(x=n.jsx(es,{label:u,side:"bottom",className:"shrink-0",children:h}),e[17]=u,e[18]=h,e[19]=x):x=e[19];let g;e[20]!==r?(g=r("contextTooltips.workspace.workflow.decline"),e[20]=r,e[21]=g):g=e[21];let v;e[22]!==a||e[23]!==s.id?(v=()=>a(s.id,"decline"),e[22]=a,e[23]=s.id,e[24]=v):v=e[24];let y;e[25]!==r?(y=r("chat.workflow.action.decline"),e[25]=r,e[26]=y):y=e[26];let C;e[27]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(ue,{name:"close",className:"size-3.5"}),e[27]=C):C=e[27];let S;e[28]!==r?(S=r("chat.workflow.action.decline"),e[28]=r,e[29]=S):S=e[29];let N;e[30]!==S?(N=n.jsx("span",{className:"workflows-header__action-label",children:S}),e[30]=S,e[31]=N):N=e[31];let F;e[32]!==i||e[33]!==v||e[34]!==y||e[35]!==N?(F=n.jsxs(yt,{type:"button",size:"sm",variant:"outline",disabled:i,onClick:v,"aria-label":y,children:[C,N]}),e[32]=i,e[33]=v,e[34]=y,e[35]=N,e[36]=F):F=e[36];let _;e[37]!==F||e[38]!==g?(_=n.jsx(es,{label:g,side:"bottom",className:"shrink-0",children:F}),e[37]=F,e[38]=g,e[39]=_):_=e[39];let M;return e[40]!==_||e[41]!==x?(M=n.jsxs(n.Fragment,{children:[x,_]}),e[40]=_,e[41]=x,e[42]=M):M=e[42],M}if(s.state==="running"){let u;e[43]!==r?(u=r("contextTooltips.workspace.workflow.stop"),e[43]=r,e[44]=u):u=e[44];let d;e[45]!==a||e[46]!==s.id?(d=()=>a(s.id,"stop"),e[45]=a,e[46]=s.id,e[47]=d):d=e[47];let l;e[48]!==r?(l=r("chat.workflow.action.stop"),e[48]=r,e[49]=l):l=e[49];let f;e[50]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(ue,{name:"stop",className:"size-3.5"}),e[50]=f):f=e[50];let m;e[51]!==r?(m=r("chat.workflow.action.stop"),e[51]=r,e[52]=m):m=e[52];let p;e[53]!==m?(p=n.jsx("span",{className:"workflows-header__action-label",children:m}),e[53]=m,e[54]=p):p=e[54];let h;e[55]!==i||e[56]!==d||e[57]!==l||e[58]!==p?(h=n.jsxs(yt,{type:"button",size:"sm",variant:"outline",disabled:i,onClick:d,"aria-label":l,children:[f,p]}),e[55]=i,e[56]=d,e[57]=l,e[58]=p,e[59]=h):h=e[59];let x;return e[60]!==u||e[61]!==h?(x=n.jsx(es,{label:u,side:"bottom",className:"shrink-0",children:h}),e[60]=u,e[61]=h,e[62]=x):x=e[62],x}if(s.state==="failed"||s.state==="stopped"){let u;e[63]!==r?(u=r("contextTooltips.workspace.workflow.resume"),e[63]=r,e[64]=u):u=e[64];let d;e[65]!==a||e[66]!==s.id?(d=()=>a(s.id,"resume"),e[65]=a,e[66]=s.id,e[67]=d):d=e[67];let l;e[68]!==r?(l=r("chat.workflow.action.resume"),e[68]=r,e[69]=l):l=e[69];let f;e[70]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(ue,{name:"restart",className:"size-3.5"}),e[70]=f):f=e[70];let m;e[71]!==r?(m=r("chat.workflow.action.resume"),e[71]=r,e[72]=m):m=e[72];let p;e[73]!==m?(p=n.jsx("span",{className:"workflows-header__action-label",children:m}),e[73]=m,e[74]=p):p=e[74];let h;e[75]!==i||e[76]!==d||e[77]!==l||e[78]!==p?(h=n.jsxs(yt,{type:"button",size:"sm",variant:"outline",disabled:i,onClick:d,"aria-label":l,children:[f,p]}),e[75]=i,e[76]=d,e[77]=l,e[78]=p,e[79]=h):h=e[79];let x;return e[80]!==u||e[81]!==h?(x=n.jsx(es,{label:u,side:"bottom",className:"shrink-0",children:h}),e[80]=u,e[81]=h,e[82]=x):x=e[82],x}return null},Mv=()=>{const t=qe.c(2),e=os(Vv);let s;return t[0]!==e?(s={get:r=>e.get(r)?.title},t[0]=e,t[1]=s):s=t[1],s},yl=t=>{const e=qe.c(31),{run:s,selected:r,caption:o,onSelect:a}=t,{t:i}=gt();let u,d,l,f,m,p,h;if(e[0]!==a||e[1]!==s.state||e[2]!==i){const N=wd(s.state);d=Ks,h=a,u=ue,l=N.icon,f="size-3.5 shrink-0",m=N.color?{color:N.color}:void 0,p=i(N.labelKey),e[0]=a,e[1]=s.state,e[2]=i,e[3]=u,e[4]=d,e[5]=l,e[6]=f,e[7]=m,e[8]=p,e[9]=h}else u=e[3],d=e[4],l=e[5],f=e[6],m=e[7],p=e[8],h=e[9];let x;e[10]!==u||e[11]!==l||e[12]!==f||e[13]!==m||e[14]!==p?(x=n.jsx(u,{name:l,className:f,style:m,"aria-label":p}),e[10]=u,e[11]=l,e[12]=f,e[13]=m,e[14]=p,e[15]=x):x=e[15];let g;e[16]!==s.name?(g=n.jsx("span",{className:"truncate",dir:"auto",children:s.name}),e[16]=s.name,e[17]=g):g=e[17];let v;e[18]!==o?(v=o?n.jsx("span",{className:"truncate typography-micro text-muted-foreground",dir:"auto",children:o}):null,e[18]=o,e[19]=v):v=e[19];let y;e[20]!==g||e[21]!==v?(y=n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[g,v]}),e[20]=g,e[21]=v,e[22]=y):y=e[22];let C;e[23]!==r?(C=r?n.jsx(ue,{name:"check",className:"size-3.5 shrink-0"}):null,e[23]=r,e[24]=C):C=e[24];let S;return e[25]!==d||e[26]!==C||e[27]!==h||e[28]!==x||e[29]!==y?(S=n.jsxs(d,{onSelect:h,children:[x,y,C]}),e[25]=d,e[26]=C,e[27]=h,e[28]=x,e[29]=y,e[30]=S):S=e[30],S},Fv=t=>{const e=qe.c(63),{runs:s,selected:r,sessionId:o,sessionTitles:a,saved:i,onSelect:u,onRunSaved:d,onDelete:l}=t,{t:f}=gt();let m;e[0]!==r.state?(m=wd(r.state),e[0]=r.state,e[1]=m):m=e[1];const p=m;let h,x,g,v,y,C,S;if(e[2]!==p.color||e[3]!==p.icon||e[4]!==u||e[5]!==s||e[6]!==r.id||e[7]!==r.name||e[8]!==o||e[9]!==a||e[10]!==f){const B=s.slice().reverse();let T;e[18]!==o?(T=G=>G.parentSessionId===o,e[18]=o,e[19]=T):T=e[19];const I=B.filter(T);let b;e[20]!==o?(b=G=>G.parentSessionId!==o,e[20]=o,e[21]=b):b=e[21];const w=B.filter(b);x=Sn;let j;e[22]!==f?(j=f("workflows.panel.runPicker"),e[22]=f,e[23]=j):j=e[23];let R;e[24]===Symbol.for("react.memo_cache_sentinel")?(R=Ye(Eg(),"max-w-[14rem] shrink-0"),e[24]=R):R=e[24];let L;e[25]!==p.color?(L=p.color?{color:p.color}:void 0,e[25]=p.color,e[26]=L):L=e[26];let E;e[27]!==p.icon||e[28]!==L?(E=n.jsx(ue,{name:p.icon,className:"size-3.5",style:L}),e[27]=p.icon,e[28]=L,e[29]=E):E=e[29];let D;e[30]!==r.name?(D=n.jsx("span",{className:"workflows-header__run-name min-w-0 truncate",dir:"auto",children:r.name}),e[30]=r.name,e[31]=D):D=e[31];let U;e[32]===Symbol.for("react.memo_cache_sentinel")?(U=n.jsx(ue,{name:"arrow-down-s",className:"size-4"}),e[32]=U):U=e[32];let V;e[33]!==E||e[34]!==D||e[35]!==j?(V=n.jsx(Pt,{asChild:true,children:n.jsx(kn,{asChild:true,children:n.jsxs("button",{type:"button","aria-label":j,className:R,children:[E,D,U]})})}),e[33]=E,e[34]=D,e[35]=j,e[36]=V):V=e[36];let J;e[37]!==f?(J=f("contextTooltips.workspace.workflow.pickRun"),e[37]=f,e[38]=J):J=e[38];let W;e[39]!==J?(W=n.jsx(Dt,{side:"bottom",sideOffset:6,children:J}),e[39]=J,e[40]=W):W=e[40],e[41]!==V||e[42]!==W?(S=n.jsxs(Rt,{children:[V,W]}),e[41]=V,e[42]=W,e[43]=S):S=e[43],h=jn,g="start",v="max-h-[min(var(--available-height),28rem)] w-[18rem] max-w-[calc(100vw-2rem)] overflow-y-auto",y=I.length>0?n.jsxs(n.Fragment,{children:[n.jsx(Hr,{children:f("workflows.panel.picker.thisSession")}),I.map(G=>n.jsx(yl,{run:G,selected:G.id===r.id,onSelect:()=>u(G.id)},G.id))]}):null,C=w.length>0?n.jsxs(n.Fragment,{children:[I.length>0?n.jsx(tr,{}):null,n.jsx(Hr,{children:f("workflows.panel.picker.otherSessions")}),w.map(G=>n.jsx(yl,{run:G,selected:G.id===r.id,caption:a.get(G.parentSessionId)||f("workflows.panel.picker.untitledSession"),onSelect:()=>u(G.id)},G.id))]}):null,e[2]=p.color,e[3]=p.icon,e[4]=u,e[5]=s,e[6]=r.id,e[7]=r.name,e[8]=o,e[9]=a,e[10]=f,e[11]=h,e[12]=x,e[13]=g,e[14]=v,e[15]=y,e[16]=C,e[17]=S}else h=e[11],x=e[12],g=e[13],v=e[14],y=e[15],C=e[16],S=e[17];let N;e[44]!==d||e[45]!==i||e[46]!==f?(N=i.length>0?n.jsxs(n.Fragment,{children:[n.jsx(tr,{}),n.jsx(Hr,{children:f("workflows.panel.picker.saved")}),i.map(B=>n.jsxs(Ks,{disabled:!!B.error,onSelect:()=>d(B.name),title:B.error??B.description,children:[n.jsx(ue,{name:"play",className:"size-3.5 shrink-0"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:B.name})]},B.name))]}):null,e[44]=d,e[45]=i,e[46]=f,e[47]=N):N=e[47];let F;e[48]!==l||e[49]!==f?(F=l?n.jsxs(n.Fragment,{children:[n.jsx(tr,{}),n.jsxs(Ks,{variant:"destructive",onSelect:l,children:[n.jsx(ue,{name:"delete-bin",className:"size-3.5 shrink-0"}),f("workflows.panel.delete.action")]})]}):null,e[48]=l,e[49]=f,e[50]=F):F=e[50];let _;e[51]!==h||e[52]!==g||e[53]!==v||e[54]!==y||e[55]!==C||e[56]!==N||e[57]!==F?(_=n.jsxs(h,{align:g,className:v,children:[y,C,N,F]}),e[51]=h,e[52]=g,e[53]=v,e[54]=y,e[55]=C,e[56]=N,e[57]=F,e[58]=_):_=e[58];let M;return e[59]!==x||e[60]!==S||e[61]!==_?(M=n.jsxs(x,{children:[S,_]}),e[59]=x,e[60]=S,e[61]=_,e[62]=M):M=e[62],M},Lv=(t,e,s,r)=>{const o=qe.c(11),{t:a}=gt(),{confirm:i,dialog:u}=ei(),d=oi(Uv);let l;o[0]!==i||o[1]!==t||o[2]!==e||o[3]!==d||o[4]!==r||o[5]!==s||o[6]!==a?(l=async p=>{if(!(!t||!e||!await i({title:a("workflows.panel.saved.confirmTitle",{name:p}),message:a(s?"workflows.panel.saved.confirmHere":"workflows.panel.saved.confirmNew"),action:a("workflows.panel.saved.confirmAction")})))try{const x=await kg({directory:t,scriptDirectory:e,sessionId:s,name:p});s?d(r,x.runId):(d(x.sessionId,x.runId),it.getState().setCurrentSession(x.sessionId,t))}catch(x){const g=x;Fe.error(a("workflows.panel.saved.failed"),{description:g instanceof Error?g.message:void 0})}},o[0]=i,o[1]=t,o[2]=e,o[3]=d,o[4]=r,o[5]=s,o[6]=a,o[7]=l):l=o[7];const f=l;let m;return o[8]!==u||o[9]!==f?(m={run:f,dialog:u},o[8]=u,o[9]=f,o[10]=m):m=o[10],m},$v=t=>{const e=qe.c(23),{saved:s,onRunSaved:r}=t,{t:o}=gt();if(s.length===0){let m;e[0]!==o?(m=o("workflows.panel.emptyProject"),e[0]=o,e[1]=m):m=e[1];let p;return e[2]!==m?(p=n.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-meta text-muted-foreground",children:m}),e[2]=m,e[3]=p):p=e[3],p}let a;e[4]!==o?(a=o("workflows.panel.emptyProject"),e[4]=o,e[5]=a):a=e[5];let i;e[6]!==a?(i=n.jsx("p",{className:"typography-meta text-muted-foreground",children:a}),e[6]=a,e[7]=i):i=e[7];let u;e[8]!==o?(u=o("workflows.panel.picker.saved"),e[8]=o,e[9]=u):u=e[9];let d;e[10]!==u?(d=n.jsx("h4",{className:"mt-2 typography-micro font-medium text-muted-foreground",children:u}),e[10]=u,e[11]=d):d=e[11];let l;if(e[12]!==r||e[13]!==s||e[14]!==o){let m;e[16]!==r||e[17]!==o?(m=p=>n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate typography-meta text-foreground",dir:"auto",children:p.name}),p.description||p.error?n.jsx("div",{className:"truncate typography-micro text-muted-foreground",dir:"auto",title:p.error??p.description,children:p.error??p.description}):null]}),n.jsx(es,{label:o("workflows.panel.saved.runAria",{name:p.name}),className:"shrink-0",children:n.jsxs(yt,{type:"button",size:"sm",variant:"outline",disabled:!!p.error,onClick:()=>r(p.name),"aria-label":o("workflows.panel.saved.runAria",{name:p.name}),children:[n.jsx(ue,{name:"play",className:"size-3.5"}),o("workflows.panel.saved.confirmAction")]})})]},p.name),e[16]=r,e[17]=o,e[18]=m):m=e[18],l=s.map(m),e[12]=r,e[13]=s,e[14]=o,e[15]=l}else l=e[15];let f;return e[19]!==i||e[20]!==d||e[21]!==l?(f=n.jsxs("div",{className:"flex flex-col gap-1 px-3 py-3",children:[i,d,l]}),e[19]=i,e[20]=d,e[21]=l,e[22]=f):f=e[22],f},Bv=t=>{const e=qe.c(17),{directory:s}=t,r=it(Hv),o=yg(s),a=vg(o),i=Sg(o?.savedDirectory??null),u=r??`directory:${s??""}`;let d;e[0]!==u?(d=v=>v.selectedBySession[u],e[0]=u,e[1]=d):d=e[1];const l=oi(d),{run:f,dialog:m}=Lv(s,o?.savedDirectory??null,r,u);let p;e[2]!==a||e[3]!==l||e[4]!==r?(p=a.find(v=>v.id===l)??a.filter(v=>v.parentSessionId===r).at(-1)??a.at(-1)??null,e[2]=a,e[3]=l,e[4]=r,e[5]=p):p=e[5];const h=p;let x;e[6]!==s||e[7]!==h||e[8]!==f||e[9]!==a||e[10]!==i||e[11]!==u||e[12]!==r?(x=h?n.jsx(zv,{sessionId:r,selectionKey:u,runs:a,saved:i,run:h,directory:s,onRunSaved:v=>{f(v)}}):n.jsx($v,{saved:i,onRunSaved:v=>{f(v)}}),e[6]=s,e[7]=h,e[8]=f,e[9]=a,e[10]=i,e[11]=u,e[12]=r,e[13]=x):x=e[13];let g;return e[14]!==m||e[15]!==x?(g=n.jsxs(n.Fragment,{children:[m,x]}),e[14]=m,e[15]=x,e[16]=g):g=e[16],g},zv=t=>{const e=qe.c(58),{sessionId:s,selectionKey:r,runs:o,saved:a,run:i,directory:u,onRunSaved:d}=t,{t:l}=gt(),f=oi(Kv),m=Mv(),[p,h]=c.useState("agents"),{detail:x,failed:g}=Pv(i,p),v=c.useRef(null);jg(v,Ev);const{confirm:y,dialog:C}=ei(),S=i.state==="running"||i.state==="awaiting-approval",N=i.parentSessionId!==s;let F;e[0]!==y||e[1]!==i.id||e[2]!==i.name||e[3]!==i.parentSessionId||e[4]!==l?(F=async()=>{if(await y({title:l("workflows.panel.delete.title",{name:i.name}),message:l("workflows.panel.delete.message"),action:l("workflows.panel.delete.confirm"),destructive:true}))try{await Tg(i.id),Cg.getState().remove(i.parentSessionId,i.id)}catch(G){const le=G;Fe.error(l("workflows.panel.delete.failed"),{description:le instanceof Error?le.message:void 0})}},e[0]=y,e[1]=i.id,e[2]=i.name,e[3]=i.parentSessionId,e[4]=l,e[5]=F):F=e[5];const _=F;let M;e[6]!==i.directory||e[7]!==i.id||e[8]!==i.parentSessionId||e[9]!==f?(M=()=>{f(i.parentSessionId,i.id),it.getState().setCurrentSession(i.parentSessionId,i.directory)},e[6]=i.directory,e[7]=i.id,e[8]=i.parentSessionId,e[9]=f,e[10]=M):M=e[10];const B=M;let T;e[11]!==f||e[12]!==r?(T=W=>f(r,W),e[11]=f,e[12]=r,e[13]=T):T=e[13];let I;e[14]!==_||e[15]!==S?(I=S?null:()=>{_()},e[14]=_,e[15]=S,e[16]=I):I=e[16];let b;e[17]!==d||e[18]!==i||e[19]!==o||e[20]!==a||e[21]!==s||e[22]!==m||e[23]!==T||e[24]!==I?(b=n.jsx(Fv,{runs:o,selected:i,sessionId:s,sessionTitles:m,saved:a,onSelect:T,onRunSaved:d,onDelete:I}),e[17]=d,e[18]=i,e[19]=o,e[20]=a,e[21]=s,e[22]=m,e[23]=T,e[24]=I,e[25]=b):b=e[25];let w;e[26]!==l?(w=l("workflows.panel.view.label"),e[26]=l,e[27]=w):w=e[27];let j;e[28]!==l||e[29]!==p?(j=Iv.map(W=>{const G=W.id===p;return n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsxs("button",{type:"button",onClick:()=>h(W.id),"aria-current":G?"page":void 0,"aria-label":l(W.labelKey),className:Ye("flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 transition-colors",G?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground"),children:[n.jsx(ue,{name:W.icon,className:"size-3.5 shrink-0"}),n.jsx("span",{className:"workflows-header__label whitespace-nowrap typography-meta",children:l(W.labelKey)})]})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:l(W.tooltipKey)})]},W.id)}),e[28]=l,e[29]=p,e[30]=j):j=e[30];let R;e[31]!==w||e[32]!==j?(R=n.jsx("nav",{className:"flex shrink-0 items-center gap-1","aria-label":w,children:j}),e[31]=w,e[32]=j,e[33]=R):R=e[33];let L;e[34]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("div",{"aria-hidden":true,className:"min-w-0 flex-1"}),e[34]=L):L=e[34];let E;e[35]!==N||e[36]!==B||e[37]!==i.parentSessionId||e[38]!==m||e[39]!==l?(E=N?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsxs(yt,{type:"button",size:"sm",variant:"ghost",onClick:B,"aria-label":l("workflows.panel.agent.openSession"),children:[n.jsx(ue,{name:"chat-4",className:"size-3.5"}),n.jsx("span",{className:"workflows-header__action-label",children:l("workflows.panel.agent.openSession")})]})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:m.get(i.parentSessionId)||l("workflows.panel.picker.untitledSession")})]}):null,e[35]=N,e[36]=B,e[37]=i.parentSessionId,e[38]=m,e[39]=l,e[40]=E):E=e[40];let D;e[41]!==i?(D=n.jsx(Ov,{run:i}),e[41]=i,e[42]=D):D=e[42];let U;e[43]!==E||e[44]!==D||e[45]!==b||e[46]!==R?(U=n.jsx(bd,{children:n.jsxs("div",{ref:v,className:"workflows-header flex min-w-0 flex-1 flex-nowrap items-center gap-1.5 overflow-hidden ps-1 pe-1",children:[b,R,L,E,D]})}),e[43]=E,e[44]=D,e[45]=b,e[46]=R,e[47]=U):U=e[47];let V;e[48]!==x||e[49]!==u||e[50]!==g||e[51]!==i||e[52]!==p?(V=p==="agents"?n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(yv,{run:i,directory:u},i.id)}):n.jsxs(ps,{outerClassName:"min-h-0 flex-1",disableHorizontal:true,children:[p==="log"?n.jsx(Dv,{run:i,detail:x}):null,p==="result"?n.jsx(_v,{run:i,detail:x,failed:g}):null,p==="script"?n.jsx(Av,{detail:x,failed:g}):null]}),e[48]=x,e[49]=u,e[50]=g,e[51]=i,e[52]=p,e[53]=V):V=e[53];let J;return e[54]!==C||e[55]!==U||e[56]!==V?(J=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[C,U,V]}),e[54]=C,e[55]=U,e[56]=V,e[57]=J):J=e[57],J};function Wv(t,e){return n.jsxs("li",{className:"flex min-w-0 gap-3 typography-meta",children:[n.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",dir:"ltr",children:Rv(t.at)}),n.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words text-foreground",dir:"auto",children:t.message})]},`${t.at}-${e}`)}function Vv(t){return t.entityById}function Uv(t){return t.select}function Hv(t){return t.currentSessionId}function Kv(t){return t.select}const vl=60,qv=t=>{try{return new URL(t).origin}catch{return""}},Qo=new Set,uu=Io()((t,e)=>({byOrigin:{},resolve:(s,r,o)=>{const a=qv(s);!a||!r||e().byOrigin[a]||Qo.has(a)||(Qo.add(a),en("desktop_browser_fetch_favicon",{url:r,webContentsId:o}).then(i=>{const u=typeof i?.dataUrl=="string"?i.dataUrl:"";u&&t(d=>{const l={...d.byOrigin,[a]:u},f=Object.keys(l);if(f.length<=vl)return{byOrigin:l};for(const m of f.slice(0,f.length-vl))delete l[m];return{byOrigin:l}})}).catch(()=>{}).finally(()=>{Qo.delete(a)}))}})),mi=t=>t,ka=t=>{const e=mi(t).type;return typeof e=="string"?e:""},Gv=t=>{const e=mi(t).tool;return typeof e=="string"?e:""},Zv=t=>{const e=mi(t).text;return typeof e=="string"?e:""},Xv=t=>{const e=ka(t);return e==="tool"?Gv(t).trim().toLowerCase()||"tool":e||"unknown"},Yv=t=>{if(t.length===0)return"";const e=[];for(const s of t){const r=Xv(s);e.includes(r)||e.push(r)}return e.join(" + ")},Jv=t=>t.replace(/\s+/g," ").trim(),Qv=t=>{for(const s of t)if(ka(s)==="text"){const r=Jv(Zv(s));if(r.length===0)continue;return r}const e=t.filter(s=>ka(s)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},eS=(t,e,s)=>`${s(t)} / ${s(e)}`,tS=t=>{if(t==="12h")return true;if(t==="24h")return false},sS=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const s=tS(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:s===false?"2-digit":"numeric",minute:"2-digit",...s===void 0?{}:{hour12:s}})},nS=(t,{windowTokens:e,compacted:s=false})=>{const r=s?0:e,o=Number.isFinite(r)&&r>0?r:0,a=t.user+t.assistant+t.tool+t.other,i=Math.max(o,a);return{user:t.user,assistant:t.assistant,tool:t.tool,other:i-a,total:i}},ja={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},lo={user:0,assistant:0,tool:0,other:0},Ws=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,fu=t=>{const e=t.info.tokens,s=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof s=="number")return{...ja,total:Ws(s)};if(!s||typeof s!="object")return ja;const r=s,o=Ws(r.input),a=Ws(r.output),i=Ws(r.reasoning),u=Ws(r.cache?.read),d=Ws(r.cache?.write),l=Ws(r.total);return{input:o,output:a,reasoning:i,cacheRead:u,cacheWrite:d,total:l>0?l:o+a+i+u+d}},rS=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},xs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,s)=>e+xs(s),0):t&&typeof t=="object"?Object.values(t).reduce((e,s)=>e+xs(s),0):0,oS=(t,e)=>{const s=t,r=typeof s.type=="string"?s.type:"";if(r==="reasoning")return{...lo,assistant:xs(s.text)+xs(s.content)};const o=rS(s.text,s.content,s.value,s.source?.value,s.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:xs(s.input)+xs(s.output)+xs(s.error)+xs(s.call?.input)+xs(s.call?.output)+xs(s.call?.error)+xs(s.raw)+Math.round(xs(s.metadata)*.25)+Math.round(xs(s.state)*.1)+Math.round((kf(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}},pu=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),aS=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",Sl=new WeakMap,iS=t=>{const e=Sl.get(t);if(e)return e;const s=aS(t);let r={...lo};for(const o of t.parts)r=pu(r,oS(o,s));return Sl.set(t,r),r},lS=(t,e)=>{if(t.length===0)return{...lo};const s=t.reduce((r,o)=>pu(r,iS(o)),{...lo});return s.user+=e.length,{user:Math.ceil(s.user/4),assistant:Math.ceil(s.assistant/4),tool:Math.ceil(s.tool/4),other:Math.ceil(s.other/4)}},xn=t=>t.toLocaleString(yd()),cS=(t,e)=>!t||!Number.isFinite(t)?"-":Mg(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),dS=(t,e,s)=>{const r=t.find(a=>a.id===e),o=r?.models?.find(a=>a.id===s);return{providerName:r?.name||e||"-",modelName:o?.name||s||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},kl=t=>{const e=qe.c(21),{title:s,figures:r}=t,{t:o}=gt();let a,i,u,d;if(e[0]!==r?.cacheHitPercent||e[1]!==r?.cacheRead||e[2]!==r?.cacheWrite||e[3]!==r?.output||e[4]!==r?.prompt||e[5]!==r?.reasoning||e[6]!==o||e[7]!==s){const m=[{label:o("contextSidebar.tokens.input"),value:r?.prompt??null,format:"count"},{label:o("contextSidebar.tokens.output"),value:r?.output??null,format:"count"},{label:o("contextSidebar.tokens.reasoning"),value:r?.reasoning??null,format:"count"},{label:o("contextSidebar.tokens.cacheRead"),value:r?.cacheRead??null,format:"count"},{label:o("contextSidebar.tokens.cacheWrite"),value:r?.cacheWrite??null,format:"count"},{label:o("contextSidebar.tokens.cacheHit"),value:r?.cacheHitPercent??null,format:"percent"}];u="mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",e[12]!==s?(d=n.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:s}),e[12]=s,e[13]=d):d=e[13],a="grid grid-cols-3 gap-x-4 gap-y-2.5",i=m.map(pS),e[0]=r?.cacheHitPercent,e[1]=r?.cacheRead,e[2]=r?.cacheWrite,e[3]=r?.output,e[4]=r?.prompt,e[5]=r?.reasoning,e[6]=o,e[7]=s,e[8]=a,e[9]=i,e[10]=u,e[11]=d}else a=e[8],i=e[9],u=e[10],d=e[11];let l;e[14]!==a||e[15]!==i?(l=n.jsx("div",{className:a,children:i}),e[14]=a,e[15]=i,e[16]=l):l=e[16];let f;return e[17]!==u||e[18]!==d||e[19]!==l?(f=n.jsxs("div",{className:u,children:[d,l]}),e[17]=u,e[18]=d,e[19]=l,e[20]=f):f=e[20],f},uS=c.memo(function(e){const s=qe.c(54),{message:r,isExpanded:o,isCopied:a,timeFormatPreference:i,onToggle:u,onCopy:d}=e,{t:l}=gt(),f=r.info.role,m=f==="assistant",p=f==="user",h=r.info.time?.created??null;let x;s[0]!==r.parts?(x=Yv(r.parts),s[0]=r.parts,s[1]=x):x=s[1];const g=x;let v,y,C,S;if(s[2]!==m||s[3]!==p||s[4]!==r||s[5]!==h||s[6]!==g||s[7]!==i){const U=m?fu(r):null;let V;s[12]!==p||s[13]!==r.parts?(V=p?Qv(r.parts):"",s[12]=p,s[13]=r.parts,s[14]=V):V=s[14],S=V;let J;s[15]!==h||s[16]!==i?(J=sS(h,i),s[15]=h,s[16]=i,s[17]=J):J=s[17],y=J,v=g||"\u2014",C=U?eS(U.input,U.output,xn):"",s[2]=m,s[3]=p,s[4]=r,s[5]=h,s[6]=g,s[7]=i,s[8]=v,s[9]=y,s[10]=C,s[11]=S}else v=s[8],y=s[9],C=s[10],S=s[11];const N=C,F=f||"unknown",_=g?`${F}: ${g}`:F;let M;s[18]!==o||s[19]!==r.info||s[20]!==r.parts?(M=o?JSON.stringify({info:r.info,parts:r.parts},null,2):"",s[18]=o,s[19]=r.info,s[20]=r.parts,s[21]=M):M=s[21];const B=M;let T;s[22]!==r.info.id||s[23]!==u?(T=()=>u(r.info.id),s[22]=r.info.id,s[23]=u,s[24]=T):T=s[24];const I=m?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content";let b;s[25]!==I?(b={gridTemplateColumns:I},s[25]=I,s[26]=b):b=s[26];let w;s[27]!==v||s[28]!==N||s[29]!==m||s[30]!==p||s[31]!==_||s[32]!==S?(w=p?n.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[n.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",S]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:m?v:_}),m&&n.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:N})]}),s[27]=v,s[28]=N,s[29]=m,s[30]=p,s[31]=_,s[32]=S,s[33]=w):w=s[33];let j;s[34]!==y?(j=n.jsx("span",{className:"text-end text-muted-foreground",children:y}),s[34]=y,s[35]=j):j=s[35];let R;s[36]!==b||s[37]!==w||s[38]!==j?(R=n.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:b,children:[w,j]}),s[36]=b,s[37]=w,s[38]=j,s[39]=R):R=s[39];let L;s[40]!==o||s[41]!==T||s[42]!==R?(L=n.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-start hover:bg-[var(--interactive-hover)]","aria-expanded":o,onClick:T,children:R}),s[40]=o,s[41]=T,s[42]=R,s[43]=L):L=s[43];let E;s[44]!==a||s[45]!==o||s[46]!==B||s[47]!==r.info.id||s[48]!==d||s[49]!==l?(E=o&&n.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:n.jsxs(ps,{outerClassName:"max-h-[26rem] bg-[var(--surface-background)]",className:"group relative",disableHorizontal:true,children:[n.jsx("div",{className:"absolute top-1 inset-e-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:U=>{U.stopPropagation(),d(r.info.id,B)},"aria-label":l(a?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),children:a?n.jsx(ue,{name:"check",className:"size-3.5"}):n.jsx(ue,{name:"file-copy",className:"size-3.5"})})}),n.jsx(Dt,{sideOffset:6,children:l(a?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson")})]})}),n.jsx(Pg,{language:"json",code:B,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:true})]})}),s[44]=a,s[45]=o,s[46]=B,s[47]=r.info.id,s[48]=d,s[49]=l,s[50]=E):E=s[50];let D;return s[51]!==L||s[52]!==E?(D=n.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[L,E]}),s[51]=L,s[52]=E,s[53]=D):D=s[53],D}),fS=()=>{const t=qe.c(216),{t:e}=gt(),s=Rg(),r=K(mS);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={},t[0]=o):o=t[0];const[a,i]=c.useState(o),[u,d]=c.useState(null),l=c.useRef(null),f=it(hS),m=it(gS),p=Dg(m??void 0),h=_g(f??"",m??void 0),x=Ut(xS);let g;t[1]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null),i(bS),d(null)},t[1]=g):g=t[1];let v;t[2]!==m||t[3]!==f?(v=[m,f],t[2]=m,t[3]=f,t[4]=v):v=t[4],c.useEffect(g,v);let y,C;t[5]===Symbol.for("react.memo_cache_sentinel")?(y=()=>()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},C=[],t[5]=y,t[6]=C):(y=t[5],C=t[6]),c.useEffect(y,C);let S;t[7]===Symbol.for("react.memo_cache_sentinel")?(S=He=>{i(pt=>({...pt,[He]:pt[He]!==true}))},t[7]=S):S=t[7];const N=S;let F;t[8]===Symbol.for("react.memo_cache_sentinel")?(F=async(He,pt)=>{(await wo(pt)).ok?(d(He),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>{d(se=>se===He?null:se),l.current=null},2e3)):d(null)},t[8]=F):F=t[8];const _=F;let M,B,T,I,b,w,j,R,L,E,D,U,V,J;if(t[9]!==f||t[10]!==x||t[11]!==h||t[12]!==p||t[13]!==e){b=f?p.find(Wt=>Wt.id===f)??null:null,M=h.filter(wS);let He;t[28]!==h?(He=h.filter(yS),t[28]=h,t[29]=He):He=t[29],J=He;let pt;t[30]!==h?(pt=Qc(h.map(vS)),t[30]=h,t[31]=pt):pt=t[31];const q=pt,se=q?h[q.index]??null:null,De=q?.state==="compacted";D=se?fu(se):ja,T=Ag({input:D.input,cache:{read:D.cacheRead,write:D.cacheWrite}}),U=Number.isFinite(b?.cost)?Ws(b?.cost):M.reduce(SS,0);const we=se?.info??null,rt=x,ft=we?.providerID||"",nt=we?.modelID||"";let ut;t[32]!==rt||t[33]!==ft||t[34]!==nt?(ut=dS(rt,ft,nt),t[32]=rt,t[33]=ft,t[34]=nt,t[35]=ut):ut=t[35],R=ut,I=R.contextLimit,V=De?null:I&&I>0?Math.min(999,D.total/I*100):0;const Nt=[...h].reverse().find(kS),Et=Nt?.info.role==="system"?Nt.info.text:"",Ft=lS(h,Et);B=nS(Ft,{windowTokens:D.total,compacted:De}),w=h[0]?.info?.time?.created,j=h.length>0?h[h.length-1]?.info?.time?.created:null,L=b?.title||e("contextSidebar.session.untitled"),E=Og(b),t[9]=f,t[10]=x,t[11]=h,t[12]=p,t[13]=e,t[14]=M,t[15]=B,t[16]=T,t[17]=I,t[18]=b,t[19]=w,t[20]=j,t[21]=R,t[22]=L,t[23]=E,t[24]=D,t[25]=U,t[26]=V,t[27]=J}else M=t[14],B=t[15],T=t[16],I=t[17],b=t[18],w=t[19],j=t[20],R=t[21],L=t[22],E=t[23],D=t[24],U=t[25],V=t[26],J=t[27];const W=b?.time?.created??w??null,G=j??b?.time?.created??null;let le;t[36]!==M.length||t[37]!==B||t[38]!==T||t[39]!==I||t[40]!==R||t[41]!==h.length||t[42]!==G||t[43]!==L||t[44]!==E||t[45]!==W||t[46]!==D||t[47]!==U||t[48]!==V||t[49]!==J.length?(le={sessionTitle:L,sessionTotals:E,messagesCount:h.length,userMessagesCount:J.length,assistantMessagesCount:M.length,createdAt:W,lastActivityAt:G,providerModel:R,tokenBreakdown:D,usagePercent:V,cacheHitRate:T,totalAssistantCost:U,contextLimit:I,breakdown:B,breakdownTotal:B.total},t[36]=M.length,t[37]=B,t[38]=T,t[39]=I,t[40]=R,t[41]=h.length,t[42]=G,t[43]=L,t[44]=E,t[45]=W,t[46]=D,t[47]=U,t[48]=V,t[49]=J.length,t[50]=le):le=t[50];const $=le;if(!f){let He;t[51]!==e?(He=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=He):He=t[52];let pt;return t[53]!==He?(pt=n.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:He}),t[53]=He,t[54]=pt):pt=t[54],pt}let re;t[55]!==e?(re=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=re):re=t[56];let H;t[57]!==re||t[58]!==$.breakdown.user?(H={key:"user",label:re,value:$.breakdown.user,color:"var(--status-success)"},t[57]=re,t[58]=$.breakdown.user,t[59]=H):H=t[59];let P;t[60]!==e?(P=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=P):P=t[61];let ee;t[62]!==P||t[63]!==$.breakdown.assistant?(ee={key:"assistant",label:P,value:$.breakdown.assistant,color:"var(--primary-base)"},t[62]=P,t[63]=$.breakdown.assistant,t[64]=ee):ee=t[64];let oe;t[65]!==e?(oe=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=oe):oe=t[66];let de;t[67]!==oe||t[68]!==$.breakdown.tool?(de={key:"tool",label:oe,value:$.breakdown.tool,color:"var(--status-warning)"},t[67]=oe,t[68]=$.breakdown.tool,t[69]=de):de=t[69];let he;t[70]!==e?(he=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=he):he=t[71];let Z;t[72]!==he||t[73]!==$.breakdown.other?(Z={key:"other",label:he,value:$.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=he,t[73]=$.breakdown.other,t[74]=Z):Z=t[74];let ce;t[75]!==H||t[76]!==ee||t[77]!==de||t[78]!==Z?(ce=[H,ee,de,Z],t[75]=H,t[76]=ee,t[77]=de,t[78]=Z,t[79]=ce):ce=t[79];const ae=ce;let te;t[80]!==s||t[81]!==$.sessionTitle?(te=s?n.jsx(bd,{children:n.jsx("div",{className:"flex min-w-0 flex-1 items-center ps-1.5 pe-1",children:n.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-foreground",title:$.sessionTitle,children:$.sessionTitle})})}):null,t[80]=s,t[81]=$.sessionTitle,t[82]=te):te=t[82];let pe;t[83]!==s||t[84]!==$.sessionTitle?(pe=s?null:n.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:$.sessionTitle}),t[83]=s,t[84]=$.sessionTitle,t[85]=pe):pe=t[85];const Te=!s&&"mt-1";let Ae;t[86]!==Te?(Ae=Ye(Te,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground"),t[86]=Te,t[87]=Ae):Ae=t[87];let Pe;t[88]!==$.providerModel.modelName||t[89]!==$.providerModel.providerName?(Pe=n.jsxs("span",{children:[$.providerModel.providerName," / ",$.providerModel.modelName]}),t[88]=$.providerModel.modelName,t[89]=$.providerModel.providerName,t[90]=Pe):Pe=t[90];let ze;t[91]!==r||t[92]!==$.createdAt?(ze=$.createdAt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"\xB7"}),n.jsx("span",{children:cS($.createdAt,r)})]}),t[91]=r,t[92]=$.createdAt,t[93]=ze):ze=t[93];let Oe;t[94]!==Ae||t[95]!==Pe||t[96]!==ze?(Oe=n.jsxs("div",{className:Ae,children:[Pe,ze]}),t[94]=Ae,t[95]=Pe,t[96]=ze,t[97]=Oe):Oe=t[97];let me;t[98]!==pe||t[99]!==Oe?(me=n.jsxs("div",{className:"mb-6",children:[pe,Oe]}),t[98]=pe,t[99]=Oe,t[100]=me):me=t[100];let be;t[101]!==e?(be=e("contextSidebar.section.context"),t[101]=e,t[102]=be):be=t[102];let Ce;t[103]!==be?(Ce=n.jsx("span",{className:"typography-micro text-muted-foreground",children:be}),t[103]=be,t[104]=Ce):Ce=t[104];let $e;t[105]!==$.tokenBreakdown.total||t[106]!==$.usagePercent?($e=$.usagePercent===null?"\u2014":xn($.tokenBreakdown.total),t[105]=$.tokenBreakdown.total,t[106]=$.usagePercent,t[107]=$e):$e=t[107];let We;t[108]!==$.contextLimit?(We=$.contextLimit?` / ${xn($.contextLimit)}`:"",t[108]=$.contextLimit,t[109]=We):We=t[109];let _e;t[110]!==$e||t[111]!==We?(_e=n.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[$e,We]}),t[110]=$e,t[111]=We,t[112]=_e):_e=t[112];let Ue;t[113]!==Ce||t[114]!==_e?(Ue=n.jsxs("div",{className:"flex items-baseline justify-between",children:[Ce,_e]}),t[113]=Ce,t[114]=_e,t[115]=Ue):Ue=t[115];let Xe;t[116]!==$.usagePercent?(Xe=$.usagePercent!==null&&$.usagePercent>0&&n.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,$.usagePercent)}%`,backgroundColor:$.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[116]=$.usagePercent,t[117]=Xe):Xe=t[117];let Me;t[118]!==Xe?(Me=n.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Xe}),t[118]=Xe,t[119]=Me):Me=t[119];let ot;t[120]!==e||t[121]!==$.usagePercent?(ot=$.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:$.usagePercent.toFixed(1)}),t[120]=e,t[121]=$.usagePercent,t[122]=ot):ot=t[122];let ye;t[123]!==ot?(ye=n.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:ot}),t[123]=ot,t[124]=ye):ye=t[124];let Ve;t[125]!==Ue||t[126]!==Me||t[127]!==ye?(Ve=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Ue,Me,ye]}),t[125]=Ue,t[126]=Me,t[127]=ye,t[128]=Ve):Ve=t[128];let lt;t[129]!==e?(lt=e("contextSidebar.stats.messages"),t[129]=e,t[130]=lt):lt=t[130];let ct;t[131]!==$.messagesCount?(ct=xn($.messagesCount),t[131]=$.messagesCount,t[132]=ct):ct=t[132];let st;t[133]!==lt||t[134]!==ct?(st={label:lt,value:ct},t[133]=lt,t[134]=ct,t[135]=st):st=t[135];let k;t[136]!==e?(k=e("contextSidebar.stats.user"),t[136]=e,t[137]=k):k=t[137];let Y;t[138]!==$.userMessagesCount?(Y=xn($.userMessagesCount),t[138]=$.userMessagesCount,t[139]=Y):Y=t[139];let Ne;t[140]!==k||t[141]!==Y?(Ne={label:k,value:Y},t[140]=k,t[141]=Y,t[142]=Ne):Ne=t[142];let Re;t[143]!==e?(Re=e("contextSidebar.stats.assistant"),t[143]=e,t[144]=Re):Re=t[144];let Ie;t[145]!==$.assistantMessagesCount?(Ie=xn($.assistantMessagesCount),t[145]=$.assistantMessagesCount,t[146]=Ie):Ie=t[146];let Ee;t[147]!==Re||t[148]!==Ie?(Ee={label:Re,value:Ie},t[147]=Re,t[148]=Ie,t[149]=Ee):Ee=t[149];let Ge;t[150]!==e?(Ge=e("contextSidebar.stats.cost"),t[150]=e,t[151]=Ge):Ge=t[151];let Be;t[152]!==$.totalAssistantCost?(Be=Wd($.totalAssistantCost),t[152]=$.totalAssistantCost,t[153]=Be):Be=t[153];let Ze;t[154]!==Ge||t[155]!==Be?(Ze={label:Ge,value:Be},t[154]=Ge,t[155]=Be,t[156]=Ze):Ze=t[156];let et;t[157]!==st||t[158]!==Ne||t[159]!==Ee||t[160]!==Ze?(et=[st,Ne,Ee,Ze],t[157]=st,t[158]=Ne,t[159]=Ee,t[160]=Ze,t[161]=et):et=t[161];const wt=et;let Qe;t[162]!==wt?(Qe=n.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:wt.map(jS)}),t[162]=wt,t[163]=Qe):Qe=t[163];let dt;t[164]!==e?(dt=e("contextSidebar.section.sessionTotals"),t[164]=e,t[165]=dt):dt=t[165];let at;t[166]!==dt||t[167]!==$.sessionTotals?(at=n.jsx(kl,{title:dt,figures:$.sessionTotals}),t[166]=dt,t[167]=$.sessionTotals,t[168]=at):at=t[168];let z;t[169]!==e?(z=e("contextSidebar.section.lastAssistantMessage"),t[169]=e,t[170]=z):z=t[170];const fe=$.tokenBreakdown.input+$.tokenBreakdown.cacheRead+$.tokenBreakdown.cacheWrite,ke=$.cacheHitRate.hasInput?$.cacheHitRate.percent:null;let ie;t[171]!==fe||t[172]!==ke||t[173]!==$.tokenBreakdown?(ie={...$.tokenBreakdown,prompt:fe,cacheHitPercent:ke},t[171]=fe,t[172]=ke,t[173]=$.tokenBreakdown,t[174]=ie):ie=t[174];let xe;t[175]!==z||t[176]!==ie?(xe=n.jsx(kl,{title:z,figures:ie}),t[175]=z,t[176]=ie,t[177]=xe):xe=t[177];let Le;t[178]!==ae||t[179]!==$.breakdownTotal?(Le=n.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:ae.map(He=>He.value<=0||$.breakdownTotal<=0?null:n.jsx("div",{style:{width:`${He.value/$.breakdownTotal*100}%`,backgroundColor:He.color}},He.key))}),t[178]=ae,t[179]=$.breakdownTotal,t[180]=Le):Le=t[180];let Ke;t[181]!==ae||t[182]!==$.breakdownTotal?(Ke=n.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:ae.map(He=>{const pt=$.breakdownTotal>0?He.value/$.breakdownTotal*100:0;return n.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:He.color}}),n.jsxs("span",{className:"typography-micro text-muted-foreground",children:[He.label," ",n.jsxs("span",{className:"tabular-nums",children:[pt.toFixed(0),"%"]})]})]},He.key)})}),t[181]=ae,t[182]=$.breakdownTotal,t[183]=Ke):Ke=t[183];let ve;t[184]!==Le||t[185]!==Ke?(ve=n.jsxs("div",{className:"mb-6",children:[Le,Ke]}),t[184]=Le,t[185]=Ke,t[186]=ve):ve=t[186];let je;t[187]!==e?(je=e("contextSidebar.section.rawMessages"),t[187]=e,t[188]=je):je=t[188];let vt;t[189]!==je?(vt=n.jsx("div",{className:"typography-micro text-muted-foreground",children:je}),t[189]=je,t[190]=vt):vt=t[190];let ne;if(t[191]!==u||t[192]!==a||t[193]!==h||t[194]!==r){let He;t[196]!==u||t[197]!==a||t[198]!==r?(He=pt=>n.jsx(uS,{message:pt,isExpanded:a[pt.info.id]===true,isCopied:u===pt.info.id,timeFormatPreference:r,onToggle:N,onCopy:_},pt.info.id),t[196]=u,t[197]=a,t[198]=r,t[199]=He):He=t[199],ne=[...h].reverse().map(He),t[191]=u,t[192]=a,t[193]=h,t[194]=r,t[195]=ne}else ne=t[195];let Je;t[200]!==ne?(Je=n.jsx("div",{className:"mt-2.5 space-y-1",children:ne}),t[200]=ne,t[201]=Je):Je=t[201];let kt;t[202]!==vt||t[203]!==Je?(kt=n.jsxs("div",{children:[vt,Je]}),t[202]=vt,t[203]=Je,t[204]=kt):kt=t[204];let bt;t[205]!==me||t[206]!==Ve||t[207]!==Qe||t[208]!==at||t[209]!==xe||t[210]!==ve||t[211]!==kt?(bt=n.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[me,Ve,Qe,at,xe,ve,kt]}),t[205]=me,t[206]=Ve,t[207]=Qe,t[208]=at,t[209]=xe,t[210]=ve,t[211]=kt,t[212]=bt):bt=t[212];let _t;return t[213]!==te||t[214]!==bt?(_t=n.jsxs(ps,{outerClassName:"h-full",className:"bg-background",children:[te,bt]}),t[213]=te,t[214]=bt,t[215]=_t):_t=t[215],_t};function pS(t){return n.jsxs("div",{children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),n.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value===null?"\u2014":t.format==="percent"?`${t.value.toFixed(1)}%`:xn(t.value)})]},t.label)}function mS(t){return t.timeFormatPreference}function hS(t){return t.currentSessionId}function gS(t){return t.currentSessionDirectory}function xS(t){return t.providers}function bS(t){return Object.keys(t).length>0?{}:t}function wS(t){return t.info.role==="assistant"}function yS(t){return t.info.role==="user"}function vS(t){return t.info}function SS(t,e){const s=Ws(e.info.cost);return t+s}function kS(t){return t.info.role==="system"}function jS(t){return n.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),n.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}const Gr=(t,e)=>{const[s,r]=c.useState(null),o=t?.id??null;return e&&s!==o&&r(o),e||s===null||s===o?t:null},TS=280,CS=.28,ES=240,IS=.35,NS=(t,e,s=null)=>{const r=t.left+t.width,o=e.left+e.width,a=e.top+e.height,i=s?s.top:a-Math.min(ES,e.height*IS),u=Math.min(TS,t.width*CS,e.width/4),d=e.left-t.left>=1,l=r-o>=1,f=Math.max(0,i-t.top),m=d?e.left:t.left+u,p=l?o:r-u;return{left:{left:t.left,top:t.top,width:m-t.left,height:d?t.height:f},right:{left:p,top:t.top,width:r-p,height:l?t.height:f},bottom:{left:e.left,top:i,width:e.width,height:Math.max(0,a-i)}}},ea=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,PS=(t,e)=>ea(t.bottom,e)?"bottom":ea(t.left,e)?"left":ea(t.right,e)?"right":null,Gs=Io(()=>({drag:null,hovered:null})),Zr=t=>{if(!t)return null;const{left:e,top:s,width:r,height:o}=t.getBoundingClientRect();return r>0&&o>0?{left:e,top:s,width:r,height:o}:null},ta=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),sa=t=>Zr(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),mu=t=>{const e=Zr(document.querySelector("[data-workspace-row]")),s=Zr(document.querySelector("[data-workspace-chat]"));if(!e||!s)return false;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=NS(e,s,Zr(r)),a={left:sa("left")??ta(o.left),right:sa("right")??ta(o.right),bottom:sa("bottom")??ta(o.bottom)};return Gs.setState({drag:{...t,targets:o,frames:a},hovered:null}),true},hu=t=>{const{drag:e,hovered:s}=Gs.getState();if(!e)return;const r=PS(e.targets,t);r!==s&&Gs.setState({hovered:r})},Ta=()=>{Gs.getState().drag&&Gs.setState({drag:null,hovered:null})},gu=t=>{const{drag:e,hovered:s}=Gs.getState();if(Gs.setState({drag:null,hovered:null}),!e||!s)return false;const r=K.getState();s!==e.from&&r.moveContextSurfaceToZone(e.mode,s);const o=t?ds(t):"";if(o){const a=K.getState();za(a.contextPanelByDirectory[o],a.contextSurfaceZones).has(e.mode)||a.openContextSurface(o,e.mode)}return true},hi=(t,e)=>{let s=false;const r=a=>{const i={x:a.clientX,y:a.clientY};e(i)?(s||(s=mu(t)),s&&hu(i)):s&&(Ta(),s=false)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:a=>(o(),s?(gu(a),true):false),cancel:()=>{o(),s&&Ta()}}},jl={left:null,right:null,bottom:null},yr=Io(()=>({body:jl,headerSlot:jl})),xu=(t,e,s)=>{const r=yr.getState()[t];r[e]!==s&&yr.setState({[t]:{...r,[e]:s}})},RS=(t,e)=>xu("body",t,e),DS=(t,e)=>xu("headerSlot",t,e),rr=t=>{const e=c.useRef(t);e.current=t;const[s,r]=c.useState(t),o=c.useCallback(()=>r(e.current),[]);return c.useLayoutEffect(()=>{hr(o)},[t,o]),c.useEffect(()=>()=>ai(o),[o]),s},na=t=>{const e=rr(t);return t||e},_S=Tr(()=>Vt(()=>import("./GitView-Ccs7O5Rf.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,207,208,209,210,211])).then(t=>({default:t.GitView}))),gi=320,bu=320,AS=24,OS=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Tl=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(gi,Math.round(t))):Va,MS=t=>t===null?Number.POSITIVE_INFINITY:Math.max(gi,t-bu),Cl=(t,e)=>{if(!t)return"";const s=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&s.startsWith(r+"/")?s.slice(r.length+1):s},Xr=(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"):t==="pages"?e("contextPanel.mode.pages"):wn(t)?cr.getState().guests.find(r=>r.id===er(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),FS=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const s=e.split("/").filter(Boolean);return s.length===0?e:s[s.length-1]||null},LS=(t,e,s)=>{if(t.mode==="chat"){const r=No(t.dedupeKey);if(r){const a=e.get(r)?.trim();if(a)return a}const o=t.sessionTitleFallback?.trim();return o||s("contextPanel.mode.chat")}return t.mode==="browser"?xo(t.targetPath??"")||t.label||s("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?FS(t.targetPath)||s("contextPanel.mode.files"):t.mode==="diff"?s("contextPanel.mode.diff"):Xr(t.mode,s)},$S=t=>{const e=qe.c(8),{mode:s}=t,r=ii();let o;if(e[0]!==s||e[1]!==r){let l;e[3]!==s?(l=f=>f.mode===s,e[3]=s,e[4]=l):l=e[4],o=r.find(l),e[0]=s,e[1]=r,e[2]=o}else o=e[2];const a=o,i=a?.icon??Hg,u=a?.iconSrc;let d;return e[5]!==i||e[6]!==u?(d=n.jsx(li,{icon:i,iconSrc:u,className:"h-3.5 w-3.5"}),e[5]=i,e[6]=u,e[7]=d):d=e[7],d},BS=t=>{const e=qe.c(2),{sessionId:s}=t,r=Zc(s);let o;return e[0]!==r?(o=r?n.jsx(Yc,{state:r,className:"h-3.5 w-3.5"}):n.jsx(ue,{name:"chat-4",className:"h-3.5 w-3.5"}),e[0]=r,e[1]=o):o=e[1],o},zS=[],WS=(t,e,s)=>{const r=s(t);if(r)return Kg(r.provider,r.identifier);const o=e.match(t);return o?qg(o.kind,o):null},VS=t=>{switch(t?.type){case"pull":return t.state?Vo({kind:"pull",state:t.state.state,draft:t.state.draft},t.state):null;case"issue":return t.state?Vo({kind:"issue",state:t.state.state},null):null;case"discussion":return t.state?Vo({kind:"discussion",state:t.state.state,answered:t.state.answered},null):null;case"work-item":return t.state?Gg(t.state.state.category):null;default:return null}},US=t=>{const e=qe.c(23),{url:s,active:r,visible:o}=t,a=To(),i=gd();let u;e[0]!==i||e[1]!==s||e[2]!==a?(u=s?WS(s,a,i):null,e[0]=i,e[1]=s,e[2]=a,e[3]=u):u=e[3];const d=u;let l;e[4]!==d?(l=d?[d]:[],e[4]=d,e[5]=l):l=e[5];const f=l;ko(o?f:zS);const m=Wg(f)[0]??null;let p;e[6]!==m?(p=VS(m),e[6]=m,e[7]=p):p=e[7];const h=p;let x,g;if(e[8]!==r||e[9]!==h||e[10]!==i||e[11]!==s||e[12]!==a){g=Symbol.for("react.early_return_sentinel");e:{const C=s?xd(s,a,i):null;if(C&&h){let S;e[15]!==r||e[16]!==h.color?(S=r?void 0:{color:h.color},e[15]=r,e[16]=h.color,e[17]=S):S=e[17];let N;e[18]!==h.icon||e[19]!==S?(N=n.jsx(ue,{name:h.icon,className:"h-3.5 w-3.5",style:S}),e[18]=h.icon,e[19]=S,e[20]=N):N=e[20],g=N;break e}x=C?C.source==="tracker"?Ug(C.provider).icon:Vg[C.kind]:"git-branch"}e[8]=r,e[9]=h,e[10]=i,e[11]=s,e[12]=a,e[13]=x,e[14]=g}else x=e[13],g=e[14];if(g!==Symbol.for("react.early_return_sentinel"))return g;const v=x;let y;return e[21]!==v?(y=n.jsx(ue,{name:v,className:"h-3.5 w-3.5"}),e[21]=v,e[22]=y):y=e[22],y},El=(t,e={},s=true,r=true)=>{if(t.mode==="file")return t.targetPath?n.jsx(Co,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return n.jsx(Wp,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return n.jsx(ue,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return n.jsx(ue,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return n.jsx(US,{url:t.targetPath,active:s,visible:r});if(t.mode==="notes")return n.jsx(ue,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return n.jsx(ue,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return n.jsx(ue,{name:"pie-chart",className:"h-3.5 w-3.5"});if(t.mode==="workflows")return n.jsx(ue,{name:"flow-chart",className:"h-3.5 w-3.5"});if(t.mode==="pages")return n.jsx(ue,{name:"pages",className:"h-3.5 w-3.5"});if(t.mode==="chat"){const o=No(t.dedupeKey);return o?n.jsx(BS,{sessionId:o}):n.jsx(ue,{name:"chat-4",className:"h-3.5 w-3.5"})}if(wn(t.mode))return n.jsx($S,{mode:t.mode});if(t.mode==="browser"){const o=HS(t.targetPath??"",e);return o?n.jsx("img",{src:o,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):n.jsx(ue,{name:"global",className:"h-3.5 w-3.5"})}},HS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},KS=t=>{const e=Sd(),s=c.useRef(io),r=c.useRef(t);r.current=t;const o=t.length>0;return c.useSyncExternalStore(c.useCallback(a=>o?e.subscribeAllSelected(i=>i.session,a):()=>{},[e,o]),c.useCallback(()=>{const a=Array.from(e.children.values(),u=>u.getState()),i=av(a,r.current);return rv(s.current,i)?s.current:(s.current=i,i)},[e]),()=>io)},qS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,GS=8,ZS='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',XS=t=>t==="context"||t==="git"||t==="pr"||t==="notes"||t==="workflows",wu=320,xi=160,Ca=200,YS={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"}},Il=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(xi,Math.round(t))):wu,JS=t=>t===null?Number.POSITIVE_INFINITY:Math.max(xi,t-Ca),ra=({zone:t="right"})=>{const e=YS[t],s=vo(),r=e.axis==="y",{t:o,direction:a}=gt(),i=a==="rtl",u=Zs()??"",d=Tc(Fg(u||null)),l=c.useCallback((Q,tt)=>o(Us(Q,d),tt),[d,o]),f=c.useMemo(()=>OS(u),[u]),m=K(Q=>f?Q.contextPanelByDirectory[f]:void 0),p=K(Q=>Q.contextSurfaceZones),h=K(Q=>Q.shortcutOverrides),x=K(Q=>Q.closeContextZone),g=K(Q=>Q.closeContextPanelTab),v=K(Q=>Q.pinContextPanelTab),y=K(Q=>Q.toggleContextPanelExpanded),C=K(Q=>Q.setContextZoneSize),S=K(Q=>Q.setContextZoneExpandedChatSize),N=K(Q=>Q.setActiveContextPanelTab),F=K(Q=>Q.reorderContextPanelTabs),_=K(Q=>Q.contextEditorTreeVisible),M=K(Q=>Q.contextEditorTreeWidth),B=K(Q=>Q.setContextEditorTreeWidth),T=K(Q=>Q.toggleContextEditorTree),I=K(Q=>Q.contextEditorVisible),b=K(Q=>Q.toggleContextEditor),w=K(Q=>Q.fileTreeSide),j=K(Q=>Q.openNewContextBrowserTab),R=uu(Q=>Q.byOrigin),[L,E]=c.useState(null),D=c.useCallback(Q=>{E(Q),DS(t,Q)},[t]),U=c.useCallback(Q=>{RS(t,Q)},[t]),V=c.useMemo(()=>m?.tabs??[],[m?.tabs]),J=m?to(m,p,t):null,W=m?lr(m,t):jf,G=Kr(Q=>Q.workStatusReserved),le=Kr(Q=>Q.workStatusBesidePanel),$=Kr(Q=>Q.chatCovered),re=t==="bottom"&&$,H=!!(W.isOpen&&J)&&!re,P=Gr(J,H),ee=c.useMemo(()=>V.some(Q=>Q.mode==="file"&&Q.targetPath),[V]),oe=ee&&(I||!_),de=!r&&P?.mode==="file"&&!oe,he=!!(H&&W.expanded&&!de),Z=K(Q=>Q.contextZoneSizes[t]),ce=de?M:r?Il(Z??wu,Number.POSITIVE_INFINITY):Tl(Z??Va,Number.POSITIVE_INFINITY),ae=c.useCallback((Q,tt)=>r?Il(Q,JS(tt)):Tl(Q,MS(tt)),[r]),te=r?Ca:bu,pe=K(Q=>r?0:Q.sidebarWidth),Te=K(Q=>Q.contextZoneExpandedChatSizes[t]),Ae=Math.max(te,Te??(r?Ca:pe)),Pe=t==="right"?"left":t==="left"?"right":null,ze=K(Q=>{if(!Pe||!f)return 0;const tt=Q.contextPanelByDirectory[f],St=tt&&Qn(tt,Q.contextSurfaceZones,Pe)?to(tt,Q.contextSurfaceZones,Pe):null;return tt&&St?Tf(tt,St,Pe,Q):0}),Oe=Pe==="right"&&G&&!$&&ze===0?In:ze,me=t==="right"&&G&&!$,be=me&&le&&!he,[Ce,$e]=c.useState(null),We=c.useRef(null),_e=c.useRef(Oe);_e.current=Oe;const Ue=c.useRef(H);Ue.current=H;const Xe=c.useRef(()=>false);Xe.current=Q=>he||!de&&Q-_e.current-te<ce;const Me=c.useCallback(()=>{let Q=We.current;Q!==null&&!r&&Ue.current&&(Q+=Lg()),$e(Q!==null&&Xe.current(Q)?Q:null)},[r]),ot=Ce!==null?Ce-Oe:null,ye=de?ce:he&&ot!==null?Math.max(r?xi:gi,ot-Ae):ae(ce,ot),Ve=H&&P?.mode==="chat",lt=c.useMemo(()=>{const Q=[];if(!Ve)return Q;for(const tt of V){if(tt.mode!=="chat")continue;const St=No(tt.dedupeKey);St&&!Q.includes(St)&&Q.push(St)}return Q},[Ve,V]),ct=KS(lt),[st,k]=c.useState(false),Y=c.useRef(0),Ne=c.useRef(ye),Re=c.useRef(null),Ie=c.useRef(null),Ee=c.useRef(null),Ge=c.useRef(null),Be=c.useRef(false);c.useLayoutEffect(()=>{const Q=r?Ee.current?.parentElement:Ee.current?.closest("[data-workspace-row]");if(!Q||typeof ResizeObserver>"u")return;const tt=new ResizeObserver(St=>{const Tt=St[St.length-1]?.contentRect,Bt=r?Tt?.height:Tt?.width;We.current=Bt?Math.round(Bt):null,hr(Me)});return tt.observe(Q),We.current=(r?Q.clientHeight:Q.clientWidth)||null,Me(),()=>{tt.disconnect(),ai(Me)}},[Me,r]);const Ze=!r&&H&&(he||Ce!==null),et=K(Q=>Ze&&Q.isSidebarOpen);c.useLayoutEffect(()=>{Me()},[Me,ce,he,H,Oe,et]),c.useEffect(()=>{if(!H||Be.current){Be.current=H;return}const Q=window.requestAnimationFrame(()=>{Ge.current?.focus({preventScroll:true})});return Be.current=true,()=>window.cancelAnimationFrame(Q)},[H]);const wt=c.useRef(null),Qe=c.useRef(null),dt=c.useRef(null),at=c.useRef(null),z=c.useRef(false),fe=c.useRef(null),ke=c.useRef(false),ie=c.useCallback(Q=>{const tt=Ee.current,St=fe.current;if(!tt||!St)return;const Tt=r?"height":"width";tt.style[Tt]=ke.current?`${Q+In}px`:`min(${Q}px, 100%)`,St.style[Tt]=`calc(${Q}px - ${e.gutterSize})`},[e.gutterSize,r]),xe=c.useCallback(()=>{Qe.current=null;const Q=Re.current;Q!==null&&ie(Q)},[ie]);c.useEffect(()=>()=>{Qe.current!==null&&cancelAnimationFrame(Qe.current),dt.current?.(),dt.current=null,at.current?.remove(),at.current=null},[]);const Le=c.useCallback(Q=>{const tt=wt.current,St=de?da(Q):ae(Q,tt);return tt===null?St:Math.min(St,Math.max(1,tt))},[ae,de]),Ke=c.useCallback(Q=>{if(!H||!f)return;Ie.current=Q.pointerId,k(true),Y.current=r?Q.clientY:Q.clientX,Ne.current=ye,Re.current=ye;const tt=r?Ee.current?.parentElement?.clientHeight:(Ee.current?.closest("[data-workspace-row]")?.clientWidth??0)-_e.current-(be?In:0);wt.current=tt&&tt>0?tt:null,at.current?.remove();const St=document.createElement("div");St.style.cssText=`position:fixed;inset:0;z-index:2147483647;cursor:${r?"row-resize":"col-resize"}`,document.body.appendChild(St),at.current=St,dt.current?.(),dt.current=nd(r?"height":"width"),Q.preventDefault()},[be,f,H,r,ye]),ve=c.useCallback(()=>{const Q=Le(Re.current??ye),tt=wt.current;Qe.current!==null&&(cancelAnimationFrame(Qe.current),Qe.current=null);const St=Ee.current,Tt=fe.current;if(St&&Tt){const Bt=r?"height":"width";St.style.setProperty(e.sizeVariable,`${Q}px`),St.style[Bt]=jt.current,Tt.style[Bt]=$t.current}Re.current=null,wt.current=null,z.current=true,at.current?.remove(),at.current=null,de?B(Q):he?tt!==null&&S(t,tt-Q):C(t,Q),k(false),Ie.current=null,dt.current?.(),dt.current=null},[Le,e.sizeVariable,he,de,r,B,S,C,ye,t]);c.useEffect(()=>{if(!st)return;const Q=Tt=>{if(Ie.current!==Tt.pointerId)return;const Bt=r?Tt.clientY:Tt.clientX,Zt=t==="left"?Bt-Y.current:Y.current-Bt,js=!r&&i?-Zt:Zt,us=Le(Ne.current+js);Re.current!==us&&(Re.current=us,Qe.current===null&&(Qe.current=requestAnimationFrame(xe)))},tt=Tt=>{Ie.current===Tt.pointerId&&ve()},St=()=>{ve()};return window.addEventListener("pointermove",Q),window.addEventListener("pointerup",tt),window.addEventListener("pointercancel",tt),window.addEventListener("blur",St),()=>{window.removeEventListener("pointermove",Q),window.removeEventListener("pointerup",tt),window.removeEventListener("pointercancel",tt),window.removeEventListener("blur",St)}},[xe,Le,ve,st,i,r,t]),c.useEffect(()=>{st||(Re.current=null,at.current?.remove(),at.current=null)},[st]);const je=c.useCallback(()=>{f&&x(f,t)},[x,f,t]),vt=c.useCallback(()=>{f&&y(f,t)},[f,y,t]),ne=P?.mode==="file"||P?.mode==="chat"||P?.mode==="browser"||P?.mode==="pr"||P?.mode==="pages",Je=c.useMemo(()=>{if(!P)return[];const Q=V.filter(tt=>tt.mode===P.mode);return P.mode==="pr"?[...Q.filter(Or),...Q.filter(tt=>!Or(tt))]:Q},[P,V]),kt=jo(P?.mode==="pr"&&f?f:null)?.current??null,bt=P?.id,_t=c.useMemo(()=>{const Q=$g(Je.filter(tt=>tt.mode==="file").map(tt=>Cl(tt.targetPath,u)));return Je.map(tt=>{const St=Or(tt),Tt=St?kt||o("contextPanel.tracker.branchTab"):LS(tt,ct,l),Bt=qS(Tt,AS),Zt=Cl(tt.targetPath,u);return{id:tt.id,label:Bt,labelFolder:tt.mode==="file"?Q.get(Zt):void 0,icon:El(tt,R,tt.id===bt,H),title:Zt?`${Tt}: ${Zt}`:Tt,closeLabel:o("contextPanel.tab.closeTabAria",{label:Bt}),closeShortcut:tt.id===bt&&As()?bs("mod+w",""):void 0,closable:!St,preview:tt.preview}})},[Je,bt,u,R,H,ct,o,l,kt]),He=P?.mode==="context"?n.jsx(bn,{value:L,children:n.jsx(fS,{})}):P?.mode==="git"?n.jsx(c.Suspense,{fallback:null,children:n.jsx(bn,{value:L,children:n.jsx(_S,{isActive:H})})}):P?.mode==="pr"?P.targetPath?n.jsx(qy,{url:P.targetPath,directory:P.targetDirectory??u,panelDirectory:u,tabId:P.id,foreign:!!P.targetDirectory,visible:H},P.id):n.jsx(Fy,{}):P?.mode==="notes"?n.jsx(bn,{value:L,children:n.jsx(zp,{visible:H})}):P?.mode==="workflows"?n.jsx(bn,{value:L,children:n.jsx(Bv,{directory:u||null})}):P?.mode==="pages"&&!P.targetPath?n.jsx(Xw,{}):null,pt=P?.mode==="file",q=pt&&!!P?.targetPath&&oe,se=H&&P&&ne&&!q&&!Or(P)?P.id:null;c.useEffect(()=>{if(!(!f||!se))return Ka(()=>g(f,se),Ee)},[g,f,se]);const De=K(Q=>Q.closeContextPanelTabs),we=c.useCallback(Q=>{if(!f)return null;const{id:tt,index:St,allIds:Tt,close:Bt}=Q,Zt=()=>De(f,Tt.filter(Ys=>Ys!==tt)),js=Tt.slice(0,St),us=Tt.slice(St+1),Ps=()=>De(f,i?us:js),Rs=()=>De(f,i?js:us),hs=()=>De(f,Tt),ls=Tt.length>1,ws=i?St===Tt.length-1:St===0,cn=i?St===0:St===Tt.length-1;return n.jsxs(n.Fragment,{children:[n.jsxs(Ts,{onClick:Bt,children:[n.jsx(ue,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),n.jsx(Dn,{}),n.jsxs(Ts,{onClick:Zt,disabled:!ls,children:[n.jsx(ue,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),n.jsxs(Ts,{onClick:Ps,disabled:ws,children:[n.jsx(ue,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),n.jsxs(Ts,{onClick:Rs,disabled:cn,children:[n.jsx(ue,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),n.jsx(Dn,{}),n.jsxs(Ts,{onClick:hs,disabled:!ls,children:[n.jsx(ue,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),P?n.jsxs(n.Fragment,{children:[n.jsx(Dn,{}),n.jsx(Uc,{mode:P.mode})]}):null]})},[P,De,f,i,o]),rt=c.useCallback((Q,tt)=>{const St=V.find(Bt=>Bt.id===Q);if(!St)return null;const Tt=hi({mode:St.mode,label:Xr(St.mode,l),from:t},tt);return{finish:()=>Tt.finish(f),cancel:Tt.cancel}},[f,l,V,t]),[ft,nt]=c.useState(null),ut=c.useCallback(Q=>{if(!P||Q.button!==0||Q.pointerType==="touch"||Q.target instanceof Element&&Q.target.closest(ZS))return;const tt=P.mode,St=Xr(tt,l),Tt={x:Q.clientX,y:Q.clientY};let Bt=false;const Zt=Rs=>{const hs={x:Rs.clientX,y:Rs.clientY};!Bt&&(Math.hypot(hs.x-Tt.x,hs.y-Tt.y)<GS||(Bt=mu({mode:tt,label:St,from:t}),!Bt))||hu(hs)},js=()=>{window.removeEventListener("pointermove",Zt),window.removeEventListener("pointerup",us),window.removeEventListener("pointercancel",Ps),window.removeEventListener("blur",Ps)},us=()=>{js(),Bt&&gu(f)},Ps=()=>{js(),Bt&&Ta()};window.addEventListener("pointermove",Zt),window.addEventListener("pointerup",us),window.addEventListener("pointercancel",Ps),window.addEventListener("blur",Ps)},[P,f,l,t]);c.useEffect(()=>{if(ft)return ft.addEventListener("pointerdown",ut),()=>ft.removeEventListener("pointerdown",ut)},[ut,ft]);const Nt=n.jsxs("header",{ref:nt,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[ne?n.jsx(Bg,{items:_t,activeId:P?.id??null,onSelect:Q=>{f&&N(f,Q)},onClose:Q=>{f&&g(f,Q)},onReorder:(Q,tt)=>{f&&F(f,Q,tt)},onDoubleClickTab:Q=>{f&&v(f,Q)},layoutMode:"scrollable",variant:"default",tabContextMenu:we,onTabDragOut:rt}):n.jsxs(n.Fragment,{children:[n.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:[P?El(P,R):null,n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:P?Xr(P.mode,l):null})]}),n.jsx("div",{ref:D,className:"flex min-w-0 flex-1 items-stretch ps-1.5 empty:hidden"})]}),n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 self-start px-1.5",children:[P?.mode==="browser"?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&j(f)},className:"h-7 w-7 p-0","aria-label":o("contextPanel.browser.newTab"),children:n.jsx(ue,{name:"add",className:"h-3.5 w-3.5"})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:o("contextPanel.browser.newTab")})]}):null,pt?["left","right"].map(Q=>{const tt=Q===w;if(!tt&&!ee)return null;const St=o(tt?"contextRail.editorTree.toggle":"contextRail.editor.toggle"),Tt=tt?_:oe,Bt=o(tt?Tt?"contextTooltips.panel.hideFileTree":"contextTooltips.panel.showFileTree":Tt?"contextTooltips.panel.hideFileEditor":"contextTooltips.panel.showFileEditor");return n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{type:"button",variant:"ghost",size:"sm",onClick:tt?T:b,className:"h-7 w-7 p-0","aria-label":St,"aria-pressed":Tt,children:n.jsx(ue,{name:Q==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:Bt})]},Q)}):null,de?null:n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{type:"button",variant:"ghost",size:"sm",onClick:vt,className:"h-7 w-7 p-0","aria-label":o(he?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:he?n.jsx(ue,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):n.jsx(ue,{name:"fullscreen",className:"h-3.5 w-3.5"})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:n.jsx(qs,{label:o(he?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),shortcut:bs(Es("toggle_context_panel_expanded",h),"")})})]}),n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{type:"button",variant:"ghost",size:"sm",onClick:je,className:"h-7 w-7 p-0","aria-label":o("contextPanel.actions.closePanel"),children:n.jsx(ue,{name:"close",className:"h-3.5 w-3.5"})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:o("contextPanel.actions.closePanel")})]})]})]}),Et=H?be?`calc(var(${e.sizeVariable}) + ${In}px)`:`min(var(${e.sizeVariable}), 100%)`:me?`${In}px`:"0px",Ft=be?`${In}px`:"0px";ke.current=be;const Wt=t==="bottom"&&Qn(m,p,"left"),is=t==="bottom"&&(G&&!$||Qn(m,p,"right")),Gt=`${H}|${he}|${me}|${H&&be}|${H?ce:""}`,ns=c.useRef(Gt),ms=c.useRef($),Ns=ms.current!==$;c.useLayoutEffect(()=>{ms.current=$},[$]),c.useLayoutEffect(()=>{if(ns.current===Gt)return;ns.current=Gt;const Q=z.current;!Ns&&!Q&&sd(s)},[Gt,Ns,s]),c.useLayoutEffect(()=>{z.current=false});const Fs=!Vr(H,rr(H),P?.mode),X={[e.sizeVariable]:`${ye}px`,...r?{height:Et,maxHeight:"100%"}:{width:Et,maxWidth:"100%"},transitionDuration:Ns||st?"0ms":`${s}ms`,transitionTimingFunction:Mn},mt=`calc(var(${e.sizeVariable}) - ${e.gutterSize})`,jt=c.useRef(Et);jt.current=Et;const $t=c.useRef(mt);return $t.current=mt,n.jsxs("aside",{ref:Ee,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":H?"true":"false","data-zone-size":ye,tabIndex:-1,className:Ye("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:X,children:[n.jsx("div",{ref:Ge,tabIndex:-1,className:"absolute size-0 overflow-hidden outline-none"}),t==="right"?n.jsx("div",{ref:zg,className:Ye("absolute inset-y-0 z-0 flex",be?"inset-s-0":"inset-e-0",$&&"invisible")}):null,H&&n.jsx("div",{className:e.handle,style:{marginInlineStart:Ft},onPointerDown:Ke,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{ref:fe,"data-zone-card":"",className:Ye("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(Wt?"ms-0":"ms-2"),t==="bottom"&&(is?"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]",!H&&"opacity-0",Fs&&"pointer-events-none select-none"),style:{...r?{height:mt,width:`calc(100% - ${(Wt?0:.5)+(is?0:.375)}rem)`}:{width:mt},...t==="right"?{marginInlineStart:`calc(0.5rem + ${Ft})`}:null,transitionDuration:st?"0ms":`${s}ms`,transitionTimingFunction:Mn},inert:Fs||void 0,children:n.jsxs(vd.Provider,{value:true,children:[Nt,n.jsx("div",{ref:U,className:"relative min-h-0 flex-1 overflow-hidden",children:P&&(XS(P.mode)||P.mode==="pages"&&!P.targetPath)?He:null})]})})]})},QS=Mt({port:as().int().positive(),url:It().min(1),command:It(),directory:It().min(1).optional()}),e0=t=>{const e=Mt({servers:Cn(Jd())}).safeParse(t);return e.success?e.data.servers.flatMap(s=>{const r=QS.safeParse(s);return r.success?[r.data]:[]}):null},t0=async(t,e)=>{try{const s=await Ms("/api/dev-servers",{signal:t,directory:e});if(!s.ok)return{kind:"unavailable"};const r=e0(await s.json());return r?{kind:"ready",servers:r}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},s0=async t=>{try{const e=await Ms("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const s=await e.json();if(!s||typeof s!="object")return null;const r=s.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},n0=t=>{try{const e=new URL(t),s=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(s)&&s>0?s:null}catch{return null}},r0=({announced:t,discovered:e})=>{const s=new Map;for(const r of t){const o=n0(r);o!==null&&!s.has(o)&&s.set(o,r)}return e?e.map(r=>{const o=s.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):[...s.entries()].map(([r,o])=>({url:o,port:r,announced:true})).sort((r,o)=>r.port-o.port)},o0=(t,e)=>e===t||e.startsWith(t.endsWith("/")?t:`${t}/`),Nl=(t,e)=>{if(!e)return null;let s=null;for(const r of t)o0(r.path,e)&&(!s||r.path.length>s.path.length)&&(s=r);return s},a0=t=>t.slice(t.lastIndexOf("/")+1)||t,i0=({candidates:t,folders:e,directory:s})=>{const r=e.flatMap(d=>{const l=ts(d.path),f=ts(d.projectPath);return l&&f?[{path:l,projectPath:f}]:[]}),o=ts(s),a=o?{path:o,projectPath:Nl(r,o)?.projectPath??o}:null,i=a?[...r,a]:r;return t.map(d=>{const l=ts(d.directory),f=Nl(i,l),m=d.announced?0:f&&a&&f.path===a.path?1:f&&a&&f.projectPath===a.projectPath?2:3;return{server:{...d,folderName:f?a0(f.path):null,outsideWork:l!==null&&f===null&&!d.announced},rank:m}}).sort((d,l)=>d.rank-l.rank||d.server.port-l.server.port).map(d=>d.server)},l0=t=>({sessionId:t.sessionId,directory:t.directory?ds(t.directory):null}),c0=2e3,d0=Mt({title:It(),settled:ss(),dialogs:Cn(Jd()).optional(),note:It().optional()}),u0=4e4,f0=50,or=400,fs=new Map,Os=new Map;let Ea=null,Ia=null;const vr=new Map;let Cs=null,rn=null,Yr=null,ar=null;const Vs=async t=>{try{const e=await Ms("/api/browser-control/claim",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t})});return e.ok?(await e.json())?.granted===true:false}catch{return false}},p0=async(t,e)=>{try{const s=await Ms("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});s.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${s.status}); the agent will see this action time out`)}catch(s){console.warn(`[browser-control] could not deliver the result for ${t}:`,s)}},yu=async(t,e=c0)=>{const s=Date.now()+e;for(;!fs.has(t)&&Date.now()<s;)await new Promise(r=>setTimeout(r,f0));return fs.get(t)??null},co=t=>fs.has(t)||Os.has(t),Bn=t=>fs.get(t)??Os.get(t)??null,Na=()=>[...fs.values(),...[...Os.values()].filter(t=>!fs.has(t.tabId))],bi=t=>{const e=Ia?Bn(Ia):null,s=e?.directory===Ea?e:null;if(!t.sessionId){if(s)return s.tabId;const a=Na().filter(d=>d.directory===Ea),i=a.filter(d=>fs.has(d.tabId)),u=i.length>0?i:a;return u.length>0?u[u.length-1].tabId:null}if(s?.ownerSessionId===t.sessionId)return s.tabId;const r=vr.get(t.sessionId);if(r&&Bn(r)?.ownerSessionId===t.sessionId)return r;const o=Na().filter(a=>a.ownerSessionId===t.sessionId);return o.length>0?o[o.length-1].tabId:s&&s.ownerSessionId===null&&(!t.directory||s.directory===t.directory)?s.tabId:null},m0=t=>{const e=bi(t);return e&&Bn(e)?.ownerSessionId===t.sessionId?e:null},h0=(t,e)=>{t.sessionId&&Bn(e)?.ownerSessionId===t.sessionId&&vr.set(t.sessionId,e)},vu=async t=>{const e=fs.get(t);if(e)return e;const s=Os.get(t);return s?(s.wake(),yu(t)):null},Su=t=>{const e=bi(t);return Na().filter(s=>!t.sessionId||!t.directory||s.ownerSessionId===t.sessionId||s.directory===t.directory).map(s=>{let r={title:"",url:""};try{r=s.describe()}catch{}const o=s.ownerSessionId===null?"user":s.ownerSessionId===t.sessionId?"you":"another session";return{id:s.tabId,title:r.title,url:r.url,owner:o,active:s.tabId===e}})},ku=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,ju=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.`,g0=t=>{const e=Su(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 n.jsxs("div",{className:Ye("min-w-0",r?"flex items-baseline gap-2":"flex flex-col gap-0.5"),children:[n.jsx("dt",{className:"shrink-0 typography-micro text-muted-foreground",dir:"ltr",children:e}),n.jsx("dd",{className:"min-w-0 typography-meta",children:n.jsx(Po,{node:s})})]},e)}function uv(t,e){return n.jsx("div",{className:"oc-tile-inset rounded-lg px-3 py-2",children:n.jsx(Po,{node:t})},e)}function fv(t,e){return n.jsx("li",{className:"typography-meta",children:n.jsx(Po,{node:t})},e)}function pv(t){return!t}const du=t=>t.slice(t.indexOf("/")+1),pi=t=>{const e=qe.c(7),{start:s,end:r,className:o}=t,a=xg(s!==void 0&&r===void 0);if(s===void 0)return null;let i;e[0]!==o?(i=Ye("shrink-0 whitespace-nowrap tabular-nums",o),e[0]=o,e[1]=i):i=e[1];const u=(r??a)-s;let d;e[2]!==u?(d=bg(u),e[2]=u,e[3]=d):d=e[3];let l;return e[4]!==i||e[5]!==d?(l=n.jsx("span",{className:i,dir:"auto",children:d}),e[4]=i,e[5]=d,e[6]=l):l=e[6],l},mv=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 s=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:s?void 0:Math.max(...r,...e)}},hv=t=>{const e=qe.c(18),{run:s,groups:r}=t,{t:o}=gt();let a,i,u,d,l,f;if(e[0]!==r||e[1]!==s||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{const p=r.filter(vv);if(p.length===0){f=null;break e}a=ps,i="overlay-scrollbar-wrapper--no-gutter",u=false,d="flex gap-1.5 pb-1";let h;e[9]!==s||e[10]!==o?(h=x=>{const g=x.agents.length,v=mv(x.agents),y=s.state==="running"&&s.currentPhase===x.title;return n.jsxs("div",{className:"oc-tile min-w-[7.5rem] flex-1 rounded-lg px-2.5 py-2",children:[n.jsx("div",{className:Ye("truncate typography-meta",y?"font-semibold text-foreground":"text-foreground"),dir:"auto",children:x.title}),n.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 typography-micro text-muted-foreground",children:[g>0?n.jsx("span",{className:"tabular-nums",dir:"auto",children:`${x.done}/${g}`}):n.jsx("span",{children:o("workflows.panel.phase.waiting")}),g>0?n.jsx(pi,{start:v.start,end:v.end,className:"ms-auto"}):null]}),n.jsx("div",{className:"oc-tile-inset mt-1.5 h-1 overflow-hidden rounded-full",children:g>0?n.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.round(x.done/g*100)}%`,background:x.failed>0?"var(--status-warning)":"var(--status-success)"}}):null})]},x.title)},e[9]=s,e[10]=o,e[11]=h):h=e[11],l=p.map(h)}e[0]=r,e[1]=s,e[2]=o,e[3]=a,e[4]=i,e[5]=u,e[6]=d,e[7]=l,e[8]=f}else a=e[3],i=e[4],u=e[5],d=e[6],l=e[7],f=e[8];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;return e[12]!==a||e[13]!==i||e[14]!==u||e[15]!==d||e[16]!==l?(m=n.jsx(a,{outerClassName:i,fillContainer:u,className:d,children:l}),e[12]=a,e[13]=i,e[14]=u,e[15]=d,e[16]=l,e[17]=m):m=e[17],m},gv=t=>{const e=qe.c(30),{run:s,agent:r,onOpenSession:o}=t,{t:a}=gt(),[i,u]=c.useState(null),[d,l]=c.useState(false),[f,m]=c.useState(false);let p;e[0]!==r.key||e[1]!==s.id?(p=()=>{let N=true;return l(false),wg(s.id,r.key).then(F=>{N&&u(F)}).catch(()=>{N&&l(true)}),()=>{N=false}},e[0]=r.key,e[1]=s.id,e[2]=p):p=e[2];let h;e[3]!==r.key||e[4]!==r.state||e[5]!==s.id?(h=[r.key,r.state,s.id],e[3]=r.key,e[4]=r.state,e[5]=s.id,e[6]=h):h=e[6],c.useEffect(p,h);let x;e[7]!==r.error||e[8]!==r.state?(x=r.error?n.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]=x):x=e[9];let g;e[10]!==d||e[11]!==a?(g=d?n.jsx("p",{className:"typography-meta text-muted-foreground",children:a("workflows.panel.agent.loadFailed")}):null,e[10]=d,e[11]=a,e[12]=g):g=e[12];let v;e[13]!==i||e[14]!==d||e[15]!==a?(v=!i&&!d?n.jsxs("p",{className:"typography-meta text-muted-foreground",children:[a("workflows.panel.agent.loading"),n.jsx(ri,{})]}):null,e[13]=i,e[14]=d,e[15]=a,e[16]=v):v=e[16];let y;e[17]!==i||e[18]!==f||e[19]!==a?(y=i?n.jsxs(n.Fragment,{children:[n.jsxs("section",{children:[n.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:a("workflows.panel.agent.answer")}),n.jsx("div",{className:"mt-1",children:i.result===void 0?n.jsx("p",{className:"typography-meta text-muted-foreground",children:a("workflows.panel.agent.noAnswer")}):n.jsx(cu,{answer:i.result})})]}),n.jsxs("section",{children:[n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsxs("button",{type:"button",onClick:()=>m(Sv),"aria-expanded":f,className:"flex items-center gap-1 typography-micro font-medium text-muted-foreground hover:text-foreground",children:[n.jsx(ue,{name:"arrow-right-s",className:Ye("size-3.5 transition-transform",f&&"rotate-90 rtl:-rotate-90")}),a("workflows.panel.agent.prompt")]})}),n.jsx(Dt,{sideOffset:6,children:a(f?"contextTooltips.workspace.workflow.promptHide":"contextTooltips.workspace.workflow.promptShow")})]}),f?n.jsx(ps,{as:"pre",dir:"auto",outerClassName:"mt-1 max-h-72",className:"whitespace-pre-wrap break-words font-mono typography-micro text-foreground",disableHorizontal:true,children:i.prompt}):null]})]}):null,e[17]=i,e[18]=f,e[19]=a,e[20]=y):y=e[20];let C;e[21]!==o||e[22]!==a?(C=o?n.jsx("div",{children:n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsxs(yt,{type:"button",size:"xs",variant:"ghost",onClick:o,children:[n.jsx(ue,{name:"chat-4",className:"size-3.5"}),a("workflows.panel.agent.openSession")]})}),n.jsx(Dt,{sideOffset:6,children:a("contextTooltips.workspace.workflow.agentSession")})]})}):null,e[21]=o,e[22]=a,e[23]=C):C=e[23];let S;return e[24]!==x||e[25]!==g||e[26]!==v||e[27]!==y||e[28]!==C?(S=n.jsxs("div",{className:"oc-tile mb-1.5 ms-5 flex flex-col gap-2 rounded-lg px-3 py-2.5",children:[x,g,v,y,C]}),e[24]=x,e[25]=g,e[26]=v,e[27]=y,e[28]=C,e[29]=S):S=e[29],S},xv=t=>{const e=qe.c(57),{run:s,agent:r,showModel:o,columns:a,open:i,onToggle:u,onOpenSession:d}=t,{t:l}=gt();let f,m,p,h,x,g,v,y,C,S,N;if(e[0]!==r||e[1]!==a.tokens||e[2]!==u||e[3]!==i||e[4]!==o||e[5]!==l){const T=hg(r.state),I=gg(r);f="button",h=u,x=i,g=r.label,v="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 b=T.icon,w=T.color?{color:T.color}:void 0,j=l(T.labelKey);e[17]!==T||e[18]!==w||e[19]!==j?(y=n.jsx(ue,{name:b,className:"size-3.5 shrink-0",style:w,"aria-label":j}),e[17]=T,e[18]=w,e[19]=j,e[20]=y):y=e[20],e[21]!==r.label?(C=n.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:r.label}),e[21]=r.label,e[22]=C):C=e[22],e[23]!==r.replayed||e[24]!==l?(S=r.replayed?n.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:l("chat.workflow.agent.reused")}):null,e[23]=r.replayed,e[24]=l,e[25]=S):S=e[25],e[26]!==r.model||e[27]!==o?(N=o&&r.model?n.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:du(r.model)}):null,e[26]=r.model,e[27]=o,e[28]=N):N=e[28];const R=r.replayed?void 0:r.startedAt;e[29]!==r.endedAt||e[30]!==R?(m=n.jsx(pi,{start:R,end:r.endedAt,className:"min-w-12 text-end typography-micro text-muted-foreground"}),e[29]=r.endedAt,e[30]=R,e[31]=m):m=e[31],p=a.tokens?n.jsx("span",{className:"min-w-12 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"auto",children:I===null||r.replayed?"":si(I)}):null,e[0]=r,e[1]=a.tokens,e[2]=u,e[3]=i,e[4]=o,e[5]=l,e[6]=f,e[7]=m,e[8]=p,e[9]=h,e[10]=x,e[11]=g,e[12]=v,e[13]=y,e[14]=C,e[15]=S,e[16]=N}else f=e[6],m=e[7],p=e[8],h=e[9],x=e[10],g=e[11],v=e[12],y=e[13],C=e[14],S=e[15],N=e[16];let F;e[32]!==r.replayed||e[33]!==r.usage||e[34]!==a.cost?(F=a.cost?n.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?ni(r.usage.cost):""}):null,e[32]=r.replayed,e[33]=r.usage,e[34]=a.cost,e[35]=F):F=e[35];let _;e[36]!==f||e[37]!==m||e[38]!==p||e[39]!==F||e[40]!==h||e[41]!==x||e[42]!==g||e[43]!==v||e[44]!==y||e[45]!==C||e[46]!==S||e[47]!==N?(_=n.jsxs("button",{type:f,onClick:h,"aria-expanded":x,title:g,className:v,children:[y,C,S,N,m,p,F]}),e[36]=f,e[37]=m,e[38]=p,e[39]=F,e[40]=h,e[41]=x,e[42]=g,e[43]=v,e[44]=y,e[45]=C,e[46]=S,e[47]=N,e[48]=_):_=e[48];let M;e[49]!==r||e[50]!==d||e[51]!==i||e[52]!==s?(M=i?n.jsx(gv,{run:s,agent:r,onOpenSession:d}):null,e[49]=r,e[50]=d,e[51]=i,e[52]=s,e[53]=M):M=e[53];let B;return e[54]!==_||e[55]!==M?(B=n.jsxs(n.Fragment,{children:[_,M]}),e[54]=_,e[55]=M,e[56]=B):B=e[56],B},bv=(t,e)=>{const s=mg(t);if(s.measured===0)return null;const r=[];return e.tokens&&r.push(si(s.tokens)),e.cost&&s.cost>0&&r.push(ni(s.cost)),r.length>0?r.join(" \xB7 "):null},wv=t=>{const e=new Set(t.map(r=>r.model??null)),[s]=e;return e.size===1&&s?du(s):null},yv=t=>{const e=qe.c(51),{run:s,directory:r}=t,{t:o}=gt();let a;e[0]!==s?(a=ug(s),e[0]=s,e[1]=a):a=e[1];const i=a,u=fg(r),[d,l]=c.useState(kv),[f,m]=c.useState(jv);let p,h,x,g,v,y;if(e[2]!==i||e[3]!==d||e[4]!==u||e[5]!==s||e[6]!==o||e[7]!==f){const N=pg(s),F=N.measured>0,_=N.cost>0;let M,B,T;if(e[14]!==i||e[15]!==d||e[16]!==u||e[17]!==s||e[18]!==o||e[19]!==F||e[20]!==_||e[21]!==f){const I={tokens:F,cost:_},b=s.agents.filter(Tv).length,w=Cv;v="flex h-full min-h-0 flex-col";let j;e[28]!==i||e[29]!==s?(j=n.jsx(hv,{run:s,groups:i}),e[28]=i,e[29]=s,e[30]=j):j=e[30];const R=i.map(L=>{if(L.agents.length===0)return null;const E=L.title??"",D=L.done+L.failed===L.agents.length,V=(s.state==="running"&&D)===f.has(E),J=wv(L.agents),W=bv(L.agents,I);return n.jsxs("section",{className:"mt-3",children:[n.jsxs("button",{type:"button",onClick:()=>w(m,E),"aria-expanded":V,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:[n.jsx(ue,{name:"arrow-right-s",className:Ye("size-3.5 shrink-0 transition-transform",V&&"rotate-90 rtl:-rotate-90")}),n.jsx("span",{className:"min-w-0 truncate",dir:"auto",children:L.title??o("chat.workflow.phase.unphased")}),J?n.jsx("span",{className:"min-w-0 truncate font-normal",dir:"ltr",children:`\xB7 ${J}`}):null,W?n.jsx("span",{className:"ms-auto shrink-0 tabular-nums font-normal",dir:"ltr",children:W}):null,n.jsx("span",{className:Ye("shrink-0 tabular-nums font-normal",!W&&"ms-auto"),dir:"auto",children:W?`\xB7 ${L.done}/${L.agents.length}`:`${L.done}/${L.agents.length}`})]}),V?L.agents.map(G=>{const le=G.sessionId;return n.jsx(xv,{run:s,agent:G,showModel:J===null,columns:I,open:d.has(G.key),onToggle:()=>w(l,G.key),onOpenSession:le?()=>u(le,G.label):null},G.key)}):null]},E)});e[31]!==j||e[32]!==R?(y=n.jsxs(ps,{outerClassName:"min-h-0 flex-1",className:"px-3 py-3",disableHorizontal:true,children:[j,R]}),e[31]=j,e[32]=R,e[33]=y):y=e[33],p="flex shrink-0 flex-wrap items-center gap-x-1.5 border-t border-edge px-3 py-2 typography-micro text-muted-foreground",M="tabular-nums",B="auto",T=o("workflows.panel.summary.agents",{done:b,total:s.agents.length}),e[14]=i,e[15]=d,e[16]=u,e[17]=s,e[18]=o,e[19]=F,e[20]=_,e[21]=f,e[22]=M,e[23]=B,e[24]=T,e[25]=p,e[26]=v,e[27]=y}else M=e[22],B=e[23],T=e[24],p=e[25],v=e[26],y=e[27];e[34]!==M||e[35]!==B||e[36]!==T?(h=n.jsx("span",{className:M,dir:B,children:T}),e[34]=M,e[35]=B,e[36]=T,e[37]=h):h=e[37],e[38]!==s.endedAt||e[39]!==s.startedAt||e[40]!==s.state?(x=s.startedAt!==void 0?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":true,children:"\xB7"}),n.jsx(pi,{start:s.startedAt,end:s.state==="running"?void 0:s.endedAt??s.startedAt})]}):null,e[38]=s.endedAt,e[39]=s.startedAt,e[40]=s.state,e[41]=x):x=e[41],g=N.measured>0?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":true,children:"\xB7"}),n.jsx("span",{className:"tabular-nums",dir:"auto",children:o("workflows.panel.summary.tokens",{tokens:si(N.tokens)})}),N.cost>0?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":true,children:"\xB7"}),n.jsx("span",{className:"tabular-nums",dir:"ltr",children:ni(N.cost)})]}):null]}):null,e[2]=i,e[3]=d,e[4]=u,e[5]=s,e[6]=o,e[7]=f,e[8]=p,e[9]=h,e[10]=x,e[11]=g,e[12]=v,e[13]=y}else p=e[8],h=e[9],x=e[10],g=e[11],v=e[12],y=e[13];let C;e[42]!==p||e[43]!==h||e[44]!==x||e[45]!==g?(C=n.jsxs("div",{className:p,children:[h,x,g]}),e[42]=p,e[43]=h,e[44]=x,e[45]=g,e[46]=C):C=e[46];let S;return e[47]!==v||e[48]!==y||e[49]!==C?(S=n.jsxs("div",{className:v,children:[y,C]}),e[47]=v,e[48]=y,e[49]=C,e[50]=S):S=e[50],S};function vv(t){return t.title!==null}function Sv(t){return!t}function kv(){return new Set}function jv(){return new Set}function Tv(t){return t.state==="completed"}function Cv(t,e){return t(s=>{const r=new Set(s);return r.has(e)?r.delete(e):r.add(e),r})}const Ev={steps:["data-workflows-header-compact","data-workflows-header-tight","data-workflows-header-narrow"]},Iv=[{id:"agents",icon:"flow-chart",labelKey:"workflows.panel.view.agents",tooltipKey:"contextTooltips.workspace.workflow.view.agents"},{id:"log",icon:"file-list-2",labelKey:"workflows.panel.view.log",tooltipKey:"contextTooltips.workspace.workflow.view.log"},{id:"result",icon:"checkbox-circle",labelKey:"workflows.panel.view.result",tooltipKey:"contextTooltips.workspace.workflow.view.result"},{id:"script",icon:"code-sslash",labelKey:"workflows.panel.view.script",tooltipKey:"contextTooltips.workspace.workflow.view.script"}],Nv=1500,Pv=(t,e)=>{const s=qe.c(11),[r,o]=c.useState(null),[a,i]=c.useState(null),u=c.useRef(null),d=e!=="agents",l=e==="log"&&t.state==="running"?t.logs.at(-1)?.at??0:0;let f;s[0]!==t.id||s[1]!==d?(f=()=>{if(!d)return;let g=true;const v=u.current?.runId===t.id?u.current.at:0,y=Math.max(0,v+Nv-Date.now()),C=setTimeout(()=>{u.current={runId:t.id,at:Date.now()},Ng(t.id).then(S=>{g&&(o(S),i(null))}).catch(()=>{g&&i(t.id)})},y);return()=>{g=false,clearTimeout(C)}},s[0]=t.id,s[1]=d,s[2]=f):f=s[2];let m;s[3]!==l||s[4]!==t.id||s[5]!==t.state||s[6]!==d?(m=[l,t.id,t.state,d],s[3]=l,s[4]=t.id,s[5]=t.state,s[6]=d,s[7]=m):m=s[7],c.useEffect(f,m);const p=r?.runId===t.id?r:null,h=a===t.id;let x;return s[8]!==p||s[9]!==h?(x={detail:p,failed:h},s[8]=p,s[9]=h,s[10]=x):x=s[10],x},Rv=t=>new Intl.DateTimeFormat(yd(),{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(t),Dv=t=>{const e=qe.c(8),{run:s,detail:r}=t,{t:o}=gt(),a=r?.logs??s.logs;if(a.length===0){let d;e[0]!==o?(d=o("workflows.panel.log.empty"),e[0]=o,e[1]=d):d=e[1];let l;return e[2]!==d?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:d}),e[2]=d,e[3]=l):l=e[3],l}let i;e[4]!==a?(i=a.map(Wv),e[4]=a,e[5]=i):i=e[5];let u;return e[6]!==i?(u=n.jsx("ol",{className:"flex flex-col gap-1 px-3 py-3",children:i}),e[6]=i,e[7]=u):u=e[7],u},_v=t=>{const e=qe.c(24),{run:s,detail:r,failed:o}=t,{t:a}=gt();if(s.error&&(s.state==="failed"||s.state==="stopped")){const d=s.state==="failed"?"var(--status-error)":void 0;let l;e[0]!==d?(l={color:d},e[0]=d,e[1]=l):l=e[1];let f;return e[2]!==s.error||e[3]!==l?(f=n.jsx("p",{dir:"auto",className:"px-4 py-6 typography-meta",style:l,children:s.error}),e[2]=s.error,e[3]=l,e[4]=f):f=e[4],f}if(s.state==="awaiting-approval"||s.state==="running"||s.state==="declined"){let d;e[5]!==a?(d=a("workflows.panel.result.pending"),e[5]=a,e[6]=d):d=e[6];let l;return e[7]!==d?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:d}),e[7]=d,e[8]=l):l=e[8],l}if(o&&!r){let d;e[9]!==a?(d=a("workflows.panel.detail.loadFailed"),e[9]=a,e[10]=d):d=e[10];let l;return e[11]!==d?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:d}),e[11]=d,e[12]=l):l=e[12],l}if(!r){let d;e[13]!==a?(d=a("workflows.panel.agent.loading"),e[13]=a,e[14]=d):d=e[14];let l;e[15]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(ri,{}),e[15]=l):l=e[15];let f;return e[16]!==d?(f=n.jsxs("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:[d,l]}),e[16]=d,e[17]=f):f=e[17],f}const{result:i}=r;if(!i||i.kind==="json"&&i.value===null){let d;e[18]!==a?(d=a("workflows.panel.result.none"),e[18]=a,e[19]=d):d=e[19];let l;return e[20]!==d?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:d}),e[20]=d,e[21]=l):l=e[21],l}let u;return e[22]!==i?(u=n.jsx("div",{className:"px-4 py-3",children:n.jsx(cu,{answer:i})}),e[22]=i,e[23]=u):u=e[23],u},Av=t=>{const e=qe.c(16),{detail:s,failed:r}=t,{t:o}=gt();if(!s){let m;e[0]!==r||e[1]!==o?(m=r?o("workflows.panel.detail.loadFailed"):n.jsxs(n.Fragment,{children:[o("workflows.panel.agent.loading"),n.jsx(ri,{})]}),e[0]=r,e[1]=o,e[2]=m):m=e[2];let p;return e[3]!==m?(p=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:m}),e[3]=m,e[4]=p):p=e[4],p}const a=s.args;let i;e[5]!==a?(i=a!=null&&JSON.stringify(a)!=="{}",e[5]=a,e[6]=i):i=e[6];const u=i;let d;e[7]!==a||e[8]!==u||e[9]!==o?(d=u?n.jsxs("section",{children:[n.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:o("workflows.panel.script.args")}),n.jsx(ps,{as:"pre",dir:"ltr",outerClassName:"overlay-scrollbar-wrapper--no-gutter oc-tile mt-1 rounded-lg",fillContainer:false,className:"px-3 py-2 font-mono typography-micro text-foreground",children:JSON.stringify(a,null,2)})]}):null,e[7]=a,e[8]=u,e[9]=o,e[10]=d):d=e[10];let l;e[11]!==s.script?(l=n.jsx(ps,{as:"pre",dir:"ltr",outerClassName:"overlay-scrollbar-wrapper--no-gutter oc-tile rounded-lg",fillContainer:false,className:"px-3 py-2 font-mono typography-micro leading-relaxed text-foreground",children:s.script}),e[11]=s.script,e[12]=l):l=e[12];let f;return e[13]!==d||e[14]!==l?(f=n.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3",children:[d,l]}),e[13]=d,e[14]=l,e[15]=f):f=e[15],f},Ov=t=>{const e=qe.c(83),{run:s}=t,{t:r}=gt(),{pending:o,act:a}=Ig(),i=o===s.id;if(s.state==="awaiting-approval"){let u;e[0]!==r?(u=r("contextTooltips.workspace.workflow.approve"),e[0]=r,e[1]=u):u=e[1];let d;e[2]!==a||e[3]!==s.id?(d=()=>a(s.id,"approve"),e[2]=a,e[3]=s.id,e[4]=d):d=e[4];let l;e[5]!==r?(l=r("chat.workflow.action.run"),e[5]=r,e[6]=l):l=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(ue,{name:"play",className:"size-3.5"}),e[7]=f):f=e[7];let m;e[8]!==r?(m=r("chat.workflow.action.run"),e[8]=r,e[9]=m):m=e[9];let p;e[10]!==m?(p=n.jsx("span",{className:"workflows-header__action-label",children:m}),e[10]=m,e[11]=p):p=e[11];let h;e[12]!==i||e[13]!==d||e[14]!==l||e[15]!==p?(h=n.jsxs(yt,{type:"button",size:"sm",disabled:i,onClick:d,"aria-label":l,children:[f,p]}),e[12]=i,e[13]=d,e[14]=l,e[15]=p,e[16]=h):h=e[16];let x;e[17]!==u||e[18]!==h?(x=n.jsx(es,{label:u,side:"bottom",className:"shrink-0",children:h}),e[17]=u,e[18]=h,e[19]=x):x=e[19];let g;e[20]!==r?(g=r("contextTooltips.workspace.workflow.decline"),e[20]=r,e[21]=g):g=e[21];let v;e[22]!==a||e[23]!==s.id?(v=()=>a(s.id,"decline"),e[22]=a,e[23]=s.id,e[24]=v):v=e[24];let y;e[25]!==r?(y=r("chat.workflow.action.decline"),e[25]=r,e[26]=y):y=e[26];let C;e[27]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(ue,{name:"close",className:"size-3.5"}),e[27]=C):C=e[27];let S;e[28]!==r?(S=r("chat.workflow.action.decline"),e[28]=r,e[29]=S):S=e[29];let N;e[30]!==S?(N=n.jsx("span",{className:"workflows-header__action-label",children:S}),e[30]=S,e[31]=N):N=e[31];let F;e[32]!==i||e[33]!==v||e[34]!==y||e[35]!==N?(F=n.jsxs(yt,{type:"button",size:"sm",variant:"outline",disabled:i,onClick:v,"aria-label":y,children:[C,N]}),e[32]=i,e[33]=v,e[34]=y,e[35]=N,e[36]=F):F=e[36];let _;e[37]!==F||e[38]!==g?(_=n.jsx(es,{label:g,side:"bottom",className:"shrink-0",children:F}),e[37]=F,e[38]=g,e[39]=_):_=e[39];let M;return e[40]!==_||e[41]!==x?(M=n.jsxs(n.Fragment,{children:[x,_]}),e[40]=_,e[41]=x,e[42]=M):M=e[42],M}if(s.state==="running"){let u;e[43]!==r?(u=r("contextTooltips.workspace.workflow.stop"),e[43]=r,e[44]=u):u=e[44];let d;e[45]!==a||e[46]!==s.id?(d=()=>a(s.id,"stop"),e[45]=a,e[46]=s.id,e[47]=d):d=e[47];let l;e[48]!==r?(l=r("chat.workflow.action.stop"),e[48]=r,e[49]=l):l=e[49];let f;e[50]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(ue,{name:"stop",className:"size-3.5"}),e[50]=f):f=e[50];let m;e[51]!==r?(m=r("chat.workflow.action.stop"),e[51]=r,e[52]=m):m=e[52];let p;e[53]!==m?(p=n.jsx("span",{className:"workflows-header__action-label",children:m}),e[53]=m,e[54]=p):p=e[54];let h;e[55]!==i||e[56]!==d||e[57]!==l||e[58]!==p?(h=n.jsxs(yt,{type:"button",size:"sm",variant:"outline",disabled:i,onClick:d,"aria-label":l,children:[f,p]}),e[55]=i,e[56]=d,e[57]=l,e[58]=p,e[59]=h):h=e[59];let x;return e[60]!==u||e[61]!==h?(x=n.jsx(es,{label:u,side:"bottom",className:"shrink-0",children:h}),e[60]=u,e[61]=h,e[62]=x):x=e[62],x}if(s.state==="failed"||s.state==="stopped"){let u;e[63]!==r?(u=r("contextTooltips.workspace.workflow.resume"),e[63]=r,e[64]=u):u=e[64];let d;e[65]!==a||e[66]!==s.id?(d=()=>a(s.id,"resume"),e[65]=a,e[66]=s.id,e[67]=d):d=e[67];let l;e[68]!==r?(l=r("chat.workflow.action.resume"),e[68]=r,e[69]=l):l=e[69];let f;e[70]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(ue,{name:"restart",className:"size-3.5"}),e[70]=f):f=e[70];let m;e[71]!==r?(m=r("chat.workflow.action.resume"),e[71]=r,e[72]=m):m=e[72];let p;e[73]!==m?(p=n.jsx("span",{className:"workflows-header__action-label",children:m}),e[73]=m,e[74]=p):p=e[74];let h;e[75]!==i||e[76]!==d||e[77]!==l||e[78]!==p?(h=n.jsxs(yt,{type:"button",size:"sm",variant:"outline",disabled:i,onClick:d,"aria-label":l,children:[f,p]}),e[75]=i,e[76]=d,e[77]=l,e[78]=p,e[79]=h):h=e[79];let x;return e[80]!==u||e[81]!==h?(x=n.jsx(es,{label:u,side:"bottom",className:"shrink-0",children:h}),e[80]=u,e[81]=h,e[82]=x):x=e[82],x}return null},Mv=()=>{const t=qe.c(2),e=os(Vv);let s;return t[0]!==e?(s={get:r=>e.get(r)?.title},t[0]=e,t[1]=s):s=t[1],s},yl=t=>{const e=qe.c(31),{run:s,selected:r,caption:o,onSelect:a}=t,{t:i}=gt();let u,d,l,f,m,p,h;if(e[0]!==a||e[1]!==s.state||e[2]!==i){const N=wd(s.state);d=Ks,h=a,u=ue,l=N.icon,f="size-3.5 shrink-0",m=N.color?{color:N.color}:void 0,p=i(N.labelKey),e[0]=a,e[1]=s.state,e[2]=i,e[3]=u,e[4]=d,e[5]=l,e[6]=f,e[7]=m,e[8]=p,e[9]=h}else u=e[3],d=e[4],l=e[5],f=e[6],m=e[7],p=e[8],h=e[9];let x;e[10]!==u||e[11]!==l||e[12]!==f||e[13]!==m||e[14]!==p?(x=n.jsx(u,{name:l,className:f,style:m,"aria-label":p}),e[10]=u,e[11]=l,e[12]=f,e[13]=m,e[14]=p,e[15]=x):x=e[15];let g;e[16]!==s.name?(g=n.jsx("span",{className:"truncate",dir:"auto",children:s.name}),e[16]=s.name,e[17]=g):g=e[17];let v;e[18]!==o?(v=o?n.jsx("span",{className:"truncate typography-micro text-muted-foreground",dir:"auto",children:o}):null,e[18]=o,e[19]=v):v=e[19];let y;e[20]!==g||e[21]!==v?(y=n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[g,v]}),e[20]=g,e[21]=v,e[22]=y):y=e[22];let C;e[23]!==r?(C=r?n.jsx(ue,{name:"check",className:"size-3.5 shrink-0"}):null,e[23]=r,e[24]=C):C=e[24];let S;return e[25]!==d||e[26]!==C||e[27]!==h||e[28]!==x||e[29]!==y?(S=n.jsxs(d,{onSelect:h,children:[x,y,C]}),e[25]=d,e[26]=C,e[27]=h,e[28]=x,e[29]=y,e[30]=S):S=e[30],S},Fv=t=>{const e=qe.c(63),{runs:s,selected:r,sessionId:o,sessionTitles:a,saved:i,onSelect:u,onRunSaved:d,onDelete:l}=t,{t:f}=gt();let m;e[0]!==r.state?(m=wd(r.state),e[0]=r.state,e[1]=m):m=e[1];const p=m;let h,x,g,v,y,C,S;if(e[2]!==p.color||e[3]!==p.icon||e[4]!==u||e[5]!==s||e[6]!==r.id||e[7]!==r.name||e[8]!==o||e[9]!==a||e[10]!==f){const B=s.slice().reverse();let T;e[18]!==o?(T=G=>G.parentSessionId===o,e[18]=o,e[19]=T):T=e[19];const I=B.filter(T);let b;e[20]!==o?(b=G=>G.parentSessionId!==o,e[20]=o,e[21]=b):b=e[21];const w=B.filter(b);x=Sn;let j;e[22]!==f?(j=f("workflows.panel.runPicker"),e[22]=f,e[23]=j):j=e[23];let R;e[24]===Symbol.for("react.memo_cache_sentinel")?(R=Ye(Eg(),"max-w-[14rem] shrink-0"),e[24]=R):R=e[24];let L;e[25]!==p.color?(L=p.color?{color:p.color}:void 0,e[25]=p.color,e[26]=L):L=e[26];let E;e[27]!==p.icon||e[28]!==L?(E=n.jsx(ue,{name:p.icon,className:"size-3.5",style:L}),e[27]=p.icon,e[28]=L,e[29]=E):E=e[29];let D;e[30]!==r.name?(D=n.jsx("span",{className:"workflows-header__run-name min-w-0 truncate",dir:"auto",children:r.name}),e[30]=r.name,e[31]=D):D=e[31];let U;e[32]===Symbol.for("react.memo_cache_sentinel")?(U=n.jsx(ue,{name:"arrow-down-s",className:"size-4"}),e[32]=U):U=e[32];let V;e[33]!==E||e[34]!==D||e[35]!==j?(V=n.jsx(Pt,{asChild:true,children:n.jsx(kn,{asChild:true,children:n.jsxs("button",{type:"button","aria-label":j,className:R,children:[E,D,U]})})}),e[33]=E,e[34]=D,e[35]=j,e[36]=V):V=e[36];let J;e[37]!==f?(J=f("contextTooltips.workspace.workflow.pickRun"),e[37]=f,e[38]=J):J=e[38];let W;e[39]!==J?(W=n.jsx(Dt,{side:"bottom",sideOffset:6,children:J}),e[39]=J,e[40]=W):W=e[40],e[41]!==V||e[42]!==W?(S=n.jsxs(Rt,{children:[V,W]}),e[41]=V,e[42]=W,e[43]=S):S=e[43],h=jn,g="start",v="max-h-[min(var(--available-height),28rem)] w-[18rem] max-w-[calc(100vw-2rem)] overflow-y-auto",y=I.length>0?n.jsxs(n.Fragment,{children:[n.jsx(Hr,{children:f("workflows.panel.picker.thisSession")}),I.map(G=>n.jsx(yl,{run:G,selected:G.id===r.id,onSelect:()=>u(G.id)},G.id))]}):null,C=w.length>0?n.jsxs(n.Fragment,{children:[I.length>0?n.jsx(tr,{}):null,n.jsx(Hr,{children:f("workflows.panel.picker.otherSessions")}),w.map(G=>n.jsx(yl,{run:G,selected:G.id===r.id,caption:a.get(G.parentSessionId)||f("workflows.panel.picker.untitledSession"),onSelect:()=>u(G.id)},G.id))]}):null,e[2]=p.color,e[3]=p.icon,e[4]=u,e[5]=s,e[6]=r.id,e[7]=r.name,e[8]=o,e[9]=a,e[10]=f,e[11]=h,e[12]=x,e[13]=g,e[14]=v,e[15]=y,e[16]=C,e[17]=S}else h=e[11],x=e[12],g=e[13],v=e[14],y=e[15],C=e[16],S=e[17];let N;e[44]!==d||e[45]!==i||e[46]!==f?(N=i.length>0?n.jsxs(n.Fragment,{children:[n.jsx(tr,{}),n.jsx(Hr,{children:f("workflows.panel.picker.saved")}),i.map(B=>n.jsxs(Ks,{disabled:!!B.error,onSelect:()=>d(B.name),title:B.error??B.description,children:[n.jsx(ue,{name:"play",className:"size-3.5 shrink-0"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:B.name})]},B.name))]}):null,e[44]=d,e[45]=i,e[46]=f,e[47]=N):N=e[47];let F;e[48]!==l||e[49]!==f?(F=l?n.jsxs(n.Fragment,{children:[n.jsx(tr,{}),n.jsxs(Ks,{variant:"destructive",onSelect:l,children:[n.jsx(ue,{name:"delete-bin",className:"size-3.5 shrink-0"}),f("workflows.panel.delete.action")]})]}):null,e[48]=l,e[49]=f,e[50]=F):F=e[50];let _;e[51]!==h||e[52]!==g||e[53]!==v||e[54]!==y||e[55]!==C||e[56]!==N||e[57]!==F?(_=n.jsxs(h,{align:g,className:v,children:[y,C,N,F]}),e[51]=h,e[52]=g,e[53]=v,e[54]=y,e[55]=C,e[56]=N,e[57]=F,e[58]=_):_=e[58];let M;return e[59]!==x||e[60]!==S||e[61]!==_?(M=n.jsxs(x,{children:[S,_]}),e[59]=x,e[60]=S,e[61]=_,e[62]=M):M=e[62],M},Lv=(t,e,s,r)=>{const o=qe.c(11),{t:a}=gt(),{confirm:i,dialog:u}=ei(),d=oi(Uv);let l;o[0]!==i||o[1]!==t||o[2]!==e||o[3]!==d||o[4]!==r||o[5]!==s||o[6]!==a?(l=async p=>{if(!(!t||!e||!await i({title:a("workflows.panel.saved.confirmTitle",{name:p}),message:a(s?"workflows.panel.saved.confirmHere":"workflows.panel.saved.confirmNew"),action:a("workflows.panel.saved.confirmAction")})))try{const x=await kg({directory:t,scriptDirectory:e,sessionId:s,name:p});s?d(r,x.runId):(d(x.sessionId,x.runId),it.getState().setCurrentSession(x.sessionId,t))}catch(x){const g=x;Fe.error(a("workflows.panel.saved.failed"),{description:g instanceof Error?g.message:void 0})}},o[0]=i,o[1]=t,o[2]=e,o[3]=d,o[4]=r,o[5]=s,o[6]=a,o[7]=l):l=o[7];const f=l;let m;return o[8]!==u||o[9]!==f?(m={run:f,dialog:u},o[8]=u,o[9]=f,o[10]=m):m=o[10],m},$v=t=>{const e=qe.c(23),{saved:s,onRunSaved:r}=t,{t:o}=gt();if(s.length===0){let m;e[0]!==o?(m=o("workflows.panel.emptyProject"),e[0]=o,e[1]=m):m=e[1];let p;return e[2]!==m?(p=n.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-meta text-muted-foreground",children:m}),e[2]=m,e[3]=p):p=e[3],p}let a;e[4]!==o?(a=o("workflows.panel.emptyProject"),e[4]=o,e[5]=a):a=e[5];let i;e[6]!==a?(i=n.jsx("p",{className:"typography-meta text-muted-foreground",children:a}),e[6]=a,e[7]=i):i=e[7];let u;e[8]!==o?(u=o("workflows.panel.picker.saved"),e[8]=o,e[9]=u):u=e[9];let d;e[10]!==u?(d=n.jsx("h4",{className:"mt-2 typography-micro font-medium text-muted-foreground",children:u}),e[10]=u,e[11]=d):d=e[11];let l;if(e[12]!==r||e[13]!==s||e[14]!==o){let m;e[16]!==r||e[17]!==o?(m=p=>n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate typography-meta text-foreground",dir:"auto",children:p.name}),p.description||p.error?n.jsx("div",{className:"truncate typography-micro text-muted-foreground",dir:"auto",title:p.error??p.description,children:p.error??p.description}):null]}),n.jsx(es,{label:o("workflows.panel.saved.runAria",{name:p.name}),className:"shrink-0",children:n.jsxs(yt,{type:"button",size:"sm",variant:"outline",disabled:!!p.error,onClick:()=>r(p.name),"aria-label":o("workflows.panel.saved.runAria",{name:p.name}),children:[n.jsx(ue,{name:"play",className:"size-3.5"}),o("workflows.panel.saved.confirmAction")]})})]},p.name),e[16]=r,e[17]=o,e[18]=m):m=e[18],l=s.map(m),e[12]=r,e[13]=s,e[14]=o,e[15]=l}else l=e[15];let f;return e[19]!==i||e[20]!==d||e[21]!==l?(f=n.jsxs("div",{className:"flex flex-col gap-1 px-3 py-3",children:[i,d,l]}),e[19]=i,e[20]=d,e[21]=l,e[22]=f):f=e[22],f},Bv=t=>{const e=qe.c(17),{directory:s}=t,r=it(Hv),o=yg(s),a=vg(o),i=Sg(o?.savedDirectory??null),u=r??`directory:${s??""}`;let d;e[0]!==u?(d=v=>v.selectedBySession[u],e[0]=u,e[1]=d):d=e[1];const l=oi(d),{run:f,dialog:m}=Lv(s,o?.savedDirectory??null,r,u);let p;e[2]!==a||e[3]!==l||e[4]!==r?(p=a.find(v=>v.id===l)??a.filter(v=>v.parentSessionId===r).at(-1)??a.at(-1)??null,e[2]=a,e[3]=l,e[4]=r,e[5]=p):p=e[5];const h=p;let x;e[6]!==s||e[7]!==h||e[8]!==f||e[9]!==a||e[10]!==i||e[11]!==u||e[12]!==r?(x=h?n.jsx(zv,{sessionId:r,selectionKey:u,runs:a,saved:i,run:h,directory:s,onRunSaved:v=>{f(v)}}):n.jsx($v,{saved:i,onRunSaved:v=>{f(v)}}),e[6]=s,e[7]=h,e[8]=f,e[9]=a,e[10]=i,e[11]=u,e[12]=r,e[13]=x):x=e[13];let g;return e[14]!==m||e[15]!==x?(g=n.jsxs(n.Fragment,{children:[m,x]}),e[14]=m,e[15]=x,e[16]=g):g=e[16],g},zv=t=>{const e=qe.c(58),{sessionId:s,selectionKey:r,runs:o,saved:a,run:i,directory:u,onRunSaved:d}=t,{t:l}=gt(),f=oi(Kv),m=Mv(),[p,h]=c.useState("agents"),{detail:x,failed:g}=Pv(i,p),v=c.useRef(null);jg(v,Ev);const{confirm:y,dialog:C}=ei(),S=i.state==="running"||i.state==="awaiting-approval",N=i.parentSessionId!==s;let F;e[0]!==y||e[1]!==i.id||e[2]!==i.name||e[3]!==i.parentSessionId||e[4]!==l?(F=async()=>{if(await y({title:l("workflows.panel.delete.title",{name:i.name}),message:l("workflows.panel.delete.message"),action:l("workflows.panel.delete.confirm"),destructive:true}))try{await Tg(i.id),Cg.getState().remove(i.parentSessionId,i.id)}catch(G){const le=G;Fe.error(l("workflows.panel.delete.failed"),{description:le instanceof Error?le.message:void 0})}},e[0]=y,e[1]=i.id,e[2]=i.name,e[3]=i.parentSessionId,e[4]=l,e[5]=F):F=e[5];const _=F;let M;e[6]!==i.directory||e[7]!==i.id||e[8]!==i.parentSessionId||e[9]!==f?(M=()=>{f(i.parentSessionId,i.id),it.getState().setCurrentSession(i.parentSessionId,i.directory)},e[6]=i.directory,e[7]=i.id,e[8]=i.parentSessionId,e[9]=f,e[10]=M):M=e[10];const B=M;let T;e[11]!==f||e[12]!==r?(T=W=>f(r,W),e[11]=f,e[12]=r,e[13]=T):T=e[13];let I;e[14]!==_||e[15]!==S?(I=S?null:()=>{_()},e[14]=_,e[15]=S,e[16]=I):I=e[16];let b;e[17]!==d||e[18]!==i||e[19]!==o||e[20]!==a||e[21]!==s||e[22]!==m||e[23]!==T||e[24]!==I?(b=n.jsx(Fv,{runs:o,selected:i,sessionId:s,sessionTitles:m,saved:a,onSelect:T,onRunSaved:d,onDelete:I}),e[17]=d,e[18]=i,e[19]=o,e[20]=a,e[21]=s,e[22]=m,e[23]=T,e[24]=I,e[25]=b):b=e[25];let w;e[26]!==l?(w=l("workflows.panel.view.label"),e[26]=l,e[27]=w):w=e[27];let j;e[28]!==l||e[29]!==p?(j=Iv.map(W=>{const G=W.id===p;return n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsxs("button",{type:"button",onClick:()=>h(W.id),"aria-current":G?"page":void 0,"aria-label":l(W.labelKey),className:Ye("flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 transition-colors",G?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground"),children:[n.jsx(ue,{name:W.icon,className:"size-3.5 shrink-0"}),n.jsx("span",{className:"workflows-header__label whitespace-nowrap typography-meta",children:l(W.labelKey)})]})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:l(W.tooltipKey)})]},W.id)}),e[28]=l,e[29]=p,e[30]=j):j=e[30];let R;e[31]!==w||e[32]!==j?(R=n.jsx("nav",{className:"flex shrink-0 items-center gap-1","aria-label":w,children:j}),e[31]=w,e[32]=j,e[33]=R):R=e[33];let L;e[34]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("div",{"aria-hidden":true,className:"min-w-0 flex-1"}),e[34]=L):L=e[34];let E;e[35]!==N||e[36]!==B||e[37]!==i.parentSessionId||e[38]!==m||e[39]!==l?(E=N?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsxs(yt,{type:"button",size:"sm",variant:"ghost",onClick:B,"aria-label":l("workflows.panel.agent.openSession"),children:[n.jsx(ue,{name:"chat-4",className:"size-3.5"}),n.jsx("span",{className:"workflows-header__action-label",children:l("workflows.panel.agent.openSession")})]})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:m.get(i.parentSessionId)||l("workflows.panel.picker.untitledSession")})]}):null,e[35]=N,e[36]=B,e[37]=i.parentSessionId,e[38]=m,e[39]=l,e[40]=E):E=e[40];let D;e[41]!==i?(D=n.jsx(Ov,{run:i}),e[41]=i,e[42]=D):D=e[42];let U;e[43]!==E||e[44]!==D||e[45]!==b||e[46]!==R?(U=n.jsx(bd,{children:n.jsxs("div",{ref:v,className:"workflows-header flex min-w-0 flex-1 flex-nowrap items-center gap-1.5 overflow-hidden ps-1 pe-1",children:[b,R,L,E,D]})}),e[43]=E,e[44]=D,e[45]=b,e[46]=R,e[47]=U):U=e[47];let V;e[48]!==x||e[49]!==u||e[50]!==g||e[51]!==i||e[52]!==p?(V=p==="agents"?n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(yv,{run:i,directory:u},i.id)}):n.jsxs(ps,{outerClassName:"min-h-0 flex-1",disableHorizontal:true,children:[p==="log"?n.jsx(Dv,{run:i,detail:x}):null,p==="result"?n.jsx(_v,{run:i,detail:x,failed:g}):null,p==="script"?n.jsx(Av,{detail:x,failed:g}):null]}),e[48]=x,e[49]=u,e[50]=g,e[51]=i,e[52]=p,e[53]=V):V=e[53];let J;return e[54]!==C||e[55]!==U||e[56]!==V?(J=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[C,U,V]}),e[54]=C,e[55]=U,e[56]=V,e[57]=J):J=e[57],J};function Wv(t,e){return n.jsxs("li",{className:"flex min-w-0 gap-3 typography-meta",children:[n.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",dir:"ltr",children:Rv(t.at)}),n.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words text-foreground",dir:"auto",children:t.message})]},`${t.at}-${e}`)}function Vv(t){return t.entityById}function Uv(t){return t.select}function Hv(t){return t.currentSessionId}function Kv(t){return t.select}const vl=60,qv=t=>{try{return new URL(t).origin}catch{return""}},Qo=new Set,uu=Io()((t,e)=>({byOrigin:{},resolve:(s,r,o)=>{const a=qv(s);!a||!r||e().byOrigin[a]||Qo.has(a)||(Qo.add(a),en("desktop_browser_fetch_favicon",{url:r,webContentsId:o}).then(i=>{const u=typeof i?.dataUrl=="string"?i.dataUrl:"";u&&t(d=>{const l={...d.byOrigin,[a]:u},f=Object.keys(l);if(f.length<=vl)return{byOrigin:l};for(const m of f.slice(0,f.length-vl))delete l[m];return{byOrigin:l}})}).catch(()=>{}).finally(()=>{Qo.delete(a)}))}})),mi=t=>t,ka=t=>{const e=mi(t).type;return typeof e=="string"?e:""},Gv=t=>{const e=mi(t).tool;return typeof e=="string"?e:""},Zv=t=>{const e=mi(t).text;return typeof e=="string"?e:""},Xv=t=>{const e=ka(t);return e==="tool"?Gv(t).trim().toLowerCase()||"tool":e||"unknown"},Yv=t=>{if(t.length===0)return"";const e=[];for(const s of t){const r=Xv(s);e.includes(r)||e.push(r)}return e.join(" + ")},Jv=t=>t.replace(/\s+/g," ").trim(),Qv=t=>{for(const s of t)if(ka(s)==="text"){const r=Jv(Zv(s));if(r.length===0)continue;return r}const e=t.filter(s=>ka(s)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},eS=(t,e,s)=>`${s(t)} / ${s(e)}`,tS=t=>{if(t==="12h")return true;if(t==="24h")return false},sS=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const s=tS(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:s===false?"2-digit":"numeric",minute:"2-digit",...s===void 0?{}:{hour12:s}})},nS=(t,{windowTokens:e,compacted:s=false})=>{const r=s?0:e,o=Number.isFinite(r)&&r>0?r:0,a=t.user+t.assistant+t.tool+t.other,i=Math.max(o,a);return{user:t.user,assistant:t.assistant,tool:t.tool,other:i-a,total:i}},ja={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},lo={user:0,assistant:0,tool:0,other:0},Ws=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,fu=t=>{const e=t.info.tokens,s=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof s=="number")return{...ja,total:Ws(s)};if(!s||typeof s!="object")return ja;const r=s,o=Ws(r.input),a=Ws(r.output),i=Ws(r.reasoning),u=Ws(r.cache?.read),d=Ws(r.cache?.write),l=Ws(r.total);return{input:o,output:a,reasoning:i,cacheRead:u,cacheWrite:d,total:l>0?l:o+a+i+u+d}},rS=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},xs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,s)=>e+xs(s),0):t&&typeof t=="object"?Object.values(t).reduce((e,s)=>e+xs(s),0):0,oS=(t,e)=>{const s=t,r=typeof s.type=="string"?s.type:"";if(r==="reasoning")return{...lo,assistant:xs(s.text)+xs(s.content)};const o=rS(s.text,s.content,s.value,s.source?.value,s.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:xs(s.input)+xs(s.output)+xs(s.error)+xs(s.call?.input)+xs(s.call?.output)+xs(s.call?.error)+xs(s.raw)+Math.round(xs(s.metadata)*.25)+Math.round(xs(s.state)*.1)+Math.round((kf(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}},pu=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),aS=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",Sl=new WeakMap,iS=t=>{const e=Sl.get(t);if(e)return e;const s=aS(t);let r={...lo};for(const o of t.parts)r=pu(r,oS(o,s));return Sl.set(t,r),r},lS=(t,e)=>{if(t.length===0)return{...lo};const s=t.reduce((r,o)=>pu(r,iS(o)),{...lo});return s.user+=e.length,{user:Math.ceil(s.user/4),assistant:Math.ceil(s.assistant/4),tool:Math.ceil(s.tool/4),other:Math.ceil(s.other/4)}},xn=t=>t.toLocaleString(yd()),cS=(t,e)=>!t||!Number.isFinite(t)?"-":Mg(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),dS=(t,e,s)=>{const r=t.find(a=>a.id===e),o=r?.models?.find(a=>a.id===s);return{providerName:r?.name||e||"-",modelName:o?.name||s||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},kl=t=>{const e=qe.c(21),{title:s,figures:r}=t,{t:o}=gt();let a,i,u,d;if(e[0]!==r?.cacheHitPercent||e[1]!==r?.cacheRead||e[2]!==r?.cacheWrite||e[3]!==r?.output||e[4]!==r?.prompt||e[5]!==r?.reasoning||e[6]!==o||e[7]!==s){const m=[{label:o("contextSidebar.tokens.input"),value:r?.prompt??null,format:"count"},{label:o("contextSidebar.tokens.output"),value:r?.output??null,format:"count"},{label:o("contextSidebar.tokens.reasoning"),value:r?.reasoning??null,format:"count"},{label:o("contextSidebar.tokens.cacheRead"),value:r?.cacheRead??null,format:"count"},{label:o("contextSidebar.tokens.cacheWrite"),value:r?.cacheWrite??null,format:"count"},{label:o("contextSidebar.tokens.cacheHit"),value:r?.cacheHitPercent??null,format:"percent"}];u="mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",e[12]!==s?(d=n.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:s}),e[12]=s,e[13]=d):d=e[13],a="grid grid-cols-3 gap-x-4 gap-y-2.5",i=m.map(pS),e[0]=r?.cacheHitPercent,e[1]=r?.cacheRead,e[2]=r?.cacheWrite,e[3]=r?.output,e[4]=r?.prompt,e[5]=r?.reasoning,e[6]=o,e[7]=s,e[8]=a,e[9]=i,e[10]=u,e[11]=d}else a=e[8],i=e[9],u=e[10],d=e[11];let l;e[14]!==a||e[15]!==i?(l=n.jsx("div",{className:a,children:i}),e[14]=a,e[15]=i,e[16]=l):l=e[16];let f;return e[17]!==u||e[18]!==d||e[19]!==l?(f=n.jsxs("div",{className:u,children:[d,l]}),e[17]=u,e[18]=d,e[19]=l,e[20]=f):f=e[20],f},uS=c.memo(function(e){const s=qe.c(54),{message:r,isExpanded:o,isCopied:a,timeFormatPreference:i,onToggle:u,onCopy:d}=e,{t:l}=gt(),f=r.info.role,m=f==="assistant",p=f==="user",h=r.info.time?.created??null;let x;s[0]!==r.parts?(x=Yv(r.parts),s[0]=r.parts,s[1]=x):x=s[1];const g=x;let v,y,C,S;if(s[2]!==m||s[3]!==p||s[4]!==r||s[5]!==h||s[6]!==g||s[7]!==i){const U=m?fu(r):null;let V;s[12]!==p||s[13]!==r.parts?(V=p?Qv(r.parts):"",s[12]=p,s[13]=r.parts,s[14]=V):V=s[14],S=V;let J;s[15]!==h||s[16]!==i?(J=sS(h,i),s[15]=h,s[16]=i,s[17]=J):J=s[17],y=J,v=g||"\u2014",C=U?eS(U.input,U.output,xn):"",s[2]=m,s[3]=p,s[4]=r,s[5]=h,s[6]=g,s[7]=i,s[8]=v,s[9]=y,s[10]=C,s[11]=S}else v=s[8],y=s[9],C=s[10],S=s[11];const N=C,F=f||"unknown",_=g?`${F}: ${g}`:F;let M;s[18]!==o||s[19]!==r.info||s[20]!==r.parts?(M=o?JSON.stringify({info:r.info,parts:r.parts},null,2):"",s[18]=o,s[19]=r.info,s[20]=r.parts,s[21]=M):M=s[21];const B=M;let T;s[22]!==r.info.id||s[23]!==u?(T=()=>u(r.info.id),s[22]=r.info.id,s[23]=u,s[24]=T):T=s[24];const I=m?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content";let b;s[25]!==I?(b={gridTemplateColumns:I},s[25]=I,s[26]=b):b=s[26];let w;s[27]!==v||s[28]!==N||s[29]!==m||s[30]!==p||s[31]!==_||s[32]!==S?(w=p?n.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[n.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",S]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:m?v:_}),m&&n.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:N})]}),s[27]=v,s[28]=N,s[29]=m,s[30]=p,s[31]=_,s[32]=S,s[33]=w):w=s[33];let j;s[34]!==y?(j=n.jsx("span",{className:"text-end text-muted-foreground",children:y}),s[34]=y,s[35]=j):j=s[35];let R;s[36]!==b||s[37]!==w||s[38]!==j?(R=n.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:b,children:[w,j]}),s[36]=b,s[37]=w,s[38]=j,s[39]=R):R=s[39];let L;s[40]!==o||s[41]!==T||s[42]!==R?(L=n.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-start hover:bg-[var(--interactive-hover)]","aria-expanded":o,onClick:T,children:R}),s[40]=o,s[41]=T,s[42]=R,s[43]=L):L=s[43];let E;s[44]!==a||s[45]!==o||s[46]!==B||s[47]!==r.info.id||s[48]!==d||s[49]!==l?(E=o&&n.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:n.jsxs(ps,{outerClassName:"max-h-[26rem] bg-[var(--surface-background)]",className:"group relative",disableHorizontal:true,children:[n.jsx("div",{className:"absolute top-1 inset-e-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:U=>{U.stopPropagation(),d(r.info.id,B)},"aria-label":l(a?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),children:a?n.jsx(ue,{name:"check",className:"size-3.5"}):n.jsx(ue,{name:"file-copy",className:"size-3.5"})})}),n.jsx(Dt,{sideOffset:6,children:l(a?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson")})]})}),n.jsx(Pg,{language:"json",code:B,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:true})]})}),s[44]=a,s[45]=o,s[46]=B,s[47]=r.info.id,s[48]=d,s[49]=l,s[50]=E):E=s[50];let D;return s[51]!==L||s[52]!==E?(D=n.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[L,E]}),s[51]=L,s[52]=E,s[53]=D):D=s[53],D}),fS=()=>{const t=qe.c(216),{t:e}=gt(),s=Rg(),r=K(mS);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={},t[0]=o):o=t[0];const[a,i]=c.useState(o),[u,d]=c.useState(null),l=c.useRef(null),f=it(hS),m=it(gS),p=Dg(m??void 0),h=_g(f??"",m??void 0),x=Ut(xS);let g;t[1]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null),i(bS),d(null)},t[1]=g):g=t[1];let v;t[2]!==m||t[3]!==f?(v=[m,f],t[2]=m,t[3]=f,t[4]=v):v=t[4],c.useEffect(g,v);let y,C;t[5]===Symbol.for("react.memo_cache_sentinel")?(y=()=>()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},C=[],t[5]=y,t[6]=C):(y=t[5],C=t[6]),c.useEffect(y,C);let S;t[7]===Symbol.for("react.memo_cache_sentinel")?(S=He=>{i(pt=>({...pt,[He]:pt[He]!==true}))},t[7]=S):S=t[7];const N=S;let F;t[8]===Symbol.for("react.memo_cache_sentinel")?(F=async(He,pt)=>{(await wo(pt)).ok?(d(He),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>{d(se=>se===He?null:se),l.current=null},2e3)):d(null)},t[8]=F):F=t[8];const _=F;let M,B,T,I,b,w,j,R,L,E,D,U,V,J;if(t[9]!==f||t[10]!==x||t[11]!==h||t[12]!==p||t[13]!==e){b=f?p.find(Wt=>Wt.id===f)??null:null,M=h.filter(wS);let He;t[28]!==h?(He=h.filter(yS),t[28]=h,t[29]=He):He=t[29],J=He;let pt;t[30]!==h?(pt=Qc(h.map(vS)),t[30]=h,t[31]=pt):pt=t[31];const q=pt,se=q?h[q.index]??null:null,De=q?.state==="compacted";D=se?fu(se):ja,T=Ag({input:D.input,cache:{read:D.cacheRead,write:D.cacheWrite}}),U=Number.isFinite(b?.cost)?Ws(b?.cost):M.reduce(SS,0);const we=se?.info??null,rt=x,ft=we?.providerID||"",nt=we?.modelID||"";let ut;t[32]!==rt||t[33]!==ft||t[34]!==nt?(ut=dS(rt,ft,nt),t[32]=rt,t[33]=ft,t[34]=nt,t[35]=ut):ut=t[35],R=ut,I=R.contextLimit,V=De?null:I&&I>0?Math.min(999,D.total/I*100):0;const Nt=[...h].reverse().find(kS),Et=Nt?.info.role==="system"?Nt.info.text:"",Ft=lS(h,Et);B=nS(Ft,{windowTokens:D.total,compacted:De}),w=h[0]?.info?.time?.created,j=h.length>0?h[h.length-1]?.info?.time?.created:null,L=b?.title||e("contextSidebar.session.untitled"),E=Og(b),t[9]=f,t[10]=x,t[11]=h,t[12]=p,t[13]=e,t[14]=M,t[15]=B,t[16]=T,t[17]=I,t[18]=b,t[19]=w,t[20]=j,t[21]=R,t[22]=L,t[23]=E,t[24]=D,t[25]=U,t[26]=V,t[27]=J}else M=t[14],B=t[15],T=t[16],I=t[17],b=t[18],w=t[19],j=t[20],R=t[21],L=t[22],E=t[23],D=t[24],U=t[25],V=t[26],J=t[27];const W=b?.time?.created??w??null,G=j??b?.time?.created??null;let le;t[36]!==M.length||t[37]!==B||t[38]!==T||t[39]!==I||t[40]!==R||t[41]!==h.length||t[42]!==G||t[43]!==L||t[44]!==E||t[45]!==W||t[46]!==D||t[47]!==U||t[48]!==V||t[49]!==J.length?(le={sessionTitle:L,sessionTotals:E,messagesCount:h.length,userMessagesCount:J.length,assistantMessagesCount:M.length,createdAt:W,lastActivityAt:G,providerModel:R,tokenBreakdown:D,usagePercent:V,cacheHitRate:T,totalAssistantCost:U,contextLimit:I,breakdown:B,breakdownTotal:B.total},t[36]=M.length,t[37]=B,t[38]=T,t[39]=I,t[40]=R,t[41]=h.length,t[42]=G,t[43]=L,t[44]=E,t[45]=W,t[46]=D,t[47]=U,t[48]=V,t[49]=J.length,t[50]=le):le=t[50];const $=le;if(!f){let He;t[51]!==e?(He=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=He):He=t[52];let pt;return t[53]!==He?(pt=n.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:He}),t[53]=He,t[54]=pt):pt=t[54],pt}let re;t[55]!==e?(re=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=re):re=t[56];let H;t[57]!==re||t[58]!==$.breakdown.user?(H={key:"user",label:re,value:$.breakdown.user,color:"var(--status-success)"},t[57]=re,t[58]=$.breakdown.user,t[59]=H):H=t[59];let P;t[60]!==e?(P=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=P):P=t[61];let ee;t[62]!==P||t[63]!==$.breakdown.assistant?(ee={key:"assistant",label:P,value:$.breakdown.assistant,color:"var(--primary-base)"},t[62]=P,t[63]=$.breakdown.assistant,t[64]=ee):ee=t[64];let oe;t[65]!==e?(oe=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=oe):oe=t[66];let de;t[67]!==oe||t[68]!==$.breakdown.tool?(de={key:"tool",label:oe,value:$.breakdown.tool,color:"var(--status-warning)"},t[67]=oe,t[68]=$.breakdown.tool,t[69]=de):de=t[69];let he;t[70]!==e?(he=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=he):he=t[71];let Z;t[72]!==he||t[73]!==$.breakdown.other?(Z={key:"other",label:he,value:$.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=he,t[73]=$.breakdown.other,t[74]=Z):Z=t[74];let ce;t[75]!==H||t[76]!==ee||t[77]!==de||t[78]!==Z?(ce=[H,ee,de,Z],t[75]=H,t[76]=ee,t[77]=de,t[78]=Z,t[79]=ce):ce=t[79];const ae=ce;let te;t[80]!==s||t[81]!==$.sessionTitle?(te=s?n.jsx(bd,{children:n.jsx("div",{className:"flex min-w-0 flex-1 items-center ps-1.5 pe-1",children:n.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-foreground",title:$.sessionTitle,children:$.sessionTitle})})}):null,t[80]=s,t[81]=$.sessionTitle,t[82]=te):te=t[82];let pe;t[83]!==s||t[84]!==$.sessionTitle?(pe=s?null:n.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:$.sessionTitle}),t[83]=s,t[84]=$.sessionTitle,t[85]=pe):pe=t[85];const Te=!s&&"mt-1";let Ae;t[86]!==Te?(Ae=Ye(Te,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground"),t[86]=Te,t[87]=Ae):Ae=t[87];let Pe;t[88]!==$.providerModel.modelName||t[89]!==$.providerModel.providerName?(Pe=n.jsxs("span",{children:[$.providerModel.providerName," / ",$.providerModel.modelName]}),t[88]=$.providerModel.modelName,t[89]=$.providerModel.providerName,t[90]=Pe):Pe=t[90];let ze;t[91]!==r||t[92]!==$.createdAt?(ze=$.createdAt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"\xB7"}),n.jsx("span",{children:cS($.createdAt,r)})]}),t[91]=r,t[92]=$.createdAt,t[93]=ze):ze=t[93];let Oe;t[94]!==Ae||t[95]!==Pe||t[96]!==ze?(Oe=n.jsxs("div",{className:Ae,children:[Pe,ze]}),t[94]=Ae,t[95]=Pe,t[96]=ze,t[97]=Oe):Oe=t[97];let me;t[98]!==pe||t[99]!==Oe?(me=n.jsxs("div",{className:"mb-6",children:[pe,Oe]}),t[98]=pe,t[99]=Oe,t[100]=me):me=t[100];let be;t[101]!==e?(be=e("contextSidebar.section.context"),t[101]=e,t[102]=be):be=t[102];let Ce;t[103]!==be?(Ce=n.jsx("span",{className:"typography-micro text-muted-foreground",children:be}),t[103]=be,t[104]=Ce):Ce=t[104];let $e;t[105]!==$.tokenBreakdown.total||t[106]!==$.usagePercent?($e=$.usagePercent===null?"\u2014":xn($.tokenBreakdown.total),t[105]=$.tokenBreakdown.total,t[106]=$.usagePercent,t[107]=$e):$e=t[107];let We;t[108]!==$.contextLimit?(We=$.contextLimit?` / ${xn($.contextLimit)}`:"",t[108]=$.contextLimit,t[109]=We):We=t[109];let _e;t[110]!==$e||t[111]!==We?(_e=n.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[$e,We]}),t[110]=$e,t[111]=We,t[112]=_e):_e=t[112];let Ue;t[113]!==Ce||t[114]!==_e?(Ue=n.jsxs("div",{className:"flex items-baseline justify-between",children:[Ce,_e]}),t[113]=Ce,t[114]=_e,t[115]=Ue):Ue=t[115];let Xe;t[116]!==$.usagePercent?(Xe=$.usagePercent!==null&&$.usagePercent>0&&n.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,$.usagePercent)}%`,backgroundColor:$.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[116]=$.usagePercent,t[117]=Xe):Xe=t[117];let Me;t[118]!==Xe?(Me=n.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Xe}),t[118]=Xe,t[119]=Me):Me=t[119];let ot;t[120]!==e||t[121]!==$.usagePercent?(ot=$.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:$.usagePercent.toFixed(1)}),t[120]=e,t[121]=$.usagePercent,t[122]=ot):ot=t[122];let ye;t[123]!==ot?(ye=n.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:ot}),t[123]=ot,t[124]=ye):ye=t[124];let Ve;t[125]!==Ue||t[126]!==Me||t[127]!==ye?(Ve=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Ue,Me,ye]}),t[125]=Ue,t[126]=Me,t[127]=ye,t[128]=Ve):Ve=t[128];let lt;t[129]!==e?(lt=e("contextSidebar.stats.messages"),t[129]=e,t[130]=lt):lt=t[130];let ct;t[131]!==$.messagesCount?(ct=xn($.messagesCount),t[131]=$.messagesCount,t[132]=ct):ct=t[132];let st;t[133]!==lt||t[134]!==ct?(st={label:lt,value:ct},t[133]=lt,t[134]=ct,t[135]=st):st=t[135];let k;t[136]!==e?(k=e("contextSidebar.stats.user"),t[136]=e,t[137]=k):k=t[137];let Y;t[138]!==$.userMessagesCount?(Y=xn($.userMessagesCount),t[138]=$.userMessagesCount,t[139]=Y):Y=t[139];let Ne;t[140]!==k||t[141]!==Y?(Ne={label:k,value:Y},t[140]=k,t[141]=Y,t[142]=Ne):Ne=t[142];let Re;t[143]!==e?(Re=e("contextSidebar.stats.assistant"),t[143]=e,t[144]=Re):Re=t[144];let Ie;t[145]!==$.assistantMessagesCount?(Ie=xn($.assistantMessagesCount),t[145]=$.assistantMessagesCount,t[146]=Ie):Ie=t[146];let Ee;t[147]!==Re||t[148]!==Ie?(Ee={label:Re,value:Ie},t[147]=Re,t[148]=Ie,t[149]=Ee):Ee=t[149];let Ge;t[150]!==e?(Ge=e("contextSidebar.stats.cost"),t[150]=e,t[151]=Ge):Ge=t[151];let Be;t[152]!==$.totalAssistantCost?(Be=Wd($.totalAssistantCost),t[152]=$.totalAssistantCost,t[153]=Be):Be=t[153];let Ze;t[154]!==Ge||t[155]!==Be?(Ze={label:Ge,value:Be},t[154]=Ge,t[155]=Be,t[156]=Ze):Ze=t[156];let et;t[157]!==st||t[158]!==Ne||t[159]!==Ee||t[160]!==Ze?(et=[st,Ne,Ee,Ze],t[157]=st,t[158]=Ne,t[159]=Ee,t[160]=Ze,t[161]=et):et=t[161];const wt=et;let Qe;t[162]!==wt?(Qe=n.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:wt.map(jS)}),t[162]=wt,t[163]=Qe):Qe=t[163];let dt;t[164]!==e?(dt=e("contextSidebar.section.sessionTotals"),t[164]=e,t[165]=dt):dt=t[165];let at;t[166]!==dt||t[167]!==$.sessionTotals?(at=n.jsx(kl,{title:dt,figures:$.sessionTotals}),t[166]=dt,t[167]=$.sessionTotals,t[168]=at):at=t[168];let z;t[169]!==e?(z=e("contextSidebar.section.lastAssistantMessage"),t[169]=e,t[170]=z):z=t[170];const fe=$.tokenBreakdown.input+$.tokenBreakdown.cacheRead+$.tokenBreakdown.cacheWrite,ke=$.cacheHitRate.hasInput?$.cacheHitRate.percent:null;let ie;t[171]!==fe||t[172]!==ke||t[173]!==$.tokenBreakdown?(ie={...$.tokenBreakdown,prompt:fe,cacheHitPercent:ke},t[171]=fe,t[172]=ke,t[173]=$.tokenBreakdown,t[174]=ie):ie=t[174];let xe;t[175]!==z||t[176]!==ie?(xe=n.jsx(kl,{title:z,figures:ie}),t[175]=z,t[176]=ie,t[177]=xe):xe=t[177];let Le;t[178]!==ae||t[179]!==$.breakdownTotal?(Le=n.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:ae.map(He=>He.value<=0||$.breakdownTotal<=0?null:n.jsx("div",{style:{width:`${He.value/$.breakdownTotal*100}%`,backgroundColor:He.color}},He.key))}),t[178]=ae,t[179]=$.breakdownTotal,t[180]=Le):Le=t[180];let Ke;t[181]!==ae||t[182]!==$.breakdownTotal?(Ke=n.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:ae.map(He=>{const pt=$.breakdownTotal>0?He.value/$.breakdownTotal*100:0;return n.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:He.color}}),n.jsxs("span",{className:"typography-micro text-muted-foreground",children:[He.label," ",n.jsxs("span",{className:"tabular-nums",children:[pt.toFixed(0),"%"]})]})]},He.key)})}),t[181]=ae,t[182]=$.breakdownTotal,t[183]=Ke):Ke=t[183];let ve;t[184]!==Le||t[185]!==Ke?(ve=n.jsxs("div",{className:"mb-6",children:[Le,Ke]}),t[184]=Le,t[185]=Ke,t[186]=ve):ve=t[186];let je;t[187]!==e?(je=e("contextSidebar.section.rawMessages"),t[187]=e,t[188]=je):je=t[188];let vt;t[189]!==je?(vt=n.jsx("div",{className:"typography-micro text-muted-foreground",children:je}),t[189]=je,t[190]=vt):vt=t[190];let ne;if(t[191]!==u||t[192]!==a||t[193]!==h||t[194]!==r){let He;t[196]!==u||t[197]!==a||t[198]!==r?(He=pt=>n.jsx(uS,{message:pt,isExpanded:a[pt.info.id]===true,isCopied:u===pt.info.id,timeFormatPreference:r,onToggle:N,onCopy:_},pt.info.id),t[196]=u,t[197]=a,t[198]=r,t[199]=He):He=t[199],ne=[...h].reverse().map(He),t[191]=u,t[192]=a,t[193]=h,t[194]=r,t[195]=ne}else ne=t[195];let Je;t[200]!==ne?(Je=n.jsx("div",{className:"mt-2.5 space-y-1",children:ne}),t[200]=ne,t[201]=Je):Je=t[201];let kt;t[202]!==vt||t[203]!==Je?(kt=n.jsxs("div",{children:[vt,Je]}),t[202]=vt,t[203]=Je,t[204]=kt):kt=t[204];let bt;t[205]!==me||t[206]!==Ve||t[207]!==Qe||t[208]!==at||t[209]!==xe||t[210]!==ve||t[211]!==kt?(bt=n.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[me,Ve,Qe,at,xe,ve,kt]}),t[205]=me,t[206]=Ve,t[207]=Qe,t[208]=at,t[209]=xe,t[210]=ve,t[211]=kt,t[212]=bt):bt=t[212];let _t;return t[213]!==te||t[214]!==bt?(_t=n.jsxs(ps,{outerClassName:"h-full",className:"bg-background",children:[te,bt]}),t[213]=te,t[214]=bt,t[215]=_t):_t=t[215],_t};function pS(t){return n.jsxs("div",{children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),n.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value===null?"\u2014":t.format==="percent"?`${t.value.toFixed(1)}%`:xn(t.value)})]},t.label)}function mS(t){return t.timeFormatPreference}function hS(t){return t.currentSessionId}function gS(t){return t.currentSessionDirectory}function xS(t){return t.providers}function bS(t){return Object.keys(t).length>0?{}:t}function wS(t){return t.info.role==="assistant"}function yS(t){return t.info.role==="user"}function vS(t){return t.info}function SS(t,e){const s=Ws(e.info.cost);return t+s}function kS(t){return t.info.role==="system"}function jS(t){return n.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),n.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}const Gr=(t,e)=>{const[s,r]=c.useState(null),o=t?.id??null;return e&&s!==o&&r(o),e||s===null||s===o?t:null},TS=280,CS=.28,ES=240,IS=.35,NS=(t,e,s=null)=>{const r=t.left+t.width,o=e.left+e.width,a=e.top+e.height,i=s?s.top:a-Math.min(ES,e.height*IS),u=Math.min(TS,t.width*CS,e.width/4),d=e.left-t.left>=1,l=r-o>=1,f=Math.max(0,i-t.top),m=d?e.left:t.left+u,p=l?o:r-u;return{left:{left:t.left,top:t.top,width:m-t.left,height:d?t.height:f},right:{left:p,top:t.top,width:r-p,height:l?t.height:f},bottom:{left:e.left,top:i,width:e.width,height:Math.max(0,a-i)}}},ea=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,PS=(t,e)=>ea(t.bottom,e)?"bottom":ea(t.left,e)?"left":ea(t.right,e)?"right":null,Gs=Io(()=>({drag:null,hovered:null})),Zr=t=>{if(!t)return null;const{left:e,top:s,width:r,height:o}=t.getBoundingClientRect();return r>0&&o>0?{left:e,top:s,width:r,height:o}:null},ta=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),sa=t=>Zr(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),mu=t=>{const e=Zr(document.querySelector("[data-workspace-row]")),s=Zr(document.querySelector("[data-workspace-chat]"));if(!e||!s)return false;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=NS(e,s,Zr(r)),a={left:sa("left")??ta(o.left),right:sa("right")??ta(o.right),bottom:sa("bottom")??ta(o.bottom)};return Gs.setState({drag:{...t,targets:o,frames:a},hovered:null}),true},hu=t=>{const{drag:e,hovered:s}=Gs.getState();if(!e)return;const r=PS(e.targets,t);r!==s&&Gs.setState({hovered:r})},Ta=()=>{Gs.getState().drag&&Gs.setState({drag:null,hovered:null})},gu=t=>{const{drag:e,hovered:s}=Gs.getState();if(Gs.setState({drag:null,hovered:null}),!e||!s)return false;const r=K.getState();s!==e.from&&r.moveContextSurfaceToZone(e.mode,s);const o=t?ds(t):"";if(o){const a=K.getState();za(a.contextPanelByDirectory[o],a.contextSurfaceZones).has(e.mode)||a.openContextSurface(o,e.mode)}return true},hi=(t,e)=>{let s=false;const r=a=>{const i={x:a.clientX,y:a.clientY};e(i)?(s||(s=mu(t)),s&&hu(i)):s&&(Ta(),s=false)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:a=>(o(),s?(gu(a),true):false),cancel:()=>{o(),s&&Ta()}}},jl={left:null,right:null,bottom:null},yr=Io(()=>({body:jl,headerSlot:jl})),xu=(t,e,s)=>{const r=yr.getState()[t];r[e]!==s&&yr.setState({[t]:{...r,[e]:s}})},RS=(t,e)=>xu("body",t,e),DS=(t,e)=>xu("headerSlot",t,e),rr=t=>{const e=c.useRef(t);e.current=t;const[s,r]=c.useState(t),o=c.useCallback(()=>r(e.current),[]);return c.useLayoutEffect(()=>{hr(o)},[t,o]),c.useEffect(()=>()=>ai(o),[o]),s},na=t=>{const e=rr(t);return t||e},_S=Tr(()=>Vt(()=>import("./GitView-CJl97ZjN.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,207,208,209,210,211])).then(t=>({default:t.GitView}))),gi=320,bu=320,AS=24,OS=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Tl=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(gi,Math.round(t))):Va,MS=t=>t===null?Number.POSITIVE_INFINITY:Math.max(gi,t-bu),Cl=(t,e)=>{if(!t)return"";const s=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&s.startsWith(r+"/")?s.slice(r.length+1):s},Xr=(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"):t==="pages"?e("contextPanel.mode.pages"):wn(t)?cr.getState().guests.find(r=>r.id===er(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),FS=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const s=e.split("/").filter(Boolean);return s.length===0?e:s[s.length-1]||null},LS=(t,e,s)=>{if(t.mode==="chat"){const r=No(t.dedupeKey);if(r){const a=e.get(r)?.trim();if(a)return a}const o=t.sessionTitleFallback?.trim();return o||s("contextPanel.mode.chat")}return t.mode==="browser"?xo(t.targetPath??"")||t.label||s("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?FS(t.targetPath)||s("contextPanel.mode.files"):t.mode==="diff"?s("contextPanel.mode.diff"):Xr(t.mode,s)},$S=t=>{const e=qe.c(8),{mode:s}=t,r=ii();let o;if(e[0]!==s||e[1]!==r){let l;e[3]!==s?(l=f=>f.mode===s,e[3]=s,e[4]=l):l=e[4],o=r.find(l),e[0]=s,e[1]=r,e[2]=o}else o=e[2];const a=o,i=a?.icon??Hg,u=a?.iconSrc;let d;return e[5]!==i||e[6]!==u?(d=n.jsx(li,{icon:i,iconSrc:u,className:"h-3.5 w-3.5"}),e[5]=i,e[6]=u,e[7]=d):d=e[7],d},BS=t=>{const e=qe.c(2),{sessionId:s}=t,r=Zc(s);let o;return e[0]!==r?(o=r?n.jsx(Yc,{state:r,className:"h-3.5 w-3.5"}):n.jsx(ue,{name:"chat-4",className:"h-3.5 w-3.5"}),e[0]=r,e[1]=o):o=e[1],o},zS=[],WS=(t,e,s)=>{const r=s(t);if(r)return Kg(r.provider,r.identifier);const o=e.match(t);return o?qg(o.kind,o):null},VS=t=>{switch(t?.type){case"pull":return t.state?Vo({kind:"pull",state:t.state.state,draft:t.state.draft},t.state):null;case"issue":return t.state?Vo({kind:"issue",state:t.state.state},null):null;case"discussion":return t.state?Vo({kind:"discussion",state:t.state.state,answered:t.state.answered},null):null;case"work-item":return t.state?Gg(t.state.state.category):null;default:return null}},US=t=>{const e=qe.c(23),{url:s,active:r,visible:o}=t,a=To(),i=gd();let u;e[0]!==i||e[1]!==s||e[2]!==a?(u=s?WS(s,a,i):null,e[0]=i,e[1]=s,e[2]=a,e[3]=u):u=e[3];const d=u;let l;e[4]!==d?(l=d?[d]:[],e[4]=d,e[5]=l):l=e[5];const f=l;ko(o?f:zS);const m=Wg(f)[0]??null;let p;e[6]!==m?(p=VS(m),e[6]=m,e[7]=p):p=e[7];const h=p;let x,g;if(e[8]!==r||e[9]!==h||e[10]!==i||e[11]!==s||e[12]!==a){g=Symbol.for("react.early_return_sentinel");e:{const C=s?xd(s,a,i):null;if(C&&h){let S;e[15]!==r||e[16]!==h.color?(S=r?void 0:{color:h.color},e[15]=r,e[16]=h.color,e[17]=S):S=e[17];let N;e[18]!==h.icon||e[19]!==S?(N=n.jsx(ue,{name:h.icon,className:"h-3.5 w-3.5",style:S}),e[18]=h.icon,e[19]=S,e[20]=N):N=e[20],g=N;break e}x=C?C.source==="tracker"?Ug(C.provider).icon:Vg[C.kind]:"git-branch"}e[8]=r,e[9]=h,e[10]=i,e[11]=s,e[12]=a,e[13]=x,e[14]=g}else x=e[13],g=e[14];if(g!==Symbol.for("react.early_return_sentinel"))return g;const v=x;let y;return e[21]!==v?(y=n.jsx(ue,{name:v,className:"h-3.5 w-3.5"}),e[21]=v,e[22]=y):y=e[22],y},El=(t,e={},s=true,r=true)=>{if(t.mode==="file")return t.targetPath?n.jsx(Co,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return n.jsx(Wp,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return n.jsx(ue,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return n.jsx(ue,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return n.jsx(US,{url:t.targetPath,active:s,visible:r});if(t.mode==="notes")return n.jsx(ue,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return n.jsx(ue,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return n.jsx(ue,{name:"pie-chart",className:"h-3.5 w-3.5"});if(t.mode==="workflows")return n.jsx(ue,{name:"flow-chart",className:"h-3.5 w-3.5"});if(t.mode==="pages")return n.jsx(ue,{name:"pages",className:"h-3.5 w-3.5"});if(t.mode==="chat"){const o=No(t.dedupeKey);return o?n.jsx(BS,{sessionId:o}):n.jsx(ue,{name:"chat-4",className:"h-3.5 w-3.5"})}if(wn(t.mode))return n.jsx($S,{mode:t.mode});if(t.mode==="browser"){const o=HS(t.targetPath??"",e);return o?n.jsx("img",{src:o,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):n.jsx(ue,{name:"global",className:"h-3.5 w-3.5"})}},HS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},KS=t=>{const e=Sd(),s=c.useRef(io),r=c.useRef(t);r.current=t;const o=t.length>0;return c.useSyncExternalStore(c.useCallback(a=>o?e.subscribeAllSelected(i=>i.session,a):()=>{},[e,o]),c.useCallback(()=>{const a=Array.from(e.children.values(),u=>u.getState()),i=av(a,r.current);return rv(s.current,i)?s.current:(s.current=i,i)},[e]),()=>io)},qS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,GS=8,ZS='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',XS=t=>t==="context"||t==="git"||t==="pr"||t==="notes"||t==="workflows",wu=320,xi=160,Ca=200,YS={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"}},Il=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(xi,Math.round(t))):wu,JS=t=>t===null?Number.POSITIVE_INFINITY:Math.max(xi,t-Ca),ra=({zone:t="right"})=>{const e=YS[t],s=vo(),r=e.axis==="y",{t:o,direction:a}=gt(),i=a==="rtl",u=Zs()??"",d=Tc(Fg(u||null)),l=c.useCallback((Q,tt)=>o(Us(Q,d),tt),[d,o]),f=c.useMemo(()=>OS(u),[u]),m=K(Q=>f?Q.contextPanelByDirectory[f]:void 0),p=K(Q=>Q.contextSurfaceZones),h=K(Q=>Q.shortcutOverrides),x=K(Q=>Q.closeContextZone),g=K(Q=>Q.closeContextPanelTab),v=K(Q=>Q.pinContextPanelTab),y=K(Q=>Q.toggleContextPanelExpanded),C=K(Q=>Q.setContextZoneSize),S=K(Q=>Q.setContextZoneExpandedChatSize),N=K(Q=>Q.setActiveContextPanelTab),F=K(Q=>Q.reorderContextPanelTabs),_=K(Q=>Q.contextEditorTreeVisible),M=K(Q=>Q.contextEditorTreeWidth),B=K(Q=>Q.setContextEditorTreeWidth),T=K(Q=>Q.toggleContextEditorTree),I=K(Q=>Q.contextEditorVisible),b=K(Q=>Q.toggleContextEditor),w=K(Q=>Q.fileTreeSide),j=K(Q=>Q.openNewContextBrowserTab),R=uu(Q=>Q.byOrigin),[L,E]=c.useState(null),D=c.useCallback(Q=>{E(Q),DS(t,Q)},[t]),U=c.useCallback(Q=>{RS(t,Q)},[t]),V=c.useMemo(()=>m?.tabs??[],[m?.tabs]),J=m?to(m,p,t):null,W=m?lr(m,t):jf,G=Kr(Q=>Q.workStatusReserved),le=Kr(Q=>Q.workStatusBesidePanel),$=Kr(Q=>Q.chatCovered),re=t==="bottom"&&$,H=!!(W.isOpen&&J)&&!re,P=Gr(J,H),ee=c.useMemo(()=>V.some(Q=>Q.mode==="file"&&Q.targetPath),[V]),oe=ee&&(I||!_),de=!r&&P?.mode==="file"&&!oe,he=!!(H&&W.expanded&&!de),Z=K(Q=>Q.contextZoneSizes[t]),ce=de?M:r?Il(Z??wu,Number.POSITIVE_INFINITY):Tl(Z??Va,Number.POSITIVE_INFINITY),ae=c.useCallback((Q,tt)=>r?Il(Q,JS(tt)):Tl(Q,MS(tt)),[r]),te=r?Ca:bu,pe=K(Q=>r?0:Q.sidebarWidth),Te=K(Q=>Q.contextZoneExpandedChatSizes[t]),Ae=Math.max(te,Te??(r?Ca:pe)),Pe=t==="right"?"left":t==="left"?"right":null,ze=K(Q=>{if(!Pe||!f)return 0;const tt=Q.contextPanelByDirectory[f],St=tt&&Qn(tt,Q.contextSurfaceZones,Pe)?to(tt,Q.contextSurfaceZones,Pe):null;return tt&&St?Tf(tt,St,Pe,Q):0}),Oe=Pe==="right"&&G&&!$&&ze===0?In:ze,me=t==="right"&&G&&!$,be=me&&le&&!he,[Ce,$e]=c.useState(null),We=c.useRef(null),_e=c.useRef(Oe);_e.current=Oe;const Ue=c.useRef(H);Ue.current=H;const Xe=c.useRef(()=>false);Xe.current=Q=>he||!de&&Q-_e.current-te<ce;const Me=c.useCallback(()=>{let Q=We.current;Q!==null&&!r&&Ue.current&&(Q+=Lg()),$e(Q!==null&&Xe.current(Q)?Q:null)},[r]),ot=Ce!==null?Ce-Oe:null,ye=de?ce:he&&ot!==null?Math.max(r?xi:gi,ot-Ae):ae(ce,ot),Ve=H&&P?.mode==="chat",lt=c.useMemo(()=>{const Q=[];if(!Ve)return Q;for(const tt of V){if(tt.mode!=="chat")continue;const St=No(tt.dedupeKey);St&&!Q.includes(St)&&Q.push(St)}return Q},[Ve,V]),ct=KS(lt),[st,k]=c.useState(false),Y=c.useRef(0),Ne=c.useRef(ye),Re=c.useRef(null),Ie=c.useRef(null),Ee=c.useRef(null),Ge=c.useRef(null),Be=c.useRef(false);c.useLayoutEffect(()=>{const Q=r?Ee.current?.parentElement:Ee.current?.closest("[data-workspace-row]");if(!Q||typeof ResizeObserver>"u")return;const tt=new ResizeObserver(St=>{const Tt=St[St.length-1]?.contentRect,Bt=r?Tt?.height:Tt?.width;We.current=Bt?Math.round(Bt):null,hr(Me)});return tt.observe(Q),We.current=(r?Q.clientHeight:Q.clientWidth)||null,Me(),()=>{tt.disconnect(),ai(Me)}},[Me,r]);const Ze=!r&&H&&(he||Ce!==null),et=K(Q=>Ze&&Q.isSidebarOpen);c.useLayoutEffect(()=>{Me()},[Me,ce,he,H,Oe,et]),c.useEffect(()=>{if(!H||Be.current){Be.current=H;return}const Q=window.requestAnimationFrame(()=>{Ge.current?.focus({preventScroll:true})});return Be.current=true,()=>window.cancelAnimationFrame(Q)},[H]);const wt=c.useRef(null),Qe=c.useRef(null),dt=c.useRef(null),at=c.useRef(null),z=c.useRef(false),fe=c.useRef(null),ke=c.useRef(false),ie=c.useCallback(Q=>{const tt=Ee.current,St=fe.current;if(!tt||!St)return;const Tt=r?"height":"width";tt.style[Tt]=ke.current?`${Q+In}px`:`min(${Q}px, 100%)`,St.style[Tt]=`calc(${Q}px - ${e.gutterSize})`},[e.gutterSize,r]),xe=c.useCallback(()=>{Qe.current=null;const Q=Re.current;Q!==null&&ie(Q)},[ie]);c.useEffect(()=>()=>{Qe.current!==null&&cancelAnimationFrame(Qe.current),dt.current?.(),dt.current=null,at.current?.remove(),at.current=null},[]);const Le=c.useCallback(Q=>{const tt=wt.current,St=de?da(Q):ae(Q,tt);return tt===null?St:Math.min(St,Math.max(1,tt))},[ae,de]),Ke=c.useCallback(Q=>{if(!H||!f)return;Ie.current=Q.pointerId,k(true),Y.current=r?Q.clientY:Q.clientX,Ne.current=ye,Re.current=ye;const tt=r?Ee.current?.parentElement?.clientHeight:(Ee.current?.closest("[data-workspace-row]")?.clientWidth??0)-_e.current-(be?In:0);wt.current=tt&&tt>0?tt:null,at.current?.remove();const St=document.createElement("div");St.style.cssText=`position:fixed;inset:0;z-index:2147483647;cursor:${r?"row-resize":"col-resize"}`,document.body.appendChild(St),at.current=St,dt.current?.(),dt.current=nd(r?"height":"width"),Q.preventDefault()},[be,f,H,r,ye]),ve=c.useCallback(()=>{const Q=Le(Re.current??ye),tt=wt.current;Qe.current!==null&&(cancelAnimationFrame(Qe.current),Qe.current=null);const St=Ee.current,Tt=fe.current;if(St&&Tt){const Bt=r?"height":"width";St.style.setProperty(e.sizeVariable,`${Q}px`),St.style[Bt]=jt.current,Tt.style[Bt]=$t.current}Re.current=null,wt.current=null,z.current=true,at.current?.remove(),at.current=null,de?B(Q):he?tt!==null&&S(t,tt-Q):C(t,Q),k(false),Ie.current=null,dt.current?.(),dt.current=null},[Le,e.sizeVariable,he,de,r,B,S,C,ye,t]);c.useEffect(()=>{if(!st)return;const Q=Tt=>{if(Ie.current!==Tt.pointerId)return;const Bt=r?Tt.clientY:Tt.clientX,Zt=t==="left"?Bt-Y.current:Y.current-Bt,js=!r&&i?-Zt:Zt,us=Le(Ne.current+js);Re.current!==us&&(Re.current=us,Qe.current===null&&(Qe.current=requestAnimationFrame(xe)))},tt=Tt=>{Ie.current===Tt.pointerId&&ve()},St=()=>{ve()};return window.addEventListener("pointermove",Q),window.addEventListener("pointerup",tt),window.addEventListener("pointercancel",tt),window.addEventListener("blur",St),()=>{window.removeEventListener("pointermove",Q),window.removeEventListener("pointerup",tt),window.removeEventListener("pointercancel",tt),window.removeEventListener("blur",St)}},[xe,Le,ve,st,i,r,t]),c.useEffect(()=>{st||(Re.current=null,at.current?.remove(),at.current=null)},[st]);const je=c.useCallback(()=>{f&&x(f,t)},[x,f,t]),vt=c.useCallback(()=>{f&&y(f,t)},[f,y,t]),ne=P?.mode==="file"||P?.mode==="chat"||P?.mode==="browser"||P?.mode==="pr"||P?.mode==="pages",Je=c.useMemo(()=>{if(!P)return[];const Q=V.filter(tt=>tt.mode===P.mode);return P.mode==="pr"?[...Q.filter(Or),...Q.filter(tt=>!Or(tt))]:Q},[P,V]),kt=jo(P?.mode==="pr"&&f?f:null)?.current??null,bt=P?.id,_t=c.useMemo(()=>{const Q=$g(Je.filter(tt=>tt.mode==="file").map(tt=>Cl(tt.targetPath,u)));return Je.map(tt=>{const St=Or(tt),Tt=St?kt||o("contextPanel.tracker.branchTab"):LS(tt,ct,l),Bt=qS(Tt,AS),Zt=Cl(tt.targetPath,u);return{id:tt.id,label:Bt,labelFolder:tt.mode==="file"?Q.get(Zt):void 0,icon:El(tt,R,tt.id===bt,H),title:Zt?`${Tt}: ${Zt}`:Tt,closeLabel:o("contextPanel.tab.closeTabAria",{label:Bt}),closeShortcut:tt.id===bt&&As()?bs("mod+w",""):void 0,closable:!St,preview:tt.preview}})},[Je,bt,u,R,H,ct,o,l,kt]),He=P?.mode==="context"?n.jsx(bn,{value:L,children:n.jsx(fS,{})}):P?.mode==="git"?n.jsx(c.Suspense,{fallback:null,children:n.jsx(bn,{value:L,children:n.jsx(_S,{isActive:H})})}):P?.mode==="pr"?P.targetPath?n.jsx(qy,{url:P.targetPath,directory:P.targetDirectory??u,panelDirectory:u,tabId:P.id,foreign:!!P.targetDirectory,visible:H},P.id):n.jsx(Fy,{}):P?.mode==="notes"?n.jsx(bn,{value:L,children:n.jsx(zp,{visible:H})}):P?.mode==="workflows"?n.jsx(bn,{value:L,children:n.jsx(Bv,{directory:u||null})}):P?.mode==="pages"&&!P.targetPath?n.jsx(Xw,{}):null,pt=P?.mode==="file",q=pt&&!!P?.targetPath&&oe,se=H&&P&&ne&&!q&&!Or(P)?P.id:null;c.useEffect(()=>{if(!(!f||!se))return Ka(()=>g(f,se),Ee)},[g,f,se]);const De=K(Q=>Q.closeContextPanelTabs),we=c.useCallback(Q=>{if(!f)return null;const{id:tt,index:St,allIds:Tt,close:Bt}=Q,Zt=()=>De(f,Tt.filter(Ys=>Ys!==tt)),js=Tt.slice(0,St),us=Tt.slice(St+1),Ps=()=>De(f,i?us:js),Rs=()=>De(f,i?js:us),hs=()=>De(f,Tt),ls=Tt.length>1,ws=i?St===Tt.length-1:St===0,cn=i?St===0:St===Tt.length-1;return n.jsxs(n.Fragment,{children:[n.jsxs(Ts,{onClick:Bt,children:[n.jsx(ue,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),n.jsx(Dn,{}),n.jsxs(Ts,{onClick:Zt,disabled:!ls,children:[n.jsx(ue,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),n.jsxs(Ts,{onClick:Ps,disabled:ws,children:[n.jsx(ue,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),n.jsxs(Ts,{onClick:Rs,disabled:cn,children:[n.jsx(ue,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),n.jsx(Dn,{}),n.jsxs(Ts,{onClick:hs,disabled:!ls,children:[n.jsx(ue,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),P?n.jsxs(n.Fragment,{children:[n.jsx(Dn,{}),n.jsx(Uc,{mode:P.mode})]}):null]})},[P,De,f,i,o]),rt=c.useCallback((Q,tt)=>{const St=V.find(Bt=>Bt.id===Q);if(!St)return null;const Tt=hi({mode:St.mode,label:Xr(St.mode,l),from:t},tt);return{finish:()=>Tt.finish(f),cancel:Tt.cancel}},[f,l,V,t]),[ft,nt]=c.useState(null),ut=c.useCallback(Q=>{if(!P||Q.button!==0||Q.pointerType==="touch"||Q.target instanceof Element&&Q.target.closest(ZS))return;const tt=P.mode,St=Xr(tt,l),Tt={x:Q.clientX,y:Q.clientY};let Bt=false;const Zt=Rs=>{const hs={x:Rs.clientX,y:Rs.clientY};!Bt&&(Math.hypot(hs.x-Tt.x,hs.y-Tt.y)<GS||(Bt=mu({mode:tt,label:St,from:t}),!Bt))||hu(hs)},js=()=>{window.removeEventListener("pointermove",Zt),window.removeEventListener("pointerup",us),window.removeEventListener("pointercancel",Ps),window.removeEventListener("blur",Ps)},us=()=>{js(),Bt&&gu(f)},Ps=()=>{js(),Bt&&Ta()};window.addEventListener("pointermove",Zt),window.addEventListener("pointerup",us),window.addEventListener("pointercancel",Ps),window.addEventListener("blur",Ps)},[P,f,l,t]);c.useEffect(()=>{if(ft)return ft.addEventListener("pointerdown",ut),()=>ft.removeEventListener("pointerdown",ut)},[ut,ft]);const Nt=n.jsxs("header",{ref:nt,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[ne?n.jsx(Bg,{items:_t,activeId:P?.id??null,onSelect:Q=>{f&&N(f,Q)},onClose:Q=>{f&&g(f,Q)},onReorder:(Q,tt)=>{f&&F(f,Q,tt)},onDoubleClickTab:Q=>{f&&v(f,Q)},layoutMode:"scrollable",variant:"default",tabContextMenu:we,onTabDragOut:rt}):n.jsxs(n.Fragment,{children:[n.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:[P?El(P,R):null,n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:P?Xr(P.mode,l):null})]}),n.jsx("div",{ref:D,className:"flex min-w-0 flex-1 items-stretch ps-1.5 empty:hidden"})]}),n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 self-start px-1.5",children:[P?.mode==="browser"?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&j(f)},className:"h-7 w-7 p-0","aria-label":o("contextPanel.browser.newTab"),children:n.jsx(ue,{name:"add",className:"h-3.5 w-3.5"})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:o("contextPanel.browser.newTab")})]}):null,pt?["left","right"].map(Q=>{const tt=Q===w;if(!tt&&!ee)return null;const St=o(tt?"contextRail.editorTree.toggle":"contextRail.editor.toggle"),Tt=tt?_:oe,Bt=o(tt?Tt?"contextTooltips.panel.hideFileTree":"contextTooltips.panel.showFileTree":Tt?"contextTooltips.panel.hideFileEditor":"contextTooltips.panel.showFileEditor");return n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{type:"button",variant:"ghost",size:"sm",onClick:tt?T:b,className:"h-7 w-7 p-0","aria-label":St,"aria-pressed":Tt,children:n.jsx(ue,{name:Q==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:Bt})]},Q)}):null,de?null:n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{type:"button",variant:"ghost",size:"sm",onClick:vt,className:"h-7 w-7 p-0","aria-label":o(he?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:he?n.jsx(ue,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):n.jsx(ue,{name:"fullscreen",className:"h-3.5 w-3.5"})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:n.jsx(qs,{label:o(he?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),shortcut:bs(Es("toggle_context_panel_expanded",h),"")})})]}),n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{type:"button",variant:"ghost",size:"sm",onClick:je,className:"h-7 w-7 p-0","aria-label":o("contextPanel.actions.closePanel"),children:n.jsx(ue,{name:"close",className:"h-3.5 w-3.5"})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:o("contextPanel.actions.closePanel")})]})]})]}),Et=H?be?`calc(var(${e.sizeVariable}) + ${In}px)`:`min(var(${e.sizeVariable}), 100%)`:me?`${In}px`:"0px",Ft=be?`${In}px`:"0px";ke.current=be;const Wt=t==="bottom"&&Qn(m,p,"left"),is=t==="bottom"&&(G&&!$||Qn(m,p,"right")),Gt=`${H}|${he}|${me}|${H&&be}|${H?ce:""}`,ns=c.useRef(Gt),ms=c.useRef($),Ns=ms.current!==$;c.useLayoutEffect(()=>{ms.current=$},[$]),c.useLayoutEffect(()=>{if(ns.current===Gt)return;ns.current=Gt;const Q=z.current;!Ns&&!Q&&sd(s)},[Gt,Ns,s]),c.useLayoutEffect(()=>{z.current=false});const Fs=!Vr(H,rr(H),P?.mode),X={[e.sizeVariable]:`${ye}px`,...r?{height:Et,maxHeight:"100%"}:{width:Et,maxWidth:"100%"},transitionDuration:Ns||st?"0ms":`${s}ms`,transitionTimingFunction:Mn},mt=`calc(var(${e.sizeVariable}) - ${e.gutterSize})`,jt=c.useRef(Et);jt.current=Et;const $t=c.useRef(mt);return $t.current=mt,n.jsxs("aside",{ref:Ee,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":H?"true":"false","data-zone-size":ye,tabIndex:-1,className:Ye("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:X,children:[n.jsx("div",{ref:Ge,tabIndex:-1,className:"absolute size-0 overflow-hidden outline-none"}),t==="right"?n.jsx("div",{ref:zg,className:Ye("absolute inset-y-0 z-0 flex",be?"inset-s-0":"inset-e-0",$&&"invisible")}):null,H&&n.jsx("div",{className:e.handle,style:{marginInlineStart:Ft},onPointerDown:Ke,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{ref:fe,"data-zone-card":"",className:Ye("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(Wt?"ms-0":"ms-2"),t==="bottom"&&(is?"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]",!H&&"opacity-0",Fs&&"pointer-events-none select-none"),style:{...r?{height:mt,width:`calc(100% - ${(Wt?0:.5)+(is?0:.375)}rem)`}:{width:mt},...t==="right"?{marginInlineStart:`calc(0.5rem + ${Ft})`}:null,transitionDuration:st?"0ms":`${s}ms`,transitionTimingFunction:Mn},inert:Fs||void 0,children:n.jsxs(vd.Provider,{value:true,children:[Nt,n.jsx("div",{ref:U,className:"relative min-h-0 flex-1 overflow-hidden",children:P&&(XS(P.mode)||P.mode==="pages"&&!P.targetPath)?He:null})]})})]})},QS=Mt({port:as().int().positive(),url:It().min(1),command:It(),directory:It().min(1).optional()}),e0=t=>{const e=Mt({servers:Cn(Jd())}).safeParse(t);return e.success?e.data.servers.flatMap(s=>{const r=QS.safeParse(s);return r.success?[r.data]:[]}):null},t0=async(t,e)=>{try{const s=await Ms("/api/dev-servers",{signal:t,directory:e});if(!s.ok)return{kind:"unavailable"};const r=e0(await s.json());return r?{kind:"ready",servers:r}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},s0=async t=>{try{const e=await Ms("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const s=await e.json();if(!s||typeof s!="object")return null;const r=s.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},n0=t=>{try{const e=new URL(t),s=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(s)&&s>0?s:null}catch{return null}},r0=({announced:t,discovered:e})=>{const s=new Map;for(const r of t){const o=n0(r);o!==null&&!s.has(o)&&s.set(o,r)}return e?e.map(r=>{const o=s.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):[...s.entries()].map(([r,o])=>({url:o,port:r,announced:true})).sort((r,o)=>r.port-o.port)},o0=(t,e)=>e===t||e.startsWith(t.endsWith("/")?t:`${t}/`),Nl=(t,e)=>{if(!e)return null;let s=null;for(const r of t)o0(r.path,e)&&(!s||r.path.length>s.path.length)&&(s=r);return s},a0=t=>t.slice(t.lastIndexOf("/")+1)||t,i0=({candidates:t,folders:e,directory:s})=>{const r=e.flatMap(d=>{const l=ts(d.path),f=ts(d.projectPath);return l&&f?[{path:l,projectPath:f}]:[]}),o=ts(s),a=o?{path:o,projectPath:Nl(r,o)?.projectPath??o}:null,i=a?[...r,a]:r;return t.map(d=>{const l=ts(d.directory),f=Nl(i,l),m=d.announced?0:f&&a&&f.path===a.path?1:f&&a&&f.projectPath===a.projectPath?2:3;return{server:{...d,folderName:f?a0(f.path):null,outsideWork:l!==null&&f===null&&!d.announced},rank:m}}).sort((d,l)=>d.rank-l.rank||d.server.port-l.server.port).map(d=>d.server)},l0=t=>({sessionId:t.sessionId,directory:t.directory?ds(t.directory):null}),c0=2e3,d0=Mt({title:It(),settled:ss(),dialogs:Cn(Jd()).optional(),note:It().optional()}),u0=4e4,f0=50,or=400,fs=new Map,Os=new Map;let Ea=null,Ia=null;const vr=new Map;let Cs=null,rn=null,Yr=null,ar=null;const Vs=async t=>{try{const e=await Ms("/api/browser-control/claim",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t})});return e.ok?(await e.json())?.granted===true:false}catch{return false}},p0=async(t,e)=>{try{const s=await Ms("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});s.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${s.status}); the agent will see this action time out`)}catch(s){console.warn(`[browser-control] could not deliver the result for ${t}:`,s)}},yu=async(t,e=c0)=>{const s=Date.now()+e;for(;!fs.has(t)&&Date.now()<s;)await new Promise(r=>setTimeout(r,f0));return fs.get(t)??null},co=t=>fs.has(t)||Os.has(t),Bn=t=>fs.get(t)??Os.get(t)??null,Na=()=>[...fs.values(),...[...Os.values()].filter(t=>!fs.has(t.tabId))],bi=t=>{const e=Ia?Bn(Ia):null,s=e?.directory===Ea?e:null;if(!t.sessionId){if(s)return s.tabId;const a=Na().filter(d=>d.directory===Ea),i=a.filter(d=>fs.has(d.tabId)),u=i.length>0?i:a;return u.length>0?u[u.length-1].tabId:null}if(s?.ownerSessionId===t.sessionId)return s.tabId;const r=vr.get(t.sessionId);if(r&&Bn(r)?.ownerSessionId===t.sessionId)return r;const o=Na().filter(a=>a.ownerSessionId===t.sessionId);return o.length>0?o[o.length-1].tabId:s&&s.ownerSessionId===null&&(!t.directory||s.directory===t.directory)?s.tabId:null},m0=t=>{const e=bi(t);return e&&Bn(e)?.ownerSessionId===t.sessionId?e:null},h0=(t,e)=>{t.sessionId&&Bn(e)?.ownerSessionId===t.sessionId&&vr.set(t.sessionId,e)},vu=async t=>{const e=fs.get(t);if(e)return e;const s=Os.get(t);return s?(s.wake(),yu(t)):null},Su=t=>{const e=bi(t);return Na().filter(s=>!t.sessionId||!t.directory||s.ownerSessionId===t.sessionId||s.directory===t.directory).map(s=>{let r={title:"",url:""};try{r=s.describe()}catch{}const o=s.ownerSessionId===null?"user":s.ownerSessionId===t.sessionId?"you":"another session";return{id:s.tabId,title:r.title,url:r.url,owner:o,active:s.tabId===e}})},ku=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,ju=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.`,g0=t=>{const e=Su(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
  `)}`:"")},x0=()=>"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.",b0=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.`,w0=()=>"This browser.close did not come from a session, so there is no tab it opened to close. Nothing was closed.",Qt=(t,e)=>p0(t.requestId,t.action==="browser.open"&&e.ok?{...e,data:Object.assign({},e.data,{drivable:kd()})}:e),y0=async(t,e,s)=>{if(!e.sessionId){if(!await Vs(t.requestId))return;await Qt(t,{ok:false,error:w0()});return}const r=s??m0(e);if(r===null){if(await new Promise(i=>setTimeout(i,or)),!await Vs(t.requestId))return;await Qt(t,{ok:false,error:x0()});return}if(!co(r)){if(fs.size===0&&Os.size===0&&!rn)return;if(await new Promise(i=>setTimeout(i,or)),!co(r)){if(!await Vs(t.requestId))return;await Qt(t,{ok:false,error:ju(r)});return}}const o=Bn(r);if(!o||o.ownerSessionId!==e.sessionId){if(!await Vs(t.requestId))return;await Qt(t,{ok:false,error:b0(r)});return}if(!await Vs(t.requestId))return;if(!(rn?rn(o.directory,r):false)){await Qt(t,{ok:false,error:rn?`The browser tab ${r} could not be closed.`:"There is no browser here to close a tab in."});return}e.sessionId&&vr.get(e.sessionId)===r&&vr.delete(e.sessionId),await Qt(t,{ok:true,data:{closed:true,tabId:r}})},v0=async t=>{const e=t.action==="browser.open",s=t.action==="browser.close",r=l0(t.context),{tabId:o,...a}=t.parameters,i=o===void 0?null:String(o);if(s){await y0(t,r,i);return}if(i!==null){if(!co(i)){if(fs.size===0&&Os.size===0&&!Cs)return;if(await new Promise(l=>setTimeout(l,or)),co(i)){await Pl(t,r,i,a);return}if(!await Vs(t.requestId))return;await Qt(t,{ok:false,error:ju(i)});return}await Pl(t,r,i,a);return}const u=bi(r);if(!u&&!(e&&Cs)){if(!r.sessionId||(await new Promise(l=>setTimeout(l,or)),!await Vs(t.requestId)))return;await Qt(t,{ok:false,error:g0(r)});return}if(!(e&&Cs!==null)&&r.sessionId&&Bn(u)?.ownerSessionId!==r.sessionId&&await new Promise(l=>setTimeout(l,or)),!!await Vs(t.requestId))try{const l=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!l){await Qt(t,{ok:false,error:"url is required"});return}const f=Date.now(),m=e&&Cs?Cs(l,t.context):null;if(e&&!m&&!u){await Qt(t,{ok:false,error:"There is no browser here to open the page in."});return}if(m){r.sessionId&&vr.set(r.sessionId,m);const h=typeof t.parameters.viewport=="string"?t.parameters.viewport:"",x=!!h&&h!=="fill",g=kd();if(!x&&!g){await Qt(t,{ok:true,data:{url:l,opened:true,tabId:m}});return}const v=await yu(m);if(!v&&!x){await Qt(t,{ok:true,data:{url:l,opened:true,tabId:m,settled:false}});return}if(!v){await Qt(t,{ok:true,data:{url:l,opened:true,tabId:m,viewportApplied:false,note:"The panel had no browser view yet, so the viewport was not applied. Call browser.resize now that one exists."}});return}const y=x?await v.run("browser.resize",{viewport:h}):null,C=y&&typeof y=="object"?y.viewport??null:null,S=Math.max(0,u0-(Date.now()-f)),N=t.parameters.dialog==="accept"?{budgetMs:S,dialog:"accept"}:{budgetMs:S},F=g?d0.safeParse(await v.run("browser.settle",N).catch(()=>null)):null;await Qt(t,{ok:true,data:Object.assign({url:l,opened:true,tabId:m},x?{viewportApplied:true,viewport:C}:{},F?F.success?F.data:{settled:false}:{})});return}const p=await vu(u);await Qt(t,p?await Tu(p,r,t.action,a):{ok:false,error:ku(u)})}catch(l){await Qt(t,{ok:false,error:l instanceof Error?l.message:String(l)})}},Pl=async(t,e,s,r)=>{if(!await Vs(t.requestId))return;h0(e,s);const o=await vu(s);await Qt(t,o?await Tu(o,e,t.action,r):{ok:false,error:ku(s)})},Tu=async(t,e,s,r)=>{Yr?.(t.directory,t.tabId);try{const o=await t.run(s,r);return s==="browser.snapshot"&&Object(o)===o?{ok:true,data:{...Object(o),tabs:Su(e)}}:{ok:true,data:o}}catch(o){return{ok:false,error:o instanceof Error?o.message:String(o)}}},Ro=()=>{ar||(ar=$n(t=>{t.type==="browser-control-request"&&v0({requestId:t.requestId,action:t.action,parameters:t.parameters,context:t.context})}))},Do=()=>{fs.size>0||Os.size>0||Cs||rn||!ar||(ar(),ar=null)},S0=t=>(fs.set(t.tabId,t),Ro(),()=>{fs.get(t.tabId)===t&&fs.delete(t.tabId),Do()}),k0=t=>(Os.set(t.tabId,t),Ro(),()=>{Os.get(t.tabId)===t&&Os.delete(t.tabId),Do()}),j0=(t,e)=>{Ea=t,e&&(Ia=e)},T0=t=>(Yr=t,()=>{Yr===t&&(Yr=null)}),C0=(t,e)=>Cs?Cs(t,e):null,E0=t=>(Cs=t,Ro(),()=>{Cs===t&&(Cs=null),Do()}),I0=t=>(rn=t,Ro(),()=>{rn===t&&(rn=null),Do()}),N0=50,P0=6,R0=2048,D0=200,Cu=t=>{const e=Rn(String(t??"").trim());if(!e||e.length>R0)return"";try{const s=new URL(e);return s.protocol!=="http:"&&s.protocol!=="https:"?"":s.toString()}catch{return""}},_0=(t,e)=>{const s=Cu(e.url);if(!s)return t;const r=t.find(i=>i.url===s),o=String(e.title??"").trim().slice(0,D0)||r?.title||"";return[{url:s,title:o,lastVisitedAt:e.at},...t.filter(i=>i.url!==s)].slice(0,N0)},A0=(t,e)=>{const s=Cu(e);return t.filter(r=>r.url!==s)},O0=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Eu=(t,e,s=P0)=>{const r=String(e??"").trim().toLowerCase(),o=[...t].sort((i,u)=>u.lastVisitedAt-i.lastVisitedAt);if(!r)return o.slice(0,s);const a=r.replace(/^https?:\/\//,"");return o.filter(i=>{const u=O0(i);return i.url===r||u===a?false:u.includes(a)}).slice(0,s)},Rl=20,Jr=t=>{const e=ts((t||"").trim());return e?JSON.stringify([Xt(),e]):""},M0=t=>{const e=Object.keys(t);if(e.length<=Rl)return t;const s=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,o)=>o[1]-r[1]).slice(0,Rl);return Object.fromEntries(s.map(([r])=>[r,t[r]??[]]))},_n=Io()(fb(t=>({byProject:{},recordVisit:(e,s)=>{const r=Jr(e);r&&t(o=>{const a=o.byProject[r]??[],i=_0(a,{...s,at:Date.now()});return i===a?o:{byProject:M0({...o.byProject,[r]:i})}})},forget:(e,s)=>{const r=Jr(e);r&&t(o=>{const a=o.byProject[r];return a?{byProject:{...o.byProject,[r]:A0(a,s)}}:o})},clear:e=>{const s=Jr(e);s&&t(r=>{if(!(s in r.byProject))return r;const o={...r.byProject};return delete o[s],{byProject:o}})}}),{name:"openchamber-browser-history",version:1,storage:Cf(),partialize:t=>({byProject:t.byProject})})),F0=[],Iu=t=>e=>{const s=Jr(t);return(s?e.byProject[s]:void 0)??F0},wi=t=>{const e=qe.c(10),{t:s}=gt();let r;e[0]!==t?(r=ks(t),e[0]=t,e[1]=r):r=e[1];const o=r;let a;e[2]!==o?(a=l=>o?l.journey?.get(o):void 0,e[2]=o,e[3]=a):a=e[3];const i=yn(a);if(o===null)return null;if(!i){let l;return e[4]!==s?(l=s("contextPanel.browser.spaceAddress"),e[4]=s,e[5]=l):l=e[5],l}let u;e[6]!==i.machine||e[7]!==i.placeId||e[8]!==s?(u=i.machine??(i.placeId==="docker"?s("spaces.create.place.localDocker"):i.placeId),e[6]=i.machine,e[7]=i.placeId,e[8]=s,e[9]=u):u=e[9];const d=u;return`${i.name} \xB7 ${d}`},Nu=6e3,Pu=120,L0=80,$0=32,B0=100,Pa="stale",z0='a[href], button, input, select, textarea, summary, [role="button"], [role="link"], [role="tab"], [role="checkbox"], [role="radio"], [role="switch"], [role="menuitem"], [role="option"], [role="combobox"], [role="textbox"], [contenteditable="true"], [draggable="true"]',W0=`
8
8
  var MAX_LABEL_CHARS = ${L0};
@@ -580,4 +580,4 @@ ${t}
580
580
  `),r2=Mt({token:It().min(1),files:Cn(Mt({name:It().min(1),size:as()})).min(1)}),o2=t=>new Promise((e,s)=>{const r=new FileReader;r.onload=()=>{const o=String(r.result??"");e(o.slice(o.indexOf(",")+1))},r.onerror=()=>s(r.error??new Error("Could not read the file")),r.readAsDataURL(t)}),a2=async(t,e)=>{const s=[];for(const[r,o]of t.files.entries()){const a=await Ms(`/api/browser-control/uploads/${encodeURIComponent(t.token)}/${r}`);if(!a.ok)throw new Error(`Could not fetch ${o.name} for the upload (HTTP ${a.status})`);s.push({name:o.name,base64:await o2(await a.blob())})}return e(s)},i2=Mt({ref:It().optional(),selector:It().optional(),text:It().optional(),to:It().optional(),toSelector:It().optional(),value:It().optional(),label:It().optional(),key:It().optional(),direction:It().optional(),submit:ss().optional(),accept:ss().optional(),gone:ss().optional(),timeoutMs:as().optional(),dialog:Qd(["accept","dismiss"]).optional(),upload:r2.optional()}),Du=Mt({type:It(),message:It(),defaultPrompt:It().optional(),url:It()}),l2=Mt({frameId:It(),parentFrameId:It().nullable(),url:It()}),c2=Cn(l2).min(1),_u=Mt({x:as(),y:as()}),Au=Mt({x:as(),y:as(),width:as(),height:as()}),d2=Mt({dialog:Du.optional(),value:an().optional()}),u2=Mt({ok:br(false),error:It().optional(),code:It().optional()}),Al=wr(It(),an()),f2=Mt({id:as(),bounds:Au}).catchall(an()),Ol=Mt({doc:It(),text:It(),elements:Cn(f2),textTruncated:ss().optional(),textTotalChars:as().optional(),elementsTruncated:ss().optional(),interactiveElementsOnPage:as().optional()}).catchall(an()),p2=pb("found",[Mt({found:br(false)}),Mt({found:br(true),exact:ss(),id:as(),doc:It()})]),m2=_u.extend({label:It(),selector:It().optional()}),h2=Mt({selector:It().optional()}),g2=Mt({value:It(),valueTruncated:ss()}),x2=Mt({multiple:ss()}),b2=Mt({draggable:ss()}),w2=Mt({accepted:ss()}),Ml=Mt({present:ss()}),y2=Mt({bounds:Au,selector:It().optional()}).catchall(an()),Fl=15e3,v2=250,cs=t=>t||null,Ra=t=>`The page opened a ${t.type} dialog${t.message?` saying "${t.message}"`:""} and waits for an answer. Answer it with browser.dialog (accept true or false) before anything else.`;class hn extends Error{constructor(e){super(Ra(e)),this.dialog=e}dialog}const Ll=t=>new Error(`${t} is not on the page any more, or comes from an older snapshot. Take a new browser.snapshot and use its refs.`),$l=t=>t.defaultPrompt===void 0?{type:t.type,message:t.message,url:t.url}:{type:t.type,message:t.message,url:t.url,defaultPrompt:t.defaultPrompt},Bl=(t,e)=>({x:Math.round(t.x+e.x),y:Math.round(t.y+e.y),width:t.width,height:t.height}),S2=({drive:t,withInput:e})=>{let s=new Map;const r=async()=>{const b=c2.safeParse(await t("frames"));if(!b.success)throw new Error("The page has no frame to act in yet");return b.data},o=async()=>Du.nullable().parse(await t("dialog")),a=async()=>{const b=await o();if(b)throw new hn(b)},i=async(b,w)=>{const j=d2.parse(await t(b,w));if(j.dialog)throw new hn(j.dialog);return j.value},u=async(b,w,j,R)=>{const L=await i("evaluate",{frameId:b,expression:w}),E=u2.safeParse(L);if(E.success)throw R&&E.data.code===Pa?Ll(R):new Error(E.data.error||"Browser action failed");const D=j.safeParse(L);if(!D.success)throw new Error("The page returned no usable result");return D.data},d=async(b,w,j)=>{const R=await u(b,w,Al,j);return delete R.ok,R},l=async(b,w)=>{if(b.frameId===w)return{x:0,y:0};const j=_u.safeParse(await t("frameOrigin",{frameId:b.frameId}));if(!j.success)throw new Error("Could not tell where the frame sits on the page");return j.data},f=async(b,w,j)=>{const R=await r(),L=E=>{const D=R.find(U=>U.frameId===E);return D&&D.frameId!==R[0].frameId?D:null};if(b){const E=s.get(b);if(!E||!R.some(D=>D.frameId===E.frameId))throw Ll(b);return{frameId:E.frameId,target:{id:E.id,doc:E.doc},name:b,frame:L(E.frameId)}}if(w)return{frameId:R[0].frameId,target:{selector:w},name:w,frame:null};if(j){let E=null;for(const D of R){let U;try{U=await u(D.frameId,V0(j),p2)}catch(J){if(J instanceof hn)throw J;continue}if(!U.found)continue;const V={frameId:D.frameId,target:{id:U.id,doc:U.doc},name:j,frame:L(D.frameId)};if(U.exact)return V;E??=V}if(E)return E;throw new Error(`No clickable element has the label ${j}`)}throw new Error("Name the element with ref from browser.snapshot, a selector, or text")},m=(b,w=false)=>f(cs(b.ref),cs(b.selector),w?cs(b.text):null),p=async(b,w=true)=>{const j=await u(b.frameId,U0(b.target,{requireEnabled:w}),m2,b.name);return{frameId:b.frameId,x:j.x,y:j.y,label:j.label,selector:b.frame?null:j.selector??null}},h=(b,w,j)=>(w?b.ref=w:j&&(b.selector=j),b),x=async b=>(await a(),e(async()=>{try{return await b()}catch(w){if(w instanceof hn)return{dialog:$l(w.dialog),note:Ra(w.dialog)};throw w}}));return{snapshot:async b=>{const w=await o();if(w)return{dialog:$l(w),note:Ra(w)};const j=cs(b.selector),R=await r(),[L,...E]=R,D=new Map,U=[];let V=0,J=0,W=false;const G=(ce,ae,te)=>{V+=ae.interactiveElementsOnPage??ae.elements.length,ae.textTruncated&&(W=true),J+=ae.textTotalChars??ae.text.length;for(const{id:pe,bounds:Te,...Ae}of ae.elements){const Pe=`e${D.size+1}`;D.set(Pe,{frameId:ce.frameId,id:pe,doc:ae.doc});const{selector:ze,...Oe}=Ae;U.push(te?{ref:Pe,...Oe,bounds:Bl(Te,te),frame:ce.url}:{ref:Pe,...Ae,bounds:Te})}},le=await u(L.frameId,Dl({selector:j??void 0}),Ol);G(L,le,null);let $=le.text;const re=[];if(!j)for(const ce of E){const ae=Math.max(0,Pu-U.length),te=Math.max(0,Nu-$.length);let pe;try{pe=await u(ce.frameId,Dl({maxElements:ae,maxTextChars:te}),Ol)}catch(Ae){if(Ae instanceof hn)throw Ae;continue}if(pe.elements.length===0&&!pe.text&&!pe.elementsTruncated)continue;let Te={x:0,y:0};try{Te=await l(ce,L.frameId)}catch{}G(ce,pe,Te),pe.text&&($+=`
581
581
 
582
582
  [frame ${ce.url}]
583
- ${pe.text}`),re.push({url:ce.url,elements:pe.elements.length})}s=D;const{elements:H,interactiveElementsOnPage:P,elementsTruncated:ee,textTruncated:oe,textTotalChars:de,doc:he,...Z}=le;return delete Z.ok,Object.assign({...Z,text:$,elements:U},W?{textTruncated:true,textTotalChars:J}:null,V>U.length?{elementsTruncated:true,interactiveElementsOnPage:V}:null,re.length>0?{frames:re}:null)},click:b=>x(async()=>{const w=await p(await m(b,true));await i("click",{frameId:w.frameId,x:w.x,y:w.y});const j=h({clicked:true},b.ref,w.selector);return w.label&&(j.label=w.label),j}),hover:b=>x(async()=>{const w=await p(await m(b,true),false);await i("hover",{frameId:w.frameId,x:w.x,y:w.y});const j=h({hovered:true},b.ref,w.selector);return w.label&&(j.label=w.label),j}),drag:b=>x(async()=>{const w=await m(b),j=await f(cs(b.to),cs(b.toSelector),null),R=cs(b.to)??cs(b.toSelector),{draggable:L}=await u(w.frameId,q0(w.target),b2,w.name);if(L){if(w.frameId!==j.frameId)throw new Error("An HTML drag can only drop inside the same frame of the page");const{accepted:U}=await u(w.frameId,G0(w.target,j.target),w2,w.name),V=h({dragged:true,to:R,mode:"html"},b.ref,null);return U||(V.note="The target did not accept the drop: its dragover was not cancelled."),V}const E=await p(j,false),D=await p(w,false);return await i("drag",{from:{frameId:D.frameId,x:D.x,y:D.y},to:{frameId:E.frameId,x:E.x,y:E.y}}),h({dragged:true,to:R??E.selector,mode:"pointer"},b.ref,D.selector)}),type:b=>x(async()=>{const w=await m(b),j=b.value??"",R=await u(w.frameId,H0(w.target),h2,w.name);j?await i("insertText",{text:j}):await i("press",{key:"Delete"}),b.submit&&await i("press",{key:"Enter"});const L=h({typed:true},b.ref,w.frame?null:R.selector??null);try{const E=await u(w.frameId,Z0(w.target),g2,w.name);L.value=E.value,E.valueTruncated&&(L.valueTruncated=true)}catch(E){if(E instanceof hn)throw E}return L}),press:b=>x(async()=>{const w=cs(b.key);if(!w)throw new Error("key is required, such as Enter, Escape, Tab or Meta+a");if(cs(b.ref)||cs(b.selector)){const j=await m(b);await u(j.frameId,K0(j.target),Al,j.name)}return await i("press",{key:w}),{pressed:w}}),select:async b=>{await a();const w=await m(b),j=await d(w.frameId,J0(w.target,{label:b.label,value:b.value}),w.name);return w.frame&&delete j.selector,b.ref&&(j.ref=b.ref),j},scroll:async b=>{if(await a(),cs(b.ref)||cs(b.selector)){const R=await m(b);return d(R.frameId,Q0(R.target),R.name)}const w=cs(b.direction);if(!w)throw new Error("browser.scroll requires direction, ref or selector");const j=await r();return d(j[0].frameId,e2({direction:w}))},inspect:async b=>{await a();const w=await m(b),{bounds:j,selector:R,...L}=await u(w.frameId,n2(w.target),y2,w.name);delete L.ok;const E=w.frame?{bounds:Bl(j,await l(w.frame,(await r())[0].frameId)),frame:w.frame.url}:R?{bounds:j,selector:R}:{bounds:j};return Object.assign({...L,...E},b.ref?{ref:b.ref}:null)},upload:async(b,w)=>{await a();const j=await m(b),{multiple:R}=await u(j.frameId,X0(j.target),x2,j.name);if(w.length>1&&!R)throw new Error("This file input takes one file; pass one path");return await t("setFiles",{frameId:j.frameId,expression:Y0(j.target),files:w}),{uploaded:w.length}},answerDialog:async b=>{if(b.accept===void 0)throw new Error("accept is required: true to accept, false to dismiss");return t("answerDialog",b.value===void 0?{accept:b.accept}:{accept:b.accept,promptText:b.value})},wait:async(b,w,j)=>{await a();const R=cs(b.text),L=b.gone===true,E=Math.min(Fl,Math.max(0,b.timeoutMs??Fl)),D=R?null:await m(b),U=j();for(;;){let V=false;if(D)V=(await u(D.frameId,_l({target:D.target}),Ml)).present;else for(const W of await r())try{if((await u(W.frameId,_l({text:R??""}),Ml)).present){V=true;break}}catch(G){if(G instanceof hn)throw G}const J=j()-U;if(V!==L)return{met:true,waitedMs:J};if(J>=E){const W=R?`the text "${R}"`:D?.name??"it";throw new Error(`Waited ${(J/1e3).toFixed(1)} s, and ${W} ${L?"is still on the page":"did not show up"}.`)}await w(v2)}},ensureNoDialog:a}},k2=t=>{const e=qe.c(18),{entries:s,activeIndex:r,onSelect:o,onForget:a,onHighlight:i}=t,{t:u}=gt();if(s.length===0)return null;let d;e[0]!==u?(d=u("contextPanel.browser.history.label"),e[0]=u,e[1]=d):d=e[1];let l;if(e[2]!==r||e[3]!==s||e[4]!==a||e[5]!==i||e[6]!==o||e[7]!==u){let m;e[9]!==r||e[10]!==a||e[11]!==i||e[12]!==o||e[13]!==u?(m=(p,h)=>n.jsxs("div",{role:"option","aria-selected":h===r,className:Ye("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",h===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:x=>{x.preventDefault(),o(p.url)},onPointerEnter:()=>i(h),children:[n.jsx(ue,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate typography-micro text-foreground",children:p.title||xo(p.url)}),n.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",className:Ye("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"),onPointerDown:x=>{x.preventDefault(),x.stopPropagation(),a(p.url)},children:n.jsx(ue,{name:"close",className:"size-3","aria-hidden":"true"})})}),n.jsx(Dt,{sideOffset:6,children:u("contextPanel.browser.history.forget")})]})]},p.url),e[9]=r,e[10]=a,e[11]=i,e[12]=o,e[13]=u,e[14]=m):m=e[14],l=s.map(m),e[2]=r,e[3]=s,e[4]=a,e[5]=i,e[6]=o,e[7]=u,e[8]=l}else l=e[8];let f;return e[15]!==d||e[16]!==l?(f=n.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":d,children:l}),e[15]=d,e[16]=l,e[17]=f):f=e[17],f},j2=t=>{const e=/^(https?:\/\/)?([^/?#\s]+)(.*)$/i.exec(t.trim());return e?{host:e[2],rest:e[3]}:null},Ou=t=>{const e=qe.c(189),{address:s,addressMark:r,suggestions:o,onForgetSuggestion:a,onAddressChange:i,onSubmit:u,onBack:d,onForward:l,onReload:f,onOpenExternal:m,canOpenExternal:p,canGoBack:h,canGoForward:x,isLoading:g,onAnnotate:v,onOpenDevTools:y,isAnnotating:C,onHardReload:S,onZoomIn:N,onZoomOut:F,onZoomReset:_,zoomPercent:M,onClearCookies:B,onClearCache:T,onToggleDeviceBar:I,isDeviceBarOpen:b}=t;let w;e[0]!==o?(w=o===void 0?[]:o,e[0]=o,e[1]=w):w=e[1];const j=w,R=p===void 0?true:p,L=M===void 0?100:M,{t:E}=gt(),[D,U]=c.useState(false),[V,J]=c.useState(-1);let W;e[2]!==D||e[3]!==j?(W=D?j:[],e[2]=D,e[3]=j,e[4]=W):W=e[4];const G=W;let le;e[5]===Symbol.for("react.memo_cache_sentinel")?(le=()=>{J(-1)},e[5]=le):le=e[5];let $;e[6]!==s||e[7]!==D?($=[s,D],e[6]=s,e[7]=D,e[8]=$):$=e[8],c.useEffect(le,$);let re;e[9]!==u?(re=Ie=>{U(false),J(-1),u(Ie)},e[9]=u,e[10]=re):re=e[10];const H=re;let P;e[11]!==V||e[12]!==H||e[13]!==G?(P=Ie=>{if(G.length!==0){if(Ie.key==="ArrowDown"||Ie.key==="ArrowUp"){Ie.preventDefault();const Ee=Ie.key==="ArrowDown"?1:-1,Ge=G.length;J(Be=>{const Ze=Be+Ee;return Ze<-1?Ge-1:Ze>=Ge?-1:Ze});return}if(Ie.key==="Escape"&&V>=0){Ie.preventDefault(),J(-1);return}if(Ie.key==="Enter"&&V>=0){Ie.preventDefault();const Ee=G[V];Ee&&H(Ee.url)}}},e[11]=V,e[12]=H,e[13]=G,e[14]=P):P=e[14];const ee=P,oe=K(T2);let de;e[15]!==oe?(de=Ie=>bs(Es(Ie,oe),"")||void 0,e[15]=oe,e[16]=de):de=e[16];const he=de;let Z,ce,ae,te,pe,Te,Ae,Pe,ze,Oe,me,be,Ce,$e,We,_e,Ue,Xe,Me;if(e[17]!==s||e[18]!==r||e[19]!==h||e[20]!==x||e[21]!==R||e[22]!==D||e[23]!==C||e[24]!==b||e[25]!==g||e[26]!==i||e[27]!==ee||e[28]!==v||e[29]!==d||e[30]!==T||e[31]!==B||e[32]!==l||e[33]!==S||e[34]!==y||e[35]!==m||e[36]!==f||e[37]!==I||e[38]!==N||e[39]!==F||e[40]!==he||e[41]!==H||e[42]!==E||e[43]!==G.length||e[44]!==L){ae=D?null:j2(s);let Ie;e[64]!==b||e[65]!==I||e[66]!==E?(Ie=I?{id:"device",icon:"smartphone",label:E("contextPanel.browser.deviceToolbar"),onSelect:I,pressed:b}:null,e[64]=b,e[65]=I,e[66]=E,e[67]=Ie):Ie=e[67];let Ee;e[68]!==C||e[69]!==v||e[70]!==E?(Ee=v?{id:"annotate",icon:"markup",label:E("contextPanel.browser.annotate.toggle"),onSelect:v,pressed:C}:null,e[68]=C,e[69]=v,e[70]=E,e[71]=Ee):Ee=e[71];let Ge;e[72]!==Ie||e[73]!==Ee?(Ge=[Ie,Ee],e[72]=Ie,e[73]=Ee,e[74]=Ge):Ge=e[74],ce=Ge;let Be;e[75]!==E?(Be=E("contextPanel.browser.openExternal"),e[75]=E,e[76]=Be):Be=e[76];const Ze=!R;let et;e[77]!==m||e[78]!==Be||e[79]!==Ze?(et={id:"external",icon:"external-link",label:Be,onSelect:m,disabled:Ze},e[77]=m,e[78]=Be,e[79]=Ze,e[80]=et):et=e[80];let wt;e[81]!==S||e[82]!==E?(wt=S?{id:"hard-reload",icon:"restart",label:E("contextPanel.browser.hardReload"),onSelect:S}:null,e[81]=S,e[82]=E,e[83]=wt):wt=e[83];let Qe;e[84]!==N||e[85]!==he||e[86]!==E?(Qe=N?{id:"zoom-in",icon:"zoom-in",label:E("contextPanel.browser.zoomIn"),onSelect:N,shortcut:he("zoom_in")}:null,e[84]=N,e[85]=he,e[86]=E,e[87]=Qe):Qe=e[87];let dt;e[88]!==F||e[89]!==he||e[90]!==E?(dt=F?{id:"zoom-out",icon:"zoom-out",label:E("contextPanel.browser.zoomOut"),onSelect:F,shortcut:he("zoom_out")}:null,e[88]=F,e[89]=he,e[90]=E,e[91]=dt):dt=e[91];let at;e[92]!==y||e[93]!==E?(at=y?{id:"devtools",icon:"terminal-box",label:E("contextPanel.browser.devTools"),onSelect:y}:null,e[92]=y,e[93]=E,e[94]=at):at=e[94];let z;e[95]!==T||e[96]!==E?(z=T?{id:"clear-cache",icon:"database-2",label:E("contextPanel.browser.clearCache"),onSelect:T}:null,e[95]=T,e[96]=E,e[97]=z):z=e[97];let fe;e[98]!==B||e[99]!==E?(fe=B?{id:"clear-cookies",icon:"delete-bin",label:E("contextPanel.browser.clearCookies"),onSelect:B,destructive:true}:null,e[98]=B,e[99]=E,e[100]=fe):fe=e[100];let ke;e[101]!==et||e[102]!==wt||e[103]!==Qe||e[104]!==dt||e[105]!==at||e[106]!==z||e[107]!==fe?(ke=[et,wt,Qe,dt,at,z,fe],e[101]=et,e[102]=wt,e[103]=Qe,e[104]=dt,e[105]=at,e[106]=z,e[107]=fe,e[108]=ke):ke=e[108],Z=ke,Xe="flex min-w-0 items-center gap-1.5 px-2 py-1.5";let ie;e[109]!==E?(ie=E("contextPanel.browser.back"),e[109]=E,e[110]=ie):ie=e[110];const xe=!h;let Le;e[111]!==d||e[112]!==ie||e[113]!==xe?(Le=n.jsx(qr,{icon:"arrow-left",label:ie,onClick:d,disabled:xe}),e[111]=d,e[112]=ie,e[113]=xe,e[114]=Le):Le=e[114];let Ke;e[115]!==E?(Ke=E("contextPanel.browser.forward"),e[115]=E,e[116]=Ke):Ke=e[116];const ve=!x;let je;e[117]!==l||e[118]!==Ke||e[119]!==ve?(je=n.jsx(qr,{icon:"arrow-right",label:Ke,onClick:l,disabled:ve}),e[117]=l,e[118]=Ke,e[119]=ve,e[120]=je):je=e[120];const vt=g?"close":"refresh";let ne;e[121]!==g||e[122]!==E?(ne=E(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[121]=g,e[122]=E,e[123]=ne):ne=e[123];let Je;e[124]!==f||e[125]!==vt||e[126]!==ne?(Je=n.jsx(qr,{icon:vt,label:ne,onClick:f}),e[124]=f,e[125]=vt,e[126]=ne,e[127]=Je):Je=e[127],e[128]!==Le||e[129]!==je||e[130]!==Je?(Me=n.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[Le,je,Je]}),e[128]=Le,e[129]=je,e[130]=Je,e[131]=Me):Me=e[131],We="relative min-w-0 flex-1",e[132]!==s||e[133]!==H?(_e=kt=>{kt.preventDefault(),H(s)},e[132]=s,e[133]=H,e[134]=_e):_e=e[134],e[135]!==r?(Ue=r?n.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:n.jsx(ue,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[135]=r,e[136]=Ue):Ue=e[136],te=s,e[137]!==i?(pe=kt=>i(kt.target.value),e[137]=i,e[138]=pe):pe=e[138],e[139]===Symbol.for("react.memo_cache_sentinel")?(Te=kt=>{U(true),kt.currentTarget.select()},Ae=()=>U(false),e[139]=Te,e[140]=Ae):(Te=e[139],Ae=e[140]),Pe=ee,ze=false,Oe="off",me="combobox",be=G.length>0,Ce="openchamber-browser-address-suggestions",$e=Ye("oc-raised oc-field h-7 w-full rounded-full bg-[var(--surface-elevated)] px-3.5",r&&"ps-8",L!==100&&"pe-14","typography-meta text-foreground outline-none",ae&&"text-transparent"),e[17]=s,e[18]=r,e[19]=h,e[20]=x,e[21]=R,e[22]=D,e[23]=C,e[24]=b,e[25]=g,e[26]=i,e[27]=ee,e[28]=v,e[29]=d,e[30]=T,e[31]=B,e[32]=l,e[33]=S,e[34]=y,e[35]=m,e[36]=f,e[37]=I,e[38]=N,e[39]=F,e[40]=he,e[41]=H,e[42]=E,e[43]=G.length,e[44]=L,e[45]=Z,e[46]=ce,e[47]=ae,e[48]=te,e[49]=pe,e[50]=Te,e[51]=Ae,e[52]=Pe,e[53]=ze,e[54]=Oe,e[55]=me,e[56]=be,e[57]=Ce,e[58]=$e,e[59]=We,e[60]=_e,e[61]=Ue,e[62]=Xe,e[63]=Me}else Z=e[45],ce=e[46],ae=e[47],te=e[48],pe=e[49],Te=e[50],Ae=e[51],Pe=e[52],ze=e[53],Oe=e[54],me=e[55],be=e[56],Ce=e[57],$e=e[58],We=e[59],_e=e[60],Ue=e[61],Xe=e[62],Me=e[63];let ot;e[141]!==E?(ot=E("contextPanel.browser.addressAria"),e[141]=E,e[142]=ot):ot=e[142];let ye;e[143]!==te||e[144]!==pe||e[145]!==Te||e[146]!==Ae||e[147]!==Pe||e[148]!==ze||e[149]!==Oe||e[150]!==me||e[151]!==be||e[152]!==Ce||e[153]!==$e||e[154]!==ot?(ye=n.jsx("input",{value:te,onChange:pe,onFocus:Te,onBlur:Ae,onKeyDown:Pe,spellCheck:ze,autoComplete:Oe,role:me,"aria-expanded":be,"aria-controls":Ce,className:$e,"aria-label":ot}),e[143]=te,e[144]=pe,e[145]=Te,e[146]=Ae,e[147]=Pe,e[148]=ze,e[149]=Oe,e[150]=me,e[151]=be,e[152]=Ce,e[153]=$e,e[154]=ot,e[155]=ye):ye=e[155];let Ve;e[156]!==r||e[157]!==ae||e[158]!==L?(Ve=ae?n.jsx("span",{"aria-hidden":"true",className:Ye("pointer-events-none absolute inset-y-0 inset-s-0 flex min-w-0 items-center overflow-hidden px-3.5 typography-meta",r&&"ps-8",L!==100?"inset-e-14":"inset-e-0"),children:n.jsxs("span",{className:"truncate",children:[n.jsx("span",{className:"text-foreground",children:ae.host}),n.jsx("span",{className:"text-muted-foreground",children:ae.rest})]})}):null,e[156]=r,e[157]=ae,e[158]=L,e[159]=Ve):Ve=e[159];let lt;e[160]!==_||e[161]!==E||e[162]!==L?(lt=L!==100&&_?n.jsx(es,{label:E("contextPanel.browser.zoomReset"),side:"bottom",className:"absolute inset-e-1 top-1/2 -translate-y-1/2",children:n.jsxs("button",{type:"button",onClick:_,"aria-label":E("contextPanel.browser.zoomReset"),className:"h-4.5 rounded-full bg-[color-mix(in_srgb,var(--foreground)_8%,transparent)] px-1.5 typography-micro tabular-nums text-muted-foreground hover:text-foreground",children:[L,"%"]})}):null,e[160]=_,e[161]=E,e[162]=L,e[163]=lt):lt=e[163];let ct;e[164]!==a?(ct=Ie=>a?.(Ie),e[164]=a,e[165]=ct):ct=e[165];let st;e[166]!==V||e[167]!==H||e[168]!==ct||e[169]!==G?(st=n.jsx("div",{id:"openchamber-browser-address-suggestions",children:n.jsx(k2,{entries:G,activeIndex:V,onSelect:H,onForget:ct,onHighlight:J})}),e[166]=V,e[167]=H,e[168]=ct,e[169]=G,e[170]=st):st=e[170];let k;e[171]!==We||e[172]!==_e||e[173]!==Ue||e[174]!==ye||e[175]!==Ve||e[176]!==lt||e[177]!==st?(k=n.jsxs("form",{className:We,onSubmit:_e,children:[Ue,ye,Ve,lt,st]}),e[171]=We,e[172]=_e,e[173]=Ue,e[174]=ye,e[175]=Ve,e[176]=lt,e[177]=st,e[178]=k):k=e[178];let Y;e[179]!==ce?(Y=[ce],e[179]=ce,e[180]=Y):Y=e[180];let Ne;e[181]!==Z||e[182]!==Y?(Ne=n.jsx(jd,{className:"shrink-0",groups:Y,menuOnly:Z,fold:true}),e[181]=Z,e[182]=Y,e[183]=Ne):Ne=e[183];let Re;return e[184]!==Xe||e[185]!==Me||e[186]!==k||e[187]!==Ne?(Re=n.jsxs("div",{className:Xe,children:[Me,k,Ne]}),e[184]=Xe,e[185]=Me,e[186]=k,e[187]=Ne,e[188]=Re):Re=e[188],Re};function T2(t){return t.shortcutOverrides}const Sr={kind:"fill"},zl=240,C2=3840,Da=[{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}],Wl=t=>Number.isFinite(t)?Math.round(Math.min(C2,Math.max(zl,t))):zl,kr=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Mu=t=>{const e=Da.find(s=>s.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},E2=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},I2=(t,e)=>{const s=kr(t);if(!s)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),a=Math.min(1,r/s.width,o/s.height);return{width:s.width,height:s.height,scale:a}},N2=["mobile","tablet","desktop","fill"],P2={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Vl=t=>typeof t=="string"&&N2.includes(t),_a=t=>t==="fill"?Sr:Mu(P2[t])??Sr,Fr=t=>{const e=kr(t);if(!e)return{mode:"fill",width:null,height:null};for(const s of["mobile","tablet","desktop"]){const r=_a(s),o=kr(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:s,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},Lr="responsive",R2=[{value:"system",icon:"contrast-2"},{value:"light",icon:"sun"},{value:"dark",icon:"moon"}],D2=t=>{const e=qe.c(86),{viewport:s,onViewportChange:r,colorScheme:o,onColorSchemeChange:a,scale:i,panelSize:u}=t,{t:d}=gt();let l;e[0]!==s?(l=kr(s),e[0]=s,e[1]=l):l=e[1];const f=l,m=s.kind==="preset"?s.id:Lr;let p;e[2]!==d?(p=pe=>pe===Lr?d("contextPanel.browser.device.responsive"):Da.find(Te=>Te.id===pe)?.label??pe,e[2]=d,e[3]=p):p=e[3];const h=p;let x;e[4]!==u.width?(x=Math.round(u.width),e[4]=u.width,e[5]=x):x=e[5];let g;e[6]!==u.height?(g=Math.round(u.height),e[6]=u.height,e[7]=g):g=e[7];let v;e[8]!==x||e[9]!==g?(v={width:x,height:g},e[8]=x,e[9]=g,e[10]=v):v=e[10];const y=v;let C;e[11]!==r||e[12]!==y||e[13]!==f?(C=(pe,Te)=>{const Ae=Number.parseInt(Te,10);if(!Number.isFinite(Ae))return;const Pe=f??y;r({kind:"custom",width:Wl(pe==="width"?Ae:Pe.width),height:Wl(pe==="height"?Ae:Pe.height)})},e[11]=r,e[12]=y,e[13]=f,e[14]=C):C=e[14];const S=C;let N;e[15]===Symbol.for("react.memo_cache_sentinel")?(N=Ye("w-11 min-w-0 bg-transparent text-center typography-meta tabular-nums text-foreground outline-none","placeholder:text-muted-foreground"),e[15]=N):N=e[15];const F=N;let _;e[16]!==r?(_=pe=>r(pe===Lr?Sr:Mu(pe)??Sr),e[16]=r,e[17]=_):_=e[17];let M;e[18]!==d?(M=d("contextPanel.browser.device.preset"),e[18]=d,e[19]=M):M=e[19];let B;e[20]!==h?(B=n.jsx(pd,{children:pe=>h(String(pe))}),e[20]=h,e[21]=B):B=e[21];let T;e[22]!==B||e[23]!==M?(T=n.jsx(fd,{className:"min-w-0 max-w-[12rem]","aria-label":M,children:B}),e[22]=B,e[23]=M,e[24]=T):T=e[24];let I;e[25]!==d?(I=d("contextPanel.browser.device.responsive"),e[25]=d,e[26]=I):I=e[26];let b;e[27]!==I?(b=n.jsx(ti,{value:Lr,children:I}),e[27]=I,e[28]=b):b=e[28];let w;e[29]===Symbol.for("react.memo_cache_sentinel")?(w=Da.map(_2),e[29]=w):w=e[29];let j;e[30]!==b?(j=n.jsxs(md,{children:[b,w]}),e[30]=b,e[31]=j):j=e[31];let R;e[32]!==m||e[33]!==T||e[34]!==j||e[35]!==_?(R=n.jsxs(ud,{value:m,onValueChange:_,children:[T,j]}),e[32]=m,e[33]=T,e[34]=j,e[35]=_,e[36]=R):R=e[36];const L=f?String(f.width):"";let E;e[37]!==S?(E=pe=>S("width",pe.target.value),e[37]=S,e[38]=E):E=e[38];const D=y.width>0?String(y.width):"";let U;e[39]!==d?(U=d("contextPanel.browser.device.width"),e[39]=d,e[40]=U):U=e[40];let V;e[41]!==L||e[42]!==E||e[43]!==D||e[44]!==U?(V=n.jsx("input",{value:L,onChange:E,placeholder:D,inputMode:"numeric","aria-label":U,className:F}),e[41]=L,e[42]=E,e[43]=D,e[44]=U,e[45]=V):V=e[45];let J;e[46]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx("span",{className:"typography-meta text-muted-foreground","aria-hidden":"true",children:"\xD7"}),e[46]=J):J=e[46];const W=f?String(f.height):"";let G;e[47]!==S?(G=pe=>S("height",pe.target.value),e[47]=S,e[48]=G):G=e[48];const le=y.height>0?String(y.height):"";let $;e[49]!==d?($=d("contextPanel.browser.device.height"),e[49]=d,e[50]=$):$=e[50];let re;e[51]!==W||e[52]!==G||e[53]!==le||e[54]!==$?(re=n.jsx("input",{value:W,onChange:G,placeholder:le,inputMode:"numeric","aria-label":$,className:F}),e[51]=W,e[52]=G,e[53]=le,e[54]=$,e[55]=re):re=e[55];let H;e[56]!==V||e[57]!==re?(H=n.jsxs("div",{className:"oc-raised oc-field flex h-7 shrink-0 items-center rounded-md bg-[var(--surface-elevated)] px-1",children:[V,J,re]}),e[56]=V,e[57]=re,e[58]=H):H=e[58];let P;e[59]!==d?(P=d("contextPanel.browser.device.rotate"),e[59]=d,e[60]=P):P=e[60];let ee;e[61]!==r||e[62]!==s?(ee=()=>r(E2(s)),e[61]=r,e[62]=s,e[63]=ee):ee=e[63];const oe=!f;let de;e[64]!==P||e[65]!==ee||e[66]!==oe?(de=n.jsx(qr,{icon:"anticlockwise-2",label:P,onClick:ee,disabled:oe}),e[64]=P,e[65]=ee,e[66]=oe,e[67]=de):de=e[67];let he;e[68]!==i||e[69]!==f?(he=f&&i<1?n.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(i*100),"%"]}):null,e[68]=i,e[69]=f,e[70]=he):he=e[70];let Z;e[71]!==d?(Z=d("contextPanel.browser.device.scheme"),e[71]=d,e[72]=Z):Z=e[72];let ce;e[73]!==o||e[74]!==a||e[75]!==d?(ce=R2.map(pe=>{const{value:Te,icon:Ae}=pe,Pe=o===Te;return n.jsx(es,{side:"bottom",label:d(Te==="system"?"contextTooltips.terminalBrowser.device.schemeSystem":Te==="light"?"contextTooltips.terminalBrowser.device.schemeLight":"contextTooltips.terminalBrowser.device.schemeDark"),children:n.jsxs(yt,{type:"button",variant:"ghost",size:"xs","aria-pressed":Pe,onClick:()=>a(Te),className:Ye("h-6 gap-1.5 rounded-md px-2 typography-meta !font-normal",Pe?"oc-raised bg-[var(--surface-background)] text-foreground hover:bg-[var(--surface-background)] dark:bg-[var(--surface-elevated)] dark:hover:bg-[var(--surface-elevated)]":"text-muted-foreground hover:bg-transparent hover:text-foreground"),children:[n.jsx(ue,{name:Ae,className:"size-3.5","aria-hidden":"true"}),d(Te==="system"?"contextPanel.browser.device.schemeSystem":Te==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")]})},Te)}),e[73]=o,e[74]=a,e[75]=d,e[76]=ce):ce=e[76];let ae;e[77]!==Z||e[78]!==ce?(ae=n.jsx("div",{role:"group","aria-label":Z,className:"oc-recessed ms-auto inline-flex h-7 shrink-0 items-center gap-0.5 rounded-lg bg-[color-mix(in_srgb,var(--foreground)_4%,transparent)] p-0.5",children:ce}),e[77]=Z,e[78]=ce,e[79]=ae):ae=e[79];let te;return e[80]!==R||e[81]!==H||e[82]!==de||e[83]!==he||e[84]!==ae?(te=n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 px-2 pb-1.5",children:[R,H,de,he,ae]}),e[80]=R,e[81]=H,e[82]=de,e[83]=he,e[84]=ae,e[85]=te):te=e[85],te};function _2(t){return n.jsx(ti,{value:t.id,children:t.label},t.id)}const uo=new Map,Aa=new Set,Fu=()=>{for(const t of Aa)t()},oa=(t,e)=>{const s=t.trim();s&&(e.length===0?uo.delete(s):uo.set(s,[...e]),Fu())},A2=t=>{uo.delete(t.trim())&&Fu()},Lu=[],O2=t=>uo.get(t.trim())??Lu,M2=t=>(Aa.add(t),()=>{Aa.delete(t)}),F2=t=>{const e=qe.c(2);let s;return e[0]!==t?(s=()=>O2(t),e[0]=t,e[1]=s):s=e[1],c.useSyncExternalStore(M2,s,L2)};function L2(){return Lu}const $u="oc.browser.hiddenDevServerPorts.v1",$2=wr(It(),Cn(as().int().positive())),Oa=new Set,Bu=[];let $r=null;const yi=()=>{const t=Cr().getItem($u);if($r&&$r.raw===t)return $r.value;let e={};if(t!==null)try{const s=$2.safeParse(JSON.parse(t));s.success&&(e=s.data)}catch{e={}}return $r={raw:t,value:e},e},zu=t=>{Cr().setItem($u,JSON.stringify(t));for(const e of Oa)e()},B2=(t=Xt())=>yi()[t]??Bu,z2=t=>{const e=Xt(),s=yi(),r=s[e]??[];r.includes(t)||zu({...s,[e]:[...r,t].sort((o,a)=>o-a)})},W2=()=>{const t=Xt(),e=yi();if(!e[t])return;const s={...e};delete s[t],zu(s)},V2=t=>(Oa.add(t),()=>{Oa.delete(t)}),U2=()=>c.useSyncExternalStore(V2,H2,K2);function H2(){return B2()}function K2(){return Bu}const q2=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},G2=2e3,Z2=t=>Hc("http://localhost",t),Wu=t=>{const e=qe.c(62),{onOpen:s,directory:r,visible:o}=t,a=r===void 0?"":r,{t:i}=gt();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={kind:"loading"},e[0]=u):u=e[0];const[d,l]=c.useState(u),f=F2(a);let m;e[1]!==a?(m=()=>Z2(a),e[1]=a,e[2]=m):m=e[2];const[p]=c.useState(m);let h;e[3]!==a?(h=()=>Vp(a),e[3]=a,e[4]=h):h=e[4];const[x]=c.useState(h);let g;e[5]!==a?(g=Cc(a),e[5]=a,e[6]=g):g=e[6];const v=g,y=wi(a),C=Ef(a);let S,N;e[7]!==a||e[8]!==C||e[9]!==o?(S=()=>{if(C){l({kind:"ready",servers:[]});return}if(!o)return;let H=true,P=null;const ee=new AbortController,oe=()=>{t0(ee.signal,a).then(de=>{H&&(l(de),P=setTimeout(oe,G2))})};return oe(),()=>{H=false,P&&clearTimeout(P),ee.abort()}},N=[a,C,o],e[7]=a,e[8]=C,e[9]=o,e[10]=S,e[11]=N):(S=e[10],N=e[11]),c.useEffect(S,N);const F=Yt(X2),_=it(Y2);let M;if(e[12]!==F||e[13]!==_){const H=F.map(J2);let P;e[15]!==_?(P=[..._].flatMap(Q2),e[15]=_,e[16]=P):P=e[16],M=[...H,...P],e[12]=F,e[13]=_,e[14]=M}else M=e[14];const B=M;let T;e[17]!==f||e[18]!==a||e[19]!==d.kind||e[20]!==d.servers||e[21]!==B?(T=i0({candidates:r0({announced:f,discovered:d.kind==="ready"?d.servers:null}),folders:B,directory:a}),e[17]=f,e[18]=a,e[19]=d.kind,e[20]=d.servers,e[21]=B,e[22]=T):T=e[22];const I=T,b=U2(),[w,j]=c.useState(false);let R;if(e[23]!==I||e[24]!==b||e[25]!==w){let H;e[27]!==b||e[28]!==w?(H=P=>P.announced||!b.includes(P.port)&&(w||!P.outsideWork),e[27]=b,e[28]=w,e[29]=H):H=e[29],R=I.filter(H),e[23]=I,e[24]=b,e[25]=w,e[26]=R}else R=e[26];const L=R,E=I.length-L.length;let D;e[30]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(Zg,{width:110,height:110,className:"shrink-0 opacity-20"}),e[30]=D):D=e[30];let U;e[31]!==i?(U=i("contextPanel.browser.empty"),e[31]=i,e[32]=U):U=e[32];let V;e[33]!==U?(V=n.jsx("span",{className:"typography-ui-header text-foreground",children:U}),e[33]=U,e[34]=V):V=e[34];let J;e[35]!==i?(J=i("contextPanel.browser.emptyHint"),e[35]=i,e[36]=J):J=e[36];let W;e[37]!==J?(W=n.jsx("span",{className:"typography-micro text-muted-foreground",children:J}),e[37]=J,e[38]=W):W=e[38];let G;e[39]!==V||e[40]!==W?(G=n.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[V,W]}),e[39]=V,e[40]=W,e[41]=G):G=e[41];let le;e[42]!==f||e[43]!==I.length||e[44]!==a||e[45]!==E||e[46]!==v||e[47]!==s||e[48]!==p||e[49]!==y||e[50]!==x||e[51]!==i||e[52]!==L?(le=I.length>0?n.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[n.jsx("span",{className:"shrink-0 typography-micro text-start text-muted-foreground",children:f.length>0?i("contextPanel.browser.devServers.justStarted"):i("contextPanel.browser.devServers.title")}),p&&!x?n.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.remoteOnly")}):null,n.jsx(ps,{outerClassName:"min-h-0",className:"flex flex-col gap-1 pe-0.5",disableHorizontal:true,children:L.map(H=>n.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[n.jsxs(yt,{type:"button",variant:"outline",size:"sm",className:Ye("min-w-0 flex-1 justify-start gap-2",p&&"cursor-default opacity-60"),"aria-disabled":p||void 0,onClick:()=>{p||(A2(a),s(H.url))},children:[v?n.jsx("span",{className:"shrink-0",role:"img","aria-label":y??i("contextPanel.browser.spaceAddress"),title:y??i("contextPanel.browser.spaceAddress"),children:n.jsx(ue,{name:"instance",className:"size-3.5","aria-hidden":"true"})}):n.jsx(ue,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsxs("span",{className:"truncate",children:[xo(H.url)||H.url,n.jsx("span",{className:"typography-micro text-muted-foreground",children:q2(H.url)})]}),x?n.jsx("span",{className:"ms-auto shrink-0 text-muted-foreground",role:"img","aria-label":i("contextPanel.browser.devServers.spaceOnlyDesktop"),title:i("contextPanel.browser.devServers.spaceOnlyDesktop"),children:n.jsx(ue,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):H.folderName?n.jsxs("span",{className:"ms-auto flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",title:H.directory,children:[n.jsx(ue,{name:"folder",className:"size-3 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"truncate",dir:"auto",children:H.folderName})]}):null]}),H.announced?null:n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{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:()=>z2(H.port),"aria-label":i("contextPanel.browser.devServers.hide",{port:H.port}),children:n.jsx(ue,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})}),n.jsx(Dt,{sideOffset:6,children:i("contextPanel.browser.devServers.hide",{port:H.port})})]})]},H.port))}),E>0?n.jsx(yt,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:()=>{W2(),j(true)},children:E===1?i("contextPanel.browser.devServers.showHiddenSingle",{count:E}):i("contextPanel.browser.devServers.showHiddenPlural",{count:E})}):null]}):null,e[42]=f,e[43]=I.length,e[44]=a,e[45]=E,e[46]=v,e[47]=s,e[48]=p,e[49]=y,e[50]=x,e[51]=i,e[52]=L,e[53]=le):le=e[53];let $;e[54]!==I.length||e[55]!==d.kind||e[56]!==i?($=I.length===0&&d.kind==="unavailable"?n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.unavailable")}):null,e[54]=I.length,e[55]=d.kind,e[56]=i,e[57]=$):$=e[57];let re;return e[58]!==G||e[59]!==le||e[60]!==$?(re=n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[D,G,le,$]}),e[58]=G,e[59]=le,e[60]=$,e[61]=re):re=e[61],re};function X2(t){return t.projects}function Y2(t){return t.availableWorktreesByProject}function J2(t){return{path:t.path,projectPath:t.path}}function Q2(t){const[e,s]=t;return s.map(r=>({path:r.path,projectPath:e}))}const ek=80,tk=Mt({reasonCode:br("model_download_in_progress")}),sk=t=>{const e=qe.c(37),{channel:s}=t,{t:r}=gt();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Promise.resolve(),e[0]=o):o=e[0];const a=c.useRef(o);let i;e[1]!==s?(i=D=>{a.current=a.current.then(()=>s.send(D)).catch(nk)},e[1]=s,e[2]=i):i=e[2];const u=i;let d;e[3]!==u?(d=D=>u({type:"insert",text:D}),e[3]=u,e[4]=d):d=e[4];let l;e[5]!==r?(l=D=>{tk.safeParse(D).success||Fe.error(r("chat.dictation.failed"),{description:D.message})},e[5]=r,e[6]=l):l=e[6];let f;e[7]!==d||e[8]!==l?(f={onTranscript:d,onError:l},e[7]=d,e[8]=l,e[9]=f):f=e[9];const{status:m,errorReason:p,partialTranscript:h,subscribeLevel:x,startDictation:g,confirmDictation:v,cancelDictation:y,discardFailedDictation:C}=Xg(f);let S,N;e[10]!==y||e[11]!==s||e[12]!==v||e[13]!==g?(S=()=>s.subscribe(D=>{D.action==="start"?g():D.action==="finish"?v():y()}),N=[y,s,v,g],e[10]=y,e[11]=s,e[12]=v,e[13]=g,e[14]=S,e[15]=N):(S=e[14],N=e[15]),c.useEffect(S,N);const F=c.useRef(false);let _,M;e[16]!==C||e[17]!==h||e[18]!==u||e[19]!==m?(_=()=>{if(m!=="failed")return;const D=h.trim();D&&u({type:"insert",text:D}),F.current=true,C()},M=[C,h,u,m],e[16]=C,e[17]=h,e[18]=u,e[19]=m,e[20]=_,e[21]=M):(_=e[20],M=e[21]),c.useEffect(_,M);let B;e[22]!==p||e[23]!==m||e[24]!==r?(B=m==="recording"&&p==="model_download_in_progress"?r("chat.dictation.downloadingModel"):"",e[22]=p,e[23]=m,e[24]=r,e[25]=B):B=e[25];const T=B,I=m==="recording"?"recording":m==="uploading"?"processing":m==="idle"?"idle":null;let b;e[26]===Symbol.for("react.memo_cache_sentinel")?(b={phase:"idle",note:""},e[26]=b):b=e[26];const w=c.useRef(b);let j,R;e[27]!==T||e[28]!==I||e[29]!==u?(j=()=>{if(!I)return;const D=w.current;if(!(D.phase===I&&D.note===T)){if(w.current={phase:I,note:T},I==="idle"){u({type:"voice",phase:I,failed:F.current}),F.current=false;return}u(T?{type:"voice",phase:I,note:T}:{type:"voice",phase:I})}},R=[T,I,u],e[27]=T,e[28]=I,e[29]=u,e[30]=j,e[31]=R):(j=e[30],R=e[31]),c.useEffect(j,R);let L,E;return e[32]!==s||e[33]!==m||e[34]!==x?(L=()=>{if(m!=="recording")return;let D=0,U=false;const V=x(W=>{D=Math.max(D,W)}),J=setInterval(()=>{if(U)return;const W=D;D=0,U=true,s.send({type:"level",level:W}).catch(rk).finally(()=>{U=false})},ek);return()=>{clearInterval(J),V()}},E=[s,m,x],e[32]=s,e[33]=m,e[34]=x,e[35]=L,e[36]=E):(L=e[35],E=e[36]),c.useEffect(L,E),null};function nk(){}function rk(){}const ok=(t,e)=>{const s=Jg(t);if(!s||s.chords.length!==1)return null;const{modifiers:r,key:o}=s.chords[0];if(!/^[a-z0-9]$/.test(o))return null;const a=r.has("mod");return{key:o,meta:e?a:r.has("super"),ctrl:e?r.has("ctrl"):a||r.has("ctrl"),alt:r.has("alt"),shift:r.has("shift")}},ak=()=>{const t=qe.c(22),{t:e}=gt(),s=Ut(ik),r=K(lk),[o]=c.useState(ck);let a;e:{if(!o||!s){a=null;break e}let i;t[0]!==r?(i=ok(Es("toggle_dictation",r),Td()),t[0]=r,t[1]=i):i=t[1];let u;t[2]!==e?(u=e("chat.dictation.start"),t[2]=e,t[3]=u):u=t[3];let d;t[4]!==e?(d=e("chat.dictation.cancel"),t[4]=e,t[5]=d):d=t[5];let l;t[6]!==e?(l=e("chat.dictation.insert"),t[6]=e,t[7]=l):l=t[7];let f;t[8]!==e?(f=e("chat.dictation.listening"),t[8]=e,t[9]=f):f=t[9];let m;t[10]!==e?(m=e("chat.dictation.processing"),t[10]=e,t[11]=m):m=t[11];let p;t[12]!==u||t[13]!==d||t[14]!==l||t[15]!==f||t[16]!==m?(p={start:u,cancel:d,insert:l,listening:f,processing:m},t[12]=u,t[13]=d,t[14]=l,t[15]=f,t[16]=m,t[17]=p):p=t[17];let h;t[18]===Symbol.for("react.memo_cache_sentinel")?(h={mic:Mr.mic,close:Mr.close,check:Mr.check,loader:Mr["loader-4"]},t[18]=h):h=t[18];let x;t[19]!==i||t[20]!==p?(x={shortcut:i,labels:p,icons:h},t[19]=i,t[20]=p,t[21]=x):x=t[21],a=x}return a};function ik(t){return t.dictationEnabled}function lk(t){return t.shortcutOverrides}function ck(){return!zn()&&Yg()}const dk=3e4,uk=3,fk=250,pk={attempts:0,windowStartedAt:null},mk=(t,e)=>{const s=t.windowStartedAt===null||e-t.windowStartedAt>=dk,r=s?0:t.attempts;return r>=uk?null:{delayMs:fk*2**r,state:{attempts:r+1,windowStartedAt:s?e:t.windowStartedAt}}},hk=-3,Br=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",Pn=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},gk=(t,{initialUrl:e,onUrlChange:s})=>{const[r,o]=c.useState(e?{kind:"loading",url:e}:Qg),[a,i]=c.useState(e),[u,d]=c.useState(""),[l,f]=c.useState(false),[m,p]=c.useState(false),h=c.useRef(s);h.current=s;const x=c.useRef(pk);return c.useEffect(()=>{if(!t)return;const g=()=>{try{const I=t.getURL();return Br(I)?I:""}catch{return""}},v=()=>{try{f(t.canGoBack()),p(t.canGoForward())}catch{}},y=I=>{Br(I)&&(i(I),h.current(I))},C=()=>{const I=g();o({kind:"loading",url:I})},S=()=>{const I=g();let b="";try{b=t.getTitle()||""}catch{b=""}d(b),y(I),v(),o(w=>w.kind==="failed"?w:{kind:"ready",url:I,title:b})},N=I=>{const b=Pn(I);Br(b.url)&&(y(b.url),v())},F=I=>{const b=Pn(I),w=Array.isArray(b.favicons)?b.favicons.find(Boolean):"",j=g();if(!w||!j)return;let R=-1;try{R=t.getWebContentsId()}catch{return}!Number.isFinite(R)||R<0||uu.getState().resolve(j,w,R)},_=I=>{const b=Pn(I);typeof b.title=="string"&&d(b.title)},M=I=>{const b=Pn(I);if(b.isMainFrame===false)return;const w=typeof b.errorCode=="number"?b.errorCode:0;w!==hk&&o({kind:"failed",url:Br(b.validatedURL)?b.validatedURL:g(),code:w,description:typeof b.errorDescription=="string"?b.errorDescription:""})};let B=null;const T=()=>{const I=g(),b=mk(x.current,Date.now());if(!b){o({kind:"failed",url:I,code:0,description:"",crashed:true});return}x.current=b.state,o({kind:"loading",url:I}),B=setTimeout(()=>{B=null;try{t.reload()}catch{o({kind:"failed",url:I,code:0,description:"",crashed:true})}},b.delayMs)};t.addEventListener("did-start-loading",C),t.addEventListener("did-stop-loading",S),t.addEventListener("did-navigate",N),t.addEventListener("did-navigate-in-page",N),t.addEventListener("page-title-updated",_),t.addEventListener("page-favicon-updated",F),t.addEventListener("did-fail-load",M),t.addEventListener("render-process-gone",T),t.addEventListener("crashed",T);try{!t.isLoading()&&g()&&S()}catch{}return()=>{B!==null&&clearTimeout(B),t.removeEventListener("render-process-gone",T),t.removeEventListener("crashed",T),t.removeEventListener("did-start-loading",C),t.removeEventListener("did-stop-loading",S),t.removeEventListener("did-navigate",N),t.removeEventListener("did-navigate-in-page",N),t.removeEventListener("page-title-updated",_),t.removeEventListener("page-favicon-updated",F),t.removeEventListener("did-fail-load",M)}},[t]),{status:r,url:a,title:u,canGoBack:l,canGoForward:m}},xk=240,bk=(t,e,s)=>{const r=t??e;return s<=r?r:Math.ceil(s)+xk},Ul=(t,e,s)=>{const r=e!==null&&s!==null?s-e:0;return r>0?t+r:t},wk=90,yk=(t,e,s)=>{const[r,o]=c.useState({width:0,height:0}),a=c.useRef(s);return a.current=s,c.useEffect(()=>{const i=t.current;if(!i||!globalThis.ResizeObserver)return;let u=null,d=0,l=null;const f=()=>{const S=i.closest("[data-context-panel]");if(!S||S.dataset.contextZone==="bottom")return null;const N=Number(S.dataset.zoneSize);return N>0?N:null};let m=f(),p=false,h=null;const x=()=>{h=null;const S=e.current;!S||a.current||!u||(l=u.width,S.style.width=`${l}px`)},g=()=>{if(p=false,h!==null&&clearTimeout(h),h=null,l!==null&&(l=null,e.current&&!a.current&&(e.current.style.width="100%")),m=f(),!u)return;const S=u;d=S.width,o(N=>N.width===S.width&&N.height===S.height?N:S)},v=new ResizeObserver(S=>{const N=S[0]?.contentRect;if(!N)return;u={width:N.width,height:N.height},d===0&&(d=N.width);const F=e.current;if(p)h!==null&&clearTimeout(h),h=setTimeout(x,wk);else if(e1()&&F&&!a.current){const _=Ul(d,m,f()),M=bk(Math.max(l??d,_),d,N.width);M!==l&&(l=M,F.style.width=`${M}px`)}hr(g)});v.observe(i);const y=t1(()=>{const S=e.current;!S||a.current||d===0||l!==null||(l=Ul(d,m,f()),S.style.width=`${l}px`,hr(g))}),C=s1(()=>{p=true});return()=>{y(),C(),h!==null&&clearTimeout(h),v.disconnect(),ai(g)}},[e,t]),r},Hl=1e3,Vu=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:true,visibilityProperty:true})},vk=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},Ma=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},Sk=(t,e)=>{const s=c.useRef(0),r=c.useRef(0),o=c.useRef(0),a=c.useRef(null),i=c.useCallback(()=>{if(!t||document.activeElement!==t)return;const u=a.current;u&&u.isConnected&&u!==document.body?u.focus({preventScroll:true}):t.blur()},[t]);return c.useEffect(()=>{if(!t)return;document.activeElement!==t&&(a.current=Ma());const u=()=>{if(document.activeElement!==t)return;const f=e.current,m=s.current>r.current||Date.now()<o.current;f&&Vu(f)&&!m||r.current>0||i()},d=f=>{if(document.activeElement!==t){a.current=vk(f);return}u()},l=f=>{f.target===window&&setTimeout(u,0)};return document.addEventListener("focusin",d,true),window.addEventListener("blur",l,true),()=>{document.removeEventListener("focusin",d,true),window.removeEventListener("blur",l,true)}},[i,e,t]),c.useCallback(async u=>{const d=t!==null&&document.activeElement===t;let l=false;const f=()=>{l&&(l=false,r.current-=1,o.current=Date.now()+Hl,!d&&r.current===0&&i())},m=()=>(l||(l=true,r.current+=1),f);s.current+=1;try{return await u(m)}finally{s.current-=1,o.current=Date.now()+Hl,f(),!d&&r.current===0&&i()}},[i,t])},kk=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),jk=()=>document.visibilityState==="visible",Tk=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,zr=.5,Ck=-3,Ek=4,Ik="persist:openchamber-browser",Uu=(t,e,s)=>ks(t)!==null&&Ic(e)?{icon:"instance",label:s}:void 0,Nk="persist:openchamber-browser-agent",Pk=(t,e=false)=>{const s=ks(t);return s?`openchamber-space-preview:${s}`:e?Nk:Ik},Kl="openchamber:browser-panel-open-tab",Rk=Mt({webContentsId:as(),url:It().min(1),background:ss()}),ql=20,Dk=600,_k=2e4,Gl=15e3,Zl=500,Xl=5e3,Ak=3e4,Ok=3e3,Mk=12e3,Yl=1e3,Fk=250,Lk=Mt({quiet:ss()}),$k=Cn(Mt({answer:It()}).catchall(an())),Bk=wr(It(),an()),zk=Mt({value:an().nullable()}),Wk=Mt({ended:ss().optional(),message:It().nullable().optional()}),Vk=Mt({type:br("voice"),action:Qd(["start","finish","cancel"])}),Jl=()=>new Promise(t=>{let e=0,s=0,r=0,o;const a=l=>{clearTimeout(o),t(l)},i=()=>{e+=1,e>=2?a(true):requestAnimationFrame(i)},u=()=>{s=e,r=performance.now()+Yl,o=setTimeout(d,Yl)},d=()=>{e>s||performance.now()-r>Fk?u():a(false)};requestAnimationFrame(i),u()}),Ql=(t,e)=>{if(!t||Vu(t))return()=>{};const s=t.getBoundingClientRect(),r=t.style.cssText;return Object.assign(t.style,{position:"fixed",top:`${s.top}px`,left:`${Math.max(0,Math.min(s.left,window.innerWidth-s.width))}px`,width:`${s.width}px`,height:`${s.height}px`,visibility:"visible",opacity:"0",...e==="input"?{pointerEvents:"auto",zIndex:"-1"}:{pointerEvents:"none"}}),()=>{t.style.cssText=r}},Uk=({initialUrl:t,directory:e,siteDirectory:s,tabID:r,ownerSessionId:o,visible:a})=>{const{t:i}=gt(),{currentTheme:u}=bo(),d=c.useRef(null),[l,f]=c.useState(null),m=c.useCallback(q=>{d.current=q,f(q)},[]),p=K(q=>q.setContextPanelTabTargetPath),h=K(q=>q.agentBrowserSharesLogins),x=Pk(s,o!==null&&!h),g=c.useRef(Rn(t)),v=g.current!==nn?g.current:"",[y,C]=c.useState(v?null:nn),S=wi(s),[N,F]=c.useState(v),[_,M]=c.useState(false),[B,T]=c.useState(false),[I,b]=c.useState(0),w=c.useRef(0),[j,R]=c.useState(false),[L,E]=c.useState(Sr),D=c.useRef(L);D.current=L;const U=c.useRef([]),[V,J]=c.useState("system"),W=c.useRef(null),G=c.useRef(null),le=ds(e),$=c.useRef(!!v&&!If(le,r)),re=c.useRef(null);c.useEffect(()=>{Ec(le,r)},[le,r]);const H=c.useRef(false),P=c.useRef(Date.now()),ee=c.useCallback(q=>{!q||q===nn||!e||!r||p(e,r,q)},[e,r,p]),oe=gk(l,{initialUrl:v,onUrlChange:c.useCallback(q=>{const se=Js(q);F(se),ee(se)},[ee])}),[de,he]=c.useState(null),[Z,ce]=c.useState(ks(s)===null);c.useEffect(()=>{const q=ks(s);if(q===null){ce(true);return}let se=true;return ce(false),en("desktop_space_preview_prepare",{spaceId:q}).then(()=>{se&&ce(true)}).catch(()=>{se&&he(v||"http://localhost/")}),()=>{se=false}},[s,v]);const ae=n1(e),te=r1(),pe=ak(),Te=oe.status.kind==="loading",Ae=_n(Iu(s)),Pe=_n(q=>q.recordVisit),ze=_n(q=>q.forget);c.useEffect(()=>{oe.status.kind==="ready"&&Pe(s,{url:Js(oe.status.url),title:oe.status.title})},[s,oe.status,Pe]);const Oe=c.useMemo(()=>Eu(Ae,N),[Ae,N]),me=c.useCallback(q=>{const se=Rn(q);se!==nn&&($.current=false,F(se),he(null),Oi(se,s).then(De=>{const we=d.current;if(!we){C(De);return}try{we.loadURL(De)}catch{C(De)}}).catch(De=>{De instanceof Mi&&he(se)}))},[s]);c.useEffect(()=>{if(!v)return;let q=true;return Oi(v,s).then(se=>{q&&C(se)}).catch(se=>{if(q){if(se instanceof Mi){he(v),$.current=false,C(nn);return}C(v)}}),()=>{q=false}},[]);const be=c.useRef(false);c.useEffect(()=>{if(!l)return;const q=()=>{be.current=true};return l.addEventListener("dom-ready",q),l.addEventListener("did-fail-load",q),()=>{l.removeEventListener("dom-ready",q),l.removeEventListener("did-fail-load",q)}},[l]);const Ce=c.useCallback(async()=>{const q=Date.now()+Gl;for(;!(d.current&&be.current)&&Date.now()<q;)await new Promise(se=>setTimeout(se,100));return d.current},[]),$e=c.useCallback(async(q=8e3)=>{const se=Date.now();for(;;){const De=d.current;if(!De)return false;let we=false;try{we=De.isLoading()}catch{return false}if(!we)return true;if(Date.now()-se>q)return false;await new Promise(rt=>setTimeout(rt,120))}},[]),We=c.useCallback(async(q,se)=>{const De=t2({quietMs:Zl,maxMs:se});let we;const rt=new Promise(ft=>{we=setTimeout(()=>ft(null),se+1e3)});try{const ft=Lk.safeParse(await Promise.race([q.executeJavaScript(De,false),rt]));return ft.success&&ft.data.quiet}catch{return false}finally{clearTimeout(we)}},[]),_e=c.useCallback(async(q,se=Ak)=>{const De=Date.now(),we=await $e(Math.min(25e3,Math.max(0,se-Xl))),rt=se-(Date.now()-De),ft=we&&rt>Zl&&await We(q,Math.min(Xl,rt));let nt="";try{nt=q.getTitle()||""}catch{nt=""}return{title:nt,settled:ft}},[$e,We]),Ue=c.useCallback(async(q,se={})=>{const De=d.current;if(!De)throw new Error("The browser panel is not ready");try{return await en("desktop_browser_drive",{...se,webContentsId:De.getWebContentsId(),op:q})}catch(we){const rt=(we instanceof Error?we.message:String(we)).replace(/^Error invoking remote method '[^']*': (?:Error: )?/,"");throw rt.includes("Unknown desktop command")?new Error("This OpenChamber desktop app is older than its server and cannot run this browser action. Update the desktop app."):new Error(rt)}},[]),Xe=c.useCallback(async q=>{const se=Ql(W.current,"input");let De;try{if(!await Jl())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 the page takes no input. browser.snapshot still reads the page.");const we=new Promise((ut,Nt)=>{De=setTimeout(()=>Nt(new Error("The page did not take the input in time. Take a snapshot to see its state.")),Mk)}),rt=d.current&&document.activeElement!==d.current?Ma():null;let ft=false;const nt=ut=>{ut.isTrusted&&(ft=true)};document.addEventListener("pointerdown",nt,true),document.addEventListener("keydown",nt,true);try{return await Promise.race([q(),we])}finally{document.removeEventListener("pointerdown",nt,true),document.removeEventListener("keydown",nt,true),!ft&&rt?.isConnected&&rt!==document.body&&Ma()!==rt&&document.activeElement!==d.current&&rt.focus({preventScroll:true})}}finally{clearTimeout(De),se()}},[]),Me=c.useMemo(()=>S2({drive:Ue,withInput:Xe}),[Ue,Xe]),ot=c.useCallback(async(q,se)=>zk.parse(await Ue("annotate",{expression:q,sessionId:se})).value,[Ue]),ye=c.useMemo(()=>({executeJavaScript:async(q,se)=>{const De=d.current;if(!De)throw new Error("Browser view is not available");return De.executeJavaScript(q,se)},capturePage:async()=>{const q=d.current;if(!q)return null;const se=q.getWebContentsId();return Number.isFinite(se)?await en("desktop_browser_capture_page",{webContentsId:se}):null}}),[]),[Ve,lt]=c.useState(null),ct=c.useCallback(async(q,se)=>{for(;!se.done;){let De;try{De=Wk.parse(await Ue("annotationMessage",{sessionId:se.id,timeoutMs:2e4}))}catch{return}if(De.ended){await new Promise(rt=>setTimeout(rt,150));continue}if(!De.message)continue;let we=null;try{we=Vk.parse(JSON.parse(De.message))}catch{continue}for(const rt of[...q])rt(we)}},[Ue]),st=c.useRef(null),k=c.useRef(0),Y=c.useCallback(()=>{const q=st.current;st.current=null,M(false),lt(null),q&&(q.cancelled=true,Ue("annotationCancel",{sessionId:q.id}).catch(()=>{})),Ki(ye)},[ye,Ue]),Ne=c.useCallback(()=>{if(_){Y();return}if(!oe.url){Fe.error(i("contextPanel.browser.annotate.noPage"));return}const q=o1(u.metadata.variant==="light"?"light":"dark");k.current+=1;const se={id:k.current,done:false,cancelled:false};st.current=se;const De=()=>st.current===se;M(true);const we=new Set;pe&&lt({send:async ft=>{await Ue("annotationSend",{message:ft})},subscribe:ft=>(we.add(ft),()=>{we.delete(ft)})});const rt={...ye,runIsolated:async ft=>{pe&&ct(we,se);try{return await ot(ft,se.id)}catch(nt){if(se.done=true,se.cancelled)return null;throw De()&&lt(null),nt}}};a1({host:rt,theme:q,labels:te,voice:pe}).finally(()=>{se.done=true,De()&&(st.current=null,lt(null),M(false))}).then(async ft=>{!ft||se.cancelled||await ae(ft)}).catch(()=>{se.cancelled||Fe.error(i("contextPanel.browser.annotate.failed"))})},[ye,pe,ae,Y,u,Ue,_,ct,oe.url,te,ot,i]);c.useEffect(()=>{if(!_)return;const q=se=>{rd(se)||se.key!=="Escape"||(se.preventDefault(),se.stopImmediatePropagation(),Y())};return window.addEventListener("keydown",q,true),()=>window.removeEventListener("keydown",q,true)},[Y,_]);const Re=c.useCallback(q=>a2(q,se=>en("desktop_browser_stage_upload",{files:se}).then(De=>De.paths)),[]),Ie=c.useCallback(async(q,se,De)=>{const we=await Ce();if(!we)throw new Error("The browser panel is not ready");const rt=()=>{Vl(se.viewport)&&(E(_a(se.viewport)),R(true))};if(q==="browser.back"||q==="browser.forward"){const Et=q==="browser.back";if(!(Et?we.canGoBack():we.canGoForward()))throw new Error(Et?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Et?we.goBack():we.goForward(),await new Promise(is=>setTimeout(is,150)),await $e();let Wt="";try{Wt=we.getTitle()||""}catch{Wt=""}return{url:Js(we.getURL()),title:Wt}}if(q==="browser.capture"){const Et=Ql(W.current,"capture");try{if(!await Jl())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(we,Ok);const Ft=await ye.capturePage();if(!Ft)throw new Error("The page could not be captured");let Wt="";try{Wt=we.getTitle()||""}catch{Wt=""}return{...Ft,url:Js(we.getURL()),title:Wt,viewport:Fr(D.current)}}finally{Et()}}if(q==="browser.resize"){if(!Vl(se.viewport))throw new Error("viewport is required");return rt(),await new Promise(Et=>setTimeout(Et,200)),await $e(),{viewport:Fr(_a(se.viewport))}}if(q==="browser.open"){const Et=typeof se.url=="string"?se.url:"";if(!Et)throw new Error("url is required");return rt(),me(Et),await new Promise(Ft=>setTimeout(Ft,150)),{url:Rn(Et),...await _e(we),opened:true,viewport:Fr(D.current)}}if(q==="browser.settle"){const Et=as().safeParse(se.budgetMs);return _e(we,Et.success?Et.data:void 0)}await $e();const ft=i2.parse(se);if(q==="browser.dialog")return Me.answerDialog(ft);q!=="browser.snapshot"&&await Me.ensureNoDialog();const nt=["browser.click","browser.type","browser.press","browser.hover","browser.drag"].includes(q);let ut=()=>{};nt&&(await en("desktop_browser_keep_page_focused",{webContentsId:we.getWebContentsId()}).then(Ft=>Ft.focused===true).catch(()=>false)||(ut=De(),we.focus({preventScroll:true})));let Nt;try{switch(q){case"browser.snapshot":{const Et=U.current,Ft=await Me.snapshot(ft);return Ft.viewport=Fr(D.current),Et.length>0&&(Ft.consoleProblems=[...Et]),Ft}case"browser.click":Nt=await Me.click(ft);break;case"browser.hover":Nt=await Me.hover(ft);break;case"browser.drag":Nt=await Me.drag(ft);break;case"browser.type":Nt=await Me.type(ft);break;case"browser.press":Nt=await Me.press(ft);break;case"browser.select":Nt=await Me.select(ft);break;case"browser.scroll":return Me.scroll(ft);case"browser.inspect":return Me.inspect(ft);case"browser.upload":{if(!ft.upload)throw new Error("The upload came without its files");return Me.upload(ft,await Re(ft.upload))}case"browser.wait":return Me.wait(ft,Et=>new Promise(Ft=>setTimeout(Ft,Et)),()=>Date.now());default:throw new Error(`Unsupported browser action: ${q}`)}}finally{ut()}return await new Promise(Et=>setTimeout(Et,150)),await $e(),{url:Js(we.getURL()),...Nt}},[ye,me,Me,_e,Re,$e,We,Ce]);c.useEffect(()=>{if(!l||o===null)return;const q=()=>{Ue("dialogPolicy",{auto:true}).catch(()=>{})};return l.addEventListener("did-attach",q),l.addEventListener("did-start-loading",q),l.addEventListener("dom-ready",q),()=>{l.removeEventListener("did-attach",q),l.removeEventListener("did-start-loading",q),l.removeEventListener("dom-ready",q)}},[Ue,o,l]);const Ee=Sk(l,W),[Ge,Be]=c.useState(false),Ze=c.useCallback(async(q,se,De)=>{if(o===null)return De();if(q==="browser.dialog")throw new Error('This tab answers its dialogs as they open, no by default. To answer yes, repeat the action that opened it with dialog: "accept".');const we=Date.now()+Gl;for(;;)try{await Ue("dialogPolicy",{auto:true});break}catch(Nt){if(Date.now()>we)throw Nt;await new Promise(Et=>setTimeout(Et,100))}await Ue("armDialog",{accept:se});let rt;try{rt=await De()}finally{await Ue("armDialog",{accept:false}).catch(()=>null)}const ft=$k.safeParse(await Ue("takeAnsweredDialogs").catch(()=>[])),nt=Bk.safeParse(rt);if(!ft.success||ft.data.length===0||!nt.success)return rt;const ut={...nt.data,dialogs:ft.data};return ft.data.some(Nt=>Nt.answer==="dismissed")&&(ut.note='The page showed a dialog and it was answered no. To answer yes, repeat the action with dialog: "accept".'),ut},[Ue,o]),et=c.useRef(Promise.resolve()),wt=c.useCallback((q,se)=>{Be(true);const De=et.current.catch(()=>{}).then(()=>Ee(we=>Ze(q,se.dialog==="accept",()=>Ie(q,se,we))));return et.current=De,De},[Ze,Ee,Ie]),Qe=c.useCallback(()=>{const q=d.current;if(!q)return{title:"",url:""};let se="",De="";try{se=q.getTitle()||""}catch{se=""}try{De=Js(q.getURL())}catch{De=""}return{title:se,url:De}},[]);c.useEffect(()=>S0({tabId:r,directory:le,ownerSessionId:o,describe:Qe,run:wt}),[Qe,o,wt,le,r]),c.useEffect(()=>{const q=ye;return()=>{Ki(q)}},[ye]),c.useEffect(()=>{if(!l)return;const q=De=>{const we=De;if(typeof we.level!="number"||we.level<2)return;const rt=we.sourceId?`${we.sourceId}${we.line?`:${we.line}`:""}`:"";U.current.push({level:we.level>=3?"error":"warning",message:String(we.message??"").slice(0,400),source:rt}),U.current.length>ql&&U.current.splice(0,U.current.length-ql)},se=()=>{U.current=[]};return l.addEventListener("console-message",q),l.addEventListener("did-start-loading",se),()=>{l.removeEventListener("console-message",q),l.removeEventListener("did-start-loading",se)}},[l]);const dt=c.useRef(new Set),at=c.useCallback(q=>{dt.current.clear(),me(q)},[me]),z=c.useRef(oe.status);z.current=oe.status;const fe=c.useRef(false);oe.status.kind==="ready"&&oe.status.url&&(fe.current=true),c.useEffect(()=>Nf(le,r,q=>{Df(z.current,fe.current)&&at(q)}),[at,le,r]),c.useEffect(()=>{if(!l)return;const q=De=>{const we=Pn(De),rt=typeof we.url=="string"?we.url:"";!rt||!Fi(rt,s)||(De.preventDefault(),me(rt))},se=De=>{const we=Pn(De);if(we.isMainFrame===false||we.errorCode===-3)return;const rt=typeof we.validatedURL=="string"?we.validatedURL:"";!rt||!Fi(rt,s)||dt.current.has(rt)||(dt.current.add(rt),me(rt))};return l.addEventListener("will-navigate",q),l.addEventListener("did-fail-load",se),()=>{l.removeEventListener("will-navigate",q),l.removeEventListener("did-fail-load",se)}},[s,me,l]),c.useEffect(()=>{if(!l)return;const q=se=>{if(!(se instanceof CustomEvent))return;const De=Rk.safeParse(se.detail);if(!De.success)return;let we=-1;try{we=l.getWebContentsId()}catch{return}if(De.data.webContentsId===we){if(o!==null){C0(De.data.url,{directory:le,sessionId:o});return}K.getState().openContextBrowser(le,De.data.url,{reveal:!De.data.background})}};return window.addEventListener(Kl,q),()=>window.removeEventListener(Kl,q)},[o,le,l]);const ke=c.useCallback(q=>{const se=Math.min(Ek,Math.max(Ck,q));w.current=se,b(se);try{d.current?.setZoomLevel(se)}catch{}},[]);c.useEffect(()=>{const q=se=>{if(!(se instanceof CustomEvent))return;const De=se.detail,we=d.current;!we||document.activeElement!==we||(De==="zoom-in"?ke(w.current+zr):De==="zoom-out"?ke(w.current-zr):De==="zoom-reset"&&ke(0))};return window.addEventListener("openchamber:zoom",q),()=>window.removeEventListener("openchamber:zoom",q)},[ke]);const ie=c.useCallback(q=>{en("desktop_browser_clear_data",{partition:x,cookies:q==="cookies",cache:q==="cache"}).then(()=>{Fe.success(i(q==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{d.current?.reloadIgnoringCache()}catch{}}).catch(()=>Fe.error(i("contextPanel.browser.clearFailed")))},[x,i]),xe=c.useCallback(q=>{J(q);const se=d.current;if(!se)return;let De=-1;try{De=se.getWebContentsId()}catch{return}en("desktop_browser_set_color_scheme",{webContentsId:De,scheme:q}).catch(we=>{J("system"),Fe.error(we instanceof Error?we.message:i("contextPanel.browser.device.schemeFailed"))})},[i]),Le=c.useCallback(()=>{try{Te?d.current?.stop():d.current?.reload()}catch{}},[Te]),Ke=oe.status,ve=c.useSyncExternalStore(kk,jk),je=a&&ve||o!==null||Ge,vt=Js(i1(Ke)),ne=Ct(q=>Pf(q.sessions,vt)),Je=c.useRef(false),kt=c.useRef(null);c.useEffect(()=>{const q=ft=>{T(true);const nt=setTimeout(()=>{try{d.current?.reload()}catch{}},ft);return()=>clearTimeout(nt)};if(Je.current&&!ne&&(kt.current=Date.now()),Je.current=ne,Ke.kind==="loading")return;const se=$.current||re.current===Ke;if($.current&&(Ke.kind==="failed"||Ke.kind==="ready"&&Ke.url)&&($.current=false,re.current=Ke),Ke.kind==="failed"){const ft=Rf(Ke,{run:G.current,restored:se,watched:je,now:Date.now(),actionRunning:ne,actionStoppedAt:kt.current});if(G.current=ft.run,ft.next==="retry")return q(ft.delayMs);T(ft.next==="pause");return}if(G.current=null,Ke.kind!=="ready"||!Ke.url||!Ic(Ke.url)){H.current=true,T(false);return}if(se||H.current||Date.now()-P.current>_k){H.current=true,T(false);return}let De=false,we=null;return(ks(s)?Promise.resolve(null):s0(Js(Ke.url))).then(ft=>{if(!De){if(ft===null||ft<500){H.current=true,T(false);return}we=q(Dk)}}),()=>{De=true,we?.()}},[ne,s,Ke,je]);const bt=oe.status.kind==="failed"&&!B?oe.status:null,_t=yk(W,d,kr(L)!==null),He=I2(L,_t),pt=q=>{if(!(!(Td()?q.metaKey&&!q.ctrlKey:q.ctrlKey&&!q.metaKey)||q.altKey||q.repeat||q.key.toLowerCase()!=="r")){q.preventDefault();try{q.shiftKey?d.current?.reloadIgnoringCache():d.current?.reload()}catch{}}};return n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",onKeyDown:pt,children:[Ve?n.jsx(sk,{channel:Ve}):null,n.jsx(Ou,{address:N,onAddressChange:F,onSubmit:at,suggestions:Oe,onForgetSuggestion:q=>ze(s,q),onBack:()=>{try{d.current?.goBack()}catch{}},onForward:()=>{try{d.current?.goForward()}catch{}},onReload:Le,onOpenExternal:()=>{Wn(oe.url||N)},addressMark:Uu(s,N,S??i("contextPanel.browser.spaceAddress")),canOpenExternal:ks(s)===null,canGoBack:oe.canGoBack,canGoForward:oe.canGoForward,isLoading:Te,onAnnotate:Ne,isAnnotating:_,onOpenDevTools:()=>{try{d.current?.openDevTools()}catch{}},onHardReload:()=>{try{d.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>ke(I+zr),onZoomOut:()=>ke(I-zr),onZoomReset:()=>ke(0),zoomPercent:Math.round(Math.pow(1.2,I)*100),onClearCookies:()=>ie("cookies"),onClearCache:()=>ie("cache"),onToggleDeviceBar:()=>R(q=>!q),isDeviceBarOpen:j}),j?n.jsx(D2,{viewport:L,onViewportChange:E,colorScheme:V,onColorSchemeChange:xe,scale:He?.scale??1,panelSize:_t}):null,n.jsxs("div",{ref:W,className:Ye("relative min-h-0 flex-1 overflow-hidden bg-background",He&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[y!==null&&Z?n.jsx("webview",{ref:m,src:y,partition:x,allowpopups:"true",webpreferences:o!==null?"backgroundThrottling=no":void 0,style:He?{width:`${He.width}px`,height:`${He.height}px`,transform:`scale(${He.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,y!==null&&!v&&!oe.url&&!Te?n.jsx(Wu,{onOpen:at,directory:s,visible:a}):null,B?n.jsxs("div",{role:"status",className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx(dd,{className:"mb-1 size-5 text-muted-foreground","aria-hidden":true}),n.jsx("span",{className:"typography-ui-header text-foreground",children:i("contextPanel.browser.waitingForServer")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.waitingForServerHint")})]}):null,de?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[ks(s)!==null?n.jsx(ue,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:i("contextPanel.browser.tunnelFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i(ks(s)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:de})})]}):null,bt&&!de?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:bt.crashed?i("contextPanel.browser.crashed"):i("contextPanel.browser.loadFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:bt.crashed?i("contextPanel.browser.crashedHint"):bt.description||i("contextPanel.browser.loadFailedUnknown")})]}):null,Te?n.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:n.jsx("div",{className:"h-full w-1/3 bg-[var(--primary)]"})}):null]})]})},Hk=t=>{const e=qe.c(75),{initialUrl:s,directory:r,siteDirectory:o,tabID:a,visible:i}=t,{t:u}=gt(),d=K(qk);let l;e[0]!==s?(l=Rn(s),e[0]=s,e[1]=l):l=e[1];const f=l,m=f!==nn?f:"",[p,h]=c.useState(m);let x;e[2]!==o||e[3]!==m?(x=zo(m,o),e[2]=o,e[3]=m,e[4]=x):x=e[4];const[g,v]=c.useState(x);let y;e[5]!==o||e[6]!==m?(y=Hc(m,o)?m:"",e[5]=o,e[6]=m,e[7]=y):y=e[7];const[C,S]=c.useState(y);let N;e[8]!==o?(N=ks(o),e[8]=o,e[9]=N):N=e[9];const F=N!==null,_=wi(o);let M;e[10]!==m?(M=m?[m]:[],e[10]=m,e[11]=M):M=e[11];const[B,T]=c.useState(M),[I,b]=c.useState(m?0:-1),[w,j]=c.useReducer(Gk,0);let R,L;e[12]!==a||e[13]!==r?(R=()=>{Ec(ds(r),a)},L=[r,a],e[12]=a,e[13]=r,e[14]=R,e[15]=L):(R=e[14],L=e[15]),c.useEffect(R,L);let E;e[16]!==d||e[17]!==a||e[18]!==r?(E=ze=>{!ze||ze===nn||!r||!a||d(r,a,ze)},e[16]=d,e[17]=a,e[18]=r,e[19]=E):E=e[19];const D=E;let U;e[20]!==o?(U=Iu(o),e[20]=o,e[21]=U):U=e[21];const V=_n(U),J=_n(Zk),W=_n(Xk);let G;e[22]!==p||e[23]!==V?(G=Eu(V,p),e[22]=p,e[23]=V,e[24]=G):G=e[24];const le=G;let $;e[25]!==o||e[26]!==I||e[27]!==D||e[28]!==J?($=ze=>{const Oe=Rn(ze);if(Oe===nn)return;h(Oe);const me=zo(Oe,o);v(me),S(me?"":Oe),D(Oe),J(o,{url:Oe}),T(be=>{const Ce=I>=0?be.slice(0,I+1):[];return Ce[Ce.length-1]===Oe?(b(Ce.length-1),Ce):(b(Ce.length),[...Ce,Oe])})},e[25]=o,e[26]=I,e[27]=D,e[28]=J,e[29]=$):$=e[29];const re=$;let H;e[30]!==o||e[31]!==B||e[32]!==D?(H=ze=>{const Oe=B[ze];if(!Oe)return;b(ze),h(Oe);const me=zo(Oe,o);v(me),S(me?"":Oe),D(Oe)},e[30]=o,e[31]=B,e[32]=D,e[33]=H):H=e[33];const P=H;let ee;e[34]!==o||e[35]!==W?(ee=ze=>W(o,ze),e[34]=o,e[35]=W,e[36]=ee):ee=e[36];let oe,de;e[37]!==P||e[38]!==I?(oe=()=>P(I-1),de=()=>P(I+1),e[37]=P,e[38]=I,e[39]=oe,e[40]=de):(oe=e[39],de=e[40]);let he;e[41]!==p||e[42]!==g?(he=()=>{Wn(g||p)},e[41]=p,e[42]=g,e[43]=he):he=e[43];let Z;e[44]!==_||e[45]!==u?(Z=_??u("contextPanel.browser.spaceAddress"),e[44]=_,e[45]=u,e[46]=Z):Z=e[46];let ce;e[47]!==p||e[48]!==o||e[49]!==Z?(ce=Uu(o,p,Z),e[47]=p,e[48]=o,e[49]=Z,e[50]=ce):ce=e[50];const ae=!C,te=I>0,pe=I>=0&&I<B.length-1;let Te;e[51]!==p||e[52]!==re||e[53]!==le||e[54]!==ee||e[55]!==oe||e[56]!==de||e[57]!==he||e[58]!==ce||e[59]!==ae||e[60]!==te||e[61]!==pe?(Te=n.jsx(Ou,{address:p,onAddressChange:h,onSubmit:re,suggestions:le,onForgetSuggestion:ee,onBack:oe,onForward:de,onReload:j,onOpenExternal:he,addressMark:ce,canOpenExternal:ae,canGoBack:te,canGoForward:pe,isLoading:false}),e[51]=p,e[52]=re,e[53]=le,e[54]=ee,e[55]=oe,e[56]=de,e[57]=he,e[58]=ce,e[59]=ae,e[60]=te,e[61]=pe,e[62]=Te):Te=e[62];let Ae;e[63]!==o||e[64]!==F||e[65]!==g||e[66]!==re||e[67]!==w||e[68]!==u||e[69]!==C||e[70]!==i?(Ae=n.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:C?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[F?n.jsx(ue,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:u(F?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:xo(C)})}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:u("contextPanel.browser.remoteLoopback.hint")})]}):g?n.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}|${w}`):n.jsx(Wu,{onOpen:re,directory:o,visible:i})}),e[63]=o,e[64]=F,e[65]=g,e[66]=re,e[67]=w,e[68]=u,e[69]=C,e[70]=i,e[71]=Ae):Ae=e[71];let Pe;return e[72]!==Te||e[73]!==Ae?(Pe=n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Te,Ae]}),e[72]=Te,e[73]=Ae,e[74]=Pe):Pe=e[74],Pe},Kk=t=>{const e=qe.c(3),[s]=c.useState(Tk);let r;return e[0]!==s||e[1]!==t?(r=s?n.jsx(Uk,{...t}):n.jsx(Hk,{...t}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r};function qk(t){return t.setContextPanelTabTargetPath}function Gk(t){return t+1}function Zk(t){return t.recordVisit}function Xk(t){return t.forget}const Yk=t=>{const e=qe.c(13),{zone:s,children:r}=t,[o]=c.useState(Jk);let a;e[0]!==s?(a=p=>p.body[s],e[0]=s,e[1]=a):a=e[1];const i=yr(a);let u,d;e[2]!==i||e[3]!==o||e[4]!==s?(u=()=>{const p=i??yr.getState().body[s];if(!p){o.remove();return}if(o.parentElement===p)return;const h=document.activeElement;p.moveBefore&&o.isConnected?p.moveBefore(o,null):p.append(o),h instanceof HTMLElement&&o.contains(h)&&document.activeElement!==h&&h.focus({preventScroll:true})},d=[i,o,s],e[2]=i,e[3]=o,e[4]=s,e[5]=u,e[6]=d):(u=e[5],d=e[6]),c.useLayoutEffect(u,d);let l,f;e[7]!==o?(l=()=>()=>o.remove(),f=[o],e[7]=o,e[8]=l,e[9]=f):(l=e[8],f=e[9]),c.useLayoutEffect(l,f);let m;return e[10]!==r||e[11]!==o?(m=yc.createPortal(r,o),e[10]=r,e[11]=o,e[12]=m):m=e[12],m};function Jk(){const t=document.createElement("div");return t.style.display="contents",t}const Qk=200,Hu=t=>`${t.path}:${t.line}:${t.column}`,ec={status:"idle"},e3=t=>{const e=qe.c(9),{searchContents:s,directory:r,query:o,regex:a,includeHidden:i,respectGitignore:u,active:d}=t,[l,f]=c.useState(ec);let m,p;return e[0]!==d||e[1]!==r||e[2]!==i||e[3]!==o||e[4]!==a||e[5]!==u||e[6]!==s?(m=()=>{if(!d||!s||!r||!o.trim()){f(ec);return}const h=new AbortController;let x=false;return f({status:"searching"}),s({directory:r,query:o,regex:a,limit:Qk,includeHidden:i,respectGitignore:u,signal:h.signal}).then(g=>{x||f(g.status==="ok"?{status:"results",matches:g.matches,stopped:g.stopped}:g)}).catch(g=>{x||f({status:"failed",message:g instanceof Error?g.message:String(g)})}),()=>{x=true,h.abort()}},p=[d,r,i,o,a,u,s],e[0]=d,e[1]=r,e[2]=i,e[3]=o,e[4]=a,e[5]=u,e[6]=s,e[7]=m,e[8]=p):(m=e[7],p=e[8]),c.useEffect(m,p),l},gn=t=>{const e=qe.c(5),{className:s,children:r}=t;let o;e[0]!==s?(o=Ye("px-2 py-1 typography-meta text-muted-foreground",s),e[0]=s,e[1]=o):o=e[1];let a;return e[2]!==r||e[3]!==o?(a=n.jsx("li",{className:o,children:r}),e[2]=r,e[3]=o,e[4]=a):a=e[4],a},t3=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},s3=t=>{const e=qe.c(44),{state:s,activeMatchKey:r,onOpen:o,onDragStart:a,onDragEnd:i}=t,{t:u}=gt();switch(s.status){case"idle":return null;case"searching":{let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(ue,{name:"loader-4",className:"h-4 w-4 animate-spin"}),e[0]=m):m=e[0];let p;e[1]!==u?(p=u("sidebarFilesTree.state.searching"),e[1]=u,e[2]=p):p=e[2];let h;return e[3]!==p?(h=n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[m,p]}),e[3]=p,e[4]=h):h=e[4],h}case"unavailable":{let m;e[5]!==u?(m=u("sidebarFilesTree.contentSearch.unavailable"),e[5]=u,e[6]=m):m=e[6];let p;return e[7]!==m?(p=n.jsx(gn,{children:m}),e[7]=m,e[8]=p):p=e[8],p}case"invalid-pattern":{let m;e[9]!==u?(m=u("sidebarFilesTree.contentSearch.invalidPattern"),e[9]=u,e[10]=m):m=e[10];let p;e[11]!==m?(p=n.jsx("span",{className:"text-[var(--status-error)]",children:m}),e[11]=m,e[12]=p):p=e[12];let h;e[13]!==s.message?(h=n.jsx("span",{className:"font-mono typography-micro",dir:"ltr",children:s.message}),e[13]=s.message,e[14]=h):h=e[14];let x;return e[15]!==p||e[16]!==h?(x=n.jsxs(gn,{className:"flex flex-col gap-0.5",children:[p,h]}),e[15]=p,e[16]=h,e[17]=x):x=e[17],x}case"failed":{let m;e[18]!==s.message||e[19]!==u?(m=u("sidebarFilesTree.contentSearch.failed",{message:s.message}),e[18]=s.message,e[19]=u,e[20]=m):m=e[20];let p;return e[21]!==m?(p=n.jsx(gn,{className:"text-[var(--status-error)]",children:m}),e[21]=m,e[22]=p):p=e[22],p}}if(s.matches.length===0){let m;return e[23]!==s.stopped||e[24]!==u?(m=s.stopped==="deadline"?n.jsx(gn,{children:u("sidebarFilesTree.contentSearch.deadline")}):n.jsx(gn,{children:u("sidebarFilesTree.contentSearch.empty")}),e[23]=s.stopped,e[24]=u,e[25]=m):m=e[25],m}let d;if(e[26]!==r||e[27]!==i||e[28]!==a||e[29]!==o||e[30]!==s.matches){let m;e[32]!==r||e[33]!==i||e[34]!==a||e[35]!==o?(m=p=>{const{name:h,directory:x}=t3(p.relativePath),g=Hu(p),v=r===g;return n.jsx("li",{"data-file-tree-path":p.path,children:n.jsxs("button",{type:"button",onClick:()=>o(p),onDoubleClick:()=>o(p,{pin:true}),draggable:!!a,onDragStart:a?y=>a(y,p):void 0,onDragEnd:i?y=>i(y,p):void 0,className:Ye("flex w-full flex-col gap-0.5 rounded-md px-2 py-1 text-start transition-colors",ci(v)),title:`${p.relativePath}:${p.line}`,children:[n.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[n.jsx(Co,{filePath:p.path,className:"size-3.5 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 flex-shrink truncate typography-meta",dir:"auto",children:h}),x?n.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-micro text-muted-foreground",style:{direction:"rtl"},children:`\u200E${x}\u200E`}):n.jsx("span",{className:"flex-1"}),n.jsx("span",{className:"flex-shrink-0 typography-micro tabular-nums text-muted-foreground",children:p.line})]}),n.jsxs("span",{className:"block w-full min-w-0 truncate font-mono typography-micro text-muted-foreground",dir:"ltr",children:[p.cutStart?"\u2026":null,n.jsx(Up,{segments:Hp(p.text,p.ranges)})]})]})},g)},e[32]=r,e[33]=i,e[34]=a,e[35]=o,e[36]=m):m=e[36],d=s.matches.map(m),e[26]=r,e[27]=i,e[28]=a,e[29]=o,e[30]=s.matches,e[31]=d}else d=e[31];let l;e[37]!==s.matches.length||e[38]!==s.stopped||e[39]!==u?(l=s.stopped==="limit"?n.jsx(gn,{children:u("sidebarFilesTree.contentSearch.limit",{count:s.matches.length})}):s.stopped==="deadline"?n.jsx(gn,{children:u("sidebarFilesTree.contentSearch.deadline")}):null,e[37]=s.matches.length,e[38]=s.stopped,e[39]=u,e[40]=l):l=e[40];let f;return e[41]!==d||e[42]!==l?(f=n.jsxs(n.Fragment,{children:[d,l]}),e[41]=d,e[42]=l,e[43]=f):f=e[43],f},tc=8;let jr=null;const Ku=(t,e)=>Math.abs(e.clientX-t.x)<=tc&&Math.abs(e.clientY-t.y)<=tc,Fa=t=>{jr={x:t.clientX,y:t.clientY}},La=t=>{const e=jr;return jr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?false:Ku(e,t)},qu=t=>jr!==null&&Ku(jr,t);let Gu=null;const aa=t=>{Gu=t},Zu=()=>Gu,sc=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},Xu=(t,e,s)=>{const r=e===null?s:e.type==="directory"?e.path:sc(e.path);return!r||sc(t.path)===r||t.type==="directory"&&_f(r,t.path,t.path)!==null?null:r},n3=(t,e)=>{const s=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${s}`:`${e}/${s}`},r3=({root:t,childrenByDir:e,expandedPaths:s,loadErrorsByDir:r})=>{const o=[],a=(i,u)=>{for(const d of e[i]??[]){const l=d.type==="directory"&&s.has(d.path);if(o.push({kind:"node",key:d.path,node:d,depth:u,isExpanded:l}),!l)continue;const f=r[d.path];f&&o.push({kind:"error",key:`error:${d.path}`,directory:d.path,depth:u+1,message:f}),a(d.path,u+1)}};return a(t,0),o},o3=(t,e,s)=>{const r=e.filter(o=>o>=0&&o<s&&!t.includes(o));return r.length===0?[...t]:[...t,...r].sort((o,a)=>o-a)},a3=28,An=t=>Array.from(t.types).includes("Files"),ir=t=>Array.from(t.types).includes(gr)?Zu():null,Yu=(t,e,s)=>t.getData(gr)===_o(e,s.path),i3=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(s=>{if(s.kind!=="file"||s.webkitGetAsEntry()?.isDirectory)return[];const r=s.getAsFile();return r?[r]:[]})},l3=t=>t.slice().sort((e,s)=>e.type!==s.type?e.type==="directory"?-1:1:e.name.localeCompare(s.name)),Ht=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},_o=(t,e)=>{const s=Ht(e),r=Ht(t).replace(/\/+$/,"");return s===r?".":!r||!s.startsWith(`${r}/`)?s:s.slice(r.length+1)},Gn=(t,e)=>{const s=_o(t,e);if(s!==".")return s;const r=Ht(t);return r.split("/").filter(Boolean).pop()??r},Qr=t=>{const e=Ht(t),s=e.lastIndexOf("/");return s<0?"":s===0?"/":e.slice(0,s)},c3=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),d3=new Set(["node_modules"]),u3=t=>d3.has(t),f3=t=>{const e=Ht(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},p3=8,_s=new Map,vi=t=>JSON.stringify([Xt(),t]),m3=t=>{const e=vi(t),s=_s.get(e);return s?(s.touchedAt=Date.now(),_s.delete(e),_s.set(e,s),s):null},ia=t=>{const e=vi(t),s=_s.get(e);if(s)return s.touchedAt=Date.now(),s;if(_s.size>=p3){const o=_s.keys().next().value;o!==void 0&&_s.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return _s.set(e,r),r},h3=t=>{const e=qe.c(159),{guestActions:s,node:r,root:o,isExpanded:a,isActive:i,isBrowserClient:u,depth:d,isOpen:l,status:f,badge:m,isDropTarget:p,isDragSource:h,canUpload:x,canMove:g,permissions:v,downloadFile:y,onSelect:C,onToggle:S,onRevealPath:N,onOpenDialog:F,onSetDropTarget:_,onDropFiles:M,onPickFiles:B,onMoveDragChange:T,onSetMoveDropTarget:I,onMoveDrop:b}=t,{t:w}=gt(),j=r.type==="directory";let R;e[0]!==j||e[1]!==r.path?(R=j?r.path:Qr(r.path),e[0]=j,e[1]=r.path,e[2]=R):R=e[2];const L=R,{canRename:E,canCreateFile:D,canCreateFolder:U,canDelete:V,canReveal:J}=v,W=!j&&!!y,G=J&&!u,le=j&&x,$=E||D||U||le||V||W||G,[re,H]=c.useState(false),[P,ee]=c.useState(false);let oe;e[3]!==$?(oe=We=>{$&&(We?.preventDefault(),ee(true))},e[3]=$,e[4]=oe):oe=e[4];const de=oe;let he;e[5]!==j||e[6]!==r||e[7]!==C||e[8]!==S?(he=()=>{j?S(r.path):C(r)},e[5]=j,e[6]=r,e[7]=C,e[8]=S,e[9]=he):he=e[9];const Z=he;let ce;e[10]!==j||e[11]!==r||e[12]!==C?(ce=()=>{j||C(r,{pin:true})},e[10]=j,e[11]=r,e[12]=C,e[13]=ce):ce=e[13];const ae=ce;let te;e[14]===Symbol.for("react.memo_cache_sentinel")?(te=We=>{We.stopPropagation(),ee(false),H(true)},e[14]=te):te=e[14];const pe=te;let Te,Ae,Pe,ze,Oe,me,be;if(e[15]!==m||e[16]!==D||e[17]!==U||e[18]!==V||e[19]!==g||e[20]!==E||e[21]!==G||e[22]!==x||e[23]!==le||e[24]!==re||e[25]!==d||e[26]!==y||e[27]!==s||e[28]!==de||e[29]!==ae||e[30]!==Z||e[31]!==$||e[32]!==i||e[33]!==u||e[34]!==j||e[35]!==h||e[36]!==p||e[37]!==a||e[38]!==l||e[39]!==r||e[40]!==M||e[41]!==T||e[42]!==b||e[43]!==F||e[44]!==B||e[45]!==N||e[46]!==_||e[47]!==I||e[48]!==P||e[49]!==o||e[50]!==f||e[51]!==w||e[52]!==L){const We=l1(s,"file"),_e=ve=>{const{Item:je,Separator:vt}=ve;return n.jsxs(n.Fragment,{children:[E&&n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),F("rename",r)},children:[n.jsx(ue,{name:"edit",className:"me-2 h-4 w-4"})," ",w("sidebarFilesTree.menu.rename")]}),n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),wo(r.path).then(Je=>{if(Je.ok){Fe.success(w("sidebarFilesTree.toast.pathCopied"));return}Fe.error(w("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(ue,{name:"link",className:"me-2 h-4 w-4"})," ",w("sidebarFilesTree.menu.copyPath")]}),!j&&y&&n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),y(r.path).catch(Je=>{console.error("Download failed:",Je),Fe.error(w("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(ue,{name:"download",className:"me-2 h-4 w-4"})," ",w(u?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),G&&n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),N(r.path)},children:[n.jsx(ue,{name:"folder-received",className:"me-2 h-4 w-4"})," ",w(u1())]}),!j&&G&&go()&&n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),Sc(r.path).then(Je=>{Je||Fe.error(w("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(ue,{name:"external-link",className:"me-2 h-4 w-4"})," ",w("sidebarFilesTree.menu.openInDefaultApp")]}),We.length>0&&n.jsx(vt,{}),We.map(ne=>n.jsxs(je,{onClick:Je=>{Je.stopPropagation(),f1(ne,{kind:"file",action:ne.action.id,directory:o||null,path:r.path,isDirectory:j},w)},children:[n.jsx(li,{icon:ne.icon,iconSrc:ne.iconSrc,className:"me-2 h-4 w-4"})," ",ne.action.label]},`${ne.guest.id}:${ne.action.id}`)),j&&(D||U||le)&&n.jsxs(n.Fragment,{children:[n.jsx(vt,{}),D&&n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),F("createFile",r)},children:[n.jsx(ue,{name:"file-add",className:"me-2 h-4 w-4"})," ",w("sidebarFilesTree.menu.newFile")]}),U&&n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),F("createFolder",r)},children:[n.jsx(ue,{name:"folder-add",className:"me-2 h-4 w-4"})," ",w("sidebarFilesTree.menu.newFolder")]}),le&&n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),B(r.path)},children:[n.jsx(ue,{name:"upload-2",className:"me-2 h-4 w-4"})," ",w("sidebarFilesTree.menu.uploadFiles")]})]}),V&&n.jsxs(n.Fragment,{children:[n.jsx(vt,{}),n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),F("delete",r)},className:"text-destructive focus:text-destructive",children:[n.jsx(ue,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",w("sidebarFilesTree.menu.delete")]})]})]})};let Ue;e[60]!==g||e[61]!==r.path||e[62]!==r.type||e[63]!==T||e[64]!==o?(Ue=ve=>{Fa(ve);const je=_o(o,r.path);!je||je==="."||(ve.dataTransfer.setData(gr,je),ve.dataTransfer.effectAllowed=g?"copyMove":"copy",g&&T({path:r.path,type:r.type}))},e[60]=g,e[61]=r.path,e[62]=r.type,e[63]=T,e[64]=o,e[65]=Ue):Ue=e[65];const Xe=Ue;let Me;e[66]!==g||e[67]!==Z||e[68]!==T?(Me=ve=>{g&&T(null),La(ve)&&Z()},e[66]=g,e[67]=Z,e[68]=T,e[69]=Me):Me=e[69];const ot=Me;let ye;e[70]!==x||e[71]!==_||e[72]!==L?(ye=ve=>{!x||!L||!An(ve.dataTransfer)||(ve.preventDefault(),ve.stopPropagation(),ve.dataTransfer.dropEffect="copy",_(L))},e[70]=x,e[71]=_,e[72]=L,e[73]=ye):ye=e[73];const Ve=ye;let lt;e[74]!==x||e[75]!==_||e[76]!==L?(lt=ve=>{!x||!L||!An(ve.dataTransfer)||ve.relatedTarget instanceof Node&&ve.currentTarget.contains(ve.relatedTarget)||(ve.stopPropagation(),_(null))},e[74]=x,e[75]=_,e[76]=L,e[77]=lt):lt=e[77];const ct=lt;let st;e[78]!==x||e[79]!==M||e[80]!==L?(st=ve=>{!x||!L||!An(ve.dataTransfer)||(ve.preventDefault(),ve.stopPropagation(),M(L,ve.dataTransfer))},e[78]=x,e[79]=M,e[80]=L,e[81]=st):st=e[81];const k=st;let Y;e[82]!==r.path||e[83]!==r.type||e[84]!==o?(Y=(ve,je)=>qu(ve)?null:Xu(je,{path:r.path,type:r.type},o),e[82]=r.path,e[83]=r.type,e[84]=o,e[85]=Y):Y=e[85];const Ne=Y;let Re;e[86]!==g||e[87]!==Ne||e[88]!==Ve||e[89]!==I?(Re=ve=>{const je=g?ir(ve.dataTransfer):null;if(!je){Ve(ve);return}ve.stopPropagation();const vt=Ne(ve,je);I(vt),vt&&(ve.preventDefault(),ve.dataTransfer.dropEffect="move")},e[86]=g,e[87]=Ne,e[88]=Ve,e[89]=I,e[90]=Re):Re=e[90];const Ie=Re;let Ee;e[91]!==g||e[92]!==Ne||e[93]!==k||e[94]!==b||e[95]!==I||e[96]!==o?(Ee=ve=>{const je=g?ir(ve.dataTransfer):null;if(!je){k(ve);return}ve.stopPropagation(),ve.preventDefault(),I(null);const vt=Ne(ve,je);vt&&Yu(ve.dataTransfer,o,je)&&b(je,vt)},e[91]=g,e[92]=Ne,e[93]=k,e[94]=b,e[95]=I,e[96]=o,e[97]=Ee):Ee=e[97];const Ge=Ee;Ae=Ir,me=P,be=ee;let Be;e[98]===Symbol.for("react.memo_cache_sentinel")?(Be={blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[98]=Be):Be=e[98];let Ze;e[99]!==de||e[100]!==ct||e[101]!==Ie||e[102]!==Ge?(Ze=n.jsx("div",{className:"group relative flex items-center typography-meta",style:Be,onContextMenu:de,onDragEnter:Ie,onDragOver:Ie,onDragLeave:ct,onDrop:Ge}),e[99]=de,e[100]=ct,e[101]=Ie,e[102]=Ge,e[103]=Ze):Ze=e[103];let et;e[104]!==d?(et=n.jsx(Cd,{depth:d}),e[104]=d,e[105]=et):et=e[105];let wt;e[106]!==i||e[107]!==h||e[108]!==p?(wt=Ye("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)]":ci(i),h&&"opacity-50"),e[106]=i,e[107]=h,e[108]=p,e[109]=wt):wt=e[109];let Qe;e[110]!==d?(Qe=Ed(d),e[110]=d,e[111]=Qe):Qe=e[111];let dt;e[112]!==Qe?(dt={paddingInlineStart:Qe},e[112]=Qe,e[113]=dt):dt=e[113];let at;e[114]!==j||e[115]!==a||e[116]!==r.extension||e[117]!==r.path?(at=j?n.jsx(c1,{expanded:a}):n.jsx(Co,{filePath:r.path,extension:r.extension,className:"ms-0.5 size-3.5"}),e[114]=j,e[115]=a,e[116]=r.extension,e[117]=r.path,e[118]=at):at=e[118];let z;e[119]!==r.name||e[120]!==r.path?(z=n.jsx("span",{className:"oc-file-tree-row-name typography-meta",title:r.path,children:r.name}),e[119]=r.name,e[120]=r.path,e[121]=z):z=e[121];let fe;e[122]!==j||e[123]!==l||e[124]!==f?(fe=!j&&n.jsx(p1,{isOpen:l,status:f}),e[122]=j,e[123]=l,e[124]=f,e[125]=fe):fe=e[125];let ke;e[126]!==m||e[127]!==j?(ke=j&&m&&n.jsx(m1,{badge:m}),e[126]=m,e[127]=j,e[128]=ke):ke=e[128];let ie;e[129]!==fe||e[130]!==ke?(ie=n.jsxs(h1,{className:"pe-2",children:[fe,ke]}),e[129]=fe,e[130]=ke,e[131]=ie):ie=e[131];let xe;e[132]!==de||e[133]!==ae||e[134]!==ot||e[135]!==Xe||e[136]!==Z||e[137]!==wt||e[138]!==dt||e[139]!==at||e[140]!==z||e[141]!==ie?(xe=n.jsxs("button",{type:"button",onClick:Z,onDoubleClick:ae,onContextMenu:de,draggable:true,onDragStart:Xe,onDragEnd:ot,className:wt,style:dt,children:[at,z,ie]}),e[132]=de,e[133]=ae,e[134]=ot,e[135]=Xe,e[136]=Z,e[137]=wt,e[138]=dt,e[139]=at,e[140]=z,e[141]=ie,e[142]=xe):xe=e[142];const Le=$&&n.jsx("div",{className:Ye("oc-file-tree-row-end -ms-7 w-7 pe-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 pointer-fine:hidden",d1(i||p)),children:n.jsxs(Sn,{open:re,onOpenChange:H,children:[n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("span",{className:"inline-flex",children:n.jsx(kn,{asChild:true,children:n.jsx(yt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:pe,"aria-label":w("diffView.actions.moreActions"),children:n.jsx(ue,{name:"more-2-fill",className:"h-4 w-4"})})})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:w("diffView.actions.moreActions")})]}),n.jsx(jn,{align:"end",side:"bottom",onCloseAutoFocus:()=>H(false),children:_e({Item:Ks,Separator:tr})})]})});e[143]!==Ze||e[144]!==et||e[145]!==xe||e[146]!==Le?(Pe=n.jsxs(yo,{render:Ze,children:[et,xe,Le]}),e[143]=Ze,e[144]=et,e[145]=xe,e[146]=Le,e[147]=Pe):Pe=e[147],Te=Nr,ze="min-w-[180px]";let Ke;e[148]===Symbol.for("react.memo_cache_sentinel")?(Ke={Item:Ts,Separator:Dn},e[148]=Ke):Ke=e[148],Oe=_e(Ke),e[15]=m,e[16]=D,e[17]=U,e[18]=V,e[19]=g,e[20]=E,e[21]=G,e[22]=x,e[23]=le,e[24]=re,e[25]=d,e[26]=y,e[27]=s,e[28]=de,e[29]=ae,e[30]=Z,e[31]=$,e[32]=i,e[33]=u,e[34]=j,e[35]=h,e[36]=p,e[37]=a,e[38]=l,e[39]=r,e[40]=M,e[41]=T,e[42]=b,e[43]=F,e[44]=B,e[45]=N,e[46]=_,e[47]=I,e[48]=P,e[49]=o,e[50]=f,e[51]=w,e[52]=L,e[53]=Te,e[54]=Ae,e[55]=Pe,e[56]=ze,e[57]=Oe,e[58]=me,e[59]=be}else Te=e[53],Ae=e[54],Pe=e[55],ze=e[56],Oe=e[57],me=e[58],be=e[59];let Ce;e[149]!==Te||e[150]!==ze||e[151]!==Oe?(Ce=n.jsx(Te,{className:ze,children:Oe}),e[149]=Te,e[150]=ze,e[151]=Oe,e[152]=Ce):Ce=e[152];let $e;return e[153]!==Ae||e[154]!==Pe||e[155]!==Ce||e[156]!==me||e[157]!==be?($e=n.jsxs(Ae,{open:me,onOpenChange:be,children:[Pe,Ce]}),e[153]=Ae,e[154]=Pe,e[155]=Ce,e[156]=me,e[157]=be,e[158]=$e):$e=e[158],$e},g3=(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&&t.guestActions===e.guestActions,x3=c.memo(h3,g3),b3=t=>{const e=qe.c(14),{visible:s}=t,r=s===void 0?true:s,o=Ln(y3),a=Zs()??"",i=Pr();let u,d,l,f;if(e[0]!==i||e[1]!==a||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{if(d=So(i,a)??"",i?.kind==="preparing"){let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Ur,{}),e[7]=p):p=e[7],f=p;break e}u=w3,l=JSON.stringify([o,d])}e[0]=i,e[1]=a,e[2]=o,e[3]=u,e[4]=d,e[5]=l,e[6]=f}else u=e[3],d=e[4],l=e[5],f=e[6];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;return e[8]!==u||e[9]!==d||e[10]!==a||e[11]!==l||e[12]!==r?(m=n.jsx(u,{visible:r,currentDirectory:d,panelDirectory:a},l),e[8]=u,e[9]=d,e[10]=a,e[11]=l,e[12]=r,e[13]=m):m=e[13],m},w3=({visible:t,currentDirectory:e,panelDirectory:s})=>{const r=c.useRef(t);r.current=t;const{t:o}=gt(),{files:a,runtime:i}=Is(),u=g1(),d=Af(i.platform),l=Ht(e.trim()),f=Ht(s.trim()),m=vi(l),p=Of(),h=Mf(),x=Ff(O=>O.searchFiles),g=K(O=>O.openContextFile),v=jo(t?e:null),[y,C]=c.useState(""),S=x1(y,200),N=c.useRef(null),[F,_]=c.useState([]),[M,B]=c.useState(false),T=!!a.searchContents,[I,b]=c.useState("names"),[w,j]=c.useState(false),R=T&&I==="contents",L=e3({searchContents:a.searchContents,directory:e,query:S,regex:w,includeHidden:p,respectGitignore:!h,active:t&&R}),E=K(O=>O.openContextFileAtLine),[D,U]=c.useState(null),[V,J]=c.useState(null),[W,G]=c.useState(null),[le,$]=c.useState(null),[re,H]=c.useState(null),{hasTouchOnlyPointer:P}=Tn(),ee=!!(a.rename&&l)&&!P,oe=K(O=>O.confirmFileTreeMove),de=K(O=>O.setConfirmFileTreeMove),[he,Z]=c.useState({}),[ce,ae]=c.useState({}),te=c.useRef(new Set),pe=c.useRef(new Map),Te=c.useMemo(()=>new cb,[]);c.useEffect(()=>()=>Te.clear(),[Te]);const Ae=c.useRef(null);c.useEffect(()=>{if(J(null),$(null),H(null),!l){Z({}),ae({}),te.current=new Set;return}const O=m3(l);O?(Z({...O.childrenByDir}),ae({...O.loadErrorsByDir}),te.current=new Set(O.loadedDirs)):(Z({}),ae({}),te.current=new Set)},[l]),c.useEffect(()=>{if(!l)return;const O=ia(l);O.childrenByDir=he},[l,he]),c.useEffect(()=>{if(!l)return;const O=ia(l);O.loadErrorsByDir=ce},[l,ce]),c.useEffect(()=>{if(!l)return;const O=ia(l);O.loadedDirs=new Set(te.current)},[l,he,ce]),c.useEffect(()=>()=>{if(!l)return;const O=_s.get(m);O&&O.loadedDirs.size===0&&Object.keys(O.childrenByDir).length===0&&_s.delete(m)},[m,l]);const Pe=c.useMemo(()=>[],[]),ze=c.useMemo(()=>[],[]),Oe=gs(O=>l?O.byRoot[l]?.expandedPaths??Pe:Pe),me=c.useMemo(()=>new Set(Oe),[Oe]),be=gs(O=>l?O.byRoot[l]?.selectedPath??null:null),Ce=gs(O=>O.setSelectedPath),$e=c.useRef(null);c.useEffect(()=>{$e.current=be},[be]);const We=gs(O=>O.addOpenPath),_e=gs(O=>O.removeOpenPathsByPrefix),Ue=gs(O=>O.toggleExpandedPath),Xe=gs(O=>O.expandPath),Me=gs(O=>O.collapseAllExpandedPaths),ot=K(O=>f?O.contextPanelByDirectory[f]?.tabs??ze:ze),ye=c.useMemo(()=>new Set(ot.map(O=>O.mode==="file"?O.targetPath:null).filter(O=>typeof O=="string"&&O.length>0).map(O=>Ht(O))),[ot]),[Ve,lt]=c.useState(null),[ct,st]=c.useState(null),[k,Y]=c.useState(""),[Ne,Re]=c.useState(false),Ie=!!a.writeFile,Ee=!!a.createDirectory,Ge=!!a.rename,Be=!!a.delete,Ze=!!a.revealPath,et=c.useMemo(()=>({canRename:Ge,canCreateFile:Ie,canCreateFolder:Ee,canDelete:Be,canReveal:Ze}),[Ge,Ie,Ee,Be,Ze]),wt=c.useCallback(O=>{a.revealPath&&a.revealPath(O).catch(()=>{Fe.error(o("sidebarFilesTree.toast.revealFailed"))})},[a,o]),Qe=c.useCallback((O,A)=>{lt(O),st(A),Y(O==="rename"&&A.name||""),Re(false)},[]),dt=c.useCallback((O,A)=>{const Se=A.filter(ge=>ge&&typeof ge.name=="string"&&ge.name.length>0).filter(ge=>p||!ge.name.startsWith(".")).filter(ge=>h||!u3(ge.name)).map(ge=>{const xt=ge.name,ht=Ht(ge.path||""),At=ht?c3(ht)?ht:Ht(`${O}/${ht}`):Ht(`${O}/${xt}`),Lt=ge.isDirectory?"directory":"file",Ot=Lt==="file"&&xt.includes(".")?xt.split(".").pop()?.toLowerCase():void 0;return{name:xt,path:At,type:Lt,extension:Ot}});return l3(Se)},[h,p]),at=c.useCallback(async(O,A,Se=false)=>{if(!r.current||A?.())return;const ge=Ht(O.trim());if(!ge||!Se&&te.current.has(ge))return;const xt=Xt();return Te.run(ge,async ht=>{const At=()=>!ht()||Xt()!==xt;try{const Lt=!h,Ot=a.listDirectory?(await a.listDirectory(ge,{respectGitignore:Lt})).entries:await ua.listLocalDirectory(ge,{respectGitignore:Lt});if(At())return;pe.current.set(ge,Ot.length);const zt=dt(ge,Ot);te.current=new Set(te.current),te.current.add(ge),ae(ys=>{if(!ys[ge])return ys;const dn={...ys};return delete dn[ge],dn}),Z(ys=>ys[ge]&&db(ys[ge],zt)?ys:{...ys,[ge]:zt})}catch(Lt){if(At())return;const Ot=Lt instanceof Error?Lt.message:String(Lt??"");console.error("Failed to load sidebar directory:",Lt),ae(zt=>({...zt,[ge]:Ot}))}},Se)},[Te,a,dt,h]),z=c.useCallback(async()=>{if(!l)return;Ae.current?.abort();const O=new AbortController;Ae.current=O,Te.clear();try{const Se=(gs.getState().byRoot[l]?.expandedPaths??[]).map(ht=>Ht(ht)).filter(ht=>!!ht&&ht!==l&&ht.startsWith(`${l}/`)),ge=[l,...Se];te.current=new Set(te.current);for(const ht of ge)te.current.delete(ht);ae(ht=>{if(Object.keys(ht).length===0)return ht;const At={...ht};let Lt=false;for(const Ot of ge)Ot in At&&(delete At[Ot],Lt=true);return Lt?At:ht});const xt=()=>O.signal.aborted;await at(l,xt);for(let ht=0;ht<Se.length&&!O.signal.aborted;ht+=3){const At=Se.slice(ht,ht+3);await Promise.all(At.map(Lt=>at(Lt,xt)))}}catch(A){if(O.signal.aborted)return;console.error("Failed to refresh sidebar tree:",A)}finally{Ae.current===O&&(Ae.current=null)}},[Te,at,l]),fe=c.useCallback(async O=>{if(!O){await z();return}const A=Ht(O);te.current=new Set(te.current),te.current.delete(A),await at(A,void 0,true)},[at,z]);c.useEffect(()=>{l&&(Ae.current?.abort(),te.current=new Set,Te.clear(),ae({}),Z(O=>Object.keys(O).length===0?O:{}),at(l))},[Te,at,l,p,h]),c.useEffect(()=>{if(!t||!l||Oe.length===0)return;const O=Oe.map(ge=>Ht(ge)).filter(ge=>!!ge&&ge!==l&&ge.startsWith(`${l}/`)&&!te.current.has(ge)&&!Te.has(ge)).sort((ge,xt)=>ge.split("/").length-xt.split("/").length);if(O.length===0)return;let A=false;const Se=()=>A;return(async()=>{for(let ge=0;ge<O.length&&!A;ge+=3){const xt=O.slice(ge,ge+3);await Promise.all(xt.map(ht=>at(ht,Se)))}})(),()=>{A=true}},[Te,Oe,at,l,t]);const ke=c.useRef(t);c.useEffect(()=>{const O=t&&!ke.current;ke.current=t,O&&z()},[z,t]);const ie=c.useCallback(({directories:O})=>{if(!l)return;const A=new Set((gs.getState().byRoot[l]?.expandedPaths??[]).map(Ot=>Ht(Ot))),Se=l==="/"?"/":`${l}/`,ge=Ot=>{for(let zt=Ot;zt!==l;zt=Qr(zt))if(!zt.startsWith(Se)||!A.has(zt))return false;return true},xt=Ot=>{for(let zt=Ot;zt===l||zt.startsWith(Se);zt=Qr(zt)){if(te.current.has(zt))return zt;if(zt===l)break}return null},ht=new Set,At=new Set;for(const Ot of O??te.current){const zt=xt(Ht(Ot));zt&&(ge(zt)?ht:At).add(zt)}At.size>0&&(te.current=new Set([...te.current].filter(Ot=>!At.has(Ot))));const Lt=[...ht].filter(Ot=>(pe.current.get(Ot)??0)<=Kp);(async()=>{for(let Ot=0;Ot<Lt.length;Ot+=3)await Promise.all(Lt.slice(Ot,Ot+3).map(zt=>at(zt,void 0,true)))})()},[at,l]);qp({root:l,active:t,whileInactive:"drop",onChanges:ie}),c.useEffect(()=>{if(!t)return;if(!e||R){_([]),B(false);return}const O=S.trim();if(!O){_([]),B(false);return}let A=false;return B(true),x(e,O,150,{includeHidden:p,respectGitignore:!h,type:"file"}).then(Se=>{if(A)return;const xt=Se.filter(ht=>h||!f3(ht.path)).map(ht=>({name:ht.name,path:Ht(ht.path),type:"file",extension:ht.extension,relativePath:ht.relativePath}));_(xt)}).catch(()=>{A||_([])}).finally(()=>{A||B(false)}),()=>{A=true}},[R,e,S,x,p,h,t]);const xe=c.useMemo(()=>{const O=new Map;if(!v?.files)return O;for(const A of v.files)A.index==="A"||A.working_dir==="?"?O.set(A.path,"git-added"):A.index==="D"?O.set(A.path,"git-deleted"):(A.index==="M"||A.working_dir==="M")&&O.set(A.path,"git-modified");return O},[v]),Le=c.useMemo(()=>{const O=new Map;if(!v?.files||!l)return O;for(const A of v.files){const Se=A.index==="M"||A.working_dir==="M",ge=A.index==="A"||A.working_dir==="?";if(!Se&&!ge)continue;const xt=A.path.split("/");if(xt.length<=1)continue;let ht=l;for(let At=0;At<xt.length-1;At++){ht=`${ht}/${xt[At]}`;let Lt=O.get(ht);Lt||(Lt={modified:0,added:0},O.set(ht,Lt)),Se&&Lt.modified++,ge&&Lt.added++}}return O},[v,l]),Ke=c.useCallback(O=>{if(xe.size===0)return null;const A=O.startsWith(l+"/")?O.slice(l.length+1):O;return xe.get(A)??null},[xe,l]),ve=c.useCallback(O=>{if(Le.size===0)return null;const A=Le.get(O);return A&&A.modified+A.added>0?A:null},[Le]),je=c.useCallback(async(O,A)=>{if(!l)return;const Se=await ol(a,O.path,{directory:l});if(!Se.ok){al(O.path,Se);return}Ce(l,O.path),We(l,O.path),g(f,O.path,{preview:!A?.pin&&!K.getState().isMobile})},[We,a,g,f,l,Ce]),vt=c.useCallback(async(O,A)=>{if(!l)return;const Se=await ol(a,O.path,{directory:l});if(!Se.ok){al(O.path,Se);return}Ce(l,O.path),We(l,O.path),U({path:O.path,key:Hu(O)}),E(f,O.path,O.line,O.column,{preview:!A?.pin&&!K.getState().isMobile})},[We,a,E,f,l,Ce]),ne=c.useCallback((O,A)=>{Fa(O),aa(null),O.dataTransfer.setData(gr,A.relativePath),O.dataTransfer.effectAllowed="copy"},[]),Je=c.useCallback((O,A)=>{La(O)&&vt(A)},[vt]),[kt,bt]=c.useState(null),_t=c.useCallback(()=>bt(null),[]),He=c.useRef(null),pt=ub(He,{onSettled:_t}),q=c.useCallback(async O=>{const A=Ht(O);if(!l)return;const Se=gs.getState().byRoot[l]?.expandedPaths.includes(A)??false;pt(O,Se,()=>{const ge=Array.from(He.current?.querySelectorAll("[data-tree-disclosure-path]")??[],xt=>xt.dataset.treeDisclosurePath??"");bt(Se?null:ge.slice(ge.indexOf(O)+1)),Ue(l,A)}),te.current.has(A)||await at(A)},[at,l,Ue,pt]),{canUpload:se,uploadingDirectory:De,uploadFiles:we,pickFiles:rt,uploadElements:ft}=Gp({root:l,refreshDirectory:fe}),nt=De!==null,ut=De??V,Nt=c.useCallback((O,A)=>{const Se=i3(A);Se.length!==0&&(J(null),we(O,Se))},[we]),Et=c.useCallback(O=>{if(aa(O),!O){G(null),$(null);return}requestAnimationFrame(()=>{Zu()?.path===O.path&&G(O.path)})},[]),Ft=c.useCallback(async(O,A)=>{const Se=n3(O,A),ge=await rl(a,{tabs:f,files:l},O.path,Se);if(ge==="conflict"){Fe.error(o("sidebarFilesTree.toast.nameTaken",{name:Se.slice(Se.lastIndexOf("/")+1),folder:Gn(l,A)}));return}if(ge==="failed"){Fe.error(o("sidebarFilesTree.toast.operationFailed"));return}A!==l&&Xe(l,A),await Promise.all([fe(Qr(O.path)),fe(A)]).catch(()=>{})},[Xe,a,f,fe,l,o]),Wt=c.useCallback((O,A)=>{if(K.getState().confirmFileTreeMove){H({source:O,targetDirectory:A});return}Ft(O,A)},[Ft]),is=c.useCallback(()=>{re&&(H(null),Ft(re.source,re.targetDirectory))},[Ft,re]),Gt=c.useCallback((O,A)=>!ee||qu(O)?null:Xu(A,null,l),[ee,l]),ns=c.useCallback(O=>{const A=ir(O.dataTransfer);if(A){const Se=Gt(O,A);if($(Se),!Se)return;O.preventDefault(),O.dataTransfer.dropEffect="move";return}!se||nt||!l||!An(O.dataTransfer)||(O.preventDefault(),O.dataTransfer.dropEffect="copy",J(l))},[se,Gt,nt,l]),ms=c.useCallback(O=>{if(!(O.relatedTarget instanceof Node&&O.currentTarget.contains(O.relatedTarget))){if(ir(O.dataTransfer)){$(null);return}An(O.dataTransfer)&&J(null)}},[]),Ns=c.useCallback(O=>{const A=ir(O.dataTransfer);if(A){O.preventDefault(),$(null);const Se=Gt(O,A);Se&&Yu(O.dataTransfer,l,A)&&Wt(A,Se);return}!se||nt||!l||!An(O.dataTransfer)||(O.preventDefault(),Nt(l,O.dataTransfer))},[se,Gt,Nt,Wt,nt,l]),Fs=c.useCallback(async O=>{if(O?.preventDefault(),!ct||!Ve)return;Re(true);const A=()=>Re(false),Se=()=>lt(null);if(Ve==="createFile"){if(!k.trim()){Fe.error(o("sidebarFilesTree.toast.filenameRequired")),A();return}if(!a.writeFile){Fe.error(o("sidebarFilesTree.toast.writeNotSupported")),A();return}const ge=ct.path,xt=ge?`${ge}/`:"",ht=Ht(`${xt}${k.trim()}`);await a.writeFile(ht,"").then(async At=>{At.success&&(Fe.success(o("sidebarFilesTree.toast.fileCreated")),await fe(ge)),Se()}).catch(()=>Fe.error(o("sidebarFilesTree.toast.operationFailed"))).finally(A);return}if(Ve==="createFolder"){if(!k.trim()){Fe.error(o("sidebarFilesTree.toast.folderNameRequired")),A();return}const ge=ct.path,xt=ge?`${ge}/`:"",ht=Ht(`${xt}${k.trim()}`);await a.createDirectory(ht).then(async At=>{At.success&&(Fe.success(o("sidebarFilesTree.toast.folderCreated")),await fe(ge)),Se()}).catch(()=>Fe.error(o("sidebarFilesTree.toast.operationFailed"))).finally(A);return}if(Ve==="rename"){if(!k.trim()){Fe.error(o("sidebarFilesTree.toast.nameRequired")),A();return}if(!a.rename){Fe.error(o("sidebarFilesTree.toast.renameNotSupported")),A();return}const ge=ct.path,xt=ge.split("/").slice(0,-1).join("/"),ht=xt?`${xt}/`:"",At=k.trim(),Lt=Ht(`${ht}${At}`);try{const Ot=await rl(a,{tabs:f,files:l},ge,Lt);Ot==="moved"?(Fe.success(o("sidebarFilesTree.toast.renamedSuccessfully")),await fe(xt),Se()):Ot==="conflict"?Fe.error(o("sidebarFilesTree.toast.nameTaken",{name:At,folder:Gn(l,xt)})):Fe.error(o("sidebarFilesTree.toast.operationFailed"))}catch{Fe.error(o("sidebarFilesTree.toast.operationFailed"))}finally{A()}return}if(Ve==="delete"){if(!a.delete){Fe.error(o("sidebarFilesTree.toast.deleteNotSupported")),A();return}const ge=ct.path,xt=ge.split("/").slice(0,-1).join("/");await a.delete(ge).then(async ht=>{ht.success&&(Fe.success(o("sidebarFilesTree.toast.deletedSuccessfully")),await fe(xt),l&&_e(l,ge),(be===ge||be&&be.startsWith(ge+"/"))&&Ce(l,null)),Se()}).catch(()=>Fe.error(o("sidebarFilesTree.toast.operationFailed"))).finally(A);return}A()},[Ve,ct,k,a,f,fe,_e,l,be,Ce,o]),X=c.useMemo(()=>l?r3({root:l,childrenByDir:he,expandedPaths:me,loadErrorsByDir:ce}):[],[he,me,ce,l]),mt=c.useMemo(()=>new Map(X.flatMap((O,A)=>O.kind==="node"?[[O.node.path,A]]:[])),[X]),[jt,$t]=c.useState(null),[Q,tt]=c.useState(null),St=c.useCallback(O=>{He.current=O,tt(O)},[]),[Tt,Bt]=c.useState(null),Zt=c.useMemo(()=>[W,Tt,...kt??[]].flatMap(O=>O?[mt.get(O)??-1]:[]),[Tt,W,kt,mt]),js=c.useCallback(O=>o3(hb(O),Zt,X.length),[Zt,X.length]),[us,Ps]=c.useState(0);c.useLayoutEffect(()=>{if(!jt||!Q)return;const O=Q.getBoundingClientRect().top-jt.getBoundingClientRect().top+jt.scrollTop;Ps(Math.max(0,Math.round(O)))},[Q,jt]);const Rs=c.useRef(null),hs=c.useRef(new Map),ls=c.useRef(null),ws=c.useCallback(O=>{const A=Math.max(0,...hs.current.values());O.style.setProperty("--oc-file-tree-width",`${A}px`)},[]),cn=c.useCallback((O,A)=>{const Se=O.dataset.treeRowPath,ge=He.current;!Se||!ge||A<=ge.clientWidth+.5||hs.current.get(Se)!==A&&(hs.current.set(Se,A),ls.current===null&&(ls.current=requestAnimationFrame(()=>{ls.current=null,He.current&&ws(He.current)})))},[ws]);c.useEffect(()=>()=>{ls.current!==null&&cancelAnimationFrame(ls.current)},[]),c.useLayoutEffect(()=>{if(!Q)return;const O=hs.current;for(const ge of O.keys())mt.has(ge)||O.delete(ge);const A=jt?.scrollLeft??0;Q.style.removeProperty("--oc-file-tree-width");const Se=Q.clientWidth;for(const ge of Q.children){const xt=ge instanceof HTMLElement?ge.dataset.treeRowPath:void 0;if(!xt)continue;const ht=ge.getBoundingClientRect().width;ht>Se+.5?O.set(xt,ht):O.delete(xt)}ws(Q),jt&&(jt.scrollLeft=A)},[Q,mt,jt,ws]);const Ys=mb({count:X.length,enabled:jt!==null,getScrollElement:()=>jt,estimateSize:O=>(X[O]?.kind==="node"?Rs.current:null)??a3,measureElement:(O,A,Se)=>{const ge=gb(O,A,Se);return O.dataset.treeRowPath&&(Rs.current=ge),A&&cn(O,A.borderBoxSize?.[0]?.inlineSize??O.getBoundingClientRect().width),ge},getItemKey:O=>X[O]?.key??O,overscan:12,scrollMargin:us,rangeExtractor:js}),En=O=>{if(O.kind==="error")return n.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:Ed(O.depth)},children:[n.jsx(Cd,{depth:O.depth}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:O.message,children:O.message}),n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsxs(yt,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{fe(O.directory)},children:[n.jsx(ue,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})}),n.jsx(Dt,{sideOffset:6,children:o("contextTooltips.files.retryFolder")})]})]});const{node:A,depth:Se,isExpanded:ge}=O,xt=A.type==="directory";return n.jsx(x3,{node:A,root:l,isExpanded:ge,isActive:be===A.path,isBrowserClient:d,depth:Se,isOpen:!xt&&ye.has(A.path),status:xt?void 0:Ke(A.path),badge:xt?ve(A.path):void 0,isDropTarget:xt&&(ut===A.path||le===A.path),isDragSource:W===A.path,canUpload:se&&!nt,canMove:ee,permissions:et,downloadFile:a.downloadFile,onSelect:je,onToggle:q,onRevealPath:wt,onOpenDialog:Qe,onSetDropTarget:J,onDropFiles:Nt,onPickFiles:rt,onMoveDragChange:Et,onSetMoveDropTarget:$,onMoveDrop:Wt,guestActions:u})},Ao=c.useCallback(O=>{const A=O.target instanceof Element?O.target.closest("[data-tree-row-path]"):null;Bt(A?.dataset.treeRowPath??null)},[]),Oo=c.useCallback(O=>{O.relatedTarget instanceof Node&&O.currentTarget.contains(O.relatedTarget)||Bt(null)},[]);c.useEffect(()=>{const O=$e.current;if(!O||!jt||!Q)return;const A=mt.get(O);A===void 0||jt.offsetParent===null||($e.current=null,Ys.scrollToIndex(A,{align:"auto"}))});const Dr=!!(l&&he[l]),Vn=l?ce[l]:null,Un=S.trim().length>0,Mo=!M&&!Un&&F.length===0&&!Vn&&Dr&&!!l,Hn=ut?Gn(l,ut):"",_r=le?Gn(l,le):"",Fo=re?re.source.path.slice(re.source.path.lastIndexOf("/")+1):"";return n.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-t border-edge-muted px-2",children:[n.jsxs("div",{className:"relative min-w-0 flex-1",children:[T?n.jsxs(Sn,{children:[n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("span",{className:"absolute inset-s-0.5 top-1/2 inline-flex -translate-y-1/2",children:n.jsx(kn,{asChild:true,children:n.jsx(yt,{variant:"ghost",size:"sm",className:"relative size-6 p-0 text-muted-foreground hover:text-foreground","aria-label":o("sidebarFilesTree.search.mode.aria"),children:n.jsx(ue,{name:R?"file-search":"search",className:"size-3.5"})})})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.search.mode.aria")})]}),n.jsx(jn,{align:"start",side:"bottom",children:n.jsxs(hd,{value:I,onValueChange:O=>b(O==="contents"?"contents":"names"),children:[n.jsxs(oo,{value:"names",closeOnClick:true,className:"items-center",children:[n.jsx(ue,{name:"search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.names")]}),n.jsxs(oo,{value:"contents",closeOnClick:true,className:"items-center",children:[n.jsx(ue,{name:"file-search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.contents")]})]})})]}):n.jsx(ue,{name:"search",className:"pointer-events-none absolute inset-s-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),n.jsx(Fn,{ref:N,inputSize:"compact",value:y,onChange:O=>C(O.target.value),placeholder:o(R?"sidebarFilesTree.search.contentsPlaceholder":"sidebarFilesTree.search.placeholder"),className:Ye("ps-7",R?"pe-14":y.trim().length>0?"pe-7":"pe-2")}),R?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{variant:"chip",size:"xs","aria-pressed":w,onClick:()=>{j(O=>!O),N.current?.focus()},"aria-label":o("sidebarFilesTree.search.regexTitle"),className:"absolute inset-e-1 top-1/2 h-5 min-w-0 -translate-y-1/2 px-1 font-mono typography-micro",children:".*"})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:o(w?"contextTooltips.files.searchPlainText":"sidebarFilesTree.search.regexTitle")})]}):null,y.trim().length>0?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button","aria-label":o("sidebarFilesTree.search.clearAria"),className:Ye("absolute top-1/2 inline-flex size-4 -translate-y-1/2 items-center justify-center text-muted-foreground hover:text-foreground",R?"inset-e-8":"inset-e-2"),onClick:()=>{C(""),N.current?.focus()},children:n.jsx(ue,{name:"close",className:"size-3.5"})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.search.clearAria")})]}):null]}),n.jsx(jd,{className:"shrink-0 gap-0.5",groups:[[(Ie||Ee||se)&&{id:"add",label:o("sidebarFilesTree.actions.addMenuTitle"),icon:nt?"loader-4":"add",iconClassName:nt?"animate-spin":void 0,menu:n.jsxs(n.Fragment,{children:[Ie?n.jsxs(Ks,{onClick:()=>Qe("createFile",{path:e,type:"directory"}),children:[n.jsx(ue,{name:"file-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFile")]}):null,Ee?n.jsxs(Ks,{onClick:()=>Qe("createFolder",{path:e,type:"directory"}),children:[n.jsx(ue,{name:"folder-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFolder")]}):null,se?n.jsxs(Ks,{disabled:!l||nt,onClick:()=>rt(l),children:[n.jsx(ue,{name:"upload-2",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.uploadFiles")]}):null]})}]],menuOnly:[{id:"gitignored",label:o("filesView.tree.actions.showGitignored"),icon:"file-forbid",pressed:h,onSelect:()=>Lf(!h)},{id:"refresh",label:o("sidebarFilesTree.actions.refreshTitle"),icon:"refresh",onSelect:()=>{z()}},{id:"collapse-all",label:o("sidebarFilesTree.actions.collapseAllTitle"),icon:"collapse-vertical",onSelect:()=>{l&&Me(l)}}]})]}),n.jsxs("div",{className:"relative flex-1 min-h-0",children:[n.jsxs(ps,{ref:$t,outerClassName:"h-full min-h-0",className:Ye("@container px-1.5 py-1.5 [overflow-anchor:none]",(ut===l||le===l)&&"bg-interactive-selection/10"),onDragEnter:ns,onDragOver:ns,onDragLeave:ms,onDrop:Ns,children:[n.jsx("ul",{className:"flex flex-col",children:R&&L.status!=="idle"?n.jsx(s3,{state:L,activeMatchKey:D&&D.path===be?D.key:null,onOpen:vt,onDragStart:ne,onDragEnd:Je}):M?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx(ue,{name:"loader-4",className:"h-4 w-4 animate-spin"}),o("sidebarFilesTree.state.searching")]}):Un&&F.length===0?n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("mobile.files.search.empty")}):F.length>0?F.map(O=>{const A=be===O.path;return n.jsx("li",{"data-file-tree-path":O.path,children:n.jsxs("button",{type:"button",onClick:()=>je(O),onDoubleClick:()=>je(O,{pin:true}),draggable:true,onDragStart:Se=>{Fa(Se),aa(null);const ge=O.relativePath||_o(l??"",O.path);!ge||ge==="."||(Se.dataTransfer.setData(gr,ge),Se.dataTransfer.effectAllowed="copy")},onDragEnd:Se=>{La(Se)&&je(O)},className:Ye("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",ci(A)),title:O.path,children:[n.jsx(Co,{filePath:O.path,extension:O.extension,className:"size-3.5"}),n.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},children:`\u200E${O.relativePath??O.path}\u200E`})]})},O.path)}):Vn?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{children:Vn}),n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsxs(yt,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{z()},children:[n.jsx(ue,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})}),n.jsx(Dt,{sideOffset:6,children:o("contextTooltips.files.retryFileList")})]})]}):Dr&&l?null:n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("sidebarFilesTree.state.loading")})}),Mo?n.jsx("ul",{ref:St,className:"relative min-w-[max(100%,var(--oc-file-tree-width,0px))]",style:{height:Ys.getTotalSize()},onFocus:Ao,onBlur:Oo,children:Ys.getVirtualItems().map(O=>{const A=X[O.index];if(!A)return null;const Se=A.kind==="node"?A.node.path:void 0;return n.jsx("li",{ref:Ys.measureElement,"data-index":O.index,"data-tree-row-path":Se,"data-tree-disclosure-path":A.kind==="node"?Se:`${A.directory}/`,"data-file-tree-path":A.kind==="node"&&A.node.type==="file"?Se:void 0,className:Ye("absolute inset-x-0 top-0",A.kind==="node"&&"min-w-max"),style:{transform:`translateY(${O.start-us}px)`},children:En(A)},O.key)})}):null]}),ut?n.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:[n.jsx(ue,{name:nt?"loader-4":"folder-received",className:Ye("size-4 flex-shrink-0",nt&&"animate-spin")}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:Hn,children:o(nt?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Hn})})]}):le?n.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:[n.jsx(ue,{name:"folder-received",className:"size-4 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:_r,children:o("sidebarFilesTree.drop.moveTarget",{path:_r})})]}):null]}),ft,n.jsx(dr,{open:!!Ve,onOpenChange:O=>!O&&lt(null),children:n.jsxs(ur,{children:[n.jsxs(fr,{children:[n.jsxs(pr,{children:[Ve==="createFile"&&o("sidebarFilesTree.dialog.createFile.title"),Ve==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.title"),Ve==="rename"&&o("sidebarFilesTree.dialog.rename.title"),Ve==="delete"&&o("sidebarFilesTree.dialog.delete.title")]}),n.jsxs(mr,{children:[Ve==="createFile"&&o("sidebarFilesTree.dialog.createFile.description",{path:ct?.path??o("sidebarFilesTree.dialog.rootFallback")}),Ve==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.description",{path:ct?.path??o("sidebarFilesTree.dialog.rootFallback")}),Ve==="rename"&&o("sidebarFilesTree.dialog.rename.description",{name:ct?.name??""}),Ve==="delete"&&o("sidebarFilesTree.dialog.delete.description",{name:ct?.name??""})]})]}),Ve!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(Fn,{value:k,onChange:O=>Y(O.target.value),placeholder:o(Ve==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:O=>{O.key==="Enter"&&Fs()},autoFocus:true})}),n.jsxs(no,{children:[n.jsx(yt,{variant:"outline",onClick:()=>lt(null),disabled:Ne,children:o("sidebarFilesTree.dialog.cancel")}),n.jsx(yt,{variant:Ve==="delete"?"destructive":"default",onClick:()=>{Fs()},disabled:Ne||Ve!=="delete"&&!k.trim(),children:Ne?n.jsx(ue,{name:"loader-4",className:"size-4 animate-spin"}):o(Ve==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),n.jsx(dr,{open:re!==null,onOpenChange:O=>{O||H(null)},children:n.jsxs(ur,{showCloseButton:false,className:"max-w-sm gap-5",children:[n.jsxs(fr,{children:[n.jsx(pr,{children:o("sidebarFilesTree.dialog.move.title")}),n.jsx(mr,{children:re?o("sidebarFilesTree.dialog.move.description",{name:Fo,folder:Gn(l,re.targetDirectory)}):null})]}),n.jsxs(no,{className:"w-full sm:items-center sm:justify-between",children:[n.jsxs("div",{className:"flex cursor-pointer items-center gap-2 typography-meta text-muted-foreground",onClick:()=>de(!oe),children:[n.jsx(pa,{checked:!oe,onChange:O=>de(!O),ariaLabel:o("sidebarFilesTree.dialog.move.neverAsk")}),n.jsx("span",{children:o("sidebarFilesTree.dialog.move.neverAsk")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(yt,{variant:"ghost",onClick:()=>H(null),children:o("sidebarFilesTree.dialog.cancel")}),n.jsx(yt,{onClick:is,children:o("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function y3(t){return t.runtimeKey}const v3=Tr(()=>Vt(()=>import("./WalkthroughView-l9TMdlPB.js"),__vite__mapDeps([212,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,213,186,187,188,189,190,191,192,193,194,195,181,182,183,185,196,197,198,199,200,201,202,203,214,215,216,217])).then(t=>({default:t.WalkthroughView}))),S3=Tr(()=>Vt(()=>import("./DiffView-CS0gR_am.js"),__vite__mapDeps([218,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,213,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,219,185,196,197,198,199,200,201,202,203,204,205,206,207,209,210,214,217])).then(t=>({default:t.DiffView}))),k3=Tr(()=>Vt(()=>import("./FilesView-tcU8_bnh.js").then(t=>t.F),__vite__mapDeps([220,5,1,2,3,4,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,221,222,223,224,203,181,182,183,225,226,200,227,186,187,188,189,190,191,192,193,194,195,228,197,229,230,231,201,199,210,232,233,209,206,217,202,234])).then(t=>({default:t.FilesView}))),j3=c.lazy(()=>Vt(()=>import("./GuestPanelContent-CJ_wlnNr.js"),__vite__mapDeps([235,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])).then(t=>({default:t.GuestPanelContent}))),$s=(t,e)=>`${t}\0${e}`,T3=6e4,C3=({visible:t,active:e,fill:s=false,side:r})=>{const{t:o}=gt(),a=K(S=>S.contextEditorTreeWidth),i=K(S=>S.setContextEditorTreeWidth),[u,d]=c.useState(false),l=c.useRef(0),f=c.useRef(a),m=c.useRef(null),p=c.useRef(null),h=c.useRef(null),x=c.useCallback(S=>{const N=h.current;N&&(N.style.width=`${S}px`,N.style.setProperty("--oc-editor-tree-width",`${S}px`))},[]),g=S=>{if(t){try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}p.current=S.pointerId,d(true),l.current=S.clientX,f.current=a,m.current=a,S.preventDefault()}},v=S=>{if(!u||p.current!==S.pointerId)return;const N=r==="left"?S.clientX-l.current:l.current-S.clientX,F=mo(S.currentTarget)?-N:N,_=da(f.current+F);m.current!==_&&(m.current=_,x(_))},y=S=>{if(p.current!==S.pointerId)return;try{S.currentTarget.releasePointerCapture(S.pointerId)}catch{}const N=da(m.current??a);p.current=null,m.current=null,d(false),i(N)},C=t?a:0;return n.jsxs("div",{ref:h,className:Ye("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",s&&(r==="left"?"me-auto":"ms-auto")),style:{width:`${u?m.current??C:C}px`,maxWidth:s?"100%":void 0,"--oc-editor-tree-width":`${u?m.current??a:a}px`,overflowX:"clip",transitionProperty:u?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!s&&n.jsx("div",{"aria-hidden":"true",className:Ye("pointer-events-none absolute inset-y-0 z-20 w-px bg-border",r==="left"?"inset-e-0":"inset-s-0")}),t&&!s&&n.jsx("div",{className:Ye("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:v,onPointerUp:y,onPointerCancel:y,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{className:Ye("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:s?"100%":void 0},"aria-hidden":!t,children:n.jsx(b3,{visible:t&&e})})]})},Qs=t=>{const e=qe.c(12),{zone:s,isOpen:r,interactive:o,hidden:a,className:i,children:u}=t,d=!r||a;let l;e[0]!==u||e[1]!==d?(l=n.jsx(Id,{paused:d,children:u}),e[0]=u,e[1]=d,e[2]=l):l=e[2];let f;e[3]!==o||e[4]!==l?(f=n.jsx(vd.Provider,{value:true,children:n.jsx(Jp.Provider,{value:o,children:l})}),e[3]=o,e[4]=l,e[5]=f):f=e[5];let m;e[6]!==i||e[7]!==f?(m=n.jsx("div",{className:i,children:f}),e[6]=i,e[7]=f,e[8]=m):m=e[8];let p;return e[9]!==m||e[10]!==s?(p=n.jsx(Yk,{zone:s,children:m}),e[9]=m,e[10]=s,e[11]=p):p=e[11],p},E3=()=>{const{t}=gt(),e=Zs()??"",s=c.useMemo(()=>e?ds(e):"",[e]),r=K(k=>s?k.contextPanelByDirectory[s]:void 0),o=Pr(),a=o?.kind==="preparing",i=o?.kind==="ready"?o.directory:null,u=So(o,e)??"",d=K(k=>k.contextSurfaceZones),l=K(k=>k.contextPanelByDirectory),f=K(k=>k.closeContextPanelTab),m=K(k=>k.closeContextFile),p=K(k=>k.openContextPanelTab),h=K(k=>k.openAgentBrowserTab),x=K(k=>k.openContextFile),g=K(k=>k.contextEditorTreeVisible),v=K(k=>k.contextEditorVisible),y=K(k=>k.fileTreeSide),C=gs(k=>k.setSelectedPath),S=yr(k=>k.headerSlot),N=c.useMemo(()=>r?.tabs??[],[r?.tabs]),F=Kr(k=>k.chatCovered),_=c.useMemo(()=>{const k=Y=>{const Ne=r?to(r,d,Y):null,Re=Y==="bottom"&&F;return{activeTab:Ne,isOpen:!!(r&&lr(r,Y).isOpen&&Ne)&&!Re}};return{left:k("left"),right:k("right"),bottom:k("bottom")}},[F,r,d]),M={left:{..._.left,activeTab:Gr(_.left.activeTab,_.left.isOpen)},right:{..._.right,activeTab:Gr(_.right.activeTab,_.right.isOpen)},bottom:{..._.bottom,activeTab:Gr(_.bottom.activeTab,_.bottom.isOpen)}},B={left:na(M.left.isOpen),right:na(M.right.isOpen),bottom:na(M.bottom.isOpen)},T=k=>!B[k],I={left:rr(M.left.isOpen),right:rr(M.right.isOpen),bottom:rr(M.bottom.isOpen)},b={left:Vr(M.left.isOpen,I.left,M.left.activeTab?.mode),right:Vr(M.right.isOpen,I.right,M.right.activeTab?.mode),bottom:Vr(M.bottom.isOpen,I.bottom,M.bottom.activeTab?.mode)},w=k=>{const Y=fa(d,k);return{zone:Y,...M[Y]}},j=w("file"),R=w("chat"),L=w("browser"),E=w("diff"),D=w("terminal"),U=w("walkthrough"),[V,J]=c.useState([]),W=c.useRef(new Map),G=c.useCallback((k,Y)=>{const Ne=$s(k,Y);W.current.set(Ne,Date.now()),J(Re=>$f(Re,Ne))},[]);c.useEffect(()=>T0((k,Y)=>{W.current.set($s(k,Y),Date.now())}),[]);const le=K(k=>k.liveBrowserTabLimit),$=K(k=>k.agentBrowserSharesLogins);c.useEffect(()=>E0((k,Y)=>{const Ne=Y.directory?ds(Y.directory):s;if(!Ne)return null;const Re=h(Ne,k,Y.sessionId);return Re&&G(Ne,Re),Re}),[s,h,G]),c.useEffect(()=>I0((k,Y)=>K.getState().contextPanelByDirectory[k]?.tabs?.some(Re=>Re.id===Y&&Re.mode==="browser")?(f(k,Y),true):false),[f]),c.useEffect(()=>$n(k=>{if(k.type!=="file-open-request")return;const Y=k.directory??e;Y&&x(Y,k.path)}),[e,x]),c.useEffect(()=>$n(k=>{if(k.type!=="plan-open-request")return;const Y=k.directory??e,Ne=b1(Y,k.projectId);!Y||!Ne||K.getState().openProjectKnowledgePlan(Y,w1(Ne),k.planId)}),[e]);const re=_[L.zone].activeTab,H=re?.mode==="browser"?re.id:null;c.useEffect(()=>{j0(s,H)},[s,H]);const P=_[j.zone].activeTab;c.useEffect(()=>{if(!u||P?.mode!=="file"||!P.targetPath)return;const k=ks(P.targetPath)===ks(u);C(ds(u),P.targetPath,{allowOutsideRoot:!o&&k})},[u,o,P,C]);const ee=c.useMemo(()=>N.some(k=>k.mode==="file"&&k.targetPath),[N]),oe=c.useMemo(()=>N.some(k=>k.mode==="file"),[N]),de=ee&&(v||!g),he=j.activeTab?.mode==="file",Z=c.useCallback(k=>{s&&m(s,k)},[m,s]),ce=R.isOpen&&R.activeTab?.mode==="chat"?R.activeTab:null,ae=ce?No(ce.dedupeKey):null,te=c.useMemo(()=>(ce?.targetDirectory?ds(ce.targetDirectory):"")||s||null,[ce?.targetDirectory,s]),pe=c.useMemo(()=>ae?{sessionId:ae,directory:te}:null,[ae,te]);c.useEffect(()=>{if(!te||!ae||typeof window>"u")return;const k=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Uo(te,ae,false);return}Nd(ae),Uo(te,ae,true)};k();const Y=window.setInterval(k,1e4);return window.addEventListener("focus",k),window.addEventListener("blur",k),document.addEventListener("visibilitychange",k),()=>{window.clearInterval(Y),window.removeEventListener("focus",k),window.removeEventListener("blur",k),document.removeEventListener("visibilitychange",k),Uo(te,ae,false)}},[te,ae]);const Te=E.activeTab,Ae=c.useCallback(k=>{!s||Te?.mode!=="diff"||p(s,{mode:"diff",targetPath:Te.targetPath,targetDirectory:Te.targetDirectory,stagedDiff:k==="staged",diffScope:k})},[Te,s,p]),Pe=L.isOpen&&L.activeTab?.mode==="browser"?L.activeTab.id:null;c.useEffect(()=>{Pe&&s&&G(s,Pe)},[s,Pe,G]);const ze=c.useRef(null);c.useEffect(()=>{ze.current=Pe&&s?$s(s,Pe):null},[s,Pe]),c.useEffect(()=>{const k=()=>{const Ne=Date.now(),Re=W.current;ze.current&&Re.set(ze.current,Ne);const Ie=new Set;for(const[Ee,Ge]of Object.entries(K.getState().contextPanelByDirectory))for(const Be of Ge.tabs)Be.mode==="browser"&&Be.ownerSessionId!==null&&Ie.add($s(Ee,Be.id));J(Ee=>zf(Ee,Ie,Re,Ne-Wf))},Y=window.setInterval(k,T3);return()=>window.clearInterval(Y)},[]);const{loadedBrowserTabs:Oe,sleepingBrowserTabs:me}=c.useMemo(()=>{const k=new Set(V),Y=new Set;for(const[Ee,Ge]of Object.entries(l))for(const Be of Ge.tabs)Be.mode==="browser"&&Be.ownerSessionId===null&&Y.add($s(Ee,Be.id));const Ne=Bf(V,Y,le),Re=[],Ie=[];for(const[Ee,Ge]of Object.entries(l)){const Be=Ee===s;for(const Ze of Ge.tabs){if(Ze.mode!=="browser")continue;const et=$s(Ee,Ze.id),wt=Ze.ownerSessionId===null,Qe=Be&&Ze.id===Pe||(wt?Ne.has(et):k.has(et));if(!Qe&&!Be&&wt)continue;const dt={directory:Ee,id:Ze.id,targetPath:Ze.targetPath,ownerSessionId:Ze.ownerSessionId};(Qe?Re:Ie).push(dt)}}return Re.sort((Ee,Ge)=>$s(Ee.directory,Ee.id)<$s(Ge.directory,Ge.id)?-1:1),{loadedBrowserTabs:Re,sleepingBrowserTabs:Ie}},[l,s,le,V,Pe]);c.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const k=me.map(Y=>k0({tabId:Y.id,directory:Y.directory,ownerSessionId:Y.ownerSessionId,describe:()=>({title:"",url:Y.targetPath??""}),wake:()=>G(Y.directory,Y.id)}));return()=>k.forEach(Y=>Y())},[me,G]);const be=c.useMemo(()=>N.filter(k=>k.mode==="diff"),[N]),Ce=c.useMemo(()=>N.find(k=>k.mode==="terminal")??null,[N]),$e=c.useMemo(()=>N.find(k=>k.mode==="walkthrough")??null,[N]),We=c.useMemo(()=>N.filter(k=>wn(k.mode)),[N]),_e=c.useMemo(()=>N.filter(k=>k.mode==="pages"&&k.targetPath),[N]),Ue=cr(k=>k.guests),Xe=c.useMemo(()=>new Set(Ue.filter(y1).map(k=>k.id)),[Ue]),Me=c.useMemo(()=>{const k=new Map;for(const Y of Ue){const Ne=v1(Y);Ne&&k.set(Y.id,Ne)}return k},[Ue]),ot=D.zone,ye=c.useCallback(k=>{const Y=hi({mode:"terminal",label:t("layout.mainTab.terminal"),from:ot},k);return{finish:()=>Y.finish(s),cancel:Y.cancel}},[s,t,ot]),Ve=(k,Y)=>Y?S[k]:null,[lt,ct]=c.useState(()=>new Set),st=[...We,..._e].filter(k=>{if(lt.has(k.id))return false;const Y=w(k.mode);return Y.isOpen&&Y.activeTab?.id===k.id});return st.length>0&&ct(new Set([...lt,...st.map(k=>k.id)])),n.jsxs(n.Fragment,{children:[oe?n.jsxs(Qs,{zone:j.zone,interactive:b[j.zone],isOpen:j.isOpen,hidden:T(j.zone),className:Ye("absolute inset-0 flex",y==="left"&&"flex-row-reverse",he?"flex":"hidden"),children:[a?n.jsx("div",{className:"h-full min-w-0 flex-1",children:n.jsx(Ur,{})}):ee||!g?n.jsx("div",{className:Ye("h-full min-w-0 flex-1",ee&&!de&&"hidden"),children:ee?n.jsx(c.Suspense,{fallback:null,children:n.jsx(k3,{mode:"editor-only",visible:!T(j.zone)&&he&&de,onCloseFile:Z})}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx(ue,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),n.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,a?null:n.jsx(C3,{visible:g,active:j.isOpen&&he,fill:!de,side:y})]}):null,ce&&ae&&pe?n.jsx(Qs,{zone:R.zone,interactive:b[R.zone],isOpen:R.isOpen,hidden:T(R.zone),className:"absolute inset-0 bg-background",children:n.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:ae}),className:"h-full",children:n.jsx(Kc,{pinnedSession:pe,readOnly:ce.readOnly})})},ce.id):null,Oe.map(k=>{const Y=k.directory===s&&L.activeTab?.id===k.id,Ne=k.directory===s?i??k.directory:k.directory;return n.jsx(Qs,{zone:L.zone,interactive:b[L.zone],isOpen:L.isOpen,hidden:T(L.zone),className:Ye("absolute inset-0",!Y&&"invisible pointer-events-none"),children:n.jsx("div",{className:"h-full","aria-hidden":!Y||void 0,children:n.jsx(Id,{paused:!Y,children:k.directory===s&&a?n.jsx(Ur,{}):n.jsx(Kk,{initialUrl:k.targetPath??"",directory:k.directory,siteDirectory:Ne,tabID:k.id,ownerSessionId:k.ownerSessionId,visible:Y&&L.isOpen},k.ownerSessionId!==null&&!$?`${Ne}\0agent`:Ne)})})},$s(k.directory,k.id))}),be.map(k=>{const Y=E.activeTab?.id===k.id;return n.jsx(Qs,{zone:E.zone,interactive:b[E.zone],isOpen:E.isOpen,hidden:T(E.zone),className:Ye("absolute inset-0",!Y&&"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(bn,{value:Ve(E.zone,Y),children:a&&!k.targetDirectory?n.jsx(Ur,{}):n.jsx(S3,{directory:k.targetDirectory??i,visible:E.isOpen&&Y,hideStackedFileSidebar:true,stackedDefaultCollapsedAll:true,pinSelectedFileHeaderToTopOnNavigate:true,showOpenInEditorAction:true,diffScope:k.diffScope??(k.stagedDiff?"staged":null),onDiffScopeChange:Ae,targetFilePath:k.targetPath,flushContent:true})})})},k.id)}),Ce?n.jsx(Qs,{zone:D.zone,interactive:b[D.zone],isOpen:D.isOpen,hidden:T(D.zone),className:Ye("absolute inset-0",D.activeTab?.mode==="terminal"?"block":"hidden"),children:n.jsx(bn,{value:Ve(D.zone,D.activeTab?.mode==="terminal"),children:n.jsx(Zp.Provider,{value:ye,children:n.jsx(Xp,{visible:D.isOpen&&D.activeTab?.mode==="terminal",directory:Ce.targetDirectory,onLastTabClosed:()=>{s&&f(s,Ce.id)}})})})}):null,$e?n.jsx(Qs,{zone:U.zone,interactive:b[U.zone],isOpen:U.isOpen,hidden:T(U.zone),className:Ye("absolute inset-0",U.activeTab?.mode==="walkthrough"?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(bn,{value:Ve(U.zone,U.activeTab?.mode==="walkthrough"),children:n.jsx(v3,{directory:$e.targetDirectory??e,visible:U.isOpen&&U.activeTab?.mode==="walkthrough"})})})}):null,_e.map(k=>{const Y=w(k.mode);return!lt.has(k.id)||!k.targetPath?null:n.jsx(Qs,{zone:Y.zone,interactive:b[Y.zone],isOpen:Y.isOpen,hidden:T(Y.zone),className:Ye("absolute inset-0",Y.activeTab?.id===k.id?"block":"hidden"),children:n.jsx(Yp,{receivedId:k.targetPath})},k.id)}),We.map(k=>{if(!wn(k.mode))return null;const Y=w(k.mode);if(!lt.has(k.id))return null;const Ne=er(k.mode),Re=Xe.has(Ne),Ie=Me.get(Ne),Ee=Y.activeTab?.id===k.id,Ge=Ee&&Y.isOpen;return Re&&!Ie&&!Ge?null:n.jsx(Qs,{zone:Y.zone,interactive:b[Y.zone],isOpen:Y.isOpen,hidden:T(Y.zone),className:Ye("absolute inset-0",Ee?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(j3,{mode:k.mode,sharedSurface:Re,docking:Ie??null,surfaceMounted:Ge})})},k.id)})]})},I3={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},N3=()=>{const t=qe.c(20),{t:e}=gt(),s=Gs(P3),r=Gs(R3),o=c.useRef(null),[a,i]=c.useState(false);let u,d;t[0]!==s?(u=()=>{if(!s){i(false);return}const y=requestAnimationFrame(()=>i(true));return()=>cancelAnimationFrame(y)},d=[s],t[0]=s,t[1]=u,t[2]=d):(u=t[1],d=t[2]),c.useEffect(u,d);let l,f;if(t[3]!==s?(l=()=>{if(!s)return;const y=C=>{const S=o.current;S&&(S.style.transform=`translate(${C.clientX+12}px, ${C.clientY+12}px)`)};return window.addEventListener("pointermove",y),()=>window.removeEventListener("pointermove",y)},f=[s],t[3]=s,t[4]=l,t[5]=f):(l=t[4],f=t[5]),c.useEffect(l,f),!s)return null;const m=a?"opacity-100":"opacity-0";let p;t[6]!==m?(p=Ye("absolute inset-0 bg-surface-overlay/40 transition-opacity duration-150 ease-out motion-reduce:transition-none",m),t[6]=m,t[7]=p):p=t[7];let h;t[8]!==p?(h=n.jsx("div",{className:p}),t[8]=p,t[9]=h):h=t[9];let x;t[10]!==s.frames||t[11]!==r||t[12]!==e?(x=Ua.map(y=>{const C=s.frames[y];if(C.width<=0||C.height<=0)return null;const S=r===y;return n.jsx("div",{className:Ye("absolute flex items-center justify-center rounded-[10px] border transition-colors duration-100",S?"border-primary bg-background/90 text-foreground shadow-sm":"border-border bg-background/80 text-muted-foreground"),style:{left:C.left,top:C.top,width:C.width,height:C.height},children:n.jsx("span",{className:"typography-ui-label",children:e(I3[y])})},y)}),t[10]=s.frames,t[11]=r,t[12]=e,t[13]=x):x=t[13];let g;t[14]!==s.label?(g=n.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:s.label}),t[14]=s.label,t[15]=g):g=t[15];let v;return t[16]!==h||t[17]!==x||t[18]!==g?(v=yc.createPortal(n.jsxs("div",{className:"pointer-events-none fixed inset-0 z-[60]","aria-hidden":"true",children:[h,x,g]}),document.body),t[16]=h,t[17]=x,t[18]=g,t[19]=v):v=t[19],v};function P3(t){return t.drag}function R3(t){return t.hovered}const nc=320,D3=({rowWidth:t,leftWidth:e,rightWidth:s,sidebarWidth:r,opening:o})=>{let a=t-e-s;if(a>=nc)return{collapseSidebar:false,displace:null};const i=r!==null;if(i&&(a+=r),a>=nc)return{collapseSidebar:i,displace:null};const u=o==="left"?"right":"left";return{collapseSidebar:i,displace:(u==="left"?e:s)>0?u:null}},_3=({directoryKey:t,folded:e,readRowWidth:s})=>{const r=v=>{const y=v.contextPanelByDirectory[t];return{left:Qn(y,v.contextSurfaceZones,"left"),right:Qn(y,v.contextSurfaceZones,"right")}},o=(v,y,C)=>{const S=v.contextPanelByDirectory[t];return(C&&S?to(S,v.contextSurfaceZones,y):null)?v.contextZoneSizes[y]??Va:0},a=v=>{const y=v.contextPanelByDirectory[t];return y?Ua.some(C=>lr(y,C).expanded&&Vf(y,v,C)):false};let i=null,u=false,d=r(K.getState()),l=a(K.getState());const f=v=>{e.current=v,K.getState().setSidebarFoldedForExpandedZone(v==="expanded")},m=v=>{u=true,K.getState().setSidebarOpen(v),u=false},p=()=>{f(null),K.getState().isSidebarOpen||m(true)};!e.current&&K.getState().sidebarFoldedForExpandedZone&&(e.current="expanded");const h=e.current;h&&!(h==="expanded"?l:d[h])&&p(),!e.current&&l&&K.getState().isSidebarOpen&&(f("expanded"),m(false));const x=(v,y,C)=>{const S=s();if(!S)return;const N=e.current==="expanded",F=D3({rowWidth:N?S-v.sidebarWidth:S,leftWidth:o(v,"left",C.left),rightWidth:o(v,"right",C.right),sidebarWidth:v.isSidebarOpen||N?v.sidebarWidth:null,opening:y});if(F.displace){const _=lr(v.contextPanelByDirectory[t],F.displace).activeTabId;_&&(i={side:F.displace,by:y,tabId:_})}F.collapseSidebar&&(f(y),v.isSidebarOpen&&m(false)),F.displace&&v.closeContextZone(t,F.displace)},g=v=>{if(i?.side===v){e.current===v&&f(i.by);return}const y=i?.by===v?i:null;y&&(i=null),e.current===v&&(y?f(y.side):p()),y&&K.getState().setActiveContextPanelTab(t,y.tabId)};return K.subscribe((v,y)=>{v.isSidebarOpen!==y.isSidebarOpen&&!u&&f(null);const C=r(v),S=a(v),N=d,F=l;d=C,l=S;const _=["left","right"],M=_.filter(T=>C[T]&&!N[T]),B=_.filter(T=>!C[T]&&N[T]);for(const T of B){const I=T==="left"?"right":"left";M.includes(I)&&(e.current===T&&f(I),i?.by===T&&(i=null))}for(const T of B)g(T);for(const T of M)x(v,T,C);S&&!F&&v.isSidebarOpen?(f("expanded"),m(false)):!S&&F&&e.current==="expanded"&&p()})},A3=()=>{const t=qe.c(5),e=Zs();let s;t[0]!==e?(s=e?ds(e):"",t[0]=e,t[1]=s):s=t[1];const r=s,o=c.useRef(null);let a,i;return t[2]!==r?(a=()=>{if(r)return _3({directoryKey:r,folded:o,readRowWidth:O3})},i=[r],t[2]=r,t[3]=a,t[4]=i):(a=t[3],i=t[4]),c.useEffect(a,i),null};function O3(){return document.querySelector("[data-workspace-row]")?.clientWidth}const M3=t=>{const e=qe.c(54),{open:s,onOpenChange:r}=t,{t:o}=gt(),a=K(F3),i=K(L3),u=K($3),d=K(B3),l=K(z3),f=ii(),m=K(S1);let p;if(e[0]!==a||e[1]!==f||e[2]!==m){let V;e[4]!==m?(V=J=>m||J.id!=="workflows",e[4]=m,e[5]=V):V=e[5],p=ma(a,f).filter(V),e[0]=a,e[1]=f,e[2]=m,e[3]=p}else p=e[3];const h=p,x=u.length===0;let g;if(e[6]!==u||e[7]!==h){let V;e[9]!==u?(V=J=>u.includes(J.id),e[9]=u,e[10]=V):V=e[10],g=h.every(V),e[6]=u,e[7]=h,e[8]=g}else g=e[8];const v=g,y=c.useRef(false);let C;e[11]!==u||e[12]!==h||e[13]!==o?(C=h.map((V,J)=>({id:V.id,label:V.label??o(V.labelKey),visible:!u.includes(V.id),groupStart:J>0&&sn(h[J-1])!==sn(V)})),e[11]=u,e[12]=h,e[13]=o,e[14]=C):C=e[14];const S=C;let N;e[15]!==a||e[16]!==f||e[17]!==i?(N=V=>{const J=ma(V,f).map(W3).filter(G=>V.includes(G)),W=new Set(J);i([...J,...a.filter(G=>!W.has(G))])},e[15]=a,e[16]=f,e[17]=i,e[18]=N):N=e[18];const F=N;let _;e[19]!==r?(_=(V,J)=>{if(!V&&J.reason==="escape-key"&&y.current){J.cancel(),J.allowPropagation();return}y.current=false,r(V)},e[19]=r,e[20]=_):_=e[20];let M;e[21]===Symbol.for("react.memo_cache_sentinel")?(M=V=>{y.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(V.key)&&V.preventBaseUIHandler()},e[21]=M):M=e[21];let B;e[22]!==o?(B=o("contextRail.configure.dialogTitle"),e[22]=o,e[23]=B):B=e[23];let T;e[24]!==B?(T=n.jsx(pr,{children:B}),e[24]=B,e[25]=T):T=e[25];let I;e[26]!==o?(I=o("contextRail.configure.dialogDescription"),e[26]=o,e[27]=I):I=e[27];let b;e[28]!==I?(b=n.jsx(mr,{children:I}),e[28]=I,e[29]=b):b=e[29];let w;e[30]!==b||e[31]!==T?(w=n.jsxs(fr,{children:[T,b]}),e[30]=b,e[31]=T,e[32]=w):w=e[32];let j;e[33]!==o?(j=o("contextRail.configure.dragInstructions"),e[33]=o,e[34]=j):j=e[34];let R;e[35]===Symbol.for("react.memo_cache_sentinel")?(R=V=>{y.current=V},e[35]=R):R=e[35];let L;e[36]!==F||e[37]!==S||e[38]!==d||e[39]!==j?(L=n.jsx(Qp,{items:S,onVisibleChange:d,onReorder:F,settingsItemPrefix:"layout.context-rail.surface.",dragInstructions:j,onDraggingChange:R}),e[36]=F,e[37]=S,e[38]=d,e[39]=j,e[40]=L):L=e[40];let E;e[41]!==x||e[42]!==v||e[43]!==l||e[44]!==o?(E=x?null:n.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[v?n.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):n.jsx("span",{}),n.jsx(yt,{variant:"link",size:"xs",onClick:()=>l([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[41]=x,e[42]=v,e[43]=l,e[44]=o,e[45]=E):E=e[45];let D;e[46]!==w||e[47]!==L||e[48]!==E?(D=n.jsxs(ur,{className:"max-w-md",onKeyDown:M,children:[w,L,E]}),e[46]=w,e[47]=L,e[48]=E,e[49]=D):D=e[49];let U;return e[50]!==s||e[51]!==D||e[52]!==_?(U=n.jsx(dr,{open:s,onOpenChange:_,children:D}),e[50]=s,e[51]=D,e[52]=_,e[53]=U):U=e[53],U};function F3(t){return t.contextRailOrder}function L3(t){return t.setContextRailOrder}function $3(t){return t.contextRailHiddenSurfaces}function B3(t){return t.setContextRailSurfaceVisible}function z3(t){return t.setContextRailHiddenSurfaces}function W3(t){return t.id}const Ju=150,V3=500,U3=[],H3=t=>{const e=qe.c(70),{surface:s,isActive:r,showActivityDot:o,label:a,description:i,badgeCount:u,badgeAriaLabel:d,badgeDescription:l,listening:f,orderNumber:m,showOrderNumber:p,onSelect:h}=t,x=f===void 0?false:f,g=K(G3);let v;e[0]!==g?(v=Ga("switch_context_surface",g),e[0]=g,e[1]=v):v=e[1];const y=v;let C;e[2]!==m||e[3]!==y?(C=y&&y!==Gc&&m!=null&&m<=10?bs(`${y}+${m===10?"0":m}`):void 0,e[2]=m,e[3]=y,e[4]=C):C=e[4];const S=C;let N;e[5]!==s.id?(N={id:s.id},e[5]=s.id,e[6]=N):N=e[6];const{attributes:F,listeners:_,setNodeRef:M,transform:B,transition:T,isDragging:I}=Zd(N),b=u!=null&&u>0;let w;e[7]!==B?(w=Yd.Translate.toString(B),e[7]=B,e[8]=w):w=e[8];let j;e[9]!==w||e[10]!==T?(j={transform:w,transition:T},e[9]=w,e[10]=T,e[11]=j):j=e[11];const R=I&&"z-10 opacity-70";let L;e[12]!==R?(L=Ye("relative",R),e[12]=R,e[13]=L):L=e[13];let E;e[14]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx("div",{}),e[14]=E):E=e[14];let D;e[15]!==h||e[16]!==s?(D=()=>h(s),e[15]=h,e[16]=s,e[17]=D):D=e[17];const U=d??a,V=s.id,J=r?"oc-selected text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground";let W;e[18]!==J?(W=Ye("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",J),e[18]=J,e[19]=W):W=e[19];let G;e[20]!==s.icon||e[21]!==s.iconSrc?(G=n.jsx(li,{icon:s.icon,iconSrc:s.iconSrc,className:"h-[17px] w-[17px]"}),e[20]=s.icon,e[21]=s.iconSrc,e[22]=G):G=e[22];let le;e[23]!==b||e[24]!==x||e[25]!==m||e[26]!==o||e[27]!==p?(le=p&&m!=null?n.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:m===10?"0":m}):x?n.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-error)]"}):b?n.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?n.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[23]=b,e[24]=x,e[25]=m,e[26]=o,e[27]=p,e[28]=le):le=e[28];let $;e[29]!==F||e[30]!==r||e[31]!==_||e[32]!==s.id||e[33]!==D||e[34]!==U||e[35]!==W||e[36]!==G||e[37]!==le?($=n.jsx(Pt,{asChild:true,children:n.jsxs("button",{type:"button",...F,..._,onClick:D,"aria-label":U,"aria-pressed":r,"data-context-surface":V,className:W,children:[G,le]})}),e[29]=F,e[30]=r,e[31]=_,e[32]=s.id,e[33]=D,e[34]=U,e[35]=W,e[36]=G,e[37]=le,e[38]=$):$=e[38];let re;e[39]!==g||e[40]!==s.id||e[41]!==S?(re=s.id==="terminal"?bs(Es("toggle_terminal",g),""):S,e[39]=g,e[40]=s.id,e[41]=S,e[42]=re):re=e[42];let H;e[43]!==a||e[44]!==re?(H=n.jsx(qs,{label:a,shortcut:re}),e[43]=a,e[44]=re,e[45]=H):H=e[45];let P;e[46]!==i?(P=n.jsx("span",{className:"typography-micro text-muted-foreground",children:i}),e[46]=i,e[47]=P):P=e[47];let ee;e[48]!==l?(ee=l?n.jsx("span",{className:"typography-micro text-muted-foreground",children:l}):null,e[48]=l,e[49]=ee):ee=e[49];let oe;e[50]!==s.id?(oe=s.id==="context"?n.jsx(tu,{}):null,e[50]=s.id,e[51]=oe):oe=e[51];let de;e[52]!==H||e[53]!==P||e[54]!==ee||e[55]!==oe?(de=n.jsx(Dt,{side:"left",sideOffset:8,className:"max-w-72 break-words",children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[H,P,ee,oe]})}),e[52]=H,e[53]=P,e[54]=ee,e[55]=oe,e[56]=de):de=e[56];let he;e[57]!==$||e[58]!==de?(he=n.jsx(yo,{render:E,children:n.jsxs(Rt,{delayDuration:Ju,children:[$,de]})}),e[57]=$,e[58]=de,e[59]=he):he=e[59];let Z;e[60]!==s.mode?(Z=n.jsx(Nr,{children:n.jsx(Uc,{mode:s.mode})}),e[60]=s.mode,e[61]=Z):Z=e[61];let ce;e[62]!==he||e[63]!==Z?(ce=n.jsxs(Ir,{children:[he,Z]}),e[62]=he,e[63]=Z,e[64]=ce):ce=e[64];let ae;return e[65]!==M||e[66]!==ce||e[67]!==j||e[68]!==L?(ae=n.jsx("div",{ref:M,style:j,className:L,children:ce}),e[65]=M,e[66]=ce,e[67]=j,e[68]=L,e[69]=ae):ae=e[69],ae},K3=t=>{if(!t)return{icon:"ticket-2"};const e=P1(t,"line");return e?{icon:e}:{icon:R1,iconSrc:D1(t)}},q3=()=>{const t=qe.c(126),{t:e}=gt(),s=Zs();let r;t[0]!==s?(r=s?ds(s):"",t[0]=s,t[1]=r):r=t[1];const o=r;let a;t[2]!==o?(a=ne=>o?ne.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=a):a=t[3];const i=K(a),u=K(Z3),d=K(X3),l=K(Y3),f=K(J3),m=K(Q3),p=K(ej),h=K(tj),x=K(sj),g=Uf();let v;t[4]!==g?(v=ne=>g.some(Je=>Je.instances.defaultInstance!==null&&ne.entries[Xn({provider:Je.id,instance:Je.instances.defaultInstance})]?.hasChecked===true),t[4]=g,t[5]=v):v=t[5];const y=vn(v),C=vn(rj),S=k1(o||null),N=Wa(S==="none"?null:S??g[0]?.id),F=S==="none"?"pullRequest":N.terminology.changeRequest,{screenWidth:_}=Tn(),M=Pr(),B=s??null;let T;t[6]!==M||t[7]!==B?(T=So(M,B),t[6]=M,t[7]=B,t[8]=T):T=t[8];const I=T,b=j1(I),w=jo(b),{git:j}=Is(),R=Ln(oj),L=Ln(aj);let E,D;t[9]!==R||t[10]!==L||t[11]!==j||t[12]!==b||t[13]!==I?(E=()=>{if(!j||!I||!b||b===I)return;ji(()=>R(b,j));const ne=ts(I),Je=ts(b);return xr.onGitRefreshHint(kt=>{const bt=ts(kt.directory);bt!==ne&&bt!==Je||ji(()=>L(b,j,{silent:true}))})},D=[R,L,j,b,I],t[9]=R,t[10]=L,t[11]=j,t[12]=b,t[13]=I,t[14]=E,t[15]=D):(E=t[14],D=t[15]),c.useEffect(E,D);let U;t[16]!==x?(U=Ga("switch_context_surface",x),t[16]=x,t[17]=U):U=t[17];const V=U,[J,W]=c.useState(false);let G,le;t[18]!==V?(le=()=>{const ne=new Set;let Je=null,kt=false;const bt=ij,_t=()=>{Gi(V,ne)?!kt&&Je===null&&(Je=setTimeout(()=>W(true),V3)):(kt=false,Je!==null&&(clearTimeout(Je),Je=null),W(false))},He=se=>{if(ne.add(se.key.toLowerCase()),bt(se.key)&&Gi(V,ne)){kt=true,Je!==null&&(clearTimeout(Je),Je=null),W(false);return}_t()},pt=se=>{ne.delete(se.key.toLowerCase()),_t()},q=()=>{ne.clear(),kt=false,Je!==null&&(clearTimeout(Je),Je=null),W(false)};return window.addEventListener("keydown",He,true),window.addEventListener("keyup",pt,true),window.addEventListener("blur",q),()=>{window.removeEventListener("keydown",He,true),window.removeEventListener("keyup",pt,true),window.removeEventListener("blur",q),Je!==null&&clearTimeout(Je)}},G=[V],t[18]=V,t[19]=G,t[20]=le):(G=t[19],le=t[20]),c.useEffect(le,G);let $;t[21]===Symbol.for("react.memo_cache_sentinel")?($={activationConstraint:{distance:8}},t[21]=$):$=t[21];let re;t[22]===Symbol.for("react.memo_cache_sentinel")?(re={activationConstraint:{delay:200,tolerance:6}},t[22]=re):re=t[22];const H=Hd(ao(qd,$),ao(Kd,re)),P=ii(),ee=qi(lj),oe=T1(cj),de=qi(dj),he=i?.tabs??U3,Z=C1(he,s||null),ce=E1();let ae;t[23]!==ce?(ae=I1(ce),t[23]=ce,t[24]=ae):ae=t[24];const te=ae;let pe;t[25]!==h||t[26]!==i?(pe=za(i,h),t[25]=h,t[26]=i,t[27]=pe):pe=t[27];const Te=pe,Ae=w?.files.length??0;let Pe;if(t[28]!==l||t[29]!==d||t[30]!==P||t[31]!==te||t[32]!==S||t[33]!==_||t[34]!==C||t[35]!==he||t[36]!==N||t[37]!==Z){let ne;t[39]!==S||t[40]!==N?(ne=Je=>Je.id==="pr"?{...Je,...K3(S==="none"?null:N)}:Je,t[39]=S,t[40]=N,t[41]=ne):ne=t[41],Pe=N1({railOrder:d,hiddenSurfaces:l,isVSCode:zn(),screenWidth:_,tabs:he,sourceControlConnected:C,workflowsShown:Z,receivedPagesShown:te,extras:P}).map(ne),t[28]=l,t[29]=d,t[30]=P,t[31]=te,t[32]=S,t[33]=_,t[34]=C,t[35]=he,t[36]=N,t[37]=Z,t[38]=Pe}else Pe=t[38];const ze=Pe;let Oe;t[42]!==he?(Oe=he.some(uj),t[42]=he,t[43]=Oe):Oe=t[43];const me=Oe;let be,Ce;t[44]!==p||t[45]!==h||t[46]!==y||t[47]!==o||t[48]!==me||t[49]!==Te||t[50]!==C?(be=()=>{!o||!y||C||me||!Te.has("pr")||p(o,fa(h,"pr"))},Ce=[p,h,o,y,me,Te,C],t[44]=p,t[45]=h,t[46]=y,t[47]=o,t[48]=me,t[49]=Te,t[50]=C,t[51]=be,t[52]=Ce):(be=t[51],Ce=t[52]),c.useEffect(be,Ce);const[$e,We]=c.useState(false),_e=c.useRef(null),Ue=c.useRef(null);let Xe;t[53]!==F||t[54]!==ze||t[55]!==e?(Xe=ne=>{const Je=ze.find(bt=>bt.id===ne.active.id),kt=_e.current?.getBoundingClientRect().left;!Je||kt===void 0||(Ue.current?.cancel(),Ue.current=hi({mode:Je.mode,label:Je.label??e(Us(Je.labelKey,F)),from:fa(K.getState().contextSurfaceZones,Je.mode)},bt=>bt.x<kt-16))},t[53]=F,t[54]=ze,t[55]=e,t[56]=Xe):Xe=t[56];const Me=Xe;let ot;t[57]===Symbol.for("react.memo_cache_sentinel")?(ot=()=>{Ue.current?.cancel(),Ue.current=null},t[57]=ot):ot=t[57];const ye=ot;let Ve,lt;t[58]===Symbol.for("react.memo_cache_sentinel")?(Ve=()=>()=>Ue.current?.cancel(),lt=[],t[58]=Ve,t[59]=lt):(Ve=t[58],lt=t[59]),c.useEffect(Ve,lt);let ct;t[60]!==o||t[61]!==P||t[62]!==f?(ct=ne=>{const Je=Ue.current;if(Ue.current=null,Je?.finish(o))return;const{active:kt,over:bt}=ne;if(!bt||kt.id===bt.id)return;const _t=ma(K.getState().contextRailOrder,P),He=De=>{const we=_t.find(rt=>rt.id===De);return we?sn(we):null};if(He(kt.id)!==He(bt.id))return;const pt=_t.map(fj),q=pt.indexOf(kt.id),se=pt.indexOf(bt.id);q===-1||se===-1||f(ob(pt,q,se))},t[60]=o,t[61]=P,t[62]=f,t[63]=ct):ct=t[63];const st=ct;let k;if(t[64]!==ze){k=[];for(const ne of ze){const Je=k.at(-1);Je&&sn(Je[0])===sn(ne)?Je.push(ne):k.push([ne])}t[64]=ze,t[65]=k}else k=t[65];const Y=k;let Ne;t[66]!==ze?(Ne=ne=>{const Je=ze.find(bt=>bt.id===ne.active.id);if(!Je)return ba(ne);const kt=sn(Je);return ba({...ne,droppableContainers:ne.droppableContainers.filter(bt=>{const _t=ze.find(He=>He.id===bt.id);return _t!==void 0&&sn(_t)===kt})})},t[66]=ze,t[67]=Ne):Ne=t[67];const Re=Ne;if(!o)return null;let Ie,Ee,Ge,Be,Ze,et,wt,Qe,dt,at;if(t[68]!==F||t[69]!==Ae||t[70]!==de||t[71]!==Re||t[72]!==o||t[73]!==Y||t[74]!==ee||t[75]!==oe||t[76]!==st||t[77]!==Me||t[78]!==m||t[79]!==J||t[80]!==H||t[81]!==Te||t[82]!==e||t[83]!==u){let ne=0;Qe=_e,t[94]!==e?(dt=e("contextRail.aria.rail"),t[94]=e,t[95]=dt):dt=t[95],at="flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",Ie=Gd,Ee=H,Ge=Re,Be=Me,Ze=ye,et=st,wt=Y.map((Je,kt)=>n.jsxs(c.Fragment,{children:[kt>0?n.jsx("div",{"aria-hidden":"true",className:"h-1.5 shrink-0"}):null,n.jsx(Xd,{items:Je.map(pj),strategy:rb,children:Je.map(bt=>{ne=ne+1;const _t=bt.label??e(Us(bt.labelKey,F)),He=bt.id==="git"&&!u?Ae:0,pt=wn(bt.mode)&&!Te.has(bt.mode)?ee[er(bt.mode)]??0:0,q=He>0?He:pt>0?pt:null,se=q!==null&&He===0,De=wn(bt.mode)&&(oe[er(bt.mode)]??0)>0;return n.jsx(H3,{surface:bt,isActive:Te.has(bt.mode),showActivityDot:false,label:_t,description:e(Us(bt.descriptionKey,F)),badgeCount:q,listening:De,badgeAriaLabel:De?e("contextRail.surface.plugin.listeningAria",{label:_t}):q!==null?e(se?q===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":q===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:_t,count:q}):null,badgeDescription:De?e("contextRail.surface.plugin.listeningTooltip"):q!==null?e(se?q===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":q===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:q}):null,orderNumber:ne,showOrderNumber:J,onSelect:we=>{wn(we.mode)&&de(er(we.mode)),m(o,we.mode)}},bt.id)})})]},sn(Je[0]))),t[68]=F,t[69]=Ae,t[70]=de,t[71]=Re,t[72]=o,t[73]=Y,t[74]=ee,t[75]=oe,t[76]=st,t[77]=Me,t[78]=m,t[79]=J,t[80]=H,t[81]=Te,t[82]=e,t[83]=u,t[84]=Ie,t[85]=Ee,t[86]=Ge,t[87]=Be,t[88]=Ze,t[89]=et,t[90]=wt,t[91]=Qe,t[92]=dt,t[93]=at}else Ie=t[84],Ee=t[85],Ge=t[86],Be=t[87],Ze=t[88],et=t[89],wt=t[90],Qe=t[91],dt=t[92],at=t[93];let z;t[96]!==Ie||t[97]!==Ee||t[98]!==Ge||t[99]!==Be||t[100]!==Ze||t[101]!==et||t[102]!==wt?(z=n.jsx(Ie,{sensors:Ee,collisionDetection:Ge,onDragStart:Be,onDragCancel:Ze,onDragEnd:et,children:wt}),t[96]=Ie,t[97]=Ee,t[98]=Ge,t[99]=Be,t[100]=Ze,t[101]=et,t[102]=wt,t[103]=z):z=t[103];let fe;t[104]!==e?(fe=e("contextRail.configure.open"),t[104]=e,t[105]=fe):fe=t[105];let ke;t[106]===Symbol.for("react.memo_cache_sentinel")?(ke=()=>We(true),t[106]=ke):ke=t[106];let ie;t[107]===Symbol.for("react.memo_cache_sentinel")?(ie=n.jsx(ue,{name:"list-settings",className:"h-[17px] w-[17px]"}),t[107]=ie):ie=t[107];let xe;t[108]!==fe?(xe=n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button","aria-label":fe,onClick:ke,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground",children:ie})}),t[108]=fe,t[109]=xe):xe=t[109];let Le;t[110]!==e?(Le=e("contextRail.configure.open"),t[110]=e,t[111]=Le):Le=t[111];let Ke;t[112]!==Le?(Ke=n.jsx(Dt,{side:"left",sideOffset:8,children:Le}),t[112]=Le,t[113]=Ke):Ke=t[113];let ve;t[114]!==xe||t[115]!==Ke?(ve=n.jsxs(Rt,{delayDuration:Ju,children:[xe,Ke]}),t[114]=xe,t[115]=Ke,t[116]=ve):ve=t[116];let je;t[117]!==$e?(je=n.jsx(M3,{open:$e,onOpenChange:We}),t[117]=$e,t[118]=je):je=t[118];let vt;return t[119]!==Qe||t[120]!==dt||t[121]!==at||t[122]!==z||t[123]!==ve||t[124]!==je?(vt=n.jsxs("nav",{ref:Qe,"aria-label":dt,className:at,children:[z,ve,je]}),t[119]=Qe,t[120]=dt,t[121]=at,t[122]=z,t[123]=ve,t[124]=je,t[125]=vt):vt=t[125],vt};function G3(t){return t.shortcutOverrides}function Z3(t){return t.workStatusPanelVisible}function X3(t){return t.contextRailOrder}function Y3(t){return t.contextRailHiddenSurfaces}function J3(t){return t.setContextRailOrder}function Q3(t){return t.openContextSurface}function ej(t){return t.closeContextZone}function tj(t){return t.contextSurfaceZones}function sj(t){return t.shortcutOverrides}function nj(t){return t.status?.status==="connected"}function rj(t){return Object.values(t.entries).some(nj)}function oj(t){return t.ensureStatus}function aj(t){return t.fetchStatus}function ij(t){return t.length===1&&t>="0"&&t<="9"}function lj(t){return t.countByGuest}function cj(t){return t.captureCountByGuest}function dj(t){return t.clearBadge}function uj(t){return t.mode==="pr"&&t.targetPath}function fj(t){return t.id}function pj(t){return t.id}const Ds=t=>t?n.jsx("span",{className:"oc-title-rest",children:t}):void 0,Ss=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},mj=()=>{const{t}=gt(),{git:e,sourceControl:s}=Is(),{childStores:r}=_1(),[o,a]=c.useState(false),[i,u]=c.useState(null),[d,l]=c.useState([]),[f,m]=c.useState(false),[p,h]=c.useState(false),[x,g]=c.useState(false),[v,y]=c.useState(false),[C,S]=c.useState(false),[N,F]=c.useState(new Set),_=it(k=>k.getWorktreeMetadata),M=it(k=>k.setNewSessionDraftTarget),B=it(k=>k.setDraftBootstrapPendingDirectory),T=M1,I=B1,b=it(k=>k.deleteSessions),w=it(k=>k.archiveSessions),j=it(k=>k.unarchiveSessions),R=K(k=>k.showDeletionDialog),L=K(k=>k.setShowDeletionDialog),E=qt(k=>k.currentDirectory),D=qt(k=>k.homeDirectory),U=Yt(k=>k.projects),V=Yt(k=>k.activeProjectId),{isMobile:J,isTablet:W,hasTouchInput:G}=Tn(),le=J||W||G,$=c.useMemo(()=>{const Y=(V?U.find(Ne=>Ne.id===V)??null:null)?.path??E;return Ss(Y)},[V,E,U]),re=c.useCallback(k=>{const Ne=Ss(k.projectDirectory)||$;return{id:(U.find(Ie=>Ss(Ie.path)===Ne)??null)?.id??`path:${Ne}`,path:Ne}},[$,U]),H=C&&N.size>0,[P,ee]=c.useState(false),oe=i?.mode==="worktree"?i.worktree??d[0]?.metadata??null:null,de=oe?.path,he=oe?.branch,Z=oe?re(oe).path:null;c.useEffect(()=>{if(ee(false),!de||!Z)return;let k=false;return A1(Z,{path:de,branch:he??""}).then(Y=>{k||ee(Y)}),()=>{k=true}},[he,de,Z]);const ce=c.useMemo(()=>{if(!P)return false;const k=i?.worktree;return k&&typeof k.branch=="string"&&k.branch.trim().length>0?!!k.status?.upstream?.split("/")[0]?.trim():d.length>0&&d.every(({metadata:Y})=>typeof Y.branch=="string"&&Y.branch.trim().length>0&&!!Y.status?.upstream?.split("/")[0]?.trim())},[P,i?.worktree,d]),ae=i?.mode==="worktree",te=v||!ae||!ce,pe=v||!ae,Te=ae?de:void 0,Ae=c.useCallback(k=>Te?O1(r,k):()=>{},[r,Te]),Pe=c.useSyncExternalStore(Ae,()=>Te?Zi(r,Te).length:0),ze=x&&Pe>0,Oe=c.useCallback(k=>{u({sessions:k.sessions,dateLabel:k.dateLabel,mode:k.mode??"session",worktree:k.worktree??null})},[]),me=c.useCallback(()=>{u(null),l([]),m(false),h(false),g(false),y(false),S(false),F(new Set)},[]),be=c.useCallback(async k=>{if(k.sessions.length===0)return;if(k.sessions.length===1){const Ie=k.sessions[0];await T(Ie.id)?Fe.success(t("sessions.sidebar.session.delete.success")):Fe.error(t("sessions.sidebar.session.delete.error"));return}const Y=k.sessions.map(Ie=>Ie.id),{deletedIds:Ne,failedIds:Re}=await b(Y);if(Ne.length>0){const Ie=Re.length>0?Re.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Re.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Re.length}):k.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:k.dateLabel}):void 0;Fe.success(Ne.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Ne.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Ne.length}),{description:Ds(Ie)})}Re.length>0&&Fe.error(Re.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Re.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Re.length}),{description:Ds(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[T,b,t]);c.useEffect(()=>xr.onDirectoryRequest(()=>{a(true)}),[]),c.useEffect(()=>{if(!i){l([]),m(false),h(false),g(false),S(false),F(new Set);return}const k=i.sessions.map(Re=>{const Ie=_(Re.id);return Ie?{session:Re,metadata:Ie}:null}).filter(Re=>!!Re);l(k),m(false),S(false),F(new Set);const Y=new Map;if(i.worktree?.path&&Y.set(Ss(i.worktree.path),i.worktree),k.forEach(({metadata:Re})=>{Re.path&&Y.set(Ss(Re.path),Re)}),Y.size===0){S(true);return}let Ne=false;return(async()=>{const Re=new Map,Ie=new Set;await Promise.all(Array.from(Y.entries()).map(async([Ee,Ge])=>{try{const Be=await Xi(Ge.path);Re.set(Ee,Be),Be?.isDirty&&Ie.add(Ee)}catch{Ge.status&&(Re.set(Ee,Ge.status),Ge.status.isDirty&&Ie.add(Ee))}})).catch(Ee=>{console.warn("Failed to inspect worktree status before deletion:",Ee)}),!Ne&&(F(Ie),S(true),u(Ee=>{if(!Ee?.worktree?.path)return Ee;const Ge=Ss(Ee.worktree.path),Be=Re.get(Ge);if(!Be)return Ee;const Ze=Ee.worktree.status;return Ze?.isDirty===Be.isDirty&&Ze?.ahead===Be.ahead&&Ze?.behind===Be.behind&&Ze?.upstream===Be.upstream?Ee:{...Ee,worktree:{...Ee.worktree,status:Be}}}),l(Ee=>Ee.map(Ge=>{const Be=Ss(Ge.metadata.path),Ze=Re.get(Be);return Ze?{session:Ge.session,metadata:{...Ge.metadata,status:Ze}}:Ge})))})(),()=>{Ne=true}},[i,_]),c.useEffect(()=>{ce||m(false)},[ce]);const Ce=c.useCallback(async(k,Y,Ne,Re)=>{const Ie=f&&ce,Ee=re(k),Ge=Ss(k.path),Be=Ss(Ee.path);try{await F1(Ee,k,{deleteRemoteBranch:Ie,deleteLocalBranch:Y,remoteName:k.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:s},skipTeardown:Re});const Ze=Qe=>!!(Ge&&Qe&&L1(Ge,Qe)),et=it.getState().newSessionDraft,wt=Ss(et?.directoryOverride);return et?.open&&Ze(wt)&&Be&&(B(null),M({projectId:Ee.id,directoryOverride:Be},{force:true})),Ze(Ss(qt.getState().currentDirectory))&&Be&&qt.getState().setDirectory(Be,{showOverlay:false}),true}catch(Ze){if(Ze instanceof Error&&$1(Ze))throw Ze;return Fe.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Ne,description:Ds(Ze instanceof Error?Ze.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),false}},[ce,f,re,e,B,M,s,t]),$e=c.useCallback((k,Y,Ne,Re)=>{const Ie=f&&ce,Ee=async(Ge,Be)=>{const Ze=Fe.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:Ho(k)}));H1(k.path);try{if(Re){const Qe=()=>Zi(r,k.path),dt=Qe().map(z=>z.id);if(!(await K1({worktreePath:k.path,projectDirectory:re(k).path,readSessions:Qe,removeWorktree:()=>Ce(k,Ne,Ze,Ge)})).removed)return;Yi(dt,{projectId:re(k).id}),Fe.success(t(Ie?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed"),{id:Ze,description:Ds(Ho(k))});return}const et=await q1({sessionIds:Be,removeWorktree:()=>Ce(k,Ne,Ze,Ge),restoreSessions:Qe=>j(Qe,{undo:true}),archiveSessions:async Qe=>Qe.length===1?await I(Qe[0])?{archivedIds:Qe,failedIds:[]}:{archivedIds:[],failedIds:Qe}:w(Qe)});if(!et.removed)return;Yi(Be,{projectId:re(k).id}),Fe.success(t(Ie?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed"),{id:Ze,description:Ds(Ho(k))});const{failedIds:wt}=et.archive;wt.length>0&&Fe.error(wt.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:wt.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:wt.length}),{description:Ds(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(et){Fe.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Ze,description:Ds(et instanceof Error?X1(et,t)??et.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain")),...et instanceof Error?G1(et,t("sessions.sidebar.sessionDialogs.worktree.deleteWithoutTeardown"),()=>{Ee(true,Z1(Be,k.path))}):void 0})}finally{Y1(k.path)}};return Ee(false,Y)},[I,w,ce,r,f,re,Ce,t,j]),We=c.useRef(new Set),_e=c.useCallback(async(k,Y)=>{const Ne=Ss(k.path);if(!We.current.has(Ne)){We.current.add(Ne);try{const Re=await Xi(k.path).catch(()=>{});if(!z1(Re)){Oe({sessions:Y,mode:"worktree",worktree:k});return}await $e(k,Y.map(Ie=>Ie.id),true,false)}finally{We.current.delete(Ne)}}},[Oe,$e]);c.useEffect(()=>xr.onDeleteRequest(k=>{if(!R&&(k.mode??"session")==="session"){be(k);return}if(k.mode==="worktree"&&k.skipDialogIfSafe&&k.worktree){_e(k.worktree,k.sessions);return}Oe(k)}),[Oe,R,be,_e]);const Ue=c.useCallback(async()=>{if(i){y(true);try{if(ae){const k=i.worktree??d[0]?.metadata;if(!k){Fe.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:Ds(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),y(false);return}$e(k,i.sessions.map(Y=>Y.id),p&&P,ze),me();return}if(i.sessions.length===1){const k=i.sessions[0];if(!await T(k.id)){Fe.error(t("sessions.sidebar.session.delete.error")),y(false);return}Fe.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const k=i.sessions.map(Re=>Re.id),{deletedIds:Y,failedIds:Ne}=await b(k);if(Y.length>0){const Re=Ne.length>0?Ne.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Ne.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Ne.length}):i.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:i.dateLabel}):void 0;Fe.success(Y.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Y.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Y.length}),{description:Ds(Re),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(Ne.length>0&&(Fe.error(Ne.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Ne.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Ne.length}),{description:Ds(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),Y.length===0)){y(false);return}}me()}finally{y(false)}}},[P,i,d,p,T,b,me,ae,ze,$e,t]),Xe=i?.worktree??d[0]?.metadata??null;let Me="";if(i?.mode==="worktree"){const k=i.sessions.length;ze?Me=Pe===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinkedKept",{count:Pe}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinkedKept",{count:Pe}):k===0?Me=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):k===1?Me=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:k}):Me=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:k})}else if(i){const k=i.sessions.length;k===1?Me=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):Me=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:k,dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:k})}const ot=i?n.jsxs("div",{className:Ye(ae?"space-y-3":"space-y-2"),children:[i.sessions.length>0&&n.jsxs("div",{className:Ye(ae?"oc-tile rounded-lg p-3":"oc-tile space-y-1.5 rounded-lg p-3"),children:[ae&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"typography-meta font-medium text-foreground",children:i.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i.sessions.length})]}),n.jsxs("ul",{className:Ye(ae?"mt-2 space-y-1":"space-y-0.5"),children:[i.sessions.slice(0,5).map(k=>n.jsxs("li",{className:Ye(ae?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground"),children:[n.jsx("span",{className:Ye(!ae&&"hidden"),children:"\u2022"}),n.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:k.title||t("sessions.sidebar.session.untitled")})]},k.id)),i.sessions.length>5&&n.jsx("li",{className:Ye(ae?"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})})]})]}),ae?n.jsxs("div",{className:"oc-tile space-y-2 rounded-lg p-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ue,{name:"worktree",className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),Xe?.label?n.jsx("span",{className:"typography-micro text-muted-foreground",children:Xe.label}):null]}),n.jsx("p",{className:"typography-micro text-muted-foreground break-all",children:Xe?W1(Xe.path,D):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),H&&n.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):n.jsx("div",{className:"oc-tile rounded-lg p-3",children:n.jsx("p",{className:"typography-meta text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,ye=ae&&P?ce?n.jsxs("button",{type:"button",onClick:()=>{te||m(k=>!k)},disabled:te,"aria-pressed":f,className:Ye("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",te?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[f?n.jsx(ue,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(ue,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):n.jsx("span",{className:"text-xs text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,Ve=ae&&P?n.jsxs("button",{type:"button",onClick:()=>{pe||h(k=>!k)},disabled:pe,"aria-pressed":p,className:Ye("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",pe?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[p?n.jsx(ue,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(ue,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,lt=ae&&Pe>0?n.jsxs("button",{type:"button",onClick:()=>{v||g(k=>!k)},disabled:v,"aria-pressed":x,className:Ye("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",v?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[x?n.jsx(ue,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(ue,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.keepSessions")]}):null,ct=ae?n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col items-start gap-1",children:[lt,Ve,ye]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(yt,{variant:"ghost",onClick:me,disabled:v,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(yt,{variant:"destructive",onClick:Ue,disabled:v,children:t(v?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("button",{type:"button",onClick:()=>L(!R),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":!R,children:[R?n.jsx(ue,{name:"checkbox-blank",className:"size-4"}):n.jsx(ue,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(yt,{variant:"ghost",onClick:me,disabled:v,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(yt,{variant:"destructive",onClick:Ue,disabled:v,children:v?t("sessions.sidebar.sessionDialogs.actions.deleting"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),st=ae?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return n.jsxs(n.Fragment,{children:[le?n.jsx(V1,{open:!!i,onClose:()=>{v||me()},title:st,footer:n.jsx("div",{className:"flex justify-end gap-2",children:ct}),children:n.jsxs("div",{className:"space-y-2 pb-2",children:[Me&&n.jsx("p",{className:"typography-meta text-muted-foreground",children:Me}),ot]})}):n.jsx(dr,{open:!!i,onOpenChange:k=>{if(!k){if(v)return;me()}},children:n.jsxs(ur,{className:Ye(ae?"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:[n.jsxs(fr,{children:[n.jsxs(pr,{className:Ye(ae&&"flex items-center gap-2"),children:[ae&&n.jsx(ue,{name:"delete-bin",className:"h-5 w-5"}),st]}),Me&&n.jsx(mr,{children:Me})]}),ae?n.jsx(ps,{outerClassName:"flex-1 min-h-0",className:"space-y-2",disableHorizontal:true,children:ot}):n.jsx("div",{children:ot}),n.jsx(no,{className:"mt-2 gap-2 pt-1 pb-1",children:ct})]})}),n.jsx(U1,{open:o,onOpenChange:a})]})},Qu=[{pattern:/^dev(:.*)?$/i},{pattern:/^start$/i},{pattern:/^start:(?:dev|preview|serve)(?::.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],hj=/^(?:(?:dev(?:elopment)?|preview|serve)(?: server)?|(?:start|run)\s+(?:dev(?:elopment)?\s+)?(?:server|preview))(?:\s+\([^)]+\))?$/i,gj=/^(?:cd\s+(?:"[^"]+"|'[^']+'|[^\s;&|]+)\s*&&\s*)?(?:npm|yarn|pnpm|bun)\s+(?:run\s+)?(?:--shell=bun\s+)?([^\s;&|]+)(?:\s|$)/i,xj=t=>Qu.some(({pattern:e})=>e.test(t));async function bj(t,e,s){if(!t)return null;const r=vj(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(s){const o=Sj(s);if(o){const a=await kj(t);return{command:`${a==="npm"?"npm run":a==="yarn"?"yarn":a==="pnpm"?"pnpm":a==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await wj(t)){const o=await yj(),a=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${a}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${a}/`}}return null}async function wj(t){const e=`${t}/index.html`,s=await fo(e,t);return typeof s=="string"&&s.trim().length>0}async function yj(){try{const t=await Ms("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),s=typeof e?.port=="number"?e.port:null;return s&&Number.isFinite(s)?s:null}catch{return null}}function vj(t){for(const e of t){const s=gj.exec(e.command.trim())?.[1];if(s&&xj(s)||e.source!=="shared"&&hj.test(e.name.trim()))return e}return null}function Sj(t){for(const{pattern:e}of Qu)for(const s of Object.keys(t))if(e.test(s))return s;return null}async function kj(t){const e=await fo(`${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 s=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of s){const a=await fo(`${t}/${r}`,t);if(typeof a=="string"&&a.trim().length>0)return o}return"npm"}async function fo(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await Ms(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const s=Nc()?.files;if(s?.readFile)try{const r=await s.readFile(t,{optional:true});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await Ms(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function jj(t){try{const e=await fo(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const Tj=/\{(worktree|branch)\}/g,la=63,Cj=new Set(["main","master"]),ef=t=>/\{(worktree|branch)\}/.test(t??""),Ej=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const s=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(s).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},tf=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=la)return e;const s=await Ej(e);return s?`${e.slice(0,la-7).replace(/-+$/,"")}-${s}`:e.slice(0,la).replace(/-+$/,"")},Ij=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},Nj=async(t,e,s)=>{const r=s.includes("{branch}"),o=s.includes("{worktree}")?await t.isLinkedWorktree(e):false;if(!r&&!o)return{branch:null,linkedWorktree:o};const a=await t.getGitStatus(e,{mode:"light"});return{branch:Ij(a.current),linkedWorktree:o}},Pj=async t=>!t.linkedWorktree||!t.branch||Cj.has(t.branch)?"":tf(t.branch.split("/").pop()??""),Rj=t=>{const e=t.lastIndexOf("@"),s=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const o=r.lastIndexOf(":"),a=o>=0?r.slice(0,o):r,i=o>=0?r.slice(o):"",u=a.split(".").map(d=>d.replace(/^-+|-+$/g,"")).filter(Boolean);return`${s}${u.join(".")}${i}`},Dj=async(t,e)=>{const s={worktree:await Pj(e),branch:e.branch?await tf(e.branch):""},r=t.replace(Tj,(d,l)=>s[l]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,a="",i="",u=""]=o;return`${a}${Rj(i)}${u}`},_j=async(t,e,s)=>ef(e)?Dj(e,await Nj(t,s,e)):e,sf="oc.projectActions.selectedAction.v1",Aj=wr(It(),wr(It(),It())),nf=()=>{const t=Cr().getItem(sf);if(t===null)return{};try{const e=Aj.safeParse(JSON.parse(t));return e.success?e.data:{}}catch{return{}}},rc=(t,e=Xt())=>nf()[e]?.[t]??null,Oj=(t,e,s=Xt())=>{const r=nf();r[s]?.[t]!==e&&Cr().setItem(sf,JSON.stringify({...r,[s]:{...r[s],[t]:e}}))},Mj=15e3,Fj=3e3,Lj=t=>{const e=(t||"").trim();if(!e)return null;const s=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(s);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},$j=({projectRef:t,directory:e,allowMobile:s=false})=>{const{t:r}=gt(),{currentTheme:o}=bo(),{terminal:a,runtime:i,git:u}=Is(),d=Zs(),{isMobile:l}=Tn(),f=c.useMemo(()=>As(),[]),m=Li(z=>z.instances),p=Li(z=>z.load),h=K(z=>z.terminalShell),x=K(z=>z.terminalLoginShells.includes(z.terminalShell)),g=K(z=>z.setSettingsPage),v=K(z=>z.setSettingsDialogOpen),y=K(z=>z.setSettingsProjectsSelectedId),C=K(z=>z.openContextPreview),S=Ct(z=>z.ensureDirectory),N=Ct(z=>z.reconcileServerSessions),F=Ct(z=>z.setTabLabel),_=Ct(z=>z.setTabIconKey),M=Ct(z=>z.setActiveTab),B=Ct(z=>z.setConnecting),T=Ct(z=>z.setTabSessionId),I=Ct(z=>z.setTabPurpose),b=Ct(z=>z.allocateActionExecution),w=Ct(z=>z.setTabLifecycle),j=Ct(z=>z.setTabPreviewUrl),R=Ct(z=>z.matchesActionExecution),L=Ct(z=>z.captureStartedActionMutationRevisions),[E,D]=c.useState([]),U=c.useRef(null),[V,J]=c.useState(()=>t?.id?rc(t.id):null),[W,G]=c.useState(false),le=c.useRef({}),$=c.useRef({}),re=c.useRef({}),H=c.useRef(new Set),P=c.useRef(0),[ee,oe]=c.useState({}),de=t?.id??null,he=t?.path??"";c.useEffect(()=>{J(de?rc(de):null)},[de]);const Z=c.useMemo(()=>de?{id:de,path:he}:null,[de,he]);c.useEffect(()=>{f&&p().catch(()=>{})},[f,p]);const ce=c.useCallback(async z=>{await Wn(z)},[]),ae=c.useCallback(async()=>{if(!Z)return;const z=P.current+1;P.current=z,G(true);try{const fe=await Ko(Z);if(P.current!==z)return;U.current=fe;const ke=fe.projectActions;D(ke)}catch{if(P.current!==z)return}finally{P.current===z&&G(false)}},[Z]),te=c.useMemo(()=>qo(e||Z?.path||""),[e,Z?.path]),pe=c.useMemo(()=>qo(Z?.path||""),[Z?.path]),Te=c.useMemo(()=>qo(d||"")||te,[d,te]),Ae=c.useRef(Te);c.useEffect(()=>{Ae.current=Te},[Te]);const Pe=Ct(z=>te?z.getDirectoryState(te):void 0),ze=Ct(z=>pe&&pe!==te?z.getDirectoryState(pe):void 0),Oe=c.useMemo(()=>{const z=te?[{directory:te,state:Pe}]:[];return pe&&pe!==te&&z.push({directory:pe,state:ze}),z},[Pe,te,pe,ze]),me=c.useMemo(()=>{const z=te?[te]:[];return pe&&pe!==te&&z.push(pe),z},[te,pe]),be=c.useCallback(z=>z.id!==pn&&z.runIn==="parent"&&pe||te,[te,pe]),Ce=c.useCallback((z,fe,ke)=>`${z}::${fe}::${ke}`,[]),$e=c.useCallback((z,fe,ke=Ct.getState())=>z?ke.getDirectoryState(z)?.tabs.find(ie=>ie.purpose.type==="project-action"&&ie.purpose.actionId===fe)??null:null,[]),We=c.useMemo(()=>{const z={};for(const{directory:fe,state:ke}of Oe)for(const ie of ke?.tabs??[]){if(ie.purpose.type!=="project-action"||!ie.purpose.executionId||!ie.terminalSessionId||ie.lifecycle==="idle"||ie.lifecycle==="exited")continue;const xe=Nn(fe,ie.purpose.actionId),Le=Ce(fe,ie.purpose.actionId,ie.purpose.executionId);z[xe]={directory:fe,actionId:ie.purpose.actionId,tabId:ie.id,sessionId:ie.terminalSessionId,executionId:ie.purpose.executionId,status:ie.lifecycle==="stopping"?"stopping":ee[Le]?"waiting-for-preview":"running"}}return z},[Ce,ee,Oe]),_e=c.useCallback((z,fe,ke)=>{const ie=Nn(z,fe),xe=Ce(z,fe,ke),Ke=le.current[ie]?.executionId===ke,ve=globalThis.window,je=vt=>{ve?.clearTimeout(re.current[vt]),delete re.current[vt]};Ke&&(delete le.current[ie],je(ie)),$.current[xe]?.(),delete $.current[xe],je(xe),oe(vt=>{if(!vt[xe])return vt;const ne={...vt};return delete ne[xe],ne})},[Ce]),Ue=c.useCallback(z=>{$.current[z]?.(),delete $.current[z]},[]),Xe=c.useCallback(z=>{window.clearTimeout(re.current[z]),delete re.current[z]},[]);c.useEffect(()=>{const z=$.current,fe=re.current;return()=>{for(const ke of Object.keys(z))Ue(ke);for(const ke of Object.keys(fe))Xe(ke)}},[Xe,Ue]),c.useEffect(()=>{const z=new Set(me);for(const fe of Object.values(le.current))z.has(fe.directory)||_e(fe.directory,fe.actionId,fe.executionId);for(const fe of Object.keys($.current)){const ke=fe.split("::",1)[0]??"";z.has(ke)||Ue(fe)}},[_e,Ue,me]);const Me=c.useCallback((z,fe)=>{K.getState().openContextPanelTab(z,{mode:"terminal",targetDirectory:fe===z?null:fe})},[]),ot=c.useMemo(()=>({id:pn,name:r("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:true}),[r]),ye=!l,Ve=c.useMemo(()=>ye?[...E,ot]:E,[E,ot,ye]),lt=c.useMemo(()=>V?Ve.find(z=>z.id===V)??null:null,[Ve,V]);c.useEffect(()=>{ae()},[ae]);const[ct,st]=c.useState(0),k=c.useCallback(()=>(st(z=>z+1),()=>st(z=>z-1)),[]),Y=ct>0;c.useEffect(()=>{if(!Y)return;const z=me.map(fe=>em(a,fe,L,ke=>N(fe,ke.sessions,{startedActionMutationRevisions:ke.startedActionMutationRevisions})));return()=>{for(const fe of z)fe()}},[L,Y,N,a,me]),c.useEffect(()=>{for(const{directory:z,state:fe}of Oe)if(z)for(const ke of fe?.tabs??[]){if(ke.purpose.type!=="project-action")continue;const ie=ke.purpose.actionId,xe=Ve.find(ve=>ve.id===ie),Le=xe?.name??ie,Ke=xe?.icon||"play";ke.label!==Le&&F(z,ke.id,Le),ke.iconKey!==Ke&&_(z,ke.id,Ke)}},[Ve,_,F,Oe]),c.useEffect(()=>{const z=globalThis.window;if(!z)return;const fe=ke=>{const ie=ke.detail;de&&(ie?.projectId&&ie.projectId!==de||ae())};return z.addEventListener(Ji,fe),()=>{z.removeEventListener(Ji,fe)}},[ae,de]),c.useEffect(()=>{const z=ke=>{delete re.current[ke];const ie=le.current[ke];if(!ie||ie.openedUrl)return;const xe=Ce(ie.directory,ie.actionId,ie.executionId),Le=ie.announced;if(Le.length!==0){if(window.clearTimeout(re.current[xe]),delete re.current[xe],ie.openedUrl=true,oe(Ke=>{if(!Ke[xe])return Ke;const ve={...Ke};return delete ve[xe],ve}),Le.length===1){oa(ie.directory,[]),j(ie.directory,ie.tabId,Le[0],{locked:false,autoOpened:true}),C(ie.directory,Le[0]);return}ie.offering=true,oa(ie.directory,Le),K.getState().openContextSurface(ie.directory,"browser"),Fe.info(r("projectActions.toast.multipleServers"))}},fe=()=>{const ke=Ct.getState(),ie=ke.sessions,xe=We;for(const[Le,Ke]of Object.entries(xe)){const je=ie.get(Ke.directory)?.tabs.find(se=>se.id===Ke.tabId);if(!je||je.terminalSessionId!==Ke.sessionId){_e(Ke.directory,Ke.actionId,Ke.executionId);continue}const vt=le.current[Le],ne=vt?.executionId===Ke.executionId?vt:{hostDirectory:Ae.current||Ke.directory,directory:Ke.directory,tabId:Ke.tabId,actionId:Ke.actionId,executionId:Ke.executionId,lastSeenChunkId:null,openedUrl:true,tail:"",openInPreview:false,announced:[],offering:false,proxiedPorts:[]};le.current[Le]=ne;const Je=Ve.find(se=>se.id===Ke.actionId),kt=ke.getBuffer(Ke.directory,Ke.tabId).chunks;if(!Je||kt.length===0)continue;const bt=kt.filter(se=>ne.lastSeenChunkId===null||se.id>ne.lastSeenChunkId);if(bt.length===0)continue;const _t=bt.map(se=>se.data).join(""),He=`${ne.tail}${_t}`;for(const se of om(He))ne.proxiedPorts.includes(se)||ne.proxiedPorts.push(se);if(ne.openInPreview&&(!ne.openedUrl||ne.offering)){const se=am(He,{proxiedPorts:ne.proxiedPorts,namedAddressesReachable:!$i()}),De=ne.announced.length;for(const rt of se)ne.announced.includes(rt)||ne.announced.push(rt);const we=ne.announced.length-De;ne.offering&&we>0?oa(Ke.directory,ne.announced):!ne.openedUrl&&De===0&&ne.announced.length>0&&(window.clearTimeout(re.current[Le]),re.current[Le]=window.setTimeout(()=>z(Le),Fj))}const pt=!ne.openedUrl&&Je.autoOpenUrl===true&&!ne.openInPreview?im(He,{proxiedPorts:ne.proxiedPorts,namedAddressesReachable:!$i()}):null,q=bt[bt.length-1]?.id??ne.lastSeenChunkId;if(ne.lastSeenChunkId=q,ne.tail=He.slice(-512),pt)if(ne.openedUrl=true,ne.openInPreview){const se=xe[Le];se&&(j(se.directory,se.tabId,pt,{locked:false,autoOpened:false,expectedExecutionId:se.executionId}),se.status==="waiting-for-preview"&&oe(De=>{const we=Ce(se.directory,se.actionId,se.executionId);if(!De[we])return De;const rt={...De};return delete rt[we],rt}),window.clearTimeout(re.current[Le]),delete re.current[Le],C(se.directory,pt))}else ce(pt),Fe.success(r("projectActions.toast.openedUrlFromOutput"));le.current[Le]=ne}for(const Le of Object.keys(le.current))if(!xe[Le]){const Ke=le.current[Le],ve=Ke?ie.get(Ke.directory)?.tabs.find(vt=>vt.id===Ke.tabId):void 0;if(ve?.purpose.type==="project-action"&&ve.purpose.executionId===Ke?.executionId&&!!ve.terminalSessionId&&ve.lifecycle!=="idle"&&ve.lifecycle!=="exited")continue;delete le.current[Le],window.clearTimeout(re.current[Le]),delete re.current[Le]}};return fe(),Ct.subscribe((ke,ie)=>{(ke.sessions!==ie.sessions||ke.buffers!==ie.buffers)&&fe()})},[_e,Ae,Ve,Ce,C,ce,We,j,r]),c.useEffect(()=>{for(const{directory:z,state:fe}of Oe)for(const ke of fe?.tabs??[]){if(ke.purpose.type!=="project-action"||!ke.purpose.executionId||!ke.terminalSessionId||ke.lifecycle!=="running")continue;const ie=ke.purpose.actionId,xe=ke.purpose.executionId,Le=Ce(z,ie,xe);if($.current[Le])continue;const Ke=a.connect(ke.terminalSessionId,{onEvent:ve=>{if(!R(z,ke.id,xe))return;ve.type==="snapshot"&&(Ct.getState().replaceBuffer(z,ke.id,ve.data??"",ve.sequence??0,Ti(ve)),ve.status==="running"&&Ct.getState().setTabLifecycle(z,ke.id,"running",{expectedExecutionId:xe}),ve.status==="exited"&&(Ct.getState().setTabLifecycle(z,ke.id,"exited",{expectedExecutionId:xe}),Ct.getState().setTabPurpose(z,ke.id,{type:"project-action",actionId:ie,executionId:null}),_e(z,ie,xe)));const je=ve.type==="data"?ve.data??"":"";je&&Ct.getState().appendToBuffer(z,ke.id,je,ve.sequence,ve.replayData),ve.type==="exit"&&(Ct.getState().setTabLifecycle(z,ke.id,"exited",{expectedExecutionId:xe}),Ct.getState().setTabPurpose(z,ke.id,{type:"project-action",actionId:ie,executionId:null}),_e(z,ie,xe))},onError:(ve,je)=>{!je||!R(z,ke.id,xe)||(Ct.getState().setTabLifecycle(z,ke.id,"exited",{expectedExecutionId:xe}),Ct.getState().setTabSessionId(z,ke.id,null,{expectedExecutionId:xe}),Ct.getState().setTabPurpose(z,ke.id,{type:"project-action",actionId:ie,executionId:null}),_e(z,ie,xe))}},z);$.current[Le]=Ke.close}},[_e,Ce,R,a,Oe]);const Ne=c.useCallback(async z=>{const fe=be(z);if(!fe)throw new Error(r("projectActions.error.noActiveDirectory"));const ke=Nn(fe,z.id);S(fe);const ie=Ct.getState(),xe=$e(fe,z.id,ie),Le=xe?.id??ie.createTab(fe);F(fe,Le,z.name),_(fe,Le,z.icon||"play"),xe||I(fe,Le,{type:"project-action",actionId:z.id,executionId:null}),M(fe,Le);const ve=Ct.getState().getDirectoryState(fe)?.tabs.find(je=>je.id===Le);return{executionDirectory:fe,key:ke,tabId:Le,sessionId:ve?.terminalSessionId??null,executionId:ve?.purpose.type==="project-action"?ve.purpose.executionId:null}},[S,be,$e,M,_,F,I,r]),Re=c.useCallback(async z=>{if(i.isVSCode||!s&&l)return;if(!te){Fe.error(r("projectActions.error.noActiveDirectoryForAction"));return}const fe=Nn(be(z),z.id),ke=We[fe];if(ke&&ke.status==="running"||H.current.has(fe))return;H.current.add(fe);let ie=null;try{const xe=z.id===pn?await(async()=>{const nt=Z??{id:"",path:te},[ut,Nt]=await Promise.all([Ko(nt),jj(te)]),Et=await bj(te,ut.projectActions,Nt);if(!Et)throw new Error(r("contextPanel.preview.noDevServer"));return ut.projectActions.find(Wt=>Wt.id===Et.actionId)?.source==="shared"&&!await Qi(nt,ut)?null:{id:pn,name:r("projectActions.actions.autoDiscover"),command:Et.command,icon:"scan-2",autoOpenUrl:true,openUrl:Et.previewUrlHint||""}})():z;if(!xe)return;const Le=xe.autoOpenUrl===true&&(xe.openUrl||"").trim().length>0,Ke=!Le&&z.id!==pn&&K.getState().terminalOpenOnProjectAction,ve=Ae.current||te,{executionDirectory:je,key:vt,tabId:ne}=await Ne(xe),Je=tm(xe.command);if(!Je)throw new Error(r("projectActions.error.failedToRunAction"));const kt=xe.autoOpenUrl===true&&f&&(xe.desktopOpenSshForward||"").trim().length>0,bt=xe.autoOpenUrl&&xe.openUrl||"";let _t=false;const He=ef(bt)?await _j(u,bt,je).catch(()=>(_t=true,"")):bt,pt=xe.autoOpenUrl?Lj(He):null,q=xe.autoOpenUrl&&f?J1(xe.desktopOpenSshForward,m):null;if(a.listSessions){const nt=$e(je,xe.id);if(nt?.purpose.type==="project-action"&&nt.purpose.executionId===null){const ut=await sm(a,je,{captureStartedActionMutationRevisions:L});ut&&N(je,ut.sessions,{startedActionMutationRevisions:ut.startedActionMutationRevisions})}}const se=$e(je,xe.id);let De,we;if(se?.lifecycle==="running"&&se.terminalSessionId&&se.purpose.type==="project-action"&&se.purpose.executionId)De=se.terminalSessionId,we=se.purpose.executionId;else{const nt=se?.purpose.type==="project-action"?se.purpose.executionId:null;nt&&_e(je,xe.id,nt);const ut=b(je,ne,xe.id);if(!ut)throw new Error(r("projectActions.error.failedToCreateTerminalSession"));ie={directory:je,tabId:ne,id:ut},B(je,ne,true,{expectedExecutionId:ut});const Nt=await nm({terminal:a,createOptions:{cwd:je,shell:h,loginShell:x,themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground},command:Je,isRunStillExpected:()=>R(je,ne,ut),purpose:{type:"project-action",actionId:xe.id,executionId:ut}});if(!R(je,ne,ut)){Nt.sessionId===ut&&await a.close(Nt.sessionId).catch(()=>{});return}we=Nt.purpose?.type==="project-action"?Nt.purpose.executionId:ut,De=Nt.sessionId,I(je,ne,{type:"project-action",actionId:xe.id,executionId:we}),T(je,ne,De,{expectedExecutionId:we}),B(je,ne,false,{expectedExecutionId:we})}Ke&&ve&&Me(ve,je),le.current[vt]={hostDirectory:ve,directory:je,tabId:ne,actionId:xe.id,executionId:we,lastSeenChunkId:null,openedUrl:!!q||!!pt||Le,tail:"",openInPreview:xe.id===pn,announced:[],offering:false,proxiedPorts:[]};const rt=Ce(je,xe.id,we);B(je,ne,true,{expectedExecutionId:we});const ft=a.connect(De,{onEvent:nt=>{if(!R(je,ne,we)||nt.purpose?.type==="project-action"&&nt.purpose.executionId!==we)return;nt.type==="snapshot"&&(Ct.getState().replaceBuffer(je,ne,nt.data??"",nt.sequence??0,Ti(nt)),Ct.getState().setConnecting(je,ne,false,{expectedExecutionId:we}),nt.purpose?.type==="project-action"&&Ct.getState().setTabPurpose(je,ne,{type:"project-action",actionId:nt.purpose.actionId,executionId:nt.purpose.executionId}),nt.status==="running"&&Ct.getState().setTabLifecycle(je,ne,"running",{expectedExecutionId:we}),nt.status==="exited"&&(Ct.getState().setTabLifecycle(je,ne,"exited",{expectedExecutionId:we}),Ct.getState().setTabPurpose(je,ne,{type:"project-action",actionId:xe.id,executionId:null}),_e(je,xe.id,we)));const ut=nt.type==="data"?nt.data??"":"";ut&&Ct.getState().appendToBuffer(je,ne,ut,nt.sequence,nt.replayData),nt.type==="exit"&&(Ct.getState().setTabLifecycle(je,ne,"exited",{expectedExecutionId:we}),Ct.getState().setConnecting(je,ne,false,{expectedExecutionId:we}),Ct.getState().setTabPurpose(je,ne,{type:"project-action",actionId:xe.id,executionId:null}),_e(je,xe.id,we))},onError:(nt,ut)=>{R(je,ne,we)&&(Ct.getState().setConnecting(je,ne,false,{expectedExecutionId:we}),ut&&(Ct.getState().setTabLifecycle(je,ne,"exited",{expectedExecutionId:we}),Ct.getState().setTabSessionId(je,ne,null,{expectedExecutionId:we}),Ct.getState().setTabPurpose(je,ne,{type:"project-action",actionId:xe.id,executionId:null}),_e(je,xe.id,we)))}},je);if(!R(je,ne,we)){ft.close();return}$.current[rt]?.(),$.current[rt]=ft.close,window.clearTimeout(re.current[rt]),delete re.current[rt],xe.id===pn&&!pt&&(oe(nt=>({...nt,[rt]:true})),re.current[rt]=window.setTimeout(()=>{delete re.current[rt];const nt=le.current[vt];!nt||nt.executionId!==we||nt.openedUrl||nt.offering||R(je,ne,we)&&(oe(ut=>{if(!ut[rt])return ut;const Nt={...ut};return delete Nt[rt],Nt}),Ct.getState().setActiveTab(je,ne),Me(nt.hostDirectory,je))},Mj)),q?(j(je,ne,null,{locked:true,expectedExecutionId:we}),ce(q),Fe.success(r("projectActions.toast.openedForwardedUrl"))):pt?(j(je,ne,pt,{locked:true,autoOpened:true,expectedExecutionId:we}),C(ve,pt),Fe.success(r("projectActions.toast.openedActionUrl"))):_t?(j(je,ne,null,{locked:true,expectedExecutionId:we}),Fe.error(r("projectActions.error.openUrlTemplateUnresolved"))):Le?(j(je,ne,null,{locked:true,expectedExecutionId:we}),Fe.error(r("projectActions.error.invalidCustomUrlFormat"))):kt?(j(je,ne,null,{locked:true,expectedExecutionId:we}),Fe.error(r("projectActions.error.selectedDesktopSshForwardUnavailable"))):j(je,ne,null,{locked:false,autoOpened:false,expectedExecutionId:we})}catch(xe){if(ie&&R(ie.directory,ie.tabId,ie.id)){const{directory:Le,tabId:Ke,id:ve}=ie;_e(Le,z.id,ve),w(Le,Ke,"exited",{expectedExecutionId:ve}),I(Le,Ke,{type:"project-action",actionId:z.id,executionId:null})}if(xe instanceof Error&&xe.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(xe instanceof Error&&(xe.message==="COMMAND_MODE_UNSUPPORTED"||xe.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Fe.error(r("projectActions.error.failedToCreateTerminalSession"));return}Fe.error(xe instanceof Error?xe.message:r("projectActions.error.failedToRunAction"))}finally{H.current.delete(fe)}},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,Ae,m,Ne,u,s,l,f,te,x,h,ce,C,We,Me,i.isVSCode,be,R,_e,Ce,$e,N,b,L,B,w,I,j,T,Z,r,a]),Ie=c.useCallback(async z=>{const fe=Nn(be(z),z.id),ke=We[fe];ke&&await rm({terminal:a,sessionId:ke.sessionId,isExecutionStillCurrent:()=>R(ke.directory,ke.tabId,ke.executionId),markStopping:()=>{w(ke.directory,ke.tabId,"stopping",{expectedExecutionId:ke.executionId})},restoreRunning:()=>{w(ke.directory,ke.tabId,"running",{expectedExecutionId:ke.executionId})},clearSession:()=>{T(ke.directory,ke.tabId,null,{expectedExecutionId:ke.executionId})},finalizeExit:()=>{w(ke.directory,ke.tabId,"exited",{expectedExecutionId:ke.executionId}),I(ke.directory,ke.tabId,{type:"project-action",actionId:ke.actionId,executionId:null}),_e(ke.directory,ke.actionId,ke.executionId)}})},[_e,be,R,We,w,I,T,a]),Ee=c.useCallback(async z=>{if(z.source==="shared"&&Z){const fe=U.current?.trust.trusted?U.current:await Ko(Z);if(U.current=fe,!await Qi(Z,fe))return;U.current={...fe,trust:{...fe.trust,trusted:true}}}await Re(z)},[Re,Z]),Ge=c.useCallback(z=>We[Nn(be(z),z.id)]??null,[be,We]),Be=(lt&&Ge(lt)?lt:null)??Ve.find(z=>Ge(z)!==null)??lt??Ve[0]??null,Ze=c.useCallback(z=>{const fe=Ge(z);if(fe?.status!=="stopping"){if(fe){Ie(z);return}Ee(z)}},[Ee,Ge,Ie]),et=c.useCallback(z=>{Ee(z)},[Ee]),wt=c.useCallback(z=>{Ie(z)},[Ie]),Qe=c.useCallback(z=>{J(z.id),de&&Oj(de,z.id)},[de]),dt=c.useCallback(()=>{Z?.id&&(y(Z.id),g("projects"),v(true))},[v,g,y,Z?.id]),at=!i.isVSCode&&(s||!l)&&!!Z&&!!te;return c.useMemo(()=>({available:at,actions:at?Ve:[],shown:at?Be:null,isLoading:W,observe:k,runOf:Ge,select:Qe,run:et,stop:wt,toggle:Ze,openSettings:dt}),[at,Ve,W,k,dt,et,Ge,Qe,Be,wt,Ze])},Bj=t=>{const e=qe.c(6);let s,r;e[0]!==t?({children:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=$j(r);let a;return e[3]!==s||e[4]!==o?(a=n.jsx(Q1.Provider,{value:o,children:s}),e[3]=s,e[4]=o,e[5]=a):a=e[5],a},zj=t=>{const e=qe.c(4),{children:s}=t,r=su(),o=Pr(),a=o?.kind==="preparing"?null:r?.projectRef??null,i=o?.kind==="ready"?o.directory:r?.directory??"";let u;return e[0]!==s||e[1]!==i||e[2]!==a?(u=n.jsx(Bj,{projectRef:a,directory:i,children:s}),e[0]=s,e[1]=i,e[2]=a,e[3]=u):u=e[3],u},Wj=2e4,Vj=14400*1e3,Uj=t=>Object.entries(t).map(([e,s])=>`${e}@${s.version}`).sort().join(","),Hj="openchamber.guests.announcedUpdates",Kj=()=>{const{t}=gt(),e=c.useRef(t);e.current=t,c.useEffect(()=>{let s=false;const r=async()=>{const i=Xt();await ex();const u=await lm(false);if(s||!u.ok||Xt()!==i)return;const d=cr.getState();d.applyUpdates(u.updates,d.runtimeKey);const l=cr.getState().guests.filter(g=>u.updates[g.id]),f=Uj(u.updates),m=Cr(),p=`${Hj}:${i}`;if(l.length===0||m.getItem(p)===f)return;m.setItem(p,f);const h=e.current,[x]=l;Fe.info(l.length===1&&x?h("settings.extensions.updates.notice.one",{name:x.name}):h("settings.extensions.updates.notice.many",{count:l.length}),{action:{label:h("settings.extensions.updates.notice.open"),onClick:()=>{const g=K.getState();g.setSettingsPage("extensions"),g.setSettingsDialogOpen(true)}}})};let o;const a=window.setTimeout(()=>{r(),o=window.setInterval(()=>{r()},Vj)},Wj);return()=>{s=true,window.clearTimeout(a),window.clearInterval(o)}},[])},qj=()=>{xr.requestDirectoryDialog()},Gj=()=>{K.getState().setNewWorktreeDialogOpen(true)},Zj=()=>{const t=qt.getState().currentDirectory;if(!t)return false;K.getState().openContextOverview(t)},Xj=()=>{Pd()},Yj=()=>{if(!K.getState().overviewFeatureAvailable)return false;K.getState().setOverviewOpen(true)},Jj=()=>{window.location.reload()},Qj=()=>{const t=K.getState();t.setSessionSwitcherOpen(false),t.setArchivePageOpen(true)},rf=t=>{const e=qt.getState().currentDirectory;if(!e)return false;const s=K.getState();return s.setProjectContextTab(t),s.openContextSurface(e,"notes"),true},e4=()=>rf("notes"),t4=()=>rf("todos"),s4=t=>()=>{cm(t)},n4=t=>()=>{const e=it.getState().currentSessionId,s=qt.getState().currentDirectory;if(!e||!s)return false;const r=di(Rr.getState().ids,s,e)?"sessions.sidebar.session.pin.unpinFailed":"sessions.sidebar.session.pin.pinFailed";dm({directory:s,sessionId:e}).catch(()=>Fe.error(t(r)))},r4=t=>()=>{const e=it.getState().currentSessionId;if(!e)return false;wo(e).then(s=>{if(s.ok){Fe.success(t("sessions.sidebar.session.copyId.success"));return}Fe.error(t("sessions.sidebar.session.copyId.error"))}).catch(()=>Fe.error(t("sessions.sidebar.session.copyId.error")))},o4=t=>()=>{if(!K.getState().sessionWorkEnabled)return false;const e=it.getState().currentSessionId;if(!e)return false;const s=os.getState().activeSessions.find(a=>a.id===e);if(!s||s.parentID)return false;const r=Hs(s)??qt.getState().currentDirectory;if(!r||ho(r)||di(Rr.getState().ids,r,e)||it.getState().worktreeMetadata.get(e)?.pinnedAt!==void 0)return false;const o=Za(s)?"done":"open";tx(e,r,o).catch(()=>Fe.error(t("sessions.sidebar.session.work.updateFailed")))},a4=()=>{K.getState().setSessionSwitcherOpen(false),sx()};function i4(){const t=qe.c(13),{t:e}=gt();let s;t[0]!==e?(s=s4(e),t[0]=e,t[1]=s):s=t[1];let r;t[2]!==e?(r=n4(e),t[2]=e,t[3]=r):r=t[3];let o;t[4]!==e?(o=r4(e),t[4]=e,t[5]=o):o=t[5];let a;t[6]!==e?(a=o4(e),t[6]=e,t[7]=a):a=t[7];let i;t[8]!==s||t[9]!==r||t[10]!==o||t[11]!==a?(i={open_new_worktree_dialog:Gj,add_project:qj,show_context_usage:Zj,show_opencode_status:Xj,open_overview:Yj,reload_ui:Jj,open_archive:Qj,open_notes:e4,open_todos:t4,restart_opencode:s,pin_current_session:r,copy_current_session_id:o,toggle_work_current_session:a,open_multi_run:a4},t[8]=s,t[9]=r,t[10]=o,t[11]=a,t[12]=i):i=t[12],td(i)}function l4(t){const e=[],s=(r,o)=>{const a=ts(r);!a||e.some(i=>i.directory===a)||e.push({directory:a,priority:"selected",reason:o})};return s(t.currentDirectory,"current-directory"),s(t.currentSessionDirectory,"selected-session"),e}const c4=new Map,d4=[],u4=t=>{const e=qe.c(20),{isVSCode:s}=t,r=Sd(),o=Yt(f4),a=qt(p4),i=it(m4);let u;e[0]!==s?(u=M=>s?c4:M.availableWorktreesByProject,e[0]=s,e[1]=u):u=e[1];const d=it(u),l=!s;let f;e[2]!==d||e[3]!==o||e[4]!==l?(f=um(o,d,{includeWorktrees:l}),e[2]=d,e[3]=o,e[4]=l,e[5]=f):f=e[5];const m=f,p=os(h4),h=`session-list-sync:${c.useId()}`;let x,g;e[6]!==h||e[7]!==r||e[8]!==a||e[9]!==i?(x=()=>(r.setBootstrapDemand(h,l4({currentDirectory:a,currentSessionDirectory:i})),()=>r.clearBootstrapDemand(h)),g=[h,r,a,i],e[6]=h,e[7]=r,e[8]=a,e[9]=i,e[10]=x,e[11]=g):(x=e[10],g=e[11]),c.useEffect(x,g);const v=c.useRef(null);let y,C;e[12]!==s||e[13]!==m?(y=()=>{const M=new Set(m),B=v.current;v.current=M;const T=B?[...M].filter(I=>!B.has(I)):s?[...M]:[];T.length&&Rd(T,ha())},C=[s,m],e[12]=s,e[13]=m,e[14]=y,e[15]=C):(y=e[14],C=e[15]),c.useEffect(y,C);let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=[],e[16]=S):S=e[16],c.useEffect(g4,S);const N=p!=null,F=p??d4;let _;e[17]!==F||e[18]!==N?(_={enabled:true,hasAuthoritativeGlobalSessions:N,sessions:F},e[17]=F,e[18]=N,e[19]=_):_=e[19],fm(_)};function f4(t){return t.projects}function p4(t){return t.currentDirectory}function m4(t){return t.currentSessionDirectory}function h4(t){return t.authoritativeSessions}function g4(){let t=null,e=false;const s=new Set,r=$n(o=>{if(o.type==="scheduled-task-ran")e=true;else if(o.type==="session-created")s.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=false,s.clear(),nx(ha());return}const a=[...s];s.clear(),a.length&&Rd(a,ha())},500)});return()=>{t&&clearTimeout(t),r()}}const x4=()=>Vt(()=>import("./SettingsWindow-CoijA05f.js"),__vite__mapDeps([236,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,237,238,239,221,222,223,224,203,231,201,188,189,240,241,211,230,216,242,243,244])).then(t=>t.SettingsWindow),b4=()=>Vt(()=>import("./CommandPalette-C7Uc4nDE.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,244,210,181,182,183,208,209,211])).then(t=>t.CommandPalette),w4=()=>Vt(()=>import("./HelpDialog-iH44R9qu.js"),__vite__mapDeps([246,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),y4=()=>Vt(()=>import("./ProjectActionsDialog-B_jMMuJ0.js"),__vite__mapDeps([247,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,208,209,210,211])).then(t=>t.ProjectActionsDialog),v4=()=>Vt(()=>import("./OpenCodeStatusDialog-CBiLhgh9.js"),__vite__mapDeps([248,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),S4=()=>Vt(()=>import("./RunOverview-C7FUT8DD.js"),__vite__mapDeps([249,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),k4=()=>Vt(()=>import("./ScheduledTasksDialog-DdXypryy.js"),__vite__mapDeps([250,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,234,251,252,253])).then(t=>t.ScheduledTasksDialog),j4=()=>Vt(()=>import("./ArchiveView-DjRZQdOo.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,255])).then(t=>t.ArchiveView),T4=()=>Vt(()=>import("./IntegrationsCatalogView-D9icTaJt.js"),__vite__mapDeps([256,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,238])).then(t=>t.IntegrationsCatalogView),C4=()=>Vt(()=>import("./UsageStatsView-Dbo3dCgC.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])).then(t=>t.UsageStatsView),E4=()=>Vt(()=>import("./SourceBoardView-BrQkCEgn.js"),__vite__mapDeps([258,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),I4=()=>Vt(()=>import("./OverviewView-DmNAg498.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,181,182,183])).then(t=>t.OverviewView),N4=()=>Vt(()=>import("./WorktreesView-DNa5Soxq.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,255])).then(t=>t.WorktreesView),P4=()=>Vt(()=>import("./SpacesView-GxzOEIeI.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,242,181,182,183])).then(t=>t.SpacesView),R4=()=>Vt(()=>import("./SpaceAccessDialog-CymnxxLO.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,263])).then(t=>t.SpaceAccessDialog),D4=()=>Vt(()=>import("./SpaceApplyDialog-DVJkF4lG.js"),__vite__mapDeps([264,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),_4=()=>Vt(()=>import("./SpaceSetupOutput-Btttdq6K.js"),__vite__mapDeps([265,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,263])).then(t=>t.SpaceSetupOutputDialog),Bs=()=>K.getState().closeMainSurfaces(),rs=t=>{const e=qe.c(2),{needed:s,load:r,onFailure:o}=t,a=Eo(s,r,o);let i;return e[0]!==a?(i=a?n.jsx(a,{}):null,e[0]=a,e[1]=i):i=e[1],i},of=c.memo(t=>{const e=qe.c(12),{isMobile:s}=t,r=K(O4),o=!r&&!s,a=vo();let i;e[0]!==o||e[1]!==a?(i={enabled:o,layoutAnimationMs:a},e[0]=o,e[1]=a,e[2]=i):i=e[2];const u=Ww(i),[d,l]=c.useState(null);let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Mw,{actionsSlotRef:l}),e[3]=f):f=e[3];const m=r||u.state!==false;let p;e[4]!==d||e[5]!==m?(p=n.jsx(pm,{isVisible:m,listControlsSlot:d}),e[4]=d,e[5]=m,e[6]=p):p=e[6];let h;return e[7]!==s||e[8]!==r||e[9]!==u||e[10]!==p?(h=n.jsx(Ow,{isOpen:r,isMobile:s,className:"border-border",topBar:f,peek:u,children:p}),e[7]=s,e[8]=r,e[9]=u,e[10]=p,e[11]=h):h=e[11],h});of.displayName="LeftSidebar";const A4=()=>{const t=qe.c(114);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:false},t[0]=e):e=t[0],u4(e),i4(),mm();const s=K(M4),r=K(F4),o=K(L4),a=K($4);let i;t[1]!==a?(i=()=>a(false),t[1]=a,t[2]=i):i=t[2];const u=Eo(o,x4,i),d=K(B4),l=K(z4),f=K(W4),m=K(V4),p=K(U4),h=K(H4),x=K(K4),g=K(q4),v=K(G4),y=K(Z4),C=K(X4),S=K(Y4),N=K(J4),F=yn(Q4),_=yn(e5),M=yn(t5),B=K(s5),T=rx();let I;if(t[3]!==T||t[4]!==B){let dt;t[6]!==B?(dt=at=>at.id===B,t[6]=B,t[7]=dt):dt=t[7],I=T.find(dt),t[3]=T,t[4]=B,t[5]=I}else I=t[5];const b=I;let w,j;t[8]!==b||t[9]!==B?(w=()=>{B&&!b&&K.getState().setOpenGuestPage(null)},j=[B,b],t[8]=b,t[9]=B,t[10]=w,t[11]=j):(w=t[10],j=t[11]),c.useEffect(w,j);let R;t[12]===Symbol.for("react.memo_cache_sentinel")?(R=[],t[12]=R):R=t[12],c.useEffect(r5,R);let L;t[13]===Symbol.for("react.memo_cache_sentinel")?(L=[],t[13]=L):L=t[13],c.useEffect(o5,L);const E=l||f||m||p||h||x||!!g||v||d||!!b,D=c.useRef(null);let U,V;t[14]!==E?(U=()=>{if(E)return Ka(a5,D,1)},V=[E],t[14]=E,t[15]=U,t[16]=V):(U=t[15],V=t[16]),c.useEffect(U,V);let J,W;t[17]!==E?(W=()=>{Dd(E)},J=[E],t[17]=E,t[18]=J,t[19]=W):(J=t[18],W=t[19]),c.useLayoutEffect(W,J);let G;t[20]===Symbol.for("react.memo_cache_sentinel")?(G=[],t[20]=G):G=t[20],c.useEffect(l5,G);let le;t[21]===Symbol.for("react.memo_cache_sentinel")?(le=[],t[21]=le):le=t[21],c.useEffect(d5,le);const{isMobile:$}=Tn();hm(),Kj();let re,H;t[22]!==$||t[23]!==r?(re=()=>{K.getState().isMobile!==$&&r($)},H=[$,r],t[22]=$,t[23]=r,t[24]=re,t[25]=H):(re=t[24],H=t[25]),c.useEffect(re,H);let P;t[26]!==y?(P=n.jsx(rs,{needed:y,load:b4,onFailure:u5}),t[26]=y,t[27]=P):P=t[27];let ee;t[28]!==C?(ee=n.jsx(rs,{needed:C,load:w4,onFailure:f5}),t[28]=C,t[29]=ee):ee=t[29];let oe;t[30]!==S?(oe=n.jsx(rs,{needed:S,load:y4,onFailure:p5}),t[30]=S,t[31]=oe):oe=t[31];let de;t[32]!==N?(de=n.jsx(rs,{needed:N,load:v4,onFailure:m5}),t[32]=N,t[33]=de):de=t[33];let he,Z;t[34]===Symbol.for("react.memo_cache_sentinel")?(he=n.jsx(xm,{}),Z=n.jsx(mj,{}),t[34]=he,t[35]=Z):(he=t[34],Z=t[35]);let ce;t[36]!==F||t[37]!==_||t[38]!==M||t[39]!==s?(ce=s?n.jsxs(n.Fragment,{children:[n.jsx(rs,{needed:F,load:R4,onFailure:h5}),n.jsx(bm,{}),n.jsx(rs,{needed:_,load:D4,onFailure:g5}),n.jsx(wm,{}),n.jsx(rs,{needed:M,load:_4,onFailure:x5})]}):null,t[36]=F,t[37]=_,t[38]=M,t[39]=s,t[40]=ce):ce=t[40];let ae;t[41]===Symbol.for("react.memo_cache_sentinel")?(ae=n.jsx(Vw,{}),t[41]=ae):ae=t[41];let te;t[42]!==$?(te=n.jsx(of,{isMobile:$}),t[42]=$,t[43]=te):te=t[43];let pe;t[44]===Symbol.for("react.memo_cache_sentinel")?(pe=n.jsx(Aw,{}),t[44]=pe):pe=t[44];let Te;t[45]===Symbol.for("react.memo_cache_sentinel")?(Te=n.jsx(ra,{zone:"left"}),t[45]=Te):Te=t[45];const Ae=E&&"invisible";let Pe;t[46]!==Ae?(Pe=Ye("absolute inset-0",Ae),t[46]=Ae,t[47]=Pe):Pe=t[47];const ze=!o&&!E;let Oe;t[48]!==ze?(Oe=n.jsx(Jt,{children:n.jsx(Kc,{active:ze})}),t[48]=ze,t[49]=Oe):Oe=t[49];let me;t[50]!==Pe||t[51]!==Oe?(me=n.jsx("div",{className:Pe,children:Oe}),t[50]=Pe,t[51]=Oe,t[52]=me):me=t[52];let be;t[53]!==d?(be=n.jsx(Jt,{children:n.jsx(rs,{needed:d,load:S4,onFailure:Bs})}),t[53]=d,t[54]=be):be=t[54];let Ce;t[55]!==l?(Ce=n.jsx(Jt,{children:n.jsx(rs,{needed:l,load:k4,onFailure:Bs})}),t[55]=l,t[56]=Ce):Ce=t[56];let $e;t[57]!==f?($e=n.jsx(Jt,{children:n.jsx(rs,{needed:f,load:j4,onFailure:Bs})}),t[57]=f,t[58]=$e):$e=t[58];let We;t[59]!==m?(We=n.jsx(Jt,{children:n.jsx(rs,{needed:m,load:T4,onFailure:Bs})}),t[59]=m,t[60]=We):We=t[60];let _e;t[61]!==p?(_e=p&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(Jt,{children:n.jsx(rs,{needed:true,load:C4,onFailure:Bs})})}),t[61]=p,t[62]=_e):_e=t[62];let Ue;t[63]!==h?(Ue=n.jsx(rs,{needed:h,load:E4,onFailure:Bs}),t[63]=h,t[64]=Ue):Ue=t[64];let Xe;t[65]!==x?(Xe=n.jsx(Jt,{children:n.jsx(rs,{needed:x,load:I4,onFailure:Bs})}),t[65]=x,t[66]=Xe):Xe=t[66];const Me=!!g;let ot;t[67]!==Me?(ot=n.jsx(Jt,{children:n.jsx(rs,{needed:Me,load:N4,onFailure:Bs})}),t[67]=Me,t[68]=ot):ot=t[68];let ye;t[69]!==v?(ye=v?n.jsx(Jt,{children:n.jsx(rs,{needed:true,load:P4,onFailure:Bs})}):null,t[69]=v,t[70]=ye):ye=t[70];let Ve;t[71]!==b?(Ve=b&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(Jt,{children:n.jsx(ox,{mode:`plugin:${b.id}`,surface:"page",item:null,onDismiss:b5})})}),t[71]=b,t[72]=Ve):Ve=t[72];let lt;t[73]!==me||t[74]!==be||t[75]!==Ce||t[76]!==$e||t[77]!==We||t[78]!==_e||t[79]!==Ue||t[80]!==Xe||t[81]!==ot||t[82]!==ye||t[83]!==Ve?(lt=n.jsxs("main",{ref:D,className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[me,be,Ce,$e,We,_e,Ue,Xe,ot,ye,Ve]}),t[73]=me,t[74]=be,t[75]=Ce,t[76]=$e,t[77]=We,t[78]=_e,t[79]=Ue,t[80]=Xe,t[81]=ot,t[82]=ye,t[83]=Ve,t[84]=lt):lt=t[84];let ct;t[85]===Symbol.for("react.memo_cache_sentinel")?(ct=n.jsx(ra,{zone:"bottom"}),t[85]=ct):ct=t[85];let st;t[86]!==lt?(st=n.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[lt,ct]}),t[86]=lt,t[87]=st):st=t[87];let k,Y,Ne,Re;t[88]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(ra,{zone:"right"}),Y=n.jsx(E3,{}),Ne=n.jsx(N3,{}),Re=n.jsx(A3,{}),t[88]=k,t[89]=Y,t[90]=Ne,t[91]=Re):(k=t[88],Y=t[89],Ne=t[90],Re=t[91]);let Ie;t[92]!==st?(Ie=n.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true","data-workspace-row":"true",children:[Te,n.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:[st,k,Y,Ne,Re]})]})}),t[92]=st,t[93]=Ie):Ie=t[93];let Ee;t[94]===Symbol.for("react.memo_cache_sentinel")?(Ee=n.jsx("div",{"data-page-scroll-lock":"true",children:n.jsx(Jt,{children:n.jsx(q3,{})})}),t[94]=Ee):Ee=t[94];let Ge;t[95]===Symbol.for("react.memo_cache_sentinel")?(Ge=n.jsx(Jt,{children:n.jsx(ix,{})}),t[95]=Ge):Ge=t[95];let Be;t[96]!==Ie?(Be=n.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[pe,n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Ie,Ee,Ge]})]}),t[96]=Ie,t[97]=Be):Be=t[97];let Ze;t[98]!==te||t[99]!==Be?(Ze=n.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[te,Be]}),t[98]=te,t[99]=Be,t[100]=Ze):Ze=t[100];let et;t[101]!==u||t[102]!==o||t[103]!==a?(et=u?n.jsx(u,{open:o,onOpenChange:a}):null,t[101]=u,t[102]=o,t[103]=a,t[104]=et):et=t[104];let wt;t[105]===Symbol.for("react.memo_cache_sentinel")?(wt=null,t[105]=wt):wt=t[105];let Qe;return t[106]!==P||t[107]!==ee||t[108]!==oe||t[109]!==de||t[110]!==ce||t[111]!==Ze||t[112]!==et?(Qe=n.jsx(ax.Provider,{value:true,children:n.jsx(gm,{children:n.jsx(zj,{children:n.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[P,ee,oe,de,he,Z,ce,ae,Ze,et,wt]})})})}),t[106]=P,t[107]=ee,t[108]=oe,t[109]=de,t[110]=ce,t[111]=Ze,t[112]=et,t[113]=Qe):Qe=t[113],Qe};function O4(t){return t.isSidebarOpen}function M4(t){return t.isolatedSpacesEnabled}function F4(t){return t.setIsMobile}function L4(t){return t.isSettingsDialogOpen}function $4(t){return t.setSettingsDialogOpen}function B4(t){return t.runOverviewKey!==null}function z4(t){return t.isScheduledTasksDialogOpen}function W4(t){return t.isArchivePageOpen}function V4(t){return t.isIntegrationsCatalogOpen}function U4(t){return t.isUsageStatsPageOpen}function H4(t){return t.isSourceBoardOpen}function K4(t){return t.isOverviewOpen}function q4(t){return t.worktreesPageProjectId}function G4(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function Z4(t){return t.isCommandPaletteOpen}function X4(t){return t.isHelpDialogOpen}function Y4(t){return t.isProjectActionsDialogOpen}function J4(t){return t.isOpenCodeStatusDialogOpen}function Q4(t){return t.accessDialog!==null}function e5(t){return t.applyDialog!==null}function t5(t){return t.setupOutputDialog!==null}function s5(t){return t.openGuestPageId}function n5(){return K.getState().setOpenGuestPage(null)}function r5(){return Pc(n5)}function o5(){return eb()}function a5(){return K.getState().closeMainSurfaces()}function i5(){return Dd(false)}function l5(){return i5}function c5(){return K.getState().closeMainSurfaces()}function d5(){const t=c5,e=it.subscribe((s,r)=>{const o=!!s.currentSessionId&&s.currentSessionId!==r.currentSessionId,a=!!s.newSessionDraft?.open&&s.newSessionDraft!==r.newSessionDraft;(o||a)&&t()});return()=>{e()}}function u5(){return K.getState().setCommandPaletteOpen(false)}function f5(){return K.getState().setHelpDialogOpen(false)}function p5(){return K.getState().setProjectActionsDialogOpen(false)}function m5(){return K.getState().setOpenCodeStatusDialogOpen(false)}function h5(){return yn.getState().closeAccessDialog()}function g5(){return yn.getState().closeApplyDialog()}function x5(){return yn.getState().closeSetupOutputDialog()}function b5(){return K.getState().setOpenGuestPage(null)}const $a="openchamber_requests_in_flight",af=1e3,w5=300*1e3,po=Math.ceil(w5/af),y5=()=>{if(typeof window>"u")return false;try{return window.localStorage.getItem($a)==="1"}catch{return false}},lf=()=>({enabled:true,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:false,originalFetch:null,sampleTimer:null});let v5=1;const S5=(t,e)=>{const s=window.__openchamberRequestsInFlight__;!s||!s.enabled||(s.inFlight+=1,s.totalStarted+=1,s.inFlight>s.peak&&(s.peak=s.inFlight),s.inFlightStarts.set(t,e))},k5=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},cf=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),s=[];for(const r of t.inFlightStarts.values())s.push(Math.max(0,e-r));return s.sort((r,o)=>r-o),s},On=(t,e)=>{const s=t.length;if(s===0)return 0;if(s===1)return t[0];const r=e/100*(s-1),o=Math.floor(r),a=Math.ceil(r);return o===a?t[o]:t[o]+(t[a]-t[o])*(r-o)},j5=()=>{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=true;const s=async(r,o)=>{const a=v5++;S5(a,Date.now());try{return await e(r,o)}finally{k5(a)}};window.fetch=s},oc=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=false,t.originalFetch=null)},Zn=t=>{t.length>po&&t.splice(0,t.length-po)},T5=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=cf(t),s=e.length>0?e[e.length-1]:0;t.p50Samples.push(On(e,50)),t.p90Samples.push(On(e,90)),t.p99Samples.push(On(e,99)),t.maxSamples.push(s),s>t.peakAgeMs&&(t.peakAgeMs=s),t.sampleCount+=1,Zn(t.samples),Zn(t.p50Samples),Zn(t.p90Samples),Zn(t.p99Samples),Zn(t.maxSamples),t.lastSampleAt=Date.now()},C5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(T5,af))},ac=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},ic=t=>{if(!(typeof window>"u"))try{if(t){ac(),oc(),window.localStorage.setItem($a,"1"),window.__openchamberRequestsInFlight__=lf(),j5(),C5();return}window.localStorage.removeItem($a),ac(),oc(),delete window.__openchamberRequestsInFlight__}catch{}},mC=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=lf();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},hC=()=>{if(typeof window>"u")return lc();const t=window.__openchamberRequestsInFlight__;if(!y5()||!t)return lc();const e=cf(t);return{enabled:true,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:On(e,50),ageP90:On(e,90),ageP99:On(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:po}},lc=()=>({enabled:false,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:po}),E5=(t,e,s)=>lx(t.filter(r=>!_d(r)&&!r.parentID),e,s),I5=()=>E5(os.getState().activeSessions,Rr.getState().ids,ui.getState().rankById??cx),N5=(t,e,s)=>{if(t.length===0)return;const r=t.findIndex(a=>a.id===e);let o=s>0?0:t.length-1;return r>=0&&(o=(r+s+t.length)%t.length),t[o]},P5=()=>{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()??"":""},R5=async()=>{const t=P5()||window.getSelection()?.toString()||"";if(!t.trim())return false;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),true}catch{}return document.execCommand("copy")},cc="openchamber:menu-action",dc="openchamber:check-for-updates",D5=t=>{const e=qe.c(24),{t:s}=gt(),r=it(_5),o=K(A5),a=K(O5),i=K(M5),u=K(F5),d=K(L5),l=K($5),f=K(B5),m=qc(z5),{setThemeMode:p}=bo(),h=c.useRef(false),x=K(W5);let g,v;e[0]!==x?(g=()=>{eo()&&on("desktop_set_menu_shortcuts",{shortcuts:dx(x)}).catch(V5)},v=[x],e[0]=x,e[1]=g,e[2]=v):(g=e[1],v=e[2]),c.useEffect(g,v);let y;e[3]!==m?(y=()=>{h.current||(h.current=true,m().then(U5).finally(()=>{h.current=false}))},e[3]=m,e[4]=y):y=e[4];const C=y,S=H5;let N;e[5]!==d?(N=b=>{const w=it.getState().currentSessionId,j=N5(I5(),w,b);j&&(d(false),it.getState().setCurrentSession(j.id,Hs(j)))},e[5]=d,e[6]=N):N=e[6];const F=N,_=K5;let M;e[7]!==F||e[8]!==t||e[9]!==r||e[10]!==f||e[11]!==a||e[12]!==d||e[13]!==l||e[14]!==p||e[15]!==s||e[16]!==o||e[17]!==i||e[18]!==u?(M=b=>{e:switch(b){case"about":{f(true);break e}case"settings":{l(true);break e}case"command-palette":{o();break e}case"quick-open":{a(true);break e}case"new-session":{d(false);const w=it.getState(),j=qt.getState().currentDirectory;r(w.currentSessionId&&j?{directoryOverride:j}:void 0);break e}case"new-worktree-session":{d(false),px();break e}case"change-workspace":{S();break e}case"toggle-right-sidebar":{const w=qt.getState().currentDirectory;if(!w)break e;const j=K.getState(),R=ds(w),L=j.contextPanelByDirectory[R],E=L?Hf(L.tabs,j.contextSurfaceZones,"right",lr(L,"right").activeTabId):null;L?.isOpen?j.closeContextPanel(R):E?j.setActiveContextPanelTab(R,E):j.openContextSurface(R,"git");break e}case"open-right-sidebar-git":{const w=qt.getState().currentDirectory;if(!w)break e;K.getState().openContextSurface(ds(w),"git");break e}case"open-right-sidebar-files":{const w=qt.getState().currentDirectory;if(!w)break e;K.getState().openContextSurface(ds(w),"file");break e}case"toggle-terminal":{const w=qt.getState().currentDirectory;if(!w)break e;K.getState().openContextSurface(ds(w),"terminal");break e}case"toggle-context-panel-expanded":{fx(qt.getState().currentDirectory);break e}case"copy":{const w=new Event("openchamber:copy",{cancelable:true});!window.dispatchEvent(w)||R5();break e}case"theme-light":{p("light");break e}case"theme-dark":{p("dark");break e}case"theme-system":{p("system");break e}case"add-selection-to-chat":{ux();break e}case"toggle-sidebar":{u();break e}case"toggle-memory-debug":{t?.();break e}case"go-back":{el(-1);break e}case"go-forward":{el(1);break e}case"previous-session":{F(-1);break e}case"next-session":{F(1);break e}case"previous-project":{_(-1);break e}case"next-project":{_(1);break e}case"help-dialog":{i();break e}case"download-logs":Pd().catch(()=>{Fe.error(s("openCodeStatusDialog.toast.collectFailed"))})}},e[7]=F,e[8]=t,e[9]=r,e[10]=f,e[11]=a,e[12]=d,e[13]=l,e[14]=p,e[15]=s,e[16]=o,e[17]=i,e[18]=u,e[19]=M):M=e[19];const B=M;let T,I;e[20]!==B||e[21]!==C?(T=()=>{const b=j=>{const R=j.detail;R&&B(R)},w=()=>{C()};return window.addEventListener(cc,b),window.addEventListener(dc,w),()=>{window.removeEventListener(cc,b),window.removeEventListener(dc,w)}},I=[B,C],e[20]=B,e[21]=C,e[22]=T,e[23]=I):(T=e[22],I=e[23]),c.useEffect(T,I)};function _5(t){return t.openNewSessionDraft}function A5(t){return t.toggleCommandPalette}function O5(t){return t.setCommandPaletteOpen}function M5(t){return t.toggleHelpDialog}function F5(t){return t.toggleSidebar}function L5(t){return t.setSessionSwitcherOpen}function $5(t){return t.setSettingsDialogOpen}function B5(t){return t.setAboutDialogOpen}function z5(t){return t.checkForUpdates}function W5(t){return t.shortcutOverrides}function V5(t){console.warn("[menu-actions] failed to update menu shortcuts",t)}function U5(){const{available:t,error:e}=qc.getState();if(e){Fe.error("Failed to check for updates",{description:e});return}t||Fe.success("You are on the latest version")}function H5(){xr.requestDirectoryDialog()}function K5(t){const{activeProjectId:e,projects:s,setActiveProject:r}=Yt.getState();if(s.length===0)return;const o=s.findIndex(u=>u.id===e);let a=t>0?0:s.length-1;o>=0&&(a=(o+t+s.length)%s.length);const i=s[a];i&&r(i.id)}const uc="openchamber:install-extension",df=t=>xb({source:t,confirmed:false}),q5=()=>{const t=qe.c(1);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],c.useEffect(X5,e)};function G5(t){const{url:e}=t.detail??{};typeof e=="string"&&e&&df(e)}function Z5(t){return t.forEach(df)}function X5(){const t=G5;return window.addEventListener(uc,t),Kf().then(Z5),()=>window.removeEventListener(uc,t)}const fc=(t,{isAdmitted:e,isPlaced:s,isPinned:r,zones:o})=>!e||t.parentID||t.time?.archived||_d(t)?false:s||o.pinned&&r||o.work&&Za(t),Y5="openchamber:tray-action",J5=5e3,Q5=500,eT=20,pc=()=>{if(typeof window>"u")return false;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},mc=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==false,uf=t=>{const e=t.action.trim()||"Permission",s=t.resources.find(r=>r.trim());return s?`${e}: ${s}`:e},ff=t=>t.title.trim()||"Question",tT=new Set,sT=(t,e)=>vx(t,e,tT,ui.getState().rankById),nT=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),s=e.lastIndexOf("/");return s>=0?e.slice(s+1):e},rT=(t,e,s,r,o)=>{if(!t)return"";const a=Er(s,r,t),i=e.project?.name,u=a?.label?.trim()||i?.trim()||nT(t),d=ro(t);let l=d&&o.get(d)||"";if(!l){for(const[f,m]of Ln.getState().directories)if(ro(f)===d){l=m.status?.current??"";break}}if(!l)for(const f of r.values()){const m=d?so(f,d):void 0;if(m?.branch){l=m.branch;break}}return l?`${u} \xB7 ${l}`:u},oT=()=>{const{dictionary:t}=Xf.getState(),e=(l,f)=>Yf(t,l,f),{results:s,dropdownProviderIds:r,displayMode:o,extensionProviders:a}=Bd.getState(),i=o==="remaining"?"remaining":"usage";if(!r.length)return{mode:i,groups:[]};const u=new Map(s.map(l=>[l.providerId,l])),d=[];for(const l of Sx(a)){if(!r.includes(l.id))continue;const f=u.get(l.id);if(!f||f.configured!==true)continue;const m=[];for(const[h,x]of Object.entries(f.usage?.windows??{})){const g=i==="remaining"?x.remainingPercent:x.usedPercent;m.push({label:jx(h),value:kx(x,g,e)})}const p=!f.ok&&f.error?f.error:m.length===0?"No rate limits reported":null;d.push({provider:l.name,rows:m,status:p})}return{mode:i,groups:d}},aT=async()=>{try{if(go())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=qf();if(e&&Ci(e,t))return"Local OpenChamber";const r=(await Ha()).hosts.find(o=>e?Ci(e,Dc(o)):false);return r?.label?.trim()?Gf(r.label.trim()):"Instance"}catch{return""}},iT=()=>{const t=new Map,e=new Map,s=[],r=new Map;let o;try{o=xa()}catch{return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}}for(const[a,i]of o.children.entries()){const u=i.getState();u.vcs?.branch&&e.set(ro(a)??a,u.vcs.branch);for(const d of u.session)d?.id&&r.set(d.id,d.title);for(const[d,l]of Object.entries(u.session_status??{})){const f=l?.type,m=f==="busy"?"busy":f==="retry"?"retry":"idle",p=t.get(d);(!p||p==="idle")&&t.set(d,m)}for(const[d,l]of Object.entries(u.permission??{}))for(const f of l??[]){if(!f?.id)continue;const m=f.sessionID||d;s.push({kind:"permission",id:f.id,sessionId:m,sessionTitle:"",label:uf(f),directory:a,canSave:zd(f.save)})}for(const[d,l]of Object.entries(u.form??{}))for(const f of l??[]){if(!f?.id)continue;const m=f.sessionID||d;s.push({kind:"form",id:f.id,sessionId:m,sessionTitle:"",label:ff(f),directory:a,canSave:false})}}return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}},lT=(t,e)=>{const s=os.getState().activeSessions,r=xx(s),o=T=>r.descendantsOf(T,"active").map(I=>I.id),a=Yt.getState().projects,i=it.getState().availableWorktreesByProject,u=Rr.getState().ids,d=(T,I)=>{const b=Hs(T),w=tl(b,a,i);return ho(b)||T.projectID===Zf?fc(T,{isAdmitted:w,isPlaced:I.chats,isPinned:false,zones:{pinned:false,work:false}}):fc(T,{isAdmitted:w,isPlaced:Cc(b)||Er(a,i,b)!==null,isPinned:di(u,T.directory,T.id),zones:I})},l=Rc.getState(),f={chats:l.showChatsSection,pinned:l.showPinnedSection,work:K.getState().sessionWorkEnabled&&l.showWorkSection},m={chats:true,pinned:true,work:true},p=bx(ga.getState().activeSessionIds,[Ad.getState().runningSessionIds,Od.getState().sessionIds,Md.getState().sessionIds,Fd.getState().bySession.keys(),Ld.getState().bySession.keys()]),h=T=>yx(T)&&!p.has(T.id),x=K.getState().dockBadgeEnabled?s.filter(T=>h(T)&&d(T,f)):[],g=x.length,v=x.sort((T,I)=>(I.time.idle??I.time.updated)-(T.time.idle??T.time.updated)||T.id.localeCompare(I.id)).slice(0,10).map(T=>({id:T.id,title:T.title,directory:Hs(T)??""}));if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:g,dockUnreadSessions:v};const y=iT(),C=new Map(y.titleById);for(const T of s)T?.id&&T.title&&C.set(T.id,T.title);const S=ga.getState().statusById,N=T=>{const I=y.statusById.get(T);return I&&I!=="idle"?I:S.get(T)?.status.type??I??"idle"},F=T=>{const I=T.map(b=>N(b));return I.includes("busy")?"busy":I.includes("retry")?"retry":"idle"},_=s.filter(T=>T?.id&&!T.parentID).filter(T=>d(T,m)).slice().sort(sT).slice(0,eT).map(T=>{const I=[T.id,...o(T.id)],b=Hs(T)??"";return{id:T.id,title:T.title||"Untitled session",status:F(I),branch:b?y.branchByDirectory.get(b)??"":"",unseen:h(T)?1:0,hasError:h(T)&&wx(T),directory:b,subtitle:rT(b,T,a,i,y.branchByDirectory)}}),M=y.approvals.map(T=>({...T,sessionTitle:C.get(T.sessionId)||""})),B=new Set(M.map(T=>T.id));for(const[T,I]of $d.getState().bySession){const b=C.get(T)||"";for(const w of I.permissions)B.has(w.id)||(B.add(w.id),M.push({kind:"permission",id:w.id,sessionId:T,sessionTitle:b,label:uf(w),directory:I.directory,canSave:zd(w.save)}));for(const w of[...I.forms,...I.pages])B.has(w.id)||(B.add(w.id),M.push({kind:"form",id:w.id,sessionId:T,sessionTitle:b,label:ff(w),directory:I.directory,canSave:false}))}return{sessions:_,approvals:M.filter(T=>tl(T.directory,a,i)),instanceName:t,usage:oT(),dockBadgeCount:g,dockUnreadSessions:v}},cT=()=>{c.useEffect(()=>{if(!pc()||!eo())return;const t=mc();let e=false,s="",r=null,o="";const a=()=>{if(e)return;const j=lT(o,t),R=JSON.stringify(j);R!==s&&(s=R,on("desktop_tray_update",j))},i=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,a()},Q5))},u=os.subscribe(()=>i()),d=ga.subscribe(()=>i()),l=Ad.subscribe(()=>i()),f=Od.subscribe(()=>i()),m=Md.subscribe(()=>i()),p=Fd.subscribe(()=>i()),h=Ld.subscribe(()=>i()),x=K.subscribe((j,R)=>{(j.dockBadgeEnabled!==R.dockBadgeEnabled||j.sessionWorkEnabled!==R.sessionWorkEnabled)&&i()}),g=Yt.subscribe(()=>i()),v=it.subscribe(()=>i()),y=Rr.subscribe(()=>i()),C=Rc.subscribe((j,R)=>{(j.showChatsSection!==R.showChatsSection||j.showPinnedSection!==R.showPinnedSection||j.showWorkSection!==R.showWorkSection)&&i()}),S=()=>{e=true,r!==null&&window.clearTimeout(r),u(),d(),l(),f(),m(),p(),h(),x(),g(),v(),y(),C()};if(!t)return a(),S;aT().then(j=>{e||(o=j,a())});const N=new Map,F=()=>{if(e)return;let j;try{j=xa()}catch{return}const R=new Set;for(const[L,E]of j.children.entries())R.add(L),N.has(L)||N.set(L,E.subscribe(()=>i()));for(const[L,E]of N)R.has(L)||(E(),N.delete(L))};let _=null;try{_=xa().subscribeRegistry(()=>{F(),i()})}catch{}F();const M=Ln.subscribe(()=>i()),B=$d.subscribe(()=>i()),T=ui.subscribe(()=>i()),I=Bd.subscribe(()=>i()),b=Ut.subscribe((j,R)=>{j.isInitialized&&!R.isInitialized&&Go(true)});Go(true);const w=window.setInterval(()=>{F(),a()},J5);return a(),()=>{S(),window.clearInterval(w),M(),B(),T(),I(),b(),_?.();for(const j of N.values())j();N.clear()}},[]),c.useEffect(()=>{if(!pc()||!eo())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const s=a=>{switch(a.type){case"mark-all-read":hx().then(()=>gx()).catch(()=>{});break;case"menu-opened":mc()&&Go();break;case"respond-permission":mx(a.sessionId,a.id,a.response).catch(()=>{Fe.error("Failed to respond to permission request")});break}};let r=null,o=false;return e(Y5,a=>{const i=a?.payload;!i||typeof i!="object"||typeof i.type!="string"||s(i)}).then(a=>{if(o){a();return}r=a,on("desktop_tray_actions_ready")}).catch(()=>{}),()=>{o=true;try{const a=r?.();a instanceof Promise&&a.catch(()=>{})}catch{}}},[])},dT=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():true,uT=(t,e,s,r)=>r||[t,e,s].filter(Boolean).join("|")||void 0,fT=t=>{t.kind!=="plugin"||!t.title||Fe.info(t.title,{id:uT(t.kind,t.title,t.body,t.tag),description:t.body})},pT=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===true,mT=t=>{const e=qe.c(3),s=true;let r,o;e[0]!==s?(r=()=>{if(!(As()||!_c()||!globalThis.window))return $n(hT)},o=[s],e[0]=s,e[1]=r,e[2]=o):(r=e[1],o=e[2]),c.useEffect(r,o)};function hT(t){if(t.type!=="notification"||t.payload.kind==="share-answer"&&t.payload.toastOnly===true)return;const e=K.getState();if(!e.nativeNotificationsEnabled)return;const s=dT();if(pT(t.payload,s)){fT(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==false&&s)return;Nc()?.notifications?.notifyAgentCompletion(t.payload)}const gT=()=>{const t=qe.c(3),{t:e}=gt();let s,r;t[0]!==e?(s=()=>$n(o=>{if(o.type!=="limit-failover")return;const{failover:a}=o,i=Ut.getState().providers,u=d=>i.find(l=>l.id===d);if(a.kind==="account"){const d=u(a.providerId)?.name||a.providerId;Fe.info(a.fromAccount?e("chat.limitFailover.toast.account",{provider:d,from:a.fromAccount,to:a.toAccount}):e("chat.limitFailover.toast.accountUnknown",{provider:d,to:a.toAccount}));return}Fe.info(e("chat.limitFailover.toast.model",{model:sl(u(a.providerId),a.modelId),fallback:sl(u(a.toProviderId),a.toModelId)}))}),r=[e],t[0]=e,t[1]=s,t[2]=r):(s=t[1],r=t[2]),c.useEffect(s,r)},hc="relay-limit-reached",xT=()=>{const t=qe.c(3),{t:e}=gt();let s,r;t[0]!==e?(s=()=>{const o=()=>{Fe.error(e("relayConnection.limitReached.title"),{id:hc,description:e("relayConnection.limitReached.description"),duration:1/0,action:{label:e("relayConnection.limitReached.retry"),onClick:bT}})};return Ei(Ac()?.getStatus())&&o(),Jf(i=>{Ei(i)?o():(i.state==="connected"||i.state==="idle")&&Fe.dismiss(hc)})},r=[e],t[0]=e,t[1]=s,t[2]=r):(s=t[1],r=t[2]),c.useEffect(s,r)};function bT(){return Ac()?.retry()}const gc=()=>{Qf()||(Tx(),Cx(ym.map(t=>t.id)))},wT=(t,e)=>{const s=qe.c(5);let r;s[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const i=window.requestIdleCallback(gc,{timeout:1e4});return()=>window.cancelIdleCallback(i)}const a=setTimeout(gc,3e3);return()=>clearTimeout(a)},s[0]=t,s[1]=r):r=s[1];let o;s[2]!==e||s[3]!==t?(o=[t,e],s[2]=e,s[3]=t,s[4]=o):o=s[4],c.useEffect(r,o)},xc="pwa-install-toast-shown",bc="pwa-install-toast-dismissed",yT=()=>{const t=qe.c(6),{browserTab:e}=vm(),{t:s}=gt(),r=c.useRef(s);let o,a;t[0]!==s?(o=()=>{r.current=s},a=[s],t[0]=s,t[1]=o,t[2]=a):(o=t[1],a=t[2]),c.useEffect(o,a);let i,u;t[3]!==e?(i=()=>{if(typeof window>"u"||!_c()||!e)return;let d=null,l=null;const f=()=>{l!==null&&(Fe.dismiss(l),l=null)},m=async()=>{if(!d)return;const x=d;d=null,f(),await x.prompt();const{outcome:g}=await x.userChoice;g==="accepted"&&Fe.success(r.current("pwa.installPrompt.started"))},p=x=>{const g=x;if(typeof g.prompt!="function")return;g.preventDefault(),d=g;const v=Ii(),y=ep();Sm({dismissed:v.getItem(bc),sessionShown:y.getItem(xc),hasActiveToast:l!==null})&&(y.setItem(xc,"true"),l=Fe.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{m()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Ii().setItem(bc,"true"),f()}}}))},h=()=>{d=null,f(),Fe.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",h),()=>{f(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",h)}},u=[e],t[3]=e,t[4]=i,t[5]=u):(i=t[4],u=t[5]),c.useEffect(i,u)},pf=()=>globalThis.window?.__OPENCHAMBER_SAFE_START__===true,vT=()=>{gs.setState({byRoot:{},runtimeSnapshots:{}});const t=K.getState();for(const e of Object.keys(t.contextPanelByDirectory))for(const s of Ua)t.closeContextZone(e,s)},ST=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",mf=async(t,e)=>{const s=(await Ha()).hosts.find(o=>o.id===t);if(!s)throw new Error("host-not-found");if(s.relay){await rp(s.id,e);return}const r=op(Dc(s));if(!r)throw new Error("host-not-found");ap({apiBaseUrl:r,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:ip(s),sshForwarded:s.sshForwarded===true})},kT=async t=>{const e=await Ha(),s=await sp(t,e.hosts);await np({hosts:s.hosts,defaultHostId:e.defaultHostId||s.hostId,initialHostChoiceCompleted:true}),await mf(s.hostId,{reconnectActive:true})},jT=async t=>{const e=await tp();for(const s of e)try{s.type==="pairing"?await kT(s.link):await mf(s.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",s.type,o),t(ST(o))}},Ba="project-config-invalid",TT=()=>{const t=qe.c(9),{t:e}=gt(),s=Ut(CT);let r;t[0]!==s?(r=p=>p.projectConfigErrors[s],t[0]=s,t[1]=r):r=t[1];const o=Ut(r),[a,i]=Kt.useState(false);let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const p=Ut.getState(),h=p.activeDirectoryKey;i(true),Promise.all([p.loadProviders({directory:h,source:"projectConfigError:retry"}),p.loadAgents({directory:h,source:"projectConfigError:retry"})]).finally(()=>i(false))},t[2]=u):u=t[2];const d=u;let l,f;t[3]!==o||t[4]!==a||t[5]!==e?(l=()=>{if(!o){Fe.dismiss(Ba);return}Fe.error(e("projectConfigError.toast.title"),{id:Ba,duration:1/0,description:n.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[n.jsx("span",{className:"break-all font-mono typography-meta",children:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&n.jsx(ps,{as:"span",outerClassName:"max-h-40",className:"whitespace-pre-wrap break-words font-mono typography-meta",disableHorizontal:true,children:o.message}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(a?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:p=>{p.preventDefault(),a||d()}}})},f=[o,a,d,e],t[3]=o,t[4]=a,t[5]=e,t[6]=l,t[7]=f):(l=t[6],f=t[7]),Kt.useEffect(l,f);let m;return t[8]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[8]=m):m=t[8],Kt.useEffect(IT,m),null};function CT(t){return t.activeDirectoryKey}function ET(){Fe.dismiss(Ba)}function IT(){return ET}const NT="\x1B",PT=new RegExp(`${NT}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Wr=It().transform(t=>t.replace(PT,"").trim()).nullish(),RT=Mt({isOpenCodeReady:ss().optional(),openCodeRunning:ss().optional(),lastOpenCodeError:Wr,opencodeBinaryResolved:Wr,lastOpenCodeLaunchDiagnostics:Mt({sourceBinary:Wr,binary:Wr}).nullish()}),DT=async(t,e=Ms)=>{const s=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)throw new Error(`Startup diagnostics request failed (${s.status})`);const r=RT.parse(await s.json());return r.isOpenCodeReady===true||r.isOpenCodeReady!==false&&r.openCodeRunning!==false?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},_T=(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"}},AT=Mt({openchamberVersion:It()}),OT=async(t,e=Ms)=>{const s=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)return null;const r=AT.safeParse(await s.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},MT=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function FT({version:t}){const{t:e}=gt(),[s,r]=c.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const u=await jm();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})}},a=s.kind==="manual"?s:null,i=a?.info?.updateCommand||"openchamber update";return n.jsxs("div",{className:"flex w-full flex-col items-center gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("h1",{className:"typography-h1 text-foreground",children:e("startup.serverOutdated.title")}),n.jsx("p",{className:"typography-markdown text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),n.jsxs(yt,{type:"button",onClick:()=>{o()},disabled:s.kind==="checking",children:[n.jsx(ue,{name:s.kind==="checking"?"loader":"download",className:s.kind==="checking"?"size-4 animate-spin":"size-4"}),s.kind==="checking"?e("startup.serverOutdated.checking"):e("onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),a&&n.jsxs("div",{className:"w-full space-y-2 text-start",children:[!a.info?.available&&n.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),a.error&&n.jsx("p",{dir:"auto",className:"typography-meta text-muted-foreground",children:a.error}),a.info?.installBlocked==="opencode-version"?n.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:e("updateDialog.openCodeTooOld",{version:a.info.version||"",required:a.info.requiredOpenCodeVersion||"",current:a.info.openCodeVersion||""})}):a.info?.installBlocked==="desktop-host"?n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:a.info.version||""})}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("onboarding.desktopRecovery.remoteIncompatible.manualUpdate")}),n.jsx("code",{dir:"ltr",className:"block select-text rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono text-sm text-foreground",children:i})]})]}),n.jsx(km,{open:s.kind==="available",onOpenChange:u=>{u||r({kind:"idle"})},info:s.kind==="available"?s.info:null,downloading:false,downloaded:false,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const wc=Tr(()=>Vt(()=>import("./OnboardingScreen-CDhZHMEt.js"),__vite__mapDeps([266,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}))),LT=()=>Vt(()=>import("./AboutDialog-l-zrh7nU.js"),__vite__mapDeps([267,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,243])).then(t=>t.AboutDialog),$T=()=>Vt(()=>import("./MemoryDebugPanel-fX9cD8th.js"),__vite__mapDeps([268,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,208,209,210,211])).then(t=>t.MemoryDebugPanel),BT=()=>{const t=qe.c(6),e=K(HT),s=K(KT);let r;t[0]!==s?(r=()=>s(false),t[0]=s,t[1]=r):r=t[1];const o=Eo(e,LT,r);if(!o)return null;let a;return t[2]!==o||t[3]!==e||t[4]!==s?(a=n.jsx(o,{open:e,onOpenChange:s}),t[2]=o,t[3]=e,t[4]=s,t[5]=a):a=t[5],a},zT=t=>{const e=qe.c(3),{onClose:s}=t,r=Eo(true,$T,s);let o;return e[0]!==r||e[1]!==s?(o=r?n.jsx(r,{onClose:s}):null,e[0]=r,e[1]=s,e[2]=o):o=e[2],o},WT=t=>{const e=qe.c(47),{onRetry:s,isRetrying:r}=t,{t:o}=gt(),[a,i]=c.useState(null);let u,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const T=new AbortController,I=Xt(),b=setTimeout(()=>T.abort(),5e3);return DT(T.signal).then(w=>{!T.signal.aborted&&Xt()===I&&i(w)}).catch(qT).finally(()=>clearTimeout(b)),()=>{T.abort(),clearTimeout(b)}},d=[],e[0]=u,e[1]=d):(u=e[0],d=e[1]),c.useEffect(u,d);const[l,f]=c.useState(null);let m,p;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{const T=new AbortController,I=Xt(),b=setTimeout(()=>T.abort(),5e3);return OT(T.signal).then(w=>{T.signal.aborted||Xt()!==I||f(w&&MT(w)?w:null)}).catch(GT).finally(()=>clearTimeout(b)),()=>{T.abort(),clearTimeout(b)}},p=[],e[2]=m,e[3]=p):(m=e[2],p=e[3]),c.useEffect(m,p);const h=Ut(ZT),x=a?null:h?.message??null;if(l){let T;e[4]!==l?(T=n.jsx(FT,{version:l}),e[4]=l,e[5]=T):T=e[5];let I;e[6]!==r||e[7]!==o?(I=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=I):I=e[8];let b;e[9]!==r||e[10]!==s||e[11]!==I?(b=n.jsx(yt,{type:"button",variant:"outline",onClick:s,disabled:r,children:I}),e[9]=r,e[10]=s,e[11]=I,e[12]=b):b=e[12];let w;return e[13]!==T||e[14]!==b?(w=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[T,b]})}),e[13]=T,e[14]=b,e[15]=w):w=e[15],w}let g;e[16]!==o?(g=o("startup.initRecovery.title"),e[16]=o,e[17]=g):g=e[17];let v;e[18]!==g?(v=n.jsx("h1",{className:"typography-h1 text-foreground",children:g}),e[18]=g,e[19]=v):v=e[19];let y;e[20]!==a||e[21]!==h||e[22]!==o?(y=o(_T(a,h)),e[20]=a,e[21]=h,e[22]=o,e[23]=y):y=e[23];let C;e[24]!==y?(C=n.jsx("p",{className:"typography-markdown text-muted-foreground",children:y}),e[24]=y,e[25]=C):C=e[25];let S;e[26]!==v||e[27]!==C?(S=n.jsxs("div",{className:"flex flex-col gap-2",children:[v,C]}),e[26]=v,e[27]=C,e[28]=S):S=e[28];let N;e[29]!==x||e[30]!==o?(N=x&&n.jsxs("dl",{className:"w-full min-w-0 text-start","aria-live":"polite",children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.lastError")}),n.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:x})]}),e[29]=x,e[30]=o,e[31]=N):N=e[31];let F;e[32]!==a||e[33]!==o?(F=a&&n.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[a.binary&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),n.jsx("dd",{className:"break-all font-mono typography-meta",children:a.binary})]}),a.error&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.error")}),n.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:a.error})]})]}),e[32]=a,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 M;e[38]!==r||e[39]!==s||e[40]!==_?(M=n.jsx(yt,{type:"button",onClick:s,disabled:r,children:_}),e[38]=r,e[39]=s,e[40]=_,e[41]=M):M=e[41];let B;return e[42]!==N||e[43]!==F||e[44]!==M||e[45]!==S?(B=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[S,N,F,M]})}),e[42]=N,e[43]=F,e[44]=M,e[45]=S,e[46]=B):B=e[46],B};function VT({apis:t}){q5(),c.useEffect(()=>Ex(),[]),c.useEffect(()=>{lp("App:mounted"),cp()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Ut(P=>P.initializeApp),s=Ut(P=>P.isInitialized),r=Ut(P=>P.isConnected),o=Ut(P=>P.providersLoaded),a=Ut(P=>P.agentsLoaded),i=Ut(P=>P.loadProviders),u=Ut(P=>P.loadAgents),d=it(P=>P.error),l=it(P=>P.clearError),f=qt(P=>P.currentDirectory),m=qt(P=>P.isSwitchingDirectory),[p,h]=c.useState(false),x=vn(P=>P.refreshAll),g=jc(P=>P.refresh),[v,y]=c.useState(()=>t.runtime.isVSCode),[C,S]=c.useState(false),[N,F]=c.useState(0),[_,M]=c.useState(0),[B,T]=c.useState(false),I=K(P=>P.mobileKeyboardMode),b=c.useMemo(()=>As(),[]),[w,j]=c.useState(()=>Ni()),[R,L]=c.useState(()=>{const P=Bo();return P!==null?Pi({isDesktopShell:true,bootOutcome:P}):null}),E=c.useRef(false),{t:D}=gt(),U=c.useRef(false);c.useEffect(()=>{if(!s||w!=="valid"||U.current)return;const P=Bo();P?.target!=="local"||P.status!=="ok"||!P.sshStartupFallbackHostId||(U.current=true,Fe.error(D("desktopHostSwitcher.startup.title"),{description:D("desktopHostSwitcher.startup.fellBackToLocal")}))},[w,s,D]);const V=c.useRef(false);c.useEffect(()=>{!s||!pf()||V.current||(V.current=true,Fe.info(D("desktopSafeStart.title"),{description:D("desktopSafeStart.description"),duration:1/0}))},[s,D]),c.useEffect(()=>(Ri(p),ic(p),()=>{Ri(false),ic(false)}),[p]),c.useEffect(()=>{dp(I)},[I]),c.useEffect(()=>{y(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>Pc(P=>{Cm(P)&&Em(P),M(ee=>ee+1),S(false),F(ee=>ee+1)}),[]),Im(),c.useEffect(()=>(Di(t),()=>Di(null)),[t]),c.useEffect(()=>{r&&(g(t.sourceControl),x(t.sourceControl,{force:true}),Ix(t.trackers))},[t.sourceControl,t.trackers,r,x,g,_]),Nx();const J=w==="valid",W=R?.screen==="main";c.useEffect(()=>{if(!up({isDesktopShell:b,bootOutcomeKnown:J}))return;Px();const P=setTimeout(()=>{const ee=document.getElementById("initial-loading");ee&&(ee.classList.add("fade-out"),setTimeout(()=>{ee.remove()},300))},150);return()=>clearTimeout(P)},[b,J]),c.useEffect(()=>{if(!b||w!=="malformed")return;const P=document.getElementById("initial-loading");P&&(P.textContent="Desktop startup failed \u2014 please restart the app.")},[b,w]),c.useEffect(()=>{v||e()},[e,v]),c.useEffect(()=>{if(v||s)return;let P=true,ee,oe=0;const de=10,he=1e3,Z=async()=>{if(!P)return;if(oe>=de){S(true);return}const ce=Ut.getState();if(ce.isInitialized){S(false);return}oe+=1,await ce.initializeApp();const ae=Ut.getState();if(!P)return;if(ae.isInitialized){S(false);return}if(oe>=de){S(true);return}const te=Math.min(he*Math.pow(2,oe-1),4e3);ee=setTimeout(Z,te)};return ee=setTimeout(Z,he),()=>{P=false,ee&&clearTimeout(ee)}},[N,s,v]),c.useEffect(()=>{s&&S(false)},[s]),c.useEffect(()=>{if(!C)return;const P=document.getElementById("initial-loading");P&&(P.classList.add("fade-out"),setTimeout(()=>{P.remove()},300))},[C]),c.useEffect(()=>{if(v||!r||o&&a)return;let P=true,ee=0;const oe=15,de=async()=>{const Z=Ut.getState();if(!(Z.providersLoaded&&Z.agentsLoaded))try{Z.providersLoaded||await i({source:"startupRecovery"}),Ut.getState().agentsLoaded||await u({source:"startupRecovery"})}catch{}};de();const he=setInterval(()=>{if(P){if(++ee>=oe){clearInterval(he);return}de()}},2e3);return()=>{P=false,clearInterval(he)}},[r,v,u,i,o,a]),c.useEffect(()=>{m||v||r&&ua.setDirectory(f)},[f,m,r,v]),c.useEffect(()=>{if(typeof window>"u")return;const P=ee=>{const oe=ee.detail,de=typeof oe?.sessionId=="string"?oe.sessionId.trim():"";if(!de)return;const he=typeof oe?.directory=="string"&&oe.directory.trim().length>0?oe.directory.trim():null,Z=typeof oe?.messageId=="string"&&oe.messageId.trim()||null;_i(de,String(oe?.runtimeKey??"").trim(),Z)||nl(de,{directory:he,messageId:Z,requireKnownSession:oe?.requireKnownSession===true})};return window.addEventListener("openchamber:open-session",P),fp().then(ee=>{for(const oe of ee)_i(oe.sessionId,oe.runtimeKey,oe.messageId)||(oe.requireKnownSession?nl(oe.sessionId,{messageId:oe.messageId,requireKnownSession:true}):Rx(oe.sessionId,oe.messageId))}),()=>window.removeEventListener("openchamber:open-session",P)},[]),c.useEffect(()=>{if(!As())return;const P=()=>{jT(ee=>{Fe.error(D(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",P),P(),()=>window.removeEventListener("openchamber:host-actions-ready",P)},[D]);const G=c.useRef({attempt:null,running:false,done:false});c.useLayoutEffect(()=>{const P=G.current;P.attempt||(P.attempt=Nm({selectNow:!Pm().sessionId,refresh:false}))},[]),c.useEffect(()=>{const P=G.current,ee=()=>{const oe=P.attempt;if(!oe||P.running||P.done)return;const de=Ut.getState().isInitialized;P.running=true,oe().then(he=>{if(P.running=false,he!=="failed"||de){P.done=true;return}Ut.getState().isInitialized&&ee()})};ee()},[s]),c.useEffect(()=>{if(typeof window>"u")return;const P=()=>{on("desktop_open_draft_mini_chat_window",{directory:"",projectId:null,...ca()})};return window.addEventListener("openchamber:open-mini-chat",P),()=>window.removeEventListener("openchamber:open-mini-chat",P)},[]),c.useEffect(()=>{if(typeof window>"u")return;const P=()=>{const ee=it.getState().currentSessionId;ee&&Nd(ee)};return window.addEventListener("focus",P),()=>window.removeEventListener("focus",P)},[]),c.useEffect(()=>{if(typeof window>"u")return;const P=ee=>{const oe=ee.detail,de=typeof oe?.directory=="string"&&oe.directory.trim().length>0?oe.directory.trim():null,he=typeof oe?.projectId=="string"&&oe.projectId.trim().length>0?oe.projectId.trim():null,Z=!!(de||he);K.getState().setSessionSwitcherOpen(false),it.getState().openNewSessionDraft({target:Z?"project":"chat",selectedProjectId:Z?he:null,directoryOverride:Z?de:null,preserveDirectoryOverride:!!de})};return window.addEventListener("openchamber:open-draft-session",P),()=>window.removeEventListener("openchamber:open-draft-session",P)},[]),c.useEffect(()=>{typeof window>"u"||!s||m||E.current||(E.current=true,window.__openchamberAppReady=true,window.dispatchEvent(new Event("openchamber:app-ready")))},[s,m]),Dx(),mT(),Rm(f||null),Dm(),_m(t.sourceControl),Am(t.trackers),Om(),Mm(),Fm(),gT(),_x(),Lm(),xT(),wT(s&&r,_),yT(),Ax(),tb(),$m();const le=c.useCallback(()=>{h(P=>!P)},[]);D5(le),cT(),Bm(true),c.useEffect(()=>{const P=()=>h(ee=>!ee);return window.addEventListener("openchamber:memory-debug-toggle",P),()=>window.removeEventListener("openchamber:memory-debug-toggle",P)},[]),c.useEffect(()=>{d&&setTimeout(()=>l(),5e3)},[l,d]),c.useEffect(()=>{if(!b||w!=="not-injected")return;let P=false,ee=0;const oe=200,de=2e3,he=50,Z=()=>{if(P)return;ee++;const ce=Ni();if(ce!=="not-injected"){if(P=true,j(ce),ce==="valid"){const te=Bo();te&&L(Pi({isDesktopShell:true,bootOutcome:te}))}return}const ae=Math.min(oe*Math.pow(1.1,ee),de);if(ee>=he){const te=document.getElementById("initial-loading");te&&!te.textContent?.includes("taking longer")&&(te.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Z,ae)};return window.setTimeout(Z,oe),()=>{P=true}},[b,w]);const $=c.useCallback(async()=>{if(pp({isDesktopShell:As(),isDesktopLocalOriginActive:go()})){await mp();return}window.location.reload()},[]),re=c.useCallback(async()=>{if(!B){S(false),T(true);try{await Ut.getState().initializeApp()}finally{T(false)}Ut.getState().isInitialized||F(P=>P+1)}},[B]),H=P=>{if(P.screen==="recovery")return P.variant};if(b&&R&&R.screen!=="main"){if(R.screen==="chooser")return n.jsx(Jt,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(c.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(wc,{mode:"first-launch",localAvailable:R.localAvailable!==false,onCliAvailable:$,onChooseRemote:()=>{}})})})});const P=H(R),ee=R.screen==="recovery"&&"url"in R?R.url:void 0,oe=R.screen==="recovery"&&"hostId"in R?R.hostId:void 0;return n.jsx(Jt,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(c.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(wc,{mode:"recovery",recoveryVariant:P,recoveryHostUrl:ee,recoveryHostLabel:void 0,recoveryHostId:oe,localAvailable:R.localAvailable!==false,onCliAvailable:$})})})})}return C&&!s&&!v?n.jsx(Jt,{children:n.jsx(WT,{onRetry:()=>{re()},isRetrying:B},_)}):n.jsx(Jt,{children:n.jsx(Ox,{sdk:ua.getSdkClient(),directory:f||"",children:n.jsx(Mx,{apis:t,children:n.jsx(zm,{children:n.jsx(Fx,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:b?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[n.jsx(Lx,{backgroundWorkEnabled:true}),n.jsx(Wm,{}),n.jsx(TT,{}),n.jsx(A4,{}),b&&!(J&&W)?n.jsx(Vm,{ready:false}):null,n.jsx($x,{}),n.jsx(Bx,{}),n.jsx(zx,{}),n.jsx(Wx,{}),n.jsx(Vx,{}),n.jsx(Um,{}),n.jsx(BT,{}),p&&n.jsx(zT,{onClose:()=>h(false)})]})})})})},_)})}function UT(t){const e=qe.c(2);let s;return e[0]!==t?(s=n.jsx(Tm,{children:n.jsx(VT,{...t})}),e[0]=t,e[1]=s):s=e[1],s}function HT(t){return t.isAboutDialogOpen}function KT(t){return t.setAboutDialogOpen}function qT(){}function GT(){}function ZT(t){return t.lastInitFailure}const XT=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();hp();pf()&&vT();Hm();Km();gp().then(()=>{Ux().catch(t=>{console.error("[main] settings init failed:",t)}),Hx(),Kx(),qx()}).catch(t=>{console.error("[main] appearance init failed:",t)});const hf=document.getElementById("root");if(!hf)throw new Error("Root element not found");Gx();gf.createRoot(hf).render(n.jsx(Kt.StrictMode,{children:n.jsx(Zx,{children:n.jsx(Xx,{children:n.jsx(Yx,{children:n.jsx(Jx,{children:n.jsx(UT,{apis:XT})})})})})}));const gC=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{dl as P,qj as a,Xj as b,Yj as c,Jj as d,r4 as e,a4 as f,hC as g,Qj as h,e4 as i,t4 as j,s4 as k,E5 as l,gC as m,Gj as o,n4 as p,mC as r,Zj as s,Yw as u};
583
+ ${pe.text}`),re.push({url:ce.url,elements:pe.elements.length})}s=D;const{elements:H,interactiveElementsOnPage:P,elementsTruncated:ee,textTruncated:oe,textTotalChars:de,doc:he,...Z}=le;return delete Z.ok,Object.assign({...Z,text:$,elements:U},W?{textTruncated:true,textTotalChars:J}:null,V>U.length?{elementsTruncated:true,interactiveElementsOnPage:V}:null,re.length>0?{frames:re}:null)},click:b=>x(async()=>{const w=await p(await m(b,true));await i("click",{frameId:w.frameId,x:w.x,y:w.y});const j=h({clicked:true},b.ref,w.selector);return w.label&&(j.label=w.label),j}),hover:b=>x(async()=>{const w=await p(await m(b,true),false);await i("hover",{frameId:w.frameId,x:w.x,y:w.y});const j=h({hovered:true},b.ref,w.selector);return w.label&&(j.label=w.label),j}),drag:b=>x(async()=>{const w=await m(b),j=await f(cs(b.to),cs(b.toSelector),null),R=cs(b.to)??cs(b.toSelector),{draggable:L}=await u(w.frameId,q0(w.target),b2,w.name);if(L){if(w.frameId!==j.frameId)throw new Error("An HTML drag can only drop inside the same frame of the page");const{accepted:U}=await u(w.frameId,G0(w.target,j.target),w2,w.name),V=h({dragged:true,to:R,mode:"html"},b.ref,null);return U||(V.note="The target did not accept the drop: its dragover was not cancelled."),V}const E=await p(j,false),D=await p(w,false);return await i("drag",{from:{frameId:D.frameId,x:D.x,y:D.y},to:{frameId:E.frameId,x:E.x,y:E.y}}),h({dragged:true,to:R??E.selector,mode:"pointer"},b.ref,D.selector)}),type:b=>x(async()=>{const w=await m(b),j=b.value??"",R=await u(w.frameId,H0(w.target),h2,w.name);j?await i("insertText",{text:j}):await i("press",{key:"Delete"}),b.submit&&await i("press",{key:"Enter"});const L=h({typed:true},b.ref,w.frame?null:R.selector??null);try{const E=await u(w.frameId,Z0(w.target),g2,w.name);L.value=E.value,E.valueTruncated&&(L.valueTruncated=true)}catch(E){if(E instanceof hn)throw E}return L}),press:b=>x(async()=>{const w=cs(b.key);if(!w)throw new Error("key is required, such as Enter, Escape, Tab or Meta+a");if(cs(b.ref)||cs(b.selector)){const j=await m(b);await u(j.frameId,K0(j.target),Al,j.name)}return await i("press",{key:w}),{pressed:w}}),select:async b=>{await a();const w=await m(b),j=await d(w.frameId,J0(w.target,{label:b.label,value:b.value}),w.name);return w.frame&&delete j.selector,b.ref&&(j.ref=b.ref),j},scroll:async b=>{if(await a(),cs(b.ref)||cs(b.selector)){const R=await m(b);return d(R.frameId,Q0(R.target),R.name)}const w=cs(b.direction);if(!w)throw new Error("browser.scroll requires direction, ref or selector");const j=await r();return d(j[0].frameId,e2({direction:w}))},inspect:async b=>{await a();const w=await m(b),{bounds:j,selector:R,...L}=await u(w.frameId,n2(w.target),y2,w.name);delete L.ok;const E=w.frame?{bounds:Bl(j,await l(w.frame,(await r())[0].frameId)),frame:w.frame.url}:R?{bounds:j,selector:R}:{bounds:j};return Object.assign({...L,...E},b.ref?{ref:b.ref}:null)},upload:async(b,w)=>{await a();const j=await m(b),{multiple:R}=await u(j.frameId,X0(j.target),x2,j.name);if(w.length>1&&!R)throw new Error("This file input takes one file; pass one path");return await t("setFiles",{frameId:j.frameId,expression:Y0(j.target),files:w}),{uploaded:w.length}},answerDialog:async b=>{if(b.accept===void 0)throw new Error("accept is required: true to accept, false to dismiss");return t("answerDialog",b.value===void 0?{accept:b.accept}:{accept:b.accept,promptText:b.value})},wait:async(b,w,j)=>{await a();const R=cs(b.text),L=b.gone===true,E=Math.min(Fl,Math.max(0,b.timeoutMs??Fl)),D=R?null:await m(b),U=j();for(;;){let V=false;if(D)V=(await u(D.frameId,_l({target:D.target}),Ml)).present;else for(const W of await r())try{if((await u(W.frameId,_l({text:R??""}),Ml)).present){V=true;break}}catch(G){if(G instanceof hn)throw G}const J=j()-U;if(V!==L)return{met:true,waitedMs:J};if(J>=E){const W=R?`the text "${R}"`:D?.name??"it";throw new Error(`Waited ${(J/1e3).toFixed(1)} s, and ${W} ${L?"is still on the page":"did not show up"}.`)}await w(v2)}},ensureNoDialog:a}},k2=t=>{const e=qe.c(18),{entries:s,activeIndex:r,onSelect:o,onForget:a,onHighlight:i}=t,{t:u}=gt();if(s.length===0)return null;let d;e[0]!==u?(d=u("contextPanel.browser.history.label"),e[0]=u,e[1]=d):d=e[1];let l;if(e[2]!==r||e[3]!==s||e[4]!==a||e[5]!==i||e[6]!==o||e[7]!==u){let m;e[9]!==r||e[10]!==a||e[11]!==i||e[12]!==o||e[13]!==u?(m=(p,h)=>n.jsxs("div",{role:"option","aria-selected":h===r,className:Ye("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",h===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:x=>{x.preventDefault(),o(p.url)},onPointerEnter:()=>i(h),children:[n.jsx(ue,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate typography-micro text-foreground",children:p.title||xo(p.url)}),n.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button",className:Ye("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"),onPointerDown:x=>{x.preventDefault(),x.stopPropagation(),a(p.url)},children:n.jsx(ue,{name:"close",className:"size-3","aria-hidden":"true"})})}),n.jsx(Dt,{sideOffset:6,children:u("contextPanel.browser.history.forget")})]})]},p.url),e[9]=r,e[10]=a,e[11]=i,e[12]=o,e[13]=u,e[14]=m):m=e[14],l=s.map(m),e[2]=r,e[3]=s,e[4]=a,e[5]=i,e[6]=o,e[7]=u,e[8]=l}else l=e[8];let f;return e[15]!==d||e[16]!==l?(f=n.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":d,children:l}),e[15]=d,e[16]=l,e[17]=f):f=e[17],f},j2=t=>{const e=/^(https?:\/\/)?([^/?#\s]+)(.*)$/i.exec(t.trim());return e?{host:e[2],rest:e[3]}:null},Ou=t=>{const e=qe.c(189),{address:s,addressMark:r,suggestions:o,onForgetSuggestion:a,onAddressChange:i,onSubmit:u,onBack:d,onForward:l,onReload:f,onOpenExternal:m,canOpenExternal:p,canGoBack:h,canGoForward:x,isLoading:g,onAnnotate:v,onOpenDevTools:y,isAnnotating:C,onHardReload:S,onZoomIn:N,onZoomOut:F,onZoomReset:_,zoomPercent:M,onClearCookies:B,onClearCache:T,onToggleDeviceBar:I,isDeviceBarOpen:b}=t;let w;e[0]!==o?(w=o===void 0?[]:o,e[0]=o,e[1]=w):w=e[1];const j=w,R=p===void 0?true:p,L=M===void 0?100:M,{t:E}=gt(),[D,U]=c.useState(false),[V,J]=c.useState(-1);let W;e[2]!==D||e[3]!==j?(W=D?j:[],e[2]=D,e[3]=j,e[4]=W):W=e[4];const G=W;let le;e[5]===Symbol.for("react.memo_cache_sentinel")?(le=()=>{J(-1)},e[5]=le):le=e[5];let $;e[6]!==s||e[7]!==D?($=[s,D],e[6]=s,e[7]=D,e[8]=$):$=e[8],c.useEffect(le,$);let re;e[9]!==u?(re=Ie=>{U(false),J(-1),u(Ie)},e[9]=u,e[10]=re):re=e[10];const H=re;let P;e[11]!==V||e[12]!==H||e[13]!==G?(P=Ie=>{if(G.length!==0){if(Ie.key==="ArrowDown"||Ie.key==="ArrowUp"){Ie.preventDefault();const Ee=Ie.key==="ArrowDown"?1:-1,Ge=G.length;J(Be=>{const Ze=Be+Ee;return Ze<-1?Ge-1:Ze>=Ge?-1:Ze});return}if(Ie.key==="Escape"&&V>=0){Ie.preventDefault(),J(-1);return}if(Ie.key==="Enter"&&V>=0){Ie.preventDefault();const Ee=G[V];Ee&&H(Ee.url)}}},e[11]=V,e[12]=H,e[13]=G,e[14]=P):P=e[14];const ee=P,oe=K(T2);let de;e[15]!==oe?(de=Ie=>bs(Es(Ie,oe),"")||void 0,e[15]=oe,e[16]=de):de=e[16];const he=de;let Z,ce,ae,te,pe,Te,Ae,Pe,ze,Oe,me,be,Ce,$e,We,_e,Ue,Xe,Me;if(e[17]!==s||e[18]!==r||e[19]!==h||e[20]!==x||e[21]!==R||e[22]!==D||e[23]!==C||e[24]!==b||e[25]!==g||e[26]!==i||e[27]!==ee||e[28]!==v||e[29]!==d||e[30]!==T||e[31]!==B||e[32]!==l||e[33]!==S||e[34]!==y||e[35]!==m||e[36]!==f||e[37]!==I||e[38]!==N||e[39]!==F||e[40]!==he||e[41]!==H||e[42]!==E||e[43]!==G.length||e[44]!==L){ae=D?null:j2(s);let Ie;e[64]!==b||e[65]!==I||e[66]!==E?(Ie=I?{id:"device",icon:"smartphone",label:E("contextPanel.browser.deviceToolbar"),onSelect:I,pressed:b}:null,e[64]=b,e[65]=I,e[66]=E,e[67]=Ie):Ie=e[67];let Ee;e[68]!==C||e[69]!==v||e[70]!==E?(Ee=v?{id:"annotate",icon:"markup",label:E("contextPanel.browser.annotate.toggle"),onSelect:v,pressed:C}:null,e[68]=C,e[69]=v,e[70]=E,e[71]=Ee):Ee=e[71];let Ge;e[72]!==Ie||e[73]!==Ee?(Ge=[Ie,Ee],e[72]=Ie,e[73]=Ee,e[74]=Ge):Ge=e[74],ce=Ge;let Be;e[75]!==E?(Be=E("contextPanel.browser.openExternal"),e[75]=E,e[76]=Be):Be=e[76];const Ze=!R;let et;e[77]!==m||e[78]!==Be||e[79]!==Ze?(et={id:"external",icon:"external-link",label:Be,onSelect:m,disabled:Ze},e[77]=m,e[78]=Be,e[79]=Ze,e[80]=et):et=e[80];let wt;e[81]!==S||e[82]!==E?(wt=S?{id:"hard-reload",icon:"restart",label:E("contextPanel.browser.hardReload"),onSelect:S}:null,e[81]=S,e[82]=E,e[83]=wt):wt=e[83];let Qe;e[84]!==N||e[85]!==he||e[86]!==E?(Qe=N?{id:"zoom-in",icon:"zoom-in",label:E("contextPanel.browser.zoomIn"),onSelect:N,shortcut:he("zoom_in")}:null,e[84]=N,e[85]=he,e[86]=E,e[87]=Qe):Qe=e[87];let dt;e[88]!==F||e[89]!==he||e[90]!==E?(dt=F?{id:"zoom-out",icon:"zoom-out",label:E("contextPanel.browser.zoomOut"),onSelect:F,shortcut:he("zoom_out")}:null,e[88]=F,e[89]=he,e[90]=E,e[91]=dt):dt=e[91];let at;e[92]!==y||e[93]!==E?(at=y?{id:"devtools",icon:"terminal-box",label:E("contextPanel.browser.devTools"),onSelect:y}:null,e[92]=y,e[93]=E,e[94]=at):at=e[94];let z;e[95]!==T||e[96]!==E?(z=T?{id:"clear-cache",icon:"database-2",label:E("contextPanel.browser.clearCache"),onSelect:T}:null,e[95]=T,e[96]=E,e[97]=z):z=e[97];let fe;e[98]!==B||e[99]!==E?(fe=B?{id:"clear-cookies",icon:"delete-bin",label:E("contextPanel.browser.clearCookies"),onSelect:B,destructive:true}:null,e[98]=B,e[99]=E,e[100]=fe):fe=e[100];let ke;e[101]!==et||e[102]!==wt||e[103]!==Qe||e[104]!==dt||e[105]!==at||e[106]!==z||e[107]!==fe?(ke=[et,wt,Qe,dt,at,z,fe],e[101]=et,e[102]=wt,e[103]=Qe,e[104]=dt,e[105]=at,e[106]=z,e[107]=fe,e[108]=ke):ke=e[108],Z=ke,Xe="flex min-w-0 items-center gap-1.5 px-2 py-1.5";let ie;e[109]!==E?(ie=E("contextPanel.browser.back"),e[109]=E,e[110]=ie):ie=e[110];const xe=!h;let Le;e[111]!==d||e[112]!==ie||e[113]!==xe?(Le=n.jsx(qr,{icon:"arrow-left",label:ie,onClick:d,disabled:xe}),e[111]=d,e[112]=ie,e[113]=xe,e[114]=Le):Le=e[114];let Ke;e[115]!==E?(Ke=E("contextPanel.browser.forward"),e[115]=E,e[116]=Ke):Ke=e[116];const ve=!x;let je;e[117]!==l||e[118]!==Ke||e[119]!==ve?(je=n.jsx(qr,{icon:"arrow-right",label:Ke,onClick:l,disabled:ve}),e[117]=l,e[118]=Ke,e[119]=ve,e[120]=je):je=e[120];const vt=g?"close":"refresh";let ne;e[121]!==g||e[122]!==E?(ne=E(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[121]=g,e[122]=E,e[123]=ne):ne=e[123];let Je;e[124]!==f||e[125]!==vt||e[126]!==ne?(Je=n.jsx(qr,{icon:vt,label:ne,onClick:f}),e[124]=f,e[125]=vt,e[126]=ne,e[127]=Je):Je=e[127],e[128]!==Le||e[129]!==je||e[130]!==Je?(Me=n.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[Le,je,Je]}),e[128]=Le,e[129]=je,e[130]=Je,e[131]=Me):Me=e[131],We="relative min-w-0 flex-1",e[132]!==s||e[133]!==H?(_e=kt=>{kt.preventDefault(),H(s)},e[132]=s,e[133]=H,e[134]=_e):_e=e[134],e[135]!==r?(Ue=r?n.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:n.jsx(ue,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[135]=r,e[136]=Ue):Ue=e[136],te=s,e[137]!==i?(pe=kt=>i(kt.target.value),e[137]=i,e[138]=pe):pe=e[138],e[139]===Symbol.for("react.memo_cache_sentinel")?(Te=kt=>{U(true),kt.currentTarget.select()},Ae=()=>U(false),e[139]=Te,e[140]=Ae):(Te=e[139],Ae=e[140]),Pe=ee,ze=false,Oe="off",me="combobox",be=G.length>0,Ce="openchamber-browser-address-suggestions",$e=Ye("oc-raised oc-field h-7 w-full rounded-full bg-[var(--surface-elevated)] px-3.5",r&&"ps-8",L!==100&&"pe-14","typography-meta text-foreground outline-none",ae&&"text-transparent"),e[17]=s,e[18]=r,e[19]=h,e[20]=x,e[21]=R,e[22]=D,e[23]=C,e[24]=b,e[25]=g,e[26]=i,e[27]=ee,e[28]=v,e[29]=d,e[30]=T,e[31]=B,e[32]=l,e[33]=S,e[34]=y,e[35]=m,e[36]=f,e[37]=I,e[38]=N,e[39]=F,e[40]=he,e[41]=H,e[42]=E,e[43]=G.length,e[44]=L,e[45]=Z,e[46]=ce,e[47]=ae,e[48]=te,e[49]=pe,e[50]=Te,e[51]=Ae,e[52]=Pe,e[53]=ze,e[54]=Oe,e[55]=me,e[56]=be,e[57]=Ce,e[58]=$e,e[59]=We,e[60]=_e,e[61]=Ue,e[62]=Xe,e[63]=Me}else Z=e[45],ce=e[46],ae=e[47],te=e[48],pe=e[49],Te=e[50],Ae=e[51],Pe=e[52],ze=e[53],Oe=e[54],me=e[55],be=e[56],Ce=e[57],$e=e[58],We=e[59],_e=e[60],Ue=e[61],Xe=e[62],Me=e[63];let ot;e[141]!==E?(ot=E("contextPanel.browser.addressAria"),e[141]=E,e[142]=ot):ot=e[142];let ye;e[143]!==te||e[144]!==pe||e[145]!==Te||e[146]!==Ae||e[147]!==Pe||e[148]!==ze||e[149]!==Oe||e[150]!==me||e[151]!==be||e[152]!==Ce||e[153]!==$e||e[154]!==ot?(ye=n.jsx("input",{value:te,onChange:pe,onFocus:Te,onBlur:Ae,onKeyDown:Pe,spellCheck:ze,autoComplete:Oe,role:me,"aria-expanded":be,"aria-controls":Ce,className:$e,"aria-label":ot}),e[143]=te,e[144]=pe,e[145]=Te,e[146]=Ae,e[147]=Pe,e[148]=ze,e[149]=Oe,e[150]=me,e[151]=be,e[152]=Ce,e[153]=$e,e[154]=ot,e[155]=ye):ye=e[155];let Ve;e[156]!==r||e[157]!==ae||e[158]!==L?(Ve=ae?n.jsx("span",{"aria-hidden":"true",className:Ye("pointer-events-none absolute inset-y-0 inset-s-0 flex min-w-0 items-center overflow-hidden px-3.5 typography-meta",r&&"ps-8",L!==100?"inset-e-14":"inset-e-0"),children:n.jsxs("span",{className:"truncate",children:[n.jsx("span",{className:"text-foreground",children:ae.host}),n.jsx("span",{className:"text-muted-foreground",children:ae.rest})]})}):null,e[156]=r,e[157]=ae,e[158]=L,e[159]=Ve):Ve=e[159];let lt;e[160]!==_||e[161]!==E||e[162]!==L?(lt=L!==100&&_?n.jsx(es,{label:E("contextPanel.browser.zoomReset"),side:"bottom",className:"absolute inset-e-1 top-1/2 -translate-y-1/2",children:n.jsxs("button",{type:"button",onClick:_,"aria-label":E("contextPanel.browser.zoomReset"),className:"h-4.5 rounded-full bg-[color-mix(in_srgb,var(--foreground)_8%,transparent)] px-1.5 typography-micro tabular-nums text-muted-foreground hover:text-foreground",children:[L,"%"]})}):null,e[160]=_,e[161]=E,e[162]=L,e[163]=lt):lt=e[163];let ct;e[164]!==a?(ct=Ie=>a?.(Ie),e[164]=a,e[165]=ct):ct=e[165];let st;e[166]!==V||e[167]!==H||e[168]!==ct||e[169]!==G?(st=n.jsx("div",{id:"openchamber-browser-address-suggestions",children:n.jsx(k2,{entries:G,activeIndex:V,onSelect:H,onForget:ct,onHighlight:J})}),e[166]=V,e[167]=H,e[168]=ct,e[169]=G,e[170]=st):st=e[170];let k;e[171]!==We||e[172]!==_e||e[173]!==Ue||e[174]!==ye||e[175]!==Ve||e[176]!==lt||e[177]!==st?(k=n.jsxs("form",{className:We,onSubmit:_e,children:[Ue,ye,Ve,lt,st]}),e[171]=We,e[172]=_e,e[173]=Ue,e[174]=ye,e[175]=Ve,e[176]=lt,e[177]=st,e[178]=k):k=e[178];let Y;e[179]!==ce?(Y=[ce],e[179]=ce,e[180]=Y):Y=e[180];let Ne;e[181]!==Z||e[182]!==Y?(Ne=n.jsx(jd,{className:"shrink-0",groups:Y,menuOnly:Z,fold:true}),e[181]=Z,e[182]=Y,e[183]=Ne):Ne=e[183];let Re;return e[184]!==Xe||e[185]!==Me||e[186]!==k||e[187]!==Ne?(Re=n.jsxs("div",{className:Xe,children:[Me,k,Ne]}),e[184]=Xe,e[185]=Me,e[186]=k,e[187]=Ne,e[188]=Re):Re=e[188],Re};function T2(t){return t.shortcutOverrides}const Sr={kind:"fill"},zl=240,C2=3840,Da=[{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}],Wl=t=>Number.isFinite(t)?Math.round(Math.min(C2,Math.max(zl,t))):zl,kr=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Mu=t=>{const e=Da.find(s=>s.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},E2=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},I2=(t,e)=>{const s=kr(t);if(!s)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),a=Math.min(1,r/s.width,o/s.height);return{width:s.width,height:s.height,scale:a}},N2=["mobile","tablet","desktop","fill"],P2={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Vl=t=>typeof t=="string"&&N2.includes(t),_a=t=>t==="fill"?Sr:Mu(P2[t])??Sr,Fr=t=>{const e=kr(t);if(!e)return{mode:"fill",width:null,height:null};for(const s of["mobile","tablet","desktop"]){const r=_a(s),o=kr(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:s,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},Lr="responsive",R2=[{value:"system",icon:"contrast-2"},{value:"light",icon:"sun"},{value:"dark",icon:"moon"}],D2=t=>{const e=qe.c(86),{viewport:s,onViewportChange:r,colorScheme:o,onColorSchemeChange:a,scale:i,panelSize:u}=t,{t:d}=gt();let l;e[0]!==s?(l=kr(s),e[0]=s,e[1]=l):l=e[1];const f=l,m=s.kind==="preset"?s.id:Lr;let p;e[2]!==d?(p=pe=>pe===Lr?d("contextPanel.browser.device.responsive"):Da.find(Te=>Te.id===pe)?.label??pe,e[2]=d,e[3]=p):p=e[3];const h=p;let x;e[4]!==u.width?(x=Math.round(u.width),e[4]=u.width,e[5]=x):x=e[5];let g;e[6]!==u.height?(g=Math.round(u.height),e[6]=u.height,e[7]=g):g=e[7];let v;e[8]!==x||e[9]!==g?(v={width:x,height:g},e[8]=x,e[9]=g,e[10]=v):v=e[10];const y=v;let C;e[11]!==r||e[12]!==y||e[13]!==f?(C=(pe,Te)=>{const Ae=Number.parseInt(Te,10);if(!Number.isFinite(Ae))return;const Pe=f??y;r({kind:"custom",width:Wl(pe==="width"?Ae:Pe.width),height:Wl(pe==="height"?Ae:Pe.height)})},e[11]=r,e[12]=y,e[13]=f,e[14]=C):C=e[14];const S=C;let N;e[15]===Symbol.for("react.memo_cache_sentinel")?(N=Ye("w-11 min-w-0 bg-transparent text-center typography-meta tabular-nums text-foreground outline-none","placeholder:text-muted-foreground"),e[15]=N):N=e[15];const F=N;let _;e[16]!==r?(_=pe=>r(pe===Lr?Sr:Mu(pe)??Sr),e[16]=r,e[17]=_):_=e[17];let M;e[18]!==d?(M=d("contextPanel.browser.device.preset"),e[18]=d,e[19]=M):M=e[19];let B;e[20]!==h?(B=n.jsx(pd,{children:pe=>h(String(pe))}),e[20]=h,e[21]=B):B=e[21];let T;e[22]!==B||e[23]!==M?(T=n.jsx(fd,{className:"min-w-0 max-w-[12rem]","aria-label":M,children:B}),e[22]=B,e[23]=M,e[24]=T):T=e[24];let I;e[25]!==d?(I=d("contextPanel.browser.device.responsive"),e[25]=d,e[26]=I):I=e[26];let b;e[27]!==I?(b=n.jsx(ti,{value:Lr,children:I}),e[27]=I,e[28]=b):b=e[28];let w;e[29]===Symbol.for("react.memo_cache_sentinel")?(w=Da.map(_2),e[29]=w):w=e[29];let j;e[30]!==b?(j=n.jsxs(md,{children:[b,w]}),e[30]=b,e[31]=j):j=e[31];let R;e[32]!==m||e[33]!==T||e[34]!==j||e[35]!==_?(R=n.jsxs(ud,{value:m,onValueChange:_,children:[T,j]}),e[32]=m,e[33]=T,e[34]=j,e[35]=_,e[36]=R):R=e[36];const L=f?String(f.width):"";let E;e[37]!==S?(E=pe=>S("width",pe.target.value),e[37]=S,e[38]=E):E=e[38];const D=y.width>0?String(y.width):"";let U;e[39]!==d?(U=d("contextPanel.browser.device.width"),e[39]=d,e[40]=U):U=e[40];let V;e[41]!==L||e[42]!==E||e[43]!==D||e[44]!==U?(V=n.jsx("input",{value:L,onChange:E,placeholder:D,inputMode:"numeric","aria-label":U,className:F}),e[41]=L,e[42]=E,e[43]=D,e[44]=U,e[45]=V):V=e[45];let J;e[46]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx("span",{className:"typography-meta text-muted-foreground","aria-hidden":"true",children:"\xD7"}),e[46]=J):J=e[46];const W=f?String(f.height):"";let G;e[47]!==S?(G=pe=>S("height",pe.target.value),e[47]=S,e[48]=G):G=e[48];const le=y.height>0?String(y.height):"";let $;e[49]!==d?($=d("contextPanel.browser.device.height"),e[49]=d,e[50]=$):$=e[50];let re;e[51]!==W||e[52]!==G||e[53]!==le||e[54]!==$?(re=n.jsx("input",{value:W,onChange:G,placeholder:le,inputMode:"numeric","aria-label":$,className:F}),e[51]=W,e[52]=G,e[53]=le,e[54]=$,e[55]=re):re=e[55];let H;e[56]!==V||e[57]!==re?(H=n.jsxs("div",{className:"oc-raised oc-field flex h-7 shrink-0 items-center rounded-md bg-[var(--surface-elevated)] px-1",children:[V,J,re]}),e[56]=V,e[57]=re,e[58]=H):H=e[58];let P;e[59]!==d?(P=d("contextPanel.browser.device.rotate"),e[59]=d,e[60]=P):P=e[60];let ee;e[61]!==r||e[62]!==s?(ee=()=>r(E2(s)),e[61]=r,e[62]=s,e[63]=ee):ee=e[63];const oe=!f;let de;e[64]!==P||e[65]!==ee||e[66]!==oe?(de=n.jsx(qr,{icon:"anticlockwise-2",label:P,onClick:ee,disabled:oe}),e[64]=P,e[65]=ee,e[66]=oe,e[67]=de):de=e[67];let he;e[68]!==i||e[69]!==f?(he=f&&i<1?n.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(i*100),"%"]}):null,e[68]=i,e[69]=f,e[70]=he):he=e[70];let Z;e[71]!==d?(Z=d("contextPanel.browser.device.scheme"),e[71]=d,e[72]=Z):Z=e[72];let ce;e[73]!==o||e[74]!==a||e[75]!==d?(ce=R2.map(pe=>{const{value:Te,icon:Ae}=pe,Pe=o===Te;return n.jsx(es,{side:"bottom",label:d(Te==="system"?"contextTooltips.terminalBrowser.device.schemeSystem":Te==="light"?"contextTooltips.terminalBrowser.device.schemeLight":"contextTooltips.terminalBrowser.device.schemeDark"),children:n.jsxs(yt,{type:"button",variant:"ghost",size:"xs","aria-pressed":Pe,onClick:()=>a(Te),className:Ye("h-6 gap-1.5 rounded-md px-2 typography-meta !font-normal",Pe?"oc-raised bg-[var(--surface-background)] text-foreground hover:bg-[var(--surface-background)] dark:bg-[var(--surface-elevated)] dark:hover:bg-[var(--surface-elevated)]":"text-muted-foreground hover:bg-transparent hover:text-foreground"),children:[n.jsx(ue,{name:Ae,className:"size-3.5","aria-hidden":"true"}),d(Te==="system"?"contextPanel.browser.device.schemeSystem":Te==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")]})},Te)}),e[73]=o,e[74]=a,e[75]=d,e[76]=ce):ce=e[76];let ae;e[77]!==Z||e[78]!==ce?(ae=n.jsx("div",{role:"group","aria-label":Z,className:"oc-recessed ms-auto inline-flex h-7 shrink-0 items-center gap-0.5 rounded-lg bg-[color-mix(in_srgb,var(--foreground)_4%,transparent)] p-0.5",children:ce}),e[77]=Z,e[78]=ce,e[79]=ae):ae=e[79];let te;return e[80]!==R||e[81]!==H||e[82]!==de||e[83]!==he||e[84]!==ae?(te=n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 px-2 pb-1.5",children:[R,H,de,he,ae]}),e[80]=R,e[81]=H,e[82]=de,e[83]=he,e[84]=ae,e[85]=te):te=e[85],te};function _2(t){return n.jsx(ti,{value:t.id,children:t.label},t.id)}const uo=new Map,Aa=new Set,Fu=()=>{for(const t of Aa)t()},oa=(t,e)=>{const s=t.trim();s&&(e.length===0?uo.delete(s):uo.set(s,[...e]),Fu())},A2=t=>{uo.delete(t.trim())&&Fu()},Lu=[],O2=t=>uo.get(t.trim())??Lu,M2=t=>(Aa.add(t),()=>{Aa.delete(t)}),F2=t=>{const e=qe.c(2);let s;return e[0]!==t?(s=()=>O2(t),e[0]=t,e[1]=s):s=e[1],c.useSyncExternalStore(M2,s,L2)};function L2(){return Lu}const $u="oc.browser.hiddenDevServerPorts.v1",$2=wr(It(),Cn(as().int().positive())),Oa=new Set,Bu=[];let $r=null;const yi=()=>{const t=Cr().getItem($u);if($r&&$r.raw===t)return $r.value;let e={};if(t!==null)try{const s=$2.safeParse(JSON.parse(t));s.success&&(e=s.data)}catch{e={}}return $r={raw:t,value:e},e},zu=t=>{Cr().setItem($u,JSON.stringify(t));for(const e of Oa)e()},B2=(t=Xt())=>yi()[t]??Bu,z2=t=>{const e=Xt(),s=yi(),r=s[e]??[];r.includes(t)||zu({...s,[e]:[...r,t].sort((o,a)=>o-a)})},W2=()=>{const t=Xt(),e=yi();if(!e[t])return;const s={...e};delete s[t],zu(s)},V2=t=>(Oa.add(t),()=>{Oa.delete(t)}),U2=()=>c.useSyncExternalStore(V2,H2,K2);function H2(){return B2()}function K2(){return Bu}const q2=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},G2=2e3,Z2=t=>Hc("http://localhost",t),Wu=t=>{const e=qe.c(62),{onOpen:s,directory:r,visible:o}=t,a=r===void 0?"":r,{t:i}=gt();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={kind:"loading"},e[0]=u):u=e[0];const[d,l]=c.useState(u),f=F2(a);let m;e[1]!==a?(m=()=>Z2(a),e[1]=a,e[2]=m):m=e[2];const[p]=c.useState(m);let h;e[3]!==a?(h=()=>Vp(a),e[3]=a,e[4]=h):h=e[4];const[x]=c.useState(h);let g;e[5]!==a?(g=Cc(a),e[5]=a,e[6]=g):g=e[6];const v=g,y=wi(a),C=Ef(a);let S,N;e[7]!==a||e[8]!==C||e[9]!==o?(S=()=>{if(C){l({kind:"ready",servers:[]});return}if(!o)return;let H=true,P=null;const ee=new AbortController,oe=()=>{t0(ee.signal,a).then(de=>{H&&(l(de),P=setTimeout(oe,G2))})};return oe(),()=>{H=false,P&&clearTimeout(P),ee.abort()}},N=[a,C,o],e[7]=a,e[8]=C,e[9]=o,e[10]=S,e[11]=N):(S=e[10],N=e[11]),c.useEffect(S,N);const F=Yt(X2),_=it(Y2);let M;if(e[12]!==F||e[13]!==_){const H=F.map(J2);let P;e[15]!==_?(P=[..._].flatMap(Q2),e[15]=_,e[16]=P):P=e[16],M=[...H,...P],e[12]=F,e[13]=_,e[14]=M}else M=e[14];const B=M;let T;e[17]!==f||e[18]!==a||e[19]!==d.kind||e[20]!==d.servers||e[21]!==B?(T=i0({candidates:r0({announced:f,discovered:d.kind==="ready"?d.servers:null}),folders:B,directory:a}),e[17]=f,e[18]=a,e[19]=d.kind,e[20]=d.servers,e[21]=B,e[22]=T):T=e[22];const I=T,b=U2(),[w,j]=c.useState(false);let R;if(e[23]!==I||e[24]!==b||e[25]!==w){let H;e[27]!==b||e[28]!==w?(H=P=>P.announced||!b.includes(P.port)&&(w||!P.outsideWork),e[27]=b,e[28]=w,e[29]=H):H=e[29],R=I.filter(H),e[23]=I,e[24]=b,e[25]=w,e[26]=R}else R=e[26];const L=R,E=I.length-L.length;let D;e[30]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(Zg,{width:110,height:110,className:"shrink-0 opacity-20"}),e[30]=D):D=e[30];let U;e[31]!==i?(U=i("contextPanel.browser.empty"),e[31]=i,e[32]=U):U=e[32];let V;e[33]!==U?(V=n.jsx("span",{className:"typography-ui-header text-foreground",children:U}),e[33]=U,e[34]=V):V=e[34];let J;e[35]!==i?(J=i("contextPanel.browser.emptyHint"),e[35]=i,e[36]=J):J=e[36];let W;e[37]!==J?(W=n.jsx("span",{className:"typography-micro text-muted-foreground",children:J}),e[37]=J,e[38]=W):W=e[38];let G;e[39]!==V||e[40]!==W?(G=n.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[V,W]}),e[39]=V,e[40]=W,e[41]=G):G=e[41];let le;e[42]!==f||e[43]!==I.length||e[44]!==a||e[45]!==E||e[46]!==v||e[47]!==s||e[48]!==p||e[49]!==y||e[50]!==x||e[51]!==i||e[52]!==L?(le=I.length>0?n.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[n.jsx("span",{className:"shrink-0 typography-micro text-start text-muted-foreground",children:f.length>0?i("contextPanel.browser.devServers.justStarted"):i("contextPanel.browser.devServers.title")}),p&&!x?n.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.remoteOnly")}):null,n.jsx(ps,{outerClassName:"min-h-0",className:"flex flex-col gap-1 pe-0.5",disableHorizontal:true,children:L.map(H=>n.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[n.jsxs(yt,{type:"button",variant:"outline",size:"sm",className:Ye("min-w-0 flex-1 justify-start gap-2",p&&"cursor-default opacity-60"),"aria-disabled":p||void 0,onClick:()=>{p||(A2(a),s(H.url))},children:[v?n.jsx("span",{className:"shrink-0",role:"img","aria-label":y??i("contextPanel.browser.spaceAddress"),title:y??i("contextPanel.browser.spaceAddress"),children:n.jsx(ue,{name:"instance",className:"size-3.5","aria-hidden":"true"})}):n.jsx(ue,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsxs("span",{className:"truncate",children:[xo(H.url)||H.url,n.jsx("span",{className:"typography-micro text-muted-foreground",children:q2(H.url)})]}),x?n.jsx("span",{className:"ms-auto shrink-0 text-muted-foreground",role:"img","aria-label":i("contextPanel.browser.devServers.spaceOnlyDesktop"),title:i("contextPanel.browser.devServers.spaceOnlyDesktop"),children:n.jsx(ue,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):H.folderName?n.jsxs("span",{className:"ms-auto flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",title:H.directory,children:[n.jsx(ue,{name:"folder",className:"size-3 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"truncate",dir:"auto",children:H.folderName})]}):null]}),H.announced?null:n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{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:()=>z2(H.port),"aria-label":i("contextPanel.browser.devServers.hide",{port:H.port}),children:n.jsx(ue,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})}),n.jsx(Dt,{sideOffset:6,children:i("contextPanel.browser.devServers.hide",{port:H.port})})]})]},H.port))}),E>0?n.jsx(yt,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:()=>{W2(),j(true)},children:E===1?i("contextPanel.browser.devServers.showHiddenSingle",{count:E}):i("contextPanel.browser.devServers.showHiddenPlural",{count:E})}):null]}):null,e[42]=f,e[43]=I.length,e[44]=a,e[45]=E,e[46]=v,e[47]=s,e[48]=p,e[49]=y,e[50]=x,e[51]=i,e[52]=L,e[53]=le):le=e[53];let $;e[54]!==I.length||e[55]!==d.kind||e[56]!==i?($=I.length===0&&d.kind==="unavailable"?n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.unavailable")}):null,e[54]=I.length,e[55]=d.kind,e[56]=i,e[57]=$):$=e[57];let re;return e[58]!==G||e[59]!==le||e[60]!==$?(re=n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[D,G,le,$]}),e[58]=G,e[59]=le,e[60]=$,e[61]=re):re=e[61],re};function X2(t){return t.projects}function Y2(t){return t.availableWorktreesByProject}function J2(t){return{path:t.path,projectPath:t.path}}function Q2(t){const[e,s]=t;return s.map(r=>({path:r.path,projectPath:e}))}const ek=80,tk=Mt({reasonCode:br("model_download_in_progress")}),sk=t=>{const e=qe.c(37),{channel:s}=t,{t:r}=gt();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Promise.resolve(),e[0]=o):o=e[0];const a=c.useRef(o);let i;e[1]!==s?(i=D=>{a.current=a.current.then(()=>s.send(D)).catch(nk)},e[1]=s,e[2]=i):i=e[2];const u=i;let d;e[3]!==u?(d=D=>u({type:"insert",text:D}),e[3]=u,e[4]=d):d=e[4];let l;e[5]!==r?(l=D=>{tk.safeParse(D).success||Fe.error(r("chat.dictation.failed"),{description:D.message})},e[5]=r,e[6]=l):l=e[6];let f;e[7]!==d||e[8]!==l?(f={onTranscript:d,onError:l},e[7]=d,e[8]=l,e[9]=f):f=e[9];const{status:m,errorReason:p,partialTranscript:h,subscribeLevel:x,startDictation:g,confirmDictation:v,cancelDictation:y,discardFailedDictation:C}=Xg(f);let S,N;e[10]!==y||e[11]!==s||e[12]!==v||e[13]!==g?(S=()=>s.subscribe(D=>{D.action==="start"?g():D.action==="finish"?v():y()}),N=[y,s,v,g],e[10]=y,e[11]=s,e[12]=v,e[13]=g,e[14]=S,e[15]=N):(S=e[14],N=e[15]),c.useEffect(S,N);const F=c.useRef(false);let _,M;e[16]!==C||e[17]!==h||e[18]!==u||e[19]!==m?(_=()=>{if(m!=="failed")return;const D=h.trim();D&&u({type:"insert",text:D}),F.current=true,C()},M=[C,h,u,m],e[16]=C,e[17]=h,e[18]=u,e[19]=m,e[20]=_,e[21]=M):(_=e[20],M=e[21]),c.useEffect(_,M);let B;e[22]!==p||e[23]!==m||e[24]!==r?(B=m==="recording"&&p==="model_download_in_progress"?r("chat.dictation.downloadingModel"):"",e[22]=p,e[23]=m,e[24]=r,e[25]=B):B=e[25];const T=B,I=m==="recording"?"recording":m==="uploading"?"processing":m==="idle"?"idle":null;let b;e[26]===Symbol.for("react.memo_cache_sentinel")?(b={phase:"idle",note:""},e[26]=b):b=e[26];const w=c.useRef(b);let j,R;e[27]!==T||e[28]!==I||e[29]!==u?(j=()=>{if(!I)return;const D=w.current;if(!(D.phase===I&&D.note===T)){if(w.current={phase:I,note:T},I==="idle"){u({type:"voice",phase:I,failed:F.current}),F.current=false;return}u(T?{type:"voice",phase:I,note:T}:{type:"voice",phase:I})}},R=[T,I,u],e[27]=T,e[28]=I,e[29]=u,e[30]=j,e[31]=R):(j=e[30],R=e[31]),c.useEffect(j,R);let L,E;return e[32]!==s||e[33]!==m||e[34]!==x?(L=()=>{if(m!=="recording")return;let D=0,U=false;const V=x(W=>{D=Math.max(D,W)}),J=setInterval(()=>{if(U)return;const W=D;D=0,U=true,s.send({type:"level",level:W}).catch(rk).finally(()=>{U=false})},ek);return()=>{clearInterval(J),V()}},E=[s,m,x],e[32]=s,e[33]=m,e[34]=x,e[35]=L,e[36]=E):(L=e[35],E=e[36]),c.useEffect(L,E),null};function nk(){}function rk(){}const ok=(t,e)=>{const s=Jg(t);if(!s||s.chords.length!==1)return null;const{modifiers:r,key:o}=s.chords[0];if(!/^[a-z0-9]$/.test(o))return null;const a=r.has("mod");return{key:o,meta:e?a:r.has("super"),ctrl:e?r.has("ctrl"):a||r.has("ctrl"),alt:r.has("alt"),shift:r.has("shift")}},ak=()=>{const t=qe.c(22),{t:e}=gt(),s=Ut(ik),r=K(lk),[o]=c.useState(ck);let a;e:{if(!o||!s){a=null;break e}let i;t[0]!==r?(i=ok(Es("toggle_dictation",r),Td()),t[0]=r,t[1]=i):i=t[1];let u;t[2]!==e?(u=e("chat.dictation.start"),t[2]=e,t[3]=u):u=t[3];let d;t[4]!==e?(d=e("chat.dictation.cancel"),t[4]=e,t[5]=d):d=t[5];let l;t[6]!==e?(l=e("chat.dictation.insert"),t[6]=e,t[7]=l):l=t[7];let f;t[8]!==e?(f=e("chat.dictation.listening"),t[8]=e,t[9]=f):f=t[9];let m;t[10]!==e?(m=e("chat.dictation.processing"),t[10]=e,t[11]=m):m=t[11];let p;t[12]!==u||t[13]!==d||t[14]!==l||t[15]!==f||t[16]!==m?(p={start:u,cancel:d,insert:l,listening:f,processing:m},t[12]=u,t[13]=d,t[14]=l,t[15]=f,t[16]=m,t[17]=p):p=t[17];let h;t[18]===Symbol.for("react.memo_cache_sentinel")?(h={mic:Mr.mic,close:Mr.close,check:Mr.check,loader:Mr["loader-4"]},t[18]=h):h=t[18];let x;t[19]!==i||t[20]!==p?(x={shortcut:i,labels:p,icons:h},t[19]=i,t[20]=p,t[21]=x):x=t[21],a=x}return a};function ik(t){return t.dictationEnabled}function lk(t){return t.shortcutOverrides}function ck(){return!zn()&&Yg()}const dk=3e4,uk=3,fk=250,pk={attempts:0,windowStartedAt:null},mk=(t,e)=>{const s=t.windowStartedAt===null||e-t.windowStartedAt>=dk,r=s?0:t.attempts;return r>=uk?null:{delayMs:fk*2**r,state:{attempts:r+1,windowStartedAt:s?e:t.windowStartedAt}}},hk=-3,Br=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",Pn=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},gk=(t,{initialUrl:e,onUrlChange:s})=>{const[r,o]=c.useState(e?{kind:"loading",url:e}:Qg),[a,i]=c.useState(e),[u,d]=c.useState(""),[l,f]=c.useState(false),[m,p]=c.useState(false),h=c.useRef(s);h.current=s;const x=c.useRef(pk);return c.useEffect(()=>{if(!t)return;const g=()=>{try{const I=t.getURL();return Br(I)?I:""}catch{return""}},v=()=>{try{f(t.canGoBack()),p(t.canGoForward())}catch{}},y=I=>{Br(I)&&(i(I),h.current(I))},C=()=>{const I=g();o({kind:"loading",url:I})},S=()=>{const I=g();let b="";try{b=t.getTitle()||""}catch{b=""}d(b),y(I),v(),o(w=>w.kind==="failed"?w:{kind:"ready",url:I,title:b})},N=I=>{const b=Pn(I);Br(b.url)&&(y(b.url),v())},F=I=>{const b=Pn(I),w=Array.isArray(b.favicons)?b.favicons.find(Boolean):"",j=g();if(!w||!j)return;let R=-1;try{R=t.getWebContentsId()}catch{return}!Number.isFinite(R)||R<0||uu.getState().resolve(j,w,R)},_=I=>{const b=Pn(I);typeof b.title=="string"&&d(b.title)},M=I=>{const b=Pn(I);if(b.isMainFrame===false)return;const w=typeof b.errorCode=="number"?b.errorCode:0;w!==hk&&o({kind:"failed",url:Br(b.validatedURL)?b.validatedURL:g(),code:w,description:typeof b.errorDescription=="string"?b.errorDescription:""})};let B=null;const T=()=>{const I=g(),b=mk(x.current,Date.now());if(!b){o({kind:"failed",url:I,code:0,description:"",crashed:true});return}x.current=b.state,o({kind:"loading",url:I}),B=setTimeout(()=>{B=null;try{t.reload()}catch{o({kind:"failed",url:I,code:0,description:"",crashed:true})}},b.delayMs)};t.addEventListener("did-start-loading",C),t.addEventListener("did-stop-loading",S),t.addEventListener("did-navigate",N),t.addEventListener("did-navigate-in-page",N),t.addEventListener("page-title-updated",_),t.addEventListener("page-favicon-updated",F),t.addEventListener("did-fail-load",M),t.addEventListener("render-process-gone",T),t.addEventListener("crashed",T);try{!t.isLoading()&&g()&&S()}catch{}return()=>{B!==null&&clearTimeout(B),t.removeEventListener("render-process-gone",T),t.removeEventListener("crashed",T),t.removeEventListener("did-start-loading",C),t.removeEventListener("did-stop-loading",S),t.removeEventListener("did-navigate",N),t.removeEventListener("did-navigate-in-page",N),t.removeEventListener("page-title-updated",_),t.removeEventListener("page-favicon-updated",F),t.removeEventListener("did-fail-load",M)}},[t]),{status:r,url:a,title:u,canGoBack:l,canGoForward:m}},xk=240,bk=(t,e,s)=>{const r=t??e;return s<=r?r:Math.ceil(s)+xk},Ul=(t,e,s)=>{const r=e!==null&&s!==null?s-e:0;return r>0?t+r:t},wk=90,yk=(t,e,s)=>{const[r,o]=c.useState({width:0,height:0}),a=c.useRef(s);return a.current=s,c.useEffect(()=>{const i=t.current;if(!i||!globalThis.ResizeObserver)return;let u=null,d=0,l=null;const f=()=>{const S=i.closest("[data-context-panel]");if(!S||S.dataset.contextZone==="bottom")return null;const N=Number(S.dataset.zoneSize);return N>0?N:null};let m=f(),p=false,h=null;const x=()=>{h=null;const S=e.current;!S||a.current||!u||(l=u.width,S.style.width=`${l}px`)},g=()=>{if(p=false,h!==null&&clearTimeout(h),h=null,l!==null&&(l=null,e.current&&!a.current&&(e.current.style.width="100%")),m=f(),!u)return;const S=u;d=S.width,o(N=>N.width===S.width&&N.height===S.height?N:S)},v=new ResizeObserver(S=>{const N=S[0]?.contentRect;if(!N)return;u={width:N.width,height:N.height},d===0&&(d=N.width);const F=e.current;if(p)h!==null&&clearTimeout(h),h=setTimeout(x,wk);else if(e1()&&F&&!a.current){const _=Ul(d,m,f()),M=bk(Math.max(l??d,_),d,N.width);M!==l&&(l=M,F.style.width=`${M}px`)}hr(g)});v.observe(i);const y=t1(()=>{const S=e.current;!S||a.current||d===0||l!==null||(l=Ul(d,m,f()),S.style.width=`${l}px`,hr(g))}),C=s1(()=>{p=true});return()=>{y(),C(),h!==null&&clearTimeout(h),v.disconnect(),ai(g)}},[e,t]),r},Hl=1e3,Vu=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:true,visibilityProperty:true})},vk=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},Ma=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},Sk=(t,e)=>{const s=c.useRef(0),r=c.useRef(0),o=c.useRef(0),a=c.useRef(null),i=c.useCallback(()=>{if(!t||document.activeElement!==t)return;const u=a.current;u&&u.isConnected&&u!==document.body?u.focus({preventScroll:true}):t.blur()},[t]);return c.useEffect(()=>{if(!t)return;document.activeElement!==t&&(a.current=Ma());const u=()=>{if(document.activeElement!==t)return;const f=e.current,m=s.current>r.current||Date.now()<o.current;f&&Vu(f)&&!m||r.current>0||i()},d=f=>{if(document.activeElement!==t){a.current=vk(f);return}u()},l=f=>{f.target===window&&setTimeout(u,0)};return document.addEventListener("focusin",d,true),window.addEventListener("blur",l,true),()=>{document.removeEventListener("focusin",d,true),window.removeEventListener("blur",l,true)}},[i,e,t]),c.useCallback(async u=>{const d=t!==null&&document.activeElement===t;let l=false;const f=()=>{l&&(l=false,r.current-=1,o.current=Date.now()+Hl,!d&&r.current===0&&i())},m=()=>(l||(l=true,r.current+=1),f);s.current+=1;try{return await u(m)}finally{s.current-=1,o.current=Date.now()+Hl,f(),!d&&r.current===0&&i()}},[i,t])},kk=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),jk=()=>document.visibilityState==="visible",Tk=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,zr=.5,Ck=-3,Ek=4,Ik="persist:openchamber-browser",Uu=(t,e,s)=>ks(t)!==null&&Ic(e)?{icon:"instance",label:s}:void 0,Nk="persist:openchamber-browser-agent",Pk=(t,e=false)=>{const s=ks(t);return s?`openchamber-space-preview:${s}`:e?Nk:Ik},Kl="openchamber:browser-panel-open-tab",Rk=Mt({webContentsId:as(),url:It().min(1),background:ss()}),ql=20,Dk=600,_k=2e4,Gl=15e3,Zl=500,Xl=5e3,Ak=3e4,Ok=3e3,Mk=12e3,Yl=1e3,Fk=250,Lk=Mt({quiet:ss()}),$k=Cn(Mt({answer:It()}).catchall(an())),Bk=wr(It(),an()),zk=Mt({value:an().nullable()}),Wk=Mt({ended:ss().optional(),message:It().nullable().optional()}),Vk=Mt({type:br("voice"),action:Qd(["start","finish","cancel"])}),Jl=()=>new Promise(t=>{let e=0,s=0,r=0,o;const a=l=>{clearTimeout(o),t(l)},i=()=>{e+=1,e>=2?a(true):requestAnimationFrame(i)},u=()=>{s=e,r=performance.now()+Yl,o=setTimeout(d,Yl)},d=()=>{e>s||performance.now()-r>Fk?u():a(false)};requestAnimationFrame(i),u()}),Ql=(t,e)=>{if(!t||Vu(t))return()=>{};const s=t.getBoundingClientRect(),r=t.style.cssText;return Object.assign(t.style,{position:"fixed",top:`${s.top}px`,left:`${Math.max(0,Math.min(s.left,window.innerWidth-s.width))}px`,width:`${s.width}px`,height:`${s.height}px`,visibility:"visible",opacity:"0",...e==="input"?{pointerEvents:"auto",zIndex:"-1"}:{pointerEvents:"none"}}),()=>{t.style.cssText=r}},Uk=({initialUrl:t,directory:e,siteDirectory:s,tabID:r,ownerSessionId:o,visible:a})=>{const{t:i}=gt(),{currentTheme:u}=bo(),d=c.useRef(null),[l,f]=c.useState(null),m=c.useCallback(q=>{d.current=q,f(q)},[]),p=K(q=>q.setContextPanelTabTargetPath),h=K(q=>q.agentBrowserSharesLogins),x=Pk(s,o!==null&&!h),g=c.useRef(Rn(t)),v=g.current!==nn?g.current:"",[y,C]=c.useState(v?null:nn),S=wi(s),[N,F]=c.useState(v),[_,M]=c.useState(false),[B,T]=c.useState(false),[I,b]=c.useState(0),w=c.useRef(0),[j,R]=c.useState(false),[L,E]=c.useState(Sr),D=c.useRef(L);D.current=L;const U=c.useRef([]),[V,J]=c.useState("system"),W=c.useRef(null),G=c.useRef(null),le=ds(e),$=c.useRef(!!v&&!If(le,r)),re=c.useRef(null);c.useEffect(()=>{Ec(le,r)},[le,r]);const H=c.useRef(false),P=c.useRef(Date.now()),ee=c.useCallback(q=>{!q||q===nn||!e||!r||p(e,r,q)},[e,r,p]),oe=gk(l,{initialUrl:v,onUrlChange:c.useCallback(q=>{const se=Js(q);F(se),ee(se)},[ee])}),[de,he]=c.useState(null),[Z,ce]=c.useState(ks(s)===null);c.useEffect(()=>{const q=ks(s);if(q===null){ce(true);return}let se=true;return ce(false),en("desktop_space_preview_prepare",{spaceId:q}).then(()=>{se&&ce(true)}).catch(()=>{se&&he(v||"http://localhost/")}),()=>{se=false}},[s,v]);const ae=n1(e),te=r1(),pe=ak(),Te=oe.status.kind==="loading",Ae=_n(Iu(s)),Pe=_n(q=>q.recordVisit),ze=_n(q=>q.forget);c.useEffect(()=>{oe.status.kind==="ready"&&Pe(s,{url:Js(oe.status.url),title:oe.status.title})},[s,oe.status,Pe]);const Oe=c.useMemo(()=>Eu(Ae,N),[Ae,N]),me=c.useCallback(q=>{const se=Rn(q);se!==nn&&($.current=false,F(se),he(null),Oi(se,s).then(De=>{const we=d.current;if(!we){C(De);return}try{we.loadURL(De)}catch{C(De)}}).catch(De=>{De instanceof Mi&&he(se)}))},[s]);c.useEffect(()=>{if(!v)return;let q=true;return Oi(v,s).then(se=>{q&&C(se)}).catch(se=>{if(q){if(se instanceof Mi){he(v),$.current=false,C(nn);return}C(v)}}),()=>{q=false}},[]);const be=c.useRef(false);c.useEffect(()=>{if(!l)return;const q=()=>{be.current=true};return l.addEventListener("dom-ready",q),l.addEventListener("did-fail-load",q),()=>{l.removeEventListener("dom-ready",q),l.removeEventListener("did-fail-load",q)}},[l]);const Ce=c.useCallback(async()=>{const q=Date.now()+Gl;for(;!(d.current&&be.current)&&Date.now()<q;)await new Promise(se=>setTimeout(se,100));return d.current},[]),$e=c.useCallback(async(q=8e3)=>{const se=Date.now();for(;;){const De=d.current;if(!De)return false;let we=false;try{we=De.isLoading()}catch{return false}if(!we)return true;if(Date.now()-se>q)return false;await new Promise(rt=>setTimeout(rt,120))}},[]),We=c.useCallback(async(q,se)=>{const De=t2({quietMs:Zl,maxMs:se});let we;const rt=new Promise(ft=>{we=setTimeout(()=>ft(null),se+1e3)});try{const ft=Lk.safeParse(await Promise.race([q.executeJavaScript(De,false),rt]));return ft.success&&ft.data.quiet}catch{return false}finally{clearTimeout(we)}},[]),_e=c.useCallback(async(q,se=Ak)=>{const De=Date.now(),we=await $e(Math.min(25e3,Math.max(0,se-Xl))),rt=se-(Date.now()-De),ft=we&&rt>Zl&&await We(q,Math.min(Xl,rt));let nt="";try{nt=q.getTitle()||""}catch{nt=""}return{title:nt,settled:ft}},[$e,We]),Ue=c.useCallback(async(q,se={})=>{const De=d.current;if(!De)throw new Error("The browser panel is not ready");try{return await en("desktop_browser_drive",{...se,webContentsId:De.getWebContentsId(),op:q})}catch(we){const rt=(we instanceof Error?we.message:String(we)).replace(/^Error invoking remote method '[^']*': (?:Error: )?/,"");throw rt.includes("Unknown desktop command")?new Error("This OpenChamber desktop app is older than its server and cannot run this browser action. Update the desktop app."):new Error(rt)}},[]),Xe=c.useCallback(async q=>{const se=Ql(W.current,"input");let De;try{if(!await Jl())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 the page takes no input. browser.snapshot still reads the page.");const we=new Promise((ut,Nt)=>{De=setTimeout(()=>Nt(new Error("The page did not take the input in time. Take a snapshot to see its state.")),Mk)}),rt=d.current&&document.activeElement!==d.current?Ma():null;let ft=false;const nt=ut=>{ut.isTrusted&&(ft=true)};document.addEventListener("pointerdown",nt,true),document.addEventListener("keydown",nt,true);try{return await Promise.race([q(),we])}finally{document.removeEventListener("pointerdown",nt,true),document.removeEventListener("keydown",nt,true),!ft&&rt?.isConnected&&rt!==document.body&&Ma()!==rt&&document.activeElement!==d.current&&rt.focus({preventScroll:true})}}finally{clearTimeout(De),se()}},[]),Me=c.useMemo(()=>S2({drive:Ue,withInput:Xe}),[Ue,Xe]),ot=c.useCallback(async(q,se)=>zk.parse(await Ue("annotate",{expression:q,sessionId:se})).value,[Ue]),ye=c.useMemo(()=>({executeJavaScript:async(q,se)=>{const De=d.current;if(!De)throw new Error("Browser view is not available");return De.executeJavaScript(q,se)},capturePage:async()=>{const q=d.current;if(!q)return null;const se=q.getWebContentsId();return Number.isFinite(se)?await en("desktop_browser_capture_page",{webContentsId:se}):null}}),[]),[Ve,lt]=c.useState(null),ct=c.useCallback(async(q,se)=>{for(;!se.done;){let De;try{De=Wk.parse(await Ue("annotationMessage",{sessionId:se.id,timeoutMs:2e4}))}catch{return}if(De.ended){await new Promise(rt=>setTimeout(rt,150));continue}if(!De.message)continue;let we=null;try{we=Vk.parse(JSON.parse(De.message))}catch{continue}for(const rt of[...q])rt(we)}},[Ue]),st=c.useRef(null),k=c.useRef(0),Y=c.useCallback(()=>{const q=st.current;st.current=null,M(false),lt(null),q&&(q.cancelled=true,Ue("annotationCancel",{sessionId:q.id}).catch(()=>{})),Ki(ye)},[ye,Ue]),Ne=c.useCallback(()=>{if(_){Y();return}if(!oe.url){Fe.error(i("contextPanel.browser.annotate.noPage"));return}const q=o1(u.metadata.variant==="light"?"light":"dark");k.current+=1;const se={id:k.current,done:false,cancelled:false};st.current=se;const De=()=>st.current===se;M(true);const we=new Set;pe&&lt({send:async ft=>{await Ue("annotationSend",{message:ft})},subscribe:ft=>(we.add(ft),()=>{we.delete(ft)})});const rt={...ye,runIsolated:async ft=>{pe&&ct(we,se);try{return await ot(ft,se.id)}catch(nt){if(se.done=true,se.cancelled)return null;throw De()&&lt(null),nt}}};a1({host:rt,theme:q,labels:te,voice:pe}).finally(()=>{se.done=true,De()&&(st.current=null,lt(null),M(false))}).then(async ft=>{!ft||se.cancelled||await ae(ft)}).catch(()=>{se.cancelled||Fe.error(i("contextPanel.browser.annotate.failed"))})},[ye,pe,ae,Y,u,Ue,_,ct,oe.url,te,ot,i]);c.useEffect(()=>{if(!_)return;const q=se=>{rd(se)||se.key!=="Escape"||(se.preventDefault(),se.stopImmediatePropagation(),Y())};return window.addEventListener("keydown",q,true),()=>window.removeEventListener("keydown",q,true)},[Y,_]);const Re=c.useCallback(q=>a2(q,se=>en("desktop_browser_stage_upload",{files:se}).then(De=>De.paths)),[]),Ie=c.useCallback(async(q,se,De)=>{const we=await Ce();if(!we)throw new Error("The browser panel is not ready");const rt=()=>{Vl(se.viewport)&&(E(_a(se.viewport)),R(true))};if(q==="browser.back"||q==="browser.forward"){const Et=q==="browser.back";if(!(Et?we.canGoBack():we.canGoForward()))throw new Error(Et?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Et?we.goBack():we.goForward(),await new Promise(is=>setTimeout(is,150)),await $e();let Wt="";try{Wt=we.getTitle()||""}catch{Wt=""}return{url:Js(we.getURL()),title:Wt}}if(q==="browser.capture"){const Et=Ql(W.current,"capture");try{if(!await Jl())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(we,Ok);const Ft=await ye.capturePage();if(!Ft)throw new Error("The page could not be captured");let Wt="";try{Wt=we.getTitle()||""}catch{Wt=""}return{...Ft,url:Js(we.getURL()),title:Wt,viewport:Fr(D.current)}}finally{Et()}}if(q==="browser.resize"){if(!Vl(se.viewport))throw new Error("viewport is required");return rt(),await new Promise(Et=>setTimeout(Et,200)),await $e(),{viewport:Fr(_a(se.viewport))}}if(q==="browser.open"){const Et=typeof se.url=="string"?se.url:"";if(!Et)throw new Error("url is required");return rt(),me(Et),await new Promise(Ft=>setTimeout(Ft,150)),{url:Rn(Et),...await _e(we),opened:true,viewport:Fr(D.current)}}if(q==="browser.settle"){const Et=as().safeParse(se.budgetMs);return _e(we,Et.success?Et.data:void 0)}await $e();const ft=i2.parse(se);if(q==="browser.dialog")return Me.answerDialog(ft);q!=="browser.snapshot"&&await Me.ensureNoDialog();const nt=["browser.click","browser.type","browser.press","browser.hover","browser.drag"].includes(q);let ut=()=>{};nt&&(await en("desktop_browser_keep_page_focused",{webContentsId:we.getWebContentsId()}).then(Ft=>Ft.focused===true).catch(()=>false)||(ut=De(),we.focus({preventScroll:true})));let Nt;try{switch(q){case"browser.snapshot":{const Et=U.current,Ft=await Me.snapshot(ft);return Ft.viewport=Fr(D.current),Et.length>0&&(Ft.consoleProblems=[...Et]),Ft}case"browser.click":Nt=await Me.click(ft);break;case"browser.hover":Nt=await Me.hover(ft);break;case"browser.drag":Nt=await Me.drag(ft);break;case"browser.type":Nt=await Me.type(ft);break;case"browser.press":Nt=await Me.press(ft);break;case"browser.select":Nt=await Me.select(ft);break;case"browser.scroll":return Me.scroll(ft);case"browser.inspect":return Me.inspect(ft);case"browser.upload":{if(!ft.upload)throw new Error("The upload came without its files");return Me.upload(ft,await Re(ft.upload))}case"browser.wait":return Me.wait(ft,Et=>new Promise(Ft=>setTimeout(Ft,Et)),()=>Date.now());default:throw new Error(`Unsupported browser action: ${q}`)}}finally{ut()}return await new Promise(Et=>setTimeout(Et,150)),await $e(),{url:Js(we.getURL()),...Nt}},[ye,me,Me,_e,Re,$e,We,Ce]);c.useEffect(()=>{if(!l||o===null)return;const q=()=>{Ue("dialogPolicy",{auto:true}).catch(()=>{})};return l.addEventListener("did-attach",q),l.addEventListener("did-start-loading",q),l.addEventListener("dom-ready",q),()=>{l.removeEventListener("did-attach",q),l.removeEventListener("did-start-loading",q),l.removeEventListener("dom-ready",q)}},[Ue,o,l]);const Ee=Sk(l,W),[Ge,Be]=c.useState(false),Ze=c.useCallback(async(q,se,De)=>{if(o===null)return De();if(q==="browser.dialog")throw new Error('This tab answers its dialogs as they open, no by default. To answer yes, repeat the action that opened it with dialog: "accept".');const we=Date.now()+Gl;for(;;)try{await Ue("dialogPolicy",{auto:true});break}catch(Nt){if(Date.now()>we)throw Nt;await new Promise(Et=>setTimeout(Et,100))}await Ue("armDialog",{accept:se});let rt;try{rt=await De()}finally{await Ue("armDialog",{accept:false}).catch(()=>null)}const ft=$k.safeParse(await Ue("takeAnsweredDialogs").catch(()=>[])),nt=Bk.safeParse(rt);if(!ft.success||ft.data.length===0||!nt.success)return rt;const ut={...nt.data,dialogs:ft.data};return ft.data.some(Nt=>Nt.answer==="dismissed")&&(ut.note='The page showed a dialog and it was answered no. To answer yes, repeat the action with dialog: "accept".'),ut},[Ue,o]),et=c.useRef(Promise.resolve()),wt=c.useCallback((q,se)=>{Be(true);const De=et.current.catch(()=>{}).then(()=>Ee(we=>Ze(q,se.dialog==="accept",()=>Ie(q,se,we))));return et.current=De,De},[Ze,Ee,Ie]),Qe=c.useCallback(()=>{const q=d.current;if(!q)return{title:"",url:""};let se="",De="";try{se=q.getTitle()||""}catch{se=""}try{De=Js(q.getURL())}catch{De=""}return{title:se,url:De}},[]);c.useEffect(()=>S0({tabId:r,directory:le,ownerSessionId:o,describe:Qe,run:wt}),[Qe,o,wt,le,r]),c.useEffect(()=>{const q=ye;return()=>{Ki(q)}},[ye]),c.useEffect(()=>{if(!l)return;const q=De=>{const we=De;if(typeof we.level!="number"||we.level<2)return;const rt=we.sourceId?`${we.sourceId}${we.line?`:${we.line}`:""}`:"";U.current.push({level:we.level>=3?"error":"warning",message:String(we.message??"").slice(0,400),source:rt}),U.current.length>ql&&U.current.splice(0,U.current.length-ql)},se=()=>{U.current=[]};return l.addEventListener("console-message",q),l.addEventListener("did-start-loading",se),()=>{l.removeEventListener("console-message",q),l.removeEventListener("did-start-loading",se)}},[l]);const dt=c.useRef(new Set),at=c.useCallback(q=>{dt.current.clear(),me(q)},[me]),z=c.useRef(oe.status);z.current=oe.status;const fe=c.useRef(false);oe.status.kind==="ready"&&oe.status.url&&(fe.current=true),c.useEffect(()=>Nf(le,r,q=>{Df(z.current,fe.current)&&at(q)}),[at,le,r]),c.useEffect(()=>{if(!l)return;const q=De=>{const we=Pn(De),rt=typeof we.url=="string"?we.url:"";!rt||!Fi(rt,s)||(De.preventDefault(),me(rt))},se=De=>{const we=Pn(De);if(we.isMainFrame===false||we.errorCode===-3)return;const rt=typeof we.validatedURL=="string"?we.validatedURL:"";!rt||!Fi(rt,s)||dt.current.has(rt)||(dt.current.add(rt),me(rt))};return l.addEventListener("will-navigate",q),l.addEventListener("did-fail-load",se),()=>{l.removeEventListener("will-navigate",q),l.removeEventListener("did-fail-load",se)}},[s,me,l]),c.useEffect(()=>{if(!l)return;const q=se=>{if(!(se instanceof CustomEvent))return;const De=Rk.safeParse(se.detail);if(!De.success)return;let we=-1;try{we=l.getWebContentsId()}catch{return}if(De.data.webContentsId===we){if(o!==null){C0(De.data.url,{directory:le,sessionId:o});return}K.getState().openContextBrowser(le,De.data.url,{reveal:!De.data.background})}};return window.addEventListener(Kl,q),()=>window.removeEventListener(Kl,q)},[o,le,l]);const ke=c.useCallback(q=>{const se=Math.min(Ek,Math.max(Ck,q));w.current=se,b(se);try{d.current?.setZoomLevel(se)}catch{}},[]);c.useEffect(()=>{const q=se=>{if(!(se instanceof CustomEvent))return;const De=se.detail,we=d.current;!we||document.activeElement!==we||(De==="zoom-in"?ke(w.current+zr):De==="zoom-out"?ke(w.current-zr):De==="zoom-reset"&&ke(0))};return window.addEventListener("openchamber:zoom",q),()=>window.removeEventListener("openchamber:zoom",q)},[ke]);const ie=c.useCallback(q=>{en("desktop_browser_clear_data",{partition:x,cookies:q==="cookies",cache:q==="cache"}).then(()=>{Fe.success(i(q==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{d.current?.reloadIgnoringCache()}catch{}}).catch(()=>Fe.error(i("contextPanel.browser.clearFailed")))},[x,i]),xe=c.useCallback(q=>{J(q);const se=d.current;if(!se)return;let De=-1;try{De=se.getWebContentsId()}catch{return}en("desktop_browser_set_color_scheme",{webContentsId:De,scheme:q}).catch(we=>{J("system"),Fe.error(we instanceof Error?we.message:i("contextPanel.browser.device.schemeFailed"))})},[i]),Le=c.useCallback(()=>{try{Te?d.current?.stop():d.current?.reload()}catch{}},[Te]),Ke=oe.status,ve=c.useSyncExternalStore(kk,jk),je=a&&ve||o!==null||Ge,vt=Js(i1(Ke)),ne=Ct(q=>Pf(q.sessions,vt)),Je=c.useRef(false),kt=c.useRef(null);c.useEffect(()=>{const q=ft=>{T(true);const nt=setTimeout(()=>{try{d.current?.reload()}catch{}},ft);return()=>clearTimeout(nt)};if(Je.current&&!ne&&(kt.current=Date.now()),Je.current=ne,Ke.kind==="loading")return;const se=$.current||re.current===Ke;if($.current&&(Ke.kind==="failed"||Ke.kind==="ready"&&Ke.url)&&($.current=false,re.current=Ke),Ke.kind==="failed"){const ft=Rf(Ke,{run:G.current,restored:se,watched:je,now:Date.now(),actionRunning:ne,actionStoppedAt:kt.current});if(G.current=ft.run,ft.next==="retry")return q(ft.delayMs);T(ft.next==="pause");return}if(G.current=null,Ke.kind!=="ready"||!Ke.url||!Ic(Ke.url)){H.current=true,T(false);return}if(se||H.current||Date.now()-P.current>_k){H.current=true,T(false);return}let De=false,we=null;return(ks(s)?Promise.resolve(null):s0(Js(Ke.url))).then(ft=>{if(!De){if(ft===null||ft<500){H.current=true,T(false);return}we=q(Dk)}}),()=>{De=true,we?.()}},[ne,s,Ke,je]);const bt=oe.status.kind==="failed"&&!B?oe.status:null,_t=yk(W,d,kr(L)!==null),He=I2(L,_t),pt=q=>{if(!(!(Td()?q.metaKey&&!q.ctrlKey:q.ctrlKey&&!q.metaKey)||q.altKey||q.repeat||q.key.toLowerCase()!=="r")){q.preventDefault();try{q.shiftKey?d.current?.reloadIgnoringCache():d.current?.reload()}catch{}}};return n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",onKeyDown:pt,children:[Ve?n.jsx(sk,{channel:Ve}):null,n.jsx(Ou,{address:N,onAddressChange:F,onSubmit:at,suggestions:Oe,onForgetSuggestion:q=>ze(s,q),onBack:()=>{try{d.current?.goBack()}catch{}},onForward:()=>{try{d.current?.goForward()}catch{}},onReload:Le,onOpenExternal:()=>{Wn(oe.url||N)},addressMark:Uu(s,N,S??i("contextPanel.browser.spaceAddress")),canOpenExternal:ks(s)===null,canGoBack:oe.canGoBack,canGoForward:oe.canGoForward,isLoading:Te,onAnnotate:Ne,isAnnotating:_,onOpenDevTools:()=>{try{d.current?.openDevTools()}catch{}},onHardReload:()=>{try{d.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>ke(I+zr),onZoomOut:()=>ke(I-zr),onZoomReset:()=>ke(0),zoomPercent:Math.round(Math.pow(1.2,I)*100),onClearCookies:()=>ie("cookies"),onClearCache:()=>ie("cache"),onToggleDeviceBar:()=>R(q=>!q),isDeviceBarOpen:j}),j?n.jsx(D2,{viewport:L,onViewportChange:E,colorScheme:V,onColorSchemeChange:xe,scale:He?.scale??1,panelSize:_t}):null,n.jsxs("div",{ref:W,className:Ye("relative min-h-0 flex-1 overflow-hidden bg-background",He&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[y!==null&&Z?n.jsx("webview",{ref:m,src:y,partition:x,allowpopups:"true",webpreferences:o!==null?"backgroundThrottling=no":void 0,style:He?{width:`${He.width}px`,height:`${He.height}px`,transform:`scale(${He.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,y!==null&&!v&&!oe.url&&!Te?n.jsx(Wu,{onOpen:at,directory:s,visible:a}):null,B?n.jsxs("div",{role:"status",className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx(dd,{className:"mb-1 size-5 text-muted-foreground","aria-hidden":true}),n.jsx("span",{className:"typography-ui-header text-foreground",children:i("contextPanel.browser.waitingForServer")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.waitingForServerHint")})]}):null,de?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[ks(s)!==null?n.jsx(ue,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:i("contextPanel.browser.tunnelFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i(ks(s)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:de})})]}):null,bt&&!de?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:bt.crashed?i("contextPanel.browser.crashed"):i("contextPanel.browser.loadFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:bt.crashed?i("contextPanel.browser.crashedHint"):bt.description||i("contextPanel.browser.loadFailedUnknown")})]}):null,Te?n.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:n.jsx("div",{className:"h-full w-1/3 bg-[var(--primary)]"})}):null]})]})},Hk=t=>{const e=qe.c(75),{initialUrl:s,directory:r,siteDirectory:o,tabID:a,visible:i}=t,{t:u}=gt(),d=K(qk);let l;e[0]!==s?(l=Rn(s),e[0]=s,e[1]=l):l=e[1];const f=l,m=f!==nn?f:"",[p,h]=c.useState(m);let x;e[2]!==o||e[3]!==m?(x=zo(m,o),e[2]=o,e[3]=m,e[4]=x):x=e[4];const[g,v]=c.useState(x);let y;e[5]!==o||e[6]!==m?(y=Hc(m,o)?m:"",e[5]=o,e[6]=m,e[7]=y):y=e[7];const[C,S]=c.useState(y);let N;e[8]!==o?(N=ks(o),e[8]=o,e[9]=N):N=e[9];const F=N!==null,_=wi(o);let M;e[10]!==m?(M=m?[m]:[],e[10]=m,e[11]=M):M=e[11];const[B,T]=c.useState(M),[I,b]=c.useState(m?0:-1),[w,j]=c.useReducer(Gk,0);let R,L;e[12]!==a||e[13]!==r?(R=()=>{Ec(ds(r),a)},L=[r,a],e[12]=a,e[13]=r,e[14]=R,e[15]=L):(R=e[14],L=e[15]),c.useEffect(R,L);let E;e[16]!==d||e[17]!==a||e[18]!==r?(E=ze=>{!ze||ze===nn||!r||!a||d(r,a,ze)},e[16]=d,e[17]=a,e[18]=r,e[19]=E):E=e[19];const D=E;let U;e[20]!==o?(U=Iu(o),e[20]=o,e[21]=U):U=e[21];const V=_n(U),J=_n(Zk),W=_n(Xk);let G;e[22]!==p||e[23]!==V?(G=Eu(V,p),e[22]=p,e[23]=V,e[24]=G):G=e[24];const le=G;let $;e[25]!==o||e[26]!==I||e[27]!==D||e[28]!==J?($=ze=>{const Oe=Rn(ze);if(Oe===nn)return;h(Oe);const me=zo(Oe,o);v(me),S(me?"":Oe),D(Oe),J(o,{url:Oe}),T(be=>{const Ce=I>=0?be.slice(0,I+1):[];return Ce[Ce.length-1]===Oe?(b(Ce.length-1),Ce):(b(Ce.length),[...Ce,Oe])})},e[25]=o,e[26]=I,e[27]=D,e[28]=J,e[29]=$):$=e[29];const re=$;let H;e[30]!==o||e[31]!==B||e[32]!==D?(H=ze=>{const Oe=B[ze];if(!Oe)return;b(ze),h(Oe);const me=zo(Oe,o);v(me),S(me?"":Oe),D(Oe)},e[30]=o,e[31]=B,e[32]=D,e[33]=H):H=e[33];const P=H;let ee;e[34]!==o||e[35]!==W?(ee=ze=>W(o,ze),e[34]=o,e[35]=W,e[36]=ee):ee=e[36];let oe,de;e[37]!==P||e[38]!==I?(oe=()=>P(I-1),de=()=>P(I+1),e[37]=P,e[38]=I,e[39]=oe,e[40]=de):(oe=e[39],de=e[40]);let he;e[41]!==p||e[42]!==g?(he=()=>{Wn(g||p)},e[41]=p,e[42]=g,e[43]=he):he=e[43];let Z;e[44]!==_||e[45]!==u?(Z=_??u("contextPanel.browser.spaceAddress"),e[44]=_,e[45]=u,e[46]=Z):Z=e[46];let ce;e[47]!==p||e[48]!==o||e[49]!==Z?(ce=Uu(o,p,Z),e[47]=p,e[48]=o,e[49]=Z,e[50]=ce):ce=e[50];const ae=!C,te=I>0,pe=I>=0&&I<B.length-1;let Te;e[51]!==p||e[52]!==re||e[53]!==le||e[54]!==ee||e[55]!==oe||e[56]!==de||e[57]!==he||e[58]!==ce||e[59]!==ae||e[60]!==te||e[61]!==pe?(Te=n.jsx(Ou,{address:p,onAddressChange:h,onSubmit:re,suggestions:le,onForgetSuggestion:ee,onBack:oe,onForward:de,onReload:j,onOpenExternal:he,addressMark:ce,canOpenExternal:ae,canGoBack:te,canGoForward:pe,isLoading:false}),e[51]=p,e[52]=re,e[53]=le,e[54]=ee,e[55]=oe,e[56]=de,e[57]=he,e[58]=ce,e[59]=ae,e[60]=te,e[61]=pe,e[62]=Te):Te=e[62];let Ae;e[63]!==o||e[64]!==F||e[65]!==g||e[66]!==re||e[67]!==w||e[68]!==u||e[69]!==C||e[70]!==i?(Ae=n.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:C?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[F?n.jsx(ue,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:u(F?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:xo(C)})}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:u("contextPanel.browser.remoteLoopback.hint")})]}):g?n.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}|${w}`):n.jsx(Wu,{onOpen:re,directory:o,visible:i})}),e[63]=o,e[64]=F,e[65]=g,e[66]=re,e[67]=w,e[68]=u,e[69]=C,e[70]=i,e[71]=Ae):Ae=e[71];let Pe;return e[72]!==Te||e[73]!==Ae?(Pe=n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Te,Ae]}),e[72]=Te,e[73]=Ae,e[74]=Pe):Pe=e[74],Pe},Kk=t=>{const e=qe.c(3),[s]=c.useState(Tk);let r;return e[0]!==s||e[1]!==t?(r=s?n.jsx(Uk,{...t}):n.jsx(Hk,{...t}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r};function qk(t){return t.setContextPanelTabTargetPath}function Gk(t){return t+1}function Zk(t){return t.recordVisit}function Xk(t){return t.forget}const Yk=t=>{const e=qe.c(13),{zone:s,children:r}=t,[o]=c.useState(Jk);let a;e[0]!==s?(a=p=>p.body[s],e[0]=s,e[1]=a):a=e[1];const i=yr(a);let u,d;e[2]!==i||e[3]!==o||e[4]!==s?(u=()=>{const p=i??yr.getState().body[s];if(!p){o.remove();return}if(o.parentElement===p)return;const h=document.activeElement;p.moveBefore&&o.isConnected?p.moveBefore(o,null):p.append(o),h instanceof HTMLElement&&o.contains(h)&&document.activeElement!==h&&h.focus({preventScroll:true})},d=[i,o,s],e[2]=i,e[3]=o,e[4]=s,e[5]=u,e[6]=d):(u=e[5],d=e[6]),c.useLayoutEffect(u,d);let l,f;e[7]!==o?(l=()=>()=>o.remove(),f=[o],e[7]=o,e[8]=l,e[9]=f):(l=e[8],f=e[9]),c.useLayoutEffect(l,f);let m;return e[10]!==r||e[11]!==o?(m=yc.createPortal(r,o),e[10]=r,e[11]=o,e[12]=m):m=e[12],m};function Jk(){const t=document.createElement("div");return t.style.display="contents",t}const Qk=200,Hu=t=>`${t.path}:${t.line}:${t.column}`,ec={status:"idle"},e3=t=>{const e=qe.c(9),{searchContents:s,directory:r,query:o,regex:a,includeHidden:i,respectGitignore:u,active:d}=t,[l,f]=c.useState(ec);let m,p;return e[0]!==d||e[1]!==r||e[2]!==i||e[3]!==o||e[4]!==a||e[5]!==u||e[6]!==s?(m=()=>{if(!d||!s||!r||!o.trim()){f(ec);return}const h=new AbortController;let x=false;return f({status:"searching"}),s({directory:r,query:o,regex:a,limit:Qk,includeHidden:i,respectGitignore:u,signal:h.signal}).then(g=>{x||f(g.status==="ok"?{status:"results",matches:g.matches,stopped:g.stopped}:g)}).catch(g=>{x||f({status:"failed",message:g instanceof Error?g.message:String(g)})}),()=>{x=true,h.abort()}},p=[d,r,i,o,a,u,s],e[0]=d,e[1]=r,e[2]=i,e[3]=o,e[4]=a,e[5]=u,e[6]=s,e[7]=m,e[8]=p):(m=e[7],p=e[8]),c.useEffect(m,p),l},gn=t=>{const e=qe.c(5),{className:s,children:r}=t;let o;e[0]!==s?(o=Ye("px-2 py-1 typography-meta text-muted-foreground",s),e[0]=s,e[1]=o):o=e[1];let a;return e[2]!==r||e[3]!==o?(a=n.jsx("li",{className:o,children:r}),e[2]=r,e[3]=o,e[4]=a):a=e[4],a},t3=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},s3=t=>{const e=qe.c(44),{state:s,activeMatchKey:r,onOpen:o,onDragStart:a,onDragEnd:i}=t,{t:u}=gt();switch(s.status){case"idle":return null;case"searching":{let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(ue,{name:"loader-4",className:"h-4 w-4 animate-spin"}),e[0]=m):m=e[0];let p;e[1]!==u?(p=u("sidebarFilesTree.state.searching"),e[1]=u,e[2]=p):p=e[2];let h;return e[3]!==p?(h=n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[m,p]}),e[3]=p,e[4]=h):h=e[4],h}case"unavailable":{let m;e[5]!==u?(m=u("sidebarFilesTree.contentSearch.unavailable"),e[5]=u,e[6]=m):m=e[6];let p;return e[7]!==m?(p=n.jsx(gn,{children:m}),e[7]=m,e[8]=p):p=e[8],p}case"invalid-pattern":{let m;e[9]!==u?(m=u("sidebarFilesTree.contentSearch.invalidPattern"),e[9]=u,e[10]=m):m=e[10];let p;e[11]!==m?(p=n.jsx("span",{className:"text-[var(--status-error)]",children:m}),e[11]=m,e[12]=p):p=e[12];let h;e[13]!==s.message?(h=n.jsx("span",{className:"font-mono typography-micro",dir:"ltr",children:s.message}),e[13]=s.message,e[14]=h):h=e[14];let x;return e[15]!==p||e[16]!==h?(x=n.jsxs(gn,{className:"flex flex-col gap-0.5",children:[p,h]}),e[15]=p,e[16]=h,e[17]=x):x=e[17],x}case"failed":{let m;e[18]!==s.message||e[19]!==u?(m=u("sidebarFilesTree.contentSearch.failed",{message:s.message}),e[18]=s.message,e[19]=u,e[20]=m):m=e[20];let p;return e[21]!==m?(p=n.jsx(gn,{className:"text-[var(--status-error)]",children:m}),e[21]=m,e[22]=p):p=e[22],p}}if(s.matches.length===0){let m;return e[23]!==s.stopped||e[24]!==u?(m=s.stopped==="deadline"?n.jsx(gn,{children:u("sidebarFilesTree.contentSearch.deadline")}):n.jsx(gn,{children:u("sidebarFilesTree.contentSearch.empty")}),e[23]=s.stopped,e[24]=u,e[25]=m):m=e[25],m}let d;if(e[26]!==r||e[27]!==i||e[28]!==a||e[29]!==o||e[30]!==s.matches){let m;e[32]!==r||e[33]!==i||e[34]!==a||e[35]!==o?(m=p=>{const{name:h,directory:x}=t3(p.relativePath),g=Hu(p),v=r===g;return n.jsx("li",{"data-file-tree-path":p.path,children:n.jsxs("button",{type:"button",onClick:()=>o(p),onDoubleClick:()=>o(p,{pin:true}),draggable:!!a,onDragStart:a?y=>a(y,p):void 0,onDragEnd:i?y=>i(y,p):void 0,className:Ye("flex w-full flex-col gap-0.5 rounded-md px-2 py-1 text-start transition-colors",ci(v)),title:`${p.relativePath}:${p.line}`,children:[n.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[n.jsx(Co,{filePath:p.path,className:"size-3.5 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 flex-shrink truncate typography-meta",dir:"auto",children:h}),x?n.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-micro text-muted-foreground",style:{direction:"rtl"},children:`\u200E${x}\u200E`}):n.jsx("span",{className:"flex-1"}),n.jsx("span",{className:"flex-shrink-0 typography-micro tabular-nums text-muted-foreground",children:p.line})]}),n.jsxs("span",{className:"block w-full min-w-0 truncate font-mono typography-micro text-muted-foreground",dir:"ltr",children:[p.cutStart?"\u2026":null,n.jsx(Up,{segments:Hp(p.text,p.ranges)})]})]})},g)},e[32]=r,e[33]=i,e[34]=a,e[35]=o,e[36]=m):m=e[36],d=s.matches.map(m),e[26]=r,e[27]=i,e[28]=a,e[29]=o,e[30]=s.matches,e[31]=d}else d=e[31];let l;e[37]!==s.matches.length||e[38]!==s.stopped||e[39]!==u?(l=s.stopped==="limit"?n.jsx(gn,{children:u("sidebarFilesTree.contentSearch.limit",{count:s.matches.length})}):s.stopped==="deadline"?n.jsx(gn,{children:u("sidebarFilesTree.contentSearch.deadline")}):null,e[37]=s.matches.length,e[38]=s.stopped,e[39]=u,e[40]=l):l=e[40];let f;return e[41]!==d||e[42]!==l?(f=n.jsxs(n.Fragment,{children:[d,l]}),e[41]=d,e[42]=l,e[43]=f):f=e[43],f},tc=8;let jr=null;const Ku=(t,e)=>Math.abs(e.clientX-t.x)<=tc&&Math.abs(e.clientY-t.y)<=tc,Fa=t=>{jr={x:t.clientX,y:t.clientY}},La=t=>{const e=jr;return jr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?false:Ku(e,t)},qu=t=>jr!==null&&Ku(jr,t);let Gu=null;const aa=t=>{Gu=t},Zu=()=>Gu,sc=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},Xu=(t,e,s)=>{const r=e===null?s:e.type==="directory"?e.path:sc(e.path);return!r||sc(t.path)===r||t.type==="directory"&&_f(r,t.path,t.path)!==null?null:r},n3=(t,e)=>{const s=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${s}`:`${e}/${s}`},r3=({root:t,childrenByDir:e,expandedPaths:s,loadErrorsByDir:r})=>{const o=[],a=(i,u)=>{for(const d of e[i]??[]){const l=d.type==="directory"&&s.has(d.path);if(o.push({kind:"node",key:d.path,node:d,depth:u,isExpanded:l}),!l)continue;const f=r[d.path];f&&o.push({kind:"error",key:`error:${d.path}`,directory:d.path,depth:u+1,message:f}),a(d.path,u+1)}};return a(t,0),o},o3=(t,e,s)=>{const r=e.filter(o=>o>=0&&o<s&&!t.includes(o));return r.length===0?[...t]:[...t,...r].sort((o,a)=>o-a)},a3=28,An=t=>Array.from(t.types).includes("Files"),ir=t=>Array.from(t.types).includes(gr)?Zu():null,Yu=(t,e,s)=>t.getData(gr)===_o(e,s.path),i3=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(s=>{if(s.kind!=="file"||s.webkitGetAsEntry()?.isDirectory)return[];const r=s.getAsFile();return r?[r]:[]})},l3=t=>t.slice().sort((e,s)=>e.type!==s.type?e.type==="directory"?-1:1:e.name.localeCompare(s.name)),Ht=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},_o=(t,e)=>{const s=Ht(e),r=Ht(t).replace(/\/+$/,"");return s===r?".":!r||!s.startsWith(`${r}/`)?s:s.slice(r.length+1)},Gn=(t,e)=>{const s=_o(t,e);if(s!==".")return s;const r=Ht(t);return r.split("/").filter(Boolean).pop()??r},Qr=t=>{const e=Ht(t),s=e.lastIndexOf("/");return s<0?"":s===0?"/":e.slice(0,s)},c3=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),d3=new Set(["node_modules"]),u3=t=>d3.has(t),f3=t=>{const e=Ht(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},p3=8,_s=new Map,vi=t=>JSON.stringify([Xt(),t]),m3=t=>{const e=vi(t),s=_s.get(e);return s?(s.touchedAt=Date.now(),_s.delete(e),_s.set(e,s),s):null},ia=t=>{const e=vi(t),s=_s.get(e);if(s)return s.touchedAt=Date.now(),s;if(_s.size>=p3){const o=_s.keys().next().value;o!==void 0&&_s.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return _s.set(e,r),r},h3=t=>{const e=qe.c(159),{guestActions:s,node:r,root:o,isExpanded:a,isActive:i,isBrowserClient:u,depth:d,isOpen:l,status:f,badge:m,isDropTarget:p,isDragSource:h,canUpload:x,canMove:g,permissions:v,downloadFile:y,onSelect:C,onToggle:S,onRevealPath:N,onOpenDialog:F,onSetDropTarget:_,onDropFiles:M,onPickFiles:B,onMoveDragChange:T,onSetMoveDropTarget:I,onMoveDrop:b}=t,{t:w}=gt(),j=r.type==="directory";let R;e[0]!==j||e[1]!==r.path?(R=j?r.path:Qr(r.path),e[0]=j,e[1]=r.path,e[2]=R):R=e[2];const L=R,{canRename:E,canCreateFile:D,canCreateFolder:U,canDelete:V,canReveal:J}=v,W=!j&&!!y,G=J&&!u,le=j&&x,$=E||D||U||le||V||W||G,[re,H]=c.useState(false),[P,ee]=c.useState(false);let oe;e[3]!==$?(oe=We=>{$&&(We?.preventDefault(),ee(true))},e[3]=$,e[4]=oe):oe=e[4];const de=oe;let he;e[5]!==j||e[6]!==r||e[7]!==C||e[8]!==S?(he=()=>{j?S(r.path):C(r)},e[5]=j,e[6]=r,e[7]=C,e[8]=S,e[9]=he):he=e[9];const Z=he;let ce;e[10]!==j||e[11]!==r||e[12]!==C?(ce=()=>{j||C(r,{pin:true})},e[10]=j,e[11]=r,e[12]=C,e[13]=ce):ce=e[13];const ae=ce;let te;e[14]===Symbol.for("react.memo_cache_sentinel")?(te=We=>{We.stopPropagation(),ee(false),H(true)},e[14]=te):te=e[14];const pe=te;let Te,Ae,Pe,ze,Oe,me,be;if(e[15]!==m||e[16]!==D||e[17]!==U||e[18]!==V||e[19]!==g||e[20]!==E||e[21]!==G||e[22]!==x||e[23]!==le||e[24]!==re||e[25]!==d||e[26]!==y||e[27]!==s||e[28]!==de||e[29]!==ae||e[30]!==Z||e[31]!==$||e[32]!==i||e[33]!==u||e[34]!==j||e[35]!==h||e[36]!==p||e[37]!==a||e[38]!==l||e[39]!==r||e[40]!==M||e[41]!==T||e[42]!==b||e[43]!==F||e[44]!==B||e[45]!==N||e[46]!==_||e[47]!==I||e[48]!==P||e[49]!==o||e[50]!==f||e[51]!==w||e[52]!==L){const We=l1(s,"file"),_e=ve=>{const{Item:je,Separator:vt}=ve;return n.jsxs(n.Fragment,{children:[E&&n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),F("rename",r)},children:[n.jsx(ue,{name:"edit",className:"me-2 h-4 w-4"})," ",w("sidebarFilesTree.menu.rename")]}),n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),wo(r.path).then(Je=>{if(Je.ok){Fe.success(w("sidebarFilesTree.toast.pathCopied"));return}Fe.error(w("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(ue,{name:"link",className:"me-2 h-4 w-4"})," ",w("sidebarFilesTree.menu.copyPath")]}),!j&&y&&n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),y(r.path).catch(Je=>{console.error("Download failed:",Je),Fe.error(w("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(ue,{name:"download",className:"me-2 h-4 w-4"})," ",w(u?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),G&&n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),N(r.path)},children:[n.jsx(ue,{name:"folder-received",className:"me-2 h-4 w-4"})," ",w(u1())]}),!j&&G&&go()&&n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),Sc(r.path).then(Je=>{Je||Fe.error(w("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(ue,{name:"external-link",className:"me-2 h-4 w-4"})," ",w("sidebarFilesTree.menu.openInDefaultApp")]}),We.length>0&&n.jsx(vt,{}),We.map(ne=>n.jsxs(je,{onClick:Je=>{Je.stopPropagation(),f1(ne,{kind:"file",action:ne.action.id,directory:o||null,path:r.path,isDirectory:j},w)},children:[n.jsx(li,{icon:ne.icon,iconSrc:ne.iconSrc,className:"me-2 h-4 w-4"})," ",ne.action.label]},`${ne.guest.id}:${ne.action.id}`)),j&&(D||U||le)&&n.jsxs(n.Fragment,{children:[n.jsx(vt,{}),D&&n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),F("createFile",r)},children:[n.jsx(ue,{name:"file-add",className:"me-2 h-4 w-4"})," ",w("sidebarFilesTree.menu.newFile")]}),U&&n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),F("createFolder",r)},children:[n.jsx(ue,{name:"folder-add",className:"me-2 h-4 w-4"})," ",w("sidebarFilesTree.menu.newFolder")]}),le&&n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),B(r.path)},children:[n.jsx(ue,{name:"upload-2",className:"me-2 h-4 w-4"})," ",w("sidebarFilesTree.menu.uploadFiles")]})]}),V&&n.jsxs(n.Fragment,{children:[n.jsx(vt,{}),n.jsxs(je,{onClick:ne=>{ne.stopPropagation(),F("delete",r)},className:"text-destructive focus:text-destructive",children:[n.jsx(ue,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",w("sidebarFilesTree.menu.delete")]})]})]})};let Ue;e[60]!==g||e[61]!==r.path||e[62]!==r.type||e[63]!==T||e[64]!==o?(Ue=ve=>{Fa(ve);const je=_o(o,r.path);!je||je==="."||(ve.dataTransfer.setData(gr,je),ve.dataTransfer.effectAllowed=g?"copyMove":"copy",g&&T({path:r.path,type:r.type}))},e[60]=g,e[61]=r.path,e[62]=r.type,e[63]=T,e[64]=o,e[65]=Ue):Ue=e[65];const Xe=Ue;let Me;e[66]!==g||e[67]!==Z||e[68]!==T?(Me=ve=>{g&&T(null),La(ve)&&Z()},e[66]=g,e[67]=Z,e[68]=T,e[69]=Me):Me=e[69];const ot=Me;let ye;e[70]!==x||e[71]!==_||e[72]!==L?(ye=ve=>{!x||!L||!An(ve.dataTransfer)||(ve.preventDefault(),ve.stopPropagation(),ve.dataTransfer.dropEffect="copy",_(L))},e[70]=x,e[71]=_,e[72]=L,e[73]=ye):ye=e[73];const Ve=ye;let lt;e[74]!==x||e[75]!==_||e[76]!==L?(lt=ve=>{!x||!L||!An(ve.dataTransfer)||ve.relatedTarget instanceof Node&&ve.currentTarget.contains(ve.relatedTarget)||(ve.stopPropagation(),_(null))},e[74]=x,e[75]=_,e[76]=L,e[77]=lt):lt=e[77];const ct=lt;let st;e[78]!==x||e[79]!==M||e[80]!==L?(st=ve=>{!x||!L||!An(ve.dataTransfer)||(ve.preventDefault(),ve.stopPropagation(),M(L,ve.dataTransfer))},e[78]=x,e[79]=M,e[80]=L,e[81]=st):st=e[81];const k=st;let Y;e[82]!==r.path||e[83]!==r.type||e[84]!==o?(Y=(ve,je)=>qu(ve)?null:Xu(je,{path:r.path,type:r.type},o),e[82]=r.path,e[83]=r.type,e[84]=o,e[85]=Y):Y=e[85];const Ne=Y;let Re;e[86]!==g||e[87]!==Ne||e[88]!==Ve||e[89]!==I?(Re=ve=>{const je=g?ir(ve.dataTransfer):null;if(!je){Ve(ve);return}ve.stopPropagation();const vt=Ne(ve,je);I(vt),vt&&(ve.preventDefault(),ve.dataTransfer.dropEffect="move")},e[86]=g,e[87]=Ne,e[88]=Ve,e[89]=I,e[90]=Re):Re=e[90];const Ie=Re;let Ee;e[91]!==g||e[92]!==Ne||e[93]!==k||e[94]!==b||e[95]!==I||e[96]!==o?(Ee=ve=>{const je=g?ir(ve.dataTransfer):null;if(!je){k(ve);return}ve.stopPropagation(),ve.preventDefault(),I(null);const vt=Ne(ve,je);vt&&Yu(ve.dataTransfer,o,je)&&b(je,vt)},e[91]=g,e[92]=Ne,e[93]=k,e[94]=b,e[95]=I,e[96]=o,e[97]=Ee):Ee=e[97];const Ge=Ee;Ae=Ir,me=P,be=ee;let Be;e[98]===Symbol.for("react.memo_cache_sentinel")?(Be={blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[98]=Be):Be=e[98];let Ze;e[99]!==de||e[100]!==ct||e[101]!==Ie||e[102]!==Ge?(Ze=n.jsx("div",{className:"group relative flex items-center typography-meta",style:Be,onContextMenu:de,onDragEnter:Ie,onDragOver:Ie,onDragLeave:ct,onDrop:Ge}),e[99]=de,e[100]=ct,e[101]=Ie,e[102]=Ge,e[103]=Ze):Ze=e[103];let et;e[104]!==d?(et=n.jsx(Cd,{depth:d}),e[104]=d,e[105]=et):et=e[105];let wt;e[106]!==i||e[107]!==h||e[108]!==p?(wt=Ye("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)]":ci(i),h&&"opacity-50"),e[106]=i,e[107]=h,e[108]=p,e[109]=wt):wt=e[109];let Qe;e[110]!==d?(Qe=Ed(d),e[110]=d,e[111]=Qe):Qe=e[111];let dt;e[112]!==Qe?(dt={paddingInlineStart:Qe},e[112]=Qe,e[113]=dt):dt=e[113];let at;e[114]!==j||e[115]!==a||e[116]!==r.extension||e[117]!==r.path?(at=j?n.jsx(c1,{expanded:a}):n.jsx(Co,{filePath:r.path,extension:r.extension,className:"ms-0.5 size-3.5"}),e[114]=j,e[115]=a,e[116]=r.extension,e[117]=r.path,e[118]=at):at=e[118];let z;e[119]!==r.name||e[120]!==r.path?(z=n.jsx("span",{className:"oc-file-tree-row-name typography-meta",title:r.path,children:r.name}),e[119]=r.name,e[120]=r.path,e[121]=z):z=e[121];let fe;e[122]!==j||e[123]!==l||e[124]!==f?(fe=!j&&n.jsx(p1,{isOpen:l,status:f}),e[122]=j,e[123]=l,e[124]=f,e[125]=fe):fe=e[125];let ke;e[126]!==m||e[127]!==j?(ke=j&&m&&n.jsx(m1,{badge:m}),e[126]=m,e[127]=j,e[128]=ke):ke=e[128];let ie;e[129]!==fe||e[130]!==ke?(ie=n.jsxs(h1,{className:"pe-2",children:[fe,ke]}),e[129]=fe,e[130]=ke,e[131]=ie):ie=e[131];let xe;e[132]!==de||e[133]!==ae||e[134]!==ot||e[135]!==Xe||e[136]!==Z||e[137]!==wt||e[138]!==dt||e[139]!==at||e[140]!==z||e[141]!==ie?(xe=n.jsxs("button",{type:"button",onClick:Z,onDoubleClick:ae,onContextMenu:de,draggable:true,onDragStart:Xe,onDragEnd:ot,className:wt,style:dt,children:[at,z,ie]}),e[132]=de,e[133]=ae,e[134]=ot,e[135]=Xe,e[136]=Z,e[137]=wt,e[138]=dt,e[139]=at,e[140]=z,e[141]=ie,e[142]=xe):xe=e[142];const Le=$&&n.jsx("div",{className:Ye("oc-file-tree-row-end -ms-7 w-7 pe-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 pointer-fine:hidden",d1(i||p)),children:n.jsxs(Sn,{open:re,onOpenChange:H,children:[n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("span",{className:"inline-flex",children:n.jsx(kn,{asChild:true,children:n.jsx(yt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:pe,"aria-label":w("diffView.actions.moreActions"),children:n.jsx(ue,{name:"more-2-fill",className:"h-4 w-4"})})})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:w("diffView.actions.moreActions")})]}),n.jsx(jn,{align:"end",side:"bottom",onCloseAutoFocus:()=>H(false),children:_e({Item:Ks,Separator:tr})})]})});e[143]!==Ze||e[144]!==et||e[145]!==xe||e[146]!==Le?(Pe=n.jsxs(yo,{render:Ze,children:[et,xe,Le]}),e[143]=Ze,e[144]=et,e[145]=xe,e[146]=Le,e[147]=Pe):Pe=e[147],Te=Nr,ze="min-w-[180px]";let Ke;e[148]===Symbol.for("react.memo_cache_sentinel")?(Ke={Item:Ts,Separator:Dn},e[148]=Ke):Ke=e[148],Oe=_e(Ke),e[15]=m,e[16]=D,e[17]=U,e[18]=V,e[19]=g,e[20]=E,e[21]=G,e[22]=x,e[23]=le,e[24]=re,e[25]=d,e[26]=y,e[27]=s,e[28]=de,e[29]=ae,e[30]=Z,e[31]=$,e[32]=i,e[33]=u,e[34]=j,e[35]=h,e[36]=p,e[37]=a,e[38]=l,e[39]=r,e[40]=M,e[41]=T,e[42]=b,e[43]=F,e[44]=B,e[45]=N,e[46]=_,e[47]=I,e[48]=P,e[49]=o,e[50]=f,e[51]=w,e[52]=L,e[53]=Te,e[54]=Ae,e[55]=Pe,e[56]=ze,e[57]=Oe,e[58]=me,e[59]=be}else Te=e[53],Ae=e[54],Pe=e[55],ze=e[56],Oe=e[57],me=e[58],be=e[59];let Ce;e[149]!==Te||e[150]!==ze||e[151]!==Oe?(Ce=n.jsx(Te,{className:ze,children:Oe}),e[149]=Te,e[150]=ze,e[151]=Oe,e[152]=Ce):Ce=e[152];let $e;return e[153]!==Ae||e[154]!==Pe||e[155]!==Ce||e[156]!==me||e[157]!==be?($e=n.jsxs(Ae,{open:me,onOpenChange:be,children:[Pe,Ce]}),e[153]=Ae,e[154]=Pe,e[155]=Ce,e[156]=me,e[157]=be,e[158]=$e):$e=e[158],$e},g3=(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&&t.guestActions===e.guestActions,x3=c.memo(h3,g3),b3=t=>{const e=qe.c(14),{visible:s}=t,r=s===void 0?true:s,o=Ln(y3),a=Zs()??"",i=Pr();let u,d,l,f;if(e[0]!==i||e[1]!==a||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{if(d=So(i,a)??"",i?.kind==="preparing"){let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Ur,{}),e[7]=p):p=e[7],f=p;break e}u=w3,l=JSON.stringify([o,d])}e[0]=i,e[1]=a,e[2]=o,e[3]=u,e[4]=d,e[5]=l,e[6]=f}else u=e[3],d=e[4],l=e[5],f=e[6];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;return e[8]!==u||e[9]!==d||e[10]!==a||e[11]!==l||e[12]!==r?(m=n.jsx(u,{visible:r,currentDirectory:d,panelDirectory:a},l),e[8]=u,e[9]=d,e[10]=a,e[11]=l,e[12]=r,e[13]=m):m=e[13],m},w3=({visible:t,currentDirectory:e,panelDirectory:s})=>{const r=c.useRef(t);r.current=t;const{t:o}=gt(),{files:a,runtime:i}=Is(),u=g1(),d=Af(i.platform),l=Ht(e.trim()),f=Ht(s.trim()),m=vi(l),p=Of(),h=Mf(),x=Ff(O=>O.searchFiles),g=K(O=>O.openContextFile),v=jo(t?e:null),[y,C]=c.useState(""),S=x1(y,200),N=c.useRef(null),[F,_]=c.useState([]),[M,B]=c.useState(false),T=!!a.searchContents,[I,b]=c.useState("names"),[w,j]=c.useState(false),R=T&&I==="contents",L=e3({searchContents:a.searchContents,directory:e,query:S,regex:w,includeHidden:p,respectGitignore:!h,active:t&&R}),E=K(O=>O.openContextFileAtLine),[D,U]=c.useState(null),[V,J]=c.useState(null),[W,G]=c.useState(null),[le,$]=c.useState(null),[re,H]=c.useState(null),{hasTouchOnlyPointer:P}=Tn(),ee=!!(a.rename&&l)&&!P,oe=K(O=>O.confirmFileTreeMove),de=K(O=>O.setConfirmFileTreeMove),[he,Z]=c.useState({}),[ce,ae]=c.useState({}),te=c.useRef(new Set),pe=c.useRef(new Map),Te=c.useMemo(()=>new cb,[]);c.useEffect(()=>()=>Te.clear(),[Te]);const Ae=c.useRef(null);c.useEffect(()=>{if(J(null),$(null),H(null),!l){Z({}),ae({}),te.current=new Set;return}const O=m3(l);O?(Z({...O.childrenByDir}),ae({...O.loadErrorsByDir}),te.current=new Set(O.loadedDirs)):(Z({}),ae({}),te.current=new Set)},[l]),c.useEffect(()=>{if(!l)return;const O=ia(l);O.childrenByDir=he},[l,he]),c.useEffect(()=>{if(!l)return;const O=ia(l);O.loadErrorsByDir=ce},[l,ce]),c.useEffect(()=>{if(!l)return;const O=ia(l);O.loadedDirs=new Set(te.current)},[l,he,ce]),c.useEffect(()=>()=>{if(!l)return;const O=_s.get(m);O&&O.loadedDirs.size===0&&Object.keys(O.childrenByDir).length===0&&_s.delete(m)},[m,l]);const Pe=c.useMemo(()=>[],[]),ze=c.useMemo(()=>[],[]),Oe=gs(O=>l?O.byRoot[l]?.expandedPaths??Pe:Pe),me=c.useMemo(()=>new Set(Oe),[Oe]),be=gs(O=>l?O.byRoot[l]?.selectedPath??null:null),Ce=gs(O=>O.setSelectedPath),$e=c.useRef(null);c.useEffect(()=>{$e.current=be},[be]);const We=gs(O=>O.addOpenPath),_e=gs(O=>O.removeOpenPathsByPrefix),Ue=gs(O=>O.toggleExpandedPath),Xe=gs(O=>O.expandPath),Me=gs(O=>O.collapseAllExpandedPaths),ot=K(O=>f?O.contextPanelByDirectory[f]?.tabs??ze:ze),ye=c.useMemo(()=>new Set(ot.map(O=>O.mode==="file"?O.targetPath:null).filter(O=>typeof O=="string"&&O.length>0).map(O=>Ht(O))),[ot]),[Ve,lt]=c.useState(null),[ct,st]=c.useState(null),[k,Y]=c.useState(""),[Ne,Re]=c.useState(false),Ie=!!a.writeFile,Ee=!!a.createDirectory,Ge=!!a.rename,Be=!!a.delete,Ze=!!a.revealPath,et=c.useMemo(()=>({canRename:Ge,canCreateFile:Ie,canCreateFolder:Ee,canDelete:Be,canReveal:Ze}),[Ge,Ie,Ee,Be,Ze]),wt=c.useCallback(O=>{a.revealPath&&a.revealPath(O).catch(()=>{Fe.error(o("sidebarFilesTree.toast.revealFailed"))})},[a,o]),Qe=c.useCallback((O,A)=>{lt(O),st(A),Y(O==="rename"&&A.name||""),Re(false)},[]),dt=c.useCallback((O,A)=>{const Se=A.filter(ge=>ge&&typeof ge.name=="string"&&ge.name.length>0).filter(ge=>p||!ge.name.startsWith(".")).filter(ge=>h||!u3(ge.name)).map(ge=>{const xt=ge.name,ht=Ht(ge.path||""),At=ht?c3(ht)?ht:Ht(`${O}/${ht}`):Ht(`${O}/${xt}`),Lt=ge.isDirectory?"directory":"file",Ot=Lt==="file"&&xt.includes(".")?xt.split(".").pop()?.toLowerCase():void 0;return{name:xt,path:At,type:Lt,extension:Ot}});return l3(Se)},[h,p]),at=c.useCallback(async(O,A,Se=false)=>{if(!r.current||A?.())return;const ge=Ht(O.trim());if(!ge||!Se&&te.current.has(ge))return;const xt=Xt();return Te.run(ge,async ht=>{const At=()=>!ht()||Xt()!==xt;try{const Lt=!h,Ot=a.listDirectory?(await a.listDirectory(ge,{respectGitignore:Lt})).entries:await ua.listLocalDirectory(ge,{respectGitignore:Lt});if(At())return;pe.current.set(ge,Ot.length);const zt=dt(ge,Ot);te.current=new Set(te.current),te.current.add(ge),ae(ys=>{if(!ys[ge])return ys;const dn={...ys};return delete dn[ge],dn}),Z(ys=>ys[ge]&&db(ys[ge],zt)?ys:{...ys,[ge]:zt})}catch(Lt){if(At())return;const Ot=Lt instanceof Error?Lt.message:String(Lt??"");console.error("Failed to load sidebar directory:",Lt),ae(zt=>({...zt,[ge]:Ot}))}},Se)},[Te,a,dt,h]),z=c.useCallback(async()=>{if(!l)return;Ae.current?.abort();const O=new AbortController;Ae.current=O,Te.clear();try{const Se=(gs.getState().byRoot[l]?.expandedPaths??[]).map(ht=>Ht(ht)).filter(ht=>!!ht&&ht!==l&&ht.startsWith(`${l}/`)),ge=[l,...Se];te.current=new Set(te.current);for(const ht of ge)te.current.delete(ht);ae(ht=>{if(Object.keys(ht).length===0)return ht;const At={...ht};let Lt=false;for(const Ot of ge)Ot in At&&(delete At[Ot],Lt=true);return Lt?At:ht});const xt=()=>O.signal.aborted;await at(l,xt);for(let ht=0;ht<Se.length&&!O.signal.aborted;ht+=3){const At=Se.slice(ht,ht+3);await Promise.all(At.map(Lt=>at(Lt,xt)))}}catch(A){if(O.signal.aborted)return;console.error("Failed to refresh sidebar tree:",A)}finally{Ae.current===O&&(Ae.current=null)}},[Te,at,l]),fe=c.useCallback(async O=>{if(!O){await z();return}const A=Ht(O);te.current=new Set(te.current),te.current.delete(A),await at(A,void 0,true)},[at,z]);c.useEffect(()=>{l&&(Ae.current?.abort(),te.current=new Set,Te.clear(),ae({}),Z(O=>Object.keys(O).length===0?O:{}),at(l))},[Te,at,l,p,h]),c.useEffect(()=>{if(!t||!l||Oe.length===0)return;const O=Oe.map(ge=>Ht(ge)).filter(ge=>!!ge&&ge!==l&&ge.startsWith(`${l}/`)&&!te.current.has(ge)&&!Te.has(ge)).sort((ge,xt)=>ge.split("/").length-xt.split("/").length);if(O.length===0)return;let A=false;const Se=()=>A;return(async()=>{for(let ge=0;ge<O.length&&!A;ge+=3){const xt=O.slice(ge,ge+3);await Promise.all(xt.map(ht=>at(ht,Se)))}})(),()=>{A=true}},[Te,Oe,at,l,t]);const ke=c.useRef(t);c.useEffect(()=>{const O=t&&!ke.current;ke.current=t,O&&z()},[z,t]);const ie=c.useCallback(({directories:O})=>{if(!l)return;const A=new Set((gs.getState().byRoot[l]?.expandedPaths??[]).map(Ot=>Ht(Ot))),Se=l==="/"?"/":`${l}/`,ge=Ot=>{for(let zt=Ot;zt!==l;zt=Qr(zt))if(!zt.startsWith(Se)||!A.has(zt))return false;return true},xt=Ot=>{for(let zt=Ot;zt===l||zt.startsWith(Se);zt=Qr(zt)){if(te.current.has(zt))return zt;if(zt===l)break}return null},ht=new Set,At=new Set;for(const Ot of O??te.current){const zt=xt(Ht(Ot));zt&&(ge(zt)?ht:At).add(zt)}At.size>0&&(te.current=new Set([...te.current].filter(Ot=>!At.has(Ot))));const Lt=[...ht].filter(Ot=>(pe.current.get(Ot)??0)<=Kp);(async()=>{for(let Ot=0;Ot<Lt.length;Ot+=3)await Promise.all(Lt.slice(Ot,Ot+3).map(zt=>at(zt,void 0,true)))})()},[at,l]);qp({root:l,active:t,whileInactive:"drop",onChanges:ie}),c.useEffect(()=>{if(!t)return;if(!e||R){_([]),B(false);return}const O=S.trim();if(!O){_([]),B(false);return}let A=false;return B(true),x(e,O,150,{includeHidden:p,respectGitignore:!h,type:"file"}).then(Se=>{if(A)return;const xt=Se.filter(ht=>h||!f3(ht.path)).map(ht=>({name:ht.name,path:Ht(ht.path),type:"file",extension:ht.extension,relativePath:ht.relativePath}));_(xt)}).catch(()=>{A||_([])}).finally(()=>{A||B(false)}),()=>{A=true}},[R,e,S,x,p,h,t]);const xe=c.useMemo(()=>{const O=new Map;if(!v?.files)return O;for(const A of v.files)A.index==="A"||A.working_dir==="?"?O.set(A.path,"git-added"):A.index==="D"?O.set(A.path,"git-deleted"):(A.index==="M"||A.working_dir==="M")&&O.set(A.path,"git-modified");return O},[v]),Le=c.useMemo(()=>{const O=new Map;if(!v?.files||!l)return O;for(const A of v.files){const Se=A.index==="M"||A.working_dir==="M",ge=A.index==="A"||A.working_dir==="?";if(!Se&&!ge)continue;const xt=A.path.split("/");if(xt.length<=1)continue;let ht=l;for(let At=0;At<xt.length-1;At++){ht=`${ht}/${xt[At]}`;let Lt=O.get(ht);Lt||(Lt={modified:0,added:0},O.set(ht,Lt)),Se&&Lt.modified++,ge&&Lt.added++}}return O},[v,l]),Ke=c.useCallback(O=>{if(xe.size===0)return null;const A=O.startsWith(l+"/")?O.slice(l.length+1):O;return xe.get(A)??null},[xe,l]),ve=c.useCallback(O=>{if(Le.size===0)return null;const A=Le.get(O);return A&&A.modified+A.added>0?A:null},[Le]),je=c.useCallback(async(O,A)=>{if(!l)return;const Se=await ol(a,O.path,{directory:l});if(!Se.ok){al(O.path,Se);return}Ce(l,O.path),We(l,O.path),g(f,O.path,{preview:!A?.pin&&!K.getState().isMobile})},[We,a,g,f,l,Ce]),vt=c.useCallback(async(O,A)=>{if(!l)return;const Se=await ol(a,O.path,{directory:l});if(!Se.ok){al(O.path,Se);return}Ce(l,O.path),We(l,O.path),U({path:O.path,key:Hu(O)}),E(f,O.path,O.line,O.column,{preview:!A?.pin&&!K.getState().isMobile})},[We,a,E,f,l,Ce]),ne=c.useCallback((O,A)=>{Fa(O),aa(null),O.dataTransfer.setData(gr,A.relativePath),O.dataTransfer.effectAllowed="copy"},[]),Je=c.useCallback((O,A)=>{La(O)&&vt(A)},[vt]),[kt,bt]=c.useState(null),_t=c.useCallback(()=>bt(null),[]),He=c.useRef(null),pt=ub(He,{onSettled:_t}),q=c.useCallback(async O=>{const A=Ht(O);if(!l)return;const Se=gs.getState().byRoot[l]?.expandedPaths.includes(A)??false;pt(O,Se,()=>{const ge=Array.from(He.current?.querySelectorAll("[data-tree-disclosure-path]")??[],xt=>xt.dataset.treeDisclosurePath??"");bt(Se?null:ge.slice(ge.indexOf(O)+1)),Ue(l,A)}),te.current.has(A)||await at(A)},[at,l,Ue,pt]),{canUpload:se,uploadingDirectory:De,uploadFiles:we,pickFiles:rt,uploadElements:ft}=Gp({root:l,refreshDirectory:fe}),nt=De!==null,ut=De??V,Nt=c.useCallback((O,A)=>{const Se=i3(A);Se.length!==0&&(J(null),we(O,Se))},[we]),Et=c.useCallback(O=>{if(aa(O),!O){G(null),$(null);return}requestAnimationFrame(()=>{Zu()?.path===O.path&&G(O.path)})},[]),Ft=c.useCallback(async(O,A)=>{const Se=n3(O,A),ge=await rl(a,{tabs:f,files:l},O.path,Se);if(ge==="conflict"){Fe.error(o("sidebarFilesTree.toast.nameTaken",{name:Se.slice(Se.lastIndexOf("/")+1),folder:Gn(l,A)}));return}if(ge==="failed"){Fe.error(o("sidebarFilesTree.toast.operationFailed"));return}A!==l&&Xe(l,A),await Promise.all([fe(Qr(O.path)),fe(A)]).catch(()=>{})},[Xe,a,f,fe,l,o]),Wt=c.useCallback((O,A)=>{if(K.getState().confirmFileTreeMove){H({source:O,targetDirectory:A});return}Ft(O,A)},[Ft]),is=c.useCallback(()=>{re&&(H(null),Ft(re.source,re.targetDirectory))},[Ft,re]),Gt=c.useCallback((O,A)=>!ee||qu(O)?null:Xu(A,null,l),[ee,l]),ns=c.useCallback(O=>{const A=ir(O.dataTransfer);if(A){const Se=Gt(O,A);if($(Se),!Se)return;O.preventDefault(),O.dataTransfer.dropEffect="move";return}!se||nt||!l||!An(O.dataTransfer)||(O.preventDefault(),O.dataTransfer.dropEffect="copy",J(l))},[se,Gt,nt,l]),ms=c.useCallback(O=>{if(!(O.relatedTarget instanceof Node&&O.currentTarget.contains(O.relatedTarget))){if(ir(O.dataTransfer)){$(null);return}An(O.dataTransfer)&&J(null)}},[]),Ns=c.useCallback(O=>{const A=ir(O.dataTransfer);if(A){O.preventDefault(),$(null);const Se=Gt(O,A);Se&&Yu(O.dataTransfer,l,A)&&Wt(A,Se);return}!se||nt||!l||!An(O.dataTransfer)||(O.preventDefault(),Nt(l,O.dataTransfer))},[se,Gt,Nt,Wt,nt,l]),Fs=c.useCallback(async O=>{if(O?.preventDefault(),!ct||!Ve)return;Re(true);const A=()=>Re(false),Se=()=>lt(null);if(Ve==="createFile"){if(!k.trim()){Fe.error(o("sidebarFilesTree.toast.filenameRequired")),A();return}if(!a.writeFile){Fe.error(o("sidebarFilesTree.toast.writeNotSupported")),A();return}const ge=ct.path,xt=ge?`${ge}/`:"",ht=Ht(`${xt}${k.trim()}`);await a.writeFile(ht,"").then(async At=>{At.success&&(Fe.success(o("sidebarFilesTree.toast.fileCreated")),await fe(ge)),Se()}).catch(()=>Fe.error(o("sidebarFilesTree.toast.operationFailed"))).finally(A);return}if(Ve==="createFolder"){if(!k.trim()){Fe.error(o("sidebarFilesTree.toast.folderNameRequired")),A();return}const ge=ct.path,xt=ge?`${ge}/`:"",ht=Ht(`${xt}${k.trim()}`);await a.createDirectory(ht).then(async At=>{At.success&&(Fe.success(o("sidebarFilesTree.toast.folderCreated")),await fe(ge)),Se()}).catch(()=>Fe.error(o("sidebarFilesTree.toast.operationFailed"))).finally(A);return}if(Ve==="rename"){if(!k.trim()){Fe.error(o("sidebarFilesTree.toast.nameRequired")),A();return}if(!a.rename){Fe.error(o("sidebarFilesTree.toast.renameNotSupported")),A();return}const ge=ct.path,xt=ge.split("/").slice(0,-1).join("/"),ht=xt?`${xt}/`:"",At=k.trim(),Lt=Ht(`${ht}${At}`);try{const Ot=await rl(a,{tabs:f,files:l},ge,Lt);Ot==="moved"?(Fe.success(o("sidebarFilesTree.toast.renamedSuccessfully")),await fe(xt),Se()):Ot==="conflict"?Fe.error(o("sidebarFilesTree.toast.nameTaken",{name:At,folder:Gn(l,xt)})):Fe.error(o("sidebarFilesTree.toast.operationFailed"))}catch{Fe.error(o("sidebarFilesTree.toast.operationFailed"))}finally{A()}return}if(Ve==="delete"){if(!a.delete){Fe.error(o("sidebarFilesTree.toast.deleteNotSupported")),A();return}const ge=ct.path,xt=ge.split("/").slice(0,-1).join("/");await a.delete(ge).then(async ht=>{ht.success&&(Fe.success(o("sidebarFilesTree.toast.deletedSuccessfully")),await fe(xt),l&&_e(l,ge),(be===ge||be&&be.startsWith(ge+"/"))&&Ce(l,null)),Se()}).catch(()=>Fe.error(o("sidebarFilesTree.toast.operationFailed"))).finally(A);return}A()},[Ve,ct,k,a,f,fe,_e,l,be,Ce,o]),X=c.useMemo(()=>l?r3({root:l,childrenByDir:he,expandedPaths:me,loadErrorsByDir:ce}):[],[he,me,ce,l]),mt=c.useMemo(()=>new Map(X.flatMap((O,A)=>O.kind==="node"?[[O.node.path,A]]:[])),[X]),[jt,$t]=c.useState(null),[Q,tt]=c.useState(null),St=c.useCallback(O=>{He.current=O,tt(O)},[]),[Tt,Bt]=c.useState(null),Zt=c.useMemo(()=>[W,Tt,...kt??[]].flatMap(O=>O?[mt.get(O)??-1]:[]),[Tt,W,kt,mt]),js=c.useCallback(O=>o3(hb(O),Zt,X.length),[Zt,X.length]),[us,Ps]=c.useState(0);c.useLayoutEffect(()=>{if(!jt||!Q)return;const O=Q.getBoundingClientRect().top-jt.getBoundingClientRect().top+jt.scrollTop;Ps(Math.max(0,Math.round(O)))},[Q,jt]);const Rs=c.useRef(null),hs=c.useRef(new Map),ls=c.useRef(null),ws=c.useCallback(O=>{const A=Math.max(0,...hs.current.values());O.style.setProperty("--oc-file-tree-width",`${A}px`)},[]),cn=c.useCallback((O,A)=>{const Se=O.dataset.treeRowPath,ge=He.current;!Se||!ge||A<=ge.clientWidth+.5||hs.current.get(Se)!==A&&(hs.current.set(Se,A),ls.current===null&&(ls.current=requestAnimationFrame(()=>{ls.current=null,He.current&&ws(He.current)})))},[ws]);c.useEffect(()=>()=>{ls.current!==null&&cancelAnimationFrame(ls.current)},[]),c.useLayoutEffect(()=>{if(!Q)return;const O=hs.current;for(const ge of O.keys())mt.has(ge)||O.delete(ge);const A=jt?.scrollLeft??0;Q.style.removeProperty("--oc-file-tree-width");const Se=Q.clientWidth;for(const ge of Q.children){const xt=ge instanceof HTMLElement?ge.dataset.treeRowPath:void 0;if(!xt)continue;const ht=ge.getBoundingClientRect().width;ht>Se+.5?O.set(xt,ht):O.delete(xt)}ws(Q),jt&&(jt.scrollLeft=A)},[Q,mt,jt,ws]);const Ys=mb({count:X.length,enabled:jt!==null,getScrollElement:()=>jt,estimateSize:O=>(X[O]?.kind==="node"?Rs.current:null)??a3,measureElement:(O,A,Se)=>{const ge=gb(O,A,Se);return O.dataset.treeRowPath&&(Rs.current=ge),A&&cn(O,A.borderBoxSize?.[0]?.inlineSize??O.getBoundingClientRect().width),ge},getItemKey:O=>X[O]?.key??O,overscan:12,scrollMargin:us,rangeExtractor:js}),En=O=>{if(O.kind==="error")return n.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:Ed(O.depth)},children:[n.jsx(Cd,{depth:O.depth}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:O.message,children:O.message}),n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsxs(yt,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{fe(O.directory)},children:[n.jsx(ue,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})}),n.jsx(Dt,{sideOffset:6,children:o("contextTooltips.files.retryFolder")})]})]});const{node:A,depth:Se,isExpanded:ge}=O,xt=A.type==="directory";return n.jsx(x3,{node:A,root:l,isExpanded:ge,isActive:be===A.path,isBrowserClient:d,depth:Se,isOpen:!xt&&ye.has(A.path),status:xt?void 0:Ke(A.path),badge:xt?ve(A.path):void 0,isDropTarget:xt&&(ut===A.path||le===A.path),isDragSource:W===A.path,canUpload:se&&!nt,canMove:ee,permissions:et,downloadFile:a.downloadFile,onSelect:je,onToggle:q,onRevealPath:wt,onOpenDialog:Qe,onSetDropTarget:J,onDropFiles:Nt,onPickFiles:rt,onMoveDragChange:Et,onSetMoveDropTarget:$,onMoveDrop:Wt,guestActions:u})},Ao=c.useCallback(O=>{const A=O.target instanceof Element?O.target.closest("[data-tree-row-path]"):null;Bt(A?.dataset.treeRowPath??null)},[]),Oo=c.useCallback(O=>{O.relatedTarget instanceof Node&&O.currentTarget.contains(O.relatedTarget)||Bt(null)},[]);c.useEffect(()=>{const O=$e.current;if(!O||!jt||!Q)return;const A=mt.get(O);A===void 0||jt.offsetParent===null||($e.current=null,Ys.scrollToIndex(A,{align:"auto"}))});const Dr=!!(l&&he[l]),Vn=l?ce[l]:null,Un=S.trim().length>0,Mo=!M&&!Un&&F.length===0&&!Vn&&Dr&&!!l,Hn=ut?Gn(l,ut):"",_r=le?Gn(l,le):"",Fo=re?re.source.path.slice(re.source.path.lastIndexOf("/")+1):"";return n.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-t border-edge-muted px-2",children:[n.jsxs("div",{className:"relative min-w-0 flex-1",children:[T?n.jsxs(Sn,{children:[n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("span",{className:"absolute inset-s-0.5 top-1/2 inline-flex -translate-y-1/2",children:n.jsx(kn,{asChild:true,children:n.jsx(yt,{variant:"ghost",size:"sm",className:"relative size-6 p-0 text-muted-foreground hover:text-foreground","aria-label":o("sidebarFilesTree.search.mode.aria"),children:n.jsx(ue,{name:R?"file-search":"search",className:"size-3.5"})})})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.search.mode.aria")})]}),n.jsx(jn,{align:"start",side:"bottom",children:n.jsxs(hd,{value:I,onValueChange:O=>b(O==="contents"?"contents":"names"),children:[n.jsxs(oo,{value:"names",closeOnClick:true,className:"items-center",children:[n.jsx(ue,{name:"search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.names")]}),n.jsxs(oo,{value:"contents",closeOnClick:true,className:"items-center",children:[n.jsx(ue,{name:"file-search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.contents")]})]})})]}):n.jsx(ue,{name:"search",className:"pointer-events-none absolute inset-s-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),n.jsx(Fn,{ref:N,inputSize:"compact",value:y,onChange:O=>C(O.target.value),placeholder:o(R?"sidebarFilesTree.search.contentsPlaceholder":"sidebarFilesTree.search.placeholder"),className:Ye("ps-7",R?"pe-14":y.trim().length>0?"pe-7":"pe-2")}),R?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx(yt,{variant:"chip",size:"xs","aria-pressed":w,onClick:()=>{j(O=>!O),N.current?.focus()},"aria-label":o("sidebarFilesTree.search.regexTitle"),className:"absolute inset-e-1 top-1/2 h-5 min-w-0 -translate-y-1/2 px-1 font-mono typography-micro",children:".*"})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:o(w?"contextTooltips.files.searchPlainText":"sidebarFilesTree.search.regexTitle")})]}):null,y.trim().length>0?n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button","aria-label":o("sidebarFilesTree.search.clearAria"),className:Ye("absolute top-1/2 inline-flex size-4 -translate-y-1/2 items-center justify-center text-muted-foreground hover:text-foreground",R?"inset-e-8":"inset-e-2"),onClick:()=>{C(""),N.current?.focus()},children:n.jsx(ue,{name:"close",className:"size-3.5"})})}),n.jsx(Dt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.search.clearAria")})]}):null]}),n.jsx(jd,{className:"shrink-0 gap-0.5",groups:[[(Ie||Ee||se)&&{id:"add",label:o("sidebarFilesTree.actions.addMenuTitle"),icon:nt?"loader-4":"add",iconClassName:nt?"animate-spin":void 0,menu:n.jsxs(n.Fragment,{children:[Ie?n.jsxs(Ks,{onClick:()=>Qe("createFile",{path:e,type:"directory"}),children:[n.jsx(ue,{name:"file-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFile")]}):null,Ee?n.jsxs(Ks,{onClick:()=>Qe("createFolder",{path:e,type:"directory"}),children:[n.jsx(ue,{name:"folder-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFolder")]}):null,se?n.jsxs(Ks,{disabled:!l||nt,onClick:()=>rt(l),children:[n.jsx(ue,{name:"upload-2",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.uploadFiles")]}):null]})}]],menuOnly:[{id:"gitignored",label:o("filesView.tree.actions.showGitignored"),icon:"file-forbid",pressed:h,onSelect:()=>Lf(!h)},{id:"refresh",label:o("sidebarFilesTree.actions.refreshTitle"),icon:"refresh",onSelect:()=>{z()}},{id:"collapse-all",label:o("sidebarFilesTree.actions.collapseAllTitle"),icon:"collapse-vertical",onSelect:()=>{l&&Me(l)}}]})]}),n.jsxs("div",{className:"relative flex-1 min-h-0",children:[n.jsxs(ps,{ref:$t,outerClassName:"h-full min-h-0",className:Ye("@container px-1.5 py-1.5 [overflow-anchor:none]",(ut===l||le===l)&&"bg-interactive-selection/10"),onDragEnter:ns,onDragOver:ns,onDragLeave:ms,onDrop:Ns,children:[n.jsx("ul",{className:"flex flex-col",children:R&&L.status!=="idle"?n.jsx(s3,{state:L,activeMatchKey:D&&D.path===be?D.key:null,onOpen:vt,onDragStart:ne,onDragEnd:Je}):M?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx(ue,{name:"loader-4",className:"h-4 w-4 animate-spin"}),o("sidebarFilesTree.state.searching")]}):Un&&F.length===0?n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("mobile.files.search.empty")}):F.length>0?F.map(O=>{const A=be===O.path;return n.jsx("li",{"data-file-tree-path":O.path,children:n.jsxs("button",{type:"button",onClick:()=>je(O),onDoubleClick:()=>je(O,{pin:true}),draggable:true,onDragStart:Se=>{Fa(Se),aa(null);const ge=O.relativePath||_o(l??"",O.path);!ge||ge==="."||(Se.dataTransfer.setData(gr,ge),Se.dataTransfer.effectAllowed="copy")},onDragEnd:Se=>{La(Se)&&je(O)},className:Ye("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",ci(A)),title:O.path,children:[n.jsx(Co,{filePath:O.path,extension:O.extension,className:"size-3.5"}),n.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},children:`\u200E${O.relativePath??O.path}\u200E`})]})},O.path)}):Vn?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{children:Vn}),n.jsxs(Rt,{children:[n.jsx(Pt,{asChild:true,children:n.jsxs(yt,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{z()},children:[n.jsx(ue,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})}),n.jsx(Dt,{sideOffset:6,children:o("contextTooltips.files.retryFileList")})]})]}):Dr&&l?null:n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("sidebarFilesTree.state.loading")})}),Mo?n.jsx("ul",{ref:St,className:"relative min-w-[max(100%,var(--oc-file-tree-width,0px))]",style:{height:Ys.getTotalSize()},onFocus:Ao,onBlur:Oo,children:Ys.getVirtualItems().map(O=>{const A=X[O.index];if(!A)return null;const Se=A.kind==="node"?A.node.path:void 0;return n.jsx("li",{ref:Ys.measureElement,"data-index":O.index,"data-tree-row-path":Se,"data-tree-disclosure-path":A.kind==="node"?Se:`${A.directory}/`,"data-file-tree-path":A.kind==="node"&&A.node.type==="file"?Se:void 0,className:Ye("absolute inset-x-0 top-0",A.kind==="node"&&"min-w-max"),style:{transform:`translateY(${O.start-us}px)`},children:En(A)},O.key)})}):null]}),ut?n.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:[n.jsx(ue,{name:nt?"loader-4":"folder-received",className:Ye("size-4 flex-shrink-0",nt&&"animate-spin")}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:Hn,children:o(nt?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Hn})})]}):le?n.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:[n.jsx(ue,{name:"folder-received",className:"size-4 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:_r,children:o("sidebarFilesTree.drop.moveTarget",{path:_r})})]}):null]}),ft,n.jsx(dr,{open:!!Ve,onOpenChange:O=>!O&&lt(null),children:n.jsxs(ur,{children:[n.jsxs(fr,{children:[n.jsxs(pr,{children:[Ve==="createFile"&&o("sidebarFilesTree.dialog.createFile.title"),Ve==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.title"),Ve==="rename"&&o("sidebarFilesTree.dialog.rename.title"),Ve==="delete"&&o("sidebarFilesTree.dialog.delete.title")]}),n.jsxs(mr,{children:[Ve==="createFile"&&o("sidebarFilesTree.dialog.createFile.description",{path:ct?.path??o("sidebarFilesTree.dialog.rootFallback")}),Ve==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.description",{path:ct?.path??o("sidebarFilesTree.dialog.rootFallback")}),Ve==="rename"&&o("sidebarFilesTree.dialog.rename.description",{name:ct?.name??""}),Ve==="delete"&&o("sidebarFilesTree.dialog.delete.description",{name:ct?.name??""})]})]}),Ve!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(Fn,{value:k,onChange:O=>Y(O.target.value),placeholder:o(Ve==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:O=>{O.key==="Enter"&&Fs()},autoFocus:true})}),n.jsxs(no,{children:[n.jsx(yt,{variant:"outline",onClick:()=>lt(null),disabled:Ne,children:o("sidebarFilesTree.dialog.cancel")}),n.jsx(yt,{variant:Ve==="delete"?"destructive":"default",onClick:()=>{Fs()},disabled:Ne||Ve!=="delete"&&!k.trim(),children:Ne?n.jsx(ue,{name:"loader-4",className:"size-4 animate-spin"}):o(Ve==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),n.jsx(dr,{open:re!==null,onOpenChange:O=>{O||H(null)},children:n.jsxs(ur,{showCloseButton:false,className:"max-w-sm gap-5",children:[n.jsxs(fr,{children:[n.jsx(pr,{children:o("sidebarFilesTree.dialog.move.title")}),n.jsx(mr,{children:re?o("sidebarFilesTree.dialog.move.description",{name:Fo,folder:Gn(l,re.targetDirectory)}):null})]}),n.jsxs(no,{className:"w-full sm:items-center sm:justify-between",children:[n.jsxs("div",{className:"flex cursor-pointer items-center gap-2 typography-meta text-muted-foreground",onClick:()=>de(!oe),children:[n.jsx(pa,{checked:!oe,onChange:O=>de(!O),ariaLabel:o("sidebarFilesTree.dialog.move.neverAsk")}),n.jsx("span",{children:o("sidebarFilesTree.dialog.move.neverAsk")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(yt,{variant:"ghost",onClick:()=>H(null),children:o("sidebarFilesTree.dialog.cancel")}),n.jsx(yt,{onClick:is,children:o("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function y3(t){return t.runtimeKey}const v3=Tr(()=>Vt(()=>import("./WalkthroughView-Dm4-RaV3.js"),__vite__mapDeps([212,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,213,186,187,188,189,190,191,192,193,194,195,181,182,183,185,196,197,198,199,200,201,202,203,214,215,216,217])).then(t=>({default:t.WalkthroughView}))),S3=Tr(()=>Vt(()=>import("./DiffView-CSSPNDYJ.js"),__vite__mapDeps([218,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,213,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,219,185,196,197,198,199,200,201,202,203,204,205,206,207,209,210,214,217])).then(t=>({default:t.DiffView}))),k3=Tr(()=>Vt(()=>import("./FilesView-D0FOaLpo.js").then(t=>t.F),__vite__mapDeps([220,5,1,2,3,4,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,221,222,223,224,203,181,182,183,225,226,200,227,186,187,188,189,190,191,192,193,194,195,228,197,229,230,231,201,199,210,232,233,209,206,217,202,234])).then(t=>({default:t.FilesView}))),j3=c.lazy(()=>Vt(()=>import("./GuestPanelContent-BCxvKv4H.js"),__vite__mapDeps([235,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])).then(t=>({default:t.GuestPanelContent}))),$s=(t,e)=>`${t}\0${e}`,T3=6e4,C3=({visible:t,active:e,fill:s=false,side:r})=>{const{t:o}=gt(),a=K(S=>S.contextEditorTreeWidth),i=K(S=>S.setContextEditorTreeWidth),[u,d]=c.useState(false),l=c.useRef(0),f=c.useRef(a),m=c.useRef(null),p=c.useRef(null),h=c.useRef(null),x=c.useCallback(S=>{const N=h.current;N&&(N.style.width=`${S}px`,N.style.setProperty("--oc-editor-tree-width",`${S}px`))},[]),g=S=>{if(t){try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}p.current=S.pointerId,d(true),l.current=S.clientX,f.current=a,m.current=a,S.preventDefault()}},v=S=>{if(!u||p.current!==S.pointerId)return;const N=r==="left"?S.clientX-l.current:l.current-S.clientX,F=mo(S.currentTarget)?-N:N,_=da(f.current+F);m.current!==_&&(m.current=_,x(_))},y=S=>{if(p.current!==S.pointerId)return;try{S.currentTarget.releasePointerCapture(S.pointerId)}catch{}const N=da(m.current??a);p.current=null,m.current=null,d(false),i(N)},C=t?a:0;return n.jsxs("div",{ref:h,className:Ye("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",s&&(r==="left"?"me-auto":"ms-auto")),style:{width:`${u?m.current??C:C}px`,maxWidth:s?"100%":void 0,"--oc-editor-tree-width":`${u?m.current??a:a}px`,overflowX:"clip",transitionProperty:u?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!s&&n.jsx("div",{"aria-hidden":"true",className:Ye("pointer-events-none absolute inset-y-0 z-20 w-px bg-border",r==="left"?"inset-e-0":"inset-s-0")}),t&&!s&&n.jsx("div",{className:Ye("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:v,onPointerUp:y,onPointerCancel:y,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{className:Ye("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:s?"100%":void 0},"aria-hidden":!t,children:n.jsx(b3,{visible:t&&e})})]})},Qs=t=>{const e=qe.c(12),{zone:s,isOpen:r,interactive:o,hidden:a,className:i,children:u}=t,d=!r||a;let l;e[0]!==u||e[1]!==d?(l=n.jsx(Id,{paused:d,children:u}),e[0]=u,e[1]=d,e[2]=l):l=e[2];let f;e[3]!==o||e[4]!==l?(f=n.jsx(vd.Provider,{value:true,children:n.jsx(Jp.Provider,{value:o,children:l})}),e[3]=o,e[4]=l,e[5]=f):f=e[5];let m;e[6]!==i||e[7]!==f?(m=n.jsx("div",{className:i,children:f}),e[6]=i,e[7]=f,e[8]=m):m=e[8];let p;return e[9]!==m||e[10]!==s?(p=n.jsx(Yk,{zone:s,children:m}),e[9]=m,e[10]=s,e[11]=p):p=e[11],p},E3=()=>{const{t}=gt(),e=Zs()??"",s=c.useMemo(()=>e?ds(e):"",[e]),r=K(k=>s?k.contextPanelByDirectory[s]:void 0),o=Pr(),a=o?.kind==="preparing",i=o?.kind==="ready"?o.directory:null,u=So(o,e)??"",d=K(k=>k.contextSurfaceZones),l=K(k=>k.contextPanelByDirectory),f=K(k=>k.closeContextPanelTab),m=K(k=>k.closeContextFile),p=K(k=>k.openContextPanelTab),h=K(k=>k.openAgentBrowserTab),x=K(k=>k.openContextFile),g=K(k=>k.contextEditorTreeVisible),v=K(k=>k.contextEditorVisible),y=K(k=>k.fileTreeSide),C=gs(k=>k.setSelectedPath),S=yr(k=>k.headerSlot),N=c.useMemo(()=>r?.tabs??[],[r?.tabs]),F=Kr(k=>k.chatCovered),_=c.useMemo(()=>{const k=Y=>{const Ne=r?to(r,d,Y):null,Re=Y==="bottom"&&F;return{activeTab:Ne,isOpen:!!(r&&lr(r,Y).isOpen&&Ne)&&!Re}};return{left:k("left"),right:k("right"),bottom:k("bottom")}},[F,r,d]),M={left:{..._.left,activeTab:Gr(_.left.activeTab,_.left.isOpen)},right:{..._.right,activeTab:Gr(_.right.activeTab,_.right.isOpen)},bottom:{..._.bottom,activeTab:Gr(_.bottom.activeTab,_.bottom.isOpen)}},B={left:na(M.left.isOpen),right:na(M.right.isOpen),bottom:na(M.bottom.isOpen)},T=k=>!B[k],I={left:rr(M.left.isOpen),right:rr(M.right.isOpen),bottom:rr(M.bottom.isOpen)},b={left:Vr(M.left.isOpen,I.left,M.left.activeTab?.mode),right:Vr(M.right.isOpen,I.right,M.right.activeTab?.mode),bottom:Vr(M.bottom.isOpen,I.bottom,M.bottom.activeTab?.mode)},w=k=>{const Y=fa(d,k);return{zone:Y,...M[Y]}},j=w("file"),R=w("chat"),L=w("browser"),E=w("diff"),D=w("terminal"),U=w("walkthrough"),[V,J]=c.useState([]),W=c.useRef(new Map),G=c.useCallback((k,Y)=>{const Ne=$s(k,Y);W.current.set(Ne,Date.now()),J(Re=>$f(Re,Ne))},[]);c.useEffect(()=>T0((k,Y)=>{W.current.set($s(k,Y),Date.now())}),[]);const le=K(k=>k.liveBrowserTabLimit),$=K(k=>k.agentBrowserSharesLogins);c.useEffect(()=>E0((k,Y)=>{const Ne=Y.directory?ds(Y.directory):s;if(!Ne)return null;const Re=h(Ne,k,Y.sessionId);return Re&&G(Ne,Re),Re}),[s,h,G]),c.useEffect(()=>I0((k,Y)=>K.getState().contextPanelByDirectory[k]?.tabs?.some(Re=>Re.id===Y&&Re.mode==="browser")?(f(k,Y),true):false),[f]),c.useEffect(()=>$n(k=>{if(k.type!=="file-open-request")return;const Y=k.directory??e;Y&&x(Y,k.path)}),[e,x]),c.useEffect(()=>$n(k=>{if(k.type!=="plan-open-request")return;const Y=k.directory??e,Ne=b1(Y,k.projectId);!Y||!Ne||K.getState().openProjectKnowledgePlan(Y,w1(Ne),k.planId)}),[e]);const re=_[L.zone].activeTab,H=re?.mode==="browser"?re.id:null;c.useEffect(()=>{j0(s,H)},[s,H]);const P=_[j.zone].activeTab;c.useEffect(()=>{if(!u||P?.mode!=="file"||!P.targetPath)return;const k=ks(P.targetPath)===ks(u);C(ds(u),P.targetPath,{allowOutsideRoot:!o&&k})},[u,o,P,C]);const ee=c.useMemo(()=>N.some(k=>k.mode==="file"&&k.targetPath),[N]),oe=c.useMemo(()=>N.some(k=>k.mode==="file"),[N]),de=ee&&(v||!g),he=j.activeTab?.mode==="file",Z=c.useCallback(k=>{s&&m(s,k)},[m,s]),ce=R.isOpen&&R.activeTab?.mode==="chat"?R.activeTab:null,ae=ce?No(ce.dedupeKey):null,te=c.useMemo(()=>(ce?.targetDirectory?ds(ce.targetDirectory):"")||s||null,[ce?.targetDirectory,s]),pe=c.useMemo(()=>ae?{sessionId:ae,directory:te}:null,[ae,te]);c.useEffect(()=>{if(!te||!ae||typeof window>"u")return;const k=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Uo(te,ae,false);return}Nd(ae),Uo(te,ae,true)};k();const Y=window.setInterval(k,1e4);return window.addEventListener("focus",k),window.addEventListener("blur",k),document.addEventListener("visibilitychange",k),()=>{window.clearInterval(Y),window.removeEventListener("focus",k),window.removeEventListener("blur",k),document.removeEventListener("visibilitychange",k),Uo(te,ae,false)}},[te,ae]);const Te=E.activeTab,Ae=c.useCallback(k=>{!s||Te?.mode!=="diff"||p(s,{mode:"diff",targetPath:Te.targetPath,targetDirectory:Te.targetDirectory,stagedDiff:k==="staged",diffScope:k})},[Te,s,p]),Pe=L.isOpen&&L.activeTab?.mode==="browser"?L.activeTab.id:null;c.useEffect(()=>{Pe&&s&&G(s,Pe)},[s,Pe,G]);const ze=c.useRef(null);c.useEffect(()=>{ze.current=Pe&&s?$s(s,Pe):null},[s,Pe]),c.useEffect(()=>{const k=()=>{const Ne=Date.now(),Re=W.current;ze.current&&Re.set(ze.current,Ne);const Ie=new Set;for(const[Ee,Ge]of Object.entries(K.getState().contextPanelByDirectory))for(const Be of Ge.tabs)Be.mode==="browser"&&Be.ownerSessionId!==null&&Ie.add($s(Ee,Be.id));J(Ee=>zf(Ee,Ie,Re,Ne-Wf))},Y=window.setInterval(k,T3);return()=>window.clearInterval(Y)},[]);const{loadedBrowserTabs:Oe,sleepingBrowserTabs:me}=c.useMemo(()=>{const k=new Set(V),Y=new Set;for(const[Ee,Ge]of Object.entries(l))for(const Be of Ge.tabs)Be.mode==="browser"&&Be.ownerSessionId===null&&Y.add($s(Ee,Be.id));const Ne=Bf(V,Y,le),Re=[],Ie=[];for(const[Ee,Ge]of Object.entries(l)){const Be=Ee===s;for(const Ze of Ge.tabs){if(Ze.mode!=="browser")continue;const et=$s(Ee,Ze.id),wt=Ze.ownerSessionId===null,Qe=Be&&Ze.id===Pe||(wt?Ne.has(et):k.has(et));if(!Qe&&!Be&&wt)continue;const dt={directory:Ee,id:Ze.id,targetPath:Ze.targetPath,ownerSessionId:Ze.ownerSessionId};(Qe?Re:Ie).push(dt)}}return Re.sort((Ee,Ge)=>$s(Ee.directory,Ee.id)<$s(Ge.directory,Ge.id)?-1:1),{loadedBrowserTabs:Re,sleepingBrowserTabs:Ie}},[l,s,le,V,Pe]);c.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const k=me.map(Y=>k0({tabId:Y.id,directory:Y.directory,ownerSessionId:Y.ownerSessionId,describe:()=>({title:"",url:Y.targetPath??""}),wake:()=>G(Y.directory,Y.id)}));return()=>k.forEach(Y=>Y())},[me,G]);const be=c.useMemo(()=>N.filter(k=>k.mode==="diff"),[N]),Ce=c.useMemo(()=>N.find(k=>k.mode==="terminal")??null,[N]),$e=c.useMemo(()=>N.find(k=>k.mode==="walkthrough")??null,[N]),We=c.useMemo(()=>N.filter(k=>wn(k.mode)),[N]),_e=c.useMemo(()=>N.filter(k=>k.mode==="pages"&&k.targetPath),[N]),Ue=cr(k=>k.guests),Xe=c.useMemo(()=>new Set(Ue.filter(y1).map(k=>k.id)),[Ue]),Me=c.useMemo(()=>{const k=new Map;for(const Y of Ue){const Ne=v1(Y);Ne&&k.set(Y.id,Ne)}return k},[Ue]),ot=D.zone,ye=c.useCallback(k=>{const Y=hi({mode:"terminal",label:t("layout.mainTab.terminal"),from:ot},k);return{finish:()=>Y.finish(s),cancel:Y.cancel}},[s,t,ot]),Ve=(k,Y)=>Y?S[k]:null,[lt,ct]=c.useState(()=>new Set),st=[...We,..._e].filter(k=>{if(lt.has(k.id))return false;const Y=w(k.mode);return Y.isOpen&&Y.activeTab?.id===k.id});return st.length>0&&ct(new Set([...lt,...st.map(k=>k.id)])),n.jsxs(n.Fragment,{children:[oe?n.jsxs(Qs,{zone:j.zone,interactive:b[j.zone],isOpen:j.isOpen,hidden:T(j.zone),className:Ye("absolute inset-0 flex",y==="left"&&"flex-row-reverse",he?"flex":"hidden"),children:[a?n.jsx("div",{className:"h-full min-w-0 flex-1",children:n.jsx(Ur,{})}):ee||!g?n.jsx("div",{className:Ye("h-full min-w-0 flex-1",ee&&!de&&"hidden"),children:ee?n.jsx(c.Suspense,{fallback:null,children:n.jsx(k3,{mode:"editor-only",visible:!T(j.zone)&&he&&de,onCloseFile:Z})}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx(ue,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),n.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,a?null:n.jsx(C3,{visible:g,active:j.isOpen&&he,fill:!de,side:y})]}):null,ce&&ae&&pe?n.jsx(Qs,{zone:R.zone,interactive:b[R.zone],isOpen:R.isOpen,hidden:T(R.zone),className:"absolute inset-0 bg-background",children:n.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:ae}),className:"h-full",children:n.jsx(Kc,{pinnedSession:pe,readOnly:ce.readOnly})})},ce.id):null,Oe.map(k=>{const Y=k.directory===s&&L.activeTab?.id===k.id,Ne=k.directory===s?i??k.directory:k.directory;return n.jsx(Qs,{zone:L.zone,interactive:b[L.zone],isOpen:L.isOpen,hidden:T(L.zone),className:Ye("absolute inset-0",!Y&&"invisible pointer-events-none"),children:n.jsx("div",{className:"h-full","aria-hidden":!Y||void 0,children:n.jsx(Id,{paused:!Y,children:k.directory===s&&a?n.jsx(Ur,{}):n.jsx(Kk,{initialUrl:k.targetPath??"",directory:k.directory,siteDirectory:Ne,tabID:k.id,ownerSessionId:k.ownerSessionId,visible:Y&&L.isOpen},k.ownerSessionId!==null&&!$?`${Ne}\0agent`:Ne)})})},$s(k.directory,k.id))}),be.map(k=>{const Y=E.activeTab?.id===k.id;return n.jsx(Qs,{zone:E.zone,interactive:b[E.zone],isOpen:E.isOpen,hidden:T(E.zone),className:Ye("absolute inset-0",!Y&&"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(bn,{value:Ve(E.zone,Y),children:a&&!k.targetDirectory?n.jsx(Ur,{}):n.jsx(S3,{directory:k.targetDirectory??i,visible:E.isOpen&&Y,hideStackedFileSidebar:true,stackedDefaultCollapsedAll:true,pinSelectedFileHeaderToTopOnNavigate:true,showOpenInEditorAction:true,diffScope:k.diffScope??(k.stagedDiff?"staged":null),onDiffScopeChange:Ae,targetFilePath:k.targetPath,flushContent:true})})})},k.id)}),Ce?n.jsx(Qs,{zone:D.zone,interactive:b[D.zone],isOpen:D.isOpen,hidden:T(D.zone),className:Ye("absolute inset-0",D.activeTab?.mode==="terminal"?"block":"hidden"),children:n.jsx(bn,{value:Ve(D.zone,D.activeTab?.mode==="terminal"),children:n.jsx(Zp.Provider,{value:ye,children:n.jsx(Xp,{visible:D.isOpen&&D.activeTab?.mode==="terminal",directory:Ce.targetDirectory,onLastTabClosed:()=>{s&&f(s,Ce.id)}})})})}):null,$e?n.jsx(Qs,{zone:U.zone,interactive:b[U.zone],isOpen:U.isOpen,hidden:T(U.zone),className:Ye("absolute inset-0",U.activeTab?.mode==="walkthrough"?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(bn,{value:Ve(U.zone,U.activeTab?.mode==="walkthrough"),children:n.jsx(v3,{directory:$e.targetDirectory??e,visible:U.isOpen&&U.activeTab?.mode==="walkthrough"})})})}):null,_e.map(k=>{const Y=w(k.mode);return!lt.has(k.id)||!k.targetPath?null:n.jsx(Qs,{zone:Y.zone,interactive:b[Y.zone],isOpen:Y.isOpen,hidden:T(Y.zone),className:Ye("absolute inset-0",Y.activeTab?.id===k.id?"block":"hidden"),children:n.jsx(Yp,{receivedId:k.targetPath})},k.id)}),We.map(k=>{if(!wn(k.mode))return null;const Y=w(k.mode);if(!lt.has(k.id))return null;const Ne=er(k.mode),Re=Xe.has(Ne),Ie=Me.get(Ne),Ee=Y.activeTab?.id===k.id,Ge=Ee&&Y.isOpen;return Re&&!Ie&&!Ge?null:n.jsx(Qs,{zone:Y.zone,interactive:b[Y.zone],isOpen:Y.isOpen,hidden:T(Y.zone),className:Ye("absolute inset-0",Ee?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(j3,{mode:k.mode,sharedSurface:Re,docking:Ie??null,surfaceMounted:Ge})})},k.id)})]})},I3={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},N3=()=>{const t=qe.c(20),{t:e}=gt(),s=Gs(P3),r=Gs(R3),o=c.useRef(null),[a,i]=c.useState(false);let u,d;t[0]!==s?(u=()=>{if(!s){i(false);return}const y=requestAnimationFrame(()=>i(true));return()=>cancelAnimationFrame(y)},d=[s],t[0]=s,t[1]=u,t[2]=d):(u=t[1],d=t[2]),c.useEffect(u,d);let l,f;if(t[3]!==s?(l=()=>{if(!s)return;const y=C=>{const S=o.current;S&&(S.style.transform=`translate(${C.clientX+12}px, ${C.clientY+12}px)`)};return window.addEventListener("pointermove",y),()=>window.removeEventListener("pointermove",y)},f=[s],t[3]=s,t[4]=l,t[5]=f):(l=t[4],f=t[5]),c.useEffect(l,f),!s)return null;const m=a?"opacity-100":"opacity-0";let p;t[6]!==m?(p=Ye("absolute inset-0 bg-surface-overlay/40 transition-opacity duration-150 ease-out motion-reduce:transition-none",m),t[6]=m,t[7]=p):p=t[7];let h;t[8]!==p?(h=n.jsx("div",{className:p}),t[8]=p,t[9]=h):h=t[9];let x;t[10]!==s.frames||t[11]!==r||t[12]!==e?(x=Ua.map(y=>{const C=s.frames[y];if(C.width<=0||C.height<=0)return null;const S=r===y;return n.jsx("div",{className:Ye("absolute flex items-center justify-center rounded-[10px] border transition-colors duration-100",S?"border-primary bg-background/90 text-foreground shadow-sm":"border-border bg-background/80 text-muted-foreground"),style:{left:C.left,top:C.top,width:C.width,height:C.height},children:n.jsx("span",{className:"typography-ui-label",children:e(I3[y])})},y)}),t[10]=s.frames,t[11]=r,t[12]=e,t[13]=x):x=t[13];let g;t[14]!==s.label?(g=n.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:s.label}),t[14]=s.label,t[15]=g):g=t[15];let v;return t[16]!==h||t[17]!==x||t[18]!==g?(v=yc.createPortal(n.jsxs("div",{className:"pointer-events-none fixed inset-0 z-[60]","aria-hidden":"true",children:[h,x,g]}),document.body),t[16]=h,t[17]=x,t[18]=g,t[19]=v):v=t[19],v};function P3(t){return t.drag}function R3(t){return t.hovered}const nc=320,D3=({rowWidth:t,leftWidth:e,rightWidth:s,sidebarWidth:r,opening:o})=>{let a=t-e-s;if(a>=nc)return{collapseSidebar:false,displace:null};const i=r!==null;if(i&&(a+=r),a>=nc)return{collapseSidebar:i,displace:null};const u=o==="left"?"right":"left";return{collapseSidebar:i,displace:(u==="left"?e:s)>0?u:null}},_3=({directoryKey:t,folded:e,readRowWidth:s})=>{const r=v=>{const y=v.contextPanelByDirectory[t];return{left:Qn(y,v.contextSurfaceZones,"left"),right:Qn(y,v.contextSurfaceZones,"right")}},o=(v,y,C)=>{const S=v.contextPanelByDirectory[t];return(C&&S?to(S,v.contextSurfaceZones,y):null)?v.contextZoneSizes[y]??Va:0},a=v=>{const y=v.contextPanelByDirectory[t];return y?Ua.some(C=>lr(y,C).expanded&&Vf(y,v,C)):false};let i=null,u=false,d=r(K.getState()),l=a(K.getState());const f=v=>{e.current=v,K.getState().setSidebarFoldedForExpandedZone(v==="expanded")},m=v=>{u=true,K.getState().setSidebarOpen(v),u=false},p=()=>{f(null),K.getState().isSidebarOpen||m(true)};!e.current&&K.getState().sidebarFoldedForExpandedZone&&(e.current="expanded");const h=e.current;h&&!(h==="expanded"?l:d[h])&&p(),!e.current&&l&&K.getState().isSidebarOpen&&(f("expanded"),m(false));const x=(v,y,C)=>{const S=s();if(!S)return;const N=e.current==="expanded",F=D3({rowWidth:N?S-v.sidebarWidth:S,leftWidth:o(v,"left",C.left),rightWidth:o(v,"right",C.right),sidebarWidth:v.isSidebarOpen||N?v.sidebarWidth:null,opening:y});if(F.displace){const _=lr(v.contextPanelByDirectory[t],F.displace).activeTabId;_&&(i={side:F.displace,by:y,tabId:_})}F.collapseSidebar&&(f(y),v.isSidebarOpen&&m(false)),F.displace&&v.closeContextZone(t,F.displace)},g=v=>{if(i?.side===v){e.current===v&&f(i.by);return}const y=i?.by===v?i:null;y&&(i=null),e.current===v&&(y?f(y.side):p()),y&&K.getState().setActiveContextPanelTab(t,y.tabId)};return K.subscribe((v,y)=>{v.isSidebarOpen!==y.isSidebarOpen&&!u&&f(null);const C=r(v),S=a(v),N=d,F=l;d=C,l=S;const _=["left","right"],M=_.filter(T=>C[T]&&!N[T]),B=_.filter(T=>!C[T]&&N[T]);for(const T of B){const I=T==="left"?"right":"left";M.includes(I)&&(e.current===T&&f(I),i?.by===T&&(i=null))}for(const T of B)g(T);for(const T of M)x(v,T,C);S&&!F&&v.isSidebarOpen?(f("expanded"),m(false)):!S&&F&&e.current==="expanded"&&p()})},A3=()=>{const t=qe.c(5),e=Zs();let s;t[0]!==e?(s=e?ds(e):"",t[0]=e,t[1]=s):s=t[1];const r=s,o=c.useRef(null);let a,i;return t[2]!==r?(a=()=>{if(r)return _3({directoryKey:r,folded:o,readRowWidth:O3})},i=[r],t[2]=r,t[3]=a,t[4]=i):(a=t[3],i=t[4]),c.useEffect(a,i),null};function O3(){return document.querySelector("[data-workspace-row]")?.clientWidth}const M3=t=>{const e=qe.c(54),{open:s,onOpenChange:r}=t,{t:o}=gt(),a=K(F3),i=K(L3),u=K($3),d=K(B3),l=K(z3),f=ii(),m=K(S1);let p;if(e[0]!==a||e[1]!==f||e[2]!==m){let V;e[4]!==m?(V=J=>m||J.id!=="workflows",e[4]=m,e[5]=V):V=e[5],p=ma(a,f).filter(V),e[0]=a,e[1]=f,e[2]=m,e[3]=p}else p=e[3];const h=p,x=u.length===0;let g;if(e[6]!==u||e[7]!==h){let V;e[9]!==u?(V=J=>u.includes(J.id),e[9]=u,e[10]=V):V=e[10],g=h.every(V),e[6]=u,e[7]=h,e[8]=g}else g=e[8];const v=g,y=c.useRef(false);let C;e[11]!==u||e[12]!==h||e[13]!==o?(C=h.map((V,J)=>({id:V.id,label:V.label??o(V.labelKey),visible:!u.includes(V.id),groupStart:J>0&&sn(h[J-1])!==sn(V)})),e[11]=u,e[12]=h,e[13]=o,e[14]=C):C=e[14];const S=C;let N;e[15]!==a||e[16]!==f||e[17]!==i?(N=V=>{const J=ma(V,f).map(W3).filter(G=>V.includes(G)),W=new Set(J);i([...J,...a.filter(G=>!W.has(G))])},e[15]=a,e[16]=f,e[17]=i,e[18]=N):N=e[18];const F=N;let _;e[19]!==r?(_=(V,J)=>{if(!V&&J.reason==="escape-key"&&y.current){J.cancel(),J.allowPropagation();return}y.current=false,r(V)},e[19]=r,e[20]=_):_=e[20];let M;e[21]===Symbol.for("react.memo_cache_sentinel")?(M=V=>{y.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(V.key)&&V.preventBaseUIHandler()},e[21]=M):M=e[21];let B;e[22]!==o?(B=o("contextRail.configure.dialogTitle"),e[22]=o,e[23]=B):B=e[23];let T;e[24]!==B?(T=n.jsx(pr,{children:B}),e[24]=B,e[25]=T):T=e[25];let I;e[26]!==o?(I=o("contextRail.configure.dialogDescription"),e[26]=o,e[27]=I):I=e[27];let b;e[28]!==I?(b=n.jsx(mr,{children:I}),e[28]=I,e[29]=b):b=e[29];let w;e[30]!==b||e[31]!==T?(w=n.jsxs(fr,{children:[T,b]}),e[30]=b,e[31]=T,e[32]=w):w=e[32];let j;e[33]!==o?(j=o("contextRail.configure.dragInstructions"),e[33]=o,e[34]=j):j=e[34];let R;e[35]===Symbol.for("react.memo_cache_sentinel")?(R=V=>{y.current=V},e[35]=R):R=e[35];let L;e[36]!==F||e[37]!==S||e[38]!==d||e[39]!==j?(L=n.jsx(Qp,{items:S,onVisibleChange:d,onReorder:F,settingsItemPrefix:"layout.context-rail.surface.",dragInstructions:j,onDraggingChange:R}),e[36]=F,e[37]=S,e[38]=d,e[39]=j,e[40]=L):L=e[40];let E;e[41]!==x||e[42]!==v||e[43]!==l||e[44]!==o?(E=x?null:n.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[v?n.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):n.jsx("span",{}),n.jsx(yt,{variant:"link",size:"xs",onClick:()=>l([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[41]=x,e[42]=v,e[43]=l,e[44]=o,e[45]=E):E=e[45];let D;e[46]!==w||e[47]!==L||e[48]!==E?(D=n.jsxs(ur,{className:"max-w-md",onKeyDown:M,children:[w,L,E]}),e[46]=w,e[47]=L,e[48]=E,e[49]=D):D=e[49];let U;return e[50]!==s||e[51]!==D||e[52]!==_?(U=n.jsx(dr,{open:s,onOpenChange:_,children:D}),e[50]=s,e[51]=D,e[52]=_,e[53]=U):U=e[53],U};function F3(t){return t.contextRailOrder}function L3(t){return t.setContextRailOrder}function $3(t){return t.contextRailHiddenSurfaces}function B3(t){return t.setContextRailSurfaceVisible}function z3(t){return t.setContextRailHiddenSurfaces}function W3(t){return t.id}const Ju=150,V3=500,U3=[],H3=t=>{const e=qe.c(70),{surface:s,isActive:r,showActivityDot:o,label:a,description:i,badgeCount:u,badgeAriaLabel:d,badgeDescription:l,listening:f,orderNumber:m,showOrderNumber:p,onSelect:h}=t,x=f===void 0?false:f,g=K(G3);let v;e[0]!==g?(v=Ga("switch_context_surface",g),e[0]=g,e[1]=v):v=e[1];const y=v;let C;e[2]!==m||e[3]!==y?(C=y&&y!==Gc&&m!=null&&m<=10?bs(`${y}+${m===10?"0":m}`):void 0,e[2]=m,e[3]=y,e[4]=C):C=e[4];const S=C;let N;e[5]!==s.id?(N={id:s.id},e[5]=s.id,e[6]=N):N=e[6];const{attributes:F,listeners:_,setNodeRef:M,transform:B,transition:T,isDragging:I}=Zd(N),b=u!=null&&u>0;let w;e[7]!==B?(w=Yd.Translate.toString(B),e[7]=B,e[8]=w):w=e[8];let j;e[9]!==w||e[10]!==T?(j={transform:w,transition:T},e[9]=w,e[10]=T,e[11]=j):j=e[11];const R=I&&"z-10 opacity-70";let L;e[12]!==R?(L=Ye("relative",R),e[12]=R,e[13]=L):L=e[13];let E;e[14]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx("div",{}),e[14]=E):E=e[14];let D;e[15]!==h||e[16]!==s?(D=()=>h(s),e[15]=h,e[16]=s,e[17]=D):D=e[17];const U=d??a,V=s.id,J=r?"oc-selected text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground";let W;e[18]!==J?(W=Ye("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",J),e[18]=J,e[19]=W):W=e[19];let G;e[20]!==s.icon||e[21]!==s.iconSrc?(G=n.jsx(li,{icon:s.icon,iconSrc:s.iconSrc,className:"h-[17px] w-[17px]"}),e[20]=s.icon,e[21]=s.iconSrc,e[22]=G):G=e[22];let le;e[23]!==b||e[24]!==x||e[25]!==m||e[26]!==o||e[27]!==p?(le=p&&m!=null?n.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:m===10?"0":m}):x?n.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-error)]"}):b?n.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?n.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[23]=b,e[24]=x,e[25]=m,e[26]=o,e[27]=p,e[28]=le):le=e[28];let $;e[29]!==F||e[30]!==r||e[31]!==_||e[32]!==s.id||e[33]!==D||e[34]!==U||e[35]!==W||e[36]!==G||e[37]!==le?($=n.jsx(Pt,{asChild:true,children:n.jsxs("button",{type:"button",...F,..._,onClick:D,"aria-label":U,"aria-pressed":r,"data-context-surface":V,className:W,children:[G,le]})}),e[29]=F,e[30]=r,e[31]=_,e[32]=s.id,e[33]=D,e[34]=U,e[35]=W,e[36]=G,e[37]=le,e[38]=$):$=e[38];let re;e[39]!==g||e[40]!==s.id||e[41]!==S?(re=s.id==="terminal"?bs(Es("toggle_terminal",g),""):S,e[39]=g,e[40]=s.id,e[41]=S,e[42]=re):re=e[42];let H;e[43]!==a||e[44]!==re?(H=n.jsx(qs,{label:a,shortcut:re}),e[43]=a,e[44]=re,e[45]=H):H=e[45];let P;e[46]!==i?(P=n.jsx("span",{className:"typography-micro text-muted-foreground",children:i}),e[46]=i,e[47]=P):P=e[47];let ee;e[48]!==l?(ee=l?n.jsx("span",{className:"typography-micro text-muted-foreground",children:l}):null,e[48]=l,e[49]=ee):ee=e[49];let oe;e[50]!==s.id?(oe=s.id==="context"?n.jsx(tu,{}):null,e[50]=s.id,e[51]=oe):oe=e[51];let de;e[52]!==H||e[53]!==P||e[54]!==ee||e[55]!==oe?(de=n.jsx(Dt,{side:"left",sideOffset:8,className:"max-w-72 break-words",children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[H,P,ee,oe]})}),e[52]=H,e[53]=P,e[54]=ee,e[55]=oe,e[56]=de):de=e[56];let he;e[57]!==$||e[58]!==de?(he=n.jsx(yo,{render:E,children:n.jsxs(Rt,{delayDuration:Ju,children:[$,de]})}),e[57]=$,e[58]=de,e[59]=he):he=e[59];let Z;e[60]!==s.mode?(Z=n.jsx(Nr,{children:n.jsx(Uc,{mode:s.mode})}),e[60]=s.mode,e[61]=Z):Z=e[61];let ce;e[62]!==he||e[63]!==Z?(ce=n.jsxs(Ir,{children:[he,Z]}),e[62]=he,e[63]=Z,e[64]=ce):ce=e[64];let ae;return e[65]!==M||e[66]!==ce||e[67]!==j||e[68]!==L?(ae=n.jsx("div",{ref:M,style:j,className:L,children:ce}),e[65]=M,e[66]=ce,e[67]=j,e[68]=L,e[69]=ae):ae=e[69],ae},K3=t=>{if(!t)return{icon:"ticket-2"};const e=P1(t,"line");return e?{icon:e}:{icon:R1,iconSrc:D1(t)}},q3=()=>{const t=qe.c(126),{t:e}=gt(),s=Zs();let r;t[0]!==s?(r=s?ds(s):"",t[0]=s,t[1]=r):r=t[1];const o=r;let a;t[2]!==o?(a=ne=>o?ne.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=a):a=t[3];const i=K(a),u=K(Z3),d=K(X3),l=K(Y3),f=K(J3),m=K(Q3),p=K(ej),h=K(tj),x=K(sj),g=Uf();let v;t[4]!==g?(v=ne=>g.some(Je=>Je.instances.defaultInstance!==null&&ne.entries[Xn({provider:Je.id,instance:Je.instances.defaultInstance})]?.hasChecked===true),t[4]=g,t[5]=v):v=t[5];const y=vn(v),C=vn(rj),S=k1(o||null),N=Wa(S==="none"?null:S??g[0]?.id),F=S==="none"?"pullRequest":N.terminology.changeRequest,{screenWidth:_}=Tn(),M=Pr(),B=s??null;let T;t[6]!==M||t[7]!==B?(T=So(M,B),t[6]=M,t[7]=B,t[8]=T):T=t[8];const I=T,b=j1(I),w=jo(b),{git:j}=Is(),R=Ln(oj),L=Ln(aj);let E,D;t[9]!==R||t[10]!==L||t[11]!==j||t[12]!==b||t[13]!==I?(E=()=>{if(!j||!I||!b||b===I)return;ji(()=>R(b,j));const ne=ts(I),Je=ts(b);return xr.onGitRefreshHint(kt=>{const bt=ts(kt.directory);bt!==ne&&bt!==Je||ji(()=>L(b,j,{silent:true}))})},D=[R,L,j,b,I],t[9]=R,t[10]=L,t[11]=j,t[12]=b,t[13]=I,t[14]=E,t[15]=D):(E=t[14],D=t[15]),c.useEffect(E,D);let U;t[16]!==x?(U=Ga("switch_context_surface",x),t[16]=x,t[17]=U):U=t[17];const V=U,[J,W]=c.useState(false);let G,le;t[18]!==V?(le=()=>{const ne=new Set;let Je=null,kt=false;const bt=ij,_t=()=>{Gi(V,ne)?!kt&&Je===null&&(Je=setTimeout(()=>W(true),V3)):(kt=false,Je!==null&&(clearTimeout(Je),Je=null),W(false))},He=se=>{if(ne.add(se.key.toLowerCase()),bt(se.key)&&Gi(V,ne)){kt=true,Je!==null&&(clearTimeout(Je),Je=null),W(false);return}_t()},pt=se=>{ne.delete(se.key.toLowerCase()),_t()},q=()=>{ne.clear(),kt=false,Je!==null&&(clearTimeout(Je),Je=null),W(false)};return window.addEventListener("keydown",He,true),window.addEventListener("keyup",pt,true),window.addEventListener("blur",q),()=>{window.removeEventListener("keydown",He,true),window.removeEventListener("keyup",pt,true),window.removeEventListener("blur",q),Je!==null&&clearTimeout(Je)}},G=[V],t[18]=V,t[19]=G,t[20]=le):(G=t[19],le=t[20]),c.useEffect(le,G);let $;t[21]===Symbol.for("react.memo_cache_sentinel")?($={activationConstraint:{distance:8}},t[21]=$):$=t[21];let re;t[22]===Symbol.for("react.memo_cache_sentinel")?(re={activationConstraint:{delay:200,tolerance:6}},t[22]=re):re=t[22];const H=Hd(ao(qd,$),ao(Kd,re)),P=ii(),ee=qi(lj),oe=T1(cj),de=qi(dj),he=i?.tabs??U3,Z=C1(he,s||null),ce=E1();let ae;t[23]!==ce?(ae=I1(ce),t[23]=ce,t[24]=ae):ae=t[24];const te=ae;let pe;t[25]!==h||t[26]!==i?(pe=za(i,h),t[25]=h,t[26]=i,t[27]=pe):pe=t[27];const Te=pe,Ae=w?.files.length??0;let Pe;if(t[28]!==l||t[29]!==d||t[30]!==P||t[31]!==te||t[32]!==S||t[33]!==_||t[34]!==C||t[35]!==he||t[36]!==N||t[37]!==Z){let ne;t[39]!==S||t[40]!==N?(ne=Je=>Je.id==="pr"?{...Je,...K3(S==="none"?null:N)}:Je,t[39]=S,t[40]=N,t[41]=ne):ne=t[41],Pe=N1({railOrder:d,hiddenSurfaces:l,isVSCode:zn(),screenWidth:_,tabs:he,sourceControlConnected:C,workflowsShown:Z,receivedPagesShown:te,extras:P}).map(ne),t[28]=l,t[29]=d,t[30]=P,t[31]=te,t[32]=S,t[33]=_,t[34]=C,t[35]=he,t[36]=N,t[37]=Z,t[38]=Pe}else Pe=t[38];const ze=Pe;let Oe;t[42]!==he?(Oe=he.some(uj),t[42]=he,t[43]=Oe):Oe=t[43];const me=Oe;let be,Ce;t[44]!==p||t[45]!==h||t[46]!==y||t[47]!==o||t[48]!==me||t[49]!==Te||t[50]!==C?(be=()=>{!o||!y||C||me||!Te.has("pr")||p(o,fa(h,"pr"))},Ce=[p,h,o,y,me,Te,C],t[44]=p,t[45]=h,t[46]=y,t[47]=o,t[48]=me,t[49]=Te,t[50]=C,t[51]=be,t[52]=Ce):(be=t[51],Ce=t[52]),c.useEffect(be,Ce);const[$e,We]=c.useState(false),_e=c.useRef(null),Ue=c.useRef(null);let Xe;t[53]!==F||t[54]!==ze||t[55]!==e?(Xe=ne=>{const Je=ze.find(bt=>bt.id===ne.active.id),kt=_e.current?.getBoundingClientRect().left;!Je||kt===void 0||(Ue.current?.cancel(),Ue.current=hi({mode:Je.mode,label:Je.label??e(Us(Je.labelKey,F)),from:fa(K.getState().contextSurfaceZones,Je.mode)},bt=>bt.x<kt-16))},t[53]=F,t[54]=ze,t[55]=e,t[56]=Xe):Xe=t[56];const Me=Xe;let ot;t[57]===Symbol.for("react.memo_cache_sentinel")?(ot=()=>{Ue.current?.cancel(),Ue.current=null},t[57]=ot):ot=t[57];const ye=ot;let Ve,lt;t[58]===Symbol.for("react.memo_cache_sentinel")?(Ve=()=>()=>Ue.current?.cancel(),lt=[],t[58]=Ve,t[59]=lt):(Ve=t[58],lt=t[59]),c.useEffect(Ve,lt);let ct;t[60]!==o||t[61]!==P||t[62]!==f?(ct=ne=>{const Je=Ue.current;if(Ue.current=null,Je?.finish(o))return;const{active:kt,over:bt}=ne;if(!bt||kt.id===bt.id)return;const _t=ma(K.getState().contextRailOrder,P),He=De=>{const we=_t.find(rt=>rt.id===De);return we?sn(we):null};if(He(kt.id)!==He(bt.id))return;const pt=_t.map(fj),q=pt.indexOf(kt.id),se=pt.indexOf(bt.id);q===-1||se===-1||f(ob(pt,q,se))},t[60]=o,t[61]=P,t[62]=f,t[63]=ct):ct=t[63];const st=ct;let k;if(t[64]!==ze){k=[];for(const ne of ze){const Je=k.at(-1);Je&&sn(Je[0])===sn(ne)?Je.push(ne):k.push([ne])}t[64]=ze,t[65]=k}else k=t[65];const Y=k;let Ne;t[66]!==ze?(Ne=ne=>{const Je=ze.find(bt=>bt.id===ne.active.id);if(!Je)return ba(ne);const kt=sn(Je);return ba({...ne,droppableContainers:ne.droppableContainers.filter(bt=>{const _t=ze.find(He=>He.id===bt.id);return _t!==void 0&&sn(_t)===kt})})},t[66]=ze,t[67]=Ne):Ne=t[67];const Re=Ne;if(!o)return null;let Ie,Ee,Ge,Be,Ze,et,wt,Qe,dt,at;if(t[68]!==F||t[69]!==Ae||t[70]!==de||t[71]!==Re||t[72]!==o||t[73]!==Y||t[74]!==ee||t[75]!==oe||t[76]!==st||t[77]!==Me||t[78]!==m||t[79]!==J||t[80]!==H||t[81]!==Te||t[82]!==e||t[83]!==u){let ne=0;Qe=_e,t[94]!==e?(dt=e("contextRail.aria.rail"),t[94]=e,t[95]=dt):dt=t[95],at="flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",Ie=Gd,Ee=H,Ge=Re,Be=Me,Ze=ye,et=st,wt=Y.map((Je,kt)=>n.jsxs(c.Fragment,{children:[kt>0?n.jsx("div",{"aria-hidden":"true",className:"h-1.5 shrink-0"}):null,n.jsx(Xd,{items:Je.map(pj),strategy:rb,children:Je.map(bt=>{ne=ne+1;const _t=bt.label??e(Us(bt.labelKey,F)),He=bt.id==="git"&&!u?Ae:0,pt=wn(bt.mode)&&!Te.has(bt.mode)?ee[er(bt.mode)]??0:0,q=He>0?He:pt>0?pt:null,se=q!==null&&He===0,De=wn(bt.mode)&&(oe[er(bt.mode)]??0)>0;return n.jsx(H3,{surface:bt,isActive:Te.has(bt.mode),showActivityDot:false,label:_t,description:e(Us(bt.descriptionKey,F)),badgeCount:q,listening:De,badgeAriaLabel:De?e("contextRail.surface.plugin.listeningAria",{label:_t}):q!==null?e(se?q===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":q===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:_t,count:q}):null,badgeDescription:De?e("contextRail.surface.plugin.listeningTooltip"):q!==null?e(se?q===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":q===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:q}):null,orderNumber:ne,showOrderNumber:J,onSelect:we=>{wn(we.mode)&&de(er(we.mode)),m(o,we.mode)}},bt.id)})})]},sn(Je[0]))),t[68]=F,t[69]=Ae,t[70]=de,t[71]=Re,t[72]=o,t[73]=Y,t[74]=ee,t[75]=oe,t[76]=st,t[77]=Me,t[78]=m,t[79]=J,t[80]=H,t[81]=Te,t[82]=e,t[83]=u,t[84]=Ie,t[85]=Ee,t[86]=Ge,t[87]=Be,t[88]=Ze,t[89]=et,t[90]=wt,t[91]=Qe,t[92]=dt,t[93]=at}else Ie=t[84],Ee=t[85],Ge=t[86],Be=t[87],Ze=t[88],et=t[89],wt=t[90],Qe=t[91],dt=t[92],at=t[93];let z;t[96]!==Ie||t[97]!==Ee||t[98]!==Ge||t[99]!==Be||t[100]!==Ze||t[101]!==et||t[102]!==wt?(z=n.jsx(Ie,{sensors:Ee,collisionDetection:Ge,onDragStart:Be,onDragCancel:Ze,onDragEnd:et,children:wt}),t[96]=Ie,t[97]=Ee,t[98]=Ge,t[99]=Be,t[100]=Ze,t[101]=et,t[102]=wt,t[103]=z):z=t[103];let fe;t[104]!==e?(fe=e("contextRail.configure.open"),t[104]=e,t[105]=fe):fe=t[105];let ke;t[106]===Symbol.for("react.memo_cache_sentinel")?(ke=()=>We(true),t[106]=ke):ke=t[106];let ie;t[107]===Symbol.for("react.memo_cache_sentinel")?(ie=n.jsx(ue,{name:"list-settings",className:"h-[17px] w-[17px]"}),t[107]=ie):ie=t[107];let xe;t[108]!==fe?(xe=n.jsx(Pt,{asChild:true,children:n.jsx("button",{type:"button","aria-label":fe,onClick:ke,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground",children:ie})}),t[108]=fe,t[109]=xe):xe=t[109];let Le;t[110]!==e?(Le=e("contextRail.configure.open"),t[110]=e,t[111]=Le):Le=t[111];let Ke;t[112]!==Le?(Ke=n.jsx(Dt,{side:"left",sideOffset:8,children:Le}),t[112]=Le,t[113]=Ke):Ke=t[113];let ve;t[114]!==xe||t[115]!==Ke?(ve=n.jsxs(Rt,{delayDuration:Ju,children:[xe,Ke]}),t[114]=xe,t[115]=Ke,t[116]=ve):ve=t[116];let je;t[117]!==$e?(je=n.jsx(M3,{open:$e,onOpenChange:We}),t[117]=$e,t[118]=je):je=t[118];let vt;return t[119]!==Qe||t[120]!==dt||t[121]!==at||t[122]!==z||t[123]!==ve||t[124]!==je?(vt=n.jsxs("nav",{ref:Qe,"aria-label":dt,className:at,children:[z,ve,je]}),t[119]=Qe,t[120]=dt,t[121]=at,t[122]=z,t[123]=ve,t[124]=je,t[125]=vt):vt=t[125],vt};function G3(t){return t.shortcutOverrides}function Z3(t){return t.workStatusPanelVisible}function X3(t){return t.contextRailOrder}function Y3(t){return t.contextRailHiddenSurfaces}function J3(t){return t.setContextRailOrder}function Q3(t){return t.openContextSurface}function ej(t){return t.closeContextZone}function tj(t){return t.contextSurfaceZones}function sj(t){return t.shortcutOverrides}function nj(t){return t.status?.status==="connected"}function rj(t){return Object.values(t.entries).some(nj)}function oj(t){return t.ensureStatus}function aj(t){return t.fetchStatus}function ij(t){return t.length===1&&t>="0"&&t<="9"}function lj(t){return t.countByGuest}function cj(t){return t.captureCountByGuest}function dj(t){return t.clearBadge}function uj(t){return t.mode==="pr"&&t.targetPath}function fj(t){return t.id}function pj(t){return t.id}const Ds=t=>t?n.jsx("span",{className:"oc-title-rest",children:t}):void 0,Ss=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},mj=()=>{const{t}=gt(),{git:e,sourceControl:s}=Is(),{childStores:r}=_1(),[o,a]=c.useState(false),[i,u]=c.useState(null),[d,l]=c.useState([]),[f,m]=c.useState(false),[p,h]=c.useState(false),[x,g]=c.useState(false),[v,y]=c.useState(false),[C,S]=c.useState(false),[N,F]=c.useState(new Set),_=it(k=>k.getWorktreeMetadata),M=it(k=>k.setNewSessionDraftTarget),B=it(k=>k.setDraftBootstrapPendingDirectory),T=M1,I=B1,b=it(k=>k.deleteSessions),w=it(k=>k.archiveSessions),j=it(k=>k.unarchiveSessions),R=K(k=>k.showDeletionDialog),L=K(k=>k.setShowDeletionDialog),E=qt(k=>k.currentDirectory),D=qt(k=>k.homeDirectory),U=Yt(k=>k.projects),V=Yt(k=>k.activeProjectId),{isMobile:J,isTablet:W,hasTouchInput:G}=Tn(),le=J||W||G,$=c.useMemo(()=>{const Y=(V?U.find(Ne=>Ne.id===V)??null:null)?.path??E;return Ss(Y)},[V,E,U]),re=c.useCallback(k=>{const Ne=Ss(k.projectDirectory)||$;return{id:(U.find(Ie=>Ss(Ie.path)===Ne)??null)?.id??`path:${Ne}`,path:Ne}},[$,U]),H=C&&N.size>0,[P,ee]=c.useState(false),oe=i?.mode==="worktree"?i.worktree??d[0]?.metadata??null:null,de=oe?.path,he=oe?.branch,Z=oe?re(oe).path:null;c.useEffect(()=>{if(ee(false),!de||!Z)return;let k=false;return A1(Z,{path:de,branch:he??""}).then(Y=>{k||ee(Y)}),()=>{k=true}},[he,de,Z]);const ce=c.useMemo(()=>{if(!P)return false;const k=i?.worktree;return k&&typeof k.branch=="string"&&k.branch.trim().length>0?!!k.status?.upstream?.split("/")[0]?.trim():d.length>0&&d.every(({metadata:Y})=>typeof Y.branch=="string"&&Y.branch.trim().length>0&&!!Y.status?.upstream?.split("/")[0]?.trim())},[P,i?.worktree,d]),ae=i?.mode==="worktree",te=v||!ae||!ce,pe=v||!ae,Te=ae?de:void 0,Ae=c.useCallback(k=>Te?O1(r,k):()=>{},[r,Te]),Pe=c.useSyncExternalStore(Ae,()=>Te?Zi(r,Te).length:0),ze=x&&Pe>0,Oe=c.useCallback(k=>{u({sessions:k.sessions,dateLabel:k.dateLabel,mode:k.mode??"session",worktree:k.worktree??null})},[]),me=c.useCallback(()=>{u(null),l([]),m(false),h(false),g(false),y(false),S(false),F(new Set)},[]),be=c.useCallback(async k=>{if(k.sessions.length===0)return;if(k.sessions.length===1){const Ie=k.sessions[0];await T(Ie.id)?Fe.success(t("sessions.sidebar.session.delete.success")):Fe.error(t("sessions.sidebar.session.delete.error"));return}const Y=k.sessions.map(Ie=>Ie.id),{deletedIds:Ne,failedIds:Re}=await b(Y);if(Ne.length>0){const Ie=Re.length>0?Re.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Re.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Re.length}):k.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:k.dateLabel}):void 0;Fe.success(Ne.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Ne.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Ne.length}),{description:Ds(Ie)})}Re.length>0&&Fe.error(Re.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Re.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Re.length}),{description:Ds(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[T,b,t]);c.useEffect(()=>xr.onDirectoryRequest(()=>{a(true)}),[]),c.useEffect(()=>{if(!i){l([]),m(false),h(false),g(false),S(false),F(new Set);return}const k=i.sessions.map(Re=>{const Ie=_(Re.id);return Ie?{session:Re,metadata:Ie}:null}).filter(Re=>!!Re);l(k),m(false),S(false),F(new Set);const Y=new Map;if(i.worktree?.path&&Y.set(Ss(i.worktree.path),i.worktree),k.forEach(({metadata:Re})=>{Re.path&&Y.set(Ss(Re.path),Re)}),Y.size===0){S(true);return}let Ne=false;return(async()=>{const Re=new Map,Ie=new Set;await Promise.all(Array.from(Y.entries()).map(async([Ee,Ge])=>{try{const Be=await Xi(Ge.path);Re.set(Ee,Be),Be?.isDirty&&Ie.add(Ee)}catch{Ge.status&&(Re.set(Ee,Ge.status),Ge.status.isDirty&&Ie.add(Ee))}})).catch(Ee=>{console.warn("Failed to inspect worktree status before deletion:",Ee)}),!Ne&&(F(Ie),S(true),u(Ee=>{if(!Ee?.worktree?.path)return Ee;const Ge=Ss(Ee.worktree.path),Be=Re.get(Ge);if(!Be)return Ee;const Ze=Ee.worktree.status;return Ze?.isDirty===Be.isDirty&&Ze?.ahead===Be.ahead&&Ze?.behind===Be.behind&&Ze?.upstream===Be.upstream?Ee:{...Ee,worktree:{...Ee.worktree,status:Be}}}),l(Ee=>Ee.map(Ge=>{const Be=Ss(Ge.metadata.path),Ze=Re.get(Be);return Ze?{session:Ge.session,metadata:{...Ge.metadata,status:Ze}}:Ge})))})(),()=>{Ne=true}},[i,_]),c.useEffect(()=>{ce||m(false)},[ce]);const Ce=c.useCallback(async(k,Y,Ne,Re)=>{const Ie=f&&ce,Ee=re(k),Ge=Ss(k.path),Be=Ss(Ee.path);try{await F1(Ee,k,{deleteRemoteBranch:Ie,deleteLocalBranch:Y,remoteName:k.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:s},skipTeardown:Re});const Ze=Qe=>!!(Ge&&Qe&&L1(Ge,Qe)),et=it.getState().newSessionDraft,wt=Ss(et?.directoryOverride);return et?.open&&Ze(wt)&&Be&&(B(null),M({projectId:Ee.id,directoryOverride:Be},{force:true})),Ze(Ss(qt.getState().currentDirectory))&&Be&&qt.getState().setDirectory(Be,{showOverlay:false}),true}catch(Ze){if(Ze instanceof Error&&$1(Ze))throw Ze;return Fe.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Ne,description:Ds(Ze instanceof Error?Ze.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),false}},[ce,f,re,e,B,M,s,t]),$e=c.useCallback((k,Y,Ne,Re)=>{const Ie=f&&ce,Ee=async(Ge,Be)=>{const Ze=Fe.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:Ho(k)}));H1(k.path);try{if(Re){const Qe=()=>Zi(r,k.path),dt=Qe().map(z=>z.id);if(!(await K1({worktreePath:k.path,projectDirectory:re(k).path,readSessions:Qe,removeWorktree:()=>Ce(k,Ne,Ze,Ge)})).removed)return;Yi(dt,{projectId:re(k).id}),Fe.success(t(Ie?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed"),{id:Ze,description:Ds(Ho(k))});return}const et=await q1({sessionIds:Be,removeWorktree:()=>Ce(k,Ne,Ze,Ge),restoreSessions:Qe=>j(Qe,{undo:true}),archiveSessions:async Qe=>Qe.length===1?await I(Qe[0])?{archivedIds:Qe,failedIds:[]}:{archivedIds:[],failedIds:Qe}:w(Qe)});if(!et.removed)return;Yi(Be,{projectId:re(k).id}),Fe.success(t(Ie?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed"),{id:Ze,description:Ds(Ho(k))});const{failedIds:wt}=et.archive;wt.length>0&&Fe.error(wt.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:wt.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:wt.length}),{description:Ds(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(et){Fe.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Ze,description:Ds(et instanceof Error?X1(et,t)??et.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain")),...et instanceof Error?G1(et,t("sessions.sidebar.sessionDialogs.worktree.deleteWithoutTeardown"),()=>{Ee(true,Z1(Be,k.path))}):void 0})}finally{Y1(k.path)}};return Ee(false,Y)},[I,w,ce,r,f,re,Ce,t,j]),We=c.useRef(new Set),_e=c.useCallback(async(k,Y)=>{const Ne=Ss(k.path);if(!We.current.has(Ne)){We.current.add(Ne);try{const Re=await Xi(k.path).catch(()=>{});if(!z1(Re)){Oe({sessions:Y,mode:"worktree",worktree:k});return}await $e(k,Y.map(Ie=>Ie.id),true,false)}finally{We.current.delete(Ne)}}},[Oe,$e]);c.useEffect(()=>xr.onDeleteRequest(k=>{if(!R&&(k.mode??"session")==="session"){be(k);return}if(k.mode==="worktree"&&k.skipDialogIfSafe&&k.worktree){_e(k.worktree,k.sessions);return}Oe(k)}),[Oe,R,be,_e]);const Ue=c.useCallback(async()=>{if(i){y(true);try{if(ae){const k=i.worktree??d[0]?.metadata;if(!k){Fe.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:Ds(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),y(false);return}$e(k,i.sessions.map(Y=>Y.id),p&&P,ze),me();return}if(i.sessions.length===1){const k=i.sessions[0];if(!await T(k.id)){Fe.error(t("sessions.sidebar.session.delete.error")),y(false);return}Fe.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const k=i.sessions.map(Re=>Re.id),{deletedIds:Y,failedIds:Ne}=await b(k);if(Y.length>0){const Re=Ne.length>0?Ne.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Ne.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Ne.length}):i.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:i.dateLabel}):void 0;Fe.success(Y.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Y.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Y.length}),{description:Ds(Re),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(Ne.length>0&&(Fe.error(Ne.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Ne.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Ne.length}),{description:Ds(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),Y.length===0)){y(false);return}}me()}finally{y(false)}}},[P,i,d,p,T,b,me,ae,ze,$e,t]),Xe=i?.worktree??d[0]?.metadata??null;let Me="";if(i?.mode==="worktree"){const k=i.sessions.length;ze?Me=Pe===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinkedKept",{count:Pe}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinkedKept",{count:Pe}):k===0?Me=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):k===1?Me=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:k}):Me=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:k})}else if(i){const k=i.sessions.length;k===1?Me=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):Me=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:k,dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:k})}const ot=i?n.jsxs("div",{className:Ye(ae?"space-y-3":"space-y-2"),children:[i.sessions.length>0&&n.jsxs("div",{className:Ye(ae?"oc-tile rounded-lg p-3":"oc-tile space-y-1.5 rounded-lg p-3"),children:[ae&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"typography-meta font-medium text-foreground",children:i.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i.sessions.length})]}),n.jsxs("ul",{className:Ye(ae?"mt-2 space-y-1":"space-y-0.5"),children:[i.sessions.slice(0,5).map(k=>n.jsxs("li",{className:Ye(ae?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground"),children:[n.jsx("span",{className:Ye(!ae&&"hidden"),children:"\u2022"}),n.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:k.title||t("sessions.sidebar.session.untitled")})]},k.id)),i.sessions.length>5&&n.jsx("li",{className:Ye(ae?"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})})]})]}),ae?n.jsxs("div",{className:"oc-tile space-y-2 rounded-lg p-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ue,{name:"worktree",className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),Xe?.label?n.jsx("span",{className:"typography-micro text-muted-foreground",children:Xe.label}):null]}),n.jsx("p",{className:"typography-micro text-muted-foreground break-all",children:Xe?W1(Xe.path,D):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),H&&n.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):n.jsx("div",{className:"oc-tile rounded-lg p-3",children:n.jsx("p",{className:"typography-meta text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,ye=ae&&P?ce?n.jsxs("button",{type:"button",onClick:()=>{te||m(k=>!k)},disabled:te,"aria-pressed":f,className:Ye("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",te?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[f?n.jsx(ue,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(ue,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):n.jsx("span",{className:"text-xs text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,Ve=ae&&P?n.jsxs("button",{type:"button",onClick:()=>{pe||h(k=>!k)},disabled:pe,"aria-pressed":p,className:Ye("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",pe?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[p?n.jsx(ue,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(ue,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,lt=ae&&Pe>0?n.jsxs("button",{type:"button",onClick:()=>{v||g(k=>!k)},disabled:v,"aria-pressed":x,className:Ye("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",v?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[x?n.jsx(ue,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(ue,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.keepSessions")]}):null,ct=ae?n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col items-start gap-1",children:[lt,Ve,ye]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(yt,{variant:"ghost",onClick:me,disabled:v,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(yt,{variant:"destructive",onClick:Ue,disabled:v,children:t(v?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("button",{type:"button",onClick:()=>L(!R),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":!R,children:[R?n.jsx(ue,{name:"checkbox-blank",className:"size-4"}):n.jsx(ue,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(yt,{variant:"ghost",onClick:me,disabled:v,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(yt,{variant:"destructive",onClick:Ue,disabled:v,children:v?t("sessions.sidebar.sessionDialogs.actions.deleting"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),st=ae?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return n.jsxs(n.Fragment,{children:[le?n.jsx(V1,{open:!!i,onClose:()=>{v||me()},title:st,footer:n.jsx("div",{className:"flex justify-end gap-2",children:ct}),children:n.jsxs("div",{className:"space-y-2 pb-2",children:[Me&&n.jsx("p",{className:"typography-meta text-muted-foreground",children:Me}),ot]})}):n.jsx(dr,{open:!!i,onOpenChange:k=>{if(!k){if(v)return;me()}},children:n.jsxs(ur,{className:Ye(ae?"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:[n.jsxs(fr,{children:[n.jsxs(pr,{className:Ye(ae&&"flex items-center gap-2"),children:[ae&&n.jsx(ue,{name:"delete-bin",className:"h-5 w-5"}),st]}),Me&&n.jsx(mr,{children:Me})]}),ae?n.jsx(ps,{outerClassName:"flex-1 min-h-0",className:"space-y-2",disableHorizontal:true,children:ot}):n.jsx("div",{children:ot}),n.jsx(no,{className:"mt-2 gap-2 pt-1 pb-1",children:ct})]})}),n.jsx(U1,{open:o,onOpenChange:a})]})},Qu=[{pattern:/^dev(:.*)?$/i},{pattern:/^start$/i},{pattern:/^start:(?:dev|preview|serve)(?::.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],hj=/^(?:(?:dev(?:elopment)?|preview|serve)(?: server)?|(?:start|run)\s+(?:dev(?:elopment)?\s+)?(?:server|preview))(?:\s+\([^)]+\))?$/i,gj=/^(?:cd\s+(?:"[^"]+"|'[^']+'|[^\s;&|]+)\s*&&\s*)?(?:npm|yarn|pnpm|bun)\s+(?:run\s+)?(?:--shell=bun\s+)?([^\s;&|]+)(?:\s|$)/i,xj=t=>Qu.some(({pattern:e})=>e.test(t));async function bj(t,e,s){if(!t)return null;const r=vj(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(s){const o=Sj(s);if(o){const a=await kj(t);return{command:`${a==="npm"?"npm run":a==="yarn"?"yarn":a==="pnpm"?"pnpm":a==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await wj(t)){const o=await yj(),a=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${a}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${a}/`}}return null}async function wj(t){const e=`${t}/index.html`,s=await fo(e,t);return typeof s=="string"&&s.trim().length>0}async function yj(){try{const t=await Ms("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),s=typeof e?.port=="number"?e.port:null;return s&&Number.isFinite(s)?s:null}catch{return null}}function vj(t){for(const e of t){const s=gj.exec(e.command.trim())?.[1];if(s&&xj(s)||e.source!=="shared"&&hj.test(e.name.trim()))return e}return null}function Sj(t){for(const{pattern:e}of Qu)for(const s of Object.keys(t))if(e.test(s))return s;return null}async function kj(t){const e=await fo(`${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 s=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of s){const a=await fo(`${t}/${r}`,t);if(typeof a=="string"&&a.trim().length>0)return o}return"npm"}async function fo(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await Ms(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const s=Nc()?.files;if(s?.readFile)try{const r=await s.readFile(t,{optional:true});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await Ms(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function jj(t){try{const e=await fo(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const Tj=/\{(worktree|branch)\}/g,la=63,Cj=new Set(["main","master"]),ef=t=>/\{(worktree|branch)\}/.test(t??""),Ej=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const s=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(s).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},tf=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=la)return e;const s=await Ej(e);return s?`${e.slice(0,la-7).replace(/-+$/,"")}-${s}`:e.slice(0,la).replace(/-+$/,"")},Ij=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},Nj=async(t,e,s)=>{const r=s.includes("{branch}"),o=s.includes("{worktree}")?await t.isLinkedWorktree(e):false;if(!r&&!o)return{branch:null,linkedWorktree:o};const a=await t.getGitStatus(e,{mode:"light"});return{branch:Ij(a.current),linkedWorktree:o}},Pj=async t=>!t.linkedWorktree||!t.branch||Cj.has(t.branch)?"":tf(t.branch.split("/").pop()??""),Rj=t=>{const e=t.lastIndexOf("@"),s=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const o=r.lastIndexOf(":"),a=o>=0?r.slice(0,o):r,i=o>=0?r.slice(o):"",u=a.split(".").map(d=>d.replace(/^-+|-+$/g,"")).filter(Boolean);return`${s}${u.join(".")}${i}`},Dj=async(t,e)=>{const s={worktree:await Pj(e),branch:e.branch?await tf(e.branch):""},r=t.replace(Tj,(d,l)=>s[l]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,a="",i="",u=""]=o;return`${a}${Rj(i)}${u}`},_j=async(t,e,s)=>ef(e)?Dj(e,await Nj(t,s,e)):e,sf="oc.projectActions.selectedAction.v1",Aj=wr(It(),wr(It(),It())),nf=()=>{const t=Cr().getItem(sf);if(t===null)return{};try{const e=Aj.safeParse(JSON.parse(t));return e.success?e.data:{}}catch{return{}}},rc=(t,e=Xt())=>nf()[e]?.[t]??null,Oj=(t,e,s=Xt())=>{const r=nf();r[s]?.[t]!==e&&Cr().setItem(sf,JSON.stringify({...r,[s]:{...r[s],[t]:e}}))},Mj=15e3,Fj=3e3,Lj=t=>{const e=(t||"").trim();if(!e)return null;const s=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(s);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},$j=({projectRef:t,directory:e,allowMobile:s=false})=>{const{t:r}=gt(),{currentTheme:o}=bo(),{terminal:a,runtime:i,git:u}=Is(),d=Zs(),{isMobile:l}=Tn(),f=c.useMemo(()=>As(),[]),m=Li(z=>z.instances),p=Li(z=>z.load),h=K(z=>z.terminalShell),x=K(z=>z.terminalLoginShells.includes(z.terminalShell)),g=K(z=>z.setSettingsPage),v=K(z=>z.setSettingsDialogOpen),y=K(z=>z.setSettingsProjectsSelectedId),C=K(z=>z.openContextPreview),S=Ct(z=>z.ensureDirectory),N=Ct(z=>z.reconcileServerSessions),F=Ct(z=>z.setTabLabel),_=Ct(z=>z.setTabIconKey),M=Ct(z=>z.setActiveTab),B=Ct(z=>z.setConnecting),T=Ct(z=>z.setTabSessionId),I=Ct(z=>z.setTabPurpose),b=Ct(z=>z.allocateActionExecution),w=Ct(z=>z.setTabLifecycle),j=Ct(z=>z.setTabPreviewUrl),R=Ct(z=>z.matchesActionExecution),L=Ct(z=>z.captureStartedActionMutationRevisions),[E,D]=c.useState([]),U=c.useRef(null),[V,J]=c.useState(()=>t?.id?rc(t.id):null),[W,G]=c.useState(false),le=c.useRef({}),$=c.useRef({}),re=c.useRef({}),H=c.useRef(new Set),P=c.useRef(0),[ee,oe]=c.useState({}),de=t?.id??null,he=t?.path??"";c.useEffect(()=>{J(de?rc(de):null)},[de]);const Z=c.useMemo(()=>de?{id:de,path:he}:null,[de,he]);c.useEffect(()=>{f&&p().catch(()=>{})},[f,p]);const ce=c.useCallback(async z=>{await Wn(z)},[]),ae=c.useCallback(async()=>{if(!Z)return;const z=P.current+1;P.current=z,G(true);try{const fe=await Ko(Z);if(P.current!==z)return;U.current=fe;const ke=fe.projectActions;D(ke)}catch{if(P.current!==z)return}finally{P.current===z&&G(false)}},[Z]),te=c.useMemo(()=>qo(e||Z?.path||""),[e,Z?.path]),pe=c.useMemo(()=>qo(Z?.path||""),[Z?.path]),Te=c.useMemo(()=>qo(d||"")||te,[d,te]),Ae=c.useRef(Te);c.useEffect(()=>{Ae.current=Te},[Te]);const Pe=Ct(z=>te?z.getDirectoryState(te):void 0),ze=Ct(z=>pe&&pe!==te?z.getDirectoryState(pe):void 0),Oe=c.useMemo(()=>{const z=te?[{directory:te,state:Pe}]:[];return pe&&pe!==te&&z.push({directory:pe,state:ze}),z},[Pe,te,pe,ze]),me=c.useMemo(()=>{const z=te?[te]:[];return pe&&pe!==te&&z.push(pe),z},[te,pe]),be=c.useCallback(z=>z.id!==pn&&z.runIn==="parent"&&pe||te,[te,pe]),Ce=c.useCallback((z,fe,ke)=>`${z}::${fe}::${ke}`,[]),$e=c.useCallback((z,fe,ke=Ct.getState())=>z?ke.getDirectoryState(z)?.tabs.find(ie=>ie.purpose.type==="project-action"&&ie.purpose.actionId===fe)??null:null,[]),We=c.useMemo(()=>{const z={};for(const{directory:fe,state:ke}of Oe)for(const ie of ke?.tabs??[]){if(ie.purpose.type!=="project-action"||!ie.purpose.executionId||!ie.terminalSessionId||ie.lifecycle==="idle"||ie.lifecycle==="exited")continue;const xe=Nn(fe,ie.purpose.actionId),Le=Ce(fe,ie.purpose.actionId,ie.purpose.executionId);z[xe]={directory:fe,actionId:ie.purpose.actionId,tabId:ie.id,sessionId:ie.terminalSessionId,executionId:ie.purpose.executionId,status:ie.lifecycle==="stopping"?"stopping":ee[Le]?"waiting-for-preview":"running"}}return z},[Ce,ee,Oe]),_e=c.useCallback((z,fe,ke)=>{const ie=Nn(z,fe),xe=Ce(z,fe,ke),Ke=le.current[ie]?.executionId===ke,ve=globalThis.window,je=vt=>{ve?.clearTimeout(re.current[vt]),delete re.current[vt]};Ke&&(delete le.current[ie],je(ie)),$.current[xe]?.(),delete $.current[xe],je(xe),oe(vt=>{if(!vt[xe])return vt;const ne={...vt};return delete ne[xe],ne})},[Ce]),Ue=c.useCallback(z=>{$.current[z]?.(),delete $.current[z]},[]),Xe=c.useCallback(z=>{window.clearTimeout(re.current[z]),delete re.current[z]},[]);c.useEffect(()=>{const z=$.current,fe=re.current;return()=>{for(const ke of Object.keys(z))Ue(ke);for(const ke of Object.keys(fe))Xe(ke)}},[Xe,Ue]),c.useEffect(()=>{const z=new Set(me);for(const fe of Object.values(le.current))z.has(fe.directory)||_e(fe.directory,fe.actionId,fe.executionId);for(const fe of Object.keys($.current)){const ke=fe.split("::",1)[0]??"";z.has(ke)||Ue(fe)}},[_e,Ue,me]);const Me=c.useCallback((z,fe)=>{K.getState().openContextPanelTab(z,{mode:"terminal",targetDirectory:fe===z?null:fe})},[]),ot=c.useMemo(()=>({id:pn,name:r("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:true}),[r]),ye=!l,Ve=c.useMemo(()=>ye?[...E,ot]:E,[E,ot,ye]),lt=c.useMemo(()=>V?Ve.find(z=>z.id===V)??null:null,[Ve,V]);c.useEffect(()=>{ae()},[ae]);const[ct,st]=c.useState(0),k=c.useCallback(()=>(st(z=>z+1),()=>st(z=>z-1)),[]),Y=ct>0;c.useEffect(()=>{if(!Y)return;const z=me.map(fe=>em(a,fe,L,ke=>N(fe,ke.sessions,{startedActionMutationRevisions:ke.startedActionMutationRevisions})));return()=>{for(const fe of z)fe()}},[L,Y,N,a,me]),c.useEffect(()=>{for(const{directory:z,state:fe}of Oe)if(z)for(const ke of fe?.tabs??[]){if(ke.purpose.type!=="project-action")continue;const ie=ke.purpose.actionId,xe=Ve.find(ve=>ve.id===ie),Le=xe?.name??ie,Ke=xe?.icon||"play";ke.label!==Le&&F(z,ke.id,Le),ke.iconKey!==Ke&&_(z,ke.id,Ke)}},[Ve,_,F,Oe]),c.useEffect(()=>{const z=globalThis.window;if(!z)return;const fe=ke=>{const ie=ke.detail;de&&(ie?.projectId&&ie.projectId!==de||ae())};return z.addEventListener(Ji,fe),()=>{z.removeEventListener(Ji,fe)}},[ae,de]),c.useEffect(()=>{const z=ke=>{delete re.current[ke];const ie=le.current[ke];if(!ie||ie.openedUrl)return;const xe=Ce(ie.directory,ie.actionId,ie.executionId),Le=ie.announced;if(Le.length!==0){if(window.clearTimeout(re.current[xe]),delete re.current[xe],ie.openedUrl=true,oe(Ke=>{if(!Ke[xe])return Ke;const ve={...Ke};return delete ve[xe],ve}),Le.length===1){oa(ie.directory,[]),j(ie.directory,ie.tabId,Le[0],{locked:false,autoOpened:true}),C(ie.directory,Le[0]);return}ie.offering=true,oa(ie.directory,Le),K.getState().openContextSurface(ie.directory,"browser"),Fe.info(r("projectActions.toast.multipleServers"))}},fe=()=>{const ke=Ct.getState(),ie=ke.sessions,xe=We;for(const[Le,Ke]of Object.entries(xe)){const je=ie.get(Ke.directory)?.tabs.find(se=>se.id===Ke.tabId);if(!je||je.terminalSessionId!==Ke.sessionId){_e(Ke.directory,Ke.actionId,Ke.executionId);continue}const vt=le.current[Le],ne=vt?.executionId===Ke.executionId?vt:{hostDirectory:Ae.current||Ke.directory,directory:Ke.directory,tabId:Ke.tabId,actionId:Ke.actionId,executionId:Ke.executionId,lastSeenChunkId:null,openedUrl:true,tail:"",openInPreview:false,announced:[],offering:false,proxiedPorts:[]};le.current[Le]=ne;const Je=Ve.find(se=>se.id===Ke.actionId),kt=ke.getBuffer(Ke.directory,Ke.tabId).chunks;if(!Je||kt.length===0)continue;const bt=kt.filter(se=>ne.lastSeenChunkId===null||se.id>ne.lastSeenChunkId);if(bt.length===0)continue;const _t=bt.map(se=>se.data).join(""),He=`${ne.tail}${_t}`;for(const se of om(He))ne.proxiedPorts.includes(se)||ne.proxiedPorts.push(se);if(ne.openInPreview&&(!ne.openedUrl||ne.offering)){const se=am(He,{proxiedPorts:ne.proxiedPorts,namedAddressesReachable:!$i()}),De=ne.announced.length;for(const rt of se)ne.announced.includes(rt)||ne.announced.push(rt);const we=ne.announced.length-De;ne.offering&&we>0?oa(Ke.directory,ne.announced):!ne.openedUrl&&De===0&&ne.announced.length>0&&(window.clearTimeout(re.current[Le]),re.current[Le]=window.setTimeout(()=>z(Le),Fj))}const pt=!ne.openedUrl&&Je.autoOpenUrl===true&&!ne.openInPreview?im(He,{proxiedPorts:ne.proxiedPorts,namedAddressesReachable:!$i()}):null,q=bt[bt.length-1]?.id??ne.lastSeenChunkId;if(ne.lastSeenChunkId=q,ne.tail=He.slice(-512),pt)if(ne.openedUrl=true,ne.openInPreview){const se=xe[Le];se&&(j(se.directory,se.tabId,pt,{locked:false,autoOpened:false,expectedExecutionId:se.executionId}),se.status==="waiting-for-preview"&&oe(De=>{const we=Ce(se.directory,se.actionId,se.executionId);if(!De[we])return De;const rt={...De};return delete rt[we],rt}),window.clearTimeout(re.current[Le]),delete re.current[Le],C(se.directory,pt))}else ce(pt),Fe.success(r("projectActions.toast.openedUrlFromOutput"));le.current[Le]=ne}for(const Le of Object.keys(le.current))if(!xe[Le]){const Ke=le.current[Le],ve=Ke?ie.get(Ke.directory)?.tabs.find(vt=>vt.id===Ke.tabId):void 0;if(ve?.purpose.type==="project-action"&&ve.purpose.executionId===Ke?.executionId&&!!ve.terminalSessionId&&ve.lifecycle!=="idle"&&ve.lifecycle!=="exited")continue;delete le.current[Le],window.clearTimeout(re.current[Le]),delete re.current[Le]}};return fe(),Ct.subscribe((ke,ie)=>{(ke.sessions!==ie.sessions||ke.buffers!==ie.buffers)&&fe()})},[_e,Ae,Ve,Ce,C,ce,We,j,r]),c.useEffect(()=>{for(const{directory:z,state:fe}of Oe)for(const ke of fe?.tabs??[]){if(ke.purpose.type!=="project-action"||!ke.purpose.executionId||!ke.terminalSessionId||ke.lifecycle!=="running")continue;const ie=ke.purpose.actionId,xe=ke.purpose.executionId,Le=Ce(z,ie,xe);if($.current[Le])continue;const Ke=a.connect(ke.terminalSessionId,{onEvent:ve=>{if(!R(z,ke.id,xe))return;ve.type==="snapshot"&&(Ct.getState().replaceBuffer(z,ke.id,ve.data??"",ve.sequence??0,Ti(ve)),ve.status==="running"&&Ct.getState().setTabLifecycle(z,ke.id,"running",{expectedExecutionId:xe}),ve.status==="exited"&&(Ct.getState().setTabLifecycle(z,ke.id,"exited",{expectedExecutionId:xe}),Ct.getState().setTabPurpose(z,ke.id,{type:"project-action",actionId:ie,executionId:null}),_e(z,ie,xe)));const je=ve.type==="data"?ve.data??"":"";je&&Ct.getState().appendToBuffer(z,ke.id,je,ve.sequence,ve.replayData),ve.type==="exit"&&(Ct.getState().setTabLifecycle(z,ke.id,"exited",{expectedExecutionId:xe}),Ct.getState().setTabPurpose(z,ke.id,{type:"project-action",actionId:ie,executionId:null}),_e(z,ie,xe))},onError:(ve,je)=>{!je||!R(z,ke.id,xe)||(Ct.getState().setTabLifecycle(z,ke.id,"exited",{expectedExecutionId:xe}),Ct.getState().setTabSessionId(z,ke.id,null,{expectedExecutionId:xe}),Ct.getState().setTabPurpose(z,ke.id,{type:"project-action",actionId:ie,executionId:null}),_e(z,ie,xe))}},z);$.current[Le]=Ke.close}},[_e,Ce,R,a,Oe]);const Ne=c.useCallback(async z=>{const fe=be(z);if(!fe)throw new Error(r("projectActions.error.noActiveDirectory"));const ke=Nn(fe,z.id);S(fe);const ie=Ct.getState(),xe=$e(fe,z.id,ie),Le=xe?.id??ie.createTab(fe);F(fe,Le,z.name),_(fe,Le,z.icon||"play"),xe||I(fe,Le,{type:"project-action",actionId:z.id,executionId:null}),M(fe,Le);const ve=Ct.getState().getDirectoryState(fe)?.tabs.find(je=>je.id===Le);return{executionDirectory:fe,key:ke,tabId:Le,sessionId:ve?.terminalSessionId??null,executionId:ve?.purpose.type==="project-action"?ve.purpose.executionId:null}},[S,be,$e,M,_,F,I,r]),Re=c.useCallback(async z=>{if(i.isVSCode||!s&&l)return;if(!te){Fe.error(r("projectActions.error.noActiveDirectoryForAction"));return}const fe=Nn(be(z),z.id),ke=We[fe];if(ke&&ke.status==="running"||H.current.has(fe))return;H.current.add(fe);let ie=null;try{const xe=z.id===pn?await(async()=>{const nt=Z??{id:"",path:te},[ut,Nt]=await Promise.all([Ko(nt),jj(te)]),Et=await bj(te,ut.projectActions,Nt);if(!Et)throw new Error(r("contextPanel.preview.noDevServer"));return ut.projectActions.find(Wt=>Wt.id===Et.actionId)?.source==="shared"&&!await Qi(nt,ut)?null:{id:pn,name:r("projectActions.actions.autoDiscover"),command:Et.command,icon:"scan-2",autoOpenUrl:true,openUrl:Et.previewUrlHint||""}})():z;if(!xe)return;const Le=xe.autoOpenUrl===true&&(xe.openUrl||"").trim().length>0,Ke=!Le&&z.id!==pn&&K.getState().terminalOpenOnProjectAction,ve=Ae.current||te,{executionDirectory:je,key:vt,tabId:ne}=await Ne(xe),Je=tm(xe.command);if(!Je)throw new Error(r("projectActions.error.failedToRunAction"));const kt=xe.autoOpenUrl===true&&f&&(xe.desktopOpenSshForward||"").trim().length>0,bt=xe.autoOpenUrl&&xe.openUrl||"";let _t=false;const He=ef(bt)?await _j(u,bt,je).catch(()=>(_t=true,"")):bt,pt=xe.autoOpenUrl?Lj(He):null,q=xe.autoOpenUrl&&f?J1(xe.desktopOpenSshForward,m):null;if(a.listSessions){const nt=$e(je,xe.id);if(nt?.purpose.type==="project-action"&&nt.purpose.executionId===null){const ut=await sm(a,je,{captureStartedActionMutationRevisions:L});ut&&N(je,ut.sessions,{startedActionMutationRevisions:ut.startedActionMutationRevisions})}}const se=$e(je,xe.id);let De,we;if(se?.lifecycle==="running"&&se.terminalSessionId&&se.purpose.type==="project-action"&&se.purpose.executionId)De=se.terminalSessionId,we=se.purpose.executionId;else{const nt=se?.purpose.type==="project-action"?se.purpose.executionId:null;nt&&_e(je,xe.id,nt);const ut=b(je,ne,xe.id);if(!ut)throw new Error(r("projectActions.error.failedToCreateTerminalSession"));ie={directory:je,tabId:ne,id:ut},B(je,ne,true,{expectedExecutionId:ut});const Nt=await nm({terminal:a,createOptions:{cwd:je,shell:h,loginShell:x,themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground},command:Je,isRunStillExpected:()=>R(je,ne,ut),purpose:{type:"project-action",actionId:xe.id,executionId:ut}});if(!R(je,ne,ut)){Nt.sessionId===ut&&await a.close(Nt.sessionId).catch(()=>{});return}we=Nt.purpose?.type==="project-action"?Nt.purpose.executionId:ut,De=Nt.sessionId,I(je,ne,{type:"project-action",actionId:xe.id,executionId:we}),T(je,ne,De,{expectedExecutionId:we}),B(je,ne,false,{expectedExecutionId:we})}Ke&&ve&&Me(ve,je),le.current[vt]={hostDirectory:ve,directory:je,tabId:ne,actionId:xe.id,executionId:we,lastSeenChunkId:null,openedUrl:!!q||!!pt||Le,tail:"",openInPreview:xe.id===pn,announced:[],offering:false,proxiedPorts:[]};const rt=Ce(je,xe.id,we);B(je,ne,true,{expectedExecutionId:we});const ft=a.connect(De,{onEvent:nt=>{if(!R(je,ne,we)||nt.purpose?.type==="project-action"&&nt.purpose.executionId!==we)return;nt.type==="snapshot"&&(Ct.getState().replaceBuffer(je,ne,nt.data??"",nt.sequence??0,Ti(nt)),Ct.getState().setConnecting(je,ne,false,{expectedExecutionId:we}),nt.purpose?.type==="project-action"&&Ct.getState().setTabPurpose(je,ne,{type:"project-action",actionId:nt.purpose.actionId,executionId:nt.purpose.executionId}),nt.status==="running"&&Ct.getState().setTabLifecycle(je,ne,"running",{expectedExecutionId:we}),nt.status==="exited"&&(Ct.getState().setTabLifecycle(je,ne,"exited",{expectedExecutionId:we}),Ct.getState().setTabPurpose(je,ne,{type:"project-action",actionId:xe.id,executionId:null}),_e(je,xe.id,we)));const ut=nt.type==="data"?nt.data??"":"";ut&&Ct.getState().appendToBuffer(je,ne,ut,nt.sequence,nt.replayData),nt.type==="exit"&&(Ct.getState().setTabLifecycle(je,ne,"exited",{expectedExecutionId:we}),Ct.getState().setConnecting(je,ne,false,{expectedExecutionId:we}),Ct.getState().setTabPurpose(je,ne,{type:"project-action",actionId:xe.id,executionId:null}),_e(je,xe.id,we))},onError:(nt,ut)=>{R(je,ne,we)&&(Ct.getState().setConnecting(je,ne,false,{expectedExecutionId:we}),ut&&(Ct.getState().setTabLifecycle(je,ne,"exited",{expectedExecutionId:we}),Ct.getState().setTabSessionId(je,ne,null,{expectedExecutionId:we}),Ct.getState().setTabPurpose(je,ne,{type:"project-action",actionId:xe.id,executionId:null}),_e(je,xe.id,we)))}},je);if(!R(je,ne,we)){ft.close();return}$.current[rt]?.(),$.current[rt]=ft.close,window.clearTimeout(re.current[rt]),delete re.current[rt],xe.id===pn&&!pt&&(oe(nt=>({...nt,[rt]:true})),re.current[rt]=window.setTimeout(()=>{delete re.current[rt];const nt=le.current[vt];!nt||nt.executionId!==we||nt.openedUrl||nt.offering||R(je,ne,we)&&(oe(ut=>{if(!ut[rt])return ut;const Nt={...ut};return delete Nt[rt],Nt}),Ct.getState().setActiveTab(je,ne),Me(nt.hostDirectory,je))},Mj)),q?(j(je,ne,null,{locked:true,expectedExecutionId:we}),ce(q),Fe.success(r("projectActions.toast.openedForwardedUrl"))):pt?(j(je,ne,pt,{locked:true,autoOpened:true,expectedExecutionId:we}),C(ve,pt),Fe.success(r("projectActions.toast.openedActionUrl"))):_t?(j(je,ne,null,{locked:true,expectedExecutionId:we}),Fe.error(r("projectActions.error.openUrlTemplateUnresolved"))):Le?(j(je,ne,null,{locked:true,expectedExecutionId:we}),Fe.error(r("projectActions.error.invalidCustomUrlFormat"))):kt?(j(je,ne,null,{locked:true,expectedExecutionId:we}),Fe.error(r("projectActions.error.selectedDesktopSshForwardUnavailable"))):j(je,ne,null,{locked:false,autoOpened:false,expectedExecutionId:we})}catch(xe){if(ie&&R(ie.directory,ie.tabId,ie.id)){const{directory:Le,tabId:Ke,id:ve}=ie;_e(Le,z.id,ve),w(Le,Ke,"exited",{expectedExecutionId:ve}),I(Le,Ke,{type:"project-action",actionId:z.id,executionId:null})}if(xe instanceof Error&&xe.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(xe instanceof Error&&(xe.message==="COMMAND_MODE_UNSUPPORTED"||xe.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Fe.error(r("projectActions.error.failedToCreateTerminalSession"));return}Fe.error(xe instanceof Error?xe.message:r("projectActions.error.failedToRunAction"))}finally{H.current.delete(fe)}},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,Ae,m,Ne,u,s,l,f,te,x,h,ce,C,We,Me,i.isVSCode,be,R,_e,Ce,$e,N,b,L,B,w,I,j,T,Z,r,a]),Ie=c.useCallback(async z=>{const fe=Nn(be(z),z.id),ke=We[fe];ke&&await rm({terminal:a,sessionId:ke.sessionId,isExecutionStillCurrent:()=>R(ke.directory,ke.tabId,ke.executionId),markStopping:()=>{w(ke.directory,ke.tabId,"stopping",{expectedExecutionId:ke.executionId})},restoreRunning:()=>{w(ke.directory,ke.tabId,"running",{expectedExecutionId:ke.executionId})},clearSession:()=>{T(ke.directory,ke.tabId,null,{expectedExecutionId:ke.executionId})},finalizeExit:()=>{w(ke.directory,ke.tabId,"exited",{expectedExecutionId:ke.executionId}),I(ke.directory,ke.tabId,{type:"project-action",actionId:ke.actionId,executionId:null}),_e(ke.directory,ke.actionId,ke.executionId)}})},[_e,be,R,We,w,I,T,a]),Ee=c.useCallback(async z=>{if(z.source==="shared"&&Z){const fe=U.current?.trust.trusted?U.current:await Ko(Z);if(U.current=fe,!await Qi(Z,fe))return;U.current={...fe,trust:{...fe.trust,trusted:true}}}await Re(z)},[Re,Z]),Ge=c.useCallback(z=>We[Nn(be(z),z.id)]??null,[be,We]),Be=(lt&&Ge(lt)?lt:null)??Ve.find(z=>Ge(z)!==null)??lt??Ve[0]??null,Ze=c.useCallback(z=>{const fe=Ge(z);if(fe?.status!=="stopping"){if(fe){Ie(z);return}Ee(z)}},[Ee,Ge,Ie]),et=c.useCallback(z=>{Ee(z)},[Ee]),wt=c.useCallback(z=>{Ie(z)},[Ie]),Qe=c.useCallback(z=>{J(z.id),de&&Oj(de,z.id)},[de]),dt=c.useCallback(()=>{Z?.id&&(y(Z.id),g("projects"),v(true))},[v,g,y,Z?.id]),at=!i.isVSCode&&(s||!l)&&!!Z&&!!te;return c.useMemo(()=>({available:at,actions:at?Ve:[],shown:at?Be:null,isLoading:W,observe:k,runOf:Ge,select:Qe,run:et,stop:wt,toggle:Ze,openSettings:dt}),[at,Ve,W,k,dt,et,Ge,Qe,Be,wt,Ze])},Bj=t=>{const e=qe.c(6);let s,r;e[0]!==t?({children:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=$j(r);let a;return e[3]!==s||e[4]!==o?(a=n.jsx(Q1.Provider,{value:o,children:s}),e[3]=s,e[4]=o,e[5]=a):a=e[5],a},zj=t=>{const e=qe.c(4),{children:s}=t,r=su(),o=Pr(),a=o?.kind==="preparing"?null:r?.projectRef??null,i=o?.kind==="ready"?o.directory:r?.directory??"";let u;return e[0]!==s||e[1]!==i||e[2]!==a?(u=n.jsx(Bj,{projectRef:a,directory:i,children:s}),e[0]=s,e[1]=i,e[2]=a,e[3]=u):u=e[3],u},Wj=2e4,Vj=14400*1e3,Uj=t=>Object.entries(t).map(([e,s])=>`${e}@${s.version}`).sort().join(","),Hj="openchamber.guests.announcedUpdates",Kj=()=>{const{t}=gt(),e=c.useRef(t);e.current=t,c.useEffect(()=>{let s=false;const r=async()=>{const i=Xt();await ex();const u=await lm(false);if(s||!u.ok||Xt()!==i)return;const d=cr.getState();d.applyUpdates(u.updates,d.runtimeKey);const l=cr.getState().guests.filter(g=>u.updates[g.id]),f=Uj(u.updates),m=Cr(),p=`${Hj}:${i}`;if(l.length===0||m.getItem(p)===f)return;m.setItem(p,f);const h=e.current,[x]=l;Fe.info(l.length===1&&x?h("settings.extensions.updates.notice.one",{name:x.name}):h("settings.extensions.updates.notice.many",{count:l.length}),{action:{label:h("settings.extensions.updates.notice.open"),onClick:()=>{const g=K.getState();g.setSettingsPage("extensions"),g.setSettingsDialogOpen(true)}}})};let o;const a=window.setTimeout(()=>{r(),o=window.setInterval(()=>{r()},Vj)},Wj);return()=>{s=true,window.clearTimeout(a),window.clearInterval(o)}},[])},qj=()=>{xr.requestDirectoryDialog()},Gj=()=>{K.getState().setNewWorktreeDialogOpen(true)},Zj=()=>{const t=qt.getState().currentDirectory;if(!t)return false;K.getState().openContextOverview(t)},Xj=()=>{Pd()},Yj=()=>{if(!K.getState().overviewFeatureAvailable)return false;K.getState().setOverviewOpen(true)},Jj=()=>{window.location.reload()},Qj=()=>{const t=K.getState();t.setSessionSwitcherOpen(false),t.setArchivePageOpen(true)},rf=t=>{const e=qt.getState().currentDirectory;if(!e)return false;const s=K.getState();return s.setProjectContextTab(t),s.openContextSurface(e,"notes"),true},e4=()=>rf("notes"),t4=()=>rf("todos"),s4=t=>()=>{cm(t)},n4=t=>()=>{const e=it.getState().currentSessionId,s=qt.getState().currentDirectory;if(!e||!s)return false;const r=di(Rr.getState().ids,s,e)?"sessions.sidebar.session.pin.unpinFailed":"sessions.sidebar.session.pin.pinFailed";dm({directory:s,sessionId:e}).catch(()=>Fe.error(t(r)))},r4=t=>()=>{const e=it.getState().currentSessionId;if(!e)return false;wo(e).then(s=>{if(s.ok){Fe.success(t("sessions.sidebar.session.copyId.success"));return}Fe.error(t("sessions.sidebar.session.copyId.error"))}).catch(()=>Fe.error(t("sessions.sidebar.session.copyId.error")))},o4=t=>()=>{if(!K.getState().sessionWorkEnabled)return false;const e=it.getState().currentSessionId;if(!e)return false;const s=os.getState().activeSessions.find(a=>a.id===e);if(!s||s.parentID)return false;const r=Hs(s)??qt.getState().currentDirectory;if(!r||ho(r)||di(Rr.getState().ids,r,e)||it.getState().worktreeMetadata.get(e)?.pinnedAt!==void 0)return false;const o=Za(s)?"done":"open";tx(e,r,o).catch(()=>Fe.error(t("sessions.sidebar.session.work.updateFailed")))},a4=()=>{K.getState().setSessionSwitcherOpen(false),sx()};function i4(){const t=qe.c(13),{t:e}=gt();let s;t[0]!==e?(s=s4(e),t[0]=e,t[1]=s):s=t[1];let r;t[2]!==e?(r=n4(e),t[2]=e,t[3]=r):r=t[3];let o;t[4]!==e?(o=r4(e),t[4]=e,t[5]=o):o=t[5];let a;t[6]!==e?(a=o4(e),t[6]=e,t[7]=a):a=t[7];let i;t[8]!==s||t[9]!==r||t[10]!==o||t[11]!==a?(i={open_new_worktree_dialog:Gj,add_project:qj,show_context_usage:Zj,show_opencode_status:Xj,open_overview:Yj,reload_ui:Jj,open_archive:Qj,open_notes:e4,open_todos:t4,restart_opencode:s,pin_current_session:r,copy_current_session_id:o,toggle_work_current_session:a,open_multi_run:a4},t[8]=s,t[9]=r,t[10]=o,t[11]=a,t[12]=i):i=t[12],td(i)}function l4(t){const e=[],s=(r,o)=>{const a=ts(r);!a||e.some(i=>i.directory===a)||e.push({directory:a,priority:"selected",reason:o})};return s(t.currentDirectory,"current-directory"),s(t.currentSessionDirectory,"selected-session"),e}const c4=new Map,d4=[],u4=t=>{const e=qe.c(20),{isVSCode:s}=t,r=Sd(),o=Yt(f4),a=qt(p4),i=it(m4);let u;e[0]!==s?(u=M=>s?c4:M.availableWorktreesByProject,e[0]=s,e[1]=u):u=e[1];const d=it(u),l=!s;let f;e[2]!==d||e[3]!==o||e[4]!==l?(f=um(o,d,{includeWorktrees:l}),e[2]=d,e[3]=o,e[4]=l,e[5]=f):f=e[5];const m=f,p=os(h4),h=`session-list-sync:${c.useId()}`;let x,g;e[6]!==h||e[7]!==r||e[8]!==a||e[9]!==i?(x=()=>(r.setBootstrapDemand(h,l4({currentDirectory:a,currentSessionDirectory:i})),()=>r.clearBootstrapDemand(h)),g=[h,r,a,i],e[6]=h,e[7]=r,e[8]=a,e[9]=i,e[10]=x,e[11]=g):(x=e[10],g=e[11]),c.useEffect(x,g);const v=c.useRef(null);let y,C;e[12]!==s||e[13]!==m?(y=()=>{const M=new Set(m),B=v.current;v.current=M;const T=B?[...M].filter(I=>!B.has(I)):s?[...M]:[];T.length&&Rd(T,ha())},C=[s,m],e[12]=s,e[13]=m,e[14]=y,e[15]=C):(y=e[14],C=e[15]),c.useEffect(y,C);let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=[],e[16]=S):S=e[16],c.useEffect(g4,S);const N=p!=null,F=p??d4;let _;e[17]!==F||e[18]!==N?(_={enabled:true,hasAuthoritativeGlobalSessions:N,sessions:F},e[17]=F,e[18]=N,e[19]=_):_=e[19],fm(_)};function f4(t){return t.projects}function p4(t){return t.currentDirectory}function m4(t){return t.currentSessionDirectory}function h4(t){return t.authoritativeSessions}function g4(){let t=null,e=false;const s=new Set,r=$n(o=>{if(o.type==="scheduled-task-ran")e=true;else if(o.type==="session-created")s.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=false,s.clear(),nx(ha());return}const a=[...s];s.clear(),a.length&&Rd(a,ha())},500)});return()=>{t&&clearTimeout(t),r()}}const x4=()=>Vt(()=>import("./SettingsWindow-D2K9vSYk.js"),__vite__mapDeps([236,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,237,238,239,221,222,223,224,203,231,201,188,189,240,241,211,230,216,242,243,244])).then(t=>t.SettingsWindow),b4=()=>Vt(()=>import("./CommandPalette-D4bXVkJf.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,244,210,181,182,183,208,209,211])).then(t=>t.CommandPalette),w4=()=>Vt(()=>import("./HelpDialog-DjficTGt.js"),__vite__mapDeps([246,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),y4=()=>Vt(()=>import("./ProjectActionsDialog-C5q25ipO.js"),__vite__mapDeps([247,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,208,209,210,211])).then(t=>t.ProjectActionsDialog),v4=()=>Vt(()=>import("./OpenCodeStatusDialog-DtnVfNI4.js"),__vite__mapDeps([248,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),S4=()=>Vt(()=>import("./RunOverview-BDblAbDp.js"),__vite__mapDeps([249,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),k4=()=>Vt(()=>import("./ScheduledTasksDialog-NDtZLq5t.js"),__vite__mapDeps([250,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,234,251,252,253])).then(t=>t.ScheduledTasksDialog),j4=()=>Vt(()=>import("./ArchiveView-0QjF07oK.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,255])).then(t=>t.ArchiveView),T4=()=>Vt(()=>import("./IntegrationsCatalogView-BvS1pCRR.js"),__vite__mapDeps([256,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,238])).then(t=>t.IntegrationsCatalogView),C4=()=>Vt(()=>import("./UsageStatsView-CLJFagDC.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])).then(t=>t.UsageStatsView),E4=()=>Vt(()=>import("./SourceBoardView-CKJDJ2f4.js"),__vite__mapDeps([258,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),I4=()=>Vt(()=>import("./OverviewView-BXMN0Z8_.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,181,182,183])).then(t=>t.OverviewView),N4=()=>Vt(()=>import("./WorktreesView-DyZy4OjB.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,255])).then(t=>t.WorktreesView),P4=()=>Vt(()=>import("./SpacesView-DFcnInBv.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,242,181,182,183])).then(t=>t.SpacesView),R4=()=>Vt(()=>import("./SpaceAccessDialog-G331hiT_.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,263])).then(t=>t.SpaceAccessDialog),D4=()=>Vt(()=>import("./SpaceApplyDialog-x0rDuJEc.js"),__vite__mapDeps([264,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),_4=()=>Vt(()=>import("./SpaceSetupOutput-BEXQGXPw.js"),__vite__mapDeps([265,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,263])).then(t=>t.SpaceSetupOutputDialog),Bs=()=>K.getState().closeMainSurfaces(),rs=t=>{const e=qe.c(2),{needed:s,load:r,onFailure:o}=t,a=Eo(s,r,o);let i;return e[0]!==a?(i=a?n.jsx(a,{}):null,e[0]=a,e[1]=i):i=e[1],i},of=c.memo(t=>{const e=qe.c(12),{isMobile:s}=t,r=K(O4),o=!r&&!s,a=vo();let i;e[0]!==o||e[1]!==a?(i={enabled:o,layoutAnimationMs:a},e[0]=o,e[1]=a,e[2]=i):i=e[2];const u=Ww(i),[d,l]=c.useState(null);let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Mw,{actionsSlotRef:l}),e[3]=f):f=e[3];const m=r||u.state!==false;let p;e[4]!==d||e[5]!==m?(p=n.jsx(pm,{isVisible:m,listControlsSlot:d}),e[4]=d,e[5]=m,e[6]=p):p=e[6];let h;return e[7]!==s||e[8]!==r||e[9]!==u||e[10]!==p?(h=n.jsx(Ow,{isOpen:r,isMobile:s,className:"border-border",topBar:f,peek:u,children:p}),e[7]=s,e[8]=r,e[9]=u,e[10]=p,e[11]=h):h=e[11],h});of.displayName="LeftSidebar";const A4=()=>{const t=qe.c(114);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:false},t[0]=e):e=t[0],u4(e),i4(),mm();const s=K(M4),r=K(F4),o=K(L4),a=K($4);let i;t[1]!==a?(i=()=>a(false),t[1]=a,t[2]=i):i=t[2];const u=Eo(o,x4,i),d=K(B4),l=K(z4),f=K(W4),m=K(V4),p=K(U4),h=K(H4),x=K(K4),g=K(q4),v=K(G4),y=K(Z4),C=K(X4),S=K(Y4),N=K(J4),F=yn(Q4),_=yn(e5),M=yn(t5),B=K(s5),T=rx();let I;if(t[3]!==T||t[4]!==B){let dt;t[6]!==B?(dt=at=>at.id===B,t[6]=B,t[7]=dt):dt=t[7],I=T.find(dt),t[3]=T,t[4]=B,t[5]=I}else I=t[5];const b=I;let w,j;t[8]!==b||t[9]!==B?(w=()=>{B&&!b&&K.getState().setOpenGuestPage(null)},j=[B,b],t[8]=b,t[9]=B,t[10]=w,t[11]=j):(w=t[10],j=t[11]),c.useEffect(w,j);let R;t[12]===Symbol.for("react.memo_cache_sentinel")?(R=[],t[12]=R):R=t[12],c.useEffect(r5,R);let L;t[13]===Symbol.for("react.memo_cache_sentinel")?(L=[],t[13]=L):L=t[13],c.useEffect(o5,L);const E=l||f||m||p||h||x||!!g||v||d||!!b,D=c.useRef(null);let U,V;t[14]!==E?(U=()=>{if(E)return Ka(a5,D,1)},V=[E],t[14]=E,t[15]=U,t[16]=V):(U=t[15],V=t[16]),c.useEffect(U,V);let J,W;t[17]!==E?(W=()=>{Dd(E)},J=[E],t[17]=E,t[18]=J,t[19]=W):(J=t[18],W=t[19]),c.useLayoutEffect(W,J);let G;t[20]===Symbol.for("react.memo_cache_sentinel")?(G=[],t[20]=G):G=t[20],c.useEffect(l5,G);let le;t[21]===Symbol.for("react.memo_cache_sentinel")?(le=[],t[21]=le):le=t[21],c.useEffect(d5,le);const{isMobile:$}=Tn();hm(),Kj();let re,H;t[22]!==$||t[23]!==r?(re=()=>{K.getState().isMobile!==$&&r($)},H=[$,r],t[22]=$,t[23]=r,t[24]=re,t[25]=H):(re=t[24],H=t[25]),c.useEffect(re,H);let P;t[26]!==y?(P=n.jsx(rs,{needed:y,load:b4,onFailure:u5}),t[26]=y,t[27]=P):P=t[27];let ee;t[28]!==C?(ee=n.jsx(rs,{needed:C,load:w4,onFailure:f5}),t[28]=C,t[29]=ee):ee=t[29];let oe;t[30]!==S?(oe=n.jsx(rs,{needed:S,load:y4,onFailure:p5}),t[30]=S,t[31]=oe):oe=t[31];let de;t[32]!==N?(de=n.jsx(rs,{needed:N,load:v4,onFailure:m5}),t[32]=N,t[33]=de):de=t[33];let he,Z;t[34]===Symbol.for("react.memo_cache_sentinel")?(he=n.jsx(xm,{}),Z=n.jsx(mj,{}),t[34]=he,t[35]=Z):(he=t[34],Z=t[35]);let ce;t[36]!==F||t[37]!==_||t[38]!==M||t[39]!==s?(ce=s?n.jsxs(n.Fragment,{children:[n.jsx(rs,{needed:F,load:R4,onFailure:h5}),n.jsx(bm,{}),n.jsx(rs,{needed:_,load:D4,onFailure:g5}),n.jsx(wm,{}),n.jsx(rs,{needed:M,load:_4,onFailure:x5})]}):null,t[36]=F,t[37]=_,t[38]=M,t[39]=s,t[40]=ce):ce=t[40];let ae;t[41]===Symbol.for("react.memo_cache_sentinel")?(ae=n.jsx(Vw,{}),t[41]=ae):ae=t[41];let te;t[42]!==$?(te=n.jsx(of,{isMobile:$}),t[42]=$,t[43]=te):te=t[43];let pe;t[44]===Symbol.for("react.memo_cache_sentinel")?(pe=n.jsx(Aw,{}),t[44]=pe):pe=t[44];let Te;t[45]===Symbol.for("react.memo_cache_sentinel")?(Te=n.jsx(ra,{zone:"left"}),t[45]=Te):Te=t[45];const Ae=E&&"invisible";let Pe;t[46]!==Ae?(Pe=Ye("absolute inset-0",Ae),t[46]=Ae,t[47]=Pe):Pe=t[47];const ze=!o&&!E;let Oe;t[48]!==ze?(Oe=n.jsx(Jt,{children:n.jsx(Kc,{active:ze})}),t[48]=ze,t[49]=Oe):Oe=t[49];let me;t[50]!==Pe||t[51]!==Oe?(me=n.jsx("div",{className:Pe,children:Oe}),t[50]=Pe,t[51]=Oe,t[52]=me):me=t[52];let be;t[53]!==d?(be=n.jsx(Jt,{children:n.jsx(rs,{needed:d,load:S4,onFailure:Bs})}),t[53]=d,t[54]=be):be=t[54];let Ce;t[55]!==l?(Ce=n.jsx(Jt,{children:n.jsx(rs,{needed:l,load:k4,onFailure:Bs})}),t[55]=l,t[56]=Ce):Ce=t[56];let $e;t[57]!==f?($e=n.jsx(Jt,{children:n.jsx(rs,{needed:f,load:j4,onFailure:Bs})}),t[57]=f,t[58]=$e):$e=t[58];let We;t[59]!==m?(We=n.jsx(Jt,{children:n.jsx(rs,{needed:m,load:T4,onFailure:Bs})}),t[59]=m,t[60]=We):We=t[60];let _e;t[61]!==p?(_e=p&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(Jt,{children:n.jsx(rs,{needed:true,load:C4,onFailure:Bs})})}),t[61]=p,t[62]=_e):_e=t[62];let Ue;t[63]!==h?(Ue=n.jsx(rs,{needed:h,load:E4,onFailure:Bs}),t[63]=h,t[64]=Ue):Ue=t[64];let Xe;t[65]!==x?(Xe=n.jsx(Jt,{children:n.jsx(rs,{needed:x,load:I4,onFailure:Bs})}),t[65]=x,t[66]=Xe):Xe=t[66];const Me=!!g;let ot;t[67]!==Me?(ot=n.jsx(Jt,{children:n.jsx(rs,{needed:Me,load:N4,onFailure:Bs})}),t[67]=Me,t[68]=ot):ot=t[68];let ye;t[69]!==v?(ye=v?n.jsx(Jt,{children:n.jsx(rs,{needed:true,load:P4,onFailure:Bs})}):null,t[69]=v,t[70]=ye):ye=t[70];let Ve;t[71]!==b?(Ve=b&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(Jt,{children:n.jsx(ox,{mode:`plugin:${b.id}`,surface:"page",item:null,onDismiss:b5})})}),t[71]=b,t[72]=Ve):Ve=t[72];let lt;t[73]!==me||t[74]!==be||t[75]!==Ce||t[76]!==$e||t[77]!==We||t[78]!==_e||t[79]!==Ue||t[80]!==Xe||t[81]!==ot||t[82]!==ye||t[83]!==Ve?(lt=n.jsxs("main",{ref:D,className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[me,be,Ce,$e,We,_e,Ue,Xe,ot,ye,Ve]}),t[73]=me,t[74]=be,t[75]=Ce,t[76]=$e,t[77]=We,t[78]=_e,t[79]=Ue,t[80]=Xe,t[81]=ot,t[82]=ye,t[83]=Ve,t[84]=lt):lt=t[84];let ct;t[85]===Symbol.for("react.memo_cache_sentinel")?(ct=n.jsx(ra,{zone:"bottom"}),t[85]=ct):ct=t[85];let st;t[86]!==lt?(st=n.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[lt,ct]}),t[86]=lt,t[87]=st):st=t[87];let k,Y,Ne,Re;t[88]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(ra,{zone:"right"}),Y=n.jsx(E3,{}),Ne=n.jsx(N3,{}),Re=n.jsx(A3,{}),t[88]=k,t[89]=Y,t[90]=Ne,t[91]=Re):(k=t[88],Y=t[89],Ne=t[90],Re=t[91]);let Ie;t[92]!==st?(Ie=n.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true","data-workspace-row":"true",children:[Te,n.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:[st,k,Y,Ne,Re]})]})}),t[92]=st,t[93]=Ie):Ie=t[93];let Ee;t[94]===Symbol.for("react.memo_cache_sentinel")?(Ee=n.jsx("div",{"data-page-scroll-lock":"true",children:n.jsx(Jt,{children:n.jsx(q3,{})})}),t[94]=Ee):Ee=t[94];let Ge;t[95]===Symbol.for("react.memo_cache_sentinel")?(Ge=n.jsx(Jt,{children:n.jsx(ix,{})}),t[95]=Ge):Ge=t[95];let Be;t[96]!==Ie?(Be=n.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[pe,n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Ie,Ee,Ge]})]}),t[96]=Ie,t[97]=Be):Be=t[97];let Ze;t[98]!==te||t[99]!==Be?(Ze=n.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[te,Be]}),t[98]=te,t[99]=Be,t[100]=Ze):Ze=t[100];let et;t[101]!==u||t[102]!==o||t[103]!==a?(et=u?n.jsx(u,{open:o,onOpenChange:a}):null,t[101]=u,t[102]=o,t[103]=a,t[104]=et):et=t[104];let wt;t[105]===Symbol.for("react.memo_cache_sentinel")?(wt=null,t[105]=wt):wt=t[105];let Qe;return t[106]!==P||t[107]!==ee||t[108]!==oe||t[109]!==de||t[110]!==ce||t[111]!==Ze||t[112]!==et?(Qe=n.jsx(ax.Provider,{value:true,children:n.jsx(gm,{children:n.jsx(zj,{children:n.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[P,ee,oe,de,he,Z,ce,ae,Ze,et,wt]})})})}),t[106]=P,t[107]=ee,t[108]=oe,t[109]=de,t[110]=ce,t[111]=Ze,t[112]=et,t[113]=Qe):Qe=t[113],Qe};function O4(t){return t.isSidebarOpen}function M4(t){return t.isolatedSpacesEnabled}function F4(t){return t.setIsMobile}function L4(t){return t.isSettingsDialogOpen}function $4(t){return t.setSettingsDialogOpen}function B4(t){return t.runOverviewKey!==null}function z4(t){return t.isScheduledTasksDialogOpen}function W4(t){return t.isArchivePageOpen}function V4(t){return t.isIntegrationsCatalogOpen}function U4(t){return t.isUsageStatsPageOpen}function H4(t){return t.isSourceBoardOpen}function K4(t){return t.isOverviewOpen}function q4(t){return t.worktreesPageProjectId}function G4(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function Z4(t){return t.isCommandPaletteOpen}function X4(t){return t.isHelpDialogOpen}function Y4(t){return t.isProjectActionsDialogOpen}function J4(t){return t.isOpenCodeStatusDialogOpen}function Q4(t){return t.accessDialog!==null}function e5(t){return t.applyDialog!==null}function t5(t){return t.setupOutputDialog!==null}function s5(t){return t.openGuestPageId}function n5(){return K.getState().setOpenGuestPage(null)}function r5(){return Pc(n5)}function o5(){return eb()}function a5(){return K.getState().closeMainSurfaces()}function i5(){return Dd(false)}function l5(){return i5}function c5(){return K.getState().closeMainSurfaces()}function d5(){const t=c5,e=it.subscribe((s,r)=>{const o=!!s.currentSessionId&&s.currentSessionId!==r.currentSessionId,a=!!s.newSessionDraft?.open&&s.newSessionDraft!==r.newSessionDraft;(o||a)&&t()});return()=>{e()}}function u5(){return K.getState().setCommandPaletteOpen(false)}function f5(){return K.getState().setHelpDialogOpen(false)}function p5(){return K.getState().setProjectActionsDialogOpen(false)}function m5(){return K.getState().setOpenCodeStatusDialogOpen(false)}function h5(){return yn.getState().closeAccessDialog()}function g5(){return yn.getState().closeApplyDialog()}function x5(){return yn.getState().closeSetupOutputDialog()}function b5(){return K.getState().setOpenGuestPage(null)}const $a="openchamber_requests_in_flight",af=1e3,w5=300*1e3,po=Math.ceil(w5/af),y5=()=>{if(typeof window>"u")return false;try{return window.localStorage.getItem($a)==="1"}catch{return false}},lf=()=>({enabled:true,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:false,originalFetch:null,sampleTimer:null});let v5=1;const S5=(t,e)=>{const s=window.__openchamberRequestsInFlight__;!s||!s.enabled||(s.inFlight+=1,s.totalStarted+=1,s.inFlight>s.peak&&(s.peak=s.inFlight),s.inFlightStarts.set(t,e))},k5=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},cf=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),s=[];for(const r of t.inFlightStarts.values())s.push(Math.max(0,e-r));return s.sort((r,o)=>r-o),s},On=(t,e)=>{const s=t.length;if(s===0)return 0;if(s===1)return t[0];const r=e/100*(s-1),o=Math.floor(r),a=Math.ceil(r);return o===a?t[o]:t[o]+(t[a]-t[o])*(r-o)},j5=()=>{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=true;const s=async(r,o)=>{const a=v5++;S5(a,Date.now());try{return await e(r,o)}finally{k5(a)}};window.fetch=s},oc=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=false,t.originalFetch=null)},Zn=t=>{t.length>po&&t.splice(0,t.length-po)},T5=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=cf(t),s=e.length>0?e[e.length-1]:0;t.p50Samples.push(On(e,50)),t.p90Samples.push(On(e,90)),t.p99Samples.push(On(e,99)),t.maxSamples.push(s),s>t.peakAgeMs&&(t.peakAgeMs=s),t.sampleCount+=1,Zn(t.samples),Zn(t.p50Samples),Zn(t.p90Samples),Zn(t.p99Samples),Zn(t.maxSamples),t.lastSampleAt=Date.now()},C5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(T5,af))},ac=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},ic=t=>{if(!(typeof window>"u"))try{if(t){ac(),oc(),window.localStorage.setItem($a,"1"),window.__openchamberRequestsInFlight__=lf(),j5(),C5();return}window.localStorage.removeItem($a),ac(),oc(),delete window.__openchamberRequestsInFlight__}catch{}},mC=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=lf();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},hC=()=>{if(typeof window>"u")return lc();const t=window.__openchamberRequestsInFlight__;if(!y5()||!t)return lc();const e=cf(t);return{enabled:true,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:On(e,50),ageP90:On(e,90),ageP99:On(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:po}},lc=()=>({enabled:false,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:po}),E5=(t,e,s)=>lx(t.filter(r=>!_d(r)&&!r.parentID),e,s),I5=()=>E5(os.getState().activeSessions,Rr.getState().ids,ui.getState().rankById??cx),N5=(t,e,s)=>{if(t.length===0)return;const r=t.findIndex(a=>a.id===e);let o=s>0?0:t.length-1;return r>=0&&(o=(r+s+t.length)%t.length),t[o]},P5=()=>{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()??"":""},R5=async()=>{const t=P5()||window.getSelection()?.toString()||"";if(!t.trim())return false;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),true}catch{}return document.execCommand("copy")},cc="openchamber:menu-action",dc="openchamber:check-for-updates",D5=t=>{const e=qe.c(24),{t:s}=gt(),r=it(_5),o=K(A5),a=K(O5),i=K(M5),u=K(F5),d=K(L5),l=K($5),f=K(B5),m=qc(z5),{setThemeMode:p}=bo(),h=c.useRef(false),x=K(W5);let g,v;e[0]!==x?(g=()=>{eo()&&on("desktop_set_menu_shortcuts",{shortcuts:dx(x)}).catch(V5)},v=[x],e[0]=x,e[1]=g,e[2]=v):(g=e[1],v=e[2]),c.useEffect(g,v);let y;e[3]!==m?(y=()=>{h.current||(h.current=true,m().then(U5).finally(()=>{h.current=false}))},e[3]=m,e[4]=y):y=e[4];const C=y,S=H5;let N;e[5]!==d?(N=b=>{const w=it.getState().currentSessionId,j=N5(I5(),w,b);j&&(d(false),it.getState().setCurrentSession(j.id,Hs(j)))},e[5]=d,e[6]=N):N=e[6];const F=N,_=K5;let M;e[7]!==F||e[8]!==t||e[9]!==r||e[10]!==f||e[11]!==a||e[12]!==d||e[13]!==l||e[14]!==p||e[15]!==s||e[16]!==o||e[17]!==i||e[18]!==u?(M=b=>{e:switch(b){case"about":{f(true);break e}case"settings":{l(true);break e}case"command-palette":{o();break e}case"quick-open":{a(true);break e}case"new-session":{d(false);const w=it.getState(),j=qt.getState().currentDirectory;r(w.currentSessionId&&j?{directoryOverride:j}:void 0);break e}case"new-worktree-session":{d(false),px();break e}case"change-workspace":{S();break e}case"toggle-right-sidebar":{const w=qt.getState().currentDirectory;if(!w)break e;const j=K.getState(),R=ds(w),L=j.contextPanelByDirectory[R],E=L?Hf(L.tabs,j.contextSurfaceZones,"right",lr(L,"right").activeTabId):null;L?.isOpen?j.closeContextPanel(R):E?j.setActiveContextPanelTab(R,E):j.openContextSurface(R,"git");break e}case"open-right-sidebar-git":{const w=qt.getState().currentDirectory;if(!w)break e;K.getState().openContextSurface(ds(w),"git");break e}case"open-right-sidebar-files":{const w=qt.getState().currentDirectory;if(!w)break e;K.getState().openContextSurface(ds(w),"file");break e}case"toggle-terminal":{const w=qt.getState().currentDirectory;if(!w)break e;K.getState().openContextSurface(ds(w),"terminal");break e}case"toggle-context-panel-expanded":{fx(qt.getState().currentDirectory);break e}case"copy":{const w=new Event("openchamber:copy",{cancelable:true});!window.dispatchEvent(w)||R5();break e}case"theme-light":{p("light");break e}case"theme-dark":{p("dark");break e}case"theme-system":{p("system");break e}case"add-selection-to-chat":{ux();break e}case"toggle-sidebar":{u();break e}case"toggle-memory-debug":{t?.();break e}case"go-back":{el(-1);break e}case"go-forward":{el(1);break e}case"previous-session":{F(-1);break e}case"next-session":{F(1);break e}case"previous-project":{_(-1);break e}case"next-project":{_(1);break e}case"help-dialog":{i();break e}case"download-logs":Pd().catch(()=>{Fe.error(s("openCodeStatusDialog.toast.collectFailed"))})}},e[7]=F,e[8]=t,e[9]=r,e[10]=f,e[11]=a,e[12]=d,e[13]=l,e[14]=p,e[15]=s,e[16]=o,e[17]=i,e[18]=u,e[19]=M):M=e[19];const B=M;let T,I;e[20]!==B||e[21]!==C?(T=()=>{const b=j=>{const R=j.detail;R&&B(R)},w=()=>{C()};return window.addEventListener(cc,b),window.addEventListener(dc,w),()=>{window.removeEventListener(cc,b),window.removeEventListener(dc,w)}},I=[B,C],e[20]=B,e[21]=C,e[22]=T,e[23]=I):(T=e[22],I=e[23]),c.useEffect(T,I)};function _5(t){return t.openNewSessionDraft}function A5(t){return t.toggleCommandPalette}function O5(t){return t.setCommandPaletteOpen}function M5(t){return t.toggleHelpDialog}function F5(t){return t.toggleSidebar}function L5(t){return t.setSessionSwitcherOpen}function $5(t){return t.setSettingsDialogOpen}function B5(t){return t.setAboutDialogOpen}function z5(t){return t.checkForUpdates}function W5(t){return t.shortcutOverrides}function V5(t){console.warn("[menu-actions] failed to update menu shortcuts",t)}function U5(){const{available:t,error:e}=qc.getState();if(e){Fe.error("Failed to check for updates",{description:e});return}t||Fe.success("You are on the latest version")}function H5(){xr.requestDirectoryDialog()}function K5(t){const{activeProjectId:e,projects:s,setActiveProject:r}=Yt.getState();if(s.length===0)return;const o=s.findIndex(u=>u.id===e);let a=t>0?0:s.length-1;o>=0&&(a=(o+t+s.length)%s.length);const i=s[a];i&&r(i.id)}const uc="openchamber:install-extension",df=t=>xb({source:t,confirmed:false}),q5=()=>{const t=qe.c(1);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],c.useEffect(X5,e)};function G5(t){const{url:e}=t.detail??{};typeof e=="string"&&e&&df(e)}function Z5(t){return t.forEach(df)}function X5(){const t=G5;return window.addEventListener(uc,t),Kf().then(Z5),()=>window.removeEventListener(uc,t)}const fc=(t,{isAdmitted:e,isPlaced:s,isPinned:r,zones:o})=>!e||t.parentID||t.time?.archived||_d(t)?false:s||o.pinned&&r||o.work&&Za(t),Y5="openchamber:tray-action",J5=5e3,Q5=500,eT=20,pc=()=>{if(typeof window>"u")return false;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},mc=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==false,uf=t=>{const e=t.action.trim()||"Permission",s=t.resources.find(r=>r.trim());return s?`${e}: ${s}`:e},ff=t=>t.title.trim()||"Question",tT=new Set,sT=(t,e)=>vx(t,e,tT,ui.getState().rankById),nT=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),s=e.lastIndexOf("/");return s>=0?e.slice(s+1):e},rT=(t,e,s,r,o)=>{if(!t)return"";const a=Er(s,r,t),i=e.project?.name,u=a?.label?.trim()||i?.trim()||nT(t),d=ro(t);let l=d&&o.get(d)||"";if(!l){for(const[f,m]of Ln.getState().directories)if(ro(f)===d){l=m.status?.current??"";break}}if(!l)for(const f of r.values()){const m=d?so(f,d):void 0;if(m?.branch){l=m.branch;break}}return l?`${u} \xB7 ${l}`:u},oT=()=>{const{dictionary:t}=Xf.getState(),e=(l,f)=>Yf(t,l,f),{results:s,dropdownProviderIds:r,displayMode:o,extensionProviders:a}=Bd.getState(),i=o==="remaining"?"remaining":"usage";if(!r.length)return{mode:i,groups:[]};const u=new Map(s.map(l=>[l.providerId,l])),d=[];for(const l of Sx(a)){if(!r.includes(l.id))continue;const f=u.get(l.id);if(!f||f.configured!==true)continue;const m=[];for(const[h,x]of Object.entries(f.usage?.windows??{})){const g=i==="remaining"?x.remainingPercent:x.usedPercent;m.push({label:jx(h),value:kx(x,g,e)})}const p=!f.ok&&f.error?f.error:m.length===0?"No rate limits reported":null;d.push({provider:l.name,rows:m,status:p})}return{mode:i,groups:d}},aT=async()=>{try{if(go())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=qf();if(e&&Ci(e,t))return"Local OpenChamber";const r=(await Ha()).hosts.find(o=>e?Ci(e,Dc(o)):false);return r?.label?.trim()?Gf(r.label.trim()):"Instance"}catch{return""}},iT=()=>{const t=new Map,e=new Map,s=[],r=new Map;let o;try{o=xa()}catch{return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}}for(const[a,i]of o.children.entries()){const u=i.getState();u.vcs?.branch&&e.set(ro(a)??a,u.vcs.branch);for(const d of u.session)d?.id&&r.set(d.id,d.title);for(const[d,l]of Object.entries(u.session_status??{})){const f=l?.type,m=f==="busy"?"busy":f==="retry"?"retry":"idle",p=t.get(d);(!p||p==="idle")&&t.set(d,m)}for(const[d,l]of Object.entries(u.permission??{}))for(const f of l??[]){if(!f?.id)continue;const m=f.sessionID||d;s.push({kind:"permission",id:f.id,sessionId:m,sessionTitle:"",label:uf(f),directory:a,canSave:zd(f.save)})}for(const[d,l]of Object.entries(u.form??{}))for(const f of l??[]){if(!f?.id)continue;const m=f.sessionID||d;s.push({kind:"form",id:f.id,sessionId:m,sessionTitle:"",label:ff(f),directory:a,canSave:false})}}return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}},lT=(t,e)=>{const s=os.getState().activeSessions,r=xx(s),o=T=>r.descendantsOf(T,"active").map(I=>I.id),a=Yt.getState().projects,i=it.getState().availableWorktreesByProject,u=Rr.getState().ids,d=(T,I)=>{const b=Hs(T),w=tl(b,a,i);return ho(b)||T.projectID===Zf?fc(T,{isAdmitted:w,isPlaced:I.chats,isPinned:false,zones:{pinned:false,work:false}}):fc(T,{isAdmitted:w,isPlaced:Cc(b)||Er(a,i,b)!==null,isPinned:di(u,T.directory,T.id),zones:I})},l=Rc.getState(),f={chats:l.showChatsSection,pinned:l.showPinnedSection,work:K.getState().sessionWorkEnabled&&l.showWorkSection},m={chats:true,pinned:true,work:true},p=bx(ga.getState().activeSessionIds,[Ad.getState().runningSessionIds,Od.getState().sessionIds,Md.getState().sessionIds,Fd.getState().bySession.keys(),Ld.getState().bySession.keys()]),h=T=>yx(T)&&!p.has(T.id),x=K.getState().dockBadgeEnabled?s.filter(T=>h(T)&&d(T,f)):[],g=x.length,v=x.sort((T,I)=>(I.time.idle??I.time.updated)-(T.time.idle??T.time.updated)||T.id.localeCompare(I.id)).slice(0,10).map(T=>({id:T.id,title:T.title,directory:Hs(T)??""}));if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:g,dockUnreadSessions:v};const y=iT(),C=new Map(y.titleById);for(const T of s)T?.id&&T.title&&C.set(T.id,T.title);const S=ga.getState().statusById,N=T=>{const I=y.statusById.get(T);return I&&I!=="idle"?I:S.get(T)?.status.type??I??"idle"},F=T=>{const I=T.map(b=>N(b));return I.includes("busy")?"busy":I.includes("retry")?"retry":"idle"},_=s.filter(T=>T?.id&&!T.parentID).filter(T=>d(T,m)).slice().sort(sT).slice(0,eT).map(T=>{const I=[T.id,...o(T.id)],b=Hs(T)??"";return{id:T.id,title:T.title||"Untitled session",status:F(I),branch:b?y.branchByDirectory.get(b)??"":"",unseen:h(T)?1:0,hasError:h(T)&&wx(T),directory:b,subtitle:rT(b,T,a,i,y.branchByDirectory)}}),M=y.approvals.map(T=>({...T,sessionTitle:C.get(T.sessionId)||""})),B=new Set(M.map(T=>T.id));for(const[T,I]of $d.getState().bySession){const b=C.get(T)||"";for(const w of I.permissions)B.has(w.id)||(B.add(w.id),M.push({kind:"permission",id:w.id,sessionId:T,sessionTitle:b,label:uf(w),directory:I.directory,canSave:zd(w.save)}));for(const w of[...I.forms,...I.pages])B.has(w.id)||(B.add(w.id),M.push({kind:"form",id:w.id,sessionId:T,sessionTitle:b,label:ff(w),directory:I.directory,canSave:false}))}return{sessions:_,approvals:M.filter(T=>tl(T.directory,a,i)),instanceName:t,usage:oT(),dockBadgeCount:g,dockUnreadSessions:v}},cT=()=>{c.useEffect(()=>{if(!pc()||!eo())return;const t=mc();let e=false,s="",r=null,o="";const a=()=>{if(e)return;const j=lT(o,t),R=JSON.stringify(j);R!==s&&(s=R,on("desktop_tray_update",j))},i=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,a()},Q5))},u=os.subscribe(()=>i()),d=ga.subscribe(()=>i()),l=Ad.subscribe(()=>i()),f=Od.subscribe(()=>i()),m=Md.subscribe(()=>i()),p=Fd.subscribe(()=>i()),h=Ld.subscribe(()=>i()),x=K.subscribe((j,R)=>{(j.dockBadgeEnabled!==R.dockBadgeEnabled||j.sessionWorkEnabled!==R.sessionWorkEnabled)&&i()}),g=Yt.subscribe(()=>i()),v=it.subscribe(()=>i()),y=Rr.subscribe(()=>i()),C=Rc.subscribe((j,R)=>{(j.showChatsSection!==R.showChatsSection||j.showPinnedSection!==R.showPinnedSection||j.showWorkSection!==R.showWorkSection)&&i()}),S=()=>{e=true,r!==null&&window.clearTimeout(r),u(),d(),l(),f(),m(),p(),h(),x(),g(),v(),y(),C()};if(!t)return a(),S;aT().then(j=>{e||(o=j,a())});const N=new Map,F=()=>{if(e)return;let j;try{j=xa()}catch{return}const R=new Set;for(const[L,E]of j.children.entries())R.add(L),N.has(L)||N.set(L,E.subscribe(()=>i()));for(const[L,E]of N)R.has(L)||(E(),N.delete(L))};let _=null;try{_=xa().subscribeRegistry(()=>{F(),i()})}catch{}F();const M=Ln.subscribe(()=>i()),B=$d.subscribe(()=>i()),T=ui.subscribe(()=>i()),I=Bd.subscribe(()=>i()),b=Ut.subscribe((j,R)=>{j.isInitialized&&!R.isInitialized&&Go(true)});Go(true);const w=window.setInterval(()=>{F(),a()},J5);return a(),()=>{S(),window.clearInterval(w),M(),B(),T(),I(),b(),_?.();for(const j of N.values())j();N.clear()}},[]),c.useEffect(()=>{if(!pc()||!eo())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const s=a=>{switch(a.type){case"mark-all-read":hx().then(()=>gx()).catch(()=>{});break;case"menu-opened":mc()&&Go();break;case"respond-permission":mx(a.sessionId,a.id,a.response).catch(()=>{Fe.error("Failed to respond to permission request")});break}};let r=null,o=false;return e(Y5,a=>{const i=a?.payload;!i||typeof i!="object"||typeof i.type!="string"||s(i)}).then(a=>{if(o){a();return}r=a,on("desktop_tray_actions_ready")}).catch(()=>{}),()=>{o=true;try{const a=r?.();a instanceof Promise&&a.catch(()=>{})}catch{}}},[])},dT=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():true,uT=(t,e,s,r)=>r||[t,e,s].filter(Boolean).join("|")||void 0,fT=t=>{t.kind!=="plugin"||!t.title||Fe.info(t.title,{id:uT(t.kind,t.title,t.body,t.tag),description:t.body})},pT=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===true,mT=t=>{const e=qe.c(3),s=true;let r,o;e[0]!==s?(r=()=>{if(!(As()||!_c()||!globalThis.window))return $n(hT)},o=[s],e[0]=s,e[1]=r,e[2]=o):(r=e[1],o=e[2]),c.useEffect(r,o)};function hT(t){if(t.type!=="notification"||t.payload.kind==="share-answer"&&t.payload.toastOnly===true)return;const e=K.getState();if(!e.nativeNotificationsEnabled)return;const s=dT();if(pT(t.payload,s)){fT(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==false&&s)return;Nc()?.notifications?.notifyAgentCompletion(t.payload)}const gT=()=>{const t=qe.c(3),{t:e}=gt();let s,r;t[0]!==e?(s=()=>$n(o=>{if(o.type!=="limit-failover")return;const{failover:a}=o,i=Ut.getState().providers,u=d=>i.find(l=>l.id===d);if(a.kind==="account"){const d=u(a.providerId)?.name||a.providerId;Fe.info(a.fromAccount?e("chat.limitFailover.toast.account",{provider:d,from:a.fromAccount,to:a.toAccount}):e("chat.limitFailover.toast.accountUnknown",{provider:d,to:a.toAccount}));return}Fe.info(e("chat.limitFailover.toast.model",{model:sl(u(a.providerId),a.modelId),fallback:sl(u(a.toProviderId),a.toModelId)}))}),r=[e],t[0]=e,t[1]=s,t[2]=r):(s=t[1],r=t[2]),c.useEffect(s,r)},hc="relay-limit-reached",xT=()=>{const t=qe.c(3),{t:e}=gt();let s,r;t[0]!==e?(s=()=>{const o=()=>{Fe.error(e("relayConnection.limitReached.title"),{id:hc,description:e("relayConnection.limitReached.description"),duration:1/0,action:{label:e("relayConnection.limitReached.retry"),onClick:bT}})};return Ei(Ac()?.getStatus())&&o(),Jf(i=>{Ei(i)?o():(i.state==="connected"||i.state==="idle")&&Fe.dismiss(hc)})},r=[e],t[0]=e,t[1]=s,t[2]=r):(s=t[1],r=t[2]),c.useEffect(s,r)};function bT(){return Ac()?.retry()}const gc=()=>{Qf()||(Tx(),Cx(ym.map(t=>t.id)))},wT=(t,e)=>{const s=qe.c(5);let r;s[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const i=window.requestIdleCallback(gc,{timeout:1e4});return()=>window.cancelIdleCallback(i)}const a=setTimeout(gc,3e3);return()=>clearTimeout(a)},s[0]=t,s[1]=r):r=s[1];let o;s[2]!==e||s[3]!==t?(o=[t,e],s[2]=e,s[3]=t,s[4]=o):o=s[4],c.useEffect(r,o)},xc="pwa-install-toast-shown",bc="pwa-install-toast-dismissed",yT=()=>{const t=qe.c(6),{browserTab:e}=vm(),{t:s}=gt(),r=c.useRef(s);let o,a;t[0]!==s?(o=()=>{r.current=s},a=[s],t[0]=s,t[1]=o,t[2]=a):(o=t[1],a=t[2]),c.useEffect(o,a);let i,u;t[3]!==e?(i=()=>{if(typeof window>"u"||!_c()||!e)return;let d=null,l=null;const f=()=>{l!==null&&(Fe.dismiss(l),l=null)},m=async()=>{if(!d)return;const x=d;d=null,f(),await x.prompt();const{outcome:g}=await x.userChoice;g==="accepted"&&Fe.success(r.current("pwa.installPrompt.started"))},p=x=>{const g=x;if(typeof g.prompt!="function")return;g.preventDefault(),d=g;const v=Ii(),y=ep();Sm({dismissed:v.getItem(bc),sessionShown:y.getItem(xc),hasActiveToast:l!==null})&&(y.setItem(xc,"true"),l=Fe.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{m()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Ii().setItem(bc,"true"),f()}}}))},h=()=>{d=null,f(),Fe.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",h),()=>{f(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",h)}},u=[e],t[3]=e,t[4]=i,t[5]=u):(i=t[4],u=t[5]),c.useEffect(i,u)},pf=()=>globalThis.window?.__OPENCHAMBER_SAFE_START__===true,vT=()=>{gs.setState({byRoot:{},runtimeSnapshots:{}});const t=K.getState();for(const e of Object.keys(t.contextPanelByDirectory))for(const s of Ua)t.closeContextZone(e,s)},ST=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",mf=async(t,e)=>{const s=(await Ha()).hosts.find(o=>o.id===t);if(!s)throw new Error("host-not-found");if(s.relay){await rp(s.id,e);return}const r=op(Dc(s));if(!r)throw new Error("host-not-found");ap({apiBaseUrl:r,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:ip(s),sshForwarded:s.sshForwarded===true})},kT=async t=>{const e=await Ha(),s=await sp(t,e.hosts);await np({hosts:s.hosts,defaultHostId:e.defaultHostId||s.hostId,initialHostChoiceCompleted:true}),await mf(s.hostId,{reconnectActive:true})},jT=async t=>{const e=await tp();for(const s of e)try{s.type==="pairing"?await kT(s.link):await mf(s.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",s.type,o),t(ST(o))}},Ba="project-config-invalid",TT=()=>{const t=qe.c(9),{t:e}=gt(),s=Ut(CT);let r;t[0]!==s?(r=p=>p.projectConfigErrors[s],t[0]=s,t[1]=r):r=t[1];const o=Ut(r),[a,i]=Kt.useState(false);let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const p=Ut.getState(),h=p.activeDirectoryKey;i(true),Promise.all([p.loadProviders({directory:h,source:"projectConfigError:retry"}),p.loadAgents({directory:h,source:"projectConfigError:retry"})]).finally(()=>i(false))},t[2]=u):u=t[2];const d=u;let l,f;t[3]!==o||t[4]!==a||t[5]!==e?(l=()=>{if(!o){Fe.dismiss(Ba);return}Fe.error(e("projectConfigError.toast.title"),{id:Ba,duration:1/0,description:n.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[n.jsx("span",{className:"break-all font-mono typography-meta",children:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&n.jsx(ps,{as:"span",outerClassName:"max-h-40",className:"whitespace-pre-wrap break-words font-mono typography-meta",disableHorizontal:true,children:o.message}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(a?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:p=>{p.preventDefault(),a||d()}}})},f=[o,a,d,e],t[3]=o,t[4]=a,t[5]=e,t[6]=l,t[7]=f):(l=t[6],f=t[7]),Kt.useEffect(l,f);let m;return t[8]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[8]=m):m=t[8],Kt.useEffect(IT,m),null};function CT(t){return t.activeDirectoryKey}function ET(){Fe.dismiss(Ba)}function IT(){return ET}const NT="\x1B",PT=new RegExp(`${NT}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Wr=It().transform(t=>t.replace(PT,"").trim()).nullish(),RT=Mt({isOpenCodeReady:ss().optional(),openCodeRunning:ss().optional(),lastOpenCodeError:Wr,opencodeBinaryResolved:Wr,lastOpenCodeLaunchDiagnostics:Mt({sourceBinary:Wr,binary:Wr}).nullish()}),DT=async(t,e=Ms)=>{const s=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)throw new Error(`Startup diagnostics request failed (${s.status})`);const r=RT.parse(await s.json());return r.isOpenCodeReady===true||r.isOpenCodeReady!==false&&r.openCodeRunning!==false?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},_T=(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"}},AT=Mt({openchamberVersion:It()}),OT=async(t,e=Ms)=>{const s=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)return null;const r=AT.safeParse(await s.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},MT=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function FT({version:t}){const{t:e}=gt(),[s,r]=c.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const u=await jm();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})}},a=s.kind==="manual"?s:null,i=a?.info?.updateCommand||"openchamber update";return n.jsxs("div",{className:"flex w-full flex-col items-center gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("h1",{className:"typography-h1 text-foreground",children:e("startup.serverOutdated.title")}),n.jsx("p",{className:"typography-markdown text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),n.jsxs(yt,{type:"button",onClick:()=>{o()},disabled:s.kind==="checking",children:[n.jsx(ue,{name:s.kind==="checking"?"loader":"download",className:s.kind==="checking"?"size-4 animate-spin":"size-4"}),s.kind==="checking"?e("startup.serverOutdated.checking"):e("onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),a&&n.jsxs("div",{className:"w-full space-y-2 text-start",children:[!a.info?.available&&n.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),a.error&&n.jsx("p",{dir:"auto",className:"typography-meta text-muted-foreground",children:a.error}),a.info?.installBlocked==="opencode-version"?n.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:e("updateDialog.openCodeTooOld",{version:a.info.version||"",required:a.info.requiredOpenCodeVersion||"",current:a.info.openCodeVersion||""})}):a.info?.installBlocked==="desktop-host"?n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:a.info.version||""})}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("onboarding.desktopRecovery.remoteIncompatible.manualUpdate")}),n.jsx("code",{dir:"ltr",className:"block select-text rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono text-sm text-foreground",children:i})]})]}),n.jsx(km,{open:s.kind==="available",onOpenChange:u=>{u||r({kind:"idle"})},info:s.kind==="available"?s.info:null,downloading:false,downloaded:false,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const wc=Tr(()=>Vt(()=>import("./OnboardingScreen-NWWMu7OG.js"),__vite__mapDeps([266,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}))),LT=()=>Vt(()=>import("./AboutDialog-gL1x0YFW.js"),__vite__mapDeps([267,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,243])).then(t=>t.AboutDialog),$T=()=>Vt(()=>import("./MemoryDebugPanel-BWT5owg7.js"),__vite__mapDeps([268,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,208,209,210,211])).then(t=>t.MemoryDebugPanel),BT=()=>{const t=qe.c(6),e=K(HT),s=K(KT);let r;t[0]!==s?(r=()=>s(false),t[0]=s,t[1]=r):r=t[1];const o=Eo(e,LT,r);if(!o)return null;let a;return t[2]!==o||t[3]!==e||t[4]!==s?(a=n.jsx(o,{open:e,onOpenChange:s}),t[2]=o,t[3]=e,t[4]=s,t[5]=a):a=t[5],a},zT=t=>{const e=qe.c(3),{onClose:s}=t,r=Eo(true,$T,s);let o;return e[0]!==r||e[1]!==s?(o=r?n.jsx(r,{onClose:s}):null,e[0]=r,e[1]=s,e[2]=o):o=e[2],o},WT=t=>{const e=qe.c(47),{onRetry:s,isRetrying:r}=t,{t:o}=gt(),[a,i]=c.useState(null);let u,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const T=new AbortController,I=Xt(),b=setTimeout(()=>T.abort(),5e3);return DT(T.signal).then(w=>{!T.signal.aborted&&Xt()===I&&i(w)}).catch(qT).finally(()=>clearTimeout(b)),()=>{T.abort(),clearTimeout(b)}},d=[],e[0]=u,e[1]=d):(u=e[0],d=e[1]),c.useEffect(u,d);const[l,f]=c.useState(null);let m,p;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{const T=new AbortController,I=Xt(),b=setTimeout(()=>T.abort(),5e3);return OT(T.signal).then(w=>{T.signal.aborted||Xt()!==I||f(w&&MT(w)?w:null)}).catch(GT).finally(()=>clearTimeout(b)),()=>{T.abort(),clearTimeout(b)}},p=[],e[2]=m,e[3]=p):(m=e[2],p=e[3]),c.useEffect(m,p);const h=Ut(ZT),x=a?null:h?.message??null;if(l){let T;e[4]!==l?(T=n.jsx(FT,{version:l}),e[4]=l,e[5]=T):T=e[5];let I;e[6]!==r||e[7]!==o?(I=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=I):I=e[8];let b;e[9]!==r||e[10]!==s||e[11]!==I?(b=n.jsx(yt,{type:"button",variant:"outline",onClick:s,disabled:r,children:I}),e[9]=r,e[10]=s,e[11]=I,e[12]=b):b=e[12];let w;return e[13]!==T||e[14]!==b?(w=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[T,b]})}),e[13]=T,e[14]=b,e[15]=w):w=e[15],w}let g;e[16]!==o?(g=o("startup.initRecovery.title"),e[16]=o,e[17]=g):g=e[17];let v;e[18]!==g?(v=n.jsx("h1",{className:"typography-h1 text-foreground",children:g}),e[18]=g,e[19]=v):v=e[19];let y;e[20]!==a||e[21]!==h||e[22]!==o?(y=o(_T(a,h)),e[20]=a,e[21]=h,e[22]=o,e[23]=y):y=e[23];let C;e[24]!==y?(C=n.jsx("p",{className:"typography-markdown text-muted-foreground",children:y}),e[24]=y,e[25]=C):C=e[25];let S;e[26]!==v||e[27]!==C?(S=n.jsxs("div",{className:"flex flex-col gap-2",children:[v,C]}),e[26]=v,e[27]=C,e[28]=S):S=e[28];let N;e[29]!==x||e[30]!==o?(N=x&&n.jsxs("dl",{className:"w-full min-w-0 text-start","aria-live":"polite",children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.lastError")}),n.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:x})]}),e[29]=x,e[30]=o,e[31]=N):N=e[31];let F;e[32]!==a||e[33]!==o?(F=a&&n.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[a.binary&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),n.jsx("dd",{className:"break-all font-mono typography-meta",children:a.binary})]}),a.error&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.error")}),n.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:a.error})]})]}),e[32]=a,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 M;e[38]!==r||e[39]!==s||e[40]!==_?(M=n.jsx(yt,{type:"button",onClick:s,disabled:r,children:_}),e[38]=r,e[39]=s,e[40]=_,e[41]=M):M=e[41];let B;return e[42]!==N||e[43]!==F||e[44]!==M||e[45]!==S?(B=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[S,N,F,M]})}),e[42]=N,e[43]=F,e[44]=M,e[45]=S,e[46]=B):B=e[46],B};function VT({apis:t}){q5(),c.useEffect(()=>Ex(),[]),c.useEffect(()=>{lp("App:mounted"),cp()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Ut(P=>P.initializeApp),s=Ut(P=>P.isInitialized),r=Ut(P=>P.isConnected),o=Ut(P=>P.providersLoaded),a=Ut(P=>P.agentsLoaded),i=Ut(P=>P.loadProviders),u=Ut(P=>P.loadAgents),d=it(P=>P.error),l=it(P=>P.clearError),f=qt(P=>P.currentDirectory),m=qt(P=>P.isSwitchingDirectory),[p,h]=c.useState(false),x=vn(P=>P.refreshAll),g=jc(P=>P.refresh),[v,y]=c.useState(()=>t.runtime.isVSCode),[C,S]=c.useState(false),[N,F]=c.useState(0),[_,M]=c.useState(0),[B,T]=c.useState(false),I=K(P=>P.mobileKeyboardMode),b=c.useMemo(()=>As(),[]),[w,j]=c.useState(()=>Ni()),[R,L]=c.useState(()=>{const P=Bo();return P!==null?Pi({isDesktopShell:true,bootOutcome:P}):null}),E=c.useRef(false),{t:D}=gt(),U=c.useRef(false);c.useEffect(()=>{if(!s||w!=="valid"||U.current)return;const P=Bo();P?.target!=="local"||P.status!=="ok"||!P.sshStartupFallbackHostId||(U.current=true,Fe.error(D("desktopHostSwitcher.startup.title"),{description:D("desktopHostSwitcher.startup.fellBackToLocal")}))},[w,s,D]);const V=c.useRef(false);c.useEffect(()=>{!s||!pf()||V.current||(V.current=true,Fe.info(D("desktopSafeStart.title"),{description:D("desktopSafeStart.description"),duration:1/0}))},[s,D]),c.useEffect(()=>(Ri(p),ic(p),()=>{Ri(false),ic(false)}),[p]),c.useEffect(()=>{dp(I)},[I]),c.useEffect(()=>{y(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>Pc(P=>{Cm(P)&&Em(P),M(ee=>ee+1),S(false),F(ee=>ee+1)}),[]),Im(),c.useEffect(()=>(Di(t),()=>Di(null)),[t]),c.useEffect(()=>{r&&(g(t.sourceControl),x(t.sourceControl,{force:true}),Ix(t.trackers))},[t.sourceControl,t.trackers,r,x,g,_]),Nx();const J=w==="valid",W=R?.screen==="main";c.useEffect(()=>{if(!up({isDesktopShell:b,bootOutcomeKnown:J}))return;Px();const P=setTimeout(()=>{const ee=document.getElementById("initial-loading");ee&&(ee.classList.add("fade-out"),setTimeout(()=>{ee.remove()},300))},150);return()=>clearTimeout(P)},[b,J]),c.useEffect(()=>{if(!b||w!=="malformed")return;const P=document.getElementById("initial-loading");P&&(P.textContent="Desktop startup failed \u2014 please restart the app.")},[b,w]),c.useEffect(()=>{v||e()},[e,v]),c.useEffect(()=>{if(v||s)return;let P=true,ee,oe=0;const de=10,he=1e3,Z=async()=>{if(!P)return;if(oe>=de){S(true);return}const ce=Ut.getState();if(ce.isInitialized){S(false);return}oe+=1,await ce.initializeApp();const ae=Ut.getState();if(!P)return;if(ae.isInitialized){S(false);return}if(oe>=de){S(true);return}const te=Math.min(he*Math.pow(2,oe-1),4e3);ee=setTimeout(Z,te)};return ee=setTimeout(Z,he),()=>{P=false,ee&&clearTimeout(ee)}},[N,s,v]),c.useEffect(()=>{s&&S(false)},[s]),c.useEffect(()=>{if(!C)return;const P=document.getElementById("initial-loading");P&&(P.classList.add("fade-out"),setTimeout(()=>{P.remove()},300))},[C]),c.useEffect(()=>{if(v||!r||o&&a)return;let P=true,ee=0;const oe=15,de=async()=>{const Z=Ut.getState();if(!(Z.providersLoaded&&Z.agentsLoaded))try{Z.providersLoaded||await i({source:"startupRecovery"}),Ut.getState().agentsLoaded||await u({source:"startupRecovery"})}catch{}};de();const he=setInterval(()=>{if(P){if(++ee>=oe){clearInterval(he);return}de()}},2e3);return()=>{P=false,clearInterval(he)}},[r,v,u,i,o,a]),c.useEffect(()=>{m||v||r&&ua.setDirectory(f)},[f,m,r,v]),c.useEffect(()=>{if(typeof window>"u")return;const P=ee=>{const oe=ee.detail,de=typeof oe?.sessionId=="string"?oe.sessionId.trim():"";if(!de)return;const he=typeof oe?.directory=="string"&&oe.directory.trim().length>0?oe.directory.trim():null,Z=typeof oe?.messageId=="string"&&oe.messageId.trim()||null;_i(de,String(oe?.runtimeKey??"").trim(),Z)||nl(de,{directory:he,messageId:Z,requireKnownSession:oe?.requireKnownSession===true})};return window.addEventListener("openchamber:open-session",P),fp().then(ee=>{for(const oe of ee)_i(oe.sessionId,oe.runtimeKey,oe.messageId)||(oe.requireKnownSession?nl(oe.sessionId,{messageId:oe.messageId,requireKnownSession:true}):Rx(oe.sessionId,oe.messageId))}),()=>window.removeEventListener("openchamber:open-session",P)},[]),c.useEffect(()=>{if(!As())return;const P=()=>{jT(ee=>{Fe.error(D(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",P),P(),()=>window.removeEventListener("openchamber:host-actions-ready",P)},[D]);const G=c.useRef({attempt:null,running:false,done:false});c.useLayoutEffect(()=>{const P=G.current;P.attempt||(P.attempt=Nm({selectNow:!Pm().sessionId,refresh:false}))},[]),c.useEffect(()=>{const P=G.current,ee=()=>{const oe=P.attempt;if(!oe||P.running||P.done)return;const de=Ut.getState().isInitialized;P.running=true,oe().then(he=>{if(P.running=false,he!=="failed"||de){P.done=true;return}Ut.getState().isInitialized&&ee()})};ee()},[s]),c.useEffect(()=>{if(typeof window>"u")return;const P=()=>{on("desktop_open_draft_mini_chat_window",{directory:"",projectId:null,...ca()})};return window.addEventListener("openchamber:open-mini-chat",P),()=>window.removeEventListener("openchamber:open-mini-chat",P)},[]),c.useEffect(()=>{if(typeof window>"u")return;const P=()=>{const ee=it.getState().currentSessionId;ee&&Nd(ee)};return window.addEventListener("focus",P),()=>window.removeEventListener("focus",P)},[]),c.useEffect(()=>{if(typeof window>"u")return;const P=ee=>{const oe=ee.detail,de=typeof oe?.directory=="string"&&oe.directory.trim().length>0?oe.directory.trim():null,he=typeof oe?.projectId=="string"&&oe.projectId.trim().length>0?oe.projectId.trim():null,Z=!!(de||he);K.getState().setSessionSwitcherOpen(false),it.getState().openNewSessionDraft({target:Z?"project":"chat",selectedProjectId:Z?he:null,directoryOverride:Z?de:null,preserveDirectoryOverride:!!de})};return window.addEventListener("openchamber:open-draft-session",P),()=>window.removeEventListener("openchamber:open-draft-session",P)},[]),c.useEffect(()=>{typeof window>"u"||!s||m||E.current||(E.current=true,window.__openchamberAppReady=true,window.dispatchEvent(new Event("openchamber:app-ready")))},[s,m]),Dx(),mT(),Rm(f||null),Dm(),_m(t.sourceControl),Am(t.trackers),Om(),Mm(),Fm(),gT(),_x(),Lm(),xT(),wT(s&&r,_),yT(),Ax(),tb(),$m();const le=c.useCallback(()=>{h(P=>!P)},[]);D5(le),cT(),Bm(true),c.useEffect(()=>{const P=()=>h(ee=>!ee);return window.addEventListener("openchamber:memory-debug-toggle",P),()=>window.removeEventListener("openchamber:memory-debug-toggle",P)},[]),c.useEffect(()=>{d&&setTimeout(()=>l(),5e3)},[l,d]),c.useEffect(()=>{if(!b||w!=="not-injected")return;let P=false,ee=0;const oe=200,de=2e3,he=50,Z=()=>{if(P)return;ee++;const ce=Ni();if(ce!=="not-injected"){if(P=true,j(ce),ce==="valid"){const te=Bo();te&&L(Pi({isDesktopShell:true,bootOutcome:te}))}return}const ae=Math.min(oe*Math.pow(1.1,ee),de);if(ee>=he){const te=document.getElementById("initial-loading");te&&!te.textContent?.includes("taking longer")&&(te.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Z,ae)};return window.setTimeout(Z,oe),()=>{P=true}},[b,w]);const $=c.useCallback(async()=>{if(pp({isDesktopShell:As(),isDesktopLocalOriginActive:go()})){await mp();return}window.location.reload()},[]),re=c.useCallback(async()=>{if(!B){S(false),T(true);try{await Ut.getState().initializeApp()}finally{T(false)}Ut.getState().isInitialized||F(P=>P+1)}},[B]),H=P=>{if(P.screen==="recovery")return P.variant};if(b&&R&&R.screen!=="main"){if(R.screen==="chooser")return n.jsx(Jt,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(c.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(wc,{mode:"first-launch",localAvailable:R.localAvailable!==false,onCliAvailable:$,onChooseRemote:()=>{}})})})});const P=H(R),ee=R.screen==="recovery"&&"url"in R?R.url:void 0,oe=R.screen==="recovery"&&"hostId"in R?R.hostId:void 0;return n.jsx(Jt,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(c.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(wc,{mode:"recovery",recoveryVariant:P,recoveryHostUrl:ee,recoveryHostLabel:void 0,recoveryHostId:oe,localAvailable:R.localAvailable!==false,onCliAvailable:$})})})})}return C&&!s&&!v?n.jsx(Jt,{children:n.jsx(WT,{onRetry:()=>{re()},isRetrying:B},_)}):n.jsx(Jt,{children:n.jsx(Ox,{sdk:ua.getSdkClient(),directory:f||"",children:n.jsx(Mx,{apis:t,children:n.jsx(zm,{children:n.jsx(Fx,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:b?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[n.jsx(Lx,{backgroundWorkEnabled:true}),n.jsx(Wm,{}),n.jsx(TT,{}),n.jsx(A4,{}),b&&!(J&&W)?n.jsx(Vm,{ready:false}):null,n.jsx($x,{}),n.jsx(Bx,{}),n.jsx(zx,{}),n.jsx(Wx,{}),n.jsx(Vx,{}),n.jsx(Um,{}),n.jsx(BT,{}),p&&n.jsx(zT,{onClose:()=>h(false)})]})})})})},_)})}function UT(t){const e=qe.c(2);let s;return e[0]!==t?(s=n.jsx(Tm,{children:n.jsx(VT,{...t})}),e[0]=t,e[1]=s):s=e[1],s}function HT(t){return t.isAboutDialogOpen}function KT(t){return t.setAboutDialogOpen}function qT(){}function GT(){}function ZT(t){return t.lastInitFailure}const XT=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();hp();pf()&&vT();Hm();Km();gp().then(()=>{Ux().catch(t=>{console.error("[main] settings init failed:",t)}),Hx(),Kx(),qx()}).catch(t=>{console.error("[main] appearance init failed:",t)});const hf=document.getElementById("root");if(!hf)throw new Error("Root element not found");Gx();gf.createRoot(hf).render(n.jsx(Kt.StrictMode,{children:n.jsx(Zx,{children:n.jsx(Xx,{children:n.jsx(Yx,{children:n.jsx(Jx,{children:n.jsx(UT,{apis:XT})})})})})}));const gC=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{dl as P,qj as a,Xj as b,Yj as c,Jj as d,r4 as e,a4 as f,hC as g,Qj as h,e4 as i,t4 as j,s4 as k,E5 as l,gC as m,Gj as o,n4 as p,mC as r,Zj as s,Yw as u};