@pi-chamber/web 1.0.6-rc.2 → 1.0.6-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/assets/{DiagramView-BdDt1SI7.js → DiagramView-Dq5w8TCG.js} +1 -1
  2. package/dist/assets/{DiffView-Dk3VIX9E.js → DiffView-CFIjN2zy.js} +1 -1
  3. package/dist/assets/{FileSaveConflictDialog-DpyPjMH1.js → FileSaveConflictDialog-dFqLbFzT.js} +1 -1
  4. package/dist/assets/{FilesView-CumrwioK.js → FilesView-D0b2mEKA.js} +1 -1
  5. package/dist/assets/{GitHubDetailScaffold-CW2ZqU0Y.js → GitHubDetailScaffold-B2HRjT8V.js} +1 -1
  6. package/dist/assets/{GitHubLinkPicker-BjJNQ7Ap.js → GitHubLinkPicker-D7I3J9_O.js} +1 -1
  7. package/dist/assets/{GitHubListPrimitives-BcB-cCTs.js → GitHubListPrimitives-Dw5LAmzm.js} +1 -1
  8. package/dist/assets/{GitView-BoCaX5AO.js → GitView-Dhr7qVeI.js} +3 -3
  9. package/dist/assets/{IssuesSurface-CDZENHrE.js → IssuesSurface-Bya7OsRl.js} +1 -1
  10. package/dist/assets/{JsonTreeView-DpCgOUXg.js → JsonTreeView-BJr5kBg4.js} +1 -1
  11. package/dist/assets/{MarkdownRendererImpl-BkT5TUWF.js → MarkdownRendererImpl-DadkFPCz.js} +1 -1
  12. package/dist/assets/{PatchDiff-Dcr3EQgA.js → PatchDiff-B6RBZULC.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-o_Edh6ny.js → PierreDiffViewer-YJJQkE7t.js} +1 -1
  14. package/dist/assets/{PullRequestsSurface-eSXl6sef.js → PullRequestsSurface-D8JpzP5l.js} +2 -2
  15. package/dist/assets/{SessionSwitcherContent-Dm30bfpn.js → SessionSwitcherContent-CJ6C2ZKG.js} +1 -1
  16. package/dist/assets/{SessionSwitcherDropdown-CFj9VWSa.js → SessionSwitcherDropdown-CEAid1Bd.js} +2 -2
  17. package/dist/assets/{SessionUnreadDot-CHlK2awX.js → SessionUnreadDot-I1_tmqY9.js} +1 -1
  18. package/dist/assets/{SettingsView-CcHRUyev.js → SettingsView-B-b76XDV.js} +3 -3
  19. package/dist/assets/{SettingsWindow-BMzUErrM.js → SettingsWindow-5dK-buUn.js} +1 -1
  20. package/dist/assets/{ToolOutputDialog-QC8IoeBH.js → ToolOutputDialog-gITobhpo.js} +1 -1
  21. package/dist/assets/{ToolPartDiffPreview-BigGwtul.js → ToolPartDiffPreview-nOJxBl-Y.js} +1 -1
  22. package/dist/assets/{VirtualizedFileDiff-DvLCd7Qq.js → VirtualizedFileDiff-BmJk6XJm.js} +1 -1
  23. package/dist/assets/{computeVirtualFileMetrics-aX6tjjqv.js → computeVirtualFileMetrics-BCFpa-1q.js} +1 -1
  24. package/dist/assets/{contextFileOpenGuard-CZKJuHxf.js → contextFileOpenGuard-BCi5nTZp.js} +1 -1
  25. package/dist/assets/{gitStatusPredicates-3i8CcYWJ.js → gitStatusPredicates-BQOqDJU1.js} +1 -1
  26. package/dist/assets/{githubLink-BvevcNay.js → githubLink-CCmFsyTF.js} +1 -1
  27. package/dist/assets/{index-BMdbHCFt.js → index-BaeFf5Q8.js} +1 -1
  28. package/dist/assets/{main-BM-b2y8p.js → main-CgXs2e27.js} +2 -2
  29. package/dist/assets/{main-BXZ561E3.js → main-DoVzQV56.js} +4 -4
  30. package/dist/assets/{markdownCore-DbS8DkKw.js → markdownCore-DTNVLpYS.js} +1 -1
  31. package/dist/assets/{miniChat-DO3DW6kJ.js → miniChat-CrAin_em.js} +2 -2
  32. package/dist/assets/{mobile-BgWLkut6.js → mobile-EK9oTupb.js} +2 -2
  33. package/dist/assets/{pi-session-focus-preference-ChYVctYk.js → pi-session-focus-preference-BoN1cyoG.js} +1 -1
  34. package/dist/assets/{renderDiffWithHighlighter-xlvSvnTf.js → renderDiffWithHighlighter-DixZh5Zd.js} +1 -1
  35. package/dist/assets/{renderElectronMiniChatApp-CgVqxKDm.js → renderElectronMiniChatApp-0MqKeGfI.js} +2 -2
  36. package/dist/assets/{renderFileWithHighlighter-CCoYfC-t.js → renderFileWithHighlighter-s6fQq9eg.js} +1 -1
  37. package/dist/assets/{renderMobileApp-CoY1tsk5.js → renderMobileApp-BLoXL_J8.js} +3 -3
  38. package/dist/assets/{runtimeEndpointReset-fozcAShH.js → runtimeEndpointReset-Bv2Y1fMm.js} +4 -4
  39. package/dist/assets/{useAppFontEffects-D_gtiA95.js → useAppFontEffects-D2xXdmYC.js} +6 -6
  40. package/dist/assets/{useFilesViewSearch-BUxcZj60.js → useFilesViewSearch-BKotcAUN.js} +1 -1
  41. package/dist/assets/{useGitHubRemoteSearch-CevR5iLf.js → useGitHubRemoteSearch-CZ92xKSw.js} +1 -1
  42. package/dist/assets/{useSwitcherItems-kaRkXggX.js → useSwitcherItems-BfA4omGb.js} +1 -1
  43. package/dist/assets/{web-components-6ORYp3Iv.js → web-components-Bz5oGa3p.js} +1 -1
  44. package/dist/index.html +1 -1
  45. package/dist/mini-chat.html +1 -1
  46. package/dist/mobile.html +1 -1
  47. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-CumrwioK.js","assets/vendor-boot-CoTxysn6.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-clsx-B-dksMZM.js","assets/index-C2ISrmRR.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js","assets/index-DgwThEwf.css","assets/useAppFontEffects-D_gtiA95.js","assets/runtimeSurface-CJN1oo_1.js","assets/nativeFileSave-Bhafll_7.js","assets/vendor-codemirror-lang-javascript-Dkzl3s07.js","assets/vendor-lezer-javascript-B3s21DIS.js","assets/vendor-lezer-lr-Bllrq8hY.js","assets/vendor-codemirror-autocomplete-qsuH4Dh-.js","assets/vendor-codemirror-lang-json-CsdmtHhi.js","assets/vendor-lezer-json-DPFM6EBV.js","assets/vendor-codemirror-lang-css-2bFuyM70.js","assets/vendor-lezer-css-JnEzSyZR.js","assets/vendor-codemirror-lang-html-BV8lrR8v.js","assets/vendor-lezer-html-Cr3U-1pu.js","assets/vendor-codemirror-lang-markdown-C0Zu3b3n.js","assets/vendor-lezer-markdown-6-3PLvXG.js","assets/vendor-codemirror-language-data-vn2RyN9T.js","assets/vendor-codemirror-lang-python-Cv2exx_M.js","assets/vendor-lezer-python-CdHdN5qt.js","assets/shell-CjFT_Tl9.js","assets/appThemeRegistry-Ca8eGRB9.js","assets/registerCustomTheme-C-h6lsYW.js","assets/themeResolver-DrfmQi8i.js","assets/vendor-pierre-theming-BO6EPniU.js","assets/vendor-shikijs-core-Ck_OPM_T.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-DPFxvYtK.js","assets/vendor-hast-util-to-html-O3stl53j.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-C40bX6nM.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/FileSaveConflictDialog-DpyPjMH1.js","assets/vendor-react-drawio-IYnLUY5N.js","assets/runtimeEndpointReset-fozcAShH.js","assets/SessionUnreadDot-CHlK2awX.js","assets/permissionStore-zIpxq9Pq.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/vendor-xterm-xterm-css-DDGTF8rc.css","assets/useFilesViewSearch-BUxcZj60.js","assets/JsonTreeView-DpCgOUXg.js","assets/web-components-6ORYp3Iv.js","assets/computeVirtualFileMetrics-aX6tjjqv.js","assets/vendor-shiki-BEwTOAFg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/vendor-shikijs-engine-javascript-DL394yyj.js","assets/vendor-oniguruma-to-es-DgwFOwdE.js","assets/vendor-oniguruma-parser-BrbMHgHx.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-DNJrJKVb.js","assets/renderFileWithHighlighter-CCoYfC-t.js","assets/vendor-codemirror-search-BVCYIV0D.js","assets/vendor-replit-codemirror-vim-Cwhyn_5f.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/StickyHorizontalScrollbar-p7EbL2-E.js","assets/GitView-BoCaX5AO.js","assets/gitStatusPredicates-3i8CcYWJ.js","assets/GitHubDetailScaffold-CW2ZqU0Y.js","assets/vendor-dompurify-BGCr_sdL.js","assets/collapsible-0yfy07W2.js","assets/vendor-base-ui-C7vVMZTg.js","assets/PierreDiffViewer-o_Edh6ny.js","assets/VirtualizedFileDiff-DvLCd7Qq.js","assets/renderDiffWithHighlighter-xlvSvnTf.js","assets/vendor-diff-C3JhlQdm.js","assets/PullRequestsSurface-eSXl6sef.js","assets/useGitHubRemoteSearch-CevR5iLf.js","assets/GitHubListPrimitives-BcB-cCTs.js","assets/IssuesSurface-CDZENHrE.js","assets/githubLink-BvevcNay.js","assets/vendor-capacitor-app-NX6DULfp.js"])))=>i.map(i=>d[i]);
