@openchambery/web 1.19.9 → 1.19.10-beta.1
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-DnN3m4Dp.js → AssistantView-7SZQ12Js.js} +1 -1
- package/dist/assets/{DiagramView-E3efnEX7.js → DiagramView-D5WUE1De.js} +1 -1
- package/dist/assets/MarkdownRenderer-CqYd9loP.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-CdpiFWqs.js → MarkdownRendererImpl-uH_cfmYV.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-BPyoNg8p.js → MarkstreamRendererImpl-BAEStQuf.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-Cx7eDb4W.js → MobileDetailNavigation-DfZmPtql.js} +1 -1
- package/dist/assets/{MobileShareBridge-B_go2MeO.js → MobileShareBridge-CSJXojSq.js} +1 -1
- package/dist/assets/MobileSurface-CmFXo_Zx.js +2 -0
- package/dist/assets/{MultiRunWindow-DLCZOjCj.js → MultiRunWindow-DM_LKkMR.js} +1 -1
- package/dist/assets/{SettingsView-C4mB0uFW.js → SettingsView-DLzL3jV2.js} +1 -1
- package/dist/assets/{SettingsWindow-OGO76Rgi.js → SettingsWindow-CtF8i9jw.js} +1 -1
- package/dist/assets/{TerminalView-Ck5P5GWU.js → TerminalView-D_XjSm4c.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BenN_1If.js → ToolOutputDialog-FB6tTD3j.js} +1 -1
- package/dist/assets/{appThemeRegistry-DAH35eaE.js → appThemeRegistry-QBlzmiVt.js} +1 -1
- package/dist/assets/{gitApi-DdJQDVmv.js → gitApi-Dhf22VRf.js} +1 -1
- package/dist/assets/{insertionBoundaries-DRvsnrxu.js → insertionBoundaries-DPXJs_6g.js} +1 -1
- package/dist/assets/{main-CEdvbeao.js → main-DDkeV7EJ.js} +2 -2
- package/dist/assets/{main-DPnPRJo9.js → main-rP7OpJ90.js} +4 -4
- package/dist/assets/{miniChat-9KRGMcES.js → miniChat-DbpkRapr.js} +2 -2
- package/dist/assets/{mobile-CaTrLmyq.js → mobile-BHzD2N9R.js} +2 -2
- package/dist/assets/{multirun-DZxLNwZx.js → multirun-Bj0sq61V.js} +1 -1
- package/dist/assets/{projectMeta-B4mvLrV7.js → projectMeta-CWZHL9ES.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-IARSnJ6n.js → renderElectronMiniChatApp-Cvq7gvEF.js} +2 -2
- package/dist/assets/{renderMobileApp-CvA1QBLw.js → renderMobileApp-Bw-DYhhE.js} +4 -4
- package/dist/assets/{runtimeConfig-CmL9jcr-.js → runtimeConfig-DI2F7QqO.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-DUO6iUn_.js → runtimeEndpointReset-BaZvZoAh.js} +1 -1
- package/dist/assets/{sessionLookup-CfllxmO1.js → sessionLookup-C0X2jjwR.js} +1 -1
- package/dist/assets/{useAppFontEffects-COqtb3tR.js → useAppFontEffects-BzioX7oh.js} +6 -6
- package/dist/assets/{useDesktopWindowControlsLayout-nDXj3p6q.js → useDesktopWindowControlsLayout-sxoPqjgO.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-DOU5Xg5n.js → useEffectiveDirectory-D36udiNq.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-BawYHSru.js → useMobileNavigationStore-DYJ6I8FV.js} +1 -1
- package/dist/assets/{useSessionAutoCleanup-R4Ke7did.js → useSessionAutoCleanup-7L5-suil.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-Dfd5Ra8Y.js → useWorkerHighlightedLines-bL-mmXJM.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
- package/dist/assets/MarkdownRenderer-BYryAKz2.js +0 -2
- package/dist/assets/MobileSurface-ByPOhQrz.js +0 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-
|
|
2
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,A as n,C as r,E as i,K as a,P as o,Y as s,b as c,j as l,k as u,t as d,z as f}from"./useUIStore-CuaA8-Hp.js";import{$ as p,Sn as m,kn as h,kt as g,n as _,t as v,xn as y}from"./persistence-DdUac14I.js";import{a as b,i as x}from"./vendor-zustand-B4dlGEM2.js";import{nt as S,rt as C,tt as w}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as T,Nt as E,n as D,r as O,t as k}from"./platform-B4KKLnZ5.js";import{a as A,n as j,o as M}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as N,t as P}from"./vendor-react-DLPElpoQ.js";import{t as F}from"./capgoAdapter-DCowZ2ab.js";/* empty css */import{a as I}from"./vendor-pierre-diffs-DX7XTPG3.js";import{r as L}from"./vendor-sonner-DVzioF3d.js";import{n as R}from"./vendor-reactuses-core-DDoDDyM9.js";import{i as z,n as ee,t as B}from"./clipboard-DJ4nQEuY.js";import{i as V,n as H}from"./store-BDFdnk6l.js";import{a as te,c as ne,d as U,f as W,l as re,o as ie,s as G,t as K,u as ae}from"./MobileShareBridge-B_go2MeO.js";import{An as oe,Ar as q,Bt as se,Ci as ce,Fa as le,Jt as ue,Na as de,Nn as fe,Nt as pe,P as me,Pa as he,Sa as ge,Ut as _e,Vt as ve,Xr as ye,Yi as be,Yt as xe,Zi as Se,_r as Ce,an as we,ar as Te,bn as Ee,c as J,cn as De,cr as Oe,dr as ke,fr as Ae,gr as je,ho as Me,hr as Ne,in as Pe,ir as Fe,mr as Y,na as Ie,nn as Le,pr as Re,r as ze,sn as Be,t as Ve,ur as He,vr as Ue,wi as We,xa as Ge,yr as Ke}from"./useMobileNavigationStore-BawYHSru.js";import{f as qe,h as Je,t as Ye}from"./MobileDetailNavigation-Cx7eDb4W.js";import{i as Xe,n as Ze,r as Qe}from"./useAssistantUIStore-me6s63b2.js";import{t as X}from"./utils-BiK3tBGM.js";import{n as Z}from"./Icon-BYM02QyU.js";import{t as $e}from"./button-C0cth9tl.js";import{F as et,I as tt,M as nt,N as rt,p as it}from"./gitApi-DdJQDVmv.js";import{At as at,C as ot,Ct as st,Dt as ct,Et as lt,Ht as ut,I as dt,It as ft,Lt as pt,Ot as mt,Q as ht,S as gt,St as _t,Tt as vt,Y as yt,ct as bt,ht as xt,i as St,kt as Ct,o as wt,r as Tt,s as Et,st as Dt,t as Ot,vt as kt,wt as At,yt as jt}from"./useAppFontEffects-COqtb3tR.js";import{A as Mt,E as Nt,F as Pt,I as Ft,L as It,M as Lt,N as Rt,P as zt,R as Bt,T as Vt,X as Ht,a as Ut,f as Wt,i as Gt,k as Kt,n as qt,s as Jt,z as Yt}from"./projectMeta-B4mvLrV7.js";import{t as Xt}from"./input-DFLpqjGR.js";import{r as Zt}from"./tooltip-BifLJ8o0.js";import{F as Qt,I as $t,P as en,V as tn,c as nn,et as rn,f as an,ht as on,o as sn,s as cn,u as ln}from"./useSessionAutoCleanup-R4Ke7did.js";import{n as un}from"./useThemeSystem-DMzWVJaW.js";import{a as dn,n as fn,s as pn}from"./OverlayScrollbar-KUpvYHdv.js";import{x as mn}from"./markdownTheme-DyJ4Gfcj.js";import{n as hn}from"./useRuntimeAPIs-DSLXJybW.js";import{N as gn,b as _n,g as vn,x as yn,y as bn}from"./insertionBoundaries-DRvsnrxu.js";import{E as xn,M as Sn,a as Cn,h as wn,i as Tn,j as En,p as Dn,r as On,s as kn,t as An}from"./appThemeRegistry-DAH35eaE.js";import{i as jn,n as Mn,o as Nn}from"./MarkdownRenderer-BYryAKz2.js";import{r as Pn}from"./textarea-Cgo_nWUU.js";import{a as Fn}from"./url-Pk6tQ1EZ.js";import{c as In,d as Ln,s as Rn,u as zn}from"./markdown-worker-CTsrtpPh.js";import{n as Bn}from"./useEffectiveDirectory-DOU5Xg5n.js";import{f as Vn}from"./FadeInOnReveal-CTlNE4Hg.js";import{f as Hn,p as Un,r as Wn,t as Gn}from"./sessionChangeSummary-hVby3sJk.js";import{$ as Kn,B as qn,I as Jn,Q as Yn,X as Xn,Z as Zn,_ as Qn,a as $n,b as er,i as tr,n as nr,o as rr,p as ir,r as ar,t as or,v as sr,z as cr}from"./MobileSurface-ByPOhQrz.js";import{t as lr}from"./useFontPreferences-BCOBlaAd.js";import{A as ur,C as dr,D as fr,E as pr,G as mr,H as hr,K as gr,L as _r,O as vr,S as yr,T as br,U as xr,W as Sr,X as Cr,Y as wr,_ as Tr,a as Er,at as Dr,b as Or,c as kr,d as Ar,f as jr,h as Mr,i as Nr,j as Pr,k as Fr,l as Ir,m as Lr,n as Rr,nt as zr,o as Br,ot as Vr,p as Hr,r as Ur,rt as Wr,t as Gr,tt as Kr,u as qr,v as Jr,w as Yr,x as Xr,y as Zr}from"./runtimeEndpointReset-DUO6iUn_.js";import{a as Qr,c as $r,i as ei,l as ti,o as ni,r as ri,s as ii,t as ai}from"./SettingsView-C4mB0uFW.js";import{a as oi,i as si,r as ci,t as li}from"./AssistantView-DnN3m4Dp.js";import{a as ui,i as di,n as fi,r as pi,t as mi}from"./context-menu-CAp74NfV.js";import{a as hi,i as gi,o as _i,r as vi}from"./fileQueries-BY-9OWzp.js";var Q=e(C(),1),yi=P(),bi=null,xi=!1,Si=new Promise(e=>{bi=e});function Ci(){xi||(xi=!0,bi?.())}var wi=6,Ti=e=>e.parentID??null,Ei=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},Di=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),Oi=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=Di(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return Ei(n?n.path:e)},ki=()=>{let e=ke.getState().activeSessions,t=oe.getState().index.session.unseenCount,n=Me.getState().projects,r=0,i=[];for(let a of e){let e=Ti(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:Oi(Oe(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,wi).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},Ai=`__OPENCHAMBER_WIDGET_SNAPSHOT__`,ji=()=>{typeof window>`u`||(window[Ai]=()=>{try{return JSON.stringify(ki())}catch{return null}})},Mi=N(),Ni=A(`OpenChamberExternalBrowser`),Pi={getPlatform:()=>j.getPlatform(),isPluginAvailable:e=>j.isPluginAvailable(e),openInSystemBrowser:e=>Ni.open(e),openExternal:Fn},Fi=async(e,t=Pi)=>{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)},$=S(),Ii=`mobile-app-update-available`,Li=`mobile-app-update-toast-dismissed-version`,Ri=()=>{let e=(0,Mi.c)(9),{t}=ee(),n=qn(zi),r=qn(Bi),i=qn(Vi),a=qn(Hi),o=qn(Ui),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,e[0]=s):s=e[0];let l=Q.useRef(s),u,d;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(u=()=>{if(k()!==`android`||r!==`mobile`||!n||!i||!a||o){Y.dismiss(Ii);return}c().getItem(Li)!==i&&(l.current.has(i)||(l.current.add(i),Y.info(t(`mobileUpdate.toast.available.title`),{id:Ii,description:t(`mobileUpdate.toast.available.description`,{version:i}),duration:1/0,icon:(0,$.jsx)(Z,{name:`download`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.toast.actions.download`),onClick:()=>{Fi(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{c().setItem(Li,i),Y.dismiss(Ii)}}})))},d=[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]=u,e[8]=d):(u=e[7],d=e[8]),Q.useEffect(u,d),null};function zi(e){return e.available}function Bi(e){return e.runtimeType}function Vi(e){return e.info?.version}function Hi(e){return e.info?.downloadUrl}function Ui(e){return e.info?.inAppApply===!0}var Wi=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Gi=e=>e.enabled&&!e.alreadyChecked,Ki=`mobile-ota-update-available`,qi=`mobile-ota-update-toast-dismissed-version`,Ji=()=>{let e=(0,Mi.c)(24),{t}=ee(),[n,r]=Q.useState(!1),i=Q.useRef(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,e[0]=a):a=e[0];let o=Q.useRef(a),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=D(),e[1]=s):s=e[1];let l=s,u=qn(Yi),d=qn(Xi),f=qn(Zi),p=qn(Qi),m=qn($i),h=qn(ea),g=qn(ta),_=qn(na),v=qn(ra),y=f?.version,b=f?.inAppApply===!0,x,S;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{Gi({enabled:l,alreadyChecked:i.current})&&(i.current=!0,qn.getState().checkForUpdates().catch(ia))},S=[l],e[2]=x,e[3]=S):(x=e[2],S=e[3]),Q.useEffect(x,S);let C;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{r(!0)},e[4]=C):C=e[4];let w=R(C),T=R(aa),E,O;if(e[5]!==u||e[6]!==T||e[7]!==b||e[8]!==w||e[9]!==d||e[10]!==t||e[11]!==y?(E=()=>{if(!Wi({enabled:l,runtimeType:d,available:u,inAppApply:b,version:y??``,dismissedVersion:c().getItem(qi),seenVersions:o.current})||!y){(!u||!b||d!==`mobile`)&&Y.dismiss(Ki);return}o.current.add(y),Y.info(t(`mobileUpdate.ota.toast.available.title`),{id:Ki,description:t(`mobileUpdate.ota.toast.available.description`,{version:y}),duration:1/0,icon:(0,$.jsx)(Z,{name:`refresh`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.ota.toast.actions.update`),onClick:w},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{T(y)}}})},O=[u,b,l,w,T,d,t,y],e[5]=u,e[6]=T,e[7]=b,e[8]=w,e[9]=d,e[10]=t,e[11]=y,e[12]=E,e[13]=O):(E=e[12],O=e[13]),Q.useEffect(E,O),!l)return null;let k;return e[14]!==n||e[15]!==_||e[16]!==m||e[17]!==p||e[18]!==g||e[19]!==f||e[20]!==h||e[21]!==v||e[22]!==d?(k=(0,$.jsx)(cr,{open:n,onOpenChange:r,info:f,downloading:p,downloaded:m,progress:h,error:g,onDownload:_,onRestart:v,runtimeType:d}),e[14]=n,e[15]=_,e[16]=m,e[17]=p,e[18]=g,e[19]=f,e[20]=h,e[21]=v,e[22]=d,e[23]=k):k=e[23],k};function Yi(e){return e.available}function Xi(e){return e.runtimeType}function Zi(e){return e.info}function Qi(e){return e.downloading}function $i(e){return e.downloaded}function ea(e){return e.progress}function ta(e){return e.error}function na(e){return e.downloadUpdate}function ra(e){return e.restartToUpdate}function ia(){}function aa(e){c().setItem(qi,e),Y.dismiss(Ki)}var oa=e=>{let t=(0,Mi.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=X(`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=X(`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},sa=`.oc-mobile-composer`;function ca(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(sa)}function la(e){if(!e||typeof e!=`object`||ca(e))return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;return n===`TEXTAREA`||n===`INPUT`||t.isContentEditable===!0}function ua(e){return ca(e??null)}function da(e,t){return e?`cache`:ca(t??null)?`open`:la(t??null)?`field`:`ignore`}function fa(e,t){return!(t>0)||!(e>=0)?!1:t>e+24}function pa(e,t){return e>0?Math.max(0,Math.round(e/(Number.isFinite(t)&&t>0?t:1))):0}var ma=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),ha=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},ga=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},_a=(e,t)=>t?`${e}\u0000staged`:e,va=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=ee(),{git:o}=hn(),s=ma(Bn()??null),c=bn(s||null),l=yn(s||null),u=vn(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]=Q.useState(()=>t?{type:`diff`,path:t,staged:n,targetLine:r}:{type:`list`}),b=Q.useRef(null);Q.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]=Q.useState(null),[C,w]=Q.useState(null),[T,E]=Q.useState(``),[D,O]=Q.useState(new Set),[k,A]=Q.useState(!1),[j,M]=Q.useState(!1),[N,P]=Q.useState([]),[F,I]=Q.useState([]),[L,z]=Q.useState([]),[B,V]=Q.useState(null),[H,te]=Q.useState({key:null,loading:!1,error:null,resolved:!1}),[ne,U]=Q.useState(0),W=Q.useRef({key:null,generation:0}),[re,ie]=Q.useState(!1),G=Ir(c)&&!re,K=Q.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=Q.useMemo(()=>K.filter(ha),[K]),oe=Q.useMemo(()=>K.filter(ga),[K]),{deferredStagedCount:q,deferredUnstagedCount:se}=Q.useMemo(()=>{if(!G||!c)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of c.files??[])ha(n)&&(e+=1),ga(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[G,c]),ce=Q.useMemo(()=>{if(L.length>0)return L;let e=c?.tracking?.includes(`/`)?c.tracking.split(`/`)[0]:null;return e||B?[{name:e||`origin`,fetchUrl:B??``,pushUrl:B??``}]:[]},[B,L,c?.tracking]),le=Q.useMemo(()=>e=>!s||v.type!==`diff`?null:e.directories.get(s)?.diffCache.get(_a(v.path,v.staged))??null,[s,v]),ue=_n(le),de=Q.useMemo(()=>v.type===`diff`?K.find(e=>e.path===v.path)??null:null,[K,v]),fe=v.type===`diff`&&s?`${s}\u0000${_a(v.path,v.staged)}`:null,pe=H.key===fe,me=!!(fe&&!ue&&(!pe||H.loading)),he=pe?H.error:null,ge=!!(de||pe&&H.resolved),_e=R(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`))}}),ve=R(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;z(t),V(n)}catch{if(!r())return;z([]),V(null)}}),ye=R(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:ve(e,e,t)}});Q.useEffect(()=>{s&&(d(s),f(s,o))},[s,f,o,d]),Q.useEffect(()=>{if(!s){W.current={key:null,generation:W.current.generation+1},z([]),V(null);return}let{requestGeneration:e,promise:t}=ye(s);return()=>{e!==null&&W.current.key===s&&W.current.generation===e&&(W.current={key:s,generation:e+1})}},[s,o,ye]),Q.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]),Q.useEffect(()=>{if(v.type!==`diff`){te({key:null,loading:!1,error:null,resolved:!1});return}let e=_a(v.path,v.staged);if(!s||!fe){te({key:null,loading:!1,error:null,resolved:!1});return}if(g(s,e)){te(e=>({key:fe,loading:!1,error:null,resolved:e.key===fe&&e.resolved||!!de}));return}let t=!1;return te({key:fe,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}),te(e=>e.key===fe?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||te(t=>t.key===fe?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[fe,s,ne,g,o,v,de,_]);let be=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 _e(n,!1),await ye(n).promise}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{S(null)}},xe=R(async(e,t)=>{if(!s||e.length===0)return;let n=s;try{t===`stage`?e.length>1?await rt(n,e):await nt(n,e[0]):e.length>1?await tt(n,e):await et(n,e[0]),await _e(n,!1)}catch(e){Y.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),Se=R((e,t=!1)=>{y({type:`diff`,path:e,staged:t,targetLine:null})}),Ce=R(()=>v.type===`diff`&&(y({type:`list`}),!0));Tn({id:`mobile-changes-diff`,active:v.type===`diff`&&!i,layer:`overlay`,onBack:Ce,surfaceRef:b});let we=R(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 _e(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})}}),Te=R(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 _e(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)}}),Ee=R(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-FB6tTD3j.js","assets/rolldown-runtime-C0FnF6B9.js","assets/useUIStore-CuaA8-Hp.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-base-ui-CnHfUmDN.js","assets/persistence-DdUac14I.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/vendor-pierre-diffs-DX7XTPG3.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/vendor-hast-util-to-html-B0p1k5Xa.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-DpDied8H.js","assets/vendor-reactuses-core-DDoDDyM9.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/clipboard-DJ4nQEuY.js","assets/store-BDFdnk6l.js","assets/dialog-CgbV5ljg.js","assets/utils-BiK3tBGM.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-BYM02QyU.js","assets/button-C0cth9tl.js","assets/useThemeSystem-DMzWVJaW.js","assets/markdownTheme-DyJ4Gfcj.js","assets/appThemeRegistry-QBlzmiVt.js","assets/platform-B4KKLnZ5.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/useMobileNavigationStore-DYJ6I8FV.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/useAssistantUIStore-me6s63b2.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/MarkdownRenderer-CqYd9loP.js","assets/markdownHeightCache-CYDlisxr.js","assets/markdown-worker-CTsrtpPh.js","assets/useEffectiveDirectory-D36udiNq.js","assets/useWorkerHighlightedLines-bL-mmXJM.js","assets/tooltip-BifLJ8o0.js","assets/vendor-tanstack-react-virtual-tlDgH6PG.js","assets/vendor-capacitor-app-PzT84wSx.js","assets/vendor-capacitor-push-notifications-DB3-G2vL.js","assets/vendor-capacitor-status-bar-DeAGEDuY.js","assets/vendor-capacitor-keyboard-BkRQ-Kv-.js","assets/gitApi-Dhf22VRf.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,A as n,C as r,E as i,K as a,P as o,Y as s,b as c,j as l,k as u,t as d,z as f}from"./useUIStore-CuaA8-Hp.js";import{$ as p,Sn as m,kn as h,kt as g,n as _,t as v,xn as y}from"./persistence-DdUac14I.js";import{a as b,i as x}from"./vendor-zustand-B4dlGEM2.js";import{nt as S,rt as C,tt as w}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as T,Nt as E,n as D,r as O,t as k}from"./platform-B4KKLnZ5.js";import{a as A,n as j,o as M}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as N,t as P}from"./vendor-react-DLPElpoQ.js";import{t as F}from"./capgoAdapter-DCowZ2ab.js";/* empty css */import{a as I}from"./vendor-pierre-diffs-DX7XTPG3.js";import{r as L}from"./vendor-sonner-DVzioF3d.js";import{n as R}from"./vendor-reactuses-core-DDoDDyM9.js";import{i as z,n as ee,t as B}from"./clipboard-DJ4nQEuY.js";import{i as V,n as H}from"./store-BDFdnk6l.js";import{a as te,c as ne,d as U,f as W,l as re,o as ie,s as G,t as K,u as ae}from"./MobileShareBridge-CSJXojSq.js";import{An as oe,Ar as q,Bt as se,Ci as ce,Fa as le,Jt as ue,Na as de,Nn as fe,Nt as pe,P as me,Pa as he,Sa as ge,Ut as _e,Vt as ve,Xr as ye,Yi as be,Yt as xe,Zi as Se,_r as Ce,an as we,ar as Te,bn as Ee,c as J,cn as De,cr as Oe,dr as ke,fr as Ae,gr as je,ho as Me,hr as Ne,in as Pe,ir as Fe,mr as Y,na as Ie,nn as Le,pr as Re,r as ze,sn as Be,t as Ve,ur as He,vr as Ue,wi as We,xa as Ge,yr as Ke}from"./useMobileNavigationStore-DYJ6I8FV.js";import{f as qe,h as Je,t as Ye}from"./MobileDetailNavigation-DfZmPtql.js";import{i as Xe,n as Ze,r as Qe}from"./useAssistantUIStore-me6s63b2.js";import{t as X}from"./utils-BiK3tBGM.js";import{n as Z}from"./Icon-BYM02QyU.js";import{t as $e}from"./button-C0cth9tl.js";import{F as et,I as tt,M as nt,N as rt,p as it}from"./gitApi-Dhf22VRf.js";import{At as at,C as ot,Ct as st,Dt as ct,Et as lt,Ht as ut,I as dt,It as ft,Lt as pt,Ot as mt,Q as ht,S as gt,St as _t,Tt as vt,Y as yt,ct as bt,ht as xt,i as St,kt as Ct,o as wt,r as Tt,s as Et,st as Dt,t as Ot,vt as kt,wt as At,yt as jt}from"./useAppFontEffects-BzioX7oh.js";import{A as Mt,E as Nt,F as Pt,I as Ft,L as It,M as Lt,N as Rt,P as zt,R as Bt,T as Vt,X as Ht,a as Ut,f as Wt,i as Gt,k as Kt,n as qt,s as Jt,z as Yt}from"./projectMeta-CWZHL9ES.js";import{t as Xt}from"./input-DFLpqjGR.js";import{r as Zt}from"./tooltip-BifLJ8o0.js";import{F as Qt,I as $t,P as en,V as tn,c as nn,et as rn,f as an,ht as on,o as sn,s as cn,u as ln}from"./useSessionAutoCleanup-7L5-suil.js";import{n as un}from"./useThemeSystem-DMzWVJaW.js";import{a as dn,n as fn,s as pn}from"./OverlayScrollbar-KUpvYHdv.js";import{x as mn}from"./markdownTheme-DyJ4Gfcj.js";import{n as hn}from"./useRuntimeAPIs-DSLXJybW.js";import{N as gn,b as _n,g as vn,x as yn,y as bn}from"./insertionBoundaries-DPXJs_6g.js";import{E as xn,M as Sn,a as Cn,h as wn,i as Tn,j as En,p as Dn,r as On,s as kn,t as An}from"./appThemeRegistry-QBlzmiVt.js";import{i as jn,n as Mn,o as Nn}from"./MarkdownRenderer-CqYd9loP.js";import{r as Pn}from"./textarea-Cgo_nWUU.js";import{a as Fn}from"./url-Pk6tQ1EZ.js";import{c as In,d as Ln,s as Rn,u as zn}from"./markdown-worker-CTsrtpPh.js";import{n as Bn}from"./useEffectiveDirectory-D36udiNq.js";import{f as Vn}from"./FadeInOnReveal-CTlNE4Hg.js";import{f as Hn,p as Un,r as Wn,t as Gn}from"./sessionChangeSummary-hVby3sJk.js";import{$ as Kn,B as qn,I as Jn,Q as Yn,X as Xn,Z as Zn,_ as Qn,a as $n,b as er,i as tr,n as nr,o as rr,p as ir,r as ar,t as or,v as sr,z as cr}from"./MobileSurface-CmFXo_Zx.js";import{t as lr}from"./useFontPreferences-BCOBlaAd.js";import{A as ur,C as dr,D as fr,E as pr,G as mr,H as hr,K as gr,L as _r,O as vr,S as yr,T as br,U as xr,W as Sr,X as Cr,Y as wr,_ as Tr,a as Er,at as Dr,b as Or,c as kr,d as Ar,f as jr,h as Mr,i as Nr,j as Pr,k as Fr,l as Ir,m as Lr,n as Rr,nt as zr,o as Br,ot as Vr,p as Hr,r as Ur,rt as Wr,t as Gr,tt as Kr,u as qr,v as Jr,w as Yr,x as Xr,y as Zr}from"./runtimeEndpointReset-BaZvZoAh.js";import{a as Qr,c as $r,i as ei,l as ti,o as ni,r as ri,s as ii,t as ai}from"./SettingsView-DLzL3jV2.js";import{a as oi,i as si,r as ci,t as li}from"./AssistantView-7SZQ12Js.js";import{a as ui,i as di,n as fi,r as pi,t as mi}from"./context-menu-CAp74NfV.js";import{a as hi,i as gi,o as _i,r as vi}from"./fileQueries-BY-9OWzp.js";var Q=e(C(),1),yi=P(),bi=null,xi=!1,Si=new Promise(e=>{bi=e});function Ci(){xi||(xi=!0,bi?.())}var wi=6,Ti=e=>e.parentID??null,Ei=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},Di=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),Oi=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=Di(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return Ei(n?n.path:e)},ki=()=>{let e=ke.getState().activeSessions,t=oe.getState().index.session.unseenCount,n=Me.getState().projects,r=0,i=[];for(let a of e){let e=Ti(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:Oi(Oe(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,wi).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},Ai=`__OPENCHAMBER_WIDGET_SNAPSHOT__`,ji=()=>{typeof window>`u`||(window[Ai]=()=>{try{return JSON.stringify(ki())}catch{return null}})},Mi=N(),Ni=A(`OpenChamberExternalBrowser`),Pi={getPlatform:()=>j.getPlatform(),isPluginAvailable:e=>j.isPluginAvailable(e),openInSystemBrowser:e=>Ni.open(e),openExternal:Fn},Fi=async(e,t=Pi)=>{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)},$=S(),Ii=`mobile-app-update-available`,Li=`mobile-app-update-toast-dismissed-version`,Ri=()=>{let e=(0,Mi.c)(9),{t}=ee(),n=qn(zi),r=qn(Bi),i=qn(Vi),a=qn(Hi),o=qn(Ui),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,e[0]=s):s=e[0];let l=Q.useRef(s),u,d;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(u=()=>{if(k()!==`android`||r!==`mobile`||!n||!i||!a||o){Y.dismiss(Ii);return}c().getItem(Li)!==i&&(l.current.has(i)||(l.current.add(i),Y.info(t(`mobileUpdate.toast.available.title`),{id:Ii,description:t(`mobileUpdate.toast.available.description`,{version:i}),duration:1/0,icon:(0,$.jsx)(Z,{name:`download`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.toast.actions.download`),onClick:()=>{Fi(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{c().setItem(Li,i),Y.dismiss(Ii)}}})))},d=[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]=u,e[8]=d):(u=e[7],d=e[8]),Q.useEffect(u,d),null};function zi(e){return e.available}function Bi(e){return e.runtimeType}function Vi(e){return e.info?.version}function Hi(e){return e.info?.downloadUrl}function Ui(e){return e.info?.inAppApply===!0}var Wi=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Gi=e=>e.enabled&&!e.alreadyChecked,Ki=`mobile-ota-update-available`,qi=`mobile-ota-update-toast-dismissed-version`,Ji=()=>{let e=(0,Mi.c)(24),{t}=ee(),[n,r]=Q.useState(!1),i=Q.useRef(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,e[0]=a):a=e[0];let o=Q.useRef(a),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=D(),e[1]=s):s=e[1];let l=s,u=qn(Yi),d=qn(Xi),f=qn(Zi),p=qn(Qi),m=qn($i),h=qn(ea),g=qn(ta),_=qn(na),v=qn(ra),y=f?.version,b=f?.inAppApply===!0,x,S;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{Gi({enabled:l,alreadyChecked:i.current})&&(i.current=!0,qn.getState().checkForUpdates().catch(ia))},S=[l],e[2]=x,e[3]=S):(x=e[2],S=e[3]),Q.useEffect(x,S);let C;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{r(!0)},e[4]=C):C=e[4];let w=R(C),T=R(aa),E,O;if(e[5]!==u||e[6]!==T||e[7]!==b||e[8]!==w||e[9]!==d||e[10]!==t||e[11]!==y?(E=()=>{if(!Wi({enabled:l,runtimeType:d,available:u,inAppApply:b,version:y??``,dismissedVersion:c().getItem(qi),seenVersions:o.current})||!y){(!u||!b||d!==`mobile`)&&Y.dismiss(Ki);return}o.current.add(y),Y.info(t(`mobileUpdate.ota.toast.available.title`),{id:Ki,description:t(`mobileUpdate.ota.toast.available.description`,{version:y}),duration:1/0,icon:(0,$.jsx)(Z,{name:`refresh`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.ota.toast.actions.update`),onClick:w},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{T(y)}}})},O=[u,b,l,w,T,d,t,y],e[5]=u,e[6]=T,e[7]=b,e[8]=w,e[9]=d,e[10]=t,e[11]=y,e[12]=E,e[13]=O):(E=e[12],O=e[13]),Q.useEffect(E,O),!l)return null;let k;return e[14]!==n||e[15]!==_||e[16]!==m||e[17]!==p||e[18]!==g||e[19]!==f||e[20]!==h||e[21]!==v||e[22]!==d?(k=(0,$.jsx)(cr,{open:n,onOpenChange:r,info:f,downloading:p,downloaded:m,progress:h,error:g,onDownload:_,onRestart:v,runtimeType:d}),e[14]=n,e[15]=_,e[16]=m,e[17]=p,e[18]=g,e[19]=f,e[20]=h,e[21]=v,e[22]=d,e[23]=k):k=e[23],k};function Yi(e){return e.available}function Xi(e){return e.runtimeType}function Zi(e){return e.info}function Qi(e){return e.downloading}function $i(e){return e.downloaded}function ea(e){return e.progress}function ta(e){return e.error}function na(e){return e.downloadUpdate}function ra(e){return e.restartToUpdate}function ia(){}function aa(e){c().setItem(qi,e),Y.dismiss(Ki)}var oa=e=>{let t=(0,Mi.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=X(`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=X(`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},sa=`.oc-mobile-composer`;function ca(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(sa)}function la(e){if(!e||typeof e!=`object`||ca(e))return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;return n===`TEXTAREA`||n===`INPUT`||t.isContentEditable===!0}function ua(e){return ca(e??null)}function da(e,t){return e?`cache`:ca(t??null)?`open`:la(t??null)?`field`:`ignore`}function fa(e,t){return!(t>0)||!(e>=0)?!1:t>e+24}function pa(e,t){return e>0?Math.max(0,Math.round(e/(Number.isFinite(t)&&t>0?t:1))):0}var ma=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),ha=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},ga=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},_a=(e,t)=>t?`${e}\u0000staged`:e,va=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=ee(),{git:o}=hn(),s=ma(Bn()??null),c=bn(s||null),l=yn(s||null),u=vn(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]=Q.useState(()=>t?{type:`diff`,path:t,staged:n,targetLine:r}:{type:`list`}),b=Q.useRef(null);Q.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]=Q.useState(null),[C,w]=Q.useState(null),[T,E]=Q.useState(``),[D,O]=Q.useState(new Set),[k,A]=Q.useState(!1),[j,M]=Q.useState(!1),[N,P]=Q.useState([]),[F,I]=Q.useState([]),[L,z]=Q.useState([]),[B,V]=Q.useState(null),[H,te]=Q.useState({key:null,loading:!1,error:null,resolved:!1}),[ne,U]=Q.useState(0),W=Q.useRef({key:null,generation:0}),[re,ie]=Q.useState(!1),G=Ir(c)&&!re,K=Q.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=Q.useMemo(()=>K.filter(ha),[K]),oe=Q.useMemo(()=>K.filter(ga),[K]),{deferredStagedCount:q,deferredUnstagedCount:se}=Q.useMemo(()=>{if(!G||!c)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of c.files??[])ha(n)&&(e+=1),ga(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[G,c]),ce=Q.useMemo(()=>{if(L.length>0)return L;let e=c?.tracking?.includes(`/`)?c.tracking.split(`/`)[0]:null;return e||B?[{name:e||`origin`,fetchUrl:B??``,pushUrl:B??``}]:[]},[B,L,c?.tracking]),le=Q.useMemo(()=>e=>!s||v.type!==`diff`?null:e.directories.get(s)?.diffCache.get(_a(v.path,v.staged))??null,[s,v]),ue=_n(le),de=Q.useMemo(()=>v.type===`diff`?K.find(e=>e.path===v.path)??null:null,[K,v]),fe=v.type===`diff`&&s?`${s}\u0000${_a(v.path,v.staged)}`:null,pe=H.key===fe,me=!!(fe&&!ue&&(!pe||H.loading)),he=pe?H.error:null,ge=!!(de||pe&&H.resolved),_e=R(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`))}}),ve=R(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;z(t),V(n)}catch{if(!r())return;z([]),V(null)}}),ye=R(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:ve(e,e,t)}});Q.useEffect(()=>{s&&(d(s),f(s,o))},[s,f,o,d]),Q.useEffect(()=>{if(!s){W.current={key:null,generation:W.current.generation+1},z([]),V(null);return}let{requestGeneration:e,promise:t}=ye(s);return()=>{e!==null&&W.current.key===s&&W.current.generation===e&&(W.current={key:s,generation:e+1})}},[s,o,ye]),Q.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]),Q.useEffect(()=>{if(v.type!==`diff`){te({key:null,loading:!1,error:null,resolved:!1});return}let e=_a(v.path,v.staged);if(!s||!fe){te({key:null,loading:!1,error:null,resolved:!1});return}if(g(s,e)){te(e=>({key:fe,loading:!1,error:null,resolved:e.key===fe&&e.resolved||!!de}));return}let t=!1;return te({key:fe,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}),te(e=>e.key===fe?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||te(t=>t.key===fe?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[fe,s,ne,g,o,v,de,_]);let be=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 _e(n,!1),await ye(n).promise}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{S(null)}},xe=R(async(e,t)=>{if(!s||e.length===0)return;let n=s;try{t===`stage`?e.length>1?await rt(n,e):await nt(n,e[0]):e.length>1?await tt(n,e):await et(n,e[0]),await _e(n,!1)}catch(e){Y.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),Se=R((e,t=!1)=>{y({type:`diff`,path:e,staged:t,targetLine:null})}),Ce=R(()=>v.type===`diff`&&(y({type:`list`}),!0));Tn({id:`mobile-changes-diff`,active:v.type===`diff`&&!i,layer:`overlay`,onBack:Ce,surfaceRef:b});let we=R(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 _e(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})}}),Te=R(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 _e(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)}}),Ee=R(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([])}),J=R(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 it(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=ce.find(t=>t.name===e)??ce[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 _e(t,!1),await ye(t).promise}else await _e(t,!1)}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{w(null),e.pushAfter&&S(null)}},Oe=Q.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 xe([e],`unstage`),onActionAll:e=>void xe(e,`unstage`),onViewDiff:e=>Se(e,!0),onRevertFile:we,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 xe([e],`stage`),onActionAll:e=>void xe(e,`stage`),onViewDiff:e=>Se(e,!1),onRevertFile:we}),e},[we,Se,xe,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)(Z,{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)(ya,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):l===!1?ke((0,$.jsx)(ya,{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)(ba,{path:v.path,diff:ue,fileExists:ge,error:he,loading:me,targetLine:v.targetLine,onBack:Ce,onRetry:()=>U(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)(Z,{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)(Mr,{syncAction:x,remotes:ce,onSync:e=>void be(`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)(qr,{stagedCount:q,unstagedCount:se,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)(Ar,{groups:Oe,diffStats:c?.diffStats,revertingPaths:D,onRevertAll:Te,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)(kr,{stagedCount:ae.length,commitMessage:T,onCommitMessageChange:E,generatedHighlights:N,onInsertHighlights:Ee,onGenerateMessage:J,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)(ya,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):ke((0,$.jsx)(ya,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},ya=e=>{let t=(0,Mi.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)(Z,{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)(Z,{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},ba=e=>{let t=(0,Mi.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}=ee(),p;t[0]===n?p=t[1]:(p=In(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)(Z,{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)($e,{type:`button`,size:`sm`,variant:`outline`,onClick:l,children:f(`diffView.actions.retry`)})]})}):o?(0,$.jsx)(ya,{loading:!0,message:f(`diffView.state.loadingDiff`)}):i?r?r.isBinary?(0,$.jsx)(ya,{icon:!0,message:f(`diffView.binary.unavailable`)}):Ln(n)?(0,$.jsx)(ya,{icon:!0,message:f(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(Pn,{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)(Cr,{original:r.original,modified:r.modified,language:m,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:s,layout:`inline`})}):(0,$.jsx)(ya,{loading:!0,message:f(`diffView.state.loadingDiff`)}):(0,$.jsx)(ya,{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],_},xa=e(w(),1),Sa=`data-oc-motion-id`,Ca=`data-oc-sheet-overscroll`,wa=`html, body { overscroll-behavior-y: none; }`,Ta=[`input`,`textarea`,`select`,`[contenteditable]:not([contenteditable="false"])`,`[data-mobile-sheet-no-dismiss]`].join(`, `),Ea=e=>e.closest(`[data-oc-motion-id]`)?.getAttribute(`data-oc-motion-id`)??null,Da=e=>{try{let t=e.contentDocument;return t?t.scrollingElement??t.documentElement:null}catch{return null}},Oa=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)&&e<=1&&t>0,ka=(e,t,n)=>e?!0:Oa(t,n),Aa=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.Element},ja=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLElement},Ma=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLStyleElement},Na=(e,t)=>{if(typeof e.item==`function`){let n=e.item(t);if(n)return n}return e[t]??null},Pa=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=Na(e,n);if(r?.identifier===t)return r}return null},Fa=(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}},Ia=(e,t)=>{let n=[],r=new Set,i=t=>{!t||r.has(t)||Fa(e,t)&&(r.add(t),n.push(t))},a=Aa(e,t)?t:null;for(;a&&(ja(e,a)&&i(a),a!==e.documentElement&&a!==e.body);)a=a.parentElement;let o=e.scrollingElement??e.documentElement;return ja(e,o)&&i(o),n},La=(e,t)=>{let n=Ia(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)},Ra=e=>{let t=e.closest(`[${Sa}]`);if(t instanceof HTMLElement){let e=t.getBoundingClientRect().height;if(Number.isFinite(e)&&e>0)return e}return window.innerHeight||1},za=e=>{let t=null,n=()=>{t?.(),t=null;let n=(()=>{try{return e.contentDocument}catch{return null}})();if(!n)return;let r=Ea(e);if(!r)return;let i=null;if(!Ma(n,n.querySelector(`style[${Ca}]`))){let e=n.createElement(`style`);e.setAttribute(Ca,`true`),e.textContent=wa,(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||(Aa(n,t.target)?t.target:null)?.closest(Ta)||!La(n,t.target))return;let r=Na(t.touches,0);if(!r)return;let i=Ra(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:Lt(i,.1,40,64),active:!1,controller:null}},c=t=>{if(!a)return;if(t.touches.length!==1){o();return}let i=Pa(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=Pt(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(!La(n,t.target)){a=null;return}if(!ka(!1,Da(e)?.scrollTop??0,s)){a=null;return}if(!Ft(`bottom`,c,s,8,1))return;let i=Yt(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=Rt(`bottom`,c,s);u.controller.update(zt(d,u.motionDistance))},l=e=>{if(!a)return;let t=a,n=Pa(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=Pt(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=Rt(`bottom`,o,i),c=It(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?.()}},Ba=Nn(()=>M(()=>import(`./ToolOutputDialog-BenN_1If.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]))),Va=25e4,Ha=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Ua=e=>{let t=Ha(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},Wa=e=>{let t=Ha(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},Ga=(e,t)=>{let n=Ha(e),r=Ha(t);return!r||n===r?Ua(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},Ka=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``},qa=e=>e.toLowerCase().endsWith(`.svg`)?``:o().authenticatedAsset(`/api/fs/raw`,{path:e}),Ja=e=>/\.(md|mdx|markdown)$/i.test(e),Ya=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return`/api/fs/serve${t.startsWith(`/`)?t:`/${t}`}`},Xa=e=>o().authenticatedAsset(Ya(e)),Za=e=>{let t=(0,Mi.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}=ee(),{files:u}=hn(),f=Bn()??null,p;t[0]===f?p=t[1]:(p=Ha(f),t[0]=f,t[1]=p);let m=p,h;t[2]!==o||t[3]!==m?(h=()=>{let e=Ha(o);return e?{type:`file`,path:e,returnDirectory:Wa(e)??m}:{type:`browser`,directory:m}},t[2]=o,t[3]=m,t[4]=h):h=t[4];let[g,_]=Q.useState(h),v=Q.useRef(null),[y,b]=Q.useState(``),x=d(ao),S=d(oo),C,w;t[5]===m?(C=t[6],w=t[7]):(C=()=>{m&&_(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:Wa(e.path)??m}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:m})},w=[m],t[5]=m,t[6]=C,t[7]=w),Q.useEffect(C,w);let T,E;t[8]!==x||t[9]!==m||t[10]!==S?(E=()=>{if(!x||!m)return;let e=Ha(x);if(!e){S(null);return}b(``),_({type:`file`,path:e,returnDirectory:Wa(e)??m}),S(null)},T=[x,m,S],t[8]=x,t[9]=m,t[10]=S,t[11]=T,t[12]=E):(T=t[11],E=t[12]),Q.useEffect(E,T);let D=g.type===`browser`?g.directory:g.returnDirectory,O=g.type===`browser`?g.directory:``,k=g.type===`file`?g.path:``,[A,j]=Q.useState(`preview`),M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{j(`preview`)},t[13]=M):M=t[13];let N;t[14]===k?N=t[15]:(N=[k],t[14]=k,t[15]=N),Q.useEffect(M,N);let P=gn(y,250),F;t[16]===y?F=t[17]:(F=y.trim(),t[16]=y,t[17]=F);let I=F,L;t[18]===P?L=t[19]:(L=P.trim(),t[18]=P,t[19]=L);let z=L,V;t[20]!==O||t[21]!==m?(V={scopeDirectory:m,directory:O},t[20]=O,t[21]=m,t[22]=V):V=t[22];let H=!!O,te;t[23]===H?te=t[24]:(te={enabled:H,refetchOnMount:`always`},t[23]=H,t[24]=te);let ne=gi(V,te),U;t[25]!==O||t[26]!==z?(U={directory:O,query:z,maxResults:40},t[25]=O,t[26]=z,t[27]=U):U=t[27];let W=!!(O&&z),re;t[28]===W?re=t[29]:(re={enabled:W},t[28]=W,t[29]=re);let ie=hi(U,re),G;t[30]!==k||t[31]!==u||t[32]!==A?(G=k&&u.readFile&&(!zn(k)||A===`source`)&&(!Ln(k)||k.toLowerCase().endsWith(`.svg`)),t[30]=k,t[31]=u,t[32]=A,t[33]=G):G=t[33];let K=!!G,ae;t[34]!==k||t[35]!==m?(ae={scopeDirectory:m,path:k},t[34]=k,t[35]=m,t[36]=ae):ae=t[36];let oe;t[37]===K?oe=t[38]:(oe={enabled:K},t[37]=K,t[38]=oe);let q=vi(ae,oe),se;t[39]!==k||t[40]!==m?(se={scopeDirectory:m,path:k},t[39]=k,t[40]=m,t[41]=se):se=t[41];let ce;t[42]===K?ce=t[43]:(ce={enabled:K},t[42]=K,t[43]=ce),_i(se,ce);let le=ne.data?.entries.slice().sort(so)??[],ue;t[44]!==ne.error||t[45]!==l?(ue=ne.error?ne.error instanceof Error?ne.error.message:l(`mobile.files.error.listFailed`):null,t[44]=ne.error,t[45]=l,t[46]=ue):ue=t[46];let de=ue,fe=ne.isFetching,pe;t[47]===ie.data?pe=t[48]:(pe=ie.data??[],t[47]=ie.data,t[48]=pe);let me=pe,he=!!(I&&z&&y===P&&ie.isFetching),ge;t[49]!==q.data||t[50]!==l?(ge=q.data&&q.data.length>Va?`${q.data.slice(0,Va)}\n\n${l(`mobile.files.file.truncated`)}`:q.data??``,t[49]=q.data,t[50]=l,t[51]=ge):ge=t[51];let _e=ge,ve;t[52]!==k||t[53]!==q.error||t[54]!==u||t[55]!==l?(ve=k&&!u.readFile?l(`mobile.files.error.readUnavailable`):q.error?q.error instanceof Error?q.error.message:l(`filesView.error.readFileFailed`):null,t[52]=k,t[53]=q.error,t[54]=u,t[55]=l,t[56]=ve):ve=t[56];let ye=ve,be=K&&q.isFetching,xe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(xe=e=>{b(``),_({type:`browser`,directory:e})},t[57]=xe):xe=t[57];let Se=xe,Ce;t[58]!==D||t[59]!==m?(Ce=e=>{_({type:`file`,path:e,returnDirectory:D||m})},t[58]=D,t[59]=m,t[60]=Ce):Ce=t[60];let we=Ce,Te;t[61]!==s||t[62]!==n||t[63]!==g.returnDirectory||t[64]!==g.type?(Te=()=>g.type===`file`?s?(n?.(),!0):(_({type:`browser`,directory:g.returnDirectory}),!0):!1,t[61]=s,t[62]=n,t[63]=g.returnDirectory,t[64]=g.type,t[65]=Te):Te=t[65];let Ee=R(Te),J=g.type===`file`,De;t[66]!==Ee||t[67]!==J?(De={id:`mobile-files-detail`,active:J,layer:`overlay`,onBack:Ee,surfaceRef:v},t[66]=Ee,t[67]=J,t[68]=De):De=t[68],Tn(De);let Oe;t[69]===l?Oe=t[70]:(Oe=async e=>{(await B(e)).ok||Y.error(l(`mobile.files.toast.copyFailed`))},t[69]=l,t[70]=Oe);let ke=Oe,Ae;t[71]!==_e||t[72]!==l?(Ae=async()=>{(await B(_e)).ok?Y.success(l(`mobile.files.toast.contentCopied`)):Y.error(l(`mobile.files.toast.copyFailed`))},t[71]=_e,t[72]=l,t[73]=Ae):Ae=t[73];let je=Ae;if(!m){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)(io,{message:e}),t[76]=e,t[77]=n),n}if(g.type===`file`){let e;t[78]!==ke||t[79]!==g.path?(e=()=>void ke(g.path),t[78]=ke,t[79]=g.path,t[80]=e):e=t[80];let n;t[81]===je?n=t[82]:(n=()=>void je(),t[81]=je,t[82]=n);let r;return t[83]!==Ee||t[84]!==_e||t[85]!==ye||t[86]!==c||t[87]!==A||t[88]!==be||t[89]!==g.path||t[90]!==e||t[91]!==n?(r=(0,$.jsx)(`div`,{ref:v,className:`flex h-full min-h-0 flex-col`,children:(0,$.jsx)(to,{path:g.path,content:_e,error:ye,isLoading:be,hideHeader:c,htmlViewMode:A,onHtmlViewModeChange:j,onBack:Ee,onCopyPath:e,onCopyContent:n})}),t[83]=Ee,t[84]=_e,t[85]=ye,t[86]=c,t[87]=A,t[88]=be,t[89]=g.path,t[90]=e,t[91]=n,t[92]=r):r=t[92],r}let Me;t[93]!==m||t[94]!==g.directory||t[95]!==l?(Me=g.directory===m?l(`mobile.files.rootDirectory`):Ua(g.directory),t[93]=m,t[94]=g.directory,t[95]=l,t[96]=Me):Me=t[96];let Ne=Me,Pe;t[97]!==y||t[98]!==me?(Pe=y.trim()?me:[],t[97]=y,t[98]=me,t[99]=Pe):Pe=t[99];let Fe=Pe,Ie,Le,Re,ze;if(t[100]!==n||t[101]!==y||t[102]!==m||t[103]!==g.directory||t[104]!==l){let e=Wa(g.directory),r=g.directory!==m&&e!==null&&(e===m||e.startsWith(`${m}/`)),i=r&&!y.trim(),a=r?e:null;ze=`flex h-full flex-col overflow-hidden bg-background text-foreground`,Ie=`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[109]!==n||t[110]!==l?(Le=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)(Z,{name:`close`,className:`size-5`})}):null,t[109]=n,t[110]=l,t[111]=Le):Le=t[111],Re=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:Ua(a)}),onClick:()=>Se(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`arrow-left`,className:`size-5`})}):null,t[100]=n,t[101]=y,t[102]=m,t[103]=g.directory,t[104]=l,t[105]=Ie,t[106]=Le,t[107]=Re,t[108]=ze}else Ie=t[105],Le=t[106],Re=t[107],ze=t[108];let Be;t[112]===Ne?Be=t[113]:(Be=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:Ne})}),t[112]=Ne,t[113]=Be);let Ve;t[114]===l?Ve=t[115]:(Ve=l(`mobile.files.refreshAria`),t[114]=l,t[115]=Ve);let He;t[116]===ne?He=t[117]:(He=()=>void ne.refetch(),t[116]=ne,t[117]=He);let Ue;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(Ue={touchAction:`manipulation`},t[118]=Ue):Ue=t[118];let We=fe&&`animate-spin`,Ge;t[119]===We?Ge=t[120]:(Ge=X(`size-5`,We),t[119]=We,t[120]=Ge);let Ke;t[121]===Ge?Ke=t[122]:(Ke=(0,$.jsx)(Z,{name:`refresh`,className:Ge}),t[121]=Ge,t[122]=Ke);let qe;t[123]!==Ve||t[124]!==He||t[125]!==Ke?(qe=(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":Ve,onClick:He,style:Ue,children:Ke}),t[123]=Ve,t[124]=He,t[125]=Ke,t[126]=qe):qe=t[126];let Je;t[127]!==Ie||t[128]!==Le||t[129]!==Re||t[130]!==Be||t[131]!==qe?(Je=(0,$.jsxs)(`header`,{className:Ie,children:[Le,Re,Be,qe]}),t[127]=Ie,t[128]=Le,t[129]=Re,t[130]=Be,t[131]=qe,t[132]=Je):Je=t[132];let Ye;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=(0,$.jsx)(Z,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[133]=Ye):Ye=t[133];let Xe;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=e=>b(e.target.value),t[134]=Xe):Xe=t[134];let Ze;t[135]===l?Ze=t[136]:(Ze=l(`mobile.files.search.placeholder`),t[135]=l,t[136]=Ze);let Qe;t[137]!==y||t[138]!==Ze?(Qe=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[Ye,(0,$.jsx)(Xt,{type:`text`,inputMode:`search`,value:y,onChange:Xe,placeholder:Ze,className:`h-11 pl-9`})]})}),t[137]=y,t[138]=Ze,t[139]=Qe):Qe=t[139];let $e=Pn,et=de?(0,$.jsx)(io,{message:de}):y.trim()?(0,$.jsx)($a,{results:Fe,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)(Qa,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:Ka(e.size),onClick:()=>e.isDirectory?Se(e.path):we(e.path)},e.path))]}),tt;t[140]!==$e||t[141]!==et?(tt=(0,$.jsx)($e,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:et}),t[140]=$e,t[141]=et,t[142]=tt):tt=t[142];let nt;return t[143]!==ze||t[144]!==Je||t[145]!==Qe||t[146]!==tt?(nt=(0,$.jsxs)(`div`,{className:ze,children:[Je,Qe,tt]}),t[143]=ze,t[144]=Je,t[145]=Qe,t[146]=tt,t[147]=nt):nt=t[147],nt},Qa=e=>{let t=(0,Mi.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)(Z,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(jt,{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)(Z,{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},$a=e=>{let t=(0,Mi.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=ee(),o=Ha(Bn()??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)(io,{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)(io,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(Qa,{name:Ua(e.path),path:e.path,directory:!1,meta:Ga(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},eo=e=>{let t=(0,Mi.c)(24),{path:n,htmlViewMode:r,htmlFullscreen:i,onToggleHtmlViewMode:a,onEnterHtmlFullscreen:o,onCopyPath:s,onCopyContent:c}=e,{t:l}=ee(),u;t[0]===n?u=t[1]:(u=zn(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)($e,{type:`button`,variant:`ghost`,size:`icon`,onClick:a,"aria-label":l(r===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(Z,{name:r===`preview`?`file-code`:`eye`,className:`size-4`})}),i?null:(0,$.jsx)($e,{type:`button`,variant:`ghost`,size:`icon`,onClick:o,"aria-label":l(`mobile.files.html.fullscreenAria`),children:(0,$.jsx)(Z,{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=!Ln(n)&&!d?(0,$.jsx)($e,{type:`button`,variant:`ghost`,size:`icon`,onClick:c,"aria-label":l(`mobile.files.copyContentAria`),children:(0,$.jsx)(Z,{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)(Z,{name:`clipboard`,className:`size-4`}),t[16]=h):h=t[16];let g;t[17]!==s||t[18]!==m?(g=(0,$.jsx)($e,{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],_},to=e=>{let n=(0,Mi.c)(100),{path:o,content:s,error:c,isLoading:l,hideHeader:u,htmlViewMode:d,onHtmlViewModeChange:f,onBack:p,onCopyPath:m,onCopyContent:g}=e,_=u!==void 0&&u,{t:v}=ee(),y=Q.useRef(null),b=Ln(o)&&!o.toLowerCase().endsWith(`.svg`)?o:``,x;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=i(),n[0]=x):x=n[0];let S=x,C;n[1]===b?C=n[2]:(C=b&&t()?`${S}|${b}`:``,n[1]=b,n[2]=C);let w=C,T=b&&!w?`${S}|${b}`:``,[E,D]=Q.useState(``),[O,k]=Q.useState(``),[A,j]=Q.useState(null),[M,N]=Q.useState(!1),P;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(P={open:!1,title:``,content:``},n[3]=P):P=n[3];let[F,I]=Q.useState(P),L,z;n[4]===T?(L=n[5],z=n[6]):(L=()=>{if(!T){D(``);return}let e=!1;return D(``),a(r()).then(t=>{!e&&t&&D(T)}).catch(co),()=>{e=!0}},z=[T],n[4]=T,n[5]=L,n[6]=z),Q.useEffect(L,z);let B,V;n[7]!==b||n[8]!==w||n[9]!==v?(B=()=>{if(!w){k(``),j(null),N(!1);return}let e=!1,t=``;return k(``),j(null),N(!0),h(`/api/fs/raw`,{query:{path:b}}).then(async e=>{if(!e.ok)throw Error(v(`filesView.error.readFileFailed`));return e.blob()}).then(n=>{if(t=URL.createObjectURL(n),e){URL.revokeObjectURL(t);return}k(t)}).catch(t=>{e||j(t instanceof Error?t.message:v(`filesView.error.readFileFailed`))}).finally(()=>{e||N(!1)}),()=>{e=!0,t&&URL.revokeObjectURL(t)}},V=[b,w,v],n[7]=b,n[8]=w,n[9]=v,n[10]=B,n[11]=V):(B=n[10],V=n[11]),Q.useEffect(B,V);let H=!!(T&&E!==T),te;n[12]!==H||n[13]!==o||n[14]!==w||n[15]!==O?(te=w?O:H?``:qa(o),n[12]=H,n[13]=o,n[14]=w,n[15]=O,n[16]=te):te=n[16];let ne=te,U=c??A,W;n[17]===o?W=n[18]:(W=Ua(o),n[17]=o,n[18]=W);let re=W,ie;n[19]!==s||n[20]!==o?(ie=Ln(o)?`data:${Rn(o)};utf8,${encodeURIComponent(s)}`:``,n[19]=s,n[20]=o,n[21]=ie):ie=n[21];let G=ie,K;n[22]!==s||n[23]!==G||n[24]!==ne||n[25]!==o?(K=ne||(Ln(o)&&s?G:``),n[22]=s,n[23]=G,n[24]=ne,n[25]=o,n[26]=K):K=n[26];let ae=K,oe;n[27]!==re||n[28]!==b||n[29]!==o||n[30]!==ae?(oe=()=>{let e=b||ae;e&&I({open:!0,title:re,content:``,metadata:{tool:`image-preview`,filename:re,mime:Rn(o)},image:{url:e,mimeType:Rn(o),filename:re}})},n[27]=re,n[28]=b,n[29]=o,n[30]=ae,n[31]=oe):oe=n[31];let q=R(oe),se;n[32]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>{I(t=>t.open===e?t:{...t,open:e})},n[32]=se):se=n[32];let ce=R(se),le;n[33]===o?le=n[34]:(le=zn(o),n[33]=o,n[34]=le);let ue=le,[de,fe]=Q.useState(!1),pe=Q.useRef(null),me;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>{fe(!1)},n[35]=me):me=n[35];let he;n[36]===o?he=n[37]:(he=[o],n[36]=o,n[37]=he),Q.useEffect(me,he);let ge;n[38]!==d||n[39]!==f?(ge=()=>{f(d===`preview`?`source`:`preview`)},n[38]=d,n[39]=f,n[40]=ge):ge=n[40];let _e=R(ge),ve;n[41]===Symbol.for(`react.memo_cache_sentinel`)?(ve=()=>{fe(!0)},n[41]=ve):ve=n[41];let ye=R(ve),be;n[42]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>(fe(!1),!0),n[42]=be):be=n[42];let xe=R(be),Se=ue&&de,Ce;n[43]!==xe||n[44]!==Se?(Ce={id:`mobile-html-fullscreen`,active:Se,layer:`overlay`,onBack:xe,surfaceRef:pe},n[43]=xe,n[44]=Se,n[45]=Ce):Ce=n[45],Tn(Ce);let we;n[46]!==ye||n[47]!==de||n[48]!==d||n[49]!==g||n[50]!==m||n[51]!==o||n[52]!==_e?(we=(0,$.jsx)(eo,{path:o,htmlViewMode:d,htmlFullscreen:de,onToggleHtmlViewMode:_e,onEnterHtmlFullscreen:ye,onCopyPath:m,onCopyContent:g}),n[46]=ye,n[47]=de,n[48]=d,n[49]=g,n[50]=m,n[51]=o,n[52]=_e,n[53]=we):we=n[53];let Te=we,Ee;n[54]!==s||n[55]!==c||n[56]!==d||n[57]!==l||n[58]!==o||n[59]!==v?(Ee=d===`source`?l?(0,$.jsx)(io,{loading:!0,message:v(`filesView.state.loading`)}):c?(0,$.jsx)(io,{message:c}):(0,$.jsx)(ro,{path:o,content:s}):(0,$.jsx)(no,{path:o}),n[54]=s,n[55]=c,n[56]=d,n[57]=l,n[58]=o,n[59]=v,n[60]=Ee):Ee=n[60];let J=Ee,De;n[61]!==xe||n[62]!==ue||n[63]!==J||n[64]!==de||n[65]!==d||n[66]!==re||n[67]!==v||n[68]!==_e?(De=ue?(0,$.jsxs)(`div`,{ref:pe,"data-mobile-html-preview":d===`preview`&&!de?`true`:void 0,"data-mobile-html-fullscreen":d===`preview`&&de?`true`:void 0,className:de?`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:[de?(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)($e,{type:`button`,variant:`ghost`,size:`icon`,onClick:xe,"aria-label":v(`mobile.files.html.exitFullscreenAria`),className:`shrink-0 text-muted-foreground`,children:(0,$.jsx)(Z,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-header text-foreground`,children:re}),(0,$.jsx)($e,{type:`button`,variant:`ghost`,size:`icon`,onClick:_e,"aria-label":v(d===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(Z,{name:d===`preview`?`file-code`:`eye`,className:`size-4`})})]}):null,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden bg-background`,children:J})]}):null,n[61]=xe,n[62]=ue,n[63]=J,n[64]=de,n[65]=d,n[66]=re,n[67]=v,n[68]=_e,n[69]=De):De=n[69];let Oe=De,ke;n[70]!==Te||n[71]!==_||n[72]!==re||n[73]!==p||n[74]!==v?(ke=_?(0,$.jsx)(Mt,{children:Te}):(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":v(`header.actions.backAria`),onClick:p,children:(0,$.jsx)(Z,{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:re})}),Te]}),n[70]=Te,n[71]=_,n[72]=re,n[73]=p,n[74]=v,n[75]=ke):ke=n[75];let Ae;n[76]!==s||n[77]!==ue||n[78]!==de||n[79]!==Oe||n[80]!==H||n[81]!==U||n[82]!==re||n[83]!==l||n[84]!==M||n[85]!==q||n[86]!==o||n[87]!==ae||n[88]!==v?(Ae=ue?de&&typeof document<`u`?(0,xa.createPortal)(Oe,document.body):Oe:l||H||M?(0,$.jsx)(io,{loading:!0,message:v(`filesView.state.loading`)}):U?(0,$.jsx)(io,{message:U}):Ln(o)&&ae?(0,$.jsx)(Pn,{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:q,"aria-label":re,children:(0,$.jsx)(`img`,{src:ae,alt:re,className:`mx-auto max-h-full max-w-full rounded-lg object-contain`,draggable:!1})})}):(0,$.jsx)(ro,{path:o,content:s}),n[76]=s,n[77]=ue,n[78]=de,n[79]=Oe,n[80]=H,n[81]=U,n[82]=re,n[83]=l,n[84]=M,n[85]=q,n[86]=o,n[87]=ae,n[88]=v,n[89]=Ae):Ae=n[89];let je;n[90]===Ae?je=n[91]:(je=(0,$.jsx)(`div`,{ref:y,className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:Ae}),n[90]=Ae,n[91]=je);let Me;n[92]===Symbol.for(`react.memo_cache_sentinel`)?(Me=(0,$.jsx)(yt,{containerRef:y}),n[92]=Me):Me=n[92];let Ne;n[93]!==ce||n[94]!==F?(Ne=F.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ba,{popup:F,onOpenChange:ce,isMobile:!0})}):null,n[93]=ce,n[94]=F,n[95]=Ne):Ne=n[95];let Pe;return n[96]!==ke||n[97]!==je||n[98]!==Ne?(Pe=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[ke,je,Me,Ne]}),n[96]=ke,n[97]=je,n[98]=Ne,n[99]=Pe):Pe=n[99],Pe},no=e=>{let n=(0,Mi.c)(29),{path:i}=e,{t:o}=ee(),c;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=t(),n[0]=c):c=n[0];let l=c,u=Q.useRef(null),[d,p]=Q.useState(``),[m,g]=Q.useState(0),[_,v]=Q.useState(null),[y,b]=Q.useState(``),x,S;n[1]!==i||n[2]!==o?(x=()=>{let e=!1;if(p(``),v(null),b(``),l)return h(Ya(i)).then(async e=>{if(!e.ok)throw Error(o(`filesView.error.readFileFailed`));return e.text()}).then(t=>{e||(b(t),p(i))}).catch(t=>{e||(v(t instanceof Error?t.message:o(`filesView.error.readFileFailed`)),p(i))}),()=>{e=!0};let t=r(),n=f(t);a(t).then(t=>{e||!t||(p(i),v(null))}).catch(t=>{e||(v(t instanceof Error?t.message:o(`filesView.error.readFileFailed`)),p(i))});let c=s(()=>{e||(p(i),g(lo),v(null))});return()=>{e=!0,n(),c()}},S=[i,l,o],n[1]=i,n[2]=o,n[3]=x,n[4]=S):(x=n[3],S=n[4]),Q.useEffect(x,S);let C;n[5]!==i||n[6]!==d?(C=()=>{if(d!==i)return;let e=u.current;if(e)return za(e)},n[5]=i,n[6]=d,n[7]=C):C=n[7];let w;if(n[8]!==m||n[9]!==i||n[10]!==d||n[11]!==y?(w=[m,i,d,y],n[8]=m,n[9]=i,n[10]=d,n[11]=y,n[12]=w):w=n[12],Q.useEffect(C,w),_){let e;return n[13]===_?e=n[14]:(e=(0,$.jsx)(io,{message:_}),n[13]=_,n[14]=e),e}if(d!==i){let e;n[15]===o?e=n[16]:(e=o(`filesView.state.loading`),n[15]=o,n[16]=e);let t;return n[17]===e?t=n[18]:(t=(0,$.jsx)(io,{loading:!0,message:e}),n[17]=e,n[18]=t),t}let T;n[19]===i?T=n[20]:(T=l?void 0:Xa(i),n[19]=i,n[20]=T);let E=l?y:void 0,D;n[21]===Symbol.for(`react.memo_cache_sentinel`)?(D={backgroundColor:`var(--surface-background)`},n[21]=D):D=n[21];let O;n[22]===o?O=n[23]:(O=o(`filesView.editor.htmlPreviewTitle`),n[22]=o,n[23]=O);let k;return n[24]!==m||n[25]!==T||n[26]!==E||n[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},m)}),n[24]=m,n[25]=T,n[26]=E,n[27]=O,n[28]=k):k=n[28],k},ro=e=>{let t=(0,Mi.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=un(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??mn(!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)??mn(!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=()=>{An(l),An(d)},p=[d,l],t[6]=d,t[7]=l,t[8]=f,t[9]=p):(f=t[8],p=t[9]),Q.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(Ja(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Pn,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(Mn,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=Ua(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=In(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:wr},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)(Pn,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(I,{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},io=e=>{let t=(0,Mi.c)(7),{message:n,loading:r}=e,i=r!==void 0&&r,a;t[0]===i?a=t[1]:(a=i?(0,$.jsx)(Z,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(Z,{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 ao(e){return e.pendingFileFocusPath}function oo(e){return e.setPendingFileFocusPath}function so(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}function co(){}function lo(e){return e+1}var uo=b(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),fo=b()(x(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:g()}));typeof window<`u`&&n(e=>{u(e)&&fo.persist.rehydrate()});var po=36,mo=18,ho=e=>e.parentID??null,go=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),_o=e=>{let t=e;return go(t.directory??t.project?.worktree??null)},vo=e=>{let t=go(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},yo=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},bo=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),xo=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))},So=(e,t)=>{let n=go(e),r=go(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},Co=(e,t)=>e.worktrees.find(e=>go(e.path)===t)??null,wo=(e,t)=>t===e.path||!!Co(e,t),To=(e,t)=>{let n=go(t);return n?e.find(e=>wo(e,n))??null:null},Eo=(e,t,n)=>!n||`${e.title??``} ${e.id} ${_o(e)} ${t}`.toLowerCase().includes(n),Do=e=>{let t=(0,Mi.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?Gt[n.icon]:null,c=n.color?qt[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)(Z,{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=X(`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)(Ut,{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},Oo=e=>{let t=(0,Mi.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=X(`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)(Z,{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},ko=e=>{let t=(0,Mi.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},Ao=e=>{let t=(0,Mi.c)(12),{onClick:n,className:r}=e,{t:i}=ee(),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=X(`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)(Z,{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},jo=e=>{let t=(0,Mi.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)(Z,{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)($e,{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},Mo=e=>{let t=(0,Mi.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}=ee(),x;t[0]===n?x=t[1]:(x=xo(yo(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=X(`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)(Z,{name:`arrow-down-s`,className:X(`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=X(`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=X(`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=X(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),I=g?dt(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 V;t[56]!==F||t[57]!==I?(V=(0,$.jsx)(`span`,{className:F,children:I}),t[56]=F,t[57]=I,t[58]=V):V=t[58];let H;t[59]===S?H=t[60]:(H=S?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:S}):null,t[59]=S,t[60]=H);let te;t[61]!==V||t[62]!==H||t[63]!==L||t[64]!==R?(te=(0,$.jsxs)(`span`,{className:L,children:[R,V,H]}),t[61]=V,t[62]=H,t[63]=L,t[64]=R,t[65]=te):te=t[65];let ne;t[66]!==a||t[67]!==g?(ne=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?dt(a,g):a}):null,t[66]=a,t[67]=g,t[68]=ne):ne=t[68];let U;t[69]!==te||t[70]!==ne||t[71]!==z?(U=(0,$.jsxs)(`span`,{className:z,children:[te,ne]}),t[69]=te,t[70]=ne,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 re;t[85]!==p||t[86]!==m?(re=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)(Pr,{})}):null,t[85]=p,t[86]=m,t[87]=re):re=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)(Z,{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)(Z,{name:`close`,className:`size-4`}):(0,$.jsx)(Z,{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 G;return t[94]!==N||t[95]!==P||t[96]!==W||t[97]!==re||t[98]!==ie?(G=(0,$.jsxs)(`div`,{className:N,children:[P,W,re,ie]}),t[94]=N,t[95]=P,t[96]=W,t[97]=re,t[98]=ie,t[99]=G):G=t[99],G},No=e=>{let t=(0,Mi.c)(15),{indent:n,showMore:r,showFewer:i,loadingMore:a,onShowMore:o,onShowFewer:s}=e,c=a!==void 0&&a,{t:l}=ee();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)(Z,{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:X(`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)(Z,{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},Po=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=ee(),{git:i}=hn(),a=se(),o=ke(e=>e.activeSessions),s=ke(e=>e.activePaginationByDirectory),c=Me(e=>e.projects),l=Me(e=>e.activeProjectId),u=T(e=>e.currentDirectory),d=J(e=>e.currentSessionId),f=J(e=>e.availableWorktreesByProject),p=J(e=>e.setCurrentSession),m=J(e=>e.archiveSession),h=J(e=>e.archiveSessions),g=J(e=>e.updateSessionTitle),_=J(e=>e.requestSessionSmartTitle),v=J(e=>e.shareSession),y=J(e=>e.unshareSession),b=J(e=>e.openNewSessionDraft),x=Me(e=>e.setActiveProject),S=Me(e=>e.setActiveProjectIdOnly),C=Me(e=>e.removeProject),w=Ae(),E=Re(),D=fo(e=>e.projectExpanded),O=fo(e=>e.worktreeExpanded),k=fo(e=>e.setProjectExpanded),A=fo(e=>e.setWorktreeExpanded),j=Et(e=>e.orderByProject),M=uo(e=>e.expandedParents),N=uo(e=>e.toggleParent),[P,F]=Q.useState(``),[I,L]=Q.useState(null),[z,V]=Q.useState(null),[H,te]=Q.useState(0),[ne,U]=Q.useState(!1),[W,re]=Q.useState(!1),[ie,G]=Q.useState(null),[K,ae]=Q.useState(null),[oe,ce]=Q.useState(null),[le,ue]=Q.useState(null),[de,fe]=Q.useState(null),[pe,he]=Q.useState(``),[ge,_e]=Q.useState(!1),[ve,ye]=Q.useState(null),xe=Q.useRef(null);xe.current||=Vn({onPressedKeyChange:ue});let[Se,Ce]=Q.useState(new Set),[we,Ee]=Q.useState(new Map),[De,Oe]=Q.useState(new Map),je=mr(),Ne=Sr(),Pe=R(e=>{me(e),q(e)}),Ie=R(e=>{Promise.all(e.map(e=>(me(e),q(e))))});Q.useEffect(()=>{if(!e){F(``),Oe(new Map),L(null),V(null),ae(null),fe(null),ye(null),xe.current?.reset();return}},[e]),Q.useEffect(()=>()=>{xe.current?.reset()},[]),Q.useEffect(()=>{if(!e)return;if(c.length===0){J.setState(e=>{let t=pr(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),Ce(e=>e.size===0?e:new Set),Ee(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(c.map(async e=>{let n=go(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([Jt({id:e.id,path:n},{isCurrent:()=>!t}),Wt(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(c.map(e=>go(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);J.setState(e=>{let t=pr(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),Ce(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 bo(r,t)?t:r}),Ee(t=>{let n=new Set(c.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,c,H]);let Le=Q.useMemo(()=>c.map(e=>({id:e.id,label:vo(e.path),path:go(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:Se.has(go(e.path)),worktrees:wt(j[e.id],f.get(go(e.path))??[])})),[Se,c,j,f]),ze=Q.useMemo(()=>{let e=new Map(a.map(e=>[e.id,e])),t=o.map(t=>{let n=e.get(t.id);return n?Te(n,t):t}),n=new Set(t.map(e=>e.id));for(let e of a)n.has(e.id)||t.push(e);return t},[o,a]),Be=P.trim().toLowerCase(),Ve=Q.useMemo(()=>{let e=Le.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===l})),t=(e,t,n)=>{let r=go(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||vo(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 ze){let r=_o(n);if(!r)continue;let i=go(r),a=e.find(e=>wo(e.project,i));if(!a)continue;let o=Co(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)=>be(t)-be(e));for(let n of e.sessions)ho(n)||(t.totalSessions+=1)}return e},[l,Le,ze]),Ue=go(u),We=e=>e.isActive?Ue===e.project.path?e.project.path:e.project.worktrees.find(e=>So(Ue,e.path))?.path??e.project.path:null,Ge=e=>D[e.project.id]??!0,Ke=(e,t)=>O[`${e.project.id}::${t.key}`]??!1,qe=e=>{Oe(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},Je=()=>{ae(null),xe.current?.reset()},Ye=e=>({pressed:le===e.key||K?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||xe.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>ae(e)})},onPointerMove:e=>{xe.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{xe.current?.end(e.pointerId)},onPointerCancel:e=>{xe.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),xe.current?.openFromContextMenu(e.key,()=>ae(e))}}),Xe=(e,t)=>{xe.current?.consumeClick(e)||t()},Ze=(e,t,n,r)=>{let i=Yr(),a=br();if(Oe(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=go(t);if(!o)return;let s=ke.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&Fe(o)},Qe=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=Yr(),o=new Set(t.sessions.map(e=>e.id)),c=new Map;for(let e of t.sessions){let t=ho(e);if(t&&o.has(t)){let n=c.get(t)??[];n.push(e),c.set(t,n)}}let l=t.sessions.filter(e=>!ho(e)),u=De.get(i)??a,f=_r(l,u,Ne),p=l.length-f.length,m=s.get(go(t.path)),h=m?.hasMore===!0,g=m?.loadingMore===!0,_=l.length>a&&u>a,v=(e,t)=>{let n=c.get(e.id)??[],i=n.length>0,a=!!M[e.id],o=je.has(e.id),s=i&&!a?n.filter(e=>je.has(e.id)).map(e=>e.id):[],l=s.length>0,u=o?[e.id,...s]:s,f=e.title?.trim()||r(`mobile.sessions.untitled`),p=`session:${e.id}`;return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(Mo,{session:e,active:d===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>N(e.id):void 0,confirmingArchive:z===e.id,onSelect:()=>Xe(p,()=>nt(e)),onRequestArchive:()=>rt(e.id),onConfirmArchive:()=>void it(e),onStop:o||l?()=>Ie(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:f}),longPressHandlers:Ye({key:p,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+mo)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[f.map(e=>v(e,n)),(0,$.jsx)(No,{indent:n,showMore:p>0||h,showFewer:_,loadingMore:g,onShowMore:()=>Ze(i,t.path,u,l.length),onShowFewer:()=>qe(i)})]})},et=(e,t)=>{k(e,!t)},tt=(e,t,n)=>{A(`${e}::${t}`,!n)},nt=e=>{Ht();let n=_o(e)||null,r=To(Le,n??``);r&&S(r.id),p(e.id,n),t(!1)},rt=e=>{V(t=>t===e?null:e)},it=async e=>{V(null),await m(e.id)?ur({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`))},at=()=>{b(),t(!1)},ot=e=>{G(e),S(e),re(!0)},st=e=>{let t=new Map;for(let e of ze){let n=ho(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},ct=async e=>{let t=st(e.id),{archivedIds:n,failedIds:i}=await h(t);n.length>0&&ur({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}))},lt=e=>{let t=st(e.id);Fr({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`)})},ut=async e=>{try{if(!(await v(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`))}},ft=async e=>{if((await B(e)).ok){Y.success(r(`sessions.sidebar.session.menu.copied`));return}Y.error(r(`sessions.sidebar.session.share.copyUrlError`))},pt=async e=>{try{if(await y(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`))}},mt=async()=>{if(!de)return;let e=pe.trim();if(e)try{await g(de.id,e),fe(null),he(``)}catch{Y.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},gt=async()=>{if(!de||ge)return;let e=de.id;fe(null),he(``),_e(!0);try{await _(e)}catch{Y.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{_e(!1)}},_t=(e,n)=>{S(e.id),b({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},vt=e=>{(async()=>{try{await Jt({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=J.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await He(n,ze)})()},yt=e=>{let t=_o(e),n=To(Le,t);if(!n)return vo(t)||t;let r=Co(n,go(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},bt=e=>{x(e.id),t(!1)},St=Q.useMemo(()=>Be?Ve.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Be)?!0:e.buckets.some(t=>t.sessions.some(t=>Eo(t,e.project.label,Be)))):Ve,[Be,Ve]),Ct=Q.useMemo(()=>Be?ze.filter(e=>{let t=_o(e);return Eo(e,To(Le,t)?.label??``,Be)}).sort((e,t)=>be(t)-be(e)):[],[Be,Le,ze]),Tt=Q.useMemo(()=>Be?Le.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Be)).map(e=>({...e,sessionCount:ze.filter(t=>!ho(t)&&wo(e,go(_o(t)))).length})):[],[Be,Le,ze]),Dt=Be&&Ct.length===0&&Tt.length===0,Ot=Le.length>0?(0,$.jsxs)($e,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:at,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Z,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,kt=Le.find(e=>e.id===l)??null,At=kt?.isGitRepo?(0,$.jsx)($e,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>ot(kt.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`node-tree`,className:`size-4`})}):null,jt=(0,$.jsx)($e,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>U(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`})}),Mt=Ot||jt?(0,$.jsxs)($.Fragment,{children:[Ot,At,jt]}):null,Nt=K?.kind===`project`?K.project.label:K?.kind===`worktree`?K.worktree.branch||K.worktree.label||K.worktree.path:K?.kind===`session`?K.session.title?.trim()||r(`mobile.sessions.untitled`):``,Pt=Q.useMemo(()=>{if(!K)return[];if(K.kind===`project`){let e=K.project;return Or({gitRepository:e.isGitRepo,onNewSession:()=>{Je(),_t(e,e.path)},onNewWorktree:()=>{Je(),ot(e.id)},onSyncSessions:()=>{Je(),vt(e)},onEditProject:()=>{Je(),L(e.id)},onCloseProject:()=>{Je(),ce(e)}})}if(K.kind===`worktree`){let{project:e,worktree:t}=K;return yr({onNewSession:()=>{Je(),_t(e,t.path)},onDeleteWorktree:()=>{Je(),ye({project:e,worktree:t})}})}let e=K.session,t=!!e.share?.url;return Xr({pinned:w.has(e.id),shared:t,onRename:()=>{Je(),he(e.title?.trim()||r(`mobile.sessions.untitled`)),fe(e)},onTogglePin:()=>{Je(),E(e.id)},onShare:t?void 0:()=>{Je(),ut(e)},onCopyLink:t?()=>{let t=e.share?.url;Je(),t&&ft(t)}:void 0,onUnshare:t?()=>{Je(),pt(e.id)}:void 0,onArchive:()=>{Je(),ct(e)},onDelete:()=>{Je(),lt(e)}})},[K,Je,ct,ft,lt,ot,ut,pt,w,_t,vt,r,E]),Ft=Pt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Pt.map(e=>{let t=(0,$.jsx)(jo,{icon:e.icon,label:dr(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,It=(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)(Z,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Xt,{value:P,onChange:e=>F(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:X(`h-11 pl-9`,P&&`pr-10`)}),P?(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:()=>F(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsx)(Pn,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:Le.length===0?(0,$.jsx)(Fo,{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:()=>U(!0),children:[(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):Dt?(0,$.jsx)(Fo,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Be?(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=je.has(e.id),i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:X(t>0&&`border-t border-border/30`),children:(0,$.jsx)(Mo,{session:e,active:d===e.id,indent:12,contextLabel:yt(e),highlightQuery:Be,onSelect:()=>Xe(`session:${e.id}`,()=>nt(e)),longPressHandlers:Ye({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>Pe(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,Tt.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:Tt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Tt.map((e,t)=>{let n=`project:${e.id}`,r=Ye({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:X(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:X(`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:()=>Xe(n,()=>bt(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Do,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:dt(e.label,Be)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(Ao,{className:`mr-2`,onClick:()=>ot(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:St.map((e,t)=>{let n=Ge(e),i=`project:${e.project.id}`,a=Ye({key:i,kind:`project`,project:e.project}),o=Be?e.buckets.filter(t=>t.sessions.some(t=>Eo(t,e.project.label,Be))):e.buckets,s=We(e);return(0,$.jsxs)(`section`,{className:X(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:X(`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:()=>Xe(i,()=>et(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)(Do,{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}),we.get(e.project.id)?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:we.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(ko,{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=>je.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(),Ie(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Pr,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(Ao,{className:`mr-2`,onClick:()=>ot(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?Qe(e,t,po):null,n.map(t=>{let n=Ke(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Ye({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:X(`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:()=>Xe(a,()=>tt(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)(Oo,{expanded:n}),(0,$.jsx)(Z,{name:`node-tree`,className:X(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:X(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(ko,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>je.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(),Ie(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Pr,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?Qe(e,t,po):null]},t.key)})]})})()}):null]},e.project.id)})})}),(0,$.jsx)(Lr,{open:ne,onOpenChange:U,forceMobile:!0}),(0,$.jsx)(ht,{open:W,projectId:ie,onOpenChange:e=>{re(e),e||G(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?p(n.sessionId,e):b({selectedProjectId:ie,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(xt,{open:!!K,title:Nt,onClose:Je,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Ft}),(0,$.jsx)(xt,{open:!!oe,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>ce(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)($e,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>ce(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)($e,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!oe)return;let e=oe;ce(null),C(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:oe?.label??``})})}),(0,$.jsx)(xt,{open:!!de,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{ge||(fe(null),he(``))},footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)($e,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:ge,onClick:()=>{fe(null),he(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)($e,{type:`button`,variant:`default`,className:`flex-1`,disabled:!pe.trim()||ge,onClick:()=>void mt(),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(),mt()},children:[(0,$.jsx)(Xt,{value:pe,onChange:e=>he(e.target.value),autoFocus:!0,className:`h-12`,disabled:ge}),(0,$.jsxs)($e,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:ge,onClick:()=>void gt(),children:[ge?(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-4`}),r(`sessions.sidebar.session.rename.smartTitle`)]})]})}),ve?(0,$.jsx)(vr,{open:!0,project:{id:ve.project.id,path:ve.project.path},worktree:ve.worktree,onClose:()=>ye(null),onDeleted:()=>te(e=>e+1)}):null,(0,$.jsx)(fr,{open:I!==null,project:Le.find(e=>e.id===I)??null,onClose:()=>L(null),onWorktreesChanged:()=>te(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:Mt?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:Mt}):null}),It]}):null:(0,$.jsx)(Kt,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:Mt,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:It})},Fo=e=>{let t=(0,Mi.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},Io=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,Lo=[{image:ii,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:$r,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 Ro(){let e=(0,Mi.c)(8),{t}=ee(),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 zo(e){let t=(0,Mi.c)(35),{onEnable:n}=e,{t:r}=ee(),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:Io,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)($e,{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=Lo.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 Bo({assistantID:e,displayName:t,avatarEmoji:n,summary:r,enabled:i,editLabel:a,deleteLabel:o,onOpen:s,onEdit:c,onDelete:l}){let u=si(e),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),h=Q.useRef(null);h.current||=Vn({onPressedKeyChange:t=>m(t===e)}),Q.useEffect(()=>()=>h.current?.reset(),[]);let g=R(()=>{h.current?.consumeClick(e)||d||s()}),_=R(()=>{f(!1),c()}),v=R(()=>{f(!1),l()}),y=R(()=>{m(!1),f(!0)}),b=R(t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||h.current?.start({pointerId:t.pointerId,key:e,clientX:t.clientX,clientY:t.clientY,onTrigger:y})}),x=R(e=>{h.current?.move(e.pointerId,e.clientX,e.clientY)}),S=R(e=>{h.current?.end(e.pointerId)}),C=R(e=>{h.current?.cancel(e.pointerId)}),w=R(t=>{t.preventDefault(),t.stopPropagation(),h.current?.openFromContextMenu(e,y)});return(0,$.jsxs)(mi,{open:d,onOpenChange:f,children:[(0,$.jsx)(nr,{"data-mobile-press-surface":`soft`,className:X(`oc-mobile-assistant-card-shell`,p&&`bg-interactive-hover`),children:(0,$.jsxs)(ui,{render:(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-surface-trigger":!0,className:X(`oc-mobile-assistant-card`,!i&&`opacity-65`),onClick:g,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:C,onContextMenu:w,style:{touchAction:`pan-y`}}),children:[(0,$.jsx)(`span`,{className:X(`oc-mobile-assistant-avatar`,n?`oc-mobile-assistant-avatar--emoji`:`oc-mobile-assistant-avatar--visual`),children:(0,$.jsx)(oi,{name:e,emoji:n,size:40,label:t,working:u})}),(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:t}),(0,$.jsx)(`span`,{className:`oc-mobile-assistant-summary text-muted-foreground`,children:r})]})]})}),(0,$.jsxs)(fi,{className:`min-w-[10rem]`,children:[(0,$.jsxs)(pi,{className:`min-h-10 px-3`,onClick:_,children:[(0,$.jsx)(Z,{name:`edit`,className:`size-4`}),a]}),(0,$.jsx)(di,{}),(0,$.jsxs)(pi,{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:v,children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`size-4`}),o]})]})]})}function Vo(e){let t=(0,Mi.c)(102),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=ee(),o=Un(),s=qe(),c=Je(),l=Xe(Ho),[u,d]=Q.useState(null),f;t[0]===n?f=t[1]:(f=()=>n(),t[0]=n,t[1]=f);let p=R(f),m;t[2]!==o||t[3]!==l?(m=()=>{l(),o?.openSettings(`assistants`)},t[2]=o,t[3]=l,t[4]=m):m=t[4];let h=R(m),g;t[5]===r?g=t[6]:(g=e=>r(e),t[5]=r,t[6]=g);let _=R(g),v;t[7]===o?v=t[8]:(v=e=>{Qe(e,o?{openMobileSettings:o.openSettings}:void 0)},t[7]=o,t[8]=v);let y=R(v),b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{d(e)},t[9]=b):b=t[9];let x=R(b),S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{e||d(null)},t[10]=S):S=t[10];let C=R(S),w;t[11]===a?w=t[12]:(w=a(`assistants.title`),t[11]=a,t[12]=w);let T=w,E;t[13]===a?E=t[14]:(E=a(`assistants.menu.edit`),t[13]=a,t[14]=E);let D=E,O;t[15]===a?O=t[16]:(O=a(`assistants.settings.delete`),t[15]=a,t[16]=O);let k=O;if(s.isPending||s.data?.supported&&s.data.enabled&&c.isPending){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(nr,{className:`oc-mobile-assistant-loading`,children:(0,$.jsx)(Ro,{})}),t[17]=e):e=t[17];let n;return t[18]!==i||t[19]!==T?(n=(0,$.jsx)(tr,{title:T,className:i,surface:!1,children:e}),t[18]=i,t[19]=T,t[20]=n):n=t[20],n}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length>0){let e;t[21]===a?e=t[22]:(e=a(`assistants.listAria`),t[21]=a,t[22]=e);let n;if(t[23]!==k||t[24]!==D||t[25]!==y||t[26]!==_||t[27]!==x||t[28]!==c.data.assistants){let e;t[30]!==k||t[31]!==D||t[32]!==y||t[33]!==_||t[34]!==x?(e=e=>{let t=te(e.name),n=t.displayName||e.name,r=e.defaultPrompt.trim();return(0,$.jsx)(Bo,{assistantID:e.id,displayName:n,avatarEmoji:t.avatarEmoji??void 0,summary:r,enabled:e.enabled,editLabel:D,deleteLabel:k,assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onOpen:()=>_(e.id),onEdit:()=>y(e.id),onDelete:()=>x(e)},e.id)},t[30]=k,t[31]=D,t[32]=y,t[33]=_,t[34]=x,t[35]=e):e=t[35],n=c.data.assistants.map(e),t[23]=k,t[24]=D,t[25]=y,t[26]=_,t[27]=x,t[28]=c.data.assistants,t[29]=n}else n=t[29];let r;t[36]!==e||t[37]!==n?(r=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-catalog`,role:`listbox`,"aria-label":e,children:n}),t[36]=e,t[37]=n,t[38]=r):r=t[38];let o=u!==null,s;t[39]!==u||t[40]!==C||t[41]!==o?(s=(0,$.jsx)(ci,{assistant:u,open:o,onOpenChange:C}),t[39]=u,t[40]=C,t[41]=o,t[42]=s):s=t[42];let l;return t[43]!==i||t[44]!==T||t[45]!==r||t[46]!==s?(l=(0,$.jsxs)(tr,{title:T,className:i,surface:!1,scrollsWithPage:!0,children:[r,s]}),t[43]=i,t[44]=T,t[45]=r,t[46]=s,t[47]=l):l=t[47],l}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`oc-mobile-assistant-onboarding-icon`,children:(0,$.jsx)(Z,{name:`ai-agent`,className:`size-5`})}),t[48]=e):e=t[48];let n;t[49]===a?n=t[50]:(n=a(`assistants.onboarding.title`),t[49]=a,t[50]=n);let r;t[51]===n?r=t[52]:(r=(0,$.jsx)(`h2`,{children:n}),t[51]=n,t[52]=r);let o;t[53]===a?o=t[54]:(o=a(`assistants.onboarding.description`),t[53]=a,t[54]=o);let s;t[55]===o?s=t[56]:(s=(0,$.jsx)(`p`,{children:o}),t[55]=o,t[56]=s);let c;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Z,{name:`add`,className:`size-[18px]`}),t[57]=c):c=t[57];let l;t[58]===a?l=t[59]:(l=a(`assistants.onboarding.action`),t[58]=a,t[59]=l);let u;t[60]!==h||t[61]!==l?(u=(0,$.jsxs)($e,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:h,children:[c,l]}),t[60]=h,t[61]=l,t[62]=u):u=t[62];let d;t[63]!==r||t[64]!==s||t[65]!==u?(d=(0,$.jsxs)(nr,{className:`oc-mobile-assistant-onboarding`,children:[e,r,s,u]}),t[63]=r,t[64]=s,t[65]=u,t[66]=d):d=t[66];let f;return t[67]!==i||t[68]!==T||t[69]!==d?(f=(0,$.jsx)(tr,{title:T,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:d}),t[67]=i,t[68]=T,t[69]=d,t[70]=f):f=t[70],f}let A=s.isSuccess&&s.data.supported===!1,j=s.isError||s.data?.supported===!0&&s.data.enabled&&c.isError,M=s.data?.supported===!0&&(s.data.enabled===!1||c.data?.enabled===!1),N;t[71]!==a||t[72]!==j||t[73]!==A?(N=a(j?`assistants.state.unavailable`:A?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[71]=a,t[72]=j,t[73]=A,t[74]=N):N=t[74];let P=N;if(M&&!j){let e;t[75]===p?e=t[76]:(e=(0,$.jsx)(zo,{onEnable:p}),t[75]=p,t[76]=e);let n;return t[77]!==i||t[78]!==T||t[79]!==e?(n=(0,$.jsx)(tr,{title:T,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-guide-host`,children:e}),t[77]=i,t[78]=T,t[79]=e,t[80]=n):n=t[80],n}let F;t[81]===T?F=t[82]:(F=(0,$.jsx)(`span`,{className:`oc-mobile-page-section-label`,children:T}),t[81]=T,t[82]=F);let I=A?`cloud-off`:`sparkling`,L;t[83]===I?L=t[84]:(L=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground`,children:(0,$.jsx)(Z,{name:I,weight:`medium`,className:`size-5`})}),t[83]=I,t[84]=L);let z;t[85]===P?z=t[86]:(z=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:P}),t[85]=P,t[86]=z);let B;t[87]!==a||t[88]!==j||t[89]!==A?(B=j?null:(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-small leading-relaxed text-muted-foreground`,children:a(A?`assistants.state.unsupportedDescription`:`assistants.state.instanceDisabledDescription`)}),t[87]=a,t[88]=j,t[89]=A,t[90]=B):B=t[90];let V;t[91]!==L||t[92]!==z||t[93]!==B?(V=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[L,z,B]}),t[91]=L,t[92]=z,t[93]=B,t[94]=V):V=t[94];let H;t[95]!==F||t[96]!==V?(H=(0,$.jsx)(ar,{label:F,cardClassName:`oc-mobile-assistant-state-card`,children:V}),t[95]=F,t[96]=V,t[97]=H):H=t[97];let ne;return t[98]!==i||t[99]!==T||t[100]!==H?(ne=(0,$.jsx)(tr,{title:T,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:H}),t[98]=i,t[99]=T,t[100]=H,t[101]=ne):ne=t[101],ne}function Ho(e){return e.requestCreate}var Uo=[{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 Wo(e){let t=(0,Mi.c)(17),{activeTab:n,onTabChange:r,className:i}=e,{t:a}=ee(),o;t[0]===r?o=t[1]:(o=e=>{r(e.currentTarget.dataset.tab)},t[0]=r,t[1]=o);let s=R(o),c;t[2]!==n||t[3]!==r?(c=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Uo.findIndex(e=>e.id===n),i=Uo[e.key===`Home`?0:e.key===`End`?Uo.length-1:(t+(e.key===`ArrowRight`?1:-1)+Uo.length)%Uo.length];r(i.id),document.getElementById(`mobile-tab-${i.id}`)?.focus()},t[2]=n,t[3]=r,t[4]=c):c=t[4];let l=R(c),u;t[5]===a?u=t[6]:(u=a(`mobile.nav.aria`),t[5]=a,t[6]=u);let d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d={role:`tablist`},t[7]=d):d=t[7];let f;t[8]!==n||t[9]!==s||t[10]!==l||t[11]!==a?(f=Uo.map(e=>{let t=e.id===n,r=a(e.labelKey);return(0,$.jsxs)($e,{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-selected":t,tabIndex:t?0:-1,title:r,onClick:s,onKeyDown:l,className:X(`oc-mobile-tab-button min-w-0 flex-1 flex-col overflow-hidden`,`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,$.jsx)(Z,{name:e.icon,weight:`medium`,className:`size-[23px] shrink-0`}),(0,$.jsx)(`span`,{className:`block max-w-full overflow-hidden text-ellipsis whitespace-nowrap`,children:r})]},e.id)}),t[8]=n,t[9]=s,t[10]=l,t[11]=a,t[12]=f):f=t[12];let p;return t[13]!==i||t[14]!==u||t[15]!==f?(p=(0,$.jsx)(or,{as:`nav`,"aria-label":u,variant:`navigation`,surfaceProps:d,className:i,children:f}),t[13]=i,t[14]=u,t[15]=f,t[16]=p):p=t[16],p}var Go=`oc-native-ios-tab-bar`,Ko=`OpenChamberTabBar`,qo=[`projects`,`assistant`,`scheduled`,`settings`],Jo=A(Ko),Yo=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function Xo(){return typeof window>`u`?!1:Yo({isCapacitor:D(),platform:k(),pluginAvailable:j.isPluginAvailable(Ko),nativeUiEnabled:En()})}var Zo=e=>e.classList.contains(`dark`)?`dark`:`light`,Qo=()=>xn(`--primary`),$o=e=>typeof e==`string`&&qo.includes(e),es=e=>typeof e==`string`&&$o(e)?e:null,ts=(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),ns=(e,t)=>{e.classList.toggle(Go,t)},rs=(e,t)=>e&&!t,is=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&ts(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},as=()=>Jo,os=`mobile-overlay-root`;function ss(e){let t=(0,Mi.c)(28),n=Sn(),r;t[0]===n?r=t[1]:(r=n&&Xo(),t[0]=n,t[1]=r);let i=r,[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=(0,Q.useRef)(!1),p=(0,Q.useRef)(!1),m=R(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=e.tabs.map(ls).join(`|`),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:Zo(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:Qo(),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(os);e||(e=document.createElement(`div`),e.id=os,document.body.appendChild(e));let t=()=>u(bt(e.children));t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[Dt]}),()=>n.disconnect()},S=[i],t[6]=i,t[7]=x,t[8]=S),(0,Q.useEffect)(x,S);let C;t[9]!==i||t[10]!==m?(C=()=>{if(!i)return;let e=!1,t=as(),n=[];return t.addListener(`tabSelected`,e=>{let t=es(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`&&ns(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,Q.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=as(),r={tabs:e.tabs.map(cs),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=is({visible:rs(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`&&ns(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&ns(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&ns(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,Q.useLayoutEffect)(T,E),!i||s?`web`:a?`native`:`pending`}function cs(e){return{id:e.id,label:e.label}}function ls(e){return`${e.id}:${e.label}`}function us(e){let t=(0,Mi.c)(39),{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}=ee(),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]=Q.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=Q.useRef(null),C=Q.useRef(null),w=Q.useRef(null),T=Q.useRef(new Map),E=Q.useRef(null),D=Q.useRef(!1),O=Q.useRef(``),k=R(()=>h?.onBack());Tn({id:h?`mobile-secondary:${h.key}`:`mobile-secondary:inactive`,active:!!h,onBack:k,surfaceRef:S,underlayRef:C}),Q.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),Q.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=R(j),N;t[6]===f?N=t[7]:(N=Uo.map(e=>({id:e.id,label:f(e.labelKey)})),t[6]=f,t[7]=N);let P=N,F=u&&!d&&!h,I;t[8]===f?I=t[9]:(I=f(`mobile.nav.aria`),t[8]=f,t[9]=I);let L;t[10]!==M||t[11]!==F||t[12]!==P||t[13]!==p||t[14]!==I?(L={visible:F,activeTab:p,tabs:P,ariaLabel:I,onTabChange:M},t[10]=M,t[11]=F,t[12]=P,t[13]=p,t[14]=I,t[15]=L):L=t[15];let z=ss(L),B=z===`native`,V=u&&z===`web`,H=Sn(),te,ne;t[16]!==H||t[17]!==B?(te=()=>{if(!H){kn.shutdown();return}B&&Dn(!0)&&kn.warm()},ne=[H,B],t[16]=H,t[17]=B,t[18]=te,t[19]=ne):(te=t[18],ne=t[19]),Q.useEffect(te,ne);let U;t[20]===c?U=t[21]:(U=X(`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[20]=c,t[21]=U);let W=h?!0:void 0,re=h?!0:void 0,ie;t[22]!==p||t[23]!==u||t[24]!==V||t[25]!==f||t[26]!==n||t[27]!==b?(ie=Uo.map(e=>{let t=b.has(e.id);return(0,$.jsx)(`section`,{id:`mobile-tabpanel-${e.id}`,role:`tabpanel`,"aria-labelledby":V?`mobile-tab-${e.id}`:void 0,"aria-label":V?void 0:f(e.labelKey),hidden:p!==e.id,tabIndex:0,className:X(`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)(ds,{tab:e.id,icon:e.icon}):null},e.id)}),t[22]=p,t[23]=u,t[24]=V,t[25]=f,t[26]=n,t[27]=b,t[28]=ie):ie=t[28];let G;t[29]!==w||t[30]!==W||t[31]!==re||t[32]!==ie?(G=(0,$.jsx)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":W,inert:re,className:`flex h-full min-h-0 flex-1 flex-col`,children:ie}),t[29]=w,t[30]=W,t[31]=re,t[32]=ie,t[33]=G):G=t[33];let K=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||B?!0:void 0,inert:h||B?!0:void 0,children:V?(0,$.jsx)(Wo,{activeTab:p,onTabChange:M}):null}):null,ae=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:X(`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)}),oe;return t[34]!==U||t[35]!==G||t[36]!==K||t[37]!==ae?(oe=(0,$.jsxs)(`div`,{className:U,children:[G,K,ae]}),t[34]=U,t[35]=G,t[36]=K,t[37]=ae,t[38]=oe):oe=t[38],oe}function ds(e){let t=(0,Mi.c)(17),{tab:n,icon:r,className:i}=e,{t:a}=ee(),o,s,c,l;if(t[0]!==i||t[1]!==r||t[2]!==a||t[3]!==n){let e=Uo.find(e=>e.id===n)??Uo[0];t[8]===i?c=t[9]:(c=X(`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)(Z,{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 fs={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)`}},ps=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 ms({project:e,expanded:t,embedded:n=!1,onToggle:r,onOpenActions:i,className:a,highlightQuery:o}){let{t:s}=ee(),[c,l]=Q.useState(!1),u=Q.useRef(null);u.current||=Vn({onPressedKeyChange:t=>l(t===e.id)}),Q.useEffect(()=>()=>u.current?.reset(),[]);let d=R(()=>{u.current?.consumeClick(e.id)||r(e)}),f=R(()=>i?.(e)),p=R(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=R(e=>{u.current?.move(e.pointerId,e.clientX,e.clientY)}),h=R(e=>{u.current?.end(e.pointerId)}),g=R(e=>{u.current?.cancel(e.pointerId)}),_=R(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=ps(e.path),b=(0,$.jsxs)(`article`,{"data-mobile-press-surface":`soft`,"data-pressed":c?`true`:void 0,className:X(`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:X(`oc-mobile-project-icon oc-mobile-glass-control flex shrink-0 items-center justify-center rounded-full text-muted-foreground`),style:fs[e.tone??`neutral`],"aria-hidden":!0,children:(0,$.jsx)(Z,{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?dt(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)(Z,{name:`arrow-down-s`,className:X(`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)($e,{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)(Z,{name:`more-2`,className:`size-4`})}):null]});return n?b:(0,$.jsx)(nr,{asChild:!0,children:b})}var hs=({hasPendingQuestion:e,hasPendingPermission:t,running:n,unread:r})=>e?`question`:t?`permission`:n?`running`:r?`completed-unread`:`idle`,gs=10,_s=`oc:mobile-session-row-revealed`,vs=e=>{window.dispatchEvent(new CustomEvent(_s,{detail:e}))};function ys({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}=ee(),[m,h]=Q.useState(0),[g,_]=Q.useState(!1),v=Q.useRef(null),y=Q.useRef(!1),b=Q.useRef(null),x=Q.useRef(null);x.current||=Vn(),Q.useEffect(()=>()=>x.current?.reset(),[]),Q.useEffect(()=>{let t=t=>{t.detail!==e.id&&h(0)};return window.addEventListener(_s,t),()=>window.removeEventListener(_s,t)},[e.id]),Q.useEffect(()=>{h(0)},[e.id]);let S=R(()=>h(0)),C=m!==0,w=R(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=R(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>gs&&o>a){n.intent=`vertical`,v.current=null,x.current?.cancel(t.pointerId);return}if(a>gs&&a>o){n.intent=`horizontal`,_(!0),y.current=!0,x.current?.cancel(t.pointerId);try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}vs(e.id)}}if(n.intent!==`horizontal`)return;t.preventDefault();let a=Math.max(-n.actionWidth,Math.min(0,n.startOffset+r));h(a)}),E=R(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=R(e=>{let t=v.current;v.current=null,x.current?.cancel(e.pointerId),_(!1),h(t?.startOffset??0)}),O=R(()=>{if(!x.current?.consumeClick(e.id)){if(y.current){y.current=!1;return}if(m!==0){S();return}vs(e.id),o(e)}}),k=R(t=>{t.preventDefault(),t.stopPropagation(),x.current?.openFromContextMenu(e.id,()=>{l(e)})}),A=R(()=>{S(),s(e)}),j=R(()=>{S(),c(e)}),M=R(()=>l(e)),N=R(()=>a?.()),P=e.pinned?p(`sessions.sidebar.session.menu.unpin`):p(`sessions.sidebar.session.menu.pin`),F=u??hs({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:X(`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)(Z,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`})]})}):(0,$.jsxs)(`div`,{className:X(`oc-mobile-session-row relative isolate`,d),children:[(0,$.jsxs)(`div`,{ref:b,className:X(`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)($e,{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)(Z,{name:e.pinned?`unpin`:`pushpin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:P})]}),(0,$.jsxs)($e,{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)(Z,{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:X(`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)($e,{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)(Z,{name:`arrow-down-s`,className:X(`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)(Pr,{className:`motion-reduce:[&_svg]:animate-none`}):F===`question`?(0,$.jsx)(Z,{name:`question`,className:`size-3.5 text-[var(--status-warning)]`}):F===`permission`?(0,$.jsx)(Z,{name:`shield`,className:`size-3.5 text-destructive`}):(0,$.jsx)(`span`,{className:X(`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:X(`oc-mobile-session-title truncate`,e.unread?`font-semibold`:`font-medium`),children:f?dt(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)(Z,{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?dt(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)($e,{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)(Z,{name:`more-2`,className:`size-3.5`})})]})]})}var bs=Q.memo(ys),xs=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e)),Ss=e=>e.catalogSessions??e.sessions,Cs=(e,t)=>e.filter(e=>e.kind!==`pagination`&&xs(t,e.title,e.subtitle,e.id)),ws=(e,t)=>{let n=Ss(e);if(xs(t,e.name,e.path))return{...e,sessions:n.filter(e=>e.kind!==`pagination`)};let r=Cs(n,t);return r.length>0?{...e,sessions:r}:null},Ts=(e,t)=>{let n=t.trim().toLowerCase();return n?e.flatMap(e=>{if(xs(n,e.name,e.path))return[{...e,worktrees:[]}];let t=e.worktrees.flatMap(e=>{let t=ws(e,n);return t?[t]:[]});return t.length>0?[{...e,worktrees:t}]:[]}):e},Es=10,Ds=`oc:mobile-worktree-row-revealed`,Os=e=>{window.dispatchEvent(new CustomEvent(Ds,{detail:e}))};function ks(e){let t=(0,Mi.c)(10),n=ue(e.session.id),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={bootstrap:!1},t[0]=r):r=t[0];let i=Be(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=De(e.session.id,e.session.directory,a).length>0,s=i.length>0,c=n?.type===`busy`||n?.type===`retry`,l=!!e.session.unread,u;t[2]!==o||t[3]!==s||t[4]!==c||t[5]!==l?(u=hs({hasPendingQuestion:o,hasPendingPermission:s,running:c,unread:l}),t[2]=o,t[3]=s,t[4]=c,t[5]=l,t[6]=u):u=t[6];let d=u,f;return t[7]!==d||t[8]!==e?(f=(0,$.jsx)(bs,{...e,indicator:d}),t[7]=d,t[8]=e,t[9]=f):f=t[9],f}var As=Q.memo(ks);function js(e){let t=(0,Mi.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`?bs:As;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 Ms=Q.memo(js);function Ns({project:e,worktree:t,expanded:n,onToggle:r,onNewSession:i,onOpenActions:a,onDelete:o,highlightQuery:s}){let{t:c}=ee(),l=`${e.id}::${t.id}`,u=!!(i||o),d=!!a,f=Number(!!i)+Number(!!o),[p,m]=Q.useState(0),[h,g]=Q.useState(!1),[_,v]=Q.useState(!1),y=Q.useRef(null),b=Q.useRef(!1),x=Q.useRef(null),S=Q.useRef(null);S.current||=Vn({onPressedKeyChange:e=>g(e===l)}),Q.useEffect(()=>()=>S.current?.reset(),[]),Q.useEffect(()=>{let e=e=>{e.detail!==l&&m(0)};return window.addEventListener(Ds,e),()=>window.removeEventListener(Ds,e)},[l]),Q.useEffect(()=>{m(0)},[l]);let C=R(()=>m(0)),w=p!==0,T=R(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=R(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>Es&&a>i){t.intent=`vertical`,y.current=null,S.current?.cancel(e.pointerId);return}if(i>Es&&i>a){t.intent=`horizontal`,v(!0),b.current=!0,S.current?.cancel(e.pointerId);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}Os(l)}}if(t.intent!==`horizontal`)return;e.preventDefault();let i=Math.max(-t.actionWidth,Math.min(0,t.startOffset+n));m(i)}),D=R(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=R(e=>{let t=y.current;y.current=null,S.current?.cancel(e.pointerId),v(!1),m(t?.startOffset??0)}),k=R(()=>{if(!S.current?.consumeClick(l)){if(b.current){b.current=!1;return}if(p!==0){C();return}r()}}),A=R(n=>{d&&(n.preventDefault(),n.stopPropagation(),S.current?.openFromContextMenu(l,()=>{g(!1),a?.(e,t)}))}),j=R(()=>{C(),i?.(e,t)}),M=R(()=>{C(),o?.(e,t)}),N=R(()=>a?.(e,t)),P=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`oc-mobile-group-label-icon`,"aria-hidden":!0,children:(0,$.jsx)(Z,{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?dt(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)(Z,{name:`arrow-down-s`,className:X(`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:X(`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)($e,{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)(Z,{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)($e,{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)(Z,{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:X(`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)($e,{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)(Z,{name:`more-2`,className:`size-3.5`})}):null]})]})}function Ps(e){let t=(0,Mi.c)(132),{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}=ee(),[C,w]=Q.useState(!0),[T,E]=Q.useState(!1),[D,O]=Q.useState(!1),[k,A]=Q.useState(``),j;t[2]===k?j=t[3]:(j=k.trim().toLowerCase(),t[2]=k,t[3]=j);let M=j,N=M.length>0,P;t[4]!==M||t[5]!==n?(P=Ts(n,M),t[4]=M,t[5]=n,t[6]=P):P=t[6];let F=P,I=R(a),L=R(o),z;t[7]===s?z=t[8]:(z=()=>s?.(),t[7]=s,t[8]=z);let B=R(z),V;t[9]===c?V=t[10]:(V=()=>c?.(),t[9]=c,t[10]=V);let H=R(V),te;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>O(e),t[11]=te):te=t[11];let ne=R(te),U;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>{A(``),E(!1)},t[12]=U):U=t[12];let W=R(U),re;t[13]!==W||t[14]!==T?(re=()=>{if(T){W();return}E(!0)},t[13]=W,t[14]=T,t[15]=re):re=t[15];let ie=R(re),G;t[16]!==W||t[17]!==l?(G=e=>{W(),e.expanded||l(e)},t[16]=W,t[17]=l,t[18]=G):G=t[18];let K=R(G),ae;t[19]!==W||t[20]!==l||t[21]!==d?(ae=(e,t)=>{W(),e.expanded||l(e),t.expanded||d(e,t)},t[19]=W,t[20]=l,t[21]=d,t[22]=ae):ae=t[22];let oe=R(ae),q;t[23]!==W||t[24]!==h?(q=e=>{W(),h(e)},t[23]=W,t[24]=h,t[25]=q):q=t[25];let se=R(q),ce;t[26]===y?ce=t[27]:(ce=X(`relative isolate mx-auto flex w-full max-w-[26rem] flex-col gap-5`,y),t[26]=y,t[27]=ce);let le;t[28]===S?le=t[29]:(le=S(`mobile.sessions.section.projects`),t[28]=S,t[29]=le);let ue;t[30]!==T||t[31]!==S?(ue=S(T?`mobile.sessions.clearSearchAria`:`mobile.sessions.searchAria`),t[30]=T,t[31]=S,t[32]=ue):ue=t[32];let de=T?`close`:`search`,fe;t[33]===de?fe=t[34]:(fe=(0,$.jsx)(Z,{name:de,className:`size-5`}),t[33]=de,t[34]=fe);let pe;t[35]!==ie||t[36]!==T||t[37]!==ue||t[38]!==fe?(pe=(0,$.jsx)($e,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":ue,"aria-expanded":T,onClick:ie,children:fe}),t[35]=ie,t[36]=T,t[37]=ue,t[38]=fe,t[39]=pe):pe=t[39];let me;t[40]===S?me=t[41]:(me=S(`mobile.projects.menu.label`),t[40]=S,t[41]=me);let he=D?`rotate-45`:`rotate-0`,ge;t[42]===he?ge=t[43]:(ge=X(`size-5 transition-transform duration-150 motion-reduce:transition-none`,he),t[42]=he,t[43]=ge);let _e;t[44]===ge?_e=t[45]:(_e=(0,$.jsx)(Z,{name:`add`,className:ge}),t[44]=ge,t[45]=_e);let ve;t[46]!==me||t[47]!==_e?(ve=(0,$.jsx)(tn,{asChild:!0,children:(0,$.jsx)($e,{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":me,children:_e})}),t[46]=me,t[47]=_e,t[48]=ve):ve=t[48];let ye;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(Z,{name:`chat-new`,className:`size-4`}),t[49]=ye):ye=t[49];let be;t[50]===S?be=t[51]:(be=S(`mobile.projects.menu.newChat`),t[50]=S,t[51]=be);let xe;t[52]!==L||t[53]!==be?(xe=(0,$.jsxs)($t,{className:`min-h-11`,onSelect:L,children:[ye,be]}),t[52]=L,t[53]=be,t[54]=xe):xe=t[54];let Se;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(Z,{name:`folder`,className:`size-4`}),t[55]=Se):Se=t[55];let Ce;t[56]===S?Ce=t[57]:(Ce=S(`mobile.projects.menu.newProject`),t[56]=S,t[57]=Ce);let we;t[58]!==I||t[59]!==Ce?(we=(0,$.jsxs)($t,{className:`min-h-11`,onSelect:I,children:[Se,Ce]}),t[58]=I,t[59]=Ce,t[60]=we):we=t[60];let Te;t[61]!==B||t[62]!==s||t[63]!==S?(Te=s?(0,$.jsxs)($t,{className:`min-h-11`,onSelect:B,children:[(0,$.jsx)(Z,{name:`scan-2`,className:`size-4`}),S(`mobile.projects.menu.scanQr`)]}):null,t[61]=B,t[62]=s,t[63]=S,t[64]=Te):Te=t[64];let Ee;t[65]!==H||t[66]!==c||t[67]!==S?(Ee=c?(0,$.jsxs)($t,{className:`min-h-11`,onSelect:H,children:[(0,$.jsx)(Z,{name:`server`,className:`size-4`}),S(`mobile.projects.menu.switchInstance`)]}):null,t[65]=H,t[66]=c,t[67]=S,t[68]=Ee):Ee=t[68];let J;t[69]!==xe||t[70]!==we||t[71]!==Te||t[72]!==Ee?(J=(0,$.jsxs)(Qt,{align:`end`,side:`bottom`,className:`min-w-44`,children:[xe,we,Te,Ee]}),t[69]=xe,t[70]=we,t[71]=Te,t[72]=Ee,t[73]=J):J=t[73];let De;t[74]!==ne||t[75]!==D||t[76]!==ve||t[77]!==J?(De=(0,$.jsxs)(en,{open:D,onOpenChange:ne,children:[ve,J]}),t[74]=ne,t[75]=D,t[76]=ve,t[77]=J,t[78]=De):De=t[78];let Oe;t[79]!==pe||t[80]!==De?(Oe=(0,$.jsxs)($.Fragment,{children:[pe,De]}),t[79]=pe,t[80]=De,t[81]=Oe):Oe=t[81];let ke;t[82]!==le||t[83]!==Oe?(ke=(0,$.jsx)($n,{title:le,trailing:Oe}),t[82]=le,t[83]=Oe,t[84]=ke):ke=t[84];let Ae;t[85]!==W||t[86]!==T||t[87]!==k||t[88]!==S?(Ae=T?(0,$.jsxs)(`div`,{className:`relative mx-1`,role:`search`,children:[(0,$.jsx)(Z,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 z-10 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Xt,{autoFocus:!0,type:`text`,inputMode:`search`,enterKeyHint:`search`,value:k,placeholder:S(`mobile.sessions.search.placeholder`),"aria-label":S(`mobile.sessions.searchAria`),className:X(`h-11 rounded-full pl-9`,k&&`pr-10`),onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Escape`&&W()}}),k?(0,$.jsx)($e,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-1.5 top-1/2 size-8 -translate-y-1/2 rounded-full text-muted-foreground`,"aria-label":S(`mobile.sessions.clearSearchAria`),onClick:()=>A(``),children:(0,$.jsx)(Z,{name:`close`,className:`size-4`})}):null]}):null,t[85]=W,t[86]=T,t[87]=k,t[88]=S,t[89]=Ae):Ae=t[89];let je;t[90]!==x||t[91]!==_||t[92]!==v||t[93]!==g||t[94]!==h||t[95]!==C||t[96]!==r||t[97]!==N||t[98]!==S?(je=!N&&(r.length>0||x.length>0)?(0,$.jsx)(nr,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":S(`mobile.sessions.section.pinned`),children:[(0,$.jsx)(ms,{project:{id:`__pinned__`,name:S(`mobile.sessions.section.pinned`),path:``,icon:`pushpin`,sessionCount:r.length+x.length},expanded:C,embedded:!0,onToggle:()=>w(Is)}),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)(Ms,{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)(Ms,{sessions:x,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null]}):null]})}):null,t[90]=x,t[91]=_,t[92]=v,t[93]=g,t[94]=h,t[95]=C,t[96]=r,t[97]=N,t[98]=S,t[99]=je):je=t[99];let Me;t[100]!==I||t[101]!==K||t[102]!==oe||t[103]!==se||t[104]!==M||t[105]!==_||t[106]!==m||t[107]!==f||t[108]!==u||t[109]!==v||t[110]!==p||t[111]!==g||t[112]!==h||t[113]!==l||t[114]!==d||t[115]!==n.length||t[116]!==N||t[117]!==S||t[118]!==F?(Me=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)(Z,{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)($e,{type:`button`,size:`lg`,className:`mt-4 min-h-10 rounded-full px-5`,onClick:I,children:[(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`}),S(`sessions.sidebar.header.actions.addProject`)]})]}):N&&F.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[40dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(Z,{name:`search`,className:`mb-4 size-6 text-muted-foreground`}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:S(`mobile.sessions.empty.searchTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:S(`mobile.sessions.empty.searchDescription`)})]}):F.map(e=>{let t=N||e.expanded,n=e.worktrees.find(Fs)??(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)(nr,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":e.name,children:[(0,$.jsx)(ms,{project:e,expanded:t,embedded:!0,highlightQuery:N?M:void 0,onToggle:()=>N?K(e):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)(Ms,{sessions:i,highlightQuery:N?M:void 0,onSelectSession:N?se:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,r.map(t=>{let n=N||!!t.expanded;return(0,$.jsx)(ar,{className:`oc-mobile-worktree-group`,ariaLabel:t.name,label:(0,$.jsx)(Ns,{project:e,worktree:t,expanded:n,highlightQuery:N?M:void 0,onToggle:()=>N?oe(e,t):d(e,t),onNewSession:f,onOpenActions:N?void 0:p,onDelete:N?void 0:m}),children:n&&t.sessions.length>0?(0,$.jsx)(Ms,{sessions:t.sessions,highlightQuery:N?M:void 0,onSelectSession:N?se:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v}):null},t.id)})]}):null]})},e.id)}),t[100]=I,t[101]=K,t[102]=oe,t[103]=se,t[104]=M,t[105]=_,t[106]=m,t[107]=f,t[108]=u,t[109]=v,t[110]=p,t[111]=g,t[112]=h,t[113]=l,t[114]=d,t[115]=n.length,t[116]=N,t[117]=S,t[118]=F,t[119]=Me):Me=t[119];let Ne;t[120]===S?Ne=t[121]:(Ne=S(`sessions.sidebar.header.actions.addProject`),t[120]=S,t[121]=Ne);let Pe;t[122]!==I||t[123]!==Ne?(Pe=(0,$.jsx)(`button`,{type:`button`,className:`sr-only`,onClick:I,children:Ne}),t[122]=I,t[123]=Ne,t[124]=Pe):Pe=t[124];let Fe;return t[125]!==ce||t[126]!==ke||t[127]!==Ae||t[128]!==je||t[129]!==Me||t[130]!==Pe?(Fe=(0,$.jsxs)(`main`,{className:ce,children:[ke,Ae,je,Me,Pe]}),t[125]=ce,t[126]=ke,t[127]=Ae,t[128]=je,t[129]=Me,t[130]=Pe,t[131]=Fe):Fe=t[131],Fe}function Fs(e){return e.kind===`main`}function Is(e){return!e}function Ls(e){let t=(0,Mi.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=()=>{je(`light`),i()},t[0]=i,t[1]=d);let f=R(d),p=c?`destructive`:`ghost`,m=u?`size-5 animate-spin`:`size-5`,h;t[2]!==n||t[3]!==m?(h=(0,$.jsx)(Z,{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)($e,{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 Rs(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)(Ls,{icon:e.icon,label:dr(e,t),onClick:n(e.onClick),destructive:e.destructive,disabled:e.disabled,spinning:e.spinning},e.id))},e.items[0]?.id))}function zs(e){let t=(0,Mi.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}=ee(),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=Xr({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=Or({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=yr({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=Rs(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)(Kt,{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 Bs(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 Vs(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=Bs(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 Hs=`__show_more__:`,Us=`__show_fewer__:`,Ws=e=>e.startsWith(Hs),Gs=e=>e.startsWith(Us),Ks=e=>Ws(e)||Gs(e),qs=e=>{let t=Ws(e)?Hs:Gs(e)?Us: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)}},Js=e=>e.parentID??null,Ys=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Xs=e=>{let t=e;return Ys(t.directory??t.project?.worktree??null)},Zs=(e,t)=>{if(t?.trim())return t.trim();let n=Ys(e);if(!n)return``;let r=n.split(`/`).filter(Boolean);return r[r.length-1]||n},Qs=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},$s=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))},ec=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},tc=(e,t)=>e.worktrees.find(e=>Ys(e.path)===t)??null,nc=(e,t)=>{let n=t?.trim();return n?`${e} · ${n}`:e},rc=(e,t)=>Ur(e,{pinnedSessionIds:t,omitPinnedSessions:!0}).map(e=>e.session);function ic(){let{t:e}=ee(),t=se(),n=ke(e=>e.activeSessions),r=ke(e=>e.activePaginationByDirectory),i=Me(e=>e.projects),a=Me(e=>e.activeProjectId),o=T(e=>e.currentDirectory),s=J(e=>e.currentSessionId),c=J(e=>e.availableWorktreesByProject),l=Et(e=>e.orderByProject),u=Ae(),d=fo(e=>e.projectExpanded),f=fo(e=>e.worktreeExpanded),p=oe(e=>e.index.session.unseenCount),[m,h]=Q.useState(new Map),g=mr(),_=Q.useMemo(()=>xr(g,s),[s,g]),v=Q.useMemo(()=>i.map(e=>{let t=Ys(e.path);return{id:e.id,label:Zs(t,e.label),path:t,icon:e.icon,worktrees:wt(l[e.id],c.get(t)??[])}}),[i,l,c]),y=Q.useMemo(()=>{let e=new Map(t.map(e=>[e.id,e])),r=n.map(t=>{let n=e.get(t.id);return n?Te(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]),b=Q.useMemo(()=>Nr(y,v.map(e=>({id:e.id,normalizedPath:e.path})),c,!1),[v,y,c]),x=Q.useMemo(()=>{let e=v.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===a,latestActivity:0})),t=new Map(e.map(e=>[e.project.id,e])),n=(e,t,n)=>{let r=Ys(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||Zs(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 y){let r=b.bySessionId.get(e.id);if(!r)continue;let i=t.get(r.projectId);if(!i)continue;let a=r.kind===`worktree`?tc(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)=>be(t)-be(e));let n=rc(e.sessions,u);t.totalSessions+=n.length;for(let n of e.sessions){let e=Qs(n);e>t.latestActivity&&(t.latestActivity=e)}}return e},[a,b,u,v,y]),S=Q.useMemo(()=>{let e=new Map;for(let t of y)e.set(t.id,t);return e},[y]),C=Q.useMemo(()=>{let e=new Map;for(let t of v)e.set(t.id,t);return e},[v]),w=Q.useRef([]),E=Q.useRef([]),D=Q.useRef(new Map),{pinnedSessions:O,inProgressSessions:k}=Q.useMemo(()=>{let t=new Map(v.map(e=>[e.id,e])),n=e(`mobile.sessions.untitled`),r=new Map(w.current.map(e=>[e.id,e])),i=new Map(E.current.map(e=>[e.id,e])),a=(e,r,i)=>{let a=b.bySessionId.get(e.id),o=a?t.get(a.projectId):void 0;if(!o)return[];let c=a?.kind===`worktree`?tc(o,a.scopeDirectory):null,l={id:e.id,directory:Xs(e),title:e.title?.trim()||n,subtitle:nc(o.label,c?.branch),changes:Gn(Wn(e))??void 0,activityLabel:$s(Qs(e))||void 0,unread:(p[e.id]??0)>0,pinned:r,archived:ec(e),active:s===e.id};return[Bs(i.get(e.id),l)]},o=Er(y,u).flatMap(e=>a(e,!0,r)),c=Br(y,u,g,p).flatMap(e=>a(e,!1,i)),l=Vs(w.current,o),d=Vs(E.current,c);return w.current=l,E.current=d,{pinnedSessions:l,inProgressSessions:d}},[s,b,u,v,g,y,e,p]),A=Q.useMemo(()=>{let e=new Map;for(let t of x){let n=t.project.worktrees.length>0;for(let r of t.buckets){let i=rc(r.sessions,u).length;e.set(`${t.project.id}::${r.key}`,{path:r.path,rootCount:i,hasWorktrees:n})}}return e},[u,x]),j=Q.useMemo(()=>{let t=Ys(o),n=new Map,i=e=>(e.kind!==`pagination`&&n.set(e.id,e),e),a=x.map(a=>{let o=d[a.project.id]??!0,c=Yr(),l=a.project.icon?Gt[a.project.icon]:void 0,h=a.buckets.map(o=>{let l=`${a.project.id}::${o.key}`,d=f[l]??!1,h=m.get(l)??c,g=rc(o.sessions,u),v=Ur(o.sessions,{pinnedSessionIds:u,omitPinnedSessions:!1}).map(e=>e.session),y=t=>{let r=Js(t),a=(p[t.id]??0)>0&&!r,c={id:t.id,directory:o.path,title:t.title?.trim()||e(`mobile.sessions.untitled`),changes:Gn(Wn(t))??void 0,activityLabel:$s(Qs(t))||void 0,unread:a,pinned:u.has(t.id),archived:ec(t),active:s===t.id},l=Bs(D.current.get(t.id)??n.get(t.id),c);return i(l)},b=_r(g,h,_).map(y),x=g.length-b.length,S=r.get(Ys(o.path)),C=S?.hasMore===!0,w=g.length>c&&h>c,T=[...b];w&&T.push({id:`${Us}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showFewer`)}),(x>0||C)&&T.push({id:`${Hs}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showMore`),subtitle:S?.loadingMore?`…`:void 0});let E=Ys(o.path),O=!!(a.isActive&&t&&E&&(t===E||t.startsWith(`${E}/`))),k=o.worktree==null;return{id:o.key,name:k?e(`mobile.sessions.mainWorkspace`):o.label,path:o.path,kind:k?`main`:`worktree`,active:O,expanded:k?!0:d,sessionCount:g.length,sessions:T,catalogSessions:v.map(y)}});return{id:a.project.id,name:a.project.label,path:a.project.path,icon:l,sessionCount:a.totalSessions,activityLabel:$s(a.latestActivity)||void 0,active:a.isActive,expanded:o,worktrees:h}});return D.current=n,a},[r,_,o,s,u,d,x,e,p,m,f]),M=e=>{for(let[t,n]of A)if(t.startsWith(`${e}::`))return n.hasWorktrees;return!1},N=(e,t)=>A.get(`${e}::${t}`)?.rootCount??0,P=e=>Yr();return{projects:j,pinnedSessions:O,inProgressSessions:k,sessionById:S,projectMetaById:C,allSessions:y,projectHasWorktrees:M,getBucketRootCount:N,getBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;return m.get(n)??P(e)},getBucketPageSize:P,getBucketDirectory:(e,t)=>A.get(`${e}::${t}`)?.path??null,showMoreBucketSessions:(e,t)=>{let n=`${e}::${t}`,r=A.get(n),i=Yr(),a=br(),o=m.get(n)??i,s=r?.rootCount??0;if(h(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=Ys(c);if(!l)return;let u=ke.getState().activePaginationByDirectory.get(l);u?.hasMore&&!u.loadingMore&&Fe(l)},resetBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;h(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})}}}var ac=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function oc({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,className:a}){let{t:o}=ee(),{git:s}=hn(),c=ic(),l=fo(e=>e.setProjectExpanded),u=fo(e=>e.setWorktreeExpanded),d=Re(),f=Ae(),m=J(e=>e.archiveSessions),h=J(e=>e.updateSessionTitle),g=J(e=>e.requestSessionSmartTitle),_=J(e=>e.shareSession),v=J(e=>e.unshareSession),y=J(e=>e.openNewSessionDraft),b=ze(e=>e.openDraft),x=ze(e=>e.openSession),S=Me(e=>e.projects),C=Me(e=>e.setActiveProjectIdOnly),w=Me(e=>e.removeProject),T=_t(),[E,D]=Q.useState(null),[O,k]=Q.useState(!1),[A,j]=Q.useState(null),[M,N]=Q.useState(null),[P,F]=Q.useState(null),[I,L]=Q.useState(``),[z,V]=Q.useState(!1),[H,te]=Q.useState(!1),[ne,U]=Q.useState(null),[W,re]=Q.useState(null),[ie,G]=Q.useState(null),K=E?.kind===`session`?E.session.id:``,ae=ue(K),oe=ae?.type===`busy`||ae?.type===`retry`,q=E?.kind===`session`?Xs(E.session):``,se=!!K&&ie===K,ce=!q||se||oe,le=R(e=>{let t=new Map;for(let e of c.allSessions){let n=Js(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=R(()=>{k(!1),D(null)}),fe=R(t=>{if(Ks(t.id)){let e=qs(t.id);if(!e)return;e.kind===`more`?c.showMoreBucketSessions(e.projectId,e.bucketKey):c.resetBucketVisibleCount(e.projectId,e.bucketKey);return}let n=c.sessionById.get(t.id),r=n&&Xs(n)||null;e({sessionId:t.id,directory:r})}),pe=R(e=>{Ks(e.id)||d(e.id)}),me=R(async e=>{if(Ks(e.id))return;let t=le(e.id),{archivedIds:n,failedIds:r}=await m(t);n.length>0&&ur({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=R(()=>{if(!E||E.kind!==`session`)return;let e=E.session,t=Xs(e),n=ae?.type??`idle`;!t||ie===e.id||n===`busy`||n===`retry`||(G(e.id),(async()=>{try{await T.refreshSessionTranscript(e.id,{directory:t}),Y.success(o(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{Y.error(o(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{G(t=>t===e.id?null:t)}})())}),ge=R(e=>{if(Ks(e.id))return;let t=c.sessionById.get(e.id);t&&(D({kind:`session`,session:t}),k(!0))}),_e=R(e=>{l(e.id,!e.expanded)}),ve=R((e,t)=>{u(`${e.id}::${t.id}`,!t.expanded)}),ye=R((e,t)=>{C(e.id),b({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),be=R(()=>{if(n){n();return}y()}),xe=R(e=>{let t=c.projectMetaById.get(e.id);t&&(D({kind:`project`,project:t,isGitRepository:!1}),k(!0),s.checkIsGitRepository(t.path).then(e=>{D(n=>ac(n,t.id,e))}).catch(()=>{D(e=>ac(e,t.id,!1))}))}),Se=R((e,t)=>{let n=p(t);return n?e.worktrees.find(e=>p(e.path)===n)||((J.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>p(e.path)===n)??null):null}),Ce=R((e,t)=>{let n=c.projectMetaById.get(e.id);n&&ye(n,t.path)}),we=R((e,t)=>{let n=c.projectMetaById.get(e.id);n&&(D({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),k(!0))}),Te=R((e,t)=>{let n=c.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}re({project:n,worktree:r})}),Ee=R(e=>{U(e),C(e),te(!0)}),De=R(e=>{(async()=>{let t=e.worktrees;try{t=(await Jt({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=J.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await He([e.path,...t.map(e=>e.path)],c.allSessions)})()}),Oe=R((e,t)=>{let n=ne;if(te(!1),U(null),t?.sessionId){x({sessionId:t.sessionId,directory:e});return}b({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),ke=R(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`))}}),je=R(async e=>{if((await B(e)).ok){Y.success(o(`sessions.sidebar.session.menu.copied`));return}Y.error(o(`sessions.sidebar.session.share.copyUrlError`))}),Ne=R(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`))}}),Pe=R(e=>{let t=le(e.id);Fr({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=R(async()=>{if(!P)return;let e=I.trim();if(e)try{await h(P.id,e),F(null),L(``)}catch{Y.error(o(`sessions.sidebar.session.menu.rename`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),Ie=R(async()=>{if(!P||z)return;let e=P.id;F(null),L(``),V(!0);try{await g(e)}catch{Y.error(o(`sessions.sidebar.session.rename.smartTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{V(!1)}}),Le=Q.useMemo(()=>E?E.kind===`session`?{kind:`session`,title:E.session.title?.trim()||o(`mobile.sessions.untitled`),pinned:f.has(E.session.id),shared:!!E.session.share?.url}:E.kind===`project`?{kind:`project`,title:E.project.label,gitRepository:E.isGitRepository}:{kind:`worktree`,title:E.worktreeName}:null,[E,f,o]),Be=Q.useMemo(()=>{if(!E)return{};if(E.kind===`session`){let e=E.session;return{onRename:()=>{L(e.title?.trim()||o(`mobile.sessions.untitled`)),F(e)},onTogglePin:()=>d(e.id),onShare:e.share?.url?void 0:()=>{ke(e)},onCopyLink:e.share?.url?()=>{je(e.share.url)}:void 0,onUnshare:e.share?.url?()=>{Ne(e.id)}:void 0,onRefreshTranscript:he,onArchive:()=>{me({id:e.id,title:e.title?.trim()||o(`mobile.sessions.untitled`)})},onDelete:()=>Pe(e)}}if(E.kind===`project`){let e=E.project;return{onNewSession:()=>ye(e,e.path),onNewWorktree:()=>Ee(e.id),onSyncSessions:()=>De(e),onEditProject:()=>j(e.id),onCloseProject:()=>N(e)}}let{project:e,worktreePath:t}=E;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}re({project:e,worktree:n})}}},[E,me,je,Pe,he,Ee,De,ke,Ne,Se,ye,o,d]),Ve=Q.useMemo(()=>{if(!A)return null;let e=S.find(e=>e.id===A),t=c.projectMetaById.get(A);if(!e||!t)return null;let n=E?.kind===`project`&&E.project.id===A?E.isGitRepository:t.worktrees.length>0;return{id:e.id,label:e.label?.trim()||t.label,path:p(e.path)||t.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:n,worktrees:t.worktrees}},[E,A,c.projectMetaById,S]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ps,{className:a,projects:c.projects,pinnedSessions:c.pinnedSessions,inProgressSessions:c.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)(zs,{open:O,target:Le,actions:Be,refreshTranscriptDisabled:ce,refreshTranscriptSpinning:se,onOpenChange:e=>{e?k(!0):de()}}),(0,$.jsx)(ht,{open:H,projectId:ne,onOpenChange:e=>{te(e),e||U(null)},onWorktreeCreated:Oe}),W?(0,$.jsx)(vr,{open:!0,project:{id:W.project.id,path:W.project.path},worktree:W.worktree,onClose:()=>re(null)}):null,(0,$.jsx)(xt,{open:!!M,title:o(`sessions.sidebar.project.actions.closeProject`),onClose:()=>N(null),closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)($e,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>N(null),children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)($e,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!M)return;let e=M;N(null),w(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:M?.label??``})})}),(0,$.jsx)(xt,{open:!!P,title:o(`sessions.sidebar.session.menu.rename`),onClose:()=>{z||(F(null),L(``))},closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)($e,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:z,onClick:()=>{F(null),L(``)},children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)($e,{type:`button`,variant:`default`,className:`flex-1`,disabled:!I.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)(Xt,{value:I,onChange:e=>L(e.target.value),autoFocus:!0,className:`h-12`,disabled:z}),(0,$.jsxs)($e,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:z,onClick:()=>void Ie(),children:[z?(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-4`}),o(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(fr,{open:A!==null,project:Ve,onClose:()=>j(null)})]})}function sc(e){let t=(0,Mi.c)(10),{children:n,content:r,className:i,contentClassName:a,showHeader:o}=e,s=o===void 0||o,{t:c}=ee(),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=X(`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)(tr,{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 cc(e){let t=(0,Mi.c)(10),{className:n,contentClassName:r,instancesPage:i}=e,{t:a}=ee(),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=[...rr],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(ai,{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)(tr,{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 lc(e){let t=(0,Mi.c)(92),{onAddProject:n,onScanQr:r,onSwitchInstance:i,onEnableAssistants:a,instancesPage:o,instancesSecondaryPage:s,parentSessionTarget:c,registerSecondaryBackHandler:l,scheduledContent:u,renderChat:d,className:f}=e,m=c===void 0?null:c,{t:h}=ee(),g=ze(),_=ze(bc),v=ze(yc),y=ze(vc),b=ze(_c),x=ze(gc),S=ze(hc),C=ze(mc),w=ze(pc),T=ze(fc),E;t[0]===_?E=t[1]:(E=e=>{_(e)},t[0]=_,t[1]=E);let D=R(E),O;t[2]===v?O=t[3]:(O=e=>{v(e)},t[2]=v,t[3]=O);let k=R(O),A;t[4]===x?A=t[5]:(A=()=>{x()},t[4]=x,t[5]=A);let j=R(A),M;t[6]===y?M=t[7]:(M=()=>{y()},t[6]=y,t[7]=M);let N=R(M),P;t[8]===b?P=t[9]:(P=e=>{b(e)},t[8]=b,t[9]=P);let F=R(P),I=Q.useRef(null),[L,z]=Q.useState(!1),B;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{I.current=e},t[10]=B):B=t[10];let V=R(B),H;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>{z(e)},t[11]=H):H=t[11];let te=R(H),ne;t[12]!==j||t[13]!==S?(ne=()=>{if(I.current?.())return!0;let e=ze.getState().secondary;return e?.kind===`chat`&&e.routes.length>1?(S(),!0):e?(j(),!0):!1},t[12]=j,t[13]=S,t[14]=ne):ne=t[14];let U=R(ne),W=g.secondary!==null,re;t[15]!==U||t[16]!==l?(re=()=>{if(l)return l(()=>U()),()=>l(null)},t[15]=U,t[16]=l,t[17]=re):re=t[17];let ie;t[18]!==U||t[19]!==l||t[20]!==W?(ie=[l,W,U],t[18]=U,t[19]=l,t[20]=W,t[21]=ie):ie=t[21],Q.useEffect(re,ie);let G=J(dc),K;t[22]===G?K=t[23]:(K=e=>G?e.getDirectoryForSession(G):null,t[22]=G,t[23]=K);let ae=J(K),oe,q;t[24]!==ae||t[25]!==G||t[26]!==w||t[27]!==T?(oe=()=>{let e=ze.getState().secondary;if(e?.kind===`draft`&&G){w({sessionId:G,directory:ae});return}if(e?.kind!==`chat`||!G||Ve({sessionId:G,directory:ae})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==G||p(t.directory)!==p(ae))&&T({sessionId:G,directory:ae})},q=[ae,G,w,T],t[24]=ae,t[25]=G,t[26]=w,t[27]=T,t[28]=oe,t[29]=q):(oe=t[28],q=t[29]),Q.useEffect(oe,q);let se,ce;t[30]!==G||t[31]!==m||t[32]!==C?(se=()=>{let e=ze.getState().secondary;if(e?.kind!==`chat`||!m)return;let t=e.routes.at(-1);!t||t.sessionId!==G||C({sessionId:m.id,directory:m.directory})},ce=[G,m,C],t[30]=G,t[31]=m,t[32]=C,t[33]=se,t[34]=ce):(se=t[33],ce=t[34]),Q.useEffect(se,ce);let le;t[35]!==te||t[36]!==V||t[37]!==u?(le=typeof u==`function`?u(V,te):u,t[35]=te,t[36]=V,t[37]=u,t[38]=le):le=t[38];let ue=le,de;t[39]!==N||t[40]!==n||t[41]!==r||t[42]!==i||t[43]!==k?(de=(0,$.jsx)(oc,{onOpenChat:k,onAddProject:n,onNewSession:N,onScanQr:r,onSwitchInstance:i}),t[39]=N,t[40]=n,t[41]=r,t[42]=i,t[43]=k,t[44]=de):de=t[44];let fe;t[45]!==a||t[46]!==F?(fe=(0,$.jsx)(Vo,{onEnable:a,onOpenAssistant:F}),t[45]=a,t[46]=F,t[47]=fe):fe=t[47];let pe;t[48]===ue?pe=t[49]:(pe=(0,$.jsx)(sc,{showHeader:!1,children:ue}),t[48]=ue,t[49]=pe);let me;t[50]===o?me=t[51]:(me=(0,$.jsx)(cc,{instancesPage:o}),t[50]=o,t[51]=me);let he;t[52]!==de||t[53]!==fe||t[54]!==pe||t[55]!==me?(he={projects:de,assistant:fe,scheduled:pe,settings:me},t[52]=de,t[53]=fe,t[54]=pe,t[55]=me,t[56]=he):he=t[56];let ge=he,_e=g.secondary?.kind??null,ve;bb0:{if(!_e){ve=null;break bb0}if(_e===`assistant`){let e;t[57]===h?e=t[58]:(e=h(`assistants.title`),t[57]=h,t[58]=e);let n;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(li,{activeOverride:!0,onMobileBack:uc}),t[59]=n):n=t[59];let r;t[60]!==U||t[61]!==e?(r=[{key:`assistant-secondary`,depth:1,ariaLabel:e,onBack:U,content:n}],t[60]=U,t[61]=e,t[62]=r):r=t[62],ve=r;break bb0}if(_e===`instances`){let e;t[63]===h?e=t[64]:(e=h(`mobile.settings.switchInstance`),t[63]=h,t[64]=e);let n;t[65]!==U||t[66]!==s||t[67]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:U,content:s}],t[65]=U,t[66]=s,t[67]=e,t[68]=n):n=t[68],ve=n;break bb0}if(g.secondary?.kind===`draft`){let e;t[69]===h?e=t[70]:(e=h(`mobile.nav.secondaryPageAria`),t[69]=h,t[70]=e);let n;t[71]===d?n=t[72]:(n=d({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[71]=d,t[72]=n);let r;t[73]!==U||t[74]!==e||t[75]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:U,content:n}],t[73]=U,t[74]=e,t[75]=n,t[76]=r):r=t[76],ve=r;break bb0}if(g.secondary?.kind!==`chat`){let e;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[77]=e):e=t[77],ve=e;break bb0}let e=g.secondary.routes,n;if(t[78]!==U||t[79]!==d||t[80]!==e||t[81]!==h){let r=e.slice(-2),i=e.length-r.length+1;n=r.map((e,t)=>{let n=t===r.length-1;return{key:e.key,depth:i+t,ariaLabel:h(`mobile.nav.secondaryPageAria`),onBack:U,content:d({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:n})}}),t[78]=U,t[79]=d,t[80]=e,t[81]=h,t[82]=n}else n=t[82];ve=n}let ye=ve,be;t[83]===ye?be=t[84]:(be=ye??[],t[83]=ye,t[84]=be);let xe;return t[85]!==f||t[86]!==g||t[87]!==L||t[88]!==D||t[89]!==be||t[90]!==ge?(xe=(0,$.jsx)(us,{className:f,navigation:g,onTabChange:D,tabs:ge,secondaryPages:be,tabBarCovered:L}),t[85]=f,t[86]=g,t[87]=L,t[88]=D,t[89]=be,t[90]=ge,t[91]=xe):xe=t[91],xe}function uc(){return On.requestAnimatedBack(`root`)}function dc(e){return e.currentSessionId}function fc(e){return e.replaceChatSession}function pc(e){return e.materializeDraftSession}function mc(e){return e.reconcileChatPredecessor}function hc(e){return e.popChatSession}function gc(e){return e.closeSecondary}function _c(e){return e.openAssistant}function vc(e){return e.openDraft}function yc(e){return e.openSession}function bc(e){return e.setActiveTab}function xc(e){let t=(0,Mi.c)(19),{percentage:n}=e,r,i,a,o,s,c,l;if(t[0]!==n){a=sn(n)??0;let e=an(n);i=e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,r=2*Math.PI*7.5,o=`0 0 18 18`,s=`size-[18px] -rotate-90`,c=`progressbar`,l=Math.round(a),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7];let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[8]=u):u=t[8];let d=r*(1-a/100),f;t[9]!==r||t[10]!==i||t[11]!==d?(f=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:i,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:r,strokeDashoffset:d,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[9]=r,t[10]=i,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==o||t[14]!==s||t[15]!==c||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`svg`,{viewBox:o,className:s,role:c,"aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,children:[u,f]}),t[13]=o,t[14]=s,t[15]=c,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}function Sc(e){let t=(0,Mi.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}=ee(),f=R(i),p=R(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 Cc=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},wc=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),Tc=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,Ec=e=>{let{totalTokens:t,contextLimit:n,isDraft:r}=e;if(r||t<=0||n<=0)return null;let i=Math.min(t/n*100,999);return{percentage:i,tokens:`${wc(t)}/${wc(n)}`,colorClass:Tc(i)}},Dc=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},Oc=(e,t)=>{let n=fe(e,t??(()=>void 0));return!n||`compacted`in n?0:n.totalTokens},kc=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Ac=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`},jc=e=>{let t=(0,Mi.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,$.jsx)(Z,{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},Mc=e=>{let t=(0,Mi.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ee(),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)(Z,{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)(Z,{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)(Vt,{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=nn(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:X(`shrink-0 typography-ui-label font-semibold tabular-nums`,Ac(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},Nc=e=>{let t=(0,Mi.c)(47),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l}=e,{t:u}=ee(),d=Q.useRef(null),[f,p]=Q.useState(n),[m,h]=Q.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]),Q.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]),Q.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=X(`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)(jc,{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)(jc,{iconNode:(0,$.jsx)(xc,{percentage:i.percentage}),label:u(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsxs)(`span`,{className:X(`font-semibold`,i.colorClass),children:[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)(Mc,{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:$c,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([])}),J=R(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 it(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=ce.find(t=>t.name===e)??ce[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 _e(t,!1),await ye(t).promise}else await _e(t,!1)}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{w(null),e.pushAfter&&S(null)}},Oe=Q.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 xe([e],`unstage`),onActionAll:e=>void xe(e,`unstage`),onViewDiff:e=>Se(e,!0),onRevertFile:we,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 xe([e],`stage`),onActionAll:e=>void xe(e,`stage`),onViewDiff:e=>Se(e,!1),onRevertFile:we}),e},[we,Se,xe,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)(Z,{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)(ya,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):l===!1?ke((0,$.jsx)(ya,{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)(ba,{path:v.path,diff:ue,fileExists:ge,error:he,loading:me,targetLine:v.targetLine,onBack:Ce,onRetry:()=>U(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)(Z,{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)(Mr,{syncAction:x,remotes:ce,onSync:e=>void be(`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)(qr,{stagedCount:q,unstagedCount:se,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)(Ar,{groups:Oe,diffStats:c?.diffStats,revertingPaths:D,onRevertAll:Te,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)(kr,{stagedCount:ae.length,commitMessage:T,onCommitMessageChange:E,generatedHighlights:N,onInsertHighlights:Ee,onGenerateMessage:J,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)(ya,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):ke((0,$.jsx)(ya,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},ya=e=>{let t=(0,Mi.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)(Z,{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)(Z,{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},ba=e=>{let t=(0,Mi.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}=ee(),p;t[0]===n?p=t[1]:(p=In(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)(Z,{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)($e,{type:`button`,size:`sm`,variant:`outline`,onClick:l,children:f(`diffView.actions.retry`)})]})}):o?(0,$.jsx)(ya,{loading:!0,message:f(`diffView.state.loadingDiff`)}):i?r?r.isBinary?(0,$.jsx)(ya,{icon:!0,message:f(`diffView.binary.unavailable`)}):Ln(n)?(0,$.jsx)(ya,{icon:!0,message:f(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(Pn,{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)(Cr,{original:r.original,modified:r.modified,language:m,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:s,layout:`inline`})}):(0,$.jsx)(ya,{loading:!0,message:f(`diffView.state.loadingDiff`)}):(0,$.jsx)(ya,{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],_},xa=e(w(),1),Sa=`data-oc-motion-id`,Ca=`data-oc-sheet-overscroll`,wa=`html, body { overscroll-behavior-y: none; }`,Ta=[`input`,`textarea`,`select`,`[contenteditable]:not([contenteditable="false"])`,`[data-mobile-sheet-no-dismiss]`].join(`, `),Ea=e=>e.closest(`[data-oc-motion-id]`)?.getAttribute(`data-oc-motion-id`)??null,Da=e=>{try{let t=e.contentDocument;return t?t.scrollingElement??t.documentElement:null}catch{return null}},Oa=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)&&e<=1&&t>0,ka=(e,t,n)=>e?!0:Oa(t,n),Aa=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.Element},ja=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLElement},Ma=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLStyleElement},Na=(e,t)=>{if(typeof e.item==`function`){let n=e.item(t);if(n)return n}return e[t]??null},Pa=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=Na(e,n);if(r?.identifier===t)return r}return null},Fa=(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}},Ia=(e,t)=>{let n=[],r=new Set,i=t=>{!t||r.has(t)||Fa(e,t)&&(r.add(t),n.push(t))},a=Aa(e,t)?t:null;for(;a&&(ja(e,a)&&i(a),a!==e.documentElement&&a!==e.body);)a=a.parentElement;let o=e.scrollingElement??e.documentElement;return ja(e,o)&&i(o),n},La=(e,t)=>{let n=Ia(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)},Ra=e=>{let t=e.closest(`[${Sa}]`);if(t instanceof HTMLElement){let e=t.getBoundingClientRect().height;if(Number.isFinite(e)&&e>0)return e}return window.innerHeight||1},za=e=>{let t=null,n=()=>{t?.(),t=null;let n=(()=>{try{return e.contentDocument}catch{return null}})();if(!n)return;let r=Ea(e);if(!r)return;let i=null;if(!Ma(n,n.querySelector(`style[${Ca}]`))){let e=n.createElement(`style`);e.setAttribute(Ca,`true`),e.textContent=wa,(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||(Aa(n,t.target)?t.target:null)?.closest(Ta)||!La(n,t.target))return;let r=Na(t.touches,0);if(!r)return;let i=Ra(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:Lt(i,.1,40,64),active:!1,controller:null}},c=t=>{if(!a)return;if(t.touches.length!==1){o();return}let i=Pa(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=Pt(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(!La(n,t.target)){a=null;return}if(!ka(!1,Da(e)?.scrollTop??0,s)){a=null;return}if(!Ft(`bottom`,c,s,8,1))return;let i=Yt(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=Rt(`bottom`,c,s);u.controller.update(zt(d,u.motionDistance))},l=e=>{if(!a)return;let t=a,n=Pa(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=Pt(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=Rt(`bottom`,o,i),c=It(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?.()}},Ba=Nn(()=>M(()=>import(`./ToolOutputDialog-FB6tTD3j.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]))),Va=25e4,Ha=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Ua=e=>{let t=Ha(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},Wa=e=>{let t=Ha(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},Ga=(e,t)=>{let n=Ha(e),r=Ha(t);return!r||n===r?Ua(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},Ka=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``},qa=e=>e.toLowerCase().endsWith(`.svg`)?``:o().authenticatedAsset(`/api/fs/raw`,{path:e}),Ja=e=>/\.(md|mdx|markdown)$/i.test(e),Ya=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return`/api/fs/serve${t.startsWith(`/`)?t:`/${t}`}`},Xa=e=>o().authenticatedAsset(Ya(e)),Za=e=>{let t=(0,Mi.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}=ee(),{files:u}=hn(),f=Bn()??null,p;t[0]===f?p=t[1]:(p=Ha(f),t[0]=f,t[1]=p);let m=p,h;t[2]!==o||t[3]!==m?(h=()=>{let e=Ha(o);return e?{type:`file`,path:e,returnDirectory:Wa(e)??m}:{type:`browser`,directory:m}},t[2]=o,t[3]=m,t[4]=h):h=t[4];let[g,_]=Q.useState(h),v=Q.useRef(null),[y,b]=Q.useState(``),x=d(ao),S=d(oo),C,w;t[5]===m?(C=t[6],w=t[7]):(C=()=>{m&&_(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:Wa(e.path)??m}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:m})},w=[m],t[5]=m,t[6]=C,t[7]=w),Q.useEffect(C,w);let T,E;t[8]!==x||t[9]!==m||t[10]!==S?(E=()=>{if(!x||!m)return;let e=Ha(x);if(!e){S(null);return}b(``),_({type:`file`,path:e,returnDirectory:Wa(e)??m}),S(null)},T=[x,m,S],t[8]=x,t[9]=m,t[10]=S,t[11]=T,t[12]=E):(T=t[11],E=t[12]),Q.useEffect(E,T);let D=g.type===`browser`?g.directory:g.returnDirectory,O=g.type===`browser`?g.directory:``,k=g.type===`file`?g.path:``,[A,j]=Q.useState(`preview`),M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{j(`preview`)},t[13]=M):M=t[13];let N;t[14]===k?N=t[15]:(N=[k],t[14]=k,t[15]=N),Q.useEffect(M,N);let P=gn(y,250),F;t[16]===y?F=t[17]:(F=y.trim(),t[16]=y,t[17]=F);let I=F,L;t[18]===P?L=t[19]:(L=P.trim(),t[18]=P,t[19]=L);let z=L,V;t[20]!==O||t[21]!==m?(V={scopeDirectory:m,directory:O},t[20]=O,t[21]=m,t[22]=V):V=t[22];let H=!!O,te;t[23]===H?te=t[24]:(te={enabled:H,refetchOnMount:`always`},t[23]=H,t[24]=te);let ne=gi(V,te),U;t[25]!==O||t[26]!==z?(U={directory:O,query:z,maxResults:40},t[25]=O,t[26]=z,t[27]=U):U=t[27];let W=!!(O&&z),re;t[28]===W?re=t[29]:(re={enabled:W},t[28]=W,t[29]=re);let ie=hi(U,re),G;t[30]!==k||t[31]!==u||t[32]!==A?(G=k&&u.readFile&&(!zn(k)||A===`source`)&&(!Ln(k)||k.toLowerCase().endsWith(`.svg`)),t[30]=k,t[31]=u,t[32]=A,t[33]=G):G=t[33];let K=!!G,ae;t[34]!==k||t[35]!==m?(ae={scopeDirectory:m,path:k},t[34]=k,t[35]=m,t[36]=ae):ae=t[36];let oe;t[37]===K?oe=t[38]:(oe={enabled:K},t[37]=K,t[38]=oe);let q=vi(ae,oe),se;t[39]!==k||t[40]!==m?(se={scopeDirectory:m,path:k},t[39]=k,t[40]=m,t[41]=se):se=t[41];let ce;t[42]===K?ce=t[43]:(ce={enabled:K},t[42]=K,t[43]=ce),_i(se,ce);let le=ne.data?.entries.slice().sort(so)??[],ue;t[44]!==ne.error||t[45]!==l?(ue=ne.error?ne.error instanceof Error?ne.error.message:l(`mobile.files.error.listFailed`):null,t[44]=ne.error,t[45]=l,t[46]=ue):ue=t[46];let de=ue,fe=ne.isFetching,pe;t[47]===ie.data?pe=t[48]:(pe=ie.data??[],t[47]=ie.data,t[48]=pe);let me=pe,he=!!(I&&z&&y===P&&ie.isFetching),ge;t[49]!==q.data||t[50]!==l?(ge=q.data&&q.data.length>Va?`${q.data.slice(0,Va)}\n\n${l(`mobile.files.file.truncated`)}`:q.data??``,t[49]=q.data,t[50]=l,t[51]=ge):ge=t[51];let _e=ge,ve;t[52]!==k||t[53]!==q.error||t[54]!==u||t[55]!==l?(ve=k&&!u.readFile?l(`mobile.files.error.readUnavailable`):q.error?q.error instanceof Error?q.error.message:l(`filesView.error.readFileFailed`):null,t[52]=k,t[53]=q.error,t[54]=u,t[55]=l,t[56]=ve):ve=t[56];let ye=ve,be=K&&q.isFetching,xe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(xe=e=>{b(``),_({type:`browser`,directory:e})},t[57]=xe):xe=t[57];let Se=xe,Ce;t[58]!==D||t[59]!==m?(Ce=e=>{_({type:`file`,path:e,returnDirectory:D||m})},t[58]=D,t[59]=m,t[60]=Ce):Ce=t[60];let we=Ce,Te;t[61]!==s||t[62]!==n||t[63]!==g.returnDirectory||t[64]!==g.type?(Te=()=>g.type===`file`?s?(n?.(),!0):(_({type:`browser`,directory:g.returnDirectory}),!0):!1,t[61]=s,t[62]=n,t[63]=g.returnDirectory,t[64]=g.type,t[65]=Te):Te=t[65];let Ee=R(Te),J=g.type===`file`,De;t[66]!==Ee||t[67]!==J?(De={id:`mobile-files-detail`,active:J,layer:`overlay`,onBack:Ee,surfaceRef:v},t[66]=Ee,t[67]=J,t[68]=De):De=t[68],Tn(De);let Oe;t[69]===l?Oe=t[70]:(Oe=async e=>{(await B(e)).ok||Y.error(l(`mobile.files.toast.copyFailed`))},t[69]=l,t[70]=Oe);let ke=Oe,Ae;t[71]!==_e||t[72]!==l?(Ae=async()=>{(await B(_e)).ok?Y.success(l(`mobile.files.toast.contentCopied`)):Y.error(l(`mobile.files.toast.copyFailed`))},t[71]=_e,t[72]=l,t[73]=Ae):Ae=t[73];let je=Ae;if(!m){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)(io,{message:e}),t[76]=e,t[77]=n),n}if(g.type===`file`){let e;t[78]!==ke||t[79]!==g.path?(e=()=>void ke(g.path),t[78]=ke,t[79]=g.path,t[80]=e):e=t[80];let n;t[81]===je?n=t[82]:(n=()=>void je(),t[81]=je,t[82]=n);let r;return t[83]!==Ee||t[84]!==_e||t[85]!==ye||t[86]!==c||t[87]!==A||t[88]!==be||t[89]!==g.path||t[90]!==e||t[91]!==n?(r=(0,$.jsx)(`div`,{ref:v,className:`flex h-full min-h-0 flex-col`,children:(0,$.jsx)(to,{path:g.path,content:_e,error:ye,isLoading:be,hideHeader:c,htmlViewMode:A,onHtmlViewModeChange:j,onBack:Ee,onCopyPath:e,onCopyContent:n})}),t[83]=Ee,t[84]=_e,t[85]=ye,t[86]=c,t[87]=A,t[88]=be,t[89]=g.path,t[90]=e,t[91]=n,t[92]=r):r=t[92],r}let Me;t[93]!==m||t[94]!==g.directory||t[95]!==l?(Me=g.directory===m?l(`mobile.files.rootDirectory`):Ua(g.directory),t[93]=m,t[94]=g.directory,t[95]=l,t[96]=Me):Me=t[96];let Ne=Me,Pe;t[97]!==y||t[98]!==me?(Pe=y.trim()?me:[],t[97]=y,t[98]=me,t[99]=Pe):Pe=t[99];let Fe=Pe,Ie,Le,Re,ze;if(t[100]!==n||t[101]!==y||t[102]!==m||t[103]!==g.directory||t[104]!==l){let e=Wa(g.directory),r=g.directory!==m&&e!==null&&(e===m||e.startsWith(`${m}/`)),i=r&&!y.trim(),a=r?e:null;ze=`flex h-full flex-col overflow-hidden bg-background text-foreground`,Ie=`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[109]!==n||t[110]!==l?(Le=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)(Z,{name:`close`,className:`size-5`})}):null,t[109]=n,t[110]=l,t[111]=Le):Le=t[111],Re=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:Ua(a)}),onClick:()=>Se(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`arrow-left`,className:`size-5`})}):null,t[100]=n,t[101]=y,t[102]=m,t[103]=g.directory,t[104]=l,t[105]=Ie,t[106]=Le,t[107]=Re,t[108]=ze}else Ie=t[105],Le=t[106],Re=t[107],ze=t[108];let Be;t[112]===Ne?Be=t[113]:(Be=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:Ne})}),t[112]=Ne,t[113]=Be);let Ve;t[114]===l?Ve=t[115]:(Ve=l(`mobile.files.refreshAria`),t[114]=l,t[115]=Ve);let He;t[116]===ne?He=t[117]:(He=()=>void ne.refetch(),t[116]=ne,t[117]=He);let Ue;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(Ue={touchAction:`manipulation`},t[118]=Ue):Ue=t[118];let We=fe&&`animate-spin`,Ge;t[119]===We?Ge=t[120]:(Ge=X(`size-5`,We),t[119]=We,t[120]=Ge);let Ke;t[121]===Ge?Ke=t[122]:(Ke=(0,$.jsx)(Z,{name:`refresh`,className:Ge}),t[121]=Ge,t[122]=Ke);let qe;t[123]!==Ve||t[124]!==He||t[125]!==Ke?(qe=(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":Ve,onClick:He,style:Ue,children:Ke}),t[123]=Ve,t[124]=He,t[125]=Ke,t[126]=qe):qe=t[126];let Je;t[127]!==Ie||t[128]!==Le||t[129]!==Re||t[130]!==Be||t[131]!==qe?(Je=(0,$.jsxs)(`header`,{className:Ie,children:[Le,Re,Be,qe]}),t[127]=Ie,t[128]=Le,t[129]=Re,t[130]=Be,t[131]=qe,t[132]=Je):Je=t[132];let Ye;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=(0,$.jsx)(Z,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[133]=Ye):Ye=t[133];let Xe;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=e=>b(e.target.value),t[134]=Xe):Xe=t[134];let Ze;t[135]===l?Ze=t[136]:(Ze=l(`mobile.files.search.placeholder`),t[135]=l,t[136]=Ze);let Qe;t[137]!==y||t[138]!==Ze?(Qe=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[Ye,(0,$.jsx)(Xt,{type:`text`,inputMode:`search`,value:y,onChange:Xe,placeholder:Ze,className:`h-11 pl-9`})]})}),t[137]=y,t[138]=Ze,t[139]=Qe):Qe=t[139];let $e=Pn,et=de?(0,$.jsx)(io,{message:de}):y.trim()?(0,$.jsx)($a,{results:Fe,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)(Qa,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:Ka(e.size),onClick:()=>e.isDirectory?Se(e.path):we(e.path)},e.path))]}),tt;t[140]!==$e||t[141]!==et?(tt=(0,$.jsx)($e,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:et}),t[140]=$e,t[141]=et,t[142]=tt):tt=t[142];let nt;return t[143]!==ze||t[144]!==Je||t[145]!==Qe||t[146]!==tt?(nt=(0,$.jsxs)(`div`,{className:ze,children:[Je,Qe,tt]}),t[143]=ze,t[144]=Je,t[145]=Qe,t[146]=tt,t[147]=nt):nt=t[147],nt},Qa=e=>{let t=(0,Mi.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)(Z,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(jt,{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)(Z,{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},$a=e=>{let t=(0,Mi.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=ee(),o=Ha(Bn()??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)(io,{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)(io,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(Qa,{name:Ua(e.path),path:e.path,directory:!1,meta:Ga(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},eo=e=>{let t=(0,Mi.c)(24),{path:n,htmlViewMode:r,htmlFullscreen:i,onToggleHtmlViewMode:a,onEnterHtmlFullscreen:o,onCopyPath:s,onCopyContent:c}=e,{t:l}=ee(),u;t[0]===n?u=t[1]:(u=zn(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)($e,{type:`button`,variant:`ghost`,size:`icon`,onClick:a,"aria-label":l(r===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(Z,{name:r===`preview`?`file-code`:`eye`,className:`size-4`})}),i?null:(0,$.jsx)($e,{type:`button`,variant:`ghost`,size:`icon`,onClick:o,"aria-label":l(`mobile.files.html.fullscreenAria`),children:(0,$.jsx)(Z,{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=!Ln(n)&&!d?(0,$.jsx)($e,{type:`button`,variant:`ghost`,size:`icon`,onClick:c,"aria-label":l(`mobile.files.copyContentAria`),children:(0,$.jsx)(Z,{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)(Z,{name:`clipboard`,className:`size-4`}),t[16]=h):h=t[16];let g;t[17]!==s||t[18]!==m?(g=(0,$.jsx)($e,{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],_},to=e=>{let n=(0,Mi.c)(100),{path:o,content:s,error:c,isLoading:l,hideHeader:u,htmlViewMode:d,onHtmlViewModeChange:f,onBack:p,onCopyPath:m,onCopyContent:g}=e,_=u!==void 0&&u,{t:v}=ee(),y=Q.useRef(null),b=Ln(o)&&!o.toLowerCase().endsWith(`.svg`)?o:``,x;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=i(),n[0]=x):x=n[0];let S=x,C;n[1]===b?C=n[2]:(C=b&&t()?`${S}|${b}`:``,n[1]=b,n[2]=C);let w=C,T=b&&!w?`${S}|${b}`:``,[E,D]=Q.useState(``),[O,k]=Q.useState(``),[A,j]=Q.useState(null),[M,N]=Q.useState(!1),P;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(P={open:!1,title:``,content:``},n[3]=P):P=n[3];let[F,I]=Q.useState(P),L,z;n[4]===T?(L=n[5],z=n[6]):(L=()=>{if(!T){D(``);return}let e=!1;return D(``),a(r()).then(t=>{!e&&t&&D(T)}).catch(co),()=>{e=!0}},z=[T],n[4]=T,n[5]=L,n[6]=z),Q.useEffect(L,z);let B,V;n[7]!==b||n[8]!==w||n[9]!==v?(B=()=>{if(!w){k(``),j(null),N(!1);return}let e=!1,t=``;return k(``),j(null),N(!0),h(`/api/fs/raw`,{query:{path:b}}).then(async e=>{if(!e.ok)throw Error(v(`filesView.error.readFileFailed`));return e.blob()}).then(n=>{if(t=URL.createObjectURL(n),e){URL.revokeObjectURL(t);return}k(t)}).catch(t=>{e||j(t instanceof Error?t.message:v(`filesView.error.readFileFailed`))}).finally(()=>{e||N(!1)}),()=>{e=!0,t&&URL.revokeObjectURL(t)}},V=[b,w,v],n[7]=b,n[8]=w,n[9]=v,n[10]=B,n[11]=V):(B=n[10],V=n[11]),Q.useEffect(B,V);let H=!!(T&&E!==T),te;n[12]!==H||n[13]!==o||n[14]!==w||n[15]!==O?(te=w?O:H?``:qa(o),n[12]=H,n[13]=o,n[14]=w,n[15]=O,n[16]=te):te=n[16];let ne=te,U=c??A,W;n[17]===o?W=n[18]:(W=Ua(o),n[17]=o,n[18]=W);let re=W,ie;n[19]!==s||n[20]!==o?(ie=Ln(o)?`data:${Rn(o)};utf8,${encodeURIComponent(s)}`:``,n[19]=s,n[20]=o,n[21]=ie):ie=n[21];let G=ie,K;n[22]!==s||n[23]!==G||n[24]!==ne||n[25]!==o?(K=ne||(Ln(o)&&s?G:``),n[22]=s,n[23]=G,n[24]=ne,n[25]=o,n[26]=K):K=n[26];let ae=K,oe;n[27]!==re||n[28]!==b||n[29]!==o||n[30]!==ae?(oe=()=>{let e=b||ae;e&&I({open:!0,title:re,content:``,metadata:{tool:`image-preview`,filename:re,mime:Rn(o)},image:{url:e,mimeType:Rn(o),filename:re}})},n[27]=re,n[28]=b,n[29]=o,n[30]=ae,n[31]=oe):oe=n[31];let q=R(oe),se;n[32]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>{I(t=>t.open===e?t:{...t,open:e})},n[32]=se):se=n[32];let ce=R(se),le;n[33]===o?le=n[34]:(le=zn(o),n[33]=o,n[34]=le);let ue=le,[de,fe]=Q.useState(!1),pe=Q.useRef(null),me;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>{fe(!1)},n[35]=me):me=n[35];let he;n[36]===o?he=n[37]:(he=[o],n[36]=o,n[37]=he),Q.useEffect(me,he);let ge;n[38]!==d||n[39]!==f?(ge=()=>{f(d===`preview`?`source`:`preview`)},n[38]=d,n[39]=f,n[40]=ge):ge=n[40];let _e=R(ge),ve;n[41]===Symbol.for(`react.memo_cache_sentinel`)?(ve=()=>{fe(!0)},n[41]=ve):ve=n[41];let ye=R(ve),be;n[42]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>(fe(!1),!0),n[42]=be):be=n[42];let xe=R(be),Se=ue&&de,Ce;n[43]!==xe||n[44]!==Se?(Ce={id:`mobile-html-fullscreen`,active:Se,layer:`overlay`,onBack:xe,surfaceRef:pe},n[43]=xe,n[44]=Se,n[45]=Ce):Ce=n[45],Tn(Ce);let we;n[46]!==ye||n[47]!==de||n[48]!==d||n[49]!==g||n[50]!==m||n[51]!==o||n[52]!==_e?(we=(0,$.jsx)(eo,{path:o,htmlViewMode:d,htmlFullscreen:de,onToggleHtmlViewMode:_e,onEnterHtmlFullscreen:ye,onCopyPath:m,onCopyContent:g}),n[46]=ye,n[47]=de,n[48]=d,n[49]=g,n[50]=m,n[51]=o,n[52]=_e,n[53]=we):we=n[53];let Te=we,Ee;n[54]!==s||n[55]!==c||n[56]!==d||n[57]!==l||n[58]!==o||n[59]!==v?(Ee=d===`source`?l?(0,$.jsx)(io,{loading:!0,message:v(`filesView.state.loading`)}):c?(0,$.jsx)(io,{message:c}):(0,$.jsx)(ro,{path:o,content:s}):(0,$.jsx)(no,{path:o}),n[54]=s,n[55]=c,n[56]=d,n[57]=l,n[58]=o,n[59]=v,n[60]=Ee):Ee=n[60];let J=Ee,De;n[61]!==xe||n[62]!==ue||n[63]!==J||n[64]!==de||n[65]!==d||n[66]!==re||n[67]!==v||n[68]!==_e?(De=ue?(0,$.jsxs)(`div`,{ref:pe,"data-mobile-html-preview":d===`preview`&&!de?`true`:void 0,"data-mobile-html-fullscreen":d===`preview`&&de?`true`:void 0,className:de?`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:[de?(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)($e,{type:`button`,variant:`ghost`,size:`icon`,onClick:xe,"aria-label":v(`mobile.files.html.exitFullscreenAria`),className:`shrink-0 text-muted-foreground`,children:(0,$.jsx)(Z,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-header text-foreground`,children:re}),(0,$.jsx)($e,{type:`button`,variant:`ghost`,size:`icon`,onClick:_e,"aria-label":v(d===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(Z,{name:d===`preview`?`file-code`:`eye`,className:`size-4`})})]}):null,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden bg-background`,children:J})]}):null,n[61]=xe,n[62]=ue,n[63]=J,n[64]=de,n[65]=d,n[66]=re,n[67]=v,n[68]=_e,n[69]=De):De=n[69];let Oe=De,ke;n[70]!==Te||n[71]!==_||n[72]!==re||n[73]!==p||n[74]!==v?(ke=_?(0,$.jsx)(Mt,{children:Te}):(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":v(`header.actions.backAria`),onClick:p,children:(0,$.jsx)(Z,{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:re})}),Te]}),n[70]=Te,n[71]=_,n[72]=re,n[73]=p,n[74]=v,n[75]=ke):ke=n[75];let Ae;n[76]!==s||n[77]!==ue||n[78]!==de||n[79]!==Oe||n[80]!==H||n[81]!==U||n[82]!==re||n[83]!==l||n[84]!==M||n[85]!==q||n[86]!==o||n[87]!==ae||n[88]!==v?(Ae=ue?de&&typeof document<`u`?(0,xa.createPortal)(Oe,document.body):Oe:l||H||M?(0,$.jsx)(io,{loading:!0,message:v(`filesView.state.loading`)}):U?(0,$.jsx)(io,{message:U}):Ln(o)&&ae?(0,$.jsx)(Pn,{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:q,"aria-label":re,children:(0,$.jsx)(`img`,{src:ae,alt:re,className:`mx-auto max-h-full max-w-full rounded-lg object-contain`,draggable:!1})})}):(0,$.jsx)(ro,{path:o,content:s}),n[76]=s,n[77]=ue,n[78]=de,n[79]=Oe,n[80]=H,n[81]=U,n[82]=re,n[83]=l,n[84]=M,n[85]=q,n[86]=o,n[87]=ae,n[88]=v,n[89]=Ae):Ae=n[89];let je;n[90]===Ae?je=n[91]:(je=(0,$.jsx)(`div`,{ref:y,className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:Ae}),n[90]=Ae,n[91]=je);let Me;n[92]===Symbol.for(`react.memo_cache_sentinel`)?(Me=(0,$.jsx)(yt,{containerRef:y}),n[92]=Me):Me=n[92];let Ne;n[93]!==ce||n[94]!==F?(Ne=F.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ba,{popup:F,onOpenChange:ce,isMobile:!0})}):null,n[93]=ce,n[94]=F,n[95]=Ne):Ne=n[95];let Pe;return n[96]!==ke||n[97]!==je||n[98]!==Ne?(Pe=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[ke,je,Me,Ne]}),n[96]=ke,n[97]=je,n[98]=Ne,n[99]=Pe):Pe=n[99],Pe},no=e=>{let n=(0,Mi.c)(29),{path:i}=e,{t:o}=ee(),c;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=t(),n[0]=c):c=n[0];let l=c,u=Q.useRef(null),[d,p]=Q.useState(``),[m,g]=Q.useState(0),[_,v]=Q.useState(null),[y,b]=Q.useState(``),x,S;n[1]!==i||n[2]!==o?(x=()=>{let e=!1;if(p(``),v(null),b(``),l)return h(Ya(i)).then(async e=>{if(!e.ok)throw Error(o(`filesView.error.readFileFailed`));return e.text()}).then(t=>{e||(b(t),p(i))}).catch(t=>{e||(v(t instanceof Error?t.message:o(`filesView.error.readFileFailed`)),p(i))}),()=>{e=!0};let t=r(),n=f(t);a(t).then(t=>{e||!t||(p(i),v(null))}).catch(t=>{e||(v(t instanceof Error?t.message:o(`filesView.error.readFileFailed`)),p(i))});let c=s(()=>{e||(p(i),g(lo),v(null))});return()=>{e=!0,n(),c()}},S=[i,l,o],n[1]=i,n[2]=o,n[3]=x,n[4]=S):(x=n[3],S=n[4]),Q.useEffect(x,S);let C;n[5]!==i||n[6]!==d?(C=()=>{if(d!==i)return;let e=u.current;if(e)return za(e)},n[5]=i,n[6]=d,n[7]=C):C=n[7];let w;if(n[8]!==m||n[9]!==i||n[10]!==d||n[11]!==y?(w=[m,i,d,y],n[8]=m,n[9]=i,n[10]=d,n[11]=y,n[12]=w):w=n[12],Q.useEffect(C,w),_){let e;return n[13]===_?e=n[14]:(e=(0,$.jsx)(io,{message:_}),n[13]=_,n[14]=e),e}if(d!==i){let e;n[15]===o?e=n[16]:(e=o(`filesView.state.loading`),n[15]=o,n[16]=e);let t;return n[17]===e?t=n[18]:(t=(0,$.jsx)(io,{loading:!0,message:e}),n[17]=e,n[18]=t),t}let T;n[19]===i?T=n[20]:(T=l?void 0:Xa(i),n[19]=i,n[20]=T);let E=l?y:void 0,D;n[21]===Symbol.for(`react.memo_cache_sentinel`)?(D={backgroundColor:`var(--surface-background)`},n[21]=D):D=n[21];let O;n[22]===o?O=n[23]:(O=o(`filesView.editor.htmlPreviewTitle`),n[22]=o,n[23]=O);let k;return n[24]!==m||n[25]!==T||n[26]!==E||n[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},m)}),n[24]=m,n[25]=T,n[26]=E,n[27]=O,n[28]=k):k=n[28],k},ro=e=>{let t=(0,Mi.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=un(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??mn(!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)??mn(!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=()=>{An(l),An(d)},p=[d,l],t[6]=d,t[7]=l,t[8]=f,t[9]=p):(f=t[8],p=t[9]),Q.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(Ja(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Pn,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(Mn,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=Ua(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=In(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:wr},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)(Pn,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(I,{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},io=e=>{let t=(0,Mi.c)(7),{message:n,loading:r}=e,i=r!==void 0&&r,a;t[0]===i?a=t[1]:(a=i?(0,$.jsx)(Z,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(Z,{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 ao(e){return e.pendingFileFocusPath}function oo(e){return e.setPendingFileFocusPath}function so(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}function co(){}function lo(e){return e+1}var uo=b(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),fo=b()(x(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:g()}));typeof window<`u`&&n(e=>{u(e)&&fo.persist.rehydrate()});var po=36,mo=18,ho=e=>e.parentID??null,go=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),_o=e=>{let t=e;return go(t.directory??t.project?.worktree??null)},vo=e=>{let t=go(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},yo=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},bo=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),xo=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))},So=(e,t)=>{let n=go(e),r=go(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},Co=(e,t)=>e.worktrees.find(e=>go(e.path)===t)??null,wo=(e,t)=>t===e.path||!!Co(e,t),To=(e,t)=>{let n=go(t);return n?e.find(e=>wo(e,n))??null:null},Eo=(e,t,n)=>!n||`${e.title??``} ${e.id} ${_o(e)} ${t}`.toLowerCase().includes(n),Do=e=>{let t=(0,Mi.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?Gt[n.icon]:null,c=n.color?qt[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)(Z,{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=X(`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)(Ut,{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},Oo=e=>{let t=(0,Mi.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=X(`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)(Z,{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},ko=e=>{let t=(0,Mi.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},Ao=e=>{let t=(0,Mi.c)(12),{onClick:n,className:r}=e,{t:i}=ee(),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=X(`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)(Z,{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},jo=e=>{let t=(0,Mi.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)(Z,{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)($e,{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},Mo=e=>{let t=(0,Mi.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}=ee(),x;t[0]===n?x=t[1]:(x=xo(yo(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=X(`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)(Z,{name:`arrow-down-s`,className:X(`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=X(`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=X(`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=X(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),I=g?dt(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 V;t[56]!==F||t[57]!==I?(V=(0,$.jsx)(`span`,{className:F,children:I}),t[56]=F,t[57]=I,t[58]=V):V=t[58];let H;t[59]===S?H=t[60]:(H=S?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:S}):null,t[59]=S,t[60]=H);let te;t[61]!==V||t[62]!==H||t[63]!==L||t[64]!==R?(te=(0,$.jsxs)(`span`,{className:L,children:[R,V,H]}),t[61]=V,t[62]=H,t[63]=L,t[64]=R,t[65]=te):te=t[65];let ne;t[66]!==a||t[67]!==g?(ne=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?dt(a,g):a}):null,t[66]=a,t[67]=g,t[68]=ne):ne=t[68];let U;t[69]!==te||t[70]!==ne||t[71]!==z?(U=(0,$.jsxs)(`span`,{className:z,children:[te,ne]}),t[69]=te,t[70]=ne,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 re;t[85]!==p||t[86]!==m?(re=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)(Pr,{})}):null,t[85]=p,t[86]=m,t[87]=re):re=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)(Z,{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)(Z,{name:`close`,className:`size-4`}):(0,$.jsx)(Z,{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 G;return t[94]!==N||t[95]!==P||t[96]!==W||t[97]!==re||t[98]!==ie?(G=(0,$.jsxs)(`div`,{className:N,children:[P,W,re,ie]}),t[94]=N,t[95]=P,t[96]=W,t[97]=re,t[98]=ie,t[99]=G):G=t[99],G},No=e=>{let t=(0,Mi.c)(15),{indent:n,showMore:r,showFewer:i,loadingMore:a,onShowMore:o,onShowFewer:s}=e,c=a!==void 0&&a,{t:l}=ee();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)(Z,{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:X(`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)(Z,{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},Po=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=ee(),{git:i}=hn(),a=se(),o=ke(e=>e.activeSessions),s=ke(e=>e.activePaginationByDirectory),c=Me(e=>e.projects),l=Me(e=>e.activeProjectId),u=T(e=>e.currentDirectory),d=J(e=>e.currentSessionId),f=J(e=>e.availableWorktreesByProject),p=J(e=>e.setCurrentSession),m=J(e=>e.archiveSession),h=J(e=>e.archiveSessions),g=J(e=>e.updateSessionTitle),_=J(e=>e.requestSessionSmartTitle),v=J(e=>e.shareSession),y=J(e=>e.unshareSession),b=J(e=>e.openNewSessionDraft),x=Me(e=>e.setActiveProject),S=Me(e=>e.setActiveProjectIdOnly),C=Me(e=>e.removeProject),w=Ae(),E=Re(),D=fo(e=>e.projectExpanded),O=fo(e=>e.worktreeExpanded),k=fo(e=>e.setProjectExpanded),A=fo(e=>e.setWorktreeExpanded),j=Et(e=>e.orderByProject),M=uo(e=>e.expandedParents),N=uo(e=>e.toggleParent),[P,F]=Q.useState(``),[I,L]=Q.useState(null),[z,V]=Q.useState(null),[H,te]=Q.useState(0),[ne,U]=Q.useState(!1),[W,re]=Q.useState(!1),[ie,G]=Q.useState(null),[K,ae]=Q.useState(null),[oe,ce]=Q.useState(null),[le,ue]=Q.useState(null),[de,fe]=Q.useState(null),[pe,he]=Q.useState(``),[ge,_e]=Q.useState(!1),[ve,ye]=Q.useState(null),xe=Q.useRef(null);xe.current||=Vn({onPressedKeyChange:ue});let[Se,Ce]=Q.useState(new Set),[we,Ee]=Q.useState(new Map),[De,Oe]=Q.useState(new Map),je=mr(),Ne=Sr(),Pe=R(e=>{me(e),q(e)}),Ie=R(e=>{Promise.all(e.map(e=>(me(e),q(e))))});Q.useEffect(()=>{if(!e){F(``),Oe(new Map),L(null),V(null),ae(null),fe(null),ye(null),xe.current?.reset();return}},[e]),Q.useEffect(()=>()=>{xe.current?.reset()},[]),Q.useEffect(()=>{if(!e)return;if(c.length===0){J.setState(e=>{let t=pr(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),Ce(e=>e.size===0?e:new Set),Ee(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(c.map(async e=>{let n=go(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([Jt({id:e.id,path:n},{isCurrent:()=>!t}),Wt(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(c.map(e=>go(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);J.setState(e=>{let t=pr(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),Ce(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 bo(r,t)?t:r}),Ee(t=>{let n=new Set(c.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,c,H]);let Le=Q.useMemo(()=>c.map(e=>({id:e.id,label:vo(e.path),path:go(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:Se.has(go(e.path)),worktrees:wt(j[e.id],f.get(go(e.path))??[])})),[Se,c,j,f]),ze=Q.useMemo(()=>{let e=new Map(a.map(e=>[e.id,e])),t=o.map(t=>{let n=e.get(t.id);return n?Te(n,t):t}),n=new Set(t.map(e=>e.id));for(let e of a)n.has(e.id)||t.push(e);return t},[o,a]),Be=P.trim().toLowerCase(),Ve=Q.useMemo(()=>{let e=Le.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===l})),t=(e,t,n)=>{let r=go(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||vo(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 ze){let r=_o(n);if(!r)continue;let i=go(r),a=e.find(e=>wo(e.project,i));if(!a)continue;let o=Co(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)=>be(t)-be(e));for(let n of e.sessions)ho(n)||(t.totalSessions+=1)}return e},[l,Le,ze]),Ue=go(u),We=e=>e.isActive?Ue===e.project.path?e.project.path:e.project.worktrees.find(e=>So(Ue,e.path))?.path??e.project.path:null,Ge=e=>D[e.project.id]??!0,Ke=(e,t)=>O[`${e.project.id}::${t.key}`]??!1,qe=e=>{Oe(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},Je=()=>{ae(null),xe.current?.reset()},Ye=e=>({pressed:le===e.key||K?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||xe.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>ae(e)})},onPointerMove:e=>{xe.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{xe.current?.end(e.pointerId)},onPointerCancel:e=>{xe.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),xe.current?.openFromContextMenu(e.key,()=>ae(e))}}),Xe=(e,t)=>{xe.current?.consumeClick(e)||t()},Ze=(e,t,n,r)=>{let i=Yr(),a=br();if(Oe(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=go(t);if(!o)return;let s=ke.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&Fe(o)},Qe=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=Yr(),o=new Set(t.sessions.map(e=>e.id)),c=new Map;for(let e of t.sessions){let t=ho(e);if(t&&o.has(t)){let n=c.get(t)??[];n.push(e),c.set(t,n)}}let l=t.sessions.filter(e=>!ho(e)),u=De.get(i)??a,f=_r(l,u,Ne),p=l.length-f.length,m=s.get(go(t.path)),h=m?.hasMore===!0,g=m?.loadingMore===!0,_=l.length>a&&u>a,v=(e,t)=>{let n=c.get(e.id)??[],i=n.length>0,a=!!M[e.id],o=je.has(e.id),s=i&&!a?n.filter(e=>je.has(e.id)).map(e=>e.id):[],l=s.length>0,u=o?[e.id,...s]:s,f=e.title?.trim()||r(`mobile.sessions.untitled`),p=`session:${e.id}`;return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(Mo,{session:e,active:d===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>N(e.id):void 0,confirmingArchive:z===e.id,onSelect:()=>Xe(p,()=>nt(e)),onRequestArchive:()=>rt(e.id),onConfirmArchive:()=>void it(e),onStop:o||l?()=>Ie(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:f}),longPressHandlers:Ye({key:p,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+mo)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[f.map(e=>v(e,n)),(0,$.jsx)(No,{indent:n,showMore:p>0||h,showFewer:_,loadingMore:g,onShowMore:()=>Ze(i,t.path,u,l.length),onShowFewer:()=>qe(i)})]})},et=(e,t)=>{k(e,!t)},tt=(e,t,n)=>{A(`${e}::${t}`,!n)},nt=e=>{Ht();let n=_o(e)||null,r=To(Le,n??``);r&&S(r.id),p(e.id,n),t(!1)},rt=e=>{V(t=>t===e?null:e)},it=async e=>{V(null),await m(e.id)?ur({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`))},at=()=>{b(),t(!1)},ot=e=>{G(e),S(e),re(!0)},st=e=>{let t=new Map;for(let e of ze){let n=ho(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},ct=async e=>{let t=st(e.id),{archivedIds:n,failedIds:i}=await h(t);n.length>0&&ur({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}))},lt=e=>{let t=st(e.id);Fr({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`)})},ut=async e=>{try{if(!(await v(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`))}},ft=async e=>{if((await B(e)).ok){Y.success(r(`sessions.sidebar.session.menu.copied`));return}Y.error(r(`sessions.sidebar.session.share.copyUrlError`))},pt=async e=>{try{if(await y(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`))}},mt=async()=>{if(!de)return;let e=pe.trim();if(e)try{await g(de.id,e),fe(null),he(``)}catch{Y.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},gt=async()=>{if(!de||ge)return;let e=de.id;fe(null),he(``),_e(!0);try{await _(e)}catch{Y.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{_e(!1)}},_t=(e,n)=>{S(e.id),b({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},vt=e=>{(async()=>{try{await Jt({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=J.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await He(n,ze)})()},yt=e=>{let t=_o(e),n=To(Le,t);if(!n)return vo(t)||t;let r=Co(n,go(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},bt=e=>{x(e.id),t(!1)},St=Q.useMemo(()=>Be?Ve.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Be)?!0:e.buckets.some(t=>t.sessions.some(t=>Eo(t,e.project.label,Be)))):Ve,[Be,Ve]),Ct=Q.useMemo(()=>Be?ze.filter(e=>{let t=_o(e);return Eo(e,To(Le,t)?.label??``,Be)}).sort((e,t)=>be(t)-be(e)):[],[Be,Le,ze]),Tt=Q.useMemo(()=>Be?Le.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Be)).map(e=>({...e,sessionCount:ze.filter(t=>!ho(t)&&wo(e,go(_o(t)))).length})):[],[Be,Le,ze]),Dt=Be&&Ct.length===0&&Tt.length===0,Ot=Le.length>0?(0,$.jsxs)($e,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:at,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Z,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,kt=Le.find(e=>e.id===l)??null,At=kt?.isGitRepo?(0,$.jsx)($e,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>ot(kt.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`node-tree`,className:`size-4`})}):null,jt=(0,$.jsx)($e,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>U(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`})}),Mt=Ot||jt?(0,$.jsxs)($.Fragment,{children:[Ot,At,jt]}):null,Nt=K?.kind===`project`?K.project.label:K?.kind===`worktree`?K.worktree.branch||K.worktree.label||K.worktree.path:K?.kind===`session`?K.session.title?.trim()||r(`mobile.sessions.untitled`):``,Pt=Q.useMemo(()=>{if(!K)return[];if(K.kind===`project`){let e=K.project;return Or({gitRepository:e.isGitRepo,onNewSession:()=>{Je(),_t(e,e.path)},onNewWorktree:()=>{Je(),ot(e.id)},onSyncSessions:()=>{Je(),vt(e)},onEditProject:()=>{Je(),L(e.id)},onCloseProject:()=>{Je(),ce(e)}})}if(K.kind===`worktree`){let{project:e,worktree:t}=K;return yr({onNewSession:()=>{Je(),_t(e,t.path)},onDeleteWorktree:()=>{Je(),ye({project:e,worktree:t})}})}let e=K.session,t=!!e.share?.url;return Xr({pinned:w.has(e.id),shared:t,onRename:()=>{Je(),he(e.title?.trim()||r(`mobile.sessions.untitled`)),fe(e)},onTogglePin:()=>{Je(),E(e.id)},onShare:t?void 0:()=>{Je(),ut(e)},onCopyLink:t?()=>{let t=e.share?.url;Je(),t&&ft(t)}:void 0,onUnshare:t?()=>{Je(),pt(e.id)}:void 0,onArchive:()=>{Je(),ct(e)},onDelete:()=>{Je(),lt(e)}})},[K,Je,ct,ft,lt,ot,ut,pt,w,_t,vt,r,E]),Ft=Pt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Pt.map(e=>{let t=(0,$.jsx)(jo,{icon:e.icon,label:dr(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,It=(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)(Z,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Xt,{value:P,onChange:e=>F(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:X(`h-11 pl-9`,P&&`pr-10`)}),P?(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:()=>F(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsx)(Pn,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:Le.length===0?(0,$.jsx)(Fo,{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:()=>U(!0),children:[(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):Dt?(0,$.jsx)(Fo,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Be?(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=je.has(e.id),i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:X(t>0&&`border-t border-border/30`),children:(0,$.jsx)(Mo,{session:e,active:d===e.id,indent:12,contextLabel:yt(e),highlightQuery:Be,onSelect:()=>Xe(`session:${e.id}`,()=>nt(e)),longPressHandlers:Ye({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>Pe(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,Tt.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:Tt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Tt.map((e,t)=>{let n=`project:${e.id}`,r=Ye({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:X(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:X(`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:()=>Xe(n,()=>bt(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Do,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:dt(e.label,Be)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(Ao,{className:`mr-2`,onClick:()=>ot(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:St.map((e,t)=>{let n=Ge(e),i=`project:${e.project.id}`,a=Ye({key:i,kind:`project`,project:e.project}),o=Be?e.buckets.filter(t=>t.sessions.some(t=>Eo(t,e.project.label,Be))):e.buckets,s=We(e);return(0,$.jsxs)(`section`,{className:X(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:X(`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:()=>Xe(i,()=>et(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)(Do,{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}),we.get(e.project.id)?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:we.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(ko,{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=>je.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(),Ie(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Pr,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(Ao,{className:`mr-2`,onClick:()=>ot(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?Qe(e,t,po):null,n.map(t=>{let n=Ke(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Ye({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:X(`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:()=>Xe(a,()=>tt(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)(Oo,{expanded:n}),(0,$.jsx)(Z,{name:`node-tree`,className:X(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:X(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(ko,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>je.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(),Ie(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Pr,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?Qe(e,t,po):null]},t.key)})]})})()}):null]},e.project.id)})})}),(0,$.jsx)(Lr,{open:ne,onOpenChange:U,forceMobile:!0}),(0,$.jsx)(ht,{open:W,projectId:ie,onOpenChange:e=>{re(e),e||G(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?p(n.sessionId,e):b({selectedProjectId:ie,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(xt,{open:!!K,title:Nt,onClose:Je,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Ft}),(0,$.jsx)(xt,{open:!!oe,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>ce(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)($e,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>ce(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)($e,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!oe)return;let e=oe;ce(null),C(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:oe?.label??``})})}),(0,$.jsx)(xt,{open:!!de,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{ge||(fe(null),he(``))},footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)($e,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:ge,onClick:()=>{fe(null),he(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)($e,{type:`button`,variant:`default`,className:`flex-1`,disabled:!pe.trim()||ge,onClick:()=>void mt(),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(),mt()},children:[(0,$.jsx)(Xt,{value:pe,onChange:e=>he(e.target.value),autoFocus:!0,className:`h-12`,disabled:ge}),(0,$.jsxs)($e,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:ge,onClick:()=>void gt(),children:[ge?(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-4`}),r(`sessions.sidebar.session.rename.smartTitle`)]})]})}),ve?(0,$.jsx)(vr,{open:!0,project:{id:ve.project.id,path:ve.project.path},worktree:ve.worktree,onClose:()=>ye(null),onDeleted:()=>te(e=>e+1)}):null,(0,$.jsx)(fr,{open:I!==null,project:Le.find(e=>e.id===I)??null,onClose:()=>L(null),onWorktreesChanged:()=>te(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:Mt?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:Mt}):null}),It]}):null:(0,$.jsx)(Kt,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:Mt,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:It})},Fo=e=>{let t=(0,Mi.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},Io=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,Lo=[{image:ii,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:$r,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 Ro(){let e=(0,Mi.c)(8),{t}=ee(),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 zo(e){let t=(0,Mi.c)(35),{onEnable:n}=e,{t:r}=ee(),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:Io,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)($e,{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=Lo.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 Bo({assistantID:e,displayName:t,avatarEmoji:n,summary:r,enabled:i,editLabel:a,deleteLabel:o,onOpen:s,onEdit:c,onDelete:l}){let u=si(e),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),h=Q.useRef(null);h.current||=Vn({onPressedKeyChange:t=>m(t===e)}),Q.useEffect(()=>()=>h.current?.reset(),[]);let g=R(()=>{h.current?.consumeClick(e)||d||s()}),_=R(()=>{f(!1),c()}),v=R(()=>{f(!1),l()}),y=R(()=>{m(!1),f(!0)}),b=R(t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||h.current?.start({pointerId:t.pointerId,key:e,clientX:t.clientX,clientY:t.clientY,onTrigger:y})}),x=R(e=>{h.current?.move(e.pointerId,e.clientX,e.clientY)}),S=R(e=>{h.current?.end(e.pointerId)}),C=R(e=>{h.current?.cancel(e.pointerId)}),w=R(t=>{t.preventDefault(),t.stopPropagation(),h.current?.openFromContextMenu(e,y)});return(0,$.jsxs)(mi,{open:d,onOpenChange:f,children:[(0,$.jsx)(nr,{"data-mobile-press-surface":`soft`,className:X(`oc-mobile-assistant-card-shell`,p&&`bg-interactive-hover`),children:(0,$.jsxs)(ui,{render:(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-surface-trigger":!0,className:X(`oc-mobile-assistant-card`,!i&&`opacity-65`),onClick:g,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:C,onContextMenu:w,style:{touchAction:`pan-y`}}),children:[(0,$.jsx)(`span`,{className:X(`oc-mobile-assistant-avatar`,n?`oc-mobile-assistant-avatar--emoji`:`oc-mobile-assistant-avatar--visual`),children:(0,$.jsx)(oi,{name:e,emoji:n,size:40,label:t,working:u})}),(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:t}),(0,$.jsx)(`span`,{className:`oc-mobile-assistant-summary text-muted-foreground`,children:r})]})]})}),(0,$.jsxs)(fi,{className:`min-w-[10rem]`,children:[(0,$.jsxs)(pi,{className:`min-h-10 px-3`,onClick:_,children:[(0,$.jsx)(Z,{name:`edit`,className:`size-4`}),a]}),(0,$.jsx)(di,{}),(0,$.jsxs)(pi,{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:v,children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`size-4`}),o]})]})]})}function Vo(e){let t=(0,Mi.c)(102),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=ee(),o=Un(),s=qe(),c=Je(),l=Xe(Ho),[u,d]=Q.useState(null),f;t[0]===n?f=t[1]:(f=()=>n(),t[0]=n,t[1]=f);let p=R(f),m;t[2]!==o||t[3]!==l?(m=()=>{l(),o?.openSettings(`assistants`)},t[2]=o,t[3]=l,t[4]=m):m=t[4];let h=R(m),g;t[5]===r?g=t[6]:(g=e=>r(e),t[5]=r,t[6]=g);let _=R(g),v;t[7]===o?v=t[8]:(v=e=>{Qe(e,o?{openMobileSettings:o.openSettings}:void 0)},t[7]=o,t[8]=v);let y=R(v),b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{d(e)},t[9]=b):b=t[9];let x=R(b),S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{e||d(null)},t[10]=S):S=t[10];let C=R(S),w;t[11]===a?w=t[12]:(w=a(`assistants.title`),t[11]=a,t[12]=w);let T=w,E;t[13]===a?E=t[14]:(E=a(`assistants.menu.edit`),t[13]=a,t[14]=E);let D=E,O;t[15]===a?O=t[16]:(O=a(`assistants.settings.delete`),t[15]=a,t[16]=O);let k=O;if(s.isPending||s.data?.supported&&s.data.enabled&&c.isPending){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(nr,{className:`oc-mobile-assistant-loading`,children:(0,$.jsx)(Ro,{})}),t[17]=e):e=t[17];let n;return t[18]!==i||t[19]!==T?(n=(0,$.jsx)(tr,{title:T,className:i,surface:!1,children:e}),t[18]=i,t[19]=T,t[20]=n):n=t[20],n}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length>0){let e;t[21]===a?e=t[22]:(e=a(`assistants.listAria`),t[21]=a,t[22]=e);let n;if(t[23]!==k||t[24]!==D||t[25]!==y||t[26]!==_||t[27]!==x||t[28]!==c.data.assistants){let e;t[30]!==k||t[31]!==D||t[32]!==y||t[33]!==_||t[34]!==x?(e=e=>{let t=te(e.name),n=t.displayName||e.name,r=e.defaultPrompt.trim();return(0,$.jsx)(Bo,{assistantID:e.id,displayName:n,avatarEmoji:t.avatarEmoji??void 0,summary:r,enabled:e.enabled,editLabel:D,deleteLabel:k,assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onOpen:()=>_(e.id),onEdit:()=>y(e.id),onDelete:()=>x(e)},e.id)},t[30]=k,t[31]=D,t[32]=y,t[33]=_,t[34]=x,t[35]=e):e=t[35],n=c.data.assistants.map(e),t[23]=k,t[24]=D,t[25]=y,t[26]=_,t[27]=x,t[28]=c.data.assistants,t[29]=n}else n=t[29];let r;t[36]!==e||t[37]!==n?(r=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-catalog`,role:`listbox`,"aria-label":e,children:n}),t[36]=e,t[37]=n,t[38]=r):r=t[38];let o=u!==null,s;t[39]!==u||t[40]!==C||t[41]!==o?(s=(0,$.jsx)(ci,{assistant:u,open:o,onOpenChange:C}),t[39]=u,t[40]=C,t[41]=o,t[42]=s):s=t[42];let l;return t[43]!==i||t[44]!==T||t[45]!==r||t[46]!==s?(l=(0,$.jsxs)(tr,{title:T,className:i,surface:!1,scrollsWithPage:!0,children:[r,s]}),t[43]=i,t[44]=T,t[45]=r,t[46]=s,t[47]=l):l=t[47],l}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`oc-mobile-assistant-onboarding-icon`,children:(0,$.jsx)(Z,{name:`ai-agent`,className:`size-5`})}),t[48]=e):e=t[48];let n;t[49]===a?n=t[50]:(n=a(`assistants.onboarding.title`),t[49]=a,t[50]=n);let r;t[51]===n?r=t[52]:(r=(0,$.jsx)(`h2`,{children:n}),t[51]=n,t[52]=r);let o;t[53]===a?o=t[54]:(o=a(`assistants.onboarding.description`),t[53]=a,t[54]=o);let s;t[55]===o?s=t[56]:(s=(0,$.jsx)(`p`,{children:o}),t[55]=o,t[56]=s);let c;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Z,{name:`add`,className:`size-[18px]`}),t[57]=c):c=t[57];let l;t[58]===a?l=t[59]:(l=a(`assistants.onboarding.action`),t[58]=a,t[59]=l);let u;t[60]!==h||t[61]!==l?(u=(0,$.jsxs)($e,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:h,children:[c,l]}),t[60]=h,t[61]=l,t[62]=u):u=t[62];let d;t[63]!==r||t[64]!==s||t[65]!==u?(d=(0,$.jsxs)(nr,{className:`oc-mobile-assistant-onboarding`,children:[e,r,s,u]}),t[63]=r,t[64]=s,t[65]=u,t[66]=d):d=t[66];let f;return t[67]!==i||t[68]!==T||t[69]!==d?(f=(0,$.jsx)(tr,{title:T,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:d}),t[67]=i,t[68]=T,t[69]=d,t[70]=f):f=t[70],f}let A=s.isSuccess&&s.data.supported===!1,j=s.isError||s.data?.supported===!0&&s.data.enabled&&c.isError,M=s.data?.supported===!0&&(s.data.enabled===!1||c.data?.enabled===!1),N;t[71]!==a||t[72]!==j||t[73]!==A?(N=a(j?`assistants.state.unavailable`:A?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[71]=a,t[72]=j,t[73]=A,t[74]=N):N=t[74];let P=N;if(M&&!j){let e;t[75]===p?e=t[76]:(e=(0,$.jsx)(zo,{onEnable:p}),t[75]=p,t[76]=e);let n;return t[77]!==i||t[78]!==T||t[79]!==e?(n=(0,$.jsx)(tr,{title:T,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-guide-host`,children:e}),t[77]=i,t[78]=T,t[79]=e,t[80]=n):n=t[80],n}let F;t[81]===T?F=t[82]:(F=(0,$.jsx)(`span`,{className:`oc-mobile-page-section-label`,children:T}),t[81]=T,t[82]=F);let I=A?`cloud-off`:`sparkling`,L;t[83]===I?L=t[84]:(L=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground`,children:(0,$.jsx)(Z,{name:I,weight:`medium`,className:`size-5`})}),t[83]=I,t[84]=L);let z;t[85]===P?z=t[86]:(z=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:P}),t[85]=P,t[86]=z);let B;t[87]!==a||t[88]!==j||t[89]!==A?(B=j?null:(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-small leading-relaxed text-muted-foreground`,children:a(A?`assistants.state.unsupportedDescription`:`assistants.state.instanceDisabledDescription`)}),t[87]=a,t[88]=j,t[89]=A,t[90]=B):B=t[90];let V;t[91]!==L||t[92]!==z||t[93]!==B?(V=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[L,z,B]}),t[91]=L,t[92]=z,t[93]=B,t[94]=V):V=t[94];let H;t[95]!==F||t[96]!==V?(H=(0,$.jsx)(ar,{label:F,cardClassName:`oc-mobile-assistant-state-card`,children:V}),t[95]=F,t[96]=V,t[97]=H):H=t[97];let ne;return t[98]!==i||t[99]!==T||t[100]!==H?(ne=(0,$.jsx)(tr,{title:T,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:H}),t[98]=i,t[99]=T,t[100]=H,t[101]=ne):ne=t[101],ne}function Ho(e){return e.requestCreate}var Uo=[{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 Wo(e){let t=(0,Mi.c)(17),{activeTab:n,onTabChange:r,className:i}=e,{t:a}=ee(),o;t[0]===r?o=t[1]:(o=e=>{r(e.currentTarget.dataset.tab)},t[0]=r,t[1]=o);let s=R(o),c;t[2]!==n||t[3]!==r?(c=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Uo.findIndex(e=>e.id===n),i=Uo[e.key===`Home`?0:e.key===`End`?Uo.length-1:(t+(e.key===`ArrowRight`?1:-1)+Uo.length)%Uo.length];r(i.id),document.getElementById(`mobile-tab-${i.id}`)?.focus()},t[2]=n,t[3]=r,t[4]=c):c=t[4];let l=R(c),u;t[5]===a?u=t[6]:(u=a(`mobile.nav.aria`),t[5]=a,t[6]=u);let d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d={role:`tablist`},t[7]=d):d=t[7];let f;t[8]!==n||t[9]!==s||t[10]!==l||t[11]!==a?(f=Uo.map(e=>{let t=e.id===n,r=a(e.labelKey);return(0,$.jsxs)($e,{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-selected":t,tabIndex:t?0:-1,title:r,onClick:s,onKeyDown:l,className:X(`oc-mobile-tab-button min-w-0 flex-1 flex-col overflow-hidden`,`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,$.jsx)(Z,{name:e.icon,weight:`medium`,className:`size-[23px] shrink-0`}),(0,$.jsx)(`span`,{className:`block max-w-full overflow-hidden text-ellipsis whitespace-nowrap`,children:r})]},e.id)}),t[8]=n,t[9]=s,t[10]=l,t[11]=a,t[12]=f):f=t[12];let p;return t[13]!==i||t[14]!==u||t[15]!==f?(p=(0,$.jsx)(or,{as:`nav`,"aria-label":u,variant:`navigation`,surfaceProps:d,className:i,children:f}),t[13]=i,t[14]=u,t[15]=f,t[16]=p):p=t[16],p}var Go=`oc-native-ios-tab-bar`,Ko=`OpenChamberTabBar`,qo=[`projects`,`assistant`,`scheduled`,`settings`],Jo=A(Ko),Yo=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function Xo(){return typeof window>`u`?!1:Yo({isCapacitor:D(),platform:k(),pluginAvailable:j.isPluginAvailable(Ko),nativeUiEnabled:En()})}var Zo=e=>e.classList.contains(`dark`)?`dark`:`light`,Qo=()=>xn(`--primary`),$o=e=>typeof e==`string`&&qo.includes(e),es=e=>typeof e==`string`&&$o(e)?e:null,ts=(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),ns=(e,t)=>{e.classList.toggle(Go,t)},rs=(e,t)=>e&&!t,is=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&ts(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},as=()=>Jo,os=`mobile-overlay-root`;function ss(e){let t=(0,Mi.c)(28),n=Sn(),r;t[0]===n?r=t[1]:(r=n&&Xo(),t[0]=n,t[1]=r);let i=r,[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=(0,Q.useRef)(!1),p=(0,Q.useRef)(!1),m=R(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=e.tabs.map(ls).join(`|`),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:Zo(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:Qo(),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(os);e||(e=document.createElement(`div`),e.id=os,document.body.appendChild(e));let t=()=>u(bt(e.children));t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[Dt]}),()=>n.disconnect()},S=[i],t[6]=i,t[7]=x,t[8]=S),(0,Q.useEffect)(x,S);let C;t[9]!==i||t[10]!==m?(C=()=>{if(!i)return;let e=!1,t=as(),n=[];return t.addListener(`tabSelected`,e=>{let t=es(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`&&ns(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,Q.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=as(),r={tabs:e.tabs.map(cs),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=is({visible:rs(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`&&ns(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&ns(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&ns(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,Q.useLayoutEffect)(T,E),!i||s?`web`:a?`native`:`pending`}function cs(e){return{id:e.id,label:e.label}}function ls(e){return`${e.id}:${e.label}`}function us(e){let t=(0,Mi.c)(39),{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}=ee(),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]=Q.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=Q.useRef(null),C=Q.useRef(null),w=Q.useRef(null),T=Q.useRef(new Map),E=Q.useRef(null),D=Q.useRef(!1),O=Q.useRef(``),k=R(()=>h?.onBack());Tn({id:h?`mobile-secondary:${h.key}`:`mobile-secondary:inactive`,active:!!h,onBack:k,surfaceRef:S,underlayRef:C}),Q.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),Q.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=R(j),N;t[6]===f?N=t[7]:(N=Uo.map(e=>({id:e.id,label:f(e.labelKey)})),t[6]=f,t[7]=N);let P=N,F=u&&!d&&!h,I;t[8]===f?I=t[9]:(I=f(`mobile.nav.aria`),t[8]=f,t[9]=I);let L;t[10]!==M||t[11]!==F||t[12]!==P||t[13]!==p||t[14]!==I?(L={visible:F,activeTab:p,tabs:P,ariaLabel:I,onTabChange:M},t[10]=M,t[11]=F,t[12]=P,t[13]=p,t[14]=I,t[15]=L):L=t[15];let z=ss(L),B=z===`native`,V=u&&z===`web`,H=Sn(),te,ne;t[16]!==H||t[17]!==B?(te=()=>{if(!H){kn.shutdown();return}B&&Dn(!0)&&kn.warm()},ne=[H,B],t[16]=H,t[17]=B,t[18]=te,t[19]=ne):(te=t[18],ne=t[19]),Q.useEffect(te,ne);let U;t[20]===c?U=t[21]:(U=X(`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[20]=c,t[21]=U);let W=h?!0:void 0,re=h?!0:void 0,ie;t[22]!==p||t[23]!==u||t[24]!==V||t[25]!==f||t[26]!==n||t[27]!==b?(ie=Uo.map(e=>{let t=b.has(e.id);return(0,$.jsx)(`section`,{id:`mobile-tabpanel-${e.id}`,role:`tabpanel`,"aria-labelledby":V?`mobile-tab-${e.id}`:void 0,"aria-label":V?void 0:f(e.labelKey),hidden:p!==e.id,tabIndex:0,className:X(`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)(ds,{tab:e.id,icon:e.icon}):null},e.id)}),t[22]=p,t[23]=u,t[24]=V,t[25]=f,t[26]=n,t[27]=b,t[28]=ie):ie=t[28];let G;t[29]!==w||t[30]!==W||t[31]!==re||t[32]!==ie?(G=(0,$.jsx)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":W,inert:re,className:`flex h-full min-h-0 flex-1 flex-col`,children:ie}),t[29]=w,t[30]=W,t[31]=re,t[32]=ie,t[33]=G):G=t[33];let K=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||B?!0:void 0,inert:h||B?!0:void 0,children:V?(0,$.jsx)(Wo,{activeTab:p,onTabChange:M}):null}):null,ae=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:X(`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)}),oe;return t[34]!==U||t[35]!==G||t[36]!==K||t[37]!==ae?(oe=(0,$.jsxs)(`div`,{className:U,children:[G,K,ae]}),t[34]=U,t[35]=G,t[36]=K,t[37]=ae,t[38]=oe):oe=t[38],oe}function ds(e){let t=(0,Mi.c)(17),{tab:n,icon:r,className:i}=e,{t:a}=ee(),o,s,c,l;if(t[0]!==i||t[1]!==r||t[2]!==a||t[3]!==n){let e=Uo.find(e=>e.id===n)??Uo[0];t[8]===i?c=t[9]:(c=X(`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)(Z,{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 fs={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)`}},ps=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 ms({project:e,expanded:t,embedded:n=!1,onToggle:r,onOpenActions:i,className:a,highlightQuery:o}){let{t:s}=ee(),[c,l]=Q.useState(!1),u=Q.useRef(null);u.current||=Vn({onPressedKeyChange:t=>l(t===e.id)}),Q.useEffect(()=>()=>u.current?.reset(),[]);let d=R(()=>{u.current?.consumeClick(e.id)||r(e)}),f=R(()=>i?.(e)),p=R(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=R(e=>{u.current?.move(e.pointerId,e.clientX,e.clientY)}),h=R(e=>{u.current?.end(e.pointerId)}),g=R(e=>{u.current?.cancel(e.pointerId)}),_=R(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=ps(e.path),b=(0,$.jsxs)(`article`,{"data-mobile-press-surface":`soft`,"data-pressed":c?`true`:void 0,className:X(`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:X(`oc-mobile-project-icon oc-mobile-glass-control flex shrink-0 items-center justify-center rounded-full text-muted-foreground`),style:fs[e.tone??`neutral`],"aria-hidden":!0,children:(0,$.jsx)(Z,{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?dt(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)(Z,{name:`arrow-down-s`,className:X(`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)($e,{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)(Z,{name:`more-2`,className:`size-4`})}):null]});return n?b:(0,$.jsx)(nr,{asChild:!0,children:b})}var hs=({hasPendingQuestion:e,hasPendingPermission:t,running:n,unread:r})=>e?`question`:t?`permission`:n?`running`:r?`completed-unread`:`idle`,gs=10,_s=`oc:mobile-session-row-revealed`,vs=e=>{window.dispatchEvent(new CustomEvent(_s,{detail:e}))};function ys({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}=ee(),[m,h]=Q.useState(0),[g,_]=Q.useState(!1),v=Q.useRef(null),y=Q.useRef(!1),b=Q.useRef(null),x=Q.useRef(null);x.current||=Vn(),Q.useEffect(()=>()=>x.current?.reset(),[]),Q.useEffect(()=>{let t=t=>{t.detail!==e.id&&h(0)};return window.addEventListener(_s,t),()=>window.removeEventListener(_s,t)},[e.id]),Q.useEffect(()=>{h(0)},[e.id]);let S=R(()=>h(0)),C=m!==0,w=R(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=R(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>gs&&o>a){n.intent=`vertical`,v.current=null,x.current?.cancel(t.pointerId);return}if(a>gs&&a>o){n.intent=`horizontal`,_(!0),y.current=!0,x.current?.cancel(t.pointerId);try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}vs(e.id)}}if(n.intent!==`horizontal`)return;t.preventDefault();let a=Math.max(-n.actionWidth,Math.min(0,n.startOffset+r));h(a)}),E=R(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=R(e=>{let t=v.current;v.current=null,x.current?.cancel(e.pointerId),_(!1),h(t?.startOffset??0)}),O=R(()=>{if(!x.current?.consumeClick(e.id)){if(y.current){y.current=!1;return}if(m!==0){S();return}vs(e.id),o(e)}}),k=R(t=>{t.preventDefault(),t.stopPropagation(),x.current?.openFromContextMenu(e.id,()=>{l(e)})}),A=R(()=>{S(),s(e)}),j=R(()=>{S(),c(e)}),M=R(()=>l(e)),N=R(()=>a?.()),P=e.pinned?p(`sessions.sidebar.session.menu.unpin`):p(`sessions.sidebar.session.menu.pin`),F=u??hs({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:X(`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)(Z,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`})]})}):(0,$.jsxs)(`div`,{className:X(`oc-mobile-session-row relative isolate`,d),children:[(0,$.jsxs)(`div`,{ref:b,className:X(`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)($e,{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)(Z,{name:e.pinned?`unpin`:`pushpin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:P})]}),(0,$.jsxs)($e,{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)(Z,{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:X(`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)($e,{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)(Z,{name:`arrow-down-s`,className:X(`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)(Pr,{className:`motion-reduce:[&_svg]:animate-none`}):F===`question`?(0,$.jsx)(Z,{name:`question`,className:`size-3.5 text-[var(--status-warning)]`}):F===`permission`?(0,$.jsx)(Z,{name:`shield`,className:`size-3.5 text-destructive`}):(0,$.jsx)(`span`,{className:X(`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:X(`oc-mobile-session-title truncate`,e.unread?`font-semibold`:`font-medium`),children:f?dt(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)(Z,{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?dt(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)($e,{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)(Z,{name:`more-2`,className:`size-3.5`})})]})]})}var bs=Q.memo(ys),xs=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e)),Ss=e=>e.catalogSessions??e.sessions,Cs=(e,t)=>e.filter(e=>e.kind!==`pagination`&&xs(t,e.title,e.subtitle,e.id)),ws=(e,t)=>{let n=Ss(e);if(xs(t,e.name,e.path))return{...e,sessions:n.filter(e=>e.kind!==`pagination`)};let r=Cs(n,t);return r.length>0?{...e,sessions:r}:null},Ts=(e,t)=>{let n=t.trim().toLowerCase();return n?e.flatMap(e=>{if(xs(n,e.name,e.path))return[{...e,worktrees:[]}];let t=e.worktrees.flatMap(e=>{let t=ws(e,n);return t?[t]:[]});return t.length>0?[{...e,worktrees:t}]:[]}):e},Es=10,Ds=`oc:mobile-worktree-row-revealed`,Os=e=>{window.dispatchEvent(new CustomEvent(Ds,{detail:e}))};function ks(e){let t=(0,Mi.c)(10),n=ue(e.session.id),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={bootstrap:!1},t[0]=r):r=t[0];let i=Be(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=De(e.session.id,e.session.directory,a).length>0,s=i.length>0,c=n?.type===`busy`||n?.type===`retry`,l=!!e.session.unread,u;t[2]!==o||t[3]!==s||t[4]!==c||t[5]!==l?(u=hs({hasPendingQuestion:o,hasPendingPermission:s,running:c,unread:l}),t[2]=o,t[3]=s,t[4]=c,t[5]=l,t[6]=u):u=t[6];let d=u,f;return t[7]!==d||t[8]!==e?(f=(0,$.jsx)(bs,{...e,indicator:d}),t[7]=d,t[8]=e,t[9]=f):f=t[9],f}var As=Q.memo(ks);function js(e){let t=(0,Mi.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`?bs:As;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 Ms=Q.memo(js);function Ns({project:e,worktree:t,expanded:n,onToggle:r,onNewSession:i,onOpenActions:a,onDelete:o,highlightQuery:s}){let{t:c}=ee(),l=`${e.id}::${t.id}`,u=!!(i||o),d=!!a,f=Number(!!i)+Number(!!o),[p,m]=Q.useState(0),[h,g]=Q.useState(!1),[_,v]=Q.useState(!1),y=Q.useRef(null),b=Q.useRef(!1),x=Q.useRef(null),S=Q.useRef(null);S.current||=Vn({onPressedKeyChange:e=>g(e===l)}),Q.useEffect(()=>()=>S.current?.reset(),[]),Q.useEffect(()=>{let e=e=>{e.detail!==l&&m(0)};return window.addEventListener(Ds,e),()=>window.removeEventListener(Ds,e)},[l]),Q.useEffect(()=>{m(0)},[l]);let C=R(()=>m(0)),w=p!==0,T=R(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=R(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>Es&&a>i){t.intent=`vertical`,y.current=null,S.current?.cancel(e.pointerId);return}if(i>Es&&i>a){t.intent=`horizontal`,v(!0),b.current=!0,S.current?.cancel(e.pointerId);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}Os(l)}}if(t.intent!==`horizontal`)return;e.preventDefault();let i=Math.max(-t.actionWidth,Math.min(0,t.startOffset+n));m(i)}),D=R(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=R(e=>{let t=y.current;y.current=null,S.current?.cancel(e.pointerId),v(!1),m(t?.startOffset??0)}),k=R(()=>{if(!S.current?.consumeClick(l)){if(b.current){b.current=!1;return}if(p!==0){C();return}r()}}),A=R(n=>{d&&(n.preventDefault(),n.stopPropagation(),S.current?.openFromContextMenu(l,()=>{g(!1),a?.(e,t)}))}),j=R(()=>{C(),i?.(e,t)}),M=R(()=>{C(),o?.(e,t)}),N=R(()=>a?.(e,t)),P=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`oc-mobile-group-label-icon`,"aria-hidden":!0,children:(0,$.jsx)(Z,{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?dt(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)(Z,{name:`arrow-down-s`,className:X(`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:X(`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)($e,{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)(Z,{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)($e,{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)(Z,{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:X(`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)($e,{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)(Z,{name:`more-2`,className:`size-3.5`})}):null]})]})}function Ps(e){let t=(0,Mi.c)(132),{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}=ee(),[C,w]=Q.useState(!0),[T,E]=Q.useState(!1),[D,O]=Q.useState(!1),[k,A]=Q.useState(``),j;t[2]===k?j=t[3]:(j=k.trim().toLowerCase(),t[2]=k,t[3]=j);let M=j,N=M.length>0,P;t[4]!==M||t[5]!==n?(P=Ts(n,M),t[4]=M,t[5]=n,t[6]=P):P=t[6];let F=P,I=R(a),L=R(o),z;t[7]===s?z=t[8]:(z=()=>s?.(),t[7]=s,t[8]=z);let B=R(z),V;t[9]===c?V=t[10]:(V=()=>c?.(),t[9]=c,t[10]=V);let H=R(V),te;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>O(e),t[11]=te):te=t[11];let ne=R(te),U;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>{A(``),E(!1)},t[12]=U):U=t[12];let W=R(U),re;t[13]!==W||t[14]!==T?(re=()=>{if(T){W();return}E(!0)},t[13]=W,t[14]=T,t[15]=re):re=t[15];let ie=R(re),G;t[16]!==W||t[17]!==l?(G=e=>{W(),e.expanded||l(e)},t[16]=W,t[17]=l,t[18]=G):G=t[18];let K=R(G),ae;t[19]!==W||t[20]!==l||t[21]!==d?(ae=(e,t)=>{W(),e.expanded||l(e),t.expanded||d(e,t)},t[19]=W,t[20]=l,t[21]=d,t[22]=ae):ae=t[22];let oe=R(ae),q;t[23]!==W||t[24]!==h?(q=e=>{W(),h(e)},t[23]=W,t[24]=h,t[25]=q):q=t[25];let se=R(q),ce;t[26]===y?ce=t[27]:(ce=X(`relative isolate mx-auto flex w-full max-w-[26rem] flex-col gap-5`,y),t[26]=y,t[27]=ce);let le;t[28]===S?le=t[29]:(le=S(`mobile.sessions.section.projects`),t[28]=S,t[29]=le);let ue;t[30]!==T||t[31]!==S?(ue=S(T?`mobile.sessions.clearSearchAria`:`mobile.sessions.searchAria`),t[30]=T,t[31]=S,t[32]=ue):ue=t[32];let de=T?`close`:`search`,fe;t[33]===de?fe=t[34]:(fe=(0,$.jsx)(Z,{name:de,className:`size-5`}),t[33]=de,t[34]=fe);let pe;t[35]!==ie||t[36]!==T||t[37]!==ue||t[38]!==fe?(pe=(0,$.jsx)($e,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":ue,"aria-expanded":T,onClick:ie,children:fe}),t[35]=ie,t[36]=T,t[37]=ue,t[38]=fe,t[39]=pe):pe=t[39];let me;t[40]===S?me=t[41]:(me=S(`mobile.projects.menu.label`),t[40]=S,t[41]=me);let he=D?`rotate-45`:`rotate-0`,ge;t[42]===he?ge=t[43]:(ge=X(`size-5 transition-transform duration-150 motion-reduce:transition-none`,he),t[42]=he,t[43]=ge);let _e;t[44]===ge?_e=t[45]:(_e=(0,$.jsx)(Z,{name:`add`,className:ge}),t[44]=ge,t[45]=_e);let ve;t[46]!==me||t[47]!==_e?(ve=(0,$.jsx)(tn,{asChild:!0,children:(0,$.jsx)($e,{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":me,children:_e})}),t[46]=me,t[47]=_e,t[48]=ve):ve=t[48];let ye;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(Z,{name:`chat-new`,className:`size-4`}),t[49]=ye):ye=t[49];let be;t[50]===S?be=t[51]:(be=S(`mobile.projects.menu.newChat`),t[50]=S,t[51]=be);let xe;t[52]!==L||t[53]!==be?(xe=(0,$.jsxs)($t,{className:`min-h-11`,onSelect:L,children:[ye,be]}),t[52]=L,t[53]=be,t[54]=xe):xe=t[54];let Se;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(Z,{name:`folder`,className:`size-4`}),t[55]=Se):Se=t[55];let Ce;t[56]===S?Ce=t[57]:(Ce=S(`mobile.projects.menu.newProject`),t[56]=S,t[57]=Ce);let we;t[58]!==I||t[59]!==Ce?(we=(0,$.jsxs)($t,{className:`min-h-11`,onSelect:I,children:[Se,Ce]}),t[58]=I,t[59]=Ce,t[60]=we):we=t[60];let Te;t[61]!==B||t[62]!==s||t[63]!==S?(Te=s?(0,$.jsxs)($t,{className:`min-h-11`,onSelect:B,children:[(0,$.jsx)(Z,{name:`scan-2`,className:`size-4`}),S(`mobile.projects.menu.scanQr`)]}):null,t[61]=B,t[62]=s,t[63]=S,t[64]=Te):Te=t[64];let Ee;t[65]!==H||t[66]!==c||t[67]!==S?(Ee=c?(0,$.jsxs)($t,{className:`min-h-11`,onSelect:H,children:[(0,$.jsx)(Z,{name:`server`,className:`size-4`}),S(`mobile.projects.menu.switchInstance`)]}):null,t[65]=H,t[66]=c,t[67]=S,t[68]=Ee):Ee=t[68];let J;t[69]!==xe||t[70]!==we||t[71]!==Te||t[72]!==Ee?(J=(0,$.jsxs)(Qt,{align:`end`,side:`bottom`,className:`min-w-44`,children:[xe,we,Te,Ee]}),t[69]=xe,t[70]=we,t[71]=Te,t[72]=Ee,t[73]=J):J=t[73];let De;t[74]!==ne||t[75]!==D||t[76]!==ve||t[77]!==J?(De=(0,$.jsxs)(en,{open:D,onOpenChange:ne,children:[ve,J]}),t[74]=ne,t[75]=D,t[76]=ve,t[77]=J,t[78]=De):De=t[78];let Oe;t[79]!==pe||t[80]!==De?(Oe=(0,$.jsxs)($.Fragment,{children:[pe,De]}),t[79]=pe,t[80]=De,t[81]=Oe):Oe=t[81];let ke;t[82]!==le||t[83]!==Oe?(ke=(0,$.jsx)($n,{title:le,trailing:Oe}),t[82]=le,t[83]=Oe,t[84]=ke):ke=t[84];let Ae;t[85]!==W||t[86]!==T||t[87]!==k||t[88]!==S?(Ae=T?(0,$.jsxs)(`div`,{className:`relative mx-1`,role:`search`,children:[(0,$.jsx)(Z,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 z-10 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Xt,{autoFocus:!0,type:`text`,inputMode:`search`,enterKeyHint:`search`,value:k,placeholder:S(`mobile.sessions.search.placeholder`),"aria-label":S(`mobile.sessions.searchAria`),className:X(`h-11 rounded-full pl-9`,k&&`pr-10`),onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Escape`&&W()}}),k?(0,$.jsx)($e,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-1.5 top-1/2 size-8 -translate-y-1/2 rounded-full text-muted-foreground`,"aria-label":S(`mobile.sessions.clearSearchAria`),onClick:()=>A(``),children:(0,$.jsx)(Z,{name:`close`,className:`size-4`})}):null]}):null,t[85]=W,t[86]=T,t[87]=k,t[88]=S,t[89]=Ae):Ae=t[89];let je;t[90]!==x||t[91]!==_||t[92]!==v||t[93]!==g||t[94]!==h||t[95]!==C||t[96]!==r||t[97]!==N||t[98]!==S?(je=!N&&(r.length>0||x.length>0)?(0,$.jsx)(nr,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":S(`mobile.sessions.section.pinned`),children:[(0,$.jsx)(ms,{project:{id:`__pinned__`,name:S(`mobile.sessions.section.pinned`),path:``,icon:`pushpin`,sessionCount:r.length+x.length},expanded:C,embedded:!0,onToggle:()=>w(Is)}),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)(Ms,{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)(Ms,{sessions:x,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null]}):null]})}):null,t[90]=x,t[91]=_,t[92]=v,t[93]=g,t[94]=h,t[95]=C,t[96]=r,t[97]=N,t[98]=S,t[99]=je):je=t[99];let Me;t[100]!==I||t[101]!==K||t[102]!==oe||t[103]!==se||t[104]!==M||t[105]!==_||t[106]!==m||t[107]!==f||t[108]!==u||t[109]!==v||t[110]!==p||t[111]!==g||t[112]!==h||t[113]!==l||t[114]!==d||t[115]!==n.length||t[116]!==N||t[117]!==S||t[118]!==F?(Me=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)(Z,{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)($e,{type:`button`,size:`lg`,className:`mt-4 min-h-10 rounded-full px-5`,onClick:I,children:[(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`}),S(`sessions.sidebar.header.actions.addProject`)]})]}):N&&F.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[40dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(Z,{name:`search`,className:`mb-4 size-6 text-muted-foreground`}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:S(`mobile.sessions.empty.searchTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:S(`mobile.sessions.empty.searchDescription`)})]}):F.map(e=>{let t=N||e.expanded,n=e.worktrees.find(Fs)??(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)(nr,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":e.name,children:[(0,$.jsx)(ms,{project:e,expanded:t,embedded:!0,highlightQuery:N?M:void 0,onToggle:()=>N?K(e):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)(Ms,{sessions:i,highlightQuery:N?M:void 0,onSelectSession:N?se:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,r.map(t=>{let n=N||!!t.expanded;return(0,$.jsx)(ar,{className:`oc-mobile-worktree-group`,ariaLabel:t.name,label:(0,$.jsx)(Ns,{project:e,worktree:t,expanded:n,highlightQuery:N?M:void 0,onToggle:()=>N?oe(e,t):d(e,t),onNewSession:f,onOpenActions:N?void 0:p,onDelete:N?void 0:m}),children:n&&t.sessions.length>0?(0,$.jsx)(Ms,{sessions:t.sessions,highlightQuery:N?M:void 0,onSelectSession:N?se:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v}):null},t.id)})]}):null]})},e.id)}),t[100]=I,t[101]=K,t[102]=oe,t[103]=se,t[104]=M,t[105]=_,t[106]=m,t[107]=f,t[108]=u,t[109]=v,t[110]=p,t[111]=g,t[112]=h,t[113]=l,t[114]=d,t[115]=n.length,t[116]=N,t[117]=S,t[118]=F,t[119]=Me):Me=t[119];let Ne;t[120]===S?Ne=t[121]:(Ne=S(`sessions.sidebar.header.actions.addProject`),t[120]=S,t[121]=Ne);let Pe;t[122]!==I||t[123]!==Ne?(Pe=(0,$.jsx)(`button`,{type:`button`,className:`sr-only`,onClick:I,children:Ne}),t[122]=I,t[123]=Ne,t[124]=Pe):Pe=t[124];let Fe;return t[125]!==ce||t[126]!==ke||t[127]!==Ae||t[128]!==je||t[129]!==Me||t[130]!==Pe?(Fe=(0,$.jsxs)(`main`,{className:ce,children:[ke,Ae,je,Me,Pe]}),t[125]=ce,t[126]=ke,t[127]=Ae,t[128]=je,t[129]=Me,t[130]=Pe,t[131]=Fe):Fe=t[131],Fe}function Fs(e){return e.kind===`main`}function Is(e){return!e}function Ls(e){let t=(0,Mi.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=()=>{je(`light`),i()},t[0]=i,t[1]=d);let f=R(d),p=c?`destructive`:`ghost`,m=u?`size-5 animate-spin`:`size-5`,h;t[2]!==n||t[3]!==m?(h=(0,$.jsx)(Z,{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)($e,{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 Rs(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)(Ls,{icon:e.icon,label:dr(e,t),onClick:n(e.onClick),destructive:e.destructive,disabled:e.disabled,spinning:e.spinning},e.id))},e.items[0]?.id))}function zs(e){let t=(0,Mi.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}=ee(),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=Xr({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=Or({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=yr({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=Rs(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)(Kt,{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 Bs(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 Vs(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=Bs(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 Hs=`__show_more__:`,Us=`__show_fewer__:`,Ws=e=>e.startsWith(Hs),Gs=e=>e.startsWith(Us),Ks=e=>Ws(e)||Gs(e),qs=e=>{let t=Ws(e)?Hs:Gs(e)?Us: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)}},Js=e=>e.parentID??null,Ys=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Xs=e=>{let t=e;return Ys(t.directory??t.project?.worktree??null)},Zs=(e,t)=>{if(t?.trim())return t.trim();let n=Ys(e);if(!n)return``;let r=n.split(`/`).filter(Boolean);return r[r.length-1]||n},Qs=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},$s=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))},ec=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},tc=(e,t)=>e.worktrees.find(e=>Ys(e.path)===t)??null,nc=(e,t)=>{let n=t?.trim();return n?`${e} · ${n}`:e},rc=(e,t)=>Ur(e,{pinnedSessionIds:t,omitPinnedSessions:!0}).map(e=>e.session);function ic(){let{t:e}=ee(),t=se(),n=ke(e=>e.activeSessions),r=ke(e=>e.activePaginationByDirectory),i=Me(e=>e.projects),a=Me(e=>e.activeProjectId),o=T(e=>e.currentDirectory),s=J(e=>e.currentSessionId),c=J(e=>e.availableWorktreesByProject),l=Et(e=>e.orderByProject),u=Ae(),d=fo(e=>e.projectExpanded),f=fo(e=>e.worktreeExpanded),p=oe(e=>e.index.session.unseenCount),[m,h]=Q.useState(new Map),g=mr(),_=Q.useMemo(()=>xr(g,s),[s,g]),v=Q.useMemo(()=>i.map(e=>{let t=Ys(e.path);return{id:e.id,label:Zs(t,e.label),path:t,icon:e.icon,worktrees:wt(l[e.id],c.get(t)??[])}}),[i,l,c]),y=Q.useMemo(()=>{let e=new Map(t.map(e=>[e.id,e])),r=n.map(t=>{let n=e.get(t.id);return n?Te(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]),b=Q.useMemo(()=>Nr(y,v.map(e=>({id:e.id,normalizedPath:e.path})),c,!1),[v,y,c]),x=Q.useMemo(()=>{let e=v.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===a,latestActivity:0})),t=new Map(e.map(e=>[e.project.id,e])),n=(e,t,n)=>{let r=Ys(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||Zs(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 y){let r=b.bySessionId.get(e.id);if(!r)continue;let i=t.get(r.projectId);if(!i)continue;let a=r.kind===`worktree`?tc(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)=>be(t)-be(e));let n=rc(e.sessions,u);t.totalSessions+=n.length;for(let n of e.sessions){let e=Qs(n);e>t.latestActivity&&(t.latestActivity=e)}}return e},[a,b,u,v,y]),S=Q.useMemo(()=>{let e=new Map;for(let t of y)e.set(t.id,t);return e},[y]),C=Q.useMemo(()=>{let e=new Map;for(let t of v)e.set(t.id,t);return e},[v]),w=Q.useRef([]),E=Q.useRef([]),D=Q.useRef(new Map),{pinnedSessions:O,inProgressSessions:k}=Q.useMemo(()=>{let t=new Map(v.map(e=>[e.id,e])),n=e(`mobile.sessions.untitled`),r=new Map(w.current.map(e=>[e.id,e])),i=new Map(E.current.map(e=>[e.id,e])),a=(e,r,i)=>{let a=b.bySessionId.get(e.id),o=a?t.get(a.projectId):void 0;if(!o)return[];let c=a?.kind===`worktree`?tc(o,a.scopeDirectory):null,l={id:e.id,directory:Xs(e),title:e.title?.trim()||n,subtitle:nc(o.label,c?.branch),changes:Gn(Wn(e))??void 0,activityLabel:$s(Qs(e))||void 0,unread:(p[e.id]??0)>0,pinned:r,archived:ec(e),active:s===e.id};return[Bs(i.get(e.id),l)]},o=Er(y,u).flatMap(e=>a(e,!0,r)),c=Br(y,u,g,p).flatMap(e=>a(e,!1,i)),l=Vs(w.current,o),d=Vs(E.current,c);return w.current=l,E.current=d,{pinnedSessions:l,inProgressSessions:d}},[s,b,u,v,g,y,e,p]),A=Q.useMemo(()=>{let e=new Map;for(let t of x){let n=t.project.worktrees.length>0;for(let r of t.buckets){let i=rc(r.sessions,u).length;e.set(`${t.project.id}::${r.key}`,{path:r.path,rootCount:i,hasWorktrees:n})}}return e},[u,x]),j=Q.useMemo(()=>{let t=Ys(o),n=new Map,i=e=>(e.kind!==`pagination`&&n.set(e.id,e),e),a=x.map(a=>{let o=d[a.project.id]??!0,c=Yr(),l=a.project.icon?Gt[a.project.icon]:void 0,h=a.buckets.map(o=>{let l=`${a.project.id}::${o.key}`,d=f[l]??!1,h=m.get(l)??c,g=rc(o.sessions,u),v=Ur(o.sessions,{pinnedSessionIds:u,omitPinnedSessions:!1}).map(e=>e.session),y=t=>{let r=Js(t),a=(p[t.id]??0)>0&&!r,c={id:t.id,directory:o.path,title:t.title?.trim()||e(`mobile.sessions.untitled`),changes:Gn(Wn(t))??void 0,activityLabel:$s(Qs(t))||void 0,unread:a,pinned:u.has(t.id),archived:ec(t),active:s===t.id},l=Bs(D.current.get(t.id)??n.get(t.id),c);return i(l)},b=_r(g,h,_).map(y),x=g.length-b.length,S=r.get(Ys(o.path)),C=S?.hasMore===!0,w=g.length>c&&h>c,T=[...b];w&&T.push({id:`${Us}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showFewer`)}),(x>0||C)&&T.push({id:`${Hs}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showMore`),subtitle:S?.loadingMore?`…`:void 0});let E=Ys(o.path),O=!!(a.isActive&&t&&E&&(t===E||t.startsWith(`${E}/`))),k=o.worktree==null;return{id:o.key,name:k?e(`mobile.sessions.mainWorkspace`):o.label,path:o.path,kind:k?`main`:`worktree`,active:O,expanded:k?!0:d,sessionCount:g.length,sessions:T,catalogSessions:v.map(y)}});return{id:a.project.id,name:a.project.label,path:a.project.path,icon:l,sessionCount:a.totalSessions,activityLabel:$s(a.latestActivity)||void 0,active:a.isActive,expanded:o,worktrees:h}});return D.current=n,a},[r,_,o,s,u,d,x,e,p,m,f]),M=e=>{for(let[t,n]of A)if(t.startsWith(`${e}::`))return n.hasWorktrees;return!1},N=(e,t)=>A.get(`${e}::${t}`)?.rootCount??0,P=e=>Yr();return{projects:j,pinnedSessions:O,inProgressSessions:k,sessionById:S,projectMetaById:C,allSessions:y,projectHasWorktrees:M,getBucketRootCount:N,getBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;return m.get(n)??P(e)},getBucketPageSize:P,getBucketDirectory:(e,t)=>A.get(`${e}::${t}`)?.path??null,showMoreBucketSessions:(e,t)=>{let n=`${e}::${t}`,r=A.get(n),i=Yr(),a=br(),o=m.get(n)??i,s=r?.rootCount??0;if(h(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=Ys(c);if(!l)return;let u=ke.getState().activePaginationByDirectory.get(l);u?.hasMore&&!u.loadingMore&&Fe(l)},resetBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;h(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})}}}var ac=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function oc({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,className:a}){let{t:o}=ee(),{git:s}=hn(),c=ic(),l=fo(e=>e.setProjectExpanded),u=fo(e=>e.setWorktreeExpanded),d=Re(),f=Ae(),m=J(e=>e.archiveSessions),h=J(e=>e.updateSessionTitle),g=J(e=>e.requestSessionSmartTitle),_=J(e=>e.shareSession),v=J(e=>e.unshareSession),y=J(e=>e.openNewSessionDraft),b=ze(e=>e.openDraft),x=ze(e=>e.openSession),S=Me(e=>e.projects),C=Me(e=>e.setActiveProjectIdOnly),w=Me(e=>e.removeProject),T=_t(),[E,D]=Q.useState(null),[O,k]=Q.useState(!1),[A,j]=Q.useState(null),[M,N]=Q.useState(null),[P,F]=Q.useState(null),[I,L]=Q.useState(``),[z,V]=Q.useState(!1),[H,te]=Q.useState(!1),[ne,U]=Q.useState(null),[W,re]=Q.useState(null),[ie,G]=Q.useState(null),K=E?.kind===`session`?E.session.id:``,ae=ue(K),oe=ae?.type===`busy`||ae?.type===`retry`,q=E?.kind===`session`?Xs(E.session):``,se=!!K&&ie===K,ce=!q||se||oe,le=R(e=>{let t=new Map;for(let e of c.allSessions){let n=Js(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=R(()=>{k(!1),D(null)}),fe=R(t=>{if(Ks(t.id)){let e=qs(t.id);if(!e)return;e.kind===`more`?c.showMoreBucketSessions(e.projectId,e.bucketKey):c.resetBucketVisibleCount(e.projectId,e.bucketKey);return}let n=c.sessionById.get(t.id),r=n&&Xs(n)||null;e({sessionId:t.id,directory:r})}),pe=R(e=>{Ks(e.id)||d(e.id)}),me=R(async e=>{if(Ks(e.id))return;let t=le(e.id),{archivedIds:n,failedIds:r}=await m(t);n.length>0&&ur({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=R(()=>{if(!E||E.kind!==`session`)return;let e=E.session,t=Xs(e),n=ae?.type??`idle`;!t||ie===e.id||n===`busy`||n===`retry`||(G(e.id),(async()=>{try{await T.refreshSessionTranscript(e.id,{directory:t}),Y.success(o(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{Y.error(o(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{G(t=>t===e.id?null:t)}})())}),ge=R(e=>{if(Ks(e.id))return;let t=c.sessionById.get(e.id);t&&(D({kind:`session`,session:t}),k(!0))}),_e=R(e=>{l(e.id,!e.expanded)}),ve=R((e,t)=>{u(`${e.id}::${t.id}`,!t.expanded)}),ye=R((e,t)=>{C(e.id),b({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),be=R(()=>{if(n){n();return}y()}),xe=R(e=>{let t=c.projectMetaById.get(e.id);t&&(D({kind:`project`,project:t,isGitRepository:!1}),k(!0),s.checkIsGitRepository(t.path).then(e=>{D(n=>ac(n,t.id,e))}).catch(()=>{D(e=>ac(e,t.id,!1))}))}),Se=R((e,t)=>{let n=p(t);return n?e.worktrees.find(e=>p(e.path)===n)||((J.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>p(e.path)===n)??null):null}),Ce=R((e,t)=>{let n=c.projectMetaById.get(e.id);n&&ye(n,t.path)}),we=R((e,t)=>{let n=c.projectMetaById.get(e.id);n&&(D({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),k(!0))}),Te=R((e,t)=>{let n=c.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}re({project:n,worktree:r})}),Ee=R(e=>{U(e),C(e),te(!0)}),De=R(e=>{(async()=>{let t=e.worktrees;try{t=(await Jt({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=J.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await He([e.path,...t.map(e=>e.path)],c.allSessions)})()}),Oe=R((e,t)=>{let n=ne;if(te(!1),U(null),t?.sessionId){x({sessionId:t.sessionId,directory:e});return}b({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),ke=R(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`))}}),je=R(async e=>{if((await B(e)).ok){Y.success(o(`sessions.sidebar.session.menu.copied`));return}Y.error(o(`sessions.sidebar.session.share.copyUrlError`))}),Ne=R(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`))}}),Pe=R(e=>{let t=le(e.id);Fr({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=R(async()=>{if(!P)return;let e=I.trim();if(e)try{await h(P.id,e),F(null),L(``)}catch{Y.error(o(`sessions.sidebar.session.menu.rename`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),Ie=R(async()=>{if(!P||z)return;let e=P.id;F(null),L(``),V(!0);try{await g(e)}catch{Y.error(o(`sessions.sidebar.session.rename.smartTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{V(!1)}}),Le=Q.useMemo(()=>E?E.kind===`session`?{kind:`session`,title:E.session.title?.trim()||o(`mobile.sessions.untitled`),pinned:f.has(E.session.id),shared:!!E.session.share?.url}:E.kind===`project`?{kind:`project`,title:E.project.label,gitRepository:E.isGitRepository}:{kind:`worktree`,title:E.worktreeName}:null,[E,f,o]),Be=Q.useMemo(()=>{if(!E)return{};if(E.kind===`session`){let e=E.session;return{onRename:()=>{L(e.title?.trim()||o(`mobile.sessions.untitled`)),F(e)},onTogglePin:()=>d(e.id),onShare:e.share?.url?void 0:()=>{ke(e)},onCopyLink:e.share?.url?()=>{je(e.share.url)}:void 0,onUnshare:e.share?.url?()=>{Ne(e.id)}:void 0,onRefreshTranscript:he,onArchive:()=>{me({id:e.id,title:e.title?.trim()||o(`mobile.sessions.untitled`)})},onDelete:()=>Pe(e)}}if(E.kind===`project`){let e=E.project;return{onNewSession:()=>ye(e,e.path),onNewWorktree:()=>Ee(e.id),onSyncSessions:()=>De(e),onEditProject:()=>j(e.id),onCloseProject:()=>N(e)}}let{project:e,worktreePath:t}=E;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}re({project:e,worktree:n})}}},[E,me,je,Pe,he,Ee,De,ke,Ne,Se,ye,o,d]),Ve=Q.useMemo(()=>{if(!A)return null;let e=S.find(e=>e.id===A),t=c.projectMetaById.get(A);if(!e||!t)return null;let n=E?.kind===`project`&&E.project.id===A?E.isGitRepository:t.worktrees.length>0;return{id:e.id,label:e.label?.trim()||t.label,path:p(e.path)||t.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:n,worktrees:t.worktrees}},[E,A,c.projectMetaById,S]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ps,{className:a,projects:c.projects,pinnedSessions:c.pinnedSessions,inProgressSessions:c.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)(zs,{open:O,target:Le,actions:Be,refreshTranscriptDisabled:ce,refreshTranscriptSpinning:se,onOpenChange:e=>{e?k(!0):de()}}),(0,$.jsx)(ht,{open:H,projectId:ne,onOpenChange:e=>{te(e),e||U(null)},onWorktreeCreated:Oe}),W?(0,$.jsx)(vr,{open:!0,project:{id:W.project.id,path:W.project.path},worktree:W.worktree,onClose:()=>re(null)}):null,(0,$.jsx)(xt,{open:!!M,title:o(`sessions.sidebar.project.actions.closeProject`),onClose:()=>N(null),closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)($e,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>N(null),children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)($e,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!M)return;let e=M;N(null),w(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:M?.label??``})})}),(0,$.jsx)(xt,{open:!!P,title:o(`sessions.sidebar.session.menu.rename`),onClose:()=>{z||(F(null),L(``))},closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)($e,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:z,onClick:()=>{F(null),L(``)},children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)($e,{type:`button`,variant:`default`,className:`flex-1`,disabled:!I.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)(Xt,{value:I,onChange:e=>L(e.target.value),autoFocus:!0,className:`h-12`,disabled:z}),(0,$.jsxs)($e,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:z,onClick:()=>void Ie(),children:[z?(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-4`}),o(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(fr,{open:A!==null,project:Ve,onClose:()=>j(null)})]})}function sc(e){let t=(0,Mi.c)(10),{children:n,content:r,className:i,contentClassName:a,showHeader:o}=e,s=o===void 0||o,{t:c}=ee(),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=X(`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)(tr,{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 cc(e){let t=(0,Mi.c)(10),{className:n,contentClassName:r,instancesPage:i}=e,{t:a}=ee(),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=[...rr],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(ai,{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)(tr,{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 lc(e){let t=(0,Mi.c)(92),{onAddProject:n,onScanQr:r,onSwitchInstance:i,onEnableAssistants:a,instancesPage:o,instancesSecondaryPage:s,parentSessionTarget:c,registerSecondaryBackHandler:l,scheduledContent:u,renderChat:d,className:f}=e,m=c===void 0?null:c,{t:h}=ee(),g=ze(),_=ze(bc),v=ze(yc),y=ze(vc),b=ze(_c),x=ze(gc),S=ze(hc),C=ze(mc),w=ze(pc),T=ze(fc),E;t[0]===_?E=t[1]:(E=e=>{_(e)},t[0]=_,t[1]=E);let D=R(E),O;t[2]===v?O=t[3]:(O=e=>{v(e)},t[2]=v,t[3]=O);let k=R(O),A;t[4]===x?A=t[5]:(A=()=>{x()},t[4]=x,t[5]=A);let j=R(A),M;t[6]===y?M=t[7]:(M=()=>{y()},t[6]=y,t[7]=M);let N=R(M),P;t[8]===b?P=t[9]:(P=e=>{b(e)},t[8]=b,t[9]=P);let F=R(P),I=Q.useRef(null),[L,z]=Q.useState(!1),B;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{I.current=e},t[10]=B):B=t[10];let V=R(B),H;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>{z(e)},t[11]=H):H=t[11];let te=R(H),ne;t[12]!==j||t[13]!==S?(ne=()=>{if(I.current?.())return!0;let e=ze.getState().secondary;return e?.kind===`chat`&&e.routes.length>1?(S(),!0):e?(j(),!0):!1},t[12]=j,t[13]=S,t[14]=ne):ne=t[14];let U=R(ne),W=g.secondary!==null,re;t[15]!==U||t[16]!==l?(re=()=>{if(l)return l(()=>U()),()=>l(null)},t[15]=U,t[16]=l,t[17]=re):re=t[17];let ie;t[18]!==U||t[19]!==l||t[20]!==W?(ie=[l,W,U],t[18]=U,t[19]=l,t[20]=W,t[21]=ie):ie=t[21],Q.useEffect(re,ie);let G=J(dc),K;t[22]===G?K=t[23]:(K=e=>G?e.getDirectoryForSession(G):null,t[22]=G,t[23]=K);let ae=J(K),oe,q;t[24]!==ae||t[25]!==G||t[26]!==w||t[27]!==T?(oe=()=>{let e=ze.getState().secondary;if(e?.kind===`draft`&&G){w({sessionId:G,directory:ae});return}if(e?.kind!==`chat`||!G||Ve({sessionId:G,directory:ae})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==G||p(t.directory)!==p(ae))&&T({sessionId:G,directory:ae})},q=[ae,G,w,T],t[24]=ae,t[25]=G,t[26]=w,t[27]=T,t[28]=oe,t[29]=q):(oe=t[28],q=t[29]),Q.useEffect(oe,q);let se,ce;t[30]!==G||t[31]!==m||t[32]!==C?(se=()=>{let e=ze.getState().secondary;if(e?.kind!==`chat`||!m)return;let t=e.routes.at(-1);!t||t.sessionId!==G||C({sessionId:m.id,directory:m.directory})},ce=[G,m,C],t[30]=G,t[31]=m,t[32]=C,t[33]=se,t[34]=ce):(se=t[33],ce=t[34]),Q.useEffect(se,ce);let le;t[35]!==te||t[36]!==V||t[37]!==u?(le=typeof u==`function`?u(V,te):u,t[35]=te,t[36]=V,t[37]=u,t[38]=le):le=t[38];let ue=le,de;t[39]!==N||t[40]!==n||t[41]!==r||t[42]!==i||t[43]!==k?(de=(0,$.jsx)(oc,{onOpenChat:k,onAddProject:n,onNewSession:N,onScanQr:r,onSwitchInstance:i}),t[39]=N,t[40]=n,t[41]=r,t[42]=i,t[43]=k,t[44]=de):de=t[44];let fe;t[45]!==a||t[46]!==F?(fe=(0,$.jsx)(Vo,{onEnable:a,onOpenAssistant:F}),t[45]=a,t[46]=F,t[47]=fe):fe=t[47];let pe;t[48]===ue?pe=t[49]:(pe=(0,$.jsx)(sc,{showHeader:!1,children:ue}),t[48]=ue,t[49]=pe);let me;t[50]===o?me=t[51]:(me=(0,$.jsx)(cc,{instancesPage:o}),t[50]=o,t[51]=me);let he;t[52]!==de||t[53]!==fe||t[54]!==pe||t[55]!==me?(he={projects:de,assistant:fe,scheduled:pe,settings:me},t[52]=de,t[53]=fe,t[54]=pe,t[55]=me,t[56]=he):he=t[56];let ge=he,_e=g.secondary?.kind??null,ve;bb0:{if(!_e){ve=null;break bb0}if(_e===`assistant`){let e;t[57]===h?e=t[58]:(e=h(`assistants.title`),t[57]=h,t[58]=e);let n;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(li,{activeOverride:!0,onMobileBack:uc}),t[59]=n):n=t[59];let r;t[60]!==U||t[61]!==e?(r=[{key:`assistant-secondary`,depth:1,ariaLabel:e,onBack:U,content:n}],t[60]=U,t[61]=e,t[62]=r):r=t[62],ve=r;break bb0}if(_e===`instances`){let e;t[63]===h?e=t[64]:(e=h(`mobile.settings.switchInstance`),t[63]=h,t[64]=e);let n;t[65]!==U||t[66]!==s||t[67]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:U,content:s}],t[65]=U,t[66]=s,t[67]=e,t[68]=n):n=t[68],ve=n;break bb0}if(g.secondary?.kind===`draft`){let e;t[69]===h?e=t[70]:(e=h(`mobile.nav.secondaryPageAria`),t[69]=h,t[70]=e);let n;t[71]===d?n=t[72]:(n=d({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[71]=d,t[72]=n);let r;t[73]!==U||t[74]!==e||t[75]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:U,content:n}],t[73]=U,t[74]=e,t[75]=n,t[76]=r):r=t[76],ve=r;break bb0}if(g.secondary?.kind!==`chat`){let e;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[77]=e):e=t[77],ve=e;break bb0}let e=g.secondary.routes,n;if(t[78]!==U||t[79]!==d||t[80]!==e||t[81]!==h){let r=e.slice(-2),i=e.length-r.length+1;n=r.map((e,t)=>{let n=t===r.length-1;return{key:e.key,depth:i+t,ariaLabel:h(`mobile.nav.secondaryPageAria`),onBack:U,content:d({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:n})}}),t[78]=U,t[79]=d,t[80]=e,t[81]=h,t[82]=n}else n=t[82];ve=n}let ye=ve,be;t[83]===ye?be=t[84]:(be=ye??[],t[83]=ye,t[84]=be);let xe;return t[85]!==f||t[86]!==g||t[87]!==L||t[88]!==D||t[89]!==be||t[90]!==ge?(xe=(0,$.jsx)(us,{className:f,navigation:g,onTabChange:D,tabs:ge,secondaryPages:be,tabBarCovered:L}),t[85]=f,t[86]=g,t[87]=L,t[88]=D,t[89]=be,t[90]=ge,t[91]=xe):xe=t[91],xe}function uc(){return On.requestAnimatedBack(`root`)}function dc(e){return e.currentSessionId}function fc(e){return e.replaceChatSession}function pc(e){return e.materializeDraftSession}function mc(e){return e.reconcileChatPredecessor}function hc(e){return e.popChatSession}function gc(e){return e.closeSecondary}function _c(e){return e.openAssistant}function vc(e){return e.openDraft}function yc(e){return e.openSession}function bc(e){return e.setActiveTab}function xc(e){let t=(0,Mi.c)(19),{percentage:n}=e,r,i,a,o,s,c,l;if(t[0]!==n){a=sn(n)??0;let e=an(n);i=e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,r=2*Math.PI*7.5,o=`0 0 18 18`,s=`size-[18px] -rotate-90`,c=`progressbar`,l=Math.round(a),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7];let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[8]=u):u=t[8];let d=r*(1-a/100),f;t[9]!==r||t[10]!==i||t[11]!==d?(f=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:i,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:r,strokeDashoffset:d,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[9]=r,t[10]=i,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==o||t[14]!==s||t[15]!==c||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`svg`,{viewBox:o,className:s,role:c,"aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,children:[u,f]}),t[13]=o,t[14]=s,t[15]=c,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}function Sc(e){let t=(0,Mi.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}=ee(),f=R(i),p=R(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 Cc=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},wc=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),Tc=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,Ec=e=>{let{totalTokens:t,contextLimit:n,isDraft:r}=e;if(r||t<=0||n<=0)return null;let i=Math.min(t/n*100,999);return{percentage:i,tokens:`${wc(t)}/${wc(n)}`,colorClass:Tc(i)}},Dc=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},Oc=(e,t)=>{let n=fe(e,t??(()=>void 0));return!n||`compacted`in n?0:n.totalTokens},kc=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Ac=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`},jc=e=>{let t=(0,Mi.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,$.jsx)(Z,{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},Mc=e=>{let t=(0,Mi.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ee(),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)(Z,{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)(Z,{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)(Vt,{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=nn(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:X(`shrink-0 typography-ui-label font-semibold tabular-nums`,Ac(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},Nc=e=>{let t=(0,Mi.c)(47),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l}=e,{t:u}=ee(),d=Q.useRef(null),[f,p]=Q.useState(n),[m,h]=Q.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]),Q.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]),Q.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=X(`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)(jc,{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)(jc,{iconNode:(0,$.jsx)(xc,{percentage:i.percentage}),label:u(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsxs)(`span`,{className:X(`font-semibold`,i.colorClass),children:[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)(Mc,{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:$c,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{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,A as n,C as r,E
|
|
|
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]===ne?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:[ne,U]}),t[53]=ne,t[54]=W),W},gf=e=>{let t=(0,Mi.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ee(),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)(Z,{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)(Z,{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)(Vt,{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=nn(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:X(`shrink-0 typography-ui-label font-semibold tabular-nums`,pf(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},_f=e=>{let t=(0,Mi.c)(28),{open:n,onClose:r,items:i,rightOffset:a}=e,o=a===void 0?0:a,{t:s}=ee(),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]),Q.useEffect(c,l),!n)return null;let u;t[4]===s?u=t[5]:(u=s(`mobile.menu.titleAria`),t[4]=s,t[5]=u);let d;t[6]===s?d=t[7]:(d=s(`mobile.surface.closeAria`),t[6]=s,t[7]=d);let f;t[8]===r?f=t[9]:(f=e=>{e.preventDefault(),r()},t[8]=r,t[9]=f);let p;t[10]!==d||t[11]!==f?(p=(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":d,onPointerDown:f}),t[10]=d,t[11]=f,t[12]=p):p=t[12];let m=`max(1rem, calc(8px + ${o}px + var(--oc-safe-area-right, 0px)))`,h;t[13]===m?h=t[14]:(h={right:m,animation:`mobile-menu-in 160ms cubic-bezier(0.32, 0.72, 0, 1) forwards`},t[13]=m,t[14]=h);let g;if(t[15]!==i||t[16]!==r){let e;t[18]===r?e=t[19]:(e=(e,t)=>(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,className:X(`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)(Z,{name:e.icon,className:X(`size-5 shrink-0 text-muted-foreground`,e.spinning&&`animate-spin`)}):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]},e.key),t[18]=r,t[19]=e),g=i.map(e),t[15]=i,t[16]=r,t[17]=g}else g=t[17];let _;t[20]!==g||t[21]!==h?(_=(0,$.jsx)(`div`,{id:Wd,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:h,onAnimationEnd:Sf,children:g}),t[20]=g,t[21]=h,t[22]=_):_=t[22];let v;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(v=(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[23]=v):v=t[23];let y;return t[24]!==_||t[25]!==u||t[26]!==p?(y=(0,$.jsxs)(`div`,{className:`pointer-events-none fixed inset-0 z-50`,role:`dialog`,"aria-modal":`true`,"aria-label":u,children:[p,_,v]}),t[24]=_,t[25]=u,t[26]=p,t[27]=y):y=t[27],y},vf=Q.memo(function(e){let t=(0,Mi.c)(88),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=ee(),{git:f}=hn(),p=rl(i??``,a||void 0),m=p??l,h=Q.useRef(null),g=Pe(i??``,a||void 0),_=yn(o),v=bn(o),y=_n(Cf),b=_n(wf),x=Se(Tf),S=Se(Ef),C=Se(Df),w=Se(Of),T;t[0]===i?T=t[1]:(T=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=T);let E=le(T),D=sr(kf),O=sr(Af),k=sr(jf),A=sr(Mf),j=sr(Nf),M=sr(Pf),N=sr(Ff),P=d(If);Qn();let F,I;t[2]!==y||t[3]!==f||t[4]!==o?(F=()=>{o&&y(o,f)},I=[y,f,o],t[2]=y,t[3]=f,t[4]=o,t[5]=F,t[6]=I):(F=t[5],I=t[6]),Q.useEffect(F,I);let L,R;t[7]!==b||t[8]!==f||t[9]!==o?(L=()=>{if(o)return ye.onGitRefreshHint(e=>{af(e.directory)===o&&b(o,f)})},R=[b,f,o],t[7]=b,t[8]=f,t[9]=o,t[10]=L,t[11]=R):(L=t[10],R=t[11]),Q.useEffect(L,R);let z,B;t[12]===O?(z=t[13],B=t[14]):(z=()=>{O()},B=[O],t[12]=O,t[13]=z,t[14]=B),Q.useEffect(z,B);let V,H;t[15]===M?(V=t[16],H=t[17]):(V=()=>{Nt(M)},H=[M],t[15]=M,t[16]=V,t[17]=H),Q.useEffect(V,H);let te,ne;t[18]!==M||t[19]!==k||t[20]!==A||t[21]!==n||t[22]!==D?(te=()=>{!n||A||M.some(e=>!D.some(t=>t.providerId===e))&&k()},ne=[M,k,A,n,D],t[18]=M,t[19]=k,t[20]=A,t[21]=n,t[22]=D,t[23]=te,t[24]=ne):(te=t[23],ne=t[24]),Q.useEffect(te,ne);let U;t[25]===g?U=t[26]:(U=Dc(g),t[25]=g,t[26]=U);let W=U,re;if(t[27]!==g||t[28]!==C||t[29]!==S||t[30]!==w||t[31]!==s||t[32]!==W||t[33]!==x||t[34]!==E){let e=W??(E?{providerID:E.providerId,modelID:E.modelId}:null)??(S&&C?{providerID:S,modelID:C}:null),n=(e?x.find(t=>t.id===e.providerID):void 0)?.models.find(t=>t.id===e?.modelID),r=e?w(e.providerID,e.modelID):void 0,i=Cc(n?.limit,`context`)??r?.limit?.context??0,a;t[36]===g?a=t[37]:(a=Oc(g),t[36]=g,t[37]=a),re=Ec({totalTokens:a,contextLimit:i,isDraft:s}),t[27]=g,t[28]=C,t[29]=S,t[30]=w,t[31]=s,t[32]=W,t[33]=x,t[34]=E,t[35]=re}else re=t[35];let ie=re,G;t[38]!==v?.current||t[39]!==_||t[40]!==u?(G=_===!0?v?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[38]=v?.current,t[39]=_,t[40]=u,t[41]=G):G=t[41];let K=G,ae;if(t[42]!==M||t[43]!==D||t[44]!==N||t[45]!==u){let e=new Map(D.map(Lf)),n;t[47]===M?n=t[48]:(n=e=>M.includes(e.id),t[47]=M,t[48]=n),ae=Kn.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:ln(e),window:t});let i=Object.entries(n?.usage?.models??{}),a=N[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:ln(i),subtitle:er(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[42]=M,t[43]=D,t[44]=N,t[45]=u,t[46]=ae}else ae=t[46];let oe=ae,q,se;t[49]!==n||t[50]!==oe?(q=()=>{!n||oe.length===0||Nt(oe.map(Rf))},se=[n,oe],t[49]=n,t[50]=oe,t[51]=q,t[52]=se):(q=t[51],se=t[52]),Q.useEffect(q,se);let ce;t[53]===c?ce=t[54]:(ce=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[53]=c,t[54]=ce);let ue;t[55]!==m||t[56]!==p?(ue=m?(0,$.jsx)(`span`,{className:X(`block truncate`,p?`oc-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:m}):null,t[55]=m,t[56]=p,t[57]=ue):ue=t[57];let de;t[58]!==ce||t[59]!==ue?(de=(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:[ce,ue]})}),t[58]=ce,t[59]=ue,t[60]=de):de=t[60];let fe;t[61]===u?fe=t[62]:(fe=u(`mobile.header.openMetadataAria`),t[61]=u,t[62]=fe);let pe;t[63]===r?pe=t[64]:(pe=()=>r(zf),t[63]=r,t[64]=pe);let me;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(me={touchAction:`manipulation`},t[65]=me):me=t[65];let he=ie?.percentage??0,ge;t[66]===he?ge=t[67]:(ge=(0,$.jsx)(xc,{percentage:he}),t[66]=he,t[67]=ge);let _e;t[68]!==n||t[69]!==fe||t[70]!==pe||t[71]!==ge?(_e=(0,$.jsx)(`button`,{ref:h,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":fe,"aria-expanded":n,onClick:pe,style:me,children:ge}),t[68]=n,t[69]=fe,t[70]=pe,t[71]=ge,t[72]=_e):_e=t[72];let ve;t[73]===r?ve=t[74]:(ve=()=>r(!1),t[73]=r,t[74]=ve);let be;t[75]!==K||t[76]!==ie||t[77]!==A||t[78]!==n||t[79]!==j||t[80]!==ve||t[81]!==P||t[82]!==oe?(be=(0,$.jsx)(hf,{open:n,onClose:ve,anchorRef:h,contextDisplay:ie,branchLabel:K,usageGroups:oe,usageDisplayMode:j,isUsageLoading:A,timeFormatPreference:P}),t[75]=K,t[76]=ie,t[77]=A,t[78]=n,t[79]=j,t[80]=ve,t[81]=P,t[82]=oe,t[83]=be):be=t[83];let xe;return t[84]!==de||t[85]!==_e||t[86]!==be?(xe=(0,$.jsxs)($.Fragment,{children:[de,_e,be]}),t[84]=de,t[85]=_e,t[86]=be,t[87]=xe):xe=t[87],xe}),yf=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=ee(),[a,o]=Q.useState(!1),s=T(e=>e.currentDirectory),c=J(e=>e.currentSessionId),l=Q.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=J(l)||s,d=af(u)||null,f=Me(e=>e.projects),p=J(e=>e.availableWorktreesByProject),m=Q.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=J(m),g=_e(c),_=J(e=>!!e.newSessionDraft?.open),v=Q.useMemo(()=>{let e=af(u);return e&&lf((h?.projectDirectory?de(f,h.projectDirectory):null)??he(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:``;Q.useEffect(()=>{o(!1)},[c,u]);let x=R(()=>{o(!1),e()}),S=R(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(oa,{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)(Z,{name:`folders`,className:`size-5`})}),(0,$.jsx)(vf,{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:X(`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)(Z,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(`button`,{type:`button`,className:X(`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)(Z,{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":Wd,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`more-2`,className:`size-5`})})]})})},bf=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=ee(),r=_t();Ue(),Ce();let i=d(e=>e.mobileSessionPanelOpen),a=d(e=>e.setMobileSessionPanelOpen),o=d(e=>e.isScheduledTasksDialogOpen),s=d(e=>e.activeMainTab),c=qe(),l=d(e=>e.setActiveMainTab),[u,f]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),[x,S]=Q.useState(null),[C,w]=Q.useState(null),[E,D]=Q.useState(null),[k,A]=Q.useState(0),[j,M]=Q.useState(!1),[N,P]=Q.useState(!1),[F,I]=Q.useState(!1),[z,B]=Q.useState(!1),[V,H]=Q.useState(!1),[te,ne]=Q.useState(!1),[U,W]=Q.useState(`nav`),[re,ie]=Q.useState(!1),[G,K]=Q.useState(!1),ae=R(()=>ie(e=>!e)),oe=R(()=>ie(!1)),[q,se]=Q.useState(null),ce=T(e=>e.currentDirectory),le=d(e=>e.setSettingsPage),de=qn(e=>e.available),fe=qn(e=>e.runtimeType),pe=Q.useMemo(()=>ef(),[]),me=Q.useMemo(()=>El(),[]),{data:he=[],refetch:ge}=Xn(ce??null,{enabled:j}),{refetch:_e}=Zn(ce??null,{enabled:j}),ve=ei(e=>e.setMcpDraft),be=ei(e=>e.setSelectedMcp),Se=bn(af(ce)||null)?.files?.length??0;Q.useEffect(()=>ye.onDirectoryRequest(()=>H(!0)),[]);let we=Q.useMemo(()=>O(),[]),Te=dn()===`portrait`,[Ee,De]=Q.useState(we&&!Te),[Oe,ke]=Q.useState(null),Ae=R(e=>{if(e&&le(e),we){W(e?`page-content`:`nav`),I(!0);return}ze.getState().setActiveTab(`settings`)}),je=R(()=>{Ae(`instances`)}),Me=R(()=>{ze.getState().openInstances()}),Ne=R(()=>{ze.getState().closeSecondary()}),Pe=R(async()=>{if(!te){ne(!0);try{let t=await Dl();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`:L.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:L.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:L.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:L.error(n(`mobile.connect.scan.failed`))}}finally{ne(!1)}}});Cn({enabled:!we,rootRoutesBlocked:i||u||p||_||y||o||j||F||z||V||re});let Fe=R(()=>{let e=!Ee;e&&Te&&ke(null),De(e)}),Y=R(()=>{if(b(!1),S(null),w(null),m(!1),g(null),we){se(null),ke(`files`),Te&&De(!1);return}f(!0)}),Ie=R(()=>{m(!1),g(null)}),Le=R(e=>{let t=e.path.trim();if(t){if(b(!1),S(null),w(null),se(null),v(!1),we){d.getState().setPendingFileFocusPath(t),ke(`files`),Te&&De(!1);return}f(!1),g({path:t,targetLine:typeof e.targetLine==`number`&&Number.isFinite(e.targetLine)?Math.max(1,Math.trunc(e.targetLine)):void 0}),m(!0)}}),Re=d(e=>e.pendingFileFocusPath);Q.useEffect(()=>{if(Re){if(we){Y();return}Le({path:Re}),d.getState().setPendingFileFocusPath(null)}},[Re,we,Y,Le]);let Be=R((e=null)=>{if(b(!1),S(null),w(null),D(null),m(!1),g(null),se(e),we){ke(`changes`),Te&&De(!1);return}v(!0)}),Ve=R((e,t,n)=>{se(null),v(!1),m(!1),g(null),S(e??null),w(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(D(r),A(e=>e+1),we){ke(`turn-diff`),Te&&De(!1);return}b(!0)}),He=R(()=>{ke(null),se(null),D(null)}),We=R(e=>{if(Oe===e){He();return}e===`files`?Y():Be()}),Ge=Q.useRef(`changes`);Oe&&(Ge.current=Oe);let[Ke,Je]=Q.useState(!1);Q.useEffect(()=>{if(!we)return;if(Oe){Je(!0);return}let e=window.setTimeout(()=>Je(!1),240);return()=>window.clearTimeout(e)},[Oe,we]);let Xe=Oe??Ge.current,Ze=Qd(`left`,`openchamber.ipad.leftSidebarWidth`,Gd),Qe=Qd(`right`,`openchamber.ipad.rightSidebarWidth`,Kd),et=Q.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:()=>Y(),openSettings:e=>{Ae(e)}}),[Be,Le,Y,Ae,Ve]),tt=R(()=>{v(!1),se(null)}),nt=R(()=>{b(!1),D(null)});Xl(Q.useMemo(()=>({openSessions:()=>{if(we){De(!0);return}ze.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?Y():e===`mcp`?M(!0):e===`instances`?je():e===`update`&&B(!0)},openChanges:({path:e,staged:t}={})=>{Be(e?{path:e,staged:t===!0}:null)},openSettings:e=>{Ae(e)}}),[we,Be,Y,je,Ae]));let rt=Q.useRef(null),it=Q.useRef(null),at=Q.useRef(null),ot=Q.useRef(null),st=Q.useRef(null),ct=Q.useRef(null),lt=J(e=>e.currentSessionId),ut=J(e=>e.setCurrentSession),dt=Q.useMemo(()=>e=>lt?e.getDirectoryForSession(lt):null,[lt]),ft=J(dt),pt=xe(lt,ft||ce||void 0),mt=ue(lt??``);Fd();let ht=mt?.type===`busy`||mt?.type===`retry`,gt=R(()=>{let e=lt;if(!e||G||ht)return;let t=ft||ce||void 0;K(!0),(async()=>{try{await r.refreshSessionTranscript(e,{directory:t}),L.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{L.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{K(!1)}})()}),vt=R(e=>{ct.current=e}),yt=R(e=>{let t=at.current,n=ot.current,r=st.current;if(!t)return;if(!e){t.style.transform=``,t.style.opacity=``,t.style.willChange=``,n&&(n.style.transform=``,n.style.willChange=``),r&&(r.style.transform=``,r.style.willChange=``);return}t.style.willChange||t.getAnimations().forEach(e=>e.cancel()),t.style.willChange=`transform, opacity`,t.style.transform=`translate3d(${e.offsetX}px, 0, 0)`,t.style.opacity=String(1-e.progress*.08),n&&(n.style.willChange=`transform`,n.style.transform=`translate3d(${e.offsetX}px, 0, 0)`),r&&(r.style.willChange=`transform`,r.style.transform=`translate3d(${e.offsetX}px, 0, 0)`);let i=e.direction===`prev`?n:r;i&&Array.from(i.children).forEach(t=>{t instanceof HTMLElement&&(t.style.opacity=e.canSwitch?`1`:`0.35`)})}),bt=ze(e=>e.secondary?.kind??null),xt=!we&&(bt===`chat`||bt===`draft`);Q.useEffect(()=>{!we&&!xt&&ie(!1)},[we,xt]),Q.useEffect(()=>{ie(!1)},[lt]),hu(it,{onSwitch:vt,onProgress:yt},we||xt);let St=we&&s===`assistant`||!we&&!xt||i||u||p||_||y||o||j||F||z||V||re;Fu(it,{onOpen:R(()=>{Yt(Bt)?.finish(`commit`)}),onPreviewStart:R(()=>{Yt(Bt)?.begin(`present`)}),onPreviewCancel:R(()=>{Yt(Bt)?.finish(`cancel`)}),onProgress:R(e=>{e!==null&&Yt(Bt)?.update(e)}),disabled:St},we||xt),Q.useLayoutEffect(()=>{let e=ct.current;if(ct.current=null,!e)return;let t=at.current;if(!t||typeof t.animate!=`function`)return;t.getAnimations().forEach(e=>e.cancel());let n=e===`prev`?-70:70;t.animate([{opacity:.1,transform:`translateX(${n}px)`},{opacity:1,transform:`translateX(0)`}],{duration:300,easing:`cubic-bezier(0.22, 1, 0.36, 1)`})},[lt]);let Ct=R(e=>{rt.current=e});rf(R(()=>re?(ie(!1),!0):V?(H(!1),!0):o?(window.dispatchEvent(new Event(`oc:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):On.backImmediately(`overlay`)?!0:p?(Ie(),!0):u?(f(!1),!0):y?(nt(),!0):_?(tt(),!0):j?(M(!1),!0):F?(I(!1),!0):z?(B(!1),!0):On.requestAnimatedBack(`root`)||rt.current?.()?!0:s===`assistant`?(l(`chat`),!0):pt?(ut(pt.id,pt.directory),!0):!1));let wt=de&&(fe===`desktop`||fe===`web`),Tt=R(()=>{let e=`new-mcp-server`,t=e,n=1;for(;he.some(e=>e.name===t);)t=`${e}-${n}`,n+=1;ve({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),be(t),M(!1),Ae(`mcp`)}),Et=R(()=>{if(N)return;P(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([_e(),ge(),e]).finally(()=>P(!1))}),Dt=J(e=>e.openNewSessionDraft),Ot=Q.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(we){l(`chat`),Dt();return}ze.getState().openDraft()}}];return we||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>Y()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:Se,onSelect:()=>Be()}),e.push({key:`mcp`,iconNode:(0,$.jsx)(Yn,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>M(!0)}),wt&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>B(!0)}),we&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>Ae()}),lt&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:G||ht,spinning:G,onSelect:gt}),e},[lt,Se,we,ht,G,Be,Y,Dt,Ae,gt,l,wt,n]);return(0,$.jsxs)(Hn,{actions:et,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:[we?(0,$.jsxs)(`aside`,{ref:Ze.asideRef,className:X(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!Ee&&`border-r-0`),style:{width:Ee?Ze.width:0,minWidth:Ee?Ze.width:0,maxWidth:Ee?Ze.width:0,"--oc-ipad-sidebar-width":`${Ze.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:Ze.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Ee,"data-page-scroll-lock":`true`,children:[Ee?(0,$.jsx)($d,{side:`left`,isResizing:Ze.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:Ze.handleProps}):null,(0,$.jsx)(`div`,{className:X(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,Ze.isResizing&&`pointer-events-none`,!Ee&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(rn,{children:(0,$.jsx)(Po,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&Te&&De(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,children:we?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(yf,{onOpenSessions:()=>Fe(),menuOpen:re,onToggleMenu:ae,surfaceShortcuts:{activePanel:Oe===`turn-diff`?`changes`:Oe,changesDirty:Se>0,onToggleFiles:()=>We(`files`),onToggleChanges:()=>We(`changes`)}})}),(0,$.jsxs)(`main`,{ref:it,className:`relative min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsxs)(`div`,{ref:ot,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 -left-full flex w-full items-center justify-end gap-3 bg-background pr-4`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.previousSession`)}),(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(Z,{name:`arrow-left`,className:`size-5`})})]}),(0,$.jsxs)(`div`,{ref:st,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 left-full flex w-full items-center justify-start gap-3 bg-background pl-4`,children:[(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(Z,{name:`arrow-right`,className:`size-5`})}),(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.nextSession`)})]}),(0,$.jsx)(`div`,{ref:at,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(rn,{children:s===`assistant`?(0,$.jsx)(li,{}):(0,$.jsx)(Kr,{})})})]})]}):(0,$.jsx)(lc,{className:`min-h-0 flex-1`,onAddProject:()=>H(!0),onScanQr:pe&&me?()=>{Pe()}:void 0,onSwitchInstance:pe?Me:void 0,onEnableAssistants:()=>{Ae(`assistants`)},instancesPage:pe?(0,$.jsx)(ff,{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)(nr,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(ff,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:pt?{id:pt.id,directory:pt.directory}:null,registerSecondaryBackHandler:Ct,scheduledContent:(e,t)=>(0,$.jsx)(Hr,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(cl,{sessionId:e.sessionId,directory:e.directory,onBack:()=>{oe(),On.requestAnimatedBack(`root`)},onOpenMenu:ae,onCloseMenu:oe,menuOpen:e.active&&re,children:(0,$.jsxs)(`main`,{ref:e.active?it:void 0,className:`relative h-full min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[e.active?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{ref:ot,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 -left-full flex w-full items-center justify-end gap-3 bg-background pr-4`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.previousSession`)}),(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(Z,{name:`arrow-left`,className:`size-5`})})]}),(0,$.jsxs)(`div`,{ref:st,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 left-full flex w-full items-center justify-start gap-3 bg-background pl-4`,children:[(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(Z,{name:`arrow-right`,className:`size-5`})}),(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.nextSession`)})]})]}):null,(0,$.jsx)(`div`,{ref:e.active?at:void 0,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(rn,{children:(0,$.jsx)(Kr,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:e.sessionId||null,directory:e.directory,viewKey:e.viewKey}})})})]})})})}),we?(0,$.jsxs)(`aside`,{ref:Qe.asideRef,className:X(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!Oe&&`border-l-0`),style:{width:Oe?Qe.width:0,minWidth:Oe?Qe.width:0,maxWidth:Oe?Qe.width:0,"--oc-ipad-sidebar-width":`${Qe.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:Qe.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Oe,"data-page-scroll-lock":`true`,children:[Oe?(0,$.jsx)($d,{side:`right`,isResizing:Qe.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:Qe.handleProps}):null,(0,$.jsx)(`div`,{className:X(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,Qe.isResizing&&`pointer-events-none`,!Oe&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:Ke?(0,$.jsx)(rn,{children:Xe===`files`?(0,$.jsx)(Za,{onClose:He}):Xe===`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)($e,{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)(Z,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(gr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,targetFilePath:E,navigationRequestKey:k,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)($e,{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)(Z,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(gr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:q.path,targetLine:q.targetLine??null,toolPatches:q.toolPatches,singleFileView:q.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(va,{onClose:He,initialDiffPath:q?.path??null,initialDiffStaged:q?.staged===!0,initialDiffTargetLine:q?.targetLine??null})}):null})]}):null,(0,$.jsx)(Lr,{open:V,onOpenChange:H,forceMobile:!0}),(0,$.jsx)(_f,{open:re,onClose:()=>ie(!1),items:Ot,rightOffset:we&&Oe?Qe.width:0}),(0,$.jsx)(jr,{}),u?(0,$.jsx)(Kt,{id:zd,open:u,onOpenChange:e=>{e||f(!1)},ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(rn,{children:(0,$.jsx)(Za,{onClose:()=>f(!1)})})}):null,p&&h?(0,$.jsx)(Kt,{id:Rd,open:p,onOpenChange:e=>{e||Ie()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:h.path.split(/[/\\]/).filter(Boolean).at(-1)??h.path}),ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(rn,{children:(0,$.jsx)(Za,{onClose:Ie,initialFilePath:h.path,directFilePreview:!0,hideFileHeader:!0},h.path)})}):null,(0,$.jsx)(Kt,{id:Ld,open:y,onOpenChange:e=>{e||nt()},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)(rn,{children:(0,$.jsx)(gr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,targetFilePath:E,navigationRequestKey:k,flushContent:!0})})}),_&&q?(0,$.jsx)(Kt,{id:Id,open:_,onOpenChange:e=>{e||tt()},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)(rn,{children:q.toolPatches?.length?(0,$.jsx)(gr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:q.path,targetLine:q.targetLine??null,toolPatches:q.toolPatches,singleFileView:q.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(va,{initialDiffPath:q.path,initialDiffStaged:q.staged,initialDiffTargetLine:q.targetLine??null,hideDiffHeader:!0})})}):_?(0,$.jsx)(Kt,{id:Bd,open:_,onOpenChange:e=>{e||tt()},ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(rn,{children:(0,$.jsx)(va,{onClose:tt,initialDiffPath:q?.path??null,initialDiffStaged:q?.staged===!0,initialDiffTargetLine:q?.targetLine??null})})}):null,j?(0,$.jsx)(Kt,{id:Vd,open:j,onOpenChange:e=>{e||M(!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)($e,{type:`button`,variant:`ghost`,size:`icon`,onClick:Tt,"aria-label":n(`settings.mcp.sidebar.actions.addServerTitle`),title:n(`settings.mcp.sidebar.actions.addServerTitle`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`add`,className:`size-5`})}),(0,$.jsx)($e,{type:`button`,variant:`ghost`,size:`icon`,onClick:Et,disabled:N,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`refresh`,className:X(`size-5`,N&&`animate-spin`)})})]}),ariaLabel:n(`mcpDropdown.title`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(rn,{children:(0,$.jsx)(Dr,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,F&&we?(0,$.jsx)(Kt,{id:Hd,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)(rn,{children:(0,$.jsx)(ai,{forceMobile:!0,isWindowed:!0,initialMobileStage:U,visiblePageSlugs:[...rr],onClose:()=>I(!1),mobileInstancesPage:pe?(0,$.jsx)(ff,{connection:e,onConnect:()=>I(!1),onActiveConnectionDeleted:t}):void 0})})}):null,z?(0,$.jsx)(Kt,{id:Ud,open:z,onOpenChange:e=>{e||B(!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)(rn,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(ti,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(Qr,{enabled:pe&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(rn,{children:(0,$.jsx)(Zr,{})})]})};function xf({apis:e}){Q.useEffect(()=>Ke(),[]);let{t}=ee(),i=Se(e=>e.initializeApp),a=Se(e=>e.isInitialized),o=Se(e=>e.isConnected),s=Se(e=>e.connectionPhase),c=T(e=>e.currentDirectory),u=J(e=>e.currentSessionId),f=J(e=>!!e.newSessionDraft?.open),p=J(e=>e.error),h=J(e=>e.clearError),g=d(e=>e.setIsMobile),_=ir(e=>e.refreshStatus),v=Me(e=>e.projects),[y,b]=Q.useState(0),[x,S]=Q.useState(0),[C,w]=Q.useState(!1),[D,O]=Q.useState(`pending`),k=Q.useMemo(()=>re(),[]),[,A]=Q.useReducer(e=>e+1,0),j=Q.useMemo(()=>ef(),[]),N=Q.useRef(0),P=Q.useRef(0),I=W(()=>{O(`done`),b(e=>e+1)});Zl(R(e=>{I.redeemPairingConnection(e)}));let z=Ql({ready:j&&o&&a});Q.useEffect(()=>{!I.error||!r()||L.error(I.error)},[I.error]);let B=R(()=>{let t=r(),n=P.current+1;if(P.current=n,!t){G();return}let a=()=>{i(),_(e.github,{force:!0}),Se.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},o=()=>{l({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),b(e=>e+1)};U().then(e=>{if(P.current===n){if(e===`no-connection`){o();return}if(e===`unreachable`){window.setTimeout(()=>{P.current===n&&U().then(e=>{if(P.current===n&&e!==`switched`&&e===`unchanged`){a();return}})},4e3);return}e!==`switched`&&a()}});let s=Date.now();s-N.current>=sf&&(N.current=s,window.dispatchEvent(new Event(`openchamber:system-resume`)))});tf(),nf(B),Q.useEffect(()=>{if(!j)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>B(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[j,B]),Q.useEffect(()=>(m(e),()=>m(null)),[e]),Q.useEffect(()=>{j&&F().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[j]),Q.useEffect(()=>{if(!j)return;let e=!1,t=[];return F().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`download`,e=>{qn.getState().setOtaDownloadPercent(e.percent)}),i=await n.addListener(`downloadFailed`,()=>{qn.getState().setOtaDownloadFailed()}),a=await n.addListener(`downloadComplete`,()=>{qn.getState().setOtaPhase(`pending_restart`)}),o=await n.addListener(`appReloaded`,()=>{qn.getState().setOtaPhase(`pending_restart`)}),s=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),qn.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()}},[j]),Q.useEffect(()=>n(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){Gr(),A();return}Rr(e),ze.getState().reset(),S(e=>e+1),b(e=>e+1)}),[]),Q.useEffect(()=>{if(z===`pending`)return;if(z===`connect`){O(`done`);return}if(!j||o||r()){O(`done`);return}let e=!1;return O(`attempting`),ie().then(e=>e?!0:G()).catch(()=>!1).then(()=>{e||O(`done`)}),()=>{e=!0}},[z]),Q.useEffect(()=>{g(!0)},[g]),Q.useEffect(()=>{j&&!r()||i()},[y,i,j]),vt({enabled:!j||!!r(),source:`mobileApp:recovery`}),Q.useEffect(()=>{o&&E.setDirectory(c)},[c,o]),Q.useEffect(()=>{o&&_(e.github,{force:!0})},[e.github,o,_]),Q.useEffect(()=>{if(!o||v.length===0)return;let e=!1;return(async()=>{await Promise.all(v.map(async t=>{let n=af(t.path);if(n)try{if(!(_n.getState().directories.get(n)?.isGitRepo??await M(()=>import(`./gitApi-DdJQDVmv.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([52,1,5,2,3,4,6,7,8,34,35,10,36,37,38,20,21,22,23,24,39,40])))||e)return;await Jt({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[o,v]),Q.useEffect(()=>{if(!p)return;let e=window.setTimeout(()=>h(),5e3);return()=>window.clearTimeout(e)},[h,p]),Q.useEffect(()=>{if(!(!o&&(!j||r()))){w(!1);return}let e=window.setTimeout(()=>w(!0),8e3);return()=>window.clearTimeout(e)},[o,j,y,x]),Ot(),ot({enabled:!0}),gt(),Jr(),Ru({enabled:j&&o});let V=jl(),H=!o&&s===`reconnecting`;if(!V)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(on,{width:120,height:120,isAnimated:!0})});let te=!!r();return j&&(!te||!o&&!H)?te?(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)(on,{width:120,height:120,isAnimated:!C}),C?(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)($e,{type:`button`,variant:`outline`,onClick:()=>{l({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),b(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):D===`done`?(0,$.jsx)(df,{connection:I}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(on,{width:120,height:120,isAnimated:!0}),k?(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:[k,(0,$.jsx)(kt,{})]})]}):null]}):!o&&!H?C?(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)(on,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(rn,{children:(0,$.jsx)(pe,{sdk:E.getSdkClient(),directory:c||``,bootstrapDirectory:!(f&&u===null),children:(0,$.jsx)(At,{apis:e,children:(0,$.jsx)(Zt,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(Tr,{}),(0,$.jsx)(K,{}),(0,$.jsx)(St,{embeddedBackgroundWorkEnabled:a}),(0,$.jsx)(Wr,{}),(0,$.jsx)(Ri,{}),(0,$.jsx)(Ji,{}),(0,$.jsx)(bf,{connection:I,onActiveConnectionDeleted:()=>{l({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),ze.getState().reset(),b(e=>e+1)}}),(0,$.jsx)(st,{position:`top-center`,offset:`calc(var(--oc-safe-area-top, 0px) + 16px)`}),a?(0,$.jsx)(zr,{}):null]})})})},x)})}function Sf(e){e.currentTarget.style.transform=`none`}function Cf(e){return e.ensureStatus}function wf(e){return e.fetchStatus}function Tf(e){return e.providers}function Ef(e){return e.currentProviderId}function Df(e){return e.currentModelId}function Of(e){return e.getModelMetadata}function kf(e){return e.results}function Af(e){return e.loadSettings}function jf(e){return e.fetchAllQuotas}function Mf(e){return e.isLoading}function Nf(e){return e.displayMode}function Pf(e){return e.dropdownProviderIds}function Ff(e){return e.selectedModels}function If(e){return e.timeFormatPreference}function Lf(e){return[e.providerId,e]}function Rf(e){return e.providerId}function zf(e){return!e}var Bf=()=>{H(),v().then(()=>{Promise.all([_(),ut()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),Ct(),mt(),ct()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{Ci()})};function Vf(e){jn(),Bf(),d.getState().setIsMobile(!0),ji(),fn(),pn();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)(xf,{apis:r});(0,yi.createRoot)(t).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(lt,{children:(0,$.jsx)(z,{children:(0,$.jsx)(at,{children:(0,$.jsx)(ft,{children:(0,$.jsx)(Vr,{children:n?i:(0,$.jsx)(pt,{children:i})})})})})})}))}export{Vf as renderMobileApp};
|
|
28
|
+
`}),t[52]=U):U=t[52];let W;return t[53]===ne?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:[ne,U]}),t[53]=ne,t[54]=W),W},gf=e=>{let t=(0,Mi.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ee(),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)(Z,{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)(Z,{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)(Vt,{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=nn(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:X(`shrink-0 typography-ui-label font-semibold tabular-nums`,pf(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},_f=e=>{let t=(0,Mi.c)(28),{open:n,onClose:r,items:i,rightOffset:a}=e,o=a===void 0?0:a,{t:s}=ee(),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]),Q.useEffect(c,l),!n)return null;let u;t[4]===s?u=t[5]:(u=s(`mobile.menu.titleAria`),t[4]=s,t[5]=u);let d;t[6]===s?d=t[7]:(d=s(`mobile.surface.closeAria`),t[6]=s,t[7]=d);let f;t[8]===r?f=t[9]:(f=e=>{e.preventDefault(),r()},t[8]=r,t[9]=f);let p;t[10]!==d||t[11]!==f?(p=(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":d,onPointerDown:f}),t[10]=d,t[11]=f,t[12]=p):p=t[12];let m=`max(1rem, calc(8px + ${o}px + var(--oc-safe-area-right, 0px)))`,h;t[13]===m?h=t[14]:(h={right:m,animation:`mobile-menu-in 160ms cubic-bezier(0.32, 0.72, 0, 1) forwards`},t[13]=m,t[14]=h);let g;if(t[15]!==i||t[16]!==r){let e;t[18]===r?e=t[19]:(e=(e,t)=>(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,className:X(`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)(Z,{name:e.icon,className:X(`size-5 shrink-0 text-muted-foreground`,e.spinning&&`animate-spin`)}):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]},e.key),t[18]=r,t[19]=e),g=i.map(e),t[15]=i,t[16]=r,t[17]=g}else g=t[17];let _;t[20]!==g||t[21]!==h?(_=(0,$.jsx)(`div`,{id:Wd,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:h,onAnimationEnd:Sf,children:g}),t[20]=g,t[21]=h,t[22]=_):_=t[22];let v;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(v=(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[23]=v):v=t[23];let y;return t[24]!==_||t[25]!==u||t[26]!==p?(y=(0,$.jsxs)(`div`,{className:`pointer-events-none fixed inset-0 z-50`,role:`dialog`,"aria-modal":`true`,"aria-label":u,children:[p,_,v]}),t[24]=_,t[25]=u,t[26]=p,t[27]=y):y=t[27],y},vf=Q.memo(function(e){let t=(0,Mi.c)(88),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=ee(),{git:f}=hn(),p=rl(i??``,a||void 0),m=p??l,h=Q.useRef(null),g=Pe(i??``,a||void 0),_=yn(o),v=bn(o),y=_n(Cf),b=_n(wf),x=Se(Tf),S=Se(Ef),C=Se(Df),w=Se(Of),T;t[0]===i?T=t[1]:(T=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=T);let E=le(T),D=sr(kf),O=sr(Af),k=sr(jf),A=sr(Mf),j=sr(Nf),M=sr(Pf),N=sr(Ff),P=d(If);Qn();let F,I;t[2]!==y||t[3]!==f||t[4]!==o?(F=()=>{o&&y(o,f)},I=[y,f,o],t[2]=y,t[3]=f,t[4]=o,t[5]=F,t[6]=I):(F=t[5],I=t[6]),Q.useEffect(F,I);let L,R;t[7]!==b||t[8]!==f||t[9]!==o?(L=()=>{if(o)return ye.onGitRefreshHint(e=>{af(e.directory)===o&&b(o,f)})},R=[b,f,o],t[7]=b,t[8]=f,t[9]=o,t[10]=L,t[11]=R):(L=t[10],R=t[11]),Q.useEffect(L,R);let z,B;t[12]===O?(z=t[13],B=t[14]):(z=()=>{O()},B=[O],t[12]=O,t[13]=z,t[14]=B),Q.useEffect(z,B);let V,H;t[15]===M?(V=t[16],H=t[17]):(V=()=>{Nt(M)},H=[M],t[15]=M,t[16]=V,t[17]=H),Q.useEffect(V,H);let te,ne;t[18]!==M||t[19]!==k||t[20]!==A||t[21]!==n||t[22]!==D?(te=()=>{!n||A||M.some(e=>!D.some(t=>t.providerId===e))&&k()},ne=[M,k,A,n,D],t[18]=M,t[19]=k,t[20]=A,t[21]=n,t[22]=D,t[23]=te,t[24]=ne):(te=t[23],ne=t[24]),Q.useEffect(te,ne);let U;t[25]===g?U=t[26]:(U=Dc(g),t[25]=g,t[26]=U);let W=U,re;if(t[27]!==g||t[28]!==C||t[29]!==S||t[30]!==w||t[31]!==s||t[32]!==W||t[33]!==x||t[34]!==E){let e=W??(E?{providerID:E.providerId,modelID:E.modelId}:null)??(S&&C?{providerID:S,modelID:C}:null),n=(e?x.find(t=>t.id===e.providerID):void 0)?.models.find(t=>t.id===e?.modelID),r=e?w(e.providerID,e.modelID):void 0,i=Cc(n?.limit,`context`)??r?.limit?.context??0,a;t[36]===g?a=t[37]:(a=Oc(g),t[36]=g,t[37]=a),re=Ec({totalTokens:a,contextLimit:i,isDraft:s}),t[27]=g,t[28]=C,t[29]=S,t[30]=w,t[31]=s,t[32]=W,t[33]=x,t[34]=E,t[35]=re}else re=t[35];let ie=re,G;t[38]!==v?.current||t[39]!==_||t[40]!==u?(G=_===!0?v?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[38]=v?.current,t[39]=_,t[40]=u,t[41]=G):G=t[41];let K=G,ae;if(t[42]!==M||t[43]!==D||t[44]!==N||t[45]!==u){let e=new Map(D.map(Lf)),n;t[47]===M?n=t[48]:(n=e=>M.includes(e.id),t[47]=M,t[48]=n),ae=Kn.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:ln(e),window:t});let i=Object.entries(n?.usage?.models??{}),a=N[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:ln(i),subtitle:er(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[42]=M,t[43]=D,t[44]=N,t[45]=u,t[46]=ae}else ae=t[46];let oe=ae,q,se;t[49]!==n||t[50]!==oe?(q=()=>{!n||oe.length===0||Nt(oe.map(Rf))},se=[n,oe],t[49]=n,t[50]=oe,t[51]=q,t[52]=se):(q=t[51],se=t[52]),Q.useEffect(q,se);let ce;t[53]===c?ce=t[54]:(ce=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[53]=c,t[54]=ce);let ue;t[55]!==m||t[56]!==p?(ue=m?(0,$.jsx)(`span`,{className:X(`block truncate`,p?`oc-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:m}):null,t[55]=m,t[56]=p,t[57]=ue):ue=t[57];let de;t[58]!==ce||t[59]!==ue?(de=(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:[ce,ue]})}),t[58]=ce,t[59]=ue,t[60]=de):de=t[60];let fe;t[61]===u?fe=t[62]:(fe=u(`mobile.header.openMetadataAria`),t[61]=u,t[62]=fe);let pe;t[63]===r?pe=t[64]:(pe=()=>r(zf),t[63]=r,t[64]=pe);let me;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(me={touchAction:`manipulation`},t[65]=me):me=t[65];let he=ie?.percentage??0,ge;t[66]===he?ge=t[67]:(ge=(0,$.jsx)(xc,{percentage:he}),t[66]=he,t[67]=ge);let _e;t[68]!==n||t[69]!==fe||t[70]!==pe||t[71]!==ge?(_e=(0,$.jsx)(`button`,{ref:h,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":fe,"aria-expanded":n,onClick:pe,style:me,children:ge}),t[68]=n,t[69]=fe,t[70]=pe,t[71]=ge,t[72]=_e):_e=t[72];let ve;t[73]===r?ve=t[74]:(ve=()=>r(!1),t[73]=r,t[74]=ve);let be;t[75]!==K||t[76]!==ie||t[77]!==A||t[78]!==n||t[79]!==j||t[80]!==ve||t[81]!==P||t[82]!==oe?(be=(0,$.jsx)(hf,{open:n,onClose:ve,anchorRef:h,contextDisplay:ie,branchLabel:K,usageGroups:oe,usageDisplayMode:j,isUsageLoading:A,timeFormatPreference:P}),t[75]=K,t[76]=ie,t[77]=A,t[78]=n,t[79]=j,t[80]=ve,t[81]=P,t[82]=oe,t[83]=be):be=t[83];let xe;return t[84]!==de||t[85]!==_e||t[86]!==be?(xe=(0,$.jsxs)($.Fragment,{children:[de,_e,be]}),t[84]=de,t[85]=_e,t[86]=be,t[87]=xe):xe=t[87],xe}),yf=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=ee(),[a,o]=Q.useState(!1),s=T(e=>e.currentDirectory),c=J(e=>e.currentSessionId),l=Q.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=J(l)||s,d=af(u)||null,f=Me(e=>e.projects),p=J(e=>e.availableWorktreesByProject),m=Q.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=J(m),g=_e(c),_=J(e=>!!e.newSessionDraft?.open),v=Q.useMemo(()=>{let e=af(u);return e&&lf((h?.projectDirectory?de(f,h.projectDirectory):null)??he(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:``;Q.useEffect(()=>{o(!1)},[c,u]);let x=R(()=>{o(!1),e()}),S=R(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(oa,{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)(Z,{name:`folders`,className:`size-5`})}),(0,$.jsx)(vf,{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:X(`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)(Z,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(`button`,{type:`button`,className:X(`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)(Z,{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":Wd,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`more-2`,className:`size-5`})})]})})},bf=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=ee(),r=_t();Ue(),Ce();let i=d(e=>e.mobileSessionPanelOpen),a=d(e=>e.setMobileSessionPanelOpen),o=d(e=>e.isScheduledTasksDialogOpen),s=d(e=>e.activeMainTab),c=qe(),l=d(e=>e.setActiveMainTab),[u,f]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),[x,S]=Q.useState(null),[C,w]=Q.useState(null),[E,D]=Q.useState(null),[k,A]=Q.useState(0),[j,M]=Q.useState(!1),[N,P]=Q.useState(!1),[F,I]=Q.useState(!1),[z,B]=Q.useState(!1),[V,H]=Q.useState(!1),[te,ne]=Q.useState(!1),[U,W]=Q.useState(`nav`),[re,ie]=Q.useState(!1),[G,K]=Q.useState(!1),ae=R(()=>ie(e=>!e)),oe=R(()=>ie(!1)),[q,se]=Q.useState(null),ce=T(e=>e.currentDirectory),le=d(e=>e.setSettingsPage),de=qn(e=>e.available),fe=qn(e=>e.runtimeType),pe=Q.useMemo(()=>ef(),[]),me=Q.useMemo(()=>El(),[]),{data:he=[],refetch:ge}=Xn(ce??null,{enabled:j}),{refetch:_e}=Zn(ce??null,{enabled:j}),ve=ei(e=>e.setMcpDraft),be=ei(e=>e.setSelectedMcp),Se=bn(af(ce)||null)?.files?.length??0;Q.useEffect(()=>ye.onDirectoryRequest(()=>H(!0)),[]);let we=Q.useMemo(()=>O(),[]),Te=dn()===`portrait`,[Ee,De]=Q.useState(we&&!Te),[Oe,ke]=Q.useState(null),Ae=R(e=>{if(e&&le(e),we){W(e?`page-content`:`nav`),I(!0);return}ze.getState().setActiveTab(`settings`)}),je=R(()=>{Ae(`instances`)}),Me=R(()=>{ze.getState().openInstances()}),Ne=R(()=>{ze.getState().closeSecondary()}),Pe=R(async()=>{if(!te){ne(!0);try{let t=await Dl();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`:L.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:L.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:L.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:L.error(n(`mobile.connect.scan.failed`))}}finally{ne(!1)}}});Cn({enabled:!we,rootRoutesBlocked:i||u||p||_||y||o||j||F||z||V||re});let Fe=R(()=>{let e=!Ee;e&&Te&&ke(null),De(e)}),Y=R(()=>{if(b(!1),S(null),w(null),m(!1),g(null),we){se(null),ke(`files`),Te&&De(!1);return}f(!0)}),Ie=R(()=>{m(!1),g(null)}),Le=R(e=>{let t=e.path.trim();if(t){if(b(!1),S(null),w(null),se(null),v(!1),we){d.getState().setPendingFileFocusPath(t),ke(`files`),Te&&De(!1);return}f(!1),g({path:t,targetLine:typeof e.targetLine==`number`&&Number.isFinite(e.targetLine)?Math.max(1,Math.trunc(e.targetLine)):void 0}),m(!0)}}),Re=d(e=>e.pendingFileFocusPath);Q.useEffect(()=>{if(Re){if(we){Y();return}Le({path:Re}),d.getState().setPendingFileFocusPath(null)}},[Re,we,Y,Le]);let Be=R((e=null)=>{if(b(!1),S(null),w(null),D(null),m(!1),g(null),se(e),we){ke(`changes`),Te&&De(!1);return}v(!0)}),Ve=R((e,t,n)=>{se(null),v(!1),m(!1),g(null),S(e??null),w(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(D(r),A(e=>e+1),we){ke(`turn-diff`),Te&&De(!1);return}b(!0)}),He=R(()=>{ke(null),se(null),D(null)}),We=R(e=>{if(Oe===e){He();return}e===`files`?Y():Be()}),Ge=Q.useRef(`changes`);Oe&&(Ge.current=Oe);let[Ke,Je]=Q.useState(!1);Q.useEffect(()=>{if(!we)return;if(Oe){Je(!0);return}let e=window.setTimeout(()=>Je(!1),240);return()=>window.clearTimeout(e)},[Oe,we]);let Xe=Oe??Ge.current,Ze=Qd(`left`,`openchamber.ipad.leftSidebarWidth`,Gd),Qe=Qd(`right`,`openchamber.ipad.rightSidebarWidth`,Kd),et=Q.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:()=>Y(),openSettings:e=>{Ae(e)}}),[Be,Le,Y,Ae,Ve]),tt=R(()=>{v(!1),se(null)}),nt=R(()=>{b(!1),D(null)});Xl(Q.useMemo(()=>({openSessions:()=>{if(we){De(!0);return}ze.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?Y():e===`mcp`?M(!0):e===`instances`?je():e===`update`&&B(!0)},openChanges:({path:e,staged:t}={})=>{Be(e?{path:e,staged:t===!0}:null)},openSettings:e=>{Ae(e)}}),[we,Be,Y,je,Ae]));let rt=Q.useRef(null),it=Q.useRef(null),at=Q.useRef(null),ot=Q.useRef(null),st=Q.useRef(null),ct=Q.useRef(null),lt=J(e=>e.currentSessionId),ut=J(e=>e.setCurrentSession),dt=Q.useMemo(()=>e=>lt?e.getDirectoryForSession(lt):null,[lt]),ft=J(dt),pt=xe(lt,ft||ce||void 0),mt=ue(lt??``);Fd();let ht=mt?.type===`busy`||mt?.type===`retry`,gt=R(()=>{let e=lt;if(!e||G||ht)return;let t=ft||ce||void 0;K(!0),(async()=>{try{await r.refreshSessionTranscript(e,{directory:t}),L.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{L.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{K(!1)}})()}),vt=R(e=>{ct.current=e}),yt=R(e=>{let t=at.current,n=ot.current,r=st.current;if(!t)return;if(!e){t.style.transform=``,t.style.opacity=``,t.style.willChange=``,n&&(n.style.transform=``,n.style.willChange=``),r&&(r.style.transform=``,r.style.willChange=``);return}t.style.willChange||t.getAnimations().forEach(e=>e.cancel()),t.style.willChange=`transform, opacity`,t.style.transform=`translate3d(${e.offsetX}px, 0, 0)`,t.style.opacity=String(1-e.progress*.08),n&&(n.style.willChange=`transform`,n.style.transform=`translate3d(${e.offsetX}px, 0, 0)`),r&&(r.style.willChange=`transform`,r.style.transform=`translate3d(${e.offsetX}px, 0, 0)`);let i=e.direction===`prev`?n:r;i&&Array.from(i.children).forEach(t=>{t instanceof HTMLElement&&(t.style.opacity=e.canSwitch?`1`:`0.35`)})}),bt=ze(e=>e.secondary?.kind??null),xt=!we&&(bt===`chat`||bt===`draft`);Q.useEffect(()=>{!we&&!xt&&ie(!1)},[we,xt]),Q.useEffect(()=>{ie(!1)},[lt]),hu(it,{onSwitch:vt,onProgress:yt},we||xt);let St=we&&s===`assistant`||!we&&!xt||i||u||p||_||y||o||j||F||z||V||re;Fu(it,{onOpen:R(()=>{Yt(Bt)?.finish(`commit`)}),onPreviewStart:R(()=>{Yt(Bt)?.begin(`present`)}),onPreviewCancel:R(()=>{Yt(Bt)?.finish(`cancel`)}),onProgress:R(e=>{e!==null&&Yt(Bt)?.update(e)}),disabled:St},we||xt),Q.useLayoutEffect(()=>{let e=ct.current;if(ct.current=null,!e)return;let t=at.current;if(!t||typeof t.animate!=`function`)return;t.getAnimations().forEach(e=>e.cancel());let n=e===`prev`?-70:70;t.animate([{opacity:.1,transform:`translateX(${n}px)`},{opacity:1,transform:`translateX(0)`}],{duration:300,easing:`cubic-bezier(0.22, 1, 0.36, 1)`})},[lt]);let Ct=R(e=>{rt.current=e});rf(R(()=>re?(ie(!1),!0):V?(H(!1),!0):o?(window.dispatchEvent(new Event(`oc:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):On.backImmediately(`overlay`)?!0:p?(Ie(),!0):u?(f(!1),!0):y?(nt(),!0):_?(tt(),!0):j?(M(!1),!0):F?(I(!1),!0):z?(B(!1),!0):On.requestAnimatedBack(`root`)||rt.current?.()?!0:s===`assistant`?(l(`chat`),!0):pt?(ut(pt.id,pt.directory),!0):!1));let wt=de&&(fe===`desktop`||fe===`web`),Tt=R(()=>{let e=`new-mcp-server`,t=e,n=1;for(;he.some(e=>e.name===t);)t=`${e}-${n}`,n+=1;ve({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),be(t),M(!1),Ae(`mcp`)}),Et=R(()=>{if(N)return;P(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([_e(),ge(),e]).finally(()=>P(!1))}),Dt=J(e=>e.openNewSessionDraft),Ot=Q.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(we){l(`chat`),Dt();return}ze.getState().openDraft()}}];return we||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>Y()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:Se,onSelect:()=>Be()}),e.push({key:`mcp`,iconNode:(0,$.jsx)(Yn,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>M(!0)}),wt&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>B(!0)}),we&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>Ae()}),lt&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:G||ht,spinning:G,onSelect:gt}),e},[lt,Se,we,ht,G,Be,Y,Dt,Ae,gt,l,wt,n]);return(0,$.jsxs)(Hn,{actions:et,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:[we?(0,$.jsxs)(`aside`,{ref:Ze.asideRef,className:X(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!Ee&&`border-r-0`),style:{width:Ee?Ze.width:0,minWidth:Ee?Ze.width:0,maxWidth:Ee?Ze.width:0,"--oc-ipad-sidebar-width":`${Ze.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:Ze.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Ee,"data-page-scroll-lock":`true`,children:[Ee?(0,$.jsx)($d,{side:`left`,isResizing:Ze.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:Ze.handleProps}):null,(0,$.jsx)(`div`,{className:X(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,Ze.isResizing&&`pointer-events-none`,!Ee&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(rn,{children:(0,$.jsx)(Po,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&Te&&De(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,children:we?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(yf,{onOpenSessions:()=>Fe(),menuOpen:re,onToggleMenu:ae,surfaceShortcuts:{activePanel:Oe===`turn-diff`?`changes`:Oe,changesDirty:Se>0,onToggleFiles:()=>We(`files`),onToggleChanges:()=>We(`changes`)}})}),(0,$.jsxs)(`main`,{ref:it,className:`relative min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsxs)(`div`,{ref:ot,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 -left-full flex w-full items-center justify-end gap-3 bg-background pr-4`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.previousSession`)}),(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(Z,{name:`arrow-left`,className:`size-5`})})]}),(0,$.jsxs)(`div`,{ref:st,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 left-full flex w-full items-center justify-start gap-3 bg-background pl-4`,children:[(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(Z,{name:`arrow-right`,className:`size-5`})}),(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.nextSession`)})]}),(0,$.jsx)(`div`,{ref:at,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(rn,{children:s===`assistant`?(0,$.jsx)(li,{}):(0,$.jsx)(Kr,{})})})]})]}):(0,$.jsx)(lc,{className:`min-h-0 flex-1`,onAddProject:()=>H(!0),onScanQr:pe&&me?()=>{Pe()}:void 0,onSwitchInstance:pe?Me:void 0,onEnableAssistants:()=>{Ae(`assistants`)},instancesPage:pe?(0,$.jsx)(ff,{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)(nr,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(ff,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:pt?{id:pt.id,directory:pt.directory}:null,registerSecondaryBackHandler:Ct,scheduledContent:(e,t)=>(0,$.jsx)(Hr,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(cl,{sessionId:e.sessionId,directory:e.directory,onBack:()=>{oe(),On.requestAnimatedBack(`root`)},onOpenMenu:ae,onCloseMenu:oe,menuOpen:e.active&&re,children:(0,$.jsxs)(`main`,{ref:e.active?it:void 0,className:`relative h-full min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[e.active?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{ref:ot,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 -left-full flex w-full items-center justify-end gap-3 bg-background pr-4`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.previousSession`)}),(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(Z,{name:`arrow-left`,className:`size-5`})})]}),(0,$.jsxs)(`div`,{ref:st,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 left-full flex w-full items-center justify-start gap-3 bg-background pl-4`,children:[(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(Z,{name:`arrow-right`,className:`size-5`})}),(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.nextSession`)})]})]}):null,(0,$.jsx)(`div`,{ref:e.active?at:void 0,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(rn,{children:(0,$.jsx)(Kr,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:e.sessionId||null,directory:e.directory,viewKey:e.viewKey}})})})]})})})}),we?(0,$.jsxs)(`aside`,{ref:Qe.asideRef,className:X(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!Oe&&`border-l-0`),style:{width:Oe?Qe.width:0,minWidth:Oe?Qe.width:0,maxWidth:Oe?Qe.width:0,"--oc-ipad-sidebar-width":`${Qe.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:Qe.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Oe,"data-page-scroll-lock":`true`,children:[Oe?(0,$.jsx)($d,{side:`right`,isResizing:Qe.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:Qe.handleProps}):null,(0,$.jsx)(`div`,{className:X(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,Qe.isResizing&&`pointer-events-none`,!Oe&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:Ke?(0,$.jsx)(rn,{children:Xe===`files`?(0,$.jsx)(Za,{onClose:He}):Xe===`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)($e,{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)(Z,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(gr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,targetFilePath:E,navigationRequestKey:k,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)($e,{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)(Z,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(gr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:q.path,targetLine:q.targetLine??null,toolPatches:q.toolPatches,singleFileView:q.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(va,{onClose:He,initialDiffPath:q?.path??null,initialDiffStaged:q?.staged===!0,initialDiffTargetLine:q?.targetLine??null})}):null})]}):null,(0,$.jsx)(Lr,{open:V,onOpenChange:H,forceMobile:!0}),(0,$.jsx)(_f,{open:re,onClose:()=>ie(!1),items:Ot,rightOffset:we&&Oe?Qe.width:0}),(0,$.jsx)(jr,{}),u?(0,$.jsx)(Kt,{id:zd,open:u,onOpenChange:e=>{e||f(!1)},ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(rn,{children:(0,$.jsx)(Za,{onClose:()=>f(!1)})})}):null,p&&h?(0,$.jsx)(Kt,{id:Rd,open:p,onOpenChange:e=>{e||Ie()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:h.path.split(/[/\\]/).filter(Boolean).at(-1)??h.path}),ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(rn,{children:(0,$.jsx)(Za,{onClose:Ie,initialFilePath:h.path,directFilePreview:!0,hideFileHeader:!0},h.path)})}):null,(0,$.jsx)(Kt,{id:Ld,open:y,onOpenChange:e=>{e||nt()},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)(rn,{children:(0,$.jsx)(gr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,targetFilePath:E,navigationRequestKey:k,flushContent:!0})})}),_&&q?(0,$.jsx)(Kt,{id:Id,open:_,onOpenChange:e=>{e||tt()},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)(rn,{children:q.toolPatches?.length?(0,$.jsx)(gr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:q.path,targetLine:q.targetLine??null,toolPatches:q.toolPatches,singleFileView:q.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(va,{initialDiffPath:q.path,initialDiffStaged:q.staged,initialDiffTargetLine:q.targetLine??null,hideDiffHeader:!0})})}):_?(0,$.jsx)(Kt,{id:Bd,open:_,onOpenChange:e=>{e||tt()},ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(rn,{children:(0,$.jsx)(va,{onClose:tt,initialDiffPath:q?.path??null,initialDiffStaged:q?.staged===!0,initialDiffTargetLine:q?.targetLine??null})})}):null,j?(0,$.jsx)(Kt,{id:Vd,open:j,onOpenChange:e=>{e||M(!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)($e,{type:`button`,variant:`ghost`,size:`icon`,onClick:Tt,"aria-label":n(`settings.mcp.sidebar.actions.addServerTitle`),title:n(`settings.mcp.sidebar.actions.addServerTitle`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`add`,className:`size-5`})}),(0,$.jsx)($e,{type:`button`,variant:`ghost`,size:`icon`,onClick:Et,disabled:N,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`refresh`,className:X(`size-5`,N&&`animate-spin`)})})]}),ariaLabel:n(`mcpDropdown.title`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(rn,{children:(0,$.jsx)(Dr,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,F&&we?(0,$.jsx)(Kt,{id:Hd,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)(rn,{children:(0,$.jsx)(ai,{forceMobile:!0,isWindowed:!0,initialMobileStage:U,visiblePageSlugs:[...rr],onClose:()=>I(!1),mobileInstancesPage:pe?(0,$.jsx)(ff,{connection:e,onConnect:()=>I(!1),onActiveConnectionDeleted:t}):void 0})})}):null,z?(0,$.jsx)(Kt,{id:Ud,open:z,onOpenChange:e=>{e||B(!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)(rn,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(ti,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(Qr,{enabled:pe&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(rn,{children:(0,$.jsx)(Zr,{})})]})};function xf({apis:e}){Q.useEffect(()=>Ke(),[]);let{t}=ee(),i=Se(e=>e.initializeApp),a=Se(e=>e.isInitialized),o=Se(e=>e.isConnected),s=Se(e=>e.connectionPhase),c=T(e=>e.currentDirectory),u=J(e=>e.currentSessionId),f=J(e=>!!e.newSessionDraft?.open),p=J(e=>e.error),h=J(e=>e.clearError),g=d(e=>e.setIsMobile),_=ir(e=>e.refreshStatus),v=Me(e=>e.projects),[y,b]=Q.useState(0),[x,S]=Q.useState(0),[C,w]=Q.useState(!1),[D,O]=Q.useState(`pending`),k=Q.useMemo(()=>re(),[]),[,A]=Q.useReducer(e=>e+1,0),j=Q.useMemo(()=>ef(),[]),N=Q.useRef(0),P=Q.useRef(0),I=W(()=>{O(`done`),b(e=>e+1)});Zl(R(e=>{I.redeemPairingConnection(e)}));let z=Ql({ready:j&&o&&a});Q.useEffect(()=>{!I.error||!r()||L.error(I.error)},[I.error]);let B=R(()=>{let t=r(),n=P.current+1;if(P.current=n,!t){G();return}let a=()=>{i(),_(e.github,{force:!0}),Se.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},o=()=>{l({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),b(e=>e+1)};U().then(e=>{if(P.current===n){if(e===`no-connection`){o();return}if(e===`unreachable`){window.setTimeout(()=>{P.current===n&&U().then(e=>{if(P.current===n&&e!==`switched`&&e===`unchanged`){a();return}})},4e3);return}e!==`switched`&&a()}});let s=Date.now();s-N.current>=sf&&(N.current=s,window.dispatchEvent(new Event(`openchamber:system-resume`)))});tf(),nf(B),Q.useEffect(()=>{if(!j)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>B(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[j,B]),Q.useEffect(()=>(m(e),()=>m(null)),[e]),Q.useEffect(()=>{j&&F().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[j]),Q.useEffect(()=>{if(!j)return;let e=!1,t=[];return F().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`download`,e=>{qn.getState().setOtaDownloadPercent(e.percent)}),i=await n.addListener(`downloadFailed`,()=>{qn.getState().setOtaDownloadFailed()}),a=await n.addListener(`downloadComplete`,()=>{qn.getState().setOtaPhase(`pending_restart`)}),o=await n.addListener(`appReloaded`,()=>{qn.getState().setOtaPhase(`pending_restart`)}),s=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),qn.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()}},[j]),Q.useEffect(()=>n(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){Gr(),A();return}Rr(e),ze.getState().reset(),S(e=>e+1),b(e=>e+1)}),[]),Q.useEffect(()=>{if(z===`pending`)return;if(z===`connect`){O(`done`);return}if(!j||o||r()){O(`done`);return}let e=!1;return O(`attempting`),ie().then(e=>e?!0:G()).catch(()=>!1).then(()=>{e||O(`done`)}),()=>{e=!0}},[z]),Q.useEffect(()=>{g(!0)},[g]),Q.useEffect(()=>{j&&!r()||i()},[y,i,j]),vt({enabled:!j||!!r(),source:`mobileApp:recovery`}),Q.useEffect(()=>{o&&E.setDirectory(c)},[c,o]),Q.useEffect(()=>{o&&_(e.github,{force:!0})},[e.github,o,_]),Q.useEffect(()=>{if(!o||v.length===0)return;let e=!1;return(async()=>{await Promise.all(v.map(async t=>{let n=af(t.path);if(n)try{if(!(_n.getState().directories.get(n)?.isGitRepo??await M(()=>import(`./gitApi-Dhf22VRf.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([52,1,5,2,3,4,6,7,8,34,35,10,36,37,38,20,21,22,23,24,39,40])))||e)return;await Jt({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[o,v]),Q.useEffect(()=>{if(!p)return;let e=window.setTimeout(()=>h(),5e3);return()=>window.clearTimeout(e)},[h,p]),Q.useEffect(()=>{if(!(!o&&(!j||r()))){w(!1);return}let e=window.setTimeout(()=>w(!0),8e3);return()=>window.clearTimeout(e)},[o,j,y,x]),Ot(),ot({enabled:!0}),gt(),Jr(),Ru({enabled:j&&o});let V=jl(),H=!o&&s===`reconnecting`;if(!V)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(on,{width:120,height:120,isAnimated:!0})});let te=!!r();return j&&(!te||!o&&!H)?te?(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)(on,{width:120,height:120,isAnimated:!C}),C?(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)($e,{type:`button`,variant:`outline`,onClick:()=>{l({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),b(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):D===`done`?(0,$.jsx)(df,{connection:I}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(on,{width:120,height:120,isAnimated:!0}),k?(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:[k,(0,$.jsx)(kt,{})]})]}):null]}):!o&&!H?C?(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)(on,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(rn,{children:(0,$.jsx)(pe,{sdk:E.getSdkClient(),directory:c||``,bootstrapDirectory:!(f&&u===null),children:(0,$.jsx)(At,{apis:e,children:(0,$.jsx)(Zt,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(Tr,{}),(0,$.jsx)(K,{}),(0,$.jsx)(St,{embeddedBackgroundWorkEnabled:a}),(0,$.jsx)(Wr,{}),(0,$.jsx)(Ri,{}),(0,$.jsx)(Ji,{}),(0,$.jsx)(bf,{connection:I,onActiveConnectionDeleted:()=>{l({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),ze.getState().reset(),b(e=>e+1)}}),(0,$.jsx)(st,{position:`top-center`,offset:`calc(var(--oc-safe-area-top, 0px) + 16px)`}),a?(0,$.jsx)(zr,{}):null]})})})},x)})}function Sf(e){e.currentTarget.style.transform=`none`}function Cf(e){return e.ensureStatus}function wf(e){return e.fetchStatus}function Tf(e){return e.providers}function Ef(e){return e.currentProviderId}function Df(e){return e.currentModelId}function Of(e){return e.getModelMetadata}function kf(e){return e.results}function Af(e){return e.loadSettings}function jf(e){return e.fetchAllQuotas}function Mf(e){return e.isLoading}function Nf(e){return e.displayMode}function Pf(e){return e.dropdownProviderIds}function Ff(e){return e.selectedModels}function If(e){return e.timeFormatPreference}function Lf(e){return[e.providerId,e]}function Rf(e){return e.providerId}function zf(e){return!e}var Bf=()=>{H(),v().then(()=>{Promise.all([_(),ut()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),Ct(),mt(),ct()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{Ci()})};function Vf(e){jn(),Bf(),d.getState().setIsMobile(!0),ji(),fn(),pn();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)(xf,{apis:r});(0,yi.createRoot)(t).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(lt,{children:(0,$.jsx)(z,{children:(0,$.jsx)(at,{children:(0,$.jsx)(ft,{children:(0,$.jsx)(Vr,{children:n?i:(0,$.jsx)(pt,{children:i})})})})})})}))}export{Vf as renderMobileApp};
|