@openchamber/web 1.18.4 → 1.19.0

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 (207) hide show
  1. package/README.md +1 -0
  2. package/dist/assets/{CodeMirrorCommentWidgets-4qZbrEXU.js → CodeMirrorCommentWidgets-DAvopJvy.js} +1 -1
  3. package/dist/assets/{CommitSection-MJmntVPJ.js → CommitSection-D9cV-qR9.js} +1 -1
  4. package/dist/assets/{DiagramEditor-jnG3Hbxg.js → DiagramEditor-B9NCadU7.js} +1 -1
  5. package/dist/assets/DiagramView-LKGBwf4G.js +1 -0
  6. package/dist/assets/{DiffView-DZIoOnV7.js → DiffView-BWNq-0ov.js} +2 -2
  7. package/dist/assets/FilesView-DB-Q0Gkz.js +14 -0
  8. package/dist/assets/{GitView-DBFrDDBv.js → GitView-DsWXqWx3.js} +3 -3
  9. package/dist/assets/{JsonTreeView-DLW2Wy1g.js → JsonTreeView-h4dHASlq.js} +1 -1
  10. package/dist/assets/MarkdownImageGallery-n0ikH-xm.js +1 -0
  11. package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +12 -0
  12. package/dist/assets/OnboardingScreen-CDjgzxEe.js +1 -0
  13. package/dist/assets/{PatchDiff-BuLPx7AN.js → PatchDiff-jPKTJje5.js} +1 -1
  14. package/dist/assets/{PierreDiffViewer-BHm4Yr0X.js → PierreDiffViewer-D_Gt4A_6.js} +1 -1
  15. package/dist/assets/PlanView-UvuxIl9-.js +4 -0
  16. package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +1 -0
  17. package/dist/assets/SettingsView-3B9VN6Ys.js +28 -0
  18. package/dist/assets/SettingsWindow-CqQNDKNd.js +1 -0
  19. package/dist/assets/{ToolOutputDialog-Za6V4VMJ.js → ToolOutputDialog-PmjlAxVE.js} +6 -6
  20. package/dist/assets/{ToolPartDiffPreview-BL-9ixyC.js → ToolPartDiffPreview-B34Xw9wq.js} +1 -1
  21. package/dist/assets/{VirtualizedFileDiff-CwGocYQd.js → VirtualizedFileDiff-B37yB9jZ.js} +3 -3
  22. package/dist/assets/{WalkthroughView-5DyvN03T.js → WalkthroughView-Bxun3k66.js} +2 -2
  23. package/dist/assets/{computeVirtualFileMetrics-Da00Jg7M.js → computeVirtualFileMetrics-DYFv_yZS.js} +2 -2
  24. package/dist/assets/contextPanelEmbeddedChat-BO1wRpaN.js +1 -0
  25. package/dist/assets/de-DbV6CLxv.js +9 -0
  26. package/dist/assets/document-attachments-DFAWlG3U.js +31 -0
  27. package/dist/assets/es-CVDlyzZ4.js +15 -0
  28. package/dist/assets/fr-Czc-p0g-.js +13 -0
  29. package/dist/assets/index-1OhiMDBz.css +1 -0
  30. package/dist/assets/index-BSvmTvZl.js +1 -0
  31. package/dist/assets/index-DzriVon2.js +7 -0
  32. package/dist/assets/{isDiffPlainText-D9YpoLrV.js → isDiffPlainText-DwHKxDYc.js} +1 -1
  33. package/dist/assets/{isFilePlainText-gTibdNIe.js → isFilePlainText-Dwq6ILxo.js} +1 -1
  34. package/dist/assets/ja-dwc9NM_S.js +15 -0
  35. package/dist/assets/ko-Ds1DZ8FX.js +15 -0
  36. package/dist/assets/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
  37. package/dist/assets/main-BF51IOVF.js +921 -0
  38. package/dist/assets/{main-D7UcL3VQ.js → main-D7UPARut.js} +2 -2
  39. package/dist/assets/markdownCore-BgeBDwD3.js +2 -0
  40. package/dist/assets/{miniChat-O_GVoEbc.js → miniChat-BISXSGOo.js} +2 -2
  41. package/dist/assets/mobile-BnYxVuvw.js +2 -0
  42. package/dist/assets/{patchFileDiff-KNkxM1C1.js → patchFileDiff-BEDPDypx.js} +2 -2
  43. package/dist/assets/pl-CLiTO7i-.js +15 -0
  44. package/dist/assets/pt-BR-GIimJgpK.js +15 -0
  45. package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +2 -0
  46. package/dist/assets/{renderMobileApp-toj9cXoh.js → renderMobileApp-BiMbzPq9.js} +7 -7
  47. package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +15 -0
  48. package/dist/assets/scheduledTasksApi-01zzfzqH.js +1 -0
  49. package/dist/assets/{shikiHighlight-C7LTbwFx.js → shikiHighlight-DXYW46vW.js} +1 -1
  50. package/dist/assets/uk-DLfgD1ki.js +15 -0
  51. package/dist/assets/{useAppFontEffects-BikB6enL.js → useAppFontEffects-CbzHzFop.js} +139 -142
  52. package/dist/assets/{useInlineCommentController-CYPvYJDt.js → useInlineCommentController-CegKdDXi.js} +2 -2
  53. package/dist/assets/{vendor-base-ui-D_V6hAcE.js → vendor-base-ui-BYlZTzrw.js} +1 -1
  54. package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +1 -0
  55. package/dist/assets/vendor-codemirror-commands-B7H_j0iU.js +1 -0
  56. package/dist/assets/{vendor-codemirror-lang-angular-CgY7_gQ1.js → vendor-codemirror-lang-angular-DEPs2M5t.js} +1 -1
  57. package/dist/assets/{vendor-codemirror-lang-cpp-B5Ta4enQ.js → vendor-codemirror-lang-cpp-DhkseaMo.js} +1 -1
  58. package/dist/assets/{vendor-codemirror-lang-css-VgNqFSH-.js → vendor-codemirror-lang-css-O0cZX78y.js} +1 -1
  59. package/dist/assets/{vendor-codemirror-lang-go-LxLz62pp.js → vendor-codemirror-lang-go-fMdQYcON.js} +1 -1
  60. package/dist/assets/vendor-codemirror-lang-html-CfgK872x.js +1 -0
  61. package/dist/assets/{vendor-codemirror-lang-java-Bksi1PH4.js → vendor-codemirror-lang-java-CQj4S3zl.js} +1 -1
  62. package/dist/assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js +13 -0
  63. package/dist/assets/{vendor-codemirror-lang-jinja-C7npuDD7.js → vendor-codemirror-lang-jinja-BmZZv8g-.js} +1 -1
  64. package/dist/assets/{vendor-codemirror-lang-json-ryCw7nab.js → vendor-codemirror-lang-json-CMBS2tG9.js} +1 -1
  65. package/dist/assets/{vendor-codemirror-lang-less-BxsZJD6N.js → vendor-codemirror-lang-less-C6Eo8hVS.js} +1 -1
  66. package/dist/assets/{vendor-codemirror-lang-liquid-De6qch10.js → vendor-codemirror-lang-liquid-DSTR47-H.js} +1 -1
  67. package/dist/assets/vendor-codemirror-lang-markdown-BPGOH9ye.js +1 -0
  68. package/dist/assets/{vendor-codemirror-lang-php-Cm1es33p.js → vendor-codemirror-lang-php-DD9udfPH.js} +1 -1
  69. package/dist/assets/{vendor-codemirror-lang-python-N414WYK-.js → vendor-codemirror-lang-python-HahnQaAS.js} +1 -1
  70. package/dist/assets/{vendor-codemirror-lang-rust-C_WuUStH.js → vendor-codemirror-lang-rust-nLTovbjv.js} +1 -1
  71. package/dist/assets/{vendor-codemirror-lang-sass-8UHTCAOM.js → vendor-codemirror-lang-sass-pL2Yc72v.js} +1 -1
  72. package/dist/assets/{vendor-codemirror-lang-sql-CV3sMA5D.js → vendor-codemirror-lang-sql-BVBnan19.js} +1 -1
  73. package/dist/assets/{vendor-codemirror-lang-vue-DzvC1Dhk.js → vendor-codemirror-lang-vue-BqGzJVm1.js} +1 -1
  74. package/dist/assets/{vendor-codemirror-lang-wast-jlr-LDdA.js → vendor-codemirror-lang-wast-B0_m5DqU.js} +1 -1
  75. package/dist/assets/{vendor-codemirror-lang-xml-CrO63OVp.js → vendor-codemirror-lang-xml-Dj3voadT.js} +1 -1
  76. package/dist/assets/{vendor-codemirror-lang-yaml-dxi6CISW.js → vendor-codemirror-lang-yaml-yu-9Z5u7.js} +1 -1
  77. package/dist/assets/vendor-codemirror-language-BgPj_McA.js +3 -0
  78. package/dist/assets/{vendor-codemirror-language-data-CLHw8NWn.js → vendor-codemirror-language-data-CiAYDJXN.js} +2 -2
  79. package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +2 -0
  80. package/dist/assets/{vendor-codemirror-state-CNWM3Q8V.js → vendor-codemirror-state-C9awkmn-.js} +5 -5
  81. package/dist/assets/vendor-codemirror-view-CiLROUVV.js +4 -0
  82. package/dist/assets/vendor-replit-codemirror-vim-B2DJlAhT.js +6 -0
  83. package/dist/assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js +34 -0
  84. package/dist/assets/vendor-zod-adaMkgkm.js +39 -0
  85. package/dist/assets/{web-components-GMc3oR3i.js → web-components-DCLjCO9n.js} +1 -1
  86. package/dist/assets/zh-CN-DkeP5awK.js +15 -0
  87. package/dist/assets/zh-TW-BocaFm3d.js +15 -0
  88. package/dist/index.html +4 -4
  89. package/dist/mini-chat.html +3 -3
  90. package/dist/mobile.html +3 -3
  91. package/package.json +1 -1
  92. package/server/index.js +116 -3
  93. package/server/lib/agent-memory/actions.js +243 -0
  94. package/server/lib/agent-memory/actions.test.js +343 -0
  95. package/server/lib/agent-memory/feature-flag.js +19 -0
  96. package/server/lib/agent-memory/feature-flag.test.js +38 -0
  97. package/server/lib/agent-memory/project-resolution.js +56 -0
  98. package/server/lib/agent-memory/project-resolution.test.js +85 -0
  99. package/server/lib/agent-memory/routes.http.test.js +270 -0
  100. package/server/lib/agent-memory/routes.js +169 -0
  101. package/server/lib/agent-memory/runtime.js +427 -0
  102. package/server/lib/agent-memory/runtime.test.js +344 -0
  103. package/server/lib/agent-memory/threat-patterns.js +61 -0
  104. package/server/lib/agent-memory/threat-patterns.test.js +61 -0
  105. package/server/lib/agent-tool/DOCUMENTATION.md +14 -0
  106. package/server/lib/agent-tool/runtime.js +63 -13
  107. package/server/lib/agent-tool/runtime.test.js +85 -2
  108. package/server/lib/context-obligatory/runtime.js +34 -3
  109. package/server/lib/context-obligatory/runtime.test.js +114 -0
  110. package/server/lib/fs/DOCUMENTATION.md +3 -0
  111. package/server/lib/fs/routes.js +149 -32
  112. package/server/lib/fs/routes.test.js +225 -0
  113. package/server/lib/git/DOCUMENTATION.md +8 -0
  114. package/server/lib/git/service.js +121 -67
  115. package/server/lib/git/service.test.js +129 -0
  116. package/server/lib/github/DOCUMENTATION.md +14 -3
  117. package/server/lib/github/pr-status.js +188 -83
  118. package/server/lib/github/pr-status.test.js +182 -0
  119. package/server/lib/github/routes.js +36 -30
  120. package/server/lib/notifications/template-runtime.js +2 -3
  121. package/server/lib/openchamber-control/action-resolution.test.js +65 -0
  122. package/server/lib/openchamber-control/actions.js +78 -0
  123. package/server/lib/openchamber-control/service.js +7 -0
  124. package/server/lib/openchamber-sessions/routes.js +14 -0
  125. package/server/lib/opencode/DOCUMENTATION.md +6 -4
  126. package/server/lib/opencode/claude-cli-auth.js +60 -0
  127. package/server/lib/opencode/claude-cli-auth.test.js +54 -0
  128. package/server/lib/opencode/feature-routes-runtime.js +11 -0
  129. package/server/lib/opencode/plugins.js +12 -3
  130. package/server/lib/opencode/plugins.test.js +18 -0
  131. package/server/lib/opencode/proxy-agent-wiring.test.js +152 -0
  132. package/server/lib/opencode/proxy.js +116 -6
  133. package/server/lib/opencode/proxy.test.js +158 -1
  134. package/server/lib/opencode/routes.js +4 -1
  135. package/server/lib/opencode/settings-helpers.js +11 -0
  136. package/server/lib/opencode/settings-helpers.test.js +35 -0
  137. package/server/lib/opencode/settings-runtime.js +51 -0
  138. package/server/lib/opencode/shared.js +120 -16
  139. package/server/lib/opencode/shared.test.js +185 -1
  140. package/server/lib/project-context/DOCUMENTATION.md +158 -0
  141. package/server/lib/project-context/routes.http.test.js +264 -0
  142. package/server/lib/project-context/routes.js +237 -0
  143. package/server/lib/project-context/runtime.js +667 -0
  144. package/server/lib/project-context/runtime.test.js +498 -0
  145. package/server/lib/quota/DOCUMENTATION.md +16 -1
  146. package/server/lib/quota/providers/claude/auth.js +113 -0
  147. package/server/lib/quota/providers/claude/auth.test.js +117 -0
  148. package/server/lib/quota/providers/claude/index.js +151 -0
  149. package/server/lib/quota/providers/claude/index.test.js +147 -0
  150. package/server/lib/quota/providers/claude/transforms.js +127 -0
  151. package/server/lib/quota/providers/claude/transforms.test.js +82 -0
  152. package/server/lib/quota/providers/command-code.js +90 -0
  153. package/server/lib/quota/providers/command-code.test.js +72 -0
  154. package/server/lib/quota/providers/index.js +22 -2
  155. package/server/lib/quota/providers/index.test.js +10 -1
  156. package/server/lib/quota/utils/formatters.js +2 -1
  157. package/server/lib/scheduled-tasks/runtime.js +21 -2
  158. package/server/lib/session-knowledge/DOCUMENTATION.md +87 -0
  159. package/server/lib/session-knowledge/routes.js +107 -0
  160. package/server/lib/session-knowledge/runtime.js +331 -0
  161. package/server/lib/session-knowledge/runtime.test.js +275 -0
  162. package/server/lib/skills-catalog/DOCUMENTATION.md +22 -22
  163. package/server/lib/skills-catalog/curated-sources.js +1 -1
  164. package/server/lib/skills-catalog/curated-sources.test.js +10 -0
  165. package/server/lib/small-model/index.js +8 -0
  166. package/server/lib/small-model/index.test.js +31 -1
  167. package/server/lib/small-model/routes.js +3 -1
  168. package/dist/assets/DiagramView-CFXxgg_a.js +0 -1
  169. package/dist/assets/FilesView-BKL6YlKG.js +0 -14
  170. package/dist/assets/MarkdownImageGallery-DKIylIK7.js +0 -1
  171. package/dist/assets/MarkdownRendererImpl-CLv8hxvv.js +0 -12
  172. package/dist/assets/OnboardingScreen-D2Y6djMw.js +0 -1
  173. package/dist/assets/PlanView-ZYEJn8A_.js +0 -4
  174. package/dist/assets/SessionSwitcherDropdown-rro-SsaO.js +0 -1
  175. package/dist/assets/SettingsView-5RmswFZe.js +0 -28
  176. package/dist/assets/SettingsWindow-BZhAYFdS.js +0 -1
  177. package/dist/assets/contextPanelEmbeddedChat-B-bSg3P5.js +0 -1
  178. package/dist/assets/de-u7gSnqWs.js +0 -9
  179. package/dist/assets/document-attachments-CX_YaDsu.js +0 -30
  180. package/dist/assets/es-T9O7aAOr.js +0 -15
  181. package/dist/assets/fr-Oor7ewbE.js +0 -13
  182. package/dist/assets/index-BzIpNlNE.css +0 -1
  183. package/dist/assets/index-C0yNhuZw.js +0 -1
  184. package/dist/assets/index-DRpChWux.js +0 -7
  185. package/dist/assets/ja-DHpqbVmr.js +0 -15
  186. package/dist/assets/ko-CwLkS3nx.js +0 -15
  187. package/dist/assets/main-DPMd2iKS.js +0 -915
  188. package/dist/assets/markdownCore-DDrHVneM.js +0 -2
  189. package/dist/assets/mobile-Br4TtAqc.js +0 -2
  190. package/dist/assets/pl-CcZILN8q.js +0 -15
  191. package/dist/assets/pt-BR-DYHhVK6o.js +0 -15
  192. package/dist/assets/renderElectronMiniChatApp-CJpdxTT1.js +0 -2
  193. package/dist/assets/runtimeEndpointReset-BVmispdD.js +0 -13
  194. package/dist/assets/scheduledTasksApi-ByKya3Un.js +0 -1
  195. package/dist/assets/uk-BA2kZR38.js +0 -15
  196. package/dist/assets/vendor-codemirror-autocomplete-BjbBRsUA.js +0 -1
  197. package/dist/assets/vendor-codemirror-commands-ARAOgp1x.js +0 -1
  198. package/dist/assets/vendor-codemirror-lang-html-B3Qe3OpS.js +0 -1
  199. package/dist/assets/vendor-codemirror-lang-javascript-Bbw3D7r0.js +0 -13
  200. package/dist/assets/vendor-codemirror-lang-markdown-FGQydhTc.js +0 -1
  201. package/dist/assets/vendor-codemirror-language-DUOssd4j.js +0 -3
  202. package/dist/assets/vendor-codemirror-search-8kyQdB3f.js +0 -2
  203. package/dist/assets/vendor-codemirror-view-DSzLbZiS.js +0 -4
  204. package/dist/assets/vendor-replit-codemirror-vim-B0Ecqnlh.js +0 -39
  205. package/dist/assets/zh-CN-dlOQK6v9.js +0 -15
  206. package/dist/assets/zh-TW-BnqQ-WL5.js +0 -15
  207. package/server/lib/quota/providers/claude.js +0 -107
@@ -1,7 +1,7 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-BKL6YlKG.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-DRpChWux.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/vendor-zustand-BAGL70zf.js","assets/index-BzIpNlNE.css","assets/useAppFontEffects-BikB6enL.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-D_V6hAcE.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-DKpLs02S.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/contextPanelEmbeddedChat-B-bSg3P5.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-DUOssd4j.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-DSzLbZiS.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-Bbw3D7r0.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BjbBRsUA.js","assets/vendor-codemirror-lang-json-ryCw7nab.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-VgNqFSH-.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-B3Qe3OpS.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-FGQydhTc.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CLHw8NWn.js","assets/vendor-codemirror-lang-python-N414WYK-.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-ARAOgp1x.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CRSgBxjL.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-BVmispdD.js","assets/shikiHighlight-C7LTbwFx.js","assets/vendor-codemirror-search-8kyQdB3f.js","assets/vendor-replit-codemirror-vim-B0Ecqnlh.js","assets/JsonTreeView-DLW2Wy1g.js","assets/web-components-GMc3oR3i.js","assets/computeVirtualFileMetrics-Da00Jg7M.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/Virtualizer-X_7XPoTH.js","assets/isFilePlainText-gTibdNIe.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/DiagramEditor-jnG3Hbxg.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/useInlineCommentController-CYPvYJDt.js","assets/CodeMirrorCommentWidgets-4qZbrEXU.js","assets/scheduledTasksApi-ByKya3Un.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{f as de,r as ls,j as t,R as l,c as ut,h as no}from"./vendor-react-BUCujlKS.js";import{u as Ve,a as bt,b as Gn,d as nn,i as Te,e as Ue,s as it,f as At,r as gs,h as ro,j as Kn,p as oo,k as io,l as dt,m as ao,n as rn,o as on,q as lo,t as an,v as co,w as uo}from"./index-DRpChWux.js";import{u as bs,a as fo,b as Oe,c as Hn,d as qn,r as xs,e as mo,f as me,t as ue,o as po,I as se,B as xe,g as ho,O as qe,h as Z,P as go,i as bo,j as xo,k as yo,l as ze,m as vo,n as nt,p as wo,q as ln,s as jo,v as ys,w as ko,x as So,y as je,z as No,A as Yn,C as Jn,D as Xn,E as Co,F as vs,G as Eo,H as Qn,J as Ro,K as Po,M as To,L as Zn,N as er,Q as tr,R as sr,S as ws,T as Io,U as Ao,V as js,W as _o,X as Do,Y as cn,Z as ks,_ as nr,$ as rr,a0 as Ss,a1 as Mo,a2 as zo,a3 as Oo,a4 as We,a5 as Lo,a6 as Bo,a7 as $o,a8 as Fo,a9 as Wo,aa as Uo,ab as Vo,ac as Le,ad as Go,ae as Ko,af as Ho,ag as Ft,ah as qo,ai as Yo,aj as Jo,ak as Xo,al as or,am as Qo,an as Zo,ao as ei,ap as ti,aq as si,ar as ni,as as ri,at as oi,au as ii,av as ai,aw as li,ax as ci,ay as ui,az as di,aA as fi,aB as mi,aC as pi,aD as hi,aE as gi,aF as bi,aG as xi,aH as yi,aI as vi,aJ as wi,aK as ji,aL as ki,aM as Si,aN as Ni,aO as Ci,aP as Ei}from"./useAppFontEffects-BikB6enL.js";import{u as at,S as ir,D as Ri,N as Pi,a as Ti,b as Ii,T as Ai,P as _i,M as Di,r as Mi,c as zi,d as Oi,e as Li,O as Bi,C as $i,f as Fi,g as Wi}from"./runtimeEndpointReset-BVmispdD.js";import{_ as ft}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as Ui,A as Vi}from"./SettingsView-5RmswFZe.js";import{PlanView as Gi}from"./PlanView-ZYEJn8A_.js";import{p as Ki}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as Hi}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as cs,s as ar,M as Ns,a as Gt,J as us,p as qi,_ as un,b as lr,P as cr,d as Yi,f as Cs,V as Ji,K as dn,c as Xi,Q as Qi,r as Zi,U as ea,Z as ta}from"./vendor-remixicon-react-Dil0zKKT.js";import{f as Es,h as mt,i as Rs,P as Ps,D as Ts,j as Is}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as As,S as _s,v as Ds,u as Ms}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as zs}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as Os,p as ur}from"./vendor-zustand-BAGL70zf.js";import{C as sa,a as na}from"./CommitSection-MJmntVPJ.js";import{P as ra}from"./PierreDiffViewer-BHm4Yr0X.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-D_V6hAcE.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-B-bSg3P5.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-DUOssd4j.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.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-Bbw3D7r0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BjbBRsUA.js";import"./vendor-codemirror-lang-json-ryCw7nab.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-VgNqFSH-.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-B3Qe3OpS.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-FGQydhTc.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CLHw8NWn.js";import"./vendor-codemirror-lang-python-N414WYK-.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-ARAOgp1x.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-C7LTbwFx.js";import"./vendor-codemirror-search-8kyQdB3f.js";import"./vendor-replit-codemirror-vim-B0Ecqnlh.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./useInlineCommentController-CYPvYJDt.js";import"./CodeMirrorCommentWidgets-4qZbrEXU.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./web-components-GMc3oR3i.js";import"./computeVirtualFileMetrics-Da00Jg7M.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"./VirtualizedFileDiff-CwGocYQd.js";import"./isDiffPlainText-D9YpoLrV.js";import"./vendor-diff-C3JhlQdm.js";let dr=null,fn=!1;const oa=new Promise(n=>{dr=n});function ia(){fn||(fn=!0,dr?.())}const aa=6,la=n=>n.parentID??null,mn=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},ca=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),ua=(n,e)=>{if(!n)return"";let s=null,o=-1;for(const r of e){const i=ca(r.path);(n===i||n.startsWith(`${i}/`))&&i.length>o&&(s=r,o=i.length)}return s?s.label?.trim()||mn(s.path):mn(n)},da=()=>{const n=bs.getState().activeSessions,e=fo.getState().index.session.unseenCount,s=Ve.getState().notifyOnSubtasks,o=Oe.getState().projects,r=Hn.getState().ids,i=qn.getState().rankById;let a=0;const c=[];for(const f of n){const u=la(f)!==null,g=(e[f.id]??0)>0&&(!u||s);g&&(a+=1),u||c.push({session:f,unread:g,project:ua(xs(f),o)})}c.sort((f,u)=>mo(f.session,u.session,r,i));const d=c.slice(0,aa).map(({session:f,unread:u,project:m})=>({id:f.id,title:f.title??"",unread:u,project:m}));return{runtimeKey:bt(),attentionCount:a,recentSessions:d}},fa="__OPENCHAMBER_WIDGET_SNAPSHOT__",ma=()=>{typeof window>"u"||(window[fa]=()=>{try{return JSON.stringify(da())}catch{return null}})},ts="mobile-app-update-available",pn="mobile-app-update-toast-dismissed-version",pa=()=>{const n=de.c(8),{t:e}=me(),s=at(ha),o=at(ga),r=at(ba),i=at(xa);let a;n[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,n[0]=a):a=n[0];const c=ls.useRef(a);let d,f;return n[1]!==s||n[2]!==i||n[3]!==o||n[4]!==e||n[5]!==r?(d=()=>{if(Gn()!=="android"||o!=="mobile"||!s||!r||!i){ue.dismiss(ts);return}nn().getItem(pn)!==r&&(c.current.has(r)||(c.current.add(r),ue.info(e("mobileUpdate.toast.available.title"),{id:ts,description:e("mobileUpdate.toast.available.description",{version:r}),duration:1/0,icon:t.jsx(se,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{po(i)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{nn().setItem(pn,r),ue.dismiss(ts)}}})))},f=[s,i,o,e,r],n[1]=s,n[2]=i,n[3]=o,n[4]=e,n[5]=r,n[6]=d,n[7]=f):(d=n[6],f=n[7]),ls.useEffect(d,f),null};function ha(n){return n.available}function ga(n){return n.runtimeType}function ba(n){return n.info?.version}function xa(n){return n.info?.downloadUrl}const hn=300,ya="openchamber.mobile.connectLog.v1",lt=[];if(typeof window<"u")try{window.localStorage.removeItem(ya)}catch{}const Ls=(n,e)=>{lt.push({at:Date.now(),step:n,detail:e}),lt.length>hn&&lt.splice(0,lt.length-hn)};typeof window<"u"&&Ls("app:launch","{}");const va=()=>[...lt],wa=n=>{const e=new Date(n),s=(o,r=2)=>String(o).padStart(r,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},fr=n=>`${wa(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,ja=()=>lt.map(fr).join(`
3
- `),mr=(n,e)=>{const s=de.c(10),o=700,r=l.useRef(null),i=l.useRef(null),a=l.useRef(!1);let c;s[0]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{r.current!==null&&window.clearTimeout(r.current),r.current=null,i.current=null},s[0]=c):c=s[0];const d=c;let f,u;s[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>d,u=[d],s[1]=f,s[2]=u):(f=s[1],u=s[2]),l.useEffect(f,u);let m;s[3]!==o||s[4]!==n?(m=j=>{a.current=!1,i.current={x:j.clientX,y:j.clientY},r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,a.current=!0,n()},o)},s[3]=o,s[4]=n,s[5]=m):m=s[5];const g=m;let h;s[6]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{const C=i.current;C&&(Math.abs(j.clientX-C.x)>10||Math.abs(j.clientY-C.y)>10)&&d()},s[6]=h):h=s[6];const x=h;let w;s[7]===Symbol.for("react.memo_cache_sentinel")?(w=j=>{a.current&&(a.current=!1,j.preventDefault(),j.stopPropagation())},s[7]=w):w=s[7];const b=w;let P;return s[8]!==g?(P={onPointerDown:g,onPointerMove:x,onPointerUp:d,onPointerCancel:d,onClickCapture:b},s[8]=g,s[9]=P):P=s[9],P},Kt="openchamber.mobile.connections.v1",ka="openchamber.mobile.",gn="openchamber.mobile.deviceId",Sa=()=>{try{const n=window.localStorage.getItem(gn);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem(gn,e),e}catch{return crypto.randomUUID()}},bn=()=>`mobile:${Sa()}`,xn=()=>{try{const n=Hi.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},pr=12,hr=8e3,Na=2500,Ca=3e3,Ht=2500,Ea=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},xt=n=>{const e=n.trim();if(!e)return"";const s=/^https?:\/\//i.test(e)?e:`http://${e}`,o=new URL(s);return o.hash="",o.search="",o.pathname=o.pathname.replace(/\/+$/,""),o.toString().replace(/\/+$/,"")},Wt=n=>{try{return new URL(n).host}catch{return n}},pt=n=>{try{return xt(n)}catch{return n.trim().replace(/\/+$/g,"")}},gr=(n,e)=>pt(n)===pt(e),br=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,Ra=n=>`relay://${n.serverId}`,Xt=n=>n.candidates.filter(e=>e.kind==="direct"),Xe=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},Ge=n=>{const e=Xt(n)[0];if(e)return e.url;const s=Xe(n);return s?Ra(s):""},Re=n=>{const e=Xe(n);if(e)return br(e);const s=Xt(n)[0];return s?pt(s.url):""},qt=(n,e)=>{const s=n.find(i=>i.kind==="relay"),o=s&&s.kind==="relay"?s.relay.serverId:null,r=new Set(n.filter(i=>i.kind==="direct").map(i=>pt(i.url)));return e.some(i=>i.kind==="relay"?o!==null&&i.relay.serverId===o:r.has(pt(i.url)))},Bs=n=>{const e=(()=>{try{return xt(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},yn=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(...Bs(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},$s=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 o=s;return o.kty!=="EC"||o.crv!=="P-256"||typeof o.x!="string"||!o.x||typeof o.y!="string"||!o.y?null:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:{kty:"EC",crv:"P-256",x:o.x,y:o.y}}},xr=n=>{try{return JSON.stringify(n)}catch{return String(n)}},he=(n,e={})=>{const s=xr(e);console.info("[mobile-connect]",n,s),Ls(n,s)},wt=(n,e={})=>{he(n,e)},ht=(n,e={})=>{const s=xr(e);console.info("[mobile-storage]",n,s),Ls(n,s)},Pa=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},Ta=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},Ia=async(n,e)=>{if(!Te())return null;try{const{CapacitorHttp:s}=await ft(async()=>{const{CapacitorHttp:i}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:i}},[]),o=Object.fromEntries(new Headers(e?.headers).entries()),r=await s.request({url:n,method:e?.method||"GET",headers:o,data:Ta(e?.body)});return{ok:r.status>=200&&r.status<300,status:r.status,source:"native-http",json:async()=>Pa(r.data)}}catch(s){return he("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},Aa=async(n,e)=>{const s=await fetch(n,e).catch(o=>(he("browser-fetch:failed",{url:n,error:o instanceof Error?o.message:String(o)}),null));return s?{ok:s.ok,status:s.status,source:"browser-fetch",json:()=>s.json()}:null},He=async(n,e,s)=>{let o;const r=new Promise(i=>{o=window.setTimeout(()=>{s?.(),i(null)},n)});try{return await Promise.race([e,r])}catch{return null}finally{o!==void 0&&window.clearTimeout(o)}},Qe=async(n,e,s)=>{const o=s?.totalTimeoutMs??hr,r=Date.now(),i=await He(Math.min(Na,o),Ia(n,e));if(i)return i;const a=new AbortController,c=Math.max(500,o-(Date.now()-r));return He(c,Aa(n,{...e,signal:a.signal}),()=>a.abort())},Qt=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}},gt=15e3,_a=async(n,e,s,o=gt,r)=>{const i=Kn({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk}),a=c=>c==="ok"&&r?.keepTunnel?{outcome:c,tunnel:i}:(i.close(),{outcome:c});try{const c=e?{Authorization:`Bearer ${e}`}:void 0,d=await He(o,i.fetch("/auth/session",{headers:c}).catch(()=>null));if(he("relay:session",{ok:d?.ok===!0,status:d?.status??null,hasToken:!!e}),!d)return a("unreachable");if(d.status===401)return a(e?"auth-failed":"needs-login");if(!d.ok&&d.status!==404)return a("auth-failed");const f=await Qt(d);return f&&f.disabled!==!0&&f.authenticated===!1?a(e?"auth-failed":"needs-login"):a("ok")}catch(c){throw i.close(),c}},Da=(n,e,s,o,r)=>{const i=typeof window<"u"?window.location.origin:"",a={relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk,...s?{grant:s}:{}};r&&ro(a,r),it({apiBaseUrl:i,clientToken:e,runtimeKey:o??br(n),relay:a})},Ma=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=$s(e.relay);return s?{kind:"relay",relay:s}:null}return null},za=n=>{if(n.mode==="relay"){const e=$s(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?Bs(n.url):[]},et=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(Kt)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=Te();return n.flatMap(s=>{if(!s||typeof s!="object")return[];const o=s;if(typeof o.id!="string")return[];const r=Array.isArray(o.candidates)?o.candidates.map(Ma).filter(d=>!!d):za(o);if(r.length===0)return[];const i=typeof o.clientToken=="string"&&o.clientToken.trim()?o.clientToken:void 0,a=typeof o.label=="string"&&o.label.trim()?o.label:Wt(Ge({candidates:r})),c={id:o.id,label:a,candidates:r,lastUsedAt:typeof o.lastUsedAt=="number"?o.lastUsedAt:0};return e?[{...c,hasToken:!!o.hasToken||!!i}]:[{...c,clientToken:i,hasToken:!!i}]}).sort((s,o)=>o.lastUsedAt-s.lastUsedAt)},ds=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},Fs=n=>{if(typeof window>"u")return;const e=Te(),s=n.slice(0,pr).map(o=>{const r={id:o.id,label:o.label,candidates:o.candidates.map(ds),lastUsedAt:o.lastUsedAt};return e?{...r,hasToken:!!(o.hasToken||o.clientToken)}:{...r,clientToken:o.clientToken}});try{window.localStorage.setItem(Kt,JSON.stringify(s))}catch(o){console.warn("[mobile-storage] failed to persist connection metadata",o)}},yr=(n,e)=>{const s=n.find(i=>e.id&&i.id===e.id||qt(i.candidates,e.candidates)),o=Te(),r={id:e.id||s?.id||crypto.randomUUID(),label:e.label,candidates:e.candidates,lastUsedAt:Date.now(),...o?{hasToken:e.hasToken??(!!e.clientToken||s?.hasToken||!1)}:{clientToken:e.clientToken??s?.clientToken,hasToken:!!(e.clientToken??s?.clientToken)}};return[r,...n.filter(i=>i.id!==r.id&&!qt(i.candidates,e.candidates))].slice(0,pr)},Ws=Ki,Oa=0,Us=n=>`${ka}token.${encodeURIComponent(n)}`,La=async(n,e)=>{let s;const o=new Promise(r=>{s=window.setTimeout(()=>r(e),Ca)});try{return await Promise.race([n.catch(()=>e),o])}finally{s!==void 0&&window.clearTimeout(s)}},Vs=async(n,e,s)=>Te()?La(e().catch(o=>(console.warn(`[mobile-storage] ${n} failed`,o),s)),s):s,_t=async n=>{ht("secure:read-start",{key:n});const e=await Vs("secure:read",async()=>(await Ws.internalGetItem({prefixedKey:Us(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return ht("secure:read",{key:n,hasToken:!!s}),s},Ye=async(n,e)=>{ht("secure:write-start",{key:n});const s=await Vs("secure:write",async()=>(await Ws.internalSetItem({prefixedKey:Us(n),data:e,sync:!1,access:Oa}),!0),!1);return ht("secure:write",{key:n,ok:s}),s},Ba=async n=>{await Vs("secure:delete",async()=>(await Ws.internalRemoveItem({prefixedKey:Us(n),sync:!1}),!0),!1)},$a=async(n,e)=>{let s=0,o=0;return{records:await Promise.all(n.map(async i=>{if(!i||typeof i!="object")return i;const a=i,c=typeof a.url=="string"?a.url:null,d=typeof a.clientToken=="string"?a.clientToken.trim():"";if(!c||!d)return i;if(!await e(c,d))return o+=1,i;s+=1;const{clientToken:f,...u}=a;return{...u,hasToken:!0}})),migrated:s,failed:o}},vr=async()=>{if(typeof window>"u"||!Te())return;let n;try{n=JSON.parse(window.localStorage.getItem(Kt)||"[]")}catch{return}if(!Array.isArray(n))return;const e=n.filter(o=>!!o&&typeof o=="object"&&typeof o.url=="string"&&typeof o.clientToken=="string"&&!!o.clientToken.trim());if(e.length===0)return;ht("secure:migrate-start",{count:e.length});const s=await $a(n,async(o,r)=>{const i=pt(o);return await Ye(i,r)?await _t(i)===r:!1});if(s.migrated>0)try{window.localStorage.setItem(Kt,JSON.stringify(s.records))}catch(o){console.warn("[mobile-storage] failed to finalize secure token migration",o);return}ht("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},Fa=async()=>(await vr(),et()),Yt=async n=>{const e=yr(et(),n);return Fs(e),Te()&&n.clientToken&&await Ye(Re({candidates:n.candidates}),n.clientToken),e},Wa=async n=>{const e=et(),s=e.find(r=>r.id===n)??null,o=e.filter(r=>r.id!==n);return Fs(o),s&&Te()&&await Ba(Re(s)),o},Ua=1500,Jt=async(n,e,s)=>{const o=s?.fast?{totalTimeoutMs:Ht}:void 0,r=Xe({candidates:n})?.serverId??null,i=n.find(f=>f.kind==="relay")??null,a=n.filter(f=>f.kind==="direct"),c=async()=>{for(const f of a){const u=xt(f.url)||f.url,m=e?{Authorization:`Bearer ${e}`}:void 0,g=await Qe(`${u}/health`,{method:"GET"},o);if(he("probe:direct:health",{url:u,ok:g?.ok===!0,status:g?.status??null,source:g?.source??null}),!g?.ok)continue;if(r){const b=await g.json().catch(()=>null),P=b&&typeof b=="object"?b.serverId:null;if(typeof P=="string"&&P&&P!==r){he("probe:server-id-mismatch",{url:u});continue}}const h=await Qe(`${u}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:m},o);if(he("probe:direct:session",{url:u,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 x=await Qt(h);if(x&&x.disabled!==!0&&x.authenticated===!1)return{status:"needs-login"};const w=x?.disabled===!0;return!e&&Te()&&!w&&x?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:u}}}return{status:"unreachable"}},d=async()=>{if(!i)return{status:"unreachable"};const{outcome:f,tunnel:u}=await _a(i.relay,e,void 0,s?.fast?Ht:hr,{keepTunnel:!0});return f==="ok"?{status:"ok",transport:{kind:"relay",relay:i.relay,tunnel:u}}:f==="needs-login"||f==="auth-failed"?{status:"needs-login"}:{status:"unreachable"}};return i?a.length===0?d():new Promise(f=>{let u=!1,m=!1,g,h=null,x=null;const w=j=>{j?.status==="ok"&&j.transport.kind==="relay"&&j.transport.tunnel?.close()},b=j=>{u||(u=!0,f(j))},P=()=>{m||u||(g!==void 0&&(window.clearTimeout(g),g=void 0),d().then(j=>{if(x=j,u||m){w(j);return}if(j.status==="ok"||j.status==="needs-login"){b(j);return}h&&b(h)}))};c().then(j=>{if(h=j,!u){if(j.status==="ok"||j.status==="needs-login"){m=!0,g!==void 0&&window.clearTimeout(g),w(x),b(j);return}if(x){b(x);return}P()}}),g=window.setTimeout(P,Ua)}):c()},Je=(n,e,s)=>{n.kind==="relay"?Da(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel):it({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),jr()},Nt=()=>{const n=et()[0];return n?.label?.trim()?n.label:null},jt=async n=>{const e=n?.fast!==!1;await vr();const s=et()[0];if(he("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let o;if(Te()){if(s.hasToken&&(o=await _t(Re(s)),!o))return{status:"no-candidate"}}else if(o=s.clientToken,!o&&s.hasToken)return{status:"no-candidate"};const r=await Jt(s.candidates,o,{fast:e});return he("auto-connect:probe",{status:r.status,candidates:s.candidates.map(i=>i.kind)}),r.status==="needs-login"?{status:"needs-login",label:s.label}:r.status!=="ok"?{status:"unreachable",label:s.label}:n?.skipIfConnected&&Ue()?(r.transport.kind==="relay"&&r.transport.tunnel?.close(),he("auto-connect:superseded",{}),{status:"no-candidate"}):(await Yt({id:s.id,label:s.label,candidates:s.candidates}),Je(r.transport,o??null,{runtimeKey:Re(s)}),{status:"connected"})},Va=async(n,e)=>{let s="";try{s=xt(n.url)}catch{return!1}if(!s)return!1;const o=n.clientToken?.trim()||void 0,r=o?{Authorization:`Bearer ${o}`}:void 0,i=e?.fast?{totalTimeoutMs:Ht}:void 0;if(!(await Qe(`${s}/health`,{method:"GET",headers:r},i))?.ok)return!1;const c=await Qe(`${s}/auth/session`,{method:"GET",credentials:o?"omit":"include",headers:r},i);if(!c||!c.ok&&c.status!==404)return!1;const d=await Qt(c);return!(d&&d.disabled!==!0&&d.authenticated===!1)},Ga=n=>[...n].sort((e,s)=>{const o=(e.priority??100)-(s.priority??100);if(o!==0)return o;const r=i=>i.type==="relay"?2:i.url.startsWith("https://")?0:1;return r(e)-r(s)}).flatMap(e=>{if(e.type==="relay"){const s=$s({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return Bs(e.url)}),vn=async n=>{const e=Xe({candidates:n})?.serverId??null;for(const s of n){if(s.kind==="relay"){const i=Kn(s.relay),a=await He(gt,i.fetch("/health").catch(()=>null));if(he("establish:relay:health",{ok:a?.ok===!0,status:a?.status??null}),a?.ok)return{kind:"relay",relay:s.relay,tunnel:i};i.close();continue}const o=xt(s.url)||s.url,r=await Qe(`${o}/health`,{method:"GET"});if(he("establish:direct:health",{ok:r?.ok===!0,status:r?.status??null}),!!r?.ok){if(e){const i=await r.json().catch(()=>null),a=i&&typeof i=="object"?i.serverId:null;if(typeof a=="string"&&a&&a!==e){he("establish:server-id-mismatch",{url:o});continue}}return{kind:"direct",url:o}}}return null},Ka=async(n,e)=>{if(!At())return Va(n,e);const s=await He(e?.fast?Ht:gt,gs("/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 o=await Qt(s);return!(o&&o.disabled!==!0&&o.authenticated===!1)},Ha=n=>n.kind==="relay"?At():!At()&&gr(n.url,Ue()),wr=()=>{const n=bt();return n?et().find(e=>Re(e)===n)??null:null},wn=n=>{const e=bt();return!!e&&Re(n)===e},Ut=async n=>{const e=n?.fast!==!1,s=wr();if(!s)return he("reprobe:no-connection",{runtimeKey:!!bt()}),"no-connection";let o;if(Te()?o=s.hasToken?await _t(Re(s)):void 0:o=s.clientToken,!o&&s.hasToken)return he("reprobe:no-token",{hasToken:!0}),"unreachable";he("reprobe:start",{candidates:s.candidates.map(f=>f.kind),fast:e,hasToken:!!o});const r=s.candidates.findIndex(f=>Ha(f.kind==="relay"?{kind:"relay",relay:f.relay}:{kind:"direct",url:f.url})),i=r>=0?s.candidates.slice(0,r):s.candidates,a=await Jt(i,o,{fast:e});if(he("reprobe:better",{status:a.status,probed:i.length}),a.status==="ok")return await Yt({id:s.id,label:s.label,candidates:s.candidates}),Je(a.transport,o??null,{runtimeKey:Re(s)}),"switched";if(a.status==="needs-login")return"needs-login";if(r>=0){const f=await Ka({url:Ue(),clientToken:o},{fast:e});if(he("reprobe:current",{stillValid:f}),f)return jr(),"unchanged"}const c=r>=0?s.candidates.slice(r+1):[],d=await Jt(c,o,{fast:e});return he("reprobe:fallback",{status:d.status,probed:c.length}),d.status==="ok"?(await Yt({id:s.id,label:s.label,candidates:s.candidates}),Je(d.transport,o??null,{runtimeKey:Re(s)}),"switched"):d.status==="needs-login"?"needs-login":"unreachable"},qa=5e3;let ss=!1;const Ya=async()=>{if(ss)return"skipped";const n=wr();if(!n)return he("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=Xe(n);if(!e)return he("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";ss=!0;try{const s=await He(gt,gs("/api/client-auth/connection/candidates").then(f=>f).catch(()=>null));if(!s?.ok)return he("candidates:refresh-skip",{reason:"fetch-failed",status:s?.status??null}),"skipped";const o=await s.json().catch(()=>null);if(!o||o.serverId!==e.serverId)return he("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const r=Array.isArray(o.candidates)?o.candidates:[],i=[];for(const f of r){if(!f||typeof f!="object")continue;const u=f;if(!(u.type!=="lan"||typeof u.url!="string"))try{const m=xt(u.url);m&&!i.includes(m)&&i.push(m)}catch{}}if(i.length===0)return he("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const a=Xt(n).filter(f=>f.url.startsWith("https://")),c=[...i.map(f=>({kind:"direct",url:f})),...a,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map(ds))===JSON.stringify(c.map(ds))?"unchanged":(he("candidates:refreshed",{lanCount:i.length}),await Yt({id:n.id,label:n.label,candidates:c}),"updated")}finally{ss=!1}},jr=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await Ya().catch(()=>"skipped");he("candidates:refresh-result",{result:n}),n==="updated"&&At()&&await Ut().catch(()=>null)})()},qa)},kr=n=>{const{t:e}=me(),[s,o]=l.useState(()=>et()),[r,i]=l.useState(null),[a,c]=l.useState(null),[d,f]=l.useState(null),u=l.useRef(s),m=l.useRef(null),g=l.useRef(Ea()),h=l.useCallback(k=>{u.current=k,o(k)},[]),x=l.useCallback(k=>{m.current=k,i(k)},[]),w=l.useCallback(k=>{m.current===k&&(m.current=null,i(null))},[]);l.useEffect(()=>{let k=!1;return Fa().then(E=>{k||h(E)}),()=>{k=!0}},[h]);const b=l.useCallback(k=>{const E=yr(u.current,k);return h(E),Fs(E),E},[h]),P=l.useCallback(async k=>{c(null),x("connect");try{const E=yn(k);if(E.length===0){c(e("mobile.connect.error.urlRequired"));return}const y=k.id?u.current.find($=>$.id===k.id):u.current.find($=>qt($.candidates,E)),I=k.label?.trim()||y?.label||Wt(Ge({candidates:E})),M=k.relayGrant;let N=k.clientToken?.trim()||void 0;const S=!!N;N||(Te()?y?.hasToken&&(N=await _t(Re({candidates:E}))):N=y?.clientToken),he("connect:start",{candidates:E.map($=>$.kind),hasToken:!!N});const H=await Jt(E,N);if(he("connect:probe",{status:H.status}),H.status==="unreachable"){c(e("mobile.connect.error.unreachable"));return}if(H.status==="needs-login"){b({id:y?.id,label:I,candidates:E}),f({id:y?.id??crypto.randomUUID(),label:I,candidates:E,relay:Xe({candidates:E})??void 0,relayGrant:M});return}N&&S&&Te()&&await Ye(Re({candidates:E}),N),b({id:y?.id,label:I,candidates:E,clientToken:N}),Je(H.transport,N??null,{runtimeKey:Re({candidates:E}),grant:M}),n()}catch(E){console.warn("[mobile-connect] connect threw",E),c(e("mobile.connect.error.invalidUrl"))}finally{w("connect")}},[x,w,n,b,e]),j=l.useCallback(async k=>{if(m.current==="pairing")return;c(null),x("pairing");const E=Ga(k.candidates);let y=null,I=!1;try{if(y=await vn(E),!y){c(e("mobile.connect.error.unreachable"));return}const M=JSON.stringify({pairingId:k.pairingId,secret:k.secret,clientLabel:"OpenChamber Mobile",clientKind:"mobile",deviceName:"OpenChamber Mobile",devicePlatform:xn(),dedupeKey:bn()}),N={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:M},S=y.kind==="relay"?await He(gt,y.tunnel.fetch("/api/client-auth/pairing/redeem",N).catch(()=>null)):await Qe(`${y.url}/api/client-auth/pairing/redeem`,N);if(!S?.ok){c(e("mobile.connect.error.authRequired"));return}const H=await S.json().catch(()=>null),$=typeof H?.clientToken=="string"?H.clientToken.trim():"";if(!$){c(e("mobile.connect.error.authRequired"));return}const v=typeof H?.server?.label=="string"?H.server.label:"",A=k.label||v||Wt(Ge({candidates:E}));if(Te()&&!await Ye(Re({candidates:E}),$)){c(e("mobile.connect.error.authRequired"));return}b({label:A,candidates:E,clientToken:$}),Je(y.kind==="relay"?{kind:"relay",relay:y.relay,tunnel:y.tunnel}:{kind:"direct",url:y.url},$,{runtimeKey:Re({candidates:E})}),I=y.kind==="relay",n()}catch(M){console.warn("[mobile-connect] pairing threw",M),c(e("mobile.connect.error.authRequired"))}finally{!I&&y?.kind==="relay"&&y.tunnel.close(),w("pairing")}},[x,w,n,b,e]),C=l.useCallback(async k=>{if(!d||!k.trim()||m.current==="password")return;c(null),x("password");const E=g.current.begin(),y=()=>g.current.isCurrent(E),{id:I,label:M,candidates:N}=d;let S=null,H=!1;try{if(S=await vn(N),!y())return;if(!S){c(e("mobile.connect.error.unreachable"));return}const $={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:k,trustDevice:!0,issueClientToken:!0,clientLabel:"OpenChamber Mobile",clientKind:"mobile",devicePlatform:xn(),dedupeKey:bn()})};he("password:start",{transport:S.kind});const v=S.kind==="relay"?await He(gt,S.tunnel.fetch("/auth/session",$).catch(()=>null)):await Qe(`${S.url}/auth/session`,$);if(!y())return;if(he("password:done",{ok:v?.ok===!0,status:v?.status??null}),!v?.ok){c(e("mobile.connect.error.passwordFailed"));return}const A=await v.json().catch(()=>null);if(!y())return;const O=typeof A?.clientToken=="string"?A.clientToken.trim():"";if(he("password:token",{issued:!!O}),!O){if(S.kind==="direct"&&!Te()){b({id:I,label:M,candidates:N}),f(null),Je({kind:"direct",url:S.url},null,{runtimeKey:Re({candidates:N})}),n();return}c(e("mobile.connect.error.authRequired"));return}if(Te()&&(!y()||(await Ye(Re({candidates:N}),O),!y()))||!y()||(b({id:I,label:M,candidates:N,clientToken:O}),f(null),Je(S.kind==="relay"?{kind:"relay",relay:S.relay,tunnel:S.tunnel}:{kind:"direct",url:S.url},O,{runtimeKey:Re({candidates:N})}),H=S.kind==="relay",!y()))return;n()}catch($){if(!y())return;console.warn("[mobile-connect] password threw",$),c(e("mobile.connect.error.passwordFailed"))}finally{!H&&S?.kind==="relay"&&S.tunnel.close(),y()&&w("password")}},[x,w,n,d,b,e]),R=l.useCallback(()=>{g.current.cancel(),w("password"),f(null),c(null)},[w]),T=l.useCallback(async k=>{c(null);let E=yn(k);const y=k.id?u.current.find(S=>S.id===k.id)??null:null;if(y){const S=E.filter(v=>v.kind==="direct"),H=Xt(y).filter(v=>v.url.startsWith("https://")&&!S.some(A=>gr(A.url,v.url))),$=Xe(y);E=[...S,...H,...$?[{kind:"relay",relay:$}]:[]]}if(E.length===0)return c(e("mobile.connect.error.urlRequired")),null;const I=k.clientToken?.trim()||void 0,M=k.label?.trim()||Wt(Ge({candidates:E}));if(Te()){const S=Re({candidates:E});if(I)await Ye(S,I);else if(y?.hasToken){const H=Re(y);if(H&&S&&H!==S){const $=await _t(H);$&&await Ye(S,$)}}}return b({id:k.id,label:M,candidates:E,clientToken:I}).find(S=>qt(S.candidates,E))??null},[b,e]),D=l.useCallback(async k=>{const E=u.current.find(I=>I.id===k)??null,y=await Wa(k);return h(y),E},[h]);return{connections:s,isBusy:r!==null,isPasswordBusy:r==="password",error:a,pendingConnection:d,connect:P,redeemPairingConnection:j,submitPassword:C,cancelPassword:R,saveConnection:T,removeConnection:D,setError:c}},Sr=n=>{const e=de.c(31),{onClose:s}=n,{t:o}=me(),[r,i]=l.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=va(),e[0]=a):a=e[0];const c=a;let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{ho(ja()).then(k=>{k.ok&&(i(!0),window.setTimeout(()=>i(!1),2e3))})},e[1]=d):d=e[1];const f=d;let u;e[2]!==o?(u=o("mobile.connectionDebug.title"),e[2]=o,e[3]=u):u=e[3];let m;e[4]!==u?(m=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:u}),e[4]=u,e[5]=m):m=e[5];const g=r?"check":"file-copy";let h;e[6]!==g?(h=t.jsx(se,{name:g,className:"size-4"}),e[6]=g,e[7]=h):h=e[7];let x;e[8]!==r||e[9]!==o?(x=o(r?"mobile.connectionDebug.copied":"mobile.connectionDebug.copy"),e[8]=r,e[9]=o,e[10]=x):x=e[10];let w;e[11]!==h||e[12]!==x?(w=t.jsxs(xe,{type:"button",variant:"outline",size:"sm",onClick:f,disabled:c.length===0,children:[h,x]}),e[11]=h,e[12]=x,e[13]=w):w=e[13];let b;e[14]!==o?(b=o("mobile.connectionDebug.close"),e[14]=o,e[15]=b):b=e[15];let P;e[16]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(se,{name:"close",className:"size-[18px]"}),e[16]=P):P=e[16];let j;e[17]!==s||e[18]!==b?(j=t.jsx(xe,{type:"button",variant:"ghost",size:"icon","aria-label":b,onClick:s,children:P}),e[17]=s,e[18]=b,e[19]=j):j=e[19];let C;e[20]!==j||e[21]!==w?(C=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[w,j]}),e[20]=j,e[21]=w,e[22]=C):C=e[22];let R;e[23]!==C||e[24]!==m?(R=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[m,C]}),e[23]=C,e[24]=m,e[25]=R):R=e[25];let T;e[26]!==o?(T=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:c.length===0?t.jsx("p",{className:"typography-small text-muted-foreground",children:o("mobile.connectionDebug.empty")}):t.jsx("pre",{className:"whitespace-pre-wrap break-words typography-code text-muted-foreground",children:c.map(fr).join(`
4
- `)})}),e[26]=o,e[27]=T):T=e[27];let D;return e[28]!==R||e[29]!==T?(D=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:[R,T]}),e[28]=R,e[29]=T,e[30]=D):D=e[30],D},Nr=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},Ja=()=>window.Capacitor?.getPlatform?.()==="android",Cr=n=>{const e=n.trim();if(!e)return null;if(/^openchamber:\/\//i.test(e)){const s=oo(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},Er=(n,e)=>{const s=Cr(n);if(!s&&e?.pairingStringFallback){const o=io(n);if(o)return{status:"pairing",pairing:o}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},Xa=async(n,e)=>{if(!n.startScan||!n.stopScan||!n.addListener)return{status:"unsupported"};if(e?.aborted)return{status:"cancelled"};let s,o,r=!1,i=()=>{};const a=new Promise(f=>{i=f}),c=f=>{r||(r=!0,i(f))},d=()=>c({status:"cancelled"});e?.addEventListener("abort",d,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:u})=>{const m=u?.[0],g=(m?.rawValue??m?.displayValue??"").trim();g&&c(Er(g,{pairingStringFallback:!0}))})).then(u=>{s=u}),Promise.resolve(n.addListener("scanError",()=>c({status:"failed"}))).then(u=>{o=u})])).some(({status:u})=>u==="rejected")?c({status:"failed"}):r||n.startScan({formats:["QR_CODE"]}).catch(()=>c({status:"failed"})),await a}finally{e?.removeEventListener("abort",d),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(o?.remove()),n.stopScan()])}},fs=()=>Nr()!==null,Rr=async n=>{const e=Nr();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(Ja())return Xa(e,n?.signal);if(!e.scan)return{status:"unsupported"};const o=(await e.scan({formats:["QR_CODE"]}))?.barcodes?.[0],r=(o?.rawValue??o?.displayValue??"").trim();return r?Er(r):{status:"cancelled"}}catch{return{status:"failed"}}},ct={autoComplete:"off",autoCorrect:"off",spellCheck:!1},Ct="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-primary focus:ring-2 focus:ring-primary/20",Pr=n=>{const e=de.c(22),{onCancel:s}=n,{t:o}=me(),r=l.useRef(null);let i,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const P={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},j={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,R=D=>{!(D instanceof HTMLElement)||D===r.current||C.has(D)||(C.set(D,{opacity:D.style.opacity,pointerEvents:D.style.pointerEvents}),D.style.setProperty("opacity","0"),D.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(R);const T=new MutationObserver(D=>{D.forEach(k=>k.addedNodes.forEach(R))});return T.observe(document.body,{childList:!0}),()=>{T.disconnect(),C.forEach(Qa),P.value?document.documentElement.style.setProperty("background-color",P.value,P.priority):document.documentElement.style.removeProperty("background-color"),j.value?document.body.style.setProperty("background-color",j.value,j.priority):document.body.style.removeProperty("background-color")}},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),l.useLayoutEffect(i,a);let c,d;e[2]!==s?(c=()=>{const P=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",P),()=>document.removeEventListener("visibilitychange",P)},d=[s],e[2]=s,e[3]=c,e[4]=d):(c=e[3],d=e[4]),l.useEffect(c,d);let f;e[5]!==o?(f=o("mobile.connect.scanQr"),e[5]=o,e[6]=f):f=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=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]=u):u=e[7];let m;e[8]!==o?(m=o("mobile.connect.welcome.scanHint"),e[8]=o,e[9]=m):m=e[9];let g;e[10]!==m?(g=t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-6",children:[u,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:m})]}),e[10]=m,e[11]=g):g=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(se,{name:"close",className:"size-[18px]"}),e[12]=h):h=e[12];let x;e[13]!==o?(x=o("mobile.instances.cancelEdit"),e[13]=o,e[14]=x):x=e[14];let w;e[15]!==s||e[16]!==x?(w=t.jsxs(xe,{type:"button",variant:"outline",size:"lg",className:"mx-auto min-h-12 w-full max-w-sm bg-background",onClick:s,children:[h,x]}),e[15]=s,e[16]=x,e[17]=w):w=e[17];let b;return e[18]!==w||e[19]!==f||e[20]!==g?(b=ut.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,w]}),document.body),e[18]=w,e[19]=f,e[20]=g,e[21]=b):b=e[21],b},Tr=()=>{const n=de.c(6),{t:e}=me();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(qe,{width:96,height:96,isAnimated:!0}),n[0]=s):s=n[0];let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(se,{name:"loader-4",className:"size-[18px] animate-spin"}),n[1]=o):o=n[1];let r;n[2]!==e?(r=e("mobile.connect.connecting"),n[2]=e,n[3]=r):r=n[3];let i;return n[4]!==r?(i=ut.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:[o,t.jsx("span",{children:r})]})]}),document.body),n[4]=r,n[5]=i):i=n[5],i};function Qa(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const Za=({onConnected:n,notice:e=null})=>{const{t:s}=me(),o=kr(n),{connections:r,isBusy:i,isPasswordBusy:a,error:c,pendingConnection:d}=o,[f,u]=l.useState(""),[m,g]=l.useState(""),[h,x]=l.useState(""),[w,b]=l.useState(!1),[P,j]=l.useState(!1),C=l.useRef(null),R=l.useMemo(()=>fs(),[]),[T,D]=l.useState(()=>!fs()),[k,E]=l.useState(null),[y,I]=l.useState(""),[M,N]=l.useState(!1),S=mr(l.useCallback(()=>N(!0),[])),H=l.useCallback(z=>{z.preventDefault(),o.connect({url:f,clientToken:h,label:m})},[h,o,m,f]),$=l.useCallback(z=>{if(/^openchamber:\/\//i.test(z.trim())){const B=Cr(z);if(B){if("pairing"in B){o.redeemPairingConnection(B.pairing);return}u(B.url),B.label&&g(B.label),B.clientToken&&x(B.clientToken);return}}u(z)},[o]),v=l.useCallback(async()=>{if(C.current||i)return;o.setError(null),b(!0);const z=new AbortController;C.current=z;try{const B=await Rr({signal:z.signal});switch(C.current===z&&(C.current=null,b(!1)),B.status){case"ok":j(!0),u(B.url),B.label&&g(B.label),B.clientToken&&x(B.clientToken),await o.connect({url:B.url,clientToken:B.clientToken,label:B.label});break;case"pairing":j(!0),await o.redeemPairingConnection(B.pairing);break;case"permission-denied":o.setError(s("mobile.connect.scan.permissionDenied"));break;case"invalid":o.setError(s("mobile.connect.scan.invalid"));break;case"unsupported":o.setError(s("mobile.connect.scan.unsupported"));break;case"failed":o.setError(s("mobile.connect.scan.failed"));break;default:break}}finally{j(!1),C.current===z&&(C.current=null,b(!1))}},[o,i,s]);l.useEffect(()=>()=>C.current?.abort(),[]);const A=l.useCallback(z=>{z.preventDefault(),o.submitPassword(y)},[o,y]),O=l.useCallback(()=>{I(""),o.cancelPassword()},[o]);return t.jsxs(t.Fragment,{children:[w?t.jsx(Pr,{onCancel:()=>C.current?.abort()}):null,P?t.jsx(Tr,{}):null,M?t.jsx(Sr,{onClose:()=>N(!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",{...S,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(qe,{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(se,{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,d?t.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:A,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(se,{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:d.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:d.candidates.some(z=>z.kind==="direct")?Ge(d):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...ct,value:y,onChange:z=>I(z.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:Ct}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null,t.jsx(xe,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!y.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(xe,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:O,children:s("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[R?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(xe,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{v()},disabled:w||i,children:[t.jsx(se,{name:"scan-2",className:Z("size-[18px]",w&&"animate-pulse")}),s(i?"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,c&&!T?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):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 B=k===z.id;return t.jsxs("button",{type:"button",disabled:i,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-primary disabled:opacity-70",onClick:()=>{E(z.id),o.connect({id:z.id,candidates:z.candidates,clientToken:z.clientToken,label:z.label}).finally(()=>E(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(se,{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",B?"text-foreground":"text-muted-foreground"),children:B?s("mobile.connect.connecting"):z.candidates.some(ee=>ee.kind==="direct")?Ge(z):s("mobile.connect.relay.badge")})]}),B?t.jsx(se,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(se,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},z.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[R?t.jsxs("button",{type:"button",onClick:()=>D(z=>!z),"aria-expanded":T,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-primary",children:[t.jsx("span",{children:s("mobile.connect.manual.toggle")}),t.jsx(se,{name:"arrow-down-s",className:Z("size-4 transition-transform duration-200",T&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:T?"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:H,children:[t.jsx("input",{...ct,value:f,onChange:z=>$(z.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:T?void 0:-1,className:Z(Ct,"text-center")}),t.jsx("input",{value:m,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:T?void 0:-1,className:Z(Ct,"text-center")}),t.jsx("input",{...ct,value:h,onChange:z=>x(z.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:T?void 0:-1,autoCapitalize:"none",className:Z(Ct,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null,t.jsx(xe,{type:"submit",variant:R?"outline":"default",size:"lg",className:"h-12 w-full",disabled:i||w||!f.trim(),children:s(i?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},el=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"},tl=n=>{const e=de.c(12),{groups:s,displayMode:o,timeFormatPreference:r,className:i}=n;let a;e[0]!==i?(a=Z("space-y-1.5",i),e[0]=i,e[1]=a):a=e[1];let c;if(e[2]!==o||e[3]!==s||e[4]!==r){let f;e[6]!==o||e[7]!==r?(f=u=>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(go,{providerId:u.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:u.providerName}),u.status&&u.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:u.status}):null]}),u.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:u.rows.map(m=>{const g=o==="remaining"?m.window.remainingPercent:m.window.usedPercent,h=bo(m.window.valueLabel,g),x=xo(m.window.resetAt,m.window.resetAfterFormatted??m.window.resetAtFormatted,r);return t.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate typography-ui-label text-muted-foreground",children:m.subtitle?`${m.subtitle} · ${m.label}`:m.label}),x?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground/70",children:x}):null]}),t.jsx("span",{className:Z("shrink-0 typography-ui-label font-semibold tabular-nums",el(m.window)),children:h==="-"?"":h})]},m.key)})}):null,u.status&&u.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:u.status}):null]},u.providerId),e[6]=o,e[7]=r,e[8]=f):f=e[8],c=s.map(f),e[2]=o,e[3]=s,e[4]=r,e[5]=c}else c=e[5];let d;return e[9]!==a||e[10]!==c?(d=t.jsx("div",{className:a,children:c}),e[9]=a,e[10]=c,e[11]=d):d=e[11],d},jn=380,sl=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},kt=n=>typeof n=="number"&&Number.isFinite(n)?n:0,kn=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),Ir=n=>{const e=de.c(19),{percentage:s}=n;let o,r,i,a,c,d,f;if(e[0]!==s){i=ko(s)??0;const x=So(s);r=x==="critical"?"var(--status-error)":x==="warn"?"var(--status-warning)":"var(--status-success)",o=2*Math.PI*7.5,a="0 0 18 18",c="size-[18px] -rotate-90",d="progressbar",f=Math.round(i),e[0]=s,e[1]=o,e[2]=r,e[3]=i,e[4]=a,e[5]=c,e[6]=d,e[7]=f}else o=e[1],r=e[2],i=e[3],a=e[4],c=e[5],d=e[6],f=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),e[8]=u):u=e[8];const m=o*(1-i/100);let g;e[9]!==o||e[10]!==r||e[11]!==m?(g=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:r,strokeWidth:3,strokeLinecap:"round",strokeDasharray:o,strokeDashoffset:m,className:"transition-[stroke-dashoffset,stroke] duration-300"}),e[9]=o,e[10]=r,e[11]=m,e[12]=g):g=e[12];let h;return e[13]!==a||e[14]!==c||e[15]!==d||e[16]!==f||e[17]!==g?(h=t.jsxs("svg",{viewBox:a,className:c,role:d,"aria-valuenow":f,"aria-valuemin":0,"aria-valuemax":100,children:[u,g]}),e[13]=a,e[14]=c,e[15]=d,e[16]=f,e[17]=g,e[18]=h):h=e[18],h},nl=n=>{const e=de.c(13),{icon:s,iconNode:o,label:r,children:i}=n;let a;e[0]!==s||e[1]!==o?(a=o??(s?t.jsx(se,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=o,e[2]=a):a=e[2];let c;e[3]!==a?(c=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:a}),e[3]=a,e[4]=c):c=e[4];let d;e[5]!==r?(d=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:r}),e[5]=r,e[6]=d):d=e[6];let f;e[7]!==i?(f=t.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:i}),e[7]=i,e[8]=f):f=e[8];let u;return e[9]!==c||e[10]!==d||e[11]!==f?(u=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[c,d,f]}),e[9]=c,e[10]=d,e[11]=f,e[12]=u):u=e[12],u},rl=n=>{const e=de.c(49),{open:s,onClose:o,anchorRef:r,contextDisplay:i,usageGroups:a,usageDisplayMode:c,isUsageLoading:d,timeFormatPreference:f}=n,{t:u}=me(),m=l.useRef(null),[g,h]=l.useState(s),[x,w]=l.useState(!1),{enabled:b}=ys(),P=l.useRef(null),[j,C]=l.useState(null);let R,T;e[0]!==r||e[1]!==b||e[2]!==s||e[3]!==g?(R=()=>{if(!s||!b||!g)return;const G=()=>{const te=r.current?.getBoundingClientRect(),ae=P.current?.getBoundingClientRect();if(!te||!ae){C(null);return}const pe=te.left-ae.left,oe=Math.min(Math.max(pe,8),Math.max(8,ae.width-jn-8));C(oe)};G();const F=P.current;if(typeof ResizeObserver>"u"||!F)return;const Q=new ResizeObserver(G);return Q.observe(F),()=>Q.disconnect()},T=[r,b,s,g],e[0]=r,e[1]=b,e[2]=s,e[3]=g,e[4]=R,e[5]=T):(R=e[4],T=e[5]),l.useLayoutEffect(R,T);const D=b&&j!==null;let k,E;e[6]!==s||e[7]!==g?(k=()=>{if(s){h(!0),w(!1);return}if(!g)return;w(!0);const G=window.setTimeout(()=>{h(!1),w(!1)},140);return()=>window.clearTimeout(G)},E=[s,g],e[6]=s,e[7]=g,e[8]=k,e[9]=E):(k=e[8],E=e[9]),l.useEffect(k,E);let y,I;e[10]!==o||e[11]!==s?(y=()=>{if(!s)return;const G=F=>{F.key==="Escape"&&o()};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},I=[o,s],e[10]=o,e[11]=s,e[12]=y,e[13]=I):(y=e[12],I=e[13]),l.useEffect(y,I);let M,N;if(e[14]!==r||e[15]!==o||e[16]!==s?(M=()=>{if(!s)return;const G=F=>{const Q=F.target;if(!(Q instanceof Node)){o();return}m.current?.contains(Q)||r.current?.contains(Q)||o()};return document.addEventListener("pointerdown",G,!0),document.addEventListener("wheel",G,!0),()=>{document.removeEventListener("pointerdown",G,!0),document.removeEventListener("wheel",G,!0)}},N=[r,o,s],e[14]=r,e[15]=o,e[16]=s,e[17]=M,e[18]=N):(M=e[17],N=e[18]),l.useEffect(M,N),!g)return null;let S;e[19]!==u?(S=u("mobile.header.openMetadataAria"),e[19]=u,e[20]=S):S=e[20];const H=D?"absolute origin-top-left":"mx-3 mt-2",$=x?"pointer-events-none":"pointer-events-auto";let v;e[21]!==H||e[22]!==$?(v=Z("overflow-y-auto overscroll-contain rounded-[20px] border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",H,$),e[21]=H,e[22]=$,e[23]=v):v=e[23];const A=`${x?"session-metadata-out":"session-metadata-in"} ${x?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let O;e[24]!==j||e[25]!==D?(O=D?{top:8,left:j??8,width:`min(${jn}px, calc(100% - 16px))`}:null,e[24]=j,e[25]=D,e[26]=O):O=e[26];let z;e[27]!==A||e[28]!==O?(z={animation:A,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...O},e[27]=A,e[28]=O,e[29]=z):z=e[29];let B;e[30]!==i||e[31]!==u?(B=i?t.jsx(nl,{iconNode:t.jsx(Ir,{percentage:i.percentage}),label:u("mobile.header.metadata.context"),children:t.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[t.jsxs("span",{className:Z("font-semibold",i.colorClass),children:[i.percentage.toFixed(1),"%"]}),t.jsx("span",{className:"text-muted-foreground",children:i.tokens})]})}):null,e[30]=i,e[31]=u,e[32]=B):B=e[32];let ee;e[33]!==d||e[34]!==f||e[35]!==c||e[36]!==a?(ee=t.jsx(ol,{groups:a,displayMode:c,isLoading:d,timeFormatPreference:f}),e[33]=d,e[34]=f,e[35]=c,e[36]=a,e[37]=ee):ee=e[37];let X;e[38]!==B||e[39]!==ee?(X=t.jsxs("div",{className:"space-y-1",children:[B,ee]}),e[38]=B,e[39]=ee,e[40]=X):X=e[40];let _;e[41]!==v||e[42]!==z||e[43]!==X||e[44]!==S?(_=t.jsx("div",{ref:m,role:"dialog","aria-label":S,className:v,style:z,children:X}),e[41]=v,e[42]=z,e[43]=X,e[44]=S,e[45]=_):_=e[45];let J;e[46]===Symbol.for("react.memo_cache_sentinel")?(J=t.jsx("style",{children:`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-DB-Q0Gkz.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-DzriVon2.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/vendor-zustand-BAGL70zf.js","assets/index-1OhiMDBz.css","assets/useAppFontEffects-CbzHzFop.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-BYlZTzrw.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-DKpLs02S.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/contextPanelEmbeddedChat-BO1wRpaN.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CiAYDJXN.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CRSgBxjL.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/vendor-zod-adaMkgkm.js","assets/runtimeEndpointReset-BMBRhIbf.js","assets/shikiHighlight-DXYW46vW.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-h4dHASlq.js","assets/web-components-DCLjCO9n.js","assets/computeVirtualFileMetrics-DYFv_yZS.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/Virtualizer-X_7XPoTH.js","assets/isFilePlainText-Dwq6ILxo.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/scheduledTasksApi-01zzfzqH.js","assets/DiagramEditor-B9NCadU7.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/useInlineCommentController-CegKdDXi.js","assets/CodeMirrorCommentWidgets-DAvopJvy.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{f as de,r as ls,j as t,R as l,c as dt,h as no}from"./vendor-react-BUCujlKS.js";import{u as Ve,a as xt,b as Gn,d as nn,i as Te,e as Ue,s as at,f as At,r as gs,h as ro,j as Kn,k as oo,p as io,l as ao,m as ft,n as lo,o as rn,q as on,t as co,v as an,w as uo,x as fo}from"./index-DzriVon2.js";import{u as bs,a as mo,b as Oe,c as Hn,d as qn,r as xs,e as po,f as me,t as ue,o as ho,I as se,B as xe,g as go,O as qe,h as Z,P as bo,i as xo,j as yo,k as vo,l as ze,m as wo,n as nt,p as jo,q as ln,s as ko,v as ys,w as So,x as No,y as je,z as Co,A as Yn,C as Jn,D as Xn,E as Eo,F as vs,G as Ro,H as Qn,J as Po,K as To,M as Io,L as Zn,N as er,Q as tr,R as sr,S as ws,T as Ao,U as _o,V as js,W as Do,X as Mo,Y as cn,Z as ks,_ as nr,$ as rr,a0 as Ss,a1 as zo,a2 as Oo,a3 as Lo,a4 as We,a5 as Bo,a6 as $o,a7 as Fo,a8 as Wo,a9 as Uo,aa as Vo,ab as Go,ac as Le,ad as Ko,ae as Ho,af as qo,ag as Ft,ah as Yo,ai as Jo,aj as Xo,ak as Qo,al as or,am as Zo,an as ei,ao as ti,ap as si,aq as ni,ar as ri,as as oi,at as ii,au as ai,av as li,aw as ci,ax as ui,ay as di,az as fi,aA as mi,aB as pi,aC as hi,aD as gi,aE as bi,aF as xi,aG as yi,aH as vi,aI as wi,aJ as ji,aK as ki,aL as Si,aM as Ni,aN as Ci,aO as Ei,aP as Ri}from"./useAppFontEffects-CbzHzFop.js";import{u as lt,S as ir,D as Pi,N as Ti,a as Ii,b as Ai,T as _i,P as Di,M as Mi,r as zi,c as Oi,d as Li,e as Bi,O as $i,C as Fi,f as Wi,g as Ui}from"./runtimeEndpointReset-BMBRhIbf.js";import{_ as mt}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as Vi,A as Gi}from"./SettingsView-3B9VN6Ys.js";import{PlanView as Ki}from"./PlanView-UvuxIl9-.js";import{p as Hi}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as qi}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as cs,s as ar,M as Ns,a as Gt,J as us,p as Yi,_ as un,b as lr,P as cr,d as Ji,f as Cs,V as Xi,K as dn,c as Qi,Q as Zi,r as ea,U as ta,Z as sa}from"./vendor-remixicon-react-Dil0zKKT.js";import{f as Es,h as pt,i as Rs,P as Ps,D as Ts,j as Is}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as As,S as _s,v as Ds,u as Ms}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as zs}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as Os,p as ur}from"./vendor-zustand-BAGL70zf.js";import{C as na,a as ra}from"./CommitSection-D9cV-qR9.js";import{P as oa}from"./PierreDiffViewer-D_Gt4A_6.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BYlZTzrw.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-BO1wRpaN.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.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-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CiAYDJXN.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-zod-adaMkgkm.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-DXYW46vW.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./useInlineCommentController-CegKdDXi.js";import"./CodeMirrorCommentWidgets-DAvopJvy.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./web-components-DCLjCO9n.js";import"./computeVirtualFileMetrics-DYFv_yZS.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"./VirtualizedFileDiff-B37yB9jZ.js";import"./isDiffPlainText-DwHKxDYc.js";import"./vendor-diff-C3JhlQdm.js";let dr=null,fn=!1;const ia=new Promise(n=>{dr=n});function aa(){fn||(fn=!0,dr?.())}const la=6,ca=n=>n.parentID??null,mn=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},ua=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),da=(n,e)=>{if(!n)return"";let s=null,o=-1;for(const r of e){const i=ua(r.path);(n===i||n.startsWith(`${i}/`))&&i.length>o&&(s=r,o=i.length)}return s?s.label?.trim()||mn(s.path):mn(n)},fa=()=>{const n=bs.getState().activeSessions,e=mo.getState().index.session.unseenCount,s=Ve.getState().notifyOnSubtasks,o=Oe.getState().projects,r=Hn.getState().ids,i=qn.getState().rankById;let a=0;const c=[];for(const f of n){const u=ca(f)!==null,g=(e[f.id]??0)>0&&(!u||s);g&&(a+=1),u||c.push({session:f,unread:g,project:da(xs(f),o)})}c.sort((f,u)=>po(f.session,u.session,r,i));const d=c.slice(0,la).map(({session:f,unread:u,project:m})=>({id:f.id,title:f.title??"",unread:u,project:m}));return{runtimeKey:xt(),attentionCount:a,recentSessions:d}},ma="__OPENCHAMBER_WIDGET_SNAPSHOT__",pa=()=>{typeof window>"u"||(window[ma]=()=>{try{return JSON.stringify(fa())}catch{return null}})},ts="mobile-app-update-available",pn="mobile-app-update-toast-dismissed-version",ha=()=>{const n=de.c(8),{t:e}=me(),s=lt(ga),o=lt(ba),r=lt(xa),i=lt(ya);let a;n[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,n[0]=a):a=n[0];const c=ls.useRef(a);let d,f;return n[1]!==s||n[2]!==i||n[3]!==o||n[4]!==e||n[5]!==r?(d=()=>{if(Gn()!=="android"||o!=="mobile"||!s||!r||!i){ue.dismiss(ts);return}nn().getItem(pn)!==r&&(c.current.has(r)||(c.current.add(r),ue.info(e("mobileUpdate.toast.available.title"),{id:ts,description:e("mobileUpdate.toast.available.description",{version:r}),duration:1/0,icon:t.jsx(se,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{ho(i)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{nn().setItem(pn,r),ue.dismiss(ts)}}})))},f=[s,i,o,e,r],n[1]=s,n[2]=i,n[3]=o,n[4]=e,n[5]=r,n[6]=d,n[7]=f):(d=n[6],f=n[7]),ls.useEffect(d,f),null};function ga(n){return n.available}function ba(n){return n.runtimeType}function xa(n){return n.info?.version}function ya(n){return n.info?.downloadUrl}const hn=300,va="openchamber.mobile.connectLog.v1",ct=[];if(typeof window<"u")try{window.localStorage.removeItem(va)}catch{}const Ls=(n,e)=>{ct.push({at:Date.now(),step:n,detail:e}),ct.length>hn&&ct.splice(0,ct.length-hn)};typeof window<"u"&&Ls("app:launch","{}");const wa=()=>[...ct],ja=n=>{const e=new Date(n),s=(o,r=2)=>String(o).padStart(r,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},fr=n=>`${ja(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,ka=()=>ct.map(fr).join(`
3
+ `),mr=(n,e)=>{const s=de.c(10),o=700,r=l.useRef(null),i=l.useRef(null),a=l.useRef(!1);let c;s[0]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{r.current!==null&&window.clearTimeout(r.current),r.current=null,i.current=null},s[0]=c):c=s[0];const d=c;let f,u;s[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>d,u=[d],s[1]=f,s[2]=u):(f=s[1],u=s[2]),l.useEffect(f,u);let m;s[3]!==o||s[4]!==n?(m=j=>{a.current=!1,i.current={x:j.clientX,y:j.clientY},r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,a.current=!0,n()},o)},s[3]=o,s[4]=n,s[5]=m):m=s[5];const g=m;let h;s[6]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{const C=i.current;C&&(Math.abs(j.clientX-C.x)>10||Math.abs(j.clientY-C.y)>10)&&d()},s[6]=h):h=s[6];const x=h;let w;s[7]===Symbol.for("react.memo_cache_sentinel")?(w=j=>{a.current&&(a.current=!1,j.preventDefault(),j.stopPropagation())},s[7]=w):w=s[7];const b=w;let P;return s[8]!==g?(P={onPointerDown:g,onPointerMove:x,onPointerUp:d,onPointerCancel:d,onClickCapture:b},s[8]=g,s[9]=P):P=s[9],P},Kt="openchamber.mobile.connections.v1",Sa="openchamber.mobile.",gn="openchamber.mobile.deviceId",Na=()=>{try{const n=window.localStorage.getItem(gn);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem(gn,e),e}catch{return crypto.randomUUID()}},bn=()=>`mobile:${Na()}`,xn=()=>{try{const n=qi.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},pr=12,hr=8e3,Ca=2500,Ea=3e3,Ht=2500,Ra=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},yt=n=>{const e=n.trim();if(!e)return"";const s=/^https?:\/\//i.test(e)?e:`http://${e}`,o=new URL(s);return o.hash="",o.search="",o.pathname=o.pathname.replace(/\/+$/,""),o.toString().replace(/\/+$/,"")},Wt=n=>{try{return new URL(n).host}catch{return n}},ht=n=>{try{return yt(n)}catch{return n.trim().replace(/\/+$/g,"")}},gr=(n,e)=>ht(n)===ht(e),br=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,Pa=n=>`relay://${n.serverId}`,Xt=n=>n.candidates.filter(e=>e.kind==="direct"),Xe=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},Ge=n=>{const e=Xt(n)[0];if(e)return e.url;const s=Xe(n);return s?Pa(s):""},Re=n=>{const e=Xe(n);if(e)return br(e);const s=Xt(n)[0];return s?ht(s.url):""},qt=(n,e)=>{const s=n.find(i=>i.kind==="relay"),o=s&&s.kind==="relay"?s.relay.serverId:null,r=new Set(n.filter(i=>i.kind==="direct").map(i=>ht(i.url)));return e.some(i=>i.kind==="relay"?o!==null&&i.relay.serverId===o:r.has(ht(i.url)))},Bs=n=>{const e=(()=>{try{return yt(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},yn=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(...Bs(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},$s=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 o=s;return o.kty!=="EC"||o.crv!=="P-256"||typeof o.x!="string"||!o.x||typeof o.y!="string"||!o.y?null:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:{kty:"EC",crv:"P-256",x:o.x,y:o.y}}},xr=n=>{try{return JSON.stringify(n)}catch{return String(n)}},he=(n,e={})=>{const s=xr(e);console.info("[mobile-connect]",n,s),Ls(n,s)},jt=(n,e={})=>{he(n,e)},gt=(n,e={})=>{const s=xr(e);console.info("[mobile-storage]",n,s),Ls(n,s)},Ta=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},Ia=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},Aa=async(n,e)=>{if(!Te())return null;try{const{CapacitorHttp:s}=await mt(async()=>{const{CapacitorHttp:i}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:i}},[]),o=oo(n,new Headers(e?.headers)),r=await s.request({url:n,method:e?.method||"GET",headers:Object.fromEntries(o.entries()),data:Ia(e?.body)});return{ok:r.status>=200&&r.status<300,status:r.status,source:"native-http",json:async()=>Ta(r.data)}}catch(s){return he("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},_a=async(n,e)=>{const s=await fetch(n,e).catch(o=>(he("browser-fetch:failed",{url:n,error:o instanceof Error?o.message:String(o)}),null));return s?{ok:s.ok,status:s.status,source:"browser-fetch",json:()=>s.json()}:null},He=async(n,e,s)=>{let o;const r=new Promise(i=>{o=window.setTimeout(()=>{s?.(),i(null)},n)});try{return await Promise.race([e,r])}catch{return null}finally{o!==void 0&&window.clearTimeout(o)}},Qe=async(n,e,s)=>{const o=s?.totalTimeoutMs??hr,r=Date.now(),i=await He(Math.min(Ca,o),Aa(n,e));if(i)return i;const a=new AbortController,c=Math.max(500,o-(Date.now()-r));return He(c,_a(n,{...e,signal:a.signal}),()=>a.abort())},Qt=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}},bt=15e3,Da=async(n,e,s,o=bt,r)=>{const i=Kn({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk}),a=c=>c==="ok"&&r?.keepTunnel?{outcome:c,tunnel:i}:(i.close(),{outcome:c});try{const c=e?{Authorization:`Bearer ${e}`}:void 0,d=await He(o,i.fetch("/auth/session",{headers:c}).catch(()=>null));if(he("relay:session",{ok:d?.ok===!0,status:d?.status??null,hasToken:!!e}),!d)return a("unreachable");if(d.status===401)return a(e?"auth-failed":"needs-login");if(!d.ok&&d.status!==404)return a("auth-failed");const f=await Qt(d);return f&&f.disabled!==!0&&f.authenticated===!1?a(e?"auth-failed":"needs-login"):a("ok")}catch(c){throw i.close(),c}},Ma=(n,e,s,o,r)=>{const i=typeof window<"u"?window.location.origin:"",a={relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk,...s?{grant:s}:{}};r&&ro(a,r),at({apiBaseUrl:i,clientToken:e,runtimeKey:o??br(n),relay:a})},za=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=$s(e.relay);return s?{kind:"relay",relay:s}:null}return null},Oa=n=>{if(n.mode==="relay"){const e=$s(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?Bs(n.url):[]},et=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(Kt)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=Te();return n.flatMap(s=>{if(!s||typeof s!="object")return[];const o=s;if(typeof o.id!="string")return[];const r=Array.isArray(o.candidates)?o.candidates.map(za).filter(d=>!!d):Oa(o);if(r.length===0)return[];const i=typeof o.clientToken=="string"&&o.clientToken.trim()?o.clientToken:void 0,a=typeof o.label=="string"&&o.label.trim()?o.label:Wt(Ge({candidates:r})),c={id:o.id,label:a,candidates:r,lastUsedAt:typeof o.lastUsedAt=="number"?o.lastUsedAt:0};return e?[{...c,hasToken:!!o.hasToken||!!i}]:[{...c,clientToken:i,hasToken:!!i}]}).sort((s,o)=>o.lastUsedAt-s.lastUsedAt)},ds=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},Fs=n=>{if(typeof window>"u")return;const e=Te(),s=n.slice(0,pr).map(o=>{const r={id:o.id,label:o.label,candidates:o.candidates.map(ds),lastUsedAt:o.lastUsedAt};return e?{...r,hasToken:!!(o.hasToken||o.clientToken)}:{...r,clientToken:o.clientToken}});try{window.localStorage.setItem(Kt,JSON.stringify(s))}catch(o){console.warn("[mobile-storage] failed to persist connection metadata",o)}},yr=(n,e)=>{const s=n.find(i=>e.id&&i.id===e.id||qt(i.candidates,e.candidates)),o=Te(),r={id:e.id||s?.id||crypto.randomUUID(),label:e.label,candidates:e.candidates,lastUsedAt:Date.now(),...o?{hasToken:e.hasToken??(!!e.clientToken||s?.hasToken||!1)}:{clientToken:e.clientToken??s?.clientToken,hasToken:!!(e.clientToken??s?.clientToken)}};return[r,...n.filter(i=>i.id!==r.id&&!qt(i.candidates,e.candidates))].slice(0,pr)},Ws=Hi,La=0,Us=n=>`${Sa}token.${encodeURIComponent(n)}`,Ba=async(n,e)=>{let s;const o=new Promise(r=>{s=window.setTimeout(()=>r(e),Ea)});try{return await Promise.race([n.catch(()=>e),o])}finally{s!==void 0&&window.clearTimeout(s)}},Vs=async(n,e,s)=>Te()?Ba(e().catch(o=>(console.warn(`[mobile-storage] ${n} failed`,o),s)),s):s,_t=async n=>{gt("secure:read-start",{key:n});const e=await Vs("secure:read",async()=>(await Ws.internalGetItem({prefixedKey:Us(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return gt("secure:read",{key:n,hasToken:!!s}),s},Ye=async(n,e)=>{gt("secure:write-start",{key:n});const s=await Vs("secure:write",async()=>(await Ws.internalSetItem({prefixedKey:Us(n),data:e,sync:!1,access:La}),!0),!1);return gt("secure:write",{key:n,ok:s}),s},$a=async n=>{await Vs("secure:delete",async()=>(await Ws.internalRemoveItem({prefixedKey:Us(n),sync:!1}),!0),!1)},Fa=async(n,e)=>{let s=0,o=0;return{records:await Promise.all(n.map(async i=>{if(!i||typeof i!="object")return i;const a=i,c=typeof a.url=="string"?a.url:null,d=typeof a.clientToken=="string"?a.clientToken.trim():"";if(!c||!d)return i;if(!await e(c,d))return o+=1,i;s+=1;const{clientToken:f,...u}=a;return{...u,hasToken:!0}})),migrated:s,failed:o}},vr=async()=>{if(typeof window>"u"||!Te())return;let n;try{n=JSON.parse(window.localStorage.getItem(Kt)||"[]")}catch{return}if(!Array.isArray(n))return;const e=n.filter(o=>!!o&&typeof o=="object"&&typeof o.url=="string"&&typeof o.clientToken=="string"&&!!o.clientToken.trim());if(e.length===0)return;gt("secure:migrate-start",{count:e.length});const s=await Fa(n,async(o,r)=>{const i=ht(o);return await Ye(i,r)?await _t(i)===r:!1});if(s.migrated>0)try{window.localStorage.setItem(Kt,JSON.stringify(s.records))}catch(o){console.warn("[mobile-storage] failed to finalize secure token migration",o);return}gt("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},Wa=async()=>(await vr(),et()),Yt=async n=>{const e=yr(et(),n);return Fs(e),Te()&&n.clientToken&&await Ye(Re({candidates:n.candidates}),n.clientToken),e},Ua=async n=>{const e=et(),s=e.find(r=>r.id===n)??null,o=e.filter(r=>r.id!==n);return Fs(o),s&&Te()&&await $a(Re(s)),o},Va=1500,Jt=async(n,e,s)=>{const o=s?.fast?{totalTimeoutMs:Ht}:void 0,r=Xe({candidates:n})?.serverId??null,i=n.find(f=>f.kind==="relay")??null,a=n.filter(f=>f.kind==="direct"),c=async()=>{for(const f of a){const u=yt(f.url)||f.url,m=e?{Authorization:`Bearer ${e}`}:void 0,g=await Qe(`${u}/health`,{method:"GET"},o);if(he("probe:direct:health",{url:u,ok:g?.ok===!0,status:g?.status??null,source:g?.source??null}),!g?.ok)continue;if(r){const b=await g.json().catch(()=>null),P=b&&typeof b=="object"?b.serverId:null;if(typeof P=="string"&&P&&P!==r){he("probe:server-id-mismatch",{url:u});continue}}const h=await Qe(`${u}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:m},o);if(he("probe:direct:session",{url:u,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 x=await Qt(h);if(x&&x.disabled!==!0&&x.authenticated===!1)return{status:"needs-login"};const w=x?.disabled===!0;return!e&&Te()&&!w&&x?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:u}}}return{status:"unreachable"}},d=async()=>{if(!i)return{status:"unreachable"};const{outcome:f,tunnel:u}=await Da(i.relay,e,void 0,s?.fast?Ht:hr,{keepTunnel:!0});return f==="ok"?{status:"ok",transport:{kind:"relay",relay:i.relay,tunnel:u}}:f==="needs-login"||f==="auth-failed"?{status:"needs-login"}:{status:"unreachable"}};return i?a.length===0?d():new Promise(f=>{let u=!1,m=!1,g,h=null,x=null;const w=j=>{j?.status==="ok"&&j.transport.kind==="relay"&&j.transport.tunnel?.close()},b=j=>{u||(u=!0,f(j))},P=()=>{m||u||(g!==void 0&&(window.clearTimeout(g),g=void 0),d().then(j=>{if(x=j,u||m){w(j);return}if(j.status==="ok"||j.status==="needs-login"){b(j);return}h&&b(h)}))};c().then(j=>{if(h=j,!u){if(j.status==="ok"||j.status==="needs-login"){m=!0,g!==void 0&&window.clearTimeout(g),w(x),b(j);return}if(x){b(x);return}P()}}),g=window.setTimeout(P,Va)}):c()},Je=(n,e,s)=>{n.kind==="relay"?Ma(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel):at({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),jr()},Nt=()=>{const n=et()[0];return n?.label?.trim()?n.label:null},kt=async n=>{const e=n?.fast!==!1;await vr();const s=et()[0];if(he("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let o;if(Te()){if(s.hasToken&&(o=await _t(Re(s)),!o))return{status:"no-candidate"}}else if(o=s.clientToken,!o&&s.hasToken)return{status:"no-candidate"};const r=await Jt(s.candidates,o,{fast:e});return he("auto-connect:probe",{status:r.status,candidates:s.candidates.map(i=>i.kind)}),r.status==="needs-login"?{status:"needs-login",label:s.label}:r.status!=="ok"?{status:"unreachable",label:s.label}:n?.skipIfConnected&&Ue()?(r.transport.kind==="relay"&&r.transport.tunnel?.close(),he("auto-connect:superseded",{}),{status:"no-candidate"}):(await Yt({id:s.id,label:s.label,candidates:s.candidates}),Je(r.transport,o??null,{runtimeKey:Re(s)}),{status:"connected"})},Ga=async(n,e)=>{let s="";try{s=yt(n.url)}catch{return!1}if(!s)return!1;const o=n.clientToken?.trim()||void 0,r=o?{Authorization:`Bearer ${o}`}:void 0,i=e?.fast?{totalTimeoutMs:Ht}:void 0;if(!(await Qe(`${s}/health`,{method:"GET",headers:r},i))?.ok)return!1;const c=await Qe(`${s}/auth/session`,{method:"GET",credentials:o?"omit":"include",headers:r},i);if(!c||!c.ok&&c.status!==404)return!1;const d=await Qt(c);return!(d&&d.disabled!==!0&&d.authenticated===!1)},Ka=n=>[...n].sort((e,s)=>{const o=(e.priority??100)-(s.priority??100);if(o!==0)return o;const r=i=>i.type==="relay"?2:i.url.startsWith("https://")?0:1;return r(e)-r(s)}).flatMap(e=>{if(e.type==="relay"){const s=$s({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return Bs(e.url)}),vn=async n=>{const e=Xe({candidates:n})?.serverId??null;for(const s of n){if(s.kind==="relay"){const i=Kn(s.relay),a=await He(bt,i.fetch("/health").catch(()=>null));if(he("establish:relay:health",{ok:a?.ok===!0,status:a?.status??null}),a?.ok)return{kind:"relay",relay:s.relay,tunnel:i};i.close();continue}const o=yt(s.url)||s.url,r=await Qe(`${o}/health`,{method:"GET"});if(he("establish:direct:health",{ok:r?.ok===!0,status:r?.status??null}),!!r?.ok){if(e){const i=await r.json().catch(()=>null),a=i&&typeof i=="object"?i.serverId:null;if(typeof a=="string"&&a&&a!==e){he("establish:server-id-mismatch",{url:o});continue}}return{kind:"direct",url:o}}}return null},Ha=async(n,e)=>{if(!At())return Ga(n,e);const s=await He(e?.fast?Ht:bt,gs("/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 o=await Qt(s);return!(o&&o.disabled!==!0&&o.authenticated===!1)},qa=n=>n.kind==="relay"?At():!At()&&gr(n.url,Ue()),wr=()=>{const n=xt();return n?et().find(e=>Re(e)===n)??null:null},wn=n=>{const e=xt();return!!e&&Re(n)===e},Ut=async n=>{const e=n?.fast!==!1,s=wr();if(!s)return he("reprobe:no-connection",{runtimeKey:!!xt()}),"no-connection";let o;if(Te()?o=s.hasToken?await _t(Re(s)):void 0:o=s.clientToken,!o&&s.hasToken)return he("reprobe:no-token",{hasToken:!0}),"unreachable";he("reprobe:start",{candidates:s.candidates.map(f=>f.kind),fast:e,hasToken:!!o});const r=s.candidates.findIndex(f=>qa(f.kind==="relay"?{kind:"relay",relay:f.relay}:{kind:"direct",url:f.url})),i=r>=0?s.candidates.slice(0,r):s.candidates,a=await Jt(i,o,{fast:e});if(he("reprobe:better",{status:a.status,probed:i.length}),a.status==="ok")return await Yt({id:s.id,label:s.label,candidates:s.candidates}),Je(a.transport,o??null,{runtimeKey:Re(s)}),"switched";if(a.status==="needs-login")return"needs-login";if(r>=0){const f=await Ha({url:Ue(),clientToken:o},{fast:e});if(he("reprobe:current",{stillValid:f}),f)return jr(),"unchanged"}const c=r>=0?s.candidates.slice(r+1):[],d=await Jt(c,o,{fast:e});return he("reprobe:fallback",{status:d.status,probed:c.length}),d.status==="ok"?(await Yt({id:s.id,label:s.label,candidates:s.candidates}),Je(d.transport,o??null,{runtimeKey:Re(s)}),"switched"):d.status==="needs-login"?"needs-login":"unreachable"},Ya=5e3;let ss=!1;const Ja=async()=>{if(ss)return"skipped";const n=wr();if(!n)return he("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=Xe(n);if(!e)return he("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";ss=!0;try{const s=await He(bt,gs("/api/client-auth/connection/candidates").then(f=>f).catch(()=>null));if(!s?.ok)return he("candidates:refresh-skip",{reason:"fetch-failed",status:s?.status??null}),"skipped";const o=await s.json().catch(()=>null);if(!o||o.serverId!==e.serverId)return he("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const r=Array.isArray(o.candidates)?o.candidates:[],i=[];for(const f of r){if(!f||typeof f!="object")continue;const u=f;if(!(u.type!=="lan"||typeof u.url!="string"))try{const m=yt(u.url);m&&!i.includes(m)&&i.push(m)}catch{}}if(i.length===0)return he("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const a=Xt(n).filter(f=>f.url.startsWith("https://")),c=[...i.map(f=>({kind:"direct",url:f})),...a,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map(ds))===JSON.stringify(c.map(ds))?"unchanged":(he("candidates:refreshed",{lanCount:i.length}),await Yt({id:n.id,label:n.label,candidates:c}),"updated")}finally{ss=!1}},jr=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await Ja().catch(()=>"skipped");he("candidates:refresh-result",{result:n}),n==="updated"&&At()&&await Ut().catch(()=>null)})()},Ya)},kr=n=>{const{t:e}=me(),[s,o]=l.useState(()=>et()),[r,i]=l.useState(null),[a,c]=l.useState(null),[d,f]=l.useState(null),u=l.useRef(s),m=l.useRef(null),g=l.useRef(Ra()),h=l.useCallback(k=>{u.current=k,o(k)},[]),x=l.useCallback(k=>{m.current=k,i(k)},[]),w=l.useCallback(k=>{m.current===k&&(m.current=null,i(null))},[]);l.useEffect(()=>{let k=!1;return Wa().then(E=>{k||h(E)}),()=>{k=!0}},[h]);const b=l.useCallback(k=>{const E=yr(u.current,k);return h(E),Fs(E),E},[h]),P=l.useCallback(async k=>{c(null),x("connect");try{const E=yn(k);if(E.length===0){c(e("mobile.connect.error.urlRequired"));return}const y=k.id?u.current.find($=>$.id===k.id):u.current.find($=>qt($.candidates,E)),I=k.label?.trim()||y?.label||Wt(Ge({candidates:E})),M=k.relayGrant;let N=k.clientToken?.trim()||void 0;const S=!!N;N||(Te()?y?.hasToken&&(N=await _t(Re({candidates:E}))):N=y?.clientToken),he("connect:start",{candidates:E.map($=>$.kind),hasToken:!!N});const H=await Jt(E,N);if(he("connect:probe",{status:H.status}),H.status==="unreachable"){c(e("mobile.connect.error.unreachable"));return}if(H.status==="needs-login"){b({id:y?.id,label:I,candidates:E}),f({id:y?.id??crypto.randomUUID(),label:I,candidates:E,relay:Xe({candidates:E})??void 0,relayGrant:M});return}N&&S&&Te()&&await Ye(Re({candidates:E}),N),b({id:y?.id,label:I,candidates:E,clientToken:N}),Je(H.transport,N??null,{runtimeKey:Re({candidates:E}),grant:M}),n()}catch(E){console.warn("[mobile-connect] connect threw",E),c(e("mobile.connect.error.invalidUrl"))}finally{w("connect")}},[x,w,n,b,e]),j=l.useCallback(async k=>{if(m.current==="pairing")return;c(null),x("pairing");const E=Ka(k.candidates);let y=null,I=!1;try{if(y=await vn(E),!y){c(e("mobile.connect.error.unreachable"));return}const M=JSON.stringify({pairingId:k.pairingId,secret:k.secret,clientLabel:"OpenChamber Mobile",clientKind:"mobile",deviceName:"OpenChamber Mobile",devicePlatform:xn(),dedupeKey:bn()}),N={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:M},S=y.kind==="relay"?await He(bt,y.tunnel.fetch("/api/client-auth/pairing/redeem",N).catch(()=>null)):await Qe(`${y.url}/api/client-auth/pairing/redeem`,N);if(!S?.ok){c(e("mobile.connect.error.authRequired"));return}const H=await S.json().catch(()=>null),$=typeof H?.clientToken=="string"?H.clientToken.trim():"";if(!$){c(e("mobile.connect.error.authRequired"));return}const v=typeof H?.server?.label=="string"?H.server.label:"",A=k.label||v||Wt(Ge({candidates:E}));if(Te()&&!await Ye(Re({candidates:E}),$)){c(e("mobile.connect.error.authRequired"));return}b({label:A,candidates:E,clientToken:$}),Je(y.kind==="relay"?{kind:"relay",relay:y.relay,tunnel:y.tunnel}:{kind:"direct",url:y.url},$,{runtimeKey:Re({candidates:E})}),I=y.kind==="relay",n()}catch(M){console.warn("[mobile-connect] pairing threw",M),c(e("mobile.connect.error.authRequired"))}finally{!I&&y?.kind==="relay"&&y.tunnel.close(),w("pairing")}},[x,w,n,b,e]),C=l.useCallback(async k=>{if(!d||!k.trim()||m.current==="password")return;c(null),x("password");const E=g.current.begin(),y=()=>g.current.isCurrent(E),{id:I,label:M,candidates:N}=d;let S=null,H=!1;try{if(S=await vn(N),!y())return;if(!S){c(e("mobile.connect.error.unreachable"));return}const $={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:k,trustDevice:!0,issueClientToken:!0,clientLabel:"OpenChamber Mobile",clientKind:"mobile",devicePlatform:xn(),dedupeKey:bn()})};he("password:start",{transport:S.kind});const v=S.kind==="relay"?await He(bt,S.tunnel.fetch("/auth/session",$).catch(()=>null)):await Qe(`${S.url}/auth/session`,$);if(!y())return;if(he("password:done",{ok:v?.ok===!0,status:v?.status??null}),!v?.ok){c(e("mobile.connect.error.passwordFailed"));return}const A=await v.json().catch(()=>null);if(!y())return;const O=typeof A?.clientToken=="string"?A.clientToken.trim():"";if(he("password:token",{issued:!!O}),!O){if(S.kind==="direct"&&!Te()){b({id:I,label:M,candidates:N}),f(null),Je({kind:"direct",url:S.url},null,{runtimeKey:Re({candidates:N})}),n();return}c(e("mobile.connect.error.authRequired"));return}if(Te()&&(!y()||(await Ye(Re({candidates:N}),O),!y()))||!y()||(b({id:I,label:M,candidates:N,clientToken:O}),f(null),Je(S.kind==="relay"?{kind:"relay",relay:S.relay,tunnel:S.tunnel}:{kind:"direct",url:S.url},O,{runtimeKey:Re({candidates:N})}),H=S.kind==="relay",!y()))return;n()}catch($){if(!y())return;console.warn("[mobile-connect] password threw",$),c(e("mobile.connect.error.passwordFailed"))}finally{!H&&S?.kind==="relay"&&S.tunnel.close(),y()&&w("password")}},[x,w,n,d,b,e]),R=l.useCallback(()=>{g.current.cancel(),w("password"),f(null),c(null)},[w]),T=l.useCallback(async k=>{c(null);let E=yn(k);const y=k.id?u.current.find(S=>S.id===k.id)??null:null;if(y){const S=E.filter(v=>v.kind==="direct"),H=Xt(y).filter(v=>v.url.startsWith("https://")&&!S.some(A=>gr(A.url,v.url))),$=Xe(y);E=[...S,...H,...$?[{kind:"relay",relay:$}]:[]]}if(E.length===0)return c(e("mobile.connect.error.urlRequired")),null;const I=k.clientToken?.trim()||void 0,M=k.label?.trim()||Wt(Ge({candidates:E}));if(Te()){const S=Re({candidates:E});if(I)await Ye(S,I);else if(y?.hasToken){const H=Re(y);if(H&&S&&H!==S){const $=await _t(H);$&&await Ye(S,$)}}}return b({id:k.id,label:M,candidates:E,clientToken:I}).find(S=>qt(S.candidates,E))??null},[b,e]),D=l.useCallback(async k=>{const E=u.current.find(I=>I.id===k)??null,y=await Ua(k);return h(y),E},[h]);return{connections:s,isBusy:r!==null,isPasswordBusy:r==="password",error:a,pendingConnection:d,connect:P,redeemPairingConnection:j,submitPassword:C,cancelPassword:R,saveConnection:T,removeConnection:D,setError:c}},Sr=n=>{const e=de.c(31),{onClose:s}=n,{t:o}=me(),[r,i]=l.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=wa(),e[0]=a):a=e[0];const c=a;let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{go(ka()).then(k=>{k.ok&&(i(!0),window.setTimeout(()=>i(!1),2e3))})},e[1]=d):d=e[1];const f=d;let u;e[2]!==o?(u=o("mobile.connectionDebug.title"),e[2]=o,e[3]=u):u=e[3];let m;e[4]!==u?(m=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:u}),e[4]=u,e[5]=m):m=e[5];const g=r?"check":"file-copy";let h;e[6]!==g?(h=t.jsx(se,{name:g,className:"size-4"}),e[6]=g,e[7]=h):h=e[7];let x;e[8]!==r||e[9]!==o?(x=o(r?"mobile.connectionDebug.copied":"mobile.connectionDebug.copy"),e[8]=r,e[9]=o,e[10]=x):x=e[10];let w;e[11]!==h||e[12]!==x?(w=t.jsxs(xe,{type:"button",variant:"outline",size:"sm",onClick:f,disabled:c.length===0,children:[h,x]}),e[11]=h,e[12]=x,e[13]=w):w=e[13];let b;e[14]!==o?(b=o("mobile.connectionDebug.close"),e[14]=o,e[15]=b):b=e[15];let P;e[16]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(se,{name:"close",className:"size-[18px]"}),e[16]=P):P=e[16];let j;e[17]!==s||e[18]!==b?(j=t.jsx(xe,{type:"button",variant:"ghost",size:"icon","aria-label":b,onClick:s,children:P}),e[17]=s,e[18]=b,e[19]=j):j=e[19];let C;e[20]!==j||e[21]!==w?(C=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[w,j]}),e[20]=j,e[21]=w,e[22]=C):C=e[22];let R;e[23]!==C||e[24]!==m?(R=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[m,C]}),e[23]=C,e[24]=m,e[25]=R):R=e[25];let T;e[26]!==o?(T=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:c.length===0?t.jsx("p",{className:"typography-small text-muted-foreground",children:o("mobile.connectionDebug.empty")}):t.jsx("pre",{className:"whitespace-pre-wrap break-words typography-code text-muted-foreground",children:c.map(fr).join(`
4
+ `)})}),e[26]=o,e[27]=T):T=e[27];let D;return e[28]!==R||e[29]!==T?(D=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:[R,T]}),e[28]=R,e[29]=T,e[30]=D):D=e[30],D},Nr=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},Xa=()=>window.Capacitor?.getPlatform?.()==="android",Cr=n=>{const e=n.trim();if(!e)return null;if(/^openchamber:\/\//i.test(e)){const s=io(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},Er=(n,e)=>{const s=Cr(n);if(!s&&e?.pairingStringFallback){const o=ao(n);if(o)return{status:"pairing",pairing:o}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},Qa=async(n,e)=>{if(!n.startScan||!n.stopScan||!n.addListener)return{status:"unsupported"};if(e?.aborted)return{status:"cancelled"};let s,o,r=!1,i=()=>{};const a=new Promise(f=>{i=f}),c=f=>{r||(r=!0,i(f))},d=()=>c({status:"cancelled"});e?.addEventListener("abort",d,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:u})=>{const m=u?.[0],g=(m?.rawValue??m?.displayValue??"").trim();g&&c(Er(g,{pairingStringFallback:!0}))})).then(u=>{s=u}),Promise.resolve(n.addListener("scanError",()=>c({status:"failed"}))).then(u=>{o=u})])).some(({status:u})=>u==="rejected")?c({status:"failed"}):r||n.startScan({formats:["QR_CODE"]}).catch(()=>c({status:"failed"})),await a}finally{e?.removeEventListener("abort",d),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(o?.remove()),n.stopScan()])}},fs=()=>Nr()!==null,Rr=async n=>{const e=Nr();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(Xa())return Qa(e,n?.signal);if(!e.scan)return{status:"unsupported"};const o=(await e.scan({formats:["QR_CODE"]}))?.barcodes?.[0],r=(o?.rawValue??o?.displayValue??"").trim();return r?Er(r):{status:"cancelled"}}catch{return{status:"failed"}}},ut={autoComplete:"off",autoCorrect:"off",spellCheck:!1},Ct="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-primary focus:ring-2 focus:ring-primary/20",Pr=n=>{const e=de.c(22),{onCancel:s}=n,{t:o}=me(),r=l.useRef(null);let i,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const P={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},j={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,R=D=>{!(D instanceof HTMLElement)||D===r.current||C.has(D)||(C.set(D,{opacity:D.style.opacity,pointerEvents:D.style.pointerEvents}),D.style.setProperty("opacity","0"),D.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(R);const T=new MutationObserver(D=>{D.forEach(k=>k.addedNodes.forEach(R))});return T.observe(document.body,{childList:!0}),()=>{T.disconnect(),C.forEach(Za),P.value?document.documentElement.style.setProperty("background-color",P.value,P.priority):document.documentElement.style.removeProperty("background-color"),j.value?document.body.style.setProperty("background-color",j.value,j.priority):document.body.style.removeProperty("background-color")}},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),l.useLayoutEffect(i,a);let c,d;e[2]!==s?(c=()=>{const P=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",P),()=>document.removeEventListener("visibilitychange",P)},d=[s],e[2]=s,e[3]=c,e[4]=d):(c=e[3],d=e[4]),l.useEffect(c,d);let f;e[5]!==o?(f=o("mobile.connect.scanQr"),e[5]=o,e[6]=f):f=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=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]=u):u=e[7];let m;e[8]!==o?(m=o("mobile.connect.welcome.scanHint"),e[8]=o,e[9]=m):m=e[9];let g;e[10]!==m?(g=t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-6",children:[u,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:m})]}),e[10]=m,e[11]=g):g=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(se,{name:"close",className:"size-[18px]"}),e[12]=h):h=e[12];let x;e[13]!==o?(x=o("mobile.instances.cancelEdit"),e[13]=o,e[14]=x):x=e[14];let w;e[15]!==s||e[16]!==x?(w=t.jsxs(xe,{type:"button",variant:"outline",size:"lg",className:"mx-auto min-h-12 w-full max-w-sm bg-background",onClick:s,children:[h,x]}),e[15]=s,e[16]=x,e[17]=w):w=e[17];let b;return e[18]!==w||e[19]!==f||e[20]!==g?(b=dt.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,w]}),document.body),e[18]=w,e[19]=f,e[20]=g,e[21]=b):b=e[21],b},Tr=()=>{const n=de.c(6),{t:e}=me();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(qe,{width:96,height:96,isAnimated:!0}),n[0]=s):s=n[0];let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(se,{name:"loader-4",className:"size-[18px] animate-spin"}),n[1]=o):o=n[1];let r;n[2]!==e?(r=e("mobile.connect.connecting"),n[2]=e,n[3]=r):r=n[3];let i;return n[4]!==r?(i=dt.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:[o,t.jsx("span",{children:r})]})]}),document.body),n[4]=r,n[5]=i):i=n[5],i};function Za(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const el=({onConnected:n,notice:e=null})=>{const{t:s}=me(),o=kr(n),{connections:r,isBusy:i,isPasswordBusy:a,error:c,pendingConnection:d}=o,[f,u]=l.useState(""),[m,g]=l.useState(""),[h,x]=l.useState(""),[w,b]=l.useState(!1),[P,j]=l.useState(!1),C=l.useRef(null),R=l.useMemo(()=>fs(),[]),[T,D]=l.useState(()=>!fs()),[k,E]=l.useState(null),[y,I]=l.useState(""),[M,N]=l.useState(!1),S=mr(l.useCallback(()=>N(!0),[])),H=l.useCallback(z=>{z.preventDefault(),o.connect({url:f,clientToken:h,label:m})},[h,o,m,f]),$=l.useCallback(z=>{if(/^openchamber:\/\//i.test(z.trim())){const L=Cr(z);if(L){if("pairing"in L){o.redeemPairingConnection(L.pairing);return}u(L.url),L.label&&g(L.label),L.clientToken&&x(L.clientToken);return}}u(z)},[o]),v=l.useCallback(async()=>{if(C.current||i)return;o.setError(null),b(!0);const z=new AbortController;C.current=z;try{const L=await Rr({signal:z.signal});switch(C.current===z&&(C.current=null,b(!1)),L.status){case"ok":j(!0),u(L.url),L.label&&g(L.label),L.clientToken&&x(L.clientToken),await o.connect({url:L.url,clientToken:L.clientToken,label:L.label});break;case"pairing":j(!0),await o.redeemPairingConnection(L.pairing);break;case"permission-denied":o.setError(s("mobile.connect.scan.permissionDenied"));break;case"invalid":o.setError(s("mobile.connect.scan.invalid"));break;case"unsupported":o.setError(s("mobile.connect.scan.unsupported"));break;case"failed":o.setError(s("mobile.connect.scan.failed"));break;default:break}}finally{j(!1),C.current===z&&(C.current=null,b(!1))}},[o,i,s]);l.useEffect(()=>()=>C.current?.abort(),[]);const A=l.useCallback(z=>{z.preventDefault(),o.submitPassword(y)},[o,y]),O=l.useCallback(()=>{I(""),o.cancelPassword()},[o]);return t.jsxs(t.Fragment,{children:[w?t.jsx(Pr,{onCancel:()=>C.current?.abort()}):null,P?t.jsx(Tr,{}):null,M?t.jsx(Sr,{onClose:()=>N(!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",{...S,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(qe,{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(se,{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,d?t.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:A,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(se,{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:d.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:d.candidates.some(z=>z.kind==="direct")?Ge(d):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...ut,value:y,onChange:z=>I(z.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:Ct}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null,t.jsx(xe,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!y.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(xe,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:O,children:s("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[R?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(xe,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{v()},disabled:w||i,children:[t.jsx(se,{name:"scan-2",className:Z("size-[18px]",w&&"animate-pulse")}),s(i?"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,c&&!T?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):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 L=k===z.id;return t.jsxs("button",{type:"button",disabled:i,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-primary disabled:opacity-70",onClick:()=>{E(z.id),o.connect({id:z.id,candidates:z.candidates,clientToken:z.clientToken,label:z.label}).finally(()=>E(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(se,{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",L?"text-foreground":"text-muted-foreground"),children:L?s("mobile.connect.connecting"):z.candidates.some(ee=>ee.kind==="direct")?Ge(z):s("mobile.connect.relay.badge")})]}),L?t.jsx(se,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(se,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},z.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[R?t.jsxs("button",{type:"button",onClick:()=>D(z=>!z),"aria-expanded":T,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-primary",children:[t.jsx("span",{children:s("mobile.connect.manual.toggle")}),t.jsx(se,{name:"arrow-down-s",className:Z("size-4 transition-transform duration-200",T&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:T?"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:H,children:[t.jsx("input",{...ut,value:f,onChange:z=>$(z.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:T?void 0:-1,className:Z(Ct,"text-center")}),t.jsx("input",{value:m,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:T?void 0:-1,className:Z(Ct,"text-center")}),t.jsx("input",{...ut,value:h,onChange:z=>x(z.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:T?void 0:-1,autoCapitalize:"none",className:Z(Ct,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null,t.jsx(xe,{type:"submit",variant:R?"outline":"default",size:"lg",className:"h-12 w-full",disabled:i||w||!f.trim(),children:s(i?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},tl=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"},sl=n=>{const e=de.c(12),{groups:s,displayMode:o,timeFormatPreference:r,className:i}=n;let a;e[0]!==i?(a=Z("space-y-1.5",i),e[0]=i,e[1]=a):a=e[1];let c;if(e[2]!==o||e[3]!==s||e[4]!==r){let f;e[6]!==o||e[7]!==r?(f=u=>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(bo,{providerId:u.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:u.providerName}),u.status&&u.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:u.status}):null]}),u.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:u.rows.map(m=>{const g=o==="remaining"?m.window.remainingPercent:m.window.usedPercent,h=xo(m.window.valueLabel,g),x=yo(m.window.resetAt,m.window.resetAfterFormatted??m.window.resetAtFormatted,r);return t.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate typography-ui-label text-muted-foreground",children:m.subtitle?`${m.subtitle} · ${m.label}`:m.label}),x?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground/70",children:x}):null]}),t.jsx("span",{className:Z("shrink-0 typography-ui-label font-semibold tabular-nums",tl(m.window)),children:h==="-"?"":h})]},m.key)})}):null,u.status&&u.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:u.status}):null]},u.providerId),e[6]=o,e[7]=r,e[8]=f):f=e[8],c=s.map(f),e[2]=o,e[3]=s,e[4]=r,e[5]=c}else c=e[5];let d;return e[9]!==a||e[10]!==c?(d=t.jsx("div",{className:a,children:c}),e[9]=a,e[10]=c,e[11]=d):d=e[11],d},jn=380,nl=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},rt=n=>typeof n=="number"&&Number.isFinite(n)?n:0,kn=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),Ir=n=>{const e=de.c(19),{percentage:s}=n;let o,r,i,a,c,d,f;if(e[0]!==s){i=So(s)??0;const x=No(s);r=x==="critical"?"var(--status-error)":x==="warn"?"var(--status-warning)":"var(--status-success)",o=2*Math.PI*7.5,a="0 0 18 18",c="size-[18px] -rotate-90",d="progressbar",f=Math.round(i),e[0]=s,e[1]=o,e[2]=r,e[3]=i,e[4]=a,e[5]=c,e[6]=d,e[7]=f}else o=e[1],r=e[2],i=e[3],a=e[4],c=e[5],d=e[6],f=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),e[8]=u):u=e[8];const m=o*(1-i/100);let g;e[9]!==o||e[10]!==r||e[11]!==m?(g=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:r,strokeWidth:3,strokeLinecap:"round",strokeDasharray:o,strokeDashoffset:m,className:"transition-[stroke-dashoffset,stroke] duration-300"}),e[9]=o,e[10]=r,e[11]=m,e[12]=g):g=e[12];let h;return e[13]!==a||e[14]!==c||e[15]!==d||e[16]!==f||e[17]!==g?(h=t.jsxs("svg",{viewBox:a,className:c,role:d,"aria-valuenow":f,"aria-valuemin":0,"aria-valuemax":100,children:[u,g]}),e[13]=a,e[14]=c,e[15]=d,e[16]=f,e[17]=g,e[18]=h):h=e[18],h},rl=n=>{const e=de.c(13),{icon:s,iconNode:o,label:r,children:i}=n;let a;e[0]!==s||e[1]!==o?(a=o??(s?t.jsx(se,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=o,e[2]=a):a=e[2];let c;e[3]!==a?(c=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:a}),e[3]=a,e[4]=c):c=e[4];let d;e[5]!==r?(d=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:r}),e[5]=r,e[6]=d):d=e[6];let f;e[7]!==i?(f=t.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:i}),e[7]=i,e[8]=f):f=e[8];let u;return e[9]!==c||e[10]!==d||e[11]!==f?(u=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[c,d,f]}),e[9]=c,e[10]=d,e[11]=f,e[12]=u):u=e[12],u},ol=n=>{const e=de.c(49),{open:s,onClose:o,anchorRef:r,contextDisplay:i,usageGroups:a,usageDisplayMode:c,isUsageLoading:d,timeFormatPreference:f}=n,{t:u}=me(),m=l.useRef(null),[g,h]=l.useState(s),[x,w]=l.useState(!1),{enabled:b}=ys(),P=l.useRef(null),[j,C]=l.useState(null);let R,T;e[0]!==r||e[1]!==b||e[2]!==s||e[3]!==g?(R=()=>{if(!s||!b||!g)return;const G=()=>{const te=r.current?.getBoundingClientRect(),ae=P.current?.getBoundingClientRect();if(!te||!ae){C(null);return}const pe=te.left-ae.left,oe=Math.min(Math.max(pe,8),Math.max(8,ae.width-jn-8));C(oe)};G();const F=P.current;if(typeof ResizeObserver>"u"||!F)return;const Q=new ResizeObserver(G);return Q.observe(F),()=>Q.disconnect()},T=[r,b,s,g],e[0]=r,e[1]=b,e[2]=s,e[3]=g,e[4]=R,e[5]=T):(R=e[4],T=e[5]),l.useLayoutEffect(R,T);const D=b&&j!==null;let k,E;e[6]!==s||e[7]!==g?(k=()=>{if(s){h(!0),w(!1);return}if(!g)return;w(!0);const G=window.setTimeout(()=>{h(!1),w(!1)},140);return()=>window.clearTimeout(G)},E=[s,g],e[6]=s,e[7]=g,e[8]=k,e[9]=E):(k=e[8],E=e[9]),l.useEffect(k,E);let y,I;e[10]!==o||e[11]!==s?(y=()=>{if(!s)return;const G=F=>{F.key==="Escape"&&o()};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},I=[o,s],e[10]=o,e[11]=s,e[12]=y,e[13]=I):(y=e[12],I=e[13]),l.useEffect(y,I);let M,N;if(e[14]!==r||e[15]!==o||e[16]!==s?(M=()=>{if(!s)return;const G=F=>{const Q=F.target;if(!(Q instanceof Node)){o();return}m.current?.contains(Q)||r.current?.contains(Q)||o()};return document.addEventListener("pointerdown",G,!0),document.addEventListener("wheel",G,!0),()=>{document.removeEventListener("pointerdown",G,!0),document.removeEventListener("wheel",G,!0)}},N=[r,o,s],e[14]=r,e[15]=o,e[16]=s,e[17]=M,e[18]=N):(M=e[17],N=e[18]),l.useEffect(M,N),!g)return null;let S;e[19]!==u?(S=u("mobile.header.openMetadataAria"),e[19]=u,e[20]=S):S=e[20];const H=D?"absolute origin-top-left":"mx-3 mt-2",$=x?"pointer-events-none":"pointer-events-auto";let v;e[21]!==H||e[22]!==$?(v=Z("overflow-y-auto overscroll-contain rounded-[20px] border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",H,$),e[21]=H,e[22]=$,e[23]=v):v=e[23];const A=`${x?"session-metadata-out":"session-metadata-in"} ${x?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let O;e[24]!==j||e[25]!==D?(O=D?{top:8,left:j??8,width:`min(${jn}px, calc(100% - 16px))`}:null,e[24]=j,e[25]=D,e[26]=O):O=e[26];let z;e[27]!==A||e[28]!==O?(z={animation:A,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...O},e[27]=A,e[28]=O,e[29]=z):z=e[29];let L;e[30]!==i||e[31]!==u?(L=i?t.jsx(rl,{iconNode:t.jsx(Ir,{percentage:i.percentage}),label:u("mobile.header.metadata.context"),children:t.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[t.jsxs("span",{className:Z("font-semibold",i.colorClass),children:[i.percentage.toFixed(1),"%"]}),t.jsx("span",{className:"text-muted-foreground",children:i.tokens})]})}):null,e[30]=i,e[31]=u,e[32]=L):L=e[32];let ee;e[33]!==d||e[34]!==f||e[35]!==c||e[36]!==a?(ee=t.jsx(il,{groups:a,displayMode:c,isLoading:d,timeFormatPreference:f}),e[33]=d,e[34]=f,e[35]=c,e[36]=a,e[37]=ee):ee=e[37];let X;e[38]!==L||e[39]!==ee?(X=t.jsxs("div",{className:"space-y-1",children:[L,ee]}),e[38]=L,e[39]=ee,e[40]=X):X=e[40];let _;e[41]!==v||e[42]!==z||e[43]!==X||e[44]!==S?(_=t.jsx("div",{ref:m,role:"dialog","aria-label":S,className:v,style:z,children:X}),e[41]=v,e[42]=z,e[43]=X,e[44]=S,e[45]=_):_=e[45];let J;e[46]===Symbol.for("react.memo_cache_sentinel")?(J=t.jsx("style",{children:`
5
5
  @keyframes session-metadata-in {
6
6
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
7
7
  to { opacity: 1; transform: translateY(0) scale(1); }
@@ -10,7 +10,7 @@ import{f as de,r as ls,j as t,R as l,c as ut,h as no}from"./vendor-react-BUCujlK
10
10
  from { opacity: 1; transform: translateY(0) scale(1); }
11
11
  to { opacity: 0; transform: translateY(-6px) scale(0.985); }
12
12
  }
13
- `}),e[46]=J):J=e[46];let q;return e[47]!==_?(q=t.jsxs("div",{ref:P,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:[_,J]}),e[47]=_,e[48]=q):q=e[48],q},ol=n=>{const e=de.c(30),{groups:s,displayMode:o,isLoading:r,timeFormatPreference:i}=n,{t:a}=me();let c;e[0]!==o||e[1]!==a?(c=a(o==="remaining"?"header.services.remaining":"header.services.used"),e[0]=o,e[1]=a,e[2]=c):c=e[2];const d=c;if(s.length===0){if(!r)return null;let j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(se,{name:"loader-4",className:"size-4 animate-spin","aria-hidden":!0}),e[3]=j):j=e[3];let C;e[4]!==a?(C=a("common.loading"),e[4]=a,e[5]=C):C=e[5];let R;return e[6]!==C?(R=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-2.5 py-6 text-muted-foreground",children:[j,t.jsx("span",{className:"typography-ui-label",children:C})]}),e[6]=C,e[7]=R):R=e[7],R}let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(se,{name:"timer",className:"size-[18px]"})}),e[8]=f):f=e[8];let u;e[9]!==a?(u=a("mobile.header.metadata.usage"),e[9]=a,e[10]=u):u=e[10];let m;e[11]!==u?(m=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:u}),e[11]=u,e[12]=m):m=e[12];let g;e[13]!==r?(g=r?t.jsx(se,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[13]=r,e[14]=g):g=e[14];let h;e[15]!==d?(h=t.jsx("span",{className:"truncate",children:d}),e[15]=d,e[16]=h):h=e[16];let x;e[17]!==g||e[18]!==h?(x=t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground",children:[g,h]}),e[17]=g,e[18]=h,e[19]=x):x=e[19];let w;e[20]!==m||e[21]!==x?(w=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[f,m,x]}),e[20]=m,e[21]=x,e[22]=w):w=e[22];let b;e[23]!==o||e[24]!==s||e[25]!==i?(b=t.jsx(tl,{groups:s,displayMode:o,timeFormatPreference:i}),e[23]=o,e[24]=s,e[25]=i,e[26]=b):b=e[26];let P;return e[27]!==w||e[28]!==b?(P=t.jsxs("div",{className:"pt-2.5",children:[w,b]}),e[27]=w,e[28]=b,e[29]=P):P=e[29],P},il=l.memo(function({open:e,onOpenChange:s,currentSessionId:o,effectiveDirectory:r,isNewSessionDraftOpen:i}){const{t:a}=me(),c=l.useRef(null),d=yo(o??"",r||void 0),f=ze(A=>A.providers),u=ze(A=>A.currentProviderId),m=ze(A=>A.currentModelId),g=ze(A=>A.getModelMetadata);ze(A=>A.modelsMetadata.size);const h=vo(l.useCallback(A=>o?A.sessionModelSelections.get(o)??null:null,[o])),x=nt(A=>A.results),w=nt(A=>A.loadSettings),b=nt(A=>A.fetchAllQuotas),P=nt(A=>A.isLoading),j=nt(A=>A.displayMode),C=nt(A=>A.dropdownProviderIds),R=Ve(A=>A.timeFormatPreference);wo(),l.useEffect(()=>{w()},[w]),l.useEffect(()=>{ln(C)},[C]),l.useEffect(()=>{!e||P||!C.some(O=>!x.some(z=>z.providerId===O))||b()},[C,b,P,e,x]);const D=l.useMemo(()=>{for(let A=d.length-1;A>=0;A-=1){const O=d[A];if(O.role!=="user")continue;const z=typeof O.model?.providerID=="string"&&O.model.providerID.trim().length>0?O.model.providerID:void 0,B=typeof O.model?.modelID=="string"&&O.model.modelID.trim().length>0?O.model.modelID:void 0;if(z&&B)return{providerID:z,modelID:B}}return null},[d])??(h?{providerID:h.providerId,modelID:h.modelId}:null)??(u&&m?{providerID:u,modelID:m}:null),E=(D?f.find(A=>A.id===D.providerID):void 0)?.models.find(A=>A.id===D?.modelID),y=D?g(D.providerID,D.modelID):void 0,I=sl(E?.limit,"context")??y?.limit?.context??0,M=l.useMemo(()=>{for(let A=d.length-1;A>=0;A-=1){const O=d[A];if(O.role!=="assistant"||!O.tokens)continue;const z=kt(O.tokens.input)+kt(O.tokens.output)+kt(O.tokens.reasoning)+kt(O.tokens.cache?.read)+kt(O.tokens.cache?.write);if(z>0)return z}return 0},[d]),N=!i&&M>0&&I>0?Math.min(M/I*100,999):null,S=N!==null?`${kn(M)}/${kn(I)}`:null,H=N===null?"":N>=90?"text-[var(--status-error)]":N>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",$=N!==null&&S?{percentage:N,tokens:S,colorClass:H}:null,v=jo();return l.useEffect(()=>{!e||v.length===0||ln(v.map(A=>A.providerId))},[e,v]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:c,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-primary","aria-label":a("mobile.header.openMetadataAria"),"aria-expanded":e,onClick:()=>s(A=>!A),style:{touchAction:"manipulation"},children:t.jsx(Ir,{percentage:$?.percentage??0})}),t.jsx(rl,{open:e,onClose:()=>s(!1),anchorRef:c,contextDisplay:$,usageGroups:v,usageDisplayMode:j,isUsageLoading:P,timeFormatPreference:R})]})}),al=10,Sn=380,ll=(n,e)=>n.title?.trim()||e,cl=n=>{const e=de.c(32),{session:s,meta:o,active:r,onSelect:i}=n,{t:a}=me(),c=Yn(s.id),d=Jn(s.id),f=c?.type??"idle",u=f==="busy"||f==="retry",m=!u&&d>0&&!r,g=Xn(s.id,u),h=(u||m)&&g,x=s.time?.updated??s.time?.created??0;let w;e[0]!==x?(w=Co(x),e[0]=x,e[1]=w):w=e[1];const b=w,P=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let j;e[2]!==P?(j=Z("flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",P),e[2]=P,e[3]=j):j=e[3];let C;e[4]===Symbol.for("react.memo_cache_sentinel")?(C={touchAction:"manipulation"},e[4]=C):C=e[4];const R=r?"text-primary":"text-foreground";let T;e[5]!==R?(T=Z("block truncate typography-ui-label",R),e[5]=R,e[6]=T):T=e[6];let D;e[7]!==s||e[8]!==a?(D=ll(s,a("sessions.sidebar.session.untitled")),e[7]=s,e[8]=a,e[9]=D):D=e[9];let k;e[10]!==T||e[11]!==D?(k=t.jsx("span",{className:T,children:D}),e[10]=T,e[11]=D,e[12]=k):k=e[12];let E;e[13]!==o?(E=o?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:o}):null,e[13]=o,e[14]=E):E=e[14];let y;e[15]!==E||e[16]!==k?(y=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[k,E]}),e[15]=E,e[16]=k,e[17]=y):y=e[17];let I;e[18]!==u||e[19]!==m?(I=u||m?t.jsx("span",{className:Z("size-1.5 shrink-0 rounded-full",u?"bg-primary":"bg-[var(--status-info)]"),"aria-hidden":!0}):null,e[18]=u,e[19]=m,e[20]=I):I=e[20];let M;e[21]!==u||e[22]!==s.id||e[23]!==h||e[24]!==b?(M=h?t.jsx(ir,{sessionId:s.id,running:u,className:"typography-micro"}):b?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:b}):null,e[21]=u,e[22]=s.id,e[23]=h,e[24]=b,e[25]=M):M=e[25];let N;return e[26]!==i||e[27]!==y||e[28]!==I||e[29]!==M||e[30]!==j?(N=t.jsxs("button",{type:"button",className:j,onClick:i,style:C,children:[y,I,M]}),e[26]=i,e[27]=y,e[28]=I,e[29]=M,e[30]=j,e[31]=N):N=e[31],N},ul=n=>{const e=de.c(50),{open:s,onClose:o,anchorRef:r}=n,{t:i}=me(),a=l.useRef(null),[c,d]=l.useState(s),[f,u]=l.useState(!1),{enabled:m}=ys(),g=l.useRef(null),[h,x]=l.useState(null);let w,b;e[0]!==r||e[1]!==m||e[2]!==s||e[3]!==c?(w=()=>{if(!s||!m||!c)return;const F=()=>{const ae=r.current?.getBoundingClientRect(),pe=g.current?.getBoundingClientRect();if(!ae||!pe){x(null);return}const oe=ae.left-pe.left;x(Math.min(Math.max(oe,8),Math.max(8,pe.width-Sn-8)))};F();const Q=g.current;if(typeof ResizeObserver>"u"||!Q)return;const te=new ResizeObserver(F);return te.observe(Q),()=>te.disconnect()},b=[r,m,s,c],e[0]=r,e[1]=m,e[2]=s,e[3]=c,e[4]=w,e[5]=b):(w=e[4],b=e[5]),l.useLayoutEffect(w,b);const P=m&&h!==null,j=je(dl),C=je(fl),R=Oe(ml);let T;e[6]===Symbol.for("react.memo_cache_sentinel")?(T={maxParents:al},e[6]=T):T=e[6];const D=No(s||c,T);let k,E;e[7]!==s||e[8]!==c?(k=()=>{if(s){vs(),d(!0),u(!1);return}if(!c)return;u(!0);const F=window.setTimeout(()=>{d(!1),u(!1)},140);return()=>window.clearTimeout(F)},E=[s,c],e[7]=s,e[8]=c,e[9]=k,e[10]=E):(k=e[9],E=e[10]),l.useEffect(k,E);let y,I;e[11]!==o||e[12]!==s?(y=()=>{if(!s)return;const F=Q=>{Q.key==="Escape"&&o()};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},I=[o,s],e[11]=o,e[12]=s,e[13]=y,e[14]=I):(y=e[13],I=e[14]),l.useEffect(y,I);let M,N;e[15]!==r||e[16]!==o||e[17]!==s?(M=()=>{if(!s)return;const F=Q=>{const te=Q.target;if(!(te instanceof Node)){o();return}a.current?.contains(te)||r.current?.contains(te)||o()};return document.addEventListener("pointerdown",F,!0),()=>document.removeEventListener("pointerdown",F,!0)},N=[r,o,s],e[15]=r,e[16]=o,e[17]=s,e[18]=M,e[19]=N):(M=e[18],N=e[19]),l.useEffect(M,N);let S;e[20]!==o||e[21]!==C?(S=F=>{C(F.id,xs(F)),o()},e[20]=o,e[21]=C,e[22]=S):S=e[22];const H=S;if(!c)return null;let $;e[23]!==i?($=i("sessions.switcher.openAria"),e[23]=i,e[24]=$):$=e[24];const v=P?"absolute origin-top-left":"mx-3 mt-2",A=f?"pointer-events-none":"pointer-events-auto";let O;e[25]!==v||e[26]!==A?(O=Z("flex flex-col overflow-hidden rounded-[20px] border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",v,A),e[25]=v,e[26]=A,e[27]=O):O=e[27];const z=`${f?"session-switcher-out":"session-switcher-in"} ${f?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let B;e[28]!==h||e[29]!==P?(B=P?{top:8,left:h??8,width:`min(${Sn}px, calc(100% - 16px))`}:null,e[28]=h,e[29]=P,e[30]=B):B=e[30];let ee;e[31]!==z||e[32]!==B?(ee={animation:z,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...B},e[31]=z,e[32]=B,e[33]=ee):ee=e[33];let X;e[34]!==j||e[35]!==H||e[36]!==D||e[37]!==R||e[38]!==i?(X=D.length===0?t.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:i("sessions.switcher.empty")}):D.map(F=>{const Q=F.node.session,te=[F.secondaryMeta?.projectLabel,F.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return t.jsx(cl,{session:Q,meta:te,active:Q.id===j,onSelect:()=>{F.projectId&&R(F.projectId),H(Q)}},Q.id)}),e[34]=j,e[35]=H,e[36]=D,e[37]=R,e[38]=i,e[39]=X):X=e[39];let _;e[40]!==X?(_=t.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:X}),e[40]=X,e[41]=_):_=e[41];let J;e[42]!==$||e[43]!==O||e[44]!==ee||e[45]!==_?(J=t.jsx("div",{ref:a,role:"dialog","aria-label":$,className:O,style:ee,children:_}),e[42]=$,e[43]=O,e[44]=ee,e[45]=_,e[46]=J):J=e[46];let q;e[47]===Symbol.for("react.memo_cache_sentinel")?(q=t.jsx("style",{children:`
13
+ `}),e[46]=J):J=e[46];let q;return e[47]!==_?(q=t.jsxs("div",{ref:P,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:[_,J]}),e[47]=_,e[48]=q):q=e[48],q},il=n=>{const e=de.c(30),{groups:s,displayMode:o,isLoading:r,timeFormatPreference:i}=n,{t:a}=me();let c;e[0]!==o||e[1]!==a?(c=a(o==="remaining"?"header.services.remaining":"header.services.used"),e[0]=o,e[1]=a,e[2]=c):c=e[2];const d=c;if(s.length===0){if(!r)return null;let j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(se,{name:"loader-4",className:"size-4 animate-spin","aria-hidden":!0}),e[3]=j):j=e[3];let C;e[4]!==a?(C=a("common.loading"),e[4]=a,e[5]=C):C=e[5];let R;return e[6]!==C?(R=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-2.5 py-6 text-muted-foreground",children:[j,t.jsx("span",{className:"typography-ui-label",children:C})]}),e[6]=C,e[7]=R):R=e[7],R}let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(se,{name:"timer",className:"size-[18px]"})}),e[8]=f):f=e[8];let u;e[9]!==a?(u=a("mobile.header.metadata.usage"),e[9]=a,e[10]=u):u=e[10];let m;e[11]!==u?(m=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:u}),e[11]=u,e[12]=m):m=e[12];let g;e[13]!==r?(g=r?t.jsx(se,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[13]=r,e[14]=g):g=e[14];let h;e[15]!==d?(h=t.jsx("span",{className:"truncate",children:d}),e[15]=d,e[16]=h):h=e[16];let x;e[17]!==g||e[18]!==h?(x=t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground",children:[g,h]}),e[17]=g,e[18]=h,e[19]=x):x=e[19];let w;e[20]!==m||e[21]!==x?(w=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[f,m,x]}),e[20]=m,e[21]=x,e[22]=w):w=e[22];let b;e[23]!==o||e[24]!==s||e[25]!==i?(b=t.jsx(sl,{groups:s,displayMode:o,timeFormatPreference:i}),e[23]=o,e[24]=s,e[25]=i,e[26]=b):b=e[26];let P;return e[27]!==w||e[28]!==b?(P=t.jsxs("div",{className:"pt-2.5",children:[w,b]}),e[27]=w,e[28]=b,e[29]=P):P=e[29],P},al=l.memo(function({open:e,onOpenChange:s,currentSessionId:o,effectiveDirectory:r,isNewSessionDraftOpen:i}){const{t:a}=me(),c=l.useRef(null),d=vo(o??"",r||void 0),f=ze(A=>A.providers),u=ze(A=>A.currentProviderId),m=ze(A=>A.currentModelId),g=ze(A=>A.getModelMetadata);ze(A=>A.modelsMetadata.size);const h=wo(l.useCallback(A=>o?A.sessionModelSelections.get(o)??null:null,[o])),x=nt(A=>A.results),w=nt(A=>A.loadSettings),b=nt(A=>A.fetchAllQuotas),P=nt(A=>A.isLoading),j=nt(A=>A.displayMode),C=nt(A=>A.dropdownProviderIds),R=Ve(A=>A.timeFormatPreference);jo(),l.useEffect(()=>{w()},[w]),l.useEffect(()=>{ln(C)},[C]),l.useEffect(()=>{!e||P||!C.some(O=>!x.some(z=>z.providerId===O))||b()},[C,b,P,e,x]);const D=l.useMemo(()=>{for(let A=d.length-1;A>=0;A-=1){const O=d[A];if(O.role!=="user")continue;const z=typeof O.model?.providerID=="string"&&O.model.providerID.trim().length>0?O.model.providerID:void 0,L=typeof O.model?.modelID=="string"&&O.model.modelID.trim().length>0?O.model.modelID:void 0;if(z&&L)return{providerID:z,modelID:L}}return null},[d])??(h?{providerID:h.providerId,modelID:h.modelId}:null)??(u&&m?{providerID:u,modelID:m}:null),E=(D?f.find(A=>A.id===D.providerID):void 0)?.models.find(A=>A.id===D?.modelID),y=D?g(D.providerID,D.modelID):void 0,I=nl(E?.limit,"context")??y?.limit?.context??0,M=l.useMemo(()=>{for(let A=d.length-1;A>=0;A-=1){const O=d[A];if(O.role!=="assistant"||!O.tokens)continue;const z=rt(O.tokens.total);if(z>0)return z;const L=rt(O.tokens.input)+rt(O.tokens.output)+rt(O.tokens.reasoning)+rt(O.tokens.cache?.read)+rt(O.tokens.cache?.write);if(L>0)return L}return 0},[d]),N=!i&&M>0&&I>0?Math.min(M/I*100,999):null,S=N!==null?`${kn(M)}/${kn(I)}`:null,H=N===null?"":N>=90?"text-[var(--status-error)]":N>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",$=N!==null&&S?{percentage:N,tokens:S,colorClass:H}:null,v=ko();return l.useEffect(()=>{!e||v.length===0||ln(v.map(A=>A.providerId))},[e,v]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:c,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-primary","aria-label":a("mobile.header.openMetadataAria"),"aria-expanded":e,onClick:()=>s(A=>!A),style:{touchAction:"manipulation"},children:t.jsx(Ir,{percentage:$?.percentage??0})}),t.jsx(ol,{open:e,onClose:()=>s(!1),anchorRef:c,contextDisplay:$,usageGroups:v,usageDisplayMode:j,isUsageLoading:P,timeFormatPreference:R})]})}),ll=10,Sn=380,cl=(n,e)=>n.title?.trim()||e,ul=n=>{const e=de.c(32),{session:s,meta:o,active:r,onSelect:i}=n,{t:a}=me(),c=Yn(s.id),d=Jn(s.id),f=c?.type??"idle",u=f==="busy"||f==="retry",m=!u&&d>0&&!r,g=Xn(s.id,u),h=(u||m)&&g,x=s.time?.updated??s.time?.created??0;let w;e[0]!==x?(w=Eo(x),e[0]=x,e[1]=w):w=e[1];const b=w,P=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let j;e[2]!==P?(j=Z("flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",P),e[2]=P,e[3]=j):j=e[3];let C;e[4]===Symbol.for("react.memo_cache_sentinel")?(C={touchAction:"manipulation"},e[4]=C):C=e[4];const R=r?"text-primary":"text-foreground";let T;e[5]!==R?(T=Z("block truncate typography-ui-label",R),e[5]=R,e[6]=T):T=e[6];let D;e[7]!==s||e[8]!==a?(D=cl(s,a("sessions.sidebar.session.untitled")),e[7]=s,e[8]=a,e[9]=D):D=e[9];let k;e[10]!==T||e[11]!==D?(k=t.jsx("span",{className:T,children:D}),e[10]=T,e[11]=D,e[12]=k):k=e[12];let E;e[13]!==o?(E=o?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:o}):null,e[13]=o,e[14]=E):E=e[14];let y;e[15]!==E||e[16]!==k?(y=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[k,E]}),e[15]=E,e[16]=k,e[17]=y):y=e[17];let I;e[18]!==u||e[19]!==m?(I=u||m?t.jsx("span",{className:Z("size-1.5 shrink-0 rounded-full",u?"bg-primary":"bg-[var(--status-info)]"),"aria-hidden":!0}):null,e[18]=u,e[19]=m,e[20]=I):I=e[20];let M;e[21]!==u||e[22]!==s.id||e[23]!==h||e[24]!==b?(M=h?t.jsx(ir,{sessionId:s.id,running:u,className:"typography-micro"}):b?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:b}):null,e[21]=u,e[22]=s.id,e[23]=h,e[24]=b,e[25]=M):M=e[25];let N;return e[26]!==i||e[27]!==y||e[28]!==I||e[29]!==M||e[30]!==j?(N=t.jsxs("button",{type:"button",className:j,onClick:i,style:C,children:[y,I,M]}),e[26]=i,e[27]=y,e[28]=I,e[29]=M,e[30]=j,e[31]=N):N=e[31],N},dl=n=>{const e=de.c(50),{open:s,onClose:o,anchorRef:r}=n,{t:i}=me(),a=l.useRef(null),[c,d]=l.useState(s),[f,u]=l.useState(!1),{enabled:m}=ys(),g=l.useRef(null),[h,x]=l.useState(null);let w,b;e[0]!==r||e[1]!==m||e[2]!==s||e[3]!==c?(w=()=>{if(!s||!m||!c)return;const F=()=>{const ae=r.current?.getBoundingClientRect(),pe=g.current?.getBoundingClientRect();if(!ae||!pe){x(null);return}const oe=ae.left-pe.left;x(Math.min(Math.max(oe,8),Math.max(8,pe.width-Sn-8)))};F();const Q=g.current;if(typeof ResizeObserver>"u"||!Q)return;const te=new ResizeObserver(F);return te.observe(Q),()=>te.disconnect()},b=[r,m,s,c],e[0]=r,e[1]=m,e[2]=s,e[3]=c,e[4]=w,e[5]=b):(w=e[4],b=e[5]),l.useLayoutEffect(w,b);const P=m&&h!==null,j=je(fl),C=je(ml),R=Oe(pl);let T;e[6]===Symbol.for("react.memo_cache_sentinel")?(T={maxParents:ll},e[6]=T):T=e[6];const D=Co(s||c,T);let k,E;e[7]!==s||e[8]!==c?(k=()=>{if(s){vs(),d(!0),u(!1);return}if(!c)return;u(!0);const F=window.setTimeout(()=>{d(!1),u(!1)},140);return()=>window.clearTimeout(F)},E=[s,c],e[7]=s,e[8]=c,e[9]=k,e[10]=E):(k=e[9],E=e[10]),l.useEffect(k,E);let y,I;e[11]!==o||e[12]!==s?(y=()=>{if(!s)return;const F=Q=>{Q.key==="Escape"&&o()};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},I=[o,s],e[11]=o,e[12]=s,e[13]=y,e[14]=I):(y=e[13],I=e[14]),l.useEffect(y,I);let M,N;e[15]!==r||e[16]!==o||e[17]!==s?(M=()=>{if(!s)return;const F=Q=>{const te=Q.target;if(!(te instanceof Node)){o();return}a.current?.contains(te)||r.current?.contains(te)||o()};return document.addEventListener("pointerdown",F,!0),()=>document.removeEventListener("pointerdown",F,!0)},N=[r,o,s],e[15]=r,e[16]=o,e[17]=s,e[18]=M,e[19]=N):(M=e[18],N=e[19]),l.useEffect(M,N);let S;e[20]!==o||e[21]!==C?(S=F=>{C(F.id,xs(F)),o()},e[20]=o,e[21]=C,e[22]=S):S=e[22];const H=S;if(!c)return null;let $;e[23]!==i?($=i("sessions.switcher.openAria"),e[23]=i,e[24]=$):$=e[24];const v=P?"absolute origin-top-left":"mx-3 mt-2",A=f?"pointer-events-none":"pointer-events-auto";let O;e[25]!==v||e[26]!==A?(O=Z("flex flex-col overflow-hidden rounded-[20px] border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",v,A),e[25]=v,e[26]=A,e[27]=O):O=e[27];const z=`${f?"session-switcher-out":"session-switcher-in"} ${f?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let L;e[28]!==h||e[29]!==P?(L=P?{top:8,left:h??8,width:`min(${Sn}px, calc(100% - 16px))`}:null,e[28]=h,e[29]=P,e[30]=L):L=e[30];let ee;e[31]!==z||e[32]!==L?(ee={animation:z,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...L},e[31]=z,e[32]=L,e[33]=ee):ee=e[33];let X;e[34]!==j||e[35]!==H||e[36]!==D||e[37]!==R||e[38]!==i?(X=D.length===0?t.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:i("sessions.switcher.empty")}):D.map(F=>{const Q=F.node.session,te=[F.secondaryMeta?.projectLabel,F.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return t.jsx(ul,{session:Q,meta:te,active:Q.id===j,onSelect:()=>{F.projectId&&R(F.projectId),H(Q)}},Q.id)}),e[34]=j,e[35]=H,e[36]=D,e[37]=R,e[38]=i,e[39]=X):X=e[39];let _;e[40]!==X?(_=t.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:X}),e[40]=X,e[41]=_):_=e[41];let J;e[42]!==$||e[43]!==O||e[44]!==ee||e[45]!==_?(J=t.jsx("div",{ref:a,role:"dialog","aria-label":$,className:O,style:ee,children:_}),e[42]=$,e[43]=O,e[44]=ee,e[45]=_,e[46]=J):J=e[46];let q;e[47]===Symbol.for("react.memo_cache_sentinel")?(q=t.jsx("style",{children:`
14
14
  @keyframes session-switcher-in {
15
15
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
16
16
  to { opacity: 1; transform: translateY(0) scale(1); }
@@ -19,7 +19,7 @@ import{f as de,r as ls,j as t,R as l,c as ut,h as no}from"./vendor-react-BUCujlK
19
19
  from { opacity: 1; transform: translateY(0) scale(1); }
20
20
  to { opacity: 0; transform: translateY(-6px) scale(0.985); }
21
21
  }
22
- `}),e[47]=q):q=e[47];let G;return e[48]!==J?(G=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:[J,q]}),e[48]=J,e[49]=G):G=e[49],G};function dl(n){return n.currentSessionId}function fl(n){return n.setCurrentSession}function ml(n){return n.setActiveProjectIdOnly}const pl=n=>{const e=de.c(71),{onOpenSessions:s,onOpenWorkspace:o,compactTitle:r}=n,i=r===void 0?!1:r,{t:a}=me(),[c,d]=l.useState(!1),[f,u]=l.useState(!1),m=l.useRef(null),g=dt(hl),h=je(gl);let x;e[0]!==h?(x=Ae=>h?Ae.getDirectoryForSession(h):null,e[0]=h,e[1]=x):x=e[1];const b=je(x)||g,P=Eo(h,b||void 0),j=je(bl);let C;e[2]!==P?.title?(C=P?.title?.trim(),e[2]=P?.title,e[3]=C):C=e[3];const R=C;let T;e[4]!==h||e[5]!==R||e[6]!==a?(T=R||a(h?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[4]=h,e[5]=R,e[6]=a,e[7]=T):T=e[7];const D=T;let k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{d(!1),u(!1)},e[8]=k):k=e[8];let E;e[9]!==h||e[10]!==b?(E=[h,b],e[9]=h,e[10]=b,e[11]=E):E=e[11],l.useEffect(k,E);let y;e[12]!==s?(y=()=>{d(!1),u(!1),s()},e[12]=s,e[13]=y):y=e[13];const I=y;let M;e[14]===Symbol.for("react.memo_cache_sentinel")?(M=Ae=>{d(_e=>{const ve=typeof Ae=="function"?Ae(_e):Ae;return ve&&u(!1),ve})},e[14]=M):M=e[14];const N=M;let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{u(Ae=>{const _e=!Ae;return _e&&d(!1),_e})},e[15]=S):S=e[15];const H=S;let $;e[16]===Symbol.for("react.memo_cache_sentinel")?($={paddingTop:"var(--oc-safe-area-top, 0px)"},e[16]=$):$=e[16];let v;e[17]!==a?(v=a("mobile.sessions.openSheetAria"),e[17]=a,e[18]=v):v=e[18];let A,O;e[19]===Symbol.for("react.memo_cache_sentinel")?(A={touchAction:"manipulation"},O=t.jsx(se,{name:"list-unordered",className:"size-5"}),e[19]=A,e[20]=O):(A=e[19],O=e[20]);let z;e[21]!==I||e[22]!==v?(z=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-primary","aria-label":v,onClick:I,style:A,children:O}),e[21]=I,e[22]=v,e[23]=z):z=e[23];const B=i?"shrink":"flex-1";let ee;e[24]!==B?(ee=Z("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",B),e[24]=B,e[25]=ee):ee=e[25];let X;e[26]!==a?(X=a("sessions.switcher.openAria"),e[26]=a,e[27]=X):X=e[27];let _;e[28]===Symbol.for("react.memo_cache_sentinel")?(_={touchAction:"manipulation"},e[28]=_):_=e[28];let J;e[29]!==D?(J=t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:D}),e[29]=D,e[30]=J):J=e[30];const q=f&&"rotate-180";let G;e[31]!==q?(G=Z("size-4 shrink-0 text-muted-foreground transition-transform duration-150",q),e[31]=q,e[32]=G):G=e[32];let F;e[33]!==G?(F=t.jsx(se,{name:"arrow-down-s",className:G}),e[33]=G,e[34]=F):F=e[34];let Q;e[35]!==J||e[36]!==F?(Q=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[J,F]}),e[35]=J,e[36]=F,e[37]=Q):Q=e[37];let te;e[38]!==f||e[39]!==ee||e[40]!==X||e[41]!==Q?(te=t.jsx("button",{ref:m,type:"button",className:ee,"aria-label":X,"aria-haspopup":"dialog","aria-expanded":f,onClick:H,style:_,children:Q}),e[38]=f,e[39]=ee,e[40]=X,e[41]=Q,e[42]=te):te=e[42];let ae;e[43]!==i?(ae=i?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[43]=i,e[44]=ae):ae=e[44];let pe;e[45]!==h||e[46]!==b||e[47]!==j||e[48]!==c?(pe=t.jsx(il,{open:c,onOpenChange:N,currentSessionId:h,effectiveDirectory:b,isNewSessionDraftOpen:j}),e[45]=h,e[46]=b,e[47]=j,e[48]=c,e[49]=pe):pe=e[49];let oe;e[50]!==a?(oe=a("mobile.header.openWorkspaceAria"),e[50]=a,e[51]=oe):oe=e[51];let W;e[52]!==o?(W=()=>{d(!1),u(!1),o()},e[52]=o,e[53]=W):W=e[53];let ie,U;e[54]===Symbol.for("react.memo_cache_sentinel")?(ie={touchAction:"manipulation"},U=t.jsx(se,{name:"pencil-ruler-2",className:"size-5"}),e[54]=ie,e[55]=U):(ie=e[54],U=e[55]);let fe;e[56]!==oe||e[57]!==W?(fe=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-primary","aria-label":oe,onClick:W,style:ie,children:U}),e[56]=oe,e[57]=W,e[58]=fe):fe=e[58];let Ne;e[59]!==z||e[60]!==te||e[61]!==ae||e[62]!==pe||e[63]!==fe?(Ne=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:$,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[z,te,ae,pe,fe]})}),e[59]=z,e[60]=te,e[61]=ae,e[62]=pe,e[63]=fe,e[64]=Ne):Ne=e[64];let ke;e[65]===Symbol.for("react.memo_cache_sentinel")?(ke=()=>u(!1),e[65]=ke):ke=e[65];let Ie;e[66]!==f?(Ie=t.jsx(ul,{open:f,onClose:ke,anchorRef:m}),e[66]=f,e[67]=Ie):Ie=e[67];let Be;return e[68]!==Ne||e[69]!==Ie?(Be=t.jsxs(t.Fragment,{children:[Ne,Ie]}),e[68]=Ne,e[69]=Ie,e[70]=Be):Be=e[70],Be};function hl(n){return n.currentDirectory}function gl(n){return n.currentSessionId}function bl(n){return!!n.newSessionDraft?.open}const xl=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=me(),o=kr(e),{connections:r,isBusy:i,isPasswordBusy:a,error:c,pendingConnection:d,connect:f,submitPassword:u,cancelPassword:m,saveConnection:g,removeConnection:h,setError:x}=o,[w,b]=l.useState(null),P=w?r.find(W=>W.id===w)??null:null,[j,C]=l.useState(null),[R,T]=l.useState(""),[D,k]=l.useState(""),[E,y]=l.useState(""),[I,M]=l.useState(""),[N,S]=l.useState(!1),[H,$]=l.useState(!1),v=l.useRef(null),A=l.useMemo(()=>fs(),[]),[O,z]=l.useState(!1),[B,ee]=l.useState(null),[X,_]=l.useState(!1),J=mr(l.useCallback(()=>_(!0),[])),q=l.useCallback(()=>{b(null),T(""),k(""),y(""),x(null),z(!1)},[x]),G=l.useCallback(W=>{W.preventDefault(),g({id:w??void 0,url:R,label:D,clientToken:E}).then(ie=>{ie&&q()})},[E,w,D,q,g,R]),F=l.useCallback(async()=>{if(v.current)return;x(null),S(!0);const W=new AbortController;v.current=W;try{const ie=await Rr({signal:W.signal});switch(v.current===W&&(v.current=null,S(!1)),ie.status){case"ok":T(ie.url),ie.label&&k(ie.label),ie.clientToken&&y(ie.clientToken),z(!0);break;case"pairing":$(!0),await o.redeemPairingConnection(ie.pairing);break;case"permission-denied":x(s("mobile.connect.scan.permissionDenied"));break;case"invalid":x(s("mobile.connect.scan.invalid"));break;case"unsupported":x(s("mobile.connect.scan.unsupported"));break;case"failed":x(s("mobile.connect.scan.failed"));break;default:break}}finally{$(!1),v.current===W&&(v.current=null,S(!1))}},[o,x,s]);l.useEffect(()=>()=>v.current?.abort(),[]);const Q=l.useCallback(W=>{W.preventDefault(),u(I)},[I,u]),te=l.useCallback(()=>{M(""),m()},[m]),ae=l.useCallback(W=>{C(ie=>ie===W?null:W)},[]),pe=l.useCallback(W=>{C(null),w===W&&q();const ie=r.length===1;h(W).then(U=>{U&&(ie||wn(U))&&n()})},[r.length,w,n,h,q]),oe=Ct;return d?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:Q,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(se,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:d.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:d.candidates.some(W=>W.kind==="direct")?Ge(d):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...ct,value:I,onChange:W=>M(W.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:oe}),c?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:c}):null,t.jsx(xe,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!I.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(xe,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:te,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[N?t.jsx(Pr,{onCancel:()=>v.current?.abort()}):null,H?t.jsx(Tr,{}):null,X?t.jsx(Sr,{onClose:()=>_(!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",{...J,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(W=>{const ie=j===W.id,U=wn(W),fe=B===W.id,Ne=fe?s("mobile.connect.connecting"):U?At()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):W.candidates.some(ke=>ke.kind==="direct")?Ge(W):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",ie&&"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-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-60",onClick:()=>{U||(ee(W.id),f({id:W.id,candidates:W.candidates,clientToken:W.clientToken,label:W.label}).finally(()=>ee(null)))},disabled:i&&!fe||ie,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(se,{name:"server",className:"size-[18px]"}),U?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:W.label}),t.jsx("span",{className:Z("block truncate typography-small",U&&!fe?"text-[var(--status-success)]":"text-muted-foreground"),children:Ne})]}),fe?t.jsx(se,{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:[ie?t.jsxs("button",{type:"button","aria-label":s("mobile.instances.confirmDeleteAria",{label:W.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:()=>pe(W.id),style:{touchAction:"manipulation"},children:[t.jsx(se,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:s("mobile.instances.delete")})]}):W.candidates.some(ke=>ke.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-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>{b(W.id),T(Ge(W)),k(W.label),y(W.clientToken||""),x(null)},style:{touchAction:"manipulation"},children:t.jsx(se,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":ie?s("mobile.instances.cancelDeleteAria",{label:W.label}):s("mobile.instances.deleteAria",{label:W.label}),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>ae(W.id),style:{touchAction:"manipulation"},children:t.jsx(se,{name:ie?"close":"delete-bin",className:"size-[18px]"})})]})]},W.id)})}):t.jsx("p",{...J,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")}),!O&&!P?t.jsxs("div",{className:"space-y-2",children:[A?t.jsxs(xe,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{F()},disabled:N,children:[t.jsx(se,{name:"scan-2",className:Z("size-[18px]",N&&"animate-pulse")}),s("mobile.connect.scanQr")]}):null,t.jsxs(xe,{type:"button",variant:A?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{x(null),z(!0)},children:[t.jsx(se,{name:"add",className:"size-[18px]"}),s("mobile.instances.addManual")]}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:G,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(P?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(xe,{type:"button",variant:"ghost",size:"xs",onClick:q,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",{...ct,value:R,onChange:W=>T(W.target.value),placeholder:s("mobile.connect.url.placeholder"),type:"url",inputMode:"url",autoCapitalize:"none",className:oe})]}),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:D,onChange:W=>k(W.target.value),placeholder:s("mobile.instances.label.placeholder"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,className:oe})]}),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",{...ct,value:E,onChange:W=>y(W.target.value),placeholder:s("mobile.connect.token.placeholder"),autoCapitalize:"none",className:oe}),t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")})]}),c?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:c}):null,t.jsx(xe,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(P?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},Se=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),ns=n=>{const e=Se(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},Nn=Os(n=>({expandedParents:{},toggleParent:e=>n(s=>{const o={...s.expandedParents};return o[e]?delete o[e]:o[e]=!0,{expandedParents:o}})})),Bt=Os()(ur(n=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,s)=>n(o=>({projectExpanded:{...o.projectExpanded,[e]:s}})),setWorktreeExpanded:(e,s)=>n(o=>({worktreeExpanded:{...o.worktreeExpanded,[e]:s}}))}),{name:"mobile-session-tree"})),ms=Os()(ur(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(o=>({orderByProject:{...o.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),Cn=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),yl=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((r,i)=>[Cn(r),i])),o=r=>s.get(Cn(r.path))??Number.MAX_SAFE_INTEGER;return e.map((r,i)=>({worktree:r,index:i})).sort((r,i)=>{const a=o(r.worktree)-o(i.worktree);return a!==0?a:r.index-i.index}).map(r=>r.worktree)},Et=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),vl=n=>{const e=n;return Et(e.directory??e.project?.worktree??null)},Ar=({open:n,project:e,worktree:s,onClose:o,onDeleted:r})=>{const{t:i}=me(),a=Qn(),c=bs(y=>y.activeSessions),d=je(y=>y.archiveSessions),f=dt(y=>y.currentDirectory),[u,m]=l.useState(!1),[g,h]=l.useState(!1),[x,w]=l.useState(!1),[b,P]=l.useState(!1),j=Et(s?.path),C=typeof s?.branch=="string"&&s.branch.trim().length>0,R=l.useMemo(()=>{if(!j)return[];const y=new Map;for(const I of[...c,...a])vl(I)===j&&y.set(I.id,I);return Array.from(y.values())},[c,a,j]);l.useEffect(()=>{if(!n){m(!1),h(!1),w(!1),P(!1);return}if(!s?.path)return;let y=!1;return Ro(s.path).then(I=>{y||w(!!I?.isDirty)}).catch(()=>{y||w(!!s.status?.isDirty)}),()=>{y=!0}},[n,s?.path,s?.status?.isDirty]);const T=l.useCallback(y=>{(async()=>{try{await Po(e,y,{deleteRemoteBranch:C&&g,deleteLocalBranch:C&&u}),Et(f)===j&&Et(e.path)&&dt.getState().setDirectory(Et(e.path),{showOverlay:!1}),ue.success(i("sessions.sidebar.sessionDialogs.worktree.removedTitle"),{description:i(C&&g?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),r?.()}catch(I){ue.error(i("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:I instanceof Error?I.message:i("sessions.sidebar.dialogs.deleteResult.tryAgain")})}})()},[f,u,g,C,r,e,i,j]),D=async()=>{if(!(!s||b)){P(!0);try{if(R.length>0){const{archivedIds:y,failedIds:I}=await d(R.map(M=>M.id));if(I.length>0){y.length>0&&ue.success(y.length===1?i("sessions.sidebar.bulkActions.archivedSingle",{count:y.length}):i("sessions.sidebar.bulkActions.archivedPlural",{count:y.length})),ue.error(I.length===1?i("sessions.sidebar.bulkActions.failedArchiveSingle",{count:I.length}):i("sessions.sidebar.bulkActions.failedArchivePlural",{count:I.length}),{description:i("sessions.sidebar.dialogs.deleteResult.tryAgain")}),P(!1);return}}T(s),o()}catch(y){ue.error(i("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:y instanceof Error?y.message:i("sessions.sidebar.dialogs.deleteResult.tryAgain")}),P(!1)}finally{n||P(!1)}}};if(!s)return null;const k=s.branch||s.label||s.path,E=(y,I,M,N)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":y,disabled:N,onClick:()=>I(!y),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-primary",N&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:M}),t.jsx("span",{className:Z("relative h-6 w-10 shrink-0 rounded-full transition-colors",y?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:Z("absolute top-0.5 size-5 rounded-full bg-white transition-transform",y?"translate-x-[1.125rem]":"translate-x-0.5")})})]});return t.jsx(To,{open:n,onClose:o,title:i("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(xe,{variant:"ghost",className:"flex-1",onClick:o,disabled:b,children:i("projectEditDialog.actions.cancel")}),t.jsx(xe,{variant:"destructive",className:"flex-1",onClick:()=>{D()},disabled:b,children:i("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:i("mobile.projectEdit.deleteWorktreeConfirm",{name:k})}),x?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:i("mobile.projectEdit.deleteWorktreeDirty")}):null,R.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i("mobile.projectEdit.deleteWorktreeArchiveNote",{count:R.length})}):null,C?t.jsxs("div",{className:"flex flex-col gap-2",children:[E(u,m,i("mobile.projectEdit.deleteLocalBranch"),b),E(g,h,i("mobile.projectEdit.deleteRemoteBranch"),b)]}):null]})})},En="mobile-surface-root",rs=16,$t=200,wl=()=>{if(typeof document>"u")return null;let n=document.getElementById(En);return n||(n=document.createElement("div"),n.id=En,document.body.appendChild(n)),n},Rt=({open:n,onClose:e,title:s,subtitle:o,trailing:r,disableEscapeDismiss:i=!1,headerless:a=!1,noHeaderBorder:c=!1,ariaLabel:d,variant:f="fullscreen",dialogAlign:u="chat",children:m})=>{const{t:g}=me(),h=l.useRef(null),[x,w]=l.useState(!1),[b,P]=l.useState(!1),j=l.useRef(null),C=l.useRef(null),R=l.useRef(e);if(l.useEffect(()=>{R.current=e},[e]),typeof document<"u"&&!h.current&&(h.current=wl()),l.useEffect(()=>{if(!n){w(!1);return}const k=window.setTimeout(()=>w(!0),rs);return()=>window.clearTimeout(k)},[n]),l.useEffect(()=>{if(!n){P(!1);return}const k=window.setTimeout(()=>P(!0),rs+$t+80);return()=>window.clearTimeout(k)},[n]),l.useEffect(()=>{if(!n)return;const k=document.body.style.overflow;C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const E=()=>{const M=j.current;if(!M)return;(M.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??M).focus({preventScroll:!0})},y=window.setTimeout(E,rs),I=M=>{if(M.key==="Escape"&&!i){R.current();return}if(M.key!=="Tab")return;const N=j.current;if(!N)return;const S=Array.from(N.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(A=>!A.hasAttribute("disabled")&&A.getAttribute("aria-hidden")!=="true");if(S.length===0){M.preventDefault(),N.focus({preventScroll:!0});return}const H=S[0],$=S[S.length-1],v=document.activeElement;M.shiftKey&&v===H?(M.preventDefault(),$.focus({preventScroll:!0})):!M.shiftKey&&v===$&&(M.preventDefault(),H.focus({preventScroll:!0}))};return document.addEventListener("keydown",I),()=>{window.clearTimeout(y),document.body.style.overflow=k,document.removeEventListener("keydown",I),C.current?.focus?.({preventScroll:!0}),C.current=null}},[i,n]),!n||!h.current)return null;const T=f==="dialog",D=t.jsxs("section",{ref:j,role:"dialog","aria-modal":"true","aria-label":d,tabIndex:-1,className:Z("flex flex-col bg-background text-foreground",T?"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 fixed inset-0 z-50"),style:T?{opacity:x?1:0,transform:x?"none":"scale(0.97)",transition:`opacity ${$t}ms ease-out, transform ${$t}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:x?"none":"translateX(100%)",transition:`transform ${$t}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:k=>{x&&k.target===k.currentTarget&&k.propertyName==="transform"&&P(!0)},children:[a?null:t.jsxs("header",{className:Z("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!c&&"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-primary","aria-label":g("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(se,{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,o?typeof o=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:o}):o: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:b?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:m}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return T?ut.createPortal(t.jsx("div",{className:"oc-keyboard-inset-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:x?1:0,paddingLeft:u==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:u==="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:k=>k.stopPropagation(),children:D})}),h.current):ut.createPortal(D,h.current)},jl=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),kl=n=>{const e=de.c(36),{worktree:s,onDelete:o}=n,{t:r}=me();let i;e[0]!==s.path?(i={id:s.path},e[0]=s.path,e[1]=i):i=e[1];const{attributes:a,listeners:c,setNodeRef:d,transform:f,transition:u,isDragging:m}=Ms(i);let g;e[2]!==f?(g=zs.Transform.toString(f),e[2]=f,e[3]=g):g=e[3];const h=m?10:1;let x;e[4]!==g||e[5]!==h||e[6]!==u?(x={transform:g,transition:u,zIndex:h},e[4]=g,e[5]=h,e[6]=u,e[7]=x):x=e[7];const w=x,b=s.branch||s.label||s.path,P=m&&"shadow-lg shadow-black/20";let j;e[8]!==P?(j=Z("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",P),e[8]=P,e[9]=j):j=e[9];let C;e[10]!==b||e[11]!==r?(C=r("mobile.projectEdit.dragWorktreeAria",{label:b}),e[10]=b,e[11]=r,e[12]=C):C=e[12];let R;e[13]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(Ns,{className:"size-4"}),e[13]=R):R=e[13];let T;e[14]!==a||e[15]!==c||e[16]!==C?(T=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,...c,children:R}),e[14]=a,e[15]=c,e[16]=C,e[17]=T):T=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(se,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[18]=D):D=e[18];let k;e[19]!==b?(k=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:b}),e[19]=b,e[20]=k):k=e[20];let E;e[21]!==b||e[22]!==r?(E=r("mobile.projectEdit.deleteWorktreeAria",{label:b}),e[21]=b,e[22]=r,e[23]=E):E=e[23];let y,I;e[24]===Symbol.for("react.memo_cache_sentinel")?(y={touchAction:"manipulation"},I=t.jsx(Gt,{className:"size-4"}),e[24]=y,e[25]=I):(y=e[24],I=e[25]);let M;e[26]!==o||e[27]!==E?(M=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":E,onClick:o,style:y,children:I}),e[26]=o,e[27]=E,e[28]=M):M=e[28];let N;return e[29]!==d||e[30]!==w||e[31]!==k||e[32]!==M||e[33]!==j||e[34]!==T?(N=t.jsxs("div",{ref:d,style:w,className:j,children:[T,D,k,M]}),e[29]=d,e[30]=w,e[31]=k,e[32]=M,e[33]=j,e[34]=T,e[35]=N):N=e[35],N},Sl=({open:n,project:e,onClose:s,onWorktreesChanged:o})=>{const{t:r}=me(),{currentTheme:i}=Zn(),a=Oe(v=>v.updateProjectMeta),c=Oe(v=>v.discoverProjectIcon),d=Oe(v=>v.removeProjectIcon),f=ms(v=>v.setWorktreeOrder),u=Oe(v=>e?v.projects.find(A=>A.id===e.id)?.iconImage??null:null),[m,g]=l.useState(""),[h,x]=l.useState(null),[w,b]=l.useState(null),[P,j]=l.useState(!1),[C,R]=l.useState([]),[T,D]=l.useState(null),k=e?.id??null;l.useEffect(()=>{!n||!e||(g(e.label),x(e.icon??null),b(e.color??null),R(e.worktrees))},[n,k]),l.useEffect(()=>{!n||!e||R(v=>{const A=e.worktrees.map(B=>B.path),O=v.map(B=>B.path);return A.length===O.length&&A.every(B=>O.includes(B))?v:e.worktrees})},[e?.worktrees]);const E=Es(mt(Ps,{activationConstraint:{distance:8}}),mt(Rs,{coordinateGetter:As})),y=()=>{if(!e)return;const v=m.trim();a(e.id,{label:v||e.label,icon:h,color:w}),s()},I=()=>{!e||P||(j(!0),c(e.id).then(v=>{if(!v.ok){ue.error(v.error||r("projectEditDialog.toast.failedToDiscoverIcon"));return}if(v.skipped){ue.success(r("projectEditDialog.toast.customIconAlreadySet"));return}ue.success(r("projectEditDialog.toast.iconDiscovered"))}).finally(()=>j(!1)))},M=()=>{e&&d(e.id).then(v=>{if(!v.ok){ue.error(v.error||r("projectEditDialog.toast.failedToRemoveIcon"));return}ue.success(r("projectEditDialog.toast.iconRemoved"))})},N=v=>{const{active:A,over:O}=v;if(!O||A.id===O.id||!e)return;const z=C.findIndex(_=>_.path===A.id),B=C.findIndex(_=>_.path===O.id);if(z<0||B<0)return;const ee=[...C],[X]=ee.splice(z,1);ee.splice(B,0,X),R(ee),f(e.id,ee.map(_=>jl(_.path)))},S=w?er[w]??null:null,H=h?tr[h]:null,$=!!u;return t.jsxs(t.Fragment,{children:[t.jsx(Rt,{open:n,onClose:s,title:r("projectEditDialog.title"),ariaLabel:r("projectEditDialog.title"),noHeaderBorder:!0,trailing:t.jsxs(xe,{type:"button",variant:"default",size:"sm","aria-label":r("projectEditDialog.actions.save"),onClick:y,disabled:!m.trim(),style:{touchAction:"manipulation"},children:[t.jsx(ar,{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:$?t.jsx(sr,{project:{id:e.id,iconImage:u},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(cs,{className:"size-7"})}):H?t.jsx(se,{name:H,className:"size-7",style:S?{color:S}:void 0}):t.jsx(cs,{className:"size-7",style:S?{color:S}: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(ws,{value:m,onChange:v=>g(v.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:()=>b(null),"aria-label":r("projectEditDialog.option.none"),className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",w===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"})}),Io.map(v=>t.jsx("button",{type:"button",onClick:()=>b(v.key),"aria-label":v.label,title:v.label,className:Z("size-9 rounded-xl border-2 transition-all",w===v.key?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:v.cssVar,touchAction:"manipulation"}},v.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:()=>x(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"})}),Ao.map(v=>t.jsx("button",{type:"button",onClick:()=>x(v.key),"aria-label":v.label,title:v.label,className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===v.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(se,{name:v.Icon,className:"size-4",style:S?{color:S}:void 0})},v.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(xe,{size:"sm",variant:"outline",onClick:I,disabled:P,children:r(P?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),$?t.jsx(xe,{size:"sm",variant:"outline",onClick:M,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(Ts,{sensors:E,collisionDetection:Is,onDragEnd:N,children:t.jsx(_s,{items:C.map(v=>v.path),strategy:Ds,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:C.map(v=>t.jsx(kl,{worktree:v,onDelete:()=>D(v)},v.path))})})})]})]}):null]}):null}),e?t.jsx(Ar,{open:!!T,project:{id:e.id,path:e.path},worktree:T,onClose:()=>D(null),onDeleted:()=>{R(v=>v.filter(A=>A.path!==T?.path)),o?.()}}):null]})},Nl=new Set,os=7,Rn=40,Cl=16,St=n=>n.parentID??null,ot=n=>{const e=n;return Se(e.directory??e.project?.worktree??null)},El=n=>{const e=n.time?.updated??n.time?.created,s=typeof e=="number"?e:Number(e);return Number.isFinite(s)&&s>0?s:0},Rl=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 o=Math.floor(s/60);if(o<24)return`${o}h`;const r=Math.floor(o/24);return r<7?`${r}d`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n))},Pl=(n,e)=>{const s=Se(n),o=Se(e);return!!(s&&o&&(s===o||s.startsWith(`${o}/`)))},Vt=(n,e)=>n.worktrees.find(s=>Se(s.path)===e)??null,ps=(n,e)=>e===n.path||!!Vt(n,e),is=(n,e)=>{const s=Se(e);return s?n.find(o=>ps(o,s))??null:null},as=(n,e,s)=>s?`${n.title??""} ${n.id} ${ot(n)} ${e}`.toLowerCase().includes(s):!0,hs=n=>{const e=de.c(17),{project:s,size:o}=n,r=o===void 0?"md":o,{currentTheme:i}=Zn(),a=s.icon?tr[s.icon]:null,c=s.color?er[s.color]??null:null,d=r==="sm"?"size-6 rounded-md":"size-8 rounded-lg",f=r==="sm"?"size-3.5":"size-4";let u;e[0]!==a||e[1]!==c||e[2]!==f?(u=a?t.jsx(se,{name:a,className:f,style:c?{color:c}:void 0}):t.jsx(cs,{className:f,style:c?{color:c}:void 0}),e[0]=a,e[1]=c,e[2]=f,e[3]=u):u=e[3];const m=u;let g;e[4]!==d?(g=Z("flex shrink-0 items-center justify-center overflow-hidden bg-[var(--surface-muted)] text-muted-foreground",d),e[4]=d,e[5]=g):g=e[5];let h;e[6]!==s.iconBackground?(h=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[6]=s.iconBackground,e[7]=h):h=e[7];let x;e[8]!==i||e[9]!==m||e[10]!==s.iconImage||e[11]!==s.id?(x=s.iconImage?t.jsx(sr,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:m}):m,e[8]=i,e[9]=m,e[10]=s.iconImage,e[11]=s.id,e[12]=x):x=e[12];let w;return e[13]!==g||e[14]!==h||e[15]!==x?(w=t.jsx("span",{className:g,style:h,children:x}),e[13]=g,e[14]=h,e[15]=x,e[16]=w):w=e[16],w},Pn=n=>{const e=de.c(2),{ariaLabel:s}=n;let o;return e[0]!==s?(o=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":s}),e[0]=s,e[1]=o):o=e[1],o},Tn=n=>{const e=de.c(12),{onClick:s,className:o}=n,{t:r}=me();let i;e[0]!==r?(i=r("sessions.sidebar.project.actions.newWorktree"),e[0]=r,e[1]=i):i=e[1];const a=i;let c;e[2]!==o?(c=Z("flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] 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)]",o),e[2]=o,e[3]=c):c=e[3];let d;e[4]!==s?(d=g=>{g.stopPropagation(),s()},e[4]=s,e[5]=d):d=e[5];let f,u;e[6]===Symbol.for("react.memo_cache_sentinel")?(f={touchAction:"manipulation"},u=t.jsx(se,{name:"node-tree",className:"size-4"}),e[6]=f,e[7]=u):(f=e[6],u=e[7]);let m;return e[8]!==a||e[9]!==c||e[10]!==d?(m=t.jsx("button",{type:"button",className:c,"aria-label":a,title:a,onClick:d,style:f,children:u}),e[8]=a,e[9]=c,e[10]=d,e[11]=m):m=e[11],m},rt=144,_r=180,In=n=>{const e=de.c(25),{actionsWidth:s,actions:o,revealed:r,onRevealedChange:i,children:a}=n,c=l.useRef(null),d=l.useRef(null),f=l.useRef(!1),u=l.useRef(0),m=l.useRef(r);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=(N,S)=>{const H=c.current;H&&(H.style.transition=S?`transform ${_r}ms ease-out`:"none",H.style.transform=N===0?"none":`translateX(${N}px)`,u.current=N)},e[0]=g):g=e[0];const h=g;let x,w;e[1]!==s||e[2]!==r?(x=()=>{m.current=r,h(r?-s:0,!0)},w=[s,h,r],e[1]=s,e[2]=r,e[3]=x,e[4]=w):(x=e[3],w=e[4]),l.useEffect(x,w);let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=N=>{if(N.touches.length!==1)return;const S=N.touches[0];d.current={x:S.clientX,y:S.clientY},f.current=!1},e[5]=b):b=e[5];const P=b;let j;e[6]!==s?(j=N=>{if(!d.current)return;const S=N.touches[0],H=S.clientX-d.current.x,$=S.clientY-d.current.y;if(!f.current){if(Math.abs(H)<8||Math.abs(H)<=Math.abs($))return;f.current=!0}const v=m.current?-s:0;h(Math.min(0,Math.max(-s,v+H)),!1)},e[6]=s,e[7]=j):j=e[7];const C=j;let R;e[8]!==s||e[9]!==i?(R=()=>{if(d.current=null,!f.current)return;f.current=!1;const N=u.current<-s/2;h(N?-s:0,!0),N!==m.current&&i(N)},e[8]=s,e[9]=i,e[10]=R):R=e[10];const T=R;let D;e[11]===Symbol.for("react.memo_cache_sentinel")?(D={touchAction:"pan-y"},e[11]=D):D=e[11];let k;e[12]!==s?(k={width:s},e[12]=s,e[13]=k):k=e[13];const E=!r;let y;e[14]!==o||e[15]!==k||e[16]!==E?(y=t.jsx("div",{className:"absolute inset-y-0 right-0 flex items-stretch",style:k,"aria-hidden":E,children:o}),e[14]=o,e[15]=k,e[16]=E,e[17]=y):y=e[17];let I;e[18]!==a?(I=t.jsx("div",{ref:c,className:"relative flex w-full items-center bg-background",children:a}),e[18]=a,e[19]=I):I=e[19];let M;return e[20]!==T||e[21]!==C||e[22]!==y||e[23]!==I?(M=t.jsxs("div",{className:"relative overflow-hidden",onTouchStart:P,onTouchMove:C,onTouchEnd:T,onTouchCancel:T,style:D,children:[y,I]}),e[20]=T,e[21]=C,e[22]=y,e[23]=I,e[24]=M):M=e[24],M},Tl=n=>{const e=de.c(41),{initialTitle:s,indent:o,onSubmit:r,onCancel:i}=n,{t:a}=me(),[c,d]=l.useState(s);let f;e[0]!==s||e[1]!==i||e[2]!==r||e[3]!==c?(f=()=>{const N=c.trim();if(!N||N===s.trim()){i();return}r(N)},e[0]=s,e[1]=i,e[2]=r,e[3]=c,e[4]=f):f=e[4];const u=f;let m;e[5]!==o?(m={paddingLeft:o},e[5]=o,e[6]=m):m=e[6];let g;e[7]!==u?(g=N=>{N.preventDefault(),u()},e[7]=u,e[8]=g):g=e[8];let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=N=>d(N.target.value),e[9]=h):h=e[9];let x;e[10]!==i?(x=N=>{N.stopPropagation(),N.key==="Escape"&&i()},e[10]=i,e[11]=x):x=e[11];let w;e[12]!==a?(w=a("sessions.sidebar.session.rename.save"),e[12]=a,e[13]=w):w=e[13];let b;e[14]!==a?(b=a("sessions.sidebar.session.menu.rename"),e[14]=a,e[15]=b):b=e[15];let P;e[16]===Symbol.for("react.memo_cache_sentinel")?(P={minHeight:0},e[16]=P):P=e[16];let j;e[17]!==x||e[18]!==w||e[19]!==b||e[20]!==c?(j=t.jsx("input",{autoFocus:!0,value:c,onChange:h,onKeyDown:x,"aria-label":w,placeholder:b,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:P,enterKeyHint:"done"}),e[17]=x,e[18]=w,e[19]=b,e[20]=c,e[21]=j):j=e[21];let C;e[22]!==a?(C=a("sessions.sidebar.session.rename.save"),e[22]=a,e[23]=C):C=e[23];let R,T;e[24]===Symbol.for("react.memo_cache_sentinel")?(R={touchAction:"manipulation",minHeight:0,minWidth:0},T=t.jsx(se,{name:"check",className:"size-4"}),e[24]=R,e[25]=T):(R=e[24],T=e[25]);let D;e[26]!==C?(D=t.jsx("button",{type:"submit","aria-label":C,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-primary",style:R,children:T}),e[26]=C,e[27]=D):D=e[27];let k;e[28]!==a?(k=a("sessions.sidebar.session.rename.cancel"),e[28]=a,e[29]=k):k=e[29];let E,y;e[30]===Symbol.for("react.memo_cache_sentinel")?(E={touchAction:"manipulation",minHeight:0,minWidth:0},y=t.jsx(se,{name:"close",className:"size-4"}),e[30]=E,e[31]=y):(E=e[30],y=e[31]);let I;e[32]!==i||e[33]!==k?(I=t.jsx("button",{type:"button",onClick:i,"aria-label":k,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-primary",style:E,children:y}),e[32]=i,e[33]=k,e[34]=I):I=e[34];let M;return e[35]!==D||e[36]!==I||e[37]!==m||e[38]!==g||e[39]!==j?(M=t.jsxs("form",{className:"flex h-9 min-w-0 flex-1 items-center gap-2 pr-2",style:m,onSubmit:g,children:[j,D,I]}),e[35]=D,e[36]=I,e[37]=m,e[38]=g,e[39]=j,e[40]=M):M=e[40],M},An=n=>{const e=de.c(51),{session:s,active:o,indent:r,contextLabel:i,hasChildren:a,expanded:c,onToggleChildren:d,onSelect:f,revealed:u,onRevealedChange:m,confirmingDelete:g,onArchive:h,onRequestDelete:x,onConfirmDelete:w,renaming:b,onRequestRename:P,onSubmitRename:j,onCancelRename:C}=n,R=a===void 0?!1:a,T=c===void 0?!1:c,D=u===void 0?!1:u,k=g===void 0?!1:g,E=b===void 0?!1:b,{t:y}=me();let I;e[0]!==s?(I=Rl(El(s)),e[0]=s,e[1]=I):I=e[1];const M=I,N=s.title?.trim()||y("mobile.sessions.untitled"),S=!!(m&&h),H=Yn(s.id),$=Jn(s.id),v=H?.type??"idle",A=v==="busy"||v==="retry",O=!A&&$>0&&!o,z=Xn(s.id,A),B=(A||O)&&z,ee=l.useRef(null),X=l.useRef(null),_=l.useRef(!1),J=l.useRef(0),q=l.useRef(D);let G;e[2]===Symbol.for("react.memo_cache_sentinel")?(G=(le,Ce)=>{const be=ee.current;be&&(be.style.transition=Ce?`transform ${_r}ms ease-out`:"none",be.style.transform=le===0?"none":`translateX(${le}px)`,J.current=le)},e[2]=G):G=e[2];const F=G;let Q,te;e[3]!==D?(Q=()=>{q.current=D,F(D?-rt:0,!0)},te=[F,D],e[3]=D,e[4]=Q,e[5]=te):(Q=e[4],te=e[5]),l.useEffect(Q,te);let ae;e[6]!==S?(ae=le=>{if(!S||le.touches.length!==1)return;const Ce=le.touches[0];X.current={x:Ce.clientX,y:Ce.clientY},_.current=!1},e[6]=S,e[7]=ae):ae=e[7];const pe=ae;let oe;e[8]!==S?(oe=le=>{if(!S||!X.current)return;const Ce=le.touches[0],be=Ce.clientX-X.current.x,Fe=Ce.clientY-X.current.y;if(!_.current){if(Math.abs(be)<8||Math.abs(be)<=Math.abs(Fe))return;_.current=!0}const Pe=q.current?-rt:0,tt=Math.min(0,Math.max(-rt,Pe+be));F(tt,!1)},e[8]=S,e[9]=oe):oe=e[9];const W=oe;let ie;e[10]!==m?(ie=()=>{if(X.current=null,!_.current)return;_.current=!1;const le=J.current<-rt/2;F(le?-rt:0,!0),le!==q.current&&m?.(le)},e[10]=m,e[11]=ie):ie=e[11];const U=ie,fe=o||void 0,Ne="relative overflow-hidden";let ke;e[12]!==S?(ke=S?{touchAction:"pan-y"}:void 0,e[12]=S,e[13]=ke):ke=e[13];const Ie=S?t.jsxs("div",{className:"absolute inset-y-0 right-0 flex items-stretch",style:{width:rt},"aria-hidden":!D,children:[t.jsx("button",{type:"button",tabIndex:D?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-primary","aria-label":y("mobile.sessions.renameSessionAria",{title:N}),onClick:P,style:{touchAction:"manipulation"},children:t.jsx(us,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:D?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-primary","aria-label":y("mobile.sessions.archiveSessionAria",{title:N}),onClick:h,style:{touchAction:"manipulation"},children:t.jsx(Yi,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:D?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",k?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":k?y("mobile.sessions.confirmDeleteSessionAria",{title:N}):y("mobile.sessions.deleteSessionAria",{title:N}),onClick:k?w:x,style:{touchAction:"manipulation"},children:t.jsx(Gt,{className:"size-[18px]"})})]}):null,Be=S&&"bg-background",Ae=o&&(S?"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]":"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]");let _e;e[14]!==Be||e[15]!==Ae?(_e=Z("relative flex items-center gap-1 transition-colors",Be,Ae),e[14]=Be,e[15]=Ae,e[16]=_e):_e=e[16];let ve;e[17]!==T||e[18]!==R||e[19]!==r||e[20]!==A||e[21]!==d||e[22]!==O||e[23]!==y?(ve=A||O||R&&d?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-primary",style:{left:Math.max(r-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":y(T?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!R||!d,onClick:le=>{le.stopPropagation(),d?.()},children:A||O?t.jsx("span",{className:Z("size-1.5 rounded-full",A?"bg-primary":"bg-[var(--status-info)]"),"aria-hidden":!0}):t.jsx(Cs,{className:Z("size-[18px] transition-transform duration-150",T?"rotate-0":"-rotate-90")})}):null,e[17]=T,e[18]=R,e[19]=r,e[20]=A,e[21]=d,e[22]=O,e[23]=y,e[24]=ve):ve=e[24];let L;e[25]!==o||e[26]!==i||e[27]!==r||e[28]!==A||e[29]!==C||e[30]!==m||e[31]!==f||e[32]!==j||e[33]!==E||e[34]!==s.id||e[35]!==B||e[36]!==M||e[37]!==N?(L=E&&j&&C?t.jsx(Tl,{initialTitle:N,indent:r,onSubmit:j,onCancel:C}):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-primary focus-visible:ring-inset",i?"min-h-10 py-1":"h-9"),style:{paddingLeft:r,touchAction:"manipulation"},onClick:()=>{if(q.current){m?.(!1);return}f()},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",o?"text-primary":"text-foreground"),children:N}),B?t.jsx(ir,{sessionId:s.id,running:A,className:"typography-micro"}):M?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:M}):null]}),i?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:i}):null]})}),e[25]=o,e[26]=i,e[27]=r,e[28]=A,e[29]=C,e[30]=m,e[31]=f,e[32]=j,e[33]=E,e[34]=s.id,e[35]=B,e[36]=M,e[37]=N,e[38]=L):L=e[38];let V;e[39]!==_e||e[40]!==ve||e[41]!==L?(V=t.jsxs("div",{ref:ee,className:_e,children:[ve,L]}),e[39]=_e,e[40]=ve,e[41]=L,e[42]=V):V=e[42];let re;return e[43]!==U||e[44]!==W||e[45]!==pe||e[46]!==fe||e[47]!==ke||e[48]!==Ie||e[49]!==V?(re=t.jsxs("div",{"data-active-session":fe,className:Ne,onTouchStart:pe,onTouchMove:W,onTouchEnd:U,onTouchCancel:U,style:ke,children:[Ie,V]}),e[43]=U,e[44]=W,e[45]=pe,e[46]=fe,e[47]=ke,e[48]=Ie,e[49]=V,e[50]=re):re=e[50],re},Il=n=>{const e=de.c(11),{indent:s,onClick:o}=n,{t:r}=me();let i;e[0]!==s?(i={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Cs,{className:"size-4"}),e[2]=a):a=e[2];let c;e[3]!==r?(c=r("sessions.sidebar.group.showMore"),e[3]=r,e[4]=c):c=e[4];let d;e[5]!==c?(d=t.jsx("span",{className:"typography-micro",children:c}),e[5]=c,e[6]=d):d=e[6];let f;return e[7]!==o||e[8]!==i||e[9]!==d?(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-primary focus-visible:ring-inset",style:i,onClick:o,children:[a,d]}),e[7]=o,e[8]=i,e[9]=d,e[10]=f):f=e[10],f},Al=n=>{const e=de.c(11),{indent:s,onClick:o}=n,{t:r}=me();let i;e[0]!==s?(i={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Ji,{className:"size-4"}),e[2]=a):a=e[2];let c;e[3]!==r?(c=r("sessions.sidebar.group.showFewer"),e[3]=r,e[4]=c):c=e[4];let d;e[5]!==c?(d=t.jsx("span",{className:"typography-micro",children:c}),e[5]=c,e[6]=d):d=e[6];let f;return e[7]!==o||e[8]!==i||e[9]!==d?(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-primary focus-visible:ring-inset",style:i,onClick:o,children:[a,d]}),e[7]=o,e[8]=i,e[9]=d,e[10]=f):f=e[10],f},_l=n=>{const e=de.c(29),{worktree:s}=n,{t:o}=me();let r;e[0]!==s.path?(r=Se(s.path),e[0]=s.path,e[1]=r):r=e[1];const i=r;let a;e[2]!==i?(a={id:i},e[2]=i,e[3]=a):a=e[3];const{attributes:c,listeners:d,setNodeRef:f,transform:u,transition:m,isDragging:g}=Ms(a),h=s.branch||s.label||s.path;let x;e[4]!==u?(x=zs.Transform.toString(u),e[4]=u,e[5]=x):x=e[5];const w=g?10:1;let b;e[6]!==x||e[7]!==w||e[8]!==m?(b={transform:x,transition:m,zIndex:w},e[6]=x,e[7]=w,e[8]=m,e[9]=b):b=e[9];const P=g&&"shadow-lg shadow-black/20";let j;e[10]!==P?(j=Z("flex items-center gap-1 rounded-xl bg-background px-1 py-1",P),e[10]=P,e[11]=j):j=e[11];let C;e[12]!==h||e[13]!==o?(C=o("mobile.sessions.dragHandleAria",{label:h}),e[12]=h,e[13]=o,e[14]=C):C=e[14];let R;e[15]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(Ns,{className:"size-4"}),e[15]=R):R=e[15];let T;e[16]!==c||e[17]!==d||e[18]!==C?(T=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,...c,...d,children:R}),e[16]=c,e[17]=d,e[18]=C,e[19]=T):T=e[19];let D;e[20]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(se,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=D):D=e[20];let k;e[21]!==h?(k=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]=k):k=e[22];let E;return e[23]!==f||e[24]!==T||e[25]!==k||e[26]!==b||e[27]!==j?(E=t.jsxs("div",{ref:f,style:b,className:j,children:[T,D,k]}),e[23]=f,e[24]=T,e[25]=k,e[26]=b,e[27]=j,e[28]=E):E=e[28],E},Dl=n=>{const e=de.c(61),{project:s,totalSessions:o,expanded:r,onToggleExpanded:i,onReorderWorktrees:a}=n,{t:c}=me();let d;e[0]!==s.id?(d={id:s.id},e[0]=s.id,e[1]=d):d=e[1];const{attributes:f,listeners:u,setNodeRef:m,transform:g,transition:h,isDragging:x}=Ms(d);let w;e[2]===Symbol.for("react.memo_cache_sentinel")?(w={activationConstraint:{distance:8}},e[2]=w):w=e[2];let b;e[3]===Symbol.for("react.memo_cache_sentinel")?(b={coordinateGetter:As},e[3]=b):b=e[3];const P=Es(mt(Ps,w),mt(Rs,b)),j=s.worktrees.length>0;let C;e[4]!==a||e[5]!==s.worktrees?(C=J=>{const{active:q,over:G}=J;if(!G||q.id===G.id)return;const F=s.worktrees.map(Ll),Q=F.indexOf(String(q.id)),te=F.indexOf(String(G.id));if(Q<0||te<0)return;const ae=[...F],[pe]=ae.splice(Q,1);ae.splice(te,0,pe),a(ae)},e[4]=a,e[5]=s.worktrees,e[6]=C):C=e[6];const R=C;let T;e[7]!==g?(T=zs.Transform.toString(g),e[7]=g,e[8]=T):T=e[8];const D=x?10:1;let k;e[9]!==T||e[10]!==D||e[11]!==h?(k={transform:T,transition:h,zIndex:D},e[9]=T,e[10]=D,e[11]=h,e[12]=k):k=e[12];const E=x&&"shadow-lg shadow-black/20";let y;e[13]!==E?(y=Z("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",E),e[13]=E,e[14]=y):y=e[14];let I;e[15]!==s.label||e[16]!==c?(I=c("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=c,e[17]=I):I=e[17];let M;e[18]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(Ns,{className:"size-4"}),e[18]=M):M=e[18];let N;e[19]!==f||e[20]!==u||e[21]!==I?(N=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":I,...f,...u,children:M}),e[19]=f,e[20]=u,e[21]=I,e[22]=N):N=e[22];let S;e[23]!==r||e[24]!==s.label||e[25]!==c?(S=r?c("sessions.sidebar.group.collapseAria",{label:s.label}):c("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=r,e[24]=s.label,e[25]=c,e[26]=S):S=e[26];const H=!j;let $;e[27]===Symbol.for("react.memo_cache_sentinel")?($={touchAction:"manipulation"},e[27]=$):$=e[27];let v;e[28]!==s?(v=t.jsx(hs,{project:s}),e[28]=s,e[29]=v):v=e[29];let A;e[30]!==s.label?(A=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]=A):A=e[31];let O;e[32]!==o?(O=t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:o}),e[32]=o,e[33]=O):O=e[33];let z;e[34]!==r||e[35]!==j?(z=j?t.jsx(Cs,{className:Z("size-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-180")}):null,e[34]=r,e[35]=j,e[36]=z):z=e[36];let B;e[37]!==r||e[38]!==i||e[39]!==S||e[40]!==H||e[41]!==v||e[42]!==A||e[43]!==O||e[44]!==z?(B=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-primary",onClick:i,"aria-expanded":r,"aria-label":S,disabled:H,style:$,children:[v,A,O,z]}),e[37]=r,e[38]=i,e[39]=S,e[40]=H,e[41]=v,e[42]=A,e[43]=O,e[44]=z,e[45]=B):B=e[45];let ee;e[46]!==N||e[47]!==B?(ee=t.jsxs("div",{className:"flex items-center gap-1",children:[N,B]}),e[46]=N,e[47]=B,e[48]=ee):ee=e[48];let X;e[49]!==r||e[50]!==R||e[51]!==j||e[52]!==s.worktrees||e[53]!==P?(X=r&&j?t.jsx(Ts,{sensors:P,collisionDetection:Is,onDragEnd:R,children:t.jsx(_s,{items:s.worktrees.map(Bl),strategy:Ds,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 pl-3",children:s.worktrees.map($l)})})}):null,e[49]=r,e[50]=R,e[51]=j,e[52]=s.worktrees,e[53]=P,e[54]=X):X=e[54];let _;return e[55]!==m||e[56]!==ee||e[57]!==X||e[58]!==k||e[59]!==y?(_=t.jsxs("div",{ref:m,style:k,className:y,children:[ee,X]}),e[55]=m,e[56]=ee,e[57]=X,e[58]=k,e[59]=y,e[60]=_):_=e[60],_},_n=({open:n,onOpenChange:e,variant:s="drawer",footer:o})=>{const{t:r}=me(),{git:i}=js(),a=Qn(),c=bs(p=>p.activeSessions),d=Hn(l.useCallback(p=>n||s==="sidebar"?p.ids:Nl,[n,s])),f=qn(l.useCallback(p=>n||s==="sidebar"?p.rankById:_o,[n,s])),u=Oe(p=>p.projects),m=Oe(p=>p.activeProjectId),g=dt(p=>p.currentDirectory),h=je(p=>p.currentSessionId),x=je(p=>p.setCurrentSession),w=je(p=>p.archiveSession),b=je(p=>p.deleteSession),P=je(p=>p.updateSessionTitle),j=je(p=>p.openNewSessionDraft),C=Oe(p=>p.setActiveProject),R=Oe(p=>p.setActiveProjectIdOnly),T=Oe(p=>p.reorderProjects),D=Oe(p=>p.removeProject),k=Bt(p=>p.projectExpanded),E=Bt(p=>p.worktreeExpanded),y=Bt(p=>p.setProjectExpanded),I=Bt(p=>p.setWorktreeExpanded),M=ms(p=>p.orderByProject),N=ms(p=>p.setWorktreeOrder),S=Nn(p=>p.expandedParents),H=Nn(p=>p.toggleParent),[$,v]=l.useState(""),[A,O]=l.useState(null),[z,B]=l.useState(null),[ee,X]=l.useState(null),[_,J]=l.useState(null),[q,G]=l.useState(null),[F,Q]=l.useState(null),[te,ae]=l.useState(null),[pe,oe]=l.useState(0),[W,ie]=l.useState(!1),[U,fe]=l.useState(!1),[Ne,ke]=l.useState(null),[Ie,Be]=l.useState(()=>new Map(je.getState().availableWorktreesByProject)),[Ae,_e]=l.useState(()=>{const p=new Set;for(const[K,Y]of je.getState().availableWorktreesByProject)Y.length>0&&p.add(K);return p}),[ve,L]=l.useState(!1),[V,re]=l.useState(new Set),[le,Ce]=l.useState(new Map);l.useEffect(()=>{if(!n){v(""),L(!1),re(new Set),Ce(new Map),O(null),B(null),X(null),J(null),G(null),Q(null);return}vs(a)},[n]),l.useEffect(()=>{ve||re(new Set)},[ve]),l.useEffect(()=>{if(!n||u.length===0)return;let p=!1;return(async()=>{const Y=await Promise.all(u.map(async ce=>{const Ee=Se(ce.path);if(!Ee)return null;const ge=await i.checkIsGitRepository(Ee).catch(()=>!1),De=ge?await nr({id:ce.id,path:Ee}).catch(()=>[]):[];return[Ee,De,ge]}));if(p)return;const ne=new Map,we=new Set;for(const ce of Y)ce&&(ne.set(ce[0],ce[1]),ce[2]&&we.add(ce[0]));Be(rr(u,ne)),_e(we)})(),()=>{p=!0}},[i,n,u,pe]);const be=l.useMemo(()=>u.map(p=>({id:p.id,label:p.label?.trim()||ns(p.path),path:Se(p.path),icon:p.icon,color:p.color,iconImage:p.iconImage,iconBackground:p.iconBackground,isGitRepo:Ae.has(Se(p.path)),worktrees:yl(M[p.id],Ie.get(Se(p.path))??[])})),[Ae,u,M,Ie]),Fe=l.useMemo(()=>{const p=new Map(a.map(ne=>[ne.id,ne])),K=c.map(ne=>{const we=p.get(ne.id);return we?Do(we,ne):ne}),Y=new Set(K.map(ne=>ne.id));for(const ne of a)Y.has(ne.id)||K.push(ne);return K.filter(ne=>!ne.time?.archived)},[c,a]),Pe=$.trim().toLowerCase(),tt=l.useRef(null);l.useEffect(()=>{if(!n)return;const p=window.requestAnimationFrame(()=>{const K=tt.current;if(!K)return;(K.querySelector('[data-active-session="true"]')??K.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(p)},[n]);const Dt=l.useMemo(()=>{const p=be.map(Y=>({project:Y,buckets:[],totalSessions:0,isActive:Y.id===m})),K=(Y,ne,we)=>{const ce=Se(ne)||Y.project.path,Ee=ce||"__root__";let ge=Y.buckets.find(De=>De.key===Ee);return ge||(ge={key:Ee,label:we?.branch||ns(ce),path:ce,worktree:we,sessions:[]},Y.buckets.push(ge)),ge};for(const Y of p){K(Y,Y.project.path,null);for(const ne of Y.project.worktrees)K(Y,ne.path,ne)}for(const Y of Fe){const ne=ot(Y);if(!ne)continue;const we=Se(ne),ce=p.find(De=>ps(De.project,we));if(!ce)continue;const Ee=Vt(ce.project,we);(Ee?K(ce,Ee.path,Ee):K(ce,ce.project.path,null)).sessions.push(Y)}for(const Y of p)for(const ne of Y.buckets){ne.sessions=cn(ne.sessions,d,f);for(const we of ne.sessions)St(we)||(Y.totalSessions+=1)}return p},[m,d,be,f,Fe]),Ks=Se(g),Or=p=>p.isActive?Ks===p.project.path?p.project.path:p.project.worktrees.find(Y=>Pl(Ks,Y.path))?.path??p.project.path:null,Lr=p=>k[p.project.id]??!0,Br=(p,K)=>E[`${p.project.id}::${K.key}`]??!0,Hs=p=>{Ce(K=>{if(!K.has(p))return K;const Y=new Map(K);return Y.delete(p),Y})},$r=p=>{Ce(K=>{let Y=!1;const ne=new Map(K),we=`${p}::`;for(const ce of ne.keys())ce.startsWith(we)&&(ne.delete(ce),Y=!0);return Y?ne:K})},Fr=(p,K)=>{Ce(Y=>{const ne=new Map(Y);return ne.set(p,K+os),ne})},qs=(p,K,Y)=>{const ne=`${p.project.id}::${K.key}`,we=new Set(K.sessions.map(ye=>ye.id)),ce=new Map;for(const ye of K.sessions){const $e=St(ye);if($e&&we.has($e)){const yt=ce.get($e)??[];yt.push(ye),ce.set($e,yt)}}const Ee=K.sessions.filter(ye=>{const $e=St(ye);return!$e||!we.has($e)}),ge=le.get(ne)??os,De=Ee.slice(0,ge),st=Ee.length-De.length,Zt=Ee.length>os&&st===0,tn=(ye,$e)=>{const yt=ce.get(ye.id)??[],es=yt.length>0,sn=!!S[ye.id];return t.jsxs(l.Fragment,{children:[t.jsx(An,{session:ye,active:h===ye.id,indent:$e,hasChildren:es,expanded:sn,onToggleChildren:es?()=>H(ye.id):void 0,onSelect:()=>Ys(ye),revealed:z===ye.id,onRevealedChange:vt=>Vr(ye.id,vt),confirmingDelete:ee===ye.id,onArchive:()=>{Gr(ye)},onRequestDelete:()=>X(ye.id),onConfirmDelete:()=>{Kr(ye)},renaming:_===ye.id,onRequestRename:()=>Hr(ye.id),onSubmitRename:vt=>{qr(ye.id,vt)},onCancelRename:()=>J(null)}),es&&sn?yt.map(vt=>tn(vt,$e+Cl)):null]},ye.id)};return t.jsxs("div",{children:[De.map(ye=>tn(ye,Y)),st>0?t.jsx(Il,{indent:Y,onClick:()=>Fr(ne,De.length)}):null,Zt?t.jsx(Al,{indent:Y,onClick:()=>Hs(ne)}):null]})},Wr=(p,K)=>{y(p,!K),$r(p)},Ur=(p,K,Y)=>{I(`${p}::${K}`,!Y),Hs(`${p}::${K}`)},Ys=p=>{const K=ot(p)||null,Y=is(be,K??"");if(Y){R(Y.id),y(Y.id,!0);const ne=Vt(Y,Se(K??""));ne&&I(`${Y.id}::${Se(ne.path)}`,!0)}x(p.id,K),e(!1)},Vr=(p,K)=>{B(K?p:null),X(null),G(null),Q(null)},Mt=(p,K)=>{G(K?p:null),Q(null),B(null),X(null)},Gr=async p=>{B(null),X(null),await w(p.id)?ue.success(r("sessions.sidebar.session.archive.success")):ue.error(r("sessions.sidebar.session.archive.error"))},Kr=async p=>{B(null),X(null),await b(p.id)?ue.success(r("sessions.sidebar.session.delete.success")):ue.error(r("sessions.sidebar.session.delete.error"))},Hr=p=>{B(null),X(null),J(p)},qr=async(p,K)=>{J(null);try{await P(p,K)}catch{ue.error(r("mobile.sessions.renameError"))}},Yr=()=>{j(),e(!1)},Js=p=>{ke(p),R(p),fe(!0)},Jr=Es(mt(Ps,{activationConstraint:{distance:8}}),mt(Rs,{coordinateGetter:As})),Xr=p=>{const{active:K,over:Y}=p;if(!Y||K.id===Y.id)return;const ne=be.findIndex(ce=>ce.id===K.id),we=be.findIndex(ce=>ce.id===Y.id);ne<0||we<0||T(ne,we)},Qr=p=>{re(K=>{const Y=new Set(K);return Y.has(p)?Y.delete(p):Y.add(p),Y})},Zr=l.useCallback(p=>{const K=ot(p),Y=is(be,K);if(!Y)return ns(K)||K;const ne=Vt(Y,Se(K));return ne?.branch?`${Y.label} · ${ne.branch}`:Y.label},[be]),eo=p=>{C(p.id),e(!1)},to=l.useMemo(()=>Pe?Dt.filter(p=>`${p.project.label} ${p.project.path}`.toLowerCase().includes(Pe)?!0:p.buckets.some(K=>K.sessions.some(Y=>as(Y,p.project.label,Pe)))):Dt,[Pe,Dt]),zt=l.useMemo(()=>Pe?cn(Fe.filter(p=>{if(St(p))return!1;const K=ot(p),Y=is(be,K);return as(p,Y?.label??"",Pe)}),d,f):[],[Pe,d,be,f,Fe]),Ot=l.useMemo(()=>Pe?be.filter(p=>`${p.label} ${p.path}`.toLowerCase().includes(Pe)).map(p=>({...p,sessionCount:Fe.filter(K=>{if(St(K))return!1;const Y=Se(ot(K));return ps(p,Y)}).length})):[],[Pe,be,Fe]),so=Pe&&zt.length===0&&Ot.length===0,Xs=!Pe&&be.length>1?t.jsx(xe,{type:"button",variant:"chip",size:"sm","aria-label":r(ve?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":ve,onClick:()=>L(p=>!p),style:{touchAction:"manipulation"},children:ve?t.jsx(ar,{className:"size-4"}):t.jsx(us,{className:"size-4"})}):null,Qs=!ve&&be.length>0?t.jsxs(xe,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:Yr,style:{touchAction:"manipulation"},children:[t.jsx(qi,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,Zs=ve?null:t.jsx(xe,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.addProject"),title:r("sessions.sidebar.header.actions.addProject"),onClick:()=>ie(!0),style:{touchAction:"manipulation"},children:t.jsx(un,{className:"size-4"})}),Lt=Qs||Zs||Xs?t.jsxs(t.Fragment,{children:[Qs,Zs,Xs]}):null,en=t.jsxs("div",{ref:tt,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs(ks,{className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:Z("px-4 pb-2 pt-1",ve&&"hidden"),children:t.jsxs("div",{className:"relative",children:[t.jsx(lr,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(ws,{value:$,onChange:p=>v(p.target.value),placeholder:r("mobile.sessions.search.placeholder"),className:Z("h-11 pl-9",$&&"pr-10")}),$?t.jsx("button",{type:"button",className:"absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 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-primary","aria-label":r("mobile.sessions.clearSearchAria"),onClick:()=>v(""),style:{touchAction:"manipulation"},children:t.jsx(cr,{className:"size-4"})}):null]})}),be.length===0?t.jsx(zn,{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-primary",onClick:()=>ie(!0),children:[t.jsx(un,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):so?t.jsx(zn,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):Pe&&!ve?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[zt.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:zt.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:zt.map((p,K)=>t.jsx("div",{className:Z(K>0&&"border-t border-border/70"),children:t.jsx(An,{session:p,active:h===p.id,indent:12,contextLabel:Zr(p),onSelect:()=>Ys(p)})},p.id))})]}):null,Ot.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:Ot.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Ot.map((p,K)=>t.jsxs("div",{className:Z("flex items-center",K>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-primary focus-visible:ring-inset",onClick:()=>eo(p),style:{touchAction:"manipulation"},children:[t.jsx(hs,{project:p}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:p.label}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:p.sessionCount})]}),p.isGitRepo?t.jsx(Tn,{className:"mr-2",onClick:()=>Js(p.id)}):null]},p.id))})]}):null]}):ve?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(Ts,{sensors:Jr,collisionDetection:Is,onDragEnd:Xr,children:t.jsx(_s,{items:be.map(p=>p.id),strategy:Ds,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:be.map(p=>{const K=Dt.find(Y=>Y.project.id===p.id);return t.jsx(Dl,{project:p,totalSessions:K?.totalSessions??0,expanded:V.has(p.id),onToggleExpanded:()=>Qr(p.id),onReorderWorktrees:Y=>N(p.id,Y)},p.id)})})})})]}):t.jsx("div",{className:"flex flex-col",children:to.map((p,K)=>{const Y=Lr(p),ne=Pe?p.buckets.filter(ce=>ce.sessions.some(Ee=>as(Ee,p.project.label,Pe))):p.buckets,we=Or(p);return t.jsxs("section",{className:Z(K>0&&"border-t border-border/70"),children:[t.jsx(In,{actionsWidth:96,revealed:q===`project:${p.project.id}`,onRevealedChange:ce=>Mt(`project:${p.project.id}`,ce),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:q===`project:${p.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-primary","aria-label":r("mobile.sessions.editProjectAria",{label:p.project.label}),onClick:()=>{G(null),O(p.project.id)},style:{touchAction:"manipulation"},children:t.jsx(us,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:q===`project:${p.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",F===p.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":F===p.project.id?r("mobile.sessions.confirmRemoveProjectAria",{label:p.project.label}):r("mobile.sessions.removeProjectAria",{label:p.project.label}),onClick:()=>{if(F===p.project.id){G(null),Q(null),D(p.project.id),ue.success(r("mobile.sessions.toast.projectRemoved",{label:p.project.label}));return}Q(p.project.id)},style:{touchAction:"manipulation"},children:t.jsx(Gt,{className:"size-[18px]"})})]}),children:t.jsxs("div",{"data-active-project":p.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-primary focus-visible:ring-inset",onClick:()=>{if(q){Mt(q,!1);return}Wr(p.project.id,Y)},"aria-expanded":Y,"aria-label":Y?r("sessions.sidebar.group.collapseAria",{label:p.project.label}):r("sessions.sidebar.group.expandAria",{label:p.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(hs,{project:p.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:p.project.label}),p.isActive?t.jsx(Pn,{ariaLabel:r("mobile.sessions.activeProjectAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:p.totalSessions})]}),p.project.isGitRepo?t.jsx(Tn,{className:"mr-2",onClick:()=>Js(p.project.id)}):null]})}),Y?t.jsx("div",{className:"pb-2",children:(()=>{const ce=ne.find(ge=>ge.worktree===null),Ee=ne.filter(ge=>ge.worktree!==null);return t.jsxs(t.Fragment,{children:[ce&&ce.sessions.length>0?qs(p,ce,Rn):null,Ee.map(ge=>{const De=Br(p,ge),st=we===ge.path;return t.jsxs("div",{children:[t.jsx(In,{actionsWidth:48,revealed:q===`wt:${ge.key}`,onRevealedChange:Zt=>Mt(`wt:${ge.key}`,Zt),actions:t.jsx("button",{type:"button",tabIndex:q===`wt:${ge.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:ge.label}),onClick:()=>{G(null),ge.worktree&&ae({project:p.project,worktree:ge.worktree})},style:{touchAction:"manipulation"},children:t.jsx(Gt,{className:"size-[18px]"})}),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-primary focus-visible:ring-inset",onClick:()=>{if(q){Mt(q,!1);return}Ur(p.project.id,ge.key,De)},"aria-expanded":De,"aria-label":De?r("sessions.sidebar.group.collapseAria",{label:ge.label}):r("sessions.sidebar.group.expandAria",{label:ge.label}),style:{touchAction:"manipulation"},children:[t.jsx(se,{name:"git-branch",className:Z("size-4 shrink-0",st?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Z("block min-w-0 flex-1 truncate typography-ui-label font-bold",st?"text-foreground":"text-muted-foreground"),children:ge.label}),st?t.jsx(Pn,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:ge.sessions.length})]})}),De?qs(p,ge,Rn):null]},ge.key)})]})})()}):null]},p.project.id)})})]}),o?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:[o.instanceLabel&&o.onOpenInstances?t.jsxs(xe,{type:"button",variant:"info",size:"lg",className:"min-w-0 shrink justify-start",onClick:o.onOpenInstances,"aria-label":r("mobile.menu.instances"),style:{touchAction:"manipulation"},children:[t.jsx(se,{name:"server",className:"size-[18px]"}),t.jsx("span",{className:"block min-w-0 truncate",children:o.instanceLabel})]}):t.jsx("div",{className:"min-w-0 flex-1"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[o.onOpenUpdate?t.jsxs(xe,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:o.onOpenUpdate,"aria-label":r("mobile.menu.update"),title:r("mobile.menu.update"),style:{touchAction:"manipulation"},children:[t.jsx(se,{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(xe,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:o.onOpenSettings,"aria-label":r("mobile.menu.settings"),title:r("mobile.menu.settings"),style:{touchAction:"manipulation"},children:t.jsx(se,{name:"settings-3",className:"size-5"})})]})]}):null,t.jsx(Ri,{open:W,onOpenChange:ie}),t.jsx(Pi,{open:U,onOpenChange:p=>{fe(p),p||ke(null)},onWorktreeCreated:(p,K)=>{K?.sessionId?x(K.sessionId,p):j({selectedProjectId:Ne,directoryOverride:p,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(Sl,{open:A!==null,project:be.find(p=>p.id===A)??null,onClose:()=>O(null),onWorktreesChanged:()=>oe(p=>p+1)}),te?t.jsx(Ar,{open:!0,project:{id:te.project.id,path:te.project.path},worktree:te.worktree,onClose:()=>ae(null),onDeleted:()=>oe(p=>p+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")}),Lt?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:Lt}):null]}),en]}):null:t.jsxs(Ol,{open:n,onClose:()=>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-primary","aria-label":r("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(se,{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")}),Lt?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:Lt}):null]}),en]})},Dn="mobile-surface-root",Ml=16,Mn=320,zl="cubic-bezier(0.22, 1, 0.36, 1)",Ol=({open:n,onClose:e,ariaLabel:s,children:o})=>{const r=l.useRef(null),[i,a]=l.useState(!1),[c,d]=l.useState(n),f=l.useRef(e);if(l.useEffect(()=>{f.current=e},[e]),typeof document<"u"&&!r.current){let u=document.getElementById(Dn);u||(u=document.createElement("div"),u.id=Dn,document.body.appendChild(u)),r.current=u}return l.useEffect(()=>{if(n){d(!0);const m=window.setTimeout(()=>a(!0),Ml);return()=>window.clearTimeout(m)}a(!1);const u=window.setTimeout(()=>d(!1),Mn+40);return()=>window.clearTimeout(u)},[n]),l.useEffect(()=>{if(!n)return;const u=document.body.style.overflow;document.body.style.overflow="hidden";const m=g=>{g.key==="Escape"&&f.current()};return document.addEventListener("keydown",m),()=>{document.body.style.overflow=u,document.removeEventListener("keydown",m)}},[n]),r.current?ut.createPortal(t.jsx("section",{role:"dialog","aria-modal":"true","aria-label":s,"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:i?"none":"translateX(-100%)",transition:`transform ${Mn}ms ${zl}`,visibility:c?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:o})}),r.current):null},zn=n=>{const e=de.c(10),{title:s,description:o,action:r}=n;let i;e[0]!==s?(i=t.jsx("p",{className:"typography-ui-label text-foreground",children:s}),e[0]=s,e[1]=i):i=e[1];let a;e[2]!==o?(a=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[2]=o,e[3]=a):a=e[3];let c;e[4]!==r?(c=r?t.jsx("div",{className:"pt-2",children:r}):null,e[4]=r,e[5]=c):c=e[5];let d;return e[6]!==i||e[7]!==a||e[8]!==c?(d=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[i,a,c]}),e[6]=i,e[7]=a,e[8]=c,e[9]=d):d=e[9],d};function Ll(n){return Se(n.path)}function Bl(n){return Se(n.path)}function $l(n){return t.jsx(_l,{worktree:n},Se(n.path))}const Fl=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),Wl=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},Ul=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},On=(n,e)=>e?`${n}\0staged`:n,Vl=({onClose:n,initialDiffPath:e,initialDiffStaged:s=!1})=>{const{t:o}=me(),{git:r}=js(),i=Fl(Ss()??null),a=Mo(i||null),c=zo(i||null),d=Oo(i||null),f=We(L=>L.setActiveDirectory),u=We(L=>L.ensureAll),m=We(L=>L.fetchStatus),g=We(L=>L.fetchBranches),h=We(L=>L.prefetchDiffs),x=We(L=>L.getDiff),w=We(L=>L.setDiff),[b,P]=l.useState(()=>e?{type:"diff",path:e,staged:s}:{type:"list"});l.useEffect(()=>{e&&P(L=>L.type==="diff"&&L.path===e&&L.staged===s?L:{type:"diff",path:e,staged:s})},[e,s]);const[j,C]=l.useState(null),[R,T]=l.useState(null),[D,k]=l.useState(""),[E,y]=l.useState(new Set),[I,M]=l.useState(!1),[N,S]=l.useState(!1),[H,$]=l.useState([]),[v,A]=l.useState([]),[O,z]=l.useState([]),[B,ee]=l.useState(null),[X,_]=l.useState(null),[J,q]=l.useState(0),G=l.useMemo(()=>{const L=a?.files??[],V=new Map;for(const re of L)V.set(re.path,re);return Array.from(V.values()).sort((re,le)=>re.path.localeCompare(le.path))},[a?.files]),F=l.useMemo(()=>G.filter(Wl),[G]),Q=l.useMemo(()=>G.filter(Ul),[G]),te=l.useMemo(()=>{if(O.length>0)return O;const L=a?.tracking?.includes("/")?a.tracking.split("/")[0]:null;return L||B?[{name:L||"origin",fetchUrl:B??"",pushUrl:B??""}]:[]},[B,O,a?.tracking]),ae=We(l.useCallback(L=>!i||b.type!=="diff"?null:L.directories.get(i)?.diffCache.get(On(b.path,b.staged))??null,[i,b])),pe=l.useMemo(()=>b.type!=="diff"?null:G.find(L=>L.path===b.path)??null,[G,b]),oe=l.useCallback(async(L=!0)=>{if(i)try{await Promise.all([m(i,r),g(i,r)])}catch(V){L&&ue.error(V instanceof Error?V.message:o("gitView.toast.refreshRepositoryFailed"))}},[i,g,m,r,o]),W=l.useCallback(async()=>{if(!i){z([]),ee(null);return}try{const[L,V]=await Promise.all([r.getRemotes(i).catch(()=>[]),r.getRemoteUrl?r.getRemoteUrl(i).catch(()=>null):Promise.resolve(null)]);z(L),ee(V)}catch{z([]),ee(null)}},[i,r]);l.useEffect(()=>{i&&(f(i),u(i,r))},[i,u,r,f]),l.useEffect(()=>{W()},[W]),l.useEffect(()=>{if(!i||G.length===0)return;const L=Array.from(new Set([...F.map(re=>re.path),...v,...G.slice(0,20).map(re=>re.path)])).filter(Boolean);if(L.length===0)return;const V=window.setTimeout(()=>{h(i,r,L,{maxFiles:40})},120);return()=>window.clearTimeout(V)},[G,i,r,h,F,v]),l.useEffect(()=>{if(b.type!=="diff"){_(null);return}const L=On(b.path,b.staged);if(!i||x(i,L)){_(null);return}let V=!1;const re=bt();return _(null),r.getGitFileDiff(i,{path:b.path,staged:b.staged||void 0}).then(le=>{V||w(i,L,{original:le.original??"",modified:le.modified??"",isBinary:le.isBinary},re)}).catch(le=>{V||_(le instanceof Error?le.message:String(le))}),()=>{V=!0}},[i,J,x,r,b,w]);const ie=async(L,V)=>{if(i){C(L);try{const re=le=>{const Ce=`${le.name}/`,be=a?.tracking?.startsWith(Ce)?a.tracking.slice(Ce.length):void 0;return{remote:le.name,branch:be,rebase:!0}};if(L==="fetch"){if(!V)throw new Error(o("mobile.changes.noRemote"));await r.gitFetch(i,{remote:V.name}),ue.success(o("gitView.toast.fetchedFromRemote",{name:V.name}))}else if(L==="sync"){if(!V)throw new Error(o("mobile.changes.noRemote"));await r.gitFetch(i,{remote:V.name});const le=await r.getGitStatus(i);if((le.behind??0)>0){if((le.files?.length??0)>0){ue.error(o("gitView.toast.commitOrStashBeforeSync"));return}await r.gitPull(i,re(V))}((await r.getGitStatus(i)).ahead??0)>0&&await r.gitPush(i),ue.success(o("gitView.toast.alreadyUpToDate"))}await oe(!1),await W()}catch(re){ue.error(re instanceof Error?re.message:o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}))}finally{C(null)}}},U=l.useCallback(async(L,V)=>{if(!(!i||L.length===0))try{V==="stage"?L.length>1?await Lo(i,L):await Bo(i,L[0]):L.length>1?await $o(i,L):await Fo(i,L[0]),await oe(!1)}catch(re){ue.error(re instanceof Error?re.message:o(V==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[i,oe,o]),fe=l.useCallback((L,V=!1)=>{P({type:"diff",path:L,staged:V})},[]),Ne=l.useCallback(async L=>{if(i){y(V=>new Set(V).add(L));try{await r.revertGitFile(i,L),ue.success(o("gitView.toast.revertedFile",{path:L})),await oe(!1)}catch(V){ue.error(V instanceof Error?V.message:o("gitView.toast.revertFailed"))}finally{y(V=>{const re=new Set(V);return re.delete(L),re})}}},[i,r,oe,o]),ke=l.useCallback(async L=>{if(!i||L.length===0||I)return;const V=Array.from(new Set(L));M(!0),y(new Set(V));try{await Promise.all(V.map(re=>r.revertGitFile(i,re))),await oe(!1),ue.success(V.length===1?o("gitView.toast.revertedFilesSingle",{count:V.length}):o("gitView.toast.revertedFilesPlural",{count:V.length}))}catch(re){ue.error(re instanceof Error?re.message:o("gitView.toast.revertFailed"))}finally{y(new Set),M(!1)}},[i,r,I,oe,o]),Ie=l.useCallback(L=>{const V=L.map(re=>re.trim()).filter(Boolean);if(V.length===0){$([]);return}k(re=>`${re.trim()}${re.trim()?`
22
+ `}),e[47]=q):q=e[47];let G;return e[48]!==J?(G=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:[J,q]}),e[48]=J,e[49]=G):G=e[49],G};function fl(n){return n.currentSessionId}function ml(n){return n.setCurrentSession}function pl(n){return n.setActiveProjectIdOnly}const hl=n=>{const e=de.c(71),{onOpenSessions:s,onOpenWorkspace:o,compactTitle:r}=n,i=r===void 0?!1:r,{t:a}=me(),[c,d]=l.useState(!1),[f,u]=l.useState(!1),m=l.useRef(null),g=ft(gl),h=je(bl);let x;e[0]!==h?(x=Ae=>h?Ae.getDirectoryForSession(h):null,e[0]=h,e[1]=x):x=e[1];const b=je(x)||g,P=Ro(h,b||void 0),j=je(xl);let C;e[2]!==P?.title?(C=P?.title?.trim(),e[2]=P?.title,e[3]=C):C=e[3];const R=C;let T;e[4]!==h||e[5]!==R||e[6]!==a?(T=R||a(h?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[4]=h,e[5]=R,e[6]=a,e[7]=T):T=e[7];const D=T;let k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{d(!1),u(!1)},e[8]=k):k=e[8];let E;e[9]!==h||e[10]!==b?(E=[h,b],e[9]=h,e[10]=b,e[11]=E):E=e[11],l.useEffect(k,E);let y;e[12]!==s?(y=()=>{d(!1),u(!1),s()},e[12]=s,e[13]=y):y=e[13];const I=y;let M;e[14]===Symbol.for("react.memo_cache_sentinel")?(M=Ae=>{d(_e=>{const ve=typeof Ae=="function"?Ae(_e):Ae;return ve&&u(!1),ve})},e[14]=M):M=e[14];const N=M;let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{u(Ae=>{const _e=!Ae;return _e&&d(!1),_e})},e[15]=S):S=e[15];const H=S;let $;e[16]===Symbol.for("react.memo_cache_sentinel")?($={paddingTop:"var(--oc-safe-area-top, 0px)"},e[16]=$):$=e[16];let v;e[17]!==a?(v=a("mobile.sessions.openSheetAria"),e[17]=a,e[18]=v):v=e[18];let A,O;e[19]===Symbol.for("react.memo_cache_sentinel")?(A={touchAction:"manipulation"},O=t.jsx(se,{name:"list-unordered",className:"size-5"}),e[19]=A,e[20]=O):(A=e[19],O=e[20]);let z;e[21]!==I||e[22]!==v?(z=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-primary","aria-label":v,onClick:I,style:A,children:O}),e[21]=I,e[22]=v,e[23]=z):z=e[23];const L=i?"shrink":"flex-1";let ee;e[24]!==L?(ee=Z("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",L),e[24]=L,e[25]=ee):ee=e[25];let X;e[26]!==a?(X=a("sessions.switcher.openAria"),e[26]=a,e[27]=X):X=e[27];let _;e[28]===Symbol.for("react.memo_cache_sentinel")?(_={touchAction:"manipulation"},e[28]=_):_=e[28];let J;e[29]!==D?(J=t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:D}),e[29]=D,e[30]=J):J=e[30];const q=f&&"rotate-180";let G;e[31]!==q?(G=Z("size-4 shrink-0 text-muted-foreground transition-transform duration-150",q),e[31]=q,e[32]=G):G=e[32];let F;e[33]!==G?(F=t.jsx(se,{name:"arrow-down-s",className:G}),e[33]=G,e[34]=F):F=e[34];let Q;e[35]!==J||e[36]!==F?(Q=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[J,F]}),e[35]=J,e[36]=F,e[37]=Q):Q=e[37];let te;e[38]!==f||e[39]!==ee||e[40]!==X||e[41]!==Q?(te=t.jsx("button",{ref:m,type:"button",className:ee,"aria-label":X,"aria-haspopup":"dialog","aria-expanded":f,onClick:H,style:_,children:Q}),e[38]=f,e[39]=ee,e[40]=X,e[41]=Q,e[42]=te):te=e[42];let ae;e[43]!==i?(ae=i?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[43]=i,e[44]=ae):ae=e[44];let pe;e[45]!==h||e[46]!==b||e[47]!==j||e[48]!==c?(pe=t.jsx(al,{open:c,onOpenChange:N,currentSessionId:h,effectiveDirectory:b,isNewSessionDraftOpen:j}),e[45]=h,e[46]=b,e[47]=j,e[48]=c,e[49]=pe):pe=e[49];let oe;e[50]!==a?(oe=a("mobile.header.openWorkspaceAria"),e[50]=a,e[51]=oe):oe=e[51];let W;e[52]!==o?(W=()=>{d(!1),u(!1),o()},e[52]=o,e[53]=W):W=e[53];let ie,U;e[54]===Symbol.for("react.memo_cache_sentinel")?(ie={touchAction:"manipulation"},U=t.jsx(se,{name:"pencil-ruler-2",className:"size-5"}),e[54]=ie,e[55]=U):(ie=e[54],U=e[55]);let fe;e[56]!==oe||e[57]!==W?(fe=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-primary","aria-label":oe,onClick:W,style:ie,children:U}),e[56]=oe,e[57]=W,e[58]=fe):fe=e[58];let Ne;e[59]!==z||e[60]!==te||e[61]!==ae||e[62]!==pe||e[63]!==fe?(Ne=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:$,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[z,te,ae,pe,fe]})}),e[59]=z,e[60]=te,e[61]=ae,e[62]=pe,e[63]=fe,e[64]=Ne):Ne=e[64];let ke;e[65]===Symbol.for("react.memo_cache_sentinel")?(ke=()=>u(!1),e[65]=ke):ke=e[65];let Ie;e[66]!==f?(Ie=t.jsx(dl,{open:f,onClose:ke,anchorRef:m}),e[66]=f,e[67]=Ie):Ie=e[67];let Be;return e[68]!==Ne||e[69]!==Ie?(Be=t.jsxs(t.Fragment,{children:[Ne,Ie]}),e[68]=Ne,e[69]=Ie,e[70]=Be):Be=e[70],Be};function gl(n){return n.currentDirectory}function bl(n){return n.currentSessionId}function xl(n){return!!n.newSessionDraft?.open}const yl=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=me(),o=kr(e),{connections:r,isBusy:i,isPasswordBusy:a,error:c,pendingConnection:d,connect:f,submitPassword:u,cancelPassword:m,saveConnection:g,removeConnection:h,setError:x}=o,[w,b]=l.useState(null),P=w?r.find(W=>W.id===w)??null:null,[j,C]=l.useState(null),[R,T]=l.useState(""),[D,k]=l.useState(""),[E,y]=l.useState(""),[I,M]=l.useState(""),[N,S]=l.useState(!1),[H,$]=l.useState(!1),v=l.useRef(null),A=l.useMemo(()=>fs(),[]),[O,z]=l.useState(!1),[L,ee]=l.useState(null),[X,_]=l.useState(!1),J=mr(l.useCallback(()=>_(!0),[])),q=l.useCallback(()=>{b(null),T(""),k(""),y(""),x(null),z(!1)},[x]),G=l.useCallback(W=>{W.preventDefault(),g({id:w??void 0,url:R,label:D,clientToken:E}).then(ie=>{ie&&q()})},[E,w,D,q,g,R]),F=l.useCallback(async()=>{if(v.current)return;x(null),S(!0);const W=new AbortController;v.current=W;try{const ie=await Rr({signal:W.signal});switch(v.current===W&&(v.current=null,S(!1)),ie.status){case"ok":T(ie.url),ie.label&&k(ie.label),ie.clientToken&&y(ie.clientToken),z(!0);break;case"pairing":$(!0),await o.redeemPairingConnection(ie.pairing);break;case"permission-denied":x(s("mobile.connect.scan.permissionDenied"));break;case"invalid":x(s("mobile.connect.scan.invalid"));break;case"unsupported":x(s("mobile.connect.scan.unsupported"));break;case"failed":x(s("mobile.connect.scan.failed"));break;default:break}}finally{$(!1),v.current===W&&(v.current=null,S(!1))}},[o,x,s]);l.useEffect(()=>()=>v.current?.abort(),[]);const Q=l.useCallback(W=>{W.preventDefault(),u(I)},[I,u]),te=l.useCallback(()=>{M(""),m()},[m]),ae=l.useCallback(W=>{C(ie=>ie===W?null:W)},[]),pe=l.useCallback(W=>{C(null),w===W&&q();const ie=r.length===1;h(W).then(U=>{U&&(ie||wn(U))&&n()})},[r.length,w,n,h,q]),oe=Ct;return d?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:Q,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(se,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:d.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:d.candidates.some(W=>W.kind==="direct")?Ge(d):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...ut,value:I,onChange:W=>M(W.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:oe}),c?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:c}):null,t.jsx(xe,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!I.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(xe,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:te,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[N?t.jsx(Pr,{onCancel:()=>v.current?.abort()}):null,H?t.jsx(Tr,{}):null,X?t.jsx(Sr,{onClose:()=>_(!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",{...J,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(W=>{const ie=j===W.id,U=wn(W),fe=L===W.id,Ne=fe?s("mobile.connect.connecting"):U?At()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):W.candidates.some(ke=>ke.kind==="direct")?Ge(W):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",ie&&"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-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-60",onClick:()=>{U||(ee(W.id),f({id:W.id,candidates:W.candidates,clientToken:W.clientToken,label:W.label}).finally(()=>ee(null)))},disabled:i&&!fe||ie,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(se,{name:"server",className:"size-[18px]"}),U?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:W.label}),t.jsx("span",{className:Z("block truncate typography-small",U&&!fe?"text-[var(--status-success)]":"text-muted-foreground"),children:Ne})]}),fe?t.jsx(se,{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:[ie?t.jsxs("button",{type:"button","aria-label":s("mobile.instances.confirmDeleteAria",{label:W.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:()=>pe(W.id),style:{touchAction:"manipulation"},children:[t.jsx(se,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:s("mobile.instances.delete")})]}):W.candidates.some(ke=>ke.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-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>{b(W.id),T(Ge(W)),k(W.label),y(W.clientToken||""),x(null)},style:{touchAction:"manipulation"},children:t.jsx(se,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":ie?s("mobile.instances.cancelDeleteAria",{label:W.label}):s("mobile.instances.deleteAria",{label:W.label}),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>ae(W.id),style:{touchAction:"manipulation"},children:t.jsx(se,{name:ie?"close":"delete-bin",className:"size-[18px]"})})]})]},W.id)})}):t.jsx("p",{...J,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")}),!O&&!P?t.jsxs("div",{className:"space-y-2",children:[A?t.jsxs(xe,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{F()},disabled:N,children:[t.jsx(se,{name:"scan-2",className:Z("size-[18px]",N&&"animate-pulse")}),s("mobile.connect.scanQr")]}):null,t.jsxs(xe,{type:"button",variant:A?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{x(null),z(!0)},children:[t.jsx(se,{name:"add",className:"size-[18px]"}),s("mobile.instances.addManual")]}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:G,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(P?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(xe,{type:"button",variant:"ghost",size:"xs",onClick:q,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",{...ut,value:R,onChange:W=>T(W.target.value),placeholder:s("mobile.connect.url.placeholder"),type:"url",inputMode:"url",autoCapitalize:"none",className:oe})]}),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:D,onChange:W=>k(W.target.value),placeholder:s("mobile.instances.label.placeholder"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,className:oe})]}),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",{...ut,value:E,onChange:W=>y(W.target.value),placeholder:s("mobile.connect.token.placeholder"),autoCapitalize:"none",className:oe}),t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")})]}),c?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:c}):null,t.jsx(xe,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(P?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},Se=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),ns=n=>{const e=Se(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},Nn=Os(n=>({expandedParents:{},toggleParent:e=>n(s=>{const o={...s.expandedParents};return o[e]?delete o[e]:o[e]=!0,{expandedParents:o}})})),Bt=Os()(ur(n=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,s)=>n(o=>({projectExpanded:{...o.projectExpanded,[e]:s}})),setWorktreeExpanded:(e,s)=>n(o=>({worktreeExpanded:{...o.worktreeExpanded,[e]:s}}))}),{name:"mobile-session-tree"})),ms=Os()(ur(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(o=>({orderByProject:{...o.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),Cn=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),vl=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((r,i)=>[Cn(r),i])),o=r=>s.get(Cn(r.path))??Number.MAX_SAFE_INTEGER;return e.map((r,i)=>({worktree:r,index:i})).sort((r,i)=>{const a=o(r.worktree)-o(i.worktree);return a!==0?a:r.index-i.index}).map(r=>r.worktree)},Et=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),wl=n=>{const e=n;return Et(e.directory??e.project?.worktree??null)},Ar=({open:n,project:e,worktree:s,onClose:o,onDeleted:r})=>{const{t:i}=me(),a=Qn(),c=bs(y=>y.activeSessions),d=je(y=>y.archiveSessions),f=ft(y=>y.currentDirectory),[u,m]=l.useState(!1),[g,h]=l.useState(!1),[x,w]=l.useState(!1),[b,P]=l.useState(!1),j=Et(s?.path),C=typeof s?.branch=="string"&&s.branch.trim().length>0,R=l.useMemo(()=>{if(!j)return[];const y=new Map;for(const I of[...c,...a])wl(I)===j&&y.set(I.id,I);return Array.from(y.values())},[c,a,j]);l.useEffect(()=>{if(!n){m(!1),h(!1),w(!1),P(!1);return}if(!s?.path)return;let y=!1;return Po(s.path).then(I=>{y||w(!!I?.isDirty)}).catch(()=>{y||w(!!s.status?.isDirty)}),()=>{y=!0}},[n,s?.path,s?.status?.isDirty]);const T=l.useCallback(y=>{(async()=>{try{await To(e,y,{deleteRemoteBranch:C&&g,deleteLocalBranch:C&&u}),Et(f)===j&&Et(e.path)&&ft.getState().setDirectory(Et(e.path),{showOverlay:!1}),ue.success(i("sessions.sidebar.sessionDialogs.worktree.removedTitle"),{description:i(C&&g?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),r?.()}catch(I){ue.error(i("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:I instanceof Error?I.message:i("sessions.sidebar.dialogs.deleteResult.tryAgain")})}})()},[f,u,g,C,r,e,i,j]),D=async()=>{if(!(!s||b)){P(!0);try{if(R.length>0){const{archivedIds:y,failedIds:I}=await d(R.map(M=>M.id));if(I.length>0){y.length>0&&ue.success(y.length===1?i("sessions.sidebar.bulkActions.archivedSingle",{count:y.length}):i("sessions.sidebar.bulkActions.archivedPlural",{count:y.length})),ue.error(I.length===1?i("sessions.sidebar.bulkActions.failedArchiveSingle",{count:I.length}):i("sessions.sidebar.bulkActions.failedArchivePlural",{count:I.length}),{description:i("sessions.sidebar.dialogs.deleteResult.tryAgain")}),P(!1);return}}T(s),o()}catch(y){ue.error(i("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:y instanceof Error?y.message:i("sessions.sidebar.dialogs.deleteResult.tryAgain")}),P(!1)}finally{n||P(!1)}}};if(!s)return null;const k=s.branch||s.label||s.path,E=(y,I,M,N)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":y,disabled:N,onClick:()=>I(!y),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-primary",N&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:M}),t.jsx("span",{className:Z("relative h-6 w-10 shrink-0 rounded-full transition-colors",y?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:Z("absolute top-0.5 size-5 rounded-full bg-white transition-transform",y?"translate-x-[1.125rem]":"translate-x-0.5")})})]});return t.jsx(Io,{open:n,onClose:o,title:i("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(xe,{variant:"ghost",className:"flex-1",onClick:o,disabled:b,children:i("projectEditDialog.actions.cancel")}),t.jsx(xe,{variant:"destructive",className:"flex-1",onClick:()=>{D()},disabled:b,children:i("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:i("mobile.projectEdit.deleteWorktreeConfirm",{name:k})}),x?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:i("mobile.projectEdit.deleteWorktreeDirty")}):null,R.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i("mobile.projectEdit.deleteWorktreeArchiveNote",{count:R.length})}):null,C?t.jsxs("div",{className:"flex flex-col gap-2",children:[E(u,m,i("mobile.projectEdit.deleteLocalBranch"),b),E(g,h,i("mobile.projectEdit.deleteRemoteBranch"),b)]}):null]})})},En="mobile-surface-root",rs=16,$t=200,jl=()=>{if(typeof document>"u")return null;let n=document.getElementById(En);return n||(n=document.createElement("div"),n.id=En,document.body.appendChild(n)),n},Rt=({open:n,onClose:e,title:s,subtitle:o,trailing:r,disableEscapeDismiss:i=!1,headerless:a=!1,noHeaderBorder:c=!1,ariaLabel:d,variant:f="fullscreen",dialogAlign:u="chat",children:m})=>{const{t:g}=me(),h=l.useRef(null),[x,w]=l.useState(!1),[b,P]=l.useState(!1),j=l.useRef(null),C=l.useRef(null),R=l.useRef(e);if(l.useEffect(()=>{R.current=e},[e]),typeof document<"u"&&!h.current&&(h.current=jl()),l.useEffect(()=>{if(!n){w(!1);return}const k=window.setTimeout(()=>w(!0),rs);return()=>window.clearTimeout(k)},[n]),l.useEffect(()=>{if(!n){P(!1);return}const k=window.setTimeout(()=>P(!0),rs+$t+80);return()=>window.clearTimeout(k)},[n]),l.useEffect(()=>{if(!n)return;const k=document.body.style.overflow;C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const E=()=>{const M=j.current;if(!M)return;(M.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??M).focus({preventScroll:!0})},y=window.setTimeout(E,rs),I=M=>{if(M.key==="Escape"&&!i){R.current();return}if(M.key!=="Tab")return;const N=j.current;if(!N)return;const S=Array.from(N.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(A=>!A.hasAttribute("disabled")&&A.getAttribute("aria-hidden")!=="true");if(S.length===0){M.preventDefault(),N.focus({preventScroll:!0});return}const H=S[0],$=S[S.length-1],v=document.activeElement;M.shiftKey&&v===H?(M.preventDefault(),$.focus({preventScroll:!0})):!M.shiftKey&&v===$&&(M.preventDefault(),H.focus({preventScroll:!0}))};return document.addEventListener("keydown",I),()=>{window.clearTimeout(y),document.body.style.overflow=k,document.removeEventListener("keydown",I),C.current?.focus?.({preventScroll:!0}),C.current=null}},[i,n]),!n||!h.current)return null;const T=f==="dialog",D=t.jsxs("section",{ref:j,role:"dialog","aria-modal":"true","aria-label":d,tabIndex:-1,className:Z("flex flex-col bg-background text-foreground",T?"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 fixed inset-0 z-50"),style:T?{opacity:x?1:0,transform:x?"none":"scale(0.97)",transition:`opacity ${$t}ms ease-out, transform ${$t}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:x?"none":"translateX(100%)",transition:`transform ${$t}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:k=>{x&&k.target===k.currentTarget&&k.propertyName==="transform"&&P(!0)},children:[a?null:t.jsxs("header",{className:Z("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!c&&"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-primary","aria-label":g("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(se,{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,o?typeof o=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:o}):o: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:b?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:m}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return T?dt.createPortal(t.jsx("div",{className:"oc-keyboard-inset-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:x?1:0,paddingLeft:u==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:u==="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:k=>k.stopPropagation(),children:D})}),h.current):dt.createPortal(D,h.current)},kl=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),Sl=n=>{const e=de.c(36),{worktree:s,onDelete:o}=n,{t:r}=me();let i;e[0]!==s.path?(i={id:s.path},e[0]=s.path,e[1]=i):i=e[1];const{attributes:a,listeners:c,setNodeRef:d,transform:f,transition:u,isDragging:m}=Ms(i);let g;e[2]!==f?(g=zs.Transform.toString(f),e[2]=f,e[3]=g):g=e[3];const h=m?10:1;let x;e[4]!==g||e[5]!==h||e[6]!==u?(x={transform:g,transition:u,zIndex:h},e[4]=g,e[5]=h,e[6]=u,e[7]=x):x=e[7];const w=x,b=s.branch||s.label||s.path,P=m&&"shadow-lg shadow-black/20";let j;e[8]!==P?(j=Z("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",P),e[8]=P,e[9]=j):j=e[9];let C;e[10]!==b||e[11]!==r?(C=r("mobile.projectEdit.dragWorktreeAria",{label:b}),e[10]=b,e[11]=r,e[12]=C):C=e[12];let R;e[13]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(Ns,{className:"size-4"}),e[13]=R):R=e[13];let T;e[14]!==a||e[15]!==c||e[16]!==C?(T=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,...c,children:R}),e[14]=a,e[15]=c,e[16]=C,e[17]=T):T=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(se,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[18]=D):D=e[18];let k;e[19]!==b?(k=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:b}),e[19]=b,e[20]=k):k=e[20];let E;e[21]!==b||e[22]!==r?(E=r("mobile.projectEdit.deleteWorktreeAria",{label:b}),e[21]=b,e[22]=r,e[23]=E):E=e[23];let y,I;e[24]===Symbol.for("react.memo_cache_sentinel")?(y={touchAction:"manipulation"},I=t.jsx(Gt,{className:"size-4"}),e[24]=y,e[25]=I):(y=e[24],I=e[25]);let M;e[26]!==o||e[27]!==E?(M=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":E,onClick:o,style:y,children:I}),e[26]=o,e[27]=E,e[28]=M):M=e[28];let N;return e[29]!==d||e[30]!==w||e[31]!==k||e[32]!==M||e[33]!==j||e[34]!==T?(N=t.jsxs("div",{ref:d,style:w,className:j,children:[T,D,k,M]}),e[29]=d,e[30]=w,e[31]=k,e[32]=M,e[33]=j,e[34]=T,e[35]=N):N=e[35],N},Nl=({open:n,project:e,onClose:s,onWorktreesChanged:o})=>{const{t:r}=me(),{currentTheme:i}=Zn(),a=Oe(v=>v.updateProjectMeta),c=Oe(v=>v.discoverProjectIcon),d=Oe(v=>v.removeProjectIcon),f=ms(v=>v.setWorktreeOrder),u=Oe(v=>e?v.projects.find(A=>A.id===e.id)?.iconImage??null:null),[m,g]=l.useState(""),[h,x]=l.useState(null),[w,b]=l.useState(null),[P,j]=l.useState(!1),[C,R]=l.useState([]),[T,D]=l.useState(null),k=e?.id??null;l.useEffect(()=>{!n||!e||(g(e.label),x(e.icon??null),b(e.color??null),R(e.worktrees))},[n,k]),l.useEffect(()=>{!n||!e||R(v=>{const A=e.worktrees.map(L=>L.path),O=v.map(L=>L.path);return A.length===O.length&&A.every(L=>O.includes(L))?v:e.worktrees})},[e?.worktrees]);const E=Es(pt(Ps,{activationConstraint:{distance:8}}),pt(Rs,{coordinateGetter:As})),y=()=>{if(!e)return;const v=m.trim();a(e.id,{label:v||e.label,icon:h,color:w}),s()},I=()=>{!e||P||(j(!0),c(e.id).then(v=>{if(!v.ok){ue.error(v.error||r("projectEditDialog.toast.failedToDiscoverIcon"));return}if(v.skipped){ue.success(r("projectEditDialog.toast.customIconAlreadySet"));return}ue.success(r("projectEditDialog.toast.iconDiscovered"))}).finally(()=>j(!1)))},M=()=>{e&&d(e.id).then(v=>{if(!v.ok){ue.error(v.error||r("projectEditDialog.toast.failedToRemoveIcon"));return}ue.success(r("projectEditDialog.toast.iconRemoved"))})},N=v=>{const{active:A,over:O}=v;if(!O||A.id===O.id||!e)return;const z=C.findIndex(_=>_.path===A.id),L=C.findIndex(_=>_.path===O.id);if(z<0||L<0)return;const ee=[...C],[X]=ee.splice(z,1);ee.splice(L,0,X),R(ee),f(e.id,ee.map(_=>kl(_.path)))},S=w?er[w]??null:null,H=h?tr[h]:null,$=!!u;return t.jsxs(t.Fragment,{children:[t.jsx(Rt,{open:n,onClose:s,title:r("projectEditDialog.title"),ariaLabel:r("projectEditDialog.title"),noHeaderBorder:!0,trailing:t.jsxs(xe,{type:"button",variant:"default",size:"sm","aria-label":r("projectEditDialog.actions.save"),onClick:y,disabled:!m.trim(),style:{touchAction:"manipulation"},children:[t.jsx(ar,{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:$?t.jsx(sr,{project:{id:e.id,iconImage:u},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(cs,{className:"size-7"})}):H?t.jsx(se,{name:H,className:"size-7",style:S?{color:S}:void 0}):t.jsx(cs,{className:"size-7",style:S?{color:S}: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(ws,{value:m,onChange:v=>g(v.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:()=>b(null),"aria-label":r("projectEditDialog.option.none"),className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",w===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"})}),Ao.map(v=>t.jsx("button",{type:"button",onClick:()=>b(v.key),"aria-label":v.label,title:v.label,className:Z("size-9 rounded-xl border-2 transition-all",w===v.key?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:v.cssVar,touchAction:"manipulation"}},v.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:()=>x(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"})}),_o.map(v=>t.jsx("button",{type:"button",onClick:()=>x(v.key),"aria-label":v.label,title:v.label,className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===v.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(se,{name:v.Icon,className:"size-4",style:S?{color:S}:void 0})},v.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(xe,{size:"sm",variant:"outline",onClick:I,disabled:P,children:r(P?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),$?t.jsx(xe,{size:"sm",variant:"outline",onClick:M,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(Ts,{sensors:E,collisionDetection:Is,onDragEnd:N,children:t.jsx(_s,{items:C.map(v=>v.path),strategy:Ds,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:C.map(v=>t.jsx(Sl,{worktree:v,onDelete:()=>D(v)},v.path))})})})]})]}):null]}):null}),e?t.jsx(Ar,{open:!!T,project:{id:e.id,path:e.path},worktree:T,onClose:()=>D(null),onDeleted:()=>{R(v=>v.filter(A=>A.path!==T?.path)),o?.()}}):null]})},Cl=new Set,os=7,Rn=40,El=16,St=n=>n.parentID??null,it=n=>{const e=n;return Se(e.directory??e.project?.worktree??null)},Rl=n=>{const e=n.time?.updated??n.time?.created,s=typeof e=="number"?e:Number(e);return Number.isFinite(s)&&s>0?s:0},Pl=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 o=Math.floor(s/60);if(o<24)return`${o}h`;const r=Math.floor(o/24);return r<7?`${r}d`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n))},Tl=(n,e)=>{const s=Se(n),o=Se(e);return!!(s&&o&&(s===o||s.startsWith(`${o}/`)))},Vt=(n,e)=>n.worktrees.find(s=>Se(s.path)===e)??null,ps=(n,e)=>e===n.path||!!Vt(n,e),is=(n,e)=>{const s=Se(e);return s?n.find(o=>ps(o,s))??null:null},as=(n,e,s)=>s?`${n.title??""} ${n.id} ${it(n)} ${e}`.toLowerCase().includes(s):!0,hs=n=>{const e=de.c(17),{project:s,size:o}=n,r=o===void 0?"md":o,{currentTheme:i}=Zn(),a=s.icon?tr[s.icon]:null,c=s.color?er[s.color]??null:null,d=r==="sm"?"size-6 rounded-md":"size-8 rounded-lg",f=r==="sm"?"size-3.5":"size-4";let u;e[0]!==a||e[1]!==c||e[2]!==f?(u=a?t.jsx(se,{name:a,className:f,style:c?{color:c}:void 0}):t.jsx(cs,{className:f,style:c?{color:c}:void 0}),e[0]=a,e[1]=c,e[2]=f,e[3]=u):u=e[3];const m=u;let g;e[4]!==d?(g=Z("flex shrink-0 items-center justify-center overflow-hidden bg-[var(--surface-muted)] text-muted-foreground",d),e[4]=d,e[5]=g):g=e[5];let h;e[6]!==s.iconBackground?(h=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[6]=s.iconBackground,e[7]=h):h=e[7];let x;e[8]!==i||e[9]!==m||e[10]!==s.iconImage||e[11]!==s.id?(x=s.iconImage?t.jsx(sr,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:m}):m,e[8]=i,e[9]=m,e[10]=s.iconImage,e[11]=s.id,e[12]=x):x=e[12];let w;return e[13]!==g||e[14]!==h||e[15]!==x?(w=t.jsx("span",{className:g,style:h,children:x}),e[13]=g,e[14]=h,e[15]=x,e[16]=w):w=e[16],w},Pn=n=>{const e=de.c(2),{ariaLabel:s}=n;let o;return e[0]!==s?(o=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":s}),e[0]=s,e[1]=o):o=e[1],o},Tn=n=>{const e=de.c(12),{onClick:s,className:o}=n,{t:r}=me();let i;e[0]!==r?(i=r("sessions.sidebar.project.actions.newWorktree"),e[0]=r,e[1]=i):i=e[1];const a=i;let c;e[2]!==o?(c=Z("flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] 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)]",o),e[2]=o,e[3]=c):c=e[3];let d;e[4]!==s?(d=g=>{g.stopPropagation(),s()},e[4]=s,e[5]=d):d=e[5];let f,u;e[6]===Symbol.for("react.memo_cache_sentinel")?(f={touchAction:"manipulation"},u=t.jsx(se,{name:"node-tree",className:"size-4"}),e[6]=f,e[7]=u):(f=e[6],u=e[7]);let m;return e[8]!==a||e[9]!==c||e[10]!==d?(m=t.jsx("button",{type:"button",className:c,"aria-label":a,title:a,onClick:d,style:f,children:u}),e[8]=a,e[9]=c,e[10]=d,e[11]=m):m=e[11],m},ot=144,_r=180,In=n=>{const e=de.c(25),{actionsWidth:s,actions:o,revealed:r,onRevealedChange:i,children:a}=n,c=l.useRef(null),d=l.useRef(null),f=l.useRef(!1),u=l.useRef(0),m=l.useRef(r);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=(N,S)=>{const H=c.current;H&&(H.style.transition=S?`transform ${_r}ms ease-out`:"none",H.style.transform=N===0?"none":`translateX(${N}px)`,u.current=N)},e[0]=g):g=e[0];const h=g;let x,w;e[1]!==s||e[2]!==r?(x=()=>{m.current=r,h(r?-s:0,!0)},w=[s,h,r],e[1]=s,e[2]=r,e[3]=x,e[4]=w):(x=e[3],w=e[4]),l.useEffect(x,w);let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=N=>{if(N.touches.length!==1)return;const S=N.touches[0];d.current={x:S.clientX,y:S.clientY},f.current=!1},e[5]=b):b=e[5];const P=b;let j;e[6]!==s?(j=N=>{if(!d.current)return;const S=N.touches[0],H=S.clientX-d.current.x,$=S.clientY-d.current.y;if(!f.current){if(Math.abs(H)<8||Math.abs(H)<=Math.abs($))return;f.current=!0}const v=m.current?-s:0;h(Math.min(0,Math.max(-s,v+H)),!1)},e[6]=s,e[7]=j):j=e[7];const C=j;let R;e[8]!==s||e[9]!==i?(R=()=>{if(d.current=null,!f.current)return;f.current=!1;const N=u.current<-s/2;h(N?-s:0,!0),N!==m.current&&i(N)},e[8]=s,e[9]=i,e[10]=R):R=e[10];const T=R;let D;e[11]===Symbol.for("react.memo_cache_sentinel")?(D={touchAction:"pan-y"},e[11]=D):D=e[11];let k;e[12]!==s?(k={width:s},e[12]=s,e[13]=k):k=e[13];const E=!r;let y;e[14]!==o||e[15]!==k||e[16]!==E?(y=t.jsx("div",{className:"absolute inset-y-0 right-0 flex items-stretch",style:k,"aria-hidden":E,children:o}),e[14]=o,e[15]=k,e[16]=E,e[17]=y):y=e[17];let I;e[18]!==a?(I=t.jsx("div",{ref:c,className:"relative flex w-full items-center bg-background",children:a}),e[18]=a,e[19]=I):I=e[19];let M;return e[20]!==T||e[21]!==C||e[22]!==y||e[23]!==I?(M=t.jsxs("div",{className:"relative overflow-hidden",onTouchStart:P,onTouchMove:C,onTouchEnd:T,onTouchCancel:T,style:D,children:[y,I]}),e[20]=T,e[21]=C,e[22]=y,e[23]=I,e[24]=M):M=e[24],M},Il=n=>{const e=de.c(41),{initialTitle:s,indent:o,onSubmit:r,onCancel:i}=n,{t:a}=me(),[c,d]=l.useState(s);let f;e[0]!==s||e[1]!==i||e[2]!==r||e[3]!==c?(f=()=>{const N=c.trim();if(!N||N===s.trim()){i();return}r(N)},e[0]=s,e[1]=i,e[2]=r,e[3]=c,e[4]=f):f=e[4];const u=f;let m;e[5]!==o?(m={paddingLeft:o},e[5]=o,e[6]=m):m=e[6];let g;e[7]!==u?(g=N=>{N.preventDefault(),u()},e[7]=u,e[8]=g):g=e[8];let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=N=>d(N.target.value),e[9]=h):h=e[9];let x;e[10]!==i?(x=N=>{N.stopPropagation(),N.key==="Escape"&&i()},e[10]=i,e[11]=x):x=e[11];let w;e[12]!==a?(w=a("sessions.sidebar.session.rename.save"),e[12]=a,e[13]=w):w=e[13];let b;e[14]!==a?(b=a("sessions.sidebar.session.menu.rename"),e[14]=a,e[15]=b):b=e[15];let P;e[16]===Symbol.for("react.memo_cache_sentinel")?(P={minHeight:0},e[16]=P):P=e[16];let j;e[17]!==x||e[18]!==w||e[19]!==b||e[20]!==c?(j=t.jsx("input",{autoFocus:!0,value:c,onChange:h,onKeyDown:x,"aria-label":w,placeholder:b,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:P,enterKeyHint:"done"}),e[17]=x,e[18]=w,e[19]=b,e[20]=c,e[21]=j):j=e[21];let C;e[22]!==a?(C=a("sessions.sidebar.session.rename.save"),e[22]=a,e[23]=C):C=e[23];let R,T;e[24]===Symbol.for("react.memo_cache_sentinel")?(R={touchAction:"manipulation",minHeight:0,minWidth:0},T=t.jsx(se,{name:"check",className:"size-4"}),e[24]=R,e[25]=T):(R=e[24],T=e[25]);let D;e[26]!==C?(D=t.jsx("button",{type:"submit","aria-label":C,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-primary",style:R,children:T}),e[26]=C,e[27]=D):D=e[27];let k;e[28]!==a?(k=a("sessions.sidebar.session.rename.cancel"),e[28]=a,e[29]=k):k=e[29];let E,y;e[30]===Symbol.for("react.memo_cache_sentinel")?(E={touchAction:"manipulation",minHeight:0,minWidth:0},y=t.jsx(se,{name:"close",className:"size-4"}),e[30]=E,e[31]=y):(E=e[30],y=e[31]);let I;e[32]!==i||e[33]!==k?(I=t.jsx("button",{type:"button",onClick:i,"aria-label":k,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-primary",style:E,children:y}),e[32]=i,e[33]=k,e[34]=I):I=e[34];let M;return e[35]!==D||e[36]!==I||e[37]!==m||e[38]!==g||e[39]!==j?(M=t.jsxs("form",{className:"flex h-9 min-w-0 flex-1 items-center gap-2 pr-2",style:m,onSubmit:g,children:[j,D,I]}),e[35]=D,e[36]=I,e[37]=m,e[38]=g,e[39]=j,e[40]=M):M=e[40],M},An=n=>{const e=de.c(51),{session:s,active:o,indent:r,contextLabel:i,hasChildren:a,expanded:c,onToggleChildren:d,onSelect:f,revealed:u,onRevealedChange:m,confirmingDelete:g,onArchive:h,onRequestDelete:x,onConfirmDelete:w,renaming:b,onRequestRename:P,onSubmitRename:j,onCancelRename:C}=n,R=a===void 0?!1:a,T=c===void 0?!1:c,D=u===void 0?!1:u,k=g===void 0?!1:g,E=b===void 0?!1:b,{t:y}=me();let I;e[0]!==s?(I=Pl(Rl(s)),e[0]=s,e[1]=I):I=e[1];const M=I,N=s.title?.trim()||y("mobile.sessions.untitled"),S=!!(m&&h),H=Yn(s.id),$=Jn(s.id),v=H?.type??"idle",A=v==="busy"||v==="retry",O=!A&&$>0&&!o,z=Xn(s.id,A),L=(A||O)&&z,ee=l.useRef(null),X=l.useRef(null),_=l.useRef(!1),J=l.useRef(0),q=l.useRef(D);let G;e[2]===Symbol.for("react.memo_cache_sentinel")?(G=(le,Ce)=>{const be=ee.current;be&&(be.style.transition=Ce?`transform ${_r}ms ease-out`:"none",be.style.transform=le===0?"none":`translateX(${le}px)`,J.current=le)},e[2]=G):G=e[2];const F=G;let Q,te;e[3]!==D?(Q=()=>{q.current=D,F(D?-ot:0,!0)},te=[F,D],e[3]=D,e[4]=Q,e[5]=te):(Q=e[4],te=e[5]),l.useEffect(Q,te);let ae;e[6]!==S?(ae=le=>{if(!S||le.touches.length!==1)return;const Ce=le.touches[0];X.current={x:Ce.clientX,y:Ce.clientY},_.current=!1},e[6]=S,e[7]=ae):ae=e[7];const pe=ae;let oe;e[8]!==S?(oe=le=>{if(!S||!X.current)return;const Ce=le.touches[0],be=Ce.clientX-X.current.x,Fe=Ce.clientY-X.current.y;if(!_.current){if(Math.abs(be)<8||Math.abs(be)<=Math.abs(Fe))return;_.current=!0}const Pe=q.current?-ot:0,tt=Math.min(0,Math.max(-ot,Pe+be));F(tt,!1)},e[8]=S,e[9]=oe):oe=e[9];const W=oe;let ie;e[10]!==m?(ie=()=>{if(X.current=null,!_.current)return;_.current=!1;const le=J.current<-ot/2;F(le?-ot:0,!0),le!==q.current&&m?.(le)},e[10]=m,e[11]=ie):ie=e[11];const U=ie,fe=o||void 0,Ne="relative overflow-hidden";let ke;e[12]!==S?(ke=S?{touchAction:"pan-y"}:void 0,e[12]=S,e[13]=ke):ke=e[13];const Ie=S?t.jsxs("div",{className:"absolute inset-y-0 right-0 flex items-stretch",style:{width:ot},"aria-hidden":!D,children:[t.jsx("button",{type:"button",tabIndex:D?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-primary","aria-label":y("mobile.sessions.renameSessionAria",{title:N}),onClick:P,style:{touchAction:"manipulation"},children:t.jsx(us,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:D?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-primary","aria-label":y("mobile.sessions.archiveSessionAria",{title:N}),onClick:h,style:{touchAction:"manipulation"},children:t.jsx(Ji,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:D?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",k?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":k?y("mobile.sessions.confirmDeleteSessionAria",{title:N}):y("mobile.sessions.deleteSessionAria",{title:N}),onClick:k?w:x,style:{touchAction:"manipulation"},children:t.jsx(Gt,{className:"size-[18px]"})})]}):null,Be=S&&"bg-background",Ae=o&&(S?"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]":"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]");let _e;e[14]!==Be||e[15]!==Ae?(_e=Z("relative flex items-center gap-1 transition-colors",Be,Ae),e[14]=Be,e[15]=Ae,e[16]=_e):_e=e[16];let ve;e[17]!==T||e[18]!==R||e[19]!==r||e[20]!==A||e[21]!==d||e[22]!==O||e[23]!==y?(ve=A||O||R&&d?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-primary",style:{left:Math.max(r-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":y(T?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!R||!d,onClick:le=>{le.stopPropagation(),d?.()},children:A||O?t.jsx("span",{className:Z("size-1.5 rounded-full",A?"bg-primary":"bg-[var(--status-info)]"),"aria-hidden":!0}):t.jsx(Cs,{className:Z("size-[18px] transition-transform duration-150",T?"rotate-0":"-rotate-90")})}):null,e[17]=T,e[18]=R,e[19]=r,e[20]=A,e[21]=d,e[22]=O,e[23]=y,e[24]=ve):ve=e[24];let B;e[25]!==o||e[26]!==i||e[27]!==r||e[28]!==A||e[29]!==C||e[30]!==m||e[31]!==f||e[32]!==j||e[33]!==E||e[34]!==s.id||e[35]!==L||e[36]!==M||e[37]!==N?(B=E&&j&&C?t.jsx(Il,{initialTitle:N,indent:r,onSubmit:j,onCancel:C}):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-primary focus-visible:ring-inset",i?"min-h-10 py-1":"h-9"),style:{paddingLeft:r,touchAction:"manipulation"},onClick:()=>{if(q.current){m?.(!1);return}f()},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",o?"text-primary":"text-foreground"),children:N}),L?t.jsx(ir,{sessionId:s.id,running:A,className:"typography-micro"}):M?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:M}):null]}),i?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:i}):null]})}),e[25]=o,e[26]=i,e[27]=r,e[28]=A,e[29]=C,e[30]=m,e[31]=f,e[32]=j,e[33]=E,e[34]=s.id,e[35]=L,e[36]=M,e[37]=N,e[38]=B):B=e[38];let V;e[39]!==_e||e[40]!==ve||e[41]!==B?(V=t.jsxs("div",{ref:ee,className:_e,children:[ve,B]}),e[39]=_e,e[40]=ve,e[41]=B,e[42]=V):V=e[42];let re;return e[43]!==U||e[44]!==W||e[45]!==pe||e[46]!==fe||e[47]!==ke||e[48]!==Ie||e[49]!==V?(re=t.jsxs("div",{"data-active-session":fe,className:Ne,onTouchStart:pe,onTouchMove:W,onTouchEnd:U,onTouchCancel:U,style:ke,children:[Ie,V]}),e[43]=U,e[44]=W,e[45]=pe,e[46]=fe,e[47]=ke,e[48]=Ie,e[49]=V,e[50]=re):re=e[50],re},Al=n=>{const e=de.c(11),{indent:s,onClick:o}=n,{t:r}=me();let i;e[0]!==s?(i={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Cs,{className:"size-4"}),e[2]=a):a=e[2];let c;e[3]!==r?(c=r("sessions.sidebar.group.showMore"),e[3]=r,e[4]=c):c=e[4];let d;e[5]!==c?(d=t.jsx("span",{className:"typography-micro",children:c}),e[5]=c,e[6]=d):d=e[6];let f;return e[7]!==o||e[8]!==i||e[9]!==d?(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-primary focus-visible:ring-inset",style:i,onClick:o,children:[a,d]}),e[7]=o,e[8]=i,e[9]=d,e[10]=f):f=e[10],f},_l=n=>{const e=de.c(11),{indent:s,onClick:o}=n,{t:r}=me();let i;e[0]!==s?(i={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Xi,{className:"size-4"}),e[2]=a):a=e[2];let c;e[3]!==r?(c=r("sessions.sidebar.group.showFewer"),e[3]=r,e[4]=c):c=e[4];let d;e[5]!==c?(d=t.jsx("span",{className:"typography-micro",children:c}),e[5]=c,e[6]=d):d=e[6];let f;return e[7]!==o||e[8]!==i||e[9]!==d?(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-primary focus-visible:ring-inset",style:i,onClick:o,children:[a,d]}),e[7]=o,e[8]=i,e[9]=d,e[10]=f):f=e[10],f},Dl=n=>{const e=de.c(29),{worktree:s}=n,{t:o}=me();let r;e[0]!==s.path?(r=Se(s.path),e[0]=s.path,e[1]=r):r=e[1];const i=r;let a;e[2]!==i?(a={id:i},e[2]=i,e[3]=a):a=e[3];const{attributes:c,listeners:d,setNodeRef:f,transform:u,transition:m,isDragging:g}=Ms(a),h=s.branch||s.label||s.path;let x;e[4]!==u?(x=zs.Transform.toString(u),e[4]=u,e[5]=x):x=e[5];const w=g?10:1;let b;e[6]!==x||e[7]!==w||e[8]!==m?(b={transform:x,transition:m,zIndex:w},e[6]=x,e[7]=w,e[8]=m,e[9]=b):b=e[9];const P=g&&"shadow-lg shadow-black/20";let j;e[10]!==P?(j=Z("flex items-center gap-1 rounded-xl bg-background px-1 py-1",P),e[10]=P,e[11]=j):j=e[11];let C;e[12]!==h||e[13]!==o?(C=o("mobile.sessions.dragHandleAria",{label:h}),e[12]=h,e[13]=o,e[14]=C):C=e[14];let R;e[15]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(Ns,{className:"size-4"}),e[15]=R):R=e[15];let T;e[16]!==c||e[17]!==d||e[18]!==C?(T=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,...c,...d,children:R}),e[16]=c,e[17]=d,e[18]=C,e[19]=T):T=e[19];let D;e[20]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(se,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=D):D=e[20];let k;e[21]!==h?(k=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]=k):k=e[22];let E;return e[23]!==f||e[24]!==T||e[25]!==k||e[26]!==b||e[27]!==j?(E=t.jsxs("div",{ref:f,style:b,className:j,children:[T,D,k]}),e[23]=f,e[24]=T,e[25]=k,e[26]=b,e[27]=j,e[28]=E):E=e[28],E},Ml=n=>{const e=de.c(61),{project:s,totalSessions:o,expanded:r,onToggleExpanded:i,onReorderWorktrees:a}=n,{t:c}=me();let d;e[0]!==s.id?(d={id:s.id},e[0]=s.id,e[1]=d):d=e[1];const{attributes:f,listeners:u,setNodeRef:m,transform:g,transition:h,isDragging:x}=Ms(d);let w;e[2]===Symbol.for("react.memo_cache_sentinel")?(w={activationConstraint:{distance:8}},e[2]=w):w=e[2];let b;e[3]===Symbol.for("react.memo_cache_sentinel")?(b={coordinateGetter:As},e[3]=b):b=e[3];const P=Es(pt(Ps,w),pt(Rs,b)),j=s.worktrees.length>0;let C;e[4]!==a||e[5]!==s.worktrees?(C=J=>{const{active:q,over:G}=J;if(!G||q.id===G.id)return;const F=s.worktrees.map(Bl),Q=F.indexOf(String(q.id)),te=F.indexOf(String(G.id));if(Q<0||te<0)return;const ae=[...F],[pe]=ae.splice(Q,1);ae.splice(te,0,pe),a(ae)},e[4]=a,e[5]=s.worktrees,e[6]=C):C=e[6];const R=C;let T;e[7]!==g?(T=zs.Transform.toString(g),e[7]=g,e[8]=T):T=e[8];const D=x?10:1;let k;e[9]!==T||e[10]!==D||e[11]!==h?(k={transform:T,transition:h,zIndex:D},e[9]=T,e[10]=D,e[11]=h,e[12]=k):k=e[12];const E=x&&"shadow-lg shadow-black/20";let y;e[13]!==E?(y=Z("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",E),e[13]=E,e[14]=y):y=e[14];let I;e[15]!==s.label||e[16]!==c?(I=c("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=c,e[17]=I):I=e[17];let M;e[18]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(Ns,{className:"size-4"}),e[18]=M):M=e[18];let N;e[19]!==f||e[20]!==u||e[21]!==I?(N=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":I,...f,...u,children:M}),e[19]=f,e[20]=u,e[21]=I,e[22]=N):N=e[22];let S;e[23]!==r||e[24]!==s.label||e[25]!==c?(S=r?c("sessions.sidebar.group.collapseAria",{label:s.label}):c("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=r,e[24]=s.label,e[25]=c,e[26]=S):S=e[26];const H=!j;let $;e[27]===Symbol.for("react.memo_cache_sentinel")?($={touchAction:"manipulation"},e[27]=$):$=e[27];let v;e[28]!==s?(v=t.jsx(hs,{project:s}),e[28]=s,e[29]=v):v=e[29];let A;e[30]!==s.label?(A=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]=A):A=e[31];let O;e[32]!==o?(O=t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:o}),e[32]=o,e[33]=O):O=e[33];let z;e[34]!==r||e[35]!==j?(z=j?t.jsx(Cs,{className:Z("size-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-180")}):null,e[34]=r,e[35]=j,e[36]=z):z=e[36];let L;e[37]!==r||e[38]!==i||e[39]!==S||e[40]!==H||e[41]!==v||e[42]!==A||e[43]!==O||e[44]!==z?(L=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-primary",onClick:i,"aria-expanded":r,"aria-label":S,disabled:H,style:$,children:[v,A,O,z]}),e[37]=r,e[38]=i,e[39]=S,e[40]=H,e[41]=v,e[42]=A,e[43]=O,e[44]=z,e[45]=L):L=e[45];let ee;e[46]!==N||e[47]!==L?(ee=t.jsxs("div",{className:"flex items-center gap-1",children:[N,L]}),e[46]=N,e[47]=L,e[48]=ee):ee=e[48];let X;e[49]!==r||e[50]!==R||e[51]!==j||e[52]!==s.worktrees||e[53]!==P?(X=r&&j?t.jsx(Ts,{sensors:P,collisionDetection:Is,onDragEnd:R,children:t.jsx(_s,{items:s.worktrees.map($l),strategy:Ds,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 pl-3",children:s.worktrees.map(Fl)})})}):null,e[49]=r,e[50]=R,e[51]=j,e[52]=s.worktrees,e[53]=P,e[54]=X):X=e[54];let _;return e[55]!==m||e[56]!==ee||e[57]!==X||e[58]!==k||e[59]!==y?(_=t.jsxs("div",{ref:m,style:k,className:y,children:[ee,X]}),e[55]=m,e[56]=ee,e[57]=X,e[58]=k,e[59]=y,e[60]=_):_=e[60],_},_n=({open:n,onOpenChange:e,variant:s="drawer",footer:o})=>{const{t:r}=me(),{git:i}=js(),a=Qn(),c=bs(p=>p.activeSessions),d=Hn(l.useCallback(p=>n||s==="sidebar"?p.ids:Cl,[n,s])),f=qn(l.useCallback(p=>n||s==="sidebar"?p.rankById:Do,[n,s])),u=Oe(p=>p.projects),m=Oe(p=>p.activeProjectId),g=ft(p=>p.currentDirectory),h=je(p=>p.currentSessionId),x=je(p=>p.setCurrentSession),w=je(p=>p.archiveSession),b=je(p=>p.deleteSession),P=je(p=>p.updateSessionTitle),j=je(p=>p.openNewSessionDraft),C=Oe(p=>p.setActiveProject),R=Oe(p=>p.setActiveProjectIdOnly),T=Oe(p=>p.reorderProjects),D=Oe(p=>p.removeProject),k=Bt(p=>p.projectExpanded),E=Bt(p=>p.worktreeExpanded),y=Bt(p=>p.setProjectExpanded),I=Bt(p=>p.setWorktreeExpanded),M=ms(p=>p.orderByProject),N=ms(p=>p.setWorktreeOrder),S=Nn(p=>p.expandedParents),H=Nn(p=>p.toggleParent),[$,v]=l.useState(""),[A,O]=l.useState(null),[z,L]=l.useState(null),[ee,X]=l.useState(null),[_,J]=l.useState(null),[q,G]=l.useState(null),[F,Q]=l.useState(null),[te,ae]=l.useState(null),[pe,oe]=l.useState(0),[W,ie]=l.useState(!1),[U,fe]=l.useState(!1),[Ne,ke]=l.useState(null),[Ie,Be]=l.useState(()=>new Map(je.getState().availableWorktreesByProject)),[Ae,_e]=l.useState(()=>{const p=new Set;for(const[K,Y]of je.getState().availableWorktreesByProject)Y.length>0&&p.add(K);return p}),[ve,B]=l.useState(!1),[V,re]=l.useState(new Set),[le,Ce]=l.useState(new Map);l.useEffect(()=>{if(!n){v(""),B(!1),re(new Set),Ce(new Map),O(null),L(null),X(null),J(null),G(null),Q(null);return}vs(a)},[n]),l.useEffect(()=>{ve||re(new Set)},[ve]),l.useEffect(()=>{if(!n||u.length===0)return;let p=!1;return(async()=>{const Y=await Promise.all(u.map(async ce=>{const Ee=Se(ce.path);if(!Ee)return null;const ge=await i.checkIsGitRepository(Ee).catch(()=>!1),De=ge?await nr({id:ce.id,path:Ee}).catch(()=>[]):[];return[Ee,De,ge]}));if(p)return;const ne=new Map,we=new Set;for(const ce of Y)ce&&(ne.set(ce[0],ce[1]),ce[2]&&we.add(ce[0]));Be(rr(u,ne)),_e(we)})(),()=>{p=!0}},[i,n,u,pe]);const be=l.useMemo(()=>u.map(p=>({id:p.id,label:p.label?.trim()||ns(p.path),path:Se(p.path),icon:p.icon,color:p.color,iconImage:p.iconImage,iconBackground:p.iconBackground,isGitRepo:Ae.has(Se(p.path)),worktrees:vl(M[p.id],Ie.get(Se(p.path))??[])})),[Ae,u,M,Ie]),Fe=l.useMemo(()=>{const p=new Map(a.map(ne=>[ne.id,ne])),K=c.map(ne=>{const we=p.get(ne.id);return we?Mo(we,ne):ne}),Y=new Set(K.map(ne=>ne.id));for(const ne of a)Y.has(ne.id)||K.push(ne);return K.filter(ne=>!ne.time?.archived)},[c,a]),Pe=$.trim().toLowerCase(),tt=l.useRef(null);l.useEffect(()=>{if(!n)return;const p=window.requestAnimationFrame(()=>{const K=tt.current;if(!K)return;(K.querySelector('[data-active-session="true"]')??K.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(p)},[n]);const Dt=l.useMemo(()=>{const p=be.map(Y=>({project:Y,buckets:[],totalSessions:0,isActive:Y.id===m})),K=(Y,ne,we)=>{const ce=Se(ne)||Y.project.path,Ee=ce||"__root__";let ge=Y.buckets.find(De=>De.key===Ee);return ge||(ge={key:Ee,label:we?.branch||ns(ce),path:ce,worktree:we,sessions:[]},Y.buckets.push(ge)),ge};for(const Y of p){K(Y,Y.project.path,null);for(const ne of Y.project.worktrees)K(Y,ne.path,ne)}for(const Y of Fe){const ne=it(Y);if(!ne)continue;const we=Se(ne),ce=p.find(De=>ps(De.project,we));if(!ce)continue;const Ee=Vt(ce.project,we);(Ee?K(ce,Ee.path,Ee):K(ce,ce.project.path,null)).sessions.push(Y)}for(const Y of p)for(const ne of Y.buckets){ne.sessions=cn(ne.sessions,d,f);for(const we of ne.sessions)St(we)||(Y.totalSessions+=1)}return p},[m,d,be,f,Fe]),Ks=Se(g),Or=p=>p.isActive?Ks===p.project.path?p.project.path:p.project.worktrees.find(Y=>Tl(Ks,Y.path))?.path??p.project.path:null,Lr=p=>k[p.project.id]??!0,Br=(p,K)=>E[`${p.project.id}::${K.key}`]??!0,Hs=p=>{Ce(K=>{if(!K.has(p))return K;const Y=new Map(K);return Y.delete(p),Y})},$r=p=>{Ce(K=>{let Y=!1;const ne=new Map(K),we=`${p}::`;for(const ce of ne.keys())ce.startsWith(we)&&(ne.delete(ce),Y=!0);return Y?ne:K})},Fr=(p,K)=>{Ce(Y=>{const ne=new Map(Y);return ne.set(p,K+os),ne})},qs=(p,K,Y)=>{const ne=`${p.project.id}::${K.key}`,we=new Set(K.sessions.map(ye=>ye.id)),ce=new Map;for(const ye of K.sessions){const $e=St(ye);if($e&&we.has($e)){const vt=ce.get($e)??[];vt.push(ye),ce.set($e,vt)}}const Ee=K.sessions.filter(ye=>{const $e=St(ye);return!$e||!we.has($e)}),ge=le.get(ne)??os,De=Ee.slice(0,ge),st=Ee.length-De.length,Zt=Ee.length>os&&st===0,tn=(ye,$e)=>{const vt=ce.get(ye.id)??[],es=vt.length>0,sn=!!S[ye.id];return t.jsxs(l.Fragment,{children:[t.jsx(An,{session:ye,active:h===ye.id,indent:$e,hasChildren:es,expanded:sn,onToggleChildren:es?()=>H(ye.id):void 0,onSelect:()=>Ys(ye),revealed:z===ye.id,onRevealedChange:wt=>Vr(ye.id,wt),confirmingDelete:ee===ye.id,onArchive:()=>{Gr(ye)},onRequestDelete:()=>X(ye.id),onConfirmDelete:()=>{Kr(ye)},renaming:_===ye.id,onRequestRename:()=>Hr(ye.id),onSubmitRename:wt=>{qr(ye.id,wt)},onCancelRename:()=>J(null)}),es&&sn?vt.map(wt=>tn(wt,$e+El)):null]},ye.id)};return t.jsxs("div",{children:[De.map(ye=>tn(ye,Y)),st>0?t.jsx(Al,{indent:Y,onClick:()=>Fr(ne,De.length)}):null,Zt?t.jsx(_l,{indent:Y,onClick:()=>Hs(ne)}):null]})},Wr=(p,K)=>{y(p,!K),$r(p)},Ur=(p,K,Y)=>{I(`${p}::${K}`,!Y),Hs(`${p}::${K}`)},Ys=p=>{const K=it(p)||null,Y=is(be,K??"");if(Y){R(Y.id),y(Y.id,!0);const ne=Vt(Y,Se(K??""));ne&&I(`${Y.id}::${Se(ne.path)}`,!0)}x(p.id,K),e(!1)},Vr=(p,K)=>{L(K?p:null),X(null),G(null),Q(null)},Mt=(p,K)=>{G(K?p:null),Q(null),L(null),X(null)},Gr=async p=>{L(null),X(null),await w(p.id)?ue.success(r("sessions.sidebar.session.archive.success")):ue.error(r("sessions.sidebar.session.archive.error"))},Kr=async p=>{L(null),X(null),await b(p.id)?ue.success(r("sessions.sidebar.session.delete.success")):ue.error(r("sessions.sidebar.session.delete.error"))},Hr=p=>{L(null),X(null),J(p)},qr=async(p,K)=>{J(null);try{await P(p,K)}catch{ue.error(r("mobile.sessions.renameError"))}},Yr=()=>{j(),e(!1)},Js=p=>{ke(p),R(p),fe(!0)},Jr=Es(pt(Ps,{activationConstraint:{distance:8}}),pt(Rs,{coordinateGetter:As})),Xr=p=>{const{active:K,over:Y}=p;if(!Y||K.id===Y.id)return;const ne=be.findIndex(ce=>ce.id===K.id),we=be.findIndex(ce=>ce.id===Y.id);ne<0||we<0||T(ne,we)},Qr=p=>{re(K=>{const Y=new Set(K);return Y.has(p)?Y.delete(p):Y.add(p),Y})},Zr=l.useCallback(p=>{const K=it(p),Y=is(be,K);if(!Y)return ns(K)||K;const ne=Vt(Y,Se(K));return ne?.branch?`${Y.label} · ${ne.branch}`:Y.label},[be]),eo=p=>{C(p.id),e(!1)},to=l.useMemo(()=>Pe?Dt.filter(p=>`${p.project.label} ${p.project.path}`.toLowerCase().includes(Pe)?!0:p.buckets.some(K=>K.sessions.some(Y=>as(Y,p.project.label,Pe)))):Dt,[Pe,Dt]),zt=l.useMemo(()=>Pe?cn(Fe.filter(p=>{if(St(p))return!1;const K=it(p),Y=is(be,K);return as(p,Y?.label??"",Pe)}),d,f):[],[Pe,d,be,f,Fe]),Ot=l.useMemo(()=>Pe?be.filter(p=>`${p.label} ${p.path}`.toLowerCase().includes(Pe)).map(p=>({...p,sessionCount:Fe.filter(K=>{if(St(K))return!1;const Y=Se(it(K));return ps(p,Y)}).length})):[],[Pe,be,Fe]),so=Pe&&zt.length===0&&Ot.length===0,Xs=!Pe&&be.length>1?t.jsx(xe,{type:"button",variant:"chip",size:"sm","aria-label":r(ve?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":ve,onClick:()=>B(p=>!p),style:{touchAction:"manipulation"},children:ve?t.jsx(ar,{className:"size-4"}):t.jsx(us,{className:"size-4"})}):null,Qs=!ve&&be.length>0?t.jsxs(xe,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:Yr,style:{touchAction:"manipulation"},children:[t.jsx(Yi,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,Zs=ve?null:t.jsx(xe,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.addProject"),title:r("sessions.sidebar.header.actions.addProject"),onClick:()=>ie(!0),style:{touchAction:"manipulation"},children:t.jsx(un,{className:"size-4"})}),Lt=Qs||Zs||Xs?t.jsxs(t.Fragment,{children:[Qs,Zs,Xs]}):null,en=t.jsxs("div",{ref:tt,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs(ks,{className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:Z("px-4 pb-2 pt-1",ve&&"hidden"),children:t.jsxs("div",{className:"relative",children:[t.jsx(lr,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(ws,{value:$,onChange:p=>v(p.target.value),placeholder:r("mobile.sessions.search.placeholder"),className:Z("h-11 pl-9",$&&"pr-10")}),$?t.jsx("button",{type:"button",className:"absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 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-primary","aria-label":r("mobile.sessions.clearSearchAria"),onClick:()=>v(""),style:{touchAction:"manipulation"},children:t.jsx(cr,{className:"size-4"})}):null]})}),be.length===0?t.jsx(zn,{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-primary",onClick:()=>ie(!0),children:[t.jsx(un,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):so?t.jsx(zn,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):Pe&&!ve?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[zt.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:zt.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:zt.map((p,K)=>t.jsx("div",{className:Z(K>0&&"border-t border-border/70"),children:t.jsx(An,{session:p,active:h===p.id,indent:12,contextLabel:Zr(p),onSelect:()=>Ys(p)})},p.id))})]}):null,Ot.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:Ot.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Ot.map((p,K)=>t.jsxs("div",{className:Z("flex items-center",K>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-primary focus-visible:ring-inset",onClick:()=>eo(p),style:{touchAction:"manipulation"},children:[t.jsx(hs,{project:p}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:p.label}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:p.sessionCount})]}),p.isGitRepo?t.jsx(Tn,{className:"mr-2",onClick:()=>Js(p.id)}):null]},p.id))})]}):null]}):ve?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(Ts,{sensors:Jr,collisionDetection:Is,onDragEnd:Xr,children:t.jsx(_s,{items:be.map(p=>p.id),strategy:Ds,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:be.map(p=>{const K=Dt.find(Y=>Y.project.id===p.id);return t.jsx(Ml,{project:p,totalSessions:K?.totalSessions??0,expanded:V.has(p.id),onToggleExpanded:()=>Qr(p.id),onReorderWorktrees:Y=>N(p.id,Y)},p.id)})})})})]}):t.jsx("div",{className:"flex flex-col",children:to.map((p,K)=>{const Y=Lr(p),ne=Pe?p.buckets.filter(ce=>ce.sessions.some(Ee=>as(Ee,p.project.label,Pe))):p.buckets,we=Or(p);return t.jsxs("section",{className:Z(K>0&&"border-t border-border/70"),children:[t.jsx(In,{actionsWidth:96,revealed:q===`project:${p.project.id}`,onRevealedChange:ce=>Mt(`project:${p.project.id}`,ce),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:q===`project:${p.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-primary","aria-label":r("mobile.sessions.editProjectAria",{label:p.project.label}),onClick:()=>{G(null),O(p.project.id)},style:{touchAction:"manipulation"},children:t.jsx(us,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:q===`project:${p.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",F===p.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":F===p.project.id?r("mobile.sessions.confirmRemoveProjectAria",{label:p.project.label}):r("mobile.sessions.removeProjectAria",{label:p.project.label}),onClick:()=>{if(F===p.project.id){G(null),Q(null),D(p.project.id),ue.success(r("mobile.sessions.toast.projectRemoved",{label:p.project.label}));return}Q(p.project.id)},style:{touchAction:"manipulation"},children:t.jsx(Gt,{className:"size-[18px]"})})]}),children:t.jsxs("div",{"data-active-project":p.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-primary focus-visible:ring-inset",onClick:()=>{if(q){Mt(q,!1);return}Wr(p.project.id,Y)},"aria-expanded":Y,"aria-label":Y?r("sessions.sidebar.group.collapseAria",{label:p.project.label}):r("sessions.sidebar.group.expandAria",{label:p.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(hs,{project:p.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:p.project.label}),p.isActive?t.jsx(Pn,{ariaLabel:r("mobile.sessions.activeProjectAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:p.totalSessions})]}),p.project.isGitRepo?t.jsx(Tn,{className:"mr-2",onClick:()=>Js(p.project.id)}):null]})}),Y?t.jsx("div",{className:"pb-2",children:(()=>{const ce=ne.find(ge=>ge.worktree===null),Ee=ne.filter(ge=>ge.worktree!==null);return t.jsxs(t.Fragment,{children:[ce&&ce.sessions.length>0?qs(p,ce,Rn):null,Ee.map(ge=>{const De=Br(p,ge),st=we===ge.path;return t.jsxs("div",{children:[t.jsx(In,{actionsWidth:48,revealed:q===`wt:${ge.key}`,onRevealedChange:Zt=>Mt(`wt:${ge.key}`,Zt),actions:t.jsx("button",{type:"button",tabIndex:q===`wt:${ge.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:ge.label}),onClick:()=>{G(null),ge.worktree&&ae({project:p.project,worktree:ge.worktree})},style:{touchAction:"manipulation"},children:t.jsx(Gt,{className:"size-[18px]"})}),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-primary focus-visible:ring-inset",onClick:()=>{if(q){Mt(q,!1);return}Ur(p.project.id,ge.key,De)},"aria-expanded":De,"aria-label":De?r("sessions.sidebar.group.collapseAria",{label:ge.label}):r("sessions.sidebar.group.expandAria",{label:ge.label}),style:{touchAction:"manipulation"},children:[t.jsx(se,{name:"git-branch",className:Z("size-4 shrink-0",st?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Z("block min-w-0 flex-1 truncate typography-ui-label font-bold",st?"text-foreground":"text-muted-foreground"),children:ge.label}),st?t.jsx(Pn,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:ge.sessions.length})]})}),De?qs(p,ge,Rn):null]},ge.key)})]})})()}):null]},p.project.id)})})]}),o?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:[o.instanceLabel&&o.onOpenInstances?t.jsxs(xe,{type:"button",variant:"info",size:"lg",className:"min-w-0 shrink justify-start",onClick:o.onOpenInstances,"aria-label":r("mobile.menu.instances"),style:{touchAction:"manipulation"},children:[t.jsx(se,{name:"server",className:"size-[18px]"}),t.jsx("span",{className:"block min-w-0 truncate",children:o.instanceLabel})]}):t.jsx("div",{className:"min-w-0 flex-1"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[o.onOpenUpdate?t.jsxs(xe,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:o.onOpenUpdate,"aria-label":r("mobile.menu.update"),title:r("mobile.menu.update"),style:{touchAction:"manipulation"},children:[t.jsx(se,{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(xe,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:o.onOpenSettings,"aria-label":r("mobile.menu.settings"),title:r("mobile.menu.settings"),style:{touchAction:"manipulation"},children:t.jsx(se,{name:"settings-3",className:"size-5"})})]})]}):null,t.jsx(Pi,{open:W,onOpenChange:ie}),t.jsx(Ti,{open:U,onOpenChange:p=>{fe(p),p||ke(null)},onWorktreeCreated:(p,K)=>{K?.sessionId?x(K.sessionId,p):j({selectedProjectId:Ne,directoryOverride:p,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(Nl,{open:A!==null,project:be.find(p=>p.id===A)??null,onClose:()=>O(null),onWorktreesChanged:()=>oe(p=>p+1)}),te?t.jsx(Ar,{open:!0,project:{id:te.project.id,path:te.project.path},worktree:te.worktree,onClose:()=>ae(null),onDeleted:()=>oe(p=>p+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")}),Lt?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:Lt}):null]}),en]}):null:t.jsxs(Ll,{open:n,onClose:()=>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-primary","aria-label":r("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(se,{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")}),Lt?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:Lt}):null]}),en]})},Dn="mobile-surface-root",zl=16,Mn=320,Ol="cubic-bezier(0.22, 1, 0.36, 1)",Ll=({open:n,onClose:e,ariaLabel:s,children:o})=>{const r=l.useRef(null),[i,a]=l.useState(!1),[c,d]=l.useState(n),f=l.useRef(e);if(l.useEffect(()=>{f.current=e},[e]),typeof document<"u"&&!r.current){let u=document.getElementById(Dn);u||(u=document.createElement("div"),u.id=Dn,document.body.appendChild(u)),r.current=u}return l.useEffect(()=>{if(n){d(!0);const m=window.setTimeout(()=>a(!0),zl);return()=>window.clearTimeout(m)}a(!1);const u=window.setTimeout(()=>d(!1),Mn+40);return()=>window.clearTimeout(u)},[n]),l.useEffect(()=>{if(!n)return;const u=document.body.style.overflow;document.body.style.overflow="hidden";const m=g=>{g.key==="Escape"&&f.current()};return document.addEventListener("keydown",m),()=>{document.body.style.overflow=u,document.removeEventListener("keydown",m)}},[n]),r.current?dt.createPortal(t.jsx("section",{role:"dialog","aria-modal":"true","aria-label":s,"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:i?"none":"translateX(-100%)",transition:`transform ${Mn}ms ${Ol}`,visibility:c?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:o})}),r.current):null},zn=n=>{const e=de.c(10),{title:s,description:o,action:r}=n;let i;e[0]!==s?(i=t.jsx("p",{className:"typography-ui-label text-foreground",children:s}),e[0]=s,e[1]=i):i=e[1];let a;e[2]!==o?(a=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[2]=o,e[3]=a):a=e[3];let c;e[4]!==r?(c=r?t.jsx("div",{className:"pt-2",children:r}):null,e[4]=r,e[5]=c):c=e[5];let d;return e[6]!==i||e[7]!==a||e[8]!==c?(d=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[i,a,c]}),e[6]=i,e[7]=a,e[8]=c,e[9]=d):d=e[9],d};function Bl(n){return Se(n.path)}function $l(n){return Se(n.path)}function Fl(n){return t.jsx(Dl,{worktree:n},Se(n.path))}const Wl=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),Ul=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},Vl=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},On=(n,e)=>e?`${n}\0staged`:n,Gl=({onClose:n,initialDiffPath:e,initialDiffStaged:s=!1})=>{const{t:o}=me(),{git:r}=js(),i=Wl(Ss()??null),a=zo(i||null),c=Oo(i||null),d=Lo(i||null),f=We(B=>B.setActiveDirectory),u=We(B=>B.ensureAll),m=We(B=>B.fetchStatus),g=We(B=>B.fetchBranches),h=We(B=>B.prefetchDiffs),x=We(B=>B.getDiff),w=We(B=>B.setDiff),[b,P]=l.useState(()=>e?{type:"diff",path:e,staged:s}:{type:"list"});l.useEffect(()=>{e&&P(B=>B.type==="diff"&&B.path===e&&B.staged===s?B:{type:"diff",path:e,staged:s})},[e,s]);const[j,C]=l.useState(null),[R,T]=l.useState(null),[D,k]=l.useState(""),[E,y]=l.useState(new Set),[I,M]=l.useState(!1),[N,S]=l.useState(!1),[H,$]=l.useState([]),[v,A]=l.useState([]),[O,z]=l.useState([]),[L,ee]=l.useState(null),[X,_]=l.useState(null),[J,q]=l.useState(0),G=l.useMemo(()=>{const B=a?.files??[],V=new Map;for(const re of B)V.set(re.path,re);return Array.from(V.values()).sort((re,le)=>re.path.localeCompare(le.path))},[a?.files]),F=l.useMemo(()=>G.filter(Ul),[G]),Q=l.useMemo(()=>G.filter(Vl),[G]),te=l.useMemo(()=>{if(O.length>0)return O;const B=a?.tracking?.includes("/")?a.tracking.split("/")[0]:null;return B||L?[{name:B||"origin",fetchUrl:L??"",pushUrl:L??""}]:[]},[L,O,a?.tracking]),ae=We(l.useCallback(B=>!i||b.type!=="diff"?null:B.directories.get(i)?.diffCache.get(On(b.path,b.staged))??null,[i,b])),pe=l.useMemo(()=>b.type!=="diff"?null:G.find(B=>B.path===b.path)??null,[G,b]),oe=l.useCallback(async(B=!0)=>{if(i)try{await Promise.all([m(i,r),g(i,r)])}catch(V){B&&ue.error(V instanceof Error?V.message:o("gitView.toast.refreshRepositoryFailed"))}},[i,g,m,r,o]),W=l.useCallback(async()=>{if(!i){z([]),ee(null);return}try{const[B,V]=await Promise.all([r.getRemotes(i).catch(()=>[]),r.getRemoteUrl?r.getRemoteUrl(i).catch(()=>null):Promise.resolve(null)]);z(B),ee(V)}catch{z([]),ee(null)}},[i,r]);l.useEffect(()=>{i&&(f(i),u(i,r))},[i,u,r,f]),l.useEffect(()=>{W()},[W]),l.useEffect(()=>{if(!i||G.length===0)return;const B=Array.from(new Set([...F.map(re=>re.path),...v,...G.slice(0,20).map(re=>re.path)])).filter(Boolean);if(B.length===0)return;const V=window.setTimeout(()=>{h(i,r,B,{maxFiles:40})},120);return()=>window.clearTimeout(V)},[G,i,r,h,F,v]),l.useEffect(()=>{if(b.type!=="diff"){_(null);return}const B=On(b.path,b.staged);if(!i||x(i,B)){_(null);return}let V=!1;const re=xt();return _(null),r.getGitFileDiff(i,{path:b.path,staged:b.staged||void 0}).then(le=>{V||w(i,B,{original:le.original??"",modified:le.modified??"",isBinary:le.isBinary},re)}).catch(le=>{V||_(le instanceof Error?le.message:String(le))}),()=>{V=!0}},[i,J,x,r,b,w]);const ie=async(B,V)=>{if(i){C(B);try{const re=le=>{const Ce=`${le.name}/`,be=a?.tracking?.startsWith(Ce)?a.tracking.slice(Ce.length):void 0;return{remote:le.name,branch:be,rebase:!0}};if(B==="fetch"){if(!V)throw new Error(o("mobile.changes.noRemote"));await r.gitFetch(i,{remote:V.name}),ue.success(o("gitView.toast.fetchedFromRemote",{name:V.name}))}else if(B==="sync"){if(!V)throw new Error(o("mobile.changes.noRemote"));await r.gitFetch(i,{remote:V.name});const le=await r.getGitStatus(i);if((le.behind??0)>0){if((le.files?.length??0)>0){ue.error(o("gitView.toast.commitOrStashBeforeSync"));return}await r.gitPull(i,re(V))}((await r.getGitStatus(i)).ahead??0)>0&&await r.gitPush(i),ue.success(o("gitView.toast.alreadyUpToDate"))}await oe(!1),await W()}catch(re){ue.error(re instanceof Error?re.message:o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}))}finally{C(null)}}},U=l.useCallback(async(B,V)=>{if(!(!i||B.length===0))try{V==="stage"?B.length>1?await Bo(i,B):await $o(i,B[0]):B.length>1?await Fo(i,B):await Wo(i,B[0]),await oe(!1)}catch(re){ue.error(re instanceof Error?re.message:o(V==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[i,oe,o]),fe=l.useCallback((B,V=!1)=>{P({type:"diff",path:B,staged:V})},[]),Ne=l.useCallback(async B=>{if(i){y(V=>new Set(V).add(B));try{await r.revertGitFile(i,B),ue.success(o("gitView.toast.revertedFile",{path:B})),await oe(!1)}catch(V){ue.error(V instanceof Error?V.message:o("gitView.toast.revertFailed"))}finally{y(V=>{const re=new Set(V);return re.delete(B),re})}}},[i,r,oe,o]),ke=l.useCallback(async B=>{if(!i||B.length===0||I)return;const V=Array.from(new Set(B));M(!0),y(new Set(V));try{await Promise.all(V.map(re=>r.revertGitFile(i,re))),await oe(!1),ue.success(V.length===1?o("gitView.toast.revertedFilesSingle",{count:V.length}):o("gitView.toast.revertedFilesPlural",{count:V.length}))}catch(re){ue.error(re instanceof Error?re.message:o("gitView.toast.revertFailed"))}finally{y(new Set),M(!1)}},[i,r,I,oe,o]),Ie=l.useCallback(B=>{const V=B.map(re=>re.trim()).filter(Boolean);if(V.length===0){$([]);return}k(re=>`${re.trim()}${re.trim()?`
23
23
 
24
24
  `:""}${V.join(`
25
- `)}`.trim()),$([])},[]),Be=l.useCallback(async()=>{if(!i)return;const L=F.map(V=>V.path).sort();if(L.length===0){ue.error(o("gitView.toast.selectFileToDescribe"));return}S(!0);try{const{message:V}=await Wo(i,L);k(V.subject?.trim()??""),$(Array.isArray(V.highlights)?V.highlights:[])}catch(V){ue.error(V instanceof Error?V.message:o("gitView.toast.generateCommitMessageFailed"))}finally{S(!1)}},[i,F,o]),Ae=async(L={})=>{if(!i)return;if(!D.trim()){ue.error(o("gitView.toast.enterCommitMessage"));return}const V=F.map(re=>re.path).sort();if(V.length===0){ue.error(o("gitView.toast.selectFileToCommit"));return}T(L.pushAfter?"commitAndPush":"commit");try{if(await r.createGitCommit(i,D.trim(),{files:V}),ue.success(o("gitView.toast.commitCreated")),k(""),$([]),L.pushAfter){const re=a?.tracking?.split("/")[0],le=te.find(tt=>tt.name===re)??te[0];if(!le)throw new Error(o("mobile.changes.noRemote"));C("sync");const Ce=`${le.name}/`,be=a?.tracking?.startsWith(Ce)?a.tracking.slice(Ce.length):void 0;await r.gitFetch(i,{remote:le.name}),((await r.getGitStatus(i)).behind??0)>0&&await r.gitPull(i,{remote:le.name,branch:be,rebase:!0}),((await r.getGitStatus(i)).ahead??0)>0&&await r.gitPush(i),await oe(!1),await W()}else await oe(!1)}catch(re){ue.error(re instanceof Error?re.message:o("gitView.toast.createCommitFailed"))}finally{T(null),L.pushAfter&&C(null)}},_e=l.useMemo(()=>{const L=[];return F.length>0&&L.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:F,actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:V=>o("gitView.changes.unstageFileAria",{path:V}),onActionFile:V=>{U([V],"unstage")},onActionAll:V=>{U(V,"unstage")},onViewDiff:V=>fe(V,!0),onRevertFile:Ne,showRevertActions:!1,accent:!0}),Q.length>0&&L.push({id:"unstaged",title:o("gitView.changes.title"),entries:Q,actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:V=>o("gitView.changes.stageFileAria",{path:V}),onActionFile:V=>{U([V],"stage")},onActionAll:V=>{U(V,"stage")},onViewDiff:V=>fe(V,!1),onRevertFile:Ne}),L},[Ne,fe,U,F,o,Q]),ve=L=>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:[n?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-primary","aria-label":o("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(se,{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:a?.current||i||""})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:L})]});return i?d&&c===null?ve(t.jsx(Ke,{loading:!0,message:o("gitView.loading.checkingRepository")})):c===!1?ve(t.jsx(Ke,{icon:!0,message:o("gitView.empty.notGitRepository"),description:o("gitView.empty.notGitRepositoryDescription")})):b.type==="diff"?t.jsx(Gl,{path:b.path,diff:ae,fileExists:!!pe,error:X,onBack:()=>P({type:"list"}),onRetry:()=>q(L=>L+1)}):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:[n?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-primary","aria-label":o("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(se,{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:a?.current||i})]}),t.jsx(Ti,{syncAction:j,remotes:te,onFetch:L=>{ie("fetch",L)},onSync:L=>{ie("sync",L)},disabled:R!==null||d,aheadCount:a?.ahead??0,behindCount:a?.behind??0,trackingRemoteName:a?.tracking?.split("/")[0],hasUncommittedChanges:G.length>0})]}),G.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(sa,{groups:_e,diffStats:a?.diffStats,revertingPaths:E,onRevertAll:ke,isRevertingAll:I,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:A})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(na,{stagedCount:F.length,commitMessage:D,onCommitMessageChange:k,generatedHighlights:H,onInsertHighlights:Ie,onGenerateMessage:Be,isGeneratingMessage:N,onCommit:()=>{Ae({pushAfter:!1})},onCommitAndPush:()=>{Ae({pushAfter:!0})},commitAction:R,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Ke,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})})]}):ve(t.jsx(Ke,{message:o("gitView.empty.selectSessionOrDirectory")}))},Ke=n=>{const e=de.c(13),{message:s,description:o,loading:r,icon:i}=n,a=r===void 0?!1:r,c=i===void 0?!1:i;let d;e[0]!==a?(d=a?t.jsx(se,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=a,e[1]=d):d=e[1];let f;e[2]!==c?(f=c?t.jsx(se,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=c,e[3]=f):f=e[3];let u;e[4]!==s?(u=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=u):u=e[5];let m;e[6]!==o?(m=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[6]=o,e[7]=m):m=e[7];let g;return e[8]!==d||e[9]!==f||e[10]!==u||e[11]!==m?(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:[d,f,u,m]})}),e[8]=d,e[9]=f,e[10]=u,e[11]=m,e[12]=g):g=e[12],g},Gl=n=>{const e=de.c(24),{path:s,diff:o,fileExists:r,error:i,onBack:a,onRetry:c}=n,{t:d}=me();let f;e[0]!==s?(f=Uo(s)||"text",e[0]=s,e[1]=f):f=e[1];const u=f;let m;e[2]!==d?(m=d("header.actions.backAria"),e[2]=d,e[3]=m):m=e[3];let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(se,{name:"arrow-left",className:"size-5"}),e[4]=g):g=e[4];let h;e[5]!==a||e[6]!==m?(h=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-primary","aria-label":m,onClick:a,children:g}),e[5]=a,e[6]=m,e[7]=h):h=e[7];let x;e[8]!==s?(x=t.jsx("div",{className:"min-w-0 flex-1 px-2",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s})}),e[8]=s,e[9]=x):x=e[9];let w;e[10]!==h||e[11]!==x?(w=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:[h,x]}),e[10]=h,e[11]=x,e[12]=w):w=e[12];let b;e[13]!==o||e[14]!==i||e[15]!==r||e[16]!==u||e[17]!==c||e[18]!==s||e[19]!==d?(b=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r?i?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:d("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}),t.jsx(xe,{type:"button",size:"sm",variant:"outline",onClick:c,children:d("diffView.actions.retry")})]})}):o?o.isBinary?t.jsx(Ke,{icon:!0,message:d("diffView.binary.unavailable")}):Vo(s)?t.jsx(Ke,{icon:!0,message:d("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(ks,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(ra,{original:o.original,modified:o.modified,language:u,fileName:s,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):t.jsx(Ke,{loading:!0,message:d("diffView.state.loadingDiff")}):t.jsx(Ke,{icon:!0,message:d("mobile.changes.diffDetail.missingTitle"),description:d("mobile.changes.diffDetail.missingDescription")})}),e[13]=o,e[14]=i,e[15]=r,e[16]=u,e[17]=c,e[18]=s,e[19]=d,e[20]=b):b=e[20];let P;return e[21]!==w||e[22]!==b?(P=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[w,b]}),e[21]=w,e[22]=b,e[23]=P):P=e[23],P},Kl=l.lazy(()=>ft(()=>import("./FilesView-BKL6YlKG.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121])).then(n=>({default:n.FilesView}))),Ze=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),Tt=n=>{const e=Ze(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},Hl=n=>{const e=Ze(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},ql=(n,e)=>{const s=Ze(n),o=Ze(e);return!o||s===o?Tt(s):s.startsWith(`${o}/`)?s.slice(o.length+1):s},Yl=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 o of e){if(s<1024||o===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${o}`;s/=1024}return""},Jl=({onClose:n})=>{const{t:e}=me(),{files:s}=js(),o=ao(v=>v.setSelectedPath),r=Ze(Ss()??null),[i,a]=l.useState(()=>({type:"browser",directory:r})),[c,d]=l.useState([]),[f,u]=l.useState(!1),[m,g]=l.useState(null),[h,x]=l.useState(""),[w,b]=l.useState([]),[P,j]=l.useState(!1),C=l.useRef(0);l.useEffect(()=>{r&&a(v=>v.type==="browser"&&v.directory?v:{type:"browser",directory:r})},[r]);const R=i.type==="browser"?i.directory:i.returnDirectory,T=l.useCallback(async v=>{if(!v)return;const A=C.current+1;C.current=A,u(!0),g(null);try{const O=await s.listDirectory(v);if(C.current!==A)return;d(O.entries.slice().sort((z,B)=>z.isDirectory!==B.isDirectory?z.isDirectory?-1:1:z.name.localeCompare(B.name)))}catch(O){if(C.current!==A)return;d([]),g(O instanceof Error?O.message:e("mobile.files.error.listFailed"))}finally{C.current===A&&u(!1)}},[s,e]);l.useEffect(()=>{i.type==="browser"&&T(i.directory)},[T,i]),l.useEffect(()=>{if(i.type!=="browser")return;const v=h.trim();if(!v){b([]),j(!1);return}let A=!1;const O=window.setTimeout(()=>{j(!0),s.search({directory:i.directory,query:v,maxResults:40}).then(z=>{A||b(z)}).catch(()=>{A||b([])}).finally(()=>{A||j(!1)})},250);return()=>{A=!0,window.clearTimeout(O)}},[s,h,i]);const D=v=>{x(""),a({type:"browser",directory:v})},k=v=>{o(r,v),a({type:"file",path:v,returnDirectory:R||r})},E=Ve(v=>v.pendingFileFocusPath),y=Ve(v=>v.pendingFileNavigation);if(l.useEffect(()=>{const v=Ze(y?.path??E??"");!v||!r||v!==r&&!v.startsWith(`${r}/`)||(o(r,v),a({type:"file",path:v,returnDirectory:r}),E&&Ve.getState().setPendingFileFocusPath(null))},[E,y,r,o]),!r)return t.jsx(It,{message:e("mobile.files.empty.noDirectory")});if(i.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-primary","aria-label":e("header.actions.backAria"),onClick:()=>a({type:"browser",directory:i.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(dn,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:Tt(i.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Le,{children:t.jsx(l.Suspense,{fallback:t.jsx(It,{loading:!0,message:e("filesView.state.loading")}),children:t.jsx(Kl,{mode:"editor-only"})})})})]});const I=i.directory===r?e("mobile.files.rootDirectory"):Tt(i.directory),M=h.trim()?w:[],N=Hl(i.directory),S=i.directory!==r&&N!==null&&(N===r||N.startsWith(`${r}/`)),H=S&&!h.trim(),$=S?N:null;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 px-3 text-foreground",children:[n?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-primary","aria-label":e("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(cr,{className:"size-5"})}):null,H&&$?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-primary","aria-label":e("mobile.files.backToParentAria",{name:Tt($)}),onClick:()=>D($),style:{touchAction:"manipulation"},children:t.jsx(dn,{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:I})}),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-primary","aria-label":e("mobile.files.refreshAria"),onClick:()=>{T(i.directory)},style:{touchAction:"manipulation"},children:t.jsx(Xi,{className:Z("size-5",f&&"animate-spin")})})]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(lr,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(ws,{value:h,onChange:v=>x(v.target.value),placeholder:e("mobile.files.search.placeholder"),className:"h-11 pl-9"})]})}),t.jsx(ks,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:m?t.jsx(It,{message:m}):h.trim()?t.jsx(Xl,{results:M,isSearching:P,onOpenFile:k}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[c.length===0&&!f?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:e("mobile.files.empty.directory")}):null,c.map(v=>t.jsx(Dr,{name:v.name,path:v.path,directory:v.isDirectory,meta:v.isDirectory?void 0:Yl(v.size),onClick:()=>v.isDirectory?D(v.path):k(v.path)},v.path))]})})]})},Dr=n=>{const e=de.c(16),{name:s,path:o,directory:r,meta:i,onClick:a}=n;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={touchAction:"manipulation"},e[0]=c):c=e[0];let d;e[1]!==r||e[2]!==o?(d=r?t.jsx(Qi,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(Go,{filePath:o,className:"size-5 shrink-0"}),e[1]=r,e[2]=o,e[3]=d):d=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 u;e[6]!==i?(u=i?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,e[6]=i,e[7]=u):u=e[7];let m;e[8]!==r?(m=r?t.jsx(Zi,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=r,e[9]=m):m=e[9];let g;return e[10]!==a||e[11]!==d||e[12]!==f||e[13]!==u||e[14]!==m?(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-primary focus-visible:ring-inset",onClick:a,style:c,children:[d,f,u,m]}),e[10]=a,e[11]=d,e[12]=f,e[13]=u,e[14]=m,e[15]=g):g=e[15],g},Xl=n=>{const e=de.c(10),{results:s,isSearching:o,onOpenFile:r}=n,{t:i}=me(),a=Ze(Ss()??null);if(o){let u;e[0]!==i?(u=i("common.loading"),e[0]=i,e[1]=u):u=e[1];let m;return e[2]!==u?(m=t.jsx(It,{loading:!0,message:u}),e[2]=u,e[3]=m):m=e[3],m}if(s.length===0){let u;e[4]!==i?(u=i("mobile.files.search.empty"),e[4]=i,e[5]=u):u=e[5];let m;return e[6]!==u?(m=t.jsx(It,{message:u}),e[6]=u,e[7]=m):m=e[7],m}const c="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",d=s.map(u=>t.jsx(Dr,{name:Tt(u.path),path:u.path,directory:!1,meta:ql(u.path,a),onClick:()=>r(u.path)},u.path));let f;return e[8]!==d?(f=t.jsx("div",{className:c,children:d}),e[8]=d,e[9]=f):f=e[9],f},It=n=>{const e=de.c(7),{message:s,loading:o}=n,r=o===void 0?!1:o;let i;e[0]!==r?(i=r?t.jsx(ea,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(ta,{className:"size-6 text-muted-foreground"}),e[0]=r,e[1]=i):i=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 c;return e[4]!==i||e[5]!==a?(c=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:[i,a]})}),e[4]=i,e[5]=a,e[6]=c):c=e[6],c},Ln="mobile-surface-root",Ql=16,Bn=320,Zl="cubic-bezier(0.22, 1, 0.36, 1)",ec=n=>{const e=de.c(36),{onOpenMcpSettings:s}=n,{t:o}=me(),[r,i]=l.useState(!1),a=dt(tc),c=Ho(sc),d=Ft(nc);let f;e[0]!==a||e[1]!==r||e[2]!==d||e[3]!==c?(f=()=>{if(r)return;i(!0);const I=new Promise(rc);Promise.all([c({directory:a||null,silent:!0}),d({force:!0}),I]).finally(()=>i(!1))},e[0]=a,e[1]=r,e[2]=d,e[3]=c,e[4]=f):f=e[4];const u=f;let m;e[5]!==o?(m=o("settings.mcp.sidebar.actions.addServerTitle"),e[5]=o,e[6]=m):m=e[6];let g;e[7]!==o?(g=o("settings.mcp.sidebar.actions.addServerTitle"),e[7]=o,e[8]=g):g=e[8];let h,x;e[9]===Symbol.for("react.memo_cache_sentinel")?(h={touchAction:"manipulation"},x=t.jsx(se,{name:"add",className:"size-5"}),e[9]=h,e[10]=x):(h=e[9],x=e[10]);let w;e[11]!==s||e[12]!==m||e[13]!==g?(w=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-primary",onClick:s,"aria-label":m,title:g,style:h,children:x}),e[11]=s,e[12]=m,e[13]=g,e[14]=w):w=e[14];let b;e[15]!==o?(b=o("mcpDropdown.actions.refreshAria"),e[15]=o,e[16]=b):b=e[16];let P;e[17]!==o?(P=o("mcpDropdown.actions.refreshAria"),e[17]=o,e[18]=P):P=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j={touchAction:"manipulation"},e[19]=j):j=e[19];const C=r&&"animate-spin";let R;e[20]!==C?(R=Z("size-5",C),e[20]=C,e[21]=R):R=e[21];let T;e[22]!==R?(T=t.jsx(se,{name:"refresh",className:R}),e[22]=R,e[23]=T):T=e[23];let D;e[24]!==r||e[25]!==u||e[26]!==T||e[27]!==b||e[28]!==P?(D=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-primary",onClick:u,disabled:r,"aria-label":b,title:P,style:j,children:T}),e[24]=r,e[25]=u,e[26]=T,e[27]=b,e[28]=P,e[29]=D):D=e[29];let k;e[30]!==D||e[31]!==w?(k=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[w,D]}),e[30]=D,e[31]=w,e[32]=k):k=e[32];let E;e[33]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Di,{active:!0,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=E):E=e[33];let y;return e[34]!==k?(y=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[k,E]}),e[34]=k,e[35]=y):y=e[35],y},$n=({open:n,onClose:e,tab:s,onTabChange:o,pendingChangesDiff:r,onOpenPlan:i,onOpenMcpSettings:a,variant:c="drawer"})=>{const{t:d}=me(),f=l.useRef(null),[u,m]=l.useState(!1),[g,h]=l.useState(n),x=l.useRef(e);l.useEffect(()=>{x.current=e},[e]);const w=l.useRef(s);l.useEffect(()=>{w.current=s},[s]);const[b,P]=l.useState(()=>new Set);if(l.useEffect(()=>{n&&P(R=>{if(R.has(s))return R;const T=new Set(R);return T.add(s),T})},[n,s]),typeof document<"u"&&!f.current){let R=document.getElementById(Ln);R||(R=document.createElement("div"),R.id=Ln,document.body.appendChild(R)),f.current=R}if(l.useEffect(()=>{if(n){h(!0);const T=window.setTimeout(()=>m(!0),Ql);return()=>window.clearTimeout(T)}m(!1);const R=window.setTimeout(()=>h(!1),Bn+40);return()=>window.clearTimeout(R)},[n]),l.useEffect(()=>{if(!n)return;const R=document.body.style.overflow;c==="drawer"&&(document.body.style.overflow="hidden");const T=D=>{D.key==="Escape"&&w.current!=="terminal"&&x.current()};return document.addEventListener("keydown",T),()=>{c==="drawer"&&(document.body.style.overflow=R),document.removeEventListener("keydown",T)}},[n,c]),c==="drawer"&&!f.current)return null;const j=[{id:"changes",label:d("mobile.menu.changes"),icon:t.jsx(se,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:d("mobile.menu.files"),icon:t.jsx(se,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:d("mobile.menu.terminal"),icon:t.jsx(se,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:d("contextRail.surface.notes"),icon:t.jsx(se,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:d("mobile.menu.mcp"),icon:t.jsx(Ko,{className:"h-3.5 w-3.5"})}],C=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:g?t.jsx(Ii,{items:j,activeId:s,onSelect:R=>o(R),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-primary","aria-label":d("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(se,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[b.has("changes")?t.jsx("div",{className:Z("h-full",s!=="changes"&&"hidden"),children:t.jsx(Le,{children:t.jsx(Vl,{initialDiffPath:r?.path??null,initialDiffStaged:r?.staged===!0})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,b.has("files")?t.jsx("div",{className:Z("h-full",s!=="files"&&"hidden"),children:t.jsx(Le,{children:t.jsx(Jl,{})})}):null,b.has("terminal")?t.jsx("div",{className:Z("h-full",s!=="terminal"&&"hidden"),children:t.jsx(Le,{children:t.jsx(Ai,{visible:n&&s==="terminal"})})}):null,b.has("notes")?t.jsx("div",{className:Z("h-full",s!=="notes"&&"hidden"),children:t.jsx(Le,{children:t.jsx(_i,{onActionComplete:e,onOpenPlan:i})})}):null,b.has("mcp")?t.jsx("div",{className:Z("h-full",s!=="mcp"&&"hidden"),children:t.jsx(Le,{children:t.jsx(ec,{onOpenMcpSettings:a})})}):null]})]});return c==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:C}):ut.createPortal(t.jsx("section",{role:"dialog","aria-modal":"true","aria-label":d("mobile.header.openWorkspaceAria"),"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:u?"none":"translateX(100%)",transition:`transform ${Bn}ms ${Zl}`,visibility:g?"visible":"hidden",pointerEvents:n?"auto":"none"},children:C}),f.current)};function tc(n){return n.currentDirectory}function sc(n){return n.refresh}function nc(n){return n.loadMcpConfigs}function rc(n){return window.setTimeout(n,500)}function oc(n){const e=de.c(4),s=2500,{uiFont:o}=qo(),[r,i]=l.useState(!1);let a,c;return e[0]!==s||e[1]!==o?(a=()=>{let d=!1;const f=()=>{d||i(!0)},u=()=>{requestAnimationFrame(()=>requestAnimationFrame(f))},m=Promise.all([Yo(o).catch(uc),document.fonts?.ready?.then(cc).catch(lc)??Promise.resolve(),oa.catch(ac)]).then(ic),g=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([m,g]).then(u),()=>{d=!0}},c=[o,s],e[0]=s,e[1]=o,e[2]=a,e[3]=c):(a=e[2],c=e[3]),l.useEffect(a,c),r}function ic(){}function ac(){}function lc(){}function cc(){}function uc(){}const dc="openchamber",fc=n=>n.replace(/^\/+|\/+$/g,""),mc=n=>{const e=fc(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function pc(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${dc}:`)return null;const s=mc(e),o=(s[0]??"").toLowerCase(),r=s.slice(1),i=e.searchParams;switch(o){case"session":{const a=r[0]||i.get("id")||"";return a?{type:"session",sessionId:a,directory:i.get("dir")??void 0}:null}case"new":case"new-session":return{type:"new-session",directory:i.get("dir")??void 0,projectId:i.get("project")??void 0,agent:i.get("agent")??void 0,model:i.get("model")??void 0};case"sessions":{const a=i.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]||i.get("section")||void 0};case"changes":return{type:"changes",path:r.join("/")||i.get("path")||void 0,staged:i.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 Me={},Mr=!1,Pt=null;const hc=n=>{switch(n.type){case"session":return je.getState().setCurrentSession(n.sessionId,n.directory??null),!0;case"new-session":{const e=je.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 Me.openSessions?(Me.openSessions(n.filter),!0):!1;case"status":return Me.openSessions?(Me.openSessions(),!0):!1;case"view":return Me.openView?(Me.openView(n.target),!0):!1;case"changes":return Me.openChanges?(Me.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return Me.openSettings?(Me.openSettings(n.section),!0):!1}},Gs=()=>{if(!Mr||!Pt)return;const n=Pt;Pt=null,hc(n)||(Pt=n)},zr=n=>{Pt=n,Gs()},Fn=n=>{const e=pc(n);e&&zr(e)},gc=n=>{Mr=n,Gs()},bc=n=>{const e=de.c(3);let s,o;e[0]!==n?(s=()=>(Me=n,Gs(),()=>{Me===n&&(Me={})}),o=[n],e[0]=n,e[1]=s,e[2]=o):(s=e[1],o=e[2]),l.useEffect(s,o)},xc=n=>{const{ready:e}=n;l.useEffect(()=>{gc(e)},[e]),l.useEffect(()=>{if(!Te())return;let s=!1;const o=[];return ft(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([122,4,123])).then(async({App:r})=>{if(s)return;const i=await r.addListener("appUrlOpen",a=>{Fn(a?.url)});if(s){i.remove();return}o.push(()=>{i.remove()})}).catch(()=>{}),ft(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([124,123])).then(async({PushNotifications:r})=>{if(s)return;const i=await r.addListener("pushNotificationActionPerformed",a=>{const c=a?.notification?.data,d=typeof c?.url=="string"?c.url:typeof c?.deeplink=="string"?c.deeplink:void 0;if(d){Fn(d);return}const f=typeof c?.sessionId=="string"?c.sessionId:void 0;f&&zr({type:"session",sessionId:f})});if(s){i.remove();return}o.push(()=>{i.remove()})}).catch(()=>{}),()=>{s=!0,o.forEach(r=>r())}},[])},yc=32,vc=80,wc=64,jc=.7,kc=(n,e)=>{const s=l.useRef(e);s.current=e,l.useEffect(()=>{const o=n.current;if(!o)return;const i=window.Capacitor?.getPlatform?.()==="android"?vc:yc;let a=!1,c=!1,d=0,f=0;const u=g=>{if(g.touches.length!==1){a=!1;return}const h=g.touches[0],x=o.clientWidth,w=h.clientX<=i,b=h.clientX>=x-i;a=w||b,c=w,d=h.clientX,f=h.clientY},m=g=>{if(!a)return;a=!1;const h=g.changedTouches[0];if(!h)return;const x=h.clientX-d,w=h.clientY-f;Math.abs(x)<wc||Math.abs(w)>Math.abs(x)*jc||c&&x<=0||!c&&x>=0||(c?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return o.addEventListener("touchstart",u,{passive:!0}),o.addEventListener("touchend",m,{passive:!0}),()=>{o.removeEventListener("touchstart",u),o.removeEventListener("touchend",m)}},[n])},Sc=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},Nc=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},Cc=n=>{const{enabled:e}=n,s=Ve(r=>r.nativeNotificationsEnabled),o=l.useRef(null);l.useEffect(()=>{if(!e||!s||!Nc())return;let r=!1;const i=[];return ft(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([124,123])).then(async({PushNotifications:a})=>{if(r)return;let c=await a.checkPermissions().catch(()=>null);if(c?.receive!=="granted"&&(c=await a.requestPermissions().catch(()=>null)),c?.receive!=="granted")return;const d=await a.addListener("registration",u=>{o.current=u.value,rn()?.push?.registerApnsToken?.({token:u.value,platform:Gn(),environment:Sc()})}),f=await a.addListener("registrationError",u=>{console.warn("[Push] APNs registration error:",u)});if(await a.register().catch(()=>{}),r){d.remove(),f.remove();return}i.push(()=>{d.remove()},()=>{f.remove()})}).catch(()=>{}),()=>{r=!0,i.forEach(a=>a())}},[e,s]),l.useEffect(()=>{if(s)return;const r=o.current;if(!r)return;o.current=null,rn()?.push?.unregisterApnsToken?.({token:r})},[s])},Wn=n=>{const e=de.c(12),{side:s,isResizing:o,ariaLabel:r,handleProps:i}=n,a=s==="left"?"right-0":"left-0";let c;e[0]!==a?(c=Z("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",a),e[0]=a,e[1]=c):c=e[1];const d=s==="left"?"right-0":"left-0",f=o&&"bg-[var(--interactive-border)]";let u;e[2]!==d||e[3]!==f?(u=Z("absolute inset-y-0 w-[3px] transition-colors",d,f),e[2]=d,e[3]=f,e[4]=u):u=e[4];let m;e[5]!==u?(m=t.jsx("div",{className:u}),e[5]=u,e[6]=m):m=e[6];let g;return e[7]!==r||e[8]!==i||e[9]!==c||e[10]!==m?(g=t.jsx("div",{className:c,role:"separator","aria-orientation":"vertical","aria-label":r,...i,children:m}),e[7]=r,e[8]=i,e[9]=c,e[10]=m,e[11]=g):g=e[11],g},Ec=320,Rc=380,Un=280,Pc=560,Tc=900;function Vn(n,e,s,o){const r=de.c(23),i=o===void 0?Pc:o,a=l.useRef(null);let c;r[0]!==s||r[1]!==i||r[2]!==e?(c=()=>{if(typeof window>"u")return s;const S=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(S)?Math.min(i,Math.max(Un,S)):s},r[0]=s,r[1]=i,r[2]=e,r[3]=c):c=r[3];const[d,f]=l.useState(c),[u,m]=l.useState(!1),g=l.useRef(0),h=l.useRef(d),x=l.useRef(null),w=l.useRef(null);let b;r[4]!==i?(b=S=>Math.min(i,Math.max(Un,Math.round(S))),r[4]=i,r[5]=b):b=r[5];const P=b;let j;r[6]===Symbol.for("react.memo_cache_sentinel")?(j=S=>{const H=a.current;H&&(H.style.width=`${S}px`,H.style.minWidth=`${S}px`,H.style.maxWidth=`${S}px`,H.style.setProperty("--oc-ipad-sidebar-width",`${S}px`))},r[6]=j):j=r[6];const C=j;let R;r[7]!==d?(R=S=>{try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}w.current=S.pointerId,g.current=S.clientX,h.current=d,x.current=d,m(!0),S.preventDefault()},r[7]=d,r[8]=R):R=r[8];const T=R;let D;r[9]!==P||r[10]!==n?(D=S=>{if(w.current!==S.pointerId)return;const H=S.clientX-g.current,$=P(h.current+(n==="left"?H:-H));x.current!==$&&(x.current=$,C($))},r[9]=P,r[10]=n,r[11]=D):D=r[11];const k=D;let E;r[12]!==P||r[13]!==e?(E=S=>{if(w.current!==S.pointerId)return;try{S.currentTarget.releasePointerCapture(S.pointerId)}catch{}const H=P(x.current??h.current);w.current=null,x.current=null,m(!1),f(H);try{window.localStorage.setItem(e,String(H))}catch{}},r[12]=P,r[13]=e,r[14]=E):E=r[14];const y=E;let I;r[15]!==T||r[16]!==y||r[17]!==k?(I={onPointerDown:T,onPointerMove:k,onPointerUp:y,onPointerCancel:y},r[15]=T,r[16]=y,r[17]=k,r[18]=I):I=r[18];const M=I;let N;return r[19]!==M||r[20]!==u||r[21]!==d?(N={asideRef:a,width:d,isResizing:u,handleProps:M},r[19]=M,r[20]=u,r[21]=d,r[22]=N):N=r[22],N}const Ic=["general","appearance","chat","notifications","sessions","git","magic-prompts","behavior","mcp","providers","usage","voice","about"],Ac=1e3,_c=({onActiveConnectionDeleted:n})=>{const{t:e}=me(),[s,o]=l.useState(!1),[r,i]=l.useState(null),[a,c]=l.useState(!1),[d,f]=l.useState("changes"),[u,m]=l.useState(null),[g,h]=l.useState("nav"),[x,w]=l.useState(null),b=Ve(U=>U.setSettingsPage),P=Ve(U=>U.wideChatLayoutEnabled),j=at(U=>U.available),C=at(U=>U.runtimeType),R=l.useMemo(()=>or(),[]),T=Ft(U=>U.mcpServers),D=Ft(U=>U.setMcpDraft),k=Ft(U=>U.setSelectedMcp),E=l.useCallback(()=>{i(null),m(null)},[]),y=l.useCallback(U=>{i(U)},[]),I=l.useCallback(()=>{c(!1)},[]),M=l.useCallback(U=>{h(U),y("settings")},[y]),{enabled:N,roomyForPanels:S}=ys(),$=fi()==="portrait",v=mi(),[A,O]=l.useState(()=>pi().roomyForPanels),z=l.useCallback(()=>{O(U=>!U)},[]);l.useEffect(()=>{N||O(!1)},[N]);const B=l.useCallback(()=>{w(null),f("files"),c(!0)},[]),ee=l.useCallback((U=null)=>{w(U),f("changes"),c(!0)},[]),X=Vn("left","openchamber.ipad.leftSidebarWidth",Ec),_=Vn("right","openchamber.ipad.rightSidebarWidth",Rc,Tc),J=S,q=J&&a?_.width:0,G=N&&A?X.width:0;l.useEffect(()=>{if(typeof document>"u")return;const U=document.documentElement;return U.style.setProperty("--oc-chat-inset-left",`${G}px`),U.style.setProperty("--oc-chat-inset-right",`${q}px`),()=>{U.style.removeProperty("--oc-chat-inset-left"),U.style.removeProperty("--oc-chat-inset-right")}},[G,q]),l.useEffect(()=>{if(typeof document>"u")return;const U=document.documentElement;return U.classList.toggle("wide-chat-layout",P),()=>U.classList.remove("wide-chat-layout")},[P]),l.useEffect(()=>{if(typeof document>"u")return;const U=N&&($||v),fe=document.documentElement;return fe.classList.toggle("oc-keep-draft-starters",U),()=>fe.classList.remove("oc-keep-draft-starters")},[v,N,$]);const F=l.useMemo(()=>({openChanges:({diffPath:U,staged:fe}={})=>{ee(U?{path:U,staged:fe===!0}:null)},openFiles:()=>B(),openSettings:()=>M("nav")}),[ee,B,M]),Q=l.useMemo(()=>({openSessions:()=>{N?O(!0):o(!0)},openView:U=>{if(U==="files"){B();return}if(U==="mcp"){f("mcp"),c(!0);return}y(U)},openChanges:({path:U,staged:fe}={})=>{ee(U?{path:U,staged:fe===!0}:null)},openSettings:U=>{U&&b(U),M(U?"page-content":"nav")}}),[N,ee,B,M,y,b]);bc(Q);const te=l.useRef(null);kc(te,{onLeftEdgeSwipe:()=>{N?O(!0):o(!0)},onRightEdgeSwipe:()=>c(!0)});const ae=l.useCallback(()=>u?(m(null),!0):r?(E(),!0):a?(I(),!0):s?(o(!1),!0):!1,[r,E,I,u,s,a]);hi(ae);const pe=!R&&j&&(C==="desktop"||C==="web"),oe=N?"dialog":"fullscreen",W=l.useMemo(()=>({instanceLabel:R?Nt():null,onOpenInstances:R?()=>y("instances"):void 0,onOpenSettings:()=>M("nav"),onOpenUpdate:pe?()=>y("update"):void 0}),[M,y,R,pe]),ie=l.useCallback(()=>{const U="new-mcp-server";let fe=U,Ne=1;for(;T.some(Ie=>Ie.name===fe);)fe=`${U}-${Ne}`,Ne+=1;D({name:fe,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",timeout:"",enabled:!0}),k(fe),b("mcp"),M("page-content")},[T,M,D,k,b]);return t.jsx(gi,{actions:F,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:[N?t.jsxs("aside",{ref:X.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",!A&&"border-r-0"),style:{width:A?X.width:0,minWidth:A?X.width:0,maxWidth:A?X.width:0,"--oc-ipad-sidebar-width":`${X.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:X.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!A,"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",X.isResizing&&"pointer-events-none",!A&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Le,{children:t.jsx(_n,{open:!0,variant:"sidebar",onOpenChange:U=>{!U&&!S&&O(!1)},footer:W})})}),A?t.jsx(Wn,{side:"left",isResizing:X.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:X.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(pl,{onOpenSessions:()=>N?z():o(!0),onOpenWorkspace:()=>c(!0),compactTitle:N}),t.jsx("main",{ref:te,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(Le,{children:t.jsx(Fi,{})})})})]}),N?null:t.jsx(_n,{open:s,onOpenChange:o,footer:W}),N?t.jsxs("aside",{ref:_.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",!q&&"border-l-0"),style:{width:q,minWidth:q,maxWidth:q,"--oc-ipad-sidebar-width":`${_.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:_.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!q,"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",_.isResizing&&"pointer-events-none",!q&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Le,{children:t.jsx($n,{open:a,onClose:I,tab:d,onTabChange:f,pendingChangesDiff:x,onOpenPlan:m,onOpenMcpSettings:ie,variant:J?"panel":"drawer"})})}),q?t.jsx(Wn,{side:"right",isResizing:_.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:_.handleProps}):null]}):t.jsx($n,{open:a,onClose:I,tab:d,onTabChange:f,pendingChangesDiff:x,onOpenPlan:m,onOpenMcpSettings:ie}),u?t.jsx(Rt,{open:!0,variant:oe,onClose:()=>m(null),ariaLabel:u.title,title:u.title,children:t.jsx(Le,{children:t.jsx(Gi,{targetPath:u.path,onNavigatedToChat:()=>{E(),I()}})})}):null,r==="instances"&&R?t.jsx(Rt,{open:!0,variant:oe,dialogAlign:"app",onClose:E,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(xl,{onConnect:E,onActiveConnectionDeleted:n})}):null,r==="settings"?t.jsx(Rt,{open:!0,variant:oe,dialogAlign:"app",onClose:E,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Le,{children:t.jsx(Ui,{forceMobile:!0,isWindowed:!0,initialMobileStage:g,visiblePageSlugs:Ic.filter(U=>!(R&&U==="about")),onClose:E})})}):null,r==="update"?t.jsx(Rt,{open:!0,variant:oe,dialogAlign:"app",onClose:E,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Le,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(Vi,{initialUpdateDialogOpen:!0})})})}):null]})})};function Dc({apis:n}){const{t:e}=me(),s=ze(_=>_.initializeApp),o=ze(_=>_.isInitialized),r=ze(_=>_.isConnected),i=ze(_=>_.connectionPhase),a=ze(_=>_.providers.length),c=ze(_=>_.agents.length),d=ze(_=>_.loadProviders),f=ze(_=>_.loadAgents),u=dt(_=>_.currentDirectory),m=je(_=>_.error),g=je(_=>_.clearError),h=Ve(_=>_.setIsMobile),x=Jo(_=>_.refreshStatus),w=Xo(_=>_.setPlanModeEnabled),b=Oe(_=>_.projects),[P,j]=l.useState(0),[C,R]=l.useState(0),[T,D]=l.useState(!1),[k,E]=l.useState("pending"),[y,I]=l.useState(null),M=l.useMemo(()=>Nt(),[]),[,N]=l.useReducer(_=>_+1,0),S=l.useMemo(()=>or(),[]),H=l.useRef(0),$=l.useRef(0),v=l.useCallback(()=>{const _=Ue(),J=$.current+1;if($.current=J,!_){wt("resume:auto-connect",{}),jt();return}wt("resume:reprobe",{});const q=()=>{s(),x(n.github,{force:!0}),a===0&&d({source:"mobileApp:nativeResume"}),c===0&&f({source:"mobileApp:nativeResume"})},G=Q=>{wt("resume:disconnect",{reason:Q}),it({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),j(te=>te+1)};Ut().then(Q=>{if($.current===J){if(Q==="no-connection"){G("no-connection");return}if(Q==="needs-login"){I({kind:"auth-expired",label:Nt()??""}),G("needs-login");return}if(Q==="unreachable"){const te=[4e3,1e4],ae=pe=>{window.setTimeout(()=>{if($.current!==J)return;const oe=pe===te.length-1;Ut({fast:!oe}).then(W=>{if($.current===J&&W!=="switched"){if(W==="unchanged"){q();return}if(W==="needs-login"){I({kind:"auth-expired",label:Nt()??""}),G("retry-needs-login");return}if(!oe){ae(pe+1);return}G(`retry-${W}`)}})},te[pe])};ae(0);return}Q!=="switched"&&q()}});const F=Date.now();F-H.current>=Ac&&(H.current=F,window.dispatchEvent(new Event("openchamber:system-resume")))},[c,n.github,s,f,d,a,x]);Qo(),Zo(v),l.useEffect(()=>{if(!S)return;let _;const J=()=>{window.clearTimeout(_),_=window.setTimeout(()=>v(),1500)};return window.addEventListener("online",J),()=>{window.removeEventListener("online",J),window.clearTimeout(_)}},[S,v]),l.useEffect(()=>(on(n),()=>on(null)),[n]),l.useEffect(()=>lo(_=>{if(wt("endpoint:changed",{runtimeKey:_.runtimeKey||"none",previousRuntimeKey:_.previousRuntimeKey||"none",connected:!!_.apiBaseUrl}),!!_.runtimeKey&&_.runtimeKey===_.previousRuntimeKey){Mi(),N();return}zi(_),R(q=>q+1),j(q=>q+1)}),[]),l.useEffect(()=>{if(!S||r||Ue()){E("done");return}let _=!1;return E("attempting"),(async()=>{const J=await jt().catch(()=>({status:"no-candidate"}));_||(J.status==="unreachable"?I({kind:"unreachable",label:J.label}):J.status==="needs-login"&&I({kind:"auth-expired",label:J.label}),E("done"),J.status==="unreachable"&&jt({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{_=!0}},[]),l.useEffect(()=>{if(!S||!Ue())return;let _=!1;const J=q=>{wt("cold-launch:drop",{kind:q?.kind??"unknown"}),q&&I(q),it({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),j(G=>G+1)};return Ut().then(async q=>{if(_||q==="switched"||q==="unchanged")return;const G=Nt();if(q==="needs-login"){J({kind:"auth-expired",label:G??""});return}if(q==="unreachable"){J(G?{kind:"unreachable",label:G}:null),jt({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const F=await jt().catch(()=>({status:"no-candidate"}));_||F.status==="connected"||(F.status==="needs-login"?J({kind:"auth-expired",label:F.label}):F.status==="unreachable"?J({kind:"unreachable",label:F.label}):J(null))}),()=>{_=!0}},[]),l.useEffect(()=>{h(!0)},[h]),l.useEffect(()=>{S&&!Ue()||s()},[P,s,S]),l.useEffect(()=>{r&&(a===0&&d({source:"mobileApp:recovery"}),c===0&&f({source:"mobileApp:recovery"}))},[c,r,f,d,a]);const A=l.useRef(!1),[O,z]=l.useState(S);l.useEffect(()=>{if(!S||!r||A.current)return;if(je.getState().currentSessionId){A.current=!0,z(!1);return}const _=bt(),J=ei(_);if(!J){A.current=!0,z(!1);return}let q=!1;const G=window.setTimeout(()=>z(!1),6e3);return(async()=>{const F=await vs().catch(()=>null);if(q)return;if(!F){z(!1);return}A.current=!0;const Q=F.activeSessions.find(ae=>ae.id===J.sessionId);if(!Q){ti(_),z(!1);return}const te=je.getState();te.currentSessionId||te.setCurrentSession(Q.id,xs(Q)??J.directory??void 0),z(!1)})(),()=>{q=!0,window.clearTimeout(G)}},[P,r,S]),l.useEffect(()=>{r&&an.setDirectory(u)},[u,r]),l.useEffect(()=>{r&&x(n.github,{force:!0})},[n.github,r,x]),l.useEffect(()=>{if(!r||b.length===0)return;let _=!1;return(async()=>{const q=new Map(je.getState().availableWorktreesByProject);if(await Promise.all(b.map(async Q=>{const te=Q.path.replace(/\\/g,"/").replace(/\/+$/,"");if(te)try{if(!(We.getState().directories.get(te)?.isGitRepo??await ft(()=>import("./useAppFontEffects-BikB6enL.js").then(W=>W.hu),__vite__mapDeps([8,1,2,3,4,5,6,7,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])).then(W=>W.checkIsGitRepository(te))))return;const oe=await nr({id:Q.id,path:te});if(_)return;q.set(te,oe)}catch{}})),_)return;const G=rr(b,q),F=je.getState().availableWorktreesByProject;di(G,F)||je.setState({availableWorktrees:[...G.values()].flat(),availableWorktreesByProject:G})})(),()=>{_=!0}},[r,b]),l.useEffect(()=>{let _=!1;return(async()=>{const q=await gs("/health",{method:"GET"}).catch(()=>null);if(!q||!q.ok||_)return;const G=await q.json().catch(()=>null);if(!G||_)return;const F=G.planModeExperimentalEnabled;w(F===!0||F===1||F==="1"||F==="true")})(),()=>{_=!0}},[w]),l.useEffect(()=>{if(!m)return;const _=window.setTimeout(()=>g(),5e3);return()=>window.clearTimeout(_)},[g,m]),l.useEffect(()=>{if(!(!r&&(S?!!Ue():!0))){D(!1);return}const J=window.setTimeout(()=>{D(!0)},S?4e3:8e3);return()=>window.clearTimeout(J)},[r,S,P,C]),si(),ni({enabled:!0}),Oi(),ri(),Li(),Cc({enabled:S&&r}),xc({ready:S&&r&&o});const B=oc(),ee=!r&&i==="reconnecting";if(!B)return t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(qe,{width:120,height:120,isAnimated:!0})});const X=!!Ue();return S&&(!X||!r&&!ee)?X?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:"flex max-w-sm flex-col items-center gap-4",children:[t.jsx(qe,{width:120,height:120,isAnimated:!T}),T?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("mobile.connect.recovery.description")})]}),t.jsx(xe,{type:"button",variant:"outline",onClick:()=>{it({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),j(_=>_+1)},children:e("mobile.connect.cancelPassword")})]}):null]})}):k!=="done"?t.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-background text-foreground",children:[t.jsx(qe,{width:120,height:120,isAnimated:!0}),M?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:e("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[M,t.jsx(oi,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(Za,{onConnected:()=>j(_=>_+1),notice:y})}):!r&&!ee?T?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:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("sessionAuth.error.networkDescription")})]})}):t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(qe,{width:120,height:120,isAnimated:!0})}):t.jsx(Le,{children:t.jsx(ii,{sdk:an.getSdkClient(),directory:u||"",children:t.jsx(ai,{apis:n,children:t.jsx(li,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[S&&O?t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background",children:t.jsx(qe,{width:120,height:120,isAnimated:!0})}):null,t.jsx(ci,{embeddedBackgroundWorkEnabled:o}),t.jsx(Bi,{}),t.jsx(pa,{}),t.jsx(_c,{onActiveConnectionDeleted:()=>{it({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),j(_=>_+1)}}),t.jsx(ui,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),o?t.jsx($i,{}):null]})})})},C)})}const Mc=()=>{ki(),co().then(()=>{Promise.all([uo(),Si()]).catch(n=>{console.error("[mobile-main] settings init failed:",n)}),Ni(),Ci(),Ei()}).catch(n=>{console.error("[mobile-main] appearance init failed:",n)}).finally(()=>{ia()})};function nf(n){window.__OPENCHAMBER_SURFACE__="mobile",bi(),Mc(),ma(),xi();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const o=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",r=o?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,i=t.jsx(Dc,{apis:r});no.createRoot(e).render(t.jsx(ls.StrictMode,{children:t.jsx(yi,{children:t.jsx(vi,{children:t.jsx(wi,{children:t.jsx(Wi,{children:o?i:t.jsx(ji,{children:i})})})})})}))}export{nf as renderMobileApp};
25
+ `)}`.trim()),$([])},[]),Be=l.useCallback(async()=>{if(!i)return;const B=F.map(V=>V.path).sort();if(B.length===0){ue.error(o("gitView.toast.selectFileToDescribe"));return}S(!0);try{const{message:V}=await Uo(i,B);k(V.subject?.trim()??""),$(Array.isArray(V.highlights)?V.highlights:[])}catch(V){ue.error(V instanceof Error?V.message:o("gitView.toast.generateCommitMessageFailed"))}finally{S(!1)}},[i,F,o]),Ae=async(B={})=>{if(!i)return;if(!D.trim()){ue.error(o("gitView.toast.enterCommitMessage"));return}const V=F.map(re=>re.path).sort();if(V.length===0){ue.error(o("gitView.toast.selectFileToCommit"));return}T(B.pushAfter?"commitAndPush":"commit");try{if(await r.createGitCommit(i,D.trim(),{files:V}),ue.success(o("gitView.toast.commitCreated")),k(""),$([]),B.pushAfter){const re=a?.tracking?.split("/")[0],le=te.find(tt=>tt.name===re)??te[0];if(!le)throw new Error(o("mobile.changes.noRemote"));C("sync");const Ce=`${le.name}/`,be=a?.tracking?.startsWith(Ce)?a.tracking.slice(Ce.length):void 0;await r.gitFetch(i,{remote:le.name}),((await r.getGitStatus(i)).behind??0)>0&&await r.gitPull(i,{remote:le.name,branch:be,rebase:!0}),((await r.getGitStatus(i)).ahead??0)>0&&await r.gitPush(i),await oe(!1),await W()}else await oe(!1)}catch(re){ue.error(re instanceof Error?re.message:o("gitView.toast.createCommitFailed"))}finally{T(null),B.pushAfter&&C(null)}},_e=l.useMemo(()=>{const B=[];return F.length>0&&B.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:F,actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:V=>o("gitView.changes.unstageFileAria",{path:V}),onActionFile:V=>{U([V],"unstage")},onActionAll:V=>{U(V,"unstage")},onViewDiff:V=>fe(V,!0),onRevertFile:Ne,showRevertActions:!1,accent:!0}),Q.length>0&&B.push({id:"unstaged",title:o("gitView.changes.title"),entries:Q,actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:V=>o("gitView.changes.stageFileAria",{path:V}),onActionFile:V=>{U([V],"stage")},onActionAll:V=>{U(V,"stage")},onViewDiff:V=>fe(V,!1),onRevertFile:Ne}),B},[Ne,fe,U,F,o,Q]),ve=B=>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:[n?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-primary","aria-label":o("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(se,{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:a?.current||i||""})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:B})]});return i?d&&c===null?ve(t.jsx(Ke,{loading:!0,message:o("gitView.loading.checkingRepository")})):c===!1?ve(t.jsx(Ke,{icon:!0,message:o("gitView.empty.notGitRepository"),description:o("gitView.empty.notGitRepositoryDescription")})):b.type==="diff"?t.jsx(Kl,{path:b.path,diff:ae,fileExists:!!pe,error:X,onBack:()=>P({type:"list"}),onRetry:()=>q(B=>B+1)}):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:[n?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-primary","aria-label":o("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(se,{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:a?.current||i})]}),t.jsx(Ii,{syncAction:j,remotes:te,onFetch:B=>{ie("fetch",B)},onSync:B=>{ie("sync",B)},disabled:R!==null||d,aheadCount:a?.ahead??0,behindCount:a?.behind??0,trackingRemoteName:a?.tracking?.split("/")[0],hasUncommittedChanges:G.length>0})]}),G.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(na,{groups:_e,diffStats:a?.diffStats,revertingPaths:E,onRevertAll:ke,isRevertingAll:I,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:A})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(ra,{stagedCount:F.length,commitMessage:D,onCommitMessageChange:k,generatedHighlights:H,onInsertHighlights:Ie,onGenerateMessage:Be,isGeneratingMessage:N,onCommit:()=>{Ae({pushAfter:!1})},onCommitAndPush:()=>{Ae({pushAfter:!0})},commitAction:R,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Ke,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})})]}):ve(t.jsx(Ke,{message:o("gitView.empty.selectSessionOrDirectory")}))},Ke=n=>{const e=de.c(13),{message:s,description:o,loading:r,icon:i}=n,a=r===void 0?!1:r,c=i===void 0?!1:i;let d;e[0]!==a?(d=a?t.jsx(se,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=a,e[1]=d):d=e[1];let f;e[2]!==c?(f=c?t.jsx(se,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=c,e[3]=f):f=e[3];let u;e[4]!==s?(u=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=u):u=e[5];let m;e[6]!==o?(m=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[6]=o,e[7]=m):m=e[7];let g;return e[8]!==d||e[9]!==f||e[10]!==u||e[11]!==m?(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:[d,f,u,m]})}),e[8]=d,e[9]=f,e[10]=u,e[11]=m,e[12]=g):g=e[12],g},Kl=n=>{const e=de.c(24),{path:s,diff:o,fileExists:r,error:i,onBack:a,onRetry:c}=n,{t:d}=me();let f;e[0]!==s?(f=Vo(s)||"text",e[0]=s,e[1]=f):f=e[1];const u=f;let m;e[2]!==d?(m=d("header.actions.backAria"),e[2]=d,e[3]=m):m=e[3];let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(se,{name:"arrow-left",className:"size-5"}),e[4]=g):g=e[4];let h;e[5]!==a||e[6]!==m?(h=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-primary","aria-label":m,onClick:a,children:g}),e[5]=a,e[6]=m,e[7]=h):h=e[7];let x;e[8]!==s?(x=t.jsx("div",{className:"min-w-0 flex-1 px-2",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s})}),e[8]=s,e[9]=x):x=e[9];let w;e[10]!==h||e[11]!==x?(w=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:[h,x]}),e[10]=h,e[11]=x,e[12]=w):w=e[12];let b;e[13]!==o||e[14]!==i||e[15]!==r||e[16]!==u||e[17]!==c||e[18]!==s||e[19]!==d?(b=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r?i?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:d("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}),t.jsx(xe,{type:"button",size:"sm",variant:"outline",onClick:c,children:d("diffView.actions.retry")})]})}):o?o.isBinary?t.jsx(Ke,{icon:!0,message:d("diffView.binary.unavailable")}):Go(s)?t.jsx(Ke,{icon:!0,message:d("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(ks,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(oa,{original:o.original,modified:o.modified,language:u,fileName:s,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):t.jsx(Ke,{loading:!0,message:d("diffView.state.loadingDiff")}):t.jsx(Ke,{icon:!0,message:d("mobile.changes.diffDetail.missingTitle"),description:d("mobile.changes.diffDetail.missingDescription")})}),e[13]=o,e[14]=i,e[15]=r,e[16]=u,e[17]=c,e[18]=s,e[19]=d,e[20]=b):b=e[20];let P;return e[21]!==w||e[22]!==b?(P=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[w,b]}),e[21]=w,e[22]=b,e[23]=P):P=e[23],P},Hl=l.lazy(()=>mt(()=>import("./FilesView-DB-Q0Gkz.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123])).then(n=>({default:n.FilesView}))),Ze=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),Tt=n=>{const e=Ze(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},ql=n=>{const e=Ze(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},Yl=(n,e)=>{const s=Ze(n),o=Ze(e);return!o||s===o?Tt(s):s.startsWith(`${o}/`)?s.slice(o.length+1):s},Jl=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 o of e){if(s<1024||o===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${o}`;s/=1024}return""},Xl=({onClose:n})=>{const{t:e}=me(),{files:s}=js(),o=lo(v=>v.setSelectedPath),r=Ze(Ss()??null),[i,a]=l.useState(()=>({type:"browser",directory:r})),[c,d]=l.useState([]),[f,u]=l.useState(!1),[m,g]=l.useState(null),[h,x]=l.useState(""),[w,b]=l.useState([]),[P,j]=l.useState(!1),C=l.useRef(0);l.useEffect(()=>{r&&a(v=>v.type==="browser"&&v.directory?v:{type:"browser",directory:r})},[r]);const R=i.type==="browser"?i.directory:i.returnDirectory,T=l.useCallback(async v=>{if(!v)return;const A=C.current+1;C.current=A,u(!0),g(null);try{const O=await s.listDirectory(v);if(C.current!==A)return;d(O.entries.slice().sort((z,L)=>z.isDirectory!==L.isDirectory?z.isDirectory?-1:1:z.name.localeCompare(L.name)))}catch(O){if(C.current!==A)return;d([]),g(O instanceof Error?O.message:e("mobile.files.error.listFailed"))}finally{C.current===A&&u(!1)}},[s,e]);l.useEffect(()=>{i.type==="browser"&&T(i.directory)},[T,i]),l.useEffect(()=>{if(i.type!=="browser")return;const v=h.trim();if(!v){b([]),j(!1);return}let A=!1;const O=window.setTimeout(()=>{j(!0),s.search({directory:i.directory,query:v,maxResults:40}).then(z=>{A||b(z)}).catch(()=>{A||b([])}).finally(()=>{A||j(!1)})},250);return()=>{A=!0,window.clearTimeout(O)}},[s,h,i]);const D=v=>{x(""),a({type:"browser",directory:v})},k=v=>{o(r,v),a({type:"file",path:v,returnDirectory:R||r})},E=Ve(v=>v.pendingFileFocusPath),y=Ve(v=>v.pendingFileNavigation);if(l.useEffect(()=>{const v=Ze(y?.path??E??"");!v||!r||v!==r&&!v.startsWith(`${r}/`)||(o(r,v),a({type:"file",path:v,returnDirectory:r}),E&&Ve.getState().setPendingFileFocusPath(null))},[E,y,r,o]),!r)return t.jsx(It,{message:e("mobile.files.empty.noDirectory")});if(i.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-primary","aria-label":e("header.actions.backAria"),onClick:()=>a({type:"browser",directory:i.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(dn,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:Tt(i.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Le,{children:t.jsx(l.Suspense,{fallback:t.jsx(It,{loading:!0,message:e("filesView.state.loading")}),children:t.jsx(Hl,{mode:"editor-only"})})})})]});const I=i.directory===r?e("mobile.files.rootDirectory"):Tt(i.directory),M=h.trim()?w:[],N=ql(i.directory),S=i.directory!==r&&N!==null&&(N===r||N.startsWith(`${r}/`)),H=S&&!h.trim(),$=S?N:null;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 px-3 text-foreground",children:[n?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-primary","aria-label":e("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(cr,{className:"size-5"})}):null,H&&$?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-primary","aria-label":e("mobile.files.backToParentAria",{name:Tt($)}),onClick:()=>D($),style:{touchAction:"manipulation"},children:t.jsx(dn,{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:I})}),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-primary","aria-label":e("mobile.files.refreshAria"),onClick:()=>{T(i.directory)},style:{touchAction:"manipulation"},children:t.jsx(Qi,{className:Z("size-5",f&&"animate-spin")})})]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(lr,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(ws,{value:h,onChange:v=>x(v.target.value),placeholder:e("mobile.files.search.placeholder"),className:"h-11 pl-9"})]})}),t.jsx(ks,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:m?t.jsx(It,{message:m}):h.trim()?t.jsx(Ql,{results:M,isSearching:P,onOpenFile:k}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[c.length===0&&!f?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:e("mobile.files.empty.directory")}):null,c.map(v=>t.jsx(Dr,{name:v.name,path:v.path,directory:v.isDirectory,meta:v.isDirectory?void 0:Jl(v.size),onClick:()=>v.isDirectory?D(v.path):k(v.path)},v.path))]})})]})},Dr=n=>{const e=de.c(16),{name:s,path:o,directory:r,meta:i,onClick:a}=n;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={touchAction:"manipulation"},e[0]=c):c=e[0];let d;e[1]!==r||e[2]!==o?(d=r?t.jsx(Zi,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(Ko,{filePath:o,className:"size-5 shrink-0"}),e[1]=r,e[2]=o,e[3]=d):d=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 u;e[6]!==i?(u=i?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,e[6]=i,e[7]=u):u=e[7];let m;e[8]!==r?(m=r?t.jsx(ea,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=r,e[9]=m):m=e[9];let g;return e[10]!==a||e[11]!==d||e[12]!==f||e[13]!==u||e[14]!==m?(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-primary focus-visible:ring-inset",onClick:a,style:c,children:[d,f,u,m]}),e[10]=a,e[11]=d,e[12]=f,e[13]=u,e[14]=m,e[15]=g):g=e[15],g},Ql=n=>{const e=de.c(10),{results:s,isSearching:o,onOpenFile:r}=n,{t:i}=me(),a=Ze(Ss()??null);if(o){let u;e[0]!==i?(u=i("common.loading"),e[0]=i,e[1]=u):u=e[1];let m;return e[2]!==u?(m=t.jsx(It,{loading:!0,message:u}),e[2]=u,e[3]=m):m=e[3],m}if(s.length===0){let u;e[4]!==i?(u=i("mobile.files.search.empty"),e[4]=i,e[5]=u):u=e[5];let m;return e[6]!==u?(m=t.jsx(It,{message:u}),e[6]=u,e[7]=m):m=e[7],m}const c="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",d=s.map(u=>t.jsx(Dr,{name:Tt(u.path),path:u.path,directory:!1,meta:Yl(u.path,a),onClick:()=>r(u.path)},u.path));let f;return e[8]!==d?(f=t.jsx("div",{className:c,children:d}),e[8]=d,e[9]=f):f=e[9],f},It=n=>{const e=de.c(7),{message:s,loading:o}=n,r=o===void 0?!1:o;let i;e[0]!==r?(i=r?t.jsx(ta,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(sa,{className:"size-6 text-muted-foreground"}),e[0]=r,e[1]=i):i=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 c;return e[4]!==i||e[5]!==a?(c=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:[i,a]})}),e[4]=i,e[5]=a,e[6]=c):c=e[6],c},Ln="mobile-surface-root",Zl=16,Bn=320,ec="cubic-bezier(0.22, 1, 0.36, 1)",tc=n=>{const e=de.c(36),{onOpenMcpSettings:s}=n,{t:o}=me(),[r,i]=l.useState(!1),a=ft(sc),c=qo(nc),d=Ft(rc);let f;e[0]!==a||e[1]!==r||e[2]!==d||e[3]!==c?(f=()=>{if(r)return;i(!0);const I=new Promise(oc);Promise.all([c({directory:a||null,silent:!0}),d({force:!0}),I]).finally(()=>i(!1))},e[0]=a,e[1]=r,e[2]=d,e[3]=c,e[4]=f):f=e[4];const u=f;let m;e[5]!==o?(m=o("settings.mcp.sidebar.actions.addServerTitle"),e[5]=o,e[6]=m):m=e[6];let g;e[7]!==o?(g=o("settings.mcp.sidebar.actions.addServerTitle"),e[7]=o,e[8]=g):g=e[8];let h,x;e[9]===Symbol.for("react.memo_cache_sentinel")?(h={touchAction:"manipulation"},x=t.jsx(se,{name:"add",className:"size-5"}),e[9]=h,e[10]=x):(h=e[9],x=e[10]);let w;e[11]!==s||e[12]!==m||e[13]!==g?(w=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-primary",onClick:s,"aria-label":m,title:g,style:h,children:x}),e[11]=s,e[12]=m,e[13]=g,e[14]=w):w=e[14];let b;e[15]!==o?(b=o("mcpDropdown.actions.refreshAria"),e[15]=o,e[16]=b):b=e[16];let P;e[17]!==o?(P=o("mcpDropdown.actions.refreshAria"),e[17]=o,e[18]=P):P=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j={touchAction:"manipulation"},e[19]=j):j=e[19];const C=r&&"animate-spin";let R;e[20]!==C?(R=Z("size-5",C),e[20]=C,e[21]=R):R=e[21];let T;e[22]!==R?(T=t.jsx(se,{name:"refresh",className:R}),e[22]=R,e[23]=T):T=e[23];let D;e[24]!==r||e[25]!==u||e[26]!==T||e[27]!==b||e[28]!==P?(D=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-primary",onClick:u,disabled:r,"aria-label":b,title:P,style:j,children:T}),e[24]=r,e[25]=u,e[26]=T,e[27]=b,e[28]=P,e[29]=D):D=e[29];let k;e[30]!==D||e[31]!==w?(k=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[w,D]}),e[30]=D,e[31]=w,e[32]=k):k=e[32];let E;e[33]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Mi,{active:!0,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=E):E=e[33];let y;return e[34]!==k?(y=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[k,E]}),e[34]=k,e[35]=y):y=e[35],y},$n=({open:n,onClose:e,tab:s,onTabChange:o,pendingChangesDiff:r,onOpenPlan:i,onOpenMcpSettings:a,variant:c="drawer"})=>{const{t:d}=me(),f=l.useRef(null),[u,m]=l.useState(!1),[g,h]=l.useState(n),x=l.useRef(e);l.useEffect(()=>{x.current=e},[e]);const w=l.useRef(s);l.useEffect(()=>{w.current=s},[s]);const[b,P]=l.useState(()=>new Set);if(l.useEffect(()=>{n&&P(R=>{if(R.has(s))return R;const T=new Set(R);return T.add(s),T})},[n,s]),typeof document<"u"&&!f.current){let R=document.getElementById(Ln);R||(R=document.createElement("div"),R.id=Ln,document.body.appendChild(R)),f.current=R}if(l.useEffect(()=>{if(n){h(!0);const T=window.setTimeout(()=>m(!0),Zl);return()=>window.clearTimeout(T)}m(!1);const R=window.setTimeout(()=>h(!1),Bn+40);return()=>window.clearTimeout(R)},[n]),l.useEffect(()=>{if(!n)return;const R=document.body.style.overflow;c==="drawer"&&(document.body.style.overflow="hidden");const T=D=>{D.key==="Escape"&&w.current!=="terminal"&&x.current()};return document.addEventListener("keydown",T),()=>{c==="drawer"&&(document.body.style.overflow=R),document.removeEventListener("keydown",T)}},[n,c]),c==="drawer"&&!f.current)return null;const j=[{id:"changes",label:d("mobile.menu.changes"),icon:t.jsx(se,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:d("mobile.menu.files"),icon:t.jsx(se,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:d("mobile.menu.terminal"),icon:t.jsx(se,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:d("contextRail.surface.notes"),icon:t.jsx(se,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:d("mobile.menu.mcp"),icon:t.jsx(Ho,{className:"h-3.5 w-3.5"})}],C=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:g?t.jsx(Ai,{items:j,activeId:s,onSelect:R=>o(R),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-primary","aria-label":d("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(se,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[b.has("changes")?t.jsx("div",{className:Z("h-full",s!=="changes"&&"hidden"),children:t.jsx(Le,{children:t.jsx(Gl,{initialDiffPath:r?.path??null,initialDiffStaged:r?.staged===!0})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,b.has("files")?t.jsx("div",{className:Z("h-full",s!=="files"&&"hidden"),children:t.jsx(Le,{children:t.jsx(Xl,{})})}):null,b.has("terminal")?t.jsx("div",{className:Z("h-full",s!=="terminal"&&"hidden"),children:t.jsx(Le,{children:t.jsx(_i,{visible:n&&s==="terminal"})})}):null,b.has("notes")?t.jsx("div",{className:Z("h-full",s!=="notes"&&"hidden"),children:t.jsx(Le,{children:t.jsx(Di,{onActionComplete:e,onOpenPlan:i})})}):null,b.has("mcp")?t.jsx("div",{className:Z("h-full",s!=="mcp"&&"hidden"),children:t.jsx(Le,{children:t.jsx(tc,{onOpenMcpSettings:a})})}):null]})]});return c==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:C}):dt.createPortal(t.jsx("section",{role:"dialog","aria-modal":"true","aria-label":d("mobile.header.openWorkspaceAria"),"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:u?"none":"translateX(100%)",transition:`transform ${Bn}ms ${ec}`,visibility:g?"visible":"hidden",pointerEvents:n?"auto":"none"},children:C}),f.current)};function sc(n){return n.currentDirectory}function nc(n){return n.refresh}function rc(n){return n.loadMcpConfigs}function oc(n){return window.setTimeout(n,500)}function ic(n){const e=de.c(4),s=2500,{uiFont:o}=Yo(),[r,i]=l.useState(!1);let a,c;return e[0]!==s||e[1]!==o?(a=()=>{let d=!1;const f=()=>{d||i(!0)},u=()=>{requestAnimationFrame(()=>requestAnimationFrame(f))},m=Promise.all([Jo(o).catch(dc),document.fonts?.ready?.then(uc).catch(cc)??Promise.resolve(),ia.catch(lc)]).then(ac),g=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([m,g]).then(u),()=>{d=!0}},c=[o,s],e[0]=s,e[1]=o,e[2]=a,e[3]=c):(a=e[2],c=e[3]),l.useEffect(a,c),r}function ac(){}function lc(){}function cc(){}function uc(){}function dc(){}const fc="openchamber",mc=n=>n.replace(/^\/+|\/+$/g,""),pc=n=>{const e=mc(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function hc(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${fc}:`)return null;const s=pc(e),o=(s[0]??"").toLowerCase(),r=s.slice(1),i=e.searchParams;switch(o){case"session":{const a=r[0]||i.get("id")||"";return a?{type:"session",sessionId:a,directory:i.get("dir")??void 0}:null}case"new":case"new-session":return{type:"new-session",directory:i.get("dir")??void 0,projectId:i.get("project")??void 0,agent:i.get("agent")??void 0,model:i.get("model")??void 0};case"sessions":{const a=i.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]||i.get("section")||void 0};case"changes":return{type:"changes",path:r.join("/")||i.get("path")||void 0,staged:i.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 Me={},Mr=!1,Pt=null;const gc=n=>{switch(n.type){case"session":return je.getState().setCurrentSession(n.sessionId,n.directory??null),!0;case"new-session":{const e=je.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 Me.openSessions?(Me.openSessions(n.filter),!0):!1;case"status":return Me.openSessions?(Me.openSessions(),!0):!1;case"view":return Me.openView?(Me.openView(n.target),!0):!1;case"changes":return Me.openChanges?(Me.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return Me.openSettings?(Me.openSettings(n.section),!0):!1}},Gs=()=>{if(!Mr||!Pt)return;const n=Pt;Pt=null,gc(n)||(Pt=n)},zr=n=>{Pt=n,Gs()},Fn=n=>{const e=hc(n);e&&zr(e)},bc=n=>{Mr=n,Gs()},xc=n=>{const e=de.c(3);let s,o;e[0]!==n?(s=()=>(Me=n,Gs(),()=>{Me===n&&(Me={})}),o=[n],e[0]=n,e[1]=s,e[2]=o):(s=e[1],o=e[2]),l.useEffect(s,o)},yc=n=>{const{ready:e}=n;l.useEffect(()=>{bc(e)},[e]),l.useEffect(()=>{if(!Te())return;let s=!1;const o=[];return mt(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([124,4,125])).then(async({App:r})=>{if(s)return;const i=await r.addListener("appUrlOpen",a=>{Fn(a?.url)});if(s){i.remove();return}o.push(()=>{i.remove()})}).catch(()=>{}),mt(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([126,125])).then(async({PushNotifications:r})=>{if(s)return;const i=await r.addListener("pushNotificationActionPerformed",a=>{const c=a?.notification?.data,d=typeof c?.url=="string"?c.url:typeof c?.deeplink=="string"?c.deeplink:void 0;if(d){Fn(d);return}const f=typeof c?.sessionId=="string"?c.sessionId:void 0;f&&zr({type:"session",sessionId:f})});if(s){i.remove();return}o.push(()=>{i.remove()})}).catch(()=>{}),()=>{s=!0,o.forEach(r=>r())}},[])},vc=32,wc=80,jc=64,kc=.7,Sc=(n,e)=>{const s=l.useRef(e);s.current=e,l.useEffect(()=>{const o=n.current;if(!o)return;const i=window.Capacitor?.getPlatform?.()==="android"?wc:vc;let a=!1,c=!1,d=0,f=0;const u=g=>{if(g.touches.length!==1){a=!1;return}const h=g.touches[0],x=o.clientWidth,w=h.clientX<=i,b=h.clientX>=x-i;a=w||b,c=w,d=h.clientX,f=h.clientY},m=g=>{if(!a)return;a=!1;const h=g.changedTouches[0];if(!h)return;const x=h.clientX-d,w=h.clientY-f;Math.abs(x)<jc||Math.abs(w)>Math.abs(x)*kc||c&&x<=0||!c&&x>=0||(c?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return o.addEventListener("touchstart",u,{passive:!0}),o.addEventListener("touchend",m,{passive:!0}),()=>{o.removeEventListener("touchstart",u),o.removeEventListener("touchend",m)}},[n])},Nc=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},Cc=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},Ec=n=>{const{enabled:e}=n,s=Ve(r=>r.nativeNotificationsEnabled),o=l.useRef(null);l.useEffect(()=>{if(!e||!s||!Cc())return;let r=!1;const i=[];return mt(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([126,125])).then(async({PushNotifications:a})=>{if(r)return;let c=await a.checkPermissions().catch(()=>null);if(c?.receive!=="granted"&&(c=await a.requestPermissions().catch(()=>null)),c?.receive!=="granted")return;const d=await a.addListener("registration",u=>{o.current=u.value,rn()?.push?.registerApnsToken?.({token:u.value,platform:Gn(),environment:Nc()})}),f=await a.addListener("registrationError",u=>{console.warn("[Push] APNs registration error:",u)});if(await a.register().catch(()=>{}),r){d.remove(),f.remove();return}i.push(()=>{d.remove()},()=>{f.remove()})}).catch(()=>{}),()=>{r=!0,i.forEach(a=>a())}},[e,s]),l.useEffect(()=>{if(s)return;const r=o.current;if(!r)return;o.current=null,rn()?.push?.unregisterApnsToken?.({token:r})},[s])},Wn=n=>{const e=de.c(12),{side:s,isResizing:o,ariaLabel:r,handleProps:i}=n,a=s==="left"?"right-0":"left-0";let c;e[0]!==a?(c=Z("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",a),e[0]=a,e[1]=c):c=e[1];const d=s==="left"?"right-0":"left-0",f=o&&"bg-[var(--interactive-border)]";let u;e[2]!==d||e[3]!==f?(u=Z("absolute inset-y-0 w-[3px] transition-colors",d,f),e[2]=d,e[3]=f,e[4]=u):u=e[4];let m;e[5]!==u?(m=t.jsx("div",{className:u}),e[5]=u,e[6]=m):m=e[6];let g;return e[7]!==r||e[8]!==i||e[9]!==c||e[10]!==m?(g=t.jsx("div",{className:c,role:"separator","aria-orientation":"vertical","aria-label":r,...i,children:m}),e[7]=r,e[8]=i,e[9]=c,e[10]=m,e[11]=g):g=e[11],g},Rc=320,Pc=380,Un=280,Tc=560,Ic=900;function Vn(n,e,s,o){const r=de.c(23),i=o===void 0?Tc:o,a=l.useRef(null);let c;r[0]!==s||r[1]!==i||r[2]!==e?(c=()=>{if(typeof window>"u")return s;const S=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(S)?Math.min(i,Math.max(Un,S)):s},r[0]=s,r[1]=i,r[2]=e,r[3]=c):c=r[3];const[d,f]=l.useState(c),[u,m]=l.useState(!1),g=l.useRef(0),h=l.useRef(d),x=l.useRef(null),w=l.useRef(null);let b;r[4]!==i?(b=S=>Math.min(i,Math.max(Un,Math.round(S))),r[4]=i,r[5]=b):b=r[5];const P=b;let j;r[6]===Symbol.for("react.memo_cache_sentinel")?(j=S=>{const H=a.current;H&&(H.style.width=`${S}px`,H.style.minWidth=`${S}px`,H.style.maxWidth=`${S}px`,H.style.setProperty("--oc-ipad-sidebar-width",`${S}px`))},r[6]=j):j=r[6];const C=j;let R;r[7]!==d?(R=S=>{try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}w.current=S.pointerId,g.current=S.clientX,h.current=d,x.current=d,m(!0),S.preventDefault()},r[7]=d,r[8]=R):R=r[8];const T=R;let D;r[9]!==P||r[10]!==n?(D=S=>{if(w.current!==S.pointerId)return;const H=S.clientX-g.current,$=P(h.current+(n==="left"?H:-H));x.current!==$&&(x.current=$,C($))},r[9]=P,r[10]=n,r[11]=D):D=r[11];const k=D;let E;r[12]!==P||r[13]!==e?(E=S=>{if(w.current!==S.pointerId)return;try{S.currentTarget.releasePointerCapture(S.pointerId)}catch{}const H=P(x.current??h.current);w.current=null,x.current=null,m(!1),f(H);try{window.localStorage.setItem(e,String(H))}catch{}},r[12]=P,r[13]=e,r[14]=E):E=r[14];const y=E;let I;r[15]!==T||r[16]!==y||r[17]!==k?(I={onPointerDown:T,onPointerMove:k,onPointerUp:y,onPointerCancel:y},r[15]=T,r[16]=y,r[17]=k,r[18]=I):I=r[18];const M=I;let N;return r[19]!==M||r[20]!==u||r[21]!==d?(N={asideRef:a,width:d,isResizing:u,handleProps:M},r[19]=M,r[20]=u,r[21]=d,r[22]=N):N=r[22],N}const Ac=["general","appearance","chat","notifications","sessions","git","magic-prompts","behavior","mcp","providers","usage","voice","integrations","about"],_c=1e3,Dc=({onActiveConnectionDeleted:n})=>{const{t:e}=me(),[s,o]=l.useState(!1),[r,i]=l.useState(null),[a,c]=l.useState(!1),[d,f]=l.useState("changes"),[u,m]=l.useState(null),[g,h]=l.useState("nav"),[x,w]=l.useState(null),b=Ve(U=>U.setSettingsPage),P=Ve(U=>U.wideChatLayoutEnabled),j=lt(U=>U.available),C=lt(U=>U.runtimeType),R=l.useMemo(()=>or(),[]),T=Ft(U=>U.mcpServers),D=Ft(U=>U.setMcpDraft),k=Ft(U=>U.setSelectedMcp),E=l.useCallback(()=>{i(null),m(null)},[]),y=l.useCallback(U=>{i(U)},[]),I=l.useCallback(()=>{c(!1)},[]),M=l.useCallback(U=>{h(U),y("settings")},[y]),{enabled:N,roomyForPanels:S}=ys(),$=mi()==="portrait",v=pi(),[A,O]=l.useState(()=>hi().roomyForPanels),z=l.useCallback(()=>{O(U=>!U)},[]);l.useEffect(()=>{N||O(!1)},[N]);const L=l.useCallback(()=>{w(null),f("files"),c(!0)},[]),ee=l.useCallback((U=null)=>{w(U),f("changes"),c(!0)},[]),X=Vn("left","openchamber.ipad.leftSidebarWidth",Rc),_=Vn("right","openchamber.ipad.rightSidebarWidth",Pc,Ic),J=S,q=J&&a?_.width:0,G=N&&A?X.width:0;l.useEffect(()=>{if(typeof document>"u")return;const U=document.documentElement;return U.style.setProperty("--oc-chat-inset-left",`${G}px`),U.style.setProperty("--oc-chat-inset-right",`${q}px`),()=>{U.style.removeProperty("--oc-chat-inset-left"),U.style.removeProperty("--oc-chat-inset-right")}},[G,q]),l.useEffect(()=>{if(typeof document>"u")return;const U=document.documentElement;return U.classList.toggle("wide-chat-layout",P),()=>U.classList.remove("wide-chat-layout")},[P]),l.useEffect(()=>{if(typeof document>"u")return;const U=N&&($||v),fe=document.documentElement;return fe.classList.toggle("oc-keep-draft-starters",U),()=>fe.classList.remove("oc-keep-draft-starters")},[v,N,$]);const F=l.useMemo(()=>({openChanges:({diffPath:U,staged:fe}={})=>{ee(U?{path:U,staged:fe===!0}:null)},openFiles:()=>L(),openSettings:()=>M("nav")}),[ee,L,M]),Q=l.useMemo(()=>({openSessions:()=>{N?O(!0):o(!0)},openView:U=>{if(U==="files"){L();return}if(U==="mcp"){f("mcp"),c(!0);return}y(U)},openChanges:({path:U,staged:fe}={})=>{ee(U?{path:U,staged:fe===!0}:null)},openSettings:U=>{U&&b(U),M(U?"page-content":"nav")}}),[N,ee,L,M,y,b]);xc(Q);const te=l.useRef(null);Sc(te,{onLeftEdgeSwipe:()=>{N?O(!0):o(!0)},onRightEdgeSwipe:()=>c(!0)});const ae=l.useCallback(()=>u?(m(null),!0):r?(E(),!0):a?(I(),!0):s?(o(!1),!0):!1,[r,E,I,u,s,a]);gi(ae);const pe=!R&&j&&(C==="desktop"||C==="web"),oe=N?"dialog":"fullscreen",W=l.useMemo(()=>({instanceLabel:R?Nt():null,onOpenInstances:R?()=>y("instances"):void 0,onOpenSettings:()=>M("nav"),onOpenUpdate:pe?()=>y("update"):void 0}),[M,y,R,pe]),ie=l.useCallback(()=>{const U="new-mcp-server";let fe=U,Ne=1;for(;T.some(Ie=>Ie.name===fe);)fe=`${U}-${Ne}`,Ne+=1;D({name:fe,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",timeout:"",enabled:!0}),k(fe),b("mcp"),M("page-content")},[T,M,D,k,b]);return t.jsx(bi,{actions:F,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:[N?t.jsxs("aside",{ref:X.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",!A&&"border-r-0"),style:{width:A?X.width:0,minWidth:A?X.width:0,maxWidth:A?X.width:0,"--oc-ipad-sidebar-width":`${X.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:X.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!A,"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",X.isResizing&&"pointer-events-none",!A&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Le,{children:t.jsx(_n,{open:!0,variant:"sidebar",onOpenChange:U=>{!U&&!S&&O(!1)},footer:W})})}),A?t.jsx(Wn,{side:"left",isResizing:X.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:X.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(hl,{onOpenSessions:()=>N?z():o(!0),onOpenWorkspace:()=>c(!0),compactTitle:N}),t.jsx("main",{ref:te,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(Le,{children:t.jsx(Wi,{})})})})]}),N?null:t.jsx(_n,{open:s,onOpenChange:o,footer:W}),N?t.jsxs("aside",{ref:_.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",!q&&"border-l-0"),style:{width:q,minWidth:q,maxWidth:q,"--oc-ipad-sidebar-width":`${_.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:_.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!q,"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",_.isResizing&&"pointer-events-none",!q&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Le,{children:t.jsx($n,{open:a,onClose:I,tab:d,onTabChange:f,pendingChangesDiff:x,onOpenPlan:m,onOpenMcpSettings:ie,variant:J?"panel":"drawer"})})}),q?t.jsx(Wn,{side:"right",isResizing:_.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:_.handleProps}):null]}):t.jsx($n,{open:a,onClose:I,tab:d,onTabChange:f,pendingChangesDiff:x,onOpenPlan:m,onOpenMcpSettings:ie}),u?t.jsx(Rt,{open:!0,variant:oe,onClose:()=>m(null),ariaLabel:u.title,title:u.title,children:t.jsx(Le,{children:t.jsx(Ki,{projectPlanId:u.id,onNavigatedToChat:()=>{E(),I()}})})}):null,r==="instances"&&R?t.jsx(Rt,{open:!0,variant:oe,dialogAlign:"app",onClose:E,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(yl,{onConnect:E,onActiveConnectionDeleted:n})}):null,r==="settings"?t.jsx(Rt,{open:!0,variant:oe,dialogAlign:"app",onClose:E,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Le,{children:t.jsx(Vi,{forceMobile:!0,isWindowed:!0,initialMobileStage:g,visiblePageSlugs:Ac.filter(U=>!(R&&U==="about")),onClose:E})})}):null,r==="update"?t.jsx(Rt,{open:!0,variant:oe,dialogAlign:"app",onClose:E,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Le,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(Gi,{initialUpdateDialogOpen:!0})})})}):null]})})};function Mc({apis:n}){const{t:e}=me(),s=ze(_=>_.initializeApp),o=ze(_=>_.isInitialized),r=ze(_=>_.isConnected),i=ze(_=>_.connectionPhase),a=ze(_=>_.providers.length),c=ze(_=>_.agents.length),d=ze(_=>_.loadProviders),f=ze(_=>_.loadAgents),u=ft(_=>_.currentDirectory),m=je(_=>_.error),g=je(_=>_.clearError),h=Ve(_=>_.setIsMobile),x=Xo(_=>_.refreshStatus),w=Qo(_=>_.setPlanModeEnabled),b=Oe(_=>_.projects),[P,j]=l.useState(0),[C,R]=l.useState(0),[T,D]=l.useState(!1),[k,E]=l.useState("pending"),[y,I]=l.useState(null),M=l.useMemo(()=>Nt(),[]),[,N]=l.useReducer(_=>_+1,0),S=l.useMemo(()=>or(),[]),H=l.useRef(0),$=l.useRef(0),v=l.useCallback(()=>{const _=Ue(),J=$.current+1;if($.current=J,!_){jt("resume:auto-connect",{}),kt();return}jt("resume:reprobe",{});const q=()=>{s(),x(n.github,{force:!0}),a===0&&d({source:"mobileApp:nativeResume"}),c===0&&f({source:"mobileApp:nativeResume"})},G=Q=>{jt("resume:disconnect",{reason:Q}),at({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),j(te=>te+1)};Ut().then(Q=>{if($.current===J){if(Q==="no-connection"){G("no-connection");return}if(Q==="needs-login"){I({kind:"auth-expired",label:Nt()??""}),G("needs-login");return}if(Q==="unreachable"){const te=[4e3,1e4],ae=pe=>{window.setTimeout(()=>{if($.current!==J)return;const oe=pe===te.length-1;Ut({fast:!oe}).then(W=>{if($.current===J&&W!=="switched"){if(W==="unchanged"){q();return}if(W==="needs-login"){I({kind:"auth-expired",label:Nt()??""}),G("retry-needs-login");return}if(!oe){ae(pe+1);return}G(`retry-${W}`)}})},te[pe])};ae(0);return}Q!=="switched"&&q()}});const F=Date.now();F-H.current>=_c&&(H.current=F,window.dispatchEvent(new Event("openchamber:system-resume")))},[c,n.github,s,f,d,a,x]);Zo(),ei(v),l.useEffect(()=>{if(!S)return;let _;const J=()=>{window.clearTimeout(_),_=window.setTimeout(()=>v(),1500)};return window.addEventListener("online",J),()=>{window.removeEventListener("online",J),window.clearTimeout(_)}},[S,v]),l.useEffect(()=>(on(n),()=>on(null)),[n]),l.useEffect(()=>co(_=>{if(jt("endpoint:changed",{runtimeKey:_.runtimeKey||"none",previousRuntimeKey:_.previousRuntimeKey||"none",connected:!!_.apiBaseUrl}),!!_.runtimeKey&&_.runtimeKey===_.previousRuntimeKey){zi(),N();return}Oi(_),R(q=>q+1),j(q=>q+1)}),[]),l.useEffect(()=>{if(!S||r||Ue()){E("done");return}let _=!1;return E("attempting"),(async()=>{const J=await kt().catch(()=>({status:"no-candidate"}));_||(J.status==="unreachable"?I({kind:"unreachable",label:J.label}):J.status==="needs-login"&&I({kind:"auth-expired",label:J.label}),E("done"),J.status==="unreachable"&&kt({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{_=!0}},[]),l.useEffect(()=>{if(!S||!Ue())return;let _=!1;const J=q=>{jt("cold-launch:drop",{kind:q?.kind??"unknown"}),q&&I(q),at({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),j(G=>G+1)};return Ut().then(async q=>{if(_||q==="switched"||q==="unchanged")return;const G=Nt();if(q==="needs-login"){J({kind:"auth-expired",label:G??""});return}if(q==="unreachable"){J(G?{kind:"unreachable",label:G}:null),kt({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const F=await kt().catch(()=>({status:"no-candidate"}));_||F.status==="connected"||(F.status==="needs-login"?J({kind:"auth-expired",label:F.label}):F.status==="unreachable"?J({kind:"unreachable",label:F.label}):J(null))}),()=>{_=!0}},[]),l.useEffect(()=>{h(!0)},[h]),l.useEffect(()=>{S&&!Ue()||s()},[P,s,S]),l.useEffect(()=>{r&&(a===0&&d({source:"mobileApp:recovery"}),c===0&&f({source:"mobileApp:recovery"}))},[c,r,f,d,a]);const A=l.useRef(!1),[O,z]=l.useState(S);l.useEffect(()=>{if(!S||!r||A.current)return;if(je.getState().currentSessionId){A.current=!0,z(!1);return}const _=xt(),J=ti(_);if(!J){A.current=!0,z(!1);return}let q=!1;const G=window.setTimeout(()=>z(!1),6e3);return(async()=>{const F=await vs().catch(()=>null);if(q)return;if(!F){z(!1);return}A.current=!0;const Q=F.activeSessions.find(ae=>ae.id===J.sessionId);if(!Q){si(_),z(!1);return}const te=je.getState();te.currentSessionId||te.setCurrentSession(Q.id,xs(Q)??J.directory??void 0),z(!1)})(),()=>{q=!0,window.clearTimeout(G)}},[P,r,S]),l.useEffect(()=>{r&&an.setDirectory(u)},[u,r]),l.useEffect(()=>{r&&x(n.github,{force:!0})},[n.github,r,x]),l.useEffect(()=>{if(!r||b.length===0)return;let _=!1;return(async()=>{const q=new Map(je.getState().availableWorktreesByProject);if(await Promise.all(b.map(async Q=>{const te=Q.path.replace(/\\/g,"/").replace(/\/+$/,"");if(te)try{if(!(We.getState().directories.get(te)?.isGitRepo??await mt(()=>import("./useAppFontEffects-CbzHzFop.js").then(W=>W.hD),__vite__mapDeps([8,1,2,3,4,5,6,7,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])).then(W=>W.checkIsGitRepository(te))))return;const oe=await nr({id:Q.id,path:te});if(_)return;q.set(te,oe)}catch{}})),_)return;const G=rr(b,q),F=je.getState().availableWorktreesByProject;fi(G,F)||je.setState({availableWorktrees:[...G.values()].flat(),availableWorktreesByProject:G})})(),()=>{_=!0}},[r,b]),l.useEffect(()=>{let _=!1;return(async()=>{const q=await gs("/health",{method:"GET"}).catch(()=>null);if(!q||!q.ok||_)return;const G=await q.json().catch(()=>null);if(!G||_)return;const F=G.planModeExperimentalEnabled;w(F===!0||F===1||F==="1"||F==="true")})(),()=>{_=!0}},[w]),l.useEffect(()=>{if(!m)return;const _=window.setTimeout(()=>g(),5e3);return()=>window.clearTimeout(_)},[g,m]),l.useEffect(()=>{if(!(!r&&(S?!!Ue():!0))){D(!1);return}const J=window.setTimeout(()=>{D(!0)},S?4e3:8e3);return()=>window.clearTimeout(J)},[r,S,P,C]),ni(),ri({enabled:!0}),Li(),oi(),Bi(),Ec({enabled:S&&r}),yc({ready:S&&r&&o});const L=ic(),ee=!r&&i==="reconnecting";if(!L)return t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(qe,{width:120,height:120,isAnimated:!0})});const X=!!Ue();return S&&(!X||!r&&!ee)?X?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:"flex max-w-sm flex-col items-center gap-4",children:[t.jsx(qe,{width:120,height:120,isAnimated:!T}),T?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("mobile.connect.recovery.description")})]}),t.jsx(xe,{type:"button",variant:"outline",onClick:()=>{at({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),j(_=>_+1)},children:e("mobile.connect.cancelPassword")})]}):null]})}):k!=="done"?t.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-background text-foreground",children:[t.jsx(qe,{width:120,height:120,isAnimated:!0}),M?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:e("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[M,t.jsx(ii,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(el,{onConnected:()=>j(_=>_+1),notice:y})}):!r&&!ee?T?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:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("sessionAuth.error.networkDescription")})]})}):t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(qe,{width:120,height:120,isAnimated:!0})}):t.jsx(Le,{children:t.jsx(ai,{sdk:an.getSdkClient(),directory:u||"",children:t.jsx(li,{apis:n,children:t.jsx(ci,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[S&&O?t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background",children:t.jsx(qe,{width:120,height:120,isAnimated:!0})}):null,t.jsx(ui,{embeddedBackgroundWorkEnabled:o}),t.jsx($i,{}),t.jsx(ha,{}),t.jsx(Dc,{onActiveConnectionDeleted:()=>{at({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),j(_=>_+1)}}),t.jsx(di,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),o?t.jsx(Fi,{}):null]})})})},C)})}const zc=()=>{Si(),uo().then(()=>{Promise.all([fo(),Ni()]).catch(n=>{console.error("[mobile-main] settings init failed:",n)}),Ci(),Ei(),Ri()}).catch(n=>{console.error("[mobile-main] appearance init failed:",n)}).finally(()=>{aa()})};function af(n){window.__OPENCHAMBER_SURFACE__="mobile",xi(),zc(),pa(),yi();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const o=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",r=o?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,i=t.jsx(Mc,{apis:r});no.createRoot(e).render(t.jsx(ls.StrictMode,{children:t.jsx(vi,{children:t.jsx(wi,{children:t.jsx(ji,{children:t.jsx(Ui,{children:o?i:t.jsx(ki,{children:i})})})})})}))}export{af as renderMobileApp};