@openchambery/web 2.1.6-beta.7 → 2.1.6-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AssistantView-BAn7c1j0.js → AssistantView-CNI0zQTE.js} +3 -3
- package/dist/assets/{DiagramView-CcT2y7La.js → DiagramView-DWH25cTW.js} +1 -1
- package/dist/assets/{MarkdownRenderer-DVE7BXyU.js → MarkdownRenderer-dLZyr9W5.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-BoidX86O.js → MarkdownRendererImpl-BId3jZPx.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-B8MznUfR.js → MarkstreamRendererImpl-3RYaxtPS.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-BB2hRMes.js → MobileDetailNavigation-DO3ghMuq.js} +1 -1
- package/dist/assets/{MobileShareBridge-DmY_F56w.js → MobileShareBridge-CPPp_bPt.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-wyNSBINq.js → MobileTabPageHeader-D32a8Hs0.js} +1 -1
- package/dist/assets/{MultiRunWindow-CQdG8Sjp.js → MultiRunWindow-DFxxAKe4.js} +1 -1
- package/dist/assets/{SettingsView-CpA3P8Hj.js → SettingsView-D--vyB_S.js} +1 -1
- package/dist/assets/{SettingsWindow-MxNLysXf.js → SettingsWindow-DbFOkDt5.js} +1 -1
- package/dist/assets/{TerminalView-Bc1rQTuK.js → TerminalView-DQTBbEkB.js} +1 -1
- package/dist/assets/{ToolOutputDialog-0MzoUb8d.js → ToolOutputDialog-SMP_kNn6.js} +1 -1
- package/dist/assets/{appThemeRegistry-DuusPsuR.js → appThemeRegistry-CiEDgyCl.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-zYNvEOA7.js → fileMentionTouchSelection-CsPactMH.js} +1 -1
- package/dist/assets/{gitApi-k8hCwYqu.js → gitApi-BOlE2j2L.js} +1 -1
- package/dist/assets/{insertionBoundaries-D2KDgrS0.js → insertionBoundaries-BON5gcu9.js} +1 -1
- package/dist/assets/{main-CDLieC0x.js → main-DYjfXhVU.js} +4 -4
- package/dist/assets/{main-rsLnx-58.js → main-DsKN4NIj.js} +2 -2
- package/dist/assets/{mcpQueries-DxtC14uJ.js → mcpQueries-BnBTQPOC.js} +1 -1
- package/dist/assets/{miniChat-_WMT0ocE.js → miniChat-B0AB_-gG.js} +2 -2
- package/dist/assets/{mobile-DlsyRhzT.js → mobile-CreSH0WP.js} +2 -2
- package/dist/assets/{multirun-TuZ84E4i.js → multirun-CkqmQEf9.js} +1 -1
- package/dist/assets/{projectMeta-CRGyp6h1.js → projectMeta-Cdx7RbLo.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CcwM2ERi.js → renderElectronMiniChatApp-BoO5qg3C.js} +2 -2
- package/dist/assets/{renderMobileApp-Ci90vrGl.js → renderMobileApp-M8-Y4hWH.js} +4 -4
- package/dist/assets/{runtimeConfig-DnxTxkDG.js → runtimeConfig-lDKfE8JI.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-DLwrJ8o6.js → runtimeEndpointReset-D4VD9Jn_.js} +1 -1
- package/dist/assets/{sessionChangeSummary-DjTq4ZTb.js → sessionChangeSummary-03r3sD9M.js} +1 -1
- package/dist/assets/{sessionLookup-ai7V-fcR.js → sessionLookup--IwXu1NF.js} +1 -1
- package/dist/assets/{speechSettingsQueries-GUD7hwQt.js → speechSettingsQueries-FzNqlyDv.js} +1 -1
- package/dist/assets/{useAppFontEffects-ADlv1hDy.js → useAppFontEffects-CHL4rtDx.js} +8 -8
- package/dist/assets/{useDesktopWindowControlsLayout-D63tZVkG.js → useDesktopWindowControlsLayout-P-vYpU8A.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-DSPgEsnp.js → useEffectiveDirectory-CW0-F3UC.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-CaaSJtom.js → useMobileNavigationStore-CC30Ki7r.js} +3 -3
- package/dist/assets/{useWorkerHighlightedLines-D6B2J_UI.js → useWorkerHighlightedLines-pIf0YNjH.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/mini-chat.html +2 -2
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{S as t,_ as n,p as r,r as i,t as a,v as o,w as s}from"./runtime-auth-C8w0nlKy.js";import{c,f as l,i as u,l as d,r as f,s as p,t as m}from"./runtime-switch-3ad3yzM7.js";import{n as h}from"./runtime-fetch-QCWYlAx0.js";import{Mn as g,Nn as _,Rt as v,ot as y,r as b,t as x}from"./persistence-DUPZl7Oy.js";import{a as S,i as C}from"./vendor-zustand-o69pgTEK.js";import{it as w,nt as T,rt as E}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as D,Ir as O,Lr as k,Nt as A,n as j,r as M,t as N}from"./platform-z2erC6Bs.js";import{n as P,x as F}from"./useUIStore-pl39iO82.js";import{n as I,t as L}from"./vendor-react-BP2cRVqX.js";import{a as R,n as z,o as B}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{t as ee}from"./capgoAdapter-KNLHDj7G.js";/* empty css */import{a as V}from"./vendor-pierre-diffs-DPBtNDJ5.js";import{r as H}from"./vendor-sonner-ZS8XIOVl.js";import{c as te,n as U,r as W}from"./vendor-reactuses-core-BpfIZ1tg.js";import{d as ne,f as re,m as ie,r as G,t as K}from"./button-kJNzMb1G.js";import{i as ae,n as oe}from"./store-D5OeM4wB.js";import{a as se,c as ce,d as q,f as J,l as le,m as ue,o as de,p as fe,s as pe,t as me,u as he}from"./MobileShareBridge-DmY_F56w.js";import{S as ge,_ as _e,b as ve,t as ye,w as be,x as xe}from"./MobileDetailNavigation-BB2hRMes.js";import{Ar as Se,Dr as Ce,Ea as we,F as Te,Fr as Ee,Ht as De,Ii as Oe,Ir as ke,Li as Ae,Lr as je,Mn as Me,Mr as Ne,Nr as Pe,Nt as Fe,Pi as Ie,Pr as Y,Ri as Le,Rr as Re,Sr as ze,Vt as Be,Wt as Ve,Xn as He,Xr as Ue,Xt as We,Yt as Ge,_i as Ke,a as qe,an as Je,ba as Ye,co as Xe,d as Ze,fn as Qe,gi as $e,kr as et,ln as tt,nn as nt,o as rt,pn as it,qn as at,sn as ot,t as st,tn as ct,un as lt,va as ut,wr as dt,zi as ft,zr as pt}from"./useMobileNavigationStore-CaaSJtom.js";import{i as mt,n as ht,r as gt}from"./useAssistantUIStore-Dt0l5AKe.js";import{n as _t}from"./useThemeSystem-8jhE4Zyk.js";import{n as X}from"./Icon-DewMAW7N.js";import{F as vt,I as yt,M as bt,N as xt,p as St}from"./gitApi-k8hCwYqu.js";import{$ as Ct,At as wt,B as Tt,Bt as Et,Dt,Et as Ot,H as kt,Kt as At,Mt as jt,Nt as Mt,Ot as Nt,Q as Pt,St as Ft,T as It,Tt as Lt,V as Rt,Vt as zt,X as Bt,Y as Vt,Z as Ht,dt as Ut,ft as Wt,i as Gt,jt as Kt,kt as qt,nt as Jt,o as Yt,r as Xt,s as Zt,t as Qt,tt as $t,w as en,xt as tn,z as nn,zt as rn}from"./useAppFontEffects-ADlv1hDy.js";import{E as an,T as on,a as sn,f as cn,i as ln,n as un,s as dn}from"./projectMeta-CRGyp6h1.js";import{t as fn}from"./input-02eTmC8w.js";import{r as pn}from"./tooltip-B3eYZnNS.js";import{A as mn,Dt as hn,E as gn,Ht as _n,I as vn,M as yn,P as bn,Z as xn,ct as Sn,j as Cn,lt as wn,mt as Tn,st as En}from"./speechSettingsQueries-GUD7hwQt.js";import{a as Dn,n as On,s as kn}from"./OverlayScrollbar-C24-p2ns.js";import{s as An,v as jn}from"./image-loading-BilWo6nu.js";import{n as Mn}from"./useRuntimeAPIs-Cx8S1HLz.js";import{T as Nn,a as Pn,c as Fn,d as In,f as Ln,i as Rn,l as zn,m as Bn,p as Vn,r as Hn,s as Un,u as Wn}from"./textarea-yLPH5NYp.js";import{D as Gn,O as Kn,r as qn,t as Jn}from"./sessionChangeSummary-DjTq4ZTb.js";import{b as Yn,h as Xn,k as Zn,v as Qn,y as $n}from"./insertionBoundaries-D2KDgrS0.js";import{D as er,M as tr,N as nr,a as rr,g as ir,i as ar,m as or,r as sr,s as cr,t as lr}from"./appThemeRegistry-DuusPsuR.js";import{i as ur,n as dr,o as fr}from"./MarkdownRenderer-DVE7BXyU.js";import{a as pr,o as mr}from"./url-DAyfGWPH.js";import{c as hr,d as gr,f as _r,l as vr}from"./markdown-worker-DFNZ3KJ_.js";import{n as yr}from"./useEffectiveDirectory-DSPgEsnp.js";import{u as br}from"./FadeInOnReveal-BssISEuf.js";import{a as xr,i as Sr,o as Cr,s as wr}from"./fileQueries-Dhgypzyl.js";import{t as Tr}from"./ImageLoadingPlaceholder-izjx-F-t.js";import{t as Er}from"./LoadingImage-CCj65iXL.js";import{F as Dr,K as Or,R as kr,W as Ar,d as jr,f as Mr,i as Nr,k as Pr,m as Fr,s as Ir,t as Lr,z as Rr}from"./MobileTabPageHeader-wyNSBINq.js";import{t as zr}from"./useFontPreferences-B4Cgu3bS.js";import{$ as Br,A as Vr,C as Hr,D as Ur,E as Wr,G as Gr,J as Kr,K as qr,M as Jr,O as Yr,R as Xr,S as Zr,T as Qr,U as $r,W as ei,a as ti,b as ni,c as ri,d as ii,et as ai,f as oi,g as si,h as ci,i as li,it as ui,j as di,k as fi,l as pi,m as mi,n as hi,ot as gi,p as _i,q as vi,r as yi,rt as bi,s as xi,st as Si,t as Ci,u as wi,v as Ti,w as Ei,x as Di,y as Oi}from"./runtimeEndpointReset-DLwrJ8o6.js";import{c as ki,l as Ai}from"./mcpQueries-DxtC14uJ.js";import{a as ji,c as Mi,d as Ni,f as Pi,i as Fi,l as Ii,m as Li,o as Ri,p as zi,r as Bi,s as Vi,t as Hi,u as Ui}from"./SettingsView-CpA3P8Hj.js";import{a as Wi,c as Gi,i as Ki,l as qi,o as Ji,r as Yi,s as Xi,t as Zi}from"./AssistantView-BAn7c1j0.js";import{a as Qi,i as $i}from"./sessionLookup-ai7V-fcR.js";import{a as ea,i as ta,n as na,r as ra,t as ia}from"./context-menu-BYq0LM7H.js";var Z=e(w(),1),aa=L(),oa=null,sa=!1,ca=new Promise(e=>{oa=e});function la(){sa||(sa=!0,oa?.())}var ua=6,da=e=>e.parentID??null,fa=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},pa=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),ma=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=pa(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return fa(n?n.path:e)},ha=()=>{let e=Se.getState().activeSessions,t=He.getState().index.session.unseenCount,n=Xe.getState().projects,r=0,i=[];for(let a of e){let e=da(a)!==null,o=(t[a.id]??0)>0&&!e;o&&(r+=1),e||i.push({id:a.id,title:a.title??``,updated:a.time?.updated??a.time?.created??0,unread:o,project:ma(Ce(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,ua).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},ga=`__OPENCHAMBER_WIDGET_SNAPSHOT__`,_a=()=>{typeof window>`u`||(window[ga]=()=>{try{return JSON.stringify(ha())}catch{return null}})},Q=I(),va=R(`OpenChamberScreenAwake`),ya=Promise.resolve(),ba=0;function xa(e){let t=ya.then(()=>va.setEnabled({enabled:e}));return ya=t.catch(()=>void 0),t}async function Sa(){if(z.isNativePlatform()&&z.isPluginAvailable(`OpenChamberScreenAwake`)){ba+=1;try{await xa(!0)}catch(e){throw--ba,e}let e=!1;return async()=>{e||(e=!0,--ba,ba===0&&await xa(!1))}}if(!navigator.wakeLock)throw Error(`Screen wake lock unavailable`);let e=await navigator.wakeLock.request(`screen`);return async()=>{e.released||await e.release()}}var $=E();function Ca({sessionId:e,directory:t,active:n,children:r}){let{t:i}=re(),a=tt(e,t),o=lt(e,t),[s,l]=te(`openchamber.auto-read`,!1),u=s===!0,[d,f]=(0,Z.useState)(0),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(document.visibilityState===`visible`),y=kt({enabled:p}),b=(0,Z.useRef)({enabled:!1,generation:0,floor:0,seen:new Set,observed:new Set,pending:[],playing:!1}),x=(0,Z.useRef)(!1),S=n&&!!e&&o,C=U(()=>{let e=b.current;e.enabled=!1,e.generation+=1,e.pending=[],e.playing=!1,e.seen.clear(),e.observed.clear(),x.current=!1,y.stop(),g(null),m(!1)}),w=U(()=>{let e=b.current;if(!e.enabled||e.playing||!n||document.visibilityState!==`visible`)return;let t=e.pending.shift();if(!t)return;e.playing=!0,g(t);let r=e.generation;y.play(t.text,t=>{if(r===e.generation){if(e.playing=!1,g(null),t){C(),H.error(i(`mobile.menu.autoReadFailed`));return}w()}})}),T=U(t=>{let n=b.current;!n.enabled||!S||t.sessionId!==e||!t.text.trim()||t.created<n.floor&&!n.observed.has(t.messageId)||n.seen.has(t.messageId)||(n.seen.add(t.messageId),n.pending.push(t),w())}),E=U((t,n)=>{b.current.enabled&&S&&t===e&&b.current.observed.add(n)}),D=U(()=>{if(u){l(!1),C();return}S&&(l(!0),y.unlock().catch(()=>{H.error(i(`mobile.menu.autoReadFailed`))}))}),O=U(()=>{let e=b.current;e.floor=Math.max(0,...a.map(e=>e.time.created)),e.seen=new Set(a.filter(e=>e.time.completed!=null||e.role!==`assistant`).map(e=>e.id)),e.enabled=!0,m(!0)});(0,Z.useEffect)(()=>(C(),u&&S&&O(),C),[e,t,u,S,d,O,C]),(0,Z.useEffect)(()=>c(()=>{C(),f(e=>e+1)}),[C]);let k=U(()=>{l(!1),C()});W(`pointerdown`,()=>{if(!b.current.enabled||x.current)return;x.current=!0;let e=b.current.generation;y.unlock().catch(()=>{e===b.current.generation&&(x.current=!1)})},document),W(`visibilitychange`,()=>{v(document.visibilityState===`visible`),document.visibilityState===`visible`?w():(b.current.generation+=1,b.current.playing=!1,b.current.pending=[],y.stop(),g(null))},document),(0,Z.useEffect)(()=>{if(!p||!n||!_)return;let e=!1,t;return Sa().then(n=>{e?n().catch(()=>void 0):t=n}).catch(()=>{e||H.warning(i(`mobile.menu.autoReadAwakeFailed`))}),()=>{e=!0,t?.().catch(()=>void 0)}},[p,n,_,e,t,d,i]);let A=(0,Z.useMemo)(()=>({enabled:u,available:S,toggle:D,rendered:T,streaming:E}),[u,S,D,T,E]),j=(0,Z.useMemo)(()=>p&&n&&_&&y.isPlaying&&h?.sessionId===e?{sessionId:e,messageId:h.messageId,stop:k}:null,[p,n,_,y.isPlaying,h,e,k]);return(0,$.jsx)(Tt.Provider,{value:A,children:(0,$.jsx)(Rt.Provider,{value:j,children:r})})}function wa(e){let t=(0,Q.c)(3),{children:n}=e,r=(0,Z.useContext)(Tt);if(!r)return null;let i;return t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var Ta={getPlatform:()=>z.getPlatform(),isPluginAvailable:e=>z.isPluginAvailable(e),openInSystemBrowser:e=>mr.open(e),openExternal:pr},Ea=async(e,t=Ta)=>{if(t.getPlatform()===`android`){if(!t.isPluginAvailable(`OpenChamberExternalBrowser`))return!1;try{return await t.openInSystemBrowser({url:e}),!0}catch{return!1}}return t.openExternal(e)},Da=`mobile-app-update-available`,Oa=`mobile-app-update-toast-dismissed-version`,ka=()=>{let e=(0,Q.c)(9),{t}=re(),n=Rr(Aa),r=Rr(ja),i=Rr(Ma),a=Rr(Na),o=Rr(Pa),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,e[0]=s):s=e[0];let c=Z.useRef(s),l,u;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(l=()=>{if(N()!==`android`||r!==`mobile`||!n||!i||!a||o){Y.dismiss(Da);return}F().getItem(Oa)!==i&&(c.current.has(i)||(c.current.add(i),Y.info(t(`mobileUpdate.toast.available.title`),{id:Da,description:t(`mobileUpdate.toast.available.description`,{version:i}),duration:1/0,icon:(0,$.jsx)(X,{name:`download`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.toast.actions.download`),onClick:()=>{Ea(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{F().setItem(Oa,i),Y.dismiss(Da)}}})))},u=[n,a,o,r,t,i],e[1]=n,e[2]=a,e[3]=o,e[4]=r,e[5]=t,e[6]=i,e[7]=l,e[8]=u):(l=e[7],u=e[8]),Z.useEffect(l,u),null};function Aa(e){return e.available}function ja(e){return e.runtimeType}function Ma(e){return e.info?.version}function Na(e){return e.info?.downloadUrl}function Pa(e){return e.info?.inAppApply===!0}var Fa=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Ia=e=>e.enabled&&!e.alreadyChecked,La=`mobile-ota-update-available`,Ra=`mobile-ota-update-toast-dismissed-version`,za=()=>{let e=(0,Q.c)(24),{t}=re(),[n,r]=Z.useState(!1),i=Z.useRef(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,e[0]=a):a=e[0];let o=Z.useRef(a),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=j(),e[1]=s):s=e[1];let c=s,l=Rr(Ba),u=Rr(Va),d=Rr(Ha),f=Rr(Ua),p=Rr(Wa),m=Rr(Ga),h=Rr(Ka),g=Rr(qa),_=Rr(Ja),v=d?.version,y=d?.inAppApply===!0,b,x;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{Ia({enabled:c,alreadyChecked:i.current})&&(i.current=!0,Rr.getState().checkForUpdates().catch(Ya))},x=[c],e[2]=b,e[3]=x):(b=e[2],x=e[3]),Z.useEffect(b,x);let S;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{r(!0)},e[4]=S):S=e[4];let C=U(S),w=U(Xa),T,E;if(e[5]!==l||e[6]!==w||e[7]!==y||e[8]!==C||e[9]!==u||e[10]!==t||e[11]!==v?(T=()=>{if(!Fa({enabled:c,runtimeType:u,available:l,inAppApply:y,version:v??``,dismissedVersion:F().getItem(Ra),seenVersions:o.current})||!v){(!l||!y||u!==`mobile`)&&Y.dismiss(La);return}o.current.add(v),Y.info(t(`mobileUpdate.ota.toast.available.title`),{id:La,description:t(`mobileUpdate.ota.toast.available.description`,{version:v}),duration:1/0,icon:(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.ota.toast.actions.update`),onClick:C},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{w(v)}}})},E=[l,y,c,C,w,u,t,v],e[5]=l,e[6]=w,e[7]=y,e[8]=C,e[9]=u,e[10]=t,e[11]=v,e[12]=T,e[13]=E):(T=e[12],E=e[13]),Z.useEffect(T,E),!c)return null;let D;return e[14]!==n||e[15]!==g||e[16]!==p||e[17]!==f||e[18]!==h||e[19]!==d||e[20]!==m||e[21]!==_||e[22]!==u?(D=(0,$.jsx)(kr,{open:n,onOpenChange:r,info:d,downloading:f,downloaded:p,progress:m,error:h,onDownload:g,onRestart:_,runtimeType:u}),e[14]=n,e[15]=g,e[16]=p,e[17]=f,e[18]=h,e[19]=d,e[20]=m,e[21]=_,e[22]=u,e[23]=D):D=e[23],D};function Ba(e){return e.available}function Va(e){return e.runtimeType}function Ha(e){return e.info}function Ua(e){return e.downloading}function Wa(e){return e.downloaded}function Ga(e){return e.progress}function Ka(e){return e.error}function qa(e){return e.downloadUpdate}function Ja(e){return e.restartToUpdate}function Ya(){}function Xa(e){F().setItem(Ra,e),Y.dismiss(La)}function Za(e){let t=(0,Q.c)(17),{children:n}=e,r=P(eo),i=P($a),a=Z.useRef(null),o=Z.useRef(null),s;t[0]===i?s=t[1]:(s=()=>i(!1),t[0]=i,t[1]=s);let c;t[2]!==r||t[3]!==s?(c={id:`mobile-global-search`,active:r,onBack:s,surfaceRef:a,underlayRef:o},t[2]=r,t[3]=s,t[4]=c):c=t[4],ar(c);let l,u;t[5]===r?(l=t[6],u=t[7]):(l=()=>{if(!r)return;let e=document.activeElement,t=Pt(`global-search-page`);return()=>{t(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},u=[r],t[5]=r,t[6]=l,t[7]=u),Z.useLayoutEffect(l,u);let d=r||void 0,f=r||void 0,p;t[8]!==n||t[9]!==d||t[10]!==f?(p=(0,$.jsx)(`div`,{ref:o,inert:d,"aria-hidden":f,className:`h-full min-h-0 w-full`,children:n}),t[8]=n,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===r?m=t[13]:(m=r?(0,$.jsx)(`div`,{ref:a,"data-mobile-search-page":`true`,className:`absolute inset-0 z-50 flex min-h-0 flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(ai,{presentation:`page`,onBack:Qa})}):null,t[12]=r,t[13]=m);let h;return t[14]!==p||t[15]!==m?(h=(0,$.jsxs)(`div`,{className:`relative isolate flex h-[100dvh] min-h-0 w-full flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:[p,m]}),t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function Qa(){sr.requestAnimatedBack(`root`)}function $a(e){return e.setCommandPaletteOpen}function eo(e){return e.isCommandPaletteOpen}var to=e=>{let t=(0,Q.c)(20),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({children:n,className:r,contentClassName:i,style:o,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=G(`oc-mobile-header relative z-30 shrink-0 border-b border-border/30 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80`,r),t[6]=r,t[7]=s);let c;t[8]===o?c=t[9]:(c={paddingTop:`var(--oc-safe-area-top, 0px)`,...o},t[8]=o,t[9]=c);let l;t[10]===i?l=t[11]:(l=G(`flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2`,i),t[10]=i,t[11]=l);let u;t[12]!==n||t[13]!==l?(u=(0,$.jsx)(`div`,{className:l,children:n}),t[12]=n,t[13]=l,t[14]=u):u=t[14];let d;return t[15]!==a||t[16]!==s||t[17]!==c||t[18]!==u?(d=(0,$.jsx)(`header`,{className:s,style:c,...a,children:u}),t[15]=a,t[16]=s,t[17]=c,t[18]=u,t[19]=d):d=t[19],d},no=`.oc-mobile-composer`,ro=`[data-btw-composer]`;function io(e,t){if(!e)return!1;let n=t;return!n||typeof n.closest!=`function`||!n.closest(ro)}function ao(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(no)}function oo(e){if(!e||typeof e!=`object`||ao(e))return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;return n===`TEXTAREA`||n===`INPUT`||t.isContentEditable===!0}function so(e){return ao(e??null)}function co(e,t){return e?`cache`:ao(t??null)?`open`:oo(t??null)?`field`:`ignore`}function lo(e,t){return!(t>0)||!(e>=0)?!1:t>e+24}function uo(e,t){return e>0?Math.max(0,Math.round(e/(Number.isFinite(t)&&t>0?t:1))):0}var fo=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),po=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},mo=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},ho=(e,t)=>t?`${e}\u0000staged`:e,go=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=re(),{git:o}=Mn(),s=fo(yr()??null),c=Qn(s||null),l=Yn(s||null),u=Xn(s||null),d=$n(e=>e.setActiveDirectory),f=$n(e=>e.ensureAll),p=$n(e=>e.fetchStatus),m=$n(e=>e.fetchBranches),h=$n(e=>e.prefetchDiffs),g=$n(e=>e.getDiff),_=$n(e=>e.setDiff),[v,y]=Z.useState(()=>t?{type:`diff`,path:t,staged:n,targetLine:r}:{type:`list`}),b=Z.useRef(null);Z.useEffect(()=>{t&&y(e=>e.type===`diff`&&e.path===t&&e.staged===n&&e.targetLine===r?e:{type:`diff`,path:t,staged:n,targetLine:r})},[t,n,r]);let[x,S]=Z.useState(null),[C,w]=Z.useState(null),[T,E]=Z.useState(``),[D,O]=Z.useState(new Set),[k,A]=Z.useState(!1),[j,M]=Z.useState(!1),[N,P]=Z.useState([]),[F,I]=Z.useState([]),[L,R]=Z.useState([]),[z,B]=Z.useState(null),[ee,V]=Z.useState({key:null,loading:!1,error:null,resolved:!1}),[H,te]=Z.useState(0),W=Z.useRef({key:null,generation:0}),[ne,ie]=Z.useState(!1),G=wi(c)&&!ne,K=Z.useMemo(()=>{let e=c?.files??[];if(G)return[];let t=new Map;for(let n of e)t.set(n.path,n);return Array.from(t.values()).sort((e,t)=>e.path.localeCompare(t.path))},[c?.files,G]),ae=Z.useMemo(()=>K.filter(po),[K]),oe=Z.useMemo(()=>K.filter(mo),[K]),{deferredStagedCount:se,deferredUnstagedCount:ce}=Z.useMemo(()=>{if(!G||!c)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of c.files??[])po(n)&&(e+=1),mo(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[G,c]),q=Z.useMemo(()=>{if(L.length>0)return L;let e=c?.tracking?.includes(`/`)?c.tracking.split(`/`)[0]:null;return e||z?[{name:e||`origin`,fetchUrl:z??``,pushUrl:z??``}]:[]},[z,L,c?.tracking]),J=Z.useMemo(()=>e=>!s||v.type!==`diff`?null:e.directories.get(s)?.diffCache.get(ho(v.path,v.staged))??null,[s,v]),le=$n(J),ue=Z.useMemo(()=>v.type===`diff`?K.find(e=>e.path===v.path)??null:null,[K,v]),de=v.type===`diff`&&s?`${s}\u0000${ho(v.path,v.staged)}`:null,fe=ee.key===de,pe=!!(de&&!le&&(!fe||ee.loading)),me=fe?ee.error:null,he=!!(ue||fe&&ee.resolved),ge=U(async(e,t=!0)=>{try{await Promise.all([p(e,o),m(e,o)])}catch(e){t&&Y.error(e instanceof Error?e.message:a(`gitView.toast.refreshRepositoryFailed`))}}),_e=U(async(e,t,n)=>{let r=()=>W.current.key===t&&W.current.generation===n;try{let[t,n]=await Promise.all([o.getRemotes(e).catch(()=>[]),o.getRemoteUrl?o.getRemoteUrl(e).catch(()=>null):Promise.resolve(null)]);if(!r())return;R(t),B(n)}catch{if(!r())return;R([]),B(null)}}),ve=U(e=>{if(e!==s)return{requestGeneration:null,promise:Promise.resolve()};let t=W.current.generation+1;return W.current={key:e,generation:t},{requestGeneration:t,promise:_e(e,e,t)}});Z.useEffect(()=>{s&&(d(s),f(s,o))},[s,f,o,d]),Z.useEffect(()=>{if(!s){W.current={key:null,generation:W.current.generation+1},R([]),B(null);return}let{requestGeneration:e,promise:t}=ve(s);return()=>{e!==null&&W.current.key===s&&W.current.generation===e&&(W.current={key:s,generation:e+1})}},[s,o,ve]),Z.useEffect(()=>{if(!s||K.length===0)return;let e=Array.from(new Set([...ae.map(e=>e.path),...F,...K.slice(0,20).map(e=>e.path)])).filter(Boolean);if(e.length===0)return;let t=window.setTimeout(()=>{h(s,o,e,{maxFiles:40})},120);return()=>window.clearTimeout(t)},[K,s,o,h,ae,F]),Z.useEffect(()=>{if(v.type!==`diff`){V({key:null,loading:!1,error:null,resolved:!1});return}let e=ho(v.path,v.staged);if(!s||!de){V({key:null,loading:!1,error:null,resolved:!1});return}if(g(s,e)){V(e=>({key:de,loading:!1,error:null,resolved:e.key===de&&e.resolved||!!ue}));return}let t=!1;return V({key:de,loading:!0,error:null,resolved:!1}),o.getGitFileDiff(s,{path:v.path,staged:v.staged||void 0}).then(n=>{t||(_(s,e,{original:n.original??``,modified:n.modified??``,isBinary:n.isBinary}),V(e=>e.key===de?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||V(t=>t.key===de?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[de,s,H,g,o,v,ue,_]);let ye=async(e,t)=>{if(!s)return;let n=s;S(e);try{let r=e=>{let t=`${e.name}/`,n=c?.tracking?.startsWith(t)?c.tracking.slice(t.length):void 0;return{remote:e.name,branch:n,rebase:!0}};if(e===`fetch`){if(!t)throw Error(a(`mobile.changes.noRemote`));await o.gitFetch(n,{remote:t.name}),Y.success(a(`gitView.toast.fetchedFromRemote`,{name:t.name}))}else if(e===`sync`){if(!t)throw Error(a(`mobile.changes.noRemote`));await o.gitFetch(n,{remote:t.name});let e=await o.getGitStatus(n);if((e.behind??0)>0){if((e.files?.length??0)>0){Y.error(a(`gitView.toast.commitOrStashBeforeSync`));return}await o.gitPull(n,r(t))}((await o.getGitStatus(n)).ahead??0)>0&&await o.gitPush(n),Y.success(a(`gitView.toast.alreadyUpToDate`))}await ge(n,!1),await ve(n).promise}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{S(null)}},be=U(async(e,t)=>{if(!s||e.length===0)return;let n=s;try{t===`stage`?e.length>1?await xt(n,e):await bt(n,e[0]):e.length>1?await yt(n,e):await vt(n,e[0]),await ge(n,!1)}catch(e){Y.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),xe=U((e,t=!1)=>{y({type:`diff`,path:e,staged:t,targetLine:null})}),Se=U(()=>v.type===`diff`&&(y({type:`list`}),!0));ar({id:`mobile-changes-diff`,active:v.type===`diff`&&!i,layer:`overlay`,onBack:Se,surfaceRef:b});let Ce=U(async e=>{if(!s)return;let t=s;O(t=>new Set(t).add(e));try{await o.revertGitFile(t,e),Y.success(a(`gitView.toast.revertedFile`,{path:e})),await ge(t,!1)}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(t=>{let n=new Set(t);return n.delete(e),n})}}),we=U(async e=>{if(!s||e.length===0||k)return;let t=s,n=Array.from(new Set(e));A(!0),O(new Set(n));try{await Promise.all(n.map(e=>o.revertGitFile(t,e))),await ge(t,!1),Y.success(n.length===1?a(`gitView.toast.revertedFilesSingle`,{count:n.length}):a(`gitView.toast.revertedFilesPlural`,{count:n.length}))}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(new Set),A(!1)}}),Te=U(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){P([]);return}E(e=>`${e.trim()}${e.trim()?`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-SMP_kNn6.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-fetch-QCWYlAx0.js","assets/runtime-auth-C8w0nlKy.js","assets/runtime-switch-3ad3yzM7.js","assets/vendor-base-ui-CdzJ6My_.js","assets/useUIStore-pl39iO82.js","assets/vendor-zustand-o69pgTEK.js","assets/vendor-react-BP2cRVqX.js","assets/vendor-pierre-diffs-DPBtNDJ5.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/vendor-reactuses-core-BpfIZ1tg.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-kJNzMb1G.js","assets/persistence-DUPZl7Oy.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/store-D5OeM4wB.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/rasterizePng-DCmIQQsI.js","assets/Icon-DewMAW7N.js","assets/useThemeSystem-8jhE4Zyk.js","assets/image-loading-BilWo6nu.js","assets/fileQueries-Dhgypzyl.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/useRuntimeAPIs-Cx8S1HLz.js","assets/relay-image-stream-qI2NTXbG.js","assets/image-loading-BzqNA0Jz.css","assets/appThemeRegistry-CiEDgyCl.js","assets/platform-z2erC6Bs.js","assets/vendor-opencode-client-MF2GBrFx.js","assets/useMobileNavigationStore-CC30Ki7r.js","assets/vendor-sonner-ZS8XIOVl.js","assets/useAssistantUIStore-Dt0l5AKe.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/MarkdownRenderer-dLZyr9W5.js","assets/markdownHeightCache-CAVQhVdd.js","assets/dualLimitLru-D8Sphgua.js","assets/markdown-worker-DFNZ3KJ_.js","assets/useEffectiveDirectory-CW0-F3UC.js","assets/markdownTheme-CV7_0QAL.js","assets/ImageLoadingPlaceholder-izjx-F-t.js","assets/useWorkerHighlightedLines-pIf0YNjH.js","assets/tooltip-B3eYZnNS.js","assets/vendor-tanstack-react-virtual-B_EO--9t.js","assets/ToolOutputDialog-DesCcdFD.css","assets/vendor-capacitor-app-B5H_XtmE.js","assets/vendor-capacitor-push-notifications-D5cqJIPw.js","assets/vendor-capacitor-status-bar-D9bcMr9Q.js","assets/vendor-capacitor-keyboard-BRVcFyc9.js","assets/gitApi-BOlE2j2L.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{S as t,_ as n,p as r,r as i,t as a,v as o,w as s}from"./runtime-auth-C8w0nlKy.js";import{c,f as l,i as u,l as d,r as f,s as p,t as m}from"./runtime-switch-3ad3yzM7.js";import{n as h}from"./runtime-fetch-QCWYlAx0.js";import{Mn as g,Nn as _,Rt as v,ot as y,r as b,t as x}from"./persistence-DUPZl7Oy.js";import{a as S,i as C}from"./vendor-zustand-o69pgTEK.js";import{it as w,nt as T,rt as E}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as D,Ir as O,Lr as k,Nt as A,n as j,r as M,t as N}from"./platform-z2erC6Bs.js";import{n as P,x as F}from"./useUIStore-pl39iO82.js";import{n as I,t as L}from"./vendor-react-BP2cRVqX.js";import{a as R,n as z,o as B}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{t as ee}from"./capgoAdapter-KNLHDj7G.js";/* empty css */import{a as V}from"./vendor-pierre-diffs-DPBtNDJ5.js";import{r as H}from"./vendor-sonner-ZS8XIOVl.js";import{c as te,n as U,r as W}from"./vendor-reactuses-core-BpfIZ1tg.js";import{d as ne,f as re,m as ie,r as G,t as K}from"./button-kJNzMb1G.js";import{i as ae,n as oe}from"./store-D5OeM4wB.js";import{a as se,c as ce,d as q,f as J,l as le,m as ue,o as de,p as fe,s as pe,t as me,u as he}from"./MobileShareBridge-CPPp_bPt.js";import{S as ge,_ as _e,b as ve,t as ye,w as be,x as xe}from"./MobileDetailNavigation-DO3ghMuq.js";import{Ar as Se,Dr as Ce,Ea as we,F as Te,Fr as Ee,Ht as De,Ii as Oe,Ir as ke,Li as Ae,Lr as je,Mn as Me,Mr as Ne,Nr as Pe,Nt as Fe,Pi as Ie,Pr as Y,Ri as Le,Rr as Re,Sr as ze,Vt as Be,Wt as Ve,Xn as He,Xr as Ue,Xt as We,Yt as Ge,_i as Ke,a as qe,an as Je,ba as Ye,co as Xe,d as Ze,fn as Qe,gi as $e,kr as et,ln as tt,nn as nt,o as rt,pn as it,qn as at,sn as ot,t as st,tn as ct,un as lt,va as ut,wr as dt,zi as ft,zr as pt}from"./useMobileNavigationStore-CC30Ki7r.js";import{i as mt,n as ht,r as gt}from"./useAssistantUIStore-Dt0l5AKe.js";import{n as _t}from"./useThemeSystem-8jhE4Zyk.js";import{n as X}from"./Icon-DewMAW7N.js";import{F as vt,I as yt,M as bt,N as xt,p as St}from"./gitApi-BOlE2j2L.js";import{$ as Ct,At as wt,B as Tt,Bt as Et,Dt,Et as Ot,H as kt,Kt as At,Mt as jt,Nt as Mt,Ot as Nt,Q as Pt,St as Ft,T as It,Tt as Lt,V as Rt,Vt as zt,X as Bt,Y as Vt,Z as Ht,dt as Ut,ft as Wt,i as Gt,jt as Kt,kt as qt,nt as Jt,o as Yt,r as Xt,s as Zt,t as Qt,tt as $t,w as en,xt as tn,z as nn,zt as rn}from"./useAppFontEffects-CHL4rtDx.js";import{E as an,T as on,a as sn,f as cn,i as ln,n as un,s as dn}from"./projectMeta-Cdx7RbLo.js";import{t as fn}from"./input-02eTmC8w.js";import{r as pn}from"./tooltip-B3eYZnNS.js";import{A as mn,Dt as hn,E as gn,Ht as _n,I as vn,M as yn,P as bn,Z as xn,ct as Sn,j as Cn,lt as wn,mt as Tn,st as En}from"./speechSettingsQueries-FzNqlyDv.js";import{a as Dn,n as On,s as kn}from"./OverlayScrollbar-C24-p2ns.js";import{s as An,v as jn}from"./image-loading-BilWo6nu.js";import{n as Mn}from"./useRuntimeAPIs-Cx8S1HLz.js";import{T as Nn,a as Pn,c as Fn,d as In,f as Ln,i as Rn,l as zn,m as Bn,p as Vn,r as Hn,s as Un,u as Wn}from"./textarea-yLPH5NYp.js";import{D as Gn,O as Kn,r as qn,t as Jn}from"./sessionChangeSummary-03r3sD9M.js";import{b as Yn,h as Xn,k as Zn,v as Qn,y as $n}from"./insertionBoundaries-BON5gcu9.js";import{D as er,M as tr,N as nr,a as rr,g as ir,i as ar,m as or,r as sr,s as cr,t as lr}from"./appThemeRegistry-CiEDgyCl.js";import{i as ur,n as dr,o as fr}from"./MarkdownRenderer-dLZyr9W5.js";import{a as pr,o as mr}from"./url-DAyfGWPH.js";import{c as hr,d as gr,f as _r,l as vr}from"./markdown-worker-DFNZ3KJ_.js";import{n as yr}from"./useEffectiveDirectory-CW0-F3UC.js";import{u as br}from"./FadeInOnReveal-BssISEuf.js";import{a as xr,i as Sr,o as Cr,s as wr}from"./fileQueries-Dhgypzyl.js";import{t as Tr}from"./ImageLoadingPlaceholder-izjx-F-t.js";import{t as Er}from"./LoadingImage-CCj65iXL.js";import{F as Dr,K as Or,R as kr,W as Ar,d as jr,f as Mr,i as Nr,k as Pr,m as Fr,s as Ir,t as Lr,z as Rr}from"./MobileTabPageHeader-D32a8Hs0.js";import{t as zr}from"./useFontPreferences-B4Cgu3bS.js";import{$ as Br,A as Vr,C as Hr,D as Ur,E as Wr,G as Gr,J as Kr,K as qr,M as Jr,O as Yr,R as Xr,S as Zr,T as Qr,U as $r,W as ei,a as ti,b as ni,c as ri,d as ii,et as ai,f as oi,g as si,h as ci,i as li,it as ui,j as di,k as fi,l as pi,m as mi,n as hi,ot as gi,p as _i,q as vi,r as yi,rt as bi,s as xi,st as Si,t as Ci,u as wi,v as Ti,w as Ei,x as Di,y as Oi}from"./runtimeEndpointReset-D4VD9Jn_.js";import{c as ki,l as Ai}from"./mcpQueries-BnBTQPOC.js";import{a as ji,c as Mi,d as Ni,f as Pi,i as Fi,l as Ii,m as Li,o as Ri,p as zi,r as Bi,s as Vi,t as Hi,u as Ui}from"./SettingsView-D--vyB_S.js";import{a as Wi,c as Gi,i as Ki,l as qi,o as Ji,r as Yi,s as Xi,t as Zi}from"./AssistantView-CNI0zQTE.js";import{a as Qi,i as $i}from"./sessionLookup--IwXu1NF.js";import{a as ea,i as ta,n as na,r as ra,t as ia}from"./context-menu-BYq0LM7H.js";var Z=e(w(),1),aa=L(),oa=null,sa=!1,ca=new Promise(e=>{oa=e});function la(){sa||(sa=!0,oa?.())}var ua=6,da=e=>e.parentID??null,fa=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},pa=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),ma=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=pa(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return fa(n?n.path:e)},ha=()=>{let e=Se.getState().activeSessions,t=He.getState().index.session.unseenCount,n=Xe.getState().projects,r=0,i=[];for(let a of e){let e=da(a)!==null,o=(t[a.id]??0)>0&&!e;o&&(r+=1),e||i.push({id:a.id,title:a.title??``,updated:a.time?.updated??a.time?.created??0,unread:o,project:ma(Ce(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,ua).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},ga=`__OPENCHAMBER_WIDGET_SNAPSHOT__`,_a=()=>{typeof window>`u`||(window[ga]=()=>{try{return JSON.stringify(ha())}catch{return null}})},Q=I(),va=R(`OpenChamberScreenAwake`),ya=Promise.resolve(),ba=0;function xa(e){let t=ya.then(()=>va.setEnabled({enabled:e}));return ya=t.catch(()=>void 0),t}async function Sa(){if(z.isNativePlatform()&&z.isPluginAvailable(`OpenChamberScreenAwake`)){ba+=1;try{await xa(!0)}catch(e){throw--ba,e}let e=!1;return async()=>{e||(e=!0,--ba,ba===0&&await xa(!1))}}if(!navigator.wakeLock)throw Error(`Screen wake lock unavailable`);let e=await navigator.wakeLock.request(`screen`);return async()=>{e.released||await e.release()}}var $=E();function Ca({sessionId:e,directory:t,active:n,children:r}){let{t:i}=re(),a=tt(e,t),o=lt(e,t),[s,l]=te(`openchamber.auto-read`,!1),u=s===!0,[d,f]=(0,Z.useState)(0),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(document.visibilityState===`visible`),y=kt({enabled:p}),b=(0,Z.useRef)({enabled:!1,generation:0,floor:0,seen:new Set,observed:new Set,pending:[],playing:!1}),x=(0,Z.useRef)(!1),S=n&&!!e&&o,C=U(()=>{let e=b.current;e.enabled=!1,e.generation+=1,e.pending=[],e.playing=!1,e.seen.clear(),e.observed.clear(),x.current=!1,y.stop(),g(null),m(!1)}),w=U(()=>{let e=b.current;if(!e.enabled||e.playing||!n||document.visibilityState!==`visible`)return;let t=e.pending.shift();if(!t)return;e.playing=!0,g(t);let r=e.generation;y.play(t.text,t=>{if(r===e.generation){if(e.playing=!1,g(null),t){C(),H.error(i(`mobile.menu.autoReadFailed`));return}w()}})}),T=U(t=>{let n=b.current;!n.enabled||!S||t.sessionId!==e||!t.text.trim()||t.created<n.floor&&!n.observed.has(t.messageId)||n.seen.has(t.messageId)||(n.seen.add(t.messageId),n.pending.push(t),w())}),E=U((t,n)=>{b.current.enabled&&S&&t===e&&b.current.observed.add(n)}),D=U(()=>{if(u){l(!1),C();return}S&&(l(!0),y.unlock().catch(()=>{H.error(i(`mobile.menu.autoReadFailed`))}))}),O=U(()=>{let e=b.current;e.floor=Math.max(0,...a.map(e=>e.time.created)),e.seen=new Set(a.filter(e=>e.time.completed!=null||e.role!==`assistant`).map(e=>e.id)),e.enabled=!0,m(!0)});(0,Z.useEffect)(()=>(C(),u&&S&&O(),C),[e,t,u,S,d,O,C]),(0,Z.useEffect)(()=>c(()=>{C(),f(e=>e+1)}),[C]);let k=U(()=>{l(!1),C()});W(`pointerdown`,()=>{if(!b.current.enabled||x.current)return;x.current=!0;let e=b.current.generation;y.unlock().catch(()=>{e===b.current.generation&&(x.current=!1)})},document),W(`visibilitychange`,()=>{v(document.visibilityState===`visible`),document.visibilityState===`visible`?w():(b.current.generation+=1,b.current.playing=!1,b.current.pending=[],y.stop(),g(null))},document),(0,Z.useEffect)(()=>{if(!p||!n||!_)return;let e=!1,t;return Sa().then(n=>{e?n().catch(()=>void 0):t=n}).catch(()=>{e||H.warning(i(`mobile.menu.autoReadAwakeFailed`))}),()=>{e=!0,t?.().catch(()=>void 0)}},[p,n,_,e,t,d,i]);let A=(0,Z.useMemo)(()=>({enabled:u,available:S,toggle:D,rendered:T,streaming:E}),[u,S,D,T,E]),j=(0,Z.useMemo)(()=>p&&n&&_&&y.isPlaying&&h?.sessionId===e?{sessionId:e,messageId:h.messageId,stop:k}:null,[p,n,_,y.isPlaying,h,e,k]);return(0,$.jsx)(Tt.Provider,{value:A,children:(0,$.jsx)(Rt.Provider,{value:j,children:r})})}function wa(e){let t=(0,Q.c)(3),{children:n}=e,r=(0,Z.useContext)(Tt);if(!r)return null;let i;return t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var Ta={getPlatform:()=>z.getPlatform(),isPluginAvailable:e=>z.isPluginAvailable(e),openInSystemBrowser:e=>mr.open(e),openExternal:pr},Ea=async(e,t=Ta)=>{if(t.getPlatform()===`android`){if(!t.isPluginAvailable(`OpenChamberExternalBrowser`))return!1;try{return await t.openInSystemBrowser({url:e}),!0}catch{return!1}}return t.openExternal(e)},Da=`mobile-app-update-available`,Oa=`mobile-app-update-toast-dismissed-version`,ka=()=>{let e=(0,Q.c)(9),{t}=re(),n=Rr(Aa),r=Rr(ja),i=Rr(Ma),a=Rr(Na),o=Rr(Pa),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,e[0]=s):s=e[0];let c=Z.useRef(s),l,u;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(l=()=>{if(N()!==`android`||r!==`mobile`||!n||!i||!a||o){Y.dismiss(Da);return}F().getItem(Oa)!==i&&(c.current.has(i)||(c.current.add(i),Y.info(t(`mobileUpdate.toast.available.title`),{id:Da,description:t(`mobileUpdate.toast.available.description`,{version:i}),duration:1/0,icon:(0,$.jsx)(X,{name:`download`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.toast.actions.download`),onClick:()=>{Ea(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{F().setItem(Oa,i),Y.dismiss(Da)}}})))},u=[n,a,o,r,t,i],e[1]=n,e[2]=a,e[3]=o,e[4]=r,e[5]=t,e[6]=i,e[7]=l,e[8]=u):(l=e[7],u=e[8]),Z.useEffect(l,u),null};function Aa(e){return e.available}function ja(e){return e.runtimeType}function Ma(e){return e.info?.version}function Na(e){return e.info?.downloadUrl}function Pa(e){return e.info?.inAppApply===!0}var Fa=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Ia=e=>e.enabled&&!e.alreadyChecked,La=`mobile-ota-update-available`,Ra=`mobile-ota-update-toast-dismissed-version`,za=()=>{let e=(0,Q.c)(24),{t}=re(),[n,r]=Z.useState(!1),i=Z.useRef(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,e[0]=a):a=e[0];let o=Z.useRef(a),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=j(),e[1]=s):s=e[1];let c=s,l=Rr(Ba),u=Rr(Va),d=Rr(Ha),f=Rr(Ua),p=Rr(Wa),m=Rr(Ga),h=Rr(Ka),g=Rr(qa),_=Rr(Ja),v=d?.version,y=d?.inAppApply===!0,b,x;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{Ia({enabled:c,alreadyChecked:i.current})&&(i.current=!0,Rr.getState().checkForUpdates().catch(Ya))},x=[c],e[2]=b,e[3]=x):(b=e[2],x=e[3]),Z.useEffect(b,x);let S;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{r(!0)},e[4]=S):S=e[4];let C=U(S),w=U(Xa),T,E;if(e[5]!==l||e[6]!==w||e[7]!==y||e[8]!==C||e[9]!==u||e[10]!==t||e[11]!==v?(T=()=>{if(!Fa({enabled:c,runtimeType:u,available:l,inAppApply:y,version:v??``,dismissedVersion:F().getItem(Ra),seenVersions:o.current})||!v){(!l||!y||u!==`mobile`)&&Y.dismiss(La);return}o.current.add(v),Y.info(t(`mobileUpdate.ota.toast.available.title`),{id:La,description:t(`mobileUpdate.ota.toast.available.description`,{version:v}),duration:1/0,icon:(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.ota.toast.actions.update`),onClick:C},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{w(v)}}})},E=[l,y,c,C,w,u,t,v],e[5]=l,e[6]=w,e[7]=y,e[8]=C,e[9]=u,e[10]=t,e[11]=v,e[12]=T,e[13]=E):(T=e[12],E=e[13]),Z.useEffect(T,E),!c)return null;let D;return e[14]!==n||e[15]!==g||e[16]!==p||e[17]!==f||e[18]!==h||e[19]!==d||e[20]!==m||e[21]!==_||e[22]!==u?(D=(0,$.jsx)(kr,{open:n,onOpenChange:r,info:d,downloading:f,downloaded:p,progress:m,error:h,onDownload:g,onRestart:_,runtimeType:u}),e[14]=n,e[15]=g,e[16]=p,e[17]=f,e[18]=h,e[19]=d,e[20]=m,e[21]=_,e[22]=u,e[23]=D):D=e[23],D};function Ba(e){return e.available}function Va(e){return e.runtimeType}function Ha(e){return e.info}function Ua(e){return e.downloading}function Wa(e){return e.downloaded}function Ga(e){return e.progress}function Ka(e){return e.error}function qa(e){return e.downloadUpdate}function Ja(e){return e.restartToUpdate}function Ya(){}function Xa(e){F().setItem(Ra,e),Y.dismiss(La)}function Za(e){let t=(0,Q.c)(17),{children:n}=e,r=P(eo),i=P($a),a=Z.useRef(null),o=Z.useRef(null),s;t[0]===i?s=t[1]:(s=()=>i(!1),t[0]=i,t[1]=s);let c;t[2]!==r||t[3]!==s?(c={id:`mobile-global-search`,active:r,onBack:s,surfaceRef:a,underlayRef:o},t[2]=r,t[3]=s,t[4]=c):c=t[4],ar(c);let l,u;t[5]===r?(l=t[6],u=t[7]):(l=()=>{if(!r)return;let e=document.activeElement,t=Pt(`global-search-page`);return()=>{t(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},u=[r],t[5]=r,t[6]=l,t[7]=u),Z.useLayoutEffect(l,u);let d=r||void 0,f=r||void 0,p;t[8]!==n||t[9]!==d||t[10]!==f?(p=(0,$.jsx)(`div`,{ref:o,inert:d,"aria-hidden":f,className:`h-full min-h-0 w-full`,children:n}),t[8]=n,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===r?m=t[13]:(m=r?(0,$.jsx)(`div`,{ref:a,"data-mobile-search-page":`true`,className:`absolute inset-0 z-50 flex min-h-0 flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(ai,{presentation:`page`,onBack:Qa})}):null,t[12]=r,t[13]=m);let h;return t[14]!==p||t[15]!==m?(h=(0,$.jsxs)(`div`,{className:`relative isolate flex h-[100dvh] min-h-0 w-full flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:[p,m]}),t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function Qa(){sr.requestAnimatedBack(`root`)}function $a(e){return e.setCommandPaletteOpen}function eo(e){return e.isCommandPaletteOpen}var to=e=>{let t=(0,Q.c)(20),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({children:n,className:r,contentClassName:i,style:o,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=G(`oc-mobile-header relative z-30 shrink-0 border-b border-border/30 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80`,r),t[6]=r,t[7]=s);let c;t[8]===o?c=t[9]:(c={paddingTop:`var(--oc-safe-area-top, 0px)`,...o},t[8]=o,t[9]=c);let l;t[10]===i?l=t[11]:(l=G(`flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2`,i),t[10]=i,t[11]=l);let u;t[12]!==n||t[13]!==l?(u=(0,$.jsx)(`div`,{className:l,children:n}),t[12]=n,t[13]=l,t[14]=u):u=t[14];let d;return t[15]!==a||t[16]!==s||t[17]!==c||t[18]!==u?(d=(0,$.jsx)(`header`,{className:s,style:c,...a,children:u}),t[15]=a,t[16]=s,t[17]=c,t[18]=u,t[19]=d):d=t[19],d},no=`.oc-mobile-composer`,ro=`[data-btw-composer]`;function io(e,t){if(!e)return!1;let n=t;return!n||typeof n.closest!=`function`||!n.closest(ro)}function ao(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(no)}function oo(e){if(!e||typeof e!=`object`||ao(e))return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;return n===`TEXTAREA`||n===`INPUT`||t.isContentEditable===!0}function so(e){return ao(e??null)}function co(e,t){return e?`cache`:ao(t??null)?`open`:oo(t??null)?`field`:`ignore`}function lo(e,t){return!(t>0)||!(e>=0)?!1:t>e+24}function uo(e,t){return e>0?Math.max(0,Math.round(e/(Number.isFinite(t)&&t>0?t:1))):0}var fo=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),po=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},mo=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},ho=(e,t)=>t?`${e}\u0000staged`:e,go=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=re(),{git:o}=Mn(),s=fo(yr()??null),c=Qn(s||null),l=Yn(s||null),u=Xn(s||null),d=$n(e=>e.setActiveDirectory),f=$n(e=>e.ensureAll),p=$n(e=>e.fetchStatus),m=$n(e=>e.fetchBranches),h=$n(e=>e.prefetchDiffs),g=$n(e=>e.getDiff),_=$n(e=>e.setDiff),[v,y]=Z.useState(()=>t?{type:`diff`,path:t,staged:n,targetLine:r}:{type:`list`}),b=Z.useRef(null);Z.useEffect(()=>{t&&y(e=>e.type===`diff`&&e.path===t&&e.staged===n&&e.targetLine===r?e:{type:`diff`,path:t,staged:n,targetLine:r})},[t,n,r]);let[x,S]=Z.useState(null),[C,w]=Z.useState(null),[T,E]=Z.useState(``),[D,O]=Z.useState(new Set),[k,A]=Z.useState(!1),[j,M]=Z.useState(!1),[N,P]=Z.useState([]),[F,I]=Z.useState([]),[L,R]=Z.useState([]),[z,B]=Z.useState(null),[ee,V]=Z.useState({key:null,loading:!1,error:null,resolved:!1}),[H,te]=Z.useState(0),W=Z.useRef({key:null,generation:0}),[ne,ie]=Z.useState(!1),G=wi(c)&&!ne,K=Z.useMemo(()=>{let e=c?.files??[];if(G)return[];let t=new Map;for(let n of e)t.set(n.path,n);return Array.from(t.values()).sort((e,t)=>e.path.localeCompare(t.path))},[c?.files,G]),ae=Z.useMemo(()=>K.filter(po),[K]),oe=Z.useMemo(()=>K.filter(mo),[K]),{deferredStagedCount:se,deferredUnstagedCount:ce}=Z.useMemo(()=>{if(!G||!c)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of c.files??[])po(n)&&(e+=1),mo(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[G,c]),q=Z.useMemo(()=>{if(L.length>0)return L;let e=c?.tracking?.includes(`/`)?c.tracking.split(`/`)[0]:null;return e||z?[{name:e||`origin`,fetchUrl:z??``,pushUrl:z??``}]:[]},[z,L,c?.tracking]),J=Z.useMemo(()=>e=>!s||v.type!==`diff`?null:e.directories.get(s)?.diffCache.get(ho(v.path,v.staged))??null,[s,v]),le=$n(J),ue=Z.useMemo(()=>v.type===`diff`?K.find(e=>e.path===v.path)??null:null,[K,v]),de=v.type===`diff`&&s?`${s}\u0000${ho(v.path,v.staged)}`:null,fe=ee.key===de,pe=!!(de&&!le&&(!fe||ee.loading)),me=fe?ee.error:null,he=!!(ue||fe&&ee.resolved),ge=U(async(e,t=!0)=>{try{await Promise.all([p(e,o),m(e,o)])}catch(e){t&&Y.error(e instanceof Error?e.message:a(`gitView.toast.refreshRepositoryFailed`))}}),_e=U(async(e,t,n)=>{let r=()=>W.current.key===t&&W.current.generation===n;try{let[t,n]=await Promise.all([o.getRemotes(e).catch(()=>[]),o.getRemoteUrl?o.getRemoteUrl(e).catch(()=>null):Promise.resolve(null)]);if(!r())return;R(t),B(n)}catch{if(!r())return;R([]),B(null)}}),ve=U(e=>{if(e!==s)return{requestGeneration:null,promise:Promise.resolve()};let t=W.current.generation+1;return W.current={key:e,generation:t},{requestGeneration:t,promise:_e(e,e,t)}});Z.useEffect(()=>{s&&(d(s),f(s,o))},[s,f,o,d]),Z.useEffect(()=>{if(!s){W.current={key:null,generation:W.current.generation+1},R([]),B(null);return}let{requestGeneration:e,promise:t}=ve(s);return()=>{e!==null&&W.current.key===s&&W.current.generation===e&&(W.current={key:s,generation:e+1})}},[s,o,ve]),Z.useEffect(()=>{if(!s||K.length===0)return;let e=Array.from(new Set([...ae.map(e=>e.path),...F,...K.slice(0,20).map(e=>e.path)])).filter(Boolean);if(e.length===0)return;let t=window.setTimeout(()=>{h(s,o,e,{maxFiles:40})},120);return()=>window.clearTimeout(t)},[K,s,o,h,ae,F]),Z.useEffect(()=>{if(v.type!==`diff`){V({key:null,loading:!1,error:null,resolved:!1});return}let e=ho(v.path,v.staged);if(!s||!de){V({key:null,loading:!1,error:null,resolved:!1});return}if(g(s,e)){V(e=>({key:de,loading:!1,error:null,resolved:e.key===de&&e.resolved||!!ue}));return}let t=!1;return V({key:de,loading:!0,error:null,resolved:!1}),o.getGitFileDiff(s,{path:v.path,staged:v.staged||void 0}).then(n=>{t||(_(s,e,{original:n.original??``,modified:n.modified??``,isBinary:n.isBinary}),V(e=>e.key===de?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||V(t=>t.key===de?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[de,s,H,g,o,v,ue,_]);let ye=async(e,t)=>{if(!s)return;let n=s;S(e);try{let r=e=>{let t=`${e.name}/`,n=c?.tracking?.startsWith(t)?c.tracking.slice(t.length):void 0;return{remote:e.name,branch:n,rebase:!0}};if(e===`fetch`){if(!t)throw Error(a(`mobile.changes.noRemote`));await o.gitFetch(n,{remote:t.name}),Y.success(a(`gitView.toast.fetchedFromRemote`,{name:t.name}))}else if(e===`sync`){if(!t)throw Error(a(`mobile.changes.noRemote`));await o.gitFetch(n,{remote:t.name});let e=await o.getGitStatus(n);if((e.behind??0)>0){if((e.files?.length??0)>0){Y.error(a(`gitView.toast.commitOrStashBeforeSync`));return}await o.gitPull(n,r(t))}((await o.getGitStatus(n)).ahead??0)>0&&await o.gitPush(n),Y.success(a(`gitView.toast.alreadyUpToDate`))}await ge(n,!1),await ve(n).promise}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{S(null)}},be=U(async(e,t)=>{if(!s||e.length===0)return;let n=s;try{t===`stage`?e.length>1?await xt(n,e):await bt(n,e[0]):e.length>1?await yt(n,e):await vt(n,e[0]),await ge(n,!1)}catch(e){Y.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),xe=U((e,t=!1)=>{y({type:`diff`,path:e,staged:t,targetLine:null})}),Se=U(()=>v.type===`diff`&&(y({type:`list`}),!0));ar({id:`mobile-changes-diff`,active:v.type===`diff`&&!i,layer:`overlay`,onBack:Se,surfaceRef:b});let Ce=U(async e=>{if(!s)return;let t=s;O(t=>new Set(t).add(e));try{await o.revertGitFile(t,e),Y.success(a(`gitView.toast.revertedFile`,{path:e})),await ge(t,!1)}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(t=>{let n=new Set(t);return n.delete(e),n})}}),we=U(async e=>{if(!s||e.length===0||k)return;let t=s,n=Array.from(new Set(e));A(!0),O(new Set(n));try{await Promise.all(n.map(e=>o.revertGitFile(t,e))),await ge(t,!1),Y.success(n.length===1?a(`gitView.toast.revertedFilesSingle`,{count:n.length}):a(`gitView.toast.revertedFilesPlural`,{count:n.length}))}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(new Set),A(!1)}}),Te=U(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){P([]);return}E(e=>`${e.trim()}${e.trim()?`
|
|
3
3
|
|
|
4
4
|
`:``}${t.join(`
|
|
5
|
-
`)}`.trim()),P([])}),Ee=U(async()=>{if(!s)return;let e=s,t=ae.map(e=>e.path).sort();if(t.length===0){Y.error(a(`gitView.toast.selectFileToDescribe`));return}M(!0);try{let{message:n}=await St(e,t);E(n.subject?.trim()??``),P(Array.isArray(n.highlights)?n.highlights:[])}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.generateCommitMessageFailed`))}finally{M(!1)}}),De=async(e={})=>{if(!s)return;let t=s;if(!T.trim()){Y.error(a(`gitView.toast.enterCommitMessage`));return}let n=ae.map(e=>e.path).sort();if(n.length===0){Y.error(a(`gitView.toast.selectFileToCommit`));return}w(e.pushAfter?`commitAndPush`:`commit`);try{if(await o.createGitCommit(t,T.trim(),{files:n}),Y.success(a(`gitView.toast.commitCreated`)),E(``),P([]),e.pushAfter){let e=c?.tracking?.split(`/`)[0],n=q.find(t=>t.name===e)??q[0];if(!n)throw Error(a(`mobile.changes.noRemote`));S(`sync`);let r=`${n.name}/`,i=c?.tracking?.startsWith(r)?c.tracking.slice(r.length):void 0;await o.gitFetch(t,{remote:n.name}),((await o.getGitStatus(t)).behind??0)>0&&await o.gitPull(t,{remote:n.name,branch:i,rebase:!0}),((await o.getGitStatus(t)).ahead??0)>0&&await o.gitPush(t),await ge(t,!1),await ve(t).promise}else await ge(t,!1)}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{w(null),e.pushAfter&&S(null)}},Oe=Z.useMemo(()=>{let e=[];return ae.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:ae,actionSymbol:`-`,actionAllLabel:a(`gitView.changes.unstageAllAria`),getActionLabel:e=>a(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void be([e],`unstage`),onActionAll:e=>void be(e,`unstage`),onViewDiff:e=>xe(e,!0),onRevertFile:Ce,showRevertActions:!1,accent:!0}),oe.length>0&&e.push({id:`unstaged`,title:a(`gitView.changes.title`),entries:oe,actionSymbol:`+`,actionAllLabel:a(`gitView.changes.stageAllAria`),getActionLabel:e=>a(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void be([e],`stage`),onActionAll:e=>void be(e,`stage`),onViewDiff:e=>xe(e,!1),onRevertFile:Ce}),e},[Ce,xe,be,ae,a,oe]),ke=t=>(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[i?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.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":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c?.current||s||``})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:t})]});return s?u&&l===null?ke((0,$.jsx)(_o,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):l===!1?ke((0,$.jsx)(_o,{icon:!0,message:a(`gitView.empty.notGitRepository`),description:a(`gitView.empty.notGitRepositoryDescription`)})):v.type===`diff`?(0,$.jsx)(`div`,{ref:b,className:`h-full min-h-0`,children:(0,$.jsx)(vo,{path:v.path,diff:le,fileExists:he,error:me,loading:pe,targetLine:v.targetLine,onBack:Se,onRetry:()=>te(e=>e+1),hideHeader:i})}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.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":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c?.current||s})]}),(0,$.jsx)(si,{syncAction:x,remotes:q,onSync:e=>void ye(`sync`,e),disabled:C!==null||u,aheadCount:c?.ahead??0,behindCount:c?.behind??0,trackingRemoteName:c?.tracking?.split(`/`)[0],hasUncommittedChanges:(c?.files?.length??0)>0})]}),G?(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(ii,{stagedCount:se,unstagedCount:ce,onLoad:()=>ie(!0)})}):K.length>0?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-4 pt-4`,children:(0,$.jsx)(oi,{groups:Oe,diffStats:c?.diffStats,revertingPaths:D,onRevertAll:we,isRevertingAll:k,headerBackgroundClassName:`bg-transparent`,onVisiblePathsChange:I})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-4 pt-3`,children:(0,$.jsx)(pi,{stagedCount:ae.length,commitMessage:T,onCommitMessageChange:E,generatedHighlights:N,onInsertHighlights:Te,onGenerateMessage:Ee,isGeneratingMessage:j,onCommit:()=>void De({pushAfter:!1}),onCommitAndPush:()=>void De({pushAfter:!0}),commitAction:C,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(_o,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):ke((0,$.jsx)(_o,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},_o=e=>{let t=(0,Q.c)(13),{message:n,description:r,loading:i,icon:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c;t[0]===o?c=t[1]:(c=o?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):null,t[0]=o,t[1]=c);let l;t[2]===s?l=t[3]:(l=s?(0,$.jsx)(X,{name:`git-branch`,className:`size-6 text-muted-foreground`}):null,t[2]=s,t[3]=l);let u;t[4]===n?u=t[5]:(u=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[4]=n,t[5]=u);let d;t[6]===r?d=t[7]:(d=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[6]=r,t[7]=d);let f;return t[8]!==c||t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[c,l,u,d]})}),t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f},vo=e=>{let t=(0,Q.c)(20),{path:n,diff:r,fileExists:i,error:a,loading:o,targetLine:s,onBack:c,onRetry:l,hideHeader:u}=e,d=u!==void 0&&u,{t:f}=re(),p;t[0]===n?p=t[1]:(p=vr(n)||`text`,t[0]=n,t[1]=p);let m=p,h;t[2]!==d||t[3]!==c||t[4]!==n||t[5]!==f?(h=d?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":f(`header.actions.backAria`),onClick:c,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-2`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:n})})]}),t[2]=d,t[3]=c,t[4]=n,t[5]=f,t[6]=h):h=t[6];let g;t[7]!==r||t[8]!==a||t[9]!==i||t[10]!==m||t[11]!==o||t[12]!==l||t[13]!==n||t[14]!==f||t[15]!==s?(g=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:a?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:f(`mobile.changes.diffDetail.loadFailed`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:a}),(0,$.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,onClick:l,children:f(`diffView.actions.retry`)})]})}):o?(0,$.jsx)(_o,{loading:!0,message:f(`diffView.state.loadingDiff`)}):i?r?r.isBinary?(0,$.jsx)(_o,{icon:!0,message:f(`diffView.binary.unavailable`)}):_r(n)?(0,$.jsx)(_o,{icon:!0,message:f(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(Hn,{className:`h-full overflow-y-auto overflow-x-hidden p-3 pwa-overlay-scroll`,"data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:(0,$.jsx)(Kr,{original:r.original,modified:r.modified,language:m,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:s,layout:`inline`})}):(0,$.jsx)(_o,{loading:!0,message:f(`diffView.state.loadingDiff`)}):(0,$.jsx)(_o,{icon:!0,message:f(`mobile.changes.diffDetail.missingTitle`),description:f(`mobile.changes.diffDetail.missingDescription`)})}),t[7]=r,t[8]=a,t[9]=i,t[10]=m,t[11]=o,t[12]=l,t[13]=n,t[14]=f,t[15]=s,t[16]=g):g=t[16];let _;return t[17]!==h||t[18]!==g?(_=(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19],_},yo=e(T(),1),bo=`data-oc-motion-id`,xo=`data-oc-sheet-overscroll`,So=`html, body { overscroll-behavior-y: none; }`,Co=[`input`,`textarea`,`select`,`[contenteditable]:not([contenteditable="false"])`,`[data-mobile-sheet-no-dismiss]`].join(`, `),wo=e=>e.closest(`[data-oc-motion-id]`)?.getAttribute(`data-oc-motion-id`)??null,To=e=>{try{let t=e.contentDocument;return t?t.scrollingElement??t.documentElement:null}catch{return null}},Eo=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)&&e<=1&&t>0,Do=(e,t,n)=>e?!0:Eo(t,n),Oo=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.Element},ko=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLElement},Ao=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLStyleElement},jo=(e,t)=>{if(typeof e.item==`function`){let n=e.item(t);if(n)return n}return e[t]??null},Mo=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=jo(e,n);if(r?.identifier===t)return r}return null},No=(e,t)=>{try{let n=e.defaultView?.getComputedStyle(t);if(!n)return!1;let r=n.overflowY;return(r===`auto`||r===`scroll`||r===`overlay`)&&t.scrollHeight>t.clientHeight+1}catch{return!1}},Po=(e,t)=>{let n=[],r=new Set,i=t=>{!t||r.has(t)||No(e,t)&&(r.add(t),n.push(t))},a=Oo(e,t)?t:null;for(;a&&(ko(e,a)&&i(a),a!==e.documentElement&&a!==e.body);)a=a.parentElement;let o=e.scrollingElement??e.documentElement;return ko(e,o)&&i(o),n},Fo=(e,t)=>{let n=Po(e,t);if(n.length===0){let t=(e.scrollingElement??e.documentElement)?.scrollTop??1/0;return Number.isFinite(t)&&t<=1}return n.every(e=>e.scrollTop<=1)},Io=e=>{let t=e.closest(`[${bo}]`);if(t instanceof HTMLElement){let e=t.getBoundingClientRect().height;if(Number.isFinite(e)&&e>0)return e}return window.innerHeight||1},Lo=e=>{let t=null,n=()=>{t?.(),t=null;let n=(()=>{try{return e.contentDocument}catch{return null}})();if(!n)return;let r=wo(e);if(!r)return;let i=null;if(!Ao(n,n.querySelector(`style[${xo}]`))){let e=n.createElement(`style`);e.setAttribute(xo,`true`),e.textContent=So,(n.head??n.documentElement).appendChild(e),i=e}let a=null,o=()=>{a?.active&&a.controller.finish(`cancel`),a=null},s=t=>{if(o(),t.touches.length!==1||(Oo(n,t.target)?t.target:null)?.closest(Co)||!Fo(n,t.target))return;let r=jo(t.touches,0);if(!r)return;let i=Io(e);a={touchId:r.identifier,startX:r.screenX,startY:r.screenY,lastY:r.screenY,lastTime:t.timeStamp,lastVelocityTime:t.timeStamp,velocity:0,motionDistance:i,commitDistance:Un(i,.1,40,64),active:!1,controller:null}},c=t=>{if(!a)return;if(t.touches.length!==1){o();return}let i=Mo(t.touches,a.touchId);if(!i){o();return}let s=i.screenY-a.startY,c=i.screenX-a.startX,l=t.timeStamp-a.lastTime;if(a.velocity=Wn(a.velocity,i.screenY-a.lastY,l,t.timeStamp-a.lastVelocityTime,1),i.screenY!==a.lastY&&l>0&&(a.lastVelocityTime=t.timeStamp),a.lastY=i.screenY,a.lastTime=t.timeStamp,!a.active){if(!Fo(n,t.target)){a=null;return}if(!Do(!1,To(e)?.scrollTop??0,s)){a=null;return}if(!In(`bottom`,c,s,8,1))return;let i=Bn(r);if(!i?.begin(`dismiss`)){a=null;return}a={...a,active:!0,controller:i}}let u=a;if(!u.active)return;t.preventDefault();let d=Fn(`bottom`,c,s);u.controller.update(zn(d,u.motionDistance))},l=e=>{if(!a)return;let t=a,n=Mo(e.changedTouches,t.touchId);if(a=null,!t.active)return;if(!n){t.controller.finish(`cancel`);return}let r=e.timeStamp-t.lastTime;t.velocity=Wn(t.velocity,n.screenY-t.lastY,r,e.timeStamp-t.lastVelocityTime,1),n.screenY!==t.lastY&&r>0&&(t.lastVelocityTime=e.timeStamp),t.lastY=n.screenY,t.lastTime=e.timeStamp;let i=n.screenY-t.startY,o=n.screenX-t.startX,s=Fn(`bottom`,o,i),c=Ln(s,t.velocity,t.commitDistance,.65,12);t.controller.finish(c?`commit`:`cancel`),e.preventDefault()},u=()=>o();n.addEventListener(`touchstart`,s,{capture:!0,passive:!0}),n.addEventListener(`touchmove`,c,{capture:!0,passive:!1}),n.addEventListener(`touchend`,l,{capture:!0,passive:!1}),n.addEventListener(`touchcancel`,u,{capture:!0,passive:!0}),t=()=>{o(),n.removeEventListener(`touchstart`,s,!0),n.removeEventListener(`touchmove`,c,!0),n.removeEventListener(`touchend`,l,!0),n.removeEventListener(`touchcancel`,u,!0);try{i?.remove()}catch{}i=null}};return e.addEventListener(`load`,n),n(),()=>{e.removeEventListener(`load`,n),t?.()}},Ro=fr(()=>B(()=>import(`./ToolOutputDialog-0MzoUb8d.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]))),zo=25e4,Bo=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Vo=e=>{let t=Bo(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},Ho=e=>{let t=Bo(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},Uo=(e,t)=>{let n=Bo(e),r=Bo(t);return!r||n===r?Vo(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},Wo=e=>{if(typeof e!=`number`||!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`],n=e/1024;for(let e of t){if(n<1024||e===t[t.length-1])return`${n.toFixed(n>=10?0:1)} ${e}`;n/=1024}return``},Go=e=>/\.(md|mdx|markdown)$/i.test(e),Ko=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return`/api/fs/serve${t.startsWith(`/`)?t:`/${t}`}`},qo=e=>l().authenticatedAsset(Ko(e)),Jo=e=>{let t=(0,Q.c)(148),{onClose:n,initialFilePath:r,directFilePreview:i,hideFileHeader:a}=e,o=r===void 0?null:r,s=i!==void 0&&i,c=a!==void 0&&a,{t:l}=re(),{files:u}=Mn(),d=yr()??null,f;t[0]===d?f=t[1]:(f=Bo(d),t[0]=d,t[1]=f);let p=f,m;t[2]!==o||t[3]!==p?(m=()=>{let e=Bo(o);return e?{type:`file`,path:e,returnDirectory:Ho(e)??p}:{type:`browser`,directory:p}},t[2]=o,t[3]=p,t[4]=m):m=t[4];let[h,g]=Z.useState(m),_=Z.useRef(null),[v,y]=Z.useState(``),b=P(ns),x=P(rs),S,C;t[5]===p?(S=t[6],C=t[7]):(S=()=>{p&&g(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:Ho(e.path)??p}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:p})},C=[p],t[5]=p,t[6]=S,t[7]=C),Z.useEffect(S,C);let w,T;t[8]!==b||t[9]!==p||t[10]!==x?(T=()=>{if(!b||!p)return;let e=Bo(b);if(!e){x(null);return}y(``),g({type:`file`,path:e,returnDirectory:Ho(e)??p}),x(null)},w=[b,p,x],t[8]=b,t[9]=p,t[10]=x,t[11]=w,t[12]=T):(w=t[11],T=t[12]),Z.useEffect(T,w);let E=h.type===`browser`?h.directory:h.returnDirectory,D=h.type===`browser`?h.directory:``,O=h.type===`file`?h.path:``,[k,A]=Z.useState(`preview`),j;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{A(`preview`)},t[13]=j):j=t[13];let M;t[14]===O?M=t[15]:(M=[O],t[14]=O,t[15]=M),Z.useEffect(j,M);let N=Zn(v,250),F;t[16]===v?F=t[17]:(F=v.trim(),t[16]=v,t[17]=F);let I=F,L;t[18]===N?L=t[19]:(L=N.trim(),t[18]=N,t[19]=L);let R=L,z;t[20]!==D||t[21]!==p?(z={scopeDirectory:p,directory:D},t[20]=D,t[21]=p,t[22]=z):z=t[22];let B=!!D,ee;t[23]===B?ee=t[24]:(ee={enabled:B,refetchOnMount:`always`},t[23]=B,t[24]=ee);let V=xr(z,ee),H;t[25]!==D||t[26]!==R?(H={directory:D,query:R,maxResults:40},t[25]=D,t[26]=R,t[27]=H):H=t[27];let te=!!(D&&R),W;t[28]===te?W=t[29]:(W={enabled:te},t[28]=te,t[29]=W);let ie=Cr(H,W),K;t[30]!==O||t[31]!==u||t[32]!==k?(K=O&&u.readFile&&(!gr(O)||k===`source`)&&(!_r(O)||O.toLowerCase().endsWith(`.svg`)),t[30]=O,t[31]=u,t[32]=k,t[33]=K):K=t[33];let ae=!!K,oe;t[34]!==O||t[35]!==p?(oe={scopeDirectory:p,path:O},t[34]=O,t[35]=p,t[36]=oe):oe=t[36];let se;t[37]===ae?se=t[38]:(se={enabled:ae},t[37]=ae,t[38]=se);let ce=Sr(oe,se),q;t[39]!==O||t[40]!==p?(q={scopeDirectory:p,path:O},t[39]=O,t[40]=p,t[41]=q):q=t[41];let J;t[42]===ae?J=t[43]:(J={enabled:ae},t[42]=ae,t[43]=J),wr(q,J);let le=V.data?.entries.slice().sort(is)??[],ue;t[44]!==V.error||t[45]!==l?(ue=V.error?V.error instanceof Error?V.error.message:l(`mobile.files.error.listFailed`):null,t[44]=V.error,t[45]=l,t[46]=ue):ue=t[46];let de=ue,fe=V.isFetching,pe;t[47]===ie.data?pe=t[48]:(pe=ie.data??[],t[47]=ie.data,t[48]=pe);let me=pe,he=!!(I&&R&&v===N&&ie.isFetching),ge;t[49]!==ce.data||t[50]!==l?(ge=ce.data&&ce.data.length>zo?`${ce.data.slice(0,zo)}\n\n${l(`mobile.files.file.truncated`)}`:ce.data??``,t[49]=ce.data,t[50]=l,t[51]=ge):ge=t[51];let _e=ge,ve;t[52]!==O||t[53]!==ce.error||t[54]!==u||t[55]!==l?(ve=O&&!u.readFile?l(`mobile.files.error.readUnavailable`):ce.error?ce.error instanceof Error?ce.error.message:l(`filesView.error.readFileFailed`):null,t[52]=O,t[53]=ce.error,t[54]=u,t[55]=l,t[56]=ve):ve=t[56];let ye=ve,be=ae&&ce.isFetching,xe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(xe=e=>{y(``),g({type:`browser`,directory:e})},t[57]=xe):xe=t[57];let Se=xe,Ce;t[58]!==E||t[59]!==p?(Ce=e=>{g({type:`file`,path:e,returnDirectory:E||p})},t[58]=E,t[59]=p,t[60]=Ce):Ce=t[60];let we=Ce,Te;t[61]!==s||t[62]!==n||t[63]!==h.returnDirectory||t[64]!==h.type?(Te=()=>h.type===`file`?s?(n?.(),!0):(g({type:`browser`,directory:h.returnDirectory}),!0):!1,t[61]=s,t[62]=n,t[63]=h.returnDirectory,t[64]=h.type,t[65]=Te):Te=t[65];let Ee=U(Te),De=h.type===`file`,Oe;t[66]!==Ee||t[67]!==De?(Oe={id:`mobile-files-detail`,active:De,layer:`overlay`,onBack:Ee,surfaceRef:_},t[66]=Ee,t[67]=De,t[68]=Oe):Oe=t[68],ar(Oe);let ke;t[69]===l?ke=t[70]:(ke=async e=>{(await ne(e)).ok||Y.error(l(`mobile.files.toast.copyFailed`))},t[69]=l,t[70]=ke);let Ae=ke,je;t[71]!==_e||t[72]!==l?(je=async()=>{(await ne(_e)).ok?Y.success(l(`mobile.files.toast.contentCopied`)):Y.error(l(`mobile.files.toast.copyFailed`))},t[71]=_e,t[72]=l,t[73]=je):je=t[73];let Me=je;if(!p){let e;t[74]===l?e=t[75]:(e=l(`mobile.files.empty.noDirectory`),t[74]=l,t[75]=e);let n;return t[76]===e?n=t[77]:(n=(0,$.jsx)(ts,{message:e}),t[76]=e,t[77]=n),n}if(h.type===`file`){let e;t[78]!==Ae||t[79]!==h.path?(e=()=>void Ae(h.path),t[78]=Ae,t[79]=h.path,t[80]=e):e=t[80];let n;t[81]===Me?n=t[82]:(n=()=>void Me(),t[81]=Me,t[82]=n);let r;return t[83]!==Ee||t[84]!==_e||t[85]!==ye||t[86]!==c||t[87]!==k||t[88]!==be||t[89]!==h.path||t[90]!==e||t[91]!==n?(r=(0,$.jsx)(`div`,{ref:_,className:`flex h-full min-h-0 flex-col`,children:(0,$.jsx)(Qo,{path:h.path,content:_e,error:ye,isLoading:be,hideHeader:c,htmlViewMode:k,onHtmlViewModeChange:A,onBack:Ee,onCopyPath:e,onCopyContent:n})}),t[83]=Ee,t[84]=_e,t[85]=ye,t[86]=c,t[87]=k,t[88]=be,t[89]=h.path,t[90]=e,t[91]=n,t[92]=r):r=t[92],r}let Ne;t[93]!==p||t[94]!==h.directory||t[95]!==l?(Ne=h.directory===p?l(`mobile.files.rootDirectory`):Vo(h.directory),t[93]=p,t[94]=h.directory,t[95]=l,t[96]=Ne):Ne=t[96];let Pe=Ne,Fe;t[97]!==v||t[98]!==me?(Fe=v.trim()?me:[],t[97]=v,t[98]=me,t[99]=Fe):Fe=t[99];let Ie=Fe,Le,Re,ze,Be;if(t[100]!==n||t[101]!==v||t[102]!==p||t[103]!==h.directory||t[104]!==l){let e=Ho(h.directory),r=h.directory!==p&&e!==null&&(e===p||e.startsWith(`${p}/`)),i=r&&!v.trim(),a=r?e:null;Be=`flex h-full flex-col overflow-hidden bg-background text-foreground`,Le=`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[109]!==n||t[110]!==l?(Re=n?(0,$.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":l(`mobile.surface.closeAria`),onClick:n,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,t[109]=n,t[110]=l,t[111]=Re):Re=t[111],ze=i&&a?(0,$.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":l(`mobile.files.backToParentAria`,{name:Vo(a)}),onClick:()=>Se(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}):null,t[100]=n,t[101]=v,t[102]=p,t[103]=h.directory,t[104]=l,t[105]=Le,t[106]=Re,t[107]=ze,t[108]=Be}else Le=t[105],Re=t[106],ze=t[107],Be=t[108];let Ve;t[112]===Pe?Ve=t[113]:(Ve=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:Pe})}),t[112]=Pe,t[113]=Ve);let He;t[114]===l?He=t[115]:(He=l(`mobile.files.refreshAria`),t[114]=l,t[115]=He);let Ue;t[116]===V?Ue=t[117]:(Ue=()=>void V.refetch(),t[116]=V,t[117]=Ue);let We;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(We={touchAction:`manipulation`},t[118]=We):We=t[118];let Ge=fe&&`animate-spin`,Ke;t[119]===Ge?Ke=t[120]:(Ke=G(`size-5`,Ge),t[119]=Ge,t[120]=Ke);let qe;t[121]===Ke?qe=t[122]:(qe=(0,$.jsx)(X,{name:`refresh`,className:Ke}),t[121]=Ke,t[122]=qe);let Je;t[123]!==He||t[124]!==Ue||t[125]!==qe?(Je=(0,$.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":He,onClick:Ue,style:We,children:qe}),t[123]=He,t[124]=Ue,t[125]=qe,t[126]=Je):Je=t[126];let Ye;t[127]!==Le||t[128]!==Re||t[129]!==ze||t[130]!==Ve||t[131]!==Je?(Ye=(0,$.jsxs)(`header`,{className:Le,children:[Re,ze,Ve,Je]}),t[127]=Le,t[128]=Re,t[129]=ze,t[130]=Ve,t[131]=Je,t[132]=Ye):Ye=t[132];let Xe;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[133]=Xe):Xe=t[133];let Ze;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=e=>y(e.target.value),t[134]=Ze):Ze=t[134];let Qe;t[135]===l?Qe=t[136]:(Qe=l(`mobile.files.search.placeholder`),t[135]=l,t[136]=Qe);let $e;t[137]!==v||t[138]!==Qe?($e=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[Xe,(0,$.jsx)(fn,{type:`text`,inputMode:`search`,value:v,onChange:Ze,placeholder:Qe,className:`h-11 pl-9`})]})}),t[137]=v,t[138]=Qe,t[139]=$e):$e=t[139];let et=Hn,tt=de?(0,$.jsx)(ts,{message:de}):v.trim()?(0,$.jsx)(Xo,{results:Ie,isSearching:he,onOpenFile:we}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[le.length===0&&!fe?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:l(`mobile.files.empty.directory`)}):null,le.map(e=>(0,$.jsx)(Yo,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:Wo(e.size),onClick:()=>e.isDirectory?Se(e.path):we(e.path)},e.path))]}),nt;t[140]!==et||t[141]!==tt?(nt=(0,$.jsx)(et,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:tt}),t[140]=et,t[141]=tt,t[142]=nt):nt=t[142];let rt;return t[143]!==Be||t[144]!==Ye||t[145]!==$e||t[146]!==nt?(rt=(0,$.jsxs)(`div`,{className:Be,children:[Ye,$e,nt]}),t[143]=Be,t[144]=Ye,t[145]=$e,t[146]=nt,t[147]=rt):rt=t[147],rt},Yo=e=>{let t=(0,Q.c)(16),{name:n,path:r,directory:i,meta:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==r?(c=i?(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(Ft,{filePath:r,className:`size-5 shrink-0`}),t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:n}),t[4]=n,t[5]=l);let u;t[6]===a?u=t[7]:(u=a?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:a}):null,t[6]=a,t[7]=u);let d;t[8]===i?d=t[9]:(d=i?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null,t[8]=i,t[9]=d);let f;return t[10]!==o||t[11]!==c||t[12]!==l||t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-14 w-full items-center gap-3 border-b border-border/30 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:o,style:s,children:[c,l,u,d]}),t[10]=o,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f):f=t[15],f},Xo=e=>{let t=(0,Q.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=re(),o=Bo(yr()??null);if(r){let e;t[0]===a?e=t[1]:(e=a(`common.loading`),t[0]=a,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,$.jsx)(ts,{loading:!0,message:e}),t[2]=e,t[3]=n),n}if(n.length===0){let e;t[4]===a?e=t[5]:(e=a(`mobile.files.search.empty`),t[4]=a,t[5]=e);let n;return t[6]===e?n=t[7]:(n=(0,$.jsx)(ts,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(Yo,{name:Vo(e.path),path:e.path,directory:!1,meta:Uo(e.path,o),onClick:()=>i(e.path)},e.path)),c;return t[8]===s?c=t[9]:(c=(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:s}),t[8]=s,t[9]=c),c},Zo=e=>{let t=(0,Q.c)(24),{path:n,htmlViewMode:r,htmlFullscreen:i,onToggleHtmlViewMode:a,onEnterHtmlFullscreen:o,onCopyPath:s,onCopyContent:c}=e,{t:l}=re(),u;t[0]===n?u=t[1]:(u=gr(n),t[0]=n,t[1]=u);let d=u,f;t[2]!==d||t[3]!==i||t[4]!==r||t[5]!==o||t[6]!==a||t[7]!==l?(f=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:a,"aria-label":l(r===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:r===`preview`?`file-code`:`eye`,className:`size-4`})}),i?null:(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:o,"aria-label":l(`mobile.files.html.fullscreenAria`),children:(0,$.jsx)(X,{name:`fullscreen`,className:`size-4`})})]}):null,t[2]=d,t[3]=i,t[4]=r,t[5]=o,t[6]=a,t[7]=l,t[8]=f):f=t[8];let p;t[9]!==d||t[10]!==c||t[11]!==n||t[12]!==l?(p=!_r(n)&&!d?(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:c,"aria-label":l(`mobile.files.copyContentAria`),children:(0,$.jsx)(X,{name:`file-copy`,className:`size-4`})}):null,t[9]=d,t[10]=c,t[11]=n,t[12]=l,t[13]=p):p=t[13];let m;t[14]===l?m=t[15]:(m=l(`mobile.files.copyPathAria`),t[14]=l,t[15]=m);let h;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(X,{name:`clipboard`,className:`size-4`}),t[16]=h):h=t[16];let g;t[17]!==s||t[18]!==m?(g=(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:s,"aria-label":m,children:h}),t[17]=s,t[18]=m,t[19]=g):g=t[19];let _;return t[20]!==f||t[21]!==p||t[22]!==g?(_=(0,$.jsxs)($.Fragment,{children:[f,p,g]}),t[20]=f,t[21]=p,t[22]=g,t[23]=_):_=t[23],_},Qo=e=>{let t=(0,Q.c)(94),{path:n,content:r,error:i,isLoading:a,hideHeader:o,htmlViewMode:s,onHtmlViewModeChange:c,onBack:l,onCopyPath:u,onCopyContent:d}=e,f=o!==void 0&&o,{t:p}=re(),m=Z.useRef(null),h=_r(n)&&!n.toLowerCase().endsWith(`.svg`)?n:``,g;t[0]===n?g=t[1]:(g=Ho(n)??``,t[0]=n,t[1]=g);let _=An(h,g,`preview`),[v,y]=Z.useState(``),b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b={open:!1,title:``,content:``},t[2]=b):b=t[2];let[x,S]=Z.useState(b),C=_.source,w;t[3]===n?w=t[4]:(w=Vo(n),t[3]=n,t[4]=w);let T=w,E;t[5]!==r||t[6]!==n?(E=_r(n)?`data:${hr(n)};utf8,${encodeURIComponent(r)}`:``,t[5]=r,t[6]=n,t[7]=E):E=t[7];let D=E,O;t[8]!==r||t[9]!==D||t[10]!==C||t[11]!==n?(O=C||(_r(n)&&r?D:``),t[8]=r,t[9]=D,t[10]=C,t[11]=n,t[12]=O):O=t[12];let k=O,A;t[13]!==i||t[14]!==v||t[15]!==_.error||t[16]!==k||t[17]!==p?(A=i??_.error??(k&&v===k?p(`filesView.error.readFileFailed`):null),t[13]=i,t[14]=v,t[15]=_.error,t[16]=k,t[17]=p,t[18]=A):A=t[18];let j=A,M;t[19]===k?M=t[20]:(M=()=>y(k),t[19]=k,t[20]=M);let N=U(M),P;t[21]!==T||t[22]!==h||t[23]!==n||t[24]!==k?(P=e=>{let t=h||k;t&&S({open:!0,title:T,content:``,previewSource:e.currentTarget.querySelector(`img`)??void 0,metadata:{tool:`image-preview`,filename:T,mime:hr(n)},image:{url:t,mimeType:hr(n),filename:T}})},t[21]=T,t[22]=h,t[23]=n,t[24]=k,t[25]=P):P=t[25];let F=U(P),I;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>{S(t=>t.open===e?t:{...t,open:e})},t[26]=I):I=t[26];let L=U(I),R;t[27]===n?R=t[28]:(R=gr(n),t[27]=n,t[28]=R);let z=R,[B,ee]=Z.useState(!1),V=Z.useRef(null),H;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{ee(!1)},t[29]=H):H=t[29];let te;t[30]===n?te=t[31]:(te=[n],t[30]=n,t[31]=te),Z.useEffect(H,te);let W;t[32]!==s||t[33]!==c?(W=()=>{c(s===`preview`?`source`:`preview`)},t[32]=s,t[33]=c,t[34]=W):W=t[34];let ne=U(W),ie;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>{ee(!0)},t[35]=ie):ie=t[35];let G=U(ie),ae;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>(ee(!1),!0),t[36]=ae):ae=t[36];let oe=U(ae),se=z&&B,ce;t[37]!==oe||t[38]!==se?(ce={id:`mobile-html-fullscreen`,active:se,layer:`overlay`,onBack:oe,surfaceRef:V},t[37]=oe,t[38]=se,t[39]=ce):ce=t[39],ar(ce);let q;t[40]!==G||t[41]!==B||t[42]!==s||t[43]!==d||t[44]!==u||t[45]!==n||t[46]!==ne?(q=(0,$.jsx)(Zo,{path:n,htmlViewMode:s,htmlFullscreen:B,onToggleHtmlViewMode:ne,onEnterHtmlFullscreen:G,onCopyPath:u,onCopyContent:d}),t[40]=G,t[41]=B,t[42]=s,t[43]=d,t[44]=u,t[45]=n,t[46]=ne,t[47]=q):q=t[47];let J=q,le;t[48]!==r||t[49]!==i||t[50]!==s||t[51]!==a||t[52]!==n||t[53]!==p?(le=s===`source`?a?(0,$.jsx)(ts,{loading:!0,message:p(`filesView.state.loading`)}):i?(0,$.jsx)(ts,{message:i}):(0,$.jsx)(es,{path:n,content:r}):(0,$.jsx)($o,{path:n}),t[48]=r,t[49]=i,t[50]=s,t[51]=a,t[52]=n,t[53]=p,t[54]=le):le=t[54];let ue=le,de;t[55]!==oe||t[56]!==z||t[57]!==ue||t[58]!==B||t[59]!==s||t[60]!==T||t[61]!==p||t[62]!==ne?(de=z?(0,$.jsxs)(`div`,{ref:V,"data-mobile-html-preview":s===`preview`&&!B?`true`:void 0,"data-mobile-html-fullscreen":s===`preview`&&B?`true`:void 0,className:B?`fixed inset-0 z-[80] flex flex-col bg-background text-foreground`:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[B?(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-border/50 px-3 pb-2 pt-[max(0.5rem,env(safe-area-inset-top))]`,children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:oe,"aria-label":p(`mobile.files.html.exitFullscreenAria`),className:`shrink-0 text-muted-foreground`,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-header text-foreground`,children:T}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:ne,"aria-label":p(s===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:s===`preview`?`file-code`:`eye`,className:`size-4`})})]}):null,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden bg-background`,children:ue})]}):null,t[55]=oe,t[56]=z,t[57]=ue,t[58]=B,t[59]=s,t[60]=T,t[61]=p,t[62]=ne,t[63]=de):de=t[63];let fe=de,pe;t[64]!==J||t[65]!==f||t[66]!==T||t[67]!==l||t[68]!==p?(pe=f?(0,$.jsx)(Pn,{children:J}):(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":p(`header.actions.backAria`),onClick:l,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:T})}),J]}),t[64]=J,t[65]=f,t[66]=T,t[67]=l,t[68]=p,t[69]=pe):pe=t[69];let me;t[70]!==r||t[71]!==N||t[72]!==z||t[73]!==B||t[74]!==fe||t[75]!==j||t[76]!==T||t[77]!==_.loading||t[78]!==a||t[79]!==F||t[80]!==n||t[81]!==k||t[82]!==p?(me=z?B&&typeof document<`u`?(0,yo.createPortal)(fe,document.body):fe:a||_.loading?_r(n)?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-4`,children:(0,$.jsx)(Tr,{className:`aspect-square w-64 max-w-full rounded-lg`})}):(0,$.jsx)(ts,{loading:!0,message:p(`filesView.state.loading`)}):j?(0,$.jsx)(ts,{message:j}):_r(n)&&k?(0,$.jsx)(Hn,{className:`h-full overflow-auto p-4`,children:(0,$.jsx)(`button`,{type:`button`,className:`mx-auto block max-h-full max-w-full cursor-zoom-in rounded-lg border-0 bg-transparent p-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:F,"aria-label":T,children:(0,$.jsx)(Er,{src:k,alt:T,className:`mx-auto max-h-full max-w-full rounded-lg object-contain`,draggable:!1,onError:N})})}):(0,$.jsx)(es,{path:n,content:r}),t[70]=r,t[71]=N,t[72]=z,t[73]=B,t[74]=fe,t[75]=j,t[76]=T,t[77]=_.loading,t[78]=a,t[79]=F,t[80]=n,t[81]=k,t[82]=p,t[83]=me):me=t[83];let he;t[84]===me?he=t[85]:(he=(0,$.jsx)(`div`,{ref:m,className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:me}),t[84]=me,t[85]=he);let ge;t[86]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(nn,{containerRef:m}),t[86]=ge):ge=t[86];let _e;t[87]!==L||t[88]!==x?(_e=x.open?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ro,{popup:x,onOpenChange:L,isMobile:!0})}):null,t[87]=L,t[88]=x,t[89]=_e):_e=t[89];let ve;return t[90]!==pe||t[91]!==he||t[92]!==_e?(ve=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[pe,he,ge,_e]}),t[90]=pe,t[91]=he,t[92]=_e,t[93]=ve):ve=t[93],ve},$o=e=>{let t=(0,Q.c)(29),{path:n}=e,{t:i}=re(),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=s(),t[0]=c):c=t[0];let l=c,u=Z.useRef(null),[d,f]=Z.useState(``),[p,g]=Z.useState(0),[_,v]=Z.useState(null),[y,b]=Z.useState(``),x,S;t[1]!==n||t[2]!==i?(x=()=>{let e=!1;if(f(``),v(null),b(``),l)return h(Ko(n)).then(async e=>{if(!e.ok)throw Error(i(`filesView.error.readFileFailed`));return e.text()}).then(t=>{e||(b(t),f(n))}).catch(t=>{e||(v(t instanceof Error?t.message:i(`filesView.error.readFileFailed`)),f(n))}),()=>{e=!0};let t=m(),s=a(t);r(t).then(t=>{e||!t||(f(n),v(null))}).catch(t=>{e||(v(t instanceof Error?t.message:i(`filesView.error.readFileFailed`)),f(n))});let c=o(()=>{e||(f(n),g(as),v(null))});return()=>{e=!0,s(),c()}},S=[n,l,i],t[1]=n,t[2]=i,t[3]=x,t[4]=S):(x=t[3],S=t[4]),Z.useEffect(x,S);let C;t[5]!==n||t[6]!==d?(C=()=>{if(d!==n)return;let e=u.current;if(e)return Lo(e)},t[5]=n,t[6]=d,t[7]=C):C=t[7];let w;if(t[8]!==p||t[9]!==n||t[10]!==d||t[11]!==y?(w=[p,n,d,y],t[8]=p,t[9]=n,t[10]=d,t[11]=y,t[12]=w):w=t[12],Z.useEffect(C,w),_){let e;return t[13]===_?e=t[14]:(e=(0,$.jsx)(ts,{message:_}),t[13]=_,t[14]=e),e}if(d!==n){let e;t[15]===i?e=t[16]:(e=i(`filesView.state.loading`),t[15]=i,t[16]=e);let n;return t[17]===e?n=t[18]:(n=(0,$.jsx)(ts,{loading:!0,message:e}),t[17]=e,t[18]=n),n}let T;t[19]===n?T=t[20]:(T=l?void 0:qo(n),t[19]=n,t[20]=T);let E=l?y:void 0,D;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(D={backgroundColor:`var(--surface-background)`},t[21]=D):D=t[21];let O;t[22]===i?O=t[23]:(O=i(`filesView.editor.htmlPreviewTitle`),t[22]=i,t[23]=O);let k;return t[24]!==p||t[25]!==T||t[26]!==E||t[27]!==O?(k=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:(0,$.jsx)(`iframe`,{ref:u,src:T,srcDoc:E,className:`h-full min-h-0 w-full flex-1 border-none bg-background`,style:D,sandbox:`allow-scripts allow-same-origin allow-forms`,title:O},p)}),t[24]=p,t[25]=T,t[26]=E,t[27]=O,t[28]=k):k=t[28],k},es=e=>{let t=(0,Q.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=_t(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??jn(!1),t[0]=a,t[1]=o,t[2]=c):c=t[2];let l=c,u;t[3]!==a||t[4]!==s?(u=a.find(e=>e.metadata.id===s)??jn(!0),t[3]=a,t[4]=s,t[5]=u):u=t[5];let d=u,f,p;t[6]!==d||t[7]!==l?(f=()=>{lr(l),lr(d)},p=[d,l],t[6]=d,t[7]=l,t[8]=f,t[9]=p):(f=t[8],p=t[9]),Z.useEffect(f,p);let m;t[10]!==d.metadata.id||t[11]!==l.metadata.id?(m={light:l.metadata.id,dark:d.metadata.id},t[10]=d.metadata.id,t[11]=l.metadata.id,t[12]=m):m=t[12];let h=m;if(Go(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Hn,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(dr,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=Vo(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=vr(n)||void 0,t[17]=n,t[18]=_);let v;t[19]!==r||t[20]!==g||t[21]!==_?(v={name:g,contents:r,lang:_},t[19]=r,t[20]=g,t[21]=_,t[22]=v):v=t[22];let y=i.metadata.variant===`dark`?`dark`:`light`,b;t[23]!==h||t[24]!==y?(b={disableFileHeader:!0,overflow:`wrap`,theme:h,themeType:y,unsafeCSS:vi},t[23]=h,t[24]=y,t[25]=b):b=t[25];let x;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(x={minHeight:`100%`},t[26]=x):x=t[26];let S;return t[27]!==b||t[28]!==v?(S=(0,$.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,$.jsx)(Hn,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(V,{file:v,options:b,className:`block min-h-full w-full`,style:x})})}),t[27]=b,t[28]=v,t[29]=S):S=t[29],S},ts=e=>{let t=(0,Q.c)(7),{message:n,loading:r}=e,i=r!==void 0&&r,a;t[0]===i?a=t[1]:(a=i?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-open-fill`,className:`size-6 text-muted-foreground`}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s};function ns(e){return e.pendingFileFocusPath}function rs(e){return e.setPendingFileFocusPath}function is(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}function as(e){return e+1}var os=S(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),ss=S()(C(e=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(t,n)=>e(e=>({projectExpanded:{...e.projectExpanded,[t]:n}})),setWorktreeExpanded:(t,n)=>e(e=>({worktreeExpanded:{...e.worktreeExpanded,[t]:n}}))}),{name:`mobile-session-tree`,storage:v()}));typeof window<`u`&&c(e=>{p(e)&&ss.persist.rehydrate()});var cs=36,ls=18,us=e=>e.parentID??null,ds=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),fs=e=>{let t=e;return ds(t.directory??t.project?.worktree??null)},ps=e=>{let t=ds(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},ms=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},hs=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),gs=e=>{if(e<=0)return``;let t=Date.now()-e;if(t<6e4)return`now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return`${r}h`;let i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))},_s=(e,t)=>{let n=ds(e),r=ds(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},vs=(e,t)=>e.worktrees.find(e=>ds(e.path)===t)??null,ys=(e,t)=>t===e.path||!!vs(e,t),bs=(e,t)=>{let n=ds(t);return n?e.find(e=>ys(e,n))??null:null},xs=(e,t,n)=>!n||`${e.title??``} ${e.id} ${fs(e)} ${t}`.toLowerCase().includes(n),Ss=e=>{let t=(0,Q.c)(14),{project:n,size:r}=e,i=r===void 0?`md`:r,a=i===`sm`?`size-6 rounded-md`:`size-8 rounded-lg`,o=i===`sm`?`size-3.5`:`size-4`,s=n.icon?ln[n.icon]:null,c=n.color?un[n.color]:void 0,l=s??`folder-open`,u;t[0]===c?u=t[1]:(u=c?{color:c}:void 0,t[0]=c,t[1]=u);let d;t[2]!==o||t[3]!==l||t[4]!==u?(d=(0,$.jsx)(X,{name:l,className:o,style:u}),t[2]=o,t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=d,p;t[6]===a?p=t[7]:(p=G(`flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,a),t[6]=a,t[7]=p);let m;t[8]!==f||t[9]!==n?(m=n.iconImage?(0,$.jsx)(sn,{project:n,className:`size-full object-contain`,fallback:f}):f,t[8]=f,t[9]=n,t[10]=m):m=t[10];let h;return t[11]!==p||t[12]!==m?(h=(0,$.jsx)(`span`,{className:p,children:m}),t[11]=p,t[12]=m,t[13]=h):h=t[13],h},Cs=e=>{let t=(0,Q.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=G(`flex size-5 shrink-0 items-center justify-center text-muted-foreground/70 transition-transform duration-150`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`span`,{"aria-hidden":!0,className:i,children:a}),t[3]=i,t[4]=o),o},ws=e=>{let t=(0,Q.c)(2),{ariaLabel:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`inline-block size-1.5 shrink-0 rounded-full bg-primary`,"aria-label":n}),t[0]=n,t[1]=r),r},Ts=e=>{let t=(0,Q.c)(12),{onClick:n,className:r}=e,{t:i}=re(),a;t[0]===i?a=t[1]:(a=i(`sessions.sidebar.project.actions.newWorktree`),t[0]=i,t[1]=a);let o=a,s;t[2]===r?s=t[3]:(s=G(`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,r),t[2]=r,t[3]=s);let c;t[4]===n?c=t[5]:(c=e=>{e.stopPropagation(),n()},t[4]=n,t[5]=c);let l,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l={touchAction:`manipulation`},u=(0,$.jsx)(X,{name:`node-tree`,className:`size-4`}),t[6]=l,t[7]=u):(l=t[6],u=t[7]);let d;return t[8]!==o||t[9]!==s||t[10]!==c?(d=(0,$.jsx)(`button`,{type:`button`,className:s,"aria-label":o,title:o,onClick:c,style:l,children:u}),t[8]=o,t[9]=s,t[10]=c,t[11]=d):d=t[11],d},Es=e=>{let t=(0,Q.c)(10),{icon:n,label:r,onClick:i,destructive:a}=e,o=a!==void 0&&a?`destructive`:`ghost`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(X,{name:n,className:`size-5 shrink-0`}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=l);let u;return t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(K,{type:`button`,variant:o,size:`default`,className:`min-h-12 w-full justify-start gap-3 rounded-xl px-3 typography-ui-label`,onClick:i,style:s,children:[c,l]}),t[5]=i,t[6]=o,t[7]=c,t[8]=l,t[9]=u):u=t[9],u},Ds=e=>{let t=(0,Q.c)(100),{session:n,active:r,indent:i,contextLabel:a,confirmingArchive:o,hasChildren:s,expanded:c,onToggleChildren:l,onSelect:u,onRequestArchive:d,onConfirmArchive:f,onStop:p,stopAriaLabel:m,longPressHandlers:h,highlightQuery:g}=e,_=o!==void 0&&o,v=s!==void 0&&s,y=c!==void 0&&c,{t:b}=re(),x;t[0]===n?x=t[1]:(x=gs(ms(n)),t[0]=n,t[1]=x);let S=x,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,R,z,B;if(t[2]!==r||t[3]!==_||t[4]!==y||t[5]!==v||t[6]!==g||t[7]!==i||t[8]!==h.onContextMenu||t[9]!==h.onPointerCancel||t[10]!==h.onPointerDown||t[11]!==h.onPointerMove||t[12]!==h.onPointerUp||t[13]!==h.pressed||t[14]!==u||t[15]!==l||t[16]!==n.title||t[17]!==b){B=n.title?.trim()||b(`mobile.sessions.untitled`);let e=r&&!_&&`bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]`,a=_&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`;t[36]!==e||t[37]!==a?(N=G(`relative flex items-center gap-1 transition-colors`,e,a),t[36]=e,t[37]=a,t[38]=N):N=t[38],t[39]!==y||t[40]!==v||t[41]!==i||t[42]!==l||t[43]!==b?(P=v&&l?(0,$.jsx)(`button`,{type:`button`,className:`absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,style:{left:Math.max(i-32,2),top:0,bottom:0,touchAction:`manipulation`},"aria-label":b(y?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:e=>{e.stopPropagation(),l()},children:(0,$.jsx)(X,{name:`arrow-down-s`,className:G(`size-[18px] transition-transform duration-150`,y?`rotate-0`:`-rotate-90`)})}):null,t[39]=y,t[40]=v,t[41]=i,t[42]=l,t[43]=b,t[44]=P):P=t[44],C=`button`;let o=_&&`opacity-50`,s=h.pressed&&`bg-interactive-active scale-[0.99]`;t[45]!==o||t[46]!==s?(w=G(`flex min-h-12 min-w-0 flex-1 items-center gap-2.5 py-2 pr-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o,s),t[45]=o,t[46]=s,t[47]=w):w=t[47],t[48]===i?T=t[49]:(T={paddingLeft:i,touchAction:`manipulation`},t[48]=i,t[49]=T),E=u,D=h.onPointerDown,O=h.onPointerMove,k=h.onPointerUp,A=h.onPointerCancel,j=h.onContextMenu,M=_,z=`flex min-w-0 flex-1 flex-col`,L=`flex items-center gap-2.5`;let c=r?`bg-primary`:`bg-muted-foreground/30`,d;t[50]===c?d=t[51]:(d=G(`size-1.5 shrink-0 rounded-full`,c),t[50]=c,t[51]=d),t[52]===d?R=t[53]:(R=(0,$.jsx)(`span`,{className:d,"aria-hidden":!0}),t[52]=d,t[53]=R);let f=r?`text-primary`:`text-foreground`;t[54]===f?F=t[55]:(F=G(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),I=g?gn(B,g):B,t[2]=r,t[3]=_,t[4]=y,t[5]=v,t[6]=g,t[7]=i,t[8]=h.onContextMenu,t[9]=h.onPointerCancel,t[10]=h.onPointerDown,t[11]=h.onPointerMove,t[12]=h.onPointerUp,t[13]=h.pressed,t[14]=u,t[15]=l,t[16]=n.title,t[17]=b,t[18]=C,t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A,t[26]=j,t[27]=M,t[28]=N,t[29]=P,t[30]=F,t[31]=I,t[32]=L,t[33]=R,t[34]=z,t[35]=B}else C=t[18],w=t[19],T=t[20],E=t[21],D=t[22],O=t[23],k=t[24],A=t[25],j=t[26],M=t[27],N=t[28],P=t[29],F=t[30],I=t[31],L=t[32],R=t[33],z=t[34],B=t[35];let ee;t[56]!==F||t[57]!==I?(ee=(0,$.jsx)(`span`,{className:F,children:I}),t[56]=F,t[57]=I,t[58]=ee):ee=t[58];let V;t[59]===S?V=t[60]:(V=S?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:S}):null,t[59]=S,t[60]=V);let H;t[61]!==ee||t[62]!==V||t[63]!==L||t[64]!==R?(H=(0,$.jsxs)(`span`,{className:L,children:[R,ee,V]}),t[61]=ee,t[62]=V,t[63]=L,t[64]=R,t[65]=H):H=t[65];let te;t[66]!==a||t[67]!==g?(te=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?gn(a,g):a}):null,t[66]=a,t[67]=g,t[68]=te):te=t[68];let U;t[69]!==H||t[70]!==te||t[71]!==z?(U=(0,$.jsxs)(`span`,{className:z,children:[H,te]}),t[69]=H,t[70]=te,t[71]=z,t[72]=U):U=t[72];let W;t[73]!==C||t[74]!==w||t[75]!==T||t[76]!==E||t[77]!==D||t[78]!==O||t[79]!==k||t[80]!==A||t[81]!==j||t[82]!==M||t[83]!==U?(W=(0,$.jsx)(`button`,{type:C,className:w,style:T,onClick:E,onPointerDown:D,onPointerMove:O,onPointerUp:k,onPointerCancel:A,onContextMenu:j,disabled:M,children:U}),t[73]=C,t[74]=w,t[75]=T,t[76]=E,t[77]=D,t[78]=O,t[79]=k,t[80]=A,t[81]=j,t[82]=M,t[83]=U,t[84]=W):W=t[84];let ne;t[85]!==p||t[86]!==m?(ne=p?(0,$.jsx)(`button`,{type:`button`,className:`mr-0.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":m,onClick:e=>{e.stopPropagation(),p()},style:{touchAction:`manipulation`},children:(0,$.jsx)(Jr,{})}):null,t[85]=p,t[86]=m,t[87]=ne):ne=t[87];let ie;t[88]!==_||t[89]!==f||t[90]!==d||t[91]!==b||t[92]!==B?(ie=d?(0,$.jsxs)($.Fragment,{children:[_?(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 shrink-0 items-center gap-1.5 rounded-xl bg-destructive px-3 text-destructive-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,"aria-label":b(`mobile.sessions.archiveSessionAria`,{title:B}),onClick:f,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`archive`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:b(`sessions.sidebar.bulkActions.archive`)})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`mr-1.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":b(_?`mobile.sessions.cancelArchiveAria`:`mobile.sessions.archiveSessionAria`,{title:B}),onClick:d,style:{touchAction:`manipulation`},children:_?(0,$.jsx)(X,{name:`close`,className:`size-4`}):(0,$.jsx)(X,{name:`archive`,className:`size-4`})})]}):null,t[88]=_,t[89]=f,t[90]=d,t[91]=b,t[92]=B,t[93]=ie):ie=t[93];let K;return t[94]!==N||t[95]!==P||t[96]!==W||t[97]!==ne||t[98]!==ie?(K=(0,$.jsxs)(`div`,{className:N,children:[P,W,ne,ie]}),t[94]=N,t[95]=P,t[96]=W,t[97]=ne,t[98]=ie,t[99]=K):K=t[99],K},Os=e=>{let t=(0,Q.c)(15),{indent:n,showMore:r,showFewer:i,loadingMore:a,onShowMore:o,onShowFewer:s}=e,c=a!==void 0&&a,{t:l}=re();if(!r&&!i)return null;let u;t[0]===n?u=t[1]:(u={paddingLeft:n,touchAction:`manipulation`},t[0]=n,t[1]=u);let d;t[2]!==s||t[3]!==i||t[4]!==l?(d=i?(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:s,children:[(0,$.jsx)(X,{name:`arrow-up-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showFewer`)})]}):null,t[2]=s,t[3]=i,t[4]=l,t[5]=d):d=t[5];let f;t[6]!==c||t[7]!==o||t[8]!==r||t[9]!==l?(f=r?(0,$.jsxs)(`button`,{type:`button`,className:G(`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-60`,c&&`animate-pulse`),onClick:o,disabled:c,children:[(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showMore`)})]}):null,t[6]=c,t[7]=o,t[8]=r,t[9]=l,t[10]=f):f=t[10];let p;return t[11]!==u||t[12]!==d||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-h-10 w-full items-center gap-3 py-1.5 pr-3 text-muted-foreground`,style:u,children:[d,f]}),t[11]=u,t[12]=d,t[13]=f,t[14]=p):p=t[14],p},ks=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=re(),{git:i}=Mn(),a=Ke(),o=Be(),s=Se(e=>e.activeSessions),c=Se(e=>e.activePaginationByDirectory),l=Xe(e=>e.projects),u=Xe(e=>e.activeProjectId),d=D(e=>e.currentDirectory),f=Ze(e=>e.currentSessionId),p=Ze(e=>e.availableWorktreesByProject),m=Ze(e=>e.setCurrentSession),h=Ze(e=>e.archiveSession),g=Ze(e=>e.archiveSessions),_=Ze(e=>e.updateSessionTitle),v=Ze(e=>e.requestSessionSmartTitle),y=Ze(e=>e.shareSession),b=Ze(e=>e.unshareSession),x=Ze(e=>e.openNewSessionDraft),S=Xe(e=>e.setActiveProject),C=Xe(e=>e.setActiveProjectIdOnly),w=Xe(e=>e.removeProject),T=Ne(),E=Pe(),O=ss(e=>e.projectExpanded),k=ss(e=>e.worktreeExpanded),A=ss(e=>e.setProjectExpanded),j=ss(e=>e.setWorktreeExpanded),M=Zt(e=>e.orderByProject),N=os(e=>e.expandedParents),P=os(e=>e.toggleParent),[F,I]=Z.useState(``),[L,R]=Z.useState(null),[z,B]=Z.useState(null),[ee,V]=Z.useState(0),[H,te]=Z.useState(!1),[W,ie]=Z.useState(!1),[ae,oe]=Z.useState(null),[se,ce]=Z.useState(null),[q,J]=Z.useState(null),[le,ue]=Z.useState(null),[de,fe]=Z.useState(null),[pe,me]=Z.useState(``),[he,ge]=Z.useState(!1),[_e,ve]=Z.useState(null),ye=Z.useRef(null);ye.current||=br({onPressedKeyChange:ue});let[be,xe]=Z.useState(new Set),[Ce,we]=Z.useState(new Map),[Ee,De]=Z.useState(new Map),Oe=Gr(),ke=ei(),Ae=U(e=>{Te(e),Ue(e)}),je=U(e=>{Promise.all(e.map(e=>(Te(e),Ue(e))))});Z.useEffect(()=>{if(!e){I(``),De(new Map),R(null),B(null),ce(null),fe(null),ve(null),ye.current?.reset();return}},[e]),Z.useEffect(()=>()=>{ye.current?.reset()},[]),Z.useEffect(()=>{if(!e)return;if(l.length===0){Ze.setState(e=>{let t=Ur(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),xe(e=>e.size===0?e:new Set),we(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(l.map(async e=>{let n=ds(e.path);if(!n)return null;let r;try{r=await i.checkIsGitRepository(n)}catch{return{id:e.id,path:n,gitStatus:`failed`}}if(!r)return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:`success`,worktrees:[]};let[a,o]=await Promise.allSettled([dn({id:e.id,path:n},{isCurrent:()=>!t}),cn(n)]);return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:a.status===`fulfilled`?`success`:`failed`,worktrees:a.status===`fulfilled`?a.value.worktrees:void 0,rootBranchStatus:o.status===`fulfilled`?`success`:`failed`,rootBranch:o.status===`fulfilled`?o.value:void 0}}));if(t)return;let n=new Set(l.map(e=>ds(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);Ze.setState(e=>{let t=Ur(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),xe(t=>{let r=new Set([...t].filter(e=>n.has(e)));for(let t of e)t?.gitStatus===`success`&&(t.isGitRepo?r.add(t.path):r.delete(t.path));return hs(r,t)?t:r}),we(t=>{let n=new Set(l.map(e=>e.id)),r=new Map([...t].filter(([e])=>n.has(e)));for(let t of e){if(!t||t.gitStatus!==`success`)continue;if(!t.isGitRepo){r.delete(t.id);continue}if(t.rootBranchStatus!==`success`)continue;let e=t.rootBranch?.trim();e&&e!==`HEAD`?r.set(t.id,e):r.delete(t.id)}return r.size===t.size&&[...r].every(([e,n])=>t.get(e)===n)?t:r})})(),()=>{t=!0}},[i,e,l,ee]);let Me=Z.useMemo(()=>l.map(e=>({id:e.id,label:ps(e.path),path:ds(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:be.has(ds(e.path)),worktrees:Yt(M[e.id],p.get(ds(e.path))??[])})),[be,l,M,p]),Fe=Z.useMemo(()=>{let e=new Map(o.map(e=>[e.id,e])),t=s.map(t=>{let n=e.get(t.id);return n?dt(n,t):t}),n=new Set(t.map(e=>e.id));for(let e of o)n.has(e.id)||t.push(e);return t},[s,o]),Ie=F.trim().toLowerCase(),Le=Z.useMemo(()=>{let e=Me.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===u})),t=(e,t,n)=>{let r=ds(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||ps(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a};for(let n of e){t(n,n.project.path,null);for(let e of n.project.worktrees)t(n,e.path,e)}for(let n of Fe){let r=fs(n);if(!r)continue;let i=ds(r),a=e.find(e=>ys(e.project,i));if(!a)continue;let o=vs(a.project,i);(o?t(a,o.path,o):t(a,a.project.path,null)).sessions.push(n)}for(let t of e)for(let e of t.buckets){e.sessions.sort((e,t)=>ut(t)-ut(e));for(let n of e.sessions)us(n)||(t.totalSessions+=1)}return e},[u,Me,Fe]),Re=ds(d),Ve=e=>e.isActive?Re===e.project.path?e.project.path:e.project.worktrees.find(e=>_s(Re,e.path))?.path??e.project.path:null,He=e=>O[e.project.id]??!0,We=(e,t)=>k[`${e.project.id}::${t.key}`]??!1,Ge=e=>{De(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},qe=()=>{ce(null),ye.current?.reset()},Je=e=>({pressed:le===e.key||se?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||ye.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>ce(e)})},onPointerMove:e=>{ye.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{ye.current?.end(e.pointerId)},onPointerCancel:e=>{ye.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),ye.current?.openFromContextMenu(e.key,()=>ce(e))}}),Ye=(e,t)=>{ye.current?.consumeClick(e)||t()},Qe=(e,t,n,r)=>{let i=Qr(),a=Wr();if(De(t=>{let r=new Map(t),o=Math.max(i,t.get(e)??i,n);return r.set(e,o+a),r}),Math.max(i,n)+a<r)return;let o=ds(t);if(!o)return;let s=Se.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&ze(o)},$e=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=Qr(),o=new Set(t.sessions.map(e=>e.id)),s=new Map;for(let e of t.sessions){let t=us(e);if(t&&o.has(t)){let n=s.get(t)??[];n.push(e),s.set(t,n)}}let l=t.sessions.filter(e=>!us(e)),u=Ee.get(i)??a,d=Xr(l,u,ke),p=l.length-d.length,m=c.get(ds(t.path)),h=m?.hasMore===!0,g=m?.loadingMore===!0,_=l.length>a&&u>a,v=(e,t)=>{let n=s.get(e.id)??[],i=n.length>0,a=!!N[e.id],o=Oe.has(e.id),c=i&&!a?n.filter(e=>Oe.has(e.id)).map(e=>e.id):[],l=c.length>0,u=o?[e.id,...c]:c,d=e.title?.trim()||r(`mobile.sessions.untitled`),p=`session:${e.id}`;return(0,$.jsxs)(Z.Fragment,{children:[(0,$.jsx)(Ds,{session:e,active:f===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>P(e.id):void 0,confirmingArchive:z===e.id,onSelect:()=>Ye(p,()=>rt(e)),onRequestArchive:()=>it(e.id),onConfirmArchive:()=>void at(e),onStop:o||l?()=>je(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:d}),longPressHandlers:Je({key:p,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+ls)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[d.map(e=>v(e,n)),(0,$.jsx)(Os,{indent:n,showMore:p>0||h,showFewer:_,loadingMore:g,onShowMore:()=>Qe(i,t.path,u,l.length),onShowFewer:()=>Ge(i)})]})},tt=(e,t)=>{A(e,!t)},nt=(e,t,n)=>{j(`${e}::${t}`,!n)},rt=e=>{Nn();let n=fs(e)||null,r=bs(Me,n??``);r&&C(r.id),m(e.id,n),t(!1)},it=e=>{B(t=>t===e?null:e)},at=async e=>{B(null),await h(e.id)?di({sessionIds:[e.id],message:r(`sessions.sidebar.session.archive.success`),undoLabel:r(`sessions.sidebar.undo`),settingsLabel:r(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:r(`sessions.sidebar.session.archive.undoFailed`)}):Y.error(r(`sessions.sidebar.session.archive.error`))},ot=()=>{x(),t(!1)},st=e=>{oe(e),C(e),ie(!0)},ct=e=>{let t=new Map;for(let e of Fe){let n=us(e);if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n},lt=async e=>{let t=ct(e.id),{archivedIds:n,failedIds:i}=await g(t);n.length>0&&di({sessionIds:n,message:n.length===1?r(`sessions.sidebar.session.archive.success`):r(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:r(`sessions.sidebar.undo`),settingsLabel:r(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:n.length===1?r(`sessions.sidebar.session.archive.undoFailed`):r(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),i.length>0&&Y.error(i.length===1?r(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):r(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}))},ft=e=>{let t=ct(e.id);Vr({sessionIds:t,message:t.length===1?r(`sessions.sidebar.session.delete.success`):r(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:r(`sessions.sidebar.undo`),commitFailedMessage:r(`sessions.sidebar.session.delete.error`)})},pt=async e=>{try{if(!(await y(e.id))?.share?.url){Y.error(r(`sessions.sidebar.session.share.error`));return}Y.success(r(`sessions.sidebar.session.share.successTitle`),{description:r(`sessions.sidebar.session.share.successDescription`)})}catch{Y.error(r(`sessions.sidebar.session.share.error`))}},mt=async e=>{if((await ne(e)).ok){Y.success(r(`sessions.sidebar.session.menu.copied`));return}Y.error(r(`sessions.sidebar.session.share.copyUrlError`))},ht=async e=>{try{if(await b(e)){Y.success(r(`sessions.sidebar.session.unshare.success`));return}Y.error(r(`sessions.sidebar.session.unshare.error`))}catch{Y.error(r(`sessions.sidebar.session.unshare.error`))}},gt=async()=>{if(!de)return;let e=pe.trim();if(e)try{await _(de.id,e),fe(null),me(``)}catch{Y.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},_t=async()=>{if(!de||he)return;let e=de.id;fe(null),me(``),ge(!0);try{await v(e)}catch{Y.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{ge(!1)}},vt=(e,n)=>{C(e.id),x({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},yt=e=>{(async()=>{try{await dn({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=Ze.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await et(n,Fe)})()},bt=e=>{let t=fs(e),n=bs(Me,t);if(!n)return ps(t)||t;let r=vs(n,ds(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},xt=e=>{S(e.id),t(!1)},St=Z.useMemo(()=>Ie?Le.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Ie)?!0:e.buckets.some(t=>t.sessions.some(t=>xs(t,e.project.label,Ie)))):Le,[Ie,Le]),Ct=Z.useMemo(()=>Ie?Fe.filter(e=>{let t=fs(e);return xs(e,bs(Me,t)?.label??``,Ie)}).sort((e,t)=>ut(t)-ut(e)):[],[Ie,Me,Fe]),wt=Z.useMemo(()=>Ie?Me.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Ie)).map(e=>({...e,sessionCount:Fe.filter(t=>!us(t)&&ys(e,ds(fs(t)))).length})):[],[Ie,Me,Fe]),Tt=Ie&&Ct.length===0&&wt.length===0,Et=Me.length>0?(0,$.jsxs)(K,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:ot,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,Dt=Me.find(e=>e.id===u)??null,Ot=Dt?.isGitRepo?(0,$.jsx)(K,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>st(Dt.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`node-tree`,className:`size-4`})}):null,kt=(0,$.jsx)(K,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>te(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folder-add`,className:`size-4`})}),At=Et||kt?(0,$.jsxs)($.Fragment,{children:[Et,Ot,kt]}):null,jt=se?.kind===`project`?se.project.label:se?.kind===`worktree`?se.worktree.branch||se.worktree.label||se.worktree.path:se?.kind===`session`?se.session.title?.trim()||r(`mobile.sessions.untitled`):``,Mt=Z.useMemo(()=>{if(!se)return[];if(se.kind===`project`){let e=se.project;return Di({gitRepository:e.isGitRepo,onNewSession:()=>{qe(),vt(e,e.path)},onNewWorktree:()=>{qe(),st(e.id)},onSyncSessions:()=>{qe(),yt(e)},onEditProject:()=>{qe(),R(e.id)},onCloseProject:()=>{qe(),J(e)}})}if(se.kind===`worktree`){let{project:e,worktree:t}=se;return Hr({onNewSession:()=>{qe(),vt(e,t.path)},onDeleteWorktree:()=>{qe(),ve({project:e,worktree:t})}})}let e=se.session,t=!!e.share?.url;return Zr({pinned:T.has(e.id),shared:t,onRename:()=>{qe(),me(e.title?.trim()||r(`mobile.sessions.untitled`)),fe(e)},onTogglePin:()=>{qe(),E(e.id)},onShare:!a||t?void 0:()=>{qe(),pt(e)},onCopyLink:a&&t?()=>{let t=e.share?.url;qe(),t&&mt(t)}:void 0,onUnshare:a&&t?()=>{qe(),ht(e.id)}:void 0,onArchive:()=>{qe(),lt(e)},onDelete:()=>{qe(),ft(e)}})},[se,qe,lt,mt,ft,st,pt,ht,T,vt,yt,r,E]),Nt=Mt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Mt.map(e=>{let t=(0,$.jsx)(Es,{icon:e.icon,label:Ei(e,r),destructive:e.destructive,onClick:e.onClick},e.id);return e.separated?(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:t},e.id):t})}):null,Pt=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(fn,{value:F,onChange:e=>I(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:G(`h-11 pl-9`,F&&`pr-10`)}),F?(0,$.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":r(`mobile.sessions.clearSearchAria`),onClick:()=>I(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsx)(Hn,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:Me.length===0?(0,$.jsx)(As,{title:r(`mobile.sessions.empty.noProjectsTitle`),description:r(`mobile.sessions.empty.noProjectsDescription`),action:(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center justify-center gap-2 rounded-2xl bg-primary px-5 py-3 typography-ui-label text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>te(!0),children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):Tt?(0,$.jsx)(As,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Ie?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 pt-2`,children:[Ct.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.sessions`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:Ct.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Ct.map((e,t)=>{let n=Oe.has(e.id),i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:G(t>0&&`border-t border-border/30`),children:(0,$.jsx)(Ds,{session:e,active:f===e.id,indent:12,contextLabel:bt(e),highlightQuery:Ie,onSelect:()=>Ye(`session:${e.id}`,()=>rt(e)),longPressHandlers:Je({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>Ae(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,wt.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.projects`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:wt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:wt.map((e,t)=>{let n=`project:${e.id}`,r=Je({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:G(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:G(`flex min-h-14 min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,r.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(n,()=>xt(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Ss,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:gn(e.label,Ie)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(Ts,{className:`mr-2`,onClick:()=>st(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:St.map((e,t)=>{let n=He(e),i=`project:${e.project.id}`,a=Je({key:i,kind:`project`,project:e.project}),o=Ie?e.buckets.filter(t=>t.sessions.some(t=>xs(t,e.project.label,Ie))):e.buckets,s=Ve(e);return(0,$.jsxs)(`section`,{className:G(t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`div`,{className:`flex min-h-14 w-full items-center`,children:[(0,$.jsxs)(`button`,{type:`button`,className:G(`flex min-h-14 min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,a.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(i,()=>tt(e.project.id,n)),onPointerDown:a.onPointerDown,onPointerMove:a.onPointerMove,onPointerUp:a.onPointerUp,onPointerCancel:a.onPointerCancel,onContextMenu:a.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:e.project.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)(Ss,{project:e.project}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-semibold text-foreground`,children:e.project.label}),Ce.get(e.project.id)?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:Ce.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(ws,{ariaLabel:r(`mobile.sessions.activeProjectAria`)}):null,(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.totalSessions})]}),(()=>{let t=n?[]:[...new Set(e.buckets.flatMap(e=>e.sessions.filter(e=>Oe.has(e.id)).map(e=>e.id)))];return t.length>0?(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] mr-1`,"aria-label":r(`mobile.sessions.stopGroupAria`,{label:e.project.label}),onClick:e=>{e.stopPropagation(),je(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Jr,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(Ts,{className:`mr-2`,onClick:()=>st(e.project.id)}):null]}),n?(0,$.jsx)(`div`,{className:`pb-2`,children:(()=>{let t=o.find(e=>e.worktree===null),n=o.filter(e=>e.worktree!==null);return(0,$.jsxs)($.Fragment,{children:[t&&t.sessions.length>0?$e(e,t,cs):null,n.map(t=>{let n=We(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Je({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:G(`flex min-h-11 w-full items-center gap-2 py-1.5 pl-4 pr-3 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(a,()=>nt(e.project.id,t.key,n)),onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onPointerCancel:o.onPointerCancel,onContextMenu:o.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:t.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)(Cs,{expanded:n}),(0,$.jsx)(X,{name:`node-tree`,className:G(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:G(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(ws,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>Oe.has(e.id)).map(e=>e.id);return e.length>0?(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":r(`mobile.sessions.stopGroupAria`,{label:t.label}),onClick:t=>{t.stopPropagation(),je(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Jr,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?$e(e,t,cs):null]},t.key)})]})})()}):null]},e.project.id)})})}),(0,$.jsx)(ci,{open:H,onOpenChange:te,forceMobile:!0}),(0,$.jsx)(Jt,{open:W,projectId:ae,onOpenChange:e=>{ie(e),e||oe(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?m(n.sessionId,e):x({selectedProjectId:ae,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(xn,{open:!!se,title:jt,onClose:qe,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Nt}),(0,$.jsx)(xn,{open:!!q,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>J(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>J(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(K,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!q)return;let e=q;J(null),w(e.id),Y.success(r(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:r(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:r(`mobile.projects.closeConfirmMessage`,{title:q?.label??``})})}),(0,$.jsx)(xn,{open:!!de,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{he||(fe(null),me(``))},footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:he,onClick:()=>{fe(null),me(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(K,{type:`button`,variant:`default`,className:`flex-1`,disabled:!pe.trim()||he,onClick:()=>void gt(),children:r(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),gt()},children:[(0,$.jsx)(fn,{value:pe,onChange:e=>me(e.target.value),autoFocus:!0,className:`h-12`,disabled:he}),(0,$.jsxs)(K,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:he,onClick:()=>void _t(),children:[he?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),r(`sessions.sidebar.session.rename.smartTitle`)]})]})}),_e?(0,$.jsx)(fi,{open:!0,project:{id:_e.project.id,path:_e.project.path},worktree:_e.worktree,onClose:()=>ve(null),onDeleted:()=>V(e=>e+1)}):null,(0,$.jsx)(Yr,{open:L!==null,project:Me.find(e=>e.id===L)??null,onClose:()=>R(null),onWorktreesChanged:()=>V(e=>e+1)})]});return n===`sidebar`?e?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsx)(`div`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center justify-end gap-2 px-4`,children:At?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:At}):null}),Pt]}):null:(0,$.jsx)(Rn,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:At,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:Pt})},As=e=>{let t=(0,Q.c)(10),{title:n,description:r,action:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i?(0,$.jsx)(`div`,{className:`pt-2`,children:i}):null,t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c},js=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,Ms=[{image:Pi,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:zi,titleKey:`assistants.guide.share.android.title`,descriptionKey:`assistants.guide.share.android.description`},{image:Ni,titleKey:`assistants.guide.share.pick.title`,descriptionKey:`assistants.guide.share.pick.description`}];function Ns(){let e=(0,Q.c)(8),{t}=re(),n;e[0]===t?n=e[1]:(n=t(`common.loading`),e[0]=t,e[1]=n);let r,i,a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`h-10 w-10 animate-pulse rounded-xl bg-[var(--surface-muted)] motion-reduce:animate-none`}),i=(0,$.jsx)(`div`,{className:`mt-2 h-4 w-2/3 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),a=(0,$.jsx)(`div`,{className:`h-3.5 w-full animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),o=(0,$.jsx)(`div`,{className:`h-3.5 w-4/5 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),e[2]=r,e[3]=i,e[4]=a,e[5]=o):(r=e[2],i=e[3],a=e[4],o=e[5]);let s;return e[6]===n?s=e[7]:(s=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 p-5`,"aria-busy":`true`,"aria-label":n,children:[r,i,a,o]}),e[6]=n,e[7]=s),s}function Ps(e){let t=(0,Q.c)(35),{onEnable:n}=e,{t:r}=re(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-hero`,"aria-hidden":`true`,children:(0,$.jsx)(`img`,{src:js,alt:``})}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=r(`assistants.guide.disabledTitle`),t[1]=r,t[2]=a);let o;t[3]===a?o=t[4]:(o=(0,$.jsx)(`h2`,{className:`oc-mobile-assistant-guide-title`,children:a}),t[3]=a,t[4]=o);let s;t[5]===r?s=t[6]:(s=r(`assistants.guide.disabledDescription`),t[5]=r,t[6]=s);let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(`p`,{className:`oc-mobile-assistant-guide-description`,children:s}),t[7]=s,t[8]=c);let l;t[9]===r?l=t[10]:(l=r(`assistants.guide.enableAction`),t[9]=r,t[10]=l);let u;t[11]!==n||t[12]!==l?(u=(0,$.jsx)(K,{type:`button`,size:`lg`,onClick:n,children:l}),t[11]=n,t[12]=l,t[13]=u):u=t[13];let d;t[14]!==o||t[15]!==c||t[16]!==u?(d=(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-body`,children:[o,c,u]}),t[14]=o,t[15]=c,t[16]=u,t[17]=d):d=t[17];let f;t[18]===r?f=t[19]:(f=r(`assistants.guide.shareTitle`),t[18]=r,t[19]=f);let p;t[20]===f?p=t[21]:(p=(0,$.jsx)(`h3`,{className:`oc-mobile-assistant-guide-share-title`,children:f}),t[20]=f,t[21]=p);let m;t[22]===r?m=t[23]:(m=r(`assistants.guide.shareAria`),t[22]=r,t[23]=m);let h;t[24]===r?h=t[25]:(h=Ms.map(e=>(0,$.jsxs)(`article`,{className:`oc-mobile-assistant-guide-step`,children:[(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-step-image`,children:(0,$.jsx)(`img`,{src:e.image,alt:``})}),(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-step-copy`,children:[(0,$.jsx)(`h4`,{children:r(e.titleKey)}),(0,$.jsx)(`p`,{children:r(e.descriptionKey)})]})]},e.titleKey)),t[24]=r,t[25]=h);let g;t[26]!==m||t[27]!==h?(g=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-steps`,"aria-label":m,children:h}),t[26]=m,t[27]=h,t[28]=g):g=t[28];let _;t[29]!==p||t[30]!==g?(_=(0,$.jsxs)(`section`,{className:`oc-mobile-assistant-guide-share`,children:[p,g]}),t[29]=p,t[30]=g,t[31]=_):_=t[31];let v;return t[32]!==_||t[33]!==d?(v=(0,$.jsxs)(`article`,{className:`oc-mobile-assistant-guide`,children:[i,d,_]}),t[32]=_,t[33]=d,t[34]=v):v=t[34],v}function Fs({avatarSeed:e,unreadCount:t,assistantID:n,displayName:r,summary:i,enabled:a,editLabel:o,deleteLabel:s,onOpen:c,onEdit:l,onDelete:u,serverWorking:d=!1}){let f=Xi(n,d),[p,m]=Z.useState(!1),[h,g]=Z.useState(!1),_=Z.useRef(null);_.current||=br({onPressedKeyChange:e=>g(e===n)}),Z.useEffect(()=>()=>_.current?.reset(),[]);let v=U(()=>{_.current?.consumeClick(n)||p||c()}),y=U(()=>{m(!1),l()}),b=U(()=>{m(!1),u()}),x=U(()=>{g(!1),m(!0)}),S=U(e=>{e.pointerType!==`touch`&&e.pointerType!==`pen`||e.button!==0||_.current?.start({pointerId:e.pointerId,key:n,clientX:e.clientX,clientY:e.clientY,onTrigger:x})}),C=U(e=>{_.current?.move(e.pointerId,e.clientX,e.clientY)}),w=U(e=>{_.current?.end(e.pointerId)}),T=U(e=>{_.current?.cancel(e.pointerId)}),E=U(e=>{e.preventDefault(),e.stopPropagation(),_.current?.openFromContextMenu(n,x)});return(0,$.jsxs)(ia,{open:p,onOpenChange:m,children:[(0,$.jsx)(Fi,{"data-mobile-press-surface":`soft`,className:G(`oc-mobile-assistant-card-shell`,h&&`bg-interactive-hover`),children:(0,$.jsxs)(ea,{render:(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-surface-trigger":!0,className:G(`oc-mobile-assistant-card`,!a&&`opacity-65`),onClick:v,onPointerDown:S,onPointerMove:C,onPointerUp:w,onPointerCancel:T,onContextMenu:E,style:{touchAction:`pan-y`}}),children:[(0,$.jsx)(`span`,{className:`oc-mobile-assistant-avatar`,children:(0,$.jsx)(Ji,{name:n,avatarSeed:e,size:44,label:r,working:f})}),(0,$.jsxs)(`span`,{className:`oc-mobile-assistant-card-content min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-entity-title oc-mobile-assistant-name block min-w-0 truncate font-semibold text-foreground`,children:r}),(0,$.jsx)(`span`,{className:G(`oc-mobile-assistant-summary`,Yi),children:i})]}),(0,$.jsx)(Qi,{count:t})]})}),(0,$.jsxs)(na,{className:`min-w-[10rem]`,children:[(0,$.jsxs)(ra,{className:`min-h-10 px-3`,onClick:y,children:[(0,$.jsx)(X,{name:`edit`,className:`size-4`}),o]}),(0,$.jsx)(ta,{}),(0,$.jsxs)(ra,{className:`min-h-10 px-3 text-[var(--status-error)] focus:text-[var(--status-error)] data-[highlighted]:text-[var(--status-error)] [&_svg]:text-[var(--status-error)]`,onClick:b,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`}),s]})]})]})}function Is(e){let t=(0,Q.c)(118),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=re(),o=Kn(),s=_e(),c=ve();c.data?.assistants;let l;t[0]===c.data?.assistants?l=t[1]:(l=c.data?.assistants??[],t[0]=c.data?.assistants,t[1]=l);let u;t[2]===l?u=t[3]:(u=qi(l),t[2]=l,t[3]=u);let d=u,f=mt(Ls),[p,m]=Z.useState(null),h;t[4]===n?h=t[5]:(h=()=>n(),t[4]=n,t[5]=h);let g=U(h),_;t[6]!==o||t[7]!==f?(_=()=>{f(),o?.openSettings(`assistants`)},t[6]=o,t[7]=f,t[8]=_):_=t[8];let v=U(_),y;t[9]===r?y=t[10]:(y=e=>r(e),t[9]=r,t[10]=y);let b=U(y),x;t[11]===o?x=t[12]:(x=e=>{gt(e,o?{openMobileSettings:o.openSettings}:void 0)},t[11]=o,t[12]=x);let S=U(x),C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{m(e)},t[13]=C):C=t[13];let w=U(C),T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{e||m(null)},t[14]=T):T=t[14];let E=U(T),D;t[15]===a?D=t[16]:(D=a(`assistants.title`),t[15]=a,t[16]=D);let O=D,k;t[17]===a?k=t[18]:(k=a(`assistants.menu.edit`),t[17]=a,t[18]=k);let A=k,j;t[19]===a?j=t[20]:(j=a(`assistants.settings.delete`),t[19]=a,t[20]=j);let M=j;if(s.isPending||s.data?.supported&&s.data.enabled&&c.isPending){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Fi,{className:`oc-mobile-assistant-loading`,children:(0,$.jsx)(Ns,{})}),t[21]=e):e=t[21];let n;return t[22]!==i||t[23]!==O?(n=(0,$.jsx)(Ri,{title:O,className:i,surface:!1,children:e}),t[22]=i,t[23]=O,t[24]=n):n=t[24],n}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length>0){let e;t[25]===a?e=t[26]:(e=a(`assistants.settings.create`),t[25]=a,t[26]=e);let n;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(X,{name:`add`,className:`size-5`}),t[27]=n):n=t[27];let r;t[28]!==v||t[29]!==e?(r=(0,$.jsx)(K,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":e,onClick:v,children:n}),t[28]=v,t[29]=e,t[30]=r):r=t[30];let o;t[31]===c.data?o=t[32]:(o=(0,$.jsx)(Gi,{snapshot:c.data,rowClassName:`flex justify-end pb-2`}),t[31]=c.data,t[32]=o);let s;t[33]===a?s=t[34]:(s=a(`assistants.listAria`),t[33]=a,t[34]=s);let l;if(t[35]!==d||t[36]!==M||t[37]!==A||t[38]!==S||t[39]!==b||t[40]!==w||t[41]!==a){let e;t[43]!==M||t[44]!==A||t[45]!==S||t[46]!==b||t[47]!==w||t[48]!==a?(e=e=>{let t=se(e.name).displayName||e.name,n=Ki(e.latestMessagePreview,a);return(0,$.jsx)(Fs,{assistantID:e.id,avatarSeed:e.avatarSeed,unreadCount:e.unreadCount??0,displayName:t,summary:n,enabled:e.enabled,editLabel:A,deleteLabel:M,assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onOpen:()=>b(e.id),onEdit:()=>S(e.id),onDelete:()=>w(e)},e.id)},t[43]=M,t[44]=A,t[45]=S,t[46]=b,t[47]=w,t[48]=a,t[49]=e):e=t[49],l=d.map(e),t[35]=d,t[36]=M,t[37]=A,t[38]=S,t[39]=b,t[40]=w,t[41]=a,t[42]=l}else l=t[42];let u;t[50]!==s||t[51]!==l?(u=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-catalog`,role:`listbox`,"aria-label":s,children:l}),t[50]=s,t[51]=l,t[52]=u):u=t[52];let f=p!==null,m;t[53]!==p||t[54]!==E||t[55]!==f?(m=(0,$.jsx)(Wi,{assistant:p,open:f,onOpenChange:E}),t[53]=p,t[54]=E,t[55]=f,t[56]=m):m=t[56];let h;return t[57]!==i||t[58]!==O||t[59]!==r||t[60]!==o||t[61]!==u||t[62]!==m?(h=(0,$.jsxs)(Ri,{title:O,className:i,surface:!1,scrollsWithPage:!0,trailing:r,children:[o,u,m]}),t[57]=i,t[58]=O,t[59]=r,t[60]=o,t[61]=u,t[62]=m,t[63]=h):h=t[63],h}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`oc-mobile-assistant-onboarding-icon`,children:(0,$.jsx)(X,{name:`ai-agent`,className:`size-5`})}),t[64]=e):e=t[64];let n;t[65]===a?n=t[66]:(n=a(`assistants.onboarding.title`),t[65]=a,t[66]=n);let r;t[67]===n?r=t[68]:(r=(0,$.jsx)(`h2`,{children:n}),t[67]=n,t[68]=r);let o;t[69]===a?o=t[70]:(o=a(`assistants.onboarding.description`),t[69]=a,t[70]=o);let s;t[71]===o?s=t[72]:(s=(0,$.jsx)(`p`,{children:o}),t[71]=o,t[72]=s);let c;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),t[73]=c):c=t[73];let l;t[74]===a?l=t[75]:(l=a(`assistants.onboarding.action`),t[74]=a,t[75]=l);let u;t[76]!==v||t[77]!==l?(u=(0,$.jsxs)(K,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:v,children:[c,l]}),t[76]=v,t[77]=l,t[78]=u):u=t[78];let d;t[79]!==r||t[80]!==s||t[81]!==u?(d=(0,$.jsxs)(Fi,{className:`oc-mobile-assistant-onboarding`,children:[e,r,s,u]}),t[79]=r,t[80]=s,t[81]=u,t[82]=d):d=t[82];let f;return t[83]!==i||t[84]!==O||t[85]!==d?(f=(0,$.jsx)(Ri,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:d}),t[83]=i,t[84]=O,t[85]=d,t[86]=f):f=t[86],f}let N=s.isSuccess&&s.data.supported===!1,P=s.isError||s.data?.supported===!0&&s.data.enabled&&c.isError,F=s.data?.supported===!0&&(s.data.enabled===!1||c.data?.enabled===!1),I;t[87]!==a||t[88]!==P||t[89]!==N?(I=a(P?`assistants.state.unavailable`:N?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[87]=a,t[88]=P,t[89]=N,t[90]=I):I=t[90];let L=I;if(F&&!P){let e;t[91]===g?e=t[92]:(e=(0,$.jsx)(Ps,{onEnable:g}),t[91]=g,t[92]=e);let n;return t[93]!==i||t[94]!==O||t[95]!==e?(n=(0,$.jsx)(Ri,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-guide-host`,children:e}),t[93]=i,t[94]=O,t[95]=e,t[96]=n):n=t[96],n}let R;t[97]===O?R=t[98]:(R=(0,$.jsx)(`span`,{className:`oc-mobile-page-section-label`,children:O}),t[97]=O,t[98]=R);let z=N?`cloud-off`:`sparkling`,B;t[99]===z?B=t[100]:(B=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground`,children:(0,$.jsx)(X,{name:z,weight:`medium`,className:`size-5`})}),t[99]=z,t[100]=B);let ee;t[101]===L?ee=t[102]:(ee=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:L}),t[101]=L,t[102]=ee);let V;t[103]!==a||t[104]!==P||t[105]!==N?(V=P?null:(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-small leading-relaxed text-muted-foreground`,children:a(N?`assistants.state.unsupportedDescription`:`assistants.state.instanceDisabledDescription`)}),t[103]=a,t[104]=P,t[105]=N,t[106]=V):V=t[106];let H;t[107]!==B||t[108]!==ee||t[109]!==V?(H=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[B,ee,V]}),t[107]=B,t[108]=ee,t[109]=V,t[110]=H):H=t[110];let te;t[111]!==R||t[112]!==H?(te=(0,$.jsx)(ji,{label:R,cardClassName:`oc-mobile-assistant-state-card`,children:H}),t[111]=R,t[112]=H,t[113]=te):te=t[113];let W;return t[114]!==i||t[115]!==O||t[116]!==te?(W=(0,$.jsx)(Ri,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:te}),t[114]=i,t[115]=O,t[116]=te,t[117]=W):W=t[117],W}function Ls(e){return e.requestCreate}function Rs(e){let t=(0,Q.c)(16),{assistantID:n,onBack:r}=e,{t:i}=re(),[a,o]=(0,Z.useState)(null),s;t[0]===i?s=t[1]:(s=i(`assistants.title`),t[0]=i,t[1]=s);let c;t[2]===i?c=t[3]:(c=i(`settings.view.actions.back`),t[2]=i,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`div`,{ref:o}),t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==s||t[7]!==c?(u=(0,$.jsx)(ye,{title:s,backAriaLabel:c,onBack:r,trailing:l}),t[5]=r,t[6]=s,t[7]=c,t[8]=u):u=t[8];let d;t[9]!==n||t[10]!==r||t[11]!==a?(d=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-[var(--oc-mobile-page-inline-inset)] pb-[var(--oc-safe-area-bottom,env(safe-area-inset-bottom,0px))]`,children:(0,$.jsx)(Fi,{className:`oc-mobile-settings-detail-card h-full`,children:(0,$.jsx)(hn,{children:(0,$.jsx)(Mi,{assistantID:n,onItemDeleted:r,saveActionContainer:a},n)})})}),t[9]=n,t[10]=r,t[11]=a,t[12]=d):d=t[12];let f;return t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`div`,{"data-settings-view":`true`,"data-mobile-settings-stage":`page-content`,className:`oc-settings-workspace oc-settings-workspace-mobile flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[u,d]}),t[13]=u,t[14]=d,t[15]=f):f=t[15],f}function zs(e){let t=(0,Q.c)(13),{route:n}=e,{t:r}=re(),i;t[0]===r?i=t[1]:(i=r(`chat.btw.title`),t[0]=r,t[1]=i);let a;t[2]===r?a=t[3]:(a=r(`header.actions.backAria`),t[2]=r,t[3]=a);let o;t[4]!==i||t[5]!==a?(o=(0,$.jsx)(ye,{title:i,backAriaLabel:a,onBack:Bs}),t[4]=i,t[5]=a,t[6]=o):o=t[6];let s;t[7]!==n.directory||t[8]!==n.sessionId?(s=(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Vt,{scope:{sessionId:n.sessionId,directory:n.directory},foot:`page`})}),t[7]=n.directory,t[8]=n.sessionId,t[9]=s):s=t[9];let c;return t[10]!==o||t[11]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[o,s]}),t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function Bs(){sr.requestAnimatedBack(`root`)}var Vs=[{id:`projects`,icon:`folder-open`,labelKey:`mobile.tabs.projects`},{id:`assistant`,icon:`sparkling`,labelKey:`mobile.tabs.assistant`},{id:`scheduled`,icon:`calendar-schedule`,labelKey:`mobile.tabs.scheduled`},{id:`settings`,icon:`settings-3`,labelKey:`mobile.tabs.settings`}];function Hs(e){let t=(0,Q.c)(22),{activeTab:n,onTabChange:r,className:i,tabMarks:a}=e,{t:o}=re(),s=xe(),c;t[0]===o?c=t[1]:(c=o(`mobile.tabs.activity.loading`),t[0]=o,t[1]=c);let l=c,u;t[2]===r?u=t[3]:(u=e=>{r(e.currentTarget.dataset.tab)},t[2]=r,t[3]=u);let d=U(u),f;t[4]!==n||t[5]!==r?(f=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Vs.findIndex(e=>e.id===n),i=Vs[e.key===`Home`?0:e.key===`End`?Vs.length-1:(t+(e.key===`ArrowRight`?1:-1)+Vs.length)%Vs.length];r(i.id),document.getElementById(`mobile-tab-${i.id}`)?.focus()},t[4]=n,t[5]=r,t[6]=f):f=t[6];let p=U(f),m;t[7]===o?m=t[8]:(m=o(`mobile.nav.aria`),t[7]=o,t[8]=m);let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h={role:`tablist`},t[9]=h):h=t[9];let g;t[10]!==n||t[11]!==s||t[12]!==d||t[13]!==p||t[14]!==l||t[15]!==o||t[16]!==a?(g=Vs.map(e=>{let t=e.id===n,r=o(e.labelKey),i=e.id===`assistant`&&s>0,c=!i&&a?.[e.id]===`loading`,u=i?`mobile-tab-assistant-unread`:c?`mobile-tab-${e.id}-activity`:void 0;return(0,$.jsxs)(K,{id:`mobile-tab-${e.id}`,"data-tab":e.id,type:`button`,role:`tab`,variant:`ghost`,size:`sm`,"aria-controls":`mobile-tabpanel-${e.id}`,"aria-label":r,"aria-describedby":u,"aria-selected":t,tabIndex:t?0:-1,title:r,onClick:d,onKeyDown:p,className:G(`oc-mobile-tab-button min-w-0 flex-1 flex-col overflow-visible`,`text-xs font-medium leading-none tracking-tight text-muted-foreground`,`transition-[background-color,color,box-shadow,transform] duration-100`,`hover:bg-transparent hover:text-foreground`,`active:bg-interactive-active`,`motion-reduce:transition-none`,t&&[`bg-interactive-selection/55 text-primary`,`hover:bg-interactive-selection/55 hover:text-primary`,`font-semibold`]),children:[(0,$.jsxs)(`span`,{className:`relative inline-flex shrink-0 overflow-visible`,children:[(0,$.jsx)(X,{name:e.icon,weight:`medium`,className:`size-[23px] shrink-0`}),u?(0,$.jsx)(`span`,{id:u,role:c?`status`:void 0,"aria-label":c?l:void 0,"data-mobile-tab-activity":c?`loading`:void 0,className:`pointer-events-none absolute left-full -top-1 ml-0.5 inline-flex z-10`,children:i?(0,$.jsx)($i,{className:`h-[18px] min-w-[18px] bg-foreground px-1 text-[11px] font-bold tracking-normal text-background shadow-none ring-2 ring-background`}):(0,$.jsx)(`span`,{className:`inline-flex size-[18px] items-center justify-center rounded-full bg-foreground text-background ring-2 ring-background`,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin`})})}):null]}),(0,$.jsx)(`span`,{className:`oc-mobile-tab-label block max-w-full overflow-hidden text-ellipsis whitespace-nowrap`,children:r})]},e.id)}),t[10]=n,t[11]=s,t[12]=d,t[13]=p,t[14]=l,t[15]=o,t[16]=a,t[17]=g):g=t[17];let _;return t[18]!==i||t[19]!==m||t[20]!==g?(_=(0,$.jsx)(Bi,{as:`nav`,"aria-label":m,variant:`navigation`,surfaceProps:h,className:i,children:g}),t[18]=i,t[19]=m,t[20]=g,t[21]=_):_=t[21],_}function Us(e){return e.unreadCount>0?`unread`:e.working?`loading`:null}var Ws=`oc-native-ios-tab-bar`,Gs=`OpenChamberTabBar`,Ks=[`projects`,`assistant`,`scheduled`,`settings`],qs=R(Gs),Js=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function Ys(){return typeof window>`u`?!1:Js({isCapacitor:j(),platform:N(),pluginAvailable:z.isPluginAvailable(Gs),nativeUiEnabled:tr()})}var Xs=e=>e.classList.contains(`dark`)?`dark`:`light`,Zs=()=>er(`--primary`),Qs=e=>typeof e==`string`&&Ks.includes(e),$s=e=>typeof e==`string`&&Qs(e)?e:null,ec=(e,t)=>e.selectedTab===t.selectedTab&&e.appearance===t.appearance&&e.ariaLabel===t.ariaLabel&&e.accentColor===t.accentColor&&e.tabs.length===t.tabs.length&&e.tabs.every((e,n)=>e.id===t.tabs[n]?.id&&e.label===t.tabs[n]?.label&&e.badge===t.tabs[n]?.badge&&e.activity===!0==(t.tabs[n]?.activity===!0)&&(e.activity===!0?e.activityLabel??null:null)===(t.tabs[n]?.activity===!0?t.tabs[n]?.activityLabel??null:null)),tc=(e,t)=>{e.classList.toggle(Ws,t)},nc=(e,t)=>e&&!t,rc=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&ec(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},ic=()=>qs,ac=`mobile-overlay-root`;function oc(e){let t=(0,Q.c)(28),n=nr(),r;t[0]===n?r=t[1]:(r=n&&Ys(),t[0]=n,t[1]=r);let i=r,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=(0,Z.useRef)(!1),p=(0,Z.useRef)(!1),m=U(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=JSON.stringify(e.tabs.map(cc)),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:Xs(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:Zs(),t[5]=y):y=t[5];let b=y,x,S;t[6]===i?(x=t[7],S=t[8]):(x=()=>{if(!i||typeof document>`u`)return;let e=document.getElementById(ac);e||(e=document.createElement(`div`),e.id=ac,document.body.appendChild(e));let t=()=>u(Wt(e.children));t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[Ut]}),()=>n.disconnect()},S=[i],t[6]=i,t[7]=x,t[8]=S),(0,Z.useEffect)(x,S);let C;t[9]!==i||t[10]!==m?(C=()=>{if(!i)return;let e=!1,t=ic(),n=[];return t.addListener(`tabSelected`,e=>{let t=$s(e.tab);t&&m(t)}).then(t=>{if(e){t.remove();return}n.push(t)}),()=>{e=!0,d.current=null,t.hide();for(let e of n)e.remove();typeof document<`u`&&tc(document.documentElement,!1)}},t[9]=i,t[10]=m,t[11]=C):C=t[11];let w;t[12]===i?w=t[13]:(w=[i],t[12]=i,t[13]=w),(0,Z.useEffect)(C,w);let T;t[14]!==e.activeTab||t[15]!==e.ariaLabel||t[16]!==e.tabs||t[17]!==e.visible||t[18]!==i||t[19]!==l?(T=()=>{if(!i||p.current)return;let t=!1,n=ic(),r={tabs:e.tabs.map(sc),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=rc({visible:nc(e.visible,l),overlayHidden:f.current,lastState:d.current,nextState:r});return(async()=>{if(a.action===`skip`)return;if(a.action===`hide`){f.current=!0,n.hide();return}let e=await n.present(r);if(!t){if(e.adopted!==!0){p.current=!0,c(!0),o(!1),typeof document<`u`&&tc(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&tc(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&tc(document.documentElement,!1))}),()=>{t=!0}},t[14]=e.activeTab,t[15]=e.ariaLabel,t[16]=e.tabs,t[17]=e.visible,t[18]=i,t[19]=l,t[20]=T):T=t[20];let E;return t[21]!==e.activeTab||t[22]!==e.ariaLabel||t[23]!==e.visible||t[24]!==i||t[25]!==l||t[26]!==g?(E=[i,e.visible,l,e.activeTab,e.ariaLabel,v,b,g],t[21]=e.activeTab,t[22]=e.ariaLabel,t[23]=e.visible,t[24]=i,t[25]=l,t[26]=g,t[27]=E):E=t[27],(0,Z.useLayoutEffect)(T,E),!i||s?`web`:a?`native`:`pending`}function sc(e){return{id:e.id,label:e.label,badge:e.badge??null,activity:e.activity===!0,activityLabel:e.activity===!0?e.activityLabel??null:null}}function cc(e){return[e.id,e.label,e.badge??null,e.activity===!0,e.activity===!0?e.activityLabel??null:null]}function lc(e){let t=(0,Q.c)(50),{tabs:n,navigation:r,onTabChange:i,secondaryPages:a,showTabBar:o,tabBarCovered:s,className:c}=e,l=a===void 0?[]:a,u=o===void 0||o,d=s!==void 0&&s,{t:f}=re(),p=r.activeTab,m=l.slice(-2),h=m.at(-1)??null,g=h?.key??null,_=h?.depth,v=m.length>1?m[m.length-2].key:null,y;t[0]===p?y=t[1]:(y=()=>new Set([p]),t[0]=p,t[1]=y);let[b,x]=Z.useState(y);b.has(p)||x(e=>{if(e.has(p))return e;let t=new Set(e);return t.add(p),t});let S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(null),T=Z.useRef(new Map),E=Z.useRef(null),D=Z.useRef(!1),O=Z.useRef(``),k=U(()=>h?.onBack());ar({id:h?`mobile-secondary:${h.key}`:`mobile-secondary:inactive`,active:!!h,onBack:k,surfaceRef:S,underlayRef:C}),Z.useLayoutEffect(()=>{let e=g===null?null:T.current.get(g)??null,t=v===null?w.current:T.current.get(v)??null;S.current=e,C.current=t},[g,_,v]);let A;t[2]===h?A=t[3]:(A=[h],t[2]=h,t[3]=A),Z.useLayoutEffect(()=>{if(h){if(!D.current){let e=document.activeElement;E.current=e instanceof HTMLElement?e:null,D.current=!0}O.current!==h.key&&(O.current=h.key,S.current?.focus());return}if(D.current){D.current=!1,O.current=``;let e=E.current;E.current=null,e&&e.isConnected&&e.focus()}},A);let j;t[4]===i?j=t[5]:(j=e=>{i(e)},t[4]=i,t[5]=j);let M=U(j),N=xe(),P=ge(),F=be(),I;t[6]===f?I=t[7]:(I=f(`mobile.tabs.activity.loading`),t[6]=f,t[7]=I);let L=I,R;t[8]!==N||t[9]!==P?(R=Us({unreadCount:N,working:P}),t[8]=N,t[9]=P,t[10]=R):R=t[10];let z=R,B;t[11]===F?B=t[12]:(B=Us({unreadCount:0,working:F}),t[11]=F,t[12]=B);let ee=B,V;t[13]!==z||t[14]!==N||t[15]!==L||t[16]!==ee||t[17]!==f?(V=Vs.map(e=>{let t=e.id===`assistant`&&z===`loading`||e.id===`scheduled`&&ee===`loading`;return{id:e.id,label:f(e.labelKey),badge:e.id===`assistant`&&z===`unread`?N>99?`99+`:String(N):null,activity:t,activityLabel:t?L:null}}),t[13]=z,t[14]=N,t[15]=L,t[16]=ee,t[17]=f,t[18]=V):V=t[18];let H=V,te=u&&!d&&!h,W;t[19]===f?W=t[20]:(W=f(`mobile.nav.aria`),t[19]=f,t[20]=W);let ne;t[21]!==M||t[22]!==te||t[23]!==H||t[24]!==p||t[25]!==W?(ne={visible:te,activeTab:p,tabs:H,ariaLabel:W,onTabChange:M},t[21]=M,t[22]=te,t[23]=H,t[24]=p,t[25]=W,t[26]=ne):ne=t[26];let ie=oc(ne),K=ie===`native`,ae=u&&ie===`web`,oe=nr(),se,ce;t[27]!==oe||t[28]!==K?(se=()=>{if(!oe){cr.shutdown();return}K&&or(!0)&&cr.warm()},ce=[oe,K],t[27]=oe,t[28]=K,t[29]=se,t[30]=ce):(se=t[29],ce=t[30]),Z.useEffect(se,ce);let q;t[31]===c?q=t[32]:(q=G(`oc-mobile-floating-shell relative isolate flex h-full min-h-0 flex-col overflow-hidden text-foreground`,`bg-[var(--oc-mobile-page-background)]`,c),t[31]=c,t[32]=q);let J=h?!0:void 0,le=h?!0:void 0,ue;t[33]!==p||t[34]!==u||t[35]!==ae||t[36]!==f||t[37]!==n||t[38]!==b?(ue=Vs.map(e=>{let t=b.has(e.id);return(0,$.jsx)(`section`,{id:`mobile-tabpanel-${e.id}`,role:`tabpanel`,"aria-labelledby":ae?`mobile-tab-${e.id}`:void 0,"aria-label":ae?void 0:f(e.labelKey),hidden:p!==e.id,tabIndex:0,className:G(`scrollbar-none h-full min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--oc-mobile-page-inline-inset)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+1rem)] outline-none`,u?`pb-[calc(var(--oc-mobile-dock-height)+2.5rem+var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px)))]`:`pb-0`),children:t?n?.[e.id]??(0,$.jsx)(uc,{tab:e.id,icon:e.icon}):null},e.id)}),t[33]=p,t[34]=u,t[35]=ae,t[36]=f,t[37]=n,t[38]=b,t[39]=ue):ue=t[39];let de;t[40]!==w||t[41]!==J||t[42]!==le||t[43]!==ue?(de=(0,$.jsx)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":J,inert:le,className:`flex h-full min-h-0 flex-1 flex-col`,children:ue}),t[40]=w,t[41]=J,t[42]=le,t[43]=ue,t[44]=de):de=t[44];let fe=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||K?!0:void 0,inert:h||K?!0:void 0,children:ae?(0,$.jsx)(Hs,{activeTab:p,onTabChange:M,tabMarks:{assistant:z===`loading`?`loading`:null,scheduled:ee===`loading`?`loading`:null}}):null}):null,pe=m.map((e,t)=>{let n=t===m.length-1;return(0,$.jsx)(`div`,{ref:t=>{t?T.current.set(e.key,t):T.current.delete(e.key)},"data-mobile-secondary-page":`true`,"data-mobile-secondary-active":n?`true`:`false`,role:n?`dialog`:void 0,"aria-modal":n?!0:void 0,"aria-label":n?e.ariaLabel??f(`mobile.nav.secondaryPageAria`):void 0,"aria-hidden":!n||void 0,inert:!n||void 0,tabIndex:n?-1:void 0,className:G(`absolute inset-0 flex h-full min-h-0 flex-col overflow-hidden bg-background outline-none`,n?`z-50`:`z-40`),children:e.content},e.key)}),me;return t[45]!==q||t[46]!==de||t[47]!==fe||t[48]!==pe?(me=(0,$.jsxs)(`div`,{className:q,children:[de,fe,pe]}),t[45]=q,t[46]=de,t[47]=fe,t[48]=pe,t[49]=me):me=t[49],me}function uc(e){let t=(0,Q.c)(17),{tab:n,icon:r,className:i}=e,{t:a}=re(),o,s,c,l;if(t[0]!==i||t[1]!==r||t[2]!==a||t[3]!==n){let e=Vs.find(e=>e.id===n)??Vs[0];t[8]===i?c=t[9]:(c=G(`flex min-h-[70dvh] flex-col items-center justify-center gap-3 text-center`,i),t[8]=i,t[9]=c),l=(0,$.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:r??e.icon,className:`size-6`})}),o=`typography-ui-label font-semibold tracking-[-0.01em] text-foreground`,s=a(e.labelKey),t[0]=i,t[1]=r,t[2]=a,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];let u;t[10]!==o||t[11]!==s?(u=(0,$.jsx)(`h1`,{className:o,children:s}),t[10]=o,t[11]=s,t[12]=u):u=t[12];let d;return t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:c,children:[l,u]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}var dc={neutral:void 0,info:{color:`var(--status-info)`,backgroundColor:`var(--status-info-background)`},success:{color:`var(--status-success)`,backgroundColor:`var(--status-success-background)`},warning:{color:`var(--status-warning)`,backgroundColor:`var(--status-warning-background)`},error:{color:`var(--status-error)`,backgroundColor:`var(--status-error-background)`}},fc=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/g,``);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n.length<=1?t:n.length===2?n[0]:n.slice(-3,-1).join(`/`)};function pc({project:e,expanded:t,embedded:n=!1,onToggle:r,onOpenActions:i,className:a,highlightQuery:o}){let{t:s}=re(),[c,l]=Z.useState(!1),u=Z.useRef(null);u.current||=br({onPressedKeyChange:t=>l(t===e.id)}),Z.useEffect(()=>()=>u.current?.reset(),[]);let d=U(()=>{u.current?.consumeClick(e.id)||r(e)}),f=U(()=>i?.(e)),p=U(t=>{if(!i||t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0)return;let n=i;u.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{l(!1),n(e)}})}),m=U(e=>{u.current?.move(e.pointerId,e.clientX,e.clientY)}),h=U(e=>{u.current?.end(e.pointerId)}),g=U(e=>{u.current?.cancel(e.pointerId)}),_=U(t=>{if(!i)return;let n=i;t.preventDefault(),t.stopPropagation(),u.current?.openFromContextMenu(e.id,()=>{l(!1),n(e)})}),v=e.sessionCount===1?s(`mobile.sessions.project.sessionsSingle`):s(`mobile.sessions.project.sessionsPlural`,{count:e.sessionCount}),y=fc(e.path),b=(0,$.jsxs)(`article`,{"data-mobile-press-surface":`soft`,"data-pressed":c?`true`:void 0,className:G(`oc-mobile-project-card relative flex items-stretch overflow-hidden rounded-[var(--oc-mobile-surface-radius)]`,a),children:[(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-surface-trigger":!0,className:`oc-mobile-project-trigger flex min-w-0 flex-1 items-center text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-expanded":t,onClick:d,onPointerDown:p,onPointerMove:m,onPointerUp:h,onPointerCancel:g,onContextMenu:_,style:{touchAction:`pan-y`},children:[(0,$.jsx)(`span`,{className:G(`oc-mobile-project-icon oc-mobile-glass-control flex shrink-0 items-center justify-center rounded-full text-muted-foreground`),style:dc[e.tone??`neutral`],"aria-hidden":!0,children:(0,$.jsx)(X,{name:e.icon??`code-box`,className:`oc-mobile-project-icon-glyph`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-project-title oc-mobile-entity-title truncate font-semibold text-foreground`,children:o?gn(e.name,o):e.name}),e.active?(0,$.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-[var(--status-success)] shadow-[0_0_0_3px_color-mix(in_srgb,var(--status-success)_12%,transparent)]`,"aria-label":s(`mobile.sessions.activeProjectAria`)}):null]}),(0,$.jsxs)(`span`,{className:`oc-mobile-project-meta oc-mobile-entity-meta flex min-w-0 items-center text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:v}),e.activityLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.activityLabel})]}):null,y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,title:e.path,children:y})]}):null]})]}),(0,$.jsx)(X,{name:`arrow-down-s`,className:G(`oc-mobile-project-chevron shrink-0 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,t?`rotate-0`:`-rotate-90`)})]}),i?(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-project-action self-center rounded-full text-muted-foreground`,"aria-label":s(`sessions.sidebar.project.actions.projectMenu`),onClick:f,children:(0,$.jsx)(X,{name:`more-2`,className:`size-4`})}):null]});return n?b:(0,$.jsx)(Fi,{asChild:!0,children:b})}var mc=({hasPendingQuestion:e,hasPendingPermission:t,running:n,unread:r})=>e?`question`:t?`permission`:n?`running`:r?`completed-unread`:`idle`,hc=10,gc=`oc:mobile-session-row-revealed`,_c=e=>{window.dispatchEvent(new CustomEvent(gc,{detail:e}))};function vc({session:e,depth:t=0,hasChildren:n=!1,expanded:r=!1,paginationContinues:i=!1,onToggleChildren:a,onSelect:o,onPin:s,onArchive:c,onOpenActions:l,indicator:u,className:d,highlightQuery:f}){let{t:p}=re(),[m,h]=Z.useState(0),[g,_]=Z.useState(!1),v=Z.useRef(null),y=Z.useRef(!1),b=Z.useRef(null),x=Z.useRef(null);x.current||=br(),Z.useEffect(()=>()=>x.current?.reset(),[]),Z.useEffect(()=>{let t=t=>{t.detail!==e.id&&h(0)};return window.addEventListener(gc,t),()=>window.removeEventListener(gc,t)},[e.id]),Z.useEffect(()=>{h(0)},[e.id]);let S=U(()=>h(0)),C=m!==0,w=U(t=>{if(t.button!==0||t.pointerType!==`touch`&&t.pointerType!==`pen`)return;let n=b.current?.offsetWidth??0;n<=0||(v.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startOffset:m,actionWidth:n,intent:`pending`},y.current=!1,x.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{l(e)}}))}),T=U(t=>{let n=v.current;if(!n||n.pointerId!==t.pointerId)return;let r=t.clientX-n.startX,i=t.clientY-n.startY;if(x.current?.move(t.pointerId,t.clientX,t.clientY),n.intent===`pending`){let a=Math.abs(r),o=Math.abs(i);if(o>hc&&o>a){n.intent=`vertical`,v.current=null,x.current?.cancel(t.pointerId);return}if(a>hc&&a>o){n.intent=`horizontal`,_(!0),y.current=!0,x.current?.cancel(t.pointerId);try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}_c(e.id)}}if(n.intent!==`horizontal`)return;t.preventDefault();let a=Math.max(-n.actionWidth,Math.min(0,n.startOffset+r));h(a)}),E=U(e=>{let t=v.current;x.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(v.current=null,t.intent===`horizontal`&&(_(!1),h(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),D=U(e=>{let t=v.current;v.current=null,x.current?.cancel(e.pointerId),_(!1),h(t?.startOffset??0)}),O=U(()=>{if(!x.current?.consumeClick(e.id)){if(y.current){y.current=!1;return}if(m!==0){S();return}_c(e.id),o(e)}}),k=U(t=>{t.preventDefault(),t.stopPropagation(),x.current?.openFromContextMenu(e.id,()=>{l(e)})}),A=U(()=>{S(),s(e)}),j=U(()=>{S(),c(e)}),M=U(()=>l(e)),N=U(()=>a?.()),P=e.pinned?p(`sessions.sidebar.session.menu.unpin`):p(`sessions.sidebar.session.menu.pin`),F=u??mc({hasPendingQuestion:!1,hasPendingPermission:!1,running:!1,unread:!!e.unread}),I=F===`question`?p(`sessions.sidebar.session.status.questionRequired`):F===`permission`?p(`sessions.sidebar.session.status.permissionRequired`):F===`running`?p(`sessions.sidebar.session.status.active`):F===`completed-unread`?p(`sessions.sidebar.session.status.unread`):void 0;return e.kind===`pagination`?(0,$.jsx)(`div`,{className:G(`oc-mobile-session-row`,i&&`oc-mobile-session-pagination-continues`,d),children:(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-pagination-row`,style:{touchAction:`pan-y`},onClick:O,onPointerDown:()=>void 0,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium text-foreground typography-meta`,children:e.title}),e.subtitle?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.subtitle}):null,(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`})]})}):(0,$.jsxs)(`div`,{className:G(`oc-mobile-session-row relative isolate`,d),children:[(0,$.jsxs)(`div`,{ref:b,className:G(`oc-mobile-session-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,g?`transition-none`:`transition-transform duration-150 ease-out`,!C&&`invisible pointer-events-none`),style:{transform:`translate3d(calc(var(--oc-mobile-session-actions-width) + ${m}px), 0, 0)`,willChange:m===0?void 0:`transform`},"aria-hidden":!C,children:[(0,$.jsxs)(K,{type:`button`,variant:`secondary`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":P,tabIndex:C?0:-1,onClick:A,children:[(0,$.jsx)(X,{name:e.pinned?`unpin`:`pushpin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:P})]}),(0,$.jsxs)(K,{type:`button`,variant:`destructive`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 px-1`,"aria-label":p(`sessions.sidebar.bulkActions.archive`),tabIndex:C?0:-1,onClick:j,children:[(0,$.jsx)(X,{name:`archive`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:p(`sessions.sidebar.bulkActions.archive`)})]})]}),(0,$.jsxs)(`div`,{className:G(`oc-mobile-session-row-content relative z-10 flex items-center`,`text-foreground`,`ease-out motion-reduce:transition-none`,g?`transition-none`:`transition-[transform,background-color] duration-150`,e.archived&&`opacity-55`),"data-dragging":g?`true`:void 0,style:{transform:`translate3d(${m}px, 0, 0)`,willChange:m===0?void 0:`transform`},children:[n&&a?(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,className:`min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":p(r?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:N,children:(0,$.jsx)(X,{name:`arrow-down-s`,className:G(`size-3.5 transition-transform duration-150 motion-reduce:transition-none`,r?`rotate-0`:`-rotate-90`)})}):null,(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-row-main flex min-w-0 flex-1 items-center text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,style:{paddingLeft:16+Math.min(t,4)*12,touchAction:`pan-y`},onClick:O,onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:D,onContextMenu:k,children:[(0,$.jsx)(`span`,{className:`oc-mobile-session-status shrink-0`,"data-session-status":F,"aria-hidden":!I||void 0,"aria-label":I,title:I,children:F===`running`?(0,$.jsx)(Jr,{className:`motion-reduce:[&_svg]:animate-none`}):F===`question`?(0,$.jsx)(X,{name:`question`,className:`size-3.5 text-[var(--status-warning)]`}):F===`permission`?(0,$.jsx)(X,{name:`shield`,className:`size-3.5 text-destructive`}):(0,$.jsx)(`span`,{className:G(`oc-mobile-session-dot rounded-full`,F===`completed-unread`?`bg-[var(--status-info)]`:`bg-muted-foreground/35`)})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:G(`oc-mobile-session-title truncate`,e.unread?`font-semibold`:`font-medium`),children:f?gn(e.title,f):e.title}),e.changes?(0,$.jsx)(`span`,{className:`oc-mobile-session-changes shrink-0 tabular-nums text-muted-foreground`,children:e.changes}):null,e.archived?(0,$.jsx)(X,{name:`archive`,className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}):null]}),e.subtitle?(0,$.jsx)(`span`,{className:`oc-mobile-session-subtitle truncate text-muted-foreground`,children:f?gn(e.subtitle,f):e.subtitle}):null]}),(0,$.jsx)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-muted-foreground`,children:e.activityLabel?(0,$.jsx)(`span`,{className:`oc-mobile-session-time tabular-nums`,children:e.activityLabel}):null})]}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,className:`mr-1 min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":p(`sessions.sidebar.session.menu.label`),onClick:M,children:(0,$.jsx)(X,{name:`more-2`,className:`size-3.5`})})]})]})}var yc=Z.memo(vc),bc=10,xc=`oc:mobile-worktree-row-revealed`,Sc=e=>{window.dispatchEvent(new CustomEvent(xc,{detail:e}))};function Cc(e){let t=(0,Q.c)(10),n=ct(e.session.id),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={bootstrap:!1},t[0]=r):r=t[0];let i=Qe(e.session.id,e.session.directory,r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a={bootstrap:!1},t[1]=a):a=t[1];let o=it(e.session.id,e.session.directory,a).length>0,s=i.length>0,c=!!e.session.unread,l;t[2]!==n||t[3]!==o||t[4]!==s||t[5]!==c?(l=mc({hasPendingQuestion:o,hasPendingPermission:s,running:n,unread:c}),t[2]=n,t[3]=o,t[4]=s,t[5]=c,t[6]=l):l=t[6];let u=l,d;return t[7]!==u||t[8]!==e?(d=(0,$.jsx)(yc,{...e,indicator:u}),t[7]=u,t[8]=e,t[9]=d):d=t[9],d}var wc=Z.memo(Cc);function Tc(e){let t=(0,Q.c)(9),{sessions:n,onSelectSession:r,onPinSession:i,onArchiveSession:a,onOpenSessionActions:o,highlightQuery:s}=e,c;t[0]!==s||t[1]!==a||t[2]!==o||t[3]!==i||t[4]!==r||t[5]!==n?(c=n.map((e,t)=>{let c=e.kind===`pagination`&&n[t+1]?.kind===`pagination`,l=e.kind===`pagination`?yc:wc;return(0,$.jsx)(l,{session:e,paginationContinues:c,highlightQuery:s,onSelect:r,onPin:i,onArchive:a,onOpenActions:o},e.id)}),t[0]=s,t[1]=a,t[2]=o,t[3]=i,t[4]=r,t[5]=n,t[6]=c):c=t[6];let l;return t[7]===c?l=t[8]:(l=(0,$.jsx)($.Fragment,{children:c}),t[7]=c,t[8]=l),l}var Ec=Z.memo(Tc);function Dc({project:e,worktree:t,expanded:n,onToggle:r,onNewSession:i,onOpenActions:a,onDelete:o,highlightQuery:s}){let{t:c}=re(),l=`${e.id}::${t.id}`,u=!!(i||o),d=!!a,f=Number(!!i)+Number(!!o),[p,m]=Z.useState(0),[h,g]=Z.useState(!1),[_,v]=Z.useState(!1),y=Z.useRef(null),b=Z.useRef(!1),x=Z.useRef(null),S=Z.useRef(null);S.current||=br({onPressedKeyChange:e=>g(e===l)}),Z.useEffect(()=>()=>S.current?.reset(),[]),Z.useEffect(()=>{let e=e=>{e.detail!==l&&m(0)};return window.addEventListener(xc,e),()=>window.removeEventListener(xc,e)},[l]),Z.useEffect(()=>{m(0)},[l]);let C=U(()=>m(0)),w=p!==0,T=U(n=>{if(n.button===0&&(n.pointerType===`touch`||n.pointerType===`pen`)){if(u){let e=x.current?.offsetWidth??0;e>0&&(y.current={pointerId:n.pointerId,startX:n.clientX,startY:n.clientY,startOffset:p,actionWidth:e,intent:`pending`},b.current=!1)}d&&S.current?.start({pointerId:n.pointerId,key:l,clientX:n.clientX,clientY:n.clientY,onTrigger:()=>{g(!1),a?.(e,t)}})}}),E=U(e=>{let t=y.current;if(!t||t.pointerId!==e.pointerId){S.current?.move(e.pointerId,e.clientX,e.clientY);return}let n=e.clientX-t.startX,r=e.clientY-t.startY;if(S.current?.move(e.pointerId,e.clientX,e.clientY),t.intent===`pending`){let i=Math.abs(n),a=Math.abs(r);if(a>bc&&a>i){t.intent=`vertical`,y.current=null,S.current?.cancel(e.pointerId);return}if(i>bc&&i>a){t.intent=`horizontal`,v(!0),b.current=!0,S.current?.cancel(e.pointerId);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}Sc(l)}}if(t.intent!==`horizontal`)return;e.preventDefault();let i=Math.max(-t.actionWidth,Math.min(0,t.startOffset+n));m(i)}),D=U(e=>{let t=y.current;S.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(y.current=null,t.intent===`horizontal`&&(v(!1),m(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),O=U(e=>{let t=y.current;y.current=null,S.current?.cancel(e.pointerId),v(!1),m(t?.startOffset??0)}),k=U(()=>{if(!S.current?.consumeClick(l)){if(b.current){b.current=!1;return}if(p!==0){C();return}r()}}),A=U(n=>{d&&(n.preventDefault(),n.stopPropagation(),S.current?.openFromContextMenu(l,()=>{g(!1),a?.(e,t)}))}),j=U(()=>{C(),i?.(e,t)}),M=U(()=>{C(),o?.(e,t)}),N=U(()=>a?.(e,t)),P=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`oc-mobile-group-label-icon`,"aria-hidden":!0,children:(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left oc-mobile-entity-title font-semibold text-foreground`,children:s?gn(t.name,s):t.name}),(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:t.sessionCount===1?c(`mobile.sessions.project.sessionsSingle`):c(`mobile.sessions.project.sessionsPlural`,{count:t.sessionCount})}),(0,$.jsx)(X,{name:`arrow-down-s`,className:G(`size-3.5 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,n?`rotate-0`:`-rotate-90`)})]});return(0,$.jsxs)(`div`,{className:`oc-mobile-group-label oc-mobile-worktree-label relative isolate overflow-hidden`,children:[u?(0,$.jsxs)(`div`,{ref:x,className:G(`oc-mobile-worktree-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,_?`transition-none`:`transition-transform duration-150 ease-out`,!w&&`invisible pointer-events-none`),style:{width:`calc(${f} * var(--oc-mobile-worktree-action-width))`,transform:`translate3d(calc(100% + ${p}px), 0, 0)`,willChange:p===0?void 0:`transform`},"aria-hidden":!w,children:[i?(0,$.jsxs)(K,{type:`button`,variant:`secondary`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":c(`mobile.sessions.newSessionAria`),tabIndex:w?0:-1,onClick:j,children:[(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:c(`sessions.sidebar.project.actions.newSession`)})]}):null,o?(0,$.jsxs)(K,{type:`button`,variant:`destructive`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 px-1`,"aria-label":c(`mobile.projectEdit.deleteWorktreeAria`,{label:t.name}),tabIndex:w?0:-1,onClick:M,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:c(`mobile.projectEdit.deleteWorktreeConfirmButton`)})]}):null]}):null,(0,$.jsxs)(`div`,{className:G(`oc-mobile-worktree-label-content relative z-10 flex min-w-0 flex-1 items-center`,`ease-out motion-reduce:transition-none`,_?`transition-none`:`transition-transform duration-150`),style:{transform:`translate3d(${p}px, 0, 0)`,willChange:p===0?void 0:`transform`},"data-pressed":h?`true`:void 0,children:[(0,$.jsx)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-group-label-trigger oc-mobile-worktree-label-trigger`,"aria-expanded":n,onClick:k,onPointerDown:T,onPointerMove:E,onPointerUp:D,onPointerCancel:O,onContextMenu:A,style:{touchAction:`pan-y`},children:P}),d?(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-worktree-more rounded-full text-muted-foreground`,"aria-label":c(`agentManager.detail.actions.worktreeActionsAria`),onClick:N,children:(0,$.jsx)(X,{name:`more-2`,className:`size-3.5`})}):null]})]})}function Oc(e){let t=(0,Q.c)(88),{projects:n,pinnedSessions:r,inProgressSessions:i,onAddProject:a,onNewSession:o,onScanQr:s,onSwitchInstance:c,onToggleProject:l,onOpenProjectActions:u,onToggleWorktree:d,onNewWorktreeSession:f,onOpenWorktreeActions:p,onDeleteWorktree:m,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v,className:y}=e,b;t[0]===i?b=t[1]:(b=i===void 0?[]:i,t[0]=i,t[1]=b);let x=b,{t:S}=re(),[C,w]=Z.useState(!0),[T,E]=Z.useState(!1),D=U(a),O=U(o),k;t[2]===s?k=t[3]:(k=()=>s?.(),t[2]=s,t[3]=k);let A=U(k),j;t[4]===c?j=t[5]:(j=()=>c?.(),t[4]=c,t[5]=j);let M=U(j),N;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>E(e),t[6]=N):N=t[6];let P=U(N),F;t[7]===y?F=t[8]:(F=G(`relative isolate mx-auto flex w-full max-w-[26rem] flex-col gap-5`,y),t[7]=y,t[8]=F);let I;t[9]===S?I=t[10]:(I=S(`mobile.sessions.section.projects`),t[9]=S,t[10]=I);let L;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(ri,{mobile:!0}),t[11]=L):L=t[11];let R;t[12]===S?R=t[13]:(R=S(`mobile.projects.menu.label`),t[12]=S,t[13]=R);let z=T?`rotate-45`:`rotate-0`,B;t[14]===z?B=t[15]:(B=G(`size-5 transition-transform duration-150 motion-reduce:transition-none`,z),t[14]=z,t[15]=B);let ee;t[16]===B?ee=t[17]:(ee=(0,$.jsx)(X,{name:`add`,className:B}),t[16]=B,t[17]=ee);let V;t[18]!==ee||t[19]!==R?(V=(0,$.jsx)(Tn,{asChild:!0,children:(0,$.jsx)(K,{type:`button`,size:`mobileIcon`,className:`oc-mobile-round-control border-transparent bg-[var(--primary-base)] text-[var(--primary-foreground)] shadow-[0_10px_22px_color-mix(in_srgb,var(--primary-base)_22%,transparent)] hover:bg-[var(--primary-hover)] dark:bg-[var(--primary-base)] dark:hover:bg-[var(--primary-hover)]`,"aria-label":R,children:ee})}),t[18]=ee,t[19]=R,t[20]=V):V=t[20];let H;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(X,{name:`chat-new`,className:`size-4`}),t[21]=H):H=t[21];let te;t[22]===S?te=t[23]:(te=S(`mobile.projects.menu.newChat`),t[22]=S,t[23]=te);let W;t[24]!==O||t[25]!==te?(W=(0,$.jsxs)(wn,{className:`min-h-11`,onSelect:O,children:[H,te]}),t[24]=O,t[25]=te,t[26]=W):W=t[26];let ne;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(X,{name:`folder`,className:`size-4`}),t[27]=ne):ne=t[27];let ie;t[28]===S?ie=t[29]:(ie=S(`mobile.projects.menu.newProject`),t[28]=S,t[29]=ie);let ae;t[30]!==D||t[31]!==ie?(ae=(0,$.jsxs)(wn,{className:`min-h-11`,onSelect:D,children:[ne,ie]}),t[30]=D,t[31]=ie,t[32]=ae):ae=t[32];let oe;t[33]!==A||t[34]!==s||t[35]!==S?(oe=s?(0,$.jsxs)(wn,{className:`min-h-11`,onSelect:A,children:[(0,$.jsx)(X,{name:`scan-2`,className:`size-4`}),S(`mobile.projects.menu.scanQr`)]}):null,t[33]=A,t[34]=s,t[35]=S,t[36]=oe):oe=t[36];let se;t[37]!==M||t[38]!==c||t[39]!==S?(se=c?(0,$.jsxs)(wn,{className:`min-h-11`,onSelect:M,children:[(0,$.jsx)(X,{name:`server`,className:`size-4`}),S(`mobile.projects.menu.switchInstance`)]}):null,t[37]=M,t[38]=c,t[39]=S,t[40]=se):se=t[40];let ce;t[41]!==W||t[42]!==ae||t[43]!==oe||t[44]!==se?(ce=(0,$.jsxs)(Sn,{align:`end`,side:`bottom`,className:`min-w-44`,children:[W,ae,oe,se]}),t[41]=W,t[42]=ae,t[43]=oe,t[44]=se,t[45]=ce):ce=t[45];let q;t[46]!==P||t[47]!==T||t[48]!==V||t[49]!==ce?(q=(0,$.jsxs)($.Fragment,{children:[L,(0,$.jsxs)(En,{open:T,onOpenChange:P,children:[V,ce]})]}),t[46]=P,t[47]=T,t[48]=V,t[49]=ce,t[50]=q):q=t[50];let J;t[51]!==q||t[52]!==I?(J=(0,$.jsx)(Lr,{title:I,trailing:q}),t[51]=q,t[52]=I,t[53]=J):J=t[53];let le;t[54]!==x||t[55]!==_||t[56]!==v||t[57]!==g||t[58]!==h||t[59]!==C||t[60]!==r||t[61]!==S?(le=r.length>0||x.length>0?(0,$.jsx)(Fi,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":S(`mobile.sessions.section.pinned`),children:[(0,$.jsx)(pc,{project:{id:`__pinned__`,name:S(`mobile.sessions.section.pinned`),path:``,icon:`pushpin`,sessionCount:r.length+x.length},expanded:C,embedded:!0,onToggle:()=>w(Ac)}),C?(0,$.jsxs)(`div`,{className:`oc-mobile-project-groups`,role:`group`,children:[r.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(Ec,{sessions:r,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,x.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(Ec,{sessions:x,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null]}):null]})}):null,t[54]=x,t[55]=_,t[56]=v,t[57]=g,t[58]=h,t[59]=C,t[60]=r,t[61]=S,t[62]=le):le=t[62];let ue;t[63]!==D||t[64]!==_||t[65]!==m||t[66]!==f||t[67]!==u||t[68]!==v||t[69]!==p||t[70]!==g||t[71]!==h||t[72]!==l||t[73]!==d||t[74]!==n||t[75]!==S?(ue=n.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[52dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(`span`,{className:`mb-4 flex size-14 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:`folder-add`,className:`size-6`})}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:S(`mobile.sessions.empty.noProjectsTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:S(`mobile.sessions.empty.noProjectsDescription`)}),(0,$.jsxs)(K,{type:`button`,size:`lg`,className:`mt-4 min-h-10 rounded-full px-5`,onClick:D,children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),S(`sessions.sidebar.header.actions.addProject`)]})]}):n.map(e=>{let t=e.expanded,n=e.worktrees.find(kc)??(e.worktrees.length===1&&!e.worktrees[0]?.kind?e.worktrees[0]:void 0),r=e.worktrees.filter(e=>e!==n),i=n?.sessions??[];return(0,$.jsx)(Fi,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":e.name,children:[(0,$.jsx)(pc,{project:e,expanded:t,embedded:!0,onToggle:()=>l(e),onOpenActions:()=>u(e)}),t?(0,$.jsxs)(`div`,{className:`oc-mobile-project-groups`,role:`group`,"aria-label":e.name,children:[i.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(Ec,{sessions:i,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,r.map(t=>{let n=!!t.expanded;return(0,$.jsx)(ji,{className:`oc-mobile-worktree-group`,ariaLabel:t.name,label:(0,$.jsx)(Dc,{project:e,worktree:t,expanded:n,onToggle:()=>d(e,t),onNewSession:f,onOpenActions:p,onDelete:m}),children:n&&t.sessions.length>0?(0,$.jsx)(Ec,{sessions:t.sessions,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v}):null},t.id)})]}):null]})},e.id)}),t[63]=D,t[64]=_,t[65]=m,t[66]=f,t[67]=u,t[68]=v,t[69]=p,t[70]=g,t[71]=h,t[72]=l,t[73]=d,t[74]=n,t[75]=S,t[76]=ue):ue=t[76];let de;t[77]===S?de=t[78]:(de=S(`sessions.sidebar.header.actions.addProject`),t[77]=S,t[78]=de);let fe;t[79]!==D||t[80]!==de?(fe=(0,$.jsx)(`button`,{type:`button`,className:`sr-only`,onClick:D,children:de}),t[79]=D,t[80]=de,t[81]=fe):fe=t[81];let pe;return t[82]!==J||t[83]!==le||t[84]!==ue||t[85]!==fe||t[86]!==F?(pe=(0,$.jsxs)(`main`,{className:F,children:[J,le,ue,fe]}),t[82]=J,t[83]=le,t[84]=ue,t[85]=fe,t[86]=F,t[87]=pe):pe=t[87],pe}function kc(e){return e.kind===`main`}function Ac(e){return!e}function jc(e){let t=(0,Q.c)(13),{icon:n,label:r,onClick:i,destructive:a,disabled:o,spinning:s}=e,c=a!==void 0&&a,l=o!==void 0&&o,u=s!==void 0&&s,d;t[0]===i?d=t[1]:(d=()=>{ke(`light`),i()},t[0]=i,t[1]=d);let f=U(d),p=c?`destructive`:`ghost`,m=u?`size-5 animate-spin`:`size-5`,h;t[2]!==n||t[3]!==m?(h=(0,$.jsx)(X,{name:n,className:m}),t[2]=n,t[3]=m,t[4]=h):h=t[4];let g;t[5]===r?g=t[6]:(g=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[5]=r,t[6]=g);let _;return t[7]!==l||t[8]!==f||t[9]!==p||t[10]!==h||t[11]!==g?(_=(0,$.jsxs)(K,{type:`button`,variant:p,size:`lg`,className:`h-auto min-h-14 w-full justify-start gap-3 rounded-none supports-[corner-shape:squircle]:rounded-none px-4 leading-6 border-b border-[var(--surface-subtle)] last:border-b-0 active:bg-interactive-active dark:active:bg-interactive-active`,"data-mobile-press-feedback":`none`,disabled:l,onClick:f,children:[h,g]}),t[7]=l,t[8]=f,t[9]=p,t[10]=h,t[11]=g,t[12]=_):_=t[12],_}function Mc(e,t,n){return e.reduce((e,t)=>{let n=!!t.separated,r=e.at(-1);return r?.separated===n?r.items.push(t):e.push({separated:n,items:[t]}),e},[]).map(e=>(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl bg-[var(--surface-muted)]`,"data-mobile-action-group":e.separated?`separated`:`standard`,children:e.items.map(e=>(0,$.jsx)(jc,{icon:e.icon,label:Ei(e,t),onClick:n(e.onClick),destructive:e.destructive,disabled:e.disabled,spinning:e.spinning},e.id))},e.items[0]?.id))}function Nc(e){let t=(0,Q.c)(46),{open:n,target:r,actions:i,onOpenChange:a,refreshTranscriptDisabled:o,refreshTranscriptSpinning:s}=e,c=o!==void 0&&o,l=s!==void 0&&s,{t:u}=re(),d;t[0]===a?d=t[1]:(d=e=>()=>{a(!1),e?.()},t[0]=a,t[1]=d);let f=d,p;bb0:{if(!r){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[2]=e):e=t[2],p=e;break bb0}if(r.kind===`session`){let e;t[3]!==i.onArchive||t[4]!==i.onCopyLink||t[5]!==i.onDelete||t[6]!==i.onRefreshTranscript||t[7]!==i.onRename||t[8]!==i.onShare||t[9]!==i.onTogglePin||t[10]!==i.onUnshare||t[11]!==c||t[12]!==l||t[13]!==r.pinned||t[14]!==r.shared?(e=Zr({pinned:r.pinned,shared:r.shared,onRename:i.onRename,onTogglePin:i.onTogglePin,onShare:i.onShare,onCopyLink:i.onCopyLink,onUnshare:i.onUnshare,onRefreshTranscript:i.onRefreshTranscript,onArchive:i.onArchive,onDelete:i.onDelete,refreshTranscriptDisabled:c,refreshTranscriptSpinning:l}),t[3]=i.onArchive,t[4]=i.onCopyLink,t[5]=i.onDelete,t[6]=i.onRefreshTranscript,t[7]=i.onRename,t[8]=i.onShare,t[9]=i.onTogglePin,t[10]=i.onUnshare,t[11]=c,t[12]=l,t[13]=r.pinned,t[14]=r.shared,t[15]=e):e=t[15],p=e;break bb0}if(r.kind===`project`){let e;t[16]!==i.onCloseProject||t[17]!==i.onEditProject||t[18]!==i.onNewSession||t[19]!==i.onNewWorktree||t[20]!==i.onSyncSessions||t[21]!==r.gitRepository?(e=Di({gitRepository:r.gitRepository,onNewSession:i.onNewSession,onNewWorktree:i.onNewWorktree,onSyncSessions:i.onSyncSessions,onEditProject:i.onEditProject,onCloseProject:i.onCloseProject}),t[16]=i.onCloseProject,t[17]=i.onEditProject,t[18]=i.onNewSession,t[19]=i.onNewWorktree,t[20]=i.onSyncSessions,t[21]=r.gitRepository,t[22]=e):e=t[22],p=e;break bb0}let e;t[23]!==i.onDeleteWorktree||t[24]!==i.onNewSession?(e=Hr({onNewSession:i.onNewSession,onDeleteWorktree:i.onDeleteWorktree}),t[23]=i.onDeleteWorktree,t[24]=i.onNewSession,t[25]=e):e=t[25],p=e}let m=p;if(!r)return null;let h;t[26]===r.title?h=t[27]:(h=(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:r.title}),t[26]=r.title,t[27]=h);let g=r.title,_;t[28]===u?_=t[29]:(_=u(`mobile.surface.closeAria`),t[28]=u,t[29]=_);let v;t[30]===u?v=t[31]:(v=u(`mobile.sessions.sheet.resizeAria`),t[30]=u,t[31]=v);let y;t[32]!==m||t[33]!==f||t[34]!==u?(y=Mc(m,u,f),t[32]=m,t[33]=f,t[34]=u,t[35]=y):y=t[35];let b;t[36]===y?b=t[37]:(b=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain px-3 pb-3`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-5`,"data-page-scroll-lock":`true`,children:y})}),t[36]=y,t[37]=b);let x;return t[38]!==a||t[39]!==n||t[40]!==b||t[41]!==h||t[42]!==_||t[43]!==v||t[44]!==r.title?(x=(0,$.jsx)(Rn,{id:`mobile-row-actions-sheet`,open:n,onOpenChange:a,title:h,ariaLabel:g,closeAriaLabel:_,resizeAriaLabel:v,fitContent:!0,children:b}),t[38]=a,t[39]=n,t[40]=b,t[41]=h,t[42]=_,t[43]=v,t[44]=r.title,t[45]=x):x=t[45],x}function Pc(e,t){return e&&e.id===t.id&&e.kind===t.kind&&e.title===t.title&&e.subtitle===t.subtitle&&e.changes===t.changes&&e.activityLabel===t.activityLabel&&e.unread===t.unread&&e.pinned===t.pinned&&e.archived===t.archived&&e.active===t.active&&e.directory===t.directory&&e.expanded===t.expanded&&e.children===t.children?e:t}function Fc(e,t){if(!e||e.length===0)return t.slice();let n=new Map(e.map(e=>[e.id,e])),r=e.length===t.length,i=t.map((t,i)=>{let a=Pc(n.get(t.id)??e[i],t);return a!==e[i]&&(r=!1),a});if(r){let t=!0;for(let n=0;n<i.length;n+=1)if(i[n]!==e[n]){t=!1;break}if(t)return e}return i}var Ic=`__show_more__:`,Lc=`__show_fewer__:`,Rc=e=>e.startsWith(Ic),zc=e=>e.startsWith(Lc),Bc=e=>Rc(e)||zc(e),Vc=e=>{let t=Rc(e)?Ic:zc(e)?Lc:null;if(!t)return null;let n=e.slice(t.length),r=n.indexOf(`::`);return r<=0?null:{kind:t===`__show_more__:`?`more`:`fewer`,projectId:n.slice(0,r),bucketKey:n.slice(r+2)}},Hc=e=>e.parentID??null,Uc=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Wc=e=>{let t=e;return Uc(t.directory??t.project?.worktree??null)},Gc=(e,t)=>{if(t?.trim())return t.trim();let n=Uc(e);if(!n)return``;let r=n.split(`/`).filter(Boolean);return r[r.length-1]||n},Kc=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},qc=e=>{if(e<=0)return``;let t=Date.now()-e;if(t<6e4)return`now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return`${r}h`;let i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))},Jc=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},Yc=(e,t)=>e.worktrees.find(e=>Uc(e.path)===t)??null,Xc=(e,t)=>{let n=t?.trim();return n?`${e} · ${n}`:e},Zc=(e,t)=>yi(e,{pinnedSessionIds:t,omitPinnedSessions:!0}).map(e=>e.session);function Qc(){let{t:e}=re(),t=Be(),n=Se(e=>e.activeSessions),r=Se(e=>e.activePaginationByDirectory),i=Xe(e=>e.projects),a=at(e=>e.projectSortOrder),o=Z.useMemo(()=>xi(i,a),[i,a]),s=Xe(e=>e.activeProjectId),c=D(e=>e.currentDirectory),l=Ze(e=>e.currentSessionId),u=Ze(e=>e.availableWorktreesByProject),d=Zt(e=>e.orderByProject),f=Ne(),p=ss(e=>e.projectExpanded),m=ss(e=>e.worktreeExpanded),h=He(e=>e.index.session.unseenCount),[g,_]=Z.useState(new Map),v=Gr(),y=Z.useMemo(()=>$r(v,l),[l,v]),b=Z.useMemo(()=>o.map(e=>{let t=Uc(e.path);return{id:e.id,label:Gc(t,e.label),path:t,icon:e.icon,worktrees:Yt(d[e.id],u.get(t)??[])}}),[o,d,u]),x=Z.useMemo(()=>{let e=new Map(t.map(e=>[e.id,e])),r=n.map(t=>{let n=e.get(t.id);return n?dt(n,t):t}),i=new Set(r.map(e=>e.id));for(let e of t)i.has(e.id)||r.push(e);return r},[n,t]),S=Z.useMemo(()=>Nr(x,b.map(e=>({id:e.id,normalizedPath:e.path})),u,!1),[b,x,u]),C=Z.useMemo(()=>{let e=b.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===s,latestActivity:0})),t=new Map(e.map(e=>[e.project.id,e])),n=(e,t,n)=>{let r=Uc(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||n?.label||Gc(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a};for(let t of e){n(t,t.project.path,null);for(let e of t.project.worktrees)n(t,e.path,e)}for(let e of x){let r=S.bySessionId.get(e.id);if(!r)continue;let i=t.get(r.projectId);if(!i)continue;let a=r.kind===`worktree`?Yc(i.project,r.scopeDirectory):null;(a?n(i,a.path,a):n(i,i.project.path,null)).sessions.push(e)}for(let t of e)for(let e of t.buckets){e.sessions.sort((e,t)=>ut(t)-ut(e));let n=Zc(e.sessions,f);t.totalSessions+=n.length;for(let n of e.sessions){let e=Kc(n);e>t.latestActivity&&(t.latestActivity=e)}}return e},[s,S,f,b,x]),w=Z.useMemo(()=>{let e=new Map;for(let t of x)e.set(t.id,t);return e},[x]),T=Z.useMemo(()=>{let e=new Map;for(let t of b)e.set(t.id,t);return e},[b]),E=Z.useRef([]),O=Z.useRef([]),k=Z.useRef(new Map),{pinnedSessions:A,inProgressSessions:j}=Z.useMemo(()=>{let t=new Map(b.map(e=>[e.id,e])),n=e(`mobile.sessions.untitled`),r=new Map(E.current.map(e=>[e.id,e])),i=new Map(O.current.map(e=>[e.id,e])),a=(e,r,i)=>{let a=S.bySessionId.get(e.id),o=a?t.get(a.projectId):void 0;if(!o)return[];let s=a?.kind===`worktree`?Yc(o,a.scopeDirectory):null,c={id:e.id,directory:Wc(e),title:e.title?.trim()||n,subtitle:Xc(o.label,s?.branch),changes:Jn(qn(e))??void 0,activityLabel:qc(Kc(e))||void 0,unread:(h[e.id]??0)>0,pinned:r,archived:Jc(e),active:l===e.id};return[Pc(i.get(e.id),c)]},o=li(x,f).flatMap(e=>a(e,!0,r)),s=ti(x,f,v,h).flatMap(e=>a(e,!1,i)),c=Fc(E.current,o),u=Fc(O.current,s);return E.current=c,O.current=u,{pinnedSessions:c,inProgressSessions:u}},[l,S,f,b,v,x,e,h]),M=Z.useMemo(()=>{let e=new Map;for(let t of C){let n=t.project.worktrees.length>0;for(let r of t.buckets){let i=Zc(r.sessions,f).length;e.set(`${t.project.id}::${r.key}`,{path:r.path,rootCount:i,hasWorktrees:n})}}return e},[f,C]),N=Z.useMemo(()=>{let t=Uc(c),n=new Map,i=e=>(e.kind!==`pagination`&&n.set(e.id,e),e),a=C.map(a=>{let o=p[a.project.id]??!0,s=Qr(),c=a.project.icon?ln[a.project.icon]:void 0,u=a.buckets.map(o=>{let c=`${a.project.id}::${o.key}`,u=m[c]??!1,d=g.get(c)??s,p=Zc(o.sessions,f),_=yi(o.sessions,{pinnedSessionIds:f,omitPinnedSessions:!1}).map(e=>e.session),v=t=>{let r=Hc(t),a=(h[t.id]??0)>0&&!r,s={id:t.id,directory:o.path,title:t.title?.trim()||e(`mobile.sessions.untitled`),changes:Jn(qn(t))??void 0,activityLabel:qc(Kc(t))||void 0,unread:a,pinned:f.has(t.id),archived:Jc(t),active:l===t.id},c=Pc(k.current.get(t.id)??n.get(t.id),s);return i(c)},b=Xr(p,d,y).map(v),x=p.length-b.length,S=r.get(Uc(o.path)),C=S?.hasMore===!0,w=p.length>s&&d>s,T=[...b];w&&T.push({id:`${Lc}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showFewer`)}),(x>0||C)&&T.push({id:`${Ic}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showMore`),subtitle:S?.loadingMore?`…`:void 0});let E=Uc(o.path),D=!!(a.isActive&&t&&E&&(t===E||t.startsWith(`${E}/`))),O=o.worktree==null;return{id:o.key,name:O?e(`mobile.sessions.mainWorkspace`):o.label,path:o.path,kind:O?`main`:`worktree`,active:D,expanded:O?!0:u,sessionCount:p.length,sessions:T,catalogSessions:_.map(v)}});return{id:a.project.id,name:a.project.label,path:a.project.path,icon:c,sessionCount:a.totalSessions,activityLabel:qc(a.latestActivity)||void 0,active:a.isActive,expanded:o,worktrees:u}});return k.current=n,a},[r,y,c,l,f,p,C,e,h,g,m]),P=e=>{for(let[t,n]of M)if(t.startsWith(`${e}::`))return n.hasWorktrees;return!1},F=(e,t)=>M.get(`${e}::${t}`)?.rootCount??0,I=e=>Qr();return{projects:N,pinnedSessions:A,inProgressSessions:j,sessionById:w,projectMetaById:T,allSessions:x,projectHasWorktrees:P,getBucketRootCount:F,getBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;return g.get(n)??I(e)},getBucketPageSize:I,getBucketDirectory:(e,t)=>M.get(`${e}::${t}`)?.path??null,showMoreBucketSessions:(e,t)=>{let n=`${e}::${t}`,r=M.get(n),i=Qr(),a=Wr(),o=g.get(n)??i,s=r?.rootCount??0;if(_(e=>{let t=new Map(e),r=Math.max(i,e.get(n)??i,o);return t.set(n,r+a),t}),Math.max(i,o)+a<s)return;let c=r?.path,l=Uc(c);if(!l)return;let u=Se.getState().activePaginationByDirectory.get(l);u?.hasMore&&!u.loadingMore&&ze(l)},resetBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;_(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})}}}var $c=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function el({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,className:a}){let{t:o}=re(),{git:s}=Mn(),c=Ke(),l=Qc(),u=ss(e=>e.setProjectExpanded),d=ss(e=>e.setWorktreeExpanded),f=Pe(),p=Ne(),m=Ze(e=>e.archiveSessions),h=Ze(e=>e.updateSessionTitle),g=Ze(e=>e.requestSessionSmartTitle),_=Ze(e=>e.shareSession),v=Ze(e=>e.unshareSession),b=Ze(e=>e.openNewSessionDraft),x=rt(e=>e.openDraft),S=rt(e=>e.openSession),C=Xe(e=>e.projects),w=Xe(e=>e.setActiveProjectIdOnly),T=Xe(e=>e.removeProject),E=Lt(),[D,O]=Z.useState(null),[k,A]=Z.useState(!1),[j,M]=Z.useState(null),[N,P]=Z.useState(null),[F,I]=Z.useState(null),[L,R]=Z.useState(``),[z,B]=Z.useState(!1),[ee,V]=Z.useState(!1),[H,te]=Z.useState(null),[W,ie]=Z.useState(null),[G,ae]=Z.useState(null),oe=D?.kind===`session`?D.session.id:``,se=Ge(oe),ce=se?.type===`busy`||se?.type===`retry`,q=D?.kind===`session`?Wc(D.session):``,J=!!oe&&G===oe,le=!q||J||ce,ue=U(e=>{let t=new Map;for(let e of l.allSessions){let n=Hc(e);if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n}),de=U(()=>{A(!1),O(null)}),fe=U(t=>{if(Bc(t.id)){let e=Vc(t.id);if(!e)return;e.kind===`more`?l.showMoreBucketSessions(e.projectId,e.bucketKey):l.resetBucketVisibleCount(e.projectId,e.bucketKey);return}let n=l.sessionById.get(t.id),r=n&&Wc(n)||null;e({sessionId:t.id,directory:r})}),pe=U(e=>{Bc(e.id)||f(e.id)}),me=U(async e=>{if(Bc(e.id))return;let t=ue(e.id),{archivedIds:n,failedIds:r}=await m(t);n.length>0&&di({sessionIds:n,message:n.length===1?o(`sessions.sidebar.session.archive.success`):o(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:o(`sessions.sidebar.undo`),settingsLabel:o(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:n.length===1?o(`sessions.sidebar.session.archive.undoFailed`):o(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&Y.error(r.length===1?o(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):o(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}),he=U(()=>{if(!D||D.kind!==`session`)return;let e=D.session,t=Wc(e),n=se?.type??`idle`;!t||G===e.id||n===`busy`||n===`retry`||(ae(e.id),(async()=>{try{await E.refreshSessionTranscript(e.id,{directory:t}),Y.success(o(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{Y.error(o(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ae(t=>t===e.id?null:t)}})())}),ge=U(e=>{if(Bc(e.id))return;let t=l.sessionById.get(e.id);t&&(O({kind:`session`,session:t}),A(!0))}),_e=U(e=>{u(e.id,!e.expanded)}),ve=U((e,t)=>{d(`${e.id}::${t.id}`,!t.expanded)}),ye=U((e,t)=>{w(e.id),x({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),be=U(()=>{if(n){n();return}b()}),xe=U(e=>{let t=l.projectMetaById.get(e.id);t&&(O({kind:`project`,project:t,isGitRepository:!1}),A(!0),s.checkIsGitRepository(t.path).then(e=>{O(n=>$c(n,t.id,e))}).catch(()=>{O(e=>$c(e,t.id,!1))}))}),Se=U((e,t)=>{let n=y(t);return n?e.worktrees.find(e=>y(e.path)===n)||((Ze.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>y(e.path)===n)??null):null}),Ce=U((e,t)=>{let n=l.projectMetaById.get(e.id);n&&ye(n,t.path)}),we=U((e,t)=>{let n=l.projectMetaById.get(e.id);n&&(O({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),A(!0))}),Te=U((e,t)=>{let n=l.projectMetaById.get(e.id);if(!n)return;let r=Se(n,t.path);if(!r){Y.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}ie({project:n,worktree:r})}),Ee=U(e=>{te(e),w(e),V(!0)}),De=U(e=>{(async()=>{let t=e.worktrees;try{t=(await dn({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=Ze.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await et([e.path,...t.map(e=>e.path)],l.allSessions)})()}),Oe=U((e,t)=>{let n=H;if(V(!1),te(null),t?.sessionId){S({sessionId:t.sessionId,directory:e});return}x({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),ke=U(async e=>{try{if(!(await _(e.id))?.share?.url){Y.error(o(`sessions.sidebar.session.share.error`));return}Y.success(o(`sessions.sidebar.session.share.successTitle`),{description:o(`sessions.sidebar.session.share.successDescription`)})}catch{Y.error(o(`sessions.sidebar.session.share.error`))}}),Ae=U(async e=>{if((await ne(e)).ok){Y.success(o(`sessions.sidebar.session.menu.copied`));return}Y.error(o(`sessions.sidebar.session.share.copyUrlError`))}),je=U(async e=>{try{if(await v(e)){Y.success(o(`sessions.sidebar.session.unshare.success`));return}Y.error(o(`sessions.sidebar.session.unshare.error`))}catch{Y.error(o(`sessions.sidebar.session.unshare.error`))}}),Me=U(e=>{let t=ue(e.id);Vr({sessionIds:t,message:t.length===1?o(`sessions.sidebar.session.delete.success`):o(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:o(`sessions.sidebar.undo`),commitFailedMessage:o(`sessions.sidebar.session.delete.error`)})}),Fe=U(async()=>{if(!F)return;let e=L.trim();if(e)try{await h(F.id,e),I(null),R(``)}catch{Y.error(o(`sessions.sidebar.session.menu.rename`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),Ie=U(async()=>{if(!F||z)return;let e=F.id;I(null),R(``),B(!0);try{await g(e)}catch{Y.error(o(`sessions.sidebar.session.rename.smartTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{B(!1)}}),Le=Z.useMemo(()=>D?D.kind===`session`?{kind:`session`,title:D.session.title?.trim()||o(`mobile.sessions.untitled`),pinned:p.has(D.session.id),shared:!!D.session.share?.url}:D.kind===`project`?{kind:`project`,title:D.project.label,gitRepository:D.isGitRepository}:{kind:`worktree`,title:D.worktreeName}:null,[D,p,o]),Re=Z.useMemo(()=>{if(!D)return{};if(D.kind===`session`){let e=D.session;return{onRename:()=>{R(e.title?.trim()||o(`mobile.sessions.untitled`)),I(e)},onTogglePin:()=>f(e.id),onShare:c&&!e.share?.url?()=>{ke(e)}:void 0,onCopyLink:c&&e.share?.url?()=>{Ae(e.share.url)}:void 0,onUnshare:c&&e.share?.url?()=>{je(e.id)}:void 0,onRefreshTranscript:he,onArchive:()=>{me({id:e.id,title:e.title?.trim()||o(`mobile.sessions.untitled`)})},onDelete:()=>Me(e)}}if(D.kind===`project`){let e=D.project;return{onNewSession:()=>ye(e,e.path),onNewWorktree:()=>Ee(e.id),onSyncSessions:()=>De(e),onEditProject:()=>M(e.id),onCloseProject:()=>P(e)}}let{project:e,worktreePath:t}=D;return{onNewSession:()=>ye(e,t),onDeleteWorktree:()=>{let n=Se(e,t);if(!n){Y.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}ie({project:e,worktree:n})}}},[D,me,Ae,Me,he,Ee,De,ke,je,Se,c,ye,o,f]),ze=Z.useMemo(()=>{if(!j)return null;let e=C.find(e=>e.id===j),t=l.projectMetaById.get(j);if(!e||!t)return null;let n=D?.kind===`project`&&D.project.id===j?D.isGitRepository:t.worktrees.length>0;return{id:e.id,label:e.label?.trim()||t.label,path:y(e.path)||t.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:n,worktrees:t.worktrees}},[D,j,l.projectMetaById,C]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Oc,{className:a,projects:l.projects,pinnedSessions:l.pinnedSessions,inProgressSessions:l.inProgressSessions,onAddProject:t,onNewSession:be,onScanQr:r,onSwitchInstance:i,onToggleProject:_e,onOpenProjectActions:xe,onToggleWorktree:ve,onNewWorktreeSession:Ce,onOpenWorktreeActions:we,onDeleteWorktree:Te,onSelectSession:fe,onPinSession:pe,onArchiveSession:e=>{me(e)},onOpenSessionActions:ge}),(0,$.jsx)(Nc,{open:k,target:Le,actions:Re,refreshTranscriptDisabled:le,refreshTranscriptSpinning:J,onOpenChange:e=>{e?A(!0):de()}}),(0,$.jsx)(Jt,{open:ee,projectId:H,onOpenChange:e=>{V(e),e||te(null)},onWorktreeCreated:Oe}),W?(0,$.jsx)(fi,{open:!0,project:{id:W.project.id,path:W.project.path},worktree:W.worktree,onClose:()=>ie(null)}):null,(0,$.jsx)(xn,{open:!!N,title:o(`sessions.sidebar.project.actions.closeProject`),onClose:()=>P(null),closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>P(null),children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(K,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!N)return;let e=N;P(null),T(e.id),Y.success(o(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:o(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:o(`mobile.projects.closeConfirmMessage`,{title:N?.label??``})})}),(0,$.jsx)(xn,{open:!!F,title:o(`sessions.sidebar.session.menu.rename`),onClose:()=>{z||(I(null),R(``))},closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:z,onClick:()=>{I(null),R(``)},children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(K,{type:`button`,variant:`default`,className:`flex-1`,disabled:!L.trim()||z,onClick:()=>void Fe(),children:o(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),Fe()},children:[(0,$.jsx)(fn,{value:L,onChange:e=>R(e.target.value),autoFocus:!0,className:`h-12`,disabled:z}),(0,$.jsxs)(K,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:z,onClick:()=>void Ie(),children:[z?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),o(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(Yr,{open:j!==null,project:ze,onClose:()=>M(null)})]})}function tl(e){let t=(0,Q.c)(10),{children:n,content:r,className:i,contentClassName:a,showHeader:o}=e,s=o===void 0||o,{t:c}=re(),l;t[0]===c?l=t[1]:(l=c(`sessions.scheduledTasks.dialog.title`),t[0]=c,t[1]=l);let u;t[2]===a?u=t[3]:(u=G(`oc-mobile-scheduled-content`,a),t[2]=a,t[3]=u);let d=n??r,f;return t[4]!==i||t[5]!==s||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,$.jsx)(Ri,{title:l,className:i,surface:!1,scrollsWithPage:!0,showHeader:s,surfaceClassName:u,children:d}),t[4]=i,t[5]=s,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function nl(e){let t=(0,Q.c)(10),{className:n,contentClassName:r,instancesPage:i}=e,{t:a}=re(),o;t[0]===a?o=t[1]:(o=a(`mobile.settings.placeholder.title`),t[0]=a,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=[...Pr],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(Hi,{forceMobile:!0,isWindowed:!0,hideMobileHeader:!0,flowMobile:!0,autoOpenMobilePage:!0,visiblePageSlugs:s,mobileInstancesPage:i}),t[3]=i,t[4]=c);let l;return t[5]!==n||t[6]!==r||t[7]!==o||t[8]!==c?(l=(0,$.jsx)(Ri,{title:o,className:n,surface:!1,scrollsWithPage:!0,showHeader:!1,surfaceClassName:r,children:c}),t[5]=n,t[6]=r,t[7]=o,t[8]=c,t[9]=l):l=t[9],l}function rl(e){let t=(0,Q.c)(110),{onAddProject:n,onScanQr:r,onSwitchInstance:i,onEnableAssistants:a,instancesPage:o,instancesSecondaryPage:s,parentSessionTarget:c,registerSecondaryBackHandler:l,scheduledContent:u,renderChat:d,className:f}=e,p=c===void 0?null:c,{t:m}=re(),h=P(Sl),g=rt(),_=rt(xl),v=rt(bl),b=rt(yl),x=rt(vl),S=rt(_l),C=rt(gl),w=rt(hl),T=rt(ml),E=rt(pl),D=rt(fl),O=rt(dl),k=rt(ul),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A=[],t[0]=A):A=t[0],Z.useEffect(ll,A);let j=g.secondary?.kind===`chat`?g.secondary.btw??null:null,M=Z.useRef(null),N,F;t[1]===j?(N=t[2],F=t[3]):(N=()=>{let e=M.current;M.current=j,e&&e!==j&&$t.getState().clear({sessionId:e.sessionId,directory:e.directory}),j?Ht(Bt):Ct(Bt)},F=[j],t[1]=j,t[2]=N,t[3]=F),Z.useEffect(N,F);let I;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(I=[],t[4]=I):I=t[4],Z.useEffect(sl,I);let L;t[5]===_?L=t[6]:(L=e=>{e===`settings`&&P.getState().setSettingsPage(`home`),_(e)},t[5]=_,t[6]=L);let R=U(L),z;t[7]===v?z=t[8]:(z=e=>{v(e)},t[7]=v,t[8]=z);let B=U(z),ee;t[9]===w?ee=t[10]:(ee=()=>{w()},t[9]=w,t[10]=ee);let V=U(ee),H;t[11]===b?H=t[12]:(H=()=>{b()},t[11]=b,t[12]=H);let te=U(H),W;t[13]===x?W=t[14]:(W=e=>{x(e)},t[13]=x,t[14]=W);let ne=U(W),ie=Z.useRef(null),[G,K]=Z.useState(!1),ae;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>{ie.current=e},t[15]=ae):ae=t[15];let oe=U(ae),se;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>{K(e)},t[16]=se):se=t[16];let ce=U(se),q;t[17]!==V||t[18]!==C||t[19]!==k||t[20]!==T?(q=()=>{if(ie.current?.())return!0;let e=rt.getState().secondary;return e?.kind===`chat`&&e.btw?(k(),!0):e?.kind===`assistant`&&e.settingsAssistantID?(C(),!0):e?.kind===`chat`&&e.routes.length>1?(T(),!0):e?(V(),!0):!1},t[17]=V,t[18]=C,t[19]=k,t[20]=T,t[21]=q):q=t[21];let J=U(q),le=g.secondary!==null,ue;t[22]!==J||t[23]!==l?(ue=()=>{if(l)return l(()=>J()),()=>l(null)},t[22]=J,t[23]=l,t[24]=ue):ue=t[24];let de;t[25]!==J||t[26]!==l||t[27]!==le?(de=[l,le,J],t[25]=J,t[26]=l,t[27]=le,t[28]=de):de=t[28],Z.useEffect(ue,de);let fe=Ze(ol),pe;t[29]===fe?pe=t[30]:(pe=e=>fe?e.getDirectoryForSession(fe):null,t[29]=fe,t[30]=pe);let me=Ze(pe),he,ge;t[31]!==me||t[32]!==fe||t[33]!==D||t[34]!==O?(he=()=>{let e=rt.getState().secondary;if(e?.kind===`draft`&&fe){D({sessionId:fe,directory:me});return}if(e?.kind!==`chat`||!fe||st({sessionId:fe,directory:me})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==fe||y(t.directory)!==y(me))&&O({sessionId:fe,directory:me})},ge=[me,fe,D,O],t[31]=me,t[32]=fe,t[33]=D,t[34]=O,t[35]=he,t[36]=ge):(he=t[35],ge=t[36]),Z.useEffect(he,ge);let _e,ve;t[37]!==fe||t[38]!==p||t[39]!==E?(_e=()=>{let e=rt.getState().secondary;if(e?.kind!==`chat`||!p)return;let t=e.routes.at(-1);!t||t.sessionId!==fe||E({sessionId:p.id,directory:p.directory})},ve=[fe,p,E],t[37]=fe,t[38]=p,t[39]=E,t[40]=_e,t[41]=ve):(_e=t[40],ve=t[41]),Z.useEffect(_e,ve);let ye;t[42]!==ce||t[43]!==oe||t[44]!==u?(ye=typeof u==`function`?u(oe,ce):u,t[42]=ce,t[43]=oe,t[44]=u,t[45]=ye):ye=t[45];let be=ye,xe;t[46]!==te||t[47]!==n||t[48]!==r||t[49]!==i||t[50]!==B?(xe=(0,$.jsx)(el,{onOpenChat:B,onAddProject:n,onNewSession:te,onScanQr:r,onSwitchInstance:i}),t[46]=te,t[47]=n,t[48]=r,t[49]=i,t[50]=B,t[51]=xe):xe=t[51];let Se;t[52]!==a||t[53]!==ne?(Se=(0,$.jsx)(Is,{onEnable:a,onOpenAssistant:ne}),t[52]=a,t[53]=ne,t[54]=Se):Se=t[54];let Ce;t[55]===be?Ce=t[56]:(Ce=(0,$.jsx)(tl,{showHeader:!1,children:be}),t[55]=be,t[56]=Ce);let we;t[57]===o?we=t[58]:(we=(0,$.jsx)(nl,{instancesPage:o}),t[57]=o,t[58]=we);let Te;t[59]!==xe||t[60]!==Se||t[61]!==Ce||t[62]!==we?(Te={projects:xe,assistant:Se,scheduled:Ce,settings:we},t[59]=xe,t[60]=Se,t[61]=Ce,t[62]=we,t[63]=Te):Te=t[63];let Ee=Te,De=g.secondary?.kind??null,Oe;bb0:{if(!De){Oe=null;break bb0}if(De===`assistant`){let e=g.secondary?.kind===`assistant`?g.secondary.settingsAssistantID:void 0,n;t[64]===m?n=t[65]:(n=m(`assistants.title`),t[64]=m,t[65]=n);let r=!e,i;t[66]!==S||t[67]!==r?(i=(0,$.jsx)(Zi,{activeOverride:r,onMobileBack:al,onMobileOpenSettings:S}),t[66]=S,t[67]=r,t[68]=i):i=t[68];let a;t[69]!==J||t[70]!==n||t[71]!==i?(a={key:`assistant-secondary`,depth:1,ariaLabel:n,onBack:J,content:i},t[69]=J,t[70]=n,t[71]=i,t[72]=a):a=t[72];let o;t[73]!==J||t[74]!==e||t[75]!==m?(o=e?[{key:`assistant-settings:${e}`,depth:2,ariaLabel:m(`assistants.conversation.openSettings`),onBack:J,content:(0,$.jsx)(Rs,{assistantID:e,onBack:il})}]:[],t[73]=J,t[74]=e,t[75]=m,t[76]=o):o=t[76];let s;t[77]!==a||t[78]!==o?(s=[a,...o],t[77]=a,t[78]=o,t[79]=s):s=t[79],Oe=s;break bb0}if(De===`instances`){let e;t[80]===m?e=t[81]:(e=m(`mobile.settings.switchInstance`),t[80]=m,t[81]=e);let n;t[82]!==J||t[83]!==s||t[84]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:J,content:s}],t[82]=J,t[83]=s,t[84]=e,t[85]=n):n=t[85],Oe=n;break bb0}if(g.secondary?.kind===`draft`){let e;t[86]===m?e=t[87]:(e=m(`mobile.nav.secondaryPageAria`),t[86]=m,t[87]=e);let n;t[88]===d?n=t[89]:(n=d({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[88]=d,t[89]=n);let r;t[90]!==J||t[91]!==e||t[92]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:J,content:n}],t[90]=J,t[91]=e,t[92]=n,t[93]=r):r=t[93],Oe=r;break bb0}if(g.secondary?.kind!==`chat`){let e;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[94]=e):e=t[94],Oe=e;break bb0}let e=g.secondary.routes,n=g.secondary.btw,r;if(t[95]!==n||t[96]!==J||t[97]!==d||t[98]!==e||t[99]!==m){let i=e.slice(n?-1:-2),a=e.length-i.length+1,o=i.map((e,t)=>{let r=!n&&t===i.length-1;return{key:e.key,depth:a+t,ariaLabel:m(`mobile.nav.secondaryPageAria`),onBack:J,content:d({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:r})}});r=n?[...o,{key:`chat-btw`,depth:e.length+1,ariaLabel:m(`chat.btw.title`),onBack:J,content:(0,$.jsx)(zs,{route:n})}]:o,t[95]=n,t[96]=J,t[97]=d,t[98]=e,t[99]=m,t[100]=r}else r=t[100];Oe=r}let ke=Oe,Ae;t[101]===ke?Ae=t[102]:(Ae=ke??[],t[101]=ke,t[102]=Ae);let je=G||h,Me;return t[103]!==f||t[104]!==g||t[105]!==R||t[106]!==Ae||t[107]!==je||t[108]!==Ee?(Me=(0,$.jsx)(lc,{className:f,navigation:g,onTabChange:R,tabs:Ee,secondaryPages:Ae,tabBarCovered:je}),t[103]=f,t[104]=g,t[105]=R,t[106]=Ae,t[107]=je,t[108]=Ee,t[109]=Me):Me=t[109],Me}function il(){sr.requestAnimatedBack(`root`)}function al(){return sr.requestAnimatedBack(`root`)}function ol(e){return e.currentSessionId}function sl(){return cl}function cl(){return Ct(Bt)}function ll(){return qe()}function ul(e){return e.popBtw}function dl(e){return e.replaceChatSession}function fl(e){return e.materializeDraftSession}function pl(e){return e.reconcileChatPredecessor}function ml(e){return e.popChatSession}function hl(e){return e.closeSecondary}function gl(e){return e.popAssistantSettings}function _l(e){return e.pushAssistantSettings}function vl(e){return e.openAssistant}function yl(e){return e.openDraft}function bl(e){return e.openSession}function xl(e){return e.setActiveTab}function Sl(e){return e.isCommandPaletteOpen}function Cl(e){let t=(0,Q.c)(30),{percentage:n,pending:r}=e,i=r!==void 0&&r,{t:a}=re(),o,s,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==n||t[2]!==a){c=i?0:mn(n)??0;let e=vn(n);s=i?`var(--surface-muted-foreground)`:e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,o=2*Math.PI*7.5,l=`0 0 18 18`,u=`size-[18px] -rotate-90`,d=`progressbar`,t[12]===a?f=t[13]:(f=a(`contextUsage.aria.label`),t[12]=a,t[13]=f),t[14]!==i||t[15]!==a?(p=i?a(`contextUsage.pending`):void 0,t[14]=i,t[15]=a,t[16]=p):p=t[16],m=i?void 0:Math.round(c),t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m}else o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11];let h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[17]=h):h=t[17];let g=o*(1-c/100),_;t[18]!==o||t[19]!==s||t[20]!==g?(_=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:s,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:o,strokeDashoffset:g,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[18]=o,t[19]=s,t[20]=g,t[21]=_):_=t[21];let v;return t[22]!==_||t[23]!==l||t[24]!==u||t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m?(v=(0,$.jsxs)(`svg`,{viewBox:l,className:u,role:d,"aria-label":f,"aria-valuetext":p,"aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:[h,_]}),t[22]=_,t[23]=l,t[24]=u,t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=v):v=t[29],v}function wl(e){let t=(0,Q.c)(16),{title:n,subtitle:r,onBack:i,onOpenMenu:a,menuOpen:o,elevated:s,trailing:c}=e,l=o!==void 0&&o,u=s!==void 0&&s,{t:d}=re(),f=U(i),p=U(a),m;t[0]===d?m=t[1]:(m=d(`header.actions.backAria`),t[0]=d,t[1]=m);let h=u||l,g;t[2]===d?g=t[3]:(g=d(`mobile.menu.titleAria`),t[2]=d,t[3]=g);let _;t[4]!==p||t[5]!==l||t[6]!==g?(_=[{icon:`more-2`,ariaLabel:g,onClick:p,pressed:l}],t[4]=p,t[5]=l,t[6]=g,t[7]=_):_=t[7];let v;return t[8]!==f||t[9]!==r||t[10]!==m||t[11]!==h||t[12]!==_||t[13]!==n||t[14]!==c?(v=(0,$.jsx)(ye,{title:n,subtitle:r,backAriaLabel:m,onBack:f,overlay:!0,elevated:h,trailing:c,actions:_}),t[8]=f,t[9]=r,t[10]=m,t[11]=h,t[12]=_,t[13]=n,t[14]=c,t[15]=v):v=t[15],v}var Tl=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},El=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),Dl=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,Ol=e=>{let{totalTokens:t,contextLimit:n,isDraft:r}=e;if(!r&&t===null)return{pending:!0,percentage:0,tokens:`—`,colorClass:`text-muted-foreground`};if(t===null||r||t<=0||n<=0)return null;let i=Math.min(t/n*100,999);return{percentage:i,tokens:`${El(t)}/${El(n)}`,colorClass:Dl(i)}},kl=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`user`)continue;let r=typeof n.model?.providerID==`string`&&n.model.providerID.trim().length>0?n.model.providerID:void 0,i=typeof n.model?.modelID==`string`&&n.model.modelID.trim().length>0?n.model.modelID:void 0;if(r&&i)return{providerID:r,modelID:i}}return null},Al=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),jl=e=>{let t=e.usedPercent;return typeof t!=`number`||!Number.isFinite(t)?`text-foreground`:t>=80?`text-[var(--status-error)]`:t>=50?`text-[var(--status-warning)]`:`text-foreground`},Ml=e=>{let t=(0,Q.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,$.jsx)(X,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},Nl=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=re(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(on,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map(e=>{let t=r===`remaining`?e.window.remainingPercent:e.window.usedPercent,n=yn(e.window.valueLabel,t),i=Cn(e.window.resetAt,e.window.resetAfterFormatted??e.window.resetAtFormatted,a);return(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:e.subtitle?`${e.subtitle} · ${e.label}`:e.label}),i?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground/70`,children:i}):null]}),(0,$.jsx)(`span`,{className:G(`shrink-0 typography-ui-label font-semibold tabular-nums`,jl(e.window)),children:n===`-`?``:n})]},e.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 typography-micro text-muted-foreground`,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,$.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},Pl=e=>{let t=(0,Q.c)(47),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l}=e,{t:u}=re(),d=Z.useRef(null),[f,p]=Z.useState(n),[m,h]=Z.useState(!1),g,_;t[0]!==n||t[1]!==f?(g=()=>{if(n){p(!0),h(!1);return}if(!f)return;h(!0);let e=window.setTimeout(()=>{p(!1),h(!1)},140);return()=>window.clearTimeout(e)},_=[n,f],t[0]=n,t[1]=f,t[2]=g,t[3]=_):(g=t[2],_=t[3]),Z.useEffect(g,_);let v,y;if(t[4]!==r||t[5]!==n?(v=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},y=[r,n],t[4]=r,t[5]=n,t[6]=v,t[7]=y):(v=t[6],y=t[7]),Z.useEffect(v,y),!f)return null;let b;t[8]===u?b=t[9]:(b=u(`mobile.surface.closeAria`),t[8]=u,t[9]=b);let x;t[10]===r?x=t[11]:(x=e=>{e.preventDefault(),r()},t[10]=r,t[11]=x);let S;t[12]!==b||t[13]!==x?(S=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":b,onPointerDown:x}),t[12]=b,t[13]=x,t[14]=S):S=t[14];let C;t[15]===u?C=t[16]:(C=u(`mobile.header.openMetadataAria`),t[15]=u,t[16]=C);let w=m&&`pointer-events-none`,T;t[17]===w?T=t[18]:(T=G(`pointer-events-auto absolute inset-x-3 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.5rem)] overflow-y-auto overscroll-contain rounded-[20px] oc-mobile-overlay-surface oc-mobile-overlay-surface--translucent p-2 will-change-transform`,w),t[17]=w,t[18]=T);let E=`${m?`session-metadata-out`:`session-metadata-in`} ${m?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,D;t[19]===E?D=t[20]:(D={animation:E,maxHeight:`min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-mobile-detail-navigation-height, 3.5rem) - 1rem))`},t[19]=E,t[20]=D);let O;t[21]===u?O=t[22]:(O=u(`mobile.header.metadata.branch`),t[21]=u,t[22]=O);let k;t[23]!==a||t[24]!==O?(k=(0,$.jsx)(Ml,{iconName:`git-branch`,label:O,children:a}),t[23]=a,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==i||t[27]!==u?(A=i?(0,$.jsx)(Ml,{iconNode:(0,$.jsx)(Cl,{percentage:i.percentage,pending:i.pending}),label:u(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsx)(`span`,{className:G(`font-semibold`,i.colorClass),children:i.pending?u(`contextUsage.pending`):`${i.percentage.toFixed(1)}%`}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:i.tokens})]})}):null,t[26]=i,t[27]=u,t[28]=A):A=t[28];let j;t[29]!==c||t[30]!==l||t[31]!==s||t[32]!==o?(j=(0,$.jsx)(Nl,{groups:o,displayMode:s,isLoading:c,timeFormatPreference:l}),t[29]=c,t[30]=l,t[31]=s,t[32]=o,t[33]=j):j=t[33];let M;t[34]!==k||t[35]!==A||t[36]!==j?(M=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[k,A,j]}),t[34]=k,t[35]=A,t[36]=j,t[37]=M):M=t[37];let N;t[38]!==T||t[39]!==D||t[40]!==M||t[41]!==C?(N=(0,$.jsx)(`div`,{ref:d,role:`dialog`,"aria-label":C,className:T,style:D,onPointerDown:eu,children:M}),t[38]=T,t[39]=D,t[40]=M,t[41]=C,t[42]=N):N=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(`style`,{children:`
|
|
5
|
+
`)}`.trim()),P([])}),Ee=U(async()=>{if(!s)return;let e=s,t=ae.map(e=>e.path).sort();if(t.length===0){Y.error(a(`gitView.toast.selectFileToDescribe`));return}M(!0);try{let{message:n}=await St(e,t);E(n.subject?.trim()??``),P(Array.isArray(n.highlights)?n.highlights:[])}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.generateCommitMessageFailed`))}finally{M(!1)}}),De=async(e={})=>{if(!s)return;let t=s;if(!T.trim()){Y.error(a(`gitView.toast.enterCommitMessage`));return}let n=ae.map(e=>e.path).sort();if(n.length===0){Y.error(a(`gitView.toast.selectFileToCommit`));return}w(e.pushAfter?`commitAndPush`:`commit`);try{if(await o.createGitCommit(t,T.trim(),{files:n}),Y.success(a(`gitView.toast.commitCreated`)),E(``),P([]),e.pushAfter){let e=c?.tracking?.split(`/`)[0],n=q.find(t=>t.name===e)??q[0];if(!n)throw Error(a(`mobile.changes.noRemote`));S(`sync`);let r=`${n.name}/`,i=c?.tracking?.startsWith(r)?c.tracking.slice(r.length):void 0;await o.gitFetch(t,{remote:n.name}),((await o.getGitStatus(t)).behind??0)>0&&await o.gitPull(t,{remote:n.name,branch:i,rebase:!0}),((await o.getGitStatus(t)).ahead??0)>0&&await o.gitPush(t),await ge(t,!1),await ve(t).promise}else await ge(t,!1)}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{w(null),e.pushAfter&&S(null)}},Oe=Z.useMemo(()=>{let e=[];return ae.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:ae,actionSymbol:`-`,actionAllLabel:a(`gitView.changes.unstageAllAria`),getActionLabel:e=>a(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void be([e],`unstage`),onActionAll:e=>void be(e,`unstage`),onViewDiff:e=>xe(e,!0),onRevertFile:Ce,showRevertActions:!1,accent:!0}),oe.length>0&&e.push({id:`unstaged`,title:a(`gitView.changes.title`),entries:oe,actionSymbol:`+`,actionAllLabel:a(`gitView.changes.stageAllAria`),getActionLabel:e=>a(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void be([e],`stage`),onActionAll:e=>void be(e,`stage`),onViewDiff:e=>xe(e,!1),onRevertFile:Ce}),e},[Ce,xe,be,ae,a,oe]),ke=t=>(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[i?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.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":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c?.current||s||``})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:t})]});return s?u&&l===null?ke((0,$.jsx)(_o,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):l===!1?ke((0,$.jsx)(_o,{icon:!0,message:a(`gitView.empty.notGitRepository`),description:a(`gitView.empty.notGitRepositoryDescription`)})):v.type===`diff`?(0,$.jsx)(`div`,{ref:b,className:`h-full min-h-0`,children:(0,$.jsx)(vo,{path:v.path,diff:le,fileExists:he,error:me,loading:pe,targetLine:v.targetLine,onBack:Se,onRetry:()=>te(e=>e+1),hideHeader:i})}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.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":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c?.current||s})]}),(0,$.jsx)(si,{syncAction:x,remotes:q,onSync:e=>void ye(`sync`,e),disabled:C!==null||u,aheadCount:c?.ahead??0,behindCount:c?.behind??0,trackingRemoteName:c?.tracking?.split(`/`)[0],hasUncommittedChanges:(c?.files?.length??0)>0})]}),G?(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(ii,{stagedCount:se,unstagedCount:ce,onLoad:()=>ie(!0)})}):K.length>0?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-4 pt-4`,children:(0,$.jsx)(oi,{groups:Oe,diffStats:c?.diffStats,revertingPaths:D,onRevertAll:we,isRevertingAll:k,headerBackgroundClassName:`bg-transparent`,onVisiblePathsChange:I})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-4 pt-3`,children:(0,$.jsx)(pi,{stagedCount:ae.length,commitMessage:T,onCommitMessageChange:E,generatedHighlights:N,onInsertHighlights:Te,onGenerateMessage:Ee,isGeneratingMessage:j,onCommit:()=>void De({pushAfter:!1}),onCommitAndPush:()=>void De({pushAfter:!0}),commitAction:C,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(_o,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):ke((0,$.jsx)(_o,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},_o=e=>{let t=(0,Q.c)(13),{message:n,description:r,loading:i,icon:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c;t[0]===o?c=t[1]:(c=o?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):null,t[0]=o,t[1]=c);let l;t[2]===s?l=t[3]:(l=s?(0,$.jsx)(X,{name:`git-branch`,className:`size-6 text-muted-foreground`}):null,t[2]=s,t[3]=l);let u;t[4]===n?u=t[5]:(u=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[4]=n,t[5]=u);let d;t[6]===r?d=t[7]:(d=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[6]=r,t[7]=d);let f;return t[8]!==c||t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[c,l,u,d]})}),t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f},vo=e=>{let t=(0,Q.c)(20),{path:n,diff:r,fileExists:i,error:a,loading:o,targetLine:s,onBack:c,onRetry:l,hideHeader:u}=e,d=u!==void 0&&u,{t:f}=re(),p;t[0]===n?p=t[1]:(p=vr(n)||`text`,t[0]=n,t[1]=p);let m=p,h;t[2]!==d||t[3]!==c||t[4]!==n||t[5]!==f?(h=d?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":f(`header.actions.backAria`),onClick:c,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-2`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:n})})]}),t[2]=d,t[3]=c,t[4]=n,t[5]=f,t[6]=h):h=t[6];let g;t[7]!==r||t[8]!==a||t[9]!==i||t[10]!==m||t[11]!==o||t[12]!==l||t[13]!==n||t[14]!==f||t[15]!==s?(g=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:a?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:f(`mobile.changes.diffDetail.loadFailed`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:a}),(0,$.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,onClick:l,children:f(`diffView.actions.retry`)})]})}):o?(0,$.jsx)(_o,{loading:!0,message:f(`diffView.state.loadingDiff`)}):i?r?r.isBinary?(0,$.jsx)(_o,{icon:!0,message:f(`diffView.binary.unavailable`)}):_r(n)?(0,$.jsx)(_o,{icon:!0,message:f(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(Hn,{className:`h-full overflow-y-auto overflow-x-hidden p-3 pwa-overlay-scroll`,"data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:(0,$.jsx)(Kr,{original:r.original,modified:r.modified,language:m,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:s,layout:`inline`})}):(0,$.jsx)(_o,{loading:!0,message:f(`diffView.state.loadingDiff`)}):(0,$.jsx)(_o,{icon:!0,message:f(`mobile.changes.diffDetail.missingTitle`),description:f(`mobile.changes.diffDetail.missingDescription`)})}),t[7]=r,t[8]=a,t[9]=i,t[10]=m,t[11]=o,t[12]=l,t[13]=n,t[14]=f,t[15]=s,t[16]=g):g=t[16];let _;return t[17]!==h||t[18]!==g?(_=(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19],_},yo=e(T(),1),bo=`data-oc-motion-id`,xo=`data-oc-sheet-overscroll`,So=`html, body { overscroll-behavior-y: none; }`,Co=[`input`,`textarea`,`select`,`[contenteditable]:not([contenteditable="false"])`,`[data-mobile-sheet-no-dismiss]`].join(`, `),wo=e=>e.closest(`[data-oc-motion-id]`)?.getAttribute(`data-oc-motion-id`)??null,To=e=>{try{let t=e.contentDocument;return t?t.scrollingElement??t.documentElement:null}catch{return null}},Eo=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)&&e<=1&&t>0,Do=(e,t,n)=>e?!0:Eo(t,n),Oo=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.Element},ko=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLElement},Ao=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLStyleElement},jo=(e,t)=>{if(typeof e.item==`function`){let n=e.item(t);if(n)return n}return e[t]??null},Mo=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=jo(e,n);if(r?.identifier===t)return r}return null},No=(e,t)=>{try{let n=e.defaultView?.getComputedStyle(t);if(!n)return!1;let r=n.overflowY;return(r===`auto`||r===`scroll`||r===`overlay`)&&t.scrollHeight>t.clientHeight+1}catch{return!1}},Po=(e,t)=>{let n=[],r=new Set,i=t=>{!t||r.has(t)||No(e,t)&&(r.add(t),n.push(t))},a=Oo(e,t)?t:null;for(;a&&(ko(e,a)&&i(a),a!==e.documentElement&&a!==e.body);)a=a.parentElement;let o=e.scrollingElement??e.documentElement;return ko(e,o)&&i(o),n},Fo=(e,t)=>{let n=Po(e,t);if(n.length===0){let t=(e.scrollingElement??e.documentElement)?.scrollTop??1/0;return Number.isFinite(t)&&t<=1}return n.every(e=>e.scrollTop<=1)},Io=e=>{let t=e.closest(`[${bo}]`);if(t instanceof HTMLElement){let e=t.getBoundingClientRect().height;if(Number.isFinite(e)&&e>0)return e}return window.innerHeight||1},Lo=e=>{let t=null,n=()=>{t?.(),t=null;let n=(()=>{try{return e.contentDocument}catch{return null}})();if(!n)return;let r=wo(e);if(!r)return;let i=null;if(!Ao(n,n.querySelector(`style[${xo}]`))){let e=n.createElement(`style`);e.setAttribute(xo,`true`),e.textContent=So,(n.head??n.documentElement).appendChild(e),i=e}let a=null,o=()=>{a?.active&&a.controller.finish(`cancel`),a=null},s=t=>{if(o(),t.touches.length!==1||(Oo(n,t.target)?t.target:null)?.closest(Co)||!Fo(n,t.target))return;let r=jo(t.touches,0);if(!r)return;let i=Io(e);a={touchId:r.identifier,startX:r.screenX,startY:r.screenY,lastY:r.screenY,lastTime:t.timeStamp,lastVelocityTime:t.timeStamp,velocity:0,motionDistance:i,commitDistance:Un(i,.1,40,64),active:!1,controller:null}},c=t=>{if(!a)return;if(t.touches.length!==1){o();return}let i=Mo(t.touches,a.touchId);if(!i){o();return}let s=i.screenY-a.startY,c=i.screenX-a.startX,l=t.timeStamp-a.lastTime;if(a.velocity=Wn(a.velocity,i.screenY-a.lastY,l,t.timeStamp-a.lastVelocityTime,1),i.screenY!==a.lastY&&l>0&&(a.lastVelocityTime=t.timeStamp),a.lastY=i.screenY,a.lastTime=t.timeStamp,!a.active){if(!Fo(n,t.target)){a=null;return}if(!Do(!1,To(e)?.scrollTop??0,s)){a=null;return}if(!In(`bottom`,c,s,8,1))return;let i=Bn(r);if(!i?.begin(`dismiss`)){a=null;return}a={...a,active:!0,controller:i}}let u=a;if(!u.active)return;t.preventDefault();let d=Fn(`bottom`,c,s);u.controller.update(zn(d,u.motionDistance))},l=e=>{if(!a)return;let t=a,n=Mo(e.changedTouches,t.touchId);if(a=null,!t.active)return;if(!n){t.controller.finish(`cancel`);return}let r=e.timeStamp-t.lastTime;t.velocity=Wn(t.velocity,n.screenY-t.lastY,r,e.timeStamp-t.lastVelocityTime,1),n.screenY!==t.lastY&&r>0&&(t.lastVelocityTime=e.timeStamp),t.lastY=n.screenY,t.lastTime=e.timeStamp;let i=n.screenY-t.startY,o=n.screenX-t.startX,s=Fn(`bottom`,o,i),c=Ln(s,t.velocity,t.commitDistance,.65,12);t.controller.finish(c?`commit`:`cancel`),e.preventDefault()},u=()=>o();n.addEventListener(`touchstart`,s,{capture:!0,passive:!0}),n.addEventListener(`touchmove`,c,{capture:!0,passive:!1}),n.addEventListener(`touchend`,l,{capture:!0,passive:!1}),n.addEventListener(`touchcancel`,u,{capture:!0,passive:!0}),t=()=>{o(),n.removeEventListener(`touchstart`,s,!0),n.removeEventListener(`touchmove`,c,!0),n.removeEventListener(`touchend`,l,!0),n.removeEventListener(`touchcancel`,u,!0);try{i?.remove()}catch{}i=null}};return e.addEventListener(`load`,n),n(),()=>{e.removeEventListener(`load`,n),t?.()}},Ro=fr(()=>B(()=>import(`./ToolOutputDialog-SMP_kNn6.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]))),zo=25e4,Bo=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Vo=e=>{let t=Bo(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},Ho=e=>{let t=Bo(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},Uo=(e,t)=>{let n=Bo(e),r=Bo(t);return!r||n===r?Vo(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},Wo=e=>{if(typeof e!=`number`||!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`],n=e/1024;for(let e of t){if(n<1024||e===t[t.length-1])return`${n.toFixed(n>=10?0:1)} ${e}`;n/=1024}return``},Go=e=>/\.(md|mdx|markdown)$/i.test(e),Ko=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return`/api/fs/serve${t.startsWith(`/`)?t:`/${t}`}`},qo=e=>l().authenticatedAsset(Ko(e)),Jo=e=>{let t=(0,Q.c)(148),{onClose:n,initialFilePath:r,directFilePreview:i,hideFileHeader:a}=e,o=r===void 0?null:r,s=i!==void 0&&i,c=a!==void 0&&a,{t:l}=re(),{files:u}=Mn(),d=yr()??null,f;t[0]===d?f=t[1]:(f=Bo(d),t[0]=d,t[1]=f);let p=f,m;t[2]!==o||t[3]!==p?(m=()=>{let e=Bo(o);return e?{type:`file`,path:e,returnDirectory:Ho(e)??p}:{type:`browser`,directory:p}},t[2]=o,t[3]=p,t[4]=m):m=t[4];let[h,g]=Z.useState(m),_=Z.useRef(null),[v,y]=Z.useState(``),b=P(ns),x=P(rs),S,C;t[5]===p?(S=t[6],C=t[7]):(S=()=>{p&&g(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:Ho(e.path)??p}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:p})},C=[p],t[5]=p,t[6]=S,t[7]=C),Z.useEffect(S,C);let w,T;t[8]!==b||t[9]!==p||t[10]!==x?(T=()=>{if(!b||!p)return;let e=Bo(b);if(!e){x(null);return}y(``),g({type:`file`,path:e,returnDirectory:Ho(e)??p}),x(null)},w=[b,p,x],t[8]=b,t[9]=p,t[10]=x,t[11]=w,t[12]=T):(w=t[11],T=t[12]),Z.useEffect(T,w);let E=h.type===`browser`?h.directory:h.returnDirectory,D=h.type===`browser`?h.directory:``,O=h.type===`file`?h.path:``,[k,A]=Z.useState(`preview`),j;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{A(`preview`)},t[13]=j):j=t[13];let M;t[14]===O?M=t[15]:(M=[O],t[14]=O,t[15]=M),Z.useEffect(j,M);let N=Zn(v,250),F;t[16]===v?F=t[17]:(F=v.trim(),t[16]=v,t[17]=F);let I=F,L;t[18]===N?L=t[19]:(L=N.trim(),t[18]=N,t[19]=L);let R=L,z;t[20]!==D||t[21]!==p?(z={scopeDirectory:p,directory:D},t[20]=D,t[21]=p,t[22]=z):z=t[22];let B=!!D,ee;t[23]===B?ee=t[24]:(ee={enabled:B,refetchOnMount:`always`},t[23]=B,t[24]=ee);let V=xr(z,ee),H;t[25]!==D||t[26]!==R?(H={directory:D,query:R,maxResults:40},t[25]=D,t[26]=R,t[27]=H):H=t[27];let te=!!(D&&R),W;t[28]===te?W=t[29]:(W={enabled:te},t[28]=te,t[29]=W);let ie=Cr(H,W),K;t[30]!==O||t[31]!==u||t[32]!==k?(K=O&&u.readFile&&(!gr(O)||k===`source`)&&(!_r(O)||O.toLowerCase().endsWith(`.svg`)),t[30]=O,t[31]=u,t[32]=k,t[33]=K):K=t[33];let ae=!!K,oe;t[34]!==O||t[35]!==p?(oe={scopeDirectory:p,path:O},t[34]=O,t[35]=p,t[36]=oe):oe=t[36];let se;t[37]===ae?se=t[38]:(se={enabled:ae},t[37]=ae,t[38]=se);let ce=Sr(oe,se),q;t[39]!==O||t[40]!==p?(q={scopeDirectory:p,path:O},t[39]=O,t[40]=p,t[41]=q):q=t[41];let J;t[42]===ae?J=t[43]:(J={enabled:ae},t[42]=ae,t[43]=J),wr(q,J);let le=V.data?.entries.slice().sort(is)??[],ue;t[44]!==V.error||t[45]!==l?(ue=V.error?V.error instanceof Error?V.error.message:l(`mobile.files.error.listFailed`):null,t[44]=V.error,t[45]=l,t[46]=ue):ue=t[46];let de=ue,fe=V.isFetching,pe;t[47]===ie.data?pe=t[48]:(pe=ie.data??[],t[47]=ie.data,t[48]=pe);let me=pe,he=!!(I&&R&&v===N&&ie.isFetching),ge;t[49]!==ce.data||t[50]!==l?(ge=ce.data&&ce.data.length>zo?`${ce.data.slice(0,zo)}\n\n${l(`mobile.files.file.truncated`)}`:ce.data??``,t[49]=ce.data,t[50]=l,t[51]=ge):ge=t[51];let _e=ge,ve;t[52]!==O||t[53]!==ce.error||t[54]!==u||t[55]!==l?(ve=O&&!u.readFile?l(`mobile.files.error.readUnavailable`):ce.error?ce.error instanceof Error?ce.error.message:l(`filesView.error.readFileFailed`):null,t[52]=O,t[53]=ce.error,t[54]=u,t[55]=l,t[56]=ve):ve=t[56];let ye=ve,be=ae&&ce.isFetching,xe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(xe=e=>{y(``),g({type:`browser`,directory:e})},t[57]=xe):xe=t[57];let Se=xe,Ce;t[58]!==E||t[59]!==p?(Ce=e=>{g({type:`file`,path:e,returnDirectory:E||p})},t[58]=E,t[59]=p,t[60]=Ce):Ce=t[60];let we=Ce,Te;t[61]!==s||t[62]!==n||t[63]!==h.returnDirectory||t[64]!==h.type?(Te=()=>h.type===`file`?s?(n?.(),!0):(g({type:`browser`,directory:h.returnDirectory}),!0):!1,t[61]=s,t[62]=n,t[63]=h.returnDirectory,t[64]=h.type,t[65]=Te):Te=t[65];let Ee=U(Te),De=h.type===`file`,Oe;t[66]!==Ee||t[67]!==De?(Oe={id:`mobile-files-detail`,active:De,layer:`overlay`,onBack:Ee,surfaceRef:_},t[66]=Ee,t[67]=De,t[68]=Oe):Oe=t[68],ar(Oe);let ke;t[69]===l?ke=t[70]:(ke=async e=>{(await ne(e)).ok||Y.error(l(`mobile.files.toast.copyFailed`))},t[69]=l,t[70]=ke);let Ae=ke,je;t[71]!==_e||t[72]!==l?(je=async()=>{(await ne(_e)).ok?Y.success(l(`mobile.files.toast.contentCopied`)):Y.error(l(`mobile.files.toast.copyFailed`))},t[71]=_e,t[72]=l,t[73]=je):je=t[73];let Me=je;if(!p){let e;t[74]===l?e=t[75]:(e=l(`mobile.files.empty.noDirectory`),t[74]=l,t[75]=e);let n;return t[76]===e?n=t[77]:(n=(0,$.jsx)(ts,{message:e}),t[76]=e,t[77]=n),n}if(h.type===`file`){let e;t[78]!==Ae||t[79]!==h.path?(e=()=>void Ae(h.path),t[78]=Ae,t[79]=h.path,t[80]=e):e=t[80];let n;t[81]===Me?n=t[82]:(n=()=>void Me(),t[81]=Me,t[82]=n);let r;return t[83]!==Ee||t[84]!==_e||t[85]!==ye||t[86]!==c||t[87]!==k||t[88]!==be||t[89]!==h.path||t[90]!==e||t[91]!==n?(r=(0,$.jsx)(`div`,{ref:_,className:`flex h-full min-h-0 flex-col`,children:(0,$.jsx)(Qo,{path:h.path,content:_e,error:ye,isLoading:be,hideHeader:c,htmlViewMode:k,onHtmlViewModeChange:A,onBack:Ee,onCopyPath:e,onCopyContent:n})}),t[83]=Ee,t[84]=_e,t[85]=ye,t[86]=c,t[87]=k,t[88]=be,t[89]=h.path,t[90]=e,t[91]=n,t[92]=r):r=t[92],r}let Ne;t[93]!==p||t[94]!==h.directory||t[95]!==l?(Ne=h.directory===p?l(`mobile.files.rootDirectory`):Vo(h.directory),t[93]=p,t[94]=h.directory,t[95]=l,t[96]=Ne):Ne=t[96];let Pe=Ne,Fe;t[97]!==v||t[98]!==me?(Fe=v.trim()?me:[],t[97]=v,t[98]=me,t[99]=Fe):Fe=t[99];let Ie=Fe,Le,Re,ze,Be;if(t[100]!==n||t[101]!==v||t[102]!==p||t[103]!==h.directory||t[104]!==l){let e=Ho(h.directory),r=h.directory!==p&&e!==null&&(e===p||e.startsWith(`${p}/`)),i=r&&!v.trim(),a=r?e:null;Be=`flex h-full flex-col overflow-hidden bg-background text-foreground`,Le=`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[109]!==n||t[110]!==l?(Re=n?(0,$.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":l(`mobile.surface.closeAria`),onClick:n,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,t[109]=n,t[110]=l,t[111]=Re):Re=t[111],ze=i&&a?(0,$.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":l(`mobile.files.backToParentAria`,{name:Vo(a)}),onClick:()=>Se(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}):null,t[100]=n,t[101]=v,t[102]=p,t[103]=h.directory,t[104]=l,t[105]=Le,t[106]=Re,t[107]=ze,t[108]=Be}else Le=t[105],Re=t[106],ze=t[107],Be=t[108];let Ve;t[112]===Pe?Ve=t[113]:(Ve=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:Pe})}),t[112]=Pe,t[113]=Ve);let He;t[114]===l?He=t[115]:(He=l(`mobile.files.refreshAria`),t[114]=l,t[115]=He);let Ue;t[116]===V?Ue=t[117]:(Ue=()=>void V.refetch(),t[116]=V,t[117]=Ue);let We;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(We={touchAction:`manipulation`},t[118]=We):We=t[118];let Ge=fe&&`animate-spin`,Ke;t[119]===Ge?Ke=t[120]:(Ke=G(`size-5`,Ge),t[119]=Ge,t[120]=Ke);let qe;t[121]===Ke?qe=t[122]:(qe=(0,$.jsx)(X,{name:`refresh`,className:Ke}),t[121]=Ke,t[122]=qe);let Je;t[123]!==He||t[124]!==Ue||t[125]!==qe?(Je=(0,$.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":He,onClick:Ue,style:We,children:qe}),t[123]=He,t[124]=Ue,t[125]=qe,t[126]=Je):Je=t[126];let Ye;t[127]!==Le||t[128]!==Re||t[129]!==ze||t[130]!==Ve||t[131]!==Je?(Ye=(0,$.jsxs)(`header`,{className:Le,children:[Re,ze,Ve,Je]}),t[127]=Le,t[128]=Re,t[129]=ze,t[130]=Ve,t[131]=Je,t[132]=Ye):Ye=t[132];let Xe;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[133]=Xe):Xe=t[133];let Ze;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=e=>y(e.target.value),t[134]=Ze):Ze=t[134];let Qe;t[135]===l?Qe=t[136]:(Qe=l(`mobile.files.search.placeholder`),t[135]=l,t[136]=Qe);let $e;t[137]!==v||t[138]!==Qe?($e=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[Xe,(0,$.jsx)(fn,{type:`text`,inputMode:`search`,value:v,onChange:Ze,placeholder:Qe,className:`h-11 pl-9`})]})}),t[137]=v,t[138]=Qe,t[139]=$e):$e=t[139];let et=Hn,tt=de?(0,$.jsx)(ts,{message:de}):v.trim()?(0,$.jsx)(Xo,{results:Ie,isSearching:he,onOpenFile:we}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[le.length===0&&!fe?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:l(`mobile.files.empty.directory`)}):null,le.map(e=>(0,$.jsx)(Yo,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:Wo(e.size),onClick:()=>e.isDirectory?Se(e.path):we(e.path)},e.path))]}),nt;t[140]!==et||t[141]!==tt?(nt=(0,$.jsx)(et,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:tt}),t[140]=et,t[141]=tt,t[142]=nt):nt=t[142];let rt;return t[143]!==Be||t[144]!==Ye||t[145]!==$e||t[146]!==nt?(rt=(0,$.jsxs)(`div`,{className:Be,children:[Ye,$e,nt]}),t[143]=Be,t[144]=Ye,t[145]=$e,t[146]=nt,t[147]=rt):rt=t[147],rt},Yo=e=>{let t=(0,Q.c)(16),{name:n,path:r,directory:i,meta:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==r?(c=i?(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(Ft,{filePath:r,className:`size-5 shrink-0`}),t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:n}),t[4]=n,t[5]=l);let u;t[6]===a?u=t[7]:(u=a?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:a}):null,t[6]=a,t[7]=u);let d;t[8]===i?d=t[9]:(d=i?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null,t[8]=i,t[9]=d);let f;return t[10]!==o||t[11]!==c||t[12]!==l||t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-14 w-full items-center gap-3 border-b border-border/30 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:o,style:s,children:[c,l,u,d]}),t[10]=o,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f):f=t[15],f},Xo=e=>{let t=(0,Q.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=re(),o=Bo(yr()??null);if(r){let e;t[0]===a?e=t[1]:(e=a(`common.loading`),t[0]=a,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,$.jsx)(ts,{loading:!0,message:e}),t[2]=e,t[3]=n),n}if(n.length===0){let e;t[4]===a?e=t[5]:(e=a(`mobile.files.search.empty`),t[4]=a,t[5]=e);let n;return t[6]===e?n=t[7]:(n=(0,$.jsx)(ts,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(Yo,{name:Vo(e.path),path:e.path,directory:!1,meta:Uo(e.path,o),onClick:()=>i(e.path)},e.path)),c;return t[8]===s?c=t[9]:(c=(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:s}),t[8]=s,t[9]=c),c},Zo=e=>{let t=(0,Q.c)(24),{path:n,htmlViewMode:r,htmlFullscreen:i,onToggleHtmlViewMode:a,onEnterHtmlFullscreen:o,onCopyPath:s,onCopyContent:c}=e,{t:l}=re(),u;t[0]===n?u=t[1]:(u=gr(n),t[0]=n,t[1]=u);let d=u,f;t[2]!==d||t[3]!==i||t[4]!==r||t[5]!==o||t[6]!==a||t[7]!==l?(f=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:a,"aria-label":l(r===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:r===`preview`?`file-code`:`eye`,className:`size-4`})}),i?null:(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:o,"aria-label":l(`mobile.files.html.fullscreenAria`),children:(0,$.jsx)(X,{name:`fullscreen`,className:`size-4`})})]}):null,t[2]=d,t[3]=i,t[4]=r,t[5]=o,t[6]=a,t[7]=l,t[8]=f):f=t[8];let p;t[9]!==d||t[10]!==c||t[11]!==n||t[12]!==l?(p=!_r(n)&&!d?(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:c,"aria-label":l(`mobile.files.copyContentAria`),children:(0,$.jsx)(X,{name:`file-copy`,className:`size-4`})}):null,t[9]=d,t[10]=c,t[11]=n,t[12]=l,t[13]=p):p=t[13];let m;t[14]===l?m=t[15]:(m=l(`mobile.files.copyPathAria`),t[14]=l,t[15]=m);let h;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(X,{name:`clipboard`,className:`size-4`}),t[16]=h):h=t[16];let g;t[17]!==s||t[18]!==m?(g=(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:s,"aria-label":m,children:h}),t[17]=s,t[18]=m,t[19]=g):g=t[19];let _;return t[20]!==f||t[21]!==p||t[22]!==g?(_=(0,$.jsxs)($.Fragment,{children:[f,p,g]}),t[20]=f,t[21]=p,t[22]=g,t[23]=_):_=t[23],_},Qo=e=>{let t=(0,Q.c)(94),{path:n,content:r,error:i,isLoading:a,hideHeader:o,htmlViewMode:s,onHtmlViewModeChange:c,onBack:l,onCopyPath:u,onCopyContent:d}=e,f=o!==void 0&&o,{t:p}=re(),m=Z.useRef(null),h=_r(n)&&!n.toLowerCase().endsWith(`.svg`)?n:``,g;t[0]===n?g=t[1]:(g=Ho(n)??``,t[0]=n,t[1]=g);let _=An(h,g,`preview`),[v,y]=Z.useState(``),b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b={open:!1,title:``,content:``},t[2]=b):b=t[2];let[x,S]=Z.useState(b),C=_.source,w;t[3]===n?w=t[4]:(w=Vo(n),t[3]=n,t[4]=w);let T=w,E;t[5]!==r||t[6]!==n?(E=_r(n)?`data:${hr(n)};utf8,${encodeURIComponent(r)}`:``,t[5]=r,t[6]=n,t[7]=E):E=t[7];let D=E,O;t[8]!==r||t[9]!==D||t[10]!==C||t[11]!==n?(O=C||(_r(n)&&r?D:``),t[8]=r,t[9]=D,t[10]=C,t[11]=n,t[12]=O):O=t[12];let k=O,A;t[13]!==i||t[14]!==v||t[15]!==_.error||t[16]!==k||t[17]!==p?(A=i??_.error??(k&&v===k?p(`filesView.error.readFileFailed`):null),t[13]=i,t[14]=v,t[15]=_.error,t[16]=k,t[17]=p,t[18]=A):A=t[18];let j=A,M;t[19]===k?M=t[20]:(M=()=>y(k),t[19]=k,t[20]=M);let N=U(M),P;t[21]!==T||t[22]!==h||t[23]!==n||t[24]!==k?(P=e=>{let t=h||k;t&&S({open:!0,title:T,content:``,previewSource:e.currentTarget.querySelector(`img`)??void 0,metadata:{tool:`image-preview`,filename:T,mime:hr(n)},image:{url:t,mimeType:hr(n),filename:T}})},t[21]=T,t[22]=h,t[23]=n,t[24]=k,t[25]=P):P=t[25];let F=U(P),I;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>{S(t=>t.open===e?t:{...t,open:e})},t[26]=I):I=t[26];let L=U(I),R;t[27]===n?R=t[28]:(R=gr(n),t[27]=n,t[28]=R);let z=R,[B,ee]=Z.useState(!1),V=Z.useRef(null),H;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{ee(!1)},t[29]=H):H=t[29];let te;t[30]===n?te=t[31]:(te=[n],t[30]=n,t[31]=te),Z.useEffect(H,te);let W;t[32]!==s||t[33]!==c?(W=()=>{c(s===`preview`?`source`:`preview`)},t[32]=s,t[33]=c,t[34]=W):W=t[34];let ne=U(W),ie;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>{ee(!0)},t[35]=ie):ie=t[35];let G=U(ie),ae;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>(ee(!1),!0),t[36]=ae):ae=t[36];let oe=U(ae),se=z&&B,ce;t[37]!==oe||t[38]!==se?(ce={id:`mobile-html-fullscreen`,active:se,layer:`overlay`,onBack:oe,surfaceRef:V},t[37]=oe,t[38]=se,t[39]=ce):ce=t[39],ar(ce);let q;t[40]!==G||t[41]!==B||t[42]!==s||t[43]!==d||t[44]!==u||t[45]!==n||t[46]!==ne?(q=(0,$.jsx)(Zo,{path:n,htmlViewMode:s,htmlFullscreen:B,onToggleHtmlViewMode:ne,onEnterHtmlFullscreen:G,onCopyPath:u,onCopyContent:d}),t[40]=G,t[41]=B,t[42]=s,t[43]=d,t[44]=u,t[45]=n,t[46]=ne,t[47]=q):q=t[47];let J=q,le;t[48]!==r||t[49]!==i||t[50]!==s||t[51]!==a||t[52]!==n||t[53]!==p?(le=s===`source`?a?(0,$.jsx)(ts,{loading:!0,message:p(`filesView.state.loading`)}):i?(0,$.jsx)(ts,{message:i}):(0,$.jsx)(es,{path:n,content:r}):(0,$.jsx)($o,{path:n}),t[48]=r,t[49]=i,t[50]=s,t[51]=a,t[52]=n,t[53]=p,t[54]=le):le=t[54];let ue=le,de;t[55]!==oe||t[56]!==z||t[57]!==ue||t[58]!==B||t[59]!==s||t[60]!==T||t[61]!==p||t[62]!==ne?(de=z?(0,$.jsxs)(`div`,{ref:V,"data-mobile-html-preview":s===`preview`&&!B?`true`:void 0,"data-mobile-html-fullscreen":s===`preview`&&B?`true`:void 0,className:B?`fixed inset-0 z-[80] flex flex-col bg-background text-foreground`:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[B?(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-border/50 px-3 pb-2 pt-[max(0.5rem,env(safe-area-inset-top))]`,children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:oe,"aria-label":p(`mobile.files.html.exitFullscreenAria`),className:`shrink-0 text-muted-foreground`,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-header text-foreground`,children:T}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:ne,"aria-label":p(s===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:s===`preview`?`file-code`:`eye`,className:`size-4`})})]}):null,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden bg-background`,children:ue})]}):null,t[55]=oe,t[56]=z,t[57]=ue,t[58]=B,t[59]=s,t[60]=T,t[61]=p,t[62]=ne,t[63]=de):de=t[63];let fe=de,pe;t[64]!==J||t[65]!==f||t[66]!==T||t[67]!==l||t[68]!==p?(pe=f?(0,$.jsx)(Pn,{children:J}):(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":p(`header.actions.backAria`),onClick:l,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:T})}),J]}),t[64]=J,t[65]=f,t[66]=T,t[67]=l,t[68]=p,t[69]=pe):pe=t[69];let me;t[70]!==r||t[71]!==N||t[72]!==z||t[73]!==B||t[74]!==fe||t[75]!==j||t[76]!==T||t[77]!==_.loading||t[78]!==a||t[79]!==F||t[80]!==n||t[81]!==k||t[82]!==p?(me=z?B&&typeof document<`u`?(0,yo.createPortal)(fe,document.body):fe:a||_.loading?_r(n)?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-4`,children:(0,$.jsx)(Tr,{className:`aspect-square w-64 max-w-full rounded-lg`})}):(0,$.jsx)(ts,{loading:!0,message:p(`filesView.state.loading`)}):j?(0,$.jsx)(ts,{message:j}):_r(n)&&k?(0,$.jsx)(Hn,{className:`h-full overflow-auto p-4`,children:(0,$.jsx)(`button`,{type:`button`,className:`mx-auto block max-h-full max-w-full cursor-zoom-in rounded-lg border-0 bg-transparent p-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:F,"aria-label":T,children:(0,$.jsx)(Er,{src:k,alt:T,className:`mx-auto max-h-full max-w-full rounded-lg object-contain`,draggable:!1,onError:N})})}):(0,$.jsx)(es,{path:n,content:r}),t[70]=r,t[71]=N,t[72]=z,t[73]=B,t[74]=fe,t[75]=j,t[76]=T,t[77]=_.loading,t[78]=a,t[79]=F,t[80]=n,t[81]=k,t[82]=p,t[83]=me):me=t[83];let he;t[84]===me?he=t[85]:(he=(0,$.jsx)(`div`,{ref:m,className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:me}),t[84]=me,t[85]=he);let ge;t[86]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(nn,{containerRef:m}),t[86]=ge):ge=t[86];let _e;t[87]!==L||t[88]!==x?(_e=x.open?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ro,{popup:x,onOpenChange:L,isMobile:!0})}):null,t[87]=L,t[88]=x,t[89]=_e):_e=t[89];let ve;return t[90]!==pe||t[91]!==he||t[92]!==_e?(ve=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[pe,he,ge,_e]}),t[90]=pe,t[91]=he,t[92]=_e,t[93]=ve):ve=t[93],ve},$o=e=>{let t=(0,Q.c)(29),{path:n}=e,{t:i}=re(),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=s(),t[0]=c):c=t[0];let l=c,u=Z.useRef(null),[d,f]=Z.useState(``),[p,g]=Z.useState(0),[_,v]=Z.useState(null),[y,b]=Z.useState(``),x,S;t[1]!==n||t[2]!==i?(x=()=>{let e=!1;if(f(``),v(null),b(``),l)return h(Ko(n)).then(async e=>{if(!e.ok)throw Error(i(`filesView.error.readFileFailed`));return e.text()}).then(t=>{e||(b(t),f(n))}).catch(t=>{e||(v(t instanceof Error?t.message:i(`filesView.error.readFileFailed`)),f(n))}),()=>{e=!0};let t=m(),s=a(t);r(t).then(t=>{e||!t||(f(n),v(null))}).catch(t=>{e||(v(t instanceof Error?t.message:i(`filesView.error.readFileFailed`)),f(n))});let c=o(()=>{e||(f(n),g(as),v(null))});return()=>{e=!0,s(),c()}},S=[n,l,i],t[1]=n,t[2]=i,t[3]=x,t[4]=S):(x=t[3],S=t[4]),Z.useEffect(x,S);let C;t[5]!==n||t[6]!==d?(C=()=>{if(d!==n)return;let e=u.current;if(e)return Lo(e)},t[5]=n,t[6]=d,t[7]=C):C=t[7];let w;if(t[8]!==p||t[9]!==n||t[10]!==d||t[11]!==y?(w=[p,n,d,y],t[8]=p,t[9]=n,t[10]=d,t[11]=y,t[12]=w):w=t[12],Z.useEffect(C,w),_){let e;return t[13]===_?e=t[14]:(e=(0,$.jsx)(ts,{message:_}),t[13]=_,t[14]=e),e}if(d!==n){let e;t[15]===i?e=t[16]:(e=i(`filesView.state.loading`),t[15]=i,t[16]=e);let n;return t[17]===e?n=t[18]:(n=(0,$.jsx)(ts,{loading:!0,message:e}),t[17]=e,t[18]=n),n}let T;t[19]===n?T=t[20]:(T=l?void 0:qo(n),t[19]=n,t[20]=T);let E=l?y:void 0,D;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(D={backgroundColor:`var(--surface-background)`},t[21]=D):D=t[21];let O;t[22]===i?O=t[23]:(O=i(`filesView.editor.htmlPreviewTitle`),t[22]=i,t[23]=O);let k;return t[24]!==p||t[25]!==T||t[26]!==E||t[27]!==O?(k=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:(0,$.jsx)(`iframe`,{ref:u,src:T,srcDoc:E,className:`h-full min-h-0 w-full flex-1 border-none bg-background`,style:D,sandbox:`allow-scripts allow-same-origin allow-forms`,title:O},p)}),t[24]=p,t[25]=T,t[26]=E,t[27]=O,t[28]=k):k=t[28],k},es=e=>{let t=(0,Q.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=_t(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??jn(!1),t[0]=a,t[1]=o,t[2]=c):c=t[2];let l=c,u;t[3]!==a||t[4]!==s?(u=a.find(e=>e.metadata.id===s)??jn(!0),t[3]=a,t[4]=s,t[5]=u):u=t[5];let d=u,f,p;t[6]!==d||t[7]!==l?(f=()=>{lr(l),lr(d)},p=[d,l],t[6]=d,t[7]=l,t[8]=f,t[9]=p):(f=t[8],p=t[9]),Z.useEffect(f,p);let m;t[10]!==d.metadata.id||t[11]!==l.metadata.id?(m={light:l.metadata.id,dark:d.metadata.id},t[10]=d.metadata.id,t[11]=l.metadata.id,t[12]=m):m=t[12];let h=m;if(Go(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Hn,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(dr,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=Vo(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=vr(n)||void 0,t[17]=n,t[18]=_);let v;t[19]!==r||t[20]!==g||t[21]!==_?(v={name:g,contents:r,lang:_},t[19]=r,t[20]=g,t[21]=_,t[22]=v):v=t[22];let y=i.metadata.variant===`dark`?`dark`:`light`,b;t[23]!==h||t[24]!==y?(b={disableFileHeader:!0,overflow:`wrap`,theme:h,themeType:y,unsafeCSS:vi},t[23]=h,t[24]=y,t[25]=b):b=t[25];let x;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(x={minHeight:`100%`},t[26]=x):x=t[26];let S;return t[27]!==b||t[28]!==v?(S=(0,$.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,$.jsx)(Hn,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(V,{file:v,options:b,className:`block min-h-full w-full`,style:x})})}),t[27]=b,t[28]=v,t[29]=S):S=t[29],S},ts=e=>{let t=(0,Q.c)(7),{message:n,loading:r}=e,i=r!==void 0&&r,a;t[0]===i?a=t[1]:(a=i?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-open-fill`,className:`size-6 text-muted-foreground`}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s};function ns(e){return e.pendingFileFocusPath}function rs(e){return e.setPendingFileFocusPath}function is(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}function as(e){return e+1}var os=S(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),ss=S()(C(e=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(t,n)=>e(e=>({projectExpanded:{...e.projectExpanded,[t]:n}})),setWorktreeExpanded:(t,n)=>e(e=>({worktreeExpanded:{...e.worktreeExpanded,[t]:n}}))}),{name:`mobile-session-tree`,storage:v()}));typeof window<`u`&&c(e=>{p(e)&&ss.persist.rehydrate()});var cs=36,ls=18,us=e=>e.parentID??null,ds=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),fs=e=>{let t=e;return ds(t.directory??t.project?.worktree??null)},ps=e=>{let t=ds(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},ms=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},hs=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),gs=e=>{if(e<=0)return``;let t=Date.now()-e;if(t<6e4)return`now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return`${r}h`;let i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))},_s=(e,t)=>{let n=ds(e),r=ds(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},vs=(e,t)=>e.worktrees.find(e=>ds(e.path)===t)??null,ys=(e,t)=>t===e.path||!!vs(e,t),bs=(e,t)=>{let n=ds(t);return n?e.find(e=>ys(e,n))??null:null},xs=(e,t,n)=>!n||`${e.title??``} ${e.id} ${fs(e)} ${t}`.toLowerCase().includes(n),Ss=e=>{let t=(0,Q.c)(14),{project:n,size:r}=e,i=r===void 0?`md`:r,a=i===`sm`?`size-6 rounded-md`:`size-8 rounded-lg`,o=i===`sm`?`size-3.5`:`size-4`,s=n.icon?ln[n.icon]:null,c=n.color?un[n.color]:void 0,l=s??`folder-open`,u;t[0]===c?u=t[1]:(u=c?{color:c}:void 0,t[0]=c,t[1]=u);let d;t[2]!==o||t[3]!==l||t[4]!==u?(d=(0,$.jsx)(X,{name:l,className:o,style:u}),t[2]=o,t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=d,p;t[6]===a?p=t[7]:(p=G(`flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,a),t[6]=a,t[7]=p);let m;t[8]!==f||t[9]!==n?(m=n.iconImage?(0,$.jsx)(sn,{project:n,className:`size-full object-contain`,fallback:f}):f,t[8]=f,t[9]=n,t[10]=m):m=t[10];let h;return t[11]!==p||t[12]!==m?(h=(0,$.jsx)(`span`,{className:p,children:m}),t[11]=p,t[12]=m,t[13]=h):h=t[13],h},Cs=e=>{let t=(0,Q.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=G(`flex size-5 shrink-0 items-center justify-center text-muted-foreground/70 transition-transform duration-150`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`span`,{"aria-hidden":!0,className:i,children:a}),t[3]=i,t[4]=o),o},ws=e=>{let t=(0,Q.c)(2),{ariaLabel:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`inline-block size-1.5 shrink-0 rounded-full bg-primary`,"aria-label":n}),t[0]=n,t[1]=r),r},Ts=e=>{let t=(0,Q.c)(12),{onClick:n,className:r}=e,{t:i}=re(),a;t[0]===i?a=t[1]:(a=i(`sessions.sidebar.project.actions.newWorktree`),t[0]=i,t[1]=a);let o=a,s;t[2]===r?s=t[3]:(s=G(`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,r),t[2]=r,t[3]=s);let c;t[4]===n?c=t[5]:(c=e=>{e.stopPropagation(),n()},t[4]=n,t[5]=c);let l,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l={touchAction:`manipulation`},u=(0,$.jsx)(X,{name:`node-tree`,className:`size-4`}),t[6]=l,t[7]=u):(l=t[6],u=t[7]);let d;return t[8]!==o||t[9]!==s||t[10]!==c?(d=(0,$.jsx)(`button`,{type:`button`,className:s,"aria-label":o,title:o,onClick:c,style:l,children:u}),t[8]=o,t[9]=s,t[10]=c,t[11]=d):d=t[11],d},Es=e=>{let t=(0,Q.c)(10),{icon:n,label:r,onClick:i,destructive:a}=e,o=a!==void 0&&a?`destructive`:`ghost`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(X,{name:n,className:`size-5 shrink-0`}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=l);let u;return t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(K,{type:`button`,variant:o,size:`default`,className:`min-h-12 w-full justify-start gap-3 rounded-xl px-3 typography-ui-label`,onClick:i,style:s,children:[c,l]}),t[5]=i,t[6]=o,t[7]=c,t[8]=l,t[9]=u):u=t[9],u},Ds=e=>{let t=(0,Q.c)(100),{session:n,active:r,indent:i,contextLabel:a,confirmingArchive:o,hasChildren:s,expanded:c,onToggleChildren:l,onSelect:u,onRequestArchive:d,onConfirmArchive:f,onStop:p,stopAriaLabel:m,longPressHandlers:h,highlightQuery:g}=e,_=o!==void 0&&o,v=s!==void 0&&s,y=c!==void 0&&c,{t:b}=re(),x;t[0]===n?x=t[1]:(x=gs(ms(n)),t[0]=n,t[1]=x);let S=x,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,R,z,B;if(t[2]!==r||t[3]!==_||t[4]!==y||t[5]!==v||t[6]!==g||t[7]!==i||t[8]!==h.onContextMenu||t[9]!==h.onPointerCancel||t[10]!==h.onPointerDown||t[11]!==h.onPointerMove||t[12]!==h.onPointerUp||t[13]!==h.pressed||t[14]!==u||t[15]!==l||t[16]!==n.title||t[17]!==b){B=n.title?.trim()||b(`mobile.sessions.untitled`);let e=r&&!_&&`bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]`,a=_&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`;t[36]!==e||t[37]!==a?(N=G(`relative flex items-center gap-1 transition-colors`,e,a),t[36]=e,t[37]=a,t[38]=N):N=t[38],t[39]!==y||t[40]!==v||t[41]!==i||t[42]!==l||t[43]!==b?(P=v&&l?(0,$.jsx)(`button`,{type:`button`,className:`absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,style:{left:Math.max(i-32,2),top:0,bottom:0,touchAction:`manipulation`},"aria-label":b(y?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:e=>{e.stopPropagation(),l()},children:(0,$.jsx)(X,{name:`arrow-down-s`,className:G(`size-[18px] transition-transform duration-150`,y?`rotate-0`:`-rotate-90`)})}):null,t[39]=y,t[40]=v,t[41]=i,t[42]=l,t[43]=b,t[44]=P):P=t[44],C=`button`;let o=_&&`opacity-50`,s=h.pressed&&`bg-interactive-active scale-[0.99]`;t[45]!==o||t[46]!==s?(w=G(`flex min-h-12 min-w-0 flex-1 items-center gap-2.5 py-2 pr-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o,s),t[45]=o,t[46]=s,t[47]=w):w=t[47],t[48]===i?T=t[49]:(T={paddingLeft:i,touchAction:`manipulation`},t[48]=i,t[49]=T),E=u,D=h.onPointerDown,O=h.onPointerMove,k=h.onPointerUp,A=h.onPointerCancel,j=h.onContextMenu,M=_,z=`flex min-w-0 flex-1 flex-col`,L=`flex items-center gap-2.5`;let c=r?`bg-primary`:`bg-muted-foreground/30`,d;t[50]===c?d=t[51]:(d=G(`size-1.5 shrink-0 rounded-full`,c),t[50]=c,t[51]=d),t[52]===d?R=t[53]:(R=(0,$.jsx)(`span`,{className:d,"aria-hidden":!0}),t[52]=d,t[53]=R);let f=r?`text-primary`:`text-foreground`;t[54]===f?F=t[55]:(F=G(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),I=g?gn(B,g):B,t[2]=r,t[3]=_,t[4]=y,t[5]=v,t[6]=g,t[7]=i,t[8]=h.onContextMenu,t[9]=h.onPointerCancel,t[10]=h.onPointerDown,t[11]=h.onPointerMove,t[12]=h.onPointerUp,t[13]=h.pressed,t[14]=u,t[15]=l,t[16]=n.title,t[17]=b,t[18]=C,t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A,t[26]=j,t[27]=M,t[28]=N,t[29]=P,t[30]=F,t[31]=I,t[32]=L,t[33]=R,t[34]=z,t[35]=B}else C=t[18],w=t[19],T=t[20],E=t[21],D=t[22],O=t[23],k=t[24],A=t[25],j=t[26],M=t[27],N=t[28],P=t[29],F=t[30],I=t[31],L=t[32],R=t[33],z=t[34],B=t[35];let ee;t[56]!==F||t[57]!==I?(ee=(0,$.jsx)(`span`,{className:F,children:I}),t[56]=F,t[57]=I,t[58]=ee):ee=t[58];let V;t[59]===S?V=t[60]:(V=S?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:S}):null,t[59]=S,t[60]=V);let H;t[61]!==ee||t[62]!==V||t[63]!==L||t[64]!==R?(H=(0,$.jsxs)(`span`,{className:L,children:[R,ee,V]}),t[61]=ee,t[62]=V,t[63]=L,t[64]=R,t[65]=H):H=t[65];let te;t[66]!==a||t[67]!==g?(te=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?gn(a,g):a}):null,t[66]=a,t[67]=g,t[68]=te):te=t[68];let U;t[69]!==H||t[70]!==te||t[71]!==z?(U=(0,$.jsxs)(`span`,{className:z,children:[H,te]}),t[69]=H,t[70]=te,t[71]=z,t[72]=U):U=t[72];let W;t[73]!==C||t[74]!==w||t[75]!==T||t[76]!==E||t[77]!==D||t[78]!==O||t[79]!==k||t[80]!==A||t[81]!==j||t[82]!==M||t[83]!==U?(W=(0,$.jsx)(`button`,{type:C,className:w,style:T,onClick:E,onPointerDown:D,onPointerMove:O,onPointerUp:k,onPointerCancel:A,onContextMenu:j,disabled:M,children:U}),t[73]=C,t[74]=w,t[75]=T,t[76]=E,t[77]=D,t[78]=O,t[79]=k,t[80]=A,t[81]=j,t[82]=M,t[83]=U,t[84]=W):W=t[84];let ne;t[85]!==p||t[86]!==m?(ne=p?(0,$.jsx)(`button`,{type:`button`,className:`mr-0.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":m,onClick:e=>{e.stopPropagation(),p()},style:{touchAction:`manipulation`},children:(0,$.jsx)(Jr,{})}):null,t[85]=p,t[86]=m,t[87]=ne):ne=t[87];let ie;t[88]!==_||t[89]!==f||t[90]!==d||t[91]!==b||t[92]!==B?(ie=d?(0,$.jsxs)($.Fragment,{children:[_?(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 shrink-0 items-center gap-1.5 rounded-xl bg-destructive px-3 text-destructive-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,"aria-label":b(`mobile.sessions.archiveSessionAria`,{title:B}),onClick:f,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`archive`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:b(`sessions.sidebar.bulkActions.archive`)})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`mr-1.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":b(_?`mobile.sessions.cancelArchiveAria`:`mobile.sessions.archiveSessionAria`,{title:B}),onClick:d,style:{touchAction:`manipulation`},children:_?(0,$.jsx)(X,{name:`close`,className:`size-4`}):(0,$.jsx)(X,{name:`archive`,className:`size-4`})})]}):null,t[88]=_,t[89]=f,t[90]=d,t[91]=b,t[92]=B,t[93]=ie):ie=t[93];let K;return t[94]!==N||t[95]!==P||t[96]!==W||t[97]!==ne||t[98]!==ie?(K=(0,$.jsxs)(`div`,{className:N,children:[P,W,ne,ie]}),t[94]=N,t[95]=P,t[96]=W,t[97]=ne,t[98]=ie,t[99]=K):K=t[99],K},Os=e=>{let t=(0,Q.c)(15),{indent:n,showMore:r,showFewer:i,loadingMore:a,onShowMore:o,onShowFewer:s}=e,c=a!==void 0&&a,{t:l}=re();if(!r&&!i)return null;let u;t[0]===n?u=t[1]:(u={paddingLeft:n,touchAction:`manipulation`},t[0]=n,t[1]=u);let d;t[2]!==s||t[3]!==i||t[4]!==l?(d=i?(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:s,children:[(0,$.jsx)(X,{name:`arrow-up-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showFewer`)})]}):null,t[2]=s,t[3]=i,t[4]=l,t[5]=d):d=t[5];let f;t[6]!==c||t[7]!==o||t[8]!==r||t[9]!==l?(f=r?(0,$.jsxs)(`button`,{type:`button`,className:G(`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-60`,c&&`animate-pulse`),onClick:o,disabled:c,children:[(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showMore`)})]}):null,t[6]=c,t[7]=o,t[8]=r,t[9]=l,t[10]=f):f=t[10];let p;return t[11]!==u||t[12]!==d||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-h-10 w-full items-center gap-3 py-1.5 pr-3 text-muted-foreground`,style:u,children:[d,f]}),t[11]=u,t[12]=d,t[13]=f,t[14]=p):p=t[14],p},ks=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=re(),{git:i}=Mn(),a=Ke(),o=Be(),s=Se(e=>e.activeSessions),c=Se(e=>e.activePaginationByDirectory),l=Xe(e=>e.projects),u=Xe(e=>e.activeProjectId),d=D(e=>e.currentDirectory),f=Ze(e=>e.currentSessionId),p=Ze(e=>e.availableWorktreesByProject),m=Ze(e=>e.setCurrentSession),h=Ze(e=>e.archiveSession),g=Ze(e=>e.archiveSessions),_=Ze(e=>e.updateSessionTitle),v=Ze(e=>e.requestSessionSmartTitle),y=Ze(e=>e.shareSession),b=Ze(e=>e.unshareSession),x=Ze(e=>e.openNewSessionDraft),S=Xe(e=>e.setActiveProject),C=Xe(e=>e.setActiveProjectIdOnly),w=Xe(e=>e.removeProject),T=Ne(),E=Pe(),O=ss(e=>e.projectExpanded),k=ss(e=>e.worktreeExpanded),A=ss(e=>e.setProjectExpanded),j=ss(e=>e.setWorktreeExpanded),M=Zt(e=>e.orderByProject),N=os(e=>e.expandedParents),P=os(e=>e.toggleParent),[F,I]=Z.useState(``),[L,R]=Z.useState(null),[z,B]=Z.useState(null),[ee,V]=Z.useState(0),[H,te]=Z.useState(!1),[W,ie]=Z.useState(!1),[ae,oe]=Z.useState(null),[se,ce]=Z.useState(null),[q,J]=Z.useState(null),[le,ue]=Z.useState(null),[de,fe]=Z.useState(null),[pe,me]=Z.useState(``),[he,ge]=Z.useState(!1),[_e,ve]=Z.useState(null),ye=Z.useRef(null);ye.current||=br({onPressedKeyChange:ue});let[be,xe]=Z.useState(new Set),[Ce,we]=Z.useState(new Map),[Ee,De]=Z.useState(new Map),Oe=Gr(),ke=ei(),Ae=U(e=>{Te(e),Ue(e)}),je=U(e=>{Promise.all(e.map(e=>(Te(e),Ue(e))))});Z.useEffect(()=>{if(!e){I(``),De(new Map),R(null),B(null),ce(null),fe(null),ve(null),ye.current?.reset();return}},[e]),Z.useEffect(()=>()=>{ye.current?.reset()},[]),Z.useEffect(()=>{if(!e)return;if(l.length===0){Ze.setState(e=>{let t=Ur(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),xe(e=>e.size===0?e:new Set),we(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(l.map(async e=>{let n=ds(e.path);if(!n)return null;let r;try{r=await i.checkIsGitRepository(n)}catch{return{id:e.id,path:n,gitStatus:`failed`}}if(!r)return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:`success`,worktrees:[]};let[a,o]=await Promise.allSettled([dn({id:e.id,path:n},{isCurrent:()=>!t}),cn(n)]);return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:a.status===`fulfilled`?`success`:`failed`,worktrees:a.status===`fulfilled`?a.value.worktrees:void 0,rootBranchStatus:o.status===`fulfilled`?`success`:`failed`,rootBranch:o.status===`fulfilled`?o.value:void 0}}));if(t)return;let n=new Set(l.map(e=>ds(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);Ze.setState(e=>{let t=Ur(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),xe(t=>{let r=new Set([...t].filter(e=>n.has(e)));for(let t of e)t?.gitStatus===`success`&&(t.isGitRepo?r.add(t.path):r.delete(t.path));return hs(r,t)?t:r}),we(t=>{let n=new Set(l.map(e=>e.id)),r=new Map([...t].filter(([e])=>n.has(e)));for(let t of e){if(!t||t.gitStatus!==`success`)continue;if(!t.isGitRepo){r.delete(t.id);continue}if(t.rootBranchStatus!==`success`)continue;let e=t.rootBranch?.trim();e&&e!==`HEAD`?r.set(t.id,e):r.delete(t.id)}return r.size===t.size&&[...r].every(([e,n])=>t.get(e)===n)?t:r})})(),()=>{t=!0}},[i,e,l,ee]);let Me=Z.useMemo(()=>l.map(e=>({id:e.id,label:ps(e.path),path:ds(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:be.has(ds(e.path)),worktrees:Yt(M[e.id],p.get(ds(e.path))??[])})),[be,l,M,p]),Fe=Z.useMemo(()=>{let e=new Map(o.map(e=>[e.id,e])),t=s.map(t=>{let n=e.get(t.id);return n?dt(n,t):t}),n=new Set(t.map(e=>e.id));for(let e of o)n.has(e.id)||t.push(e);return t},[s,o]),Ie=F.trim().toLowerCase(),Le=Z.useMemo(()=>{let e=Me.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===u})),t=(e,t,n)=>{let r=ds(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||ps(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a};for(let n of e){t(n,n.project.path,null);for(let e of n.project.worktrees)t(n,e.path,e)}for(let n of Fe){let r=fs(n);if(!r)continue;let i=ds(r),a=e.find(e=>ys(e.project,i));if(!a)continue;let o=vs(a.project,i);(o?t(a,o.path,o):t(a,a.project.path,null)).sessions.push(n)}for(let t of e)for(let e of t.buckets){e.sessions.sort((e,t)=>ut(t)-ut(e));for(let n of e.sessions)us(n)||(t.totalSessions+=1)}return e},[u,Me,Fe]),Re=ds(d),Ve=e=>e.isActive?Re===e.project.path?e.project.path:e.project.worktrees.find(e=>_s(Re,e.path))?.path??e.project.path:null,He=e=>O[e.project.id]??!0,We=(e,t)=>k[`${e.project.id}::${t.key}`]??!1,Ge=e=>{De(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},qe=()=>{ce(null),ye.current?.reset()},Je=e=>({pressed:le===e.key||se?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||ye.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>ce(e)})},onPointerMove:e=>{ye.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{ye.current?.end(e.pointerId)},onPointerCancel:e=>{ye.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),ye.current?.openFromContextMenu(e.key,()=>ce(e))}}),Ye=(e,t)=>{ye.current?.consumeClick(e)||t()},Qe=(e,t,n,r)=>{let i=Qr(),a=Wr();if(De(t=>{let r=new Map(t),o=Math.max(i,t.get(e)??i,n);return r.set(e,o+a),r}),Math.max(i,n)+a<r)return;let o=ds(t);if(!o)return;let s=Se.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&ze(o)},$e=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=Qr(),o=new Set(t.sessions.map(e=>e.id)),s=new Map;for(let e of t.sessions){let t=us(e);if(t&&o.has(t)){let n=s.get(t)??[];n.push(e),s.set(t,n)}}let l=t.sessions.filter(e=>!us(e)),u=Ee.get(i)??a,d=Xr(l,u,ke),p=l.length-d.length,m=c.get(ds(t.path)),h=m?.hasMore===!0,g=m?.loadingMore===!0,_=l.length>a&&u>a,v=(e,t)=>{let n=s.get(e.id)??[],i=n.length>0,a=!!N[e.id],o=Oe.has(e.id),c=i&&!a?n.filter(e=>Oe.has(e.id)).map(e=>e.id):[],l=c.length>0,u=o?[e.id,...c]:c,d=e.title?.trim()||r(`mobile.sessions.untitled`),p=`session:${e.id}`;return(0,$.jsxs)(Z.Fragment,{children:[(0,$.jsx)(Ds,{session:e,active:f===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>P(e.id):void 0,confirmingArchive:z===e.id,onSelect:()=>Ye(p,()=>rt(e)),onRequestArchive:()=>it(e.id),onConfirmArchive:()=>void at(e),onStop:o||l?()=>je(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:d}),longPressHandlers:Je({key:p,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+ls)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[d.map(e=>v(e,n)),(0,$.jsx)(Os,{indent:n,showMore:p>0||h,showFewer:_,loadingMore:g,onShowMore:()=>Qe(i,t.path,u,l.length),onShowFewer:()=>Ge(i)})]})},tt=(e,t)=>{A(e,!t)},nt=(e,t,n)=>{j(`${e}::${t}`,!n)},rt=e=>{Nn();let n=fs(e)||null,r=bs(Me,n??``);r&&C(r.id),m(e.id,n),t(!1)},it=e=>{B(t=>t===e?null:e)},at=async e=>{B(null),await h(e.id)?di({sessionIds:[e.id],message:r(`sessions.sidebar.session.archive.success`),undoLabel:r(`sessions.sidebar.undo`),settingsLabel:r(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:r(`sessions.sidebar.session.archive.undoFailed`)}):Y.error(r(`sessions.sidebar.session.archive.error`))},ot=()=>{x(),t(!1)},st=e=>{oe(e),C(e),ie(!0)},ct=e=>{let t=new Map;for(let e of Fe){let n=us(e);if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n},lt=async e=>{let t=ct(e.id),{archivedIds:n,failedIds:i}=await g(t);n.length>0&&di({sessionIds:n,message:n.length===1?r(`sessions.sidebar.session.archive.success`):r(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:r(`sessions.sidebar.undo`),settingsLabel:r(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:n.length===1?r(`sessions.sidebar.session.archive.undoFailed`):r(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),i.length>0&&Y.error(i.length===1?r(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):r(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}))},ft=e=>{let t=ct(e.id);Vr({sessionIds:t,message:t.length===1?r(`sessions.sidebar.session.delete.success`):r(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:r(`sessions.sidebar.undo`),commitFailedMessage:r(`sessions.sidebar.session.delete.error`)})},pt=async e=>{try{if(!(await y(e.id))?.share?.url){Y.error(r(`sessions.sidebar.session.share.error`));return}Y.success(r(`sessions.sidebar.session.share.successTitle`),{description:r(`sessions.sidebar.session.share.successDescription`)})}catch{Y.error(r(`sessions.sidebar.session.share.error`))}},mt=async e=>{if((await ne(e)).ok){Y.success(r(`sessions.sidebar.session.menu.copied`));return}Y.error(r(`sessions.sidebar.session.share.copyUrlError`))},ht=async e=>{try{if(await b(e)){Y.success(r(`sessions.sidebar.session.unshare.success`));return}Y.error(r(`sessions.sidebar.session.unshare.error`))}catch{Y.error(r(`sessions.sidebar.session.unshare.error`))}},gt=async()=>{if(!de)return;let e=pe.trim();if(e)try{await _(de.id,e),fe(null),me(``)}catch{Y.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},_t=async()=>{if(!de||he)return;let e=de.id;fe(null),me(``),ge(!0);try{await v(e)}catch{Y.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{ge(!1)}},vt=(e,n)=>{C(e.id),x({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},yt=e=>{(async()=>{try{await dn({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=Ze.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await et(n,Fe)})()},bt=e=>{let t=fs(e),n=bs(Me,t);if(!n)return ps(t)||t;let r=vs(n,ds(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},xt=e=>{S(e.id),t(!1)},St=Z.useMemo(()=>Ie?Le.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Ie)?!0:e.buckets.some(t=>t.sessions.some(t=>xs(t,e.project.label,Ie)))):Le,[Ie,Le]),Ct=Z.useMemo(()=>Ie?Fe.filter(e=>{let t=fs(e);return xs(e,bs(Me,t)?.label??``,Ie)}).sort((e,t)=>ut(t)-ut(e)):[],[Ie,Me,Fe]),wt=Z.useMemo(()=>Ie?Me.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Ie)).map(e=>({...e,sessionCount:Fe.filter(t=>!us(t)&&ys(e,ds(fs(t)))).length})):[],[Ie,Me,Fe]),Tt=Ie&&Ct.length===0&&wt.length===0,Et=Me.length>0?(0,$.jsxs)(K,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:ot,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,Dt=Me.find(e=>e.id===u)??null,Ot=Dt?.isGitRepo?(0,$.jsx)(K,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>st(Dt.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`node-tree`,className:`size-4`})}):null,kt=(0,$.jsx)(K,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>te(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folder-add`,className:`size-4`})}),At=Et||kt?(0,$.jsxs)($.Fragment,{children:[Et,Ot,kt]}):null,jt=se?.kind===`project`?se.project.label:se?.kind===`worktree`?se.worktree.branch||se.worktree.label||se.worktree.path:se?.kind===`session`?se.session.title?.trim()||r(`mobile.sessions.untitled`):``,Mt=Z.useMemo(()=>{if(!se)return[];if(se.kind===`project`){let e=se.project;return Di({gitRepository:e.isGitRepo,onNewSession:()=>{qe(),vt(e,e.path)},onNewWorktree:()=>{qe(),st(e.id)},onSyncSessions:()=>{qe(),yt(e)},onEditProject:()=>{qe(),R(e.id)},onCloseProject:()=>{qe(),J(e)}})}if(se.kind===`worktree`){let{project:e,worktree:t}=se;return Hr({onNewSession:()=>{qe(),vt(e,t.path)},onDeleteWorktree:()=>{qe(),ve({project:e,worktree:t})}})}let e=se.session,t=!!e.share?.url;return Zr({pinned:T.has(e.id),shared:t,onRename:()=>{qe(),me(e.title?.trim()||r(`mobile.sessions.untitled`)),fe(e)},onTogglePin:()=>{qe(),E(e.id)},onShare:!a||t?void 0:()=>{qe(),pt(e)},onCopyLink:a&&t?()=>{let t=e.share?.url;qe(),t&&mt(t)}:void 0,onUnshare:a&&t?()=>{qe(),ht(e.id)}:void 0,onArchive:()=>{qe(),lt(e)},onDelete:()=>{qe(),ft(e)}})},[se,qe,lt,mt,ft,st,pt,ht,T,vt,yt,r,E]),Nt=Mt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Mt.map(e=>{let t=(0,$.jsx)(Es,{icon:e.icon,label:Ei(e,r),destructive:e.destructive,onClick:e.onClick},e.id);return e.separated?(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:t},e.id):t})}):null,Pt=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(fn,{value:F,onChange:e=>I(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:G(`h-11 pl-9`,F&&`pr-10`)}),F?(0,$.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":r(`mobile.sessions.clearSearchAria`),onClick:()=>I(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsx)(Hn,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:Me.length===0?(0,$.jsx)(As,{title:r(`mobile.sessions.empty.noProjectsTitle`),description:r(`mobile.sessions.empty.noProjectsDescription`),action:(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center justify-center gap-2 rounded-2xl bg-primary px-5 py-3 typography-ui-label text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>te(!0),children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):Tt?(0,$.jsx)(As,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Ie?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 pt-2`,children:[Ct.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.sessions`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:Ct.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Ct.map((e,t)=>{let n=Oe.has(e.id),i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:G(t>0&&`border-t border-border/30`),children:(0,$.jsx)(Ds,{session:e,active:f===e.id,indent:12,contextLabel:bt(e),highlightQuery:Ie,onSelect:()=>Ye(`session:${e.id}`,()=>rt(e)),longPressHandlers:Je({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>Ae(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,wt.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.projects`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:wt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:wt.map((e,t)=>{let n=`project:${e.id}`,r=Je({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:G(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:G(`flex min-h-14 min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,r.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(n,()=>xt(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Ss,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:gn(e.label,Ie)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(Ts,{className:`mr-2`,onClick:()=>st(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:St.map((e,t)=>{let n=He(e),i=`project:${e.project.id}`,a=Je({key:i,kind:`project`,project:e.project}),o=Ie?e.buckets.filter(t=>t.sessions.some(t=>xs(t,e.project.label,Ie))):e.buckets,s=Ve(e);return(0,$.jsxs)(`section`,{className:G(t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`div`,{className:`flex min-h-14 w-full items-center`,children:[(0,$.jsxs)(`button`,{type:`button`,className:G(`flex min-h-14 min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,a.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(i,()=>tt(e.project.id,n)),onPointerDown:a.onPointerDown,onPointerMove:a.onPointerMove,onPointerUp:a.onPointerUp,onPointerCancel:a.onPointerCancel,onContextMenu:a.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:e.project.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)(Ss,{project:e.project}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-semibold text-foreground`,children:e.project.label}),Ce.get(e.project.id)?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:Ce.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(ws,{ariaLabel:r(`mobile.sessions.activeProjectAria`)}):null,(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.totalSessions})]}),(()=>{let t=n?[]:[...new Set(e.buckets.flatMap(e=>e.sessions.filter(e=>Oe.has(e.id)).map(e=>e.id)))];return t.length>0?(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] mr-1`,"aria-label":r(`mobile.sessions.stopGroupAria`,{label:e.project.label}),onClick:e=>{e.stopPropagation(),je(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Jr,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(Ts,{className:`mr-2`,onClick:()=>st(e.project.id)}):null]}),n?(0,$.jsx)(`div`,{className:`pb-2`,children:(()=>{let t=o.find(e=>e.worktree===null),n=o.filter(e=>e.worktree!==null);return(0,$.jsxs)($.Fragment,{children:[t&&t.sessions.length>0?$e(e,t,cs):null,n.map(t=>{let n=We(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Je({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:G(`flex min-h-11 w-full items-center gap-2 py-1.5 pl-4 pr-3 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(a,()=>nt(e.project.id,t.key,n)),onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onPointerCancel:o.onPointerCancel,onContextMenu:o.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:t.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)(Cs,{expanded:n}),(0,$.jsx)(X,{name:`node-tree`,className:G(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:G(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(ws,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>Oe.has(e.id)).map(e=>e.id);return e.length>0?(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":r(`mobile.sessions.stopGroupAria`,{label:t.label}),onClick:t=>{t.stopPropagation(),je(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Jr,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?$e(e,t,cs):null]},t.key)})]})})()}):null]},e.project.id)})})}),(0,$.jsx)(ci,{open:H,onOpenChange:te,forceMobile:!0}),(0,$.jsx)(Jt,{open:W,projectId:ae,onOpenChange:e=>{ie(e),e||oe(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?m(n.sessionId,e):x({selectedProjectId:ae,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(xn,{open:!!se,title:jt,onClose:qe,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Nt}),(0,$.jsx)(xn,{open:!!q,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>J(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>J(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(K,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!q)return;let e=q;J(null),w(e.id),Y.success(r(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:r(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:r(`mobile.projects.closeConfirmMessage`,{title:q?.label??``})})}),(0,$.jsx)(xn,{open:!!de,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{he||(fe(null),me(``))},footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:he,onClick:()=>{fe(null),me(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(K,{type:`button`,variant:`default`,className:`flex-1`,disabled:!pe.trim()||he,onClick:()=>void gt(),children:r(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),gt()},children:[(0,$.jsx)(fn,{value:pe,onChange:e=>me(e.target.value),autoFocus:!0,className:`h-12`,disabled:he}),(0,$.jsxs)(K,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:he,onClick:()=>void _t(),children:[he?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),r(`sessions.sidebar.session.rename.smartTitle`)]})]})}),_e?(0,$.jsx)(fi,{open:!0,project:{id:_e.project.id,path:_e.project.path},worktree:_e.worktree,onClose:()=>ve(null),onDeleted:()=>V(e=>e+1)}):null,(0,$.jsx)(Yr,{open:L!==null,project:Me.find(e=>e.id===L)??null,onClose:()=>R(null),onWorktreesChanged:()=>V(e=>e+1)})]});return n===`sidebar`?e?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsx)(`div`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center justify-end gap-2 px-4`,children:At?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:At}):null}),Pt]}):null:(0,$.jsx)(Rn,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:At,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:Pt})},As=e=>{let t=(0,Q.c)(10),{title:n,description:r,action:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i?(0,$.jsx)(`div`,{className:`pt-2`,children:i}):null,t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c},js=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,Ms=[{image:Pi,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:zi,titleKey:`assistants.guide.share.android.title`,descriptionKey:`assistants.guide.share.android.description`},{image:Ni,titleKey:`assistants.guide.share.pick.title`,descriptionKey:`assistants.guide.share.pick.description`}];function Ns(){let e=(0,Q.c)(8),{t}=re(),n;e[0]===t?n=e[1]:(n=t(`common.loading`),e[0]=t,e[1]=n);let r,i,a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`h-10 w-10 animate-pulse rounded-xl bg-[var(--surface-muted)] motion-reduce:animate-none`}),i=(0,$.jsx)(`div`,{className:`mt-2 h-4 w-2/3 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),a=(0,$.jsx)(`div`,{className:`h-3.5 w-full animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),o=(0,$.jsx)(`div`,{className:`h-3.5 w-4/5 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),e[2]=r,e[3]=i,e[4]=a,e[5]=o):(r=e[2],i=e[3],a=e[4],o=e[5]);let s;return e[6]===n?s=e[7]:(s=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 p-5`,"aria-busy":`true`,"aria-label":n,children:[r,i,a,o]}),e[6]=n,e[7]=s),s}function Ps(e){let t=(0,Q.c)(35),{onEnable:n}=e,{t:r}=re(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-hero`,"aria-hidden":`true`,children:(0,$.jsx)(`img`,{src:js,alt:``})}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=r(`assistants.guide.disabledTitle`),t[1]=r,t[2]=a);let o;t[3]===a?o=t[4]:(o=(0,$.jsx)(`h2`,{className:`oc-mobile-assistant-guide-title`,children:a}),t[3]=a,t[4]=o);let s;t[5]===r?s=t[6]:(s=r(`assistants.guide.disabledDescription`),t[5]=r,t[6]=s);let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(`p`,{className:`oc-mobile-assistant-guide-description`,children:s}),t[7]=s,t[8]=c);let l;t[9]===r?l=t[10]:(l=r(`assistants.guide.enableAction`),t[9]=r,t[10]=l);let u;t[11]!==n||t[12]!==l?(u=(0,$.jsx)(K,{type:`button`,size:`lg`,onClick:n,children:l}),t[11]=n,t[12]=l,t[13]=u):u=t[13];let d;t[14]!==o||t[15]!==c||t[16]!==u?(d=(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-body`,children:[o,c,u]}),t[14]=o,t[15]=c,t[16]=u,t[17]=d):d=t[17];let f;t[18]===r?f=t[19]:(f=r(`assistants.guide.shareTitle`),t[18]=r,t[19]=f);let p;t[20]===f?p=t[21]:(p=(0,$.jsx)(`h3`,{className:`oc-mobile-assistant-guide-share-title`,children:f}),t[20]=f,t[21]=p);let m;t[22]===r?m=t[23]:(m=r(`assistants.guide.shareAria`),t[22]=r,t[23]=m);let h;t[24]===r?h=t[25]:(h=Ms.map(e=>(0,$.jsxs)(`article`,{className:`oc-mobile-assistant-guide-step`,children:[(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-step-image`,children:(0,$.jsx)(`img`,{src:e.image,alt:``})}),(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-step-copy`,children:[(0,$.jsx)(`h4`,{children:r(e.titleKey)}),(0,$.jsx)(`p`,{children:r(e.descriptionKey)})]})]},e.titleKey)),t[24]=r,t[25]=h);let g;t[26]!==m||t[27]!==h?(g=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-steps`,"aria-label":m,children:h}),t[26]=m,t[27]=h,t[28]=g):g=t[28];let _;t[29]!==p||t[30]!==g?(_=(0,$.jsxs)(`section`,{className:`oc-mobile-assistant-guide-share`,children:[p,g]}),t[29]=p,t[30]=g,t[31]=_):_=t[31];let v;return t[32]!==_||t[33]!==d?(v=(0,$.jsxs)(`article`,{className:`oc-mobile-assistant-guide`,children:[i,d,_]}),t[32]=_,t[33]=d,t[34]=v):v=t[34],v}function Fs({avatarSeed:e,unreadCount:t,assistantID:n,displayName:r,summary:i,enabled:a,editLabel:o,deleteLabel:s,onOpen:c,onEdit:l,onDelete:u,serverWorking:d=!1}){let f=Xi(n,d),[p,m]=Z.useState(!1),[h,g]=Z.useState(!1),_=Z.useRef(null);_.current||=br({onPressedKeyChange:e=>g(e===n)}),Z.useEffect(()=>()=>_.current?.reset(),[]);let v=U(()=>{_.current?.consumeClick(n)||p||c()}),y=U(()=>{m(!1),l()}),b=U(()=>{m(!1),u()}),x=U(()=>{g(!1),m(!0)}),S=U(e=>{e.pointerType!==`touch`&&e.pointerType!==`pen`||e.button!==0||_.current?.start({pointerId:e.pointerId,key:n,clientX:e.clientX,clientY:e.clientY,onTrigger:x})}),C=U(e=>{_.current?.move(e.pointerId,e.clientX,e.clientY)}),w=U(e=>{_.current?.end(e.pointerId)}),T=U(e=>{_.current?.cancel(e.pointerId)}),E=U(e=>{e.preventDefault(),e.stopPropagation(),_.current?.openFromContextMenu(n,x)});return(0,$.jsxs)(ia,{open:p,onOpenChange:m,children:[(0,$.jsx)(Fi,{"data-mobile-press-surface":`soft`,className:G(`oc-mobile-assistant-card-shell`,h&&`bg-interactive-hover`),children:(0,$.jsxs)(ea,{render:(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-surface-trigger":!0,className:G(`oc-mobile-assistant-card`,!a&&`opacity-65`),onClick:v,onPointerDown:S,onPointerMove:C,onPointerUp:w,onPointerCancel:T,onContextMenu:E,style:{touchAction:`pan-y`}}),children:[(0,$.jsx)(`span`,{className:`oc-mobile-assistant-avatar`,children:(0,$.jsx)(Ji,{name:n,avatarSeed:e,size:44,label:r,working:f})}),(0,$.jsxs)(`span`,{className:`oc-mobile-assistant-card-content min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-entity-title oc-mobile-assistant-name block min-w-0 truncate font-semibold text-foreground`,children:r}),(0,$.jsx)(`span`,{className:G(`oc-mobile-assistant-summary`,Yi),children:i})]}),(0,$.jsx)(Qi,{count:t})]})}),(0,$.jsxs)(na,{className:`min-w-[10rem]`,children:[(0,$.jsxs)(ra,{className:`min-h-10 px-3`,onClick:y,children:[(0,$.jsx)(X,{name:`edit`,className:`size-4`}),o]}),(0,$.jsx)(ta,{}),(0,$.jsxs)(ra,{className:`min-h-10 px-3 text-[var(--status-error)] focus:text-[var(--status-error)] data-[highlighted]:text-[var(--status-error)] [&_svg]:text-[var(--status-error)]`,onClick:b,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`}),s]})]})]})}function Is(e){let t=(0,Q.c)(118),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=re(),o=Kn(),s=_e(),c=ve();c.data?.assistants;let l;t[0]===c.data?.assistants?l=t[1]:(l=c.data?.assistants??[],t[0]=c.data?.assistants,t[1]=l);let u;t[2]===l?u=t[3]:(u=qi(l),t[2]=l,t[3]=u);let d=u,f=mt(Ls),[p,m]=Z.useState(null),h;t[4]===n?h=t[5]:(h=()=>n(),t[4]=n,t[5]=h);let g=U(h),_;t[6]!==o||t[7]!==f?(_=()=>{f(),o?.openSettings(`assistants`)},t[6]=o,t[7]=f,t[8]=_):_=t[8];let v=U(_),y;t[9]===r?y=t[10]:(y=e=>r(e),t[9]=r,t[10]=y);let b=U(y),x;t[11]===o?x=t[12]:(x=e=>{gt(e,o?{openMobileSettings:o.openSettings}:void 0)},t[11]=o,t[12]=x);let S=U(x),C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{m(e)},t[13]=C):C=t[13];let w=U(C),T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{e||m(null)},t[14]=T):T=t[14];let E=U(T),D;t[15]===a?D=t[16]:(D=a(`assistants.title`),t[15]=a,t[16]=D);let O=D,k;t[17]===a?k=t[18]:(k=a(`assistants.menu.edit`),t[17]=a,t[18]=k);let A=k,j;t[19]===a?j=t[20]:(j=a(`assistants.settings.delete`),t[19]=a,t[20]=j);let M=j;if(s.isPending||s.data?.supported&&s.data.enabled&&c.isPending){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Fi,{className:`oc-mobile-assistant-loading`,children:(0,$.jsx)(Ns,{})}),t[21]=e):e=t[21];let n;return t[22]!==i||t[23]!==O?(n=(0,$.jsx)(Ri,{title:O,className:i,surface:!1,children:e}),t[22]=i,t[23]=O,t[24]=n):n=t[24],n}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length>0){let e;t[25]===a?e=t[26]:(e=a(`assistants.settings.create`),t[25]=a,t[26]=e);let n;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(X,{name:`add`,className:`size-5`}),t[27]=n):n=t[27];let r;t[28]!==v||t[29]!==e?(r=(0,$.jsx)(K,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":e,onClick:v,children:n}),t[28]=v,t[29]=e,t[30]=r):r=t[30];let o;t[31]===c.data?o=t[32]:(o=(0,$.jsx)(Gi,{snapshot:c.data,rowClassName:`flex justify-end pb-2`}),t[31]=c.data,t[32]=o);let s;t[33]===a?s=t[34]:(s=a(`assistants.listAria`),t[33]=a,t[34]=s);let l;if(t[35]!==d||t[36]!==M||t[37]!==A||t[38]!==S||t[39]!==b||t[40]!==w||t[41]!==a){let e;t[43]!==M||t[44]!==A||t[45]!==S||t[46]!==b||t[47]!==w||t[48]!==a?(e=e=>{let t=se(e.name).displayName||e.name,n=Ki(e.latestMessagePreview,a);return(0,$.jsx)(Fs,{assistantID:e.id,avatarSeed:e.avatarSeed,unreadCount:e.unreadCount??0,displayName:t,summary:n,enabled:e.enabled,editLabel:A,deleteLabel:M,assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onOpen:()=>b(e.id),onEdit:()=>S(e.id),onDelete:()=>w(e)},e.id)},t[43]=M,t[44]=A,t[45]=S,t[46]=b,t[47]=w,t[48]=a,t[49]=e):e=t[49],l=d.map(e),t[35]=d,t[36]=M,t[37]=A,t[38]=S,t[39]=b,t[40]=w,t[41]=a,t[42]=l}else l=t[42];let u;t[50]!==s||t[51]!==l?(u=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-catalog`,role:`listbox`,"aria-label":s,children:l}),t[50]=s,t[51]=l,t[52]=u):u=t[52];let f=p!==null,m;t[53]!==p||t[54]!==E||t[55]!==f?(m=(0,$.jsx)(Wi,{assistant:p,open:f,onOpenChange:E}),t[53]=p,t[54]=E,t[55]=f,t[56]=m):m=t[56];let h;return t[57]!==i||t[58]!==O||t[59]!==r||t[60]!==o||t[61]!==u||t[62]!==m?(h=(0,$.jsxs)(Ri,{title:O,className:i,surface:!1,scrollsWithPage:!0,trailing:r,children:[o,u,m]}),t[57]=i,t[58]=O,t[59]=r,t[60]=o,t[61]=u,t[62]=m,t[63]=h):h=t[63],h}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`oc-mobile-assistant-onboarding-icon`,children:(0,$.jsx)(X,{name:`ai-agent`,className:`size-5`})}),t[64]=e):e=t[64];let n;t[65]===a?n=t[66]:(n=a(`assistants.onboarding.title`),t[65]=a,t[66]=n);let r;t[67]===n?r=t[68]:(r=(0,$.jsx)(`h2`,{children:n}),t[67]=n,t[68]=r);let o;t[69]===a?o=t[70]:(o=a(`assistants.onboarding.description`),t[69]=a,t[70]=o);let s;t[71]===o?s=t[72]:(s=(0,$.jsx)(`p`,{children:o}),t[71]=o,t[72]=s);let c;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),t[73]=c):c=t[73];let l;t[74]===a?l=t[75]:(l=a(`assistants.onboarding.action`),t[74]=a,t[75]=l);let u;t[76]!==v||t[77]!==l?(u=(0,$.jsxs)(K,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:v,children:[c,l]}),t[76]=v,t[77]=l,t[78]=u):u=t[78];let d;t[79]!==r||t[80]!==s||t[81]!==u?(d=(0,$.jsxs)(Fi,{className:`oc-mobile-assistant-onboarding`,children:[e,r,s,u]}),t[79]=r,t[80]=s,t[81]=u,t[82]=d):d=t[82];let f;return t[83]!==i||t[84]!==O||t[85]!==d?(f=(0,$.jsx)(Ri,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:d}),t[83]=i,t[84]=O,t[85]=d,t[86]=f):f=t[86],f}let N=s.isSuccess&&s.data.supported===!1,P=s.isError||s.data?.supported===!0&&s.data.enabled&&c.isError,F=s.data?.supported===!0&&(s.data.enabled===!1||c.data?.enabled===!1),I;t[87]!==a||t[88]!==P||t[89]!==N?(I=a(P?`assistants.state.unavailable`:N?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[87]=a,t[88]=P,t[89]=N,t[90]=I):I=t[90];let L=I;if(F&&!P){let e;t[91]===g?e=t[92]:(e=(0,$.jsx)(Ps,{onEnable:g}),t[91]=g,t[92]=e);let n;return t[93]!==i||t[94]!==O||t[95]!==e?(n=(0,$.jsx)(Ri,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-guide-host`,children:e}),t[93]=i,t[94]=O,t[95]=e,t[96]=n):n=t[96],n}let R;t[97]===O?R=t[98]:(R=(0,$.jsx)(`span`,{className:`oc-mobile-page-section-label`,children:O}),t[97]=O,t[98]=R);let z=N?`cloud-off`:`sparkling`,B;t[99]===z?B=t[100]:(B=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground`,children:(0,$.jsx)(X,{name:z,weight:`medium`,className:`size-5`})}),t[99]=z,t[100]=B);let ee;t[101]===L?ee=t[102]:(ee=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:L}),t[101]=L,t[102]=ee);let V;t[103]!==a||t[104]!==P||t[105]!==N?(V=P?null:(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-small leading-relaxed text-muted-foreground`,children:a(N?`assistants.state.unsupportedDescription`:`assistants.state.instanceDisabledDescription`)}),t[103]=a,t[104]=P,t[105]=N,t[106]=V):V=t[106];let H;t[107]!==B||t[108]!==ee||t[109]!==V?(H=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[B,ee,V]}),t[107]=B,t[108]=ee,t[109]=V,t[110]=H):H=t[110];let te;t[111]!==R||t[112]!==H?(te=(0,$.jsx)(ji,{label:R,cardClassName:`oc-mobile-assistant-state-card`,children:H}),t[111]=R,t[112]=H,t[113]=te):te=t[113];let W;return t[114]!==i||t[115]!==O||t[116]!==te?(W=(0,$.jsx)(Ri,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:te}),t[114]=i,t[115]=O,t[116]=te,t[117]=W):W=t[117],W}function Ls(e){return e.requestCreate}function Rs(e){let t=(0,Q.c)(16),{assistantID:n,onBack:r}=e,{t:i}=re(),[a,o]=(0,Z.useState)(null),s;t[0]===i?s=t[1]:(s=i(`assistants.title`),t[0]=i,t[1]=s);let c;t[2]===i?c=t[3]:(c=i(`settings.view.actions.back`),t[2]=i,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`div`,{ref:o}),t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==s||t[7]!==c?(u=(0,$.jsx)(ye,{title:s,backAriaLabel:c,onBack:r,trailing:l}),t[5]=r,t[6]=s,t[7]=c,t[8]=u):u=t[8];let d;t[9]!==n||t[10]!==r||t[11]!==a?(d=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-[var(--oc-mobile-page-inline-inset)] pb-[var(--oc-safe-area-bottom,env(safe-area-inset-bottom,0px))]`,children:(0,$.jsx)(Fi,{className:`oc-mobile-settings-detail-card h-full`,children:(0,$.jsx)(hn,{children:(0,$.jsx)(Mi,{assistantID:n,onItemDeleted:r,saveActionContainer:a},n)})})}),t[9]=n,t[10]=r,t[11]=a,t[12]=d):d=t[12];let f;return t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`div`,{"data-settings-view":`true`,"data-mobile-settings-stage":`page-content`,className:`oc-settings-workspace oc-settings-workspace-mobile flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[u,d]}),t[13]=u,t[14]=d,t[15]=f):f=t[15],f}function zs(e){let t=(0,Q.c)(13),{route:n}=e,{t:r}=re(),i;t[0]===r?i=t[1]:(i=r(`chat.btw.title`),t[0]=r,t[1]=i);let a;t[2]===r?a=t[3]:(a=r(`header.actions.backAria`),t[2]=r,t[3]=a);let o;t[4]!==i||t[5]!==a?(o=(0,$.jsx)(ye,{title:i,backAriaLabel:a,onBack:Bs}),t[4]=i,t[5]=a,t[6]=o):o=t[6];let s;t[7]!==n.directory||t[8]!==n.sessionId?(s=(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Vt,{scope:{sessionId:n.sessionId,directory:n.directory},foot:`page`})}),t[7]=n.directory,t[8]=n.sessionId,t[9]=s):s=t[9];let c;return t[10]!==o||t[11]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[o,s]}),t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function Bs(){sr.requestAnimatedBack(`root`)}var Vs=[{id:`projects`,icon:`folder-open`,labelKey:`mobile.tabs.projects`},{id:`assistant`,icon:`sparkling`,labelKey:`mobile.tabs.assistant`},{id:`scheduled`,icon:`calendar-schedule`,labelKey:`mobile.tabs.scheduled`},{id:`settings`,icon:`settings-3`,labelKey:`mobile.tabs.settings`}];function Hs(e){let t=(0,Q.c)(22),{activeTab:n,onTabChange:r,className:i,tabMarks:a}=e,{t:o}=re(),s=xe(),c;t[0]===o?c=t[1]:(c=o(`mobile.tabs.activity.loading`),t[0]=o,t[1]=c);let l=c,u;t[2]===r?u=t[3]:(u=e=>{r(e.currentTarget.dataset.tab)},t[2]=r,t[3]=u);let d=U(u),f;t[4]!==n||t[5]!==r?(f=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Vs.findIndex(e=>e.id===n),i=Vs[e.key===`Home`?0:e.key===`End`?Vs.length-1:(t+(e.key===`ArrowRight`?1:-1)+Vs.length)%Vs.length];r(i.id),document.getElementById(`mobile-tab-${i.id}`)?.focus()},t[4]=n,t[5]=r,t[6]=f):f=t[6];let p=U(f),m;t[7]===o?m=t[8]:(m=o(`mobile.nav.aria`),t[7]=o,t[8]=m);let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h={role:`tablist`},t[9]=h):h=t[9];let g;t[10]!==n||t[11]!==s||t[12]!==d||t[13]!==p||t[14]!==l||t[15]!==o||t[16]!==a?(g=Vs.map(e=>{let t=e.id===n,r=o(e.labelKey),i=e.id===`assistant`&&s>0,c=!i&&a?.[e.id]===`loading`,u=i?`mobile-tab-assistant-unread`:c?`mobile-tab-${e.id}-activity`:void 0;return(0,$.jsxs)(K,{id:`mobile-tab-${e.id}`,"data-tab":e.id,type:`button`,role:`tab`,variant:`ghost`,size:`sm`,"aria-controls":`mobile-tabpanel-${e.id}`,"aria-label":r,"aria-describedby":u,"aria-selected":t,tabIndex:t?0:-1,title:r,onClick:d,onKeyDown:p,className:G(`oc-mobile-tab-button min-w-0 flex-1 flex-col overflow-visible`,`text-xs font-medium leading-none tracking-tight text-muted-foreground`,`transition-[background-color,color,box-shadow,transform] duration-100`,`hover:bg-transparent hover:text-foreground`,`active:bg-interactive-active`,`motion-reduce:transition-none`,t&&[`bg-interactive-selection/55 text-primary`,`hover:bg-interactive-selection/55 hover:text-primary`,`font-semibold`]),children:[(0,$.jsxs)(`span`,{className:`relative inline-flex shrink-0 overflow-visible`,children:[(0,$.jsx)(X,{name:e.icon,weight:`medium`,className:`size-[23px] shrink-0`}),u?(0,$.jsx)(`span`,{id:u,role:c?`status`:void 0,"aria-label":c?l:void 0,"data-mobile-tab-activity":c?`loading`:void 0,className:`pointer-events-none absolute left-full -top-1 ml-0.5 inline-flex z-10`,children:i?(0,$.jsx)($i,{className:`h-[18px] min-w-[18px] bg-foreground px-1 text-[11px] font-bold tracking-normal text-background shadow-none ring-2 ring-background`}):(0,$.jsx)(`span`,{className:`inline-flex size-[18px] items-center justify-center rounded-full bg-foreground text-background ring-2 ring-background`,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin`})})}):null]}),(0,$.jsx)(`span`,{className:`oc-mobile-tab-label block max-w-full overflow-hidden text-ellipsis whitespace-nowrap`,children:r})]},e.id)}),t[10]=n,t[11]=s,t[12]=d,t[13]=p,t[14]=l,t[15]=o,t[16]=a,t[17]=g):g=t[17];let _;return t[18]!==i||t[19]!==m||t[20]!==g?(_=(0,$.jsx)(Bi,{as:`nav`,"aria-label":m,variant:`navigation`,surfaceProps:h,className:i,children:g}),t[18]=i,t[19]=m,t[20]=g,t[21]=_):_=t[21],_}function Us(e){return e.unreadCount>0?`unread`:e.working?`loading`:null}var Ws=`oc-native-ios-tab-bar`,Gs=`OpenChamberTabBar`,Ks=[`projects`,`assistant`,`scheduled`,`settings`],qs=R(Gs),Js=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function Ys(){return typeof window>`u`?!1:Js({isCapacitor:j(),platform:N(),pluginAvailable:z.isPluginAvailable(Gs),nativeUiEnabled:tr()})}var Xs=e=>e.classList.contains(`dark`)?`dark`:`light`,Zs=()=>er(`--primary`),Qs=e=>typeof e==`string`&&Ks.includes(e),$s=e=>typeof e==`string`&&Qs(e)?e:null,ec=(e,t)=>e.selectedTab===t.selectedTab&&e.appearance===t.appearance&&e.ariaLabel===t.ariaLabel&&e.accentColor===t.accentColor&&e.tabs.length===t.tabs.length&&e.tabs.every((e,n)=>e.id===t.tabs[n]?.id&&e.label===t.tabs[n]?.label&&e.badge===t.tabs[n]?.badge&&e.activity===!0==(t.tabs[n]?.activity===!0)&&(e.activity===!0?e.activityLabel??null:null)===(t.tabs[n]?.activity===!0?t.tabs[n]?.activityLabel??null:null)),tc=(e,t)=>{e.classList.toggle(Ws,t)},nc=(e,t)=>e&&!t,rc=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&ec(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},ic=()=>qs,ac=`mobile-overlay-root`;function oc(e){let t=(0,Q.c)(28),n=nr(),r;t[0]===n?r=t[1]:(r=n&&Ys(),t[0]=n,t[1]=r);let i=r,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=(0,Z.useRef)(!1),p=(0,Z.useRef)(!1),m=U(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=JSON.stringify(e.tabs.map(cc)),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:Xs(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:Zs(),t[5]=y):y=t[5];let b=y,x,S;t[6]===i?(x=t[7],S=t[8]):(x=()=>{if(!i||typeof document>`u`)return;let e=document.getElementById(ac);e||(e=document.createElement(`div`),e.id=ac,document.body.appendChild(e));let t=()=>u(Wt(e.children));t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[Ut]}),()=>n.disconnect()},S=[i],t[6]=i,t[7]=x,t[8]=S),(0,Z.useEffect)(x,S);let C;t[9]!==i||t[10]!==m?(C=()=>{if(!i)return;let e=!1,t=ic(),n=[];return t.addListener(`tabSelected`,e=>{let t=$s(e.tab);t&&m(t)}).then(t=>{if(e){t.remove();return}n.push(t)}),()=>{e=!0,d.current=null,t.hide();for(let e of n)e.remove();typeof document<`u`&&tc(document.documentElement,!1)}},t[9]=i,t[10]=m,t[11]=C):C=t[11];let w;t[12]===i?w=t[13]:(w=[i],t[12]=i,t[13]=w),(0,Z.useEffect)(C,w);let T;t[14]!==e.activeTab||t[15]!==e.ariaLabel||t[16]!==e.tabs||t[17]!==e.visible||t[18]!==i||t[19]!==l?(T=()=>{if(!i||p.current)return;let t=!1,n=ic(),r={tabs:e.tabs.map(sc),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=rc({visible:nc(e.visible,l),overlayHidden:f.current,lastState:d.current,nextState:r});return(async()=>{if(a.action===`skip`)return;if(a.action===`hide`){f.current=!0,n.hide();return}let e=await n.present(r);if(!t){if(e.adopted!==!0){p.current=!0,c(!0),o(!1),typeof document<`u`&&tc(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&tc(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&tc(document.documentElement,!1))}),()=>{t=!0}},t[14]=e.activeTab,t[15]=e.ariaLabel,t[16]=e.tabs,t[17]=e.visible,t[18]=i,t[19]=l,t[20]=T):T=t[20];let E;return t[21]!==e.activeTab||t[22]!==e.ariaLabel||t[23]!==e.visible||t[24]!==i||t[25]!==l||t[26]!==g?(E=[i,e.visible,l,e.activeTab,e.ariaLabel,v,b,g],t[21]=e.activeTab,t[22]=e.ariaLabel,t[23]=e.visible,t[24]=i,t[25]=l,t[26]=g,t[27]=E):E=t[27],(0,Z.useLayoutEffect)(T,E),!i||s?`web`:a?`native`:`pending`}function sc(e){return{id:e.id,label:e.label,badge:e.badge??null,activity:e.activity===!0,activityLabel:e.activity===!0?e.activityLabel??null:null}}function cc(e){return[e.id,e.label,e.badge??null,e.activity===!0,e.activity===!0?e.activityLabel??null:null]}function lc(e){let t=(0,Q.c)(50),{tabs:n,navigation:r,onTabChange:i,secondaryPages:a,showTabBar:o,tabBarCovered:s,className:c}=e,l=a===void 0?[]:a,u=o===void 0||o,d=s!==void 0&&s,{t:f}=re(),p=r.activeTab,m=l.slice(-2),h=m.at(-1)??null,g=h?.key??null,_=h?.depth,v=m.length>1?m[m.length-2].key:null,y;t[0]===p?y=t[1]:(y=()=>new Set([p]),t[0]=p,t[1]=y);let[b,x]=Z.useState(y);b.has(p)||x(e=>{if(e.has(p))return e;let t=new Set(e);return t.add(p),t});let S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(null),T=Z.useRef(new Map),E=Z.useRef(null),D=Z.useRef(!1),O=Z.useRef(``),k=U(()=>h?.onBack());ar({id:h?`mobile-secondary:${h.key}`:`mobile-secondary:inactive`,active:!!h,onBack:k,surfaceRef:S,underlayRef:C}),Z.useLayoutEffect(()=>{let e=g===null?null:T.current.get(g)??null,t=v===null?w.current:T.current.get(v)??null;S.current=e,C.current=t},[g,_,v]);let A;t[2]===h?A=t[3]:(A=[h],t[2]=h,t[3]=A),Z.useLayoutEffect(()=>{if(h){if(!D.current){let e=document.activeElement;E.current=e instanceof HTMLElement?e:null,D.current=!0}O.current!==h.key&&(O.current=h.key,S.current?.focus());return}if(D.current){D.current=!1,O.current=``;let e=E.current;E.current=null,e&&e.isConnected&&e.focus()}},A);let j;t[4]===i?j=t[5]:(j=e=>{i(e)},t[4]=i,t[5]=j);let M=U(j),N=xe(),P=ge(),F=be(),I;t[6]===f?I=t[7]:(I=f(`mobile.tabs.activity.loading`),t[6]=f,t[7]=I);let L=I,R;t[8]!==N||t[9]!==P?(R=Us({unreadCount:N,working:P}),t[8]=N,t[9]=P,t[10]=R):R=t[10];let z=R,B;t[11]===F?B=t[12]:(B=Us({unreadCount:0,working:F}),t[11]=F,t[12]=B);let ee=B,V;t[13]!==z||t[14]!==N||t[15]!==L||t[16]!==ee||t[17]!==f?(V=Vs.map(e=>{let t=e.id===`assistant`&&z===`loading`||e.id===`scheduled`&&ee===`loading`;return{id:e.id,label:f(e.labelKey),badge:e.id===`assistant`&&z===`unread`?N>99?`99+`:String(N):null,activity:t,activityLabel:t?L:null}}),t[13]=z,t[14]=N,t[15]=L,t[16]=ee,t[17]=f,t[18]=V):V=t[18];let H=V,te=u&&!d&&!h,W;t[19]===f?W=t[20]:(W=f(`mobile.nav.aria`),t[19]=f,t[20]=W);let ne;t[21]!==M||t[22]!==te||t[23]!==H||t[24]!==p||t[25]!==W?(ne={visible:te,activeTab:p,tabs:H,ariaLabel:W,onTabChange:M},t[21]=M,t[22]=te,t[23]=H,t[24]=p,t[25]=W,t[26]=ne):ne=t[26];let ie=oc(ne),K=ie===`native`,ae=u&&ie===`web`,oe=nr(),se,ce;t[27]!==oe||t[28]!==K?(se=()=>{if(!oe){cr.shutdown();return}K&&or(!0)&&cr.warm()},ce=[oe,K],t[27]=oe,t[28]=K,t[29]=se,t[30]=ce):(se=t[29],ce=t[30]),Z.useEffect(se,ce);let q;t[31]===c?q=t[32]:(q=G(`oc-mobile-floating-shell relative isolate flex h-full min-h-0 flex-col overflow-hidden text-foreground`,`bg-[var(--oc-mobile-page-background)]`,c),t[31]=c,t[32]=q);let J=h?!0:void 0,le=h?!0:void 0,ue;t[33]!==p||t[34]!==u||t[35]!==ae||t[36]!==f||t[37]!==n||t[38]!==b?(ue=Vs.map(e=>{let t=b.has(e.id);return(0,$.jsx)(`section`,{id:`mobile-tabpanel-${e.id}`,role:`tabpanel`,"aria-labelledby":ae?`mobile-tab-${e.id}`:void 0,"aria-label":ae?void 0:f(e.labelKey),hidden:p!==e.id,tabIndex:0,className:G(`scrollbar-none h-full min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--oc-mobile-page-inline-inset)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+1rem)] outline-none`,u?`pb-[calc(var(--oc-mobile-dock-height)+2.5rem+var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px)))]`:`pb-0`),children:t?n?.[e.id]??(0,$.jsx)(uc,{tab:e.id,icon:e.icon}):null},e.id)}),t[33]=p,t[34]=u,t[35]=ae,t[36]=f,t[37]=n,t[38]=b,t[39]=ue):ue=t[39];let de;t[40]!==w||t[41]!==J||t[42]!==le||t[43]!==ue?(de=(0,$.jsx)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":J,inert:le,className:`flex h-full min-h-0 flex-1 flex-col`,children:ue}),t[40]=w,t[41]=J,t[42]=le,t[43]=ue,t[44]=de):de=t[44];let fe=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||K?!0:void 0,inert:h||K?!0:void 0,children:ae?(0,$.jsx)(Hs,{activeTab:p,onTabChange:M,tabMarks:{assistant:z===`loading`?`loading`:null,scheduled:ee===`loading`?`loading`:null}}):null}):null,pe=m.map((e,t)=>{let n=t===m.length-1;return(0,$.jsx)(`div`,{ref:t=>{t?T.current.set(e.key,t):T.current.delete(e.key)},"data-mobile-secondary-page":`true`,"data-mobile-secondary-active":n?`true`:`false`,role:n?`dialog`:void 0,"aria-modal":n?!0:void 0,"aria-label":n?e.ariaLabel??f(`mobile.nav.secondaryPageAria`):void 0,"aria-hidden":!n||void 0,inert:!n||void 0,tabIndex:n?-1:void 0,className:G(`absolute inset-0 flex h-full min-h-0 flex-col overflow-hidden bg-background outline-none`,n?`z-50`:`z-40`),children:e.content},e.key)}),me;return t[45]!==q||t[46]!==de||t[47]!==fe||t[48]!==pe?(me=(0,$.jsxs)(`div`,{className:q,children:[de,fe,pe]}),t[45]=q,t[46]=de,t[47]=fe,t[48]=pe,t[49]=me):me=t[49],me}function uc(e){let t=(0,Q.c)(17),{tab:n,icon:r,className:i}=e,{t:a}=re(),o,s,c,l;if(t[0]!==i||t[1]!==r||t[2]!==a||t[3]!==n){let e=Vs.find(e=>e.id===n)??Vs[0];t[8]===i?c=t[9]:(c=G(`flex min-h-[70dvh] flex-col items-center justify-center gap-3 text-center`,i),t[8]=i,t[9]=c),l=(0,$.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:r??e.icon,className:`size-6`})}),o=`typography-ui-label font-semibold tracking-[-0.01em] text-foreground`,s=a(e.labelKey),t[0]=i,t[1]=r,t[2]=a,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];let u;t[10]!==o||t[11]!==s?(u=(0,$.jsx)(`h1`,{className:o,children:s}),t[10]=o,t[11]=s,t[12]=u):u=t[12];let d;return t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:c,children:[l,u]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}var dc={neutral:void 0,info:{color:`var(--status-info)`,backgroundColor:`var(--status-info-background)`},success:{color:`var(--status-success)`,backgroundColor:`var(--status-success-background)`},warning:{color:`var(--status-warning)`,backgroundColor:`var(--status-warning-background)`},error:{color:`var(--status-error)`,backgroundColor:`var(--status-error-background)`}},fc=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/g,``);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n.length<=1?t:n.length===2?n[0]:n.slice(-3,-1).join(`/`)};function pc({project:e,expanded:t,embedded:n=!1,onToggle:r,onOpenActions:i,className:a,highlightQuery:o}){let{t:s}=re(),[c,l]=Z.useState(!1),u=Z.useRef(null);u.current||=br({onPressedKeyChange:t=>l(t===e.id)}),Z.useEffect(()=>()=>u.current?.reset(),[]);let d=U(()=>{u.current?.consumeClick(e.id)||r(e)}),f=U(()=>i?.(e)),p=U(t=>{if(!i||t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0)return;let n=i;u.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{l(!1),n(e)}})}),m=U(e=>{u.current?.move(e.pointerId,e.clientX,e.clientY)}),h=U(e=>{u.current?.end(e.pointerId)}),g=U(e=>{u.current?.cancel(e.pointerId)}),_=U(t=>{if(!i)return;let n=i;t.preventDefault(),t.stopPropagation(),u.current?.openFromContextMenu(e.id,()=>{l(!1),n(e)})}),v=e.sessionCount===1?s(`mobile.sessions.project.sessionsSingle`):s(`mobile.sessions.project.sessionsPlural`,{count:e.sessionCount}),y=fc(e.path),b=(0,$.jsxs)(`article`,{"data-mobile-press-surface":`soft`,"data-pressed":c?`true`:void 0,className:G(`oc-mobile-project-card relative flex items-stretch overflow-hidden rounded-[var(--oc-mobile-surface-radius)]`,a),children:[(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-surface-trigger":!0,className:`oc-mobile-project-trigger flex min-w-0 flex-1 items-center text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-expanded":t,onClick:d,onPointerDown:p,onPointerMove:m,onPointerUp:h,onPointerCancel:g,onContextMenu:_,style:{touchAction:`pan-y`},children:[(0,$.jsx)(`span`,{className:G(`oc-mobile-project-icon oc-mobile-glass-control flex shrink-0 items-center justify-center rounded-full text-muted-foreground`),style:dc[e.tone??`neutral`],"aria-hidden":!0,children:(0,$.jsx)(X,{name:e.icon??`code-box`,className:`oc-mobile-project-icon-glyph`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-project-title oc-mobile-entity-title truncate font-semibold text-foreground`,children:o?gn(e.name,o):e.name}),e.active?(0,$.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-[var(--status-success)] shadow-[0_0_0_3px_color-mix(in_srgb,var(--status-success)_12%,transparent)]`,"aria-label":s(`mobile.sessions.activeProjectAria`)}):null]}),(0,$.jsxs)(`span`,{className:`oc-mobile-project-meta oc-mobile-entity-meta flex min-w-0 items-center text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:v}),e.activityLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.activityLabel})]}):null,y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,title:e.path,children:y})]}):null]})]}),(0,$.jsx)(X,{name:`arrow-down-s`,className:G(`oc-mobile-project-chevron shrink-0 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,t?`rotate-0`:`-rotate-90`)})]}),i?(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-project-action self-center rounded-full text-muted-foreground`,"aria-label":s(`sessions.sidebar.project.actions.projectMenu`),onClick:f,children:(0,$.jsx)(X,{name:`more-2`,className:`size-4`})}):null]});return n?b:(0,$.jsx)(Fi,{asChild:!0,children:b})}var mc=({hasPendingQuestion:e,hasPendingPermission:t,running:n,unread:r})=>e?`question`:t?`permission`:n?`running`:r?`completed-unread`:`idle`,hc=10,gc=`oc:mobile-session-row-revealed`,_c=e=>{window.dispatchEvent(new CustomEvent(gc,{detail:e}))};function vc({session:e,depth:t=0,hasChildren:n=!1,expanded:r=!1,paginationContinues:i=!1,onToggleChildren:a,onSelect:o,onPin:s,onArchive:c,onOpenActions:l,indicator:u,className:d,highlightQuery:f}){let{t:p}=re(),[m,h]=Z.useState(0),[g,_]=Z.useState(!1),v=Z.useRef(null),y=Z.useRef(!1),b=Z.useRef(null),x=Z.useRef(null);x.current||=br(),Z.useEffect(()=>()=>x.current?.reset(),[]),Z.useEffect(()=>{let t=t=>{t.detail!==e.id&&h(0)};return window.addEventListener(gc,t),()=>window.removeEventListener(gc,t)},[e.id]),Z.useEffect(()=>{h(0)},[e.id]);let S=U(()=>h(0)),C=m!==0,w=U(t=>{if(t.button!==0||t.pointerType!==`touch`&&t.pointerType!==`pen`)return;let n=b.current?.offsetWidth??0;n<=0||(v.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startOffset:m,actionWidth:n,intent:`pending`},y.current=!1,x.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{l(e)}}))}),T=U(t=>{let n=v.current;if(!n||n.pointerId!==t.pointerId)return;let r=t.clientX-n.startX,i=t.clientY-n.startY;if(x.current?.move(t.pointerId,t.clientX,t.clientY),n.intent===`pending`){let a=Math.abs(r),o=Math.abs(i);if(o>hc&&o>a){n.intent=`vertical`,v.current=null,x.current?.cancel(t.pointerId);return}if(a>hc&&a>o){n.intent=`horizontal`,_(!0),y.current=!0,x.current?.cancel(t.pointerId);try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}_c(e.id)}}if(n.intent!==`horizontal`)return;t.preventDefault();let a=Math.max(-n.actionWidth,Math.min(0,n.startOffset+r));h(a)}),E=U(e=>{let t=v.current;x.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(v.current=null,t.intent===`horizontal`&&(_(!1),h(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),D=U(e=>{let t=v.current;v.current=null,x.current?.cancel(e.pointerId),_(!1),h(t?.startOffset??0)}),O=U(()=>{if(!x.current?.consumeClick(e.id)){if(y.current){y.current=!1;return}if(m!==0){S();return}_c(e.id),o(e)}}),k=U(t=>{t.preventDefault(),t.stopPropagation(),x.current?.openFromContextMenu(e.id,()=>{l(e)})}),A=U(()=>{S(),s(e)}),j=U(()=>{S(),c(e)}),M=U(()=>l(e)),N=U(()=>a?.()),P=e.pinned?p(`sessions.sidebar.session.menu.unpin`):p(`sessions.sidebar.session.menu.pin`),F=u??mc({hasPendingQuestion:!1,hasPendingPermission:!1,running:!1,unread:!!e.unread}),I=F===`question`?p(`sessions.sidebar.session.status.questionRequired`):F===`permission`?p(`sessions.sidebar.session.status.permissionRequired`):F===`running`?p(`sessions.sidebar.session.status.active`):F===`completed-unread`?p(`sessions.sidebar.session.status.unread`):void 0;return e.kind===`pagination`?(0,$.jsx)(`div`,{className:G(`oc-mobile-session-row`,i&&`oc-mobile-session-pagination-continues`,d),children:(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-pagination-row`,style:{touchAction:`pan-y`},onClick:O,onPointerDown:()=>void 0,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium text-foreground typography-meta`,children:e.title}),e.subtitle?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.subtitle}):null,(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`})]})}):(0,$.jsxs)(`div`,{className:G(`oc-mobile-session-row relative isolate`,d),children:[(0,$.jsxs)(`div`,{ref:b,className:G(`oc-mobile-session-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,g?`transition-none`:`transition-transform duration-150 ease-out`,!C&&`invisible pointer-events-none`),style:{transform:`translate3d(calc(var(--oc-mobile-session-actions-width) + ${m}px), 0, 0)`,willChange:m===0?void 0:`transform`},"aria-hidden":!C,children:[(0,$.jsxs)(K,{type:`button`,variant:`secondary`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":P,tabIndex:C?0:-1,onClick:A,children:[(0,$.jsx)(X,{name:e.pinned?`unpin`:`pushpin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:P})]}),(0,$.jsxs)(K,{type:`button`,variant:`destructive`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 px-1`,"aria-label":p(`sessions.sidebar.bulkActions.archive`),tabIndex:C?0:-1,onClick:j,children:[(0,$.jsx)(X,{name:`archive`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:p(`sessions.sidebar.bulkActions.archive`)})]})]}),(0,$.jsxs)(`div`,{className:G(`oc-mobile-session-row-content relative z-10 flex items-center`,`text-foreground`,`ease-out motion-reduce:transition-none`,g?`transition-none`:`transition-[transform,background-color] duration-150`,e.archived&&`opacity-55`),"data-dragging":g?`true`:void 0,style:{transform:`translate3d(${m}px, 0, 0)`,willChange:m===0?void 0:`transform`},children:[n&&a?(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,className:`min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":p(r?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:N,children:(0,$.jsx)(X,{name:`arrow-down-s`,className:G(`size-3.5 transition-transform duration-150 motion-reduce:transition-none`,r?`rotate-0`:`-rotate-90`)})}):null,(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-row-main flex min-w-0 flex-1 items-center text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,style:{paddingLeft:16+Math.min(t,4)*12,touchAction:`pan-y`},onClick:O,onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:D,onContextMenu:k,children:[(0,$.jsx)(`span`,{className:`oc-mobile-session-status shrink-0`,"data-session-status":F,"aria-hidden":!I||void 0,"aria-label":I,title:I,children:F===`running`?(0,$.jsx)(Jr,{className:`motion-reduce:[&_svg]:animate-none`}):F===`question`?(0,$.jsx)(X,{name:`question`,className:`size-3.5 text-[var(--status-warning)]`}):F===`permission`?(0,$.jsx)(X,{name:`shield`,className:`size-3.5 text-destructive`}):(0,$.jsx)(`span`,{className:G(`oc-mobile-session-dot rounded-full`,F===`completed-unread`?`bg-[var(--status-info)]`:`bg-muted-foreground/35`)})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:G(`oc-mobile-session-title truncate`,e.unread?`font-semibold`:`font-medium`),children:f?gn(e.title,f):e.title}),e.changes?(0,$.jsx)(`span`,{className:`oc-mobile-session-changes shrink-0 tabular-nums text-muted-foreground`,children:e.changes}):null,e.archived?(0,$.jsx)(X,{name:`archive`,className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}):null]}),e.subtitle?(0,$.jsx)(`span`,{className:`oc-mobile-session-subtitle truncate text-muted-foreground`,children:f?gn(e.subtitle,f):e.subtitle}):null]}),(0,$.jsx)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-muted-foreground`,children:e.activityLabel?(0,$.jsx)(`span`,{className:`oc-mobile-session-time tabular-nums`,children:e.activityLabel}):null})]}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,className:`mr-1 min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":p(`sessions.sidebar.session.menu.label`),onClick:M,children:(0,$.jsx)(X,{name:`more-2`,className:`size-3.5`})})]})]})}var yc=Z.memo(vc),bc=10,xc=`oc:mobile-worktree-row-revealed`,Sc=e=>{window.dispatchEvent(new CustomEvent(xc,{detail:e}))};function Cc(e){let t=(0,Q.c)(10),n=ct(e.session.id),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={bootstrap:!1},t[0]=r):r=t[0];let i=Qe(e.session.id,e.session.directory,r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a={bootstrap:!1},t[1]=a):a=t[1];let o=it(e.session.id,e.session.directory,a).length>0,s=i.length>0,c=!!e.session.unread,l;t[2]!==n||t[3]!==o||t[4]!==s||t[5]!==c?(l=mc({hasPendingQuestion:o,hasPendingPermission:s,running:n,unread:c}),t[2]=n,t[3]=o,t[4]=s,t[5]=c,t[6]=l):l=t[6];let u=l,d;return t[7]!==u||t[8]!==e?(d=(0,$.jsx)(yc,{...e,indicator:u}),t[7]=u,t[8]=e,t[9]=d):d=t[9],d}var wc=Z.memo(Cc);function Tc(e){let t=(0,Q.c)(9),{sessions:n,onSelectSession:r,onPinSession:i,onArchiveSession:a,onOpenSessionActions:o,highlightQuery:s}=e,c;t[0]!==s||t[1]!==a||t[2]!==o||t[3]!==i||t[4]!==r||t[5]!==n?(c=n.map((e,t)=>{let c=e.kind===`pagination`&&n[t+1]?.kind===`pagination`,l=e.kind===`pagination`?yc:wc;return(0,$.jsx)(l,{session:e,paginationContinues:c,highlightQuery:s,onSelect:r,onPin:i,onArchive:a,onOpenActions:o},e.id)}),t[0]=s,t[1]=a,t[2]=o,t[3]=i,t[4]=r,t[5]=n,t[6]=c):c=t[6];let l;return t[7]===c?l=t[8]:(l=(0,$.jsx)($.Fragment,{children:c}),t[7]=c,t[8]=l),l}var Ec=Z.memo(Tc);function Dc({project:e,worktree:t,expanded:n,onToggle:r,onNewSession:i,onOpenActions:a,onDelete:o,highlightQuery:s}){let{t:c}=re(),l=`${e.id}::${t.id}`,u=!!(i||o),d=!!a,f=Number(!!i)+Number(!!o),[p,m]=Z.useState(0),[h,g]=Z.useState(!1),[_,v]=Z.useState(!1),y=Z.useRef(null),b=Z.useRef(!1),x=Z.useRef(null),S=Z.useRef(null);S.current||=br({onPressedKeyChange:e=>g(e===l)}),Z.useEffect(()=>()=>S.current?.reset(),[]),Z.useEffect(()=>{let e=e=>{e.detail!==l&&m(0)};return window.addEventListener(xc,e),()=>window.removeEventListener(xc,e)},[l]),Z.useEffect(()=>{m(0)},[l]);let C=U(()=>m(0)),w=p!==0,T=U(n=>{if(n.button===0&&(n.pointerType===`touch`||n.pointerType===`pen`)){if(u){let e=x.current?.offsetWidth??0;e>0&&(y.current={pointerId:n.pointerId,startX:n.clientX,startY:n.clientY,startOffset:p,actionWidth:e,intent:`pending`},b.current=!1)}d&&S.current?.start({pointerId:n.pointerId,key:l,clientX:n.clientX,clientY:n.clientY,onTrigger:()=>{g(!1),a?.(e,t)}})}}),E=U(e=>{let t=y.current;if(!t||t.pointerId!==e.pointerId){S.current?.move(e.pointerId,e.clientX,e.clientY);return}let n=e.clientX-t.startX,r=e.clientY-t.startY;if(S.current?.move(e.pointerId,e.clientX,e.clientY),t.intent===`pending`){let i=Math.abs(n),a=Math.abs(r);if(a>bc&&a>i){t.intent=`vertical`,y.current=null,S.current?.cancel(e.pointerId);return}if(i>bc&&i>a){t.intent=`horizontal`,v(!0),b.current=!0,S.current?.cancel(e.pointerId);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}Sc(l)}}if(t.intent!==`horizontal`)return;e.preventDefault();let i=Math.max(-t.actionWidth,Math.min(0,t.startOffset+n));m(i)}),D=U(e=>{let t=y.current;S.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(y.current=null,t.intent===`horizontal`&&(v(!1),m(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),O=U(e=>{let t=y.current;y.current=null,S.current?.cancel(e.pointerId),v(!1),m(t?.startOffset??0)}),k=U(()=>{if(!S.current?.consumeClick(l)){if(b.current){b.current=!1;return}if(p!==0){C();return}r()}}),A=U(n=>{d&&(n.preventDefault(),n.stopPropagation(),S.current?.openFromContextMenu(l,()=>{g(!1),a?.(e,t)}))}),j=U(()=>{C(),i?.(e,t)}),M=U(()=>{C(),o?.(e,t)}),N=U(()=>a?.(e,t)),P=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`oc-mobile-group-label-icon`,"aria-hidden":!0,children:(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left oc-mobile-entity-title font-semibold text-foreground`,children:s?gn(t.name,s):t.name}),(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:t.sessionCount===1?c(`mobile.sessions.project.sessionsSingle`):c(`mobile.sessions.project.sessionsPlural`,{count:t.sessionCount})}),(0,$.jsx)(X,{name:`arrow-down-s`,className:G(`size-3.5 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,n?`rotate-0`:`-rotate-90`)})]});return(0,$.jsxs)(`div`,{className:`oc-mobile-group-label oc-mobile-worktree-label relative isolate overflow-hidden`,children:[u?(0,$.jsxs)(`div`,{ref:x,className:G(`oc-mobile-worktree-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,_?`transition-none`:`transition-transform duration-150 ease-out`,!w&&`invisible pointer-events-none`),style:{width:`calc(${f} * var(--oc-mobile-worktree-action-width))`,transform:`translate3d(calc(100% + ${p}px), 0, 0)`,willChange:p===0?void 0:`transform`},"aria-hidden":!w,children:[i?(0,$.jsxs)(K,{type:`button`,variant:`secondary`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":c(`mobile.sessions.newSessionAria`),tabIndex:w?0:-1,onClick:j,children:[(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:c(`sessions.sidebar.project.actions.newSession`)})]}):null,o?(0,$.jsxs)(K,{type:`button`,variant:`destructive`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 px-1`,"aria-label":c(`mobile.projectEdit.deleteWorktreeAria`,{label:t.name}),tabIndex:w?0:-1,onClick:M,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:c(`mobile.projectEdit.deleteWorktreeConfirmButton`)})]}):null]}):null,(0,$.jsxs)(`div`,{className:G(`oc-mobile-worktree-label-content relative z-10 flex min-w-0 flex-1 items-center`,`ease-out motion-reduce:transition-none`,_?`transition-none`:`transition-transform duration-150`),style:{transform:`translate3d(${p}px, 0, 0)`,willChange:p===0?void 0:`transform`},"data-pressed":h?`true`:void 0,children:[(0,$.jsx)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-group-label-trigger oc-mobile-worktree-label-trigger`,"aria-expanded":n,onClick:k,onPointerDown:T,onPointerMove:E,onPointerUp:D,onPointerCancel:O,onContextMenu:A,style:{touchAction:`pan-y`},children:P}),d?(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-worktree-more rounded-full text-muted-foreground`,"aria-label":c(`agentManager.detail.actions.worktreeActionsAria`),onClick:N,children:(0,$.jsx)(X,{name:`more-2`,className:`size-3.5`})}):null]})]})}function Oc(e){let t=(0,Q.c)(88),{projects:n,pinnedSessions:r,inProgressSessions:i,onAddProject:a,onNewSession:o,onScanQr:s,onSwitchInstance:c,onToggleProject:l,onOpenProjectActions:u,onToggleWorktree:d,onNewWorktreeSession:f,onOpenWorktreeActions:p,onDeleteWorktree:m,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v,className:y}=e,b;t[0]===i?b=t[1]:(b=i===void 0?[]:i,t[0]=i,t[1]=b);let x=b,{t:S}=re(),[C,w]=Z.useState(!0),[T,E]=Z.useState(!1),D=U(a),O=U(o),k;t[2]===s?k=t[3]:(k=()=>s?.(),t[2]=s,t[3]=k);let A=U(k),j;t[4]===c?j=t[5]:(j=()=>c?.(),t[4]=c,t[5]=j);let M=U(j),N;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>E(e),t[6]=N):N=t[6];let P=U(N),F;t[7]===y?F=t[8]:(F=G(`relative isolate mx-auto flex w-full max-w-[26rem] flex-col gap-5`,y),t[7]=y,t[8]=F);let I;t[9]===S?I=t[10]:(I=S(`mobile.sessions.section.projects`),t[9]=S,t[10]=I);let L;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(ri,{mobile:!0}),t[11]=L):L=t[11];let R;t[12]===S?R=t[13]:(R=S(`mobile.projects.menu.label`),t[12]=S,t[13]=R);let z=T?`rotate-45`:`rotate-0`,B;t[14]===z?B=t[15]:(B=G(`size-5 transition-transform duration-150 motion-reduce:transition-none`,z),t[14]=z,t[15]=B);let ee;t[16]===B?ee=t[17]:(ee=(0,$.jsx)(X,{name:`add`,className:B}),t[16]=B,t[17]=ee);let V;t[18]!==ee||t[19]!==R?(V=(0,$.jsx)(Tn,{asChild:!0,children:(0,$.jsx)(K,{type:`button`,size:`mobileIcon`,className:`oc-mobile-round-control border-transparent bg-[var(--primary-base)] text-[var(--primary-foreground)] shadow-[0_10px_22px_color-mix(in_srgb,var(--primary-base)_22%,transparent)] hover:bg-[var(--primary-hover)] dark:bg-[var(--primary-base)] dark:hover:bg-[var(--primary-hover)]`,"aria-label":R,children:ee})}),t[18]=ee,t[19]=R,t[20]=V):V=t[20];let H;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(X,{name:`chat-new`,className:`size-4`}),t[21]=H):H=t[21];let te;t[22]===S?te=t[23]:(te=S(`mobile.projects.menu.newChat`),t[22]=S,t[23]=te);let W;t[24]!==O||t[25]!==te?(W=(0,$.jsxs)(wn,{className:`min-h-11`,onSelect:O,children:[H,te]}),t[24]=O,t[25]=te,t[26]=W):W=t[26];let ne;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(X,{name:`folder`,className:`size-4`}),t[27]=ne):ne=t[27];let ie;t[28]===S?ie=t[29]:(ie=S(`mobile.projects.menu.newProject`),t[28]=S,t[29]=ie);let ae;t[30]!==D||t[31]!==ie?(ae=(0,$.jsxs)(wn,{className:`min-h-11`,onSelect:D,children:[ne,ie]}),t[30]=D,t[31]=ie,t[32]=ae):ae=t[32];let oe;t[33]!==A||t[34]!==s||t[35]!==S?(oe=s?(0,$.jsxs)(wn,{className:`min-h-11`,onSelect:A,children:[(0,$.jsx)(X,{name:`scan-2`,className:`size-4`}),S(`mobile.projects.menu.scanQr`)]}):null,t[33]=A,t[34]=s,t[35]=S,t[36]=oe):oe=t[36];let se;t[37]!==M||t[38]!==c||t[39]!==S?(se=c?(0,$.jsxs)(wn,{className:`min-h-11`,onSelect:M,children:[(0,$.jsx)(X,{name:`server`,className:`size-4`}),S(`mobile.projects.menu.switchInstance`)]}):null,t[37]=M,t[38]=c,t[39]=S,t[40]=se):se=t[40];let ce;t[41]!==W||t[42]!==ae||t[43]!==oe||t[44]!==se?(ce=(0,$.jsxs)(Sn,{align:`end`,side:`bottom`,className:`min-w-44`,children:[W,ae,oe,se]}),t[41]=W,t[42]=ae,t[43]=oe,t[44]=se,t[45]=ce):ce=t[45];let q;t[46]!==P||t[47]!==T||t[48]!==V||t[49]!==ce?(q=(0,$.jsxs)($.Fragment,{children:[L,(0,$.jsxs)(En,{open:T,onOpenChange:P,children:[V,ce]})]}),t[46]=P,t[47]=T,t[48]=V,t[49]=ce,t[50]=q):q=t[50];let J;t[51]!==q||t[52]!==I?(J=(0,$.jsx)(Lr,{title:I,trailing:q}),t[51]=q,t[52]=I,t[53]=J):J=t[53];let le;t[54]!==x||t[55]!==_||t[56]!==v||t[57]!==g||t[58]!==h||t[59]!==C||t[60]!==r||t[61]!==S?(le=r.length>0||x.length>0?(0,$.jsx)(Fi,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":S(`mobile.sessions.section.pinned`),children:[(0,$.jsx)(pc,{project:{id:`__pinned__`,name:S(`mobile.sessions.section.pinned`),path:``,icon:`pushpin`,sessionCount:r.length+x.length},expanded:C,embedded:!0,onToggle:()=>w(Ac)}),C?(0,$.jsxs)(`div`,{className:`oc-mobile-project-groups`,role:`group`,children:[r.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(Ec,{sessions:r,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,x.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(Ec,{sessions:x,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null]}):null]})}):null,t[54]=x,t[55]=_,t[56]=v,t[57]=g,t[58]=h,t[59]=C,t[60]=r,t[61]=S,t[62]=le):le=t[62];let ue;t[63]!==D||t[64]!==_||t[65]!==m||t[66]!==f||t[67]!==u||t[68]!==v||t[69]!==p||t[70]!==g||t[71]!==h||t[72]!==l||t[73]!==d||t[74]!==n||t[75]!==S?(ue=n.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[52dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(`span`,{className:`mb-4 flex size-14 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:`folder-add`,className:`size-6`})}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:S(`mobile.sessions.empty.noProjectsTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:S(`mobile.sessions.empty.noProjectsDescription`)}),(0,$.jsxs)(K,{type:`button`,size:`lg`,className:`mt-4 min-h-10 rounded-full px-5`,onClick:D,children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),S(`sessions.sidebar.header.actions.addProject`)]})]}):n.map(e=>{let t=e.expanded,n=e.worktrees.find(kc)??(e.worktrees.length===1&&!e.worktrees[0]?.kind?e.worktrees[0]:void 0),r=e.worktrees.filter(e=>e!==n),i=n?.sessions??[];return(0,$.jsx)(Fi,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":e.name,children:[(0,$.jsx)(pc,{project:e,expanded:t,embedded:!0,onToggle:()=>l(e),onOpenActions:()=>u(e)}),t?(0,$.jsxs)(`div`,{className:`oc-mobile-project-groups`,role:`group`,"aria-label":e.name,children:[i.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(Ec,{sessions:i,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,r.map(t=>{let n=!!t.expanded;return(0,$.jsx)(ji,{className:`oc-mobile-worktree-group`,ariaLabel:t.name,label:(0,$.jsx)(Dc,{project:e,worktree:t,expanded:n,onToggle:()=>d(e,t),onNewSession:f,onOpenActions:p,onDelete:m}),children:n&&t.sessions.length>0?(0,$.jsx)(Ec,{sessions:t.sessions,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v}):null},t.id)})]}):null]})},e.id)}),t[63]=D,t[64]=_,t[65]=m,t[66]=f,t[67]=u,t[68]=v,t[69]=p,t[70]=g,t[71]=h,t[72]=l,t[73]=d,t[74]=n,t[75]=S,t[76]=ue):ue=t[76];let de;t[77]===S?de=t[78]:(de=S(`sessions.sidebar.header.actions.addProject`),t[77]=S,t[78]=de);let fe;t[79]!==D||t[80]!==de?(fe=(0,$.jsx)(`button`,{type:`button`,className:`sr-only`,onClick:D,children:de}),t[79]=D,t[80]=de,t[81]=fe):fe=t[81];let pe;return t[82]!==J||t[83]!==le||t[84]!==ue||t[85]!==fe||t[86]!==F?(pe=(0,$.jsxs)(`main`,{className:F,children:[J,le,ue,fe]}),t[82]=J,t[83]=le,t[84]=ue,t[85]=fe,t[86]=F,t[87]=pe):pe=t[87],pe}function kc(e){return e.kind===`main`}function Ac(e){return!e}function jc(e){let t=(0,Q.c)(13),{icon:n,label:r,onClick:i,destructive:a,disabled:o,spinning:s}=e,c=a!==void 0&&a,l=o!==void 0&&o,u=s!==void 0&&s,d;t[0]===i?d=t[1]:(d=()=>{ke(`light`),i()},t[0]=i,t[1]=d);let f=U(d),p=c?`destructive`:`ghost`,m=u?`size-5 animate-spin`:`size-5`,h;t[2]!==n||t[3]!==m?(h=(0,$.jsx)(X,{name:n,className:m}),t[2]=n,t[3]=m,t[4]=h):h=t[4];let g;t[5]===r?g=t[6]:(g=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[5]=r,t[6]=g);let _;return t[7]!==l||t[8]!==f||t[9]!==p||t[10]!==h||t[11]!==g?(_=(0,$.jsxs)(K,{type:`button`,variant:p,size:`lg`,className:`h-auto min-h-14 w-full justify-start gap-3 rounded-none supports-[corner-shape:squircle]:rounded-none px-4 leading-6 border-b border-[var(--surface-subtle)] last:border-b-0 active:bg-interactive-active dark:active:bg-interactive-active`,"data-mobile-press-feedback":`none`,disabled:l,onClick:f,children:[h,g]}),t[7]=l,t[8]=f,t[9]=p,t[10]=h,t[11]=g,t[12]=_):_=t[12],_}function Mc(e,t,n){return e.reduce((e,t)=>{let n=!!t.separated,r=e.at(-1);return r?.separated===n?r.items.push(t):e.push({separated:n,items:[t]}),e},[]).map(e=>(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl bg-[var(--surface-muted)]`,"data-mobile-action-group":e.separated?`separated`:`standard`,children:e.items.map(e=>(0,$.jsx)(jc,{icon:e.icon,label:Ei(e,t),onClick:n(e.onClick),destructive:e.destructive,disabled:e.disabled,spinning:e.spinning},e.id))},e.items[0]?.id))}function Nc(e){let t=(0,Q.c)(46),{open:n,target:r,actions:i,onOpenChange:a,refreshTranscriptDisabled:o,refreshTranscriptSpinning:s}=e,c=o!==void 0&&o,l=s!==void 0&&s,{t:u}=re(),d;t[0]===a?d=t[1]:(d=e=>()=>{a(!1),e?.()},t[0]=a,t[1]=d);let f=d,p;bb0:{if(!r){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[2]=e):e=t[2],p=e;break bb0}if(r.kind===`session`){let e;t[3]!==i.onArchive||t[4]!==i.onCopyLink||t[5]!==i.onDelete||t[6]!==i.onRefreshTranscript||t[7]!==i.onRename||t[8]!==i.onShare||t[9]!==i.onTogglePin||t[10]!==i.onUnshare||t[11]!==c||t[12]!==l||t[13]!==r.pinned||t[14]!==r.shared?(e=Zr({pinned:r.pinned,shared:r.shared,onRename:i.onRename,onTogglePin:i.onTogglePin,onShare:i.onShare,onCopyLink:i.onCopyLink,onUnshare:i.onUnshare,onRefreshTranscript:i.onRefreshTranscript,onArchive:i.onArchive,onDelete:i.onDelete,refreshTranscriptDisabled:c,refreshTranscriptSpinning:l}),t[3]=i.onArchive,t[4]=i.onCopyLink,t[5]=i.onDelete,t[6]=i.onRefreshTranscript,t[7]=i.onRename,t[8]=i.onShare,t[9]=i.onTogglePin,t[10]=i.onUnshare,t[11]=c,t[12]=l,t[13]=r.pinned,t[14]=r.shared,t[15]=e):e=t[15],p=e;break bb0}if(r.kind===`project`){let e;t[16]!==i.onCloseProject||t[17]!==i.onEditProject||t[18]!==i.onNewSession||t[19]!==i.onNewWorktree||t[20]!==i.onSyncSessions||t[21]!==r.gitRepository?(e=Di({gitRepository:r.gitRepository,onNewSession:i.onNewSession,onNewWorktree:i.onNewWorktree,onSyncSessions:i.onSyncSessions,onEditProject:i.onEditProject,onCloseProject:i.onCloseProject}),t[16]=i.onCloseProject,t[17]=i.onEditProject,t[18]=i.onNewSession,t[19]=i.onNewWorktree,t[20]=i.onSyncSessions,t[21]=r.gitRepository,t[22]=e):e=t[22],p=e;break bb0}let e;t[23]!==i.onDeleteWorktree||t[24]!==i.onNewSession?(e=Hr({onNewSession:i.onNewSession,onDeleteWorktree:i.onDeleteWorktree}),t[23]=i.onDeleteWorktree,t[24]=i.onNewSession,t[25]=e):e=t[25],p=e}let m=p;if(!r)return null;let h;t[26]===r.title?h=t[27]:(h=(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:r.title}),t[26]=r.title,t[27]=h);let g=r.title,_;t[28]===u?_=t[29]:(_=u(`mobile.surface.closeAria`),t[28]=u,t[29]=_);let v;t[30]===u?v=t[31]:(v=u(`mobile.sessions.sheet.resizeAria`),t[30]=u,t[31]=v);let y;t[32]!==m||t[33]!==f||t[34]!==u?(y=Mc(m,u,f),t[32]=m,t[33]=f,t[34]=u,t[35]=y):y=t[35];let b;t[36]===y?b=t[37]:(b=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain px-3 pb-3`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-5`,"data-page-scroll-lock":`true`,children:y})}),t[36]=y,t[37]=b);let x;return t[38]!==a||t[39]!==n||t[40]!==b||t[41]!==h||t[42]!==_||t[43]!==v||t[44]!==r.title?(x=(0,$.jsx)(Rn,{id:`mobile-row-actions-sheet`,open:n,onOpenChange:a,title:h,ariaLabel:g,closeAriaLabel:_,resizeAriaLabel:v,fitContent:!0,children:b}),t[38]=a,t[39]=n,t[40]=b,t[41]=h,t[42]=_,t[43]=v,t[44]=r.title,t[45]=x):x=t[45],x}function Pc(e,t){return e&&e.id===t.id&&e.kind===t.kind&&e.title===t.title&&e.subtitle===t.subtitle&&e.changes===t.changes&&e.activityLabel===t.activityLabel&&e.unread===t.unread&&e.pinned===t.pinned&&e.archived===t.archived&&e.active===t.active&&e.directory===t.directory&&e.expanded===t.expanded&&e.children===t.children?e:t}function Fc(e,t){if(!e||e.length===0)return t.slice();let n=new Map(e.map(e=>[e.id,e])),r=e.length===t.length,i=t.map((t,i)=>{let a=Pc(n.get(t.id)??e[i],t);return a!==e[i]&&(r=!1),a});if(r){let t=!0;for(let n=0;n<i.length;n+=1)if(i[n]!==e[n]){t=!1;break}if(t)return e}return i}var Ic=`__show_more__:`,Lc=`__show_fewer__:`,Rc=e=>e.startsWith(Ic),zc=e=>e.startsWith(Lc),Bc=e=>Rc(e)||zc(e),Vc=e=>{let t=Rc(e)?Ic:zc(e)?Lc:null;if(!t)return null;let n=e.slice(t.length),r=n.indexOf(`::`);return r<=0?null:{kind:t===`__show_more__:`?`more`:`fewer`,projectId:n.slice(0,r),bucketKey:n.slice(r+2)}},Hc=e=>e.parentID??null,Uc=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Wc=e=>{let t=e;return Uc(t.directory??t.project?.worktree??null)},Gc=(e,t)=>{if(t?.trim())return t.trim();let n=Uc(e);if(!n)return``;let r=n.split(`/`).filter(Boolean);return r[r.length-1]||n},Kc=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},qc=e=>{if(e<=0)return``;let t=Date.now()-e;if(t<6e4)return`now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return`${r}h`;let i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))},Jc=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},Yc=(e,t)=>e.worktrees.find(e=>Uc(e.path)===t)??null,Xc=(e,t)=>{let n=t?.trim();return n?`${e} · ${n}`:e},Zc=(e,t)=>yi(e,{pinnedSessionIds:t,omitPinnedSessions:!0}).map(e=>e.session);function Qc(){let{t:e}=re(),t=Be(),n=Se(e=>e.activeSessions),r=Se(e=>e.activePaginationByDirectory),i=Xe(e=>e.projects),a=at(e=>e.projectSortOrder),o=Z.useMemo(()=>xi(i,a),[i,a]),s=Xe(e=>e.activeProjectId),c=D(e=>e.currentDirectory),l=Ze(e=>e.currentSessionId),u=Ze(e=>e.availableWorktreesByProject),d=Zt(e=>e.orderByProject),f=Ne(),p=ss(e=>e.projectExpanded),m=ss(e=>e.worktreeExpanded),h=He(e=>e.index.session.unseenCount),[g,_]=Z.useState(new Map),v=Gr(),y=Z.useMemo(()=>$r(v,l),[l,v]),b=Z.useMemo(()=>o.map(e=>{let t=Uc(e.path);return{id:e.id,label:Gc(t,e.label),path:t,icon:e.icon,worktrees:Yt(d[e.id],u.get(t)??[])}}),[o,d,u]),x=Z.useMemo(()=>{let e=new Map(t.map(e=>[e.id,e])),r=n.map(t=>{let n=e.get(t.id);return n?dt(n,t):t}),i=new Set(r.map(e=>e.id));for(let e of t)i.has(e.id)||r.push(e);return r},[n,t]),S=Z.useMemo(()=>Nr(x,b.map(e=>({id:e.id,normalizedPath:e.path})),u,!1),[b,x,u]),C=Z.useMemo(()=>{let e=b.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===s,latestActivity:0})),t=new Map(e.map(e=>[e.project.id,e])),n=(e,t,n)=>{let r=Uc(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||n?.label||Gc(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a};for(let t of e){n(t,t.project.path,null);for(let e of t.project.worktrees)n(t,e.path,e)}for(let e of x){let r=S.bySessionId.get(e.id);if(!r)continue;let i=t.get(r.projectId);if(!i)continue;let a=r.kind===`worktree`?Yc(i.project,r.scopeDirectory):null;(a?n(i,a.path,a):n(i,i.project.path,null)).sessions.push(e)}for(let t of e)for(let e of t.buckets){e.sessions.sort((e,t)=>ut(t)-ut(e));let n=Zc(e.sessions,f);t.totalSessions+=n.length;for(let n of e.sessions){let e=Kc(n);e>t.latestActivity&&(t.latestActivity=e)}}return e},[s,S,f,b,x]),w=Z.useMemo(()=>{let e=new Map;for(let t of x)e.set(t.id,t);return e},[x]),T=Z.useMemo(()=>{let e=new Map;for(let t of b)e.set(t.id,t);return e},[b]),E=Z.useRef([]),O=Z.useRef([]),k=Z.useRef(new Map),{pinnedSessions:A,inProgressSessions:j}=Z.useMemo(()=>{let t=new Map(b.map(e=>[e.id,e])),n=e(`mobile.sessions.untitled`),r=new Map(E.current.map(e=>[e.id,e])),i=new Map(O.current.map(e=>[e.id,e])),a=(e,r,i)=>{let a=S.bySessionId.get(e.id),o=a?t.get(a.projectId):void 0;if(!o)return[];let s=a?.kind===`worktree`?Yc(o,a.scopeDirectory):null,c={id:e.id,directory:Wc(e),title:e.title?.trim()||n,subtitle:Xc(o.label,s?.branch),changes:Jn(qn(e))??void 0,activityLabel:qc(Kc(e))||void 0,unread:(h[e.id]??0)>0,pinned:r,archived:Jc(e),active:l===e.id};return[Pc(i.get(e.id),c)]},o=li(x,f).flatMap(e=>a(e,!0,r)),s=ti(x,f,v,h).flatMap(e=>a(e,!1,i)),c=Fc(E.current,o),u=Fc(O.current,s);return E.current=c,O.current=u,{pinnedSessions:c,inProgressSessions:u}},[l,S,f,b,v,x,e,h]),M=Z.useMemo(()=>{let e=new Map;for(let t of C){let n=t.project.worktrees.length>0;for(let r of t.buckets){let i=Zc(r.sessions,f).length;e.set(`${t.project.id}::${r.key}`,{path:r.path,rootCount:i,hasWorktrees:n})}}return e},[f,C]),N=Z.useMemo(()=>{let t=Uc(c),n=new Map,i=e=>(e.kind!==`pagination`&&n.set(e.id,e),e),a=C.map(a=>{let o=p[a.project.id]??!0,s=Qr(),c=a.project.icon?ln[a.project.icon]:void 0,u=a.buckets.map(o=>{let c=`${a.project.id}::${o.key}`,u=m[c]??!1,d=g.get(c)??s,p=Zc(o.sessions,f),_=yi(o.sessions,{pinnedSessionIds:f,omitPinnedSessions:!1}).map(e=>e.session),v=t=>{let r=Hc(t),a=(h[t.id]??0)>0&&!r,s={id:t.id,directory:o.path,title:t.title?.trim()||e(`mobile.sessions.untitled`),changes:Jn(qn(t))??void 0,activityLabel:qc(Kc(t))||void 0,unread:a,pinned:f.has(t.id),archived:Jc(t),active:l===t.id},c=Pc(k.current.get(t.id)??n.get(t.id),s);return i(c)},b=Xr(p,d,y).map(v),x=p.length-b.length,S=r.get(Uc(o.path)),C=S?.hasMore===!0,w=p.length>s&&d>s,T=[...b];w&&T.push({id:`${Lc}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showFewer`)}),(x>0||C)&&T.push({id:`${Ic}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showMore`),subtitle:S?.loadingMore?`…`:void 0});let E=Uc(o.path),D=!!(a.isActive&&t&&E&&(t===E||t.startsWith(`${E}/`))),O=o.worktree==null;return{id:o.key,name:O?e(`mobile.sessions.mainWorkspace`):o.label,path:o.path,kind:O?`main`:`worktree`,active:D,expanded:O?!0:u,sessionCount:p.length,sessions:T,catalogSessions:_.map(v)}});return{id:a.project.id,name:a.project.label,path:a.project.path,icon:c,sessionCount:a.totalSessions,activityLabel:qc(a.latestActivity)||void 0,active:a.isActive,expanded:o,worktrees:u}});return k.current=n,a},[r,y,c,l,f,p,C,e,h,g,m]),P=e=>{for(let[t,n]of M)if(t.startsWith(`${e}::`))return n.hasWorktrees;return!1},F=(e,t)=>M.get(`${e}::${t}`)?.rootCount??0,I=e=>Qr();return{projects:N,pinnedSessions:A,inProgressSessions:j,sessionById:w,projectMetaById:T,allSessions:x,projectHasWorktrees:P,getBucketRootCount:F,getBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;return g.get(n)??I(e)},getBucketPageSize:I,getBucketDirectory:(e,t)=>M.get(`${e}::${t}`)?.path??null,showMoreBucketSessions:(e,t)=>{let n=`${e}::${t}`,r=M.get(n),i=Qr(),a=Wr(),o=g.get(n)??i,s=r?.rootCount??0;if(_(e=>{let t=new Map(e),r=Math.max(i,e.get(n)??i,o);return t.set(n,r+a),t}),Math.max(i,o)+a<s)return;let c=r?.path,l=Uc(c);if(!l)return;let u=Se.getState().activePaginationByDirectory.get(l);u?.hasMore&&!u.loadingMore&&ze(l)},resetBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;_(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})}}}var $c=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function el({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,className:a}){let{t:o}=re(),{git:s}=Mn(),c=Ke(),l=Qc(),u=ss(e=>e.setProjectExpanded),d=ss(e=>e.setWorktreeExpanded),f=Pe(),p=Ne(),m=Ze(e=>e.archiveSessions),h=Ze(e=>e.updateSessionTitle),g=Ze(e=>e.requestSessionSmartTitle),_=Ze(e=>e.shareSession),v=Ze(e=>e.unshareSession),b=Ze(e=>e.openNewSessionDraft),x=rt(e=>e.openDraft),S=rt(e=>e.openSession),C=Xe(e=>e.projects),w=Xe(e=>e.setActiveProjectIdOnly),T=Xe(e=>e.removeProject),E=Lt(),[D,O]=Z.useState(null),[k,A]=Z.useState(!1),[j,M]=Z.useState(null),[N,P]=Z.useState(null),[F,I]=Z.useState(null),[L,R]=Z.useState(``),[z,B]=Z.useState(!1),[ee,V]=Z.useState(!1),[H,te]=Z.useState(null),[W,ie]=Z.useState(null),[G,ae]=Z.useState(null),oe=D?.kind===`session`?D.session.id:``,se=Ge(oe),ce=se?.type===`busy`||se?.type===`retry`,q=D?.kind===`session`?Wc(D.session):``,J=!!oe&&G===oe,le=!q||J||ce,ue=U(e=>{let t=new Map;for(let e of l.allSessions){let n=Hc(e);if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n}),de=U(()=>{A(!1),O(null)}),fe=U(t=>{if(Bc(t.id)){let e=Vc(t.id);if(!e)return;e.kind===`more`?l.showMoreBucketSessions(e.projectId,e.bucketKey):l.resetBucketVisibleCount(e.projectId,e.bucketKey);return}let n=l.sessionById.get(t.id),r=n&&Wc(n)||null;e({sessionId:t.id,directory:r})}),pe=U(e=>{Bc(e.id)||f(e.id)}),me=U(async e=>{if(Bc(e.id))return;let t=ue(e.id),{archivedIds:n,failedIds:r}=await m(t);n.length>0&&di({sessionIds:n,message:n.length===1?o(`sessions.sidebar.session.archive.success`):o(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:o(`sessions.sidebar.undo`),settingsLabel:o(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:n.length===1?o(`sessions.sidebar.session.archive.undoFailed`):o(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&Y.error(r.length===1?o(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):o(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}),he=U(()=>{if(!D||D.kind!==`session`)return;let e=D.session,t=Wc(e),n=se?.type??`idle`;!t||G===e.id||n===`busy`||n===`retry`||(ae(e.id),(async()=>{try{await E.refreshSessionTranscript(e.id,{directory:t}),Y.success(o(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{Y.error(o(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ae(t=>t===e.id?null:t)}})())}),ge=U(e=>{if(Bc(e.id))return;let t=l.sessionById.get(e.id);t&&(O({kind:`session`,session:t}),A(!0))}),_e=U(e=>{u(e.id,!e.expanded)}),ve=U((e,t)=>{d(`${e.id}::${t.id}`,!t.expanded)}),ye=U((e,t)=>{w(e.id),x({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),be=U(()=>{if(n){n();return}b()}),xe=U(e=>{let t=l.projectMetaById.get(e.id);t&&(O({kind:`project`,project:t,isGitRepository:!1}),A(!0),s.checkIsGitRepository(t.path).then(e=>{O(n=>$c(n,t.id,e))}).catch(()=>{O(e=>$c(e,t.id,!1))}))}),Se=U((e,t)=>{let n=y(t);return n?e.worktrees.find(e=>y(e.path)===n)||((Ze.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>y(e.path)===n)??null):null}),Ce=U((e,t)=>{let n=l.projectMetaById.get(e.id);n&&ye(n,t.path)}),we=U((e,t)=>{let n=l.projectMetaById.get(e.id);n&&(O({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),A(!0))}),Te=U((e,t)=>{let n=l.projectMetaById.get(e.id);if(!n)return;let r=Se(n,t.path);if(!r){Y.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}ie({project:n,worktree:r})}),Ee=U(e=>{te(e),w(e),V(!0)}),De=U(e=>{(async()=>{let t=e.worktrees;try{t=(await dn({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=Ze.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await et([e.path,...t.map(e=>e.path)],l.allSessions)})()}),Oe=U((e,t)=>{let n=H;if(V(!1),te(null),t?.sessionId){S({sessionId:t.sessionId,directory:e});return}x({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),ke=U(async e=>{try{if(!(await _(e.id))?.share?.url){Y.error(o(`sessions.sidebar.session.share.error`));return}Y.success(o(`sessions.sidebar.session.share.successTitle`),{description:o(`sessions.sidebar.session.share.successDescription`)})}catch{Y.error(o(`sessions.sidebar.session.share.error`))}}),Ae=U(async e=>{if((await ne(e)).ok){Y.success(o(`sessions.sidebar.session.menu.copied`));return}Y.error(o(`sessions.sidebar.session.share.copyUrlError`))}),je=U(async e=>{try{if(await v(e)){Y.success(o(`sessions.sidebar.session.unshare.success`));return}Y.error(o(`sessions.sidebar.session.unshare.error`))}catch{Y.error(o(`sessions.sidebar.session.unshare.error`))}}),Me=U(e=>{let t=ue(e.id);Vr({sessionIds:t,message:t.length===1?o(`sessions.sidebar.session.delete.success`):o(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:o(`sessions.sidebar.undo`),commitFailedMessage:o(`sessions.sidebar.session.delete.error`)})}),Fe=U(async()=>{if(!F)return;let e=L.trim();if(e)try{await h(F.id,e),I(null),R(``)}catch{Y.error(o(`sessions.sidebar.session.menu.rename`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),Ie=U(async()=>{if(!F||z)return;let e=F.id;I(null),R(``),B(!0);try{await g(e)}catch{Y.error(o(`sessions.sidebar.session.rename.smartTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{B(!1)}}),Le=Z.useMemo(()=>D?D.kind===`session`?{kind:`session`,title:D.session.title?.trim()||o(`mobile.sessions.untitled`),pinned:p.has(D.session.id),shared:!!D.session.share?.url}:D.kind===`project`?{kind:`project`,title:D.project.label,gitRepository:D.isGitRepository}:{kind:`worktree`,title:D.worktreeName}:null,[D,p,o]),Re=Z.useMemo(()=>{if(!D)return{};if(D.kind===`session`){let e=D.session;return{onRename:()=>{R(e.title?.trim()||o(`mobile.sessions.untitled`)),I(e)},onTogglePin:()=>f(e.id),onShare:c&&!e.share?.url?()=>{ke(e)}:void 0,onCopyLink:c&&e.share?.url?()=>{Ae(e.share.url)}:void 0,onUnshare:c&&e.share?.url?()=>{je(e.id)}:void 0,onRefreshTranscript:he,onArchive:()=>{me({id:e.id,title:e.title?.trim()||o(`mobile.sessions.untitled`)})},onDelete:()=>Me(e)}}if(D.kind===`project`){let e=D.project;return{onNewSession:()=>ye(e,e.path),onNewWorktree:()=>Ee(e.id),onSyncSessions:()=>De(e),onEditProject:()=>M(e.id),onCloseProject:()=>P(e)}}let{project:e,worktreePath:t}=D;return{onNewSession:()=>ye(e,t),onDeleteWorktree:()=>{let n=Se(e,t);if(!n){Y.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}ie({project:e,worktree:n})}}},[D,me,Ae,Me,he,Ee,De,ke,je,Se,c,ye,o,f]),ze=Z.useMemo(()=>{if(!j)return null;let e=C.find(e=>e.id===j),t=l.projectMetaById.get(j);if(!e||!t)return null;let n=D?.kind===`project`&&D.project.id===j?D.isGitRepository:t.worktrees.length>0;return{id:e.id,label:e.label?.trim()||t.label,path:y(e.path)||t.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:n,worktrees:t.worktrees}},[D,j,l.projectMetaById,C]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Oc,{className:a,projects:l.projects,pinnedSessions:l.pinnedSessions,inProgressSessions:l.inProgressSessions,onAddProject:t,onNewSession:be,onScanQr:r,onSwitchInstance:i,onToggleProject:_e,onOpenProjectActions:xe,onToggleWorktree:ve,onNewWorktreeSession:Ce,onOpenWorktreeActions:we,onDeleteWorktree:Te,onSelectSession:fe,onPinSession:pe,onArchiveSession:e=>{me(e)},onOpenSessionActions:ge}),(0,$.jsx)(Nc,{open:k,target:Le,actions:Re,refreshTranscriptDisabled:le,refreshTranscriptSpinning:J,onOpenChange:e=>{e?A(!0):de()}}),(0,$.jsx)(Jt,{open:ee,projectId:H,onOpenChange:e=>{V(e),e||te(null)},onWorktreeCreated:Oe}),W?(0,$.jsx)(fi,{open:!0,project:{id:W.project.id,path:W.project.path},worktree:W.worktree,onClose:()=>ie(null)}):null,(0,$.jsx)(xn,{open:!!N,title:o(`sessions.sidebar.project.actions.closeProject`),onClose:()=>P(null),closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>P(null),children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(K,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!N)return;let e=N;P(null),T(e.id),Y.success(o(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:o(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:o(`mobile.projects.closeConfirmMessage`,{title:N?.label??``})})}),(0,$.jsx)(xn,{open:!!F,title:o(`sessions.sidebar.session.menu.rename`),onClose:()=>{z||(I(null),R(``))},closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:z,onClick:()=>{I(null),R(``)},children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(K,{type:`button`,variant:`default`,className:`flex-1`,disabled:!L.trim()||z,onClick:()=>void Fe(),children:o(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),Fe()},children:[(0,$.jsx)(fn,{value:L,onChange:e=>R(e.target.value),autoFocus:!0,className:`h-12`,disabled:z}),(0,$.jsxs)(K,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:z,onClick:()=>void Ie(),children:[z?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),o(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(Yr,{open:j!==null,project:ze,onClose:()=>M(null)})]})}function tl(e){let t=(0,Q.c)(10),{children:n,content:r,className:i,contentClassName:a,showHeader:o}=e,s=o===void 0||o,{t:c}=re(),l;t[0]===c?l=t[1]:(l=c(`sessions.scheduledTasks.dialog.title`),t[0]=c,t[1]=l);let u;t[2]===a?u=t[3]:(u=G(`oc-mobile-scheduled-content`,a),t[2]=a,t[3]=u);let d=n??r,f;return t[4]!==i||t[5]!==s||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,$.jsx)(Ri,{title:l,className:i,surface:!1,scrollsWithPage:!0,showHeader:s,surfaceClassName:u,children:d}),t[4]=i,t[5]=s,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function nl(e){let t=(0,Q.c)(10),{className:n,contentClassName:r,instancesPage:i}=e,{t:a}=re(),o;t[0]===a?o=t[1]:(o=a(`mobile.settings.placeholder.title`),t[0]=a,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=[...Pr],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(Hi,{forceMobile:!0,isWindowed:!0,hideMobileHeader:!0,flowMobile:!0,autoOpenMobilePage:!0,visiblePageSlugs:s,mobileInstancesPage:i}),t[3]=i,t[4]=c);let l;return t[5]!==n||t[6]!==r||t[7]!==o||t[8]!==c?(l=(0,$.jsx)(Ri,{title:o,className:n,surface:!1,scrollsWithPage:!0,showHeader:!1,surfaceClassName:r,children:c}),t[5]=n,t[6]=r,t[7]=o,t[8]=c,t[9]=l):l=t[9],l}function rl(e){let t=(0,Q.c)(110),{onAddProject:n,onScanQr:r,onSwitchInstance:i,onEnableAssistants:a,instancesPage:o,instancesSecondaryPage:s,parentSessionTarget:c,registerSecondaryBackHandler:l,scheduledContent:u,renderChat:d,className:f}=e,p=c===void 0?null:c,{t:m}=re(),h=P(Sl),g=rt(),_=rt(xl),v=rt(bl),b=rt(yl),x=rt(vl),S=rt(_l),C=rt(gl),w=rt(hl),T=rt(ml),E=rt(pl),D=rt(fl),O=rt(dl),k=rt(ul),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A=[],t[0]=A):A=t[0],Z.useEffect(ll,A);let j=g.secondary?.kind===`chat`?g.secondary.btw??null:null,M=Z.useRef(null),N,F;t[1]===j?(N=t[2],F=t[3]):(N=()=>{let e=M.current;M.current=j,e&&e!==j&&$t.getState().clear({sessionId:e.sessionId,directory:e.directory}),j?Ht(Bt):Ct(Bt)},F=[j],t[1]=j,t[2]=N,t[3]=F),Z.useEffect(N,F);let I;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(I=[],t[4]=I):I=t[4],Z.useEffect(sl,I);let L;t[5]===_?L=t[6]:(L=e=>{e===`settings`&&P.getState().setSettingsPage(`home`),_(e)},t[5]=_,t[6]=L);let R=U(L),z;t[7]===v?z=t[8]:(z=e=>{v(e)},t[7]=v,t[8]=z);let B=U(z),ee;t[9]===w?ee=t[10]:(ee=()=>{w()},t[9]=w,t[10]=ee);let V=U(ee),H;t[11]===b?H=t[12]:(H=()=>{b()},t[11]=b,t[12]=H);let te=U(H),W;t[13]===x?W=t[14]:(W=e=>{x(e)},t[13]=x,t[14]=W);let ne=U(W),ie=Z.useRef(null),[G,K]=Z.useState(!1),ae;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>{ie.current=e},t[15]=ae):ae=t[15];let oe=U(ae),se;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>{K(e)},t[16]=se):se=t[16];let ce=U(se),q;t[17]!==V||t[18]!==C||t[19]!==k||t[20]!==T?(q=()=>{if(ie.current?.())return!0;let e=rt.getState().secondary;return e?.kind===`chat`&&e.btw?(k(),!0):e?.kind===`assistant`&&e.settingsAssistantID?(C(),!0):e?.kind===`chat`&&e.routes.length>1?(T(),!0):e?(V(),!0):!1},t[17]=V,t[18]=C,t[19]=k,t[20]=T,t[21]=q):q=t[21];let J=U(q),le=g.secondary!==null,ue;t[22]!==J||t[23]!==l?(ue=()=>{if(l)return l(()=>J()),()=>l(null)},t[22]=J,t[23]=l,t[24]=ue):ue=t[24];let de;t[25]!==J||t[26]!==l||t[27]!==le?(de=[l,le,J],t[25]=J,t[26]=l,t[27]=le,t[28]=de):de=t[28],Z.useEffect(ue,de);let fe=Ze(ol),pe;t[29]===fe?pe=t[30]:(pe=e=>fe?e.getDirectoryForSession(fe):null,t[29]=fe,t[30]=pe);let me=Ze(pe),he,ge;t[31]!==me||t[32]!==fe||t[33]!==D||t[34]!==O?(he=()=>{let e=rt.getState().secondary;if(e?.kind===`draft`&&fe){D({sessionId:fe,directory:me});return}if(e?.kind!==`chat`||!fe||st({sessionId:fe,directory:me})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==fe||y(t.directory)!==y(me))&&O({sessionId:fe,directory:me})},ge=[me,fe,D,O],t[31]=me,t[32]=fe,t[33]=D,t[34]=O,t[35]=he,t[36]=ge):(he=t[35],ge=t[36]),Z.useEffect(he,ge);let _e,ve;t[37]!==fe||t[38]!==p||t[39]!==E?(_e=()=>{let e=rt.getState().secondary;if(e?.kind!==`chat`||!p)return;let t=e.routes.at(-1);!t||t.sessionId!==fe||E({sessionId:p.id,directory:p.directory})},ve=[fe,p,E],t[37]=fe,t[38]=p,t[39]=E,t[40]=_e,t[41]=ve):(_e=t[40],ve=t[41]),Z.useEffect(_e,ve);let ye;t[42]!==ce||t[43]!==oe||t[44]!==u?(ye=typeof u==`function`?u(oe,ce):u,t[42]=ce,t[43]=oe,t[44]=u,t[45]=ye):ye=t[45];let be=ye,xe;t[46]!==te||t[47]!==n||t[48]!==r||t[49]!==i||t[50]!==B?(xe=(0,$.jsx)(el,{onOpenChat:B,onAddProject:n,onNewSession:te,onScanQr:r,onSwitchInstance:i}),t[46]=te,t[47]=n,t[48]=r,t[49]=i,t[50]=B,t[51]=xe):xe=t[51];let Se;t[52]!==a||t[53]!==ne?(Se=(0,$.jsx)(Is,{onEnable:a,onOpenAssistant:ne}),t[52]=a,t[53]=ne,t[54]=Se):Se=t[54];let Ce;t[55]===be?Ce=t[56]:(Ce=(0,$.jsx)(tl,{showHeader:!1,children:be}),t[55]=be,t[56]=Ce);let we;t[57]===o?we=t[58]:(we=(0,$.jsx)(nl,{instancesPage:o}),t[57]=o,t[58]=we);let Te;t[59]!==xe||t[60]!==Se||t[61]!==Ce||t[62]!==we?(Te={projects:xe,assistant:Se,scheduled:Ce,settings:we},t[59]=xe,t[60]=Se,t[61]=Ce,t[62]=we,t[63]=Te):Te=t[63];let Ee=Te,De=g.secondary?.kind??null,Oe;bb0:{if(!De){Oe=null;break bb0}if(De===`assistant`){let e=g.secondary?.kind===`assistant`?g.secondary.settingsAssistantID:void 0,n;t[64]===m?n=t[65]:(n=m(`assistants.title`),t[64]=m,t[65]=n);let r=!e,i;t[66]!==S||t[67]!==r?(i=(0,$.jsx)(Zi,{activeOverride:r,onMobileBack:al,onMobileOpenSettings:S}),t[66]=S,t[67]=r,t[68]=i):i=t[68];let a;t[69]!==J||t[70]!==n||t[71]!==i?(a={key:`assistant-secondary`,depth:1,ariaLabel:n,onBack:J,content:i},t[69]=J,t[70]=n,t[71]=i,t[72]=a):a=t[72];let o;t[73]!==J||t[74]!==e||t[75]!==m?(o=e?[{key:`assistant-settings:${e}`,depth:2,ariaLabel:m(`assistants.conversation.openSettings`),onBack:J,content:(0,$.jsx)(Rs,{assistantID:e,onBack:il})}]:[],t[73]=J,t[74]=e,t[75]=m,t[76]=o):o=t[76];let s;t[77]!==a||t[78]!==o?(s=[a,...o],t[77]=a,t[78]=o,t[79]=s):s=t[79],Oe=s;break bb0}if(De===`instances`){let e;t[80]===m?e=t[81]:(e=m(`mobile.settings.switchInstance`),t[80]=m,t[81]=e);let n;t[82]!==J||t[83]!==s||t[84]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:J,content:s}],t[82]=J,t[83]=s,t[84]=e,t[85]=n):n=t[85],Oe=n;break bb0}if(g.secondary?.kind===`draft`){let e;t[86]===m?e=t[87]:(e=m(`mobile.nav.secondaryPageAria`),t[86]=m,t[87]=e);let n;t[88]===d?n=t[89]:(n=d({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[88]=d,t[89]=n);let r;t[90]!==J||t[91]!==e||t[92]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:J,content:n}],t[90]=J,t[91]=e,t[92]=n,t[93]=r):r=t[93],Oe=r;break bb0}if(g.secondary?.kind!==`chat`){let e;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[94]=e):e=t[94],Oe=e;break bb0}let e=g.secondary.routes,n=g.secondary.btw,r;if(t[95]!==n||t[96]!==J||t[97]!==d||t[98]!==e||t[99]!==m){let i=e.slice(n?-1:-2),a=e.length-i.length+1,o=i.map((e,t)=>{let r=!n&&t===i.length-1;return{key:e.key,depth:a+t,ariaLabel:m(`mobile.nav.secondaryPageAria`),onBack:J,content:d({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:r})}});r=n?[...o,{key:`chat-btw`,depth:e.length+1,ariaLabel:m(`chat.btw.title`),onBack:J,content:(0,$.jsx)(zs,{route:n})}]:o,t[95]=n,t[96]=J,t[97]=d,t[98]=e,t[99]=m,t[100]=r}else r=t[100];Oe=r}let ke=Oe,Ae;t[101]===ke?Ae=t[102]:(Ae=ke??[],t[101]=ke,t[102]=Ae);let je=G||h,Me;return t[103]!==f||t[104]!==g||t[105]!==R||t[106]!==Ae||t[107]!==je||t[108]!==Ee?(Me=(0,$.jsx)(lc,{className:f,navigation:g,onTabChange:R,tabs:Ee,secondaryPages:Ae,tabBarCovered:je}),t[103]=f,t[104]=g,t[105]=R,t[106]=Ae,t[107]=je,t[108]=Ee,t[109]=Me):Me=t[109],Me}function il(){sr.requestAnimatedBack(`root`)}function al(){return sr.requestAnimatedBack(`root`)}function ol(e){return e.currentSessionId}function sl(){return cl}function cl(){return Ct(Bt)}function ll(){return qe()}function ul(e){return e.popBtw}function dl(e){return e.replaceChatSession}function fl(e){return e.materializeDraftSession}function pl(e){return e.reconcileChatPredecessor}function ml(e){return e.popChatSession}function hl(e){return e.closeSecondary}function gl(e){return e.popAssistantSettings}function _l(e){return e.pushAssistantSettings}function vl(e){return e.openAssistant}function yl(e){return e.openDraft}function bl(e){return e.openSession}function xl(e){return e.setActiveTab}function Sl(e){return e.isCommandPaletteOpen}function Cl(e){let t=(0,Q.c)(30),{percentage:n,pending:r}=e,i=r!==void 0&&r,{t:a}=re(),o,s,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==n||t[2]!==a){c=i?0:mn(n)??0;let e=vn(n);s=i?`var(--surface-muted-foreground)`:e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,o=2*Math.PI*7.5,l=`0 0 18 18`,u=`size-[18px] -rotate-90`,d=`progressbar`,t[12]===a?f=t[13]:(f=a(`contextUsage.aria.label`),t[12]=a,t[13]=f),t[14]!==i||t[15]!==a?(p=i?a(`contextUsage.pending`):void 0,t[14]=i,t[15]=a,t[16]=p):p=t[16],m=i?void 0:Math.round(c),t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m}else o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11];let h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[17]=h):h=t[17];let g=o*(1-c/100),_;t[18]!==o||t[19]!==s||t[20]!==g?(_=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:s,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:o,strokeDashoffset:g,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[18]=o,t[19]=s,t[20]=g,t[21]=_):_=t[21];let v;return t[22]!==_||t[23]!==l||t[24]!==u||t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m?(v=(0,$.jsxs)(`svg`,{viewBox:l,className:u,role:d,"aria-label":f,"aria-valuetext":p,"aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:[h,_]}),t[22]=_,t[23]=l,t[24]=u,t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=v):v=t[29],v}function wl(e){let t=(0,Q.c)(16),{title:n,subtitle:r,onBack:i,onOpenMenu:a,menuOpen:o,elevated:s,trailing:c}=e,l=o!==void 0&&o,u=s!==void 0&&s,{t:d}=re(),f=U(i),p=U(a),m;t[0]===d?m=t[1]:(m=d(`header.actions.backAria`),t[0]=d,t[1]=m);let h=u||l,g;t[2]===d?g=t[3]:(g=d(`mobile.menu.titleAria`),t[2]=d,t[3]=g);let _;t[4]!==p||t[5]!==l||t[6]!==g?(_=[{icon:`more-2`,ariaLabel:g,onClick:p,pressed:l}],t[4]=p,t[5]=l,t[6]=g,t[7]=_):_=t[7];let v;return t[8]!==f||t[9]!==r||t[10]!==m||t[11]!==h||t[12]!==_||t[13]!==n||t[14]!==c?(v=(0,$.jsx)(ye,{title:n,subtitle:r,backAriaLabel:m,onBack:f,overlay:!0,elevated:h,trailing:c,actions:_}),t[8]=f,t[9]=r,t[10]=m,t[11]=h,t[12]=_,t[13]=n,t[14]=c,t[15]=v):v=t[15],v}var Tl=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},El=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),Dl=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,Ol=e=>{let{totalTokens:t,contextLimit:n,isDraft:r}=e;if(!r&&t===null)return{pending:!0,percentage:0,tokens:`—`,colorClass:`text-muted-foreground`};if(t===null||r||t<=0||n<=0)return null;let i=Math.min(t/n*100,999);return{percentage:i,tokens:`${El(t)}/${El(n)}`,colorClass:Dl(i)}},kl=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`user`)continue;let r=typeof n.model?.providerID==`string`&&n.model.providerID.trim().length>0?n.model.providerID:void 0,i=typeof n.model?.modelID==`string`&&n.model.modelID.trim().length>0?n.model.modelID:void 0;if(r&&i)return{providerID:r,modelID:i}}return null},Al=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),jl=e=>{let t=e.usedPercent;return typeof t!=`number`||!Number.isFinite(t)?`text-foreground`:t>=80?`text-[var(--status-error)]`:t>=50?`text-[var(--status-warning)]`:`text-foreground`},Ml=e=>{let t=(0,Q.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,$.jsx)(X,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},Nl=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=re(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(on,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map(e=>{let t=r===`remaining`?e.window.remainingPercent:e.window.usedPercent,n=yn(e.window.valueLabel,t),i=Cn(e.window.resetAt,e.window.resetAfterFormatted??e.window.resetAtFormatted,a);return(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:e.subtitle?`${e.subtitle} · ${e.label}`:e.label}),i?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground/70`,children:i}):null]}),(0,$.jsx)(`span`,{className:G(`shrink-0 typography-ui-label font-semibold tabular-nums`,jl(e.window)),children:n===`-`?``:n})]},e.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 typography-micro text-muted-foreground`,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,$.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},Pl=e=>{let t=(0,Q.c)(47),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l}=e,{t:u}=re(),d=Z.useRef(null),[f,p]=Z.useState(n),[m,h]=Z.useState(!1),g,_;t[0]!==n||t[1]!==f?(g=()=>{if(n){p(!0),h(!1);return}if(!f)return;h(!0);let e=window.setTimeout(()=>{p(!1),h(!1)},140);return()=>window.clearTimeout(e)},_=[n,f],t[0]=n,t[1]=f,t[2]=g,t[3]=_):(g=t[2],_=t[3]),Z.useEffect(g,_);let v,y;if(t[4]!==r||t[5]!==n?(v=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},y=[r,n],t[4]=r,t[5]=n,t[6]=v,t[7]=y):(v=t[6],y=t[7]),Z.useEffect(v,y),!f)return null;let b;t[8]===u?b=t[9]:(b=u(`mobile.surface.closeAria`),t[8]=u,t[9]=b);let x;t[10]===r?x=t[11]:(x=e=>{e.preventDefault(),r()},t[10]=r,t[11]=x);let S;t[12]!==b||t[13]!==x?(S=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":b,onPointerDown:x}),t[12]=b,t[13]=x,t[14]=S):S=t[14];let C;t[15]===u?C=t[16]:(C=u(`mobile.header.openMetadataAria`),t[15]=u,t[16]=C);let w=m&&`pointer-events-none`,T;t[17]===w?T=t[18]:(T=G(`pointer-events-auto absolute inset-x-3 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.5rem)] overflow-y-auto overscroll-contain rounded-[20px] oc-mobile-overlay-surface oc-mobile-overlay-surface--translucent p-2 will-change-transform`,w),t[17]=w,t[18]=T);let E=`${m?`session-metadata-out`:`session-metadata-in`} ${m?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,D;t[19]===E?D=t[20]:(D={animation:E,maxHeight:`min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-mobile-detail-navigation-height, 3.5rem) - 1rem))`},t[19]=E,t[20]=D);let O;t[21]===u?O=t[22]:(O=u(`mobile.header.metadata.branch`),t[21]=u,t[22]=O);let k;t[23]!==a||t[24]!==O?(k=(0,$.jsx)(Ml,{iconName:`git-branch`,label:O,children:a}),t[23]=a,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==i||t[27]!==u?(A=i?(0,$.jsx)(Ml,{iconNode:(0,$.jsx)(Cl,{percentage:i.percentage,pending:i.pending}),label:u(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsx)(`span`,{className:G(`font-semibold`,i.colorClass),children:i.pending?u(`contextUsage.pending`):`${i.percentage.toFixed(1)}%`}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:i.tokens})]})}):null,t[26]=i,t[27]=u,t[28]=A):A=t[28];let j;t[29]!==c||t[30]!==l||t[31]!==s||t[32]!==o?(j=(0,$.jsx)(Nl,{groups:o,displayMode:s,isLoading:c,timeFormatPreference:l}),t[29]=c,t[30]=l,t[31]=s,t[32]=o,t[33]=j):j=t[33];let M;t[34]!==k||t[35]!==A||t[36]!==j?(M=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[k,A,j]}),t[34]=k,t[35]=A,t[36]=j,t[37]=M):M=t[37];let N;t[38]!==T||t[39]!==D||t[40]!==M||t[41]!==C?(N=(0,$.jsx)(`div`,{ref:d,role:`dialog`,"aria-label":C,className:T,style:D,onPointerDown:eu,children:M}),t[38]=T,t[39]=D,t[40]=M,t[41]=C,t[42]=N):N=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(`style`,{children:`
|
|
6
6
|
@keyframes session-metadata-in {
|
|
7
7
|
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
8
8
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
@@ -25,4 +25,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{S as t,_ as n,p as r,r
|
|
|
25
25
|
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
26
26
|
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
27
27
|
}
|
|
28
|
-
`}),t[52]=U):U=t[52];let W;return t[53]===te?W=t[54]:(W=(0,$.jsxs)(`div`,{ref:y,className:`fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none`,children:[te,U]}),t[53]=te,t[54]=W),W},sp=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=re(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(on,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map(e=>{let t=r===`remaining`?e.window.remainingPercent:e.window.usedPercent,n=yn(e.window.valueLabel,t),i=Cn(e.window.resetAt,e.window.resetAfterFormatted??e.window.resetAtFormatted,a);return(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:e.subtitle?`${e.subtitle} · ${e.label}`:e.label}),i?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground/70`,children:i}):null]}),(0,$.jsx)(`span`,{className:G(`shrink-0 typography-ui-label font-semibold tabular-nums`,ip(e.window)),children:n===`-`?``:n})]},e.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 typography-micro text-muted-foreground`,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,$.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},cp=e=>{let t=(0,Q.c)(35),{open:n,onClose:r,items:i,rightOffset:a}=e,o=a===void 0?0:a,{t:s}=re(),c,l;if(t[0]!==r||t[1]!==n?(c=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},l=[r,n],t[0]=r,t[1]=n,t[2]=c,t[3]=l):(c=t[2],l=t[3]),Z.useEffect(c,l),!n)return null;let u;t[4]===r?u=t[5]:(u=(e,t,n)=>(0,$.jsxs)(`button`,{type:`button`,role:n===void 0?`menuitem`:`menuitemcheckbox`,"aria-checked":n,className:G(`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,t>0&&`border-t border-border/30`,e.disabled&&`cursor-not-allowed opacity-60`),style:{touchAction:`manipulation`},disabled:e.disabled,onClick:()=>{e.onSelect(),r()},children:[e.iconNode??(e.icon?(0,$.jsx)(X,{name:e.icon,className:G(`size-5 shrink-0 text-muted-foreground`,e.spinning&&`animate-spin`,e.key===`auto-read`&&`translate-x-px`)}):null),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:e.label}),e.badge&&e.badge>0?(0,$.jsx)(`span`,{className:`inline-flex size-2 shrink-0 rounded-full bg-primary`,"aria-hidden":!0}):null,n&&(0,$.jsx)(X,{name:`check`,className:`size-4 shrink-0 text-muted-foreground`})]},e.key),t[4]=r,t[5]=u);let d=u,f;t[6]===s?f=t[7]:(f=s(`mobile.menu.titleAria`),t[6]=s,t[7]=f);let p;t[8]===s?p=t[9]:(p=s(`mobile.surface.closeAria`),t[8]=s,t[9]=p);let m;t[10]===r?m=t[11]:(m=e=>{e.preventDefault(),r()},t[10]=r,t[11]=m);let h;t[12]!==p||t[13]!==m?(h=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":p,onPointerDown:m}),t[12]=p,t[13]=m,t[14]=h):h=t[14];let g=`max(1rem, calc(8px + ${o}px + var(--oc-safe-area-right, 0px)))`,_;t[15]===g?_=t[16]:(_={right:g,animation:`mobile-menu-in 160ms cubic-bezier(0.32, 0.72, 0, 1) forwards`},t[15]=g,t[16]=_);let v;if(t[17]!==i||t[18]!==d){let e;t[20]===d?e=t[21]:(e=(e,t)=>d(e,t),t[20]=d,t[21]=e),v=i.map(e),t[17]=i,t[18]=d,t[19]=v}else v=t[19];let y;t[22]!==i.length||t[23]!==d||t[24]!==s?(y=(0,$.jsx)(wa,{children:e=>{let{enabled:t,available:n,toggle:r}=e;return d({key:`auto-read`,icon:`volume-up`,label:s(`mobile.menu.autoRead`),disabled:!n,onSelect:r},i.length,t)}}),t[22]=i.length,t[23]=d,t[24]=s,t[25]=y):y=t[25];let b;t[26]!==_||t[27]!==v||t[28]!==y?(b=(0,$.jsxs)(`div`,{id:If,className:`pointer-events-auto absolute top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.25rem)] w-[min(220px,calc(100vw-1rem))] origin-top-right overflow-hidden rounded-2xl oc-mobile-overlay-surface`,role:`menu`,style:_,onAnimationEnd:pp,children:[v,y]}),t[26]=_,t[27]=v,t[28]=y,t[29]=b):b=t[29];let x;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`style`,{children:`@keyframes mobile-menu-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }`}),t[30]=x):x=t[30];let S;return t[31]!==b||t[32]!==f||t[33]!==h?(S=(0,$.jsxs)(`div`,{className:`pointer-events-none fixed inset-0 z-50`,role:`dialog`,"aria-modal":`true`,"aria-label":f,children:[h,b,x]}),t[31]=b,t[32]=f,t[33]=h,t[34]=S):S=t[34],S},lp=Z.memo(function(e){let t=(0,Q.c)(94),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=re(),{git:d}=Mn(),f=iu(i??``,a||void 0),p=f??l,m=Z.useRef(null),h=tt(i??``,a||void 0),g=Yn(o),_=Qn(o),v=$n(mp),y=$n(hp),b=Ye(gp),x=Ye(_p),S=Ye(vp),C=Ye(yp),w;t[0]===i?w=t[1]:(w=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=w);let T=we(w),E=Mr(bp),D=Mr(xp),O=Mr(Sp),k=Mr(Cp),A=Mr(wp),j=Mr(Tp),M=Mr(Ep),N=P(Dp);jr();let F,I;t[2]!==v||t[3]!==d||t[4]!==o?(F=()=>{o&&v(o,d)},I=[v,d,o],t[2]=v,t[3]=d,t[4]=o,t[5]=F,t[6]=I):(F=t[5],I=t[6]),Z.useEffect(F,I);let L,R;t[7]!==y||t[8]!==d||t[9]!==o?(L=()=>{if(o)return $e.onGitRefreshHint(e=>{Xf(e.directory)===o&&y(o,d)})},R=[y,d,o],t[7]=y,t[8]=d,t[9]=o,t[10]=L,t[11]=R):(L=t[10],R=t[11]),Z.useEffect(L,R);let z,B;t[12]===D?(z=t[13],B=t[14]):(z=()=>{D()},B=[D],t[12]=D,t[13]=z,t[14]=B),Z.useEffect(z,B);let ee,V;t[15]===j?(ee=t[16],V=t[17]):(ee=()=>{an(j)},V=[j],t[15]=j,t[16]=ee,t[17]=V),Z.useEffect(ee,V);let H,te;t[18]!==j||t[19]!==O||t[20]!==k||t[21]!==n||t[22]!==E?(H=()=>{!n||k||j.some(e=>!E.some(t=>t?.providerId===e))&&O()},te=[j,O,k,n,E],t[18]=j,t[19]=O,t[20]=k,t[21]=n,t[22]=E,t[23]=H,t[24]=te):(H=t[23],te=t[24]),Z.useEffect(H,te);let U;t[25]===h?U=t[26]:(U=kl(h),t[25]=h,t[26]=U);let W=U,ne;t[27]!==S||t[28]!==x||t[29]!==W||t[30]!==T?(ne=W??(T?{providerID:T.providerId,modelID:T.modelId}:null)??(x&&S?{providerID:x,modelID:S}:null),t[27]=S,t[28]=x,t[29]=W,t[30]=T,t[31]=ne):ne=t[31];let ie=ne,K;if(t[32]!==C||t[33]!==ie||t[34]!==b){let e=(ie?b.find(e=>e.id===ie.providerID):void 0)?.models.find(e=>e.id===ie?.modelID),n;t[36]!==C||t[37]!==ie?(n=ie?C(ie.providerID,ie.modelID):void 0,t[36]=C,t[37]=ie,t[38]=n):n=t[38];let r=n;K=Tl(e?.limit,`context`)??r?.limit?.context??0,t[32]=C,t[33]=ie,t[34]=b,t[35]=K}else K=t[35];let ae=K,oe=nt(i??``,ae,0,a||void 0),se=oe?.pending?null:oe?.totalTokens??0,ce;t[39]!==ae||t[40]!==s||t[41]!==se?(ce=Ol({totalTokens:se,contextLimit:ae,isDraft:s}),t[39]=ae,t[40]=s,t[41]=se,t[42]=ce):ce=t[42];let q=ce,J;t[43]!==_?.current||t[44]!==g||t[45]!==u?(J=g===!0?_?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[43]=_?.current,t[44]=g,t[45]=u,t[46]=J):J=t[46];let le=J,ue;if(t[47]!==j||t[48]!==E||t[49]!==M||t[50]!==u){let e=new Map(E.map(Op)),n;t[52]===j?n=t[53]:(n=e=>j.includes(e.id),t[52]=j,t[53]=n),ue=Or(E).filter(n).filter(t=>e.get(t.id)?.configured===!0).map(t=>{let n=e.get(t.id),r=[];for(let[e,t]of Object.entries(n?.usage?.windows??{}))r.push({key:`window-${e}`,label:bn(t.label??e),window:t});let i=Object.entries(n?.usage?.models??{}),a=M[t.id]??[],o=a.length>0?i.filter(e=>{let[t]=e;return a.includes(t)}):i;for(let[e,t]of o){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:bn(a.label??i),subtitle:Fr(e),window:a})}let s=!n.ok&&n.error?n.error:r.length===0?u(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:s}}),t[47]=j,t[48]=E,t[49]=M,t[50]=u,t[51]=ue}else ue=t[51];let de=ue,fe,pe;t[54]!==n||t[55]!==de?(fe=()=>{!n||de.length===0||an(de.map(kp))},pe=[n,de],t[54]=n,t[55]=de,t[56]=fe,t[57]=pe):(fe=t[56],pe=t[57]),Z.useEffect(fe,pe);let me;t[58]===c?me=t[59]:(me=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[58]=c,t[59]=me);let he;t[60]!==p||t[61]!==f?(he=p?(0,$.jsx)(`span`,{className:G(`block truncate`,f?`oc-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:p}):null,t[60]=p,t[61]=f,t[62]=he):he=t[62];let ge;t[63]!==me||t[64]!==he?(ge=(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center px-2 py-1.5 text-left`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[me,he]})}),t[63]=me,t[64]=he,t[65]=ge):ge=t[65];let _e;t[66]===u?_e=t[67]:(_e=u(`mobile.header.openMetadataAria`),t[66]=u,t[67]=_e);let ve;t[68]===r?ve=t[69]:(ve=()=>r(Ap),t[68]=r,t[69]=ve);let ye;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ye={touchAction:`manipulation`},t[70]=ye):ye=t[70];let be=q?.percentage??0,xe=q?.pending,Se;t[71]!==be||t[72]!==xe?(Se=(0,$.jsx)(Cl,{percentage:be,pending:xe}),t[71]=be,t[72]=xe,t[73]=Se):Se=t[73];let Ce;t[74]!==n||t[75]!==_e||t[76]!==ve||t[77]!==Se?(Ce=(0,$.jsx)(`button`,{ref:m,type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":_e,"aria-expanded":n,onClick:ve,style:ye,children:Se}),t[74]=n,t[75]=_e,t[76]=ve,t[77]=Se,t[78]=Ce):Ce=t[78];let Te;t[79]===r?Te=t[80]:(Te=()=>r(!1),t[79]=r,t[80]=Te);let Ee;t[81]!==le||t[82]!==q||t[83]!==k||t[84]!==n||t[85]!==A||t[86]!==Te||t[87]!==N||t[88]!==de?(Ee=(0,$.jsx)(op,{open:n,onClose:Te,anchorRef:m,contextDisplay:q,branchLabel:le,usageGroups:de,usageDisplayMode:A,isUsageLoading:k,timeFormatPreference:N}),t[81]=le,t[82]=q,t[83]=k,t[84]=n,t[85]=A,t[86]=Te,t[87]=N,t[88]=de,t[89]=Ee):Ee=t[89];let De;return t[90]!==ge||t[91]!==Ce||t[92]!==Ee?(De=(0,$.jsxs)($.Fragment,{children:[ge,Ce,Ee]}),t[90]=ge,t[91]=Ce,t[92]=Ee,t[93]=De):De=t[93],De}),up=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=re(),[a,o]=Z.useState(!1),s=D(e=>e.currentDirectory),c=Ze(e=>e.currentSessionId),l=Z.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=Ze(l)||s,d=Xf(u)||null,f=Xe(e=>e.projects),p=Ze(e=>e.availableWorktreesByProject),m=Z.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=Ze(m),g=Ve(c),_=Ze(e=>!!e.newSessionDraft?.open),v=Z.useMemo(()=>{let e=Xf(u);return e&&ep((h?.projectDirectory?Oe(f,h.projectDirectory):null)??Ae(f,p,e),e)||i(`mobile.header.noProject`)},[p,h?.projectDirectory,u,f,i]),y=g?.title?.trim()||(c?i(`mobile.sessions.untitled`):v),b=c?v:``;Z.useEffect(()=>{o(!1)},[c,u]);let x=U(()=>{o(!1),e()}),S=U(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(to,{children:[(0,$.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":i(`mobile.sessions.openSheetAria`),onClick:x,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folders`,className:`size-5`})}),(0,$.jsx)(lp,{open:a,onOpenChange:o,currentSessionId:c,effectiveDirectory:u,gitDirectory:d,isNewSessionDraftOpen:_,primaryLabel:y,secondaryLabel:b}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:G(`flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`files`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.files`),"aria-pressed":r.activePanel===`files`,onClick:r.onToggleFiles,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(`button`,{type:`button`,className:G(`relative flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`changes`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.changes`),"aria-pressed":r.activePanel===`changes`,onClick:r.onToggleChanges,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-5`}),r.changesDirty?(0,$.jsx)(`span`,{className:`absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary`,"aria-hidden":!0}):null]})]}):null,(0,$.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":i(`mobile.header.openMenuAria`),"aria-controls":If,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`more-2`,className:`size-5`})})]})})},dp=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=re(),r=Lt();Re(),je();let i=P(e=>e.mobileSessionPanelOpen),a=P(e=>e.setMobileSessionPanelOpen),o=P(e=>e.isScheduledTasksDialogOpen),s=P(e=>e.activeMainTab),c=_e(),l=P(e=>e.setActiveMainTab),[u,d]=Z.useState(!1),[f,p]=Z.useState(!1),[m,h]=Z.useState(null),[g,_]=Z.useState(!1),[v,y]=Z.useState(!1),[b,x]=Z.useState(null),[S,C]=Z.useState(null),[w,T]=Z.useState(null),[E,O]=Z.useState(0),[k,A]=Z.useState(!1),[j,N]=Z.useState(!1),[F,I]=Z.useState(!1),[L,R]=Z.useState(!1),[z,B]=Z.useState(!1),[ee,V]=Z.useState(!1),[te,W]=Z.useState(`nav`),[ne,ie]=Z.useState(!1),[ae,oe]=Z.useState(!1),se=U(()=>ie(e=>!e)),ce=U(()=>ie(!1)),[q,J]=Z.useState(null),le=D(e=>e.currentDirectory),ue=P(e=>e.setSettingsPage),de=Rr(e=>e.available),fe=Rr(e=>e.runtimeType),pe=Z.useMemo(()=>Kf(),[]),me=Z.useMemo(()=>Du(),[]),{data:he=[],refetch:ge}=ki(le??null,{enabled:k}),{refetch:ve}=Ai(le??null,{enabled:k}),be=Ii(e=>e.setMcpDraft),xe=Ii(e=>e.setSelectedMcp),Se=Qn(Xf(le)||null)?.files?.length??0;Z.useEffect(()=>$e.onDirectoryRequest(()=>B(!0)),[]);let Ce=Z.useMemo(()=>M(),[]),we=Dn()===`portrait`,[Te,Ee]=Z.useState(Ce&&!we),[De,Oe]=Z.useState(null),ke=U(e=>{if(e&&ue(e),Ce){W(e?`page-content`:`nav`),I(!0);return}let t=rt.getState();if(e){t.openSettingsFromCurrent();return}ue(`home`),t.setActiveTab(`settings`)}),Ae=U(()=>{ke(`instances`)}),Me=U(()=>{rt.getState().openInstances()}),Ne=U(()=>{rt.getState().closeSecondary()}),Pe=U(async()=>{if(!ee){V(!0);try{let t=await Ou();switch(t.status){case`ok`:await e.connect({url:t.url,clientToken:t.clientToken,label:t.label});break;case`pairing`:await e.redeemPairingConnection(t.pairing);break;case`permission-denied`:H.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:H.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:H.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:H.error(n(`mobile.connect.scan.failed`))}}finally{V(!1)}}});rr({enabled:!Ce,rootRoutesBlocked:i||u||f||g||v||o||k||F||L||z||ne});let Fe=U(()=>{let e=!Te;e&&we&&Oe(null),Ee(e)}),Ie=U(()=>{if(y(!1),x(null),C(null),p(!1),h(null),Ce){J(null),Oe(`files`),we&&Ee(!1);return}d(!0)}),Y=U(()=>{p(!1),h(null)}),Le=U(e=>{let t=e.path.trim();if(t){if(y(!1),x(null),C(null),J(null),_(!1),Ce){P.getState().setPendingFileFocusPath(t),Oe(`files`),we&&Ee(!1);return}d(!1),h({path:t,targetLine:typeof e.targetLine==`number`&&Number.isFinite(e.targetLine)?Math.max(1,Math.trunc(e.targetLine)):void 0}),p(!0)}}),ze=P(e=>e.pendingFileFocusPath);Z.useEffect(()=>{if(ze){if(Ce){Ie();return}Le({path:ze}),P.getState().setPendingFileFocusPath(null)}},[ze,Ce,Ie,Le]);let Be=U((e=null)=>{if(y(!1),x(null),C(null),T(null),p(!1),h(null),J(e),Ce){Oe(`changes`),we&&Ee(!1);return}_(!0)}),Ve=U((e,t,n)=>{J(null),_(!1),p(!1),h(null),x(e??null),C(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(T(r),O(e=>e+1),Ce){Oe(`turn-diff`),we&&Ee(!1);return}y(!0)}),He=U(()=>{Oe(null),J(null),T(null)}),Ue=U(e=>{if(De===e){He();return}e===`files`?Ie():Be()}),Ge=Z.useRef(`changes`);De&&(Ge.current=De);let[Ke,qe]=Z.useState(!1);Z.useEffect(()=>{if(!Ce)return;if(De){qe(!0);return}let e=window.setTimeout(()=>qe(!1),240);return()=>window.clearTimeout(e)},[De,Ce]);let Je=De??Ge.current,Ye=Wf(`left`,`openchamber.ipad.leftSidebarWidth`,Lf),Xe=Wf(`right`,`openchamber.ipad.rightSidebarWidth`,Rf),Qe=Z.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{Be(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{Be({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:Ve,openFile:({path:e,targetLine:t})=>{Le({path:e,targetLine:t})},openFiles:()=>Ie(),openSettings:e=>{ke(e)}}),[Be,Le,Ie,ke,Ve]),et=U(()=>{_(!1),J(null)}),tt=U(()=>{y(!1),T(null)});Zu(Z.useMemo(()=>({openSessions:()=>{if(Ce){Ee(!0);return}rt.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?Ie():e===`mcp`?A(!0):e===`instances`?Ae():e===`update`&&R(!0)},openChanges:({path:e,staged:t}={})=>{Be(e?{path:e,staged:t===!0}:null)},openSettings:e=>{ke(e)}}),[Ce,Be,Ie,Ae,ke]));let nt=Z.useRef(null),it=Z.useRef(null),at=Ze(e=>e.currentSessionId),ot=Ze(e=>e.setCurrentSession),st=Z.useMemo(()=>e=>at?e.getDirectoryForSession(at):null,[at]),ct=Ze(st),lt=We(at,ct||le||void 0);wf();let ut=U(()=>{let e=at;if(!e||ae)return;let t=ct||le||void 0;oe(!0),(async()=>{try{await r.refreshSessionTranscript(e,{directory:t}),H.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{H.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{oe(!1)}})()}),dt=rt(e=>e.secondary?.kind??null),ft=!Ce&&(dt===`chat`||dt===`draft`);Z.useEffect(()=>{!Ce&&!ft&&ie(!1)},[Ce,ft]),Z.useEffect(()=>{ie(!1)},[at]);let pt=Ce&&s===`assistant`||!Ce&&!ft||i||u||f||g||v||o||k||F||L||z||ne;yd(it,{onOpen:U(()=>{Bn(Vn)?.finish(`commit`)}),onPreviewStart:U(()=>{Bn(Vn)?.begin(`present`)}),onPreviewCancel:U(()=>{Bn(Vn)?.finish(`cancel`)}),onProgress:U(e=>{e!==null&&Bn(Vn)?.update(e)}),disabled:pt},Ce||ft);let mt=U(e=>{nt.current=e});Yf(U(()=>ne?(ie(!1),!0):z?(B(!1),!0):o?(window.dispatchEvent(new Event(`oc:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):sr.backImmediately(`overlay`)?!0:f?(Y(),!0):u?(d(!1),!0):v?(tt(),!0):g?(et(),!0):k?(A(!1),!0):F?(I(!1),!0):L?(R(!1),!0):sr.requestAnimatedBack(`root`)||nt.current?.()?!0:s===`assistant`?(l(`chat`),!0):lt?(ot(lt.id,lt.directory),!0):!1));let ht=de&&(fe===`desktop`||fe===`web`),gt=U(()=>{let e=`new-mcp-server`,t=e,n=1;for(;he.some(e=>e.name===t);)t=`${e}-${n}`,n+=1;be({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),xe(t),A(!1),ke(`mcp`)}),_t=U(()=>{if(j)return;N(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([ve(),ge(),e]).finally(()=>N(!1))}),vt=Ze(e=>e.openNewSessionDraft),yt=Z.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(Ce){l(`chat`),vt();return}rt.getState().openDraft()}}];return Ce||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>Ie()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:Se,onSelect:()=>Be()}),e.push({key:`mcp`,iconNode:(0,$.jsx)(Ar,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>A(!0)}),ht&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>R(!0)}),Ce&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>ke()}),at&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:ae,spinning:ae,onSelect:ut}),e},[at,Se,Ce,ae,Be,Ie,vt,ke,ut,l,ht,n]);return(0,$.jsx)(Ca,{sessionId:at??``,directory:ct||le||void 0,active:Ce?s!==`assistant`:dt===`chat`,children:(0,$.jsx)(Gn,{actions:Qe,children:(0,$.jsxs)(Za,{children:[(0,$.jsxs)(`div`,{className:`oc-mobile-app-shell main-content-safe-area flex h-[100dvh] flex-row text-foreground`,"data-page-scroll-lock":`true`,children:[Ce?(0,$.jsxs)(`aside`,{ref:Ye.asideRef,className:G(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!Te&&`border-r-0`),style:{width:Te?Ye.width:0,minWidth:Te?Ye.width:0,maxWidth:Te?Ye.width:0,"--oc-ipad-sidebar-width":`${Ye.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:Ye.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Te,"data-page-scroll-lock":`true`,children:[Te?(0,$.jsx)(Gf,{side:`left`,isResizing:Ye.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:Ye.handleProps}):null,(0,$.jsx)(`div`,{className:G(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,Ye.isResizing&&`pointer-events-none`,!Te&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(hn,{children:(0,$.jsx)(ks,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&we&&Ee(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,children:Ce?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(up,{onOpenSessions:()=>Fe(),menuOpen:ne,onToggleMenu:se,surfaceShortcuts:{activePanel:De===`turn-diff`?`changes`:De,changesDirty:Se>0,onToggleFiles:()=>Ue(`files`),onToggleChanges:()=>Ue(`changes`)}})}),(0,$.jsx)(`main`,{ref:it,className:`relative min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(`div`,{className:`relative h-full w-full bg-background`,children:(0,$.jsx)(hn,{children:s===`assistant`?(0,$.jsx)(Zi,{}):(0,$.jsx)(Br,{})})})})]}):(0,$.jsx)(rl,{className:`min-h-0 flex-1`,onAddProject:()=>B(!0),onScanQr:pe&&me?()=>{Pe()}:void 0,onSwitchInstance:pe?Me:void 0,onEnableAssistants:()=>{ke(`assistants`)},instancesPage:pe?(0,$.jsx)(rp,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,instancesSecondaryPage:pe?(0,$.jsxs)(`div`,{className:`oc-settings-workspace oc-settings-workspace-mobile flex h-full min-h-0 flex-col bg-[var(--surface-background)]`,children:[(0,$.jsx)(ye,{title:n(`mobile.settings.switchInstance`),backAriaLabel:n(`header.actions.backAria`),onBack:Ne}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[var(--oc-mobile-page-inline-inset)]`,children:(0,$.jsx)(Fi,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(rp,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:lt?{id:lt.id,directory:lt.directory}:null,registerSecondaryBackHandler:mt,scheduledContent:(e,t)=>(0,$.jsx)(mi,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(lu,{sessionId:e.sessionId,directory:e.directory,onBack:()=>{ce(),sr.requestAnimatedBack(`root`)},onOpenMenu:se,onCloseMenu:ce,menuOpen:e.active&&ne,children:(0,$.jsx)(`main`,{ref:e.active?it:void 0,className:`relative h-full min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(`div`,{className:`relative h-full w-full bg-background`,children:(0,$.jsx)(hn,{children:(0,$.jsx)(Br,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:e.sessionId||null,directory:e.directory,viewKey:e.viewKey}})})})})})})}),Ce?(0,$.jsxs)(`aside`,{ref:Xe.asideRef,className:G(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!De&&`border-l-0`),style:{width:De?Xe.width:0,minWidth:De?Xe.width:0,maxWidth:De?Xe.width:0,"--oc-ipad-sidebar-width":`${Xe.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:Xe.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!De,"data-page-scroll-lock":`true`,children:[De?(0,$.jsx)(Gf,{side:`right`,isResizing:Xe.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:Xe.handleProps}):null,(0,$.jsx)(`div`,{className:G(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,Xe.isResizing&&`pointer-events-none`,!De&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:Ke?(0,$.jsx)(hn,{children:Je===`files`?(0,$.jsx)(Jo,{onClose:He}):Je===`turn-diff`?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.nav.changes`)}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:He,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(qr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:w,navigationRequestKey:E,flushContent:!0})})]}):q?.toolPatches?.length?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:q.toolPatches.length>1?n(`mobile.nav.changes`):q.path}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:He,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(qr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:q.path,targetLine:q.targetLine??null,toolPatches:q.toolPatches,singleFileView:q.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(go,{onClose:He,initialDiffPath:q?.path??null,initialDiffStaged:q?.staged===!0,initialDiffTargetLine:q?.targetLine??null})}):null})]}):null,(0,$.jsx)(ci,{open:z,onOpenChange:B,forceMobile:!0}),(0,$.jsx)(cp,{open:ne,onClose:()=>ie(!1),items:yt,rightOffset:Ce&&De?Xe.width:0}),(0,$.jsx)(_i,{}),u?(0,$.jsx)(Rn,{id:jf,open:u,onOpenChange:e=>{e||d(!1)},ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:(0,$.jsx)(Jo,{onClose:()=>d(!1)})})}):null,f&&m?(0,$.jsx)(Rn,{id:Af,open:f,onOpenChange:e=>{e||Y()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:m.path.split(/[/\\]/).filter(Boolean).at(-1)??m.path}),ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:(0,$.jsx)(Jo,{onClose:Y,initialFilePath:m.path,directFilePreview:!0,hideFileHeader:!0},m.path)})}):null,(0,$.jsx)(Rn,{id:kf,open:v,onOpenChange:e=>{e||tt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.nav.changes`)}),ariaLabel:n(`mobile.nav.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:(0,$.jsx)(qr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:w,navigationRequestKey:E,flushContent:!0})})}),g&&q?(0,$.jsx)(Rn,{id:Of,open:g,onOpenChange:e=>{e||et()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:q.toolPatches&&q.toolPatches.length>1?n(`mobile.nav.changes`):q.path}),ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:q.toolPatches?.length?(0,$.jsx)(qr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:q.path,targetLine:q.targetLine??null,toolPatches:q.toolPatches,singleFileView:q.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(go,{initialDiffPath:q.path,initialDiffStaged:q.staged,initialDiffTargetLine:q.targetLine??null,hideDiffHeader:!0})})}):g?(0,$.jsx)(Rn,{id:Mf,open:g,onOpenChange:e=>{e||et()},ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:(0,$.jsx)(go,{onClose:et,initialDiffPath:q?.path??null,initialDiffStaged:q?.staged===!0,initialDiffTargetLine:q?.targetLine??null})})}):null,k?(0,$.jsx)(Rn,{id:Nf,open:k,onOpenChange:e=>{e||A(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mcpDropdown.title`)}),trailing:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:gt,"aria-label":n(`settings.mcp.sidebar.actions.addServerTitle`),title:n(`settings.mcp.sidebar.actions.addServerTitle`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`add`,className:`size-5`})}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:_t,disabled:j,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`refresh`,className:G(`size-5`,j&&`animate-spin`)})})]}),ariaLabel:n(`mcpDropdown.title`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:(0,$.jsx)(gi,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,F&&Ce?(0,$.jsx)(Rn,{id:Pf,open:F,onOpenChange:e=>{e||I(!1)},ariaLabel:n(`mobile.menu.settings`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:(0,$.jsx)(Hi,{forceMobile:!0,isWindowed:!0,initialMobileStage:te,visiblePageSlugs:[...Pr],onClose:()=>I(!1),mobileInstancesPage:pe?(0,$.jsx)(rp,{connection:e,onConnect:()=>I(!1),onActiveConnectionDeleted:t}):void 0})})}):null,L?(0,$.jsx)(Rn,{id:Ff,open:L,onOpenChange:e=>{e||R(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.menu.update`)}),ariaLabel:n(`mobile.menu.update`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(Li,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(Ui,{enabled:pe&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(hn,{children:(0,$.jsx)(ni,{})})]})})})};function fp({apis:e}){Z.useEffect(()=>pt(),[]);let{t}=re(),n=Ye(e=>e.initializeApp),r=Ye(e=>e.isInitialized),i=Ye(e=>e.isConnected),a=Ye(e=>e.connectionPhase),o=D(e=>e.currentDirectory),s=Ze(e=>e.currentSessionId),l=Ze(e=>!!e.newSessionDraft?.open),u=Ze(e=>e.error),f=Ze(e=>e.clearError),p=P(e=>e.setIsMobile),h=Ir(e=>e.refreshStatus),g=Xe(e=>e.projects),[v,y]=Z.useState(0),[b,x]=Z.useState(0),[S,C]=Z.useState(!1),[w,T]=Z.useState(`pending`),E=Z.useMemo(()=>le(),[]),[,O]=Z.useReducer(e=>e+1,0),k=Z.useMemo(()=>Kf(),[]),j=Z.useRef(0),M=Z.useRef(0),N=ue(()=>{T(`done`),y(e=>e+1)});Qu(U(e=>{N.redeemPairingConnection(e)}));let F=$u({ready:k&&i&&r});Z.useEffect(()=>{!N.error||!m()||H.error(N.error)},[N.error]);let I=U(()=>{let t=m(),r=M.current+1;if(M.current=r,!t){pe();return}let i=()=>{n(),h(e.github,{force:!0}),Ye.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},a=()=>{d({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)};fe().then(e=>{if(M.current===r){if(e===`no-connection`){a();return}if(e===`unreachable`){window.setTimeout(()=>{M.current===r&&fe().then(e=>{if(M.current===r&&e!==`switched`&&e===`unchanged`){i();return}})},4e3);return}e!==`switched`&&i()}});let o=Date.now();o-j.current>=Qf&&(j.current=o,window.dispatchEvent(new Event(`openchamber:system-resume`)))});qf(),Jf(I),Z.useEffect(()=>{if(!k)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>I(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[k,I]),Z.useEffect(()=>(_(e),()=>_(null)),[e]),Z.useEffect(()=>{k&&ee().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[k]),Z.useEffect(()=>{if(!k)return;let e=!1,t=[];return ee().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`download`,e=>{Rr.getState().setOtaDownloadPercent(e.percent)}),i=await n.addListener(`downloadFailed`,()=>{Rr.getState().setOtaDownloadFailed()}),a=await n.addListener(`downloadComplete`,()=>{Rr.getState().setOtaPhase(`pending_restart`)}),o=await n.addListener(`appReloaded`,()=>{Rr.getState().setOtaPhase(`pending_restart`)}),s=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),Rr.getState().setOtaPhase(`error`,`OTA update was reverted`)});if(e){r.remove(),i.remove(),a.remove(),o.remove(),s.remove();return}t.push(()=>void r.remove(),()=>void i.remove(),()=>void a.remove(),()=>void o.remove(),()=>void s.remove())}catch(e){console.warn(`[OTA] Failed to subscribe to Capgo updater events:`,e)}}),()=>{e=!0;for(let e of t)e()}},[k]),Z.useEffect(()=>c(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){Ci(),O();return}hi(e),rt.getState().reset(),x(e=>e+1),y(e=>e+1)}),[]),Z.useEffect(()=>{if(F===`pending`)return;if(F===`connect`){T(`done`);return}if(!k||i||m()){T(`done`);return}let e=!1;return T(`attempting`),de().then(e=>e?!0:pe()).catch(()=>!1).then(()=>{e||T(`done`)}),()=>{e=!0}},[F]),Z.useEffect(()=>{p(!0)},[p]),Z.useEffect(()=>{k&&!m()||n()},[v,n,k]),Nt({enabled:!k||!!m(),source:`mobileApp:recovery`}),Z.useEffect(()=>{i&&A.setDirectory(o)},[o,i]),Z.useEffect(()=>{i&&h(e.github,{force:!0})},[e.github,i,h]),Z.useEffect(()=>{if(!i||g.length===0)return;let e=!1;return(async()=>{await Promise.all(g.map(async t=>{let n=Xf(t.path);if(n)try{if(!($n.getState().directories.get(n)?.isGitRepo??await B(()=>import(`./gitApi-k8hCwYqu.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([62,1,4,3,2,24,7,5,6,8,25,26,40,41,10,42,35,43,20,21,22,23,27,28,29,44,45,46])))||e)return;await dn({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i,g]),Z.useEffect(()=>{if(!u)return;let e=window.setTimeout(()=>f(),5e3);return()=>window.clearTimeout(e)},[f,u]),Z.useEffect(()=>{if(!(!i&&(!k||m()))){C(!1);return}let e=window.setTimeout(()=>C(!0),8e3);return()=>window.clearTimeout(e)},[i,k,v,b]),Qt(),It({enabled:!0}),en(),Oi(),Ed({enabled:k&&i}),Tf();let L=Mu(),R=!i&&a===`reconnecting`;if(!L)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(_n,{width:120,height:120,isAnimated:!0})});let z=!!m();return k&&(!z||!i&&!R)?z?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-4`,children:[(0,$.jsx)(_n,{width:120,height:120,isAnimated:!S}),S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]}),(0,$.jsx)(K,{type:`button`,variant:`outline`,onClick:()=>{d({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):w===`done`?(0,$.jsx)(np,{connection:N}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(_n,{width:120,height:120,isAnimated:!0}),E?(0,$.jsxs)(`div`,{className:`absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center`,children:[(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.splash.connectingTo`)}),(0,$.jsxs)(`p`,{className:`typography-small text-foreground`,children:[E,(0,$.jsx)(tn,{})]})]}):null]}):!i&&!R?S?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`max-w-sm space-y-3`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]})}):(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(_n,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(hn,{children:(0,$.jsx)(Fe,{sdk:A.getSdkClient(),directory:o||``,bootstrapDirectory:!(l&&s===null),children:(0,$.jsx)(Dt,{apis:e,children:(0,$.jsx)(pn,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(Ti,{}),(0,$.jsx)(me,{}),(0,$.jsx)(Gt,{embeddedBackgroundWorkEnabled:r}),(0,$.jsx)(ui,{}),(0,$.jsx)(ka,{}),(0,$.jsx)(za,{}),(0,$.jsx)(dp,{connection:N,onActiveConnectionDeleted:()=>{d({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),rt.getState().reset(),y(e=>e+1)}}),(0,$.jsx)(Ot,{position:`top-center`,offset:`calc(var(--oc-safe-area-top, 0px) + 16px)`}),r?(0,$.jsx)(bi,{}):null]})})})},b)})}function pp(e){e.currentTarget.style.transform=`none`}function mp(e){return e.ensureStatus}function hp(e){return e.fetchStatus}function gp(e){return e.providers}function _p(e){return e.currentProviderId}function vp(e){return e.currentModelId}function yp(e){return e.getModelMetadata}function bp(e){return e.results}function xp(e){return e.loadSettings}function Sp(e){return e.fetchAllQuotas}function Cp(e){return e.isLoading}function wp(e){return e.displayMode}function Tp(e){return e.dropdownProviderIds}function Ep(e){return e.selectedModels}function Dp(e){return e.timeFormatPreference}function Op(e){return[e?.providerId,e]}function kp(e){return e.providerId}function Ap(e){return!e}var jp=()=>{oe(),x().then(()=>{Promise.all([b(),At()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),jt(),Kt(),wt()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{la()})};function Mp(e){ur(),jp(),P.getState().setIsMobile(!0),_a(),On(),kn();let t=document.getElementById(`root`);if(!t)throw Error(`Root element not found`);let n=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`;n&&document.documentElement.classList.add(`oc-native-app-active`);let r=n?{...e,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:e,i=(0,$.jsx)(fp,{apis:r});(0,aa.createRoot)(t).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(qt,{children:(0,$.jsx)(ie,{children:(0,$.jsx)(Mt,{children:(0,$.jsx)(rn,{children:(0,$.jsx)(Si,{children:(0,$.jsx)(Et,{children:n?i:(0,$.jsx)(zt,{children:i})})})})})})})}))}export{Mp as renderMobileApp};
|
|
28
|
+
`}),t[52]=U):U=t[52];let W;return t[53]===te?W=t[54]:(W=(0,$.jsxs)(`div`,{ref:y,className:`fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none`,children:[te,U]}),t[53]=te,t[54]=W),W},sp=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=re(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(on,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map(e=>{let t=r===`remaining`?e.window.remainingPercent:e.window.usedPercent,n=yn(e.window.valueLabel,t),i=Cn(e.window.resetAt,e.window.resetAfterFormatted??e.window.resetAtFormatted,a);return(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:e.subtitle?`${e.subtitle} · ${e.label}`:e.label}),i?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground/70`,children:i}):null]}),(0,$.jsx)(`span`,{className:G(`shrink-0 typography-ui-label font-semibold tabular-nums`,ip(e.window)),children:n===`-`?``:n})]},e.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 typography-micro text-muted-foreground`,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,$.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},cp=e=>{let t=(0,Q.c)(35),{open:n,onClose:r,items:i,rightOffset:a}=e,o=a===void 0?0:a,{t:s}=re(),c,l;if(t[0]!==r||t[1]!==n?(c=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},l=[r,n],t[0]=r,t[1]=n,t[2]=c,t[3]=l):(c=t[2],l=t[3]),Z.useEffect(c,l),!n)return null;let u;t[4]===r?u=t[5]:(u=(e,t,n)=>(0,$.jsxs)(`button`,{type:`button`,role:n===void 0?`menuitem`:`menuitemcheckbox`,"aria-checked":n,className:G(`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,t>0&&`border-t border-border/30`,e.disabled&&`cursor-not-allowed opacity-60`),style:{touchAction:`manipulation`},disabled:e.disabled,onClick:()=>{e.onSelect(),r()},children:[e.iconNode??(e.icon?(0,$.jsx)(X,{name:e.icon,className:G(`size-5 shrink-0 text-muted-foreground`,e.spinning&&`animate-spin`,e.key===`auto-read`&&`translate-x-px`)}):null),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:e.label}),e.badge&&e.badge>0?(0,$.jsx)(`span`,{className:`inline-flex size-2 shrink-0 rounded-full bg-primary`,"aria-hidden":!0}):null,n&&(0,$.jsx)(X,{name:`check`,className:`size-4 shrink-0 text-muted-foreground`})]},e.key),t[4]=r,t[5]=u);let d=u,f;t[6]===s?f=t[7]:(f=s(`mobile.menu.titleAria`),t[6]=s,t[7]=f);let p;t[8]===s?p=t[9]:(p=s(`mobile.surface.closeAria`),t[8]=s,t[9]=p);let m;t[10]===r?m=t[11]:(m=e=>{e.preventDefault(),r()},t[10]=r,t[11]=m);let h;t[12]!==p||t[13]!==m?(h=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":p,onPointerDown:m}),t[12]=p,t[13]=m,t[14]=h):h=t[14];let g=`max(1rem, calc(8px + ${o}px + var(--oc-safe-area-right, 0px)))`,_;t[15]===g?_=t[16]:(_={right:g,animation:`mobile-menu-in 160ms cubic-bezier(0.32, 0.72, 0, 1) forwards`},t[15]=g,t[16]=_);let v;if(t[17]!==i||t[18]!==d){let e;t[20]===d?e=t[21]:(e=(e,t)=>d(e,t),t[20]=d,t[21]=e),v=i.map(e),t[17]=i,t[18]=d,t[19]=v}else v=t[19];let y;t[22]!==i.length||t[23]!==d||t[24]!==s?(y=(0,$.jsx)(wa,{children:e=>{let{enabled:t,available:n,toggle:r}=e;return d({key:`auto-read`,icon:`volume-up`,label:s(`mobile.menu.autoRead`),disabled:!n,onSelect:r},i.length,t)}}),t[22]=i.length,t[23]=d,t[24]=s,t[25]=y):y=t[25];let b;t[26]!==_||t[27]!==v||t[28]!==y?(b=(0,$.jsxs)(`div`,{id:If,className:`pointer-events-auto absolute top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.25rem)] w-[min(220px,calc(100vw-1rem))] origin-top-right overflow-hidden rounded-2xl oc-mobile-overlay-surface`,role:`menu`,style:_,onAnimationEnd:pp,children:[v,y]}),t[26]=_,t[27]=v,t[28]=y,t[29]=b):b=t[29];let x;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`style`,{children:`@keyframes mobile-menu-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }`}),t[30]=x):x=t[30];let S;return t[31]!==b||t[32]!==f||t[33]!==h?(S=(0,$.jsxs)(`div`,{className:`pointer-events-none fixed inset-0 z-50`,role:`dialog`,"aria-modal":`true`,"aria-label":f,children:[h,b,x]}),t[31]=b,t[32]=f,t[33]=h,t[34]=S):S=t[34],S},lp=Z.memo(function(e){let t=(0,Q.c)(94),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=re(),{git:d}=Mn(),f=iu(i??``,a||void 0),p=f??l,m=Z.useRef(null),h=tt(i??``,a||void 0),g=Yn(o),_=Qn(o),v=$n(mp),y=$n(hp),b=Ye(gp),x=Ye(_p),S=Ye(vp),C=Ye(yp),w;t[0]===i?w=t[1]:(w=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=w);let T=we(w),E=Mr(bp),D=Mr(xp),O=Mr(Sp),k=Mr(Cp),A=Mr(wp),j=Mr(Tp),M=Mr(Ep),N=P(Dp);jr();let F,I;t[2]!==v||t[3]!==d||t[4]!==o?(F=()=>{o&&v(o,d)},I=[v,d,o],t[2]=v,t[3]=d,t[4]=o,t[5]=F,t[6]=I):(F=t[5],I=t[6]),Z.useEffect(F,I);let L,R;t[7]!==y||t[8]!==d||t[9]!==o?(L=()=>{if(o)return $e.onGitRefreshHint(e=>{Xf(e.directory)===o&&y(o,d)})},R=[y,d,o],t[7]=y,t[8]=d,t[9]=o,t[10]=L,t[11]=R):(L=t[10],R=t[11]),Z.useEffect(L,R);let z,B;t[12]===D?(z=t[13],B=t[14]):(z=()=>{D()},B=[D],t[12]=D,t[13]=z,t[14]=B),Z.useEffect(z,B);let ee,V;t[15]===j?(ee=t[16],V=t[17]):(ee=()=>{an(j)},V=[j],t[15]=j,t[16]=ee,t[17]=V),Z.useEffect(ee,V);let H,te;t[18]!==j||t[19]!==O||t[20]!==k||t[21]!==n||t[22]!==E?(H=()=>{!n||k||j.some(e=>!E.some(t=>t?.providerId===e))&&O()},te=[j,O,k,n,E],t[18]=j,t[19]=O,t[20]=k,t[21]=n,t[22]=E,t[23]=H,t[24]=te):(H=t[23],te=t[24]),Z.useEffect(H,te);let U;t[25]===h?U=t[26]:(U=kl(h),t[25]=h,t[26]=U);let W=U,ne;t[27]!==S||t[28]!==x||t[29]!==W||t[30]!==T?(ne=W??(T?{providerID:T.providerId,modelID:T.modelId}:null)??(x&&S?{providerID:x,modelID:S}:null),t[27]=S,t[28]=x,t[29]=W,t[30]=T,t[31]=ne):ne=t[31];let ie=ne,K;if(t[32]!==C||t[33]!==ie||t[34]!==b){let e=(ie?b.find(e=>e.id===ie.providerID):void 0)?.models.find(e=>e.id===ie?.modelID),n;t[36]!==C||t[37]!==ie?(n=ie?C(ie.providerID,ie.modelID):void 0,t[36]=C,t[37]=ie,t[38]=n):n=t[38];let r=n;K=Tl(e?.limit,`context`)??r?.limit?.context??0,t[32]=C,t[33]=ie,t[34]=b,t[35]=K}else K=t[35];let ae=K,oe=nt(i??``,ae,0,a||void 0),se=oe?.pending?null:oe?.totalTokens??0,ce;t[39]!==ae||t[40]!==s||t[41]!==se?(ce=Ol({totalTokens:se,contextLimit:ae,isDraft:s}),t[39]=ae,t[40]=s,t[41]=se,t[42]=ce):ce=t[42];let q=ce,J;t[43]!==_?.current||t[44]!==g||t[45]!==u?(J=g===!0?_?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[43]=_?.current,t[44]=g,t[45]=u,t[46]=J):J=t[46];let le=J,ue;if(t[47]!==j||t[48]!==E||t[49]!==M||t[50]!==u){let e=new Map(E.map(Op)),n;t[52]===j?n=t[53]:(n=e=>j.includes(e.id),t[52]=j,t[53]=n),ue=Or(E).filter(n).filter(t=>e.get(t.id)?.configured===!0).map(t=>{let n=e.get(t.id),r=[];for(let[e,t]of Object.entries(n?.usage?.windows??{}))r.push({key:`window-${e}`,label:bn(t.label??e),window:t});let i=Object.entries(n?.usage?.models??{}),a=M[t.id]??[],o=a.length>0?i.filter(e=>{let[t]=e;return a.includes(t)}):i;for(let[e,t]of o){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:bn(a.label??i),subtitle:Fr(e),window:a})}let s=!n.ok&&n.error?n.error:r.length===0?u(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:s}}),t[47]=j,t[48]=E,t[49]=M,t[50]=u,t[51]=ue}else ue=t[51];let de=ue,fe,pe;t[54]!==n||t[55]!==de?(fe=()=>{!n||de.length===0||an(de.map(kp))},pe=[n,de],t[54]=n,t[55]=de,t[56]=fe,t[57]=pe):(fe=t[56],pe=t[57]),Z.useEffect(fe,pe);let me;t[58]===c?me=t[59]:(me=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[58]=c,t[59]=me);let he;t[60]!==p||t[61]!==f?(he=p?(0,$.jsx)(`span`,{className:G(`block truncate`,f?`oc-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:p}):null,t[60]=p,t[61]=f,t[62]=he):he=t[62];let ge;t[63]!==me||t[64]!==he?(ge=(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center px-2 py-1.5 text-left`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[me,he]})}),t[63]=me,t[64]=he,t[65]=ge):ge=t[65];let _e;t[66]===u?_e=t[67]:(_e=u(`mobile.header.openMetadataAria`),t[66]=u,t[67]=_e);let ve;t[68]===r?ve=t[69]:(ve=()=>r(Ap),t[68]=r,t[69]=ve);let ye;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ye={touchAction:`manipulation`},t[70]=ye):ye=t[70];let be=q?.percentage??0,xe=q?.pending,Se;t[71]!==be||t[72]!==xe?(Se=(0,$.jsx)(Cl,{percentage:be,pending:xe}),t[71]=be,t[72]=xe,t[73]=Se):Se=t[73];let Ce;t[74]!==n||t[75]!==_e||t[76]!==ve||t[77]!==Se?(Ce=(0,$.jsx)(`button`,{ref:m,type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":_e,"aria-expanded":n,onClick:ve,style:ye,children:Se}),t[74]=n,t[75]=_e,t[76]=ve,t[77]=Se,t[78]=Ce):Ce=t[78];let Te;t[79]===r?Te=t[80]:(Te=()=>r(!1),t[79]=r,t[80]=Te);let Ee;t[81]!==le||t[82]!==q||t[83]!==k||t[84]!==n||t[85]!==A||t[86]!==Te||t[87]!==N||t[88]!==de?(Ee=(0,$.jsx)(op,{open:n,onClose:Te,anchorRef:m,contextDisplay:q,branchLabel:le,usageGroups:de,usageDisplayMode:A,isUsageLoading:k,timeFormatPreference:N}),t[81]=le,t[82]=q,t[83]=k,t[84]=n,t[85]=A,t[86]=Te,t[87]=N,t[88]=de,t[89]=Ee):Ee=t[89];let De;return t[90]!==ge||t[91]!==Ce||t[92]!==Ee?(De=(0,$.jsxs)($.Fragment,{children:[ge,Ce,Ee]}),t[90]=ge,t[91]=Ce,t[92]=Ee,t[93]=De):De=t[93],De}),up=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=re(),[a,o]=Z.useState(!1),s=D(e=>e.currentDirectory),c=Ze(e=>e.currentSessionId),l=Z.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=Ze(l)||s,d=Xf(u)||null,f=Xe(e=>e.projects),p=Ze(e=>e.availableWorktreesByProject),m=Z.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=Ze(m),g=Ve(c),_=Ze(e=>!!e.newSessionDraft?.open),v=Z.useMemo(()=>{let e=Xf(u);return e&&ep((h?.projectDirectory?Oe(f,h.projectDirectory):null)??Ae(f,p,e),e)||i(`mobile.header.noProject`)},[p,h?.projectDirectory,u,f,i]),y=g?.title?.trim()||(c?i(`mobile.sessions.untitled`):v),b=c?v:``;Z.useEffect(()=>{o(!1)},[c,u]);let x=U(()=>{o(!1),e()}),S=U(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(to,{children:[(0,$.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":i(`mobile.sessions.openSheetAria`),onClick:x,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folders`,className:`size-5`})}),(0,$.jsx)(lp,{open:a,onOpenChange:o,currentSessionId:c,effectiveDirectory:u,gitDirectory:d,isNewSessionDraftOpen:_,primaryLabel:y,secondaryLabel:b}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:G(`flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`files`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.files`),"aria-pressed":r.activePanel===`files`,onClick:r.onToggleFiles,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(`button`,{type:`button`,className:G(`relative flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`changes`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.changes`),"aria-pressed":r.activePanel===`changes`,onClick:r.onToggleChanges,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-5`}),r.changesDirty?(0,$.jsx)(`span`,{className:`absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary`,"aria-hidden":!0}):null]})]}):null,(0,$.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":i(`mobile.header.openMenuAria`),"aria-controls":If,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`more-2`,className:`size-5`})})]})})},dp=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=re(),r=Lt();Re(),je();let i=P(e=>e.mobileSessionPanelOpen),a=P(e=>e.setMobileSessionPanelOpen),o=P(e=>e.isScheduledTasksDialogOpen),s=P(e=>e.activeMainTab),c=_e(),l=P(e=>e.setActiveMainTab),[u,d]=Z.useState(!1),[f,p]=Z.useState(!1),[m,h]=Z.useState(null),[g,_]=Z.useState(!1),[v,y]=Z.useState(!1),[b,x]=Z.useState(null),[S,C]=Z.useState(null),[w,T]=Z.useState(null),[E,O]=Z.useState(0),[k,A]=Z.useState(!1),[j,N]=Z.useState(!1),[F,I]=Z.useState(!1),[L,R]=Z.useState(!1),[z,B]=Z.useState(!1),[ee,V]=Z.useState(!1),[te,W]=Z.useState(`nav`),[ne,ie]=Z.useState(!1),[ae,oe]=Z.useState(!1),se=U(()=>ie(e=>!e)),ce=U(()=>ie(!1)),[q,J]=Z.useState(null),le=D(e=>e.currentDirectory),ue=P(e=>e.setSettingsPage),de=Rr(e=>e.available),fe=Rr(e=>e.runtimeType),pe=Z.useMemo(()=>Kf(),[]),me=Z.useMemo(()=>Du(),[]),{data:he=[],refetch:ge}=ki(le??null,{enabled:k}),{refetch:ve}=Ai(le??null,{enabled:k}),be=Ii(e=>e.setMcpDraft),xe=Ii(e=>e.setSelectedMcp),Se=Qn(Xf(le)||null)?.files?.length??0;Z.useEffect(()=>$e.onDirectoryRequest(()=>B(!0)),[]);let Ce=Z.useMemo(()=>M(),[]),we=Dn()===`portrait`,[Te,Ee]=Z.useState(Ce&&!we),[De,Oe]=Z.useState(null),ke=U(e=>{if(e&&ue(e),Ce){W(e?`page-content`:`nav`),I(!0);return}let t=rt.getState();if(e){t.openSettingsFromCurrent();return}ue(`home`),t.setActiveTab(`settings`)}),Ae=U(()=>{ke(`instances`)}),Me=U(()=>{rt.getState().openInstances()}),Ne=U(()=>{rt.getState().closeSecondary()}),Pe=U(async()=>{if(!ee){V(!0);try{let t=await Ou();switch(t.status){case`ok`:await e.connect({url:t.url,clientToken:t.clientToken,label:t.label});break;case`pairing`:await e.redeemPairingConnection(t.pairing);break;case`permission-denied`:H.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:H.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:H.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:H.error(n(`mobile.connect.scan.failed`))}}finally{V(!1)}}});rr({enabled:!Ce,rootRoutesBlocked:i||u||f||g||v||o||k||F||L||z||ne});let Fe=U(()=>{let e=!Te;e&&we&&Oe(null),Ee(e)}),Ie=U(()=>{if(y(!1),x(null),C(null),p(!1),h(null),Ce){J(null),Oe(`files`),we&&Ee(!1);return}d(!0)}),Y=U(()=>{p(!1),h(null)}),Le=U(e=>{let t=e.path.trim();if(t){if(y(!1),x(null),C(null),J(null),_(!1),Ce){P.getState().setPendingFileFocusPath(t),Oe(`files`),we&&Ee(!1);return}d(!1),h({path:t,targetLine:typeof e.targetLine==`number`&&Number.isFinite(e.targetLine)?Math.max(1,Math.trunc(e.targetLine)):void 0}),p(!0)}}),ze=P(e=>e.pendingFileFocusPath);Z.useEffect(()=>{if(ze){if(Ce){Ie();return}Le({path:ze}),P.getState().setPendingFileFocusPath(null)}},[ze,Ce,Ie,Le]);let Be=U((e=null)=>{if(y(!1),x(null),C(null),T(null),p(!1),h(null),J(e),Ce){Oe(`changes`),we&&Ee(!1);return}_(!0)}),Ve=U((e,t,n)=>{J(null),_(!1),p(!1),h(null),x(e??null),C(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(T(r),O(e=>e+1),Ce){Oe(`turn-diff`),we&&Ee(!1);return}y(!0)}),He=U(()=>{Oe(null),J(null),T(null)}),Ue=U(e=>{if(De===e){He();return}e===`files`?Ie():Be()}),Ge=Z.useRef(`changes`);De&&(Ge.current=De);let[Ke,qe]=Z.useState(!1);Z.useEffect(()=>{if(!Ce)return;if(De){qe(!0);return}let e=window.setTimeout(()=>qe(!1),240);return()=>window.clearTimeout(e)},[De,Ce]);let Je=De??Ge.current,Ye=Wf(`left`,`openchamber.ipad.leftSidebarWidth`,Lf),Xe=Wf(`right`,`openchamber.ipad.rightSidebarWidth`,Rf),Qe=Z.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{Be(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{Be({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:Ve,openFile:({path:e,targetLine:t})=>{Le({path:e,targetLine:t})},openFiles:()=>Ie(),openSettings:e=>{ke(e)}}),[Be,Le,Ie,ke,Ve]),et=U(()=>{_(!1),J(null)}),tt=U(()=>{y(!1),T(null)});Zu(Z.useMemo(()=>({openSessions:()=>{if(Ce){Ee(!0);return}rt.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?Ie():e===`mcp`?A(!0):e===`instances`?Ae():e===`update`&&R(!0)},openChanges:({path:e,staged:t}={})=>{Be(e?{path:e,staged:t===!0}:null)},openSettings:e=>{ke(e)}}),[Ce,Be,Ie,Ae,ke]));let nt=Z.useRef(null),it=Z.useRef(null),at=Ze(e=>e.currentSessionId),ot=Ze(e=>e.setCurrentSession),st=Z.useMemo(()=>e=>at?e.getDirectoryForSession(at):null,[at]),ct=Ze(st),lt=We(at,ct||le||void 0);wf();let ut=U(()=>{let e=at;if(!e||ae)return;let t=ct||le||void 0;oe(!0),(async()=>{try{await r.refreshSessionTranscript(e,{directory:t}),H.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{H.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{oe(!1)}})()}),dt=rt(e=>e.secondary?.kind??null),ft=!Ce&&(dt===`chat`||dt===`draft`);Z.useEffect(()=>{!Ce&&!ft&&ie(!1)},[Ce,ft]),Z.useEffect(()=>{ie(!1)},[at]);let pt=Ce&&s===`assistant`||!Ce&&!ft||i||u||f||g||v||o||k||F||L||z||ne;yd(it,{onOpen:U(()=>{Bn(Vn)?.finish(`commit`)}),onPreviewStart:U(()=>{Bn(Vn)?.begin(`present`)}),onPreviewCancel:U(()=>{Bn(Vn)?.finish(`cancel`)}),onProgress:U(e=>{e!==null&&Bn(Vn)?.update(e)}),disabled:pt},Ce||ft);let mt=U(e=>{nt.current=e});Yf(U(()=>ne?(ie(!1),!0):z?(B(!1),!0):o?(window.dispatchEvent(new Event(`oc:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):sr.backImmediately(`overlay`)?!0:f?(Y(),!0):u?(d(!1),!0):v?(tt(),!0):g?(et(),!0):k?(A(!1),!0):F?(I(!1),!0):L?(R(!1),!0):sr.requestAnimatedBack(`root`)||nt.current?.()?!0:s===`assistant`?(l(`chat`),!0):lt?(ot(lt.id,lt.directory),!0):!1));let ht=de&&(fe===`desktop`||fe===`web`),gt=U(()=>{let e=`new-mcp-server`,t=e,n=1;for(;he.some(e=>e.name===t);)t=`${e}-${n}`,n+=1;be({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),xe(t),A(!1),ke(`mcp`)}),_t=U(()=>{if(j)return;N(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([ve(),ge(),e]).finally(()=>N(!1))}),vt=Ze(e=>e.openNewSessionDraft),yt=Z.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(Ce){l(`chat`),vt();return}rt.getState().openDraft()}}];return Ce||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>Ie()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:Se,onSelect:()=>Be()}),e.push({key:`mcp`,iconNode:(0,$.jsx)(Ar,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>A(!0)}),ht&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>R(!0)}),Ce&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>ke()}),at&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:ae,spinning:ae,onSelect:ut}),e},[at,Se,Ce,ae,Be,Ie,vt,ke,ut,l,ht,n]);return(0,$.jsx)(Ca,{sessionId:at??``,directory:ct||le||void 0,active:Ce?s!==`assistant`:dt===`chat`,children:(0,$.jsx)(Gn,{actions:Qe,children:(0,$.jsxs)(Za,{children:[(0,$.jsxs)(`div`,{className:`oc-mobile-app-shell main-content-safe-area flex h-[100dvh] flex-row text-foreground`,"data-page-scroll-lock":`true`,children:[Ce?(0,$.jsxs)(`aside`,{ref:Ye.asideRef,className:G(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!Te&&`border-r-0`),style:{width:Te?Ye.width:0,minWidth:Te?Ye.width:0,maxWidth:Te?Ye.width:0,"--oc-ipad-sidebar-width":`${Ye.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:Ye.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Te,"data-page-scroll-lock":`true`,children:[Te?(0,$.jsx)(Gf,{side:`left`,isResizing:Ye.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:Ye.handleProps}):null,(0,$.jsx)(`div`,{className:G(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,Ye.isResizing&&`pointer-events-none`,!Te&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(hn,{children:(0,$.jsx)(ks,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&we&&Ee(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,children:Ce?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(up,{onOpenSessions:()=>Fe(),menuOpen:ne,onToggleMenu:se,surfaceShortcuts:{activePanel:De===`turn-diff`?`changes`:De,changesDirty:Se>0,onToggleFiles:()=>Ue(`files`),onToggleChanges:()=>Ue(`changes`)}})}),(0,$.jsx)(`main`,{ref:it,className:`relative min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(`div`,{className:`relative h-full w-full bg-background`,children:(0,$.jsx)(hn,{children:s===`assistant`?(0,$.jsx)(Zi,{}):(0,$.jsx)(Br,{})})})})]}):(0,$.jsx)(rl,{className:`min-h-0 flex-1`,onAddProject:()=>B(!0),onScanQr:pe&&me?()=>{Pe()}:void 0,onSwitchInstance:pe?Me:void 0,onEnableAssistants:()=>{ke(`assistants`)},instancesPage:pe?(0,$.jsx)(rp,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,instancesSecondaryPage:pe?(0,$.jsxs)(`div`,{className:`oc-settings-workspace oc-settings-workspace-mobile flex h-full min-h-0 flex-col bg-[var(--surface-background)]`,children:[(0,$.jsx)(ye,{title:n(`mobile.settings.switchInstance`),backAriaLabel:n(`header.actions.backAria`),onBack:Ne}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[var(--oc-mobile-page-inline-inset)]`,children:(0,$.jsx)(Fi,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(rp,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:lt?{id:lt.id,directory:lt.directory}:null,registerSecondaryBackHandler:mt,scheduledContent:(e,t)=>(0,$.jsx)(mi,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(lu,{sessionId:e.sessionId,directory:e.directory,onBack:()=>{ce(),sr.requestAnimatedBack(`root`)},onOpenMenu:se,onCloseMenu:ce,menuOpen:e.active&&ne,children:(0,$.jsx)(`main`,{ref:e.active?it:void 0,className:`relative h-full min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(`div`,{className:`relative h-full w-full bg-background`,children:(0,$.jsx)(hn,{children:(0,$.jsx)(Br,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:e.sessionId||null,directory:e.directory,viewKey:e.viewKey}})})})})})})}),Ce?(0,$.jsxs)(`aside`,{ref:Xe.asideRef,className:G(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!De&&`border-l-0`),style:{width:De?Xe.width:0,minWidth:De?Xe.width:0,maxWidth:De?Xe.width:0,"--oc-ipad-sidebar-width":`${Xe.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:Xe.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!De,"data-page-scroll-lock":`true`,children:[De?(0,$.jsx)(Gf,{side:`right`,isResizing:Xe.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:Xe.handleProps}):null,(0,$.jsx)(`div`,{className:G(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,Xe.isResizing&&`pointer-events-none`,!De&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:Ke?(0,$.jsx)(hn,{children:Je===`files`?(0,$.jsx)(Jo,{onClose:He}):Je===`turn-diff`?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.nav.changes`)}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:He,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(qr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:w,navigationRequestKey:E,flushContent:!0})})]}):q?.toolPatches?.length?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:q.toolPatches.length>1?n(`mobile.nav.changes`):q.path}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:He,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(qr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:q.path,targetLine:q.targetLine??null,toolPatches:q.toolPatches,singleFileView:q.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(go,{onClose:He,initialDiffPath:q?.path??null,initialDiffStaged:q?.staged===!0,initialDiffTargetLine:q?.targetLine??null})}):null})]}):null,(0,$.jsx)(ci,{open:z,onOpenChange:B,forceMobile:!0}),(0,$.jsx)(cp,{open:ne,onClose:()=>ie(!1),items:yt,rightOffset:Ce&&De?Xe.width:0}),(0,$.jsx)(_i,{}),u?(0,$.jsx)(Rn,{id:jf,open:u,onOpenChange:e=>{e||d(!1)},ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:(0,$.jsx)(Jo,{onClose:()=>d(!1)})})}):null,f&&m?(0,$.jsx)(Rn,{id:Af,open:f,onOpenChange:e=>{e||Y()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:m.path.split(/[/\\]/).filter(Boolean).at(-1)??m.path}),ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:(0,$.jsx)(Jo,{onClose:Y,initialFilePath:m.path,directFilePreview:!0,hideFileHeader:!0},m.path)})}):null,(0,$.jsx)(Rn,{id:kf,open:v,onOpenChange:e=>{e||tt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.nav.changes`)}),ariaLabel:n(`mobile.nav.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:(0,$.jsx)(qr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:w,navigationRequestKey:E,flushContent:!0})})}),g&&q?(0,$.jsx)(Rn,{id:Of,open:g,onOpenChange:e=>{e||et()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:q.toolPatches&&q.toolPatches.length>1?n(`mobile.nav.changes`):q.path}),ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:q.toolPatches?.length?(0,$.jsx)(qr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:q.path,targetLine:q.targetLine??null,toolPatches:q.toolPatches,singleFileView:q.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(go,{initialDiffPath:q.path,initialDiffStaged:q.staged,initialDiffTargetLine:q.targetLine??null,hideDiffHeader:!0})})}):g?(0,$.jsx)(Rn,{id:Mf,open:g,onOpenChange:e=>{e||et()},ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:(0,$.jsx)(go,{onClose:et,initialDiffPath:q?.path??null,initialDiffStaged:q?.staged===!0,initialDiffTargetLine:q?.targetLine??null})})}):null,k?(0,$.jsx)(Rn,{id:Nf,open:k,onOpenChange:e=>{e||A(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mcpDropdown.title`)}),trailing:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:gt,"aria-label":n(`settings.mcp.sidebar.actions.addServerTitle`),title:n(`settings.mcp.sidebar.actions.addServerTitle`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`add`,className:`size-5`})}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:_t,disabled:j,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`refresh`,className:G(`size-5`,j&&`animate-spin`)})})]}),ariaLabel:n(`mcpDropdown.title`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:(0,$.jsx)(gi,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,F&&Ce?(0,$.jsx)(Rn,{id:Pf,open:F,onOpenChange:e=>{e||I(!1)},ariaLabel:n(`mobile.menu.settings`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:(0,$.jsx)(Hi,{forceMobile:!0,isWindowed:!0,initialMobileStage:te,visiblePageSlugs:[...Pr],onClose:()=>I(!1),mobileInstancesPage:pe?(0,$.jsx)(rp,{connection:e,onConnect:()=>I(!1),onActiveConnectionDeleted:t}):void 0})})}):null,L?(0,$.jsx)(Rn,{id:Ff,open:L,onOpenChange:e=>{e||R(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.menu.update`)}),ariaLabel:n(`mobile.menu.update`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(hn,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(Li,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(Ui,{enabled:pe&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(hn,{children:(0,$.jsx)(ni,{})})]})})})};function fp({apis:e}){Z.useEffect(()=>pt(),[]);let{t}=re(),n=Ye(e=>e.initializeApp),r=Ye(e=>e.isInitialized),i=Ye(e=>e.isConnected),a=Ye(e=>e.connectionPhase),o=D(e=>e.currentDirectory),s=Ze(e=>e.currentSessionId),l=Ze(e=>!!e.newSessionDraft?.open),u=Ze(e=>e.error),f=Ze(e=>e.clearError),p=P(e=>e.setIsMobile),h=Ir(e=>e.refreshStatus),g=Xe(e=>e.projects),[v,y]=Z.useState(0),[b,x]=Z.useState(0),[S,C]=Z.useState(!1),[w,T]=Z.useState(`pending`),E=Z.useMemo(()=>le(),[]),[,O]=Z.useReducer(e=>e+1,0),k=Z.useMemo(()=>Kf(),[]),j=Z.useRef(0),M=Z.useRef(0),N=ue(()=>{T(`done`),y(e=>e+1)});Qu(U(e=>{N.redeemPairingConnection(e)}));let F=$u({ready:k&&i&&r});Z.useEffect(()=>{!N.error||!m()||H.error(N.error)},[N.error]);let I=U(()=>{let t=m(),r=M.current+1;if(M.current=r,!t){pe();return}let i=()=>{n(),h(e.github,{force:!0}),Ye.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},a=()=>{d({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)};fe().then(e=>{if(M.current===r){if(e===`no-connection`){a();return}if(e===`unreachable`){window.setTimeout(()=>{M.current===r&&fe().then(e=>{if(M.current===r&&e!==`switched`&&e===`unchanged`){i();return}})},4e3);return}e!==`switched`&&i()}});let o=Date.now();o-j.current>=Qf&&(j.current=o,window.dispatchEvent(new Event(`openchamber:system-resume`)))});qf(),Jf(I),Z.useEffect(()=>{if(!k)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>I(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[k,I]),Z.useEffect(()=>(_(e),()=>_(null)),[e]),Z.useEffect(()=>{k&&ee().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[k]),Z.useEffect(()=>{if(!k)return;let e=!1,t=[];return ee().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`download`,e=>{Rr.getState().setOtaDownloadPercent(e.percent)}),i=await n.addListener(`downloadFailed`,()=>{Rr.getState().setOtaDownloadFailed()}),a=await n.addListener(`downloadComplete`,()=>{Rr.getState().setOtaPhase(`pending_restart`)}),o=await n.addListener(`appReloaded`,()=>{Rr.getState().setOtaPhase(`pending_restart`)}),s=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),Rr.getState().setOtaPhase(`error`,`OTA update was reverted`)});if(e){r.remove(),i.remove(),a.remove(),o.remove(),s.remove();return}t.push(()=>void r.remove(),()=>void i.remove(),()=>void a.remove(),()=>void o.remove(),()=>void s.remove())}catch(e){console.warn(`[OTA] Failed to subscribe to Capgo updater events:`,e)}}),()=>{e=!0;for(let e of t)e()}},[k]),Z.useEffect(()=>c(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){Ci(),O();return}hi(e),rt.getState().reset(),x(e=>e+1),y(e=>e+1)}),[]),Z.useEffect(()=>{if(F===`pending`)return;if(F===`connect`){T(`done`);return}if(!k||i||m()){T(`done`);return}let e=!1;return T(`attempting`),de().then(e=>e?!0:pe()).catch(()=>!1).then(()=>{e||T(`done`)}),()=>{e=!0}},[F]),Z.useEffect(()=>{p(!0)},[p]),Z.useEffect(()=>{k&&!m()||n()},[v,n,k]),Nt({enabled:!k||!!m(),source:`mobileApp:recovery`}),Z.useEffect(()=>{i&&A.setDirectory(o)},[o,i]),Z.useEffect(()=>{i&&h(e.github,{force:!0})},[e.github,i,h]),Z.useEffect(()=>{if(!i||g.length===0)return;let e=!1;return(async()=>{await Promise.all(g.map(async t=>{let n=Xf(t.path);if(n)try{if(!($n.getState().directories.get(n)?.isGitRepo??await B(()=>import(`./gitApi-BOlE2j2L.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([62,1,4,3,2,24,7,5,6,8,25,26,40,41,10,42,35,43,20,21,22,23,27,28,29,44,45,46])))||e)return;await dn({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i,g]),Z.useEffect(()=>{if(!u)return;let e=window.setTimeout(()=>f(),5e3);return()=>window.clearTimeout(e)},[f,u]),Z.useEffect(()=>{if(!(!i&&(!k||m()))){C(!1);return}let e=window.setTimeout(()=>C(!0),8e3);return()=>window.clearTimeout(e)},[i,k,v,b]),Qt(),It({enabled:!0}),en(),Oi(),Ed({enabled:k&&i}),Tf();let L=Mu(),R=!i&&a===`reconnecting`;if(!L)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(_n,{width:120,height:120,isAnimated:!0})});let z=!!m();return k&&(!z||!i&&!R)?z?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-4`,children:[(0,$.jsx)(_n,{width:120,height:120,isAnimated:!S}),S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]}),(0,$.jsx)(K,{type:`button`,variant:`outline`,onClick:()=>{d({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):w===`done`?(0,$.jsx)(np,{connection:N}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(_n,{width:120,height:120,isAnimated:!0}),E?(0,$.jsxs)(`div`,{className:`absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center`,children:[(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.splash.connectingTo`)}),(0,$.jsxs)(`p`,{className:`typography-small text-foreground`,children:[E,(0,$.jsx)(tn,{})]})]}):null]}):!i&&!R?S?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`max-w-sm space-y-3`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]})}):(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(_n,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(hn,{children:(0,$.jsx)(Fe,{sdk:A.getSdkClient(),directory:o||``,bootstrapDirectory:!(l&&s===null),children:(0,$.jsx)(Dt,{apis:e,children:(0,$.jsx)(pn,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(Ti,{}),(0,$.jsx)(me,{}),(0,$.jsx)(Gt,{embeddedBackgroundWorkEnabled:r}),(0,$.jsx)(ui,{}),(0,$.jsx)(ka,{}),(0,$.jsx)(za,{}),(0,$.jsx)(dp,{connection:N,onActiveConnectionDeleted:()=>{d({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),rt.getState().reset(),y(e=>e+1)}}),(0,$.jsx)(Ot,{position:`top-center`,offset:`calc(var(--oc-safe-area-top, 0px) + 16px)`}),r?(0,$.jsx)(bi,{}):null]})})})},b)})}function pp(e){e.currentTarget.style.transform=`none`}function mp(e){return e.ensureStatus}function hp(e){return e.fetchStatus}function gp(e){return e.providers}function _p(e){return e.currentProviderId}function vp(e){return e.currentModelId}function yp(e){return e.getModelMetadata}function bp(e){return e.results}function xp(e){return e.loadSettings}function Sp(e){return e.fetchAllQuotas}function Cp(e){return e.isLoading}function wp(e){return e.displayMode}function Tp(e){return e.dropdownProviderIds}function Ep(e){return e.selectedModels}function Dp(e){return e.timeFormatPreference}function Op(e){return[e?.providerId,e]}function kp(e){return e.providerId}function Ap(e){return!e}var jp=()=>{oe(),x().then(()=>{Promise.all([b(),At()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),jt(),Kt(),wt()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{la()})};function Mp(e){ur(),jp(),P.getState().setIsMobile(!0),_a(),On(),kn();let t=document.getElementById(`root`);if(!t)throw Error(`Root element not found`);let n=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`;n&&document.documentElement.classList.add(`oc-native-app-active`);let r=n?{...e,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:e,i=(0,$.jsx)(fp,{apis:r});(0,aa.createRoot)(t).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(qt,{children:(0,$.jsx)(ie,{children:(0,$.jsx)(Mt,{children:(0,$.jsx)(rn,{children:(0,$.jsx)(Si,{children:(0,$.jsx)(Et,{children:n?i:(0,$.jsx)(zt,{children:i})})})})})})})}))}export{Mp as renderMobileApp};
|