@openchamber/web 1.20.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CodeMirrorCommentWidgets-C36E738Y.js → CodeMirrorCommentWidgets-C2BopIs3.js} +1 -1
- package/dist/assets/CommitSection-HJeMUAWb.js +1 -0
- package/dist/assets/DiffView-D5cvbEPb.js +4 -0
- package/dist/assets/FilesView-DPU8aNPL.js +17 -0
- package/dist/assets/GitView-Ct6xWrVH.js +6 -0
- package/dist/assets/{JsonTreeView-KnXFN2A-.js → JsonTreeView-osju7J70.js} +1 -1
- package/dist/assets/MarkdownImageGallery-EujHSZ2M.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CPzu4kIr.js +12 -0
- package/dist/assets/OnboardingScreen-w2VG4fWY.js +1 -0
- package/dist/assets/{PatchDiff-BzVOVog8.js → PatchDiff-Dan3mADn.js} +1 -1
- package/dist/assets/PierreDiffViewer-CGoI2v0q.js +157 -0
- package/dist/assets/PlanView-Dgg-WTEc.js +4 -0
- package/dist/assets/SessionSwitcherDropdown-CJTrc8K7.js +1 -0
- package/dist/assets/SettingsView-D9yRuFZw.js +28 -0
- package/dist/assets/SettingsWindow-DXF-MTHG.js +1 -0
- package/dist/assets/{ToolOutputDialog-BB1c--Zr.js → ToolOutputDialog-DrCa1JRk.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-DaOIDISD.js → ToolPartDiffPreview-B_tfvlNF.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-lESMT-2b.js → VirtualizedFileDiff-CN_BctrR.js} +4 -4
- package/dist/assets/{Virtualizer-X_7XPoTH.js → Virtualizer-CZlLSacm.js} +1 -1
- package/dist/assets/Virtualizer-D_a8gKmg.js +1 -0
- package/dist/assets/{WalkthroughView-CaSYE0lw.js → WalkthroughView-D9Q4lr5x.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-DkRR5b75.js → computeVirtualFileMetrics-Gi1d5eU1.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-CpzVNWAv.js +1 -0
- package/dist/assets/de-B_LdJwEM.js +9 -0
- package/dist/assets/es-CubfsAYV.js +15 -0
- package/dist/assets/fr-5qJM0nFS.js +13 -0
- package/dist/assets/index-BW82eK5v.css +1 -0
- package/dist/assets/index-Brm3X9rs.js +1 -0
- package/dist/assets/index-rlLjZUM5.js +7 -0
- package/dist/assets/{isDiffPlainText-BG53Ixxy.js → isDiffPlainText-pH9kAJQH.js} +1 -1
- package/dist/assets/{isFilePlainText-BbV-39jl.js → isFilePlainText-CVKy_dgB.js} +1 -1
- package/dist/assets/ja-DJYIBUlH.js +15 -0
- package/dist/assets/ko-DcUBkB7y.js +15 -0
- package/dist/assets/main-DLBxKIoX.js +926 -0
- package/dist/assets/main-vUCh0VB0.js +2 -0
- package/dist/assets/markdownCore-DG6GHLF4.js +3 -0
- package/dist/assets/{miniChat-ldEghBLB.js → miniChat-BlzGEYgE.js} +2 -2
- package/dist/assets/mobile-CkX6H-IT.js +2 -0
- package/dist/assets/{patchFileDiff-BcFaMtMu.js → patchFileDiff-BCTsE43U.js} +3 -3
- package/dist/assets/pl-rB6BLcio.js +15 -0
- package/dist/assets/pt-BR-DcwtlO-o.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-CJYe_KOL.js +2 -0
- package/dist/assets/renderMobileApp-hQJTnr8B.js +25 -0
- package/dist/assets/runtimeEndpointReset-BDh7r8BL.js +15 -0
- package/dist/assets/scheduledTasksApi-CAGPh_gZ.js +1 -0
- package/dist/assets/{shikiHighlight-DCT2Sq_z.js → shikiHighlight-BgTPSITe.js} +1 -1
- package/dist/assets/uk-INZlFD9A.js +15 -0
- package/dist/assets/{useAppFontEffects-B53Rb6m7.js → useAppFontEffects-Cll4gnsh.js} +170 -180
- package/dist/assets/useInlineCommentController-DFFv0hae.js +2 -0
- package/dist/assets/{vendor-base-ui-DsHmyMwp.js → vendor-base-ui-_6j2xOWl.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-vch3tJ4c.js → vendor-codemirror-language-data-DkQX2EBa.js} +2 -2
- package/dist/assets/{vendor-framer-motion-CRSgBxjL.js → vendor-framer-motion-livSKyyV.js} +1 -1
- package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +1 -0
- package/dist/assets/{vendor-motion-dom-DJLgZh4Q.js → vendor-motion-dom-D_o3BTI3.js} +1 -1
- package/dist/assets/vendor-zod-BLfBSgBh.js +39 -0
- package/dist/assets/{web-components-pcwCTWjC.js → web-components-DLnGY4fs.js} +4 -4
- package/dist/assets/zh-CN-Dzda8xa1.js +15 -0
- package/dist/assets/zh-TW-Cwn3rNYZ.js +15 -0
- package/dist/index.html +6 -6
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +4 -4
- package/server/index.js +8 -0
- package/server/lib/client-auth/pairing.js +8 -7
- package/server/lib/client-auth/pairing.test.js +5 -1
- package/server/lib/client-auth/remote-clients.js +9 -1
- package/server/lib/client-auth/remote-clients.test.js +17 -0
- package/server/lib/github/pr-status.js +10 -1
- package/server/lib/quota/providers/index.js +4 -18
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/service.js +34 -2
- package/server/lib/relay/service.test.js +69 -0
- package/server/lib/session-goal/runtime.js +2 -1
- package/server/lib/session-goal/runtime.test.js +4 -2
- package/server/lib/terminal/DOCUMENTATION.md +2 -0
- package/server/lib/terminal/runtime.js +29 -1
- package/server/lib/terminal/runtime.test.js +26 -0
- package/server/lib/ui-auth/ui-auth.js +2 -2
- package/server/lib/ui-auth/ui-auth.test.js +2 -2
- package/dist/assets/CommitSection-C-F3AX6D.js +0 -1
- package/dist/assets/DiagramEditor-BPECg1jS.js +0 -1
- package/dist/assets/DiagramView-D0YNMix8.js +0 -1
- package/dist/assets/DiffView-BHWaMYCC.js +0 -4
- package/dist/assets/FilesView-NMBCW2Tm.js +0 -14
- package/dist/assets/GitView-Rp8P1KEI.js +0 -6
- package/dist/assets/MarkdownImageGallery-BMn3mtor.js +0 -1
- package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +0 -12
- package/dist/assets/OnboardingScreen-CenIeD4v.js +0 -1
- package/dist/assets/PierreDiffViewer-Dlby4XqT.js +0 -136
- package/dist/assets/PlanView-Czu1KMJa.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +0 -1
- package/dist/assets/SettingsView-B6vmuf-c.js +0 -28
- package/dist/assets/SettingsWindow-CauZpdD3.js +0 -1
- package/dist/assets/contextPanelEmbeddedChat-BEARQjgn.js +0 -1
- package/dist/assets/de-DFdX3ABv.js +0 -9
- package/dist/assets/es-iC-FKvV9.js +0 -15
- package/dist/assets/fr-BBbi_1AL.js +0 -13
- package/dist/assets/index-BiEgzzkg.js +0 -1
- package/dist/assets/index-Cwmuwk3V.js +0 -7
- package/dist/assets/index-GNm1wgUH.css +0 -1
- package/dist/assets/ja-DQLQJL2J.js +0 -15
- package/dist/assets/ko-BeElEB4Y.js +0 -15
- package/dist/assets/main-Dpzo18z7.js +0 -2
- package/dist/assets/main-WMjtYzJs.js +0 -921
- package/dist/assets/markdownCore--tDmyI_v.js +0 -2
- package/dist/assets/mobile-Dk-VGreF.js +0 -2
- package/dist/assets/pl-CLHt2_vV.js +0 -15
- package/dist/assets/pt-BR-C_MPUq7e.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +0 -2
- package/dist/assets/renderMobileApp-CDfHS5rr.js +0 -25
- package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +0 -15
- package/dist/assets/scheduledTasksApi-BFSlqgnG.js +0 -1
- package/dist/assets/uk-PhsC-c4-.js +0 -15
- package/dist/assets/useInlineCommentController-DSfrIBKT.js +0 -2
- package/dist/assets/vendor-zod-C9ioTTSo.js +0 -39
- package/dist/assets/zh-CN-wF-NOFHM.js +0 -15
- package/dist/assets/zh-TW-4m4-A7rT.js +0 -15
- package/server/lib/quota/providers/command-code.js +0 -90
- package/server/lib/quota/providers/command-code.test.js +0 -85
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-DPU8aNPL.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-rlLjZUM5.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-zod-BLfBSgBh.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-BW82eK5v.css","assets/useAppFontEffects-Cll4gnsh.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-_6j2xOWl.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-DKpLs02S.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/contextPanelEmbeddedChat-CpzVNWAv.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-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-DkQX2EBa.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-gg7YLRW7.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-BDh7r8BL.js","assets/shikiHighlight-BgTPSITe.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-osju7J70.js","assets/web-components-DLnGY4fs.js","assets/computeVirtualFileMetrics-Gi1d5eU1.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-CZlLSacm.js","assets/isFilePlainText-CVKy_dgB.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/Virtualizer-D_a8gKmg.js","assets/scheduledTasksApi-CAGPh_gZ.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/useInlineCommentController-DFFv0hae.js","assets/CodeMirrorCommentWidgets-C2BopIs3.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as de,r as cs,j as t,R as l,c as mt,h as ao}from"./vendor-react-BUCujlKS.js";import{u as Ve,a as yt,b as qn,d as rn,i as Te,e as Ue,s as lt,f as Dt,r as bs,h as lo,j as Yn,k as co,p as uo,l as fo,m as Xe,n as mo,o as on,q as an,t as ln,v as po,w as cn,x as ho,y as go}from"./index-rlLjZUM5.js";import{u as xs,a as bo,b as Oe,c as Jn,d as Xn,r as ys,e as xo,f as me,t as ue,o as yo,I as se,B as xe,g as vo,O as qe,h as J,P as wo,i as jo,j as ko,k as So,l as ze,m as No,n as rt,p as Co,q as un,s as Eo,v as vs,w as Ro,x as Po,y as je,z as To,A as Qn,C as Zn,D as er,E as Ao,F as ws,G as Io,H as tr,J as _o,K as Do,M as Mo,L as sr,N as nr,Q as rr,R as or,S as js,T as zo,U as Oo,V as ks,W as Lo,X as Bo,Y as dn,Z as ir,_ as $o,$ as Ss,a0 as ar,a1 as lr,a2 as Ct,a3 as dt,a4 as Fo,a5 as Wo,a6 as Uo,a7 as Vo,a8 as Go,a9 as Ns,aa as Ko,ab as Ho,ac as qo,ad as We,ae as Yo,af as Jo,ag as Xo,ah as Qo,ai as Zo,aj as ei,ak as ti,al as Le,am as si,an as ni,ao as ri,ap as oi,aq as ii,ar as ai,as as cr,at as li,au as ci,av as ui,aw as di,ax as fi,ay as mi,az as pi,aA as hi,aB as gi,aC as bi,aD as xi,aE as yi,aF as vi,aG as wi,aH as ji,aI as ki,aJ as Si,aK as Ni,aL as Ci,aM as Ei,aN as Ri,aO as Pi,aP as Ti,aQ as Ai,aR as Ii,aS as _i,aT as Di,aU as Mi,aV as zi,aW as Oi,aX as Li}from"./useAppFontEffects-Cll4gnsh.js";import{u as ct,S as ur,D as Bi,N as $i,a as Fi,b as Wi,T as Ui,P as Vi,r as Gi,c as Ki,d as Hi,e as qi,O as Yi,C as Ji,f as Xi,g as Qi}from"./runtimeEndpointReset-BDh7r8BL.js";import{_ as pt}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as Zi,A as ea}from"./SettingsView-D9yRuFZw.js";import{PlanView as ta}from"./PlanView-Dgg-WTEc.js";import{p as sa}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as na}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as us,s as dr,M as Cs,a as Kt,J as ds,p as ra,_ as fn,b as fr,P as mr,d as oa,f as Es,V as ia,K as mn,c as aa,Q as la,r as ca,U as ua,Z as da}from"./vendor-remixicon-react-Dil0zKKT.js";import{f as Rs,h as ht,i as Ps,P as Ts,D as As,j as Is}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as _s,S as Ds,v as Ms,u as zs}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Os}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as Ls,p as pr}from"./vendor-zustand-BAGL70zf.js";import{toast as pn}from"./vendor-sonner-DFyL3AvE.js";import{C as fa,a as ma}from"./CommitSection-HJeMUAWb.js";import{P as pa}from"./PierreDiffViewer-CGoI2v0q.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-BLfBSgBh.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-_6j2xOWl.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-CpzVNWAv.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DkQX2EBa.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-BgTPSITe.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./useInlineCommentController-DFFv0hae.js";import"./CodeMirrorCommentWidgets-C2BopIs3.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./web-components-DLnGY4fs.js";import"./computeVirtualFileMetrics-Gi1d5eU1.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-CN_BctrR.js";import"./isDiffPlainText-pH9kAJQH.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";let hr=null,hn=!1;const ha=new Promise(n=>{hr=n});function ga(){hn||(hn=!0,hr?.())}const ba=6,xa=n=>n.parentID??null,gn=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},ya=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),va=(n,e)=>{if(!n)return"";let s=null,o=-1;for(const r of e){const i=ya(r.path);(n===i||n.startsWith(`${i}/`))&&i.length>o&&(s=r,o=i.length)}return s?s.label?.trim()||gn(s.path):gn(n)},wa=()=>{const n=xs.getState().activeSessions,e=bo.getState().index.session.unseenCount,s=Ve.getState().notifyOnSubtasks,o=Oe.getState().projects,r=Jn.getState().ids,i=Xn.getState().rankById;let a=0;const c=[];for(const f of n){const d=xa(f)!==null,g=(e[f.id]??0)>0&&(!d||s);g&&(a+=1),d||c.push({session:f,unread:g,project:va(ys(f),o)})}c.sort((f,d)=>xo(f.session,d.session,r,i));const u=c.slice(0,ba).map(({session:f,unread:d,project:m})=>({id:f.id,title:f.title??"",unread:d,project:m}));return{runtimeKey:yt(),attentionCount:a,recentSessions:u}},ja="__OPENCHAMBER_WIDGET_SNAPSHOT__",ka=()=>{typeof window>"u"||(window[ja]=()=>{try{return JSON.stringify(wa())}catch{return null}})},ss="mobile-app-update-available",bn="mobile-app-update-toast-dismissed-version",Sa=()=>{const n=de.c(8),{t:e}=me(),s=ct(Na),o=ct(Ca),r=ct(Ea),i=ct(Ra);let a;n[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,n[0]=a):a=n[0];const c=cs.useRef(a);let u,f;return n[1]!==s||n[2]!==i||n[3]!==o||n[4]!==e||n[5]!==r?(u=()=>{if(qn()!=="android"||o!=="mobile"||!s||!r||!i){ue.dismiss(ss);return}rn().getItem(bn)!==r&&(c.current.has(r)||(c.current.add(r),ue.info(e("mobileUpdate.toast.available.title"),{id:ss,description:e("mobileUpdate.toast.available.description",{version:r}),duration:1/0,icon:t.jsx(se,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{yo(i)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{rn().setItem(bn,r),ue.dismiss(ss)}}})))},f=[s,i,o,e,r],n[1]=s,n[2]=i,n[3]=o,n[4]=e,n[5]=r,n[6]=u,n[7]=f):(u=n[6],f=n[7]),cs.useEffect(u,f),null};function Na(n){return n.available}function Ca(n){return n.runtimeType}function Ea(n){return n.info?.version}function Ra(n){return n.info?.downloadUrl}const xn=300,Pa="openchamber.mobile.connectLog.v1",ut=[];if(typeof window<"u")try{window.localStorage.removeItem(Pa)}catch{}const Bs=(n,e)=>{ut.push({at:Date.now(),step:n,detail:e}),ut.length>xn&&ut.splice(0,ut.length-xn)};typeof window<"u"&&Bs("app:launch","{}");const Ta=()=>[...ut],Aa=n=>{const e=new Date(n),s=(o,r=2)=>String(o).padStart(r,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},gr=n=>`${Aa(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,Ia=()=>ut.map(gr).join(`
|
|
3
|
+
`),br=(n,e)=>{const s=de.c(10),o=700,r=l.useRef(null),i=l.useRef(null),a=l.useRef(!1);let c;s[0]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{r.current!==null&&window.clearTimeout(r.current),r.current=null,i.current=null},s[0]=c):c=s[0];const u=c;let f,d;s[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>u,d=[u],s[1]=f,s[2]=d):(f=s[1],d=s[2]),l.useEffect(f,d);let m;s[3]!==o||s[4]!==n?(m=S=>{a.current=!1,i.current={x:S.clientX,y:S.clientY},r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,a.current=!0,n()},o)},s[3]=o,s[4]=n,s[5]=m):m=s[5];const g=m;let h;s[6]===Symbol.for("react.memo_cache_sentinel")?(h=S=>{const E=i.current;E&&(Math.abs(S.clientX-E.x)>10||Math.abs(S.clientY-E.y)>10)&&u()},s[6]=h):h=s[6];const x=h;let j;s[7]===Symbol.for("react.memo_cache_sentinel")?(j=S=>{a.current&&(a.current=!1,S.preventDefault(),S.stopPropagation())},s[7]=j):j=s[7];const b=j;let I;return s[8]!==g?(I={onPointerDown:g,onPointerMove:x,onPointerUp:u,onPointerCancel:u,onClickCapture:b},s[8]=g,s[9]=I):I=s[9],I},Ht="openchamber.mobile.connections.v1",_a="openchamber.mobile.",yn="openchamber.mobile.deviceId",Da=()=>{try{const n=window.localStorage.getItem(yn);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem(yn,e),e}catch{return crypto.randomUUID()}},vn=()=>`mobile:${Da()}`,wn=()=>{try{const n=na.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},xr=12,yr=8e3,Ma=2500,za=3e3,qt=2500,Oa=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},vt=n=>{const e=n.trim();if(!e)return"";const s=/^https?:\/\//i.test(e)?e:`http://${e}`,o=new URL(s);return o.hash="",o.search="",o.pathname=o.pathname.replace(/\/+$/,""),o.toString().replace(/\/+$/,"")},Ut=n=>{try{return new URL(n).host}catch{return n}},gt=n=>{try{return vt(n)}catch{return n.trim().replace(/\/+$/g,"")}},vr=(n,e)=>gt(n)===gt(e),wr=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,La=n=>`relay://${n.serverId}`,Qt=n=>n.candidates.filter(e=>e.kind==="direct"),Qe=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},Ge=n=>{const e=Qt(n)[0];if(e)return e.url;const s=Qe(n);return s?La(s):""},Re=n=>{const e=Qe(n);if(e)return wr(e);const s=Qt(n)[0];return s?gt(s.url):""},Yt=(n,e)=>{const s=n.find(i=>i.kind==="relay"),o=s&&s.kind==="relay"?s.relay.serverId:null,r=new Set(n.filter(i=>i.kind==="direct").map(i=>gt(i.url)));return e.some(i=>i.kind==="relay"?o!==null&&i.relay.serverId===o:r.has(gt(i.url)))},$s=n=>{const e=(()=>{try{return vt(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},jn=n=>{if(n.candidates&&n.candidates.length>0)return n.candidates;const e=[];return typeof n.url=="string"&&n.url.trim()&&!/^relay:\/\//i.test(n.url.trim())&&e.push(...$s(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},Fs=n=>{if(!n||typeof n!="object"||Array.isArray(n))return null;const e=n;if(typeof e.relayUrl!="string"||!e.relayUrl.trim()||typeof e.serverId!="string"||!e.serverId.trim())return null;const s=e.hostEncPubJwk;if(!s||typeof s!="object"||Array.isArray(s))return null;const o=s;return o.kty!=="EC"||o.crv!=="P-256"||typeof o.x!="string"||!o.x||typeof o.y!="string"||!o.y?null:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:{kty:"EC",crv:"P-256",x:o.x,y:o.y}}},jr=n=>{try{return JSON.stringify(n)}catch{return String(n)}},he=(n,e={})=>{const s=jr(e);console.info("[mobile-connect]",n,s),Bs(n,s)},kt=(n,e={})=>{he(n,e)},bt=(n,e={})=>{const s=jr(e);console.info("[mobile-storage]",n,s),Bs(n,s)},Ba=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},$a=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},Fa=async(n,e)=>{if(!Te())return null;try{const{CapacitorHttp:s}=await pt(async()=>{const{CapacitorHttp:i}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:i}},[]),o=co(n,new Headers(e?.headers)),r=await s.request({url:n,method:e?.method||"GET",headers:Object.fromEntries(o.entries()),data:$a(e?.body)});return{ok:r.status>=200&&r.status<300,status:r.status,source:"native-http",json:async()=>Ba(r.data)}}catch(s){return he("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},Wa=async(n,e)=>{const s=await fetch(n,e).catch(o=>(he("browser-fetch:failed",{url:n,error:o instanceof Error?o.message:String(o)}),null));return s?{ok:s.ok,status:s.status,source:"browser-fetch",json:()=>s.json()}:null},He=async(n,e,s)=>{let o;const r=new Promise(i=>{o=window.setTimeout(()=>{s?.(),i(null)},n)});try{return await Promise.race([e,r])}catch{return null}finally{o!==void 0&&window.clearTimeout(o)}},Ze=async(n,e,s)=>{const o=s?.totalTimeoutMs??yr,r=Date.now(),i=await He(Math.min(Ma,o),Fa(n,e));if(i)return i;const a=new AbortController,c=Math.max(500,o-(Date.now()-r));return He(c,Wa(n,{...e,signal:a.signal}),()=>a.abort())},Zt=async n=>{if(!n)return null;const e=await n.json().catch(()=>null);if(!e||typeof e!="object")return null;const s=e;return{authenticated:typeof s.authenticated=="boolean"?s.authenticated:void 0,disabled:typeof s.disabled=="boolean"?s.disabled:void 0,scope:typeof s.scope=="string"?s.scope:void 0}},xt=15e3,Ua=async(n,e,s,o=xt,r)=>{const i=Yn({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk}),a=c=>c==="ok"&&r?.keepTunnel?{outcome:c,tunnel:i}:(i.close(),{outcome:c});try{const c=e?{Authorization:`Bearer ${e}`}:void 0,u=await He(o,i.fetch("/auth/session",{headers:c}).catch(()=>null));if(he("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 Zt(u);return f&&f.disabled!==!0&&f.authenticated===!1?a(e?"auth-failed":"needs-login"):a("ok")}catch(c){throw i.close(),c}},Va=(n,e,s,o,r)=>{const i=typeof window<"u"?window.location.origin:"",a={relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk,...s?{grant:s}:{}};r&&lo(a,r),lt({apiBaseUrl:i,clientToken:e,runtimeKey:o??wr(n),relay:a})},Ga=n=>{if(!n||typeof n!="object")return null;const e=n;if(e.kind==="direct")return typeof e.url=="string"&&e.url.trim()?{kind:"direct",url:e.url}:null;if(e.kind==="relay"){const s=Fs(e.relay);return s?{kind:"relay",relay:s}:null}return null},Ka=n=>{if(n.mode==="relay"){const e=Fs(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?$s(n.url):[]},tt=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(Ht)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=Te();return n.flatMap(s=>{if(!s||typeof s!="object")return[];const o=s;if(typeof o.id!="string")return[];const r=Array.isArray(o.candidates)?o.candidates.map(Ga).filter(u=>!!u):Ka(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:Ut(Ge({candidates:r})),c={id:o.id,label:a,candidates:r,lastUsedAt:typeof o.lastUsedAt=="number"?o.lastUsedAt:0};return e?[{...c,hasToken:!!o.hasToken||!!i}]:[{...c,clientToken:i,hasToken:!!i}]}).sort((s,o)=>o.lastUsedAt-s.lastUsedAt)},fs=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},Ws=n=>{if(typeof window>"u")return;const e=Te(),s=n.slice(0,xr).map(o=>{const r={id:o.id,label:o.label,candidates:o.candidates.map(fs),lastUsedAt:o.lastUsedAt};return e?{...r,hasToken:!!(o.hasToken||o.clientToken)}:{...r,clientToken:o.clientToken}});try{window.localStorage.setItem(Ht,JSON.stringify(s))}catch(o){console.warn("[mobile-storage] failed to persist connection metadata",o)}},kr=(n,e)=>{const s=n.find(i=>e.id&&i.id===e.id||Yt(i.candidates,e.candidates)),o=Te(),r={id:e.id||s?.id||crypto.randomUUID(),label:e.label,candidates:e.candidates,lastUsedAt:Date.now(),...o?{hasToken:e.hasToken??(!!e.clientToken||s?.hasToken||!1)}:{clientToken:e.clientToken??s?.clientToken,hasToken:!!(e.clientToken??s?.clientToken)}};return[r,...n.filter(i=>i.id!==r.id&&!Yt(i.candidates,e.candidates))].slice(0,xr)},Us=sa,Ha=0,Vs=n=>`${_a}token.${encodeURIComponent(n)}`,qa=async(n,e)=>{let s;const o=new Promise(r=>{s=window.setTimeout(()=>r(e),za)});try{return await Promise.race([n.catch(()=>e),o])}finally{s!==void 0&&window.clearTimeout(s)}},Gs=async(n,e,s)=>Te()?qa(e().catch(o=>(console.warn(`[mobile-storage] ${n} failed`,o),s)),s):s,Mt=async n=>{bt("secure:read-start",{key:n});const e=await Gs("secure:read",async()=>(await Us.internalGetItem({prefixedKey:Vs(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return bt("secure:read",{key:n,hasToken:!!s}),s},Ye=async(n,e)=>{bt("secure:write-start",{key:n});const s=await Gs("secure:write",async()=>(await Us.internalSetItem({prefixedKey:Vs(n),data:e,sync:!1,access:Ha}),!0),!1);return bt("secure:write",{key:n,ok:s}),s},Ya=async n=>{await Gs("secure:delete",async()=>(await Us.internalRemoveItem({prefixedKey:Vs(n),sync:!1}),!0),!1)},Ja=async(n,e)=>{let s=0,o=0;return{records:await Promise.all(n.map(async i=>{if(!i||typeof i!="object")return i;const a=i,c=typeof a.url=="string"?a.url:null,u=typeof a.clientToken=="string"?a.clientToken.trim():"";if(!c||!u)return i;if(!await e(c,u))return o+=1,i;s+=1;const{clientToken:f,...d}=a;return{...d,hasToken:!0}})),migrated:s,failed:o}},Sr=async()=>{if(typeof window>"u"||!Te())return;let n;try{n=JSON.parse(window.localStorage.getItem(Ht)||"[]")}catch{return}if(!Array.isArray(n))return;const e=n.filter(o=>!!o&&typeof o=="object"&&typeof o.url=="string"&&typeof o.clientToken=="string"&&!!o.clientToken.trim());if(e.length===0)return;bt("secure:migrate-start",{count:e.length});const s=await Ja(n,async(o,r)=>{const i=gt(o);return await Ye(i,r)?await Mt(i)===r:!1});if(s.migrated>0)try{window.localStorage.setItem(Ht,JSON.stringify(s.records))}catch(o){console.warn("[mobile-storage] failed to finalize secure token migration",o);return}bt("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},Xa=async()=>(await Sr(),tt()),Jt=async n=>{const e=kr(tt(),n);return Ws(e),Te()&&n.clientToken&&await Ye(Re({candidates:n.candidates}),n.clientToken),e},Qa=async n=>{const e=tt(),s=e.find(r=>r.id===n)??null,o=e.filter(r=>r.id!==n);return Ws(o),s&&Te()&&await Ya(Re(s)),o},Za=1500,Xt=async(n,e,s)=>{const o=s?.fast?{totalTimeoutMs:qt}:void 0,r=Qe({candidates:n})?.serverId??null,i=n.find(f=>f.kind==="relay")??null,a=n.filter(f=>f.kind==="direct"),c=async()=>{for(const f of a){const d=vt(f.url)||f.url,m=e?{Authorization:`Bearer ${e}`}:void 0,g=await Ze(`${d}/health`,{method:"GET"},o);if(he("probe:direct:health",{url:d,ok:g?.ok===!0,status:g?.status??null,source:g?.source??null}),!g?.ok)continue;if(r){const b=await g.json().catch(()=>null),I=b&&typeof b=="object"?b.serverId:null;if(typeof I=="string"&&I&&I!==r){he("probe:server-id-mismatch",{url:d});continue}}const h=await Ze(`${d}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:m},o);if(he("probe:direct:session",{url:d,ok:h?.ok===!0,status:h?.status??null,source:h?.source??null,hasToken:!!e}),h?.status===401)return{status:"needs-login"};if(!h||!h.ok&&h.status!==404)continue;const x=await Zt(h);if(x&&x.disabled!==!0&&x.authenticated===!1)return{status:"needs-login"};const j=x?.disabled===!0;return!e&&Te()&&!j&&x?.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 Ua(i.relay,e,void 0,s?.fast?qt:yr,{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,h=null,x=null;const j=S=>{S?.status==="ok"&&S.transport.kind==="relay"&&S.transport.tunnel?.close()},b=S=>{d||(d=!0,f(S))},I=()=>{m||d||(g!==void 0&&(window.clearTimeout(g),g=void 0),u().then(S=>{if(x=S,d||m){j(S);return}if(S.status==="ok"||S.status==="needs-login"){b(S);return}h&&b(h)}))};c().then(S=>{if(h=S,!d){if(S.status==="ok"||S.status==="needs-login"){m=!0,g!==void 0&&window.clearTimeout(g),j(x),b(S);return}if(x){b(x);return}I()}}),g=window.setTimeout(I,Za)}):c()},Je=(n,e,s)=>{n.kind==="relay"?Va(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel):lt({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),Cr()},Et=()=>{const n=tt()[0];return n?.label?.trim()?n.label:null},St=async n=>{const e=n?.fast!==!1;await Sr();const s=tt()[0];if(he("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let o;if(Te()){if(s.hasToken&&(o=await Mt(Re(s)),!o))return{status:"no-candidate"}}else if(o=s.clientToken,!o&&s.hasToken)return{status:"no-candidate"};const r=await Xt(s.candidates,o,{fast:e});return he("auto-connect:probe",{status:r.status,candidates:s.candidates.map(i=>i.kind)}),r.status==="needs-login"?{status:"needs-login",label:s.label}:r.status!=="ok"?{status:"unreachable",label:s.label}:n?.skipIfConnected&&Ue()?(r.transport.kind==="relay"&&r.transport.tunnel?.close(),he("auto-connect:superseded",{}),{status:"no-candidate"}):(await Jt({id:s.id,label:s.label,candidates:s.candidates}),Je(r.transport,o??null,{runtimeKey:Re(s)}),{status:"connected"})},el=async(n,e)=>{let s="";try{s=vt(n.url)}catch{return!1}if(!s)return!1;const o=n.clientToken?.trim()||void 0,r=o?{Authorization:`Bearer ${o}`}:void 0,i=e?.fast?{totalTimeoutMs:qt}:void 0;if(!(await Ze(`${s}/health`,{method:"GET",headers:r},i))?.ok)return!1;const c=await Ze(`${s}/auth/session`,{method:"GET",credentials:o?"omit":"include",headers:r},i);if(!c||!c.ok&&c.status!==404)return!1;const u=await Zt(c);return!(u&&u.disabled!==!0&&u.authenticated===!1)},tl=n=>[...n].sort((e,s)=>{const o=(e.priority??100)-(s.priority??100);if(o!==0)return o;const r=i=>i.type==="relay"?2:i.url.startsWith("https://")?0:1;return r(e)-r(s)}).flatMap(e=>{if(e.type==="relay"){const s=Fs({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return $s(e.url)}),kn=async n=>{const e=Qe({candidates:n})?.serverId??null;for(const s of n){if(s.kind==="relay"){const i=Yn(s.relay),a=await He(xt,i.fetch("/health").catch(()=>null));if(he("establish:relay:health",{ok:a?.ok===!0,status:a?.status??null}),a?.ok)return{kind:"relay",relay:s.relay,tunnel:i};i.close();continue}const o=vt(s.url)||s.url,r=await Ze(`${o}/health`,{method:"GET"});if(he("establish:direct:health",{ok:r?.ok===!0,status:r?.status??null}),!!r?.ok){if(e){const i=await r.json().catch(()=>null),a=i&&typeof i=="object"?i.serverId:null;if(typeof a=="string"&&a&&a!==e){he("establish:server-id-mismatch",{url:o});continue}}return{kind:"direct",url:o}}}return null},sl=async(n,e)=>{if(!Dt())return el(n,e);const s=await He(e?.fast?qt:xt,bs("/auth/session").then(r=>r).catch(()=>null));if(!s)return!0;if(s.status===401)return!1;if(!s.ok&&s.status!==404)return!0;const o=await Zt(s);return!(o&&o.disabled!==!0&&o.authenticated===!1)},nl=n=>n.kind==="relay"?Dt():!Dt()&&vr(n.url,Ue()),Nr=()=>{const n=yt();return n?tt().find(e=>Re(e)===n)??null:null},Sn=n=>{const e=yt();return!!e&&Re(n)===e},Vt=async n=>{const e=n?.fast!==!1,s=Nr();if(!s)return he("reprobe:no-connection",{runtimeKey:!!yt()}),"no-connection";let o;if(Te()?o=s.hasToken?await Mt(Re(s)):void 0:o=s.clientToken,!o&&s.hasToken)return he("reprobe:no-token",{hasToken:!0}),"unreachable";he("reprobe:start",{candidates:s.candidates.map(f=>f.kind),fast:e,hasToken:!!o});const r=s.candidates.findIndex(f=>nl(f.kind==="relay"?{kind:"relay",relay:f.relay}:{kind:"direct",url:f.url})),i=r>=0?s.candidates.slice(0,r):s.candidates,a=await Xt(i,o,{fast:e});if(he("reprobe:better",{status:a.status,probed:i.length}),a.status==="ok")return await Jt({id:s.id,label:s.label,candidates:s.candidates}),Je(a.transport,o??null,{runtimeKey:Re(s)}),"switched";if(a.status==="needs-login")return"needs-login";if(r>=0){const f=await sl({url:Ue(),clientToken:o},{fast:e});if(he("reprobe:current",{stillValid:f}),f)return Cr(),"unchanged"}const c=r>=0?s.candidates.slice(r+1):[],u=await Xt(c,o,{fast:e});return he("reprobe:fallback",{status:u.status,probed:c.length}),u.status==="ok"?(await Jt({id:s.id,label:s.label,candidates:s.candidates}),Je(u.transport,o??null,{runtimeKey:Re(s)}),"switched"):u.status==="needs-login"?"needs-login":"unreachable"},rl=5e3;let ns=!1;const ol=async()=>{if(ns)return"skipped";const n=Nr();if(!n)return he("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=Qe(n);if(!e)return he("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";ns=!0;try{const s=await He(xt,bs("/api/client-auth/connection/candidates").then(f=>f).catch(()=>null));if(!s?.ok)return he("candidates:refresh-skip",{reason:"fetch-failed",status:s?.status??null}),"skipped";const o=await s.json().catch(()=>null);if(!o||o.serverId!==e.serverId)return he("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const r=Array.isArray(o.candidates)?o.candidates:[],i=[];for(const f of r){if(!f||typeof f!="object")continue;const d=f;if(!(d.type!=="lan"||typeof d.url!="string"))try{const m=vt(d.url);m&&!i.includes(m)&&i.push(m)}catch{}}if(i.length===0)return he("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const a=Qt(n).filter(f=>f.url.startsWith("https://")),c=[...i.map(f=>({kind:"direct",url:f})),...a,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map(fs))===JSON.stringify(c.map(fs))?"unchanged":(he("candidates:refreshed",{lanCount:i.length}),await Jt({id:n.id,label:n.label,candidates:c}),"updated")}finally{ns=!1}},Cr=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await ol().catch(()=>"skipped");he("candidates:refresh-result",{result:n}),n==="updated"&&Dt()&&await Vt().catch(()=>null)})()},rl)},Er=n=>{const{t:e}=me(),[s,o]=l.useState(()=>tt()),[r,i]=l.useState(null),[a,c]=l.useState(null),[u,f]=l.useState(null),d=l.useRef(s),m=l.useRef(null),g=l.useRef(Oa()),h=l.useCallback(w=>{d.current=w,o(w)},[]),x=l.useCallback(w=>{m.current=w,i(w)},[]),j=l.useCallback(w=>{m.current===w&&(m.current=null,i(null))},[]);l.useEffect(()=>{let w=!1;return Xa().then(R=>{w||h(R)}),()=>{w=!0}},[h]);const b=l.useCallback(w=>{const R=kr(d.current,w);return h(R),Ws(R),R},[h]),I=l.useCallback(async w=>{c(null),x("connect");try{const R=jn(w);if(R.length===0){c(e("mobile.connect.error.urlRequired"));return}const y=w.id?d.current.find($=>$.id===w.id):d.current.find($=>Yt($.candidates,R)),A=w.label?.trim()||y?.label||Ut(Ge({candidates:R})),M=w.relayGrant;let C=w.clientToken?.trim()||void 0;const N=!!C;C||(Te()?y?.hasToken&&(C=await Mt(Re({candidates:R}))):C=y?.clientToken),he("connect:start",{candidates:R.map($=>$.kind),hasToken:!!C});const H=await Xt(R,C);if(he("connect:probe",{status:H.status}),H.status==="unreachable"){c(e("mobile.connect.error.unreachable"));return}if(H.status==="needs-login"){b({id:y?.id,label:A,candidates:R}),f({id:y?.id??crypto.randomUUID(),label:A,candidates:R,relay:Qe({candidates:R})??void 0,relayGrant:M});return}C&&N&&Te()&&await Ye(Re({candidates:R}),C),b({id:y?.id,label:A,candidates:R,clientToken:C}),Je(H.transport,C??null,{runtimeKey:Re({candidates:R}),grant:M}),n()}catch(R){console.warn("[mobile-connect] connect threw",R),c(e("mobile.connect.error.invalidUrl"))}finally{j("connect")}},[x,j,n,b,e]),S=l.useCallback(async w=>{if(m.current==="pairing")return;c(null),x("pairing");const R=tl(w.candidates);let y=null,A=!1;try{if(y=await kn(R),!y){c(e("mobile.connect.error.unreachable"));return}const M=JSON.stringify({pairingId:w.pairingId,secret:w.secret,clientLabel:"OpenChamber Mobile",clientKind:"mobile",deviceName:"OpenChamber Mobile",devicePlatform:wn(),dedupeKey:vn()}),C={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:M},N=y.kind==="relay"?await He(xt,y.tunnel.fetch("/api/client-auth/pairing/redeem",C).catch(()=>null)):await Ze(`${y.url}/api/client-auth/pairing/redeem`,C);if(!N?.ok){c(e("mobile.connect.error.authRequired"));return}const H=await N.json().catch(()=>null),$=typeof H?.clientToken=="string"?H.clientToken.trim():"";if(!$){c(e("mobile.connect.error.authRequired"));return}const v=typeof H?.server?.label=="string"?H.server.label:"",_=w.label||v||Ut(Ge({candidates:R}));if(Te()&&!await Ye(Re({candidates:R}),$)){c(e("mobile.connect.error.authRequired"));return}b({label:_,candidates:R,clientToken:$}),Je(y.kind==="relay"?{kind:"relay",relay:y.relay,tunnel:y.tunnel}:{kind:"direct",url:y.url},$,{runtimeKey:Re({candidates:R})}),A=y.kind==="relay",n()}catch(M){console.warn("[mobile-connect] pairing threw",M),c(e("mobile.connect.error.authRequired"))}finally{!A&&y?.kind==="relay"&&y.tunnel.close(),j("pairing")}},[x,j,n,b,e]),E=l.useCallback(async w=>{if(!u||!w.trim()||m.current==="password")return;c(null),x("password");const R=g.current.begin(),y=()=>g.current.isCurrent(R),{id:A,label:M,candidates:C}=u;let N=null,H=!1;try{if(N=await kn(C),!y())return;if(!N){c(e("mobile.connect.error.unreachable"));return}const $={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:w,trustDevice:!0,issueClientToken:!0,clientLabel:"OpenChamber Mobile",clientKind:"mobile",devicePlatform:wn(),dedupeKey:vn()})};he("password:start",{transport:N.kind});const v=N.kind==="relay"?await He(xt,N.tunnel.fetch("/auth/session",$).catch(()=>null)):await Ze(`${N.url}/auth/session`,$);if(!y())return;if(he("password:done",{ok:v?.ok===!0,status:v?.status??null}),!v?.ok){c(e("mobile.connect.error.passwordFailed"));return}const _=await v.json().catch(()=>null);if(!y())return;const O=typeof _?.clientToken=="string"?_.clientToken.trim():"";if(he("password:token",{issued:!!O}),!O){if(N.kind==="direct"&&!Te()){b({id:A,label:M,candidates:C}),f(null),Je({kind:"direct",url:N.url},null,{runtimeKey:Re({candidates:C})}),n();return}c(e("mobile.connect.error.authRequired"));return}if(Te()&&(!y()||(await Ye(Re({candidates:C}),O),!y()))||!y()||(b({id:A,label:M,candidates:C,clientToken:O}),f(null),Je(N.kind==="relay"?{kind:"relay",relay:N.relay,tunnel:N.tunnel}:{kind:"direct",url:N.url},O,{runtimeKey:Re({candidates:C})}),H=N.kind==="relay",!y()))return;n()}catch($){if(!y())return;console.warn("[mobile-connect] password threw",$),c(e("mobile.connect.error.passwordFailed"))}finally{!H&&N?.kind==="relay"&&N.tunnel.close(),y()&&j("password")}},[x,j,n,u,b,e]),T=l.useCallback(()=>{g.current.cancel(),j("password"),f(null),c(null)},[j]),k=l.useCallback(async w=>{c(null);let R=jn(w);const y=w.id?d.current.find(N=>N.id===w.id)??null:null;if(y){const N=R.filter(v=>v.kind==="direct"),H=Qt(y).filter(v=>v.url.startsWith("https://")&&!N.some(_=>vr(_.url,v.url))),$=Qe(y);R=[...N,...H,...$?[{kind:"relay",relay:$}]:[]]}if(R.length===0)return c(e("mobile.connect.error.urlRequired")),null;const A=w.clientToken?.trim()||void 0,M=w.label?.trim()||Ut(Ge({candidates:R}));if(Te()){const N=Re({candidates:R});if(A)await Ye(N,A);else if(y?.hasToken){const H=Re(y);if(H&&N&&H!==N){const $=await Mt(H);$&&await Ye(N,$)}}}return b({id:w.id,label:M,candidates:R,clientToken:A}).find(N=>Yt(N.candidates,R))??null},[b,e]),P=l.useCallback(async w=>{const R=d.current.find(A=>A.id===w)??null,y=await Qa(w);return h(y),R},[h]);return{connections:s,isBusy:r!==null,isPasswordBusy:r==="password",error:a,pendingConnection:u,connect:I,redeemPairingConnection:S,submitPassword:E,cancelPassword:T,saveConnection:k,removeConnection:P,setError:c}},Rr=n=>{const e=de.c(31),{onClose:s}=n,{t:o}=me(),[r,i]=l.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=Ta(),e[0]=a):a=e[0];const c=a;let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{vo(Ia()).then(w=>{w.ok&&(i(!0),window.setTimeout(()=>i(!1),2e3))})},e[1]=u):u=e[1];const f=u;let d;e[2]!==o?(d=o("mobile.connectionDebug.title"),e[2]=o,e[3]=d):d=e[3];let m;e[4]!==d?(m=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:d}),e[4]=d,e[5]=m):m=e[5];const g=r?"check":"file-copy";let h;e[6]!==g?(h=t.jsx(se,{name:g,className:"size-4"}),e[6]=g,e[7]=h):h=e[7];let x;e[8]!==r||e[9]!==o?(x=o(r?"mobile.connectionDebug.copied":"mobile.connectionDebug.copy"),e[8]=r,e[9]=o,e[10]=x):x=e[10];let j;e[11]!==h||e[12]!==x?(j=t.jsxs(xe,{type:"button",variant:"outline",size:"sm",onClick:f,disabled:c.length===0,children:[h,x]}),e[11]=h,e[12]=x,e[13]=j):j=e[13];let b;e[14]!==o?(b=o("mobile.connectionDebug.close"),e[14]=o,e[15]=b):b=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(se,{name:"close",className:"size-[18px]"}),e[16]=I):I=e[16];let S;e[17]!==s||e[18]!==b?(S=t.jsx(xe,{type:"button",variant:"ghost",size:"icon","aria-label":b,onClick:s,children:I}),e[17]=s,e[18]=b,e[19]=S):S=e[19];let E;e[20]!==S||e[21]!==j?(E=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[j,S]}),e[20]=S,e[21]=j,e[22]=E):E=e[22];let T;e[23]!==E||e[24]!==m?(T=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[m,E]}),e[23]=E,e[24]=m,e[25]=T):T=e[25];let k;e[26]!==o?(k=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:c.length===0?t.jsx("p",{className:"typography-small text-muted-foreground",children:o("mobile.connectionDebug.empty")}):t.jsx("pre",{className:"whitespace-pre-wrap break-words typography-code text-muted-foreground",children:c.map(gr).join(`
|
|
4
|
+
`)})}),e[26]=o,e[27]=k):k=e[27];let P;return e[28]!==T||e[29]!==k?(P=t.jsxs("div",{className:"fixed inset-0 z-[70] flex flex-col bg-background pb-[var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))] pt-[var(--safe-area-inset-top,env(safe-area-inset-top,0px))] text-foreground",children:[T,k]}),e[28]=T,e[29]=k,e[30]=P):P=e[30],P},Pr=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},il=()=>window.Capacitor?.getPlatform?.()==="android",Tr=n=>{const e=n.trim();if(!e)return null;if(/^openchamber:\/\//i.test(e)){const s=uo(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},Ar=(n,e)=>{const s=Tr(n);if(!s&&e?.pairingStringFallback){const o=fo(n);if(o)return{status:"pairing",pairing:o}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},al=async(n,e)=>{if(!n.startScan||!n.stopScan||!n.addListener)return{status:"unsupported"};if(e?.aborted)return{status:"cancelled"};let s,o,r=!1,i=()=>{};const a=new Promise(f=>{i=f}),c=f=>{r||(r=!0,i(f))},u=()=>c({status:"cancelled"});e?.addEventListener("abort",u,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:d})=>{const m=d?.[0],g=(m?.rawValue??m?.displayValue??"").trim();g&&c(Ar(g,{pairingStringFallback:!0}))})).then(d=>{s=d}),Promise.resolve(n.addListener("scanError",()=>c({status:"failed"}))).then(d=>{o=d})])).some(({status:d})=>d==="rejected")?c({status:"failed"}):r||n.startScan({formats:["QR_CODE"]}).catch(()=>c({status:"failed"})),await a}finally{e?.removeEventListener("abort",u),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(o?.remove()),n.stopScan()])}},ms=()=>Pr()!==null,Ir=async n=>{const e=Pr();if(!e)return{status:"unsupported"};try{if(e.requestPermissions){const a=(await e.requestPermissions())?.camera;if(a&&a!=="granted"&&a!=="limited")return{status:"permission-denied"}}if(n?.signal?.aborted)return{status:"cancelled"};if(il())return al(e,n?.signal);if(!e.scan)return{status:"unsupported"};const o=(await e.scan({formats:["QR_CODE"]}))?.barcodes?.[0],r=(o?.rawValue??o?.displayValue??"").trim();return r?Ar(r):{status:"cancelled"}}catch{return{status:"failed"}}},ft={autoComplete:"off",autoCorrect:"off",spellCheck:!1},Rt="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",_r=n=>{const e=de.c(22),{onCancel:s}=n,{t:o}=me(),r=l.useRef(null);let i,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const I={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},S={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 E=new Map,T=P=>{!(P instanceof HTMLElement)||P===r.current||E.has(P)||(E.set(P,{opacity:P.style.opacity,pointerEvents:P.style.pointerEvents}),P.style.setProperty("opacity","0"),P.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(T);const k=new MutationObserver(P=>{P.forEach(w=>w.addedNodes.forEach(T))});return k.observe(document.body,{childList:!0}),()=>{k.disconnect(),E.forEach(ll),I.value?document.documentElement.style.setProperty("background-color",I.value,I.priority):document.documentElement.style.removeProperty("background-color"),S.value?document.body.style.setProperty("background-color",S.value,S.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]!==s?(c=()=>{const I=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",I),()=>document.removeEventListener("visibilitychange",I)},u=[s],e[2]=s,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 h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(se,{name:"close",className:"size-[18px]"}),e[12]=h):h=e[12];let x;e[13]!==o?(x=o("mobile.instances.cancelEdit"),e[13]=o,e[14]=x):x=e[14];let j;e[15]!==s||e[16]!==x?(j=t.jsxs(xe,{type:"button",variant:"outline",size:"lg",className:"mx-auto min-h-12 w-full max-w-sm bg-background",onClick:s,children:[h,x]}),e[15]=s,e[16]=x,e[17]=j):j=e[17];let b;return e[18]!==j||e[19]!==f||e[20]!==g?(b=mt.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,j]}),document.body),e[18]=j,e[19]=f,e[20]=g,e[21]=b):b=e[21],b},Dr=()=>{const n=de.c(6),{t:e}=me();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(qe,{width:96,height:96,isAnimated:!0}),n[0]=s):s=n[0];let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(se,{name:"loader-4",className:"size-[18px] animate-spin"}),n[1]=o):o=n[1];let r;n[2]!==e?(r=e("mobile.connect.connecting"),n[2]=e,n[3]=r):r=n[3];let i;return n[4]!==r?(i=mt.createPortal(t.jsxs("div",{role:"status",className:"fixed inset-0 z-[1000] flex flex-col items-center justify-center gap-5 bg-background px-6 text-foreground",children:[s,t.jsxs("div",{className:"flex items-center gap-2 typography-ui-label text-muted-foreground",children:[o,t.jsx("span",{children:r})]})]}),document.body),n[4]=r,n[5]=i):i=n[5],i};function ll(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const cl=({onConnected:n,notice:e=null})=>{const{t:s}=me(),o=Er(n),{connections:r,isBusy:i,isPasswordBusy:a,error:c,pendingConnection:u}=o,[f,d]=l.useState(""),[m,g]=l.useState(""),[h,x]=l.useState(""),[j,b]=l.useState(!1),[I,S]=l.useState(!1),E=l.useRef(null),T=l.useMemo(()=>ms(),[]),[k,P]=l.useState(()=>!ms()),[w,R]=l.useState(null),[y,A]=l.useState(""),[M,C]=l.useState(!1),N=br(l.useCallback(()=>C(!0),[])),H=l.useCallback(z=>{z.preventDefault(),o.connect({url:f,clientToken:h,label:m})},[h,o,m,f]),$=l.useCallback(z=>{if(/^openchamber:\/\//i.test(z.trim())){const L=Tr(z);if(L){if("pairing"in L){o.redeemPairingConnection(L.pairing);return}d(L.url),L.label&&g(L.label),L.clientToken&&x(L.clientToken);return}}d(z)},[o]),v=l.useCallback(async()=>{if(E.current||i)return;o.setError(null),b(!0);const z=new AbortController;E.current=z;try{const L=await Ir({signal:z.signal});switch(E.current===z&&(E.current=null,b(!1)),L.status){case"ok":S(!0),d(L.url),L.label&&g(L.label),L.clientToken&&x(L.clientToken),await o.connect({url:L.url,clientToken:L.clientToken,label:L.label});break;case"pairing":S(!0),await o.redeemPairingConnection(L.pairing);break;case"permission-denied":o.setError(s("mobile.connect.scan.permissionDenied"));break;case"invalid":o.setError(s("mobile.connect.scan.invalid"));break;case"unsupported":o.setError(s("mobile.connect.scan.unsupported"));break;case"failed":o.setError(s("mobile.connect.scan.failed"));break;default:break}}finally{S(!1),E.current===z&&(E.current=null,b(!1))}},[o,i,s]);l.useEffect(()=>()=>E.current?.abort(),[]);const _=l.useCallback(z=>{z.preventDefault(),o.submitPassword(y)},[o,y]),O=l.useCallback(()=>{A(""),o.cancelPassword()},[o]);return t.jsxs(t.Fragment,{children:[j?t.jsx(_r,{onCancel:()=>E.current?.abort()}):null,I?t.jsx(Dr,{}):null,M?t.jsx(Rr,{onClose:()=>C(!1)}):null,t.jsx("main",{className:"oc-keyboard-fill-screen flex min-h-dvh flex-col overflow-y-auto bg-background px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+28px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+28px)] text-foreground",children:t.jsxs("div",{className:"m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8",children:[t.jsxs("div",{className:"flex flex-col items-center gap-5 text-center",children:[t.jsx("span",{...N,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(qe,{width:72,height:72,className:"size-[72px]"})}),t.jsx("h1",{className:"typography-h2 text-foreground",children:s("mobile.connect.welcome.title")})]}),e?t.jsxs("div",{role:"status",className:"flex w-full items-center gap-3 rounded-[18px] border border-[color-mix(in_srgb,var(--status-warning)_35%,transparent)] bg-[color-mix(in_srgb,var(--status-warning)_10%,transparent)] px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-[color-mix(in_srgb,var(--status-warning)_16%,transparent)] text-[var(--status-warning)]",children:t.jsx(se,{name:e.kind==="auth-expired"?"lock":"cloud-off",className:"size-[18px]"})}),t.jsx("p",{className:"min-w-0 flex-1 typography-small text-foreground",children:e.kind==="auth-expired"?s("mobile.connect.notice.authExpired",{label:e.label}):s("mobile.connect.notice.unreachable",{label:e.label})})]}):null,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(se,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0 text-left",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:u.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:u.candidates.some(z=>z.kind==="direct")?Ge(u):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...ft,value:y,onChange:z=>A(z.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:Rt}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null,t.jsx(xe,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!y.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(xe,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:O,children:s("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[T?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(xe,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{v()},disabled:j||i,children:[t.jsx(se,{name:"scan-2",className:J("size-[18px]",j&&"animate-pulse")}),s(i?"mobile.connect.connecting":"mobile.connect.scanQr")]}),t.jsx("p",{className:"px-2 text-center typography-small text-muted-foreground",children:s("mobile.connect.welcome.scanHint")})]}):null,c&&!k?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null,r.length>0?t.jsxs("section",{className:"flex w-full flex-col gap-2.5",children:[t.jsx("h2",{className:"text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground",children:s("mobile.connect.saved.title")}),t.jsx("div",{className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(z=>{const L=w===z.id;return t.jsxs("button",{type:"button",disabled:i,className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3.5 py-2.5 text-left last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-70",onClick:()=>{R(z.id),o.connect({id:z.id,candidates:z.candidates,clientToken:z.clientToken,label:z.label}).finally(()=>R(null))},children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(se,{name:"server",className:"size-[18px]"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:z.label}),t.jsx("span",{className:J("block truncate typography-small",L?"text-foreground":"text-muted-foreground"),children:L?s("mobile.connect.connecting"):z.candidates.some(ee=>ee.kind==="direct")?Ge(z):s("mobile.connect.relay.badge")})]}),L?t.jsx(se,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(se,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},z.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[T?t.jsxs("button",{type:"button",onClick:()=>P(z=>!z),"aria-expanded":k,className:"mx-auto flex items-center gap-1 rounded-full px-2 py-1 typography-small text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:[t.jsx("span",{children:s("mobile.connect.manual.toggle")}),t.jsx(se,{name:"arrow-down-s",className:J("size-4 transition-transform duration-200",k&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:k?"1fr":"0fr"},children:t.jsx("div",{className:"min-h-0 overflow-hidden",children:t.jsxs("form",{className:"flex w-full flex-col gap-3 pt-3",onSubmit:H,children:[t.jsx("input",{...ft,value:f,onChange:z=>$(z.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:k?void 0:-1,className:J(Rt,"text-center")}),t.jsx("input",{value:m,onChange:z=>g(z.target.value),placeholder:s("mobile.instances.label.placeholder"),"aria-label":s("mobile.instances.label.label"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:k?void 0:-1,className:J(Rt,"text-center")}),t.jsx("input",{...ft,value:h,onChange:z=>x(z.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:k?void 0:-1,autoCapitalize:"none",className:J(Rt,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null,t.jsx(xe,{type:"submit",variant:T?"outline":"default",size:"lg",className:"h-12 w-full",disabled:i||j||!f.trim(),children:s(i?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},ul=n=>{const e=n.usedPercent;return typeof e!="number"||!Number.isFinite(e)?"text-foreground":e>=80?"text-[var(--status-error)]":e>=50?"text-[var(--status-warning)]":"text-foreground"},dl=n=>{const e=de.c(12),{groups:s,displayMode:o,timeFormatPreference:r,className:i}=n;let a;e[0]!==i?(a=J("space-y-1.5",i),e[0]=i,e[1]=a):a=e[1];let c;if(e[2]!==o||e[3]!==s||e[4]!==r){let f;e[6]!==o||e[7]!==r?(f=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(wo,{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.planLabel?t.jsx("span",{className:"shrink-0 typography-micro capitalize text-muted-foreground",children:d.planLabel}):null,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,h=jo(m.window.valueLabel,g),x=ko(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:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"shrink-0 truncate typography-ui-label text-muted-foreground",children:m.subtitle?`${m.subtitle} · ${m.label}`:m.label}),x?t.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/70",children:x}):null]}),t.jsx("span",{className:J("shrink-0 typography-ui-label font-semibold tabular-nums",ul(m.window)),children:h==="-"?"":h})]},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=s.map(f),e[2]=o,e[3]=s,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},Nn=380,fl=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},ot=n=>typeof n=="number"&&Number.isFinite(n)?n:0,Cn=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),Mr=n=>{const e=de.c(19),{percentage:s}=n;let o,r,i,a,c,u,f;if(e[0]!==s){i=Ro(s)??0;const x=Po(s);r=x==="critical"?"var(--status-error)":x==="warn"?"var(--status-warning)":"var(--status-success)",o=2*Math.PI*7.5,a="0 0 18 18",c="size-[18px] -rotate-90",u="progressbar",f=Math.round(i),e[0]=s,e[1]=o,e[2]=r,e[3]=i,e[4]=a,e[5]=c,e[6]=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 h;return e[13]!==a||e[14]!==c||e[15]!==u||e[16]!==f||e[17]!==g?(h=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]=h):h=e[18],h},ml=n=>{const e=de.c(13),{icon:s,iconNode:o,label:r,children:i}=n;let a;e[0]!==s||e[1]!==o?(a=o??(s?t.jsx(se,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=o,e[2]=a):a=e[2];let c;e[3]!==a?(c=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:a}),e[3]=a,e[4]=c):c=e[4];let 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},pl=n=>{const e=de.c(49),{open:s,onClose:o,anchorRef:r,contextDisplay:i,usageGroups:a,usageDisplayMode:c,isUsageLoading:u,timeFormatPreference:f}=n,{t:d}=me(),m=l.useRef(null),[g,h]=l.useState(s),[x,j]=l.useState(!1),{enabled:b}=vs(),I=l.useRef(null),[S,E]=l.useState(null);let T,k;e[0]!==r||e[1]!==b||e[2]!==s||e[3]!==g?(T=()=>{if(!s||!b||!g)return;const G=()=>{const te=r.current?.getBoundingClientRect(),ae=I.current?.getBoundingClientRect();if(!te||!ae){E(null);return}const pe=te.left-ae.left,oe=Math.min(Math.max(pe,8),Math.max(8,ae.width-Nn-8));E(oe)};G();const F=I.current;if(typeof ResizeObserver>"u"||!F)return;const Z=new ResizeObserver(G);return Z.observe(F),()=>Z.disconnect()},k=[r,b,s,g],e[0]=r,e[1]=b,e[2]=s,e[3]=g,e[4]=T,e[5]=k):(T=e[4],k=e[5]),l.useLayoutEffect(T,k);const P=b&&S!==null;let w,R;e[6]!==s||e[7]!==g?(w=()=>{if(s){h(!0),j(!1);return}if(!g)return;j(!0);const G=window.setTimeout(()=>{h(!1),j(!1)},140);return()=>window.clearTimeout(G)},R=[s,g],e[6]=s,e[7]=g,e[8]=w,e[9]=R):(w=e[8],R=e[9]),l.useEffect(w,R);let y,A;e[10]!==o||e[11]!==s?(y=()=>{if(!s)return;const G=F=>{F.key==="Escape"&&o()};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},A=[o,s],e[10]=o,e[11]=s,e[12]=y,e[13]=A):(y=e[12],A=e[13]),l.useEffect(y,A);let M,C;if(e[14]!==r||e[15]!==o||e[16]!==s?(M=()=>{if(!s)return;const G=F=>{const Z=F.target;if(!(Z instanceof Node)){o();return}m.current?.contains(Z)||r.current?.contains(Z)||o()};return document.addEventListener("pointerdown",G,!0),document.addEventListener("wheel",G,!0),()=>{document.removeEventListener("pointerdown",G,!0),document.removeEventListener("wheel",G,!0)}},C=[r,o,s],e[14]=r,e[15]=o,e[16]=s,e[17]=M,e[18]=C):(M=e[17],C=e[18]),l.useEffect(M,C),!g)return null;let N;e[19]!==d?(N=d("mobile.header.openMetadataAria"),e[19]=d,e[20]=N):N=e[20];const H=P?"absolute origin-top-left":"mx-3 mt-2",$=x?"pointer-events-none":"pointer-events-auto";let v;e[21]!==H||e[22]!==$?(v=J("overflow-y-auto overscroll-contain rounded-[20px] border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",H,$),e[21]=H,e[22]=$,e[23]=v):v=e[23];const _=`${x?"session-metadata-out":"session-metadata-in"} ${x?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let O;e[24]!==S||e[25]!==P?(O=P?{top:8,left:S??8,width:`min(${Nn}px, calc(100% - 16px))`}:null,e[24]=S,e[25]=P,e[26]=O):O=e[26];let z;e[27]!==_||e[28]!==O?(z={animation:_,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...O},e[27]=_,e[28]=O,e[29]=z):z=e[29];let L;e[30]!==i||e[31]!==d?(L=i?t.jsx(ml,{iconNode:t.jsx(Mr,{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:J("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]=L):L=e[32];let ee;e[33]!==u||e[34]!==f||e[35]!==c||e[36]!==a?(ee=t.jsx(hl,{groups:a,displayMode:c,isLoading:u,timeFormatPreference:f}),e[33]=u,e[34]=f,e[35]=c,e[36]=a,e[37]=ee):ee=e[37];let Q;e[38]!==L||e[39]!==ee?(Q=t.jsxs("div",{className:"space-y-1",children:[L,ee]}),e[38]=L,e[39]=ee,e[40]=Q):Q=e[40];let D;e[41]!==v||e[42]!==z||e[43]!==Q||e[44]!==N?(D=t.jsx("div",{ref:m,role:"dialog","aria-label":N,className:v,style:z,children:Q}),e[41]=v,e[42]=z,e[43]=Q,e[44]=N,e[45]=D):D=e[45];let X;e[46]===Symbol.for("react.memo_cache_sentinel")?(X=t.jsx("style",{children:`
|
|
5
|
+
@keyframes session-metadata-in {
|
|
6
|
+
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
7
|
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
8
|
+
}
|
|
9
|
+
@keyframes session-metadata-out {
|
|
10
|
+
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
11
|
+
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
12
|
+
}
|
|
13
|
+
`}),e[46]=X):X=e[46];let q;return e[47]!==D?(q=t.jsxs("div",{ref:I,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:[D,X]}),e[47]=D,e[48]=q):q=e[48],q},hl=n=>{const e=de.c(30),{groups:s,displayMode:o,isLoading:r,timeFormatPreference:i}=n,{t:a}=me();let c;e[0]!==o||e[1]!==a?(c=a(o==="remaining"?"header.services.remaining":"header.services.used"),e[0]=o,e[1]=a,e[2]=c):c=e[2];const u=c;if(s.length===0){if(!r)return null;let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx(se,{name:"loader-4",className:"size-4 animate-spin","aria-hidden":!0}),e[3]=S):S=e[3];let E;e[4]!==a?(E=a("common.loading"),e[4]=a,e[5]=E):E=e[5];let T;return e[6]!==E?(T=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-2.5 py-6 text-muted-foreground",children:[S,t.jsx("span",{className:"typography-ui-label",children:E})]}),e[6]=E,e[7]=T):T=e[7],T}let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(se,{name:"timer",className:"size-[18px]"})}),e[8]=f):f=e[8];let 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(se,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[13]=r,e[14]=g):g=e[14];let h;e[15]!==u?(h=t.jsx("span",{className:"truncate",children:u}),e[15]=u,e[16]=h):h=e[16];let x;e[17]!==g||e[18]!==h?(x=t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground",children:[g,h]}),e[17]=g,e[18]=h,e[19]=x):x=e[19];let j;e[20]!==m||e[21]!==x?(j=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[f,m,x]}),e[20]=m,e[21]=x,e[22]=j):j=e[22];let b;e[23]!==o||e[24]!==s||e[25]!==i?(b=t.jsx(dl,{groups:s,displayMode:o,timeFormatPreference:i}),e[23]=o,e[24]=s,e[25]=i,e[26]=b):b=e[26];let I;return e[27]!==j||e[28]!==b?(I=t.jsxs("div",{className:"pt-2.5",children:[j,b]}),e[27]=j,e[28]=b,e[29]=I):I=e[29],I},gl=l.memo(function({open:e,onOpenChange:s,currentSessionId:o,effectiveDirectory:r,isNewSessionDraftOpen:i}){const{t:a}=me(),c=l.useRef(null),u=So(o??"",r||void 0),f=ze(_=>_.providers),d=ze(_=>_.currentProviderId),m=ze(_=>_.currentModelId),g=ze(_=>_.getModelMetadata);ze(_=>_.modelsMetadata.size);const h=No(l.useCallback(_=>o?_.sessionModelSelections.get(o)??null:null,[o])),x=rt(_=>_.results),j=rt(_=>_.loadSettings),b=rt(_=>_.fetchAllQuotas),I=rt(_=>_.isLoading),S=rt(_=>_.displayMode),E=rt(_=>_.dropdownProviderIds),T=Ve(_=>_.timeFormatPreference);Co(),l.useEffect(()=>{j()},[j]),l.useEffect(()=>{un(E)},[E]),l.useEffect(()=>{!e||I||!E.some(O=>!x.some(z=>z.providerId===O))||b()},[E,b,I,e,x]);const P=l.useMemo(()=>{for(let _=u.length-1;_>=0;_-=1){const O=u[_];if(O.role!=="user")continue;const z=typeof O.model?.providerID=="string"&&O.model.providerID.trim().length>0?O.model.providerID:void 0,L=typeof O.model?.modelID=="string"&&O.model.modelID.trim().length>0?O.model.modelID:void 0;if(z&&L)return{providerID:z,modelID:L}}return null},[u])??(h?{providerID:h.providerId,modelID:h.modelId}:null)??(d&&m?{providerID:d,modelID:m}:null),R=(P?f.find(_=>_.id===P.providerID):void 0)?.models.find(_=>_.id===P?.modelID),y=P?g(P.providerID,P.modelID):void 0,A=fl(R?.limit,"context")??y?.limit?.context??0,M=l.useMemo(()=>{for(let _=u.length-1;_>=0;_-=1){const O=u[_];if(O.role!=="assistant"||!O.tokens)continue;const z=ot(O.tokens.total);if(z>0)return z;const L=ot(O.tokens.input)+ot(O.tokens.output)+ot(O.tokens.reasoning)+ot(O.tokens.cache?.read)+ot(O.tokens.cache?.write);if(L>0)return L}return 0},[u]),C=!i&&M>0&&A>0?Math.min(M/A*100,999):null,N=C!==null?`${Cn(M)}/${Cn(A)}`:null,H=C===null?"":C>=90?"text-[var(--status-error)]":C>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",$=C!==null&&N?{percentage:C,tokens:N,colorClass:H}:null,v=Eo();return l.useEffect(()=>{!e||v.length===0||un(v.map(_=>_.providerId))},[e,v]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:c,type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":a("mobile.header.openMetadataAria"),"aria-expanded":e,onClick:()=>s(_=>!_),style:{touchAction:"manipulation"},children:t.jsx(Mr,{percentage:$?.percentage??0})}),t.jsx(pl,{open:e,onClose:()=>s(!1),anchorRef:c,contextDisplay:$,usageGroups:v,usageDisplayMode:S,isUsageLoading:I,timeFormatPreference:T})]})}),bl=10,En=380,xl=(n,e)=>n.title?.trim()||e,yl=n=>{const e=de.c(32),{session:s,meta:o,active:r,onSelect:i}=n,{t:a}=me(),c=Qn(s.id),u=Zn(s.id),f=c?.type??"idle",d=f==="busy"||f==="retry",m=!d&&u>0&&!r,g=er(s.id,d),h=(d||m)&&g,x=s.time?.updated??s.time?.created??0;let j;e[0]!==x?(j=Ao(x),e[0]=x,e[1]=j):j=e[1];const b=j,I=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let S;e[2]!==I?(S=J("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",I),e[2]=I,e[3]=S):S=e[3];let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E={touchAction:"manipulation"},e[4]=E):E=e[4];const T=r?"text-primary":"text-foreground";let k;e[5]!==T?(k=J("block truncate typography-ui-label",T),e[5]=T,e[6]=k):k=e[6];let P;e[7]!==s||e[8]!==a?(P=xl(s,a("sessions.sidebar.session.untitled")),e[7]=s,e[8]=a,e[9]=P):P=e[9];let w;e[10]!==k||e[11]!==P?(w=t.jsx("span",{className:k,children:P}),e[10]=k,e[11]=P,e[12]=w):w=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]!==w?(y=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[w,R]}),e[15]=R,e[16]=w,e[17]=y):y=e[17];let A;e[18]!==d||e[19]!==m?(A=d||m?t.jsx("span",{className:J("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]=A):A=e[20];let M;e[21]!==d||e[22]!==s.id||e[23]!==h||e[24]!==b?(M=h?t.jsx(ur,{sessionId:s.id,running:d,className:"typography-micro"}):b?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:b}):null,e[21]=d,e[22]=s.id,e[23]=h,e[24]=b,e[25]=M):M=e[25];let C;return e[26]!==i||e[27]!==y||e[28]!==A||e[29]!==M||e[30]!==S?(C=t.jsxs("button",{type:"button",className:S,onClick:i,style:E,children:[y,A,M]}),e[26]=i,e[27]=y,e[28]=A,e[29]=M,e[30]=S,e[31]=C):C=e[31],C},vl=n=>{const e=de.c(50),{open:s,onClose:o,anchorRef:r}=n,{t:i}=me(),a=l.useRef(null),[c,u]=l.useState(s),[f,d]=l.useState(!1),{enabled:m}=vs(),g=l.useRef(null),[h,x]=l.useState(null);let j,b;e[0]!==r||e[1]!==m||e[2]!==s||e[3]!==c?(j=()=>{if(!s||!m||!c)return;const F=()=>{const ae=r.current?.getBoundingClientRect(),pe=g.current?.getBoundingClientRect();if(!ae||!pe){x(null);return}const oe=ae.left-pe.left;x(Math.min(Math.max(oe,8),Math.max(8,pe.width-En-8)))};F();const Z=g.current;if(typeof ResizeObserver>"u"||!Z)return;const te=new ResizeObserver(F);return te.observe(Z),()=>te.disconnect()},b=[r,m,s,c],e[0]=r,e[1]=m,e[2]=s,e[3]=c,e[4]=j,e[5]=b):(j=e[4],b=e[5]),l.useLayoutEffect(j,b);const I=m&&h!==null,S=je(wl),E=je(jl),T=Oe(kl);let k;e[6]===Symbol.for("react.memo_cache_sentinel")?(k={maxParents:bl},e[6]=k):k=e[6];const P=To(s||c,k);let w,R;e[7]!==s||e[8]!==c?(w=()=>{if(s){ws(),u(!0),d(!1);return}if(!c)return;d(!0);const F=window.setTimeout(()=>{u(!1),d(!1)},140);return()=>window.clearTimeout(F)},R=[s,c],e[7]=s,e[8]=c,e[9]=w,e[10]=R):(w=e[9],R=e[10]),l.useEffect(w,R);let y,A;e[11]!==o||e[12]!==s?(y=()=>{if(!s)return;const F=Z=>{Z.key==="Escape"&&o()};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},A=[o,s],e[11]=o,e[12]=s,e[13]=y,e[14]=A):(y=e[13],A=e[14]),l.useEffect(y,A);let M,C;e[15]!==r||e[16]!==o||e[17]!==s?(M=()=>{if(!s)return;const F=Z=>{const te=Z.target;if(!(te instanceof Node)){o();return}a.current?.contains(te)||r.current?.contains(te)||o()};return document.addEventListener("pointerdown",F,!0),()=>document.removeEventListener("pointerdown",F,!0)},C=[r,o,s],e[15]=r,e[16]=o,e[17]=s,e[18]=M,e[19]=C):(M=e[18],C=e[19]),l.useEffect(M,C);let N;e[20]!==o||e[21]!==E?(N=F=>{E(F.id,ys(F)),o()},e[20]=o,e[21]=E,e[22]=N):N=e[22];const H=N;if(!c)return null;let $;e[23]!==i?($=i("sessions.switcher.openAria"),e[23]=i,e[24]=$):$=e[24];const v=I?"absolute origin-top-left":"mx-3 mt-2",_=f?"pointer-events-none":"pointer-events-auto";let O;e[25]!==v||e[26]!==_?(O=J("flex flex-col overflow-hidden rounded-[20px] border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",v,_),e[25]=v,e[26]=_,e[27]=O):O=e[27];const z=`${f?"session-switcher-out":"session-switcher-in"} ${f?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let L;e[28]!==h||e[29]!==I?(L=I?{top:8,left:h??8,width:`min(${En}px, calc(100% - 16px))`}:null,e[28]=h,e[29]=I,e[30]=L):L=e[30];let ee;e[31]!==z||e[32]!==L?(ee={animation:z,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...L},e[31]=z,e[32]=L,e[33]=ee):ee=e[33];let Q;e[34]!==S||e[35]!==H||e[36]!==P||e[37]!==T||e[38]!==i?(Q=P.length===0?t.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:i("sessions.switcher.empty")}):P.map(F=>{const Z=F.node.session,te=[F.secondaryMeta?.projectLabel,F.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return t.jsx(yl,{session:Z,meta:te,active:Z.id===S,onSelect:()=>{F.projectId&&T(F.projectId),H(Z)}},Z.id)}),e[34]=S,e[35]=H,e[36]=P,e[37]=T,e[38]=i,e[39]=Q):Q=e[39];let D;e[40]!==Q?(D=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]=D):D=e[41];let X;e[42]!==$||e[43]!==O||e[44]!==ee||e[45]!==D?(X=t.jsx("div",{ref:a,role:"dialog","aria-label":$,className:O,style:ee,children:D}),e[42]=$,e[43]=O,e[44]=ee,e[45]=D,e[46]=X):X=e[46];let q;e[47]===Symbol.for("react.memo_cache_sentinel")?(q=t.jsx("style",{children:`
|
|
14
|
+
@keyframes session-switcher-in {
|
|
15
|
+
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
16
|
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
17
|
+
}
|
|
18
|
+
@keyframes session-switcher-out {
|
|
19
|
+
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
20
|
+
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
21
|
+
}
|
|
22
|
+
`}),e[47]=q):q=e[47];let G;return e[48]!==X?(G=t.jsxs("div",{ref:g,className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[X,q]}),e[48]=X,e[49]=G):G=e[49],G};function wl(n){return n.currentSessionId}function jl(n){return n.setCurrentSession}function kl(n){return n.setActiveProjectIdOnly}const Sl=n=>{const e=de.c(71),{onOpenSessions:s,onOpenWorkspace:o,compactTitle:r}=n,i=r===void 0?!1:r,{t:a}=me(),[c,u]=l.useState(!1),[f,d]=l.useState(!1),m=l.useRef(null),g=Xe(Nl),h=je(Cl);let x;e[0]!==h?(x=Ie=>h?Ie.getDirectoryForSession(h):null,e[0]=h,e[1]=x):x=e[1];const b=je(x)||g,I=Io(h,b||void 0),S=je(El);let E;e[2]!==I?.title?(E=I?.title?.trim(),e[2]=I?.title,e[3]=E):E=e[3];const T=E;let k;e[4]!==h||e[5]!==T||e[6]!==a?(k=T||a(h?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[4]=h,e[5]=T,e[6]=a,e[7]=k):k=e[7];const P=k;let w;e[8]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{u(!1),d(!1)},e[8]=w):w=e[8];let R;e[9]!==h||e[10]!==b?(R=[h,b],e[9]=h,e[10]=b,e[11]=R):R=e[11],l.useEffect(w,R);let y;e[12]!==s?(y=()=>{u(!1),d(!1),s()},e[12]=s,e[13]=y):y=e[13];const A=y;let M;e[14]===Symbol.for("react.memo_cache_sentinel")?(M=Ie=>{u(_e=>{const ve=typeof Ie=="function"?Ie(_e):Ie;return ve&&d(!1),ve})},e[14]=M):M=e[14];const C=M;let N;e[15]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{d(Ie=>{const _e=!Ie;return _e&&u(!1),_e})},e[15]=N):N=e[15];const H=N;let $;e[16]===Symbol.for("react.memo_cache_sentinel")?($={paddingTop:"var(--oc-safe-area-top, 0px)"},e[16]=$):$=e[16];let v;e[17]!==a?(v=a("mobile.sessions.openSheetAria"),e[17]=a,e[18]=v):v=e[18];let _,O;e[19]===Symbol.for("react.memo_cache_sentinel")?(_={touchAction:"manipulation"},O=t.jsx(se,{name:"list-unordered",className:"size-5"}),e[19]=_,e[20]=O):(_=e[19],O=e[20]);let z;e[21]!==A||e[22]!==v?(z=t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":v,onClick:A,style:_,children:O}),e[21]=A,e[22]=v,e[23]=z):z=e[23];const L=i?"shrink":"flex-1";let ee;e[24]!==L?(ee=J("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",L),e[24]=L,e[25]=ee):ee=e[25];let Q;e[26]!==a?(Q=a("sessions.switcher.openAria"),e[26]=a,e[27]=Q):Q=e[27];let D;e[28]===Symbol.for("react.memo_cache_sentinel")?(D={touchAction:"manipulation"},e[28]=D):D=e[28];let X;e[29]!==P?(X=t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:P}),e[29]=P,e[30]=X):X=e[30];const q=f&&"rotate-180";let G;e[31]!==q?(G=J("size-4 shrink-0 text-muted-foreground transition-transform duration-150",q),e[31]=q,e[32]=G):G=e[32];let F;e[33]!==G?(F=t.jsx(se,{name:"arrow-down-s",className:G}),e[33]=G,e[34]=F):F=e[34];let Z;e[35]!==X||e[36]!==F?(Z=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[X,F]}),e[35]=X,e[36]=F,e[37]=Z):Z=e[37];let te;e[38]!==f||e[39]!==ee||e[40]!==Q||e[41]!==Z?(te=t.jsx("button",{ref:m,type:"button",className:ee,"aria-label":Q,"aria-haspopup":"dialog","aria-expanded":f,onClick:H,style:D,children:Z}),e[38]=f,e[39]=ee,e[40]=Q,e[41]=Z,e[42]=te):te=e[42];let ae;e[43]!==i?(ae=i?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[43]=i,e[44]=ae):ae=e[44];let pe;e[45]!==h||e[46]!==b||e[47]!==S||e[48]!==c?(pe=t.jsx(gl,{open:c,onOpenChange:C,currentSessionId:h,effectiveDirectory:b,isNewSessionDraftOpen:S}),e[45]=h,e[46]=b,e[47]=S,e[48]=c,e[49]=pe):pe=e[49];let oe;e[50]!==a?(oe=a("mobile.header.openWorkspaceAria"),e[50]=a,e[51]=oe):oe=e[51];let W;e[52]!==o?(W=()=>{u(!1),d(!1),o()},e[52]=o,e[53]=W):W=e[53];let ie,U;e[54]===Symbol.for("react.memo_cache_sentinel")?(ie={touchAction:"manipulation"},U=t.jsx(se,{name:"pencil-ruler-2",className:"size-5"}),e[54]=ie,e[55]=U):(ie=e[54],U=e[55]);let fe;e[56]!==oe||e[57]!==W?(fe=t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":oe,onClick:W,style:ie,children:U}),e[56]=oe,e[57]=W,e[58]=fe):fe=e[58];let Ne;e[59]!==z||e[60]!==te||e[61]!==ae||e[62]!==pe||e[63]!==fe?(Ne=t.jsx("header",{className:"oc-mobile-header relative z-30 flex shrink-0 items-center gap-1 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",style:$,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[z,te,ae,pe,fe]})}),e[59]=z,e[60]=te,e[61]=ae,e[62]=pe,e[63]=fe,e[64]=Ne):Ne=e[64];let ke;e[65]===Symbol.for("react.memo_cache_sentinel")?(ke=()=>d(!1),e[65]=ke):ke=e[65];let Ae;e[66]!==f?(Ae=t.jsx(vl,{open:f,onClose:ke,anchorRef:m}),e[66]=f,e[67]=Ae):Ae=e[67];let Be;return e[68]!==Ne||e[69]!==Ae?(Be=t.jsxs(t.Fragment,{children:[Ne,Ae]}),e[68]=Ne,e[69]=Ae,e[70]=Be):Be=e[70],Be};function Nl(n){return n.currentDirectory}function Cl(n){return n.currentSessionId}function El(n){return!!n.newSessionDraft?.open}const Rl=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=me(),o=Er(e),{connections:r,isBusy:i,isPasswordBusy:a,error:c,pendingConnection:u,connect:f,submitPassword:d,cancelPassword:m,saveConnection:g,removeConnection:h,setError:x}=o,[j,b]=l.useState(null),I=j?r.find(W=>W.id===j)??null:null,[S,E]=l.useState(null),[T,k]=l.useState(""),[P,w]=l.useState(""),[R,y]=l.useState(""),[A,M]=l.useState(""),[C,N]=l.useState(!1),[H,$]=l.useState(!1),v=l.useRef(null),_=l.useMemo(()=>ms(),[]),[O,z]=l.useState(!1),[L,ee]=l.useState(null),[Q,D]=l.useState(!1),X=br(l.useCallback(()=>D(!0),[])),q=l.useCallback(()=>{b(null),k(""),w(""),y(""),x(null),z(!1)},[x]),G=l.useCallback(W=>{W.preventDefault(),g({id:j??void 0,url:T,label:P,clientToken:R}).then(ie=>{ie&&q()})},[R,j,P,q,g,T]),F=l.useCallback(async()=>{if(v.current)return;x(null),N(!0);const W=new AbortController;v.current=W;try{const ie=await Ir({signal:W.signal});switch(v.current===W&&(v.current=null,N(!1)),ie.status){case"ok":k(ie.url),ie.label&&w(ie.label),ie.clientToken&&y(ie.clientToken),z(!0);break;case"pairing":$(!0),await o.redeemPairingConnection(ie.pairing);break;case"permission-denied":x(s("mobile.connect.scan.permissionDenied"));break;case"invalid":x(s("mobile.connect.scan.invalid"));break;case"unsupported":x(s("mobile.connect.scan.unsupported"));break;case"failed":x(s("mobile.connect.scan.failed"));break;default:break}}finally{$(!1),v.current===W&&(v.current=null,N(!1))}},[o,x,s]);l.useEffect(()=>()=>v.current?.abort(),[]);const Z=l.useCallback(W=>{W.preventDefault(),d(A)},[A,d]),te=l.useCallback(()=>{M(""),m()},[m]),ae=l.useCallback(W=>{E(ie=>ie===W?null:W)},[]),pe=l.useCallback(W=>{E(null),j===W&&q();const ie=r.length===1;h(W).then(U=>{U&&(ie||Sn(U))&&n()})},[r.length,j,n,h,q]),oe=Rt;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:Z,children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(se,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:u.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:u.candidates.some(W=>W.kind==="direct")?Ge(u):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...ft,value:A,onChange:W=>M(W.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:oe}),c?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:c}):null,t.jsx(xe,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!A.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(xe,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:te,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[C?t.jsx(_r,{onCancel:()=>v.current?.abort()}):null,H?t.jsx(Dr,{}):null,Q?t.jsx(Rr,{onClose:()=>D(!1)}):null,t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:t.jsxs("div",{className:"space-y-6",children:[r.length>0?t.jsx("div",{...X,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(W=>{const ie=S===W.id,U=Sn(W),fe=L===W.id,Ne=fe?s("mobile.connect.connecting"):U?Dt()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):W.candidates.some(ke=>ke.kind==="direct")?Ge(W):s("mobile.connect.relay.badge");return t.jsxs("div",{className:J("flex items-center border-b border-border/70 transition-colors last:border-b-0",ie&&"bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-3 px-3.5 py-3 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-60",onClick:()=>{U||(ee(W.id),f({id:W.id,candidates:W.candidates,clientToken:W.clientToken,label:W.label}).finally(()=>ee(null)))},disabled:i&&!fe||ie,children:[t.jsxs("span",{className:"relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:[t.jsx(se,{name:"server",className:"size-[18px]"}),U?t.jsx("span",{className:"absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--status-success)]","aria-hidden":!0}):null]}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:W.label}),t.jsx("span",{className:J("block truncate typography-small",U&&!fe?"text-[var(--status-success)]":"text-muted-foreground"),children:Ne})]}),fe?t.jsx(se,{name:"loader-4",className:"size-5 shrink-0 animate-spin text-muted-foreground"}):null]}),t.jsxs("div",{className:"flex items-center gap-0.5 pr-2",children:[ie?t.jsxs("button",{type:"button","aria-label":s("mobile.instances.confirmDeleteAria",{label:W.label}),className:"flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-destructive px-3 text-destructive-foreground transition-opacity active:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive",onClick:()=>pe(W.id),style:{touchAction:"manipulation"},children:[t.jsx(se,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:s("mobile.instances.delete")})]}):W.candidates.some(ke=>ke.kind==="direct")?t.jsx("button",{type:"button","aria-label":s("mobile.instances.edit"),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>{b(W.id),k(Ge(W)),w(W.label),y(W.clientToken||""),x(null)},style:{touchAction:"manipulation"},children:t.jsx(se,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":ie?s("mobile.instances.cancelDeleteAria",{label:W.label}):s("mobile.instances.deleteAria",{label:W.label}),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>ae(W.id),style:{touchAction:"manipulation"},children:t.jsx(se,{name:ie?"close":"delete-bin",className:"size-[18px]"})})]})]},W.id)})}):t.jsx("p",{...X,className:"rounded-[18px] border border-dashed border-border/70 px-4 py-6 text-center typography-small text-muted-foreground",children:s("mobile.connect.saved.empty")}),!O&&!I?t.jsxs("div",{className:"space-y-2",children:[_?t.jsxs(xe,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{F()},disabled:C,children:[t.jsx(se,{name:"scan-2",className:J("size-[18px]",C&&"animate-pulse")}),s("mobile.connect.scanQr")]}):null,t.jsxs(xe,{type:"button",variant:_?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{x(null),z(!0)},children:[t.jsx(se,{name:"add",className:"size-[18px]"}),s("mobile.instances.addManual")]}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:G,children:[t.jsxs("div",{className:"flex h-8 items-center justify-between gap-3 px-1",children:[t.jsx("h3",{className:"typography-ui-label text-foreground",children:s(I?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(xe,{type:"button",variant:"ghost",size:"xs",onClick:q,children:s("mobile.instances.cancelEdit")})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.connect.url.label")}),t.jsx("input",{...ft,value:T,onChange:W=>k(W.target.value),placeholder:s("mobile.connect.url.placeholder"),type:"url",inputMode:"url",autoCapitalize:"none",className:oe})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.instances.label.label")}),t.jsx("input",{value:P,onChange:W=>w(W.target.value),placeholder:s("mobile.instances.label.placeholder"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,className:oe})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.connect.token.label")}),t.jsx("input",{...ft,value:R,onChange:W=>y(W.target.value),placeholder:s("mobile.connect.token.placeholder"),autoCapitalize:"none",className:oe}),t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")})]}),c?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:c}):null,t.jsx(xe,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(I?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},Se=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),rs=n=>{const e=Se(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},Rn=Ls(n=>({expandedParents:{},toggleParent:e=>n(s=>{const o={...s.expandedParents};return o[e]?delete o[e]:o[e]=!0,{expandedParents:o}})})),Ft=Ls()(pr(n=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,s)=>n(o=>({projectExpanded:{...o.projectExpanded,[e]:s}})),setWorktreeExpanded:(e,s)=>n(o=>({worktreeExpanded:{...o.worktreeExpanded,[e]:s}}))}),{name:"mobile-session-tree"})),ps=Ls()(pr(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(o=>({orderByProject:{...o.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),Pn=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Pl=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((r,i)=>[Pn(r),i])),o=r=>s.get(Pn(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)},Pt=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),Tl=n=>{const e=n;return Pt(e.directory??e.project?.worktree??null)},zr=({open:n,project:e,worktree:s,onClose:o,onDeleted:r})=>{const{t:i}=me(),a=tr(),c=xs(y=>y.activeSessions),u=je(y=>y.archiveSessions),f=Xe(y=>y.currentDirectory),[d,m]=l.useState(!1),[g,h]=l.useState(!1),[x,j]=l.useState(!1),[b,I]=l.useState(!1),S=Pt(s?.path),E=typeof s?.branch=="string"&&s.branch.trim().length>0,T=l.useMemo(()=>{if(!S)return[];const y=new Map;for(const A of[...c,...a])Tl(A)===S&&y.set(A.id,A);return Array.from(y.values())},[c,a,S]);l.useEffect(()=>{if(!n){m(!1),h(!1),j(!1),I(!1);return}if(!s?.path)return;let y=!1;return _o(s.path).then(A=>{y||j(!!A?.isDirty)}).catch(()=>{y||j(!!s.status?.isDirty)}),()=>{y=!0}},[n,s?.path,s?.status?.isDirty]);const k=l.useCallback(y=>{(async()=>{try{await Do(e,y,{deleteRemoteBranch:E&&g,deleteLocalBranch:E&&d}),Pt(f)===S&&Pt(e.path)&&Xe.getState().setDirectory(Pt(e.path),{showOverlay:!1}),ue.success(i("sessions.sidebar.sessionDialogs.worktree.removedTitle"),{description:i(E&&g?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),r?.()}catch(A){ue.error(i("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:A instanceof Error?A.message:i("sessions.sidebar.dialogs.deleteResult.tryAgain")})}})()},[f,d,g,E,r,e,i,S]),P=async()=>{if(!(!s||b)){I(!0);try{if(T.length>0){const{archivedIds:y,failedIds:A}=await u(T.map(M=>M.id));if(A.length>0){y.length>0&&ue.success(y.length===1?i("sessions.sidebar.bulkActions.archivedSingle",{count:y.length}):i("sessions.sidebar.bulkActions.archivedPlural",{count:y.length})),ue.error(A.length===1?i("sessions.sidebar.bulkActions.failedArchiveSingle",{count:A.length}):i("sessions.sidebar.bulkActions.failedArchivePlural",{count:A.length}),{description:i("sessions.sidebar.dialogs.deleteResult.tryAgain")}),I(!1);return}}k(s),o()}catch(y){ue.error(i("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:y instanceof Error?y.message:i("sessions.sidebar.dialogs.deleteResult.tryAgain")}),I(!1)}finally{n||I(!1)}}};if(!s)return null;const w=s.branch||s.label||s.path,R=(y,A,M,C)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":y,disabled:C,onClick:()=>A(!y),className:J("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",C&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:M}),t.jsx("span",{className:J("relative h-6 w-10 shrink-0 rounded-full transition-colors",y?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:J("absolute top-0.5 size-5 rounded-full bg-white transition-transform",y?"translate-x-[1.125rem]":"translate-x-0.5")})})]});return t.jsx(Mo,{open:n,onClose:o,title:i("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(xe,{variant:"ghost",className:"flex-1",onClick:o,disabled:b,children:i("projectEditDialog.actions.cancel")}),t.jsx(xe,{variant:"destructive",className:"flex-1",onClick:()=>{P()},disabled:b,children:i("mobile.projectEdit.deleteWorktreeConfirmButton")})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx("p",{className:"typography-ui-body text-foreground",children:i("mobile.projectEdit.deleteWorktreeConfirm",{name:w})}),x?t.jsx("p",{className:"rounded-xl border border-[var(--warning)]/40 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] px-3.5 py-3 typography-meta text-foreground",children:i("mobile.projectEdit.deleteWorktreeDirty")}):null,T.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i("mobile.projectEdit.deleteWorktreeArchiveNote",{count:T.length})}):null,E?t.jsxs("div",{className:"flex flex-col gap-2",children:[R(d,m,i("mobile.projectEdit.deleteLocalBranch"),b),R(g,h,i("mobile.projectEdit.deleteRemoteBranch"),b)]}):null]})})},Tn="mobile-surface-root",os=16,Wt=200,Al=()=>{if(typeof document>"u")return null;let n=document.getElementById(Tn);return n||(n=document.createElement("div"),n.id=Tn,document.body.appendChild(n)),n},Tt=({open:n,onClose:e,title:s,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}=me(),h=l.useRef(null),[x,j]=l.useState(!1),[b,I]=l.useState(!1),S=l.useRef(null),E=l.useRef(null),T=l.useRef(e);if(l.useEffect(()=>{T.current=e},[e]),typeof document<"u"&&!h.current&&(h.current=Al()),l.useEffect(()=>{if(!n){j(!1);return}const w=window.setTimeout(()=>j(!0),os);return()=>window.clearTimeout(w)},[n]),l.useEffect(()=>{if(!n){I(!1);return}const w=window.setTimeout(()=>I(!0),os+Wt+80);return()=>window.clearTimeout(w)},[n]),l.useEffect(()=>{if(!n)return;const w=document.body.style.overflow;E.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const R=()=>{const M=S.current;if(!M)return;(M.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??M).focus({preventScroll:!0})},y=window.setTimeout(R,os),A=M=>{if(M.key==="Escape"&&!i){T.current();return}if(M.key!=="Tab")return;const C=S.current;if(!C)return;const N=Array.from(C.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(_=>!_.hasAttribute("disabled")&&_.getAttribute("aria-hidden")!=="true");if(N.length===0){M.preventDefault(),C.focus({preventScroll:!0});return}const H=N[0],$=N[N.length-1],v=document.activeElement;M.shiftKey&&v===H?(M.preventDefault(),$.focus({preventScroll:!0})):!M.shiftKey&&v===$&&(M.preventDefault(),H.focus({preventScroll:!0}))};return document.addEventListener("keydown",A),()=>{window.clearTimeout(y),document.body.style.overflow=w,document.removeEventListener("keydown",A),E.current?.focus?.({preventScroll:!0}),E.current=null}},[i,n]),!n||!h.current)return null;const k=f==="dialog",P=t.jsxs("section",{ref:S,role:"dialog","aria-modal":"true","aria-label":u,tabIndex:-1,className:J("flex flex-col bg-background text-foreground",k?"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:k?{opacity:x?1:0,transform:x?"none":"scale(0.97)",transition:`opacity ${Wt}ms ease-out, transform ${Wt}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:x?"none":"translateX(100%)",transition:`transform ${Wt}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:w=>{x&&w.target===w.currentTarget&&w.propertyName==="transform"&&I(!0)},children:[a?null:t.jsxs("header",{className:J("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!c&&"border-b border-border/70"),children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":g("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(se,{name:"close",className:"size-5"})}),t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[s?typeof s=="string"?t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:s}):s:null,o?typeof o=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:o}):o:null]}),r?t.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:r}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:b?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:m}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return k?mt.createPortal(t.jsx("div",{className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex items-center justify-center p-4 transition-opacity duration-200 ease-out",style:{background:"rgb(0 0 0 / 0.45)",opacity:x?1:0,paddingLeft: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:w=>w.stopPropagation(),children:P})}),h.current):mt.createPortal(P,h.current)},Il=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),_l=n=>{const e=de.c(36),{worktree:s,onDelete:o}=n,{t:r}=me();let i;e[0]!==s.path?(i={id:s.path},e[0]=s.path,e[1]=i):i=e[1];const{attributes:a,listeners:c,setNodeRef:u,transform:f,transition:d,isDragging:m}=zs(i);let g;e[2]!==f?(g=Os.Transform.toString(f),e[2]=f,e[3]=g):g=e[3];const h=m?10:1;let x;e[4]!==g||e[5]!==h||e[6]!==d?(x={transform:g,transition:d,zIndex:h},e[4]=g,e[5]=h,e[6]=d,e[7]=x):x=e[7];const j=x,b=s.branch||s.label||s.path,I=m&&"shadow-lg shadow-black/20";let S;e[8]!==I?(S=J("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",I),e[8]=I,e[9]=S):S=e[9];let E;e[10]!==b||e[11]!==r?(E=r("mobile.projectEdit.dragWorktreeAria",{label:b}),e[10]=b,e[11]=r,e[12]=E):E=e[12];let T;e[13]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Cs,{className:"size-4"}),e[13]=T):T=e[13];let k;e[14]!==a||e[15]!==c||e[16]!==E?(k=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":E,...a,...c,children:T}),e[14]=a,e[15]=c,e[16]=E,e[17]=k):k=e[17];let P;e[18]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(se,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[18]=P):P=e[18];let w;e[19]!==b?(w=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:b}),e[19]=b,e[20]=w):w=e[20];let R;e[21]!==b||e[22]!==r?(R=r("mobile.projectEdit.deleteWorktreeAria",{label:b}),e[21]=b,e[22]=r,e[23]=R):R=e[23];let y,A;e[24]===Symbol.for("react.memo_cache_sentinel")?(y={touchAction:"manipulation"},A=t.jsx(Kt,{className:"size-4"}),e[24]=y,e[25]=A):(y=e[24],A=e[25]);let M;e[26]!==o||e[27]!==R?(M=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive","aria-label":R,onClick:o,style:y,children:A}),e[26]=o,e[27]=R,e[28]=M):M=e[28];let C;return e[29]!==u||e[30]!==j||e[31]!==w||e[32]!==M||e[33]!==S||e[34]!==k?(C=t.jsxs("div",{ref:u,style:j,className:S,children:[k,P,w,M]}),e[29]=u,e[30]=j,e[31]=w,e[32]=M,e[33]=S,e[34]=k,e[35]=C):C=e[35],C},Dl=({open:n,project:e,onClose:s,onWorktreesChanged:o})=>{const{t:r}=me(),{currentTheme:i}=sr(),a=Oe(v=>v.updateProjectMeta),c=Oe(v=>v.discoverProjectIcon),u=Oe(v=>v.removeProjectIcon),f=ps(v=>v.setWorktreeOrder),d=Oe(v=>e?v.projects.find(_=>_.id===e.id)?.iconImage??null:null),[m,g]=l.useState(""),[h,x]=l.useState(null),[j,b]=l.useState(null),[I,S]=l.useState(!1),[E,T]=l.useState([]),[k,P]=l.useState(null),w=e?.id??null;l.useEffect(()=>{!n||!e||(g(e.label),x(e.icon??null),b(e.color??null),T(e.worktrees))},[n,w]),l.useEffect(()=>{!n||!e||T(v=>{const _=e.worktrees.map(L=>L.path),O=v.map(L=>L.path);return _.length===O.length&&_.every(L=>O.includes(L))?v:e.worktrees})},[e?.worktrees]);const R=Rs(ht(Ts,{activationConstraint:{distance:8}}),ht(Ps,{coordinateGetter:_s})),y=()=>{if(!e)return;const v=m.trim();a(e.id,{label:v||e.label,icon:h,color:j}),s()},A=()=>{!e||I||(S(!0),c(e.id).then(v=>{if(!v.ok){ue.error(v.error||r("projectEditDialog.toast.failedToDiscoverIcon"));return}if(v.skipped){ue.success(r("projectEditDialog.toast.customIconAlreadySet"));return}ue.success(r("projectEditDialog.toast.iconDiscovered"))}).finally(()=>S(!1)))},M=()=>{e&&u(e.id).then(v=>{if(!v.ok){ue.error(v.error||r("projectEditDialog.toast.failedToRemoveIcon"));return}ue.success(r("projectEditDialog.toast.iconRemoved"))})},C=v=>{const{active:_,over:O}=v;if(!O||_.id===O.id||!e)return;const z=E.findIndex(D=>D.path===_.id),L=E.findIndex(D=>D.path===O.id);if(z<0||L<0)return;const ee=[...E],[Q]=ee.splice(z,1);ee.splice(L,0,Q),T(ee),f(e.id,ee.map(D=>Il(D.path)))},N=j?nr[j]??null:null,H=h?rr[h]:null,$=!!d;return t.jsxs(t.Fragment,{children:[t.jsx(Tt,{open:n,onClose:s,title:r("projectEditDialog.title"),ariaLabel:r("projectEditDialog.title"),noHeaderBorder:!0,trailing:t.jsxs(xe,{type:"button",variant:"default",size:"sm","aria-label":r("projectEditDialog.actions.save"),onClick:y,disabled:!m.trim(),style:{touchAction:"manipulation"},children:[t.jsx(dr,{className:"size-4"}),r("projectEditDialog.actions.save")]}),children:e?t.jsxs("div",{className:"h-full space-y-6 overflow-y-auto px-4 pb-8 pt-2",children:[t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx("span",{className:"flex size-16 items-center justify-center overflow-hidden rounded-2xl bg-[var(--surface-muted)] text-muted-foreground",style:e.iconBackground?{backgroundColor:e.iconBackground}:void 0,children:$?t.jsx(or,{project:{id:e.id,iconImage:d},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(us,{className:"size-7"})}):H?t.jsx(se,{name:H,className:"size-7",style:N?{color:N}:void 0}):t.jsx(us,{className:"size-7",style:N?{color:N}: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(js,{value:m,onChange:v=>g(v.target.value),placeholder:r("projectEditDialog.field.namePlaceholder"),className:"h-11"}),t.jsx("p",{className:"truncate typography-meta text-muted-foreground",title:e.path,children:e.path})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.color")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>b(null),"aria-label":r("projectEditDialog.option.none"),className:J("flex size-9 items-center justify-center rounded-xl border-2 transition-all",j===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"})}),zo.map(v=>t.jsx("button",{type:"button",onClick:()=>b(v.key),"aria-label":v.label,title:v.label,className:J("size-9 rounded-xl border-2 transition-all",j===v.key?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:v.cssVar,touchAction:"manipulation"}},v.key))]})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.icon")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>x(null),"aria-label":r("projectEditDialog.option.none"),className:J("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===null?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),Oo.map(v=>t.jsx("button",{type:"button",onClick:()=>x(v.key),"aria-label":v.label,title:v.label,className:J("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===v.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(se,{name:v.Icon,className:"size-4",style:N?{color:N}:void 0})},v.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(xe,{size:"sm",variant:"outline",onClick:A,disabled:I,children:r(I?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),$?t.jsx(xe,{size:"sm",variant:"outline",onClick:M,children:r("projectEditDialog.actions.removeProjectIcon")}):null]})]}),e.isGitRepo?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("mobile.projectEdit.worktreesTitle")}),E.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(As,{sensors:R,collisionDetection:Is,onDragEnd:C,children:t.jsx(Ds,{items:E.map(v=>v.path),strategy:Ms,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:E.map(v=>t.jsx(_l,{worktree:v,onDelete:()=>P(v)},v.path))})})})]})]}):null]}):null}),e?t.jsx(zr,{open:!!k,project:{id:e.id,path:e.path},worktree:k,onClose:()=>P(null),onDeleted:()=>{T(v=>v.filter(_=>_.path!==k?.path)),o?.()}}):null]})},Ml=new Set,is=7,An=40,zl=16,Nt=n=>n.parentID??null,at=n=>{const e=n;return Se(e.directory??e.project?.worktree??null)},Ol=n=>{const e=n.time?.updated??n.time?.created,s=typeof e=="number"?e:Number(e);return Number.isFinite(s)&&s>0?s:0},Ll=n=>{if(n<=0)return"";const e=Date.now()-n;if(e<6e4)return"now";const s=Math.floor(e/6e4);if(s<60)return`${s}m`;const o=Math.floor(s/60);if(o<24)return`${o}h`;const r=Math.floor(o/24);return r<7?`${r}d`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n))},Bl=(n,e)=>{const s=Se(n),o=Se(e);return!!(s&&o&&(s===o||s.startsWith(`${o}/`)))},Gt=(n,e)=>n.worktrees.find(s=>Se(s.path)===e)??null,hs=(n,e)=>e===n.path||!!Gt(n,e),as=(n,e)=>{const s=Se(e);return s?n.find(o=>hs(o,s))??null:null},ls=(n,e,s)=>ir([n.title,n.id,at(n),e],s),gs=n=>{const e=de.c(17),{project:s,size:o}=n,r=o===void 0?"md":o,{currentTheme:i}=sr(),a=s.icon?rr[s.icon]:null,c=s.color?nr[s.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(se,{name:a,className:f,style:c?{color:c}:void 0}):t.jsx(us,{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=J("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 h;e[6]!==s.iconBackground?(h=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[6]=s.iconBackground,e[7]=h):h=e[7];let x;e[8]!==i||e[9]!==m||e[10]!==s.iconImage||e[11]!==s.id?(x=s.iconImage?t.jsx(or,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:m}):m,e[8]=i,e[9]=m,e[10]=s.iconImage,e[11]=s.id,e[12]=x):x=e[12];let j;return e[13]!==g||e[14]!==h||e[15]!==x?(j=t.jsx("span",{className:g,style:h,children:x}),e[13]=g,e[14]=h,e[15]=x,e[16]=j):j=e[16],j},In=n=>{const e=de.c(2),{ariaLabel:s}=n;let o;return e[0]!==s?(o=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":s}),e[0]=s,e[1]=o):o=e[1],o},_n=n=>{const e=de.c(12),{onClick:s,className:o}=n,{t:r}=me();let i;e[0]!==r?(i=r("sessions.sidebar.project.actions.newWorktree"),e[0]=r,e[1]=i):i=e[1];const a=i;let c;e[2]!==o?(c=J("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]!==s?(u=g=>{g.stopPropagation(),s()},e[4]=s,e[5]=u):u=e[5];let f,d;e[6]===Symbol.for("react.memo_cache_sentinel")?(f={touchAction:"manipulation"},d=t.jsx(se,{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},it=144,Or=180,Dn=n=>{const e=de.c(25),{actionsWidth:s,actions:o,revealed:r,onRevealedChange:i,children:a}=n,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=(C,N)=>{const H=c.current;H&&(H.style.transition=N?`transform ${Or}ms ease-out`:"none",H.style.transform=C===0?"none":`translateX(${C}px)`,d.current=C)},e[0]=g):g=e[0];const h=g;let x,j;e[1]!==s||e[2]!==r?(x=()=>{m.current=r,h(r?-s:0,!0)},j=[s,h,r],e[1]=s,e[2]=r,e[3]=x,e[4]=j):(x=e[3],j=e[4]),l.useEffect(x,j);let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=C=>{if(C.touches.length!==1)return;const N=C.touches[0];u.current={x:N.clientX,y:N.clientY},f.current=!1},e[5]=b):b=e[5];const I=b;let S;e[6]!==s?(S=C=>{if(!u.current)return;const N=C.touches[0],H=N.clientX-u.current.x,$=N.clientY-u.current.y;if(!f.current){if(Math.abs(H)<8||Math.abs(H)<=Math.abs($))return;f.current=!0}const v=m.current?-s:0;h(Math.min(0,Math.max(-s,v+H)),!1)},e[6]=s,e[7]=S):S=e[7];const E=S;let T;e[8]!==s||e[9]!==i?(T=()=>{if(u.current=null,!f.current)return;f.current=!1;const C=d.current<-s/2;h(C?-s:0,!0),C!==m.current&&i(C)},e[8]=s,e[9]=i,e[10]=T):T=e[10];const k=T;let P;e[11]===Symbol.for("react.memo_cache_sentinel")?(P={touchAction:"pan-y"},e[11]=P):P=e[11];let w;e[12]!==s?(w={width:s},e[12]=s,e[13]=w):w=e[13];const R=!r;let y;e[14]!==o||e[15]!==w||e[16]!==R?(y=t.jsx("div",{className:"absolute inset-y-0 right-0 flex items-stretch",style:w,"aria-hidden":R,children:o}),e[14]=o,e[15]=w,e[16]=R,e[17]=y):y=e[17];let A;e[18]!==a?(A=t.jsx("div",{ref:c,className:"relative flex w-full items-center bg-background",children:a}),e[18]=a,e[19]=A):A=e[19];let M;return e[20]!==k||e[21]!==E||e[22]!==y||e[23]!==A?(M=t.jsxs("div",{className:"relative overflow-hidden",onTouchStart:I,onTouchMove:E,onTouchEnd:k,onTouchCancel:k,style:P,children:[y,A]}),e[20]=k,e[21]=E,e[22]=y,e[23]=A,e[24]=M):M=e[24],M},$l=n=>{const e=de.c(41),{initialTitle:s,indent:o,onSubmit:r,onCancel:i}=n,{t:a}=me(),[c,u]=l.useState(s);let f;e[0]!==s||e[1]!==i||e[2]!==r||e[3]!==c?(f=()=>{const C=c.trim();if(!C||C===s.trim()){i();return}r(C)},e[0]=s,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=C=>{C.preventDefault(),d()},e[7]=d,e[8]=g):g=e[8];let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=C=>u(C.target.value),e[9]=h):h=e[9];let x;e[10]!==i?(x=C=>{C.stopPropagation(),C.key==="Escape"&&i()},e[10]=i,e[11]=x):x=e[11];let j;e[12]!==a?(j=a("sessions.sidebar.session.rename.save"),e[12]=a,e[13]=j):j=e[13];let b;e[14]!==a?(b=a("sessions.sidebar.session.menu.rename"),e[14]=a,e[15]=b):b=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I={minHeight:0},e[16]=I):I=e[16];let S;e[17]!==x||e[18]!==j||e[19]!==b||e[20]!==c?(S=t.jsx("input",{autoFocus:!0,value:c,onChange:h,onKeyDown:x,"aria-label":j,placeholder:b,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:I,enterKeyHint:"done"}),e[17]=x,e[18]=j,e[19]=b,e[20]=c,e[21]=S):S=e[21];let E;e[22]!==a?(E=a("sessions.sidebar.session.rename.save"),e[22]=a,e[23]=E):E=e[23];let T,k;e[24]===Symbol.for("react.memo_cache_sentinel")?(T={touchAction:"manipulation",minHeight:0,minWidth:0},k=t.jsx(se,{name:"check",className:"size-4"}),e[24]=T,e[25]=k):(T=e[24],k=e[25]);let P;e[26]!==E?(P=t.jsx("button",{type:"submit","aria-label":E,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:T,children:k}),e[26]=E,e[27]=P):P=e[27];let w;e[28]!==a?(w=a("sessions.sidebar.session.rename.cancel"),e[28]=a,e[29]=w):w=e[29];let R,y;e[30]===Symbol.for("react.memo_cache_sentinel")?(R={touchAction:"manipulation",minHeight:0,minWidth:0},y=t.jsx(se,{name:"close",className:"size-4"}),e[30]=R,e[31]=y):(R=e[30],y=e[31]);let A;e[32]!==i||e[33]!==w?(A=t.jsx("button",{type:"button",onClick:i,"aria-label":w,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]=w,e[34]=A):A=e[34];let M;return e[35]!==P||e[36]!==A||e[37]!==m||e[38]!==g||e[39]!==S?(M=t.jsxs("form",{className:"flex h-9 min-w-0 flex-1 items-center gap-2 pr-2",style:m,onSubmit:g,children:[S,P,A]}),e[35]=P,e[36]=A,e[37]=m,e[38]=g,e[39]=S,e[40]=M):M=e[40],M},Mn=n=>{const e=de.c(51),{session:s,active:o,indent:r,contextLabel:i,hasChildren:a,expanded:c,onToggleChildren:u,onSelect:f,revealed:d,onRevealedChange:m,confirmingDelete:g,onArchive:h,onRequestDelete:x,onConfirmDelete:j,renaming:b,onRequestRename:I,onSubmitRename:S,onCancelRename:E}=n,T=a===void 0?!1:a,k=c===void 0?!1:c,P=d===void 0?!1:d,w=g===void 0?!1:g,R=b===void 0?!1:b,{t:y}=me();let A;e[0]!==s?(A=Ll(Ol(s)),e[0]=s,e[1]=A):A=e[1];const M=A,C=s.title?.trim()||y("mobile.sessions.untitled"),N=!!(m&&h),H=Qn(s.id),$=Zn(s.id),v=H?.type??"idle",_=v==="busy"||v==="retry",O=!_&&$>0&&!o,z=er(s.id,_),L=(_||O)&&z,ee=l.useRef(null),Q=l.useRef(null),D=l.useRef(!1),X=l.useRef(0),q=l.useRef(P);let G;e[2]===Symbol.for("react.memo_cache_sentinel")?(G=(le,Ce)=>{const be=ee.current;be&&(be.style.transition=Ce?`transform ${Or}ms ease-out`:"none",be.style.transform=le===0?"none":`translateX(${le}px)`,X.current=le)},e[2]=G):G=e[2];const F=G;let Z,te;e[3]!==P?(Z=()=>{q.current=P,F(P?-it:0,!0)},te=[F,P],e[3]=P,e[4]=Z,e[5]=te):(Z=e[4],te=e[5]),l.useEffect(Z,te);let ae;e[6]!==N?(ae=le=>{if(!N||le.touches.length!==1)return;const Ce=le.touches[0];Q.current={x:Ce.clientX,y:Ce.clientY},D.current=!1},e[6]=N,e[7]=ae):ae=e[7];const pe=ae;let oe;e[8]!==N?(oe=le=>{if(!N||!Q.current)return;const Ce=le.touches[0],be=Ce.clientX-Q.current.x,Fe=Ce.clientY-Q.current.y;if(!D.current){if(Math.abs(be)<8||Math.abs(be)<=Math.abs(Fe))return;D.current=!0}const Pe=q.current?-it:0,st=Math.min(0,Math.max(-it,Pe+be));F(st,!1)},e[8]=N,e[9]=oe):oe=e[9];const W=oe;let ie;e[10]!==m?(ie=()=>{if(Q.current=null,!D.current)return;D.current=!1;const le=X.current<-it/2;F(le?-it:0,!0),le!==q.current&&m?.(le)},e[10]=m,e[11]=ie):ie=e[11];const U=ie,fe=o||void 0,Ne="relative overflow-hidden";let ke;e[12]!==N?(ke=N?{touchAction:"pan-y"}:void 0,e[12]=N,e[13]=ke):ke=e[13];const Ae=N?t.jsxs("div",{className:"absolute inset-y-0 right-0 flex items-stretch",style:{width:it},"aria-hidden":!P,children:[t.jsx("button",{type:"button",tabIndex:P?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:C}),onClick:I,style:{touchAction:"manipulation"},children:t.jsx(ds,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:P?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:C}),onClick:h,style:{touchAction:"manipulation"},children:t.jsx(oa,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:P?0:-1,className:J("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",w?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":w?y("mobile.sessions.confirmDeleteSessionAria",{title:C}):y("mobile.sessions.deleteSessionAria",{title:C}),onClick:w?j:x,style:{touchAction:"manipulation"},children:t.jsx(Kt,{className:"size-[18px]"})})]}):null,Be=N&&"bg-background",Ie=o&&(N?"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]":"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]");let _e;e[14]!==Be||e[15]!==Ie?(_e=J("relative flex items-center gap-1 transition-colors",Be,Ie),e[14]=Be,e[15]=Ie,e[16]=_e):_e=e[16];let ve;e[17]!==k||e[18]!==T||e[19]!==r||e[20]!==_||e[21]!==u||e[22]!==O||e[23]!==y?(ve=_||O||T&&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(k?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!T||!u,onClick:le=>{le.stopPropagation(),u?.()},children:_||O?t.jsx("span",{className:J("size-1.5 rounded-full",_?"bg-primary":"bg-[var(--status-info)]"),"aria-hidden":!0}):t.jsx(Es,{className:J("size-[18px] transition-transform duration-150",k?"rotate-0":"-rotate-90")})}):null,e[17]=k,e[18]=T,e[19]=r,e[20]=_,e[21]=u,e[22]=O,e[23]=y,e[24]=ve):ve=e[24];let B;e[25]!==o||e[26]!==i||e[27]!==r||e[28]!==_||e[29]!==E||e[30]!==m||e[31]!==f||e[32]!==S||e[33]!==R||e[34]!==s.id||e[35]!==L||e[36]!==M||e[37]!==C?(B=R&&S&&E?t.jsx($l,{initialTitle:C,indent:r,onSubmit:S,onCancel:E}):t.jsx("button",{type:"button",className:J("flex min-w-0 flex-1 items-center gap-2.5 pr-3.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",i?"min-h-10 py-1":"h-9"),style:{paddingLeft:r,touchAction:"manipulation"},onClick:()=>{if(q.current){m?.(!1);return}f()},children:t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsxs("span",{className:"flex items-center gap-2.5",children:[t.jsx("span",{className:J("block min-w-0 flex-1 truncate typography-ui-label",o?"text-primary":"text-foreground"),children:C}),L?t.jsx(ur,{sessionId:s.id,running:_,className:"typography-micro"}):M?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:M}):null]}),i?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:i}):null]})}),e[25]=o,e[26]=i,e[27]=r,e[28]=_,e[29]=E,e[30]=m,e[31]=f,e[32]=S,e[33]=R,e[34]=s.id,e[35]=L,e[36]=M,e[37]=C,e[38]=B):B=e[38];let V;e[39]!==_e||e[40]!==ve||e[41]!==B?(V=t.jsxs("div",{ref:ee,className:_e,children:[ve,B]}),e[39]=_e,e[40]=ve,e[41]=B,e[42]=V):V=e[42];let re;return e[43]!==U||e[44]!==W||e[45]!==pe||e[46]!==fe||e[47]!==ke||e[48]!==Ae||e[49]!==V?(re=t.jsxs("div",{"data-active-session":fe,className:Ne,onTouchStart:pe,onTouchMove:W,onTouchEnd:U,onTouchCancel:U,style:ke,children:[Ae,V]}),e[43]=U,e[44]=W,e[45]=pe,e[46]=fe,e[47]=ke,e[48]=Ae,e[49]=V,e[50]=re):re=e[50],re},Fl=n=>{const e=de.c(11),{indent:s,onClick:o}=n,{t:r}=me();let i;e[0]!==s?(i={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(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},Wl=n=>{const e=de.c(11),{indent:s,onClick:o}=n,{t:r}=me();let i;e[0]!==s?(i={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(ia,{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},Ul=n=>{const e=de.c(29),{worktree:s}=n,{t:o}=me();let r;e[0]!==s.path?(r=Se(s.path),e[0]=s.path,e[1]=r):r=e[1];const i=r;let a;e[2]!==i?(a={id:i},e[2]=i,e[3]=a):a=e[3];const{attributes:c,listeners:u,setNodeRef:f,transform:d,transition:m,isDragging:g}=zs(a),h=s.branch||s.label||s.path;let x;e[4]!==d?(x=Os.Transform.toString(d),e[4]=d,e[5]=x):x=e[5];const j=g?10:1;let b;e[6]!==x||e[7]!==j||e[8]!==m?(b={transform:x,transition:m,zIndex:j},e[6]=x,e[7]=j,e[8]=m,e[9]=b):b=e[9];const I=g&&"shadow-lg shadow-black/20";let S;e[10]!==I?(S=J("flex items-center gap-1 rounded-xl bg-background px-1 py-1",I),e[10]=I,e[11]=S):S=e[11];let E;e[12]!==h||e[13]!==o?(E=o("mobile.sessions.dragHandleAria",{label:h}),e[12]=h,e[13]=o,e[14]=E):E=e[14];let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Cs,{className:"size-4"}),e[15]=T):T=e[15];let k;e[16]!==c||e[17]!==u||e[18]!==E?(k=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":E,...c,...u,children:T}),e[16]=c,e[17]=u,e[18]=E,e[19]=k):k=e[19];let P;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(se,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=P):P=e[20];let w;e[21]!==h?(w=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-bold text-muted-foreground",children:h}),e[21]=h,e[22]=w):w=e[22];let R;return e[23]!==f||e[24]!==k||e[25]!==w||e[26]!==b||e[27]!==S?(R=t.jsxs("div",{ref:f,style:b,className:S,children:[k,P,w]}),e[23]=f,e[24]=k,e[25]=w,e[26]=b,e[27]=S,e[28]=R):R=e[28],R},Vl=n=>{const e=de.c(61),{project:s,totalSessions:o,expanded:r,onToggleExpanded:i,onReorderWorktrees:a}=n,{t:c}=me();let u;e[0]!==s.id?(u={id:s.id},e[0]=s.id,e[1]=u):u=e[1];const{attributes:f,listeners:d,setNodeRef:m,transform:g,transition:h,isDragging:x}=zs(u);let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={activationConstraint:{distance:8}},e[2]=j):j=e[2];let b;e[3]===Symbol.for("react.memo_cache_sentinel")?(b={coordinateGetter:_s},e[3]=b):b=e[3];const I=Rs(ht(Ts,j),ht(Ps,b)),S=s.worktrees.length>0;let E;e[4]!==a||e[5]!==s.worktrees?(E=X=>{const{active:q,over:G}=X;if(!G||q.id===G.id)return;const F=s.worktrees.map(ql),Z=F.indexOf(String(q.id)),te=F.indexOf(String(G.id));if(Z<0||te<0)return;const ae=[...F],[pe]=ae.splice(Z,1);ae.splice(te,0,pe),a(ae)},e[4]=a,e[5]=s.worktrees,e[6]=E):E=e[6];const T=E;let k;e[7]!==g?(k=Os.Transform.toString(g),e[7]=g,e[8]=k):k=e[8];const P=x?10:1;let w;e[9]!==k||e[10]!==P||e[11]!==h?(w={transform:k,transition:h,zIndex:P},e[9]=k,e[10]=P,e[11]=h,e[12]=w):w=e[12];const R=x&&"shadow-lg shadow-black/20";let y;e[13]!==R?(y=J("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 A;e[15]!==s.label||e[16]!==c?(A=c("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=c,e[17]=A):A=e[17];let M;e[18]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(Cs,{className:"size-4"}),e[18]=M):M=e[18];let C;e[19]!==f||e[20]!==d||e[21]!==A?(C=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":A,...f,...d,children:M}),e[19]=f,e[20]=d,e[21]=A,e[22]=C):C=e[22];let N;e[23]!==r||e[24]!==s.label||e[25]!==c?(N=r?c("sessions.sidebar.group.collapseAria",{label:s.label}):c("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=r,e[24]=s.label,e[25]=c,e[26]=N):N=e[26];const H=!S;let $;e[27]===Symbol.for("react.memo_cache_sentinel")?($={touchAction:"manipulation"},e[27]=$):$=e[27];let v;e[28]!==s?(v=t.jsx(gs,{project:s}),e[28]=s,e[29]=v):v=e[29];let _;e[30]!==s.label?(_=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s.label}),e[30]=s.label,e[31]=_):_=e[31];let O;e[32]!==o?(O=t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:o}),e[32]=o,e[33]=O):O=e[33];let z;e[34]!==r||e[35]!==S?(z=S?t.jsx(Es,{className:J("size-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-180")}):null,e[34]=r,e[35]=S,e[36]=z):z=e[36];let L;e[37]!==r||e[38]!==i||e[39]!==N||e[40]!==H||e[41]!==v||e[42]!==_||e[43]!==O||e[44]!==z?(L=t.jsxs("button",{type:"button",className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 rounded-xl px-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",onClick:i,"aria-expanded":r,"aria-label":N,disabled:H,style:$,children:[v,_,O,z]}),e[37]=r,e[38]=i,e[39]=N,e[40]=H,e[41]=v,e[42]=_,e[43]=O,e[44]=z,e[45]=L):L=e[45];let ee;e[46]!==C||e[47]!==L?(ee=t.jsxs("div",{className:"flex items-center gap-1",children:[C,L]}),e[46]=C,e[47]=L,e[48]=ee):ee=e[48];let Q;e[49]!==r||e[50]!==T||e[51]!==S||e[52]!==s.worktrees||e[53]!==I?(Q=r&&S?t.jsx(As,{sensors:I,collisionDetection:Is,onDragEnd:T,children:t.jsx(Ds,{items:s.worktrees.map(Yl),strategy:Ms,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 pl-3",children:s.worktrees.map(Jl)})})}):null,e[49]=r,e[50]=T,e[51]=S,e[52]=s.worktrees,e[53]=I,e[54]=Q):Q=e[54];let D;return e[55]!==m||e[56]!==ee||e[57]!==Q||e[58]!==w||e[59]!==y?(D=t.jsxs("div",{ref:m,style:w,className:y,children:[ee,Q]}),e[55]=m,e[56]=ee,e[57]=Q,e[58]=w,e[59]=y,e[60]=D):D=e[60],D},zn=({open:n,onOpenChange:e,variant:s="drawer",footer:o})=>{const{t:r}=me(),{git:i}=ks(),a=tr(),c=xs(p=>p.activeSessions),u=Jn(l.useCallback(p=>n||s==="sidebar"?p.ids:Ml,[n,s])),f=Xn(l.useCallback(p=>n||s==="sidebar"?p.rankById:Lo,[n,s])),d=Oe(p=>p.projects),m=Oe(p=>p.activeProjectId),g=Xe(p=>p.currentDirectory),h=je(p=>p.currentSessionId),x=je(p=>p.setCurrentSession),j=je(p=>p.archiveSession),b=je(p=>p.deleteSession),I=je(p=>p.updateSessionTitle),S=je(p=>p.openNewSessionDraft),E=Oe(p=>p.setActiveProject),T=Oe(p=>p.setActiveProjectIdOnly),k=Oe(p=>p.reorderProjects),P=Oe(p=>p.removeProject),w=Ft(p=>p.projectExpanded),R=Ft(p=>p.worktreeExpanded),y=Ft(p=>p.setProjectExpanded),A=Ft(p=>p.setWorktreeExpanded),M=ps(p=>p.orderByProject),C=ps(p=>p.setWorktreeOrder),N=Rn(p=>p.expandedParents),H=Rn(p=>p.toggleParent),[$,v]=l.useState(""),[_,O]=l.useState(null),[z,L]=l.useState(null),[ee,Q]=l.useState(null),[D,X]=l.useState(null),[q,G]=l.useState(null),[F,Z]=l.useState(null),[te,ae]=l.useState(null),[pe,oe]=l.useState(0),[W,ie]=l.useState(!1),[U,fe]=l.useState(!1),[Ne,ke]=l.useState(null),[Ae,Be]=l.useState(()=>new Map(je.getState().availableWorktreesByProject)),[Ie,_e]=l.useState(()=>{const p=new Set;for(const[K,Y]of je.getState().availableWorktreesByProject)Y.length>0&&p.add(K);return p}),[ve,B]=l.useState(!1),[V,re]=l.useState(new Set),[le,Ce]=l.useState(new Map);l.useEffect(()=>{if(!n){v(""),B(!1),re(new Set),Ce(new Map),O(null),L(null),Q(null),X(null),G(null),Z(null);return}ws(a)},[n]),l.useEffect(()=>{ve||re(new Set)},[ve]),l.useEffect(()=>{if(!n||d.length===0)return;let p=!1;return(async()=>{const Y=await Promise.all(d.map(async ce=>{const Ee=Se(ce.path);if(!Ee)return null;const ge=await i.checkIsGitRepository(Ee).catch(()=>!1),De=ge?await ar({id:ce.id,path:Ee}).catch(()=>[]):[];return[Ee,De,ge]}));if(p)return;const ne=new Map,we=new Set;for(const ce of Y)ce&&(ne.set(ce[0],ce[1]),ce[2]&&we.add(ce[0]));Be(lr(d,ne)),_e(we)})(),()=>{p=!0}},[i,n,d,pe]);const be=l.useMemo(()=>d.map(p=>({id:p.id,label:p.label?.trim()||rs(p.path),path:Se(p.path),icon:p.icon,color:p.color,iconImage:p.iconImage,iconBackground:p.iconBackground,isGitRepo:Ie.has(Se(p.path)),worktrees:Pl(M[p.id],Ae.get(Se(p.path))??[])})),[Ie,d,M,Ae]),Fe=l.useMemo(()=>{const p=new Map(a.map(ne=>[ne.id,ne])),K=c.map(ne=>{const we=p.get(ne.id);return we?Bo(we,ne):ne}),Y=new Set(K.map(ne=>ne.id));for(const ne of a)Y.has(ne.id)||K.push(ne);return K.filter(ne=>!ne.time?.archived)},[c,a]),Pe=$.trim().toLowerCase(),st=l.useRef(null);l.useEffect(()=>{if(!n)return;const p=window.requestAnimationFrame(()=>{const K=st.current;if(!K)return;(K.querySelector('[data-active-session="true"]')??K.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(p)},[n]);const zt=l.useMemo(()=>{const p=be.map(Y=>({project:Y,buckets:[],totalSessions:0,isActive:Y.id===m})),K=(Y,ne,we)=>{const ce=Se(ne)||Y.project.path,Ee=ce||"__root__";let ge=Y.buckets.find(De=>De.key===Ee);return ge||(ge={key:Ee,label:we?.branch||rs(ce),path:ce,worktree:we,sessions:[]},Y.buckets.push(ge)),ge};for(const Y of p){K(Y,Y.project.path,null);for(const ne of Y.project.worktrees)K(Y,ne.path,ne)}for(const Y of Fe){const ne=at(Y);if(!ne)continue;const we=Se(ne),ce=p.find(De=>hs(De.project,we));if(!ce)continue;const Ee=Gt(ce.project,we);(Ee?K(ce,Ee.path,Ee):K(ce,ce.project.path,null)).sessions.push(Y)}for(const Y of p)for(const ne of Y.buckets){ne.sessions=dn(ne.sessions,u,f);for(const we of ne.sessions)Nt(we)||(Y.totalSessions+=1)}return p},[m,u,be,f,Fe]),Hs=Se(g),Fr=p=>p.isActive?Hs===p.project.path?p.project.path:p.project.worktrees.find(Y=>Bl(Hs,Y.path))?.path??p.project.path:null,Wr=p=>w[p.project.id]??!0,Ur=(p,K)=>R[`${p.project.id}::${K.key}`]??!0,qs=p=>{Ce(K=>{if(!K.has(p))return K;const Y=new Map(K);return Y.delete(p),Y})},Vr=p=>{Ce(K=>{let Y=!1;const ne=new Map(K),we=`${p}::`;for(const ce of ne.keys())ce.startsWith(we)&&(ne.delete(ce),Y=!0);return Y?ne:K})},Gr=(p,K)=>{Ce(Y=>{const ne=new Map(Y);return ne.set(p,K+is),ne})},Ys=(p,K,Y)=>{const ne=`${p.project.id}::${K.key}`,we=new Set(K.sessions.map(ye=>ye.id)),ce=new Map;for(const ye of K.sessions){const $e=Nt(ye);if($e&&we.has($e)){const wt=ce.get($e)??[];wt.push(ye),ce.set($e,wt)}}const Ee=K.sessions.filter(ye=>{const $e=Nt(ye);return!$e||!we.has($e)}),ge=le.get(ne)??is,De=Ee.slice(0,ge),nt=Ee.length-De.length,es=Ee.length>is&&nt===0,sn=(ye,$e)=>{const wt=ce.get(ye.id)??[],ts=wt.length>0,nn=!!N[ye.id];return t.jsxs(l.Fragment,{children:[t.jsx(Mn,{session:ye,active:h===ye.id,indent:$e,hasChildren:ts,expanded:nn,onToggleChildren:ts?()=>H(ye.id):void 0,onSelect:()=>Js(ye),revealed:z===ye.id,onRevealedChange:jt=>qr(ye.id,jt),confirmingDelete:ee===ye.id,onArchive:()=>{Yr(ye)},onRequestDelete:()=>Q(ye.id),onConfirmDelete:()=>{Jr(ye)},renaming:D===ye.id,onRequestRename:()=>Xr(ye.id),onSubmitRename:jt=>{Qr(ye.id,jt)},onCancelRename:()=>X(null)}),ts&&nn?wt.map(jt=>sn(jt,$e+zl)):null]},ye.id)};return t.jsxs("div",{children:[De.map(ye=>sn(ye,Y)),nt>0?t.jsx(Fl,{indent:Y,onClick:()=>Gr(ne,De.length)}):null,es?t.jsx(Wl,{indent:Y,onClick:()=>qs(ne)}):null]})},Kr=(p,K)=>{y(p,!K),Vr(p)},Hr=(p,K,Y)=>{A(`${p}::${K}`,!Y),qs(`${p}::${K}`)},Js=p=>{const K=at(p)||null,Y=as(be,K??"");if(Y){T(Y.id),y(Y.id,!0);const ne=Gt(Y,Se(K??""));ne&&A(`${Y.id}::${Se(ne.path)}`,!0)}x(p.id,K),e(!1)},qr=(p,K)=>{L(K?p:null),Q(null),G(null),Z(null)},Ot=(p,K)=>{G(K?p:null),Z(null),L(null),Q(null)},Yr=async p=>{L(null),Q(null),await j(p.id)?ue.success(r("sessions.sidebar.session.archive.success")):ue.error(r("sessions.sidebar.session.archive.error"))},Jr=async p=>{L(null),Q(null),await b(p.id)?ue.success(r("sessions.sidebar.session.delete.success")):ue.error(r("sessions.sidebar.session.delete.error"))},Xr=p=>{L(null),Q(null),X(p)},Qr=async(p,K)=>{X(null);try{await I(p,K)}catch{ue.error(r("mobile.sessions.renameError"))}},Zr=()=>{S(),e(!1)},Xs=p=>{ke(p),T(p),fe(!0)},eo=Rs(ht(Ts,{activationConstraint:{distance:8}}),ht(Ps,{coordinateGetter:_s})),to=p=>{const{active:K,over:Y}=p;if(!Y||K.id===Y.id)return;const ne=be.findIndex(ce=>ce.id===K.id),we=be.findIndex(ce=>ce.id===Y.id);ne<0||we<0||k(ne,we)},so=p=>{re(K=>{const Y=new Set(K);return Y.has(p)?Y.delete(p):Y.add(p),Y})},no=l.useCallback(p=>{const K=at(p),Y=as(be,K);if(!Y)return rs(K)||K;const ne=Gt(Y,Se(K));return ne?.branch?`${Y.label} · ${ne.branch}`:Y.label},[be]),ro=p=>{E(p.id),e(!1)},oo=l.useMemo(()=>Pe?zt.filter(p=>ir([p.project.label,p.project.path],Pe)?!0:p.buckets.some(K=>K.sessions.some(Y=>ls(Y,p.project.label,Pe)))):zt,[Pe,zt]),Lt=l.useMemo(()=>Pe?dn(Fe.filter(p=>{if(Nt(p))return!1;const K=at(p),Y=as(be,K);return ls(p,Y?.label??"",Pe)}),u,f):[],[Pe,u,be,f,Fe]),Bt=l.useMemo(()=>Pe?$o(be,Pe,p=>[p.label,p.path]).map(p=>({...p,sessionCount:Fe.filter(K=>{if(Nt(K))return!1;const Y=Se(at(K));return hs(p,Y)}).length})):[],[Pe,be,Fe]),io=Pe&&Lt.length===0&&Bt.length===0,Qs=!Pe&&be.length>1?t.jsx(xe,{type:"button",variant:"chip",size:"sm","aria-label":r(ve?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":ve,onClick:()=>B(p=>!p),style:{touchAction:"manipulation"},children:ve?t.jsx(dr,{className:"size-4"}):t.jsx(ds,{className:"size-4"})}):null,Zs=!ve&&be.length>0?t.jsxs(xe,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:Zr,style:{touchAction:"manipulation"},children:[t.jsx(ra,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,en=ve?null:t.jsx(xe,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.addProject"),title:r("sessions.sidebar.header.actions.addProject"),onClick:()=>ie(!0),style:{touchAction:"manipulation"},children:t.jsx(fn,{className:"size-4"})}),$t=Zs||en||Qs?t.jsxs(t.Fragment,{children:[Zs,en,Qs]}):null,tn=t.jsxs("div",{ref:st,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs(Ss,{className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:J("px-4 pb-2 pt-1",ve&&"hidden"),children:t.jsxs("div",{className:"relative",children:[t.jsx(fr,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(js,{value:$,onChange:p=>v(p.target.value),placeholder:r("mobile.sessions.search.placeholder"),className:J("h-11 pl-9",$&&"pr-10")}),$?t.jsx("button",{type:"button",className:"absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":r("mobile.sessions.clearSearchAria"),onClick:()=>v(""),style:{touchAction:"manipulation"},children:t.jsx(mr,{className:"size-4"})}):null]})}),be.length===0?t.jsx(Bn,{title:r("mobile.sessions.empty.noProjectsTitle"),description:r("mobile.sessions.empty.noProjectsDescription"),action:t.jsxs("button",{type:"button",className:"flex items-center justify-center gap-2 rounded-2xl bg-primary px-5 py-3 typography-ui-label text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>ie(!0),children:[t.jsx(fn,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):io?t.jsx(Bn,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):Pe&&!ve?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[Lt.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:Lt.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Lt.map((p,K)=>t.jsx("div",{className:J(K>0&&"border-t border-border/70"),children:t.jsx(Mn,{session:p,active:h===p.id,indent:12,contextLabel:no(p),onSelect:()=>Js(p)})},p.id))})]}):null,Bt.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:Bt.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Bt.map((p,K)=>t.jsxs("div",{className:J("flex items-center",K>0&&"border-t border-border/70"),children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-3 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>ro(p),style:{touchAction:"manipulation"},children:[t.jsx(gs,{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(_n,{className:"mr-2",onClick:()=>Xs(p.id)}):null]},p.id))})]}):null]}):ve?t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2",children:[t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:r("mobile.sessions.editOrderHint")}),t.jsx(As,{sensors:eo,collisionDetection:Is,onDragEnd:to,children:t.jsx(Ds,{items:be.map(p=>p.id),strategy:Ms,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:be.map(p=>{const K=zt.find(Y=>Y.project.id===p.id);return t.jsx(Vl,{project:p,totalSessions:K?.totalSessions??0,expanded:V.has(p.id),onToggleExpanded:()=>so(p.id),onReorderWorktrees:Y=>C(p.id,Y)},p.id)})})})})]}):t.jsx("div",{className:"flex flex-col",children:oo.map((p,K)=>{const Y=Wr(p),ne=Pe?p.buckets.filter(ce=>ce.sessions.some(Ee=>ls(Ee,p.project.label,Pe))):p.buckets,we=Fr(p);return t.jsxs("section",{className:J(K>0&&"border-t border-border/70"),children:[t.jsx(Dn,{actionsWidth:96,revealed:q===`project:${p.project.id}`,onRevealedChange:ce=>Ot(`project:${p.project.id}`,ce),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:q===`project:${p.project.id}`?0:-1,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary","aria-label":r("mobile.sessions.editProjectAria",{label:p.project.label}),onClick:()=>{G(null),O(p.project.id)},style:{touchAction:"manipulation"},children:t.jsx(ds,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:q===`project:${p.project.id}`?0:-1,className:J("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",F===p.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":F===p.project.id?r("mobile.sessions.confirmRemoveProjectAria",{label:p.project.label}):r("mobile.sessions.removeProjectAria",{label:p.project.label}),onClick:()=>{if(F===p.project.id){G(null),Z(null),P(p.project.id),ue.success(r("mobile.sessions.toast.projectRemoved",{label:p.project.label}));return}Z(p.project.id)},style:{touchAction:"manipulation"},children:t.jsx(Kt,{className:"size-[18px]"})})]}),children:t.jsxs("div",{"data-active-project":p.isActive||void 0,className:"flex min-h-12 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>{if(q){Ot(q,!1);return}Kr(p.project.id,Y)},"aria-expanded":Y,"aria-label":Y?r("sessions.sidebar.group.collapseAria",{label:p.project.label}):r("sessions.sidebar.group.expandAria",{label:p.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(gs,{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(In,{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(_n,{className:"mr-2",onClick:()=>Xs(p.project.id)}):null]})}),Y?t.jsx("div",{className:"pb-2",children:(()=>{const ce=ne.find(ge=>ge.worktree===null),Ee=ne.filter(ge=>ge.worktree!==null);return t.jsxs(t.Fragment,{children:[ce&&ce.sessions.length>0?Ys(p,ce,An):null,Ee.map(ge=>{const De=Ur(p,ge),nt=we===ge.path;return t.jsxs("div",{children:[t.jsx(Dn,{actionsWidth:48,revealed:q===`wt:${ge.key}`,onRevealedChange:es=>Ot(`wt:${ge.key}`,es),actions:t.jsx("button",{type:"button",tabIndex:q===`wt:${ge.key}`?0:-1,className:"flex flex-1 items-center justify-center text-[var(--status-error)] transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive","aria-label":r("mobile.projectEdit.deleteWorktreeAria",{label:ge.label}),onClick:()=>{G(null),ge.worktree&&ae({project:p.project,worktree:ge.worktree})},style:{touchAction:"manipulation"},children:t.jsx(Kt,{className:"size-[18px]"})}),children:t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-2 px-3 py-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>{if(q){Ot(q,!1);return}Hr(p.project.id,ge.key,De)},"aria-expanded":De,"aria-label":De?r("sessions.sidebar.group.collapseAria",{label:ge.label}):r("sessions.sidebar.group.expandAria",{label:ge.label}),style:{touchAction:"manipulation"},children:[t.jsx(se,{name:"git-branch",className:J("size-4 shrink-0",nt?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:J("block min-w-0 flex-1 truncate typography-ui-label font-bold",nt?"text-foreground":"text-muted-foreground"),children:ge.label}),nt?t.jsx(In,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:ge.sessions.length})]})}),De?Ys(p,ge,An):null]},ge.key)})]})})()}):null]},p.project.id)})})]}),o?t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/70 px-2 pt-1.5",style:{paddingBottom:"calc(0.375rem + var(--oc-safe-area-bottom, 0px))"},children:[o.instanceLabel&&o.onOpenInstances?t.jsxs(xe,{type:"button",variant:"info",size:"lg",className:"min-w-0 shrink justify-start",onClick:o.onOpenInstances,"aria-label":r("mobile.menu.instances"),style:{touchAction:"manipulation"},children:[t.jsx(se,{name:"server",className:"size-[18px]"}),t.jsx("span",{className:"block min-w-0 truncate",children:o.instanceLabel})]}):t.jsx("div",{className:"min-w-0 flex-1"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[o.onOpenUpdate?t.jsxs(xe,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:o.onOpenUpdate,"aria-label":r("mobile.menu.update"),title:r("mobile.menu.update"),style:{touchAction:"manipulation"},children:[t.jsx(se,{name:"download",className:"size-5"}),t.jsx("span",{className:"absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary","aria-hidden":!0})]}):null,t.jsx(xe,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:o.onOpenSettings,"aria-label":r("mobile.menu.settings"),title:r("mobile.menu.settings"),style:{touchAction:"manipulation"},children:t.jsx(se,{name:"settings-3",className:"size-5"})})]})]}):null,t.jsx(Bi,{open:W,onOpenChange:ie}),t.jsx($i,{open:U,onOpenChange:p=>{fe(p),p||ke(null)},onWorktreeCreated:(p,K)=>{K?.sessionId?x(K.sessionId,p):S({selectedProjectId:Ne,directoryOverride:p,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(Dl,{open:_!==null,project:be.find(p=>p.id===_)??null,onClose:()=>O(null),onWorktreesChanged:()=>oe(p=>p+1)}),te?t.jsx(zr,{open:!0,project:{id:te.project.id,path:te.project.path},worktree:te.worktree,onClose:()=>ae(null),onDeleted:()=>oe(p=>p+1)}):null]});return s==="sidebar"?n?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center justify-between gap-2 border-b border-border/70 px-4",children:[t.jsx("h2",{className:"truncate typography-ui-label font-semibold text-foreground",children:r("mobile.sessions.sheet.title")}),$t?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:$t}):null]}),tn]}):null:t.jsxs(Hl,{open:n,onClose:()=>e(!1),ariaLabel:r("mobile.sessions.sheet.title"),children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":r("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(se,{name:"close",className:"size-5"})}),t.jsx("h2",{className:"min-w-0 flex-1 truncate px-1 typography-ui-label font-semibold text-foreground",children:r("mobile.sessions.sheet.title")}),$t?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:$t}):null]}),tn]})},On="mobile-surface-root",Gl=16,Ln=320,Kl="cubic-bezier(0.22, 1, 0.36, 1)",Hl=({open:n,onClose:e,ariaLabel:s,children:o})=>{const r=l.useRef(null),[i,a]=l.useState(!1),[c,u]=l.useState(n),f=l.useRef(e);if(l.useEffect(()=>{f.current=e},[e]),typeof document<"u"&&!r.current){let d=document.getElementById(On);d||(d=document.createElement("div"),d.id=On,document.body.appendChild(d)),r.current=d}return l.useEffect(()=>{if(n){u(!0);const m=window.setTimeout(()=>a(!0),Gl);return()=>window.clearTimeout(m)}a(!1);const d=window.setTimeout(()=>u(!1),Ln+40);return()=>window.clearTimeout(d)},[n]),l.useEffect(()=>{if(!n)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)}},[n]),r.current?mt.createPortal(t.jsx("section",{role:"dialog","aria-modal":"true","aria-label":s,"aria-hidden":!n,className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:i?"none":"translateX(-100%)",transition:`transform ${Ln}ms ${Kl}`,visibility:c?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:o})}),r.current):null},Bn=n=>{const e=de.c(10),{title:s,description:o,action:r}=n;let i;e[0]!==s?(i=t.jsx("p",{className:"typography-ui-label text-foreground",children:s}),e[0]=s,e[1]=i):i=e[1];let a;e[2]!==o?(a=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[2]=o,e[3]=a):a=e[3];let c;e[4]!==r?(c=r?t.jsx("div",{className:"pt-2",children:r}):null,e[4]=r,e[5]=c):c=e[5];let 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 ql(n){return Se(n.path)}function Yl(n){return Se(n.path)}function Jl(n){return t.jsx(Ul,{worktree:n},Se(n.path))}const Xl=(n,e)=>{if(!n)return e("mcpDropdown.status.unknown");switch(n.status){case"connected":return e("mcpDropdown.status.connected");case"failed":return e("mcpDropdown.status.failed",{error:n.error||e("mcpDropdown.status.unknownError")});case"needs_auth":return e("mcpDropdown.status.needsAuth");case"needs_client_registration":return e("mcpDropdown.status.needsRegistration",{error:n.error||""});default:return n.status}},Ql=n=>{switch(n?.status){case"connected":return"success";case"failed":return"error";case"needs_auth":case"needs_client_registration":return"warning";default:return"default"}},Zl=({active:n,className:e,headerAction:s,listClassName:o,hideHeader:r=!1,mobileListDensity:i=!1})=>{const{t:a}=me(),u=Xe(k=>k.currentDirectory)??null,f=Ct(k=>k.getStatusForDirectory(u)),d=Ct(k=>k.refresh),m=Ct(k=>k.connect),g=Ct(k=>k.disconnect),h=dt(k=>k.mcpServers),x=dt(k=>k.loadMcpConfigs),[j,b]=l.useState(!1),[I,S]=l.useState(null);l.useEffect(()=>{d({directory:u,silent:!0})},[d,u]),l.useEffect(()=>{x({force:!0})},[x]),l.useEffect(()=>{n&&Promise.all([d({directory:u,silent:!0}),x({force:!0})])},[n,d,u,x]);const E=l.useMemo(()=>{const k=new Set(Object.keys(f));for(const P of h)P?.name&&k.add(P.name);return Array.from(k).sort((P,w)=>P.localeCompare(w))},[h,f]),T=l.useCallback(k=>{if(k?.preventDefault(),j)return;b(!0);const P=new Promise(w=>setTimeout(w,500));Promise.all([d({directory:u}),P]).finally(()=>{b(!1)})},[j,d,u]);return t.jsxs("div",{className:J("w-full",e),children:[r?null:t.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex items-baseline gap-2",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("mcpDropdown.title")}),u&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:u.split("/").pop()||u})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",disabled:j,onClick:T,"aria-label":a("mcpDropdown.actions.refreshAria"),children:t.jsx(se,{name:"refresh",className:J("h-4 w-4",j&&"animate-spin")})})]})]})}),t.jsx("div",{className:J("max-h-64 overflow-y-auto",i?"space-y-1 py-3":"px-3 py-2.5",o),children:t.jsxs("div",{className:J(!i&&E.length>0&&"rounded-xl bg-[var(--surface-muted)] p-1.5"),children:[E.map(k=>{const P=f[k],w=Ql(P),R=P?.status==="connected",y=I===k,A=Xl(P,a);return t.jsxs("div",{className:J("flex items-center justify-between rounded-lg hover:bg-interactive-hover/50",i?"gap-3 px-4 py-3":"gap-2 px-2.5 py-2"),children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs(Fo,{children:[t.jsx(Wo,{asChild:!0,children:t.jsx("span",{className:J("rounded-full flex-shrink-0",i?"h-2.5 w-2.5":"h-2 w-2",w==="success"&&"bg-status-success",w==="error"&&"bg-status-error",w==="warning"&&"bg-status-warning",w==="default"&&"bg-muted-foreground/40"),"aria-label":A})}),t.jsx(Uo,{side:"left",children:t.jsx("p",{children:A})})]}),t.jsx("span",{className:J("truncate",i?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:k})]})}),t.jsx(Vo,{checked:R,disabled:y,className:"data-[checked]:bg-status-info",onCheckedChange:async M=>{S(k);try{if(!M){await g(k,u);return}const C=f?.[k]?.status;if(C==="needs_auth"||C==="needs_client_registration"){const{opened:N}=await Go({name:k,directory:u});N||pn.error(a("mcpDropdown.toast.authorizeOpenFailed"));return}await m(k,u)}catch(C){pn.error(C instanceof Error?C.message:a("mcpDropdown.toast.authorizeFailed"))}finally{S(null)}}})]},k)}),E.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:a("mcpDropdown.empty.configureInConfig")})]})})]})},ec=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),tc=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},sc=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},$n=(n,e)=>e?`${n}\0staged`:n,nc=({onClose:n,initialDiffPath:e,initialDiffStaged:s=!1})=>{const{t:o}=me(),{git:r}=ks(),i=ec(Ns()??null),a=Ko(i||null),c=Ho(i||null),u=qo(i||null),f=We(B=>B.setActiveDirectory),d=We(B=>B.ensureAll),m=We(B=>B.fetchStatus),g=We(B=>B.fetchBranches),h=We(B=>B.prefetchDiffs),x=We(B=>B.getDiff),j=We(B=>B.setDiff),[b,I]=l.useState(()=>e?{type:"diff",path:e,staged:s}:{type:"list"});l.useEffect(()=>{e&&I(B=>B.type==="diff"&&B.path===e&&B.staged===s?B:{type:"diff",path:e,staged:s})},[e,s]);const[S,E]=l.useState(null),[T,k]=l.useState(null),[P,w]=l.useState(""),[R,y]=l.useState(new Set),[A,M]=l.useState(!1),[C,N]=l.useState(!1),[H,$]=l.useState([]),[v,_]=l.useState([]),[O,z]=l.useState([]),[L,ee]=l.useState(null),[Q,D]=l.useState(null),[X,q]=l.useState(0),G=l.useMemo(()=>{const B=a?.files??[],V=new Map;for(const re of B)V.set(re.path,re);return Array.from(V.values()).sort((re,le)=>re.path.localeCompare(le.path))},[a?.files]),F=l.useMemo(()=>G.filter(tc),[G]),Z=l.useMemo(()=>G.filter(sc),[G]),te=l.useMemo(()=>{if(O.length>0)return O;const B=a?.tracking?.includes("/")?a.tracking.split("/")[0]:null;return B||L?[{name:B||"origin",fetchUrl:L??"",pushUrl:L??""}]:[]},[L,O,a?.tracking]),ae=We(l.useCallback(B=>!i||b.type!=="diff"?null:B.directories.get(i)?.diffCache.get($n(b.path,b.staged))??null,[i,b])),pe=l.useMemo(()=>b.type!=="diff"?null:G.find(B=>B.path===b.path)??null,[G,b]),oe=l.useCallback(async(B=!0)=>{if(i)try{await Promise.all([m(i,r),g(i,r)])}catch(V){B&&ue.error(V instanceof Error?V.message:o("gitView.toast.refreshRepositoryFailed"))}},[i,g,m,r,o]),W=l.useCallback(async()=>{if(!i){z([]),ee(null);return}try{const[B,V]=await Promise.all([r.getRemotes(i).catch(()=>[]),r.getRemoteUrl?r.getRemoteUrl(i).catch(()=>null):Promise.resolve(null)]);z(B),ee(V)}catch{z([]),ee(null)}},[i,r]);l.useEffect(()=>{i&&(f(i),d(i,r))},[i,d,r,f]),l.useEffect(()=>{W()},[W]),l.useEffect(()=>{if(!i||G.length===0)return;const B=Array.from(new Set([...F.map(re=>re.path),...v,...G.slice(0,20).map(re=>re.path)])).filter(Boolean);if(B.length===0)return;const V=window.setTimeout(()=>{h(i,r,B,{maxFiles:40})},120);return()=>window.clearTimeout(V)},[G,i,r,h,F,v]),l.useEffect(()=>{if(b.type!=="diff"){D(null);return}const B=$n(b.path,b.staged);if(!i||x(i,B)){D(null);return}let V=!1;const re=yt();return D(null),r.getGitFileDiff(i,{path:b.path,staged:b.staged||void 0}).then(le=>{V||j(i,B,{original:le.original??"",modified:le.modified??"",isBinary:le.isBinary},re)}).catch(le=>{V||D(le instanceof Error?le.message:String(le))}),()=>{V=!0}},[i,X,x,r,b,j]);const ie=async(B,V)=>{if(i){E(B);try{const re=le=>{const Ce=`${le.name}/`,be=a?.tracking?.startsWith(Ce)?a.tracking.slice(Ce.length):void 0;return{remote:le.name,branch:be,rebase:!0}};if(B==="fetch"){if(!V)throw new Error(o("mobile.changes.noRemote"));await r.gitFetch(i,{remote:V.name}),ue.success(o("gitView.toast.fetchedFromRemote",{name:V.name}))}else if(B==="sync"){if(!V)throw new Error(o("mobile.changes.noRemote"));await r.gitFetch(i,{remote:V.name});const le=await r.getGitStatus(i);if((le.behind??0)>0){if((le.files?.length??0)>0){ue.error(o("gitView.toast.commitOrStashBeforeSync"));return}await r.gitPull(i,re(V))}((await r.getGitStatus(i)).ahead??0)>0&&await r.gitPush(i),ue.success(o("gitView.toast.alreadyUpToDate"))}await oe(!1),await W()}catch(re){ue.error(re instanceof Error?re.message:o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}))}finally{E(null)}}},U=l.useCallback(async(B,V)=>{if(!(!i||B.length===0))try{V==="stage"?B.length>1?await Yo(i,B):await Jo(i,B[0]):B.length>1?await Xo(i,B):await Qo(i,B[0]),await oe(!1)}catch(re){ue.error(re instanceof Error?re.message:o(V==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[i,oe,o]),fe=l.useCallback((B,V=!1)=>{I({type:"diff",path:B,staged:V})},[]),Ne=l.useCallback(async B=>{if(i){y(V=>new Set(V).add(B));try{await r.revertGitFile(i,B),ue.success(o("gitView.toast.revertedFile",{path:B})),await oe(!1)}catch(V){ue.error(V instanceof Error?V.message:o("gitView.toast.revertFailed"))}finally{y(V=>{const re=new Set(V);return re.delete(B),re})}}},[i,r,oe,o]),ke=l.useCallback(async B=>{if(!i||B.length===0||A)return;const V=Array.from(new Set(B));M(!0),y(new Set(V));try{await Promise.all(V.map(re=>r.revertGitFile(i,re))),await oe(!1),ue.success(V.length===1?o("gitView.toast.revertedFilesSingle",{count:V.length}):o("gitView.toast.revertedFilesPlural",{count:V.length}))}catch(re){ue.error(re instanceof Error?re.message:o("gitView.toast.revertFailed"))}finally{y(new Set),M(!1)}},[i,r,A,oe,o]),Ae=l.useCallback(B=>{const V=B.map(re=>re.trim()).filter(Boolean);if(V.length===0){$([]);return}w(re=>`${re.trim()}${re.trim()?`
|
|
23
|
+
|
|
24
|
+
`:""}${V.join(`
|
|
25
|
+
`)}`.trim()),$([])},[]),Be=l.useCallback(async()=>{if(!i)return;const B=F.map(V=>V.path).sort();if(B.length===0){ue.error(o("gitView.toast.selectFileToDescribe"));return}N(!0);try{const{message:V}=await Zo(i,B);w(V.subject?.trim()??""),$(Array.isArray(V.highlights)?V.highlights:[])}catch(V){ue.error(V instanceof Error?V.message:o("gitView.toast.generateCommitMessageFailed"))}finally{N(!1)}},[i,F,o]),Ie=async(B={})=>{if(!i)return;if(!P.trim()){ue.error(o("gitView.toast.enterCommitMessage"));return}const V=F.map(re=>re.path).sort();if(V.length===0){ue.error(o("gitView.toast.selectFileToCommit"));return}k(B.pushAfter?"commitAndPush":"commit");try{if(await r.createGitCommit(i,P.trim(),{files:V}),ue.success(o("gitView.toast.commitCreated")),w(""),$([]),B.pushAfter){const re=a?.tracking?.split("/")[0],le=te.find(st=>st.name===re)??te[0];if(!le)throw new Error(o("mobile.changes.noRemote"));E("sync");const Ce=`${le.name}/`,be=a?.tracking?.startsWith(Ce)?a.tracking.slice(Ce.length):void 0;await r.gitFetch(i,{remote:le.name}),((await r.getGitStatus(i)).behind??0)>0&&await r.gitPull(i,{remote:le.name,branch:be,rebase:!0}),((await r.getGitStatus(i)).ahead??0)>0&&await r.gitPush(i),await oe(!1),await W()}else await oe(!1)}catch(re){ue.error(re instanceof Error?re.message:o("gitView.toast.createCommitFailed"))}finally{k(null),B.pushAfter&&E(null)}},_e=l.useMemo(()=>{const B=[];return F.length>0&&B.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:F,actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:V=>o("gitView.changes.unstageFileAria",{path:V}),onActionFile:V=>{U([V],"unstage")},onActionAll:V=>{U(V,"unstage")},onViewDiff:V=>fe(V,!0),onRevertFile:Ne,showRevertActions:!1,accent:!0}),Z.length>0&&B.push({id:"unstaged",title:o("gitView.changes.title"),entries:Z,actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:V=>o("gitView.changes.stageFileAria",{path:V}),onActionFile:V=>{U([V],"stage")},onActionAll:V=>{U(V,"stage")},onViewDiff:V=>fe(V,!1),onRevertFile:Ne}),B},[Ne,fe,U,F,o,Z]),ve=B=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[n?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":o("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(se,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:o("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:a?.current||i||""})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:B})]});return i?u&&c===null?ve(t.jsx(Ke,{loading:!0,message:o("gitView.loading.checkingRepository")})):c===!1?ve(t.jsx(Ke,{icon:!0,message:o("gitView.empty.notGitRepository"),description:o("gitView.empty.notGitRepositoryDescription")})):b.type==="diff"?t.jsx(rc,{path:b.path,diff:ae,fileExists:!!pe,error:Q,onBack:()=>I({type:"list"}),onRetry:()=>q(B=>B+1)}):t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[n?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":o("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(se,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:o("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:a?.current||i})]}),t.jsx(Fi,{syncAction:S,remotes:te,onFetch:B=>{ie("fetch",B)},onSync:B=>{ie("sync",B)},disabled:T!==null||u,aheadCount:a?.ahead??0,behindCount:a?.behind??0,trackingRemoteName:a?.tracking?.split("/")[0],hasUncommittedChanges:G.length>0})]}),G.length>0?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-4 pt-4",children:t.jsx(fa,{groups:_e,diffStats:a?.diffStats,revertingPaths:R,onRevertAll:ke,isRevertingAll:A,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:_})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(ma,{stagedCount:F.length,commitMessage:P,onCommitMessageChange:w,generatedHighlights:H,onInsertHighlights:Ae,onGenerateMessage:Be,isGeneratingMessage:C,onCommit:()=>{Ie({pushAfter:!1})},onCommitAndPush:()=>{Ie({pushAfter:!0})},commitAction:T,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Ke,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})})]}):ve(t.jsx(Ke,{message:o("gitView.empty.selectSessionOrDirectory")}))},Ke=n=>{const e=de.c(13),{message:s,description:o,loading:r,icon:i}=n,a=r===void 0?!1:r,c=i===void 0?!1:i;let u;e[0]!==a?(u=a?t.jsx(se,{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(se,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=c,e[3]=f):f=e[3];let d;e[4]!==s?(d=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,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},rc=n=>{const e=de.c(24),{path:s,diff:o,fileExists:r,error:i,onBack:a,onRetry:c}=n,{t:u}=me();let f;e[0]!==s?(f=ei(s)||"text",e[0]=s,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(se,{name:"arrow-left",className:"size-5"}),e[4]=g):g=e[4];let h;e[5]!==a||e[6]!==m?(h=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":m,onClick:a,children:g}),e[5]=a,e[6]=m,e[7]=h):h=e[7];let x;e[8]!==s?(x=t.jsx("div",{className:"min-w-0 flex-1 px-2",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s})}),e[8]=s,e[9]=x):x=e[9];let j;e[10]!==h||e[11]!==x?(j=t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/70 px-3 text-foreground",children:[h,x]}),e[10]=h,e[11]=x,e[12]=j):j=e[12];let b;e[13]!==o||e[14]!==i||e[15]!==r||e[16]!==d||e[17]!==c||e[18]!==s||e[19]!==u?(b=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r?i?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children: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")}):ti(s)?t.jsx(Ke,{icon:!0,message:u("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(Ss,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(pa,{original:o.original,modified:o.modified,language:d,fileName:s,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]=s,e[19]=u,e[20]=b):b=e[20];let I;return e[21]!==j||e[22]!==b?(I=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[j,b]}),e[21]=j,e[22]=b,e[23]=I):I=e[23],I},oc=l.lazy(()=>pt(()=>import("./FilesView-DPU8aNPL.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124])).then(n=>({default:n.FilesView}))),et=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),It=n=>{const e=et(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},ic=n=>{const e=et(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},ac=(n,e)=>{const s=et(n),o=et(e);return!o||s===o?It(s):s.startsWith(`${o}/`)?s.slice(o.length+1):s},lc=n=>{if(typeof n!="number"||!Number.isFinite(n)||n<0)return"";if(n<1024)return`${n} B`;const e=["KB","MB","GB"];let s=n/1024;for(const o of e){if(s<1024||o===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${o}`;s/=1024}return""},cc=({onClose:n})=>{const{t:e}=me(),{files:s}=ks(),o=mo(v=>v.setSelectedPath),r=et(Ns()??null),[i,a]=l.useState(()=>({type:"browser",directory:r})),[c,u]=l.useState([]),[f,d]=l.useState(!1),[m,g]=l.useState(null),[h,x]=l.useState(""),[j,b]=l.useState([]),[I,S]=l.useState(!1),E=l.useRef(0);l.useEffect(()=>{r&&a(v=>v.type==="browser"&&v.directory?v:{type:"browser",directory:r})},[r]);const T=i.type==="browser"?i.directory:i.returnDirectory,k=l.useCallback(async v=>{if(!v)return;const _=E.current+1;E.current=_,d(!0),g(null);try{const O=await s.listDirectory(v);if(E.current!==_)return;u(O.entries.slice().sort((z,L)=>z.isDirectory!==L.isDirectory?z.isDirectory?-1:1:z.name.localeCompare(L.name)))}catch(O){if(E.current!==_)return;u([]),g(O instanceof Error?O.message:e("mobile.files.error.listFailed"))}finally{E.current===_&&d(!1)}},[s,e]);l.useEffect(()=>{i.type==="browser"&&k(i.directory)},[k,i]),l.useEffect(()=>{if(i.type!=="browser")return;const v=h.trim();if(!v){b([]),S(!1);return}let _=!1;const O=window.setTimeout(()=>{S(!0),s.search({directory:i.directory,query:v,maxResults:40}).then(z=>{_||b(z)}).catch(()=>{_||b([])}).finally(()=>{_||S(!1)})},250);return()=>{_=!0,window.clearTimeout(O)}},[s,h,i]);const P=v=>{x(""),a({type:"browser",directory:v})},w=v=>{o(r,v),a({type:"file",path:v,returnDirectory:T||r})},R=Ve(v=>v.pendingFileFocusPath),y=Ve(v=>v.pendingFileNavigation);if(l.useEffect(()=>{const v=et(y?.path??R??"");!v||!r||v!==r&&!v.startsWith(`${r}/`)||(o(r,v),a({type:"file",path:v,returnDirectory:r}),R&&Ve.getState().setPendingFileFocusPath(null))},[R,y,r,o]),!r)return t.jsx(_t,{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(mn,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:It(i.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Le,{children:t.jsx(l.Suspense,{fallback:t.jsx(_t,{loading:!0,message:e("filesView.state.loading")}),children:t.jsx(oc,{mode:"editor-only"})})})})]});const A=i.directory===r?e("mobile.files.rootDirectory"):It(i.directory),M=h.trim()?j:[],C=ic(i.directory),N=i.directory!==r&&C!==null&&(C===r||C.startsWith(`${r}/`)),H=N&&!h.trim(),$=N?C:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[n?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(mr,{className:"size-5"})}):null,H&&$?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.files.backToParentAria",{name:It($)}),onClick:()=>P($),style:{touchAction:"manipulation"},children:t.jsx(mn,{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:A})}),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:()=>{k(i.directory)},style:{touchAction:"manipulation"},children:t.jsx(aa,{className:J("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(fr,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(js,{value:h,onChange:v=>x(v.target.value),placeholder:e("mobile.files.search.placeholder"),className:"h-11 pl-9"})]})}),t.jsx(Ss,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:m?t.jsx(_t,{message:m}):h.trim()?t.jsx(uc,{results:M,isSearching:I,onOpenFile:w}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[c.length===0&&!f?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:e("mobile.files.empty.directory")}):null,c.map(v=>t.jsx(Lr,{name:v.name,path:v.path,directory:v.isDirectory,meta:v.isDirectory?void 0:lc(v.size),onClick:()=>v.isDirectory?P(v.path):w(v.path)},v.path))]})})]})},Lr=n=>{const e=de.c(16),{name:s,path:o,directory:r,meta:i,onClick:a}=n;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={touchAction:"manipulation"},e[0]=c):c=e[0];let u;e[1]!==r||e[2]!==o?(u=r?t.jsx(la,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(si,{filePath:o,className:"size-5 shrink-0"}),e[1]=r,e[2]=o,e[3]=u):u=e[3];let f;e[4]!==s?(f=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=f):f=e[5];let 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(ca,{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},uc=n=>{const e=de.c(10),{results:s,isSearching:o,onOpenFile:r}=n,{t:i}=me(),a=et(Ns()??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(_t,{loading:!0,message:d}),e[2]=d,e[3]=m):m=e[3],m}if(s.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(_t,{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=s.map(d=>t.jsx(Lr,{name:It(d.path),path:d.path,directory:!1,meta:ac(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},_t=n=>{const e=de.c(7),{message:s,loading:o}=n,r=o===void 0?!1:o;let i;e[0]!==r?(i=r?t.jsx(ua,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(da,{className:"size-6 text-muted-foreground"}),e[0]=r,e[1]=i):i=e[1];let a;e[2]!==s?(a=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[2]=s,e[3]=a):a=e[3];let c;return e[4]!==i||e[5]!==a?(c=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[i,a]})}),e[4]=i,e[5]=a,e[6]=c):c=e[6],c},Fn="mobile-surface-root",dc=16,Wn=320,fc="cubic-bezier(0.22, 1, 0.36, 1)",mc=n=>{const e=de.c(36),{onOpenMcpSettings:s}=n,{t:o}=me(),[r,i]=l.useState(!1),a=Xe(pc),c=Ct(hc),u=dt(gc);let f;e[0]!==a||e[1]!==r||e[2]!==u||e[3]!==c?(f=()=>{if(r)return;i(!0);const A=new Promise(bc);Promise.all([c({directory:a||null,silent:!0}),u({force:!0}),A]).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 h,x;e[9]===Symbol.for("react.memo_cache_sentinel")?(h={touchAction:"manipulation"},x=t.jsx(se,{name:"add",className:"size-5"}),e[9]=h,e[10]=x):(h=e[9],x=e[10]);let j;e[11]!==s||e[12]!==m||e[13]!==g?(j=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:s,"aria-label":m,title:g,style:h,children:x}),e[11]=s,e[12]=m,e[13]=g,e[14]=j):j=e[14];let b;e[15]!==o?(b=o("mcpDropdown.actions.refreshAria"),e[15]=o,e[16]=b):b=e[16];let I;e[17]!==o?(I=o("mcpDropdown.actions.refreshAria"),e[17]=o,e[18]=I):I=e[18];let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S={touchAction:"manipulation"},e[19]=S):S=e[19];const E=r&&"animate-spin";let T;e[20]!==E?(T=J("size-5",E),e[20]=E,e[21]=T):T=e[21];let k;e[22]!==T?(k=t.jsx(se,{name:"refresh",className:T}),e[22]=T,e[23]=k):k=e[23];let P;e[24]!==r||e[25]!==d||e[26]!==k||e[27]!==b||e[28]!==I?(P=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":b,title:I,style:S,children:k}),e[24]=r,e[25]=d,e[26]=k,e[27]=b,e[28]=I,e[29]=P):P=e[29];let w;e[30]!==P||e[31]!==j?(w=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[j,P]}),e[30]=P,e[31]=j,e[32]=w):w=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(Zl,{active:!0,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=R):R=e[33];let y;return e[34]!==w?(y=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[w,R]}),e[34]=w,e[35]=y):y=e[35],y},Un=({open:n,onClose:e,tab:s,onTabChange:o,pendingChangesDiff:r,onOpenPlan:i,onOpenMcpSettings:a,variant:c="drawer"})=>{const{t:u}=me(),f=l.useRef(null),[d,m]=l.useState(!1),[g,h]=l.useState(n),x=l.useRef(e);l.useEffect(()=>{x.current=e},[e]);const j=l.useRef(s);l.useEffect(()=>{j.current=s},[s]);const[b,I]=l.useState(()=>new Set);if(l.useEffect(()=>{n&&I(T=>{if(T.has(s))return T;const k=new Set(T);return k.add(s),k})},[n,s]),typeof document<"u"&&!f.current){let T=document.getElementById(Fn);T||(T=document.createElement("div"),T.id=Fn,document.body.appendChild(T)),f.current=T}if(l.useEffect(()=>{if(n){h(!0);const k=window.setTimeout(()=>m(!0),dc);return()=>window.clearTimeout(k)}m(!1);const T=window.setTimeout(()=>h(!1),Wn+40);return()=>window.clearTimeout(T)},[n]),l.useEffect(()=>{if(!n)return;const T=document.body.style.overflow;c==="drawer"&&(document.body.style.overflow="hidden");const k=P=>{P.key==="Escape"&&j.current!=="terminal"&&x.current()};return document.addEventListener("keydown",k),()=>{c==="drawer"&&(document.body.style.overflow=T),document.removeEventListener("keydown",k)}},[n,c]),c==="drawer"&&!f.current)return null;const S=[{id:"changes",label:u("mobile.menu.changes"),icon:t.jsx(se,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:u("mobile.menu.files"),icon:t.jsx(se,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:u("mobile.menu.terminal"),icon:t.jsx(se,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:u("contextRail.surface.notes"),icon:t.jsx(se,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:u("mobile.menu.mcp"),icon:t.jsx(ni,{className:"h-3.5 w-3.5"})}],E=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(Wi,{items:S,activeId:s,onSelect:T=>o(T),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(se,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[b.has("changes")?t.jsx("div",{className:J("h-full",s!=="changes"&&"hidden"),children:t.jsx(Le,{children:t.jsx(nc,{initialDiffPath:r?.path??null,initialDiffStaged:r?.staged===!0})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,b.has("files")?t.jsx("div",{className:J("h-full",s!=="files"&&"hidden"),children:t.jsx(Le,{children:t.jsx(cc,{})})}):null,b.has("terminal")?t.jsx("div",{className:J("h-full",s!=="terminal"&&"hidden"),children:t.jsx(Le,{children:t.jsx(Ui,{visible:n&&s==="terminal"})})}):null,b.has("notes")?t.jsx("div",{className:J("h-full",s!=="notes"&&"hidden"),children:t.jsx(Le,{children:t.jsx(Vi,{onActionComplete:e,onOpenPlan:i})})}):null,b.has("mcp")?t.jsx("div",{className:J("h-full",s!=="mcp"&&"hidden"),children:t.jsx(Le,{children:t.jsx(mc,{onOpenMcpSettings:a})})}):null]})]});return c==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:E}):mt.createPortal(t.jsx("section",{role:"dialog","aria-modal":"true","aria-label":u("mobile.header.openWorkspaceAria"),"aria-hidden":!n,className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:d?"none":"translateX(100%)",transition:`transform ${Wn}ms ${fc}`,visibility:g?"visible":"hidden",pointerEvents:n?"auto":"none"},children:E}),f.current)};function pc(n){return n.currentDirectory}function hc(n){return n.refresh}function gc(n){return n.loadMcpConfigs}function bc(n){return window.setTimeout(n,500)}function xc(n){const e=de.c(4),s=2500,{uiFont:o}=ri(),[r,i]=l.useState(!1);let a,c;return e[0]!==s||e[1]!==o?(a=()=>{let u=!1;const f=()=>{u||i(!0)},d=()=>{requestAnimationFrame(()=>requestAnimationFrame(f))},m=Promise.all([oi(o).catch(kc),document.fonts?.ready?.then(jc).catch(wc)??Promise.resolve(),ha.catch(vc)]).then(yc),g=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([m,g]).then(d),()=>{u=!0}},c=[o,s],e[0]=s,e[1]=o,e[2]=a,e[3]=c):(a=e[2],c=e[3]),l.useEffect(a,c),r}function yc(){}function vc(){}function wc(){}function jc(){}function kc(){}const Sc="openchamber",Nc=n=>n.replace(/^\/+|\/+$/g,""),Cc=n=>{const e=Nc(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function Ec(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${Sc}:`)return null;const s=Cc(e),o=(s[0]??"").toLowerCase(),r=s.slice(1),i=e.searchParams;switch(o){case"session":{const a=r[0]||i.get("id")||"";return a?{type:"session",sessionId:a,directory:i.get("dir")??void 0}:null}case"new":case"new-session":return{type:"new-session",directory:i.get("dir")??void 0,projectId:i.get("project")??void 0,agent:i.get("agent")??void 0,model:i.get("model")??void 0};case"sessions":{const a=i.get("filter");return{type:"sessions",filter:a==="attention"||a==="recent"||a==="all"?a:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:r[0]||i.get("section")||void 0};case"changes":return{type:"changes",path:r.join("/")||i.get("path")||void 0,staged:i.get("staged")==="true"};case"view":{const a=(r[0]||"").toLowerCase();return a==="changes"?{type:"changes"}:a==="files"||a==="mcp"||a==="instances"||a==="update"?{type:"view",target:a}:null}default:return null}}let Me={},Br=!1,At=null;const Rc=n=>{switch(n.type){case"session":return je.getState().setCurrentSession(n.sessionId,n.directory??null),!0;case"new-session":{const e=je.getState();return e.openNewSessionDraft(),(n.directory||n.projectId)&&e.setNewSessionDraftTarget({directoryOverride:n.directory??null,projectId:n.projectId??null,selectedProjectId:n.projectId??null}),!0}case"sessions":return Me.openSessions?(Me.openSessions(n.filter),!0):!1;case"status":return Me.openSessions?(Me.openSessions(),!0):!1;case"view":return Me.openView?(Me.openView(n.target),!0):!1;case"changes":return Me.openChanges?(Me.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return Me.openSettings?(Me.openSettings(n.section),!0):!1}},Ks=()=>{if(!Br||!At)return;const n=At;At=null,Rc(n)||(At=n)},$r=n=>{At=n,Ks()},Vn=n=>{const e=Ec(n);e&&$r(e)},Pc=n=>{Br=n,Ks()},Tc=n=>{const e=de.c(3);let s,o;e[0]!==n?(s=()=>(Me=n,Ks(),()=>{Me===n&&(Me={})}),o=[n],e[0]=n,e[1]=s,e[2]=o):(s=e[1],o=e[2]),l.useEffect(s,o)},Ac=n=>{const{ready:e}=n;l.useEffect(()=>{Pc(e)},[e]),l.useEffect(()=>{if(!Te())return;let s=!1;const o=[];return pt(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([125,4,126])).then(async({App:r})=>{if(s)return;const i=await r.addListener("appUrlOpen",a=>{Vn(a?.url)});if(s){i.remove();return}o.push(()=>{i.remove()})}).catch(()=>{}),pt(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([127,126])).then(async({PushNotifications:r})=>{if(s)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){Vn(u);return}const f=typeof c?.sessionId=="string"?c.sessionId:void 0;f&&$r({type:"session",sessionId:f})});if(s){i.remove();return}o.push(()=>{i.remove()})}).catch(()=>{}),()=>{s=!0,o.forEach(r=>r())}},[])},Ic=32,_c=80,Dc=64,Mc=.7,zc=(n,e)=>{const s=l.useRef(e);s.current=e,l.useEffect(()=>{const o=n.current;if(!o)return;const i=window.Capacitor?.getPlatform?.()==="android"?_c:Ic;let a=!1,c=!1,u=0,f=0;const d=g=>{if(g.touches.length!==1){a=!1;return}const h=g.touches[0],x=o.clientWidth,j=h.clientX<=i,b=h.clientX>=x-i;a=j||b,c=j,u=h.clientX,f=h.clientY},m=g=>{if(!a)return;a=!1;const h=g.changedTouches[0];if(!h)return;const x=h.clientX-u,j=h.clientY-f;Math.abs(x)<Dc||Math.abs(j)>Math.abs(x)*Mc||c&&x<=0||!c&&x>=0||(c?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return o.addEventListener("touchstart",d,{passive:!0}),o.addEventListener("touchend",m,{passive:!0}),()=>{o.removeEventListener("touchstart",d),o.removeEventListener("touchend",m)}},[n])},Oc=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},Lc=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},Bc=n=>{const{enabled:e}=n,s=Ve(r=>r.nativeNotificationsEnabled),o=l.useRef(null);l.useEffect(()=>{if(!e||!s||!Lc())return;let r=!1;const i=[];return pt(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([127,126])).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,on()?.push?.registerApnsToken?.({token:d.value,platform:qn(),environment:Oc()})}),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,s]),l.useEffect(()=>{if(s)return;const r=o.current;if(!r)return;o.current=null,on()?.push?.unregisterApnsToken?.({token:r})},[s])},Gn=n=>{const e=de.c(12),{side:s,isResizing:o,ariaLabel:r,handleProps:i}=n,a=s==="left"?"right-0":"left-0";let c;e[0]!==a?(c=J("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=s==="left"?"right-0":"left-0",f=o&&"bg-[var(--interactive-border)]";let d;e[2]!==u||e[3]!==f?(d=J("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},$c=320,Fc=380,Kn=280,Wc=560,Uc=900;function Hn(n,e,s,o){const r=de.c(23),i=o===void 0?Wc:o,a=l.useRef(null);let c;r[0]!==s||r[1]!==i||r[2]!==e?(c=()=>{if(typeof window>"u")return s;const N=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(N)?Math.min(i,Math.max(Kn,N)):s},r[0]=s,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),h=l.useRef(u),x=l.useRef(null),j=l.useRef(null);let b;r[4]!==i?(b=N=>Math.min(i,Math.max(Kn,Math.round(N))),r[4]=i,r[5]=b):b=r[5];const I=b;let S;r[6]===Symbol.for("react.memo_cache_sentinel")?(S=N=>{const H=a.current;H&&(H.style.width=`${N}px`,H.style.minWidth=`${N}px`,H.style.maxWidth=`${N}px`,H.style.setProperty("--oc-ipad-sidebar-width",`${N}px`))},r[6]=S):S=r[6];const E=S;let T;r[7]!==u?(T=N=>{try{N.currentTarget.setPointerCapture(N.pointerId)}catch{}j.current=N.pointerId,g.current=N.clientX,h.current=u,x.current=u,m(!0),N.preventDefault()},r[7]=u,r[8]=T):T=r[8];const k=T;let P;r[9]!==I||r[10]!==n?(P=N=>{if(j.current!==N.pointerId)return;const H=N.clientX-g.current,$=I(h.current+(n==="left"?H:-H));x.current!==$&&(x.current=$,E($))},r[9]=I,r[10]=n,r[11]=P):P=r[11];const w=P;let R;r[12]!==I||r[13]!==e?(R=N=>{if(j.current!==N.pointerId)return;try{N.currentTarget.releasePointerCapture(N.pointerId)}catch{}const H=I(x.current??h.current);j.current=null,x.current=null,m(!1),f(H);try{window.localStorage.setItem(e,String(H))}catch{}},r[12]=I,r[13]=e,r[14]=R):R=r[14];const y=R;let A;r[15]!==k||r[16]!==y||r[17]!==w?(A={onPointerDown:k,onPointerMove:w,onPointerUp:y,onPointerCancel:y},r[15]=k,r[16]=y,r[17]=w,r[18]=A):A=r[18];const M=A;let C;return r[19]!==M||r[20]!==d||r[21]!==u?(C={asideRef:a,width:u,isResizing:d,handleProps:M},r[19]=M,r[20]=d,r[21]=u,r[22]=C):C=r[22],C}const Vc=["general","appearance","chat","notifications","sessions","git","magic-prompts","behavior","mcp","providers","usage","voice","integrations","about"],Gc=1e3,Kc=({onActiveConnectionDeleted:n})=>{const{t:e}=me(),[s,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,h]=l.useState("nav"),[x,j]=l.useState(null),b=Ve(U=>U.setSettingsPage),I=Ve(U=>U.wideChatLayoutEnabled),S=ct(U=>U.available),E=ct(U=>U.runtimeType),T=l.useMemo(()=>cr(),[]),k=dt(U=>U.mcpServers),P=dt(U=>U.setMcpDraft),w=dt(U=>U.setSelectedMcp),R=l.useCallback(()=>{i(null),m(null)},[]),y=l.useCallback(U=>{i(U)},[]),A=l.useCallback(()=>{c(!1)},[]),M=l.useCallback(U=>{h(U),y("settings")},[y]),{enabled:C,roomyForPanels:N}=vs(),$=ki()==="portrait",v=Si(),[_,O]=l.useState(()=>Ni().roomyForPanels),z=l.useCallback(()=>{O(U=>!U)},[]);l.useEffect(()=>{C||O(!1)},[C]);const L=l.useCallback(()=>{j(null),f("files"),c(!0)},[]),ee=l.useCallback((U=null)=>{j(U),f("changes"),c(!0)},[]),Q=Hn("left","openchamber.ipad.leftSidebarWidth",$c),D=Hn("right","openchamber.ipad.rightSidebarWidth",Fc,Uc),X=N,q=X&&a?D.width:0,G=C&&_?Q.width:0;l.useEffect(()=>{if(typeof document>"u")return;const U=document.documentElement;return U.style.setProperty("--oc-chat-inset-left",`${G}px`),U.style.setProperty("--oc-chat-inset-right",`${q}px`),()=>{U.style.removeProperty("--oc-chat-inset-left"),U.style.removeProperty("--oc-chat-inset-right")}},[G,q]),l.useEffect(()=>{if(typeof document>"u")return;const U=document.documentElement;return U.classList.toggle("wide-chat-layout",I),()=>U.classList.remove("wide-chat-layout")},[I]),l.useEffect(()=>{if(typeof document>"u")return;const U=C&&($||v),fe=document.documentElement;return fe.classList.toggle("oc-keep-draft-starters",U),()=>fe.classList.remove("oc-keep-draft-starters")},[v,C,$]);const F=l.useMemo(()=>({openChanges:({diffPath:U,staged:fe}={})=>{ee(U?{path:U,staged:fe===!0}:null)},openFiles:()=>L(),openSettings:()=>M("nav")}),[ee,L,M]),Z=l.useMemo(()=>({openSessions:()=>{C?O(!0):o(!0)},openView:U=>{if(U==="files"){L();return}if(U==="mcp"){f("mcp"),c(!0);return}y(U)},openChanges:({path:U,staged:fe}={})=>{ee(U?{path:U,staged:fe===!0}:null)},openSettings:U=>{U&&b(U),M(U?"page-content":"nav")}}),[C,ee,L,M,y,b]);Tc(Z);const te=l.useRef(null);zc(te,{onLeftEdgeSwipe:()=>{C?O(!0):o(!0)},onRightEdgeSwipe:()=>c(!0)});const ae=l.useCallback(()=>d?(m(null),!0):r?(R(),!0):a?(A(),!0):s?(o(!1),!0):!1,[r,R,A,d,s,a]);Ci(ae);const pe=!T&&S&&(E==="desktop"||E==="web"),oe=C?"dialog":"fullscreen",W=l.useMemo(()=>({instanceLabel:T?Et():null,onOpenInstances:T?()=>y("instances"):void 0,onOpenSettings:()=>M("nav"),onOpenUpdate:pe?()=>y("update"):void 0}),[M,y,T,pe]),ie=l.useCallback(()=>{const U="new-mcp-server";let fe=U,Ne=1;for(;k.some(Ae=>Ae.name===fe);)fe=`${U}-${Ne}`,Ne+=1;P({name:fe,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",timeout:"",enabled:!0}),w(fe),b("mcp"),M("page-content")},[k,M,P,w,b]);return t.jsx(Ei,{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:[C?t.jsxs("aside",{ref:Q.asideRef,className:J("relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!_&&"border-r-0"),style:{width:_?Q.width:0,minWidth:_?Q.width:0,maxWidth:_?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":!_,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:J("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",!_&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Le,{children:t.jsx(zn,{open:!0,variant:"sidebar",onOpenChange:U=>{!U&&!N&&O(!1)},footer:W})})}),_?t.jsx(Gn,{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:()=>C?z():o(!0),onOpenWorkspace:()=>c(!0),compactTitle:C}),t.jsx("main",{ref:te,className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:t.jsx("div",{className:"h-full w-full",children:t.jsx(Le,{children:t.jsx(Xi,{})})})})]}),C?null:t.jsx(zn,{open:s,onOpenChange:o,footer:W}),C?t.jsxs("aside",{ref:D.asideRef,className:J("relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!q&&"border-l-0"),style:{width:q,minWidth:q,maxWidth:q,"--oc-ipad-sidebar-width":`${D.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:D.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!q,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:J("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",D.isResizing&&"pointer-events-none",!q&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Le,{children:t.jsx(Un,{open:a,onClose:A,tab:u,onTabChange:f,pendingChangesDiff:x,onOpenPlan:m,onOpenMcpSettings:ie,variant:X?"panel":"drawer"})})}),q?t.jsx(Gn,{side:"right",isResizing:D.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:D.handleProps}):null]}):t.jsx(Un,{open:a,onClose:A,tab:u,onTabChange:f,pendingChangesDiff:x,onOpenPlan:m,onOpenMcpSettings:ie}),d?t.jsx(Tt,{open:!0,variant:oe,onClose:()=>m(null),ariaLabel:d.title,title:d.title,children:t.jsx(Le,{children:t.jsx(ta,{projectPlanId:d.id,onNavigatedToChat:()=>{R(),A()}})})}):null,r==="instances"&&T?t.jsx(Tt,{open:!0,variant:oe,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(Rl,{onConnect:R,onActiveConnectionDeleted:n})}):null,r==="settings"?t.jsx(Tt,{open:!0,variant:oe,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Le,{children:t.jsx(Zi,{forceMobile:!0,isWindowed:!0,initialMobileStage:g,visiblePageSlugs:Vc.filter(U=>!(T&&U==="about")),onClose:R})})}):null,r==="update"?t.jsx(Tt,{open:!0,variant:oe,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Le,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(ea,{initialUpdateDialogOpen:!0})})})}):null]})})};function Hc({apis:n}){const{t:e}=me(),s=ze(D=>D.initializeApp),o=ze(D=>D.isInitialized),r=ze(D=>D.isConnected),i=ze(D=>D.connectionPhase),a=ze(D=>D.providers.length),c=ze(D=>D.agents.length),u=ze(D=>D.loadProviders),f=ze(D=>D.loadAgents),d=Xe(D=>D.currentDirectory),m=je(D=>D.error),g=je(D=>D.clearError),h=Ve(D=>D.setIsMobile),x=ii(D=>D.refreshStatus),j=ai(D=>D.setPlanModeEnabled),b=Oe(D=>D.projects),[I,S]=l.useState(0),[E,T]=l.useState(0),[k,P]=l.useState(!1),[w,R]=l.useState("pending"),[y,A]=l.useState(null),M=l.useMemo(()=>Et(),[]),[,C]=l.useReducer(D=>D+1,0),N=l.useMemo(()=>cr(),[]),H=l.useRef(0),$=l.useRef(0),v=l.useCallback(()=>{const D=Ue(),X=$.current+1;if($.current=X,!D){kt("resume:auto-connect",{}),St();return}kt("resume:reprobe",{});const q=()=>{s(),x(n.github,{force:!0}),a===0&&u({source:"mobileApp:nativeResume"}),c===0&&f({source:"mobileApp:nativeResume"})},G=Z=>{kt("resume:disconnect",{reason:Z}),lt({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),S(te=>te+1)};Vt().then(Z=>{if($.current===X){if(Z==="no-connection"){G("no-connection");return}if(Z==="needs-login"){A({kind:"auth-expired",label:Et()??""}),G("needs-login");return}if(Z==="unreachable"){const te=[4e3,1e4],ae=pe=>{window.setTimeout(()=>{if($.current!==X)return;const oe=pe===te.length-1;Vt({fast:!oe}).then(W=>{if($.current===X&&W!=="switched"){if(W==="unchanged"){q();return}if(W==="needs-login"){A({kind:"auth-expired",label:Et()??""}),G("retry-needs-login");return}if(!oe){ae(pe+1);return}G(`retry-${W}`)}})},te[pe])};ae(0);return}Z!=="switched"&&q()}});const F=Date.now();F-H.current>=Gc&&(H.current=F,window.dispatchEvent(new Event("openchamber:system-resume")))},[c,n.github,s,f,u,a,x]);li(),ci(v),l.useEffect(()=>{if(!N)return;let D;const X=()=>{window.clearTimeout(D),D=window.setTimeout(()=>v(),1500)};return window.addEventListener("online",X),()=>{window.removeEventListener("online",X),window.clearTimeout(D)}},[N,v]),l.useEffect(()=>{if(N)return an.subscribe((D,X)=>{D.state==="expired"&&X.state!=="expired"&&(v(),an.getState().markAuthenticated())})},[N,v]),l.useEffect(()=>(ln(n),()=>ln(null)),[n]),l.useEffect(()=>po(D=>{if(kt("endpoint:changed",{runtimeKey:D.runtimeKey||"none",previousRuntimeKey:D.previousRuntimeKey||"none",connected:!!D.apiBaseUrl}),!!D.runtimeKey&&D.runtimeKey===D.previousRuntimeKey){Gi(),C();return}Ki(D),T(q=>q+1),S(q=>q+1)}),[]),l.useEffect(()=>{if(!N||r||Ue()){R("done");return}let D=!1;return R("attempting"),(async()=>{const X=await St().catch(()=>({status:"no-candidate"}));D||(X.status==="unreachable"?A({kind:"unreachable",label:X.label}):X.status==="needs-login"&&A({kind:"auth-expired",label:X.label}),R("done"),X.status==="unreachable"&&St({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{D=!0}},[]),l.useEffect(()=>{if(!N||!Ue())return;let D=!1;const X=q=>{kt("cold-launch:drop",{kind:q?.kind??"unknown"}),q&&A(q),lt({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),S(G=>G+1)};return Vt().then(async q=>{if(D||q==="switched"||q==="unchanged")return;const G=Et();if(q==="needs-login"){X({kind:"auth-expired",label:G??""});return}if(q==="unreachable"){X(G?{kind:"unreachable",label:G}:null),St({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const F=await St().catch(()=>({status:"no-candidate"}));D||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))}),()=>{D=!0}},[]),l.useEffect(()=>{h(!0)},[h]),l.useEffect(()=>{N&&!Ue()||s()},[I,s,N]),l.useEffect(()=>{r&&(a===0&&u({source:"mobileApp:recovery"}),c===0&&f({source:"mobileApp:recovery"}))},[c,r,f,u,a]);const _=l.useRef(!1),[O,z]=l.useState(N);l.useEffect(()=>{if(!N||!r||_.current)return;if(je.getState().currentSessionId){_.current=!0,z(!1);return}const D=yt(),X=ui(D);if(!X){_.current=!0,z(!1);return}let q=!1;const G=window.setTimeout(()=>z(!1),6e3);return(async()=>{const F=await ws().catch(()=>null);if(q)return;if(!F){z(!1);return}_.current=!0;const Z=F.activeSessions.find(ae=>ae.id===X.sessionId);if(!Z){di(D),z(!1);return}const te=je.getState();te.currentSessionId||te.setCurrentSession(Z.id,ys(Z)??X.directory??void 0),z(!1)})(),()=>{q=!0,window.clearTimeout(G)}},[I,r,N]),l.useEffect(()=>{r&&cn.setDirectory(d)},[d,r]),l.useEffect(()=>{r&&x(n.github,{force:!0})},[n.github,r,x]),l.useEffect(()=>{if(!r||b.length===0)return;let D=!1;return(async()=>{const q=new Map(je.getState().availableWorktreesByProject);if(await Promise.all(b.map(async Z=>{const te=Z.path.replace(/\\/g,"/").replace(/\/+$/,"");if(te)try{if(!(We.getState().directories.get(te)?.isGitRepo??await pt(()=>import("./useAppFontEffects-Cll4gnsh.js").then(W=>W.i0),__vite__mapDeps([9,1,2,3,4,5,6,7,8,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])).then(W=>W.checkIsGitRepository(te))))return;const oe=await ar({id:Z.id,path:te});if(D)return;q.set(te,oe)}catch{}})),D)return;const G=lr(b,q),F=je.getState().availableWorktreesByProject;ji(G,F)||je.setState({availableWorktrees:[...G.values()].flat(),availableWorktreesByProject:G})})(),()=>{D=!0}},[r,b]),l.useEffect(()=>{let D=!1;return(async()=>{const q=await bs("/health",{method:"GET"}).catch(()=>null);if(!q||!q.ok||D)return;const G=await q.json().catch(()=>null);if(!G||D)return;const F=G.planModeExperimentalEnabled;j(F===!0||F===1||F==="1"||F==="true")})(),()=>{D=!0}},[j]),l.useEffect(()=>{if(!m)return;const D=window.setTimeout(()=>g(),5e3);return()=>window.clearTimeout(D)},[g,m]),l.useEffect(()=>{if(!(!r&&(N?!!Ue():!0))){P(!1);return}const X=window.setTimeout(()=>{P(!0)},N?4e3:8e3);return()=>window.clearTimeout(X)},[r,N,I,E]),fi(),mi({enabled:!0}),Hi(),pi(),qi(),Bc({enabled:N&&r}),Ac({ready:N&&r&&o});const L=xc(),ee=!r&&i==="reconnecting";if(!L)return t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(qe,{width:120,height:120,isAnimated:!0})});const Q=!!Ue();return N&&(!Q||!r&&!ee)?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(qe,{width:120,height:120,isAnimated:!k}),k?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:()=>{lt({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),S(D=>D+1)},children:e("mobile.connect.cancelPassword")})]}):null]})}):w!=="done"?t.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-background text-foreground",children:[t.jsx(qe,{width:120,height:120,isAnimated:!0}),M?t.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[t.jsx("p",{className:"typography-small text-muted-foreground",children:e("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[M,t.jsx(hi,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(cl,{onConnected:()=>S(D=>D+1),notice:y})}):!r&&!ee?k?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"max-w-sm space-y-3",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("sessionAuth.error.networkDescription")})]})}):t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(qe,{width:120,height:120,isAnimated:!0})}):t.jsx(Le,{children:t.jsx(gi,{sdk:cn.getSdkClient(),directory:d||"",children:t.jsx(bi,{apis:n,children:t.jsx(xi,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[N&&O?t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background",children:t.jsx(qe,{width:120,height:120,isAnimated:!0})}):null,t.jsx(yi,{embeddedBackgroundWorkEnabled:o}),t.jsx(Yi,{}),t.jsx(Sa,{}),t.jsx(Kc,{onActiveConnectionDeleted:()=>{lt({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),S(D=>D+1)}}),t.jsx(vi,{}),t.jsx(wi,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),o?t.jsx(Ji,{}):null]})})})},E)})}const qc=()=>{Di(),ho().then(()=>{Promise.all([go(),Mi()]).catch(n=>{console.error("[mobile-main] settings init failed:",n)}),zi(),Oi(),Li()}).catch(n=>{console.error("[mobile-main] appearance init failed:",n)}).finally(()=>{ga()})};function wf(n){window.__OPENCHAMBER_SURFACE__="mobile",Ri(),qc(),ka(),Pi();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const o=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",r=o?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,i=t.jsx(Hc,{apis:r});ao.createRoot(e).render(t.jsx(cs.StrictMode,{children:t.jsx(Ti,{children:t.jsx(Ai,{children:t.jsx(Ii,{children:t.jsx(Qi,{children:o?i:t.jsx(_i,{children:i})})})})})}))}export{wf as renderMobileApp};
|