@openchamber/web 1.18.2 → 1.18.3

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 (136) hide show
  1. package/bin/lib/commands-models.js +1 -1
  2. package/dist/assets/{CodeMirrorCommentWidgets-CxcJ5x9h.js → CodeMirrorCommentWidgets-DbUi6I9s.js} +1 -1
  3. package/dist/assets/{CommitSection-C9sBBYAJ.js → CommitSection-Jc2_hNPE.js} +1 -1
  4. package/dist/assets/{DiagramEditor-C7nUw7p3.js → DiagramEditor-PCrYHBko.js} +1 -1
  5. package/dist/assets/{DiagramView-cYxZP-HS.js → DiagramView-CndEcZNu.js} +1 -1
  6. package/dist/assets/{DiffView-1zd0slLu.js → DiffView-DEGlNjMH.js} +2 -2
  7. package/dist/assets/FilesView-CzUgIvUm.js +14 -0
  8. package/dist/assets/{GitView-OSVIn5V1.js → GitView-C-n17voy.js} +1 -1
  9. package/dist/assets/{JsonTreeView-Kgepz4pR.js → JsonTreeView-BYcgdTOQ.js} +1 -1
  10. package/dist/assets/MarkdownImageGallery-DzHwkVIH.js +1 -0
  11. package/dist/assets/MarkdownRendererImpl-DUcIcWgs.js +12 -0
  12. package/dist/assets/OnboardingScreen-BmN0lhk4.js +1 -0
  13. package/dist/assets/{PatchDiff-Cddz02Ya.js → PatchDiff-Bn7bfgUv.js} +1 -1
  14. package/dist/assets/{PierreDiffViewer-B5k0KvPW.js → PierreDiffViewer-D1fWvrUn.js} +2 -2
  15. package/dist/assets/{PlanView-BYgHBHDt.js → PlanView-CWM0iyFk.js} +3 -3
  16. package/dist/assets/{SessionSwitcherDropdown-ig2OT22Z.js → SessionSwitcherDropdown-Cez-9xRh.js} +1 -1
  17. package/dist/assets/SettingsView-Bl1drwPw.js +28 -0
  18. package/dist/assets/{SettingsWindow-CNHM8ifT.js → SettingsWindow-DL5axjDZ.js} +1 -1
  19. package/dist/assets/{ToolOutputDialog-DrGeYq2p.js → ToolOutputDialog-BtIJkFno.js} +7 -7
  20. package/dist/assets/{ToolPartDiffPreview-BRmPpe94.js → ToolPartDiffPreview-i3PQo6_0.js} +1 -1
  21. package/dist/assets/{VirtualizedFileDiff-Dcu8Q-5P.js → VirtualizedFileDiff-DkcusvMa.js} +1 -1
  22. package/dist/assets/{WalkthroughView-HStEYdD2.js → WalkthroughView-Cc5Hd6P5.js} +2 -2
  23. package/dist/assets/{computeVirtualFileMetrics-DQE7R9IY.js → computeVirtualFileMetrics-xPena3W2.js} +2 -2
  24. package/dist/assets/contextPanelEmbeddedChat-tQekJUAF.js +1 -0
  25. package/dist/assets/de-u7gSnqWs.js +9 -0
  26. package/dist/assets/es-T9O7aAOr.js +15 -0
  27. package/dist/assets/fr-Oor7ewbE.js +13 -0
  28. package/dist/assets/index-CVNuER6G.css +1 -0
  29. package/dist/assets/{index-BgQEgA2a.js → index-Crz1YOFl.js} +1 -1
  30. package/dist/assets/index-iFY_N5aO.js +7 -0
  31. package/dist/assets/{isDiffPlainText-XyBCe4eD.js → isDiffPlainText-Dudf-dWx.js} +1 -1
  32. package/dist/assets/{isFilePlainText-JbqDfa3n.js → isFilePlainText-DS4QV1dd.js} +1 -1
  33. package/dist/assets/ja-DHpqbVmr.js +15 -0
  34. package/dist/assets/ko-CwLkS3nx.js +15 -0
  35. package/dist/assets/{main-LfcbGv7C.js → main-C0DyIwTb.js} +2 -2
  36. package/dist/assets/main-CAxX6DAN.js +915 -0
  37. package/dist/assets/markdownCore-DhfzuGXu.js +2 -0
  38. package/dist/assets/markdownImageAssets-BTNlRyjd.js +1 -0
  39. package/dist/assets/{miniChat-CUp_elRz.js → miniChat-CGfrxKpJ.js} +2 -2
  40. package/dist/assets/{mobile-CBSN7BsH.js → mobile-DEmhwNcV.js} +2 -2
  41. package/dist/assets/{patchFileDiff-DCIXUHRJ.js → patchFileDiff-C5D1OPCa.js} +2 -2
  42. package/dist/assets/{pl-tHTP6XQx.js → pl-CcZILN8q.js} +4 -4
  43. package/dist/assets/pt-BR-DYHhVK6o.js +15 -0
  44. package/dist/assets/{renderElectronMiniChatApp-eZl-5STF.js → renderElectronMiniChatApp-Dpbswpom.js} +2 -2
  45. package/dist/assets/renderMobileApp-B5HA4qbi.js +25 -0
  46. package/dist/assets/runtimeEndpointReset-cbahJ3hD.js +13 -0
  47. package/dist/assets/scheduledTasksApi-BxgGWTL8.js +1 -0
  48. package/dist/assets/{shikiHighlight-eU8abJ3T.js → shikiHighlight-CmanopUB.js} +1 -1
  49. package/dist/assets/uk-BA2kZR38.js +15 -0
  50. package/dist/assets/{useAppFontEffects-Bbpz77To.js → useAppFontEffects-sHmU5b8u.js} +137 -137
  51. package/dist/assets/useInlineCommentController-gt56WkxJ.js +2 -0
  52. package/dist/assets/{vendor-codemirror-language-data-Dzt9rWZZ.js → vendor-codemirror-language-data-Dihw9MtL.js} +2 -2
  53. package/dist/assets/{vendor-marked-i_gIkIP3.js → vendor-marked-CX41MkDF.js} +1 -1
  54. package/dist/assets/{web-components-DGvnI0zx.js → web-components-BL-Ur2Tb.js} +1 -1
  55. package/dist/assets/zh-CN-dlOQK6v9.js +15 -0
  56. package/dist/assets/zh-TW-BnqQ-WL5.js +15 -0
  57. package/dist/index.html +4 -4
  58. package/dist/mini-chat.html +3 -3
  59. package/dist/mobile.html +3 -3
  60. package/package.json +2 -2
  61. package/server/index.js +65 -19
  62. package/server/lib/agent-tool/DOCUMENTATION.md +21 -6
  63. package/server/lib/agent-tool/runtime.js +90 -16
  64. package/server/lib/agent-tool/runtime.test.js +86 -0
  65. package/server/lib/browser-control/DOCUMENTATION.md +50 -0
  66. package/server/lib/browser-control/broker.js +154 -0
  67. package/server/lib/browser-control/broker.test.js +191 -0
  68. package/server/lib/browser-control/routes.js +48 -0
  69. package/server/lib/browser-control/routes.test.js +108 -0
  70. package/server/lib/dev-servers/parse.js +203 -0
  71. package/server/lib/dev-servers/parse.test.js +174 -0
  72. package/server/lib/dev-servers/routes.js +135 -0
  73. package/server/lib/dev-tunnel/DOCUMENTATION.md +57 -0
  74. package/server/lib/dev-tunnel/client.js +174 -0
  75. package/server/lib/dev-tunnel/runtime.js +189 -0
  76. package/server/lib/dev-tunnel/tunnel.test.js +282 -0
  77. package/server/lib/git/credentials.js +0 -33
  78. package/server/lib/github/DOCUMENTATION.md +1 -1
  79. package/server/lib/openchamber-control/DOCUMENTATION.md +9 -0
  80. package/server/lib/openchamber-control/actions.js +33 -1
  81. package/server/lib/openchamber-control/screenshots.js +83 -0
  82. package/server/lib/openchamber-control/screenshots.test.js +84 -0
  83. package/server/lib/openchamber-control/service.js +141 -2
  84. package/server/lib/openchamber-control/service.test.js +55 -0
  85. package/server/lib/opencode/core-routes.js +31 -52
  86. package/server/lib/opencode/core-routes.test.js +37 -9
  87. package/server/lib/opencode/feature-routes-runtime.js +4 -0
  88. package/server/lib/opencode/settings-helpers.js +3 -9
  89. package/server/lib/projects/project-config.js +181 -2
  90. package/server/lib/projects/project-config.test.js +295 -0
  91. package/server/lib/quota/DOCUMENTATION.md +4 -2
  92. package/server/lib/quota/credentials/providers.js +0 -7
  93. package/server/lib/quota/credentials/store.js +11 -1
  94. package/server/lib/quota/credentials/store.test.js +9 -1
  95. package/server/lib/quota/providers/opencode-go.js +35 -35
  96. package/server/lib/quota/providers/opencode-go.test.js +52 -7
  97. package/server/lib/quota/routes.js +0 -2
  98. package/server/lib/relay/DOCUMENTATION.md +2 -0
  99. package/server/lib/relay/tunnel-host.js +157 -33
  100. package/server/lib/relay/tunnel-host.test.js +147 -0
  101. package/server/lib/scheduled-tasks/DOCUMENTATION.md +49 -0
  102. package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +488 -0
  103. package/server/lib/scheduled-tasks/routes.js +6 -0
  104. package/server/lib/scheduled-tasks/runtime.js +369 -108
  105. package/server/lib/scheduled-tasks/service.js +7 -1
  106. package/server/lib/scheduled-tasks/service.test.js +20 -0
  107. package/server/lib/walkthrough/index.js +0 -2
  108. package/server/sse-routes.test.js +3 -0
  109. package/dist/assets/FilesView-WkxsWHBE.js +0 -14
  110. package/dist/assets/MarkdownRendererImpl-CKAsRfIk.js +0 -12
  111. package/dist/assets/OnboardingScreen-BCgYA7J5.js +0 -1
  112. package/dist/assets/SettingsView-e7Fmxnz8.js +0 -28
  113. package/dist/assets/contextPanelEmbeddedChat-5VGWIT_J.js +0 -1
  114. package/dist/assets/de-B6t6T54h.js +0 -9
  115. package/dist/assets/es-DH9NUKge.js +0 -15
  116. package/dist/assets/fr-Do4t2KmA.js +0 -13
  117. package/dist/assets/index-B45s9aAX.css +0 -1
  118. package/dist/assets/index-CNrN5qDs.js +0 -7
  119. package/dist/assets/ja-DJT9EM80.js +0 -15
  120. package/dist/assets/ko-CfWRq2p4.js +0 -15
  121. package/dist/assets/main-B4oBRI9u.js +0 -193
  122. package/dist/assets/markdownCore-A3_L34oS.js +0 -2
  123. package/dist/assets/pt-BR-BDEzzltP.js +0 -15
  124. package/dist/assets/renderMobileApp-DA7wpIBi.js +0 -23
  125. package/dist/assets/runtimeEndpointReset-D5izT-u5.js +0 -13
  126. package/dist/assets/scheduledTasksApi-CTJdfSWc.js +0 -1
  127. package/dist/assets/uk-B6Q32nyk.js +0 -15
  128. package/dist/assets/useInlineCommentController-D7zs7-BQ.js +0 -2
  129. package/dist/assets/vendor-zumer-snapdom-Btyu_Xi2.js +0 -8
  130. package/dist/assets/zh-CN-7MGcwGaC.js +0 -15
  131. package/dist/assets/zh-TW-CFPfqxlL.js +0 -15
  132. package/server/lib/preview/proxy-runtime.js +0 -1604
  133. package/server/lib/preview/proxy-runtime.test.js +0 -528
  134. package/server/lib/quota/opencode-go-credentials.js +0 -11
  135. package/server/lib/quota/opencode-go-credentials.test.js +0 -32
  136. package/server/lib/quota/routes.test.js +0 -40