2
- import{j as e,aP as ze,aQ as Be,aR as Vt}from"./vendor-boot-CoTxysn6.js";import{a as qe,R as t}from"./vendor-react-Bz1tRBxM.js";/* empty css */import{b as Te,d as Gt,e as tt,f as M,u as Ct,i as Xt,h as je,n as Kt,r as he,j as ue,s as Ne,k as qt,l as Yt,m as nt,o as Qt,p as Nt,q as Jt,t as Zt,v as en}from"./index-C2ISrmRR.js";import{f as tn,a as nn,s as sn}from"./pi-session-focus-preference-ChYVctYk.js";import{u as rn,M as an,a as on,i as ln,D as st,b as rt,c as it,g as cn,d as at,e as un,s as dn,S as fn,f as hn,T as pn,h as ot,j as lt,k as mn,r as bn,l as xn,m as gn,n as yn,H as vn,A as wn,C as Sn,o as jn,p as Rn,q as kn,O as En,F as Cn,t as Nn,v as Tn,W as In,w as Pn}from"./runtimeEndpointReset-fozcAShH.js";import{g as Ie,l as An,u as Dn,a as Tt,b as _n,c as Mn,r as It,d as Ln,e as ke,t as He,o as On,I as ie,s as zn,f as Pt,P as ve,B as Pe,S as Wn,h as ae,i as Un,j as Bn,k as Hn,m as $n,n as Fn,p as Vn,q as Gn,v as At,w as Xn,E as ee,C as Me,x as Dt,y as Kn,z as qn,A as ct,D as Yn,F as Qn,G as Jn,H as Zn,J as es,K as ts,L as ns,M as ss,N as rs,O as me,Q as is,R as ye,T as as,U as os,V as ls,W as cs,X as us,Y as ds,Z as fs,_ as hs,$ as ps,a0 as ms,a1 as bs,a2 as xs,a3 as gs,a4 as ys,a5 as vs,a6 as ws,a7 as Ss,a8 as js,a9 as Rs,aa as ks,ab as Es,ac as Cs,ad as Ns,ae as Ts}from"./useAppFontEffects-D_gtiA95.js";import{u as Is,i as ut,p as Ps,s as As,m as Ds,M as _s,a as Ms,c as Ls,b as Le,d as $e,e as Os,g as Re,S as zs,A as Ws,f as Fe,r as Us}from"./SettingsView-CcHRUyev.js";import{f as Bs,S as Hs,a as $s}from"./SessionUnreadDot-CHlK2awX.js";import{u as Fs}from"./useSwitcherItems-kaRkXggX.js";import{_ as De}from"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-aparajita-capacitor-secure-storage-BLsm9T1Y.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";/* empty css */import"./nativeFileSave-Bhafll_7.js";import"./permissionStore-zIpxq9Pq.js";import"./runtimeSurface-CJN1oo_1.js";import"./vendor-qrcode-gzL9QFkg.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./collapsible-0yfy07W2.js";import"./vendor-base-ui-C7vVMZTg.js";let _t=null,dt=!1;const Vs=new Promise(s=>{_t=s});function Gs(){dt||(dt=!0,_t?.())}const Xs=6,Ks=s=>s.parentID??null,ft=s=>{const n=s.replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||n},qs=s=>s.replace(/\\/g,"/").replace(/\/+$/,""),Ys=(s,n)=>{if(!s)return"";let r=null,i=-1;for(const l of n){const a=qs(l.path);(s===a||s.startsWith(`${a}/`))&&a.length>i&&(r=l,i=a.length)}return r?r.label?.trim()||ft(r.path):ft(s)},Qs=()=>{const s=Ie().getState().catalog,n=[];for(const d of s.byId.values())d.archived||n.push(An(d));const r=Dn.getState().index.session.unseenCount,i=Tt.getState().projects,l=_n.getState().ids,a=Mn.getState().rankById;let o=0;const w=[];for(const d of n){const y=Ks(d)!==null,S=(r[d.id]??0)>0;S&&(o+=1),y||w.push({session:d,unread:S,project:Ys(It(d),i)})}w.sort(Ln(l,a,d=>d.session));const m=w.slice(0,Xs).map(({session:d,unread:y,project:j})=>({id:d.id,title:d.title??"",unread:y,project:j}));return{runtimeKey:Te(),attentionCount:o,recentSessions:m}},Js="__PICHAMBER_WIDGET_SNAPSHOT__",Zs=()=>{typeof window>"u"||(window[Js]=()=>{try{return JSON.stringify(Qs())}catch{return null}})},Ve="mobile-app-update-available",ht="mobile-app-update-toast-dismissed-version",er=()=>{const s=ke(a=>a.available),n=ke(a=>a.runtimeType),r=ke(a=>a.info?.version),i=ke(a=>a.info?.downloadUrl),l=qe.useRef(new Set);return qe.useEffect(()=>{if(Gt()!=="android"||n!=="mobile"||!s||!r||!i){He.dismiss(Ve);return}tt().getItem(ht)!==r&&(l.current.has(r)||(l.current.add(r),He.info("PiChamber update available",{id:Ve,description:`Version ${r} is ready for Android.`,duration:1/0,icon:e.jsx(ie,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:"Download",onClick:()=>{On(i)}},cancel:{label:"Dismiss",onClick:()=>{tt().setItem(ht,r),He.dismiss(Ve)}}})))},[s,i,n,r]),null},tr=s=>{const{persisted:n,persistedDirectory:r,stale:i,ready:l,catalog:a,runtimeKey:o,capturedRuntimeKey:w,storeIdentityMatches:m,generationMatches:d}=s;if(!n||!r)return{action:"wait"};if(i||o!==w||!m||!d)return{action:"wait"};if(!l||!a)return{action:"wait"};const y=a.byId.get(n.sessionId);return!y||y.archived?{action:"clear"}:{action:"select",sessionId:y.id,directory:y.directory??r}},nr=({onConnected:s,notice:n=null})=>{const r=Is(s),{connections:i,isBusy:l,isPasswordBusy:a,error:o,pendingConnection:w}=r,[m,d]=t.useState(""),[y,j]=t.useState(""),[S,N]=t.useState(""),[v,T]=t.useState(!1),[k,E]=t.useState(!1),C=t.useRef(null),p=t.useMemo(()=>ut(),[]),[f,I]=t.useState(()=>!ut()),[P,H]=t.useState(null),[$,_]=t.useState(""),A=t.useCallback(g=>{g.preventDefault(),r.connect({url:m,clientToken:S,label:y})},[S,r,y,m]),L=t.useCallback(g=>{if(/^pichamber:\/\//i.test(g.trim())){const R=Ps(g);if(R){if("pairing"in R){r.redeemPairingConnection(R.pairing);return}d(R.url),R.label&&j(R.label),R.clientToken&&N(R.clientToken);return}}d(g)},[r]),h=t.useCallback(async()=>{if(C.current||l)return;r.setError(null),T(!0);const g=new AbortController;C.current=g;try{const R=await As({signal:g.signal});switch(C.current===g&&(C.current=null,T(!1)),R.status){case"ok":E(!0),d(R.url),R.label&&j(R.label),R.clientToken&&N(R.clientToken),await r.connect({url:R.url,clientToken:R.clientToken,label:R.label});break;case"pairing":E(!0),await r.redeemPairingConnection(R.pairing);break;case"permission-denied":r.setError("Camera access is off. Enable it in Settings to scan a QR code.");break;case"invalid":r.setError("That QR code is not an PiChamber connection code.");break;case"unsupported":r.setError("QR scanning is only available in the installed mobile app.");break;case"failed":r.setError("Could not scan that QR code. Try again or enter the URL manually.");break;default:break}}finally{E(!1),C.current===g&&(C.current=null,T(!1))}},[r,l]);t.useEffect(()=>()=>C.current?.abort(),[]);const D=t.useCallback(g=>{g.preventDefault(),r.submitPassword($)},[r,$]),z=t.useMemo(()=>zn(i.map(g=>Ds(g,{isCurrent:!1,status:P===g.id?{kind:"connecting"}:{kind:"unknown"},probing:P===g.id}))),[i,P]),B=t.useCallback(g=>{const R=i.find(V=>V.id===g)??null;R&&(H(g),r.connect({id:R.id,candidates:R.candidates,clientToken:R.clientToken,label:R.label}).finally(()=>H(null)))},[r,i]),W=t.useCallback(()=>{_(""),r.cancelPassword()},[r]),q=t.useCallback(()=>v?(C.current?.abort(),T(!1),!0):w?(W(),!0):f&&p?(I(!1),!0):!1,[W,v,f,w,p]);return Pt(q),e.jsxs(e.Fragment,{children:[v?e.jsx(_s,{onCancel:()=>C.current?.abort()}):null,k?e.jsx(Ms,{}):null,e.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:e.jsxs("div",{className:"m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8",children:[e.jsxs("div",{className:"flex flex-col items-center gap-5 text-center",children:[e.jsx(ve,{width:72,height:72,className:"size-[72px]"}),e.jsx("h1",{className:"typography-h2 text-foreground",children:"Connect to PiChamber"})]}),n?e.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:[e.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:e.jsx(ie,{name:n.kind==="auth-expired"?"lock":"cloud-off",className:"size-[18px]"})}),e.jsx("p",{className:"min-w-0 flex-1 typography-small text-foreground",children:n.kind==="auth-expired"?`Access to ${n.label} has expired or was revoked. Sign in again.`:`Couldn't reach ${n.label}. Check that the server is running.`})]}):null,w?e.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:D,children:[e.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:e.jsx(ie,{name:"lock",className:"size-[18px]"})}),e.jsxs("div",{className:"min-w-0 text-left",children:[e.jsx("p",{className:"truncate typography-ui-label text-foreground",children:w.label}),e.jsx("p",{className:"truncate typography-small text-muted-foreground",children:w.candidates.some(g=>g.kind==="direct")?Ls(w):"via PiChamber Relay"})]})]}),e.jsx("input",{...$e,value:$,onChange:g=>_(g.target.value),placeholder:"PiChamber password","aria-label":"Password",type:"password",autoFocus:!0,className:Le}),o?e.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:o}):null,e.jsx(Pe,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!$.trim(),children:a?"Connecting...":"Unlock and connect"}),e.jsx(Pe,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:W,children:"Use another server"})]}):e.jsxs("div",{className:"flex w-full flex-col gap-6",children:[p?e.jsxs("div",{className:"flex w-full flex-col gap-2",children:[e.jsxs(Pe,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{h()},disabled:v||l,children:[e.jsx(ie,{name:"scan-2",className:M("size-[18px]",v&&"animate-pulse")}),l?"Connecting...":"Scan QR code"]}),e.jsx("p",{className:"px-2 text-center typography-small text-muted-foreground",children:"On your computer, open «Add a device» to show a QR code, then scan it here."})]}):null,o&&!f?e.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:o}):null,i.length>0?e.jsxs("section",{className:"flex w-full flex-col gap-2.5",children:[e.jsx("h2",{className:"text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground",children:"Saved servers"}),e.jsx(Wn,{items:z,layout:"touch",switchLabel:"Connect",pendingId:P,actionsDisabled:l,onSwitch:g=>B(g.id),emptyMessage:"No saved servers yet."})]}):null,e.jsxs("div",{className:"flex w-full flex-col",children:[p?e.jsxs("button",{type:"button",onClick:()=>I(g=>!g),"aria-expanded":f,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:[e.jsx("span",{children:"Connect by address"}),e.jsx(ie,{name:"arrow-down-s",className:M("size-4 transition-transform duration-200",f&&"rotate-180")})]}):null,e.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:f?"1fr":"0fr"},children:e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsxs("form",{className:"flex w-full flex-col gap-3 pt-3",onSubmit:A,children:[e.jsx("input",{...$e,value:m,onChange:g=>L(g.target.value),placeholder:"http://192.168.1.74:2606","aria-label":"Server URL",type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:f?void 0:-1,className:M(Le,"text-center")}),e.jsx("input",{value:y,onChange:g=>j(g.target.value),placeholder:"Optional display name","aria-label":"Name",autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:f?void 0:-1,className:M(Le,"text-center")}),e.jsx("input",{...$e,value:S,onChange:g=>N(g.target.value),placeholder:"Paste access token","aria-label":"Client token",tabIndex:f?void 0:-1,autoCapitalize:"none",className:M(Le,"text-center")}),e.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:"Only needed if your server requires a token instead of a password."}),o?e.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:o}):null,e.jsx(Pe,{type:"submit",variant:p?"outline":"default",size:"lg",className:"h-12 w-full",disabled:l||v||!m.trim(),children:l?"Connecting...":"Connect"})]})})})]})]})]})})]})},sr=10,rr=(s,n)=>At(s,n),ir=({session:s,meta:n,active:r,onSelect:i})=>{const l=Un(s.id),a=Bn(s.id),o=Hn(s.id),w=l?.type??"idle",m=w==="busy"||w==="retry",d=$n({pendingInput:o,isStreaming:m,unseenCount:a,isActive:r}),y=d==="needs-input",j=y&&o?Fn(o.kind,o.count):null,S=d==="unread",N=Vn(s.id,m),v=m&&N,T=Bs(s.time?.updated??s.time?.created??0);return e.jsxs("button",{type:"button",className:M("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",r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]"),onClick:i,style:{touchAction:"manipulation"},children:[e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:M("block truncate typography-ui-label",r?"text-primary":"text-foreground"),children:rr(s,"Untitled session")}),n?e.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:n}):null]}),y?e.jsx(Gn,{label:j??"Needs input"}):m?e.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-primary","aria-hidden":!0}):S?e.jsx(Hs,{label:"Session complete"}):null,v?e.jsx($s,{sessionId:s.id,running:m,className:"typography-micro"}):S||y?null:T?e.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:T}):null]})},ar=({open:s,onClose:n,anchorRef:r})=>{const{panelRef:i,wrapperRef:l,shouldRender:a,isExiting:o,anchorLeft:w,isPopover:m}=rn({open:s,onClose:n,anchorRef:r}),d=ae(v=>v.currentSessionId),y=ae(v=>v.setCurrentSession),j=Tt(v=>v.setActiveProjectIdOnly),S=Fs(s||a,{maxParents:sr}),N=t.useCallback(v=>{y(v.id,It(v)),n()},[n,y]);return a?e.jsxs("div",{ref:l,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:[e.jsx("div",{ref:i,role:"dialog","aria-label":"Open session switcher",className:M("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",m?"absolute origin-top-left":"mx-3 mt-2",o?"pointer-events-none":"pointer-events-auto"),style:{animation:`${o?"session-switcher-out":"session-switcher-in"} ${o?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...m?{top:8,left:w??8,width:`min(${an}px, calc(100% - 16px))`}:null},children:e.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:S.length===0?e.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:"No recent sessions"}):S.map(v=>{const T=v.node.session,k=[v.secondaryMeta?.projectLabel,v.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return e.jsx(ir,{session:T,meta:k,active:T.id===d,onSelect:()=>{v.projectId&&j(v.projectId),N(T)}},T.id)})})}),e.jsx("style",{children:`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-D0b2mEKA.js","assets/vendor-boot-CoTxysn6.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-clsx-B-dksMZM.js","assets/index-C2ISrmRR.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js","assets/index-DgwThEwf.css","assets/useAppFontEffects-D2xXdmYC.js","assets/runtimeSurface-CJN1oo_1.js","assets/nativeFileSave-Bhafll_7.js","assets/vendor-codemirror-lang-javascript-Dkzl3s07.js","assets/vendor-lezer-javascript-B3s21DIS.js","assets/vendor-lezer-lr-Bllrq8hY.js","assets/vendor-codemirror-autocomplete-qsuH4Dh-.js","assets/vendor-codemirror-lang-json-CsdmtHhi.js","assets/vendor-lezer-json-DPFM6EBV.js","assets/vendor-codemirror-lang-css-2bFuyM70.js","assets/vendor-lezer-css-JnEzSyZR.js","assets/vendor-codemirror-lang-html-BV8lrR8v.js","assets/vendor-lezer-html-Cr3U-1pu.js","assets/vendor-codemirror-lang-markdown-C0Zu3b3n.js","assets/vendor-lezer-markdown-6-3PLvXG.js","assets/vendor-codemirror-language-data-vn2RyN9T.js","assets/vendor-codemirror-lang-python-Cv2exx_M.js","assets/vendor-lezer-python-CdHdN5qt.js","assets/shell-CjFT_Tl9.js","assets/appThemeRegistry-Ca8eGRB9.js","assets/registerCustomTheme-C-h6lsYW.js","assets/themeResolver-DrfmQi8i.js","assets/vendor-pierre-theming-BO6EPniU.js","assets/vendor-shikijs-core-Ck_OPM_T.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-DPFxvYtK.js","assets/vendor-hast-util-to-html-O3stl53j.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-C40bX6nM.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/FileSaveConflictDialog-dFqLbFzT.js","assets/vendor-react-drawio-IYnLUY5N.js","assets/runtimeEndpointReset-Bv2Y1fMm.js","assets/SessionUnreadDot-I1_tmqY9.js","assets/permissionStore-zIpxq9Pq.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/vendor-xterm-xterm-css-DDGTF8rc.css","assets/useFilesViewSearch-BKotcAUN.js","assets/JsonTreeView-BJr5kBg4.js","assets/web-components-Bz5oGa3p.js","assets/computeVirtualFileMetrics-BCFpa-1q.js","assets/vendor-shiki-BEwTOAFg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/vendor-shikijs-engine-javascript-DL394yyj.js","assets/vendor-oniguruma-to-es-DgwFOwdE.js","assets/vendor-oniguruma-parser-BrbMHgHx.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-DNJrJKVb.js","assets/renderFileWithHighlighter-s6fQq9eg.js","assets/vendor-codemirror-search-BVCYIV0D.js","assets/vendor-replit-codemirror-vim-Cwhyn_5f.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/StickyHorizontalScrollbar-p7EbL2-E.js","assets/GitView-Dhr7qVeI.js","assets/gitStatusPredicates-BQOqDJU1.js","assets/GitHubDetailScaffold-B2HRjT8V.js","assets/vendor-dompurify-BGCr_sdL.js","assets/collapsible-0yfy07W2.js","assets/vendor-base-ui-C7vVMZTg.js","assets/PierreDiffViewer-YJJQkE7t.js","assets/VirtualizedFileDiff-BmJk6XJm.js","assets/renderDiffWithHighlighter-DixZh5Zd.js","assets/vendor-diff-C3JhlQdm.js","assets/PullRequestsSurface-D8JpzP5l.js","assets/useGitHubRemoteSearch-CZ92xKSw.js","assets/GitHubListPrimitives-Dw5LAmzm.js","assets/IssuesSurface-Bya7OsRl.js","assets/githubLink-CCmFsyTF.js","assets/vendor-capacitor-app-NX6DULfp.js"])))=>i.map(i=>d[i]);
2
+ import{j as e,aP as ze,aQ as Be,aR as Vt}from"./vendor-boot-CoTxysn6.js";import{a as qe,R as t}from"./vendor-react-Bz1tRBxM.js";/* empty css */import{b as Te,d as Gt,e as tt,f as M,u as Ct,i as Xt,h as je,n as Kt,r as he,j as ue,s as Ne,k as qt,l as Yt,m as nt,o as Qt,p as Nt,q as Jt,t as Zt,v as en}from"./index-C2ISrmRR.js";import{f as tn,a as nn,s as sn}from"./pi-session-focus-preference-BoN1cyoG.js";import{u as rn,M as an,a as on,i as ln,D as st,b as rt,c as it,g as cn,d as at,e as un,s as dn,S as fn,f as hn,T as pn,h as ot,j as lt,k as mn,r as bn,l as xn,m as gn,n as yn,H as vn,A as wn,C as Sn,o as jn,p as Rn,q as kn,O as En,F as Cn,t as Nn,v as Tn,W as In,w as Pn}from"./runtimeEndpointReset-Bv2Y1fMm.js";import{g as Ie,l as An,u as Dn,a as Tt,b as _n,c as Mn,r as It,d as Ln,e as ke,t as He,o as On,I as ie,s as zn,f as Pt,P as ve,B as Pe,S as Wn,h as ae,i as Un,j as Bn,k as Hn,m as $n,n as Fn,p as Vn,q as Gn,v as At,w as Xn,E as ee,C as Me,x as Dt,y as Kn,z as qn,A as ct,D as Yn,F as Qn,G as Jn,H as Zn,J as es,K as ts,L as ns,M as ss,N as rs,O as me,Q as is,R as ye,T as as,U as os,V as ls,W as cs,X as us,Y as ds,Z as fs,_ as hs,$ as ps,a0 as ms,a1 as bs,a2 as xs,a3 as gs,a4 as ys,a5 as vs,a6 as ws,a7 as Ss,a8 as js,a9 as Rs,aa as ks,ab as Es,ac as Cs,ad as Ns,ae as Ts}from"./useAppFontEffects-D2xXdmYC.js";import{u as Is,i as ut,p as Ps,s as As,m as Ds,M as _s,a as Ms,c as Ls,b as Le,d as $e,e as Os,g as Re,S as zs,A as Ws,f as Fe,r as Us}from"./SettingsView-B-b76XDV.js";import{f as Bs,S as Hs,a as $s}from"./SessionUnreadDot-I1_tmqY9.js";import{u as Fs}from"./useSwitcherItems-BfA4omGb.js";import{_ as De}from"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-aparajita-capacitor-secure-storage-BLsm9T1Y.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";/* empty css */import"./nativeFileSave-Bhafll_7.js";import"./permissionStore-zIpxq9Pq.js";import"./runtimeSurface-CJN1oo_1.js";import"./vendor-qrcode-gzL9QFkg.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./collapsible-0yfy07W2.js";import"./vendor-base-ui-C7vVMZTg.js";let _t=null,dt=!1;const Vs=new Promise(s=>{_t=s});function Gs(){dt||(dt=!0,_t?.())}const Xs=6,Ks=s=>s.parentID??null,ft=s=>{const n=s.replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||n},qs=s=>s.replace(/\\/g,"/").replace(/\/+$/,""),Ys=(s,n)=>{if(!s)return"";let r=null,i=-1;for(const l of n){const a=qs(l.path);(s===a||s.startsWith(`${a}/`))&&a.length>i&&(r=l,i=a.length)}return r?r.label?.trim()||ft(r.path):ft(s)},Qs=()=>{const s=Ie().getState().catalog,n=[];for(const d of s.byId.values())d.archived||n.push(An(d));const r=Dn.getState().index.session.unseenCount,i=Tt.getState().projects,l=_n.getState().ids,a=Mn.getState().rankById;let o=0;const w=[];for(const d of n){const y=Ks(d)!==null,S=(r[d.id]??0)>0;S&&(o+=1),y||w.push({session:d,unread:S,project:Ys(It(d),i)})}w.sort(Ln(l,a,d=>d.session));const m=w.slice(0,Xs).map(({session:d,unread:y,project:j})=>({id:d.id,title:d.title??"",unread:y,project:j}));return{runtimeKey:Te(),attentionCount:o,recentSessions:m}},Js="__PICHAMBER_WIDGET_SNAPSHOT__",Zs=()=>{typeof window>"u"||(window[Js]=()=>{try{return JSON.stringify(Qs())}catch{return null}})},Ve="mobile-app-update-available",ht="mobile-app-update-toast-dismissed-version",er=()=>{const s=ke(a=>a.available),n=ke(a=>a.runtimeType),r=ke(a=>a.info?.version),i=ke(a=>a.info?.downloadUrl),l=qe.useRef(new Set);return qe.useEffect(()=>{if(Gt()!=="android"||n!=="mobile"||!s||!r||!i){He.dismiss(Ve);return}tt().getItem(ht)!==r&&(l.current.has(r)||(l.current.add(r),He.info("PiChamber update available",{id:Ve,description:`Version ${r} is ready for Android.`,duration:1/0,icon:e.jsx(ie,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:"Download",onClick:()=>{On(i)}},cancel:{label:"Dismiss",onClick:()=>{tt().setItem(ht,r),He.dismiss(Ve)}}})))},[s,i,n,r]),null},tr=s=>{const{persisted:n,persistedDirectory:r,stale:i,ready:l,catalog:a,runtimeKey:o,capturedRuntimeKey:w,storeIdentityMatches:m,generationMatches:d}=s;if(!n||!r)return{action:"wait"};if(i||o!==w||!m||!d)return{action:"wait"};if(!l||!a)return{action:"wait"};const y=a.byId.get(n.sessionId);return!y||y.archived?{action:"clear"}:{action:"select",sessionId:y.id,directory:y.directory??r}},nr=({onConnected:s,notice:n=null})=>{const r=Is(s),{connections:i,isBusy:l,isPasswordBusy:a,error:o,pendingConnection:w}=r,[m,d]=t.useState(""),[y,j]=t.useState(""),[S,N]=t.useState(""),[v,T]=t.useState(!1),[k,E]=t.useState(!1),C=t.useRef(null),p=t.useMemo(()=>ut(),[]),[f,I]=t.useState(()=>!ut()),[P,H]=t.useState(null),[$,_]=t.useState(""),A=t.useCallback(g=>{g.preventDefault(),r.connect({url:m,clientToken:S,label:y})},[S,r,y,m]),L=t.useCallback(g=>{if(/^pichamber:\/\//i.test(g.trim())){const R=Ps(g);if(R){if("pairing"in R){r.redeemPairingConnection(R.pairing);return}d(R.url),R.label&&j(R.label),R.clientToken&&N(R.clientToken);return}}d(g)},[r]),h=t.useCallback(async()=>{if(C.current||l)return;r.setError(null),T(!0);const g=new AbortController;C.current=g;try{const R=await As({signal:g.signal});switch(C.current===g&&(C.current=null,T(!1)),R.status){case"ok":E(!0),d(R.url),R.label&&j(R.label),R.clientToken&&N(R.clientToken),await r.connect({url:R.url,clientToken:R.clientToken,label:R.label});break;case"pairing":E(!0),await r.redeemPairingConnection(R.pairing);break;case"permission-denied":r.setError("Camera access is off. Enable it in Settings to scan a QR code.");break;case"invalid":r.setError("That QR code is not an PiChamber connection code.");break;case"unsupported":r.setError("QR scanning is only available in the installed mobile app.");break;case"failed":r.setError("Could not scan that QR code. Try again or enter the URL manually.");break;default:break}}finally{E(!1),C.current===g&&(C.current=null,T(!1))}},[r,l]);t.useEffect(()=>()=>C.current?.abort(),[]);const D=t.useCallback(g=>{g.preventDefault(),r.submitPassword($)},[r,$]),z=t.useMemo(()=>zn(i.map(g=>Ds(g,{isCurrent:!1,status:P===g.id?{kind:"connecting"}:{kind:"unknown"},probing:P===g.id}))),[i,P]),B=t.useCallback(g=>{const R=i.find(V=>V.id===g)??null;R&&(H(g),r.connect({id:R.id,candidates:R.candidates,clientToken:R.clientToken,label:R.label}).finally(()=>H(null)))},[r,i]),W=t.useCallback(()=>{_(""),r.cancelPassword()},[r]),q=t.useCallback(()=>v?(C.current?.abort(),T(!1),!0):w?(W(),!0):f&&p?(I(!1),!0):!1,[W,v,f,w,p]);return Pt(q),e.jsxs(e.Fragment,{children:[v?e.jsx(_s,{onCancel:()=>C.current?.abort()}):null,k?e.jsx(Ms,{}):null,e.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:e.jsxs("div",{className:"m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8",children:[e.jsxs("div",{className:"flex flex-col items-center gap-5 text-center",children:[e.jsx(ve,{width:72,height:72,className:"size-[72px]"}),e.jsx("h1",{className:"typography-h2 text-foreground",children:"Connect to PiChamber"})]}),n?e.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:[e.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:e.jsx(ie,{name:n.kind==="auth-expired"?"lock":"cloud-off",className:"size-[18px]"})}),e.jsx("p",{className:"min-w-0 flex-1 typography-small text-foreground",children:n.kind==="auth-expired"?`Access to ${n.label} has expired or was revoked. Sign in again.`:`Couldn't reach ${n.label}. Check that the server is running.`})]}):null,w?e.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:D,children:[e.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:e.jsx(ie,{name:"lock",className:"size-[18px]"})}),e.jsxs("div",{className:"min-w-0 text-left",children:[e.jsx("p",{className:"truncate typography-ui-label text-foreground",children:w.label}),e.jsx("p",{className:"truncate typography-small text-muted-foreground",children:w.candidates.some(g=>g.kind==="direct")?Ls(w):"via PiChamber Relay"})]})]}),e.jsx("input",{...$e,value:$,onChange:g=>_(g.target.value),placeholder:"PiChamber password","aria-label":"Password",type:"password",autoFocus:!0,className:Le}),o?e.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:o}):null,e.jsx(Pe,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!$.trim(),children:a?"Connecting...":"Unlock and connect"}),e.jsx(Pe,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:W,children:"Use another server"})]}):e.jsxs("div",{className:"flex w-full flex-col gap-6",children:[p?e.jsxs("div",{className:"flex w-full flex-col gap-2",children:[e.jsxs(Pe,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{h()},disabled:v||l,children:[e.jsx(ie,{name:"scan-2",className:M("size-[18px]",v&&"animate-pulse")}),l?"Connecting...":"Scan QR code"]}),e.jsx("p",{className:"px-2 text-center typography-small text-muted-foreground",children:"On your computer, open «Add a device» to show a QR code, then scan it here."})]}):null,o&&!f?e.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:o}):null,i.length>0?e.jsxs("section",{className:"flex w-full flex-col gap-2.5",children:[e.jsx("h2",{className:"text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground",children:"Saved servers"}),e.jsx(Wn,{items:z,layout:"touch",switchLabel:"Connect",pendingId:P,actionsDisabled:l,onSwitch:g=>B(g.id),emptyMessage:"No saved servers yet."})]}):null,e.jsxs("div",{className:"flex w-full flex-col",children:[p?e.jsxs("button",{type:"button",onClick:()=>I(g=>!g),"aria-expanded":f,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:[e.jsx("span",{children:"Connect by address"}),e.jsx(ie,{name:"arrow-down-s",className:M("size-4 transition-transform duration-200",f&&"rotate-180")})]}):null,e.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:f?"1fr":"0fr"},children:e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsxs("form",{className:"flex w-full flex-col gap-3 pt-3",onSubmit:A,children:[e.jsx("input",{...$e,value:m,onChange:g=>L(g.target.value),placeholder:"http://192.168.1.74:2606","aria-label":"Server URL",type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:f?void 0:-1,className:M(Le,"text-center")}),e.jsx("input",{value:y,onChange:g=>j(g.target.value),placeholder:"Optional display name","aria-label":"Name",autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:f?void 0:-1,className:M(Le,"text-center")}),e.jsx("input",{...$e,value:S,onChange:g=>N(g.target.value),placeholder:"Paste access token","aria-label":"Client token",tabIndex:f?void 0:-1,autoCapitalize:"none",className:M(Le,"text-center")}),e.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:"Only needed if your server requires a token instead of a password."}),o?e.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:o}):null,e.jsx(Pe,{type:"submit",variant:p?"outline":"default",size:"lg",className:"h-12 w-full",disabled:l||v||!m.trim(),children:l?"Connecting...":"Connect"})]})})})]})]})]})})]})},sr=10,rr=(s,n)=>At(s,n),ir=({session:s,meta:n,active:r,onSelect:i})=>{const l=Un(s.id),a=Bn(s.id),o=Hn(s.id),w=l?.type??"idle",m=w==="busy"||w==="retry",d=$n({pendingInput:o,isStreaming:m,unseenCount:a,isActive:r}),y=d==="needs-input",j=y&&o?Fn(o.kind,o.count):null,S=d==="unread",N=Vn(s.id,m),v=m&&N,T=Bs(s.time?.updated??s.time?.created??0);return e.jsxs("button",{type:"button",className:M("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",r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]"),onClick:i,style:{touchAction:"manipulation"},children:[e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:M("block truncate typography-ui-label",r?"text-primary":"text-foreground"),children:rr(s,"Untitled session")}),n?e.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:n}):null]}),y?e.jsx(Gn,{label:j??"Needs input"}):m?e.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-primary","aria-hidden":!0}):S?e.jsx(Hs,{label:"Session complete"}):null,v?e.jsx($s,{sessionId:s.id,running:m,className:"typography-micro"}):S||y?null:T?e.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:T}):null]})},ar=({open:s,onClose:n,anchorRef:r})=>{const{panelRef:i,wrapperRef:l,shouldRender:a,isExiting:o,anchorLeft:w,isPopover:m}=rn({open:s,onClose:n,anchorRef:r}),d=ae(v=>v.currentSessionId),y=ae(v=>v.setCurrentSession),j=Tt(v=>v.setActiveProjectIdOnly),S=Fs(s||a,{maxParents:sr}),N=t.useCallback(v=>{y(v.id,It(v)),n()},[n,y]);return a?e.jsxs("div",{ref:l,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:[e.jsx("div",{ref:i,role:"dialog","aria-label":"Open session switcher",className:M("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",m?"absolute origin-top-left":"mx-3 mt-2",o?"pointer-events-none":"pointer-events-auto"),style:{animation:`${o?"session-switcher-out":"session-switcher-in"} ${o?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...m?{top:8,left:w??8,width:`min(${an}px, calc(100% - 16px))`}:null},children:e.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:S.length===0?e.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:"No recent sessions"}):S.map(v=>{const T=v.node.session,k=[v.secondaryMeta?.projectLabel,v.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return e.jsx(ir,{session:T,meta:k,active:T.id===d,onSelect:()=>{v.projectId&&j(v.projectId),N(T)}},T.id)})})}),e.jsx("style",{children:`
3
3
  @keyframes session-switcher-in {
4
4
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
5
5
  to { opacity: 1; transform: translateY(0) scale(1); }
@@ -8,4 +8,4 @@ import{j as e,aP as ze,aQ as Be,aR as Vt}from"./vendor-boot-CoTxysn6.js";import{
8
8
  from { opacity: 1; transform: translateY(0) scale(1); }
9
9
  to { opacity: 0; transform: translateY(-6px) scale(0.985); }
10
10
  }
11
- `})]}):null},or=({onOpenSessions:s,onOpenWorkspace:n,compactTitle:r=!1})=>{const[i,l]=t.useState(!1),[a,o]=t.useState(!1),w=t.useRef(null),m=Ct(p=>p.currentDirectory),d=ae(p=>p.currentSessionId),j=ae(t.useCallback(p=>d?p.getDirectoryForSession(d):null,[d]))||m,S=Xn(d),N=ae(p=>!!p.newSessionDraft?.open),T=S?.title?.trim()||(d?At(S,"Untitled session"):"New session");t.useEffect(()=>{l(!1),o(!1)},[d,j]);const k=t.useCallback(()=>{l(!1),o(!1),s()},[s]),E=t.useCallback(p=>{l(f=>{const I=typeof p=="function"?p(f):p;return I&&o(!1),I})},[]),C=t.useCallback(()=>{o(p=>{const f=!p;return f&&l(!1),f})},[]);return e.jsxs(e.Fragment,{children:[e.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:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:e.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[e.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":"Open sessions and projects",onClick:k,style:{touchAction:"manipulation"},children:e.jsx(ie,{name:"list-unordered",className:"size-5"})}),e.jsx("button",{ref:w,type:"button",className:M("flex h-10 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",r?"shrink":"flex-1"),"aria-label":"Open session switcher","aria-haspopup":"dialog","aria-expanded":a,onClick:C,style:{touchAction:"manipulation"},children:e.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[e.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:T}),e.jsx(ie,{name:"arrow-down-s",className:M("size-4 shrink-0 text-muted-foreground transition-transform duration-150",a&&"rotate-180")})]})}),r?e.jsx("div",{className:"min-w-0 flex-1"}):null,e.jsx(on,{open:i,onOpenChange:E,currentSessionId:d,effectiveDirectory:j,isNewSessionDraftOpen:N}),e.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":"Open workspace panel",onClick:()=>{l(!1),o(!1),n()},style:{touchAction:"manipulation"},children:e.jsx(ie,{name:"layout-right",className:"size-5"})})]})}),e.jsx(ar,{open:a,onClose:()=>o(!1),anchorRef:w})]})},lr=({onActiveConnectionDeleted:s,onConnect:n})=>e.jsx(Os,{onConnect:n,onActiveConnectionDeleted:s,showDiagnostics:!0}),Ee=320,be="cubic-bezier(0.22, 1, 0.36, 1)",Mt=({side:s,enabled:n,open:r,drawerRef:i,scrimRef:l,onClose:a,widthRatio:o,prefersReducedMotion:w})=>{t.useEffect(()=>{if(!n||!r)return;const m=i.current,d=l.current;if(!m||!d)return;let y=!1,j=!1,S=!1,N=0,v=0,T=0,k=0;const E=w?0:Ee,C=s==="left"?"translateX(-100%)":"translateX(100%)",p=()=>({drawer:E?`transform ${E}ms ${be}`:"none",scrim:E?`opacity ${E}ms ${be}`:"none"}),f=()=>{const h=p();m.style.transition=h.drawer,d.style.transition=h.scrim,m.style.transform="none",d.style.opacity="1",d.style.pointerEvents="auto"},I=()=>{y=!1,j=!1,S=!1},P=()=>{if(!(y||j)){I();return}f(),I()},H=h=>{if(h.touches.length!==1){(y||j)&&P();return}if(ln(h.target,m,{excludeInteractive:!1}))return;m.style.transition&&m.style.transition!=="none"&&(m.style.transition="none",d.style.transition="none");const D=h.touches[0];N=D.clientX,v=D.clientY,T=Date.now(),k=m.offsetWidth||window.innerWidth*o,k<10&&(k=window.innerWidth*o),y=!0,j=!1,S=!1},$=h=>{if(!y)return;if(h.touches.length!==1){P();return}const D=h.touches[0],z=D.clientX-N,B=D.clientY-v;if(!S){if(Math.abs(z)<st&&Math.abs(B)<st)return;if(Math.abs(B)>Math.abs(z)*rt||!it(s,z)){y=!1;return}S=!0,j=!0,m.style.transition="none",d.style.transition="none"}if(!j)return;h.cancelable&&h.preventDefault();const W=at(s,z,k);m.style.transform=cn(s,W),d.style.opacity=String(W)},_=(h,D,z)=>{if(!y)return;const B=h-N,W=D-v,q=Math.max(1,Date.now()-T),g=at(s,B,k),R=dn({side:s,dx:B,dy:W,dt:q,progress:g,isDragging:j}),V=p();m.style.transition=V.drawer,d.style.transition=V.scrim,m.style.transform=R?C:"none",d.style.opacity=R?"0":"1",d.style.pointerEvents=R?"none":"auto",I(),R&&a()},A=h=>{const D=h.changedTouches[0];if(!D){P();return}const z=D.clientX-N,B=D.clientY-v,W=Math.abs(z)>=un&&Math.abs(B)<=Math.abs(z)*rt&&it(s,z);y&&(j||W)&&h.cancelable&&h.preventDefault(),_(D.clientX,D.clientY)},L=()=>{P()};return m.addEventListener("touchstart",H,{passive:!0}),m.addEventListener("touchmove",$,{passive:!1}),m.addEventListener("touchend",A,{passive:!1}),m.addEventListener("touchcancel",L,{passive:!0}),()=>{try{P()}catch{}m.removeEventListener("touchstart",H),m.removeEventListener("touchmove",$),m.removeEventListener("touchend",A),m.removeEventListener("touchcancel",L)}},[i,n,a,r,w,l,s,o])},cr=16,pt=t.memo(function({open:n,onOpenChange:r,variant:i="drawer",drawerRefExternal:l,scrimRefExternal:a,rootRefExternal:o}){const w=t.useRef(null),m=t.useCallback(()=>{const f=typeof document<"u"?document.activeElement:null;f instanceof HTMLElement&&w.current?.contains(f)&&f.blur(),r(!1)},[r]),[d,y]=t.useState(!1),j=t.useRef(null),S=t.useRef(null),N=l??j,v=a??S,T=t.useCallback(f=>{w.current=f,o&&(o.current=f)},[o]),k=t.useMemo(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[]);t.useEffect(()=>{const f=w.current;if(!f||n)return;const I=document.activeElement;I&&f.contains(I)&&I.blur()},[n]),t.useEffect(()=>{if(i!=="sidebar"){if(n){const f=window.setTimeout(()=>y(!0),k?0:cr);return()=>window.clearTimeout(f)}y(!1)}},[n,k,i]),t.useEffect(()=>{if(i==="sidebar"||!n)return;const f=document.body.style.overflow;document.body.style.overflow="hidden";const I=P=>{P.key==="Escape"&&m()};return document.addEventListener("keydown",I),()=>{document.body.style.overflow=f,document.removeEventListener("keydown",I)}},[m,n,i]);const E=i==="sidebar",C=e.jsx(fn,{mobileVariant:!E,isVisible:n,allowReselect:!0,onSessionSelected:E?void 0:m,onNavigateAway:E?void 0:m});if(Mt({side:"left",enabled:i==="drawer",open:n,drawerRef:N,scrimRef:v,onClose:m,widthRatio:.72,prefersReducedMotion:k}),i==="sidebar")return e.jsx("aside",{className:"relative flex h-full w-full flex-col bg-sidebar",children:C});if(typeof document>"u")return null;const p=k?0:Ee;return ze.createPortal(e.jsxs("div",{ref:T,className:"fixed inset-0 z-50",inert:!n,style:{pointerEvents:n?"auto":"none"},"data-mobile-sessions-root":"true",children:[e.jsx("button",{ref:v,type:"button",className:"absolute inset-0 cursor-default bg-black/70","aria-label":"Close sessions",onClick:m,tabIndex:n?0:-1,style:{opacity:d?1:0,transition:`opacity ${p}ms ${be}`},"data-mobile-sessions-scrim":"true"}),e.jsx("div",{ref:N,className:M("relative z-10 flex h-full w-[72%] max-w-[72%] flex-col bg-sidebar"),style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:d?"none":"translateX(-100%)",transition:p?`transform ${p}ms ${be}`:"none",touchAction:"pan-x pan-y"},"data-mobile-sessions-drawer":"true",children:C})]}),document.body)}),mt="mobile-surface-root",Ge=16,Oe=200,ur=()=>{if(typeof document>"u")return null;let s=document.getElementById(mt);return s||(s=document.createElement("div"),s.id=mt,document.body.appendChild(s)),s},Xe=({open:s,onClose:n,title:r,subtitle:i,trailing:l,disableEscapeDismiss:a=!1,headerless:o=!1,noHeaderBorder:w=!1,ariaLabel:m,variant:d="fullscreen",dialogAlign:y="chat",children:j})=>{const S=t.useRef(null),[N,v]=t.useState(!1),[T,k]=t.useState(!1),E=t.useRef(null),C=t.useRef(null),p=t.useRef(n);if(t.useEffect(()=>{p.current=n},[n]),typeof document<"u"&&!S.current&&(S.current=ur()),t.useEffect(()=>{if(!s){v(!1);return}const P=window.setTimeout(()=>v(!0),Ge);return()=>window.clearTimeout(P)},[s]),t.useEffect(()=>{if(!s){k(!1);return}const P=window.setTimeout(()=>k(!0),Ge+Oe+80);return()=>window.clearTimeout(P)},[s]),t.useEffect(()=>{if(!s)return;const P=document.body.style.overflow;C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const H=()=>{const A=E.current;if(!A)return;(A.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??A).focus({preventScroll:!0})},$=window.setTimeout(H,Ge),_=A=>{if(A.key==="Escape"&&!a){p.current();return}if(A.key!=="Tab")return;const L=E.current;if(!L)return;const h=Array.from(L.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(W=>!W.hasAttribute("disabled")&&W.getAttribute("aria-hidden")!=="true");if(h.length===0){A.preventDefault(),L.focus({preventScroll:!0});return}const D=h[0],z=h[h.length-1],B=document.activeElement;A.shiftKey&&B===D?(A.preventDefault(),z.focus({preventScroll:!0})):!A.shiftKey&&B===z&&(A.preventDefault(),D.focus({preventScroll:!0}))};return document.addEventListener("keydown",_),()=>{window.clearTimeout($),document.body.style.overflow=P,document.removeEventListener("keydown",_),C.current?.focus?.({preventScroll:!0}),C.current=null}},[a,s]),!s||!S.current)return null;const f=d==="dialog",I=e.jsxs("section",{ref:E,role:"dialog","aria-modal":"true","aria-label":m,tabIndex:-1,className:M("flex flex-col bg-background text-foreground",f?"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:f?{opacity:N?1:0,transform:N?"none":"scale(0.97)",transition:`opacity ${Oe}ms ease-out, transform ${Oe}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:N?"none":"translateX(100%)",transition:`transform ${Oe}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:P=>{N&&P.target===P.currentTarget&&P.propertyName==="transform"&&k(!0)},children:[o?null:e.jsxs("header",{className:M("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!w&&"border-b border-border/70"),children:[e.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":"Close",onClick:n,style:{touchAction:"manipulation"},children:e.jsx(ie,{name:"close",className:"size-5"})}),e.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[r?typeof r=="string"?e.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:r}):r:null,i?typeof i=="string"?e.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:i}):i:null]}),l?e.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:l}):null]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T?e.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:j}):null}),e.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return f?ze.createPortal(e.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:N?1:0,paddingLeft:y==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:y==="chat"?"max(1rem, var(--oc-chat-inset-right, 0px))":"1rem",paddingTop:"max(1rem, var(--oc-safe-area-top, 0px))"},onClick:n,children:e.jsx("div",{className:"flex w-full max-w-[720px] justify-center",onClick:P=>P.stopPropagation(),children:I})}),S.current):ze.createPortal(I,S.current)},dr=t.lazy(()=>De(()=>import("./FilesView-CumrwioK.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])).then(s=>({default:s.FilesView}))),fr=t.lazy(()=>De(()=>import("./GitView-BoCaX5AO.js"),__vite__mapDeps([73,6,1,2,3,10,4,5,7,8,9,11,12,49,50,51,52,53,74,75,76,77,78,79,56,57,58,33,34,35,36,37,38,39,40,41,42,43,44,45,46,59,31,32,60,61,62,63,64,65,66,80,81,82,72,29,30])).then(s=>({default:s.GitView}))),hr=t.lazy(()=>De(()=>import("./PullRequestsSurface-eSXl6sef.js"),__vite__mapDeps([83,6,1,2,3,84,4,5,7,8,9,10,11,12,49,50,51,52,53,85,75,76,79,56,57,58,33,34,35,36,37,38,39,40,41,42,43,44,45,46,59,31,32,60,61,62,63,64,65,66,80,81,82,72,29,30])).then(s=>({default:s.PullRequestsSurface}))),pr=t.lazy(()=>De(()=>import("./IssuesSurface-CDZENHrE.js"),__vite__mapDeps([86,1,2,3,84,4,5,6,7,8,9,10,11,12,49,50,51,52,53,85,75,76,87])).then(s=>({default:s.IssuesSurface}))),bt="mobile-surface-root",mr=16,xt=t.memo(function({open:n,onClose:r,tab:i,onTabChange:l,pendingChangesDiff:a,variant:o="drawer",drawerRefExternal:w,scrimRefExternal:m,rootRefExternal:d,githubTabsAvailable:y=!1}){const j=t.useRef(null),S=t.useRef(null),N=t.useRef(null),v=t.useRef(null),T=w??S,k=m??N,E=d??v,C=t.useCallback(x=>{v.current=x,d&&(d.current=x)},[d]),p=t.useCallback(()=>{const x=typeof document<"u"?document.activeElement:null;x instanceof HTMLElement&&E.current?.contains(x)&&x.blur(),r()},[r]),[f,I]=t.useState(!1),[P,H]=t.useState(n),$=`mobile-workspace-tab-${t.useId()}`,_=t.useMemo(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[]),[A,L]=t.useState(()=>new Set),[h,D]=t.useState(null),[z,B]=t.useState(null);if(t.useEffect(()=>{n&&L(x=>{if(x.has(i))return x;const O=new Set(x);return O.add(i),O})},[n,i]),typeof document<"u"&&!j.current){let x=document.getElementById(bt);x||(x=document.createElement("div"),x.id=bt,document.body.appendChild(x)),j.current=x}if(t.useEffect(()=>{if(n){H(!0);const O=window.setTimeout(()=>I(!0),_?0:mr);return()=>window.clearTimeout(O)}I(!1);const x=window.setTimeout(()=>H(!1),Ee+40);return()=>window.clearTimeout(x)},[n,_]),t.useEffect(()=>{if(!n)return;const x=document.body.style.overflow;o==="drawer"&&(document.body.style.overflow="hidden");const O=oe=>{oe.key==="Escape"&&i!=="terminal"&&p()};return document.addEventListener("keydown",O),()=>{o==="drawer"&&(document.body.style.overflow=x),document.removeEventListener("keydown",O)}},[p,n,i,o]),t.useEffect(()=>{const x=E.current;if(!x||n||o!=="drawer")return;const O=document.activeElement;O&&x.contains(O)&&O.blur()},[n,o]),Mt({side:"right",enabled:o==="drawer",open:n,drawerRef:T,scrimRef:k,onClose:p,widthRatio:1,prefersReducedMotion:_}),o==="drawer"&&!j.current)return null;const W=_?0:Ee,q=hn(y),g=_?{duration:0}:{type:"spring",stiffness:520,damping:40,mass:.8},R=e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-0.5 py-1 overflow-x-auto overflow-y-hidden scrollbar-none",role:"tablist","aria-label":"Workspace","data-no-drawer-swipe":"true",children:q.map(x=>{const O=i===x.id;return e.jsxs(Be.button,{layout:"position",transition:g,type:"button",role:"tab","aria-selected":O,"aria-label":x.label,onClick:()=>l(x.id),className:M("relative flex min-h-[44px] items-center justify-center gap-1 rounded-lg py-2 typography-ui-label transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",O?"min-w-0 shrink px-2.5 text-foreground":"size-11 shrink-0 text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[O?e.jsx(Be.span,{layoutId:$,transition:g,className:"absolute inset-0 bg-interactive-selection",style:{borderRadius:8},"aria-hidden":"true"}):null,e.jsx(ie,{name:x.icon,className:"relative size-5 shrink-0"}),O?e.jsx(Be.span,{initial:_?!1:{opacity:0,x:-4},animate:{opacity:1,x:0},transition:g,className:"relative truncate",children:x.label},x.id):null]},x.id)})}),V=e.jsxs(e.Fragment,{children:[o==="panel"?null:e.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-1 px-2",children:[R,e.jsx("button",{type:"button",onClick:p,"aria-label":"Close workspace panel",className:"flex size-11 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:e.jsx(ie,{name:"close",className:"size-5"})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[A.has("changes")?e.jsx("div",{className:M("h-full",i!=="changes"&&"hidden"),children:e.jsx(ee,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(fr,{isActive:n&&i==="changes",chrome:"mobile",initialDiffPath:a?.path??null,initialDiffStaged:a?.staged===!0})})})},a?`changes:${a.path}:${a.staged}`:"changes"):null,A.has("files")?e.jsx("div",{className:M("h-full",i!=="files"&&"hidden"),children:e.jsx(ee,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(dr,{chrome:"mobile",mode:"editor-only",isVisible:n&&i==="files"})})})}):null,A.has("terminal")?e.jsx("div",{className:M("h-full",i!=="terminal"&&"hidden"),children:e.jsx(ee,{children:e.jsx(pn,{visible:n&&i==="terminal"})})}):null,A.has("pull-requests")?e.jsx("div",{className:M("h-full",i!=="pull-requests"&&"hidden"),children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[e.jsx(ot,{icon:Me.find(x=>x.id==="pull-requests")?.icon,title:Me.find(x=>x.id==="pull-requests")?.label??"Pull requests",actions:e.jsx("div",{ref:x=>{D(x)},className:"flex items-center gap-1"})}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(ee,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(hr,{hideFilesTab:!0,headerActionsSlot:n&&i==="pull-requests"?h:null,headerActionsPresentation:"drawer"})})})})]})}):null,A.has("issues")?e.jsx("div",{className:M("h-full",i!=="issues"&&"hidden"),children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[e.jsx(ot,{icon:Me.find(x=>x.id==="issues")?.icon,title:Me.find(x=>x.id==="issues")?.label??"Issues",actions:e.jsx("div",{ref:x=>{B(x)},className:"flex items-center gap-1"})}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(ee,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(pr,{headerActionsSlot:n&&i==="issues"?z:null,headerActionsPresentation:"drawer"})})})})]})}):null]})]});return o==="panel"?e.jsx("div",{className:"flex h-full min-h-0 flex-col bg-sidebar",children:V}):ze.createPortal(e.jsxs("div",{ref:C,className:"fixed inset-0 z-50",inert:!n,style:{pointerEvents:n?"auto":"none",visibility:P?"visible":"hidden"},"data-mobile-workspace-root":"true",children:[e.jsx("button",{ref:k,type:"button",className:"absolute inset-0 cursor-default bg-black/70","aria-label":"Close workspace panel",onClick:p,tabIndex:n?0:-1,style:{opacity:f?1:0,transition:W?`opacity ${W}ms ${be}`:"none"},"data-mobile-workspace-scrim":"true"}),e.jsx("section",{ref:T,role:"dialog","aria-modal":"true","aria-label":"Open workspace panel",className:"oc-keyboard-inset-surface absolute inset-y-0 right-0 z-10 flex h-full w-full flex-col bg-sidebar",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:f?"none":"translateX(100%)",transition:W?`transform ${W}ms ${be}`:"none",touchAction:"pan-x pan-y"},"data-mobile-workspace-drawer":"true",children:V})]}),j.current)}),br="pichamber",xr=s=>s.replace(/^\/+|\/+$/g,""),gr=s=>{const n=xr(s.pathname).split("/").filter(Boolean);return s.host?[s.host,...n]:n};function yr(s){if(typeof s!="string"||s.length===0)return null;let n;try{n=new URL(s)}catch{return null}if(n.protocol!==`${br}:`)return null;const r=gr(n),i=(r[0]??"").toLowerCase(),l=r.slice(1),a=n.searchParams;switch(i){case"session":{const o=l[0]||a.get("id")||"";return o?{type:"session",sessionId:o,directory:a.get("dir")??void 0}:null}case"new":case"new-session":return{type:"new-session",directory:a.get("dir")??void 0,projectId:a.get("project")??void 0,agent:a.get("agent")??void 0,model:a.get("model")??void 0};case"sessions":{const o=a.get("filter");return{type:"sessions",filter:o==="attention"||o==="recent"||o==="all"?o:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:l[0]||a.get("section")||void 0};case"changes":return{type:"changes",path:l.join("/")||a.get("path")||void 0,staged:a.get("staged")==="true"};case"view":{const o=(l[0]||"").toLowerCase();return o==="changes"?{type:"changes"}:o==="files"||o==="mcp"||o==="instances"||o==="update"?{type:"view",target:o}:null}default:return null}}let Q={},Lt=!1,Ae=null;const vr=s=>{switch(s.type){case"session":return ae.getState().setCurrentSession(s.sessionId,s.directory??null),!0;case"new-session":{const n=ae.getState();return n.openNewSessionDraft(),(s.directory||s.projectId)&&n.setNewSessionDraftTarget({directoryOverride:s.directory??null,projectId:s.projectId??null,selectedProjectId:s.projectId??null}),!0}case"sessions":return Q.openSessions?(Q.openSessions(s.filter),!0):!1;case"status":return Q.openSessions?(Q.openSessions(),!0):!1;case"view":return Q.openView?(Q.openView(s.target),!0):!1;case"changes":return Q.openChanges?(Q.openChanges({path:s.path,staged:s.staged}),!0):!1;case"settings":return Q.openSettings?(Q.openSettings(s.section),!0):!1}},Ye=()=>{if(!Lt||!Ae)return;const s=Ae;Ae=null,vr(s)||(Ae=s)},wr=s=>{Ae=s,Ye()},Sr=s=>{const n=yr(s);n&&wr(n)},jr=s=>{Lt=s,Ye()},Rr=s=>{t.useEffect(()=>(Q=s,Ye(),()=>{Q===s&&(Q={})}),[s])},kr=s=>{const{ready:n}=s;t.useEffect(()=>{jr(n)},[n]),t.useEffect(()=>{if(!Xt())return;let r=!1;const i=[];return De(()=>import("./vendor-capacitor-app-NX6DULfp.js"),__vite__mapDeps([88,6,1,2,3])).then(async({App:l})=>{if(r)return;const a=await l.addListener("appUrlOpen",o=>{Sr(o?.url)});if(r){a.remove();return}i.push(()=>{a.remove()})}).catch(()=>{}),()=>{r=!0,i.forEach(l=>l())}},[])},gt=s=>{const n=s.drawer.current,r=s.scrim.current,i=s.root.current;i&&(i.style.pointerEvents="auto",i.style.visibility="visible"),n&&(n.style.transition="none"),r&&(r.style.transition="none")},yt=(s,n,r)=>{const i=s.drawer.current,l=s.scrim.current;if(i&&(i.style.transform=r>=.999?"none":`translateX(${(n==="left"?r-1:1-r)*100}%)`),l){l.style.opacity=String(r);const a=r>.01?"auto":"none";l.style.pointerEvents!==a&&(l.style.pointerEvents=a)}},vt=(s,n,r)=>{const i=r.drawer.current,l=r.scrim.current,a=r.root.current;i&&(i.style.transition=`transform ${Ee}ms ${be}`,i.style.transform=n?"none":s==="left"?"translateX(-100%)":"translateX(100%)"),l&&(l.style.transition=`opacity ${Ee}ms ${be}`,l.style.opacity=n?"1":"0",l.style.pointerEvents=n?"auto":"none"),a&&(a.style.pointerEvents=n?"auto":"none",a.style.visibility=n?"visible":"")},wt=s=>{const n=s.shell.current,r=s.inner.current;n&&(n.style.overflow="visible"),r&&(r.style.transition="none")},St=(s,n,r,i)=>{const l=s.inner.current;if(!l)return;const a=i==="left"?(n-1)*r:(1-n)*r;l.style.transform=n>=.999?"translateX(0)":`translateX(${a}px)`},jt=(s,n,r,i,l)=>{const a=s.shell.current,o=s.inner.current;return!a||!o?void 0:(o.style.transition="transform 200ms cubic-bezier(0.22, 1, 0.36, 1)",o.style.transform=n?"translateX(0)":`translateX(${i==="left"?-r:r}px)`,window.setTimeout(()=>{o.style.transition="",o.style.transform="",a.style.overflow=""},220))},Rt=({side:s,isResizing:n,ariaLabel:r,handleProps:i})=>e.jsx("div",{className:M("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",s==="left"?"right-0":"left-0"),role:"separator","aria-orientation":"vertical","aria-label":r,...i,children:e.jsx("div",{className:M("absolute inset-y-0 w-[3px] transition-colors",s==="left"?"right-0":"left-0",n&&"bg-[var(--interactive-border)]")})}),Er=320,Cr=380,kt=280,Nr=560,Tr=900;function Et(s,n,r,i=Nr){const l=t.useRef(null),[a,o]=t.useState(()=>{if(typeof window>"u")return r;const p=Number.parseInt(window.localStorage.getItem(n)??"",10);return Number.isFinite(p)?Math.min(i,Math.max(kt,p)):r}),[w,m]=t.useState(!1),d=t.useRef(0),y=t.useRef(a),j=t.useRef(null),S=t.useRef(null),N=t.useCallback(p=>Math.min(i,Math.max(kt,Math.round(p))),[i]),v=t.useCallback(p=>{const f=l.current;f&&(f.style.width=`${p}px`,f.style.minWidth=`${p}px`,f.style.maxWidth=`${p}px`,f.style.setProperty("--oc-ipad-sidebar-width",`${p}px`))},[]),T=t.useCallback(p=>{try{p.currentTarget.setPointerCapture(p.pointerId)}catch{}S.current=p.pointerId,d.current=p.clientX,y.current=a,j.current=a,m(!0),p.preventDefault()},[a]),k=t.useCallback(p=>{if(S.current!==p.pointerId)return;const f=p.clientX-d.current,I=N(y.current+(s==="left"?f:-f));j.current!==I&&(j.current=I,v(I))},[v,N,s]),E=t.useCallback(p=>{if(S.current!==p.pointerId)return;try{p.currentTarget.releasePointerCapture(p.pointerId)}catch{}const f=N(j.current??y.current);S.current=null,j.current=null,m(!1),o(f);try{window.localStorage.setItem(n,String(f))}catch{}},[N,n]),C=t.useMemo(()=>({onPointerDown:T,onPointerMove:k,onPointerUp:E,onPointerCancel:E}),[T,E,k]);return{asideRef:l,width:a,isResizing:w,handleProps:C}}const Ir=t.memo(Sn),Pr=({onActiveConnectionDeleted:s})=>{const[n,r]=t.useState(!1),[i,l]=t.useState(null),[a,o]=t.useState(!1),[w,m]=t.useState("changes"),d=t.useCallback(c=>{m(lt(c))},[]),y=w,[j,S]=t.useState("nav"),[N,v]=t.useState(null),T=t.useRef([]),k=t.useCallback(()=>{T.current.forEach(c=>window.clearTimeout(c)),T.current=[]},[]);t.useEffect(()=>()=>k(),[k]);const E=t.useRef(null),C=t.useRef(null),p=t.useRef(null),f=t.useRef(null),I=t.useRef(null),P=t.useRef(null),H=t.useRef(null),$=t.useRef(null),_=t.useRef(0),A=t.useRef(0),L=t.useCallback(c=>{k(),r(c)},[k]),h=t.useCallback(c=>{k(),o(c)},[k]),D=je(c=>c.setSettingsPage),z=je(c=>c.isArchivePageOpen),B=je(c=>c.setArchivePageOpen),W=ke(c=>c.available),q=ke(c=>c.runtimeType),g=t.useMemo(()=>Dt(),[]),R=!g&&W&&(q==="desktop"||q==="web"),V=Kn()??"",x=V?Kt(V):"",O=qn().github??null,oe=ct(c=>c.ensureScope);t.useEffect(()=>{!x||!O||oe(x,O)},[x,O,oe]);const _e=ct(c=>x?c.entriesByDirectory[x]??null:null),te=t.useMemo(()=>Yn(_e),[_e]),xe=Qn(te);t.useEffect(()=>{!xe&&mn(w)&&m(bn(w))},[xe,w]);const le=t.useCallback(()=>{l(null)},[]),ne=t.useCallback(c=>{l(c)},[]),ge=t.useCallback(()=>{h(!1)},[h]),u=t.useCallback(c=>{S(c),ne("settings")},[ne]),{enabled:b,roomyForPanels:U}=Jn(),F=Zn()==="portrait",J=es(),se=je(c=>c.setSidebarOpen),X=je(c=>c.isSidebarOpen),we=t.useRef(!1);t.useLayoutEffect(()=>{b&&!we.current&&se(ts().roomyForPanels),!b&&we.current&&se(!1),we.current=b},[b,se]);const pe=t.useCallback(()=>{v(null),d("files"),h(!0)},[d,h]),fe=t.useCallback((c=null)=>{v(c),d("changes"),h(!0)},[d,h]),K=Et("left","pichamber.ipad.leftSidebarWidth",Er),Z=Et("right","pichamber.ipad.rightSidebarWidth",Cr,Tr),Qe=U,ce=Qe&&a?Z.width:0,zt=xn(b&&X),Ce=b&&X?K.width:0,Wt=t.useCallback(c=>{const Y=lt(c);a&&y===Y?h(!1):(d(Y),h(!0))},[a,y,d,h]),Ut=t.useCallback(()=>{h(!a)},[a,h]),Bt=t.useCallback(c=>{!c&&!U&&se(!1)},[U,se]);t.useEffect(()=>{if(typeof document>"u")return;const c=document.documentElement;return c.style.setProperty("--oc-chat-inset-left",`${Ce}px`),c.style.setProperty("--oc-chat-inset-right",`${ce}px`),()=>{c.style.removeProperty("--oc-chat-inset-left"),c.style.removeProperty("--oc-chat-inset-right")}},[Ce,ce]),t.useEffect(()=>{if(typeof document>"u")return;const c=b&&(F||J),Y=document.documentElement;return Y.classList.toggle("oc-keep-draft-starters",c),()=>Y.classList.remove("oc-keep-draft-starters")},[J,b,F]);const Je=t.useCallback(()=>{L(!1),h(!1)},[L,h]),Ht=t.useMemo(()=>({openChanges:({diffPath:c,staged:Y}={})=>{fe(c?{path:c,staged:Y===!0}:null)},openFiles:()=>pe(),openSettings:c=>{c&&D(c),u(c?"page-content":"nav")},openInstances:g?()=>ne("instances"):void 0,instanceLabel:g?Re():null,openUpdate:R?()=>ne("update"):void 0,closeDrawers:Je}),[Je,fe,pe,u,ne,D,g,R]),$t=t.useMemo(()=>({openSessions:()=>{b?se(!0):L(!0)},openView:c=>{if(c==="files"){pe();return}(c==="instances"||c==="update"||c==="mcp")&&ne(c)},openChanges:({path:c,staged:Y}={})=>{fe(c?{path:c,staged:Y===!0}:null)},openSettings:c=>{c&&D(c),u(c?"page-content":"nav")}}),[b,fe,pe,u,ne,D,L,se]);Rr($t);const Ze=t.useRef(null);gn(Ze,{leftOpen:b?X:n,rightOpen:a,leftWidth:()=>b?K.width:E.current?.offsetWidth||window.innerWidth*.72,rightWidth:()=>b?Z.width:f.current?.offsetWidth||window.innerWidth,onLeftProgress:c=>{if(_.current=c,b){St({inner:H},c,K.width,"left");return}yt({drawer:E,scrim:C},"left",c)},onRightProgress:c=>{if(A.current=c,b&&U){St({inner:$},c,Z.width,"right");return}yt({drawer:f,scrim:I},"right",c)},onLeftOpen:()=>{b?se(!0):L(!0)},onLeftClose:()=>{b?se(!1):L(!1)},onRightOpen:()=>h(!0),onRightClose:()=>h(!1),onDragStart:c=>{if(k(),c==="left"){_.current=b?X?1:0:n?1:0,b?wt({shell:K.asideRef,inner:H}):gt({drawer:E,scrim:C,root:p});return}A.current=a?1:0,b&&U?wt({shell:Z.asideRef,inner:$}):gt({drawer:f,scrim:I,root:P})},onDragEnd:(c,Y)=>{if(c==="left"){const Se=typeof Y=="boolean"?Y:_.current>.5;if(_.current=Se?1:0,b){const et=jt({shell:K.asideRef,inner:H},Se,K.width,"left");et!==void 0&&T.current.push(et)}else vt("left",Se,{drawer:E,scrim:C,root:p});return}const Ue=typeof Y=="boolean"?Y:A.current>.5;if(A.current=Ue?1:0,b&&U){const Se=jt({shell:Z.asideRef,inner:$},Ue,Z.width,"right");Se!==void 0&&T.current.push(Se)}else vt("right",Ue,{drawer:f,scrim:I,root:P})}});const Ft=t.useCallback(()=>z?(B(!1),!0):i?(le(),!0):a?(ge(),!0):n?(L(!1),!0):!1,[i,le,ge,z,n,B,L,a]);Pt(Ft);const We=b?"dialog":"fullscreen";return e.jsx(ns,{actions:Ht,children:e.jsxs("div",{className:"oc-mobile-app-shell main-content-safe-area relative flex h-[100dvh] flex-row bg-background text-foreground","data-page-scroll-lock":"true",children:[b?e.jsxs("aside",{ref:K.asideRef,className:M("relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-sidebar motion-reduce:transition-none",!X&&"border-r-0"),style:{width:Ce,minWidth:Ce,maxWidth:Ce,"--oc-ipad-sidebar-width":`${K.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)"},inert:!X,"data-page-scroll-lock":"true",children:[e.jsx("div",{ref:H,className:M("flex h-full shrink-0 flex-col",K.isResizing&&"pointer-events-none",!X&&"pointer-events-none select-none"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden",transform:K.isResizing||zt.slidIn?"translateX(0)":"translateX(-100%)",transition:K.isResizing?"none":"transform 200ms cubic-bezier(0.22, 1, 0.36, 1)"},children:e.jsx(ee,{children:e.jsx(pt,{open:X,variant:"sidebar",onOpenChange:Bt})})}),X?e.jsx(Rt,{side:"left",isResizing:K.isResizing,ariaLabel:"Resize left panel",handleProps:K.handleProps}):null]}):null,e.jsxs("div",{className:"relative flex h-full min-w-0 flex-1 flex-col","data-page-scroll-lock":"true",children:[b?e.jsxs(e.Fragment,{children:[e.jsx(yn,{}),e.jsx(vn,{onToggleRightDrawer:Ut,rightDrawerOpen:a,tabletWorkspaceTab:y,onSelectTabletWorkspaceTab:Wt,tabletGitHubTabsAvailable:xe})]}):e.jsx(or,{onOpenSessions:()=>L(!0),onOpenWorkspace:()=>h(!0)}),e.jsx("main",{ref:Ze,className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",style:{touchAction:"pan-x pan-y"},children:e.jsx("div",{className:"h-full w-full",children:e.jsx(ee,{children:e.jsx(Ir,{})})})})]}),b?null:e.jsx(pt,{open:n,onOpenChange:L,drawerRefExternal:E,scrimRefExternal:C,rootRefExternal:p}),b?e.jsxs("aside",{ref:Z.asideRef,className:M("relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/70 bg-background motion-reduce:transition-none",!ce&&"border-l-0"),style:{width:ce,minWidth:ce,maxWidth:ce,"--oc-ipad-sidebar-width":`${Z.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)"},inert:!ce,"data-page-scroll-lock":"true",children:[e.jsx("div",{ref:$,className:M("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",Z.isResizing&&"pointer-events-none",!ce&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden",transform:ce?"translateX(0)":"translateX(100%)",transition:Z.isResizing?"none":"transform 200ms cubic-bezier(0.22, 1, 0.36, 1), opacity 200ms cubic-bezier(0.22, 1, 0.36, 1)"},children:e.jsx(ee,{children:e.jsx(xt,{open:a,onClose:ge,tab:y,onTabChange:d,pendingChangesDiff:N,variant:Qe?"panel":"drawer",githubTabsAvailable:xe,drawerRefExternal:f,scrimRefExternal:I,rootRefExternal:P})})}),ce?e.jsx(Rt,{side:"right",isResizing:Z.isResizing,ariaLabel:"Resize right panel",handleProps:Z.handleProps}):null]}):e.jsx(xt,{open:a,onClose:ge,tab:y,onTabChange:d,pendingChangesDiff:N,githubTabsAvailable:xe,drawerRefExternal:f,scrimRefExternal:I,rootRefExternal:P}),i==="instances"&&g?e.jsx(Xe,{open:!0,variant:We,dialogAlign:"app",onClose:le,ariaLabel:"Servers",title:"Servers",children:e.jsx(lr,{onConnect:le,onActiveConnectionDeleted:s})}):null,i==="settings"?e.jsx(Xe,{open:!0,variant:We,dialogAlign:"app",onClose:le,ariaLabel:"Settings",headerless:!0,children:e.jsx(ee,{children:e.jsx(zs,{forceMobile:!b,isWindowed:!0,initialMobileStage:j,onClose:le,onActiveConnectionDeleted:s})})}):null,i==="update"?e.jsx(Xe,{open:!0,variant:We,dialogAlign:"app",onClose:le,ariaLabel:"Update",title:"Update",children:e.jsx(ee,{children:e.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:e.jsx(Ws,{initialUpdateDialogOpen:!0})})})}):null,e.jsx(ee,{children:e.jsx(wn,{})})]})})},Ar=8,Ot=6e4,Dr=6e4,Ke=[1e3,2e3,4e3,8e3,15e3,3e4,3e4,3e4],_r=(s,n)=>{if(n?.offline||n?.hidden)return Ot;if(s<=0)return Ke[0];const r=Math.min(s-1,Ke.length-1);return Ke[r]??3e4},de=()=>typeof navigator<"u"&&typeof navigator.onLine=="boolean"?!navigator.onLine:!1,re=()=>typeof document<"u"&&typeof document.visibilityState=="string"?document.visibilityState==="hidden":!1;class Mr{constructor(n,r,i=()=>""){this.probe=n,this.callbacks=r,this.getRuntimeIdentity=i}probe;callbacks;getRuntimeIdentity;generation=0;attempt=0;timer=null;wakeCleanup=null;running=!1;exhausted=!1;probingGeneration=null;get currentGeneration(){return this.generation}get currentAttempt(){return this.attempt}get isRunning(){return this.running&&!this.exhausted}start(){he("recovery",{code:"start"}),this.startCycle(!1)}startCycle(n){this.clearTimer(),this.generation+=1,this.attempt=0,this.exhausted=!1,this.running=!0,n?this.runAttempt(this.generation):this.scheduleNext(this.generation)}retryNow(){if(this.exhausted){if(de()||re())return;this.startCycle(!0);return}this.running&&(this.clearTimer(),this.runAttempt(this.generation))}cancel(){he("recovery",{code:"cancel"}),this.generation+=1,this.running=!1,this.exhausted=!1,this.attempt=0,this.probingGeneration=null,this.clearTimer()}async probeOnce(){return this.running||this.exhausted||this.probingGeneration!==null||de()||re()?null:this.runGuardedProbe(this.generation)}async runGuardedProbe(n){this.probingGeneration=n;const r=this.getRuntimeIdentity();let i;try{i=await this.probe()}catch{i="unreachable"}finally{this.probingGeneration===n&&(this.probingGeneration=null)}return n!==this.generation||this.getRuntimeIdentity()!==r?null:i}settleTerminalOutcome(n){return n==="unreachable"?!1:(this.running=!1,this.exhausted=!1,this.clearTimer(),n==="needs-login"?this.callbacks.onAuthExpired():n==="no-connection"?this.callbacks.onNoConnection():this.callbacks.onHealthy(n),!0)}clearTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.wakeCleanup&&(this.wakeCleanup(),this.wakeCleanup=null)}scheduleNext(n){if(n!==this.generation||!this.running||this.exhausted)return;if(this.attempt>=Ar){this.exhausted=!0,this.running=!1,this.callbacks.onExhausted(),this.scheduleExhaustedPoll(n);return}const r=this.attempt+1,i=_r(r,{offline:de(),hidden:re()});this.callbacks.onAttempt?.(r,i);const l=()=>{de()||re()||n===this.generation&&(this.clearTimer(),this.runAttempt(n))},a=()=>l(),o=()=>{typeof document<"u"&&document.visibilityState==="visible"&&l()};typeof window<"u"&&window.addEventListener("online",a),typeof document<"u"&&document.addEventListener("visibilitychange",o),this.wakeCleanup=()=>{typeof window<"u"&&window.removeEventListener("online",a),typeof document<"u"&&document.removeEventListener("visibilitychange",o)},this.timer=setTimeout(()=>{if(this.timer=null,this.wakeCleanup?.(),this.wakeCleanup=null,!(n!==this.generation||!this.running||this.exhausted)){if(de()||re()){this.scheduleNext(n);return}this.runAttempt(n)}},i)}async runAttempt(n){if(n!==this.generation||!this.running||this.exhausted||this.probingGeneration===n)return;if(de()||re()){this.scheduleNext(n);return}const r=await this.runGuardedProbe(n);r===null||this.settleTerminalOutcome(r)||(this.attempt+=1,this.scheduleNext(n))}scheduleExhaustedPoll(n){if(n!==this.generation||!this.exhausted)return;this.clearTimer();const r=de()||re()?Ot:Dr;this.timer=setTimeout(()=>{this.timer=null,this.runExhaustedPoll(n)},r)}async runExhaustedPoll(n){if(n!==this.generation||!this.exhausted)return;if(this.probingGeneration!==null||de()||re()){this.scheduleExhaustedPoll(n);return}const r=await this.runGuardedProbe(n);r===null||!this.exhausted||this.settleTerminalOutcome(r)||this.scheduleExhaustedPoll(n)}}function Lr(s=2500){const{uiFont:n}=ss(),[r,i]=t.useState(!1);return t.useEffect(()=>{let l=!1;const a=()=>{l||i(!0)},o=()=>{requestAnimationFrame(()=>requestAnimationFrame(a))},w=Promise.all([rs(n).catch(()=>{}),document.fonts?.ready?.then(()=>{}).catch(()=>{})??Promise.resolve(),Vs.catch(()=>{})]).then(()=>{}),m=new Promise(d=>{window.setTimeout(d,s)});return Promise.race([w,m]).then(o),()=>{l=!0}},[n,s]),r}const Or=1e3;function zr({apis:s}){const n=me(u=>u.initializeApp),r=me(u=>u.isInitialized),i=me(u=>u.isConnected),l=me(u=>u.connectionPhase),a=me(u=>u.providers.length),o=me(u=>u.loadProviders),w=Ct(u=>u.currentDirectory),m=ae(u=>u.error),d=ae(u=>u.clearError),y=je(u=>u.setIsMobile),[j,S]=t.useState(0),[N,v]=t.useState(0),[T,k]=t.useState(!1),[E,C]=t.useState("idle"),p=is(),f=t.useRef(null),I=t.useRef(E);I.current=E;const[P,H]=t.useState("pending"),[$,_]=t.useState(null),A=t.useMemo(()=>Re(),[]),[,L]=t.useReducer(u=>u+1,0),h=t.useMemo(()=>Dt(),[]),D=t.useRef(0),z=t.useRef(0),B=t.useRef(!1),[W,q]=t.useState(()=>h&&!!ue());t.useEffect(()=>{const u=new Mr(()=>Us(),{onHealthy:b=>{if(he("recovery",{code:"success"}),C("idle"),ye(!1),b==="unchanged"){Zt(),me.getState().initializeApp();const U=me.getState();U.providers.length===0&&U.loadProviders({source:"mobileApp:recovery"})}},onAuthExpired:()=>{he("recovery",{code:"auth-expired"}),C("idle"),ye(!1),_({kind:"auth-expired",label:Re()??""}),Ne({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),S(b=>b+1)},onNoConnection:()=>{he("recovery",{code:"no-connection"}),C("idle"),ye(!1),Ne({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),S(b=>b+1)},onExhausted:()=>{he("recovery",{code:"exhausted"}),C("exhausted")},onAttempt:b=>{he("recovery",{code:"attempt",detail:String(b)})}},()=>`${Te()}|${ue()}`);return f.current=u,()=>{u.cancel(),f.current=null}},[]);const g=t.useCallback(()=>{if(!h||!ue())return;const u=f.current;if(u){if(u.isRunning){u.retryNow();return}C("recovering"),ye(!0),u.start()}},[h]),R=t.useCallback(()=>{f.current?.cancel(),C("idle"),ye(!1),q(!1)},[]),V=t.useCallback(u=>{R(),u&&_(u),Ne({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),S(b=>b+1)},[R]),x=t.useCallback(()=>{const u=Date.now();u-D.current>=Or&&(D.current=u,window.dispatchEvent(new Event("pichamber:system-resume")))},[]),O=t.useCallback(()=>{const u=ue(),b=z.current+1;if(z.current=b,!u){if(B.current)return;B.current=!0,Fe().catch(()=>{}).finally(()=>{B.current=!1});return}if(f.current?.isRunning){f.current.retryNow(),x();return}if(I.current==="exhausted"){if(de()||re())return;C("recovering"),ye(!0),f.current?.start(),x();return}if(de()||re()){g();return}const U=()=>{n(),a===0&&o({source:"mobileApp:nativeResume"})},G=f.current;G&&(G.probeOnce().then(F=>{if(F!==null&&z.current===b){if(F==="no-connection"){V(null);return}if(F==="needs-login"){V({kind:"auth-expired",label:Re()??""});return}if(F==="unreachable"){g();return}F!=="switched"&&U()}}),x())},[V,x,n,o,a,g]);as(),os(O),t.useEffect(()=>qt(),[]),t.useEffect(()=>{if(!h)return;let u;const b=()=>{if(f.current?.isRunning){f.current.retryNow();return}if(I.current==="exhausted"){if(re())return;C("recovering"),ye(!0),f.current?.start();return}window.clearTimeout(u),u=window.setTimeout(()=>O(),1500)};return window.addEventListener("online",b),()=>{window.removeEventListener("online",b),window.clearTimeout(u)}},[h,O]),t.useEffect(()=>{if(h)return Yt(()=>{ue()&&V({kind:"auth-expired",label:Re()??""})})},[V,h]),t.useEffect(()=>(nt(s),()=>nt(null)),[s]),t.useEffect(()=>Qt(u=>{if(!!u.runtimeKey&&u.runtimeKey===u.previousRuntimeKey){jn(),L();return}R(),Rn(u),v(U=>U+1),S(U=>U+1)}),[R]),t.useEffect(()=>{Nt()},[N]),t.useEffect(()=>{if(!h||i||ue()){H("done");return}let u=!1;return H("attempting"),Fe().catch(()=>({status:"no-candidate"})).then(b=>{u||(he("auto-connect",{code:b.status}),b.status==="unreachable"?_({kind:"unreachable",label:b.label}):b.status==="needs-login"&&_({kind:"auth-expired",label:b.label}),H("done"))}),()=>{u=!0}},[]),t.useEffect(()=>{if(!h||!ue()){q(!1);return}let u=!1;const b=G=>{G&&_(G),Ne({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),S(F=>F+1)},U=f.current;if(!U){q(!1);return}return(async()=>{try{const G=await U.probeOnce();if(u||G===null||G==="switched"||G==="unchanged")return;const F=Re();if(G==="needs-login"){b({kind:"auth-expired",label:F??""});return}if(G==="unreachable"){g();return}const J=await Fe().catch(()=>({status:"no-candidate"}));if(u||(he("auto-connect",{code:J.status}),J.status==="connected"))return;J.status==="needs-login"?b({kind:"auth-expired",label:J.label}):J.status==="unreachable"?b({kind:"unreachable",label:J.label}):b(null)}finally{u||q(!1)}})(),()=>{u=!0,q(!1)}},[g]),t.useEffect(()=>{y(!0)},[y]),t.useEffect(()=>{h&&!ue()||n()},[j,n,h]),t.useEffect(()=>{i&&a===0&&o({source:"mobileApp:recovery"})},[i,o,a]);const oe=t.useRef(!1),[_e,te]=t.useState(h);t.useEffect(()=>{if(!h||!i||oe.current)return;if(ae.getState().currentSessionId){oe.current=!0,te(!1);return}const u=Te(),b=ls(u);if(!b){oe.current=!0,te(!1);return}const U=Jt(b.directory??null);if(!U){oe.current=!0,te(!1);return}const G=Ie();let F=0;try{F=G.getRuntimeGeneration()}catch{F=0}let J=!1;const se=window.setTimeout(()=>te(!1),6e3);return(async()=>{let X=null;try{X=await cs([U])}catch{X=null}if(J)return;if(!X){te(!1);return}const we=Ie();let pe=F;try{pe=we.getRuntimeGeneration()}catch{pe=F}const fe=tr({persisted:b,persistedDirectory:U,stale:X.stale,ready:X.readyDirectories.has(U),catalog:X.catalog,runtimeKey:Te(),capturedRuntimeKey:u,storeIdentityMatches:we===G,generationMatches:pe===F});if(fe.action==="wait"){te(!1);return}if(oe.current=!0,fe.action==="clear"){us(u),te(!1);return}const K=ae.getState();if(Te()!==u||Ie()!==G){te(!1);return}K.currentSessionId||K.setCurrentSession(fe.sessionId,fe.directory),te(!1)})(),()=>{J=!0,window.clearTimeout(se)}},[j,i,h]),t.useEffect(()=>{i&&Ie().focusProject(w,tn(w))},[w,i]),t.useEffect(()=>{if(!m)return;const u=window.setTimeout(()=>d(),5e3);return()=>window.clearTimeout(u)},[d,m]),t.useEffect(()=>{if(h&&E!=="idle"){k(!1);return}if(h&&W){k(!1);return}if(!(!i&&(h?!!ue():!0))){k(!1);return}const b=window.setTimeout(()=>{k(!0)},h?4e3:8e3);return()=>window.clearTimeout(b)},[i,h,j,E,N,W]),ds(),kn(),kr({ready:h&&i&&r});const xe=Lr(),le=!i&&l==="reconnecting",ne=!!ue(),ge=h&&ne&&E!=="idle";return xe?h&&!ge&&(!ne||!i&&!le)?ne?e.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-4",children:[e.jsx(ve,{width:120,height:120,isAnimated:!T}),T?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"typography-h3 text-foreground",children:"Unable to reach server"}),e.jsx("p",{className:"typography-body text-muted-foreground",children:"Could not connect to the saved server. Check that it is running, or pick another server."})]}),e.jsx(Pe,{type:"button",variant:"outline",onClick:()=>{V(null)},children:"Use another server"})]}):null]})}):P!=="done"?e.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-background text-foreground",children:[e.jsx(ve,{width:120,height:120,isAnimated:!0}),A?e.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[e.jsx("p",{className:"typography-small text-muted-foreground",children:"Connecting to device:"}),e.jsx("div",{className:"flex justify-center",children:e.jsx(fs,{text:A,showElapsed:!1})})]}):null]}):e.jsx(e.Fragment,{children:e.jsx(nr,{onConnected:()=>S(u=>u+1),notice:$})}):!h&&!i&&!le?T?e.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:e.jsxs("div",{className:"max-w-sm space-y-3",children:[e.jsx("h1",{className:"typography-h3 text-foreground",children:"Unable to reach server"}),e.jsx("p",{className:"typography-body text-muted-foreground",children:"We could not verify the UI session. If you're opening PiChamber from another device on your local network, make sure Desktop Network Access is enabled on the desktop app and use the LAN address shown in Settings."})]})}):e.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:e.jsx(ve,{width:120,height:120,isAnimated:!0})}):e.jsx(ee,{children:e.jsx(hs,{children:e.jsxs(ps,{apis:s,children:[e.jsx(ms,{}),e.jsx(bs,{}),e.jsx(En,{}),e.jsx(xs,{}),e.jsx(gs,{}),e.jsx(ys,{delayDuration:300,skipDelayDuration:150,children:e.jsxs(Cn,{children:[e.jsx(Nn,{}),e.jsxs("div",{className:"h-full bg-background text-foreground",children:[h&&_e?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background",children:e.jsx(ve,{width:120,height:120,isAnimated:!0})}):null,e.jsx(vs,{embeddedBackgroundWorkEnabled:r&&!p}),ge?e.jsxs("div",{role:"status","aria-live":"polite",className:"pointer-events-none fixed inset-x-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px)+10px)] z-40 flex justify-center",children:[e.jsx("span",{className:"flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-[var(--surface-elevated-foreground)] shadow-sm",children:e.jsx(ve,{width:24,height:24,isAnimated:!0})}),e.jsx("span",{className:"sr-only",children:E==="exhausted"?"Server unreachable":"Reconnecting…"})]}):null,e.jsx(er,{}),e.jsx(Pr,{onActiveConnectionDeleted:()=>{R(),Ne({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),S(u=>u+1)}}),e.jsx(Tn,{}),e.jsx(In,{}),e.jsx(ws,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),e.jsx(Ss,{})]})]})})]})},N)}):e.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:e.jsx(ve,{width:120,height:120,isAnimated:!0})})}const Wr=()=>{(async()=>{try{await Promise.all([Nt(),nn()])}catch(s){console.error("[mobile-main] settings init failed:",s)}Cs(),Ns(),Ts(),sn()})().finally(()=>{Gs()})};function ui(s){window.__PICHAMBER_SURFACE__="mobile",js(),Wr(),Zs(),Rs();const n=document.getElementById("root");if(!n)throw new Error("Root element not found");const i=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",l=s??en();if(!l)throw new Error("Runtime APIs not registered");const a=i?{...l,notifications:{notify:async()=>!1,canNotify:()=>!1}}:l,o=e.jsx(zr,{apis:a});Vt.createRoot(n).render(e.jsx(qe.StrictMode,{children:e.jsx(ks,{children:e.jsx(Pn,{children:i?o:e.jsx(Es,{children:o})})})}))}export{ui as renderMobileApp};
11
+ `})]}):null},or=({onOpenSessions:s,onOpenWorkspace:n,compactTitle:r=!1})=>{const[i,l]=t.useState(!1),[a,o]=t.useState(!1),w=t.useRef(null),m=Ct(p=>p.currentDirectory),d=ae(p=>p.currentSessionId),j=ae(t.useCallback(p=>d?p.getDirectoryForSession(d):null,[d]))||m,S=Xn(d),N=ae(p=>!!p.newSessionDraft?.open),T=S?.title?.trim()||(d?At(S,"Untitled session"):"New session");t.useEffect(()=>{l(!1),o(!1)},[d,j]);const k=t.useCallback(()=>{l(!1),o(!1),s()},[s]),E=t.useCallback(p=>{l(f=>{const I=typeof p=="function"?p(f):p;return I&&o(!1),I})},[]),C=t.useCallback(()=>{o(p=>{const f=!p;return f&&l(!1),f})},[]);return e.jsxs(e.Fragment,{children:[e.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:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:e.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[e.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":"Open sessions and projects",onClick:k,style:{touchAction:"manipulation"},children:e.jsx(ie,{name:"list-unordered",className:"size-5"})}),e.jsx("button",{ref:w,type:"button",className:M("flex h-10 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",r?"shrink":"flex-1"),"aria-label":"Open session switcher","aria-haspopup":"dialog","aria-expanded":a,onClick:C,style:{touchAction:"manipulation"},children:e.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[e.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:T}),e.jsx(ie,{name:"arrow-down-s",className:M("size-4 shrink-0 text-muted-foreground transition-transform duration-150",a&&"rotate-180")})]})}),r?e.jsx("div",{className:"min-w-0 flex-1"}):null,e.jsx(on,{open:i,onOpenChange:E,currentSessionId:d,effectiveDirectory:j,isNewSessionDraftOpen:N}),e.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":"Open workspace panel",onClick:()=>{l(!1),o(!1),n()},style:{touchAction:"manipulation"},children:e.jsx(ie,{name:"layout-right",className:"size-5"})})]})}),e.jsx(ar,{open:a,onClose:()=>o(!1),anchorRef:w})]})},lr=({onActiveConnectionDeleted:s,onConnect:n})=>e.jsx(Os,{onConnect:n,onActiveConnectionDeleted:s,showDiagnostics:!0}),Ee=320,be="cubic-bezier(0.22, 1, 0.36, 1)",Mt=({side:s,enabled:n,open:r,drawerRef:i,scrimRef:l,onClose:a,widthRatio:o,prefersReducedMotion:w})=>{t.useEffect(()=>{if(!n||!r)return;const m=i.current,d=l.current;if(!m||!d)return;let y=!1,j=!1,S=!1,N=0,v=0,T=0,k=0;const E=w?0:Ee,C=s==="left"?"translateX(-100%)":"translateX(100%)",p=()=>({drawer:E?`transform ${E}ms ${be}`:"none",scrim:E?`opacity ${E}ms ${be}`:"none"}),f=()=>{const h=p();m.style.transition=h.drawer,d.style.transition=h.scrim,m.style.transform="none",d.style.opacity="1",d.style.pointerEvents="auto"},I=()=>{y=!1,j=!1,S=!1},P=()=>{if(!(y||j)){I();return}f(),I()},H=h=>{if(h.touches.length!==1){(y||j)&&P();return}if(ln(h.target,m,{excludeInteractive:!1}))return;m.style.transition&&m.style.transition!=="none"&&(m.style.transition="none",d.style.transition="none");const D=h.touches[0];N=D.clientX,v=D.clientY,T=Date.now(),k=m.offsetWidth||window.innerWidth*o,k<10&&(k=window.innerWidth*o),y=!0,j=!1,S=!1},$=h=>{if(!y)return;if(h.touches.length!==1){P();return}const D=h.touches[0],z=D.clientX-N,B=D.clientY-v;if(!S){if(Math.abs(z)<st&&Math.abs(B)<st)return;if(Math.abs(B)>Math.abs(z)*rt||!it(s,z)){y=!1;return}S=!0,j=!0,m.style.transition="none",d.style.transition="none"}if(!j)return;h.cancelable&&h.preventDefault();const W=at(s,z,k);m.style.transform=cn(s,W),d.style.opacity=String(W)},_=(h,D,z)=>{if(!y)return;const B=h-N,W=D-v,q=Math.max(1,Date.now()-T),g=at(s,B,k),R=dn({side:s,dx:B,dy:W,dt:q,progress:g,isDragging:j}),V=p();m.style.transition=V.drawer,d.style.transition=V.scrim,m.style.transform=R?C:"none",d.style.opacity=R?"0":"1",d.style.pointerEvents=R?"none":"auto",I(),R&&a()},A=h=>{const D=h.changedTouches[0];if(!D){P();return}const z=D.clientX-N,B=D.clientY-v,W=Math.abs(z)>=un&&Math.abs(B)<=Math.abs(z)*rt&&it(s,z);y&&(j||W)&&h.cancelable&&h.preventDefault(),_(D.clientX,D.clientY)},L=()=>{P()};return m.addEventListener("touchstart",H,{passive:!0}),m.addEventListener("touchmove",$,{passive:!1}),m.addEventListener("touchend",A,{passive:!1}),m.addEventListener("touchcancel",L,{passive:!0}),()=>{try{P()}catch{}m.removeEventListener("touchstart",H),m.removeEventListener("touchmove",$),m.removeEventListener("touchend",A),m.removeEventListener("touchcancel",L)}},[i,n,a,r,w,l,s,o])},cr=16,pt=t.memo(function({open:n,onOpenChange:r,variant:i="drawer",drawerRefExternal:l,scrimRefExternal:a,rootRefExternal:o}){const w=t.useRef(null),m=t.useCallback(()=>{const f=typeof document<"u"?document.activeElement:null;f instanceof HTMLElement&&w.current?.contains(f)&&f.blur(),r(!1)},[r]),[d,y]=t.useState(!1),j=t.useRef(null),S=t.useRef(null),N=l??j,v=a??S,T=t.useCallback(f=>{w.current=f,o&&(o.current=f)},[o]),k=t.useMemo(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[]);t.useEffect(()=>{const f=w.current;if(!f||n)return;const I=document.activeElement;I&&f.contains(I)&&I.blur()},[n]),t.useEffect(()=>{if(i!=="sidebar"){if(n){const f=window.setTimeout(()=>y(!0),k?0:cr);return()=>window.clearTimeout(f)}y(!1)}},[n,k,i]),t.useEffect(()=>{if(i==="sidebar"||!n)return;const f=document.body.style.overflow;document.body.style.overflow="hidden";const I=P=>{P.key==="Escape"&&m()};return document.addEventListener("keydown",I),()=>{document.body.style.overflow=f,document.removeEventListener("keydown",I)}},[m,n,i]);const E=i==="sidebar",C=e.jsx(fn,{mobileVariant:!E,isVisible:n,allowReselect:!0,onSessionSelected:E?void 0:m,onNavigateAway:E?void 0:m});if(Mt({side:"left",enabled:i==="drawer",open:n,drawerRef:N,scrimRef:v,onClose:m,widthRatio:.72,prefersReducedMotion:k}),i==="sidebar")return e.jsx("aside",{className:"relative flex h-full w-full flex-col bg-sidebar",children:C});if(typeof document>"u")return null;const p=k?0:Ee;return ze.createPortal(e.jsxs("div",{ref:T,className:"fixed inset-0 z-50",inert:!n,style:{pointerEvents:n?"auto":"none"},"data-mobile-sessions-root":"true",children:[e.jsx("button",{ref:v,type:"button",className:"absolute inset-0 cursor-default bg-black/70","aria-label":"Close sessions",onClick:m,tabIndex:n?0:-1,style:{opacity:d?1:0,transition:`opacity ${p}ms ${be}`},"data-mobile-sessions-scrim":"true"}),e.jsx("div",{ref:N,className:M("relative z-10 flex h-full w-[72%] max-w-[72%] flex-col bg-sidebar"),style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:d?"none":"translateX(-100%)",transition:p?`transform ${p}ms ${be}`:"none",touchAction:"pan-x pan-y"},"data-mobile-sessions-drawer":"true",children:C})]}),document.body)}),mt="mobile-surface-root",Ge=16,Oe=200,ur=()=>{if(typeof document>"u")return null;let s=document.getElementById(mt);return s||(s=document.createElement("div"),s.id=mt,document.body.appendChild(s)),s},Xe=({open:s,onClose:n,title:r,subtitle:i,trailing:l,disableEscapeDismiss:a=!1,headerless:o=!1,noHeaderBorder:w=!1,ariaLabel:m,variant:d="fullscreen",dialogAlign:y="chat",children:j})=>{const S=t.useRef(null),[N,v]=t.useState(!1),[T,k]=t.useState(!1),E=t.useRef(null),C=t.useRef(null),p=t.useRef(n);if(t.useEffect(()=>{p.current=n},[n]),typeof document<"u"&&!S.current&&(S.current=ur()),t.useEffect(()=>{if(!s){v(!1);return}const P=window.setTimeout(()=>v(!0),Ge);return()=>window.clearTimeout(P)},[s]),t.useEffect(()=>{if(!s){k(!1);return}const P=window.setTimeout(()=>k(!0),Ge+Oe+80);return()=>window.clearTimeout(P)},[s]),t.useEffect(()=>{if(!s)return;const P=document.body.style.overflow;C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const H=()=>{const A=E.current;if(!A)return;(A.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??A).focus({preventScroll:!0})},$=window.setTimeout(H,Ge),_=A=>{if(A.key==="Escape"&&!a){p.current();return}if(A.key!=="Tab")return;const L=E.current;if(!L)return;const h=Array.from(L.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(W=>!W.hasAttribute("disabled")&&W.getAttribute("aria-hidden")!=="true");if(h.length===0){A.preventDefault(),L.focus({preventScroll:!0});return}const D=h[0],z=h[h.length-1],B=document.activeElement;A.shiftKey&&B===D?(A.preventDefault(),z.focus({preventScroll:!0})):!A.shiftKey&&B===z&&(A.preventDefault(),D.focus({preventScroll:!0}))};return document.addEventListener("keydown",_),()=>{window.clearTimeout($),document.body.style.overflow=P,document.removeEventListener("keydown",_),C.current?.focus?.({preventScroll:!0}),C.current=null}},[a,s]),!s||!S.current)return null;const f=d==="dialog",I=e.jsxs("section",{ref:E,role:"dialog","aria-modal":"true","aria-label":m,tabIndex:-1,className:M("flex flex-col bg-background text-foreground",f?"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:f?{opacity:N?1:0,transform:N?"none":"scale(0.97)",transition:`opacity ${Oe}ms ease-out, transform ${Oe}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:N?"none":"translateX(100%)",transition:`transform ${Oe}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:P=>{N&&P.target===P.currentTarget&&P.propertyName==="transform"&&k(!0)},children:[o?null:e.jsxs("header",{className:M("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!w&&"border-b border-border/70"),children:[e.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":"Close",onClick:n,style:{touchAction:"manipulation"},children:e.jsx(ie,{name:"close",className:"size-5"})}),e.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[r?typeof r=="string"?e.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:r}):r:null,i?typeof i=="string"?e.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:i}):i:null]}),l?e.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:l}):null]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T?e.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:j}):null}),e.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return f?ze.createPortal(e.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:N?1:0,paddingLeft:y==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:y==="chat"?"max(1rem, var(--oc-chat-inset-right, 0px))":"1rem",paddingTop:"max(1rem, var(--oc-safe-area-top, 0px))"},onClick:n,children:e.jsx("div",{className:"flex w-full max-w-[720px] justify-center",onClick:P=>P.stopPropagation(),children:I})}),S.current):ze.createPortal(I,S.current)},dr=t.lazy(()=>De(()=>import("./FilesView-D0b2mEKA.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])).then(s=>({default:s.FilesView}))),fr=t.lazy(()=>De(()=>import("./GitView-Dhr7qVeI.js"),__vite__mapDeps([73,6,1,2,3,10,4,5,7,8,9,11,12,49,50,51,52,53,74,75,76,77,78,79,56,57,58,33,34,35,36,37,38,39,40,41,42,43,44,45,46,59,31,32,60,61,62,63,64,65,66,80,81,82,72,29,30])).then(s=>({default:s.GitView}))),hr=t.lazy(()=>De(()=>import("./PullRequestsSurface-D8JpzP5l.js"),__vite__mapDeps([83,6,1,2,3,84,4,5,7,8,9,10,11,12,49,50,51,52,53,85,75,76,79,56,57,58,33,34,35,36,37,38,39,40,41,42,43,44,45,46,59,31,32,60,61,62,63,64,65,66,80,81,82,72,29,30])).then(s=>({default:s.PullRequestsSurface}))),pr=t.lazy(()=>De(()=>import("./IssuesSurface-Bya7OsRl.js"),__vite__mapDeps([86,1,2,3,84,4,5,6,7,8,9,10,11,12,49,50,51,52,53,85,75,76,87])).then(s=>({default:s.IssuesSurface}))),bt="mobile-surface-root",mr=16,xt=t.memo(function({open:n,onClose:r,tab:i,onTabChange:l,pendingChangesDiff:a,variant:o="drawer",drawerRefExternal:w,scrimRefExternal:m,rootRefExternal:d,githubTabsAvailable:y=!1}){const j=t.useRef(null),S=t.useRef(null),N=t.useRef(null),v=t.useRef(null),T=w??S,k=m??N,E=d??v,C=t.useCallback(x=>{v.current=x,d&&(d.current=x)},[d]),p=t.useCallback(()=>{const x=typeof document<"u"?document.activeElement:null;x instanceof HTMLElement&&E.current?.contains(x)&&x.blur(),r()},[r]),[f,I]=t.useState(!1),[P,H]=t.useState(n),$=`mobile-workspace-tab-${t.useId()}`,_=t.useMemo(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[]),[A,L]=t.useState(()=>new Set),[h,D]=t.useState(null),[z,B]=t.useState(null);if(t.useEffect(()=>{n&&L(x=>{if(x.has(i))return x;const O=new Set(x);return O.add(i),O})},[n,i]),typeof document<"u"&&!j.current){let x=document.getElementById(bt);x||(x=document.createElement("div"),x.id=bt,document.body.appendChild(x)),j.current=x}if(t.useEffect(()=>{if(n){H(!0);const O=window.setTimeout(()=>I(!0),_?0:mr);return()=>window.clearTimeout(O)}I(!1);const x=window.setTimeout(()=>H(!1),Ee+40);return()=>window.clearTimeout(x)},[n,_]),t.useEffect(()=>{if(!n)return;const x=document.body.style.overflow;o==="drawer"&&(document.body.style.overflow="hidden");const O=oe=>{oe.key==="Escape"&&i!=="terminal"&&p()};return document.addEventListener("keydown",O),()=>{o==="drawer"&&(document.body.style.overflow=x),document.removeEventListener("keydown",O)}},[p,n,i,o]),t.useEffect(()=>{const x=E.current;if(!x||n||o!=="drawer")return;const O=document.activeElement;O&&x.contains(O)&&O.blur()},[n,o]),Mt({side:"right",enabled:o==="drawer",open:n,drawerRef:T,scrimRef:k,onClose:p,widthRatio:1,prefersReducedMotion:_}),o==="drawer"&&!j.current)return null;const W=_?0:Ee,q=hn(y),g=_?{duration:0}:{type:"spring",stiffness:520,damping:40,mass:.8},R=e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-0.5 py-1 overflow-x-auto overflow-y-hidden scrollbar-none",role:"tablist","aria-label":"Workspace","data-no-drawer-swipe":"true",children:q.map(x=>{const O=i===x.id;return e.jsxs(Be.button,{layout:"position",transition:g,type:"button",role:"tab","aria-selected":O,"aria-label":x.label,onClick:()=>l(x.id),className:M("relative flex min-h-[44px] items-center justify-center gap-1 rounded-lg py-2 typography-ui-label transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",O?"min-w-0 shrink px-2.5 text-foreground":"size-11 shrink-0 text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[O?e.jsx(Be.span,{layoutId:$,transition:g,className:"absolute inset-0 bg-interactive-selection",style:{borderRadius:8},"aria-hidden":"true"}):null,e.jsx(ie,{name:x.icon,className:"relative size-5 shrink-0"}),O?e.jsx(Be.span,{initial:_?!1:{opacity:0,x:-4},animate:{opacity:1,x:0},transition:g,className:"relative truncate",children:x.label},x.id):null]},x.id)})}),V=e.jsxs(e.Fragment,{children:[o==="panel"?null:e.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-1 px-2",children:[R,e.jsx("button",{type:"button",onClick:p,"aria-label":"Close workspace panel",className:"flex size-11 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:e.jsx(ie,{name:"close",className:"size-5"})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[A.has("changes")?e.jsx("div",{className:M("h-full",i!=="changes"&&"hidden"),children:e.jsx(ee,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(fr,{isActive:n&&i==="changes",chrome:"mobile",initialDiffPath:a?.path??null,initialDiffStaged:a?.staged===!0})})})},a?`changes:${a.path}:${a.staged}`:"changes"):null,A.has("files")?e.jsx("div",{className:M("h-full",i!=="files"&&"hidden"),children:e.jsx(ee,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(dr,{chrome:"mobile",mode:"editor-only",isVisible:n&&i==="files"})})})}):null,A.has("terminal")?e.jsx("div",{className:M("h-full",i!=="terminal"&&"hidden"),children:e.jsx(ee,{children:e.jsx(pn,{visible:n&&i==="terminal"})})}):null,A.has("pull-requests")?e.jsx("div",{className:M("h-full",i!=="pull-requests"&&"hidden"),children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[e.jsx(ot,{icon:Me.find(x=>x.id==="pull-requests")?.icon,title:Me.find(x=>x.id==="pull-requests")?.label??"Pull requests",actions:e.jsx("div",{ref:x=>{D(x)},className:"flex items-center gap-1"})}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(ee,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(hr,{hideFilesTab:!0,headerActionsSlot:n&&i==="pull-requests"?h:null,headerActionsPresentation:"drawer"})})})})]})}):null,A.has("issues")?e.jsx("div",{className:M("h-full",i!=="issues"&&"hidden"),children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[e.jsx(ot,{icon:Me.find(x=>x.id==="issues")?.icon,title:Me.find(x=>x.id==="issues")?.label??"Issues",actions:e.jsx("div",{ref:x=>{B(x)},className:"flex items-center gap-1"})}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(ee,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(pr,{headerActionsSlot:n&&i==="issues"?z:null,headerActionsPresentation:"drawer"})})})})]})}):null]})]});return o==="panel"?e.jsx("div",{className:"flex h-full min-h-0 flex-col bg-sidebar",children:V}):ze.createPortal(e.jsxs("div",{ref:C,className:"fixed inset-0 z-50",inert:!n,style:{pointerEvents:n?"auto":"none",visibility:P?"visible":"hidden"},"data-mobile-workspace-root":"true",children:[e.jsx("button",{ref:k,type:"button",className:"absolute inset-0 cursor-default bg-black/70","aria-label":"Close workspace panel",onClick:p,tabIndex:n?0:-1,style:{opacity:f?1:0,transition:W?`opacity ${W}ms ${be}`:"none"},"data-mobile-workspace-scrim":"true"}),e.jsx("section",{ref:T,role:"dialog","aria-modal":"true","aria-label":"Open workspace panel",className:"oc-keyboard-inset-surface absolute inset-y-0 right-0 z-10 flex h-full w-full flex-col bg-sidebar",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:f?"none":"translateX(100%)",transition:W?`transform ${W}ms ${be}`:"none",touchAction:"pan-x pan-y"},"data-mobile-workspace-drawer":"true",children:V})]}),j.current)}),br="pichamber",xr=s=>s.replace(/^\/+|\/+$/g,""),gr=s=>{const n=xr(s.pathname).split("/").filter(Boolean);return s.host?[s.host,...n]:n};function yr(s){if(typeof s!="string"||s.length===0)return null;let n;try{n=new URL(s)}catch{return null}if(n.protocol!==`${br}:`)return null;const r=gr(n),i=(r[0]??"").toLowerCase(),l=r.slice(1),a=n.searchParams;switch(i){case"session":{const o=l[0]||a.get("id")||"";return o?{type:"session",sessionId:o,directory:a.get("dir")??void 0}:null}case"new":case"new-session":return{type:"new-session",directory:a.get("dir")??void 0,projectId:a.get("project")??void 0,agent:a.get("agent")??void 0,model:a.get("model")??void 0};case"sessions":{const o=a.get("filter");return{type:"sessions",filter:o==="attention"||o==="recent"||o==="all"?o:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:l[0]||a.get("section")||void 0};case"changes":return{type:"changes",path:l.join("/")||a.get("path")||void 0,staged:a.get("staged")==="true"};case"view":{const o=(l[0]||"").toLowerCase();return o==="changes"?{type:"changes"}:o==="files"||o==="mcp"||o==="instances"||o==="update"?{type:"view",target:o}:null}default:return null}}let Q={},Lt=!1,Ae=null;const vr=s=>{switch(s.type){case"session":return ae.getState().setCurrentSession(s.sessionId,s.directory??null),!0;case"new-session":{const n=ae.getState();return n.openNewSessionDraft(),(s.directory||s.projectId)&&n.setNewSessionDraftTarget({directoryOverride:s.directory??null,projectId:s.projectId??null,selectedProjectId:s.projectId??null}),!0}case"sessions":return Q.openSessions?(Q.openSessions(s.filter),!0):!1;case"status":return Q.openSessions?(Q.openSessions(),!0):!1;case"view":return Q.openView?(Q.openView(s.target),!0):!1;case"changes":return Q.openChanges?(Q.openChanges({path:s.path,staged:s.staged}),!0):!1;case"settings":return Q.openSettings?(Q.openSettings(s.section),!0):!1}},Ye=()=>{if(!Lt||!Ae)return;const s=Ae;Ae=null,vr(s)||(Ae=s)},wr=s=>{Ae=s,Ye()},Sr=s=>{const n=yr(s);n&&wr(n)},jr=s=>{Lt=s,Ye()},Rr=s=>{t.useEffect(()=>(Q=s,Ye(),()=>{Q===s&&(Q={})}),[s])},kr=s=>{const{ready:n}=s;t.useEffect(()=>{jr(n)},[n]),t.useEffect(()=>{if(!Xt())return;let r=!1;const i=[];return De(()=>import("./vendor-capacitor-app-NX6DULfp.js"),__vite__mapDeps([88,6,1,2,3])).then(async({App:l})=>{if(r)return;const a=await l.addListener("appUrlOpen",o=>{Sr(o?.url)});if(r){a.remove();return}i.push(()=>{a.remove()})}).catch(()=>{}),()=>{r=!0,i.forEach(l=>l())}},[])},gt=s=>{const n=s.drawer.current,r=s.scrim.current,i=s.root.current;i&&(i.style.pointerEvents="auto",i.style.visibility="visible"),n&&(n.style.transition="none"),r&&(r.style.transition="none")},yt=(s,n,r)=>{const i=s.drawer.current,l=s.scrim.current;if(i&&(i.style.transform=r>=.999?"none":`translateX(${(n==="left"?r-1:1-r)*100}%)`),l){l.style.opacity=String(r);const a=r>.01?"auto":"none";l.style.pointerEvents!==a&&(l.style.pointerEvents=a)}},vt=(s,n,r)=>{const i=r.drawer.current,l=r.scrim.current,a=r.root.current;i&&(i.style.transition=`transform ${Ee}ms ${be}`,i.style.transform=n?"none":s==="left"?"translateX(-100%)":"translateX(100%)"),l&&(l.style.transition=`opacity ${Ee}ms ${be}`,l.style.opacity=n?"1":"0",l.style.pointerEvents=n?"auto":"none"),a&&(a.style.pointerEvents=n?"auto":"none",a.style.visibility=n?"visible":"")},wt=s=>{const n=s.shell.current,r=s.inner.current;n&&(n.style.overflow="visible"),r&&(r.style.transition="none")},St=(s,n,r,i)=>{const l=s.inner.current;if(!l)return;const a=i==="left"?(n-1)*r:(1-n)*r;l.style.transform=n>=.999?"translateX(0)":`translateX(${a}px)`},jt=(s,n,r,i,l)=>{const a=s.shell.current,o=s.inner.current;return!a||!o?void 0:(o.style.transition="transform 200ms cubic-bezier(0.22, 1, 0.36, 1)",o.style.transform=n?"translateX(0)":`translateX(${i==="left"?-r:r}px)`,window.setTimeout(()=>{o.style.transition="",o.style.transform="",a.style.overflow=""},220))},Rt=({side:s,isResizing:n,ariaLabel:r,handleProps:i})=>e.jsx("div",{className:M("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",s==="left"?"right-0":"left-0"),role:"separator","aria-orientation":"vertical","aria-label":r,...i,children:e.jsx("div",{className:M("absolute inset-y-0 w-[3px] transition-colors",s==="left"?"right-0":"left-0",n&&"bg-[var(--interactive-border)]")})}),Er=320,Cr=380,kt=280,Nr=560,Tr=900;function Et(s,n,r,i=Nr){const l=t.useRef(null),[a,o]=t.useState(()=>{if(typeof window>"u")return r;const p=Number.parseInt(window.localStorage.getItem(n)??"",10);return Number.isFinite(p)?Math.min(i,Math.max(kt,p)):r}),[w,m]=t.useState(!1),d=t.useRef(0),y=t.useRef(a),j=t.useRef(null),S=t.useRef(null),N=t.useCallback(p=>Math.min(i,Math.max(kt,Math.round(p))),[i]),v=t.useCallback(p=>{const f=l.current;f&&(f.style.width=`${p}px`,f.style.minWidth=`${p}px`,f.style.maxWidth=`${p}px`,f.style.setProperty("--oc-ipad-sidebar-width",`${p}px`))},[]),T=t.useCallback(p=>{try{p.currentTarget.setPointerCapture(p.pointerId)}catch{}S.current=p.pointerId,d.current=p.clientX,y.current=a,j.current=a,m(!0),p.preventDefault()},[a]),k=t.useCallback(p=>{if(S.current!==p.pointerId)return;const f=p.clientX-d.current,I=N(y.current+(s==="left"?f:-f));j.current!==I&&(j.current=I,v(I))},[v,N,s]),E=t.useCallback(p=>{if(S.current!==p.pointerId)return;try{p.currentTarget.releasePointerCapture(p.pointerId)}catch{}const f=N(j.current??y.current);S.current=null,j.current=null,m(!1),o(f);try{window.localStorage.setItem(n,String(f))}catch{}},[N,n]),C=t.useMemo(()=>({onPointerDown:T,onPointerMove:k,onPointerUp:E,onPointerCancel:E}),[T,E,k]);return{asideRef:l,width:a,isResizing:w,handleProps:C}}const Ir=t.memo(Sn),Pr=({onActiveConnectionDeleted:s})=>{const[n,r]=t.useState(!1),[i,l]=t.useState(null),[a,o]=t.useState(!1),[w,m]=t.useState("changes"),d=t.useCallback(c=>{m(lt(c))},[]),y=w,[j,S]=t.useState("nav"),[N,v]=t.useState(null),T=t.useRef([]),k=t.useCallback(()=>{T.current.forEach(c=>window.clearTimeout(c)),T.current=[]},[]);t.useEffect(()=>()=>k(),[k]);const E=t.useRef(null),C=t.useRef(null),p=t.useRef(null),f=t.useRef(null),I=t.useRef(null),P=t.useRef(null),H=t.useRef(null),$=t.useRef(null),_=t.useRef(0),A=t.useRef(0),L=t.useCallback(c=>{k(),r(c)},[k]),h=t.useCallback(c=>{k(),o(c)},[k]),D=je(c=>c.setSettingsPage),z=je(c=>c.isArchivePageOpen),B=je(c=>c.setArchivePageOpen),W=ke(c=>c.available),q=ke(c=>c.runtimeType),g=t.useMemo(()=>Dt(),[]),R=!g&&W&&(q==="desktop"||q==="web"),V=Kn()??"",x=V?Kt(V):"",O=qn().github??null,oe=ct(c=>c.ensureScope);t.useEffect(()=>{!x||!O||oe(x,O)},[x,O,oe]);const _e=ct(c=>x?c.entriesByDirectory[x]??null:null),te=t.useMemo(()=>Yn(_e),[_e]),xe=Qn(te);t.useEffect(()=>{!xe&&mn(w)&&m(bn(w))},[xe,w]);const le=t.useCallback(()=>{l(null)},[]),ne=t.useCallback(c=>{l(c)},[]),ge=t.useCallback(()=>{h(!1)},[h]),u=t.useCallback(c=>{S(c),ne("settings")},[ne]),{enabled:b,roomyForPanels:U}=Jn(),F=Zn()==="portrait",J=es(),se=je(c=>c.setSidebarOpen),X=je(c=>c.isSidebarOpen),we=t.useRef(!1);t.useLayoutEffect(()=>{b&&!we.current&&se(ts().roomyForPanels),!b&&we.current&&se(!1),we.current=b},[b,se]);const pe=t.useCallback(()=>{v(null),d("files"),h(!0)},[d,h]),fe=t.useCallback((c=null)=>{v(c),d("changes"),h(!0)},[d,h]),K=Et("left","pichamber.ipad.leftSidebarWidth",Er),Z=Et("right","pichamber.ipad.rightSidebarWidth",Cr,Tr),Qe=U,ce=Qe&&a?Z.width:0,zt=xn(b&&X),Ce=b&&X?K.width:0,Wt=t.useCallback(c=>{const Y=lt(c);a&&y===Y?h(!1):(d(Y),h(!0))},[a,y,d,h]),Ut=t.useCallback(()=>{h(!a)},[a,h]),Bt=t.useCallback(c=>{!c&&!U&&se(!1)},[U,se]);t.useEffect(()=>{if(typeof document>"u")return;const c=document.documentElement;return c.style.setProperty("--oc-chat-inset-left",`${Ce}px`),c.style.setProperty("--oc-chat-inset-right",`${ce}px`),()=>{c.style.removeProperty("--oc-chat-inset-left"),c.style.removeProperty("--oc-chat-inset-right")}},[Ce,ce]),t.useEffect(()=>{if(typeof document>"u")return;const c=b&&(F||J),Y=document.documentElement;return Y.classList.toggle("oc-keep-draft-starters",c),()=>Y.classList.remove("oc-keep-draft-starters")},[J,b,F]);const Je=t.useCallback(()=>{L(!1),h(!1)},[L,h]),Ht=t.useMemo(()=>({openChanges:({diffPath:c,staged:Y}={})=>{fe(c?{path:c,staged:Y===!0}:null)},openFiles:()=>pe(),openSettings:c=>{c&&D(c),u(c?"page-content":"nav")},openInstances:g?()=>ne("instances"):void 0,instanceLabel:g?Re():null,openUpdate:R?()=>ne("update"):void 0,closeDrawers:Je}),[Je,fe,pe,u,ne,D,g,R]),$t=t.useMemo(()=>({openSessions:()=>{b?se(!0):L(!0)},openView:c=>{if(c==="files"){pe();return}(c==="instances"||c==="update"||c==="mcp")&&ne(c)},openChanges:({path:c,staged:Y}={})=>{fe(c?{path:c,staged:Y===!0}:null)},openSettings:c=>{c&&D(c),u(c?"page-content":"nav")}}),[b,fe,pe,u,ne,D,L,se]);Rr($t);const Ze=t.useRef(null);gn(Ze,{leftOpen:b?X:n,rightOpen:a,leftWidth:()=>b?K.width:E.current?.offsetWidth||window.innerWidth*.72,rightWidth:()=>b?Z.width:f.current?.offsetWidth||window.innerWidth,onLeftProgress:c=>{if(_.current=c,b){St({inner:H},c,K.width,"left");return}yt({drawer:E,scrim:C},"left",c)},onRightProgress:c=>{if(A.current=c,b&&U){St({inner:$},c,Z.width,"right");return}yt({drawer:f,scrim:I},"right",c)},onLeftOpen:()=>{b?se(!0):L(!0)},onLeftClose:()=>{b?se(!1):L(!1)},onRightOpen:()=>h(!0),onRightClose:()=>h(!1),onDragStart:c=>{if(k(),c==="left"){_.current=b?X?1:0:n?1:0,b?wt({shell:K.asideRef,inner:H}):gt({drawer:E,scrim:C,root:p});return}A.current=a?1:0,b&&U?wt({shell:Z.asideRef,inner:$}):gt({drawer:f,scrim:I,root:P})},onDragEnd:(c,Y)=>{if(c==="left"){const Se=typeof Y=="boolean"?Y:_.current>.5;if(_.current=Se?1:0,b){const et=jt({shell:K.asideRef,inner:H},Se,K.width,"left");et!==void 0&&T.current.push(et)}else vt("left",Se,{drawer:E,scrim:C,root:p});return}const Ue=typeof Y=="boolean"?Y:A.current>.5;if(A.current=Ue?1:0,b&&U){const Se=jt({shell:Z.asideRef,inner:$},Ue,Z.width,"right");Se!==void 0&&T.current.push(Se)}else vt("right",Ue,{drawer:f,scrim:I,root:P})}});const Ft=t.useCallback(()=>z?(B(!1),!0):i?(le(),!0):a?(ge(),!0):n?(L(!1),!0):!1,[i,le,ge,z,n,B,L,a]);Pt(Ft);const We=b?"dialog":"fullscreen";return e.jsx(ns,{actions:Ht,children:e.jsxs("div",{className:"oc-mobile-app-shell main-content-safe-area relative flex h-[100dvh] flex-row bg-background text-foreground","data-page-scroll-lock":"true",children:[b?e.jsxs("aside",{ref:K.asideRef,className:M("relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-sidebar motion-reduce:transition-none",!X&&"border-r-0"),style:{width:Ce,minWidth:Ce,maxWidth:Ce,"--oc-ipad-sidebar-width":`${K.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)"},inert:!X,"data-page-scroll-lock":"true",children:[e.jsx("div",{ref:H,className:M("flex h-full shrink-0 flex-col",K.isResizing&&"pointer-events-none",!X&&"pointer-events-none select-none"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden",transform:K.isResizing||zt.slidIn?"translateX(0)":"translateX(-100%)",transition:K.isResizing?"none":"transform 200ms cubic-bezier(0.22, 1, 0.36, 1)"},children:e.jsx(ee,{children:e.jsx(pt,{open:X,variant:"sidebar",onOpenChange:Bt})})}),X?e.jsx(Rt,{side:"left",isResizing:K.isResizing,ariaLabel:"Resize left panel",handleProps:K.handleProps}):null]}):null,e.jsxs("div",{className:"relative flex h-full min-w-0 flex-1 flex-col","data-page-scroll-lock":"true",children:[b?e.jsxs(e.Fragment,{children:[e.jsx(yn,{}),e.jsx(vn,{onToggleRightDrawer:Ut,rightDrawerOpen:a,tabletWorkspaceTab:y,onSelectTabletWorkspaceTab:Wt,tabletGitHubTabsAvailable:xe})]}):e.jsx(or,{onOpenSessions:()=>L(!0),onOpenWorkspace:()=>h(!0)}),e.jsx("main",{ref:Ze,className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",style:{touchAction:"pan-x pan-y"},children:e.jsx("div",{className:"h-full w-full",children:e.jsx(ee,{children:e.jsx(Ir,{})})})})]}),b?null:e.jsx(pt,{open:n,onOpenChange:L,drawerRefExternal:E,scrimRefExternal:C,rootRefExternal:p}),b?e.jsxs("aside",{ref:Z.asideRef,className:M("relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/70 bg-background motion-reduce:transition-none",!ce&&"border-l-0"),style:{width:ce,minWidth:ce,maxWidth:ce,"--oc-ipad-sidebar-width":`${Z.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)"},inert:!ce,"data-page-scroll-lock":"true",children:[e.jsx("div",{ref:$,className:M("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",Z.isResizing&&"pointer-events-none",!ce&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden",transform:ce?"translateX(0)":"translateX(100%)",transition:Z.isResizing?"none":"transform 200ms cubic-bezier(0.22, 1, 0.36, 1), opacity 200ms cubic-bezier(0.22, 1, 0.36, 1)"},children:e.jsx(ee,{children:e.jsx(xt,{open:a,onClose:ge,tab:y,onTabChange:d,pendingChangesDiff:N,variant:Qe?"panel":"drawer",githubTabsAvailable:xe,drawerRefExternal:f,scrimRefExternal:I,rootRefExternal:P})})}),ce?e.jsx(Rt,{side:"right",isResizing:Z.isResizing,ariaLabel:"Resize right panel",handleProps:Z.handleProps}):null]}):e.jsx(xt,{open:a,onClose:ge,tab:y,onTabChange:d,pendingChangesDiff:N,githubTabsAvailable:xe,drawerRefExternal:f,scrimRefExternal:I,rootRefExternal:P}),i==="instances"&&g?e.jsx(Xe,{open:!0,variant:We,dialogAlign:"app",onClose:le,ariaLabel:"Servers",title:"Servers",children:e.jsx(lr,{onConnect:le,onActiveConnectionDeleted:s})}):null,i==="settings"?e.jsx(Xe,{open:!0,variant:We,dialogAlign:"app",onClose:le,ariaLabel:"Settings",headerless:!0,children:e.jsx(ee,{children:e.jsx(zs,{forceMobile:!b,isWindowed:!0,initialMobileStage:j,onClose:le,onActiveConnectionDeleted:s})})}):null,i==="update"?e.jsx(Xe,{open:!0,variant:We,dialogAlign:"app",onClose:le,ariaLabel:"Update",title:"Update",children:e.jsx(ee,{children:e.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:e.jsx(Ws,{initialUpdateDialogOpen:!0})})})}):null,e.jsx(ee,{children:e.jsx(wn,{})})]})})},Ar=8,Ot=6e4,Dr=6e4,Ke=[1e3,2e3,4e3,8e3,15e3,3e4,3e4,3e4],_r=(s,n)=>{if(n?.offline||n?.hidden)return Ot;if(s<=0)return Ke[0];const r=Math.min(s-1,Ke.length-1);return Ke[r]??3e4},de=()=>typeof navigator<"u"&&typeof navigator.onLine=="boolean"?!navigator.onLine:!1,re=()=>typeof document<"u"&&typeof document.visibilityState=="string"?document.visibilityState==="hidden":!1;class Mr{constructor(n,r,i=()=>""){this.probe=n,this.callbacks=r,this.getRuntimeIdentity=i}probe;callbacks;getRuntimeIdentity;generation=0;attempt=0;timer=null;wakeCleanup=null;running=!1;exhausted=!1;probingGeneration=null;get currentGeneration(){return this.generation}get currentAttempt(){return this.attempt}get isRunning(){return this.running&&!this.exhausted}start(){he("recovery",{code:"start"}),this.startCycle(!1)}startCycle(n){this.clearTimer(),this.generation+=1,this.attempt=0,this.exhausted=!1,this.running=!0,n?this.runAttempt(this.generation):this.scheduleNext(this.generation)}retryNow(){if(this.exhausted){if(de()||re())return;this.startCycle(!0);return}this.running&&(this.clearTimer(),this.runAttempt(this.generation))}cancel(){he("recovery",{code:"cancel"}),this.generation+=1,this.running=!1,this.exhausted=!1,this.attempt=0,this.probingGeneration=null,this.clearTimer()}async probeOnce(){return this.running||this.exhausted||this.probingGeneration!==null||de()||re()?null:this.runGuardedProbe(this.generation)}async runGuardedProbe(n){this.probingGeneration=n;const r=this.getRuntimeIdentity();let i;try{i=await this.probe()}catch{i="unreachable"}finally{this.probingGeneration===n&&(this.probingGeneration=null)}return n!==this.generation||this.getRuntimeIdentity()!==r?null:i}settleTerminalOutcome(n){return n==="unreachable"?!1:(this.running=!1,this.exhausted=!1,this.clearTimer(),n==="needs-login"?this.callbacks.onAuthExpired():n==="no-connection"?this.callbacks.onNoConnection():this.callbacks.onHealthy(n),!0)}clearTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.wakeCleanup&&(this.wakeCleanup(),this.wakeCleanup=null)}scheduleNext(n){if(n!==this.generation||!this.running||this.exhausted)return;if(this.attempt>=Ar){this.exhausted=!0,this.running=!1,this.callbacks.onExhausted(),this.scheduleExhaustedPoll(n);return}const r=this.attempt+1,i=_r(r,{offline:de(),hidden:re()});this.callbacks.onAttempt?.(r,i);const l=()=>{de()||re()||n===this.generation&&(this.clearTimer(),this.runAttempt(n))},a=()=>l(),o=()=>{typeof document<"u"&&document.visibilityState==="visible"&&l()};typeof window<"u"&&window.addEventListener("online",a),typeof document<"u"&&document.addEventListener("visibilitychange",o),this.wakeCleanup=()=>{typeof window<"u"&&window.removeEventListener("online",a),typeof document<"u"&&document.removeEventListener("visibilitychange",o)},this.timer=setTimeout(()=>{if(this.timer=null,this.wakeCleanup?.(),this.wakeCleanup=null,!(n!==this.generation||!this.running||this.exhausted)){if(de()||re()){this.scheduleNext(n);return}this.runAttempt(n)}},i)}async runAttempt(n){if(n!==this.generation||!this.running||this.exhausted||this.probingGeneration===n)return;if(de()||re()){this.scheduleNext(n);return}const r=await this.runGuardedProbe(n);r===null||this.settleTerminalOutcome(r)||(this.attempt+=1,this.scheduleNext(n))}scheduleExhaustedPoll(n){if(n!==this.generation||!this.exhausted)return;this.clearTimer();const r=de()||re()?Ot:Dr;this.timer=setTimeout(()=>{this.timer=null,this.runExhaustedPoll(n)},r)}async runExhaustedPoll(n){if(n!==this.generation||!this.exhausted)return;if(this.probingGeneration!==null||de()||re()){this.scheduleExhaustedPoll(n);return}const r=await this.runGuardedProbe(n);r===null||!this.exhausted||this.settleTerminalOutcome(r)||this.scheduleExhaustedPoll(n)}}function Lr(s=2500){const{uiFont:n}=ss(),[r,i]=t.useState(!1);return t.useEffect(()=>{let l=!1;const a=()=>{l||i(!0)},o=()=>{requestAnimationFrame(()=>requestAnimationFrame(a))},w=Promise.all([rs(n).catch(()=>{}),document.fonts?.ready?.then(()=>{}).catch(()=>{})??Promise.resolve(),Vs.catch(()=>{})]).then(()=>{}),m=new Promise(d=>{window.setTimeout(d,s)});return Promise.race([w,m]).then(o),()=>{l=!0}},[n,s]),r}const Or=1e3;function zr({apis:s}){const n=me(u=>u.initializeApp),r=me(u=>u.isInitialized),i=me(u=>u.isConnected),l=me(u=>u.connectionPhase),a=me(u=>u.providers.length),o=me(u=>u.loadProviders),w=Ct(u=>u.currentDirectory),m=ae(u=>u.error),d=ae(u=>u.clearError),y=je(u=>u.setIsMobile),[j,S]=t.useState(0),[N,v]=t.useState(0),[T,k]=t.useState(!1),[E,C]=t.useState("idle"),p=is(),f=t.useRef(null),I=t.useRef(E);I.current=E;const[P,H]=t.useState("pending"),[$,_]=t.useState(null),A=t.useMemo(()=>Re(),[]),[,L]=t.useReducer(u=>u+1,0),h=t.useMemo(()=>Dt(),[]),D=t.useRef(0),z=t.useRef(0),B=t.useRef(!1),[W,q]=t.useState(()=>h&&!!ue());t.useEffect(()=>{const u=new Mr(()=>Us(),{onHealthy:b=>{if(he("recovery",{code:"success"}),C("idle"),ye(!1),b==="unchanged"){Zt(),me.getState().initializeApp();const U=me.getState();U.providers.length===0&&U.loadProviders({source:"mobileApp:recovery"})}},onAuthExpired:()=>{he("recovery",{code:"auth-expired"}),C("idle"),ye(!1),_({kind:"auth-expired",label:Re()??""}),Ne({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),S(b=>b+1)},onNoConnection:()=>{he("recovery",{code:"no-connection"}),C("idle"),ye(!1),Ne({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),S(b=>b+1)},onExhausted:()=>{he("recovery",{code:"exhausted"}),C("exhausted")},onAttempt:b=>{he("recovery",{code:"attempt",detail:String(b)})}},()=>`${Te()}|${ue()}`);return f.current=u,()=>{u.cancel(),f.current=null}},[]);const g=t.useCallback(()=>{if(!h||!ue())return;const u=f.current;if(u){if(u.isRunning){u.retryNow();return}C("recovering"),ye(!0),u.start()}},[h]),R=t.useCallback(()=>{f.current?.cancel(),C("idle"),ye(!1),q(!1)},[]),V=t.useCallback(u=>{R(),u&&_(u),Ne({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),S(b=>b+1)},[R]),x=t.useCallback(()=>{const u=Date.now();u-D.current>=Or&&(D.current=u,window.dispatchEvent(new Event("pichamber:system-resume")))},[]),O=t.useCallback(()=>{const u=ue(),b=z.current+1;if(z.current=b,!u){if(B.current)return;B.current=!0,Fe().catch(()=>{}).finally(()=>{B.current=!1});return}if(f.current?.isRunning){f.current.retryNow(),x();return}if(I.current==="exhausted"){if(de()||re())return;C("recovering"),ye(!0),f.current?.start(),x();return}if(de()||re()){g();return}const U=()=>{n(),a===0&&o({source:"mobileApp:nativeResume"})},G=f.current;G&&(G.probeOnce().then(F=>{if(F!==null&&z.current===b){if(F==="no-connection"){V(null);return}if(F==="needs-login"){V({kind:"auth-expired",label:Re()??""});return}if(F==="unreachable"){g();return}F!=="switched"&&U()}}),x())},[V,x,n,o,a,g]);as(),os(O),t.useEffect(()=>qt(),[]),t.useEffect(()=>{if(!h)return;let u;const b=()=>{if(f.current?.isRunning){f.current.retryNow();return}if(I.current==="exhausted"){if(re())return;C("recovering"),ye(!0),f.current?.start();return}window.clearTimeout(u),u=window.setTimeout(()=>O(),1500)};return window.addEventListener("online",b),()=>{window.removeEventListener("online",b),window.clearTimeout(u)}},[h,O]),t.useEffect(()=>{if(h)return Yt(()=>{ue()&&V({kind:"auth-expired",label:Re()??""})})},[V,h]),t.useEffect(()=>(nt(s),()=>nt(null)),[s]),t.useEffect(()=>Qt(u=>{if(!!u.runtimeKey&&u.runtimeKey===u.previousRuntimeKey){jn(),L();return}R(),Rn(u),v(U=>U+1),S(U=>U+1)}),[R]),t.useEffect(()=>{Nt()},[N]),t.useEffect(()=>{if(!h||i||ue()){H("done");return}let u=!1;return H("attempting"),Fe().catch(()=>({status:"no-candidate"})).then(b=>{u||(he("auto-connect",{code:b.status}),b.status==="unreachable"?_({kind:"unreachable",label:b.label}):b.status==="needs-login"&&_({kind:"auth-expired",label:b.label}),H("done"))}),()=>{u=!0}},[]),t.useEffect(()=>{if(!h||!ue()){q(!1);return}let u=!1;const b=G=>{G&&_(G),Ne({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),S(F=>F+1)},U=f.current;if(!U){q(!1);return}return(async()=>{try{const G=await U.probeOnce();if(u||G===null||G==="switched"||G==="unchanged")return;const F=Re();if(G==="needs-login"){b({kind:"auth-expired",label:F??""});return}if(G==="unreachable"){g();return}const J=await Fe().catch(()=>({status:"no-candidate"}));if(u||(he("auto-connect",{code:J.status}),J.status==="connected"))return;J.status==="needs-login"?b({kind:"auth-expired",label:J.label}):J.status==="unreachable"?b({kind:"unreachable",label:J.label}):b(null)}finally{u||q(!1)}})(),()=>{u=!0,q(!1)}},[g]),t.useEffect(()=>{y(!0)},[y]),t.useEffect(()=>{h&&!ue()||n()},[j,n,h]),t.useEffect(()=>{i&&a===0&&o({source:"mobileApp:recovery"})},[i,o,a]);const oe=t.useRef(!1),[_e,te]=t.useState(h);t.useEffect(()=>{if(!h||!i||oe.current)return;if(ae.getState().currentSessionId){oe.current=!0,te(!1);return}const u=Te(),b=ls(u);if(!b){oe.current=!0,te(!1);return}const U=Jt(b.directory??null);if(!U){oe.current=!0,te(!1);return}const G=Ie();let F=0;try{F=G.getRuntimeGeneration()}catch{F=0}let J=!1;const se=window.setTimeout(()=>te(!1),6e3);return(async()=>{let X=null;try{X=await cs([U])}catch{X=null}if(J)return;if(!X){te(!1);return}const we=Ie();let pe=F;try{pe=we.getRuntimeGeneration()}catch{pe=F}const fe=tr({persisted:b,persistedDirectory:U,stale:X.stale,ready:X.readyDirectories.has(U),catalog:X.catalog,runtimeKey:Te(),capturedRuntimeKey:u,storeIdentityMatches:we===G,generationMatches:pe===F});if(fe.action==="wait"){te(!1);return}if(oe.current=!0,fe.action==="clear"){us(u),te(!1);return}const K=ae.getState();if(Te()!==u||Ie()!==G){te(!1);return}K.currentSessionId||K.setCurrentSession(fe.sessionId,fe.directory),te(!1)})(),()=>{J=!0,window.clearTimeout(se)}},[j,i,h]),t.useEffect(()=>{i&&Ie().focusProject(w,tn(w))},[w,i]),t.useEffect(()=>{if(!m)return;const u=window.setTimeout(()=>d(),5e3);return()=>window.clearTimeout(u)},[d,m]),t.useEffect(()=>{if(h&&E!=="idle"){k(!1);return}if(h&&W){k(!1);return}if(!(!i&&(h?!!ue():!0))){k(!1);return}const b=window.setTimeout(()=>{k(!0)},h?4e3:8e3);return()=>window.clearTimeout(b)},[i,h,j,E,N,W]),ds(),kn(),kr({ready:h&&i&&r});const xe=Lr(),le=!i&&l==="reconnecting",ne=!!ue(),ge=h&&ne&&E!=="idle";return xe?h&&!ge&&(!ne||!i&&!le)?ne?e.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-4",children:[e.jsx(ve,{width:120,height:120,isAnimated:!T}),T?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"typography-h3 text-foreground",children:"Unable to reach server"}),e.jsx("p",{className:"typography-body text-muted-foreground",children:"Could not connect to the saved server. Check that it is running, or pick another server."})]}),e.jsx(Pe,{type:"button",variant:"outline",onClick:()=>{V(null)},children:"Use another server"})]}):null]})}):P!=="done"?e.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-background text-foreground",children:[e.jsx(ve,{width:120,height:120,isAnimated:!0}),A?e.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[e.jsx("p",{className:"typography-small text-muted-foreground",children:"Connecting to device:"}),e.jsx("div",{className:"flex justify-center",children:e.jsx(fs,{text:A,showElapsed:!1})})]}):null]}):e.jsx(e.Fragment,{children:e.jsx(nr,{onConnected:()=>S(u=>u+1),notice:$})}):!h&&!i&&!le?T?e.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:e.jsxs("div",{className:"max-w-sm space-y-3",children:[e.jsx("h1",{className:"typography-h3 text-foreground",children:"Unable to reach server"}),e.jsx("p",{className:"typography-body text-muted-foreground",children:"We could not verify the UI session. If you're opening PiChamber from another device on your local network, make sure Desktop Network Access is enabled on the desktop app and use the LAN address shown in Settings."})]})}):e.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:e.jsx(ve,{width:120,height:120,isAnimated:!0})}):e.jsx(ee,{children:e.jsx(hs,{children:e.jsxs(ps,{apis:s,children:[e.jsx(ms,{}),e.jsx(bs,{}),e.jsx(En,{}),e.jsx(xs,{}),e.jsx(gs,{}),e.jsx(ys,{delayDuration:300,skipDelayDuration:150,children:e.jsxs(Cn,{children:[e.jsx(Nn,{}),e.jsxs("div",{className:"h-full bg-background text-foreground",children:[h&&_e?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background",children:e.jsx(ve,{width:120,height:120,isAnimated:!0})}):null,e.jsx(vs,{embeddedBackgroundWorkEnabled:r&&!p}),ge?e.jsxs("div",{role:"status","aria-live":"polite",className:"pointer-events-none fixed inset-x-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px)+10px)] z-40 flex justify-center",children:[e.jsx("span",{className:"flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-[var(--surface-elevated-foreground)] shadow-sm",children:e.jsx(ve,{width:24,height:24,isAnimated:!0})}),e.jsx("span",{className:"sr-only",children:E==="exhausted"?"Server unreachable":"Reconnecting…"})]}):null,e.jsx(er,{}),e.jsx(Pr,{onActiveConnectionDeleted:()=>{R(),Ne({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),S(u=>u+1)}}),e.jsx(Tn,{}),e.jsx(In,{}),e.jsx(ws,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),e.jsx(Ss,{})]})]})})]})},N)}):e.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:e.jsx(ve,{width:120,height:120,isAnimated:!0})})}const Wr=()=>{(async()=>{try{await Promise.all([Nt(),nn()])}catch(s){console.error("[mobile-main] settings init failed:",s)}Cs(),Ns(),Ts(),sn()})().finally(()=>{Gs()})};function ui(s){window.__PICHAMBER_SURFACE__="mobile",js(),Wr(),Zs(),Rs();const n=document.getElementById("root");if(!n)throw new Error("Root element not found");const i=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",l=s??en();if(!l)throw new Error("Runtime APIs not registered");const a=i?{...l,notifications:{notify:async()=>!1,canNotify:()=>!1}}:l,o=e.jsx(zr,{apis:a});Vt.createRoot(n).render(e.jsx(qe.StrictMode,{children:e.jsx(ks,{children:e.jsx(Pn,{children:i?o:e.jsx(Es,{children:o})})})}))}export{ui as renderMobileApp};