@openchambery/web 1.18.2-beta.39 → 1.18.2-beta.40
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/{AgentAvatar-SFzXgOdv.js → AgentAvatar-OmE7AspO.js} +1 -1
- package/dist/assets/{AssistantView-CvYXAhVR.js → AssistantView-1qhaLhHt.js} +1 -1
- package/dist/assets/{ChatContainer-Be1DHzgc.js → ChatContainer-CEXwPvOE.js} +4 -4
- package/dist/assets/{DiagramView-D0COpV7w.js → DiagramView-zedL3sNZ.js} +1 -1
- package/dist/assets/{FadeInOnReveal-9uJN0g-H.js → FadeInOnReveal-EygBOzfu.js} +1 -1
- package/dist/assets/{Icon-CBdklpKH.js → Icon-C0dydAmx.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DzZY5lYZ.js → MarkdownRendererImpl-CbBKHgg_.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-DnkLVrVy.js → MobileDetailNavigation-BuGHMy3o.js} +1 -1
- package/dist/assets/{MobileShareBridge-C_m49-E6.js → MobileShareBridge-DwJRFCl2.js} +2 -2
- package/dist/assets/{MobileSurface-DPBYd_9L.js → MobileSurface-BBWgxzyI.js} +1 -1
- package/dist/assets/{MultiRunWindow-DPm1lQmo.js → MultiRunWindow-DJu-y4fb.js} +1 -1
- package/dist/assets/{OnboardingScreen-C1kAHsU9.js → OnboardingScreen-Ck8vLrCb.js} +1 -1
- package/dist/assets/{OverlayScrollbar-iaMCjwrs.js → OverlayScrollbar-DMQhwzR3.js} +1 -1
- package/dist/assets/{SettingsView-jKwiCthd.js → SettingsView-BzZTiaDd.js} +1 -1
- package/dist/assets/{SettingsWindow-YVW1K0vh.js → SettingsWindow-Biji-Bb4.js} +1 -1
- package/dist/assets/{TerminalView-CiyuM0im.js → TerminalView-BKCM76aM.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DMHFrQtf.js → ToolOutputDialog-6lL_lCmU.js} +1 -1
- package/dist/assets/{appThemeRegistry-CBs9rFM0.js → appThemeRegistry-DUeCYxWD.js} +2 -2
- package/dist/assets/{button-DimCg1lF.js → button-Iv9uULki.js} +1 -1
- package/dist/assets/{clipboard-mzqrY_n2.js → clipboard-DH0BvKYH.js} +1 -1
- package/dist/assets/{collapsible-CF7TDu-T.js → collapsible-C46kU7ea.js} +1 -1
- package/dist/assets/{context-menu-ZC-7T9D6.js → context-menu-BWKM1gKq.js} +1 -1
- package/dist/assets/{desktopHosts-Tqz56Y0u.js → desktopHosts-DV_01iQq.js} +1 -1
- package/dist/assets/{desktopRelayRestore-DgHC01I5.js → desktopRelayRestore-DhQzRu4d.js} +1 -1
- package/dist/assets/{diagram-DObb9lfm.js → diagram-CqOdzPLy.js} +1 -1
- package/dist/assets/{dialog-DDrJKIhd.js → dialog-BPXCMWcj.js} +1 -1
- package/dist/assets/{fileQueries-BjL2dHDF.js → fileQueries-EAHC6GsF.js} +1 -1
- package/dist/assets/{gitApi-CdLpItUF.js → gitApi-4LIdr-v1.js} +1 -1
- package/dist/assets/{input-BNj7D6h_.js → input-7arjRNdx.js} +1 -1
- package/dist/assets/{insertionBoundaries-Dx-FimZn.js → insertionBoundaries-Dbq-aDBu.js} +1 -1
- package/dist/assets/{main-B2Qp731c.js → main-C-5guI2W.js} +2 -2
- package/dist/assets/{main-Dq04PAJw.js → main-CyVIqNNp.js} +4 -4
- package/dist/assets/{markdown-worker-CJ8ooXEK.js → markdown-worker-sIoCa792.js} +1 -1
- package/dist/assets/{markdownTheme-CziN3c9i.js → markdownTheme-QtXMKzKz.js} +1 -1
- package/dist/assets/{miniChat-XD8besP9.js → miniChat-DjAmMQNF.js} +2 -2
- package/dist/assets/mobile-B72TTAxF.js +2 -0
- package/dist/assets/{multirun-CgKdqjlp.js → multirun-hsF95duc.js} +1 -1
- package/dist/assets/{persistence-ZSrLIR97.js → persistence-Cm9DnxXq.js} +1 -1
- package/dist/assets/{platform-BiSk9jV3.js → platform-BrOZ1tqx.js} +1 -1
- package/dist/assets/{projectMeta-jWxWbDkQ.js → projectMeta-r5NAkHfX.js} +1 -1
- package/dist/assets/{radio-BArg8rN7.js → radio-G_YvD3ft.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CcHll5HJ.js → renderElectronMiniChatApp-YPzmrpPR.js} +2 -2
- package/dist/assets/{renderMobileApp-z9BLmg-1.js → renderMobileApp-CIKcbD89.js} +4 -4
- package/dist/assets/{runtimeConfig-o7VOqbIv.js → runtimeConfig-EBmDM9YF.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-ZQl4KUPA.js → runtimeEndpointReset-m802uRQ1.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-CBs61Gj9.js → sortable-tabs-strip-OO0ijdmq.js} +1 -1
- package/dist/assets/{terminalApi-CkknnXhV.js → terminalApi-BunCJZ0A.js} +1 -1
- package/dist/assets/{tooltip-BE6WDmtb.js → tooltip-CO8qCWXw.js} +1 -1
- package/dist/assets/{url-DQDmlZku.js → url-CM2fyKko.js} +1 -1
- package/dist/assets/{useAppFontEffects-BnAqVzvs.js → useAppFontEffects-BApC_Nk8.js} +2 -2
- package/dist/assets/{useAssistantUIStore-Bq3cPj2x.js → useAssistantUIStore-B9YvQgXU.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-DW06JgtH.js → useDesktopWindowControlsLayout-CPOQ6w0N.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-Cxk960zS.js → useEffectiveDirectory-Bc-cEAh0.js} +1 -1
- package/dist/assets/{useFontPreferences-ZvBF445N.js → useFontPreferences-DKIVD8RE.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-7SQlIaRN.js → useMobileNavigationStore-f5hodHkc.js} +2 -2
- package/dist/assets/{useSessionAutoCleanup-fCB4vS1c.js → useSessionAutoCleanup-EKU0ZYhf.js} +1 -1
- package/dist/assets/{useUIStore-5agS8bsW.js → useUIStore-CL06MzOk.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-Dur8-7lm.js → useWorkerHighlightedLines-DBz6RbGf.js} +1 -1
- package/dist/assets/{utils-Dh7UZFrA.js → utils-DlvuQ5yV.js} +1 -1
- package/dist/index.html +8 -8
- package/dist/mini-chat.html +8 -8
- package/dist/mobile.html +8 -8
- package/package.json +1 -1
- package/dist/assets/mobile-B-urUzQ2.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{A as t,D as n,F as r,M as i,W as a,Z as o,b as s,j as c,t as l,w as u}from"./useUIStore-5agS8bsW.js";import{$ as d,Sn as f,kn as p,kt as m,n as h,t as g,xn as _}from"./persistence-ZSrLIR97.js";import{a as v,i as y}from"./vendor-zustand-B4dlGEM2.js";import{nt as b,rt as x}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as S,Nt as C,n as w,r as T,t as E}from"./platform-BiSk9jV3.js";import{a as D,n as O,o as k}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as A,t as j}from"./vendor-react-DLPElpoQ.js";import{t as M}from"./capgoAdapter-BSPH5_gX.js";/* empty css */import{r as N}from"./vendor-sonner-DVzioF3d.js";import{n as P}from"./vendor-reactuses-core-DDoDDyM9.js";import{i as F,n as ee,t as te}from"./clipboard-mzqrY_n2.js";import{n as I}from"./store-BLmIK6EO.js";import{a as L,c as R,d as z,f as B,l as V,o as H,p as U,t as W,u as ne}from"./MobileShareBridge-C_m49-E6.js";import{$i as re,Ba as ie,Da as G,Ea as ae,En as K,Fr as oe,Gt as se,I as q,It as ce,Qt as le,Ra as ue,Sr as de,Wt as fe,_r as pe,br as me,cr as he,en as ge,fr as _e,gr as ve,hr as ye,ii as be,in as xe,kn as Se,kt as Ce,l as J,lr as we,mr as Te,oa as Ee,r as De,rn as Oe,t as ke,ta as Ae,tn as je,vr as Y,xo as Me,xr as Ne,yr as Pe,za as Fe,zt as Ie}from"./useMobileNavigationStore-7SQlIaRN.js";import{_ as Le,t as Re,y as ze}from"./MobileDetailNavigation-DnkLVrVy.js";import{i as Be,r as Ve}from"./useAssistantUIStore-Bq3cPj2x.js";import{t as He}from"./AgentAvatar-SFzXgOdv.js";import{t as X}from"./utils-Dh7UZFrA.js";import{n as Z}from"./Icon-CBdklpKH.js";import{t as Ue}from"./button-DimCg1lF.js";import{F as We,I as Ge,M as Ke,N as qe,p as Je}from"./gitApi-CdLpItUF.js";import{B as Ye,C as Xe,G as Ze,H as Qe,K as $e,Q as et,R as tt,S as nt,U as rt,V as it,W as at,i as ot,o as st,q as ct,r as lt,s as ut,t as dt,z as ft}from"./useAppFontEffects-BnAqVzvs.js";import{D as pt,E as mt,a as ht,c as gt,i as _t,j as vt,n as yt,p as bt}from"./projectMeta-jWxWbDkQ.js";import{t as xt}from"./input-BNj7D6h_.js";import{r as St}from"./tooltip-BE6WDmtb.js";import{c as Ct,f as wt,o as Tt,p as Et,s as Dt,u as Ot}from"./useSessionAutoCleanup-fCB4vS1c.js";import{n as kt}from"./useThemeSystem-DMzWVJaW.js";import{D as At,E as jt,N as Mt,O as Nt,Q as Pt,Z as Ft,_ as It,b as Lt,y as Rt}from"./radio-BArg8rN7.js";import{a as zt,n as Bt,s as Vt}from"./OverlayScrollbar-iaMCjwrs.js";import{x as Ht}from"./markdownTheme-CziN3c9i.js";import{H as Ut,M as Wt,U as Gt,j as Kt,m as qt,q as Jt,y as Yt,z as Xt}from"./ChatContainer-Be1DHzgc.js";import{n as Zt}from"./useRuntimeAPIs-DSLXJybW.js";import{c as Qt,i as $t,l as en,o as tn,s as nn,t as rn,u as an}from"./appThemeRegistry-CBs9rFM0.js";import{a as on}from"./url-DQDmlZku.js";import{f as sn,h as cn,p as ln}from"./markdown-worker-CJ8ooXEK.js";import{n as un}from"./useEffectiveDirectory-Cxk960zS.js";import{f as dn}from"./FadeInOnReveal-9uJN0g-H.js";import{M as fn,b as pn,g as mn,x as hn,y as gn}from"./insertionBoundaries-Dx-FimZn.js";import{a as _n}from"./vendor-pierre-diffs-BenIz2TM.js";import{$ as vn,B as yn,I as bn,Q as xn,X as Sn,Z as Cn,_ as wn,a as Tn,b as En,i as Dn,n as On,o as kn,p as An,r as jn,t as Mn,v as Nn,z as Pn}from"./MobileSurface-DPBYd_9L.js";import{t as Fn}from"./useFontPreferences-ZvBF445N.js";import{$ as In,C as Ln,E as Rn,H as zn,J as Bn,L as Vn,M as Hn,Q as Un,R as Wn,S as Gn,T as Kn,U as qn,X as Jn,Y as Yn,_ as Xn,a as Zn,b as Qn,c as $n,f as er,g as tr,h as nr,i as rr,l as ir,m as ar,n as or,o as sr,p as cr,r as lr,s as ur,t as dr,u as fr,v as pr,w as mr,x as hr,y as gr,z as _r}from"./runtimeEndpointReset-ZQl4KUPA.js";import{a as vr,c as yr,i as br,l as xr,o as Sr,r as Cr,s as wr,t as Tr}from"./SettingsView-jKwiCthd.js";import{a as Er,i as Dr,n as Or,r as kr,t as Ar}from"./context-menu-ZC-7T9D6.js";import{r as jr,t as Mr}from"./AssistantView-CvYXAhVR.js";import{a as Nr,i as Pr,r as Fr}from"./fileQueries-BjL2dHDF.js";var Q=e(x(),1),Ir=j(),Lr=null,Rr=!1,zr=new Promise(e=>{Lr=e});function Br(){Rr||(Rr=!0,Lr?.())}var Vr=6,Hr=e=>e.parentID??null,Ur=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},Wr=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),Gr=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=Wr(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return Ur(n?n.path:e)},Kr=()=>{let e=ye.getState().activeSessions,t=K.getState().index.session.unseenCount,n=Me.getState().projects,r=0,i=[];for(let a of e){let e=Hr(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:Gr(_e(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,Vr).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},qr=`__OPENCHAMBER_WIDGET_SNAPSHOT__`,Jr=()=>{typeof window>`u`||(window[qr]=()=>{try{return JSON.stringify(Kr())}catch{return null}})},Yr=A(),Xr=D(`OpenChamberExternalBrowser`),Zr={getPlatform:()=>O.getPlatform(),isPluginAvailable:e=>O.isPluginAvailable(e),openInSystemBrowser:e=>Xr.open(e),openExternal:on},Qr=async(e,t=Zr)=>{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)},$=b(),$r=`mobile-app-update-available`,ei=`mobile-app-update-toast-dismissed-version`,ti=()=>{let e=(0,Yr.c)(9),{t}=ee(),n=yn(ni),r=yn(ri),i=yn(ii),a=yn(ai),o=yn(oi),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=new Set,e[0]=c):c=e[0];let l=Q.useRef(c),u,d;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(u=()=>{if(E()!==`android`||r!==`mobile`||!n||!i||!a||o){Y.dismiss($r);return}s().getItem(ei)!==i&&(l.current.has(i)||(l.current.add(i),Y.info(t(`mobileUpdate.toast.available.title`),{id:$r,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:()=>{Qr(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{s().setItem(ei,i),Y.dismiss($r)}}})))},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 ni(e){return e.available}function ri(e){return e.runtimeType}function ii(e){return e.info?.version}function ai(e){return e.info?.downloadUrl}function oi(e){return e.info?.inAppApply===!0}var si=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),ci=e=>e.enabled&&!e.alreadyChecked,li=`mobile-ota-update-available`,ui=`mobile-ota-update-toast-dismissed-version`,di=()=>{let e=(0,Yr.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),c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=w(),e[1]=c):c=e[1];let l=c,u=yn(fi),d=yn(pi),f=yn(mi),p=yn(hi),m=yn(gi),h=yn(_i),g=yn(vi),_=yn(yi),v=yn(bi),y=f?.version,b=f?.inAppApply===!0,x,S;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{ci({enabled:l,alreadyChecked:i.current})&&(i.current=!0,yn.getState().checkForUpdates().catch(xi))},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 T=P(C),E=P(Si),D,O;if(e[5]!==u||e[6]!==E||e[7]!==b||e[8]!==T||e[9]!==d||e[10]!==t||e[11]!==y?(D=()=>{if(!si({enabled:l,runtimeType:d,available:u,inAppApply:b,version:y??``,dismissedVersion:s().getItem(ui),seenVersions:o.current})||!y){(!u||!b||d!==`mobile`)&&Y.dismiss(li);return}o.current.add(y),Y.info(t(`mobileUpdate.ota.toast.available.title`),{id:li,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:T},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{E(y)}}})},O=[u,b,l,T,E,d,t,y],e[5]=u,e[6]=E,e[7]=b,e[8]=T,e[9]=d,e[10]=t,e[11]=y,e[12]=D,e[13]=O):(D=e[12],O=e[13]),Q.useEffect(D,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)(Pn,{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 fi(e){return e.available}function pi(e){return e.runtimeType}function mi(e){return e.info}function hi(e){return e.downloading}function gi(e){return e.downloaded}function _i(e){return e.progress}function vi(e){return e.error}function yi(e){return e.downloadUpdate}function bi(e){return e.restartToUpdate}function xi(){}function Si(e){s().setItem(ui,e),Y.dismiss(li)}var Ci=e=>{let t=(0,Yr.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},wi=`.oc-mobile-composer`;function Ti(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(wi)}function Ei(e){if(!e||typeof e!=`object`||Ti(e))return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;return n===`TEXTAREA`||n===`INPUT`||t.isContentEditable===!0}function Di(e){return Ti(e??null)}function Oi(e,t){return e?`cache`:Ti(t??null)?`open`:Ei(t??null)?`field`:`ignore`}function ki(e,t){return!(t>0)||!(e>=0)?!1:t>e+24}function Ai(e,t){return e>0?Math.max(0,Math.round(e/(Number.isFinite(t)&&t>0?t:1))):0}var ji=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Mi=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},Ni=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},Pi=(e,t)=>t?`${e}\u0000staged`:e,Fi=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=ee(),{git:o}=Zt(),s=ji(un()??null),c=gn(s||null),l=hn(s||null),u=mn(s||null),d=pn(e=>e.setActiveDirectory),f=pn(e=>e.ensureAll),p=pn(e=>e.fetchStatus),m=pn(e=>e.fetchBranches),h=pn(e=>e.prefetchDiffs),g=pn(e=>e.getDiff),_=pn(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,F]=Q.useState([]),[te,I]=Q.useState([]),[L,R]=Q.useState([]),[z,B]=Q.useState(null),[V,H]=Q.useState({key:null,loading:!1,error:null,resolved:!1}),[U,W]=Q.useState(0),ne=Q.useRef({key:null,generation:0}),[re,ie]=Q.useState(!1),G=rr(c)&&!re,ae=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]),K=Q.useMemo(()=>ae.filter(Mi),[ae]),oe=Q.useMemo(()=>ae.filter(Ni),[ae]),{deferredStagedCount:se,deferredUnstagedCount:q}=Q.useMemo(()=>{if(!G||!c)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of c.files??[])Mi(n)&&(e+=1),Ni(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||z?[{name:e||`origin`,fetchUrl:z??``,pushUrl:z??``}]:[]},[z,L,c?.tracking]),le=Q.useMemo(()=>e=>!s||v.type!==`diff`?null:e.directories.get(s)?.diffCache.get(Pi(v.path,v.staged))??null,[s,v]),ue=pn(le),de=Q.useMemo(()=>v.type===`diff`?ae.find(e=>e.path===v.path)??null:null,[ae,v]),fe=v.type===`diff`&&s?`${s}\u0000${Pi(v.path,v.staged)}`:null,pe=V.key===fe,me=!!(fe&&!ue&&(!pe||V.loading)),he=pe?V.error:null,ge=!!(de||pe&&V.resolved),_e=P(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=P(async(e,t,n)=>{let r=()=>ne.current.key===t&&ne.current.generation===n;try{let[t,n]=await Promise.all([o.getRemotes(e).catch(()=>[]),o.getRemoteUrl?o.getRemoteUrl(e).catch(()=>null):Promise.resolve(null)]);if(!r())return;R(t),B(n)}catch{if(!r())return;R([]),B(null)}}),ye=P(e=>{if(e!==s)return{requestGeneration:null,promise:Promise.resolve()};let t=ne.current.generation+1;return ne.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){ne.current={key:null,generation:ne.current.generation+1},R([]),B(null);return}let{requestGeneration:e,promise:t}=ye(s);return()=>{e!==null&&ne.current.key===s&&ne.current.generation===e&&(ne.current={key:s,generation:e+1})}},[s,o,ye]),Q.useEffect(()=>{if(!s||ae.length===0)return;let e=Array.from(new Set([...K.map(e=>e.path),...te,...ae.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)},[ae,s,o,h,K,te]),Q.useEffect(()=>{if(v.type!==`diff`){H({key:null,loading:!1,error:null,resolved:!1});return}let e=Pi(v.path,v.staged);if(!s||!fe){H({key:null,loading:!1,error:null,resolved:!1});return}if(g(s,e)){H(e=>({key:fe,loading:!1,error:null,resolved:e.key===fe&&e.resolved||!!de}));return}let t=!1;return H({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}),H(e=>e.key===fe?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||H(t=>t.key===fe?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[fe,s,U,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=P(async(e,t)=>{if(!s||e.length===0)return;let n=s;try{t===`stage`?e.length>1?await qe(n,e):await Ke(n,e[0]):e.length>1?await Ge(n,e):await We(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=P((e,t=!1)=>{y({type:`diff`,path:e,staged:t,targetLine:null})}),Ce=P(()=>v.type===`diff`&&(y({type:`list`}),!0));Qt({id:`mobile-changes-diff`,active:v.type===`diff`&&!i,layer:`overlay`,onBack:Ce,surfaceRef:b});let J=P(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})}}),we=P(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)}}),Te=P(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){F([]);return}E(e=>`${e.trim()}${e.trim()?`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-6lL_lCmU.js","assets/rolldown-runtime-C0FnF6B9.js","assets/useUIStore-CL06MzOk.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-base-ui-CnHfUmDN.js","assets/persistence-Cm9DnxXq.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/vendor-reactuses-core-DDoDDyM9.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/clipboard-DH0BvKYH.js","assets/store-BLmIK6EO.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/utils-DlvuQ5yV.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-C0dydAmx.js","assets/dialog-BPXCMWcj.js","assets/button-Iv9uULki.js","assets/useThemeSystem-DMzWVJaW.js","assets/markdownTheme-QtXMKzKz.js","assets/vendor-pierre-diffs-BenIz2TM.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/appThemeRegistry-DUeCYxWD.js","assets/platform-BrOZ1tqx.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/markdown-worker-sIoCa792.js","assets/useEffectiveDirectory-Bc-cEAh0.js","assets/useMobileNavigationStore-f5hodHkc.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/useAssistantUIStore-B9YvQgXU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/useWorkerHighlightedLines-DBz6RbGf.js","assets/tooltip-CO8qCWXw.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-4LIdr-v1.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,D as n,F as r,M as i,W as a,Z as o,b as s,j as c,t as l,w as u}from"./useUIStore-CL06MzOk.js";import{$ as d,Sn as f,kn as p,kt as m,n as h,t as g,xn as _}from"./persistence-Cm9DnxXq.js";import{a as v,i as y}from"./vendor-zustand-B4dlGEM2.js";import{nt as b,rt as x}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as S,Nt as C,n as w,r as T,t as E}from"./platform-BrOZ1tqx.js";import{a as D,n as O,o as k}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as A,t as j}from"./vendor-react-DLPElpoQ.js";import{t as M}from"./capgoAdapter-BSPH5_gX.js";/* empty css */import{r as N}from"./vendor-sonner-DVzioF3d.js";import{n as P}from"./vendor-reactuses-core-DDoDDyM9.js";import{i as F,n as ee,t as te}from"./clipboard-DH0BvKYH.js";import{n as I}from"./store-BLmIK6EO.js";import{a as L,c as R,d as z,f as B,l as V,o as H,p as U,t as W,u as ne}from"./MobileShareBridge-DwJRFCl2.js";import{$i as re,Ba as ie,Da as G,Ea as ae,En as K,Fr as oe,Gt as se,I as q,It as ce,Qt as le,Ra as ue,Sr as de,Wt as fe,_r as pe,br as me,cr as he,en as ge,fr as _e,gr as ve,hr as ye,ii as be,in as xe,kn as Se,kt as Ce,l as J,lr as we,mr as Te,oa as Ee,r as De,rn as Oe,t as ke,ta as Ae,tn as je,vr as Y,xo as Me,xr as Ne,yr as Pe,za as Fe,zt as Ie}from"./useMobileNavigationStore-f5hodHkc.js";import{_ as Le,t as Re,y as ze}from"./MobileDetailNavigation-BuGHMy3o.js";import{i as Be,r as Ve}from"./useAssistantUIStore-B9YvQgXU.js";import{t as He}from"./AgentAvatar-OmE7AspO.js";import{t as X}from"./utils-DlvuQ5yV.js";import{n as Z}from"./Icon-C0dydAmx.js";import{t as Ue}from"./button-Iv9uULki.js";import{F as We,I as Ge,M as Ke,N as qe,p as Je}from"./gitApi-4LIdr-v1.js";import{B as Ye,C as Xe,G as Ze,H as Qe,K as $e,Q as et,R as tt,S as nt,U as rt,V as it,W as at,i as ot,o as st,q as ct,r as lt,s as ut,t as dt,z as ft}from"./useAppFontEffects-BApC_Nk8.js";import{D as pt,E as mt,a as ht,c as gt,i as _t,j as vt,n as yt,p as bt}from"./projectMeta-r5NAkHfX.js";import{t as xt}from"./input-7arjRNdx.js";import{r as St}from"./tooltip-CO8qCWXw.js";import{c as Ct,f as wt,o as Tt,p as Et,s as Dt,u as Ot}from"./useSessionAutoCleanup-EKU0ZYhf.js";import{n as kt}from"./useThemeSystem-DMzWVJaW.js";import{D as At,E as jt,N as Mt,O as Nt,Q as Pt,Z as Ft,_ as It,b as Lt,y as Rt}from"./radio-G_YvD3ft.js";import{a as zt,n as Bt,s as Vt}from"./OverlayScrollbar-DMQhwzR3.js";import{x as Ht}from"./markdownTheme-QtXMKzKz.js";import{H as Ut,M as Wt,U as Gt,j as Kt,m as qt,q as Jt,y as Yt,z as Xt}from"./ChatContainer-CEXwPvOE.js";import{n as Zt}from"./useRuntimeAPIs-DSLXJybW.js";import{c as Qt,i as $t,l as en,o as tn,s as nn,t as rn,u as an}from"./appThemeRegistry-DUeCYxWD.js";import{a as on}from"./url-CM2fyKko.js";import{f as sn,h as cn,p as ln}from"./markdown-worker-sIoCa792.js";import{n as un}from"./useEffectiveDirectory-Bc-cEAh0.js";import{f as dn}from"./FadeInOnReveal-EygBOzfu.js";import{M as fn,b as pn,g as mn,x as hn,y as gn}from"./insertionBoundaries-Dbq-aDBu.js";import{a as _n}from"./vendor-pierre-diffs-BenIz2TM.js";import{$ as vn,B as yn,I as bn,Q as xn,X as Sn,Z as Cn,_ as wn,a as Tn,b as En,i as Dn,n as On,o as kn,p as An,r as jn,t as Mn,v as Nn,z as Pn}from"./MobileSurface-BBWgxzyI.js";import{t as Fn}from"./useFontPreferences-DKIVD8RE.js";import{$ as In,C as Ln,E as Rn,H as zn,J as Bn,L as Vn,M as Hn,Q as Un,R as Wn,S as Gn,T as Kn,U as qn,X as Jn,Y as Yn,_ as Xn,a as Zn,b as Qn,c as $n,f as er,g as tr,h as nr,i as rr,l as ir,m as ar,n as or,o as sr,p as cr,r as lr,s as ur,t as dr,u as fr,v as pr,w as mr,x as hr,y as gr,z as _r}from"./runtimeEndpointReset-m802uRQ1.js";import{a as vr,c as yr,i as br,l as xr,o as Sr,r as Cr,s as wr,t as Tr}from"./SettingsView-BzZTiaDd.js";import{a as Er,i as Dr,n as Or,r as kr,t as Ar}from"./context-menu-BWKM1gKq.js";import{r as jr,t as Mr}from"./AssistantView-1qhaLhHt.js";import{a as Nr,i as Pr,r as Fr}from"./fileQueries-EAHC6GsF.js";var Q=e(x(),1),Ir=j(),Lr=null,Rr=!1,zr=new Promise(e=>{Lr=e});function Br(){Rr||(Rr=!0,Lr?.())}var Vr=6,Hr=e=>e.parentID??null,Ur=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},Wr=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),Gr=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=Wr(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return Ur(n?n.path:e)},Kr=()=>{let e=ye.getState().activeSessions,t=K.getState().index.session.unseenCount,n=Me.getState().projects,r=0,i=[];for(let a of e){let e=Hr(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:Gr(_e(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,Vr).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},qr=`__OPENCHAMBER_WIDGET_SNAPSHOT__`,Jr=()=>{typeof window>`u`||(window[qr]=()=>{try{return JSON.stringify(Kr())}catch{return null}})},Yr=A(),Xr=D(`OpenChamberExternalBrowser`),Zr={getPlatform:()=>O.getPlatform(),isPluginAvailable:e=>O.isPluginAvailable(e),openInSystemBrowser:e=>Xr.open(e),openExternal:on},Qr=async(e,t=Zr)=>{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)},$=b(),$r=`mobile-app-update-available`,ei=`mobile-app-update-toast-dismissed-version`,ti=()=>{let e=(0,Yr.c)(9),{t}=ee(),n=yn(ni),r=yn(ri),i=yn(ii),a=yn(ai),o=yn(oi),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=new Set,e[0]=c):c=e[0];let l=Q.useRef(c),u,d;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(u=()=>{if(E()!==`android`||r!==`mobile`||!n||!i||!a||o){Y.dismiss($r);return}s().getItem(ei)!==i&&(l.current.has(i)||(l.current.add(i),Y.info(t(`mobileUpdate.toast.available.title`),{id:$r,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:()=>{Qr(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{s().setItem(ei,i),Y.dismiss($r)}}})))},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 ni(e){return e.available}function ri(e){return e.runtimeType}function ii(e){return e.info?.version}function ai(e){return e.info?.downloadUrl}function oi(e){return e.info?.inAppApply===!0}var si=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),ci=e=>e.enabled&&!e.alreadyChecked,li=`mobile-ota-update-available`,ui=`mobile-ota-update-toast-dismissed-version`,di=()=>{let e=(0,Yr.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),c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=w(),e[1]=c):c=e[1];let l=c,u=yn(fi),d=yn(pi),f=yn(mi),p=yn(hi),m=yn(gi),h=yn(_i),g=yn(vi),_=yn(yi),v=yn(bi),y=f?.version,b=f?.inAppApply===!0,x,S;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{ci({enabled:l,alreadyChecked:i.current})&&(i.current=!0,yn.getState().checkForUpdates().catch(xi))},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 T=P(C),E=P(Si),D,O;if(e[5]!==u||e[6]!==E||e[7]!==b||e[8]!==T||e[9]!==d||e[10]!==t||e[11]!==y?(D=()=>{if(!si({enabled:l,runtimeType:d,available:u,inAppApply:b,version:y??``,dismissedVersion:s().getItem(ui),seenVersions:o.current})||!y){(!u||!b||d!==`mobile`)&&Y.dismiss(li);return}o.current.add(y),Y.info(t(`mobileUpdate.ota.toast.available.title`),{id:li,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:T},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{E(y)}}})},O=[u,b,l,T,E,d,t,y],e[5]=u,e[6]=E,e[7]=b,e[8]=T,e[9]=d,e[10]=t,e[11]=y,e[12]=D,e[13]=O):(D=e[12],O=e[13]),Q.useEffect(D,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)(Pn,{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 fi(e){return e.available}function pi(e){return e.runtimeType}function mi(e){return e.info}function hi(e){return e.downloading}function gi(e){return e.downloaded}function _i(e){return e.progress}function vi(e){return e.error}function yi(e){return e.downloadUpdate}function bi(e){return e.restartToUpdate}function xi(){}function Si(e){s().setItem(ui,e),Y.dismiss(li)}var Ci=e=>{let t=(0,Yr.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},wi=`.oc-mobile-composer`;function Ti(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(wi)}function Ei(e){if(!e||typeof e!=`object`||Ti(e))return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;return n===`TEXTAREA`||n===`INPUT`||t.isContentEditable===!0}function Di(e){return Ti(e??null)}function Oi(e,t){return e?`cache`:Ti(t??null)?`open`:Ei(t??null)?`field`:`ignore`}function ki(e,t){return!(t>0)||!(e>=0)?!1:t>e+24}function Ai(e,t){return e>0?Math.max(0,Math.round(e/(Number.isFinite(t)&&t>0?t:1))):0}var ji=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Mi=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},Ni=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},Pi=(e,t)=>t?`${e}\u0000staged`:e,Fi=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=ee(),{git:o}=Zt(),s=ji(un()??null),c=gn(s||null),l=hn(s||null),u=mn(s||null),d=pn(e=>e.setActiveDirectory),f=pn(e=>e.ensureAll),p=pn(e=>e.fetchStatus),m=pn(e=>e.fetchBranches),h=pn(e=>e.prefetchDiffs),g=pn(e=>e.getDiff),_=pn(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,F]=Q.useState([]),[te,I]=Q.useState([]),[L,R]=Q.useState([]),[z,B]=Q.useState(null),[V,H]=Q.useState({key:null,loading:!1,error:null,resolved:!1}),[U,W]=Q.useState(0),ne=Q.useRef({key:null,generation:0}),[re,ie]=Q.useState(!1),G=rr(c)&&!re,ae=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]),K=Q.useMemo(()=>ae.filter(Mi),[ae]),oe=Q.useMemo(()=>ae.filter(Ni),[ae]),{deferredStagedCount:se,deferredUnstagedCount:q}=Q.useMemo(()=>{if(!G||!c)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of c.files??[])Mi(n)&&(e+=1),Ni(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||z?[{name:e||`origin`,fetchUrl:z??``,pushUrl:z??``}]:[]},[z,L,c?.tracking]),le=Q.useMemo(()=>e=>!s||v.type!==`diff`?null:e.directories.get(s)?.diffCache.get(Pi(v.path,v.staged))??null,[s,v]),ue=pn(le),de=Q.useMemo(()=>v.type===`diff`?ae.find(e=>e.path===v.path)??null:null,[ae,v]),fe=v.type===`diff`&&s?`${s}\u0000${Pi(v.path,v.staged)}`:null,pe=V.key===fe,me=!!(fe&&!ue&&(!pe||V.loading)),he=pe?V.error:null,ge=!!(de||pe&&V.resolved),_e=P(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=P(async(e,t,n)=>{let r=()=>ne.current.key===t&&ne.current.generation===n;try{let[t,n]=await Promise.all([o.getRemotes(e).catch(()=>[]),o.getRemoteUrl?o.getRemoteUrl(e).catch(()=>null):Promise.resolve(null)]);if(!r())return;R(t),B(n)}catch{if(!r())return;R([]),B(null)}}),ye=P(e=>{if(e!==s)return{requestGeneration:null,promise:Promise.resolve()};let t=ne.current.generation+1;return ne.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){ne.current={key:null,generation:ne.current.generation+1},R([]),B(null);return}let{requestGeneration:e,promise:t}=ye(s);return()=>{e!==null&&ne.current.key===s&&ne.current.generation===e&&(ne.current={key:s,generation:e+1})}},[s,o,ye]),Q.useEffect(()=>{if(!s||ae.length===0)return;let e=Array.from(new Set([...K.map(e=>e.path),...te,...ae.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)},[ae,s,o,h,K,te]),Q.useEffect(()=>{if(v.type!==`diff`){H({key:null,loading:!1,error:null,resolved:!1});return}let e=Pi(v.path,v.staged);if(!s||!fe){H({key:null,loading:!1,error:null,resolved:!1});return}if(g(s,e)){H(e=>({key:fe,loading:!1,error:null,resolved:e.key===fe&&e.resolved||!!de}));return}let t=!1;return H({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}),H(e=>e.key===fe?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||H(t=>t.key===fe?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[fe,s,U,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=P(async(e,t)=>{if(!s||e.length===0)return;let n=s;try{t===`stage`?e.length>1?await qe(n,e):await Ke(n,e[0]):e.length>1?await Ge(n,e):await We(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=P((e,t=!1)=>{y({type:`diff`,path:e,staged:t,targetLine:null})}),Ce=P(()=>v.type===`diff`&&(y({type:`list`}),!0));Qt({id:`mobile-changes-diff`,active:v.type===`diff`&&!i,layer:`overlay`,onBack:Ce,surfaceRef:b});let J=P(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})}}),we=P(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)}}),Te=P(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){F([]);return}E(e=>`${e.trim()}${e.trim()?`
|
|
3
3
|
|
|
4
4
|
`:``}${t.join(`
|
|
5
|
-
`)}`.trim()),F([])}),Ee=P(async()=>{if(!s)return;let e=s,t=K.map(e=>e.path).sort();if(t.length===0){Y.error(a(`gitView.toast.selectFileToDescribe`));return}M(!0);try{let{message:n}=await Je(e,t);E(n.subject?.trim()??``),F(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=K.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(``),F([]),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 K.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:K,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:J,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:J}),e},[J,Se,xe,K,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)(Ii,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):l===!1?ke((0,$.jsx)(Ii,{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)(Li,{path:v.path,diff:ue,fileExists:ge,error:he,loading:me,targetLine:v.targetLine,onBack:Ce,onRetry:()=>W(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)(fr,{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)(Zn,{stagedCount:se,unstagedCount:q,onLoad:()=>ie(!0)})}):ae.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)(sr,{groups:Oe,diffStats:c?.diffStats,revertingPaths:D,onRevertAll:we,isRevertingAll:k,headerBackgroundClassName:`bg-transparent`,onVisiblePathsChange:I})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-4 pt-3`,children:(0,$.jsx)(lr,{stagedCount:K.length,commitMessage:T,onCommitMessageChange:E,generatedHighlights:N,onInsertHighlights:Te,onGenerateMessage:Ee,isGeneratingMessage:j,onCommit:()=>void De({pushAfter:!1}),onCommitAndPush:()=>void De({pushAfter:!0}),commitAction:C,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Ii,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):ke((0,$.jsx)(Ii,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},Ii=e=>{let t=(0,Yr.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},Li=e=>{let t=(0,Yr.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=ln(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)(Ue,{type:`button`,size:`sm`,variant:`outline`,onClick:l,children:f(`diffView.actions.retry`)})]})}):o?(0,$.jsx)(Ii,{loading:!0,message:f(`diffView.state.loadingDiff`)}):i?r?r.isBinary?(0,$.jsx)(Ii,{icon:!0,message:f(`diffView.binary.unavailable`)}):cn(n)?(0,$.jsx)(Ii,{icon:!0,message:f(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(vt,{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)(qn,{original:r.original,modified:r.modified,language:m,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:s,layout:`inline`})}):(0,$.jsx)(Ii,{loading:!0,message:f(`diffView.state.loadingDiff`)}):(0,$.jsx)(Ii,{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],_},Ri=an(()=>k(()=>import(`./ToolOutputDialog-DMHFrQtf.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]))),zi=25e4,Bi=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Vi=e=>{let t=Bi(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},Hi=e=>{let t=Bi(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},Ui=(e,t)=>{let n=Bi(e),r=Bi(t);return!r||n===r?Vi(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},Wi=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``},Gi=e=>e.toLowerCase().endsWith(`.svg`)?``:r().authenticatedAsset(`/api/fs/raw`,{path:e}),Ki=e=>/\.(md|mdx|markdown)$/i.test(e),qi=e=>{let t=(0,Yr.c)(138),{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:u}=ee(),{files:d}=Zt(),f=un()??null,p;t[0]===f?p=t[1]:(p=Bi(f),t[0]=f,t[1]=p);let m=p,h;t[2]!==o||t[3]!==m?(h=()=>{let e=Bi(o);return e?{type:`file`,path:e,returnDirectory:Hi(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=l($i),S=l(ea),C,w;t[5]===m?(C=t[6],w=t[7]):(C=()=>{m&&_(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:Hi(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=Bi(x);if(!e){S(null);return}b(``),_({type:`file`,path:e,returnDirectory:Hi(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=fn(y,250),j;t[13]===y?j=t[14]:(j=y.trim(),t[13]=y,t[14]=j);let M=j,N;t[15]===A?N=t[16]:(N=A.trim(),t[15]=A,t[16]=N);let F=N,I;t[17]!==O||t[18]!==m?(I={scopeDirectory:m,directory:O},t[17]=O,t[18]=m,t[19]=I):I=t[19];let L=!!O,R;t[20]===L?R=t[21]:(R={enabled:L,refetchOnMount:`always`},t[20]=L,t[21]=R);let z=Pr(I,R),B;t[22]!==O||t[23]!==F?(B={directory:O,query:F,maxResults:40},t[22]=O,t[23]=F,t[24]=B):B=t[24];let V=!!(O&&F),H;t[25]===V?H=t[26]:(H={enabled:V},t[25]=V,t[26]=H);let U=Nr(B,H),W;t[27]!==k||t[28]!==d?(W=k&&d.readFile&&(!cn(k)||k.toLowerCase().endsWith(`.svg`)),t[27]=k,t[28]=d,t[29]=W):W=t[29];let ne=!!W,re;t[30]!==k||t[31]!==m?(re={scopeDirectory:m,path:k},t[30]=k,t[31]=m,t[32]=re):re=t[32];let ie;t[33]===ne?ie=t[34]:(ie={enabled:ne},t[33]=ne,t[34]=ie);let G=Fr(re,ie),ae=z.data?.entries.slice().sort(ta)??[],K;t[35]!==z.error||t[36]!==u?(K=z.error?z.error instanceof Error?z.error.message:u(`mobile.files.error.listFailed`):null,t[35]=z.error,t[36]=u,t[37]=K):K=t[37];let oe=K,se=z.isFetching,q;t[38]===U.data?q=t[39]:(q=U.data??[],t[38]=U.data,t[39]=q);let ce=q,le=!!(M&&F&&y===A&&U.isFetching),ue;t[40]!==G.data||t[41]!==u?(ue=G.data&&G.data.length>zi?`${G.data.slice(0,zi)}\n\n${u(`mobile.files.file.truncated`)}`:G.data??``,t[40]=G.data,t[41]=u,t[42]=ue):ue=t[42];let de=ue,fe;t[43]!==k||t[44]!==G.error||t[45]!==d||t[46]!==u?(fe=k&&!d.readFile?u(`mobile.files.error.readUnavailable`):G.error?G.error instanceof Error?G.error.message:u(`filesView.error.readFileFailed`):null,t[43]=k,t[44]=G.error,t[45]=d,t[46]=u,t[47]=fe):fe=t[47];let pe=fe,me=ne&&G.isFetching,he;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(he=e=>{b(``),_({type:`browser`,directory:e})},t[48]=he):he=t[48];let ge=he,_e;t[49]!==D||t[50]!==m?(_e=e=>{_({type:`file`,path:e,returnDirectory:D||m})},t[49]=D,t[50]=m,t[51]=_e):_e=t[51];let ve=_e,ye;t[52]!==s||t[53]!==n||t[54]!==g.returnDirectory||t[55]!==g.type?(ye=()=>g.type===`file`?s?(n?.(),!0):(_({type:`browser`,directory:g.returnDirectory}),!0):!1,t[52]=s,t[53]=n,t[54]=g.returnDirectory,t[55]=g.type,t[56]=ye):ye=t[56];let be=P(ye),xe=g.type===`file`,Se;t[57]!==be||t[58]!==xe?(Se={id:`mobile-files-detail`,active:xe,layer:`overlay`,onBack:be,surfaceRef:v},t[57]=be,t[58]=xe,t[59]=Se):Se=t[59],Qt(Se);let Ce;t[60]===u?Ce=t[61]:(Ce=async e=>{(await te(e)).ok||Y.error(u(`mobile.files.toast.copyFailed`))},t[60]=u,t[61]=Ce);let J=Ce,we;t[62]!==de||t[63]!==u?(we=async()=>{(await te(de)).ok?Y.success(u(`mobile.files.toast.contentCopied`)):Y.error(u(`mobile.files.toast.copyFailed`))},t[62]=de,t[63]=u,t[64]=we):we=t[64];let Te=we;if(!m){let e;t[65]===u?e=t[66]:(e=u(`mobile.files.empty.noDirectory`),t[65]=u,t[66]=e);let n;return t[67]===e?n=t[68]:(n=(0,$.jsx)(Qi,{message:e}),t[67]=e,t[68]=n),n}if(g.type===`file`){let e;t[69]!==J||t[70]!==g.path?(e=()=>void J(g.path),t[69]=J,t[70]=g.path,t[71]=e):e=t[71];let n;t[72]===Te?n=t[73]:(n=()=>void Te(),t[72]=Te,t[73]=n);let r;return t[74]!==be||t[75]!==de||t[76]!==pe||t[77]!==c||t[78]!==me||t[79]!==g.path||t[80]!==e||t[81]!==n?(r=(0,$.jsx)(`div`,{ref:v,className:`h-full min-h-0`,children:(0,$.jsx)(Xi,{path:g.path,content:de,error:pe,isLoading:me,hideHeader:c,onBack:be,onCopyPath:e,onCopyContent:n})}),t[74]=be,t[75]=de,t[76]=pe,t[77]=c,t[78]=me,t[79]=g.path,t[80]=e,t[81]=n,t[82]=r):r=t[82],r}let Ee;t[83]!==m||t[84]!==g.directory||t[85]!==u?(Ee=g.directory===m?u(`mobile.files.rootDirectory`):Vi(g.directory),t[83]=m,t[84]=g.directory,t[85]=u,t[86]=Ee):Ee=t[86];let De=Ee,Oe;t[87]!==y||t[88]!==ce?(Oe=y.trim()?ce:[],t[87]=y,t[88]=ce,t[89]=Oe):Oe=t[89];let ke=Oe,Ae,je,Me,Ne;if(t[90]!==n||t[91]!==y||t[92]!==m||t[93]!==g.directory||t[94]!==u){let e=Hi(g.directory),r=g.directory!==m&&e!==null&&(e===m||e.startsWith(`${m}/`)),i=r&&!y.trim(),a=r?e:null;Ne=`flex h-full flex-col overflow-hidden bg-background text-foreground`,Ae=`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[99]!==n||t[100]!==u?(je=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":u(`mobile.surface.closeAria`),onClick:n,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`close`,className:`size-5`})}):null,t[99]=n,t[100]=u,t[101]=je):je=t[101],Me=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":u(`mobile.files.backToParentAria`,{name:Vi(a)}),onClick:()=>ge(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`arrow-left`,className:`size-5`})}):null,t[90]=n,t[91]=y,t[92]=m,t[93]=g.directory,t[94]=u,t[95]=Ae,t[96]=je,t[97]=Me,t[98]=Ne}else Ae=t[95],je=t[96],Me=t[97],Ne=t[98];let Pe;t[102]===De?Pe=t[103]:(Pe=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:De})}),t[102]=De,t[103]=Pe);let Fe;t[104]===u?Fe=t[105]:(Fe=u(`mobile.files.refreshAria`),t[104]=u,t[105]=Fe);let Ie;t[106]===z?Ie=t[107]:(Ie=()=>void z.refetch(),t[106]=z,t[107]=Ie);let Le;t[108]===Symbol.for(`react.memo_cache_sentinel`)?(Le={touchAction:`manipulation`},t[108]=Le):Le=t[108];let Re=se&&`animate-spin`,ze;t[109]===Re?ze=t[110]:(ze=X(`size-5`,Re),t[109]=Re,t[110]=ze);let Be;t[111]===ze?Be=t[112]:(Be=(0,$.jsx)(Z,{name:`refresh`,className:ze}),t[111]=ze,t[112]=Be);let Ve;t[113]!==Fe||t[114]!==Ie||t[115]!==Be?(Ve=(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":Fe,onClick:Ie,style:Le,children:Be}),t[113]=Fe,t[114]=Ie,t[115]=Be,t[116]=Ve):Ve=t[116];let He;t[117]!==Ae||t[118]!==je||t[119]!==Me||t[120]!==Pe||t[121]!==Ve?(He=(0,$.jsxs)(`header`,{className:Ae,children:[je,Me,Pe,Ve]}),t[117]=Ae,t[118]=je,t[119]=Me,t[120]=Pe,t[121]=Ve,t[122]=He):He=t[122];let Ue;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(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[123]=Ue):Ue=t[123];let We;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(We=e=>b(e.target.value),t[124]=We):We=t[124];let Ge;t[125]===u?Ge=t[126]:(Ge=u(`mobile.files.search.placeholder`),t[125]=u,t[126]=Ge);let Ke;t[127]!==y||t[128]!==Ge?(Ke=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[Ue,(0,$.jsx)(xt,{type:`text`,inputMode:`search`,value:y,onChange:We,placeholder:Ge,className:`h-11 pl-9`})]})}),t[127]=y,t[128]=Ge,t[129]=Ke):Ke=t[129];let qe=vt,Je=oe?(0,$.jsx)(Qi,{message:oe}):y.trim()?(0,$.jsx)(Yi,{results:ke,isSearching:le,onOpenFile:ve}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[ae.length===0&&!se?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:u(`mobile.files.empty.directory`)}):null,ae.map(e=>(0,$.jsx)(Ji,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:Wi(e.size),onClick:()=>e.isDirectory?ge(e.path):ve(e.path)},e.path))]}),Ye;t[130]!==qe||t[131]!==Je?(Ye=(0,$.jsx)(qe,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:Je}),t[130]=qe,t[131]=Je,t[132]=Ye):Ye=t[132];let Xe;return t[133]!==Ne||t[134]!==He||t[135]!==Ke||t[136]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:Ne,children:[He,Ke,Ye]}),t[133]=Ne,t[134]=He,t[135]=Ke,t[136]=Ye,t[137]=Xe):Xe=t[137],Xe},Ji=e=>{let t=(0,Yr.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)(Gt,{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},Yi=e=>{let t=(0,Yr.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=ee(),o=Bi(un()??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)(Qi,{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)(Qi,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(Ji,{name:Vi(e.path),path:e.path,directory:!1,meta:Ui(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},Xi=e=>{let t=(0,Yr.c)(59),{path:r,content:i,error:s,isLoading:c,hideHeader:l,onBack:d,onCopyPath:f,onCopyContent:m}=e,h=l!==void 0&&l,{t:g}=ee(),_=cn(r)&&!r.toLowerCase().endsWith(`.svg`)?r:``,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=n(),t[0]=v):v=t[0];let y=v,b;t[1]===_?b=t[2]:(b=_&&o()?`${y}|${_}`:``,t[1]=_,t[2]=b);let x=b,S=_&&!x?`${y}|${_}`:``,[C,w]=Q.useState(``),[T,E]=Q.useState(``),[D,O]=Q.useState(null),[k,A]=Q.useState(!1),j;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(j={open:!1,title:``,content:``},t[3]=j):j=t[3];let[M,N]=Q.useState(j),F,te;t[4]===S?(F=t[5],te=t[6]):(F=()=>{if(!S){w(``);return}let e=!1;return w(``),a(u()).then(t=>{!e&&t&&w(S)}).catch(na),()=>{e=!0}},te=[S],t[4]=S,t[5]=F,t[6]=te),Q.useEffect(F,te);let I,L;t[7]!==_||t[8]!==x||t[9]!==g?(I=()=>{if(!x){E(``),O(null),A(!1);return}let e=!1,t=``;return E(``),O(null),A(!0),p(`/api/fs/raw`,{query:{path:_}}).then(async e=>{if(!e.ok)throw Error(g(`filesView.error.readFileFailed`));return e.blob()}).then(n=>{if(t=URL.createObjectURL(n),e){URL.revokeObjectURL(t);return}E(t)}).catch(t=>{e||O(t instanceof Error?t.message:g(`filesView.error.readFileFailed`))}).finally(()=>{e||A(!1)}),()=>{e=!0,t&&URL.revokeObjectURL(t)}},L=[_,x,g],t[7]=_,t[8]=x,t[9]=g,t[10]=I,t[11]=L):(I=t[10],L=t[11]),Q.useEffect(I,L);let R=!!(S&&C!==S),z;t[12]!==R||t[13]!==r||t[14]!==x||t[15]!==T?(z=x?T:R?``:Gi(r),t[12]=R,t[13]=r,t[14]=x,t[15]=T,t[16]=z):z=t[16];let B=z,V=s??D,H;t[17]===r?H=t[18]:(H=Vi(r),t[17]=r,t[18]=H);let U=H,W;t[19]!==i||t[20]!==r?(W=cn(r)?`data:${sn(r)};utf8,${encodeURIComponent(i)}`:``,t[19]=i,t[20]=r,t[21]=W):W=t[21];let ne=W,re;t[22]!==i||t[23]!==ne||t[24]!==B||t[25]!==r?(re=B||(cn(r)&&i?ne:``),t[22]=i,t[23]=ne,t[24]=B,t[25]=r,t[26]=re):re=t[26];let ie=re,G;t[27]!==U||t[28]!==_||t[29]!==r||t[30]!==ie?(G=()=>{let e=_||ie;e&&N({open:!0,title:U,content:``,metadata:{tool:`image-preview`,filename:U,mime:sn(r)},image:{url:e,mimeType:sn(r),filename:U}})},t[27]=U,t[28]=_,t[29]=r,t[30]=ie,t[31]=G):G=t[31];let ae=P(G),K;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>{N(t=>t.open===e?t:{...t,open:e})},t[32]=K):K=t[32];let oe=P(K),se;t[33]!==h||t[34]!==U||t[35]!==d||t[36]!==m||t[37]!==f||t[38]!==r||t[39]!==g?(se=h?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1 px-3 pb-1`,children:[cn(r)?null:(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:m,"aria-label":g(`mobile.files.copyContentAria`),children:(0,$.jsx)(Z,{name:`file-copy`,className:`size-4`})}),(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:f,"aria-label":g(`mobile.files.copyPathAria`),children:(0,$.jsx)(Z,{name:`clipboard`,className:`size-4`})})]}):(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":g(`header.actions.backAria`),onClick:d,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:U})}),cn(r)?null:(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:m,"aria-label":g(`mobile.files.copyContentAria`),children:(0,$.jsx)(Z,{name:`file-copy`,className:`size-4`})}),(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:f,"aria-label":g(`mobile.files.copyPathAria`),children:(0,$.jsx)(Z,{name:`clipboard`,className:`size-4`})})]}),t[33]=h,t[34]=U,t[35]=d,t[36]=m,t[37]=f,t[38]=r,t[39]=g,t[40]=se):se=t[40];let q;t[41]!==i||t[42]!==R||t[43]!==V||t[44]!==U||t[45]!==c||t[46]!==k||t[47]!==ae||t[48]!==r||t[49]!==ie||t[50]!==g?(q=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:c||R||k?(0,$.jsx)(Qi,{loading:!0,message:g(`filesView.state.loading`)}):V?(0,$.jsx)(Qi,{message:V}):cn(r)&&ie?(0,$.jsx)(vt,{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:ae,"aria-label":U,children:(0,$.jsx)(`img`,{src:ie,alt:U,className:`mx-auto max-h-full max-w-full rounded-lg object-contain`,draggable:!1})})}):(0,$.jsx)(Zi,{path:r,content:i})}),t[41]=i,t[42]=R,t[43]=V,t[44]=U,t[45]=c,t[46]=k,t[47]=ae,t[48]=r,t[49]=ie,t[50]=g,t[51]=q):q=t[51];let ce;t[52]!==oe||t[53]!==M?(ce=M.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ri,{popup:M,onOpenChange:oe,isMobile:!0})}):null,t[52]=oe,t[53]=M,t[54]=ce):ce=t[54];let le;return t[55]!==se||t[56]!==q||t[57]!==ce?(le=(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[se,q,ce]}),t[55]=se,t[56]=q,t[57]=ce,t[58]=le):le=t[58],le},Zi=e=>{let t=(0,Yr.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=kt(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??Ht(!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)??Ht(!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=()=>{rn(l),rn(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(Ki(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(vt,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)($t,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=Vi(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=ln(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:zn},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)(vt,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(_n,{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},Qi=e=>{let t=(0,Yr.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 $i(e){return e.pendingFileFocusPath}function ea(e){return e.setPendingFileFocusPath}function ta(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}function na(){}var ra=v(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),ia=v()(y(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:m()}));typeof window<`u`&&c(e=>{t(e)&&ia.persist.rehydrate()});var aa=36,oa=18,sa=e=>e.parentID??null,ca=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),la=e=>{let t=e;return ca(t.directory??t.project?.worktree??null)},ua=e=>{let t=ca(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},da=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},fa=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),pa=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))},ma=(e,t)=>{let n=ca(e),r=ca(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},ha=(e,t)=>e.worktrees.find(e=>ca(e.path)===t)??null,ga=(e,t)=>t===e.path||!!ha(e,t),_a=(e,t)=>{let n=ca(t);return n?e.find(e=>ga(e,n))??null:null},va=(e,t,n)=>!n||`${e.title??``} ${e.id} ${la(e)} ${t}`.toLowerCase().includes(n),ya=e=>{let t=(0,Yr.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?_t[n.icon]:null,c=n.color?yt[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)(ht,{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},ba=e=>{let t=(0,Yr.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},xa=e=>{let t=(0,Yr.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},Sa=e=>{let t=(0,Yr.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},Ca=e=>{let t=(0,Yr.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)(Ue,{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},wa=e=>{let t=(0,Yr.c)(65),{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}=e,g=o!==void 0&&o,_=s!==void 0&&s,v=c!==void 0&&c,{t:y}=ee(),b;t[0]===n?b=t[1]:(b=pa(da(n)),t[0]=n,t[1]=b);let x=b,S;t[2]!==n.title||t[3]!==y?(S=n.title?.trim()||y(`mobile.sessions.untitled`),t[2]=n.title,t[3]=y,t[4]=S):S=t[4];let C=S,w=r&&!g&&`bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]`,T=g&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`,E;t[5]!==w||t[6]!==T?(E=X(`relative flex items-center gap-1 transition-colors`,w,T),t[5]=w,t[6]=T,t[7]=E):E=t[7];let D;t[8]!==v||t[9]!==_||t[10]!==i||t[11]!==l||t[12]!==y?(D=_&&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":y(v?`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`,v?`rotate-0`:`-rotate-90`)})}):null,t[8]=v,t[9]=_,t[10]=i,t[11]=l,t[12]=y,t[13]=D):D=t[13];let O=g&&`opacity-50`,k=h.pressed&&`bg-interactive-active scale-[0.99]`,A;t[14]!==O||t[15]!==k?(A=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,k),t[14]=O,t[15]=k,t[16]=A):A=t[16];let j;t[17]===i?j=t[18]:(j={paddingLeft:i,touchAction:`manipulation`},t[17]=i,t[18]=j);let M=h.onPointerDown,N=h.onPointerMove,P=h.onPointerUp,F=h.onPointerCancel,te=h.onContextMenu,I=r?`bg-primary`:`bg-muted-foreground/30`,L;t[19]===I?L=t[20]:(L=X(`size-1.5 shrink-0 rounded-full`,I),t[19]=I,t[20]=L);let R;t[21]===L?R=t[22]:(R=(0,$.jsx)(`span`,{className:L,"aria-hidden":!0}),t[21]=L,t[22]=R);let z=r?`text-primary`:`text-foreground`,B;t[23]===z?B=t[24]:(B=X(`block min-w-0 flex-1 truncate typography-ui-label`,z),t[23]=z,t[24]=B);let V;t[25]!==B||t[26]!==C?(V=(0,$.jsx)(`span`,{className:B,children:C}),t[25]=B,t[26]=C,t[27]=V):V=t[27];let H;t[28]===x?H=t[29]:(H=x?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:x}):null,t[28]=x,t[29]=H);let U;t[30]!==R||t[31]!==V||t[32]!==H?(U=(0,$.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[R,V,H]}),t[30]=R,t[31]=V,t[32]=H,t[33]=U):U=t[33];let W;t[34]===a?W=t[35]:(W=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:a}):null,t[34]=a,t[35]=W);let ne;t[36]!==U||t[37]!==W?(ne=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[U,W]}),t[36]=U,t[37]=W,t[38]=ne):ne=t[38];let re;t[39]!==g||t[40]!==h.onContextMenu||t[41]!==h.onPointerCancel||t[42]!==h.onPointerDown||t[43]!==h.onPointerMove||t[44]!==h.onPointerUp||t[45]!==u||t[46]!==A||t[47]!==j||t[48]!==ne?(re=(0,$.jsx)(`button`,{type:`button`,className:A,style:j,onClick:u,onPointerDown:M,onPointerMove:N,onPointerUp:P,onPointerCancel:F,onContextMenu:te,disabled:g,children:ne}),t[39]=g,t[40]=h.onContextMenu,t[41]=h.onPointerCancel,t[42]=h.onPointerDown,t[43]=h.onPointerMove,t[44]=h.onPointerUp,t[45]=u,t[46]=A,t[47]=j,t[48]=ne,t[49]=re):re=t[49];let ie;t[50]!==p||t[51]!==m?(ie=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)(Rn,{})}):null,t[50]=p,t[51]=m,t[52]=ie):ie=t[52];let G;t[53]!==g||t[54]!==f||t[55]!==d||t[56]!==y||t[57]!==C?(G=d?(0,$.jsxs)($.Fragment,{children:[g?(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":y(`mobile.sessions.archiveSessionAria`,{title:C}),onClick:f,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Z,{name:`archive`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:y(`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":y(g?`mobile.sessions.cancelArchiveAria`:`mobile.sessions.archiveSessionAria`,{title:C}),onClick:d,style:{touchAction:`manipulation`},children:g?(0,$.jsx)(Z,{name:`close`,className:`size-4`}):(0,$.jsx)(Z,{name:`archive`,className:`size-4`})})]}):null,t[53]=g,t[54]=f,t[55]=d,t[56]=y,t[57]=C,t[58]=G):G=t[58];let ae;return t[59]!==re||t[60]!==ie||t[61]!==G||t[62]!==E||t[63]!==D?(ae=(0,$.jsxs)(`div`,{className:E,children:[D,re,ie,G]}),t[59]=re,t[60]=ie,t[61]=G,t[62]=E,t[63]=D,t[64]=ae):ae=t[64],ae},Ta=e=>{let t=(0,Yr.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},Ea=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=ee(),{git:i}=Zt(),a=ce(),o=ye(e=>e.activeSessions),s=ye(e=>e.activePaginationByDirectory),c=Me(e=>e.projects),l=Me(e=>e.activeProjectId),u=S(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),C=Me(e=>e.setActiveProjectIdOnly),w=Me(e=>e.removeProject),T=ve(),E=pe(),D=ia(e=>e.projectExpanded),O=ia(e=>e.worktreeExpanded),k=ia(e=>e.setProjectExpanded),A=ia(e=>e.setWorktreeExpanded),j=ut(e=>e.orderByProject),M=ra(e=>e.expandedParents),N=ra(e=>e.toggleParent),[F,I]=Q.useState(``),[L,R]=Q.useState(null),[z,B]=Q.useState(null),[V,H]=Q.useState(0),[U,W]=Q.useState(!1),[ne,ie]=Q.useState(!1),[G,ae]=Q.useState(null),[K,se]=Q.useState(null),[le,ue]=Q.useState(null),[de,fe]=Q.useState(null),[me,ge]=Q.useState(null),[_e,be]=Q.useState(``),[xe,Se]=Q.useState(!1),[Ce,Ee]=Q.useState(null),De=Q.useRef(null);De.current||=dn({onPressedKeyChange:fe});let[Oe,ke]=Q.useState(new Set),[Ae,je]=Q.useState(new Map),[Ne,Pe]=Q.useState(new Map),Fe=Wn(),Ie=Vn(),Le=P(e=>{q(e),oe(e)}),Re=P(e=>{Promise.all(e.map(e=>(q(e),oe(e))))});Q.useEffect(()=>{if(!e){I(``),Pe(new Map),R(null),B(null),se(null),ge(null),Ee(null),De.current?.reset();return}},[e]),Q.useEffect(()=>()=>{De.current?.reset()},[]),Q.useEffect(()=>{if(!e)return;if(c.length===0){J.setState(e=>{let t=hr(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),ke(e=>e.size===0?e:new Set),je(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(c.map(async e=>{let n=ca(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([gt({id:e.id,path:n},{isCurrent:()=>!t}),bt(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=>ca(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);J.setState(e=>{let t=hr(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),ke(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 fa(r,t)?t:r}),je(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,V]);let ze=Q.useMemo(()=>c.map(e=>({id:e.id,label:ua(e.path),path:ca(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:Oe.has(ca(e.path)),worktrees:st(j[e.id],f.get(ca(e.path))??[])})),[Oe,c,j,f]),Be=Q.useMemo(()=>{let e=new Map(a.map(e=>[e.id,e])),t=o.map(t=>{let n=e.get(t.id);return n?we(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]),Ve=F.trim().toLowerCase(),He=Q.useMemo(()=>{let e=ze.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===l})),t=(e,t,n)=>{let r=ca(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||ua(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 Be){let r=la(n);if(!r)continue;let i=ca(r),a=e.find(e=>ga(e.project,i));if(!a)continue;let o=ha(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)=>re(t)-re(e));for(let n of e.sessions)sa(n)||(t.totalSessions+=1)}return e},[l,ze,Be]),We=ca(u),Ge=e=>e.isActive?We===e.project.path?e.project.path:e.project.worktrees.find(e=>ma(We,e.path))?.path??e.project.path:null,Ke=e=>D[e.project.id]??!0,qe=(e,t)=>O[`${e.project.id}::${t.key}`]??!1,Je=e=>{Pe(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},Ye=()=>{se(null),De.current?.reset()},Xe=e=>({pressed:de===e.key||K?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||De.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>se(e)})},onPointerMove:e=>{De.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{De.current?.end(e.pointerId)},onPointerCancel:e=>{De.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),De.current?.openFromContextMenu(e.key,()=>se(e))}}),Ze=(e,t)=>{De.current?.consumeClick(e)||t()},Qe=(e,t,n,r)=>{let i=gr(),a=Qn();if(Pe(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=ca(t);if(!o)return;let s=ye.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&he(o)},$e=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=gr(),o=new Set(t.sessions.map(e=>e.id)),c=new Map;for(let e of t.sessions){let t=sa(e);if(t&&o.has(t)){let n=c.get(t)??[];n.push(e),c.set(t,n)}}let l=t.sessions.filter(e=>!sa(e)),u=Ne.get(i)??a,f=Hn(l,u,Ie),p=l.length-f.length,m=s.get(ca(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=Fe.has(e.id),s=i&&!a?n.filter(e=>Fe.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)(wa,{session:e,active:d===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>N(e.id):void 0,confirmingArchive:z===e.id,onSelect:()=>Ze(p,()=>nt(e)),onRequestArchive:()=>rt(e.id),onConfirmArchive:()=>void it(e),onStop:o||l?()=>Re(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:f}),longPressHandlers:Xe({key:p,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+oa)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[f.map(e=>v(e,n)),(0,$.jsx)(Ta,{indent:n,showMore:p>0||h,showFewer:_,loadingMore:g,onShowMore:()=>Qe(i,t.path,u,l.length),onShowFewer:()=>Je(i)})]})},et=(e,t)=>{k(e,!t)},tt=(e,t,n)=>{A(`${e}::${t}`,!n)},nt=e=>{Ft();let n=la(e)||null,r=_a(ze,n??``);r&&C(r.id),p(e.id,n),t(!1)},rt=e=>{B(t=>t===e?null:e)},it=async e=>{B(null),await m(e.id)?Kn({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=>{ae(e),C(e),ie(!0)},ct=e=>{let t=new Map;for(let e of Be){let n=sa(e);if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n},lt=async e=>{let t=ct(e.id),{archivedIds:n,failedIds:i}=await h(t);n.length>0&&Kn({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}))},dt=e=>{let t=ct(e.id);mr({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`)})},ft=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`))}},pt=async e=>{if((await te(e)).ok){Y.success(r(`sessions.sidebar.session.menu.copied`));return}Y.error(r(`sessions.sidebar.session.share.copyUrlError`))},mt=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`))}},ht=async()=>{if(!me)return;let e=_e.trim();if(e)try{await g(me.id,e),ge(null),be(``)}catch{Y.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},_t=async()=>{if(!me||xe)return;let e=me.id;ge(null),be(``),Se(!0);try{await _(e)}catch{Y.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{Se(!1)}},yt=(e,n)=>{C(e.id),b({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},St=e=>{(async()=>{try{await gt({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 Te(n,Be)})()},Ct=e=>{let t=la(e),n=_a(ze,t);if(!n)return ua(t)||t;let r=ha(n,ca(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},wt=e=>{x(e.id),t(!1)},Tt=Q.useMemo(()=>Ve?He.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Ve)?!0:e.buckets.some(t=>t.sessions.some(t=>va(t,e.project.label,Ve)))):He,[Ve,He]),Et=Q.useMemo(()=>Ve?Be.filter(e=>{let t=la(e);return va(e,_a(ze,t)?.label??``,Ve)}).sort((e,t)=>re(t)-re(e)):[],[Ve,ze,Be]),Dt=Q.useMemo(()=>Ve?ze.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Ve)).map(e=>({...e,sessionCount:Be.filter(t=>!sa(t)&&ga(e,ca(la(t)))).length})):[],[Ve,ze,Be]),Ot=Ve&&Et.length===0&&Dt.length===0,kt=ze.length>0?(0,$.jsxs)(Ue,{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,At=ze.find(e=>e.id===l)??null,jt=At?.isGitRepo?(0,$.jsx)(Ue,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>ot(At.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`node-tree`,className:`size-4`})}):null,Mt=(0,$.jsx)(Ue,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>W(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`})}),Nt=kt||Mt?(0,$.jsxs)($.Fragment,{children:[kt,jt,Mt]}):null,Pt=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`):``,Lt=Q.useMemo(()=>{if(!K)return[];if(K.kind===`project`){let e=K.project;return nr({gitRepository:e.isGitRepo,onNewSession:()=>{Ye(),yt(e,e.path)},onNewWorktree:()=>{Ye(),ot(e.id)},onSyncSessions:()=>{Ye(),St(e)},onEditProject:()=>{Ye(),R(e.id)},onCloseProject:()=>{Ye(),ue(e)}})}if(K.kind===`worktree`){let{project:e,worktree:t}=K;return Xn({onNewSession:()=>{Ye(),yt(e,t.path)},onDeleteWorktree:()=>{Ye(),Ee({project:e,worktree:t})}})}let e=K.session,t=!!e.share?.url;return tr({pinned:T.has(e.id),shared:t,onRename:()=>{Ye(),be(e.title?.trim()||r(`mobile.sessions.untitled`)),ge(e)},onTogglePin:()=>{Ye(),E(e.id)},onShare:t?void 0:()=>{Ye(),ft(e)},onCopyLink:t?()=>{let t=e.share?.url;Ye(),t&&pt(t)}:void 0,onUnshare:t?()=>{Ye(),mt(e.id)}:void 0,onArchive:()=>{Ye(),lt(e)},onDelete:()=>{Ye(),dt(e)}})},[K,Ye,lt,pt,dt,ot,ft,mt,T,yt,St,r,E]),Rt=Lt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Lt.map(e=>{let t=(0,$.jsx)(Ca,{icon:e.icon,label:pr(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,zt=(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:F,onChange:e=>I(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:X(`h-11 pl-9`,F&&`pr-10`)}),F?(0,$.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":r(`mobile.sessions.clearSearchAria`),onClick:()=>I(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsx)(vt,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:ze.length===0?(0,$.jsx)(Da,{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:()=>W(!0),children:[(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):Ot?(0,$.jsx)(Da,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Ve?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 pt-2`,children:[Et.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:Et.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Et.map((e,t)=>{let n=Fe.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)(wa,{session:e,active:d===e.id,indent:12,contextLabel:Ct(e),onSelect:()=>Ze(`session:${e.id}`,()=>nt(e)),longPressHandlers:Xe({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>Le(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,Dt.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:Dt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Dt.map((e,t)=>{let n=`project:${e.id}`,r=Xe({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:()=>Ze(n,()=>wt(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(ya,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(Sa,{className:`mr-2`,onClick:()=>ot(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:Tt.map((e,t)=>{let n=Ke(e),i=`project:${e.project.id}`,a=Xe({key:i,kind:`project`,project:e.project}),o=Ve?e.buckets.filter(t=>t.sessions.some(t=>va(t,e.project.label,Ve))):e.buckets,s=Ge(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:()=>Ze(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)(ya,{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}),Ae.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:Ae.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(xa,{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=>Fe.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(),Re(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Rn,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(Sa,{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?$e(e,t,aa):null,n.map(t=>{let n=qe(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Xe({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:()=>Ze(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)(ba,{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)(xa,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>Fe.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(),Re(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Rn,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?$e(e,t,aa):null]},t.key)})]})})()}):null]},e.project.id)})})}),(0,$.jsx)(ir,{open:U,onOpenChange:W,forceMobile:!0}),(0,$.jsx)(Yt,{open:ne,projectId:G,onOpenChange:e=>{ie(e),e||ae(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?p(n.sessionId,e):b({selectedProjectId:G,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(Xt,{open:!!K,title:Pt,onClose:Ye,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Rt}),(0,$.jsx)(Xt,{open:!!le,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>ue(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>ue(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Ue,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!le)return;let e=le;ue(null),w(e.id),Y.success(r(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:r(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:r(`mobile.projects.closeConfirmMessage`,{title:le?.label??``})})}),(0,$.jsx)(Xt,{open:!!me,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{xe||(ge(null),be(``))},footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:xe,onClick:()=>{ge(null),be(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Ue,{type:`button`,variant:`default`,className:`flex-1`,disabled:!_e.trim()||xe,onClick:()=>void ht(),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(),ht()},children:[(0,$.jsx)(xt,{value:_e,onChange:e=>be(e.target.value),autoFocus:!0,className:`h-12`,disabled:xe}),(0,$.jsxs)(Ue,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:xe,onClick:()=>void _t(),children:[xe?(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`)]})]})}),Ce?(0,$.jsx)(Ln,{open:!0,project:{id:Ce.project.id,path:Ce.project.path},worktree:Ce.worktree,onClose:()=>Ee(null),onDeleted:()=>H(e=>e+1)}):null,(0,$.jsx)(Gn,{open:L!==null,project:ze.find(e=>e.id===L)??null,onClose:()=>R(null),onWorktreesChanged:()=>H(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:Nt?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:Nt}):null}),zt]}):null:(0,$.jsx)(It,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:Nt,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:zt})},Da=e=>{let t=(0,Yr.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},Oa=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,ka=[{image:wr,titleKey:`assistants.shareWelcome.example.chat.title`,descriptionKey:`assistants.shareWelcome.example.chat.description`},{image:yr,titleKey:`assistants.shareWelcome.example.article.title`,descriptionKey:`assistants.shareWelcome.example.article.description`},{image:Sr,titleKey:`assistants.shareWelcome.example.note.title`,descriptionKey:`assistants.shareWelcome.example.note.description`}];function Aa(){let e=(0,Yr.c)(8),{t}=ee(),n;e[0]===t?n=e[1]:(n=t(`assistants.state.unavailable`),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 ja(e){let t=(0,Yr.c)(49),{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:Oa,alt:``})}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=r(`assistants.subtitle`),t[1]=r,t[2]=a);let o;t[3]===a?o=t[4]:(o=(0,$.jsx)(`span`,{className:`oc-mobile-assistant-guide-kicker`,children:a}),t[3]=a,t[4]=o);let s;t[5]===r?s=t[6]:(s=r(`assistants.state.instanceDisabled`),t[5]=r,t[6]=s);let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(`h2`,{className:`oc-mobile-assistant-guide-title`,children:s}),t[7]=s,t[8]=c);let l;t[9]===r?l=t[10]:(l=r(`assistants.onboarding.description`),t[9]=r,t[10]=l);let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(`p`,{className:`oc-mobile-assistant-guide-description`,children:l}),t[11]=l,t[12]=u);let d;t[13]!==o||t[14]!==c||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-heading`,children:[o,c,u]}),t[13]=o,t[14]=c,t[15]=u,t[16]=d):d=t[16];let f;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(Z,{name:`sparkling`,className:`size-[18px]`}),t[17]=f):f=t[17];let p;t[18]===r?p=t[19]:(p=r(`assistants.settings.instanceEnabled`),t[18]=r,t[19]=p);let m;t[20]!==n||t[21]!==p?(m=(0,$.jsxs)(Ue,{type:`button`,size:`lg`,className:`w-full`,onClick:n,children:[f,p]}),t[20]=n,t[21]=p,t[22]=m):m=t[22];let h;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Z,{name:`share-2`,className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),t[23]=h):h=t[23];let g;t[24]===r?g=t[25]:(g=r(`assistants.shareWelcome.title`),t[24]=r,t[25]=g);let _;t[26]===g?_=t[27]:(_=(0,$.jsx)(`h3`,{id:`assistant-share-guide-title`,className:`typography-ui-label font-semibold text-foreground`,children:g}),t[26]=g,t[27]=_);let v;t[28]===r?v=t[29]:(v=r(`assistants.shareWelcome.description`),t[28]=r,t[29]=v);let y;t[30]===v?y=t[31]:(y=(0,$.jsx)(`p`,{className:`mt-1 typography-meta leading-5 text-muted-foreground`,children:v}),t[30]=v,t[31]=y);let b;t[32]!==_||t[33]!==y?(b=(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-share-heading`,children:[h,(0,$.jsxs)(`div`,{className:`min-w-0`,children:[_,y]})]}),t[32]=_,t[33]=y,t[34]=b):b=t[34];let x;t[35]===r?x=t[36]:(x=r(`assistants.shareWelcome.examplesAria`),t[35]=r,t[36]=x);let S;t[37]===r?S=t[38]:(S=ka.map((e,t)=>(0,$.jsxs)(`article`,{className:`oc-mobile-assistant-guide-step`,children:[(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-step-image`,children:[(0,$.jsx)(`img`,{src:e.image,alt:``}),(0,$.jsx)(`span`,{"aria-hidden":`true`,children:t+1})]}),(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[37]=r,t[38]=S);let C;t[39]!==x||t[40]!==S?(C=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-steps`,"aria-label":x,children:S}),t[39]=x,t[40]=S,t[41]=C):C=t[41];let w;t[42]!==b||t[43]!==C?(w=(0,$.jsxs)(`section`,{className:`oc-mobile-assistant-guide-share`,"aria-labelledby":`assistant-share-guide-title`,children:[b,C]}),t[42]=b,t[43]=C,t[44]=w):w=t[44];let T;return t[45]!==m||t[46]!==w||t[47]!==d?(T=(0,$.jsxs)(`article`,{className:`oc-mobile-assistant-guide`,children:[i,(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-body`,children:[d,m,w]})]}),t[45]=m,t[46]=w,t[47]=d,t[48]=T):T=t[48],T}function Ma({assistantID:e,displayName:t,avatarEmoji:n,modeLabel:r,summary:i,enabled:a,editLabel:o,deleteLabel:s,onOpen:c,onEdit:l,onDelete:u}){let[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),h=Q.useRef(null);h.current||=dn({onPressedKeyChange:t=>m(t===e)}),Q.useEffect(()=>()=>h.current?.reset(),[]);let g=P(()=>{h.current?.consumeClick(e)||d||c()}),_=P(()=>{f(!1),l()}),v=P(()=>{f(!1),u()}),y=P(()=>{m(!1),f(!0)}),b=P(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=P(e=>{h.current?.move(e.pointerId,e.clientX,e.clientY)}),S=P(e=>{h.current?.end(e.pointerId)}),C=P(e=>{h.current?.cancel(e.pointerId)}),w=P(t=>{t.preventDefault(),t.stopPropagation(),h.current?.openFromContextMenu(e,y)});return(0,$.jsxs)(Ar,{open:d,onOpenChange:f,children:[(0,$.jsx)(On,{"data-mobile-press-surface":`soft`,className:X(`oc-mobile-assistant-card-shell`,p&&`bg-interactive-hover`),children:(0,$.jsxs)(Er,{render:(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-surface-trigger":!0,"data-mobile-press-feedback":`none`,className:X(`oc-mobile-assistant-card`,!a&&`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)(He,{name:e,emoji:n,size:n?40:38,label:t})}),(0,$.jsxs)(`span`,{className:`oc-mobile-assistant-card-content min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`oc-mobile-assistant-card-header`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-entity-title oc-mobile-assistant-name min-w-0 flex-1 truncate font-semibold text-foreground`,children:t}),(0,$.jsx)(`span`,{className:`oc-mobile-entity-meta oc-mobile-assistant-mode shrink-0 text-muted-foreground`,children:r})]}),(0,$.jsx)(`span`,{className:`oc-mobile-assistant-summary text-muted-foreground`,children:i})]})]})}),(0,$.jsxs)(Or,{className:`min-w-[10rem]`,children:[(0,$.jsxs)(kr,{className:`min-h-10 px-3`,onClick:_,children:[(0,$.jsx)(Z,{name:`edit`,className:`size-4`}),o]}),(0,$.jsx)(Dr,{}),(0,$.jsxs)(kr,{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`}),s]})]})]})}function Na(e){let t=(0,Yr.c)(104),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=ee(),o=Wt(),s=Le(),c=ze(),l=Be(Pa),[u,d]=Q.useState(null),f;t[0]===n?f=t[1]:(f=()=>n(),t[0]=n,t[1]=f);let p=P(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=P(m),g;t[5]===r?g=t[6]:(g=e=>r(e),t[5]=r,t[6]=g);let _=P(g),v;t[7]===o?v=t[8]:(v=e=>{Ve(e,o?{openMobileSettings:o.openSettings}:void 0)},t[7]=o,t[8]=v);let y=P(v),b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{d(e)},t[9]=b):b=t[9];let x=P(b),S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{e||d(null)},t[10]=S):S=t[10];let C=P(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)(On,{className:`oc-mobile-assistant-loading`,children:(0,$.jsx)(Aa,{})}),t[17]=e):e=t[17];let n;return t[18]!==i||t[19]!==T?(n=(0,$.jsx)(Dn,{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||t[29]!==a){let e;t[31]!==k||t[32]!==D||t[33]!==y||t[34]!==_||t[35]!==x||t[36]!==a?(e=e=>{let t=L(e.name),n=t.displayName||e.name,r=e.mode===`stateless`?a(`assistants.mode.stateless`):a(`assistants.mode.continuous`),i=e.defaultPrompt.trim()||(e.mode===`stateless`?a(`assistants.conversation.statelessHint`):a(`assistants.conversation.continuousHint`));return(0,$.jsx)(Ma,{assistantID:e.id,displayName:n,avatarEmoji:t.avatarEmoji??void 0,modeLabel:r,summary:i,enabled:e.enabled,editLabel:D,deleteLabel:k,onOpen:()=>_(e.id),onEdit:()=>y(e.id),onDelete:()=>x(e)},e.id)},t[31]=k,t[32]=D,t[33]=y,t[34]=_,t[35]=x,t[36]=a,t[37]=e):e=t[37],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]=a,t[30]=n}else n=t[30];let r;t[38]!==e||t[39]!==n?(r=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-catalog`,role:`listbox`,"aria-label":e,children:n}),t[38]=e,t[39]=n,t[40]=r):r=t[40];let o=u!==null,s;t[41]!==u||t[42]!==C||t[43]!==o?(s=(0,$.jsx)(jr,{assistant:u,open:o,onOpenChange:C}),t[41]=u,t[42]=C,t[43]=o,t[44]=s):s=t[44];let l;return t[45]!==i||t[46]!==T||t[47]!==r||t[48]!==s?(l=(0,$.jsxs)(Dn,{title:T,className:i,surface:!1,scrollsWithPage:!0,children:[r,s]}),t[45]=i,t[46]=T,t[47]=r,t[48]=s,t[49]=l):l=t[49],l}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[50]===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[50]=e):e=t[50];let n;t[51]===a?n=t[52]:(n=a(`assistants.onboarding.title`),t[51]=a,t[52]=n);let r;t[53]===n?r=t[54]:(r=(0,$.jsx)(`h2`,{children:n}),t[53]=n,t[54]=r);let o;t[55]===a?o=t[56]:(o=a(`assistants.onboarding.description`),t[55]=a,t[56]=o);let s;t[57]===o?s=t[58]:(s=(0,$.jsx)(`p`,{children:o}),t[57]=o,t[58]=s);let c;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Z,{name:`add`,className:`size-[18px]`}),t[59]=c):c=t[59];let l;t[60]===a?l=t[61]:(l=a(`assistants.onboarding.action`),t[60]=a,t[61]=l);let u;t[62]!==h||t[63]!==l?(u=(0,$.jsxs)(Ue,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:h,children:[c,l]}),t[62]=h,t[63]=l,t[64]=u):u=t[64];let d;t[65]!==r||t[66]!==s||t[67]!==u?(d=(0,$.jsxs)(On,{className:`oc-mobile-assistant-onboarding`,children:[e,r,s,u]}),t[65]=r,t[66]=s,t[67]=u,t[68]=d):d=t[68];let f;return t[69]!==i||t[70]!==T||t[71]!==d?(f=(0,$.jsx)(Dn,{title:T,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:d}),t[69]=i,t[70]=T,t[71]=d,t[72]=f):f=t[72],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[73]!==a||t[74]!==j||t[75]!==A?(N=a(j?`assistants.state.unavailable`:A?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[73]=a,t[74]=j,t[75]=A,t[76]=N):N=t[76];let F=N;if(M&&!j){let e;t[77]===p?e=t[78]:(e=(0,$.jsx)(ja,{onEnable:p}),t[77]=p,t[78]=e);let n;return t[79]!==i||t[80]!==T||t[81]!==e?(n=(0,$.jsx)(Dn,{title:T,className:i,surface:!1,scrollsWithPage:!0,children:e}),t[79]=i,t[80]=T,t[81]=e,t[82]=n):n=t[82],n}let te;t[83]===T?te=t[84]:(te=(0,$.jsx)(`span`,{className:`oc-mobile-page-section-label`,children:T}),t[83]=T,t[84]=te);let I=A?`cloud-off`:`sparkling`,R;t[85]===I?R=t[86]:(R=(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[85]=I,t[86]=R);let z;t[87]===F?z=t[88]:(z=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:F}),t[87]=F,t[88]=z);let B;t[89]!==a||t[90]!==j||t[91]!==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[89]=a,t[90]=j,t[91]=A,t[92]=B):B=t[92];let V;t[93]!==R||t[94]!==z||t[95]!==B?(V=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[R,z,B]}),t[93]=R,t[94]=z,t[95]=B,t[96]=V):V=t[96];let H;t[97]!==te||t[98]!==V?(H=(0,$.jsx)(jn,{label:te,cardClassName:`oc-mobile-assistant-state-card`,children:V}),t[97]=te,t[98]=V,t[99]=H):H=t[99];let U;return t[100]!==i||t[101]!==T||t[102]!==H?(U=(0,$.jsx)(Dn,{title:T,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:H}),t[100]=i,t[101]=T,t[102]=H,t[103]=U):U=t[103],U}function Pa(e){return e.requestCreate}var Fa=[{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 Ia(e){let t=(0,Yr.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=P(o),c;t[2]!==n||t[3]!==r?(c=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Fa.findIndex(e=>e.id===n),i=Fa[e.key===`Home`?0:e.key===`End`?Fa.length-1:(t+(e.key===`ArrowRight`?1:-1)+Fa.length)%Fa.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=P(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=Fa.map(e=>{let t=e.id===n,r=a(e.labelKey);return(0,$.jsxs)(Ue,{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,"data-mobile-press-feedback":`none`,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:scale-[0.985]`,`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)(Mn,{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}function La(e){let t=(0,Yr.c)(23),{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=P(()=>h?.onBack());Qt({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=P(j),N;t[6]===c?N=t[7]:(N=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[6]=c,t[7]=N);let F=h?!0:void 0,te=h?!0:void 0,I;t[8]!==p||t[9]!==u||t[10]!==n||t[11]!==b?(I=Fa.map(e=>{let t=b.has(e.id);return(0,$.jsx)(`section`,{id:`mobile-tabpanel-${e.id}`,role:`tabpanel`,"aria-labelledby":`mobile-tab-${e.id}`,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)(Ra,{tab:e.id,icon:e.icon}):null},e.id)}),t[8]=p,t[9]=u,t[10]=n,t[11]=b,t[12]=I):I=t[12];let L;t[13]!==w||t[14]!==I||t[15]!==F||t[16]!==te?(L=(0,$.jsx)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":F,inert:te,className:`flex h-full min-h-0 flex-1 flex-col`,children:I}),t[13]=w,t[14]=I,t[15]=F,t[16]=te,t[17]=L):L=t[17];let R=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||d?!0:void 0,inert:h||d?!0:void 0,children:(0,$.jsx)(Ia,{activeTab:p,onTabChange:M})}):null,z=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)}),B;return t[18]!==L||t[19]!==R||t[20]!==z||t[21]!==N?(B=(0,$.jsxs)(`div`,{className:N,children:[L,R,z]}),t[18]=L,t[19]=R,t[20]=z,t[21]=N,t[22]=B):B=t[22],B}function Ra(e){let t=(0,Yr.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=Fa.find(e=>e.id===n)??Fa[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 za={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)`}},Ba=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 Va({project:e,expanded:t,embedded:n=!1,onToggle:r,onOpenActions:i,className:a}){let{t:o}=ee(),[s,c]=Q.useState(!1),l=Q.useRef(null);l.current||=dn({onPressedKeyChange:t=>c(t===e.id)}),Q.useEffect(()=>()=>l.current?.reset(),[]);let u=P(()=>{l.current?.consumeClick(e.id)||r(e)}),d=P(()=>i(e)),f=P(t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||l.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{c(!1),i(e)}})}),p=P(e=>{l.current?.move(e.pointerId,e.clientX,e.clientY)}),m=P(e=>{l.current?.end(e.pointerId)}),h=P(e=>{l.current?.cancel(e.pointerId)}),g=P(t=>{t.preventDefault(),t.stopPropagation(),l.current?.openFromContextMenu(e.id,()=>{c(!1),i(e)})}),_=e.sessionCount===1?o(`mobile.sessions.project.sessionsSingle`):o(`mobile.sessions.project.sessionsPlural`,{count:e.sessionCount}),v=Ba(e.path),y=(0,$.jsxs)(`article`,{"data-mobile-press-surface":`soft`,className:X(`oc-mobile-project-card relative flex items-stretch overflow-hidden rounded-[var(--oc-mobile-surface-radius)]`,s&&`bg-interactive-hover`,a),children:[(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-surface-trigger":!0,"data-mobile-press-feedback":`none`,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:u,onPointerDown:f,onPointerMove:p,onPointerUp:m,onPointerCancel:h,onContextMenu:g,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:za[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: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":o(`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:_}),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,v?(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:v})]}):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`)})]}),(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-project-action self-center rounded-full text-muted-foreground`,"aria-label":o(`sessions.sidebar.project.actions.projectMenu`),onClick:d,children:(0,$.jsx)(Z,{name:`more-2`,className:`size-4`})})]});return n?y:(0,$.jsx)(On,{asChild:!0,children:y})}var Ha=({hasPendingQuestion:e,hasPendingPermission:t,running:n,unread:r})=>e?`question`:t?`permission`:n?`running`:r?`completed-unread`:`idle`,Ua=10,Wa=`oc:mobile-session-row-revealed`,Ga=e=>{window.dispatchEvent(new CustomEvent(Wa,{detail:e}))};function Ka({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}){let{t:f}=ee(),[p,m]=Q.useState(0),[h,g]=Q.useState(!1),_=Q.useRef(null),v=Q.useRef(!1),y=Q.useRef(null),b=Q.useRef(null);b.current||=dn(),Q.useEffect(()=>()=>b.current?.reset(),[]),Q.useEffect(()=>{let t=t=>{t.detail!==e.id&&m(0)};return window.addEventListener(Wa,t),()=>window.removeEventListener(Wa,t)},[e.id]),Q.useEffect(()=>{m(0)},[e.id]);let x=P(()=>m(0)),S=p!==0,C=P(t=>{if(t.button!==0||t.pointerType!==`touch`&&t.pointerType!==`pen`)return;let n=y.current?.offsetWidth??0;n<=0||(_.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startOffset:p,actionWidth:n,intent:`pending`},v.current=!1,b.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{l(e)}}))}),w=P(t=>{let n=_.current;if(!n||n.pointerId!==t.pointerId)return;let r=t.clientX-n.startX,i=t.clientY-n.startY;if(b.current?.move(t.pointerId,t.clientX,t.clientY),n.intent===`pending`){let a=Math.abs(r),o=Math.abs(i);if(o>Ua&&o>a){n.intent=`vertical`,_.current=null,b.current?.cancel(t.pointerId);return}if(a>Ua&&a>o){n.intent=`horizontal`,g(!0),v.current=!0,b.current?.cancel(t.pointerId);try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}Ga(e.id)}}if(n.intent!==`horizontal`)return;t.preventDefault();let a=Math.max(-n.actionWidth,Math.min(0,n.startOffset+r));m(a)}),T=P(e=>{let t=_.current;b.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(_.current=null,t.intent===`horizontal`&&(g(!1),m(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),E=P(e=>{let t=_.current;_.current=null,b.current?.cancel(e.pointerId),g(!1),m(t?.startOffset??0)}),D=P(()=>{if(!b.current?.consumeClick(e.id)){if(v.current){v.current=!1;return}if(p!==0){x();return}Ga(e.id),o(e)}}),O=P(t=>{t.preventDefault(),t.stopPropagation(),b.current?.openFromContextMenu(e.id,()=>{l(e)})}),k=P(()=>{x(),s(e)}),A=P(()=>{x(),c(e)}),j=P(()=>l(e)),M=P(()=>a?.()),N=e.pinned?f(`sessions.sidebar.session.menu.unpin`):f(`sessions.sidebar.session.menu.pin`),F=u??Ha({hasPendingQuestion:!1,hasPendingPermission:!1,running:!1,unread:!!e.unread}),te=F===`question`?f(`sessions.sidebar.session.status.questionRequired`):F===`permission`?f(`sessions.sidebar.session.status.permissionRequired`):F===`running`?f(`sessions.sidebar.session.status.active`):F===`completed-unread`?f(`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:D,onPointerDown:()=>void 0,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium text-foreground`,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 overflow-hidden`,d),children:[(0,$.jsxs)(`div`,{ref:y,className:X(`oc-mobile-session-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,h?`transition-none`:`transition-transform duration-150 ease-out`,!S&&`invisible pointer-events-none`),style:{transform:`translate3d(calc(var(--oc-mobile-session-actions-width) + ${p}px), 0, 0)`,willChange:p===0?void 0:`transform`},"aria-hidden":!S,children:[(0,$.jsxs)(Ue,{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":N,tabIndex:S?0:-1,onClick:k,children:[(0,$.jsx)(Z,{name:e.pinned?`unpin`:`pushpin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:N})]}),(0,$.jsxs)(Ue,{type:`button`,variant:`destructive`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 px-1`,"aria-label":f(`sessions.sidebar.bulkActions.archive`),tabIndex:S?0:-1,onClick:A,children:[(0,$.jsx)(Z,{name:`archive`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:f(`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`,h?`transition-none`:`transition-[transform,background-color] duration-150`,e.archived&&`opacity-55`),"data-dragging":h?`true`:void 0,style:{transform:`translate3d(${p}px, 0, 0)`,willChange:p===0?void 0:`transform`},children:[n&&a?(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,size:`icon`,className:`min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":f(r?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:M,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:D,onPointerDown:C,onPointerMove:w,onPointerUp:T,onPointerCancel:E,onContextMenu:O,children:[(0,$.jsx)(`span`,{className:`oc-mobile-session-status shrink-0`,"data-session-status":F,"aria-hidden":!te||void 0,"aria-label":te,title:te,children:F===`running`?(0,$.jsx)(Rn,{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:e.title}),e.pinned?(0,$.jsx)(Z,{name:`pushpin`,className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}):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: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)(Ue,{type:`button`,variant:`ghost`,size:`icon`,className:`mr-1 min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":f(`sessions.sidebar.session.menu.label`),onClick:j,children:(0,$.jsx)(Z,{name:`more-2`,className:`size-3.5`})})]})]})}var qa=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e)),Ja=(e,t)=>e.filter(e=>e.kind!==`pagination`&&qa(t,e.title,e.subtitle,e.id)),Ya=(e,t)=>{if(qa(t,e.name,e.path))return{...e,sessions:e.sessions.filter(e=>e.kind!==`pagination`)};let n=Ja(e.sessions,t);return n.length>0?{...e,sessions:n}:null},Xa=(e,t)=>{let n=t.trim().toLowerCase();return n?e.flatMap(e=>{if(qa(n,e.name,e.path))return[{...e,worktrees:[]}];let t=e.worktrees.flatMap(e=>{let t=Ya(e,n);return t?[t]:[]});return t.length>0?[{...e,worktrees:t}]:[]}):e},Za=10,Qa=`oc:mobile-worktree-row-revealed`,$a=e=>{window.dispatchEvent(new CustomEvent(Qa,{detail:e}))};function eo(e){let t=(0,Yr.c)(10),n=fe(e.session.id),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={bootstrap:!1},t[0]=r):r=t[0];let i=Oe(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=xe(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=Ha({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)(Ka,{...e,indicator:d}),t[7]=d,t[8]=e,t[9]=f):f=t[9],f}function to(e){let t=(0,Yr.c)(8),{sessions:n,onSelectSession:r,onPinSession:i,onArchiveSession:a,onOpenSessionActions:o}=e,s;t[0]!==a||t[1]!==o||t[2]!==i||t[3]!==r||t[4]!==n?(s=n.map((e,t)=>{let s=e.kind===`pagination`&&n[t+1]?.kind===`pagination`,c=e.kind===`pagination`?Ka:eo;return(0,$.jsx)(c,{session:e,paginationContinues:s,onSelect:r,onPin:i,onArchive:a,onOpenActions:o},e.id)}),t[0]=a,t[1]=o,t[2]=i,t[3]=r,t[4]=n,t[5]=s):s=t[5];let c;return t[6]===s?c=t[7]:(c=(0,$.jsx)($.Fragment,{children:s}),t[6]=s,t[7]=c),c}function no(e){let t=(0,Yr.c)(22),{icon:n,label:r,count:i,expanded:a,onToggle:o,actions:s}=e,{t:c}=ee(),l;t[0]===n?l=t[1]:(l=(0,$.jsx)(`span`,{className:`oc-mobile-group-label-icon`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=l);let u;t[2]===r?u=t[3]:(u=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left typography-ui-label font-semibold text-foreground`,children:r}),t[2]=r,t[3]=u);let d;t[4]!==i||t[5]!==c?(d=typeof i==`number`?(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:i===1?c(`mobile.sessions.project.sessionsSingle`):c(`mobile.sessions.project.sessionsPlural`,{count:i})}):null,t[4]=i,t[5]=c,t[6]=d):d=t[6];let f;t[7]!==a||t[8]!==o?(f=o?(0,$.jsx)(Z,{name:`arrow-down-s`,className:X(`size-3.5 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,a?`rotate-0`:`-rotate-90`)}):null,t[7]=a,t[8]=o,t[9]=f):f=t[9];let p;t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f?(p=(0,$.jsxs)($.Fragment,{children:[l,u,d,f]}),t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p):p=t[14];let m=p,h;t[15]!==m||t[16]!==a||t[17]!==o?(h=o?(0,$.jsx)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-group-label-trigger`,"aria-expanded":a,onClick:o,children:m}):(0,$.jsx)(`div`,{className:`oc-mobile-group-label-trigger`,children:m}),t[15]=m,t[16]=a,t[17]=o,t[18]=h):h=t[18];let g;return t[19]!==s||t[20]!==h?(g=(0,$.jsxs)(`div`,{className:`oc-mobile-group-label`,children:[h,s]}),t[19]=s,t[20]=h,t[21]=g):g=t[21],g}function ro({project:e,worktree:t,expanded:n,onToggle:r,onNewSession:i,onOpenActions:a,onDelete:o}){let{t:s}=ee(),c=`${e.id}::${t.id}`,l=!!(i||o),u=!!a,d=Number(!!i)+Number(!!o),[f,p]=Q.useState(0),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),v=Q.useRef(null),y=Q.useRef(!1),b=Q.useRef(null),x=Q.useRef(null);x.current||=dn({onPressedKeyChange:e=>h(e===c)}),Q.useEffect(()=>()=>x.current?.reset(),[]),Q.useEffect(()=>{let e=e=>{e.detail!==c&&p(0)};return window.addEventListener(Qa,e),()=>window.removeEventListener(Qa,e)},[c]),Q.useEffect(()=>{p(0)},[c]);let S=P(()=>p(0)),C=f!==0,w=P(n=>{if(n.button===0&&(n.pointerType===`touch`||n.pointerType===`pen`)){if(l){let e=b.current?.offsetWidth??0;e>0&&(v.current={pointerId:n.pointerId,startX:n.clientX,startY:n.clientY,startOffset:f,actionWidth:e,intent:`pending`},y.current=!1)}u&&x.current?.start({pointerId:n.pointerId,key:c,clientX:n.clientX,clientY:n.clientY,onTrigger:()=>{h(!1),a?.(e,t)}})}}),T=P(e=>{let t=v.current;if(!t||t.pointerId!==e.pointerId){x.current?.move(e.pointerId,e.clientX,e.clientY);return}let n=e.clientX-t.startX,r=e.clientY-t.startY;if(x.current?.move(e.pointerId,e.clientX,e.clientY),t.intent===`pending`){let i=Math.abs(n),a=Math.abs(r);if(a>Za&&a>i){t.intent=`vertical`,v.current=null,x.current?.cancel(e.pointerId);return}if(i>Za&&i>a){t.intent=`horizontal`,_(!0),y.current=!0,x.current?.cancel(e.pointerId);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}$a(c)}}if(t.intent!==`horizontal`)return;e.preventDefault();let i=Math.max(-t.actionWidth,Math.min(0,t.startOffset+n));p(i)}),E=P(e=>{let t=v.current;x.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(v.current=null,t.intent===`horizontal`&&(_(!1),p(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),D=P(e=>{let t=v.current;v.current=null,x.current?.cancel(e.pointerId),_(!1),p(t?.startOffset??0)}),O=P(()=>{if(!x.current?.consumeClick(c)){if(y.current){y.current=!1;return}if(f!==0){S();return}r()}}),k=P(n=>{u&&(n.preventDefault(),n.stopPropagation(),x.current?.openFromContextMenu(c,()=>{h(!1),a?.(e,t)}))}),A=P(()=>{S(),i?.(e,t)}),j=P(()=>{S(),o?.(e,t)}),M=P(()=>a?.(e,t)),N=(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 typography-ui-label font-semibold text-foreground`,children:t.name}),(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:t.sessionCount===1?s(`mobile.sessions.project.sessionsSingle`):s(`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:[l?(0,$.jsxs)(`div`,{ref:b,className:X(`oc-mobile-worktree-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:{width:`calc(${d} * var(--oc-mobile-worktree-action-width))`,transform:`translate3d(calc(100% + ${f}px), 0, 0)`,willChange:f===0?void 0:`transform`},"aria-hidden":!C,children:[i?(0,$.jsxs)(Ue,{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":s(`mobile.sessions.newSessionAria`),tabIndex:C?0:-1,onClick:A,children:[(0,$.jsx)(Z,{name:`add`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:s(`sessions.sidebar.project.actions.newSession`)})]}):null,o?(0,$.jsxs)(Ue,{type:`button`,variant:`destructive`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 px-1`,"aria-label":s(`mobile.projectEdit.deleteWorktreeAria`,{label:t.name}),tabIndex:C?0:-1,onClick:j,children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:s(`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`,g?`transition-none`:`transition-transform duration-150`),style:{transform:`translate3d(${f}px, 0, 0)`,willChange:f===0?void 0:`transform`},"data-pressed":m?`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:O,onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:D,onContextMenu:k,style:{touchAction:`pan-y`},children:N}),u?(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-worktree-more rounded-full text-muted-foreground`,"aria-label":s(`agentManager.detail.actions.worktreeActionsAria`),onClick:M,children:(0,$.jsx)(Z,{name:`more-2`,className:`size-3.5`})}):null]})]})}function io(e){let t=(0,Yr.c)(128),{projects:n,pinnedSessions:r,onAddProject:i,onNewSession:a,onScanQr:o,onSwitchInstance:s,onToggleProject:c,onOpenProjectActions:l,onToggleWorktree:u,onNewWorktreeSession:d,onOpenWorktreeActions:f,onDeleteWorktree:p,onSelectSession:m,onPinSession:h,onArchiveSession:g,onOpenSessionActions:_,className:v}=e,{t:y}=ee(),[b,x]=Q.useState(!0),[S,C]=Q.useState(!1),[w,T]=Q.useState(!1),[E,D]=Q.useState(``),O;t[0]===E?O=t[1]:(O=E.trim().toLowerCase(),t[0]=E,t[1]=O);let k=O,A=k.length>0,j;t[2]!==k||t[3]!==n?(j=Xa(n,k),t[2]=k,t[3]=n,t[4]=j):j=t[4];let M=j,N=P(i),F=P(a),te;t[5]===o?te=t[6]:(te=()=>o?.(),t[5]=o,t[6]=te);let I=P(te),L;t[7]===s?L=t[8]:(L=()=>s?.(),t[7]=s,t[8]=L);let R=P(L),z;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>T(e),t[9]=z):z=t[9];let B=P(z),V;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{D(``),C(!1)},t[10]=V):V=t[10];let H=P(V),U;t[11]!==H||t[12]!==S?(U=()=>{if(S){H();return}C(!0)},t[11]=H,t[12]=S,t[13]=U):U=t[13];let W=P(U),ne;t[14]!==H||t[15]!==c?(ne=e=>{H(),e.expanded||c(e)},t[14]=H,t[15]=c,t[16]=ne):ne=t[16];let re=P(ne),ie;t[17]!==H||t[18]!==c||t[19]!==u?(ie=(e,t)=>{H(),e.expanded||c(e),t.expanded||u(e,t)},t[17]=H,t[18]=c,t[19]=u,t[20]=ie):ie=t[20];let G=P(ie),ae;t[21]!==H||t[22]!==m?(ae=e=>{H(),m(e)},t[21]=H,t[22]=m,t[23]=ae):ae=t[23];let K=P(ae),oe;t[24]===v?oe=t[25]:(oe=X(`relative isolate mx-auto flex w-full max-w-[26rem] flex-col gap-5`,v),t[24]=v,t[25]=oe);let se;t[26]===y?se=t[27]:(se=y(`mobile.sessions.section.projects`),t[26]=y,t[27]=se);let q;t[28]!==S||t[29]!==y?(q=y(S?`mobile.sessions.clearSearchAria`:`mobile.sessions.searchAria`),t[28]=S,t[29]=y,t[30]=q):q=t[30];let ce=S?`close`:`search`,le;t[31]===ce?le=t[32]:(le=(0,$.jsx)(Z,{name:ce,className:`size-5`}),t[31]=ce,t[32]=le);let ue;t[33]!==W||t[34]!==S||t[35]!==q||t[36]!==le?(ue=(0,$.jsx)(Ue,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":q,"aria-expanded":S,onClick:W,children:le}),t[33]=W,t[34]=S,t[35]=q,t[36]=le,t[37]=ue):ue=t[37];let de;t[38]===y?de=t[39]:(de=y(`mobile.projects.menu.label`),t[38]=y,t[39]=de);let fe=w?`rotate-45`:`rotate-0`,pe;t[40]===fe?pe=t[41]:(pe=X(`size-5 transition-transform duration-150 motion-reduce:transition-none`,fe),t[40]=fe,t[41]=pe);let me;t[42]===pe?me=t[43]:(me=(0,$.jsx)(Z,{name:`add`,className:pe}),t[42]=pe,t[43]=me);let he;t[44]!==de||t[45]!==me?(he=(0,$.jsx)(Mt,{asChild:!0,children:(0,$.jsx)(Ue,{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":de,children:me})}),t[44]=de,t[45]=me,t[46]=he):he=t[46];let ge;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(Z,{name:`chat-new`,className:`size-4`}),t[47]=ge):ge=t[47];let _e;t[48]===y?_e=t[49]:(_e=y(`mobile.projects.menu.newChat`),t[48]=y,t[49]=_e);let ve;t[50]!==F||t[51]!==_e?(ve=(0,$.jsxs)(Nt,{className:`min-h-11`,onSelect:F,children:[ge,_e]}),t[50]=F,t[51]=_e,t[52]=ve):ve=t[52];let ye;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(Z,{name:`folder`,className:`size-4`}),t[53]=ye):ye=t[53];let be;t[54]===y?be=t[55]:(be=y(`mobile.projects.menu.newProject`),t[54]=y,t[55]=be);let xe;t[56]!==N||t[57]!==be?(xe=(0,$.jsxs)(Nt,{className:`min-h-11`,onSelect:N,children:[ye,be]}),t[56]=N,t[57]=be,t[58]=xe):xe=t[58];let Se;t[59]!==I||t[60]!==o||t[61]!==y?(Se=o?(0,$.jsxs)(Nt,{className:`min-h-11`,onSelect:I,children:[(0,$.jsx)(Z,{name:`scan-2`,className:`size-4`}),y(`mobile.projects.menu.scanQr`)]}):null,t[59]=I,t[60]=o,t[61]=y,t[62]=Se):Se=t[62];let Ce;t[63]!==R||t[64]!==s||t[65]!==y?(Ce=s?(0,$.jsxs)(Nt,{className:`min-h-11`,onSelect:R,children:[(0,$.jsx)(Z,{name:`server`,className:`size-4`}),y(`mobile.projects.menu.switchInstance`)]}):null,t[63]=R,t[64]=s,t[65]=y,t[66]=Ce):Ce=t[66];let J;t[67]!==ve||t[68]!==xe||t[69]!==Se||t[70]!==Ce?(J=(0,$.jsxs)(At,{align:`end`,side:`bottom`,className:`min-w-44`,children:[ve,xe,Se,Ce]}),t[67]=ve,t[68]=xe,t[69]=Se,t[70]=Ce,t[71]=J):J=t[71];let we;t[72]!==B||t[73]!==w||t[74]!==he||t[75]!==J?(we=(0,$.jsxs)(jt,{open:w,onOpenChange:B,children:[he,J]}),t[72]=B,t[73]=w,t[74]=he,t[75]=J,t[76]=we):we=t[76];let Te;t[77]!==ue||t[78]!==we?(Te=(0,$.jsxs)($.Fragment,{children:[ue,we]}),t[77]=ue,t[78]=we,t[79]=Te):Te=t[79];let Ee;t[80]!==se||t[81]!==Te?(Ee=(0,$.jsx)(Tn,{title:se,trailing:Te}),t[80]=se,t[81]=Te,t[82]=Ee):Ee=t[82];let De;t[83]!==H||t[84]!==S||t[85]!==E||t[86]!==y?(De=S?(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:E,placeholder:y(`mobile.sessions.search.placeholder`),"aria-label":y(`mobile.sessions.searchAria`),className:X(`h-11 rounded-full pl-9`,E&&`pr-10`),onChange:e=>D(e.target.value),onKeyDown:e=>{e.key===`Escape`&&H()}}),E?(0,$.jsx)(Ue,{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":y(`mobile.sessions.clearSearchAria`),onClick:()=>D(``),children:(0,$.jsx)(Z,{name:`close`,className:`size-4`})}):null]}):null,t[83]=H,t[84]=S,t[85]=E,t[86]=y,t[87]=De):De=t[87];let Oe;t[88]!==g||t[89]!==_||t[90]!==h||t[91]!==m||t[92]!==b||t[93]!==r||t[94]!==A||t[95]!==y?(Oe=!A&&r.length>0?(0,$.jsx)(On,{children:(0,$.jsx)(jn,{ariaLabel:y(`mobile.sessions.section.pinned`),label:(0,$.jsx)(no,{icon:(0,$.jsx)(Z,{name:`pushpin`,className:`size-3.5`}),label:y(`mobile.sessions.section.pinned`),count:r.length,expanded:b,onToggle:()=>x(oo)}),children:b?(0,$.jsx)(to,{sessions:r,onSelectSession:m,onPinSession:h,onArchiveSession:g,onOpenSessionActions:_}):null})}):null,t[88]=g,t[89]=_,t[90]=h,t[91]=m,t[92]=b,t[93]=r,t[94]=A,t[95]=y,t[96]=Oe):Oe=t[96];let ke;t[97]!==N||t[98]!==re||t[99]!==G||t[100]!==K||t[101]!==g||t[102]!==p||t[103]!==d||t[104]!==l||t[105]!==_||t[106]!==f||t[107]!==h||t[108]!==m||t[109]!==c||t[110]!==u||t[111]!==n.length||t[112]!==A||t[113]!==y||t[114]!==M?(ke=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:y(`mobile.sessions.empty.noProjectsTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:y(`mobile.sessions.empty.noProjectsDescription`)}),(0,$.jsxs)(Ue,{type:`button`,size:`lg`,className:`mt-4 min-h-10 rounded-full px-5`,onClick:N,children:[(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`}),y(`sessions.sidebar.header.actions.addProject`)]})]}):A&&M.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:y(`mobile.sessions.empty.searchTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:y(`mobile.sessions.empty.searchDescription`)})]}):M.map(e=>{let t=A||e.expanded,n=e.worktrees.find(ao)??(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)(On,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":e.name,children:[(0,$.jsx)(Va,{project:e,expanded:t,embedded:!0,onToggle:()=>A?re(e):c(e),onOpenActions:()=>l(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)(to,{sessions:i,onSelectSession:A?K:m,onPinSession:h,onArchiveSession:g,onOpenSessionActions:_})}):null,r.map(t=>{let n=A||!!t.expanded;return(0,$.jsx)(jn,{className:`oc-mobile-worktree-group`,ariaLabel:t.name,label:(0,$.jsx)(ro,{project:e,worktree:t,expanded:n,onToggle:()=>A?G(e,t):u(e,t),onNewSession:d,onOpenActions:A?void 0:f,onDelete:A?void 0:p}),children:n&&t.sessions.length>0?(0,$.jsx)(to,{sessions:t.sessions,onSelectSession:A?K:m,onPinSession:h,onArchiveSession:g,onOpenSessionActions:_}):null},t.id)})]}):null]})},e.id)}),t[97]=N,t[98]=re,t[99]=G,t[100]=K,t[101]=g,t[102]=p,t[103]=d,t[104]=l,t[105]=_,t[106]=f,t[107]=h,t[108]=m,t[109]=c,t[110]=u,t[111]=n.length,t[112]=A,t[113]=y,t[114]=M,t[115]=ke):ke=t[115];let Ae;t[116]===y?Ae=t[117]:(Ae=y(`sessions.sidebar.header.actions.addProject`),t[116]=y,t[117]=Ae);let je;t[118]!==N||t[119]!==Ae?(je=(0,$.jsx)(`button`,{type:`button`,className:`sr-only`,onClick:N,children:Ae}),t[118]=N,t[119]=Ae,t[120]=je):je=t[120];let Y;return t[121]!==oe||t[122]!==Ee||t[123]!==De||t[124]!==Oe||t[125]!==ke||t[126]!==je?(Y=(0,$.jsxs)(`main`,{className:oe,children:[Ee,De,Oe,ke,je]}),t[121]=oe,t[122]=Ee,t[123]=De,t[124]=Oe,t[125]=ke,t[126]=je,t[127]=Y):Y=t[127],Y}function ao(e){return e.kind===`main`}function oo(e){return!e}function so(e){let t=(0,Yr.c)(11),{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=P(i),f=c?`destructive`:`ghost`,p=u?`size-5 animate-spin`:`size-5`,m;t[0]!==n||t[1]!==p?(m=(0,$.jsx)(Z,{name:n,className:p}),t[0]=n,t[1]=p,t[2]=m):m=t[2];let h;t[3]===r?h=t[4]:(h=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=h);let g;return t[5]!==l||t[6]!==d||t[7]!==f||t[8]!==m||t[9]!==h?(g=(0,$.jsxs)(Ue,{type:`button`,variant:f,size:`lg`,className:`min-h-12 w-full justify-start gap-3 rounded-lg px-4`,disabled:l,onClick:d,children:[m,h]}),t[5]=l,t[6]=d,t[7]=f,t[8]=m,t[9]=h,t[10]=g):g=t[10],g}function co(e,t,n){return e.map(e=>{let r=(0,$.jsx)(so,{icon:e.icon,label:pr(e,t),onClick:n(e.onClick),destructive:e.destructive,disabled:e.disabled,spinning:e.spinning},e.id);return e.separated?(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:r},e.id):r})}function lo(e){let t=(0,Yr.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=tr({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=nr({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=Xn({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=co(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-1 flex-col gap-1 overflow-y-auto overscroll-contain px-2`,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)(It,{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}var uo=`__show_more__:`,fo=`__show_fewer__:`,po=e=>e.startsWith(uo),mo=e=>e.startsWith(fo),ho=e=>po(e)||mo(e),go=e=>{let t=po(e)?uo:mo(e)?fo: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)}},_o=e=>e.parentID??null,vo=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),yo=e=>{let t=e;return vo(t.directory??t.project?.worktree??null)},bo=(e,t)=>{if(t?.trim())return t.trim();let n=vo(e);if(!n)return``;let r=n.split(`/`).filter(Boolean);return r[r.length-1]||n},xo=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},So=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))},Co=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},wo=(e,t)=>e.worktrees.find(e=>vo(e.path)===t)??null,To=(e,t)=>t===e.path||!!wo(e,t);function Eo(){let e=(0,Yr.c)(73),{t}=ee(),n=ce(),r=ye(Go),i=ye(Wo),a=Me(Uo),o=Me(Ho),s=S(Vo),c=J(Bo),l=J(zo),u=ut(Ro),d=ve(),f=ia(Lo),p=ia(Io),m=K(Fo),h;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=new Map,e[0]=h):h=e[0];let[g,_]=Q.useState(h),v=Vn(),y;if(e[1]!==a||e[2]!==u||e[3]!==l){let t;e[5]!==u||e[6]!==l?(t=e=>{let t=vo(e.path);return{id:e.id,label:bo(t,e.label),path:t,icon:e.icon,worktrees:st(u[e.id],l.get(t)??[])}},e[5]=u,e[6]=l,e[7]=t):t=e[7],y=a.map(t),e[1]=a,e[2]=u,e[3]=l,e[4]=y}else y=e[4];let b=y,x;if(e[8]!==r||e[9]!==n){let t=new Map(n.map(Po));x=r.map(e=>{let n=t.get(e.id);return n?we(n,e):e});let i=new Set(x.map(No));for(let e of n)i.has(e.id)||x.push(e);e[8]=r,e[9]=n,e[10]=x}else x=e[10];let C=x,w;if(e[11]!==o||e[12]!==b||e[13]!==C){let t;e[15]===o?t=e[16]:(t=e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===o,latestActivity:0}),e[15]=o,e[16]=t),w=b.map(t);let n=Mo;for(let e of w){n(e,e.project.path,null);for(let t of e.project.worktrees)n(e,t.path,t)}for(let e of C){let t=yo(e);if(!t)continue;let r=vo(t),i=w.find(e=>To(e.project,r));if(!i)continue;let a=wo(i.project,r);(a?n(i,a.path,a):n(i,i.project.path,null)).sessions.push(e)}for(let e of w)for(let t of e.buckets){t.sessions.sort(jo);for(let n of t.sessions){_o(n)||(e.totalSessions+=1);let t=xo(n);t>e.latestActivity&&(e.latestActivity=t)}}e[11]=o,e[12]=b,e[13]=C,e[14]=w}else w=e[14];let T=w,E;if(e[17]!==C){E=new Map;for(let e of C)E.set(e.id,e);e[17]=C,e[18]=E}else E=e[18];let D=E,O;if(e[19]!==b){O=new Map;for(let e of b)O.set(e.id,e);e[19]=b,e[20]=O}else O=e[20];let k=O,A=Ao,j;if(e[21]!==c||e[22]!==d||e[23]!==b||e[24]!==C||e[25]!==t||e[26]!==m){let n;e[28]===d?n=e[29]:(n=e=>d.has(e.id)&&!_o(e),e[28]=d,e[29]=n);let r;e[30]===Symbol.for(`react.memo_cache_sentinel`)?(r=(e,t)=>A(t)-A(e),e[30]=r):r=e[30];let i;e[31]!==c||e[32]!==b||e[33]!==t||e[34]!==m?(i=e=>{let n=yo(e),r=b.find(e=>To(e,n));return r?[{id:e.id,directory:n,title:e.title?.trim()||t(`mobile.sessions.untitled`),subtitle:r.label,activityLabel:So(xo(e))||void 0,unread:(m[e.id]??0)>0,pinned:!0,archived:Co(e),active:c===e.id}]:[]},e[31]=c,e[32]=b,e[33]=t,e[34]=m,e[35]=i):i=e[35],j=C.filter(n).sort(r).flatMap(i),e[21]=c,e[22]=d,e[23]=b,e[24]=C,e[25]=t,e[26]=m,e[27]=j}else j=e[27];let M=j,N;if(e[36]!==T){N=new Map;for(let e of T){let t=e.project.worktrees.length>0;for(let n of e.buckets){let r=n.sessions.filter(ko).length;N.set(`${e.project.id}::${n.key}`,{path:n.path,rootCount:r,hasWorktrees:t})}}e[36]=T,e[37]=N}else N=e[37];let P=N,F;if(e[38]!==i||e[39]!==v||e[40]!==s||e[41]!==c||e[42]!==d||e[43]!==f||e[44]!==T||e[45]!==t||e[46]!==m||e[47]!==g||e[48]!==p){let n=vo(s);F=T.map(e=>{let r=f[e.project.id]??!0,a=gr(),o=e.project.icon?_t[e.project.icon]:void 0,s=e.buckets.map(r=>{let o=`${e.project.id}::${r.key}`,s=p[o]??!1,l=g.get(o)??a,u=r.sessions.filter(Oo),f=Hn(u,l,v).map(e=>{let n=_o(e),i=(m[e.id]??0)>0&&!n;return{id:e.id,directory:r.path,title:e.title?.trim()||t(`mobile.sessions.untitled`),activityLabel:So(xo(e))||void 0,unread:i,pinned:d.has(e.id),archived:Co(e),active:c===e.id}}),h=u.length-f.length,_=i.get(vo(r.path)),y=_?.hasMore===!0,b=u.length>a&&l>a,x=[...f];b&&x.push({id:`${fo}${e.project.id}::${r.key}`,kind:`pagination`,title:t(`sessions.sidebar.group.showFewer`)}),(h>0||y)&&x.push({id:`${uo}${e.project.id}::${r.key}`,kind:`pagination`,title:t(`sessions.sidebar.group.showMore`),subtitle:_?.loadingMore?`…`:void 0});let S=vo(r.path),C=!!(e.isActive&&n&&S&&(n===S||n.startsWith(`${S}/`))),w=r.worktree==null;return{id:r.key,name:w?t(`mobile.sessions.mainWorkspace`):r.label,path:r.path,kind:w?`main`:`worktree`,active:C,expanded:w?!0:s,sessionCount:u.length,sessions:x}});return{id:e.project.id,name:e.project.label,path:e.project.path,icon:o,sessionCount:e.totalSessions,activityLabel:So(e.latestActivity)||void 0,active:e.isActive,expanded:r,worktrees:s}}),e[38]=i,e[39]=v,e[40]=s,e[41]=c,e[42]=d,e[43]=f,e[44]=T,e[45]=t,e[46]=m,e[47]=g,e[48]=p,e[49]=F}else F=e[49];let te=F,I;e[50]===P?I=e[51]:(I=e=>{for(let[t,n]of P)if(t.startsWith(`${e}::`))return n.hasWorktrees;return!1},e[50]=P,e[51]=I);let L=I,R;e[52]===P?R=e[53]:(R=(e,t)=>P.get(`${e}::${t}`)?.rootCount??0,e[52]=P,e[53]=R);let z=R,B=Do,V;e[54]===g?V=e[55]:(V=(e,t)=>{let n=`${e}::${t}`;return g.get(n)??B(e)},e[54]=g,e[55]=V);let H=V,U;e[56]===P?U=e[57]:(U=(e,t)=>P.get(`${e}::${t}`)?.path??null,e[56]=P,e[57]=U);let W=U,ne;e[58]!==P||e[59]!==g?(ne=(e,t)=>{let n=`${e}::${t}`,r=P.get(n),i=gr(),a=Qn(),o=g.get(n)??i,s=r?.rootCount??0;if(_(e=>{let t=new Map(e),r=Math.max(i,e.get(n)??i,o);return t.set(n,r+a),t}),Math.max(i,o)+a<s)return;let c=r?.path,l=vo(c);if(!l)return;let u=ye.getState().activePaginationByDirectory.get(l);u?.hasMore&&!u.loadingMore&&he(l)},e[58]=P,e[59]=g,e[60]=ne):ne=e[60];let re=ne,ie;e[61]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(e,t)=>{let n=`${e}::${t}`;_(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})},e[61]=ie):ie=e[61];let G=ie,ae;return e[62]!==W||e[63]!==z||e[64]!==H||e[65]!==te||e[66]!==M||e[67]!==L||e[68]!==k||e[69]!==D||e[70]!==C||e[71]!==re?(ae={projects:te,pinnedSessions:M,sessionById:D,projectMetaById:k,allSessions:C,projectHasWorktrees:L,getBucketRootCount:z,getBucketVisibleCount:H,getBucketPageSize:B,getBucketDirectory:W,showMoreBucketSessions:re,resetBucketVisibleCount:G},e[62]=W,e[63]=z,e[64]=H,e[65]=te,e[66]=M,e[67]=L,e[68]=k,e[69]=D,e[70]=C,e[71]=re,e[72]=ae):ae=e[72],ae}function Do(e){return gr()}function Oo(e){return!_o(e)}function ko(e){return!_o(e)}function Ao(e){let t=e.time?.created;return typeof t==`number`&&Number.isFinite(t)?t:0}function jo(e,t){return re(t)-re(e)}function Mo(e,t,n){let r=vo(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||bo(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a}function No(e){return e.id}function Po(e){return[e.id,e]}function Fo(e){return e.index.session.unseenCount}function Io(e){return e.worktreeExpanded}function Lo(e){return e.projectExpanded}function Ro(e){return e.orderByProject}function zo(e){return e.availableWorktreesByProject}function Bo(e){return e.currentSessionId}function Vo(e){return e.currentDirectory}function Ho(e){return e.activeProjectId}function Uo(e){return e.projects}function Wo(e){return e.activePaginationByDirectory}function Go(e){return e.activeSessions}var Ko=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function qo({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,className:a}){let{t:o}=ee(),{git:s}=Zt(),c=Eo(),l=ia(e=>e.setProjectExpanded),u=ia(e=>e.setWorktreeExpanded),f=pe(),p=ve(),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=De(e=>e.openDraft),x=De(e=>e.openSession),S=Me(e=>e.projects),C=Me(e=>e.setActiveProjectIdOnly),w=Me(e=>e.removeProject),T=Jt(),[E,D]=Q.useState(null),[O,k]=Q.useState(!1),[A,j]=Q.useState(null),[M,N]=Q.useState(null),[F,I]=Q.useState(null),[L,R]=Q.useState(``),[z,B]=Q.useState(!1),[V,H]=Q.useState(!1),[U,W]=Q.useState(null),[ne,re]=Q.useState(null),[ie,G]=Q.useState(null),ae=E?.kind===`session`?E.session.id:``,K=fe(ae),oe=K?.type===`busy`||K?.type===`retry`,se=E?.kind===`session`?yo(E.session):``,q=!!ae&&ie===ae,ce=!se||q||oe,le=P(e=>{let t=new Map;for(let e of c.allSessions){let n=_o(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}),ue=P(()=>{k(!1),D(null)}),de=P(t=>{if(ho(t.id)){let e=go(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&&yo(n)||null;e({sessionId:t.id,directory:r})}),me=P(e=>{ho(e.id)||f(e.id)}),he=P(async e=>{if(ho(e.id))return;let t=le(e.id),{archivedIds:n,failedIds:r}=await m(t);n.length>0&&Kn({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}))}),ge=P(()=>{if(!E||E.kind!==`session`)return;let e=E.session,t=yo(e),n=K?.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)}})())}),_e=P(e=>{if(ho(e.id))return;let t=c.sessionById.get(e.id);t&&(D({kind:`session`,session:t}),k(!0))}),ye=P(e=>{l(e.id,!e.expanded)}),be=P((e,t)=>{u(`${e.id}::${t.id}`,!t.expanded)}),xe=P((e,t)=>{C(e.id),b({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),Se=P(()=>{if(n){n();return}y()}),Ce=P(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=>Ko(n,t.id,e))}).catch(()=>{D(e=>Ko(e,t.id,!1))}))}),we=P((e,t)=>{let n=d(t);return n?e.worktrees.find(e=>d(e.path)===n)||((J.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>d(e.path)===n)??null):null}),Ee=P((e,t)=>{let n=c.projectMetaById.get(e.id);n&&xe(n,t.path)}),Oe=P((e,t)=>{let n=c.projectMetaById.get(e.id);n&&(D({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),k(!0))}),ke=P((e,t)=>{let n=c.projectMetaById.get(e.id);if(!n)return;let r=we(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})}),Ae=P(e=>{W(e),C(e),H(!0)}),je=P(e=>{(async()=>{let t=e.worktrees;try{t=(await gt({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 Te([e.path,...t.map(e=>e.path)],c.allSessions)})()}),Ne=P((e,t)=>{let n=U;if(H(!1),W(null),t?.sessionId){x({sessionId:t.sessionId,directory:e});return}b({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),Pe=P(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`))}}),Fe=P(async e=>{if((await te(e)).ok){Y.success(o(`sessions.sidebar.session.menu.copied`));return}Y.error(o(`sessions.sidebar.session.share.copyUrlError`))}),Ie=P(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`))}}),Le=P(e=>{let t=le(e.id);mr({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`)})}),Re=P(async()=>{if(!F)return;let e=L.trim();if(e)try{await h(F.id,e),I(null),R(``)}catch{Y.error(o(`sessions.sidebar.session.menu.rename`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),ze=P(async()=>{if(!F||z)return;let e=F.id;I(null),R(``),B(!0);try{await g(e)}catch{Y.error(o(`sessions.sidebar.session.rename.smartTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{B(!1)}}),Be=Q.useMemo(()=>E?E.kind===`session`?{kind:`session`,title:E.session.title?.trim()||o(`mobile.sessions.untitled`),pinned:p.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,p,o]),Ve=Q.useMemo(()=>{if(!E)return{};if(E.kind===`session`){let e=E.session;return{onRename:()=>{R(e.title?.trim()||o(`mobile.sessions.untitled`)),I(e)},onTogglePin:()=>f(e.id),onShare:e.share?.url?void 0:()=>{Pe(e)},onCopyLink:e.share?.url?()=>{Fe(e.share.url)}:void 0,onUnshare:e.share?.url?()=>{Ie(e.id)}:void 0,onRefreshTranscript:ge,onArchive:()=>{he({id:e.id,title:e.title?.trim()||o(`mobile.sessions.untitled`)})},onDelete:()=>Le(e)}}if(E.kind===`project`){let e=E.project;return{onNewSession:()=>xe(e,e.path),onNewWorktree:()=>Ae(e.id),onSyncSessions:()=>je(e),onEditProject:()=>j(e.id),onCloseProject:()=>N(e)}}let{project:e,worktreePath:t}=E;return{onNewSession:()=>xe(e,t),onDeleteWorktree:()=>{let n=we(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,he,Fe,Le,ge,Ae,je,Pe,Ie,we,xe,o,f]),He=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:d(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)(io,{className:a,projects:c.projects,pinnedSessions:c.pinnedSessions,onAddProject:t,onNewSession:Se,onScanQr:r,onSwitchInstance:i,onToggleProject:ye,onOpenProjectActions:Ce,onToggleWorktree:be,onNewWorktreeSession:Ee,onOpenWorktreeActions:Oe,onDeleteWorktree:ke,onSelectSession:de,onPinSession:me,onArchiveSession:e=>{he(e)},onOpenSessionActions:_e}),(0,$.jsx)(lo,{open:O,target:Be,actions:Ve,refreshTranscriptDisabled:ce,refreshTranscriptSpinning:q,onOpenChange:e=>{e?k(!0):ue()}}),(0,$.jsx)(Yt,{open:V,projectId:U,onOpenChange:e=>{H(e),e||W(null)},onWorktreeCreated:Ne}),ne?(0,$.jsx)(Ln,{open:!0,project:{id:ne.project.id,path:ne.project.path},worktree:ne.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)(Ue,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>N(null),children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Ue,{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:!!F,title:o(`sessions.sidebar.session.menu.rename`),onClose:()=>{z||(I(null),R(``))},closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:z,onClick:()=>{I(null),R(``)},children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Ue,{type:`button`,variant:`default`,className:`flex-1`,disabled:!L.trim()||z,onClick:()=>void Re(),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(),Re()},children:[(0,$.jsx)(xt,{value:L,onChange:e=>R(e.target.value),autoFocus:!0,className:`h-12`,disabled:z}),(0,$.jsxs)(Ue,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:z,onClick:()=>void ze(),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)(Gn,{open:A!==null,project:He,onClose:()=>j(null)})]})}function Jo(e){let t=(0,Yr.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)(Dn,{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 Yo(e){let t=(0,Yr.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=[...kn],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(Tr,{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)(Dn,{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 Xo(e){let t=(0,Yr.c)(92),{onAddProject:n,onScanQr:r,onSwitchInstance:i,onEnableAssistants:a,instancesPage:o,instancesSecondaryPage:s,parentSessionTarget:c,registerSecondaryBackHandler:l,scheduledContent:u,renderChat:f,className:p}=e,m=c===void 0?null:c,{t:h}=ee(),g=De(),_=De(ss),v=De(os),y=De(as),b=De(is),x=De(rs),S=De(ns),C=De(ts),w=De(es),T=De($o),E;t[0]===_?E=t[1]:(E=e=>{_(e)},t[0]=_,t[1]=E);let D=P(E),O;t[2]===v?O=t[3]:(O=e=>{v(e)},t[2]=v,t[3]=O);let k=P(O),A;t[4]===x?A=t[5]:(A=()=>{x()},t[4]=x,t[5]=A);let j=P(A),M;t[6]===y?M=t[7]:(M=()=>{y()},t[6]=y,t[7]=M);let N=P(M),F;t[8]===b?F=t[9]:(F=e=>{b(e)},t[8]=b,t[9]=F);let te=P(F),I=Q.useRef(null),[L,R]=Q.useState(!1),z;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{I.current=e},t[10]=z):z=t[10];let B=P(z),V;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(V=e=>{R(e)},t[11]=V):V=t[11];let H=P(V),U;t[12]!==j||t[13]!==S?(U=()=>{if(I.current?.())return!0;let e=De.getState().secondary;return e?.kind===`chat`&&e.routes.length>1?(S(),!0):e?(j(),!0):!1},t[12]=j,t[13]=S,t[14]=U):U=t[14];let W=P(U),ne=g.secondary!==null,re;t[15]!==W||t[16]!==l?(re=()=>{if(l)return l(()=>W()),()=>l(null)},t[15]=W,t[16]=l,t[17]=re):re=t[17];let ie;t[18]!==W||t[19]!==l||t[20]!==ne?(ie=[l,ne,W],t[18]=W,t[19]=l,t[20]=ne,t[21]=ie):ie=t[21],Q.useEffect(re,ie);let G=J(Qo),ae;t[22]===G?ae=t[23]:(ae=e=>G?e.getDirectoryForSession(G):null,t[22]=G,t[23]=ae);let K=J(ae),oe,se;t[24]!==K||t[25]!==G||t[26]!==w||t[27]!==T?(oe=()=>{let e=De.getState().secondary;if(e?.kind===`draft`&&G){w({sessionId:G,directory:K});return}if(e?.kind!==`chat`||!G||ke({sessionId:G,directory:K})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==G||d(t.directory)!==d(K))&&T({sessionId:G,directory:K})},se=[K,G,w,T],t[24]=K,t[25]=G,t[26]=w,t[27]=T,t[28]=oe,t[29]=se):(oe=t[28],se=t[29]),Q.useEffect(oe,se);let q,ce;t[30]!==G||t[31]!==m||t[32]!==C?(q=()=>{let e=De.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]=q,t[34]=ce):(q=t[33],ce=t[34]),Q.useEffect(q,ce);let le;t[35]!==H||t[36]!==B||t[37]!==u?(le=typeof u==`function`?u(B,H):u,t[35]=H,t[36]=B,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)(qo,{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]!==te?(fe=(0,$.jsx)(Na,{onEnable:a,onOpenAssistant:te}),t[45]=a,t[46]=te,t[47]=fe):fe=t[47];let pe;t[48]===ue?pe=t[49]:(pe=(0,$.jsx)(Jo,{showHeader:!1,children:ue}),t[48]=ue,t[49]=pe);let me;t[50]===o?me=t[51]:(me=(0,$.jsx)(Yo,{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)(Mr,{activeOverride:!0,onMobileBack:Zo}),t[59]=n):n=t[59];let r;t[60]!==W||t[61]!==e?(r=[{key:`assistant-secondary`,depth:1,ariaLabel:e,onBack:W,content:n}],t[60]=W,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]!==W||t[66]!==s||t[67]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:W,content:s}],t[65]=W,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]===f?n=t[72]:(n=f({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[71]=f,t[72]=n);let r;t[73]!==W||t[74]!==e||t[75]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:W,content:n}],t[73]=W,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]!==W||t[79]!==f||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:W,content:f({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:n})}}),t[78]=W,t[79]=f,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]!==p||t[86]!==g||t[87]!==L||t[88]!==D||t[89]!==be||t[90]!==ge?(xe=(0,$.jsx)(La,{className:p,navigation:g,onTabChange:D,tabs:ge,secondaryPages:be,tabBarCovered:L}),t[85]=p,t[86]=g,t[87]=L,t[88]=D,t[89]=be,t[90]=ge,t[91]=xe):xe=t[91],xe}function Zo(){return nn.requestAnimatedBack(`root`)}function Qo(e){return e.currentSessionId}function $o(e){return e.replaceChatSession}function es(e){return e.materializeDraftSession}function ts(e){return e.reconcileChatPredecessor}function ns(e){return e.popChatSession}function rs(e){return e.closeSecondary}function is(e){return e.openAssistant}function as(e){return e.openDraft}function os(e){return e.openSession}function ss(e){return e.setActiveTab}function cs(e){let t=(0,Yr.c)(19),{percentage:n}=e,r,i,a,o,s,c,l;if(t[0]!==n){a=Tt(n)??0;let e=wt(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 ls(e){let t=(0,Yr.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=P(i),p=P(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)(Re,{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 us=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},ds=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),fs=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,ps=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:`${ds(t)}/${ds(n)}`,colorClass:fs(i)}},ms=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},hs=(e,t)=>{let n=Se(e,t??(()=>void 0));return!n||`compacted`in n?0:n.totalTokens},gs=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),_s=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`},vs=e=>{let t=(0,Yr.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},ys=e=>{let t=(0,Yr.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)(mt,{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=Ct(e.window.valueLabel,t),i=Dt(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`,_s(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},bs=e=>{let t=(0,Yr.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)(vs,{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)(vs,{iconNode:(0,$.jsx)(cs,{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)(ys,{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:Bs,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()),F([])}),Ee=P(async()=>{if(!s)return;let e=s,t=K.map(e=>e.path).sort();if(t.length===0){Y.error(a(`gitView.toast.selectFileToDescribe`));return}M(!0);try{let{message:n}=await Je(e,t);E(n.subject?.trim()??``),F(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=K.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(``),F([]),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 K.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:K,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:J,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:J}),e},[J,Se,xe,K,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)(Ii,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):l===!1?ke((0,$.jsx)(Ii,{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)(Li,{path:v.path,diff:ue,fileExists:ge,error:he,loading:me,targetLine:v.targetLine,onBack:Ce,onRetry:()=>W(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)(fr,{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)(Zn,{stagedCount:se,unstagedCount:q,onLoad:()=>ie(!0)})}):ae.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)(sr,{groups:Oe,diffStats:c?.diffStats,revertingPaths:D,onRevertAll:we,isRevertingAll:k,headerBackgroundClassName:`bg-transparent`,onVisiblePathsChange:I})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-4 pt-3`,children:(0,$.jsx)(lr,{stagedCount:K.length,commitMessage:T,onCommitMessageChange:E,generatedHighlights:N,onInsertHighlights:Te,onGenerateMessage:Ee,isGeneratingMessage:j,onCommit:()=>void De({pushAfter:!1}),onCommitAndPush:()=>void De({pushAfter:!0}),commitAction:C,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Ii,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):ke((0,$.jsx)(Ii,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},Ii=e=>{let t=(0,Yr.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},Li=e=>{let t=(0,Yr.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=ln(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)(Ue,{type:`button`,size:`sm`,variant:`outline`,onClick:l,children:f(`diffView.actions.retry`)})]})}):o?(0,$.jsx)(Ii,{loading:!0,message:f(`diffView.state.loadingDiff`)}):i?r?r.isBinary?(0,$.jsx)(Ii,{icon:!0,message:f(`diffView.binary.unavailable`)}):cn(n)?(0,$.jsx)(Ii,{icon:!0,message:f(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(vt,{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)(qn,{original:r.original,modified:r.modified,language:m,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:s,layout:`inline`})}):(0,$.jsx)(Ii,{loading:!0,message:f(`diffView.state.loadingDiff`)}):(0,$.jsx)(Ii,{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],_},Ri=an(()=>k(()=>import(`./ToolOutputDialog-6lL_lCmU.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]))),zi=25e4,Bi=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Vi=e=>{let t=Bi(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},Hi=e=>{let t=Bi(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},Ui=(e,t)=>{let n=Bi(e),r=Bi(t);return!r||n===r?Vi(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},Wi=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``},Gi=e=>e.toLowerCase().endsWith(`.svg`)?``:r().authenticatedAsset(`/api/fs/raw`,{path:e}),Ki=e=>/\.(md|mdx|markdown)$/i.test(e),qi=e=>{let t=(0,Yr.c)(138),{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:u}=ee(),{files:d}=Zt(),f=un()??null,p;t[0]===f?p=t[1]:(p=Bi(f),t[0]=f,t[1]=p);let m=p,h;t[2]!==o||t[3]!==m?(h=()=>{let e=Bi(o);return e?{type:`file`,path:e,returnDirectory:Hi(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=l($i),S=l(ea),C,w;t[5]===m?(C=t[6],w=t[7]):(C=()=>{m&&_(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:Hi(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=Bi(x);if(!e){S(null);return}b(``),_({type:`file`,path:e,returnDirectory:Hi(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=fn(y,250),j;t[13]===y?j=t[14]:(j=y.trim(),t[13]=y,t[14]=j);let M=j,N;t[15]===A?N=t[16]:(N=A.trim(),t[15]=A,t[16]=N);let F=N,I;t[17]!==O||t[18]!==m?(I={scopeDirectory:m,directory:O},t[17]=O,t[18]=m,t[19]=I):I=t[19];let L=!!O,R;t[20]===L?R=t[21]:(R={enabled:L,refetchOnMount:`always`},t[20]=L,t[21]=R);let z=Pr(I,R),B;t[22]!==O||t[23]!==F?(B={directory:O,query:F,maxResults:40},t[22]=O,t[23]=F,t[24]=B):B=t[24];let V=!!(O&&F),H;t[25]===V?H=t[26]:(H={enabled:V},t[25]=V,t[26]=H);let U=Nr(B,H),W;t[27]!==k||t[28]!==d?(W=k&&d.readFile&&(!cn(k)||k.toLowerCase().endsWith(`.svg`)),t[27]=k,t[28]=d,t[29]=W):W=t[29];let ne=!!W,re;t[30]!==k||t[31]!==m?(re={scopeDirectory:m,path:k},t[30]=k,t[31]=m,t[32]=re):re=t[32];let ie;t[33]===ne?ie=t[34]:(ie={enabled:ne},t[33]=ne,t[34]=ie);let G=Fr(re,ie),ae=z.data?.entries.slice().sort(ta)??[],K;t[35]!==z.error||t[36]!==u?(K=z.error?z.error instanceof Error?z.error.message:u(`mobile.files.error.listFailed`):null,t[35]=z.error,t[36]=u,t[37]=K):K=t[37];let oe=K,se=z.isFetching,q;t[38]===U.data?q=t[39]:(q=U.data??[],t[38]=U.data,t[39]=q);let ce=q,le=!!(M&&F&&y===A&&U.isFetching),ue;t[40]!==G.data||t[41]!==u?(ue=G.data&&G.data.length>zi?`${G.data.slice(0,zi)}\n\n${u(`mobile.files.file.truncated`)}`:G.data??``,t[40]=G.data,t[41]=u,t[42]=ue):ue=t[42];let de=ue,fe;t[43]!==k||t[44]!==G.error||t[45]!==d||t[46]!==u?(fe=k&&!d.readFile?u(`mobile.files.error.readUnavailable`):G.error?G.error instanceof Error?G.error.message:u(`filesView.error.readFileFailed`):null,t[43]=k,t[44]=G.error,t[45]=d,t[46]=u,t[47]=fe):fe=t[47];let pe=fe,me=ne&&G.isFetching,he;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(he=e=>{b(``),_({type:`browser`,directory:e})},t[48]=he):he=t[48];let ge=he,_e;t[49]!==D||t[50]!==m?(_e=e=>{_({type:`file`,path:e,returnDirectory:D||m})},t[49]=D,t[50]=m,t[51]=_e):_e=t[51];let ve=_e,ye;t[52]!==s||t[53]!==n||t[54]!==g.returnDirectory||t[55]!==g.type?(ye=()=>g.type===`file`?s?(n?.(),!0):(_({type:`browser`,directory:g.returnDirectory}),!0):!1,t[52]=s,t[53]=n,t[54]=g.returnDirectory,t[55]=g.type,t[56]=ye):ye=t[56];let be=P(ye),xe=g.type===`file`,Se;t[57]!==be||t[58]!==xe?(Se={id:`mobile-files-detail`,active:xe,layer:`overlay`,onBack:be,surfaceRef:v},t[57]=be,t[58]=xe,t[59]=Se):Se=t[59],Qt(Se);let Ce;t[60]===u?Ce=t[61]:(Ce=async e=>{(await te(e)).ok||Y.error(u(`mobile.files.toast.copyFailed`))},t[60]=u,t[61]=Ce);let J=Ce,we;t[62]!==de||t[63]!==u?(we=async()=>{(await te(de)).ok?Y.success(u(`mobile.files.toast.contentCopied`)):Y.error(u(`mobile.files.toast.copyFailed`))},t[62]=de,t[63]=u,t[64]=we):we=t[64];let Te=we;if(!m){let e;t[65]===u?e=t[66]:(e=u(`mobile.files.empty.noDirectory`),t[65]=u,t[66]=e);let n;return t[67]===e?n=t[68]:(n=(0,$.jsx)(Qi,{message:e}),t[67]=e,t[68]=n),n}if(g.type===`file`){let e;t[69]!==J||t[70]!==g.path?(e=()=>void J(g.path),t[69]=J,t[70]=g.path,t[71]=e):e=t[71];let n;t[72]===Te?n=t[73]:(n=()=>void Te(),t[72]=Te,t[73]=n);let r;return t[74]!==be||t[75]!==de||t[76]!==pe||t[77]!==c||t[78]!==me||t[79]!==g.path||t[80]!==e||t[81]!==n?(r=(0,$.jsx)(`div`,{ref:v,className:`h-full min-h-0`,children:(0,$.jsx)(Xi,{path:g.path,content:de,error:pe,isLoading:me,hideHeader:c,onBack:be,onCopyPath:e,onCopyContent:n})}),t[74]=be,t[75]=de,t[76]=pe,t[77]=c,t[78]=me,t[79]=g.path,t[80]=e,t[81]=n,t[82]=r):r=t[82],r}let Ee;t[83]!==m||t[84]!==g.directory||t[85]!==u?(Ee=g.directory===m?u(`mobile.files.rootDirectory`):Vi(g.directory),t[83]=m,t[84]=g.directory,t[85]=u,t[86]=Ee):Ee=t[86];let De=Ee,Oe;t[87]!==y||t[88]!==ce?(Oe=y.trim()?ce:[],t[87]=y,t[88]=ce,t[89]=Oe):Oe=t[89];let ke=Oe,Ae,je,Me,Ne;if(t[90]!==n||t[91]!==y||t[92]!==m||t[93]!==g.directory||t[94]!==u){let e=Hi(g.directory),r=g.directory!==m&&e!==null&&(e===m||e.startsWith(`${m}/`)),i=r&&!y.trim(),a=r?e:null;Ne=`flex h-full flex-col overflow-hidden bg-background text-foreground`,Ae=`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[99]!==n||t[100]!==u?(je=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":u(`mobile.surface.closeAria`),onClick:n,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`close`,className:`size-5`})}):null,t[99]=n,t[100]=u,t[101]=je):je=t[101],Me=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":u(`mobile.files.backToParentAria`,{name:Vi(a)}),onClick:()=>ge(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`arrow-left`,className:`size-5`})}):null,t[90]=n,t[91]=y,t[92]=m,t[93]=g.directory,t[94]=u,t[95]=Ae,t[96]=je,t[97]=Me,t[98]=Ne}else Ae=t[95],je=t[96],Me=t[97],Ne=t[98];let Pe;t[102]===De?Pe=t[103]:(Pe=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:De})}),t[102]=De,t[103]=Pe);let Fe;t[104]===u?Fe=t[105]:(Fe=u(`mobile.files.refreshAria`),t[104]=u,t[105]=Fe);let Ie;t[106]===z?Ie=t[107]:(Ie=()=>void z.refetch(),t[106]=z,t[107]=Ie);let Le;t[108]===Symbol.for(`react.memo_cache_sentinel`)?(Le={touchAction:`manipulation`},t[108]=Le):Le=t[108];let Re=se&&`animate-spin`,ze;t[109]===Re?ze=t[110]:(ze=X(`size-5`,Re),t[109]=Re,t[110]=ze);let Be;t[111]===ze?Be=t[112]:(Be=(0,$.jsx)(Z,{name:`refresh`,className:ze}),t[111]=ze,t[112]=Be);let Ve;t[113]!==Fe||t[114]!==Ie||t[115]!==Be?(Ve=(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":Fe,onClick:Ie,style:Le,children:Be}),t[113]=Fe,t[114]=Ie,t[115]=Be,t[116]=Ve):Ve=t[116];let He;t[117]!==Ae||t[118]!==je||t[119]!==Me||t[120]!==Pe||t[121]!==Ve?(He=(0,$.jsxs)(`header`,{className:Ae,children:[je,Me,Pe,Ve]}),t[117]=Ae,t[118]=je,t[119]=Me,t[120]=Pe,t[121]=Ve,t[122]=He):He=t[122];let Ue;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(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[123]=Ue):Ue=t[123];let We;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(We=e=>b(e.target.value),t[124]=We):We=t[124];let Ge;t[125]===u?Ge=t[126]:(Ge=u(`mobile.files.search.placeholder`),t[125]=u,t[126]=Ge);let Ke;t[127]!==y||t[128]!==Ge?(Ke=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[Ue,(0,$.jsx)(xt,{type:`text`,inputMode:`search`,value:y,onChange:We,placeholder:Ge,className:`h-11 pl-9`})]})}),t[127]=y,t[128]=Ge,t[129]=Ke):Ke=t[129];let qe=vt,Je=oe?(0,$.jsx)(Qi,{message:oe}):y.trim()?(0,$.jsx)(Yi,{results:ke,isSearching:le,onOpenFile:ve}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[ae.length===0&&!se?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:u(`mobile.files.empty.directory`)}):null,ae.map(e=>(0,$.jsx)(Ji,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:Wi(e.size),onClick:()=>e.isDirectory?ge(e.path):ve(e.path)},e.path))]}),Ye;t[130]!==qe||t[131]!==Je?(Ye=(0,$.jsx)(qe,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:Je}),t[130]=qe,t[131]=Je,t[132]=Ye):Ye=t[132];let Xe;return t[133]!==Ne||t[134]!==He||t[135]!==Ke||t[136]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:Ne,children:[He,Ke,Ye]}),t[133]=Ne,t[134]=He,t[135]=Ke,t[136]=Ye,t[137]=Xe):Xe=t[137],Xe},Ji=e=>{let t=(0,Yr.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)(Gt,{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},Yi=e=>{let t=(0,Yr.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=ee(),o=Bi(un()??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)(Qi,{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)(Qi,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(Ji,{name:Vi(e.path),path:e.path,directory:!1,meta:Ui(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},Xi=e=>{let t=(0,Yr.c)(59),{path:r,content:i,error:s,isLoading:c,hideHeader:l,onBack:d,onCopyPath:f,onCopyContent:m}=e,h=l!==void 0&&l,{t:g}=ee(),_=cn(r)&&!r.toLowerCase().endsWith(`.svg`)?r:``,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=n(),t[0]=v):v=t[0];let y=v,b;t[1]===_?b=t[2]:(b=_&&o()?`${y}|${_}`:``,t[1]=_,t[2]=b);let x=b,S=_&&!x?`${y}|${_}`:``,[C,w]=Q.useState(``),[T,E]=Q.useState(``),[D,O]=Q.useState(null),[k,A]=Q.useState(!1),j;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(j={open:!1,title:``,content:``},t[3]=j):j=t[3];let[M,N]=Q.useState(j),F,te;t[4]===S?(F=t[5],te=t[6]):(F=()=>{if(!S){w(``);return}let e=!1;return w(``),a(u()).then(t=>{!e&&t&&w(S)}).catch(na),()=>{e=!0}},te=[S],t[4]=S,t[5]=F,t[6]=te),Q.useEffect(F,te);let I,L;t[7]!==_||t[8]!==x||t[9]!==g?(I=()=>{if(!x){E(``),O(null),A(!1);return}let e=!1,t=``;return E(``),O(null),A(!0),p(`/api/fs/raw`,{query:{path:_}}).then(async e=>{if(!e.ok)throw Error(g(`filesView.error.readFileFailed`));return e.blob()}).then(n=>{if(t=URL.createObjectURL(n),e){URL.revokeObjectURL(t);return}E(t)}).catch(t=>{e||O(t instanceof Error?t.message:g(`filesView.error.readFileFailed`))}).finally(()=>{e||A(!1)}),()=>{e=!0,t&&URL.revokeObjectURL(t)}},L=[_,x,g],t[7]=_,t[8]=x,t[9]=g,t[10]=I,t[11]=L):(I=t[10],L=t[11]),Q.useEffect(I,L);let R=!!(S&&C!==S),z;t[12]!==R||t[13]!==r||t[14]!==x||t[15]!==T?(z=x?T:R?``:Gi(r),t[12]=R,t[13]=r,t[14]=x,t[15]=T,t[16]=z):z=t[16];let B=z,V=s??D,H;t[17]===r?H=t[18]:(H=Vi(r),t[17]=r,t[18]=H);let U=H,W;t[19]!==i||t[20]!==r?(W=cn(r)?`data:${sn(r)};utf8,${encodeURIComponent(i)}`:``,t[19]=i,t[20]=r,t[21]=W):W=t[21];let ne=W,re;t[22]!==i||t[23]!==ne||t[24]!==B||t[25]!==r?(re=B||(cn(r)&&i?ne:``),t[22]=i,t[23]=ne,t[24]=B,t[25]=r,t[26]=re):re=t[26];let ie=re,G;t[27]!==U||t[28]!==_||t[29]!==r||t[30]!==ie?(G=()=>{let e=_||ie;e&&N({open:!0,title:U,content:``,metadata:{tool:`image-preview`,filename:U,mime:sn(r)},image:{url:e,mimeType:sn(r),filename:U}})},t[27]=U,t[28]=_,t[29]=r,t[30]=ie,t[31]=G):G=t[31];let ae=P(G),K;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>{N(t=>t.open===e?t:{...t,open:e})},t[32]=K):K=t[32];let oe=P(K),se;t[33]!==h||t[34]!==U||t[35]!==d||t[36]!==m||t[37]!==f||t[38]!==r||t[39]!==g?(se=h?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1 px-3 pb-1`,children:[cn(r)?null:(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:m,"aria-label":g(`mobile.files.copyContentAria`),children:(0,$.jsx)(Z,{name:`file-copy`,className:`size-4`})}),(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:f,"aria-label":g(`mobile.files.copyPathAria`),children:(0,$.jsx)(Z,{name:`clipboard`,className:`size-4`})})]}):(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":g(`header.actions.backAria`),onClick:d,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:U})}),cn(r)?null:(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:m,"aria-label":g(`mobile.files.copyContentAria`),children:(0,$.jsx)(Z,{name:`file-copy`,className:`size-4`})}),(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:f,"aria-label":g(`mobile.files.copyPathAria`),children:(0,$.jsx)(Z,{name:`clipboard`,className:`size-4`})})]}),t[33]=h,t[34]=U,t[35]=d,t[36]=m,t[37]=f,t[38]=r,t[39]=g,t[40]=se):se=t[40];let q;t[41]!==i||t[42]!==R||t[43]!==V||t[44]!==U||t[45]!==c||t[46]!==k||t[47]!==ae||t[48]!==r||t[49]!==ie||t[50]!==g?(q=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:c||R||k?(0,$.jsx)(Qi,{loading:!0,message:g(`filesView.state.loading`)}):V?(0,$.jsx)(Qi,{message:V}):cn(r)&&ie?(0,$.jsx)(vt,{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:ae,"aria-label":U,children:(0,$.jsx)(`img`,{src:ie,alt:U,className:`mx-auto max-h-full max-w-full rounded-lg object-contain`,draggable:!1})})}):(0,$.jsx)(Zi,{path:r,content:i})}),t[41]=i,t[42]=R,t[43]=V,t[44]=U,t[45]=c,t[46]=k,t[47]=ae,t[48]=r,t[49]=ie,t[50]=g,t[51]=q):q=t[51];let ce;t[52]!==oe||t[53]!==M?(ce=M.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ri,{popup:M,onOpenChange:oe,isMobile:!0})}):null,t[52]=oe,t[53]=M,t[54]=ce):ce=t[54];let le;return t[55]!==se||t[56]!==q||t[57]!==ce?(le=(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[se,q,ce]}),t[55]=se,t[56]=q,t[57]=ce,t[58]=le):le=t[58],le},Zi=e=>{let t=(0,Yr.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=kt(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??Ht(!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)??Ht(!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=()=>{rn(l),rn(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(Ki(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(vt,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)($t,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=Vi(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=ln(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:zn},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)(vt,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(_n,{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},Qi=e=>{let t=(0,Yr.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 $i(e){return e.pendingFileFocusPath}function ea(e){return e.setPendingFileFocusPath}function ta(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}function na(){}var ra=v(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),ia=v()(y(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:m()}));typeof window<`u`&&c(e=>{t(e)&&ia.persist.rehydrate()});var aa=36,oa=18,sa=e=>e.parentID??null,ca=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),la=e=>{let t=e;return ca(t.directory??t.project?.worktree??null)},ua=e=>{let t=ca(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},da=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},fa=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),pa=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))},ma=(e,t)=>{let n=ca(e),r=ca(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},ha=(e,t)=>e.worktrees.find(e=>ca(e.path)===t)??null,ga=(e,t)=>t===e.path||!!ha(e,t),_a=(e,t)=>{let n=ca(t);return n?e.find(e=>ga(e,n))??null:null},va=(e,t,n)=>!n||`${e.title??``} ${e.id} ${la(e)} ${t}`.toLowerCase().includes(n),ya=e=>{let t=(0,Yr.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?_t[n.icon]:null,c=n.color?yt[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)(ht,{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},ba=e=>{let t=(0,Yr.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},xa=e=>{let t=(0,Yr.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},Sa=e=>{let t=(0,Yr.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},Ca=e=>{let t=(0,Yr.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)(Ue,{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},wa=e=>{let t=(0,Yr.c)(65),{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}=e,g=o!==void 0&&o,_=s!==void 0&&s,v=c!==void 0&&c,{t:y}=ee(),b;t[0]===n?b=t[1]:(b=pa(da(n)),t[0]=n,t[1]=b);let x=b,S;t[2]!==n.title||t[3]!==y?(S=n.title?.trim()||y(`mobile.sessions.untitled`),t[2]=n.title,t[3]=y,t[4]=S):S=t[4];let C=S,w=r&&!g&&`bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]`,T=g&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`,E;t[5]!==w||t[6]!==T?(E=X(`relative flex items-center gap-1 transition-colors`,w,T),t[5]=w,t[6]=T,t[7]=E):E=t[7];let D;t[8]!==v||t[9]!==_||t[10]!==i||t[11]!==l||t[12]!==y?(D=_&&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":y(v?`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`,v?`rotate-0`:`-rotate-90`)})}):null,t[8]=v,t[9]=_,t[10]=i,t[11]=l,t[12]=y,t[13]=D):D=t[13];let O=g&&`opacity-50`,k=h.pressed&&`bg-interactive-active scale-[0.99]`,A;t[14]!==O||t[15]!==k?(A=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,k),t[14]=O,t[15]=k,t[16]=A):A=t[16];let j;t[17]===i?j=t[18]:(j={paddingLeft:i,touchAction:`manipulation`},t[17]=i,t[18]=j);let M=h.onPointerDown,N=h.onPointerMove,P=h.onPointerUp,F=h.onPointerCancel,te=h.onContextMenu,I=r?`bg-primary`:`bg-muted-foreground/30`,L;t[19]===I?L=t[20]:(L=X(`size-1.5 shrink-0 rounded-full`,I),t[19]=I,t[20]=L);let R;t[21]===L?R=t[22]:(R=(0,$.jsx)(`span`,{className:L,"aria-hidden":!0}),t[21]=L,t[22]=R);let z=r?`text-primary`:`text-foreground`,B;t[23]===z?B=t[24]:(B=X(`block min-w-0 flex-1 truncate typography-ui-label`,z),t[23]=z,t[24]=B);let V;t[25]!==B||t[26]!==C?(V=(0,$.jsx)(`span`,{className:B,children:C}),t[25]=B,t[26]=C,t[27]=V):V=t[27];let H;t[28]===x?H=t[29]:(H=x?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:x}):null,t[28]=x,t[29]=H);let U;t[30]!==R||t[31]!==V||t[32]!==H?(U=(0,$.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[R,V,H]}),t[30]=R,t[31]=V,t[32]=H,t[33]=U):U=t[33];let W;t[34]===a?W=t[35]:(W=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:a}):null,t[34]=a,t[35]=W);let ne;t[36]!==U||t[37]!==W?(ne=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[U,W]}),t[36]=U,t[37]=W,t[38]=ne):ne=t[38];let re;t[39]!==g||t[40]!==h.onContextMenu||t[41]!==h.onPointerCancel||t[42]!==h.onPointerDown||t[43]!==h.onPointerMove||t[44]!==h.onPointerUp||t[45]!==u||t[46]!==A||t[47]!==j||t[48]!==ne?(re=(0,$.jsx)(`button`,{type:`button`,className:A,style:j,onClick:u,onPointerDown:M,onPointerMove:N,onPointerUp:P,onPointerCancel:F,onContextMenu:te,disabled:g,children:ne}),t[39]=g,t[40]=h.onContextMenu,t[41]=h.onPointerCancel,t[42]=h.onPointerDown,t[43]=h.onPointerMove,t[44]=h.onPointerUp,t[45]=u,t[46]=A,t[47]=j,t[48]=ne,t[49]=re):re=t[49];let ie;t[50]!==p||t[51]!==m?(ie=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)(Rn,{})}):null,t[50]=p,t[51]=m,t[52]=ie):ie=t[52];let G;t[53]!==g||t[54]!==f||t[55]!==d||t[56]!==y||t[57]!==C?(G=d?(0,$.jsxs)($.Fragment,{children:[g?(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":y(`mobile.sessions.archiveSessionAria`,{title:C}),onClick:f,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Z,{name:`archive`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:y(`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":y(g?`mobile.sessions.cancelArchiveAria`:`mobile.sessions.archiveSessionAria`,{title:C}),onClick:d,style:{touchAction:`manipulation`},children:g?(0,$.jsx)(Z,{name:`close`,className:`size-4`}):(0,$.jsx)(Z,{name:`archive`,className:`size-4`})})]}):null,t[53]=g,t[54]=f,t[55]=d,t[56]=y,t[57]=C,t[58]=G):G=t[58];let ae;return t[59]!==re||t[60]!==ie||t[61]!==G||t[62]!==E||t[63]!==D?(ae=(0,$.jsxs)(`div`,{className:E,children:[D,re,ie,G]}),t[59]=re,t[60]=ie,t[61]=G,t[62]=E,t[63]=D,t[64]=ae):ae=t[64],ae},Ta=e=>{let t=(0,Yr.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},Ea=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=ee(),{git:i}=Zt(),a=ce(),o=ye(e=>e.activeSessions),s=ye(e=>e.activePaginationByDirectory),c=Me(e=>e.projects),l=Me(e=>e.activeProjectId),u=S(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),C=Me(e=>e.setActiveProjectIdOnly),w=Me(e=>e.removeProject),T=ve(),E=pe(),D=ia(e=>e.projectExpanded),O=ia(e=>e.worktreeExpanded),k=ia(e=>e.setProjectExpanded),A=ia(e=>e.setWorktreeExpanded),j=ut(e=>e.orderByProject),M=ra(e=>e.expandedParents),N=ra(e=>e.toggleParent),[F,I]=Q.useState(``),[L,R]=Q.useState(null),[z,B]=Q.useState(null),[V,H]=Q.useState(0),[U,W]=Q.useState(!1),[ne,ie]=Q.useState(!1),[G,ae]=Q.useState(null),[K,se]=Q.useState(null),[le,ue]=Q.useState(null),[de,fe]=Q.useState(null),[me,ge]=Q.useState(null),[_e,be]=Q.useState(``),[xe,Se]=Q.useState(!1),[Ce,Ee]=Q.useState(null),De=Q.useRef(null);De.current||=dn({onPressedKeyChange:fe});let[Oe,ke]=Q.useState(new Set),[Ae,je]=Q.useState(new Map),[Ne,Pe]=Q.useState(new Map),Fe=Wn(),Ie=Vn(),Le=P(e=>{q(e),oe(e)}),Re=P(e=>{Promise.all(e.map(e=>(q(e),oe(e))))});Q.useEffect(()=>{if(!e){I(``),Pe(new Map),R(null),B(null),se(null),ge(null),Ee(null),De.current?.reset();return}},[e]),Q.useEffect(()=>()=>{De.current?.reset()},[]),Q.useEffect(()=>{if(!e)return;if(c.length===0){J.setState(e=>{let t=hr(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),ke(e=>e.size===0?e:new Set),je(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(c.map(async e=>{let n=ca(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([gt({id:e.id,path:n},{isCurrent:()=>!t}),bt(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=>ca(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);J.setState(e=>{let t=hr(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),ke(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 fa(r,t)?t:r}),je(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,V]);let ze=Q.useMemo(()=>c.map(e=>({id:e.id,label:ua(e.path),path:ca(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:Oe.has(ca(e.path)),worktrees:st(j[e.id],f.get(ca(e.path))??[])})),[Oe,c,j,f]),Be=Q.useMemo(()=>{let e=new Map(a.map(e=>[e.id,e])),t=o.map(t=>{let n=e.get(t.id);return n?we(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]),Ve=F.trim().toLowerCase(),He=Q.useMemo(()=>{let e=ze.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===l})),t=(e,t,n)=>{let r=ca(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||ua(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 Be){let r=la(n);if(!r)continue;let i=ca(r),a=e.find(e=>ga(e.project,i));if(!a)continue;let o=ha(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)=>re(t)-re(e));for(let n of e.sessions)sa(n)||(t.totalSessions+=1)}return e},[l,ze,Be]),We=ca(u),Ge=e=>e.isActive?We===e.project.path?e.project.path:e.project.worktrees.find(e=>ma(We,e.path))?.path??e.project.path:null,Ke=e=>D[e.project.id]??!0,qe=(e,t)=>O[`${e.project.id}::${t.key}`]??!1,Je=e=>{Pe(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},Ye=()=>{se(null),De.current?.reset()},Xe=e=>({pressed:de===e.key||K?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||De.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>se(e)})},onPointerMove:e=>{De.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{De.current?.end(e.pointerId)},onPointerCancel:e=>{De.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),De.current?.openFromContextMenu(e.key,()=>se(e))}}),Ze=(e,t)=>{De.current?.consumeClick(e)||t()},Qe=(e,t,n,r)=>{let i=gr(),a=Qn();if(Pe(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=ca(t);if(!o)return;let s=ye.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&he(o)},$e=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=gr(),o=new Set(t.sessions.map(e=>e.id)),c=new Map;for(let e of t.sessions){let t=sa(e);if(t&&o.has(t)){let n=c.get(t)??[];n.push(e),c.set(t,n)}}let l=t.sessions.filter(e=>!sa(e)),u=Ne.get(i)??a,f=Hn(l,u,Ie),p=l.length-f.length,m=s.get(ca(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=Fe.has(e.id),s=i&&!a?n.filter(e=>Fe.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)(wa,{session:e,active:d===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>N(e.id):void 0,confirmingArchive:z===e.id,onSelect:()=>Ze(p,()=>nt(e)),onRequestArchive:()=>rt(e.id),onConfirmArchive:()=>void it(e),onStop:o||l?()=>Re(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:f}),longPressHandlers:Xe({key:p,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+oa)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[f.map(e=>v(e,n)),(0,$.jsx)(Ta,{indent:n,showMore:p>0||h,showFewer:_,loadingMore:g,onShowMore:()=>Qe(i,t.path,u,l.length),onShowFewer:()=>Je(i)})]})},et=(e,t)=>{k(e,!t)},tt=(e,t,n)=>{A(`${e}::${t}`,!n)},nt=e=>{Ft();let n=la(e)||null,r=_a(ze,n??``);r&&C(r.id),p(e.id,n),t(!1)},rt=e=>{B(t=>t===e?null:e)},it=async e=>{B(null),await m(e.id)?Kn({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=>{ae(e),C(e),ie(!0)},ct=e=>{let t=new Map;for(let e of Be){let n=sa(e);if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n},lt=async e=>{let t=ct(e.id),{archivedIds:n,failedIds:i}=await h(t);n.length>0&&Kn({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}))},dt=e=>{let t=ct(e.id);mr({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`)})},ft=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`))}},pt=async e=>{if((await te(e)).ok){Y.success(r(`sessions.sidebar.session.menu.copied`));return}Y.error(r(`sessions.sidebar.session.share.copyUrlError`))},mt=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`))}},ht=async()=>{if(!me)return;let e=_e.trim();if(e)try{await g(me.id,e),ge(null),be(``)}catch{Y.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},_t=async()=>{if(!me||xe)return;let e=me.id;ge(null),be(``),Se(!0);try{await _(e)}catch{Y.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{Se(!1)}},yt=(e,n)=>{C(e.id),b({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},St=e=>{(async()=>{try{await gt({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 Te(n,Be)})()},Ct=e=>{let t=la(e),n=_a(ze,t);if(!n)return ua(t)||t;let r=ha(n,ca(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},wt=e=>{x(e.id),t(!1)},Tt=Q.useMemo(()=>Ve?He.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Ve)?!0:e.buckets.some(t=>t.sessions.some(t=>va(t,e.project.label,Ve)))):He,[Ve,He]),Et=Q.useMemo(()=>Ve?Be.filter(e=>{let t=la(e);return va(e,_a(ze,t)?.label??``,Ve)}).sort((e,t)=>re(t)-re(e)):[],[Ve,ze,Be]),Dt=Q.useMemo(()=>Ve?ze.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Ve)).map(e=>({...e,sessionCount:Be.filter(t=>!sa(t)&&ga(e,ca(la(t)))).length})):[],[Ve,ze,Be]),Ot=Ve&&Et.length===0&&Dt.length===0,kt=ze.length>0?(0,$.jsxs)(Ue,{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,At=ze.find(e=>e.id===l)??null,jt=At?.isGitRepo?(0,$.jsx)(Ue,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>ot(At.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`node-tree`,className:`size-4`})}):null,Mt=(0,$.jsx)(Ue,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>W(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`})}),Nt=kt||Mt?(0,$.jsxs)($.Fragment,{children:[kt,jt,Mt]}):null,Pt=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`):``,Lt=Q.useMemo(()=>{if(!K)return[];if(K.kind===`project`){let e=K.project;return nr({gitRepository:e.isGitRepo,onNewSession:()=>{Ye(),yt(e,e.path)},onNewWorktree:()=>{Ye(),ot(e.id)},onSyncSessions:()=>{Ye(),St(e)},onEditProject:()=>{Ye(),R(e.id)},onCloseProject:()=>{Ye(),ue(e)}})}if(K.kind===`worktree`){let{project:e,worktree:t}=K;return Xn({onNewSession:()=>{Ye(),yt(e,t.path)},onDeleteWorktree:()=>{Ye(),Ee({project:e,worktree:t})}})}let e=K.session,t=!!e.share?.url;return tr({pinned:T.has(e.id),shared:t,onRename:()=>{Ye(),be(e.title?.trim()||r(`mobile.sessions.untitled`)),ge(e)},onTogglePin:()=>{Ye(),E(e.id)},onShare:t?void 0:()=>{Ye(),ft(e)},onCopyLink:t?()=>{let t=e.share?.url;Ye(),t&&pt(t)}:void 0,onUnshare:t?()=>{Ye(),mt(e.id)}:void 0,onArchive:()=>{Ye(),lt(e)},onDelete:()=>{Ye(),dt(e)}})},[K,Ye,lt,pt,dt,ot,ft,mt,T,yt,St,r,E]),Rt=Lt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Lt.map(e=>{let t=(0,$.jsx)(Ca,{icon:e.icon,label:pr(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,zt=(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:F,onChange:e=>I(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:X(`h-11 pl-9`,F&&`pr-10`)}),F?(0,$.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":r(`mobile.sessions.clearSearchAria`),onClick:()=>I(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsx)(vt,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:ze.length===0?(0,$.jsx)(Da,{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:()=>W(!0),children:[(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):Ot?(0,$.jsx)(Da,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Ve?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 pt-2`,children:[Et.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:Et.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Et.map((e,t)=>{let n=Fe.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)(wa,{session:e,active:d===e.id,indent:12,contextLabel:Ct(e),onSelect:()=>Ze(`session:${e.id}`,()=>nt(e)),longPressHandlers:Xe({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>Le(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,Dt.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:Dt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Dt.map((e,t)=>{let n=`project:${e.id}`,r=Xe({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:()=>Ze(n,()=>wt(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(ya,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(Sa,{className:`mr-2`,onClick:()=>ot(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:Tt.map((e,t)=>{let n=Ke(e),i=`project:${e.project.id}`,a=Xe({key:i,kind:`project`,project:e.project}),o=Ve?e.buckets.filter(t=>t.sessions.some(t=>va(t,e.project.label,Ve))):e.buckets,s=Ge(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:()=>Ze(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)(ya,{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}),Ae.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:Ae.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(xa,{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=>Fe.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(),Re(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Rn,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(Sa,{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?$e(e,t,aa):null,n.map(t=>{let n=qe(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Xe({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:()=>Ze(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)(ba,{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)(xa,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>Fe.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(),Re(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Rn,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?$e(e,t,aa):null]},t.key)})]})})()}):null]},e.project.id)})})}),(0,$.jsx)(ir,{open:U,onOpenChange:W,forceMobile:!0}),(0,$.jsx)(Yt,{open:ne,projectId:G,onOpenChange:e=>{ie(e),e||ae(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?p(n.sessionId,e):b({selectedProjectId:G,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(Xt,{open:!!K,title:Pt,onClose:Ye,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Rt}),(0,$.jsx)(Xt,{open:!!le,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>ue(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>ue(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Ue,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!le)return;let e=le;ue(null),w(e.id),Y.success(r(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:r(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:r(`mobile.projects.closeConfirmMessage`,{title:le?.label??``})})}),(0,$.jsx)(Xt,{open:!!me,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{xe||(ge(null),be(``))},footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:xe,onClick:()=>{ge(null),be(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Ue,{type:`button`,variant:`default`,className:`flex-1`,disabled:!_e.trim()||xe,onClick:()=>void ht(),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(),ht()},children:[(0,$.jsx)(xt,{value:_e,onChange:e=>be(e.target.value),autoFocus:!0,className:`h-12`,disabled:xe}),(0,$.jsxs)(Ue,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:xe,onClick:()=>void _t(),children:[xe?(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`)]})]})}),Ce?(0,$.jsx)(Ln,{open:!0,project:{id:Ce.project.id,path:Ce.project.path},worktree:Ce.worktree,onClose:()=>Ee(null),onDeleted:()=>H(e=>e+1)}):null,(0,$.jsx)(Gn,{open:L!==null,project:ze.find(e=>e.id===L)??null,onClose:()=>R(null),onWorktreesChanged:()=>H(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:Nt?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:Nt}):null}),zt]}):null:(0,$.jsx)(It,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:Nt,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:zt})},Da=e=>{let t=(0,Yr.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},Oa=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,ka=[{image:wr,titleKey:`assistants.shareWelcome.example.chat.title`,descriptionKey:`assistants.shareWelcome.example.chat.description`},{image:yr,titleKey:`assistants.shareWelcome.example.article.title`,descriptionKey:`assistants.shareWelcome.example.article.description`},{image:Sr,titleKey:`assistants.shareWelcome.example.note.title`,descriptionKey:`assistants.shareWelcome.example.note.description`}];function Aa(){let e=(0,Yr.c)(8),{t}=ee(),n;e[0]===t?n=e[1]:(n=t(`assistants.state.unavailable`),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 ja(e){let t=(0,Yr.c)(49),{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:Oa,alt:``})}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=r(`assistants.subtitle`),t[1]=r,t[2]=a);let o;t[3]===a?o=t[4]:(o=(0,$.jsx)(`span`,{className:`oc-mobile-assistant-guide-kicker`,children:a}),t[3]=a,t[4]=o);let s;t[5]===r?s=t[6]:(s=r(`assistants.state.instanceDisabled`),t[5]=r,t[6]=s);let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(`h2`,{className:`oc-mobile-assistant-guide-title`,children:s}),t[7]=s,t[8]=c);let l;t[9]===r?l=t[10]:(l=r(`assistants.onboarding.description`),t[9]=r,t[10]=l);let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(`p`,{className:`oc-mobile-assistant-guide-description`,children:l}),t[11]=l,t[12]=u);let d;t[13]!==o||t[14]!==c||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-heading`,children:[o,c,u]}),t[13]=o,t[14]=c,t[15]=u,t[16]=d):d=t[16];let f;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(Z,{name:`sparkling`,className:`size-[18px]`}),t[17]=f):f=t[17];let p;t[18]===r?p=t[19]:(p=r(`assistants.settings.instanceEnabled`),t[18]=r,t[19]=p);let m;t[20]!==n||t[21]!==p?(m=(0,$.jsxs)(Ue,{type:`button`,size:`lg`,className:`w-full`,onClick:n,children:[f,p]}),t[20]=n,t[21]=p,t[22]=m):m=t[22];let h;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Z,{name:`share-2`,className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),t[23]=h):h=t[23];let g;t[24]===r?g=t[25]:(g=r(`assistants.shareWelcome.title`),t[24]=r,t[25]=g);let _;t[26]===g?_=t[27]:(_=(0,$.jsx)(`h3`,{id:`assistant-share-guide-title`,className:`typography-ui-label font-semibold text-foreground`,children:g}),t[26]=g,t[27]=_);let v;t[28]===r?v=t[29]:(v=r(`assistants.shareWelcome.description`),t[28]=r,t[29]=v);let y;t[30]===v?y=t[31]:(y=(0,$.jsx)(`p`,{className:`mt-1 typography-meta leading-5 text-muted-foreground`,children:v}),t[30]=v,t[31]=y);let b;t[32]!==_||t[33]!==y?(b=(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-share-heading`,children:[h,(0,$.jsxs)(`div`,{className:`min-w-0`,children:[_,y]})]}),t[32]=_,t[33]=y,t[34]=b):b=t[34];let x;t[35]===r?x=t[36]:(x=r(`assistants.shareWelcome.examplesAria`),t[35]=r,t[36]=x);let S;t[37]===r?S=t[38]:(S=ka.map((e,t)=>(0,$.jsxs)(`article`,{className:`oc-mobile-assistant-guide-step`,children:[(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-step-image`,children:[(0,$.jsx)(`img`,{src:e.image,alt:``}),(0,$.jsx)(`span`,{"aria-hidden":`true`,children:t+1})]}),(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[37]=r,t[38]=S);let C;t[39]!==x||t[40]!==S?(C=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-steps`,"aria-label":x,children:S}),t[39]=x,t[40]=S,t[41]=C):C=t[41];let w;t[42]!==b||t[43]!==C?(w=(0,$.jsxs)(`section`,{className:`oc-mobile-assistant-guide-share`,"aria-labelledby":`assistant-share-guide-title`,children:[b,C]}),t[42]=b,t[43]=C,t[44]=w):w=t[44];let T;return t[45]!==m||t[46]!==w||t[47]!==d?(T=(0,$.jsxs)(`article`,{className:`oc-mobile-assistant-guide`,children:[i,(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-body`,children:[d,m,w]})]}),t[45]=m,t[46]=w,t[47]=d,t[48]=T):T=t[48],T}function Ma({assistantID:e,displayName:t,avatarEmoji:n,modeLabel:r,summary:i,enabled:a,editLabel:o,deleteLabel:s,onOpen:c,onEdit:l,onDelete:u}){let[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),h=Q.useRef(null);h.current||=dn({onPressedKeyChange:t=>m(t===e)}),Q.useEffect(()=>()=>h.current?.reset(),[]);let g=P(()=>{h.current?.consumeClick(e)||d||c()}),_=P(()=>{f(!1),l()}),v=P(()=>{f(!1),u()}),y=P(()=>{m(!1),f(!0)}),b=P(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=P(e=>{h.current?.move(e.pointerId,e.clientX,e.clientY)}),S=P(e=>{h.current?.end(e.pointerId)}),C=P(e=>{h.current?.cancel(e.pointerId)}),w=P(t=>{t.preventDefault(),t.stopPropagation(),h.current?.openFromContextMenu(e,y)});return(0,$.jsxs)(Ar,{open:d,onOpenChange:f,children:[(0,$.jsx)(On,{"data-mobile-press-surface":`soft`,className:X(`oc-mobile-assistant-card-shell`,p&&`bg-interactive-hover`),children:(0,$.jsxs)(Er,{render:(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-surface-trigger":!0,"data-mobile-press-feedback":`none`,className:X(`oc-mobile-assistant-card`,!a&&`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)(He,{name:e,emoji:n,size:n?40:38,label:t})}),(0,$.jsxs)(`span`,{className:`oc-mobile-assistant-card-content min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`oc-mobile-assistant-card-header`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-entity-title oc-mobile-assistant-name min-w-0 flex-1 truncate font-semibold text-foreground`,children:t}),(0,$.jsx)(`span`,{className:`oc-mobile-entity-meta oc-mobile-assistant-mode shrink-0 text-muted-foreground`,children:r})]}),(0,$.jsx)(`span`,{className:`oc-mobile-assistant-summary text-muted-foreground`,children:i})]})]})}),(0,$.jsxs)(Or,{className:`min-w-[10rem]`,children:[(0,$.jsxs)(kr,{className:`min-h-10 px-3`,onClick:_,children:[(0,$.jsx)(Z,{name:`edit`,className:`size-4`}),o]}),(0,$.jsx)(Dr,{}),(0,$.jsxs)(kr,{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`}),s]})]})]})}function Na(e){let t=(0,Yr.c)(104),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=ee(),o=Wt(),s=Le(),c=ze(),l=Be(Pa),[u,d]=Q.useState(null),f;t[0]===n?f=t[1]:(f=()=>n(),t[0]=n,t[1]=f);let p=P(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=P(m),g;t[5]===r?g=t[6]:(g=e=>r(e),t[5]=r,t[6]=g);let _=P(g),v;t[7]===o?v=t[8]:(v=e=>{Ve(e,o?{openMobileSettings:o.openSettings}:void 0)},t[7]=o,t[8]=v);let y=P(v),b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{d(e)},t[9]=b):b=t[9];let x=P(b),S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{e||d(null)},t[10]=S):S=t[10];let C=P(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)(On,{className:`oc-mobile-assistant-loading`,children:(0,$.jsx)(Aa,{})}),t[17]=e):e=t[17];let n;return t[18]!==i||t[19]!==T?(n=(0,$.jsx)(Dn,{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||t[29]!==a){let e;t[31]!==k||t[32]!==D||t[33]!==y||t[34]!==_||t[35]!==x||t[36]!==a?(e=e=>{let t=L(e.name),n=t.displayName||e.name,r=e.mode===`stateless`?a(`assistants.mode.stateless`):a(`assistants.mode.continuous`),i=e.defaultPrompt.trim()||(e.mode===`stateless`?a(`assistants.conversation.statelessHint`):a(`assistants.conversation.continuousHint`));return(0,$.jsx)(Ma,{assistantID:e.id,displayName:n,avatarEmoji:t.avatarEmoji??void 0,modeLabel:r,summary:i,enabled:e.enabled,editLabel:D,deleteLabel:k,onOpen:()=>_(e.id),onEdit:()=>y(e.id),onDelete:()=>x(e)},e.id)},t[31]=k,t[32]=D,t[33]=y,t[34]=_,t[35]=x,t[36]=a,t[37]=e):e=t[37],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]=a,t[30]=n}else n=t[30];let r;t[38]!==e||t[39]!==n?(r=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-catalog`,role:`listbox`,"aria-label":e,children:n}),t[38]=e,t[39]=n,t[40]=r):r=t[40];let o=u!==null,s;t[41]!==u||t[42]!==C||t[43]!==o?(s=(0,$.jsx)(jr,{assistant:u,open:o,onOpenChange:C}),t[41]=u,t[42]=C,t[43]=o,t[44]=s):s=t[44];let l;return t[45]!==i||t[46]!==T||t[47]!==r||t[48]!==s?(l=(0,$.jsxs)(Dn,{title:T,className:i,surface:!1,scrollsWithPage:!0,children:[r,s]}),t[45]=i,t[46]=T,t[47]=r,t[48]=s,t[49]=l):l=t[49],l}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[50]===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[50]=e):e=t[50];let n;t[51]===a?n=t[52]:(n=a(`assistants.onboarding.title`),t[51]=a,t[52]=n);let r;t[53]===n?r=t[54]:(r=(0,$.jsx)(`h2`,{children:n}),t[53]=n,t[54]=r);let o;t[55]===a?o=t[56]:(o=a(`assistants.onboarding.description`),t[55]=a,t[56]=o);let s;t[57]===o?s=t[58]:(s=(0,$.jsx)(`p`,{children:o}),t[57]=o,t[58]=s);let c;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Z,{name:`add`,className:`size-[18px]`}),t[59]=c):c=t[59];let l;t[60]===a?l=t[61]:(l=a(`assistants.onboarding.action`),t[60]=a,t[61]=l);let u;t[62]!==h||t[63]!==l?(u=(0,$.jsxs)(Ue,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:h,children:[c,l]}),t[62]=h,t[63]=l,t[64]=u):u=t[64];let d;t[65]!==r||t[66]!==s||t[67]!==u?(d=(0,$.jsxs)(On,{className:`oc-mobile-assistant-onboarding`,children:[e,r,s,u]}),t[65]=r,t[66]=s,t[67]=u,t[68]=d):d=t[68];let f;return t[69]!==i||t[70]!==T||t[71]!==d?(f=(0,$.jsx)(Dn,{title:T,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:d}),t[69]=i,t[70]=T,t[71]=d,t[72]=f):f=t[72],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[73]!==a||t[74]!==j||t[75]!==A?(N=a(j?`assistants.state.unavailable`:A?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[73]=a,t[74]=j,t[75]=A,t[76]=N):N=t[76];let F=N;if(M&&!j){let e;t[77]===p?e=t[78]:(e=(0,$.jsx)(ja,{onEnable:p}),t[77]=p,t[78]=e);let n;return t[79]!==i||t[80]!==T||t[81]!==e?(n=(0,$.jsx)(Dn,{title:T,className:i,surface:!1,scrollsWithPage:!0,children:e}),t[79]=i,t[80]=T,t[81]=e,t[82]=n):n=t[82],n}let te;t[83]===T?te=t[84]:(te=(0,$.jsx)(`span`,{className:`oc-mobile-page-section-label`,children:T}),t[83]=T,t[84]=te);let I=A?`cloud-off`:`sparkling`,R;t[85]===I?R=t[86]:(R=(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[85]=I,t[86]=R);let z;t[87]===F?z=t[88]:(z=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:F}),t[87]=F,t[88]=z);let B;t[89]!==a||t[90]!==j||t[91]!==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[89]=a,t[90]=j,t[91]=A,t[92]=B):B=t[92];let V;t[93]!==R||t[94]!==z||t[95]!==B?(V=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[R,z,B]}),t[93]=R,t[94]=z,t[95]=B,t[96]=V):V=t[96];let H;t[97]!==te||t[98]!==V?(H=(0,$.jsx)(jn,{label:te,cardClassName:`oc-mobile-assistant-state-card`,children:V}),t[97]=te,t[98]=V,t[99]=H):H=t[99];let U;return t[100]!==i||t[101]!==T||t[102]!==H?(U=(0,$.jsx)(Dn,{title:T,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:H}),t[100]=i,t[101]=T,t[102]=H,t[103]=U):U=t[103],U}function Pa(e){return e.requestCreate}var Fa=[{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 Ia(e){let t=(0,Yr.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=P(o),c;t[2]!==n||t[3]!==r?(c=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Fa.findIndex(e=>e.id===n),i=Fa[e.key===`Home`?0:e.key===`End`?Fa.length-1:(t+(e.key===`ArrowRight`?1:-1)+Fa.length)%Fa.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=P(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=Fa.map(e=>{let t=e.id===n,r=a(e.labelKey);return(0,$.jsxs)(Ue,{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,"data-mobile-press-feedback":`none`,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:scale-[0.985]`,`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)(Mn,{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}function La(e){let t=(0,Yr.c)(23),{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=P(()=>h?.onBack());Qt({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=P(j),N;t[6]===c?N=t[7]:(N=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[6]=c,t[7]=N);let F=h?!0:void 0,te=h?!0:void 0,I;t[8]!==p||t[9]!==u||t[10]!==n||t[11]!==b?(I=Fa.map(e=>{let t=b.has(e.id);return(0,$.jsx)(`section`,{id:`mobile-tabpanel-${e.id}`,role:`tabpanel`,"aria-labelledby":`mobile-tab-${e.id}`,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)(Ra,{tab:e.id,icon:e.icon}):null},e.id)}),t[8]=p,t[9]=u,t[10]=n,t[11]=b,t[12]=I):I=t[12];let L;t[13]!==w||t[14]!==I||t[15]!==F||t[16]!==te?(L=(0,$.jsx)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":F,inert:te,className:`flex h-full min-h-0 flex-1 flex-col`,children:I}),t[13]=w,t[14]=I,t[15]=F,t[16]=te,t[17]=L):L=t[17];let R=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||d?!0:void 0,inert:h||d?!0:void 0,children:(0,$.jsx)(Ia,{activeTab:p,onTabChange:M})}):null,z=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)}),B;return t[18]!==L||t[19]!==R||t[20]!==z||t[21]!==N?(B=(0,$.jsxs)(`div`,{className:N,children:[L,R,z]}),t[18]=L,t[19]=R,t[20]=z,t[21]=N,t[22]=B):B=t[22],B}function Ra(e){let t=(0,Yr.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=Fa.find(e=>e.id===n)??Fa[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 za={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)`}},Ba=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 Va({project:e,expanded:t,embedded:n=!1,onToggle:r,onOpenActions:i,className:a}){let{t:o}=ee(),[s,c]=Q.useState(!1),l=Q.useRef(null);l.current||=dn({onPressedKeyChange:t=>c(t===e.id)}),Q.useEffect(()=>()=>l.current?.reset(),[]);let u=P(()=>{l.current?.consumeClick(e.id)||r(e)}),d=P(()=>i(e)),f=P(t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||l.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{c(!1),i(e)}})}),p=P(e=>{l.current?.move(e.pointerId,e.clientX,e.clientY)}),m=P(e=>{l.current?.end(e.pointerId)}),h=P(e=>{l.current?.cancel(e.pointerId)}),g=P(t=>{t.preventDefault(),t.stopPropagation(),l.current?.openFromContextMenu(e.id,()=>{c(!1),i(e)})}),_=e.sessionCount===1?o(`mobile.sessions.project.sessionsSingle`):o(`mobile.sessions.project.sessionsPlural`,{count:e.sessionCount}),v=Ba(e.path),y=(0,$.jsxs)(`article`,{"data-mobile-press-surface":`soft`,className:X(`oc-mobile-project-card relative flex items-stretch overflow-hidden rounded-[var(--oc-mobile-surface-radius)]`,s&&`bg-interactive-hover`,a),children:[(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-surface-trigger":!0,"data-mobile-press-feedback":`none`,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:u,onPointerDown:f,onPointerMove:p,onPointerUp:m,onPointerCancel:h,onContextMenu:g,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:za[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: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":o(`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:_}),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,v?(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:v})]}):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`)})]}),(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-project-action self-center rounded-full text-muted-foreground`,"aria-label":o(`sessions.sidebar.project.actions.projectMenu`),onClick:d,children:(0,$.jsx)(Z,{name:`more-2`,className:`size-4`})})]});return n?y:(0,$.jsx)(On,{asChild:!0,children:y})}var Ha=({hasPendingQuestion:e,hasPendingPermission:t,running:n,unread:r})=>e?`question`:t?`permission`:n?`running`:r?`completed-unread`:`idle`,Ua=10,Wa=`oc:mobile-session-row-revealed`,Ga=e=>{window.dispatchEvent(new CustomEvent(Wa,{detail:e}))};function Ka({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}){let{t:f}=ee(),[p,m]=Q.useState(0),[h,g]=Q.useState(!1),_=Q.useRef(null),v=Q.useRef(!1),y=Q.useRef(null),b=Q.useRef(null);b.current||=dn(),Q.useEffect(()=>()=>b.current?.reset(),[]),Q.useEffect(()=>{let t=t=>{t.detail!==e.id&&m(0)};return window.addEventListener(Wa,t),()=>window.removeEventListener(Wa,t)},[e.id]),Q.useEffect(()=>{m(0)},[e.id]);let x=P(()=>m(0)),S=p!==0,C=P(t=>{if(t.button!==0||t.pointerType!==`touch`&&t.pointerType!==`pen`)return;let n=y.current?.offsetWidth??0;n<=0||(_.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startOffset:p,actionWidth:n,intent:`pending`},v.current=!1,b.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{l(e)}}))}),w=P(t=>{let n=_.current;if(!n||n.pointerId!==t.pointerId)return;let r=t.clientX-n.startX,i=t.clientY-n.startY;if(b.current?.move(t.pointerId,t.clientX,t.clientY),n.intent===`pending`){let a=Math.abs(r),o=Math.abs(i);if(o>Ua&&o>a){n.intent=`vertical`,_.current=null,b.current?.cancel(t.pointerId);return}if(a>Ua&&a>o){n.intent=`horizontal`,g(!0),v.current=!0,b.current?.cancel(t.pointerId);try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}Ga(e.id)}}if(n.intent!==`horizontal`)return;t.preventDefault();let a=Math.max(-n.actionWidth,Math.min(0,n.startOffset+r));m(a)}),T=P(e=>{let t=_.current;b.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(_.current=null,t.intent===`horizontal`&&(g(!1),m(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),E=P(e=>{let t=_.current;_.current=null,b.current?.cancel(e.pointerId),g(!1),m(t?.startOffset??0)}),D=P(()=>{if(!b.current?.consumeClick(e.id)){if(v.current){v.current=!1;return}if(p!==0){x();return}Ga(e.id),o(e)}}),O=P(t=>{t.preventDefault(),t.stopPropagation(),b.current?.openFromContextMenu(e.id,()=>{l(e)})}),k=P(()=>{x(),s(e)}),A=P(()=>{x(),c(e)}),j=P(()=>l(e)),M=P(()=>a?.()),N=e.pinned?f(`sessions.sidebar.session.menu.unpin`):f(`sessions.sidebar.session.menu.pin`),F=u??Ha({hasPendingQuestion:!1,hasPendingPermission:!1,running:!1,unread:!!e.unread}),te=F===`question`?f(`sessions.sidebar.session.status.questionRequired`):F===`permission`?f(`sessions.sidebar.session.status.permissionRequired`):F===`running`?f(`sessions.sidebar.session.status.active`):F===`completed-unread`?f(`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:D,onPointerDown:()=>void 0,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium text-foreground`,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 overflow-hidden`,d),children:[(0,$.jsxs)(`div`,{ref:y,className:X(`oc-mobile-session-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,h?`transition-none`:`transition-transform duration-150 ease-out`,!S&&`invisible pointer-events-none`),style:{transform:`translate3d(calc(var(--oc-mobile-session-actions-width) + ${p}px), 0, 0)`,willChange:p===0?void 0:`transform`},"aria-hidden":!S,children:[(0,$.jsxs)(Ue,{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":N,tabIndex:S?0:-1,onClick:k,children:[(0,$.jsx)(Z,{name:e.pinned?`unpin`:`pushpin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:N})]}),(0,$.jsxs)(Ue,{type:`button`,variant:`destructive`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 px-1`,"aria-label":f(`sessions.sidebar.bulkActions.archive`),tabIndex:S?0:-1,onClick:A,children:[(0,$.jsx)(Z,{name:`archive`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:f(`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`,h?`transition-none`:`transition-[transform,background-color] duration-150`,e.archived&&`opacity-55`),"data-dragging":h?`true`:void 0,style:{transform:`translate3d(${p}px, 0, 0)`,willChange:p===0?void 0:`transform`},children:[n&&a?(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,size:`icon`,className:`min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":f(r?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:M,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:D,onPointerDown:C,onPointerMove:w,onPointerUp:T,onPointerCancel:E,onContextMenu:O,children:[(0,$.jsx)(`span`,{className:`oc-mobile-session-status shrink-0`,"data-session-status":F,"aria-hidden":!te||void 0,"aria-label":te,title:te,children:F===`running`?(0,$.jsx)(Rn,{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:e.title}),e.pinned?(0,$.jsx)(Z,{name:`pushpin`,className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}):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: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)(Ue,{type:`button`,variant:`ghost`,size:`icon`,className:`mr-1 min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":f(`sessions.sidebar.session.menu.label`),onClick:j,children:(0,$.jsx)(Z,{name:`more-2`,className:`size-3.5`})})]})]})}var qa=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e)),Ja=(e,t)=>e.filter(e=>e.kind!==`pagination`&&qa(t,e.title,e.subtitle,e.id)),Ya=(e,t)=>{if(qa(t,e.name,e.path))return{...e,sessions:e.sessions.filter(e=>e.kind!==`pagination`)};let n=Ja(e.sessions,t);return n.length>0?{...e,sessions:n}:null},Xa=(e,t)=>{let n=t.trim().toLowerCase();return n?e.flatMap(e=>{if(qa(n,e.name,e.path))return[{...e,worktrees:[]}];let t=e.worktrees.flatMap(e=>{let t=Ya(e,n);return t?[t]:[]});return t.length>0?[{...e,worktrees:t}]:[]}):e},Za=10,Qa=`oc:mobile-worktree-row-revealed`,$a=e=>{window.dispatchEvent(new CustomEvent(Qa,{detail:e}))};function eo(e){let t=(0,Yr.c)(10),n=fe(e.session.id),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={bootstrap:!1},t[0]=r):r=t[0];let i=Oe(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=xe(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=Ha({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)(Ka,{...e,indicator:d}),t[7]=d,t[8]=e,t[9]=f):f=t[9],f}function to(e){let t=(0,Yr.c)(8),{sessions:n,onSelectSession:r,onPinSession:i,onArchiveSession:a,onOpenSessionActions:o}=e,s;t[0]!==a||t[1]!==o||t[2]!==i||t[3]!==r||t[4]!==n?(s=n.map((e,t)=>{let s=e.kind===`pagination`&&n[t+1]?.kind===`pagination`,c=e.kind===`pagination`?Ka:eo;return(0,$.jsx)(c,{session:e,paginationContinues:s,onSelect:r,onPin:i,onArchive:a,onOpenActions:o},e.id)}),t[0]=a,t[1]=o,t[2]=i,t[3]=r,t[4]=n,t[5]=s):s=t[5];let c;return t[6]===s?c=t[7]:(c=(0,$.jsx)($.Fragment,{children:s}),t[6]=s,t[7]=c),c}function no(e){let t=(0,Yr.c)(22),{icon:n,label:r,count:i,expanded:a,onToggle:o,actions:s}=e,{t:c}=ee(),l;t[0]===n?l=t[1]:(l=(0,$.jsx)(`span`,{className:`oc-mobile-group-label-icon`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=l);let u;t[2]===r?u=t[3]:(u=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left typography-ui-label font-semibold text-foreground`,children:r}),t[2]=r,t[3]=u);let d;t[4]!==i||t[5]!==c?(d=typeof i==`number`?(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:i===1?c(`mobile.sessions.project.sessionsSingle`):c(`mobile.sessions.project.sessionsPlural`,{count:i})}):null,t[4]=i,t[5]=c,t[6]=d):d=t[6];let f;t[7]!==a||t[8]!==o?(f=o?(0,$.jsx)(Z,{name:`arrow-down-s`,className:X(`size-3.5 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,a?`rotate-0`:`-rotate-90`)}):null,t[7]=a,t[8]=o,t[9]=f):f=t[9];let p;t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f?(p=(0,$.jsxs)($.Fragment,{children:[l,u,d,f]}),t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p):p=t[14];let m=p,h;t[15]!==m||t[16]!==a||t[17]!==o?(h=o?(0,$.jsx)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-group-label-trigger`,"aria-expanded":a,onClick:o,children:m}):(0,$.jsx)(`div`,{className:`oc-mobile-group-label-trigger`,children:m}),t[15]=m,t[16]=a,t[17]=o,t[18]=h):h=t[18];let g;return t[19]!==s||t[20]!==h?(g=(0,$.jsxs)(`div`,{className:`oc-mobile-group-label`,children:[h,s]}),t[19]=s,t[20]=h,t[21]=g):g=t[21],g}function ro({project:e,worktree:t,expanded:n,onToggle:r,onNewSession:i,onOpenActions:a,onDelete:o}){let{t:s}=ee(),c=`${e.id}::${t.id}`,l=!!(i||o),u=!!a,d=Number(!!i)+Number(!!o),[f,p]=Q.useState(0),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),v=Q.useRef(null),y=Q.useRef(!1),b=Q.useRef(null),x=Q.useRef(null);x.current||=dn({onPressedKeyChange:e=>h(e===c)}),Q.useEffect(()=>()=>x.current?.reset(),[]),Q.useEffect(()=>{let e=e=>{e.detail!==c&&p(0)};return window.addEventListener(Qa,e),()=>window.removeEventListener(Qa,e)},[c]),Q.useEffect(()=>{p(0)},[c]);let S=P(()=>p(0)),C=f!==0,w=P(n=>{if(n.button===0&&(n.pointerType===`touch`||n.pointerType===`pen`)){if(l){let e=b.current?.offsetWidth??0;e>0&&(v.current={pointerId:n.pointerId,startX:n.clientX,startY:n.clientY,startOffset:f,actionWidth:e,intent:`pending`},y.current=!1)}u&&x.current?.start({pointerId:n.pointerId,key:c,clientX:n.clientX,clientY:n.clientY,onTrigger:()=>{h(!1),a?.(e,t)}})}}),T=P(e=>{let t=v.current;if(!t||t.pointerId!==e.pointerId){x.current?.move(e.pointerId,e.clientX,e.clientY);return}let n=e.clientX-t.startX,r=e.clientY-t.startY;if(x.current?.move(e.pointerId,e.clientX,e.clientY),t.intent===`pending`){let i=Math.abs(n),a=Math.abs(r);if(a>Za&&a>i){t.intent=`vertical`,v.current=null,x.current?.cancel(e.pointerId);return}if(i>Za&&i>a){t.intent=`horizontal`,_(!0),y.current=!0,x.current?.cancel(e.pointerId);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}$a(c)}}if(t.intent!==`horizontal`)return;e.preventDefault();let i=Math.max(-t.actionWidth,Math.min(0,t.startOffset+n));p(i)}),E=P(e=>{let t=v.current;x.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(v.current=null,t.intent===`horizontal`&&(_(!1),p(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),D=P(e=>{let t=v.current;v.current=null,x.current?.cancel(e.pointerId),_(!1),p(t?.startOffset??0)}),O=P(()=>{if(!x.current?.consumeClick(c)){if(y.current){y.current=!1;return}if(f!==0){S();return}r()}}),k=P(n=>{u&&(n.preventDefault(),n.stopPropagation(),x.current?.openFromContextMenu(c,()=>{h(!1),a?.(e,t)}))}),A=P(()=>{S(),i?.(e,t)}),j=P(()=>{S(),o?.(e,t)}),M=P(()=>a?.(e,t)),N=(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 typography-ui-label font-semibold text-foreground`,children:t.name}),(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:t.sessionCount===1?s(`mobile.sessions.project.sessionsSingle`):s(`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:[l?(0,$.jsxs)(`div`,{ref:b,className:X(`oc-mobile-worktree-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:{width:`calc(${d} * var(--oc-mobile-worktree-action-width))`,transform:`translate3d(calc(100% + ${f}px), 0, 0)`,willChange:f===0?void 0:`transform`},"aria-hidden":!C,children:[i?(0,$.jsxs)(Ue,{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":s(`mobile.sessions.newSessionAria`),tabIndex:C?0:-1,onClick:A,children:[(0,$.jsx)(Z,{name:`add`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:s(`sessions.sidebar.project.actions.newSession`)})]}):null,o?(0,$.jsxs)(Ue,{type:`button`,variant:`destructive`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 px-1`,"aria-label":s(`mobile.projectEdit.deleteWorktreeAria`,{label:t.name}),tabIndex:C?0:-1,onClick:j,children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:s(`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`,g?`transition-none`:`transition-transform duration-150`),style:{transform:`translate3d(${f}px, 0, 0)`,willChange:f===0?void 0:`transform`},"data-pressed":m?`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:O,onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:D,onContextMenu:k,style:{touchAction:`pan-y`},children:N}),u?(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-worktree-more rounded-full text-muted-foreground`,"aria-label":s(`agentManager.detail.actions.worktreeActionsAria`),onClick:M,children:(0,$.jsx)(Z,{name:`more-2`,className:`size-3.5`})}):null]})]})}function io(e){let t=(0,Yr.c)(128),{projects:n,pinnedSessions:r,onAddProject:i,onNewSession:a,onScanQr:o,onSwitchInstance:s,onToggleProject:c,onOpenProjectActions:l,onToggleWorktree:u,onNewWorktreeSession:d,onOpenWorktreeActions:f,onDeleteWorktree:p,onSelectSession:m,onPinSession:h,onArchiveSession:g,onOpenSessionActions:_,className:v}=e,{t:y}=ee(),[b,x]=Q.useState(!0),[S,C]=Q.useState(!1),[w,T]=Q.useState(!1),[E,D]=Q.useState(``),O;t[0]===E?O=t[1]:(O=E.trim().toLowerCase(),t[0]=E,t[1]=O);let k=O,A=k.length>0,j;t[2]!==k||t[3]!==n?(j=Xa(n,k),t[2]=k,t[3]=n,t[4]=j):j=t[4];let M=j,N=P(i),F=P(a),te;t[5]===o?te=t[6]:(te=()=>o?.(),t[5]=o,t[6]=te);let I=P(te),L;t[7]===s?L=t[8]:(L=()=>s?.(),t[7]=s,t[8]=L);let R=P(L),z;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>T(e),t[9]=z):z=t[9];let B=P(z),V;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{D(``),C(!1)},t[10]=V):V=t[10];let H=P(V),U;t[11]!==H||t[12]!==S?(U=()=>{if(S){H();return}C(!0)},t[11]=H,t[12]=S,t[13]=U):U=t[13];let W=P(U),ne;t[14]!==H||t[15]!==c?(ne=e=>{H(),e.expanded||c(e)},t[14]=H,t[15]=c,t[16]=ne):ne=t[16];let re=P(ne),ie;t[17]!==H||t[18]!==c||t[19]!==u?(ie=(e,t)=>{H(),e.expanded||c(e),t.expanded||u(e,t)},t[17]=H,t[18]=c,t[19]=u,t[20]=ie):ie=t[20];let G=P(ie),ae;t[21]!==H||t[22]!==m?(ae=e=>{H(),m(e)},t[21]=H,t[22]=m,t[23]=ae):ae=t[23];let K=P(ae),oe;t[24]===v?oe=t[25]:(oe=X(`relative isolate mx-auto flex w-full max-w-[26rem] flex-col gap-5`,v),t[24]=v,t[25]=oe);let se;t[26]===y?se=t[27]:(se=y(`mobile.sessions.section.projects`),t[26]=y,t[27]=se);let q;t[28]!==S||t[29]!==y?(q=y(S?`mobile.sessions.clearSearchAria`:`mobile.sessions.searchAria`),t[28]=S,t[29]=y,t[30]=q):q=t[30];let ce=S?`close`:`search`,le;t[31]===ce?le=t[32]:(le=(0,$.jsx)(Z,{name:ce,className:`size-5`}),t[31]=ce,t[32]=le);let ue;t[33]!==W||t[34]!==S||t[35]!==q||t[36]!==le?(ue=(0,$.jsx)(Ue,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":q,"aria-expanded":S,onClick:W,children:le}),t[33]=W,t[34]=S,t[35]=q,t[36]=le,t[37]=ue):ue=t[37];let de;t[38]===y?de=t[39]:(de=y(`mobile.projects.menu.label`),t[38]=y,t[39]=de);let fe=w?`rotate-45`:`rotate-0`,pe;t[40]===fe?pe=t[41]:(pe=X(`size-5 transition-transform duration-150 motion-reduce:transition-none`,fe),t[40]=fe,t[41]=pe);let me;t[42]===pe?me=t[43]:(me=(0,$.jsx)(Z,{name:`add`,className:pe}),t[42]=pe,t[43]=me);let he;t[44]!==de||t[45]!==me?(he=(0,$.jsx)(Mt,{asChild:!0,children:(0,$.jsx)(Ue,{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":de,children:me})}),t[44]=de,t[45]=me,t[46]=he):he=t[46];let ge;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(Z,{name:`chat-new`,className:`size-4`}),t[47]=ge):ge=t[47];let _e;t[48]===y?_e=t[49]:(_e=y(`mobile.projects.menu.newChat`),t[48]=y,t[49]=_e);let ve;t[50]!==F||t[51]!==_e?(ve=(0,$.jsxs)(Nt,{className:`min-h-11`,onSelect:F,children:[ge,_e]}),t[50]=F,t[51]=_e,t[52]=ve):ve=t[52];let ye;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(Z,{name:`folder`,className:`size-4`}),t[53]=ye):ye=t[53];let be;t[54]===y?be=t[55]:(be=y(`mobile.projects.menu.newProject`),t[54]=y,t[55]=be);let xe;t[56]!==N||t[57]!==be?(xe=(0,$.jsxs)(Nt,{className:`min-h-11`,onSelect:N,children:[ye,be]}),t[56]=N,t[57]=be,t[58]=xe):xe=t[58];let Se;t[59]!==I||t[60]!==o||t[61]!==y?(Se=o?(0,$.jsxs)(Nt,{className:`min-h-11`,onSelect:I,children:[(0,$.jsx)(Z,{name:`scan-2`,className:`size-4`}),y(`mobile.projects.menu.scanQr`)]}):null,t[59]=I,t[60]=o,t[61]=y,t[62]=Se):Se=t[62];let Ce;t[63]!==R||t[64]!==s||t[65]!==y?(Ce=s?(0,$.jsxs)(Nt,{className:`min-h-11`,onSelect:R,children:[(0,$.jsx)(Z,{name:`server`,className:`size-4`}),y(`mobile.projects.menu.switchInstance`)]}):null,t[63]=R,t[64]=s,t[65]=y,t[66]=Ce):Ce=t[66];let J;t[67]!==ve||t[68]!==xe||t[69]!==Se||t[70]!==Ce?(J=(0,$.jsxs)(At,{align:`end`,side:`bottom`,className:`min-w-44`,children:[ve,xe,Se,Ce]}),t[67]=ve,t[68]=xe,t[69]=Se,t[70]=Ce,t[71]=J):J=t[71];let we;t[72]!==B||t[73]!==w||t[74]!==he||t[75]!==J?(we=(0,$.jsxs)(jt,{open:w,onOpenChange:B,children:[he,J]}),t[72]=B,t[73]=w,t[74]=he,t[75]=J,t[76]=we):we=t[76];let Te;t[77]!==ue||t[78]!==we?(Te=(0,$.jsxs)($.Fragment,{children:[ue,we]}),t[77]=ue,t[78]=we,t[79]=Te):Te=t[79];let Ee;t[80]!==se||t[81]!==Te?(Ee=(0,$.jsx)(Tn,{title:se,trailing:Te}),t[80]=se,t[81]=Te,t[82]=Ee):Ee=t[82];let De;t[83]!==H||t[84]!==S||t[85]!==E||t[86]!==y?(De=S?(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:E,placeholder:y(`mobile.sessions.search.placeholder`),"aria-label":y(`mobile.sessions.searchAria`),className:X(`h-11 rounded-full pl-9`,E&&`pr-10`),onChange:e=>D(e.target.value),onKeyDown:e=>{e.key===`Escape`&&H()}}),E?(0,$.jsx)(Ue,{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":y(`mobile.sessions.clearSearchAria`),onClick:()=>D(``),children:(0,$.jsx)(Z,{name:`close`,className:`size-4`})}):null]}):null,t[83]=H,t[84]=S,t[85]=E,t[86]=y,t[87]=De):De=t[87];let Oe;t[88]!==g||t[89]!==_||t[90]!==h||t[91]!==m||t[92]!==b||t[93]!==r||t[94]!==A||t[95]!==y?(Oe=!A&&r.length>0?(0,$.jsx)(On,{children:(0,$.jsx)(jn,{ariaLabel:y(`mobile.sessions.section.pinned`),label:(0,$.jsx)(no,{icon:(0,$.jsx)(Z,{name:`pushpin`,className:`size-3.5`}),label:y(`mobile.sessions.section.pinned`),count:r.length,expanded:b,onToggle:()=>x(oo)}),children:b?(0,$.jsx)(to,{sessions:r,onSelectSession:m,onPinSession:h,onArchiveSession:g,onOpenSessionActions:_}):null})}):null,t[88]=g,t[89]=_,t[90]=h,t[91]=m,t[92]=b,t[93]=r,t[94]=A,t[95]=y,t[96]=Oe):Oe=t[96];let ke;t[97]!==N||t[98]!==re||t[99]!==G||t[100]!==K||t[101]!==g||t[102]!==p||t[103]!==d||t[104]!==l||t[105]!==_||t[106]!==f||t[107]!==h||t[108]!==m||t[109]!==c||t[110]!==u||t[111]!==n.length||t[112]!==A||t[113]!==y||t[114]!==M?(ke=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:y(`mobile.sessions.empty.noProjectsTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:y(`mobile.sessions.empty.noProjectsDescription`)}),(0,$.jsxs)(Ue,{type:`button`,size:`lg`,className:`mt-4 min-h-10 rounded-full px-5`,onClick:N,children:[(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`}),y(`sessions.sidebar.header.actions.addProject`)]})]}):A&&M.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:y(`mobile.sessions.empty.searchTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:y(`mobile.sessions.empty.searchDescription`)})]}):M.map(e=>{let t=A||e.expanded,n=e.worktrees.find(ao)??(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)(On,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":e.name,children:[(0,$.jsx)(Va,{project:e,expanded:t,embedded:!0,onToggle:()=>A?re(e):c(e),onOpenActions:()=>l(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)(to,{sessions:i,onSelectSession:A?K:m,onPinSession:h,onArchiveSession:g,onOpenSessionActions:_})}):null,r.map(t=>{let n=A||!!t.expanded;return(0,$.jsx)(jn,{className:`oc-mobile-worktree-group`,ariaLabel:t.name,label:(0,$.jsx)(ro,{project:e,worktree:t,expanded:n,onToggle:()=>A?G(e,t):u(e,t),onNewSession:d,onOpenActions:A?void 0:f,onDelete:A?void 0:p}),children:n&&t.sessions.length>0?(0,$.jsx)(to,{sessions:t.sessions,onSelectSession:A?K:m,onPinSession:h,onArchiveSession:g,onOpenSessionActions:_}):null},t.id)})]}):null]})},e.id)}),t[97]=N,t[98]=re,t[99]=G,t[100]=K,t[101]=g,t[102]=p,t[103]=d,t[104]=l,t[105]=_,t[106]=f,t[107]=h,t[108]=m,t[109]=c,t[110]=u,t[111]=n.length,t[112]=A,t[113]=y,t[114]=M,t[115]=ke):ke=t[115];let Ae;t[116]===y?Ae=t[117]:(Ae=y(`sessions.sidebar.header.actions.addProject`),t[116]=y,t[117]=Ae);let je;t[118]!==N||t[119]!==Ae?(je=(0,$.jsx)(`button`,{type:`button`,className:`sr-only`,onClick:N,children:Ae}),t[118]=N,t[119]=Ae,t[120]=je):je=t[120];let Y;return t[121]!==oe||t[122]!==Ee||t[123]!==De||t[124]!==Oe||t[125]!==ke||t[126]!==je?(Y=(0,$.jsxs)(`main`,{className:oe,children:[Ee,De,Oe,ke,je]}),t[121]=oe,t[122]=Ee,t[123]=De,t[124]=Oe,t[125]=ke,t[126]=je,t[127]=Y):Y=t[127],Y}function ao(e){return e.kind===`main`}function oo(e){return!e}function so(e){let t=(0,Yr.c)(11),{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=P(i),f=c?`destructive`:`ghost`,p=u?`size-5 animate-spin`:`size-5`,m;t[0]!==n||t[1]!==p?(m=(0,$.jsx)(Z,{name:n,className:p}),t[0]=n,t[1]=p,t[2]=m):m=t[2];let h;t[3]===r?h=t[4]:(h=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=h);let g;return t[5]!==l||t[6]!==d||t[7]!==f||t[8]!==m||t[9]!==h?(g=(0,$.jsxs)(Ue,{type:`button`,variant:f,size:`lg`,className:`min-h-12 w-full justify-start gap-3 rounded-lg px-4`,disabled:l,onClick:d,children:[m,h]}),t[5]=l,t[6]=d,t[7]=f,t[8]=m,t[9]=h,t[10]=g):g=t[10],g}function co(e,t,n){return e.map(e=>{let r=(0,$.jsx)(so,{icon:e.icon,label:pr(e,t),onClick:n(e.onClick),destructive:e.destructive,disabled:e.disabled,spinning:e.spinning},e.id);return e.separated?(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:r},e.id):r})}function lo(e){let t=(0,Yr.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=tr({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=nr({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=Xn({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=co(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-1 flex-col gap-1 overflow-y-auto overscroll-contain px-2`,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)(It,{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}var uo=`__show_more__:`,fo=`__show_fewer__:`,po=e=>e.startsWith(uo),mo=e=>e.startsWith(fo),ho=e=>po(e)||mo(e),go=e=>{let t=po(e)?uo:mo(e)?fo: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)}},_o=e=>e.parentID??null,vo=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),yo=e=>{let t=e;return vo(t.directory??t.project?.worktree??null)},bo=(e,t)=>{if(t?.trim())return t.trim();let n=vo(e);if(!n)return``;let r=n.split(`/`).filter(Boolean);return r[r.length-1]||n},xo=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},So=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))},Co=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},wo=(e,t)=>e.worktrees.find(e=>vo(e.path)===t)??null,To=(e,t)=>t===e.path||!!wo(e,t);function Eo(){let e=(0,Yr.c)(73),{t}=ee(),n=ce(),r=ye(Go),i=ye(Wo),a=Me(Uo),o=Me(Ho),s=S(Vo),c=J(Bo),l=J(zo),u=ut(Ro),d=ve(),f=ia(Lo),p=ia(Io),m=K(Fo),h;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=new Map,e[0]=h):h=e[0];let[g,_]=Q.useState(h),v=Vn(),y;if(e[1]!==a||e[2]!==u||e[3]!==l){let t;e[5]!==u||e[6]!==l?(t=e=>{let t=vo(e.path);return{id:e.id,label:bo(t,e.label),path:t,icon:e.icon,worktrees:st(u[e.id],l.get(t)??[])}},e[5]=u,e[6]=l,e[7]=t):t=e[7],y=a.map(t),e[1]=a,e[2]=u,e[3]=l,e[4]=y}else y=e[4];let b=y,x;if(e[8]!==r||e[9]!==n){let t=new Map(n.map(Po));x=r.map(e=>{let n=t.get(e.id);return n?we(n,e):e});let i=new Set(x.map(No));for(let e of n)i.has(e.id)||x.push(e);e[8]=r,e[9]=n,e[10]=x}else x=e[10];let C=x,w;if(e[11]!==o||e[12]!==b||e[13]!==C){let t;e[15]===o?t=e[16]:(t=e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===o,latestActivity:0}),e[15]=o,e[16]=t),w=b.map(t);let n=Mo;for(let e of w){n(e,e.project.path,null);for(let t of e.project.worktrees)n(e,t.path,t)}for(let e of C){let t=yo(e);if(!t)continue;let r=vo(t),i=w.find(e=>To(e.project,r));if(!i)continue;let a=wo(i.project,r);(a?n(i,a.path,a):n(i,i.project.path,null)).sessions.push(e)}for(let e of w)for(let t of e.buckets){t.sessions.sort(jo);for(let n of t.sessions){_o(n)||(e.totalSessions+=1);let t=xo(n);t>e.latestActivity&&(e.latestActivity=t)}}e[11]=o,e[12]=b,e[13]=C,e[14]=w}else w=e[14];let T=w,E;if(e[17]!==C){E=new Map;for(let e of C)E.set(e.id,e);e[17]=C,e[18]=E}else E=e[18];let D=E,O;if(e[19]!==b){O=new Map;for(let e of b)O.set(e.id,e);e[19]=b,e[20]=O}else O=e[20];let k=O,A=Ao,j;if(e[21]!==c||e[22]!==d||e[23]!==b||e[24]!==C||e[25]!==t||e[26]!==m){let n;e[28]===d?n=e[29]:(n=e=>d.has(e.id)&&!_o(e),e[28]=d,e[29]=n);let r;e[30]===Symbol.for(`react.memo_cache_sentinel`)?(r=(e,t)=>A(t)-A(e),e[30]=r):r=e[30];let i;e[31]!==c||e[32]!==b||e[33]!==t||e[34]!==m?(i=e=>{let n=yo(e),r=b.find(e=>To(e,n));return r?[{id:e.id,directory:n,title:e.title?.trim()||t(`mobile.sessions.untitled`),subtitle:r.label,activityLabel:So(xo(e))||void 0,unread:(m[e.id]??0)>0,pinned:!0,archived:Co(e),active:c===e.id}]:[]},e[31]=c,e[32]=b,e[33]=t,e[34]=m,e[35]=i):i=e[35],j=C.filter(n).sort(r).flatMap(i),e[21]=c,e[22]=d,e[23]=b,e[24]=C,e[25]=t,e[26]=m,e[27]=j}else j=e[27];let M=j,N;if(e[36]!==T){N=new Map;for(let e of T){let t=e.project.worktrees.length>0;for(let n of e.buckets){let r=n.sessions.filter(ko).length;N.set(`${e.project.id}::${n.key}`,{path:n.path,rootCount:r,hasWorktrees:t})}}e[36]=T,e[37]=N}else N=e[37];let P=N,F;if(e[38]!==i||e[39]!==v||e[40]!==s||e[41]!==c||e[42]!==d||e[43]!==f||e[44]!==T||e[45]!==t||e[46]!==m||e[47]!==g||e[48]!==p){let n=vo(s);F=T.map(e=>{let r=f[e.project.id]??!0,a=gr(),o=e.project.icon?_t[e.project.icon]:void 0,s=e.buckets.map(r=>{let o=`${e.project.id}::${r.key}`,s=p[o]??!1,l=g.get(o)??a,u=r.sessions.filter(Oo),f=Hn(u,l,v).map(e=>{let n=_o(e),i=(m[e.id]??0)>0&&!n;return{id:e.id,directory:r.path,title:e.title?.trim()||t(`mobile.sessions.untitled`),activityLabel:So(xo(e))||void 0,unread:i,pinned:d.has(e.id),archived:Co(e),active:c===e.id}}),h=u.length-f.length,_=i.get(vo(r.path)),y=_?.hasMore===!0,b=u.length>a&&l>a,x=[...f];b&&x.push({id:`${fo}${e.project.id}::${r.key}`,kind:`pagination`,title:t(`sessions.sidebar.group.showFewer`)}),(h>0||y)&&x.push({id:`${uo}${e.project.id}::${r.key}`,kind:`pagination`,title:t(`sessions.sidebar.group.showMore`),subtitle:_?.loadingMore?`…`:void 0});let S=vo(r.path),C=!!(e.isActive&&n&&S&&(n===S||n.startsWith(`${S}/`))),w=r.worktree==null;return{id:r.key,name:w?t(`mobile.sessions.mainWorkspace`):r.label,path:r.path,kind:w?`main`:`worktree`,active:C,expanded:w?!0:s,sessionCount:u.length,sessions:x}});return{id:e.project.id,name:e.project.label,path:e.project.path,icon:o,sessionCount:e.totalSessions,activityLabel:So(e.latestActivity)||void 0,active:e.isActive,expanded:r,worktrees:s}}),e[38]=i,e[39]=v,e[40]=s,e[41]=c,e[42]=d,e[43]=f,e[44]=T,e[45]=t,e[46]=m,e[47]=g,e[48]=p,e[49]=F}else F=e[49];let te=F,I;e[50]===P?I=e[51]:(I=e=>{for(let[t,n]of P)if(t.startsWith(`${e}::`))return n.hasWorktrees;return!1},e[50]=P,e[51]=I);let L=I,R;e[52]===P?R=e[53]:(R=(e,t)=>P.get(`${e}::${t}`)?.rootCount??0,e[52]=P,e[53]=R);let z=R,B=Do,V;e[54]===g?V=e[55]:(V=(e,t)=>{let n=`${e}::${t}`;return g.get(n)??B(e)},e[54]=g,e[55]=V);let H=V,U;e[56]===P?U=e[57]:(U=(e,t)=>P.get(`${e}::${t}`)?.path??null,e[56]=P,e[57]=U);let W=U,ne;e[58]!==P||e[59]!==g?(ne=(e,t)=>{let n=`${e}::${t}`,r=P.get(n),i=gr(),a=Qn(),o=g.get(n)??i,s=r?.rootCount??0;if(_(e=>{let t=new Map(e),r=Math.max(i,e.get(n)??i,o);return t.set(n,r+a),t}),Math.max(i,o)+a<s)return;let c=r?.path,l=vo(c);if(!l)return;let u=ye.getState().activePaginationByDirectory.get(l);u?.hasMore&&!u.loadingMore&&he(l)},e[58]=P,e[59]=g,e[60]=ne):ne=e[60];let re=ne,ie;e[61]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(e,t)=>{let n=`${e}::${t}`;_(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})},e[61]=ie):ie=e[61];let G=ie,ae;return e[62]!==W||e[63]!==z||e[64]!==H||e[65]!==te||e[66]!==M||e[67]!==L||e[68]!==k||e[69]!==D||e[70]!==C||e[71]!==re?(ae={projects:te,pinnedSessions:M,sessionById:D,projectMetaById:k,allSessions:C,projectHasWorktrees:L,getBucketRootCount:z,getBucketVisibleCount:H,getBucketPageSize:B,getBucketDirectory:W,showMoreBucketSessions:re,resetBucketVisibleCount:G},e[62]=W,e[63]=z,e[64]=H,e[65]=te,e[66]=M,e[67]=L,e[68]=k,e[69]=D,e[70]=C,e[71]=re,e[72]=ae):ae=e[72],ae}function Do(e){return gr()}function Oo(e){return!_o(e)}function ko(e){return!_o(e)}function Ao(e){let t=e.time?.created;return typeof t==`number`&&Number.isFinite(t)?t:0}function jo(e,t){return re(t)-re(e)}function Mo(e,t,n){let r=vo(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||bo(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a}function No(e){return e.id}function Po(e){return[e.id,e]}function Fo(e){return e.index.session.unseenCount}function Io(e){return e.worktreeExpanded}function Lo(e){return e.projectExpanded}function Ro(e){return e.orderByProject}function zo(e){return e.availableWorktreesByProject}function Bo(e){return e.currentSessionId}function Vo(e){return e.currentDirectory}function Ho(e){return e.activeProjectId}function Uo(e){return e.projects}function Wo(e){return e.activePaginationByDirectory}function Go(e){return e.activeSessions}var Ko=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function qo({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,className:a}){let{t:o}=ee(),{git:s}=Zt(),c=Eo(),l=ia(e=>e.setProjectExpanded),u=ia(e=>e.setWorktreeExpanded),f=pe(),p=ve(),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=De(e=>e.openDraft),x=De(e=>e.openSession),S=Me(e=>e.projects),C=Me(e=>e.setActiveProjectIdOnly),w=Me(e=>e.removeProject),T=Jt(),[E,D]=Q.useState(null),[O,k]=Q.useState(!1),[A,j]=Q.useState(null),[M,N]=Q.useState(null),[F,I]=Q.useState(null),[L,R]=Q.useState(``),[z,B]=Q.useState(!1),[V,H]=Q.useState(!1),[U,W]=Q.useState(null),[ne,re]=Q.useState(null),[ie,G]=Q.useState(null),ae=E?.kind===`session`?E.session.id:``,K=fe(ae),oe=K?.type===`busy`||K?.type===`retry`,se=E?.kind===`session`?yo(E.session):``,q=!!ae&&ie===ae,ce=!se||q||oe,le=P(e=>{let t=new Map;for(let e of c.allSessions){let n=_o(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}),ue=P(()=>{k(!1),D(null)}),de=P(t=>{if(ho(t.id)){let e=go(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&&yo(n)||null;e({sessionId:t.id,directory:r})}),me=P(e=>{ho(e.id)||f(e.id)}),he=P(async e=>{if(ho(e.id))return;let t=le(e.id),{archivedIds:n,failedIds:r}=await m(t);n.length>0&&Kn({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}))}),ge=P(()=>{if(!E||E.kind!==`session`)return;let e=E.session,t=yo(e),n=K?.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)}})())}),_e=P(e=>{if(ho(e.id))return;let t=c.sessionById.get(e.id);t&&(D({kind:`session`,session:t}),k(!0))}),ye=P(e=>{l(e.id,!e.expanded)}),be=P((e,t)=>{u(`${e.id}::${t.id}`,!t.expanded)}),xe=P((e,t)=>{C(e.id),b({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),Se=P(()=>{if(n){n();return}y()}),Ce=P(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=>Ko(n,t.id,e))}).catch(()=>{D(e=>Ko(e,t.id,!1))}))}),we=P((e,t)=>{let n=d(t);return n?e.worktrees.find(e=>d(e.path)===n)||((J.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>d(e.path)===n)??null):null}),Ee=P((e,t)=>{let n=c.projectMetaById.get(e.id);n&&xe(n,t.path)}),Oe=P((e,t)=>{let n=c.projectMetaById.get(e.id);n&&(D({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),k(!0))}),ke=P((e,t)=>{let n=c.projectMetaById.get(e.id);if(!n)return;let r=we(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})}),Ae=P(e=>{W(e),C(e),H(!0)}),je=P(e=>{(async()=>{let t=e.worktrees;try{t=(await gt({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 Te([e.path,...t.map(e=>e.path)],c.allSessions)})()}),Ne=P((e,t)=>{let n=U;if(H(!1),W(null),t?.sessionId){x({sessionId:t.sessionId,directory:e});return}b({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),Pe=P(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`))}}),Fe=P(async e=>{if((await te(e)).ok){Y.success(o(`sessions.sidebar.session.menu.copied`));return}Y.error(o(`sessions.sidebar.session.share.copyUrlError`))}),Ie=P(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`))}}),Le=P(e=>{let t=le(e.id);mr({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`)})}),Re=P(async()=>{if(!F)return;let e=L.trim();if(e)try{await h(F.id,e),I(null),R(``)}catch{Y.error(o(`sessions.sidebar.session.menu.rename`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),ze=P(async()=>{if(!F||z)return;let e=F.id;I(null),R(``),B(!0);try{await g(e)}catch{Y.error(o(`sessions.sidebar.session.rename.smartTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{B(!1)}}),Be=Q.useMemo(()=>E?E.kind===`session`?{kind:`session`,title:E.session.title?.trim()||o(`mobile.sessions.untitled`),pinned:p.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,p,o]),Ve=Q.useMemo(()=>{if(!E)return{};if(E.kind===`session`){let e=E.session;return{onRename:()=>{R(e.title?.trim()||o(`mobile.sessions.untitled`)),I(e)},onTogglePin:()=>f(e.id),onShare:e.share?.url?void 0:()=>{Pe(e)},onCopyLink:e.share?.url?()=>{Fe(e.share.url)}:void 0,onUnshare:e.share?.url?()=>{Ie(e.id)}:void 0,onRefreshTranscript:ge,onArchive:()=>{he({id:e.id,title:e.title?.trim()||o(`mobile.sessions.untitled`)})},onDelete:()=>Le(e)}}if(E.kind===`project`){let e=E.project;return{onNewSession:()=>xe(e,e.path),onNewWorktree:()=>Ae(e.id),onSyncSessions:()=>je(e),onEditProject:()=>j(e.id),onCloseProject:()=>N(e)}}let{project:e,worktreePath:t}=E;return{onNewSession:()=>xe(e,t),onDeleteWorktree:()=>{let n=we(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,he,Fe,Le,ge,Ae,je,Pe,Ie,we,xe,o,f]),He=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:d(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)(io,{className:a,projects:c.projects,pinnedSessions:c.pinnedSessions,onAddProject:t,onNewSession:Se,onScanQr:r,onSwitchInstance:i,onToggleProject:ye,onOpenProjectActions:Ce,onToggleWorktree:be,onNewWorktreeSession:Ee,onOpenWorktreeActions:Oe,onDeleteWorktree:ke,onSelectSession:de,onPinSession:me,onArchiveSession:e=>{he(e)},onOpenSessionActions:_e}),(0,$.jsx)(lo,{open:O,target:Be,actions:Ve,refreshTranscriptDisabled:ce,refreshTranscriptSpinning:q,onOpenChange:e=>{e?k(!0):ue()}}),(0,$.jsx)(Yt,{open:V,projectId:U,onOpenChange:e=>{H(e),e||W(null)},onWorktreeCreated:Ne}),ne?(0,$.jsx)(Ln,{open:!0,project:{id:ne.project.id,path:ne.project.path},worktree:ne.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)(Ue,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>N(null),children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Ue,{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:!!F,title:o(`sessions.sidebar.session.menu.rename`),onClose:()=>{z||(I(null),R(``))},closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Ue,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:z,onClick:()=>{I(null),R(``)},children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Ue,{type:`button`,variant:`default`,className:`flex-1`,disabled:!L.trim()||z,onClick:()=>void Re(),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(),Re()},children:[(0,$.jsx)(xt,{value:L,onChange:e=>R(e.target.value),autoFocus:!0,className:`h-12`,disabled:z}),(0,$.jsxs)(Ue,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:z,onClick:()=>void ze(),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)(Gn,{open:A!==null,project:He,onClose:()=>j(null)})]})}function Jo(e){let t=(0,Yr.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)(Dn,{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 Yo(e){let t=(0,Yr.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=[...kn],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(Tr,{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)(Dn,{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 Xo(e){let t=(0,Yr.c)(92),{onAddProject:n,onScanQr:r,onSwitchInstance:i,onEnableAssistants:a,instancesPage:o,instancesSecondaryPage:s,parentSessionTarget:c,registerSecondaryBackHandler:l,scheduledContent:u,renderChat:f,className:p}=e,m=c===void 0?null:c,{t:h}=ee(),g=De(),_=De(ss),v=De(os),y=De(as),b=De(is),x=De(rs),S=De(ns),C=De(ts),w=De(es),T=De($o),E;t[0]===_?E=t[1]:(E=e=>{_(e)},t[0]=_,t[1]=E);let D=P(E),O;t[2]===v?O=t[3]:(O=e=>{v(e)},t[2]=v,t[3]=O);let k=P(O),A;t[4]===x?A=t[5]:(A=()=>{x()},t[4]=x,t[5]=A);let j=P(A),M;t[6]===y?M=t[7]:(M=()=>{y()},t[6]=y,t[7]=M);let N=P(M),F;t[8]===b?F=t[9]:(F=e=>{b(e)},t[8]=b,t[9]=F);let te=P(F),I=Q.useRef(null),[L,R]=Q.useState(!1),z;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{I.current=e},t[10]=z):z=t[10];let B=P(z),V;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(V=e=>{R(e)},t[11]=V):V=t[11];let H=P(V),U;t[12]!==j||t[13]!==S?(U=()=>{if(I.current?.())return!0;let e=De.getState().secondary;return e?.kind===`chat`&&e.routes.length>1?(S(),!0):e?(j(),!0):!1},t[12]=j,t[13]=S,t[14]=U):U=t[14];let W=P(U),ne=g.secondary!==null,re;t[15]!==W||t[16]!==l?(re=()=>{if(l)return l(()=>W()),()=>l(null)},t[15]=W,t[16]=l,t[17]=re):re=t[17];let ie;t[18]!==W||t[19]!==l||t[20]!==ne?(ie=[l,ne,W],t[18]=W,t[19]=l,t[20]=ne,t[21]=ie):ie=t[21],Q.useEffect(re,ie);let G=J(Qo),ae;t[22]===G?ae=t[23]:(ae=e=>G?e.getDirectoryForSession(G):null,t[22]=G,t[23]=ae);let K=J(ae),oe,se;t[24]!==K||t[25]!==G||t[26]!==w||t[27]!==T?(oe=()=>{let e=De.getState().secondary;if(e?.kind===`draft`&&G){w({sessionId:G,directory:K});return}if(e?.kind!==`chat`||!G||ke({sessionId:G,directory:K})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==G||d(t.directory)!==d(K))&&T({sessionId:G,directory:K})},se=[K,G,w,T],t[24]=K,t[25]=G,t[26]=w,t[27]=T,t[28]=oe,t[29]=se):(oe=t[28],se=t[29]),Q.useEffect(oe,se);let q,ce;t[30]!==G||t[31]!==m||t[32]!==C?(q=()=>{let e=De.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]=q,t[34]=ce):(q=t[33],ce=t[34]),Q.useEffect(q,ce);let le;t[35]!==H||t[36]!==B||t[37]!==u?(le=typeof u==`function`?u(B,H):u,t[35]=H,t[36]=B,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)(qo,{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]!==te?(fe=(0,$.jsx)(Na,{onEnable:a,onOpenAssistant:te}),t[45]=a,t[46]=te,t[47]=fe):fe=t[47];let pe;t[48]===ue?pe=t[49]:(pe=(0,$.jsx)(Jo,{showHeader:!1,children:ue}),t[48]=ue,t[49]=pe);let me;t[50]===o?me=t[51]:(me=(0,$.jsx)(Yo,{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)(Mr,{activeOverride:!0,onMobileBack:Zo}),t[59]=n):n=t[59];let r;t[60]!==W||t[61]!==e?(r=[{key:`assistant-secondary`,depth:1,ariaLabel:e,onBack:W,content:n}],t[60]=W,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]!==W||t[66]!==s||t[67]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:W,content:s}],t[65]=W,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]===f?n=t[72]:(n=f({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[71]=f,t[72]=n);let r;t[73]!==W||t[74]!==e||t[75]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:W,content:n}],t[73]=W,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]!==W||t[79]!==f||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:W,content:f({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:n})}}),t[78]=W,t[79]=f,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]!==p||t[86]!==g||t[87]!==L||t[88]!==D||t[89]!==be||t[90]!==ge?(xe=(0,$.jsx)(La,{className:p,navigation:g,onTabChange:D,tabs:ge,secondaryPages:be,tabBarCovered:L}),t[85]=p,t[86]=g,t[87]=L,t[88]=D,t[89]=be,t[90]=ge,t[91]=xe):xe=t[91],xe}function Zo(){return nn.requestAnimatedBack(`root`)}function Qo(e){return e.currentSessionId}function $o(e){return e.replaceChatSession}function es(e){return e.materializeDraftSession}function ts(e){return e.reconcileChatPredecessor}function ns(e){return e.popChatSession}function rs(e){return e.closeSecondary}function is(e){return e.openAssistant}function as(e){return e.openDraft}function os(e){return e.openSession}function ss(e){return e.setActiveTab}function cs(e){let t=(0,Yr.c)(19),{percentage:n}=e,r,i,a,o,s,c,l;if(t[0]!==n){a=Tt(n)??0;let e=wt(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 ls(e){let t=(0,Yr.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=P(i),p=P(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)(Re,{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 us=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},ds=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),fs=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,ps=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:`${ds(t)}/${ds(n)}`,colorClass:fs(i)}},ms=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},hs=(e,t)=>{let n=Se(e,t??(()=>void 0));return!n||`compacted`in n?0:n.totalTokens},gs=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),_s=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`},vs=e=>{let t=(0,Yr.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},ys=e=>{let t=(0,Yr.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)(mt,{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=Ct(e.window.valueLabel,t),i=Dt(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`,_s(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},bs=e=>{let t=(0,Yr.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)(vs,{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)(vs,{iconNode:(0,$.jsx)(cs,{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)(ys,{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:Bs,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); }
|
|
@@ -20,4 +20,4 @@ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,D as n,F as r,M
|
|
|
20
20
|
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
21
21
|
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
22
22
|
}
|
|
23
|
-
`}),t[52]=W):W=t[52];let ne;return t[53]===U?ne=t[54]:(ne=(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:[U,W]}),t[53]=U,t[54]=ne),ne},tu=e=>{let t=(0,Yr.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)(mt,{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=Ct(e.window.valueLabel,t),i=Dt(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`,Ql(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},nu=e=>{let t=(0,Yr.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:Al,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:su,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},ru=Q.memo(function(e){let t=(0,Yr.c)(88),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:u}=e,{t:d}=ee(),{git:f}=Zt(),p=Hs(i??``,a||void 0),m=p??u,h=Q.useRef(null),g=ge(i??``,a||void 0),_=hn(o),v=gn(o),y=pn(cu),b=pn(lu),x=Ae(uu),S=Ae(du),C=Ae(fu),w=Ae(pu),T;t[0]===i?T=t[1]:(T=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=T);let E=ie(T),D=Nn(mu),O=Nn(hu),k=Nn(gu),A=Nn(_u),j=Nn(vu),M=Nn(yu),N=Nn(bu),P=l(xu);wn();let F,te;t[2]!==y||t[3]!==f||t[4]!==o?(F=()=>{o&&y(o,f)},te=[y,f,o],t[2]=y,t[3]=f,t[4]=o,t[5]=F,t[6]=te):(F=t[5],te=t[6]),Q.useEffect(F,te);let I,L;t[7]!==b||t[8]!==f||t[9]!==o?(I=()=>{if(o)return be.onGitRefreshHint(e=>{Wl(e.directory)===o&&b(o,f)})},L=[b,f,o],t[7]=b,t[8]=f,t[9]=o,t[10]=I,t[11]=L):(I=t[10],L=t[11]),Q.useEffect(I,L);let R,z;t[12]===O?(R=t[13],z=t[14]):(R=()=>{O()},z=[O],t[12]=O,t[13]=R,t[14]=z),Q.useEffect(R,z);let B,V;t[15]===M?(B=t[16],V=t[17]):(B=()=>{pt(M)},V=[M],t[15]=M,t[16]=B,t[17]=V),Q.useEffect(B,V);let H,U;t[18]!==M||t[19]!==k||t[20]!==A||t[21]!==n||t[22]!==D?(H=()=>{!n||A||M.some(e=>!D.some(t=>t.providerId===e))&&k()},U=[M,k,A,n,D],t[18]=M,t[19]=k,t[20]=A,t[21]=n,t[22]=D,t[23]=H,t[24]=U):(H=t[23],U=t[24]),Q.useEffect(H,U);let W;t[25]===g?W=t[26]:(W=ms(g),t[25]=g,t[26]=W);let ne=W,re;if(t[27]!==g||t[28]!==C||t[29]!==S||t[30]!==w||t[31]!==s||t[32]!==ne||t[33]!==x||t[34]!==E){let e=ne??(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=us(n?.limit,`context`)??r?.limit?.context??0,a;t[36]===g?a=t[37]:(a=hs(g),t[36]=g,t[37]=a),re=ps({totalTokens:a,contextLimit:i,isDraft:s}),t[27]=g,t[28]=C,t[29]=S,t[30]=w,t[31]=s,t[32]=ne,t[33]=x,t[34]=E,t[35]=re}else re=t[35];let G=re,ae;t[38]!==v?.current||t[39]!==_||t[40]!==d?(ae=_===!0?v?.current?.trim()||d(`gitView.branch.detachedHead`):d(`common.unavailable`),t[38]=v?.current,t[39]=_,t[40]=d,t[41]=ae):ae=t[41];let K=ae,oe;if(t[42]!==M||t[43]!==D||t[44]!==N||t[45]!==d){let e=new Map(D.map(Su)),n;t[47]===M?n=t[48]:(n=e=>M.includes(e.id),t[47]=M,t[48]=n),oe=vn.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:Ot(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:Ot(i),subtitle:En(e),window:a})}let s=!n.ok&&n.error?n.error:r.length===0?d(`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]=d,t[46]=oe}else oe=t[46];let se=oe,q,ce;t[49]!==n||t[50]!==se?(q=()=>{!n||se.length===0||pt(se.map(Cu))},ce=[n,se],t[49]=n,t[50]=se,t[51]=q,t[52]=ce):(q=t[51],ce=t[52]),Q.useEffect(q,ce);let le;t[53]===c?le=t[54]:(le=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[53]=c,t[54]=le);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]!==le||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:[le,ue]})}),t[58]=le,t[59]=ue,t[60]=de):de=t[60];let fe;t[61]===d?fe=t[62]:(fe=d(`mobile.header.openMetadataAria`),t[61]=d,t[62]=fe);let pe;t[63]===r?pe=t[64]:(pe=()=>r(wu),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=G?.percentage??0,_e;t[66]===he?_e=t[67]:(_e=(0,$.jsx)(cs,{percentage:he}),t[66]=he,t[67]=_e);let ve;t[68]!==n||t[69]!==fe||t[70]!==pe||t[71]!==_e?(ve=(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:_e}),t[68]=n,t[69]=fe,t[70]=pe,t[71]=_e,t[72]=ve):ve=t[72];let ye;t[73]===r?ye=t[74]:(ye=()=>r(!1),t[73]=r,t[74]=ye);let xe;t[75]!==K||t[76]!==G||t[77]!==A||t[78]!==n||t[79]!==j||t[80]!==ye||t[81]!==P||t[82]!==se?(xe=(0,$.jsx)(eu,{open:n,onClose:ye,anchorRef:h,contextDisplay:G,branchLabel:K,usageGroups:se,usageDisplayMode:j,isUsageLoading:A,timeFormatPreference:P}),t[75]=K,t[76]=G,t[77]=A,t[78]=n,t[79]=j,t[80]=ye,t[81]=P,t[82]=se,t[83]=xe):xe=t[83];let Se;return t[84]!==de||t[85]!==ve||t[86]!==xe?(Se=(0,$.jsxs)($.Fragment,{children:[de,ve,xe]}),t[84]=de,t[85]=ve,t[86]=xe,t[87]=Se):Se=t[87],Se}),iu=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=ee(),[a,o]=Q.useState(!1),s=S(e=>e.currentDirectory),c=J(e=>e.currentSessionId),l=Q.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=J(l)||s,d=Wl(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=Ie(c),_=J(e=>!!e.newSessionDraft?.open),v=Q.useMemo(()=>{let e=Wl(u);return e&&Jl((h?.projectDirectory?ue(f,h.projectDirectory):null)??Fe(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=P(()=>{o(!1),e()}),C=P(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Ci,{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)(ru,{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":Al,"aria-expanded":t,"aria-haspopup":`menu`,onClick:C,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`more-2`,className:`size-5`})})]})})},au=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=ee(),r=Jt();de(),Ne();let i=l(e=>e.mobileSessionPanelOpen),a=l(e=>e.setMobileSessionPanelOpen),o=l(e=>e.isScheduledTasksDialogOpen),s=l(e=>e.activeMainTab),c=Le(),u=l(e=>e.setActiveMainTab),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),[x,C]=Q.useState(null),[w,E]=Q.useState(null),[D,O]=Q.useState(null),[k,A]=Q.useState(0),[j,M]=Q.useState(!1),[F,te]=Q.useState(!1),[I,L]=Q.useState(!1),[R,z]=Q.useState(!1),[B,V]=Q.useState(!1),[H,U]=Q.useState(!1),[W,ne]=Q.useState(`nav`),[re,ie]=Q.useState(!1),[G,ae]=Q.useState(!1),K=P(()=>ie(e=>!e)),oe=P(()=>ie(!1)),[q,ce]=Q.useState(null),le=S(e=>e.currentDirectory),ue=l(e=>e.setSettingsPage),pe=yn(e=>e.available),me=yn(e=>e.runtimeType),he=Q.useMemo(()=>Bl(),[]),ge=Q.useMemo(()=>uc(),[]),{data:_e=[],refetch:ve}=Sn(le??null,{enabled:j}),{refetch:ye}=Cn(le??null,{enabled:j}),xe=br(e=>e.setMcpDraft),Se=br(e=>e.setSelectedMcp),Ce=gn(Wl(le)||null)?.files?.length??0;Q.useEffect(()=>be.onDirectoryRequest(()=>V(!0)),[]);let we=Q.useMemo(()=>T(),[]),Te=zt()===`portrait`,[Ee,Oe]=Q.useState(we&&!Te),[ke,Ae]=Q.useState(null),je=P(e=>{if(e&&ue(e),we){ne(e?`page-content`:`nav`),L(!0);return}De.getState().setActiveTab(`settings`)}),Y=P(()=>{je(`instances`)}),Me=P(()=>{De.getState().openInstances()}),Pe=P(()=>{De.getState().closeSecondary()}),Fe=P(async()=>{if(!H){U(!0);try{let t=await dc();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`:N.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:N.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:N.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:N.error(n(`mobile.connect.scan.failed`))}}finally{U(!1)}}});en({enabled:!we,rootRoutesBlocked:i||d||p||_||y||o||j||I||R||B||re});let Ie=P(()=>{let e=!Ee;e&&Te&&Ae(null),Oe(e)}),ze=P(()=>{if(b(!1),C(null),E(null),m(!1),g(null),we){ce(null),Ae(`files`),Te&&Oe(!1);return}f(!0)}),Be=P(()=>{m(!1),g(null)}),Ve=P(e=>{let t=e.path.trim();if(t){if(b(!1),C(null),E(null),ce(null),v(!1),we){l.getState().setPendingFileFocusPath(t),Ae(`files`),Te&&Oe(!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)}}),He=l(e=>e.pendingFileFocusPath);Q.useEffect(()=>{if(He){if(we){ze();return}Ve({path:He}),l.getState().setPendingFileFocusPath(null)}},[He,we,ze,Ve]);let We=P((e=null)=>{if(b(!1),C(null),E(null),O(null),m(!1),g(null),ce(e),we){Ae(`changes`),Te&&Oe(!1);return}v(!0)}),Ge=P((e,t,n)=>{ce(null),v(!1),m(!1),g(null),C(e??null),E(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(O(r),A(e=>e+1),we){Ae(`turn-diff`),Te&&Oe(!1);return}b(!0)}),Ke=P(()=>{Ae(null),ce(null),O(null)}),qe=P(e=>{if(ke===e){Ke();return}e===`files`?ze():We()}),Je=Q.useRef(`changes`);ke&&(Je.current=ke);let[Ye,Xe]=Q.useState(!1);Q.useEffect(()=>{if(!we)return;if(ke){Xe(!0);return}let e=window.setTimeout(()=>Xe(!1),240);return()=>window.clearTimeout(e)},[ke,we]);let Ze=ke??Je.current,Qe=Rl(`left`,`openchamber.ipad.leftSidebarWidth`,jl),$e=Rl(`right`,`openchamber.ipad.rightSidebarWidth`,Ml),et=Q.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{We(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{We({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:Ge,openFile:({path:e,targetLine:t})=>{Ve({path:e,targetLine:t})},openFiles:()=>ze(),openSettings:e=>{je(e)}}),[We,Ve,ze,je,Ge]),tt=P(()=>{v(!1),ce(null)}),nt=P(()=>{b(!1),O(null)});Pc(Q.useMemo(()=>({openSessions:()=>{if(we){Oe(!0);return}De.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?ze():e===`mcp`?M(!0):e===`instances`?Y():e===`update`&&z(!0)},openChanges:({path:e,staged:t}={})=>{We(e?{path:e,staged:t===!0}:null)},openSettings:e=>{je(e)}}),[we,We,ze,Y,je]));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=se(lt,ft||le||void 0),mt=fe(lt??``),ht=mt?.type===`busy`||mt?.type===`retry`,gt=P(()=>{let e=lt;if(!e||G||ht)return;let t=ft||le||void 0;ae(!0),(async()=>{try{await r.refreshSessionTranscript(e,{directory:t}),N.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{N.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ae(!1)}})()}),_t=P(e=>{ct.current=e}),vt=P(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`)})}),yt=De(e=>e.secondary?.kind??null),bt=!we&&(yt===`chat`||yt===`draft`);Q.useEffect(()=>{!we&&!bt&&ie(!1)},[we,bt]),Q.useEffect(()=>{ie(!1)},[lt]),$c(it,{onSwitch:_t,onProgress:vt},we||bt);let xt=we&&s===`assistant`||!we&&!bt||i||d||p||_||y||o||j||I||R||B||re;yl(it,{onOpen:P(()=>{Lt(Rt)?.finish(`commit`)}),onPreviewStart:P(()=>{Lt(Rt)?.begin(`present`)}),onPreviewCancel:P(()=>{Lt(Rt)?.finish(`cancel`)}),onProgress:P(e=>{e!==null&&Lt(Rt)?.update(e)}),disabled:xt},we||bt),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 St=P(e=>{rt.current=e});Ul(P(()=>re?(ie(!1),!0):B?(V(!1),!0):o?(window.dispatchEvent(new Event(`oc:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):nn.backImmediately(`overlay`)?!0:p?(Be(),!0):d?(f(!1),!0):y?(nt(),!0):_?(tt(),!0):j?(M(!1),!0):I?(L(!1),!0):R?(z(!1),!0):nn.requestAnimatedBack(`root`)||rt.current?.()?!0:s===`assistant`?(u(`chat`),!0):pt?(ut(pt.id,pt.directory),!0):!1));let Ct=pe&&(me===`desktop`||me===`web`),wt=P(()=>{let e=`new-mcp-server`,t=e,n=1;for(;_e.some(e=>e.name===t);)t=`${e}-${n}`,n+=1;xe({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),Se(t),M(!1),je(`mcp`)}),Tt=P(()=>{if(F)return;te(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([ye(),ve(),e]).finally(()=>te(!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){u(`chat`),Dt();return}De.getState().openDraft()}}];return we||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>ze()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:Ce,onSelect:()=>We()}),e.push({key:`mcp`,iconNode:(0,$.jsx)(xn,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>M(!0)}),Ct&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>z(!0)}),we&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>je()}),lt&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:G||ht,spinning:G,onSelect:gt}),e},[lt,Ce,we,ht,G,We,ze,Dt,je,gt,u,Ct,n]);return(0,$.jsxs)(Kt,{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:Qe.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?Qe.width:0,minWidth:Ee?Qe.width:0,maxWidth:Ee?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":!Ee,"data-page-scroll-lock":`true`,children:[Ee?(0,$.jsx)(zl,{side:`left`,isResizing:Qe.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),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`,!Ee&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(Et,{children:(0,$.jsx)(Ea,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&Te&&Oe(!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)(iu,{onOpenSessions:()=>Ie(),menuOpen:re,onToggleMenu:K,surfaceShortcuts:{activePanel:ke===`turn-diff`?`changes`:ke,changesDirty:Ce>0,onToggleFiles:()=>qe(`files`),onToggleChanges:()=>qe(`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)(Et,{children:s===`assistant`?(0,$.jsx)(Mr,{}):(0,$.jsx)(Bn,{})})})]})]}):(0,$.jsx)(Xo,{className:`min-h-0 flex-1`,onAddProject:()=>V(!0),onScanQr:he&&ge?()=>{Fe()}:void 0,onSwitchInstance:he?Me:void 0,onEnableAssistants:()=>{je(`assistants`)},instancesPage:he?(0,$.jsx)(Zl,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,instancesSecondaryPage:he?(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)(Re,{title:n(`mobile.settings.switchInstance`),backAriaLabel:n(`header.actions.backAria`),onBack:Pe}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[var(--oc-mobile-page-inline-inset)]`,children:(0,$.jsx)(On,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(Zl,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:pt?{id:pt.id,directory:pt.directory}:null,registerSecondaryBackHandler:St,scheduledContent:(e,t)=>(0,$.jsx)($n,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(Ks,{sessionId:e.sessionId,directory:e.directory,onBack:()=>{oe(),nn.requestAnimatedBack(`root`)},onOpenMenu:K,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)(Et,{children:(0,$.jsx)(Bn,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:e.sessionId||null,directory:e.directory,viewKey:e.viewKey}})})})]})})})}),we?(0,$.jsxs)(`aside`,{ref:$e.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`,!ke&&`border-l-0`),style:{width:ke?$e.width:0,minWidth:ke?$e.width:0,maxWidth:ke?$e.width:0,"--oc-ipad-sidebar-width":`${$e.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:$e.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!ke,"data-page-scroll-lock":`true`,children:[ke?(0,$.jsx)(zl,{side:`right`,isResizing:$e.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:$e.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`,$e.isResizing&&`pointer-events-none`,!ke&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:Ye?(0,$.jsx)(Et,{children:Ze===`files`?(0,$.jsx)(qi,{onClose:Ke}):Ze===`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)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ke,"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)(_r,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:x,sessionId:w,targetFilePath:D,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)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ke,"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)(_r,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:q.path,targetLine:q.targetLine??null,toolPatches:q.toolPatches,singleFileView:q.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(Fi,{onClose:Ke,initialDiffPath:q?.path??null,initialDiffStaged:q?.staged===!0,initialDiffTargetLine:q?.targetLine??null})}):null})]}):null,(0,$.jsx)(ir,{open:B,onOpenChange:V,forceMobile:!0}),(0,$.jsx)(nu,{open:re,onClose:()=>ie(!1),items:Ot,rightOffset:we&&ke?$e.width:0}),(0,$.jsx)(ur,{}),d?(0,$.jsx)(It,{id:Tl,open:d,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)(Et,{children:(0,$.jsx)(qi,{onClose:()=>f(!1)})})}):null,p&&h?(0,$.jsx)(It,{id:wl,open:p,onOpenChange:e=>{e||Be()},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)(Et,{children:(0,$.jsx)(qi,{onClose:Be,initialFilePath:h.path,directFilePreview:!0,hideFileHeader:!0},h.path)})}):null,(0,$.jsx)(It,{id:Cl,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)(Et,{children:(0,$.jsx)(_r,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:x,sessionId:w,targetFilePath:D,navigationRequestKey:k,flushContent:!0})})}),_&&q?(0,$.jsx)(It,{id:Sl,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)(Et,{children:q.toolPatches?.length?(0,$.jsx)(_r,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:q.path,targetLine:q.targetLine??null,toolPatches:q.toolPatches,singleFileView:q.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(Fi,{initialDiffPath:q.path,initialDiffStaged:q.staged,initialDiffTargetLine:q.targetLine??null,hideDiffHeader:!0})})}):_?(0,$.jsx)(It,{id:El,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)(Et,{children:(0,$.jsx)(Fi,{onClose:tt,initialDiffPath:q?.path??null,initialDiffStaged:q?.staged===!0,initialDiffTargetLine:q?.targetLine??null})})}):null,j?(0,$.jsx)(It,{id:Dl,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)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:wt,"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)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:Tt,disabled:F,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`refresh`,className:X(`size-5`,F&&`animate-spin`)})})]}),ariaLabel:n(`mcpDropdown.title`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Et,{children:(0,$.jsx)(Un,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,I&&we?(0,$.jsx)(It,{id:Ol,open:I,onOpenChange:e=>{e||L(!1)},ariaLabel:n(`mobile.menu.settings`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Et,{children:(0,$.jsx)(Tr,{forceMobile:!0,isWindowed:!0,initialMobileStage:W,visiblePageSlugs:[...kn],onClose:()=>L(!1),mobileInstancesPage:he?(0,$.jsx)(Zl,{connection:e,onConnect:()=>L(!1),onActiveConnectionDeleted:t}):void 0})})}):null,R?(0,$.jsx)(It,{id:kl,open:R,onOpenChange:e=>{e||z(!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)(Et,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(xr,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(vr,{enabled:he&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(Et,{children:(0,$.jsx)(ar,{})})]})};function ou({apis:e}){let{t}=ee(),n=Ae(e=>e.initializeApp),r=Ae(e=>e.isInitialized),a=Ae(e=>e.isConnected),o=Ae(e=>e.connectionPhase),s=S(e=>e.currentDirectory),d=J(e=>e.currentSessionId),m=J(e=>!!e.newSessionDraft?.open),h=J(e=>e.error),g=J(e=>e.clearError),_=l(e=>e.setIsMobile),v=An(e=>e.refreshStatus),y=qt(e=>e.setPlanModeEnabled),b=Me(e=>e.projects),[x,w]=Q.useState(0),[T,E]=Q.useState(0),[D,O]=Q.useState(!1),[A,j]=Q.useState(`pending`),F=Q.useMemo(()=>ne(),[]),[,te]=Q.useReducer(e=>e+1,0),I=Q.useMemo(()=>Bl(),[]),L=Q.useRef(0),z=Q.useRef(0),V=U(()=>{j(`done`),w(e=>e+1)});Fc(P(e=>{V.redeemPairingConnection(e)}));let re=Ic({ready:I&&a&&r});Q.useEffect(()=>{!V.error||!u()||N.error(V.error)},[V.error]);let ie=P(()=>{let t=u(),r=z.current+1;if(z.current=r,!t){R();return}let a=()=>{n(),v(e.github,{force:!0}),Ae.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},o=()=>{i({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),w(e=>e+1)};B().then(e=>{if(z.current===r){if(e===`no-connection`){o();return}if(e===`unreachable`){window.setTimeout(()=>{z.current===r&&B().then(e=>{if(z.current===r&&e!==`switched`&&e===`unchanged`){a();return}})},4e3);return}e!==`switched`&&a()}});let s=Date.now();s-L.current>=Kl&&(L.current=s,window.dispatchEvent(new Event(`openchamber:system-resume`)))});Vl(),Hl(ie),Q.useEffect(()=>{if(!I)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>ie(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[I,ie]),Q.useEffect(()=>(f(e),()=>f(null)),[e]),Q.useEffect(()=>{I&&M().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[I]),Q.useEffect(()=>{if(!I)return;let e=!1,t=[];return M().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`downloadComplete`,()=>{yn.getState().setOtaPhase(`pending_restart`)}),i=await n.addListener(`appReloaded`,()=>{yn.getState().setOtaPhase(`pending_restart`)}),a=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),yn.getState().setOtaPhase(`error`,`OTA update was reverted`)});if(e){r.remove(),i.remove(),a.remove();return}t.push(()=>void r.remove(),()=>void i.remove(),()=>void a.remove())}catch(e){console.warn(`[OTA] Failed to subscribe to Capgo updater events:`,e)}}),()=>{e=!0;for(let e of t)e()}},[I]),Q.useEffect(()=>c(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){dr(),te();return}or(e),De.getState().reset(),E(e=>e+1),w(e=>e+1)}),[]),Q.useEffect(()=>{if(re===`pending`)return;if(re===`connect`){j(`done`);return}if(!I||a||u()){j(`done`);return}let e=!1;return j(`attempting`),H().then(e=>e?!0:R()).catch(()=>!1).then(()=>{e||j(`done`)}),()=>{e=!0}},[re]),Q.useEffect(()=>{_(!0)},[_]),Q.useEffect(()=>{I&&!u()||n()},[x,n,I]),Ye({enabled:!I||!!u(),source:`mobileApp:recovery`}),Q.useEffect(()=>{a&&C.setDirectory(s)},[s,a]),Q.useEffect(()=>{a&&v(e.github,{force:!0})},[e.github,a,v]),Q.useEffect(()=>{if(!a||b.length===0)return;let e=!1;return(async()=>{await Promise.all(b.map(async t=>{let n=Wl(t.path);if(n)try{if(!(pn.getState().directories.get(n)?.isGitRepo??await k(()=>import(`./gitApi-CdLpItUF.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([50,1,5,2,3,4,6,7,8,34,35,14,38,39,40,9,10,11,12,13,41,42])))||e)return;await gt({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[a,b]),Q.useEffect(()=>{let e=!1;return(async()=>{let t=await p(`/health`,{method:`GET`}).catch(()=>null);if(!t||!t.ok||e)return;let n=await t.json().catch(()=>null);if(!n||e)return;let r=n.planModeExperimentalEnabled;y(r===!0||r===1||r===`1`||r===`true`)})(),()=>{e=!0}},[y]),Q.useEffect(()=>{if(!h)return;let e=window.setTimeout(()=>g(),5e3);return()=>window.clearTimeout(e)},[g,h]),Q.useEffect(()=>{if(!(!a&&(!I||u()))){O(!1);return}let e=window.setTimeout(()=>O(!0),8e3);return()=>window.clearTimeout(e)},[a,I,x,T]),dt(),Xe({enabled:!0}),nt(),cr(),xl({enabled:I&&a});let G=hc(),ae=!a&&o===`reconnecting`;if(!G)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(Pt,{width:120,height:120,isAnimated:!0})});let K=!!u();return I&&(!K||!a&&!ae)?K?(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)(Pt,{width:120,height:120,isAnimated:!D}),D?(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)(Ue,{type:`button`,variant:`outline`,onClick:()=>{i({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),w(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):A===`done`?(0,$.jsx)(Xl,{connection:V}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(Pt,{width:120,height:120,isAnimated:!0}),F?(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:[F,(0,$.jsx)(Ut,{})]})]}):null]}):!a&&!ae?D?(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)(Pt,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(Et,{children:(0,$.jsx)(Ce,{sdk:C.getSdkClient(),directory:s||``,bootstrapDirectory:!(m&&d===null),children:(0,$.jsx)(ft,{apis:e,children:(0,$.jsx)(St,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(er,{}),(0,$.jsx)(W,{}),(0,$.jsx)(ot,{embeddedBackgroundWorkEnabled:r}),(0,$.jsx)(Jn,{}),(0,$.jsx)(ti,{}),(0,$.jsx)(di,{}),(0,$.jsx)(au,{connection:V,onActiveConnectionDeleted:()=>{i({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),De.getState().reset(),w(e=>e+1)}}),(0,$.jsx)(tt,{position:`top-center`,offset:`calc(var(--oc-safe-area-top, 0px) + 16px)`}),r?(0,$.jsx)(Yn,{}):null]})})})},T)})}function su(e){e.currentTarget.style.transform=`none`}function cu(e){return e.ensureStatus}function lu(e){return e.fetchStatus}function uu(e){return e.providers}function du(e){return e.currentProviderId}function fu(e){return e.currentModelId}function pu(e){return e.getModelMetadata}function mu(e){return e.results}function hu(e){return e.loadSettings}function gu(e){return e.fetchAllQuotas}function _u(e){return e.isLoading}function vu(e){return e.displayMode}function yu(e){return e.dropdownProviderIds}function bu(e){return e.selectedModels}function xu(e){return e.timeFormatPreference}function Su(e){return[e.providerId,e]}function Cu(e){return e.providerId}function wu(e){return!e}var Tu=()=>{I(),g().then(()=>{Promise.all([h(),et()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),at(),rt(),Qe()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{Br()})};function Eu(e){tn(),Tu(),l.getState().setIsMobile(!0),Jr(),Bt(),Vt();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)(ou,{apis:r});(0,Ir.createRoot)(t).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(it,{children:(0,$.jsx)(F,{children:(0,$.jsx)(Ze,{children:(0,$.jsx)($e,{children:(0,$.jsx)(In,{children:n?i:(0,$.jsx)(ct,{children:i})})})})})})}))}export{Eu as renderMobileApp};
|
|
23
|
+
`}),t[52]=W):W=t[52];let ne;return t[53]===U?ne=t[54]:(ne=(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:[U,W]}),t[53]=U,t[54]=ne),ne},tu=e=>{let t=(0,Yr.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)(mt,{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=Ct(e.window.valueLabel,t),i=Dt(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`,Ql(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},nu=e=>{let t=(0,Yr.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:Al,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:su,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},ru=Q.memo(function(e){let t=(0,Yr.c)(88),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:u}=e,{t:d}=ee(),{git:f}=Zt(),p=Hs(i??``,a||void 0),m=p??u,h=Q.useRef(null),g=ge(i??``,a||void 0),_=hn(o),v=gn(o),y=pn(cu),b=pn(lu),x=Ae(uu),S=Ae(du),C=Ae(fu),w=Ae(pu),T;t[0]===i?T=t[1]:(T=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=T);let E=ie(T),D=Nn(mu),O=Nn(hu),k=Nn(gu),A=Nn(_u),j=Nn(vu),M=Nn(yu),N=Nn(bu),P=l(xu);wn();let F,te;t[2]!==y||t[3]!==f||t[4]!==o?(F=()=>{o&&y(o,f)},te=[y,f,o],t[2]=y,t[3]=f,t[4]=o,t[5]=F,t[6]=te):(F=t[5],te=t[6]),Q.useEffect(F,te);let I,L;t[7]!==b||t[8]!==f||t[9]!==o?(I=()=>{if(o)return be.onGitRefreshHint(e=>{Wl(e.directory)===o&&b(o,f)})},L=[b,f,o],t[7]=b,t[8]=f,t[9]=o,t[10]=I,t[11]=L):(I=t[10],L=t[11]),Q.useEffect(I,L);let R,z;t[12]===O?(R=t[13],z=t[14]):(R=()=>{O()},z=[O],t[12]=O,t[13]=R,t[14]=z),Q.useEffect(R,z);let B,V;t[15]===M?(B=t[16],V=t[17]):(B=()=>{pt(M)},V=[M],t[15]=M,t[16]=B,t[17]=V),Q.useEffect(B,V);let H,U;t[18]!==M||t[19]!==k||t[20]!==A||t[21]!==n||t[22]!==D?(H=()=>{!n||A||M.some(e=>!D.some(t=>t.providerId===e))&&k()},U=[M,k,A,n,D],t[18]=M,t[19]=k,t[20]=A,t[21]=n,t[22]=D,t[23]=H,t[24]=U):(H=t[23],U=t[24]),Q.useEffect(H,U);let W;t[25]===g?W=t[26]:(W=ms(g),t[25]=g,t[26]=W);let ne=W,re;if(t[27]!==g||t[28]!==C||t[29]!==S||t[30]!==w||t[31]!==s||t[32]!==ne||t[33]!==x||t[34]!==E){let e=ne??(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=us(n?.limit,`context`)??r?.limit?.context??0,a;t[36]===g?a=t[37]:(a=hs(g),t[36]=g,t[37]=a),re=ps({totalTokens:a,contextLimit:i,isDraft:s}),t[27]=g,t[28]=C,t[29]=S,t[30]=w,t[31]=s,t[32]=ne,t[33]=x,t[34]=E,t[35]=re}else re=t[35];let G=re,ae;t[38]!==v?.current||t[39]!==_||t[40]!==d?(ae=_===!0?v?.current?.trim()||d(`gitView.branch.detachedHead`):d(`common.unavailable`),t[38]=v?.current,t[39]=_,t[40]=d,t[41]=ae):ae=t[41];let K=ae,oe;if(t[42]!==M||t[43]!==D||t[44]!==N||t[45]!==d){let e=new Map(D.map(Su)),n;t[47]===M?n=t[48]:(n=e=>M.includes(e.id),t[47]=M,t[48]=n),oe=vn.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:Ot(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:Ot(i),subtitle:En(e),window:a})}let s=!n.ok&&n.error?n.error:r.length===0?d(`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]=d,t[46]=oe}else oe=t[46];let se=oe,q,ce;t[49]!==n||t[50]!==se?(q=()=>{!n||se.length===0||pt(se.map(Cu))},ce=[n,se],t[49]=n,t[50]=se,t[51]=q,t[52]=ce):(q=t[51],ce=t[52]),Q.useEffect(q,ce);let le;t[53]===c?le=t[54]:(le=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[53]=c,t[54]=le);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]!==le||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:[le,ue]})}),t[58]=le,t[59]=ue,t[60]=de):de=t[60];let fe;t[61]===d?fe=t[62]:(fe=d(`mobile.header.openMetadataAria`),t[61]=d,t[62]=fe);let pe;t[63]===r?pe=t[64]:(pe=()=>r(wu),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=G?.percentage??0,_e;t[66]===he?_e=t[67]:(_e=(0,$.jsx)(cs,{percentage:he}),t[66]=he,t[67]=_e);let ve;t[68]!==n||t[69]!==fe||t[70]!==pe||t[71]!==_e?(ve=(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:_e}),t[68]=n,t[69]=fe,t[70]=pe,t[71]=_e,t[72]=ve):ve=t[72];let ye;t[73]===r?ye=t[74]:(ye=()=>r(!1),t[73]=r,t[74]=ye);let xe;t[75]!==K||t[76]!==G||t[77]!==A||t[78]!==n||t[79]!==j||t[80]!==ye||t[81]!==P||t[82]!==se?(xe=(0,$.jsx)(eu,{open:n,onClose:ye,anchorRef:h,contextDisplay:G,branchLabel:K,usageGroups:se,usageDisplayMode:j,isUsageLoading:A,timeFormatPreference:P}),t[75]=K,t[76]=G,t[77]=A,t[78]=n,t[79]=j,t[80]=ye,t[81]=P,t[82]=se,t[83]=xe):xe=t[83];let Se;return t[84]!==de||t[85]!==ve||t[86]!==xe?(Se=(0,$.jsxs)($.Fragment,{children:[de,ve,xe]}),t[84]=de,t[85]=ve,t[86]=xe,t[87]=Se):Se=t[87],Se}),iu=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=ee(),[a,o]=Q.useState(!1),s=S(e=>e.currentDirectory),c=J(e=>e.currentSessionId),l=Q.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=J(l)||s,d=Wl(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=Ie(c),_=J(e=>!!e.newSessionDraft?.open),v=Q.useMemo(()=>{let e=Wl(u);return e&&Jl((h?.projectDirectory?ue(f,h.projectDirectory):null)??Fe(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=P(()=>{o(!1),e()}),C=P(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Ci,{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)(ru,{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":Al,"aria-expanded":t,"aria-haspopup":`menu`,onClick:C,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`more-2`,className:`size-5`})})]})})},au=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=ee(),r=Jt();de(),Ne();let i=l(e=>e.mobileSessionPanelOpen),a=l(e=>e.setMobileSessionPanelOpen),o=l(e=>e.isScheduledTasksDialogOpen),s=l(e=>e.activeMainTab),c=Le(),u=l(e=>e.setActiveMainTab),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),[x,C]=Q.useState(null),[w,E]=Q.useState(null),[D,O]=Q.useState(null),[k,A]=Q.useState(0),[j,M]=Q.useState(!1),[F,te]=Q.useState(!1),[I,L]=Q.useState(!1),[R,z]=Q.useState(!1),[B,V]=Q.useState(!1),[H,U]=Q.useState(!1),[W,ne]=Q.useState(`nav`),[re,ie]=Q.useState(!1),[G,ae]=Q.useState(!1),K=P(()=>ie(e=>!e)),oe=P(()=>ie(!1)),[q,ce]=Q.useState(null),le=S(e=>e.currentDirectory),ue=l(e=>e.setSettingsPage),pe=yn(e=>e.available),me=yn(e=>e.runtimeType),he=Q.useMemo(()=>Bl(),[]),ge=Q.useMemo(()=>uc(),[]),{data:_e=[],refetch:ve}=Sn(le??null,{enabled:j}),{refetch:ye}=Cn(le??null,{enabled:j}),xe=br(e=>e.setMcpDraft),Se=br(e=>e.setSelectedMcp),Ce=gn(Wl(le)||null)?.files?.length??0;Q.useEffect(()=>be.onDirectoryRequest(()=>V(!0)),[]);let we=Q.useMemo(()=>T(),[]),Te=zt()===`portrait`,[Ee,Oe]=Q.useState(we&&!Te),[ke,Ae]=Q.useState(null),je=P(e=>{if(e&&ue(e),we){ne(e?`page-content`:`nav`),L(!0);return}De.getState().setActiveTab(`settings`)}),Y=P(()=>{je(`instances`)}),Me=P(()=>{De.getState().openInstances()}),Pe=P(()=>{De.getState().closeSecondary()}),Fe=P(async()=>{if(!H){U(!0);try{let t=await dc();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`:N.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:N.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:N.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:N.error(n(`mobile.connect.scan.failed`))}}finally{U(!1)}}});en({enabled:!we,rootRoutesBlocked:i||d||p||_||y||o||j||I||R||B||re});let Ie=P(()=>{let e=!Ee;e&&Te&&Ae(null),Oe(e)}),ze=P(()=>{if(b(!1),C(null),E(null),m(!1),g(null),we){ce(null),Ae(`files`),Te&&Oe(!1);return}f(!0)}),Be=P(()=>{m(!1),g(null)}),Ve=P(e=>{let t=e.path.trim();if(t){if(b(!1),C(null),E(null),ce(null),v(!1),we){l.getState().setPendingFileFocusPath(t),Ae(`files`),Te&&Oe(!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)}}),He=l(e=>e.pendingFileFocusPath);Q.useEffect(()=>{if(He){if(we){ze();return}Ve({path:He}),l.getState().setPendingFileFocusPath(null)}},[He,we,ze,Ve]);let We=P((e=null)=>{if(b(!1),C(null),E(null),O(null),m(!1),g(null),ce(e),we){Ae(`changes`),Te&&Oe(!1);return}v(!0)}),Ge=P((e,t,n)=>{ce(null),v(!1),m(!1),g(null),C(e??null),E(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(O(r),A(e=>e+1),we){Ae(`turn-diff`),Te&&Oe(!1);return}b(!0)}),Ke=P(()=>{Ae(null),ce(null),O(null)}),qe=P(e=>{if(ke===e){Ke();return}e===`files`?ze():We()}),Je=Q.useRef(`changes`);ke&&(Je.current=ke);let[Ye,Xe]=Q.useState(!1);Q.useEffect(()=>{if(!we)return;if(ke){Xe(!0);return}let e=window.setTimeout(()=>Xe(!1),240);return()=>window.clearTimeout(e)},[ke,we]);let Ze=ke??Je.current,Qe=Rl(`left`,`openchamber.ipad.leftSidebarWidth`,jl),$e=Rl(`right`,`openchamber.ipad.rightSidebarWidth`,Ml),et=Q.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{We(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{We({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:Ge,openFile:({path:e,targetLine:t})=>{Ve({path:e,targetLine:t})},openFiles:()=>ze(),openSettings:e=>{je(e)}}),[We,Ve,ze,je,Ge]),tt=P(()=>{v(!1),ce(null)}),nt=P(()=>{b(!1),O(null)});Pc(Q.useMemo(()=>({openSessions:()=>{if(we){Oe(!0);return}De.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?ze():e===`mcp`?M(!0):e===`instances`?Y():e===`update`&&z(!0)},openChanges:({path:e,staged:t}={})=>{We(e?{path:e,staged:t===!0}:null)},openSettings:e=>{je(e)}}),[we,We,ze,Y,je]));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=se(lt,ft||le||void 0),mt=fe(lt??``),ht=mt?.type===`busy`||mt?.type===`retry`,gt=P(()=>{let e=lt;if(!e||G||ht)return;let t=ft||le||void 0;ae(!0),(async()=>{try{await r.refreshSessionTranscript(e,{directory:t}),N.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{N.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ae(!1)}})()}),_t=P(e=>{ct.current=e}),vt=P(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`)})}),yt=De(e=>e.secondary?.kind??null),bt=!we&&(yt===`chat`||yt===`draft`);Q.useEffect(()=>{!we&&!bt&&ie(!1)},[we,bt]),Q.useEffect(()=>{ie(!1)},[lt]),$c(it,{onSwitch:_t,onProgress:vt},we||bt);let xt=we&&s===`assistant`||!we&&!bt||i||d||p||_||y||o||j||I||R||B||re;yl(it,{onOpen:P(()=>{Lt(Rt)?.finish(`commit`)}),onPreviewStart:P(()=>{Lt(Rt)?.begin(`present`)}),onPreviewCancel:P(()=>{Lt(Rt)?.finish(`cancel`)}),onProgress:P(e=>{e!==null&&Lt(Rt)?.update(e)}),disabled:xt},we||bt),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 St=P(e=>{rt.current=e});Ul(P(()=>re?(ie(!1),!0):B?(V(!1),!0):o?(window.dispatchEvent(new Event(`oc:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):nn.backImmediately(`overlay`)?!0:p?(Be(),!0):d?(f(!1),!0):y?(nt(),!0):_?(tt(),!0):j?(M(!1),!0):I?(L(!1),!0):R?(z(!1),!0):nn.requestAnimatedBack(`root`)||rt.current?.()?!0:s===`assistant`?(u(`chat`),!0):pt?(ut(pt.id,pt.directory),!0):!1));let Ct=pe&&(me===`desktop`||me===`web`),wt=P(()=>{let e=`new-mcp-server`,t=e,n=1;for(;_e.some(e=>e.name===t);)t=`${e}-${n}`,n+=1;xe({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),Se(t),M(!1),je(`mcp`)}),Tt=P(()=>{if(F)return;te(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([ye(),ve(),e]).finally(()=>te(!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){u(`chat`),Dt();return}De.getState().openDraft()}}];return we||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>ze()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:Ce,onSelect:()=>We()}),e.push({key:`mcp`,iconNode:(0,$.jsx)(xn,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>M(!0)}),Ct&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>z(!0)}),we&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>je()}),lt&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:G||ht,spinning:G,onSelect:gt}),e},[lt,Ce,we,ht,G,We,ze,Dt,je,gt,u,Ct,n]);return(0,$.jsxs)(Kt,{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:Qe.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?Qe.width:0,minWidth:Ee?Qe.width:0,maxWidth:Ee?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":!Ee,"data-page-scroll-lock":`true`,children:[Ee?(0,$.jsx)(zl,{side:`left`,isResizing:Qe.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),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`,!Ee&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(Et,{children:(0,$.jsx)(Ea,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&Te&&Oe(!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)(iu,{onOpenSessions:()=>Ie(),menuOpen:re,onToggleMenu:K,surfaceShortcuts:{activePanel:ke===`turn-diff`?`changes`:ke,changesDirty:Ce>0,onToggleFiles:()=>qe(`files`),onToggleChanges:()=>qe(`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)(Et,{children:s===`assistant`?(0,$.jsx)(Mr,{}):(0,$.jsx)(Bn,{})})})]})]}):(0,$.jsx)(Xo,{className:`min-h-0 flex-1`,onAddProject:()=>V(!0),onScanQr:he&&ge?()=>{Fe()}:void 0,onSwitchInstance:he?Me:void 0,onEnableAssistants:()=>{je(`assistants`)},instancesPage:he?(0,$.jsx)(Zl,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,instancesSecondaryPage:he?(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)(Re,{title:n(`mobile.settings.switchInstance`),backAriaLabel:n(`header.actions.backAria`),onBack:Pe}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[var(--oc-mobile-page-inline-inset)]`,children:(0,$.jsx)(On,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(Zl,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:pt?{id:pt.id,directory:pt.directory}:null,registerSecondaryBackHandler:St,scheduledContent:(e,t)=>(0,$.jsx)($n,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(Ks,{sessionId:e.sessionId,directory:e.directory,onBack:()=>{oe(),nn.requestAnimatedBack(`root`)},onOpenMenu:K,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)(Et,{children:(0,$.jsx)(Bn,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:e.sessionId||null,directory:e.directory,viewKey:e.viewKey}})})})]})})})}),we?(0,$.jsxs)(`aside`,{ref:$e.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`,!ke&&`border-l-0`),style:{width:ke?$e.width:0,minWidth:ke?$e.width:0,maxWidth:ke?$e.width:0,"--oc-ipad-sidebar-width":`${$e.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:$e.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!ke,"data-page-scroll-lock":`true`,children:[ke?(0,$.jsx)(zl,{side:`right`,isResizing:$e.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:$e.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`,$e.isResizing&&`pointer-events-none`,!ke&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:Ye?(0,$.jsx)(Et,{children:Ze===`files`?(0,$.jsx)(qi,{onClose:Ke}):Ze===`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)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ke,"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)(_r,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:x,sessionId:w,targetFilePath:D,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)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ke,"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)(_r,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:q.path,targetLine:q.targetLine??null,toolPatches:q.toolPatches,singleFileView:q.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(Fi,{onClose:Ke,initialDiffPath:q?.path??null,initialDiffStaged:q?.staged===!0,initialDiffTargetLine:q?.targetLine??null})}):null})]}):null,(0,$.jsx)(ir,{open:B,onOpenChange:V,forceMobile:!0}),(0,$.jsx)(nu,{open:re,onClose:()=>ie(!1),items:Ot,rightOffset:we&&ke?$e.width:0}),(0,$.jsx)(ur,{}),d?(0,$.jsx)(It,{id:Tl,open:d,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)(Et,{children:(0,$.jsx)(qi,{onClose:()=>f(!1)})})}):null,p&&h?(0,$.jsx)(It,{id:wl,open:p,onOpenChange:e=>{e||Be()},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)(Et,{children:(0,$.jsx)(qi,{onClose:Be,initialFilePath:h.path,directFilePreview:!0,hideFileHeader:!0},h.path)})}):null,(0,$.jsx)(It,{id:Cl,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)(Et,{children:(0,$.jsx)(_r,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:x,sessionId:w,targetFilePath:D,navigationRequestKey:k,flushContent:!0})})}),_&&q?(0,$.jsx)(It,{id:Sl,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)(Et,{children:q.toolPatches?.length?(0,$.jsx)(_r,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:q.path,targetLine:q.targetLine??null,toolPatches:q.toolPatches,singleFileView:q.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(Fi,{initialDiffPath:q.path,initialDiffStaged:q.staged,initialDiffTargetLine:q.targetLine??null,hideDiffHeader:!0})})}):_?(0,$.jsx)(It,{id:El,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)(Et,{children:(0,$.jsx)(Fi,{onClose:tt,initialDiffPath:q?.path??null,initialDiffStaged:q?.staged===!0,initialDiffTargetLine:q?.targetLine??null})})}):null,j?(0,$.jsx)(It,{id:Dl,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)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:wt,"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)(Ue,{type:`button`,variant:`ghost`,size:`icon`,onClick:Tt,disabled:F,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`refresh`,className:X(`size-5`,F&&`animate-spin`)})})]}),ariaLabel:n(`mcpDropdown.title`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Et,{children:(0,$.jsx)(Un,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,I&&we?(0,$.jsx)(It,{id:Ol,open:I,onOpenChange:e=>{e||L(!1)},ariaLabel:n(`mobile.menu.settings`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Et,{children:(0,$.jsx)(Tr,{forceMobile:!0,isWindowed:!0,initialMobileStage:W,visiblePageSlugs:[...kn],onClose:()=>L(!1),mobileInstancesPage:he?(0,$.jsx)(Zl,{connection:e,onConnect:()=>L(!1),onActiveConnectionDeleted:t}):void 0})})}):null,R?(0,$.jsx)(It,{id:kl,open:R,onOpenChange:e=>{e||z(!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)(Et,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(xr,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(vr,{enabled:he&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(Et,{children:(0,$.jsx)(ar,{})})]})};function ou({apis:e}){let{t}=ee(),n=Ae(e=>e.initializeApp),r=Ae(e=>e.isInitialized),a=Ae(e=>e.isConnected),o=Ae(e=>e.connectionPhase),s=S(e=>e.currentDirectory),d=J(e=>e.currentSessionId),m=J(e=>!!e.newSessionDraft?.open),h=J(e=>e.error),g=J(e=>e.clearError),_=l(e=>e.setIsMobile),v=An(e=>e.refreshStatus),y=qt(e=>e.setPlanModeEnabled),b=Me(e=>e.projects),[x,w]=Q.useState(0),[T,E]=Q.useState(0),[D,O]=Q.useState(!1),[A,j]=Q.useState(`pending`),F=Q.useMemo(()=>ne(),[]),[,te]=Q.useReducer(e=>e+1,0),I=Q.useMemo(()=>Bl(),[]),L=Q.useRef(0),z=Q.useRef(0),V=U(()=>{j(`done`),w(e=>e+1)});Fc(P(e=>{V.redeemPairingConnection(e)}));let re=Ic({ready:I&&a&&r});Q.useEffect(()=>{!V.error||!u()||N.error(V.error)},[V.error]);let ie=P(()=>{let t=u(),r=z.current+1;if(z.current=r,!t){R();return}let a=()=>{n(),v(e.github,{force:!0}),Ae.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},o=()=>{i({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),w(e=>e+1)};B().then(e=>{if(z.current===r){if(e===`no-connection`){o();return}if(e===`unreachable`){window.setTimeout(()=>{z.current===r&&B().then(e=>{if(z.current===r&&e!==`switched`&&e===`unchanged`){a();return}})},4e3);return}e!==`switched`&&a()}});let s=Date.now();s-L.current>=Kl&&(L.current=s,window.dispatchEvent(new Event(`openchamber:system-resume`)))});Vl(),Hl(ie),Q.useEffect(()=>{if(!I)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>ie(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[I,ie]),Q.useEffect(()=>(f(e),()=>f(null)),[e]),Q.useEffect(()=>{I&&M().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[I]),Q.useEffect(()=>{if(!I)return;let e=!1,t=[];return M().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`downloadComplete`,()=>{yn.getState().setOtaPhase(`pending_restart`)}),i=await n.addListener(`appReloaded`,()=>{yn.getState().setOtaPhase(`pending_restart`)}),a=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),yn.getState().setOtaPhase(`error`,`OTA update was reverted`)});if(e){r.remove(),i.remove(),a.remove();return}t.push(()=>void r.remove(),()=>void i.remove(),()=>void a.remove())}catch(e){console.warn(`[OTA] Failed to subscribe to Capgo updater events:`,e)}}),()=>{e=!0;for(let e of t)e()}},[I]),Q.useEffect(()=>c(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){dr(),te();return}or(e),De.getState().reset(),E(e=>e+1),w(e=>e+1)}),[]),Q.useEffect(()=>{if(re===`pending`)return;if(re===`connect`){j(`done`);return}if(!I||a||u()){j(`done`);return}let e=!1;return j(`attempting`),H().then(e=>e?!0:R()).catch(()=>!1).then(()=>{e||j(`done`)}),()=>{e=!0}},[re]),Q.useEffect(()=>{_(!0)},[_]),Q.useEffect(()=>{I&&!u()||n()},[x,n,I]),Ye({enabled:!I||!!u(),source:`mobileApp:recovery`}),Q.useEffect(()=>{a&&C.setDirectory(s)},[s,a]),Q.useEffect(()=>{a&&v(e.github,{force:!0})},[e.github,a,v]),Q.useEffect(()=>{if(!a||b.length===0)return;let e=!1;return(async()=>{await Promise.all(b.map(async t=>{let n=Wl(t.path);if(n)try{if(!(pn.getState().directories.get(n)?.isGitRepo??await k(()=>import(`./gitApi-4LIdr-v1.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([50,1,5,2,3,4,6,7,8,34,35,14,38,39,40,9,10,11,12,13,41,42])))||e)return;await gt({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[a,b]),Q.useEffect(()=>{let e=!1;return(async()=>{let t=await p(`/health`,{method:`GET`}).catch(()=>null);if(!t||!t.ok||e)return;let n=await t.json().catch(()=>null);if(!n||e)return;let r=n.planModeExperimentalEnabled;y(r===!0||r===1||r===`1`||r===`true`)})(),()=>{e=!0}},[y]),Q.useEffect(()=>{if(!h)return;let e=window.setTimeout(()=>g(),5e3);return()=>window.clearTimeout(e)},[g,h]),Q.useEffect(()=>{if(!(!a&&(!I||u()))){O(!1);return}let e=window.setTimeout(()=>O(!0),8e3);return()=>window.clearTimeout(e)},[a,I,x,T]),dt(),Xe({enabled:!0}),nt(),cr(),xl({enabled:I&&a});let G=hc(),ae=!a&&o===`reconnecting`;if(!G)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(Pt,{width:120,height:120,isAnimated:!0})});let K=!!u();return I&&(!K||!a&&!ae)?K?(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)(Pt,{width:120,height:120,isAnimated:!D}),D?(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)(Ue,{type:`button`,variant:`outline`,onClick:()=>{i({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),w(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):A===`done`?(0,$.jsx)(Xl,{connection:V}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(Pt,{width:120,height:120,isAnimated:!0}),F?(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:[F,(0,$.jsx)(Ut,{})]})]}):null]}):!a&&!ae?D?(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)(Pt,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(Et,{children:(0,$.jsx)(Ce,{sdk:C.getSdkClient(),directory:s||``,bootstrapDirectory:!(m&&d===null),children:(0,$.jsx)(ft,{apis:e,children:(0,$.jsx)(St,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(er,{}),(0,$.jsx)(W,{}),(0,$.jsx)(ot,{embeddedBackgroundWorkEnabled:r}),(0,$.jsx)(Jn,{}),(0,$.jsx)(ti,{}),(0,$.jsx)(di,{}),(0,$.jsx)(au,{connection:V,onActiveConnectionDeleted:()=>{i({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),De.getState().reset(),w(e=>e+1)}}),(0,$.jsx)(tt,{position:`top-center`,offset:`calc(var(--oc-safe-area-top, 0px) + 16px)`}),r?(0,$.jsx)(Yn,{}):null]})})})},T)})}function su(e){e.currentTarget.style.transform=`none`}function cu(e){return e.ensureStatus}function lu(e){return e.fetchStatus}function uu(e){return e.providers}function du(e){return e.currentProviderId}function fu(e){return e.currentModelId}function pu(e){return e.getModelMetadata}function mu(e){return e.results}function hu(e){return e.loadSettings}function gu(e){return e.fetchAllQuotas}function _u(e){return e.isLoading}function vu(e){return e.displayMode}function yu(e){return e.dropdownProviderIds}function bu(e){return e.selectedModels}function xu(e){return e.timeFormatPreference}function Su(e){return[e.providerId,e]}function Cu(e){return e.providerId}function wu(e){return!e}var Tu=()=>{I(),g().then(()=>{Promise.all([h(),et()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),at(),rt(),Qe()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{Br()})};function Eu(e){tn(),Tu(),l.getState().setIsMobile(!0),Jr(),Bt(),Vt();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)(ou,{apis:r});(0,Ir.createRoot)(t).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(it,{children:(0,$.jsx)(F,{children:(0,$.jsx)(Ze,{children:(0,$.jsx)($e,{children:(0,$.jsx)(In,{children:n?i:(0,$.jsx)(ct,{children:i})})})})})})}))}export{Eu as renderMobileApp};
|