@vantran-se/openchamber-web 2.0.9 → 2.0.10

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 (117) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-DngoXxGT.js → CodeMirrorCommentWidgets-e9rY9Jxg.js} +1 -1
  2. package/dist/assets/{DiffView-UeB7OS2J.js → DiffView-rYnmKnFF.js} +1 -1
  3. package/dist/assets/{FilesView-Cs3Y7IF5.js → FilesView-DtzJk1Ke.js} +3 -3
  4. package/dist/assets/{GitView-DsJqHet1.js → GitView-DYd5gOSc.js} +1 -1
  5. package/dist/assets/{GuestAttachDialog-CN0FTkqY.js → GuestAttachDialog-Bsi0q3M9.js} +1 -1
  6. package/dist/assets/{GuestSurfacePane-BFbUwJOB.js → GuestSurfacePane-CYMRe3EI.js} +1 -1
  7. package/dist/assets/{JsonTreeView-B2artBdi.js → JsonTreeView-DIy-frOy.js} +1 -1
  8. package/dist/assets/{LinearIssuesView-DCcXvS3Q.js → LinearIssuesView-DDHJKaVb.js} +1 -1
  9. package/dist/assets/{MarkdownImageGallery-Du-Ph58N.js → MarkdownImageGallery-BMQ4KHaO.js} +1 -1
  10. package/dist/assets/{MarkdownRendererImpl-CnXfZsIi.js → MarkdownRendererImpl-CQi_ZSPc.js} +1 -1
  11. package/dist/assets/{OnboardingScreen-DdB_pV9d.js → OnboardingScreen-DiMFS3A7.js} +1 -1
  12. package/dist/assets/{PatchDiff-JvRN2s5u.js → PatchDiff-4jmPWx6l.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-BOIbtTSo.js → PierreDiffViewer-DKHxCmze.js} +1 -1
  14. package/dist/assets/{PlanView-DYZs8zCF.js → PlanView-CN21khuJ.js} +1 -1
  15. package/dist/assets/{PluginPane-CaHXDA-2.js → PluginPane-Dx0_Dldo.js} +1 -1
  16. package/dist/assets/{SettingsView-CfFMLncG.js → SettingsView-CBGx68I6.js} +1 -1
  17. package/dist/assets/{SettingsWindow-0vSQTxkV.js → SettingsWindow-B8RpyNyO.js} +1 -1
  18. package/dist/assets/{SubmoduleDiffSummary-DhLlAYSb.js → SubmoduleDiffSummary-hkelCkS-.js} +1 -1
  19. package/dist/assets/{ToolOutputDialog-CdV4zEAG.js → ToolOutputDialog-UbbhHm0d.js} +1 -1
  20. package/dist/assets/{ToolPartDiffPreview-XL2mZzAG.js → ToolPartDiffPreview-7FbKWkeu.js} +1 -1
  21. package/dist/assets/{VirtualizedFileDiff-ACObo6xZ.js → VirtualizedFileDiff-DapU3oMs.js} +1 -1
  22. package/dist/assets/{WalkthroughView-B-3eK3lX.js → WalkthroughView-DhvkEmfP.js} +1 -1
  23. package/dist/assets/{appThemeRegistry-CgfpF2VR.js → appThemeRegistry-CWAKiwky.js} +1 -1
  24. package/dist/assets/{ar-SA-G6X2FPQ2-ChXWTl2B.js → ar-SA-G6X2FPQ2-DswVk5Qr.js} +1 -1
  25. package/dist/assets/{az-AZ-76LH7QW2-qjuQaC-s.js → az-AZ-76LH7QW2-DjkREsRV.js} +1 -1
  26. package/dist/assets/{bg-BG-XCXSNQG7-dsvyn4OJ.js → bg-BG-XCXSNQG7-DQo0fDKV.js} +1 -1
  27. package/dist/assets/{bn-BD-2XOGV67Q-BjdT9u1P.js → bn-BD-2XOGV67Q-CzA0IjiR.js} +1 -1
  28. package/dist/assets/{ca-ES-6MX7JW3Y-BTTmpcqZ.js → ca-ES-6MX7JW3Y-L92o9vc1.js} +1 -1
  29. package/dist/assets/{commitAndPush-dBUe7z8F.js → commitAndPush-D51hG7WM.js} +1 -1
  30. package/dist/assets/{computeVirtualFileMetrics-DfI7BTln.js → computeVirtualFileMetrics-BWISD0Ee.js} +1 -1
  31. package/dist/assets/{cs-CZ-2BRQDIVT-C5rG2tZX.js → cs-CZ-2BRQDIVT-BXRAPYTK.js} +1 -1
  32. package/dist/assets/{da-DK-5WZEPLOC-BOaJLF6Z.js → da-DK-5WZEPLOC-Be9eTSFu.js} +1 -1
  33. package/dist/assets/{de-DE-XR44H4JA-Dt-4U2No.js → de-DE-XR44H4JA-D7jcygnK.js} +1 -1
  34. package/dist/assets/{de-DoDk6ixL.js → de-Dzva6tmf.js} +1 -1
  35. package/dist/assets/{el-GR-BZB4AONW-CR60bCOY.js → el-GR-BZB4AONW-DWPB-4gi.js} +1 -1
  36. package/dist/assets/{es-uuDOJL65.js → es-Be7FJA1p.js} +1 -1
  37. package/dist/assets/{es-ES-U4NZUMDT-BxBSKTXR.js → es-ES-U4NZUMDT-BteMlYd0.js} +1 -1
  38. package/dist/assets/{eu-ES-A7QVB2H4-DCoZ1mko.js → eu-ES-A7QVB2H4-D3K4uMB7.js} +1 -1
  39. package/dist/assets/{fa-IR-HGAKTJCU-CGlSV3Cv.js → fa-IR-HGAKTJCU-D7LwSGvX.js} +1 -1
  40. package/dist/assets/{fi-FI-Z5N7JZ37-DjiU77q2.js → fi-FI-Z5N7JZ37-61Yx90sI.js} +1 -1
  41. package/dist/assets/{fr-C0viImM8.js → fr-CvtTZ_7n.js} +1 -1
  42. package/dist/assets/{fr-FR-RHASNOE6-tQI46EwI.js → fr-FR-RHASNOE6-BokbdDAr.js} +1 -1
  43. package/dist/assets/{gl-ES-HMX3MZ6V-UebXQim9.js → gl-ES-HMX3MZ6V-CfKWvFjV.js} +1 -1
  44. package/dist/assets/{he-IL-6SHJWFNN-CrEAMSem.js → he-IL-6SHJWFNN-BiuDhPeJ.js} +1 -1
  45. package/dist/assets/{hi-IN-IWLTKZ5I-CDElf1It.js → hi-IN-IWLTKZ5I-CBpbpt_D.js} +1 -1
  46. package/dist/assets/{hu-HU-A5ZG7DT2-BxrPciUB.js → hu-HU-A5ZG7DT2-YdbIKZJs.js} +1 -1
  47. package/dist/assets/{id-ID-SAP4L64H-BEUMSOdC.js → id-ID-SAP4L64H-B6lOIjuX.js} +1 -1
  48. package/dist/assets/{index-BW492zXv.js → index-BvpIhpBI.js} +1 -1
  49. package/dist/assets/{index-hsqFIGlo.js → index-CxBGclAj.js} +1 -1
  50. package/dist/assets/{isDiffPlainText-BrLxBox_.js → isDiffPlainText-DU3lrpLL.js} +1 -1
  51. package/dist/assets/{isFilePlainText-Cgi_4AsZ.js → isFilePlainText-udb3VTt2.js} +1 -1
  52. package/dist/assets/{it-IT-JPQ66NNP-DU7yvppw.js → it-IT-JPQ66NNP-Bmx3ltTW.js} +1 -1
  53. package/dist/assets/{ja-B9orD75V.js → ja-BPgcBIXr.js} +1 -1
  54. package/dist/assets/{ja-JP-DBVTYXUO-3JN7QvVc.js → ja-JP-DBVTYXUO-Ble1Hn10.js} +1 -1
  55. package/dist/assets/{kaa-6HZHGXH3-ZZvAjpex.js → kaa-6HZHGXH3-DZbQ2VK_.js} +1 -1
  56. package/dist/assets/{kab-KAB-ZGHBKWFO-C4wThQdT.js → kab-KAB-ZGHBKWFO-iJv1iHzt.js} +1 -1
  57. package/dist/assets/{kk-KZ-P5N5QNE5-DtGbDE5-.js → kk-KZ-P5N5QNE5-CVPa7-_X.js} +1 -1
  58. package/dist/assets/{km-KH-HSX4SM5Z-BBzQ-auj.js → km-KH-HSX4SM5Z-CG3n2D2z.js} +1 -1
  59. package/dist/assets/{ko-DMWq9y4E.js → ko-DavkJfF9.js} +1 -1
  60. package/dist/assets/{ko-KR-MTYHY66A-DKypF9JQ.js → ko-KR-MTYHY66A-4ypCzC-G.js} +1 -1
  61. package/dist/assets/{ku-TR-6OUDTVRD-D9ejnihQ.js → ku-TR-6OUDTVRD-rnEkr74f.js} +1 -1
  62. package/dist/assets/{lt-LT-XHIRWOB4-Dqmjn0mI.js → lt-LT-XHIRWOB4-CyRnYc4K.js} +1 -1
  63. package/dist/assets/{lv-LV-5QDEKY6T-UrP5oB7q.js → lv-LV-5QDEKY6T-ZRIiC6FR.js} +1 -1
  64. package/dist/assets/{main-xwL5wKzs.js → main-CrXZnahe.js} +2 -2
  65. package/dist/assets/{main-BjJBl7Nu.js → main-xs-JggnC.js} +4 -4
  66. package/dist/assets/{markdownCore-DSFyd8zF.js → markdownCore-CUxMtJCS.js} +1 -1
  67. package/dist/assets/{miniChat-DYbqo1MM.js → miniChat-BISrLEQj.js} +2 -2
  68. package/dist/assets/{mobile-BfD16Eag.js → mobile-C5yhjorl.js} +2 -2
  69. package/dist/assets/{mr-IN-CRQNXWMA-IPWmH5Ni.js → mr-IN-CRQNXWMA-UgSO2DIH.js} +1 -1
  70. package/dist/assets/{my-MM-5M5IBNSE-BLfvJLfS.js → my-MM-5M5IBNSE-D_F1DCJR.js} +1 -1
  71. package/dist/assets/{nb-NO-T6EIAALU-DpTcOSVU.js → nb-NO-T6EIAALU-oIGhTIX7.js} +1 -1
  72. package/dist/assets/{nl-NL-IS3SIHDZ-BnEpZrEO.js → nl-NL-IS3SIHDZ-cScIrIxG.js} +1 -1
  73. package/dist/assets/{nn-NO-6E72VCQL-cguGGiOn.js → nn-NO-6E72VCQL-CjEAl_Lv.js} +1 -1
  74. package/dist/assets/{oc-FR-POXYY2M6-DZRflDPj.js → oc-FR-POXYY2M6-1rehXYxp.js} +1 -1
  75. package/dist/assets/{pa-IN-N4M65BXN-B4LAi-bY.js → pa-IN-N4M65BXN-7iWEsMEJ.js} +1 -1
  76. package/dist/assets/{patchFileDiff-DkL8Aa2N.js → patchFileDiff-DzgiH2zi.js} +1 -1
  77. package/dist/assets/{percentages-BXMCSKIN-ChsKj3Ud.js → percentages-BXMCSKIN-nJkK2U43.js} +4 -4
  78. package/dist/assets/{pl-DOQ2hiXE.js → pl-DU7WIv6_.js} +1 -1
  79. package/dist/assets/{pl-PL-T2D74RX3-DIa8_Rxw.js → pl-PL-T2D74RX3-8-4_uRcY.js} +1 -1
  80. package/dist/assets/{pt-BR-5N22H2LF-CjvHq8Nl.js → pt-BR-5N22H2LF-5f518RJn.js} +1 -1
  81. package/dist/assets/{pt-BR-GRNT4bJk.js → pt-BR-nKukDIco.js} +1 -1
  82. package/dist/assets/{pt-PT-UZXXM6DQ-De7WYkMm.js → pt-PT-UZXXM6DQ-CX60-bds.js} +1 -1
  83. package/dist/assets/{renderElectronMiniChatApp-COuZPzkA.js → renderElectronMiniChatApp-BsUuzGo8.js} +2 -2
  84. package/dist/assets/{renderMobileApp-BO162-O8.js → renderMobileApp-4lMkhU0J.js} +3 -3
  85. package/dist/assets/{ro-RO-JPDTUUEW-8cucu0w7.js → ro-RO-JPDTUUEW-WRbjlbWZ.js} +1 -1
  86. package/dist/assets/{ru-RU-B4JR7IUQ-C-EfBvoP.js → ru-RU-B4JR7IUQ-BOe15dMj.js} +1 -1
  87. package/dist/assets/{runtimeEndpointReset-B_5A-WIc.js → runtimeEndpointReset-D56xMbiw.js} +19 -19
  88. package/dist/assets/{scheduledTasksApi-MxDvG-t3.js → scheduledTasksApi-BZMS2h6Z.js} +1 -1
  89. package/dist/assets/{shikiHighlight-B39UxQvQ.js → shikiHighlight-BPUnGgQg.js} +1 -1
  90. package/dist/assets/{si-LK-N5RQ5JYF-Dtp4SfIy.js → si-LK-N5RQ5JYF-DdWuRf76.js} +1 -1
  91. package/dist/assets/{sk-SK-C5VTKIMK-C2URq6ko.js → sk-SK-C5VTKIMK-C6bkxrp7.js} +1 -1
  92. package/dist/assets/{sl-SI-NN7IZMDC-DFa24yvi.js → sl-SI-NN7IZMDC-9Kz16LlM.js} +1 -1
  93. package/dist/assets/{subset-shared.chunk-DT8U7cSF.js → subset-shared.chunk-TyCa-VC5.js} +1 -1
  94. package/dist/assets/{subset-worker.chunk-DsFk1l-v.js → subset-worker.chunk-BEUpJy0_.js} +1 -1
  95. package/dist/assets/{sv-SE-XGPEYMSR-BW357iMU.js → sv-SE-XGPEYMSR-CEKYbCUy.js} +1 -1
  96. package/dist/assets/{ta-IN-2NMHFXQM-ByJpqKo_.js → ta-IN-2NMHFXQM-lt4RexfZ.js} +1 -1
  97. package/dist/assets/{textMateThemeFromAppTheme-Dmu3ECWz.js → textMateThemeFromAppTheme-AUvSJIJn.js} +1 -1
  98. package/dist/assets/{th-TH-HPSO5L25-oBYiL2Sw.js → th-TH-HPSO5L25-BTLJeK_p.js} +1 -1
  99. package/dist/assets/{tr-CcLlZCMC.js → tr-C7G7YZuM.js} +1 -1
  100. package/dist/assets/{tr-TR-DEFEU3FU-DuccnkGw.js → tr-TR-DEFEU3FU-D1x5-N8S.js} +1 -1
  101. package/dist/assets/{uk-DeV8vTnQ.js → uk-D-OHqF3o.js} +1 -1
  102. package/dist/assets/{uk-UA-QMV73CPH-EKbyzxQM.js → uk-UA-QMV73CPH-BoCWhdiB.js} +1 -1
  103. package/dist/assets/{useAppFontEffects-Cz-1Efdn.js → useAppFontEffects-FdVEdwq7.js} +101 -101
  104. package/dist/assets/{useInlineCommentController-BFwu6eZI.js → useInlineCommentController-Bf5t_8QQ.js} +1 -1
  105. package/dist/assets/{useRootScrollLock-sHvuqb26.js → useRootScrollLock-BhAup8Zd.js} +2 -2
  106. package/dist/assets/{vendor-codemirror-language-data-CbrKiV7x.js → vendor-codemirror-language-data-CaoLP1ZV.js} +2 -2
  107. package/dist/assets/{vi-VN-M7AON7JQ-FnoyhtCt.js → vi-VN-M7AON7JQ-BNXFIbWh.js} +1 -1
  108. package/dist/assets/{web-components-CyKxJIMp.js → web-components-BKRdx0aw.js} +1 -1
  109. package/dist/assets/{zh-CN-CytFue-5.js → zh-CN-CN_mO1LM.js} +1 -1
  110. package/dist/assets/{zh-CN-LNUGB5OW-CxzUpimL.js → zh-CN-LNUGB5OW-BzAzBoiv.js} +1 -1
  111. package/dist/assets/{zh-HK-E62DVLB3-Bm2BpZIC.js → zh-HK-E62DVLB3-gszEMx80.js} +1 -1
  112. package/dist/assets/{zh-TW-B-BGC0pY.js → zh-TW-DRymoioH.js} +1 -1
  113. package/dist/assets/{zh-TW-RAJ6MFWO-NVEuq9tQ.js → zh-TW-RAJ6MFWO-jlMY0UDt.js} +1 -1
  114. package/dist/index.html +2 -2
  115. package/dist/mini-chat.html +2 -2
  116. package/dist/mobile.html +2 -2
  117. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-Cs3Y7IF5.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-react-C3AD0CRp.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-BW492zXv.js","assets/vendor-zod-C3BVLiwa.js","assets/vendor-zustand-XNmn2Hnw.js","assets/vendor-use-sync-external-store-DVVwmGAS.js","assets/vendor-opencode-client-DSZl7jSi.js","assets/index-ryXjyKdZ.css","assets/useAppFontEffects-Cz-1Efdn.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-CyPa587s.js","assets/vendor-clsx-C_d985j6.js","assets/vendor-base-ui-BV0ycO3d.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BERnAEiB.js","assets/vendor-floating-ui-core-DBVSD8FA.js","assets/vendor-floating-ui-react-dom-VN3-0QGl.js","assets/vendor-dnd-kit-core-B-dmENub.js","assets/vendor-dnd-kit-utilities-D2MO70n8.js","assets/vendor-dnd-kit-accessibility-vxqCsF6D.js","assets/vendor-dnd-kit-sortable-DiuAkJDx.js","assets/vendor-tanstack-react-virtual-BHz8HhxS.js","assets/vendor-tanstack-virtual-core-BoA4iGMw.js","assets/vendor-framer-motion-0pQCvQRa.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/contextPanelEmbeddedChat-CirXEPJq.js","assets/vendor-sonner-CMlKUx1I.js","assets/vendor-cmdk-WpnCe4Xz.js","assets/vendor-radix-ui-react-dialog-Cya58wJc.js","assets/vendor-radix-ui-primitive-DOdKROq0.js","assets/vendor-radix-ui-react-compose-refs-OwL660na.js","assets/vendor-radix-ui-react-context-BGG-1ggC.js","assets/vendor-radix-ui-react-id-CciEoFzD.js","assets/vendor-radix-ui-react-use-layout-effect-ChlApEEc.js","assets/vendor-radix-ui-react-use-controllable-state-DprBN3PW.js","assets/vendor-radix-ui-react-use-callback-ref-D1Sqy0CZ.js","assets/vendor-radix-ui-react-dismissable-layer-3AH-Or1W.js","assets/vendor-radix-ui-react-primitive-CUfg3gbV.js","assets/vendor-radix-ui-react-slot-CLI2-QJb.js","assets/vendor-babel-runtime-CF3RwP-h.js","assets/vendor-radix-ui-react-use-escape-keydown-D0tG0-sR.js","assets/vendor-radix-ui-react-focus-scope-CqvJmvlR.js","assets/vendor-radix-ui-react-portal-EaY9b0dR.js","assets/vendor-radix-ui-react-presence-DBDb0ROU.js","assets/vendor-radix-ui-react-focus-guards-DOvT22db.js","assets/vendor-react-remove-scroll-CdTdY8wV.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-DAxITgbW.js","assets/vendor-react-style-singleton-XBDcq1Ec.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-CzUV4Fx5.js","assets/vendor-use-callback-ref-h1JrcWGd.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-Cg8boEOY.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-CN8Enbjc.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-Dw1gdHuT.js","assets/vendor-codemirror-lang-json-DzRRSgj9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-B_seq3PB.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CcuPVz08.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-B3FiTjDN.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CbrKiV7x.js","assets/vendor-codemirror-lang-python-frX4-6UW.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-Cg3hFNyu.js","assets/vendor-legendapp-list-ZsDnss2w.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-B_5A-WIc.js","assets/GuestAttachDialog-CN0FTkqY.js","assets/PluginPane-CaHXDA-2.js","assets/shikiHighlight-B39UxQvQ.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-C_NzAZis.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-B2artBdi.js","assets/web-components-CyKxJIMp.js","assets/computeVirtualFileMetrics-DfI7BTln.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/Virtualizer-CtRzP13T.js","assets/isFilePlainText-Cgi_4AsZ.js","assets/appThemeRegistry-CgfpF2VR.js","assets/textMateThemeFromAppTheme-Dmu3ECWz.js","assets/Virtualizer-D_a8gKmg.js","assets/vendor-react-drawio-DR5-Wn9a.js","assets/scheduledTasksApi-MxDvG-t3.js","assets/useInlineCommentController-BFwu6eZI.js","assets/CodeMirrorCommentWidgets-DngoXxGT.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
2
- import{e as me,r as Pn,j as t,R as u,b as ss,f as la}from"./vendor-react-C3AD0CRp.js";import"./vendor-katex-C8JhiARg.js";import{u as ze,g as ls,ab as zi,ac as Ur,ad as Be,f as ft,ae as Jt,af as Es,r as Fn,ag as ca,ah as Oi,ai as ua,aj as da,ak as fa,a as Nt,aa as ma,al as Ut,am as pa,an as ha,F as vn,J as Kr,a4 as ga,b as Gr,s as Bi,ao as Hr,A as qr,z as Jr,ap as Fs,B as ba,C as xa}from"./index-BW492zXv.js";import{eR as Zt,fl as ya,a0 as Ye,fm as Tn,fn as Li,c7 as Wn,fo as va,u as be,t as xe,o as wa,I as Q,B as je,am as $i,cb as Yt,h as Z,fp as Fi,fq as ja,fr as ka,b0 as Sa,a8 as tt,ag as Na,fs as _t,ft as Ca,fu as Yr,fv as Ra,fw as Ea,co as Vn,b_ as Ia,b$ as Aa,Z as Re,c1 as Pa,c3 as Un,c4 as Kn,fx as Gn,c5 as Ta,c6 as qs,fy as Hn,f7 as Da,bK as Wi,a1 as Je,fz as Vi,fA as _a,fB as Ma,fC as za,c0 as Ui,a4 as Ki,fD as Gi,fE as Hi,fF as qi,fG as Ji,fH as Yi,y as Xi,fI as Oa,fJ as Ba,j as qn,fK as La,fL as $a,fM as Fa,fN as Wa,b2 as wn,fO as Va,a6 as gs,fP as Kt,fQ as Xr,fR as Qi,cq as Ua,fS as Ka,n as sn,bq as Zi,br as eo,fT as Ga,fU as Ha,fV as ws,fW as es,ai as qa,aj as Ja,ak as Ya,fX as Xa,a2 as Jn,bJ as Qa,bL as Za,ck as el,bM as tl,fY as sl,fZ as nl,f_ as rl,f$ as il,da as Qr,F as ol,A as al,cp as ll,C as cl,E as ul,z as Ws,aa as dl,bP as fl,bR as to,an as Ve,g0 as ml,g1 as pl,g2 as hl,g3 as gl,g4 as Yn,cy as bl,k as xl,$ as yl,g5 as vl,g6 as wl,g7 as jl,g8 as kl,bo as so,bc as Sl,bd as Nl,be as Cl,bf as Rl,g9 as El,bl as Il,bk as Al,bg as Pl,ga as Tl,bh as Dl,bi as _l,bj as Ml,bs as zl,bp as Ol,gb as Bl,gc as Ll,gd as $l,ge as Fl,gf as Wl,gg as Vl,gh as Ul,bt as Kl,bu as Gl,bv as Hl,bw as ql,bx as Jl,by as Yl,bz as Xl,bA as Ql,bB as Zl}from"./useAppFontEffects-Cz-1Efdn.js";import{j as Xt,S as Xn,k as ec,l as tc,m as sc,n as no,o as ro,p as io,q as nc,r as rc,t as jn,v as ic,w as oc,x as Zr,y as ac,z as lc,D as cc,A as uc,B as dc,E as fc,b as mc,F as pc,H as hc,N as gc,a as bc,e as xc,I as yc,J as vc,P as wc,O as jc,K as kc,L as Sc,M as Nc,Q as Cc,R as Rc,U as Ec,V as Ic,W as Ac,X as Pc,Y as Tc,Z as Dc,_ as _c,$ as Mc,a0 as zc}from"./runtimeEndpointReset-B_5A-WIc.js";import{_ as ns}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as Oc,A as Bc}from"./SettingsView-CfFMLncG.js";import{PlanView as Lc}from"./PlanView-DYZs8zCF.js";import{p as $c}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as Fc}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as Dn,d as Wc,M as Js,J as _n,s as oo,a as Qn,p as Vc,_ as ei,f as Zn,V as Uc,K as ti,P as Kc,b as Gc,c as Hc,U as qc,Z as Jc,Q as Yc,r as Xc}from"./vendor-remixicon-react-AquCnQk5.js";import{f as er,h as rs,i as tr,P as sr,D as nr,j as rr}from"./vendor-dnd-kit-core-B-dmENub.js";import{s as ir,S as or,v as ar,u as lr}from"./vendor-dnd-kit-sortable-DiuAkJDx.js";import{C as cr}from"./vendor-dnd-kit-utilities-D2MO70n8.js";import{a as ur,p as ao}from"./vendor-zustand-XNmn2Hnw.js";import{toast as Mn}from"./vendor-sonner-CMlKUx1I.js";import{C as Qc,a as Zc,D as eu,p as si}from"./commitAndPush-dBUe7z8F.js";import{b as tu,c as su,a as nu,u as ru,i as iu,f as ou,B as au,C as lu,P as ni}from"./patchFileDiff-DkL8Aa2N.js";import{b as cu,c as uu,a as du,S as fu,i as mu}from"./SubmoduleDiffSummary-DhLlAYSb.js";import{P as pu}from"./PierreDiffViewer-BOIbtTSo.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-C3BVLiwa.js";import"./vendor-opencode-client-DSZl7jSi.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-CyPa587s.js";import"./vendor-clsx-C_d985j6.js";import"./vendor-base-ui-BV0ycO3d.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BERnAEiB.js";import"./vendor-floating-ui-core-DBVSD8FA.js";import"./vendor-floating-ui-react-dom-VN3-0QGl.js";import"./vendor-use-sync-external-store-DVVwmGAS.js";import"./vendor-tanstack-react-virtual-BHz8HhxS.js";import"./vendor-tanstack-virtual-core-BoA4iGMw.js";import"./vendor-framer-motion-0pQCvQRa.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-cmdk-WpnCe4Xz.js";import"./vendor-radix-ui-react-dialog-Cya58wJc.js";import"./vendor-radix-ui-primitive-DOdKROq0.js";import"./vendor-radix-ui-react-compose-refs-OwL660na.js";import"./vendor-radix-ui-react-context-BGG-1ggC.js";import"./vendor-radix-ui-react-id-CciEoFzD.js";import"./vendor-radix-ui-react-use-layout-effect-ChlApEEc.js";import"./vendor-radix-ui-react-use-controllable-state-DprBN3PW.js";import"./vendor-radix-ui-react-use-callback-ref-D1Sqy0CZ.js";import"./vendor-radix-ui-react-dismissable-layer-3AH-Or1W.js";import"./vendor-radix-ui-react-primitive-CUfg3gbV.js";import"./vendor-radix-ui-react-slot-CLI2-QJb.js";import"./vendor-babel-runtime-CF3RwP-h.js";import"./vendor-radix-ui-react-use-escape-keydown-D0tG0-sR.js";import"./vendor-radix-ui-react-focus-scope-CqvJmvlR.js";import"./vendor-radix-ui-react-portal-EaY9b0dR.js";import"./vendor-radix-ui-react-presence-DBDb0ROU.js";import"./vendor-radix-ui-react-focus-guards-DOvT22db.js";import"./vendor-react-remove-scroll-CdTdY8wV.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-DAxITgbW.js";import"./vendor-react-style-singleton-XBDcq1Ec.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-CzUV4Fx5.js";import"./vendor-use-callback-ref-h1JrcWGd.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-Cg8boEOY.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-CN8Enbjc.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-Dw1gdHuT.js";import"./vendor-codemirror-lang-json-DzRRSgj9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-B_seq3PB.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CcuPVz08.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-B3FiTjDN.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CbrKiV7x.js";import"./vendor-codemirror-lang-python-frX4-6UW.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-Cg3hFNyu.js";import"./vendor-legendapp-list-ZsDnss2w.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-CN0FTkqY.js";import"./PluginPane-CaHXDA-2.js";import"./vendor-dnd-kit-accessibility-vxqCsF6D.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-B39UxQvQ.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-C_NzAZis.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./appThemeRegistry-CgfpF2VR.js";import"./textMateThemeFromAppTheme-Dmu3ECWz.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-qrcode-BTlWCou-.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./useInlineCommentController-BFwu6eZI.js";import"./CodeMirrorCommentWidgets-DngoXxGT.js";import"./changesTree-CePHbFcj.js";import"./VirtualizedFileDiff-ACObo6xZ.js";import"./web-components-CyKxJIMp.js";import"./computeVirtualFileMetrics-DfI7BTln.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isDiffPlainText-BrLxBox_.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";let lo=null,ri=!1;const hu=new Promise(n=>{lo=n});function gu(){ri||(ri=!0,lo?.())}const bu=6,xu=n=>n.parentID??null,ii=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},yu=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),vu=(n,e)=>{if(!n)return"";let s=null,i=-1;for(const r of e){const o=yu(r.path);(n===o||n.startsWith(`${o}/`))&&o.length>i&&(s=r,i=o.length)}return s?s.label?.trim()||ii(s.path):ii(n)},wu=()=>{const n=Zt.getState().activeSessions,e=ya.getState().index.session.unseenCount,s=ze.getState().notifyOnSubtasks,i=Ye.getState().projects,r=Tn.getState().ids,o=Li.getState().rankById;let a=0;const d=[];for(const f of n){const l=xu(f)!==null,g=(e[f.id]??0)>0&&(!l||s);g&&(a+=1),l||d.push({session:f,unread:g,project:vu(Wn(f),i)})}d.sort((f,l)=>va(f.session,l.session,r,o));const m=d.slice(0,bu).map(({session:f,unread:l,project:p})=>({id:f.id,title:f.title??"",unread:l,project:p}));return{runtimeKey:ls(),attentionCount:a,recentSessions:m}},ju="__OPENCHAMBER_WIDGET_SNAPSHOT__",ku=()=>{typeof window>"u"||(window[ju]=()=>{try{return JSON.stringify(wu())}catch{return null}})},kn="mobile-app-update-available",oi="mobile-app-update-toast-dismissed-version",Su=()=>{const n=me.c(8),{t:e}=be(),s=Xt(Nu),i=Xt(Cu),r=Xt(Ru),o=Xt(Eu);let a;n[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,n[0]=a):a=n[0];const d=Pn.useRef(a);let m,f;return n[1]!==s||n[2]!==o||n[3]!==i||n[4]!==e||n[5]!==r?(m=()=>{if(zi()!=="android"||i!=="mobile"||!s||!r||!o){xe.dismiss(kn);return}Ur().getItem(oi)!==r&&(d.current.has(r)||(d.current.add(r),xe.info(e("mobileUpdate.toast.available.title"),{id:kn,description:e("mobileUpdate.toast.available.description",{version:r}),duration:1/0,icon:t.jsx(Q,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{wa(o)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{Ur().setItem(oi,r),xe.dismiss(kn)}}})))},f=[s,o,i,e,r],n[1]=s,n[2]=o,n[3]=i,n[4]=e,n[5]=r,n[6]=m,n[7]=f):(m=n[6],f=n[7]),Pn.useEffect(m,f),null};function Nu(n){return n.available}function Cu(n){return n.runtimeType}function Ru(n){return n.info?.version}function Eu(n){return n.info?.downloadUrl}const ai=300,Iu="openchamber.mobile.connectLog.v1",Qt=[];if(typeof window<"u")try{window.localStorage.removeItem(Iu)}catch{}const dr=(n,e)=>{Qt.push({at:Date.now(),step:n,detail:e}),Qt.length>ai&&Qt.splice(0,Qt.length-ai)};typeof window<"u"&&dr("app:launch","{}");const Au=()=>[...Qt],Pu=n=>{const e=new Date(n),s=(i,r=2)=>String(i).padStart(r,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},co=n=>`${Pu(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,Tu=()=>Qt.map(co).join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-DtzJk1Ke.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-react-C3AD0CRp.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-BvpIhpBI.js","assets/vendor-zod-C3BVLiwa.js","assets/vendor-zustand-XNmn2Hnw.js","assets/vendor-use-sync-external-store-DVVwmGAS.js","assets/vendor-opencode-client-DSZl7jSi.js","assets/index-ryXjyKdZ.css","assets/useAppFontEffects-FdVEdwq7.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-CyPa587s.js","assets/vendor-clsx-C_d985j6.js","assets/vendor-base-ui-BV0ycO3d.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BERnAEiB.js","assets/vendor-floating-ui-core-DBVSD8FA.js","assets/vendor-floating-ui-react-dom-VN3-0QGl.js","assets/vendor-dnd-kit-core-B-dmENub.js","assets/vendor-dnd-kit-utilities-D2MO70n8.js","assets/vendor-dnd-kit-accessibility-vxqCsF6D.js","assets/vendor-dnd-kit-sortable-DiuAkJDx.js","assets/vendor-tanstack-react-virtual-BHz8HhxS.js","assets/vendor-tanstack-virtual-core-BoA4iGMw.js","assets/vendor-framer-motion-0pQCvQRa.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/contextPanelEmbeddedChat-CirXEPJq.js","assets/vendor-sonner-CMlKUx1I.js","assets/vendor-cmdk-WpnCe4Xz.js","assets/vendor-radix-ui-react-dialog-Cya58wJc.js","assets/vendor-radix-ui-primitive-DOdKROq0.js","assets/vendor-radix-ui-react-compose-refs-OwL660na.js","assets/vendor-radix-ui-react-context-BGG-1ggC.js","assets/vendor-radix-ui-react-id-CciEoFzD.js","assets/vendor-radix-ui-react-use-layout-effect-ChlApEEc.js","assets/vendor-radix-ui-react-use-controllable-state-DprBN3PW.js","assets/vendor-radix-ui-react-use-callback-ref-D1Sqy0CZ.js","assets/vendor-radix-ui-react-dismissable-layer-3AH-Or1W.js","assets/vendor-radix-ui-react-primitive-CUfg3gbV.js","assets/vendor-radix-ui-react-slot-CLI2-QJb.js","assets/vendor-babel-runtime-CF3RwP-h.js","assets/vendor-radix-ui-react-use-escape-keydown-D0tG0-sR.js","assets/vendor-radix-ui-react-focus-scope-CqvJmvlR.js","assets/vendor-radix-ui-react-portal-EaY9b0dR.js","assets/vendor-radix-ui-react-presence-DBDb0ROU.js","assets/vendor-radix-ui-react-focus-guards-DOvT22db.js","assets/vendor-react-remove-scroll-CdTdY8wV.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-DAxITgbW.js","assets/vendor-react-style-singleton-XBDcq1Ec.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-CzUV4Fx5.js","assets/vendor-use-callback-ref-h1JrcWGd.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-Cg8boEOY.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-CN8Enbjc.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-Dw1gdHuT.js","assets/vendor-codemirror-lang-json-DzRRSgj9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-B_seq3PB.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CcuPVz08.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-B3FiTjDN.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CaoLP1ZV.js","assets/vendor-codemirror-lang-python-frX4-6UW.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-Cg3hFNyu.js","assets/vendor-legendapp-list-ZsDnss2w.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-D56xMbiw.js","assets/GuestAttachDialog-Bsi0q3M9.js","assets/PluginPane-Dx0_Dldo.js","assets/shikiHighlight-BPUnGgQg.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-C_NzAZis.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-DIy-frOy.js","assets/web-components-BKRdx0aw.js","assets/computeVirtualFileMetrics-BWISD0Ee.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/Virtualizer-CtRzP13T.js","assets/isFilePlainText-udb3VTt2.js","assets/appThemeRegistry-CWAKiwky.js","assets/textMateThemeFromAppTheme-AUvSJIJn.js","assets/Virtualizer-D_a8gKmg.js","assets/vendor-react-drawio-DR5-Wn9a.js","assets/scheduledTasksApi-BZMS2h6Z.js","assets/useInlineCommentController-Bf5t_8QQ.js","assets/CodeMirrorCommentWidgets-e9rY9Jxg.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
2
+ import{e as me,r as Pn,j as t,R as u,b as ss,f as la}from"./vendor-react-C3AD0CRp.js";import"./vendor-katex-C8JhiARg.js";import{u as ze,g as ls,ab as zi,ac as Ur,ad as Be,f as ft,ae as Jt,af as Es,r as Fn,ag as ca,ah as Oi,ai as ua,aj as da,ak as fa,a as Nt,aa as ma,al as Ut,am as pa,an as ha,F as vn,J as Kr,a4 as ga,b as Gr,s as Bi,ao as Hr,A as qr,z as Jr,ap as Fs,B as ba,C as xa}from"./index-BvpIhpBI.js";import{eR as Zt,fl as ya,a0 as Ye,fm as Tn,fn as Li,c7 as Wn,fo as va,u as be,t as xe,o as wa,I as Q,B as je,am as $i,cb as Yt,h as Z,fp as Fi,fq as ja,fr as ka,b0 as Sa,a8 as tt,ag as Na,fs as _t,ft as Ca,fu as Yr,fv as Ra,fw as Ea,co as Vn,b_ as Ia,b$ as Aa,Z as Re,c1 as Pa,c3 as Un,c4 as Kn,fx as Gn,c5 as Ta,c6 as qs,fy as Hn,f7 as Da,bK as Wi,a1 as Je,fz as Vi,fA as _a,fB as Ma,fC as za,c0 as Ui,a4 as Ki,fD as Gi,fE as Hi,fF as qi,fG as Ji,fH as Yi,y as Xi,fI as Oa,fJ as Ba,j as qn,fK as La,fL as $a,fM as Fa,fN as Wa,b2 as wn,fO as Va,a6 as gs,fP as Kt,fQ as Xr,fR as Qi,cq as Ua,fS as Ka,n as sn,bq as Zi,br as eo,fT as Ga,fU as Ha,fV as ws,fW as es,ai as qa,aj as Ja,ak as Ya,fX as Xa,a2 as Jn,bJ as Qa,bL as Za,ck as el,bM as tl,fY as sl,fZ as nl,f_ as rl,f$ as il,da as Qr,F as ol,A as al,cp as ll,C as cl,E as ul,z as Ws,aa as dl,bP as fl,bR as to,an as Ve,g0 as ml,g1 as pl,g2 as hl,g3 as gl,g4 as Yn,cy as bl,k as xl,$ as yl,g5 as vl,g6 as wl,g7 as jl,g8 as kl,bo as so,bc as Sl,bd as Nl,be as Cl,bf as Rl,g9 as El,bl as Il,bk as Al,bg as Pl,ga as Tl,bh as Dl,bi as _l,bj as Ml,bs as zl,bp as Ol,gb as Bl,gc as Ll,gd as $l,ge as Fl,gf as Wl,gg as Vl,gh as Ul,bt as Kl,bu as Gl,bv as Hl,bw as ql,bx as Jl,by as Yl,bz as Xl,bA as Ql,bB as Zl}from"./useAppFontEffects-FdVEdwq7.js";import{j as Xt,S as Xn,k as ec,l as tc,m as sc,n as no,o as ro,p as io,q as nc,r as rc,t as jn,v as ic,w as oc,x as Zr,y as ac,z as lc,D as cc,A as uc,B as dc,E as fc,b as mc,F as pc,H as hc,N as gc,a as bc,e as xc,I as yc,J as vc,P as wc,O as jc,K as kc,L as Sc,M as Nc,Q as Cc,R as Rc,U as Ec,V as Ic,W as Ac,X as Pc,Y as Tc,Z as Dc,_ as _c,$ as Mc,a0 as zc}from"./runtimeEndpointReset-D56xMbiw.js";import{_ as ns}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as Oc,A as Bc}from"./SettingsView-CBGx68I6.js";import{PlanView as Lc}from"./PlanView-CN21khuJ.js";import{p as $c}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as Fc}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as Dn,d as Wc,M as Js,J as _n,s as oo,a as Qn,p as Vc,_ as ei,f as Zn,V as Uc,K as ti,P as Kc,b as Gc,c as Hc,U as qc,Z as Jc,Q as Yc,r as Xc}from"./vendor-remixicon-react-AquCnQk5.js";import{f as er,h as rs,i as tr,P as sr,D as nr,j as rr}from"./vendor-dnd-kit-core-B-dmENub.js";import{s as ir,S as or,v as ar,u as lr}from"./vendor-dnd-kit-sortable-DiuAkJDx.js";import{C as cr}from"./vendor-dnd-kit-utilities-D2MO70n8.js";import{a as ur,p as ao}from"./vendor-zustand-XNmn2Hnw.js";import{toast as Mn}from"./vendor-sonner-CMlKUx1I.js";import{C as Qc,a as Zc,D as eu,p as si}from"./commitAndPush-D51hG7WM.js";import{b as tu,c as su,a as nu,u as ru,i as iu,f as ou,B as au,C as lu,P as ni}from"./patchFileDiff-DzgiH2zi.js";import{b as cu,c as uu,a as du,S as fu,i as mu}from"./SubmoduleDiffSummary-hkelCkS-.js";import{P as pu}from"./PierreDiffViewer-DKHxCmze.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-C3BVLiwa.js";import"./vendor-opencode-client-DSZl7jSi.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-CyPa587s.js";import"./vendor-clsx-C_d985j6.js";import"./vendor-base-ui-BV0ycO3d.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BERnAEiB.js";import"./vendor-floating-ui-core-DBVSD8FA.js";import"./vendor-floating-ui-react-dom-VN3-0QGl.js";import"./vendor-use-sync-external-store-DVVwmGAS.js";import"./vendor-tanstack-react-virtual-BHz8HhxS.js";import"./vendor-tanstack-virtual-core-BoA4iGMw.js";import"./vendor-framer-motion-0pQCvQRa.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-cmdk-WpnCe4Xz.js";import"./vendor-radix-ui-react-dialog-Cya58wJc.js";import"./vendor-radix-ui-primitive-DOdKROq0.js";import"./vendor-radix-ui-react-compose-refs-OwL660na.js";import"./vendor-radix-ui-react-context-BGG-1ggC.js";import"./vendor-radix-ui-react-id-CciEoFzD.js";import"./vendor-radix-ui-react-use-layout-effect-ChlApEEc.js";import"./vendor-radix-ui-react-use-controllable-state-DprBN3PW.js";import"./vendor-radix-ui-react-use-callback-ref-D1Sqy0CZ.js";import"./vendor-radix-ui-react-dismissable-layer-3AH-Or1W.js";import"./vendor-radix-ui-react-primitive-CUfg3gbV.js";import"./vendor-radix-ui-react-slot-CLI2-QJb.js";import"./vendor-babel-runtime-CF3RwP-h.js";import"./vendor-radix-ui-react-use-escape-keydown-D0tG0-sR.js";import"./vendor-radix-ui-react-focus-scope-CqvJmvlR.js";import"./vendor-radix-ui-react-portal-EaY9b0dR.js";import"./vendor-radix-ui-react-presence-DBDb0ROU.js";import"./vendor-radix-ui-react-focus-guards-DOvT22db.js";import"./vendor-react-remove-scroll-CdTdY8wV.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-DAxITgbW.js";import"./vendor-react-style-singleton-XBDcq1Ec.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-CzUV4Fx5.js";import"./vendor-use-callback-ref-h1JrcWGd.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-Cg8boEOY.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-CN8Enbjc.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-Dw1gdHuT.js";import"./vendor-codemirror-lang-json-DzRRSgj9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-B_seq3PB.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CcuPVz08.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-B3FiTjDN.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CaoLP1ZV.js";import"./vendor-codemirror-lang-python-frX4-6UW.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-Cg3hFNyu.js";import"./vendor-legendapp-list-ZsDnss2w.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-Bsi0q3M9.js";import"./PluginPane-Dx0_Dldo.js";import"./vendor-dnd-kit-accessibility-vxqCsF6D.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-BPUnGgQg.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-C_NzAZis.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./appThemeRegistry-CWAKiwky.js";import"./textMateThemeFromAppTheme-AUvSJIJn.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-qrcode-BTlWCou-.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./useInlineCommentController-Bf5t_8QQ.js";import"./CodeMirrorCommentWidgets-e9rY9Jxg.js";import"./changesTree-CePHbFcj.js";import"./VirtualizedFileDiff-DapU3oMs.js";import"./web-components-BKRdx0aw.js";import"./computeVirtualFileMetrics-BWISD0Ee.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isDiffPlainText-DU3lrpLL.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";let lo=null,ri=!1;const hu=new Promise(n=>{lo=n});function gu(){ri||(ri=!0,lo?.())}const bu=6,xu=n=>n.parentID??null,ii=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},yu=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),vu=(n,e)=>{if(!n)return"";let s=null,i=-1;for(const r of e){const o=yu(r.path);(n===o||n.startsWith(`${o}/`))&&o.length>i&&(s=r,i=o.length)}return s?s.label?.trim()||ii(s.path):ii(n)},wu=()=>{const n=Zt.getState().activeSessions,e=ya.getState().index.session.unseenCount,s=ze.getState().notifyOnSubtasks,i=Ye.getState().projects,r=Tn.getState().ids,o=Li.getState().rankById;let a=0;const d=[];for(const f of n){const l=xu(f)!==null,g=(e[f.id]??0)>0&&(!l||s);g&&(a+=1),l||d.push({session:f,unread:g,project:vu(Wn(f),i)})}d.sort((f,l)=>va(f.session,l.session,r,o));const m=d.slice(0,bu).map(({session:f,unread:l,project:p})=>({id:f.id,title:f.title??"",unread:l,project:p}));return{runtimeKey:ls(),attentionCount:a,recentSessions:m}},ju="__OPENCHAMBER_WIDGET_SNAPSHOT__",ku=()=>{typeof window>"u"||(window[ju]=()=>{try{return JSON.stringify(wu())}catch{return null}})},kn="mobile-app-update-available",oi="mobile-app-update-toast-dismissed-version",Su=()=>{const n=me.c(8),{t:e}=be(),s=Xt(Nu),i=Xt(Cu),r=Xt(Ru),o=Xt(Eu);let a;n[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,n[0]=a):a=n[0];const d=Pn.useRef(a);let m,f;return n[1]!==s||n[2]!==o||n[3]!==i||n[4]!==e||n[5]!==r?(m=()=>{if(zi()!=="android"||i!=="mobile"||!s||!r||!o){xe.dismiss(kn);return}Ur().getItem(oi)!==r&&(d.current.has(r)||(d.current.add(r),xe.info(e("mobileUpdate.toast.available.title"),{id:kn,description:e("mobileUpdate.toast.available.description",{version:r}),duration:1/0,icon:t.jsx(Q,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{wa(o)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{Ur().setItem(oi,r),xe.dismiss(kn)}}})))},f=[s,o,i,e,r],n[1]=s,n[2]=o,n[3]=i,n[4]=e,n[5]=r,n[6]=m,n[7]=f):(m=n[6],f=n[7]),Pn.useEffect(m,f),null};function Nu(n){return n.available}function Cu(n){return n.runtimeType}function Ru(n){return n.info?.version}function Eu(n){return n.info?.downloadUrl}const ai=300,Iu="openchamber.mobile.connectLog.v1",Qt=[];if(typeof window<"u")try{window.localStorage.removeItem(Iu)}catch{}const dr=(n,e)=>{Qt.push({at:Date.now(),step:n,detail:e}),Qt.length>ai&&Qt.splice(0,Qt.length-ai)};typeof window<"u"&&dr("app:launch","{}");const Au=()=>[...Qt],Pu=n=>{const e=new Date(n),s=(i,r=2)=>String(i).padStart(r,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},co=n=>`${Pu(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,Tu=()=>Qt.map(co).join(`
3
3
  `),uo=(n,e)=>{const s=me.c(10),i=700,r=u.useRef(null),o=u.useRef(null),a=u.useRef(!1);let d;s[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{r.current!==null&&window.clearTimeout(r.current),r.current=null,o.current=null},s[0]=d):d=s[0];const m=d;let f,l;s[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>m,l=[m],s[1]=f,s[2]=l):(f=s[1],l=s[2]),u.useEffect(f,l);let p;s[3]!==i||s[4]!==n?(p=w=>{a.current=!1,o.current={x:w.clientX,y:w.clientY},r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,a.current=!0,n()},i)},s[3]=i,s[4]=n,s[5]=p):p=s[5];const g=p;let h;s[6]===Symbol.for("react.memo_cache_sentinel")?(h=w=>{const C=o.current;C&&(Math.abs(w.clientX-C.x)>10||Math.abs(w.clientY-C.y)>10)&&m()},s[6]=h):h=s[6];const b=h;let S;s[7]===Symbol.for("react.memo_cache_sentinel")?(S=w=>{a.current&&(a.current=!1,w.preventDefault(),w.stopPropagation())},s[7]=S):S=s[7];const v=S;let I;return s[8]!==g?(I={onPointerDown:g,onPointerMove:b,onPointerUp:m,onPointerCancel:m,onClickCapture:v},s[8]=g,s[9]=I):I=s[9],I},Ys="openchamber.mobile.connections.v1",Du="openchamber.mobile.",li="openchamber.mobile.deviceId",_u=()=>{try{const n=window.localStorage.getItem(li);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem(li,e),e}catch{return crypto.randomUUID()}},ci=()=>`mobile:${_u()}`,ui=()=>{try{const n=Fc.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},fo=12,mo=8e3,Mu=2500,zu=3e3,Xs=2500,Ou=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},cs=n=>{const e=n.trim();if(!e)return"";const s=/^https?:\/\//i.test(e)?e:`http://${e}`,i=new URL(s);return i.hash="",i.search="",i.pathname=i.pathname.replace(/\/+$/,""),i.toString().replace(/\/+$/,"")},Ks=n=>{try{return new URL(n).host}catch{return n}},is=n=>{try{return cs(n)}catch{return n.trim().replace(/\/+$/g,"")}},po=(n,e)=>is(n)===is(e),ho=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,Bu=n=>`relay://${n.serverId}`,nn=n=>n.candidates.filter(e=>e.kind==="direct"),Ot=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},wt=n=>{const e=nn(n)[0];if(e)return e.url;const s=Ot(n);return s?Bu(s):""},Me=n=>{const e=Ot(n);if(e)return ho(e);const s=nn(n)[0];return s?is(s.url):""},Qs=(n,e)=>{const s=n.find(o=>o.kind==="relay"),i=s&&s.kind==="relay"?s.relay.serverId:null,r=new Set(n.filter(o=>o.kind==="direct").map(o=>is(o.url)));return e.some(o=>o.kind==="relay"?i!==null&&o.relay.serverId===i:r.has(is(o.url)))},fr=n=>{const e=(()=>{try{return cs(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},di=n=>{if(n.candidates&&n.candidates.length>0)return n.candidates;const e=[];return typeof n.url=="string"&&n.url.trim()&&!/^relay:\/\//i.test(n.url.trim())&&e.push(...fr(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},mr=n=>{if(!n||typeof n!="object"||Array.isArray(n))return null;const e=n;if(typeof e.relayUrl!="string"||!e.relayUrl.trim()||typeof e.serverId!="string"||!e.serverId.trim())return null;const s=e.hostEncPubJwk;if(!s||typeof s!="object"||Array.isArray(s))return null;const i=s;return i.kty!=="EC"||i.crv!=="P-256"||typeof i.x!="string"||!i.x||typeof i.y!="string"||!i.y?null:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:{kty:"EC",crv:"P-256",x:i.x,y:i.y}}},go=n=>{try{return JSON.stringify(n)}catch{return String(n)}},ke=(n,e={})=>{const s=go(e);console.info("[mobile-connect]",n,s),dr(n,s)},bs=(n,e={})=>{ke(n,e)},os=(n,e={})=>{const s=go(e);console.info("[mobile-storage]",n,s),dr(n,s)},Lu=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},$u=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},Fu=async(n,e)=>{if(!Be())return null;try{const{CapacitorHttp:s}=await ns(async()=>{const{CapacitorHttp:o}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:o}},[]),i=ua(n,new Headers(e?.headers)),r=await s.request({url:n,method:e?.method||"GET",headers:Object.fromEntries(i.entries()),data:$u(e?.body)});return{ok:r.status>=200&&r.status<300,status:r.status,source:"native-http",json:async()=>Lu(r.data)}}catch(s){return ke("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},Wu=async(n,e)=>{const s=await fetch(n,e).catch(i=>(ke("browser-fetch:failed",{url:n,error:i instanceof Error?i.message:String(i)}),null));return s?{ok:s.ok,status:s.status,source:"browser-fetch",json:()=>s.json()}:null},Ct=async(n,e,s)=>{let i;const r=new Promise(o=>{i=window.setTimeout(()=>{s?.(),o(null)},n)});try{return await Promise.race([e,r])}catch{return null}finally{i!==void 0&&window.clearTimeout(i)}},Bt=async(n,e,s)=>{const i=s?.totalTimeoutMs??mo,r=Date.now(),o=await Ct(Math.min(Mu,i),Fu(n,e));if(o)return o;const a=new AbortController,d=Math.max(500,i-(Date.now()-r));return Ct(d,Wu(n,{...e,signal:a.signal}),()=>a.abort())},rn=async n=>{if(!n)return null;const e=await n.json().catch(()=>null);if(!e||typeof e!="object")return null;const s=e;return{authenticated:typeof s.authenticated=="boolean"?s.authenticated:void 0,disabled:typeof s.disabled=="boolean"?s.disabled:void 0,scope:typeof s.scope=="string"?s.scope:void 0}},as=15e3,Vu=async(n,e,s,i=as,r)=>{const o=Oi({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk}),a=d=>d==="ok"&&r?.keepTunnel?{outcome:d,tunnel:o}:(o.close(),{outcome:d});try{const d=e?{Authorization:`Bearer ${e}`}:void 0,m=await Ct(i,o.fetch("/auth/session",{headers:d}).catch(()=>null));if(ke("relay:session",{ok:m?.ok===!0,status:m?.status??null,hasToken:!!e}),!m)return a("unreachable");if(m.status===401)return a(e?"auth-failed":"needs-login");if(!m.ok&&m.status!==404)return a("auth-failed");const f=await rn(m);return f&&f.disabled!==!0&&f.authenticated===!1?a(e?"auth-failed":"needs-login"):a("ok")}catch(d){throw o.close(),d}},Uu=(n,e,s,i,r)=>{const o=typeof window<"u"?window.location.origin:"",a={relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk,...s?{grant:s}:{}};r&&ca(a,r),Jt({apiBaseUrl:o,clientToken:e,runtimeKey:i??ho(n),relay:a})},Ku=n=>{if(!n||typeof n!="object")return null;const e=n;if(e.kind==="direct")return typeof e.url=="string"&&e.url.trim()?{kind:"direct",url:e.url}:null;if(e.kind==="relay"){const s=mr(e.relay);return s?{kind:"relay",relay:s}:null}return null},Gu=n=>{if(n.mode==="relay"){const e=mr(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?fr(n.url):[]},Lt=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(Ys)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=Be();return n.flatMap(s=>{if(!s||typeof s!="object")return[];const i=s;if(typeof i.id!="string")return[];const r=Array.isArray(i.candidates)?i.candidates.map(Ku).filter(m=>!!m):Gu(i);if(r.length===0)return[];const o=typeof i.clientToken=="string"&&i.clientToken.trim()?i.clientToken:void 0,a=typeof i.label=="string"&&i.label.trim()?i.label:Ks(wt({candidates:r})),d={id:i.id,label:a,candidates:r,lastUsedAt:typeof i.lastUsedAt=="number"?i.lastUsedAt:0};return e?[{...d,hasToken:!!i.hasToken||!!o}]:[{...d,clientToken:o,hasToken:!!o}]}).sort((s,i)=>i.lastUsedAt-s.lastUsedAt)},zn=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},pr=n=>{if(typeof window>"u")return;const e=Be(),s=n.slice(0,fo).map(i=>{const r={id:i.id,label:i.label,candidates:i.candidates.map(zn),lastUsedAt:i.lastUsedAt};return e?{...r,hasToken:!!(i.hasToken||i.clientToken)}:{...r,clientToken:i.clientToken}});try{window.localStorage.setItem(Ys,JSON.stringify(s))}catch(i){console.warn("[mobile-storage] failed to persist connection metadata",i)}},bo=(n,e)=>{const s=n.find(o=>e.id&&o.id===e.id||Qs(o.candidates,e.candidates)),i=Be(),r={id:e.id||s?.id||crypto.randomUUID(),label:e.label,candidates:e.candidates,lastUsedAt:Date.now(),...i?{hasToken:e.hasToken??(!!e.clientToken||s?.hasToken||!1)}:{clientToken:e.clientToken??s?.clientToken,hasToken:!!(e.clientToken??s?.clientToken)}};return[r,...n.filter(o=>o.id!==r.id&&!Qs(o.candidates,e.candidates))].slice(0,fo)},hr=$c,Hu=0,gr=n=>`${Du}token.${encodeURIComponent(n)}`,qu=async(n,e)=>{let s;const i=new Promise(r=>{s=window.setTimeout(()=>r(e),zu)});try{return await Promise.race([n.catch(()=>e),i])}finally{s!==void 0&&window.clearTimeout(s)}},br=async(n,e,s)=>Be()?qu(e().catch(i=>(console.warn(`[mobile-storage] ${n} failed`,i),s)),s):s,Is=async n=>{os("secure:read-start",{key:n});const e=await br("secure:read",async()=>(await hr.internalGetItem({prefixedKey:gr(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return os("secure:read",{key:n,hasToken:!!s}),s},Mt=async(n,e)=>{os("secure:write-start",{key:n});const s=await br("secure:write",async()=>(await hr.internalSetItem({prefixedKey:gr(n),data:e,sync:!1,access:Hu}),!0),!1);return os("secure:write",{key:n,ok:s}),s},Ju=async n=>{await br("secure:delete",async()=>(await hr.internalRemoveItem({prefixedKey:gr(n),sync:!1}),!0),!1)},Yu=async(n,e)=>{let s=0,i=0;return{records:await Promise.all(n.map(async o=>{if(!o||typeof o!="object")return o;const a=o,d=typeof a.url=="string"?a.url:null,m=typeof a.clientToken=="string"?a.clientToken.trim():"";if(!d||!m)return o;if(!await e(d,m))return i+=1,o;s+=1;const{clientToken:f,...l}=a;return{...l,hasToken:!0}})),migrated:s,failed:i}},xo=async()=>{if(typeof window>"u"||!Be())return;let n;try{n=JSON.parse(window.localStorage.getItem(Ys)||"[]")}catch{return}if(!Array.isArray(n))return;const e=n.filter(i=>!!i&&typeof i=="object"&&typeof i.url=="string"&&typeof i.clientToken=="string"&&!!i.clientToken.trim());if(e.length===0)return;os("secure:migrate-start",{count:e.length});const s=await Yu(n,async(i,r)=>{const o=is(i);return await Mt(o,r)?await Is(o)===r:!1});if(s.migrated>0)try{window.localStorage.setItem(Ys,JSON.stringify(s.records))}catch(i){console.warn("[mobile-storage] failed to finalize secure token migration",i);return}os("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},Xu=async()=>(await xo(),Lt()),Zs=async n=>{const e=bo(Lt(),n);return pr(e),Be()&&n.clientToken&&await Mt(Me({candidates:n.candidates}),n.clientToken),e},Qu=async n=>{const e=Lt(),s=e.find(r=>r.id===n)??null,i=e.filter(r=>r.id!==n);return pr(i),s&&Be()&&await Ju(Me(s)),i},Zu=1500,en=async(n,e,s)=>{const i=s?.fast?{totalTimeoutMs:Xs}:void 0,r=Ot({candidates:n})?.serverId??null,o=n.find(f=>f.kind==="relay")??null,a=n.filter(f=>f.kind==="direct"),d=async()=>{for(const f of a){const l=cs(f.url)||f.url,p=e?{Authorization:`Bearer ${e}`}:void 0,g=await Bt(`${l}/health`,{method:"GET"},i);if(ke("probe:direct:health",{url:l,ok:g?.ok===!0,status:g?.status??null,source:g?.source??null}),!g?.ok)continue;if(r){const v=await g.json().catch(()=>null),I=v&&typeof v=="object"?v.serverId:null;if(typeof I=="string"&&I&&I!==r){ke("probe:server-id-mismatch",{url:l});continue}}const h=await Bt(`${l}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:p},i);if(ke("probe:direct:session",{url:l,ok:h?.ok===!0,status:h?.status??null,source:h?.source??null,hasToken:!!e}),h?.status===401)return{status:"needs-login"};if(!h||!h.ok&&h.status!==404)continue;const b=await rn(h);if(b&&b.disabled!==!0&&b.authenticated===!1)return{status:"needs-login"};const S=b?.disabled===!0;return!e&&Be()&&!S&&b?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:l}}}return{status:"unreachable"}},m=async()=>{if(!o)return{status:"unreachable"};const{outcome:f,tunnel:l}=await Vu(o.relay,e,void 0,s?.fast?Xs:mo,{keepTunnel:!0});return f==="ok"?{status:"ok",transport:{kind:"relay",relay:o.relay,tunnel:l}}:f==="needs-login"||f==="auth-failed"?{status:"needs-login"}:{status:"unreachable"}};return o?a.length===0?m():new Promise(f=>{let l=!1,p=!1,g,h=null,b=null;const S=w=>{w?.status==="ok"&&w.transport.kind==="relay"&&w.transport.tunnel?.close()},v=w=>{l||(l=!0,f(w))},I=()=>{p||l||(g!==void 0&&(window.clearTimeout(g),g=void 0),m().then(w=>{if(b=w,l||p){S(w);return}if(w.status==="ok"||w.status==="needs-login"){v(w);return}h&&v(h)}))};d().then(w=>{if(h=w,!l){if(w.status==="ok"||w.status==="needs-login"){p=!0,g!==void 0&&window.clearTimeout(g),S(b),v(w);return}if(b){v(b);return}I()}}),g=window.setTimeout(I,Zu)}):d()},zt=(n,e,s)=>{n.kind==="relay"?Uu(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel):Jt({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),vo()},js=()=>{const n=Lt()[0];return n?.label?.trim()?n.label:null},xs=async n=>{const e=n?.fast!==!1;await xo();const s=Lt()[0];if(ke("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let i;if(Be()){if(s.hasToken&&(i=await Is(Me(s)),!i))return{status:"no-candidate"}}else if(i=s.clientToken,!i&&s.hasToken)return{status:"no-candidate"};const r=await en(s.candidates,i,{fast:e});return ke("auto-connect:probe",{status:r.status,candidates:s.candidates.map(o=>o.kind)}),r.status==="needs-login"?{status:"needs-login",label:s.label}:r.status!=="ok"?{status:"unreachable",label:s.label}:n?.skipIfConnected&&ft()?(r.transport.kind==="relay"&&r.transport.tunnel?.close(),ke("auto-connect:superseded",{}),{status:"no-candidate"}):(await Zs({id:s.id,label:s.label,candidates:s.candidates}),zt(r.transport,i??null,{runtimeKey:Me(s)}),{status:"connected"})},ed=async(n,e)=>{let s="";try{s=cs(n.url)}catch{return!1}if(!s)return!1;const i=n.clientToken?.trim()||void 0,r=i?{Authorization:`Bearer ${i}`}:void 0,o=e?.fast?{totalTimeoutMs:Xs}:void 0;if(!(await Bt(`${s}/health`,{method:"GET",headers:r},o))?.ok)return!1;const d=await Bt(`${s}/auth/session`,{method:"GET",credentials:i?"omit":"include",headers:r},o);if(!d||!d.ok&&d.status!==404)return!1;const m=await rn(d);return!(m&&m.disabled!==!0&&m.authenticated===!1)},td=n=>[...n].sort((e,s)=>{const i=(e.priority??100)-(s.priority??100);if(i!==0)return i;const r=o=>o.type==="relay"?2:o.url.startsWith("https://")?0:1;return r(e)-r(s)}).flatMap(e=>{if(e.type==="relay"){const s=mr({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return fr(e.url)}),fi=async n=>{const e=Ot({candidates:n})?.serverId??null;for(const s of n){if(s.kind==="relay"){const o=Oi(s.relay),a=await Ct(as,o.fetch("/health").catch(()=>null));if(ke("establish:relay:health",{ok:a?.ok===!0,status:a?.status??null}),a?.ok)return{kind:"relay",relay:s.relay,tunnel:o};o.close();continue}const i=cs(s.url)||s.url,r=await Bt(`${i}/health`,{method:"GET"});if(ke("establish:direct:health",{ok:r?.ok===!0,status:r?.status??null}),!!r?.ok){if(e){const o=await r.json().catch(()=>null),a=o&&typeof o=="object"?o.serverId:null;if(typeof a=="string"&&a&&a!==e){ke("establish:server-id-mismatch",{url:i});continue}}return{kind:"direct",url:i}}}return null},sd=async(n,e)=>{if(!Es())return ed(n,e);const s=await Ct(e?.fast?Xs:as,Fn("/auth/session").then(r=>r).catch(()=>null));if(!s)return!0;if(s.status===401)return!1;if(!s.ok&&s.status!==404)return!0;const i=await rn(s);return!(i&&i.disabled!==!0&&i.authenticated===!1)},nd=n=>n.kind==="relay"?Es():!Es()&&po(n.url,ft()),yo=()=>{const n=ls();return n?Lt().find(e=>Me(e)===n)??null:null},mi=n=>{const e=ls();return!!e&&Me(n)===e},Gs=async n=>{const e=n?.fast!==!1,s=yo();if(!s)return ke("reprobe:no-connection",{runtimeKey:!!ls()}),"no-connection";let i;if(Be()?i=s.hasToken?await Is(Me(s)):void 0:i=s.clientToken,!i&&s.hasToken)return ke("reprobe:no-token",{hasToken:!0}),"unreachable";ke("reprobe:start",{candidates:s.candidates.map(f=>f.kind),fast:e,hasToken:!!i});const r=s.candidates.findIndex(f=>nd(f.kind==="relay"?{kind:"relay",relay:f.relay}:{kind:"direct",url:f.url})),o=r>=0?s.candidates.slice(0,r):s.candidates,a=await en(o,i,{fast:e});if(ke("reprobe:better",{status:a.status,probed:o.length}),a.status==="ok")return await Zs({id:s.id,label:s.label,candidates:s.candidates}),zt(a.transport,i??null,{runtimeKey:Me(s)}),"switched";if(a.status==="needs-login")return"needs-login";if(r>=0){const f=await sd({url:ft(),clientToken:i},{fast:e});if(ke("reprobe:current",{stillValid:f}),f)return vo(),"unchanged"}const d=r>=0?s.candidates.slice(r+1):[],m=await en(d,i,{fast:e});return ke("reprobe:fallback",{status:m.status,probed:d.length}),m.status==="ok"?(await Zs({id:s.id,label:s.label,candidates:s.candidates}),zt(m.transport,i??null,{runtimeKey:Me(s)}),"switched"):m.status==="needs-login"?"needs-login":"unreachable"},rd=5e3;let Sn=!1;const id=async()=>{if(Sn)return"skipped";const n=yo();if(!n)return ke("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=Ot(n);if(!e)return ke("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";Sn=!0;try{const s=await Ct(as,Fn("/api/client-auth/connection/candidates").then(f=>f).catch(()=>null));if(!s?.ok)return ke("candidates:refresh-skip",{reason:"fetch-failed",status:s?.status??null}),"skipped";const i=await s.json().catch(()=>null);if(!i||i.serverId!==e.serverId)return ke("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const r=Array.isArray(i.candidates)?i.candidates:[],o=[];for(const f of r){if(!f||typeof f!="object")continue;const l=f;if(!(l.type!=="lan"||typeof l.url!="string"))try{const p=cs(l.url);p&&!o.includes(p)&&o.push(p)}catch{}}if(o.length===0)return ke("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const a=nn(n).filter(f=>f.url.startsWith("https://")),d=[...o.map(f=>({kind:"direct",url:f})),...a,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map(zn))===JSON.stringify(d.map(zn))?"unchanged":(ke("candidates:refreshed",{lanCount:o.length}),await Zs({id:n.id,label:n.label,candidates:d}),"updated")}finally{Sn=!1}},vo=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await id().catch(()=>"skipped");ke("candidates:refresh-result",{result:n}),n==="updated"&&Es()&&await Gs().catch(()=>null)})()},rd)},wo=n=>{const{t:e}=be(),[s,i]=u.useState(()=>Lt()),[r,o]=u.useState(null),[a,d]=u.useState(null),[m,f]=u.useState(null),l=u.useRef(s),p=u.useRef(null),g=u.useRef(Ou()),h=u.useCallback(N=>{l.current=N,i(N)},[]),b=u.useCallback(N=>{p.current=N,o(N)},[]),S=u.useCallback(N=>{p.current===N&&(p.current=null,o(null))},[]);u.useEffect(()=>{let N=!1;return Xu().then(R=>{N||h(R)}),()=>{N=!0}},[h]);const v=u.useCallback(N=>{const R=bo(l.current,N);return h(R),pr(R),R},[h]),I=u.useCallback(async N=>{d(null),b("connect");try{const R=di(N);if(R.length===0){d(e("mobile.connect.error.urlRequired"));return}const k=N.id?l.current.find(V=>V.id===N.id):l.current.find(V=>Qs(V.candidates,R)),P=N.label?.trim()||k?.label||Ks(wt({candidates:R})),B=N.relayGrant;let D=N.clientToken?.trim()||void 0;const x=!!D;D||(Be()?k?.hasToken&&(D=await Is(Me({candidates:R}))):D=k?.clientToken),ke("connect:start",{candidates:R.map(V=>V.kind),hasToken:!!D});const _=await en(R,D);if(ke("connect:probe",{status:_.status}),_.status==="unreachable"){d(e("mobile.connect.error.unreachable"));return}if(_.status==="needs-login"){v({id:k?.id,label:P,candidates:R}),f({id:k?.id??crypto.randomUUID(),label:P,candidates:R,relay:Ot({candidates:R})??void 0,relayGrant:B});return}D&&x&&Be()&&await Mt(Me({candidates:R}),D),v({id:k?.id,label:P,candidates:R,clientToken:D}),zt(_.transport,D??null,{runtimeKey:Me({candidates:R}),grant:B}),n()}catch(R){console.warn("[mobile-connect] connect threw",R),d(e("mobile.connect.error.invalidUrl"))}finally{S("connect")}},[b,S,n,v,e]),w=u.useCallback(async N=>{if(p.current==="pairing")return;d(null),b("pairing");const R=td(N.candidates);let k=null,P=!1;try{if(k=await fi(R),!k){d(e("mobile.connect.error.unreachable"));return}const B=JSON.stringify({pairingId:N.pairingId,secret:N.secret,clientLabel:"OpenChamber Mobile",clientKind:"mobile",deviceName:"OpenChamber Mobile",devicePlatform:ui(),dedupeKey:ci()}),D={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:B},x=k.kind==="relay"?await Ct(as,k.tunnel.fetch("/api/client-auth/pairing/redeem",D).catch(()=>null)):await Bt(`${k.url}/api/client-auth/pairing/redeem`,D);if(!x?.ok){d(e("mobile.connect.error.authRequired"));return}const _=await x.json().catch(()=>null),V=typeof _?.clientToken=="string"?_.clientToken.trim():"";if(!V){d(e("mobile.connect.error.authRequired"));return}const j=typeof _?.server?.label=="string"?_.server.label:"",$=N.label||j||Ks(wt({candidates:R}));if(Be()&&!await Mt(Me({candidates:R}),V)){d(e("mobile.connect.error.authRequired"));return}v({label:$,candidates:R,clientToken:V}),zt(k.kind==="relay"?{kind:"relay",relay:k.relay,tunnel:k.tunnel}:{kind:"direct",url:k.url},V,{runtimeKey:Me({candidates:R})}),P=k.kind==="relay",n()}catch(B){console.warn("[mobile-connect] pairing threw",B),d(e("mobile.connect.error.authRequired"))}finally{!P&&k?.kind==="relay"&&k.tunnel.close(),S("pairing")}},[b,S,n,v,e]),C=u.useCallback(async N=>{if(!m||!N.trim()||p.current==="password")return;d(null),b("password");const R=g.current.begin(),k=()=>g.current.isCurrent(R),{id:P,label:B,candidates:D}=m;let x=null,_=!1;try{if(x=await fi(D),!k())return;if(!x){d(e("mobile.connect.error.unreachable"));return}const V={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:N,trustDevice:!0,issueClientToken:!0,clientLabel:"OpenChamber Mobile",clientKind:"mobile",devicePlatform:ui(),dedupeKey:ci()})};ke("password:start",{transport:x.kind});const j=x.kind==="relay"?await Ct(as,x.tunnel.fetch("/auth/session",V).catch(()=>null)):await Bt(`${x.url}/auth/session`,V);if(!k())return;if(ke("password:done",{ok:j?.ok===!0,status:j?.status??null}),!j?.ok){d(e("mobile.connect.error.passwordFailed"));return}const $=await j.json().catch(()=>null);if(!k())return;const F=typeof $?.clientToken=="string"?$.clientToken.trim():"";if(ke("password:token",{issued:!!F}),!F){if(x.kind==="direct"&&!Be()){v({id:P,label:B,candidates:D}),f(null),zt({kind:"direct",url:x.url},null,{runtimeKey:Me({candidates:D})}),n();return}d(e("mobile.connect.error.authRequired"));return}if(Be()&&(!k()||(await Mt(Me({candidates:D}),F),!k()))||!k()||(v({id:P,label:B,candidates:D,clientToken:F}),f(null),zt(x.kind==="relay"?{kind:"relay",relay:x.relay,tunnel:x.tunnel}:{kind:"direct",url:x.url},F,{runtimeKey:Me({candidates:D})}),_=x.kind==="relay",!k()))return;n()}catch(V){if(!k())return;console.warn("[mobile-connect] password threw",V),d(e("mobile.connect.error.passwordFailed"))}finally{!_&&x?.kind==="relay"&&x.tunnel.close(),k()&&S("password")}},[b,S,n,m,v,e]),A=u.useCallback(()=>{g.current.cancel(),S("password"),f(null),d(null)},[S]),y=u.useCallback(async N=>{d(null);let R=di(N);const k=N.id?l.current.find(x=>x.id===N.id)??null:null;if(k){const x=R.filter(j=>j.kind==="direct"),_=nn(k).filter(j=>j.url.startsWith("https://")&&!x.some($=>po($.url,j.url))),V=Ot(k);R=[...x,..._,...V?[{kind:"relay",relay:V}]:[]]}if(R.length===0)return d(e("mobile.connect.error.urlRequired")),null;const P=N.clientToken?.trim()||void 0,B=N.label?.trim()||Ks(wt({candidates:R}));if(Be()){const x=Me({candidates:R});if(P)await Mt(x,P);else if(k?.hasToken){const _=Me(k);if(_&&x&&_!==x){const V=await Is(_);V&&await Mt(x,V)}}}return v({id:N.id,label:B,candidates:R,clientToken:P}).find(x=>Qs(x.candidates,R))??null},[v,e]),E=u.useCallback(async N=>{const R=l.current.find(P=>P.id===N)??null,k=await Qu(N);return h(k),R},[h]);return{connections:s,isBusy:r!==null,isPasswordBusy:r==="password",error:a,pendingConnection:m,connect:I,redeemPairingConnection:w,submitPassword:C,cancelPassword:A,saveConnection:y,removeConnection:E,setError:d}},jo=n=>{const e=me.c(31),{onClose:s}=n,{t:i}=be(),[r,o]=u.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=Au(),e[0]=a):a=e[0];const d=a;let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{$i(Tu()).then(N=>{N.ok&&(o(!0),window.setTimeout(()=>o(!1),2e3))})},e[1]=m):m=e[1];const f=m;let l;e[2]!==i?(l=i("mobile.connectionDebug.title"),e[2]=i,e[3]=l):l=e[3];let p;e[4]!==l?(p=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:l}),e[4]=l,e[5]=p):p=e[5];const g=r?"check":"file-copy";let h;e[6]!==g?(h=t.jsx(Q,{name:g,className:"size-4"}),e[6]=g,e[7]=h):h=e[7];let b;e[8]!==r||e[9]!==i?(b=i(r?"mobile.connectionDebug.copied":"mobile.connectionDebug.copy"),e[8]=r,e[9]=i,e[10]=b):b=e[10];let S;e[11]!==h||e[12]!==b?(S=t.jsxs(je,{type:"button",variant:"outline",size:"sm",onClick:f,disabled:d.length===0,children:[h,b]}),e[11]=h,e[12]=b,e[13]=S):S=e[13];let v;e[14]!==i?(v=i("mobile.connectionDebug.close"),e[14]=i,e[15]=v):v=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(Q,{name:"close",className:"size-[18px]"}),e[16]=I):I=e[16];let w;e[17]!==s||e[18]!==v?(w=t.jsx(je,{type:"button",variant:"ghost",size:"icon","aria-label":v,onClick:s,children:I}),e[17]=s,e[18]=v,e[19]=w):w=e[19];let C;e[20]!==w||e[21]!==S?(C=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[S,w]}),e[20]=w,e[21]=S,e[22]=C):C=e[22];let A;e[23]!==C||e[24]!==p?(A=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[p,C]}),e[23]=C,e[24]=p,e[25]=A):A=e[25];let y;e[26]!==i?(y=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:d.length===0?t.jsx("p",{className:"typography-small text-muted-foreground",children:i("mobile.connectionDebug.empty")}):t.jsx("pre",{className:"whitespace-pre-wrap break-words typography-code text-muted-foreground",children:d.map(co).join(`
4
4
  `)})}),e[26]=i,e[27]=y):y=e[27];let E;return e[28]!==A||e[29]!==y?(E=t.jsxs("div",{className:"fixed inset-0 z-[70] flex flex-col bg-background pb-[var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))] pt-[var(--safe-area-inset-top,env(safe-area-inset-top,0px))] text-foreground",children:[A,y]}),e[28]=A,e[29]=y,e[30]=E):E=e[30],E},ko=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},od=()=>window.Capacitor?.getPlatform?.()==="android",So=n=>{const e=n.trim();if(!e)return null;if(/^openchamber:\/\//i.test(e)){const s=da(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},No=(n,e)=>{const s=So(n);if(!s&&e?.pairingStringFallback){const i=fa(n);if(i)return{status:"pairing",pairing:i}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},ad=async(n,e)=>{if(!n.startScan||!n.stopScan||!n.addListener)return{status:"unsupported"};if(e?.aborted)return{status:"cancelled"};let s,i,r=!1,o=()=>{};const a=new Promise(f=>{o=f}),d=f=>{r||(r=!0,o(f))},m=()=>d({status:"cancelled"});e?.addEventListener("abort",m,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:l})=>{const p=l?.[0],g=(p?.rawValue??p?.displayValue??"").trim();g&&d(No(g,{pairingStringFallback:!0}))})).then(l=>{s=l}),Promise.resolve(n.addListener("scanError",()=>d({status:"failed"}))).then(l=>{i=l})])).some(({status:l})=>l==="rejected")?d({status:"failed"}):r||n.startScan({formats:["QR_CODE"]}).catch(()=>d({status:"failed"})),await a}finally{e?.removeEventListener("abort",m),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(i?.remove()),n.stopScan()])}},On=()=>ko()!==null,Co=async n=>{const e=ko();if(!e)return{status:"unsupported"};try{if(e.requestPermissions){const a=(await e.requestPermissions())?.camera;if(a&&a!=="granted"&&a!=="limited")return{status:"permission-denied"}}if(n?.signal?.aborted)return{status:"cancelled"};if(od())return ad(e,n?.signal);if(!e.scan)return{status:"unsupported"};const i=(await e.scan({formats:["QR_CODE"]}))?.barcodes?.[0],r=(i?.rawValue??i?.displayValue??"").trim();return r?No(r):{status:"cancelled"}}catch{return{status:"failed"}}},ts={autoComplete:"off",autoCorrect:"off",spellCheck:!1},ks="oc-surface-elevated h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-interactive-border-focus focus:ring-2 focus:ring-ring",Ro=n=>{const e=me.c(22),{onCancel:s}=n,{t:i}=be(),r=u.useRef(null);let o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{const I={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},w={value:document.body.style.getPropertyValue("background-color"),priority:document.body.style.getPropertyPriority("background-color")};document.documentElement.style.setProperty("background-color","rgba(0, 0, 0, 0)","important"),document.body.style.setProperty("background-color","rgba(0, 0, 0, 0)","important");const C=new Map,A=E=>{!(E instanceof HTMLElement)||E===r.current||C.has(E)||(C.set(E,{opacity:E.style.opacity,pointerEvents:E.style.pointerEvents}),E.style.setProperty("opacity","0"),E.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(A);const y=new MutationObserver(E=>{E.forEach(N=>N.addedNodes.forEach(A))});return y.observe(document.body,{childList:!0}),()=>{y.disconnect(),C.forEach(ld),I.value?document.documentElement.style.setProperty("background-color",I.value,I.priority):document.documentElement.style.removeProperty("background-color"),w.value?document.body.style.setProperty("background-color",w.value,w.priority):document.body.style.removeProperty("background-color")}},a=[],e[0]=o,e[1]=a):(o=e[0],a=e[1]),u.useLayoutEffect(o,a);let d,m;e[2]!==s?(d=()=>{const I=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",I),()=>document.removeEventListener("visibilitychange",I)},m=[s],e[2]=s,e[3]=d,e[4]=m):(d=e[3],m=e[4]),u.useEffect(d,m);let f;e[5]!==i?(f=i("mobile.connect.scanQr"),e[5]=i,e[6]=f):f=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("div",{className:"aspect-square w-full max-w-72 rounded-[28px] border-2 border-foreground/90 shadow-[0_0_0_9999px_color-mix(in_srgb,var(--surface-background)_18%,transparent)]","aria-hidden":!0}),e[7]=l):l=e[7];let p;e[8]!==i?(p=i("mobile.connect.welcome.scanHint"),e[8]=i,e[9]=p):p=e[9];let g;e[10]!==p?(g=t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-6",children:[l,t.jsx("p",{className:"max-w-sm rounded-[16px] border border-border/60 bg-background px-4 py-3 text-center typography-body text-foreground shadow-sm",children:p})]}),e[10]=p,e[11]=g):g=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Q,{name:"close",className:"size-[18px]"}),e[12]=h):h=e[12];let b;e[13]!==i?(b=i("mobile.instances.cancelEdit"),e[13]=i,e[14]=b):b=e[14];let S;e[15]!==s||e[16]!==b?(S=t.jsxs(je,{type:"button",variant:"outline",size:"lg",className:"mx-auto min-h-12 w-full max-w-sm bg-background",onClick:s,children:[h,b]}),e[15]=s,e[16]=b,e[17]=S):S=e[17];let v;return e[18]!==S||e[19]!==f||e[20]!==g?(v=ss.createPortal(t.jsxs("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":f,className:"fixed inset-0 z-[1000] flex flex-col bg-transparent px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+24px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+24px)] text-foreground",children:[g,S]}),document.body),e[18]=S,e[19]=f,e[20]=g,e[21]=v):v=e[21],v},Eo=()=>{const n=me.c(6),{t:e}=be();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(Yt,{width:96,height:96,isAnimated:!0}),n[0]=s):s=n[0];let i;n[1]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Q,{name:"loader-4",className:"size-[18px] animate-spin"}),n[1]=i):i=n[1];let r;n[2]!==e?(r=e("mobile.connect.connecting"),n[2]=e,n[3]=r):r=n[3];let o;return n[4]!==r?(o=ss.createPortal(t.jsxs("div",{role:"status",className:"fixed inset-0 z-[1000] flex flex-col items-center justify-center gap-5 bg-background px-6 text-foreground",children:[s,t.jsxs("div",{className:"flex items-center gap-2 typography-ui-label text-muted-foreground",children:[i,t.jsx("span",{children:r})]})]}),document.body),n[4]=r,n[5]=o):o=n[5],o};function ld(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const cd=({onConnected:n,notice:e=null})=>{const{t:s}=be(),i=wo(n),{connections:r,isBusy:o,isPasswordBusy:a,error:d,pendingConnection:m}=i,[f,l]=u.useState(""),[p,g]=u.useState(""),[h,b]=u.useState(""),[S,v]=u.useState(!1),[I,w]=u.useState(!1),C=u.useRef(null),A=u.useMemo(()=>On(),[]),[y,E]=u.useState(()=>!On()),[N,R]=u.useState(null),[k,P]=u.useState(""),[B,D]=u.useState(!1),x=uo(u.useCallback(()=>D(!0),[])),_=u.useCallback(z=>{z.preventDefault(),i.connect({url:f,clientToken:h,label:p})},[h,i,p,f]),V=u.useCallback(z=>{if(/^openchamber:\/\//i.test(z.trim())){const G=So(z);if(G){if("pairing"in G){i.redeemPairingConnection(G.pairing);return}l(G.url),G.label&&g(G.label),G.clientToken&&b(G.clientToken);return}}l(z)},[i]),j=u.useCallback(async()=>{if(C.current||o)return;i.setError(null),v(!0);const z=new AbortController;C.current=z;try{const G=await Co({signal:z.signal});switch(C.current===z&&(C.current=null,v(!1)),G.status){case"ok":w(!0),l(G.url),G.label&&g(G.label),G.clientToken&&b(G.clientToken),await i.connect({url:G.url,clientToken:G.clientToken,label:G.label});break;case"pairing":w(!0),await i.redeemPairingConnection(G.pairing);break;case"permission-denied":i.setError(s("mobile.connect.scan.permissionDenied"));break;case"invalid":i.setError(s("mobile.connect.scan.invalid"));break;case"unsupported":i.setError(s("mobile.connect.scan.unsupported"));break;case"failed":i.setError(s("mobile.connect.scan.failed"));break;default:break}}finally{w(!1),C.current===z&&(C.current=null,v(!1))}},[i,o,s]);u.useEffect(()=>()=>C.current?.abort(),[]);const $=u.useCallback(z=>{z.preventDefault(),i.submitPassword(k)},[i,k]),F=u.useCallback(()=>{P(""),i.cancelPassword()},[i]);return t.jsxs(t.Fragment,{children:[S?t.jsx(Ro,{onCancel:()=>C.current?.abort()}):null,I?t.jsx(Eo,{}):null,B?t.jsx(jo,{onClose:()=>D(!1)}):null,t.jsx("main",{className:"oc-keyboard-fill-screen flex min-h-dvh flex-col overflow-y-auto bg-background px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+28px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+28px)] text-foreground",children:t.jsxs("div",{className:"m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8",children:[t.jsxs("div",{className:"flex flex-col items-center gap-5 text-center",children:[t.jsx("span",{...x,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(Yt,{width:72,height:72,className:"size-[72px]"})}),t.jsx("h1",{className:"typography-h2 text-foreground",children:s("mobile.connect.welcome.title")})]}),e?t.jsxs("div",{role:"status",className:"flex w-full items-center gap-3 rounded-[18px] border border-[color-mix(in_srgb,var(--status-warning)_35%,transparent)] bg-[color-mix(in_srgb,var(--status-warning)_10%,transparent)] px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-[color-mix(in_srgb,var(--status-warning)_16%,transparent)] text-[var(--status-warning)]",children:t.jsx(Q,{name:e.kind==="auth-expired"?"lock":"cloud-off",className:"size-[18px]"})}),t.jsx("p",{className:"min-w-0 flex-1 typography-small text-foreground",children:e.kind==="auth-expired"?s("mobile.connect.notice.authExpired",{label:e.label}):s("mobile.connect.notice.unreachable",{label:e.label})})]}):null,m?t.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:$,children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(Q,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0 text-left",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:m.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:m.candidates.some(z=>z.kind==="direct")?wt(m):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...ts,value:k,onChange:z=>P(z.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:ks}),d?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:d}):null,t.jsx(je,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!k.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(je,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:F,children:s("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[A?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(je,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{j()},disabled:S||o,children:[t.jsx(Q,{name:"scan-2",className:Z("size-[18px]",S&&"animate-pulse")}),s(o?"mobile.connect.connecting":"mobile.connect.scanQr")]}),t.jsx("p",{className:"px-2 text-center typography-small text-muted-foreground",children:s("mobile.connect.welcome.scanHint")})]}):null,d&&!y?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:d}):null,r.length>0?t.jsxs("section",{className:"flex w-full flex-col gap-2.5",children:[t.jsx("h2",{className:"text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground",children:s("mobile.connect.saved.title")}),t.jsx("div",{className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(z=>{const G=N===z.id;return t.jsxs("button",{type:"button",disabled:o,className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3.5 py-2.5 text-left last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-70",onClick:()=>{R(z.id),i.connect({id:z.id,candidates:z.candidates,clientToken:z.clientToken,label:z.label}).finally(()=>R(null))},children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(Q,{name:"server",className:"size-[18px]"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:z.label}),t.jsx("span",{className:Z("block truncate typography-small",G?"text-foreground":"text-muted-foreground"),children:G?s("mobile.connect.connecting"):z.candidates.some(q=>q.kind==="direct")?wt(z):s("mobile.connect.relay.badge")})]}),G?t.jsx(Q,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(Q,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},z.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[A?t.jsxs("button",{type:"button",onClick:()=>E(z=>!z),"aria-expanded":y,className:"mx-auto flex items-center gap-1 rounded-full px-2 py-1 typography-small text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[t.jsx("span",{children:s("mobile.connect.manual.toggle")}),t.jsx(Q,{name:"arrow-down-s",className:Z("size-4 transition-transform duration-200",y&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:y?"1fr":"0fr"},children:t.jsx("div",{className:"min-h-0 overflow-hidden",children:t.jsxs("form",{className:"flex w-full flex-col gap-3 pt-3",onSubmit:_,children:[t.jsx("input",{...ts,value:f,onChange:z=>V(z.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:y?void 0:-1,className:Z(ks,"text-center")}),t.jsx("input",{value:p,onChange:z=>g(z.target.value),placeholder:s("mobile.instances.label.placeholder"),"aria-label":s("mobile.instances.label.label"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:y?void 0:-1,className:Z(ks,"text-center")}),t.jsx("input",{...ts,value:h,onChange:z=>b(z.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:y?void 0:-1,autoCapitalize:"none",className:Z(ks,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),d?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:d}):null,t.jsx(je,{type:"submit",variant:A?"outline":"default",size:"lg",className:"h-12 w-full",disabled:o||S||!f.trim(),children:s(o?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},ud=n=>{const e=n.usedPercent;return typeof e!="number"||!Number.isFinite(e)?"text-foreground":e>=80?"text-[var(--status-error)]":e>=50?"text-[var(--status-warning)]":"text-foreground"},dd=n=>{const e=me.c(12),{groups:s,displayMode:i,timeFormatPreference:r,className:o}=n;let a;e[0]!==o?(a=Z("space-y-1.5",o),e[0]=o,e[1]=a):a=e[1];let d;if(e[2]!==i||e[3]!==s||e[4]!==r){let f;e[6]!==i||e[7]!==r?(f=l=>t.jsxs("div",{className:"min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Fi,{providerId:l.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:l.providerName}),l.planLabel?t.jsx("span",{className:"shrink-0 typography-micro capitalize text-muted-foreground",children:l.planLabel}):null,l.status&&l.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:l.status}):null]}),l.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:l.rows.map(p=>{const g=i==="remaining"?p.window.remainingPercent:p.window.usedPercent,h=ja(p.window.valueLabel,g),b=ka(p.window.resetAt,p.window.resetAfterFormatted??p.window.resetAtFormatted,r);return t.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"shrink-0 truncate typography-ui-label text-muted-foreground",children:p.subtitle?`${p.subtitle} · ${p.label}`:p.label}),b?t.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/70",children:b}):null]}),t.jsx("span",{className:Z("shrink-0 typography-ui-label font-semibold tabular-nums",ud(p.window)),children:h==="-"?"":h})]},p.key)})}):null,l.status&&l.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:l.status}):null]},l.providerId),e[6]=i,e[7]=r,e[8]=f):f=e[8],d=s.map(f),e[2]=i,e[3]=s,e[4]=r,e[5]=d}else d=e[5];let m;return e[9]!==a||e[10]!==d?(m=t.jsx("div",{className:a,children:d}),e[9]=a,e[10]=d,e[11]=m):m=e[11],m},pi=380,fd=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},Nn=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),md="—",Io=n=>{const e=me.c(20),{percentage:s}=n;let i,r,o,a,d,m,f;if(e[0]!==s){o=Ia(s??0)??0;const h=Aa(s??0);r=h==="critical"?"var(--status-error)":h==="warn"?"var(--status-warning)":"var(--status-success)",i=2*Math.PI*7.5,a="0 0 18 18",d="size-[18px] -rotate-90",m="progressbar",f=s===null?void 0:Math.round(o),e[0]=s,e[1]=i,e[2]=r,e[3]=o,e[4]=a,e[5]=d,e[6]=m,e[7]=f}else i=e[1],r=e[2],o=e[3],a=e[4],d=e[5],m=e[6],f=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),e[8]=l):l=e[8];let p;e[9]!==i||e[10]!==s||e[11]!==r||e[12]!==o?(p=s===null?null:t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:r,strokeWidth:3,strokeLinecap:"round",strokeDasharray:i,strokeDashoffset:i*(1-o/100),className:"transition-[stroke-dashoffset,stroke] duration-300"}),e[9]=i,e[10]=s,e[11]=r,e[12]=o,e[13]=p):p=e[13];let g;return e[14]!==a||e[15]!==d||e[16]!==m||e[17]!==f||e[18]!==p?(g=t.jsxs("svg",{viewBox:a,className:d,role:m,"aria-valuenow":f,"aria-valuemin":0,"aria-valuemax":100,children:[l,p]}),e[14]=a,e[15]=d,e[16]=m,e[17]=f,e[18]=p,e[19]=g):g=e[19],g},pd=n=>{const e=me.c(13),{icon:s,iconNode:i,label:r,children:o}=n;let a;e[0]!==s||e[1]!==i?(a=i??(s?t.jsx(Q,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=i,e[2]=a):a=e[2];let d;e[3]!==a?(d=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:a}),e[3]=a,e[4]=d):d=e[4];let m;e[5]!==r?(m=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:r}),e[5]=r,e[6]=m):m=e[6];let f;e[7]!==o?(f=t.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:o}),e[7]=o,e[8]=f):f=e[8];let l;return e[9]!==d||e[10]!==m||e[11]!==f?(l=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[d,m,f]}),e[9]=d,e[10]=m,e[11]=f,e[12]=l):l=e[12],l},hd=n=>{const e=me.c(57),{open:s,onClose:i,anchorRef:r,contextDisplay:o,usageGroups:a,usageDisplayMode:d,isUsageLoading:m,timeFormatPreference:f}=n,{t:l}=be(),p=u.useRef(null),[g,h]=u.useState(s),[b,S]=u.useState(!1),{enabled:v}=Vn(),I=u.useRef(null),[w,C]=u.useState(null);let A,y;e[0]!==r||e[1]!==v||e[2]!==s||e[3]!==g?(A=()=>{if(!s||!v||!g)return;const ie=()=>{const ne=r.current?.getBoundingClientRect(),ae=I.current?.getBoundingClientRect();if(!ne||!ae){C(null);return}const H=ne.left-ae.left,re=Math.min(Math.max(H,8),Math.max(8,ae.width-pi-8));C(re)};ie();const O=I.current;if(typeof ResizeObserver>"u"||!O)return;const ee=new ResizeObserver(ie);return ee.observe(O),()=>ee.disconnect()},y=[r,v,s,g],e[0]=r,e[1]=v,e[2]=s,e[3]=g,e[4]=A,e[5]=y):(A=e[4],y=e[5]),u.useLayoutEffect(A,y);const E=v&&w!==null;let N,R;e[6]!==s||e[7]!==g?(N=()=>{if(s){h(!0),S(!1);return}if(!g)return;S(!0);const ie=window.setTimeout(()=>{h(!1),S(!1)},140);return()=>window.clearTimeout(ie)},R=[s,g],e[6]=s,e[7]=g,e[8]=N,e[9]=R):(N=e[8],R=e[9]),u.useEffect(N,R);let k,P;e[10]!==i||e[11]!==s?(k=()=>{if(!s)return;const ie=O=>{O.key==="Escape"&&i()};return document.addEventListener("keydown",ie),()=>document.removeEventListener("keydown",ie)},P=[i,s],e[10]=i,e[11]=s,e[12]=k,e[13]=P):(k=e[12],P=e[13]),u.useEffect(k,P);let B,D;if(e[14]!==r||e[15]!==i||e[16]!==s?(B=()=>{if(!s)return;const ie=O=>{const ee=O.target;if(!(ee instanceof Node)){i();return}p.current?.contains(ee)||r.current?.contains(ee)||i()};return document.addEventListener("pointerdown",ie,!0),document.addEventListener("wheel",ie,!0),()=>{document.removeEventListener("pointerdown",ie,!0),document.removeEventListener("wheel",ie,!0)}},D=[r,i,s],e[14]=r,e[15]=i,e[16]=s,e[17]=B,e[18]=D):(B=e[17],D=e[18]),u.useEffect(B,D),!g)return null;let x;e[19]!==l?(x=l("mobile.header.openMetadataAria"),e[19]=l,e[20]=x):x=e[20];const _=E?"absolute origin-top-left":"mx-3 mt-2",V=b?"pointer-events-none":"pointer-events-auto";let j;e[21]!==_||e[22]!==V?(j=Z("oc-surface-elevated overflow-y-auto overscroll-contain rounded-[20px] border border-border/70 bg-surface-elevated p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",_,V),e[21]=_,e[22]=V,e[23]=j):j=e[23];const $=`${b?"session-metadata-out":"session-metadata-in"} ${b?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let F;e[24]!==w||e[25]!==E?(F=E?{top:8,left:w??8,width:`min(${pi}px, calc(100% - 16px))`}:null,e[24]=w,e[25]=E,e[26]=F):F=e[26];let z;e[27]!==$||e[28]!==F?(z={animation:$,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...F},e[27]=$,e[28]=F,e[29]=z):z=e[29];let G;e[30]!==o||e[31]!==l?(G=o?t.jsx(pd,{iconNode:t.jsx(Io,{percentage:o.state==="measured"?o.percentage:null}),label:l("mobile.header.metadata.context"),children:o.state==="pending"?null:t.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[o.state==="measured"?t.jsxs("span",{className:Z("font-semibold",o.colorClass),children:[o.percentage.toFixed(1),"%"]}):null,t.jsx("span",{className:"text-muted-foreground",children:o.tokens})]})}):null,e[30]=o,e[31]=l,e[32]=G):G=e[32];let q;e[33]!==o?.state||e[34]!==l?(q=o?.state==="compacted"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:l("contextUsage.compacted.description")}):null,e[33]=o?.state,e[34]=l,e[35]=q):q=e[35];let Y;e[36]!==o?.state||e[37]!==l?(Y=o?.state==="pending"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:l("mobile.header.metadata.contextPending")}):null,e[36]=o?.state,e[37]=l,e[38]=Y):Y=e[38];let W;e[39]!==m||e[40]!==f||e[41]!==d||e[42]!==a?(W=t.jsx(gd,{groups:a,displayMode:d,isLoading:m,timeFormatPreference:f}),e[39]=m,e[40]=f,e[41]=d,e[42]=a,e[43]=W):W=e[43];let te;e[44]!==G||e[45]!==q||e[46]!==Y||e[47]!==W?(te=t.jsxs("div",{className:"space-y-1",children:[G,q,Y,W]}),e[44]=G,e[45]=q,e[46]=Y,e[47]=W,e[48]=te):te=e[48];let ce;e[49]!==j||e[50]!==z||e[51]!==te||e[52]!==x?(ce=t.jsx("div",{ref:p,role:"dialog","aria-label":x,className:j,style:z,children:te}),e[49]=j,e[50]=z,e[51]=te,e[52]=x,e[53]=ce):ce=e[53];let le;e[54]===Symbol.for("react.memo_cache_sentinel")?(le=t.jsx("style",{children:`
5
5
  @keyframes session-metadata-in {
@@ -22,4 +22,4 @@ import{e as me,r as Pn,j as t,R as u,b as ss,f as la}from"./vendor-react-C3AD0CR
22
22
  `}),e[47]=ce):ce=e[47];let le;return e[48]!==te?(le=t.jsxs("div",{ref:g,className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[te,ce]}),e[48]=te,e[49]=le):le=e[49],le};function jd(n){return n.currentSessionId}function kd(n){return n.setCurrentSession}function Sd(n){return n.setActiveProjectIdOnly}const Nd=n=>{const e=me.c(84),{onOpenSessions:s,onOpenWorkspace:i,compactTitle:r}=n,o=r===void 0?!1:r,{t:a}=be(),[d,m]=u.useState(!1),[f,l]=u.useState(!1),p=u.useRef(null),g=Nt(Cd),h=Re(Rd);let b;e[0]!==h?(b=Ue=>h?Ue.getDirectoryForSession(h):null,e[0]=h,e[1]=b):b=e[1];const v=Re(b)||g,I=Da(h,v||void 0),w=Re(Ed),C=Wi(v||null);let A;e[2]!==v||e[3]!==C?(A=Ue=>{if(!v||C!==!0)return!1;const Xe=Ue.directories.get(v)?.status;return!!(Xe&&!Xe.isClean)},e[2]=v,e[3]=C,e[4]=A):A=e[4];const y=Je(A),E=ze(Id),N=ec(E);let R;e[5]!==I?.title?(R=I?.title?.trim(),e[5]=I?.title,e[6]=R):R=e[6];const k=R;let P;e[7]!==h||e[8]!==E||e[9]!==N||e[10]!==k||e[11]!==a?(P=(E?N:null)||k||a(h?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[7]=h,e[8]=E,e[9]=N,e[10]=k,e[11]=a,e[12]=P):P=e[12];const B=P;let D;e[13]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{m(!1),l(!1)},e[13]=D):D=e[13];let x;e[14]!==h||e[15]!==v?(x=[h,v],e[14]=h,e[15]=v,e[16]=x):x=e[16],u.useEffect(D,x);let _;e[17]!==s?(_=()=>{m(!1),l(!1),s()},e[17]=s,e[18]=_):_=e[18];const V=_;let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=Ue=>{m(Xe=>{const Rt=typeof Ue=="function"?Ue(Xe):Ue;return Rt&&l(!1),Rt})},e[19]=j):j=e[19];const $=j;let F;e[20]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{l(Ue=>{const Xe=!Ue;return Xe&&m(!1),Xe})},e[20]=F):F=e[20];const z=F;let G;e[21]===Symbol.for("react.memo_cache_sentinel")?(G={paddingTop:"var(--oc-safe-area-top, 0px)"},e[21]=G):G=e[21];let q;e[22]!==a?(q=a("mobile.sessions.openSheetAria"),e[22]=a,e[23]=q):q=e[23];let Y,W;e[24]===Symbol.for("react.memo_cache_sentinel")?(Y={touchAction:"manipulation"},W=t.jsx(Q,{name:"list-unordered",className:"size-5"}),e[24]=Y,e[25]=W):(Y=e[24],W=e[25]);let te;e[26]!==V||e[27]!==q?(te=t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":q,onClick:V,style:Y,children:W}),e[26]=V,e[27]=q,e[28]=te):te=e[28];const ce=o?"shrink":"flex-1";let le;e[29]!==ce?(le=Z("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",ce),e[29]=ce,e[30]=le):le=e[30];let se;e[31]!==a?(se=a("sessions.switcher.openAria"),e[31]=a,e[32]=se):se=e[32];let ie;e[33]===Symbol.for("react.memo_cache_sentinel")?(ie={touchAction:"manipulation"},e[33]=ie):ie=e[33];let O;e[34]!==B?(O=t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:B}),e[34]=B,e[35]=O):O=e[35];const ee=f&&"rotate-180";let ne;e[36]!==ee?(ne=Z("size-4 shrink-0 text-muted-foreground transition-transform duration-150",ee),e[36]=ee,e[37]=ne):ne=e[37];let ae;e[38]!==ne?(ae=t.jsx(Q,{name:"arrow-down-s",className:ne}),e[38]=ne,e[39]=ae):ae=e[39];let H;e[40]!==O||e[41]!==ae?(H=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[O,ae]}),e[40]=O,e[41]=ae,e[42]=H):H=e[42];let re;e[43]!==f||e[44]!==le||e[45]!==se||e[46]!==H?(re=t.jsx("button",{ref:p,type:"button",className:le,"aria-label":se,"aria-haspopup":"dialog","aria-expanded":f,onClick:z,style:ie,children:H}),e[43]=f,e[44]=le,e[45]=se,e[46]=H,e[47]=re):re=e[47];let ue;e[48]!==o?(ue=o?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[48]=o,e[49]=ue):ue=e[49];let ye;e[50]!==h||e[51]!==v||e[52]!==w||e[53]!==d||e[54]!==E?(ye=E?null:t.jsx(bd,{open:d,onOpenChange:$,currentSessionId:h,effectiveDirectory:v,isNewSessionDraftOpen:w}),e[50]=h,e[51]=v,e[52]=w,e[53]=d,e[54]=E,e[55]=ye):ye=e[55];let he;e[56]!==v?(he=t.jsx(tc,{directory:v,className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",iconClassName:"size-5"}),e[56]=v,e[57]=he):he=e[57];let J;e[58]!==y||e[59]!==a?(J=a(y?"mobile.header.openWorkspaceWithChangesAria":"mobile.header.openWorkspaceAria"),e[58]=y,e[59]=a,e[60]=J):J=e[60];let de;e[61]!==i?(de=()=>{m(!1),l(!1),i()},e[61]=i,e[62]=de):de=e[62];let Se,Ee;e[63]===Symbol.for("react.memo_cache_sentinel")?(Se={touchAction:"manipulation"},Ee=t.jsx(Q,{name:"pencil-ruler-2",className:"size-5"}),e[63]=Se,e[64]=Ee):(Se=e[63],Ee=e[64]);let ve;e[65]!==y?(ve=y?t.jsx("span",{className:"absolute right-1.5 top-1.5 size-2.5 rounded-full border-2 border-[var(--background)] bg-[var(--status-warning)]","aria-hidden":!0}):null,e[65]=y,e[66]=ve):ve=e[66];let Ae;e[67]!==J||e[68]!==de||e[69]!==ve?(Ae=t.jsxs("button",{type:"button",className:"relative flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":J,onClick:de,style:Se,children:[Ee,ve]}),e[67]=J,e[68]=de,e[69]=ve,e[70]=Ae):Ae=e[70];let nt;e[71]!==te||e[72]!==re||e[73]!==ue||e[74]!==ye||e[75]!==he||e[76]!==Ae?(nt=t.jsx("header",{className:"oc-mobile-header relative z-30 flex shrink-0 items-center gap-1 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",style:G,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[te,re,ue,ye,he,Ae]})}),e[71]=te,e[72]=re,e[73]=ue,e[74]=ye,e[75]=he,e[76]=Ae,e[77]=nt):nt=e[77];let Fe;e[78]===Symbol.for("react.memo_cache_sentinel")?(Fe=()=>l(!1),e[78]=Fe):Fe=e[78];let Le;e[79]!==f?(Le=t.jsx(wd,{open:f,onClose:Fe,anchorRef:p}),e[79]=f,e[80]=Le):Le=e[80];let Ie;return e[81]!==nt||e[82]!==Le?(Ie=t.jsxs(t.Fragment,{children:[nt,Le]}),e[81]=nt,e[82]=Le,e[83]=Ie):Ie=e[83],Ie};function Cd(n){return n.currentDirectory}function Rd(n){return n.currentSessionId}function Ed(n){return!!n.newSessionDraft?.open}function Id(n){return n.runOverviewKey}const Ad=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=be(),i=wo(e),{connections:r,isBusy:o,isPasswordBusy:a,error:d,pendingConnection:m,connect:f,submitPassword:l,cancelPassword:p,saveConnection:g,removeConnection:h,setError:b}=i,[S,v]=u.useState(null),I=S?r.find(H=>H.id===S)??null:null,[w,C]=u.useState(null),[A,y]=u.useState(""),[E,N]=u.useState(""),[R,k]=u.useState(""),[P,B]=u.useState(""),[D,x]=u.useState(!1),[_,V]=u.useState(!1),j=u.useRef(null),$=u.useMemo(()=>On(),[]),[F,z]=u.useState(!1),[G,q]=u.useState(null),[Y,W]=u.useState(!1),te=uo(u.useCallback(()=>W(!0),[])),ce=u.useCallback(()=>{v(null),y(""),N(""),k(""),b(null),z(!1)},[b]),le=u.useCallback(H=>{H.preventDefault(),g({id:S??void 0,url:A,label:E,clientToken:R}).then(re=>{re&&ce()})},[R,S,E,ce,g,A]),se=u.useCallback(async()=>{if(j.current)return;b(null),x(!0);const H=new AbortController;j.current=H;try{const re=await Co({signal:H.signal});switch(j.current===H&&(j.current=null,x(!1)),re.status){case"ok":y(re.url),re.label&&N(re.label),re.clientToken&&k(re.clientToken),z(!0);break;case"pairing":V(!0),await i.redeemPairingConnection(re.pairing);break;case"permission-denied":b(s("mobile.connect.scan.permissionDenied"));break;case"invalid":b(s("mobile.connect.scan.invalid"));break;case"unsupported":b(s("mobile.connect.scan.unsupported"));break;case"failed":b(s("mobile.connect.scan.failed"));break;default:break}}finally{V(!1),j.current===H&&(j.current=null,x(!1))}},[i,b,s]);u.useEffect(()=>()=>j.current?.abort(),[]);const ie=u.useCallback(H=>{H.preventDefault(),l(P)},[P,l]),O=u.useCallback(()=>{B(""),p()},[p]),ee=u.useCallback(H=>{C(re=>re===H?null:H)},[]),ne=u.useCallback(H=>{C(null),S===H&&ce();const re=r.length===1;h(H).then(ue=>{ue&&(re||mi(ue))&&n()})},[r.length,S,n,h,ce]),ae=ks;return m?t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("form",{className:"flex-1 overflow-y-auto px-5 py-4",onSubmit:ie,children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(Q,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:m.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:m.candidates.some(H=>H.kind==="direct")?wt(m):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...ts,value:P,onChange:H=>B(H.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:ae}),d?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:d}):null,t.jsx(je,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!P.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(je,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:O,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[D?t.jsx(Ro,{onCancel:()=>j.current?.abort()}):null,_?t.jsx(Eo,{}):null,Y?t.jsx(jo,{onClose:()=>W(!1)}):null,t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:t.jsxs("div",{className:"space-y-6",children:[r.length>0?t.jsx("div",{...te,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(H=>{const re=w===H.id,ue=mi(H),ye=G===H.id,he=ye?s("mobile.connect.connecting"):ue?Es()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):H.candidates.some(J=>J.kind==="direct")?wt(H):s("mobile.connect.relay.badge");return t.jsxs("div",{className:Z("flex items-center border-b border-border/70 transition-colors last:border-b-0",re&&"bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-3 px-3.5 py-3 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-60",onClick:()=>{ue||(q(H.id),f({id:H.id,candidates:H.candidates,clientToken:H.clientToken,label:H.label}).finally(()=>q(null)))},disabled:o&&!ye||re,children:[t.jsxs("span",{className:"relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:[t.jsx(Q,{name:"server",className:"size-[18px]"}),ue?t.jsx("span",{className:"absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--status-success)]","aria-hidden":!0}):null]}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:H.label}),t.jsx("span",{className:Z("block truncate typography-small",ue&&!ye?"text-[var(--status-success)]":"text-muted-foreground"),children:he})]}),ye?t.jsx(Q,{name:"loader-4",className:"size-5 shrink-0 animate-spin text-muted-foreground"}):null]}),t.jsxs("div",{className:"flex items-center gap-0.5 pr-2",children:[re?t.jsxs("button",{type:"button","aria-label":s("mobile.instances.confirmDeleteAria",{label:H.label}),className:"flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-destructive px-3 text-destructive-foreground transition-opacity active:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive",onClick:()=>ne(H.id),style:{touchAction:"manipulation"},children:[t.jsx(Q,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:s("mobile.instances.delete")})]}):H.candidates.some(J=>J.kind==="direct")?t.jsx("button",{type:"button","aria-label":s("mobile.instances.edit"),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>{v(H.id),y(wt(H)),N(H.label),k(H.clientToken||""),b(null)},style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":re?s("mobile.instances.cancelDeleteAria",{label:H.label}):s("mobile.instances.deleteAria",{label:H.label}),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>ee(H.id),style:{touchAction:"manipulation"},children:t.jsx(Q,{name:re?"close":"delete-bin",className:"size-[18px]"})})]})]},H.id)})}):t.jsx("p",{...te,className:"rounded-[18px] border border-dashed border-border/70 px-4 py-6 text-center typography-small text-muted-foreground",children:s("mobile.connect.saved.empty")}),!F&&!I?t.jsxs("div",{className:"space-y-2",children:[$?t.jsxs(je,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{se()},disabled:D,children:[t.jsx(Q,{name:"scan-2",className:Z("size-[18px]",D&&"animate-pulse")}),s("mobile.connect.scanQr")]}):null,t.jsxs(je,{type:"button",variant:$?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{b(null),z(!0)},children:[t.jsx(Q,{name:"add",className:"size-[18px]"}),s("mobile.instances.addManual")]}),d?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:d}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:le,children:[t.jsxs("div",{className:"flex h-8 items-center justify-between gap-3 px-1",children:[t.jsx("h3",{className:"typography-ui-label text-foreground",children:s(I?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(je,{type:"button",variant:"ghost",size:"xs",onClick:ce,children:s("mobile.instances.cancelEdit")})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.connect.url.label")}),t.jsx("input",{...ts,value:A,onChange:H=>y(H.target.value),placeholder:s("mobile.connect.url.placeholder"),type:"url",inputMode:"url",autoCapitalize:"none",className:ae})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.instances.label.label")}),t.jsx("input",{value:E,onChange:H=>N(H.target.value),placeholder:s("mobile.instances.label.placeholder"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,className:ae})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.connect.token.label")}),t.jsx("input",{...ts,value:R,onChange:H=>k(H.target.value),placeholder:s("mobile.connect.token.placeholder"),autoCapitalize:"none",className:ae}),t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")})]}),d?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:d}):null,t.jsx(je,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(I?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},Te=n=>ma(n)??"",Cn=n=>{const e=Te(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},gi=ur(n=>({expandedParents:{},toggleParent:e=>n(s=>{const i={...s.expandedParents};return i[e]?delete i[e]:i[e]=!0,{expandedParents:i}})})),Vs=ur()(ao(n=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,s)=>n(i=>({projectExpanded:{...i.projectExpanded,[e]:s}})),setWorktreeExpanded:(e,s)=>n(i=>({worktreeExpanded:{...i.worktreeExpanded,[e]:s}}))}),{name:"mobile-session-tree"})),Bn=ur()(ao(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(i=>({orderByProject:{...i.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),bi=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Pd=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((r,o)=>[bi(r),o])),i=r=>s.get(bi(r.path))??Number.MAX_SAFE_INTEGER;return e.map((r,o)=>({worktree:r,index:o})).sort((r,o)=>{const a=i(r.worktree)-i(o.worktree);return a!==0?a:r.index-o.index}).map(r=>r.worktree)},Ss=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),Td=n=>{const e=n;return Ss(e.directory??e.project?.worktree??null)},Ao=({open:n,project:e,worktree:s,onClose:i,onDeleted:r})=>{const{t:o}=be(),a=Vi(),d=Zt(k=>k.activeSessions),m=Re(k=>k.archiveSessions),f=Nt(k=>k.currentDirectory),[l,p]=u.useState(!1),[g,h]=u.useState(!1),[b,S]=u.useState(!1),[v,I]=u.useState(!1),w=Ss(s?.path),C=typeof s?.branch=="string"&&s.branch.trim().length>0,A=u.useMemo(()=>{if(!w)return[];const k=new Map;for(const P of[...d,...a])Td(P)===w&&k.set(P.id,P);return Array.from(k.values())},[d,a,w]);u.useEffect(()=>{if(!n){p(!1),h(!1),S(!1),I(!1);return}if(!s?.path)return;let k=!1;return _a(s.path).then(P=>{k||S(!!P?.isDirty)}).catch(()=>{k||S(!!s.status?.isDirty)}),()=>{k=!0}},[n,s?.path,s?.status?.isDirty]);const y=u.useCallback((k,P)=>{const B=Ma(k),D=xe.loading(o("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:B}));(async()=>{try{if(P.length>0){const{failedIds:x}=await m(P);if(x.length>0){xe.error(x.length===1?o("sessions.sidebar.bulkActions.failedArchiveSingle",{count:x.length}):o("sessions.sidebar.bulkActions.failedArchivePlural",{count:x.length}),{id:D,description:o("sessions.sidebar.dialogs.deleteResult.tryAgain")});return}}await za(e,k,{deleteRemoteBranch:C&&g,deleteLocalBranch:C&&l}),Ss(f)===w&&Ss(e.path)&&Nt.getState().setDirectory(Ss(e.path),{showOverlay:!1}),xe.success(o("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:B}),{id:D,description:o(C&&g?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),r?.()}catch(x){xe.error(o("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:B}),{id:D,description:x instanceof Error?x.message:o("sessions.sidebar.dialogs.deleteResult.tryAgain")})}})()},[m,f,l,g,C,r,e,o,w]),E=()=>{!s||v||(I(!0),y(s,A.map(k=>k.id)),i())};if(!s)return null;const N=s.branch||s.label||s.path,R=(k,P,B,D)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":k,disabled:D,onClick:()=>P(!k),className:Z("flex w-full items-center justify-between gap-3 rounded-xl border border-border/70 px-3.5 py-3 text-left transition-colors","hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",D&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:B}),t.jsx("span",{className:Z("relative h-6 w-10 shrink-0 rounded-full transition-colors",k?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:Z("absolute top-0.5 size-5 rounded-full bg-white transition-transform",k?"translate-x-[1.125rem]":"translate-x-0.5")})})]});return t.jsx(Ui,{open:n,onClose:i,title:o("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(je,{variant:"ghost",className:"flex-1",onClick:i,disabled:v,children:o("projectEditDialog.actions.cancel")}),t.jsx(je,{variant:"destructive",className:"flex-1",onClick:()=>{E()},disabled:v,children:o("mobile.projectEdit.deleteWorktreeConfirmButton")})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx("p",{className:"typography-ui-body text-foreground",children:o("mobile.projectEdit.deleteWorktreeConfirm",{name:N})}),b?t.jsx("p",{className:"rounded-xl border border-[var(--warning)]/40 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] px-3.5 py-3 typography-meta text-foreground",children:o("mobile.projectEdit.deleteWorktreeDirty")}):null,A.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("mobile.projectEdit.deleteWorktreeArchiveNote",{count:A.length})}):null,C?t.jsxs("div",{className:"flex flex-col gap-2",children:[R(l,p,o("mobile.projectEdit.deleteLocalBranch"),v),R(g,h,o("mobile.projectEdit.deleteRemoteBranch"),v)]}):null]})})},As=n=>{const e=me.c(18),{project:s,size:i}=n,r=i===void 0?"md":i,{currentTheme:o}=Ki(),a=s.icon?Gi[s.icon]:null,d=s.color?Hi[s.color]??null:null,m=r==="sm"?"size-6 rounded-md":"size-8 rounded-lg",f=r==="sm"?"size-3.5":"size-4";let l;e[0]!==a||e[1]!==d||e[2]!==f?(l=a?t.jsx(Q,{name:a,className:f,style:d?{color:d}:void 0}):t.jsx(Dn,{className:f,style:d?{color:d}:void 0}),e[0]=a,e[1]=d,e[2]=f,e[3]=l):l=e[3];const p=l,g=r==="md"&&"bg-[var(--surface-muted)]";let h;e[4]!==m||e[5]!==g?(h=Z("flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground",g,m),e[4]=m,e[5]=g,e[6]=h):h=e[6];let b;e[7]!==s.iconBackground?(b=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[7]=s.iconBackground,e[8]=b):b=e[8];let S;e[9]!==o||e[10]!==p||e[11]!==s.iconImage||e[12]!==s.id?(S=s.iconImage?t.jsx(qi,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"size-full object-contain",fallback:p}):p,e[9]=o,e[10]=p,e[11]=s.iconImage,e[12]=s.id,e[13]=S):S=e[13];let v;return e[14]!==h||e[15]!==b||e[16]!==S?(v=t.jsx("span",{className:h,style:b,children:S}),e[14]=h,e[15]=b,e[16]=S,e[17]=v):v=e[17],v},Po=n=>{const e=me.c(57),{initialTitle:s,indent:i,className:r,aiRename:o,onSubmit:a,onCancel:d}=n,{t:m}=be(),[f,l]=u.useState(s),p=Dd;let g;e[0]!==s||e[1]!==d||e[2]!==a||e[3]!==f?(g=()=>{const Y=f.trim();if(!Y||Y===s.trim()){d();return}a(Y)},e[0]=s,e[1]=d,e[2]=a,e[3]=f,e[4]=g):g=e[4];const h=g;let b;e[5]!==r?(b=Z("flex h-9 min-w-0 flex-1 items-center gap-2 pr-2",r),e[5]=r,e[6]=b):b=e[6];let S;e[7]!==i?(S={paddingLeft:i},e[7]=i,e[8]=S):S=e[8];let v;e[9]!==h?(v=Y=>{Y.preventDefault(),h()},e[9]=h,e[10]=v):v=e[10];let I;e[11]===Symbol.for("react.memo_cache_sentinel")?(I=Y=>l(Y.target.value),e[11]=I):I=e[11];let w;e[12]!==d?(w=Y=>sc(Y,d),e[12]=d,e[13]=w):w=e[13];let C;e[14]!==m?(C=m("sessions.sidebar.session.rename.save"),e[14]=m,e[15]=C):C=e[15];let A;e[16]!==m?(A=m("sessions.sidebar.session.menu.rename"),e[16]=m,e[17]=A):A=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y={minHeight:0},e[18]=y):y=e[18];let E;e[19]!==w||e[20]!==C||e[21]!==A||e[22]!==f?(E=t.jsx("input",{ref:p,value:f,onChange:I,onKeyDown:w,"aria-label":C,placeholder:A,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:y,enterKeyHint:"done"}),e[19]=w,e[20]=C,e[21]=A,e[22]=f,e[23]=E):E=e[23];const N=o.disabled;let R;e[24]!==o||e[25]!==d?(R=()=>{o.run(),d()},e[24]=o,e[25]=d,e[26]=R):R=e[26];let k;e[27]!==m?(k=m("sessions.aiRename.action"),e[27]=m,e[28]=k):k=e[28];let P,B;e[29]===Symbol.for("react.memo_cache_sentinel")?(P={touchAction:"manipulation",minHeight:0,minWidth:0},B=t.jsx(Q,{name:"ai-generate-2",className:"size-4"}),e[29]=P,e[30]=B):(P=e[29],B=e[30]);let D;e[31]!==o.disabled||e[32]!==o.hint||e[33]!==R||e[34]!==k?(D=t.jsx("button",{type:"button",disabled:N,onClick:R,"aria-label":k,"aria-description":o.hint,title:o.hint,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:P,children:B}),e[31]=o.disabled,e[32]=o.hint,e[33]=R,e[34]=k,e[35]=D):D=e[35];let x;e[36]!==m?(x=m("sessions.sidebar.session.rename.save"),e[36]=m,e[37]=x):x=e[37];let _,V;e[38]===Symbol.for("react.memo_cache_sentinel")?(_={touchAction:"manipulation",minHeight:0,minWidth:0},V=t.jsx(Q,{name:"check",className:"size-4"}),e[38]=_,e[39]=V):(_=e[38],V=e[39]);let j;e[40]!==x?(j=t.jsx("button",{type:"submit","aria-label":x,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:_,children:V}),e[40]=x,e[41]=j):j=e[41];let $;e[42]!==m?($=m("sessions.sidebar.session.rename.cancel"),e[42]=m,e[43]=$):$=e[43];let F,z;e[44]===Symbol.for("react.memo_cache_sentinel")?(F={touchAction:"manipulation",minHeight:0,minWidth:0},z=t.jsx(Q,{name:"close",className:"size-4"}),e[44]=F,e[45]=z):(F=e[44],z=e[45]);let G;e[46]!==d||e[47]!==$?(G=t.jsx("button",{type:"button",onClick:d,"aria-label":$,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:F,children:z}),e[46]=d,e[47]=$,e[48]=G):G=e[48];let q;return e[49]!==E||e[50]!==D||e[51]!==b||e[52]!==j||e[53]!==G||e[54]!==S||e[55]!==v?(q=t.jsxs("form",{className:b,style:S,onSubmit:v,children:[E,D,j,G]}),e[49]=E,e[50]=D,e[51]=b,e[52]=j,e[53]=G,e[54]=S,e[55]=v,e[56]=q):q=e[56],q};function Dd(n){n&&(n.focus(),n.select())}const Ps=48,To=4*Ps,_d=180,tn=n=>{const e=me.c(27),{actionsWidth:s,actions:i,revealed:r,onRevealedChange:o,dataActiveSession:a,contentClassName:d,children:m}=n,f=d===void 0?"relative flex w-full items-center bg-background":d,l=u.useRef(null),p=u.useRef(null),g=u.useRef(!1),h=u.useRef(0),b=u.useRef(r);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S=(j,$)=>{const F=l.current;F&&(F.style.transition=$?`transform ${_d}ms ease-out`:"none",F.style.transform=j===0?"none":`translateX(${j}px)`,h.current=j)},e[0]=S):S=e[0];const v=S;let I,w;e[1]!==s||e[2]!==r?(I=()=>{b.current=r,v(r?s:0,!0)},w=[s,v,r],e[1]=s,e[2]=r,e[3]=I,e[4]=w):(I=e[3],w=e[4]),u.useEffect(I,w);let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=j=>{if(j.touches.length!==1)return;const $=j.touches[0];p.current={x:$.clientX,y:$.clientY},g.current=!1},e[5]=C):C=e[5];const A=C;let y;e[6]!==s?(y=j=>{if(!p.current)return;const $=j.touches[0],F=$.clientX-p.current.x,z=$.clientY-p.current.y;if(!g.current){if(Math.abs(F)<8||Math.abs(F)<=Math.abs(z))return;g.current=!0}const G=b.current?s:0;v(Math.max(0,Math.min(s,G+F)),!1)},e[6]=s,e[7]=y):y=e[7];const E=y;let N;e[8]!==s||e[9]!==o?(N=()=>{if(p.current=null,!g.current)return;g.current=!1;const j=h.current>s/2;v(j?s:0,!0),j!==b.current&&o(j)},e[8]=s,e[9]=o,e[10]=N):N=e[10];const R=N,k=a||void 0;let P;e[11]===Symbol.for("react.memo_cache_sentinel")?(P={touchAction:"pan-y"},e[11]=P):P=e[11];let B;e[12]!==s?(B={width:s},e[12]=s,e[13]=B):B=e[13];const D=!r;let x;e[14]!==i||e[15]!==B||e[16]!==D?(x=t.jsx("div",{className:"absolute inset-y-0 left-0 flex items-stretch",style:B,"aria-hidden":D,children:i}),e[14]=i,e[15]=B,e[16]=D,e[17]=x):x=e[17];let _;e[18]!==m||e[19]!==f?(_=t.jsx("div",{ref:l,className:f,children:m}),e[18]=m,e[19]=f,e[20]=_):_=e[20];let V;return e[21]!==R||e[22]!==E||e[23]!==x||e[24]!==_||e[25]!==k?(V=t.jsxs("div",{"data-active-session":k,className:"relative overflow-hidden",onTouchStart:A,onTouchMove:E,onTouchEnd:R,onTouchCancel:R,style:P,children:[x,_]}),e[21]=R,e[22]=E,e[23]=x,e[24]=_,e[25]=k,e[26]=V):V=e[26],V},Do=n=>{const e=me.c(62),{sessionId:s,title:i,revealed:r,confirmingDelete:o,onArchive:a,onRequestDelete:d,onConfirmDelete:m,onRequestRename:f,onRevealedChange:l,work:p,pin:g}=n,{t:h}=be(),b=r?0:-1;let S;e[0]!==l||e[1]!==s||e[2]!==h?(S=async()=>{if(!(await $i(s).catch(Md))?.ok){Mn.error(h("sessions.sidebar.session.copyId.error"));return}l?.(!1),Mn.success(h("sessions.sidebar.session.copyId.success"))},e[0]=l,e[1]=s,e[2]=h,e[3]=S):S=e[3];const v=S;let I;e[4]!==h||e[5]!==i?(I=h("mobile.sessions.archiveSessionAria",{title:i}),e[4]=h,e[5]=i,e[6]=I):I=e[6];let w,C;e[7]===Symbol.for("react.memo_cache_sentinel")?(w={touchAction:"manipulation"},C=t.jsx(Wc,{className:"size-[18px]"}),e[7]=w,e[8]=C):(w=e[7],C=e[8]);let A;e[9]!==a||e[10]!==I||e[11]!==b?(A=t.jsx("button",{type:"button",tabIndex:b,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":I,onClick:a,style:w,children:C}),e[9]=a,e[10]=I,e[11]=b,e[12]=A):A=e[12];let y;e[13]!==l||e[14]!==g||e[15]!==h||e[16]!==b?(y=g?t.jsx("button",{type:"button",tabIndex:b,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":g.pinned?h("sessions.sidebar.session.menu.unpin"):h("sessions.sidebar.session.menu.pin"),onClick:()=>{g.onToggle(),l?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(Q,{name:g.pinned?"unpin":"pushpin",className:"size-[18px]"})}):null,e[13]=l,e[14]=g,e[15]=h,e[16]=b,e[17]=y):y=e[17];let E;e[18]!==l||e[19]!==h||e[20]!==b||e[21]!==p?(E=p?t.jsx("button",{type:"button",tabIndex:b,className:Z("flex flex-1 items-center justify-center transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",p.inWork?"text-status-success":"text-muted-foreground active:text-foreground"),"aria-label":p.inWork?h("sessions.sidebar.session.work.markDone"):h("sessions.sidebar.session.work.track"),onClick:()=>{p.onToggle(),l?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(Q,{name:p.inWork?"check":"eye",className:p.inWork?"size-5":"size-[18px]"})}):null,e[18]=l,e[19]=h,e[20]=b,e[21]=p,e[22]=E):E=e[22];const N=o?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80";let R;e[23]!==N?(R=Z("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",N),e[23]=N,e[24]=R):R=e[24];let k;e[25]!==o||e[26]!==h||e[27]!==i?(k=o?h("mobile.sessions.confirmDeleteSessionAria",{title:i}):h("mobile.sessions.deleteSessionAria",{title:i}),e[25]=o,e[26]=h,e[27]=i,e[28]=k):k=e[28];const P=o?m:d;let B,D;e[29]===Symbol.for("react.memo_cache_sentinel")?(B={touchAction:"manipulation"},D=t.jsx(Js,{className:"size-[18px]"}),e[29]=B,e[30]=D):(B=e[29],D=e[30]);let x;e[31]!==k||e[32]!==P||e[33]!==R||e[34]!==b?(x=t.jsx("button",{type:"button",tabIndex:b,className:R,"aria-label":k,onClick:P,style:B,children:D}),e[31]=k,e[32]=P,e[33]=R,e[34]=b,e[35]=x):x=e[35];let _;e[36]!==h||e[37]!==i?(_=h("mobile.sessions.renameSessionAria",{title:i}),e[36]=h,e[37]=i,e[38]=_):_=e[38];let V,j;e[39]===Symbol.for("react.memo_cache_sentinel")?(V={touchAction:"manipulation"},j=t.jsx(_n,{className:"size-[18px]"}),e[39]=V,e[40]=j):(V=e[39],j=e[40]);let $;e[41]!==f||e[42]!==_||e[43]!==b?($=t.jsx("button",{type:"button",tabIndex:b,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":_,onClick:f,style:V,children:j}),e[41]=f,e[42]=_,e[43]=b,e[44]=$):$=e[44];let F;e[45]!==h?(F=h("sessions.sidebar.session.menu.copyId"),e[45]=h,e[46]=F):F=e[46];let z;e[47]!==v?(z=()=>{v()},e[47]=v,e[48]=z):z=e[48];let G,q;e[49]===Symbol.for("react.memo_cache_sentinel")?(G={touchAction:"manipulation"},q=t.jsx(Q,{name:"file-copy",className:"size-[18px]"}),e[49]=G,e[50]=q):(G=e[49],q=e[50]);let Y;e[51]!==F||e[52]!==z||e[53]!==b?(Y=t.jsx("button",{type:"button",tabIndex:b,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":F,onClick:z,style:G,children:q}),e[51]=F,e[52]=z,e[53]=b,e[54]=Y):Y=e[54];let W;return e[55]!==x||e[56]!==$||e[57]!==Y||e[58]!==A||e[59]!==y||e[60]!==E?(W=t.jsxs(t.Fragment,{children:[A,y,E,x,$,Y]}),e[55]=x,e[56]=$,e[57]=Y,e[58]=A,e[59]=y,e[60]=E,e[61]=W):W=e[61],W};function Md(){return null}const ct=n=>n.parentID??null,dt=n=>{const e=n;return Te(e.directory??e.project?.worktree??null)},_o=n=>{const e=n.time?.updated??n.time?.created,s=typeof e=="number"?e:Number(e);return Number.isFinite(s)&&s>0?s:0},on=n=>{if(n<=0)return"";const e=Date.now()-n;if(e<6e4)return"now";const s=Math.floor(e/6e4);if(s<60)return`${s}m`;const i=Math.floor(s/60);if(i<24)return`${i}h`;const r=Math.floor(i/24);return r<7?`${r}d`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n))},zd=4,Mo=n=>{const e=me.c(4),{providerIDs:s}=n;let i;e[0]!==s?(i=s.slice(0,zd).map(Od),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=t.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:i}),e[2]=i,e[3]=r):r=e[3],r};function Od(n){return t.jsx("span",{className:"inline-flex size-4 items-center justify-center rounded-full bg-background ring-1 ring-background",children:t.jsx(Fi,{providerId:n,className:"size-3 opacity-80"})},n)}const Ln=12,$n="flex min-w-0 flex-1 flex-col gap-1 py-2.5 pr-3 text-left",Bd=n=>{const e=me.c(54),{entry:s}=n,{t:i}=be(),{run:r,project:o}=s;let a;e[0]!==r.key?(a=z=>z.runOverviewKey===r.key,e[0]=r.key,e[1]=a):a=e[1];const d=ze(a);let m;e[2]!==s.laneNodes?(m={nodes:s.laneNodes,includeUnreadSubtasks:!1},e[2]=s.laneNodes,e[3]=m):m=e[3];const f=no(m);let l;e[4]!==r.lastActivity?(l=on(r.lastActivity),e[4]=r.lastActivity,e[5]=l):l=e[5];const p=l,g=r.lanes.length,h=d||void 0,b=d&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let S;e[6]!==b?(S=Z("relative bg-background transition-colors",b),e[6]=b,e[7]=S):S=e[7];let v,I;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=Z($n,"w-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),I={paddingLeft:Ln,touchAction:"manipulation"},e[8]=v,e[9]=I):(v=e[8],I=e[9]);let w;e[10]!==r.key?(w=()=>ze.getState().setRunOverviewKey(r.key),e[10]=r.key,e[11]=w):w=e[11];let C;e[12]!==r.title||e[13]!==i?(C=i("sessions.sidebar.run.openOverviewAria",{title:r.title}),e[12]=r.title,e[13]=i,e[14]=C):C=e[14];let A;e[15]!==o?(A=t.jsx(As,{project:o,size:"sm"}),e[15]=o,e[16]=A):A=e[16];let y;e[17]!==o.label?(y=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro text-muted-foreground",children:o.label}),e[17]=o.label,e[18]=y):y=e[18];let E;e[19]!==f?(E=f?t.jsx(io,{state:f}):null,e[19]=f,e[20]=E):E=e[20];let N;e[21]!==p?(N=p?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:p}):null,e[21]=p,e[22]=N):N=e[22];let R;e[23]!==A||e[24]!==y||e[25]!==E||e[26]!==N?(R=t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[A,y,E,N]}),e[23]=A,e[24]=y,e[25]=E,e[26]=N,e[27]=R):R=e[27];const k=d?"text-primary":"text-foreground";let P;e[28]!==k?(P=Z("block min-w-0 truncate typography-ui-label",k),e[28]=k,e[29]=P):P=e[29];let B;e[30]!==r.title||e[31]!==P?(B=t.jsx("span",{className:P,children:r.title}),e[30]=r.title,e[31]=P,e[32]=B):B=e[32];let D;e[33]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(Yi,{className:"size-3.5 shrink-0","aria-hidden":"true"}),e[33]=D):D=e[33];let x;e[34]!==g||e[35]!==i?(x=g===1?i("sessions.sidebar.run.laneCountSingle",{count:g}):i("sessions.sidebar.run.laneCountPlural",{count:g}),e[34]=g,e[35]=i,e[36]=x):x=e[36];let _;e[37]!==x?(_=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro",children:x}),e[37]=x,e[38]=_):_=e[38];let V;e[39]!==r.providerIDs?(V=t.jsx(Mo,{providerIDs:r.providerIDs}),e[39]=r.providerIDs,e[40]=V):V=e[40];let j;e[41]!==_||e[42]!==V?(j=t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[D,_,V]}),e[41]=_,e[42]=V,e[43]=j):j=e[43];let $;e[44]!==C||e[45]!==R||e[46]!==B||e[47]!==j||e[48]!==w?($=t.jsxs("button",{type:"button",className:v,style:I,onClick:w,"aria-label":C,children:[R,B,j]}),e[44]=C,e[45]=R,e[46]=B,e[47]=j,e[48]=w,e[49]=$):$=e[49];let F;return e[50]!==$||e[51]!==h||e[52]!==S?(F=t.jsx("div",{"data-active-session":h,className:S,children:$}),e[50]=$,e[51]=h,e[52]=S,e[53]=F):F=e[53],F},Ld=n=>{const e=me.c(106),{entry:s,active:i,revealed:r,confirmingDelete:o,renaming:a,handlers:d}=n,{t:m}=be(),{session:f,project:l,branch:p}=s;let g;e[0]!==f.title||e[1]!==m?(g=f.title?.trim()||m("mobile.sessions.untitled"),e[0]=f.title,e[1]=m,e[2]=g):g=e[2];const h=g;let b;e[3]!==f?(b=on(_o(f)),e[3]=f,e[4]=b):b=e[4];const S=b,v=ro(f.id,f.directory,r||a),I=Un(f.id),w=Kn(f.id),C=!w&&I>0&&!i,A=Gn(f.id,w),y=(w||C)&&A,E=d.onToggleWork;let N;e[5]!==f?(N=Ji(f),e[5]=f,e[6]=N):N=e[6];const R=N;let k;e[7]!==R||e[8]!==E||e[9]!==f?(k=E?{inWork:R,onToggle:()=>E(f,R)}:void 0,e[7]=R,e[8]=E,e[9]=f,e[10]=k):k=e[10];const P=k;let B;e[11]!==d||e[12]!==f?(B=d.isPinned(f),e[11]=d,e[12]=f,e[13]=B):B=e[13];const D=B;let x;e[14]!==d||e[15]!==f?(x=()=>d.onTogglePin(f),e[14]=d,e[15]=f,e[16]=x):x=e[16];let _;e[17]!==D||e[18]!==x?(_={pinned:D,onToggle:x},e[17]=D,e[18]=x,e[19]=_):_=e[19];const V=_,j=To+Ps+(P?Ps:0);let $;e[20]!==d||e[21]!==f.id?($=ie=>d.onRevealedChange(f.id,ie),e[20]=d,e[21]=f.id,e[22]=$):$=e[22];const F=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let z;e[23]!==F?(z=Z("relative flex w-full items-center bg-background transition-colors",F),e[23]=F,e[24]=z):z=e[24];let G;e[25]!==d||e[26]!==f?(G=()=>d.onArchive(f),e[25]=d,e[26]=f,e[27]=G):G=e[27];let q;e[28]!==d||e[29]!==f.id?(q=()=>d.onRequestDelete(f.id),e[28]=d,e[29]=f.id,e[30]=q):q=e[30];let Y;e[31]!==d||e[32]!==f?(Y=()=>d.onConfirmDelete(f),e[31]=d,e[32]=f,e[33]=Y):Y=e[33];let W,te;e[34]!==d||e[35]!==f.id?(W=()=>d.onRequestRename(f.id),te=ie=>d.onRevealedChange(f.id,ie),e[34]=d,e[35]=f.id,e[36]=W,e[37]=te):(W=e[36],te=e[37]);let ce;e[38]!==o||e[39]!==V||e[40]!==r||e[41]!==f.id||e[42]!==G||e[43]!==q||e[44]!==Y||e[45]!==W||e[46]!==te||e[47]!==h||e[48]!==P?(ce=t.jsx(Do,{sessionId:f.id,title:h,revealed:r,confirmingDelete:o,onArchive:G,onRequestDelete:q,onConfirmDelete:Y,onRequestRename:W,onRevealedChange:te,work:P,pin:V}),e[38]=o,e[39]=V,e[40]=r,e[41]=f.id,e[42]=G,e[43]=q,e[44]=Y,e[45]=W,e[46]=te,e[47]=h,e[48]=P,e[49]=ce):ce=e[49];let le;e:{let ie;e[50]!==l?(ie=t.jsx(As,{project:l,size:"sm"}),e[50]=l,e[51]=ie):ie=e[51];let O;e[52]!==l.label?(O=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro text-muted-foreground",children:l.label}),e[52]=l.label,e[53]=O):O=e[53];let ee;e[54]!==D||e[55]!==m?(ee=D?t.jsx(Q,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":m("sessions.sidebar.session.status.pinned")}):null,e[54]=D,e[55]=m,e[56]=ee):ee=e[56];let ne;e[57]!==v.pending||e[58]!==w||e[59]!==C||e[60]!==m?(ne=v.pending?t.jsx(Q,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":m("sessions.aiRename.generating")}):w||C?t.jsx(qs,{state:w?"running":"unread",label:m(w?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread")}):null,e[57]=v.pending,e[58]=w,e[59]=C,e[60]=m,e[61]=ne):ne=e[61];let ae;e[62]!==w||e[63]!==f.id||e[64]!==y||e[65]!==S?(ae=y?t.jsx(Xn,{sessionId:f.id,running:w,className:"shrink-0 typography-micro"}):S?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:S}):null,e[62]=w,e[63]=f.id,e[64]=y,e[65]=S,e[66]=ae):ae=e[66];let H;e[67]!==ie||e[68]!==O||e[69]!==ee||e[70]!==ne||e[71]!==ae?(H=t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[ie,O,ee,ne,ae]}),e[67]=ie,e[68]=O,e[69]=ee,e[70]=ne,e[71]=ae,e[72]=H):H=e[72];let re;e[73]!==i||e[74]!==v||e[75]!==d||e[76]!==a||e[77]!==f.id||e[78]!==h?(re=a?t.jsx(Po,{initialTitle:h,indent:0,aiRename:v,className:"h-[1lh] pr-0 typography-ui-label [&_button]:size-6 [&_button>svg]:size-3.5",onSubmit:ve=>d.onSubmitRename(f.id,ve),onCancel:d.onCancelRename}):t.jsx("span",{className:Z("block min-w-0 truncate typography-ui-label",i?"text-primary":"text-foreground"),children:h}),e[73]=i,e[74]=v,e[75]=d,e[76]=a,e[77]=f.id,e[78]=h,e[79]=re):re=e[79];let ue;e[80]!==p?(ue=p?t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[t.jsx(Q,{name:"git-branch",className:"size-3.5 shrink-0"}),t.jsx("span",{className:"block min-w-0 truncate typography-micro",children:p})]}):null,e[80]=p,e[81]=ue):ue=e[81];let ye;e[82]!==H||e[83]!==re||e[84]!==ue?(ye=t.jsxs(t.Fragment,{children:[H,re,ue]}),e[82]=H,e[83]=re,e[84]=ue,e[85]=ye):ye=e[85];const he=ye;if(a){let ve;e[86]===Symbol.for("react.memo_cache_sentinel")?(ve={paddingLeft:Ln},e[86]=ve):ve=e[86];let Ae;e[87]!==he?(Ae=t.jsx("div",{className:$n,style:ve,children:he}),e[87]=he,e[88]=Ae):Ae=e[88],le=Ae;break e}let J,de;e[89]===Symbol.for("react.memo_cache_sentinel")?(J=Z($n,"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),de={paddingLeft:Ln,touchAction:"manipulation"},e[89]=J,e[90]=de):(J=e[89],de=e[90]);let Se;e[91]!==d||e[92]!==r||e[93]!==f?(Se=()=>{if(r){d.onRevealedChange(f.id,!1);return}d.onSelect(f)},e[91]=d,e[92]=r,e[93]=f,e[94]=Se):Se=e[94];let Ee;e[95]!==he||e[96]!==Se?(Ee=t.jsx("button",{type:"button",className:J,style:de,onClick:Se,children:he}),e[95]=he,e[96]=Se,e[97]=Ee):Ee=e[97],le=Ee}let se;return e[98]!==i||e[99]!==r||e[100]!==z||e[101]!==ce||e[102]!==le||e[103]!==j||e[104]!==$?(se=t.jsx(tn,{actionsWidth:j,revealed:r,onRevealedChange:$,dataActiveSession:i,contentClassName:z,actions:ce,children:le}),e[98]=i,e[99]=r,e[100]=z,e[101]=ce,e[102]=le,e[103]=j,e[104]=$,e[105]=se):se=e[105],se},$d=n=>{const e=me.c(9),{scrollRootRef:s,visibleCount:i,onReachEnd:r}=n,o=u.useRef(null),a=u.useRef(r);let d,m;e[0]!==r?(d=()=>{a.current=r},m=[r],e[0]=r,e[1]=d,e[2]=m):(d=e[1],m=e[2]),u.useEffect(d,m);let f;e[3]!==s?(f=()=>{const g=o.current;if(!g)return;const h=new IntersectionObserver(b=>{b.some(Wd)&&a.current()},{root:s.current??null,rootMargin:"400px 0px"});return h.observe(g),()=>h.disconnect()},e[3]=s,e[4]=f):f=e[4];let l;e[5]!==s||e[6]!==i?(l=[s,i],e[5]=s,e[6]=i,e[7]=l):l=e[7],u.useEffect(f,l);let p;return e[8]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("div",{ref:o,"aria-hidden":!0,className:"h-px w-full"}),e[8]=p):p=e[8],p},Fd=n=>{const e=me.c(35),{entries:s,visibleCount:i,onRevealMore:r,scrollRootRef:o,handlers:a}=n,{t:d}=be();let m,f,l,p,g;if(e[0]!==s||e[1]!==a||e[2]!==d||e[3]!==i){g=s.slice(0,i),l="border-t border-border/70";let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:t.jsx(Q,{name:"folder-6",className:"size-4"})}),e[9]=v):v=e[9];let I;e[10]!==d?(I=d("mobile.sessions.section.projects"),e[10]=d,e[11]=I):I=e[11];let w;e[12]!==I?(w=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:I}),e[12]=I,e[13]=w):w=e[13];let C;e[14]!==s.length?(C=t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:s.length}),e[14]=s.length,e[15]=C):C=e[15],e[16]!==w||e[17]!==C?(p=t.jsxs("div",{className:"flex min-h-12 w-full items-center gap-2 px-3 py-1.5",children:[v,w,C]}),e[16]=w,e[17]=C,e[18]=p):p=e[18],m="pb-2";let A;e[19]!==a?(A=y=>y.kind==="run"?t.jsx(Bd,{entry:y},`run:${y.run.key}`):t.jsx(Ld,{entry:y,active:a.currentSessionId===y.session.id,revealed:a.revealedSessionId===y.session.id,confirmingDelete:a.confirmingDeleteSessionId===y.session.id,renaming:a.renamingSessionId===y.session.id,handlers:a},y.session.id),e[19]=a,e[20]=A):A=e[20],f=g.map(A),e[0]=s,e[1]=a,e[2]=d,e[3]=i,e[4]=m,e[5]=f,e[6]=l,e[7]=p,e[8]=g}else m=e[4],f=e[5],l=e[6],p=e[7],g=e[8];let h;e[21]!==s.length||e[22]!==r||e[23]!==o||e[24]!==i||e[25]!==g.length?(h=g.length<s.length?t.jsx($d,{scrollRootRef:o,visibleCount:i,onReachEnd:r}):null,e[21]=s.length,e[22]=r,e[23]=o,e[24]=i,e[25]=g.length,e[26]=h):h=e[26];let b;e[27]!==m||e[28]!==f||e[29]!==h?(b=t.jsxs("div",{className:m,children:[f,h]}),e[27]=m,e[28]=f,e[29]=h,e[30]=b):b=e[30];let S;return e[31]!==l||e[32]!==p||e[33]!==b?(S=t.jsxs("section",{className:l,children:[p,b]}),e[31]=l,e[32]=p,e[33]=b,e[34]=S):S=e[34],S};function Wd(n){return n.isIntersecting}const Hs=40,Vd=(n,e)=>Math.min(e,Math.max(n,0)+Hs),xi="mobile-surface-root",Rn=16,Us=200,Ud=()=>{if(typeof document>"u")return null;let n=document.getElementById(xi);return n||(n=document.createElement("div"),n.id=xi,document.body.appendChild(n)),n},qt=({open:n,onClose:e,title:s,subtitle:i,trailing:r,disableEscapeDismiss:o=!1,headerless:a=!1,noHeaderBorder:d=!1,ariaLabel:m,variant:f="fullscreen",dialogAlign:l="chat",children:p})=>{const{t:g}=be(),h=u.useRef(null),[b,S]=u.useState(!1),[v,I]=u.useState(!1),w=u.useRef(null),C=u.useRef(null),A=u.useRef(e);if(u.useEffect(()=>{A.current=e},[e]),typeof document<"u"&&!h.current&&(h.current=Ud()),u.useEffect(()=>{if(!n){S(!1);return}const N=window.setTimeout(()=>S(!0),Rn);return()=>window.clearTimeout(N)},[n]),u.useEffect(()=>{if(!n){I(!1);return}const N=window.setTimeout(()=>I(!0),Rn+Us+80);return()=>window.clearTimeout(N)},[n]),u.useEffect(()=>{if(!n)return;const N=document.body.style.overflow;C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const R=()=>{const B=w.current;if(!B)return;(B.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??B).focus({preventScroll:!0})},k=window.setTimeout(R,Rn),P=B=>{if(B.key==="Escape"&&!o){A.current();return}if(B.key!=="Tab")return;const D=w.current;if(!D)return;const x=Array.from(D.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter($=>!$.hasAttribute("disabled")&&$.getAttribute("aria-hidden")!=="true");if(x.length===0){B.preventDefault(),D.focus({preventScroll:!0});return}const _=x[0],V=x[x.length-1],j=document.activeElement;B.shiftKey&&j===_?(B.preventDefault(),V.focus({preventScroll:!0})):!B.shiftKey&&j===V&&(B.preventDefault(),_.focus({preventScroll:!0}))};return document.addEventListener("keydown",P),()=>{window.clearTimeout(k),document.body.style.overflow=N,document.removeEventListener("keydown",P),C.current?.focus?.({preventScroll:!0}),C.current=null}},[o,n]),!n||!h.current)return null;const y=f==="dialog",E=t.jsxs("section",{ref:w,role:"dialog","aria-modal":"true","aria-label":m,tabIndex:-1,className:Z("flex flex-col bg-background text-foreground",y?"h-[min(88dvh,860px)] w-full max-w-[720px] overflow-hidden rounded-2xl border border-border/70 shadow-[0_24px_64px_rgb(0_0_0_/_0.32)]":"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50"),style:y?{opacity:b?1:0,transform:b?"none":"scale(0.97)",transition:`opacity ${Us}ms ease-out, transform ${Us}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:b?"none":"translateX(100%)",transition:`transform ${Us}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:N=>{b&&N.target===N.currentTarget&&N.propertyName==="transform"&&I(!0)},children:[a?null:t.jsxs("header",{className:Z("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!d&&"border-b border-border/70"),children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":g("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"close",className:"size-5"})}),t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[s?typeof s=="string"?t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:s}):s:null,i?typeof i=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:i}):i:null]}),r?t.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:r}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:v?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:p}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return y?ss.createPortal(t.jsx("div",{className:"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50 flex items-center justify-center p-4 transition-opacity duration-200 ease-out",style:{background:"rgb(0 0 0 / 0.45)",opacity:b?1:0,paddingLeft:l==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:l==="chat"?"max(1rem, var(--oc-chat-inset-right, 0px))":"1rem",paddingTop:"max(1rem, var(--oc-safe-area-top, 0px))"},onClick:e,children:t.jsx("div",{className:"flex w-full max-w-[720px] justify-center",onClick:N=>N.stopPropagation(),children:E})}),h.current):ss.createPortal(E,h.current)},Kd=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),Gd=n=>{const e=me.c(36),{worktree:s,onDelete:i}=n,{t:r}=be();let o;e[0]!==s.path?(o={id:s.path},e[0]=s.path,e[1]=o):o=e[1];const{attributes:a,listeners:d,setNodeRef:m,transform:f,transition:l,isDragging:p}=lr(o);let g;e[2]!==f?(g=cr.Transform.toString(f),e[2]=f,e[3]=g):g=e[3];const h=p?10:1;let b;e[4]!==g||e[5]!==h||e[6]!==l?(b={transform:g,transition:l,zIndex:h},e[4]=g,e[5]=h,e[6]=l,e[7]=b):b=e[7];const S=b,v=s.branch||s.label||s.path,I=p&&"shadow-lg shadow-black/20";let w;e[8]!==I?(w=Z("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",I),e[8]=I,e[9]=w):w=e[9];let C;e[10]!==v||e[11]!==r?(C=r("mobile.projectEdit.dragWorktreeAria",{label:v}),e[10]=v,e[11]=r,e[12]=C):C=e[12];let A;e[13]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(Qn,{className:"size-4"}),e[13]=A):A=e[13];let y;e[14]!==a||e[15]!==d||e[16]!==C?(y=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":C,...a,...d,children:A}),e[14]=a,e[15]=d,e[16]=C,e[17]=y):y=e[17];let E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(Q,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[18]=E):E=e[18];let N;e[19]!==v?(N=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:v}),e[19]=v,e[20]=N):N=e[20];let R;e[21]!==v||e[22]!==r?(R=r("mobile.projectEdit.deleteWorktreeAria",{label:v}),e[21]=v,e[22]=r,e[23]=R):R=e[23];let k,P;e[24]===Symbol.for("react.memo_cache_sentinel")?(k={touchAction:"manipulation"},P=t.jsx(Js,{className:"size-4"}),e[24]=k,e[25]=P):(k=e[24],P=e[25]);let B;e[26]!==i||e[27]!==R?(B=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive","aria-label":R,onClick:i,style:k,children:P}),e[26]=i,e[27]=R,e[28]=B):B=e[28];let D;return e[29]!==m||e[30]!==S||e[31]!==N||e[32]!==B||e[33]!==w||e[34]!==y?(D=t.jsxs("div",{ref:m,style:S,className:w,children:[y,E,N,B]}),e[29]=m,e[30]=S,e[31]=N,e[32]=B,e[33]=w,e[34]=y,e[35]=D):D=e[35],D},Hd=({open:n,project:e,onClose:s,onWorktreesChanged:i})=>{const{t:r}=be(),{currentTheme:o}=Ki(),a=Ye(j=>j.updateProjectMeta),d=Ye(j=>j.discoverProjectIcon),m=Ye(j=>j.removeProjectIcon),f=Bn(j=>j.setWorktreeOrder),l=Ye(j=>e?j.projects.find($=>$.id===e.id)?.iconImage??null:null),[p,g]=u.useState(""),[h,b]=u.useState(null),[S,v]=u.useState(null),[I,w]=u.useState(!1),[C,A]=u.useState([]),[y,E]=u.useState(null),N=e?.id??null;u.useEffect(()=>{!n||!e||(g(e.label),b(e.icon??null),v(e.color??null),A(e.worktrees))},[n,N]),u.useEffect(()=>{!n||!e||A(j=>{const $=e.worktrees.map(G=>G.path),F=j.map(G=>G.path);return $.length===F.length&&$.every(G=>F.includes(G))?j:e.worktrees})},[e?.worktrees]);const R=er(rs(sr,{activationConstraint:{distance:8}}),rs(tr,{coordinateGetter:ir})),k=()=>{if(!e)return;const j=p.trim();a(e.id,{label:j||e.label,icon:h,color:S}),s()},P=()=>{!e||I||(w(!0),d(e.id).then(j=>{if(!j.ok){xe.error(j.error||r("projectEditDialog.toast.failedToDiscoverIcon"));return}if(j.skipped){xe.success(r("projectEditDialog.toast.customIconAlreadySet"));return}xe.success(r("projectEditDialog.toast.iconDiscovered"))}).finally(()=>w(!1)))},B=()=>{e&&m(e.id).then(j=>{if(!j.ok){xe.error(j.error||r("projectEditDialog.toast.failedToRemoveIcon"));return}xe.success(r("projectEditDialog.toast.iconRemoved"))})},D=j=>{const{active:$,over:F}=j;if(!F||$.id===F.id||!e)return;const z=C.findIndex(W=>W.path===$.id),G=C.findIndex(W=>W.path===F.id);if(z<0||G<0)return;const q=[...C],[Y]=q.splice(z,1);q.splice(G,0,Y),A(q),f(e.id,q.map(W=>Kd(W.path)))},x=S?Hi[S]??null:null,_=h?Gi[h]:null,V=!!l;return t.jsxs(t.Fragment,{children:[t.jsx(qt,{open:n,onClose:s,title:r("projectEditDialog.title"),ariaLabel:r("projectEditDialog.title"),noHeaderBorder:!0,trailing:t.jsxs(je,{type:"button",variant:"default",size:"sm","aria-label":r("projectEditDialog.actions.save"),onClick:k,disabled:!p.trim(),style:{touchAction:"manipulation"},children:[t.jsx(oo,{className:"size-4"}),r("projectEditDialog.actions.save")]}),children:e?t.jsxs("div",{className:"h-full space-y-6 overflow-y-auto px-4 pb-8 pt-2",children:[t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx("span",{className:"flex size-16 items-center justify-center overflow-hidden rounded-2xl bg-[var(--surface-muted)] text-muted-foreground",style:e.iconBackground?{backgroundColor:e.iconBackground}:void 0,children:V?t.jsx(qi,{project:{id:e.id,iconImage:l},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(Dn,{className:"size-7"})}):_?t.jsx(Q,{name:_,className:"size-7",style:x?{color:x}:void 0}):t.jsx(Dn,{className:"size-7",style:x?{color:x}:void 0})})}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.name")}),t.jsx(Xi,{value:p,onChange:j=>g(j.target.value),placeholder:r("projectEditDialog.field.namePlaceholder"),className:"h-11"}),t.jsx("p",{className:"truncate typography-meta text-muted-foreground",title:e.path,children:e.path})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.color")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>v(null),"aria-label":r("projectEditDialog.option.none"),className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",S===null?"border-foreground":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),Oa.map(j=>t.jsx("button",{type:"button",onClick:()=>v(j.key),"aria-label":j.label,title:j.label,className:Z("size-9 rounded-xl border-2 transition-all",S===j.key?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:j.cssVar,touchAction:"manipulation"}},j.key))]})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.icon")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>b(null),"aria-label":r("projectEditDialog.option.none"),className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===null?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),Ba.map(j=>t.jsx("button",{type:"button",onClick:()=>b(j.key),"aria-label":j.label,title:j.label,className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===j.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(Q,{name:j.Icon,className:"size-4",style:x?{color:x}:void 0})},j.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(je,{size:"sm",variant:"outline",onClick:P,disabled:I,children:r(I?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),V?t.jsx(je,{size:"sm",variant:"outline",onClick:B,children:r("projectEditDialog.actions.removeProjectIcon")}):null]})]}),e.isGitRepo?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("mobile.projectEdit.worktreesTitle")}),C.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r("mobile.projectEdit.worktreesEmpty")}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:r("mobile.projectEdit.reorderHint")}),t.jsx(nr,{sensors:R,collisionDetection:rr,onDragEnd:D,children:t.jsx(or,{items:C.map(j=>j.path),strategy:ar,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:C.map(j=>t.jsx(Gd,{worktree:j,onDelete:()=>E(j)},j.path))})})})]})]}):null]}):null}),e?t.jsx(Ao,{open:!!y,project:{id:e.id,path:e.path},worktree:y,onClose:()=>E(null),onDeleted:()=>{A(j=>j.filter($=>$.path!==y?.path)),i?.()}}):null]})},qd=32,Jd=80,Yd=64,Xd=.7,xr=(n,e)=>{const s=u.useRef(e);s.current=e;const i=e.enabled??!0;u.useEffect(()=>{if(!i)return;const r=n.current;if(!r)return;const a=window.Capacitor?.getPlatform?.()==="android"?Jd:qd,d=r.ownerDocument;let m=!1,f=!1,l=0,p=0;const g=()=>d.getSelection()?.isCollapsed===!1,h=()=>{m=!1},b=()=>{m&&g()&&h()},S=I=>{if(I.touches.length!==1||g()){m=!1;return}const w=I.touches[0],C=r.clientWidth,A=w.clientX<=a,y=w.clientX>=C-a;m=A||y,f=A,l=w.clientX,p=w.clientY},v=I=>{if(!m||(m=!1,g()))return;const w=I.changedTouches[0];if(!w)return;const C=w.clientX-l,A=w.clientY-p;Math.abs(C)<Yd||Math.abs(A)>Math.abs(C)*Xd||f&&C<=0||!f&&C>=0||(f?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return r.addEventListener("touchstart",S,{passive:!0}),r.addEventListener("touchend",v,{passive:!0}),r.addEventListener("touchcancel",h,{passive:!0}),r.addEventListener("selectstart",h),d.addEventListener("selectionchange",b),()=>{r.removeEventListener("touchstart",S),r.removeEventListener("touchend",v),r.removeEventListener("touchcancel",h),r.removeEventListener("selectstart",h),d.removeEventListener("selectionchange",b)}},[i,n])},Qd=new Set,Zd=[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]],ef=[["projects","mobile.sessions.viewMode.projects"],["timeline","mobile.sessions.viewMode.timeline"]],tf=7,sf=3,Gt=40,ys="openchamber:work",vs="openchamber:recent",nf=12,rf=16,of=(n,e)=>{const s=Te(n),i=Te(e),r=i.endsWith("/")?i:`${i}/`;return!!(s&&i&&(s===i||s.startsWith(r)))},En=(n,e)=>n.worktrees.find(s=>Te(s.path)===e)??null,In=(n,e,s)=>Qi([n.title,n.id,dt(n),e],s),af=n=>{const e=me.c(2),{ariaLabel:s}=n;let i;return e[0]!==s?(i=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":s}),e[0]=s,e[1]=i):i=e[1],i},yi=n=>{const e=me.c(12),{onClick:s,className:i}=n,{t:r}=be();let o;e[0]!==r?(o=r("sessions.sidebar.project.actions.newWorktree"),e[0]=r,e[1]=o):o=e[1];const a=o;let d;e[2]!==i?(d=Z("flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",i),e[2]=i,e[3]=d):d=e[3];let m;e[4]!==s?(m=g=>{g.stopPropagation(),s()},e[4]=s,e[5]=m):m=e[5];let f,l;e[6]===Symbol.for("react.memo_cache_sentinel")?(f={touchAction:"manipulation"},l=t.jsx(Q,{name:"node-tree",className:"size-4"}),e[6]=f,e[7]=l):(f=e[6],l=e[7]);let p;return e[8]!==a||e[9]!==d||e[10]!==m?(p=t.jsx("button",{type:"button",className:d,"aria-label":a,title:a,onClick:m,style:f,children:l}),e[8]=a,e[9]=d,e[10]=m,e[11]=p):p=e[11],p},An=n=>{const e=me.c(10),{label:s,onClick:i,className:r}=n;let o;e[0]!==r?(o=Z("flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==i?(a=l=>{l.stopPropagation(),i()},e[2]=i,e[3]=a):a=e[3];let d,m;e[4]===Symbol.for("react.memo_cache_sentinel")?(d={touchAction:"manipulation"},m=t.jsx(Q,{name:"add",className:"size-4"}),e[4]=d,e[5]=m):(d=e[4],m=e[5]);let f;return e[6]!==s||e[7]!==o||e[8]!==a?(f=t.jsx("button",{type:"button",className:o,"aria-label":s,title:s,onClick:a,style:d,children:m}),e[6]=s,e[7]=o,e[8]=a,e[9]=f):f=e[9],f},vi=n=>{const e=me.c(75),{session:s,active:i,indent:r,contextLabel:o,statusOnRight:a,hasChildren:d,expanded:m,onToggleChildren:f,onSelect:l,revealed:p,onRevealedChange:g,confirmingDelete:h,onArchive:b,onRequestDelete:S,onConfirmDelete:v,renaming:I,onRequestRename:w,onSubmitRename:C,onCancelRename:A,work:y,pin:E}=n,N=a===void 0?!1:a,R=d===void 0?!1:d,k=m===void 0?!1:m,P=p===void 0?!1:p,B=h===void 0?!1:h,D=I===void 0?!1:I,{t:x}=be();let _;e[0]!==s?(_=on(_o(s)),e[0]=s,e[1]=_):_=e[1];const V=_;let j;e[2]!==s.title||e[3]!==x?(j=s.title?.trim()||x("mobile.sessions.untitled"),e[2]=s.title,e[3]=x,e[4]=j):j=e[4];const $=j,F=!!(g&&b),z=ro(s.id,s.directory,F&&(P||D)),G=Un(s.id),q=Kn(s.id),Y=!q&&G>0&&!i,W=Gn(s.id,q),te=(q||Y)&&W;let ce;e[5]!==q||e[6]!==s||e[7]!==y?.inWork?(ce=!!y?.inWork&&!q&&Ga(s),e[5]=q,e[6]=s,e[7]=y?.inWork,e[8]=ce):ce=e[8];const le=ce;let se;e[9]!==z||e[10]!==k||e[11]!==R||e[12]!==r||e[13]!==q||e[14]!==f||e[15]!==Y||e[16]!==N||e[17]!==x?(se=!N&&(z.pending||q||Y||R&&f)?t.jsx("button",{type:"button",className:"absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:{left:Math.max(r-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":z.pending?x("sessions.aiRename.generating"):x(k?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!R||!f,onClick:he=>{he.stopPropagation(),f?.()},children:z.pending?t.jsx(Q,{name:"loader-4",className:"size-3 animate-spin text-primary","aria-label":x("sessions.aiRename.generating")}):q||Y?t.jsx(qs,{state:q?"running":"unread",label:x(q?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread")}):t.jsx(Zn,{className:Z("size-[18px] transition-transform duration-150",k?"rotate-0":"-rotate-90")})}):null,e[9]=z,e[10]=k,e[11]=R,e[12]=r,e[13]=q,e[14]=f,e[15]=Y,e[16]=N,e[17]=x,e[18]=se):se=e[18];let ie;e[19]!==i||e[20]!==z||e[21]!==o||e[22]!==r||e[23]!==q||e[24]!==A||e[25]!==g||e[26]!==l||e[27]!==C||e[28]!==E?.pinned||e[29]!==D||e[30]!==P||e[31]!==s.id||e[32]!==te||e[33]!==le||e[34]!==Y||e[35]!==N||e[36]!==x||e[37]!==V||e[38]!==$?(ie=D&&C&&A?t.jsx(Po,{initialTitle:$,indent:r,aiRename:z,onSubmit:C,onCancel:A}):t.jsx("button",{type:"button",className:Z("flex min-w-0 flex-1 items-center gap-2.5 pr-3.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",o?"min-h-10 py-1":"h-9"),style:{paddingLeft:r,touchAction:"manipulation"},onClick:()=>{if(P){g?.(!1);return}l()},children:t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsxs("span",{className:"flex items-center gap-2.5",children:[t.jsx("span",{className:Z("block min-w-0 flex-1 truncate typography-ui-label",i?"text-primary":"text-foreground"),children:$}),E?.pinned?t.jsx(Q,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":x("sessions.sidebar.session.status.pinned")}):null,N&&(z.pending||q||Y)?z.pending?t.jsx(Q,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":x("sessions.aiRename.generating")}):t.jsx(qs,{state:q?"running":"unread",label:x(q?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread")}):null,le?t.jsx(Q,{name:"check",className:"size-3.5 shrink-0 text-muted-foreground","aria-label":x("sessions.sidebar.session.work.doneSuggested")}):null,te?t.jsx(Xn,{sessionId:s.id,running:q,className:"typography-micro"}):V?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:V}):null]}),o?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:o}):null]})}),e[19]=i,e[20]=z,e[21]=o,e[22]=r,e[23]=q,e[24]=A,e[25]=g,e[26]=l,e[27]=C,e[28]=E?.pinned,e[29]=D,e[30]=P,e[31]=s.id,e[32]=te,e[33]=le,e[34]=Y,e[35]=N,e[36]=x,e[37]=V,e[38]=$,e[39]=ie):ie=e[39];let O;e[40]!==se||e[41]!==ie?(O=t.jsxs(t.Fragment,{children:[se,ie]}),e[40]=se,e[41]=ie,e[42]=O):O=e[42];const ee=O;if(!F){const he=i||void 0,J=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let de;e[43]!==J?(de=Z("relative flex items-center gap-1 transition-colors",J),e[43]=J,e[44]=de):de=e[44];let Se;e[45]!==ee||e[46]!==de?(Se=t.jsx("div",{className:de,children:ee}),e[45]=ee,e[46]=de,e[47]=Se):Se=e[47];let Ee;return e[48]!==he||e[49]!==Se?(Ee=t.jsx("div",{"data-active-session":he,className:"relative overflow-hidden",children:Se}),e[48]=he,e[49]=Se,e[50]=Ee):Ee=e[50],Ee}const ne=To+(y?Ps:0)+(E?Ps:0);let ae;e[51]!==g?(ae=he=>g?.(he),e[51]=g,e[52]=ae):ae=e[52];const H=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let re;e[53]!==H?(re=Z("relative flex w-full items-center gap-1 bg-background transition-colors",H),e[53]=H,e[54]=re):re=e[54];let ue;e[55]!==B||e[56]!==b||e[57]!==v||e[58]!==S||e[59]!==w||e[60]!==g||e[61]!==E||e[62]!==P||e[63]!==s.id||e[64]!==$||e[65]!==y?(ue=t.jsx(Do,{sessionId:s.id,title:$,revealed:P,confirmingDelete:B,onArchive:b,onRequestDelete:S,onConfirmDelete:v,onRequestRename:w,onRevealedChange:g,work:y,pin:E}),e[55]=B,e[56]=b,e[57]=v,e[58]=S,e[59]=w,e[60]=g,e[61]=E,e[62]=P,e[63]=s.id,e[64]=$,e[65]=y,e[66]=ue):ue=e[66];let ye;return e[67]!==i||e[68]!==P||e[69]!==ee||e[70]!==ne||e[71]!==ae||e[72]!==re||e[73]!==ue?(ye=t.jsx(tn,{actionsWidth:ne,revealed:P,onRevealedChange:ae,dataActiveSession:i,contentClassName:re,actions:ue,children:ee}),e[67]=i,e[68]=P,e[69]=ee,e[70]=ne,e[71]=ae,e[72]=re,e[73]=ue,e[74]=ye):ye=e[74],ye},wi=[],lf=n=>{const e=me.c(40),{run:s,laneNodes:i,indent:r}=n,{t:o}=be();let a;e[0]!==s.key?(a=B=>B.runOverviewKey===s.key,e[0]=s.key,e[1]=a):a=e[1];const d=ze(a);let m;e[2]!==i?(m={nodes:i,includeUnreadSubtasks:!1},e[2]=i,e[3]=m):m=e[3];const f=no(m);let l;e[4]!==s.lastActivity?(l=on(s.lastActivity),e[4]=s.lastActivity,e[5]=l):l=e[5];const p=l,g=d||void 0,h=d&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let b;e[6]!==h?(b=Z("relative flex items-center overflow-hidden transition-colors",h),e[6]=h,e[7]=b):b=e[7];let S;e[8]!==f||e[9]!==r?(S=f?t.jsx("span",{className:"absolute flex w-6 items-center justify-center",style:{left:Math.max(r-32,2),top:0,bottom:0},children:t.jsx(io,{state:f})}):null,e[8]=f,e[9]=r,e[10]=S):S=e[10];let v;e[11]!==r?(v={paddingLeft:r,touchAction:"manipulation"},e[11]=r,e[12]=v):v=e[12];let I;e[13]!==s.key?(I=()=>ze.getState().setRunOverviewKey(s.key),e[13]=s.key,e[14]=I):I=e[14];let w;e[15]!==s.title||e[16]!==o?(w=o("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[15]=s.title,e[16]=o,e[17]=w):w=e[17];let C;e[18]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(Yi,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[18]=C):C=e[18];const A=d?"text-primary":"text-foreground";let y;e[19]!==A?(y=Z("block min-w-0 flex-1 truncate typography-ui-label",A),e[19]=A,e[20]=y):y=e[20];let E;e[21]!==s.title||e[22]!==y?(E=t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[C,t.jsx("span",{className:y,children:s.title})]}),e[21]=s.title,e[22]=y,e[23]=E):E=e[23];let N;e[24]!==s.providerIDs?(N=t.jsx(Mo,{providerIDs:s.providerIDs}),e[24]=s.providerIDs,e[25]=N):N=e[25];let R;e[26]!==p?(R=p?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:p}):null,e[26]=p,e[27]=R):R=e[27];let k;e[28]!==w||e[29]!==E||e[30]!==N||e[31]!==R||e[32]!==v||e[33]!==I?(k=t.jsxs("button",{type:"button",className:"flex h-9 w-full min-w-0 items-center gap-2.5 pr-3.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:v,onClick:I,"aria-label":w,children:[E,N,R]}),e[28]=w,e[29]=E,e[30]=N,e[31]=R,e[32]=v,e[33]=I,e[34]=k):k=e[34];let P;return e[35]!==k||e[36]!==g||e[37]!==b||e[38]!==S?(P=t.jsxs("div",{"data-active-session":g,className:b,children:[S,k]}),e[35]=k,e[36]=g,e[37]=b,e[38]=S,e[39]=P):P=e[39],P},cf=n=>{const e=me.c(11),{indent:s,onClick:i}=n,{t:r}=be();let o;e[0]!==s?(o={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Zn,{className:"size-4"}),e[2]=a):a=e[2];let d;e[3]!==r?(d=r("sessions.sidebar.group.showMore"),e[3]=r,e[4]=d):d=e[4];let m;e[5]!==d?(m=t.jsx("span",{className:"typography-micro",children:d}),e[5]=d,e[6]=m):m=e[6];let f;return e[7]!==i||e[8]!==o||e[9]!==m?(f=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:o,onClick:i,children:[a,m]}),e[7]=i,e[8]=o,e[9]=m,e[10]=f):f=e[10],f},uf=n=>{const e=me.c(11),{indent:s,onClick:i}=n,{t:r}=be();let o;e[0]!==s?(o={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Uc,{className:"size-4"}),e[2]=a):a=e[2];let d;e[3]!==r?(d=r("sessions.sidebar.group.showFewer"),e[3]=r,e[4]=d):d=e[4];let m;e[5]!==d?(m=t.jsx("span",{className:"typography-micro",children:d}),e[5]=d,e[6]=m):m=e[6];let f;return e[7]!==i||e[8]!==o||e[9]!==m?(f=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:o,onClick:i,children:[a,m]}),e[7]=i,e[8]=o,e[9]=m,e[10]=f):f=e[10],f},df=n=>{const e=me.c(29),{worktree:s}=n,{t:i}=be();let r;e[0]!==s.path?(r=Te(s.path),e[0]=s.path,e[1]=r):r=e[1];const o=r;let a;e[2]!==o?(a={id:o},e[2]=o,e[3]=a):a=e[3];const{attributes:d,listeners:m,setNodeRef:f,transform:l,transition:p,isDragging:g}=lr(a),h=s.branch||s.label||s.path;let b;e[4]!==l?(b=cr.Transform.toString(l),e[4]=l,e[5]=b):b=e[5];const S=g?10:1;let v;e[6]!==b||e[7]!==S||e[8]!==p?(v={transform:b,transition:p,zIndex:S},e[6]=b,e[7]=S,e[8]=p,e[9]=v):v=e[9];const I=g&&"shadow-lg shadow-black/20";let w;e[10]!==I?(w=Z("flex items-center gap-1 rounded-xl bg-background px-1 py-1",I),e[10]=I,e[11]=w):w=e[11];let C;e[12]!==h||e[13]!==i?(C=i("mobile.sessions.dragHandleAria",{label:h}),e[12]=h,e[13]=i,e[14]=C):C=e[14];let A;e[15]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(Qn,{className:"size-4"}),e[15]=A):A=e[15];let y;e[16]!==d||e[17]!==m||e[18]!==C?(y=t.jsx("button",{type:"button",className:"flex size-8 shrink-0 cursor-grab touch-none items-center justify-center rounded-lg text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":C,...d,...m,children:A}),e[16]=d,e[17]=m,e[18]=C,e[19]=y):y=e[19];let E;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(Q,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=E):E=e[20];let N;e[21]!==h?(N=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-bold text-muted-foreground",children:h}),e[21]=h,e[22]=N):N=e[22];let R;return e[23]!==f||e[24]!==y||e[25]!==N||e[26]!==v||e[27]!==w?(R=t.jsxs("div",{ref:f,style:v,className:w,children:[y,E,N]}),e[23]=f,e[24]=y,e[25]=N,e[26]=v,e[27]=w,e[28]=R):R=e[28],R},ff=n=>{const e=me.c(61),{project:s,totalSessions:i,expanded:r,onToggleExpanded:o,onReorderWorktrees:a}=n,{t:d}=be();let m;e[0]!==s.id?(m={id:s.id},e[0]=s.id,e[1]=m):m=e[1];const{attributes:f,listeners:l,setNodeRef:p,transform:g,transition:h,isDragging:b}=lr(m);let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S={activationConstraint:{distance:8}},e[2]=S):S=e[2];let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v={coordinateGetter:ir},e[3]=v):v=e[3];const I=er(rs(sr,S),rs(tr,v)),w=s.worktrees.length>0;let C;e[4]!==a||e[5]!==s.worktrees?(C=te=>{const{active:ce,over:le}=te;if(!le||ce.id===le.id)return;const se=s.worktrees.map(gf),ie=se.indexOf(String(ce.id)),O=se.indexOf(String(le.id));if(ie<0||O<0)return;const ee=[...se],[ne]=ee.splice(ie,1);ee.splice(O,0,ne),a(ee)},e[4]=a,e[5]=s.worktrees,e[6]=C):C=e[6];const A=C;let y;e[7]!==g?(y=cr.Transform.toString(g),e[7]=g,e[8]=y):y=e[8];const E=b?10:1;let N;e[9]!==y||e[10]!==E||e[11]!==h?(N={transform:y,transition:h,zIndex:E},e[9]=y,e[10]=E,e[11]=h,e[12]=N):N=e[12];const R=b&&"shadow-lg shadow-black/20";let k;e[13]!==R?(k=Z("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",R),e[13]=R,e[14]=k):k=e[14];let P;e[15]!==s.label||e[16]!==d?(P=d("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=d,e[17]=P):P=e[17];let B;e[18]===Symbol.for("react.memo_cache_sentinel")?(B=t.jsx(Qn,{className:"size-4"}),e[18]=B):B=e[18];let D;e[19]!==f||e[20]!==l||e[21]!==P?(D=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":P,...f,...l,children:B}),e[19]=f,e[20]=l,e[21]=P,e[22]=D):D=e[22];let x;e[23]!==r||e[24]!==s.label||e[25]!==d?(x=r?d("sessions.sidebar.group.collapseAria",{label:s.label}):d("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=r,e[24]=s.label,e[25]=d,e[26]=x):x=e[26];const _=!w;let V;e[27]===Symbol.for("react.memo_cache_sentinel")?(V={touchAction:"manipulation"},e[27]=V):V=e[27];let j;e[28]!==s?(j=t.jsx(As,{project:s}),e[28]=s,e[29]=j):j=e[29];let $;e[30]!==s.label?($=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s.label}),e[30]=s.label,e[31]=$):$=e[31];let F;e[32]!==i?(F=t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:i}),e[32]=i,e[33]=F):F=e[33];let z;e[34]!==r||e[35]!==w?(z=w?t.jsx(Zn,{className:Z("size-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-180")}):null,e[34]=r,e[35]=w,e[36]=z):z=e[36];let G;e[37]!==r||e[38]!==o||e[39]!==x||e[40]!==_||e[41]!==j||e[42]!==$||e[43]!==F||e[44]!==z?(G=t.jsxs("button",{type:"button",className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 rounded-xl px-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:o,"aria-expanded":r,"aria-label":x,disabled:_,style:V,children:[j,$,F,z]}),e[37]=r,e[38]=o,e[39]=x,e[40]=_,e[41]=j,e[42]=$,e[43]=F,e[44]=z,e[45]=G):G=e[45];let q;e[46]!==D||e[47]!==G?(q=t.jsxs("div",{className:"flex items-center gap-1",children:[D,G]}),e[46]=D,e[47]=G,e[48]=q):q=e[48];let Y;e[49]!==r||e[50]!==A||e[51]!==w||e[52]!==s.worktrees||e[53]!==I?(Y=r&&w?t.jsx(nr,{sensors:I,collisionDetection:rr,onDragEnd:A,children:t.jsx(or,{items:s.worktrees.map(bf),strategy:ar,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 pl-3",children:s.worktrees.map(xf)})})}):null,e[49]=r,e[50]=A,e[51]=w,e[52]=s.worktrees,e[53]=I,e[54]=Y):Y=e[54];let W;return e[55]!==p||e[56]!==q||e[57]!==Y||e[58]!==N||e[59]!==k?(W=t.jsxs("div",{ref:p,style:N,className:k,children:[q,Y]}),e[55]=p,e[56]=q,e[57]=Y,e[58]=N,e[59]=k,e[60]=W):W=e[60],W},ji=({open:n,onOpenChange:e,variant:s="drawer",footer:i})=>{const{t:r}=be(),{git:o}=qn(),a=Je(c=>c.ensureStatus),d=Vi(),m=Zt(c=>c.activeSessions),f=n||s==="sidebar",l=u.useRef(Qd),p=Tn(u.useCallback(c=>(f&&(l.current=c.ids),l.current),[f])),g=u.useRef(La),h=Li(u.useCallback(c=>(f&&(g.current=c.rankById),g.current),[f])),b=Ye(c=>c.projects),S=$a(c=>c.projects),v=Ye(c=>c.activeProjectId),I=Nt(c=>c.currentDirectory),w=Re(c=>c.currentSessionId),C=Re(c=>c.setCurrentSession),A=Re(c=>c.archiveSession),y=Re(c=>c.archiveSessions),E=Re(c=>c.deleteSession),N=Re(c=>c.deleteSessions),R=Re(c=>c.updateSessionTitle),k=Re(c=>c.openNewSessionDraft),P=Ye(c=>c.setActiveProject),B=Ye(c=>c.setActiveProjectIdOnly),D=Ye(c=>c.reorderProjects),x=Ye(c=>c.manualProjectOrder),_=Ut(c=>c.projectSortOrder),V=Ut(c=>c.setProjectSortOrder),j=Ut(c=>c.sidebarViewMode),$=Ut(c=>c.setSidebarViewMode),F=Ut(c=>c.showRecentSection),z=Ut(c=>c.setShowRecentSection),G=Tn(c=>c.toggle),q=j==="projects"&&F,Y=Fa(f&&(j==="timeline"||q)),W=Ye(c=>c.removeProject),te=Vs(c=>c.projectExpanded),ce=Vs(c=>c.worktreeExpanded),le=Vs(c=>c.setProjectExpanded),se=Vs(c=>c.setWorktreeExpanded),ie=Bn(c=>c.orderByProject),O=Bn(c=>c.setWorktreeOrder),ee=gi(c=>c.expandedParents),ne=gi(c=>c.toggleParent),[ae,H]=u.useState(""),[re,ue]=u.useState(null),[ye,he]=u.useState(null),[J,de]=u.useState(null),[Se,Ee]=u.useState(null),[ve,Ae]=u.useState(null),[nt,Fe]=u.useState(null),[Le,Ie]=u.useState(null),[Ue,Xe]=u.useState(0),[Rt,kt]=u.useState(!1),[an,Ke]=u.useState(!1),[Qe,ht]=u.useState(!1),[gt,bt]=u.useState(null),[Ts,Ds]=u.useState(()=>new Map(Re.getState().availableWorktreesByProject)),[Ne,_s]=u.useState(()=>{const c=new Set;for(const[M,L]of Re.getState().availableWorktreesByProject)L.length>0&&c.add(M);return c}),[$e,rt]=u.useState(!1),[ln,us]=u.useState(new Set),[cn,$t]=u.useState(new Map),[Et,We]=u.useState(Hs),it=u.useRef(null);u.useEffect(()=>{if(!n){H(""),rt(!1),us(new Set),$t(new Map),We(Hs),ue(null),he(null),de(null),Ee(null),Ae(null),Fe(null);return}Hn(d)},[n]),u.useEffect(()=>{$e||us(new Set)},[$e]),u.useEffect(()=>{We(Hs)},[j]),u.useEffect(()=>{if(!n||b.length===0)return;let c=!1;return(async()=>{const L=await Promise.all(b.map(async K=>{const oe=Te(K.path);if(!oe)return null;const pe=await o.checkIsGitRepository(oe).catch(()=>null),fe=pe?await Zi({id:K.id,path:oe}).catch(()=>null):[];return[oe,fe,pe]}));c||(Ds(K=>{const oe=new Map;for(const pe of L){if(!pe)continue;const[fe,Oe,He]=pe,St=He===null||Oe===null;oe.set(fe,St?K.get(fe)??[]:Oe)}return eo(b,oe)}),_s(K=>{const oe=new Set;for(const pe of L){if(!pe)continue;const[fe,,Oe]=pe;(Oe===null?K.has(fe):Oe)&&oe.add(fe)}return oe}))})(),()=>{c=!0}},[o,n,b,Ue]);const we=u.useMemo(()=>nc(b.map(c=>({id:c.id,label:c.label?.trim()||Cn(c.path),path:Te(c.path),icon:c.icon,color:c.color,iconImage:c.iconImage,iconBackground:c.iconBackground,isGitRepo:Ne.has(Te(c.path)),worktrees:Pd(ie[c.id],Ts.get(Te(c.path))??[]),addedAt:c.addedAt,lastOpenedAt:c.lastOpenedAt})),_,x),[Ne,x,_,b,ie,Ts]),De=u.useMemo(()=>{const c=new Map(d.map(K=>[K.id,K])),M=m.map(K=>{const oe=c.get(K.id);return oe?Wa(oe,K):K}),L=new Set(M.map(K=>K.id));for(const K of d)L.has(K.id)||M.push(K);return M.filter(K=>!K.time?.archived)},[m,d]),xt=u.useMemo(()=>{const c=new Map;for(const M of De){const L=ct(M);if(!L)continue;const K=c.get(L)??[];K.push(M),c.set(L,K)}return c},[De]),{projectSessions:ot,chatSessions:Pe}=u.useMemo(()=>rc(De,!1),[De]),Ft=ze(c=>c.sessionWorkEnabled),at=u.useMemo(()=>{const c=new Set;if(!Ft)return c;for(const M of De)if(!(ct(M)||wn(dt(M))||!Ji(M))){c.add(M.id);for(const L of jn(xt,M.id))c.add(L)}return c},[xt,Ft,De]),lt=u.useMemo(()=>at.size>0?ot.filter(c=>!at.has(c.id)):ot,[ot,at]),Wt=u.useMemo(()=>at.size>0?Pe.filter(c=>!at.has(c.id)):Pe,[Pe,at]),mt=pa(),yt=u.useMemo(()=>new Map(mt.map(c=>[c.id,c])),[mt]),It=u.useMemo(()=>new Map(mt.map(c=>[c.id,c.name||r("sessions.sidebar.grouping.spaceUnnamed")])),[mt,r]),_e=u.useMemo(()=>ic(ot,we.map(c=>({id:c.id,normalizedPath:c.path})),new Map(we.map(c=>[c.path,c.worktrees])),!1,[],S,mt),[S,ot,we,mt]),Ze=u.useMemo(()=>Va(ot,c=>{const M=_e.bySessionId.get(c.id);return(M?we.find(K=>K.id===M.projectId):void 0)?.path||Te(dt(c))||null}),[ot,we,_e]),At=u.useMemo(()=>{const c=new Map(De.map(K=>[K.id,K])),M=K=>({session:K,children:(xt.get(K.id)??[]).map(M),worktree:null}),L=new Map;for(const K of Ze.runs.values())L.set(K.key,K.memberIds.flatMap(oe=>{const pe=c.get(oe);return pe?[M(pe)]:[]}));return L},[xt,Ze,De]),Pt=u.useMemo(()=>({key:gs,label:"",path:"",worktree:null,space:null,sessions:Kt(Wt,p,h)}),[p,Wt,h]),un=u.useMemo(()=>new Set(Pt.sessions.filter(c=>Xr(p,dt(c)||null,c.id)).map(c=>c.id)),[Pt,p]),ds=u.useMemo(()=>({key:ys,label:"",path:"",worktree:null,space:null,sessions:at.size>0?Kt(De.filter(c=>at.has(c.id)),p,h):[]}),[p,h,De,at]),Tt=oc({enabled:f&&q,isVSCode:!1,pinnedSessionIds:p,sessionOrderRanks:h,sessions:lt}),[Ms,fs]=u.useState(Tt);f&&Ms!==Tt&&fs(Tt);const vt=f?Tt:Ms,ms=u.useMemo(()=>{const c=new Set;for(const M of vt){c.add(M.id);for(const L of jn(xt,M.id))c.add(L)}return{key:vs,label:"",path:"",worktree:null,space:null,sessions:c.size>0?Kt(lt.filter(M=>c.has(M.id)),p,h):[]}},[xt,p,vt,lt,h]),dn=u.useMemo(()=>{const c=new Map;if(vt.length===0)return c;const M=Zr({sessions:vt,projects:we.map(L=>({id:L.id,normalizedPath:L.path,label:L.label})),ownerBySessionId:_e.bySessionId,availableWorktreesByProject:new Map(we.map(L=>[L.path,L.worktrees])),gitBranches:Y,homeDirectory:null,hideBranchMatchingProjectLabel:!0,spaceLabelById:It});for(const[L,K]of M)K.projectLabel&&c.set(L,K.branchLabel?`${K.projectLabel} · ${K.branchLabel}`:K.projectLabel);return c},[Y,we,vt,_e,It]),T=`${gs}::${gs}`,U=u.useMemo(()=>Wt.filter(c=>!ct(c)).length,[Wt]),X=ae.trim().toLowerCase(),Ce=u.useRef(null);u.useEffect(()=>{if(!n)return;const c=window.requestAnimationFrame(()=>{const M=Ce.current;if(!M)return;(M.querySelector('[data-active-session="true"]')??M.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(c)},[n]);const Ge=u.useMemo(()=>{const c=we.map(L=>({project:L,buckets:[],totalSessions:0,isActive:L.id===v})),M=(L,K,oe,pe=null)=>{const fe=Te(K)||L.project.path,Oe=fe||"__root__";let He=L.buckets.find(St=>St.key===Oe);return He||(He={key:Oe,label:(pe?pe.name||r("sessions.sidebar.grouping.spaceUnnamed"):null)||oe?.branch||Cn(fe),path:fe,worktree:oe,space:pe,sessions:[]},L.buckets.push(He)),He};for(const L of c){M(L,L.project.path,null);for(const K of L.project.worktrees)M(L,K.path,K);for(const K of mt)K.directory&&Te(K.projectDirectory)===Te(L.project.path)&&M(L,K.directory,null,K)}for(const L of lt){const K=_e.bySessionId.get(L.id);if(!K)continue;const oe=c.find(He=>He.project.id===K.projectId);if(!oe)continue;const pe=En(oe.project,K.scopeDirectory),fe=K.kind==="space"&&K.spaceId?yt.get(K.spaceId)??null:null;(fe?M(oe,K.scopeDirectory,null,fe):pe&&!Ze.runKeyBySessionId.has(L.id)?M(oe,pe.path,pe):M(oe,oe.project.path,null)).sessions.push(L)}for(const L of c)for(const K of L.buckets){K.sessions=Kt(K.sessions,p,h);for(const oe of K.sessions)ct(oe)||(L.totalSessions+=1)}return c},[v,p,we,Ze,lt,h,_e,mt,yt,r]),zs=Te(I),Vt=c=>c.isActive?zs===c.project.path?c.project.path:c.project.worktrees.find(L=>of(zs,L.path))?.path??c.project.path:null,fn=c=>te[c.project.id]??!0,Lo=(c,M)=>ce[`${c.project.id}::${M.key}`]??!0,vr=c=>{$t(M=>{if(!M.has(c))return M;const L=new Map(M);return L.delete(c),L})},$o=c=>{$t(M=>{let L=!1;const K=new Map(M),oe=`${c}::`;for(const pe of K.keys())pe.startsWith(oe)&&(K.delete(pe),L=!0);return L?K:M})},Fo=(c,M,L)=>{$t(K=>{const oe=new Map(K);return oe.set(c,M+L),oe})},ps=(c,M,L,K)=>{const oe=K?.pageSize??tf,pe=K?.alwaysVisibleIds,fe=new Set(M.sessions.map(ge=>ge.id)),Oe=new Map;for(const ge of M.sessions){const qe=ct(ge);if(qe&&fe.has(qe)){const pt=Oe.get(qe)??[];pt.push(ge),Oe.set(qe,pt)}}const He=M.sessions.filter(ge=>{const qe=ct(ge);return!qe||!fe.has(qe)}),St=new Set,gn=He.flatMap(ge=>{const qe=Ze.runKeyBySessionId.get(ge.id),pt=qe?Ze.runs.get(qe):void 0;return pt?St.has(pt.key)?[]:(St.add(pt.key),[{kind:"run",run:pt}]):[{kind:"session",session:ge}]}),$r=ge=>ge.kind==="session"&&!!pe?.has(ge.session.id),na=pe?gn.filter($r):[],bn=pe?gn.filter(ge=>!$r(ge)):gn,ra=cn.get(c)??oe,xn=bn.slice(0,ra),ia=[...na,...xn],Fr=bn.length-xn.length,oa=bn.length>oe&&Fr===0,Wr=(ge,qe)=>{const pt=Oe.get(ge.id)??[],yn=pt.length>0,Vr=!!ee[ge.id],aa=qe===L;return t.jsxs(u.Fragment,{children:[t.jsx(vi,{session:ge,active:w===ge.id,indent:qe,contextLabel:aa?K?.rootContextLabel?.(ge):void 0,hasChildren:yn,expanded:Vr,onToggleChildren:yn?()=>ne(ge.id):void 0,onSelect:()=>mn(ge),statusOnRight:K?.statusOnRight,revealed:ye===ge.id,onRevealedChange:hs=>wr(ge.id,hs),confirmingDelete:J===ge.id,onArchive:()=>{kr(ge)},onRequestDelete:()=>de(ge.id),onConfirmDelete:()=>{Rr(ge)},renaming:Se===ge.id,onRequestRename:()=>Er(ge.id),onSubmitRename:hs=>{Ir(ge.id,hs)},onCancelRename:()=>Ee(null),work:Vo(ge),pin:Uo(ge)}),yn&&Vr?pt.map(hs=>Wr(hs,qe+rf)):null]},ge.id)};return t.jsxs("div",{children:[ia.map(ge=>ge.kind==="run"?t.jsx(lf,{run:ge.run,laneNodes:At.get(ge.run.key)??wi,indent:L},`run:${ge.run.key}`):Wr(ge.session,L)),Fr>0?t.jsx(cf,{indent:L,onClick:()=>Fo(c,xn.length,oe)}):null,oa?t.jsx(uf,{indent:L,onClick:()=>vr(c)}):null]})},Os=(c,M)=>{le(c,!M),$o(c)},Wo=(c,M,L)=>{se(`${c}::${M}`,!L),vr(`${c}::${M}`)},mn=c=>{const M=dt(c)||null,L=_e.bySessionId.get(c.id),K=L?we.find(oe=>oe.id===L.projectId)??null:null;if(K){B(K.id),le(K.id,!0);const oe=En(K,L?.scopeDirectory??"");oe&&se(`${K.id}::${Te(oe.path)}`,!0)}C(c.id,M),e(!1)},wr=(c,M)=>{he(M?c:null),de(null),Ae(null),Fe(null)},Dt=(c,M)=>{Ae(M?c:null),Fe(null),he(null),de(null)},jr=(c,M)=>(he(null),de(null),dc(c,M,fc(M.id,jn(xt,M.id),c==="delete"),{archiveSession:A,archiveSessions:y,deleteSession:E,deleteSessions:N},r)),kr=c=>jr("archive",c),Sr=async(c,M)=>{try{await Ha(c.id,dt(c)||null,M?"done":"open")}catch{xe.error(r("sessions.sidebar.session.work.updateFailed"))}},Vo=c=>{if(!Ft||ct(c)||wn(dt(c)))return;const M=at.has(c.id);return{inWork:M,onToggle:()=>{Sr(c,M)}}},Nr=c=>Xr(p,dt(c)||null,c.id),Cr=c=>{const M=dt(c);M&&G({directory:M,sessionId:c.id})},Uo=c=>{if(!(ct(c)||!dt(c)))return{pinned:Nr(c),onToggle:()=>Cr(c)}},Rr=c=>jr("delete",c),Er=c=>{he(null),de(null),Ee(c)},Ir=async(c,M)=>{Ee(null);try{await R(c,M)}catch{xe.error(r("mobile.sessions.renameError"))}},Ar=()=>{k(),e(!1)},Pr=c=>{bt(c),B(c),ht(!0)},Ko=er(rs(sr,{activationConstraint:{distance:8}}),rs(tr,{coordinateGetter:ir})),Go=c=>{V(c),vn({sidebarProjectSortOrder:c}),c!=="manual"&&rt(!1)},Ho=c=>{$(c),vn({sidebarViewMode:c}),c==="timeline"&&rt(!1)},qo=()=>{const c=!F;z(c),vn({sidebarShowRecentSection:c})},Jo=c=>{const{active:M,over:L}=c;if(!L||M.id===L.id)return;const K=we.findIndex(pe=>pe.id===M.id),oe=we.findIndex(pe=>pe.id===L.id);K<0||oe<0||D(K,oe)},Yo=c=>{us(M=>{const L=new Set(M);return L.has(c)?L.delete(c):L.add(c),L})},Tr=u.useCallback(c=>{const M=dt(c);if(wn(M))return r("mobile.sessions.section.chats");const L=_e.bySessionId.get(c.id),K=L?we.find(fe=>fe.id===L.projectId)??null:null;if(!K)return Cn(M)||M;const oe=L?.kind==="space"&&L.spaceId?yt.get(L.spaceId):void 0;if(oe)return`${K.label} · ${oe.name||r("sessions.sidebar.grouping.spaceUnnamed")}`;const pe=En(K,L?.scopeDirectory??"");return pe?.branch?`${K.label} · ${pe.branch}`:K.label},[we,_e,yt,r]),Xo=c=>{P(c.id),e(!1)},Dr=c=>{B(c.id),k({selectedProjectId:c.id,directoryOverride:c.path}),e(!1)},Qo=u.useMemo(()=>X?Ge.filter(c=>Qi([c.project.label,c.project.path],X)?!0:c.buckets.some(M=>M.sessions.some(L=>In(L,c.project.label,X)))):Ge,[X,Ge]),Bs=u.useMemo(()=>X?Kt(De.filter(c=>{if(ct(c))return!1;const M=_e.bySessionId.get(c.id),L=M?we.find(K=>K.id===M.projectId)??null:null;return In(c,L?.label??"",X)}),p,h):[],[X,p,we,h,_e,De]),Ls=u.useMemo(()=>X?Ua(we,X,c=>[c.label,c.path]):[],[X,we]),ut=j==="timeline"&&!X&&!$e,_r=ut||q;u.useEffect(()=>{if(!(!_r||!o))for(const c of we){const M=Te(c.path);M&&Ka(()=>a(M,o))}},[a,o,_r,we]);const pn=u.useMemo(()=>{const c=new Map;if(!ut)return c;const M=Zr({sessions:ot,projects:we.map(L=>({id:L.id,normalizedPath:L.path,label:L.label})),ownerBySessionId:_e.bySessionId,availableWorktreesByProject:new Map(we.map(L=>[L.path,L.worktrees])),gitBranches:Y,homeDirectory:null,hideBranchMatchingProjectLabel:!1,spaceLabelById:It});for(const L of ot){if(ct(L))continue;const K=M.get(L.id),oe=K?we.find(pe=>pe.id===K.projectId):null;!oe||!K||c.set(L.id,{project:oe,branch:K.branchLabel})}return c},[Y,ot,we,_e,It,ut]),hn=u.useMemo(()=>{if(!ut)return[];const c=lt.filter(L=>!ct(L)&&pn.has(L.id)),M=new Set;return Kt(c,p,h).flatMap(L=>{const K=pn.get(L.id);if(!K)return[];const oe=Ze.runKeyBySessionId.get(L.id),pe=oe?Ze.runs.get(oe):void 0;return pe?M.has(pe.key)?[]:(M.add(pe.key),[{kind:"run",run:pe,laneNodes:At.get(pe.key)??wi,project:K.project}]):[{kind:"session",session:L,project:K.project,branch:K.branch}]})},[p,Ze,At,lt,h,ut,pn]),Zo=u.useCallback(()=>{We(c=>Vd(c,hn.length))},[hn.length]),ea={currentSessionId:w,revealedSessionId:ye,confirmingDeleteSessionId:J,renamingSessionId:Se,onSelect:mn,onRevealedChange:wr,onArchive:c=>{kr(c)},onRequestDelete:de,onConfirmDelete:c=>{Rr(c)},onRequestRename:Er,onSubmitRename:(c,M)=>{Ir(c,M)},onCancelRename:()=>Ee(null),onToggleWork:Ft?(c,M)=>{Sr(c,M)}:void 0,isPinned:Nr,onTogglePin:Cr},ta=X&&Bs.length===0&&Ls.length===0,sa=!X&&!ut&&we.length>1&&_==="manual",Mr=!$e&&!X&&we.length>0?t.jsx(je,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.displayMode.label"),title:r("sessions.sidebar.header.displayMode.label"),onClick:()=>kt(!0),style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"equalizer-2",className:"size-4"})}):null,zr=sa?t.jsx(je,{type:"button",variant:"chip",size:"sm","aria-label":r($e?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":$e,onClick:()=>rt(c=>!c),style:{touchAction:"manipulation"},children:$e?t.jsx(oo,{className:"size-4"}):t.jsx(_n,{className:"size-4"})}):null,Or=!$e&&we.length>0?t.jsxs(je,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:Ar,style:{touchAction:"manipulation"},children:[t.jsx(Vc,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,Br=$e?null:t.jsx(je,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.addProject"),title:r("sessions.sidebar.header.actions.addProject"),onClick:()=>Ke(!0),style:{touchAction:"manipulation"},children:t.jsx(ei,{className:"size-4"})}),$s=Or||Br||Mr||zr?t.jsxs(t.Fragment,{children:[Br,Mr,zr,Or]}):null,Lr=t.jsxs("div",{ref:Ce,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs(sn,{ref:it,className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:Z("px-4 pb-2 pt-1",$e&&"hidden"),children:t.jsx(ac,{value:ae,onSearch:H,active:n||s==="sidebar",mobile:!0,placeholder:r("mobile.sessions.search.placeholder"),clearLabel:r("mobile.sessions.clearSearchAria")})}),we.length===0&&Pe.length===0?t.jsx(Ni,{title:r("mobile.sessions.empty.noProjectsTitle"),description:r("mobile.sessions.empty.noProjectsDescription"),action:t.jsxs("button",{type:"button",className:"flex items-center justify-center gap-2 rounded-2xl bg-primary px-5 py-3 typography-ui-label text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>Ke(!0),children:[t.jsx(ei,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):ta?t.jsx(Ni,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):X&&!$e?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[Bs.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.search.section.sessions")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:Bs.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Bs.map((c,M)=>t.jsx("div",{className:Z(M>0&&"border-t border-border/70"),children:t.jsx(vi,{session:c,active:w===c.id,indent:12,contextLabel:Tr(c),onSelect:()=>mn(c)})},c.id))})]}):null,Ls.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.search.section.projects")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:Ls.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Ls.map((c,M)=>t.jsxs("div",{className:Z("flex items-center",M>0&&"border-t border-border/70"),children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-3 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>Xo(c),style:{touchAction:"manipulation"},children:[t.jsx(As,{project:c}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:c.label})]}),c.isGitRepo?t.jsx(yi,{onClick:()=>Pr(c.id)}):null,t.jsx(An,{className:"mr-2",label:r("mobile.sessions.newSessionInProjectAria",{label:c.label}),onClick:()=>Dr(c)})]},c.id))})]}):null]}):$e?t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2",children:[t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:r("mobile.sessions.editOrderHint")}),t.jsx(nr,{sensors:Ko,collisionDetection:rr,onDragEnd:Jo,children:t.jsx(or,{items:we.map(c=>c.id),strategy:ar,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:we.map(c=>{const M=Ge.find(L=>L.project.id===c.id);return t.jsx(ff,{project:c,totalSessions:M?.totalSessions??0,expanded:ln.has(c.id),onToggleExpanded:()=>Yo(c.id),onReorderWorktrees:L=>O(c.id,L)},c.id)})})})})]}):t.jsxs("div",{className:"flex flex-col",children:[(()=>{const c=te[gs]??!0,M=r("mobile.sessions.section.chats");return t.jsxs("section",{children:[t.jsxs("div",{className:"flex min-h-12 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ve){Dt(ve,!1);return}Os(gs,c)},"aria-expanded":c,"aria-label":c?r("sessions.sidebar.group.collapseAria",{label:M}):r("sessions.sidebar.group.expandAria",{label:M}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:t.jsx(Q,{name:"chat-4",className:"size-4"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:M}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:U})]}),$e?null:t.jsx(An,{className:"mr-2",label:r("mobile.sessions.newChat"),onClick:Ar})]}),c?t.jsx("div",{className:"pb-2",children:Pt.sessions.length>0?ps(T,Pt,ut?nf:Gt,ut?{pageSize:sf,alwaysVisibleIds:un,statusOnRight:!0}:void 0):t.jsx("p",{className:"px-3 pb-1 typography-micro text-muted-foreground",style:{paddingLeft:Gt},children:r("sessions.sidebar.activity.chatsEmpty")})}):null]})})(),ds.sessions.length>0?(()=>{const c=te[ys]??!0,M=r("sessions.sidebar.work.title");return t.jsxs("section",{children:[t.jsxs("button",{type:"button",className:"flex min-h-12 w-full min-w-0 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ve){Dt(ve,!1);return}Os(ys,c)},"aria-expanded":c,"aria-label":c?r("sessions.sidebar.group.collapseAria",{label:M}):r("sessions.sidebar.group.expandAria",{label:M}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:t.jsx(Q,{name:"eye",className:"size-4"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:M}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:ds.sessions.filter(L=>!ct(L)).length})]}),c?t.jsx("div",{className:"pb-2",children:ps(`${ys}::${ys}`,ds,Gt,{pageSize:Number.MAX_SAFE_INTEGER})}):null]})})():null,!ut&&ms.sessions.length>0?(()=>{const c=te[vs]??!0,M=r("mobile.sessions.section.recent");return t.jsxs("section",{children:[t.jsxs("button",{type:"button",className:"flex min-h-12 w-full min-w-0 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ve){Dt(ve,!1);return}Os(vs,c)},"aria-expanded":c,"aria-label":c?r("sessions.sidebar.group.collapseAria",{label:M}):r("sessions.sidebar.group.expandAria",{label:M}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:t.jsx(Q,{name:"history",className:"size-4"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:M}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:vt.length})]}),c?t.jsx("div",{className:"pb-2",children:ps(`${vs}::${vs}`,ms,Gt,{rootContextLabel:L=>dn.get(L.id)??Tr(L)})}):null]})})():null,ut?t.jsx(Fd,{entries:hn,visibleCount:Et,onRevealMore:Zo,scrollRootRef:it,handlers:ea}):null,ut?null:Qo.map(c=>{const M=fn(c),L=X?c.buckets.filter(oe=>oe.sessions.some(pe=>In(pe,c.project.label,X))):c.buckets,K=Vt(c);return t.jsxs("section",{className:"border-t border-border/70",children:[t.jsx(tn,{actionsWidth:96,revealed:ve===`project:${c.project.id}`,onRevealedChange:oe=>Dt(`project:${c.project.id}`,oe),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:ve===`project:${c.project.id}`?0:-1,className:Z("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",nt===c.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":nt===c.project.id?r("mobile.sessions.confirmRemoveProjectAria",{label:c.project.label}):r("mobile.sessions.removeProjectAria",{label:c.project.label}),onClick:()=>{if(nt===c.project.id){Ae(null),Fe(null),W(c.project.id),xe.success(r("mobile.sessions.toast.projectRemoved",{label:c.project.label}));return}Fe(c.project.id)},style:{touchAction:"manipulation"},children:t.jsx(Js,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:ve===`project:${c.project.id}`?0:-1,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":r("mobile.sessions.editProjectAria",{label:c.project.label}),onClick:()=>{Ae(null),ue(c.project.id)},style:{touchAction:"manipulation"},children:t.jsx(_n,{className:"size-[18px]"})})]}),children:t.jsxs("div",{"data-active-project":c.isActive||void 0,className:"flex min-h-12 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ve){Dt(ve,!1);return}Os(c.project.id,M)},"aria-expanded":M,"aria-label":M?r("sessions.sidebar.group.collapseAria",{label:c.project.label}):r("sessions.sidebar.group.expandAria",{label:c.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(As,{project:c.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:c.project.label})]}),c.project.isGitRepo?t.jsx(yi,{onClick:()=>Pr(c.project.id)}):null,t.jsx(An,{className:"mr-2",label:r("mobile.sessions.newSessionInProjectAria",{label:c.project.label}),onClick:()=>Dr(c.project)})]})}),M?t.jsx("div",{className:"pb-2",children:(()=>{const oe=L.find(fe=>fe.worktree===null&&fe.space===null),pe=L.filter(fe=>fe!==oe);return t.jsxs(t.Fragment,{children:[oe&&oe.sessions.length>0?ps(`${c.project.id}::${oe.key}`,oe,Gt):null,pe.map(fe=>{const Oe=Lo(c,fe),He=K===fe.path;return t.jsxs("div",{children:[t.jsx(tn,{actionsWidth:48,revealed:ve===`wt:${fe.key}`,onRevealedChange:St=>Dt(`wt:${fe.key}`,St),actions:fe.space?t.jsx("button",{type:"button",tabIndex:ve===`wt:${fe.key}`?0:-1,className:"flex flex-1 items-center justify-center text-foreground transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":r("spaces.group.access.giveAria",{label:fe.label}),onClick:()=>{Ae(null),fe.space&&ha.getState().openAccessDialog(fe.space.id)},style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"key",className:"size-[18px]"})}):fe.worktree?t.jsx("button",{type:"button",tabIndex:ve===`wt:${fe.key}`?0:-1,className:"flex flex-1 items-center justify-center text-[var(--status-error)] transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive","aria-label":r("mobile.projectEdit.deleteWorktreeAria",{label:fe.label}),onClick:()=>{Ae(null),fe.worktree&&Ie({project:c.project,worktree:fe.worktree})},style:{touchAction:"manipulation"},children:t.jsx(Js,{className:"size-[18px]"})}):null,children:t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-2 px-3 py-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ve){Dt(ve,!1);return}Wo(c.project.id,fe.key,Oe)},"aria-expanded":Oe,"aria-label":Oe?r("sessions.sidebar.group.collapseAria",{label:fe.label}):r("sessions.sidebar.group.expandAria",{label:fe.label}),style:{touchAction:"manipulation"},children:[t.jsx(Q,{name:fe.space?"box-3":"git-branch",className:Z("size-4 shrink-0",He?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Z("block min-w-0 flex-1 truncate typography-ui-label font-bold",He?"text-foreground":"text-muted-foreground"),children:fe.label}),He?t.jsx(af,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:fe.sessions.length})]})}),fe.space?t.jsx(lc,{spaceId:fe.space.id,className:"px-3 pb-1 pl-9"}):null,Oe?ps(`${c.project.id}::${fe.key}`,fe,Gt):null]},fe.key)})]})})()}):null]},c.project.id)})]})]}),i?t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/70 px-2 pt-1.5",style:{paddingBottom:"calc(0.375rem + var(--oc-safe-area-bottom, 0px))"},children:[i.instanceLabel&&i.onOpenInstances?t.jsxs(je,{type:"button",variant:"info",size:"lg",className:"min-w-0 shrink justify-start",onClick:i.onOpenInstances,"aria-label":r("mobile.menu.instances"),style:{touchAction:"manipulation"},children:[t.jsx(Q,{name:"server",className:"size-[18px]"}),t.jsx("span",{className:"block min-w-0 truncate",children:i.instanceLabel})]}):t.jsx("div",{className:"min-w-0 flex-1"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[i.onOpenUpdate?t.jsxs(je,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenUpdate,"aria-label":r("mobile.menu.update"),title:r("mobile.menu.update"),style:{touchAction:"manipulation"},children:[t.jsx(Q,{name:"download",className:"size-5"}),t.jsx("span",{className:"absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary","aria-hidden":!0})]}):null,t.jsx(je,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenUsage,"aria-label":r("usageStats.openAction"),title:r("usageStats.openAction"),style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"bar-chart",className:"size-5"})}),t.jsx(je,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenSettings,"aria-label":r("mobile.menu.settings"),title:r("mobile.menu.settings"),style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"settings-3",className:"size-5"})})]})]}):null,t.jsx(cc,{open:an,onOpenChange:Ke}),t.jsx(uc,{open:Qe,onOpenChange:c=>{ht(c),c||bt(null)},onWorktreeCreated:(c,M)=>{M?.sessionId?C(M.sessionId,c):k({selectedProjectId:gt,directoryOverride:c,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(Hd,{open:re!==null,project:we.find(c=>c.id===re)??null,onClose:()=>ue(null),onWorktreesChanged:()=>Xe(c=>c+1)}),t.jsx(Ui,{open:Rt,onClose:()=>kt(!1),title:r("sessions.sidebar.header.displayMode.label"),children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"px-3 pb-1 pt-1 typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.viewMode.label")}),ef.map(([c,M])=>t.jsxs("button",{type:"button",className:Z("flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",j===c?"text-primary":"text-foreground"),onClick:()=>{Ho(c),kt(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r(M)}),j===c?t.jsx(Q,{name:"check",className:"size-4"}):null]},c)),j==="timeline"?null:t.jsx("span",{className:"px-3 pb-1 pt-3 typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("sessions.sidebar.header.actions.sortProjects")}),j==="timeline"?null:Zd.map(([c,M])=>t.jsxs("button",{type:"button",className:Z("flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",_===c?"text-primary":"text-foreground"),onClick:()=>{Go(c),kt(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r(M)}),_===c?t.jsx(Q,{name:"check",className:"size-4"}):null]},c)),j==="timeline"?null:t.jsxs("button",{type:"button","aria-pressed":F,className:Z("mt-2 flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",F?"text-primary":"text-foreground"),onClick:()=>{qo(),kt(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r("sessions.sidebar.header.displayMode.showRecent")}),F?t.jsx(Q,{name:"check",className:"size-4"}):null]})]})}),Le?t.jsx(Ao,{open:!0,project:{id:Le.project.id,path:Le.project.path},worktree:Le.worktree,onClose:()=>Ie(null),onDeleted:()=>Xe(c=>c+1)}):null]});return s==="sidebar"?n?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center justify-between gap-2 border-b border-border/70 px-4",children:[t.jsx("h2",{className:"truncate typography-ui-label font-semibold text-foreground",children:r("mobile.sessions.sheet.title")}),$s?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:$s}):null]}),Lr]}):null:t.jsxs(hf,{open:n,onClose:()=>e(!1),onSwipeClose:()=>{if(ye||ve){he(null),Ae(null),de(null),Fe(null);return}e(!1)},ariaLabel:r("mobile.sessions.sheet.title"),children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":r("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"close",className:"size-5"})}),t.jsx("h2",{className:"min-w-0 flex-1 truncate px-1 typography-ui-label font-semibold text-foreground",children:r("mobile.sessions.sheet.title")}),$s?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:$s}):null]}),Lr]})},ki="mobile-surface-root",mf=16,Si=320,pf="cubic-bezier(0.22, 1, 0.36, 1)",hf=({open:n,onClose:e,onSwipeClose:s,ariaLabel:i,children:r})=>{const o=u.useRef(null),a=u.useRef(null),[d,m]=u.useState(!1),[f,l]=u.useState(n),p=u.useRef(e);u.useEffect(()=>{p.current=e},[e]);const g=u.useRef(s);if(u.useEffect(()=>{g.current=s},[s]),xr(a,{enabled:n,onRightEdgeSwipe:()=>(g.current??p.current)()}),typeof document<"u"&&!o.current){let h=document.getElementById(ki);h||(h=document.createElement("div"),h.id=ki,document.body.appendChild(h)),o.current=h}return u.useEffect(()=>{if(n){l(!0);const b=window.setTimeout(()=>m(!0),mf);return()=>window.clearTimeout(b)}m(!1);const h=window.setTimeout(()=>l(!1),Si+40);return()=>window.clearTimeout(h)},[n]),u.useEffect(()=>{if(!n)return;const h=document.body.style.overflow;document.body.style.overflow="hidden";const b=S=>{S.key==="Escape"&&p.current()};return document.addEventListener("keydown",b),()=>{document.body.style.overflow=h,document.removeEventListener("keydown",b)}},[n]),o.current?ss.createPortal(t.jsx("section",{ref:a,role:"dialog","aria-modal":"true","aria-label":i,"aria-hidden":!n,className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:d?"none":"translateX(-100%)",transition:`transform ${Si}ms ${pf}`,visibility:f?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r})}),o.current):null},Ni=n=>{const e=me.c(10),{title:s,description:i,action:r}=n;let o;e[0]!==s?(o=t.jsx("p",{className:"typography-ui-label text-foreground",children:s}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==i?(a=i?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}):null,e[2]=i,e[3]=a):a=e[3];let d;e[4]!==r?(d=r?t.jsx("div",{className:"pt-2",children:r}):null,e[4]=r,e[5]=d):d=e[5];let m;return e[6]!==o||e[7]!==a||e[8]!==d?(m=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[o,a,d]}),e[6]=o,e[7]=a,e[8]=d,e[9]=m):m=e[9],m};function gf(n){return Te(n.path)}function bf(n){return Te(n.path)}function xf(n){return t.jsx(df,{worktree:n},Te(n.path))}const yf=(n,e)=>{if(!n)return e("mcpDropdown.status.unknown");const s=n.status;switch(s.status){case"connected":return e("mcpDropdown.status.connected");case"failed":return e("mcpDropdown.status.failed",{error:s.error||e("mcpDropdown.status.unknownError")});case"needs_auth":return e("mcpDropdown.status.needsAuth");default:return s.status}},vf=n=>{switch(n?.status.status){case"connected":return"success";case"failed":return"error";case"needs_auth":return"warning";default:return"default"}},wf=({active:n,className:e,headerAction:s,listClassName:i,hideHeader:r=!1,mobileListDensity:o=!1})=>{const{t:a}=be(),m=Nt(y=>y.currentDirectory)??null,f=ws(y=>y.getStatusForDirectory(m)),l=ws(y=>y.refresh),p=ws(y=>y.connect),g=ws(y=>y.disconnect),h=es(y=>y.mcpServers),b=es(y=>y.loadMcpConfigs),[S,v]=u.useState(!1),[I,w]=u.useState(null);u.useEffect(()=>{l({directory:m,silent:!0})},[l,m]),u.useEffect(()=>{b({force:!0})},[b]),u.useEffect(()=>{n&&Promise.all([l({directory:m,silent:!0}),b({force:!0})])},[n,l,m,b]);const C=u.useMemo(()=>{const y=new Set(Object.keys(f));for(const E of h)E?.name&&y.add(E.name);return Array.from(y).sort((E,N)=>E.localeCompare(N))},[h,f]),A=u.useCallback(y=>{if(y?.preventDefault(),S)return;v(!0);const E=new Promise(N=>setTimeout(N,500));Promise.all([l({directory:m}),E]).finally(()=>{v(!1)})},[S,l,m]);return t.jsxs("div",{className:Z("w-full",e),children:[r?null:t.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex items-baseline gap-2",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("mcpDropdown.title")}),m&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:m.split("/").pop()||m})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",disabled:S,onClick:A,"aria-label":a("mcpDropdown.actions.refreshAria"),children:t.jsx(Q,{name:"refresh",className:Z("h-4 w-4",S&&"animate-spin")})})]})]})}),t.jsx("div",{className:Z("max-h-64 overflow-y-auto",o?"space-y-1 py-3":"px-3 py-2.5",i),children:t.jsxs("div",{className:Z(!o&&C.length>0&&"rounded-xl bg-[var(--surface-muted)] p-1.5"),children:[C.map(y=>{const E=f[y],N=vf(E),R=E?.status.status==="connected",k=I===y,P=yf(E,a);return t.jsxs("div",{className:Z("flex items-center justify-between rounded-lg hover:bg-interactive-hover/50",o?"gap-3 px-4 py-3":"gap-2 px-2.5 py-2"),children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs(qa,{children:[t.jsx(Ja,{asChild:!0,children:t.jsx("span",{className:Z("rounded-full flex-shrink-0",o?"h-2.5 w-2.5":"h-2 w-2",N==="success"&&"bg-status-success",N==="error"&&"bg-status-error",N==="warning"&&"bg-status-warning",N==="default"&&"bg-muted-foreground/40"),"aria-label":P})}),t.jsx(Ya,{side:"left",children:t.jsx("p",{children:P})})]}),t.jsx("span",{className:Z("truncate",o?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:y})]})}),t.jsx(Xa,{checked:R,disabled:k,className:"data-[checked]:bg-status-info",onCheckedChange:async B=>{w(y);try{B?await p(y,m):await g(y,m)}catch(D){Mn.error(D instanceof Error?D.message:a("mcpDropdown.status.unknownError"))}finally{w(null)}}})]},y)}),C.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:a("mcpDropdown.empty.configureInConfig")})]})})]})},Ci={status:"loading"},Ht={type:"list"},jf=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),kf=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},Sf=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},Ri=(n,e)=>e?`${n}\0staged`:n,Nf=n=>{const e=me.c(8),s=Jn()??null;let i;e[0]!==s?(i=jf(s),e[0]=s,e[1]=i):i=e[1];const r=i,o=n.visible??!0;let a;e[2]!==o?(a={enabled:o},e[2]=o,e[3]=a):a=e[3];const d=Qa(r||null,a);let m;return e[4]!==n||e[5]!==d||e[6]!==r?(m=t.jsx(Cf,{...n,rootDirectory:r,repository:d}),e[4]=n,e[5]=d,e[6]=r,e[7]=m):m=e[7],m},Cf=({rootDirectory:n,repository:e,onClose:s,initialDiff:i,visible:r=!0})=>{const{t:o}=be(),{git:a}=qn(),{rootIsGitRepo:d,gitDirectory:m,nestedRepos:f}=e,l=m??n,p=Za(l||null),g=el(l||null),h=Wi(l||null),b=tl(l||null),S=Je(T=>T.setActiveDirectory),v=Je(T=>T.ensureAll),I=Je(T=>T.ensureNestedRepos),w=Je(T=>T.selectNestedRepo),C=Je(T=>T.fetchStatus),A=Je(T=>T.fetchBranches),y=Je(T=>T.prefetchDiffs),E=Je(T=>T.getDiff),N=Je(T=>T.setDiff),R=Je(T=>T.runtimeKey),k=JSON.stringify([R,l]),P=u.useRef(k);P.current=k;const[B,D]=u.useState(()=>({ownerKey:k,mode:"working",route:i?.path?{type:"diff",path:i.path,staged:i.staged}:Ht})),x=B.ownerKey===k?B.mode:"working",_=B.ownerKey===k?B.route:Ht,[V,j]=u.useState(!1),$=u.useCallback(T=>{D({ownerKey:k,mode:T,route:Ht}),j(!1)},[k]),F=u.useCallback(T=>{D(U=>({ownerKey:k,mode:U.ownerKey===k?U.mode:"working",route:T}))},[k]);u.useEffect(()=>{D(T=>T.ownerKey===k?T:{ownerKey:k,mode:"working",route:Ht}),j(!1)},[k]),u.useEffect(()=>{r||j(!1)},[r]),u.useEffect(()=>{i?.path&&D({ownerKey:P.current,mode:"working",route:{type:"diff",path:i.path,staged:i.staged}})},[i]);const[z,G]=u.useState(null),[q,Y]=u.useState(null),[W,te]=u.useState(""),[ce,le]=u.useState(new Set),[se,ie]=u.useState(!1),[O,ee]=u.useState(!1),[ne,ae]=u.useState([]),[H,re]=u.useState([]),[ue,ye]=u.useState([]),[he,J]=u.useState(null),[de,Se]=u.useState(null),[Ee,ve]=u.useState(null),[Ae,nt]=u.useState(0),[Fe,Le]=u.useState(null),Ie=p?.current??null,Ue=p?.tracking?.trim().split("/")[0],Xe=(Ue&&g?.defaultBranches?.[Ue])??g?.defaultBranches?.origin??null,Rt=mu(Ie,Xe),kt=h===!1||du(Ie,Xe,p!==null,g!==null),an=tu(T=>T.setOverride),Ke=su(l||null,Ie,r&&x==="branch"&&Rt),Qe=nu(l||null,Ie,r&&x==="commit"&&h===!0),ht=Qe.selectedCommit?.hash??null,gt=ru(l||null,Ie,r&&x==="pr"&&h===!0),bt=gt.selectedSource,Ts=u.useMemo(()=>x==="pr"?bt:x==="branch"&&Ie&&Ke.base?{kind:"branch",baseRef:Ke.base,headRef:Ie}:x==="commit"&&ht?{kind:"commit",hash:ht}:null,[Ke.base,Ie,x,ht,bt]),Ds=x==="branch"?Ke.revision:"",Ne=cu(l||null,Ts,r&&h===!0,Ds),{fetchDiff:_s}=Ne,$e=u.useMemo(()=>Ne.files?[...Ne.files].sort((T,U)=>T.path.localeCompare(U.path)):null,[Ne.files]),rt=_.type==="comparison"&&_.sourceKey===Ne.key?_.path:null,[ln,us]=u.useState(0),cn=u.useCallback(async T=>{try{const{diff:U}=await _s(T),X={original:"",modified:"",isBinary:iu(U)};return X.isBinary||(X.fileDiff=ou(T,U)),{status:"ready",diff:X}}catch(U){return{status:"error",message:U instanceof Error?U.message:o("diffView.state.failedToLoadDiff")}}},[_s,o]),$t=uu(Ne.files?x==="pr"?JSON.stringify([Ne.key,Ne.revision]):Ne.key:null,r&&rt?rt:"",r?cn:null,Ci,JSON.stringify([Ds,x==="pr"?Ne.revision:0,ln])),Et=rt?$t.get(rt)??Ci:null;u.useEffect(()=>{x==="branch"&&kt&&$("working")},[kt,$,x]),u.useEffect(()=>{D(T=>T.ownerKey===k&&T.route.type==="comparison"&&T.route.sourceKey!==Ne.key?{...T,route:Ht}:T)},[Ne.key,k]);const We=u.useMemo(()=>{const T=p?.files??[],U=new Map;for(const X of T)U.set(X.path,X);return Array.from(U.values()).sort((X,Ce)=>X.path.localeCompare(Ce.path))},[p?.files]),it=u.useMemo(()=>We.filter(kf),[We]),we=u.useMemo(()=>We.filter(Sf),[We]),De=u.useMemo(()=>{if(ue.length>0)return ue;const T=p?.tracking?.includes("/")?p.tracking.split("/")[0]:null;return T||he?[{name:T||"origin",fetchUrl:he??"",pushUrl:he??""}]:[]},[he,ue,p?.tracking]),xt=Je(u.useCallback(T=>!l||_.type!=="diff"?null:T.directories.get(l)?.diffCache.get(Ri(_.path,_.staged))??null,[l,_])),ot=u.useMemo(()=>_.type!=="diff"?null:We.find(T=>T.path===_.path)??null,[We,_]),Pe=u.useCallback(async(T=!0)=>{if(l)try{await Promise.all([C(l,a),A(l,a)])}catch(U){T&&xe.error(U instanceof Error?U.message:o("gitView.toast.refreshRepositoryFailed"))}},[l,A,C,a,o]),Ft=u.useMemo(()=>(g?.all??[]).filter(T=>!T.startsWith("remotes/")).sort(),[g]),at=u.useMemo(()=>(g?.all??[]).filter(T=>T.startsWith("remotes/")).map(T=>T.replace(/^remotes\//,"")).sort(),[g]),lt=u.useCallback(async T=>{if(!l)return;const U=T.replace(/^remotes\//,"");try{const X=await a.checkoutBranch(l,U);xe.success(o("gitView.toast.checkedOut",{name:X.branch||U})),await Pe()}catch(X){xe.error(X instanceof Error?X.message:o("gitView.toast.checkoutFailed",{name:U}))}},[l,a,Pe,o]),Wt=u.useCallback(T=>{const U=T.replace(/^remotes\//,"");if((p?.files?.length??0)>0){Le(U);return}lt(U)},[lt,p?.files]),mt=u.useCallback(async(T,U)=>{if(l)try{await a.createBranch(l,T,Ie??"HEAD"),await a.checkoutBranch(l,T),U&&await a.gitPush(l,{remote:U.name,branch:T,options:["--set-upstream"]}),await Pe()}catch(X){throw xe.error(X instanceof Error?X.message:o("gitView.toast.createBranchFailed")),X}},[Ie,l,a,Pe,o]),yt=u.useCallback(async()=>{if(!l){ye([]),J(null);return}try{const[T,U]=await Promise.all([a.getRemotes(l).catch(()=>[]),a.getRemoteUrl?a.getRemoteUrl(l).catch(()=>null):Promise.resolve(null)]);ye(T),J(U)}catch{ye([]),J(null)}},[l,a]);u.useEffect(()=>{!l||!r||(S(l),v(l,a))},[l,v,a,S,r]),u.useEffect(()=>{r&&yt()},[yt,r]),u.useEffect(()=>{if(!r||x!=="working"||!l||We.length===0)return;const T=Array.from(new Set([...it.map(X=>X.path),...H,...We.slice(0,20).map(X=>X.path)])).filter(Boolean);if(T.length===0)return;const U=window.setTimeout(()=>{y(l,a,T,{maxFiles:40})},120);return()=>window.clearTimeout(U)},[We,l,a,x,y,it,H,r]),u.useEffect(()=>{if(!r)return;if(_.type!=="diff"){Se(null);return}const T=Ri(_.path,_.staged);if(ve(null),!l||E(l,T)){Se(null);return}let U=!1;const X=ls();return Se(null),a.getGitFileDiff(l,{path:_.path,staged:_.staged||void 0}).then(Ce=>{U||N(l,T,{original:Ce.original??"",modified:Ce.modified??"",isBinary:Ce.isBinary,submodule:Ce.submodule},X)}).catch(Ce=>{if(!U){if(Ce instanceof Kr&&Ce.reason!=="path_not_found"){ve({key:`${l}\0${_.path}`,reason:Ce.reason});return}Ce instanceof Kr&&C(l,a,{force:!0,silent:!0}),Se(Ce instanceof Error?Ce.message:String(Ce))}}),()=>{U=!0}},[l,Ae,C,E,a,_,N,r]);const It=async(T,U)=>{if(l){G(T);try{if(T==="fetch"){if(!U)throw new Error(o("mobile.changes.noRemote"));await a.gitFetch(l,{remote:U.name}),xe.success(o("gitView.toast.fetchedFromRemote",{name:U.name}))}else if(T==="sync"){if(!U)throw new Error(o("mobile.changes.noRemote"));let X=0;const Ce=await si({git:a,directory:l,remote:U,dirtyWorktreeError:o("gitView.toast.commitOrStashBeforeSync"),onPulled:Ge=>{X=Ge.files.length}});X>0&&xe.success(X===1?o("gitView.toast.pulledFilesSingle",{count:X,name:U.name}):o("gitView.toast.pulledFilesPlural",{count:X,name:U.name})),Ce.pushed.length>0?xe.success(o("gitView.toast.pushedToUpstream",{name:Ce.pushed[0].remote})):X===0&&xe.success(o("gitView.toast.alreadyUpToDate"))}await Pe(!1),await yt()}catch(X){xe.error(X instanceof Error?X.message:o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}))}finally{G(null)}}},_e=u.useCallback(async(T,U)=>{if(!(!l||T.length===0))try{U==="stage"?T.length>1?await sl(l,T):await nl(l,T[0]):T.length>1?await rl(l,T):await il(l,T[0]),await Pe(!1)}catch(X){xe.error(X instanceof Error?X.message:o(U==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[l,Pe,o]),Ze=u.useCallback((T,U=!1)=>{F({type:"diff",path:T,staged:U})},[F]),At=u.useCallback(async T=>{if(l){le(U=>new Set(U).add(T));try{await a.revertGitFile(l,T),xe.success(o("gitView.toast.revertedFile",{path:T})),await Pe(!1)}catch(U){xe.error(U instanceof Error?U.message:o("gitView.toast.revertFailed"))}finally{le(U=>{const X=new Set(U);return X.delete(T),X})}}},[l,a,Pe,o]),Pt=u.useCallback(async T=>{if(!l||T.length===0||se)return;const U=Array.from(new Set(T));ie(!0),le(new Set(U));try{await Promise.all(U.map(X=>a.revertGitFile(l,X))),await Pe(!1),xe.success(U.length===1?o("gitView.toast.revertedFilesSingle",{count:U.length}):o("gitView.toast.revertedFilesPlural",{count:U.length}))}catch(X){xe.error(X instanceof Error?X.message:o("gitView.toast.revertFailed"))}finally{le(new Set),ie(!1)}},[l,a,se,Pe,o]),un=u.useCallback(T=>{const U=T.map(X=>X.trim()).filter(Boolean);if(U.length===0){ae([]);return}te(X=>`${X.trim()}${X.trim()?`
23
23
 
24
24
  `:""}${U.join(`
25
- `)}`.trim()),ae([])},[]),ds=u.useCallback(async()=>{if(!l)return;const T=it.map(U=>U.path).sort();if(T.length===0){xe.error(o("gitView.toast.selectFileToDescribe"));return}ee(!0);try{const{message:U}=await Qr(l,T);te(U.subject?.trim()??""),ae(Array.isArray(U.highlights)?U.highlights:[])}catch(U){xe.error(U instanceof Error?U.message:o("gitView.toast.generateCommitMessageFailed"))}finally{ee(!1)}},[l,it,o]),Tt=async(T={})=>{if(!l)return;if(!W.trim()){xe.error(o("gitView.toast.enterCommitMessage"));return}const U=it.map(X=>X.path).sort();if(U.length===0){xe.error(o("gitView.toast.selectFileToCommit"));return}Y(T.pushAfter?"commitAndPush":"commit");try{if(await a.createGitCommit(l,W.trim(),{files:U}),xe.success(o("gitView.toast.commitCreated")),te(""),ae([]),T.pushAfter){const X=p?.tracking?.split("/")[0],Ce=De.find(Ge=>Ge.name===X)??De[0];if(!Ce)throw new Error(o("mobile.changes.noRemote"));G("sync"),await si({git:a,directory:l,remote:Ce,dirtyWorktreeError:o("gitView.toast.commitOrStashBeforeSync"),onPushed:Ge=>{xe.success(o("gitView.toast.pushedToUpstream",{name:Ge.pushed[0].remote}))}}),await Pe(!1),await yt()}else await Pe(!1)}catch(X){xe.error(X instanceof Error?X.message:o("gitView.toast.createCommitFailed"))}finally{Y(null),T.pushAfter&&G(null)}},Ms=u.useMemo(()=>{const T=[];return it.length>0&&T.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:it,statsScope:"staged",actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:U=>o("gitView.changes.unstageFileAria",{path:U}),onActionFile:U=>{_e([U],"unstage")},onActionAll:U=>{_e(U,"unstage")},onViewDiff:U=>Ze(U,!0),onRevertFile:At,showRevertActions:!1,accent:!0}),we.length>0&&T.push({id:"unstaged",title:o("gitView.changes.title"),entries:we,statsScope:"working",actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:U=>o("gitView.changes.stageFileAria",{path:U}),onActionFile:U=>{_e([U],"stage")},onActionAll:U=>{_e(U,"stage")},onViewDiff:U=>Ze(U,!1),onRevertFile:At}),T},[At,Ze,_e,it,o,we]),fs=T=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:o("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:p?.current||l||""})]}),d===!1&&Array.isArray(f)&&f.length>0?t.jsx(gc,{repositories:f,selectedRepository:m??null,onSelectRepository:U=>{n&&w(n,U)},repositoryRoot:n??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:T})]});if(!l)return fs(t.jsx(st,{message:o("gitView.empty.selectSessionOrDirectory")}));if(d===!1&&h!==!0)return fs(t.jsx(bc,{rootIsGitRepo:d,resolvedIsGitRepo:h,nestedRepos:f,onRetryDiscovery:()=>{n&&I(n,{force:!0})}}));if(b&&h===null)return fs(t.jsx(st,{loading:!0,message:o("gitView.loading.checkingRepository")}));if(_.type==="diff")return t.jsx(Ei,{path:_.path,diff:xt,staged:_.staged,fileExists:!!ot,unavailableReason:Ee?.key===`${l}\0${_.path}`?Ee.reason:null,error:de,onBack:()=>F({type:"list"}),onRetry:()=>nt(T=>T+1)});const vt=o(x==="pr"?"session.githubIntegration.tabs.pullRequests":x==="branch"?"diffView.scope.branch":x==="commit"?"commitComparison.mode":"mobile.nav.changes"),ms=x==="branch"&&Ke.base?mc(Ke.base):x==="commit"?ht?.slice(0,8):x==="pr"&&bt?`#${bt.number}`:null;if(rt&&Et)return t.jsx(Ei,{path:rt,subtitle:[vt,ms].filter(Boolean).join(" · "),diff:Et.status==="ready"?Et.diff:null,fileExists:!Ne.files||Ne.files.some(T=>T.path===rt),error:Ne.error??(Et.status==="error"?Et.message:null),onBack:()=>F(Ht),onRetry:()=>{Ne.error&&Ne.refresh(),us(T=>T+1)}});const dn=()=>x==="pr"&&!bt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(st,{loading:gt.loading,message:gt.error??(gt.loading?o("session.githubPrPicker.loading.pullRequests"):o("pullRequestComparison.select"))}),!gt.loading&&t.jsx(ni,{mobile:!0,comparison:gt})]}):x==="branch"&&!Ke.base?t.jsx(st,{loading:!Ke.resolved,message:Ke.resolved?o("gitView.pr.toast.baseBranchRequired"):o("diffView.branch.resolvingBase")}):x==="commit"&&!ht?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[Qe.loading&&t.jsx(Q,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:Qe.loading?o("diffView.state.loadingChanges"):Qe.error??o("commitComparison.noCommits")}),Qe.error&&t.jsx(je,{variant:"outline",size:"lg",onClick:()=>{Qe.refresh()},children:o("diffView.actions.retry")})]}):Ne.error?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("p",{className:"typography-ui-label font-semibold",children:o("diffView.state.failedToLoadDiff")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:Ne.error}),t.jsx(je,{variant:"outline",size:"lg",onClick:()=>{Ne.refresh()},children:o("diffView.actions.retry")})]}):$e?$e.length===0?t.jsx(st,{icon:x==="branch",message:x==="pr"?o("walkthrough.blocked.emptyDiff.description"):x==="commit"?o("commitComparison.emptyDiff"):o("diffView.branch.empty",{base:ms??""})}):t.jsx(Rf,{files:$e,onSelect:T=>{Ne.key&&F({type:"comparison",path:T,sourceKey:Ne.key})}}):t.jsx(st,{loading:!0,message:o("diffView.state.loadingChanges")});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"close",className:"size-5"})}):null,t.jsxs(ol,{open:V,onOpenChange:j,children:[t.jsx(al,{asChild:!0,children:t.jsxs(je,{variant:"outline",className:ll({size:"default"}),"data-mobile-comparison-trigger":!0,"aria-label":o("diffView.scope.selectorAria"),children:[t.jsx("span",{children:vt}),t.jsx(Q,{name:"arrow-down-s",className:"size-4"})]})}),t.jsx(cl,{align:"start",children:t.jsxs(ul,{value:x,onValueChange:T=>{(T==="working"||T==="branch"||T==="commit"||T==="pr")&&$(T)},children:[t.jsx(Ws,{value:"working",className:"min-h-8 items-center",children:o("mobile.nav.changes")}),Rt&&t.jsx(Ws,{value:"branch",className:"min-h-8 items-center",children:o("diffView.scope.branch")}),t.jsx(Ws,{value:"commit",className:"min-h-8 items-center",children:o("commitComparison.mode")}),t.jsx(Ws,{value:"pr",className:"min-h-8 items-center",children:o("session.githubIntegration.tabs.pullRequests")})]})})]}),r&&x==="branch"&&t.jsx(au,{mobile:!0,branches:g?.all??[],currentBranch:Ie,base:Ke.base,onSelect:T=>{Ie&&an(l,Ie,T)}},JSON.stringify([k,Ie])),r&&x==="commit"&&t.jsx(lu,{mobile:!0,commits:Qe.commits,selectedHash:ht,loading:Qe.loading,error:Qe.error,onSelect:Qe.select,onRefresh:()=>{Qe.refresh()}},JSON.stringify([k,Ie])),r&&x==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(ni,{mobile:!0,comparison:gt},JSON.stringify([k,Ie])),bt&&t.jsx(je,{variant:"ghost",size:"sm",disabled:Ne.loading,"aria-label":o("session.githubIssuePicker.actions.refresh"),onClick:()=>{Ne.refresh()},children:t.jsx(Q,{name:"refresh",className:"size-4"})})]})]}),x==="working"&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(pc,{currentBranch:p?.current,localBranches:Ft,remoteBranches:at,branchInfo:g?.branches,currentBranchAhead:p?.ahead,onCheckout:T=>{Wt(T)},onCreate:mt,remotes:De,disabled:b,directory:l,switchBlockedNotice:(p?.files?.length??0)>0?o("gitView.branch.switchBlockedNotice"):null})}),t.jsx(hc,{syncAction:z,remotes:De,onFetch:T=>{It("fetch",T)},onSync:T=>{It("sync",T)},disabled:q!==null||b,aheadCount:p?.ahead??0,behindCount:p?.behind??0,trackingRemoteName:p?.tracking?.split("/")[0],hasUncommittedChanges:We.length>0})]}),x!=="working"?t.jsx("div",{className:"min-h-0 flex-1",children:dn()}):We.length>0?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-4 pt-4",children:t.jsx(Qc,{groups:Ms,diffStats:p?.diffStats,revertingPaths:ce,onRevertAll:Pt,isRevertingAll:se,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:re})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(Zc,{stagedCount:it.length,commitMessage:W,onCommitMessageChange:te,generatedHighlights:ne,onInsertHighlights:un,onGenerateMessage:ds,isGeneratingMessage:O,onCommit:()=>{Tt({pushAfter:!1})},onCommitAndPush:()=>{Tt({pushAfter:!0})},commitAction:q,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(st,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})}),t.jsx(eu,{open:Fe!==null,onOpenChange:T=>{T||Le(null)},targetBranch:Fe??"",changedFileCount:p?.files?.length??0,onCommitAndSwitch:async(T,U)=>{const X=Fe;if(!X||!l)return;const Ce=p?.current??null;await a.createGitCommit(l,T,{addAll:!0});let Ge=null;if(U){const zs=p?.tracking?.split("/")[0],Vt=De.find(fn=>fn.name===zs)??De[0];try{if(!Vt)throw new Error(o("mobile.changes.noRemote"));await a.gitPush(l,p?.tracking?{remote:Vt.name}:{remote:Vt.name,branch:Ce??void 0,options:["--set-upstream"]}),Ge=Vt.name}catch{xe.error(o("gitView.dirtySwitch.pushFailed")),await Pe(),Le(null);return}}xe.success(Ce?Ge?o("gitView.toast.pushedToUpstream",{name:Ge}):o("gitView.dirtySwitch.committedNotPushed",{branch:Ce}):o("gitView.toast.commitCreated")),await Pe(),Le(null),await lt(X)},onGenerateMessage:async()=>{if(!l)return"";const T=(p?.files??[]).map(X=>X.path).sort(),{message:U}=await Qr(l,T);return U.subject?.trim()??""},onRevertAndSwitch:async()=>{const T=Fe;if(!T||!l)return;await Pt((p?.files??[]).map(X=>X.path));const U=await a.getGitStatus(l);if(!U.isClean&&(U.files?.length??0)>0){xe.error(o("gitView.dirtySwitch.revertIncomplete"));return}Le(null),await lt(T)}})]})},st=n=>{const e=me.c(13),{message:s,description:i,loading:r,icon:o}=n,a=r===void 0?!1:r,d=o===void 0?!1:o;let m;e[0]!==a?(m=a?t.jsx(Q,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=a,e[1]=m):m=e[1];let f;e[2]!==d?(f=d?t.jsx(Q,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=d,e[3]=f):f=e[3];let l;e[4]!==s?(l=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=l):l=e[5];let p;e[6]!==i?(p=i?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}):null,e[6]=i,e[7]=p):p=e[7];let g;return e[8]!==m||e[9]!==f||e[10]!==l||e[11]!==p?(g=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[m,f,l,p]})}),e[8]=m,e[9]=f,e[10]=l,e[11]=p,e[12]=g):g=e[12],g},Ei=n=>{const e=me.c(31),{path:s,subtitle:i,diff:r,staged:o,fileExists:a,unavailableReason:d,error:m,onBack:f,onRetry:l}=n,p=o===void 0?!1:o,g=d===void 0?null:d,{t:h}=be();let b;e[0]!==s?(b=dl(s)||"text",e[0]=s,e[1]=b):b=e[1];const S=b;let v;e[2]!==h?(v=h("header.actions.backAria"),e[2]=h,e[3]=v):v=e[3];let I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(Q,{name:"arrow-left",className:"size-5"}),e[4]=I):I=e[4];let w;e[5]!==f||e[6]!==v?(w=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":v,onClick:f,children:I}),e[5]=f,e[6]=v,e[7]=w):w=e[7];let C;e[8]!==s?(C=t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s}),e[8]=s,e[9]=C):C=e[9];let A;e[10]!==i?(A=i&&t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:i}),e[10]=i,e[11]=A):A=e[11];let y;e[12]!==C||e[13]!==A?(y=t.jsxs("div",{className:"min-w-0 flex-1 px-2",children:[C,A]}),e[12]=C,e[13]=A,e[14]=y):y=e[14];let E;e[15]!==w||e[16]!==y?(E=t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/70 px-3 text-foreground",children:[w,y]}),e[15]=w,e[16]=y,e[17]=E):E=e[17];let N;e[18]!==r||e[19]!==m||e[20]!==a||e[21]!==S||e[22]!==l||e[23]!==s||e[24]!==p||e[25]!==h||e[26]!==g?(N=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:a?g==="nested_repository"?t.jsx(st,{icon:!0,message:h("diffView.unavailable.nestedRepositoryTitle"),description:h("diffView.unavailable.nestedRepositoryDescription")}):g==="untracked_directory"?t.jsx(st,{icon:!0,message:h("diffView.unavailable.untrackedDirectoryTitle"),description:h("diffView.unavailable.untrackedDirectoryDescription")}):m?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:h("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:m}),t.jsx(je,{type:"button",size:"sm",variant:"outline",onClick:l,children:h("diffView.actions.retry")})]})}):r?r.submodule?t.jsx("div",{className:"p-3",children:t.jsx(fu,{state:r.submodule,staged:p})}):r.isBinary?t.jsx(st,{icon:!0,message:h("diffView.binary.unavailable")}):fl(s)&&!r.fileDiff?t.jsx(st,{icon:!0,message:h("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(sn,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(pu,{original:r.original,modified:r.modified,fileDiff:r.fileDiff,language:S,fileName:s,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):t.jsx(st,{loading:!0,message:h("diffView.state.loadingDiff")}):t.jsx(st,{icon:!0,message:h("mobile.changes.diffDetail.missingTitle"),description:h("mobile.changes.diffDetail.missingDescription")})}),e[18]=r,e[19]=m,e[20]=a,e[21]=S,e[22]=l,e[23]=s,e[24]=p,e[25]=h,e[26]=g,e[27]=N):N=e[27];let R;return e[28]!==E||e[29]!==N?(R=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[E,N]}),e[28]=E,e[29]=N,e[30]=R):R=e[30],R},Rf=n=>{const e=me.c(12),{files:s,onSelect:i}=n,{t:r}=be();let o;e[0]!==r?(o=r("gitView.changes.changedFilesAria"),e[0]=r,e[1]=o):o=e[1];let a;if(e[2]!==s||e[3]!==i||e[4]!==r){let m;e[6]!==i||e[7]!==r?(m=f=>{const l=f.status==="A"?r("diffView.change.new"):f.status==="D"?r("diffView.change.deleted"):f.status==="R"?r("diffView.change.renamed"):f.status==="C"?r("diffView.change.copied"):r("diffView.change.modified"),p=f.status==="A"?"var(--status-success)":f.status==="D"?"var(--status-error)":f.status==="R"||f.status==="C"?"var(--status-info)":"var(--status-warning)";return t.jsx("li",{children:t.jsxs(je,{variant:"ghost",size:"lg",className:"w-full justify-start gap-2.5 text-left normal-case",onClick:()=>i(f.path),children:[t.jsx("span",{className:"w-4 shrink-0 text-center typography-meta font-semibold uppercase",style:{color:p},"aria-label":l,children:f.status}),t.jsx(to,{filePath:f.path,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label",title:f.path,children:f.path}),(f.insertions>0||f.deletions>0)&&t.jsxs("span",{className:"shrink-0 typography-meta text-muted-foreground",children:["+",f.insertions," -",f.deletions]}),t.jsx(Q,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"})]})},f.path)},e[6]=i,e[7]=r,e[8]=m):m=e[8],a=s.map(m),e[2]=s,e[3]=i,e[4]=r,e[5]=a}else a=e[5];let d;return e[9]!==o||e[10]!==a?(d=t.jsx(sn,{className:"h-full overflow-y-auto overflow-x-hidden px-3 py-2",children:t.jsx("ul",{"aria-label":o,className:"flex flex-col gap-1",children:a})}),e[9]=o,e[10]=a,e[11]=d):d=e[11],d},Ef=u.lazy(()=>ns(()=>import("./FilesView-Cs3Y7IF5.js").then(n=>n.F),__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])).then(n=>({default:n.FilesView}))),jt=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),Cs=n=>{const e=jt(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},If=n=>{const e=jt(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},Af=(n,e)=>{const s=jt(n),i=jt(e);return!i||s===i?Cs(s):s.startsWith(`${i}/`)?s.slice(i.length+1):s},Pf=n=>{if(typeof n!="number"||!Number.isFinite(n)||n<0)return"";if(n<1024)return`${n} B`;const e=["KB","MB","GB"];let s=n/1024;for(const i of e){if(s<1024||i===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${i}`;s/=1024}return""},Tf=n=>{const e=me.c(5),{onClose:s}=n,i=Jn()??null;let r;e[0]!==i?(r=jt(i),e[0]=i,e[1]=r):r=e[1];const o=r;let a;return e[2]!==s||e[3]!==o?(a=t.jsx(Df,{root:o,onClose:s},o),e[2]=s,e[3]=o,e[4]=a):a=e[4],a},Df=({root:n,onClose:e})=>{const{t:s}=be(),{files:i}=qn(),r=ga(W=>W.setSelectedPath),[o,a]=u.useState(()=>({type:"browser",directory:n})),[d,m]=u.useState([]),[f,l]=u.useState(!1),[p,g]=u.useState(null),[h,b]=u.useState(""),[S,v]=u.useState([]),[I,w]=u.useState(!1),C=u.useRef(0),A=o.type==="browser"?o.directory:o.returnDirectory,y=u.useRef(A);y.current=A;const E=u.useCallback(async W=>{if(!W)return;const te=C.current+1;C.current=te,l(!0),g(null);try{const ce=await i.listDirectory(W);if(C.current!==te)return;m(ce.entries.slice().sort((le,se)=>le.isDirectory!==se.isDirectory?le.isDirectory?-1:1:le.name.localeCompare(se.name)))}catch(ce){if(C.current!==te)return;m([]),g(ce instanceof Error?ce.message:s("mobile.files.error.listFailed"))}finally{C.current===te&&l(!1)}},[i,s]);u.useEffect(()=>{o.type==="browser"&&E(o.directory)},[E,o]);const N=u.useCallback(async W=>{jt(W)===jt(y.current)&&await E(y.current)},[E]),{canUpload:R,uploadingDirectory:k,pickFiles:P,uploadElements:B}=xc({root:n,refreshDirectory:N}),D=k!==null;u.useEffect(()=>{if(o.type!=="browser")return;const W=h.trim();if(!W){v([]),w(!1);return}let te=!1;const ce=window.setTimeout(()=>{w(!0),i.search({directory:o.directory,query:W,maxResults:40}).then(le=>{te||v(le)}).catch(()=>{te||v([])}).finally(()=>{te||w(!1)})},250);return()=>{te=!0,window.clearTimeout(ce)}},[i,h,o]);const x=W=>{b(""),a({type:"browser",directory:W})},_=W=>{r(n,W),a({type:"file",path:W,returnDirectory:A||n})},V=ze(W=>W.pendingFileFocusPath),j=ze(W=>W.pendingFileNavigation);if(u.useEffect(()=>{const W=jt(j?.path??V??"");!W||!n||W!==n&&!W.startsWith(`${n}/`)||(r(n,W),a({type:"file",path:W,returnDirectory:n}),V&&ze.getState().setPendingFileFocusPath(null))},[V,j,n,r]),!n)return t.jsx(Rs,{message:s("mobile.files.empty.noDirectory")});if(o.type==="file")return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/70 px-3 text-foreground",children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":s("header.actions.backAria"),onClick:()=>a({type:"browser",directory:o.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(ti,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:Cs(o.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Ve,{children:t.jsx(u.Suspense,{fallback:t.jsx(Rs,{loading:!0,message:s("filesView.state.loading")}),children:t.jsx(Ef,{mode:"editor-only"})})})})]});const $=o.directory===n?s("mobile.files.rootDirectory"):Cs(o.directory),F=h.trim()?S:[],z=If(o.directory),G=o.directory!==n&&z!==null&&(z===n||z.startsWith(`${n}/`)),q=G&&!h.trim(),Y=G?z:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[B,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[e?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":s("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Kc,{className:"size-5"})}):null,q&&Y?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":s("mobile.files.backToParentAria",{name:Cs(Y)}),onClick:()=>x(Y),style:{touchAction:"manipulation"},children:t.jsx(ti,{className:"size-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:$})}),t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":s("mobile.files.refreshAria"),onClick:()=>{E(o.directory)},style:{touchAction:"manipulation"},children:t.jsx(Gc,{className:Z("size-5",f&&"animate-spin")})}),R?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50","aria-label":s("sidebarFilesTree.actions.uploadFilesTitle"),onClick:()=>P(o.directory),disabled:D,style:{touchAction:"manipulation"},children:t.jsx(Q,{name:D?"loader-4":"upload-2",className:Z("size-5",D&&"animate-spin")})}):null]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(Hc,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(Xi,{value:h,onChange:W=>b(W.target.value),placeholder:s("mobile.files.search.placeholder"),className:"h-11 pl-9"})]})}),t.jsx(sn,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:p?t.jsx(Rs,{message:p}):h.trim()?t.jsx(_f,{results:F,isSearching:I,onOpenFile:_}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[d.length===0&&!f?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:s("mobile.files.empty.directory")}):null,d.map(W=>t.jsx(zo,{name:W.name,path:W.path,directory:W.isDirectory,meta:W.isDirectory?void 0:Pf(W.size),onClick:()=>W.isDirectory?x(W.path):_(W.path)},W.path))]})})]})},zo=n=>{const e=me.c(16),{name:s,path:i,directory:r,meta:o,onClick:a}=n;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={touchAction:"manipulation"},e[0]=d):d=e[0];let m;e[1]!==r||e[2]!==i?(m=r?t.jsx(Yc,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(to,{filePath:i,className:"size-5 shrink-0"}),e[1]=r,e[2]=i,e[3]=m):m=e[3];let f;e[4]!==s?(f=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=f):f=e[5];let l;e[6]!==o?(l=o?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:o}):null,e[6]=o,e[7]=l):l=e[7];let p;e[8]!==r?(p=r?t.jsx(Xc,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=r,e[9]=p):p=e[9];let g;return e[10]!==a||e[11]!==m||e[12]!==f||e[13]!==l||e[14]!==p?(g=t.jsxs("button",{type:"button",className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:a,style:d,children:[m,f,l,p]}),e[10]=a,e[11]=m,e[12]=f,e[13]=l,e[14]=p,e[15]=g):g=e[15],g},_f=n=>{const e=me.c(10),{results:s,isSearching:i,onOpenFile:r}=n,{t:o}=be(),a=jt(Jn()??null);if(i){let l;e[0]!==o?(l=o("common.loading"),e[0]=o,e[1]=l):l=e[1];let p;return e[2]!==l?(p=t.jsx(Rs,{loading:!0,message:l}),e[2]=l,e[3]=p):p=e[3],p}if(s.length===0){let l;e[4]!==o?(l=o("mobile.files.search.empty"),e[4]=o,e[5]=l):l=e[5];let p;return e[6]!==l?(p=t.jsx(Rs,{message:l}),e[6]=l,e[7]=p):p=e[7],p}const d="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",m=s.map(l=>t.jsx(zo,{name:Cs(l.path),path:l.path,directory:!1,meta:Af(l.path,a),onClick:()=>r(l.path)},l.path));let f;return e[8]!==m?(f=t.jsx("div",{className:d,children:m}),e[8]=m,e[9]=f):f=e[9],f},Rs=n=>{const e=me.c(7),{message:s,loading:i}=n,r=i===void 0?!1:i;let o;e[0]!==r?(o=r?t.jsx(qc,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(Jc,{className:"size-6 text-muted-foreground"}),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s?(a=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[2]=s,e[3]=a):a=e[3];let d;return e[4]!==o||e[5]!==a?(d=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[o,a]})}),e[4]=o,e[5]=a,e[6]=d):d=e[6],d},Ii="mobile-surface-root",Mf=16,Ai=320,zf="cubic-bezier(0.22, 1, 0.36, 1)",Of=n=>{const e=me.c(36),{onOpenMcpSettings:s}=n,{t:i}=be(),[r,o]=u.useState(!1),a=Nt(Lf),d=ws($f),m=es(Ff);let f;e[0]!==a||e[1]!==r||e[2]!==m||e[3]!==d?(f=()=>{if(r)return;o(!0);const P=new Promise(Wf);Promise.all([d({directory:a||null,silent:!0}),m({force:!0}),P]).finally(()=>o(!1))},e[0]=a,e[1]=r,e[2]=m,e[3]=d,e[4]=f):f=e[4];const l=f;let p;e[5]!==i?(p=i("settings.mcp.sidebar.actions.addServerTitle"),e[5]=i,e[6]=p):p=e[6];let g;e[7]!==i?(g=i("settings.mcp.sidebar.actions.addServerTitle"),e[7]=i,e[8]=g):g=e[8];let h,b;e[9]===Symbol.for("react.memo_cache_sentinel")?(h={touchAction:"manipulation"},b=t.jsx(Q,{name:"add",className:"size-5"}),e[9]=h,e[10]=b):(h=e[9],b=e[10]);let S;e[11]!==s||e[12]!==p||e[13]!==g?(S=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:s,"aria-label":p,title:g,style:h,children:b}),e[11]=s,e[12]=p,e[13]=g,e[14]=S):S=e[14];let v;e[15]!==i?(v=i("mcpDropdown.actions.refreshAria"),e[15]=i,e[16]=v):v=e[16];let I;e[17]!==i?(I=i("mcpDropdown.actions.refreshAria"),e[17]=i,e[18]=I):I=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w={touchAction:"manipulation"},e[19]=w):w=e[19];const C=r&&"animate-spin";let A;e[20]!==C?(A=Z("size-5",C),e[20]=C,e[21]=A):A=e[21];let y;e[22]!==A?(y=t.jsx(Q,{name:"refresh",className:A}),e[22]=A,e[23]=y):y=e[23];let E;e[24]!==r||e[25]!==l||e[26]!==y||e[27]!==v||e[28]!==I?(E=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:l,disabled:r,"aria-label":v,title:I,style:w,children:y}),e[24]=r,e[25]=l,e[26]=y,e[27]=v,e[28]=I,e[29]=E):E=e[29];let N;e[30]!==E||e[31]!==S?(N=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[S,E]}),e[30]=E,e[31]=S,e[32]=N):N=e[32];let R;e[33]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(wf,{active:!0,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=R):R=e[33];let k;return e[34]!==N?(k=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[N,R]}),e[34]=N,e[35]=k):k=e[35],k},Bf=({open:n,onClose:e,tab:s,onTabChange:i,pendingChangesDiff:r,onOpenPlan:o,onOpenMcpSettings:a,variant:d="drawer"})=>{const{t:m}=be(),f=u.useRef(null),l=u.useRef(null),[p,g]=u.useState(!1),[h,b]=u.useState(n),S=u.useRef(e);u.useEffect(()=>{S.current=e},[e]);const v=u.useRef(s);u.useEffect(()=>{v.current=s},[s]),xr(l,{enabled:d==="drawer"&&n,onLeftEdgeSwipe:()=>S.current()});const[I,w]=u.useState(()=>new Set);if(u.useEffect(()=>{n&&w(y=>{if(y.has(s))return y;const E=new Set(y);return E.add(s),E})},[n,s]),typeof document<"u"&&!f.current){let y=document.getElementById(Ii);y||(y=document.createElement("div"),y.id=Ii,document.body.appendChild(y)),f.current=y}if(u.useEffect(()=>{if(n){b(!0);const E=window.setTimeout(()=>g(!0),Mf);return()=>window.clearTimeout(E)}g(!1);const y=window.setTimeout(()=>b(!1),Ai+40);return()=>window.clearTimeout(y)},[n]),u.useEffect(()=>{if(!n)return;const y=document.body.style.overflow;d==="drawer"&&(document.body.style.overflow="hidden");const E=N=>{N.key!=="Escape"||v.current==="terminal"||pl(N.target)||S.current()};return document.addEventListener("keydown",E),()=>{d==="drawer"&&(document.body.style.overflow=y),document.removeEventListener("keydown",E)}},[n,d]),d==="drawer"&&!f.current)return null;const C=[{id:"changes",label:m("mobile.menu.changes"),icon:t.jsx(Q,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:m("mobile.menu.files"),icon:t.jsx(Q,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:m("mobile.menu.terminal"),icon:t.jsx(Q,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:m("contextRail.surface.notes"),icon:t.jsx(Q,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:m("mobile.menu.mcp"),icon:t.jsx(ml,{className:"h-3.5 w-3.5"})}],A=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("div",{className:"flex h-9 min-w-0 flex-1 items-center",children:h?t.jsx(yc,{items:C,activeId:s,onSelect:y=>i(y),layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:!0,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-mr-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":m("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[I.has("changes")?t.jsx("div",{className:Z("h-full",s!=="changes"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(Nf,{visible:n&&s==="changes",initialDiff:r})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,I.has("files")?t.jsx("div",{className:Z("h-full",s!=="files"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(Tf,{})})}):null,I.has("terminal")?t.jsx("div",{className:Z("h-full",s!=="terminal"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(vc,{visible:n&&s==="terminal"})})}):null,I.has("notes")?t.jsx("div",{className:Z("h-full",s!=="notes"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(wc,{onActionComplete:e,onOpenPlan:o})})}):null,I.has("mcp")?t.jsx("div",{className:Z("h-full",s!=="mcp"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(Of,{onOpenMcpSettings:a})})}):null]})]});return d==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:A}):ss.createPortal(t.jsx("section",{ref:l,role:"dialog","aria-modal":"true","aria-label":m("mobile.header.openWorkspaceAria"),"aria-hidden":!n,className:"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:p?"none":"translateX(100%)",transition:`transform ${Ai}ms ${zf}`,visibility:h?"visible":"hidden",pointerEvents:n?"auto":"none"},children:A}),f.current)};function Lf(n){return n.currentDirectory}function $f(n){return n.refresh}function Ff(n){return n.loadMcpConfigs}function Wf(n){return window.setTimeout(n,500)}function Vf(n){const e=me.c(4),s=2500,{uiFont:i}=hl(),[r,o]=u.useState(!1);let a,d;return e[0]!==s||e[1]!==i?(a=()=>{let m=!1;const f=()=>{m||o(!0)},l=()=>{requestAnimationFrame(()=>requestAnimationFrame(f))},p=Promise.all([gl(i).catch(qf),document.fonts?.ready?.then(Hf).catch(Gf)??Promise.resolve(),hu.catch(Kf)]).then(Uf),g=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([p,g]).then(l),()=>{m=!0}},d=[i,s],e[0]=s,e[1]=i,e[2]=a,e[3]=d):(a=e[2],d=e[3]),u.useEffect(a,d),r}function Uf(){}function Kf(){}function Gf(){}function Hf(){}function qf(){}const Jf="openchamber",Yf=n=>n.replace(/^\/+|\/+$/g,""),Xf=n=>{const e=Yf(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function Qf(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${Jf}:`)return null;const s=Xf(e),i=(s[0]??"").toLowerCase(),r=s.slice(1),o=e.searchParams;switch(i){case"session":{const a=r[0]||o.get("id")||"";return a?{type:"session",sessionId:a,directory:o.get("dir")??void 0}:null}case"new":case"new-session":return{type:"new-session",directory:o.get("dir")??void 0,projectId:o.get("project")??void 0,agent:o.get("agent")??void 0,model:o.get("model")??void 0};case"sessions":{const a=o.get("filter");return{type:"sessions",filter:a==="attention"||a==="recent"||a==="all"?a:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:r[0]||o.get("section")||void 0};case"changes":return{type:"changes",path:r.join("/")||o.get("path")||void 0,staged:o.get("staged")==="true"};case"view":{const a=(r[0]||"").toLowerCase();return a==="changes"?{type:"changes"}:a==="files"||a==="mcp"||a==="instances"||a==="update"?{type:"view",target:a}:null}default:return null}}let et={},Oo=!1,Ns=null;const Zf=n=>{switch(n.type){case"session":return Re.getState().setCurrentSession(n.sessionId,n.directory??null),!0;case"new-session":{const e=Re.getState();return e.openNewSessionDraft(),(n.directory||n.projectId)&&e.setNewSessionDraftTarget({directoryOverride:n.directory??null,projectId:n.projectId??null,selectedProjectId:n.projectId??null}),!0}case"sessions":return et.openSessions?(et.openSessions(n.filter),!0):!1;case"status":return et.openSessions?(et.openSessions(),!0):!1;case"view":return et.openView?(et.openView(n.target),!0):!1;case"changes":return et.openChanges?(et.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return et.openSettings?(et.openSettings(n.section),!0):!1}},yr=()=>{if(!Oo||!Ns)return;const n=Ns;Ns=null,Zf(n)||(Ns=n)},Bo=n=>{Ns=n,yr()},Pi=n=>{const e=Qf(n);e&&Bo(e)},em=n=>{Oo=n,yr()},tm=n=>{const e=me.c(3);let s,i;e[0]!==n?(s=()=>(et=n,yr(),()=>{et===n&&(et={})}),i=[n],e[0]=n,e[1]=s,e[2]=i):(s=e[1],i=e[2]),u.useEffect(s,i)},sm=n=>{const{ready:e}=n;u.useEffect(()=>{em(e)},[e]),u.useEffect(()=>{if(!Be())return;let s=!1;const i=[];return ns(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([128,1,129])).then(async({App:r})=>{if(s)return;const o=await r.addListener("appUrlOpen",a=>{Pi(a?.url)});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),ns(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([130,129])).then(async({PushNotifications:r})=>{if(s)return;const o=await r.addListener("pushNotificationActionPerformed",a=>{const d=a?.notification?.data,m=typeof d?.url=="string"?d.url:typeof d?.deeplink=="string"?d.deeplink:void 0;if(m){Pi(m);return}const f=typeof d?.sessionId=="string"?d.sessionId:void 0;f&&Bo({type:"session",sessionId:f})});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),()=>{s=!0,i.forEach(r=>r())}},[])},nm=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},rm=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},im=n=>{const{enabled:e}=n,s=ze(r=>r.nativeNotificationsEnabled),i=u.useRef(null);u.useEffect(()=>{if(!e||!s||!rm())return;let r=!1;const o=[];return ns(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([130,129])).then(async({PushNotifications:a})=>{if(r)return;let d=await a.checkPermissions().catch(()=>null);if(d?.receive!=="granted"&&(d=await a.requestPermissions().catch(()=>null)),d?.receive!=="granted")return;const m=await a.addListener("registration",l=>{i.current=l.value,Gr()?.push?.registerApnsToken?.({token:l.value,platform:zi(),environment:nm()})}),f=await a.addListener("registrationError",l=>{console.warn("[Push] APNs registration error:",l)});if(await a.register().catch(()=>{}),r){m.remove(),f.remove();return}o.push(()=>{m.remove()},()=>{f.remove()})}).catch(()=>{}),()=>{r=!0,o.forEach(a=>a())}},[e,s]),u.useEffect(()=>{if(s)return;const r=i.current;if(!r)return;i.current=null,Gr()?.push?.unregisterApnsToken?.({token:r})},[s])},Ti=n=>{const e=me.c(12),{side:s,isResizing:i,ariaLabel:r,handleProps:o}=n,a=s==="left"?"right-0":"left-0";let d;e[0]!==a?(d=Z("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",a),e[0]=a,e[1]=d):d=e[1];const m=s==="left"?"right-0":"left-0",f=i&&"bg-[var(--interactive-border)]";let l;e[2]!==m||e[3]!==f?(l=Z("absolute inset-y-0 w-[3px] transition-colors",m,f),e[2]=m,e[3]=f,e[4]=l):l=e[4];let p;e[5]!==l?(p=t.jsx("div",{className:l}),e[5]=l,e[6]=p):p=e[6];let g;return e[7]!==r||e[8]!==o||e[9]!==d||e[10]!==p?(g=t.jsx("div",{className:d,role:"separator","aria-orientation":"vertical","aria-label":r,...o,children:p}),e[7]=r,e[8]=o,e[9]=d,e[10]=p,e[11]=g):g=e[11],g},om=320,am=380,Di=280,lm=560,cm=900;function _i(n,e,s,i){const r=me.c(23),o=i===void 0?lm:i,a=u.useRef(null);let d;r[0]!==s||r[1]!==o||r[2]!==e?(d=()=>{if(typeof window>"u")return s;const x=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(x)?Math.min(o,Math.max(Di,x)):s},r[0]=s,r[1]=o,r[2]=e,r[3]=d):d=r[3];const[m,f]=u.useState(d),[l,p]=u.useState(!1),g=u.useRef(0),h=u.useRef(m),b=u.useRef(null),S=u.useRef(null);let v;r[4]!==o?(v=x=>Math.min(o,Math.max(Di,Math.round(x))),r[4]=o,r[5]=v):v=r[5];const I=v;let w;r[6]===Symbol.for("react.memo_cache_sentinel")?(w=x=>{const _=a.current;_&&(_.style.width=`${x}px`,_.style.minWidth=`${x}px`,_.style.maxWidth=`${x}px`,_.style.setProperty("--oc-ipad-sidebar-width",`${x}px`))},r[6]=w):w=r[6];const C=w;let A;r[7]!==m?(A=x=>{try{x.currentTarget.setPointerCapture(x.pointerId)}catch{}S.current=x.pointerId,g.current=x.clientX,h.current=m,b.current=m,p(!0),x.preventDefault()},r[7]=m,r[8]=A):A=r[8];const y=A;let E;r[9]!==I||r[10]!==n?(E=x=>{if(S.current!==x.pointerId)return;const _=x.clientX-g.current,V=I(h.current+(n==="left"?_:-_));b.current!==V&&(b.current=V,C(V))},r[9]=I,r[10]=n,r[11]=E):E=r[11];const N=E;let R;r[12]!==I||r[13]!==e?(R=x=>{if(S.current!==x.pointerId)return;try{x.currentTarget.releasePointerCapture(x.pointerId)}catch{}const _=I(b.current??h.current);S.current=null,b.current=null,p(!1),f(_);try{window.localStorage.setItem(e,String(_))}catch{}},r[12]=I,r[13]=e,r[14]=R):R=r[14];const k=R;let P;r[15]!==y||r[16]!==k||r[17]!==N?(P={onPointerDown:y,onPointerMove:N,onPointerUp:k,onPointerCancel:k},r[15]=y,r[16]=k,r[17]=N,r[18]=P):P=r[18];const B=P;let D;return r[19]!==B||r[20]!==l||r[21]!==m?(D={asideRef:a,width:m,isResizing:l,handleProps:B},r[19]=B,r[20]=l,r[21]=m,r[22]=D):D=r[22],D}const um=["general","appearance","chat","notifications","sessions","routing","git","magic-prompts","snippets","behavior","agents","commands","mcp","plugins","skills.installed","skills.catalog","providers","web-search","usage","voice","integrations","about"],dm=1e3,fm=({onActiveConnectionDeleted:n})=>{const{t:e}=be();Tc();const[s,i]=u.useState(!1);u.useEffect(()=>Re.subscribe((J,de)=>{J.currentSessionId&&J.currentSessionId!==de.currentSessionId&&ze.getState().setRunOverviewKey(null)}),[]);const r=ze(J=>J.runOverviewKey!==null);u.useEffect(()=>{r&&i(!1)},[r]);const[o,a]=u.useState(null),[d,m]=u.useState(!1),[f,l]=u.useState("changes"),[p,g]=u.useState(null),[h,b]=u.useState("nav"),[S,v]=u.useState(null),I=ze(J=>J.setSettingsPage),w=ze(J=>J.wideChatLayoutEnabled),C=Xt(J=>J.available),A=Xt(J=>J.runtimeType),y=u.useMemo(()=>Yn(),[]),E=es(J=>J.mcpServers),N=es(J=>J.setMcpDraft),R=es(J=>J.setSelectedMcp),k=u.useCallback(()=>{a(null),g(null)},[]),P=u.useCallback(J=>{a(J)},[]),B=u.useCallback(()=>{m(!1)},[]),D=u.useCallback(J=>{b(J),P("settings")},[P]),{enabled:x,roomyForPanels:_}=Vn(),j=Bl()==="portrait",$=Ll(),[F,z]=u.useState(()=>$l().roomyForPanels),G=u.useCallback(()=>{z(J=>!J)},[]);u.useEffect(()=>{x||z(!1)},[x]);const q=u.useCallback(()=>{v(null),l("files"),m(!0)},[]);u.useEffect(()=>so(J=>{if(J.type!=="file-open-request")return;const de=J.directory??Nt.getState().currentDirectory;de&&(ze.getState().openContextFile(de,J.path),q())}),[q]);const Y=u.useCallback((J=null)=>{v(J),l("changes"),m(!0)},[]),W=_i("left","openchamber.ipad.leftSidebarWidth",om),te=_i("right","openchamber.ipad.rightSidebarWidth",am,cm),ce=_,le=ce&&d?te.width:0,se=x&&F?W.width:0;u.useEffect(()=>{if(typeof document>"u")return;const J=document.documentElement;return J.style.setProperty("--oc-chat-inset-left",`${se}px`),J.style.setProperty("--oc-chat-inset-right",`${le}px`),()=>{J.style.removeProperty("--oc-chat-inset-left"),J.style.removeProperty("--oc-chat-inset-right")}},[se,le]),u.useEffect(()=>{if(typeof document>"u")return;const J=document.documentElement;return J.classList.toggle("wide-chat-layout",w),()=>J.classList.remove("wide-chat-layout")},[w]),u.useEffect(()=>{if(typeof document>"u")return;const J=x&&(j||$),de=document.documentElement;return de.classList.toggle("oc-keep-draft-starters",J),()=>de.classList.remove("oc-keep-draft-starters")},[$,x,j]);const ie=u.useMemo(()=>({openChanges:({diffPath:J,staged:de}={})=>{Y(J?{path:J,staged:de===!0}:null)},openFiles:()=>q(),openSettings:()=>D("nav")}),[Y,q,D]),O=u.useMemo(()=>({openSessions:()=>{x?z(!0):i(!0)},openView:J=>{if(J==="files"){q();return}if(J==="mcp"){l("mcp"),m(!0);return}P(J)},openChanges:({path:J,staged:de}={})=>{Y(J?{path:J,staged:de===!0}:null)},openSettings:J=>{J&&I(J),D(J?"page-content":"nav")}}),[x,Y,q,D,P,I]);tm(O);const ee=u.useRef(null);xr(ee,{onLeftEdgeSwipe:()=>{x?z(!0):i(!0)},onRightEdgeSwipe:()=>m(!0)});const ne=u.useRef(null),ae=u.useCallback(J=>{ne.current=J},[]),H=u.useCallback(()=>p?(g(null),!0):o==="settings"&&ne.current?.()?!0:o?(k(),!0):d?(B(),!0):s?(i(!1),!0):!1,[o,k,B,p,s,d]);Fl(H);const re=!y&&C&&(A==="desktop"||A==="web"),ue=x?"dialog":"fullscreen",ye=u.useMemo(()=>({instanceLabel:y?js():null,onOpenInstances:y?()=>P("instances"):void 0,onOpenSettings:()=>D("nav"),onOpenUsage:()=>P("usage"),onOpenUpdate:re?()=>P("update"):void 0}),[D,P,y,re]),he=u.useCallback(()=>{const J="new-mcp-server";let de=J,Se=1;for(;E.some(ve=>ve.name===de);)de=`${J}-${Se}`,Se+=1;N({name:de,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1}),R(de),I("mcp"),D("page-content")},[E,D,N,R,I]);return t.jsx(Wl,{actions:ie,children:t.jsxs("div",{className:"oc-mobile-app-shell main-content-safe-area flex h-[100dvh] flex-row bg-background text-foreground","data-page-scroll-lock":"true",children:[x?t.jsxs("aside",{ref:W.asideRef,className:Z("relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!F&&"border-r-0"),style:{width:F?W.width:0,minWidth:F?W.width:0,maxWidth:F?W.width:0,"--oc-ipad-sidebar-width":`${W.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:W.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!F,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:Z("flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",W.isResizing&&"pointer-events-none",!F&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Ve,{children:t.jsx(ji,{open:!0,variant:"sidebar",onOpenChange:J=>{!J&&!_&&z(!1)},footer:ye})})}),F?t.jsx(Ti,{side:"left",isResizing:W.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:W.handleProps}):null]}):null,t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col","data-page-scroll-lock":"true",children:[t.jsx(Nd,{onOpenSessions:()=>x?G():i(!0),onOpenWorkspace:()=>m(!0),compactTitle:x}),t.jsxs("main",{ref:ee,className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[t.jsx("div",{className:"h-full w-full",children:t.jsx(Ve,{children:t.jsx(Dc,{})})}),t.jsx(Ve,{children:t.jsx(_c,{})})]})]}),x?null:t.jsx(ji,{open:s,onOpenChange:i,footer:ye}),t.jsxs("aside",{ref:te.asideRef,className:Z("relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!le&&"border-l-0"),style:{width:le,minWidth:le,maxWidth:le,"--oc-ipad-sidebar-width":`${te.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:te.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!le,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:Z("flex h-full min-h-0 shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",te.isResizing&&"pointer-events-none",!le&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Ve,{children:t.jsx(Bf,{open:d,onClose:B,tab:f,onTabChange:l,pendingChangesDiff:S,onOpenPlan:g,onOpenMcpSettings:he,variant:ce?"panel":"drawer"})})}),le?t.jsx(Ti,{side:"right",isResizing:te.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:te.handleProps}):null]}),p?t.jsx(qt,{open:!0,variant:ue,onClose:()=>g(null),ariaLabel:p.title,title:p.title,children:t.jsx(Ve,{children:t.jsx(Lc,{savedProjectPlan:{projectRef:p.projectRef,planId:p.id},onNavigatedToChat:()=>{k(),B()}})})}):null,o==="instances"&&y?t.jsx(qt,{open:!0,variant:ue,dialogAlign:"app",onClose:k,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(Ad,{onConnect:k,onActiveConnectionDeleted:n})}):null,o==="settings"?t.jsx(qt,{open:!0,variant:ue,dialogAlign:"app",onClose:k,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Ve,{children:t.jsx(Oc,{forceMobile:!0,isWindowed:!0,initialMobileStage:h,registerBackHandler:ae,visiblePageSlugs:[...um],onClose:k})})}):null,o==="usage"?t.jsx(qt,{open:!0,variant:ue,dialogAlign:"app",onClose:k,ariaLabel:e("usageStats.title"),title:e("usageStats.title"),children:t.jsx(Ve,{children:t.jsx(Mc,{})})}):null,o==="update"?t.jsx(qt,{open:!0,variant:ue,dialogAlign:"app",onClose:k,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Ve,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(Bc,{initialUpdateDialogOpen:!0})})})}):null]})})};function Mi({apis:n}){const e=ze(O=>O.isolatedSpacesEnabled),{t:s}=be(),i=tt(O=>O.initializeApp),r=tt(O=>O.isInitialized),o=tt(O=>O.isConnected),a=tt(O=>O.connectionPhase),d=tt(O=>O.providers.length),m=tt(O=>O.agents.length),f=tt(O=>O.loadProviders),l=tt(O=>O.loadAgents),p=Nt(O=>O.currentDirectory),g=Re(O=>O.error),h=Re(O=>O.clearError),b=ze(O=>O.setIsMobile),S=bl(O=>O.refreshStatus),v=xl(O=>O.refreshStatus),I=yl(O=>O.setPlanModeEnabled),w=Ye(O=>O.projects),C=Zt(O=>O.activeSessions),A=Zt(O=>O.archivedSessions),y=Zt(O=>O.status==="ready"),E=u.useMemo(()=>[...C,...A],[C,A]);kc({hasAuthoritativeGlobalSessions:y,sessions:E});const[N,R]=u.useState(0),[k,P]=u.useState(0),[B,D]=u.useState(!1),[x,_]=u.useState("pending"),[V,j]=u.useState(null),$=u.useMemo(()=>js(),[]),[,F]=u.useReducer(O=>O+1,0),z=u.useMemo(()=>Yn(),[]),G=u.useRef(0),q=u.useRef(0),Y=u.useCallback(()=>{const O=ft(),ee=q.current+1;if(q.current=ee,!O){bs("resume:auto-connect",{}),xs();return}bs("resume:reprobe",{});const ne=()=>{i(),S(n.github,{force:!0}),v(n.linear,{force:!0}),d===0&&f({source:"mobileApp:nativeResume"}),m===0&&l({source:"mobileApp:nativeResume"})},ae=re=>{bs("resume:disconnect",{reason:re}),Jt({apiBaseUrl:"",clientToken:null,runtimeKey:Fs}),R(ue=>ue+1)};Gs().then(re=>{if(q.current===ee){if(re==="no-connection"){ae("no-connection");return}if(re==="needs-login"){j({kind:"auth-expired",label:js()??""}),ae("needs-login");return}if(re==="unreachable"){const ue=[4e3,1e4],ye=he=>{window.setTimeout(()=>{if(q.current!==ee)return;const J=he===ue.length-1;Gs({fast:!J}).then(de=>{if(q.current===ee&&de!=="switched"){if(de==="unchanged"){ne();return}if(de==="needs-login"){j({kind:"auth-expired",label:js()??""}),ae("retry-needs-login");return}if(!J){ye(he+1);return}ae(`retry-${de}`)}})},ue[he])};ye(0);return}re!=="switched"&&ne()}});const H=Date.now();H-G.current>=dm&&(G.current=H,window.dispatchEvent(new Event("openchamber:system-resume")))},[m,n.github,n.linear,i,l,f,d,S,v]);vl(),wl(Y),u.useEffect(()=>{if(!z)return;let O;const ee=()=>{window.clearTimeout(O),O=window.setTimeout(()=>Y(),1500)};return window.addEventListener("online",ee),()=>{window.removeEventListener("online",ee),window.clearTimeout(O)}},[z,Y]),u.useEffect(()=>{if(z)return Hr.subscribe((O,ee)=>{O.state==="expired"&&ee.state!=="expired"&&(Y(),Hr.getState().markAuthenticated())})},[z,Y]),u.useEffect(()=>(qr(n),()=>qr(null)),[n]),u.useEffect(()=>Bi(O=>{if(bs("endpoint:changed",{runtimeKey:O.runtimeKey||"none",previousRuntimeKey:O.previousRuntimeKey||"none",connected:!!O.apiBaseUrl}),!!O.runtimeKey&&O.runtimeKey===O.previousRuntimeKey){Sc(),F();return}Nc(O),P(ne=>ne+1),R(ne=>ne+1)}),[]),u.useEffect(()=>{if(!z||o||ft()){_("done");return}let O=!1;return _("attempting"),(async()=>{const ee=await xs().catch(()=>({status:"no-candidate"}));O||(ee.status==="unreachable"?j({kind:"unreachable",label:ee.label}):ee.status==="needs-login"&&j({kind:"auth-expired",label:ee.label}),_("done"),ee.status==="unreachable"&&xs({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{O=!0}},[]),u.useEffect(()=>{if(!z||!ft())return;let O=!1;const ee=ne=>{bs("cold-launch:drop",{kind:ne?.kind??"unknown"}),ne&&j(ne),Jt({apiBaseUrl:"",clientToken:null,runtimeKey:Fs}),R(ae=>ae+1)};return Gs().then(async ne=>{if(O||ne==="switched"||ne==="unchanged")return;const ae=js();if(ne==="needs-login"){ee({kind:"auth-expired",label:ae??""});return}if(ne==="unreachable"){ee(ae?{kind:"unreachable",label:ae}:null),xs({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const H=await xs().catch(()=>({status:"no-candidate"}));O||H.status==="connected"||(H.status==="needs-login"?ee({kind:"auth-expired",label:H.label}):H.status==="unreachable"?ee({kind:"unreachable",label:H.label}):ee(null))}),()=>{O=!0}},[]),u.useEffect(()=>{b(!0)},[b]),u.useEffect(()=>{z&&!ft()||i()},[N,i,z]),u.useEffect(()=>{o&&(d===0&&f({source:"mobileApp:recovery"}),m===0&&l({source:"mobileApp:recovery"}))},[m,o,l,f,d]);const W=u.useRef(!1),[te,ce]=u.useState(z);u.useEffect(()=>{if(!z||!o||W.current)return;if(Re.getState().currentSessionId){W.current=!0,ce(!1);return}const O=ls(),ee=jl(O);if(!ee){W.current=!0,ce(!1);return}let ne=!1;const ae=window.setTimeout(()=>ce(!1),6e3);return(async()=>{const H=await Hn().catch(()=>null);if(ne)return;if(!H){ce(!1);return}W.current=!0;const re=H.activeSessions.find(ye=>ye.id===ee.sessionId);if(!re){kl(O),ce(!1);return}const ue=Re.getState();ue.currentSessionId||ue.setCurrentSession(re.id,Wn(re)??ee.directory??void 0),ce(!1)})(),()=>{ne=!0,window.clearTimeout(ae)}},[N,o,z]),u.useEffect(()=>{o&&Jr.setDirectory(p)},[p,o]),u.useEffect(()=>{o&&(S(n.github,{force:!0}),v(n.linear,{force:!0}))},[n.github,n.linear,o,S,v]),u.useEffect(()=>{if(!o||w.length===0)return;let O=!1;return(async()=>{const ne=new Map(Re.getState().availableWorktreesByProject);if(await Promise.all(w.map(async re=>{const ue=re.path.replace(/\\/g,"/").replace(/\/+$/,"");if(ue)try{if(!(Je.getState().directories.get(ue)?.isGitRepo??await ns(()=>import("./useAppFontEffects-Cz-1Efdn.js").then(de=>de.m8),__vite__mapDeps([10,2,3,4,5,1,6,7,8,9,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])).then(de=>de.checkIsGitRepository(ue))))return;const J=await Zi({id:re.id,path:ue});if(O)return;ne.set(ue,J)}catch{}})),O)return;const ae=eo(w,ne),H=Re.getState().availableWorktreesByProject;zl(ae,H)||Re.setState({availableWorktrees:[...ae.values()].flat(),availableWorktreesByProject:ae})})(),()=>{O=!0}},[o,w]),u.useEffect(()=>{if(!o)return;let O=!1;const ee=so(ne=>{ne.type==="worktree-changed"&&Ol(w,ne.directories,()=>O)});return()=>{O=!0,ee()}},[o,w]),u.useEffect(()=>{let O=!1;return(async()=>{const ne=await Fn("/health",{method:"GET"}).catch(()=>null);if(!ne||!ne.ok||O)return;const ae=await ne.json().catch(()=>null);if(!ae||O)return;const H=ae.planModeExperimentalEnabled;I(H===!0||H===1||H==="1"||H==="true")})(),()=>{O=!0}},[I]),u.useEffect(()=>{if(!g)return;const O=window.setTimeout(()=>h(),5e3);return()=>window.clearTimeout(O)},[h,g]),u.useEffect(()=>{if(!(!o&&(z?!!ft():!0))){D(!1);return}const ee=window.setTimeout(()=>{D(!0)},z?4e3:8e3);return()=>window.clearTimeout(ee)},[o,z,N,k]),Sl(),Nl({enabled:!0}),Cc(),Cl(),Rl(),Rc(),im({enabled:z&&o}),sm({ready:z&&o&&r});const le=Vf(),se=!o&&a==="reconnecting";if(!le)return t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:t.jsx(Yt,{width:120,height:120,isAnimated:!0,variant:"splash"})});const ie=!!ft();return z&&(!ie||!o&&!se)?ie?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] px-6 text-center text-foreground",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-4",children:[t.jsx(Yt,{width:120,height:120,isAnimated:!B,variant:"splash"}),B?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:s("mobile.connect.recovery.description")})]}),t.jsx(je,{type:"button",variant:"outline",onClick:()=>{Jt({apiBaseUrl:"",clientToken:null,runtimeKey:Fs}),R(O=>O+1)},children:s("mobile.connect.cancelPassword")})]}):null]})}):x!=="done"?t.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:[t.jsx(Yt,{width:120,height:120,isAnimated:!0,variant:"splash"}),$?t.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[t.jsx("p",{className:"typography-small text-muted-foreground",children:s("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[$,t.jsx(El,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(cd,{onConnected:()=>R(O=>O+1),notice:V})}):!o&&!se?B?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"max-w-sm space-y-3",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:s("sessionAuth.error.networkDescription")})]})}):t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:t.jsx(Yt,{width:120,height:120,isAnimated:!0,variant:"splash"})}):t.jsx(Ve,{children:t.jsx(Il,{sdk:Jr.getSdkClient(),directory:p||"",children:t.jsx(Al,{apis:n,children:t.jsx(Pl,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(Ec,{ready:!z||!te,animated:!0}),t.jsx(Tl,{embeddedBackgroundWorkEnabled:r}),t.jsx(Ic,{}),t.jsx(Su,{}),t.jsx(fm,{onActiveConnectionDeleted:()=>{Jt({apiBaseUrl:"",clientToken:null,runtimeKey:Fs}),R(O=>O+1)}}),t.jsx(Dl,{}),t.jsx(_l,{}),e?t.jsx(Ac,{}):null,t.jsx(Ml,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),r?t.jsx(Pc,{}):null]})})})},k)})}function mm(n){const e=me.c(4),s=u.useSyncExternalStore(pm,ft,ft);if(Yn()&&!s){let r;return e[0]!==n?(r=t.jsx(Mi,{...n}),e[0]=n,e[1]=r):r=e[1],r}let i;return e[2]!==n?(i=t.jsx(jc,{children:t.jsx(Mi,{...n})}),e[2]=n,e[3]=i):i=e[3],i}function pm(n){return Bi(()=>n())}const hm=()=>{Jl(),ba().then(()=>{Promise.all([xa(),Yl()]).catch(n=>{console.error("[mobile-main] settings init failed:",n)}),Xl(),Ql(),Zl()}).catch(n=>{console.error("[mobile-main] appearance init failed:",n)}).finally(()=>{gu()})};function qh(n){window.__OPENCHAMBER_SURFACE__="mobile",Vl(),hm(),ku(),Ul();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const i=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",r=i?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,o=t.jsx(mm,{apis:r});la.createRoot(e).render(t.jsx(Pn.StrictMode,{children:t.jsx(Kl,{children:t.jsx(Gl,{children:t.jsx(Hl,{children:t.jsx(zc,{children:i?o:t.jsx(ql,{children:o})})})})})}))}export{qh as renderMobileApp};
25
+ `)}`.trim()),ae([])},[]),ds=u.useCallback(async()=>{if(!l)return;const T=it.map(U=>U.path).sort();if(T.length===0){xe.error(o("gitView.toast.selectFileToDescribe"));return}ee(!0);try{const{message:U}=await Qr(l,T);te(U.subject?.trim()??""),ae(Array.isArray(U.highlights)?U.highlights:[])}catch(U){xe.error(U instanceof Error?U.message:o("gitView.toast.generateCommitMessageFailed"))}finally{ee(!1)}},[l,it,o]),Tt=async(T={})=>{if(!l)return;if(!W.trim()){xe.error(o("gitView.toast.enterCommitMessage"));return}const U=it.map(X=>X.path).sort();if(U.length===0){xe.error(o("gitView.toast.selectFileToCommit"));return}Y(T.pushAfter?"commitAndPush":"commit");try{if(await a.createGitCommit(l,W.trim(),{files:U}),xe.success(o("gitView.toast.commitCreated")),te(""),ae([]),T.pushAfter){const X=p?.tracking?.split("/")[0],Ce=De.find(Ge=>Ge.name===X)??De[0];if(!Ce)throw new Error(o("mobile.changes.noRemote"));G("sync"),await si({git:a,directory:l,remote:Ce,dirtyWorktreeError:o("gitView.toast.commitOrStashBeforeSync"),onPushed:Ge=>{xe.success(o("gitView.toast.pushedToUpstream",{name:Ge.pushed[0].remote}))}}),await Pe(!1),await yt()}else await Pe(!1)}catch(X){xe.error(X instanceof Error?X.message:o("gitView.toast.createCommitFailed"))}finally{Y(null),T.pushAfter&&G(null)}},Ms=u.useMemo(()=>{const T=[];return it.length>0&&T.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:it,statsScope:"staged",actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:U=>o("gitView.changes.unstageFileAria",{path:U}),onActionFile:U=>{_e([U],"unstage")},onActionAll:U=>{_e(U,"unstage")},onViewDiff:U=>Ze(U,!0),onRevertFile:At,showRevertActions:!1,accent:!0}),we.length>0&&T.push({id:"unstaged",title:o("gitView.changes.title"),entries:we,statsScope:"working",actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:U=>o("gitView.changes.stageFileAria",{path:U}),onActionFile:U=>{_e([U],"stage")},onActionAll:U=>{_e(U,"stage")},onViewDiff:U=>Ze(U,!1),onRevertFile:At}),T},[At,Ze,_e,it,o,we]),fs=T=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:o("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:p?.current||l||""})]}),d===!1&&Array.isArray(f)&&f.length>0?t.jsx(gc,{repositories:f,selectedRepository:m??null,onSelectRepository:U=>{n&&w(n,U)},repositoryRoot:n??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:T})]});if(!l)return fs(t.jsx(st,{message:o("gitView.empty.selectSessionOrDirectory")}));if(d===!1&&h!==!0)return fs(t.jsx(bc,{rootIsGitRepo:d,resolvedIsGitRepo:h,nestedRepos:f,onRetryDiscovery:()=>{n&&I(n,{force:!0})}}));if(b&&h===null)return fs(t.jsx(st,{loading:!0,message:o("gitView.loading.checkingRepository")}));if(_.type==="diff")return t.jsx(Ei,{path:_.path,diff:xt,staged:_.staged,fileExists:!!ot,unavailableReason:Ee?.key===`${l}\0${_.path}`?Ee.reason:null,error:de,onBack:()=>F({type:"list"}),onRetry:()=>nt(T=>T+1)});const vt=o(x==="pr"?"session.githubIntegration.tabs.pullRequests":x==="branch"?"diffView.scope.branch":x==="commit"?"commitComparison.mode":"mobile.nav.changes"),ms=x==="branch"&&Ke.base?mc(Ke.base):x==="commit"?ht?.slice(0,8):x==="pr"&&bt?`#${bt.number}`:null;if(rt&&Et)return t.jsx(Ei,{path:rt,subtitle:[vt,ms].filter(Boolean).join(" · "),diff:Et.status==="ready"?Et.diff:null,fileExists:!Ne.files||Ne.files.some(T=>T.path===rt),error:Ne.error??(Et.status==="error"?Et.message:null),onBack:()=>F(Ht),onRetry:()=>{Ne.error&&Ne.refresh(),us(T=>T+1)}});const dn=()=>x==="pr"&&!bt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(st,{loading:gt.loading,message:gt.error??(gt.loading?o("session.githubPrPicker.loading.pullRequests"):o("pullRequestComparison.select"))}),!gt.loading&&t.jsx(ni,{mobile:!0,comparison:gt})]}):x==="branch"&&!Ke.base?t.jsx(st,{loading:!Ke.resolved,message:Ke.resolved?o("gitView.pr.toast.baseBranchRequired"):o("diffView.branch.resolvingBase")}):x==="commit"&&!ht?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[Qe.loading&&t.jsx(Q,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:Qe.loading?o("diffView.state.loadingChanges"):Qe.error??o("commitComparison.noCommits")}),Qe.error&&t.jsx(je,{variant:"outline",size:"lg",onClick:()=>{Qe.refresh()},children:o("diffView.actions.retry")})]}):Ne.error?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("p",{className:"typography-ui-label font-semibold",children:o("diffView.state.failedToLoadDiff")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:Ne.error}),t.jsx(je,{variant:"outline",size:"lg",onClick:()=>{Ne.refresh()},children:o("diffView.actions.retry")})]}):$e?$e.length===0?t.jsx(st,{icon:x==="branch",message:x==="pr"?o("walkthrough.blocked.emptyDiff.description"):x==="commit"?o("commitComparison.emptyDiff"):o("diffView.branch.empty",{base:ms??""})}):t.jsx(Rf,{files:$e,onSelect:T=>{Ne.key&&F({type:"comparison",path:T,sourceKey:Ne.key})}}):t.jsx(st,{loading:!0,message:o("diffView.state.loadingChanges")});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"close",className:"size-5"})}):null,t.jsxs(ol,{open:V,onOpenChange:j,children:[t.jsx(al,{asChild:!0,children:t.jsxs(je,{variant:"outline",className:ll({size:"default"}),"data-mobile-comparison-trigger":!0,"aria-label":o("diffView.scope.selectorAria"),children:[t.jsx("span",{children:vt}),t.jsx(Q,{name:"arrow-down-s",className:"size-4"})]})}),t.jsx(cl,{align:"start",children:t.jsxs(ul,{value:x,onValueChange:T=>{(T==="working"||T==="branch"||T==="commit"||T==="pr")&&$(T)},children:[t.jsx(Ws,{value:"working",className:"min-h-8 items-center",children:o("mobile.nav.changes")}),Rt&&t.jsx(Ws,{value:"branch",className:"min-h-8 items-center",children:o("diffView.scope.branch")}),t.jsx(Ws,{value:"commit",className:"min-h-8 items-center",children:o("commitComparison.mode")}),t.jsx(Ws,{value:"pr",className:"min-h-8 items-center",children:o("session.githubIntegration.tabs.pullRequests")})]})})]}),r&&x==="branch"&&t.jsx(au,{mobile:!0,branches:g?.all??[],currentBranch:Ie,base:Ke.base,onSelect:T=>{Ie&&an(l,Ie,T)}},JSON.stringify([k,Ie])),r&&x==="commit"&&t.jsx(lu,{mobile:!0,commits:Qe.commits,selectedHash:ht,loading:Qe.loading,error:Qe.error,onSelect:Qe.select,onRefresh:()=>{Qe.refresh()}},JSON.stringify([k,Ie])),r&&x==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(ni,{mobile:!0,comparison:gt},JSON.stringify([k,Ie])),bt&&t.jsx(je,{variant:"ghost",size:"sm",disabled:Ne.loading,"aria-label":o("session.githubIssuePicker.actions.refresh"),onClick:()=>{Ne.refresh()},children:t.jsx(Q,{name:"refresh",className:"size-4"})})]})]}),x==="working"&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(pc,{currentBranch:p?.current,localBranches:Ft,remoteBranches:at,branchInfo:g?.branches,currentBranchAhead:p?.ahead,onCheckout:T=>{Wt(T)},onCreate:mt,remotes:De,disabled:b,directory:l,switchBlockedNotice:(p?.files?.length??0)>0?o("gitView.branch.switchBlockedNotice"):null})}),t.jsx(hc,{syncAction:z,remotes:De,onFetch:T=>{It("fetch",T)},onSync:T=>{It("sync",T)},disabled:q!==null||b,aheadCount:p?.ahead??0,behindCount:p?.behind??0,trackingRemoteName:p?.tracking?.split("/")[0],hasUncommittedChanges:We.length>0})]}),x!=="working"?t.jsx("div",{className:"min-h-0 flex-1",children:dn()}):We.length>0?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-4 pt-4",children:t.jsx(Qc,{groups:Ms,diffStats:p?.diffStats,revertingPaths:ce,onRevertAll:Pt,isRevertingAll:se,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:re})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(Zc,{stagedCount:it.length,commitMessage:W,onCommitMessageChange:te,generatedHighlights:ne,onInsertHighlights:un,onGenerateMessage:ds,isGeneratingMessage:O,onCommit:()=>{Tt({pushAfter:!1})},onCommitAndPush:()=>{Tt({pushAfter:!0})},commitAction:q,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(st,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})}),t.jsx(eu,{open:Fe!==null,onOpenChange:T=>{T||Le(null)},targetBranch:Fe??"",changedFileCount:p?.files?.length??0,onCommitAndSwitch:async(T,U)=>{const X=Fe;if(!X||!l)return;const Ce=p?.current??null;await a.createGitCommit(l,T,{addAll:!0});let Ge=null;if(U){const zs=p?.tracking?.split("/")[0],Vt=De.find(fn=>fn.name===zs)??De[0];try{if(!Vt)throw new Error(o("mobile.changes.noRemote"));await a.gitPush(l,p?.tracking?{remote:Vt.name}:{remote:Vt.name,branch:Ce??void 0,options:["--set-upstream"]}),Ge=Vt.name}catch{xe.error(o("gitView.dirtySwitch.pushFailed")),await Pe(),Le(null);return}}xe.success(Ce?Ge?o("gitView.toast.pushedToUpstream",{name:Ge}):o("gitView.dirtySwitch.committedNotPushed",{branch:Ce}):o("gitView.toast.commitCreated")),await Pe(),Le(null),await lt(X)},onGenerateMessage:async()=>{if(!l)return"";const T=(p?.files??[]).map(X=>X.path).sort(),{message:U}=await Qr(l,T);return U.subject?.trim()??""},onRevertAndSwitch:async()=>{const T=Fe;if(!T||!l)return;await Pt((p?.files??[]).map(X=>X.path));const U=await a.getGitStatus(l);if(!U.isClean&&(U.files?.length??0)>0){xe.error(o("gitView.dirtySwitch.revertIncomplete"));return}Le(null),await lt(T)}})]})},st=n=>{const e=me.c(13),{message:s,description:i,loading:r,icon:o}=n,a=r===void 0?!1:r,d=o===void 0?!1:o;let m;e[0]!==a?(m=a?t.jsx(Q,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=a,e[1]=m):m=e[1];let f;e[2]!==d?(f=d?t.jsx(Q,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=d,e[3]=f):f=e[3];let l;e[4]!==s?(l=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=l):l=e[5];let p;e[6]!==i?(p=i?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}):null,e[6]=i,e[7]=p):p=e[7];let g;return e[8]!==m||e[9]!==f||e[10]!==l||e[11]!==p?(g=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[m,f,l,p]})}),e[8]=m,e[9]=f,e[10]=l,e[11]=p,e[12]=g):g=e[12],g},Ei=n=>{const e=me.c(31),{path:s,subtitle:i,diff:r,staged:o,fileExists:a,unavailableReason:d,error:m,onBack:f,onRetry:l}=n,p=o===void 0?!1:o,g=d===void 0?null:d,{t:h}=be();let b;e[0]!==s?(b=dl(s)||"text",e[0]=s,e[1]=b):b=e[1];const S=b;let v;e[2]!==h?(v=h("header.actions.backAria"),e[2]=h,e[3]=v):v=e[3];let I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(Q,{name:"arrow-left",className:"size-5"}),e[4]=I):I=e[4];let w;e[5]!==f||e[6]!==v?(w=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":v,onClick:f,children:I}),e[5]=f,e[6]=v,e[7]=w):w=e[7];let C;e[8]!==s?(C=t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s}),e[8]=s,e[9]=C):C=e[9];let A;e[10]!==i?(A=i&&t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:i}),e[10]=i,e[11]=A):A=e[11];let y;e[12]!==C||e[13]!==A?(y=t.jsxs("div",{className:"min-w-0 flex-1 px-2",children:[C,A]}),e[12]=C,e[13]=A,e[14]=y):y=e[14];let E;e[15]!==w||e[16]!==y?(E=t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/70 px-3 text-foreground",children:[w,y]}),e[15]=w,e[16]=y,e[17]=E):E=e[17];let N;e[18]!==r||e[19]!==m||e[20]!==a||e[21]!==S||e[22]!==l||e[23]!==s||e[24]!==p||e[25]!==h||e[26]!==g?(N=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:a?g==="nested_repository"?t.jsx(st,{icon:!0,message:h("diffView.unavailable.nestedRepositoryTitle"),description:h("diffView.unavailable.nestedRepositoryDescription")}):g==="untracked_directory"?t.jsx(st,{icon:!0,message:h("diffView.unavailable.untrackedDirectoryTitle"),description:h("diffView.unavailable.untrackedDirectoryDescription")}):m?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:h("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:m}),t.jsx(je,{type:"button",size:"sm",variant:"outline",onClick:l,children:h("diffView.actions.retry")})]})}):r?r.submodule?t.jsx("div",{className:"p-3",children:t.jsx(fu,{state:r.submodule,staged:p})}):r.isBinary?t.jsx(st,{icon:!0,message:h("diffView.binary.unavailable")}):fl(s)&&!r.fileDiff?t.jsx(st,{icon:!0,message:h("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(sn,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(pu,{original:r.original,modified:r.modified,fileDiff:r.fileDiff,language:S,fileName:s,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):t.jsx(st,{loading:!0,message:h("diffView.state.loadingDiff")}):t.jsx(st,{icon:!0,message:h("mobile.changes.diffDetail.missingTitle"),description:h("mobile.changes.diffDetail.missingDescription")})}),e[18]=r,e[19]=m,e[20]=a,e[21]=S,e[22]=l,e[23]=s,e[24]=p,e[25]=h,e[26]=g,e[27]=N):N=e[27];let R;return e[28]!==E||e[29]!==N?(R=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[E,N]}),e[28]=E,e[29]=N,e[30]=R):R=e[30],R},Rf=n=>{const e=me.c(12),{files:s,onSelect:i}=n,{t:r}=be();let o;e[0]!==r?(o=r("gitView.changes.changedFilesAria"),e[0]=r,e[1]=o):o=e[1];let a;if(e[2]!==s||e[3]!==i||e[4]!==r){let m;e[6]!==i||e[7]!==r?(m=f=>{const l=f.status==="A"?r("diffView.change.new"):f.status==="D"?r("diffView.change.deleted"):f.status==="R"?r("diffView.change.renamed"):f.status==="C"?r("diffView.change.copied"):r("diffView.change.modified"),p=f.status==="A"?"var(--status-success)":f.status==="D"?"var(--status-error)":f.status==="R"||f.status==="C"?"var(--status-info)":"var(--status-warning)";return t.jsx("li",{children:t.jsxs(je,{variant:"ghost",size:"lg",className:"w-full justify-start gap-2.5 text-left normal-case",onClick:()=>i(f.path),children:[t.jsx("span",{className:"w-4 shrink-0 text-center typography-meta font-semibold uppercase",style:{color:p},"aria-label":l,children:f.status}),t.jsx(to,{filePath:f.path,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label",title:f.path,children:f.path}),(f.insertions>0||f.deletions>0)&&t.jsxs("span",{className:"shrink-0 typography-meta text-muted-foreground",children:["+",f.insertions," -",f.deletions]}),t.jsx(Q,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"})]})},f.path)},e[6]=i,e[7]=r,e[8]=m):m=e[8],a=s.map(m),e[2]=s,e[3]=i,e[4]=r,e[5]=a}else a=e[5];let d;return e[9]!==o||e[10]!==a?(d=t.jsx(sn,{className:"h-full overflow-y-auto overflow-x-hidden px-3 py-2",children:t.jsx("ul",{"aria-label":o,className:"flex flex-col gap-1",children:a})}),e[9]=o,e[10]=a,e[11]=d):d=e[11],d},Ef=u.lazy(()=>ns(()=>import("./FilesView-DtzJk1Ke.js").then(n=>n.F),__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])).then(n=>({default:n.FilesView}))),jt=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),Cs=n=>{const e=jt(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},If=n=>{const e=jt(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},Af=(n,e)=>{const s=jt(n),i=jt(e);return!i||s===i?Cs(s):s.startsWith(`${i}/`)?s.slice(i.length+1):s},Pf=n=>{if(typeof n!="number"||!Number.isFinite(n)||n<0)return"";if(n<1024)return`${n} B`;const e=["KB","MB","GB"];let s=n/1024;for(const i of e){if(s<1024||i===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${i}`;s/=1024}return""},Tf=n=>{const e=me.c(5),{onClose:s}=n,i=Jn()??null;let r;e[0]!==i?(r=jt(i),e[0]=i,e[1]=r):r=e[1];const o=r;let a;return e[2]!==s||e[3]!==o?(a=t.jsx(Df,{root:o,onClose:s},o),e[2]=s,e[3]=o,e[4]=a):a=e[4],a},Df=({root:n,onClose:e})=>{const{t:s}=be(),{files:i}=qn(),r=ga(W=>W.setSelectedPath),[o,a]=u.useState(()=>({type:"browser",directory:n})),[d,m]=u.useState([]),[f,l]=u.useState(!1),[p,g]=u.useState(null),[h,b]=u.useState(""),[S,v]=u.useState([]),[I,w]=u.useState(!1),C=u.useRef(0),A=o.type==="browser"?o.directory:o.returnDirectory,y=u.useRef(A);y.current=A;const E=u.useCallback(async W=>{if(!W)return;const te=C.current+1;C.current=te,l(!0),g(null);try{const ce=await i.listDirectory(W);if(C.current!==te)return;m(ce.entries.slice().sort((le,se)=>le.isDirectory!==se.isDirectory?le.isDirectory?-1:1:le.name.localeCompare(se.name)))}catch(ce){if(C.current!==te)return;m([]),g(ce instanceof Error?ce.message:s("mobile.files.error.listFailed"))}finally{C.current===te&&l(!1)}},[i,s]);u.useEffect(()=>{o.type==="browser"&&E(o.directory)},[E,o]);const N=u.useCallback(async W=>{jt(W)===jt(y.current)&&await E(y.current)},[E]),{canUpload:R,uploadingDirectory:k,pickFiles:P,uploadElements:B}=xc({root:n,refreshDirectory:N}),D=k!==null;u.useEffect(()=>{if(o.type!=="browser")return;const W=h.trim();if(!W){v([]),w(!1);return}let te=!1;const ce=window.setTimeout(()=>{w(!0),i.search({directory:o.directory,query:W,maxResults:40}).then(le=>{te||v(le)}).catch(()=>{te||v([])}).finally(()=>{te||w(!1)})},250);return()=>{te=!0,window.clearTimeout(ce)}},[i,h,o]);const x=W=>{b(""),a({type:"browser",directory:W})},_=W=>{r(n,W),a({type:"file",path:W,returnDirectory:A||n})},V=ze(W=>W.pendingFileFocusPath),j=ze(W=>W.pendingFileNavigation);if(u.useEffect(()=>{const W=jt(j?.path??V??"");!W||!n||W!==n&&!W.startsWith(`${n}/`)||(r(n,W),a({type:"file",path:W,returnDirectory:n}),V&&ze.getState().setPendingFileFocusPath(null))},[V,j,n,r]),!n)return t.jsx(Rs,{message:s("mobile.files.empty.noDirectory")});if(o.type==="file")return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/70 px-3 text-foreground",children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":s("header.actions.backAria"),onClick:()=>a({type:"browser",directory:o.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(ti,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:Cs(o.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Ve,{children:t.jsx(u.Suspense,{fallback:t.jsx(Rs,{loading:!0,message:s("filesView.state.loading")}),children:t.jsx(Ef,{mode:"editor-only"})})})})]});const $=o.directory===n?s("mobile.files.rootDirectory"):Cs(o.directory),F=h.trim()?S:[],z=If(o.directory),G=o.directory!==n&&z!==null&&(z===n||z.startsWith(`${n}/`)),q=G&&!h.trim(),Y=G?z:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[B,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[e?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":s("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Kc,{className:"size-5"})}):null,q&&Y?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":s("mobile.files.backToParentAria",{name:Cs(Y)}),onClick:()=>x(Y),style:{touchAction:"manipulation"},children:t.jsx(ti,{className:"size-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:$})}),t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":s("mobile.files.refreshAria"),onClick:()=>{E(o.directory)},style:{touchAction:"manipulation"},children:t.jsx(Gc,{className:Z("size-5",f&&"animate-spin")})}),R?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50","aria-label":s("sidebarFilesTree.actions.uploadFilesTitle"),onClick:()=>P(o.directory),disabled:D,style:{touchAction:"manipulation"},children:t.jsx(Q,{name:D?"loader-4":"upload-2",className:Z("size-5",D&&"animate-spin")})}):null]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(Hc,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(Xi,{value:h,onChange:W=>b(W.target.value),placeholder:s("mobile.files.search.placeholder"),className:"h-11 pl-9"})]})}),t.jsx(sn,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:p?t.jsx(Rs,{message:p}):h.trim()?t.jsx(_f,{results:F,isSearching:I,onOpenFile:_}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[d.length===0&&!f?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:s("mobile.files.empty.directory")}):null,d.map(W=>t.jsx(zo,{name:W.name,path:W.path,directory:W.isDirectory,meta:W.isDirectory?void 0:Pf(W.size),onClick:()=>W.isDirectory?x(W.path):_(W.path)},W.path))]})})]})},zo=n=>{const e=me.c(16),{name:s,path:i,directory:r,meta:o,onClick:a}=n;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={touchAction:"manipulation"},e[0]=d):d=e[0];let m;e[1]!==r||e[2]!==i?(m=r?t.jsx(Yc,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(to,{filePath:i,className:"size-5 shrink-0"}),e[1]=r,e[2]=i,e[3]=m):m=e[3];let f;e[4]!==s?(f=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=f):f=e[5];let l;e[6]!==o?(l=o?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:o}):null,e[6]=o,e[7]=l):l=e[7];let p;e[8]!==r?(p=r?t.jsx(Xc,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=r,e[9]=p):p=e[9];let g;return e[10]!==a||e[11]!==m||e[12]!==f||e[13]!==l||e[14]!==p?(g=t.jsxs("button",{type:"button",className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:a,style:d,children:[m,f,l,p]}),e[10]=a,e[11]=m,e[12]=f,e[13]=l,e[14]=p,e[15]=g):g=e[15],g},_f=n=>{const e=me.c(10),{results:s,isSearching:i,onOpenFile:r}=n,{t:o}=be(),a=jt(Jn()??null);if(i){let l;e[0]!==o?(l=o("common.loading"),e[0]=o,e[1]=l):l=e[1];let p;return e[2]!==l?(p=t.jsx(Rs,{loading:!0,message:l}),e[2]=l,e[3]=p):p=e[3],p}if(s.length===0){let l;e[4]!==o?(l=o("mobile.files.search.empty"),e[4]=o,e[5]=l):l=e[5];let p;return e[6]!==l?(p=t.jsx(Rs,{message:l}),e[6]=l,e[7]=p):p=e[7],p}const d="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",m=s.map(l=>t.jsx(zo,{name:Cs(l.path),path:l.path,directory:!1,meta:Af(l.path,a),onClick:()=>r(l.path)},l.path));let f;return e[8]!==m?(f=t.jsx("div",{className:d,children:m}),e[8]=m,e[9]=f):f=e[9],f},Rs=n=>{const e=me.c(7),{message:s,loading:i}=n,r=i===void 0?!1:i;let o;e[0]!==r?(o=r?t.jsx(qc,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(Jc,{className:"size-6 text-muted-foreground"}),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s?(a=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[2]=s,e[3]=a):a=e[3];let d;return e[4]!==o||e[5]!==a?(d=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[o,a]})}),e[4]=o,e[5]=a,e[6]=d):d=e[6],d},Ii="mobile-surface-root",Mf=16,Ai=320,zf="cubic-bezier(0.22, 1, 0.36, 1)",Of=n=>{const e=me.c(36),{onOpenMcpSettings:s}=n,{t:i}=be(),[r,o]=u.useState(!1),a=Nt(Lf),d=ws($f),m=es(Ff);let f;e[0]!==a||e[1]!==r||e[2]!==m||e[3]!==d?(f=()=>{if(r)return;o(!0);const P=new Promise(Wf);Promise.all([d({directory:a||null,silent:!0}),m({force:!0}),P]).finally(()=>o(!1))},e[0]=a,e[1]=r,e[2]=m,e[3]=d,e[4]=f):f=e[4];const l=f;let p;e[5]!==i?(p=i("settings.mcp.sidebar.actions.addServerTitle"),e[5]=i,e[6]=p):p=e[6];let g;e[7]!==i?(g=i("settings.mcp.sidebar.actions.addServerTitle"),e[7]=i,e[8]=g):g=e[8];let h,b;e[9]===Symbol.for("react.memo_cache_sentinel")?(h={touchAction:"manipulation"},b=t.jsx(Q,{name:"add",className:"size-5"}),e[9]=h,e[10]=b):(h=e[9],b=e[10]);let S;e[11]!==s||e[12]!==p||e[13]!==g?(S=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:s,"aria-label":p,title:g,style:h,children:b}),e[11]=s,e[12]=p,e[13]=g,e[14]=S):S=e[14];let v;e[15]!==i?(v=i("mcpDropdown.actions.refreshAria"),e[15]=i,e[16]=v):v=e[16];let I;e[17]!==i?(I=i("mcpDropdown.actions.refreshAria"),e[17]=i,e[18]=I):I=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w={touchAction:"manipulation"},e[19]=w):w=e[19];const C=r&&"animate-spin";let A;e[20]!==C?(A=Z("size-5",C),e[20]=C,e[21]=A):A=e[21];let y;e[22]!==A?(y=t.jsx(Q,{name:"refresh",className:A}),e[22]=A,e[23]=y):y=e[23];let E;e[24]!==r||e[25]!==l||e[26]!==y||e[27]!==v||e[28]!==I?(E=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:l,disabled:r,"aria-label":v,title:I,style:w,children:y}),e[24]=r,e[25]=l,e[26]=y,e[27]=v,e[28]=I,e[29]=E):E=e[29];let N;e[30]!==E||e[31]!==S?(N=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[S,E]}),e[30]=E,e[31]=S,e[32]=N):N=e[32];let R;e[33]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(wf,{active:!0,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=R):R=e[33];let k;return e[34]!==N?(k=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[N,R]}),e[34]=N,e[35]=k):k=e[35],k},Bf=({open:n,onClose:e,tab:s,onTabChange:i,pendingChangesDiff:r,onOpenPlan:o,onOpenMcpSettings:a,variant:d="drawer"})=>{const{t:m}=be(),f=u.useRef(null),l=u.useRef(null),[p,g]=u.useState(!1),[h,b]=u.useState(n),S=u.useRef(e);u.useEffect(()=>{S.current=e},[e]);const v=u.useRef(s);u.useEffect(()=>{v.current=s},[s]),xr(l,{enabled:d==="drawer"&&n,onLeftEdgeSwipe:()=>S.current()});const[I,w]=u.useState(()=>new Set);if(u.useEffect(()=>{n&&w(y=>{if(y.has(s))return y;const E=new Set(y);return E.add(s),E})},[n,s]),typeof document<"u"&&!f.current){let y=document.getElementById(Ii);y||(y=document.createElement("div"),y.id=Ii,document.body.appendChild(y)),f.current=y}if(u.useEffect(()=>{if(n){b(!0);const E=window.setTimeout(()=>g(!0),Mf);return()=>window.clearTimeout(E)}g(!1);const y=window.setTimeout(()=>b(!1),Ai+40);return()=>window.clearTimeout(y)},[n]),u.useEffect(()=>{if(!n)return;const y=document.body.style.overflow;d==="drawer"&&(document.body.style.overflow="hidden");const E=N=>{N.key!=="Escape"||v.current==="terminal"||pl(N.target)||S.current()};return document.addEventListener("keydown",E),()=>{d==="drawer"&&(document.body.style.overflow=y),document.removeEventListener("keydown",E)}},[n,d]),d==="drawer"&&!f.current)return null;const C=[{id:"changes",label:m("mobile.menu.changes"),icon:t.jsx(Q,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:m("mobile.menu.files"),icon:t.jsx(Q,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:m("mobile.menu.terminal"),icon:t.jsx(Q,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:m("contextRail.surface.notes"),icon:t.jsx(Q,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:m("mobile.menu.mcp"),icon:t.jsx(ml,{className:"h-3.5 w-3.5"})}],A=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("div",{className:"flex h-9 min-w-0 flex-1 items-center",children:h?t.jsx(yc,{items:C,activeId:s,onSelect:y=>i(y),layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:!0,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-mr-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":m("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[I.has("changes")?t.jsx("div",{className:Z("h-full",s!=="changes"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(Nf,{visible:n&&s==="changes",initialDiff:r})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,I.has("files")?t.jsx("div",{className:Z("h-full",s!=="files"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(Tf,{})})}):null,I.has("terminal")?t.jsx("div",{className:Z("h-full",s!=="terminal"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(vc,{visible:n&&s==="terminal"})})}):null,I.has("notes")?t.jsx("div",{className:Z("h-full",s!=="notes"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(wc,{onActionComplete:e,onOpenPlan:o})})}):null,I.has("mcp")?t.jsx("div",{className:Z("h-full",s!=="mcp"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(Of,{onOpenMcpSettings:a})})}):null]})]});return d==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:A}):ss.createPortal(t.jsx("section",{ref:l,role:"dialog","aria-modal":"true","aria-label":m("mobile.header.openWorkspaceAria"),"aria-hidden":!n,className:"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:p?"none":"translateX(100%)",transition:`transform ${Ai}ms ${zf}`,visibility:h?"visible":"hidden",pointerEvents:n?"auto":"none"},children:A}),f.current)};function Lf(n){return n.currentDirectory}function $f(n){return n.refresh}function Ff(n){return n.loadMcpConfigs}function Wf(n){return window.setTimeout(n,500)}function Vf(n){const e=me.c(4),s=2500,{uiFont:i}=hl(),[r,o]=u.useState(!1);let a,d;return e[0]!==s||e[1]!==i?(a=()=>{let m=!1;const f=()=>{m||o(!0)},l=()=>{requestAnimationFrame(()=>requestAnimationFrame(f))},p=Promise.all([gl(i).catch(qf),document.fonts?.ready?.then(Hf).catch(Gf)??Promise.resolve(),hu.catch(Kf)]).then(Uf),g=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([p,g]).then(l),()=>{m=!0}},d=[i,s],e[0]=s,e[1]=i,e[2]=a,e[3]=d):(a=e[2],d=e[3]),u.useEffect(a,d),r}function Uf(){}function Kf(){}function Gf(){}function Hf(){}function qf(){}const Jf="openchamber",Yf=n=>n.replace(/^\/+|\/+$/g,""),Xf=n=>{const e=Yf(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function Qf(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${Jf}:`)return null;const s=Xf(e),i=(s[0]??"").toLowerCase(),r=s.slice(1),o=e.searchParams;switch(i){case"session":{const a=r[0]||o.get("id")||"";return a?{type:"session",sessionId:a,directory:o.get("dir")??void 0}:null}case"new":case"new-session":return{type:"new-session",directory:o.get("dir")??void 0,projectId:o.get("project")??void 0,agent:o.get("agent")??void 0,model:o.get("model")??void 0};case"sessions":{const a=o.get("filter");return{type:"sessions",filter:a==="attention"||a==="recent"||a==="all"?a:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:r[0]||o.get("section")||void 0};case"changes":return{type:"changes",path:r.join("/")||o.get("path")||void 0,staged:o.get("staged")==="true"};case"view":{const a=(r[0]||"").toLowerCase();return a==="changes"?{type:"changes"}:a==="files"||a==="mcp"||a==="instances"||a==="update"?{type:"view",target:a}:null}default:return null}}let et={},Oo=!1,Ns=null;const Zf=n=>{switch(n.type){case"session":return Re.getState().setCurrentSession(n.sessionId,n.directory??null),!0;case"new-session":{const e=Re.getState();return e.openNewSessionDraft(),(n.directory||n.projectId)&&e.setNewSessionDraftTarget({directoryOverride:n.directory??null,projectId:n.projectId??null,selectedProjectId:n.projectId??null}),!0}case"sessions":return et.openSessions?(et.openSessions(n.filter),!0):!1;case"status":return et.openSessions?(et.openSessions(),!0):!1;case"view":return et.openView?(et.openView(n.target),!0):!1;case"changes":return et.openChanges?(et.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return et.openSettings?(et.openSettings(n.section),!0):!1}},yr=()=>{if(!Oo||!Ns)return;const n=Ns;Ns=null,Zf(n)||(Ns=n)},Bo=n=>{Ns=n,yr()},Pi=n=>{const e=Qf(n);e&&Bo(e)},em=n=>{Oo=n,yr()},tm=n=>{const e=me.c(3);let s,i;e[0]!==n?(s=()=>(et=n,yr(),()=>{et===n&&(et={})}),i=[n],e[0]=n,e[1]=s,e[2]=i):(s=e[1],i=e[2]),u.useEffect(s,i)},sm=n=>{const{ready:e}=n;u.useEffect(()=>{em(e)},[e]),u.useEffect(()=>{if(!Be())return;let s=!1;const i=[];return ns(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([128,1,129])).then(async({App:r})=>{if(s)return;const o=await r.addListener("appUrlOpen",a=>{Pi(a?.url)});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),ns(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([130,129])).then(async({PushNotifications:r})=>{if(s)return;const o=await r.addListener("pushNotificationActionPerformed",a=>{const d=a?.notification?.data,m=typeof d?.url=="string"?d.url:typeof d?.deeplink=="string"?d.deeplink:void 0;if(m){Pi(m);return}const f=typeof d?.sessionId=="string"?d.sessionId:void 0;f&&Bo({type:"session",sessionId:f})});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),()=>{s=!0,i.forEach(r=>r())}},[])},nm=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},rm=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},im=n=>{const{enabled:e}=n,s=ze(r=>r.nativeNotificationsEnabled),i=u.useRef(null);u.useEffect(()=>{if(!e||!s||!rm())return;let r=!1;const o=[];return ns(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([130,129])).then(async({PushNotifications:a})=>{if(r)return;let d=await a.checkPermissions().catch(()=>null);if(d?.receive!=="granted"&&(d=await a.requestPermissions().catch(()=>null)),d?.receive!=="granted")return;const m=await a.addListener("registration",l=>{i.current=l.value,Gr()?.push?.registerApnsToken?.({token:l.value,platform:zi(),environment:nm()})}),f=await a.addListener("registrationError",l=>{console.warn("[Push] APNs registration error:",l)});if(await a.register().catch(()=>{}),r){m.remove(),f.remove();return}o.push(()=>{m.remove()},()=>{f.remove()})}).catch(()=>{}),()=>{r=!0,o.forEach(a=>a())}},[e,s]),u.useEffect(()=>{if(s)return;const r=i.current;if(!r)return;i.current=null,Gr()?.push?.unregisterApnsToken?.({token:r})},[s])},Ti=n=>{const e=me.c(12),{side:s,isResizing:i,ariaLabel:r,handleProps:o}=n,a=s==="left"?"right-0":"left-0";let d;e[0]!==a?(d=Z("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",a),e[0]=a,e[1]=d):d=e[1];const m=s==="left"?"right-0":"left-0",f=i&&"bg-[var(--interactive-border)]";let l;e[2]!==m||e[3]!==f?(l=Z("absolute inset-y-0 w-[3px] transition-colors",m,f),e[2]=m,e[3]=f,e[4]=l):l=e[4];let p;e[5]!==l?(p=t.jsx("div",{className:l}),e[5]=l,e[6]=p):p=e[6];let g;return e[7]!==r||e[8]!==o||e[9]!==d||e[10]!==p?(g=t.jsx("div",{className:d,role:"separator","aria-orientation":"vertical","aria-label":r,...o,children:p}),e[7]=r,e[8]=o,e[9]=d,e[10]=p,e[11]=g):g=e[11],g},om=320,am=380,Di=280,lm=560,cm=900;function _i(n,e,s,i){const r=me.c(23),o=i===void 0?lm:i,a=u.useRef(null);let d;r[0]!==s||r[1]!==o||r[2]!==e?(d=()=>{if(typeof window>"u")return s;const x=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(x)?Math.min(o,Math.max(Di,x)):s},r[0]=s,r[1]=o,r[2]=e,r[3]=d):d=r[3];const[m,f]=u.useState(d),[l,p]=u.useState(!1),g=u.useRef(0),h=u.useRef(m),b=u.useRef(null),S=u.useRef(null);let v;r[4]!==o?(v=x=>Math.min(o,Math.max(Di,Math.round(x))),r[4]=o,r[5]=v):v=r[5];const I=v;let w;r[6]===Symbol.for("react.memo_cache_sentinel")?(w=x=>{const _=a.current;_&&(_.style.width=`${x}px`,_.style.minWidth=`${x}px`,_.style.maxWidth=`${x}px`,_.style.setProperty("--oc-ipad-sidebar-width",`${x}px`))},r[6]=w):w=r[6];const C=w;let A;r[7]!==m?(A=x=>{try{x.currentTarget.setPointerCapture(x.pointerId)}catch{}S.current=x.pointerId,g.current=x.clientX,h.current=m,b.current=m,p(!0),x.preventDefault()},r[7]=m,r[8]=A):A=r[8];const y=A;let E;r[9]!==I||r[10]!==n?(E=x=>{if(S.current!==x.pointerId)return;const _=x.clientX-g.current,V=I(h.current+(n==="left"?_:-_));b.current!==V&&(b.current=V,C(V))},r[9]=I,r[10]=n,r[11]=E):E=r[11];const N=E;let R;r[12]!==I||r[13]!==e?(R=x=>{if(S.current!==x.pointerId)return;try{x.currentTarget.releasePointerCapture(x.pointerId)}catch{}const _=I(b.current??h.current);S.current=null,b.current=null,p(!1),f(_);try{window.localStorage.setItem(e,String(_))}catch{}},r[12]=I,r[13]=e,r[14]=R):R=r[14];const k=R;let P;r[15]!==y||r[16]!==k||r[17]!==N?(P={onPointerDown:y,onPointerMove:N,onPointerUp:k,onPointerCancel:k},r[15]=y,r[16]=k,r[17]=N,r[18]=P):P=r[18];const B=P;let D;return r[19]!==B||r[20]!==l||r[21]!==m?(D={asideRef:a,width:m,isResizing:l,handleProps:B},r[19]=B,r[20]=l,r[21]=m,r[22]=D):D=r[22],D}const um=["general","appearance","chat","notifications","sessions","routing","git","magic-prompts","snippets","behavior","agents","commands","mcp","plugins","skills.installed","skills.catalog","providers","web-search","usage","voice","integrations","about"],dm=1e3,fm=({onActiveConnectionDeleted:n})=>{const{t:e}=be();Tc();const[s,i]=u.useState(!1);u.useEffect(()=>Re.subscribe((J,de)=>{J.currentSessionId&&J.currentSessionId!==de.currentSessionId&&ze.getState().setRunOverviewKey(null)}),[]);const r=ze(J=>J.runOverviewKey!==null);u.useEffect(()=>{r&&i(!1)},[r]);const[o,a]=u.useState(null),[d,m]=u.useState(!1),[f,l]=u.useState("changes"),[p,g]=u.useState(null),[h,b]=u.useState("nav"),[S,v]=u.useState(null),I=ze(J=>J.setSettingsPage),w=ze(J=>J.wideChatLayoutEnabled),C=Xt(J=>J.available),A=Xt(J=>J.runtimeType),y=u.useMemo(()=>Yn(),[]),E=es(J=>J.mcpServers),N=es(J=>J.setMcpDraft),R=es(J=>J.setSelectedMcp),k=u.useCallback(()=>{a(null),g(null)},[]),P=u.useCallback(J=>{a(J)},[]),B=u.useCallback(()=>{m(!1)},[]),D=u.useCallback(J=>{b(J),P("settings")},[P]),{enabled:x,roomyForPanels:_}=Vn(),j=Bl()==="portrait",$=Ll(),[F,z]=u.useState(()=>$l().roomyForPanels),G=u.useCallback(()=>{z(J=>!J)},[]);u.useEffect(()=>{x||z(!1)},[x]);const q=u.useCallback(()=>{v(null),l("files"),m(!0)},[]);u.useEffect(()=>so(J=>{if(J.type!=="file-open-request")return;const de=J.directory??Nt.getState().currentDirectory;de&&(ze.getState().openContextFile(de,J.path),q())}),[q]);const Y=u.useCallback((J=null)=>{v(J),l("changes"),m(!0)},[]),W=_i("left","openchamber.ipad.leftSidebarWidth",om),te=_i("right","openchamber.ipad.rightSidebarWidth",am,cm),ce=_,le=ce&&d?te.width:0,se=x&&F?W.width:0;u.useEffect(()=>{if(typeof document>"u")return;const J=document.documentElement;return J.style.setProperty("--oc-chat-inset-left",`${se}px`),J.style.setProperty("--oc-chat-inset-right",`${le}px`),()=>{J.style.removeProperty("--oc-chat-inset-left"),J.style.removeProperty("--oc-chat-inset-right")}},[se,le]),u.useEffect(()=>{if(typeof document>"u")return;const J=document.documentElement;return J.classList.toggle("wide-chat-layout",w),()=>J.classList.remove("wide-chat-layout")},[w]),u.useEffect(()=>{if(typeof document>"u")return;const J=x&&(j||$),de=document.documentElement;return de.classList.toggle("oc-keep-draft-starters",J),()=>de.classList.remove("oc-keep-draft-starters")},[$,x,j]);const ie=u.useMemo(()=>({openChanges:({diffPath:J,staged:de}={})=>{Y(J?{path:J,staged:de===!0}:null)},openFiles:()=>q(),openSettings:()=>D("nav")}),[Y,q,D]),O=u.useMemo(()=>({openSessions:()=>{x?z(!0):i(!0)},openView:J=>{if(J==="files"){q();return}if(J==="mcp"){l("mcp"),m(!0);return}P(J)},openChanges:({path:J,staged:de}={})=>{Y(J?{path:J,staged:de===!0}:null)},openSettings:J=>{J&&I(J),D(J?"page-content":"nav")}}),[x,Y,q,D,P,I]);tm(O);const ee=u.useRef(null);xr(ee,{onLeftEdgeSwipe:()=>{x?z(!0):i(!0)},onRightEdgeSwipe:()=>m(!0)});const ne=u.useRef(null),ae=u.useCallback(J=>{ne.current=J},[]),H=u.useCallback(()=>p?(g(null),!0):o==="settings"&&ne.current?.()?!0:o?(k(),!0):d?(B(),!0):s?(i(!1),!0):!1,[o,k,B,p,s,d]);Fl(H);const re=!y&&C&&(A==="desktop"||A==="web"),ue=x?"dialog":"fullscreen",ye=u.useMemo(()=>({instanceLabel:y?js():null,onOpenInstances:y?()=>P("instances"):void 0,onOpenSettings:()=>D("nav"),onOpenUsage:()=>P("usage"),onOpenUpdate:re?()=>P("update"):void 0}),[D,P,y,re]),he=u.useCallback(()=>{const J="new-mcp-server";let de=J,Se=1;for(;E.some(ve=>ve.name===de);)de=`${J}-${Se}`,Se+=1;N({name:de,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1}),R(de),I("mcp"),D("page-content")},[E,D,N,R,I]);return t.jsx(Wl,{actions:ie,children:t.jsxs("div",{className:"oc-mobile-app-shell main-content-safe-area flex h-[100dvh] flex-row bg-background text-foreground","data-page-scroll-lock":"true",children:[x?t.jsxs("aside",{ref:W.asideRef,className:Z("relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!F&&"border-r-0"),style:{width:F?W.width:0,minWidth:F?W.width:0,maxWidth:F?W.width:0,"--oc-ipad-sidebar-width":`${W.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:W.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!F,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:Z("flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",W.isResizing&&"pointer-events-none",!F&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Ve,{children:t.jsx(ji,{open:!0,variant:"sidebar",onOpenChange:J=>{!J&&!_&&z(!1)},footer:ye})})}),F?t.jsx(Ti,{side:"left",isResizing:W.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:W.handleProps}):null]}):null,t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col","data-page-scroll-lock":"true",children:[t.jsx(Nd,{onOpenSessions:()=>x?G():i(!0),onOpenWorkspace:()=>m(!0),compactTitle:x}),t.jsxs("main",{ref:ee,className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[t.jsx("div",{className:"h-full w-full",children:t.jsx(Ve,{children:t.jsx(Dc,{})})}),t.jsx(Ve,{children:t.jsx(_c,{})})]})]}),x?null:t.jsx(ji,{open:s,onOpenChange:i,footer:ye}),t.jsxs("aside",{ref:te.asideRef,className:Z("relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!le&&"border-l-0"),style:{width:le,minWidth:le,maxWidth:le,"--oc-ipad-sidebar-width":`${te.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:te.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!le,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:Z("flex h-full min-h-0 shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",te.isResizing&&"pointer-events-none",!le&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Ve,{children:t.jsx(Bf,{open:d,onClose:B,tab:f,onTabChange:l,pendingChangesDiff:S,onOpenPlan:g,onOpenMcpSettings:he,variant:ce?"panel":"drawer"})})}),le?t.jsx(Ti,{side:"right",isResizing:te.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:te.handleProps}):null]}),p?t.jsx(qt,{open:!0,variant:ue,onClose:()=>g(null),ariaLabel:p.title,title:p.title,children:t.jsx(Ve,{children:t.jsx(Lc,{savedProjectPlan:{projectRef:p.projectRef,planId:p.id},onNavigatedToChat:()=>{k(),B()}})})}):null,o==="instances"&&y?t.jsx(qt,{open:!0,variant:ue,dialogAlign:"app",onClose:k,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(Ad,{onConnect:k,onActiveConnectionDeleted:n})}):null,o==="settings"?t.jsx(qt,{open:!0,variant:ue,dialogAlign:"app",onClose:k,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Ve,{children:t.jsx(Oc,{forceMobile:!0,isWindowed:!0,initialMobileStage:h,registerBackHandler:ae,visiblePageSlugs:[...um],onClose:k})})}):null,o==="usage"?t.jsx(qt,{open:!0,variant:ue,dialogAlign:"app",onClose:k,ariaLabel:e("usageStats.title"),title:e("usageStats.title"),children:t.jsx(Ve,{children:t.jsx(Mc,{})})}):null,o==="update"?t.jsx(qt,{open:!0,variant:ue,dialogAlign:"app",onClose:k,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Ve,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(Bc,{initialUpdateDialogOpen:!0})})})}):null]})})};function Mi({apis:n}){const e=ze(O=>O.isolatedSpacesEnabled),{t:s}=be(),i=tt(O=>O.initializeApp),r=tt(O=>O.isInitialized),o=tt(O=>O.isConnected),a=tt(O=>O.connectionPhase),d=tt(O=>O.providers.length),m=tt(O=>O.agents.length),f=tt(O=>O.loadProviders),l=tt(O=>O.loadAgents),p=Nt(O=>O.currentDirectory),g=Re(O=>O.error),h=Re(O=>O.clearError),b=ze(O=>O.setIsMobile),S=bl(O=>O.refreshStatus),v=xl(O=>O.refreshStatus),I=yl(O=>O.setPlanModeEnabled),w=Ye(O=>O.projects),C=Zt(O=>O.activeSessions),A=Zt(O=>O.archivedSessions),y=Zt(O=>O.status==="ready"),E=u.useMemo(()=>[...C,...A],[C,A]);kc({hasAuthoritativeGlobalSessions:y,sessions:E});const[N,R]=u.useState(0),[k,P]=u.useState(0),[B,D]=u.useState(!1),[x,_]=u.useState("pending"),[V,j]=u.useState(null),$=u.useMemo(()=>js(),[]),[,F]=u.useReducer(O=>O+1,0),z=u.useMemo(()=>Yn(),[]),G=u.useRef(0),q=u.useRef(0),Y=u.useCallback(()=>{const O=ft(),ee=q.current+1;if(q.current=ee,!O){bs("resume:auto-connect",{}),xs();return}bs("resume:reprobe",{});const ne=()=>{i(),S(n.github,{force:!0}),v(n.linear,{force:!0}),d===0&&f({source:"mobileApp:nativeResume"}),m===0&&l({source:"mobileApp:nativeResume"})},ae=re=>{bs("resume:disconnect",{reason:re}),Jt({apiBaseUrl:"",clientToken:null,runtimeKey:Fs}),R(ue=>ue+1)};Gs().then(re=>{if(q.current===ee){if(re==="no-connection"){ae("no-connection");return}if(re==="needs-login"){j({kind:"auth-expired",label:js()??""}),ae("needs-login");return}if(re==="unreachable"){const ue=[4e3,1e4],ye=he=>{window.setTimeout(()=>{if(q.current!==ee)return;const J=he===ue.length-1;Gs({fast:!J}).then(de=>{if(q.current===ee&&de!=="switched"){if(de==="unchanged"){ne();return}if(de==="needs-login"){j({kind:"auth-expired",label:js()??""}),ae("retry-needs-login");return}if(!J){ye(he+1);return}ae(`retry-${de}`)}})},ue[he])};ye(0);return}re!=="switched"&&ne()}});const H=Date.now();H-G.current>=dm&&(G.current=H,window.dispatchEvent(new Event("openchamber:system-resume")))},[m,n.github,n.linear,i,l,f,d,S,v]);vl(),wl(Y),u.useEffect(()=>{if(!z)return;let O;const ee=()=>{window.clearTimeout(O),O=window.setTimeout(()=>Y(),1500)};return window.addEventListener("online",ee),()=>{window.removeEventListener("online",ee),window.clearTimeout(O)}},[z,Y]),u.useEffect(()=>{if(z)return Hr.subscribe((O,ee)=>{O.state==="expired"&&ee.state!=="expired"&&(Y(),Hr.getState().markAuthenticated())})},[z,Y]),u.useEffect(()=>(qr(n),()=>qr(null)),[n]),u.useEffect(()=>Bi(O=>{if(bs("endpoint:changed",{runtimeKey:O.runtimeKey||"none",previousRuntimeKey:O.previousRuntimeKey||"none",connected:!!O.apiBaseUrl}),!!O.runtimeKey&&O.runtimeKey===O.previousRuntimeKey){Sc(),F();return}Nc(O),P(ne=>ne+1),R(ne=>ne+1)}),[]),u.useEffect(()=>{if(!z||o||ft()){_("done");return}let O=!1;return _("attempting"),(async()=>{const ee=await xs().catch(()=>({status:"no-candidate"}));O||(ee.status==="unreachable"?j({kind:"unreachable",label:ee.label}):ee.status==="needs-login"&&j({kind:"auth-expired",label:ee.label}),_("done"),ee.status==="unreachable"&&xs({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{O=!0}},[]),u.useEffect(()=>{if(!z||!ft())return;let O=!1;const ee=ne=>{bs("cold-launch:drop",{kind:ne?.kind??"unknown"}),ne&&j(ne),Jt({apiBaseUrl:"",clientToken:null,runtimeKey:Fs}),R(ae=>ae+1)};return Gs().then(async ne=>{if(O||ne==="switched"||ne==="unchanged")return;const ae=js();if(ne==="needs-login"){ee({kind:"auth-expired",label:ae??""});return}if(ne==="unreachable"){ee(ae?{kind:"unreachable",label:ae}:null),xs({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const H=await xs().catch(()=>({status:"no-candidate"}));O||H.status==="connected"||(H.status==="needs-login"?ee({kind:"auth-expired",label:H.label}):H.status==="unreachable"?ee({kind:"unreachable",label:H.label}):ee(null))}),()=>{O=!0}},[]),u.useEffect(()=>{b(!0)},[b]),u.useEffect(()=>{z&&!ft()||i()},[N,i,z]),u.useEffect(()=>{o&&(d===0&&f({source:"mobileApp:recovery"}),m===0&&l({source:"mobileApp:recovery"}))},[m,o,l,f,d]);const W=u.useRef(!1),[te,ce]=u.useState(z);u.useEffect(()=>{if(!z||!o||W.current)return;if(Re.getState().currentSessionId){W.current=!0,ce(!1);return}const O=ls(),ee=jl(O);if(!ee){W.current=!0,ce(!1);return}let ne=!1;const ae=window.setTimeout(()=>ce(!1),6e3);return(async()=>{const H=await Hn().catch(()=>null);if(ne)return;if(!H){ce(!1);return}W.current=!0;const re=H.activeSessions.find(ye=>ye.id===ee.sessionId);if(!re){kl(O),ce(!1);return}const ue=Re.getState();ue.currentSessionId||ue.setCurrentSession(re.id,Wn(re)??ee.directory??void 0),ce(!1)})(),()=>{ne=!0,window.clearTimeout(ae)}},[N,o,z]),u.useEffect(()=>{o&&Jr.setDirectory(p)},[p,o]),u.useEffect(()=>{o&&(S(n.github,{force:!0}),v(n.linear,{force:!0}))},[n.github,n.linear,o,S,v]),u.useEffect(()=>{if(!o||w.length===0)return;let O=!1;return(async()=>{const ne=new Map(Re.getState().availableWorktreesByProject);if(await Promise.all(w.map(async re=>{const ue=re.path.replace(/\\/g,"/").replace(/\/+$/,"");if(ue)try{if(!(Je.getState().directories.get(ue)?.isGitRepo??await ns(()=>import("./useAppFontEffects-FdVEdwq7.js").then(de=>de.m9),__vite__mapDeps([10,2,3,4,5,1,6,7,8,9,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])).then(de=>de.checkIsGitRepository(ue))))return;const J=await Zi({id:re.id,path:ue});if(O)return;ne.set(ue,J)}catch{}})),O)return;const ae=eo(w,ne),H=Re.getState().availableWorktreesByProject;zl(ae,H)||Re.setState({availableWorktrees:[...ae.values()].flat(),availableWorktreesByProject:ae})})(),()=>{O=!0}},[o,w]),u.useEffect(()=>{if(!o)return;let O=!1;const ee=so(ne=>{ne.type==="worktree-changed"&&Ol(w,ne.directories,()=>O)});return()=>{O=!0,ee()}},[o,w]),u.useEffect(()=>{let O=!1;return(async()=>{const ne=await Fn("/health",{method:"GET"}).catch(()=>null);if(!ne||!ne.ok||O)return;const ae=await ne.json().catch(()=>null);if(!ae||O)return;const H=ae.planModeExperimentalEnabled;I(H===!0||H===1||H==="1"||H==="true")})(),()=>{O=!0}},[I]),u.useEffect(()=>{if(!g)return;const O=window.setTimeout(()=>h(),5e3);return()=>window.clearTimeout(O)},[h,g]),u.useEffect(()=>{if(!(!o&&(z?!!ft():!0))){D(!1);return}const ee=window.setTimeout(()=>{D(!0)},z?4e3:8e3);return()=>window.clearTimeout(ee)},[o,z,N,k]),Sl(),Nl({enabled:!0}),Cc(),Cl(),Rl(),Rc(),im({enabled:z&&o}),sm({ready:z&&o&&r});const le=Vf(),se=!o&&a==="reconnecting";if(!le)return t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:t.jsx(Yt,{width:120,height:120,isAnimated:!0,variant:"splash"})});const ie=!!ft();return z&&(!ie||!o&&!se)?ie?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] px-6 text-center text-foreground",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-4",children:[t.jsx(Yt,{width:120,height:120,isAnimated:!B,variant:"splash"}),B?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:s("mobile.connect.recovery.description")})]}),t.jsx(je,{type:"button",variant:"outline",onClick:()=>{Jt({apiBaseUrl:"",clientToken:null,runtimeKey:Fs}),R(O=>O+1)},children:s("mobile.connect.cancelPassword")})]}):null]})}):x!=="done"?t.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:[t.jsx(Yt,{width:120,height:120,isAnimated:!0,variant:"splash"}),$?t.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[t.jsx("p",{className:"typography-small text-muted-foreground",children:s("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[$,t.jsx(El,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(cd,{onConnected:()=>R(O=>O+1),notice:V})}):!o&&!se?B?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"max-w-sm space-y-3",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:s("sessionAuth.error.networkDescription")})]})}):t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:t.jsx(Yt,{width:120,height:120,isAnimated:!0,variant:"splash"})}):t.jsx(Ve,{children:t.jsx(Il,{sdk:Jr.getSdkClient(),directory:p||"",children:t.jsx(Al,{apis:n,children:t.jsx(Pl,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(Ec,{ready:!z||!te,animated:!0}),t.jsx(Tl,{embeddedBackgroundWorkEnabled:r}),t.jsx(Ic,{}),t.jsx(Su,{}),t.jsx(fm,{onActiveConnectionDeleted:()=>{Jt({apiBaseUrl:"",clientToken:null,runtimeKey:Fs}),R(O=>O+1)}}),t.jsx(Dl,{}),t.jsx(_l,{}),e?t.jsx(Ac,{}):null,t.jsx(Ml,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),r?t.jsx(Pc,{}):null]})})})},k)})}function mm(n){const e=me.c(4),s=u.useSyncExternalStore(pm,ft,ft);if(Yn()&&!s){let r;return e[0]!==n?(r=t.jsx(Mi,{...n}),e[0]=n,e[1]=r):r=e[1],r}let i;return e[2]!==n?(i=t.jsx(jc,{children:t.jsx(Mi,{...n})}),e[2]=n,e[3]=i):i=e[3],i}function pm(n){return Bi(()=>n())}const hm=()=>{Jl(),ba().then(()=>{Promise.all([xa(),Yl()]).catch(n=>{console.error("[mobile-main] settings init failed:",n)}),Xl(),Ql(),Zl()}).catch(n=>{console.error("[mobile-main] appearance init failed:",n)}).finally(()=>{gu()})};function qh(n){window.__OPENCHAMBER_SURFACE__="mobile",Vl(),hm(),ku(),Ul();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const i=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",r=i?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,o=t.jsx(mm,{apis:r});la.createRoot(e).render(t.jsx(Pn.StrictMode,{children:t.jsx(Kl,{children:t.jsx(Gl,{children:t.jsx(Hl,{children:t.jsx(zc,{children:i?o:t.jsx(ql,{children:o})})})})})}))}export{qh as renderMobileApp};