@openchamber/web 1.12.2 → 1.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{MarkdownRendererImpl-2INOOMmV.js → MarkdownRendererImpl-C2snGm6y.js} +1 -1
- package/dist/assets/{MultiRunWindow-BovvaCrr.js → MultiRunWindow-DXXoYCBh.js} +1 -1
- package/dist/assets/{NewWorktreeDialog-6y6rHfOQ.js → NewWorktreeDialog-C6394QE9.js} +1 -1
- package/dist/assets/OnboardingScreen-CLXmHHBW.js +1 -0
- package/dist/assets/{SessionSwitcherDropdown-DSXsR7zB.js → SessionSwitcherDropdown-BMN9gaXo.js} +1 -1
- package/dist/assets/{SettingsWindow-Dll7W_Kd.js → SettingsWindow-DXEjjH2f.js} +1 -1
- package/dist/assets/{TerminalView-D_ktT_L5.js → TerminalView-CePdcScA.js} +1 -1
- package/dist/assets/{es-9Cy-lgBh.js → es-rCA6AcBs.js} +1 -1
- package/dist/assets/{ko-BxmPoeb2.js → ko-CTiirGAp.js} +1 -1
- package/dist/assets/{main-BpZQobwD.js → main-D1IN8sAs.js} +2 -2
- package/dist/assets/{main-D8KFwoUt.js → main-DIwL7PaU.js} +46 -46
- package/dist/assets/{miniChat-BdEth0Oc.js → miniChat-DXW_W4_n.js} +2 -2
- package/dist/assets/{mobile-BxWzNO1C.js → mobile-DWyy0wq-.js} +2 -2
- package/dist/assets/{pl-J7oKZUR2.js → pl-CwJAYYhT.js} +1 -1
- package/dist/assets/{pt-BR-p6gRuJwx.js → pt-BR-xndordtt.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-MNKYhIaT.js → renderElectronMiniChatApp-BmvjGDb_.js} +2 -2
- package/dist/assets/{renderMobileApp-DpYY7X9v.js → renderMobileApp-1BEmeUF9.js} +3 -3
- package/dist/assets/{uk-BOvMb8eG.js → uk-C52rE_cP.js} +1 -1
- package/dist/assets/{useAppFontEffects-DEZpweZZ.js → useAppFontEffects-hYm-4PtP.js} +4 -4
- package/dist/assets/{zh-CN-Cv0tBxN1.js → zh-CN-B7IfGwyh.js} +1 -1
- package/dist/assets/{zh-TW-CS7R6Ak3.js → zh-TW-DiO_1_-_.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/mini-chat.html +1 -1
- package/dist/mobile.html +1 -1
- package/package.json +1 -1
- package/server/index.js +0 -15
- package/server/lib/fs/routes.js +28 -2
- package/server/lib/opencode/env-runtime.js +20 -158
- package/server/lib/opencode/env-runtime.test.js +38 -11
- package/server/lib/opencode/lifecycle.js +5 -24
- package/server/lib/opencode/lifecycle.test.js +0 -2
- package/server/lib/opencode/network-runtime.js +1 -1
- package/server/lib/opencode/routes.js +1 -1
- package/dist/assets/OnboardingScreen-B1Ft9kmW.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useAppFontEffects-
|
|
2
|
-
import{R as u,j as t,P as Fe,c as re,U as Gt,W as Vt,K as Xe,d as Cs,p as Ut,B as Es,Q as As,r as Ps,a as Ds,F as Rs,Z as _s,b as mt,e as Ht,f as Is,u as Kt,g as Je,s as qt,i as Yt,k as Jt,l as ut,D as Qt,m as Xt,S as Zt,v as es,n as ts,o as ss,C as rs,M as ns,q as dt,J as os,t as zs,w as Nt,x as ht,y as Ct,V as Ms,_ as Ts,z as Fs,O as Bs,A as $s,E as Os,G as Ws,H as Ls}from"./vendor-.bun-TPgXvEwq.js";import{g as Gs,r as Vs,a as Us,b as Hs}from"./index-D9t9eCUC.js";import{u as ie,a as gt,b as pt,c as is,d as Ks,e as qs,f as ve,t as Q,s as Ys,g as Js,h as Qs,i as Xs,j as Zs,k as ls,B as ge,l as _e,S as Ee,m as Z,I as bt,n as er,o as Et,p as xt,q as At,F as tr,r as Pt,v as sr,J as rr,w as as,x as cs,y as je,z as Ie,A as nr,M as or,C as ir,D as me,P as us,E as ds,G as fs,H as ze,K as lr,L as ar,N as cr,O as ur,Q as ms,R as Ce,T as dr,U as fr,V as mr,W as Dt,X as Rt,Y as hr,Z as gr,_ as pr,$ as We,a0 as br,a1 as xr,a2 as yr,a3 as vr,a4 as jr,a5 as wr,a6 as kr,a7 as Sr,a8 as Nr,a9 as Cr,aa as Er,ab as Ar,ac as Pr,ad as Dr,ae as Rr,af as _r,ag as Ir,ah as zr}from"./useAppFontEffects-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useAppFontEffects-hYm-4PtP.js","assets/vendor-.bun-TPgXvEwq.js","assets/vendor--V65Sl9C2.css","assets/index-D9t9eCUC.js","assets/index-BDH6F8f2.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{R as u,j as t,P as Fe,c as re,U as Gt,W as Vt,K as Xe,d as Cs,p as Ut,B as Es,Q as As,r as Ps,a as Ds,F as Rs,Z as _s,b as mt,e as Ht,f as Is,u as Kt,g as Je,s as qt,i as Yt,k as Jt,l as ut,D as Qt,m as Xt,S as Zt,v as es,n as ts,o as ss,C as rs,M as ns,q as dt,J as os,t as zs,w as Nt,x as ht,y as Ct,V as Ms,_ as Ts,z as Fs,O as Bs,A as $s,E as Os,G as Ws,H as Ls}from"./vendor-.bun-TPgXvEwq.js";import{g as Gs,r as Vs,a as Us,b as Hs}from"./index-D9t9eCUC.js";import{u as ie,a as gt,b as pt,c as is,d as Ks,e as qs,f as ve,t as Q,s as Ys,g as Js,h as Qs,i as Xs,j as Zs,k as ls,B as ge,l as _e,S as Ee,m as Z,I as bt,n as er,o as Et,p as xt,q as At,F as tr,r as Pt,v as sr,J as rr,w as as,x as cs,y as je,z as Ie,A as nr,M as or,C as ir,D as me,P as us,E as ds,G as fs,H as ze,K as lr,L as ar,N as cr,O as ur,Q as ms,R as Ce,T as dr,U as fr,V as mr,W as Dt,X as Rt,Y as hr,Z as gr,_ as pr,$ as We,a0 as br,a1 as xr,a2 as yr,a3 as vr,a4 as jr,a5 as wr,a6 as kr,a7 as Sr,a8 as Nr,a9 as Cr,aa as Er,ab as Ar,ac as Pr,ad as Dr,ae as Rr,af as _r,ag as Ir,ah as zr}from"./useAppFontEffects-hYm-4PtP.js";import{S as Mr,C as Tr,a as Fr,P as Br,b as $r,D as Or,N as Wr,u as Lr,c as Gr,d as Vr,e as Ur}from"./NewWorktreeDialog-C6394QE9.js";import"./mobileLayoutPreference-Dio-WWkI.js";const Hr=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/g,""),Kr=s=>{const e=s.index?.trim();return!!(e&&e!=="?")},qr=s=>{const e=s.working_dir?.trim(),r=s.index?.trim();return!!(e||r==="?")},_t=(s,e)=>e?`${s}\0staged`:s,Yr=({onClose:s,initialDiffPath:e,initialDiffStaged:r=!1})=>{const{t:o}=ie(),{git:n}=gt(),i=Hr(pt()??null),a=is(i||null),h=Ks(i||null),c=qs(i||null),d=ve(y=>y.setActiveDirectory),f=ve(y=>y.ensureAll),g=ve(y=>y.fetchStatus),b=ve(y=>y.fetchBranches),v=ve(y=>y.prefetchDiffs),S=ve(y=>y.getDiff),m=ve(y=>y.setDiff),[p,j]=u.useState(()=>e?{type:"diff",path:e,staged:r}:{type:"list"});u.useEffect(()=>{e&&j(y=>y.type==="diff"&&y.path===e&&y.staged===r?y:{type:"diff",path:e,staged:r})},[e,r]);const[A,P]=u.useState(null),[N,_]=u.useState(null),[z,w]=u.useState(""),[x,M]=u.useState(new Set),[F,I]=u.useState(!1),[L,T]=u.useState(!1),[G,U]=u.useState([]),[k,$]=u.useState([]),[O,H]=u.useState([]),[q,R]=u.useState(null),[V,Y]=u.useState(null),[se,de]=u.useState(0),te=u.useMemo(()=>{const y=a?.files??[],C=new Map;for(const W of y)C.set(W.path,W);return Array.from(C.values()).sort((W,ce)=>W.path.localeCompare(ce.path))},[a?.files]),ae=u.useMemo(()=>te.filter(Kr),[te]),Ne=u.useMemo(()=>te.filter(qr),[te]),ye=u.useMemo(()=>{if(O.length>0)return O;const y=a?.tracking?.includes("/")?a.tracking.split("/")[0]:null;return y||q?[{name:y||"origin",fetchUrl:q??"",pushUrl:q??""}]:[]},[q,O,a?.tracking]),Ze=ve(u.useCallback(y=>!i||p.type!=="diff"?null:y.directories.get(i)?.diffCache.get(_t(p.path,p.staged))??null,[i,p])),Ae=u.useMemo(()=>p.type!=="diff"?null:te.find(y=>y.path===p.path)??null,[te,p]),ee=u.useCallback(async(y=!0)=>{if(i)try{await Promise.all([g(i,n),b(i,n)])}catch(C){y&&Q.error(C instanceof Error?C.message:o("gitView.toast.refreshRepositoryFailed"))}},[i,b,g,n,o]),he=u.useCallback(async()=>{if(!i){H([]),R(null);return}try{const[y,C]=await Promise.all([n.getRemotes(i).catch(()=>[]),n.getRemoteUrl?n.getRemoteUrl(i).catch(()=>null):Promise.resolve(null)]);H(y),R(C)}catch{H([]),R(null)}},[i,n]);u.useEffect(()=>{i&&(d(i),f(i,n))},[i,f,n,d]),u.useEffect(()=>{he()},[he]),u.useEffect(()=>{if(!i||te.length===0)return;const y=Array.from(new Set([...ae.map(W=>W.path),...k,...te.slice(0,20).map(W=>W.path)])).filter(Boolean);if(y.length===0)return;const C=window.setTimeout(()=>{v(i,n,y,{maxFiles:40})},120);return()=>window.clearTimeout(C)},[te,i,n,v,ae,k]),u.useEffect(()=>{if(p.type!=="diff"){Y(null);return}const y=_t(p.path,p.staged);if(!i||S(i,y)){Y(null);return}let C=!1;return Y(null),n.getGitFileDiff(i,{path:p.path,staged:p.staged||void 0}).then(W=>{C||m(i,y,{original:W.original??"",modified:W.modified??"",isBinary:W.isBinary})}).catch(W=>{C||Y(W instanceof Error?W.message:String(W))}),()=>{C=!0}},[i,se,S,n,p,m]);const oe=async(y,C)=>{if(i){P(y);try{const W=ce=>{const we=`${ce.name}/`,$e=a?.tracking?.startsWith(we)?a.tracking.slice(we.length):void 0;return{remote:ce.name,branch:$e,rebase:!0}};if(y==="fetch"){if(!C)throw new Error(o("mobile.changes.noRemote"));await n.gitFetch(i,{remote:C.name}),Q.success(o("gitView.toast.fetchedFromRemote",{name:C.name}))}else if(y==="sync"){if(!C)throw new Error(o("mobile.changes.noRemote"));await n.gitFetch(i,{remote:C.name});const ce=await n.getGitStatus(i);if((ce.behind??0)>0){if((ce.files?.length??0)>0){Q.error(o("gitView.toast.commitOrStashBeforeSync"));return}await n.gitPull(i,W(C))}((await n.getGitStatus(i)).ahead??0)>0&&await n.gitPush(i),Q.success(o("gitView.toast.alreadyUpToDate"))}await ee(!1),await he()}catch(W){Q.error(W instanceof Error?W.message:o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}))}finally{P(null)}}},pe=u.useCallback(async(y,C)=>{if(!(!i||y.length===0))try{C==="stage"?y.length>1?await Ys(i,y):await Js(i,y[0]):y.length>1?await Qs(i,y):await Xs(i,y[0]),await ee(!1)}catch(W){Q.error(W instanceof Error?W.message:o(C==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[i,ee,o]),Pe=u.useCallback((y,C=!1)=>{j({type:"diff",path:y,staged:C})},[]),Be=u.useCallback(async y=>{if(i){M(C=>new Set(C).add(y));try{await n.revertGitFile(i,y),Q.success(o("gitView.toast.revertedFile",{path:y})),await ee(!1)}catch(C){Q.error(C instanceof Error?C.message:o("gitView.toast.revertFailed"))}finally{M(C=>{const W=new Set(C);return W.delete(y),W})}}},[i,n,ee,o]),et=u.useCallback(async y=>{if(!i||y.length===0||F)return;const C=Array.from(new Set(y));I(!0),M(new Set(C));try{await Promise.all(C.map(W=>n.revertGitFile(i,W))),await ee(!1),Q.success(C.length===1?o("gitView.toast.revertedFilesSingle",{count:C.length}):o("gitView.toast.revertedFilesPlural",{count:C.length}))}catch(W){Q.error(W instanceof Error?W.message:o("gitView.toast.revertFailed"))}finally{M(new Set),I(!1)}},[i,n,F,ee,o]),tt=u.useCallback(y=>{const C=y.map(W=>W.trim()).filter(Boolean);if(C.length===0){U([]);return}w(W=>`${W.trim()}${W.trim()?`
|
|
3
3
|
|
|
4
4
|
`:""}${C.join(`
|
|
5
5
|
`)}`.trim()),U([])},[]),Ue=u.useCallback(async()=>{if(!i)return;const y=ae.map(C=>C.path).sort();if(y.length===0){Q.error(o("gitView.toast.selectFileToDescribe"));return}T(!0);try{const{message:C}=await Zs(i,y);w(C.subject?.trim()??""),U(Array.isArray(C.highlights)?C.highlights:[])}catch(C){Q.error(C instanceof Error?C.message:o("gitView.toast.generateCommitMessageFailed"))}finally{T(!1)}},[i,ae,o]),He=async(y={})=>{if(!i)return;if(!z.trim()){Q.error(o("gitView.toast.enterCommitMessage"));return}const C=ae.map(W=>W.path).sort();if(C.length===0){Q.error(o("gitView.toast.selectFileToCommit"));return}_(y.pushAfter?"commitAndPush":"commit");try{if(await n.createGitCommit(i,z.trim(),{files:C}),Q.success(o("gitView.toast.commitCreated")),w(""),U([]),y.pushAfter){const W=a?.tracking?.split("/")[0],ce=ye.find(nt=>nt.name===W)??ye[0];if(!ce)throw new Error(o("mobile.changes.noRemote"));P("sync");const we=`${ce.name}/`,$e=a?.tracking?.startsWith(we)?a.tracking.slice(we.length):void 0;await n.gitFetch(i,{remote:ce.name}),((await n.getGitStatus(i)).behind??0)>0&&await n.gitPull(i,{remote:ce.name,branch:$e,rebase:!0}),((await n.getGitStatus(i)).ahead??0)>0&&await n.gitPush(i),await ee(!1),await he()}else await ee(!1)}catch(W){Q.error(W instanceof Error?W.message:o("gitView.toast.createCommitFailed"))}finally{_(null),y.pushAfter&&P(null)}},st=u.useMemo(()=>{const y=[];return ae.length>0&&y.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:ae,actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:C=>o("gitView.changes.unstageFileAria",{path:C}),onActionFile:C=>{pe([C],"unstage")},onActionAll:C=>{pe(C,"unstage")},onViewDiff:C=>Pe(C,!0),onRevertFile:Be,showRevertActions:!1,accent:!0}),Ne.length>0&&y.push({id:"unstaged",title:o("gitView.changes.title"),entries:Ne,actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:C=>o("gitView.changes.stageFileAria",{path:C}),onActionFile:C=>{pe([C],"stage")},onActionAll:C=>{pe(C,"stage")},onViewDiff:C=>Pe(C,!1),onRevertFile:Be}),y},[Be,Pe,pe,ae,o,Ne]);return i?c&&h===null?t.jsx(ke,{loading:!0,message:o("gitView.loading.checkingRepository")}):h===!1?t.jsx(ke,{icon:!0,message:o("gitView.empty.notGitRepository"),description:o("gitView.empty.notGitRepositoryDescription")}):p.type==="diff"?t.jsx(Jr,{path:p.path,diff:Ze,fileExists:!!Ae,error:V,onBack:()=>j({type:"list"}),onRetry:()=>de(y=>y+1)}):t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Fe,{className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:o("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:a?.current||i})]}),t.jsx(Mr,{syncAction:A,remotes:ye,onFetch:y=>{oe("fetch",y)},onSync:y=>{oe("sync",y)},disabled:N!==null||c,aheadCount:a?.ahead??0,behindCount:a?.behind??0,trackingRemoteName:a?.tracking?.split("/")[0],hasUncommittedChanges:te.length>0})]}),te.length>0?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-4 pt-4",children:t.jsx(Tr,{groups:st,diffStats:a?.diffStats,revertingPaths:x,onRevertAll:et,isRevertingAll:F,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:$})}),t.jsx("div",{className:"shrink-0 border-t border-border/50 px-4 pb-4 pt-3",children:t.jsx(Fr,{stagedCount:ae.length,commitMessage:z,onCommitMessageChange:w,generatedHighlights:G,onInsertHighlights:tt,onGenerateMessage:Ue,isGeneratingMessage:L,onCommit:()=>{He({pushAfter:!1})},onCommitAndPush:()=>{He({pushAfter:!0})},commitAction:N,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(ke,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})})]}):t.jsx(ke,{message:o("gitView.empty.selectSessionOrDirectory")})},ke=s=>{const e=re.c(13),{message:r,description:o,loading:n,icon:i}=s,a=n===void 0?!1:n,h=i===void 0?!1:i;let c;e[0]!==a?(c=a?t.jsx(Gt,{className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=a,e[1]=c):c=e[1];let d;e[2]!==h?(d=h?t.jsx(Vt,{className:"size-6 text-muted-foreground"}):null,e[2]=h,e[3]=d):d=e[3];let f;e[4]!==r?(f=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:r}),e[4]=r,e[5]=f):f=e[5];let g;e[6]!==o?(g=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[6]=o,e[7]=g):g=e[7];let b;return e[8]!==c||e[9]!==d||e[10]!==f||e[11]!==g?(b=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[c,d,f,g]})}),e[8]=c,e[9]=d,e[10]=f,e[11]=g,e[12]=b):b=e[12],b},Jr=s=>{const e=re.c(24),{path:r,diff:o,fileExists:n,error:i,onBack:a,onRetry:h}=s,{t:c}=ie();let d;e[0]!==r?(d=ls(r)||"text",e[0]=r,e[1]=d):d=e[1];const f=d;let g;e[2]!==c?(g=c("header.actions.backAria"),e[2]=c,e[3]=g):g=e[3];let b;e[4]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(Xe,{className:"size-5"}),e[4]=b):b=e[4];let v;e[5]!==a||e[6]!==g?(v=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":g,onClick:a,children:b}),e[5]=a,e[6]=g,e[7]=v):v=e[7];let S;e[8]!==r?(S=t.jsx("div",{className:"min-w-0 flex-1 px-2",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:r})}),e[8]=r,e[9]=S):S=e[9];let m;e[10]!==v||e[11]!==S?(m=t.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:[v,S]}),e[10]=v,e[11]=S,e[12]=m):m=e[12];let p;e[13]!==o||e[14]!==i||e[15]!==n||e[16]!==f||e[17]!==h||e[18]!==r||e[19]!==c?(p=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:n?i?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:c("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}),t.jsx(ge,{type:"button",size:"sm",variant:"outline",onClick:h,children:c("diffView.actions.retry")})]})}):o?o.isBinary?t.jsx(ke,{icon:!0,message:c("diffView.binary.unavailable")}):_e(r)?t.jsx(ke,{icon:!0,message:c("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(Ee,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(Br,{original:o.original,modified:o.modified,language:f,fileName:r,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):t.jsx(ke,{loading:!0,message:c("diffView.state.loadingDiff")}):t.jsx(ke,{icon:!0,message:c("mobile.changes.diffDetail.missingTitle"),description:c("mobile.changes.diffDetail.missingDescription")})}),e[13]=o,e[14]=i,e[15]=n,e[16]=f,e[17]=h,e[18]=r,e[19]=c,e[20]=p):p=e[20];let j;return e[21]!==m||e[22]!==p?(j=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[m,p]}),e[21]=m,e[22]=p,e[23]=j):j=e[23],j},It=25e4,Me=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/g,""),Se=s=>{const e=Me(s);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},Qr=s=>{const e=Me(s);if(!e||e==="/")return null;const r=e.lastIndexOf("/");return r<=0?e.startsWith("/")?"/":null:e.slice(0,r)},Xr=(s,e)=>{const r=Me(s),o=Me(e);return!o||r===o?Se(r):r.startsWith(`${o}/`)?r.slice(o.length+1):r},Zr=s=>{if(typeof s!="number"||!Number.isFinite(s)||s<0)return"";if(s<1024)return`${s} B`;const e=["KB","MB","GB"];let r=s/1024;for(const o of e){if(r<1024||o===e[e.length-1])return`${r.toFixed(r>=10?0:1)} ${o}`;r/=1024}return""},en=s=>s.toLowerCase().endsWith(".svg")?"":Gs().authenticatedAsset("/api/fs/raw",{path:s}),tn=s=>/\.(md|mdx|markdown)$/i.test(s),sn=s=>/\.(json|jsonc)$/i.test(s),rn=({onClose:s})=>{const{t:e}=ie(),{files:r}=gt(),o=Me(pt()??null),[n,i]=u.useState(()=>({type:"browser",directory:o})),[a,h]=u.useState([]),[c,d]=u.useState(!1),[f,g]=u.useState(null),[b,v]=u.useState(""),[S,m]=u.useState([]),[p,j]=u.useState(!1),[A,P]=u.useState(""),[N,_]=u.useState(null),[z,w]=u.useState(!1),x=u.useRef(0);u.useEffect(()=>{o&&i(R=>R.type==="browser"&&R.directory?R:{type:"browser",directory:o})},[o]);const M=n.type==="browser"?n.directory:n.returnDirectory,F=u.useCallback(async R=>{if(!R)return;const V=x.current+1;x.current=V,d(!0),g(null);try{const Y=await r.listDirectory(R);if(x.current!==V)return;h(Y.entries.slice().sort((se,de)=>se.isDirectory!==de.isDirectory?se.isDirectory?-1:1:se.name.localeCompare(de.name)))}catch(Y){if(x.current!==V)return;h([]),g(Y instanceof Error?Y.message:e("mobile.files.error.listFailed"))}finally{x.current===V&&d(!1)}},[r,e]);u.useEffect(()=>{n.type==="browser"&&F(n.directory)},[F,n]),u.useEffect(()=>{if(n.type!=="browser")return;const R=b.trim();if(!R){m([]),j(!1);return}let V=!1;const Y=window.setTimeout(()=>{j(!0),r.search({directory:n.directory,query:R,maxResults:40}).then(se=>{V||m(se)}).catch(()=>{V||m([])}).finally(()=>{V||j(!1)})},250);return()=>{V=!0,window.clearTimeout(Y)}},[r,b,n]),u.useEffect(()=>{if(n.type!=="file")return;if(P(""),_(null),_e(n.path)&&!n.path.toLowerCase().endsWith(".svg")){w(!1);return}if(!r.readFile){_(e("mobile.files.error.readUnavailable")),w(!1);return}let R=!1;return w(!0),r.readFile(n.path).then(V=>{R||P(V.content.length>It?`${V.content.slice(0,It)}
|
|
6
6
|
|
|
7
|
-
${e("mobile.files.file.truncated")}`:V.content)}).catch(V=>{R||_(V instanceof Error?V.message:e("filesView.error.readFileFailed"))}).finally(()=>{R||w(!1)}),()=>{R=!0}},[r,n,e]);const I=R=>{v(""),i({type:"browser",directory:R})},L=R=>{i({type:"file",path:R,returnDirectory:M||o})},T=async R=>{(await Et(R)).ok?Q.success(e("mobile.files.toast.pathCopied")):Q.error(e("mobile.files.toast.copyFailed"))},G=async()=>{(await Et(A)).ok?Q.success(e("mobile.files.toast.contentCopied")):Q.error(e("mobile.files.toast.copyFailed"))};if(!o)return t.jsx(Te,{message:e("mobile.files.empty.noDirectory")});if(n.type==="file")return t.jsx(on,{path:n.path,content:A,error:N,isLoading:z,onBack:()=>i({type:"browser",directory:n.returnDirectory}),onCopyPath:()=>{T(n.path)},onCopyContent:()=>{G()}});const U=n.directory===o?e("mobile.files.rootDirectory"):Se(n.directory),k=b.trim()?S:[],$=Qr(n.directory),O=n.directory!==o&&$!==null&&($===o||$.startsWith(`${o}/`)),H=O&&!b.trim(),q=O?$:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Fe,{className:"size-5"})}):null,H&&q?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.files.backToParentAria",{name:Se(q)}),onClick:()=>I(q),style:{touchAction:"manipulation"},children:t.jsx(Xe,{className:"size-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:U})}),t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.files.refreshAria"),onClick:()=>{F(n.directory)},style:{touchAction:"manipulation"},children:t.jsx(Cs,{className:Z("size-5",c&&"animate-spin")})})]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(Ut,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(bt,{value:b,onChange:R=>v(R.target.value),placeholder:e("mobile.files.search.placeholder"),className:"h-11 pl-9"})]})}),t.jsx(Ee,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:f?t.jsx(Te,{message:f}):b.trim()?t.jsx(nn,{results:k,isSearching:p,onOpenFile:L}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]",children:[a.length===0&&!c?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:e("mobile.files.empty.directory")}):null,a.map(R=>t.jsx(hs,{name:R.name,path:R.path,directory:R.isDirectory,meta:R.isDirectory?void 0:Zr(R.size),onClick:()=>R.isDirectory?I(R.path):L(R.path)},R.path))]})})]})},hs=s=>{const e=re.c(16),{name:r,path:o,directory:n,meta:i,onClick:a}=s;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={touchAction:"manipulation"},e[0]=h):h=e[0];let c;e[1]!==n||e[2]!==o?(c=n?t.jsx(As,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(tr,{filePath:o,className:"size-5 shrink-0"}),e[1]=n,e[2]=o,e[3]=c):c=e[3];let d;e[4]!==r?(d=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:r}),e[4]=r,e[5]=d):d=e[5];let f;e[6]!==i?(f=i?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,e[6]=i,e[7]=f):f=e[7];let g;e[8]!==n?(g=n?t.jsx(Ps,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=n,e[9]=g):g=e[9];let b;return e[10]!==a||e[11]!==c||e[12]!==d||e[13]!==f||e[14]!==g?(b=t.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:a,style:h,children:[c,d,f,g]}),e[10]=a,e[11]=c,e[12]=d,e[13]=f,e[14]=g,e[15]=b):b=e[15],b},nn=s=>{const e=re.c(10),{results:r,isSearching:o,onOpenFile:n}=s,{t:i}=ie(),a=Me(pt()??null);if(o){let f;e[0]!==i?(f=i("common.loading"),e[0]=i,e[1]=f):f=e[1];let g;return e[2]!==f?(g=t.jsx(Te,{loading:!0,message:f}),e[2]=f,e[3]=g):g=e[3],g}if(r.length===0){let f;e[4]!==i?(f=i("mobile.files.search.empty"),e[4]=i,e[5]=f):f=e[5];let g;return e[6]!==f?(g=t.jsx(Te,{message:f}),e[6]=f,e[7]=g):g=e[7],g}const h="overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]",c=r.map(f=>t.jsx(hs,{name:Se(f.path),path:f.path,directory:!1,meta:Xr(f.path,a),onClick:()=>n(f.path)},f.path));let d;return e[8]!==c?(d=t.jsx("div",{className:h,children:c}),e[8]=c,e[9]=d):d=e[9],d},on=s=>{const e=re.c(42),{path:r,content:o,error:n,isLoading:i,onBack:a,onCopyPath:h,onCopyContent:c}=s,{t:d}=ie(),f=_e(r)&&!r.toLowerCase().endsWith(".svg")?r:"",[g,b]=u.useState("");let v,S;e[0]!==f?(v=()=>{if(!f){b("");return}let G=!1;return b(""),Vs(Us()).then(U=>{!G&&U&&b(f)}).catch(an),()=>{G=!0}},S=[f],e[0]=f,e[1]=v,e[2]=S):(v=e[1],S=e[2]),u.useEffect(v,S);const m=!!(f&&g!==f);let p;e[3]!==m||e[4]!==r?(p=m?"":en(r),e[3]=m,e[4]=r,e[5]=p):p=e[5];const j=p;let A;e[6]!==d?(A=d("header.actions.backAria"),e[6]=d,e[7]=A):A=e[7];let P;e[8]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(Xe,{className:"size-5"}),e[8]=P):P=e[8];let N;e[9]!==a||e[10]!==A?(N=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":A,onClick:a,children:P}),e[9]=a,e[10]=A,e[11]=N):N=e[11];let _;e[12]!==r?(_=Se(r),e[12]=r,e[13]=_):_=e[13];let z;e[14]!==_?(z=t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:_})}),e[14]=_,e[15]=z):z=e[15];let w;e[16]!==c||e[17]!==r||e[18]!==d?(w=_e(r)?null:t.jsx(ge,{type:"button",variant:"ghost",size:"icon",onClick:c,"aria-label":d("mobile.files.copyContentAria"),children:t.jsx(Es,{className:"size-4"})}),e[16]=c,e[17]=r,e[18]=d,e[19]=w):w=e[19];let x;e[20]!==d?(x=d("mobile.files.copyPathAria"),e[20]=d,e[21]=x):x=e[21];let M;e[22]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(Ds,{className:"size-4"}),e[22]=M):M=e[22];let F;e[23]!==h||e[24]!==x?(F=t.jsx(ge,{type:"button",variant:"ghost",size:"icon",onClick:h,"aria-label":x,children:M}),e[23]=h,e[24]=x,e[25]=F):F=e[25];let I;e[26]!==F||e[27]!==N||e[28]!==z||e[29]!==w?(I=t.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:[N,z,w,F]}),e[26]=F,e[27]=N,e[28]=z,e[29]=w,e[30]=I):I=e[30];let L;e[31]!==o||e[32]!==n||e[33]!==m||e[34]!==j||e[35]!==i||e[36]!==r||e[37]!==d?(L=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:i||m?t.jsx(Te,{loading:!0,message:d("filesView.state.loading")}):n?t.jsx(Te,{message:n}):_e(r)&&j?t.jsx(Ee,{className:"h-full overflow-auto p-4",children:t.jsx("img",{src:j,alt:Se(r),className:"mx-auto max-h-full max-w-full rounded-lg object-contain"})}):_e(r)?t.jsx(Ee,{className:"h-full overflow-auto p-4",children:t.jsx("img",{src:`data:${er(r)};utf8,${encodeURIComponent(o)}`,alt:Se(r),className:"mx-auto max-h-full max-w-full rounded-lg object-contain"})}):t.jsx(ln,{path:r,content:o})}),e[31]=o,e[32]=n,e[33]=m,e[34]=j,e[35]=i,e[36]=r,e[37]=d,e[38]=L):L=e[38];let T;return e[39]!==I||e[40]!==L?(T=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[I,L]}),e[39]=I,e[40]=L,e[41]=T):T=e[41],T},ln=s=>{const e=re.c(32),{path:r,content:o}=s,{currentTheme:n,availableThemes:i,lightThemeId:a,darkThemeId:h}=xt();let c;e[0]!==i||e[1]!==a?(c=i.find(w=>w.metadata.id===a)??At(!1),e[0]=i,e[1]=a,e[2]=c):c=e[2];const d=c;let f;e[3]!==i||e[4]!==h?(f=i.find(w=>w.metadata.id===h)??At(!0),e[3]=i,e[4]=h,e[5]=f):f=e[5];const g=f;let b,v;e[6]!==g||e[7]!==d?(b=()=>{Pt(d),Pt(g)},v=[g,d],e[6]=g,e[7]=d,e[8]=b,e[9]=v):(b=e[8],v=e[9]),u.useEffect(b,v);let S;e[10]!==g.metadata.id||e[11]!==d.metadata.id?(S={light:d.metadata.id,dark:g.metadata.id},e[10]=g.metadata.id,e[11]=d.metadata.id,e[12]=S):S=e[12];const m=S;if(tn(r)){let w;return e[13]!==o?(w=t.jsx(Ee,{className:"h-full overflow-y-auto px-4 py-4",children:t.jsx(sr,{content:o})}),e[13]=o,e[14]=w):w=e[14],w}if(sn(r)){let w;return e[15]!==o?(w=t.jsx(rr,{jsonString:o,className:"h-full overflow-auto"}),e[15]=o,e[16]=w):w=e[16],w}let p;e[17]!==r?(p=Se(r),e[17]=r,e[18]=p):p=e[18];let j;e[19]!==r?(j=ls(r)||void 0,e[19]=r,e[20]=j):j=e[20];let A;e[21]!==o||e[22]!==p||e[23]!==j?(A={name:p,contents:o,lang:j},e[21]=o,e[22]=p,e[23]=j,e[24]=A):A=e[24];const P=n.metadata.variant==="dark"?"dark":"light";let N;e[25]!==m||e[26]!==P?(N={disableFileHeader:!0,overflow:"wrap",theme:m,themeType:P,unsafeCSS:$r},e[25]=m,e[26]=P,e[27]=N):N=e[27];let _;e[28]===Symbol.for("react.memo_cache_sentinel")?(_={minHeight:"100%"},e[28]=_):_=e[28];let z;return e[29]!==N||e[30]!==A?(z=t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx(Ee,{className:"min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]",children:t.jsx(Rs,{file:A,options:N,className:"block min-h-full w-full",style:_})})}),e[29]=N,e[30]=A,e[31]=z):z=e[31],z},Te=s=>{const e=re.c(7),{message:r,loading:o}=s,n=o===void 0?!1:o;let i;e[0]!==n?(i=n?t.jsx(Gt,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(_s,{className:"size-6 text-muted-foreground"}),e[0]=n,e[1]=i):i=e[1];let a;e[2]!==r?(a=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:r}),e[2]=r,e[3]=a):a=e[3];let h;return e[4]!==i||e[5]!==a?(h=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[i,a]})}),e[4]=i,e[5]=a,e[6]=h):h=e[6],h};function an(){}const zt=mt(s=>({expandedParents:{},toggleParent:e=>s(r=>{const o={...r.expandedParents};return o[e]?delete o[e]:o[e]=!0,{expandedParents:o}})})),Ye=mt()(Ht(s=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,r)=>s(o=>({projectExpanded:{...o.projectExpanded,[e]:r}})),setWorktreeExpanded:(e,r)=>s(o=>({worktreeExpanded:{...o.worktreeExpanded,[e]:r}}))}),{name:"mobile-session-tree"})),gs=mt()(Ht(s=>({orderByProject:{},setWorktreeOrder:(e,r)=>s(o=>({orderByProject:{...o.orderByProject,[e]:r}}))}),{name:"mobile-worktree-order"})),Mt=s=>s.replace(/\\/g,"/").replace(/\/+$/,""),cn=(s,e)=>{if(!s||s.length===0)return e;const r=new Map(s.map((n,i)=>[Mt(n),i])),o=n=>r.get(Mt(n.path))??Number.MAX_SAFE_INTEGER;return e.map((n,i)=>({worktree:n,index:i})).sort((n,i)=>{const a=o(n.worktree)-o(i.worktree);return a!==0?a:n.index-i.index}).map(n=>n.worktree)},Le=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/,""),un=s=>{const e=s;return Le(e.directory??e.project?.worktree??null)},dn=({open:s,project:e,worktree:r,onClose:o,onDeleted:n})=>{const{t:i}=ie(),a=as(),h=cs(x=>x.activeSessions),c=je(x=>x.archiveSessions),d=Ie(x=>x.currentDirectory),[f,g]=u.useState(!1),[b,v]=u.useState(!1),[S,m]=u.useState(!1),[p,j]=u.useState(!1),A=Le(r?.path),P=typeof r?.branch=="string"&&r.branch.trim().length>0,N=u.useMemo(()=>{if(!A)return[];const x=new Map;for(const M of[...h,...a])un(M)===A&&x.set(M.id,M);return Array.from(x.values())},[h,a,A]);u.useEffect(()=>{if(!s){g(!1),v(!1),m(!1),j(!1);return}if(!r?.path)return;let x=!1;return nr(r.path).then(M=>{x||m(!!M?.isDirty)}).catch(()=>{x||m(!!r.status?.isDirty)}),()=>{x=!0}},[s,r?.path,r?.status?.isDirty]);const _=async()=>{if(!(!r||p)){j(!0);try{N.length>0&&await c(N.map(x=>x.id)),await ir(e,r,{deleteRemoteBranch:P&&b,deleteLocalBranch:P&&f}),Le(d)===A&&Le(e.path)&&Ie.getState().setDirectory(Le(e.path),{showOverlay:!1}),Q.success(i("sessions.sidebar.sessionDialogs.worktree.removedTitle"),{description:i(P&&b?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),n?.(),o()}catch(x){Q.error(i("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:x instanceof Error?x.message:i("sessions.sidebar.dialogs.deleteResult.tryAgain")})}finally{j(!1)}}};if(!r)return null;const z=r.branch||r.label||r.path,w=(x,M,F,I)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":x,disabled:I,onClick:()=>M(!x),className:Z("flex w-full items-center justify-between gap-3 rounded-xl border border-border/50 px-3.5 py-3 text-left transition-colors","hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",I&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:F}),t.jsx("span",{className:Z("relative h-6 w-10 shrink-0 rounded-full transition-colors",x?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:Z("absolute top-0.5 size-5 rounded-full bg-white transition-transform",x?"translate-x-[1.125rem]":"translate-x-0.5")})})]});return t.jsx(or,{open:s,onClose:o,title:i("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ge,{variant:"ghost",className:"flex-1",onClick:o,disabled:p,children:i("projectEditDialog.actions.cancel")}),t.jsx(ge,{variant:"destructive",className:"flex-1",onClick:()=>{_()},disabled:p,children:i("mobile.projectEdit.deleteWorktreeConfirmButton")})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx("p",{className:"typography-ui-body text-foreground",children:i("mobile.projectEdit.deleteWorktreeConfirm",{name:z})}),S?t.jsx("p",{className:"rounded-xl border border-[var(--warning)]/40 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] px-3.5 py-3 typography-meta text-foreground",children:i("mobile.projectEdit.deleteWorktreeDirty")}):null,N.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i("mobile.projectEdit.deleteWorktreeArchiveNote",{count:N.length})}):null,P?t.jsxs("div",{className:"flex flex-col gap-2",children:[w(f,g,i("mobile.projectEdit.deleteLocalBranch"),p),w(b,v,i("mobile.projectEdit.deleteRemoteBranch"),p)]}):null]})})},Tt="mobile-surface-root",fn=90,it=16,Ft=100,mn=48,hn=8,gn=()=>{if(typeof document>"u")return null;let s=document.getElementById(Tt);return s||(s=document.createElement("div"),s.id=Tt,document.body.appendChild(s)),s},Ve=({open:s,onClose:e,title:r,subtitle:o,trailing:n,onBack:i,disableSwipeDismiss:a=!1,headerless:h=!1,ariaLabel:c,children:d})=>{const{t:f}=ie(),g=u.useRef(null),[b,v]=u.useState(!1),[S,m]=u.useState(!1),[p,j]=u.useState(!1),[A,P]=u.useState(0),N=u.useRef(null),_=u.useRef(!1),z=u.useRef(null),w=u.useRef(null);typeof document<"u"&&!g.current&&(g.current=gn()),u.useEffect(()=>{if(s){v(!0);const G=window.setTimeout(()=>m(!0),it);return()=>window.clearTimeout(G)}m(!1);const T=window.setTimeout(()=>v(!1),300);return()=>window.clearTimeout(T)},[s]),u.useEffect(()=>{if(!s){j(!1);return}const T=window.setTimeout(()=>j(!0),it+Ft+80);return()=>window.clearTimeout(T)},[s]),u.useEffect(()=>{if(!s)return;const T=document.body.style.overflow;w.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const G=()=>{const $=z.current;if(!$)return;($.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??$).focus({preventScroll:!0})},U=window.setTimeout(G,it),k=$=>{if($.key==="Escape"){e();return}if($.key!=="Tab")return;const O=z.current;if(!O)return;const H=Array.from(O.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(Y=>!Y.hasAttribute("disabled")&&Y.getAttribute("aria-hidden")!=="true");if(H.length===0){$.preventDefault(),O.focus({preventScroll:!0});return}const q=H[0],R=H[H.length-1],V=document.activeElement;$.shiftKey&&V===q?($.preventDefault(),R.focus({preventScroll:!0})):!$.shiftKey&&V===R&&($.preventDefault(),q.focus({preventScroll:!0}))};return document.addEventListener("keydown",k),()=>{window.clearTimeout(U),document.body.style.overflow=T,document.removeEventListener("keydown",k),w.current?.focus?.({preventScroll:!0}),w.current=null}},[e,s]);const x=T=>{a||(N.current=T.touches[0]?.clientY??null,_.current=!0)},M=T=>{if(!_.current||N.current==null)return;const U=(T.touches[0]?.clientY??N.current)-N.current;P(U>0?U:0)},F=()=>{_.current&&(_.current=!1,N.current=null,A>=fn?(P(0),e()):P(0))};if(!b||!g.current)return null;const I=i?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":f("header.actions.backAria"),onClick:i,style:{touchAction:"manipulation"},children:t.jsx(Xe,{className:"size-5"})}):t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":f("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Fe,{className:"size-5"})}),L=S?A>0?`translateY(${A}px)`:"none":`translateY(${mn}px)`;return Is.createPortal(t.jsxs("div",{className:Z("fixed inset-0 z-50 flex flex-col bg-[rgb(0_0_0_/_0.45)]","transition-opacity duration-200 ease-out",S?"opacity-100":"opacity-0"),role:"dialog","aria-modal":"true","aria-label":c,onClick:e,children:[t.jsxs("section",{ref:z,className:"mt-auto flex min-h-0 w-full flex-col overflow-hidden rounded-t-[20px] border-t border-border/40 bg-background text-foreground",tabIndex:-1,onClick:T=>T.stopPropagation(),onTransitionEnd:T=>{S&&T.target===T.currentTarget&&T.propertyName==="transform"&&j(!0)},style:{height:`calc(100% - var(--oc-safe-area-top, 0px) - ${hn}px)`,transform:L,transition:_.current?"none":`transform ${Ft}ms cubic-bezier(0.32, 0.72, 0, 1)`},children:[t.jsxs("div",{className:"shrink-0 select-none",onTouchStart:x,onTouchMove:M,onTouchEnd:F,onTouchCancel:F,children:[t.jsx("div",{className:"flex items-center justify-center pt-2 pb-1",children:t.jsx("span",{className:"h-1 w-10 rounded-full bg-[var(--surface-muted)]","aria-hidden":!0})}),h?null:t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] items-center gap-2 px-3",children:[I,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[r?typeof r=="string"?t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:r}):r:null,o?typeof o=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:o}):o:null]}),n?t.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:n}):null]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:p?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:d}):null})]}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]}),g.current)},pn=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/,""),bn=s=>{const e=re.c(36),{worktree:r,onDelete:o}=s,{t:n}=ie();let i;e[0]!==r.path?(i={id:r.path},e[0]=r.path,e[1]=i):i=e[1];const{attributes:a,listeners:h,setNodeRef:c,transform:d,transition:f,isDragging:g}=ss(i);let b;e[2]!==d?(b=rs.Transform.toString(d),e[2]=d,e[3]=b):b=e[3];const v=g?10:1;let S;e[4]!==b||e[5]!==v||e[6]!==f?(S={transform:b,transition:f,zIndex:v},e[4]=b,e[5]=v,e[6]=f,e[7]=S):S=e[7];const m=S,p=r.branch||r.label||r.path,j=g&&"shadow-lg shadow-black/20";let A;e[8]!==j?(A=Z("flex items-center gap-1 rounded-2xl border border-border/40 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",j),e[8]=j,e[9]=A):A=e[9];let P;e[10]!==p||e[11]!==n?(P=n("mobile.projectEdit.dragWorktreeAria",{label:p}),e[10]=p,e[11]=n,e[12]=P):P=e[12];let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(ns,{className:"size-4"}),e[13]=N):N=e[13];let _;e[14]!==a||e[15]!==h||e[16]!==P?(_=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":P,...a,...h,children:N}),e[14]=a,e[15]=h,e[16]=P,e[17]=_):_=e[17];let z;e[18]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx(ze,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[18]=z):z=e[18];let w;e[19]!==p?(w=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:p}),e[19]=p,e[20]=w):w=e[20];let x;e[21]!==p||e[22]!==n?(x=n("mobile.projectEdit.deleteWorktreeAria",{label:p}),e[21]=p,e[22]=n,e[23]=x):x=e[23];let M,F;e[24]===Symbol.for("react.memo_cache_sentinel")?(M={touchAction:"manipulation"},F=t.jsx(dt,{className:"size-4"}),e[24]=M,e[25]=F):(M=e[24],F=e[25]);let I;e[26]!==o||e[27]!==x?(I=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive","aria-label":x,onClick:o,style:M,children:F}),e[26]=o,e[27]=x,e[28]=I):I=e[28];let L;return e[29]!==c||e[30]!==m||e[31]!==w||e[32]!==I||e[33]!==A||e[34]!==_?(L=t.jsxs("div",{ref:c,style:m,className:A,children:[_,z,w,I]}),e[29]=c,e[30]=m,e[31]=w,e[32]=I,e[33]=A,e[34]=_,e[35]=L):L=e[35],L},xn=({open:s,project:e,onClose:r,onWorktreesChanged:o})=>{const{t:n}=ie(),{currentTheme:i}=xt(),a=me(k=>k.updateProjectMeta),h=me(k=>k.discoverProjectIcon),c=me(k=>k.removeProjectIcon),d=gs(k=>k.setWorktreeOrder),f=me(k=>e?k.projects.find($=>$.id===e.id)?.iconImage??null:null),[g,b]=u.useState(""),[v,S]=u.useState(null),[m,p]=u.useState(null),[j,A]=u.useState(!1),[P,N]=u.useState([]),[_,z]=u.useState(null),w=e?.id??null;u.useEffect(()=>{!s||!e||(b(e.label),S(e.icon??null),p(e.color??null),N(e.worktrees))},[s,w]),u.useEffect(()=>{!s||!e||N(k=>{const $=e.worktrees.map(q=>q.path),O=k.map(q=>q.path);return $.length===O.length&&$.every(q=>O.includes(q))?k:e.worktrees})},[e?.worktrees]);const x=Kt(Je(Jt,{activationConstraint:{distance:8}}),Je(Yt,{coordinateGetter:qt})),M=()=>{if(!e)return;const k=g.trim();a(e.id,{label:k||e.label,icon:v,color:m}),r()},F=()=>{!e||j||(A(!0),h(e.id).then(k=>{if(!k.ok){Q.error(k.error||n("projectEditDialog.toast.failedToDiscoverIcon"));return}if(k.skipped){Q.success(n("projectEditDialog.toast.customIconAlreadySet"));return}Q.success(n("projectEditDialog.toast.iconDiscovered"))}).finally(()=>A(!1)))},I=()=>{e&&c(e.id).then(k=>{if(!k.ok){Q.error(k.error||n("projectEditDialog.toast.failedToRemoveIcon"));return}Q.success(n("projectEditDialog.toast.iconRemoved"))})},L=k=>{const{active:$,over:O}=k;if(!O||$.id===O.id||!e)return;const H=P.findIndex(Y=>Y.path===$.id),q=P.findIndex(Y=>Y.path===O.id);if(H<0||q<0)return;const R=[...P],[V]=R.splice(H,1);R.splice(q,0,V),N(R),d(e.id,R.map(Y=>pn(Y.path)))},T=m?us[m]??null:null,G=v?ds[v]:null,U=!!f;return t.jsxs(t.Fragment,{children:[t.jsx(Ve,{open:s,onClose:r,onBack:r,title:n("projectEditDialog.title"),ariaLabel:n("projectEditDialog.title"),trailing:t.jsxs(ge,{type:"button",variant:"default",size:"sm","aria-label":n("projectEditDialog.actions.save"),onClick:M,disabled:!g.trim(),style:{touchAction:"manipulation"},children:[t.jsx(ts,{className:"size-4"}),n("projectEditDialog.actions.save")]}),children:e?t.jsxs("div",{className:"h-full space-y-6 overflow-y-auto px-4 pb-8 pt-2",children:[t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx("span",{className:"flex size-16 items-center justify-center overflow-hidden rounded-2xl bg-[var(--surface-muted)] text-muted-foreground",style:e.iconBackground?{backgroundColor:e.iconBackground}:void 0,children:U?t.jsx(fs,{project:{id:e.id,iconImage:f},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(ut,{className:"size-7"})}):G?t.jsx(ze,{name:G,className:"size-7",style:T?{color:T}:void 0}):t.jsx(ut,{className:"size-7",style:T?{color:T}:void 0})})}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:n("projectEditDialog.field.name")}),t.jsx(bt,{value:g,onChange:k=>b(k.target.value),placeholder:n("projectEditDialog.field.namePlaceholder"),className:"h-11"}),t.jsx("p",{className:"truncate typography-meta text-muted-foreground",title:e.path,children:e.path})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:n("projectEditDialog.field.color")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>p(null),"aria-label":n("projectEditDialog.option.none"),className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",m===null?"border-foreground":"border-border hover:border-border/80"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),lr.map(k=>t.jsx("button",{type:"button",onClick:()=>p(k.key),"aria-label":k.label,title:k.label,className:Z("size-9 rounded-xl border-2 transition-all",m===k.key?"border-foreground":"border-transparent hover:border-border"),style:{backgroundColor:k.cssVar,touchAction:"manipulation"}},k.key))]})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:n("projectEditDialog.field.icon")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>S(null),"aria-label":n("projectEditDialog.option.none"),className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",v===null?"border-foreground bg-[var(--surface-elevated)]":"border-border hover:border-border/80"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),ar.map(k=>t.jsx("button",{type:"button",onClick:()=>S(k.key),"aria-label":k.label,title:k.label,className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",v===k.key?"border-foreground bg-[var(--surface-elevated)]":"border-border hover:border-border/80"),style:{touchAction:"manipulation"},children:t.jsx(ze,{name:k.Icon,className:"size-4",style:T?{color:T}:void 0})},k.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(ge,{size:"sm",variant:"outline",onClick:F,disabled:j,children:n(j?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),U?t.jsx(ge,{size:"sm",variant:"outline",onClick:I,children:n("projectEditDialog.actions.removeProjectIcon")}):null]})]}),e.isGitRepo?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:n("mobile.projectEdit.worktreesTitle")}),P.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("mobile.projectEdit.worktreesEmpty")}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("mobile.projectEdit.reorderHint")}),t.jsx(Qt,{sensors:x,collisionDetection:Xt,onDragEnd:L,children:t.jsx(Zt,{items:P.map(k=>k.path),strategy:es,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:P.map(k=>t.jsx(bn,{worktree:k,onDelete:()=>z(k)},k.path))})})})]})]}):null]}):null}),e?t.jsx(dn,{open:!!_,project:{id:e.id,path:e.path},worktree:_,onClose:()=>z(null),onDeleted:()=>{N(k=>k.filter($=>$.path!==_?.path)),o?.()}}):null]})},lt=7,yn=36,vn=52,jn=18,Bt=s=>s.parentID??null,xe=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/g,""),Re=s=>{const e=s;return xe(e.directory??e.project?.worktree??null)},at=s=>{const e=xe(s);if(!e)return"";const r=e.split("/").filter(Boolean);return r[r.length-1]?.replace(/[-_]/g," ")||e},Ge=s=>{const e=s.time?.updated??s.time?.created,r=typeof e=="number"?e:Number(e);return Number.isFinite(r)&&r>0?r:0},wn=s=>{if(s<=0)return"";const e=Date.now()-s;if(e<6e4)return"now";const r=Math.floor(e/6e4);if(r<60)return`${r}m`;const o=Math.floor(r/60);if(o<24)return`${o}h`;const n=Math.floor(o/24);return n<7?`${n}d`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(s))},fe=(s,e)=>{const r=xe(s),o=xe(e);return!!(r&&o&&(r===o||r.startsWith(`${o}/`)))},ct=(s,e,r)=>r?`${s.title??""} ${s.id} ${Re(s)} ${e}`.toLowerCase().includes(r):!0,ft=s=>{const e=re.c(17),{project:r,size:o}=s,n=o===void 0?"md":o,{currentTheme:i}=xt(),a=r.icon?ds[r.icon]:null,h=r.color?us[r.color]??null:null,c=n==="sm"?"size-6 rounded-md":"size-8 rounded-lg",d=n==="sm"?"size-3.5":"size-4";let f;e[0]!==a||e[1]!==h||e[2]!==d?(f=a?t.jsx(ze,{name:a,className:d,style:h?{color:h}:void 0}):t.jsx(ut,{className:d,style:h?{color:h}:void 0}),e[0]=a,e[1]=h,e[2]=d,e[3]=f):f=e[3];const g=f;let b;e[4]!==c?(b=Z("flex shrink-0 items-center justify-center overflow-hidden bg-[var(--surface-muted)] text-muted-foreground",c),e[4]=c,e[5]=b):b=e[5];let v;e[6]!==r.iconBackground?(v=r.iconBackground?{backgroundColor:r.iconBackground}:void 0,e[6]=r.iconBackground,e[7]=v):v=e[7];let S;e[8]!==i||e[9]!==g||e[10]!==r.iconImage||e[11]!==r.id?(S=r.iconImage?t.jsx(fs,{project:{id:r.id,iconImage:r.iconImage??null},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:g}):g,e[8]=i,e[9]=g,e[10]=r.iconImage,e[11]=r.id,e[12]=S):S=e[12];let m;return e[13]!==b||e[14]!==v||e[15]!==S?(m=t.jsx("span",{className:b,style:v,children:S}),e[13]=b,e[14]=v,e[15]=S,e[16]=m):m=e[16],m},kn=s=>{const e=re.c(5),{expanded:r}=s,o=r?"rotate-0":"-rotate-90";let n;e[0]!==o?(n=Z("flex size-5 shrink-0 items-center justify-center text-muted-foreground/70 transition-transform duration-150",o),e[0]=o,e[1]=n):n=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(ht,{className:"size-4"}),e[2]=i):i=e[2];let a;return e[3]!==n?(a=t.jsx("span",{"aria-hidden":!0,className:n,children:i}),e[3]=n,e[4]=a):a=e[4],a},$t=s=>{const e=re.c(2),{ariaLabel:r}=s;let o;return e[0]!==r?(o=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":r}),e[0]=r,e[1]=o):o=e[1],o},Ot=s=>{const e=re.c(12),{onClick:r,className:o}=s,{t:n}=ie();let i;e[0]!==n?(i=n("sessions.sidebar.project.actions.newWorktree"),e[0]=n,e[1]=i):i=e[1];const a=i;let h;e[2]!==o?(h=Z("flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",o),e[2]=o,e[3]=h):h=e[3];let c;e[4]!==r?(c=b=>{b.stopPropagation(),r()},e[4]=r,e[5]=c):c=e[5];let d,f;e[6]===Symbol.for("react.memo_cache_sentinel")?(d={touchAction:"manipulation"},f=t.jsx(ze,{name:"node-tree",className:"size-4"}),e[6]=d,e[7]=f):(d=e[6],f=e[7]);let g;return e[8]!==a||e[9]!==h||e[10]!==c?(g=t.jsx("button",{type:"button",className:h,"aria-label":a,title:a,onClick:c,style:d,children:f}),e[8]=a,e[9]=h,e[10]=c,e[11]=g):g=e[11],g},Wt=s=>{const e=re.c(55),{session:r,active:o,indent:n,contextLabel:i,confirmingArchive:a,hasChildren:h,expanded:c,onToggleChildren:d,onSelect:f,onRequestArchive:g,onConfirmArchive:b}=s,v=a===void 0?!1:a,S=h===void 0?!1:h,m=c===void 0?!1:c,{t:p}=ie();let j;e[0]!==r?(j=wn(Ge(r)),e[0]=r,e[1]=j):j=e[1];const A=j;let P;e[2]!==r.title||e[3]!==p?(P=r.title?.trim()||p("mobile.sessions.untitled"),e[2]=r.title,e[3]=p,e[4]=P):P=e[4];const N=P,_=o&&!v&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]",z=v&&"bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]";let w;e[5]!==_||e[6]!==z?(w=Z("relative flex items-center gap-1 transition-colors",_,z),e[5]=_,e[6]=z,e[7]=w):w=e[7];let x;e[8]!==m||e[9]!==S||e[10]!==n||e[11]!==d||e[12]!==p?(x=S&&d?t.jsx("button",{type:"button",className:"absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",style:{left:Math.max(n-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":p(m?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),onClick:de=>{de.stopPropagation(),d()},children:t.jsx(ht,{className:Z("size-[18px] transition-transform duration-150",m?"rotate-0":"-rotate-90")})}):null,e[8]=m,e[9]=S,e[10]=n,e[11]=d,e[12]=p,e[13]=x):x=e[13];const M=v&&"opacity-50";let F;e[14]!==M?(F=Z("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",M),e[14]=M,e[15]=F):F=e[15];let I;e[16]!==n?(I={paddingLeft:n,touchAction:"manipulation"},e[16]=n,e[17]=I):I=e[17];const L=o?"bg-primary":"bg-muted-foreground/30";let T;e[18]!==L?(T=Z("size-1.5 shrink-0 rounded-full",L),e[18]=L,e[19]=T):T=e[19];let G;e[20]!==T?(G=t.jsx("span",{className:T,"aria-hidden":!0}),e[20]=T,e[21]=G):G=e[21];const U=o?"text-primary":"text-foreground";let k;e[22]!==U?(k=Z("block min-w-0 flex-1 truncate typography-ui-label",U),e[22]=U,e[23]=k):k=e[23];let $;e[24]!==k||e[25]!==N?($=t.jsx("span",{className:k,children:N}),e[24]=k,e[25]=N,e[26]=$):$=e[26];let O;e[27]!==A?(O=A?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:A}):null,e[27]=A,e[28]=O):O=e[28];let H;e[29]!==G||e[30]!==$||e[31]!==O?(H=t.jsxs("span",{className:"flex items-center gap-2.5",children:[G,$,O]}),e[29]=G,e[30]=$,e[31]=O,e[32]=H):H=e[32];let q;e[33]!==i?(q=i?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground pl-4",children:i}):null,e[33]=i,e[34]=q):q=e[34];let R;e[35]!==H||e[36]!==q?(R=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[H,q]}),e[35]=H,e[36]=q,e[37]=R):R=e[37];let V;e[38]!==v||e[39]!==f||e[40]!==F||e[41]!==I||e[42]!==R?(V=t.jsx("button",{type:"button",className:F,style:I,onClick:f,disabled:v,children:R}),e[38]=v,e[39]=f,e[40]=F,e[41]=I,e[42]=R,e[43]=V):V=e[43];let Y;e[44]!==v||e[45]!==b||e[46]!==g||e[47]!==p||e[48]!==N?(Y=g?t.jsxs(t.Fragment,{children:[v?t.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":p("mobile.sessions.archiveSessionAria",{title:N}),onClick:b,style:{touchAction:"manipulation"},children:[t.jsx(Ct,{className:"size-4"}),t.jsx("span",{className:"typography-ui-label",children:p("sessions.sidebar.bulkActions.archive")})]}):null,t.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":v?p("mobile.sessions.cancelArchiveAria",{title:N}):p("mobile.sessions.archiveSessionAria",{title:N}),onClick:g,style:{touchAction:"manipulation"},children:v?t.jsx(Fe,{className:"size-4"}):t.jsx(Ct,{className:"size-4"})})]}):null,e[44]=v,e[45]=b,e[46]=g,e[47]=p,e[48]=N,e[49]=Y):Y=e[49];let se;return e[50]!==V||e[51]!==Y||e[52]!==w||e[53]!==x?(se=t.jsxs("div",{className:w,children:[x,V,Y]}),e[50]=V,e[51]=Y,e[52]=w,e[53]=x,e[54]=se):se=e[54],se},Sn=s=>{const e=re.c(11),{indent:r,onClick:o}=s,{t:n}=ie();let i;e[0]!==r?(i={paddingLeft:r,touchAction:"manipulation"},e[0]=r,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(ht,{className:"size-4"}),e[2]=a):a=e[2];let h;e[3]!==n?(h=n("sessions.sidebar.group.showMore"),e[3]=n,e[4]=h):h=e[4];let c;e[5]!==h?(c=t.jsx("span",{className:"typography-micro",children:h}),e[5]=h,e[6]=c):c=e[6];let d;return e[7]!==o||e[8]!==i||e[9]!==c?(d=t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-2 py-1.5 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",style:i,onClick:o,children:[a,c]}),e[7]=o,e[8]=i,e[9]=c,e[10]=d):d=e[10],d},Nn=s=>{const e=re.c(11),{indent:r,onClick:o}=s,{t:n}=ie();let i;e[0]!==r?(i={paddingLeft:r,touchAction:"manipulation"},e[0]=r,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Ms,{className:"size-4"}),e[2]=a):a=e[2];let h;e[3]!==n?(h=n("sessions.sidebar.group.showFewer"),e[3]=n,e[4]=h):h=e[4];let c;e[5]!==h?(c=t.jsx("span",{className:"typography-micro",children:h}),e[5]=h,e[6]=c):c=e[6];let d;return e[7]!==o||e[8]!==i||e[9]!==c?(d=t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-2 py-1.5 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",style:i,onClick:o,children:[a,c]}),e[7]=o,e[8]=i,e[9]=c,e[10]=d):d=e[10],d},Cn=s=>{const e=re.c(53),{project:r,totalSessions:o,confirmingDelete:n,onEdit:i,onRequestRemove:a,onConfirmRemove:h}=s,{t:c}=ie();let d;e[0]!==r.id?(d={id:r.id},e[0]=r.id,e[1]=d):d=e[1];const{attributes:f,listeners:g,setNodeRef:b,transform:v,transition:S,isDragging:m}=ss(d);let p;e[2]!==v?(p=rs.Transform.toString(v),e[2]=v,e[3]=p):p=e[3];const j=m?10:1;let A;e[4]!==p||e[5]!==j||e[6]!==S?(A={transform:p,transition:S,zIndex:j},e[4]=p,e[5]=j,e[6]=S,e[7]=A):A=e[7];const P=A,N=m&&"shadow-lg shadow-black/20",_=n&&"border-destructive/50 bg-[color-mix(in_srgb,var(--destructive)_8%,var(--surface-elevated))]";let z;e[8]!==N||e[9]!==_?(z=Z("flex items-center gap-1 rounded-2xl border border-border/40 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",N,_),e[8]=N,e[9]=_,e[10]=z):z=e[10];let w;e[11]!==r.label||e[12]!==c?(w=c("mobile.sessions.dragHandleAria",{label:r.label}),e[11]=r.label,e[12]=c,e[13]=w):w=e[13];let x;e[14]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(ns,{className:"size-4"}),e[14]=x):x=e[14];let M;e[15]!==f||e[16]!==g||e[17]!==w?(M=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":w,...f,...g,children:x}),e[15]=f,e[16]=g,e[17]=w,e[18]=M):M=e[18];let F;e[19]!==r?(F=t.jsx(ft,{project:r}),e[19]=r,e[20]=F):F=e[20];let I;e[21]!==r.label?(I=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:r.label}),e[21]=r.label,e[22]=I):I=e[22];let L;e[23]!==n||e[24]!==h||e[25]!==i||e[26]!==r.label||e[27]!==c||e[28]!==o?(L=n?t.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":c("mobile.sessions.confirmRemoveProjectAria",{label:r.label}),onClick:h,style:{touchAction:"manipulation"},children:[t.jsx(dt,{className:"size-4"}),t.jsx("span",{className:"typography-ui-label",children:c("mobile.sessions.confirmRemoveProject")})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:o}),t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl 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":c("mobile.sessions.editProjectAria",{label:r.label}),onClick:i,style:{touchAction:"manipulation"},children:t.jsx(os,{className:"size-4"})})]}),e[23]=n,e[24]=h,e[25]=i,e[26]=r.label,e[27]=c,e[28]=o,e[29]=L):L=e[29];const T=n?"text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:ring-primary":"text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:ring-destructive";let G;e[30]!==T?(G=Z("flex size-9 shrink-0 items-center justify-center rounded-xl transition-colors focus-visible:outline-none focus-visible:ring-2",T),e[30]=T,e[31]=G):G=e[31];let U;e[32]!==n||e[33]!==r.label||e[34]!==c?(U=n?c("mobile.sessions.cancelRemoveProjectAria",{label:r.label}):c("mobile.sessions.removeProjectAria",{label:r.label}),e[32]=n,e[33]=r.label,e[34]=c,e[35]=U):U=e[35];let k;e[36]===Symbol.for("react.memo_cache_sentinel")?(k={touchAction:"manipulation"},e[36]=k):k=e[36];let $;e[37]!==n?($=n?t.jsx(Fe,{className:"size-4"}):t.jsx(dt,{className:"size-4"}),e[37]=n,e[38]=$):$=e[38];let O;e[39]!==a||e[40]!==G||e[41]!==U||e[42]!==$?(O=t.jsx("button",{type:"button",className:G,"aria-label":U,onClick:a,style:k,children:$}),e[39]=a,e[40]=G,e[41]=U,e[42]=$,e[43]=O):O=e[43];let H;return e[44]!==b||e[45]!==P||e[46]!==M||e[47]!==F||e[48]!==I||e[49]!==L||e[50]!==O||e[51]!==z?(H=t.jsxs("div",{ref:b,style:P,className:z,children:[M,F,I,L,O]}),e[44]=b,e[45]=P,e[46]=M,e[47]=F,e[48]=I,e[49]=L,e[50]=O,e[51]=z,e[52]=H):H=e[52],H},En=({open:s,onOpenChange:e})=>{const{t:r}=ie(),{git:o}=gt(),n=as(),i=cs(l=>l.activeSessions),a=me(l=>l.projects),h=me(l=>l.activeProjectId),c=Ie(l=>l.currentDirectory),d=je(l=>l.currentSessionId),f=je(l=>l.setCurrentSession),g=je(l=>l.archiveSession),b=je(l=>l.openNewSessionDraft),v=me(l=>l.setActiveProject),S=me(l=>l.setActiveProjectIdOnly),m=me(l=>l.reorderProjects),p=me(l=>l.removeProject),j=Ye(l=>l.projectExpanded),A=Ye(l=>l.worktreeExpanded),P=Ye(l=>l.setProjectExpanded),N=Ye(l=>l.setWorktreeExpanded),_=gs(l=>l.orderByProject),z=zt(l=>l.expandedParents),w=zt(l=>l.toggleParent),[x,M]=u.useState(""),[F,I]=u.useState(null),[L,T]=u.useState(null),[G,U]=u.useState(0),[k,$]=u.useState(!1),[O,H]=u.useState(!1),[q,R]=u.useState(null),[V,Y]=u.useState(new Map),[se,de]=u.useState(new Set),[te,ae]=u.useState(!1),[Ne,ye]=u.useState(null),[Ze,Ae]=u.useState(new Map);u.useEffect(()=>{if(!s){M(""),ae(!1),ye(null),Ae(new Map),I(null),T(null);return}cr(n)},[s]),u.useEffect(()=>{te||ye(null)},[te]),u.useEffect(()=>{if(!s||a.length===0)return;let l=!1;return(async()=>{const D=await Promise.all(a.map(async K=>{const le=xe(K.path);if(!le)return null;const X=await o.checkIsGitRepository(le).catch(()=>!1),ue=X?await ms({id:K.id,path:le}).catch(()=>[]):[];return[le,ue,X]}));if(l)return;const B=new Map,J=new Set;for(const K of D)K&&(B.set(K[0],K[1]),K[2]&&J.add(K[0]));Y(B),de(J)})(),()=>{l=!0}},[o,s,a,G]);const ee=u.useMemo(()=>a.map(l=>({id:l.id,label:l.label?.trim()||at(l.path),path:xe(l.path),icon:l.icon,color:l.color,iconImage:l.iconImage,iconBackground:l.iconBackground,isGitRepo:se.has(xe(l.path)),worktrees:cn(_[l.id],V.get(xe(l.path))??[])})),[se,a,_,V]),he=u.useMemo(()=>{const l=new Map(n.map(B=>[B.id,B])),E=i.map(B=>{const J=l.get(B.id);return J?ur(J,B):B}),D=new Set(E.map(B=>B.id));for(const B of n)D.has(B.id)||E.push(B);return E},[i,n]),oe=x.trim().toLowerCase(),pe=u.useMemo(()=>{const l=ee.map(D=>({project:D,buckets:[],totalSessions:0,isActive:D.id===h})),E=(D,B,J)=>{const K=xe(B)||D.project.path,le=K||"__root__";let X=D.buckets.find(ue=>ue.key===le);return X||(X={key:le,label:J?.branch||at(K),path:K,worktree:J,sessions:[]},D.buckets.push(X)),X};for(const D of l){E(D,D.project.path,null);for(const B of D.project.worktrees)E(D,B.path,B)}for(const D of he){const B=Re(D);if(!B)continue;const J=l.find(X=>fe(B,X.project.path)?!0:X.project.worktrees.some(ue=>fe(B,ue.path)));if(!J)continue;const K=J.project.worktrees.find(X=>fe(B,X.path));(K?E(J,K.path,K):E(J,J.project.path,null)).sessions.push(D)}for(const D of l)for(const B of D.buckets)B.sessions.sort((J,K)=>Ge(K)-Ge(J)),D.totalSessions+=B.sessions.length;return l},[h,ee,he]),Pe=xe(c),Be=l=>l.isActive?Pe===l.project.path?l.project.path:l.project.worktrees.find(D=>fe(Pe,D.path))?.path??l.project.path:null,et=l=>j[l.project.id]??!0,tt=(l,E)=>A[`${l.project.id}::${E.key}`]??!1,Ue=l=>{Ae(E=>{if(!E.has(l))return E;const D=new Map(E);return D.delete(l),D})},He=l=>{Ae(E=>{let D=!1;const B=new Map(E),J=`${l}::`;for(const K of B.keys())K.startsWith(J)&&(B.delete(K),D=!0);return D?B:E})},st=(l,E)=>{Ae(D=>{const B=new Map(D);return B.set(l,E+lt),B})},y=(l,E,D)=>{const B=`${l.project.id}::${E.key}`,J=new Set(E.sessions.map(ne=>ne.id)),K=new Map;for(const ne of E.sessions){const be=Bt(ne);if(be&&J.has(be)){const Oe=K.get(be)??[];Oe.push(ne),K.set(be,Oe)}}const le=E.sessions.filter(ne=>{const be=Bt(ne);return!be||!J.has(be)}),X=Ze.get(B)??lt,ue=le.slice(0,X),De=le.length-ue.length,Ss=le.length>lt&&De===0,kt=(ne,be)=>{const Oe=K.get(ne.id)??[],ot=Oe.length>0,St=!!z[ne.id];return t.jsxs(u.Fragment,{children:[t.jsx(Wt,{session:ne,active:d===ne.id,indent:be,hasChildren:ot,expanded:St,onToggleChildren:ot?()=>w(ne.id):void 0,confirmingArchive:L===ne.id,onSelect:()=>ce(ne),onRequestArchive:()=>we(ne.id),onConfirmArchive:()=>{$e(ne)}}),ot&&St?Oe.map(Ns=>kt(Ns,be+jn)):null]},ne.id)};return t.jsxs("div",{children:[ue.map(ne=>kt(ne,D)),De>0?t.jsx(Sn,{indent:D,onClick:()=>st(B,ue.length)}):null,Ss?t.jsx(Nn,{indent:D,onClick:()=>Ue(B)}):null]})},C=(l,E)=>{P(l,!E),He(l)},W=(l,E,D)=>{N(`${l}::${E}`,!D),Ue(`${l}::${E}`)},ce=l=>{const E=Re(l)||null,D=ee.find(B=>fe(E??"",B.path)?!0:B.worktrees.some(J=>fe(E??"",J.path)));D&&S(D.id),f(l.id,E),e(!1)},we=l=>{T(E=>E===l?null:l)},$e=async l=>{T(null),await g(l.id)?Q.success(r("sessions.sidebar.session.archive.success")):Q.error(r("sessions.sidebar.session.archive.error"))},yt=()=>{b(),e(!1)},rt=l=>{R(l),S(l),H(!0)},nt=Kt(Je(Jt,{activationConstraint:{distance:8}}),Je(Yt,{coordinateGetter:qt})),ps=l=>{const{active:E,over:D}=l;if(ye(null),!D||E.id===D.id)return;const B=ee.findIndex(K=>K.id===E.id),J=ee.findIndex(K=>K.id===D.id);B<0||J<0||m(B,J)},bs=l=>{ye(E=>E===l?null:l)},xs=l=>{p(l.id),ye(null),Q.success(r("mobile.sessions.toast.projectRemoved",{label:l.label}))},ys=u.useCallback(l=>{const E=Re(l),D=ee.find(J=>fe(E,J.path)?!0:J.worktrees.some(K=>fe(E,K.path)));if(!D)return at(E)||E;const B=D.worktrees.find(J=>fe(E,J.path));return B?.branch?`${D.label} · ${B.branch}`:D.label},[ee]),vs=l=>{v(l.id),e(!1)},js=u.useMemo(()=>oe?pe.filter(l=>`${l.project.label} ${l.project.path}`.toLowerCase().includes(oe)?!0:l.buckets.some(E=>E.sessions.some(D=>ct(D,l.project.label,oe)))):pe,[oe,pe]),Ke=u.useMemo(()=>oe?he.filter(l=>{const E=Re(l),D=ee.find(B=>fe(E,B.path)?!0:B.worktrees.some(J=>fe(E,J.path)));return ct(l,D?.label??"",oe)}).sort((l,E)=>Ge(E)-Ge(l)):[],[oe,ee,he]),qe=u.useMemo(()=>oe?ee.filter(l=>`${l.label} ${l.path}`.toLowerCase().includes(oe)).map(l=>({...l,sessionCount:he.filter(E=>{const D=Re(E);return fe(D,l.path)?!0:l.worktrees.some(B=>fe(D,B.path))}).length})):[],[oe,ee,he]),ws=oe&&Ke.length===0&&qe.length===0,vt=!oe&&ee.length>1?t.jsx(ge,{type:"button",variant:"chip",size:"sm","aria-label":r(te?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":te,onClick:()=>ae(l=>!l),style:{touchAction:"manipulation"},children:te?t.jsx(ts,{className:"size-4"}):t.jsx(os,{className:"size-4"})}):null,jt=!te&&ee.length>0?t.jsxs(ge,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:yt,style:{touchAction:"manipulation"},children:[t.jsx(zs,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,wt=te?null:t.jsx(ge,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.addProject"),title:r("sessions.sidebar.header.actions.addProject"),onClick:()=>$(!0),style:{touchAction:"manipulation"},children:t.jsx(Nt,{className:"size-4"})}),ks=jt||wt||vt?t.jsxs(t.Fragment,{children:[jt,wt,vt]}):null;return t.jsx(Ve,{open:s,onClose:()=>e(!1),ariaLabel:r("mobile.sessions.sheet.title"),title:r("mobile.sessions.sheet.title"),trailing:ks,children:t.jsxs("div",{className:"flex h-full flex-col",children:[t.jsx("div",{className:Z("shrink-0 px-4 pb-2 pt-1",te&&"hidden"),children:t.jsxs("div",{className:"relative",children:[t.jsx(Ut,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(bt,{value:x,onChange:l=>M(l.target.value),placeholder:r("mobile.sessions.search.placeholder"),className:Z("h-11 pl-9",x&&"pr-10")}),x?t.jsx("button",{type:"button",className:"absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":r("mobile.sessions.clearSearchAria"),onClick:()=>M(""),style:{touchAction:"manipulation"},children:t.jsx(Fe,{className:"size-4"})}):null]})}),t.jsx(Ee,{className:"min-h-0 flex-1 overflow-y-auto pb-4",children:ee.length===0?t.jsx(Lt,{title:r("mobile.sessions.empty.noProjectsTitle"),description:r("mobile.sessions.empty.noProjectsDescription"),action:t.jsxs("button",{type:"button",className:"flex items-center justify-center gap-2 rounded-2xl bg-primary px-5 py-3 typography-ui-label text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>$(!0),children:[t.jsx(Nt,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):ws?t.jsx(Lt,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):oe&&!te?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[Ke.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.search.section.sessions")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:Ke.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]",children:Ke.map((l,E)=>t.jsx("div",{className:Z(E>0&&"border-t border-border/30"),children:t.jsx(Wt,{session:l,active:d===l.id,indent:12,contextLabel:ys(l),onSelect:()=>ce(l)})},l.id))})]}):null,qe.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.search.section.projects")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:qe.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]",children:qe.map((l,E)=>t.jsxs("div",{className:Z("flex items-center",E>0&&"border-t border-border/30"),children:[t.jsxs("button",{type:"button",className:"flex min-h-14 min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>vs(l),style:{touchAction:"manipulation"},children:[t.jsx(ft,{project:l}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:l.label}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:l.sessionCount})]}),l.isGitRepo?t.jsx(Ot,{className:"mr-2",onClick:()=>rt(l.id)}):null]},l.id))})]}):null]}):te?t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2",children:[t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:r("mobile.sessions.editOrderHint")}),t.jsx(Qt,{sensors:nt,collisionDetection:Xt,onDragEnd:ps,children:t.jsx(Zt,{items:ee.map(l=>l.id),strategy:es,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:ee.map(l=>{const E=pe.find(D=>D.project.id===l.id);return t.jsx(Cn,{project:l,totalSessions:E?.totalSessions??0,confirmingDelete:Ne===l.id,onEdit:()=>I(l.id),onRequestRemove:()=>bs(l.id),onConfirmRemove:()=>xs(l)},l.id)})})})})]}):t.jsx("div",{className:"flex flex-col",children:js.map((l,E)=>{const D=et(l),B=oe?l.buckets.filter(K=>K.sessions.some(le=>ct(le,l.project.label,oe))):l.buckets,J=Be(l);return t.jsxs("section",{className:Z(E>0&&"border-t border-border/30"),children:[t.jsxs("div",{className:"flex min-h-14 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-14 min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>C(l.project.id,D),"aria-expanded":D,"aria-label":D?r("sessions.sidebar.group.collapseAria",{label:l.project.label}):r("sessions.sidebar.group.expandAria",{label:l.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(ft,{project:l.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:l.project.label}),l.isActive?t.jsx($t,{ariaLabel:r("mobile.sessions.activeProjectAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:l.totalSessions})]}),l.project.isGitRepo?t.jsx(Ot,{className:"mr-2",onClick:()=>rt(l.project.id)}):null]}),D?t.jsx("div",{className:"pb-2",children:(()=>{const K=B.find(X=>X.worktree===null),le=B.filter(X=>X.worktree!==null);return t.jsxs(t.Fragment,{children:[K&&K.sessions.length>0?y(l,K,yn):null,le.map(X=>{const ue=tt(l,X),De=J===X.path;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-center gap-2 py-1.5 pl-4 pr-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",onClick:()=>W(l.project.id,X.key,ue),"aria-expanded":ue,"aria-label":ue?r("sessions.sidebar.group.collapseAria",{label:X.label}):r("sessions.sidebar.group.expandAria",{label:X.label}),style:{touchAction:"manipulation"},children:[t.jsx(kn,{expanded:ue}),t.jsx(ze,{name:"node-tree",className:Z("size-4 shrink-0",De?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Z("block min-w-0 flex-1 truncate typography-ui-label font-semibold",De?"text-foreground":"text-foreground/90"),children:X.label}),De?t.jsx($t,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:X.sessions.length})]}),ue?y(l,X,vn):null]},X.key)})]})})()}):null]},l.project.id)})})}),t.jsx(Or,{open:k,onOpenChange:$}),t.jsx(Wr,{open:O,onOpenChange:l=>{H(l),l||R(null)},onWorktreeCreated:(l,E)=>{E?.sessionId?f(E.sessionId,l):b({selectedProjectId:q,directoryOverride:l,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(xn,{open:F!==null,project:ee.find(l=>l.id===F)??null,onClose:()=>I(null),onWorktreesChanged:()=>U(l=>l+1)})]})})},Lt=s=>{const e=re.c(10),{title:r,description:o,action:n}=s;let i;e[0]!==r?(i=t.jsx("p",{className:"typography-ui-label text-foreground",children:r}),e[0]=r,e[1]=i):i=e[1];let a;e[2]!==o?(a=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[2]=o,e[3]=a):a=e[3];let h;e[4]!==n?(h=n?t.jsx("div",{className:"pt-2",children:n}):null,e[4]=n,e[5]=h):h=e[5];let c;return e[6]!==i||e[7]!==a||e[8]!==h?(c=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[i,a,h]}),e[6]=i,e[7]=a,e[8]=h,e[9]=c):c=e[9],c},An=["appearance","chat","notifications","sessions","git","magic-prompts","behavior","mcp","providers","usage","voice"],Qe=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/g,""),Pn=s=>{const e=Qe(s);if(!e)return"";const r=e.split("/").filter(Boolean);return r[r.length-1]?.replace(/[-_]/g," ")||e},Dn=s=>{const e=re.c(24),{open:r,onClose:o,items:n}=s,{t:i}=ie();let a,h;if(e[0]!==o||e[1]!==r?(a=()=>{if(!r)return;const p=j=>{j.key==="Escape"&&o()};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},h=[o,r],e[0]=o,e[1]=r,e[2]=a,e[3]=h):(a=e[2],h=e[3]),u.useEffect(a,h),!r)return null;let c;e[4]!==i?(c=i("mobile.menu.titleAria"),e[4]=i,e[5]=c):c=e[5];let d;e[6]!==i?(d=i("mobile.surface.closeAria"),e[6]=i,e[7]=d):d=e[7];let f;e[8]!==o||e[9]!==d?(f=t.jsx("button",{type:"button",className:"absolute inset-0 cursor-default","aria-label":d,onClick:o}),e[8]=o,e[9]=d,e[10]=f):f=e[10];let g;e[11]===Symbol.for("react.memo_cache_sentinel")?(g={animation:"mobile-menu-in 160ms cubic-bezier(0.32, 0.72, 0, 1)"},e[11]=g):g=e[11];let b;if(e[12]!==n||e[13]!==o){let p;e[15]!==o?(p=(j,A)=>t.jsxs("button",{type:"button",role:"menuitem",className:Z("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",A>0&&"border-t border-border/30"),style:{touchAction:"manipulation"},onClick:()=>{j.onSelect(),o()},children:[t.jsx(j.Icon,{className:"size-5 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:j.label}),j.badge&&j.badge>0?t.jsx("span",{className:"inline-flex size-2 shrink-0 rounded-full bg-primary","aria-hidden":!0}):null]},j.key),e[15]=o,e[16]=p):p=e[16],b=n.map(p),e[12]=n,e[13]=o,e[14]=b}else b=e[14];let v;e[17]!==b?(v=t.jsx("div",{className:"absolute right-2 top-[calc(var(--oc-safe-area-top,0px)+56px+4px)] w-[min(220px,calc(100vw-1rem))] origin-top-right overflow-hidden rounded-2xl border border-border/40 bg-background shadow-[0_18px_60px_rgb(0_0_0_/_0.35)]",role:"menu",style:g,children:b}),e[17]=b,e[18]=v):v=e[18];let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx("style",{children:"@keyframes mobile-menu-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }"}),e[19]=S):S=e[19];let m;return e[20]!==c||e[21]!==f||e[22]!==v?(m=t.jsxs("div",{className:"fixed inset-0 z-50",role:"dialog","aria-modal":"true","aria-label":c,children:[f,v,S]}),e[20]=c,e[21]=f,e[22]=v,e[23]=m):m=e[23],m},Rn=s=>{const e=re.c(46),{onOpenSessions:r,onOpenMenu:o}=s,{t:n}=ie(),i=Ie(zn),a=je(Mn),h=me(Tn),c=kr(a,i||void 0);let d;if(e[0]!==i||e[1]!==h||e[2]!==n){e:{const k=Qe(i);if(!k){let O;e[4]!==n?(O=n("mobile.header.noProject"),e[4]=n,e[5]=O):O=e[5],d=O;break e}const $=h.find(O=>{const H=Qe(O.path);return k===H||k.startsWith(`${H}/`)});d=$?.label?.trim()||Pn($?.path||k)}e[0]=i,e[1]=h,e[2]=n,e[3]=d}else d=e[3];const f=d;let g;e[6]!==c?.title?(g=c?.title?.trim(),e[6]=c?.title,e[7]=g):g=e[7];const b=g,v=b||f;let S;e[8]!==a||e[9]!==f||e[10]!==b||e[11]!==n?(S=b?f:a?n("mobile.sessions.untitled"):"",e[8]=a,e[9]=f,e[10]=b,e[11]=n,e[12]=S):S=e[12];const m=S;let p;e[13]===Symbol.for("react.memo_cache_sentinel")?(p={paddingTop:"var(--oc-safe-area-top, 0px)"},e[13]=p):p=e[13];let j;e[14]!==n?(j=n("mobile.sessions.openSheetAria"),e[14]=n,e[15]=j):j=e[15];let A,P;e[16]===Symbol.for("react.memo_cache_sentinel")?(A={touchAction:"manipulation"},P=t.jsx($s,{className:"size-5"}),e[16]=A,e[17]=P):(A=e[16],P=e[17]);let N;e[18]!==r||e[19]!==j?(N=t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":j,onClick:r,style:A,children:P}),e[18]=r,e[19]=j,e[20]=N):N=e[20];let _;e[21]!==n?(_=n("mobile.sessions.openSheetAria"),e[21]=n,e[22]=_):_=e[22];let z;e[23]===Symbol.for("react.memo_cache_sentinel")?(z={touchAction:"manipulation"},e[23]=z):z=e[23];let w;e[24]!==v?(w=t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:v}),e[24]=v,e[25]=w):w=e[25];let x;e[26]!==m?(x=m?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:m}):null,e[26]=m,e[27]=x):x=e[27];let M;e[28]!==w||e[29]!==x?(M=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[w,x]}),e[28]=w,e[29]=x,e[30]=M):M=e[30];let F;e[31]!==r||e[32]!==M||e[33]!==_?(F=t.jsx("button",{type:"button",className:"flex min-w-0 flex-1 items-center rounded-full px-2 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":_,onClick:r,style:z,children:M}),e[31]=r,e[32]=M,e[33]=_,e[34]=F):F=e[34];let I;e[35]!==n?(I=n("mobile.header.openMenuAria"),e[35]=n,e[36]=I):I=e[36];let L,T;e[37]===Symbol.for("react.memo_cache_sentinel")?(L={touchAction:"manipulation"},T=t.jsx(Os,{className:"size-5"}),e[37]=L,e[38]=T):(L=e[37],T=e[38]);let G;e[39]!==o||e[40]!==I?(G=t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":I,onClick:o,style:L,children:T}),e[39]=o,e[40]=I,e[41]=G):G=e[41];let U;return e[42]!==F||e[43]!==G||e[44]!==N?(U=t.jsx("header",{className:"relative z-30 flex shrink-0 items-center gap-1 border-b border-border/30 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",style:p,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[N,F,G]})}),e[42]=F,e[43]=G,e[44]=N,e[45]=U):U=e[45],U},_n=()=>{const s=re.c(49),{t:e}=ie(),[r,o]=u.useState(!1),[n,i]=u.useState(!1),[a,h]=u.useState(!1),[c,d]=u.useState(!1),[f,g]=u.useState(!1),[b,v]=u.useState(null),S=Ie(Fn);let m;s[0]!==S?(m=Qe(S)||null,s[0]=S,s[1]=m):m=s[1];const j=is(m)?.files?.length??0;let A;s[2]===Symbol.for("react.memo_cache_sentinel")?(A={openChanges:te=>{const{diffPath:ae,staged:Ne}=te===void 0?{}:te;v(ae?{path:ae,staged:Ne===!0}:null),h(!0)},openFiles:()=>i(!0),openSettings:()=>d(!0)},s[2]=A):A=s[2];const P=A;let N;s[3]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{h(!1),v(null)},s[3]=N):N=s[3];const _=N;let z;s[4]!==e?(z=e("mobile.menu.files"),s[4]=e,s[5]=z):z=s[5];let w;s[6]===Symbol.for("react.memo_cache_sentinel")?(w=()=>i(!0),s[6]=w):w=s[6];let x;s[7]!==z?(x={key:"files",Icon:Fs,label:z,onSelect:w},s[7]=z,s[8]=x):x=s[8];let M;s[9]!==e?(M=e("mobile.menu.changes"),s[9]=e,s[10]=M):M=s[10];let F;s[11]===Symbol.for("react.memo_cache_sentinel")?(F=()=>h(!0),s[11]=F):F=s[11];let I;s[12]!==j||s[13]!==M?(I={key:"changes",Icon:Vt,label:M,badge:j,onSelect:F},s[12]=j,s[13]=M,s[14]=I):I=s[14];let L;s[15]!==e?(L=e("mobile.menu.settings"),s[15]=e,s[16]=L):L=s[16];let T;s[17]===Symbol.for("react.memo_cache_sentinel")?(T=()=>d(!0),s[17]=T):T=s[17];let G;s[18]!==L?(G={key:"settings",Icon:Bs,label:L,onSelect:T},s[18]=L,s[19]=G):G=s[19];let U;s[20]!==G||s[21]!==x||s[22]!==I?(U=[x,I,G],s[20]=G,s[21]=x,s[22]=I,s[23]=U):U=s[23];const k=U;let $;s[24]===Symbol.for("react.memo_cache_sentinel")?($=t.jsx(Rn,{onOpenSessions:()=>o(!0),onOpenMenu:()=>g(!0)}),s[24]=$):$=s[24];let O;s[25]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx("main",{className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:t.jsx(We,{children:t.jsx(Vr,{})})}),s[25]=O):O=s[25];let H;s[26]===Symbol.for("react.memo_cache_sentinel")?(H=()=>g(!1),s[26]=H):H=s[26];let q;s[27]!==k||s[28]!==f?(q=t.jsx(Dn,{open:f,onClose:H,items:k}),s[27]=k,s[28]=f,s[29]=q):q=s[29];let R;s[30]!==r?(R=r?t.jsx(En,{open:r,onOpenChange:o}):null,s[30]=r,s[31]=R):R=s[31];let V;s[32]!==n||s[33]!==e?(V=n?t.jsx(Ve,{open:!0,onClose:()=>i(!1),ariaLabel:e("mobile.menu.files"),headerless:!0,children:t.jsx(We,{children:t.jsx(rn,{onClose:()=>i(!1)})})}):null,s[32]=n,s[33]=e,s[34]=V):V=s[34];let Y;s[35]!==a||s[36]!==b?.path||s[37]!==b?.staged||s[38]!==e?(Y=a?t.jsx(Ve,{open:!0,onClose:_,ariaLabel:e("mobile.menu.changes"),headerless:!0,children:t.jsx(We,{children:t.jsx(Yr,{onClose:_,initialDiffPath:b?.path??null,initialDiffStaged:b?.staged===!0})})}):null,s[35]=a,s[36]=b?.path,s[37]=b?.staged,s[38]=e,s[39]=Y):Y=s[39];let se;s[40]!==c||s[41]!==e?(se=c?t.jsx(Ve,{open:!0,onClose:()=>d(!1),ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(We,{children:t.jsx(Gr,{forceMobile:!0,isWindowed:!0,visiblePageSlugs:[...An],onClose:()=>d(!1)})})}):null,s[40]=c,s[41]=e,s[42]=se):se=s[42];let de;return s[43]!==q||s[44]!==R||s[45]!==V||s[46]!==Y||s[47]!==se?(de=t.jsx(wr,{actions:P,children:t.jsxs("div",{className:"main-content-safe-area flex h-[100dvh] flex-col bg-background text-foreground","data-page-scroll-lock":"true",children:[$,O,q,R,V,Y,se]})}),s[43]=q,s[44]=R,s[45]=V,s[46]=Y,s[47]=se,s[48]=de):de=s[48],de};function In({apis:s}){const e=Ce(m=>m.initializeApp),r=Ce(m=>m.isInitialized),o=Ce(m=>m.isConnected),n=Ce(m=>m.providers.length),i=Ce(m=>m.agents.length),a=Ce(m=>m.loadProviders),h=Ce(m=>m.loadAgents),c=Ie(m=>m.currentDirectory),d=je(m=>m.error),f=je(m=>m.clearError),g=dr(m=>m.setIsMobile),b=fr(m=>m.refreshStatus),v=mr(m=>m.setPlanModeEnabled),S=me(m=>m.projects);return u.useEffect(()=>(Dt(s),()=>Dt(null)),[s]),u.useEffect(()=>{g(!0)},[g]),u.useEffect(()=>{e()},[e]),u.useEffect(()=>{o&&(n===0&&a({source:"mobileApp:recovery"}),i===0&&h({source:"mobileApp:recovery"}))},[i,o,h,a,n]),u.useEffect(()=>{o&&Rt.setDirectory(c)},[c,o]),u.useEffect(()=>{b(s.github,{force:!0})},[s.github,b]),u.useEffect(()=>{if(S.length===0)return;let m=!1;return(async()=>{const j=new Map,A=[];await Promise.all(S.map(async P=>{const N=P.path.replace(/\\/g,"/").replace(/\/+$/,"");if(N)try{if(!(ve.getState().directories.get(N)?.isGitRepo??await Ts(()=>import("./useAppFontEffects-DEZpweZZ.js").then(x=>x.fy),__vite__mapDeps([0,1,2,3,4])).then(x=>x.checkIsGitRepository(N))))return;const w=await ms({id:P.id,path:N});if(m||w.length===0)return;j.set(N,w),A.push(...w)}catch{}})),!m&&je.setState({availableWorktrees:A,availableWorktreesByProject:j})})(),()=>{m=!0}},[S]),u.useEffect(()=>{let m=!1;return(async()=>{const j=await Hs("/health",{method:"GET"}).catch(()=>null);if(!j||!j.ok||m)return;const A=await j.json().catch(()=>null);if(!A||m)return;const P=A.planModeExperimentalEnabled;v(P===!0||P===1||P==="1"||P==="true")})(),()=>{m=!0}},[v]),u.useEffect(()=>{if(!d)return;const m=window.setTimeout(()=>f(),5e3);return()=>window.clearTimeout(m)},[f,d]),hr(),gr({enabled:!0}),pr(),Lr(),t.jsx(We,{children:t.jsx(br,{sdk:Rt.getSdkClient(),directory:c||"",children:t.jsx(xr,{apis:s,children:t.jsx(yr,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(vr,{embeddedBackgroundWorkEnabled:r}),t.jsx(_n,{}),t.jsx(jr,{})]})})})})})}function zn(s){return s.currentDirectory}function Mn(s){return s.currentSessionId}function Tn(s){return s.projects}function Fn(s){return s.currentDirectory}const Bn=()=>{Ar(),Pr().then(()=>{Promise.all([Dr(),Rr()]).catch(s=>{console.error("[mobile-main] settings init failed:",s)}),_r(),Ir(),zr()}).catch(s=>{console.error("[mobile-main] appearance init failed:",s)})};function Hn(s){Bn();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");Ws.createRoot(e).render(t.jsx(Ls.StrictMode,{children:t.jsx(Sr,{children:t.jsx(Nr,{children:t.jsx(Cr,{children:t.jsx(Ur,{children:t.jsx(Er,{children:t.jsx(In,{apis:s})})})})})})}))}export{Hn as renderMobileApp};
|
|
7
|
+
${e("mobile.files.file.truncated")}`:V.content)}).catch(V=>{R||_(V instanceof Error?V.message:e("filesView.error.readFileFailed"))}).finally(()=>{R||w(!1)}),()=>{R=!0}},[r,n,e]);const I=R=>{v(""),i({type:"browser",directory:R})},L=R=>{i({type:"file",path:R,returnDirectory:M||o})},T=async R=>{(await Et(R)).ok?Q.success(e("mobile.files.toast.pathCopied")):Q.error(e("mobile.files.toast.copyFailed"))},G=async()=>{(await Et(A)).ok?Q.success(e("mobile.files.toast.contentCopied")):Q.error(e("mobile.files.toast.copyFailed"))};if(!o)return t.jsx(Te,{message:e("mobile.files.empty.noDirectory")});if(n.type==="file")return t.jsx(on,{path:n.path,content:A,error:N,isLoading:z,onBack:()=>i({type:"browser",directory:n.returnDirectory}),onCopyPath:()=>{T(n.path)},onCopyContent:()=>{G()}});const U=n.directory===o?e("mobile.files.rootDirectory"):Se(n.directory),k=b.trim()?S:[],$=Qr(n.directory),O=n.directory!==o&&$!==null&&($===o||$.startsWith(`${o}/`)),H=O&&!b.trim(),q=O?$:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Fe,{className:"size-5"})}):null,H&&q?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.files.backToParentAria",{name:Se(q)}),onClick:()=>I(q),style:{touchAction:"manipulation"},children:t.jsx(Xe,{className:"size-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:U})}),t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.files.refreshAria"),onClick:()=>{F(n.directory)},style:{touchAction:"manipulation"},children:t.jsx(Cs,{className:Z("size-5",c&&"animate-spin")})})]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(Ut,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(bt,{value:b,onChange:R=>v(R.target.value),placeholder:e("mobile.files.search.placeholder"),className:"h-11 pl-9"})]})}),t.jsx(Ee,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:f?t.jsx(Te,{message:f}):b.trim()?t.jsx(nn,{results:k,isSearching:p,onOpenFile:L}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]",children:[a.length===0&&!c?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:e("mobile.files.empty.directory")}):null,a.map(R=>t.jsx(hs,{name:R.name,path:R.path,directory:R.isDirectory,meta:R.isDirectory?void 0:Zr(R.size),onClick:()=>R.isDirectory?I(R.path):L(R.path)},R.path))]})})]})},hs=s=>{const e=re.c(16),{name:r,path:o,directory:n,meta:i,onClick:a}=s;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={touchAction:"manipulation"},e[0]=h):h=e[0];let c;e[1]!==n||e[2]!==o?(c=n?t.jsx(As,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(tr,{filePath:o,className:"size-5 shrink-0"}),e[1]=n,e[2]=o,e[3]=c):c=e[3];let d;e[4]!==r?(d=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:r}),e[4]=r,e[5]=d):d=e[5];let f;e[6]!==i?(f=i?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,e[6]=i,e[7]=f):f=e[7];let g;e[8]!==n?(g=n?t.jsx(Ps,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=n,e[9]=g):g=e[9];let b;return e[10]!==a||e[11]!==c||e[12]!==d||e[13]!==f||e[14]!==g?(b=t.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:a,style:h,children:[c,d,f,g]}),e[10]=a,e[11]=c,e[12]=d,e[13]=f,e[14]=g,e[15]=b):b=e[15],b},nn=s=>{const e=re.c(10),{results:r,isSearching:o,onOpenFile:n}=s,{t:i}=ie(),a=Me(pt()??null);if(o){let f;e[0]!==i?(f=i("common.loading"),e[0]=i,e[1]=f):f=e[1];let g;return e[2]!==f?(g=t.jsx(Te,{loading:!0,message:f}),e[2]=f,e[3]=g):g=e[3],g}if(r.length===0){let f;e[4]!==i?(f=i("mobile.files.search.empty"),e[4]=i,e[5]=f):f=e[5];let g;return e[6]!==f?(g=t.jsx(Te,{message:f}),e[6]=f,e[7]=g):g=e[7],g}const h="overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]",c=r.map(f=>t.jsx(hs,{name:Se(f.path),path:f.path,directory:!1,meta:Xr(f.path,a),onClick:()=>n(f.path)},f.path));let d;return e[8]!==c?(d=t.jsx("div",{className:h,children:c}),e[8]=c,e[9]=d):d=e[9],d},on=s=>{const e=re.c(42),{path:r,content:o,error:n,isLoading:i,onBack:a,onCopyPath:h,onCopyContent:c}=s,{t:d}=ie(),f=_e(r)&&!r.toLowerCase().endsWith(".svg")?r:"",[g,b]=u.useState("");let v,S;e[0]!==f?(v=()=>{if(!f){b("");return}let G=!1;return b(""),Vs(Us()).then(U=>{!G&&U&&b(f)}).catch(an),()=>{G=!0}},S=[f],e[0]=f,e[1]=v,e[2]=S):(v=e[1],S=e[2]),u.useEffect(v,S);const m=!!(f&&g!==f);let p;e[3]!==m||e[4]!==r?(p=m?"":en(r),e[3]=m,e[4]=r,e[5]=p):p=e[5];const j=p;let A;e[6]!==d?(A=d("header.actions.backAria"),e[6]=d,e[7]=A):A=e[7];let P;e[8]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(Xe,{className:"size-5"}),e[8]=P):P=e[8];let N;e[9]!==a||e[10]!==A?(N=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":A,onClick:a,children:P}),e[9]=a,e[10]=A,e[11]=N):N=e[11];let _;e[12]!==r?(_=Se(r),e[12]=r,e[13]=_):_=e[13];let z;e[14]!==_?(z=t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:_})}),e[14]=_,e[15]=z):z=e[15];let w;e[16]!==c||e[17]!==r||e[18]!==d?(w=_e(r)?null:t.jsx(ge,{type:"button",variant:"ghost",size:"icon",onClick:c,"aria-label":d("mobile.files.copyContentAria"),children:t.jsx(Es,{className:"size-4"})}),e[16]=c,e[17]=r,e[18]=d,e[19]=w):w=e[19];let x;e[20]!==d?(x=d("mobile.files.copyPathAria"),e[20]=d,e[21]=x):x=e[21];let M;e[22]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(Ds,{className:"size-4"}),e[22]=M):M=e[22];let F;e[23]!==h||e[24]!==x?(F=t.jsx(ge,{type:"button",variant:"ghost",size:"icon",onClick:h,"aria-label":x,children:M}),e[23]=h,e[24]=x,e[25]=F):F=e[25];let I;e[26]!==F||e[27]!==N||e[28]!==z||e[29]!==w?(I=t.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:[N,z,w,F]}),e[26]=F,e[27]=N,e[28]=z,e[29]=w,e[30]=I):I=e[30];let L;e[31]!==o||e[32]!==n||e[33]!==m||e[34]!==j||e[35]!==i||e[36]!==r||e[37]!==d?(L=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:i||m?t.jsx(Te,{loading:!0,message:d("filesView.state.loading")}):n?t.jsx(Te,{message:n}):_e(r)&&j?t.jsx(Ee,{className:"h-full overflow-auto p-4",children:t.jsx("img",{src:j,alt:Se(r),className:"mx-auto max-h-full max-w-full rounded-lg object-contain"})}):_e(r)?t.jsx(Ee,{className:"h-full overflow-auto p-4",children:t.jsx("img",{src:`data:${er(r)};utf8,${encodeURIComponent(o)}`,alt:Se(r),className:"mx-auto max-h-full max-w-full rounded-lg object-contain"})}):t.jsx(ln,{path:r,content:o})}),e[31]=o,e[32]=n,e[33]=m,e[34]=j,e[35]=i,e[36]=r,e[37]=d,e[38]=L):L=e[38];let T;return e[39]!==I||e[40]!==L?(T=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[I,L]}),e[39]=I,e[40]=L,e[41]=T):T=e[41],T},ln=s=>{const e=re.c(32),{path:r,content:o}=s,{currentTheme:n,availableThemes:i,lightThemeId:a,darkThemeId:h}=xt();let c;e[0]!==i||e[1]!==a?(c=i.find(w=>w.metadata.id===a)??At(!1),e[0]=i,e[1]=a,e[2]=c):c=e[2];const d=c;let f;e[3]!==i||e[4]!==h?(f=i.find(w=>w.metadata.id===h)??At(!0),e[3]=i,e[4]=h,e[5]=f):f=e[5];const g=f;let b,v;e[6]!==g||e[7]!==d?(b=()=>{Pt(d),Pt(g)},v=[g,d],e[6]=g,e[7]=d,e[8]=b,e[9]=v):(b=e[8],v=e[9]),u.useEffect(b,v);let S;e[10]!==g.metadata.id||e[11]!==d.metadata.id?(S={light:d.metadata.id,dark:g.metadata.id},e[10]=g.metadata.id,e[11]=d.metadata.id,e[12]=S):S=e[12];const m=S;if(tn(r)){let w;return e[13]!==o?(w=t.jsx(Ee,{className:"h-full overflow-y-auto px-4 py-4",children:t.jsx(sr,{content:o})}),e[13]=o,e[14]=w):w=e[14],w}if(sn(r)){let w;return e[15]!==o?(w=t.jsx(rr,{jsonString:o,className:"h-full overflow-auto"}),e[15]=o,e[16]=w):w=e[16],w}let p;e[17]!==r?(p=Se(r),e[17]=r,e[18]=p):p=e[18];let j;e[19]!==r?(j=ls(r)||void 0,e[19]=r,e[20]=j):j=e[20];let A;e[21]!==o||e[22]!==p||e[23]!==j?(A={name:p,contents:o,lang:j},e[21]=o,e[22]=p,e[23]=j,e[24]=A):A=e[24];const P=n.metadata.variant==="dark"?"dark":"light";let N;e[25]!==m||e[26]!==P?(N={disableFileHeader:!0,overflow:"wrap",theme:m,themeType:P,unsafeCSS:$r},e[25]=m,e[26]=P,e[27]=N):N=e[27];let _;e[28]===Symbol.for("react.memo_cache_sentinel")?(_={minHeight:"100%"},e[28]=_):_=e[28];let z;return e[29]!==N||e[30]!==A?(z=t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx(Ee,{className:"min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]",children:t.jsx(Rs,{file:A,options:N,className:"block min-h-full w-full",style:_})})}),e[29]=N,e[30]=A,e[31]=z):z=e[31],z},Te=s=>{const e=re.c(7),{message:r,loading:o}=s,n=o===void 0?!1:o;let i;e[0]!==n?(i=n?t.jsx(Gt,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(_s,{className:"size-6 text-muted-foreground"}),e[0]=n,e[1]=i):i=e[1];let a;e[2]!==r?(a=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:r}),e[2]=r,e[3]=a):a=e[3];let h;return e[4]!==i||e[5]!==a?(h=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[i,a]})}),e[4]=i,e[5]=a,e[6]=h):h=e[6],h};function an(){}const zt=mt(s=>({expandedParents:{},toggleParent:e=>s(r=>{const o={...r.expandedParents};return o[e]?delete o[e]:o[e]=!0,{expandedParents:o}})})),Ye=mt()(Ht(s=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,r)=>s(o=>({projectExpanded:{...o.projectExpanded,[e]:r}})),setWorktreeExpanded:(e,r)=>s(o=>({worktreeExpanded:{...o.worktreeExpanded,[e]:r}}))}),{name:"mobile-session-tree"})),gs=mt()(Ht(s=>({orderByProject:{},setWorktreeOrder:(e,r)=>s(o=>({orderByProject:{...o.orderByProject,[e]:r}}))}),{name:"mobile-worktree-order"})),Mt=s=>s.replace(/\\/g,"/").replace(/\/+$/,""),cn=(s,e)=>{if(!s||s.length===0)return e;const r=new Map(s.map((n,i)=>[Mt(n),i])),o=n=>r.get(Mt(n.path))??Number.MAX_SAFE_INTEGER;return e.map((n,i)=>({worktree:n,index:i})).sort((n,i)=>{const a=o(n.worktree)-o(i.worktree);return a!==0?a:n.index-i.index}).map(n=>n.worktree)},Le=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/,""),un=s=>{const e=s;return Le(e.directory??e.project?.worktree??null)},dn=({open:s,project:e,worktree:r,onClose:o,onDeleted:n})=>{const{t:i}=ie(),a=as(),h=cs(x=>x.activeSessions),c=je(x=>x.archiveSessions),d=Ie(x=>x.currentDirectory),[f,g]=u.useState(!1),[b,v]=u.useState(!1),[S,m]=u.useState(!1),[p,j]=u.useState(!1),A=Le(r?.path),P=typeof r?.branch=="string"&&r.branch.trim().length>0,N=u.useMemo(()=>{if(!A)return[];const x=new Map;for(const M of[...h,...a])un(M)===A&&x.set(M.id,M);return Array.from(x.values())},[h,a,A]);u.useEffect(()=>{if(!s){g(!1),v(!1),m(!1),j(!1);return}if(!r?.path)return;let x=!1;return nr(r.path).then(M=>{x||m(!!M?.isDirty)}).catch(()=>{x||m(!!r.status?.isDirty)}),()=>{x=!0}},[s,r?.path,r?.status?.isDirty]);const _=async()=>{if(!(!r||p)){j(!0);try{N.length>0&&await c(N.map(x=>x.id)),await ir(e,r,{deleteRemoteBranch:P&&b,deleteLocalBranch:P&&f}),Le(d)===A&&Le(e.path)&&Ie.getState().setDirectory(Le(e.path),{showOverlay:!1}),Q.success(i("sessions.sidebar.sessionDialogs.worktree.removedTitle"),{description:i(P&&b?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),n?.(),o()}catch(x){Q.error(i("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:x instanceof Error?x.message:i("sessions.sidebar.dialogs.deleteResult.tryAgain")})}finally{j(!1)}}};if(!r)return null;const z=r.branch||r.label||r.path,w=(x,M,F,I)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":x,disabled:I,onClick:()=>M(!x),className:Z("flex w-full items-center justify-between gap-3 rounded-xl border border-border/50 px-3.5 py-3 text-left transition-colors","hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",I&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:F}),t.jsx("span",{className:Z("relative h-6 w-10 shrink-0 rounded-full transition-colors",x?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:Z("absolute top-0.5 size-5 rounded-full bg-white transition-transform",x?"translate-x-[1.125rem]":"translate-x-0.5")})})]});return t.jsx(or,{open:s,onClose:o,title:i("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ge,{variant:"ghost",className:"flex-1",onClick:o,disabled:p,children:i("projectEditDialog.actions.cancel")}),t.jsx(ge,{variant:"destructive",className:"flex-1",onClick:()=>{_()},disabled:p,children:i("mobile.projectEdit.deleteWorktreeConfirmButton")})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx("p",{className:"typography-ui-body text-foreground",children:i("mobile.projectEdit.deleteWorktreeConfirm",{name:z})}),S?t.jsx("p",{className:"rounded-xl border border-[var(--warning)]/40 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] px-3.5 py-3 typography-meta text-foreground",children:i("mobile.projectEdit.deleteWorktreeDirty")}):null,N.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i("mobile.projectEdit.deleteWorktreeArchiveNote",{count:N.length})}):null,P?t.jsxs("div",{className:"flex flex-col gap-2",children:[w(f,g,i("mobile.projectEdit.deleteLocalBranch"),p),w(b,v,i("mobile.projectEdit.deleteRemoteBranch"),p)]}):null]})})},Tt="mobile-surface-root",fn=90,it=16,Ft=100,mn=48,hn=8,gn=()=>{if(typeof document>"u")return null;let s=document.getElementById(Tt);return s||(s=document.createElement("div"),s.id=Tt,document.body.appendChild(s)),s},Ve=({open:s,onClose:e,title:r,subtitle:o,trailing:n,onBack:i,disableSwipeDismiss:a=!1,headerless:h=!1,ariaLabel:c,children:d})=>{const{t:f}=ie(),g=u.useRef(null),[b,v]=u.useState(!1),[S,m]=u.useState(!1),[p,j]=u.useState(!1),[A,P]=u.useState(0),N=u.useRef(null),_=u.useRef(!1),z=u.useRef(null),w=u.useRef(null);typeof document<"u"&&!g.current&&(g.current=gn()),u.useEffect(()=>{if(s){v(!0);const G=window.setTimeout(()=>m(!0),it);return()=>window.clearTimeout(G)}m(!1);const T=window.setTimeout(()=>v(!1),300);return()=>window.clearTimeout(T)},[s]),u.useEffect(()=>{if(!s){j(!1);return}const T=window.setTimeout(()=>j(!0),it+Ft+80);return()=>window.clearTimeout(T)},[s]),u.useEffect(()=>{if(!s)return;const T=document.body.style.overflow;w.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const G=()=>{const $=z.current;if(!$)return;($.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??$).focus({preventScroll:!0})},U=window.setTimeout(G,it),k=$=>{if($.key==="Escape"){e();return}if($.key!=="Tab")return;const O=z.current;if(!O)return;const H=Array.from(O.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(Y=>!Y.hasAttribute("disabled")&&Y.getAttribute("aria-hidden")!=="true");if(H.length===0){$.preventDefault(),O.focus({preventScroll:!0});return}const q=H[0],R=H[H.length-1],V=document.activeElement;$.shiftKey&&V===q?($.preventDefault(),R.focus({preventScroll:!0})):!$.shiftKey&&V===R&&($.preventDefault(),q.focus({preventScroll:!0}))};return document.addEventListener("keydown",k),()=>{window.clearTimeout(U),document.body.style.overflow=T,document.removeEventListener("keydown",k),w.current?.focus?.({preventScroll:!0}),w.current=null}},[e,s]);const x=T=>{a||(N.current=T.touches[0]?.clientY??null,_.current=!0)},M=T=>{if(!_.current||N.current==null)return;const U=(T.touches[0]?.clientY??N.current)-N.current;P(U>0?U:0)},F=()=>{_.current&&(_.current=!1,N.current=null,A>=fn?(P(0),e()):P(0))};if(!b||!g.current)return null;const I=i?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":f("header.actions.backAria"),onClick:i,style:{touchAction:"manipulation"},children:t.jsx(Xe,{className:"size-5"})}):t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":f("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Fe,{className:"size-5"})}),L=S?A>0?`translateY(${A}px)`:"none":`translateY(${mn}px)`;return Is.createPortal(t.jsxs("div",{className:Z("fixed inset-0 z-50 flex flex-col bg-[rgb(0_0_0_/_0.45)]","transition-opacity duration-200 ease-out",S?"opacity-100":"opacity-0"),role:"dialog","aria-modal":"true","aria-label":c,onClick:e,children:[t.jsxs("section",{ref:z,className:"mt-auto flex min-h-0 w-full flex-col overflow-hidden rounded-t-[20px] border-t border-border/40 bg-background text-foreground",tabIndex:-1,onClick:T=>T.stopPropagation(),onTransitionEnd:T=>{S&&T.target===T.currentTarget&&T.propertyName==="transform"&&j(!0)},style:{height:`calc(100% - var(--oc-safe-area-top, 0px) - ${hn}px)`,transform:L,transition:_.current?"none":`transform ${Ft}ms cubic-bezier(0.32, 0.72, 0, 1)`},children:[t.jsxs("div",{className:"shrink-0 select-none",onTouchStart:x,onTouchMove:M,onTouchEnd:F,onTouchCancel:F,children:[t.jsx("div",{className:"flex items-center justify-center pt-2 pb-1",children:t.jsx("span",{className:"h-1 w-10 rounded-full bg-[var(--surface-muted)]","aria-hidden":!0})}),h?null:t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] items-center gap-2 px-3",children:[I,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[r?typeof r=="string"?t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:r}):r:null,o?typeof o=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:o}):o:null]}),n?t.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:n}):null]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:p?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:d}):null})]}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]}),g.current)},pn=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/,""),bn=s=>{const e=re.c(36),{worktree:r,onDelete:o}=s,{t:n}=ie();let i;e[0]!==r.path?(i={id:r.path},e[0]=r.path,e[1]=i):i=e[1];const{attributes:a,listeners:h,setNodeRef:c,transform:d,transition:f,isDragging:g}=ss(i);let b;e[2]!==d?(b=rs.Transform.toString(d),e[2]=d,e[3]=b):b=e[3];const v=g?10:1;let S;e[4]!==b||e[5]!==v||e[6]!==f?(S={transform:b,transition:f,zIndex:v},e[4]=b,e[5]=v,e[6]=f,e[7]=S):S=e[7];const m=S,p=r.branch||r.label||r.path,j=g&&"shadow-lg shadow-black/20";let A;e[8]!==j?(A=Z("flex items-center gap-1 rounded-2xl border border-border/40 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",j),e[8]=j,e[9]=A):A=e[9];let P;e[10]!==p||e[11]!==n?(P=n("mobile.projectEdit.dragWorktreeAria",{label:p}),e[10]=p,e[11]=n,e[12]=P):P=e[12];let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(ns,{className:"size-4"}),e[13]=N):N=e[13];let _;e[14]!==a||e[15]!==h||e[16]!==P?(_=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":P,...a,...h,children:N}),e[14]=a,e[15]=h,e[16]=P,e[17]=_):_=e[17];let z;e[18]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx(ze,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[18]=z):z=e[18];let w;e[19]!==p?(w=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:p}),e[19]=p,e[20]=w):w=e[20];let x;e[21]!==p||e[22]!==n?(x=n("mobile.projectEdit.deleteWorktreeAria",{label:p}),e[21]=p,e[22]=n,e[23]=x):x=e[23];let M,F;e[24]===Symbol.for("react.memo_cache_sentinel")?(M={touchAction:"manipulation"},F=t.jsx(dt,{className:"size-4"}),e[24]=M,e[25]=F):(M=e[24],F=e[25]);let I;e[26]!==o||e[27]!==x?(I=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive","aria-label":x,onClick:o,style:M,children:F}),e[26]=o,e[27]=x,e[28]=I):I=e[28];let L;return e[29]!==c||e[30]!==m||e[31]!==w||e[32]!==I||e[33]!==A||e[34]!==_?(L=t.jsxs("div",{ref:c,style:m,className:A,children:[_,z,w,I]}),e[29]=c,e[30]=m,e[31]=w,e[32]=I,e[33]=A,e[34]=_,e[35]=L):L=e[35],L},xn=({open:s,project:e,onClose:r,onWorktreesChanged:o})=>{const{t:n}=ie(),{currentTheme:i}=xt(),a=me(k=>k.updateProjectMeta),h=me(k=>k.discoverProjectIcon),c=me(k=>k.removeProjectIcon),d=gs(k=>k.setWorktreeOrder),f=me(k=>e?k.projects.find($=>$.id===e.id)?.iconImage??null:null),[g,b]=u.useState(""),[v,S]=u.useState(null),[m,p]=u.useState(null),[j,A]=u.useState(!1),[P,N]=u.useState([]),[_,z]=u.useState(null),w=e?.id??null;u.useEffect(()=>{!s||!e||(b(e.label),S(e.icon??null),p(e.color??null),N(e.worktrees))},[s,w]),u.useEffect(()=>{!s||!e||N(k=>{const $=e.worktrees.map(q=>q.path),O=k.map(q=>q.path);return $.length===O.length&&$.every(q=>O.includes(q))?k:e.worktrees})},[e?.worktrees]);const x=Kt(Je(Jt,{activationConstraint:{distance:8}}),Je(Yt,{coordinateGetter:qt})),M=()=>{if(!e)return;const k=g.trim();a(e.id,{label:k||e.label,icon:v,color:m}),r()},F=()=>{!e||j||(A(!0),h(e.id).then(k=>{if(!k.ok){Q.error(k.error||n("projectEditDialog.toast.failedToDiscoverIcon"));return}if(k.skipped){Q.success(n("projectEditDialog.toast.customIconAlreadySet"));return}Q.success(n("projectEditDialog.toast.iconDiscovered"))}).finally(()=>A(!1)))},I=()=>{e&&c(e.id).then(k=>{if(!k.ok){Q.error(k.error||n("projectEditDialog.toast.failedToRemoveIcon"));return}Q.success(n("projectEditDialog.toast.iconRemoved"))})},L=k=>{const{active:$,over:O}=k;if(!O||$.id===O.id||!e)return;const H=P.findIndex(Y=>Y.path===$.id),q=P.findIndex(Y=>Y.path===O.id);if(H<0||q<0)return;const R=[...P],[V]=R.splice(H,1);R.splice(q,0,V),N(R),d(e.id,R.map(Y=>pn(Y.path)))},T=m?us[m]??null:null,G=v?ds[v]:null,U=!!f;return t.jsxs(t.Fragment,{children:[t.jsx(Ve,{open:s,onClose:r,onBack:r,title:n("projectEditDialog.title"),ariaLabel:n("projectEditDialog.title"),trailing:t.jsxs(ge,{type:"button",variant:"default",size:"sm","aria-label":n("projectEditDialog.actions.save"),onClick:M,disabled:!g.trim(),style:{touchAction:"manipulation"},children:[t.jsx(ts,{className:"size-4"}),n("projectEditDialog.actions.save")]}),children:e?t.jsxs("div",{className:"h-full space-y-6 overflow-y-auto px-4 pb-8 pt-2",children:[t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx("span",{className:"flex size-16 items-center justify-center overflow-hidden rounded-2xl bg-[var(--surface-muted)] text-muted-foreground",style:e.iconBackground?{backgroundColor:e.iconBackground}:void 0,children:U?t.jsx(fs,{project:{id:e.id,iconImage:f},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(ut,{className:"size-7"})}):G?t.jsx(ze,{name:G,className:"size-7",style:T?{color:T}:void 0}):t.jsx(ut,{className:"size-7",style:T?{color:T}:void 0})})}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:n("projectEditDialog.field.name")}),t.jsx(bt,{value:g,onChange:k=>b(k.target.value),placeholder:n("projectEditDialog.field.namePlaceholder"),className:"h-11"}),t.jsx("p",{className:"truncate typography-meta text-muted-foreground",title:e.path,children:e.path})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:n("projectEditDialog.field.color")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>p(null),"aria-label":n("projectEditDialog.option.none"),className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",m===null?"border-foreground":"border-border hover:border-border/80"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),lr.map(k=>t.jsx("button",{type:"button",onClick:()=>p(k.key),"aria-label":k.label,title:k.label,className:Z("size-9 rounded-xl border-2 transition-all",m===k.key?"border-foreground":"border-transparent hover:border-border"),style:{backgroundColor:k.cssVar,touchAction:"manipulation"}},k.key))]})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:n("projectEditDialog.field.icon")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>S(null),"aria-label":n("projectEditDialog.option.none"),className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",v===null?"border-foreground bg-[var(--surface-elevated)]":"border-border hover:border-border/80"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),ar.map(k=>t.jsx("button",{type:"button",onClick:()=>S(k.key),"aria-label":k.label,title:k.label,className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",v===k.key?"border-foreground bg-[var(--surface-elevated)]":"border-border hover:border-border/80"),style:{touchAction:"manipulation"},children:t.jsx(ze,{name:k.Icon,className:"size-4",style:T?{color:T}:void 0})},k.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(ge,{size:"sm",variant:"outline",onClick:F,disabled:j,children:n(j?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),U?t.jsx(ge,{size:"sm",variant:"outline",onClick:I,children:n("projectEditDialog.actions.removeProjectIcon")}):null]})]}),e.isGitRepo?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:n("mobile.projectEdit.worktreesTitle")}),P.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("mobile.projectEdit.worktreesEmpty")}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("mobile.projectEdit.reorderHint")}),t.jsx(Qt,{sensors:x,collisionDetection:Xt,onDragEnd:L,children:t.jsx(Zt,{items:P.map(k=>k.path),strategy:es,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:P.map(k=>t.jsx(bn,{worktree:k,onDelete:()=>z(k)},k.path))})})})]})]}):null]}):null}),e?t.jsx(dn,{open:!!_,project:{id:e.id,path:e.path},worktree:_,onClose:()=>z(null),onDeleted:()=>{N(k=>k.filter($=>$.path!==_?.path)),o?.()}}):null]})},lt=7,yn=36,vn=52,jn=18,Bt=s=>s.parentID??null,xe=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/g,""),Re=s=>{const e=s;return xe(e.directory??e.project?.worktree??null)},at=s=>{const e=xe(s);if(!e)return"";const r=e.split("/").filter(Boolean);return r[r.length-1]?.replace(/[-_]/g," ")||e},Ge=s=>{const e=s.time?.updated??s.time?.created,r=typeof e=="number"?e:Number(e);return Number.isFinite(r)&&r>0?r:0},wn=s=>{if(s<=0)return"";const e=Date.now()-s;if(e<6e4)return"now";const r=Math.floor(e/6e4);if(r<60)return`${r}m`;const o=Math.floor(r/60);if(o<24)return`${o}h`;const n=Math.floor(o/24);return n<7?`${n}d`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(s))},fe=(s,e)=>{const r=xe(s),o=xe(e);return!!(r&&o&&(r===o||r.startsWith(`${o}/`)))},ct=(s,e,r)=>r?`${s.title??""} ${s.id} ${Re(s)} ${e}`.toLowerCase().includes(r):!0,ft=s=>{const e=re.c(17),{project:r,size:o}=s,n=o===void 0?"md":o,{currentTheme:i}=xt(),a=r.icon?ds[r.icon]:null,h=r.color?us[r.color]??null:null,c=n==="sm"?"size-6 rounded-md":"size-8 rounded-lg",d=n==="sm"?"size-3.5":"size-4";let f;e[0]!==a||e[1]!==h||e[2]!==d?(f=a?t.jsx(ze,{name:a,className:d,style:h?{color:h}:void 0}):t.jsx(ut,{className:d,style:h?{color:h}:void 0}),e[0]=a,e[1]=h,e[2]=d,e[3]=f):f=e[3];const g=f;let b;e[4]!==c?(b=Z("flex shrink-0 items-center justify-center overflow-hidden bg-[var(--surface-muted)] text-muted-foreground",c),e[4]=c,e[5]=b):b=e[5];let v;e[6]!==r.iconBackground?(v=r.iconBackground?{backgroundColor:r.iconBackground}:void 0,e[6]=r.iconBackground,e[7]=v):v=e[7];let S;e[8]!==i||e[9]!==g||e[10]!==r.iconImage||e[11]!==r.id?(S=r.iconImage?t.jsx(fs,{project:{id:r.id,iconImage:r.iconImage??null},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:g}):g,e[8]=i,e[9]=g,e[10]=r.iconImage,e[11]=r.id,e[12]=S):S=e[12];let m;return e[13]!==b||e[14]!==v||e[15]!==S?(m=t.jsx("span",{className:b,style:v,children:S}),e[13]=b,e[14]=v,e[15]=S,e[16]=m):m=e[16],m},kn=s=>{const e=re.c(5),{expanded:r}=s,o=r?"rotate-0":"-rotate-90";let n;e[0]!==o?(n=Z("flex size-5 shrink-0 items-center justify-center text-muted-foreground/70 transition-transform duration-150",o),e[0]=o,e[1]=n):n=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(ht,{className:"size-4"}),e[2]=i):i=e[2];let a;return e[3]!==n?(a=t.jsx("span",{"aria-hidden":!0,className:n,children:i}),e[3]=n,e[4]=a):a=e[4],a},$t=s=>{const e=re.c(2),{ariaLabel:r}=s;let o;return e[0]!==r?(o=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":r}),e[0]=r,e[1]=o):o=e[1],o},Ot=s=>{const e=re.c(12),{onClick:r,className:o}=s,{t:n}=ie();let i;e[0]!==n?(i=n("sessions.sidebar.project.actions.newWorktree"),e[0]=n,e[1]=i):i=e[1];const a=i;let h;e[2]!==o?(h=Z("flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",o),e[2]=o,e[3]=h):h=e[3];let c;e[4]!==r?(c=b=>{b.stopPropagation(),r()},e[4]=r,e[5]=c):c=e[5];let d,f;e[6]===Symbol.for("react.memo_cache_sentinel")?(d={touchAction:"manipulation"},f=t.jsx(ze,{name:"node-tree",className:"size-4"}),e[6]=d,e[7]=f):(d=e[6],f=e[7]);let g;return e[8]!==a||e[9]!==h||e[10]!==c?(g=t.jsx("button",{type:"button",className:h,"aria-label":a,title:a,onClick:c,style:d,children:f}),e[8]=a,e[9]=h,e[10]=c,e[11]=g):g=e[11],g},Wt=s=>{const e=re.c(55),{session:r,active:o,indent:n,contextLabel:i,confirmingArchive:a,hasChildren:h,expanded:c,onToggleChildren:d,onSelect:f,onRequestArchive:g,onConfirmArchive:b}=s,v=a===void 0?!1:a,S=h===void 0?!1:h,m=c===void 0?!1:c,{t:p}=ie();let j;e[0]!==r?(j=wn(Ge(r)),e[0]=r,e[1]=j):j=e[1];const A=j;let P;e[2]!==r.title||e[3]!==p?(P=r.title?.trim()||p("mobile.sessions.untitled"),e[2]=r.title,e[3]=p,e[4]=P):P=e[4];const N=P,_=o&&!v&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]",z=v&&"bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]";let w;e[5]!==_||e[6]!==z?(w=Z("relative flex items-center gap-1 transition-colors",_,z),e[5]=_,e[6]=z,e[7]=w):w=e[7];let x;e[8]!==m||e[9]!==S||e[10]!==n||e[11]!==d||e[12]!==p?(x=S&&d?t.jsx("button",{type:"button",className:"absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",style:{left:Math.max(n-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":p(m?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),onClick:de=>{de.stopPropagation(),d()},children:t.jsx(ht,{className:Z("size-[18px] transition-transform duration-150",m?"rotate-0":"-rotate-90")})}):null,e[8]=m,e[9]=S,e[10]=n,e[11]=d,e[12]=p,e[13]=x):x=e[13];const M=v&&"opacity-50";let F;e[14]!==M?(F=Z("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",M),e[14]=M,e[15]=F):F=e[15];let I;e[16]!==n?(I={paddingLeft:n,touchAction:"manipulation"},e[16]=n,e[17]=I):I=e[17];const L=o?"bg-primary":"bg-muted-foreground/30";let T;e[18]!==L?(T=Z("size-1.5 shrink-0 rounded-full",L),e[18]=L,e[19]=T):T=e[19];let G;e[20]!==T?(G=t.jsx("span",{className:T,"aria-hidden":!0}),e[20]=T,e[21]=G):G=e[21];const U=o?"text-primary":"text-foreground";let k;e[22]!==U?(k=Z("block min-w-0 flex-1 truncate typography-ui-label",U),e[22]=U,e[23]=k):k=e[23];let $;e[24]!==k||e[25]!==N?($=t.jsx("span",{className:k,children:N}),e[24]=k,e[25]=N,e[26]=$):$=e[26];let O;e[27]!==A?(O=A?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:A}):null,e[27]=A,e[28]=O):O=e[28];let H;e[29]!==G||e[30]!==$||e[31]!==O?(H=t.jsxs("span",{className:"flex items-center gap-2.5",children:[G,$,O]}),e[29]=G,e[30]=$,e[31]=O,e[32]=H):H=e[32];let q;e[33]!==i?(q=i?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground pl-4",children:i}):null,e[33]=i,e[34]=q):q=e[34];let R;e[35]!==H||e[36]!==q?(R=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[H,q]}),e[35]=H,e[36]=q,e[37]=R):R=e[37];let V;e[38]!==v||e[39]!==f||e[40]!==F||e[41]!==I||e[42]!==R?(V=t.jsx("button",{type:"button",className:F,style:I,onClick:f,disabled:v,children:R}),e[38]=v,e[39]=f,e[40]=F,e[41]=I,e[42]=R,e[43]=V):V=e[43];let Y;e[44]!==v||e[45]!==b||e[46]!==g||e[47]!==p||e[48]!==N?(Y=g?t.jsxs(t.Fragment,{children:[v?t.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":p("mobile.sessions.archiveSessionAria",{title:N}),onClick:b,style:{touchAction:"manipulation"},children:[t.jsx(Ct,{className:"size-4"}),t.jsx("span",{className:"typography-ui-label",children:p("sessions.sidebar.bulkActions.archive")})]}):null,t.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":v?p("mobile.sessions.cancelArchiveAria",{title:N}):p("mobile.sessions.archiveSessionAria",{title:N}),onClick:g,style:{touchAction:"manipulation"},children:v?t.jsx(Fe,{className:"size-4"}):t.jsx(Ct,{className:"size-4"})})]}):null,e[44]=v,e[45]=b,e[46]=g,e[47]=p,e[48]=N,e[49]=Y):Y=e[49];let se;return e[50]!==V||e[51]!==Y||e[52]!==w||e[53]!==x?(se=t.jsxs("div",{className:w,children:[x,V,Y]}),e[50]=V,e[51]=Y,e[52]=w,e[53]=x,e[54]=se):se=e[54],se},Sn=s=>{const e=re.c(11),{indent:r,onClick:o}=s,{t:n}=ie();let i;e[0]!==r?(i={paddingLeft:r,touchAction:"manipulation"},e[0]=r,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(ht,{className:"size-4"}),e[2]=a):a=e[2];let h;e[3]!==n?(h=n("sessions.sidebar.group.showMore"),e[3]=n,e[4]=h):h=e[4];let c;e[5]!==h?(c=t.jsx("span",{className:"typography-micro",children:h}),e[5]=h,e[6]=c):c=e[6];let d;return e[7]!==o||e[8]!==i||e[9]!==c?(d=t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-2 py-1.5 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",style:i,onClick:o,children:[a,c]}),e[7]=o,e[8]=i,e[9]=c,e[10]=d):d=e[10],d},Nn=s=>{const e=re.c(11),{indent:r,onClick:o}=s,{t:n}=ie();let i;e[0]!==r?(i={paddingLeft:r,touchAction:"manipulation"},e[0]=r,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Ms,{className:"size-4"}),e[2]=a):a=e[2];let h;e[3]!==n?(h=n("sessions.sidebar.group.showFewer"),e[3]=n,e[4]=h):h=e[4];let c;e[5]!==h?(c=t.jsx("span",{className:"typography-micro",children:h}),e[5]=h,e[6]=c):c=e[6];let d;return e[7]!==o||e[8]!==i||e[9]!==c?(d=t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-2 py-1.5 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",style:i,onClick:o,children:[a,c]}),e[7]=o,e[8]=i,e[9]=c,e[10]=d):d=e[10],d},Cn=s=>{const e=re.c(53),{project:r,totalSessions:o,confirmingDelete:n,onEdit:i,onRequestRemove:a,onConfirmRemove:h}=s,{t:c}=ie();let d;e[0]!==r.id?(d={id:r.id},e[0]=r.id,e[1]=d):d=e[1];const{attributes:f,listeners:g,setNodeRef:b,transform:v,transition:S,isDragging:m}=ss(d);let p;e[2]!==v?(p=rs.Transform.toString(v),e[2]=v,e[3]=p):p=e[3];const j=m?10:1;let A;e[4]!==p||e[5]!==j||e[6]!==S?(A={transform:p,transition:S,zIndex:j},e[4]=p,e[5]=j,e[6]=S,e[7]=A):A=e[7];const P=A,N=m&&"shadow-lg shadow-black/20",_=n&&"border-destructive/50 bg-[color-mix(in_srgb,var(--destructive)_8%,var(--surface-elevated))]";let z;e[8]!==N||e[9]!==_?(z=Z("flex items-center gap-1 rounded-2xl border border-border/40 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",N,_),e[8]=N,e[9]=_,e[10]=z):z=e[10];let w;e[11]!==r.label||e[12]!==c?(w=c("mobile.sessions.dragHandleAria",{label:r.label}),e[11]=r.label,e[12]=c,e[13]=w):w=e[13];let x;e[14]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(ns,{className:"size-4"}),e[14]=x):x=e[14];let M;e[15]!==f||e[16]!==g||e[17]!==w?(M=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":w,...f,...g,children:x}),e[15]=f,e[16]=g,e[17]=w,e[18]=M):M=e[18];let F;e[19]!==r?(F=t.jsx(ft,{project:r}),e[19]=r,e[20]=F):F=e[20];let I;e[21]!==r.label?(I=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:r.label}),e[21]=r.label,e[22]=I):I=e[22];let L;e[23]!==n||e[24]!==h||e[25]!==i||e[26]!==r.label||e[27]!==c||e[28]!==o?(L=n?t.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":c("mobile.sessions.confirmRemoveProjectAria",{label:r.label}),onClick:h,style:{touchAction:"manipulation"},children:[t.jsx(dt,{className:"size-4"}),t.jsx("span",{className:"typography-ui-label",children:c("mobile.sessions.confirmRemoveProject")})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:o}),t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl 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":c("mobile.sessions.editProjectAria",{label:r.label}),onClick:i,style:{touchAction:"manipulation"},children:t.jsx(os,{className:"size-4"})})]}),e[23]=n,e[24]=h,e[25]=i,e[26]=r.label,e[27]=c,e[28]=o,e[29]=L):L=e[29];const T=n?"text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:ring-primary":"text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:ring-destructive";let G;e[30]!==T?(G=Z("flex size-9 shrink-0 items-center justify-center rounded-xl transition-colors focus-visible:outline-none focus-visible:ring-2",T),e[30]=T,e[31]=G):G=e[31];let U;e[32]!==n||e[33]!==r.label||e[34]!==c?(U=n?c("mobile.sessions.cancelRemoveProjectAria",{label:r.label}):c("mobile.sessions.removeProjectAria",{label:r.label}),e[32]=n,e[33]=r.label,e[34]=c,e[35]=U):U=e[35];let k;e[36]===Symbol.for("react.memo_cache_sentinel")?(k={touchAction:"manipulation"},e[36]=k):k=e[36];let $;e[37]!==n?($=n?t.jsx(Fe,{className:"size-4"}):t.jsx(dt,{className:"size-4"}),e[37]=n,e[38]=$):$=e[38];let O;e[39]!==a||e[40]!==G||e[41]!==U||e[42]!==$?(O=t.jsx("button",{type:"button",className:G,"aria-label":U,onClick:a,style:k,children:$}),e[39]=a,e[40]=G,e[41]=U,e[42]=$,e[43]=O):O=e[43];let H;return e[44]!==b||e[45]!==P||e[46]!==M||e[47]!==F||e[48]!==I||e[49]!==L||e[50]!==O||e[51]!==z?(H=t.jsxs("div",{ref:b,style:P,className:z,children:[M,F,I,L,O]}),e[44]=b,e[45]=P,e[46]=M,e[47]=F,e[48]=I,e[49]=L,e[50]=O,e[51]=z,e[52]=H):H=e[52],H},En=({open:s,onOpenChange:e})=>{const{t:r}=ie(),{git:o}=gt(),n=as(),i=cs(l=>l.activeSessions),a=me(l=>l.projects),h=me(l=>l.activeProjectId),c=Ie(l=>l.currentDirectory),d=je(l=>l.currentSessionId),f=je(l=>l.setCurrentSession),g=je(l=>l.archiveSession),b=je(l=>l.openNewSessionDraft),v=me(l=>l.setActiveProject),S=me(l=>l.setActiveProjectIdOnly),m=me(l=>l.reorderProjects),p=me(l=>l.removeProject),j=Ye(l=>l.projectExpanded),A=Ye(l=>l.worktreeExpanded),P=Ye(l=>l.setProjectExpanded),N=Ye(l=>l.setWorktreeExpanded),_=gs(l=>l.orderByProject),z=zt(l=>l.expandedParents),w=zt(l=>l.toggleParent),[x,M]=u.useState(""),[F,I]=u.useState(null),[L,T]=u.useState(null),[G,U]=u.useState(0),[k,$]=u.useState(!1),[O,H]=u.useState(!1),[q,R]=u.useState(null),[V,Y]=u.useState(new Map),[se,de]=u.useState(new Set),[te,ae]=u.useState(!1),[Ne,ye]=u.useState(null),[Ze,Ae]=u.useState(new Map);u.useEffect(()=>{if(!s){M(""),ae(!1),ye(null),Ae(new Map),I(null),T(null);return}cr(n)},[s]),u.useEffect(()=>{te||ye(null)},[te]),u.useEffect(()=>{if(!s||a.length===0)return;let l=!1;return(async()=>{const D=await Promise.all(a.map(async K=>{const le=xe(K.path);if(!le)return null;const X=await o.checkIsGitRepository(le).catch(()=>!1),ue=X?await ms({id:K.id,path:le}).catch(()=>[]):[];return[le,ue,X]}));if(l)return;const B=new Map,J=new Set;for(const K of D)K&&(B.set(K[0],K[1]),K[2]&&J.add(K[0]));Y(B),de(J)})(),()=>{l=!0}},[o,s,a,G]);const ee=u.useMemo(()=>a.map(l=>({id:l.id,label:l.label?.trim()||at(l.path),path:xe(l.path),icon:l.icon,color:l.color,iconImage:l.iconImage,iconBackground:l.iconBackground,isGitRepo:se.has(xe(l.path)),worktrees:cn(_[l.id],V.get(xe(l.path))??[])})),[se,a,_,V]),he=u.useMemo(()=>{const l=new Map(n.map(B=>[B.id,B])),E=i.map(B=>{const J=l.get(B.id);return J?ur(J,B):B}),D=new Set(E.map(B=>B.id));for(const B of n)D.has(B.id)||E.push(B);return E},[i,n]),oe=x.trim().toLowerCase(),pe=u.useMemo(()=>{const l=ee.map(D=>({project:D,buckets:[],totalSessions:0,isActive:D.id===h})),E=(D,B,J)=>{const K=xe(B)||D.project.path,le=K||"__root__";let X=D.buckets.find(ue=>ue.key===le);return X||(X={key:le,label:J?.branch||at(K),path:K,worktree:J,sessions:[]},D.buckets.push(X)),X};for(const D of l){E(D,D.project.path,null);for(const B of D.project.worktrees)E(D,B.path,B)}for(const D of he){const B=Re(D);if(!B)continue;const J=l.find(X=>fe(B,X.project.path)?!0:X.project.worktrees.some(ue=>fe(B,ue.path)));if(!J)continue;const K=J.project.worktrees.find(X=>fe(B,X.path));(K?E(J,K.path,K):E(J,J.project.path,null)).sessions.push(D)}for(const D of l)for(const B of D.buckets)B.sessions.sort((J,K)=>Ge(K)-Ge(J)),D.totalSessions+=B.sessions.length;return l},[h,ee,he]),Pe=xe(c),Be=l=>l.isActive?Pe===l.project.path?l.project.path:l.project.worktrees.find(D=>fe(Pe,D.path))?.path??l.project.path:null,et=l=>j[l.project.id]??!0,tt=(l,E)=>A[`${l.project.id}::${E.key}`]??!1,Ue=l=>{Ae(E=>{if(!E.has(l))return E;const D=new Map(E);return D.delete(l),D})},He=l=>{Ae(E=>{let D=!1;const B=new Map(E),J=`${l}::`;for(const K of B.keys())K.startsWith(J)&&(B.delete(K),D=!0);return D?B:E})},st=(l,E)=>{Ae(D=>{const B=new Map(D);return B.set(l,E+lt),B})},y=(l,E,D)=>{const B=`${l.project.id}::${E.key}`,J=new Set(E.sessions.map(ne=>ne.id)),K=new Map;for(const ne of E.sessions){const be=Bt(ne);if(be&&J.has(be)){const Oe=K.get(be)??[];Oe.push(ne),K.set(be,Oe)}}const le=E.sessions.filter(ne=>{const be=Bt(ne);return!be||!J.has(be)}),X=Ze.get(B)??lt,ue=le.slice(0,X),De=le.length-ue.length,Ss=le.length>lt&&De===0,kt=(ne,be)=>{const Oe=K.get(ne.id)??[],ot=Oe.length>0,St=!!z[ne.id];return t.jsxs(u.Fragment,{children:[t.jsx(Wt,{session:ne,active:d===ne.id,indent:be,hasChildren:ot,expanded:St,onToggleChildren:ot?()=>w(ne.id):void 0,confirmingArchive:L===ne.id,onSelect:()=>ce(ne),onRequestArchive:()=>we(ne.id),onConfirmArchive:()=>{$e(ne)}}),ot&&St?Oe.map(Ns=>kt(Ns,be+jn)):null]},ne.id)};return t.jsxs("div",{children:[ue.map(ne=>kt(ne,D)),De>0?t.jsx(Sn,{indent:D,onClick:()=>st(B,ue.length)}):null,Ss?t.jsx(Nn,{indent:D,onClick:()=>Ue(B)}):null]})},C=(l,E)=>{P(l,!E),He(l)},W=(l,E,D)=>{N(`${l}::${E}`,!D),Ue(`${l}::${E}`)},ce=l=>{const E=Re(l)||null,D=ee.find(B=>fe(E??"",B.path)?!0:B.worktrees.some(J=>fe(E??"",J.path)));D&&S(D.id),f(l.id,E),e(!1)},we=l=>{T(E=>E===l?null:l)},$e=async l=>{T(null),await g(l.id)?Q.success(r("sessions.sidebar.session.archive.success")):Q.error(r("sessions.sidebar.session.archive.error"))},yt=()=>{b(),e(!1)},rt=l=>{R(l),S(l),H(!0)},nt=Kt(Je(Jt,{activationConstraint:{distance:8}}),Je(Yt,{coordinateGetter:qt})),ps=l=>{const{active:E,over:D}=l;if(ye(null),!D||E.id===D.id)return;const B=ee.findIndex(K=>K.id===E.id),J=ee.findIndex(K=>K.id===D.id);B<0||J<0||m(B,J)},bs=l=>{ye(E=>E===l?null:l)},xs=l=>{p(l.id),ye(null),Q.success(r("mobile.sessions.toast.projectRemoved",{label:l.label}))},ys=u.useCallback(l=>{const E=Re(l),D=ee.find(J=>fe(E,J.path)?!0:J.worktrees.some(K=>fe(E,K.path)));if(!D)return at(E)||E;const B=D.worktrees.find(J=>fe(E,J.path));return B?.branch?`${D.label} · ${B.branch}`:D.label},[ee]),vs=l=>{v(l.id),e(!1)},js=u.useMemo(()=>oe?pe.filter(l=>`${l.project.label} ${l.project.path}`.toLowerCase().includes(oe)?!0:l.buckets.some(E=>E.sessions.some(D=>ct(D,l.project.label,oe)))):pe,[oe,pe]),Ke=u.useMemo(()=>oe?he.filter(l=>{const E=Re(l),D=ee.find(B=>fe(E,B.path)?!0:B.worktrees.some(J=>fe(E,J.path)));return ct(l,D?.label??"",oe)}).sort((l,E)=>Ge(E)-Ge(l)):[],[oe,ee,he]),qe=u.useMemo(()=>oe?ee.filter(l=>`${l.label} ${l.path}`.toLowerCase().includes(oe)).map(l=>({...l,sessionCount:he.filter(E=>{const D=Re(E);return fe(D,l.path)?!0:l.worktrees.some(B=>fe(D,B.path))}).length})):[],[oe,ee,he]),ws=oe&&Ke.length===0&&qe.length===0,vt=!oe&&ee.length>1?t.jsx(ge,{type:"button",variant:"chip",size:"sm","aria-label":r(te?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":te,onClick:()=>ae(l=>!l),style:{touchAction:"manipulation"},children:te?t.jsx(ts,{className:"size-4"}):t.jsx(os,{className:"size-4"})}):null,jt=!te&&ee.length>0?t.jsxs(ge,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:yt,style:{touchAction:"manipulation"},children:[t.jsx(zs,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,wt=te?null:t.jsx(ge,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.addProject"),title:r("sessions.sidebar.header.actions.addProject"),onClick:()=>$(!0),style:{touchAction:"manipulation"},children:t.jsx(Nt,{className:"size-4"})}),ks=jt||wt||vt?t.jsxs(t.Fragment,{children:[jt,wt,vt]}):null;return t.jsx(Ve,{open:s,onClose:()=>e(!1),ariaLabel:r("mobile.sessions.sheet.title"),title:r("mobile.sessions.sheet.title"),trailing:ks,children:t.jsxs("div",{className:"flex h-full flex-col",children:[t.jsx("div",{className:Z("shrink-0 px-4 pb-2 pt-1",te&&"hidden"),children:t.jsxs("div",{className:"relative",children:[t.jsx(Ut,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(bt,{value:x,onChange:l=>M(l.target.value),placeholder:r("mobile.sessions.search.placeholder"),className:Z("h-11 pl-9",x&&"pr-10")}),x?t.jsx("button",{type:"button",className:"absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":r("mobile.sessions.clearSearchAria"),onClick:()=>M(""),style:{touchAction:"manipulation"},children:t.jsx(Fe,{className:"size-4"})}):null]})}),t.jsx(Ee,{className:"min-h-0 flex-1 overflow-y-auto pb-4",children:ee.length===0?t.jsx(Lt,{title:r("mobile.sessions.empty.noProjectsTitle"),description:r("mobile.sessions.empty.noProjectsDescription"),action:t.jsxs("button",{type:"button",className:"flex items-center justify-center gap-2 rounded-2xl bg-primary px-5 py-3 typography-ui-label text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>$(!0),children:[t.jsx(Nt,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):ws?t.jsx(Lt,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):oe&&!te?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[Ke.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.search.section.sessions")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:Ke.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]",children:Ke.map((l,E)=>t.jsx("div",{className:Z(E>0&&"border-t border-border/30"),children:t.jsx(Wt,{session:l,active:d===l.id,indent:12,contextLabel:ys(l),onSelect:()=>ce(l)})},l.id))})]}):null,qe.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.search.section.projects")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:qe.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]",children:qe.map((l,E)=>t.jsxs("div",{className:Z("flex items-center",E>0&&"border-t border-border/30"),children:[t.jsxs("button",{type:"button",className:"flex min-h-14 min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>vs(l),style:{touchAction:"manipulation"},children:[t.jsx(ft,{project:l}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:l.label}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:l.sessionCount})]}),l.isGitRepo?t.jsx(Ot,{className:"mr-2",onClick:()=>rt(l.id)}):null]},l.id))})]}):null]}):te?t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2",children:[t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:r("mobile.sessions.editOrderHint")}),t.jsx(Qt,{sensors:nt,collisionDetection:Xt,onDragEnd:ps,children:t.jsx(Zt,{items:ee.map(l=>l.id),strategy:es,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:ee.map(l=>{const E=pe.find(D=>D.project.id===l.id);return t.jsx(Cn,{project:l,totalSessions:E?.totalSessions??0,confirmingDelete:Ne===l.id,onEdit:()=>I(l.id),onRequestRemove:()=>bs(l.id),onConfirmRemove:()=>xs(l)},l.id)})})})})]}):t.jsx("div",{className:"flex flex-col",children:js.map((l,E)=>{const D=et(l),B=oe?l.buckets.filter(K=>K.sessions.some(le=>ct(le,l.project.label,oe))):l.buckets,J=Be(l);return t.jsxs("section",{className:Z(E>0&&"border-t border-border/30"),children:[t.jsxs("div",{className:"flex min-h-14 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-14 min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>C(l.project.id,D),"aria-expanded":D,"aria-label":D?r("sessions.sidebar.group.collapseAria",{label:l.project.label}):r("sessions.sidebar.group.expandAria",{label:l.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(ft,{project:l.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:l.project.label}),l.isActive?t.jsx($t,{ariaLabel:r("mobile.sessions.activeProjectAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:l.totalSessions})]}),l.project.isGitRepo?t.jsx(Ot,{className:"mr-2",onClick:()=>rt(l.project.id)}):null]}),D?t.jsx("div",{className:"pb-2",children:(()=>{const K=B.find(X=>X.worktree===null),le=B.filter(X=>X.worktree!==null);return t.jsxs(t.Fragment,{children:[K&&K.sessions.length>0?y(l,K,yn):null,le.map(X=>{const ue=tt(l,X),De=J===X.path;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-center gap-2 py-1.5 pl-4 pr-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",onClick:()=>W(l.project.id,X.key,ue),"aria-expanded":ue,"aria-label":ue?r("sessions.sidebar.group.collapseAria",{label:X.label}):r("sessions.sidebar.group.expandAria",{label:X.label}),style:{touchAction:"manipulation"},children:[t.jsx(kn,{expanded:ue}),t.jsx(ze,{name:"node-tree",className:Z("size-4 shrink-0",De?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Z("block min-w-0 flex-1 truncate typography-ui-label font-semibold",De?"text-foreground":"text-foreground/90"),children:X.label}),De?t.jsx($t,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:X.sessions.length})]}),ue?y(l,X,vn):null]},X.key)})]})})()}):null]},l.project.id)})})}),t.jsx(Or,{open:k,onOpenChange:$}),t.jsx(Wr,{open:O,onOpenChange:l=>{H(l),l||R(null)},onWorktreeCreated:(l,E)=>{E?.sessionId?f(E.sessionId,l):b({selectedProjectId:q,directoryOverride:l,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(xn,{open:F!==null,project:ee.find(l=>l.id===F)??null,onClose:()=>I(null),onWorktreesChanged:()=>U(l=>l+1)})]})})},Lt=s=>{const e=re.c(10),{title:r,description:o,action:n}=s;let i;e[0]!==r?(i=t.jsx("p",{className:"typography-ui-label text-foreground",children:r}),e[0]=r,e[1]=i):i=e[1];let a;e[2]!==o?(a=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[2]=o,e[3]=a):a=e[3];let h;e[4]!==n?(h=n?t.jsx("div",{className:"pt-2",children:n}):null,e[4]=n,e[5]=h):h=e[5];let c;return e[6]!==i||e[7]!==a||e[8]!==h?(c=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[i,a,h]}),e[6]=i,e[7]=a,e[8]=h,e[9]=c):c=e[9],c},An=["appearance","chat","notifications","sessions","git","magic-prompts","behavior","mcp","providers","usage","voice"],Qe=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/g,""),Pn=s=>{const e=Qe(s);if(!e)return"";const r=e.split("/").filter(Boolean);return r[r.length-1]?.replace(/[-_]/g," ")||e},Dn=s=>{const e=re.c(24),{open:r,onClose:o,items:n}=s,{t:i}=ie();let a,h;if(e[0]!==o||e[1]!==r?(a=()=>{if(!r)return;const p=j=>{j.key==="Escape"&&o()};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},h=[o,r],e[0]=o,e[1]=r,e[2]=a,e[3]=h):(a=e[2],h=e[3]),u.useEffect(a,h),!r)return null;let c;e[4]!==i?(c=i("mobile.menu.titleAria"),e[4]=i,e[5]=c):c=e[5];let d;e[6]!==i?(d=i("mobile.surface.closeAria"),e[6]=i,e[7]=d):d=e[7];let f;e[8]!==o||e[9]!==d?(f=t.jsx("button",{type:"button",className:"absolute inset-0 cursor-default","aria-label":d,onClick:o}),e[8]=o,e[9]=d,e[10]=f):f=e[10];let g;e[11]===Symbol.for("react.memo_cache_sentinel")?(g={animation:"mobile-menu-in 160ms cubic-bezier(0.32, 0.72, 0, 1)"},e[11]=g):g=e[11];let b;if(e[12]!==n||e[13]!==o){let p;e[15]!==o?(p=(j,A)=>t.jsxs("button",{type:"button",role:"menuitem",className:Z("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",A>0&&"border-t border-border/30"),style:{touchAction:"manipulation"},onClick:()=>{j.onSelect(),o()},children:[t.jsx(j.Icon,{className:"size-5 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:j.label}),j.badge&&j.badge>0?t.jsx("span",{className:"inline-flex size-2 shrink-0 rounded-full bg-primary","aria-hidden":!0}):null]},j.key),e[15]=o,e[16]=p):p=e[16],b=n.map(p),e[12]=n,e[13]=o,e[14]=b}else b=e[14];let v;e[17]!==b?(v=t.jsx("div",{className:"absolute right-2 top-[calc(var(--oc-safe-area-top,0px)+56px+4px)] w-[min(220px,calc(100vw-1rem))] origin-top-right overflow-hidden rounded-2xl border border-border/40 bg-background shadow-[0_18px_60px_rgb(0_0_0_/_0.35)]",role:"menu",style:g,children:b}),e[17]=b,e[18]=v):v=e[18];let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx("style",{children:"@keyframes mobile-menu-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }"}),e[19]=S):S=e[19];let m;return e[20]!==c||e[21]!==f||e[22]!==v?(m=t.jsxs("div",{className:"fixed inset-0 z-50",role:"dialog","aria-modal":"true","aria-label":c,children:[f,v,S]}),e[20]=c,e[21]=f,e[22]=v,e[23]=m):m=e[23],m},Rn=s=>{const e=re.c(46),{onOpenSessions:r,onOpenMenu:o}=s,{t:n}=ie(),i=Ie(zn),a=je(Mn),h=me(Tn),c=kr(a,i||void 0);let d;if(e[0]!==i||e[1]!==h||e[2]!==n){e:{const k=Qe(i);if(!k){let O;e[4]!==n?(O=n("mobile.header.noProject"),e[4]=n,e[5]=O):O=e[5],d=O;break e}const $=h.find(O=>{const H=Qe(O.path);return k===H||k.startsWith(`${H}/`)});d=$?.label?.trim()||Pn($?.path||k)}e[0]=i,e[1]=h,e[2]=n,e[3]=d}else d=e[3];const f=d;let g;e[6]!==c?.title?(g=c?.title?.trim(),e[6]=c?.title,e[7]=g):g=e[7];const b=g,v=b||f;let S;e[8]!==a||e[9]!==f||e[10]!==b||e[11]!==n?(S=b?f:a?n("mobile.sessions.untitled"):"",e[8]=a,e[9]=f,e[10]=b,e[11]=n,e[12]=S):S=e[12];const m=S;let p;e[13]===Symbol.for("react.memo_cache_sentinel")?(p={paddingTop:"var(--oc-safe-area-top, 0px)"},e[13]=p):p=e[13];let j;e[14]!==n?(j=n("mobile.sessions.openSheetAria"),e[14]=n,e[15]=j):j=e[15];let A,P;e[16]===Symbol.for("react.memo_cache_sentinel")?(A={touchAction:"manipulation"},P=t.jsx($s,{className:"size-5"}),e[16]=A,e[17]=P):(A=e[16],P=e[17]);let N;e[18]!==r||e[19]!==j?(N=t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":j,onClick:r,style:A,children:P}),e[18]=r,e[19]=j,e[20]=N):N=e[20];let _;e[21]!==n?(_=n("mobile.sessions.openSheetAria"),e[21]=n,e[22]=_):_=e[22];let z;e[23]===Symbol.for("react.memo_cache_sentinel")?(z={touchAction:"manipulation"},e[23]=z):z=e[23];let w;e[24]!==v?(w=t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:v}),e[24]=v,e[25]=w):w=e[25];let x;e[26]!==m?(x=m?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:m}):null,e[26]=m,e[27]=x):x=e[27];let M;e[28]!==w||e[29]!==x?(M=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[w,x]}),e[28]=w,e[29]=x,e[30]=M):M=e[30];let F;e[31]!==r||e[32]!==M||e[33]!==_?(F=t.jsx("button",{type:"button",className:"flex min-w-0 flex-1 items-center rounded-full px-2 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":_,onClick:r,style:z,children:M}),e[31]=r,e[32]=M,e[33]=_,e[34]=F):F=e[34];let I;e[35]!==n?(I=n("mobile.header.openMenuAria"),e[35]=n,e[36]=I):I=e[36];let L,T;e[37]===Symbol.for("react.memo_cache_sentinel")?(L={touchAction:"manipulation"},T=t.jsx(Os,{className:"size-5"}),e[37]=L,e[38]=T):(L=e[37],T=e[38]);let G;e[39]!==o||e[40]!==I?(G=t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":I,onClick:o,style:L,children:T}),e[39]=o,e[40]=I,e[41]=G):G=e[41];let U;return e[42]!==F||e[43]!==G||e[44]!==N?(U=t.jsx("header",{className:"relative z-30 flex shrink-0 items-center gap-1 border-b border-border/30 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",style:p,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[N,F,G]})}),e[42]=F,e[43]=G,e[44]=N,e[45]=U):U=e[45],U},_n=()=>{const s=re.c(49),{t:e}=ie(),[r,o]=u.useState(!1),[n,i]=u.useState(!1),[a,h]=u.useState(!1),[c,d]=u.useState(!1),[f,g]=u.useState(!1),[b,v]=u.useState(null),S=Ie(Fn);let m;s[0]!==S?(m=Qe(S)||null,s[0]=S,s[1]=m):m=s[1];const j=is(m)?.files?.length??0;let A;s[2]===Symbol.for("react.memo_cache_sentinel")?(A={openChanges:te=>{const{diffPath:ae,staged:Ne}=te===void 0?{}:te;v(ae?{path:ae,staged:Ne===!0}:null),h(!0)},openFiles:()=>i(!0),openSettings:()=>d(!0)},s[2]=A):A=s[2];const P=A;let N;s[3]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{h(!1),v(null)},s[3]=N):N=s[3];const _=N;let z;s[4]!==e?(z=e("mobile.menu.files"),s[4]=e,s[5]=z):z=s[5];let w;s[6]===Symbol.for("react.memo_cache_sentinel")?(w=()=>i(!0),s[6]=w):w=s[6];let x;s[7]!==z?(x={key:"files",Icon:Fs,label:z,onSelect:w},s[7]=z,s[8]=x):x=s[8];let M;s[9]!==e?(M=e("mobile.menu.changes"),s[9]=e,s[10]=M):M=s[10];let F;s[11]===Symbol.for("react.memo_cache_sentinel")?(F=()=>h(!0),s[11]=F):F=s[11];let I;s[12]!==j||s[13]!==M?(I={key:"changes",Icon:Vt,label:M,badge:j,onSelect:F},s[12]=j,s[13]=M,s[14]=I):I=s[14];let L;s[15]!==e?(L=e("mobile.menu.settings"),s[15]=e,s[16]=L):L=s[16];let T;s[17]===Symbol.for("react.memo_cache_sentinel")?(T=()=>d(!0),s[17]=T):T=s[17];let G;s[18]!==L?(G={key:"settings",Icon:Bs,label:L,onSelect:T},s[18]=L,s[19]=G):G=s[19];let U;s[20]!==G||s[21]!==x||s[22]!==I?(U=[x,I,G],s[20]=G,s[21]=x,s[22]=I,s[23]=U):U=s[23];const k=U;let $;s[24]===Symbol.for("react.memo_cache_sentinel")?($=t.jsx(Rn,{onOpenSessions:()=>o(!0),onOpenMenu:()=>g(!0)}),s[24]=$):$=s[24];let O;s[25]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx("main",{className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:t.jsx(We,{children:t.jsx(Vr,{})})}),s[25]=O):O=s[25];let H;s[26]===Symbol.for("react.memo_cache_sentinel")?(H=()=>g(!1),s[26]=H):H=s[26];let q;s[27]!==k||s[28]!==f?(q=t.jsx(Dn,{open:f,onClose:H,items:k}),s[27]=k,s[28]=f,s[29]=q):q=s[29];let R;s[30]!==r?(R=r?t.jsx(En,{open:r,onOpenChange:o}):null,s[30]=r,s[31]=R):R=s[31];let V;s[32]!==n||s[33]!==e?(V=n?t.jsx(Ve,{open:!0,onClose:()=>i(!1),ariaLabel:e("mobile.menu.files"),headerless:!0,children:t.jsx(We,{children:t.jsx(rn,{onClose:()=>i(!1)})})}):null,s[32]=n,s[33]=e,s[34]=V):V=s[34];let Y;s[35]!==a||s[36]!==b?.path||s[37]!==b?.staged||s[38]!==e?(Y=a?t.jsx(Ve,{open:!0,onClose:_,ariaLabel:e("mobile.menu.changes"),headerless:!0,children:t.jsx(We,{children:t.jsx(Yr,{onClose:_,initialDiffPath:b?.path??null,initialDiffStaged:b?.staged===!0})})}):null,s[35]=a,s[36]=b?.path,s[37]=b?.staged,s[38]=e,s[39]=Y):Y=s[39];let se;s[40]!==c||s[41]!==e?(se=c?t.jsx(Ve,{open:!0,onClose:()=>d(!1),ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(We,{children:t.jsx(Gr,{forceMobile:!0,isWindowed:!0,visiblePageSlugs:[...An],onClose:()=>d(!1)})})}):null,s[40]=c,s[41]=e,s[42]=se):se=s[42];let de;return s[43]!==q||s[44]!==R||s[45]!==V||s[46]!==Y||s[47]!==se?(de=t.jsx(wr,{actions:P,children:t.jsxs("div",{className:"main-content-safe-area flex h-[100dvh] flex-col bg-background text-foreground","data-page-scroll-lock":"true",children:[$,O,q,R,V,Y,se]})}),s[43]=q,s[44]=R,s[45]=V,s[46]=Y,s[47]=se,s[48]=de):de=s[48],de};function In({apis:s}){const e=Ce(m=>m.initializeApp),r=Ce(m=>m.isInitialized),o=Ce(m=>m.isConnected),n=Ce(m=>m.providers.length),i=Ce(m=>m.agents.length),a=Ce(m=>m.loadProviders),h=Ce(m=>m.loadAgents),c=Ie(m=>m.currentDirectory),d=je(m=>m.error),f=je(m=>m.clearError),g=dr(m=>m.setIsMobile),b=fr(m=>m.refreshStatus),v=mr(m=>m.setPlanModeEnabled),S=me(m=>m.projects);return u.useEffect(()=>(Dt(s),()=>Dt(null)),[s]),u.useEffect(()=>{g(!0)},[g]),u.useEffect(()=>{e()},[e]),u.useEffect(()=>{o&&(n===0&&a({source:"mobileApp:recovery"}),i===0&&h({source:"mobileApp:recovery"}))},[i,o,h,a,n]),u.useEffect(()=>{o&&Rt.setDirectory(c)},[c,o]),u.useEffect(()=>{b(s.github,{force:!0})},[s.github,b]),u.useEffect(()=>{if(S.length===0)return;let m=!1;return(async()=>{const j=new Map,A=[];await Promise.all(S.map(async P=>{const N=P.path.replace(/\\/g,"/").replace(/\/+$/,"");if(N)try{if(!(ve.getState().directories.get(N)?.isGitRepo??await Ts(()=>import("./useAppFontEffects-hYm-4PtP.js").then(x=>x.fy),__vite__mapDeps([0,1,2,3,4])).then(x=>x.checkIsGitRepository(N))))return;const w=await ms({id:P.id,path:N});if(m||w.length===0)return;j.set(N,w),A.push(...w)}catch{}})),!m&&je.setState({availableWorktrees:A,availableWorktreesByProject:j})})(),()=>{m=!0}},[S]),u.useEffect(()=>{let m=!1;return(async()=>{const j=await Hs("/health",{method:"GET"}).catch(()=>null);if(!j||!j.ok||m)return;const A=await j.json().catch(()=>null);if(!A||m)return;const P=A.planModeExperimentalEnabled;v(P===!0||P===1||P==="1"||P==="true")})(),()=>{m=!0}},[v]),u.useEffect(()=>{if(!d)return;const m=window.setTimeout(()=>f(),5e3);return()=>window.clearTimeout(m)},[f,d]),hr(),gr({enabled:!0}),pr(),Lr(),t.jsx(We,{children:t.jsx(br,{sdk:Rt.getSdkClient(),directory:c||"",children:t.jsx(xr,{apis:s,children:t.jsx(yr,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(vr,{embeddedBackgroundWorkEnabled:r}),t.jsx(_n,{}),t.jsx(jr,{})]})})})})})}function zn(s){return s.currentDirectory}function Mn(s){return s.currentSessionId}function Tn(s){return s.projects}function Fn(s){return s.currentDirectory}const Bn=()=>{Ar(),Pr().then(()=>{Promise.all([Dr(),Rr()]).catch(s=>{console.error("[mobile-main] settings init failed:",s)}),_r(),Ir(),zr()}).catch(s=>{console.error("[mobile-main] appearance init failed:",s)})};function Hn(s){Bn();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");Ws.createRoot(e).render(t.jsx(Ls.StrictMode,{children:t.jsx(Sr,{children:t.jsx(Nr,{children:t.jsx(Cr,{children:t.jsx(Ur,{children:t.jsx(Er,{children:t.jsx(In,{apis:s})})})})})})}))}export{Hn as renderMobileApp};
|