@@ -1,23 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-WkxsWHBE.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-CNrN5qDs.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/vendor-zustand-BAGL70zf.js","assets/index-B45s9aAX.css","assets/useAppFontEffects-Bbpz77To.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-5VGWIT_J.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-Dzt9rWZZ.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-D5izT-u5.js","assets/shikiHighlight-eU8abJ3T.js","assets/vendor-codemirror-search-8kyQdB3f.js","assets/vendor-replit-codemirror-vim-B0Ecqnlh.js","assets/JsonTreeView-Kgepz4pR.js","assets/web-components-DGvnI0zx.js","assets/computeVirtualFileMetrics-DQE7R9IY.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-JbqDfa3n.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/DiagramEditor-C7nUw7p3.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/useInlineCommentController-D7zs7-BQ.js","assets/CodeMirrorCommentWidgets-CxcJ5x9h.js","assets/scheduledTasksApi-CTJdfSWc.js","assets/vendor-capacitor-status-bar-B-N0EOVk.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-keyboard-CYccoJjr.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 Yr}from"./vendor-react-BUCujlKS.js";import{u as Ve,a as Tt,b as Vn,d as sn,i as Ce,e as Ge,s as at,f as Ct,r as gs,h as Xr,j as Hn,p as Qr,k as Zr,l as ut,m as eo,n as nn,o as rn,q as to,t as on,v as so,w as no}from"./index-CNrN5qDs.js";import{u as bs,a as ro,b as ze,c as Gn,d as Kn,r as xs,e as oo,f as ue,t as ce,o as io,I as ne,B as xe,O as Je,g as Z,P as ao,h as lo,i as co,j as uo,k as Le,l as fo,m as rt,n as mo,p as an,q as po,s as ys,v as ho,w as go,x as ve,y as bo,z as qn,A as Jn,C as Yn,D as xo,E as vs,F as yo,G as Xn,H as vo,J as wo,M as jo,K as Qn,L as Zn,N as er,Q as tr,R as ws,S as ko,T as So,U as js,V as No,W as Eo,X as ln,Y as ks,Z as sr,_ as nr,$ as Ss,a0 as Co,a1 as Ro,a2 as Po,a3 as Ue,a4 as To,a5 as Io,a6 as _o,a7 as Ao,a8 as Do,a9 as Mo,aa as Lo,ab as Oe,ac as zo,ad as Oo,ae as Bo,af as Bt,ag as $o,ah as cn,ai as Fo,aj as Wo,ak as Uo,al as Vo,am as Ho,an as Go,ao as Ko,ap as qo,aq as Jo,ar as Yo,as as Xo,at as Qo,au as Zo,av as ei,aw as ti,ax as si,ay as ni,az as ri,aA as oi,aB as ii,aC as ai,aD as li,aE as ci,aF as di,aG as ui,aH as fi,aI as mi,aJ as pi,aK as hi,aL as gi,aM as bi,aN as xi}from"./useAppFontEffects-Bbpz77To.js";import{u as lt,S as rr,D as yi,N as vi,a as wi,b as ji,T as ki,P as Si,M as Ni,r as Ei,c as Ci,d as Ri,e as Pi,O as Ti,C as Ii,f as _i,g as Ai}from"./runtimeEndpointReset-D5izT-u5.js";import{_ as $e}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as Di,A as Mi}from"./SettingsView-e7Fmxnz8.js";import{PlanView as Li}from"./PlanView-BYgHBHDt.js";import{p as zi}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as Oi}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as cs,s as or,M as Ns,a as Ut,J as ds,p as Bi,_ as dn,b as ir,P as ar,d as $i,f as Es,V as Fi,K as un,c as Wi,Q as Ui,r as Vi,U as Hi,Z as Gi}from"./vendor-remixicon-react-Dil0zKKT.js";import{f as Cs,h as ft,i as Rs,P as Ps,D as Ts,j as Is}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as _s,S as As,v as Ds,u as Ms}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Ls}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as zs,p as lr}from"./vendor-zustand-BAGL70zf.js";import{C as Ki,a as qi}from"./CommitSection-C9sBBYAJ.js";import{P as Ji}from"./PierreDiffViewer-B5k0KvPW.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-5VGWIT_J.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-Dzt9rWZZ.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-eU8abJ3T.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-D7zs7-BQ.js";import"./CodeMirrorCommentWidgets-CxcJ5x9h.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./web-components-DGvnI0zx.js";import"./computeVirtualFileMetrics-DQE7R9IY.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-Dcu8Q-5P.js";import"./isDiffPlainText-XyBCe4eD.js";import"./vendor-diff-C3JhlQdm.js";let cr=null,fn=!1;const Yi=new Promise(s=>{cr=s});function Xi(){fn||(fn=!0,cr?.())}const Qi=6,Zi=s=>s.parentID??null,mn=s=>{const e=s.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},ea=s=>s.replace(/\\/g,"/").replace(/\/+$/,""),ta=(s,e)=>{if(!s)return"";let n=null,o=-1;for(const r of e){const i=ea(r.path);(s===i||s.startsWith(`${i}/`))&&i.length>o&&(n=r,o=i.length)}return n?n.label?.trim()||mn(n.path):mn(s)},sa=()=>{const s=bs.getState().activeSessions,e=ro.getState().index.session.unseenCount,n=Ve.getState().notifyOnSubtasks,o=ze.getState().projects,r=Gn.getState().ids,i=Kn.getState().rankById;let a=0;const c=[];for(const f of s){const d=Zi(f)!==null,g=(e[f.id]??0)>0&&(!d||n);g&&(a+=1),d||c.push({session:f,unread:g,project:ta(xs(f),o)})}c.sort((f,d)=>oo(f.session,d.session,r,i));const u=c.slice(0,Qi).map(({session:f,unread:d,project:m})=>({id:f.id,title:f.title??"",unread:d,project:m}));return{runtimeKey:Tt(),attentionCount:a,recentSessions:u}},na="__OPENCHAMBER_WIDGET_SNAPSHOT__",ra=()=>{typeof window>"u"||(window[na]=()=>{try{return JSON.stringify(sa())}catch{return null}})},es="mobile-app-update-available",pn="mobile-app-update-toast-dismissed-version",oa=()=>{const s=de.c(8),{t:e}=ue(),n=lt(ia),o=lt(aa),r=lt(la),i=lt(ca);let a;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,s[0]=a):a=s[0];const c=ls.useRef(a);let u,f;return s[1]!==n||s[2]!==i||s[3]!==o||s[4]!==e||s[5]!==r?(u=()=>{if(Vn()!=="android"||o!=="mobile"||!n||!r||!i){ce.dismiss(es);return}sn().getItem(pn)!==r&&(c.current.has(r)||(c.current.add(r),ce.info(e("mobileUpdate.toast.available.title"),{id:es,description:e("mobileUpdate.toast.available.description",{version:r}),duration:1/0,icon:t.jsx(ne,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{io(i)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{sn().setItem(pn,r),ce.dismiss(es)}}})))},f=[n,i,o,e,r],s[1]=n,s[2]=i,s[3]=o,s[4]=e,s[5]=r,s[6]=u,s[7]=f):(u=s[6],f=s[7]),ls.useEffect(u,f),null};function ia(s){return s.available}function aa(s){return s.runtimeType}function la(s){return s.info?.version}function ca(s){return s.info?.downloadUrl}const Vt="openchamber.mobile.connections.v1",da="openchamber.mobile.",hn="openchamber.mobile.deviceId",ua=()=>{try{const s=window.localStorage.getItem(hn);if(s&&s.trim())return s.trim();const e=crypto.randomUUID();return window.localStorage.setItem(hn,e),e}catch{return crypto.randomUUID()}},gn=()=>`mobile:${ua()}`,bn=()=>{try{const s=Oi.getPlatform();return s==="ios"||s==="android"?s:void 0}catch{return}},dr=12,fa=8e3,ma=2500,pa=3e3,Ht=2500,ha=()=>{let s=0;return{begin:()=>(s+=1,s),cancel:()=>{s+=1},isCurrent:e=>e===s}},ht=s=>{const e=s.trim();if(!e)return"";const n=/^https?:\/\//i.test(e)?e:`http://${e}`,o=new URL(n);return o.hash="",o.search="",o.pathname=o.pathname.replace(/\/+$/,""),o.toString().replace(/\/+$/,"")},$t=s=>{try{return new URL(s).host}catch{return s}},mt=s=>{try{return ht(s)}catch{return s.trim().replace(/\/+$/g,"")}},ur=(s,e)=>mt(s)===mt(e),fr=s=>`relay:${s.serverId}@${s.relayUrl.trim()}`,ga=s=>`relay://${s.serverId}`,Jt=s=>s.candidates.filter(e=>e.kind==="direct"),Qe=s=>{const e=s.candidates.find(n=>n.kind==="relay");return e&&e.kind==="relay"?e.relay:null},He=s=>{const e=Jt(s)[0];if(e)return e.url;const n=Qe(s);return n?ga(n):""},Ne=s=>{const e=Qe(s);if(e)return fr(e);const n=Jt(s)[0];return n?mt(n.url):""},Gt=(s,e)=>{const n=s.find(i=>i.kind==="relay"),o=n&&n.kind==="relay"?n.relay.serverId:null,r=new Set(s.filter(i=>i.kind==="direct").map(i=>mt(i.url)));return e.some(i=>i.kind==="relay"?o!==null&&i.relay.serverId===o:r.has(mt(i.url)))},Os=s=>{const e=(()=>{try{return ht(s)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},xn=s=>{if(s.candidates&&s.candidates.length>0)return s.candidates;const e=[];return typeof s.url=="string"&&s.url.trim()&&!/^relay:\/\//i.test(s.url.trim())&&e.push(...Os(s.url)),s.relay&&e.push({kind:"relay",relay:s.relay}),e},Bs=s=>{if(!s||typeof s!="object"||Array.isArray(s))return null;const e=s;if(typeof e.relayUrl!="string"||!e.relayUrl.trim()||typeof e.serverId!="string"||!e.serverId.trim())return null;const n=e.hostEncPubJwk;if(!n||typeof n!="object"||Array.isArray(n))return null;const o=n;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}}},Yt=s=>{try{return JSON.stringify(s)}catch{return String(s)}},_e=(s,e={})=>{console.info("[mobile-connect]",s,Yt(e))},pt=(s,e={})=>{console.info("[mobile-storage]",s,Yt(e))},ba=s=>{if(typeof s!="string")return s;try{return JSON.parse(s)}catch{return s}},xa=s=>{if(typeof s!="string")return s??void 0;try{return JSON.parse(s)}catch{return s}},ya=async(s,e)=>{if(!Ce())return null;try{const{CapacitorHttp:n}=await $e(async()=>{const{CapacitorHttp:i}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:i}},[]),o=Object.fromEntries(new Headers(e?.headers).entries()),r=await n.request({url:s,method:e?.method||"GET",headers:o,data:xa(e?.body)});return{ok:r.status>=200&&r.status<300,status:r.status,source:"native-http",json:async()=>ba(r.data)}}catch(n){return console.warn("[mobile-connect]","native-http failed",Yt({url:s,error:n instanceof Error?n.message:String(n)})),null}},va=async(s,e)=>{const n=await fetch(s,e).catch(o=>(console.warn("[mobile-connect]","browser-fetch failed",Yt({url:s,error:o instanceof Error?o.message:String(o)})),null));return n?{ok:n.ok,status:n.status,source:"browser-fetch",json:()=>n.json()}:null},qe=async(s,e,n)=>{let o;const r=new Promise(i=>{o=window.setTimeout(()=>{n?.(),i(null)},s)});try{return await Promise.race([e,r])}catch{return null}finally{o!==void 0&&window.clearTimeout(o)}},Ze=async(s,e,n)=>{const o=n?.totalTimeoutMs??fa,r=Date.now(),i=await qe(Math.min(ma,o),ya(s,e));if(i)return i;const a=new AbortController,c=Math.max(500,o-(Date.now()-r));return qe(c,va(s,{...e,signal:a.signal}),()=>a.abort())},Xt=async s=>{if(!s)return null;const e=await s.json().catch(()=>null);if(!e||typeof e!="object")return null;const n=e;return{authenticated:typeof n.authenticated=="boolean"?n.authenticated:void 0,disabled:typeof n.disabled=="boolean"?n.disabled:void 0,scope:typeof n.scope=="string"?n.scope:void 0}},Rt=15e3,wa=async(s,e,n,o=Rt,r)=>{const i=Hn({relayUrl:s.relayUrl,serverId:s.serverId,hostEncPubJwk:s.hostEncPubJwk}),a=c=>c==="ok"&&r?.keepTunnel?{outcome:c,tunnel:i}:(i.close(),{outcome:c});try{const c=e?{Authorization:`Bearer ${e}`}:void 0,u=await qe(o,i.fetch("/auth/session",{headers:c}).catch(()=>null));if(_e("relay:session",{ok:u?.ok===!0,status:u?.status??null,hasToken:!!e}),!u)return a("unreachable");if(u.status===401)return a(e?"auth-failed":"needs-login");if(!u.ok&&u.status!==404)return a("auth-failed");const f=await Xt(u);return f&&f.disabled!==!0&&f.authenticated===!1?a(e?"auth-failed":"needs-login"):a("ok")}catch(c){throw i.close(),c}},ja=(s,e,n,o,r)=>{const i=typeof window<"u"?window.location.origin:"",a={relayUrl:s.relayUrl,serverId:s.serverId,hostEncPubJwk:s.hostEncPubJwk,...n?{grant:n}:{}};r&&Xr(a,r),at({apiBaseUrl:i,clientToken:e,runtimeKey:o??fr(s),relay:a})},ka=s=>{if(!s||typeof s!="object")return null;const e=s;if(e.kind==="direct")return typeof e.url=="string"&&e.url.trim()?{kind:"direct",url:e.url}:null;if(e.kind==="relay"){const n=Bs(e.relay);return n?{kind:"relay",relay:n}:null}return null},Sa=s=>{if(s.mode==="relay"){const e=Bs(s.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof s.url=="string"?Os(s.url):[]},tt=()=>{if(typeof window>"u")return[];let s;try{s=JSON.parse(window.localStorage.getItem(Vt)||"[]")}catch{return[]}if(!Array.isArray(s))return[];const e=Ce();return s.flatMap(n=>{if(!n||typeof n!="object")return[];const o=n;if(typeof o.id!="string")return[];const r=Array.isArray(o.candidates)?o.candidates.map(ka).filter(u=>!!u):Sa(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:$t(He({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((n,o)=>o.lastUsedAt-n.lastUsedAt)},us=s=>s.kind==="relay"?{kind:"relay",relay:{relayUrl:s.relay.relayUrl,serverId:s.relay.serverId,hostEncPubJwk:s.relay.hostEncPubJwk}}:{kind:"direct",url:s.url},$s=s=>{if(typeof window>"u")return;const e=Ce(),n=s.slice(0,dr).map(o=>{const r={id:o.id,label:o.label,candidates:o.candidates.map(us),lastUsedAt:o.lastUsedAt};return e?{...r,hasToken:!!(o.hasToken||o.clientToken)}:{...r,clientToken:o.clientToken}});try{window.localStorage.setItem(Vt,JSON.stringify(n))}catch(o){console.warn("[mobile-storage] failed to persist connection metadata",o)}},mr=(s,e)=>{const n=s.find(i=>e.id&&i.id===e.id||Gt(i.candidates,e.candidates)),o=Ce(),r={id:e.id||n?.id||crypto.randomUUID(),label:e.label,candidates:e.candidates,lastUsedAt:Date.now(),...o?{hasToken:e.hasToken??(!!e.clientToken||n?.hasToken||!1)}:{clientToken:e.clientToken??n?.clientToken,hasToken:!!(e.clientToken??n?.clientToken)}};return[r,...s.filter(i=>i.id!==r.id&&!Gt(i.candidates,e.candidates))].slice(0,dr)},Fs=zi,Na=0,Ws=s=>`${da}token.${encodeURIComponent(s)}`,Ea=async(s,e)=>{let n;const o=new Promise(r=>{n=window.setTimeout(()=>r(e),pa)});try{return await Promise.race([s.catch(()=>e),o])}finally{n!==void 0&&window.clearTimeout(n)}},Us=async(s,e,n)=>Ce()?Ea(e().catch(o=>(console.warn(`[mobile-storage] ${s} failed`,o),n)),n):n,Pt=async s=>{pt("secure:read-start",{key:s});const e=await Us("secure:read",async()=>(await Fs.internalGetItem({prefixedKey:Ws(s),sync:!1})).data,null),n=typeof e=="string"&&e.trim()?e:void 0;return pt("secure:read",{key:s,hasToken:!!n}),n},Ye=async(s,e)=>{pt("secure:write-start",{key:s});const n=await Us("secure:write",async()=>(await Fs.internalSetItem({prefixedKey:Ws(s),data:e,sync:!1,access:Na}),!0),!1);return pt("secure:write",{key:s,ok:n}),n},Ca=async s=>{await Us("secure:delete",async()=>(await Fs.internalRemoveItem({prefixedKey:Ws(s),sync:!1}),!0),!1)},Ra=async(s,e)=>{let n=0,o=0;return{records:await Promise.all(s.map(async i=>{if(!i||typeof i!="object")return i;const a=i,c=typeof a.url=="string"?a.url:null,u=typeof a.clientToken=="string"?a.clientToken.trim():"";if(!c||!u)return i;if(!await e(c,u))return o+=1,i;n+=1;const{clientToken:f,...d}=a;return{...d,hasToken:!0}})),migrated:n,failed:o}},pr=async()=>{if(typeof window>"u"||!Ce())return;let s;try{s=JSON.parse(window.localStorage.getItem(Vt)||"[]")}catch{return}if(!Array.isArray(s))return;const e=s.filter(o=>!!o&&typeof o=="object"&&typeof o.url=="string"&&typeof o.clientToken=="string"&&!!o.clientToken.trim());if(e.length===0)return;pt("secure:migrate-start",{count:e.length});const n=await Ra(s,async(o,r)=>{const i=mt(o);return await Ye(i,r)?await Pt(i)===r:!1});if(n.migrated>0)try{window.localStorage.setItem(Vt,JSON.stringify(n.records))}catch(o){console.warn("[mobile-storage] failed to finalize secure token migration",o);return}pt("secure:migrate-done",{migrated:n.migrated,failed:n.failed})},Pa=async()=>(await pr(),tt()),Kt=async s=>{const e=mr(tt(),s);return $s(e),Ce()&&s.clientToken&&await Ye(Ne({candidates:s.candidates}),s.clientToken),e},Ta=async s=>{const e=tt(),n=e.find(r=>r.id===s)??null,o=e.filter(r=>r.id!==s);return $s(o),n&&Ce()&&await Ca(Ne(n)),o},Ia=1500,qt=async(s,e,n)=>{const o=n?.fast?{totalTimeoutMs:Ht}:void 0,r=Qe({candidates:s})?.serverId??null,i=s.find(f=>f.kind==="relay")??null,a=s.filter(f=>f.kind==="direct"),c=async()=>{for(const f of a){const d=ht(f.url)||f.url,m=e?{Authorization:`Bearer ${e}`}:void 0,g=await Ze(`${d}/health`,{method:"GET"},o);if(!g?.ok)continue;if(r){const x=await g.json().catch(()=>null),A=x&&typeof x=="object"?x.serverId:null;if(typeof A=="string"&&A&&A!==r){_e("probe:server-id-mismatch",{url:d});continue}}const b=await Ze(`${d}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:m},o);if(b?.status===401)return{status:"needs-login"};if(!b||!b.ok&&b.status!==404)continue;const v=await Xt(b);if(v&&v.disabled!==!0&&v.authenticated===!1)return{status:"needs-login"};const E=v?.disabled===!0;return!e&&Ce()&&!E&&v?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:d}}}return{status:"unreachable"}},u=async()=>{if(!i)return{status:"unreachable"};const{outcome:f,tunnel:d}=await wa(i.relay,e,void 0,n?.fast?Ht:void 0,{keepTunnel:!0});return f==="ok"?{status:"ok",transport:{kind:"relay",relay:i.relay,tunnel:d}}:f==="needs-login"||f==="auth-failed"?{status:"needs-login"}:{status:"unreachable"}};return i?a.length===0?u():new Promise(f=>{let d=!1,m=!1,g,b=null,v=null;const E=C=>{C?.status==="ok"&&C.transport.kind==="relay"&&C.transport.tunnel?.close()},x=C=>{d||(d=!0,f(C))},A=()=>{m||d||(g!==void 0&&(window.clearTimeout(g),g=void 0),u().then(C=>{if(v=C,d||m){E(C);return}if(C.status==="ok"||C.status==="needs-login"){x(C);return}b&&x(b)}))};c().then(C=>{if(b=C,!d){if(C.status==="ok"||C.status==="needs-login"){m=!0,g!==void 0&&window.clearTimeout(g),E(v),x(C);return}if(v){x(v);return}A()}}),g=window.setTimeout(A,Ia)}):c()},Xe=(s,e,n)=>{s.kind==="relay"?ja(s.relay,e,n?.grant,n?.runtimeKey,s.tunnel):at({apiBaseUrl:s.url,clientToken:e,runtimeKey:n?.runtimeKey}),gr()},vt=()=>{const s=tt()[0];return s?.label?.trim()?s.label:null},ts=async()=>{await pr();const s=tt()[0];if(!s)return{status:"no-candidate"};let e;if(Ce()){if(!s.hasToken)return{status:"no-candidate"};if(e=await Pt(Ne(s)),!e)return{status:"no-candidate"}}else if(e=s.clientToken,!e)return{status:"no-candidate"};const n=await qt(s.candidates,e,{fast:!0});return n.status==="needs-login"?{status:"needs-login",label:s.label}:n.status!=="ok"?{status:"unreachable",label:s.label}:(await Kt({id:s.id,label:s.label,candidates:s.candidates}),Xe(n.transport,e,{runtimeKey:Ne(s)}),{status:"connected"})},_a=async(s,e)=>{let n="";try{n=ht(s.url)}catch{return!1}if(!n)return!1;const o=s.clientToken?.trim()||void 0,r=o?{Authorization:`Bearer ${o}`}:void 0,i={totalTimeoutMs:Ht};if(!(await Ze(`${n}/health`,{method:"GET",headers:r},i))?.ok)return!1;const c=await Ze(`${n}/auth/session`,{method:"GET",credentials:o?"omit":"include",headers:r},i);if(!c||!c.ok&&c.status!==404)return!1;const u=await Xt(c);return!(u&&u.disabled!==!0&&u.authenticated===!1)},Aa=s=>[...s].sort((e,n)=>{const o=(e.priority??100)-(n.priority??100);if(o!==0)return o;const r=i=>i.type==="relay"?2:i.url.startsWith("https://")?0:1;return r(e)-r(n)}).flatMap(e=>{if(e.type==="relay"){const n=Bs({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return n?[{kind:"relay",relay:n}]:[]}return Os(e.url)}),yn=async s=>{const e=Qe({candidates:s})?.serverId??null;for(const n of s){if(n.kind==="relay"){const i=Hn(n.relay),a=await qe(Rt,i.fetch("/health").catch(()=>null));if(_e("establish:relay:health",{ok:a?.ok===!0,status:a?.status??null}),a?.ok)return{kind:"relay",relay:n.relay,tunnel:i};i.close();continue}const o=ht(n.url)||n.url,r=await Ze(`${o}/health`,{method:"GET"});if(_e("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){_e("establish:server-id-mismatch",{url:o});continue}}return{kind:"direct",url:o}}}return null},Da=async(s,e)=>{if(!Ct())return _a(s);const n=await qe(Ht,gs("/auth/session").then(r=>r).catch(()=>null));if(!n)return!0;if(n.status===401)return!1;if(!n.ok&&n.status!==404)return!0;const o=await Xt(n);return!(o&&o.disabled!==!0&&o.authenticated===!1)},Ma=s=>s.kind==="relay"?Ct():!Ct()&&ur(s.url,Ge()),hr=()=>{const s=Tt();return s?tt().find(e=>Ne(e)===s)??null:null},vn=s=>{const e=Tt();return!!e&&Ne(s)===e},Ft=async()=>{const s=hr();if(!s)return"no-connection";let e;if(Ce()?e=s.hasToken?await Pt(Ne(s)):void 0:e=s.clientToken,!e)return"unreachable";const n=s.candidates.findIndex(c=>Ma(c.kind==="relay"?{kind:"relay",relay:c.relay}:{kind:"direct",url:c.url})),o=n>=0?s.candidates.slice(0,n):s.candidates,r=await qt(o,e,{fast:!0});if(r.status==="ok")return await Kt({id:s.id,label:s.label,candidates:s.candidates}),Xe(r.transport,e,{runtimeKey:Ne(s)}),"switched";if(r.status==="needs-login")return"needs-login";if(n>=0&&await Da({url:Ge(),clientToken:e}))return gr(),"unchanged";const i=n>=0?s.candidates.slice(n+1):[],a=await qt(i,e,{fast:!0});return a.status==="ok"?(await Kt({id:s.id,label:s.label,candidates:s.candidates}),Xe(a.transport,e,{runtimeKey:Ne(s)}),"switched"):a.status==="needs-login"?"needs-login":"unreachable"},La=5e3;let ss=!1;const za=async()=>{if(ss)return"skipped";const s=hr();if(!s)return _e("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=Qe(s);if(!e)return _e("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";ss=!0;try{const n=await qe(Rt,gs("/api/client-auth/connection/candidates").then(f=>f).catch(()=>null));if(!n?.ok)return _e("candidates:refresh-skip",{reason:"fetch-failed",status:n?.status??null}),"skipped";const o=await n.json().catch(()=>null);if(!o||o.serverId!==e.serverId)return _e("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 d=f;if(!(d.type!=="lan"||typeof d.url!="string"))try{const m=ht(d.url);m&&!i.includes(m)&&i.push(m)}catch{}}if(i.length===0)return _e("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const a=Jt(s).filter(f=>f.url.startsWith("https://")),c=[...i.map(f=>({kind:"direct",url:f})),...a,{kind:"relay",relay:e}];return JSON.stringify(s.candidates.map(us))===JSON.stringify(c.map(us))?"unchanged":(_e("candidates:refreshed",{lanCount:i.length}),await Kt({id:s.id,label:s.label,candidates:c}),"updated")}finally{ss=!1}},gr=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const s=await za().catch(()=>"skipped");_e("candidates:refresh-result",{result:s}),s==="updated"&&Ct()&&await Ft().catch(()=>null)})()},La)},br=s=>{const{t:e}=ue(),[n,o]=l.useState(()=>tt()),[r,i]=l.useState(null),[a,c]=l.useState(null),[u,f]=l.useState(null),d=l.useRef(n),m=l.useRef(null),g=l.useRef(ha()),b=l.useCallback(j=>{d.current=j,o(j)},[]),v=l.useCallback(j=>{m.current=j,i(j)},[]),E=l.useCallback(j=>{m.current===j&&(m.current=null,i(null))},[]);l.useEffect(()=>{let j=!1;return Pa().then(R=>{j||b(R)}),()=>{j=!0}},[b]);const x=l.useCallback(j=>{const R=mr(d.current,j);return b(R),$s(R),R},[b]),A=l.useCallback(async j=>{c(null),v("connect");try{const R=xn(j);if(R.length===0){c(e("mobile.connect.error.urlRequired"));return}const y=j.id?d.current.find(O=>O.id===j.id):d.current.find(O=>Gt(O.candidates,R)),w=j.label?.trim()||y?.label||$t(He({candidates:R})),T=j.relayGrant;let S=j.clientToken?.trim()||void 0;const k=!!S;S||(Ce()?y?.hasToken&&(S=await Pt(Ne({candidates:R}))):S=y?.clientToken),_e("connect:start",{candidates:R.map(O=>O.kind),hasToken:!!S});const $=await qt(R,S);if(_e("connect:probe",{status:$.status}),$.status==="unreachable"){c(e("mobile.connect.error.unreachable"));return}if($.status==="needs-login"){x({id:y?.id,label:w,candidates:R}),f({id:y?.id??crypto.randomUUID(),label:w,candidates:R,relay:Qe({candidates:R})??void 0,relayGrant:T});return}S&&k&&Ce()&&await Ye(Ne({candidates:R}),S),x({id:y?.id,label:w,candidates:R,clientToken:S}),Xe($.transport,S??null,{runtimeKey:Ne({candidates:R}),grant:T}),s()}catch(R){console.warn("[mobile-connect] connect threw",R),c(e("mobile.connect.error.invalidUrl"))}finally{E("connect")}},[v,E,s,x,e]),C=l.useCallback(async j=>{if(m.current==="pairing")return;c(null),v("pairing");const R=Aa(j.candidates);let y=null,w=!1;try{if(y=await yn(R),!y){c(e("mobile.connect.error.unreachable"));return}const T=JSON.stringify({pairingId:j.pairingId,secret:j.secret,clientLabel:"OpenChamber Mobile",clientKind:"mobile",deviceName:"OpenChamber Mobile",devicePlatform:bn(),dedupeKey:gn()}),S={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:T},k=y.kind==="relay"?await qe(Rt,y.tunnel.fetch("/api/client-auth/pairing/redeem",S).catch(()=>null)):await Ze(`${y.url}/api/client-auth/pairing/redeem`,S);if(!k?.ok){c(e("mobile.connect.error.authRequired"));return}const $=await k.json().catch(()=>null),O=typeof $?.clientToken=="string"?$.clientToken.trim():"";if(!O){c(e("mobile.connect.error.authRequired"));return}const h=typeof $?.server?.label=="string"?$.server.label:"",N=j.label||h||$t(He({candidates:R}));if(Ce()&&!await Ye(Ne({candidates:R}),O)){c(e("mobile.connect.error.authRequired"));return}x({label:N,candidates:R,clientToken:O}),Xe(y.kind==="relay"?{kind:"relay",relay:y.relay,tunnel:y.tunnel}:{kind:"direct",url:y.url},O,{runtimeKey:Ne({candidates:R})}),w=y.kind==="relay",s()}catch(T){console.warn("[mobile-connect] pairing threw",T),c(e("mobile.connect.error.authRequired"))}finally{!w&&y?.kind==="relay"&&y.tunnel.close(),E("pairing")}},[v,E,s,x,e]),P=l.useCallback(async j=>{if(!u||!j.trim()||m.current==="password")return;c(null),v("password");const R=g.current.begin(),y=()=>g.current.isCurrent(R),{id:w,label:T,candidates:S}=u;let k=null,$=!1;try{if(k=await yn(S),!y())return;if(!k){c(e("mobile.connect.error.unreachable"));return}const O={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:j,trustDevice:!0,issueClientToken:!0,clientLabel:"OpenChamber Mobile",clientKind:"mobile",devicePlatform:bn(),dedupeKey:gn()})};_e("password:start",{transport:k.kind});const h=k.kind==="relay"?await qe(Rt,k.tunnel.fetch("/auth/session",O).catch(()=>null)):await Ze(`${k.url}/auth/session`,O);if(!y())return;if(_e("password:done",{ok:h?.ok===!0,status:h?.status??null}),!h?.ok){c(e("mobile.connect.error.passwordFailed"));return}const N=await h.json().catch(()=>null);if(!y())return;const L=typeof N?.clientToken=="string"?N.clientToken.trim():"";if(_e("password:token",{issued:!!L}),!L){if(k.kind==="direct"&&!Ce()){x({id:w,label:T,candidates:S}),f(null),Xe({kind:"direct",url:k.url},null,{runtimeKey:Ne({candidates:S})}),s();return}c(e("mobile.connect.error.authRequired"));return}if(Ce()&&(!y()||(await Ye(Ne({candidates:S}),L),!y()))||!y()||(x({id:w,label:T,candidates:S,clientToken:L}),f(null),Xe(k.kind==="relay"?{kind:"relay",relay:k.relay,tunnel:k.tunnel}:{kind:"direct",url:k.url},L,{runtimeKey:Ne({candidates:S})}),$=k.kind==="relay",!y()))return;s()}catch(O){if(!y())return;console.warn("[mobile-connect] password threw",O),c(e("mobile.connect.error.passwordFailed"))}finally{!$&&k?.kind==="relay"&&k.tunnel.close(),y()&&E("password")}},[v,E,s,u,x,e]),I=l.useCallback(()=>{g.current.cancel(),E("password"),f(null),c(null)},[E]),_=l.useCallback(async j=>{c(null);let R=xn(j);const y=j.id?d.current.find(k=>k.id===j.id)??null:null;if(y){const k=R.filter(h=>h.kind==="direct"),$=Jt(y).filter(h=>h.url.startsWith("https://")&&!k.some(N=>ur(N.url,h.url))),O=Qe(y);R=[...k,...$,...O?[{kind:"relay",relay:O}]:[]]}if(R.length===0)return c(e("mobile.connect.error.urlRequired")),null;const w=j.clientToken?.trim()||void 0,T=j.label?.trim()||$t(He({candidates:R}));if(Ce()){const k=Ne({candidates:R});if(w)await Ye(k,w);else if(y?.hasToken){const $=Ne(y);if($&&k&&$!==k){const O=await Pt($);O&&await Ye(k,O)}}}return x({id:j.id,label:T,candidates:R,clientToken:w}).find(k=>Gt(k.candidates,R))??null},[x,e]),D=l.useCallback(async j=>{const R=d.current.find(w=>w.id===j)??null,y=await Ta(j);return b(y),R},[b]);return{connections:n,isBusy:r!==null,isPasswordBusy:r==="password",error:a,pendingConnection:u,connect:A,redeemPairingConnection:C,submitPassword:P,cancelPassword:I,saveConnection:_,removeConnection:D,setError:c}},xr=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},Oa=()=>window.Capacitor?.getPlatform?.()==="android",yr=s=>{const e=s.trim();if(!e)return null;if(/^openchamber:\/\//i.test(e)){const n=Qr(e);return n?{pairing:n}:null}return/^https?:\/\//i.test(e)?{url:e}:null},vr=(s,e)=>{const n=yr(s);if(!n&&e?.pairingStringFallback){const o=Zr(s);if(o)return{status:"pairing",pairing:o}}return n?"pairing"in n?{status:"pairing",...n}:{status:"ok",...n}:{status:"invalid"}},Ba=async(s,e)=>{if(!s.startScan||!s.stopScan||!s.addListener)return{status:"unsupported"};if(e?.aborted)return{status:"cancelled"};let n,o,r=!1,i=()=>{};const a=new Promise(f=>{i=f}),c=f=>{r||(r=!0,i(f))},u=()=>c({status:"cancelled"});e?.addEventListener("abort",u,{once:!0});try{return(await Promise.allSettled([Promise.resolve(s.addListener("barcodesScanned",({barcodes:d})=>{const m=d?.[0],g=(m?.rawValue??m?.displayValue??"").trim();g&&c(vr(g,{pairingStringFallback:!0}))})).then(d=>{n=d}),Promise.resolve(s.addListener("scanError",()=>c({status:"failed"}))).then(d=>{o=d})])).some(({status:d})=>d==="rejected")?c({status:"failed"}):r||s.startScan({formats:["QR_CODE"]}).catch(()=>c({status:"failed"})),await a}finally{e?.removeEventListener("abort",u),await Promise.allSettled([Promise.resolve(n?.remove()),Promise.resolve(o?.remove()),s.stopScan()])}},fs=()=>xr()!==null,wr=async s=>{const e=xr();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(s?.signal?.aborted)return{status:"cancelled"};if(Oa())return Ba(e,s?.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?vr(r):{status:"cancelled"}}catch{return{status:"failed"}}},ct={autoComplete:"off",autoCorrect:"off",spellCheck:!1},wt="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",jr=s=>{const e=de.c(22),{onCancel:n}=s,{t:o}=ue(),r=l.useRef(null);let i,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const A={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},C={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 P=new Map,I=D=>{!(D instanceof HTMLElement)||D===r.current||P.has(D)||(P.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(I);const _=new MutationObserver(D=>{D.forEach(j=>j.addedNodes.forEach(I))});return _.observe(document.body,{childList:!0}),()=>{_.disconnect(),P.forEach($a),A.value?document.documentElement.style.setProperty("background-color",A.value,A.priority):document.documentElement.style.removeProperty("background-color"),C.value?document.body.style.setProperty("background-color",C.value,C.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,u;e[2]!==n?(c=()=>{const A=()=>{document.visibilityState==="hidden"&&n()};return document.addEventListener("visibilitychange",A),()=>document.removeEventListener("visibilitychange",A)},u=[n],e[2]=n,e[3]=c,e[4]=u):(c=e[3],u=e[4]),l.useEffect(c,u);let f;e[5]!==o?(f=o("mobile.connect.scanQr"),e[5]=o,e[6]=f):f=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=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]=d):d=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:[d,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 b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(ne,{name:"close",className:"size-[18px]"}),e[12]=b):b=e[12];let v;e[13]!==o?(v=o("mobile.instances.cancelEdit"),e[13]=o,e[14]=v):v=e[14];let E;e[15]!==n||e[16]!==v?(E=t.jsxs(xe,{type:"button",variant:"outline",size:"lg",className:"mx-auto min-h-12 w-full max-w-sm bg-background",onClick:n,children:[b,v]}),e[15]=n,e[16]=v,e[17]=E):E=e[17];let x;return e[18]!==E||e[19]!==f||e[20]!==g?(x=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,E]}),document.body),e[18]=E,e[19]=f,e[20]=g,e[21]=x):x=e[21],x},kr=()=>{const s=de.c(6),{t:e}=ue();let n;s[0]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(Je,{width:96,height:96,isAnimated:!0}),s[0]=n):n=s[0];let o;s[1]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(ne,{name:"loader-4",className:"size-[18px] animate-spin"}),s[1]=o):o=s[1];let r;s[2]!==e?(r=e("mobile.connect.connecting"),s[2]=e,s[3]=r):r=s[3];let i;return s[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:[n,t.jsxs("div",{className:"flex items-center gap-2 typography-ui-label text-muted-foreground",children:[o,t.jsx("span",{children:r})]})]}),document.body),s[4]=r,s[5]=i):i=s[5],i};function $a(s,e){e.style.opacity=s.opacity,e.style.pointerEvents=s.pointerEvents}const Fa=({onConnected:s,notice:e=null})=>{const{t:n}=ue(),o=br(s),{connections:r,isBusy:i,isPasswordBusy:a,error:c,pendingConnection:u}=o,[f,d]=l.useState(""),[m,g]=l.useState(""),[b,v]=l.useState(""),[E,x]=l.useState(!1),[A,C]=l.useState(!1),P=l.useRef(null),I=l.useMemo(()=>fs(),[]),[_,D]=l.useState(()=>!fs()),[j,R]=l.useState(null),[y,w]=l.useState(""),T=l.useCallback(h=>{h.preventDefault(),o.connect({url:f,clientToken:b,label:m})},[b,o,m,f]),S=l.useCallback(h=>{if(/^openchamber:\/\//i.test(h.trim())){const N=yr(h);if(N){if("pairing"in N){o.redeemPairingConnection(N.pairing);return}d(N.url),N.label&&g(N.label),N.clientToken&&v(N.clientToken);return}}d(h)},[o]),k=l.useCallback(async()=>{if(P.current||i)return;o.setError(null),x(!0);const h=new AbortController;P.current=h;try{const N=await wr({signal:h.signal});switch(P.current===h&&(P.current=null,x(!1)),N.status){case"ok":C(!0),d(N.url),N.label&&g(N.label),N.clientToken&&v(N.clientToken),await o.connect({url:N.url,clientToken:N.clientToken,label:N.label});break;case"pairing":C(!0),await o.redeemPairingConnection(N.pairing);break;case"permission-denied":o.setError(n("mobile.connect.scan.permissionDenied"));break;case"invalid":o.setError(n("mobile.connect.scan.invalid"));break;case"unsupported":o.setError(n("mobile.connect.scan.unsupported"));break;case"failed":o.setError(n("mobile.connect.scan.failed"));break;default:break}}finally{C(!1),P.current===h&&(P.current=null,x(!1))}},[o,i,n]);l.useEffect(()=>()=>P.current?.abort(),[]);const $=l.useCallback(h=>{h.preventDefault(),o.submitPassword(y)},[o,y]),O=l.useCallback(()=>{w(""),o.cancelPassword()},[o]);return t.jsxs(t.Fragment,{children:[E?t.jsx(jr,{onCancel:()=>P.current?.abort()}):null,A?t.jsx(kr,{}):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(Je,{width:72,height:72,className:"size-[72px]"}),t.jsx("h1",{className:"typography-h2 text-foreground",children:n("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(ne,{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"?n("mobile.connect.notice.authExpired",{label:e.label}):n("mobile.connect.notice.unreachable",{label:e.label})})]}):null,u?t.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:$,children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(ne,{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:u.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:u.candidates.some(h=>h.kind==="direct")?He(u):n("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...ct,value:y,onChange:h=>w(h.target.value),placeholder:n("mobile.connect.password.placeholder"),"aria-label":n("mobile.connect.password.label"),type:"password",autoFocus:!0,className:wt}),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:n(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(xe,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:O,children:n("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[I?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:()=>{k()},disabled:E||i,children:[t.jsx(ne,{name:"scan-2",className:Z("size-[18px]",E&&"animate-pulse")}),n(i?"mobile.connect.connecting":"mobile.connect.scanQr")]}),t.jsx("p",{className:"px-2 text-center typography-small text-muted-foreground",children:n("mobile.connect.welcome.scanHint")})]}):null,c&&!_?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:n("mobile.connect.saved.title")}),t.jsx("div",{className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(h=>{const N=j===h.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:()=>{R(h.id),o.connect({id:h.id,candidates:h.candidates,clientToken:h.clientToken,label:h.label}).finally(()=>R(null))},children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(ne,{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:h.label}),t.jsx("span",{className:Z("block truncate typography-small",N?"text-foreground":"text-muted-foreground"),children:N?n("mobile.connect.connecting"):h.candidates.some(L=>L.kind==="direct")?He(h):n("mobile.connect.relay.badge")})]}),N?t.jsx(ne,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(ne,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},h.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[I?t.jsxs("button",{type:"button",onClick:()=>D(h=>!h),"aria-expanded":_,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:n("mobile.connect.manual.toggle")}),t.jsx(ne,{name:"arrow-down-s",className:Z("size-4 transition-transform duration-200",_&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:_?"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:T,children:[t.jsx("input",{...ct,value:f,onChange:h=>S(h.target.value),placeholder:n("mobile.connect.url.placeholder"),"aria-label":n("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:_?void 0:-1,className:Z(wt,"text-center")}),t.jsx("input",{value:m,onChange:h=>g(h.target.value),placeholder:n("mobile.instances.label.placeholder"),"aria-label":n("mobile.instances.label.label"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:_?void 0:-1,className:Z(wt,"text-center")}),t.jsx("input",{...ct,value:b,onChange:h=>v(h.target.value),placeholder:n("mobile.connect.token.placeholder"),"aria-label":n("mobile.connect.token.label"),tabIndex:_?void 0:-1,autoCapitalize:"none",className:Z(wt,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:n("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:I?"outline":"default",size:"lg",className:"h-12 w-full",disabled:i||E||!f.trim(),children:n(i?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},Wa=s=>{const e=s.usedPercent;return typeof e!="number"||!Number.isFinite(e)?"text-foreground":e>=80?"text-[var(--status-error)]":e>=50?"text-[var(--status-warning)]":"text-foreground"},Ua=s=>{const e=de.c(12),{groups:n,displayMode:o,timeFormatPreference:r,className:i}=s;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]!==n||e[4]!==r){let f;e[6]!==o||e[7]!==r?(f=d=>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(ao,{providerId:d.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:d.providerName}),d.status&&d.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:d.status}):null]}),d.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:d.rows.map(m=>{const g=o==="remaining"?m.window.remainingPercent:m.window.usedPercent,b=lo(m.window.valueLabel,g),v=co(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}),v?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground/70",children:v}):null]}),t.jsx("span",{className:Z("shrink-0 typography-ui-label font-semibold tabular-nums",Wa(m.window)),children:b==="-"?"":b})]},m.key)})}):null,d.status&&d.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:d.status}):null]},d.providerId),e[6]=o,e[7]=r,e[8]=f):f=e[8],c=n.map(f),e[2]=o,e[3]=n,e[4]=r,e[5]=c}else c=e[5];let u;return e[9]!==a||e[10]!==c?(u=t.jsx("div",{className:a,children:c}),e[9]=a,e[10]=c,e[11]=u):u=e[11],u},wn=380,Va=(s,e)=>{if(!s||typeof s!="object")return;const n=s[e];return typeof n=="number"&&Number.isFinite(n)?n:void 0},xt=s=>typeof s=="number"&&Number.isFinite(s)?s:0,jn=s=>s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:String(s),Sr=s=>{const e=de.c(19),{percentage:n}=s;let o,r,i,a,c,u,f;if(e[0]!==n){i=ho(n)??0;const v=go(n);r=v==="critical"?"var(--status-error)":v==="warn"?"var(--status-warning)":"var(--status-success)",o=2*Math.PI*7.5,a="0 0 18 18",c="size-[18px] -rotate-90",u="progressbar",f=Math.round(i),e[0]=n,e[1]=o,e[2]=r,e[3]=i,e[4]=a,e[5]=c,e[6]=u,e[7]=f}else o=e[1],r=e[2],i=e[3],a=e[4],c=e[5],u=e[6],f=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),e[8]=d):d=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 b;return e[13]!==a||e[14]!==c||e[15]!==u||e[16]!==f||e[17]!==g?(b=t.jsxs("svg",{viewBox:a,className:c,role:u,"aria-valuenow":f,"aria-valuemin":0,"aria-valuemax":100,children:[d,g]}),e[13]=a,e[14]=c,e[15]=u,e[16]=f,e[17]=g,e[18]=b):b=e[18],b},Ha=s=>{const e=de.c(13),{icon:n,iconNode:o,label:r,children:i}=s;let a;e[0]!==n||e[1]!==o?(a=o??(n?t.jsx(ne,{name:n,className:"size-[18px]"}):null),e[0]=n,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 u;e[5]!==r?(u=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:r}),e[5]=r,e[6]=u):u=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 d;return e[9]!==c||e[10]!==u||e[11]!==f?(d=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[c,u,f]}),e[9]=c,e[10]=u,e[11]=f,e[12]=d):d=e[12],d},Ga=s=>{const e=de.c(49),{open:n,onClose:o,anchorRef:r,contextDisplay:i,usageGroups:a,usageDisplayMode:c,isUsageLoading:u,timeFormatPreference:f}=s,{t:d}=ue(),m=l.useRef(null),[g,b]=l.useState(n),[v,E]=l.useState(!1),{enabled:x}=ys(),A=l.useRef(null),[C,P]=l.useState(null);let I,_;e[0]!==r||e[1]!==x||e[2]!==n||e[3]!==g?(I=()=>{if(!n||!x||!g)return;const V=()=>{const ee=r.current?.getBoundingClientRect(),B=A.current?.getBoundingClientRect();if(!ee||!B){P(null);return}const oe=ee.left-B.left,ie=Math.min(Math.max(oe,8),Math.max(8,B.width-wn-8));P(ie)};V();const F=A.current;if(typeof ResizeObserver>"u"||!F)return;const Q=new ResizeObserver(V);return Q.observe(F),()=>Q.disconnect()},_=[r,x,n,g],e[0]=r,e[1]=x,e[2]=n,e[3]=g,e[4]=I,e[5]=_):(I=e[4],_=e[5]),l.useLayoutEffect(I,_);const D=x&&C!==null;let j,R;e[6]!==n||e[7]!==g?(j=()=>{if(n){b(!0),E(!1);return}if(!g)return;E(!0);const V=window.setTimeout(()=>{b(!1),E(!1)},140);return()=>window.clearTimeout(V)},R=[n,g],e[6]=n,e[7]=g,e[8]=j,e[9]=R):(j=e[8],R=e[9]),l.useEffect(j,R);let y,w;e[10]!==o||e[11]!==n?(y=()=>{if(!n)return;const V=F=>{F.key==="Escape"&&o()};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},w=[o,n],e[10]=o,e[11]=n,e[12]=y,e[13]=w):(y=e[12],w=e[13]),l.useEffect(y,w);let T,S;if(e[14]!==r||e[15]!==o||e[16]!==n?(T=()=>{if(!n)return;const V=F=>{const Q=F.target;if(!(Q instanceof Node)){o();return}m.current?.contains(Q)||r.current?.contains(Q)||o()};return document.addEventListener("pointerdown",V,!0),document.addEventListener("wheel",V,!0),()=>{document.removeEventListener("pointerdown",V,!0),document.removeEventListener("wheel",V,!0)}},S=[r,o,n],e[14]=r,e[15]=o,e[16]=n,e[17]=T,e[18]=S):(T=e[17],S=e[18]),l.useEffect(T,S),!g)return null;let k;e[19]!==d?(k=d("mobile.header.openMetadataAria"),e[19]=d,e[20]=k):k=e[20];const $=D?"absolute origin-top-left":"mx-3 mt-2",O=v?"pointer-events-none":"pointer-events-auto";let h;e[21]!==$||e[22]!==O?(h=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",$,O),e[21]=$,e[22]=O,e[23]=h):h=e[23];const N=`${v?"session-metadata-out":"session-metadata-in"} ${v?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let L;e[24]!==C||e[25]!==D?(L=D?{top:8,left:C??8,width:`min(${wn}px, calc(100% - 16px))`}:null,e[24]=C,e[25]=D,e[26]=L):L=e[26];let Y;e[27]!==N||e[28]!==L?(Y={animation:N,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...L},e[27]=N,e[28]=L,e[29]=Y):Y=e[29];let J;e[30]!==i||e[31]!==d?(J=i?t.jsx(Ha,{iconNode:t.jsx(Sr,{percentage:i.percentage}),label:d("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]=d,e[32]=J):J=e[32];let te;e[33]!==u||e[34]!==f||e[35]!==c||e[36]!==a?(te=t.jsx(Ka,{groups:a,displayMode:c,isLoading:u,timeFormatPreference:f}),e[33]=u,e[34]=f,e[35]=c,e[36]=a,e[37]=te):te=e[37];let q;e[38]!==J||e[39]!==te?(q=t.jsxs("div",{className:"space-y-1",children:[J,te]}),e[38]=J,e[39]=te,e[40]=q):q=e[40];let M;e[41]!==h||e[42]!==Y||e[43]!==q||e[44]!==k?(M=t.jsx("div",{ref:m,role:"dialog","aria-label":k,className:h,style:Y,children:q}),e[41]=h,e[42]=Y,e[43]=q,e[44]=k,e[45]=M):M=e[45];let X;e[46]===Symbol.for("react.memo_cache_sentinel")?(X=t.jsx("style",{children:`
3
- @keyframes session-metadata-in {
4
- from { opacity: 0; transform: translateY(-8px) scale(0.985); }
5
- to { opacity: 1; transform: translateY(0) scale(1); }
6
- }
7
- @keyframes session-metadata-out {
8
- from { opacity: 1; transform: translateY(0) scale(1); }
9
- to { opacity: 0; transform: translateY(-6px) scale(0.985); }
10
- }
11
- `}),e[46]=X):X=e[46];let K;return e[47]!==M?(K=t.jsxs("div",{ref:A,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:[M,X]}),e[47]=M,e[48]=K):K=e[48],K},Ka=s=>{const e=de.c(30),{groups:n,displayMode:o,isLoading:r,timeFormatPreference:i}=s,{t:a}=ue();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 u=c;if(n.length===0){if(!r)return null;let C;e[3]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(ne,{name:"loader-4",className:"size-4 animate-spin","aria-hidden":!0}),e[3]=C):C=e[3];let P;e[4]!==a?(P=a("common.loading"),e[4]=a,e[5]=P):P=e[5];let I;return e[6]!==P?(I=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-2.5 py-6 text-muted-foreground",children:[C,t.jsx("span",{className:"typography-ui-label",children:P})]}),e[6]=P,e[7]=I):I=e[7],I}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(ne,{name:"timer",className:"size-[18px]"})}),e[8]=f):f=e[8];let d;e[9]!==a?(d=a("mobile.header.metadata.usage"),e[9]=a,e[10]=d):d=e[10];let m;e[11]!==d?(m=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:d}),e[11]=d,e[12]=m):m=e[12];let g;e[13]!==r?(g=r?t.jsx(ne,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[13]=r,e[14]=g):g=e[14];let b;e[15]!==u?(b=t.jsx("span",{className:"truncate",children:u}),e[15]=u,e[16]=b):b=e[16];let v;e[17]!==g||e[18]!==b?(v=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,b]}),e[17]=g,e[18]=b,e[19]=v):v=e[19];let E;e[20]!==m||e[21]!==v?(E=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[f,m,v]}),e[20]=m,e[21]=v,e[22]=E):E=e[22];let x;e[23]!==o||e[24]!==n||e[25]!==i?(x=t.jsx(Ua,{groups:n,displayMode:o,timeFormatPreference:i}),e[23]=o,e[24]=n,e[25]=i,e[26]=x):x=e[26];let A;return e[27]!==E||e[28]!==x?(A=t.jsxs("div",{className:"pt-2.5",children:[E,x]}),e[27]=E,e[28]=x,e[29]=A):A=e[29],A},qa=l.memo(function({open:e,onOpenChange:n,currentSessionId:o,effectiveDirectory:r,isNewSessionDraftOpen:i}){const{t:a}=ue(),c=l.useRef(null),u=uo(o??"",r||void 0),f=Le(N=>N.providers),d=Le(N=>N.currentProviderId),m=Le(N=>N.currentModelId),g=Le(N=>N.getModelMetadata);Le(N=>N.modelsMetadata.size);const b=fo(l.useCallback(N=>o?N.sessionModelSelections.get(o)??null:null,[o])),v=rt(N=>N.results),E=rt(N=>N.loadSettings),x=rt(N=>N.fetchAllQuotas),A=rt(N=>N.isLoading),C=rt(N=>N.displayMode),P=rt(N=>N.dropdownProviderIds),I=Ve(N=>N.timeFormatPreference);mo(),l.useEffect(()=>{E()},[E]),l.useEffect(()=>{an(P)},[P]),l.useEffect(()=>{!e||A||!P.some(L=>!v.some(Y=>Y.providerId===L))||x()},[P,x,A,e,v]);const D=l.useMemo(()=>{for(let N=u.length-1;N>=0;N-=1){const L=u[N];if(L.role!=="user")continue;const Y=typeof L.model?.providerID=="string"&&L.model.providerID.trim().length>0?L.model.providerID:void 0,J=typeof L.model?.modelID=="string"&&L.model.modelID.trim().length>0?L.model.modelID:void 0;if(Y&&J)return{providerID:Y,modelID:J}}return null},[u])??(b?{providerID:b.providerId,modelID:b.modelId}:null)??(d&&m?{providerID:d,modelID:m}:null),R=(D?f.find(N=>N.id===D.providerID):void 0)?.models.find(N=>N.id===D?.modelID),y=D?g(D.providerID,D.modelID):void 0,w=Va(R?.limit,"context")??y?.limit?.context??0,T=l.useMemo(()=>{for(let N=u.length-1;N>=0;N-=1){const L=u[N];if(L.role!=="assistant"||!L.tokens)continue;const Y=xt(L.tokens.input)+xt(L.tokens.output)+xt(L.tokens.reasoning)+xt(L.tokens.cache?.read)+xt(L.tokens.cache?.write);if(Y>0)return Y}return 0},[u]),S=!i&&T>0&&w>0?Math.min(T/w*100,999):null,k=S!==null?`${jn(T)}/${jn(w)}`:null,$=S===null?"":S>=90?"text-[var(--status-error)]":S>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",O=S!==null&&k?{percentage:S,tokens:k,colorClass:$}:null,h=po();return l.useEffect(()=>{!e||h.length===0||an(h.map(N=>N.providerId))},[e,h]),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:()=>n(N=>!N),style:{touchAction:"manipulation"},children:t.jsx(Sr,{percentage:O?.percentage??0})}),t.jsx(Ga,{open:e,onClose:()=>n(!1),anchorRef:c,contextDisplay:O,usageGroups:h,usageDisplayMode:C,isUsageLoading:A,timeFormatPreference:I})]})}),Ja=10,kn=380,Ya=(s,e)=>s.title?.trim()||e,Xa=s=>{const e=de.c(32),{session:n,meta:o,active:r,onSelect:i}=s,{t:a}=ue(),c=qn(n.id),u=Jn(n.id),f=c?.type??"idle",d=f==="busy"||f==="retry",m=!d&&u>0&&!r,g=Yn(n.id,d),b=(d||m)&&g,v=n.time?.updated??n.time?.created??0;let E;e[0]!==v?(E=xo(v),e[0]=v,e[1]=E):E=e[1];const x=E,A=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let C;e[2]!==A?(C=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",A),e[2]=A,e[3]=C):C=e[3];let P;e[4]===Symbol.for("react.memo_cache_sentinel")?(P={touchAction:"manipulation"},e[4]=P):P=e[4];const I=r?"text-primary":"text-foreground";let _;e[5]!==I?(_=Z("block truncate typography-ui-label",I),e[5]=I,e[6]=_):_=e[6];let D;e[7]!==n||e[8]!==a?(D=Ya(n,a("sessions.sidebar.session.untitled")),e[7]=n,e[8]=a,e[9]=D):D=e[9];let j;e[10]!==_||e[11]!==D?(j=t.jsx("span",{className:_,children:D}),e[10]=_,e[11]=D,e[12]=j):j=e[12];let R;e[13]!==o?(R=o?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:o}):null,e[13]=o,e[14]=R):R=e[14];let y;e[15]!==R||e[16]!==j?(y=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[j,R]}),e[15]=R,e[16]=j,e[17]=y):y=e[17];let w;e[18]!==d||e[19]!==m?(w=d||m?t.jsx("span",{className:Z("size-1.5 shrink-0 rounded-full",d?"bg-primary":"bg-[var(--status-info)]"),"aria-hidden":!0}):null,e[18]=d,e[19]=m,e[20]=w):w=e[20];let T;e[21]!==d||e[22]!==n.id||e[23]!==b||e[24]!==x?(T=b?t.jsx(rr,{sessionId:n.id,running:d,className:"typography-micro"}):x?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:x}):null,e[21]=d,e[22]=n.id,e[23]=b,e[24]=x,e[25]=T):T=e[25];let S;return e[26]!==i||e[27]!==y||e[28]!==w||e[29]!==T||e[30]!==C?(S=t.jsxs("button",{type:"button",className:C,onClick:i,style:P,children:[y,w,T]}),e[26]=i,e[27]=y,e[28]=w,e[29]=T,e[30]=C,e[31]=S):S=e[31],S},Qa=s=>{const e=de.c(50),{open:n,onClose:o,anchorRef:r}=s,{t:i}=ue(),a=l.useRef(null),[c,u]=l.useState(n),[f,d]=l.useState(!1),{enabled:m}=ys(),g=l.useRef(null),[b,v]=l.useState(null);let E,x;e[0]!==r||e[1]!==m||e[2]!==n||e[3]!==c?(E=()=>{if(!n||!m||!c)return;const F=()=>{const B=r.current?.getBoundingClientRect(),oe=g.current?.getBoundingClientRect();if(!B||!oe){v(null);return}const ie=B.left-oe.left;v(Math.min(Math.max(ie,8),Math.max(8,oe.width-kn-8)))};F();const Q=g.current;if(typeof ResizeObserver>"u"||!Q)return;const ee=new ResizeObserver(F);return ee.observe(Q),()=>ee.disconnect()},x=[r,m,n,c],e[0]=r,e[1]=m,e[2]=n,e[3]=c,e[4]=E,e[5]=x):(E=e[4],x=e[5]),l.useLayoutEffect(E,x);const A=m&&b!==null,C=ve(Za),P=ve(el),I=ze(tl);let _;e[6]===Symbol.for("react.memo_cache_sentinel")?(_={maxParents:Ja},e[6]=_):_=e[6];const D=bo(n||c,_);let j,R;e[7]!==n||e[8]!==c?(j=()=>{if(n){vs(),u(!0),d(!1);return}if(!c)return;d(!0);const F=window.setTimeout(()=>{u(!1),d(!1)},140);return()=>window.clearTimeout(F)},R=[n,c],e[7]=n,e[8]=c,e[9]=j,e[10]=R):(j=e[9],R=e[10]),l.useEffect(j,R);let y,w;e[11]!==o||e[12]!==n?(y=()=>{if(!n)return;const F=Q=>{Q.key==="Escape"&&o()};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},w=[o,n],e[11]=o,e[12]=n,e[13]=y,e[14]=w):(y=e[13],w=e[14]),l.useEffect(y,w);let T,S;e[15]!==r||e[16]!==o||e[17]!==n?(T=()=>{if(!n)return;const F=Q=>{const ee=Q.target;if(!(ee instanceof Node)){o();return}a.current?.contains(ee)||r.current?.contains(ee)||o()};return document.addEventListener("pointerdown",F,!0),()=>document.removeEventListener("pointerdown",F,!0)},S=[r,o,n],e[15]=r,e[16]=o,e[17]=n,e[18]=T,e[19]=S):(T=e[18],S=e[19]),l.useEffect(T,S);let k;e[20]!==o||e[21]!==P?(k=F=>{P(F.id,xs(F)),o()},e[20]=o,e[21]=P,e[22]=k):k=e[22];const $=k;if(!c)return null;let O;e[23]!==i?(O=i("sessions.switcher.openAria"),e[23]=i,e[24]=O):O=e[24];const h=A?"absolute origin-top-left":"mx-3 mt-2",N=f?"pointer-events-none":"pointer-events-auto";let L;e[25]!==h||e[26]!==N?(L=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",h,N),e[25]=h,e[26]=N,e[27]=L):L=e[27];const Y=`${f?"session-switcher-out":"session-switcher-in"} ${f?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let J;e[28]!==b||e[29]!==A?(J=A?{top:8,left:b??8,width:`min(${kn}px, calc(100% - 16px))`}:null,e[28]=b,e[29]=A,e[30]=J):J=e[30];let te;e[31]!==Y||e[32]!==J?(te={animation:Y,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...J},e[31]=Y,e[32]=J,e[33]=te):te=e[33];let q;e[34]!==C||e[35]!==$||e[36]!==D||e[37]!==I||e[38]!==i?(q=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,ee=[F.secondaryMeta?.projectLabel,F.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return t.jsx(Xa,{session:Q,meta:ee,active:Q.id===C,onSelect:()=>{F.projectId&&I(F.projectId),$(Q)}},Q.id)}),e[34]=C,e[35]=$,e[36]=D,e[37]=I,e[38]=i,e[39]=q):q=e[39];let M;e[40]!==q?(M=t.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:q}),e[40]=q,e[41]=M):M=e[41];let X;e[42]!==O||e[43]!==L||e[44]!==te||e[45]!==M?(X=t.jsx("div",{ref:a,role:"dialog","aria-label":O,className:L,style:te,children:M}),e[42]=O,e[43]=L,e[44]=te,e[45]=M,e[46]=X):X=e[46];let K;e[47]===Symbol.for("react.memo_cache_sentinel")?(K=t.jsx("style",{children:`
12
- @keyframes session-switcher-in {
13
- from { opacity: 0; transform: translateY(-8px) scale(0.985); }
14
- to { opacity: 1; transform: translateY(0) scale(1); }
15
- }
16
- @keyframes session-switcher-out {
17
- from { opacity: 1; transform: translateY(0) scale(1); }
18
- to { opacity: 0; transform: translateY(-6px) scale(0.985); }
19
- }
20
- `}),e[47]=K):K=e[47];let V;return e[48]!==X?(V=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:[X,K]}),e[48]=X,e[49]=V):V=e[49],V};function Za(s){return s.currentSessionId}function el(s){return s.setCurrentSession}function tl(s){return s.setActiveProjectIdOnly}const sl=s=>{const e=de.c(71),{onOpenSessions:n,onOpenWorkspace:o,compactTitle:r}=s,i=r===void 0?!1:r,{t:a}=ue(),[c,u]=l.useState(!1),[f,d]=l.useState(!1),m=l.useRef(null),g=ut(nl),b=ve(rl);let v;e[0]!==b?(v=Ie=>b?Ie.getDirectoryForSession(b):null,e[0]=b,e[1]=v):v=e[1];const x=ve(v)||g,A=yo(b,x||void 0),C=ve(ol);let P;e[2]!==A?.title?(P=A?.title?.trim(),e[2]=A?.title,e[3]=P):P=e[3];const I=P;let _;e[4]!==b||e[5]!==I||e[6]!==a?(_=I||a(b?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[4]=b,e[5]=I,e[6]=a,e[7]=_):_=e[7];const D=_;let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{u(!1),d(!1)},e[8]=j):j=e[8];let R;e[9]!==b||e[10]!==x?(R=[b,x],e[9]=b,e[10]=x,e[11]=R):R=e[11],l.useEffect(j,R);let y;e[12]!==n?(y=()=>{u(!1),d(!1),n()},e[12]=n,e[13]=y):y=e[13];const w=y;let T;e[14]===Symbol.for("react.memo_cache_sentinel")?(T=Ie=>{u(Ae=>{const be=typeof Ie=="function"?Ie(Ae):Ie;return be&&d(!1),be})},e[14]=T):T=e[14];const S=T;let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{d(Ie=>{const Ae=!Ie;return Ae&&u(!1),Ae})},e[15]=k):k=e[15];const $=k;let O;e[16]===Symbol.for("react.memo_cache_sentinel")?(O={paddingTop:"var(--oc-safe-area-top, 0px)"},e[16]=O):O=e[16];let h;e[17]!==a?(h=a("mobile.sessions.openSheetAria"),e[17]=a,e[18]=h):h=e[18];let N,L;e[19]===Symbol.for("react.memo_cache_sentinel")?(N={touchAction:"manipulation"},L=t.jsx(ne,{name:"list-unordered",className:"size-5"}),e[19]=N,e[20]=L):(N=e[19],L=e[20]);let Y;e[21]!==w||e[22]!==h?(Y=t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":h,onClick:w,style:N,children:L}),e[21]=w,e[22]=h,e[23]=Y):Y=e[23];const J=i?"shrink":"flex-1";let te;e[24]!==J?(te=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",J),e[24]=J,e[25]=te):te=e[25];let q;e[26]!==a?(q=a("sessions.switcher.openAria"),e[26]=a,e[27]=q):q=e[27];let M;e[28]===Symbol.for("react.memo_cache_sentinel")?(M={touchAction:"manipulation"},e[28]=M):M=e[28];let X;e[29]!==D?(X=t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:D}),e[29]=D,e[30]=X):X=e[30];const K=f&&"rotate-180";let V;e[31]!==K?(V=Z("size-4 shrink-0 text-muted-foreground transition-transform duration-150",K),e[31]=K,e[32]=V):V=e[32];let F;e[33]!==V?(F=t.jsx(ne,{name:"arrow-down-s",className:V}),e[33]=V,e[34]=F):F=e[34];let Q;e[35]!==X||e[36]!==F?(Q=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[X,F]}),e[35]=X,e[36]=F,e[37]=Q):Q=e[37];let ee;e[38]!==f||e[39]!==te||e[40]!==q||e[41]!==Q?(ee=t.jsx("button",{ref:m,type:"button",className:te,"aria-label":q,"aria-haspopup":"dialog","aria-expanded":f,onClick:$,style:M,children:Q}),e[38]=f,e[39]=te,e[40]=q,e[41]=Q,e[42]=ee):ee=e[42];let B;e[43]!==i?(B=i?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[43]=i,e[44]=B):B=e[44];let oe;e[45]!==b||e[46]!==x||e[47]!==C||e[48]!==c?(oe=t.jsx(qa,{open:c,onOpenChange:S,currentSessionId:b,effectiveDirectory:x,isNewSessionDraftOpen:C}),e[45]=b,e[46]=x,e[47]=C,e[48]=c,e[49]=oe):oe=e[49];let ie;e[50]!==a?(ie=a("mobile.header.openWorkspaceAria"),e[50]=a,e[51]=ie):ie=e[51];let me;e[52]!==o?(me=()=>{u(!1),d(!1),o()},e[52]=o,e[53]=me):me=e[53];let we,G;e[54]===Symbol.for("react.memo_cache_sentinel")?(we={touchAction:"manipulation"},G=t.jsx(ne,{name:"pencil-ruler-2",className:"size-5"}),e[54]=we,e[55]=G):(we=e[54],G=e[55]);let pe;e[56]!==ie||e[57]!==me?(pe=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":ie,onClick:me,style:we,children:G}),e[56]=ie,e[57]=me,e[58]=pe):pe=e[58];let Re;e[59]!==Y||e[60]!==ee||e[61]!==B||e[62]!==oe||e[63]!==pe?(Re=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:O,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[Y,ee,B,oe,pe]})}),e[59]=Y,e[60]=ee,e[61]=B,e[62]=oe,e[63]=pe,e[64]=Re):Re=e[64];let Pe;e[65]===Symbol.for("react.memo_cache_sentinel")?(Pe=()=>d(!1),e[65]=Pe):Pe=e[65];let Te;e[66]!==f?(Te=t.jsx(Qa,{open:f,onClose:Pe,anchorRef:m}),e[66]=f,e[67]=Te):Te=e[67];let Be;return e[68]!==Re||e[69]!==Te?(Be=t.jsxs(t.Fragment,{children:[Re,Te]}),e[68]=Re,e[69]=Te,e[70]=Be):Be=e[70],Be};function nl(s){return s.currentDirectory}function rl(s){return s.currentSessionId}function ol(s){return!!s.newSessionDraft?.open}const il=({onActiveConnectionDeleted:s,onConnect:e})=>{const{t:n}=ue(),o=br(e),{connections:r,isBusy:i,isPasswordBusy:a,error:c,pendingConnection:u,connect:f,submitPassword:d,cancelPassword:m,saveConnection:g,removeConnection:b,setError:v}=o,[E,x]=l.useState(null),A=E?r.find(B=>B.id===E)??null:null,[C,P]=l.useState(null),[I,_]=l.useState(""),[D,j]=l.useState(""),[R,y]=l.useState(""),[w,T]=l.useState(""),[S,k]=l.useState(!1),[$,O]=l.useState(!1),h=l.useRef(null),N=l.useMemo(()=>fs(),[]),[L,Y]=l.useState(!1),[J,te]=l.useState(null),q=l.useCallback(()=>{x(null),_(""),j(""),y(""),v(null),Y(!1)},[v]),M=l.useCallback(B=>{B.preventDefault(),g({id:E??void 0,url:I,label:D,clientToken:R}).then(oe=>{oe&&q()})},[R,E,D,q,g,I]),X=l.useCallback(async()=>{if(h.current)return;v(null),k(!0);const B=new AbortController;h.current=B;try{const oe=await wr({signal:B.signal});switch(h.current===B&&(h.current=null,k(!1)),oe.status){case"ok":_(oe.url),oe.label&&j(oe.label),oe.clientToken&&y(oe.clientToken),Y(!0);break;case"pairing":O(!0),await o.redeemPairingConnection(oe.pairing);break;case"permission-denied":v(n("mobile.connect.scan.permissionDenied"));break;case"invalid":v(n("mobile.connect.scan.invalid"));break;case"unsupported":v(n("mobile.connect.scan.unsupported"));break;case"failed":v(n("mobile.connect.scan.failed"));break;default:break}}finally{O(!1),h.current===B&&(h.current=null,k(!1))}},[o,v,n]);l.useEffect(()=>()=>h.current?.abort(),[]);const K=l.useCallback(B=>{B.preventDefault(),d(w)},[w,d]),V=l.useCallback(()=>{T(""),m()},[m]),F=l.useCallback(B=>{P(oe=>oe===B?null:B)},[]),Q=l.useCallback(B=>{P(null),E===B&&q();const oe=r.length===1;b(B).then(ie=>{ie&&(oe||vn(ie))&&s()})},[r.length,E,s,b,q]),ee=wt;return u?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:K,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(ne,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:u.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:u.candidates.some(B=>B.kind==="direct")?He(u):n("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...ct,value:w,onChange:B=>T(B.target.value),placeholder:n("mobile.connect.password.placeholder"),"aria-label":n("mobile.connect.password.label"),type:"password",autoFocus:!0,className:ee}),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||!w.trim(),children:n(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(xe,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:V,children:n("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[S?t.jsx(jr,{onCancel:()=>h.current?.abort()}):null,$?t.jsx(kr,{}):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",{className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(B=>{const oe=C===B.id,ie=vn(B),me=J===B.id,we=me?n("mobile.connect.connecting"):ie?Ct()?n("mobile.instances.status.connectedRelay"):n("mobile.instances.status.connectedDirect"):B.candidates.some(G=>G.kind==="direct")?He(B):n("mobile.connect.relay.badge");return t.jsxs("div",{className:Z("flex items-center border-b border-border/70 transition-colors last:border-b-0",oe&&"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:()=>{ie||(te(B.id),f({id:B.id,candidates:B.candidates,clientToken:B.clientToken,label:B.label}).finally(()=>te(null)))},disabled:i&&!me||oe,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(ne,{name:"server",className:"size-[18px]"}),ie?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:B.label}),t.jsx("span",{className:Z("block truncate typography-small",ie&&!me?"text-[var(--status-success)]":"text-muted-foreground"),children:we})]}),me?t.jsx(ne,{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:[oe?t.jsxs("button",{type:"button","aria-label":n("mobile.instances.confirmDeleteAria",{label:B.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:()=>Q(B.id),style:{touchAction:"manipulation"},children:[t.jsx(ne,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:n("mobile.instances.delete")})]}):B.candidates.some(G=>G.kind==="direct")?t.jsx("button",{type:"button","aria-label":n("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:()=>{x(B.id),_(He(B)),j(B.label),y(B.clientToken||""),v(null)},style:{touchAction:"manipulation"},children:t.jsx(ne,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":oe?n("mobile.instances.cancelDeleteAria",{label:B.label}):n("mobile.instances.deleteAria",{label:B.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:()=>F(B.id),style:{touchAction:"manipulation"},children:t.jsx(ne,{name:oe?"close":"delete-bin",className:"size-[18px]"})})]})]},B.id)})}):t.jsx("p",{className:"rounded-[18px] border border-dashed border-border/70 px-4 py-6 text-center typography-small text-muted-foreground",children:n("mobile.connect.saved.empty")}),!L&&!A?t.jsxs("div",{className:"space-y-2",children:[N?t.jsxs(xe,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{X()},disabled:S,children:[t.jsx(ne,{name:"scan-2",className:Z("size-[18px]",S&&"animate-pulse")}),n("mobile.connect.scanQr")]}):null,t.jsxs(xe,{type:"button",variant:N?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{v(null),Y(!0)},children:[t.jsx(ne,{name:"add",className:"size-[18px]"}),n("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:M,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:n(A?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(xe,{type:"button",variant:"ghost",size:"xs",onClick:q,children:n("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:n("mobile.connect.url.label")}),t.jsx("input",{...ct,value:I,onChange:B=>_(B.target.value),placeholder:n("mobile.connect.url.placeholder"),type:"url",inputMode:"url",autoCapitalize:"none",className:ee})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:n("mobile.instances.label.label")}),t.jsx("input",{value:D,onChange:B=>j(B.target.value),placeholder:n("mobile.instances.label.placeholder"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,className:ee})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:n("mobile.connect.token.label")}),t.jsx("input",{...ct,value:R,onChange:B=>y(B.target.value),placeholder:n("mobile.connect.token.placeholder"),autoCapitalize:"none",className:ee}),t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:n("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:n(A?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},je=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/g,""),ns=s=>{const e=je(s);if(!e)return"";const n=e.split("/").filter(Boolean);return n[n.length-1]?.replace(/[-_]/g," ")||e},Sn=zs(s=>({expandedParents:{},toggleParent:e=>s(n=>{const o={...n.expandedParents};return o[e]?delete o[e]:o[e]=!0,{expandedParents:o}})})),zt=zs()(lr(s=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,n)=>s(o=>({projectExpanded:{...o.projectExpanded,[e]:n}})),setWorktreeExpanded:(e,n)=>s(o=>({worktreeExpanded:{...o.worktreeExpanded,[e]:n}}))}),{name:"mobile-session-tree"})),ms=zs()(lr(s=>({orderByProject:{},setWorktreeOrder:(e,n)=>s(o=>({orderByProject:{...o.orderByProject,[e]:n}}))}),{name:"mobile-worktree-order"})),Nn=s=>s.replace(/\\/g,"/").replace(/\/+$/,""),al=(s,e)=>{if(!s||s.length===0)return e;const n=new Map(s.map((r,i)=>[Nn(r),i])),o=r=>n.get(Nn(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)},jt=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/,""),ll=s=>{const e=s;return jt(e.directory??e.project?.worktree??null)},Nr=({open:s,project:e,worktree:n,onClose:o,onDeleted:r})=>{const{t:i}=ue(),a=Xn(),c=bs(y=>y.activeSessions),u=ve(y=>y.archiveSessions),f=ut(y=>y.currentDirectory),[d,m]=l.useState(!1),[g,b]=l.useState(!1),[v,E]=l.useState(!1),[x,A]=l.useState(!1),C=jt(n?.path),P=typeof n?.branch=="string"&&n.branch.trim().length>0,I=l.useMemo(()=>{if(!C)return[];const y=new Map;for(const w of[...c,...a])ll(w)===C&&y.set(w.id,w);return Array.from(y.values())},[c,a,C]);l.useEffect(()=>{if(!s){m(!1),b(!1),E(!1),A(!1);return}if(!n?.path)return;let y=!1;return vo(n.path).then(w=>{y||E(!!w?.isDirty)}).catch(()=>{y||E(!!n.status?.isDirty)}),()=>{y=!0}},[s,n?.path,n?.status?.isDirty]);const _=l.useCallback(y=>{(async()=>{try{await wo(e,y,{deleteRemoteBranch:P&&g,deleteLocalBranch:P&&d}),jt(f)===C&&jt(e.path)&&ut.getState().setDirectory(jt(e.path),{showOverlay:!1}),ce.success(i("sessions.sidebar.sessionDialogs.worktree.removedTitle"),{description:i(P&&g?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),r?.()}catch(w){ce.error(i("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:w instanceof Error?w.message:i("sessions.sidebar.dialogs.deleteResult.tryAgain")})}})()},[f,d,g,P,r,e,i,C]),D=async()=>{if(!(!n||x)){A(!0);try{if(I.length>0){const{archivedIds:y,failedIds:w}=await u(I.map(T=>T.id));if(w.length>0){y.length>0&&ce.success(y.length===1?i("sessions.sidebar.bulkActions.archivedSingle",{count:y.length}):i("sessions.sidebar.bulkActions.archivedPlural",{count:y.length})),ce.error(w.length===1?i("sessions.sidebar.bulkActions.failedArchiveSingle",{count:w.length}):i("sessions.sidebar.bulkActions.failedArchivePlural",{count:w.length}),{description:i("sessions.sidebar.dialogs.deleteResult.tryAgain")}),A(!1);return}}_(n),o()}catch(y){ce.error(i("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:y instanceof Error?y.message:i("sessions.sidebar.dialogs.deleteResult.tryAgain")}),A(!1)}finally{s||A(!1)}}};if(!n)return null;const j=n.branch||n.label||n.path,R=(y,w,T,S)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":y,disabled:S,onClick:()=>w(!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",S&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:T}),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(jo,{open:s,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:x,children:i("projectEditDialog.actions.cancel")}),t.jsx(xe,{variant:"destructive",className:"flex-1",onClick:()=>{D()},disabled:x,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:j})}),v?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,I.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i("mobile.projectEdit.deleteWorktreeArchiveNote",{count:I.length})}):null,P?t.jsxs("div",{className:"flex flex-col gap-2",children:[R(d,m,i("mobile.projectEdit.deleteLocalBranch"),x),R(g,b,i("mobile.projectEdit.deleteRemoteBranch"),x)]}):null]})})},En="mobile-surface-root",rs=16,Ot=200,cl=()=>{if(typeof document>"u")return null;let s=document.getElementById(En);return s||(s=document.createElement("div"),s.id=En,document.body.appendChild(s)),s},kt=({open:s,onClose:e,title:n,subtitle:o,trailing:r,disableEscapeDismiss:i=!1,headerless:a=!1,noHeaderBorder:c=!1,ariaLabel:u,variant:f="fullscreen",dialogAlign:d="chat",children:m})=>{const{t:g}=ue(),b=l.useRef(null),[v,E]=l.useState(!1),[x,A]=l.useState(!1),C=l.useRef(null),P=l.useRef(null),I=l.useRef(e);if(l.useEffect(()=>{I.current=e},[e]),typeof document<"u"&&!b.current&&(b.current=cl()),l.useEffect(()=>{if(!s){E(!1);return}const j=window.setTimeout(()=>E(!0),rs);return()=>window.clearTimeout(j)},[s]),l.useEffect(()=>{if(!s){A(!1);return}const j=window.setTimeout(()=>A(!0),rs+Ot+80);return()=>window.clearTimeout(j)},[s]),l.useEffect(()=>{if(!s)return;const j=document.body.style.overflow;P.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const R=()=>{const T=C.current;if(!T)return;(T.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??T).focus({preventScroll:!0})},y=window.setTimeout(R,rs),w=T=>{if(T.key==="Escape"&&!i){I.current();return}if(T.key!=="Tab")return;const S=C.current;if(!S)return;const k=Array.from(S.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(N=>!N.hasAttribute("disabled")&&N.getAttribute("aria-hidden")!=="true");if(k.length===0){T.preventDefault(),S.focus({preventScroll:!0});return}const $=k[0],O=k[k.length-1],h=document.activeElement;T.shiftKey&&h===$?(T.preventDefault(),O.focus({preventScroll:!0})):!T.shiftKey&&h===O&&(T.preventDefault(),$.focus({preventScroll:!0}))};return document.addEventListener("keydown",w),()=>{window.clearTimeout(y),document.body.style.overflow=j,document.removeEventListener("keydown",w),P.current?.focus?.({preventScroll:!0}),P.current=null}},[i,s]),!s||!b.current)return null;const _=f==="dialog",D=t.jsxs("section",{ref:C,role:"dialog","aria-modal":"true","aria-label":u,tabIndex:-1,className:Z("flex flex-col bg-background text-foreground",_?"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:_?{opacity:v?1:0,transform:v?"none":"scale(0.97)",transition:`opacity ${Ot}ms ease-out, transform ${Ot}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:v?"none":"translateX(100%)",transition:`transform ${Ot}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:j=>{v&&j.target===j.currentTarget&&j.propertyName==="transform"&&A(!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(ne,{name:"close",className:"size-5"})}),t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[n?typeof n=="string"?t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:n}):n: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:x?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 _?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:v?1:0,paddingLeft:d==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:d==="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:j=>j.stopPropagation(),children:D})}),b.current):dt.createPortal(D,b.current)},dl=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/,""),ul=s=>{const e=de.c(36),{worktree:n,onDelete:o}=s,{t:r}=ue();let i;e[0]!==n.path?(i={id:n.path},e[0]=n.path,e[1]=i):i=e[1];const{attributes:a,listeners:c,setNodeRef:u,transform:f,transition:d,isDragging:m}=Ms(i);let g;e[2]!==f?(g=Ls.Transform.toString(f),e[2]=f,e[3]=g):g=e[3];const b=m?10:1;let v;e[4]!==g||e[5]!==b||e[6]!==d?(v={transform:g,transition:d,zIndex:b},e[4]=g,e[5]=b,e[6]=d,e[7]=v):v=e[7];const E=v,x=n.branch||n.label||n.path,A=m&&"shadow-lg shadow-black/20";let C;e[8]!==A?(C=Z("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",A),e[8]=A,e[9]=C):C=e[9];let P;e[10]!==x||e[11]!==r?(P=r("mobile.projectEdit.dragWorktreeAria",{label:x}),e[10]=x,e[11]=r,e[12]=P):P=e[12];let I;e[13]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(Ns,{className:"size-4"}),e[13]=I):I=e[13];let _;e[14]!==a||e[15]!==c||e[16]!==P?(_=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":P,...a,...c,children:I}),e[14]=a,e[15]=c,e[16]=P,e[17]=_):_=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(ne,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[18]=D):D=e[18];let j;e[19]!==x?(j=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:x}),e[19]=x,e[20]=j):j=e[20];let R;e[21]!==x||e[22]!==r?(R=r("mobile.projectEdit.deleteWorktreeAria",{label:x}),e[21]=x,e[22]=r,e[23]=R):R=e[23];let y,w;e[24]===Symbol.for("react.memo_cache_sentinel")?(y={touchAction:"manipulation"},w=t.jsx(Ut,{className:"size-4"}),e[24]=y,e[25]=w):(y=e[24],w=e[25]);let T;e[26]!==o||e[27]!==R?(T=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive","aria-label":R,onClick:o,style:y,children:w}),e[26]=o,e[27]=R,e[28]=T):T=e[28];let S;return e[29]!==u||e[30]!==E||e[31]!==j||e[32]!==T||e[33]!==C||e[34]!==_?(S=t.jsxs("div",{ref:u,style:E,className:C,children:[_,D,j,T]}),e[29]=u,e[30]=E,e[31]=j,e[32]=T,e[33]=C,e[34]=_,e[35]=S):S=e[35],S},fl=({open:s,project:e,onClose:n,onWorktreesChanged:o})=>{const{t:r}=ue(),{currentTheme:i}=Qn(),a=ze(h=>h.updateProjectMeta),c=ze(h=>h.discoverProjectIcon),u=ze(h=>h.removeProjectIcon),f=ms(h=>h.setWorktreeOrder),d=ze(h=>e?h.projects.find(N=>N.id===e.id)?.iconImage??null:null),[m,g]=l.useState(""),[b,v]=l.useState(null),[E,x]=l.useState(null),[A,C]=l.useState(!1),[P,I]=l.useState([]),[_,D]=l.useState(null),j=e?.id??null;l.useEffect(()=>{!s||!e||(g(e.label),v(e.icon??null),x(e.color??null),I(e.worktrees))},[s,j]),l.useEffect(()=>{!s||!e||I(h=>{const N=e.worktrees.map(J=>J.path),L=h.map(J=>J.path);return N.length===L.length&&N.every(J=>L.includes(J))?h:e.worktrees})},[e?.worktrees]);const R=Cs(ft(Ps,{activationConstraint:{distance:8}}),ft(Rs,{coordinateGetter:_s})),y=()=>{if(!e)return;const h=m.trim();a(e.id,{label:h||e.label,icon:b,color:E}),n()},w=()=>{!e||A||(C(!0),c(e.id).then(h=>{if(!h.ok){ce.error(h.error||r("projectEditDialog.toast.failedToDiscoverIcon"));return}if(h.skipped){ce.success(r("projectEditDialog.toast.customIconAlreadySet"));return}ce.success(r("projectEditDialog.toast.iconDiscovered"))}).finally(()=>C(!1)))},T=()=>{e&&u(e.id).then(h=>{if(!h.ok){ce.error(h.error||r("projectEditDialog.toast.failedToRemoveIcon"));return}ce.success(r("projectEditDialog.toast.iconRemoved"))})},S=h=>{const{active:N,over:L}=h;if(!L||N.id===L.id||!e)return;const Y=P.findIndex(M=>M.path===N.id),J=P.findIndex(M=>M.path===L.id);if(Y<0||J<0)return;const te=[...P],[q]=te.splice(Y,1);te.splice(J,0,q),I(te),f(e.id,te.map(M=>dl(M.path)))},k=E?Zn[E]??null:null,$=b?er[b]:null,O=!!d;return t.jsxs(t.Fragment,{children:[t.jsx(kt,{open:s,onClose:n,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(or,{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:O?t.jsx(tr,{project:{id:e.id,iconImage:d},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(cs,{className:"size-7"})}):$?t.jsx(ne,{name:$,className:"size-7",style:k?{color:k}:void 0}):t.jsx(cs,{className:"size-7",style:k?{color:k}: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:h=>g(h.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:()=>x(null),"aria-label":r("projectEditDialog.option.none"),className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",E===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"})}),ko.map(h=>t.jsx("button",{type:"button",onClick:()=>x(h.key),"aria-label":h.label,title:h.label,className:Z("size-9 rounded-xl border-2 transition-all",E===h.key?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:h.cssVar,touchAction:"manipulation"}},h.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:()=>v(null),"aria-label":r("projectEditDialog.option.none"),className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",b===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"})}),So.map(h=>t.jsx("button",{type:"button",onClick:()=>v(h.key),"aria-label":h.label,title:h.label,className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",b===h.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(ne,{name:h.Icon,className:"size-4",style:k?{color:k}:void 0})},h.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(xe,{size:"sm",variant:"outline",onClick:w,disabled:A,children:r(A?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),O?t.jsx(xe,{size:"sm",variant:"outline",onClick:T,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")}),P.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:R,collisionDetection:Is,onDragEnd:S,children:t.jsx(As,{items:P.map(h=>h.path),strategy:Ds,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:P.map(h=>t.jsx(ul,{worktree:h,onDelete:()=>D(h)},h.path))})})})]})]}):null]}):null}),e?t.jsx(Nr,{open:!!_,project:{id:e.id,path:e.path},worktree:_,onClose:()=>D(null),onDeleted:()=>{I(h=>h.filter(N=>N.path!==_?.path)),o?.()}}):null]})},ml=new Set,os=7,Cn=40,pl=16,yt=s=>s.parentID??null,it=s=>{const e=s;return je(e.directory??e.project?.worktree??null)},hl=s=>{const e=s.time?.updated??s.time?.created,n=typeof e=="number"?e:Number(e);return Number.isFinite(n)&&n>0?n:0},gl=s=>{if(s<=0)return"";const e=Date.now()-s;if(e<6e4)return"now";const n=Math.floor(e/6e4);if(n<60)return`${n}m`;const o=Math.floor(n/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(s))},bl=(s,e)=>{const n=je(s),o=je(e);return!!(n&&o&&(n===o||n.startsWith(`${o}/`)))},Wt=(s,e)=>s.worktrees.find(n=>je(n.path)===e)??null,ps=(s,e)=>e===s.path||!!Wt(s,e),is=(s,e)=>{const n=je(e);return n?s.find(o=>ps(o,n))??null:null},as=(s,e,n)=>n?`${s.title??""} ${s.id} ${it(s)} ${e}`.toLowerCase().includes(n):!0,hs=s=>{const e=de.c(17),{project:n,size:o}=s,r=o===void 0?"md":o,{currentTheme:i}=Qn(),a=n.icon?er[n.icon]:null,c=n.color?Zn[n.color]??null:null,u=r==="sm"?"size-6 rounded-md":"size-8 rounded-lg",f=r==="sm"?"size-3.5":"size-4";let d;e[0]!==a||e[1]!==c||e[2]!==f?(d=a?t.jsx(ne,{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]=d):d=e[3];const m=d;let g;e[4]!==u?(g=Z("flex shrink-0 items-center justify-center overflow-hidden bg-[var(--surface-muted)] text-muted-foreground",u),e[4]=u,e[5]=g):g=e[5];let b;e[6]!==n.iconBackground?(b=n.iconBackground?{backgroundColor:n.iconBackground}:void 0,e[6]=n.iconBackground,e[7]=b):b=e[7];let v;e[8]!==i||e[9]!==m||e[10]!==n.iconImage||e[11]!==n.id?(v=n.iconImage?t.jsx(tr,{project:{id:n.id,iconImage:n.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]=n.iconImage,e[11]=n.id,e[12]=v):v=e[12];let E;return e[13]!==g||e[14]!==b||e[15]!==v?(E=t.jsx("span",{className:g,style:b,children:v}),e[13]=g,e[14]=b,e[15]=v,e[16]=E):E=e[16],E},Rn=s=>{const e=de.c(2),{ariaLabel:n}=s;let o;return e[0]!==n?(o=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":n}),e[0]=n,e[1]=o):o=e[1],o},Pn=s=>{const e=de.c(12),{onClick:n,className:o}=s,{t:r}=ue();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 u;e[4]!==n?(u=g=>{g.stopPropagation(),n()},e[4]=n,e[5]=u):u=e[5];let f,d;e[6]===Symbol.for("react.memo_cache_sentinel")?(f={touchAction:"manipulation"},d=t.jsx(ne,{name:"node-tree",className:"size-4"}),e[6]=f,e[7]=d):(f=e[6],d=e[7]);let m;return e[8]!==a||e[9]!==c||e[10]!==u?(m=t.jsx("button",{type:"button",className:c,"aria-label":a,title:a,onClick:u,style:f,children:d}),e[8]=a,e[9]=c,e[10]=u,e[11]=m):m=e[11],m},ot=144,Er=180,Tn=s=>{const e=de.c(25),{actionsWidth:n,actions:o,revealed:r,onRevealedChange:i,children:a}=s,c=l.useRef(null),u=l.useRef(null),f=l.useRef(!1),d=l.useRef(0),m=l.useRef(r);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=(S,k)=>{const $=c.current;$&&($.style.transition=k?`transform ${Er}ms ease-out`:"none",$.style.transform=S===0?"none":`translateX(${S}px)`,d.current=S)},e[0]=g):g=e[0];const b=g;let v,E;e[1]!==n||e[2]!==r?(v=()=>{m.current=r,b(r?-n:0,!0)},E=[n,b,r],e[1]=n,e[2]=r,e[3]=v,e[4]=E):(v=e[3],E=e[4]),l.useEffect(v,E);let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=S=>{if(S.touches.length!==1)return;const k=S.touches[0];u.current={x:k.clientX,y:k.clientY},f.current=!1},e[5]=x):x=e[5];const A=x;let C;e[6]!==n?(C=S=>{if(!u.current)return;const k=S.touches[0],$=k.clientX-u.current.x,O=k.clientY-u.current.y;if(!f.current){if(Math.abs($)<8||Math.abs($)<=Math.abs(O))return;f.current=!0}const h=m.current?-n:0;b(Math.min(0,Math.max(-n,h+$)),!1)},e[6]=n,e[7]=C):C=e[7];const P=C;let I;e[8]!==n||e[9]!==i?(I=()=>{if(u.current=null,!f.current)return;f.current=!1;const S=d.current<-n/2;b(S?-n:0,!0),S!==m.current&&i(S)},e[8]=n,e[9]=i,e[10]=I):I=e[10];const _=I;let D;e[11]===Symbol.for("react.memo_cache_sentinel")?(D={touchAction:"pan-y"},e[11]=D):D=e[11];let j;e[12]!==n?(j={width:n},e[12]=n,e[13]=j):j=e[13];const R=!r;let y;e[14]!==o||e[15]!==j||e[16]!==R?(y=t.jsx("div",{className:"absolute inset-y-0 right-0 flex items-stretch",style:j,"aria-hidden":R,children:o}),e[14]=o,e[15]=j,e[16]=R,e[17]=y):y=e[17];let w;e[18]!==a?(w=t.jsx("div",{ref:c,className:"relative flex w-full items-center bg-background",children:a}),e[18]=a,e[19]=w):w=e[19];let T;return e[20]!==_||e[21]!==P||e[22]!==y||e[23]!==w?(T=t.jsxs("div",{className:"relative overflow-hidden",onTouchStart:A,onTouchMove:P,onTouchEnd:_,onTouchCancel:_,style:D,children:[y,w]}),e[20]=_,e[21]=P,e[22]=y,e[23]=w,e[24]=T):T=e[24],T},xl=s=>{const e=de.c(41),{initialTitle:n,indent:o,onSubmit:r,onCancel:i}=s,{t:a}=ue(),[c,u]=l.useState(n);let f;e[0]!==n||e[1]!==i||e[2]!==r||e[3]!==c?(f=()=>{const S=c.trim();if(!S||S===n.trim()){i();return}r(S)},e[0]=n,e[1]=i,e[2]=r,e[3]=c,e[4]=f):f=e[4];const d=f;let m;e[5]!==o?(m={paddingLeft:o},e[5]=o,e[6]=m):m=e[6];let g;e[7]!==d?(g=S=>{S.preventDefault(),d()},e[7]=d,e[8]=g):g=e[8];let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=S=>u(S.target.value),e[9]=b):b=e[9];let v;e[10]!==i?(v=S=>{S.stopPropagation(),S.key==="Escape"&&i()},e[10]=i,e[11]=v):v=e[11];let E;e[12]!==a?(E=a("sessions.sidebar.session.rename.save"),e[12]=a,e[13]=E):E=e[13];let x;e[14]!==a?(x=a("sessions.sidebar.session.menu.rename"),e[14]=a,e[15]=x):x=e[15];let A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A={minHeight:0},e[16]=A):A=e[16];let C;e[17]!==v||e[18]!==E||e[19]!==x||e[20]!==c?(C=t.jsx("input",{autoFocus:!0,value:c,onChange:b,onKeyDown:v,"aria-label":E,placeholder:x,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:A,enterKeyHint:"done"}),e[17]=v,e[18]=E,e[19]=x,e[20]=c,e[21]=C):C=e[21];let P;e[22]!==a?(P=a("sessions.sidebar.session.rename.save"),e[22]=a,e[23]=P):P=e[23];let I,_;e[24]===Symbol.for("react.memo_cache_sentinel")?(I={touchAction:"manipulation",minHeight:0,minWidth:0},_=t.jsx(ne,{name:"check",className:"size-4"}),e[24]=I,e[25]=_):(I=e[24],_=e[25]);let D;e[26]!==P?(D=t.jsx("button",{type:"submit","aria-label":P,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:I,children:_}),e[26]=P,e[27]=D):D=e[27];let j;e[28]!==a?(j=a("sessions.sidebar.session.rename.cancel"),e[28]=a,e[29]=j):j=e[29];let R,y;e[30]===Symbol.for("react.memo_cache_sentinel")?(R={touchAction:"manipulation",minHeight:0,minWidth:0},y=t.jsx(ne,{name:"close",className:"size-4"}),e[30]=R,e[31]=y):(R=e[30],y=e[31]);let w;e[32]!==i||e[33]!==j?(w=t.jsx("button",{type:"button",onClick:i,"aria-label":j,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:y}),e[32]=i,e[33]=j,e[34]=w):w=e[34];let T;return e[35]!==D||e[36]!==w||e[37]!==m||e[38]!==g||e[39]!==C?(T=t.jsxs("form",{className:"flex h-9 min-w-0 flex-1 items-center gap-2 pr-2",style:m,onSubmit:g,children:[C,D,w]}),e[35]=D,e[36]=w,e[37]=m,e[38]=g,e[39]=C,e[40]=T):T=e[40],T},In=s=>{const e=de.c(51),{session:n,active:o,indent:r,contextLabel:i,hasChildren:a,expanded:c,onToggleChildren:u,onSelect:f,revealed:d,onRevealedChange:m,confirmingDelete:g,onArchive:b,onRequestDelete:v,onConfirmDelete:E,renaming:x,onRequestRename:A,onSubmitRename:C,onCancelRename:P}=s,I=a===void 0?!1:a,_=c===void 0?!1:c,D=d===void 0?!1:d,j=g===void 0?!1:g,R=x===void 0?!1:x,{t:y}=ue();let w;e[0]!==n?(w=gl(hl(n)),e[0]=n,e[1]=w):w=e[1];const T=w,S=n.title?.trim()||y("mobile.sessions.untitled"),k=!!(m&&b),$=qn(n.id),O=Jn(n.id),h=$?.type??"idle",N=h==="busy"||h==="retry",L=!N&&O>0&&!o,Y=Yn(n.id,N),J=(N||L)&&Y,te=l.useRef(null),q=l.useRef(null),M=l.useRef(!1),X=l.useRef(0),K=l.useRef(D);let V;e[2]===Symbol.for("react.memo_cache_sentinel")?(V=(ae,ke)=>{const he=te.current;he&&(he.style.transition=ke?`transform ${Er}ms ease-out`:"none",he.style.transform=ae===0?"none":`translateX(${ae}px)`,X.current=ae)},e[2]=V):V=e[2];const F=V;let Q,ee;e[3]!==D?(Q=()=>{K.current=D,F(D?-ot:0,!0)},ee=[F,D],e[3]=D,e[4]=Q,e[5]=ee):(Q=e[4],ee=e[5]),l.useEffect(Q,ee);let B;e[6]!==k?(B=ae=>{if(!k||ae.touches.length!==1)return;const ke=ae.touches[0];q.current={x:ke.clientX,y:ke.clientY},M.current=!1},e[6]=k,e[7]=B):B=e[7];const oe=B;let ie;e[8]!==k?(ie=ae=>{if(!k||!q.current)return;const ke=ae.touches[0],he=ke.clientX-q.current.x,We=ke.clientY-q.current.y;if(!M.current){if(Math.abs(he)<8||Math.abs(he)<=Math.abs(We))return;M.current=!0}const Ee=K.current?-ot:0,st=Math.min(0,Math.max(-ot,Ee+he));F(st,!1)},e[8]=k,e[9]=ie):ie=e[9];const me=ie;let we;e[10]!==m?(we=()=>{if(q.current=null,!M.current)return;M.current=!1;const ae=X.current<-ot/2;F(ae?-ot:0,!0),ae!==K.current&&m?.(ae)},e[10]=m,e[11]=we):we=e[11];const G=we,pe=o||void 0,Re="relative overflow-hidden";let Pe;e[12]!==k?(Pe=k?{touchAction:"pan-y"}:void 0,e[12]=k,e[13]=Pe):Pe=e[13];const Te=k?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:S}),onClick:A,style:{touchAction:"manipulation"},children:t.jsx(ds,{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:S}),onClick:b,style:{touchAction:"manipulation"},children:t.jsx($i,{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",j?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":j?y("mobile.sessions.confirmDeleteSessionAria",{title:S}):y("mobile.sessions.deleteSessionAria",{title:S}),onClick:j?E:v,style:{touchAction:"manipulation"},children:t.jsx(Ut,{className:"size-[18px]"})})]}):null,Be=k&&"bg-background",Ie=o&&(k?"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]":"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]");let Ae;e[14]!==Be||e[15]!==Ie?(Ae=Z("relative flex items-center gap-1 transition-colors",Be,Ie),e[14]=Be,e[15]=Ie,e[16]=Ae):Ae=e[16];let be;e[17]!==_||e[18]!==I||e[19]!==r||e[20]!==N||e[21]!==u||e[22]!==L||e[23]!==y?(be=N||L||I&&u?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(_?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!I||!u,onClick:ae=>{ae.stopPropagation(),u?.()},children:N||L?t.jsx("span",{className:Z("size-1.5 rounded-full",N?"bg-primary":"bg-[var(--status-info)]"),"aria-hidden":!0}):t.jsx(Es,{className:Z("size-[18px] transition-transform duration-150",_?"rotate-0":"-rotate-90")})}):null,e[17]=_,e[18]=I,e[19]=r,e[20]=N,e[21]=u,e[22]=L,e[23]=y,e[24]=be):be=e[24];let z;e[25]!==o||e[26]!==i||e[27]!==r||e[28]!==N||e[29]!==P||e[30]!==m||e[31]!==f||e[32]!==C||e[33]!==R||e[34]!==n.id||e[35]!==J||e[36]!==T||e[37]!==S?(z=R&&C&&P?t.jsx(xl,{initialTitle:S,indent:r,onSubmit:C,onCancel:P}):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(K.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:S}),J?t.jsx(rr,{sessionId:n.id,running:N,className:"typography-micro"}):T?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:T}):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]=N,e[29]=P,e[30]=m,e[31]=f,e[32]=C,e[33]=R,e[34]=n.id,e[35]=J,e[36]=T,e[37]=S,e[38]=z):z=e[38];let W;e[39]!==Ae||e[40]!==be||e[41]!==z?(W=t.jsxs("div",{ref:te,className:Ae,children:[be,z]}),e[39]=Ae,e[40]=be,e[41]=z,e[42]=W):W=e[42];let re;return e[43]!==G||e[44]!==me||e[45]!==oe||e[46]!==pe||e[47]!==Pe||e[48]!==Te||e[49]!==W?(re=t.jsxs("div",{"data-active-session":pe,className:Re,onTouchStart:oe,onTouchMove:me,onTouchEnd:G,onTouchCancel:G,style:Pe,children:[Te,W]}),e[43]=G,e[44]=me,e[45]=oe,e[46]=pe,e[47]=Pe,e[48]=Te,e[49]=W,e[50]=re):re=e[50],re},yl=s=>{const e=de.c(11),{indent:n,onClick:o}=s,{t:r}=ue();let i;e[0]!==n?(i={paddingLeft:n,touchAction:"manipulation"},e[0]=n,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Es,{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 u;e[5]!==c?(u=t.jsx("span",{className:"typography-micro",children:c}),e[5]=c,e[6]=u):u=e[6];let f;return e[7]!==o||e[8]!==i||e[9]!==u?(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,u]}),e[7]=o,e[8]=i,e[9]=u,e[10]=f):f=e[10],f},vl=s=>{const e=de.c(11),{indent:n,onClick:o}=s,{t:r}=ue();let i;e[0]!==n?(i={paddingLeft:n,touchAction:"manipulation"},e[0]=n,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Fi,{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 u;e[5]!==c?(u=t.jsx("span",{className:"typography-micro",children:c}),e[5]=c,e[6]=u):u=e[6];let f;return e[7]!==o||e[8]!==i||e[9]!==u?(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,u]}),e[7]=o,e[8]=i,e[9]=u,e[10]=f):f=e[10],f},wl=s=>{const e=de.c(29),{worktree:n}=s,{t:o}=ue();let r;e[0]!==n.path?(r=je(n.path),e[0]=n.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:u,setNodeRef:f,transform:d,transition:m,isDragging:g}=Ms(a),b=n.branch||n.label||n.path;let v;e[4]!==d?(v=Ls.Transform.toString(d),e[4]=d,e[5]=v):v=e[5];const E=g?10:1;let x;e[6]!==v||e[7]!==E||e[8]!==m?(x={transform:v,transition:m,zIndex:E},e[6]=v,e[7]=E,e[8]=m,e[9]=x):x=e[9];const A=g&&"shadow-lg shadow-black/20";let C;e[10]!==A?(C=Z("flex items-center gap-1 rounded-xl bg-background px-1 py-1",A),e[10]=A,e[11]=C):C=e[11];let P;e[12]!==b||e[13]!==o?(P=o("mobile.sessions.dragHandleAria",{label:b}),e[12]=b,e[13]=o,e[14]=P):P=e[14];let I;e[15]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(Ns,{className:"size-4"}),e[15]=I):I=e[15];let _;e[16]!==c||e[17]!==u||e[18]!==P?(_=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":P,...c,...u,children:I}),e[16]=c,e[17]=u,e[18]=P,e[19]=_):_=e[19];let D;e[20]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(ne,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=D):D=e[20];let j;e[21]!==b?(j=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-bold text-muted-foreground",children:b}),e[21]=b,e[22]=j):j=e[22];let R;return e[23]!==f||e[24]!==_||e[25]!==j||e[26]!==x||e[27]!==C?(R=t.jsxs("div",{ref:f,style:x,className:C,children:[_,D,j]}),e[23]=f,e[24]=_,e[25]=j,e[26]=x,e[27]=C,e[28]=R):R=e[28],R},jl=s=>{const e=de.c(61),{project:n,totalSessions:o,expanded:r,onToggleExpanded:i,onReorderWorktrees:a}=s,{t:c}=ue();let u;e[0]!==n.id?(u={id:n.id},e[0]=n.id,e[1]=u):u=e[1];const{attributes:f,listeners:d,setNodeRef:m,transform:g,transition:b,isDragging:v}=Ms(u);let E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E={activationConstraint:{distance:8}},e[2]=E):E=e[2];let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x={coordinateGetter:_s},e[3]=x):x=e[3];const A=Cs(ft(Ps,E),ft(Rs,x)),C=n.worktrees.length>0;let P;e[4]!==a||e[5]!==n.worktrees?(P=X=>{const{active:K,over:V}=X;if(!V||K.id===V.id)return;const F=n.worktrees.map(El),Q=F.indexOf(String(K.id)),ee=F.indexOf(String(V.id));if(Q<0||ee<0)return;const B=[...F],[oe]=B.splice(Q,1);B.splice(ee,0,oe),a(B)},e[4]=a,e[5]=n.worktrees,e[6]=P):P=e[6];const I=P;let _;e[7]!==g?(_=Ls.Transform.toString(g),e[7]=g,e[8]=_):_=e[8];const D=v?10:1;let j;e[9]!==_||e[10]!==D||e[11]!==b?(j={transform:_,transition:b,zIndex:D},e[9]=_,e[10]=D,e[11]=b,e[12]=j):j=e[12];const R=v&&"shadow-lg shadow-black/20";let y;e[13]!==R?(y=Z("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",R),e[13]=R,e[14]=y):y=e[14];let w;e[15]!==n.label||e[16]!==c?(w=c("mobile.sessions.dragHandleAria",{label:n.label}),e[15]=n.label,e[16]=c,e[17]=w):w=e[17];let T;e[18]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Ns,{className:"size-4"}),e[18]=T):T=e[18];let S;e[19]!==f||e[20]!==d||e[21]!==w?(S=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":w,...f,...d,children:T}),e[19]=f,e[20]=d,e[21]=w,e[22]=S):S=e[22];let k;e[23]!==r||e[24]!==n.label||e[25]!==c?(k=r?c("sessions.sidebar.group.collapseAria",{label:n.label}):c("sessions.sidebar.group.expandAria",{label:n.label}),e[23]=r,e[24]=n.label,e[25]=c,e[26]=k):k=e[26];const $=!C;let O;e[27]===Symbol.for("react.memo_cache_sentinel")?(O={touchAction:"manipulation"},e[27]=O):O=e[27];let h;e[28]!==n?(h=t.jsx(hs,{project:n}),e[28]=n,e[29]=h):h=e[29];let N;e[30]!==n.label?(N=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:n.label}),e[30]=n.label,e[31]=N):N=e[31];let L;e[32]!==o?(L=t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:o}),e[32]=o,e[33]=L):L=e[33];let Y;e[34]!==r||e[35]!==C?(Y=C?t.jsx(Es,{className:Z("size-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-180")}):null,e[34]=r,e[35]=C,e[36]=Y):Y=e[36];let J;e[37]!==r||e[38]!==i||e[39]!==k||e[40]!==$||e[41]!==h||e[42]!==N||e[43]!==L||e[44]!==Y?(J=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":k,disabled:$,style:O,children:[h,N,L,Y]}),e[37]=r,e[38]=i,e[39]=k,e[40]=$,e[41]=h,e[42]=N,e[43]=L,e[44]=Y,e[45]=J):J=e[45];let te;e[46]!==S||e[47]!==J?(te=t.jsxs("div",{className:"flex items-center gap-1",children:[S,J]}),e[46]=S,e[47]=J,e[48]=te):te=e[48];let q;e[49]!==r||e[50]!==I||e[51]!==C||e[52]!==n.worktrees||e[53]!==A?(q=r&&C?t.jsx(Ts,{sensors:A,collisionDetection:Is,onDragEnd:I,children:t.jsx(As,{items:n.worktrees.map(Cl),strategy:Ds,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 pl-3",children:n.worktrees.map(Rl)})})}):null,e[49]=r,e[50]=I,e[51]=C,e[52]=n.worktrees,e[53]=A,e[54]=q):q=e[54];let M;return e[55]!==m||e[56]!==te||e[57]!==q||e[58]!==j||e[59]!==y?(M=t.jsxs("div",{ref:m,style:j,className:y,children:[te,q]}),e[55]=m,e[56]=te,e[57]=q,e[58]=j,e[59]=y,e[60]=M):M=e[60],M},_n=({open:s,onOpenChange:e,variant:n="drawer",footer:o})=>{const{t:r}=ue(),{git:i}=js(),a=Xn(),c=bs(p=>p.activeSessions),u=Gn(l.useCallback(p=>s||n==="sidebar"?p.ids:ml,[s,n])),f=Kn(l.useCallback(p=>s||n==="sidebar"?p.rankById:No,[s,n])),d=ze(p=>p.projects),m=ze(p=>p.activeProjectId),g=ut(p=>p.currentDirectory),b=ve(p=>p.currentSessionId),v=ve(p=>p.setCurrentSession),E=ve(p=>p.archiveSession),x=ve(p=>p.deleteSession),A=ve(p=>p.updateSessionTitle),C=ve(p=>p.openNewSessionDraft),P=ze(p=>p.setActiveProject),I=ze(p=>p.setActiveProjectIdOnly),_=ze(p=>p.reorderProjects),D=ze(p=>p.removeProject),j=zt(p=>p.projectExpanded),R=zt(p=>p.worktreeExpanded),y=zt(p=>p.setProjectExpanded),w=zt(p=>p.setWorktreeExpanded),T=ms(p=>p.orderByProject),S=ms(p=>p.setWorktreeOrder),k=Sn(p=>p.expandedParents),$=Sn(p=>p.toggleParent),[O,h]=l.useState(""),[N,L]=l.useState(null),[Y,J]=l.useState(null),[te,q]=l.useState(null),[M,X]=l.useState(null),[K,V]=l.useState(null),[F,Q]=l.useState(null),[ee,B]=l.useState(null),[oe,ie]=l.useState(0),[me,we]=l.useState(!1),[G,pe]=l.useState(!1),[Re,Pe]=l.useState(null),[Te,Be]=l.useState(()=>new Map(ve.getState().availableWorktreesByProject)),[Ie,Ae]=l.useState(()=>{const p=new Set;for(const[U,H]of ve.getState().availableWorktreesByProject)H.length>0&&p.add(U);return p}),[be,z]=l.useState(!1),[W,re]=l.useState(new Set),[ae,ke]=l.useState(new Map);l.useEffect(()=>{if(!s){h(""),z(!1),re(new Set),ke(new Map),L(null),J(null),q(null),X(null),V(null),Q(null);return}vs(a)},[s]),l.useEffect(()=>{be||re(new Set)},[be]),l.useEffect(()=>{if(!s||d.length===0)return;let p=!1;return(async()=>{const H=await Promise.all(d.map(async le=>{const Se=je(le.path);if(!Se)return null;const fe=await i.checkIsGitRepository(Se).catch(()=>!1),De=fe?await sr({id:le.id,path:Se}).catch(()=>[]):[];return[Se,De,fe]}));if(p)return;const se=new Map,ye=new Set;for(const le of H)le&&(se.set(le[0],le[1]),le[2]&&ye.add(le[0]));Be(nr(d,se)),Ae(ye)})(),()=>{p=!0}},[i,s,d,oe]);const he=l.useMemo(()=>d.map(p=>({id:p.id,label:p.label?.trim()||ns(p.path),path:je(p.path),icon:p.icon,color:p.color,iconImage:p.iconImage,iconBackground:p.iconBackground,isGitRepo:Ie.has(je(p.path)),worktrees:al(T[p.id],Te.get(je(p.path))??[])})),[Ie,d,T,Te]),We=l.useMemo(()=>{const p=new Map(a.map(se=>[se.id,se])),U=c.map(se=>{const ye=p.get(se.id);return ye?Eo(ye,se):se}),H=new Set(U.map(se=>se.id));for(const se of a)H.has(se.id)||U.push(se);return U.filter(se=>!se.time?.archived)},[c,a]),Ee=O.trim().toLowerCase(),st=l.useRef(null);l.useEffect(()=>{if(!s)return;const p=window.requestAnimationFrame(()=>{const U=st.current;if(!U)return;(U.querySelector('[data-active-session="true"]')??U.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(p)},[s]);const _t=l.useMemo(()=>{const p=he.map(H=>({project:H,buckets:[],totalSessions:0,isActive:H.id===m})),U=(H,se,ye)=>{const le=je(se)||H.project.path,Se=le||"__root__";let fe=H.buckets.find(De=>De.key===Se);return fe||(fe={key:Se,label:ye?.branch||ns(le),path:le,worktree:ye,sessions:[]},H.buckets.push(fe)),fe};for(const H of p){U(H,H.project.path,null);for(const se of H.project.worktrees)U(H,se.path,se)}for(const H of We){const se=it(H);if(!se)continue;const ye=je(se),le=p.find(De=>ps(De.project,ye));if(!le)continue;const Se=Wt(le.project,ye);(Se?U(le,Se.path,Se):U(le,le.project.path,null)).sessions.push(H)}for(const H of p)for(const se of H.buckets){se.sessions=ln(se.sessions,u,f);for(const ye of se.sessions)yt(ye)||(H.totalSessions+=1)}return p},[m,u,he,f,We]),Hs=je(g),Tr=p=>p.isActive?Hs===p.project.path?p.project.path:p.project.worktrees.find(H=>bl(Hs,H.path))?.path??p.project.path:null,Ir=p=>j[p.project.id]??!0,_r=(p,U)=>R[`${p.project.id}::${U.key}`]??!0,Gs=p=>{ke(U=>{if(!U.has(p))return U;const H=new Map(U);return H.delete(p),H})},Ar=p=>{ke(U=>{let H=!1;const se=new Map(U),ye=`${p}::`;for(const le of se.keys())le.startsWith(ye)&&(se.delete(le),H=!0);return H?se:U})},Dr=(p,U)=>{ke(H=>{const se=new Map(H);return se.set(p,U+os),se})},Ks=(p,U,H)=>{const se=`${p.project.id}::${U.key}`,ye=new Set(U.sessions.map(ge=>ge.id)),le=new Map;for(const ge of U.sessions){const Fe=yt(ge);if(Fe&&ye.has(Fe)){const gt=le.get(Fe)??[];gt.push(ge),le.set(Fe,gt)}}const Se=U.sessions.filter(ge=>{const Fe=yt(ge);return!Fe||!ye.has(Fe)}),fe=ae.get(se)??os,De=Se.slice(0,fe),nt=Se.length-De.length,Qt=Se.length>os&&nt===0,en=(ge,Fe)=>{const gt=le.get(ge.id)??[],Zt=gt.length>0,tn=!!k[ge.id];return t.jsxs(l.Fragment,{children:[t.jsx(In,{session:ge,active:b===ge.id,indent:Fe,hasChildren:Zt,expanded:tn,onToggleChildren:Zt?()=>$(ge.id):void 0,onSelect:()=>qs(ge),revealed:Y===ge.id,onRevealedChange:bt=>zr(ge.id,bt),confirmingDelete:te===ge.id,onArchive:()=>{Or(ge)},onRequestDelete:()=>q(ge.id),onConfirmDelete:()=>{Br(ge)},renaming:M===ge.id,onRequestRename:()=>$r(ge.id),onSubmitRename:bt=>{Fr(ge.id,bt)},onCancelRename:()=>X(null)}),Zt&&tn?gt.map(bt=>en(bt,Fe+pl)):null]},ge.id)};return t.jsxs("div",{children:[De.map(ge=>en(ge,H)),nt>0?t.jsx(yl,{indent:H,onClick:()=>Dr(se,De.length)}):null,Qt?t.jsx(vl,{indent:H,onClick:()=>Gs(se)}):null]})},Mr=(p,U)=>{y(p,!U),Ar(p)},Lr=(p,U,H)=>{w(`${p}::${U}`,!H),Gs(`${p}::${U}`)},qs=p=>{const U=it(p)||null,H=is(he,U??"");if(H){I(H.id),y(H.id,!0);const se=Wt(H,je(U??""));se&&w(`${H.id}::${je(se.path)}`,!0)}v(p.id,U),e(!1)},zr=(p,U)=>{J(U?p:null),q(null),V(null),Q(null)},At=(p,U)=>{V(U?p:null),Q(null),J(null),q(null)},Or=async p=>{J(null),q(null),await E(p.id)?ce.success(r("sessions.sidebar.session.archive.success")):ce.error(r("sessions.sidebar.session.archive.error"))},Br=async p=>{J(null),q(null),await x(p.id)?ce.success(r("sessions.sidebar.session.delete.success")):ce.error(r("sessions.sidebar.session.delete.error"))},$r=p=>{J(null),q(null),X(p)},Fr=async(p,U)=>{X(null);try{await A(p,U)}catch{ce.error(r("mobile.sessions.renameError"))}},Wr=()=>{C(),e(!1)},Js=p=>{Pe(p),I(p),pe(!0)},Ur=Cs(ft(Ps,{activationConstraint:{distance:8}}),ft(Rs,{coordinateGetter:_s})),Vr=p=>{const{active:U,over:H}=p;if(!H||U.id===H.id)return;const se=he.findIndex(le=>le.id===U.id),ye=he.findIndex(le=>le.id===H.id);se<0||ye<0||_(se,ye)},Hr=p=>{re(U=>{const H=new Set(U);return H.has(p)?H.delete(p):H.add(p),H})},Gr=l.useCallback(p=>{const U=it(p),H=is(he,U);if(!H)return ns(U)||U;const se=Wt(H,je(U));return se?.branch?`${H.label} · ${se.branch}`:H.label},[he]),Kr=p=>{P(p.id),e(!1)},qr=l.useMemo(()=>Ee?_t.filter(p=>`${p.project.label} ${p.project.path}`.toLowerCase().includes(Ee)?!0:p.buckets.some(U=>U.sessions.some(H=>as(H,p.project.label,Ee)))):_t,[Ee,_t]),Dt=l.useMemo(()=>Ee?ln(We.filter(p=>{if(yt(p))return!1;const U=it(p),H=is(he,U);return as(p,H?.label??"",Ee)}),u,f):[],[Ee,u,he,f,We]),Mt=l.useMemo(()=>Ee?he.filter(p=>`${p.label} ${p.path}`.toLowerCase().includes(Ee)).map(p=>({...p,sessionCount:We.filter(U=>{if(yt(U))return!1;const H=je(it(U));return ps(p,H)}).length})):[],[Ee,he,We]),Jr=Ee&&Dt.length===0&&Mt.length===0,Ys=!Ee&&he.length>1?t.jsx(xe,{type:"button",variant:"chip",size:"sm","aria-label":r(be?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":be,onClick:()=>z(p=>!p),style:{touchAction:"manipulation"},children:be?t.jsx(or,{className:"size-4"}):t.jsx(ds,{className:"size-4"})}):null,Xs=!be&&he.length>0?t.jsxs(xe,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:Wr,style:{touchAction:"manipulation"},children:[t.jsx(Bi,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,Qs=be?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:()=>we(!0),style:{touchAction:"manipulation"},children:t.jsx(dn,{className:"size-4"})}),Lt=Xs||Qs||Ys?t.jsxs(t.Fragment,{children:[Xs,Qs,Ys]}):null,Zs=t.jsxs("div",{ref:st,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",be&&"hidden"),children:t.jsxs("div",{className:"relative",children:[t.jsx(ir,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(ws,{value:O,onChange:p=>h(p.target.value),placeholder:r("mobile.sessions.search.placeholder"),className:Z("h-11 pl-9",O&&"pr-10")}),O?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:()=>h(""),style:{touchAction:"manipulation"},children:t.jsx(ar,{className:"size-4"})}):null]})}),he.length===0?t.jsx(Mn,{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:()=>we(!0),children:[t.jsx(dn,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):Jr?t.jsx(Mn,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):Ee&&!be?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[Dt.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:Dt.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Dt.map((p,U)=>t.jsx("div",{className:Z(U>0&&"border-t border-border/70"),children:t.jsx(In,{session:p,active:b===p.id,indent:12,contextLabel:Gr(p),onSelect:()=>qs(p)})},p.id))})]}):null,Mt.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:Mt.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Mt.map((p,U)=>t.jsxs("div",{className:Z("flex items-center",U>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:()=>Kr(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(Pn,{className:"mr-2",onClick:()=>Js(p.id)}):null]},p.id))})]}):null]}):be?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:Ur,collisionDetection:Is,onDragEnd:Vr,children:t.jsx(As,{items:he.map(p=>p.id),strategy:Ds,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:he.map(p=>{const U=_t.find(H=>H.project.id===p.id);return t.jsx(jl,{project:p,totalSessions:U?.totalSessions??0,expanded:W.has(p.id),onToggleExpanded:()=>Hr(p.id),onReorderWorktrees:H=>S(p.id,H)},p.id)})})})})]}):t.jsx("div",{className:"flex flex-col",children:qr.map((p,U)=>{const H=Ir(p),se=Ee?p.buckets.filter(le=>le.sessions.some(Se=>as(Se,p.project.label,Ee))):p.buckets,ye=Tr(p);return t.jsxs("section",{className:Z(U>0&&"border-t border-border/70"),children:[t.jsx(Tn,{actionsWidth:96,revealed:K===`project:${p.project.id}`,onRevealedChange:le=>At(`project:${p.project.id}`,le),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:K===`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:()=>{V(null),L(p.project.id)},style:{touchAction:"manipulation"},children:t.jsx(ds,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:K===`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){V(null),Q(null),D(p.project.id),ce.success(r("mobile.sessions.toast.projectRemoved",{label:p.project.label}));return}Q(p.project.id)},style:{touchAction:"manipulation"},children:t.jsx(Ut,{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(K){At(K,!1);return}Mr(p.project.id,H)},"aria-expanded":H,"aria-label":H?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(Rn,{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(Pn,{className:"mr-2",onClick:()=>Js(p.project.id)}):null]})}),H?t.jsx("div",{className:"pb-2",children:(()=>{const le=se.find(fe=>fe.worktree===null),Se=se.filter(fe=>fe.worktree!==null);return t.jsxs(t.Fragment,{children:[le&&le.sessions.length>0?Ks(p,le,Cn):null,Se.map(fe=>{const De=_r(p,fe),nt=ye===fe.path;return t.jsxs("div",{children:[t.jsx(Tn,{actionsWidth:48,revealed:K===`wt:${fe.key}`,onRevealedChange:Qt=>At(`wt:${fe.key}`,Qt),actions:t.jsx("button",{type:"button",tabIndex:K===`wt:${fe.key}`?0:-1,className:"flex flex-1 items-center justify-center text-[var(--status-error)] transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive","aria-label":r("mobile.projectEdit.deleteWorktreeAria",{label:fe.label}),onClick:()=>{V(null),fe.worktree&&B({project:p.project,worktree:fe.worktree})},style:{touchAction:"manipulation"},children:t.jsx(Ut,{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(K){At(K,!1);return}Lr(p.project.id,fe.key,De)},"aria-expanded":De,"aria-label":De?r("sessions.sidebar.group.collapseAria",{label:fe.label}):r("sessions.sidebar.group.expandAria",{label:fe.label}),style:{touchAction:"manipulation"},children:[t.jsx(ne,{name:"git-branch",className:Z("size-4 shrink-0",nt?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Z("block min-w-0 flex-1 truncate typography-ui-label font-bold",nt?"text-foreground":"text-muted-foreground"),children:fe.label}),nt?t.jsx(Rn,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:fe.sessions.length})]})}),De?Ks(p,fe,Cn):null]},fe.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(ne,{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(ne,{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(ne,{name:"settings-3",className:"size-5"})})]})]}):null,t.jsx(yi,{open:me,onOpenChange:we}),t.jsx(vi,{open:G,onOpenChange:p=>{pe(p),p||Pe(null)},onWorktreeCreated:(p,U)=>{U?.sessionId?v(U.sessionId,p):C({selectedProjectId:Re,directoryOverride:p,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(fl,{open:N!==null,project:he.find(p=>p.id===N)??null,onClose:()=>L(null),onWorktreesChanged:()=>ie(p=>p+1)}),ee?t.jsx(Nr,{open:!0,project:{id:ee.project.id,path:ee.project.path},worktree:ee.worktree,onClose:()=>B(null),onDeleted:()=>ie(p=>p+1)}):null]});return n==="sidebar"?s?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]}),Zs]}):null:t.jsxs(Nl,{open:s,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(ne,{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]}),Zs]})},An="mobile-surface-root",kl=16,Dn=320,Sl="cubic-bezier(0.22, 1, 0.36, 1)",Nl=({open:s,onClose:e,ariaLabel:n,children:o})=>{const r=l.useRef(null),[i,a]=l.useState(!1),[c,u]=l.useState(s),f=l.useRef(e);if(l.useEffect(()=>{f.current=e},[e]),typeof document<"u"&&!r.current){let d=document.getElementById(An);d||(d=document.createElement("div"),d.id=An,document.body.appendChild(d)),r.current=d}return l.useEffect(()=>{if(s){u(!0);const m=window.setTimeout(()=>a(!0),kl);return()=>window.clearTimeout(m)}a(!1);const d=window.setTimeout(()=>u(!1),Dn+40);return()=>window.clearTimeout(d)},[s]),l.useEffect(()=>{if(!s)return;const d=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=d,document.removeEventListener("keydown",m)}},[s]),r.current?dt.createPortal(t.jsx("section",{role:"dialog","aria-modal":"true","aria-label":n,"aria-hidden":!s,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 ${Dn}ms ${Sl}`,visibility:c?"visible":"hidden",pointerEvents:s?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:o})}),r.current):null},Mn=s=>{const e=de.c(10),{title:n,description:o,action:r}=s;let i;e[0]!==n?(i=t.jsx("p",{className:"typography-ui-label text-foreground",children:n}),e[0]=n,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 u;return e[6]!==i||e[7]!==a||e[8]!==c?(u=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]=u):u=e[9],u};function El(s){return je(s.path)}function Cl(s){return je(s.path)}function Rl(s){return t.jsx(wl,{worktree:s},je(s.path))}const Pl=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/g,""),Tl=s=>{const e=s.index?.trim();return!!(e&&e!=="?")},Il=s=>{const e=s.working_dir?.trim(),n=s.index?.trim();return!!(e||n==="?")},Ln=(s,e)=>e?`${s}\0staged`:s,_l=({onClose:s,initialDiffPath:e,initialDiffStaged:n=!1})=>{const{t:o}=ue(),{git:r}=js(),i=Pl(Ss()??null),a=Co(i||null),c=Ro(i||null),u=Po(i||null),f=Ue(z=>z.setActiveDirectory),d=Ue(z=>z.ensureAll),m=Ue(z=>z.fetchStatus),g=Ue(z=>z.fetchBranches),b=Ue(z=>z.prefetchDiffs),v=Ue(z=>z.getDiff),E=Ue(z=>z.setDiff),[x,A]=l.useState(()=>e?{type:"diff",path:e,staged:n}:{type:"list"});l.useEffect(()=>{e&&A(z=>z.type==="diff"&&z.path===e&&z.staged===n?z:{type:"diff",path:e,staged:n})},[e,n]);const[C,P]=l.useState(null),[I,_]=l.useState(null),[D,j]=l.useState(""),[R,y]=l.useState(new Set),[w,T]=l.useState(!1),[S,k]=l.useState(!1),[$,O]=l.useState([]),[h,N]=l.useState([]),[L,Y]=l.useState([]),[J,te]=l.useState(null),[q,M]=l.useState(null),[X,K]=l.useState(0),V=l.useMemo(()=>{const z=a?.files??[],W=new Map;for(const re of z)W.set(re.path,re);return Array.from(W.values()).sort((re,ae)=>re.path.localeCompare(ae.path))},[a?.files]),F=l.useMemo(()=>V.filter(Tl),[V]),Q=l.useMemo(()=>V.filter(Il),[V]),ee=l.useMemo(()=>{if(L.length>0)return L;const z=a?.tracking?.includes("/")?a.tracking.split("/")[0]:null;return z||J?[{name:z||"origin",fetchUrl:J??"",pushUrl:J??""}]:[]},[J,L,a?.tracking]),B=Ue(l.useCallback(z=>!i||x.type!=="diff"?null:z.directories.get(i)?.diffCache.get(Ln(x.path,x.staged))??null,[i,x])),oe=l.useMemo(()=>x.type!=="diff"?null:V.find(z=>z.path===x.path)??null,[V,x]),ie=l.useCallback(async(z=!0)=>{if(i)try{await Promise.all([m(i,r),g(i,r)])}catch(W){z&&ce.error(W instanceof Error?W.message:o("gitView.toast.refreshRepositoryFailed"))}},[i,g,m,r,o]),me=l.useCallback(async()=>{if(!i){Y([]),te(null);return}try{const[z,W]=await Promise.all([r.getRemotes(i).catch(()=>[]),r.getRemoteUrl?r.getRemoteUrl(i).catch(()=>null):Promise.resolve(null)]);Y(z),te(W)}catch{Y([]),te(null)}},[i,r]);l.useEffect(()=>{i&&(f(i),d(i,r))},[i,d,r,f]),l.useEffect(()=>{me()},[me]),l.useEffect(()=>{if(!i||V.length===0)return;const z=Array.from(new Set([...F.map(re=>re.path),...h,...V.slice(0,20).map(re=>re.path)])).filter(Boolean);if(z.length===0)return;const W=window.setTimeout(()=>{b(i,r,z,{maxFiles:40})},120);return()=>window.clearTimeout(W)},[V,i,r,b,F,h]),l.useEffect(()=>{if(x.type!=="diff"){M(null);return}const z=Ln(x.path,x.staged);if(!i||v(i,z)){M(null);return}let W=!1;const re=Tt();return M(null),r.getGitFileDiff(i,{path:x.path,staged:x.staged||void 0}).then(ae=>{W||E(i,z,{original:ae.original??"",modified:ae.modified??"",isBinary:ae.isBinary},re)}).catch(ae=>{W||M(ae instanceof Error?ae.message:String(ae))}),()=>{W=!0}},[i,X,v,r,x,E]);const we=async(z,W)=>{if(i){P(z);try{const re=ae=>{const ke=`${ae.name}/`,he=a?.tracking?.startsWith(ke)?a.tracking.slice(ke.length):void 0;return{remote:ae.name,branch:he,rebase:!0}};if(z==="fetch"){if(!W)throw new Error(o("mobile.changes.noRemote"));await r.gitFetch(i,{remote:W.name}),ce.success(o("gitView.toast.fetchedFromRemote",{name:W.name}))}else if(z==="sync"){if(!W)throw new Error(o("mobile.changes.noRemote"));await r.gitFetch(i,{remote:W.name});const ae=await r.getGitStatus(i);if((ae.behind??0)>0){if((ae.files?.length??0)>0){ce.error(o("gitView.toast.commitOrStashBeforeSync"));return}await r.gitPull(i,re(W))}((await r.getGitStatus(i)).ahead??0)>0&&await r.gitPush(i),ce.success(o("gitView.toast.alreadyUpToDate"))}await ie(!1),await me()}catch(re){ce.error(re instanceof Error?re.message:o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}))}finally{P(null)}}},G=l.useCallback(async(z,W)=>{if(!(!i||z.length===0))try{W==="stage"?z.length>1?await To(i,z):await Io(i,z[0]):z.length>1?await _o(i,z):await Ao(i,z[0]),await ie(!1)}catch(re){ce.error(re instanceof Error?re.message:o(W==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[i,ie,o]),pe=l.useCallback((z,W=!1)=>{A({type:"diff",path:z,staged:W})},[]),Re=l.useCallback(async z=>{if(i){y(W=>new Set(W).add(z));try{await r.revertGitFile(i,z),ce.success(o("gitView.toast.revertedFile",{path:z})),await ie(!1)}catch(W){ce.error(W instanceof Error?W.message:o("gitView.toast.revertFailed"))}finally{y(W=>{const re=new Set(W);return re.delete(z),re})}}},[i,r,ie,o]),Pe=l.useCallback(async z=>{if(!i||z.length===0||w)return;const W=Array.from(new Set(z));T(!0),y(new Set(W));try{await Promise.all(W.map(re=>r.revertGitFile(i,re))),await ie(!1),ce.success(W.length===1?o("gitView.toast.revertedFilesSingle",{count:W.length}):o("gitView.toast.revertedFilesPlural",{count:W.length}))}catch(re){ce.error(re instanceof Error?re.message:o("gitView.toast.revertFailed"))}finally{y(new Set),T(!1)}},[i,r,w,ie,o]),Te=l.useCallback(z=>{const W=z.map(re=>re.trim()).filter(Boolean);if(W.length===0){O([]);return}j(re=>`${re.trim()}${re.trim()?`
21
-
22
- `:""}${W.join(`
23
- `)}`.trim()),O([])},[]),Be=l.useCallback(async()=>{if(!i)return;const z=F.map(W=>W.path).sort();if(z.length===0){ce.error(o("gitView.toast.selectFileToDescribe"));return}k(!0);try{const{message:W}=await Do(i,z);j(W.subject?.trim()??""),O(Array.isArray(W.highlights)?W.highlights:[])}catch(W){ce.error(W instanceof Error?W.message:o("gitView.toast.generateCommitMessageFailed"))}finally{k(!1)}},[i,F,o]),Ie=async(z={})=>{if(!i)return;if(!D.trim()){ce.error(o("gitView.toast.enterCommitMessage"));return}const W=F.map(re=>re.path).sort();if(W.length===0){ce.error(o("gitView.toast.selectFileToCommit"));return}_(z.pushAfter?"commitAndPush":"commit");try{if(await r.createGitCommit(i,D.trim(),{files:W}),ce.success(o("gitView.toast.commitCreated")),j(""),O([]),z.pushAfter){const re=a?.tracking?.split("/")[0],ae=ee.find(st=>st.name===re)??ee[0];if(!ae)throw new Error(o("mobile.changes.noRemote"));P("sync");const ke=`${ae.name}/`,he=a?.tracking?.startsWith(ke)?a.tracking.slice(ke.length):void 0;await r.gitFetch(i,{remote:ae.name}),((await r.getGitStatus(i)).behind??0)>0&&await r.gitPull(i,{remote:ae.name,branch:he,rebase:!0}),((await r.getGitStatus(i)).ahead??0)>0&&await r.gitPush(i),await ie(!1),await me()}else await ie(!1)}catch(re){ce.error(re instanceof Error?re.message:o("gitView.toast.createCommitFailed"))}finally{_(null),z.pushAfter&&P(null)}},Ae=l.useMemo(()=>{const z=[];return F.length>0&&z.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:F,actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:W=>o("gitView.changes.unstageFileAria",{path:W}),onActionFile:W=>{G([W],"unstage")},onActionAll:W=>{G(W,"unstage")},onViewDiff:W=>pe(W,!0),onRevertFile:Re,showRevertActions:!1,accent:!0}),Q.length>0&&z.push({id:"unstaged",title:o("gitView.changes.title"),entries:Q,actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:W=>o("gitView.changes.stageFileAria",{path:W}),onActionFile:W=>{G([W],"stage")},onActionAll:W=>{G(W,"stage")},onViewDiff:W=>pe(W,!1),onRevertFile:Re}),z},[Re,pe,G,F,o,Q]),be=z=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(ne,{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:z})]});return i?u&&c===null?be(t.jsx(Ke,{loading:!0,message:o("gitView.loading.checkingRepository")})):c===!1?be(t.jsx(Ke,{icon:!0,message:o("gitView.empty.notGitRepository"),description:o("gitView.empty.notGitRepositoryDescription")})):x.type==="diff"?t.jsx(Al,{path:x.path,diff:B,fileExists:!!oe,error:q,onBack:()=>A({type:"list"}),onRetry:()=>K(z=>z+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:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(ne,{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(wi,{syncAction:C,remotes:ee,onFetch:z=>{we("fetch",z)},onSync:z=>{we("sync",z)},disabled:I!==null||u,aheadCount:a?.ahead??0,behindCount:a?.behind??0,trackingRemoteName:a?.tracking?.split("/")[0],hasUncommittedChanges:V.length>0})]}),V.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(Ki,{groups:Ae,diffStats:a?.diffStats,revertingPaths:R,onRevertAll:Pe,isRevertingAll:w,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:N})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(qi,{stagedCount:F.length,commitMessage:D,onCommitMessageChange:j,generatedHighlights:$,onInsertHighlights:Te,onGenerateMessage:Be,isGeneratingMessage:S,onCommit:()=>{Ie({pushAfter:!1})},onCommitAndPush:()=>{Ie({pushAfter:!0})},commitAction:I,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")})})]}):be(t.jsx(Ke,{message:o("gitView.empty.selectSessionOrDirectory")}))},Ke=s=>{const e=de.c(13),{message:n,description:o,loading:r,icon:i}=s,a=r===void 0?!1:r,c=i===void 0?!1:i;let u;e[0]!==a?(u=a?t.jsx(ne,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=a,e[1]=u):u=e[1];let f;e[2]!==c?(f=c?t.jsx(ne,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=c,e[3]=f):f=e[3];let d;e[4]!==n?(d=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:n}),e[4]=n,e[5]=d):d=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]!==u||e[9]!==f||e[10]!==d||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:[u,f,d,m]})}),e[8]=u,e[9]=f,e[10]=d,e[11]=m,e[12]=g):g=e[12],g},Al=s=>{const e=de.c(24),{path:n,diff:o,fileExists:r,error:i,onBack:a,onRetry:c}=s,{t:u}=ue();let f;e[0]!==n?(f=Mo(n)||"text",e[0]=n,e[1]=f):f=e[1];const d=f;let m;e[2]!==u?(m=u("header.actions.backAria"),e[2]=u,e[3]=m):m=e[3];let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(ne,{name:"arrow-left",className:"size-5"}),e[4]=g):g=e[4];let b;e[5]!==a||e[6]!==m?(b=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]=b):b=e[7];let v;e[8]!==n?(v=t.jsx("div",{className:"min-w-0 flex-1 px-2",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:n})}),e[8]=n,e[9]=v):v=e[9];let E;e[10]!==b||e[11]!==v?(E=t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/70 px-3 text-foreground",children:[b,v]}),e[10]=b,e[11]=v,e[12]=E):E=e[12];let x;e[13]!==o||e[14]!==i||e[15]!==r||e[16]!==d||e[17]!==c||e[18]!==n||e[19]!==u?(x=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:u("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:u("diffView.actions.retry")})]})}):o?o.isBinary?t.jsx(Ke,{icon:!0,message:u("diffView.binary.unavailable")}):Lo(n)?t.jsx(Ke,{icon:!0,message:u("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(Ji,{original:o.original,modified:o.modified,language:d,fileName:n,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):t.jsx(Ke,{loading:!0,message:u("diffView.state.loadingDiff")}):t.jsx(Ke,{icon:!0,message:u("mobile.changes.diffDetail.missingTitle"),description:u("mobile.changes.diffDetail.missingDescription")})}),e[13]=o,e[14]=i,e[15]=r,e[16]=d,e[17]=c,e[18]=n,e[19]=u,e[20]=x):x=e[20];let A;return e[21]!==E||e[22]!==x?(A=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[E,x]}),e[21]=E,e[22]=x,e[23]=A):A=e[23],A},Dl=l.lazy(()=>$e(()=>import("./FilesView-WkxsWHBE.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(s=>({default:s.FilesView}))),et=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/g,""),Nt=s=>{const e=et(s);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},Ml=s=>{const e=et(s);if(!e||e==="/")return null;const n=e.lastIndexOf("/");return n<=0?e.startsWith("/")?"/":null:e.slice(0,n)},Ll=(s,e)=>{const n=et(s),o=et(e);return!o||n===o?Nt(n):n.startsWith(`${o}/`)?n.slice(o.length+1):n},zl=s=>{if(typeof s!="number"||!Number.isFinite(s)||s<0)return"";if(s<1024)return`${s} B`;const e=["KB","MB","GB"];let n=s/1024;for(const o of e){if(n<1024||o===e[e.length-1])return`${n.toFixed(n>=10?0:1)} ${o}`;n/=1024}return""},Ol=({onClose:s})=>{const{t:e}=ue(),{files:n}=js(),o=eo(h=>h.setSelectedPath),r=et(Ss()??null),[i,a]=l.useState(()=>({type:"browser",directory:r})),[c,u]=l.useState([]),[f,d]=l.useState(!1),[m,g]=l.useState(null),[b,v]=l.useState(""),[E,x]=l.useState([]),[A,C]=l.useState(!1),P=l.useRef(0);l.useEffect(()=>{r&&a(h=>h.type==="browser"&&h.directory?h:{type:"browser",directory:r})},[r]);const I=i.type==="browser"?i.directory:i.returnDirectory,_=l.useCallback(async h=>{if(!h)return;const N=P.current+1;P.current=N,d(!0),g(null);try{const L=await n.listDirectory(h);if(P.current!==N)return;u(L.entries.slice().sort((Y,J)=>Y.isDirectory!==J.isDirectory?Y.isDirectory?-1:1:Y.name.localeCompare(J.name)))}catch(L){if(P.current!==N)return;u([]),g(L instanceof Error?L.message:e("mobile.files.error.listFailed"))}finally{P.current===N&&d(!1)}},[n,e]);l.useEffect(()=>{i.type==="browser"&&_(i.directory)},[_,i]),l.useEffect(()=>{if(i.type!=="browser")return;const h=b.trim();if(!h){x([]),C(!1);return}let N=!1;const L=window.setTimeout(()=>{C(!0),n.search({directory:i.directory,query:h,maxResults:40}).then(Y=>{N||x(Y)}).catch(()=>{N||x([])}).finally(()=>{N||C(!1)})},250);return()=>{N=!0,window.clearTimeout(L)}},[n,b,i]);const D=h=>{v(""),a({type:"browser",directory:h})},j=h=>{o(r,h),a({type:"file",path:h,returnDirectory:I||r})},R=Ve(h=>h.pendingFileFocusPath),y=Ve(h=>h.pendingFileNavigation);if(l.useEffect(()=>{const h=et(y?.path??R??"");!h||!r||h!==r&&!h.startsWith(`${r}/`)||(o(r,h),a({type:"file",path:h,returnDirectory:r}),R&&Ve.getState().setPendingFileFocusPath(null))},[R,y,r,o]),!r)return t.jsx(Et,{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(un,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:Nt(i.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Oe,{children:t.jsx(l.Suspense,{fallback:t.jsx(Et,{loading:!0,message:e("filesView.state.loading")}),children:t.jsx(Dl,{mode:"editor-only"})})})})]});const w=i.directory===r?e("mobile.files.rootDirectory"):Nt(i.directory),T=b.trim()?E:[],S=Ml(i.directory),k=i.directory!==r&&S!==null&&(S===r||S.startsWith(`${r}/`)),$=k&&!b.trim(),O=k?S: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:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(ar,{className:"size-5"})}):null,$&&O?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:Nt(O)}),onClick:()=>D(O),style:{touchAction:"manipulation"},children:t.jsx(un,{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:w})}),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:()=>{_(i.directory)},style:{touchAction:"manipulation"},children:t.jsx(Wi,{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(ir,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(ws,{value:b,onChange:h=>v(h.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(Et,{message:m}):b.trim()?t.jsx(Bl,{results:T,isSearching:A,onOpenFile:j}):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(h=>t.jsx(Cr,{name:h.name,path:h.path,directory:h.isDirectory,meta:h.isDirectory?void 0:zl(h.size),onClick:()=>h.isDirectory?D(h.path):j(h.path)},h.path))]})})]})},Cr=s=>{const e=de.c(16),{name:n,path:o,directory:r,meta:i,onClick:a}=s;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={touchAction:"manipulation"},e[0]=c):c=e[0];let u;e[1]!==r||e[2]!==o?(u=r?t.jsx(Ui,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(zo,{filePath:o,className:"size-5 shrink-0"}),e[1]=r,e[2]=o,e[3]=u):u=e[3];let f;e[4]!==n?(f=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:n}),e[4]=n,e[5]=f):f=e[5];let d;e[6]!==i?(d=i?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,e[6]=i,e[7]=d):d=e[7];let m;e[8]!==r?(m=r?t.jsx(Vi,{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]!==u||e[12]!==f||e[13]!==d||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:[u,f,d,m]}),e[10]=a,e[11]=u,e[12]=f,e[13]=d,e[14]=m,e[15]=g):g=e[15],g},Bl=s=>{const e=de.c(10),{results:n,isSearching:o,onOpenFile:r}=s,{t:i}=ue(),a=et(Ss()??null);if(o){let d;e[0]!==i?(d=i("common.loading"),e[0]=i,e[1]=d):d=e[1];let m;return e[2]!==d?(m=t.jsx(Et,{loading:!0,message:d}),e[2]=d,e[3]=m):m=e[3],m}if(n.length===0){let d;e[4]!==i?(d=i("mobile.files.search.empty"),e[4]=i,e[5]=d):d=e[5];let m;return e[6]!==d?(m=t.jsx(Et,{message:d}),e[6]=d,e[7]=m):m=e[7],m}const c="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",u=n.map(d=>t.jsx(Cr,{name:Nt(d.path),path:d.path,directory:!1,meta:Ll(d.path,a),onClick:()=>r(d.path)},d.path));let f;return e[8]!==u?(f=t.jsx("div",{className:c,children:u}),e[8]=u,e[9]=f):f=e[9],f},Et=s=>{const e=de.c(7),{message:n,loading:o}=s,r=o===void 0?!1:o;let i;e[0]!==r?(i=r?t.jsx(Hi,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(Gi,{className:"size-6 text-muted-foreground"}),e[0]=r,e[1]=i):i=e[1];let a;e[2]!==n?(a=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:n}),e[2]=n,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},zn="mobile-surface-root",$l=16,On=320,Fl="cubic-bezier(0.22, 1, 0.36, 1)",Wl=s=>{const e=de.c(36),{onOpenMcpSettings:n}=s,{t:o}=ue(),[r,i]=l.useState(!1),a=ut(Ul),c=Bo(Vl),u=Bt(Hl);let f;e[0]!==a||e[1]!==r||e[2]!==u||e[3]!==c?(f=()=>{if(r)return;i(!0);const w=new Promise(Gl);Promise.all([c({directory:a||null,silent:!0}),u({force:!0}),w]).finally(()=>i(!1))},e[0]=a,e[1]=r,e[2]=u,e[3]=c,e[4]=f):f=e[4];const d=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 b,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(b={touchAction:"manipulation"},v=t.jsx(ne,{name:"add",className:"size-5"}),e[9]=b,e[10]=v):(b=e[9],v=e[10]);let E;e[11]!==n||e[12]!==m||e[13]!==g?(E=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:n,"aria-label":m,title:g,style:b,children:v}),e[11]=n,e[12]=m,e[13]=g,e[14]=E):E=e[14];let x;e[15]!==o?(x=o("mcpDropdown.actions.refreshAria"),e[15]=o,e[16]=x):x=e[16];let A;e[17]!==o?(A=o("mcpDropdown.actions.refreshAria"),e[17]=o,e[18]=A):A=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C={touchAction:"manipulation"},e[19]=C):C=e[19];const P=r&&"animate-spin";let I;e[20]!==P?(I=Z("size-5",P),e[20]=P,e[21]=I):I=e[21];let _;e[22]!==I?(_=t.jsx(ne,{name:"refresh",className:I}),e[22]=I,e[23]=_):_=e[23];let D;e[24]!==r||e[25]!==d||e[26]!==_||e[27]!==x||e[28]!==A?(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:d,disabled:r,"aria-label":x,title:A,style:C,children:_}),e[24]=r,e[25]=d,e[26]=_,e[27]=x,e[28]=A,e[29]=D):D=e[29];let j;e[30]!==D||e[31]!==E?(j=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[E,D]}),e[30]=D,e[31]=E,e[32]=j):j=e[32];let R;e[33]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Ni,{active:!0,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=R):R=e[33];let y;return e[34]!==j?(y=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[j,R]}),e[34]=j,e[35]=y):y=e[35],y},Bn=({open:s,onClose:e,tab:n,onTabChange:o,pendingChangesDiff:r,onOpenPlan:i,onOpenMcpSettings:a,variant:c="drawer"})=>{const{t:u}=ue(),f=l.useRef(null),[d,m]=l.useState(!1),[g,b]=l.useState(s),v=l.useRef(e);l.useEffect(()=>{v.current=e},[e]);const E=l.useRef(n);l.useEffect(()=>{E.current=n},[n]);const[x,A]=l.useState(()=>new Set);if(l.useEffect(()=>{s&&A(I=>{if(I.has(n))return I;const _=new Set(I);return _.add(n),_})},[s,n]),typeof document<"u"&&!f.current){let I=document.getElementById(zn);I||(I=document.createElement("div"),I.id=zn,document.body.appendChild(I)),f.current=I}if(l.useEffect(()=>{if(s){b(!0);const _=window.setTimeout(()=>m(!0),$l);return()=>window.clearTimeout(_)}m(!1);const I=window.setTimeout(()=>b(!1),On+40);return()=>window.clearTimeout(I)},[s]),l.useEffect(()=>{if(!s)return;const I=document.body.style.overflow;c==="drawer"&&(document.body.style.overflow="hidden");const _=D=>{D.key==="Escape"&&E.current!=="terminal"&&v.current()};return document.addEventListener("keydown",_),()=>{c==="drawer"&&(document.body.style.overflow=I),document.removeEventListener("keydown",_)}},[s,c]),c==="drawer"&&!f.current)return null;const C=[{id:"changes",label:u("mobile.menu.changes"),icon:t.jsx(ne,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:u("mobile.menu.files"),icon:t.jsx(ne,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:u("mobile.menu.terminal"),icon:t.jsx(ne,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:u("contextRail.surface.notes"),icon:t.jsx(ne,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:u("mobile.menu.mcp"),icon:t.jsx(Oo,{className:"h-3.5 w-3.5"})}],P=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(ji,{items:C,activeId:n,onSelect:I=>o(I),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":u("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(ne,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[x.has("changes")?t.jsx("div",{className:Z("h-full",n!=="changes"&&"hidden"),children:t.jsx(Oe,{children:t.jsx(_l,{initialDiffPath:r?.path??null,initialDiffStaged:r?.staged===!0})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,x.has("files")?t.jsx("div",{className:Z("h-full",n!=="files"&&"hidden"),children:t.jsx(Oe,{children:t.jsx(Ol,{})})}):null,x.has("terminal")?t.jsx("div",{className:Z("h-full",n!=="terminal"&&"hidden"),children:t.jsx(Oe,{children:t.jsx(ki,{visible:s&&n==="terminal"})})}):null,x.has("notes")?t.jsx("div",{className:Z("h-full",n!=="notes"&&"hidden"),children:t.jsx(Oe,{children:t.jsx(Si,{onActionComplete:e,onOpenPlan:i})})}):null,x.has("mcp")?t.jsx("div",{className:Z("h-full",n!=="mcp"&&"hidden"),children:t.jsx(Oe,{children:t.jsx(Wl,{onOpenMcpSettings:a})})}):null]})]});return c==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:P}):dt.createPortal(t.jsx("section",{role:"dialog","aria-modal":"true","aria-label":u("mobile.header.openWorkspaceAria"),"aria-hidden":!s,className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:d?"none":"translateX(100%)",transition:`transform ${On}ms ${Fl}`,visibility:g?"visible":"hidden",pointerEvents:s?"auto":"none"},children:P}),f.current)};function Ul(s){return s.currentDirectory}function Vl(s){return s.refresh}function Hl(s){return s.loadMcpConfigs}function Gl(s){return window.setTimeout(s,500)}const It=()=>typeof window>"u"?!1:window.Capacitor?.isNativePlatform?.()===!0?!0:window.location.protocol==="capacitor:",Kl=()=>{l.useEffect(()=>{if(!It())return;let s=!1;const e=[],n=document.documentElement;n.classList.add("oc-capacitor-app"),window.Capacitor?.getPlatform?.()==="android"&&n.classList.add("oc-platform-android"),e.push($o());const r=i=>{n.style.setProperty("--oc-keyboard-inset",`${Math.max(0,Math.round(i))}px`)};return $e(()=>import("./vendor-capacitor-status-bar-B-N0EOVk.js"),__vite__mapDeps([122,123])).then(async({StatusBar:i,Style:a})=>{if(s)return;const c=window.Capacitor?.getPlatform?.(),u=async()=>{if(c==="android"){const g=document.documentElement.classList.contains("dark"),b=(g?localStorage.getItem("splashBgDark"):localStorage.getItem("splashBgLight"))||(g?"#171515":"#fffdf4");await i.setOverlaysWebView({overlay:!1}).catch(()=>{}),await i.setBackgroundColor({color:b}).catch(()=>{}),await i.setStyle({style:g?a.Dark:a.Light}).catch(()=>{}),await i.show().catch(()=>{});return}await i.setStyle({style:a.Default}).catch(()=>{}),await i.setOverlaysWebView({overlay:!0}).catch(()=>{}),await i.show().catch(()=>{})};await u();const f=window.setTimeout(()=>{u()},400);e.push(()=>window.clearTimeout(f));const{App:d}=await $e(async()=>{const{App:g}=await import("./vendor-capacitor-app-BrDJj9I_.js");return{App:g}},__vite__mapDeps([124,4,123])),m=await d.addListener("appStateChange",({isActive:g})=>{g&&u()});if(s){m.remove();return}e.push(()=>{m.remove()})}).catch(()=>{}),$e(()=>import("./vendor-capacitor-keyboard-CYccoJjr.js"),__vite__mapDeps([125,123])).then(async({Keyboard:i})=>{if(s)return;if(window.Capacitor?.getPlatform?.()==="android"){const w=await i.addListener("keyboardWillShow",O=>{cn(O.keyboardHeight),n.classList.add("oc-keyboard-open"),window.dispatchEvent(new CustomEvent("oc:keyboard-settled",{detail:{open:!0}}))}),T=await i.addListener("keyboardDidShow",()=>{window.dispatchEvent(new CustomEvent("oc:keyboard-settled",{detail:{open:!0}}))}),S=await i.addListener("keyboardWillHide",()=>{window.dispatchEvent(new CustomEvent("oc:keyboard-intent",{detail:{open:!1}})),n.classList.remove("oc-keyboard-open")}),k=await i.addListener("keyboardDidHide",()=>{window.dispatchEvent(new CustomEvent("oc:keyboard-settled",{detail:{open:!1}}))}),$=()=>{w.remove(),T.remove(),S.remove(),k.remove()};if(s){$();return}e.push($);return}await i.setAccessoryBarVisible({isVisible:!1}).catch(()=>{});const c=250,u=200,f="cubic-bezier(0.38, 0.7, 0.125, 1)";let d=null,m=null,g=0,b=!1,v=0,E=!1;const x=(w,T)=>{n.style.setProperty(w,`${Math.max(0,Math.round(T))}px`)},A=()=>{d!==null&&(window.clearTimeout(d),d=null)},C=(w,T)=>{window.dispatchEvent(new CustomEvent(w,{detail:T}))},P=()=>{const w=[],T=document.querySelector(".oc-mobile-composer");T&&w.push({el:T,factor:1});const S=document.querySelector(".oc-draft-center");return S&&w.push({el:S,factor:.5}),w},I=()=>{for(const{el:w}of P())w.style.transition="",w.style.transform=""},_=await i.addListener("keyboardWillShow",w=>{if(A(),cn(w.keyboardHeight),E=!0,g=w.keyboardHeight,!b){const S=document.querySelector(".oc-mobile-app-shell");v=S&&parseFloat(getComputedStyle(S).paddingBottom)||0}const T=Math.max(0,g-v);n.classList.remove("oc-kb-hide"),m!==null&&(window.clearTimeout(m),m=null),n.classList.add("oc-keyboard-open","oc-kb-animating","oc-kb-caret-hold"),r(g);for(const{el:S,factor:k}of P())S.style.transition=`transform ${c}ms ${f}`,S.style.transform=`translateY(${-T*k}px)`;x("--oc-kb-scroll-inset",T),C("oc:keyboard-settled",{open:!0}),C("oc:keyboard-anim",{phase:"show",slide:T,durationMs:c,easing:f}),d=window.setTimeout(()=>{d=null,n.classList.remove("oc-kb-animating"),x("--oc-kb-layout",g),b=!0,I(),C("oc:keyboard-settled",{open:!0}),m=window.setTimeout(()=>{m=null,n.classList.remove("oc-kb-caret-hold")},250)},c+20)}),D=()=>{if(!E)return;E=!1,A(),C("oc:keyboard-intent",{open:!1}),m!==null&&(window.clearTimeout(m),m=null),n.classList.remove("oc-kb-caret-hold");const w=Math.max(0,g-v);if(n.classList.remove("oc-keyboard-open"),r(0),x("--oc-kb-scroll-inset",0),b){n.classList.remove("oc-kb-animating"),x("--oc-kb-layout",0),b=!1;for(const{el:T,factor:S}of P())T.style.transition="none",T.style.transform=`translateY(${-w*S}px)`;document.querySelector(".oc-mobile-app-shell")?.offsetHeight}C("oc:keyboard-anim",{phase:"hide",slide:w,durationMs:u,easing:f}),n.classList.add("oc-kb-animating","oc-kb-hide");for(const{el:T}of P())T.style.transition=`transform ${u}ms ${f}`,T.style.transform="translateY(0px)";d=window.setTimeout(()=>{d=null,n.classList.remove("oc-kb-animating","oc-kb-hide"),I(),C("oc:keyboard-settled",{open:!1})},u+20)},j=await i.addListener("keyboardWillHide",D),R=w=>w instanceof HTMLElement&&(w.tagName==="TEXTAREA"||w.tagName==="INPUT"||w.isContentEditable),y=w=>{E&&R(w.target)&&(R(w.relatedTarget)||window.setTimeout(()=>{E&&(R(document.activeElement)||D())},0))};if(document.addEventListener("focusout",y,!0),s){A(),document.removeEventListener("focusout",y,!0),_.remove(),j.remove();return}e.push(A,()=>{m!==null&&(window.clearTimeout(m),m=null)},()=>document.removeEventListener("focusout",y,!0),()=>{_.remove()},()=>{j.remove()})}).catch(()=>{}),()=>{s=!0,e.forEach(i=>i()),Fo(),n.classList.remove("oc-capacitor-app","oc-keyboard-open","oc-kb-animating","oc-kb-hide","oc-kb-caret-hold","oc-platform-android"),n.style.removeProperty("--oc-keyboard-inset"),n.style.removeProperty("--oc-kb-shift"),n.style.removeProperty("--oc-kb-layout"),n.style.removeProperty("--oc-kb-scroll-inset")}},[])},ql=s=>{const e=l.useRef(!1);l.useEffect(()=>{if(!It())return;let n=!1;const o=[],r=()=>{e.current&&(e.current=!1,s())},i=()=>{if(document.visibilityState==="hidden"){e.current=!0;return}r()};return document.addEventListener("visibilitychange",i),o.push(()=>document.removeEventListener("visibilitychange",i)),$e(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([124,4,123])).then(async({App:a})=>{if(n)return;const c=await a.addListener("appStateChange",({isActive:f})=>{if(document.documentElement.classList.toggle("oc-native-app-active",f),!f){e.current=!0;return}r()}),u=await a.addListener("resume",r);if(n){c.remove(),u.remove();return}o.push(()=>{c.remove()},()=>{u.remove()})}).catch(()=>{}),()=>{n=!0,o.forEach(a=>a())}},[s])},Jl=s=>{l.useEffect(()=>{if(!It())return;let e=!1,n=null;return $e(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([124,4,123])).then(async({App:o})=>{if(e)return;const r=await o.addListener("backButton",()=>{s()||o.minimizeApp().catch(()=>{})});if(e){r.remove();return}n=()=>{r.remove()}}).catch(()=>{}),()=>{e=!0,n?.()}},[s])};function Yl(s){const e=de.c(4),n=2500,{uiFont:o}=Wo(),[r,i]=l.useState(!1);let a,c;return e[0]!==n||e[1]!==o?(a=()=>{let u=!1;const f=()=>{u||i(!0)},d=()=>{requestAnimationFrame(()=>requestAnimationFrame(f))},m=Promise.all([Uo(o).catch(tc),document.fonts?.ready?.then(ec).catch(Zl)??Promise.resolve(),Yi.catch(Ql)]).then(Xl),g=new Promise(b=>{window.setTimeout(b,n)});return Promise.race([m,g]).then(d),()=>{u=!0}},c=[o,n],e[0]=n,e[1]=o,e[2]=a,e[3]=c):(a=e[2],c=e[3]),l.useEffect(a,c),r}function Xl(){}function Ql(){}function Zl(){}function ec(){}function tc(){}const sc="openchamber",nc=s=>s.replace(/^\/+|\/+$/g,""),rc=s=>{const e=nc(s.pathname).split("/").filter(Boolean);return s.host?[s.host,...e]:e};function oc(s){if(typeof s!="string"||s.length===0)return null;let e;try{e=new URL(s)}catch{return null}if(e.protocol!==`${sc}:`)return null;const n=rc(e),o=(n[0]??"").toLowerCase(),r=n.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={},Rr=!1,St=null;const ic=s=>{switch(s.type){case"session":return ve.getState().setCurrentSession(s.sessionId,s.directory??null),!0;case"new-session":{const e=ve.getState();return e.openNewSessionDraft(),(s.directory||s.projectId)&&e.setNewSessionDraftTarget({directoryOverride:s.directory??null,projectId:s.projectId??null,selectedProjectId:s.projectId??null}),!0}case"sessions":return Me.openSessions?(Me.openSessions(s.filter),!0):!1;case"status":return Me.openSessions?(Me.openSessions(),!0):!1;case"view":return Me.openView?(Me.openView(s.target),!0):!1;case"changes":return Me.openChanges?(Me.openChanges({path:s.path,staged:s.staged}),!0):!1;case"settings":return Me.openSettings?(Me.openSettings(s.section),!0):!1}},Vs=()=>{if(!Rr||!St)return;const s=St;St=null,ic(s)||(St=s)},Pr=s=>{St=s,Vs()},$n=s=>{const e=oc(s);e&&Pr(e)},ac=s=>{Rr=s,Vs()},lc=s=>{const e=de.c(3);let n,o;e[0]!==s?(n=()=>(Me=s,Vs(),()=>{Me===s&&(Me={})}),o=[s],e[0]=s,e[1]=n,e[2]=o):(n=e[1],o=e[2]),l.useEffect(n,o)},cc=s=>{const{ready:e}=s;l.useEffect(()=>{ac(e)},[e]),l.useEffect(()=>{if(!Ce())return;let n=!1;const o=[];return $e(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([124,4,123])).then(async({App:r})=>{if(n)return;const i=await r.addListener("appUrlOpen",a=>{$n(a?.url)});if(n){i.remove();return}o.push(()=>{i.remove()})}).catch(()=>{}),$e(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([126,123])).then(async({PushNotifications:r})=>{if(n)return;const i=await r.addListener("pushNotificationActionPerformed",a=>{const c=a?.notification?.data,u=typeof c?.url=="string"?c.url:typeof c?.deeplink=="string"?c.deeplink:void 0;if(u){$n(u);return}const f=typeof c?.sessionId=="string"?c.sessionId:void 0;f&&Pr({type:"session",sessionId:f})});if(n){i.remove();return}o.push(()=>{i.remove()})}).catch(()=>{}),()=>{n=!0,o.forEach(r=>r())}},[])},dc=32,uc=80,fc=64,mc=.7,pc=(s,e)=>{const n=l.useRef(e);n.current=e,l.useEffect(()=>{const o=s.current;if(!o)return;const i=window.Capacitor?.getPlatform?.()==="android"?uc:dc;let a=!1,c=!1,u=0,f=0;const d=g=>{if(g.touches.length!==1){a=!1;return}const b=g.touches[0],v=o.clientWidth,E=b.clientX<=i,x=b.clientX>=v-i;a=E||x,c=E,u=b.clientX,f=b.clientY},m=g=>{if(!a)return;a=!1;const b=g.changedTouches[0];if(!b)return;const v=b.clientX-u,E=b.clientY-f;Math.abs(v)<fc||Math.abs(E)>Math.abs(v)*mc||c&&v<=0||!c&&v>=0||(c?n.current.onLeftEdgeSwipe?.():n.current.onRightEdgeSwipe?.())};return o.addEventListener("touchstart",d,{passive:!0}),o.addEventListener("touchend",m,{passive:!0}),()=>{o.removeEventListener("touchstart",d),o.removeEventListener("touchend",m)}},[s])},hc=()=>{if(typeof window>"u")return;const s=window.__OPENCHAMBER_APNS_ENV__;if(s==="development")return"sandbox";if(s==="production")return"production"},gc=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},bc=s=>{const{enabled:e}=s,n=Ve(r=>r.nativeNotificationsEnabled),o=l.useRef(null);l.useEffect(()=>{if(!e||!n||!gc())return;let r=!1;const i=[];return $e(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([126,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 u=await a.addListener("registration",d=>{o.current=d.value,nn()?.push?.registerApnsToken?.({token:d.value,platform:Vn(),environment:hc()})}),f=await a.addListener("registrationError",d=>{console.warn("[Push] APNs registration error:",d)});if(await a.register().catch(()=>{}),r){u.remove(),f.remove();return}i.push(()=>{u.remove()},()=>{f.remove()})}).catch(()=>{}),()=>{r=!0,i.forEach(a=>a())}},[e,n]),l.useEffect(()=>{if(n)return;const r=o.current;if(!r)return;o.current=null,nn()?.push?.unregisterApnsToken?.({token:r})},[n])},Fn=s=>{const e=de.c(12),{side:n,isResizing:o,ariaLabel:r,handleProps:i}=s,a=n==="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 u=n==="left"?"right-0":"left-0",f=o&&"bg-[var(--interactive-border)]";let d;e[2]!==u||e[3]!==f?(d=Z("absolute inset-y-0 w-[3px] transition-colors",u,f),e[2]=u,e[3]=f,e[4]=d):d=e[4];let m;e[5]!==d?(m=t.jsx("div",{className:d}),e[5]=d,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},xc=320,yc=380,Wn=280,vc=560,wc=900;function Un(s,e,n,o){const r=de.c(23),i=o===void 0?vc:o,a=l.useRef(null);let c;r[0]!==n||r[1]!==i||r[2]!==e?(c=()=>{if(typeof window>"u")return n;const k=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(k)?Math.min(i,Math.max(Wn,k)):n},r[0]=n,r[1]=i,r[2]=e,r[3]=c):c=r[3];const[u,f]=l.useState(c),[d,m]=l.useState(!1),g=l.useRef(0),b=l.useRef(u),v=l.useRef(null),E=l.useRef(null);let x;r[4]!==i?(x=k=>Math.min(i,Math.max(Wn,Math.round(k))),r[4]=i,r[5]=x):x=r[5];const A=x;let C;r[6]===Symbol.for("react.memo_cache_sentinel")?(C=k=>{const $=a.current;$&&($.style.width=`${k}px`,$.style.minWidth=`${k}px`,$.style.maxWidth=`${k}px`,$.style.setProperty("--oc-ipad-sidebar-width",`${k}px`))},r[6]=C):C=r[6];const P=C;let I;r[7]!==u?(I=k=>{try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}E.current=k.pointerId,g.current=k.clientX,b.current=u,v.current=u,m(!0),k.preventDefault()},r[7]=u,r[8]=I):I=r[8];const _=I;let D;r[9]!==A||r[10]!==s?(D=k=>{if(E.current!==k.pointerId)return;const $=k.clientX-g.current,O=A(b.current+(s==="left"?$:-$));v.current!==O&&(v.current=O,P(O))},r[9]=A,r[10]=s,r[11]=D):D=r[11];const j=D;let R;r[12]!==A||r[13]!==e?(R=k=>{if(E.current!==k.pointerId)return;try{k.currentTarget.releasePointerCapture(k.pointerId)}catch{}const $=A(v.current??b.current);E.current=null,v.current=null,m(!1),f($);try{window.localStorage.setItem(e,String($))}catch{}},r[12]=A,r[13]=e,r[14]=R):R=r[14];const y=R;let w;r[15]!==_||r[16]!==y||r[17]!==j?(w={onPointerDown:_,onPointerMove:j,onPointerUp:y,onPointerCancel:y},r[15]=_,r[16]=y,r[17]=j,r[18]=w):w=r[18];const T=w;let S;return r[19]!==T||r[20]!==d||r[21]!==u?(S={asideRef:a,width:u,isResizing:d,handleProps:T},r[19]=T,r[20]=d,r[21]=u,r[22]=S):S=r[22],S}const jc=["general","appearance","chat","notifications","sessions","git","magic-prompts","behavior","mcp","providers","usage","voice","about"],kc=1e3,Sc=({onActiveConnectionDeleted:s})=>{const{t:e}=ue(),[n,o]=l.useState(!1),[r,i]=l.useState(null),[a,c]=l.useState(!1),[u,f]=l.useState("changes"),[d,m]=l.useState(null),[g,b]=l.useState("nav"),[v,E]=l.useState(null),x=Ve(G=>G.setSettingsPage),A=Ve(G=>G.wideChatLayoutEnabled),C=lt(G=>G.available),P=lt(G=>G.runtimeType),I=l.useMemo(()=>It(),[]),_=Bt(G=>G.mcpServers),D=Bt(G=>G.setMcpDraft),j=Bt(G=>G.setSelectedMcp),R=l.useCallback(()=>{i(null),m(null)},[]),y=l.useCallback(G=>{i(G)},[]),w=l.useCallback(()=>{c(!1)},[]),T=l.useCallback(G=>{b(G),y("settings")},[y]),{enabled:S,roomyForPanels:k}=ys(),O=ri()==="portrait",h=oi(),[N,L]=l.useState(()=>ii().roomyForPanels),Y=l.useCallback(()=>{L(G=>!G)},[]);l.useEffect(()=>{S||L(!1)},[S]);const J=l.useCallback(()=>{E(null),f("files"),c(!0)},[]),te=l.useCallback((G=null)=>{E(G),f("changes"),c(!0)},[]),q=Un("left","openchamber.ipad.leftSidebarWidth",xc),M=Un("right","openchamber.ipad.rightSidebarWidth",yc,wc),X=k,K=X&&a?M.width:0,V=S&&N?q.width:0;l.useEffect(()=>{if(typeof document>"u")return;const G=document.documentElement;return G.style.setProperty("--oc-chat-inset-left",`${V}px`),G.style.setProperty("--oc-chat-inset-right",`${K}px`),()=>{G.style.removeProperty("--oc-chat-inset-left"),G.style.removeProperty("--oc-chat-inset-right")}},[V,K]),l.useEffect(()=>{if(typeof document>"u")return;const G=document.documentElement;return G.classList.toggle("wide-chat-layout",A),()=>G.classList.remove("wide-chat-layout")},[A]),l.useEffect(()=>{if(typeof document>"u")return;const G=S&&(O||h),pe=document.documentElement;return pe.classList.toggle("oc-keep-draft-starters",G),()=>pe.classList.remove("oc-keep-draft-starters")},[h,S,O]);const F=l.useMemo(()=>({openChanges:({diffPath:G,staged:pe}={})=>{te(G?{path:G,staged:pe===!0}:null)},openFiles:()=>J(),openSettings:()=>T("nav")}),[te,J,T]),Q=l.useMemo(()=>({openSessions:()=>{S?L(!0):o(!0)},openView:G=>{if(G==="files"){J();return}if(G==="mcp"){f("mcp"),c(!0);return}y(G)},openChanges:({path:G,staged:pe}={})=>{te(G?{path:G,staged:pe===!0}:null)},openSettings:G=>{G&&x(G),T(G?"page-content":"nav")}}),[S,te,J,T,y,x]);lc(Q);const ee=l.useRef(null);pc(ee,{onLeftEdgeSwipe:()=>{S?L(!0):o(!0)},onRightEdgeSwipe:()=>c(!0)});const B=l.useCallback(()=>d?(m(null),!0):r?(R(),!0):a?(w(),!0):n?(o(!1),!0):!1,[r,R,w,d,n,a]);Jl(B);const oe=!I&&C&&(P==="desktop"||P==="web"),ie=S?"dialog":"fullscreen",me=l.useMemo(()=>({instanceLabel:I?vt():null,onOpenInstances:I?()=>y("instances"):void 0,onOpenSettings:()=>T("nav"),onOpenUpdate:oe?()=>y("update"):void 0}),[T,y,I,oe]),we=l.useCallback(()=>{const G="new-mcp-server";let pe=G,Re=1;for(;_.some(Te=>Te.name===pe);)pe=`${G}-${Re}`,Re+=1;D({name:pe,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",timeout:"",enabled:!0}),j(pe),x("mcp"),T("page-content")},[_,T,D,j,x]);return t.jsx(ai,{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:[S?t.jsxs("aside",{ref:q.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",!N&&"border-r-0"),style:{width:N?q.width:0,minWidth:N?q.width:0,maxWidth:N?q.width:0,"--oc-ipad-sidebar-width":`${q.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:q.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!N,"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",q.isResizing&&"pointer-events-none",!N&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Oe,{children:t.jsx(_n,{open:!0,variant:"sidebar",onOpenChange:G=>{!G&&!k&&L(!1)},footer:me})})}),N?t.jsx(Fn,{side:"left",isResizing:q.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:q.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(sl,{onOpenSessions:()=>S?Y():o(!0),onOpenWorkspace:()=>c(!0),compactTitle:S}),t.jsx("main",{ref:ee,className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:t.jsx("div",{className:"h-full w-full",children:t.jsx(Oe,{children:t.jsx(_i,{})})})})]}),S?null:t.jsx(_n,{open:n,onOpenChange:o,footer:me}),S?t.jsxs("aside",{ref:M.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",!K&&"border-l-0"),style:{width:K,minWidth:K,maxWidth:K,"--oc-ipad-sidebar-width":`${M.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:M.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!K,"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",M.isResizing&&"pointer-events-none",!K&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Oe,{children:t.jsx(Bn,{open:a,onClose:w,tab:u,onTabChange:f,pendingChangesDiff:v,onOpenPlan:m,onOpenMcpSettings:we,variant:X?"panel":"drawer"})})}),K?t.jsx(Fn,{side:"right",isResizing:M.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:M.handleProps}):null]}):t.jsx(Bn,{open:a,onClose:w,tab:u,onTabChange:f,pendingChangesDiff:v,onOpenPlan:m,onOpenMcpSettings:we}),d?t.jsx(kt,{open:!0,variant:ie,onClose:()=>m(null),ariaLabel:d.title,title:d.title,children:t.jsx(Oe,{children:t.jsx(Li,{targetPath:d.path,onNavigatedToChat:()=>{R(),w()}})})}):null,r==="instances"&&I?t.jsx(kt,{open:!0,variant:ie,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(il,{onConnect:R,onActiveConnectionDeleted:s})}):null,r==="settings"?t.jsx(kt,{open:!0,variant:ie,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Oe,{children:t.jsx(Di,{forceMobile:!0,isWindowed:!0,initialMobileStage:g,visiblePageSlugs:jc.filter(G=>!(I&&G==="about")),onClose:R})})}):null,r==="update"?t.jsx(kt,{open:!0,variant:ie,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Oe,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(Mi,{initialUpdateDialogOpen:!0})})})}):null]})})};function Nc({apis:s}){const{t:e}=ue(),n=Le(M=>M.initializeApp),o=Le(M=>M.isInitialized),r=Le(M=>M.isConnected),i=Le(M=>M.connectionPhase),a=Le(M=>M.providers.length),c=Le(M=>M.agents.length),u=Le(M=>M.loadProviders),f=Le(M=>M.loadAgents),d=ut(M=>M.currentDirectory),m=ve(M=>M.error),g=ve(M=>M.clearError),b=Ve(M=>M.setIsMobile),v=Vo(M=>M.refreshStatus),E=Ho(M=>M.setPlanModeEnabled),x=ze(M=>M.projects),[A,C]=l.useState(0),[P,I]=l.useState(0),[_,D]=l.useState(!1),[j,R]=l.useState("pending"),[y,w]=l.useState(null),T=l.useMemo(()=>vt(),[]),[,S]=l.useReducer(M=>M+1,0),k=l.useMemo(()=>It(),[]),$=l.useRef(0),O=l.useRef(0),h=l.useCallback(()=>{const M=Ge(),X=O.current+1;if(O.current=X,!M){ts();return}const K=()=>{n(),v(s.github,{force:!0}),a===0&&u({source:"mobileApp:nativeResume"}),c===0&&f({source:"mobileApp:nativeResume"})},V=()=>{at({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),C(Q=>Q+1)};Ft().then(Q=>{if(O.current===X){if(Q==="no-connection"){V();return}if(Q==="needs-login"){w({kind:"auth-expired",label:vt()??""}),V();return}if(Q==="unreachable"){window.setTimeout(()=>{O.current===X&&Ft().then(ee=>{if(O.current===X&&ee!=="switched"){if(ee==="unchanged"){K();return}ee==="needs-login"&&w({kind:"auth-expired",label:vt()??""}),V()}})},4e3);return}Q!=="switched"&&K()}});const F=Date.now();F-$.current>=kc&&($.current=F,window.dispatchEvent(new Event("openchamber:system-resume")))},[c,s.github,n,f,u,a,v]);Kl(),ql(h),l.useEffect(()=>{if(!k)return;let M;const X=()=>{window.clearTimeout(M),M=window.setTimeout(()=>h(),1500)};return window.addEventListener("online",X),()=>{window.removeEventListener("online",X),window.clearTimeout(M)}},[k,h]),l.useEffect(()=>(rn(s),()=>rn(null)),[s]),l.useEffect(()=>to(M=>{if(!!M.runtimeKey&&M.runtimeKey===M.previousRuntimeKey){Ei(),S();return}Ci(M),I(K=>K+1),C(K=>K+1)}),[]),l.useEffect(()=>{if(!k||r||Ge()){R("done");return}let M=!1;return R("attempting"),ts().catch(()=>({status:"no-candidate"})).then(X=>{M||(X.status==="unreachable"?w({kind:"unreachable",label:X.label}):X.status==="needs-login"&&w({kind:"auth-expired",label:X.label}),R("done"))}),()=>{M=!0}},[]),l.useEffect(()=>{if(!k||!Ge())return;let M=!1;const X=K=>{K&&w(K),at({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),C(V=>V+1)};return Ft().then(async K=>{if(M||K==="switched"||K==="unchanged")return;const V=vt();if(K==="needs-login"){X({kind:"auth-expired",label:V??""});return}if(K==="unreachable"){X(V?{kind:"unreachable",label:V}:null);return}const F=await ts().catch(()=>({status:"no-candidate"}));M||F.status==="connected"||(F.status==="needs-login"?X({kind:"auth-expired",label:F.label}):F.status==="unreachable"?X({kind:"unreachable",label:F.label}):X(null))}),()=>{M=!0}},[]),l.useEffect(()=>{b(!0)},[b]),l.useEffect(()=>{k&&!Ge()||n()},[A,n,k]),l.useEffect(()=>{r&&(a===0&&u({source:"mobileApp:recovery"}),c===0&&f({source:"mobileApp:recovery"}))},[c,r,f,u,a]);const N=l.useRef(!1),[L,Y]=l.useState(k);l.useEffect(()=>{if(!k||!r||N.current)return;if(ve.getState().currentSessionId){N.current=!0,Y(!1);return}const M=Tt(),X=Go(M);if(!X){N.current=!0,Y(!1);return}let K=!1;const V=window.setTimeout(()=>Y(!1),6e3);return(async()=>{const F=await vs().catch(()=>null);if(K)return;if(!F){Y(!1);return}N.current=!0;const Q=F.activeSessions.find(B=>B.id===X.sessionId);if(!Q){Ko(M),Y(!1);return}const ee=ve.getState();ee.currentSessionId||ee.setCurrentSession(Q.id,xs(Q)??X.directory??void 0),Y(!1)})(),()=>{K=!0,window.clearTimeout(V)}},[A,r,k]),l.useEffect(()=>{r&&on.setDirectory(d)},[d,r]),l.useEffect(()=>{r&&v(s.github,{force:!0})},[s.github,r,v]),l.useEffect(()=>{if(!r||x.length===0)return;let M=!1;return(async()=>{const K=new Map(ve.getState().availableWorktreesByProject);if(await Promise.all(x.map(async Q=>{const ee=Q.path.replace(/\\/g,"/").replace(/\/+$/,"");if(ee)try{if(!(Ue.getState().directories.get(ee)?.isGitRepo??await $e(()=>import("./useAppFontEffects-Bbpz77To.js").then(me=>me.hx),__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(me=>me.checkIsGitRepository(ee))))return;const ie=await sr({id:Q.id,path:ee});if(M)return;K.set(ee,ie)}catch{}})),M)return;const V=nr(x,K),F=ve.getState().availableWorktreesByProject;ni(V,F)||ve.setState({availableWorktrees:[...V.values()].flat(),availableWorktreesByProject:V})})(),()=>{M=!0}},[r,x]),l.useEffect(()=>{let M=!1;return(async()=>{const K=await gs("/health",{method:"GET"}).catch(()=>null);if(!K||!K.ok||M)return;const V=await K.json().catch(()=>null);if(!V||M)return;const F=V.planModeExperimentalEnabled;E(F===!0||F===1||F==="1"||F==="true")})(),()=>{M=!0}},[E]),l.useEffect(()=>{if(!m)return;const M=window.setTimeout(()=>g(),5e3);return()=>window.clearTimeout(M)},[g,m]),l.useEffect(()=>{if(!(!r&&(k?!!Ge():!0))){D(!1);return}const X=window.setTimeout(()=>{D(!0)},k?4e3:8e3);return()=>window.clearTimeout(X)},[r,k,A,P]),qo(),Jo({enabled:!0}),Ri(),Yo(),Pi(),bc({enabled:k&&r}),cc({ready:k&&r&&o});const J=Yl(),te=!r&&i==="reconnecting";if(!J)return t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(Je,{width:120,height:120,isAnimated:!0})});const q=!!Ge();return k&&(!q||!r&&!te)?q?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(Je,{width:120,height:120,isAnimated:!_}),_?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"}),C(M=>M+1)},children:e("mobile.connect.cancelPassword")})]}):null]})}):j!=="done"?t.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-background text-foreground",children:[t.jsx(Je,{width:120,height:120,isAnimated:!0}),T?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:[T,t.jsx(Xo,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(Fa,{onConnected:()=>C(M=>M+1),notice:y})}):!r&&!te?_?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(Je,{width:120,height:120,isAnimated:!0})}):t.jsx(Oe,{children:t.jsx(Qo,{sdk:on.getSdkClient(),directory:d||"",children:t.jsx(Zo,{apis:s,children:t.jsx(ei,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[k&&L?t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background",children:t.jsx(Je,{width:120,height:120,isAnimated:!0})}):null,t.jsx(ti,{embeddedBackgroundWorkEnabled:o}),t.jsx(Ti,{}),t.jsx(oa,{}),t.jsx(Sc,{onActiveConnectionDeleted:()=>{at({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),C(M=>M+1)}}),t.jsx(si,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),o?t.jsx(Ii,{}):null]})})})},P)})}const Ec=()=>{pi(),so().then(()=>{Promise.all([no(),hi()]).catch(s=>{console.error("[mobile-main] settings init failed:",s)}),gi(),bi(),xi()}).catch(s=>{console.error("[mobile-main] appearance init failed:",s)}).finally(()=>{Xi()})};function qu(s){window.__OPENCHAMBER_SURFACE__="mobile",li(),Ec(),ra(),ci();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?{...s,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:s,i=t.jsx(Nc,{apis:r});Yr.createRoot(e).render(t.jsx(ls.StrictMode,{children:t.jsx(di,{children:t.jsx(ui,{children:t.jsx(fi,{children:t.jsx(Ai,{children:o?i:t.jsx(mi,{children:i})})})})})}))}export{qu as renderMobileApp};