@yuriai/web 0.2.40-beta.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-7jBkH_B6.js → AgentAvatar-DUB7W_Si.js} +1 -1
- package/dist/assets/{AssistantConversationSurface-FGzDw0UO.js → AssistantConversationSurface-BJth3jXT.js} +3 -3
- package/dist/assets/{AssistantSessionCard-O8-4Ro7A.js → AssistantSessionCard-vld_AE4i.js} +2 -2
- package/dist/assets/{AssistantUnreadBadge-hIbYspFk.js → AssistantUnreadBadge-c8MicghF.js} +1 -1
- package/dist/assets/{AssistantView-CD6DuSQR.js → AssistantView-BJuadEep.js} +1 -1
- package/dist/assets/{DiagramView-BYNceLBG.js → DiagramView-S4Ud3Mlj.js} +1 -1
- package/dist/assets/{FadeInOnReveal-Btdc2gHQ.js → FadeInOnReveal-DbVaH7-A.js} +1 -1
- package/dist/assets/{GuiPluginPage-DGuz2JN8.js → GuiPluginPage-DjgQBCjp.js} +1 -1
- package/dist/assets/{GuiPluginSurface-CyWOutB_.js → GuiPluginSurface-DYlCgzhA.js} +1 -1
- package/dist/assets/{GuiPluginWindow-ClTpxdu0.js → GuiPluginWindow-BE-r7Z66.js} +1 -1
- package/dist/assets/{Icon-dlmCSbtX.js → Icon-B3cNGB1E.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-dTg1NZqZ.js → ImageLoadingPlaceholder-DtxjvYT1.js} +1 -1
- package/dist/assets/{LoadingImage-BUVKP8pw.js → LoadingImage-2TwmcRKf.js} +1 -1
- package/dist/assets/MarkdownRenderer-OdVoXQ3K.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-B4-hhUU1.js → MarkdownRendererImpl-CwTBWyzl.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-pJZwlp1_.js → MarkstreamRendererImpl-B038pJqX.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-uBwR49fY.js → MobileDetailNavigation-BjB-cyVm.js} +1 -1
- package/dist/assets/{MobileResizableSheet-CPIkRz1y.js → MobileResizableSheet-UePgX-mu.js} +1 -1
- package/dist/assets/{MobileShareBridge-8rOTS21L.js → MobileShareBridge-CI3yZRU6.js} +1 -1
- package/dist/assets/{MobileSurface-C3Om5xCW.js → MobileSurface-wMpm_zU8.js} +1 -1
- package/dist/assets/{MultiRunWindow-C7GqTc4n.js → MultiRunWindow-BQjuQgnl.js} +1 -1
- package/dist/assets/{OnboardingScreen-BgdeB-yT.js → OnboardingScreen-BZEndbgc.js} +1 -1
- package/dist/assets/{OverlayScrollbar-BgyQGTzf.js → OverlayScrollbar-Bbk7lpYm.js} +1 -1
- package/dist/assets/{RemoteAssistantSessionCard-B8znUBMi.js → RemoteAssistantSessionCard-DFPkBp-H.js} +1 -1
- package/dist/assets/{SettingsView-BtlWPEFz.js → SettingsView-D5IHBHDl.js} +1 -1
- package/dist/assets/{SettingsWindow-DlMmfkQl.js → SettingsWindow-DgwxY7zd.js} +1 -1
- package/dist/assets/{SetupTourDialog-BQbtI0rx.js → SetupTourDialog-B3Zk2SAX.js} +1 -1
- package/dist/assets/{TerminalView-C-jY-zFv.js → TerminalView-CTW9Ivs4.js} +1 -1
- package/dist/assets/{ToolOutputDialog-K4unHbkl.js → ToolOutputDialog-CKyuEaps.js} +1 -1
- package/dist/assets/{VoiceSettings-BHXI8vCw.js → VoiceSettings-WOD75tlI.js} +1 -1
- package/dist/assets/{capgoAdapter-BFgkCmsy.js → capgoAdapter-DOWlyoxM.js} +1 -1
- package/dist/assets/{checkbox-DztH_Uxh.js → checkbox-MPeKvj7J.js} +1 -1
- package/dist/assets/{collapsible-WNZa3bQL.js → collapsible-DLhoqiwk.js} +1 -1
- package/dist/assets/{context-menu-DMRr7Lhy.js → context-menu-B5I2Rgmk.js} +1 -1
- package/dist/assets/{diagram-0jDQteO-.js → diagram-Cen2xPMV.js} +1 -1
- package/dist/assets/{dialog-GB5GgL9t.js → dialog-DGjWVnel.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-P8IYpO7L.js → fileMentionTouchSelection-BM_cX6dU.js} +1 -1
- package/dist/assets/{gitApi-BnO-MC2O.js → gitApi-DMqau005.js} +1 -1
- package/dist/assets/{input-CJRYbf5y.js → input-zMUdy5A_.js} +1 -1
- package/dist/assets/{insertionBoundaries-DtkwIDQg.js → insertionBoundaries-Dr-UiiPl.js} +1 -1
- package/dist/assets/{main-Dr64Qzs4.js → main-C4wHLZE-.js} +4 -4
- package/dist/assets/{main-CVKs-_CW.js → main-ikGS4VZ6.js} +2 -2
- package/dist/assets/{markdownHeightCache-D5EOEf3y.js → markdownHeightCache-squymH-Z.js} +1 -1
- package/dist/assets/{mcpQueries-tNLFED0P.js → mcpQueries-BLOLrmAP.js} +1 -1
- package/dist/assets/{miniChat-DrUExSCq.js → miniChat-D1sfi9nT.js} +2 -2
- package/dist/assets/{mobile-DpWfQU01.js → mobile-Bq-eRKG9.js} +2 -2
- package/dist/assets/{mobileBackNavigation-BzuplHWI.js → mobileBackNavigation-ix4AQEOa.js} +1 -1
- package/dist/assets/{mobileConnections-R518oxZz.js → mobileConnections-ZifVGuqT.js} +2 -2
- package/dist/assets/{multirun-DXIHkg_u.js → multirun-BUHW3nAI.js} +1 -1
- package/dist/assets/{native-config-Dya3VMEx.js → native-config-DzaiNrLL.js} +1 -1
- package/dist/assets/{navigation-CVM0CiqR.js → navigation-QwtyGNxR.js} +1 -1
- package/dist/assets/{openRemoteProjectSession-DPHipesJ.js → openRemoteProjectSession-BZw6ETw7.js} +1 -1
- package/dist/assets/{projectMeta-nJFvBok1.js → projectMeta-Cl_IHUOq.js} +1 -1
- package/dist/assets/{pwa-BMGWPAyY.js → pwa-Bix1wcNI.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-v08cDYmk.js → queue-abort-optimistic-C3mS_Lhh.js} +1 -1
- package/dist/assets/{react-UzGkPj-7.js → react-BQSnpJ3a.js} +1 -1
- package/dist/assets/{readiness-CeuptTQQ.js → readiness-aosbvIX3.js} +2 -2
- package/dist/assets/{reference-history-BHl2F1Ua.js → reference-history-B1yRHnrs.js} +1 -1
- package/dist/assets/{remoteSessionReference-b9gLK7-H.js → remoteSessionReference-BU_6fDAW.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-j9llIv2j.js → renderElectronMiniChatApp-C-PhYiqi.js} +2 -2
- package/dist/assets/{renderMobileApp-BMPvWB1m.js → renderMobileApp-CvfHOvat.js} +4 -4
- package/dist/assets/{runtimeConfig-CImjL93k.js → runtimeConfig-u0ammbMq.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-DAHjrbRZ.js → runtimeEndpointReset-ZHN1UrEC.js} +3 -3
- package/dist/assets/{select-oU_1TcgU.js → select-hPO_aN_C.js} +1 -1
- package/dist/assets/{sessionLookup-DmPwcStr.js → sessionLookup-DSqwyvC5.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-Du4-shpP.js → sortable-tabs-strip-u6crnfcl.js} +1 -1
- package/dist/assets/{speechSettingsQueries-2G_D-a3C.js → speechSettingsQueries-CBjXHSqU.js} +1 -1
- package/dist/assets/{textarea-CFFlotQM.js → textarea-C6wJ8cXq.js} +1 -1
- package/dist/assets/{tooltip-BcBn2Wkr.js → tooltip-BfY_e3WX.js} +1 -1
- package/dist/assets/types-DSPae2ym.js +2 -0
- package/dist/assets/{useAppFontEffects-fAWK91TK.js → useAppFontEffects-vT1vSXTc.js} +6 -6
- package/dist/assets/{useDesktopWindowControlsLayout-Cd0Eogh-.js → useDesktopWindowControlsLayout-BKiVG_U6.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-BnPXmaP9.js → useEffectiveDirectory-BciDDIuG.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-B8HMmRMH.js → useMobileNavigationStore-DuBHKBp6.js} +4 -4
- package/dist/assets/{usePluginsStore-SYsjpg1M.js → usePluginsStore-Cal-Lu-K.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-Yscm-GXX.js → useProjectRuntimeAPIs-CULigqL2.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-BqwnEZRy.js → useStreamingTextThrottle-B4pmGGM4.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +1 -1
- package/package.json +1 -1
- package/server/lib/assistants/DOCUMENTATION.md +13 -0
- package/server/lib/assistants/assign.js +8 -7
- package/server/lib/assistants/contact-tools.js +12 -9
- package/server/lib/assistants/remote-execution.test.js +68 -3
- package/server/lib/assistants/service.js +61 -51
- package/dist/assets/MarkdownRenderer-CSMh8m96.js +0 -2
- package/dist/assets/types-D46NeDOJ.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-B5H_XtmE.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/ToolOutputDialog-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{S as t,_ as n,p as r,r as i,t as a,v as o}from"./runtime-auth-mjIpsk3N.js";import{c as s,f as c,i as l,l as u,n as d,r as f,t as p}from"./runtime-switch-BMjl5Y5W.js";import{n as m}from"./runtime-fetch-DKZOpfzo.js";import{f as h,n as g,r as _,s as v,t as y}from"./platform-wF65ZFgV.js";import{n as b,t as x}from"./runtimeAPIRegistry-C2VogTny.js";import{a as S}from"./vendor-zustand-Cwko4FG1.js";import{it as C,ot as w,st as T}from"./vendor-base-ui-z2M4boRm.js";import{Mt as E,Pt as D,St as O,xt as k}from"./gitApiHttp-B0FJaIhU.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as A}from"./safeStorage-DTOhKN0V.js";import{Bt as j,Qt as M,Zt as N,dn as P,n as F,on as I,sn as L,un as R,zt as ee}from"./client-1Fk5IbQR.js";import{n as z,t as B}from"./vendor-react-P8wFrkcT.js";import{f as V}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{c as te,o as ne,s as re}from"./vendor-tanstack-react-query-B-KblYBV.js";import{C as H,D as ie,E as U,G as ae,S as oe,T as se,V as ce,k as le,q as ue,w as de,z as W}from"./runtime-file-resource-CuLP3xp7.js";import{o as fe}from"./path-utils-jGozTg9d.js";import{i as G,l as pe,m as me,r as K}from"./vendor-reactuses-core-Dyjw5sZR.js";import{a as he,n as q,o as ge}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as _e}from"./useUIStore-Cfmg-aDQ.js";import{a as ve,o as ye,s as be,t as xe}from"./useMobileHtmlPreviewStore-EOAzZiAy.js";import{t as Se}from"./capgoAdapter-BFgkCmsy.js";/* empty css */import{a as Ce}from"./vendor-pierre-diffs-tqo4Z3TC.js";import{r as we}from"./vendor-sonner-B5HgJenP.js";import{r as Te,t as Ee}from"./i18n-qHllte6P.js";import{i as De,n as Oe}from"./store-BOD3jjMl.js";import{a as ke,i as Ae,l as je,o as Me,r as Ne,s as Pe,t as Fe,u as Ie}from"./mobileConnections-R518oxZz.js";import{S as Le,b as Re,h as ze,t as Be,v as Ve,y as He}from"./MobileDetailNavigation-uBwR49fY.js";import{A as Ue,Ci as We,Cn as Ge,Cr as Ke,Di as qe,Dr as Je,Ei as Ye,Fr as Xe,H as Ze,In as J,J as Qe,Ji as $e,Pa as et,Pr as tt,Pt as nt,R as rt,Rn as it,Si as Y,Ti as at,Ui as ot,Va as st,Wa as ct,Xi as lt,_i as ut,ai as dt,ar as ft,at as pt,bi as mt,er as ht,fi as gt,gr as _t,hi as vt,hr as yt,in as bt,ir as xt,jr as St,kr as Ct,lt as wt,mr as Tt,na as Et,o as Dt,p as Ot,q as kt,rr as At,s as jt,st as Mt,t as Nt,tt as Pt,ui as Ft,ut as It,vi as Lt,wi as Rt,xi as zt,z as Bt}from"./useMobileNavigationStore-B8HMmRMH.js";import{i as Vt,n as Ht,r as Ut}from"./useAssistantUIStore-jOKVcBK8.js";import{a as Wt,o as Gt,t as Kt}from"./MobileShareBridge-8rOTS21L.js";import{d as qt,h as Jt,i as Yt,m as Xt,p as Zt}from"./remoteProjectQueries-Dfms-cCx.js";import{n as Qt}from"./useThemeSystem-C57Z9mV2.js";import{n as X}from"./Icon-dlmCSbtX.js";import{a as $t,i as en,n as tn,o as nn,r as rn,t as an}from"./dialog-GB5GgL9t.js";import{$ as on,At as sn,Bt as cn,D as ln,Et as un,Ft as dn,G as fn,Ht as pn,It as mn,J as hn,K as gn,Lt as _n,Mt as vn,Nt as yn,Pt as bn,Q as xn,R as Sn,Rt as Cn,S as wn,St as Tn,T as En,Tt as Dn,Ut as On,Vt as kn,W as An,Wt as jn,Xt as Mn,Z as Nn,dt as Pn,ft as Fn,ht as In,i as Ln,nt as Rn,q as zn,r as Bn,t as Vn,tt as Hn,wt as Un,x as Wn,zt as Gn}from"./useAppFontEffects-fAWK91TK.js";import{t as Kn}from"./input-CJRYbf5y.js";import{t as qn}from"./tap-LkQum5bB.js";import{r as Jn}from"./tooltip-BcBn2Wkr.js";import{A as Yn,D as Xn,E as Zn,G as Qn,K as $n,M as er,O as tr,Q as nr,S as rr,W as ir,q as ar}from"./pwa-BMGWPAyY.js";import{t as or}from"./YuriLogo-VXtP1vhh.js";import{o as sr}from"./react-UzGkPj-7.js";import{i as cr,o as lr,t as ur}from"./device-QL8KNSLM.js";import{r as dr}from"./themes-BgDJcxRc.js";import{o as fr}from"./scheduledTaskNavigation-y5g8D2ee.js";import{a as pr,n as mr,o as hr}from"./MarkdownRenderer-CSMh8m96.js";import{C as gr,d as _r,n as vr,r as yr,t as br,u as xr}from"./MobileResizableSheet-CPIkRz1y.js";import{_ as Sr,g as Cr,v as wr,w as Tr}from"./insertionBoundaries-DtkwIDQg.js";import{l as Er,u as Dr}from"./select-oU_1TcgU.js";import{M as Or,N as kr,O as Ar,h as jr,i as Mr,n as Nr,r as Pr,s as Fr,t as Ir}from"./mobileBackNavigation-BzuplHWI.js";import{r as Lr}from"./queue-abort-optimistic-v08cDYmk.js";import{a as Rr,c as zr,i as Br,s as Vr}from"./toolHelpers-iEHVHQ9p.js";import{o as Hr}from"./image-loading-DBqnxgDH.js";import{t as Ur}from"./ImageLoadingPlaceholder-dTg1NZqZ.js";import{t as Wr}from"./LoadingImage-BUVKP8pw.js";import{n as Gr,r as Kr}from"./textarea-CFFlotQM.js";import{a as qr,f as Jr,i as Yr,n as Xr,s as Zr}from"./projectMeta-nJFvBok1.js";import{r as Qr}from"./ToolOutputDialog-K4unHbkl.js";import{c as $r,s as ei}from"./sessionLookup-DmPwcStr.js";import{n as ti,t as ni}from"./useProjectRuntimeAPIs-Yscm-GXX.js";import{$ as ri,A as ii,G as ai,M as oi,Q as si,Y as ci,d as li,et as ui,i as di,k as fi,n as pi,r as mi,t as hi}from"./MobileSurface-C3Om5xCW.js";import{t as gi}from"./openRemoteProjectSession-DPHipesJ.js";import{i as _i,r as vi}from"./AssistantConversationSurface-FGzDw0UO.js";import{t as yi}from"./useFontPreferences-CO-L-Gd7.js";import{B as bi,Ct as xi,Dt as Si,E as Ci,Et as wi,F as Ti,Ft as Ei,G as Di,Ht as Oi,I as ki,It as Ai,J as ji,Jt as Mi,K as Ni,Kt as Pi,L as Fi,Lt as Ii,Nt as Li,Ot as Ri,P as zi,Q as Bi,R as Vi,Rt as Hi,St as Ui,T as Wi,Tt as Gi,Ut as Ki,V as qi,W as Ji,Wt as Yi,X as Xi,Y as Zi,Z as Qi,Zt as $i,_t as ea,a as ta,at as na,c as ra,ct as ia,d as aa,dt as oa,et as sa,f as ca,ft as la,gt as ua,ht as da,i as fa,it as pa,l as ma,lt as ha,mt as ga,n as _a,nt as va,o as ya,ot as ba,pt as xa,q as Sa,qt as Ca,r as wa,rt as Ta,s as Ea,st as Da,t as Oa,tt as ka,u as Aa,ut as ja,w as Ma,wt as Na,xt as Pa,z as Fa,zt as Ia}from"./runtimeEndpointReset-DAHjrbRZ.js";import{t as La}from"./YuriWordmark-B7lmpLRB.js";import{r as Ra,t as za}from"./mcpQueries-tNLFED0P.js";import{f as Ba}from"./usePluginsStore-SYsjpg1M.js";import{a as Va,i as Ha,o as Ua,r as Wa,t as Ga}from"./SettingsView-BtlWPEFz.js";import{a as Ka,i as qa}from"./readiness-CeuptTQQ.js";import{t as Ja}from"./relay-preview-frame-src-BPyz3nXA.js";import{n as Ya}from"./project-preview-2H-TmJkd.js";import{n as Xa,r as Za,t as Qa}from"./AssistantUnreadBadge-hIbYspFk.js";import{a as $a,c as eo,i as to,o as no,r as ro,s as io,t as ao}from"./AssistantView-CD6DuSQR.js";var Z=e(T(),1),oo=B(),so=null,co=!1,lo=new Promise(e=>{so=e});function uo(){co||(co=!0,so?.())}var fo=6,po=e=>e.parentID??null,mo=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},ho=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),go=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=ho(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return mo(n?n.path:e)},_o=()=>{let e=Lt.getState().activeSessions,t=Je.getState().index.session.unseenCount,n=st.getState().projects,r=0,i=[];for(let a of e){let e=po(a)!==null,o=(t[a.id]??0)>0&&!e;o&&(r+=1),e||i.push({id:a.id,title:a.title??``,updated:a.time?.updated??a.time?.created??0,unread:o,project:go(vt(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,fo).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},vo=`__YURI_WIDGET_SNAPSHOT__`,yo=()=>{typeof window>`u`||(window[vo]=()=>{try{return JSON.stringify(_o())}catch{return null}})},Q=z(),bo=he(`YuriScreenAwake`),xo=Promise.resolve(),So=0;function Co(e){let t=xo.then(()=>bo.setEnabled({enabled:e}));return xo=t.catch(()=>void 0),t}async function wo(){if(q.isNativePlatform()&&q.isPluginAvailable(`YuriScreenAwake`)){So+=1;try{await Co(!0)}catch(e){throw--So,e}let e=!1;return async()=>{e||(e=!0,--So,So===0&&await Co(!1))}}if(!navigator.wakeLock)throw Error(`Screen wake lock unavailable`);let e=await navigator.wakeLock.request(`screen`);return async()=>{e.released||await e.release()}}var $=w();function To(e){let t=(0,Q.c)(3),n=ft(),r=e.remoteState??n??void 0,i;return t[0]!==e||t[1]!==r?(i=(0,$.jsx)(Oo,{...e,remoteState:r}),t[0]=e,t[1]=r,t[2]=i):i=t[2],i}function Eo(e){let t=(0,Q.c)(6),{identity:n,onSource:r}=e,i=wt(e.sessionId,e.directory),a=It(e.sessionId,e.directory),o,s;return t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a?(o=()=>r({identity:n,resolved:a,getMessages:()=>i}),s=[n,r,i,a],t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o,t[5]=s):(o=t[4],s=t[5]),(0,Z.useLayoutEffect)(o,s),null}function Do(e){let{identity:t,onSource:n}=e,r=e.remoteState,i=(0,Z.useMemo)(()=>r.scope(e.sessionId),[r,e.sessionId]),a=(0,Z.useMemo)(()=>e=>r.repository.subscribe(i,e),[r,i]),o=(0,Z.useMemo)(()=>()=>r.repository.hasSession?.(i)||r.repository.getRequestState?.(i)?.status===`ready`||r.repository.getTranscript(i).messageOrder.length>0,[r,i]),s=(0,Z.useSyncExternalStore)(a,o,o),c=K(function*(){let e=r.repository.getTranscript(i);for(let t of e.messageOrder)yield e.messagesByID[t]});return(0,Z.useLayoutEffect)(()=>n({identity:t,resolved:s,getMessages:c}),[t,n,s,c]),null}function Oo(e){let{sessionId:t,directory:n,active:r,children:i,remoteState:a}=e,{t:o}=Ee(),c=JSON.stringify([a?.entry.key??(e.remote?`remote-pending`:`local`),a?.entry.connectionGeneration,t,n]),l=(0,Z.useRef)(null),[u,d]=(0,Z.useState)(null),f=K(e=>{l.current=e,d(t=>t?.identity===e.identity&&t.resolved===e.resolved?t:{identity:e.identity,resolved:e.resolved})}),[p,m]=pe(`yuri.auto-read`,!1),h=p===!0,[g,_]=(0,Z.useState)(0),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(document.visibilityState===`visible`),w=on({enabled:v}),T=(0,Z.useRef)({enabled:!1,generation:0,floor:0,seen:new Set,observed:new Set,pending:[],playing:!1}),E=(0,Z.useRef)(!1),D=r&&!!t&&u?.identity===c&&u.resolved,O=K(()=>{let e=T.current;e.enabled=!1,e.generation+=1,e.pending=[],e.playing=!1,e.seen.clear(),e.observed.clear(),E.current=!1,w.stop(),x(null),y(!1)}),k=K(()=>{let e=T.current;if(!e.enabled||e.playing||!r||document.visibilityState!==`visible`)return;let t=e.pending.shift();if(!t)return;e.playing=!0,x(t);let n=e.generation;w.play(t.text,t=>{if(n===e.generation){if(e.playing=!1,x(null),t){O(),we.error(o(`mobile.menu.autoReadFailed`));return}k()}},{target:t.target})}),A=K(e=>{let n=T.current;!n.enabled||!D||e.sessionId!==t||!e.text.trim()||e.created<n.floor&&!n.observed.has(e.messageId)||n.seen.has(e.messageId)||(n.seen.add(e.messageId),n.pending.push(e),k())}),j=K((e,n)=>{T.current.enabled&&D&&e===t&&T.current.observed.add(n)}),M=K(()=>{if(h){m(!1),O();return}D&&(m(!0),w.unlock().catch(()=>{we.error(o(`mobile.menu.autoReadFailed`))}))}),N=K(()=>{let e=T.current;e.floor=0,e.seen=new Set;for(let t of l.current?.getMessages()??[])e.floor=Math.max(e.floor,t.time.created),(t.time.completed!=null||t.role!==`assistant`)&&e.seen.add(t.id);e.enabled=!0,y(!0)});(0,Z.useEffect)(()=>(O(),h&&D&&N(),O),[t,n,c,h,D,g,N,O]),(0,Z.useEffect)(()=>s(()=>{O(),_(e=>e+1)}),[O]);let P=K(()=>{m(!1),O()});G(`pointerdown`,()=>{if(!T.current.enabled||E.current)return;E.current=!0;let e=T.current.generation;w.unlock().catch(()=>{e===T.current.generation&&(E.current=!1)})},document),G(`visibilitychange`,()=>{C(document.visibilityState===`visible`),document.visibilityState===`visible`?k():(T.current.generation+=1,T.current.playing=!1,T.current.pending=[],w.stop(),x(null))},document),(0,Z.useEffect)(()=>{if(!v||!D||!S)return;let e=!1,t;return wo().then(n=>{e?n().catch(()=>void 0):t=n}).catch(()=>{e||we.warning(o(`mobile.menu.autoReadAwakeFailed`))}),()=>{e=!0,t?.().catch(()=>void 0)}},[v,D,S,t,n,c,g,o]);let F=(0,Z.useMemo)(()=>({enabled:h,available:D,toggle:M,rendered:A,streaming:j}),[h,D,M,A,j]),I=(0,Z.useMemo)(()=>v&&r&&S&&w.isPlaying&&b?.sessionId===t?{sessionId:t,messageId:b.messageId,stop:P}:null,[v,r,S,w.isPlaying,b,t,P]);return(0,$.jsx)(Nn.Provider,{value:F,children:(0,$.jsxs)(xn.Provider,{value:I,children:[a?(0,$.jsx)(Do,{...e,identity:c,onSource:f,remoteState:a}):e.remote?null:(0,$.jsx)(Eo,{...e,identity:c,onSource:f}),i]})})}function ko(e){let t=(0,Q.c)(3),{children:n}=e,r=(0,Z.useContext)(Nn);if(!r)return null;let i;return t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var Ao={getPlatform:()=>q.getPlatform(),isPluginAvailable:e=>q.isPluginAvailable(e),openInSystemBrowser:e=>be.open(e),openExternal:ye},jo=async(e,t=Ao)=>{if(t.getPlatform()===`android`){if(!t.isPluginAvailable(`YuriExternalBrowser`))return!1;try{return await t.openInSystemBrowser({url:e}),!0}catch{return!1}}return t.openExternal(e)},Mo=`mobile-app-update-available`,No=`mobile-app-update-toast-dismissed-version`,Po=()=>{let e=(0,Q.c)(9),{t}=Ee(),n=ci(Fo),r=ci(Io),i=ci(Lo),a=ci(Ro),o=ci(zo),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,e[0]=s):s=e[0];let c=Z.useRef(s),l,u;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(l=()=>{if(y()!==`android`||r!==`mobile`||!n||!i||!a||o){Y.dismiss(Mo);return}A().getItem(No)!==i&&(c.current.has(i)||(c.current.add(i),Y.info(t(`mobileUpdate.toast.available.title`),{id:Mo,description:t(`mobileUpdate.toast.available.description`,{version:i}),duration:1/0,icon:(0,$.jsx)(X,{name:`download`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.toast.actions.download`),onClick:()=>{jo(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{A().setItem(No,i),Y.dismiss(Mo)}}})))},u=[n,a,o,r,t,i],e[1]=n,e[2]=a,e[3]=o,e[4]=r,e[5]=t,e[6]=i,e[7]=l,e[8]=u):(l=e[7],u=e[8]),Z.useEffect(l,u),null};function Fo(e){return e.available}function Io(e){return e.runtimeType}function Lo(e){return e.info?.version}function Ro(e){return e.info?.downloadUrl}function zo(e){return e.info?.inAppApply===!0}var Bo=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Vo=e=>e.enabled&&!e.alreadyChecked,Ho=`mobile-ota-update-available`,Uo=`mobile-ota-update-toast-dismissed-version`,Wo=()=>{let e=(0,Q.c)(24),{t}=Ee(),[n,r]=Z.useState(!1),i=Z.useRef(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,e[0]=a):a=e[0];let o=Z.useRef(a),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=g(),e[1]=s):s=e[1];let c=s,l=ci(Go),u=ci(Ko),d=ci(qo),f=ci(Jo),p=ci(Yo),m=ci(Xo),h=ci(Zo),_=ci(Qo),v=ci($o),y=d?.version,b=d?.inAppApply===!0,x,S;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{Vo({enabled:c,alreadyChecked:i.current})&&(i.current=!0,ci.getState().checkForUpdates().catch(es))},S=[c],e[2]=x,e[3]=S):(x=e[2],S=e[3]),Z.useEffect(x,S);let C;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{r(!0)},e[4]=C):C=e[4];let w=K(C),T=K(ts),E,D;if(e[5]!==l||e[6]!==T||e[7]!==b||e[8]!==w||e[9]!==u||e[10]!==t||e[11]!==y?(E=()=>{if(!Bo({enabled:c,runtimeType:u,available:l,inAppApply:b,version:y??``,dismissedVersion:A().getItem(Uo),seenVersions:o.current})||!y){(!l||!b||u!==`mobile`)&&Y.dismiss(Ho);return}o.current.add(y),Y.info(t(`mobileUpdate.ota.toast.available.title`),{id:Ho,description:t(`mobileUpdate.ota.toast.available.description`,{version:y}),duration:1/0,icon:(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.ota.toast.actions.update`),onClick:w},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{T(y)}}})},D=[l,b,c,w,T,u,t,y],e[5]=l,e[6]=T,e[7]=b,e[8]=w,e[9]=u,e[10]=t,e[11]=y,e[12]=E,e[13]=D):(E=e[12],D=e[13]),Z.useEffect(E,D),!c)return null;let O;return e[14]!==n||e[15]!==_||e[16]!==p||e[17]!==f||e[18]!==h||e[19]!==d||e[20]!==m||e[21]!==v||e[22]!==u?(O=(0,$.jsx)(ai,{open:n,onOpenChange:r,info:d,downloading:f,downloaded:p,progress:m,error:h,onDownload:_,onRestart:v,runtimeType:u}),e[14]=n,e[15]=_,e[16]=p,e[17]=f,e[18]=h,e[19]=d,e[20]=m,e[21]=v,e[22]=u,e[23]=O):O=e[23],O};function Go(e){return e.available}function Ko(e){return e.runtimeType}function qo(e){return e.info}function Jo(e){return e.downloading}function Yo(e){return e.downloaded}function Xo(e){return e.progress}function Zo(e){return e.error}function Qo(e){return e.downloadUpdate}function $o(e){return e.restartToUpdate}function es(){}function ts(e){A().setItem(Uo,e),Y.dismiss(Ho)}var ns=he(`BarcodeScanner`),rs=`yuri-barcode-scanner-active`,is=()=>ys()?ns:null,as=()=>window.Capacitor?.getPlatform?.()===`android`,os=e=>typeof e==`object`&&e&&`message`in e?String(e.message??``):String(e??``),ss=e=>/^\s*scan canceled\.?\s*$/i.test(os(e)),cs=e=>/denied access to camera/i.test(os(e)),ls=e=>!ss(e)&&!cs(e),us=e=>{let t=os(e);return/module/i.test(t)&&/not\s*available|unavailable/i.test(t)},ds=e=>{e.installGoogleBarcodeScannerModule?.().catch(()=>void 0)},fs=e=>{let t=e.trim();if(!t)return null;if(/^yuri:\/\//i.test(t)){let e=Va(t);return e?{pairing:e}:null}return/^https?:\/\//i.test(t)?{url:t}:null},ps=e=>{let t=fs(e);return t?`pairing`in t?{status:`pairing`,...t}:{status:`ok`,...t}:{status:`invalid`}},ms=e=>{typeof document>`u`||document.documentElement.classList.toggle(rs,e)},hs=e=>{try{e()}catch{}},gs=e=>{if(typeof document>`u`)return()=>void 0;let t=document.body,n=document.createElement(`button`);n.type=`button`,n.className=`yuri-barcode-scanner-chrome`,n.setAttribute(`aria-label`,`Cancel`),n.textContent=`×`,n.addEventListener(`click`,e),t.appendChild(n);let r=!1;return()=>{r||(r=!0,n.removeEventListener(`click`,e),n.parentNode===t&&t.removeChild(n))}},_s=async e=>{if(!e.startScan||!e.stopScan||!e.addListener)return{status:`unsupported`};let t,n,r,i=!1,a=()=>void 0,o=new Promise(e=>{a=e}),s=e=>{i||(i=!0,a(e))};ms(!0);let c=gs(()=>s({status:`cancelled`}));try{let{App:e}=await ge(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),t=await e.addListener(`backButton`,()=>s({status:`cancelled`}));r=()=>void t.remove()}catch{r=void 0}try{return(await Promise.allSettled([Promise.resolve(e.addListener(`barcodesScanned`,({barcodes:e})=>{let t=e?.[0],n=(t?.rawValue??t?.displayValue??``).trim();n&&s(ps(n))})).then(e=>{t=e}),Promise.resolve(e.addListener(`scanError`,()=>s({status:`failed`}))).then(e=>{n=e})])).some(({status:e})=>e===`rejected`)?s({status:`failed`}):i||e.startScan({formats:[`QR_CODE`]}).catch(e=>{cs(e)?s({status:`permission-denied`}):s({status:`failed`})}),await o}finally{ms(!1),hs(c),hs(()=>r?.()),await Promise.allSettled([Promise.resolve(t?.remove()),Promise.resolve(n?.remove()),e.stopScan()])}},vs=e=>e.isNativePlatform&&e.isPluginAvailable,ys=()=>vs({isNativePlatform:q.isNativePlatform(),isPluginAvailable:q.isPluginAvailable(`BarcodeScanner`)}),bs=async()=>{let e=is();if(!e)return{status:`unsupported`};try{if(e.requestPermissions){let t=(await e.requestPermissions())?.camera;if(t&&t!==`granted`&&t!==`limited`)return{status:`permission-denied`}}if(e.scan)try{let t=(await e.scan({formats:[`QR_CODE`]}))?.barcodes?.[0],n=(t?.rawValue??t?.displayValue??``).trim();return n?ps(n):{status:`cancelled`}}catch(t){return ss(t)?{status:`cancelled`}:cs(t)?{status:`permission-denied`}:as()&&ls(t)&&e.startScan?(us(t)&&ds(e),_s(e)):{status:`failed`}}return as()&&e.startScan?_s(e):{status:`unsupported`}}catch{return{status:`failed`}}},xs={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},Ss=({disabled:e=!1,isBusy:t=!1,tabIndex:n,inputClassName:r,buttonVariant:i=`outline`,buttonClassName:a=`h-12 w-full`,value:o,onValueChange:s,showPasteButton:c=!1,error:l,onRedeem:u,onInvalid:d})=>{let{t:f}=Ee(),[p,m]=Z.useState(``),[h,g]=Z.useState(null),[_,v]=Z.useState(!1),y=o??p,b=Z.useId(),x=e=>{g(null),m(e),s?.(e)},S=K(async()=>{if(!(e||t||_)){v(!0);try{let e=await navigator.clipboard.readText();x(e);let t=fs(e);e.trim()&&(!t||!(`pairing`in t))&&d()}catch{g(f(`mobile.connect.link.pasteFallback`))}finally{v(!1)}}}),C=K(n=>{if(n.preventDefault(),e||t||_)return;let r=fs(y);if(!r||!(`pairing`in r)){d();return}u(r.pairing)});return(0,$.jsxs)(`form`,{className:`flex w-full flex-col gap-3`,onSubmit:C,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Kn,{...xs,value:y,onChange:e=>x(e.target.value),placeholder:f(`mobile.connect.link.placeholder`),"aria-label":f(`mobile.connect.link.label`),inputMode:`url`,autoCapitalize:`none`,tabIndex:n,disabled:e||t||_,"aria-invalid":!!l,"aria-describedby":l||h?b:void 0,className:r}),c?(0,$.jsx)(J,{variant:`outline`,size:`icon`,onClick:()=>void S(),disabled:e||t||_,"aria-label":f(`mobile.connect.link.paste`),children:(0,$.jsx)(X,{name:`clipboard`,className:`size-5`})}):null]}),l||h?(0,$.jsx)(`p`,{id:b,role:`alert`,className:`typography-small text-[var(--status-error)]`,children:l||h}):null,(0,$.jsx)(J,{type:`submit`,variant:i,size:`lg`,className:a,disabled:e||t||_||!y.trim(),children:f(t?`mobile.connect.connecting`:`mobile.connect.connectButton`)})]})};function Cs({connection:e}){let{t}=Ee(),{connections:n,isBusy:r,error:i,pendingConnection:a}=e,o=Z.useMemo(()=>ys(),[]),[s,c]=Z.useState(null),[l,u]=Z.useState(!1),[d,f]=Z.useState(null),[p,m]=Z.useState(!1),[h,_]=Z.useState(null),[v,y]=Z.useState(null),[b,x]=Z.useState(``),[S,C]=Z.useState(``),[w,T]=Z.useState(``),E=n[0],D=n.find(e=>e.id===v),O=r||p,k=s!==null||a!==null,A=t=>{e.setError(null),c(t)},j=()=>{e.setError(null),c(null),u(!0)},M=K(()=>{O||(a?(e.cancelPassword(),C(``)):A(null))}),N=K(async t=>{O||(_(t.id),C(``),await e.connect({id:t.id,candidates:t.candidates,label:t.label}))}),P=K(async()=>{if(!O){_(null),m(!0),e.setError(null);try{let n=await bs();n.status===`ok`?await e.connect({url:n.url,label:n.label,clientToken:n.clientToken}):n.status===`pairing`?await e.redeemPairingConnection(n.pairing):n.status===`permission-denied`?e.setError(t(`mobile.connect.scan.permissionDenied`)):n.status===`invalid`?e.setError(t(`mobile.connect.scan.invalid`)):n.status===`unsupported`?e.setError(t(`mobile.connect.scan.unsupported`)):n.status===`failed`&&e.setError(t(`mobile.connect.scan.failed`))}catch{e.setError(t(`mobile.connect.scan.failed`))}finally{m(!1)}}}),F=K(()=>d?(f(null),!0):k?(M(),!0):l?(u(!1),!0):!1);Z.useEffect(()=>{if(!g())return;let e=!1,t;return ge(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])).then(async({App:n})=>{let r=await n.addListener(`backButton`,()=>{F()||n.minimizeApp().catch(()=>void 0)});e?r.remove():t=()=>{r.remove()}}).catch(()=>void 0),()=>{e=!0,t?.()}},[F]);let I=e=>h===e.id&&r&&!a&&s!==`rename`&&s!==`remove`?t(`mobile.connect.connecting`):e.id===E?.id&&e.lastUsedAt>0?t(`mobile.connect.history.lastUsed`):t(`mobile.instances.status.saved`),L=e=>(0,$.jsxs)(J,{size:`lg`,variant:e?`default`:`ghost`,className:e?`yuri-welcome-primary w-full`:`w-full`,disabled:O,onClick:()=>void P(),children:[(0,$.jsx)(X,{name:p?`loader-4`:`scan-2`,className:p?`size-5 animate-spin motion-reduce:animate-none`:`size-5`}),t(`mobile.connect.scanQr`)]}),R=t(a?a.reason===`pairing`?`mobile.connect.pairing.expired`:`mobile.connect.password.label`:s===`rename`?`mobile.connect.history.rename`:s===`remove`?`mobile.connect.history.remove`:`mobile.connect.welcome.moreOptions`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`main`,{className:`yuri-keyboard-fill-screen yuri-mobile-welcome`,inert:k||l,"aria-hidden":k||l||void 0,"data-welcome-paused":k||l||p?`true`:void 0,children:[(0,$.jsx)(`header`,{className:`yuri-welcome-brand`,children:(0,$.jsx)(La,{className:`block`,width:88})}),(0,$.jsxs)(`div`,{className:`yuri-welcome-content`,children:[(0,$.jsxs)(`div`,{className:`yuri-welcome-intro`,children:[(0,$.jsxs)(`div`,{className:`yuri-welcome-art`,"aria-hidden":`true`,children:[(0,$.jsx)(`span`,{className:`yuri-image-loading yuri-welcome-dots`}),(0,$.jsx)(`div`,{className:`yuri-welcome-logo`,children:(0,$.jsx)(or,{width:144,height:144,className:`size-full`})})]}),(0,$.jsxs)(`div`,{className:`yuri-welcome-copy`,children:[(0,$.jsx)(`h1`,{children:t(E?`mobile.connect.history.welcomeBack`:`mobile.connect.welcome.heading`)}),(0,$.jsx)(`p`,{children:t(`mobile.connect.welcome.pairingHint`)})]})]}),(0,$.jsxs)(`div`,{className:`yuri-welcome-actions flex w-full flex-col gap-3`,children:[E?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(J,{variant:`outline`,className:`yuri-welcome-device`,disabled:O,onClick:j,children:[(0,$.jsx)(X,{name:`computer`,className:`size-7`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 text-left`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label`,children:E.label}),(0,$.jsx)(`span`,{className:`block typography-small font-normal text-muted-foreground`,children:I(E)})]}),(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-5 text-muted-foreground`})]}),(0,$.jsx)(J,{size:`lg`,className:`yuri-welcome-primary w-full`,disabled:O,onClick:()=>void N(E),children:r&&h===E.id?t(`mobile.connect.connecting`):i&&h===E.id?t(`desktopHostSwitcher.actions.retry`):t(`mobile.connect.history.continue`)})]}):null,o?L(!E):E?null:(0,$.jsx)(J,{size:`lg`,className:`yuri-welcome-primary w-full`,disabled:O,onClick:()=>A(`more`),children:t(`mobile.connect.link.useLink`)}),i&&!k&&!l?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,(0,$.jsx)(J,{variant:`ghost`,size:`lg`,disabled:O,className:`mx-auto text-muted-foreground`,onClick:()=>A(`more`),children:t(`mobile.connect.welcome.moreOptions`)})]})]})]}),(0,$.jsxs)(yr,{id:`welcome-history`,open:l,onOpenChange:u,presentation:`page`,edge:`right`,dismissGesture:!0,ariaLabel:t(`mobile.connect.history.title`),children:[(0,$.jsx)(Be,{title:t(`mobile.connect.history.title`),backAriaLabel:t(`header.actions.backAria`),onBack:()=>u(!1)}),(0,$.jsxs)(Gr,{outerClassName:`flex-1`,className:`px-6 py-6`,disableHorizontal:!0,children:[(0,$.jsx)(`h1`,{className:`typography-h1 mb-3`,children:t(`mobile.connect.history.title`)}),(0,$.jsx)(`p`,{className:`mb-6 typography-ui-label font-normal text-muted-foreground`,children:t(n.length?`mobile.connect.history.description`:`mobile.connect.saved.empty`)}),n.map(e=>(0,$.jsx)(`div`,{className:`border-b border-border/60 py-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(J,{variant:`ghost`,className:`yuri-welcome-history-row min-w-0 flex-1`,disabled:O,onClick:()=>void N(e),children:[(0,$.jsx)(X,{name:r&&h===e.id&&!k?`loader-4`:`computer`,className:r&&h===e.id&&!k?`size-7 animate-spin motion-reduce:animate-none`:`size-7`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 text-left`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label`,children:e.label}),(0,$.jsx)(`span`,{className:`block typography-small font-normal text-muted-foreground`,children:I(e)})]})]}),i&&h===e.id&&!k&&!r?(0,$.jsx)(J,{variant:`ghost`,size:`icon`,disabled:O,"aria-label":t(`desktopHostSwitcher.actions.retry`),onClick:()=>void N(e),children:(0,$.jsx)(X,{name:`error-warning-fill`,className:`size-5 text-[var(--status-error)]`})}):null,(0,$.jsxs)(Qn,{open:d===e.id,onOpenChange:t=>f(t?e.id:null),children:[(0,$.jsx)(nr,{asChild:!0,children:(0,$.jsx)(J,{variant:`ghost`,size:`icon`,disabled:O,"aria-label":t(`mobile.connect.history.actions`,{name:e.label}),children:(0,$.jsx)(X,{name:`more`,className:`size-5`})})}),(0,$.jsxs)($n,{align:`end`,children:[(0,$.jsxs)(ar,{onSelect:()=>{y(e.id),x(e.label),A(`rename`)},children:[(0,$.jsx)(X,{name:`edit`,className:`size-4`}),t(`mobile.connect.history.rename`)]}),(0,$.jsxs)(ar,{onSelect:()=>{y(e.id),A(`remove`)},className:`text-[var(--status-error)]`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-4 text-inherit`}),t(`mobile.connect.history.remove`)]})]})]})]})},e.id)),i&&!h&&!k?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null]}),(0,$.jsxs)(`div`,{className:`yuri-welcome-history-footer`,children:[(0,$.jsx)(or,{width:36,height:36,className:`mx-auto mb-5 opacity-40`}),o?L(!1):null,(0,$.jsx)(J,{variant:`ghost`,size:`lg`,className:`w-full`,disabled:O,onClick:()=>A(`more`),children:t(`mobile.connect.link.useLink`)})]})]}),(0,$.jsx)(br,{id:`welcome-options`,open:k,onOpenChange:e=>{e||M()},fitContent:!0,title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:R}),ariaLabel:R,closeAriaLabel:t(`mobile.surface.closeAria`),resizeAriaLabel:t(`mobile.connect.options.resize`),children:(0,$.jsx)(Gr,{className:`px-5 py-5`,disableHorizontal:!0,fillContainer:!1,children:a?.reason===`pairing`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(X,{name:`computer`,className:`size-6 shrink-0 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`min-w-0 flex-1 truncate typography-ui-label`,children:a.label}),n.some(e=>e.id===a.id)?(0,$.jsx)(J,{variant:`ghost`,size:`icon`,disabled:O,"aria-label":t(`mobile.instances.deleteAria`,{label:a.label}),onClick:()=>{y(a.id),e.cancelPassword(),A(`remove`)},children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-5`})}):null]}),(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.pairing.reconnectHint`)}),i?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,o?L(!0):null,(0,$.jsx)(J,{variant:o?`ghost`:`default`,size:`lg`,disabled:O,onClick:()=>{e.cancelPassword(),A(`more`)},children:t(`mobile.connect.link.useLink`)})]}):a?(0,$.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),r||e.submitPassword(S)},children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label`,children:a.label}),(0,$.jsx)(Kn,{type:`password`,autoComplete:`current-password`,value:S,onChange:e=>C(e.target.value),"aria-label":t(`mobile.connect.password.label`),placeholder:t(`mobile.connect.password.placeholder`),disabled:r}),i?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,(0,$.jsx)(J,{type:`submit`,size:`lg`,className:`yuri-welcome-primary w-full`,disabled:r||!S.trim(),children:t(r?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(J,{variant:`ghost`,disabled:r,onClick:M,children:t(`mobile.connect.cancelPassword`)})]}):s===`rename`&&D?(0,$.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e.renameConnection(D.id,b).then(e=>{e&&c(null)})},children:[(0,$.jsx)(Kn,{value:b,onChange:e=>x(e.target.value),disabled:r,"aria-label":t(`mobile.instances.label.label`),autoComplete:`off`,maxLength:120}),i?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,(0,$.jsx)(J,{type:`submit`,size:`lg`,disabled:r||!b.trim(),children:t(`mobile.instances.saveEdit`)})]}):s===`remove`&&D?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-normal`,children:t(`mobile.connect.history.removeHint`,{name:D.label})}),i?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,(0,$.jsx)(J,{variant:`destructive`,size:`lg`,disabled:r,onClick:()=>{e.removeConnection(D.id).then(e=>{e&&(c(null),_(null))})},children:t(`mobile.connect.history.remove`)}),(0,$.jsx)(J,{variant:`ghost`,disabled:r,onClick:M,children:t(`mobile.instances.cancelEdit`)})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`typography-ui-header mb-2`,children:t(`mobile.connect.link.useLink`)}),(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.link.help`)})]}),(0,$.jsx)(Ss,{value:w,onValueChange:t=>{T(t),e.setError(null)},showPasteButton:!0,inputClassName:`min-w-0 flex-1 text-[16px]`,buttonClassName:`yuri-welcome-primary w-full`,buttonVariant:`default`,disabled:O,isBusy:r,error:i,onInvalid:()=>e.setError(t(`mobile.connect.link.invalid`)),onRedeem:t=>{_(null),e.redeemPairingConnection(t)}}),(0,$.jsxs)(J,{variant:`outline`,className:`yuri-welcome-history-row`,disabled:O,onClick:j,children:[(0,$.jsx)(X,{name:`history`,className:`size-6`}),(0,$.jsx)(`span`,{className:`flex-1 text-left`,children:t(`mobile.connect.history.title`)}),(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-5`})]}),(0,$.jsx)(`p`,{className:`typography-small leading-relaxed text-muted-foreground`,children:t(`mobile.connect.welcome.scanHint`)})]})})})]})}function ws(e){let t=(0,Q.c)(17),{children:n}=e,r=_e(Ds),i=_e(Es),a=Z.useRef(null),o=Z.useRef(null),s;t[0]===i?s=t[1]:(s=()=>i(!1),t[0]=i,t[1]=s);let c;t[2]!==r||t[3]!==s?(c={id:`mobile-global-search`,active:r,onBack:s,surfaceRef:a,underlayRef:o},t[2]=r,t[3]=s,t[4]=c):c=t[4],Nr(c);let l,u;t[5]===r?(l=t[6],u=t[7]):(l=()=>{if(!r)return;let e=document.activeElement,t=zn(`global-search-page`);return()=>{t(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},u=[r],t[5]=r,t[6]=l,t[7]=u),Z.useLayoutEffect(l,u);let d=r||void 0,f=r||void 0,p;t[8]!==n||t[9]!==d||t[10]!==f?(p=(0,$.jsx)(`div`,{ref:o,inert:d,"aria-hidden":f,className:`h-full min-h-0 w-full`,children:n}),t[8]=n,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===r?m=t[13]:(m=r?(0,$.jsx)(`div`,{ref:a,"data-mobile-search-page":`true`,className:`absolute inset-0 z-50 flex min-h-0 flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(Ia,{presentation:`page`,onBack:Ts})}):null,t[12]=r,t[13]=m);let h;return t[14]!==p||t[15]!==m?(h=(0,$.jsxs)(`div`,{className:`relative isolate flex h-[100dvh] min-h-0 w-full flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:[p,m]}),t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function Ts(){Ir.requestAnimatedBack(`root`)}function Es(e){return e.setCommandPaletteOpen}function Ds(e){return e.isCommandPaletteOpen}async function Os(e,t,n,i){if(i){let r=await Ya(i,e,n);if(!ve(e))return r;if(!t)throw Error(`unsupported_host`);let a=new URL(r.src,`http://runtime.invalid`);return{...r,src:`${t}${a.pathname}${a.search}${a.hash}`}}let a=d(),o=()=>{if(n.aborted||a!==d())throw new DOMException(`Preview ended`,`AbortError`)};o();let s=new URL(e);if(![`http:`,`https:`].includes(s.protocol)||s.username||s.password)throw Error(`invalid_url`);if(!ve(e))return{src:s.href};if(!t)throw Error(`unsupported_host`);let l=await m(`/api/preview/targets`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:s.href}),signal:n});if(!l.ok)throw Error(`preview_unavailable`);let u=await l.json();if(o(),typeof u.proxyBasePath!=`string`||!/^\/api\/preview\/proxy\/[a-f0-9]{16,64}$/i.test(u.proxyBasePath)||!Ja(`${u.proxyBasePath}${s.pathname}`)||typeof u.previewToken!=`string`||!u.previewToken||typeof u.expiresAt!=`number`||!Number.isFinite(u.expiresAt)||u.expiresAt<=Date.now())throw Error(`invalid_preview`);await r(),o();let f=new URLSearchParams(s.search);f.delete(`yuri_client_token`),f.delete(`yuri_url_token`),f.set(`yuri_preview_token`,u.previewToken);let p=`${u.proxyBasePath}${s.pathname}?${f}${s.hash}`,h=new URL(c().authenticatedAsset(p),`http://runtime.invalid`);return{src:`${t}${h.pathname}${h.search}${h.hash}`,expiresAt:u.expiresAt}}function ks({url:e,hostOrigin:t,entry:n}){let{t:r}=Ee(),i=Z.useRef(null),[s,c]=Z.useReducer(e=>e+1,0),l=n?JSON.stringify(n.queryScope):`local`,[u,d]=Z.useState();Z.useEffect(()=>{let r=new AbortController,i,c=0,u=async()=>{let a=++c;clearTimeout(i);try{let o=await Os(e,t,r.signal,n);if(r.signal.aborted||a!==c)return;d({url:e,hostOrigin:t,scope:l,attempt:s,src:o.src}),o.expiresAt&&(i=setTimeout(()=>{u()},Math.max(1e3,o.expiresAt-Date.now()-1e4)))}catch{!r.signal.aborted&&a===c&&d({url:e,hostOrigin:t,scope:l,attempt:s,error:!0})}},f=ve(e),p=f?a():void 0,m=f?o(()=>{u()}):void 0;return u(),()=>{r.abort(),clearTimeout(i),m?.(),p?.()}},[e,t,s,n,l]);let f=u?.url===e&&u.hostOrigin===t&&u.scope===l&&u.attempt===s?u:void 0;return G(`message`,t=>{if(!f?.src||!ve(e)||t.source!==i.current?.contentWindow||t.origin!==new URL(f.src).origin)return;let r=t.data;r?.source===`yuri-preview-bridge`&&r.version===1&&r.type===`navigate-preview`&&typeof r.url==`string`&&xe.getState().open(r.url,n?.location)}),f?.error?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3`,children:[(0,$.jsx)(Ka,{message:r(`contextPanel.preview.proxyError`)}),(0,$.jsx)(J,{size:`sm`,onClick:c,children:r(`contextPanel.preview.actions.retry`)})]}):f?.src?(0,$.jsx)(`iframe`,{ref:i,src:f.src,title:r(`contextPanel.preview.iframeTitle`),onError:()=>d({url:e,hostOrigin:t,scope:l,attempt:s,error:!0}),className:`h-full w-full border-0`,sandbox:`allow-scripts allow-same-origin allow-forms`}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:r(`contextPanel.preview.loading`)})}function As(e){let t=(0,Q.c)(10),{location:n,url:r,hostOrigin:i}=e,{t:a}=Ee(),o=Xt(!0);if(!o.registry||o.registry.hubId!==n.hubId){let e;return t[0]!==o.error||t[1]!==a?(e=o.error?(0,$.jsx)(Ka,{message:o.error.message}):(0,$.jsx)(`div`,{className:`text-muted-foreground`,children:a(`contextPanel.preview.loading`)}),t[0]=o.error,t[1]=a,t[2]=e):e=t[2],e}let s;t[3]!==n||t[4]!==o.registry?(s=o.registry.resolve(n),t[3]=n,t[4]=o.registry,t[5]=s):s=t[5];let c;return t[6]!==i||t[7]!==s||t[8]!==r?(c=(0,$.jsx)(ks,{url:r,hostOrigin:i,entry:s}),t[6]=i,t[7]=s,t[8]=r,t[9]=c):c=t[9],c}function js(){let e=(0,Q.c)(17),{t}=Ee(),n=xe(Ns),r=U(),i=Z.useSyncExternalStore(s,d,d),a=n?.generation===i?n:null,o=!!a,c;e[0]===t?c=e[1]:(c=t(`contextPanel.preview.iframeTitle`),e[0]=t,e[1]=c);let l;e[2]===t?l=e[3]:(l=t(`guiPlugins.close`),e[2]=t,e[3]=l);let u;e[4]===t?u=e[5]:(u=t(`guiPlugins.resize`),e[4]=t,e[5]=u);let f=a?.url??``,p;e[6]!==a||e[7]!==i||e[8]!==r?(p=a?(0,$.jsx)(qa,{children:e=>a.location?.hostId?r?.entry.location.hubId===a.location.hubId&&r.entry.location.hostId===a.location.hostId&&r.entry.location.directory===a.location.directory?(0,$.jsx)(ks,{url:a.url,hostOrigin:e?.hostOrigin,entry:r.entry}):(0,$.jsx)(As,{location:a.location,url:a.url,hostOrigin:e?.hostOrigin}):(0,$.jsx)(ks,{url:a.url,hostOrigin:e?.hostOrigin})},i):null,e[6]=a,e[7]=i,e[8]=r,e[9]=p):p=e[9];let m;return e[10]!==o||e[11]!==c||e[12]!==l||e[13]!==u||e[14]!==f||e[15]!==p?(m=(0,$.jsx)(br,{id:`mobile-html-preview`,open:o,ariaLabel:c,closeAriaLabel:l,resizeAriaLabel:u,initiallyExpanded:!0,title:f,onOpenChange:Ms,children:p}),e[10]=o,e[11]=c,e[12]=l,e[13]=u,e[14]=f,e[15]=p,e[16]=m):m=e[16],m}function Ms(e){e||xe.getState().close()}function Ns(e){return e.target}function Ps(){let e=st(e=>e.projects.find(t=>t.id===e.activeProjectId)),t=ct(e=>e.remoteSession),n=!!e?.hostId,r=qt(),i=Xt(n&&r),a=r&&i.catalog?.supported!==!1,o=Z.useMemo(()=>e?.hubId&&e.hostId?{supported:!0,hubId:e.hubId,projects:[],hosts:[{id:e.hostId,name:e.hostId,source:`direct`,state:`offline`}]}:void 0,[e?.hubId,e?.hostId]),s=n&&a?i.registry??(o?Yt(o):void 0):void 0,c=e?.hostId,l=Z.useMemo(()=>e=>s&&c?s.subscribeHost(c,e):()=>{},[s,c]),u=Z.useMemo(()=>()=>s&&c?s.getHost(c):void 0,[s,c]),d=Z.useSyncExternalStore(l,u,u),f=t?.projectId===e?.id&&t?.location.hostId===c&&t?.location.hubId===(e?.hubId??s?.hubId),p=Z.useMemo(()=>s&&c&&e&&(!e.hubId||s.hubId===e.hubId)?{hubId:s.hubId,hostId:c,directory:f&&t?t.location.directory:e.path}:void 0,[s,c,e,f,t]),m=p&&s?s.resolve(p):void 0,[h,g]=Z.useState();Z.useEffect(()=>{if(!s||!m)return;let e=xt(s,m),t=e.retain();return g({entry:m,owner:e}),t},[s,m]);let _=h?.entry===m?h?.owner:void 0,y=f?t?.sessionId??null:null,b=Z.useMemo(()=>e=>_?_.state.subscribeSnapshot(e):()=>{},[_]),x=Z.useMemo(()=>()=>_&&y?_.state.getSnapshot(y).session:void 0,[_,y]),S=Z.useSyncExternalStore(b,x,x),C=Zt(s,c,n&&a);return{enabled:n,supported:a,project:e,registry:s,entry:m,owner:_,sessionId:y,session:S??C.data?.directories.find(e=>e.directory===p?.directory)?.sessions.find(e=>e.id===y),host:d,openSession:K(t=>{if(!e?.hostId||!p)throw Error(`Remote Host scope unavailable`);ct.getState().openRemoteSession(e,p,t)}),refresh:K(async()=>{if(!_||!y)throw Error(`Remote session unavailable`);await _.state.repository.refreshFromAuthority(_.state.scope(y))}),key:p?v(p):e?.id??``,error:i.error}}var Fs=e=>{let t=(0,Q.c)(20),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({children:n,className:r,contentClassName:i,style:o,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=it(`yuri-mobile-header relative z-30 shrink-0 border-b border-border/30 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80`,r),t[6]=r,t[7]=s);let c;t[8]===o?c=t[9]:(c={paddingTop:`var(--yuri-safe-area-top, 0px)`,...o},t[8]=o,t[9]=c);let l;t[10]===i?l=t[11]:(l=it(`flex h-[var(--yuri-header-height,56px)] w-full items-center gap-1 px-2`,i),t[10]=i,t[11]=l);let u;t[12]!==n||t[13]!==l?(u=(0,$.jsx)(`div`,{className:l,children:n}),t[12]=n,t[13]=l,t[14]=u):u=t[14];let d;return t[15]!==a||t[16]!==s||t[17]!==c||t[18]!==u?(d=(0,$.jsx)(`header`,{className:s,style:c,...a,children:u}),t[15]=a,t[16]=s,t[17]=c,t[18]=u,t[19]=d):d=t[19],d};function Is(e){let t=(0,Q.c)(30),{percentage:n,pending:r}=e,i=r!==void 0&&r,{t:a}=Ee(),o,s,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==n||t[2]!==a){c=i?0:Zn(n)??0;let e=er(n);s=i?`var(--surface-muted-foreground)`:e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,o=2*Math.PI*7.5,l=`0 0 18 18`,u=`size-[18px] -rotate-90`,d=`progressbar`,t[12]===a?f=t[13]:(f=a(`contextUsage.aria.label`),t[12]=a,t[13]=f),t[14]!==i||t[15]!==a?(p=i?a(`contextUsage.pending`):void 0,t[14]=i,t[15]=a,t[16]=p):p=t[16],m=i?void 0:Math.round(c),t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m}else o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11];let h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[17]=h):h=t[17];let g=o*(1-c/100),_;t[18]!==o||t[19]!==s||t[20]!==g?(_=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:s,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:o,strokeDashoffset:g,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[18]=o,t[19]=s,t[20]=g,t[21]=_):_=t[21];let v;return t[22]!==_||t[23]!==l||t[24]!==u||t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m?(v=(0,$.jsxs)(`svg`,{viewBox:l,className:u,role:d,"aria-label":f,"aria-valuetext":p,"aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:[h,_]}),t[22]=_,t[23]=l,t[24]=u,t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=v):v=t[29],v}var Ls=(e,t,n)=>ne({queryKey:[...e.queryScope,`mobile-session-metadata`,t],staleTime:3e4,gcTime:1/0,retry:!1,queryFn:({signal:e})=>n(e)});function Rs(e){let t=W(e);return Ls(e,`git`,async n=>{let r={signal:n,query:{directory:e.location.directory},headers:{"x-opencode-directory":e.location.directory}};return(await t.json(`/api/git/check`,r)).isGitRepository?{isGitRepository:!0,current:(await t.json(`/api/git/status`,{...r,query:{...r.query,mode:`light`}})).current}:{isGitRepository:!1,current:null}})}function zs(e){let t=W(e);return Ls(e,`quota-settings`,async e=>{let n=await t.json(`/api/config/settings`,{signal:e}),r=ri.map(e=>e.id),i=Array.isArray(n.usageDropdownProviders)?n.usageDropdownProviders.filter(e=>typeof e==`string`&&(e.startsWith(`magpie:`)||r.includes(e))):r,a={};if(n.usageSelectedModels&&typeof n.usageSelectedModels==`object`)for(let[e,t]of Object.entries(n.usageSelectedModels))Array.isArray(t)&&(a[e]=t.filter(e=>typeof e==`string`));return{providerIds:i,selectedModels:a,displayMode:n.usageDisplayMode===`remaining`?`remaining`:`usage`,autoRefresh:n.usageAutoRefresh===!0,refreshIntervalMs:typeof n.usageRefreshIntervalMs==`number`&&Number.isFinite(n.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(n.usageRefreshIntervalMs))):6e4}})}function Bs(e,t){let n=W(e);return Ls(e,`quota:${t}`,async e=>{let r=await n.json(`/api/quota/${encodeURIComponent(t)}`,{signal:e});if(!ae(r)||r.providerId!==t)throw Error(`Invalid quota response`);return r})}function Vs(e){let t=W(e);return Ls(e,`magpie`,async n=>{let r=await t.json(`/api/quota/magpie`,{signal:n,query:{directory:e.location.directory}});if(!Array.isArray(r.sources)||!r.sources.every(e=>e&&typeof e.id==`string`&&Array.isArray(e.results)&&e.results.every(t=>ae(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return r.sources.flatMap(e=>e.results)})}var Hs=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},Us=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),Ws=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,Gs=e=>{let{totalTokens:t,contextLimit:n,isDraft:r}=e;if(!r&&t===null)return{pending:!0,percentage:0,tokens:`—`,colorClass:`text-muted-foreground`};if(t===null||r||t<=0||n<=0)return null;let i=Math.min(t/n*100,999);return{percentage:i,tokens:`${Us(t)}/${Us(n)}`,colorClass:Ws(i)}},Ks=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`user`)continue;let r=typeof n.model?.providerID==`string`&&n.model.providerID.trim().length>0?n.model.providerID:void 0,i=typeof n.model?.modelID==`string`&&n.model.modelID.trim().length>0?n.model.modelID:void 0;if(r&&i)return{providerID:r,modelID:i}}return null},qs=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``);function Js(e,t,n){let r=(0,Q.c)(7),{t:i}=Ee(),a;if(r[0]!==t||r[1]!==e||r[2]!==n||r[3]!==i){let o=new Map(e.map(Ys)),s;r[5]===t?s=r[6]:(s=e=>t.includes(e.id),r[5]=t,r[6]=s),a=ui(e).filter(s).filter(e=>o.get(e.id)?.configured===!0).map(e=>{let t=o.get(e.id),r=[];for(let[e,n]of Ai(Object.entries(t?.usage?.windows??{}),t?.usage?.accounts))r.push({key:`window-${e}`,label:Yn(n.label??e),window:n});let a=Object.entries(t?.usage?.models??{}),s=n[e.id]??[];for(let[e,t]of s.length>0?a.filter(e=>{let[t]=e;return s.includes(t)}):a){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:Yn(a.label??i),subtitle:oi(e),window:a})}return{providerId:e.id,providerName:e.name,rows:r,status:!t.ok&&t.error?t.error:r.length===0?i(`header.services.noRateLimitsReported`):null}}),r[0]=t,r[1]=e,r[2]=n,r[3]=i,r[4]=a}else a=r[4];return a}function Ys(e){return[e?.providerId,e]}var Xs=e=>{let t=e.usedPercent;return typeof t!=`number`||!Number.isFinite(t)?`text-foreground`:t>=80?`text-[var(--status-error)]`:t>=50?`text-[var(--status-warning)]`:`text-foreground`},Zs=e=>{let t=(0,Q.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,$.jsx)(X,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},Qs=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=Ee(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Er,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,$.jsx)(`span`,{className:`min-w-0 max-w-[60%] truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map((t,n)=>{let i=Ei(e.rows.map(wc),n),o=r===`remaining`?t.window.remainingPercent:t.window.usedPercent,s=tr(t.window.valueLabel,o),c=Xn(t.window.resetAt,t.window.resetAfterFormatted??t.window.resetAtFormatted,a);return(0,$.jsxs)(Z.Fragment,{children:[i?(0,$.jsx)(`div`,{className:it(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-3 border-t border-[var(--surface-subtle)] pt-2`),children:i}):null,(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:t.subtitle?`${t.subtitle} · ${t.label}`:t.label}),c?(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-micro text-muted-foreground/70`,children:c}):null]}),(0,$.jsx)(`span`,{className:it(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,Xs(t.window)),children:s===`-`?``:s})]})]},t.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 truncate typography-micro text-muted-foreground`,title:e.status,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,$.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},$s=e=>{let t=(0,Q.c)(52),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l,error:u,onRetry:d}=e,{t:f}=Ee(),p=Z.useRef(null),[m,h]=Z.useState(n),[g,_]=Z.useState(!1),v,y;t[0]!==n||t[1]!==m?(v=()=>{if(n){h(!0),_(!1);return}if(!m)return;_(!0);let e=window.setTimeout(()=>{h(!1),_(!1)},140);return()=>window.clearTimeout(e)},y=[n,m],t[0]=n,t[1]=m,t[2]=v,t[3]=y):(v=t[2],y=t[3]),Z.useEffect(v,y);let b,x;if(t[4]!==r||t[5]!==n?(b=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},x=[r,n],t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),Z.useEffect(b,x),!m)return null;let S;t[8]===f?S=t[9]:(S=f(`mobile.surface.closeAria`),t[8]=f,t[9]=S);let C;t[10]===r?C=t[11]:(C=e=>{e.preventDefault(),r()},t[10]=r,t[11]=C);let w;t[12]!==S||t[13]!==C?(w=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":S,onPointerDown:C}),t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;t[15]===f?T=t[16]:(T=f(`mobile.header.openMetadataAria`),t[15]=f,t[16]=T);let E=g&&`pointer-events-none`,D;t[17]===E?D=t[18]:(D=it(`pointer-events-auto absolute inset-x-3 top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.5rem)] overflow-x-hidden overflow-y-auto overscroll-contain rounded-[20px] yuri-mobile-overlay-surface yuri-mobile-overlay-surface--translucent p-2 will-change-transform`,E),t[17]=E,t[18]=D);let O=`${g?`session-metadata-out`:`session-metadata-in`} ${g?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,k;t[19]===O?k=t[20]:(k={animation:O,maxHeight:`min(72dvh, calc(100dvh - var(--yuri-safe-area-top, 0px) - var(--yuri-mobile-detail-navigation-height, 3.5rem) - 1rem))`},t[19]=O,t[20]=k);let A;t[21]===f?A=t[22]:(A=f(`mobile.header.metadata.branch`),t[21]=f,t[22]=A);let j;t[23]!==a||t[24]!==A?(j=(0,$.jsx)(Zs,{iconName:`git-branch`,label:A,children:a}),t[23]=a,t[24]=A,t[25]=j):j=t[25];let M;t[26]!==i||t[27]!==f?(M=i?(0,$.jsx)(Zs,{iconNode:(0,$.jsx)(Is,{percentage:i.percentage,pending:i.pending}),label:f(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsx)(`span`,{className:it(`font-semibold`,i.colorClass),children:i.pending?f(`contextUsage.pending`):`${i.percentage.toFixed(1)}%`}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:i.tokens})]})}):null,t[26]=i,t[27]=f,t[28]=M):M=t[28];let N;t[29]!==c||t[30]!==l||t[31]!==s||t[32]!==o?(N=(0,$.jsx)(Qs,{groups:o,displayMode:s,isLoading:c,timeFormatPreference:l}),t[29]=c,t[30]=l,t[31]=s,t[32]=o,t[33]=N):N=t[33];let P;t[34]!==u||t[35]!==d||t[36]!==f?(P=u?(0,$.jsxs)(`div`,{role:`alert`,className:`px-2.5 py-2 typography-ui-label text-[var(--status-error)]`,children:[u,(0,$.jsx)(J,{variant:`ghost`,size:`sm`,onClick:d,children:f(`contextPanel.preview.actions.retry`)})]}):null,t[34]=u,t[35]=d,t[36]=f,t[37]=P):P=t[37];let F;t[38]!==j||t[39]!==M||t[40]!==N||t[41]!==P?(F=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[j,M,N,P]}),t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=F):F=t[42];let I;t[43]!==D||t[44]!==k||t[45]!==F||t[46]!==T?(I=(0,$.jsx)(`div`,{ref:p,role:`dialog`,"aria-label":T,className:D,style:k,onPointerDown:Tc,children:F}),t[43]=D,t[44]=k,t[45]=F,t[46]=T,t[47]=I):I=t[47];let L;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(`style`,{children:`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-B5H_XtmE.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/ToolOutputDialog-CKyuEaps.js","assets/runtime-auth-mjIpsk3N.js","assets/runtime-switch-BMjl5Y5W.js","assets/runtime-fetch-DKZOpfzo.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-wF65ZFgV.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-z2M4boRm.js","assets/vendor-react-P8wFrkcT.js","assets/vendor-tanstack-react-query-B-KblYBV.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/runtime-file-resource-CuLP3xp7.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-Dyjw5sZR.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-Cfmg-aDQ.js","assets/vendor-zustand-Cwko4FG1.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-EOAzZiAy.js","assets/runtime-file-download-D11Nnedg.js","assets/vendor-pierre-diffs-tqo4Z3TC.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/i18n-qHllte6P.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-BOD3jjMl.js","assets/tour-CMXP3Kif.js","assets/useMobileNavigationStore-DuBHKBp6.js","assets/gitApiHttp-B0FJaIhU.js","assets/client-1Fk5IbQR.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-9fjmgafL.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-B5HgJenP.js","assets/useAssistantUIStore-jOKVcBK8.js","assets/input-store-CsY-uaSj.js","assets/remoteProjectQueries-Dfms-cCx.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-C57Z9mV2.js","assets/vendor-framer-motion-CF9BQLta.js","assets/Icon-B3cNGB1E.js","assets/dialog-DGjWVnel.js","assets/dialog-CTYD3Sbr.css","assets/tap-LkQum5bB.js","assets/themes-BgDJcxRc.js","assets/MarkdownRenderer-OdVoXQ3K.js","assets/useEffectiveDirectory-BciDDIuG.js","assets/markdownHeightCache-squymH-Z.js","assets/dualLimitLru-D8Sphgua.js","assets/MobileWindowStack-DGLdgoGr.js","assets/mobileBackNavigation-ix4AQEOa.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/toolHelpers-iEHVHQ9p.js","assets/image-loading-DBqnxgDH.js","assets/image-loading-DA9JEHD8.css","assets/ImageLoadingPlaceholder-DtxjvYT1.js","assets/vendor-tanstack-react-virtual-BkuqzrEV.js","assets/markdownTheme-DFDWa8Gh.js","assets/markdown-worker-oBGEB9Eg.js","assets/vendor-capacitor-push-notifications-D5cqJIPw.js","assets/vendor-capacitor-status-bar-D9bcMr9Q.js","assets/vendor-capacitor-keyboard-BRVcFyc9.js","assets/gitApi-DMqau005.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{S as t,_ as n,p as r,r as i,t as a,v as o}from"./runtime-auth-mjIpsk3N.js";import{c as s,f as c,i as l,l as u,n as d,r as f,t as p}from"./runtime-switch-BMjl5Y5W.js";import{n as m}from"./runtime-fetch-DKZOpfzo.js";import{f as h,n as g,r as _,s as v,t as y}from"./platform-wF65ZFgV.js";import{n as b,t as x}from"./runtimeAPIRegistry-C2VogTny.js";import{a as S}from"./vendor-zustand-Cwko4FG1.js";import{it as C,ot as w,st as T}from"./vendor-base-ui-z2M4boRm.js";import{Mt as E,Pt as D,St as O,xt as k}from"./gitApiHttp-B0FJaIhU.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as A}from"./safeStorage-DTOhKN0V.js";import{Bt as j,Qt as M,Zt as N,dn as P,n as F,on as I,sn as L,un as R,zt as ee}from"./client-1Fk5IbQR.js";import{n as z,t as B}from"./vendor-react-P8wFrkcT.js";import{f as V}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{c as te,o as ne,s as re}from"./vendor-tanstack-react-query-B-KblYBV.js";import{C as H,D as ie,E as U,G as ae,S as oe,T as se,V as ce,k as le,q as ue,w as de,z as W}from"./runtime-file-resource-CuLP3xp7.js";import{o as fe}from"./path-utils-jGozTg9d.js";import{i as G,l as pe,m as me,r as K}from"./vendor-reactuses-core-Dyjw5sZR.js";import{a as he,n as q,o as ge}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as _e}from"./useUIStore-Cfmg-aDQ.js";import{a as ve,o as ye,s as be,t as xe}from"./useMobileHtmlPreviewStore-EOAzZiAy.js";import{t as Se}from"./capgoAdapter-DOWlyoxM.js";/* empty css */import{a as Ce}from"./vendor-pierre-diffs-tqo4Z3TC.js";import{r as we}from"./vendor-sonner-B5HgJenP.js";import{r as Te,t as Ee}from"./i18n-qHllte6P.js";import{i as De,n as Oe}from"./store-BOD3jjMl.js";import{a as ke,i as Ae,l as je,o as Me,r as Ne,s as Pe,t as Fe,u as Ie}from"./mobileConnections-ZifVGuqT.js";import{S as Le,b as Re,h as ze,t as Be,v as Ve,y as He}from"./MobileDetailNavigation-BjB-cyVm.js";import{A as Ue,Ci as We,Cn as Ge,Cr as Ke,Di as qe,Dr as Je,Ei as Ye,Fr as Xe,H as Ze,In as J,J as Qe,Ji as $e,Pa as et,Pr as tt,Pt as nt,R as rt,Rn as it,Si as Y,Ti as at,Ui as ot,Va as st,Wa as ct,Xi as lt,_i as ut,ai as dt,ar as ft,at as pt,bi as mt,er as ht,fi as gt,gr as _t,hi as vt,hr as yt,in as bt,ir as xt,jr as St,kr as Ct,lt as wt,mr as Tt,na as Et,o as Dt,p as Ot,q as kt,rr as At,s as jt,st as Mt,t as Nt,tt as Pt,ui as Ft,ut as It,vi as Lt,wi as Rt,xi as zt,z as Bt}from"./useMobileNavigationStore-DuBHKBp6.js";import{i as Vt,n as Ht,r as Ut}from"./useAssistantUIStore-jOKVcBK8.js";import{a as Wt,o as Gt,t as Kt}from"./MobileShareBridge-CI3yZRU6.js";import{d as qt,h as Jt,i as Yt,m as Xt,p as Zt}from"./remoteProjectQueries-Dfms-cCx.js";import{n as Qt}from"./useThemeSystem-C57Z9mV2.js";import{n as X}from"./Icon-B3cNGB1E.js";import{a as $t,i as en,n as tn,o as nn,r as rn,t as an}from"./dialog-DGjWVnel.js";import{$ as on,At as sn,Bt as cn,D as ln,Et as un,Ft as dn,G as fn,Ht as pn,It as mn,J as hn,K as gn,Lt as _n,Mt as vn,Nt as yn,Pt as bn,Q as xn,R as Sn,Rt as Cn,S as wn,St as Tn,T as En,Tt as Dn,Ut as On,Vt as kn,W as An,Wt as jn,Xt as Mn,Z as Nn,dt as Pn,ft as Fn,ht as In,i as Ln,nt as Rn,q as zn,r as Bn,t as Vn,tt as Hn,wt as Un,x as Wn,zt as Gn}from"./useAppFontEffects-vT1vSXTc.js";import{t as Kn}from"./input-zMUdy5A_.js";import{t as qn}from"./tap-LkQum5bB.js";import{r as Jn}from"./tooltip-BfY_e3WX.js";import{A as Yn,D as Xn,E as Zn,G as Qn,K as $n,M as er,O as tr,Q as nr,S as rr,W as ir,q as ar}from"./pwa-Bix1wcNI.js";import{t as or}from"./YuriLogo-VXtP1vhh.js";import{o as sr}from"./react-BQSnpJ3a.js";import{i as cr,o as lr,t as ur}from"./device-QL8KNSLM.js";import{r as dr}from"./themes-BgDJcxRc.js";import{o as fr}from"./scheduledTaskNavigation-y5g8D2ee.js";import{a as pr,n as mr,o as hr}from"./MarkdownRenderer-OdVoXQ3K.js";import{C as gr,d as _r,n as vr,r as yr,t as br,u as xr}from"./MobileResizableSheet-UePgX-mu.js";import{_ as Sr,g as Cr,v as wr,w as Tr}from"./insertionBoundaries-Dr-UiiPl.js";import{l as Er,u as Dr}from"./select-hPO_aN_C.js";import{M as Or,N as kr,O as Ar,h as jr,i as Mr,n as Nr,r as Pr,s as Fr,t as Ir}from"./mobileBackNavigation-ix4AQEOa.js";import{r as Lr}from"./queue-abort-optimistic-C3mS_Lhh.js";import{a as Rr,c as zr,i as Br,s as Vr}from"./toolHelpers-iEHVHQ9p.js";import{o as Hr}from"./image-loading-DBqnxgDH.js";import{t as Ur}from"./ImageLoadingPlaceholder-DtxjvYT1.js";import{t as Wr}from"./LoadingImage-2TwmcRKf.js";import{n as Gr,r as Kr}from"./textarea-C6wJ8cXq.js";import{a as qr,f as Jr,i as Yr,n as Xr,s as Zr}from"./projectMeta-Cl_IHUOq.js";import{r as Qr}from"./ToolOutputDialog-CKyuEaps.js";import{c as $r,s as ei}from"./sessionLookup-DSqwyvC5.js";import{n as ti,t as ni}from"./useProjectRuntimeAPIs-CULigqL2.js";import{$ as ri,A as ii,G as ai,M as oi,Q as si,Y as ci,d as li,et as ui,i as di,k as fi,n as pi,r as mi,t as hi}from"./MobileSurface-wMpm_zU8.js";import{t as gi}from"./openRemoteProjectSession-BZw6ETw7.js";import{i as _i,r as vi}from"./AssistantConversationSurface-BJth3jXT.js";import{t as yi}from"./useFontPreferences-CO-L-Gd7.js";import{B as bi,Ct as xi,Dt as Si,E as Ci,Et as wi,F as Ti,Ft as Ei,G as Di,Ht as Oi,I as ki,It as Ai,J as ji,Jt as Mi,K as Ni,Kt as Pi,L as Fi,Lt as Ii,Nt as Li,Ot as Ri,P as zi,Q as Bi,R as Vi,Rt as Hi,St as Ui,T as Wi,Tt as Gi,Ut as Ki,V as qi,W as Ji,Wt as Yi,X as Xi,Y as Zi,Z as Qi,Zt as $i,_t as ea,a as ta,at as na,c as ra,ct as ia,d as aa,dt as oa,et as sa,f as ca,ft as la,gt as ua,ht as da,i as fa,it as pa,l as ma,lt as ha,mt as ga,n as _a,nt as va,o as ya,ot as ba,pt as xa,q as Sa,qt as Ca,r as wa,rt as Ta,s as Ea,st as Da,t as Oa,tt as ka,u as Aa,ut as ja,w as Ma,wt as Na,xt as Pa,z as Fa,zt as Ia}from"./runtimeEndpointReset-ZHN1UrEC.js";import{t as La}from"./YuriWordmark-B7lmpLRB.js";import{r as Ra,t as za}from"./mcpQueries-BLOLrmAP.js";import{f as Ba}from"./usePluginsStore-Cal-Lu-K.js";import{a as Va,i as Ha,o as Ua,r as Wa,t as Ga}from"./SettingsView-D5IHBHDl.js";import{a as Ka,i as qa}from"./readiness-aosbvIX3.js";import{t as Ja}from"./relay-preview-frame-src-BPyz3nXA.js";import{n as Ya}from"./project-preview-2H-TmJkd.js";import{n as Xa,r as Za,t as Qa}from"./AssistantUnreadBadge-c8MicghF.js";import{a as $a,c as eo,i as to,o as no,r as ro,s as io,t as ao}from"./AssistantView-BJuadEep.js";var Z=e(T(),1),oo=B(),so=null,co=!1,lo=new Promise(e=>{so=e});function uo(){co||(co=!0,so?.())}var fo=6,po=e=>e.parentID??null,mo=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},ho=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),go=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=ho(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return mo(n?n.path:e)},_o=()=>{let e=Lt.getState().activeSessions,t=Je.getState().index.session.unseenCount,n=st.getState().projects,r=0,i=[];for(let a of e){let e=po(a)!==null,o=(t[a.id]??0)>0&&!e;o&&(r+=1),e||i.push({id:a.id,title:a.title??``,updated:a.time?.updated??a.time?.created??0,unread:o,project:go(vt(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,fo).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},vo=`__YURI_WIDGET_SNAPSHOT__`,yo=()=>{typeof window>`u`||(window[vo]=()=>{try{return JSON.stringify(_o())}catch{return null}})},Q=z(),bo=he(`YuriScreenAwake`),xo=Promise.resolve(),So=0;function Co(e){let t=xo.then(()=>bo.setEnabled({enabled:e}));return xo=t.catch(()=>void 0),t}async function wo(){if(q.isNativePlatform()&&q.isPluginAvailable(`YuriScreenAwake`)){So+=1;try{await Co(!0)}catch(e){throw--So,e}let e=!1;return async()=>{e||(e=!0,--So,So===0&&await Co(!1))}}if(!navigator.wakeLock)throw Error(`Screen wake lock unavailable`);let e=await navigator.wakeLock.request(`screen`);return async()=>{e.released||await e.release()}}var $=w();function To(e){let t=(0,Q.c)(3),n=ft(),r=e.remoteState??n??void 0,i;return t[0]!==e||t[1]!==r?(i=(0,$.jsx)(Oo,{...e,remoteState:r}),t[0]=e,t[1]=r,t[2]=i):i=t[2],i}function Eo(e){let t=(0,Q.c)(6),{identity:n,onSource:r}=e,i=wt(e.sessionId,e.directory),a=It(e.sessionId,e.directory),o,s;return t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a?(o=()=>r({identity:n,resolved:a,getMessages:()=>i}),s=[n,r,i,a],t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o,t[5]=s):(o=t[4],s=t[5]),(0,Z.useLayoutEffect)(o,s),null}function Do(e){let{identity:t,onSource:n}=e,r=e.remoteState,i=(0,Z.useMemo)(()=>r.scope(e.sessionId),[r,e.sessionId]),a=(0,Z.useMemo)(()=>e=>r.repository.subscribe(i,e),[r,i]),o=(0,Z.useMemo)(()=>()=>r.repository.hasSession?.(i)||r.repository.getRequestState?.(i)?.status===`ready`||r.repository.getTranscript(i).messageOrder.length>0,[r,i]),s=(0,Z.useSyncExternalStore)(a,o,o),c=K(function*(){let e=r.repository.getTranscript(i);for(let t of e.messageOrder)yield e.messagesByID[t]});return(0,Z.useLayoutEffect)(()=>n({identity:t,resolved:s,getMessages:c}),[t,n,s,c]),null}function Oo(e){let{sessionId:t,directory:n,active:r,children:i,remoteState:a}=e,{t:o}=Ee(),c=JSON.stringify([a?.entry.key??(e.remote?`remote-pending`:`local`),a?.entry.connectionGeneration,t,n]),l=(0,Z.useRef)(null),[u,d]=(0,Z.useState)(null),f=K(e=>{l.current=e,d(t=>t?.identity===e.identity&&t.resolved===e.resolved?t:{identity:e.identity,resolved:e.resolved})}),[p,m]=pe(`yuri.auto-read`,!1),h=p===!0,[g,_]=(0,Z.useState)(0),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(document.visibilityState===`visible`),w=on({enabled:v}),T=(0,Z.useRef)({enabled:!1,generation:0,floor:0,seen:new Set,observed:new Set,pending:[],playing:!1}),E=(0,Z.useRef)(!1),D=r&&!!t&&u?.identity===c&&u.resolved,O=K(()=>{let e=T.current;e.enabled=!1,e.generation+=1,e.pending=[],e.playing=!1,e.seen.clear(),e.observed.clear(),E.current=!1,w.stop(),x(null),y(!1)}),k=K(()=>{let e=T.current;if(!e.enabled||e.playing||!r||document.visibilityState!==`visible`)return;let t=e.pending.shift();if(!t)return;e.playing=!0,x(t);let n=e.generation;w.play(t.text,t=>{if(n===e.generation){if(e.playing=!1,x(null),t){O(),we.error(o(`mobile.menu.autoReadFailed`));return}k()}},{target:t.target})}),A=K(e=>{let n=T.current;!n.enabled||!D||e.sessionId!==t||!e.text.trim()||e.created<n.floor&&!n.observed.has(e.messageId)||n.seen.has(e.messageId)||(n.seen.add(e.messageId),n.pending.push(e),k())}),j=K((e,n)=>{T.current.enabled&&D&&e===t&&T.current.observed.add(n)}),M=K(()=>{if(h){m(!1),O();return}D&&(m(!0),w.unlock().catch(()=>{we.error(o(`mobile.menu.autoReadFailed`))}))}),N=K(()=>{let e=T.current;e.floor=0,e.seen=new Set;for(let t of l.current?.getMessages()??[])e.floor=Math.max(e.floor,t.time.created),(t.time.completed!=null||t.role!==`assistant`)&&e.seen.add(t.id);e.enabled=!0,y(!0)});(0,Z.useEffect)(()=>(O(),h&&D&&N(),O),[t,n,c,h,D,g,N,O]),(0,Z.useEffect)(()=>s(()=>{O(),_(e=>e+1)}),[O]);let P=K(()=>{m(!1),O()});G(`pointerdown`,()=>{if(!T.current.enabled||E.current)return;E.current=!0;let e=T.current.generation;w.unlock().catch(()=>{e===T.current.generation&&(E.current=!1)})},document),G(`visibilitychange`,()=>{C(document.visibilityState===`visible`),document.visibilityState===`visible`?k():(T.current.generation+=1,T.current.playing=!1,T.current.pending=[],w.stop(),x(null))},document),(0,Z.useEffect)(()=>{if(!v||!D||!S)return;let e=!1,t;return wo().then(n=>{e?n().catch(()=>void 0):t=n}).catch(()=>{e||we.warning(o(`mobile.menu.autoReadAwakeFailed`))}),()=>{e=!0,t?.().catch(()=>void 0)}},[v,D,S,t,n,c,g,o]);let F=(0,Z.useMemo)(()=>({enabled:h,available:D,toggle:M,rendered:A,streaming:j}),[h,D,M,A,j]),I=(0,Z.useMemo)(()=>v&&r&&S&&w.isPlaying&&b?.sessionId===t?{sessionId:t,messageId:b.messageId,stop:P}:null,[v,r,S,w.isPlaying,b,t,P]);return(0,$.jsx)(Nn.Provider,{value:F,children:(0,$.jsxs)(xn.Provider,{value:I,children:[a?(0,$.jsx)(Do,{...e,identity:c,onSource:f,remoteState:a}):e.remote?null:(0,$.jsx)(Eo,{...e,identity:c,onSource:f}),i]})})}function ko(e){let t=(0,Q.c)(3),{children:n}=e,r=(0,Z.useContext)(Nn);if(!r)return null;let i;return t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var Ao={getPlatform:()=>q.getPlatform(),isPluginAvailable:e=>q.isPluginAvailable(e),openInSystemBrowser:e=>be.open(e),openExternal:ye},jo=async(e,t=Ao)=>{if(t.getPlatform()===`android`){if(!t.isPluginAvailable(`YuriExternalBrowser`))return!1;try{return await t.openInSystemBrowser({url:e}),!0}catch{return!1}}return t.openExternal(e)},Mo=`mobile-app-update-available`,No=`mobile-app-update-toast-dismissed-version`,Po=()=>{let e=(0,Q.c)(9),{t}=Ee(),n=ci(Fo),r=ci(Io),i=ci(Lo),a=ci(Ro),o=ci(zo),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,e[0]=s):s=e[0];let c=Z.useRef(s),l,u;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(l=()=>{if(y()!==`android`||r!==`mobile`||!n||!i||!a||o){Y.dismiss(Mo);return}A().getItem(No)!==i&&(c.current.has(i)||(c.current.add(i),Y.info(t(`mobileUpdate.toast.available.title`),{id:Mo,description:t(`mobileUpdate.toast.available.description`,{version:i}),duration:1/0,icon:(0,$.jsx)(X,{name:`download`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.toast.actions.download`),onClick:()=>{jo(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{A().setItem(No,i),Y.dismiss(Mo)}}})))},u=[n,a,o,r,t,i],e[1]=n,e[2]=a,e[3]=o,e[4]=r,e[5]=t,e[6]=i,e[7]=l,e[8]=u):(l=e[7],u=e[8]),Z.useEffect(l,u),null};function Fo(e){return e.available}function Io(e){return e.runtimeType}function Lo(e){return e.info?.version}function Ro(e){return e.info?.downloadUrl}function zo(e){return e.info?.inAppApply===!0}var Bo=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Vo=e=>e.enabled&&!e.alreadyChecked,Ho=`mobile-ota-update-available`,Uo=`mobile-ota-update-toast-dismissed-version`,Wo=()=>{let e=(0,Q.c)(24),{t}=Ee(),[n,r]=Z.useState(!1),i=Z.useRef(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,e[0]=a):a=e[0];let o=Z.useRef(a),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=g(),e[1]=s):s=e[1];let c=s,l=ci(Go),u=ci(Ko),d=ci(qo),f=ci(Jo),p=ci(Yo),m=ci(Xo),h=ci(Zo),_=ci(Qo),v=ci($o),y=d?.version,b=d?.inAppApply===!0,x,S;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{Vo({enabled:c,alreadyChecked:i.current})&&(i.current=!0,ci.getState().checkForUpdates().catch(es))},S=[c],e[2]=x,e[3]=S):(x=e[2],S=e[3]),Z.useEffect(x,S);let C;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{r(!0)},e[4]=C):C=e[4];let w=K(C),T=K(ts),E,D;if(e[5]!==l||e[6]!==T||e[7]!==b||e[8]!==w||e[9]!==u||e[10]!==t||e[11]!==y?(E=()=>{if(!Bo({enabled:c,runtimeType:u,available:l,inAppApply:b,version:y??``,dismissedVersion:A().getItem(Uo),seenVersions:o.current})||!y){(!l||!b||u!==`mobile`)&&Y.dismiss(Ho);return}o.current.add(y),Y.info(t(`mobileUpdate.ota.toast.available.title`),{id:Ho,description:t(`mobileUpdate.ota.toast.available.description`,{version:y}),duration:1/0,icon:(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.ota.toast.actions.update`),onClick:w},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{T(y)}}})},D=[l,b,c,w,T,u,t,y],e[5]=l,e[6]=T,e[7]=b,e[8]=w,e[9]=u,e[10]=t,e[11]=y,e[12]=E,e[13]=D):(E=e[12],D=e[13]),Z.useEffect(E,D),!c)return null;let O;return e[14]!==n||e[15]!==_||e[16]!==p||e[17]!==f||e[18]!==h||e[19]!==d||e[20]!==m||e[21]!==v||e[22]!==u?(O=(0,$.jsx)(ai,{open:n,onOpenChange:r,info:d,downloading:f,downloaded:p,progress:m,error:h,onDownload:_,onRestart:v,runtimeType:u}),e[14]=n,e[15]=_,e[16]=p,e[17]=f,e[18]=h,e[19]=d,e[20]=m,e[21]=v,e[22]=u,e[23]=O):O=e[23],O};function Go(e){return e.available}function Ko(e){return e.runtimeType}function qo(e){return e.info}function Jo(e){return e.downloading}function Yo(e){return e.downloaded}function Xo(e){return e.progress}function Zo(e){return e.error}function Qo(e){return e.downloadUpdate}function $o(e){return e.restartToUpdate}function es(){}function ts(e){A().setItem(Uo,e),Y.dismiss(Ho)}var ns=he(`BarcodeScanner`),rs=`yuri-barcode-scanner-active`,is=()=>ys()?ns:null,as=()=>window.Capacitor?.getPlatform?.()===`android`,os=e=>typeof e==`object`&&e&&`message`in e?String(e.message??``):String(e??``),ss=e=>/^\s*scan canceled\.?\s*$/i.test(os(e)),cs=e=>/denied access to camera/i.test(os(e)),ls=e=>!ss(e)&&!cs(e),us=e=>{let t=os(e);return/module/i.test(t)&&/not\s*available|unavailable/i.test(t)},ds=e=>{e.installGoogleBarcodeScannerModule?.().catch(()=>void 0)},fs=e=>{let t=e.trim();if(!t)return null;if(/^yuri:\/\//i.test(t)){let e=Va(t);return e?{pairing:e}:null}return/^https?:\/\//i.test(t)?{url:t}:null},ps=e=>{let t=fs(e);return t?`pairing`in t?{status:`pairing`,...t}:{status:`ok`,...t}:{status:`invalid`}},ms=e=>{typeof document>`u`||document.documentElement.classList.toggle(rs,e)},hs=e=>{try{e()}catch{}},gs=e=>{if(typeof document>`u`)return()=>void 0;let t=document.body,n=document.createElement(`button`);n.type=`button`,n.className=`yuri-barcode-scanner-chrome`,n.setAttribute(`aria-label`,`Cancel`),n.textContent=`×`,n.addEventListener(`click`,e),t.appendChild(n);let r=!1;return()=>{r||(r=!0,n.removeEventListener(`click`,e),n.parentNode===t&&t.removeChild(n))}},_s=async e=>{if(!e.startScan||!e.stopScan||!e.addListener)return{status:`unsupported`};let t,n,r,i=!1,a=()=>void 0,o=new Promise(e=>{a=e}),s=e=>{i||(i=!0,a(e))};ms(!0);let c=gs(()=>s({status:`cancelled`}));try{let{App:e}=await ge(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),t=await e.addListener(`backButton`,()=>s({status:`cancelled`}));r=()=>void t.remove()}catch{r=void 0}try{return(await Promise.allSettled([Promise.resolve(e.addListener(`barcodesScanned`,({barcodes:e})=>{let t=e?.[0],n=(t?.rawValue??t?.displayValue??``).trim();n&&s(ps(n))})).then(e=>{t=e}),Promise.resolve(e.addListener(`scanError`,()=>s({status:`failed`}))).then(e=>{n=e})])).some(({status:e})=>e===`rejected`)?s({status:`failed`}):i||e.startScan({formats:[`QR_CODE`]}).catch(e=>{cs(e)?s({status:`permission-denied`}):s({status:`failed`})}),await o}finally{ms(!1),hs(c),hs(()=>r?.()),await Promise.allSettled([Promise.resolve(t?.remove()),Promise.resolve(n?.remove()),e.stopScan()])}},vs=e=>e.isNativePlatform&&e.isPluginAvailable,ys=()=>vs({isNativePlatform:q.isNativePlatform(),isPluginAvailable:q.isPluginAvailable(`BarcodeScanner`)}),bs=async()=>{let e=is();if(!e)return{status:`unsupported`};try{if(e.requestPermissions){let t=(await e.requestPermissions())?.camera;if(t&&t!==`granted`&&t!==`limited`)return{status:`permission-denied`}}if(e.scan)try{let t=(await e.scan({formats:[`QR_CODE`]}))?.barcodes?.[0],n=(t?.rawValue??t?.displayValue??``).trim();return n?ps(n):{status:`cancelled`}}catch(t){return ss(t)?{status:`cancelled`}:cs(t)?{status:`permission-denied`}:as()&&ls(t)&&e.startScan?(us(t)&&ds(e),_s(e)):{status:`failed`}}return as()&&e.startScan?_s(e):{status:`unsupported`}}catch{return{status:`failed`}}},xs={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},Ss=({disabled:e=!1,isBusy:t=!1,tabIndex:n,inputClassName:r,buttonVariant:i=`outline`,buttonClassName:a=`h-12 w-full`,value:o,onValueChange:s,showPasteButton:c=!1,error:l,onRedeem:u,onInvalid:d})=>{let{t:f}=Ee(),[p,m]=Z.useState(``),[h,g]=Z.useState(null),[_,v]=Z.useState(!1),y=o??p,b=Z.useId(),x=e=>{g(null),m(e),s?.(e)},S=K(async()=>{if(!(e||t||_)){v(!0);try{let e=await navigator.clipboard.readText();x(e);let t=fs(e);e.trim()&&(!t||!(`pairing`in t))&&d()}catch{g(f(`mobile.connect.link.pasteFallback`))}finally{v(!1)}}}),C=K(n=>{if(n.preventDefault(),e||t||_)return;let r=fs(y);if(!r||!(`pairing`in r)){d();return}u(r.pairing)});return(0,$.jsxs)(`form`,{className:`flex w-full flex-col gap-3`,onSubmit:C,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Kn,{...xs,value:y,onChange:e=>x(e.target.value),placeholder:f(`mobile.connect.link.placeholder`),"aria-label":f(`mobile.connect.link.label`),inputMode:`url`,autoCapitalize:`none`,tabIndex:n,disabled:e||t||_,"aria-invalid":!!l,"aria-describedby":l||h?b:void 0,className:r}),c?(0,$.jsx)(J,{variant:`outline`,size:`icon`,onClick:()=>void S(),disabled:e||t||_,"aria-label":f(`mobile.connect.link.paste`),children:(0,$.jsx)(X,{name:`clipboard`,className:`size-5`})}):null]}),l||h?(0,$.jsx)(`p`,{id:b,role:`alert`,className:`typography-small text-[var(--status-error)]`,children:l||h}):null,(0,$.jsx)(J,{type:`submit`,variant:i,size:`lg`,className:a,disabled:e||t||_||!y.trim(),children:f(t?`mobile.connect.connecting`:`mobile.connect.connectButton`)})]})};function Cs({connection:e}){let{t}=Ee(),{connections:n,isBusy:r,error:i,pendingConnection:a}=e,o=Z.useMemo(()=>ys(),[]),[s,c]=Z.useState(null),[l,u]=Z.useState(!1),[d,f]=Z.useState(null),[p,m]=Z.useState(!1),[h,_]=Z.useState(null),[v,y]=Z.useState(null),[b,x]=Z.useState(``),[S,C]=Z.useState(``),[w,T]=Z.useState(``),E=n[0],D=n.find(e=>e.id===v),O=r||p,k=s!==null||a!==null,A=t=>{e.setError(null),c(t)},j=()=>{e.setError(null),c(null),u(!0)},M=K(()=>{O||(a?(e.cancelPassword(),C(``)):A(null))}),N=K(async t=>{O||(_(t.id),C(``),await e.connect({id:t.id,candidates:t.candidates,label:t.label}))}),P=K(async()=>{if(!O){_(null),m(!0),e.setError(null);try{let n=await bs();n.status===`ok`?await e.connect({url:n.url,label:n.label,clientToken:n.clientToken}):n.status===`pairing`?await e.redeemPairingConnection(n.pairing):n.status===`permission-denied`?e.setError(t(`mobile.connect.scan.permissionDenied`)):n.status===`invalid`?e.setError(t(`mobile.connect.scan.invalid`)):n.status===`unsupported`?e.setError(t(`mobile.connect.scan.unsupported`)):n.status===`failed`&&e.setError(t(`mobile.connect.scan.failed`))}catch{e.setError(t(`mobile.connect.scan.failed`))}finally{m(!1)}}}),F=K(()=>d?(f(null),!0):k?(M(),!0):l?(u(!1),!0):!1);Z.useEffect(()=>{if(!g())return;let e=!1,t;return ge(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])).then(async({App:n})=>{let r=await n.addListener(`backButton`,()=>{F()||n.minimizeApp().catch(()=>void 0)});e?r.remove():t=()=>{r.remove()}}).catch(()=>void 0),()=>{e=!0,t?.()}},[F]);let I=e=>h===e.id&&r&&!a&&s!==`rename`&&s!==`remove`?t(`mobile.connect.connecting`):e.id===E?.id&&e.lastUsedAt>0?t(`mobile.connect.history.lastUsed`):t(`mobile.instances.status.saved`),L=e=>(0,$.jsxs)(J,{size:`lg`,variant:e?`default`:`ghost`,className:e?`yuri-welcome-primary w-full`:`w-full`,disabled:O,onClick:()=>void P(),children:[(0,$.jsx)(X,{name:p?`loader-4`:`scan-2`,className:p?`size-5 animate-spin motion-reduce:animate-none`:`size-5`}),t(`mobile.connect.scanQr`)]}),R=t(a?a.reason===`pairing`?`mobile.connect.pairing.expired`:`mobile.connect.password.label`:s===`rename`?`mobile.connect.history.rename`:s===`remove`?`mobile.connect.history.remove`:`mobile.connect.welcome.moreOptions`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`main`,{className:`yuri-keyboard-fill-screen yuri-mobile-welcome`,inert:k||l,"aria-hidden":k||l||void 0,"data-welcome-paused":k||l||p?`true`:void 0,children:[(0,$.jsx)(`header`,{className:`yuri-welcome-brand`,children:(0,$.jsx)(La,{className:`block`,width:88})}),(0,$.jsxs)(`div`,{className:`yuri-welcome-content`,children:[(0,$.jsxs)(`div`,{className:`yuri-welcome-intro`,children:[(0,$.jsxs)(`div`,{className:`yuri-welcome-art`,"aria-hidden":`true`,children:[(0,$.jsx)(`span`,{className:`yuri-image-loading yuri-welcome-dots`}),(0,$.jsx)(`div`,{className:`yuri-welcome-logo`,children:(0,$.jsx)(or,{width:144,height:144,className:`size-full`})})]}),(0,$.jsxs)(`div`,{className:`yuri-welcome-copy`,children:[(0,$.jsx)(`h1`,{children:t(E?`mobile.connect.history.welcomeBack`:`mobile.connect.welcome.heading`)}),(0,$.jsx)(`p`,{children:t(`mobile.connect.welcome.pairingHint`)})]})]}),(0,$.jsxs)(`div`,{className:`yuri-welcome-actions flex w-full flex-col gap-3`,children:[E?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(J,{variant:`outline`,className:`yuri-welcome-device`,disabled:O,onClick:j,children:[(0,$.jsx)(X,{name:`computer`,className:`size-7`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 text-left`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label`,children:E.label}),(0,$.jsx)(`span`,{className:`block typography-small font-normal text-muted-foreground`,children:I(E)})]}),(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-5 text-muted-foreground`})]}),(0,$.jsx)(J,{size:`lg`,className:`yuri-welcome-primary w-full`,disabled:O,onClick:()=>void N(E),children:r&&h===E.id?t(`mobile.connect.connecting`):i&&h===E.id?t(`desktopHostSwitcher.actions.retry`):t(`mobile.connect.history.continue`)})]}):null,o?L(!E):E?null:(0,$.jsx)(J,{size:`lg`,className:`yuri-welcome-primary w-full`,disabled:O,onClick:()=>A(`more`),children:t(`mobile.connect.link.useLink`)}),i&&!k&&!l?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,(0,$.jsx)(J,{variant:`ghost`,size:`lg`,disabled:O,className:`mx-auto text-muted-foreground`,onClick:()=>A(`more`),children:t(`mobile.connect.welcome.moreOptions`)})]})]})]}),(0,$.jsxs)(yr,{id:`welcome-history`,open:l,onOpenChange:u,presentation:`page`,edge:`right`,dismissGesture:!0,ariaLabel:t(`mobile.connect.history.title`),children:[(0,$.jsx)(Be,{title:t(`mobile.connect.history.title`),backAriaLabel:t(`header.actions.backAria`),onBack:()=>u(!1)}),(0,$.jsxs)(Gr,{outerClassName:`flex-1`,className:`px-6 py-6`,disableHorizontal:!0,children:[(0,$.jsx)(`h1`,{className:`typography-h1 mb-3`,children:t(`mobile.connect.history.title`)}),(0,$.jsx)(`p`,{className:`mb-6 typography-ui-label font-normal text-muted-foreground`,children:t(n.length?`mobile.connect.history.description`:`mobile.connect.saved.empty`)}),n.map(e=>(0,$.jsx)(`div`,{className:`border-b border-border/60 py-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(J,{variant:`ghost`,className:`yuri-welcome-history-row min-w-0 flex-1`,disabled:O,onClick:()=>void N(e),children:[(0,$.jsx)(X,{name:r&&h===e.id&&!k?`loader-4`:`computer`,className:r&&h===e.id&&!k?`size-7 animate-spin motion-reduce:animate-none`:`size-7`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 text-left`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label`,children:e.label}),(0,$.jsx)(`span`,{className:`block typography-small font-normal text-muted-foreground`,children:I(e)})]})]}),i&&h===e.id&&!k&&!r?(0,$.jsx)(J,{variant:`ghost`,size:`icon`,disabled:O,"aria-label":t(`desktopHostSwitcher.actions.retry`),onClick:()=>void N(e),children:(0,$.jsx)(X,{name:`error-warning-fill`,className:`size-5 text-[var(--status-error)]`})}):null,(0,$.jsxs)(Qn,{open:d===e.id,onOpenChange:t=>f(t?e.id:null),children:[(0,$.jsx)(nr,{asChild:!0,children:(0,$.jsx)(J,{variant:`ghost`,size:`icon`,disabled:O,"aria-label":t(`mobile.connect.history.actions`,{name:e.label}),children:(0,$.jsx)(X,{name:`more`,className:`size-5`})})}),(0,$.jsxs)($n,{align:`end`,children:[(0,$.jsxs)(ar,{onSelect:()=>{y(e.id),x(e.label),A(`rename`)},children:[(0,$.jsx)(X,{name:`edit`,className:`size-4`}),t(`mobile.connect.history.rename`)]}),(0,$.jsxs)(ar,{onSelect:()=>{y(e.id),A(`remove`)},className:`text-[var(--status-error)]`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-4 text-inherit`}),t(`mobile.connect.history.remove`)]})]})]})]})},e.id)),i&&!h&&!k?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null]}),(0,$.jsxs)(`div`,{className:`yuri-welcome-history-footer`,children:[(0,$.jsx)(or,{width:36,height:36,className:`mx-auto mb-5 opacity-40`}),o?L(!1):null,(0,$.jsx)(J,{variant:`ghost`,size:`lg`,className:`w-full`,disabled:O,onClick:()=>A(`more`),children:t(`mobile.connect.link.useLink`)})]})]}),(0,$.jsx)(br,{id:`welcome-options`,open:k,onOpenChange:e=>{e||M()},fitContent:!0,title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:R}),ariaLabel:R,closeAriaLabel:t(`mobile.surface.closeAria`),resizeAriaLabel:t(`mobile.connect.options.resize`),children:(0,$.jsx)(Gr,{className:`px-5 py-5`,disableHorizontal:!0,fillContainer:!1,children:a?.reason===`pairing`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(X,{name:`computer`,className:`size-6 shrink-0 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`min-w-0 flex-1 truncate typography-ui-label`,children:a.label}),n.some(e=>e.id===a.id)?(0,$.jsx)(J,{variant:`ghost`,size:`icon`,disabled:O,"aria-label":t(`mobile.instances.deleteAria`,{label:a.label}),onClick:()=>{y(a.id),e.cancelPassword(),A(`remove`)},children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-5`})}):null]}),(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.pairing.reconnectHint`)}),i?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,o?L(!0):null,(0,$.jsx)(J,{variant:o?`ghost`:`default`,size:`lg`,disabled:O,onClick:()=>{e.cancelPassword(),A(`more`)},children:t(`mobile.connect.link.useLink`)})]}):a?(0,$.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),r||e.submitPassword(S)},children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label`,children:a.label}),(0,$.jsx)(Kn,{type:`password`,autoComplete:`current-password`,value:S,onChange:e=>C(e.target.value),"aria-label":t(`mobile.connect.password.label`),placeholder:t(`mobile.connect.password.placeholder`),disabled:r}),i?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,(0,$.jsx)(J,{type:`submit`,size:`lg`,className:`yuri-welcome-primary w-full`,disabled:r||!S.trim(),children:t(r?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(J,{variant:`ghost`,disabled:r,onClick:M,children:t(`mobile.connect.cancelPassword`)})]}):s===`rename`&&D?(0,$.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e.renameConnection(D.id,b).then(e=>{e&&c(null)})},children:[(0,$.jsx)(Kn,{value:b,onChange:e=>x(e.target.value),disabled:r,"aria-label":t(`mobile.instances.label.label`),autoComplete:`off`,maxLength:120}),i?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,(0,$.jsx)(J,{type:`submit`,size:`lg`,disabled:r||!b.trim(),children:t(`mobile.instances.saveEdit`)})]}):s===`remove`&&D?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-normal`,children:t(`mobile.connect.history.removeHint`,{name:D.label})}),i?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,(0,$.jsx)(J,{variant:`destructive`,size:`lg`,disabled:r,onClick:()=>{e.removeConnection(D.id).then(e=>{e&&(c(null),_(null))})},children:t(`mobile.connect.history.remove`)}),(0,$.jsx)(J,{variant:`ghost`,disabled:r,onClick:M,children:t(`mobile.instances.cancelEdit`)})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`typography-ui-header mb-2`,children:t(`mobile.connect.link.useLink`)}),(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.link.help`)})]}),(0,$.jsx)(Ss,{value:w,onValueChange:t=>{T(t),e.setError(null)},showPasteButton:!0,inputClassName:`min-w-0 flex-1 text-[16px]`,buttonClassName:`yuri-welcome-primary w-full`,buttonVariant:`default`,disabled:O,isBusy:r,error:i,onInvalid:()=>e.setError(t(`mobile.connect.link.invalid`)),onRedeem:t=>{_(null),e.redeemPairingConnection(t)}}),(0,$.jsxs)(J,{variant:`outline`,className:`yuri-welcome-history-row`,disabled:O,onClick:j,children:[(0,$.jsx)(X,{name:`history`,className:`size-6`}),(0,$.jsx)(`span`,{className:`flex-1 text-left`,children:t(`mobile.connect.history.title`)}),(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-5`})]}),(0,$.jsx)(`p`,{className:`typography-small leading-relaxed text-muted-foreground`,children:t(`mobile.connect.welcome.scanHint`)})]})})})]})}function ws(e){let t=(0,Q.c)(17),{children:n}=e,r=_e(Ds),i=_e(Es),a=Z.useRef(null),o=Z.useRef(null),s;t[0]===i?s=t[1]:(s=()=>i(!1),t[0]=i,t[1]=s);let c;t[2]!==r||t[3]!==s?(c={id:`mobile-global-search`,active:r,onBack:s,surfaceRef:a,underlayRef:o},t[2]=r,t[3]=s,t[4]=c):c=t[4],Nr(c);let l,u;t[5]===r?(l=t[6],u=t[7]):(l=()=>{if(!r)return;let e=document.activeElement,t=zn(`global-search-page`);return()=>{t(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},u=[r],t[5]=r,t[6]=l,t[7]=u),Z.useLayoutEffect(l,u);let d=r||void 0,f=r||void 0,p;t[8]!==n||t[9]!==d||t[10]!==f?(p=(0,$.jsx)(`div`,{ref:o,inert:d,"aria-hidden":f,className:`h-full min-h-0 w-full`,children:n}),t[8]=n,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===r?m=t[13]:(m=r?(0,$.jsx)(`div`,{ref:a,"data-mobile-search-page":`true`,className:`absolute inset-0 z-50 flex min-h-0 flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(Ia,{presentation:`page`,onBack:Ts})}):null,t[12]=r,t[13]=m);let h;return t[14]!==p||t[15]!==m?(h=(0,$.jsxs)(`div`,{className:`relative isolate flex h-[100dvh] min-h-0 w-full flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:[p,m]}),t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function Ts(){Ir.requestAnimatedBack(`root`)}function Es(e){return e.setCommandPaletteOpen}function Ds(e){return e.isCommandPaletteOpen}async function Os(e,t,n,i){if(i){let r=await Ya(i,e,n);if(!ve(e))return r;if(!t)throw Error(`unsupported_host`);let a=new URL(r.src,`http://runtime.invalid`);return{...r,src:`${t}${a.pathname}${a.search}${a.hash}`}}let a=d(),o=()=>{if(n.aborted||a!==d())throw new DOMException(`Preview ended`,`AbortError`)};o();let s=new URL(e);if(![`http:`,`https:`].includes(s.protocol)||s.username||s.password)throw Error(`invalid_url`);if(!ve(e))return{src:s.href};if(!t)throw Error(`unsupported_host`);let l=await m(`/api/preview/targets`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:s.href}),signal:n});if(!l.ok)throw Error(`preview_unavailable`);let u=await l.json();if(o(),typeof u.proxyBasePath!=`string`||!/^\/api\/preview\/proxy\/[a-f0-9]{16,64}$/i.test(u.proxyBasePath)||!Ja(`${u.proxyBasePath}${s.pathname}`)||typeof u.previewToken!=`string`||!u.previewToken||typeof u.expiresAt!=`number`||!Number.isFinite(u.expiresAt)||u.expiresAt<=Date.now())throw Error(`invalid_preview`);await r(),o();let f=new URLSearchParams(s.search);f.delete(`yuri_client_token`),f.delete(`yuri_url_token`),f.set(`yuri_preview_token`,u.previewToken);let p=`${u.proxyBasePath}${s.pathname}?${f}${s.hash}`,h=new URL(c().authenticatedAsset(p),`http://runtime.invalid`);return{src:`${t}${h.pathname}${h.search}${h.hash}`,expiresAt:u.expiresAt}}function ks({url:e,hostOrigin:t,entry:n}){let{t:r}=Ee(),i=Z.useRef(null),[s,c]=Z.useReducer(e=>e+1,0),l=n?JSON.stringify(n.queryScope):`local`,[u,d]=Z.useState();Z.useEffect(()=>{let r=new AbortController,i,c=0,u=async()=>{let a=++c;clearTimeout(i);try{let o=await Os(e,t,r.signal,n);if(r.signal.aborted||a!==c)return;d({url:e,hostOrigin:t,scope:l,attempt:s,src:o.src}),o.expiresAt&&(i=setTimeout(()=>{u()},Math.max(1e3,o.expiresAt-Date.now()-1e4)))}catch{!r.signal.aborted&&a===c&&d({url:e,hostOrigin:t,scope:l,attempt:s,error:!0})}},f=ve(e),p=f?a():void 0,m=f?o(()=>{u()}):void 0;return u(),()=>{r.abort(),clearTimeout(i),m?.(),p?.()}},[e,t,s,n,l]);let f=u?.url===e&&u.hostOrigin===t&&u.scope===l&&u.attempt===s?u:void 0;return G(`message`,t=>{if(!f?.src||!ve(e)||t.source!==i.current?.contentWindow||t.origin!==new URL(f.src).origin)return;let r=t.data;r?.source===`yuri-preview-bridge`&&r.version===1&&r.type===`navigate-preview`&&typeof r.url==`string`&&xe.getState().open(r.url,n?.location)}),f?.error?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3`,children:[(0,$.jsx)(Ka,{message:r(`contextPanel.preview.proxyError`)}),(0,$.jsx)(J,{size:`sm`,onClick:c,children:r(`contextPanel.preview.actions.retry`)})]}):f?.src?(0,$.jsx)(`iframe`,{ref:i,src:f.src,title:r(`contextPanel.preview.iframeTitle`),onError:()=>d({url:e,hostOrigin:t,scope:l,attempt:s,error:!0}),className:`h-full w-full border-0`,sandbox:`allow-scripts allow-same-origin allow-forms`}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:r(`contextPanel.preview.loading`)})}function As(e){let t=(0,Q.c)(10),{location:n,url:r,hostOrigin:i}=e,{t:a}=Ee(),o=Xt(!0);if(!o.registry||o.registry.hubId!==n.hubId){let e;return t[0]!==o.error||t[1]!==a?(e=o.error?(0,$.jsx)(Ka,{message:o.error.message}):(0,$.jsx)(`div`,{className:`text-muted-foreground`,children:a(`contextPanel.preview.loading`)}),t[0]=o.error,t[1]=a,t[2]=e):e=t[2],e}let s;t[3]!==n||t[4]!==o.registry?(s=o.registry.resolve(n),t[3]=n,t[4]=o.registry,t[5]=s):s=t[5];let c;return t[6]!==i||t[7]!==s||t[8]!==r?(c=(0,$.jsx)(ks,{url:r,hostOrigin:i,entry:s}),t[6]=i,t[7]=s,t[8]=r,t[9]=c):c=t[9],c}function js(){let e=(0,Q.c)(17),{t}=Ee(),n=xe(Ns),r=U(),i=Z.useSyncExternalStore(s,d,d),a=n?.generation===i?n:null,o=!!a,c;e[0]===t?c=e[1]:(c=t(`contextPanel.preview.iframeTitle`),e[0]=t,e[1]=c);let l;e[2]===t?l=e[3]:(l=t(`guiPlugins.close`),e[2]=t,e[3]=l);let u;e[4]===t?u=e[5]:(u=t(`guiPlugins.resize`),e[4]=t,e[5]=u);let f=a?.url??``,p;e[6]!==a||e[7]!==i||e[8]!==r?(p=a?(0,$.jsx)(qa,{children:e=>a.location?.hostId?r?.entry.location.hubId===a.location.hubId&&r.entry.location.hostId===a.location.hostId&&r.entry.location.directory===a.location.directory?(0,$.jsx)(ks,{url:a.url,hostOrigin:e?.hostOrigin,entry:r.entry}):(0,$.jsx)(As,{location:a.location,url:a.url,hostOrigin:e?.hostOrigin}):(0,$.jsx)(ks,{url:a.url,hostOrigin:e?.hostOrigin})},i):null,e[6]=a,e[7]=i,e[8]=r,e[9]=p):p=e[9];let m;return e[10]!==o||e[11]!==c||e[12]!==l||e[13]!==u||e[14]!==f||e[15]!==p?(m=(0,$.jsx)(br,{id:`mobile-html-preview`,open:o,ariaLabel:c,closeAriaLabel:l,resizeAriaLabel:u,initiallyExpanded:!0,title:f,onOpenChange:Ms,children:p}),e[10]=o,e[11]=c,e[12]=l,e[13]=u,e[14]=f,e[15]=p,e[16]=m):m=e[16],m}function Ms(e){e||xe.getState().close()}function Ns(e){return e.target}function Ps(){let e=st(e=>e.projects.find(t=>t.id===e.activeProjectId)),t=ct(e=>e.remoteSession),n=!!e?.hostId,r=qt(),i=Xt(n&&r),a=r&&i.catalog?.supported!==!1,o=Z.useMemo(()=>e?.hubId&&e.hostId?{supported:!0,hubId:e.hubId,projects:[],hosts:[{id:e.hostId,name:e.hostId,source:`direct`,state:`offline`}]}:void 0,[e?.hubId,e?.hostId]),s=n&&a?i.registry??(o?Yt(o):void 0):void 0,c=e?.hostId,l=Z.useMemo(()=>e=>s&&c?s.subscribeHost(c,e):()=>{},[s,c]),u=Z.useMemo(()=>()=>s&&c?s.getHost(c):void 0,[s,c]),d=Z.useSyncExternalStore(l,u,u),f=t?.projectId===e?.id&&t?.location.hostId===c&&t?.location.hubId===(e?.hubId??s?.hubId),p=Z.useMemo(()=>s&&c&&e&&(!e.hubId||s.hubId===e.hubId)?{hubId:s.hubId,hostId:c,directory:f&&t?t.location.directory:e.path}:void 0,[s,c,e,f,t]),m=p&&s?s.resolve(p):void 0,[h,g]=Z.useState();Z.useEffect(()=>{if(!s||!m)return;let e=xt(s,m),t=e.retain();return g({entry:m,owner:e}),t},[s,m]);let _=h?.entry===m?h?.owner:void 0,y=f?t?.sessionId??null:null,b=Z.useMemo(()=>e=>_?_.state.subscribeSnapshot(e):()=>{},[_]),x=Z.useMemo(()=>()=>_&&y?_.state.getSnapshot(y).session:void 0,[_,y]),S=Z.useSyncExternalStore(b,x,x),C=Zt(s,c,n&&a);return{enabled:n,supported:a,project:e,registry:s,entry:m,owner:_,sessionId:y,session:S??C.data?.directories.find(e=>e.directory===p?.directory)?.sessions.find(e=>e.id===y),host:d,openSession:K(t=>{if(!e?.hostId||!p)throw Error(`Remote Host scope unavailable`);ct.getState().openRemoteSession(e,p,t)}),refresh:K(async()=>{if(!_||!y)throw Error(`Remote session unavailable`);await _.state.repository.refreshFromAuthority(_.state.scope(y))}),key:p?v(p):e?.id??``,error:i.error}}var Fs=e=>{let t=(0,Q.c)(20),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({children:n,className:r,contentClassName:i,style:o,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=it(`yuri-mobile-header relative z-30 shrink-0 border-b border-border/30 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80`,r),t[6]=r,t[7]=s);let c;t[8]===o?c=t[9]:(c={paddingTop:`var(--yuri-safe-area-top, 0px)`,...o},t[8]=o,t[9]=c);let l;t[10]===i?l=t[11]:(l=it(`flex h-[var(--yuri-header-height,56px)] w-full items-center gap-1 px-2`,i),t[10]=i,t[11]=l);let u;t[12]!==n||t[13]!==l?(u=(0,$.jsx)(`div`,{className:l,children:n}),t[12]=n,t[13]=l,t[14]=u):u=t[14];let d;return t[15]!==a||t[16]!==s||t[17]!==c||t[18]!==u?(d=(0,$.jsx)(`header`,{className:s,style:c,...a,children:u}),t[15]=a,t[16]=s,t[17]=c,t[18]=u,t[19]=d):d=t[19],d};function Is(e){let t=(0,Q.c)(30),{percentage:n,pending:r}=e,i=r!==void 0&&r,{t:a}=Ee(),o,s,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==n||t[2]!==a){c=i?0:Zn(n)??0;let e=er(n);s=i?`var(--surface-muted-foreground)`:e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,o=2*Math.PI*7.5,l=`0 0 18 18`,u=`size-[18px] -rotate-90`,d=`progressbar`,t[12]===a?f=t[13]:(f=a(`contextUsage.aria.label`),t[12]=a,t[13]=f),t[14]!==i||t[15]!==a?(p=i?a(`contextUsage.pending`):void 0,t[14]=i,t[15]=a,t[16]=p):p=t[16],m=i?void 0:Math.round(c),t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m}else o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11];let h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[17]=h):h=t[17];let g=o*(1-c/100),_;t[18]!==o||t[19]!==s||t[20]!==g?(_=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:s,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:o,strokeDashoffset:g,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[18]=o,t[19]=s,t[20]=g,t[21]=_):_=t[21];let v;return t[22]!==_||t[23]!==l||t[24]!==u||t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m?(v=(0,$.jsxs)(`svg`,{viewBox:l,className:u,role:d,"aria-label":f,"aria-valuetext":p,"aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:[h,_]}),t[22]=_,t[23]=l,t[24]=u,t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=v):v=t[29],v}var Ls=(e,t,n)=>ne({queryKey:[...e.queryScope,`mobile-session-metadata`,t],staleTime:3e4,gcTime:1/0,retry:!1,queryFn:({signal:e})=>n(e)});function Rs(e){let t=W(e);return Ls(e,`git`,async n=>{let r={signal:n,query:{directory:e.location.directory},headers:{"x-opencode-directory":e.location.directory}};return(await t.json(`/api/git/check`,r)).isGitRepository?{isGitRepository:!0,current:(await t.json(`/api/git/status`,{...r,query:{...r.query,mode:`light`}})).current}:{isGitRepository:!1,current:null}})}function zs(e){let t=W(e);return Ls(e,`quota-settings`,async e=>{let n=await t.json(`/api/config/settings`,{signal:e}),r=ri.map(e=>e.id),i=Array.isArray(n.usageDropdownProviders)?n.usageDropdownProviders.filter(e=>typeof e==`string`&&(e.startsWith(`magpie:`)||r.includes(e))):r,a={};if(n.usageSelectedModels&&typeof n.usageSelectedModels==`object`)for(let[e,t]of Object.entries(n.usageSelectedModels))Array.isArray(t)&&(a[e]=t.filter(e=>typeof e==`string`));return{providerIds:i,selectedModels:a,displayMode:n.usageDisplayMode===`remaining`?`remaining`:`usage`,autoRefresh:n.usageAutoRefresh===!0,refreshIntervalMs:typeof n.usageRefreshIntervalMs==`number`&&Number.isFinite(n.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(n.usageRefreshIntervalMs))):6e4}})}function Bs(e,t){let n=W(e);return Ls(e,`quota:${t}`,async e=>{let r=await n.json(`/api/quota/${encodeURIComponent(t)}`,{signal:e});if(!ae(r)||r.providerId!==t)throw Error(`Invalid quota response`);return r})}function Vs(e){let t=W(e);return Ls(e,`magpie`,async n=>{let r=await t.json(`/api/quota/magpie`,{signal:n,query:{directory:e.location.directory}});if(!Array.isArray(r.sources)||!r.sources.every(e=>e&&typeof e.id==`string`&&Array.isArray(e.results)&&e.results.every(t=>ae(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return r.sources.flatMap(e=>e.results)})}var Hs=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},Us=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),Ws=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,Gs=e=>{let{totalTokens:t,contextLimit:n,isDraft:r}=e;if(!r&&t===null)return{pending:!0,percentage:0,tokens:`—`,colorClass:`text-muted-foreground`};if(t===null||r||t<=0||n<=0)return null;let i=Math.min(t/n*100,999);return{percentage:i,tokens:`${Us(t)}/${Us(n)}`,colorClass:Ws(i)}},Ks=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`user`)continue;let r=typeof n.model?.providerID==`string`&&n.model.providerID.trim().length>0?n.model.providerID:void 0,i=typeof n.model?.modelID==`string`&&n.model.modelID.trim().length>0?n.model.modelID:void 0;if(r&&i)return{providerID:r,modelID:i}}return null},qs=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``);function Js(e,t,n){let r=(0,Q.c)(7),{t:i}=Ee(),a;if(r[0]!==t||r[1]!==e||r[2]!==n||r[3]!==i){let o=new Map(e.map(Ys)),s;r[5]===t?s=r[6]:(s=e=>t.includes(e.id),r[5]=t,r[6]=s),a=ui(e).filter(s).filter(e=>o.get(e.id)?.configured===!0).map(e=>{let t=o.get(e.id),r=[];for(let[e,n]of Ai(Object.entries(t?.usage?.windows??{}),t?.usage?.accounts))r.push({key:`window-${e}`,label:Yn(n.label??e),window:n});let a=Object.entries(t?.usage?.models??{}),s=n[e.id]??[];for(let[e,t]of s.length>0?a.filter(e=>{let[t]=e;return s.includes(t)}):a){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:Yn(a.label??i),subtitle:oi(e),window:a})}return{providerId:e.id,providerName:e.name,rows:r,status:!t.ok&&t.error?t.error:r.length===0?i(`header.services.noRateLimitsReported`):null}}),r[0]=t,r[1]=e,r[2]=n,r[3]=i,r[4]=a}else a=r[4];return a}function Ys(e){return[e?.providerId,e]}var Xs=e=>{let t=e.usedPercent;return typeof t!=`number`||!Number.isFinite(t)?`text-foreground`:t>=80?`text-[var(--status-error)]`:t>=50?`text-[var(--status-warning)]`:`text-foreground`},Zs=e=>{let t=(0,Q.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,$.jsx)(X,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},Qs=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=Ee(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Er,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,$.jsx)(`span`,{className:`min-w-0 max-w-[60%] truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map((t,n)=>{let i=Ei(e.rows.map(wc),n),o=r===`remaining`?t.window.remainingPercent:t.window.usedPercent,s=tr(t.window.valueLabel,o),c=Xn(t.window.resetAt,t.window.resetAfterFormatted??t.window.resetAtFormatted,a);return(0,$.jsxs)(Z.Fragment,{children:[i?(0,$.jsx)(`div`,{className:it(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-3 border-t border-[var(--surface-subtle)] pt-2`),children:i}):null,(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:t.subtitle?`${t.subtitle} · ${t.label}`:t.label}),c?(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-micro text-muted-foreground/70`,children:c}):null]}),(0,$.jsx)(`span`,{className:it(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,Xs(t.window)),children:s===`-`?``:s})]})]},t.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 truncate typography-micro text-muted-foreground`,title:e.status,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,$.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},$s=e=>{let t=(0,Q.c)(52),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l,error:u,onRetry:d}=e,{t:f}=Ee(),p=Z.useRef(null),[m,h]=Z.useState(n),[g,_]=Z.useState(!1),v,y;t[0]!==n||t[1]!==m?(v=()=>{if(n){h(!0),_(!1);return}if(!m)return;_(!0);let e=window.setTimeout(()=>{h(!1),_(!1)},140);return()=>window.clearTimeout(e)},y=[n,m],t[0]=n,t[1]=m,t[2]=v,t[3]=y):(v=t[2],y=t[3]),Z.useEffect(v,y);let b,x;if(t[4]!==r||t[5]!==n?(b=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},x=[r,n],t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),Z.useEffect(b,x),!m)return null;let S;t[8]===f?S=t[9]:(S=f(`mobile.surface.closeAria`),t[8]=f,t[9]=S);let C;t[10]===r?C=t[11]:(C=e=>{e.preventDefault(),r()},t[10]=r,t[11]=C);let w;t[12]!==S||t[13]!==C?(w=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":S,onPointerDown:C}),t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;t[15]===f?T=t[16]:(T=f(`mobile.header.openMetadataAria`),t[15]=f,t[16]=T);let E=g&&`pointer-events-none`,D;t[17]===E?D=t[18]:(D=it(`pointer-events-auto absolute inset-x-3 top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.5rem)] overflow-x-hidden overflow-y-auto overscroll-contain rounded-[20px] yuri-mobile-overlay-surface yuri-mobile-overlay-surface--translucent p-2 will-change-transform`,E),t[17]=E,t[18]=D);let O=`${g?`session-metadata-out`:`session-metadata-in`} ${g?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,k;t[19]===O?k=t[20]:(k={animation:O,maxHeight:`min(72dvh, calc(100dvh - var(--yuri-safe-area-top, 0px) - var(--yuri-mobile-detail-navigation-height, 3.5rem) - 1rem))`},t[19]=O,t[20]=k);let A;t[21]===f?A=t[22]:(A=f(`mobile.header.metadata.branch`),t[21]=f,t[22]=A);let j;t[23]!==a||t[24]!==A?(j=(0,$.jsx)(Zs,{iconName:`git-branch`,label:A,children:a}),t[23]=a,t[24]=A,t[25]=j):j=t[25];let M;t[26]!==i||t[27]!==f?(M=i?(0,$.jsx)(Zs,{iconNode:(0,$.jsx)(Is,{percentage:i.percentage,pending:i.pending}),label:f(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsx)(`span`,{className:it(`font-semibold`,i.colorClass),children:i.pending?f(`contextUsage.pending`):`${i.percentage.toFixed(1)}%`}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:i.tokens})]})}):null,t[26]=i,t[27]=f,t[28]=M):M=t[28];let N;t[29]!==c||t[30]!==l||t[31]!==s||t[32]!==o?(N=(0,$.jsx)(Qs,{groups:o,displayMode:s,isLoading:c,timeFormatPreference:l}),t[29]=c,t[30]=l,t[31]=s,t[32]=o,t[33]=N):N=t[33];let P;t[34]!==u||t[35]!==d||t[36]!==f?(P=u?(0,$.jsxs)(`div`,{role:`alert`,className:`px-2.5 py-2 typography-ui-label text-[var(--status-error)]`,children:[u,(0,$.jsx)(J,{variant:`ghost`,size:`sm`,onClick:d,children:f(`contextPanel.preview.actions.retry`)})]}):null,t[34]=u,t[35]=d,t[36]=f,t[37]=P):P=t[37];let F;t[38]!==j||t[39]!==M||t[40]!==N||t[41]!==P?(F=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[j,M,N,P]}),t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=F):F=t[42];let I;t[43]!==D||t[44]!==k||t[45]!==F||t[46]!==T?(I=(0,$.jsx)(`div`,{ref:p,role:`dialog`,"aria-label":T,className:D,style:k,onPointerDown:Tc,children:F}),t[43]=D,t[44]=k,t[45]=F,t[46]=T,t[47]=I):I=t[47];let L;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(`style`,{children:`
|
|
3
3
|
@keyframes session-metadata-in {
|
|
4
4
|
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
5
5
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
@@ -12,7 +12,7 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{S as t,_ as n,p as r,r
|
|
|
12
12
|
`)},nl=()=>{let e=0;for(let t of document.styleSheets)try{e+=t.cssRules.length}catch{}return`${document.styleSheets.length}:${e}`},rl=Hc,il=()=>new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e(1)))});function al(){let e=document.documentElement,t=window,n=!1,r=0,i=0,a=null,o=``,s=``,c=``,l=``,u=!1,d=!1,f=[],p=()=>{if(!a)return;let e=parseFloat(a.style.getPropertyValue(`--yuri-mobile-header-collapse`))||0,n=a.dataset.yuriHeaderCollapsePhase??`rest`,r=a.dataset.yuriHeaderCollapseRest??`expanded`,i=`${e}|${n}|${r}`;i!==l&&(l=i,t.YuriHeaderCollapse?t.YuriHeaderCollapse.set(e,n,r):t.webkit?.messageHandlers?.yuriHeaderCollapse?.postMessage({progress:e,phase:n,rest:r}))},m=()=>{e.classList.remove(Gc),u&&(u=!1,o=``,Hc.update({seq:++r,visible:!1}).catch(()=>void 0))},h=()=>{if(i=0,n)return;let t=el(a,d);if(t!==a){if(a?.classList.remove(Wc),m(),a=t,l=``,!t)return;t.classList.add(Wc),p()}if(!t)return;let f=window.devicePixelRatio||1,h=t.offsetHeight,g=parseFloat(getComputedStyle(t,`::after`).height)||0,_=Math.ceil(h*f),v=t.querySelector(Jc)===null?Math.ceil(Math.max(h,g)*f):_,y=(h+2*(parseFloat(getComputedStyle(e).fontSize)||16))*f,b=t.cloneNode(!0);b.classList.remove(Wc),b.style.removeProperty(ln),delete b.dataset.yuriHeaderCollapsePhase,delete b.dataset.yuriHeaderCollapseRest;for(let e of b.querySelectorAll(Jc))e.style.display=`none`;let x=b.outerHTML,S=[...e.classList].filter(e=>!Kc.has(e)).join(` `),C=(e.getAttribute(`style`)??``).replace(RegExp(`${qc}\\s*:[^;]*;?`,`g`),``),w=document.body.className,T=`${x}|${S}|${C}|${w}|${v}|${y}`,E=nl(),D=document.getElementById(`yuri-icon-sprite-v2`)?.outerHTML??``;if(T===o&&E===s&&D===c)return;o=T;let O={seq:++r,visible:!0,height:v,hitBottom:_,collapseDistance:y,html:x,rootClass:S,rootStyle:C,bodyClass:w};E!==s&&(s=E,O.css=tl()),D!==c&&(c=D,O.sprite=D),u=!0,Hc.update(O).catch(()=>void 0)},g=()=>{!i&&!n&&(i=requestAnimationFrame(h))};f.push(Hc.addListener(`shown`,t=>{d&&t.seq===r&&a&&e.classList.add(Gc)})),f.push(Hc.addListener(`tap`,e=>{if(!a||!d)return;let t=a;try{for(let n of JSON.parse(e.path))t=t?.children[n]??null}catch{return}let n=t?.closest(`button, a, [role="button"]`);if(!n||!a.contains(n))return;let r={bubbles:!0,cancelable:!0,pointerType:`touch`,isPrimary:!0};n.dispatchEvent(new PointerEvent(`pointerdown`,r)),n.dispatchEvent(new PointerEvent(`pointerup`,r)),n.click()}));let _=new MutationObserver(e=>{if(!a||!a.isConnected){g();return}let t=!1;for(let n of e){if(n.target===a&&n.type===`attributes`&&Yc.has(n.attributeName??``)){p();continue}let e=n.target instanceof Element?n.target:n.target.parentElement;if(!(e?.closest(Zc)&&a.contains(e))){if(a.contains(n.target)||n.type===`attributes`&&n.target.contains(a))t=!0;else if(n.type===`attributes`&&Qc.has(n.attributeName??``)&&n.target instanceof Element&&n.target.querySelector(Uc))t=!0;else if(n.type===`childList`)for(let e of n.addedNodes)e instanceof Element&&(e.matches(Uc)||e.querySelector(Uc))&&(t=!0)}}t&&g()});_.observe(document.body,{subtree:!0,childList:!0,attributes:!0,characterData:!0});let v=new MutationObserver(g);v.observe(e,{attributes:!0,attributeFilter:[`class`,`style`]});let y=new MutationObserver(g);y.observe(document.head,{childList:!0,subtree:!0,characterData:!0}),window.addEventListener(`resize`,g),g(),t.__yuriImeOffset=t=>(window.dispatchEvent(new Event(`yuri:keyboard-native-layout`)),e.style.setProperty(qc,`${Math.max(0,t)}px`),il());let b=window;return b.__yuriNativeHeader=t=>(d=t,e.classList.toggle(Gc,t&&a!==null),il()),()=>{n=!0,delete b.__yuriNativeHeader,i&&cancelAnimationFrame(i),_.disconnect(),v.disconnect(),y.disconnect(),window.removeEventListener(`resize`,g),delete t.__yuriImeOffset,e.classList.remove(Gc),a?.classList.remove(Wc),a=null;for(let e of f)e.then(e=>e.remove()).catch(()=>void 0);Hc.update({seq:++r,visible:!1}).catch(()=>void 0)}}var ol=`.yuri-mobile-composer`,sl=`[data-btw-composer]`;function cl(e,t){if(!e)return!1;let n=t;return!n||typeof n.closest!=`function`||!n.closest(sl)}function ll(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(ol)}function ul(e){return ll(e??null)}var dl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),fl=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},pl=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},ml=(e,t)=>t?`${e}\u0000staged`:e,hl=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=Ee(),{git:o,projectScope:s}=ti(),{generateCommitMessage:c,stageGitFile:l,stageGitFiles:u,unstageGitFile:d,unstageGitFiles:f}=Ji(),p=ni(),m=s?p??null:dl(p??null),h=Un(m||null),g=un(m||null),_=Tn(m||null),v=Dn(e=>e.setActiveDirectory),y=Dn(e=>e.ensureAll),b=Dn(e=>e.fetchStatus),x=Dn(e=>e.fetchBranches),S=Dn(e=>e.prefetchDiffs),C=Dn(e=>e.getDiff),w=Dn(e=>e.setDiff),[T,E]=Z.useState(()=>t?{type:`diff`,path:t,staged:n,targetLine:r}:{type:`list`}),D=Z.useRef(null);Z.useEffect(()=>{t&&E(e=>e.type===`diff`&&e.path===t&&e.staged===n&&e.targetLine===r?e:{type:`diff`,path:t,staged:n,targetLine:r})},[t,n,r]);let[O,k]=Z.useState(null),[A,j]=Z.useState(null),[M,N]=Z.useState(``),[P,F]=Z.useState(new Set),[I,L]=Z.useState(!1),[R,ee]=Z.useState(!1),[z,B]=Z.useState([]),[V,te]=Z.useState([]),[ne,re]=Z.useState([]),[H,ie]=Z.useState(null),[U,ae]=Z.useState({key:null,loading:!1,error:null,resolved:!1}),[oe,se]=Z.useState(0),ce=Z.useRef({key:null,generation:0}),[le,ue]=Z.useState(!1),de=Ni(h)&&!le,W=Z.useMemo(()=>{let e=h?.files??[];if(de)return[];let t=new Map;for(let n of e)t.set(n.path,n);return Array.from(t.values()).sort((e,t)=>e.path.localeCompare(t.path))},[h?.files,de]),fe=Z.useMemo(()=>W.filter(fl),[W]),G=Z.useMemo(()=>W.filter(pl),[W]),{deferredStagedCount:pe,deferredUnstagedCount:me}=Z.useMemo(()=>{if(!de||!h)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of h.files??[])fl(n)&&(e+=1),pl(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[de,h]),he=Z.useMemo(()=>{if(ne.length>0)return ne;let e=h?.tracking?.includes(`/`)?h.tracking.split(`/`)[0]:null;return e||H?[{name:e||`origin`,fetchUrl:H??``,pushUrl:H??``}]:[]},[H,ne,h?.tracking]),q=Z.useMemo(()=>e=>!m||T.type!==`diff`?null:e.directories.get(m)?.diffCache.get(ml(T.path,T.staged))??null,[m,T]),ge=Dn(q),_e=Z.useMemo(()=>T.type===`diff`?W.find(e=>e.path===T.path)??null:null,[W,T]),ve=T.type===`diff`&&m?`${m}\u0000${ml(T.path,T.staged)}`:null,ye=U.key===ve,be=!!(ve&&!ge&&(!ye||U.loading)),xe=ye?U.error:null,Se=!!(_e||ye&&U.resolved),Ce=K(async(e,t=!0)=>{try{await Promise.all([b(e,o),x(e,o)])}catch(e){t&&Y.error(e instanceof Error?e.message:a(`gitView.toast.refreshRepositoryFailed`))}}),we=K(async(e,t,n)=>{let r=()=>ce.current.key===t&&ce.current.generation===n;try{let[t,n]=await Promise.all([o.getRemotes(e).catch(()=>[]),o.getRemoteUrl?o.getRemoteUrl(e).catch(()=>null):Promise.resolve(null)]);if(!r())return;re(t),ie(n)}catch{if(!r())return;re([]),ie(null)}}),Te=K(e=>{if(e!==m)return{requestGeneration:null,promise:Promise.resolve()};let t=ce.current.generation+1;return ce.current={key:e,generation:t},{requestGeneration:t,promise:we(e,e,t)}});Z.useEffect(()=>{m&&(v(m),y(m,o))},[m,y,o,v]),Z.useEffect(()=>{if(!m){ce.current={key:null,generation:ce.current.generation+1},re([]),ie(null);return}let{requestGeneration:e,promise:t}=Te(m);return()=>{e!==null&&ce.current.key===m&&ce.current.generation===e&&(ce.current={key:m,generation:e+1})}},[m,o,Te]),Z.useEffect(()=>{if(!m||W.length===0)return;let e=Array.from(new Set([...fe.map(e=>e.path),...V,...W.slice(0,20).map(e=>e.path)])).filter(Boolean);if(e.length===0)return;let t=window.setTimeout(()=>{S(m,o,e,{maxFiles:40})},120);return()=>window.clearTimeout(t)},[W,m,o,S,fe,V]),Z.useEffect(()=>{if(T.type!==`diff`){ae({key:null,loading:!1,error:null,resolved:!1});return}let e=ml(T.path,T.staged);if(!m||!ve){ae({key:null,loading:!1,error:null,resolved:!1});return}if(C(m,e)){ae(e=>({key:ve,loading:!1,error:null,resolved:e.key===ve&&e.resolved||!!_e}));return}let t=!1;return ae({key:ve,loading:!0,error:null,resolved:!1}),o.getGitFileDiff(m,{path:T.path,staged:T.staged||void 0}).then(n=>{t||(w(m,e,{original:n.original??``,modified:n.modified??``,isBinary:n.isBinary}),ae(e=>e.key===ve?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||ae(t=>t.key===ve?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[ve,m,oe,C,o,T,_e,w]);let De=async(e,t)=>{if(!m)return;let n=m;k(e);try{let r=e=>{let t=`${e.name}/`,n=h?.tracking?.startsWith(t)?h.tracking.slice(t.length):void 0;return{remote:e.name,branch:n,rebase:!0}};if(e===`fetch`){if(!t)throw Error(a(`mobile.changes.noRemote`));await o.gitFetch(n,{remote:t.name}),Y.success(a(`gitView.toast.fetchedFromRemote`,{name:t.name}))}else if(e===`sync`){if(!t)throw Error(a(`mobile.changes.noRemote`));await o.gitFetch(n,{remote:t.name});let e=await o.getGitStatus(n);if((e.behind??0)>0){if((e.files?.length??0)>0){Y.error(a(`gitView.toast.commitOrStashBeforeSync`));return}await o.gitPull(n,r(t))}((await o.getGitStatus(n)).ahead??0)>0&&await o.gitPush(n),Y.success(a(`gitView.toast.alreadyUpToDate`))}await Ce(n,!1),await Te(n).promise}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{k(null)}},Oe=K(async(e,t)=>{if(!m||e.length===0)return;let n=m;try{t===`stage`?e.length>1?await u(n,e):await l(n,e[0]):e.length>1?await f(n,e):await d(n,e[0]),await Ce(n,!1)}catch(e){Y.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),ke=K((e,t=!1)=>{E({type:`diff`,path:e,staged:t,targetLine:null})}),Ae=K(()=>T.type===`diff`&&(E({type:`list`}),!0));Nr({id:`mobile-changes-diff`,active:T.type===`diff`&&!i,layer:`overlay`,onBack:Ae,surfaceRef:D});let je=K(async e=>{if(!m)return;let t=m;F(t=>new Set(t).add(e));try{await o.revertGitFile(t,e),Y.success(a(`gitView.toast.revertedFile`,{path:e})),await Ce(t,!1)}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{F(t=>{let n=new Set(t);return n.delete(e),n})}}),Me=K(async e=>{if(!m||e.length===0||I)return;let t=m,n=Array.from(new Set(e));L(!0),F(new Set(n));try{await Promise.all(n.map(e=>o.revertGitFile(t,e))),await Ce(t,!1),Y.success(n.length===1?a(`gitView.toast.revertedFilesSingle`,{count:n.length}):a(`gitView.toast.revertedFilesPlural`,{count:n.length}))}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{F(new Set),L(!1)}}),Ne=K(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){B([]);return}N(e=>`${e.trim()}${e.trim()?`
|
|
13
13
|
|
|
14
14
|
`:``}${t.join(`
|
|
15
|
-
`)}`.trim()),B([])}),Pe=K(async()=>{if(!m)return;let e=m,t=fe.map(e=>e.path).sort();if(t.length===0){Y.error(a(`gitView.toast.selectFileToDescribe`));return}ee(!0);try{let{message:n}=await c(e,t);N(n.subject?.trim()??``),B(Array.isArray(n.highlights)?n.highlights:[])}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.generateCommitMessageFailed`))}finally{ee(!1)}}),Fe=async(e={})=>{if(!m)return;let t=m;if(!M.trim()){Y.error(a(`gitView.toast.enterCommitMessage`));return}let n=fe.map(e=>e.path).sort();if(n.length===0){Y.error(a(`gitView.toast.selectFileToCommit`));return}j(e.pushAfter?`commitAndPush`:`commit`);try{if(await o.createGitCommit(t,M.trim(),{files:n}),Y.success(a(`gitView.toast.commitCreated`)),N(``),B([]),e.pushAfter){let e=h?.tracking?.split(`/`)[0],n=he.find(t=>t.name===e)??he[0];if(!n)throw Error(a(`mobile.changes.noRemote`));k(`sync`);let r=`${n.name}/`,i=h?.tracking?.startsWith(r)?h.tracking.slice(r.length):void 0;await o.gitFetch(t,{remote:n.name}),((await o.getGitStatus(t)).behind??0)>0&&await o.gitPull(t,{remote:n.name,branch:i,rebase:!0}),((await o.getGitStatus(t)).ahead??0)>0&&await o.gitPush(t),await Ce(t,!1),await Te(t).promise}else await Ce(t,!1)}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{j(null),e.pushAfter&&k(null)}},Ie=Z.useMemo(()=>{let e=[];return fe.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:fe,actionSymbol:`-`,actionAllLabel:a(`gitView.changes.unstageAllAria`),getActionLabel:e=>a(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void Oe([e],`unstage`),onActionAll:e=>void Oe(e,`unstage`),onViewDiff:e=>ke(e,!0),onRevertFile:je,showRevertActions:!1,accent:!0}),G.length>0&&e.push({id:`unstaged`,title:a(`gitView.changes.title`),entries:G,actionSymbol:`+`,actionAllLabel:a(`gitView.changes.stageAllAria`),getActionLabel:e=>a(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void Oe([e],`stage`),onActionAll:e=>void Oe(e,`stage`),onViewDiff:e=>ke(e,!1),onRevertFile:je}),e},[je,ke,Oe,fe,a,G]),Le=t=>(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[i?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:h?.current||m||``})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:t})]});return m?_&&g===null?Le((0,$.jsx)(gl,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):g===!1?Le((0,$.jsx)(gl,{icon:!0,message:a(`gitView.empty.notGitRepository`),description:a(`gitView.empty.notGitRepositoryDescription`)})):T.type===`diff`?(0,$.jsx)(`div`,{ref:D,className:`h-full min-h-0`,children:(0,$.jsx)(_l,{path:T.path,directory:m,diff:ge,fileExists:Se,error:xe,loading:be,targetLine:T.targetLine,onBack:Ae,onRetry:()=>se(e=>e+1),hideHeader:i})}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:h?.current||m})]}),(0,$.jsx)(Bi,{syncAction:O,remotes:he,onSync:e=>void De(`sync`,e),disabled:A!==null||_,aheadCount:h?.ahead??0,behindCount:h?.behind??0,trackingRemoteName:h?.tracking?.split(`/`)[0],hasUncommittedChanges:(h?.files?.length??0)>0})]}),de?(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Sa,{stagedCount:pe,unstagedCount:me,onLoad:()=>ue(!0)})}):W.length>0?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-4 pt-4`,children:(0,$.jsx)(ji,{groups:Ie,diffStats:h?.diffStats,revertingPaths:P,onRevertAll:Me,isRevertingAll:I,headerBackgroundClassName:`bg-transparent`,onVisiblePathsChange:te})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-4 pt-3`,children:(0,$.jsx)(Di,{stagedCount:fe.length,commitMessage:M,onCommitMessageChange:N,generatedHighlights:z,onInsertHighlights:Ne,onGenerateMessage:Pe,isGeneratingMessage:R,onCommit:()=>void Fe({pushAfter:!1}),onCommitAndPush:()=>void Fe({pushAfter:!0}),commitAction:A,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(gl,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):Le((0,$.jsx)(gl,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},gl=e=>{let t=(0,Q.c)(13),{message:n,description:r,loading:i,icon:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c;t[0]===o?c=t[1]:(c=o?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):null,t[0]=o,t[1]=c);let l;t[2]===s?l=t[3]:(l=s?(0,$.jsx)(X,{name:`git-branch`,className:`size-6 text-muted-foreground`}):null,t[2]=s,t[3]=l);let u;t[4]===n?u=t[5]:(u=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[4]=n,t[5]=u);let d;t[6]===r?d=t[7]:(d=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[6]=r,t[7]=d);let f;return t[8]!==c||t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[c,l,u,d]})}),t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f},_l=e=>{let t=(0,Q.c)(26),{path:n,directory:r,diff:i,fileExists:a,error:o,loading:s,targetLine:c,onBack:l,onRetry:u,hideHeader:d}=e,f=d!==void 0&&d,{t:p}=Ee(),m=$r(),h;t[0]===n?h=t[1]:(h=Rr(n)||`text`,t[0]=n,t[1]=h);let g=h,_;t[2]!==r||t[3]!==m||t[4]!==n||t[5]!==p?(_=m?(0,$.jsx)(J,{variant:`ghost`,size:`icon`,title:p(`diffView.actions.openFilePreview`),"aria-label":p(`diffView.actions.openFilePreview`),onClick:()=>m.openFile({path:fe(r,n)}),children:(0,$.jsx)(X,{name:`eye`,className:`size-4`})}):null,t[2]=r,t[3]=m,t[4]=n,t[5]=p,t[6]=_):_=t[6];let v=_,y;t[7]!==f||t[8]!==l||t[9]!==n||t[10]!==v||t[11]!==p?(y=f?(0,$.jsx)(vr,{children:v}):(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":p(`header.actions.backAria`),onClick:l,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-2`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:n})}),v]}),t[7]=f,t[8]=l,t[9]=n,t[10]=v,t[11]=p,t[12]=y):y=t[12];let b;t[13]!==i||t[14]!==o||t[15]!==a||t[16]!==g||t[17]!==s||t[18]!==u||t[19]!==n||t[20]!==p||t[21]!==c?(b=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:o?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:p(`mobile.changes.diffDetail.loadFailed`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:o}),(0,$.jsx)(J,{type:`button`,size:`sm`,variant:`outline`,onClick:u,children:p(`diffView.actions.retry`)})]})}):s?(0,$.jsx)(gl,{loading:!0,message:p(`diffView.state.loadingDiff`)}):a?i?i.isBinary?(0,$.jsx)(gl,{icon:!0,message:p(`diffView.binary.unavailable`)}):zr(n)?(0,$.jsx)(gl,{icon:!0,message:p(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(Kr,{className:`h-full overflow-y-auto overflow-x-hidden p-3 pwa-overlay-scroll`,"data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:(0,$.jsx)(Ri,{original:i.original,modified:i.modified,language:g,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:c,layout:`inline`})}):(0,$.jsx)(gl,{loading:!0,message:p(`diffView.state.loadingDiff`)}):(0,$.jsx)(gl,{icon:!0,message:p(`mobile.changes.diffDetail.missingTitle`),description:p(`mobile.changes.diffDetail.missingDescription`)})}),t[13]=i,t[14]=o,t[15]=a,t[16]=g,t[17]=s,t[18]=u,t[19]=n,t[20]=p,t[21]=c,t[22]=b):b=t[22];let x;return t[23]!==y||t[24]!==b?(x=(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[y,b]}),t[23]=y,t[24]=b,t[25]=x):x=t[25],x},vl=e(C(),1),yl=pr(()=>ge(()=>import(`./ToolOutputDialog-K4unHbkl.js`).then(e=>e.n),__vite__mapDeps([3,1,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,2,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79]))),bl=25e4,xl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Sl=e=>{let t=xl(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},Cl=e=>{let t=xl(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},wl=(e,t)=>{let n=xl(e),r=xl(t);return!r||n===r?Sl(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},Tl=e=>{if(typeof e!=`number`||!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`],n=e/1024;for(let e of t){if(n<1024||e===t[t.length-1])return`${n.toFixed(n>=10?0:1)} ${e}`;n/=1024}return``},El=e=>/\.(md|mdx|markdown)$/i.test(e),Dl=e=>{let t=(0,Q.c)(156),{onClose:n,initialFilePath:r,directFilePreview:i,hideFileHeader:a}=e,o=r===void 0?null:r,s=i!==void 0&&i,c=a!==void 0&&a,{t:l}=Ee(),{files:u}=ti(),d=ni()??null,f;t[0]===d?f=t[1]:(f=xl(d),t[0]=d,t[1]=f);let p=f,m;t[2]!==o||t[3]!==p?(m=()=>{let e=xl(o);return e?{type:`file`,path:e,returnDirectory:Cl(e)??p}:{type:`browser`,directory:p}},t[2]=o,t[3]=p,t[4]=m):m=t[4];let[h,g]=Z.useState(m),_=Z.useRef(null),[v,y]=Z.useState(``),b=_e(Fl),x=_e(Il),S,C;t[5]===p?(S=t[6],C=t[7]):(S=()=>{p&&g(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:Cl(e.path)??p}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:p})},C=[p],t[5]=p,t[6]=S,t[7]=C),Z.useEffect(S,C);let w,T;t[8]!==b||t[9]!==p||t[10]!==x?(T=()=>{if(!b||!p)return;let e=xl(b);if(!e){x(null);return}y(``),g({type:`file`,path:e,returnDirectory:Cl(e)??p}),x(null)},w=[b,p,x],t[8]=b,t[9]=p,t[10]=x,t[11]=w,t[12]=T):(w=t[11],T=t[12]),Z.useEffect(T,w);let E=h.type===`browser`?h.directory:h.returnDirectory,D=h.type===`browser`?h.directory:``,O=h.type===`file`?h.path:``,[k,A]=Z.useState(`preview`),j;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{A(`preview`)},t[13]=j):j=t[13];let M;t[14]===O?M=t[15]:(M=[O],t[14]=O,t[15]=M),Z.useEffect(j,M);let N=Tr(v,250),P;t[16]===v?P=t[17]:(P=v.trim(),t[16]=v,t[17]=P);let F=P,I;t[18]===N?I=t[19]:(I=N.trim(),t[18]=N,t[19]=I);let L=I,R;t[20]!==D||t[21]!==p?(R={scopeDirectory:p,directory:D},t[20]=D,t[21]=p,t[22]=R):R=t[22];let ee=!!D,z;t[23]===ee?z=t[24]:(z={enabled:ee,refetchOnMount:`always`},t[23]=ee,t[24]=z);let B=H(R,z),V;t[25]!==D||t[26]!==L?(V={directory:D,query:L,maxResults:40},t[25]=D,t[26]=L,t[27]=V):V=t[27];let te=!!(D&&L),ne;t[28]===te?ne=t[29]:(ne={enabled:te},t[28]=te,t[29]=ne);let re=de(V,ne),ie;t[30]===O?ie=t[31]:(ie=O&&(!zr(O)||O.toLowerCase().endsWith(`.svg`)),t[30]=O,t[31]=ie);let U=!!ie,ae;t[32]!==O||t[33]!==p?(ae={scopeDirectory:p,path:O},t[32]=O,t[33]=p,t[34]=ae):ae=t[34];let ce;t[35]===U?ce=t[36]:(ce={enabled:U},t[35]=U,t[36]=ce);let le=se(ae,ce),ue=U&&le.data?.isBinary===!0,W;t[37]!==O||t[38]!==le.data||t[39]!==le.error||t[40]!==le.isFetchedAfterMount||t[41]!==u||t[42]!==k||t[43]!==ue?(W=O&&u.readFile&&le.data&&le.isFetchedAfterMount&&!le.error&&!ue&&(!Vr(O)||k===`source`)&&(!zr(O)||O.toLowerCase().endsWith(`.svg`)),t[37]=O,t[38]=le.data,t[39]=le.error,t[40]=le.isFetchedAfterMount,t[41]=u,t[42]=k,t[43]=ue,t[44]=W):W=t[44];let fe=!!W,G;t[45]!==O||t[46]!==p?(G={scopeDirectory:p,path:O},t[45]=O,t[46]=p,t[47]=G):G=t[47];let pe;t[48]===fe?pe=t[49]:(pe={enabled:fe},t[48]=fe,t[49]=pe);let me=oe(G,pe),he=B.data?.entries.slice().sort(Ll)??[],q;t[50]!==B.error||t[51]!==l?(q=B.error?B.error instanceof Error?B.error.message:l(`mobile.files.error.listFailed`):null,t[50]=B.error,t[51]=l,t[52]=q):q=t[52];let ge=q,ve=B.isFetching,ye;t[53]===re.data?ye=t[54]:(ye=re.data??[],t[53]=re.data,t[54]=ye);let be=ye,xe=!!(F&&L&&v===N&&re.isFetching),Se;t[55]!==me.data||t[56]!==l?(Se=me.data&&me.data.length>bl?`${me.data.slice(0,bl)}\n\n${l(`mobile.files.file.truncated`)}`:me.data??``,t[55]=me.data,t[56]=l,t[57]=Se):Se=t[57];let Ce=Se,we=le.error??me.error,Te;t[58]!==u||t[59]!==ue||t[60]!==U||t[61]!==we||t[62]!==l?(Te=U&&(!u.statFile||!ue&&!u.readFile)?l(`mobile.files.error.readUnavailable`):we?we instanceof Error?we.message:l(`filesView.error.readFileFailed`):null,t[58]=u,t[59]=ue,t[60]=U,t[61]=we,t[62]=l,t[63]=Te):Te=t[63];let De=Te,Oe=!De&&(U&&(!le.data||!le.isFetchedAfterMount)||fe&&me.isFetching&&me.data===void 0),ke;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(ke=e=>{y(``),g({type:`browser`,directory:e})},t[64]=ke):ke=t[64];let Ae=ke,je;t[65]!==E||t[66]!==p?(je=e=>{g({type:`file`,path:e,returnDirectory:E||p})},t[65]=E,t[66]=p,t[67]=je):je=t[67];let Me=je,Ne;t[68]!==s||t[69]!==n||t[70]!==h.returnDirectory||t[71]!==h.type?(Ne=()=>h.type===`file`?s?(n?.(),!0):(g({type:`browser`,directory:h.returnDirectory}),!0):!1,t[68]=s,t[69]=n,t[70]=h.returnDirectory,t[71]=h.type,t[72]=Ne):Ne=t[72];let Pe=K(Ne),Fe=h.type===`file`,Ie;t[73]!==Pe||t[74]!==Fe?(Ie={id:`mobile-files-detail`,active:Fe,layer:`overlay`,onBack:Pe,surfaceRef:_},t[73]=Pe,t[74]=Fe,t[75]=Ie):Ie=t[75],Nr(Ie);let Le;t[76]===l?Le=t[77]:(Le=async e=>{(await ot(e)).ok||Y.error(l(`mobile.files.toast.copyFailed`))},t[76]=l,t[77]=Le);let Re=Le,ze;t[78]!==Ce||t[79]!==l?(ze=async()=>{(await ot(Ce)).ok?Y.success(l(`mobile.files.toast.contentCopied`)):Y.error(l(`mobile.files.toast.copyFailed`))},t[78]=Ce,t[79]=l,t[80]=ze):ze=t[80];let Be=ze;if(!p){let e;t[81]===l?e=t[82]:(e=l(`mobile.files.empty.noDirectory`),t[81]=l,t[82]=e);let n;return t[83]===e?n=t[84]:(n=(0,$.jsx)(Pl,{message:e}),t[83]=e,t[84]=n),n}if(h.type===`file`){let e;t[85]!==Re||t[86]!==h.path?(e=()=>void Re(h.path),t[85]=Re,t[86]=h.path,t[87]=e):e=t[87];let n;t[88]===Be?n=t[89]:(n=()=>void Be(),t[88]=Be,t[89]=n);let r;return t[90]!==Pe||t[91]!==Ce||t[92]!==De||t[93]!==c||t[94]!==k||t[95]!==ue||t[96]!==Oe||t[97]!==h.path||t[98]!==e||t[99]!==n?(r=(0,$.jsx)(`div`,{ref:_,className:`flex h-full min-h-0 flex-col`,children:(0,$.jsx)(jl,{path:h.path,content:Ce,error:De,isLoading:Oe,isBinary:ue,hideHeader:c,htmlViewMode:k,onHtmlViewModeChange:A,onBack:Pe,onCopyPath:e,onCopyContent:n})}),t[90]=Pe,t[91]=Ce,t[92]=De,t[93]=c,t[94]=k,t[95]=ue,t[96]=Oe,t[97]=h.path,t[98]=e,t[99]=n,t[100]=r):r=t[100],r}let Ve;t[101]!==p||t[102]!==h.directory||t[103]!==l?(Ve=h.directory===p?l(`mobile.files.rootDirectory`):Sl(h.directory),t[101]=p,t[102]=h.directory,t[103]=l,t[104]=Ve):Ve=t[104];let He=Ve,Ue;t[105]!==v||t[106]!==be?(Ue=v.trim()?be:[],t[105]=v,t[106]=be,t[107]=Ue):Ue=t[107];let We=Ue,Ge,Ke,qe,Je;if(t[108]!==n||t[109]!==v||t[110]!==p||t[111]!==h.directory||t[112]!==l){let e=Cl(h.directory),r=h.directory!==p&&e!==null&&(e===p||e.startsWith(`${p}/`)),i=r&&!v.trim(),a=r?e:null;Je=`flex h-full flex-col overflow-hidden bg-background text-foreground`,Ge=`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[117]!==n||t[118]!==l?(Ke=n?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":l(`mobile.surface.closeAria`),onClick:n,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,t[117]=n,t[118]=l,t[119]=Ke):Ke=t[119],qe=i&&a?(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":l(`mobile.files.backToParentAria`,{name:Sl(a)}),onClick:()=>Ae(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}):null,t[108]=n,t[109]=v,t[110]=p,t[111]=h.directory,t[112]=l,t[113]=Ge,t[114]=Ke,t[115]=qe,t[116]=Je}else Ge=t[113],Ke=t[114],qe=t[115],Je=t[116];let Ye;t[120]===He?Ye=t[121]:(Ye=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:He})}),t[120]=He,t[121]=Ye);let Xe;t[122]===l?Xe=t[123]:(Xe=l(`mobile.files.refreshAria`),t[122]=l,t[123]=Xe);let Ze;t[124]===B?Ze=t[125]:(Ze=()=>void B.refetch(),t[124]=B,t[125]=Ze);let J;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(J={touchAction:`manipulation`},t[126]=J):J=t[126];let Qe=ve&&`animate-spin`,$e;t[127]===Qe?$e=t[128]:($e=it(`size-5`,Qe),t[127]=Qe,t[128]=$e);let et;t[129]===$e?et=t[130]:(et=(0,$.jsx)(X,{name:`refresh`,className:$e}),t[129]=$e,t[130]=et);let tt;t[131]!==Xe||t[132]!==Ze||t[133]!==et?(tt=(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":Xe,onClick:Ze,style:J,children:et}),t[131]=Xe,t[132]=Ze,t[133]=et,t[134]=tt):tt=t[134];let nt;t[135]!==Ge||t[136]!==Ke||t[137]!==qe||t[138]!==Ye||t[139]!==tt?(nt=(0,$.jsxs)(`header`,{className:Ge,children:[Ke,qe,Ye,tt]}),t[135]=Ge,t[136]=Ke,t[137]=qe,t[138]=Ye,t[139]=tt,t[140]=nt):nt=t[140];let rt;t[141]===Symbol.for(`react.memo_cache_sentinel`)?(rt=(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[141]=rt):rt=t[141];let at;t[142]===Symbol.for(`react.memo_cache_sentinel`)?(at=e=>y(e.target.value),t[142]=at):at=t[142];let st;t[143]===l?st=t[144]:(st=l(`mobile.files.search.placeholder`),t[143]=l,t[144]=st);let ct;t[145]!==v||t[146]!==st?(ct=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[rt,(0,$.jsx)(Kn,{type:`text`,inputMode:`search`,value:v,onChange:at,placeholder:st,className:`h-11 pl-9`})]})}),t[145]=v,t[146]=st,t[147]=ct):ct=t[147];let lt=Kr,ut=ge?(0,$.jsx)(Pl,{message:ge}):v.trim()?(0,$.jsx)(kl,{results:We,isSearching:xe,onOpenFile:Me}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[he.length===0&&!ve?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:l(`mobile.files.empty.directory`)}):null,he.map(e=>(0,$.jsx)(Ol,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:Tl(e.size),onClick:()=>e.isDirectory?Ae(e.path):Me(e.path)},e.path))]}),dt;t[148]!==lt||t[149]!==ut?(dt=(0,$.jsx)(lt,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:ut}),t[148]=lt,t[149]=ut,t[150]=dt):dt=t[150];let ft;return t[151]!==Je||t[152]!==nt||t[153]!==ct||t[154]!==dt?(ft=(0,$.jsxs)(`div`,{className:Je,children:[nt,ct,dt]}),t[151]=Je,t[152]=nt,t[153]=ct,t[154]=dt,t[155]=ft):ft=t[155],ft},Ol=e=>{let t=(0,Q.c)(16),{name:n,path:r,directory:i,meta:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==r?(c=i?(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(sn,{filePath:r,className:`size-5 shrink-0`}),t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:n}),t[4]=n,t[5]=l);let u;t[6]===a?u=t[7]:(u=a?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:a}):null,t[6]=a,t[7]=u);let d;t[8]===i?d=t[9]:(d=i?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null,t[8]=i,t[9]=d);let f;return t[10]!==o||t[11]!==c||t[12]!==l||t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-14 w-full items-center gap-3 border-b border-border/30 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:o,style:s,children:[c,l,u,d]}),t[10]=o,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f):f=t[15],f},kl=e=>{let t=(0,Q.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=Ee(),o=xl(ni()??null);if(r){let e;t[0]===a?e=t[1]:(e=a(`common.loading`),t[0]=a,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,$.jsx)(Pl,{loading:!0,message:e}),t[2]=e,t[3]=n),n}if(n.length===0){let e;t[4]===a?e=t[5]:(e=a(`mobile.files.search.empty`),t[4]=a,t[5]=e);let n;return t[6]===e?n=t[7]:(n=(0,$.jsx)(Pl,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(Ol,{name:Sl(e.path),path:e.path,directory:!1,meta:wl(e.path,o),onClick:()=>i(e.path)},e.path)),c;return t[8]===s?c=t[9]:(c=(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:s}),t[8]=s,t[9]=c),c},Al=e=>{let t=(0,Q.c)(26),{path:n,canUseText:r,htmlViewMode:i,htmlFullscreen:a,onToggleHtmlViewMode:o,onEnterHtmlFullscreen:s,onCopyPath:c,onCopyContent:l}=e,{t:u}=Ee(),d;t[0]===n?d=t[1]:(d=Vr(n),t[0]=n,t[1]=d);let f=d,p;t[2]!==r||t[3]!==f||t[4]!==a||t[5]!==i||t[6]!==s||t[7]!==o||t[8]!==u?(p=f&&r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:o,"aria-label":u(i===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:i===`preview`?`file-code`:`eye`,className:`size-4`})}),a?null:(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:s,"aria-label":u(`mobile.files.html.fullscreenAria`),children:(0,$.jsx)(X,{name:`fullscreen`,className:`size-4`})})]}):null,t[2]=r,t[3]=f,t[4]=a,t[5]=i,t[6]=s,t[7]=o,t[8]=u,t[9]=p):p=t[9];let m;t[10]!==r||t[11]!==f||t[12]!==l||t[13]!==n||t[14]!==u?(m=r&&!zr(n)&&!f?(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:l,"aria-label":u(`mobile.files.copyContentAria`),children:(0,$.jsx)(X,{name:`file-copy`,className:`size-4`})}):null,t[10]=r,t[11]=f,t[12]=l,t[13]=n,t[14]=u,t[15]=m):m=t[15];let h;t[16]!==r||t[17]!==f||t[18]!==c||t[19]!==n||t[20]!==u?(h=!r||zr(n)||f?(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:c,"aria-label":u(`mobile.files.copyPathAria`),children:(0,$.jsx)(X,{name:`clipboard`,className:`size-4`})}):null,t[16]=r,t[17]=f,t[18]=c,t[19]=n,t[20]=u,t[21]=h):h=t[21];let g;return t[22]!==p||t[23]!==m||t[24]!==h?(g=(0,$.jsxs)($.Fragment,{children:[p,m,h]}),t[22]=p,t[23]=m,t[24]=h,t[25]=g):g=t[25],g},jl=e=>{let t=(0,Q.c)(90),{path:n,content:r,error:i,isLoading:a,isBinary:o,hideHeader:s,htmlViewMode:c,onHtmlViewModeChange:l,onBack:u,onCopyPath:d,onCopyContent:f}=e,p=s!==void 0&&s,{t:m}=Ee(),h=Z.useRef(null),g=ni(),_=zr(n)&&!n.toLowerCase().endsWith(`.svg`)?n:``,v;t[0]===n?v=t[1]:(v=Cl(n)??``,t[0]=n,t[1]=v);let y=Hr(_,v,`preview`),[b,x]=Z.useState(``),S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S={open:!1,title:``,content:``},t[2]=S):S=t[2];let[C,w]=Z.useState(S),T=y.source,E;t[3]===n?E=t[4]:(E=Sl(n),t[3]=n,t[4]=E);let D=E,O;t[5]!==r||t[6]!==n?(O=zr(n)?`data:${Br(n)};utf8,${encodeURIComponent(r)}`:``,t[5]=r,t[6]=n,t[7]=O):O=t[7];let k=O,A;t[8]!==r||t[9]!==k||t[10]!==T||t[11]!==n?(A=T||(zr(n)&&r?k:``),t[8]=r,t[9]=k,t[10]=T,t[11]=n,t[12]=A):A=t[12];let j=A,M;t[13]!==i||t[14]!==b||t[15]!==y.error||t[16]!==j||t[17]!==m?(M=i??y.error??(j&&b===j?m(`filesView.error.readFileFailed`):null),t[13]=i,t[14]=b,t[15]=y.error,t[16]=j,t[17]=m,t[18]=M):M=t[18];let N=M,P;t[19]===j?P=t[20]:(P=()=>x(j),t[19]=j,t[20]=P);let F=K(P),I;t[21]!==D||t[22]!==_||t[23]!==n||t[24]!==j?(I=e=>{let t=_||j;t&&w({open:!0,title:D,content:``,previewSource:e.currentTarget.querySelector(`img`)??void 0,metadata:{tool:`image-preview`,filename:D,mime:Br(n)},image:{url:t,mimeType:Br(n),filename:D}})},t[21]=D,t[22]=_,t[23]=n,t[24]=j,t[25]=I):I=t[25];let L=K(I),R;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{w(t=>t.open===e?t:{...t,open:e})},t[26]=R):R=t[26];let ee=K(R),z;t[27]===n?z=t[28]:(z=Vr(n),t[27]=n,t[28]=z);let B=z,[V,te]=Z.useState(!1),ne=Z.useRef(null),re;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{te(!1)},t[29]=re):re=t[29];let H;t[30]===n?H=t[31]:(H=[n],t[30]=n,t[31]=H),Z.useEffect(re,H);let ie;t[32]!==c||t[33]!==l?(ie=()=>{l(c===`preview`?`source`:`preview`)},t[32]=c,t[33]=l,t[34]=ie):ie=t[34];let U=K(ie),ae;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>{te(!0)},t[35]=ae):ae=t[35];let oe=K(ae),se;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>(te(!1),!0),t[36]=se):se=t[36];let ce=K(se),le=B&&V,ue;t[37]!==ce||t[38]!==le?(ue={id:`mobile-html-fullscreen`,active:le,layer:`overlay`,onBack:ce,surfaceRef:ne},t[37]=ce,t[38]=le,t[39]=ue):ue=t[39],Nr(ue);let de=!o&&!a&&!i,W;t[40]!==oe||t[41]!==V||t[42]!==c||t[43]!==f||t[44]!==d||t[45]!==n||t[46]!==de||t[47]!==U?(W=(0,$.jsx)(Al,{path:n,canUseText:de,htmlViewMode:c,htmlFullscreen:V,onToggleHtmlViewMode:U,onEnterHtmlFullscreen:oe,onCopyPath:d,onCopyContent:f}),t[40]=oe,t[41]=V,t[42]=c,t[43]=f,t[44]=d,t[45]=n,t[46]=de,t[47]=U,t[48]=W):W=t[48];let fe=W,G;t[49]!==r||t[50]!==i||t[51]!==c||t[52]!==a||t[53]!==n||t[54]!==m?(G=c===`source`?a?(0,$.jsx)(Pl,{loading:!0,message:m(`filesView.state.loading`)}):i?(0,$.jsx)(Ka,{message:i}):(0,$.jsx)(Nl,{path:n,content:r}):(0,$.jsx)(Ml,{path:n}),t[49]=r,t[50]=i,t[51]=c,t[52]=a,t[53]=n,t[54]=m,t[55]=G):G=t[55];let pe=G,me;t[56]!==ce||t[57]!==B||t[58]!==pe||t[59]!==V||t[60]!==c||t[61]!==D||t[62]!==m||t[63]!==U?(me=B?(0,$.jsxs)(`div`,{ref:ne,"data-mobile-html-preview":c===`preview`&&!V?`true`:void 0,"data-mobile-html-fullscreen":c===`preview`&&V?`true`:void 0,className:V?`fixed inset-0 z-[80] flex flex-col bg-background text-foreground`:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[V?(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-border/50 px-3 pb-2 pt-[max(0.5rem,env(safe-area-inset-top))]`,children:[(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:ce,"aria-label":m(`mobile.files.html.exitFullscreenAria`),className:`shrink-0 text-muted-foreground`,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-header text-foreground`,children:D}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:U,"aria-label":m(c===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:c===`preview`?`file-code`:`eye`,className:`size-4`})})]}):null,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden bg-background`,children:pe})]}):null,t[56]=ce,t[57]=B,t[58]=pe,t[59]=V,t[60]=c,t[61]=D,t[62]=m,t[63]=U,t[64]=me):me=t[64];let he=me,q=g??void 0,ge;t[65]!==r||t[66]!==i||t[67]!==fe||t[68]!==F||t[69]!==ee||t[70]!==p||t[71]!==B||t[72]!==V||t[73]!==he||t[74]!==N||t[75]!==D||t[76]!==C||t[77]!==y.loading||t[78]!==o||t[79]!==a||t[80]!==u||t[81]!==L||t[82]!==n||t[83]!==j||t[84]!==m?(ge=e=>{let{preview:t,controls:s}=e;return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,"data-mobile-edge-to-edge-preview":`true`,children:[p?(0,$.jsxs)(vr,{children:[s,fe]}):(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":m(`header.actions.backAria`),onClick:u,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:D})}),s,fe]}),(0,$.jsx)(`div`,{ref:h,className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:t??(o&&!a&&!i?(0,$.jsx)(Fa,{path:n},n):B&&!a&&!i?V&&typeof document<`u`?(0,vl.createPortal)(he,document.body):he:a||y.loading?zr(n)?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-4`,children:(0,$.jsx)(Ur,{className:`aspect-square w-64 max-w-full rounded-lg`})}):(0,$.jsx)(Pl,{loading:!0,message:m(`filesView.state.loading`)}):N?(0,$.jsx)(Ka,{message:N}):zr(n)&&j?(0,$.jsx)(Kr,{className:`h-full overflow-auto p-4`,children:(0,$.jsx)(`button`,{type:`button`,className:`mx-auto block w-full cursor-zoom-in rounded-lg border-0 bg-transparent p-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary [&>.yuri-image-frame]:w-full`,onClick:L,"aria-label":D,children:(0,$.jsx)(Wr,{src:j,alt:D,className:`h-auto w-full rounded-lg object-contain`,draggable:!1,onError:F})})}):(0,$.jsx)(Nl,{path:n,content:r}))}),(0,$.jsx)(Sn,{containerRef:h}),C.open?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(yl,{popup:C,onOpenChange:ee,isMobile:!0})}):null]})},t[65]=r,t[66]=i,t[67]=fe,t[68]=F,t[69]=ee,t[70]=p,t[71]=B,t[72]=V,t[73]=he,t[74]=N,t[75]=D,t[76]=C,t[77]=y.loading,t[78]=o,t[79]=a,t[80]=u,t[81]=L,t[82]=n,t[83]=j,t[84]=m,t[85]=ge):ge=t[85];let _e;return t[86]!==n||t[87]!==q||t[88]!==ge?(_e=(0,$.jsx)(bi,{path:n,base:q,children:ge}),t[86]=n,t[87]=q,t[88]=ge,t[89]=_e):_e=t[89],_e},Ml=e=>{let t=(0,Q.c)(5),{path:n}=e,{projectScope:r}=ti(),i=ni(),a=r?.location.directory??i??``,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={backgroundColor:`var(--surface-background)`},t[0]=o):o=t[0];let s;return t[1]!==n||t[2]!==r||t[3]!==a?(s=(0,$.jsx)(qi,{path:n,directory:a,entry:r,className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-background`,iframeClassName:`h-full min-h-0 w-full flex-1 border-none bg-background`,iframeStyle:o}),t[1]=n,t[2]=r,t[3]=a,t[4]=s):s=t[4],s},Nl=e=>{let t=(0,Q.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=Qt(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??dr(!1),t[0]=a,t[1]=o,t[2]=c):c=t[2];let l=c,u;t[3]!==a||t[4]!==s?(u=a.find(e=>e.metadata.id===s)??dr(!0),t[3]=a,t[4]=s,t[5]=u):u=t[5];let d=u,f,p;t[6]!==d||t[7]!==l?(f=()=>{Mr(l),Mr(d)},p=[d,l],t[6]=d,t[7]=l,t[8]=f,t[9]=p):(f=t[8],p=t[9]),Z.useEffect(f,p);let m;t[10]!==d.metadata.id||t[11]!==l.metadata.id?(m={light:l.metadata.id,dark:d.metadata.id},t[10]=d.metadata.id,t[11]=l.metadata.id,t[12]=m):m=t[12];let h=m;if(El(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Kr,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(mr,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=Sl(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=Rr(n)||void 0,t[17]=n,t[18]=_);let v;t[19]!==r||t[20]!==g||t[21]!==_?(v={name:g,contents:r,lang:_},t[19]=r,t[20]=g,t[21]=_,t[22]=v):v=t[22];let y=i.metadata.variant===`dark`?`dark`:`light`,b;t[23]!==h||t[24]!==y?(b={disableFileHeader:!0,overflow:`wrap`,theme:h,themeType:y,unsafeCSS:Si},t[23]=h,t[24]=y,t[25]=b):b=t[25];let x;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(x={minHeight:`100%`},t[26]=x):x=t[26];let S;return t[27]!==b||t[28]!==v?(S=(0,$.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,$.jsx)(Kr,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(Ce,{file:v,options:b,className:`block min-h-full w-full`,style:x})})}),t[27]=b,t[28]=v,t[29]=S):S=t[29],S},Pl=e=>{let t=(0,Q.c)(7),{message:n,loading:r}=e,i=r!==void 0&&r,a;t[0]===i?a=t[1]:(a=i?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-open-fill`,className:`size-6 text-muted-foreground`}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s};function Fl(e){return e.pendingFileFocusPath}function Il(e){return e.setPendingFileFocusPath}function Ll(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}var Rl=S(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),zl=36,Bl=18,Vl=e=>e.parentID??null,Hl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Ul=e=>{let t=e;return Hl(t.directory??t.project?.worktree??null)},Wl=e=>{let t=Hl(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},Gl=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},Kl=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),ql=e=>{if(e<=0)return``;let t=Date.now()-e;if(t<6e4)return`now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return`${r}h`;let i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))},Jl=(e,t)=>{let n=Hl(e),r=Hl(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},Yl=(e,t)=>e.worktrees.find(e=>Hl(e.path)===t)??null,Xl=(e,t)=>t===e.path||!!Yl(e,t),Zl=(e,t)=>{let n=Hl(t);return n?e.find(e=>Xl(e,n))??null:null},Ql=(e,t,n)=>!n||`${e.title??``} ${e.id} ${Ul(e)} ${t}`.toLowerCase().includes(n),$l=e=>{let t=(0,Q.c)(14),{project:n,size:r}=e,i=r===void 0?`md`:r,a=i===`sm`?`size-6 rounded-md`:`size-8 rounded-lg`,o=i===`sm`?`size-3.5`:`size-4`,s=n.icon?Yr[n.icon]:null,c=n.color?Xr[n.color]:void 0,l=s??`folder-open`,u;t[0]===c?u=t[1]:(u=c?{color:c}:void 0,t[0]=c,t[1]=u);let d;t[2]!==o||t[3]!==l||t[4]!==u?(d=(0,$.jsx)(X,{name:l,className:o,style:u}),t[2]=o,t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=d,p;t[6]===a?p=t[7]:(p=it(`flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,a),t[6]=a,t[7]=p);let m;t[8]!==f||t[9]!==n?(m=n.iconImage?(0,$.jsx)(qr,{project:n,className:`size-full object-contain`,fallback:f}):f,t[8]=f,t[9]=n,t[10]=m):m=t[10];let h;return t[11]!==p||t[12]!==m?(h=(0,$.jsx)(`span`,{className:p,children:m}),t[11]=p,t[12]=m,t[13]=h):h=t[13],h},eu=e=>{let t=(0,Q.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=it(`flex size-5 shrink-0 items-center justify-center text-muted-foreground/70 transition-transform duration-150`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`span`,{"aria-hidden":!0,className:i,children:a}),t[3]=i,t[4]=o),o},tu=e=>{let t=(0,Q.c)(2),{ariaLabel:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`inline-block size-1.5 shrink-0 rounded-full bg-primary`,"aria-label":n}),t[0]=n,t[1]=r),r},nu=e=>{let t=(0,Q.c)(12),{onClick:n,className:r}=e,{t:i}=Ee(),a;t[0]===i?a=t[1]:(a=i(`sessions.sidebar.project.actions.newWorktree`),t[0]=i,t[1]=a);let o=a,s;t[2]===r?s=t[3]:(s=it(`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,r),t[2]=r,t[3]=s);let c;t[4]===n?c=t[5]:(c=e=>{e.stopPropagation(),n()},t[4]=n,t[5]=c);let l,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l={touchAction:`manipulation`},u=(0,$.jsx)(X,{name:`node-tree`,className:`size-4`}),t[6]=l,t[7]=u):(l=t[6],u=t[7]);let d;return t[8]!==o||t[9]!==s||t[10]!==c?(d=(0,$.jsx)(`button`,{type:`button`,className:s,"aria-label":o,title:o,onClick:c,style:l,children:u}),t[8]=o,t[9]=s,t[10]=c,t[11]=d):d=t[11],d},ru=e=>{let t=(0,Q.c)(10),{icon:n,label:r,onClick:i,destructive:a}=e,o=a!==void 0&&a?`destructive`:`ghost`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(X,{name:n,className:`size-5 shrink-0 text-inherit`}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=l);let u;return t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(J,{type:`button`,variant:o,size:`default`,className:`min-h-12 w-full justify-start gap-3 rounded-xl px-3 typography-ui-label`,onClick:i,style:s,children:[c,l]}),t[5]=i,t[6]=o,t[7]=c,t[8]=l,t[9]=u):u=t[9],u},iu=e=>{let t=(0,Q.c)(107),{session:n,active:r,indent:i,contextLabel:a,confirmingArchive:o,hasChildren:s,expanded:c,onToggleChildren:l,onSelect:u,onRequestArchive:d,onConfirmArchive:f,onStop:p,stopAriaLabel:m,longPressHandlers:h,highlightQuery:g}=e,_=o!==void 0&&o,v=s!==void 0&&s,y=c!==void 0&&c,{t:b}=Ee(),x;t[0]===n?x=t[1]:(x=ql(Gl(n)),t[0]=n,t[1]=x);let S=x,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,R,ee,z;if(t[2]!==r||t[3]!==_||t[4]!==y||t[5]!==v||t[6]!==g||t[7]!==i||t[8]!==h.onContextMenu||t[9]!==h.onPointerCancel||t[10]!==h.onPointerDown||t[11]!==h.onPointerMove||t[12]!==h.onPointerUp||t[13]!==h.pressed||t[14]!==u||t[15]!==l||t[16]!==n.title||t[17]!==b){z=n.title?.trim()||b(`mobile.sessions.untitled`);let e=r&&!_&&`bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]`,a=_&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`;t[36]!==e||t[37]!==a?(N=it(`relative flex items-center gap-1 transition-colors`,e,a),t[36]=e,t[37]=a,t[38]=N):N=t[38],t[39]!==y||t[40]!==v||t[41]!==i||t[42]!==l||t[43]!==b?(P=v&&l?(0,$.jsx)(`button`,{type:`button`,className:`absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,style:{left:Math.max(i-32,2),top:0,bottom:0,touchAction:`manipulation`},"aria-label":b(y?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:e=>{e.stopPropagation(),l()},children:(0,$.jsx)(X,{name:`arrow-down-s`,className:it(`size-[18px] transition-transform duration-150`,y?`rotate-0`:`-rotate-90`)})}):null,t[39]=y,t[40]=v,t[41]=i,t[42]=l,t[43]=b,t[44]=P):P=t[44],C=`button`;let o=_&&`opacity-50`,s=h.pressed&&`bg-interactive-active scale-[0.99]`;t[45]!==o||t[46]!==s?(w=it(`flex min-h-12 min-w-0 flex-1 items-center gap-2.5 py-2 pr-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o,s),t[45]=o,t[46]=s,t[47]=w):w=t[47],t[48]===i?T=t[49]:(T={paddingLeft:i,touchAction:`manipulation`},t[48]=i,t[49]=T),E=u,D=h.onPointerDown,O=h.onPointerMove,k=h.onPointerUp,A=h.onPointerCancel,j=h.onContextMenu,M=_,ee=`flex min-w-0 flex-1 flex-col`,L=`flex items-center gap-2.5`;let c=r?`bg-primary`:`bg-muted-foreground/30`,d;t[50]===c?d=t[51]:(d=it(`size-1.5 shrink-0 rounded-full`,c),t[50]=c,t[51]=d),t[52]===d?R=t[53]:(R=(0,$.jsx)(`span`,{className:d,"aria-hidden":!0}),t[52]=d,t[53]=R);let f=r?`text-primary`:`text-foreground`;t[54]===f?F=t[55]:(F=it(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),I=g?rr(z,g):z,t[2]=r,t[3]=_,t[4]=y,t[5]=v,t[6]=g,t[7]=i,t[8]=h.onContextMenu,t[9]=h.onPointerCancel,t[10]=h.onPointerDown,t[11]=h.onPointerMove,t[12]=h.onPointerUp,t[13]=h.pressed,t[14]=u,t[15]=l,t[16]=n.title,t[17]=b,t[18]=C,t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A,t[26]=j,t[27]=M,t[28]=N,t[29]=P,t[30]=F,t[31]=I,t[32]=L,t[33]=R,t[34]=ee,t[35]=z}else C=t[18],w=t[19],T=t[20],E=t[21],D=t[22],O=t[23],k=t[24],A=t[25],j=t[26],M=t[27],N=t[28],P=t[29],F=t[30],I=t[31],L=t[32],R=t[33],ee=t[34],z=t[35];let B;t[56]!==F||t[57]!==I?(B=(0,$.jsx)(`span`,{className:F,children:I}),t[56]=F,t[57]=I,t[58]=B):B=t[58];let V;t[59]===S?V=t[60]:(V=S?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:S}):null,t[59]=S,t[60]=V);let te;t[61]!==B||t[62]!==V||t[63]!==L||t[64]!==R?(te=(0,$.jsxs)(`span`,{className:L,children:[R,B,V]}),t[61]=B,t[62]=V,t[63]=L,t[64]=R,t[65]=te):te=t[65];let ne;t[66]!==a||t[67]!==g?(ne=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?rr(a,g):a}):null,t[66]=a,t[67]=g,t[68]=ne):ne=t[68];let re;t[69]!==te||t[70]!==ne||t[71]!==ee?(re=(0,$.jsxs)(`span`,{className:ee,children:[te,ne]}),t[69]=te,t[70]=ne,t[71]=ee,t[72]=re):re=t[72];let H;t[73]!==C||t[74]!==w||t[75]!==T||t[76]!==E||t[77]!==D||t[78]!==O||t[79]!==k||t[80]!==A||t[81]!==j||t[82]!==M||t[83]!==re?(H=(0,$.jsx)(`button`,{type:C,className:w,style:T,onClick:E,onPointerDown:D,onPointerMove:O,onPointerUp:k,onPointerCancel:A,onContextMenu:j,disabled:M,children:re}),t[73]=C,t[74]=w,t[75]=T,t[76]=E,t[77]=D,t[78]=O,t[79]=k,t[80]=A,t[81]=j,t[82]=M,t[83]=re,t[84]=H):H=t[84];let ie;t[85]!==p||t[86]!==m?(ie=p?(0,$.jsx)(`button`,{type:`button`,className:`mr-0.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":m,onClick:e=>{e.stopPropagation(),p()},style:{touchAction:`manipulation`},children:(0,$.jsx)(ea,{})}):null,t[85]=p,t[86]=m,t[87]=ie):ie=t[87];let U;t[88]===b?U=t[89]:(U=b(`sessions.sidebar.session.menu.label`),t[88]=b,t[89]=U);let ae;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(X,{name:`more-2`,className:`size-4`}),t[90]=ae):ae=t[90];let oe;t[91]!==h.onOpenActions||t[92]!==U?(oe=(0,$.jsx)(J,{variant:`ghost`,size:`icon`,"data-session-drag-ignore":!0,"aria-label":U,onClick:h.onOpenActions,children:ae}),t[91]=h.onOpenActions,t[92]=U,t[93]=oe):oe=t[93];let se;t[94]!==_||t[95]!==f||t[96]!==d||t[97]!==b||t[98]!==z?(se=d?(0,$.jsxs)($.Fragment,{children:[_?(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 shrink-0 items-center gap-1.5 rounded-xl bg-destructive px-3 text-destructive-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,"aria-label":b(`mobile.sessions.archiveSessionAria`,{title:z}),onClick:f,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`archive`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:b(`sessions.sidebar.bulkActions.archive`)})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`mr-1.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":b(_?`mobile.sessions.cancelArchiveAria`:`mobile.sessions.archiveSessionAria`,{title:z}),onClick:d,style:{touchAction:`manipulation`},children:_?(0,$.jsx)(X,{name:`close`,className:`size-4`}):(0,$.jsx)(X,{name:`archive`,className:`size-4`})})]}):null,t[94]=_,t[95]=f,t[96]=d,t[97]=b,t[98]=z,t[99]=se):se=t[99];let ce;return t[100]!==N||t[101]!==P||t[102]!==H||t[103]!==ie||t[104]!==oe||t[105]!==se?(ce=(0,$.jsxs)(`div`,{className:N,children:[P,H,ie,oe,se]}),t[100]=N,t[101]=P,t[102]=H,t[103]=ie,t[104]=oe,t[105]=se,t[106]=ce):ce=t[106],ce},au=e=>{let t=(0,Q.c)(15),{indent:n,showMore:r,showFewer:i,loadingMore:a,onShowMore:o,onShowFewer:s}=e,c=a!==void 0&&a,{t:l}=Ee();if(!r&&!i)return null;let u;t[0]===n?u=t[1]:(u={paddingLeft:n,touchAction:`manipulation`},t[0]=n,t[1]=u);let d;t[2]!==s||t[3]!==i||t[4]!==l?(d=i?(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:s,children:[(0,$.jsx)(X,{name:`arrow-up-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showFewer`)})]}):null,t[2]=s,t[3]=i,t[4]=l,t[5]=d):d=t[5];let f;t[6]!==c||t[7]!==o||t[8]!==r||t[9]!==l?(f=r?(0,$.jsxs)(`button`,{type:`button`,className:it(`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-60`,c&&`animate-pulse`),onClick:o,disabled:c,children:[(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showMore`)})]}):null,t[6]=c,t[7]=o,t[8]=r,t[9]=l,t[10]=f):f=t[10];let p;return t[11]!==u||t[12]!==d||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-h-10 w-full items-center gap-3 py-1.5 pr-3 text-muted-foreground`,style:u,children:[d,f]}),t[11]=u,t[12]=d,t[13]=f,t[14]=p):p=t[14],p},ou=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=Ee(),{git:i}=ce(),a=bt(),o=rt(),s=Lt(e=>e.activeSessions),c=Lt(e=>e.activePaginationByDirectory),l=st(e=>e.projects),u=Z.useMemo(()=>l.filter(e=>!e.hostId),[l]),d=l.some(e=>!!e.hostId),f=Xt(e&&d),p=f.catalog?.projects??[],m=st(e=>e.activeProjectId),h=O(e=>e.currentDirectory),g=Ot(e=>e.currentSessionId),_=Ot(e=>e.availableWorktreesByProject),v=Ot(e=>e.setCurrentSession),y=Ot(e=>e.archiveSession),b=Ot(e=>e.archiveSessions),x=Ot(e=>e.updateSessionTitle),S=Ot(e=>e.requestSessionSmartTitle),C=Ot(e=>e.shareSession),w=Ot(e=>e.unshareSession),T=Ot(e=>e.openNewSessionDraft),E=st(e=>e.setActiveProject),D=st(e=>e.setActiveProjectIdOnly),k=st(e=>e.removeProject),A=mt();Vi();let j=dt(e=>e.sessionOrderByScope),M=dt(e=>e.sessionOrderActivityByScope),N=zt(),P=Ti(e=>e.projectExpanded),F=Ti(e=>e.worktreeExpanded),I=Ti(e=>e.setProjectExpanded),L=Ti(e=>e.setWorktreeExpanded),R=St(e=>e.orderByProject),ee=Rl(e=>e.expandedParents),z=Rl(e=>e.toggleParent),[B,V]=Z.useState(``),[te,ne]=Z.useState(null),[re,H]=Z.useState(null),[ie,U]=Z.useState(0),[ae,oe]=Z.useState(!1),[se,le]=Z.useState(!1),[ue,de]=Z.useState(null),[W,fe]=Z.useState(null),G=W?.kind===`session`?W.session:null,{unread:pe,onToggleRead:me}=pa(G,G?Ul(G):void 0),[he,q]=Z.useState(null),[ge,_e]=Z.useState(null),[ve,ye]=Z.useState(null),[be,xe]=Z.useState(``),[Se,Ce]=Z.useState(!1),[we,Te]=Z.useState(null),De=Z.useRef(null);De.current||=ga({onPressedKeyChange:_e});let[Oe,ke]=Z.useState(new Set),[Ae,je]=Z.useState(new Map),[Me,Ne]=Z.useState(new Map),Pe=Gi(),Fe=Na(),Ie=K(e=>{Lr(e),nt(e)}),Le=K(e=>{Promise.all(e.map(e=>(Lr(e),nt(e))))});Z.useEffect(()=>{if(!e){V(``),Ne(new Map),ne(null),H(null),fe(null),ye(null),Te(null),De.current?.reset();return}},[e]),Z.useEffect(()=>()=>{De.current?.reset()},[]),Z.useEffect(()=>{if(!e)return;if(u.length===0){Ot.setState(e=>{let t=oa(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),ke(e=>e.size===0?e:new Set),je(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(u.map(async e=>{let n=Hl(e.path);if(!n)return null;let r;try{r=await i.checkIsGitRepository(n)}catch{return{id:e.id,path:n,gitStatus:`failed`}}if(!r)return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:`success`,worktrees:[]};let[a,o]=await Promise.allSettled([Zr({id:e.id,path:n},{isCurrent:()=>!t}),Jr(n)]);return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:a.status===`fulfilled`?`success`:`failed`,worktrees:a.status===`fulfilled`?a.value.worktrees:void 0,rootBranchStatus:o.status===`fulfilled`?`success`:`failed`,rootBranch:o.status===`fulfilled`?o.value:void 0}}));if(t)return;let n=new Set(u.map(e=>Hl(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);Ot.setState(e=>{let t=oa(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),ke(t=>{let r=new Set([...t].filter(e=>n.has(e)));for(let t of e)t?.gitStatus===`success`&&(t.isGitRepo?r.add(t.path):r.delete(t.path));return Kl(r,t)?t:r}),je(t=>{let n=new Set(u.map(e=>e.id)),r=new Map([...t].filter(([e])=>n.has(e)));for(let t of e){if(!t||t.gitStatus!==`success`)continue;if(!t.isGitRepo){r.delete(t.id);continue}if(t.rootBranchStatus!==`success`)continue;let e=t.rootBranch?.trim();e&&e!==`HEAD`?r.set(t.id,e):r.delete(t.id)}return r.size===t.size&&[...r].every(([e,n])=>t.get(e)===n)?t:r})})(),()=>{t=!0}},[i,e,u,ie]);let Re=Z.useMemo(()=>u.map(e=>({id:e.id,label:Wl(e.path),path:Hl(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:Oe.has(Hl(e.path)),worktrees:Ct(R[e.id],_.get(Hl(e.path))??[])})),[Oe,u,R,_]),ze=Z.useMemo(()=>{let e=new Map(o.map(e=>[e.id,e])),t=s.map(t=>{let n=e.get(t.id);return n?gt(n,t):t}),n=new Set(t.map(e=>e.id));for(let e of o)n.has(e.id)||t.push(e);return t},[s,o]),Be=B.trim().toLowerCase(),Ve=Z.useMemo(()=>{let e=Re.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===m})),t=(e,t,n)=>{let r=Hl(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||Wl(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a};for(let n of e){t(n,n.project.path,null);for(let e of n.project.worktrees)t(n,e.path,e)}for(let n of ze){let r=Ul(n);if(!r)continue;let i=Hl(r),a=e.find(e=>Xl(e.project,i));if(!a)continue;let o=Yl(a.project,i);(o?t(a,o.path,o):t(a,a.project.path,null)).sessions.push(n)}for(let t of e)for(let e of t.buckets){let n=Hl(e.path),r=xi(e.sessions.map(e=>({session:e})),j[n],M[n],A);e.sessions.sort((e,t)=>r({session:e},{session:t}));for(let n of e.sessions)Vl(n)||(t.totalSessions+=1)}return e},[m,Re,ze,j,M,A]),He=Hl(h),Ue=e=>e.isActive?He===e.project.path?e.project.path:e.project.worktrees.find(e=>Jl(He,e.path))?.path??e.project.path:null,We=e=>P[e.project.id]??!0,Ge=(e,t)=>F[`${e.project.id}::${t.key}`]??!1,Ke=e=>{Ne(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},qe=()=>{fe(null),De.current?.reset()},Je=e=>({onOpenActions:()=>fe(e),pressed:ge===e.key||W?.key===e.key,onPointerDown:t=>{e.kind!==`session`&&(t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||De.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>fe(e)}))},onPointerMove:e=>{De.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{De.current?.end(e.pointerId)},onPointerCancel:e=>{De.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),e.kind!==`session`&&De.current?.openFromContextMenu(e.key,()=>fe(e))}}),Ye=(e,t)=>{De.current?.consumeClick(e)||t()},Xe=(e,t,n,r)=>{let i=ha(),a=ja();if(Ne(t=>{let r=new Map(t),o=Math.max(i,t.get(e)??i,n);return r.set(e,o+a),r}),Math.max(i,n)+a<r)return;let o=Hl(t);if(!o)return;let s=Lt.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&Ft(o)},Ze=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=ha(),o=new Set(t.sessions.map(e=>e.id)),s=new Map;for(let e of t.sessions){let t=Vl(e);if(t&&o.has(t)){let n=s.get(t)??[];n.push(e),s.set(t,n)}}let l=t.sessions.filter(e=>!Vl(e)),u=Me.get(i)??a,d=Pa(l,u,Fe),f=l.length-d.length,p=c.get(Hl(t.path)),m=p?.hasMore===!0,h=p?.loadingMore===!0,_=l.length>a&&u>a,v=(e,t)=>{let n=s.get(e.id)??[],i=n.length>0,a=!!ee[e.id],o=Pe.has(e.id),c=i&&!a?n.filter(e=>Pe.has(e.id)).map(e=>e.id):[],l=c.length>0,u=o?[e.id,...c]:c,d=e.title?.trim()||r(`mobile.sessions.untitled`),f=`session:${e.id}`;return(0,$.jsxs)(Z.Fragment,{children:[(0,$.jsx)(iu,{session:e,active:g===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>z(e.id):void 0,confirmingArchive:re===e.id,onSelect:()=>Ye(f,()=>tt(e)),onRequestArchive:()=>at(e.id),onConfirmArchive:()=>void ct(e),onStop:o||l?()=>Le(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:d}),longPressHandlers:Je({key:f,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+Bl)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[l.length===0&&!m&&!h?(0,$.jsx)(`div`,{className:`py-1.5 pr-3 typography-ui-label font-normal text-muted-foreground/80`,style:{paddingLeft:n},children:r(`sessions.sidebar.group.empty.noSessionsInWorkspace`)}):null,(0,$.jsx)(Fi,{scopeKey:re?null:Hl(t.path),sessionIds:d.map(e=>e.id),folderIdBySessionId:new Map(d.map(e=>[e.id,dt.getState().getSessionFolderId(Hl(t.path),e.id)])),onSessionDroppedOnFolder:()=>{},onSessionsReordered:(e,n)=>{dt.getState().reorderSessions(Hl(t.path),d.map(e=>e.id),e,n,Ui(t.sessions)).catch(()=>Y.error(r(`sessions.order.saveFailed`)))},children:d.map(e=>re?v(e,n):(0,$.jsx)(ki,{sessionId:e.id,sessionDirectory:t.path,sessionTitle:e.title??``,children:v(e,n)},e.id))}),(0,$.jsx)(au,{indent:n,showMore:f>0||m,showFewer:_,loadingMore:h,onShowMore:()=>Xe(i,t.path,u,l.length),onShowFewer:()=>Ke(i)})]})},Qe=(e,t)=>{I(e,!t)},et=(e,t,n)=>{L(`${e}::${t}`,!n)},tt=e=>{gr();let n=Ul(e)||null,r=Zl(Re,n??``);r&&D(r.id),v(e.id,n),t(!1)},at=e=>{H(t=>t===e?null:e)},ct=async e=>{H(null),await y(e.id)?ua({sessionIds:[e.id],message:r(`sessions.sidebar.session.archive.success`),undoLabel:r(`sessions.sidebar.undo`),settingsLabel:r(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:r(`sessions.sidebar.session.archive.undoFailed`)}):Y.error(r(`sessions.sidebar.session.archive.error`))},lt=()=>{T(),t(!1)},ft=e=>{de(e),D(e),le(!0)},pt=e=>{let t=new Map;for(let e of ze){let n=Vl(e);if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n},ht=async e=>{let t=pt(e.id),{archivedIds:n,failedIds:i}=await b(t);n.length>0&&ua({sessionIds:n,message:n.length===1?r(`sessions.sidebar.session.archive.success`):r(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:r(`sessions.sidebar.undo`),settingsLabel:r(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n.length===1?r(`sessions.sidebar.session.archive.undoFailed`):r(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),i.length>0&&Y.error(i.length===1?r(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):r(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}))},_t=e=>{let t=pt(e.id);da({sessionIds:t,message:t.length===1?r(`sessions.sidebar.session.delete.success`):r(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:r(`sessions.sidebar.undo`),commitFailedMessage:r(`sessions.sidebar.session.delete.error`)})},vt=async e=>{try{if(!(await C(e.id))?.share?.url){Y.error(r(`sessions.sidebar.session.share.error`));return}Y.success(r(`sessions.sidebar.session.share.successTitle`),{description:r(`sessions.sidebar.session.share.successDescription`)})}catch{Y.error(r(`sessions.sidebar.session.share.error`))}},yt=async e=>{if((await ot(e)).ok){Y.success(r(`sessions.sidebar.session.menu.copied`));return}Y.error(r(`sessions.sidebar.session.share.copyUrlError`))},xt=async e=>{try{if(await w(e)){Y.success(r(`sessions.sidebar.session.unshare.success`));return}Y.error(r(`sessions.sidebar.session.unshare.error`))}catch{Y.error(r(`sessions.sidebar.session.unshare.error`))}},wt=async()=>{if(!ve)return;let e=be.trim();if(e)try{await x(ve.id,e),ye(null),xe(``)}catch{Y.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},Tt=async()=>{if(!ve||Se)return;let e=ve.id;ye(null),xe(``),Ce(!0);try{await S(e)}catch{Y.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{Ce(!1)}},Et=(e,n)=>{D(e.id),T({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},Dt=e=>{(async()=>{try{await Zr({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=Ot.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await ut(n,ze)})()},kt=e=>{let t=Ul(e),n=Zl(Re,t);if(!n)return Wl(t)||t;let r=Yl(n,Hl(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},At=e=>{E(e.id),t(!1)},jt=Z.useMemo(()=>Be?Ve.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Be)?!0:e.buckets.some(t=>t.sessions.some(t=>Ql(t,e.project.label,Be)))):Ve,[Be,Ve]),Mt=Z.useMemo(()=>Be?ze.filter(e=>{let t=Ul(e);return Ql(e,Zl(Re,t)?.label??``,Be)}).sort((e,t)=>$e(t)-$e(e)):[],[Be,Re,ze]),Nt=Z.useMemo(()=>Be?Re.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Be)).map(e=>({...e,sessionCount:ze.filter(t=>!Vl(t)&&Xl(e,Hl(Ul(t)))).length})):[],[Be,Re,ze]),Pt=Be&&Mt.length===0&&Nt.length===0,It=Re.length>0?(0,$.jsxs)(J,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:lt,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,Rt=Re.find(e=>e.id===m)??null,Bt=Rt?.isGitRepo?(0,$.jsx)(J,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>ft(Rt.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`node-tree`,className:`size-4`})}):null,Vt=(0,$.jsx)(J,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>oe(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folder-add`,className:`size-4`})}),Ht=It||Vt?(0,$.jsxs)($.Fragment,{children:[It,Bt,Vt]}):null,Ut=W?.kind===`project`?W.project.label:W?.kind===`worktree`?W.worktree.branch||W.worktree.label||W.worktree.path:W?.kind===`session`?W.session.title?.trim()||r(`mobile.sessions.untitled`):``,Wt=Z.useMemo(()=>{if(!W)return[];if(W.kind===`project`){let e=W.project;return na({gitRepository:e.isGitRepo,onNewSession:()=>{qe(),Et(e,e.path)},onNewWorktree:()=>{qe(),ft(e.id)},onSyncSessions:()=>{qe(),Dt(e)},onEditProject:()=>{qe(),ne(e.id)},onCloseProject:()=>{qe(),q(e)}})}if(W.kind===`worktree`){let{project:e,worktree:t}=W;return Da({onNewSession:()=>{qe(),Et(e,t.path)},onDeleteWorktree:()=>{qe(),Te({project:e,worktree:t})}})}let e=W.session,t=!!e.share?.url;return ba({pinned:A.has(e.id),shared:t,unread:pe,onToggleRead:me?()=>{qe(),me()}:void 0,onRename:()=>{qe(),xe(e.title?.trim()||r(`mobile.sessions.untitled`)),ye(e)},onTogglePin:()=>{qe(),N(e.id)},onShare:!a||t?void 0:()=>{qe(),vt(e)},onCopyLink:a&&t?()=>{let t=e.share?.url;qe(),t&&yt(t)}:void 0,onUnshare:a&&t?()=>{qe(),xt(e.id)}:void 0,onArchive:()=>{qe(),ht(e)},onDelete:()=>{qe(),_t(e)}})},[W,pe,qe,ht,yt,_t,ft,vt,xt,me,A,Et,Dt,r,N]),Gt=Wt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Wt.map(e=>{let t=(0,$.jsx)(ru,{icon:e.icon,label:ia(e,r),destructive:e.destructive,onClick:e.onClick},e.id);return e.separated?(0,$.jsx)(`div`,{className:W?.kind===`project`?`border-t border-[var(--yuri-popup-divider)]`:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:t},e.id):t})}):null,Kt=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Kn,{value:B,onChange:e=>V(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:it(`h-11 pl-9`,B&&`pr-10`)}),B?(0,$.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":r(`mobile.sessions.clearSearchAria`),onClick:()=>V(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsxs)(Kr,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:[d&&f.registry&&p.map(e=>(0,$.jsx)(ta,{project:e,registry:f.registry,search:B,mobile:!0,reorderEnabled:!1},e.id)),Re.length===0&&!d?(0,$.jsx)(su,{title:r(`mobile.sessions.empty.noProjectsTitle`),description:r(`mobile.sessions.empty.noProjectsDescription`),action:(0,$.jsxs)(J,{type:`button`,size:`lg`,onClick:()=>oe(!0),children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):Pt&&!d?(0,$.jsx)(su,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Be?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 pt-2`,children:[Mt.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.sessions`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:Mt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Mt.map((e,t)=>{let n=Pe.has(e.id),i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:it(t>0&&`border-t border-border/30`),children:(0,$.jsx)(iu,{session:e,active:g===e.id,indent:12,contextLabel:kt(e),highlightQuery:Be,onSelect:()=>Ye(`session:${e.id}`,()=>tt(e)),longPressHandlers:Je({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>Ie(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,Nt.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.projects`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:Nt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Nt.map((e,t)=>{let n=`project:${e.id}`,r=Je({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:it(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:it(`flex min-h-14 min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,r.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(n,()=>At(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)($l,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:rr(e.label,Be)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(nu,{className:`mr-2`,onClick:()=>ft(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:jt.map((e,t)=>{let n=We(e),i=`project:${e.project.id}`,a=Je({key:i,kind:`project`,project:e.project}),o=Be?e.buckets.filter(t=>t.sessions.some(t=>Ql(t,e.project.label,Be))):e.buckets,s=Ue(e);return(0,$.jsxs)(`section`,{className:it(t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`div`,{className:`flex min-h-14 w-full items-center`,children:[(0,$.jsxs)(`button`,{type:`button`,className:it(`flex min-h-14 min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,a.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(i,()=>Qe(e.project.id,n)),onPointerDown:a.onPointerDown,onPointerMove:a.onPointerMove,onPointerUp:a.onPointerUp,onPointerCancel:a.onPointerCancel,onContextMenu:a.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:e.project.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)($l,{project:e.project}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-semibold text-foreground`,children:e.project.label}),Ae.get(e.project.id)?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:Ae.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(tu,{ariaLabel:r(`mobile.sessions.activeProjectAria`)}):null,(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.totalSessions})]}),(()=>{let t=n?[]:[...new Set(e.buckets.flatMap(e=>e.sessions.filter(e=>Pe.has(e.id)).map(e=>e.id)))];return t.length>0?(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] mr-1`,"aria-label":r(`mobile.sessions.stopGroupAria`,{label:e.project.label}),onClick:e=>{e.stopPropagation(),Le(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(ea,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(nu,{className:`mr-2`,onClick:()=>ft(e.project.id)}):null]}),n?(0,$.jsx)(`div`,{className:`pb-2`,children:(()=>{let t=o.find(e=>e.worktree===null),n=o.filter(e=>e.worktree!==null);return(0,$.jsxs)($.Fragment,{children:[t&&(t.sessions.length>0||n.length===0)?Ze(e,t,zl):null,n.map(t=>{let n=Ge(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Je({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:it(`flex min-h-11 w-full items-center gap-2 py-1.5 pl-4 pr-3 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(a,()=>et(e.project.id,t.key,n)),onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onPointerCancel:o.onPointerCancel,onContextMenu:o.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:t.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)(eu,{expanded:n}),(0,$.jsx)(X,{name:`node-tree`,className:it(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:it(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(tu,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>Pe.has(e.id)).map(e=>e.id);return e.length>0?(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":r(`mobile.sessions.stopGroupAria`,{label:t.label}),onClick:t=>{t.stopPropagation(),Le(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(ea,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?Ze(e,t,zl):null]},t.key)})]})})()}):null]},e.project.id)})})]}),(0,$.jsx)(Qi,{open:ae,onOpenChange:oe,forceMobile:!0}),(0,$.jsx)(Rn,{open:se,projectId:ue,onOpenChange:e=>{le(e),e||de(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?v(n.sessionId,e):T({selectedProjectId:ue,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(ir,{open:!!W,title:Ut,onClose:qe,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Gt}),(0,$.jsx)(ir,{open:!!he,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>q(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>q(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!he)return;let e=he;q(null),k(e.id),Y.success(r(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:r(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:r(`mobile.projects.closeConfirmMessage`,{title:he?.label??``})})}),(0,$.jsx)(ir,{open:!!ve,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{Se||(ye(null),xe(``))},footer:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`default`,className:`flex-1`,disabled:Se,onClick:()=>{ye(null),xe(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{type:`button`,variant:`default`,className:`flex-1`,disabled:!be.trim()||Se,onClick:()=>void wt(),children:r(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),wt()},children:[(0,$.jsx)(Kn,{value:be,onChange:e=>xe(e.target.value),autoFocus:!0,className:`h-12`,disabled:Se}),(0,$.jsxs)(J,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:Se,onClick:()=>void Tt(),children:[Se?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),r(`sessions.sidebar.session.rename.smartTitle`)]})]})}),we?(0,$.jsx)(xa,{open:!0,project:{id:we.project.id,path:we.project.path},worktree:we.worktree,onClose:()=>Te(null),onDeleted:()=>U(e=>e+1)}):null,(0,$.jsx)(la,{open:te!==null,project:Re.find(e=>e.id===te)??null,onClose:()=>ne(null),onWorktreesChanged:()=>U(e=>e+1)})]});return n===`sidebar`?e?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsx)(`div`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center justify-end gap-2 px-4`,children:Ht?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:Ht}):null}),Kt]}):null:(0,$.jsx)(br,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:Ht,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:Kt})},su=e=>{let t=(0,Q.c)(10),{title:n,description:r,action:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i?(0,$.jsx)(`div`,{className:`pt-2`,children:i}):null,t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c},cu=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,lu=[{image:Lc,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:Ic,titleKey:`assistants.guide.share.android.title`,descriptionKey:`assistants.guide.share.android.description`},{image:Rc,titleKey:`assistants.guide.share.pick.title`,descriptionKey:`assistants.guide.share.pick.description`}];function uu(){let e=(0,Q.c)(8),{t}=Ee(),n;e[0]===t?n=e[1]:(n=t(`common.loading`),e[0]=t,e[1]=n);let r,i,a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`h-10 w-10 animate-pulse rounded-xl bg-[var(--surface-muted)] motion-reduce:animate-none`}),i=(0,$.jsx)(`div`,{className:`mt-2 h-4 w-2/3 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),a=(0,$.jsx)(`div`,{className:`h-3.5 w-full animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),o=(0,$.jsx)(`div`,{className:`h-3.5 w-4/5 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),e[2]=r,e[3]=i,e[4]=a,e[5]=o):(r=e[2],i=e[3],a=e[4],o=e[5]);let s;return e[6]===n?s=e[7]:(s=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 p-5`,"aria-busy":`true`,"aria-label":n,children:[r,i,a,o]}),e[6]=n,e[7]=s),s}function du(e){let t=(0,Q.c)(35),{onEnable:n}=e,{t:r}=Ee(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`yuri-mobile-assistant-guide-hero`,"aria-hidden":`true`,children:(0,$.jsx)(`img`,{src:cu,alt:``})}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=r(`assistants.guide.disabledTitle`),t[1]=r,t[2]=a);let o;t[3]===a?o=t[4]:(o=(0,$.jsx)(`h2`,{className:`yuri-mobile-assistant-guide-title`,children:a}),t[3]=a,t[4]=o);let s;t[5]===r?s=t[6]:(s=r(`assistants.guide.disabledDescription`),t[5]=r,t[6]=s);let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(`p`,{className:`yuri-mobile-assistant-guide-description`,children:s}),t[7]=s,t[8]=c);let l;t[9]===r?l=t[10]:(l=r(`assistants.guide.enableAction`),t[9]=r,t[10]=l);let u;t[11]!==n||t[12]!==l?(u=(0,$.jsx)(J,{type:`button`,size:`lg`,onClick:n,children:l}),t[11]=n,t[12]=l,t[13]=u):u=t[13];let d;t[14]!==o||t[15]!==c||t[16]!==u?(d=(0,$.jsxs)(`div`,{className:`yuri-mobile-assistant-guide-body`,children:[o,c,u]}),t[14]=o,t[15]=c,t[16]=u,t[17]=d):d=t[17];let f;t[18]===r?f=t[19]:(f=r(`assistants.guide.shareTitle`),t[18]=r,t[19]=f);let p;t[20]===f?p=t[21]:(p=(0,$.jsx)(`h3`,{className:`yuri-mobile-assistant-guide-share-title`,children:f}),t[20]=f,t[21]=p);let m;t[22]===r?m=t[23]:(m=r(`assistants.guide.shareAria`),t[22]=r,t[23]=m);let h;t[24]===r?h=t[25]:(h=lu.map(e=>(0,$.jsxs)(`article`,{className:`yuri-mobile-assistant-guide-step`,children:[(0,$.jsx)(`div`,{className:`yuri-mobile-assistant-guide-step-image`,children:(0,$.jsx)(`img`,{src:e.image,alt:``})}),(0,$.jsxs)(`div`,{className:`yuri-mobile-assistant-guide-step-copy`,children:[(0,$.jsx)(`h4`,{children:r(e.titleKey)}),(0,$.jsx)(`p`,{children:r(e.descriptionKey)})]})]},e.titleKey)),t[24]=r,t[25]=h);let g;t[26]!==m||t[27]!==h?(g=(0,$.jsx)(`div`,{className:`yuri-mobile-assistant-guide-steps`,"aria-label":m,children:h}),t[26]=m,t[27]=h,t[28]=g):g=t[28];let _;t[29]!==p||t[30]!==g?(_=(0,$.jsxs)(`section`,{className:`yuri-mobile-assistant-guide-share`,children:[p,g]}),t[29]=p,t[30]=g,t[31]=_):_=t[31];let v;return t[32]!==_||t[33]!==d?(v=(0,$.jsxs)(`article`,{className:`yuri-mobile-assistant-guide`,children:[i,d,_]}),t[32]=_,t[33]=d,t[34]=v):v=t[34],v}function fu(e){let t=(0,Q.c)(51),{assistant:n,avatarSeed:r,unreadCount:i,assistantID:a,displayName:o,summary:s,editLabel:c,deleteLabel:l,onOpen:u,onEdit:d,onDelete:f,serverWorking:p}=e,m=_i(a,p!==void 0&&p),h=Wi(`assistant:${a}`,u),g=Z.useRef(null),_;t[0]!==c||t[1]!==d?(_={label:c,icon:`edit`,onClick:d},t[0]=c,t[1]=d,t[2]=_):_=t[2];let v;t[3]!==l||t[4]!==f?(v={label:l,icon:`delete-bin`,destructive:!0,onClick:f},t[3]=l,t[4]=f,t[5]=v):v=t[5];let y;t[6]!==_||t[7]!==v?(y=[_,v],t[6]=_,t[7]=v,t[8]=y):y=t[8];let b;t[9]!==h||t[10]!==y?(b=(0,$.jsx)(Ci,{swipe:h,actions:y}),t[9]=h,t[10]=y,t[11]=b):b=t[11];let x=h.dragging?`transition-none`:`transition-transform duration-150 ease-out`,S;t[12]===x?S=t[13]:(S=it(`yuri-mobile-assistant-card relative z-10 motion-reduce:transition-none`,x),t[12]=x,t[13]=S);let C=h.handleSelect,w=h.handlePointerDown,T=h.handlePointerMove,E=h.finishGesture,D=h.handlePointerCancel,O=`translate3d(${h.offset}px, 0, 0)`,k=h.offset===0?void 0:`transform`,A;t[14]!==O||t[15]!==k?(A={touchAction:`pan-y`,transform:O,willChange:k},t[14]=O,t[15]=k,t[16]=A):A=t[16];let j;t[17]!==a||t[18]!==r||t[19]!==o||t[20]!==m?(j=(0,$.jsx)(`span`,{className:`yuri-mobile-assistant-avatar`,children:(0,$.jsx)(vi,{name:a,avatarSeed:r,size:44,label:o,working:m,hoverTarget:g})}),t[17]=a,t[18]=r,t[19]=o,t[20]=m,t[21]=j):j=t[21];let M;t[22]===o?M=t[23]:(M=(0,$.jsx)(`span`,{className:`yuri-mobile-entity-title yuri-mobile-assistant-name block min-w-0 truncate font-semibold text-foreground`,children:o}),t[22]=o,t[23]=M);let N;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(N=it(`yuri-mobile-assistant-summary`,ro),t[24]=N):N=t[24];let P;t[25]===s?P=t[26]:(P=(0,$.jsx)(`span`,{className:N,children:s}),t[25]=s,t[26]=P);let F;t[27]!==M||t[28]!==P?(F=(0,$.jsxs)(`span`,{className:`yuri-mobile-assistant-card-content min-w-0 flex-1`,children:[M,P]}),t[27]=M,t[28]=P,t[29]=F):F=t[29];let I;t[30]===i?I=t[31]:(I=(0,$.jsx)(Xa,{count:i}),t[30]=i,t[31]=I);let L;t[32]!==h.finishGesture||t[33]!==h.handlePointerCancel||t[34]!==h.handlePointerDown||t[35]!==h.handlePointerMove||t[36]!==h.handleSelect||t[37]!==A||t[38]!==j||t[39]!==F||t[40]!==I||t[41]!==S?(L=(0,$.jsxs)(`button`,{ref:g,type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-feedback":`soft`,className:S,onClick:C,onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:D,style:A,children:[j,F,I]}),t[32]=h.finishGesture,t[33]=h.handlePointerCancel,t[34]=h.handlePointerDown,t[35]=h.handlePointerMove,t[36]=h.handleSelect,t[37]=A,t[38]=j,t[39]=F,t[40]=I,t[41]=S,t[42]=L):L=t[42];let R;t[43]!==n||t[44]!==f||t[45]!==d||t[46]!==L?(R=(0,$.jsx)(eo,{assistant:n,onEdit:d,onDelete:f,trigger:L}),t[43]=n,t[44]=f,t[45]=d,t[46]=L,t[47]=R):R=t[47];let ee;return t[48]!==R||t[49]!==b?(ee=(0,$.jsxs)(pi,{className:`yuri-mobile-assistant-card-shell relative isolate overflow-clip`,children:[b,R]}),t[48]=R,t[49]=b,t[50]=ee):ee=t[50],ee}function pu(e){let t=(0,Q.c)(128),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=Ee(),o=$r(),s=ze(),c=Ve();c.data?.assistants;let l;t[0]===c.data?.assistants?l=t[1]:(l=c.data?.assistants??[],t[0]=c.data?.assistants,t[1]=l);let u;t[2]===l?u=t[3]:(u=Za(l),t[2]=l,t[3]=u);let d=u,f=Vt(mu),[p,m]=Z.useState(null),h;t[4]===n?h=t[5]:(h=()=>n(),t[4]=n,t[5]=h);let g=K(h),_;t[6]!==o||t[7]!==f?(_=()=>{f(),o?.openSettings(`assistants`)},t[6]=o,t[7]=f,t[8]=_):_=t[8];let v=K(_),y;t[9]===r?y=t[10]:(y=e=>r(e),t[9]=r,t[10]=y);let b=K(y),x;t[11]===o?x=t[12]:(x=e=>{Ut(e,o?{openMobileSettings:o.openSettings}:void 0)},t[11]=o,t[12]=x);let S=K(x),C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{m(e)},t[13]=C):C=t[13];let w=K(C),T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{e||m(null)},t[14]=T):T=t[14];let E=K(T),D;t[15]===a?D=t[16]:(D=a(`assistants.title`),t[15]=a,t[16]=D);let O=D,k;t[17]===a?k=t[18]:(k=a(`assistants.menu.edit`),t[17]=a,t[18]=k);let A=k,j;t[19]===a?j=t[20]:(j=a(`assistants.settings.delete`),t[19]=a,t[20]=j);let M=j,N;t[21]===i?N=t[22]:(N=it(`yuri-assistant-mobile-catalog-page`,i),t[21]=i,t[22]=N);let P=N;if(s.isPending||s.data?.supported&&s.data.enabled&&c.isPending){let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(pi,{className:`yuri-mobile-assistant-loading`,children:(0,$.jsx)(uu,{})}),t[23]=e):e=t[23];let n;return t[24]!==P||t[25]!==O?(n=(0,$.jsx)(di,{title:O,className:P,surface:!1,children:e}),t[24]=P,t[25]=O,t[26]=n):n=t[26],n}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length>0){let e;t[27]===c.data?e=t[28]:(e=(0,$.jsx)(no,{snapshot:c.data,compact:!0,mobile:!0}),t[27]=c.data,t[28]=e);let n;t[29]===a?n=t[30]:(n=a(`assistants.settings.create`),t[29]=a,t[30]=n);let r;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(X,{name:`add`,className:`size-5`}),t[31]=r):r=t[31];let i;t[32]!==v||t[33]!==n?(i=(0,$.jsx)(J,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:`yuri-mobile-inverse-action`,"aria-label":n,onClick:v,children:r}),t[32]=v,t[33]=n,t[34]=i):i=t[34];let o;t[35]!==e||t[36]!==i?(o=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e,i]}),t[35]=e,t[36]=i,t[37]=o):o=t[37];let s;t[38]===a?s=t[39]:(s=a(`assistants.listAria`),t[38]=a,t[39]=s);let l;t[40]!==d.pinned||t[41]!==S||t[42]!==b||t[43]!==w?(l=(0,$.jsx)(io,{contacts:d.pinned,onSelect:b,onEdit:S,onDelete:w}),t[40]=d.pinned,t[41]=S,t[42]=b,t[43]=w,t[44]=l):l=t[44];let u;if(t[45]!==d.unpinned||t[46]!==M||t[47]!==A||t[48]!==S||t[49]!==b||t[50]!==w||t[51]!==a){let e;t[53]!==M||t[54]!==A||t[55]!==S||t[56]!==b||t[57]!==w||t[58]!==a?(e=e=>{let t=Wt(e.name).displayName||e.name,n=to(e.latestMessagePreview,a);return(0,$.jsx)(fu,{assistant:e,assistantID:e.id,avatarSeed:e.avatarSeed,unreadCount:e.unreadCount??0,displayName:t,summary:n,editLabel:A,deleteLabel:M,assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onOpen:()=>b(e.id),onEdit:()=>S(e.id),onDelete:()=>w(e)},e.id)},t[53]=M,t[54]=A,t[55]=S,t[56]=b,t[57]=w,t[58]=a,t[59]=e):e=t[59],u=d.unpinned.map(e),t[45]=d.unpinned,t[46]=M,t[47]=A,t[48]=S,t[49]=b,t[50]=w,t[51]=a,t[52]=u}else u=t[52];let f;t[60]!==s||t[61]!==l||t[62]!==u?(f=(0,$.jsxs)(`div`,{className:`yuri-mobile-assistant-catalog`,role:`listbox`,"aria-label":s,children:[l,u]}),t[60]=s,t[61]=l,t[62]=u,t[63]=f):f=t[63];let m=p!==null,h;t[64]!==p||t[65]!==E||t[66]!==m?(h=(0,$.jsx)($a,{assistant:p,open:m,onOpenChange:E}),t[64]=p,t[65]=E,t[66]=m,t[67]=h):h=t[67];let g;return t[68]!==P||t[69]!==O||t[70]!==o||t[71]!==f||t[72]!==h?(g=(0,$.jsxs)(di,{title:O,className:P,surface:!1,scrollsWithPage:!0,trailing:o,children:[f,h]}),t[68]=P,t[69]=O,t[70]=o,t[71]=f,t[72]=h,t[73]=g):g=t[73],g}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`yuri-mobile-assistant-onboarding-icon`,children:(0,$.jsx)(X,{name:`ai-agent`,className:`size-5`})}),t[74]=e):e=t[74];let n;t[75]===a?n=t[76]:(n=a(`assistants.onboarding.title`),t[75]=a,t[76]=n);let r;t[77]===n?r=t[78]:(r=(0,$.jsx)(`h2`,{children:n}),t[77]=n,t[78]=r);let i;t[79]===a?i=t[80]:(i=a(`assistants.onboarding.description`),t[79]=a,t[80]=i);let o;t[81]===i?o=t[82]:(o=(0,$.jsx)(`p`,{children:i}),t[81]=i,t[82]=o);let s;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),t[83]=s):s=t[83];let c;t[84]===a?c=t[85]:(c=a(`assistants.onboarding.action`),t[84]=a,t[85]=c);let l;t[86]!==v||t[87]!==c?(l=(0,$.jsxs)(J,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:v,children:[s,c]}),t[86]=v,t[87]=c,t[88]=l):l=t[88];let u;t[89]!==r||t[90]!==o||t[91]!==l?(u=(0,$.jsxs)(pi,{className:`yuri-mobile-assistant-onboarding`,children:[e,r,o,l]}),t[89]=r,t[90]=o,t[91]=l,t[92]=u):u=t[92];let d;return t[93]!==P||t[94]!==O||t[95]!==u?(d=(0,$.jsx)(di,{title:O,className:P,surface:!1,surfaceClassName:`yuri-mobile-assistant-state`,children:u}),t[93]=P,t[94]=O,t[95]=u,t[96]=d):d=t[96],d}let F=s.isSuccess&&s.data.supported===!1,I=s.isError||s.data?.supported===!0&&s.data.enabled&&c.isError,L=s.data?.supported===!0&&(s.data.enabled===!1||c.data?.enabled===!1),R;t[97]!==a||t[98]!==I||t[99]!==F?(R=a(I?`assistants.state.unavailable`:F?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[97]=a,t[98]=I,t[99]=F,t[100]=R):R=t[100];let ee=R;if(L&&!I){let e;t[101]===g?e=t[102]:(e=(0,$.jsx)(du,{onEnable:g}),t[101]=g,t[102]=e);let n;return t[103]!==P||t[104]!==O||t[105]!==e?(n=(0,$.jsx)(di,{title:O,className:P,surface:!1,surfaceClassName:`yuri-mobile-assistant-guide-host`,children:e}),t[103]=P,t[104]=O,t[105]=e,t[106]=n):n=t[106],n}let z;t[107]===O?z=t[108]:(z=(0,$.jsx)(`span`,{className:`yuri-mobile-page-section-label`,children:O}),t[107]=O,t[108]=z);let B=F?`cloud-off`:`sparkling`,V;t[109]===B?V=t[110]:(V=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground`,children:(0,$.jsx)(X,{name:B,weight:`medium`,className:`size-5`})}),t[109]=B,t[110]=V);let te;t[111]===ee?te=t[112]:(te=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:ee}),t[111]=ee,t[112]=te);let ne;t[113]!==a||t[114]!==I||t[115]!==F?(ne=I?null:(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-small leading-relaxed text-muted-foreground`,children:a(F?`assistants.state.unsupportedDescription`:`assistants.state.instanceDisabledDescription`)}),t[113]=a,t[114]=I,t[115]=F,t[116]=ne):ne=t[116];let re;t[117]!==V||t[118]!==te||t[119]!==ne?(re=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[V,te,ne]}),t[117]=V,t[118]=te,t[119]=ne,t[120]=re):re=t[120];let H;t[121]!==z||t[122]!==re?(H=(0,$.jsx)(mi,{label:z,cardClassName:`yuri-mobile-assistant-state-card`,children:re}),t[121]=z,t[122]=re,t[123]=H):H=t[123];let ie;return t[124]!==P||t[125]!==O||t[126]!==H?(ie=(0,$.jsx)(di,{title:O,className:P,surface:!1,surfaceClassName:`yuri-mobile-assistant-state`,children:H}),t[124]=P,t[125]=O,t[126]=H,t[127]=ie):ie=t[127],ie}function mu(e){return e.requestCreate}function hu(e){let t=(0,Q.c)(16),{assistantID:n,onBack:r}=e,{t:i}=Ee(),[a,o]=(0,Z.useState)(null),s;t[0]===i?s=t[1]:(s=i(`assistants.title`),t[0]=i,t[1]=s);let c;t[2]===i?c=t[3]:(c=i(`settings.view.actions.back`),t[2]=i,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`div`,{ref:o}),t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==s||t[7]!==c?(u=(0,$.jsx)(Be,{title:s,backAriaLabel:c,onBack:r,trailing:l}),t[5]=r,t[6]=s,t[7]=c,t[8]=u):u=t[8];let d;t[9]!==n||t[10]!==r||t[11]!==a?(d=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-[var(--yuri-mobile-page-inline-inset)] pb-[var(--yuri-safe-area-bottom,env(safe-area-inset-bottom,0px))]`,children:(0,$.jsx)(pi,{className:`yuri-mobile-settings-detail-card h-full`,children:(0,$.jsx)(sr,{children:(0,$.jsx)(Wa,{assistantID:n,onItemDeleted:r,onSaved:r,saveActionContainer:a},n)})})}),t[9]=n,t[10]=r,t[11]=a,t[12]=d):d=t[12];let f;return t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`div`,{"data-settings-view":`true`,"data-mobile-settings-stage":`page-content`,className:`yuri-settings-workspace yuri-settings-workspace-mobile flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[u,d]}),t[13]=u,t[14]=d,t[15]=f):f=t[15],f}function gu(e){let t=(0,Q.c)(13),{route:n}=e,{t:r}=Ee(),i;t[0]===r?i=t[1]:(i=r(`chat.btw.title`),t[0]=r,t[1]=i);let a;t[2]===r?a=t[3]:(a=r(`header.actions.backAria`),t[2]=r,t[3]=a);let o;t[4]!==i||t[5]!==a?(o=(0,$.jsx)(Be,{title:i,backAriaLabel:a,onBack:_u}),t[4]=i,t[5]=a,t[6]=o):o=t[6];let s;t[7]!==n.directory||t[8]!==n.sessionId?(s=(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(An,{scope:{sessionId:n.sessionId,directory:n.directory},foot:`page`})}),t[7]=n.directory,t[8]=n.sessionId,t[9]=s):s=t[9];let c;return t[10]!==o||t[11]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[o,s]}),t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function _u(){Ir.requestAnimatedBack(`root`)}var vu=[{id:`projects`,icon:`folder-open`,labelKey:`mobile.tabs.projects`},{id:`assistant`,icon:`sparkling`,labelKey:`mobile.tabs.assistant`},{id:`scheduled`,icon:`calendar-schedule`,labelKey:`mobile.tabs.scheduled`},{id:`settings`,icon:`settings-3`,labelKey:`mobile.tabs.settings`}];function yu(e){let t=(0,Q.c)(22),{activeTab:n,onTabChange:r,className:i,tabMarks:a}=e,{t:o}=Ee(),s=He(),c;t[0]===o?c=t[1]:(c=o(`mobile.tabs.activity.loading`),t[0]=o,t[1]=c);let l=c,u;t[2]===r?u=t[3]:(u=e=>{r(e.currentTarget.dataset.tab)},t[2]=r,t[3]=u);let d=K(u),f;t[4]!==n||t[5]!==r?(f=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=vu.findIndex(e=>e.id===n),i=vu[e.key===`Home`?0:e.key===`End`?vu.length-1:(t+(e.key===`ArrowRight`?1:-1)+vu.length)%vu.length];r(i.id),document.getElementById(`mobile-tab-${i.id}`)?.focus()},t[4]=n,t[5]=r,t[6]=f):f=t[6];let p=K(f),m;t[7]===o?m=t[8]:(m=o(`mobile.nav.aria`),t[7]=o,t[8]=m);let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h={role:`tablist`},t[9]=h):h=t[9];let g;t[10]!==n||t[11]!==s||t[12]!==d||t[13]!==p||t[14]!==l||t[15]!==o||t[16]!==a?(g=vu.map(e=>{let t=e.id===n,r=o(e.labelKey),i=e.id===`assistant`&&s>0,c=!i&&a?.[e.id]===`loading`,u=i?`mobile-tab-assistant-unread`:c?`mobile-tab-${e.id}-activity`:void 0;return(0,$.jsxs)(J,{id:`mobile-tab-${e.id}`,"data-tab":e.id,type:`button`,role:`tab`,variant:`ghost`,size:`sm`,"aria-controls":`mobile-tabpanel-${e.id}`,"aria-label":r,"aria-describedby":u,"aria-selected":t,tabIndex:t?0:-1,title:r,onClick:d,onKeyDown:p,className:it(`yuri-mobile-tab-button min-w-0 flex-1 flex-col overflow-visible`,`font-medium leading-none tracking-tight text-muted-foreground`,`transition-[background-color,color,box-shadow,transform] duration-100`,`hover:bg-transparent hover:text-foreground`,`active:bg-interactive-active`,`motion-reduce:transition-none`,t&&[`bg-interactive-selection/55 text-primary`,`hover:bg-interactive-selection/55 hover:text-primary`,`font-semibold`]),children:[(0,$.jsxs)(`span`,{className:`relative inline-flex size-[23px] shrink-0 items-center justify-center overflow-visible`,children:[e.id===`assistant`?(0,$.jsx)(fa,{size:23,className:`size-[23px] shrink-0 items-center justify-center [&[data-assistant-navigation-avatar]]:scale-105`}):(0,$.jsx)(X,{name:e.icon,weight:`medium`,className:`size-[23px] shrink-0`}),u?(0,$.jsx)(`span`,{id:u,role:c?`status`:void 0,"aria-label":c?l:void 0,"data-mobile-tab-activity":c?`loading`:void 0,className:`pointer-events-none absolute left-full -top-1 ml-0.5 inline-flex z-10`,children:i?(0,$.jsx)(Qa,{className:`h-[18px] min-w-[18px] px-1 text-[11px] font-bold tracking-normal ring-2 ring-background`}):(0,$.jsx)(`span`,{className:`inline-flex size-[18px] items-center justify-center rounded-full bg-foreground text-background ring-2 ring-background`,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin`})})}):null]}),(0,$.jsx)(`span`,{className:`yuri-mobile-tab-label block max-w-full overflow-hidden text-ellipsis whitespace-nowrap`,children:r})]},e.id)}),t[10]=n,t[11]=s,t[12]=d,t[13]=p,t[14]=l,t[15]=o,t[16]=a,t[17]=g):g=t[17];let _;return t[18]!==i||t[19]!==m||t[20]!==g?(_=(0,$.jsx)(hi,{as:`nav`,"aria-label":m,variant:`navigation`,surfaceProps:h,className:i,children:g}),t[18]=i,t[19]=m,t[20]=g,t[21]=_):_=t[21],_}function bu(e){return e.unreadCount>0?`unread`:e.working?`loading`:null}var xu=`yuri-native-ios-tab-bar`,Su=`YuriTabBar`,Cu=[`projects`,`assistant`,`scheduled`,`settings`],wu=he(Su),Tu=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function Eu(){return typeof window>`u`?!1:Tu({isCapacitor:g(),platform:y(),pluginAvailable:q.isPluginAvailable(Su),nativeUiEnabled:Or()})}var Du=e=>e.classList.contains(`dark`)?`dark`:`light`,Ou=()=>Ar(`--primary`),ku=e=>typeof e==`string`&&Cu.includes(e),Au=e=>typeof e==`string`&&ku(e)?e:null,ju=(e,t)=>e.selectedTab===t.selectedTab&&e.appearance===t.appearance&&e.ariaLabel===t.ariaLabel&&e.accentColor===t.accentColor&&e.tabs.length===t.tabs.length&&e.tabs.every((e,n)=>e.id===t.tabs[n]?.id&&e.label===t.tabs[n]?.label&&e.badge===t.tabs[n]?.badge&&e.activity===!0==(t.tabs[n]?.activity===!0)&&(e.activity===!0?e.activityLabel??null:null)===(t.tabs[n]?.activity===!0?t.tabs[n]?.activityLabel??null:null)),Mu=(e,t)=>{e.classList.toggle(xu,t)},Nu=(e,t)=>e&&!t,Pu=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&ju(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},Fu=()=>wu,Iu=`mobile-overlay-root`;function Lu(e){let t=(0,Q.c)(28),n=kr(),r;t[0]===n?r=t[1]:(r=n&&Eu(),t[0]=n,t[1]=r);let i=r,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=(0,Z.useRef)(!1),p=(0,Z.useRef)(!1),m=K(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=JSON.stringify(e.tabs.map(zu)),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:Du(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:Ou(),t[5]=y):y=t[5];let b=y,x,S;t[6]===i?(x=t[7],S=t[8]):(x=()=>{if(!i||typeof document>`u`)return;let e=document.getElementById(Iu);e||(e=document.createElement(`div`),e.id=Iu,document.body.appendChild(e));let t=()=>u(Fn(e.children));t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[Pn]}),()=>n.disconnect()},S=[i],t[6]=i,t[7]=x,t[8]=S),(0,Z.useEffect)(x,S);let C;t[9]!==i||t[10]!==m?(C=()=>{if(!i)return;let e=!1,t=Fu(),n=[];return t.addListener(`tabSelected`,e=>{let t=Au(e.tab);t&&m(t)}).then(t=>{if(e){t.remove();return}n.push(t)}),()=>{e=!0,d.current=null,t.hide();for(let e of n)e.remove();typeof document<`u`&&Mu(document.documentElement,!1)}},t[9]=i,t[10]=m,t[11]=C):C=t[11];let w;t[12]===i?w=t[13]:(w=[i],t[12]=i,t[13]=w),(0,Z.useEffect)(C,w);let T;t[14]!==e.activeTab||t[15]!==e.ariaLabel||t[16]!==e.tabs||t[17]!==e.visible||t[18]!==i||t[19]!==l?(T=()=>{if(!i||p.current)return;let t=!1,n=Fu(),r={tabs:e.tabs.map(Ru),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=Pu({visible:Nu(e.visible,l),overlayHidden:f.current,lastState:d.current,nextState:r});return(async()=>{if(a.action===`skip`)return;if(a.action===`hide`){f.current=!0,n.hide();return}let e=await n.present(r);if(!t){if(e.adopted!==!0){p.current=!0,c(!0),o(!1),typeof document<`u`&&Mu(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&Mu(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&Mu(document.documentElement,!1))}),()=>{t=!0}},t[14]=e.activeTab,t[15]=e.ariaLabel,t[16]=e.tabs,t[17]=e.visible,t[18]=i,t[19]=l,t[20]=T):T=t[20];let E;return t[21]!==e.activeTab||t[22]!==e.ariaLabel||t[23]!==e.visible||t[24]!==i||t[25]!==l||t[26]!==g?(E=[i,e.visible,l,e.activeTab,e.ariaLabel,v,b,g],t[21]=e.activeTab,t[22]=e.ariaLabel,t[23]=e.visible,t[24]=i,t[25]=l,t[26]=g,t[27]=E):E=t[27],(0,Z.useLayoutEffect)(T,E),!i||s?`web`:a?`native`:`pending`}function Ru(e){return{id:e.id,label:e.label,badge:e.badge??null,activity:e.activity===!0,activityLabel:e.activity===!0?e.activityLabel??null:null}}function zu(e){return[e.id,e.label,e.badge??null,e.activity===!0,e.activity===!0?e.activityLabel??null:null]}function Bu(e){let t=(0,Q.c)(52),{tabs:n,navigation:r,onTabChange:i,secondaryPages:a,showTabBar:o,tabBarCovered:s,className:c}=e,l=a===void 0?[]:a,u=o===void 0||o,d=s!==void 0&&s,{t:f}=Ee(),p=r.activeTab,m=l.slice(-2),h=m.at(-1)??null,g=h?.key??null,_=h?.depth,v=m.length>1?m[m.length-2].key:null,y;t[0]===p?y=t[1]:(y=()=>new Set([p]),t[0]=p,t[1]=y);let[b,x]=Z.useState(y);b.has(p)||x(e=>{if(e.has(p))return e;let t=new Set(e);return t.add(p),t});let S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(null),T=Z.useRef(new Map),E=Z.useRef(null),D=Z.useRef(!1),O=Z.useRef(``),k=K(()=>h?.onBack());Nr({id:h?`mobile-secondary:${h.key}`:`mobile-secondary:inactive`,active:!!h,onBack:k,surfaceRef:S,underlayRef:C}),Z.useLayoutEffect(()=>{let e=g===null?null:T.current.get(g)??null,t=v===null?w.current:T.current.get(v)??null;S.current=e,C.current=t},[g,_,v]);let A;t[2]===h?A=t[3]:(A=[h],t[2]=h,t[3]=A),Z.useLayoutEffect(()=>{if(h){if(!D.current){let e=document.activeElement;E.current=e instanceof HTMLElement?e:null,D.current=!0}O.current!==h.key&&(O.current=h.key,S.current?.focus());return}if(D.current){D.current=!1,O.current=``;let e=E.current;E.current=null,e&&e.isConnected&&e.focus()}},A);let j;t[4]===i?j=t[5]:(j=e=>{i(e)},t[4]=i,t[5]=j);let M=K(j),N=He(),P=Re(),F=Le(),I;t[6]===f?I=t[7]:(I=f(`mobile.tabs.activity.loading`),t[6]=f,t[7]=I);let L=I,R;t[8]!==N||t[9]!==P?(R=bu({unreadCount:N,working:P}),t[8]=N,t[9]=P,t[10]=R):R=t[10];let ee=R,z;t[11]===F?z=t[12]:(z=bu({unreadCount:0,working:F}),t[11]=F,t[12]=z);let B=z,V;t[13]!==ee||t[14]!==N||t[15]!==L||t[16]!==B||t[17]!==f?(V=vu.map(e=>{let t=e.id===`assistant`&&ee===`loading`||e.id===`scheduled`&&B===`loading`;return{id:e.id,label:f(e.labelKey),badge:e.id===`assistant`&&ee===`unread`?N>99?`99+`:String(N):null,activity:t,activityLabel:t?L:null}}),t[13]=ee,t[14]=N,t[15]=L,t[16]=B,t[17]=f,t[18]=V):V=t[18];let te=V,ne=u&&!d&&!h,re;t[19]===f?re=t[20]:(re=f(`mobile.nav.aria`),t[19]=f,t[20]=re);let H;t[21]!==M||t[22]!==ne||t[23]!==te||t[24]!==p||t[25]!==re?(H={visible:ne,activeTab:p,tabs:te,ariaLabel:re,onTabChange:M},t[21]=M,t[22]=ne,t[23]=te,t[24]=p,t[25]=re,t[26]=H):H=t[26];let ie=Lu(H),U=ie===`native`,ae=u&&ie===`web`,oe=kr(),se,ce;t[27]!==oe||t[28]!==U?(se=()=>{if(!oe){Fr.shutdown();return}U&&jr(!0)&&Fr.warm()},ce=[oe,U],t[27]=oe,t[28]=U,t[29]=se,t[30]=ce):(se=t[29],ce=t[30]),Z.useEffect(se,ce);let le=p===`assistant`&&`yuri-assistant-wallpaper`,ue;t[31]!==c||t[32]!==le?(ue=it(`yuri-mobile-floating-shell relative isolate flex h-full min-h-0 flex-col overflow-hidden text-foreground`,`bg-[var(--yuri-mobile-page-background)]`,le,c),t[31]=c,t[32]=le,t[33]=ue):ue=t[33];let de=h?!0:void 0,W=h?!0:void 0,fe=h?`true`:void 0,G;t[34]!==p||t[35]!==u||t[36]!==ae||t[37]!==f||t[38]!==n||t[39]!==b?(G=vu.map(e=>{let t=b.has(e.id);return(0,$.jsx)(`section`,{id:`mobile-tabpanel-${e.id}`,role:`tabpanel`,"aria-labelledby":ae?`mobile-tab-${e.id}`:void 0,"aria-label":ae?void 0:f(e.labelKey),hidden:p!==e.id,tabIndex:0,className:it(`scrollbar-none h-full min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--yuri-mobile-page-inline-inset)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+1rem)] outline-none`,u?`pb-[calc(var(--yuri-mobile-dock-height)+2.5rem+var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px)))]`:`pb-0`),children:t?n?.[e.id]??(0,$.jsx)(Vu,{tab:e.id,icon:e.icon}):null},e.id)}),t[34]=p,t[35]=u,t[36]=ae,t[37]=f,t[38]=n,t[39]=b,t[40]=G):G=t[40];let pe=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||U?!0:void 0,inert:h||U?!0:void 0,children:ae?(0,$.jsx)(yu,{activeTab:p,onTabChange:M,tabMarks:{assistant:ee===`loading`?`loading`:null,scheduled:B===`loading`?`loading`:null}}):null}):null,me;t[41]!==w||t[42]!==de||t[43]!==W||t[44]!==fe||t[45]!==G||t[46]!==pe?(me=(0,$.jsxs)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":de,inert:W,"data-mobile-navigation-parked":fe,className:`flex h-full min-h-0 flex-1 flex-col`,children:[G,pe]}),t[41]=w,t[42]=de,t[43]=W,t[44]=fe,t[45]=G,t[46]=pe,t[47]=me):me=t[47];let he=m.map((e,t)=>{let n=t===m.length-1;return(0,$.jsx)(`div`,{ref:t=>{t?T.current.set(e.key,t):T.current.delete(e.key)},"data-mobile-secondary-page":`true`,"data-mobile-secondary-active":n?`true`:`false`,role:n?`dialog`:void 0,"aria-modal":n?!0:void 0,"aria-label":n?e.ariaLabel??f(`mobile.nav.secondaryPageAria`):void 0,"aria-hidden":!n||void 0,inert:!n||void 0,tabIndex:n?-1:void 0,className:it(`absolute inset-0 flex h-full min-h-0 flex-col overflow-hidden bg-background outline-none`,n?`z-50`:`z-40`),children:e.content},e.key)}),q;return t[48]!==ue||t[49]!==me||t[50]!==he?(q=(0,$.jsxs)(`div`,{className:ue,children:[me,he]}),t[48]=ue,t[49]=me,t[50]=he,t[51]=q):q=t[51],q}function Vu(e){let t=(0,Q.c)(17),{tab:n,icon:r,className:i}=e,{t:a}=Ee(),o,s,c,l;if(t[0]!==i||t[1]!==r||t[2]!==a||t[3]!==n){let e=vu.find(e=>e.id===n)??vu[0];t[8]===i?c=t[9]:(c=it(`flex min-h-[70dvh] flex-col items-center justify-center gap-3 text-center`,i),t[8]=i,t[9]=c),l=(0,$.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:r??e.icon,className:`size-6`})}),o=`typography-ui-label font-semibold tracking-[-0.01em] text-foreground`,s=a(e.labelKey),t[0]=i,t[1]=r,t[2]=a,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];let u;t[10]!==o||t[11]!==s?(u=(0,$.jsx)(`h1`,{className:o,children:s}),t[10]=o,t[11]=s,t[12]=u):u=t[12];let d;return t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:c,children:[l,u]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}var Hu=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function Uu({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,onRemoteDesktop:a,instanceOptions:o,className:s}){let{t:c}=Ee(),{git:l}=ce(),u=bt(),d=Aa(),[f,p]=Z.useState(()=>new Map),m=K((e,t)=>{p(n=>{if(!t.length&&!n.has(e))return n;let r=new Map(n);return t.length?r.set(e,t):r.delete(e),r})}),g=K((e,t,n,r)=>{let i=dt.getState(),a=e===`__pinned__`?e:h(e);if(!a||a!==`__pinned__`&&i.getSessionFolderId(a,n)!==i.getSessionFolderId(a,r))return;let o=a===`__pinned__`?{}:Ui(d.allSessions.filter(e=>Ea(e)===a));i.reorderSessions(a,t,n,r,o).catch(()=>Y.error(c(`sessions.order.saveFailed`)))}),_=Ti(e=>e.setProjectExpanded),v=Ti(e=>e.setWorktreeExpanded),y=zt(),b=mt(),x=Ot(e=>e.archiveSessions),S=Ot(e=>e.updateSessionTitle),C=Ot(e=>e.requestSessionSmartTitle),w=Ot(e=>e.shareSession),T=Ot(e=>e.unshareSession),E=Ot(e=>e.openNewSessionDraft),D=jt(e=>e.openDraft),O=jt(e=>e.openSession),k=st(e=>e.projects),A=Ke(e=>e.projectSortOrder),j=zi(),M=Z.useMemo(()=>k.filter(e=>e.hostId).map(Jt),[k]),N=Z.useMemo(()=>[...d.inProgressSessions.map(e=>({session:e,time:d.sessionById.get(e.id)?$e(d.sessionById.get(e.id)):0})),...M.flatMap(e=>f.get(e.id)??[]).map(e=>({session:{id:e.identity,title:e.node.session.title||``,content:e.content},time:$e(e.node.session)}))].sort((e,t)=>t.time-e.time).map(e=>e.session),[d.inProgressSessions,d.sessionById,M,f]),P=st(e=>e.setActiveProjectIdOnly),F=st(e=>e.removeProject),I=vn(),[L,R]=Z.useState(null),[ee,z]=Z.useState(!1),[B,V]=Z.useState(null),[te,ne]=Z.useState(null),[re,H]=Z.useState(null),[ie,U]=Z.useState(``),[ae,oe]=Z.useState(!1),[se,le]=Z.useState(!1),[ue,de]=Z.useState(null),[W,fe]=Z.useState(null),[G,pe]=Z.useState(null),me=L?.kind===`session`?L.session.id:``,he=kt(me),q=he?.type===`busy`||he?.type===`retry`,ge=L?.kind===`session`?Ea(L.session):``,{unread:_e,onToggleRead:ve}=pa(L?.kind===`session`?L.session:null,ge),ye=!!me&&G===me,be=!ge||ye||q,xe=K(e=>{let t=new Map;for(let e of d.allSessions){let n=ya(e);if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n}),Se=K(()=>{z(!1),R(null)}),Ce=K(t=>{if(ra(t.id)){let e=ma(t.id);if(!e)return;e.kind===`more`?d.showMoreBucketSessions(e.projectId,e.bucketKey):d.resetBucketVisibleCount(e.projectId,e.bucketKey);return}let n=d.sessionById.get(t.id),r=n&&Ea(n)||null;e({sessionId:t.id,directory:r})}),we=K(e=>{ra(e.id)||y(e.id)}),Te=K(async e=>{if(ra(e.id))return;let t=xe(e.id),{archivedIds:n,failedIds:r}=await x(t);n.length>0&&ua({sessionIds:n,message:n.length===1?c(`sessions.sidebar.session.archive.success`):c(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:c(`sessions.sidebar.undo`),settingsLabel:c(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n.length===1?c(`sessions.sidebar.session.archive.undoFailed`):c(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&Y.error(r.length===1?c(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):c(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}),De=K(()=>{if(!L||L.kind!==`session`)return;let e=L.session,t=Ea(e),n=he?.type??`idle`;!t||G===e.id||n===`busy`||n===`retry`||(pe(e.id),(async()=>{try{await I.refreshSessionTranscript(e.id,{directory:t}),Y.success(c(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{Y.error(c(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{pe(t=>t===e.id?null:t)}})())}),Oe=K(e=>{if(ra(e.id))return;let t=d.sessionById.get(e.id);t&&(R({kind:`session`,session:t}),z(!0))}),ke=K(e=>{_(e.id,!e.expanded)}),Ae=K((e,t)=>{v(`${e.id}::${t.id}`,!t.expanded)}),je=K((e,t)=>{P(e.id),D({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),Me=K(()=>{let e=st.getState().getActiveProject();if(e?.hostId){gi(Jt(e),!0).catch(e=>Y.error(e instanceof Error?e.message:String(e)));return}if(n){n();return}E()}),Ne=K(e=>{let t=d.projectMetaById.get(e.id);t&&(R({kind:`project`,project:t,isGitRepository:!1}),z(!0),l.checkIsGitRepository(t.path).then(e=>{R(n=>Hu(n,t.id,e))}).catch(()=>{R(e=>Hu(e,t.id,!1))}))}),Pe=K((e,t)=>{let n=h(t);return n?e.worktrees.find(e=>h(e.path)===n)||((Ot.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>h(e.path)===n)??null):null}),Fe=K((e,t)=>{let n=d.projectMetaById.get(e.id);n&&je(n,t.path)}),Ie=K((e,t)=>{let n=d.projectMetaById.get(e.id);n&&(R({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),z(!0))}),Le=K((e,t)=>{let n=d.projectMetaById.get(e.id);if(!n)return;let r=Pe(n,t.path);if(!r){Y.error(c(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}fe({project:n,worktree:r})}),Re=K(e=>{de(e),P(e),le(!0)}),ze=K(e=>{(async()=>{let t=e.worktrees;try{t=(await Zr({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=Ot.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await ut([e.path,...t.map(e=>e.path)],d.allSessions)})()}),Be=K((e,t)=>{let n=ue;if(le(!1),de(null),t?.sessionId){O({sessionId:t.sessionId,directory:e});return}D({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),Ve=K(async e=>{try{if(!(await w(e.id))?.share?.url){Y.error(c(`sessions.sidebar.session.share.error`));return}Y.success(c(`sessions.sidebar.session.share.successTitle`),{description:c(`sessions.sidebar.session.share.successDescription`)})}catch{Y.error(c(`sessions.sidebar.session.share.error`))}}),He=K(async e=>{if((await ot(e)).ok){Y.success(c(`sessions.sidebar.session.menu.copied`));return}Y.error(c(`sessions.sidebar.session.share.copyUrlError`))}),Ue=K(async e=>{try{if(await T(e)){Y.success(c(`sessions.sidebar.session.unshare.success`));return}Y.error(c(`sessions.sidebar.session.unshare.error`))}catch{Y.error(c(`sessions.sidebar.session.unshare.error`))}}),We=K(e=>{let t=xe(e.id);da({sessionIds:t,message:t.length===1?c(`sessions.sidebar.session.delete.success`):c(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:c(`sessions.sidebar.undo`),commitFailedMessage:c(`sessions.sidebar.session.delete.error`)})}),Ge=K(async()=>{if(!re)return;let e=ie.trim();if(e)try{await S(re.id,e),H(null),U(``)}catch{Y.error(c(`sessions.sidebar.session.menu.rename`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),qe=K(async()=>{if(!re||ae)return;let e=re.id;H(null),U(``),oe(!0);try{await C(e)}catch{Y.error(c(`sessions.sidebar.session.rename.smartTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{oe(!1)}}),Je=Z.useMemo(()=>L?L.kind===`session`?{kind:`session`,title:L.session.title?.trim()||c(`mobile.sessions.untitled`),pinned:b.has(L.session.id),shared:!!L.session.share?.url,unread:_e}:L.kind===`project`?{kind:`project`,title:L.project.label,gitRepository:L.isGitRepository}:{kind:`worktree`,title:L.worktreeName}:null,[L,_e,b,c]),Ye=Z.useMemo(()=>{if(!L)return{};if(L.kind===`session`){let e=L.session;return{onRename:()=>{U(e.title?.trim()||c(`mobile.sessions.untitled`)),H(e)},onTogglePin:()=>y(e.id),onToggleRead:ve,onShare:u&&!e.share?.url?()=>{Ve(e)}:void 0,onCopyLink:u&&e.share?.url?()=>{He(e.share.url)}:void 0,onUnshare:u&&e.share?.url?()=>{Ue(e.id)}:void 0,onRefreshTranscript:De,onArchive:()=>{Te({id:e.id,title:e.title?.trim()||c(`mobile.sessions.untitled`)})},onDelete:()=>We(e)}}if(L.kind===`project`){let e=L.project;return{onNewSession:()=>je(e,e.path),onNewWorktree:()=>Re(e.id),onSyncSessions:()=>ze(e),onEditProject:()=>V(e.id),onCloseProject:()=>ne(e)}}let{project:e,worktreePath:t}=L;return{onNewSession:()=>je(e,t),onDeleteWorktree:()=>{let n=Pe(e,t);if(!n){Y.error(c(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}fe({project:e,worktree:n})}}},[L,Te,He,We,De,Re,ze,Ve,Ue,ve,Pe,u,je,c,y]),Xe=Z.useMemo(()=>{if(!B)return null;let e=k.find(e=>e.id===B),t=d.projectMetaById.get(B);if(!e||!t)return null;let n=L?.kind===`project`&&L.project.id===B?L.isGitRepository:t.worktrees.length>0;return{id:e.id,label:e.label?.trim()||t.label,path:h(e.path)||t.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:n,worktrees:t.worktrees}},[L,B,d.projectMetaById,k]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ca,{remoteProjects:M,hostRegistry:j.registry,projectOrderIds:aa(k,A).map(e=>e.id),renderRemoteProject:j.registry?e=>(0,$.jsx)(ta,{project:e,registry:j.registry,mobile:!0,reorderEnabled:!1,onActivityItems:m}):void 0,remoteError:j.catalog.error?.message,className:s,projects:d.projects,pinnedSessions:d.pinnedSessions,inProgressSessions:N,onAddProject:t,onNewSession:Me,onScanQr:r,onSwitchInstance:i,instanceOptions:o,onRemoteDesktop:a,onToggleProject:ke,onOpenProjectActions:Ne,onToggleWorktree:Ae,onNewWorktreeSession:Fe,onOpenWorktreeActions:Ie,onDeleteWorktree:Le,onSelectSession:Ce,onPinSession:we,onArchiveSession:e=>{Te(e)},onOpenSessionActions:Oe,onReorderSessions:g}),(0,$.jsx)(Ma,{open:ee,target:Je,actions:Ye,refreshTranscriptDisabled:be,refreshTranscriptSpinning:ye,onOpenChange:e=>{e?z(!0):Se()}}),(0,$.jsx)(Rn,{open:se,projectId:ue,onOpenChange:e=>{le(e),e||de(null)},onWorktreeCreated:Be}),W?(0,$.jsx)(xa,{open:!0,project:{id:W.project.id,path:W.project.path},worktree:W.worktree,onClose:()=>fe(null)}):null,(0,$.jsx)(ir,{open:!!te,title:c(`sessions.sidebar.project.actions.closeProject`),onClose:()=>ne(null),closeAriaLabel:c(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>ne(null),children:c(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!te)return;let e=te;ne(null),F(e.id),Y.success(c(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:c(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:c(`mobile.projects.closeConfirmMessage`,{title:te?.label??``})})}),(0,$.jsx)(ir,{open:!!re,title:c(`sessions.sidebar.session.menu.rename`),onClose:()=>{ae||(H(null),U(``))},closeAriaLabel:c(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`default`,className:`flex-1`,disabled:ae,onClick:()=>{H(null),U(``)},children:c(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{type:`button`,variant:`default`,className:`flex-1`,disabled:!ie.trim()||ae,onClick:()=>void Ge(),children:c(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),Ge()},children:[(0,$.jsx)(Kn,{value:ie,onChange:e=>U(e.target.value),autoFocus:!0,className:`h-12`,disabled:ae}),(0,$.jsxs)(J,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:ae,onClick:()=>void qe(),children:[ae?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),c(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(la,{open:B!==null,project:Xe,onClose:()=>V(null)})]})}function Wu(e){let t=(0,Q.c)(10),{children:n,content:r,className:i,contentClassName:a,showHeader:o}=e,s=o===void 0||o,{t:c}=Ee(),l;t[0]===c?l=t[1]:(l=c(`sessions.scheduledTasks.dialog.title`),t[0]=c,t[1]=l);let u;t[2]===a?u=t[3]:(u=it(`yuri-mobile-scheduled-content`,a),t[2]=a,t[3]=u);let d=n??r,f;return t[4]!==i||t[5]!==s||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,$.jsx)(di,{title:l,className:i,surface:!1,scrollsWithPage:!0,showHeader:s,surfaceClassName:u,children:d}),t[4]=i,t[5]=s,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function Gu(e){let t=(0,Q.c)(10),{className:n,contentClassName:r,instancesPage:i}=e,{t:a}=Ee(),o;t[0]===a?o=t[1]:(o=a(`mobile.settings.placeholder.title`),t[0]=a,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=[...fr],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(Ga,{forceMobile:!0,isWindowed:!0,hideMobileHeader:!0,flowMobile:!0,autoOpenMobilePage:!0,visiblePageSlugs:s,mobileInstancesPage:i}),t[3]=i,t[4]=c);let l;return t[5]!==n||t[6]!==r||t[7]!==o||t[8]!==c?(l=(0,$.jsx)(di,{title:o,className:n,surface:!1,scrollsWithPage:!0,showHeader:!1,surfaceClassName:r,children:c}),t[5]=n,t[6]=r,t[7]=o,t[8]=c,t[9]=l):l=t[9],l}function Ku(e){let t=(0,Q.c)(115),{onAddProject:n,onScanQr:r,onSwitchInstance:i,onRemoteDesktop:a,remoteDesktopActive:o,instanceOptions:s,onEnableAssistants:c,instancesPage:l,instancesSecondaryPage:u,parentSessionTarget:d,registerSecondaryBackHandler:f,scheduledContent:p,renderChat:m,className:g}=e,_=o!==void 0&&o,v=d===void 0?null:d,{t:y}=Ee(),b=_e(fd),x=jt(),S=jt(dd),C=jt(ud),w=jt(ld),T=jt(cd),E=jt(sd),D=jt(od),O=jt(ad),k=jt(id),A=jt(rd),j=jt(nd),M=jt(td),N=jt(ed),P;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(P=[],t[0]=P):P=t[0],Z.useEffect($u,P);let F=x.secondary?.kind===`chat`?x.secondary.btw??null:null,I=Z.useRef(null),L,R;t[1]===F?(L=t[2],R=t[3]):(L=()=>{let e=I.current;I.current=F,e&&e!==F&&Hn.getState().clear({sessionId:e.sessionId,directory:e.directory}),F?gn(fn):hn(fn)},R=[F],t[1]=F,t[2]=L,t[3]=R),Z.useEffect(L,R);let ee;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(ee=[],t[4]=ee):ee=t[4],Z.useEffect(Zu,ee);let z;t[5]===S?z=t[6]:(z=e=>{e===`settings`&&_e.getState().setSettingsPage(`home`),S(e)},t[5]=S,t[6]=z);let B=K(z),V;t[7]===C?V=t[8]:(V=e=>{C(e)},t[7]=C,t[8]=V);let te=K(V),ne;t[9]===O?ne=t[10]:(ne=()=>{O()},t[9]=O,t[10]=ne);let re=K(ne),H;t[11]===w?H=t[12]:(H=()=>{w()},t[11]=w,t[12]=H);let ie=K(H),U;t[13]===T?U=t[14]:(U=e=>{T(e)},t[13]=T,t[14]=U);let ae=K(U),oe=Z.useRef(null),[se,ce]=Z.useState(!1),le;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(le=e=>{oe.current=e},t[15]=le):le=t[15];let ue=K(le),de;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>{ce(e)},t[16]=de):de=t[16];let W=K(de),fe;t[17]!==re||t[18]!==v||t[19]!==D||t[20]!==N||t[21]!==k?(fe=()=>{if(oe.current?.())return!0;let e=jt.getState().secondary;return e?.kind===`chat`&&e.btw?(N(),!0):e?.kind===`assistant`&&e.settingsAssistantID?(D(),!0):(e?.kind===`draft`||e?.kind===`chat`)&&v?.onSelect?(v.onSelect(),!0):e?.kind===`chat`&&e.routes.length>1?(k(),!0):e?(re(),!0):!1},t[17]=re,t[18]=v,t[19]=D,t[20]=N,t[21]=k,t[22]=fe):fe=t[22];let G=K(fe),pe=x.secondary!==null,me;t[23]!==G||t[24]!==f?(me=()=>{if(f)return f(()=>G()),()=>f(null)},t[23]=G,t[24]=f,t[25]=me):me=t[25];let he;t[26]!==G||t[27]!==f||t[28]!==pe?(he=[f,pe,G],t[26]=G,t[27]=f,t[28]=pe,t[29]=he):he=t[29],Z.useEffect(me,he);let q=Ot(Xu),ge=ct(Yu),ve;t[30]===q?ve=t[31]:(ve=e=>q?e.getDirectoryForSession(q):null,t[30]=q,t[31]=ve);let ye=Ot(ve),be,xe;t[32]!==ye||t[33]!==q||t[34]!==j||t[35]!==ge||t[36]!==M?(be=()=>{let e=jt.getState().secondary;if(ge)return;if(e?.kind===`draft`&&q){j({sessionId:q,directory:ye});return}if(e?.kind!==`chat`||!q||Nt({sessionId:q,directory:ye})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==q||h(t.directory)!==h(ye))&&M({sessionId:q,directory:ye})},xe=[ye,q,j,M,ge],t[32]=ye,t[33]=q,t[34]=j,t[35]=ge,t[36]=M,t[37]=be,t[38]=xe):(be=t[37],xe=t[38]),Z.useEffect(be,xe);let Se,Ce;t[39]!==q||t[40]!==v||t[41]!==A||t[42]!==ge?(Se=()=>{let e=jt.getState().secondary;if(e?.kind!==`chat`||!v||v.onSelect||ge)return;let t=e.routes.at(-1);!t||t.sessionId!==q||A({sessionId:v.id,directory:v.directory})},Ce=[q,v,A,ge],t[39]=q,t[40]=v,t[41]=A,t[42]=ge,t[43]=Se,t[44]=Ce):(Se=t[43],Ce=t[44]),Z.useEffect(Se,Ce);let we;t[45]!==W||t[46]!==ue||t[47]!==p?(we=typeof p==`function`?p(ue,W):p,t[45]=W,t[46]=ue,t[47]=p,t[48]=we):we=t[48];let Te=we,De;t[49]!==ie||t[50]!==s||t[51]!==n||t[52]!==a||t[53]!==r||t[54]!==i||t[55]!==te?(De=(0,$.jsx)(Uu,{onOpenChat:te,onAddProject:n,onNewSession:ie,onScanQr:r,onSwitchInstance:i,onRemoteDesktop:a,instanceOptions:s}),t[49]=ie,t[50]=s,t[51]=n,t[52]=a,t[53]=r,t[54]=i,t[55]=te,t[56]=De):De=t[56];let Oe;t[57]!==c||t[58]!==ae?(Oe=(0,$.jsx)(pu,{onEnable:c,onOpenAssistant:ae}),t[57]=c,t[58]=ae,t[59]=Oe):Oe=t[59];let ke;t[60]===Te?ke=t[61]:(ke=(0,$.jsx)(Wu,{showHeader:!1,children:Te}),t[60]=Te,t[61]=ke);let Ae;t[62]===l?Ae=t[63]:(Ae=(0,$.jsx)(Gu,{instancesPage:l}),t[62]=l,t[63]=Ae);let je;t[64]!==De||t[65]!==Oe||t[66]!==ke||t[67]!==Ae?(je={projects:De,assistant:Oe,scheduled:ke,settings:Ae},t[64]=De,t[65]=Oe,t[66]=ke,t[67]=Ae,t[68]=je):je=t[68];let Me=je,Ne=x.secondary?.kind??null,Pe;bb0:{if(!Ne){Pe=null;break bb0}let e;t[69]!==G||t[70]!==E||t[71]!==y?(e=e=>({key:`assistant-secondary`,depth:1,ariaLabel:y(`assistants.title`),onBack:G,content:(0,$.jsx)(ao,{activeOverride:e,onMobileBack:Ju,onMobileOpenSettings:E})}),t[69]=G,t[70]=E,t[71]=y,t[72]=e):e=t[72];let n=e;if(Ne===`assistant`){let e=x.secondary?.kind===`assistant`?x.secondary.settingsAssistantID:void 0,r=!e,i;t[73]!==n||t[74]!==r?(i=n(r),t[73]=n,t[74]=r,t[75]=i):i=t[75];let a;t[76]!==G||t[77]!==e||t[78]!==y?(a=e?[{key:`assistant-settings:${e}`,depth:2,ariaLabel:y(`assistants.conversation.openSettings`),onBack:G,content:(0,$.jsx)(hu,{assistantID:e,onBack:qu})}]:[],t[76]=G,t[77]=e,t[78]=y,t[79]=a):a=t[79];let o;t[80]!==i||t[81]!==a?(o=[i,...a],t[80]=i,t[81]=a,t[82]=o):o=t[82],Pe=o;break bb0}if(Ne===`instances`){let e;t[83]===y?e=t[84]:(e=y(`mobile.settings.switchInstance`),t[83]=y,t[84]=e);let n;t[85]!==G||t[86]!==u||t[87]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:G,content:u}],t[85]=G,t[86]=u,t[87]=e,t[88]=n):n=t[88],Pe=n;break bb0}if(x.secondary?.kind===`draft`){let e;t[89]===y?e=t[90]:(e=y(`mobile.nav.secondaryPageAria`),t[89]=y,t[90]=e);let n;t[91]===m?n=t[92]:(n=m({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[91]=m,t[92]=n);let r;t[93]!==G||t[94]!==e||t[95]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:G,content:n}],t[93]=G,t[94]=e,t[95]=n,t[96]=r):r=t[96],Pe=r;break bb0}if(x.secondary?.kind!==`chat`){let e;t[97]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[97]=e):e=t[97],Pe=e;break bb0}let r=x.secondary.routes,i;if(t[98]!==n||t[99]!==G||t[100]!==x.secondary.btw||t[101]!==x.secondary.returnTo||t[102]!==m||t[103]!==r||t[104]!==y){let e=x.secondary.returnTo?[n(!1)]:[],a=x.secondary.btw,o=r.slice(a?-1:-2),s=r.length-o.length+1+e.length,c=o.map((e,t)=>{let n=!a&&t===o.length-1;return{key:e.key,depth:s+t,ariaLabel:y(`mobile.nav.secondaryPageAria`),onBack:G,content:m({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:n})}});i=a?[...e,...c,{key:`chat-btw`,depth:r.length+1+e.length,ariaLabel:y(`chat.btw.title`),onBack:G,content:(0,$.jsx)(gu,{route:a})}]:[...e,...c],t[98]=n,t[99]=G,t[100]=x.secondary.btw,t[101]=x.secondary.returnTo,t[102]=m,t[103]=r,t[104]=y,t[105]=i}else i=t[105];Pe=i}let Fe=Pe,Ie;t[106]===Fe?Ie=t[107]:(Ie=Fe??[],t[106]=Fe,t[107]=Ie);let Le=se||b||_,Re;return t[108]!==g||t[109]!==x||t[110]!==B||t[111]!==Ie||t[112]!==Le||t[113]!==Me?(Re=(0,$.jsx)(Bu,{className:g,navigation:x,onTabChange:B,tabs:Me,secondaryPages:Ie,tabBarCovered:Le}),t[108]=g,t[109]=x,t[110]=B,t[111]=Ie,t[112]=Le,t[113]=Me,t[114]=Re):Re=t[114],Re}function qu(){Ir.requestAnimatedBack(`root`)}function Ju(){return Ir.requestAnimatedBack(`root`)}function Yu(e){return e.remoteSession}function Xu(e){return e.currentSessionId}function Zu(){return Qu}function Qu(){return hn(fn)}function $u(){return Dt()}function ed(e){return e.popBtw}function td(e){return e.replaceChatSession}function nd(e){return e.materializeDraftSession}function rd(e){return e.reconcileChatPredecessor}function id(e){return e.popChatSession}function ad(e){return e.closeSecondary}function od(e){return e.popAssistantSettings}function sd(e){return e.pushAssistantSettings}function cd(e){return e.openAssistant}function ld(e){return e.openDraft}function ud(e){return e.openSession}function dd(e){return e.setActiveTab}function fd(e){return e.isCommandPaletteOpen}function pd(e){let t=!1,n=0,r=0,i=!1,a,o,c,u=()=>e.transport===l()&&e.generation===d(),f=()=>document.visibilityState===`hidden`,p=()=>{r++;let e=a;a=void 0,clearTimeout(o),o=void 0,e?.close()},m=n=>{t||(t=!0,p(),x(),window.removeEventListener(`online`,_),window.removeEventListener(`pageshow`,y),window.removeEventListener(`yuri:system-resume`,v),document.removeEventListener(`visibilitychange`,b),e.onState(`closed`,n))},h=()=>{if(t||f())return;let e=navigator.onLine===!1||c===`permission_required`?6e4:Math.min(1e3*2**Math.min(n++,5),3e4);o=setTimeout(()=>{o=void 0,g()},e)},g=()=>{if(t||a||f())return;if(!u()){m(`runtime_changed`);return}if(clearTimeout(o),o=void 0,navigator.onLine===!1){h();return}let s=++r;a=md({...e,onState:(i,o)=>{if(!(t||s!==r)){if(i===`closed`){if(a=void 0,c=o,!o||[`runtime_changed`,`disabled`,`unsupported`,`helper_unavailable`,`authentication_required`,`permission_denied`].includes(o)){m(o);return}e.onState(i,o),h();return}(i===`webrtc`||i===`tunnel`)&&(n=0,c=void 0),e.onState(i,o)}}}),a.setZoomed(i)},_=()=>{!t&&!f()&&!a&&g()},v=()=>{t||(p(),_())},y=e=>{e.persisted&&v()},b=()=>{f()?(p(),e.onState(`connecting`,void 0)):_()},x=s(()=>m(`runtime_changed`));return window.addEventListener(`online`,_),window.addEventListener(`pageshow`,y),window.addEventListener(`yuri:system-resume`,v),document.addEventListener(`visibilitychange`,b),g(),{send:e=>{!t&&u()&&a?.send(e)},close:()=>m(),setZoomed:e=>{i=e,a?.setZoomed(e)}}}function md(e){let t=!1,n,i,a=!1,o,s,u=setTimeout(()=>E(`connection_failed`),6e4),f,p=Date.now(),m,h,g=!1,_=!1,v=!1,y=(t,n)=>{(m!==t||h!==n)&&(m=t,h=n,e.onState(t,n))},b=Promise.resolve(),x=0,S=[],C=()=>!t&&e.transport===l()&&e.generation===d(),w=e=>{if(!(!C()||n?.readyState!==1))try{n.send(JSON.stringify(e))}catch{E(`connection_failed`)}},T=()=>{!g||_===v||!C()||n?.readyState!==1||(w({type:`view`,zoomed:_}),v=_)},E=r=>{if(t)return;let a=C()&&n?.readyState===1;if(t=!0,a)try{n.send(JSON.stringify({type:`release`}))}catch{}clearInterval(s),clearTimeout(u),clearTimeout(f),n&&(n.onopen=null,n.onmessage=null,n.onerror=null,n.onclose=null,n.close()),i?.close();let c=e.video.srcObject;c instanceof MediaStream&&c.getTracks().forEach(e=>e.stop()),e.video.srcObject=null,e.video.onloadeddata=null,e.image.onload=null,e.image.onerror=null,e.image.removeAttribute(`src`),o&&URL.revokeObjectURL(o),y(`closed`,r)},D=()=>{!C()||a||(a=!0,i?.close(),clearTimeout(f),f=setTimeout(()=>E(`connection_failed`),15e3),w({type:`fallback`}))},O=async t=>{if(!C())return;if(p=Date.now(),t instanceof ArrayBuffer){if(t.byteLength>524288){E(`connection_failed`);return}o&&URL.revokeObjectURL(o),o=URL.createObjectURL(new Blob([t],{type:`image/jpeg`})),e.image.onload=()=>{C()&&(clearTimeout(u),clearTimeout(f),e.onSize(e.image.naturalWidth,e.image.naturalHeight),y(`tunnel`),w({type:`ack`}))},e.image.onerror=()=>E(`connection_failed`),e.image.src=o;return}let n=JSON.parse(t);if(n.type===`error`){E(typeof n.code==`string`?n.code:`connection_failed`);return}if(n.type===`ready`)g=n.zoomQuality===!0,T(),Number.isFinite(n.width)&&Number.isFinite(n.height)&&e.onSize(n.width,n.height);else if(n.type===`offer`&&!a){if(i||typeof n.sdp!=`string`||n.sdp.length>65536)throw Error(`invalid_offer`);if(typeof RTCPeerConnection>`u`){D();return}i=new RTCPeerConnection({iceServers:Array.isArray(n.iceServers)?n.iceServers:[]}),i.onicecandidate=e=>{e.candidate&&w({type:`ice`,candidate:e.candidate.toJSON()})},i.onconnectionstatechange=()=>{(i?.connectionState===`failed`||i?.connectionState===`disconnected`)&&D()},i.ontrack=t=>{C()&&(e.video.srcObject=new MediaStream([t.track]),e.video.onloadeddata=()=>{!C()||a||(clearTimeout(u),clearTimeout(f),e.onSize(e.video.videoWidth,e.video.videoHeight),y(`webrtc`))},e.video.play().catch(D))},await i.setRemoteDescription({type:`offer`,sdp:n.sdp});for(let e of S.splice(0))await i.addIceCandidate(e);if(await i.setLocalDescription(await i.createAnswer()),!C()||a)return;f=setTimeout(D,7e3),w({type:`answer`,sdp:i.localDescription?.sdp})}else n.type===`ice`&&n.candidate&&!a?i?.remoteDescription?await i.addIceCandidate(n.candidate):S.length<128&&S.push(n.candidate):n.type===`rtc-failed`&&D()};return y(`connecting`),(async()=>{try{if(await r(),!C())return;n=k(c().websocket(`/api/remote-desktop/ws`)),n.binaryType=`arraybuffer`,n.onopen=()=>{C()&&(p=Date.now(),s=setInterval(()=>{if(!C()){E(`runtime_changed`);return}if(Date.now()-p>3e4){E(`connection_failed`);return}w({type:`ping`})},5e3))},n.onmessage=e=>{if(C()){if(++x>128){E(`connection_failed`);return}b=b.then(()=>O(e.data)).catch(D).finally(()=>{x--})}},n.onerror=()=>E(`connection_failed`),n.onclose=e=>E(e.code===4001?`authentication_required`:`connection_failed`)}catch{E(`connection_failed`)}})(),{send:e=>w(e),close:E,setZoomed:e=>{_=e,T()}}}var hd={scale:1,x:0,y:0};function gd(e){let t=Math.min(e.width/e.remoteWidth,e.height/e.remoteHeight),n=e.remoteWidth*t,r=e.remoteHeight*t;return{width:n,height:r,x:(e.width-n)/2,y:(e.height-r)/2}}function _d(e,t,n){if(t.width<=0||t.height<=0||t.remoteWidth<=0||t.remoteHeight<=0)return null;let r=gd(t),i=((e.x-n.x)/n.scale-r.x)/r.width,a=((e.y-n.y)/n.scale-r.y)/r.height;return i>=0&&i<=1&&a>=0&&a<=1?{x:i,y:a}:null}function vd(e,t,n=1){let r=Math.max(n,Math.min(5,e.scale)),i=gd(t),a=(e,t,n,i)=>n*r<=i?(i-n*r)/2-t*r:Math.max(i-(t+n)*r,Math.min(-t*r,e));return{scale:r,x:a(e.x,i.x,i.width,t.width),y:a(e.y,i.y,i.height,t.height)}}function yd(e){let t=new Map,n={...hd},r=null,i=null,a=!1,o=!1,s=!1,c=!1,l,u=null,d=0,f=null,p=()=>{a&&e.send({type:`release`}),a=!1},m=()=>{(n.scale!==1||n.x!==0||n.y!==0)&&(n={...hd},e.apply(n,!0))},h=()=>{clearTimeout(l),p(),t.clear(),f=null,r=i=null,s=!1,u=null,n.scale<=1&&m()},g=()=>{let[e,n]=[...t.values()];return{midpoint:{x:(e.x+n.x)/2,y:(e.y+n.y)/2},distance:Math.max(1,Math.hypot(e.x-n.x,e.y-n.y))}},_={down(a,m){t.size>=2||(t.set(a,m),t.size===1&&(r=i=m,o=!1,s=!1,c=!1,d=Date.now(),e.mode()===`cursor`&&(l=setTimeout(()=>{let t=_d(m,e.viewport(),n);t&&!o&&!s&&(e.send({type:`pointer`,action:`right`,...t}),c=!0)},550))),t.size===2&&(clearTimeout(l),s=!0,u=null,p(),f={...g(),transform:{...n}}))},move(d,p){if(t.has(d)){if(t.set(d,p),t.size===2&&f){let{midpoint:t,distance:r}=g(),i=Math.max(.5,Math.min(5,f.transform.scale*r/f.distance)),a=i/f.transform.scale;n=vd({scale:i,x:t.x-(f.midpoint.x-f.transform.x)*a,y:t.y-(f.midpoint.y-f.transform.y)*a},e.viewport(),.5),e.apply(n);return}if(!(s||c||!r||!i)&&(Math.hypot(p.x-r.x,p.y-r.y)>6&&(o=!0,u=null,clearTimeout(l)),o)){if(e.mode()===`drag`)n={...n,x:n.x+p.x-i.x,y:n.y+p.y-i.y},e.apply(n);else{let t=_d(p,e.viewport(),n);if(t){let i=_d(r,e.viewport(),n);!a&&i&&(e.send({type:`pointer`,action:`down`,...i}),a=!0),a&&e.send({type:`pointer`,action:`move`,...t})}}i=p}}},moveMany(e){let n;for(let[r,i]of e)t.has(r)&&(t.set(r,i),n=[r,i]);n&&_.move(...n)},up(a,h,g=!1){if(t.has(a)){if(clearTimeout(l),t.delete(a),e.mode()===`cursor`&&!g&&!s&&!o&&!c){let t=_d(h,e.viewport(),n);t&&e.send({type:`pointer`,action:`click`,...t})}if(e.mode()===`drag`&&!g&&!s&&!o&&Date.now()-d<450){let t=Date.now(),r={x:h.x,y:h.y,time:t};if(qn(u,r)){if(n.scale>1)n={...hd};else{let t=2.5,r=t/n.scale;n=vd({scale:t,x:h.x-(h.x-n.x)*r,y:h.y-(h.y-n.y)*r},e.viewport())}e.apply(n,!0),u=null}else u=r}else u=null;p(),t.size||(f=null,r=i=null,s=!1,n.scale<=1&&m())}},cancel:h,refit(){if(n.scale<=1){m();return}n=vd(n,e.viewport()),e.apply(n)},reset(){h(),n={...hd},e.apply(n)}};return _}function bd(e,t,n){return n===90?{x:e.y-t.top,y:t.right-e.x}:n===-90?{x:t.bottom-e.y,y:e.x-t.left}:{x:e.x-t.left,y:e.y-t.top}}var xd=he(`YuriOrientation`);function Sd(){return q.isNativePlatform()&&q.isPluginAvailable(`YuriOrientation`)}function Cd(e){return xd.lock({orientation:e})}function wd(e){let t=(0,Q.c)(14),[n,r]=(0,Z.useState)(Ad),[i]=(0,Z.useState)(kd),[a,o]=(0,Z.useState)(i),[s]=(0,Z.useState)(Sd),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{let[t]=e;if(!t)return;let{width:n,height:i}=t.contentRect;n>0&&i>0&&r(e=>e.width===n&&e.height===i?e:{width:n,height:i})},t[0]=c):c=t[0],me(e,c);let l,u;t[1]!==s||t[2]!==a?(l=()=>{s&&Cd(a).catch(Od)},u=[s,a],t[1]=s,t[2]=a,t[3]=l,t[4]=u):(l=t[3],u=t[4]),(0,Z.useEffect)(l,u);let d,f;t[5]===s?(d=t[6],f=t[7]):(d=()=>{if(s)return Ed},f=[s],t[5]=s,t[6]=d,t[7]=f),(0,Z.useEffect)(d,f);let p=!s&&a!==i,m=p?90:0,h=p?n.height:n.width,g=p?n.width:n.height,_;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>o(Td),t[8]=_):_=t[8];let v;return t[9]!==a||t[10]!==m||t[11]!==h||t[12]!==g?(v={orientation:a,rotation:m,width:h,height:g,toggle:_},t[9]=a,t[10]=m,t[11]=h,t[12]=g,t[13]=v):v=t[13],v}function Td(e){return e===`portrait`?`landscape`:`portrait`}function Ed(){Cd(`portrait`).catch(Dd)}function Dd(){}function Od(){}function kd(){return window.innerWidth>window.innerHeight?`landscape`:`portrait`}function Ad(){return{width:window.innerWidth,height:window.innerHeight}}var jd=(e,t)=>({queryKey:[e,`remote-desktop`,t],queryFn:async({signal:n})=>{let r=()=>{if(e!==l()||t!==d())throw Error(`runtime_changed`)};r();let i=new AbortController,a=()=>i.abort();n.addEventListener(`abort`,a,{once:!0}),n.aborted&&a();let o;try{return await Promise.race([(async()=>{let e=await m(`/api/remote-desktop`,{signal:i.signal,headers:{Accept:`application/json`}});if(r(),[401,403].includes(e.status))throw Error(`authentication_required`);if([404,501].includes(e.status))throw Error(`unsupported`);if(!e.ok)throw Error(`connection_failed`);if(!e.headers.get(`content-type`)?.includes(`application/json`))throw Error(`unsupported`);let t=await e.json();if(r(),!t||typeof t!=`object`||!(`supported`in t)||typeof t.supported!=`boolean`)throw Error(`unsupported`);return{supported:t.supported,enabled:`enabled`in t&&t.enabled===!0}})(),new Promise((e,t)=>{o=setTimeout(()=>{a(),t(Error(`connection_failed`))},1e4)})])}finally{clearTimeout(o),n.removeEventListener(`abort`,a)}},staleTime:3e4,retry:!1,refetchInterval:e=>{let t=e.state.error;return!t||[`unsupported`,`runtime_changed`,`authentication_required`].includes(t.message)?!1:Math.min(1e3*2**Math.min(Math.max(0,e.state.errorUpdateCount-1),5),3e4)},refetchIntervalInBackground:!1}),Md=(e,t)=>{let n=(0,Q.c)(3),r;return n[0]!==t||n[1]!==e?(r=jd(e,t),n[0]=t,n[1]=e,n[2]=r):r=n[2],re(r)},Nd=[{key:`Escape`,icon:`corner-up-left`},{key:`Tab`,icon:`arrow-right-to-line`},{key:`Backspace`,icon:`delete-back`},{key:`Enter`,icon:`corner-down-left`},{key:`ArrowLeft`,icon:`arrow-left`},{key:`ArrowUp`,icon:`arrow-up`},{key:`ArrowDown`,icon:`arrow-down`},{key:`ArrowRight`,icon:`arrow-right`}];function Pd({onClose:e,instanceName:t}){let{t:n}=Ee(),[r]=Z.useState(()=>({transport:l(),generation:d()})),i=Md(r.transport,r.generation),[a,o]=Z.useState(0),[s,c]=Z.useState(`connecting`),[u,f]=Z.useState(),[p,m]=Z.useState(`drag`),[h,g]=Z.useState(!1),[_,v]=Z.useState(``),y=Z.useRef(null),b=Z.useRef(null),x=wd(b),S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(null),T=Z.useRef({width:1,height:1,remoteWidth:1920,remoteHeight:1080}),E=Z.useRef(null),D=Z.useRef(null),O=Z.useRef(new Map),k=Z.useRef(new Set),A=Z.useRef(!1),j=K(e=>{E.current?.send(e)}),M=K(()=>p),[N]=Z.useState(()=>yd({viewport:()=>T.current,send:j,mode:M,apply:(e,t)=>{let n=e.scale>(A.current?1.01:1.05);n!==A.current&&(A.current=n,E.current?.setZoomed(n)),S.current&&(S.current.style.transition=t&&!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`transform 180ms ease-out`:`none`,S.current.style.transform=`translate(${e.x}px, ${e.y}px) scale(${e.scale})`)}})),P=K(()=>{if(D.current!==null&&cancelAnimationFrame(D.current),D.current=null,O.current.size&&y.current){let e=y.current.getBoundingClientRect(),t=new Map([...O.current].map(([t,n])=>[t,bd(n,e,x.rotation)]));N.moveMany(t)}O.current.clear()}),F=K(()=>{P(),N.reset(),E.current?.close(),E.current=null}),I=K(()=>{F(),e()});Nr({id:`remote-desktop-page`,active:!0,layer:`root`,onBack:I,surfaceRef:b}),Z.useEffect(()=>zn(`remote-desktop-page`),[]),Z.useLayoutEffect(()=>{let e=document.activeElement;return b.current?.focus({preventScroll:!0}),()=>{e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),G(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),Ir.requestBrowserBack())},()=>document);let L=K((e,t)=>{(e===`closed`||e===`connecting`)&&(O.current.clear(),k.current.clear(),N.cancel()),c(e),f(t)}),R=K((e,t)=>{if(e<=0||t<=0||T.current.remoteWidth===e&&T.current.remoteHeight===t)return;let n=T.current;T.current={...n,remoteWidth:e,remoteHeight:t},!(Math.abs(n.remoteWidth/n.remoteHeight-e/t)<.01)&&!k.current.size&&N.reset()});me(y,([e])=>{if(!e)return;let{width:t,height:n}=e.contentRect,r=Math.abs(T.current.width-t)>=1||Math.abs(T.current.height-n)>=1;T.current={...T.current,width:t,height:n},r&&!k.current.size&&N.refit()}),Qr(y),Z.useEffect(()=>{if(!i.data?.supported||!i.data.enabled||!C.current||!w.current)return;let e=pd({...r,video:C.current,image:w.current,onSize:R,onState:L});return E.current=e,e.setZoomed(A.current),()=>{e.close(),E.current=null}},[i.data?.supported,i.data?.enabled,r,a,R,L]),Z.useEffect(()=>()=>{P(),N.reset()},[P,N]);let ee=e=>{let t=y.current.getBoundingClientRect();return bd({x:e.clientX,y:e.clientY},t,x.rotation)},z=s===`webrtc`||s===`tunnel`,B=i.data?.supported===!1||i.error?.message===`unsupported`,V=i.data?.supported===!0&&i.data.enabled!==!0,te=B||u===`helper_unavailable`?n(`remoteDesktop.unsupported`):V||u===`disabled`?n(`settings.remoteDesktop.disabled`):u===`permission_required`?n(`remoteDesktop.permissions`):u===`permission_denied`?n(`remoteDesktop.denied`):u===`runtime_changed`||i.error?.message===`runtime_changed`?n(`remoteDesktop.runtimeChanged`):u||i.error||s===`closed`?n(`remoteDesktop.failed`):n(`remoteDesktop.connecting`);return(0,vl.createPortal)((0,$.jsx)(`div`,{ref:b,tabIndex:-1,"data-remote-desktop-page":!0,className:`yuri-keyboard-inset-surface yuri-keyboard-inset-snap fixed inset-0 z-[150] overflow-clip bg-background text-foreground outline-none`,children:(0,$.jsxs)(`main`,{"aria-label":t?`${n(`remoteDesktop.title`)} · ${t}`:n(`remoteDesktop.title`),className:`absolute left-0 top-0 flex flex-col overflow-clip bg-background`,style:{width:x.width,height:x.height,transformOrigin:`top left`,"--desktop-safe-top":`env(safe-area-inset-${x.rotation===90?`right`:x.rotation===-90?`left`:`top`}, 0px)`,"--desktop-safe-right":`env(safe-area-inset-${x.rotation===90?`bottom`:x.rotation===-90?`top`:`right`}, 0px)`,"--desktop-safe-bottom":`env(safe-area-inset-${x.rotation===90?`left`:x.rotation===-90?`right`:`bottom`}, 0px)`,"--desktop-safe-left":`env(safe-area-inset-${x.rotation===90?`top`:x.rotation===-90?`bottom`:`left`}, 0px)`,transform:x.rotation===90?`translateX(${x.height}px) rotate(90deg)`:x.rotation===-90?`translateY(${x.width}px) rotate(-90deg)`:void 0},children:[(0,$.jsxs)(`div`,{"data-remote-desktop-stage-region":!0,className:`relative min-h-0 flex-1 overflow-clip`,children:[(0,$.jsxs)(`div`,{ref:y,className:`absolute inset-0 touch-none overflow-clip bg-background`,"aria-label":n(`remoteDesktop.screen`),onPointerDown:e=>{z&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),k.current.add(e.pointerId),P(),N.down(e.pointerId,ee(e)))},onPointerMove:e=>{!z||!k.current.has(e.pointerId)||(e.preventDefault(),O.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),D.current===null&&(D.current=requestAnimationFrame(P)))},onPointerUp:e=>{P(),N.up(e.pointerId,ee(e)),k.current.delete(e.pointerId),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:e=>{P(),N.up(e.pointerId,ee(e),!0),k.current.delete(e.pointerId)},onContextMenu:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{ref:S,className:`absolute inset-0 origin-top-left will-change-transform`,children:[(0,$.jsx)(`video`,{ref:C,autoPlay:!0,muted:!0,playsInline:!0,className:`pointer-events-none absolute inset-0 size-full object-contain`,style:{visibility:s===`webrtc`?`visible`:`hidden`}}),(0,$.jsx)(`img`,{ref:w,alt:n(`remoteDesktop.screen`),draggable:!1,className:`pointer-events-none absolute inset-0 size-full object-contain`,style:{visibility:s===`tunnel`?`visible`:`hidden`}})]}),!z&&(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-4 p-6 text-center text-sm text-muted-foreground`,role:`status`,children:[s===`connecting`&&!u&&!i.error&&!B&&!V&&(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin`}),(0,$.jsx)(`p`,{children:te}),(s===`closed`||i.error||V)&&!B&&u!==`runtime_changed`&&i.error?.message!==`runtime_changed`&&(0,$.jsx)(J,{onClick:()=>{F(),f(void 0),c(`connecting`),i.error||V?i.refetch():o(e=>e+1)},children:n(`remoteDesktop.retry`)})]})]}),(0,$.jsxs)(`div`,{className:`pointer-events-none absolute left-[max(0.75rem,var(--desktop-safe-left))] right-[max(0.75rem,var(--desktop-safe-right))] top-[max(0.75rem,var(--desktop-safe-top))] flex items-start justify-between gap-3`,children:[(0,$.jsx)(J,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto`,"aria-label":n(`header.actions.backAria`),onClick:()=>Ir.requestBrowserBack(),children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(J,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto`,"aria-label":n(`remoteDesktop.rotate`),title:n(`remoteDesktop.rotate`),onClick:()=>{P(),N.reset(),g(!1),x.toggle()},children:(0,$.jsx)(X,{name:`smartphone`,className:`size-5 rotate-45`})})]}),(0,$.jsx)(`p`,{className:`sr-only`,children:n(`remoteDesktop.hint`)}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute left-[max(0.75rem,var(--desktop-safe-left))] right-[max(0.75rem,var(--desktop-safe-right))] bottom-[max(0.75rem,var(--desktop-safe-bottom))] top-[calc(4rem+var(--desktop-safe-top))] flex flex-col items-end justify-end gap-3`,children:(0,$.jsxs)(`div`,{className:`flex w-full shrink-0 items-end justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`pointer-events-auto flex gap-3`,children:[(0,$.jsx)(J,{size:`mobileIcon`,variant:`mobileGlass`,className:p===`drag`?`yuri-mobile-inverse-action`:void 0,"aria-label":n(`remoteDesktop.drag`),title:n(`remoteDesktop.drag`),"aria-pressed":p===`drag`,disabled:!z,onClick:()=>{P(),N.cancel(),m(`drag`)},children:(0,$.jsx)(X,{name:`hand`,className:`size-5`})}),(0,$.jsx)(J,{size:`mobileIcon`,variant:`mobileGlass`,className:p===`cursor`?`yuri-mobile-inverse-action`:void 0,"aria-label":n(`remoteDesktop.cursor`),title:n(`remoteDesktop.cursor`),"aria-pressed":p===`cursor`,disabled:!z,onClick:()=>{P(),N.cancel(),m(`cursor`)},children:(0,$.jsx)(X,{name:`cursor`,className:`size-5`})})]}),(0,$.jsx)(J,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto${h?` yuri-mobile-inverse-action`:``}`,disabled:!z,"aria-label":n(`remoteDesktop.text`),title:n(`remoteDesktop.text`),"aria-pressed":h,"aria-expanded":h,onClick:()=>g(e=>!e),children:(0,$.jsx)(X,{name:`keyboard`,className:`size-5`})})]})})]}),h&&(0,$.jsxs)(`footer`,{"data-remote-desktop-keyboard":!0,className:`max-h-[50%] w-full shrink-0 overflow-y-auto overscroll-contain border-t border-border bg-[var(--surface-elevated)] pt-3 pl-[max(0.75rem,var(--desktop-safe-left))] pr-[max(0.75rem,var(--desktop-safe-right))] pb-[max(0.75rem,var(--desktop-safe-bottom))]`,children:[(0,$.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),_&&z&&(j({type:`text`,text:_}),v(``))},children:[(0,$.jsx)(Kn,{className:`min-w-0 flex-1`,value:_,maxLength:1024,onChange:e=>v(e.target.value),placeholder:n(`remoteDesktop.text`),"aria-label":n(`remoteDesktop.text`),disabled:!z,autoComplete:`off`}),(0,$.jsx)(J,{type:`submit`,size:`icon`,disabled:!z||!_,"aria-label":n(`remoteDesktop.send`),children:(0,$.jsx)(X,{name:`send-plane-2`,className:`size-4`})})]}),(0,$.jsx)(`div`,{className:`mt-2 grid grid-cols-4 gap-1 min-[360px]:grid-cols-8`,children:Nd.map(({key:e,icon:t})=>(0,$.jsx)(J,{size:`icon`,variant:`ghost`,className:`w-full`,disabled:!z,onClick:()=>j({type:`key`,key:e}),"aria-label":n(`remoteDesktop.pressKey`,{key:e}),title:n(`remoteDesktop.pressKey`,{key:e}),children:(0,$.jsx)(X,{name:t,className:`size-4`})},e))})]})]})}),document.body)}var Fd=Z.memo(Pd);function Id(e){let t=(0,Q.c)(25),{title:n,subtitle:r,onBack:i,onOpenMenu:a,menuOpen:o,elevated:s,trailing:c}=e,l=o!==void 0&&o,u=s!==void 0&&s,{t:d}=Ee(),f=U(),p=K(i),m=K(a),h;t[0]!==f||t[1]!==n?(h=f?.entry.location.hostId?(0,$.jsx)(Ld,{host:f}):n,t[0]=f,t[1]=n,t[2]=h):h=t[2];let g;t[3]!==f||t[4]!==r?(g=r||(f?.entry.location.hostId?(0,$.jsx)(yn,{registry:f.registry,hostId:f.entry.location.hostId,showName:!0}):null),t[3]=f,t[4]=r,t[5]=g):g=t[5];let _;t[6]===d?_=t[7]:(_=d(`header.actions.backAria`),t[6]=d,t[7]=_);let v=u||l,y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(wa,{mobile:!0}),t[8]=y):y=t[8];let b;t[9]===c?b=t[10]:(b=(0,$.jsxs)($.Fragment,{children:[y,c]}),t[9]=c,t[10]=b);let x;t[11]===d?x=t[12]:(x=d(`mobile.menu.titleAria`),t[11]=d,t[12]=x);let S;t[13]!==m||t[14]!==l||t[15]!==x?(S=[{icon:`more-2`,ariaLabel:x,onClick:m,pressed:l}],t[13]=m,t[14]=l,t[15]=x,t[16]=S):S=t[16];let C;return t[17]!==p||t[18]!==S||t[19]!==h||t[20]!==g||t[21]!==_||t[22]!==v||t[23]!==b?(C=(0,$.jsx)(Be,{title:h,subtitle:g,backAriaLabel:_,onBack:p,overlay:!0,collapsible:!0,elevated:v,trailing:b,actions:S}),t[17]=p,t[18]=S,t[19]=h,t[20]=g,t[21]=_,t[22]=v,t[23]=b,t[24]=C):C=t[24],C}function Ld(e){let t=(0,Q.c)(16),{host:n}=e,{t:r}=Ee(),{location:i}=n.entry,a;t[0]!==i.directory||t[1]!==i.hostId||t[2]!==i.hubId?(a=e=>e.remoteSession?.location.hubId===i.hubId&&e.remoteSession.location.hostId===i.hostId&&e.remoteSession.location.directory===i.directory?e.remoteSession:null,t[0]=i.directory,t[1]=i.hostId,t[2]=i.hubId,t[3]=a):a=t[3];let o=ct(a),s=o?.sessionId,c=Zt(n.registry,i.hostId),l;t[4]!==i.directory||t[5]!==s||t[6]!==c.data?.directories?(l=c.data?.directories.find(e=>e.directory===i.directory)?.sessions.find(e=>e.id===s),t[4]=i.directory,t[5]=s,t[6]=c.data?.directories,t[7]=l):l=t[7];let u=l,d;t[8]!==n.entry||t[9]!==o?.draft?.title||t[10]!==s||t[11]!==u?.title||t[12]!==r?(d=s?(0,$.jsx)(Rd,{entry:n.entry,sessionId:s,fallback:u?.title||r(`mobile.sessions.untitled`)}):o?.draft?.title||r(`mobile.menu.newSession`),t[8]=n.entry,t[9]=o?.draft?.title,t[10]=s,t[11]=u?.title,t[12]=r,t[13]=d):d=t[13];let f;return t[14]===d?f=t[15]:(f=(0,$.jsx)($.Fragment,{children:d}),t[14]=d,t[15]=f),f}var Rd=(0,Z.memo)(function(e){let t=(0,Q.c)(10),{entry:n,sessionId:r,fallback:i}=e,a;t[0]!==n.queryScope||t[1]!==r?(a=[...n.queryScope,`chat`,r,`session`],t[0]=n.queryScope,t[1]=r,t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=e=>e.id===r&&e.title?.trim()||null,t[3]=r,t[4]=o);let s;t[5]!==a||t[6]!==o?(s={queryKey:a,queryFn:V,enabled:!1,staleTime:1/0,gcTime:1/0,select:o},t[5]=a,t[6]=o,t[7]=s):s=t[7];let c=re(s,ue).data??i,l;return t[8]===c?l=t[9]:(l=(0,$.jsx)($.Fragment,{children:c}),t[8]=c,t[9]=l),l});function zd(e){return e.sessionId?e.userRefreshInFlight||e.backgroundResyncInFlight?`syncing`:e.hasRenderableTranscript?null:!e.isConnected&&e.connectionPhase===`reconnecting`||e.loadStatus!==`error`?`syncing`:null:null}function Bd(e,t){let n=t?.showDelayMs??250,r=t?.hideGraceMs??1e3,i=!1,a=!1,o=null,s=()=>{o=null,a!==i&&(a=i,e(a))};return{setRaw(e){i=e,o&&clearTimeout(o),o=setTimeout(s,i?n:r)},cancel(){i=!1,o&&=(clearTimeout(o),null)}}}function Vd(e,t){let n=(0,Q.c)(10),r;n[0]===t?r=n[1]:(r={key:t},n[0]=t,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a={scope:i,visible:!1},n[2]=i,n[3]=a);let[o,s]=(0,Z.useState)(a),c;n[4]===i?c=n[5]:(c=Bd(e=>s({scope:i,visible:e})),n[4]=i,n[5]=c);let l=c,u,d;return n[6]!==e||n[7]!==l?(u=()=>(l.setRaw(e),()=>l.cancel()),d=[e,l],n[6]=e,n[7]=l,n[8]=u,n[9]=d):(u=n[8],d=n[9]),(0,Z.useEffect)(u,d),o.scope===i&&o.visible}function Hd(e,t){let n=(0,Q.c)(20),{t:r}=Ee(),i=Mt(e,t),{renderable:a}=pt(e,t),o=lt(Kd),s=lt(Gd),c;n[0]!==t||n[1]!==e?(c=()=>R(e,t),n[0]=t,n[1]=e,n[2]=c):c=n[2];let l=(0,Z.useSyncExternalStore)(P,c,Wd),u;n[3]!==t||n[4]!==e?(u=()=>yt(e,t),n[3]=t,n[4]=e,n[5]=u):u=n[5];let d=(0,Z.useSyncExternalStore)(_t,u,Ud),f=i?.status,p;n[6]!==d||n[7]!==s||n[8]!==a||n[9]!==o||n[10]!==e||n[11]!==f||n[12]!==l?(p=zd({sessionId:e,hasRenderableTranscript:a,loadStatus:f,userRefreshInFlight:l,backgroundResyncInFlight:d,isConnected:o,connectionPhase:s}),n[6]=d,n[7]=s,n[8]=a,n[9]=o,n[10]=e,n[11]=f,n[12]=l,n[13]=p):p=n[13];let m=p,h;n[14]!==t||n[15]!==e?(h=JSON.stringify([t,e]),n[14]=t,n[15]=e,n[16]=h):h=n[16];let g=Vd(m===`syncing`,h),_;return n[17]!==r||n[18]!==g?(_=g?r(`mobile.chat.syncingMessages`):null,n[17]=r,n[18]=g,n[19]=_):_=n[19],_}function Ud(){return!1}function Wd(){return!1}function Gd(e){return e.connectionPhase}function Kd(e){return e.isConnected}function qd(e,t){let n=(0,Q.c)(41),{t:r}=Ee(),i=ie(e.registry,e.entry.location.hostId),a=(0,Z.useSyncExternalStore)(I,M,M),o;n[0]===e.entry.location?o=n[1]:(o=N(e.entry.location),n[0]=e.entry.location,n[1]=o);let s=o,c;n[2]!==e.entry.location||n[3]!==s||n[4]!==t?(c=s&&t?L(e.entry.location,t):null,n[2]=e.entry.location,n[3]=s,n[4]=t,n[5]=c):c=n[5];let l;n[6]!==a||n[7]!==c?(l={revision:a,scope:c},n[6]=a,n[7]=c,n[8]=l):l=n[8];let u=l.scope,d;n[9]!==s||n[10]!==u?(d=e=>s&&u?s.subscribe(u,e):Xd,n[9]=s,n[10]=u,n[11]=d):d=n[11];let f=d,p;n[12]!==s||n[13]!==u||n[14]!==t?(p=()=>!s||!u?t?`loading`:`idle`:s.getHydrationState?.(u).p0Satisfied?`renderable`:s.getRequestState?.(u).status??`loading`,n[12]=s,n[13]=u,n[14]=t,n[15]=p):p=n[15];let m=p,h=(0,Z.useSyncExternalStore)(f,m,m),g;n[16]===e.entry.location?g=n[17]:(g=v(e.entry.location),n[16]=e.entry.location,n[17]=g);let _=g,y;n[18]!==_||n[19]!==t?(y=()=>R(t,_),n[18]=_,n[19]=t,n[20]=y):y=n[20];let b=(0,Z.useSyncExternalStore)(P,y,Yd),x;n[21]!==_||n[22]!==t?(x=()=>yt(t,_),n[21]=_,n[22]=t,n[23]=x):x=n[23];let S=(0,Z.useSyncExternalStore)(_t,x,Jd),C=h===`renderable`,w=h===`error`?`error`:h===`ready`?`ready`:`loading`,T=i?.state===`connected`,E=i?.state===`connected`?`connected`:i?.state===`connecting`?`connecting`:`reconnecting`,D;n[24]!==S||n[25]!==t||n[26]!==T||n[27]!==E||n[28]!==C||n[29]!==w||n[30]!==b?(D=zd({sessionId:t,hasRenderableTranscript:C,loadStatus:w,userRefreshInFlight:b,backgroundResyncInFlight:S,isConnected:T,connectionPhase:E}),n[24]=S,n[25]=t,n[26]=T,n[27]=E,n[28]=C,n[29]=w,n[30]=b,n[31]=D):D=n[31];let O=D,k;n[32]!==_||n[33]!==t?(k=JSON.stringify([_,t]),n[32]=_,n[33]=t,n[34]=k):k=n[34];let A=Vd(O===`syncing`,k),j;if(n[35]!==i||n[36]!==r){j=Symbol.for(`react.early_return_sentinel`);bb0:{let e=In(i);if(e){j=r(e.key);break bb0}}n[35]=i,n[36]=r,n[37]=j}else j=n[37];if(j!==Symbol.for(`react.early_return_sentinel`))return j;let F;return n[38]!==r||n[39]!==A?(F=A?r(`mobile.chat.syncingMessages`):null,n[38]=r,n[39]=A,n[40]=F):F=n[40],F}function Jd(){return!1}function Yd(){return!1}function Xd(){}function Zd(e){let t=(0,Q.c)(3),n=U(),r;return t[0]!==n||t[1]!==e?(r=n?.entry.location.hostId?(0,$.jsx)($d,{...e,host:n}):(0,$.jsx)(Qd,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}function Qd(e){let t=(0,Q.c)(15),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({sessionId:i,directory:n,title:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{t:o}=Ee(),s=i.length===0,c=Ze(s?null:i),l;t[5]!==s||t[6]!==c?.title||t[7]!==o||t[8]!==a?(l=s?a?.trim()||o(`mobile.menu.newSession`):a?.trim()||c?.title?.trim()||o(`mobile.sessions.untitled`),t[5]=s,t[6]=c?.title,t[7]=o,t[8]=a,t[9]=l):l=t[9];let u=l,d=Hd(s?``:i,n||void 0),f;return t[10]!==r||t[11]!==u||t[12]!==i||t[13]!==d?(f=(0,$.jsx)(ef,{...r,sessionId:i,title:u,syncHint:d}),t[10]=r,t[11]=u,t[12]=i,t[13]=d,t[14]=f):f=t[14],f}function $d(e){let t=(0,Q.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({host:n,sessionId:i,title:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]!==n.entry.location.directory||t[6]!==n.entry.location.hostId||t[7]!==n.entry.location.hubId?(o=e=>{let t=e.remoteSession;return t?.location.hubId===n.entry.location.hubId&&t.location.hostId===n.entry.location.hostId&&t.location.directory===n.entry.location.directory?t.sessionId:null},t[5]=n.entry.location.directory,t[6]=n.entry.location.hostId,t[7]=n.entry.location.hubId,t[8]=o):o=t[8];let s=ct(o),c=i||s||``,l=qd(n,c),u;return t[9]!==c||t[10]!==r||t[11]!==l||t[12]!==a?(u=(0,$.jsx)(ef,{...r,sessionId:c,title:a,syncHint:l}),t[9]=c,t[10]=r,t[11]=l,t[12]=a,t[13]=u):u=t[13],u}function ef(e){let t=(0,Q.c)(31),{sessionId:n,title:r,onBack:i,onOpenMenu:a,onCloseMenu:o,menuOpen:s,children:c,className:l,syncHint:u}=e,d=s!==void 0&&s,{t:f}=Ee(),[p,m]=Z.useState(!1),h;t[0]!==d||t[1]!==o?(h=e=>{e&&d&&o?.(),m(e)},t[0]=d,t[1]=o,t[2]=h):h=t[2];let g=K(h),_;t[3]!==p||t[4]!==a?(_=()=>{p&&m(!1),a()},t[3]=p,t[4]=a,t[5]=_):_=t[5];let v=K(_),y=d||p,b;t[6]===l?b=t[7]:(b=it(`mobile-chat-screen relative isolate flex h-full min-h-0 w-full flex-col overflow-hidden bg-background text-foreground`,l),t[6]=l,t[7]=b);let x;t[8]!==n||t[9]!==f||t[10]!==r?(x=r||f(n?`mobile.sessions.untitled`:`mobile.menu.newSession`),t[8]=n,t[9]=f,t[10]=r,t[11]=x):x=t[11];let S;t[12]!==p||t[13]!==g||t[14]!==n?(S=(0,$.jsx)(ec,{sessionId:n,open:p,onOpenChange:g}),t[12]=p,t[13]=g,t[14]=n,t[15]=S):S=t[15];let C;t[16]!==v||t[17]!==y||t[18]!==d||t[19]!==i||t[20]!==u||t[21]!==x||t[22]!==S?(C=(0,$.jsx)(Id,{title:x,subtitle:u,onBack:i,onOpenMenu:v,menuOpen:d,elevated:y,trailing:S}),t[16]=v,t[17]=y,t[18]=d,t[19]=i,t[20]=u,t[21]=x,t[22]=S,t[23]=C):C=t[23];let w;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(w=it(`mobile-chat-screen__content relative h-full min-h-0 flex-1`,`[&_[data-scrollbar=chat]>.yuri-chat-scroll-content]:pt-[calc(max(0.625rem,var(--yuri-safe-area-top,0px))+var(--yuri-mobile-detail-navigation-height)+1.25rem)]`),t[24]=w):w=t[24];let T;t[25]===c?T=t[26]:(T=(0,$.jsx)(`div`,{className:w,children:c}),t[25]=c,t[26]=T);let E;return t[27]!==b||t[28]!==C||t[29]!==T?(E=(0,$.jsxs)(`main`,{className:b,children:[C,T]}),t[27]=b,t[28]=C,t[29]=T,t[30]=E):E=t[30],E}function tf(e){let t=(0,Q.c)(4),n=e===void 0?2500:e,{uiFont:r}=yi(),[i,a]=Z.useState(!1),o,s;return t[0]!==n||t[1]!==r?(o=()=>{let e=!1,t=()=>{e||a(!0)},i=()=>{requestAnimationFrame(()=>requestAnimationFrame(t))},o=Promise.all([Bn(r).catch(sf),document.fonts?.ready?.then(of).catch(af)??Promise.resolve(),lo.catch(rf)]).then(nf),s=new Promise(e=>{window.setTimeout(e,n)});return Promise.race([o,s]).then(i),()=>{e=!0}},s=[r,n],t[0]=n,t[1]=r,t[2]=o,t[3]=s):(o=t[2],s=t[3]),Z.useEffect(o,s),i}function nf(){}function rf(){}function af(){}function of(){}function sf(){}var cf=e=>e.replace(/^\/+|\/+$/g,``),lf=e=>{let t=e.get(`directory`)||e.get(`dir`)||e.get(`path`);if(typeof t!=`string`)return;let n=t.trim();return n.length>0?n:void 0},uf=e=>{let t=cf(e.pathname).split(`/`).filter(Boolean);return e.host?[e.host,...t]:t};function df(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(![`yuri:`,`openchamber:`,`openchambery:`].includes(t.protocol))return null;let n=uf(t),r=(n[0]??``).toLowerCase(),i=n.slice(1),a=t.searchParams;switch(r){case`connect`:{let t=Va(e);return t?{type:`connect`,pairing:t}:null}case`session`:{let e=i[0]||a.get(`id`)||``;return e?{type:`session`,sessionId:e,directory:lf(a)}:null}case`assistant`:{let e=i[0]||a.get(`id`)||``;return e?{type:`assistant`,assistantId:e}:null}case`new`:case`new-session`:{let e=a.get(`prompt`)?.trim();return{type:`new-session`,directory:lf(a),projectId:a.get(`project`)??void 0,agent:a.get(`agent`)??void 0,model:a.get(`model`)??void 0,prompt:e||void 0}}case`project`:case`open-project`:{let e;if(i.length>0)try{e=decodeURIComponent(i.join(`/`))}catch{e=i.join(`/`)}let t=lf(a)||e;return t?{type:`open-project`,directory:t}:null}case`sessions`:{let e=a.get(`filter`);return{type:`sessions`,filter:e===`attention`||e===`recent`||e===`all`?e:void 0}}case`status`:return{type:`status`};case`settings`:return{type:`settings`,section:i[0]||a.get(`section`)||void 0};case`changes`:return{type:`changes`,path:i.join(`/`)||a.get(`path`)||void 0,staged:a.get(`staged`)===`true`};case`view`:{let e=(i[0]||``).toLowerCase();return e===`changes`?{type:`changes`}:e===`files`||e===`mcp`||e===`instances`||e===`update`?{type:`view`,target:e}:null}default:return null}}var ff={},pf=null,mf=!1,hf=null,gf=e=>{switch(e.type){case`connect`:return pf?(pf(e.pairing),!0):!1;case`session`:return _()?(Ot.getState().setCurrentSession(e.sessionId,e.directory??null),!0):(jt.getState().openSession({sessionId:e.sessionId,directory:e.directory??null}),!0);case`assistant`:if(!_()){let t=jt.getState();return t.setActiveTab(`assistant`),t.openAssistant(e.assistantId),!0}return Ht(e.assistantId),!0;case`new-session`:return _()?(Ot.getState().openNewSessionDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0):(jt.getState().openDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0);case`open-project`:return _()?(Ot.getState().openNewSessionDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0):(jt.getState().openDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0);case`sessions`:return ff.openSessions?(ff.openSessions(e.filter),!0):!1;case`status`:return ff.openSessions?(ff.openSessions(),!0):(_e.getState().setMobileSessionPanelOpen(!0),!0);case`view`:return ff.openView?(ff.openView(e.target),!0):!1;case`changes`:return ff.openChanges?(ff.openChanges({path:e.path,staged:e.staged}),!0):!1;case`settings`:return ff.openSettings?(ff.openSettings(e.section),!0):!1}return!1},_f=()=>{if(!hf||!mf&&hf.type!==`connect`)return;let e=hf;hf=null,gf(e)||(hf=e)},vf=e=>{hf=e,_f()},yf=e=>{let t=df(e);t&&vf(t)},bf=e=>{mf=e,_f()},xf=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(ff=e,_f(),()=>{ff===e&&(ff={})}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},Sf=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(pf=e,_f(),()=>{pf===e&&(pf=null)}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},Cf=e=>{let{ready:t}=e,[n,r]=Z.useState(()=>g()?`pending`:`none`);return Z.useEffect(()=>{bf(t)},[t]),Z.useEffect(()=>{if(!g())return;let e=!1,t=[];return ge(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])).then(async({App:n})=>{if(e)return;let i=await n.addListener(`appUrlOpen`,e=>{yf(e?.url)});if(e){i.remove();return}t.push(()=>void i.remove());let a=await n.getLaunchUrl().catch(()=>void 0);if(e)return;let o=df(a?.url);r(o?.type===`connect`?`connect`:o?`other`:`none`),o&&vf(o)}).catch(()=>{e||r(`none`)}),ge(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-D5cqJIPw.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([80,1,2])).then(async({PushNotifications:n})=>{if(e)return;let r=await n.addListener(`pushNotificationActionPerformed`,e=>{let t=e?.notification?.data,n=typeof t?.url==`string`?t.url:typeof t?.deeplink==`string`?t.deeplink:void 0;if(n){yf(n);return}let r=typeof t?.assistantID==`string`?t.assistantID.trim():``;if(r){vf({type:`assistant`,assistantId:r});return}let i=typeof t?.sessionId==`string`?t.sessionId:void 0;i&&vf({type:`session`,sessionId:i})});if(e){r.remove();return}t.push(()=>void r.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e())}},[]),n},wf=.85,Tf=8,Ef=.35,Df=.22,Of=e=>({segmentStart:e,lastTouch:e,open:!1}),kf=e=>e*Ef,Af=e=>e*Df,jf=(e,t)=>Math.max(0,e-t),Mf=(e,t)=>Math.max(0,t-e),Nf=(e,t)=>{let n=Math.abs(e);return n<Tf||Math.abs(t)<=n*wf},Pf=(e,t,n)=>{let r=t.clientX-e.segmentStart.clientX,i=t.clientY-e.segmentStart.clientY,a=jf(e.segmentStart.clientX,t.clientX),o=kf(n),s=Af(n),c=e.open;return c=a<=0?!1:e.open?a>=s:a>=o&&Nf(r,i),{segmentStart:e.segmentStart,lastTouch:t,open:c}},Ff=e=>{if(e.disabled||e.startedOnExcludedTarget)return{open:!1,back:!1};let t=e.endX-e.startX,n=e.endY-e.startY,r=jf(e.startX,e.endX),i=Mf(e.startX,e.endX),a=kf(e.viewportWidth),o=Nf(t,n);return{open:r>=a&&o,back:i>=a&&o}},If=(e,t,n)=>Math.min(jf(e,t)/Math.max(1,kf(n)),1),Lf=(e,t,n)=>Math.min(Mf(e,t)/Math.max(1,kf(n)),1),Rf=e=>{let t=e;for(;t&&t!==document.body&&t!==document.documentElement;){let e=window.getComputedStyle(t).overflowX;if((e===`auto`||e===`scroll`)&&t.scrollWidth>t.clientWidth)return!0;t=t.parentElement}return!1},zf=e=>{let t=document.elementFromPoint(e.clientX,e.clientY);return!!t?.closest(`.yuri-mobile-composer`)||Rf(t)},Bf=1,Vf=(e,t)=>{if(!e||e.rangeCount===0||e.isCollapsed)return!1;if(!t)return!0;let n=e.anchorNode;if(!n)return!1;let r=n.nodeType===Bf?n:n.parentElement;return!!(r&&t.contains(r))},Hf=e=>Vf(window.getSelection(),e),Uf=(e,t,n)=>{let r=Z.useRef(t.onOpen);r.current=t.onOpen;let i=Z.useRef(t.onPreviewStart);i.current=t.onPreviewStart;let a=Z.useRef(t.onPreviewCancel);a.current=t.onPreviewCancel;let o=Z.useRef(t.onProgress);o.current=t.onProgress;let s=Z.useRef(t.onBack);s.current=t.onBack;let c=Z.useRef(t.onBackProgress);c.current=t.onBackProgress;let l=Z.useRef(t.disabled);l.current=t.disabled,Z.useEffect(()=>{let t=e.current;if(!t)return;let n=!1,u=!1,d=null,f=!1,p=!1,m=!1,h=0,g=0,_=null,v=e=>{let t=kf(g),n=We({thresholdReached:p,distance:e,enterDistance:t,cancelDistance:Af(g),available:!0});p=n.thresholdReached,n.event===`enter`&&(m=Rt(`medium`,{bypassCadence:!0})),n.event===`cancel`&&(Rt(`light`,{bypassCadence:!0}),m=!1)},y=e=>{o.current?.(null),p&&!e&&Rt(`light`,{bypassCadence:!0}),p=!1,m=!1,e?r.current():f&&a.current?.(),f=!1},b=e=>{c.current?.(null),p&&!e&&Rt(`light`,{bypassCadence:!0}),p=!1,m=!1,e&&s.current?.()},x=e=>{if(e.touches.length!==1){n=!1,_=null;return}if(l.current){n=!1,_=null;return}let r=e.touches[0];n=!0,g=window.innerWidth,u=zf(r)||Hf(t),d=null,f=!1,p=!1,m=!1,h=0,_=Of(r)},S=e=>{if(!n||u||!_)return;if(e.touches.length!==1){d===`sessions`&&y(!1),d===`back`&&b(!1),n=!1,_=null;return}let r=e.touches[0];_=Pf(_,r,g);let a=r.clientX-_.segmentStart.clientX,l=r.clientY-_.segmentStart.clientY;if(d===null){if(Hf(t))return;let e=Math.abs(a);if(e<Tf||Math.abs(l)>e*wf)return;if(a<0)d=`sessions`,f=!0,i.current?.();else if(s.current)d=`back`;else return}e.preventDefault(),h=d===`sessions`?jf(_.segmentStart.clientX,r.clientX):Mf(_.segmentStart.clientX,r.clientX),v(h),d===`sessions`?o.current?.(If(_.segmentStart.clientX,r.clientX,g)):c.current?.(Lf(_.segmentStart.clientX,r.clientX,g))},C=e=>{if(!n||!_)return;if(n=!1,!d){_=null;return}let t=e.changedTouches[0];t&&(_=Pf(_,t,g),h=d===`sessions`?jf(_.segmentStart.clientX,t.clientX):Mf(_.segmentStart.clientX,t.clientX),v(h));let r=d===`sessions`?_.open:Ff({startX:_.segmentStart.clientX,startY:_.segmentStart.clientY,endX:_.lastTouch.clientX,endY:_.lastTouch.clientY,viewportWidth:g,disabled:!1,startedOnExcludedTarget:!1}).back;_=null,e.preventDefault(),r&&!m&&Rt(`medium`,{bypassCadence:!0}),d===`sessions`?y(r):b(r)},w=()=>{d===`sessions`&&y(!1),d===`back`&&b(!1),n=!1,_=null};return t.addEventListener(`touchstart`,x,{passive:!0,capture:!0}),t.addEventListener(`touchmove`,S,{passive:!1,capture:!0}),t.addEventListener(`touchend`,C,{passive:!1,capture:!0}),t.addEventListener(`touchcancel`,w,{passive:!0,capture:!0}),()=>{f&&y(!1),d===`back`&&b(!1),t.removeEventListener(`touchstart`,x,!0),t.removeEventListener(`touchmove`,S,!0),t.removeEventListener(`touchend`,C,!0),t.removeEventListener(`touchcancel`,w,!0)}},[e,n])},Wf=he(`YuriNotifications`),Gf=()=>q.getPlatform()===`android`&&q.isPluginAvailable(`YuriNotifications`);async function Kf(e,n){let r=f(),a=t(),o=a?``:p();if(!a&&!/^https?:\/\//.test(o))return null;let s=await i();s.set(`Accept-Language`,n);let c=(await Me()).find(e=>Pe(e)===r)?.candidates.find(e=>e.kind===`relay`);return{runtimeKey:r,baseUrl:o,relay:a??(c?.kind===`relay`?c.relay:void 0),preferRelay:!!a,headers:Object.fromEntries(s.entries()),labels:e}}function qf(e){let t=0,n=!1;return{refresh:async()=>{let r=++t;try{if(await e.plugin.stop(),n||r!==t)return;let i=await e.resolveConfig();if(n||r!==t||!i)return;let a=await e.plugin.configure({config:i});!n&&r===t&&e.onState(a.state)}catch{!n&&r===t&&e.onError()}},stop:()=>{++t,e.plugin.stop().catch(e.onError)},dispose:()=>{n=!0,++t,e.plugin.stop().catch(e.onError)}}}var Jf=()=>{if(Gf()||typeof window>`u`)return!1;let e=window.Capacitor?.getPlatform?.();return e===`ios`||e===`android`},Yf=(e,t)=>{x()?.push?.registerApnsToken?.({token:e,platform:y(),locale:t})},Xf=e=>{let{enabled:t}=e,n=_e(e=>e.nativeNotificationsEnabled),r=De(e=>e.locale),i=Z.useRef(null),a=Z.useRef(r);a.current=r,Z.useEffect(()=>{if(!t||!n||!Jf())return;let e=!1,r=[];return ge(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-D5cqJIPw.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([80,1,2])).then(async({PushNotifications:t})=>{if(e)return;let n=await t.checkPermissions().catch(()=>null);if(n?.receive!==`granted`&&(n=await t.requestPermissions().catch(()=>null)),n?.receive!==`granted`)return;let o=await t.addListener(`registration`,e=>{i.current=e.value,Yf(e.value,a.current)}),s=await t.addListener(`registrationError`,e=>{console.warn(`[Push] APNs registration error:`,e)});if(await t.register().catch(()=>void 0),e){o.remove(),s.remove();return}r.push(()=>void o.remove(),()=>void s.remove())}).catch(()=>void 0),()=>{e=!0,r.forEach(e=>e())}},[t,n]),Z.useEffect(()=>{if(!t||!n||!Jf())return;let e=i.current;e&&Yf(e,r)},[t,n,r]),Z.useEffect(()=>{if(n)return;let e=i.current;e&&(i.current=null,x()?.push?.unregisterApnsToken?.({token:e}))},[n])},Zf=`YuriLiveActivity`,Qf=5e3,$f=3600,ep=`live`,tp=he(Zf),np=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable;function rp(){return typeof window>`u`?!1:np({isCapacitor:g(),platform:y(),pluginAvailable:q.isPluginAvailable(Zf)})}var ip=()=>tp,ap=new Set([`permission`,`input`,`retry`]),op=()=>({trackedSessionId:null,started:!1,startedAt:null,busySince:null,lastStatus:null,eventVersion:0,items:[]}),sp=(e,t)=>Math.max(Math.floor(e),t+1),cp=e=>e.failedEpoch===e.currentEpoch?e.previous:e.current,lp=e=>e.failedEpoch===e.currentEpoch&&e.retryCount<1,up=e=>e.hasSessionError?`error`:e.hasPendingPermissions?`permission`:e.hasPendingQuestions?`input`:e.statusType===`retry`?`retry`:e.statusType===`busy`?`working`:e.statusType===`idle`?`complete`:null,dp=e=>{let t=e.trim();return t.length<=80?t:`${t.slice(0,79)}…`},fp=e=>typeof e.parentID==`string`&&e.parentID.length>0?e.parentID:null,pp=e=>{if(e.runningIds.size===0)return[];let t=[];for(let n of e.sessions)!e.runningIds.has(n.id)||fp(n)||t.push({sessionId:n.id,title:dp(n.title??``),statusType:e.statuses[n.id]?.type??`busy`});return t},mp=e=>e!==`complete`&&e!==`error`,hp=e=>e.some(e=>e.status===`permission`)?`permission`:e.some(e=>e.status===`input`)?`input`:e.some(e=>e.status===`retry`)?`retry`:e.some(e=>e.status===`tool`)?`tool`:e.some(e=>e.status===`stale`)?`stale`:e.some(e=>e.status===`working`)?`working`:e.some(e=>e.status===`error`)?`error`:`complete`,gp=e=>{if(e.length<=4)return e;let t=e.filter(e=>mp(e.status)),n=e.filter(e=>!mp(e.status)).sort((e,t)=>(t.endedAt??0)-(e.endedAt??0)),r=[...t];for(let e of n){if(r.length>=4)break;r.push(e)}return r.slice(0,4)},_p=(e,t,n,r)=>{if(n&&n.length>0)return n;let i=r?.[e];return i&&i.length>0?i:t},vp=(e,t,n,r,i)=>{let a=new Map;for(let e of t)a.set(e.sessionId,e);let o=[],s=new Set;for(let t of e){if(i&&!i.has(t.sessionId))continue;let e=a.get(t.sessionId);if(e){let i=up({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;o.push({sessionId:t.sessionId,title:_p(t.sessionId,t.title,e.title,r),status:i,startedAt:t.startedAt,busySince:i===`working`?t.busySince??n:null})}else if(mp(t.status))o.push({...t,title:_p(t.sessionId,t.title,void 0,r),status:`complete`,endedAt:n,busySince:null});else{let e=_p(t.sessionId,t.title,void 0,r);o.push(e===t.title?t:{...t,title:e})}s.add(t.sessionId)}for(let e of t){if(s.has(e.sessionId))continue;let t=up({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;o.push({sessionId:e.sessionId,title:e.title,status:t,startedAt:n,busySince:t===`working`?n:null})}return gp(o)},yp=e=>e.map(e=>`${e.sessionId}\0${e.title}\0${e.status}\0${e.endedAt??``}`).join(`
|
|
15
|
+
`)}`.trim()),B([])}),Pe=K(async()=>{if(!m)return;let e=m,t=fe.map(e=>e.path).sort();if(t.length===0){Y.error(a(`gitView.toast.selectFileToDescribe`));return}ee(!0);try{let{message:n}=await c(e,t);N(n.subject?.trim()??``),B(Array.isArray(n.highlights)?n.highlights:[])}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.generateCommitMessageFailed`))}finally{ee(!1)}}),Fe=async(e={})=>{if(!m)return;let t=m;if(!M.trim()){Y.error(a(`gitView.toast.enterCommitMessage`));return}let n=fe.map(e=>e.path).sort();if(n.length===0){Y.error(a(`gitView.toast.selectFileToCommit`));return}j(e.pushAfter?`commitAndPush`:`commit`);try{if(await o.createGitCommit(t,M.trim(),{files:n}),Y.success(a(`gitView.toast.commitCreated`)),N(``),B([]),e.pushAfter){let e=h?.tracking?.split(`/`)[0],n=he.find(t=>t.name===e)??he[0];if(!n)throw Error(a(`mobile.changes.noRemote`));k(`sync`);let r=`${n.name}/`,i=h?.tracking?.startsWith(r)?h.tracking.slice(r.length):void 0;await o.gitFetch(t,{remote:n.name}),((await o.getGitStatus(t)).behind??0)>0&&await o.gitPull(t,{remote:n.name,branch:i,rebase:!0}),((await o.getGitStatus(t)).ahead??0)>0&&await o.gitPush(t),await Ce(t,!1),await Te(t).promise}else await Ce(t,!1)}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{j(null),e.pushAfter&&k(null)}},Ie=Z.useMemo(()=>{let e=[];return fe.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:fe,actionSymbol:`-`,actionAllLabel:a(`gitView.changes.unstageAllAria`),getActionLabel:e=>a(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void Oe([e],`unstage`),onActionAll:e=>void Oe(e,`unstage`),onViewDiff:e=>ke(e,!0),onRevertFile:je,showRevertActions:!1,accent:!0}),G.length>0&&e.push({id:`unstaged`,title:a(`gitView.changes.title`),entries:G,actionSymbol:`+`,actionAllLabel:a(`gitView.changes.stageAllAria`),getActionLabel:e=>a(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void Oe([e],`stage`),onActionAll:e=>void Oe(e,`stage`),onViewDiff:e=>ke(e,!1),onRevertFile:je}),e},[je,ke,Oe,fe,a,G]),Le=t=>(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[i?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:h?.current||m||``})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:t})]});return m?_&&g===null?Le((0,$.jsx)(gl,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):g===!1?Le((0,$.jsx)(gl,{icon:!0,message:a(`gitView.empty.notGitRepository`),description:a(`gitView.empty.notGitRepositoryDescription`)})):T.type===`diff`?(0,$.jsx)(`div`,{ref:D,className:`h-full min-h-0`,children:(0,$.jsx)(_l,{path:T.path,directory:m,diff:ge,fileExists:Se,error:xe,loading:be,targetLine:T.targetLine,onBack:Ae,onRetry:()=>se(e=>e+1),hideHeader:i})}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:h?.current||m})]}),(0,$.jsx)(Bi,{syncAction:O,remotes:he,onSync:e=>void De(`sync`,e),disabled:A!==null||_,aheadCount:h?.ahead??0,behindCount:h?.behind??0,trackingRemoteName:h?.tracking?.split(`/`)[0],hasUncommittedChanges:(h?.files?.length??0)>0})]}),de?(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Sa,{stagedCount:pe,unstagedCount:me,onLoad:()=>ue(!0)})}):W.length>0?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-4 pt-4`,children:(0,$.jsx)(ji,{groups:Ie,diffStats:h?.diffStats,revertingPaths:P,onRevertAll:Me,isRevertingAll:I,headerBackgroundClassName:`bg-transparent`,onVisiblePathsChange:te})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-4 pt-3`,children:(0,$.jsx)(Di,{stagedCount:fe.length,commitMessage:M,onCommitMessageChange:N,generatedHighlights:z,onInsertHighlights:Ne,onGenerateMessage:Pe,isGeneratingMessage:R,onCommit:()=>void Fe({pushAfter:!1}),onCommitAndPush:()=>void Fe({pushAfter:!0}),commitAction:A,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(gl,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):Le((0,$.jsx)(gl,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},gl=e=>{let t=(0,Q.c)(13),{message:n,description:r,loading:i,icon:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c;t[0]===o?c=t[1]:(c=o?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):null,t[0]=o,t[1]=c);let l;t[2]===s?l=t[3]:(l=s?(0,$.jsx)(X,{name:`git-branch`,className:`size-6 text-muted-foreground`}):null,t[2]=s,t[3]=l);let u;t[4]===n?u=t[5]:(u=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[4]=n,t[5]=u);let d;t[6]===r?d=t[7]:(d=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[6]=r,t[7]=d);let f;return t[8]!==c||t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[c,l,u,d]})}),t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f},_l=e=>{let t=(0,Q.c)(26),{path:n,directory:r,diff:i,fileExists:a,error:o,loading:s,targetLine:c,onBack:l,onRetry:u,hideHeader:d}=e,f=d!==void 0&&d,{t:p}=Ee(),m=$r(),h;t[0]===n?h=t[1]:(h=Rr(n)||`text`,t[0]=n,t[1]=h);let g=h,_;t[2]!==r||t[3]!==m||t[4]!==n||t[5]!==p?(_=m?(0,$.jsx)(J,{variant:`ghost`,size:`icon`,title:p(`diffView.actions.openFilePreview`),"aria-label":p(`diffView.actions.openFilePreview`),onClick:()=>m.openFile({path:fe(r,n)}),children:(0,$.jsx)(X,{name:`eye`,className:`size-4`})}):null,t[2]=r,t[3]=m,t[4]=n,t[5]=p,t[6]=_):_=t[6];let v=_,y;t[7]!==f||t[8]!==l||t[9]!==n||t[10]!==v||t[11]!==p?(y=f?(0,$.jsx)(vr,{children:v}):(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":p(`header.actions.backAria`),onClick:l,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-2`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:n})}),v]}),t[7]=f,t[8]=l,t[9]=n,t[10]=v,t[11]=p,t[12]=y):y=t[12];let b;t[13]!==i||t[14]!==o||t[15]!==a||t[16]!==g||t[17]!==s||t[18]!==u||t[19]!==n||t[20]!==p||t[21]!==c?(b=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:o?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:p(`mobile.changes.diffDetail.loadFailed`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:o}),(0,$.jsx)(J,{type:`button`,size:`sm`,variant:`outline`,onClick:u,children:p(`diffView.actions.retry`)})]})}):s?(0,$.jsx)(gl,{loading:!0,message:p(`diffView.state.loadingDiff`)}):a?i?i.isBinary?(0,$.jsx)(gl,{icon:!0,message:p(`diffView.binary.unavailable`)}):zr(n)?(0,$.jsx)(gl,{icon:!0,message:p(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(Kr,{className:`h-full overflow-y-auto overflow-x-hidden p-3 pwa-overlay-scroll`,"data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:(0,$.jsx)(Ri,{original:i.original,modified:i.modified,language:g,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:c,layout:`inline`})}):(0,$.jsx)(gl,{loading:!0,message:p(`diffView.state.loadingDiff`)}):(0,$.jsx)(gl,{icon:!0,message:p(`mobile.changes.diffDetail.missingTitle`),description:p(`mobile.changes.diffDetail.missingDescription`)})}),t[13]=i,t[14]=o,t[15]=a,t[16]=g,t[17]=s,t[18]=u,t[19]=n,t[20]=p,t[21]=c,t[22]=b):b=t[22];let x;return t[23]!==y||t[24]!==b?(x=(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[y,b]}),t[23]=y,t[24]=b,t[25]=x):x=t[25],x},vl=e(C(),1),yl=pr(()=>ge(()=>import(`./ToolOutputDialog-CKyuEaps.js`).then(e=>e.n),__vite__mapDeps([3,1,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,2,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79]))),bl=25e4,xl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Sl=e=>{let t=xl(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},Cl=e=>{let t=xl(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},wl=(e,t)=>{let n=xl(e),r=xl(t);return!r||n===r?Sl(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},Tl=e=>{if(typeof e!=`number`||!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`],n=e/1024;for(let e of t){if(n<1024||e===t[t.length-1])return`${n.toFixed(n>=10?0:1)} ${e}`;n/=1024}return``},El=e=>/\.(md|mdx|markdown)$/i.test(e),Dl=e=>{let t=(0,Q.c)(156),{onClose:n,initialFilePath:r,directFilePreview:i,hideFileHeader:a}=e,o=r===void 0?null:r,s=i!==void 0&&i,c=a!==void 0&&a,{t:l}=Ee(),{files:u}=ti(),d=ni()??null,f;t[0]===d?f=t[1]:(f=xl(d),t[0]=d,t[1]=f);let p=f,m;t[2]!==o||t[3]!==p?(m=()=>{let e=xl(o);return e?{type:`file`,path:e,returnDirectory:Cl(e)??p}:{type:`browser`,directory:p}},t[2]=o,t[3]=p,t[4]=m):m=t[4];let[h,g]=Z.useState(m),_=Z.useRef(null),[v,y]=Z.useState(``),b=_e(Fl),x=_e(Il),S,C;t[5]===p?(S=t[6],C=t[7]):(S=()=>{p&&g(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:Cl(e.path)??p}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:p})},C=[p],t[5]=p,t[6]=S,t[7]=C),Z.useEffect(S,C);let w,T;t[8]!==b||t[9]!==p||t[10]!==x?(T=()=>{if(!b||!p)return;let e=xl(b);if(!e){x(null);return}y(``),g({type:`file`,path:e,returnDirectory:Cl(e)??p}),x(null)},w=[b,p,x],t[8]=b,t[9]=p,t[10]=x,t[11]=w,t[12]=T):(w=t[11],T=t[12]),Z.useEffect(T,w);let E=h.type===`browser`?h.directory:h.returnDirectory,D=h.type===`browser`?h.directory:``,O=h.type===`file`?h.path:``,[k,A]=Z.useState(`preview`),j;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{A(`preview`)},t[13]=j):j=t[13];let M;t[14]===O?M=t[15]:(M=[O],t[14]=O,t[15]=M),Z.useEffect(j,M);let N=Tr(v,250),P;t[16]===v?P=t[17]:(P=v.trim(),t[16]=v,t[17]=P);let F=P,I;t[18]===N?I=t[19]:(I=N.trim(),t[18]=N,t[19]=I);let L=I,R;t[20]!==D||t[21]!==p?(R={scopeDirectory:p,directory:D},t[20]=D,t[21]=p,t[22]=R):R=t[22];let ee=!!D,z;t[23]===ee?z=t[24]:(z={enabled:ee,refetchOnMount:`always`},t[23]=ee,t[24]=z);let B=H(R,z),V;t[25]!==D||t[26]!==L?(V={directory:D,query:L,maxResults:40},t[25]=D,t[26]=L,t[27]=V):V=t[27];let te=!!(D&&L),ne;t[28]===te?ne=t[29]:(ne={enabled:te},t[28]=te,t[29]=ne);let re=de(V,ne),ie;t[30]===O?ie=t[31]:(ie=O&&(!zr(O)||O.toLowerCase().endsWith(`.svg`)),t[30]=O,t[31]=ie);let U=!!ie,ae;t[32]!==O||t[33]!==p?(ae={scopeDirectory:p,path:O},t[32]=O,t[33]=p,t[34]=ae):ae=t[34];let ce;t[35]===U?ce=t[36]:(ce={enabled:U},t[35]=U,t[36]=ce);let le=se(ae,ce),ue=U&&le.data?.isBinary===!0,W;t[37]!==O||t[38]!==le.data||t[39]!==le.error||t[40]!==le.isFetchedAfterMount||t[41]!==u||t[42]!==k||t[43]!==ue?(W=O&&u.readFile&&le.data&&le.isFetchedAfterMount&&!le.error&&!ue&&(!Vr(O)||k===`source`)&&(!zr(O)||O.toLowerCase().endsWith(`.svg`)),t[37]=O,t[38]=le.data,t[39]=le.error,t[40]=le.isFetchedAfterMount,t[41]=u,t[42]=k,t[43]=ue,t[44]=W):W=t[44];let fe=!!W,G;t[45]!==O||t[46]!==p?(G={scopeDirectory:p,path:O},t[45]=O,t[46]=p,t[47]=G):G=t[47];let pe;t[48]===fe?pe=t[49]:(pe={enabled:fe},t[48]=fe,t[49]=pe);let me=oe(G,pe),he=B.data?.entries.slice().sort(Ll)??[],q;t[50]!==B.error||t[51]!==l?(q=B.error?B.error instanceof Error?B.error.message:l(`mobile.files.error.listFailed`):null,t[50]=B.error,t[51]=l,t[52]=q):q=t[52];let ge=q,ve=B.isFetching,ye;t[53]===re.data?ye=t[54]:(ye=re.data??[],t[53]=re.data,t[54]=ye);let be=ye,xe=!!(F&&L&&v===N&&re.isFetching),Se;t[55]!==me.data||t[56]!==l?(Se=me.data&&me.data.length>bl?`${me.data.slice(0,bl)}\n\n${l(`mobile.files.file.truncated`)}`:me.data??``,t[55]=me.data,t[56]=l,t[57]=Se):Se=t[57];let Ce=Se,we=le.error??me.error,Te;t[58]!==u||t[59]!==ue||t[60]!==U||t[61]!==we||t[62]!==l?(Te=U&&(!u.statFile||!ue&&!u.readFile)?l(`mobile.files.error.readUnavailable`):we?we instanceof Error?we.message:l(`filesView.error.readFileFailed`):null,t[58]=u,t[59]=ue,t[60]=U,t[61]=we,t[62]=l,t[63]=Te):Te=t[63];let De=Te,Oe=!De&&(U&&(!le.data||!le.isFetchedAfterMount)||fe&&me.isFetching&&me.data===void 0),ke;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(ke=e=>{y(``),g({type:`browser`,directory:e})},t[64]=ke):ke=t[64];let Ae=ke,je;t[65]!==E||t[66]!==p?(je=e=>{g({type:`file`,path:e,returnDirectory:E||p})},t[65]=E,t[66]=p,t[67]=je):je=t[67];let Me=je,Ne;t[68]!==s||t[69]!==n||t[70]!==h.returnDirectory||t[71]!==h.type?(Ne=()=>h.type===`file`?s?(n?.(),!0):(g({type:`browser`,directory:h.returnDirectory}),!0):!1,t[68]=s,t[69]=n,t[70]=h.returnDirectory,t[71]=h.type,t[72]=Ne):Ne=t[72];let Pe=K(Ne),Fe=h.type===`file`,Ie;t[73]!==Pe||t[74]!==Fe?(Ie={id:`mobile-files-detail`,active:Fe,layer:`overlay`,onBack:Pe,surfaceRef:_},t[73]=Pe,t[74]=Fe,t[75]=Ie):Ie=t[75],Nr(Ie);let Le;t[76]===l?Le=t[77]:(Le=async e=>{(await ot(e)).ok||Y.error(l(`mobile.files.toast.copyFailed`))},t[76]=l,t[77]=Le);let Re=Le,ze;t[78]!==Ce||t[79]!==l?(ze=async()=>{(await ot(Ce)).ok?Y.success(l(`mobile.files.toast.contentCopied`)):Y.error(l(`mobile.files.toast.copyFailed`))},t[78]=Ce,t[79]=l,t[80]=ze):ze=t[80];let Be=ze;if(!p){let e;t[81]===l?e=t[82]:(e=l(`mobile.files.empty.noDirectory`),t[81]=l,t[82]=e);let n;return t[83]===e?n=t[84]:(n=(0,$.jsx)(Pl,{message:e}),t[83]=e,t[84]=n),n}if(h.type===`file`){let e;t[85]!==Re||t[86]!==h.path?(e=()=>void Re(h.path),t[85]=Re,t[86]=h.path,t[87]=e):e=t[87];let n;t[88]===Be?n=t[89]:(n=()=>void Be(),t[88]=Be,t[89]=n);let r;return t[90]!==Pe||t[91]!==Ce||t[92]!==De||t[93]!==c||t[94]!==k||t[95]!==ue||t[96]!==Oe||t[97]!==h.path||t[98]!==e||t[99]!==n?(r=(0,$.jsx)(`div`,{ref:_,className:`flex h-full min-h-0 flex-col`,children:(0,$.jsx)(jl,{path:h.path,content:Ce,error:De,isLoading:Oe,isBinary:ue,hideHeader:c,htmlViewMode:k,onHtmlViewModeChange:A,onBack:Pe,onCopyPath:e,onCopyContent:n})}),t[90]=Pe,t[91]=Ce,t[92]=De,t[93]=c,t[94]=k,t[95]=ue,t[96]=Oe,t[97]=h.path,t[98]=e,t[99]=n,t[100]=r):r=t[100],r}let Ve;t[101]!==p||t[102]!==h.directory||t[103]!==l?(Ve=h.directory===p?l(`mobile.files.rootDirectory`):Sl(h.directory),t[101]=p,t[102]=h.directory,t[103]=l,t[104]=Ve):Ve=t[104];let He=Ve,Ue;t[105]!==v||t[106]!==be?(Ue=v.trim()?be:[],t[105]=v,t[106]=be,t[107]=Ue):Ue=t[107];let We=Ue,Ge,Ke,qe,Je;if(t[108]!==n||t[109]!==v||t[110]!==p||t[111]!==h.directory||t[112]!==l){let e=Cl(h.directory),r=h.directory!==p&&e!==null&&(e===p||e.startsWith(`${p}/`)),i=r&&!v.trim(),a=r?e:null;Je=`flex h-full flex-col overflow-hidden bg-background text-foreground`,Ge=`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[117]!==n||t[118]!==l?(Ke=n?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":l(`mobile.surface.closeAria`),onClick:n,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,t[117]=n,t[118]=l,t[119]=Ke):Ke=t[119],qe=i&&a?(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":l(`mobile.files.backToParentAria`,{name:Sl(a)}),onClick:()=>Ae(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}):null,t[108]=n,t[109]=v,t[110]=p,t[111]=h.directory,t[112]=l,t[113]=Ge,t[114]=Ke,t[115]=qe,t[116]=Je}else Ge=t[113],Ke=t[114],qe=t[115],Je=t[116];let Ye;t[120]===He?Ye=t[121]:(Ye=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:He})}),t[120]=He,t[121]=Ye);let Xe;t[122]===l?Xe=t[123]:(Xe=l(`mobile.files.refreshAria`),t[122]=l,t[123]=Xe);let Ze;t[124]===B?Ze=t[125]:(Ze=()=>void B.refetch(),t[124]=B,t[125]=Ze);let J;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(J={touchAction:`manipulation`},t[126]=J):J=t[126];let Qe=ve&&`animate-spin`,$e;t[127]===Qe?$e=t[128]:($e=it(`size-5`,Qe),t[127]=Qe,t[128]=$e);let et;t[129]===$e?et=t[130]:(et=(0,$.jsx)(X,{name:`refresh`,className:$e}),t[129]=$e,t[130]=et);let tt;t[131]!==Xe||t[132]!==Ze||t[133]!==et?(tt=(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":Xe,onClick:Ze,style:J,children:et}),t[131]=Xe,t[132]=Ze,t[133]=et,t[134]=tt):tt=t[134];let nt;t[135]!==Ge||t[136]!==Ke||t[137]!==qe||t[138]!==Ye||t[139]!==tt?(nt=(0,$.jsxs)(`header`,{className:Ge,children:[Ke,qe,Ye,tt]}),t[135]=Ge,t[136]=Ke,t[137]=qe,t[138]=Ye,t[139]=tt,t[140]=nt):nt=t[140];let rt;t[141]===Symbol.for(`react.memo_cache_sentinel`)?(rt=(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[141]=rt):rt=t[141];let at;t[142]===Symbol.for(`react.memo_cache_sentinel`)?(at=e=>y(e.target.value),t[142]=at):at=t[142];let st;t[143]===l?st=t[144]:(st=l(`mobile.files.search.placeholder`),t[143]=l,t[144]=st);let ct;t[145]!==v||t[146]!==st?(ct=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[rt,(0,$.jsx)(Kn,{type:`text`,inputMode:`search`,value:v,onChange:at,placeholder:st,className:`h-11 pl-9`})]})}),t[145]=v,t[146]=st,t[147]=ct):ct=t[147];let lt=Kr,ut=ge?(0,$.jsx)(Pl,{message:ge}):v.trim()?(0,$.jsx)(kl,{results:We,isSearching:xe,onOpenFile:Me}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[he.length===0&&!ve?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:l(`mobile.files.empty.directory`)}):null,he.map(e=>(0,$.jsx)(Ol,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:Tl(e.size),onClick:()=>e.isDirectory?Ae(e.path):Me(e.path)},e.path))]}),dt;t[148]!==lt||t[149]!==ut?(dt=(0,$.jsx)(lt,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:ut}),t[148]=lt,t[149]=ut,t[150]=dt):dt=t[150];let ft;return t[151]!==Je||t[152]!==nt||t[153]!==ct||t[154]!==dt?(ft=(0,$.jsxs)(`div`,{className:Je,children:[nt,ct,dt]}),t[151]=Je,t[152]=nt,t[153]=ct,t[154]=dt,t[155]=ft):ft=t[155],ft},Ol=e=>{let t=(0,Q.c)(16),{name:n,path:r,directory:i,meta:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==r?(c=i?(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(sn,{filePath:r,className:`size-5 shrink-0`}),t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:n}),t[4]=n,t[5]=l);let u;t[6]===a?u=t[7]:(u=a?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:a}):null,t[6]=a,t[7]=u);let d;t[8]===i?d=t[9]:(d=i?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null,t[8]=i,t[9]=d);let f;return t[10]!==o||t[11]!==c||t[12]!==l||t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-14 w-full items-center gap-3 border-b border-border/30 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:o,style:s,children:[c,l,u,d]}),t[10]=o,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f):f=t[15],f},kl=e=>{let t=(0,Q.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=Ee(),o=xl(ni()??null);if(r){let e;t[0]===a?e=t[1]:(e=a(`common.loading`),t[0]=a,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,$.jsx)(Pl,{loading:!0,message:e}),t[2]=e,t[3]=n),n}if(n.length===0){let e;t[4]===a?e=t[5]:(e=a(`mobile.files.search.empty`),t[4]=a,t[5]=e);let n;return t[6]===e?n=t[7]:(n=(0,$.jsx)(Pl,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(Ol,{name:Sl(e.path),path:e.path,directory:!1,meta:wl(e.path,o),onClick:()=>i(e.path)},e.path)),c;return t[8]===s?c=t[9]:(c=(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:s}),t[8]=s,t[9]=c),c},Al=e=>{let t=(0,Q.c)(26),{path:n,canUseText:r,htmlViewMode:i,htmlFullscreen:a,onToggleHtmlViewMode:o,onEnterHtmlFullscreen:s,onCopyPath:c,onCopyContent:l}=e,{t:u}=Ee(),d;t[0]===n?d=t[1]:(d=Vr(n),t[0]=n,t[1]=d);let f=d,p;t[2]!==r||t[3]!==f||t[4]!==a||t[5]!==i||t[6]!==s||t[7]!==o||t[8]!==u?(p=f&&r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:o,"aria-label":u(i===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:i===`preview`?`file-code`:`eye`,className:`size-4`})}),a?null:(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:s,"aria-label":u(`mobile.files.html.fullscreenAria`),children:(0,$.jsx)(X,{name:`fullscreen`,className:`size-4`})})]}):null,t[2]=r,t[3]=f,t[4]=a,t[5]=i,t[6]=s,t[7]=o,t[8]=u,t[9]=p):p=t[9];let m;t[10]!==r||t[11]!==f||t[12]!==l||t[13]!==n||t[14]!==u?(m=r&&!zr(n)&&!f?(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:l,"aria-label":u(`mobile.files.copyContentAria`),children:(0,$.jsx)(X,{name:`file-copy`,className:`size-4`})}):null,t[10]=r,t[11]=f,t[12]=l,t[13]=n,t[14]=u,t[15]=m):m=t[15];let h;t[16]!==r||t[17]!==f||t[18]!==c||t[19]!==n||t[20]!==u?(h=!r||zr(n)||f?(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:c,"aria-label":u(`mobile.files.copyPathAria`),children:(0,$.jsx)(X,{name:`clipboard`,className:`size-4`})}):null,t[16]=r,t[17]=f,t[18]=c,t[19]=n,t[20]=u,t[21]=h):h=t[21];let g;return t[22]!==p||t[23]!==m||t[24]!==h?(g=(0,$.jsxs)($.Fragment,{children:[p,m,h]}),t[22]=p,t[23]=m,t[24]=h,t[25]=g):g=t[25],g},jl=e=>{let t=(0,Q.c)(90),{path:n,content:r,error:i,isLoading:a,isBinary:o,hideHeader:s,htmlViewMode:c,onHtmlViewModeChange:l,onBack:u,onCopyPath:d,onCopyContent:f}=e,p=s!==void 0&&s,{t:m}=Ee(),h=Z.useRef(null),g=ni(),_=zr(n)&&!n.toLowerCase().endsWith(`.svg`)?n:``,v;t[0]===n?v=t[1]:(v=Cl(n)??``,t[0]=n,t[1]=v);let y=Hr(_,v,`preview`),[b,x]=Z.useState(``),S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S={open:!1,title:``,content:``},t[2]=S):S=t[2];let[C,w]=Z.useState(S),T=y.source,E;t[3]===n?E=t[4]:(E=Sl(n),t[3]=n,t[4]=E);let D=E,O;t[5]!==r||t[6]!==n?(O=zr(n)?`data:${Br(n)};utf8,${encodeURIComponent(r)}`:``,t[5]=r,t[6]=n,t[7]=O):O=t[7];let k=O,A;t[8]!==r||t[9]!==k||t[10]!==T||t[11]!==n?(A=T||(zr(n)&&r?k:``),t[8]=r,t[9]=k,t[10]=T,t[11]=n,t[12]=A):A=t[12];let j=A,M;t[13]!==i||t[14]!==b||t[15]!==y.error||t[16]!==j||t[17]!==m?(M=i??y.error??(j&&b===j?m(`filesView.error.readFileFailed`):null),t[13]=i,t[14]=b,t[15]=y.error,t[16]=j,t[17]=m,t[18]=M):M=t[18];let N=M,P;t[19]===j?P=t[20]:(P=()=>x(j),t[19]=j,t[20]=P);let F=K(P),I;t[21]!==D||t[22]!==_||t[23]!==n||t[24]!==j?(I=e=>{let t=_||j;t&&w({open:!0,title:D,content:``,previewSource:e.currentTarget.querySelector(`img`)??void 0,metadata:{tool:`image-preview`,filename:D,mime:Br(n)},image:{url:t,mimeType:Br(n),filename:D}})},t[21]=D,t[22]=_,t[23]=n,t[24]=j,t[25]=I):I=t[25];let L=K(I),R;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{w(t=>t.open===e?t:{...t,open:e})},t[26]=R):R=t[26];let ee=K(R),z;t[27]===n?z=t[28]:(z=Vr(n),t[27]=n,t[28]=z);let B=z,[V,te]=Z.useState(!1),ne=Z.useRef(null),re;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{te(!1)},t[29]=re):re=t[29];let H;t[30]===n?H=t[31]:(H=[n],t[30]=n,t[31]=H),Z.useEffect(re,H);let ie;t[32]!==c||t[33]!==l?(ie=()=>{l(c===`preview`?`source`:`preview`)},t[32]=c,t[33]=l,t[34]=ie):ie=t[34];let U=K(ie),ae;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>{te(!0)},t[35]=ae):ae=t[35];let oe=K(ae),se;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>(te(!1),!0),t[36]=se):se=t[36];let ce=K(se),le=B&&V,ue;t[37]!==ce||t[38]!==le?(ue={id:`mobile-html-fullscreen`,active:le,layer:`overlay`,onBack:ce,surfaceRef:ne},t[37]=ce,t[38]=le,t[39]=ue):ue=t[39],Nr(ue);let de=!o&&!a&&!i,W;t[40]!==oe||t[41]!==V||t[42]!==c||t[43]!==f||t[44]!==d||t[45]!==n||t[46]!==de||t[47]!==U?(W=(0,$.jsx)(Al,{path:n,canUseText:de,htmlViewMode:c,htmlFullscreen:V,onToggleHtmlViewMode:U,onEnterHtmlFullscreen:oe,onCopyPath:d,onCopyContent:f}),t[40]=oe,t[41]=V,t[42]=c,t[43]=f,t[44]=d,t[45]=n,t[46]=de,t[47]=U,t[48]=W):W=t[48];let fe=W,G;t[49]!==r||t[50]!==i||t[51]!==c||t[52]!==a||t[53]!==n||t[54]!==m?(G=c===`source`?a?(0,$.jsx)(Pl,{loading:!0,message:m(`filesView.state.loading`)}):i?(0,$.jsx)(Ka,{message:i}):(0,$.jsx)(Nl,{path:n,content:r}):(0,$.jsx)(Ml,{path:n}),t[49]=r,t[50]=i,t[51]=c,t[52]=a,t[53]=n,t[54]=m,t[55]=G):G=t[55];let pe=G,me;t[56]!==ce||t[57]!==B||t[58]!==pe||t[59]!==V||t[60]!==c||t[61]!==D||t[62]!==m||t[63]!==U?(me=B?(0,$.jsxs)(`div`,{ref:ne,"data-mobile-html-preview":c===`preview`&&!V?`true`:void 0,"data-mobile-html-fullscreen":c===`preview`&&V?`true`:void 0,className:V?`fixed inset-0 z-[80] flex flex-col bg-background text-foreground`:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[V?(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-border/50 px-3 pb-2 pt-[max(0.5rem,env(safe-area-inset-top))]`,children:[(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:ce,"aria-label":m(`mobile.files.html.exitFullscreenAria`),className:`shrink-0 text-muted-foreground`,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-header text-foreground`,children:D}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:U,"aria-label":m(c===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:c===`preview`?`file-code`:`eye`,className:`size-4`})})]}):null,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden bg-background`,children:pe})]}):null,t[56]=ce,t[57]=B,t[58]=pe,t[59]=V,t[60]=c,t[61]=D,t[62]=m,t[63]=U,t[64]=me):me=t[64];let he=me,q=g??void 0,ge;t[65]!==r||t[66]!==i||t[67]!==fe||t[68]!==F||t[69]!==ee||t[70]!==p||t[71]!==B||t[72]!==V||t[73]!==he||t[74]!==N||t[75]!==D||t[76]!==C||t[77]!==y.loading||t[78]!==o||t[79]!==a||t[80]!==u||t[81]!==L||t[82]!==n||t[83]!==j||t[84]!==m?(ge=e=>{let{preview:t,controls:s}=e;return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,"data-mobile-edge-to-edge-preview":`true`,children:[p?(0,$.jsxs)(vr,{children:[s,fe]}):(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":m(`header.actions.backAria`),onClick:u,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:D})}),s,fe]}),(0,$.jsx)(`div`,{ref:h,className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:t??(o&&!a&&!i?(0,$.jsx)(Fa,{path:n},n):B&&!a&&!i?V&&typeof document<`u`?(0,vl.createPortal)(he,document.body):he:a||y.loading?zr(n)?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-4`,children:(0,$.jsx)(Ur,{className:`aspect-square w-64 max-w-full rounded-lg`})}):(0,$.jsx)(Pl,{loading:!0,message:m(`filesView.state.loading`)}):N?(0,$.jsx)(Ka,{message:N}):zr(n)&&j?(0,$.jsx)(Kr,{className:`h-full overflow-auto p-4`,children:(0,$.jsx)(`button`,{type:`button`,className:`mx-auto block w-full cursor-zoom-in rounded-lg border-0 bg-transparent p-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary [&>.yuri-image-frame]:w-full`,onClick:L,"aria-label":D,children:(0,$.jsx)(Wr,{src:j,alt:D,className:`h-auto w-full rounded-lg object-contain`,draggable:!1,onError:F})})}):(0,$.jsx)(Nl,{path:n,content:r}))}),(0,$.jsx)(Sn,{containerRef:h}),C.open?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(yl,{popup:C,onOpenChange:ee,isMobile:!0})}):null]})},t[65]=r,t[66]=i,t[67]=fe,t[68]=F,t[69]=ee,t[70]=p,t[71]=B,t[72]=V,t[73]=he,t[74]=N,t[75]=D,t[76]=C,t[77]=y.loading,t[78]=o,t[79]=a,t[80]=u,t[81]=L,t[82]=n,t[83]=j,t[84]=m,t[85]=ge):ge=t[85];let _e;return t[86]!==n||t[87]!==q||t[88]!==ge?(_e=(0,$.jsx)(bi,{path:n,base:q,children:ge}),t[86]=n,t[87]=q,t[88]=ge,t[89]=_e):_e=t[89],_e},Ml=e=>{let t=(0,Q.c)(5),{path:n}=e,{projectScope:r}=ti(),i=ni(),a=r?.location.directory??i??``,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={backgroundColor:`var(--surface-background)`},t[0]=o):o=t[0];let s;return t[1]!==n||t[2]!==r||t[3]!==a?(s=(0,$.jsx)(qi,{path:n,directory:a,entry:r,className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-background`,iframeClassName:`h-full min-h-0 w-full flex-1 border-none bg-background`,iframeStyle:o}),t[1]=n,t[2]=r,t[3]=a,t[4]=s):s=t[4],s},Nl=e=>{let t=(0,Q.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=Qt(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??dr(!1),t[0]=a,t[1]=o,t[2]=c):c=t[2];let l=c,u;t[3]!==a||t[4]!==s?(u=a.find(e=>e.metadata.id===s)??dr(!0),t[3]=a,t[4]=s,t[5]=u):u=t[5];let d=u,f,p;t[6]!==d||t[7]!==l?(f=()=>{Mr(l),Mr(d)},p=[d,l],t[6]=d,t[7]=l,t[8]=f,t[9]=p):(f=t[8],p=t[9]),Z.useEffect(f,p);let m;t[10]!==d.metadata.id||t[11]!==l.metadata.id?(m={light:l.metadata.id,dark:d.metadata.id},t[10]=d.metadata.id,t[11]=l.metadata.id,t[12]=m):m=t[12];let h=m;if(El(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Kr,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(mr,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=Sl(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=Rr(n)||void 0,t[17]=n,t[18]=_);let v;t[19]!==r||t[20]!==g||t[21]!==_?(v={name:g,contents:r,lang:_},t[19]=r,t[20]=g,t[21]=_,t[22]=v):v=t[22];let y=i.metadata.variant===`dark`?`dark`:`light`,b;t[23]!==h||t[24]!==y?(b={disableFileHeader:!0,overflow:`wrap`,theme:h,themeType:y,unsafeCSS:Si},t[23]=h,t[24]=y,t[25]=b):b=t[25];let x;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(x={minHeight:`100%`},t[26]=x):x=t[26];let S;return t[27]!==b||t[28]!==v?(S=(0,$.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,$.jsx)(Kr,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(Ce,{file:v,options:b,className:`block min-h-full w-full`,style:x})})}),t[27]=b,t[28]=v,t[29]=S):S=t[29],S},Pl=e=>{let t=(0,Q.c)(7),{message:n,loading:r}=e,i=r!==void 0&&r,a;t[0]===i?a=t[1]:(a=i?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-open-fill`,className:`size-6 text-muted-foreground`}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s};function Fl(e){return e.pendingFileFocusPath}function Il(e){return e.setPendingFileFocusPath}function Ll(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}var Rl=S(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),zl=36,Bl=18,Vl=e=>e.parentID??null,Hl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Ul=e=>{let t=e;return Hl(t.directory??t.project?.worktree??null)},Wl=e=>{let t=Hl(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},Gl=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},Kl=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),ql=e=>{if(e<=0)return``;let t=Date.now()-e;if(t<6e4)return`now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return`${r}h`;let i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))},Jl=(e,t)=>{let n=Hl(e),r=Hl(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},Yl=(e,t)=>e.worktrees.find(e=>Hl(e.path)===t)??null,Xl=(e,t)=>t===e.path||!!Yl(e,t),Zl=(e,t)=>{let n=Hl(t);return n?e.find(e=>Xl(e,n))??null:null},Ql=(e,t,n)=>!n||`${e.title??``} ${e.id} ${Ul(e)} ${t}`.toLowerCase().includes(n),$l=e=>{let t=(0,Q.c)(14),{project:n,size:r}=e,i=r===void 0?`md`:r,a=i===`sm`?`size-6 rounded-md`:`size-8 rounded-lg`,o=i===`sm`?`size-3.5`:`size-4`,s=n.icon?Yr[n.icon]:null,c=n.color?Xr[n.color]:void 0,l=s??`folder-open`,u;t[0]===c?u=t[1]:(u=c?{color:c}:void 0,t[0]=c,t[1]=u);let d;t[2]!==o||t[3]!==l||t[4]!==u?(d=(0,$.jsx)(X,{name:l,className:o,style:u}),t[2]=o,t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=d,p;t[6]===a?p=t[7]:(p=it(`flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,a),t[6]=a,t[7]=p);let m;t[8]!==f||t[9]!==n?(m=n.iconImage?(0,$.jsx)(qr,{project:n,className:`size-full object-contain`,fallback:f}):f,t[8]=f,t[9]=n,t[10]=m):m=t[10];let h;return t[11]!==p||t[12]!==m?(h=(0,$.jsx)(`span`,{className:p,children:m}),t[11]=p,t[12]=m,t[13]=h):h=t[13],h},eu=e=>{let t=(0,Q.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=it(`flex size-5 shrink-0 items-center justify-center text-muted-foreground/70 transition-transform duration-150`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`span`,{"aria-hidden":!0,className:i,children:a}),t[3]=i,t[4]=o),o},tu=e=>{let t=(0,Q.c)(2),{ariaLabel:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`inline-block size-1.5 shrink-0 rounded-full bg-primary`,"aria-label":n}),t[0]=n,t[1]=r),r},nu=e=>{let t=(0,Q.c)(12),{onClick:n,className:r}=e,{t:i}=Ee(),a;t[0]===i?a=t[1]:(a=i(`sessions.sidebar.project.actions.newWorktree`),t[0]=i,t[1]=a);let o=a,s;t[2]===r?s=t[3]:(s=it(`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,r),t[2]=r,t[3]=s);let c;t[4]===n?c=t[5]:(c=e=>{e.stopPropagation(),n()},t[4]=n,t[5]=c);let l,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l={touchAction:`manipulation`},u=(0,$.jsx)(X,{name:`node-tree`,className:`size-4`}),t[6]=l,t[7]=u):(l=t[6],u=t[7]);let d;return t[8]!==o||t[9]!==s||t[10]!==c?(d=(0,$.jsx)(`button`,{type:`button`,className:s,"aria-label":o,title:o,onClick:c,style:l,children:u}),t[8]=o,t[9]=s,t[10]=c,t[11]=d):d=t[11],d},ru=e=>{let t=(0,Q.c)(10),{icon:n,label:r,onClick:i,destructive:a}=e,o=a!==void 0&&a?`destructive`:`ghost`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(X,{name:n,className:`size-5 shrink-0 text-inherit`}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=l);let u;return t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(J,{type:`button`,variant:o,size:`default`,className:`min-h-12 w-full justify-start gap-3 rounded-xl px-3 typography-ui-label`,onClick:i,style:s,children:[c,l]}),t[5]=i,t[6]=o,t[7]=c,t[8]=l,t[9]=u):u=t[9],u},iu=e=>{let t=(0,Q.c)(107),{session:n,active:r,indent:i,contextLabel:a,confirmingArchive:o,hasChildren:s,expanded:c,onToggleChildren:l,onSelect:u,onRequestArchive:d,onConfirmArchive:f,onStop:p,stopAriaLabel:m,longPressHandlers:h,highlightQuery:g}=e,_=o!==void 0&&o,v=s!==void 0&&s,y=c!==void 0&&c,{t:b}=Ee(),x;t[0]===n?x=t[1]:(x=ql(Gl(n)),t[0]=n,t[1]=x);let S=x,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,R,ee,z;if(t[2]!==r||t[3]!==_||t[4]!==y||t[5]!==v||t[6]!==g||t[7]!==i||t[8]!==h.onContextMenu||t[9]!==h.onPointerCancel||t[10]!==h.onPointerDown||t[11]!==h.onPointerMove||t[12]!==h.onPointerUp||t[13]!==h.pressed||t[14]!==u||t[15]!==l||t[16]!==n.title||t[17]!==b){z=n.title?.trim()||b(`mobile.sessions.untitled`);let e=r&&!_&&`bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]`,a=_&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`;t[36]!==e||t[37]!==a?(N=it(`relative flex items-center gap-1 transition-colors`,e,a),t[36]=e,t[37]=a,t[38]=N):N=t[38],t[39]!==y||t[40]!==v||t[41]!==i||t[42]!==l||t[43]!==b?(P=v&&l?(0,$.jsx)(`button`,{type:`button`,className:`absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,style:{left:Math.max(i-32,2),top:0,bottom:0,touchAction:`manipulation`},"aria-label":b(y?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:e=>{e.stopPropagation(),l()},children:(0,$.jsx)(X,{name:`arrow-down-s`,className:it(`size-[18px] transition-transform duration-150`,y?`rotate-0`:`-rotate-90`)})}):null,t[39]=y,t[40]=v,t[41]=i,t[42]=l,t[43]=b,t[44]=P):P=t[44],C=`button`;let o=_&&`opacity-50`,s=h.pressed&&`bg-interactive-active scale-[0.99]`;t[45]!==o||t[46]!==s?(w=it(`flex min-h-12 min-w-0 flex-1 items-center gap-2.5 py-2 pr-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o,s),t[45]=o,t[46]=s,t[47]=w):w=t[47],t[48]===i?T=t[49]:(T={paddingLeft:i,touchAction:`manipulation`},t[48]=i,t[49]=T),E=u,D=h.onPointerDown,O=h.onPointerMove,k=h.onPointerUp,A=h.onPointerCancel,j=h.onContextMenu,M=_,ee=`flex min-w-0 flex-1 flex-col`,L=`flex items-center gap-2.5`;let c=r?`bg-primary`:`bg-muted-foreground/30`,d;t[50]===c?d=t[51]:(d=it(`size-1.5 shrink-0 rounded-full`,c),t[50]=c,t[51]=d),t[52]===d?R=t[53]:(R=(0,$.jsx)(`span`,{className:d,"aria-hidden":!0}),t[52]=d,t[53]=R);let f=r?`text-primary`:`text-foreground`;t[54]===f?F=t[55]:(F=it(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),I=g?rr(z,g):z,t[2]=r,t[3]=_,t[4]=y,t[5]=v,t[6]=g,t[7]=i,t[8]=h.onContextMenu,t[9]=h.onPointerCancel,t[10]=h.onPointerDown,t[11]=h.onPointerMove,t[12]=h.onPointerUp,t[13]=h.pressed,t[14]=u,t[15]=l,t[16]=n.title,t[17]=b,t[18]=C,t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A,t[26]=j,t[27]=M,t[28]=N,t[29]=P,t[30]=F,t[31]=I,t[32]=L,t[33]=R,t[34]=ee,t[35]=z}else C=t[18],w=t[19],T=t[20],E=t[21],D=t[22],O=t[23],k=t[24],A=t[25],j=t[26],M=t[27],N=t[28],P=t[29],F=t[30],I=t[31],L=t[32],R=t[33],ee=t[34],z=t[35];let B;t[56]!==F||t[57]!==I?(B=(0,$.jsx)(`span`,{className:F,children:I}),t[56]=F,t[57]=I,t[58]=B):B=t[58];let V;t[59]===S?V=t[60]:(V=S?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:S}):null,t[59]=S,t[60]=V);let te;t[61]!==B||t[62]!==V||t[63]!==L||t[64]!==R?(te=(0,$.jsxs)(`span`,{className:L,children:[R,B,V]}),t[61]=B,t[62]=V,t[63]=L,t[64]=R,t[65]=te):te=t[65];let ne;t[66]!==a||t[67]!==g?(ne=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?rr(a,g):a}):null,t[66]=a,t[67]=g,t[68]=ne):ne=t[68];let re;t[69]!==te||t[70]!==ne||t[71]!==ee?(re=(0,$.jsxs)(`span`,{className:ee,children:[te,ne]}),t[69]=te,t[70]=ne,t[71]=ee,t[72]=re):re=t[72];let H;t[73]!==C||t[74]!==w||t[75]!==T||t[76]!==E||t[77]!==D||t[78]!==O||t[79]!==k||t[80]!==A||t[81]!==j||t[82]!==M||t[83]!==re?(H=(0,$.jsx)(`button`,{type:C,className:w,style:T,onClick:E,onPointerDown:D,onPointerMove:O,onPointerUp:k,onPointerCancel:A,onContextMenu:j,disabled:M,children:re}),t[73]=C,t[74]=w,t[75]=T,t[76]=E,t[77]=D,t[78]=O,t[79]=k,t[80]=A,t[81]=j,t[82]=M,t[83]=re,t[84]=H):H=t[84];let ie;t[85]!==p||t[86]!==m?(ie=p?(0,$.jsx)(`button`,{type:`button`,className:`mr-0.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":m,onClick:e=>{e.stopPropagation(),p()},style:{touchAction:`manipulation`},children:(0,$.jsx)(ea,{})}):null,t[85]=p,t[86]=m,t[87]=ie):ie=t[87];let U;t[88]===b?U=t[89]:(U=b(`sessions.sidebar.session.menu.label`),t[88]=b,t[89]=U);let ae;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(X,{name:`more-2`,className:`size-4`}),t[90]=ae):ae=t[90];let oe;t[91]!==h.onOpenActions||t[92]!==U?(oe=(0,$.jsx)(J,{variant:`ghost`,size:`icon`,"data-session-drag-ignore":!0,"aria-label":U,onClick:h.onOpenActions,children:ae}),t[91]=h.onOpenActions,t[92]=U,t[93]=oe):oe=t[93];let se;t[94]!==_||t[95]!==f||t[96]!==d||t[97]!==b||t[98]!==z?(se=d?(0,$.jsxs)($.Fragment,{children:[_?(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 shrink-0 items-center gap-1.5 rounded-xl bg-destructive px-3 text-destructive-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,"aria-label":b(`mobile.sessions.archiveSessionAria`,{title:z}),onClick:f,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`archive`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:b(`sessions.sidebar.bulkActions.archive`)})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`mr-1.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":b(_?`mobile.sessions.cancelArchiveAria`:`mobile.sessions.archiveSessionAria`,{title:z}),onClick:d,style:{touchAction:`manipulation`},children:_?(0,$.jsx)(X,{name:`close`,className:`size-4`}):(0,$.jsx)(X,{name:`archive`,className:`size-4`})})]}):null,t[94]=_,t[95]=f,t[96]=d,t[97]=b,t[98]=z,t[99]=se):se=t[99];let ce;return t[100]!==N||t[101]!==P||t[102]!==H||t[103]!==ie||t[104]!==oe||t[105]!==se?(ce=(0,$.jsxs)(`div`,{className:N,children:[P,H,ie,oe,se]}),t[100]=N,t[101]=P,t[102]=H,t[103]=ie,t[104]=oe,t[105]=se,t[106]=ce):ce=t[106],ce},au=e=>{let t=(0,Q.c)(15),{indent:n,showMore:r,showFewer:i,loadingMore:a,onShowMore:o,onShowFewer:s}=e,c=a!==void 0&&a,{t:l}=Ee();if(!r&&!i)return null;let u;t[0]===n?u=t[1]:(u={paddingLeft:n,touchAction:`manipulation`},t[0]=n,t[1]=u);let d;t[2]!==s||t[3]!==i||t[4]!==l?(d=i?(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:s,children:[(0,$.jsx)(X,{name:`arrow-up-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showFewer`)})]}):null,t[2]=s,t[3]=i,t[4]=l,t[5]=d):d=t[5];let f;t[6]!==c||t[7]!==o||t[8]!==r||t[9]!==l?(f=r?(0,$.jsxs)(`button`,{type:`button`,className:it(`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-60`,c&&`animate-pulse`),onClick:o,disabled:c,children:[(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showMore`)})]}):null,t[6]=c,t[7]=o,t[8]=r,t[9]=l,t[10]=f):f=t[10];let p;return t[11]!==u||t[12]!==d||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-h-10 w-full items-center gap-3 py-1.5 pr-3 text-muted-foreground`,style:u,children:[d,f]}),t[11]=u,t[12]=d,t[13]=f,t[14]=p):p=t[14],p},ou=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=Ee(),{git:i}=ce(),a=bt(),o=rt(),s=Lt(e=>e.activeSessions),c=Lt(e=>e.activePaginationByDirectory),l=st(e=>e.projects),u=Z.useMemo(()=>l.filter(e=>!e.hostId),[l]),d=l.some(e=>!!e.hostId),f=Xt(e&&d),p=f.catalog?.projects??[],m=st(e=>e.activeProjectId),h=O(e=>e.currentDirectory),g=Ot(e=>e.currentSessionId),_=Ot(e=>e.availableWorktreesByProject),v=Ot(e=>e.setCurrentSession),y=Ot(e=>e.archiveSession),b=Ot(e=>e.archiveSessions),x=Ot(e=>e.updateSessionTitle),S=Ot(e=>e.requestSessionSmartTitle),C=Ot(e=>e.shareSession),w=Ot(e=>e.unshareSession),T=Ot(e=>e.openNewSessionDraft),E=st(e=>e.setActiveProject),D=st(e=>e.setActiveProjectIdOnly),k=st(e=>e.removeProject),A=mt();Vi();let j=dt(e=>e.sessionOrderByScope),M=dt(e=>e.sessionOrderActivityByScope),N=zt(),P=Ti(e=>e.projectExpanded),F=Ti(e=>e.worktreeExpanded),I=Ti(e=>e.setProjectExpanded),L=Ti(e=>e.setWorktreeExpanded),R=St(e=>e.orderByProject),ee=Rl(e=>e.expandedParents),z=Rl(e=>e.toggleParent),[B,V]=Z.useState(``),[te,ne]=Z.useState(null),[re,H]=Z.useState(null),[ie,U]=Z.useState(0),[ae,oe]=Z.useState(!1),[se,le]=Z.useState(!1),[ue,de]=Z.useState(null),[W,fe]=Z.useState(null),G=W?.kind===`session`?W.session:null,{unread:pe,onToggleRead:me}=pa(G,G?Ul(G):void 0),[he,q]=Z.useState(null),[ge,_e]=Z.useState(null),[ve,ye]=Z.useState(null),[be,xe]=Z.useState(``),[Se,Ce]=Z.useState(!1),[we,Te]=Z.useState(null),De=Z.useRef(null);De.current||=ga({onPressedKeyChange:_e});let[Oe,ke]=Z.useState(new Set),[Ae,je]=Z.useState(new Map),[Me,Ne]=Z.useState(new Map),Pe=Gi(),Fe=Na(),Ie=K(e=>{Lr(e),nt(e)}),Le=K(e=>{Promise.all(e.map(e=>(Lr(e),nt(e))))});Z.useEffect(()=>{if(!e){V(``),Ne(new Map),ne(null),H(null),fe(null),ye(null),Te(null),De.current?.reset();return}},[e]),Z.useEffect(()=>()=>{De.current?.reset()},[]),Z.useEffect(()=>{if(!e)return;if(u.length===0){Ot.setState(e=>{let t=oa(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),ke(e=>e.size===0?e:new Set),je(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(u.map(async e=>{let n=Hl(e.path);if(!n)return null;let r;try{r=await i.checkIsGitRepository(n)}catch{return{id:e.id,path:n,gitStatus:`failed`}}if(!r)return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:`success`,worktrees:[]};let[a,o]=await Promise.allSettled([Zr({id:e.id,path:n},{isCurrent:()=>!t}),Jr(n)]);return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:a.status===`fulfilled`?`success`:`failed`,worktrees:a.status===`fulfilled`?a.value.worktrees:void 0,rootBranchStatus:o.status===`fulfilled`?`success`:`failed`,rootBranch:o.status===`fulfilled`?o.value:void 0}}));if(t)return;let n=new Set(u.map(e=>Hl(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);Ot.setState(e=>{let t=oa(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),ke(t=>{let r=new Set([...t].filter(e=>n.has(e)));for(let t of e)t?.gitStatus===`success`&&(t.isGitRepo?r.add(t.path):r.delete(t.path));return Kl(r,t)?t:r}),je(t=>{let n=new Set(u.map(e=>e.id)),r=new Map([...t].filter(([e])=>n.has(e)));for(let t of e){if(!t||t.gitStatus!==`success`)continue;if(!t.isGitRepo){r.delete(t.id);continue}if(t.rootBranchStatus!==`success`)continue;let e=t.rootBranch?.trim();e&&e!==`HEAD`?r.set(t.id,e):r.delete(t.id)}return r.size===t.size&&[...r].every(([e,n])=>t.get(e)===n)?t:r})})(),()=>{t=!0}},[i,e,u,ie]);let Re=Z.useMemo(()=>u.map(e=>({id:e.id,label:Wl(e.path),path:Hl(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:Oe.has(Hl(e.path)),worktrees:Ct(R[e.id],_.get(Hl(e.path))??[])})),[Oe,u,R,_]),ze=Z.useMemo(()=>{let e=new Map(o.map(e=>[e.id,e])),t=s.map(t=>{let n=e.get(t.id);return n?gt(n,t):t}),n=new Set(t.map(e=>e.id));for(let e of o)n.has(e.id)||t.push(e);return t},[s,o]),Be=B.trim().toLowerCase(),Ve=Z.useMemo(()=>{let e=Re.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===m})),t=(e,t,n)=>{let r=Hl(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||Wl(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a};for(let n of e){t(n,n.project.path,null);for(let e of n.project.worktrees)t(n,e.path,e)}for(let n of ze){let r=Ul(n);if(!r)continue;let i=Hl(r),a=e.find(e=>Xl(e.project,i));if(!a)continue;let o=Yl(a.project,i);(o?t(a,o.path,o):t(a,a.project.path,null)).sessions.push(n)}for(let t of e)for(let e of t.buckets){let n=Hl(e.path),r=xi(e.sessions.map(e=>({session:e})),j[n],M[n],A);e.sessions.sort((e,t)=>r({session:e},{session:t}));for(let n of e.sessions)Vl(n)||(t.totalSessions+=1)}return e},[m,Re,ze,j,M,A]),He=Hl(h),Ue=e=>e.isActive?He===e.project.path?e.project.path:e.project.worktrees.find(e=>Jl(He,e.path))?.path??e.project.path:null,We=e=>P[e.project.id]??!0,Ge=(e,t)=>F[`${e.project.id}::${t.key}`]??!1,Ke=e=>{Ne(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},qe=()=>{fe(null),De.current?.reset()},Je=e=>({onOpenActions:()=>fe(e),pressed:ge===e.key||W?.key===e.key,onPointerDown:t=>{e.kind!==`session`&&(t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||De.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>fe(e)}))},onPointerMove:e=>{De.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{De.current?.end(e.pointerId)},onPointerCancel:e=>{De.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),e.kind!==`session`&&De.current?.openFromContextMenu(e.key,()=>fe(e))}}),Ye=(e,t)=>{De.current?.consumeClick(e)||t()},Xe=(e,t,n,r)=>{let i=ha(),a=ja();if(Ne(t=>{let r=new Map(t),o=Math.max(i,t.get(e)??i,n);return r.set(e,o+a),r}),Math.max(i,n)+a<r)return;let o=Hl(t);if(!o)return;let s=Lt.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&Ft(o)},Ze=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=ha(),o=new Set(t.sessions.map(e=>e.id)),s=new Map;for(let e of t.sessions){let t=Vl(e);if(t&&o.has(t)){let n=s.get(t)??[];n.push(e),s.set(t,n)}}let l=t.sessions.filter(e=>!Vl(e)),u=Me.get(i)??a,d=Pa(l,u,Fe),f=l.length-d.length,p=c.get(Hl(t.path)),m=p?.hasMore===!0,h=p?.loadingMore===!0,_=l.length>a&&u>a,v=(e,t)=>{let n=s.get(e.id)??[],i=n.length>0,a=!!ee[e.id],o=Pe.has(e.id),c=i&&!a?n.filter(e=>Pe.has(e.id)).map(e=>e.id):[],l=c.length>0,u=o?[e.id,...c]:c,d=e.title?.trim()||r(`mobile.sessions.untitled`),f=`session:${e.id}`;return(0,$.jsxs)(Z.Fragment,{children:[(0,$.jsx)(iu,{session:e,active:g===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>z(e.id):void 0,confirmingArchive:re===e.id,onSelect:()=>Ye(f,()=>tt(e)),onRequestArchive:()=>at(e.id),onConfirmArchive:()=>void ct(e),onStop:o||l?()=>Le(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:d}),longPressHandlers:Je({key:f,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+Bl)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[l.length===0&&!m&&!h?(0,$.jsx)(`div`,{className:`py-1.5 pr-3 typography-ui-label font-normal text-muted-foreground/80`,style:{paddingLeft:n},children:r(`sessions.sidebar.group.empty.noSessionsInWorkspace`)}):null,(0,$.jsx)(Fi,{scopeKey:re?null:Hl(t.path),sessionIds:d.map(e=>e.id),folderIdBySessionId:new Map(d.map(e=>[e.id,dt.getState().getSessionFolderId(Hl(t.path),e.id)])),onSessionDroppedOnFolder:()=>{},onSessionsReordered:(e,n)=>{dt.getState().reorderSessions(Hl(t.path),d.map(e=>e.id),e,n,Ui(t.sessions)).catch(()=>Y.error(r(`sessions.order.saveFailed`)))},children:d.map(e=>re?v(e,n):(0,$.jsx)(ki,{sessionId:e.id,sessionDirectory:t.path,sessionTitle:e.title??``,children:v(e,n)},e.id))}),(0,$.jsx)(au,{indent:n,showMore:f>0||m,showFewer:_,loadingMore:h,onShowMore:()=>Xe(i,t.path,u,l.length),onShowFewer:()=>Ke(i)})]})},Qe=(e,t)=>{I(e,!t)},et=(e,t,n)=>{L(`${e}::${t}`,!n)},tt=e=>{gr();let n=Ul(e)||null,r=Zl(Re,n??``);r&&D(r.id),v(e.id,n),t(!1)},at=e=>{H(t=>t===e?null:e)},ct=async e=>{H(null),await y(e.id)?ua({sessionIds:[e.id],message:r(`sessions.sidebar.session.archive.success`),undoLabel:r(`sessions.sidebar.undo`),settingsLabel:r(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:r(`sessions.sidebar.session.archive.undoFailed`)}):Y.error(r(`sessions.sidebar.session.archive.error`))},lt=()=>{T(),t(!1)},ft=e=>{de(e),D(e),le(!0)},pt=e=>{let t=new Map;for(let e of ze){let n=Vl(e);if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n},ht=async e=>{let t=pt(e.id),{archivedIds:n,failedIds:i}=await b(t);n.length>0&&ua({sessionIds:n,message:n.length===1?r(`sessions.sidebar.session.archive.success`):r(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:r(`sessions.sidebar.undo`),settingsLabel:r(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n.length===1?r(`sessions.sidebar.session.archive.undoFailed`):r(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),i.length>0&&Y.error(i.length===1?r(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):r(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}))},_t=e=>{let t=pt(e.id);da({sessionIds:t,message:t.length===1?r(`sessions.sidebar.session.delete.success`):r(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:r(`sessions.sidebar.undo`),commitFailedMessage:r(`sessions.sidebar.session.delete.error`)})},vt=async e=>{try{if(!(await C(e.id))?.share?.url){Y.error(r(`sessions.sidebar.session.share.error`));return}Y.success(r(`sessions.sidebar.session.share.successTitle`),{description:r(`sessions.sidebar.session.share.successDescription`)})}catch{Y.error(r(`sessions.sidebar.session.share.error`))}},yt=async e=>{if((await ot(e)).ok){Y.success(r(`sessions.sidebar.session.menu.copied`));return}Y.error(r(`sessions.sidebar.session.share.copyUrlError`))},xt=async e=>{try{if(await w(e)){Y.success(r(`sessions.sidebar.session.unshare.success`));return}Y.error(r(`sessions.sidebar.session.unshare.error`))}catch{Y.error(r(`sessions.sidebar.session.unshare.error`))}},wt=async()=>{if(!ve)return;let e=be.trim();if(e)try{await x(ve.id,e),ye(null),xe(``)}catch{Y.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},Tt=async()=>{if(!ve||Se)return;let e=ve.id;ye(null),xe(``),Ce(!0);try{await S(e)}catch{Y.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{Ce(!1)}},Et=(e,n)=>{D(e.id),T({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},Dt=e=>{(async()=>{try{await Zr({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=Ot.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await ut(n,ze)})()},kt=e=>{let t=Ul(e),n=Zl(Re,t);if(!n)return Wl(t)||t;let r=Yl(n,Hl(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},At=e=>{E(e.id),t(!1)},jt=Z.useMemo(()=>Be?Ve.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Be)?!0:e.buckets.some(t=>t.sessions.some(t=>Ql(t,e.project.label,Be)))):Ve,[Be,Ve]),Mt=Z.useMemo(()=>Be?ze.filter(e=>{let t=Ul(e);return Ql(e,Zl(Re,t)?.label??``,Be)}).sort((e,t)=>$e(t)-$e(e)):[],[Be,Re,ze]),Nt=Z.useMemo(()=>Be?Re.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Be)).map(e=>({...e,sessionCount:ze.filter(t=>!Vl(t)&&Xl(e,Hl(Ul(t)))).length})):[],[Be,Re,ze]),Pt=Be&&Mt.length===0&&Nt.length===0,It=Re.length>0?(0,$.jsxs)(J,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:lt,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,Rt=Re.find(e=>e.id===m)??null,Bt=Rt?.isGitRepo?(0,$.jsx)(J,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>ft(Rt.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`node-tree`,className:`size-4`})}):null,Vt=(0,$.jsx)(J,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>oe(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folder-add`,className:`size-4`})}),Ht=It||Vt?(0,$.jsxs)($.Fragment,{children:[It,Bt,Vt]}):null,Ut=W?.kind===`project`?W.project.label:W?.kind===`worktree`?W.worktree.branch||W.worktree.label||W.worktree.path:W?.kind===`session`?W.session.title?.trim()||r(`mobile.sessions.untitled`):``,Wt=Z.useMemo(()=>{if(!W)return[];if(W.kind===`project`){let e=W.project;return na({gitRepository:e.isGitRepo,onNewSession:()=>{qe(),Et(e,e.path)},onNewWorktree:()=>{qe(),ft(e.id)},onSyncSessions:()=>{qe(),Dt(e)},onEditProject:()=>{qe(),ne(e.id)},onCloseProject:()=>{qe(),q(e)}})}if(W.kind===`worktree`){let{project:e,worktree:t}=W;return Da({onNewSession:()=>{qe(),Et(e,t.path)},onDeleteWorktree:()=>{qe(),Te({project:e,worktree:t})}})}let e=W.session,t=!!e.share?.url;return ba({pinned:A.has(e.id),shared:t,unread:pe,onToggleRead:me?()=>{qe(),me()}:void 0,onRename:()=>{qe(),xe(e.title?.trim()||r(`mobile.sessions.untitled`)),ye(e)},onTogglePin:()=>{qe(),N(e.id)},onShare:!a||t?void 0:()=>{qe(),vt(e)},onCopyLink:a&&t?()=>{let t=e.share?.url;qe(),t&&yt(t)}:void 0,onUnshare:a&&t?()=>{qe(),xt(e.id)}:void 0,onArchive:()=>{qe(),ht(e)},onDelete:()=>{qe(),_t(e)}})},[W,pe,qe,ht,yt,_t,ft,vt,xt,me,A,Et,Dt,r,N]),Gt=Wt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Wt.map(e=>{let t=(0,$.jsx)(ru,{icon:e.icon,label:ia(e,r),destructive:e.destructive,onClick:e.onClick},e.id);return e.separated?(0,$.jsx)(`div`,{className:W?.kind===`project`?`border-t border-[var(--yuri-popup-divider)]`:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:t},e.id):t})}):null,Kt=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Kn,{value:B,onChange:e=>V(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:it(`h-11 pl-9`,B&&`pr-10`)}),B?(0,$.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":r(`mobile.sessions.clearSearchAria`),onClick:()=>V(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsxs)(Kr,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:[d&&f.registry&&p.map(e=>(0,$.jsx)(ta,{project:e,registry:f.registry,search:B,mobile:!0,reorderEnabled:!1},e.id)),Re.length===0&&!d?(0,$.jsx)(su,{title:r(`mobile.sessions.empty.noProjectsTitle`),description:r(`mobile.sessions.empty.noProjectsDescription`),action:(0,$.jsxs)(J,{type:`button`,size:`lg`,onClick:()=>oe(!0),children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):Pt&&!d?(0,$.jsx)(su,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Be?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 pt-2`,children:[Mt.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.sessions`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:Mt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Mt.map((e,t)=>{let n=Pe.has(e.id),i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:it(t>0&&`border-t border-border/30`),children:(0,$.jsx)(iu,{session:e,active:g===e.id,indent:12,contextLabel:kt(e),highlightQuery:Be,onSelect:()=>Ye(`session:${e.id}`,()=>tt(e)),longPressHandlers:Je({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>Ie(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,Nt.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.projects`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:Nt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Nt.map((e,t)=>{let n=`project:${e.id}`,r=Je({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:it(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:it(`flex min-h-14 min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,r.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(n,()=>At(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)($l,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:rr(e.label,Be)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(nu,{className:`mr-2`,onClick:()=>ft(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:jt.map((e,t)=>{let n=We(e),i=`project:${e.project.id}`,a=Je({key:i,kind:`project`,project:e.project}),o=Be?e.buckets.filter(t=>t.sessions.some(t=>Ql(t,e.project.label,Be))):e.buckets,s=Ue(e);return(0,$.jsxs)(`section`,{className:it(t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`div`,{className:`flex min-h-14 w-full items-center`,children:[(0,$.jsxs)(`button`,{type:`button`,className:it(`flex min-h-14 min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,a.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(i,()=>Qe(e.project.id,n)),onPointerDown:a.onPointerDown,onPointerMove:a.onPointerMove,onPointerUp:a.onPointerUp,onPointerCancel:a.onPointerCancel,onContextMenu:a.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:e.project.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)($l,{project:e.project}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-semibold text-foreground`,children:e.project.label}),Ae.get(e.project.id)?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:Ae.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(tu,{ariaLabel:r(`mobile.sessions.activeProjectAria`)}):null,(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.totalSessions})]}),(()=>{let t=n?[]:[...new Set(e.buckets.flatMap(e=>e.sessions.filter(e=>Pe.has(e.id)).map(e=>e.id)))];return t.length>0?(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] mr-1`,"aria-label":r(`mobile.sessions.stopGroupAria`,{label:e.project.label}),onClick:e=>{e.stopPropagation(),Le(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(ea,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(nu,{className:`mr-2`,onClick:()=>ft(e.project.id)}):null]}),n?(0,$.jsx)(`div`,{className:`pb-2`,children:(()=>{let t=o.find(e=>e.worktree===null),n=o.filter(e=>e.worktree!==null);return(0,$.jsxs)($.Fragment,{children:[t&&(t.sessions.length>0||n.length===0)?Ze(e,t,zl):null,n.map(t=>{let n=Ge(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Je({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:it(`flex min-h-11 w-full items-center gap-2 py-1.5 pl-4 pr-3 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(a,()=>et(e.project.id,t.key,n)),onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onPointerCancel:o.onPointerCancel,onContextMenu:o.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:t.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)(eu,{expanded:n}),(0,$.jsx)(X,{name:`node-tree`,className:it(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:it(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(tu,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>Pe.has(e.id)).map(e=>e.id);return e.length>0?(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":r(`mobile.sessions.stopGroupAria`,{label:t.label}),onClick:t=>{t.stopPropagation(),Le(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(ea,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?Ze(e,t,zl):null]},t.key)})]})})()}):null]},e.project.id)})})]}),(0,$.jsx)(Qi,{open:ae,onOpenChange:oe,forceMobile:!0}),(0,$.jsx)(Rn,{open:se,projectId:ue,onOpenChange:e=>{le(e),e||de(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?v(n.sessionId,e):T({selectedProjectId:ue,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(ir,{open:!!W,title:Ut,onClose:qe,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Gt}),(0,$.jsx)(ir,{open:!!he,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>q(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>q(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!he)return;let e=he;q(null),k(e.id),Y.success(r(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:r(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:r(`mobile.projects.closeConfirmMessage`,{title:he?.label??``})})}),(0,$.jsx)(ir,{open:!!ve,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{Se||(ye(null),xe(``))},footer:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`default`,className:`flex-1`,disabled:Se,onClick:()=>{ye(null),xe(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{type:`button`,variant:`default`,className:`flex-1`,disabled:!be.trim()||Se,onClick:()=>void wt(),children:r(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),wt()},children:[(0,$.jsx)(Kn,{value:be,onChange:e=>xe(e.target.value),autoFocus:!0,className:`h-12`,disabled:Se}),(0,$.jsxs)(J,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:Se,onClick:()=>void Tt(),children:[Se?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),r(`sessions.sidebar.session.rename.smartTitle`)]})]})}),we?(0,$.jsx)(xa,{open:!0,project:{id:we.project.id,path:we.project.path},worktree:we.worktree,onClose:()=>Te(null),onDeleted:()=>U(e=>e+1)}):null,(0,$.jsx)(la,{open:te!==null,project:Re.find(e=>e.id===te)??null,onClose:()=>ne(null),onWorktreesChanged:()=>U(e=>e+1)})]});return n===`sidebar`?e?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsx)(`div`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center justify-end gap-2 px-4`,children:Ht?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:Ht}):null}),Kt]}):null:(0,$.jsx)(br,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:Ht,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:Kt})},su=e=>{let t=(0,Q.c)(10),{title:n,description:r,action:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i?(0,$.jsx)(`div`,{className:`pt-2`,children:i}):null,t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c},cu=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,lu=[{image:Lc,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:Ic,titleKey:`assistants.guide.share.android.title`,descriptionKey:`assistants.guide.share.android.description`},{image:Rc,titleKey:`assistants.guide.share.pick.title`,descriptionKey:`assistants.guide.share.pick.description`}];function uu(){let e=(0,Q.c)(8),{t}=Ee(),n;e[0]===t?n=e[1]:(n=t(`common.loading`),e[0]=t,e[1]=n);let r,i,a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`h-10 w-10 animate-pulse rounded-xl bg-[var(--surface-muted)] motion-reduce:animate-none`}),i=(0,$.jsx)(`div`,{className:`mt-2 h-4 w-2/3 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),a=(0,$.jsx)(`div`,{className:`h-3.5 w-full animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),o=(0,$.jsx)(`div`,{className:`h-3.5 w-4/5 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),e[2]=r,e[3]=i,e[4]=a,e[5]=o):(r=e[2],i=e[3],a=e[4],o=e[5]);let s;return e[6]===n?s=e[7]:(s=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 p-5`,"aria-busy":`true`,"aria-label":n,children:[r,i,a,o]}),e[6]=n,e[7]=s),s}function du(e){let t=(0,Q.c)(35),{onEnable:n}=e,{t:r}=Ee(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`yuri-mobile-assistant-guide-hero`,"aria-hidden":`true`,children:(0,$.jsx)(`img`,{src:cu,alt:``})}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=r(`assistants.guide.disabledTitle`),t[1]=r,t[2]=a);let o;t[3]===a?o=t[4]:(o=(0,$.jsx)(`h2`,{className:`yuri-mobile-assistant-guide-title`,children:a}),t[3]=a,t[4]=o);let s;t[5]===r?s=t[6]:(s=r(`assistants.guide.disabledDescription`),t[5]=r,t[6]=s);let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(`p`,{className:`yuri-mobile-assistant-guide-description`,children:s}),t[7]=s,t[8]=c);let l;t[9]===r?l=t[10]:(l=r(`assistants.guide.enableAction`),t[9]=r,t[10]=l);let u;t[11]!==n||t[12]!==l?(u=(0,$.jsx)(J,{type:`button`,size:`lg`,onClick:n,children:l}),t[11]=n,t[12]=l,t[13]=u):u=t[13];let d;t[14]!==o||t[15]!==c||t[16]!==u?(d=(0,$.jsxs)(`div`,{className:`yuri-mobile-assistant-guide-body`,children:[o,c,u]}),t[14]=o,t[15]=c,t[16]=u,t[17]=d):d=t[17];let f;t[18]===r?f=t[19]:(f=r(`assistants.guide.shareTitle`),t[18]=r,t[19]=f);let p;t[20]===f?p=t[21]:(p=(0,$.jsx)(`h3`,{className:`yuri-mobile-assistant-guide-share-title`,children:f}),t[20]=f,t[21]=p);let m;t[22]===r?m=t[23]:(m=r(`assistants.guide.shareAria`),t[22]=r,t[23]=m);let h;t[24]===r?h=t[25]:(h=lu.map(e=>(0,$.jsxs)(`article`,{className:`yuri-mobile-assistant-guide-step`,children:[(0,$.jsx)(`div`,{className:`yuri-mobile-assistant-guide-step-image`,children:(0,$.jsx)(`img`,{src:e.image,alt:``})}),(0,$.jsxs)(`div`,{className:`yuri-mobile-assistant-guide-step-copy`,children:[(0,$.jsx)(`h4`,{children:r(e.titleKey)}),(0,$.jsx)(`p`,{children:r(e.descriptionKey)})]})]},e.titleKey)),t[24]=r,t[25]=h);let g;t[26]!==m||t[27]!==h?(g=(0,$.jsx)(`div`,{className:`yuri-mobile-assistant-guide-steps`,"aria-label":m,children:h}),t[26]=m,t[27]=h,t[28]=g):g=t[28];let _;t[29]!==p||t[30]!==g?(_=(0,$.jsxs)(`section`,{className:`yuri-mobile-assistant-guide-share`,children:[p,g]}),t[29]=p,t[30]=g,t[31]=_):_=t[31];let v;return t[32]!==_||t[33]!==d?(v=(0,$.jsxs)(`article`,{className:`yuri-mobile-assistant-guide`,children:[i,d,_]}),t[32]=_,t[33]=d,t[34]=v):v=t[34],v}function fu(e){let t=(0,Q.c)(51),{assistant:n,avatarSeed:r,unreadCount:i,assistantID:a,displayName:o,summary:s,editLabel:c,deleteLabel:l,onOpen:u,onEdit:d,onDelete:f,serverWorking:p}=e,m=_i(a,p!==void 0&&p),h=Wi(`assistant:${a}`,u),g=Z.useRef(null),_;t[0]!==c||t[1]!==d?(_={label:c,icon:`edit`,onClick:d},t[0]=c,t[1]=d,t[2]=_):_=t[2];let v;t[3]!==l||t[4]!==f?(v={label:l,icon:`delete-bin`,destructive:!0,onClick:f},t[3]=l,t[4]=f,t[5]=v):v=t[5];let y;t[6]!==_||t[7]!==v?(y=[_,v],t[6]=_,t[7]=v,t[8]=y):y=t[8];let b;t[9]!==h||t[10]!==y?(b=(0,$.jsx)(Ci,{swipe:h,actions:y}),t[9]=h,t[10]=y,t[11]=b):b=t[11];let x=h.dragging?`transition-none`:`transition-transform duration-150 ease-out`,S;t[12]===x?S=t[13]:(S=it(`yuri-mobile-assistant-card relative z-10 motion-reduce:transition-none`,x),t[12]=x,t[13]=S);let C=h.handleSelect,w=h.handlePointerDown,T=h.handlePointerMove,E=h.finishGesture,D=h.handlePointerCancel,O=`translate3d(${h.offset}px, 0, 0)`,k=h.offset===0?void 0:`transform`,A;t[14]!==O||t[15]!==k?(A={touchAction:`pan-y`,transform:O,willChange:k},t[14]=O,t[15]=k,t[16]=A):A=t[16];let j;t[17]!==a||t[18]!==r||t[19]!==o||t[20]!==m?(j=(0,$.jsx)(`span`,{className:`yuri-mobile-assistant-avatar`,children:(0,$.jsx)(vi,{name:a,avatarSeed:r,size:44,label:o,working:m,hoverTarget:g})}),t[17]=a,t[18]=r,t[19]=o,t[20]=m,t[21]=j):j=t[21];let M;t[22]===o?M=t[23]:(M=(0,$.jsx)(`span`,{className:`yuri-mobile-entity-title yuri-mobile-assistant-name block min-w-0 truncate font-semibold text-foreground`,children:o}),t[22]=o,t[23]=M);let N;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(N=it(`yuri-mobile-assistant-summary`,ro),t[24]=N):N=t[24];let P;t[25]===s?P=t[26]:(P=(0,$.jsx)(`span`,{className:N,children:s}),t[25]=s,t[26]=P);let F;t[27]!==M||t[28]!==P?(F=(0,$.jsxs)(`span`,{className:`yuri-mobile-assistant-card-content min-w-0 flex-1`,children:[M,P]}),t[27]=M,t[28]=P,t[29]=F):F=t[29];let I;t[30]===i?I=t[31]:(I=(0,$.jsx)(Xa,{count:i}),t[30]=i,t[31]=I);let L;t[32]!==h.finishGesture||t[33]!==h.handlePointerCancel||t[34]!==h.handlePointerDown||t[35]!==h.handlePointerMove||t[36]!==h.handleSelect||t[37]!==A||t[38]!==j||t[39]!==F||t[40]!==I||t[41]!==S?(L=(0,$.jsxs)(`button`,{ref:g,type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-feedback":`soft`,className:S,onClick:C,onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:D,style:A,children:[j,F,I]}),t[32]=h.finishGesture,t[33]=h.handlePointerCancel,t[34]=h.handlePointerDown,t[35]=h.handlePointerMove,t[36]=h.handleSelect,t[37]=A,t[38]=j,t[39]=F,t[40]=I,t[41]=S,t[42]=L):L=t[42];let R;t[43]!==n||t[44]!==f||t[45]!==d||t[46]!==L?(R=(0,$.jsx)(eo,{assistant:n,onEdit:d,onDelete:f,trigger:L}),t[43]=n,t[44]=f,t[45]=d,t[46]=L,t[47]=R):R=t[47];let ee;return t[48]!==R||t[49]!==b?(ee=(0,$.jsxs)(pi,{className:`yuri-mobile-assistant-card-shell relative isolate overflow-clip`,children:[b,R]}),t[48]=R,t[49]=b,t[50]=ee):ee=t[50],ee}function pu(e){let t=(0,Q.c)(128),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=Ee(),o=$r(),s=ze(),c=Ve();c.data?.assistants;let l;t[0]===c.data?.assistants?l=t[1]:(l=c.data?.assistants??[],t[0]=c.data?.assistants,t[1]=l);let u;t[2]===l?u=t[3]:(u=Za(l),t[2]=l,t[3]=u);let d=u,f=Vt(mu),[p,m]=Z.useState(null),h;t[4]===n?h=t[5]:(h=()=>n(),t[4]=n,t[5]=h);let g=K(h),_;t[6]!==o||t[7]!==f?(_=()=>{f(),o?.openSettings(`assistants`)},t[6]=o,t[7]=f,t[8]=_):_=t[8];let v=K(_),y;t[9]===r?y=t[10]:(y=e=>r(e),t[9]=r,t[10]=y);let b=K(y),x;t[11]===o?x=t[12]:(x=e=>{Ut(e,o?{openMobileSettings:o.openSettings}:void 0)},t[11]=o,t[12]=x);let S=K(x),C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{m(e)},t[13]=C):C=t[13];let w=K(C),T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{e||m(null)},t[14]=T):T=t[14];let E=K(T),D;t[15]===a?D=t[16]:(D=a(`assistants.title`),t[15]=a,t[16]=D);let O=D,k;t[17]===a?k=t[18]:(k=a(`assistants.menu.edit`),t[17]=a,t[18]=k);let A=k,j;t[19]===a?j=t[20]:(j=a(`assistants.settings.delete`),t[19]=a,t[20]=j);let M=j,N;t[21]===i?N=t[22]:(N=it(`yuri-assistant-mobile-catalog-page`,i),t[21]=i,t[22]=N);let P=N;if(s.isPending||s.data?.supported&&s.data.enabled&&c.isPending){let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(pi,{className:`yuri-mobile-assistant-loading`,children:(0,$.jsx)(uu,{})}),t[23]=e):e=t[23];let n;return t[24]!==P||t[25]!==O?(n=(0,$.jsx)(di,{title:O,className:P,surface:!1,children:e}),t[24]=P,t[25]=O,t[26]=n):n=t[26],n}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length>0){let e;t[27]===c.data?e=t[28]:(e=(0,$.jsx)(no,{snapshot:c.data,compact:!0,mobile:!0}),t[27]=c.data,t[28]=e);let n;t[29]===a?n=t[30]:(n=a(`assistants.settings.create`),t[29]=a,t[30]=n);let r;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(X,{name:`add`,className:`size-5`}),t[31]=r):r=t[31];let i;t[32]!==v||t[33]!==n?(i=(0,$.jsx)(J,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:`yuri-mobile-inverse-action`,"aria-label":n,onClick:v,children:r}),t[32]=v,t[33]=n,t[34]=i):i=t[34];let o;t[35]!==e||t[36]!==i?(o=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e,i]}),t[35]=e,t[36]=i,t[37]=o):o=t[37];let s;t[38]===a?s=t[39]:(s=a(`assistants.listAria`),t[38]=a,t[39]=s);let l;t[40]!==d.pinned||t[41]!==S||t[42]!==b||t[43]!==w?(l=(0,$.jsx)(io,{contacts:d.pinned,onSelect:b,onEdit:S,onDelete:w}),t[40]=d.pinned,t[41]=S,t[42]=b,t[43]=w,t[44]=l):l=t[44];let u;if(t[45]!==d.unpinned||t[46]!==M||t[47]!==A||t[48]!==S||t[49]!==b||t[50]!==w||t[51]!==a){let e;t[53]!==M||t[54]!==A||t[55]!==S||t[56]!==b||t[57]!==w||t[58]!==a?(e=e=>{let t=Wt(e.name).displayName||e.name,n=to(e.latestMessagePreview,a);return(0,$.jsx)(fu,{assistant:e,assistantID:e.id,avatarSeed:e.avatarSeed,unreadCount:e.unreadCount??0,displayName:t,summary:n,editLabel:A,deleteLabel:M,assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onOpen:()=>b(e.id),onEdit:()=>S(e.id),onDelete:()=>w(e)},e.id)},t[53]=M,t[54]=A,t[55]=S,t[56]=b,t[57]=w,t[58]=a,t[59]=e):e=t[59],u=d.unpinned.map(e),t[45]=d.unpinned,t[46]=M,t[47]=A,t[48]=S,t[49]=b,t[50]=w,t[51]=a,t[52]=u}else u=t[52];let f;t[60]!==s||t[61]!==l||t[62]!==u?(f=(0,$.jsxs)(`div`,{className:`yuri-mobile-assistant-catalog`,role:`listbox`,"aria-label":s,children:[l,u]}),t[60]=s,t[61]=l,t[62]=u,t[63]=f):f=t[63];let m=p!==null,h;t[64]!==p||t[65]!==E||t[66]!==m?(h=(0,$.jsx)($a,{assistant:p,open:m,onOpenChange:E}),t[64]=p,t[65]=E,t[66]=m,t[67]=h):h=t[67];let g;return t[68]!==P||t[69]!==O||t[70]!==o||t[71]!==f||t[72]!==h?(g=(0,$.jsxs)(di,{title:O,className:P,surface:!1,scrollsWithPage:!0,trailing:o,children:[f,h]}),t[68]=P,t[69]=O,t[70]=o,t[71]=f,t[72]=h,t[73]=g):g=t[73],g}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`yuri-mobile-assistant-onboarding-icon`,children:(0,$.jsx)(X,{name:`ai-agent`,className:`size-5`})}),t[74]=e):e=t[74];let n;t[75]===a?n=t[76]:(n=a(`assistants.onboarding.title`),t[75]=a,t[76]=n);let r;t[77]===n?r=t[78]:(r=(0,$.jsx)(`h2`,{children:n}),t[77]=n,t[78]=r);let i;t[79]===a?i=t[80]:(i=a(`assistants.onboarding.description`),t[79]=a,t[80]=i);let o;t[81]===i?o=t[82]:(o=(0,$.jsx)(`p`,{children:i}),t[81]=i,t[82]=o);let s;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),t[83]=s):s=t[83];let c;t[84]===a?c=t[85]:(c=a(`assistants.onboarding.action`),t[84]=a,t[85]=c);let l;t[86]!==v||t[87]!==c?(l=(0,$.jsxs)(J,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:v,children:[s,c]}),t[86]=v,t[87]=c,t[88]=l):l=t[88];let u;t[89]!==r||t[90]!==o||t[91]!==l?(u=(0,$.jsxs)(pi,{className:`yuri-mobile-assistant-onboarding`,children:[e,r,o,l]}),t[89]=r,t[90]=o,t[91]=l,t[92]=u):u=t[92];let d;return t[93]!==P||t[94]!==O||t[95]!==u?(d=(0,$.jsx)(di,{title:O,className:P,surface:!1,surfaceClassName:`yuri-mobile-assistant-state`,children:u}),t[93]=P,t[94]=O,t[95]=u,t[96]=d):d=t[96],d}let F=s.isSuccess&&s.data.supported===!1,I=s.isError||s.data?.supported===!0&&s.data.enabled&&c.isError,L=s.data?.supported===!0&&(s.data.enabled===!1||c.data?.enabled===!1),R;t[97]!==a||t[98]!==I||t[99]!==F?(R=a(I?`assistants.state.unavailable`:F?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[97]=a,t[98]=I,t[99]=F,t[100]=R):R=t[100];let ee=R;if(L&&!I){let e;t[101]===g?e=t[102]:(e=(0,$.jsx)(du,{onEnable:g}),t[101]=g,t[102]=e);let n;return t[103]!==P||t[104]!==O||t[105]!==e?(n=(0,$.jsx)(di,{title:O,className:P,surface:!1,surfaceClassName:`yuri-mobile-assistant-guide-host`,children:e}),t[103]=P,t[104]=O,t[105]=e,t[106]=n):n=t[106],n}let z;t[107]===O?z=t[108]:(z=(0,$.jsx)(`span`,{className:`yuri-mobile-page-section-label`,children:O}),t[107]=O,t[108]=z);let B=F?`cloud-off`:`sparkling`,V;t[109]===B?V=t[110]:(V=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground`,children:(0,$.jsx)(X,{name:B,weight:`medium`,className:`size-5`})}),t[109]=B,t[110]=V);let te;t[111]===ee?te=t[112]:(te=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:ee}),t[111]=ee,t[112]=te);let ne;t[113]!==a||t[114]!==I||t[115]!==F?(ne=I?null:(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-small leading-relaxed text-muted-foreground`,children:a(F?`assistants.state.unsupportedDescription`:`assistants.state.instanceDisabledDescription`)}),t[113]=a,t[114]=I,t[115]=F,t[116]=ne):ne=t[116];let re;t[117]!==V||t[118]!==te||t[119]!==ne?(re=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[V,te,ne]}),t[117]=V,t[118]=te,t[119]=ne,t[120]=re):re=t[120];let H;t[121]!==z||t[122]!==re?(H=(0,$.jsx)(mi,{label:z,cardClassName:`yuri-mobile-assistant-state-card`,children:re}),t[121]=z,t[122]=re,t[123]=H):H=t[123];let ie;return t[124]!==P||t[125]!==O||t[126]!==H?(ie=(0,$.jsx)(di,{title:O,className:P,surface:!1,surfaceClassName:`yuri-mobile-assistant-state`,children:H}),t[124]=P,t[125]=O,t[126]=H,t[127]=ie):ie=t[127],ie}function mu(e){return e.requestCreate}function hu(e){let t=(0,Q.c)(16),{assistantID:n,onBack:r}=e,{t:i}=Ee(),[a,o]=(0,Z.useState)(null),s;t[0]===i?s=t[1]:(s=i(`assistants.title`),t[0]=i,t[1]=s);let c;t[2]===i?c=t[3]:(c=i(`settings.view.actions.back`),t[2]=i,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`div`,{ref:o}),t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==s||t[7]!==c?(u=(0,$.jsx)(Be,{title:s,backAriaLabel:c,onBack:r,trailing:l}),t[5]=r,t[6]=s,t[7]=c,t[8]=u):u=t[8];let d;t[9]!==n||t[10]!==r||t[11]!==a?(d=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-[var(--yuri-mobile-page-inline-inset)] pb-[var(--yuri-safe-area-bottom,env(safe-area-inset-bottom,0px))]`,children:(0,$.jsx)(pi,{className:`yuri-mobile-settings-detail-card h-full`,children:(0,$.jsx)(sr,{children:(0,$.jsx)(Wa,{assistantID:n,onItemDeleted:r,onSaved:r,saveActionContainer:a},n)})})}),t[9]=n,t[10]=r,t[11]=a,t[12]=d):d=t[12];let f;return t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`div`,{"data-settings-view":`true`,"data-mobile-settings-stage":`page-content`,className:`yuri-settings-workspace yuri-settings-workspace-mobile flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[u,d]}),t[13]=u,t[14]=d,t[15]=f):f=t[15],f}function gu(e){let t=(0,Q.c)(13),{route:n}=e,{t:r}=Ee(),i;t[0]===r?i=t[1]:(i=r(`chat.btw.title`),t[0]=r,t[1]=i);let a;t[2]===r?a=t[3]:(a=r(`header.actions.backAria`),t[2]=r,t[3]=a);let o;t[4]!==i||t[5]!==a?(o=(0,$.jsx)(Be,{title:i,backAriaLabel:a,onBack:_u}),t[4]=i,t[5]=a,t[6]=o):o=t[6];let s;t[7]!==n.directory||t[8]!==n.sessionId?(s=(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(An,{scope:{sessionId:n.sessionId,directory:n.directory},foot:`page`})}),t[7]=n.directory,t[8]=n.sessionId,t[9]=s):s=t[9];let c;return t[10]!==o||t[11]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[o,s]}),t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function _u(){Ir.requestAnimatedBack(`root`)}var vu=[{id:`projects`,icon:`folder-open`,labelKey:`mobile.tabs.projects`},{id:`assistant`,icon:`sparkling`,labelKey:`mobile.tabs.assistant`},{id:`scheduled`,icon:`calendar-schedule`,labelKey:`mobile.tabs.scheduled`},{id:`settings`,icon:`settings-3`,labelKey:`mobile.tabs.settings`}];function yu(e){let t=(0,Q.c)(22),{activeTab:n,onTabChange:r,className:i,tabMarks:a}=e,{t:o}=Ee(),s=He(),c;t[0]===o?c=t[1]:(c=o(`mobile.tabs.activity.loading`),t[0]=o,t[1]=c);let l=c,u;t[2]===r?u=t[3]:(u=e=>{r(e.currentTarget.dataset.tab)},t[2]=r,t[3]=u);let d=K(u),f;t[4]!==n||t[5]!==r?(f=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=vu.findIndex(e=>e.id===n),i=vu[e.key===`Home`?0:e.key===`End`?vu.length-1:(t+(e.key===`ArrowRight`?1:-1)+vu.length)%vu.length];r(i.id),document.getElementById(`mobile-tab-${i.id}`)?.focus()},t[4]=n,t[5]=r,t[6]=f):f=t[6];let p=K(f),m;t[7]===o?m=t[8]:(m=o(`mobile.nav.aria`),t[7]=o,t[8]=m);let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h={role:`tablist`},t[9]=h):h=t[9];let g;t[10]!==n||t[11]!==s||t[12]!==d||t[13]!==p||t[14]!==l||t[15]!==o||t[16]!==a?(g=vu.map(e=>{let t=e.id===n,r=o(e.labelKey),i=e.id===`assistant`&&s>0,c=!i&&a?.[e.id]===`loading`,u=i?`mobile-tab-assistant-unread`:c?`mobile-tab-${e.id}-activity`:void 0;return(0,$.jsxs)(J,{id:`mobile-tab-${e.id}`,"data-tab":e.id,type:`button`,role:`tab`,variant:`ghost`,size:`sm`,"aria-controls":`mobile-tabpanel-${e.id}`,"aria-label":r,"aria-describedby":u,"aria-selected":t,tabIndex:t?0:-1,title:r,onClick:d,onKeyDown:p,className:it(`yuri-mobile-tab-button min-w-0 flex-1 flex-col overflow-visible`,`font-medium leading-none tracking-tight text-muted-foreground`,`transition-[background-color,color,box-shadow,transform] duration-100`,`hover:bg-transparent hover:text-foreground`,`active:bg-interactive-active`,`motion-reduce:transition-none`,t&&[`bg-interactive-selection/55 text-primary`,`hover:bg-interactive-selection/55 hover:text-primary`,`font-semibold`]),children:[(0,$.jsxs)(`span`,{className:`relative inline-flex size-[23px] shrink-0 items-center justify-center overflow-visible`,children:[e.id===`assistant`?(0,$.jsx)(fa,{size:23,className:`size-[23px] shrink-0 items-center justify-center [&[data-assistant-navigation-avatar]]:scale-105`}):(0,$.jsx)(X,{name:e.icon,weight:`medium`,className:`size-[23px] shrink-0`}),u?(0,$.jsx)(`span`,{id:u,role:c?`status`:void 0,"aria-label":c?l:void 0,"data-mobile-tab-activity":c?`loading`:void 0,className:`pointer-events-none absolute left-full -top-1 ml-0.5 inline-flex z-10`,children:i?(0,$.jsx)(Qa,{className:`h-[18px] min-w-[18px] px-1 text-[11px] font-bold tracking-normal ring-2 ring-background`}):(0,$.jsx)(`span`,{className:`inline-flex size-[18px] items-center justify-center rounded-full bg-foreground text-background ring-2 ring-background`,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin`})})}):null]}),(0,$.jsx)(`span`,{className:`yuri-mobile-tab-label block max-w-full overflow-hidden text-ellipsis whitespace-nowrap`,children:r})]},e.id)}),t[10]=n,t[11]=s,t[12]=d,t[13]=p,t[14]=l,t[15]=o,t[16]=a,t[17]=g):g=t[17];let _;return t[18]!==i||t[19]!==m||t[20]!==g?(_=(0,$.jsx)(hi,{as:`nav`,"aria-label":m,variant:`navigation`,surfaceProps:h,className:i,children:g}),t[18]=i,t[19]=m,t[20]=g,t[21]=_):_=t[21],_}function bu(e){return e.unreadCount>0?`unread`:e.working?`loading`:null}var xu=`yuri-native-ios-tab-bar`,Su=`YuriTabBar`,Cu=[`projects`,`assistant`,`scheduled`,`settings`],wu=he(Su),Tu=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function Eu(){return typeof window>`u`?!1:Tu({isCapacitor:g(),platform:y(),pluginAvailable:q.isPluginAvailable(Su),nativeUiEnabled:Or()})}var Du=e=>e.classList.contains(`dark`)?`dark`:`light`,Ou=()=>Ar(`--primary`),ku=e=>typeof e==`string`&&Cu.includes(e),Au=e=>typeof e==`string`&&ku(e)?e:null,ju=(e,t)=>e.selectedTab===t.selectedTab&&e.appearance===t.appearance&&e.ariaLabel===t.ariaLabel&&e.accentColor===t.accentColor&&e.tabs.length===t.tabs.length&&e.tabs.every((e,n)=>e.id===t.tabs[n]?.id&&e.label===t.tabs[n]?.label&&e.badge===t.tabs[n]?.badge&&e.activity===!0==(t.tabs[n]?.activity===!0)&&(e.activity===!0?e.activityLabel??null:null)===(t.tabs[n]?.activity===!0?t.tabs[n]?.activityLabel??null:null)),Mu=(e,t)=>{e.classList.toggle(xu,t)},Nu=(e,t)=>e&&!t,Pu=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&ju(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},Fu=()=>wu,Iu=`mobile-overlay-root`;function Lu(e){let t=(0,Q.c)(28),n=kr(),r;t[0]===n?r=t[1]:(r=n&&Eu(),t[0]=n,t[1]=r);let i=r,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=(0,Z.useRef)(!1),p=(0,Z.useRef)(!1),m=K(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=JSON.stringify(e.tabs.map(zu)),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:Du(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:Ou(),t[5]=y):y=t[5];let b=y,x,S;t[6]===i?(x=t[7],S=t[8]):(x=()=>{if(!i||typeof document>`u`)return;let e=document.getElementById(Iu);e||(e=document.createElement(`div`),e.id=Iu,document.body.appendChild(e));let t=()=>u(Fn(e.children));t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[Pn]}),()=>n.disconnect()},S=[i],t[6]=i,t[7]=x,t[8]=S),(0,Z.useEffect)(x,S);let C;t[9]!==i||t[10]!==m?(C=()=>{if(!i)return;let e=!1,t=Fu(),n=[];return t.addListener(`tabSelected`,e=>{let t=Au(e.tab);t&&m(t)}).then(t=>{if(e){t.remove();return}n.push(t)}),()=>{e=!0,d.current=null,t.hide();for(let e of n)e.remove();typeof document<`u`&&Mu(document.documentElement,!1)}},t[9]=i,t[10]=m,t[11]=C):C=t[11];let w;t[12]===i?w=t[13]:(w=[i],t[12]=i,t[13]=w),(0,Z.useEffect)(C,w);let T;t[14]!==e.activeTab||t[15]!==e.ariaLabel||t[16]!==e.tabs||t[17]!==e.visible||t[18]!==i||t[19]!==l?(T=()=>{if(!i||p.current)return;let t=!1,n=Fu(),r={tabs:e.tabs.map(Ru),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=Pu({visible:Nu(e.visible,l),overlayHidden:f.current,lastState:d.current,nextState:r});return(async()=>{if(a.action===`skip`)return;if(a.action===`hide`){f.current=!0,n.hide();return}let e=await n.present(r);if(!t){if(e.adopted!==!0){p.current=!0,c(!0),o(!1),typeof document<`u`&&Mu(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&Mu(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&Mu(document.documentElement,!1))}),()=>{t=!0}},t[14]=e.activeTab,t[15]=e.ariaLabel,t[16]=e.tabs,t[17]=e.visible,t[18]=i,t[19]=l,t[20]=T):T=t[20];let E;return t[21]!==e.activeTab||t[22]!==e.ariaLabel||t[23]!==e.visible||t[24]!==i||t[25]!==l||t[26]!==g?(E=[i,e.visible,l,e.activeTab,e.ariaLabel,v,b,g],t[21]=e.activeTab,t[22]=e.ariaLabel,t[23]=e.visible,t[24]=i,t[25]=l,t[26]=g,t[27]=E):E=t[27],(0,Z.useLayoutEffect)(T,E),!i||s?`web`:a?`native`:`pending`}function Ru(e){return{id:e.id,label:e.label,badge:e.badge??null,activity:e.activity===!0,activityLabel:e.activity===!0?e.activityLabel??null:null}}function zu(e){return[e.id,e.label,e.badge??null,e.activity===!0,e.activity===!0?e.activityLabel??null:null]}function Bu(e){let t=(0,Q.c)(52),{tabs:n,navigation:r,onTabChange:i,secondaryPages:a,showTabBar:o,tabBarCovered:s,className:c}=e,l=a===void 0?[]:a,u=o===void 0||o,d=s!==void 0&&s,{t:f}=Ee(),p=r.activeTab,m=l.slice(-2),h=m.at(-1)??null,g=h?.key??null,_=h?.depth,v=m.length>1?m[m.length-2].key:null,y;t[0]===p?y=t[1]:(y=()=>new Set([p]),t[0]=p,t[1]=y);let[b,x]=Z.useState(y);b.has(p)||x(e=>{if(e.has(p))return e;let t=new Set(e);return t.add(p),t});let S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(null),T=Z.useRef(new Map),E=Z.useRef(null),D=Z.useRef(!1),O=Z.useRef(``),k=K(()=>h?.onBack());Nr({id:h?`mobile-secondary:${h.key}`:`mobile-secondary:inactive`,active:!!h,onBack:k,surfaceRef:S,underlayRef:C}),Z.useLayoutEffect(()=>{let e=g===null?null:T.current.get(g)??null,t=v===null?w.current:T.current.get(v)??null;S.current=e,C.current=t},[g,_,v]);let A;t[2]===h?A=t[3]:(A=[h],t[2]=h,t[3]=A),Z.useLayoutEffect(()=>{if(h){if(!D.current){let e=document.activeElement;E.current=e instanceof HTMLElement?e:null,D.current=!0}O.current!==h.key&&(O.current=h.key,S.current?.focus());return}if(D.current){D.current=!1,O.current=``;let e=E.current;E.current=null,e&&e.isConnected&&e.focus()}},A);let j;t[4]===i?j=t[5]:(j=e=>{i(e)},t[4]=i,t[5]=j);let M=K(j),N=He(),P=Re(),F=Le(),I;t[6]===f?I=t[7]:(I=f(`mobile.tabs.activity.loading`),t[6]=f,t[7]=I);let L=I,R;t[8]!==N||t[9]!==P?(R=bu({unreadCount:N,working:P}),t[8]=N,t[9]=P,t[10]=R):R=t[10];let ee=R,z;t[11]===F?z=t[12]:(z=bu({unreadCount:0,working:F}),t[11]=F,t[12]=z);let B=z,V;t[13]!==ee||t[14]!==N||t[15]!==L||t[16]!==B||t[17]!==f?(V=vu.map(e=>{let t=e.id===`assistant`&&ee===`loading`||e.id===`scheduled`&&B===`loading`;return{id:e.id,label:f(e.labelKey),badge:e.id===`assistant`&&ee===`unread`?N>99?`99+`:String(N):null,activity:t,activityLabel:t?L:null}}),t[13]=ee,t[14]=N,t[15]=L,t[16]=B,t[17]=f,t[18]=V):V=t[18];let te=V,ne=u&&!d&&!h,re;t[19]===f?re=t[20]:(re=f(`mobile.nav.aria`),t[19]=f,t[20]=re);let H;t[21]!==M||t[22]!==ne||t[23]!==te||t[24]!==p||t[25]!==re?(H={visible:ne,activeTab:p,tabs:te,ariaLabel:re,onTabChange:M},t[21]=M,t[22]=ne,t[23]=te,t[24]=p,t[25]=re,t[26]=H):H=t[26];let ie=Lu(H),U=ie===`native`,ae=u&&ie===`web`,oe=kr(),se,ce;t[27]!==oe||t[28]!==U?(se=()=>{if(!oe){Fr.shutdown();return}U&&jr(!0)&&Fr.warm()},ce=[oe,U],t[27]=oe,t[28]=U,t[29]=se,t[30]=ce):(se=t[29],ce=t[30]),Z.useEffect(se,ce);let le=p===`assistant`&&`yuri-assistant-wallpaper`,ue;t[31]!==c||t[32]!==le?(ue=it(`yuri-mobile-floating-shell relative isolate flex h-full min-h-0 flex-col overflow-hidden text-foreground`,`bg-[var(--yuri-mobile-page-background)]`,le,c),t[31]=c,t[32]=le,t[33]=ue):ue=t[33];let de=h?!0:void 0,W=h?!0:void 0,fe=h?`true`:void 0,G;t[34]!==p||t[35]!==u||t[36]!==ae||t[37]!==f||t[38]!==n||t[39]!==b?(G=vu.map(e=>{let t=b.has(e.id);return(0,$.jsx)(`section`,{id:`mobile-tabpanel-${e.id}`,role:`tabpanel`,"aria-labelledby":ae?`mobile-tab-${e.id}`:void 0,"aria-label":ae?void 0:f(e.labelKey),hidden:p!==e.id,tabIndex:0,className:it(`scrollbar-none h-full min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--yuri-mobile-page-inline-inset)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+1rem)] outline-none`,u?`pb-[calc(var(--yuri-mobile-dock-height)+2.5rem+var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px)))]`:`pb-0`),children:t?n?.[e.id]??(0,$.jsx)(Vu,{tab:e.id,icon:e.icon}):null},e.id)}),t[34]=p,t[35]=u,t[36]=ae,t[37]=f,t[38]=n,t[39]=b,t[40]=G):G=t[40];let pe=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||U?!0:void 0,inert:h||U?!0:void 0,children:ae?(0,$.jsx)(yu,{activeTab:p,onTabChange:M,tabMarks:{assistant:ee===`loading`?`loading`:null,scheduled:B===`loading`?`loading`:null}}):null}):null,me;t[41]!==w||t[42]!==de||t[43]!==W||t[44]!==fe||t[45]!==G||t[46]!==pe?(me=(0,$.jsxs)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":de,inert:W,"data-mobile-navigation-parked":fe,className:`flex h-full min-h-0 flex-1 flex-col`,children:[G,pe]}),t[41]=w,t[42]=de,t[43]=W,t[44]=fe,t[45]=G,t[46]=pe,t[47]=me):me=t[47];let he=m.map((e,t)=>{let n=t===m.length-1;return(0,$.jsx)(`div`,{ref:t=>{t?T.current.set(e.key,t):T.current.delete(e.key)},"data-mobile-secondary-page":`true`,"data-mobile-secondary-active":n?`true`:`false`,role:n?`dialog`:void 0,"aria-modal":n?!0:void 0,"aria-label":n?e.ariaLabel??f(`mobile.nav.secondaryPageAria`):void 0,"aria-hidden":!n||void 0,inert:!n||void 0,tabIndex:n?-1:void 0,className:it(`absolute inset-0 flex h-full min-h-0 flex-col overflow-hidden bg-background outline-none`,n?`z-50`:`z-40`),children:e.content},e.key)}),q;return t[48]!==ue||t[49]!==me||t[50]!==he?(q=(0,$.jsxs)(`div`,{className:ue,children:[me,he]}),t[48]=ue,t[49]=me,t[50]=he,t[51]=q):q=t[51],q}function Vu(e){let t=(0,Q.c)(17),{tab:n,icon:r,className:i}=e,{t:a}=Ee(),o,s,c,l;if(t[0]!==i||t[1]!==r||t[2]!==a||t[3]!==n){let e=vu.find(e=>e.id===n)??vu[0];t[8]===i?c=t[9]:(c=it(`flex min-h-[70dvh] flex-col items-center justify-center gap-3 text-center`,i),t[8]=i,t[9]=c),l=(0,$.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:r??e.icon,className:`size-6`})}),o=`typography-ui-label font-semibold tracking-[-0.01em] text-foreground`,s=a(e.labelKey),t[0]=i,t[1]=r,t[2]=a,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];let u;t[10]!==o||t[11]!==s?(u=(0,$.jsx)(`h1`,{className:o,children:s}),t[10]=o,t[11]=s,t[12]=u):u=t[12];let d;return t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:c,children:[l,u]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}var Hu=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function Uu({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,onRemoteDesktop:a,instanceOptions:o,className:s}){let{t:c}=Ee(),{git:l}=ce(),u=bt(),d=Aa(),[f,p]=Z.useState(()=>new Map),m=K((e,t)=>{p(n=>{if(!t.length&&!n.has(e))return n;let r=new Map(n);return t.length?r.set(e,t):r.delete(e),r})}),g=K((e,t,n,r)=>{let i=dt.getState(),a=e===`__pinned__`?e:h(e);if(!a||a!==`__pinned__`&&i.getSessionFolderId(a,n)!==i.getSessionFolderId(a,r))return;let o=a===`__pinned__`?{}:Ui(d.allSessions.filter(e=>Ea(e)===a));i.reorderSessions(a,t,n,r,o).catch(()=>Y.error(c(`sessions.order.saveFailed`)))}),_=Ti(e=>e.setProjectExpanded),v=Ti(e=>e.setWorktreeExpanded),y=zt(),b=mt(),x=Ot(e=>e.archiveSessions),S=Ot(e=>e.updateSessionTitle),C=Ot(e=>e.requestSessionSmartTitle),w=Ot(e=>e.shareSession),T=Ot(e=>e.unshareSession),E=Ot(e=>e.openNewSessionDraft),D=jt(e=>e.openDraft),O=jt(e=>e.openSession),k=st(e=>e.projects),A=Ke(e=>e.projectSortOrder),j=zi(),M=Z.useMemo(()=>k.filter(e=>e.hostId).map(Jt),[k]),N=Z.useMemo(()=>[...d.inProgressSessions.map(e=>({session:e,time:d.sessionById.get(e.id)?$e(d.sessionById.get(e.id)):0})),...M.flatMap(e=>f.get(e.id)??[]).map(e=>({session:{id:e.identity,title:e.node.session.title||``,content:e.content},time:$e(e.node.session)}))].sort((e,t)=>t.time-e.time).map(e=>e.session),[d.inProgressSessions,d.sessionById,M,f]),P=st(e=>e.setActiveProjectIdOnly),F=st(e=>e.removeProject),I=vn(),[L,R]=Z.useState(null),[ee,z]=Z.useState(!1),[B,V]=Z.useState(null),[te,ne]=Z.useState(null),[re,H]=Z.useState(null),[ie,U]=Z.useState(``),[ae,oe]=Z.useState(!1),[se,le]=Z.useState(!1),[ue,de]=Z.useState(null),[W,fe]=Z.useState(null),[G,pe]=Z.useState(null),me=L?.kind===`session`?L.session.id:``,he=kt(me),q=he?.type===`busy`||he?.type===`retry`,ge=L?.kind===`session`?Ea(L.session):``,{unread:_e,onToggleRead:ve}=pa(L?.kind===`session`?L.session:null,ge),ye=!!me&&G===me,be=!ge||ye||q,xe=K(e=>{let t=new Map;for(let e of d.allSessions){let n=ya(e);if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n}),Se=K(()=>{z(!1),R(null)}),Ce=K(t=>{if(ra(t.id)){let e=ma(t.id);if(!e)return;e.kind===`more`?d.showMoreBucketSessions(e.projectId,e.bucketKey):d.resetBucketVisibleCount(e.projectId,e.bucketKey);return}let n=d.sessionById.get(t.id),r=n&&Ea(n)||null;e({sessionId:t.id,directory:r})}),we=K(e=>{ra(e.id)||y(e.id)}),Te=K(async e=>{if(ra(e.id))return;let t=xe(e.id),{archivedIds:n,failedIds:r}=await x(t);n.length>0&&ua({sessionIds:n,message:n.length===1?c(`sessions.sidebar.session.archive.success`):c(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:c(`sessions.sidebar.undo`),settingsLabel:c(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n.length===1?c(`sessions.sidebar.session.archive.undoFailed`):c(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&Y.error(r.length===1?c(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):c(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}),De=K(()=>{if(!L||L.kind!==`session`)return;let e=L.session,t=Ea(e),n=he?.type??`idle`;!t||G===e.id||n===`busy`||n===`retry`||(pe(e.id),(async()=>{try{await I.refreshSessionTranscript(e.id,{directory:t}),Y.success(c(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{Y.error(c(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{pe(t=>t===e.id?null:t)}})())}),Oe=K(e=>{if(ra(e.id))return;let t=d.sessionById.get(e.id);t&&(R({kind:`session`,session:t}),z(!0))}),ke=K(e=>{_(e.id,!e.expanded)}),Ae=K((e,t)=>{v(`${e.id}::${t.id}`,!t.expanded)}),je=K((e,t)=>{P(e.id),D({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),Me=K(()=>{let e=st.getState().getActiveProject();if(e?.hostId){gi(Jt(e),!0).catch(e=>Y.error(e instanceof Error?e.message:String(e)));return}if(n){n();return}E()}),Ne=K(e=>{let t=d.projectMetaById.get(e.id);t&&(R({kind:`project`,project:t,isGitRepository:!1}),z(!0),l.checkIsGitRepository(t.path).then(e=>{R(n=>Hu(n,t.id,e))}).catch(()=>{R(e=>Hu(e,t.id,!1))}))}),Pe=K((e,t)=>{let n=h(t);return n?e.worktrees.find(e=>h(e.path)===n)||((Ot.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>h(e.path)===n)??null):null}),Fe=K((e,t)=>{let n=d.projectMetaById.get(e.id);n&&je(n,t.path)}),Ie=K((e,t)=>{let n=d.projectMetaById.get(e.id);n&&(R({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),z(!0))}),Le=K((e,t)=>{let n=d.projectMetaById.get(e.id);if(!n)return;let r=Pe(n,t.path);if(!r){Y.error(c(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}fe({project:n,worktree:r})}),Re=K(e=>{de(e),P(e),le(!0)}),ze=K(e=>{(async()=>{let t=e.worktrees;try{t=(await Zr({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=Ot.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await ut([e.path,...t.map(e=>e.path)],d.allSessions)})()}),Be=K((e,t)=>{let n=ue;if(le(!1),de(null),t?.sessionId){O({sessionId:t.sessionId,directory:e});return}D({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),Ve=K(async e=>{try{if(!(await w(e.id))?.share?.url){Y.error(c(`sessions.sidebar.session.share.error`));return}Y.success(c(`sessions.sidebar.session.share.successTitle`),{description:c(`sessions.sidebar.session.share.successDescription`)})}catch{Y.error(c(`sessions.sidebar.session.share.error`))}}),He=K(async e=>{if((await ot(e)).ok){Y.success(c(`sessions.sidebar.session.menu.copied`));return}Y.error(c(`sessions.sidebar.session.share.copyUrlError`))}),Ue=K(async e=>{try{if(await T(e)){Y.success(c(`sessions.sidebar.session.unshare.success`));return}Y.error(c(`sessions.sidebar.session.unshare.error`))}catch{Y.error(c(`sessions.sidebar.session.unshare.error`))}}),We=K(e=>{let t=xe(e.id);da({sessionIds:t,message:t.length===1?c(`sessions.sidebar.session.delete.success`):c(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:c(`sessions.sidebar.undo`),commitFailedMessage:c(`sessions.sidebar.session.delete.error`)})}),Ge=K(async()=>{if(!re)return;let e=ie.trim();if(e)try{await S(re.id,e),H(null),U(``)}catch{Y.error(c(`sessions.sidebar.session.menu.rename`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),qe=K(async()=>{if(!re||ae)return;let e=re.id;H(null),U(``),oe(!0);try{await C(e)}catch{Y.error(c(`sessions.sidebar.session.rename.smartTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{oe(!1)}}),Je=Z.useMemo(()=>L?L.kind===`session`?{kind:`session`,title:L.session.title?.trim()||c(`mobile.sessions.untitled`),pinned:b.has(L.session.id),shared:!!L.session.share?.url,unread:_e}:L.kind===`project`?{kind:`project`,title:L.project.label,gitRepository:L.isGitRepository}:{kind:`worktree`,title:L.worktreeName}:null,[L,_e,b,c]),Ye=Z.useMemo(()=>{if(!L)return{};if(L.kind===`session`){let e=L.session;return{onRename:()=>{U(e.title?.trim()||c(`mobile.sessions.untitled`)),H(e)},onTogglePin:()=>y(e.id),onToggleRead:ve,onShare:u&&!e.share?.url?()=>{Ve(e)}:void 0,onCopyLink:u&&e.share?.url?()=>{He(e.share.url)}:void 0,onUnshare:u&&e.share?.url?()=>{Ue(e.id)}:void 0,onRefreshTranscript:De,onArchive:()=>{Te({id:e.id,title:e.title?.trim()||c(`mobile.sessions.untitled`)})},onDelete:()=>We(e)}}if(L.kind===`project`){let e=L.project;return{onNewSession:()=>je(e,e.path),onNewWorktree:()=>Re(e.id),onSyncSessions:()=>ze(e),onEditProject:()=>V(e.id),onCloseProject:()=>ne(e)}}let{project:e,worktreePath:t}=L;return{onNewSession:()=>je(e,t),onDeleteWorktree:()=>{let n=Pe(e,t);if(!n){Y.error(c(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}fe({project:e,worktree:n})}}},[L,Te,He,We,De,Re,ze,Ve,Ue,ve,Pe,u,je,c,y]),Xe=Z.useMemo(()=>{if(!B)return null;let e=k.find(e=>e.id===B),t=d.projectMetaById.get(B);if(!e||!t)return null;let n=L?.kind===`project`&&L.project.id===B?L.isGitRepository:t.worktrees.length>0;return{id:e.id,label:e.label?.trim()||t.label,path:h(e.path)||t.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:n,worktrees:t.worktrees}},[L,B,d.projectMetaById,k]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ca,{remoteProjects:M,hostRegistry:j.registry,projectOrderIds:aa(k,A).map(e=>e.id),renderRemoteProject:j.registry?e=>(0,$.jsx)(ta,{project:e,registry:j.registry,mobile:!0,reorderEnabled:!1,onActivityItems:m}):void 0,remoteError:j.catalog.error?.message,className:s,projects:d.projects,pinnedSessions:d.pinnedSessions,inProgressSessions:N,onAddProject:t,onNewSession:Me,onScanQr:r,onSwitchInstance:i,instanceOptions:o,onRemoteDesktop:a,onToggleProject:ke,onOpenProjectActions:Ne,onToggleWorktree:Ae,onNewWorktreeSession:Fe,onOpenWorktreeActions:Ie,onDeleteWorktree:Le,onSelectSession:Ce,onPinSession:we,onArchiveSession:e=>{Te(e)},onOpenSessionActions:Oe,onReorderSessions:g}),(0,$.jsx)(Ma,{open:ee,target:Je,actions:Ye,refreshTranscriptDisabled:be,refreshTranscriptSpinning:ye,onOpenChange:e=>{e?z(!0):Se()}}),(0,$.jsx)(Rn,{open:se,projectId:ue,onOpenChange:e=>{le(e),e||de(null)},onWorktreeCreated:Be}),W?(0,$.jsx)(xa,{open:!0,project:{id:W.project.id,path:W.project.path},worktree:W.worktree,onClose:()=>fe(null)}):null,(0,$.jsx)(ir,{open:!!te,title:c(`sessions.sidebar.project.actions.closeProject`),onClose:()=>ne(null),closeAriaLabel:c(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>ne(null),children:c(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!te)return;let e=te;ne(null),F(e.id),Y.success(c(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:c(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:c(`mobile.projects.closeConfirmMessage`,{title:te?.label??``})})}),(0,$.jsx)(ir,{open:!!re,title:c(`sessions.sidebar.session.menu.rename`),onClose:()=>{ae||(H(null),U(``))},closeAriaLabel:c(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`default`,className:`flex-1`,disabled:ae,onClick:()=>{H(null),U(``)},children:c(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{type:`button`,variant:`default`,className:`flex-1`,disabled:!ie.trim()||ae,onClick:()=>void Ge(),children:c(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),Ge()},children:[(0,$.jsx)(Kn,{value:ie,onChange:e=>U(e.target.value),autoFocus:!0,className:`h-12`,disabled:ae}),(0,$.jsxs)(J,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:ae,onClick:()=>void qe(),children:[ae?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),c(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(la,{open:B!==null,project:Xe,onClose:()=>V(null)})]})}function Wu(e){let t=(0,Q.c)(10),{children:n,content:r,className:i,contentClassName:a,showHeader:o}=e,s=o===void 0||o,{t:c}=Ee(),l;t[0]===c?l=t[1]:(l=c(`sessions.scheduledTasks.dialog.title`),t[0]=c,t[1]=l);let u;t[2]===a?u=t[3]:(u=it(`yuri-mobile-scheduled-content`,a),t[2]=a,t[3]=u);let d=n??r,f;return t[4]!==i||t[5]!==s||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,$.jsx)(di,{title:l,className:i,surface:!1,scrollsWithPage:!0,showHeader:s,surfaceClassName:u,children:d}),t[4]=i,t[5]=s,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function Gu(e){let t=(0,Q.c)(10),{className:n,contentClassName:r,instancesPage:i}=e,{t:a}=Ee(),o;t[0]===a?o=t[1]:(o=a(`mobile.settings.placeholder.title`),t[0]=a,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=[...fr],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(Ga,{forceMobile:!0,isWindowed:!0,hideMobileHeader:!0,flowMobile:!0,autoOpenMobilePage:!0,visiblePageSlugs:s,mobileInstancesPage:i}),t[3]=i,t[4]=c);let l;return t[5]!==n||t[6]!==r||t[7]!==o||t[8]!==c?(l=(0,$.jsx)(di,{title:o,className:n,surface:!1,scrollsWithPage:!0,showHeader:!1,surfaceClassName:r,children:c}),t[5]=n,t[6]=r,t[7]=o,t[8]=c,t[9]=l):l=t[9],l}function Ku(e){let t=(0,Q.c)(115),{onAddProject:n,onScanQr:r,onSwitchInstance:i,onRemoteDesktop:a,remoteDesktopActive:o,instanceOptions:s,onEnableAssistants:c,instancesPage:l,instancesSecondaryPage:u,parentSessionTarget:d,registerSecondaryBackHandler:f,scheduledContent:p,renderChat:m,className:g}=e,_=o!==void 0&&o,v=d===void 0?null:d,{t:y}=Ee(),b=_e(fd),x=jt(),S=jt(dd),C=jt(ud),w=jt(ld),T=jt(cd),E=jt(sd),D=jt(od),O=jt(ad),k=jt(id),A=jt(rd),j=jt(nd),M=jt(td),N=jt(ed),P;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(P=[],t[0]=P):P=t[0],Z.useEffect($u,P);let F=x.secondary?.kind===`chat`?x.secondary.btw??null:null,I=Z.useRef(null),L,R;t[1]===F?(L=t[2],R=t[3]):(L=()=>{let e=I.current;I.current=F,e&&e!==F&&Hn.getState().clear({sessionId:e.sessionId,directory:e.directory}),F?gn(fn):hn(fn)},R=[F],t[1]=F,t[2]=L,t[3]=R),Z.useEffect(L,R);let ee;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(ee=[],t[4]=ee):ee=t[4],Z.useEffect(Zu,ee);let z;t[5]===S?z=t[6]:(z=e=>{e===`settings`&&_e.getState().setSettingsPage(`home`),S(e)},t[5]=S,t[6]=z);let B=K(z),V;t[7]===C?V=t[8]:(V=e=>{C(e)},t[7]=C,t[8]=V);let te=K(V),ne;t[9]===O?ne=t[10]:(ne=()=>{O()},t[9]=O,t[10]=ne);let re=K(ne),H;t[11]===w?H=t[12]:(H=()=>{w()},t[11]=w,t[12]=H);let ie=K(H),U;t[13]===T?U=t[14]:(U=e=>{T(e)},t[13]=T,t[14]=U);let ae=K(U),oe=Z.useRef(null),[se,ce]=Z.useState(!1),le;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(le=e=>{oe.current=e},t[15]=le):le=t[15];let ue=K(le),de;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>{ce(e)},t[16]=de):de=t[16];let W=K(de),fe;t[17]!==re||t[18]!==v||t[19]!==D||t[20]!==N||t[21]!==k?(fe=()=>{if(oe.current?.())return!0;let e=jt.getState().secondary;return e?.kind===`chat`&&e.btw?(N(),!0):e?.kind===`assistant`&&e.settingsAssistantID?(D(),!0):(e?.kind===`draft`||e?.kind===`chat`)&&v?.onSelect?(v.onSelect(),!0):e?.kind===`chat`&&e.routes.length>1?(k(),!0):e?(re(),!0):!1},t[17]=re,t[18]=v,t[19]=D,t[20]=N,t[21]=k,t[22]=fe):fe=t[22];let G=K(fe),pe=x.secondary!==null,me;t[23]!==G||t[24]!==f?(me=()=>{if(f)return f(()=>G()),()=>f(null)},t[23]=G,t[24]=f,t[25]=me):me=t[25];let he;t[26]!==G||t[27]!==f||t[28]!==pe?(he=[f,pe,G],t[26]=G,t[27]=f,t[28]=pe,t[29]=he):he=t[29],Z.useEffect(me,he);let q=Ot(Xu),ge=ct(Yu),ve;t[30]===q?ve=t[31]:(ve=e=>q?e.getDirectoryForSession(q):null,t[30]=q,t[31]=ve);let ye=Ot(ve),be,xe;t[32]!==ye||t[33]!==q||t[34]!==j||t[35]!==ge||t[36]!==M?(be=()=>{let e=jt.getState().secondary;if(ge)return;if(e?.kind===`draft`&&q){j({sessionId:q,directory:ye});return}if(e?.kind!==`chat`||!q||Nt({sessionId:q,directory:ye})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==q||h(t.directory)!==h(ye))&&M({sessionId:q,directory:ye})},xe=[ye,q,j,M,ge],t[32]=ye,t[33]=q,t[34]=j,t[35]=ge,t[36]=M,t[37]=be,t[38]=xe):(be=t[37],xe=t[38]),Z.useEffect(be,xe);let Se,Ce;t[39]!==q||t[40]!==v||t[41]!==A||t[42]!==ge?(Se=()=>{let e=jt.getState().secondary;if(e?.kind!==`chat`||!v||v.onSelect||ge)return;let t=e.routes.at(-1);!t||t.sessionId!==q||A({sessionId:v.id,directory:v.directory})},Ce=[q,v,A,ge],t[39]=q,t[40]=v,t[41]=A,t[42]=ge,t[43]=Se,t[44]=Ce):(Se=t[43],Ce=t[44]),Z.useEffect(Se,Ce);let we;t[45]!==W||t[46]!==ue||t[47]!==p?(we=typeof p==`function`?p(ue,W):p,t[45]=W,t[46]=ue,t[47]=p,t[48]=we):we=t[48];let Te=we,De;t[49]!==ie||t[50]!==s||t[51]!==n||t[52]!==a||t[53]!==r||t[54]!==i||t[55]!==te?(De=(0,$.jsx)(Uu,{onOpenChat:te,onAddProject:n,onNewSession:ie,onScanQr:r,onSwitchInstance:i,onRemoteDesktop:a,instanceOptions:s}),t[49]=ie,t[50]=s,t[51]=n,t[52]=a,t[53]=r,t[54]=i,t[55]=te,t[56]=De):De=t[56];let Oe;t[57]!==c||t[58]!==ae?(Oe=(0,$.jsx)(pu,{onEnable:c,onOpenAssistant:ae}),t[57]=c,t[58]=ae,t[59]=Oe):Oe=t[59];let ke;t[60]===Te?ke=t[61]:(ke=(0,$.jsx)(Wu,{showHeader:!1,children:Te}),t[60]=Te,t[61]=ke);let Ae;t[62]===l?Ae=t[63]:(Ae=(0,$.jsx)(Gu,{instancesPage:l}),t[62]=l,t[63]=Ae);let je;t[64]!==De||t[65]!==Oe||t[66]!==ke||t[67]!==Ae?(je={projects:De,assistant:Oe,scheduled:ke,settings:Ae},t[64]=De,t[65]=Oe,t[66]=ke,t[67]=Ae,t[68]=je):je=t[68];let Me=je,Ne=x.secondary?.kind??null,Pe;bb0:{if(!Ne){Pe=null;break bb0}let e;t[69]!==G||t[70]!==E||t[71]!==y?(e=e=>({key:`assistant-secondary`,depth:1,ariaLabel:y(`assistants.title`),onBack:G,content:(0,$.jsx)(ao,{activeOverride:e,onMobileBack:Ju,onMobileOpenSettings:E})}),t[69]=G,t[70]=E,t[71]=y,t[72]=e):e=t[72];let n=e;if(Ne===`assistant`){let e=x.secondary?.kind===`assistant`?x.secondary.settingsAssistantID:void 0,r=!e,i;t[73]!==n||t[74]!==r?(i=n(r),t[73]=n,t[74]=r,t[75]=i):i=t[75];let a;t[76]!==G||t[77]!==e||t[78]!==y?(a=e?[{key:`assistant-settings:${e}`,depth:2,ariaLabel:y(`assistants.conversation.openSettings`),onBack:G,content:(0,$.jsx)(hu,{assistantID:e,onBack:qu})}]:[],t[76]=G,t[77]=e,t[78]=y,t[79]=a):a=t[79];let o;t[80]!==i||t[81]!==a?(o=[i,...a],t[80]=i,t[81]=a,t[82]=o):o=t[82],Pe=o;break bb0}if(Ne===`instances`){let e;t[83]===y?e=t[84]:(e=y(`mobile.settings.switchInstance`),t[83]=y,t[84]=e);let n;t[85]!==G||t[86]!==u||t[87]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:G,content:u}],t[85]=G,t[86]=u,t[87]=e,t[88]=n):n=t[88],Pe=n;break bb0}if(x.secondary?.kind===`draft`){let e;t[89]===y?e=t[90]:(e=y(`mobile.nav.secondaryPageAria`),t[89]=y,t[90]=e);let n;t[91]===m?n=t[92]:(n=m({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[91]=m,t[92]=n);let r;t[93]!==G||t[94]!==e||t[95]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:G,content:n}],t[93]=G,t[94]=e,t[95]=n,t[96]=r):r=t[96],Pe=r;break bb0}if(x.secondary?.kind!==`chat`){let e;t[97]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[97]=e):e=t[97],Pe=e;break bb0}let r=x.secondary.routes,i;if(t[98]!==n||t[99]!==G||t[100]!==x.secondary.btw||t[101]!==x.secondary.returnTo||t[102]!==m||t[103]!==r||t[104]!==y){let e=x.secondary.returnTo?[n(!1)]:[],a=x.secondary.btw,o=r.slice(a?-1:-2),s=r.length-o.length+1+e.length,c=o.map((e,t)=>{let n=!a&&t===o.length-1;return{key:e.key,depth:s+t,ariaLabel:y(`mobile.nav.secondaryPageAria`),onBack:G,content:m({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:n})}});i=a?[...e,...c,{key:`chat-btw`,depth:r.length+1+e.length,ariaLabel:y(`chat.btw.title`),onBack:G,content:(0,$.jsx)(gu,{route:a})}]:[...e,...c],t[98]=n,t[99]=G,t[100]=x.secondary.btw,t[101]=x.secondary.returnTo,t[102]=m,t[103]=r,t[104]=y,t[105]=i}else i=t[105];Pe=i}let Fe=Pe,Ie;t[106]===Fe?Ie=t[107]:(Ie=Fe??[],t[106]=Fe,t[107]=Ie);let Le=se||b||_,Re;return t[108]!==g||t[109]!==x||t[110]!==B||t[111]!==Ie||t[112]!==Le||t[113]!==Me?(Re=(0,$.jsx)(Bu,{className:g,navigation:x,onTabChange:B,tabs:Me,secondaryPages:Ie,tabBarCovered:Le}),t[108]=g,t[109]=x,t[110]=B,t[111]=Ie,t[112]=Le,t[113]=Me,t[114]=Re):Re=t[114],Re}function qu(){Ir.requestAnimatedBack(`root`)}function Ju(){return Ir.requestAnimatedBack(`root`)}function Yu(e){return e.remoteSession}function Xu(e){return e.currentSessionId}function Zu(){return Qu}function Qu(){return hn(fn)}function $u(){return Dt()}function ed(e){return e.popBtw}function td(e){return e.replaceChatSession}function nd(e){return e.materializeDraftSession}function rd(e){return e.reconcileChatPredecessor}function id(e){return e.popChatSession}function ad(e){return e.closeSecondary}function od(e){return e.popAssistantSettings}function sd(e){return e.pushAssistantSettings}function cd(e){return e.openAssistant}function ld(e){return e.openDraft}function ud(e){return e.openSession}function dd(e){return e.setActiveTab}function fd(e){return e.isCommandPaletteOpen}function pd(e){let t=!1,n=0,r=0,i=!1,a,o,c,u=()=>e.transport===l()&&e.generation===d(),f=()=>document.visibilityState===`hidden`,p=()=>{r++;let e=a;a=void 0,clearTimeout(o),o=void 0,e?.close()},m=n=>{t||(t=!0,p(),x(),window.removeEventListener(`online`,_),window.removeEventListener(`pageshow`,y),window.removeEventListener(`yuri:system-resume`,v),document.removeEventListener(`visibilitychange`,b),e.onState(`closed`,n))},h=()=>{if(t||f())return;let e=navigator.onLine===!1||c===`permission_required`?6e4:Math.min(1e3*2**Math.min(n++,5),3e4);o=setTimeout(()=>{o=void 0,g()},e)},g=()=>{if(t||a||f())return;if(!u()){m(`runtime_changed`);return}if(clearTimeout(o),o=void 0,navigator.onLine===!1){h();return}let s=++r;a=md({...e,onState:(i,o)=>{if(!(t||s!==r)){if(i===`closed`){if(a=void 0,c=o,!o||[`runtime_changed`,`disabled`,`unsupported`,`helper_unavailable`,`authentication_required`,`permission_denied`].includes(o)){m(o);return}e.onState(i,o),h();return}(i===`webrtc`||i===`tunnel`)&&(n=0,c=void 0),e.onState(i,o)}}}),a.setZoomed(i)},_=()=>{!t&&!f()&&!a&&g()},v=()=>{t||(p(),_())},y=e=>{e.persisted&&v()},b=()=>{f()?(p(),e.onState(`connecting`,void 0)):_()},x=s(()=>m(`runtime_changed`));return window.addEventListener(`online`,_),window.addEventListener(`pageshow`,y),window.addEventListener(`yuri:system-resume`,v),document.addEventListener(`visibilitychange`,b),g(),{send:e=>{!t&&u()&&a?.send(e)},close:()=>m(),setZoomed:e=>{i=e,a?.setZoomed(e)}}}function md(e){let t=!1,n,i,a=!1,o,s,u=setTimeout(()=>E(`connection_failed`),6e4),f,p=Date.now(),m,h,g=!1,_=!1,v=!1,y=(t,n)=>{(m!==t||h!==n)&&(m=t,h=n,e.onState(t,n))},b=Promise.resolve(),x=0,S=[],C=()=>!t&&e.transport===l()&&e.generation===d(),w=e=>{if(!(!C()||n?.readyState!==1))try{n.send(JSON.stringify(e))}catch{E(`connection_failed`)}},T=()=>{!g||_===v||!C()||n?.readyState!==1||(w({type:`view`,zoomed:_}),v=_)},E=r=>{if(t)return;let a=C()&&n?.readyState===1;if(t=!0,a)try{n.send(JSON.stringify({type:`release`}))}catch{}clearInterval(s),clearTimeout(u),clearTimeout(f),n&&(n.onopen=null,n.onmessage=null,n.onerror=null,n.onclose=null,n.close()),i?.close();let c=e.video.srcObject;c instanceof MediaStream&&c.getTracks().forEach(e=>e.stop()),e.video.srcObject=null,e.video.onloadeddata=null,e.image.onload=null,e.image.onerror=null,e.image.removeAttribute(`src`),o&&URL.revokeObjectURL(o),y(`closed`,r)},D=()=>{!C()||a||(a=!0,i?.close(),clearTimeout(f),f=setTimeout(()=>E(`connection_failed`),15e3),w({type:`fallback`}))},O=async t=>{if(!C())return;if(p=Date.now(),t instanceof ArrayBuffer){if(t.byteLength>524288){E(`connection_failed`);return}o&&URL.revokeObjectURL(o),o=URL.createObjectURL(new Blob([t],{type:`image/jpeg`})),e.image.onload=()=>{C()&&(clearTimeout(u),clearTimeout(f),e.onSize(e.image.naturalWidth,e.image.naturalHeight),y(`tunnel`),w({type:`ack`}))},e.image.onerror=()=>E(`connection_failed`),e.image.src=o;return}let n=JSON.parse(t);if(n.type===`error`){E(typeof n.code==`string`?n.code:`connection_failed`);return}if(n.type===`ready`)g=n.zoomQuality===!0,T(),Number.isFinite(n.width)&&Number.isFinite(n.height)&&e.onSize(n.width,n.height);else if(n.type===`offer`&&!a){if(i||typeof n.sdp!=`string`||n.sdp.length>65536)throw Error(`invalid_offer`);if(typeof RTCPeerConnection>`u`){D();return}i=new RTCPeerConnection({iceServers:Array.isArray(n.iceServers)?n.iceServers:[]}),i.onicecandidate=e=>{e.candidate&&w({type:`ice`,candidate:e.candidate.toJSON()})},i.onconnectionstatechange=()=>{(i?.connectionState===`failed`||i?.connectionState===`disconnected`)&&D()},i.ontrack=t=>{C()&&(e.video.srcObject=new MediaStream([t.track]),e.video.onloadeddata=()=>{!C()||a||(clearTimeout(u),clearTimeout(f),e.onSize(e.video.videoWidth,e.video.videoHeight),y(`webrtc`))},e.video.play().catch(D))},await i.setRemoteDescription({type:`offer`,sdp:n.sdp});for(let e of S.splice(0))await i.addIceCandidate(e);if(await i.setLocalDescription(await i.createAnswer()),!C()||a)return;f=setTimeout(D,7e3),w({type:`answer`,sdp:i.localDescription?.sdp})}else n.type===`ice`&&n.candidate&&!a?i?.remoteDescription?await i.addIceCandidate(n.candidate):S.length<128&&S.push(n.candidate):n.type===`rtc-failed`&&D()};return y(`connecting`),(async()=>{try{if(await r(),!C())return;n=k(c().websocket(`/api/remote-desktop/ws`)),n.binaryType=`arraybuffer`,n.onopen=()=>{C()&&(p=Date.now(),s=setInterval(()=>{if(!C()){E(`runtime_changed`);return}if(Date.now()-p>3e4){E(`connection_failed`);return}w({type:`ping`})},5e3))},n.onmessage=e=>{if(C()){if(++x>128){E(`connection_failed`);return}b=b.then(()=>O(e.data)).catch(D).finally(()=>{x--})}},n.onerror=()=>E(`connection_failed`),n.onclose=e=>E(e.code===4001?`authentication_required`:`connection_failed`)}catch{E(`connection_failed`)}})(),{send:e=>w(e),close:E,setZoomed:e=>{_=e,T()}}}var hd={scale:1,x:0,y:0};function gd(e){let t=Math.min(e.width/e.remoteWidth,e.height/e.remoteHeight),n=e.remoteWidth*t,r=e.remoteHeight*t;return{width:n,height:r,x:(e.width-n)/2,y:(e.height-r)/2}}function _d(e,t,n){if(t.width<=0||t.height<=0||t.remoteWidth<=0||t.remoteHeight<=0)return null;let r=gd(t),i=((e.x-n.x)/n.scale-r.x)/r.width,a=((e.y-n.y)/n.scale-r.y)/r.height;return i>=0&&i<=1&&a>=0&&a<=1?{x:i,y:a}:null}function vd(e,t,n=1){let r=Math.max(n,Math.min(5,e.scale)),i=gd(t),a=(e,t,n,i)=>n*r<=i?(i-n*r)/2-t*r:Math.max(i-(t+n)*r,Math.min(-t*r,e));return{scale:r,x:a(e.x,i.x,i.width,t.width),y:a(e.y,i.y,i.height,t.height)}}function yd(e){let t=new Map,n={...hd},r=null,i=null,a=!1,o=!1,s=!1,c=!1,l,u=null,d=0,f=null,p=()=>{a&&e.send({type:`release`}),a=!1},m=()=>{(n.scale!==1||n.x!==0||n.y!==0)&&(n={...hd},e.apply(n,!0))},h=()=>{clearTimeout(l),p(),t.clear(),f=null,r=i=null,s=!1,u=null,n.scale<=1&&m()},g=()=>{let[e,n]=[...t.values()];return{midpoint:{x:(e.x+n.x)/2,y:(e.y+n.y)/2},distance:Math.max(1,Math.hypot(e.x-n.x,e.y-n.y))}},_={down(a,m){t.size>=2||(t.set(a,m),t.size===1&&(r=i=m,o=!1,s=!1,c=!1,d=Date.now(),e.mode()===`cursor`&&(l=setTimeout(()=>{let t=_d(m,e.viewport(),n);t&&!o&&!s&&(e.send({type:`pointer`,action:`right`,...t}),c=!0)},550))),t.size===2&&(clearTimeout(l),s=!0,u=null,p(),f={...g(),transform:{...n}}))},move(d,p){if(t.has(d)){if(t.set(d,p),t.size===2&&f){let{midpoint:t,distance:r}=g(),i=Math.max(.5,Math.min(5,f.transform.scale*r/f.distance)),a=i/f.transform.scale;n=vd({scale:i,x:t.x-(f.midpoint.x-f.transform.x)*a,y:t.y-(f.midpoint.y-f.transform.y)*a},e.viewport(),.5),e.apply(n);return}if(!(s||c||!r||!i)&&(Math.hypot(p.x-r.x,p.y-r.y)>6&&(o=!0,u=null,clearTimeout(l)),o)){if(e.mode()===`drag`)n={...n,x:n.x+p.x-i.x,y:n.y+p.y-i.y},e.apply(n);else{let t=_d(p,e.viewport(),n);if(t){let i=_d(r,e.viewport(),n);!a&&i&&(e.send({type:`pointer`,action:`down`,...i}),a=!0),a&&e.send({type:`pointer`,action:`move`,...t})}}i=p}}},moveMany(e){let n;for(let[r,i]of e)t.has(r)&&(t.set(r,i),n=[r,i]);n&&_.move(...n)},up(a,h,g=!1){if(t.has(a)){if(clearTimeout(l),t.delete(a),e.mode()===`cursor`&&!g&&!s&&!o&&!c){let t=_d(h,e.viewport(),n);t&&e.send({type:`pointer`,action:`click`,...t})}if(e.mode()===`drag`&&!g&&!s&&!o&&Date.now()-d<450){let t=Date.now(),r={x:h.x,y:h.y,time:t};if(qn(u,r)){if(n.scale>1)n={...hd};else{let t=2.5,r=t/n.scale;n=vd({scale:t,x:h.x-(h.x-n.x)*r,y:h.y-(h.y-n.y)*r},e.viewport())}e.apply(n,!0),u=null}else u=r}else u=null;p(),t.size||(f=null,r=i=null,s=!1,n.scale<=1&&m())}},cancel:h,refit(){if(n.scale<=1){m();return}n=vd(n,e.viewport()),e.apply(n)},reset(){h(),n={...hd},e.apply(n)}};return _}function bd(e,t,n){return n===90?{x:e.y-t.top,y:t.right-e.x}:n===-90?{x:t.bottom-e.y,y:e.x-t.left}:{x:e.x-t.left,y:e.y-t.top}}var xd=he(`YuriOrientation`);function Sd(){return q.isNativePlatform()&&q.isPluginAvailable(`YuriOrientation`)}function Cd(e){return xd.lock({orientation:e})}function wd(e){let t=(0,Q.c)(14),[n,r]=(0,Z.useState)(Ad),[i]=(0,Z.useState)(kd),[a,o]=(0,Z.useState)(i),[s]=(0,Z.useState)(Sd),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{let[t]=e;if(!t)return;let{width:n,height:i}=t.contentRect;n>0&&i>0&&r(e=>e.width===n&&e.height===i?e:{width:n,height:i})},t[0]=c):c=t[0],me(e,c);let l,u;t[1]!==s||t[2]!==a?(l=()=>{s&&Cd(a).catch(Od)},u=[s,a],t[1]=s,t[2]=a,t[3]=l,t[4]=u):(l=t[3],u=t[4]),(0,Z.useEffect)(l,u);let d,f;t[5]===s?(d=t[6],f=t[7]):(d=()=>{if(s)return Ed},f=[s],t[5]=s,t[6]=d,t[7]=f),(0,Z.useEffect)(d,f);let p=!s&&a!==i,m=p?90:0,h=p?n.height:n.width,g=p?n.width:n.height,_;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>o(Td),t[8]=_):_=t[8];let v;return t[9]!==a||t[10]!==m||t[11]!==h||t[12]!==g?(v={orientation:a,rotation:m,width:h,height:g,toggle:_},t[9]=a,t[10]=m,t[11]=h,t[12]=g,t[13]=v):v=t[13],v}function Td(e){return e===`portrait`?`landscape`:`portrait`}function Ed(){Cd(`portrait`).catch(Dd)}function Dd(){}function Od(){}function kd(){return window.innerWidth>window.innerHeight?`landscape`:`portrait`}function Ad(){return{width:window.innerWidth,height:window.innerHeight}}var jd=(e,t)=>({queryKey:[e,`remote-desktop`,t],queryFn:async({signal:n})=>{let r=()=>{if(e!==l()||t!==d())throw Error(`runtime_changed`)};r();let i=new AbortController,a=()=>i.abort();n.addEventListener(`abort`,a,{once:!0}),n.aborted&&a();let o;try{return await Promise.race([(async()=>{let e=await m(`/api/remote-desktop`,{signal:i.signal,headers:{Accept:`application/json`}});if(r(),[401,403].includes(e.status))throw Error(`authentication_required`);if([404,501].includes(e.status))throw Error(`unsupported`);if(!e.ok)throw Error(`connection_failed`);if(!e.headers.get(`content-type`)?.includes(`application/json`))throw Error(`unsupported`);let t=await e.json();if(r(),!t||typeof t!=`object`||!(`supported`in t)||typeof t.supported!=`boolean`)throw Error(`unsupported`);return{supported:t.supported,enabled:`enabled`in t&&t.enabled===!0}})(),new Promise((e,t)=>{o=setTimeout(()=>{a(),t(Error(`connection_failed`))},1e4)})])}finally{clearTimeout(o),n.removeEventListener(`abort`,a)}},staleTime:3e4,retry:!1,refetchInterval:e=>{let t=e.state.error;return!t||[`unsupported`,`runtime_changed`,`authentication_required`].includes(t.message)?!1:Math.min(1e3*2**Math.min(Math.max(0,e.state.errorUpdateCount-1),5),3e4)},refetchIntervalInBackground:!1}),Md=(e,t)=>{let n=(0,Q.c)(3),r;return n[0]!==t||n[1]!==e?(r=jd(e,t),n[0]=t,n[1]=e,n[2]=r):r=n[2],re(r)},Nd=[{key:`Escape`,icon:`corner-up-left`},{key:`Tab`,icon:`arrow-right-to-line`},{key:`Backspace`,icon:`delete-back`},{key:`Enter`,icon:`corner-down-left`},{key:`ArrowLeft`,icon:`arrow-left`},{key:`ArrowUp`,icon:`arrow-up`},{key:`ArrowDown`,icon:`arrow-down`},{key:`ArrowRight`,icon:`arrow-right`}];function Pd({onClose:e,instanceName:t}){let{t:n}=Ee(),[r]=Z.useState(()=>({transport:l(),generation:d()})),i=Md(r.transport,r.generation),[a,o]=Z.useState(0),[s,c]=Z.useState(`connecting`),[u,f]=Z.useState(),[p,m]=Z.useState(`drag`),[h,g]=Z.useState(!1),[_,v]=Z.useState(``),y=Z.useRef(null),b=Z.useRef(null),x=wd(b),S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(null),T=Z.useRef({width:1,height:1,remoteWidth:1920,remoteHeight:1080}),E=Z.useRef(null),D=Z.useRef(null),O=Z.useRef(new Map),k=Z.useRef(new Set),A=Z.useRef(!1),j=K(e=>{E.current?.send(e)}),M=K(()=>p),[N]=Z.useState(()=>yd({viewport:()=>T.current,send:j,mode:M,apply:(e,t)=>{let n=e.scale>(A.current?1.01:1.05);n!==A.current&&(A.current=n,E.current?.setZoomed(n)),S.current&&(S.current.style.transition=t&&!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`transform 180ms ease-out`:`none`,S.current.style.transform=`translate(${e.x}px, ${e.y}px) scale(${e.scale})`)}})),P=K(()=>{if(D.current!==null&&cancelAnimationFrame(D.current),D.current=null,O.current.size&&y.current){let e=y.current.getBoundingClientRect(),t=new Map([...O.current].map(([t,n])=>[t,bd(n,e,x.rotation)]));N.moveMany(t)}O.current.clear()}),F=K(()=>{P(),N.reset(),E.current?.close(),E.current=null}),I=K(()=>{F(),e()});Nr({id:`remote-desktop-page`,active:!0,layer:`root`,onBack:I,surfaceRef:b}),Z.useEffect(()=>zn(`remote-desktop-page`),[]),Z.useLayoutEffect(()=>{let e=document.activeElement;return b.current?.focus({preventScroll:!0}),()=>{e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),G(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),Ir.requestBrowserBack())},()=>document);let L=K((e,t)=>{(e===`closed`||e===`connecting`)&&(O.current.clear(),k.current.clear(),N.cancel()),c(e),f(t)}),R=K((e,t)=>{if(e<=0||t<=0||T.current.remoteWidth===e&&T.current.remoteHeight===t)return;let n=T.current;T.current={...n,remoteWidth:e,remoteHeight:t},!(Math.abs(n.remoteWidth/n.remoteHeight-e/t)<.01)&&!k.current.size&&N.reset()});me(y,([e])=>{if(!e)return;let{width:t,height:n}=e.contentRect,r=Math.abs(T.current.width-t)>=1||Math.abs(T.current.height-n)>=1;T.current={...T.current,width:t,height:n},r&&!k.current.size&&N.refit()}),Qr(y),Z.useEffect(()=>{if(!i.data?.supported||!i.data.enabled||!C.current||!w.current)return;let e=pd({...r,video:C.current,image:w.current,onSize:R,onState:L});return E.current=e,e.setZoomed(A.current),()=>{e.close(),E.current=null}},[i.data?.supported,i.data?.enabled,r,a,R,L]),Z.useEffect(()=>()=>{P(),N.reset()},[P,N]);let ee=e=>{let t=y.current.getBoundingClientRect();return bd({x:e.clientX,y:e.clientY},t,x.rotation)},z=s===`webrtc`||s===`tunnel`,B=i.data?.supported===!1||i.error?.message===`unsupported`,V=i.data?.supported===!0&&i.data.enabled!==!0,te=B||u===`helper_unavailable`?n(`remoteDesktop.unsupported`):V||u===`disabled`?n(`settings.remoteDesktop.disabled`):u===`permission_required`?n(`remoteDesktop.permissions`):u===`permission_denied`?n(`remoteDesktop.denied`):u===`runtime_changed`||i.error?.message===`runtime_changed`?n(`remoteDesktop.runtimeChanged`):u||i.error||s===`closed`?n(`remoteDesktop.failed`):n(`remoteDesktop.connecting`);return(0,vl.createPortal)((0,$.jsx)(`div`,{ref:b,tabIndex:-1,"data-remote-desktop-page":!0,className:`yuri-keyboard-inset-surface yuri-keyboard-inset-snap fixed inset-0 z-[150] overflow-clip bg-background text-foreground outline-none`,children:(0,$.jsxs)(`main`,{"aria-label":t?`${n(`remoteDesktop.title`)} · ${t}`:n(`remoteDesktop.title`),className:`absolute left-0 top-0 flex flex-col overflow-clip bg-background`,style:{width:x.width,height:x.height,transformOrigin:`top left`,"--desktop-safe-top":`env(safe-area-inset-${x.rotation===90?`right`:x.rotation===-90?`left`:`top`}, 0px)`,"--desktop-safe-right":`env(safe-area-inset-${x.rotation===90?`bottom`:x.rotation===-90?`top`:`right`}, 0px)`,"--desktop-safe-bottom":`env(safe-area-inset-${x.rotation===90?`left`:x.rotation===-90?`right`:`bottom`}, 0px)`,"--desktop-safe-left":`env(safe-area-inset-${x.rotation===90?`top`:x.rotation===-90?`bottom`:`left`}, 0px)`,transform:x.rotation===90?`translateX(${x.height}px) rotate(90deg)`:x.rotation===-90?`translateY(${x.width}px) rotate(-90deg)`:void 0},children:[(0,$.jsxs)(`div`,{"data-remote-desktop-stage-region":!0,className:`relative min-h-0 flex-1 overflow-clip`,children:[(0,$.jsxs)(`div`,{ref:y,className:`absolute inset-0 touch-none overflow-clip bg-background`,"aria-label":n(`remoteDesktop.screen`),onPointerDown:e=>{z&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),k.current.add(e.pointerId),P(),N.down(e.pointerId,ee(e)))},onPointerMove:e=>{!z||!k.current.has(e.pointerId)||(e.preventDefault(),O.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),D.current===null&&(D.current=requestAnimationFrame(P)))},onPointerUp:e=>{P(),N.up(e.pointerId,ee(e)),k.current.delete(e.pointerId),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:e=>{P(),N.up(e.pointerId,ee(e),!0),k.current.delete(e.pointerId)},onContextMenu:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{ref:S,className:`absolute inset-0 origin-top-left will-change-transform`,children:[(0,$.jsx)(`video`,{ref:C,autoPlay:!0,muted:!0,playsInline:!0,className:`pointer-events-none absolute inset-0 size-full object-contain`,style:{visibility:s===`webrtc`?`visible`:`hidden`}}),(0,$.jsx)(`img`,{ref:w,alt:n(`remoteDesktop.screen`),draggable:!1,className:`pointer-events-none absolute inset-0 size-full object-contain`,style:{visibility:s===`tunnel`?`visible`:`hidden`}})]}),!z&&(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-4 p-6 text-center text-sm text-muted-foreground`,role:`status`,children:[s===`connecting`&&!u&&!i.error&&!B&&!V&&(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin`}),(0,$.jsx)(`p`,{children:te}),(s===`closed`||i.error||V)&&!B&&u!==`runtime_changed`&&i.error?.message!==`runtime_changed`&&(0,$.jsx)(J,{onClick:()=>{F(),f(void 0),c(`connecting`),i.error||V?i.refetch():o(e=>e+1)},children:n(`remoteDesktop.retry`)})]})]}),(0,$.jsxs)(`div`,{className:`pointer-events-none absolute left-[max(0.75rem,var(--desktop-safe-left))] right-[max(0.75rem,var(--desktop-safe-right))] top-[max(0.75rem,var(--desktop-safe-top))] flex items-start justify-between gap-3`,children:[(0,$.jsx)(J,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto`,"aria-label":n(`header.actions.backAria`),onClick:()=>Ir.requestBrowserBack(),children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(J,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto`,"aria-label":n(`remoteDesktop.rotate`),title:n(`remoteDesktop.rotate`),onClick:()=>{P(),N.reset(),g(!1),x.toggle()},children:(0,$.jsx)(X,{name:`smartphone`,className:`size-5 rotate-45`})})]}),(0,$.jsx)(`p`,{className:`sr-only`,children:n(`remoteDesktop.hint`)}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute left-[max(0.75rem,var(--desktop-safe-left))] right-[max(0.75rem,var(--desktop-safe-right))] bottom-[max(0.75rem,var(--desktop-safe-bottom))] top-[calc(4rem+var(--desktop-safe-top))] flex flex-col items-end justify-end gap-3`,children:(0,$.jsxs)(`div`,{className:`flex w-full shrink-0 items-end justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`pointer-events-auto flex gap-3`,children:[(0,$.jsx)(J,{size:`mobileIcon`,variant:`mobileGlass`,className:p===`drag`?`yuri-mobile-inverse-action`:void 0,"aria-label":n(`remoteDesktop.drag`),title:n(`remoteDesktop.drag`),"aria-pressed":p===`drag`,disabled:!z,onClick:()=>{P(),N.cancel(),m(`drag`)},children:(0,$.jsx)(X,{name:`hand`,className:`size-5`})}),(0,$.jsx)(J,{size:`mobileIcon`,variant:`mobileGlass`,className:p===`cursor`?`yuri-mobile-inverse-action`:void 0,"aria-label":n(`remoteDesktop.cursor`),title:n(`remoteDesktop.cursor`),"aria-pressed":p===`cursor`,disabled:!z,onClick:()=>{P(),N.cancel(),m(`cursor`)},children:(0,$.jsx)(X,{name:`cursor`,className:`size-5`})})]}),(0,$.jsx)(J,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto${h?` yuri-mobile-inverse-action`:``}`,disabled:!z,"aria-label":n(`remoteDesktop.text`),title:n(`remoteDesktop.text`),"aria-pressed":h,"aria-expanded":h,onClick:()=>g(e=>!e),children:(0,$.jsx)(X,{name:`keyboard`,className:`size-5`})})]})})]}),h&&(0,$.jsxs)(`footer`,{"data-remote-desktop-keyboard":!0,className:`max-h-[50%] w-full shrink-0 overflow-y-auto overscroll-contain border-t border-border bg-[var(--surface-elevated)] pt-3 pl-[max(0.75rem,var(--desktop-safe-left))] pr-[max(0.75rem,var(--desktop-safe-right))] pb-[max(0.75rem,var(--desktop-safe-bottom))]`,children:[(0,$.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),_&&z&&(j({type:`text`,text:_}),v(``))},children:[(0,$.jsx)(Kn,{className:`min-w-0 flex-1`,value:_,maxLength:1024,onChange:e=>v(e.target.value),placeholder:n(`remoteDesktop.text`),"aria-label":n(`remoteDesktop.text`),disabled:!z,autoComplete:`off`}),(0,$.jsx)(J,{type:`submit`,size:`icon`,disabled:!z||!_,"aria-label":n(`remoteDesktop.send`),children:(0,$.jsx)(X,{name:`send-plane-2`,className:`size-4`})})]}),(0,$.jsx)(`div`,{className:`mt-2 grid grid-cols-4 gap-1 min-[360px]:grid-cols-8`,children:Nd.map(({key:e,icon:t})=>(0,$.jsx)(J,{size:`icon`,variant:`ghost`,className:`w-full`,disabled:!z,onClick:()=>j({type:`key`,key:e}),"aria-label":n(`remoteDesktop.pressKey`,{key:e}),title:n(`remoteDesktop.pressKey`,{key:e}),children:(0,$.jsx)(X,{name:t,className:`size-4`})},e))})]})]})}),document.body)}var Fd=Z.memo(Pd);function Id(e){let t=(0,Q.c)(25),{title:n,subtitle:r,onBack:i,onOpenMenu:a,menuOpen:o,elevated:s,trailing:c}=e,l=o!==void 0&&o,u=s!==void 0&&s,{t:d}=Ee(),f=U(),p=K(i),m=K(a),h;t[0]!==f||t[1]!==n?(h=f?.entry.location.hostId?(0,$.jsx)(Ld,{host:f}):n,t[0]=f,t[1]=n,t[2]=h):h=t[2];let g;t[3]!==f||t[4]!==r?(g=r||(f?.entry.location.hostId?(0,$.jsx)(yn,{registry:f.registry,hostId:f.entry.location.hostId,showName:!0}):null),t[3]=f,t[4]=r,t[5]=g):g=t[5];let _;t[6]===d?_=t[7]:(_=d(`header.actions.backAria`),t[6]=d,t[7]=_);let v=u||l,y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(wa,{mobile:!0}),t[8]=y):y=t[8];let b;t[9]===c?b=t[10]:(b=(0,$.jsxs)($.Fragment,{children:[y,c]}),t[9]=c,t[10]=b);let x;t[11]===d?x=t[12]:(x=d(`mobile.menu.titleAria`),t[11]=d,t[12]=x);let S;t[13]!==m||t[14]!==l||t[15]!==x?(S=[{icon:`more-2`,ariaLabel:x,onClick:m,pressed:l}],t[13]=m,t[14]=l,t[15]=x,t[16]=S):S=t[16];let C;return t[17]!==p||t[18]!==S||t[19]!==h||t[20]!==g||t[21]!==_||t[22]!==v||t[23]!==b?(C=(0,$.jsx)(Be,{title:h,subtitle:g,backAriaLabel:_,onBack:p,overlay:!0,collapsible:!0,elevated:v,trailing:b,actions:S}),t[17]=p,t[18]=S,t[19]=h,t[20]=g,t[21]=_,t[22]=v,t[23]=b,t[24]=C):C=t[24],C}function Ld(e){let t=(0,Q.c)(16),{host:n}=e,{t:r}=Ee(),{location:i}=n.entry,a;t[0]!==i.directory||t[1]!==i.hostId||t[2]!==i.hubId?(a=e=>e.remoteSession?.location.hubId===i.hubId&&e.remoteSession.location.hostId===i.hostId&&e.remoteSession.location.directory===i.directory?e.remoteSession:null,t[0]=i.directory,t[1]=i.hostId,t[2]=i.hubId,t[3]=a):a=t[3];let o=ct(a),s=o?.sessionId,c=Zt(n.registry,i.hostId),l;t[4]!==i.directory||t[5]!==s||t[6]!==c.data?.directories?(l=c.data?.directories.find(e=>e.directory===i.directory)?.sessions.find(e=>e.id===s),t[4]=i.directory,t[5]=s,t[6]=c.data?.directories,t[7]=l):l=t[7];let u=l,d;t[8]!==n.entry||t[9]!==o?.draft?.title||t[10]!==s||t[11]!==u?.title||t[12]!==r?(d=s?(0,$.jsx)(Rd,{entry:n.entry,sessionId:s,fallback:u?.title||r(`mobile.sessions.untitled`)}):o?.draft?.title||r(`mobile.menu.newSession`),t[8]=n.entry,t[9]=o?.draft?.title,t[10]=s,t[11]=u?.title,t[12]=r,t[13]=d):d=t[13];let f;return t[14]===d?f=t[15]:(f=(0,$.jsx)($.Fragment,{children:d}),t[14]=d,t[15]=f),f}var Rd=(0,Z.memo)(function(e){let t=(0,Q.c)(10),{entry:n,sessionId:r,fallback:i}=e,a;t[0]!==n.queryScope||t[1]!==r?(a=[...n.queryScope,`chat`,r,`session`],t[0]=n.queryScope,t[1]=r,t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=e=>e.id===r&&e.title?.trim()||null,t[3]=r,t[4]=o);let s;t[5]!==a||t[6]!==o?(s={queryKey:a,queryFn:V,enabled:!1,staleTime:1/0,gcTime:1/0,select:o},t[5]=a,t[6]=o,t[7]=s):s=t[7];let c=re(s,ue).data??i,l;return t[8]===c?l=t[9]:(l=(0,$.jsx)($.Fragment,{children:c}),t[8]=c,t[9]=l),l});function zd(e){return e.sessionId?e.userRefreshInFlight||e.backgroundResyncInFlight?`syncing`:e.hasRenderableTranscript?null:!e.isConnected&&e.connectionPhase===`reconnecting`||e.loadStatus!==`error`?`syncing`:null:null}function Bd(e,t){let n=t?.showDelayMs??250,r=t?.hideGraceMs??1e3,i=!1,a=!1,o=null,s=()=>{o=null,a!==i&&(a=i,e(a))};return{setRaw(e){i=e,o&&clearTimeout(o),o=setTimeout(s,i?n:r)},cancel(){i=!1,o&&=(clearTimeout(o),null)}}}function Vd(e,t){let n=(0,Q.c)(10),r;n[0]===t?r=n[1]:(r={key:t},n[0]=t,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a={scope:i,visible:!1},n[2]=i,n[3]=a);let[o,s]=(0,Z.useState)(a),c;n[4]===i?c=n[5]:(c=Bd(e=>s({scope:i,visible:e})),n[4]=i,n[5]=c);let l=c,u,d;return n[6]!==e||n[7]!==l?(u=()=>(l.setRaw(e),()=>l.cancel()),d=[e,l],n[6]=e,n[7]=l,n[8]=u,n[9]=d):(u=n[8],d=n[9]),(0,Z.useEffect)(u,d),o.scope===i&&o.visible}function Hd(e,t){let n=(0,Q.c)(20),{t:r}=Ee(),i=Mt(e,t),{renderable:a}=pt(e,t),o=lt(Kd),s=lt(Gd),c;n[0]!==t||n[1]!==e?(c=()=>R(e,t),n[0]=t,n[1]=e,n[2]=c):c=n[2];let l=(0,Z.useSyncExternalStore)(P,c,Wd),u;n[3]!==t||n[4]!==e?(u=()=>yt(e,t),n[3]=t,n[4]=e,n[5]=u):u=n[5];let d=(0,Z.useSyncExternalStore)(_t,u,Ud),f=i?.status,p;n[6]!==d||n[7]!==s||n[8]!==a||n[9]!==o||n[10]!==e||n[11]!==f||n[12]!==l?(p=zd({sessionId:e,hasRenderableTranscript:a,loadStatus:f,userRefreshInFlight:l,backgroundResyncInFlight:d,isConnected:o,connectionPhase:s}),n[6]=d,n[7]=s,n[8]=a,n[9]=o,n[10]=e,n[11]=f,n[12]=l,n[13]=p):p=n[13];let m=p,h;n[14]!==t||n[15]!==e?(h=JSON.stringify([t,e]),n[14]=t,n[15]=e,n[16]=h):h=n[16];let g=Vd(m===`syncing`,h),_;return n[17]!==r||n[18]!==g?(_=g?r(`mobile.chat.syncingMessages`):null,n[17]=r,n[18]=g,n[19]=_):_=n[19],_}function Ud(){return!1}function Wd(){return!1}function Gd(e){return e.connectionPhase}function Kd(e){return e.isConnected}function qd(e,t){let n=(0,Q.c)(41),{t:r}=Ee(),i=ie(e.registry,e.entry.location.hostId),a=(0,Z.useSyncExternalStore)(I,M,M),o;n[0]===e.entry.location?o=n[1]:(o=N(e.entry.location),n[0]=e.entry.location,n[1]=o);let s=o,c;n[2]!==e.entry.location||n[3]!==s||n[4]!==t?(c=s&&t?L(e.entry.location,t):null,n[2]=e.entry.location,n[3]=s,n[4]=t,n[5]=c):c=n[5];let l;n[6]!==a||n[7]!==c?(l={revision:a,scope:c},n[6]=a,n[7]=c,n[8]=l):l=n[8];let u=l.scope,d;n[9]!==s||n[10]!==u?(d=e=>s&&u?s.subscribe(u,e):Xd,n[9]=s,n[10]=u,n[11]=d):d=n[11];let f=d,p;n[12]!==s||n[13]!==u||n[14]!==t?(p=()=>!s||!u?t?`loading`:`idle`:s.getHydrationState?.(u).p0Satisfied?`renderable`:s.getRequestState?.(u).status??`loading`,n[12]=s,n[13]=u,n[14]=t,n[15]=p):p=n[15];let m=p,h=(0,Z.useSyncExternalStore)(f,m,m),g;n[16]===e.entry.location?g=n[17]:(g=v(e.entry.location),n[16]=e.entry.location,n[17]=g);let _=g,y;n[18]!==_||n[19]!==t?(y=()=>R(t,_),n[18]=_,n[19]=t,n[20]=y):y=n[20];let b=(0,Z.useSyncExternalStore)(P,y,Yd),x;n[21]!==_||n[22]!==t?(x=()=>yt(t,_),n[21]=_,n[22]=t,n[23]=x):x=n[23];let S=(0,Z.useSyncExternalStore)(_t,x,Jd),C=h===`renderable`,w=h===`error`?`error`:h===`ready`?`ready`:`loading`,T=i?.state===`connected`,E=i?.state===`connected`?`connected`:i?.state===`connecting`?`connecting`:`reconnecting`,D;n[24]!==S||n[25]!==t||n[26]!==T||n[27]!==E||n[28]!==C||n[29]!==w||n[30]!==b?(D=zd({sessionId:t,hasRenderableTranscript:C,loadStatus:w,userRefreshInFlight:b,backgroundResyncInFlight:S,isConnected:T,connectionPhase:E}),n[24]=S,n[25]=t,n[26]=T,n[27]=E,n[28]=C,n[29]=w,n[30]=b,n[31]=D):D=n[31];let O=D,k;n[32]!==_||n[33]!==t?(k=JSON.stringify([_,t]),n[32]=_,n[33]=t,n[34]=k):k=n[34];let A=Vd(O===`syncing`,k),j;if(n[35]!==i||n[36]!==r){j=Symbol.for(`react.early_return_sentinel`);bb0:{let e=In(i);if(e){j=r(e.key);break bb0}}n[35]=i,n[36]=r,n[37]=j}else j=n[37];if(j!==Symbol.for(`react.early_return_sentinel`))return j;let F;return n[38]!==r||n[39]!==A?(F=A?r(`mobile.chat.syncingMessages`):null,n[38]=r,n[39]=A,n[40]=F):F=n[40],F}function Jd(){return!1}function Yd(){return!1}function Xd(){}function Zd(e){let t=(0,Q.c)(3),n=U(),r;return t[0]!==n||t[1]!==e?(r=n?.entry.location.hostId?(0,$.jsx)($d,{...e,host:n}):(0,$.jsx)(Qd,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}function Qd(e){let t=(0,Q.c)(15),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({sessionId:i,directory:n,title:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{t:o}=Ee(),s=i.length===0,c=Ze(s?null:i),l;t[5]!==s||t[6]!==c?.title||t[7]!==o||t[8]!==a?(l=s?a?.trim()||o(`mobile.menu.newSession`):a?.trim()||c?.title?.trim()||o(`mobile.sessions.untitled`),t[5]=s,t[6]=c?.title,t[7]=o,t[8]=a,t[9]=l):l=t[9];let u=l,d=Hd(s?``:i,n||void 0),f;return t[10]!==r||t[11]!==u||t[12]!==i||t[13]!==d?(f=(0,$.jsx)(ef,{...r,sessionId:i,title:u,syncHint:d}),t[10]=r,t[11]=u,t[12]=i,t[13]=d,t[14]=f):f=t[14],f}function $d(e){let t=(0,Q.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({host:n,sessionId:i,title:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]!==n.entry.location.directory||t[6]!==n.entry.location.hostId||t[7]!==n.entry.location.hubId?(o=e=>{let t=e.remoteSession;return t?.location.hubId===n.entry.location.hubId&&t.location.hostId===n.entry.location.hostId&&t.location.directory===n.entry.location.directory?t.sessionId:null},t[5]=n.entry.location.directory,t[6]=n.entry.location.hostId,t[7]=n.entry.location.hubId,t[8]=o):o=t[8];let s=ct(o),c=i||s||``,l=qd(n,c),u;return t[9]!==c||t[10]!==r||t[11]!==l||t[12]!==a?(u=(0,$.jsx)(ef,{...r,sessionId:c,title:a,syncHint:l}),t[9]=c,t[10]=r,t[11]=l,t[12]=a,t[13]=u):u=t[13],u}function ef(e){let t=(0,Q.c)(31),{sessionId:n,title:r,onBack:i,onOpenMenu:a,onCloseMenu:o,menuOpen:s,children:c,className:l,syncHint:u}=e,d=s!==void 0&&s,{t:f}=Ee(),[p,m]=Z.useState(!1),h;t[0]!==d||t[1]!==o?(h=e=>{e&&d&&o?.(),m(e)},t[0]=d,t[1]=o,t[2]=h):h=t[2];let g=K(h),_;t[3]!==p||t[4]!==a?(_=()=>{p&&m(!1),a()},t[3]=p,t[4]=a,t[5]=_):_=t[5];let v=K(_),y=d||p,b;t[6]===l?b=t[7]:(b=it(`mobile-chat-screen relative isolate flex h-full min-h-0 w-full flex-col overflow-hidden bg-background text-foreground`,l),t[6]=l,t[7]=b);let x;t[8]!==n||t[9]!==f||t[10]!==r?(x=r||f(n?`mobile.sessions.untitled`:`mobile.menu.newSession`),t[8]=n,t[9]=f,t[10]=r,t[11]=x):x=t[11];let S;t[12]!==p||t[13]!==g||t[14]!==n?(S=(0,$.jsx)(ec,{sessionId:n,open:p,onOpenChange:g}),t[12]=p,t[13]=g,t[14]=n,t[15]=S):S=t[15];let C;t[16]!==v||t[17]!==y||t[18]!==d||t[19]!==i||t[20]!==u||t[21]!==x||t[22]!==S?(C=(0,$.jsx)(Id,{title:x,subtitle:u,onBack:i,onOpenMenu:v,menuOpen:d,elevated:y,trailing:S}),t[16]=v,t[17]=y,t[18]=d,t[19]=i,t[20]=u,t[21]=x,t[22]=S,t[23]=C):C=t[23];let w;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(w=it(`mobile-chat-screen__content relative h-full min-h-0 flex-1`,`[&_[data-scrollbar=chat]>.yuri-chat-scroll-content]:pt-[calc(max(0.625rem,var(--yuri-safe-area-top,0px))+var(--yuri-mobile-detail-navigation-height)+1.25rem)]`),t[24]=w):w=t[24];let T;t[25]===c?T=t[26]:(T=(0,$.jsx)(`div`,{className:w,children:c}),t[25]=c,t[26]=T);let E;return t[27]!==b||t[28]!==C||t[29]!==T?(E=(0,$.jsxs)(`main`,{className:b,children:[C,T]}),t[27]=b,t[28]=C,t[29]=T,t[30]=E):E=t[30],E}function tf(e){let t=(0,Q.c)(4),n=e===void 0?2500:e,{uiFont:r}=yi(),[i,a]=Z.useState(!1),o,s;return t[0]!==n||t[1]!==r?(o=()=>{let e=!1,t=()=>{e||a(!0)},i=()=>{requestAnimationFrame(()=>requestAnimationFrame(t))},o=Promise.all([Bn(r).catch(sf),document.fonts?.ready?.then(of).catch(af)??Promise.resolve(),lo.catch(rf)]).then(nf),s=new Promise(e=>{window.setTimeout(e,n)});return Promise.race([o,s]).then(i),()=>{e=!0}},s=[r,n],t[0]=n,t[1]=r,t[2]=o,t[3]=s):(o=t[2],s=t[3]),Z.useEffect(o,s),i}function nf(){}function rf(){}function af(){}function of(){}function sf(){}var cf=e=>e.replace(/^\/+|\/+$/g,``),lf=e=>{let t=e.get(`directory`)||e.get(`dir`)||e.get(`path`);if(typeof t!=`string`)return;let n=t.trim();return n.length>0?n:void 0},uf=e=>{let t=cf(e.pathname).split(`/`).filter(Boolean);return e.host?[e.host,...t]:t};function df(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(![`yuri:`,`openchamber:`,`openchambery:`].includes(t.protocol))return null;let n=uf(t),r=(n[0]??``).toLowerCase(),i=n.slice(1),a=t.searchParams;switch(r){case`connect`:{let t=Va(e);return t?{type:`connect`,pairing:t}:null}case`session`:{let e=i[0]||a.get(`id`)||``;return e?{type:`session`,sessionId:e,directory:lf(a)}:null}case`assistant`:{let e=i[0]||a.get(`id`)||``;return e?{type:`assistant`,assistantId:e}:null}case`new`:case`new-session`:{let e=a.get(`prompt`)?.trim();return{type:`new-session`,directory:lf(a),projectId:a.get(`project`)??void 0,agent:a.get(`agent`)??void 0,model:a.get(`model`)??void 0,prompt:e||void 0}}case`project`:case`open-project`:{let e;if(i.length>0)try{e=decodeURIComponent(i.join(`/`))}catch{e=i.join(`/`)}let t=lf(a)||e;return t?{type:`open-project`,directory:t}:null}case`sessions`:{let e=a.get(`filter`);return{type:`sessions`,filter:e===`attention`||e===`recent`||e===`all`?e:void 0}}case`status`:return{type:`status`};case`settings`:return{type:`settings`,section:i[0]||a.get(`section`)||void 0};case`changes`:return{type:`changes`,path:i.join(`/`)||a.get(`path`)||void 0,staged:a.get(`staged`)===`true`};case`view`:{let e=(i[0]||``).toLowerCase();return e===`changes`?{type:`changes`}:e===`files`||e===`mcp`||e===`instances`||e===`update`?{type:`view`,target:e}:null}default:return null}}var ff={},pf=null,mf=!1,hf=null,gf=e=>{switch(e.type){case`connect`:return pf?(pf(e.pairing),!0):!1;case`session`:return _()?(Ot.getState().setCurrentSession(e.sessionId,e.directory??null),!0):(jt.getState().openSession({sessionId:e.sessionId,directory:e.directory??null}),!0);case`assistant`:if(!_()){let t=jt.getState();return t.setActiveTab(`assistant`),t.openAssistant(e.assistantId),!0}return Ht(e.assistantId),!0;case`new-session`:return _()?(Ot.getState().openNewSessionDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0):(jt.getState().openDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0);case`open-project`:return _()?(Ot.getState().openNewSessionDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0):(jt.getState().openDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0);case`sessions`:return ff.openSessions?(ff.openSessions(e.filter),!0):!1;case`status`:return ff.openSessions?(ff.openSessions(),!0):(_e.getState().setMobileSessionPanelOpen(!0),!0);case`view`:return ff.openView?(ff.openView(e.target),!0):!1;case`changes`:return ff.openChanges?(ff.openChanges({path:e.path,staged:e.staged}),!0):!1;case`settings`:return ff.openSettings?(ff.openSettings(e.section),!0):!1}return!1},_f=()=>{if(!hf||!mf&&hf.type!==`connect`)return;let e=hf;hf=null,gf(e)||(hf=e)},vf=e=>{hf=e,_f()},yf=e=>{let t=df(e);t&&vf(t)},bf=e=>{mf=e,_f()},xf=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(ff=e,_f(),()=>{ff===e&&(ff={})}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},Sf=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(pf=e,_f(),()=>{pf===e&&(pf=null)}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},Cf=e=>{let{ready:t}=e,[n,r]=Z.useState(()=>g()?`pending`:`none`);return Z.useEffect(()=>{bf(t)},[t]),Z.useEffect(()=>{if(!g())return;let e=!1,t=[];return ge(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])).then(async({App:n})=>{if(e)return;let i=await n.addListener(`appUrlOpen`,e=>{yf(e?.url)});if(e){i.remove();return}t.push(()=>void i.remove());let a=await n.getLaunchUrl().catch(()=>void 0);if(e)return;let o=df(a?.url);r(o?.type===`connect`?`connect`:o?`other`:`none`),o&&vf(o)}).catch(()=>{e||r(`none`)}),ge(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-D5cqJIPw.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([80,1,2])).then(async({PushNotifications:n})=>{if(e)return;let r=await n.addListener(`pushNotificationActionPerformed`,e=>{let t=e?.notification?.data,n=typeof t?.url==`string`?t.url:typeof t?.deeplink==`string`?t.deeplink:void 0;if(n){yf(n);return}let r=typeof t?.assistantID==`string`?t.assistantID.trim():``;if(r){vf({type:`assistant`,assistantId:r});return}let i=typeof t?.sessionId==`string`?t.sessionId:void 0;i&&vf({type:`session`,sessionId:i})});if(e){r.remove();return}t.push(()=>void r.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e())}},[]),n},wf=.85,Tf=8,Ef=.35,Df=.22,Of=e=>({segmentStart:e,lastTouch:e,open:!1}),kf=e=>e*Ef,Af=e=>e*Df,jf=(e,t)=>Math.max(0,e-t),Mf=(e,t)=>Math.max(0,t-e),Nf=(e,t)=>{let n=Math.abs(e);return n<Tf||Math.abs(t)<=n*wf},Pf=(e,t,n)=>{let r=t.clientX-e.segmentStart.clientX,i=t.clientY-e.segmentStart.clientY,a=jf(e.segmentStart.clientX,t.clientX),o=kf(n),s=Af(n),c=e.open;return c=a<=0?!1:e.open?a>=s:a>=o&&Nf(r,i),{segmentStart:e.segmentStart,lastTouch:t,open:c}},Ff=e=>{if(e.disabled||e.startedOnExcludedTarget)return{open:!1,back:!1};let t=e.endX-e.startX,n=e.endY-e.startY,r=jf(e.startX,e.endX),i=Mf(e.startX,e.endX),a=kf(e.viewportWidth),o=Nf(t,n);return{open:r>=a&&o,back:i>=a&&o}},If=(e,t,n)=>Math.min(jf(e,t)/Math.max(1,kf(n)),1),Lf=(e,t,n)=>Math.min(Mf(e,t)/Math.max(1,kf(n)),1),Rf=e=>{let t=e;for(;t&&t!==document.body&&t!==document.documentElement;){let e=window.getComputedStyle(t).overflowX;if((e===`auto`||e===`scroll`)&&t.scrollWidth>t.clientWidth)return!0;t=t.parentElement}return!1},zf=e=>{let t=document.elementFromPoint(e.clientX,e.clientY);return!!t?.closest(`.yuri-mobile-composer`)||Rf(t)},Bf=1,Vf=(e,t)=>{if(!e||e.rangeCount===0||e.isCollapsed)return!1;if(!t)return!0;let n=e.anchorNode;if(!n)return!1;let r=n.nodeType===Bf?n:n.parentElement;return!!(r&&t.contains(r))},Hf=e=>Vf(window.getSelection(),e),Uf=(e,t,n)=>{let r=Z.useRef(t.onOpen);r.current=t.onOpen;let i=Z.useRef(t.onPreviewStart);i.current=t.onPreviewStart;let a=Z.useRef(t.onPreviewCancel);a.current=t.onPreviewCancel;let o=Z.useRef(t.onProgress);o.current=t.onProgress;let s=Z.useRef(t.onBack);s.current=t.onBack;let c=Z.useRef(t.onBackProgress);c.current=t.onBackProgress;let l=Z.useRef(t.disabled);l.current=t.disabled,Z.useEffect(()=>{let t=e.current;if(!t)return;let n=!1,u=!1,d=null,f=!1,p=!1,m=!1,h=0,g=0,_=null,v=e=>{let t=kf(g),n=We({thresholdReached:p,distance:e,enterDistance:t,cancelDistance:Af(g),available:!0});p=n.thresholdReached,n.event===`enter`&&(m=Rt(`medium`,{bypassCadence:!0})),n.event===`cancel`&&(Rt(`light`,{bypassCadence:!0}),m=!1)},y=e=>{o.current?.(null),p&&!e&&Rt(`light`,{bypassCadence:!0}),p=!1,m=!1,e?r.current():f&&a.current?.(),f=!1},b=e=>{c.current?.(null),p&&!e&&Rt(`light`,{bypassCadence:!0}),p=!1,m=!1,e&&s.current?.()},x=e=>{if(e.touches.length!==1){n=!1,_=null;return}if(l.current){n=!1,_=null;return}let r=e.touches[0];n=!0,g=window.innerWidth,u=zf(r)||Hf(t),d=null,f=!1,p=!1,m=!1,h=0,_=Of(r)},S=e=>{if(!n||u||!_)return;if(e.touches.length!==1){d===`sessions`&&y(!1),d===`back`&&b(!1),n=!1,_=null;return}let r=e.touches[0];_=Pf(_,r,g);let a=r.clientX-_.segmentStart.clientX,l=r.clientY-_.segmentStart.clientY;if(d===null){if(Hf(t))return;let e=Math.abs(a);if(e<Tf||Math.abs(l)>e*wf)return;if(a<0)d=`sessions`,f=!0,i.current?.();else if(s.current)d=`back`;else return}e.preventDefault(),h=d===`sessions`?jf(_.segmentStart.clientX,r.clientX):Mf(_.segmentStart.clientX,r.clientX),v(h),d===`sessions`?o.current?.(If(_.segmentStart.clientX,r.clientX,g)):c.current?.(Lf(_.segmentStart.clientX,r.clientX,g))},C=e=>{if(!n||!_)return;if(n=!1,!d){_=null;return}let t=e.changedTouches[0];t&&(_=Pf(_,t,g),h=d===`sessions`?jf(_.segmentStart.clientX,t.clientX):Mf(_.segmentStart.clientX,t.clientX),v(h));let r=d===`sessions`?_.open:Ff({startX:_.segmentStart.clientX,startY:_.segmentStart.clientY,endX:_.lastTouch.clientX,endY:_.lastTouch.clientY,viewportWidth:g,disabled:!1,startedOnExcludedTarget:!1}).back;_=null,e.preventDefault(),r&&!m&&Rt(`medium`,{bypassCadence:!0}),d===`sessions`?y(r):b(r)},w=()=>{d===`sessions`&&y(!1),d===`back`&&b(!1),n=!1,_=null};return t.addEventListener(`touchstart`,x,{passive:!0,capture:!0}),t.addEventListener(`touchmove`,S,{passive:!1,capture:!0}),t.addEventListener(`touchend`,C,{passive:!1,capture:!0}),t.addEventListener(`touchcancel`,w,{passive:!0,capture:!0}),()=>{f&&y(!1),d===`back`&&b(!1),t.removeEventListener(`touchstart`,x,!0),t.removeEventListener(`touchmove`,S,!0),t.removeEventListener(`touchend`,C,!0),t.removeEventListener(`touchcancel`,w,!0)}},[e,n])},Wf=he(`YuriNotifications`),Gf=()=>q.getPlatform()===`android`&&q.isPluginAvailable(`YuriNotifications`);async function Kf(e,n){let r=f(),a=t(),o=a?``:p();if(!a&&!/^https?:\/\//.test(o))return null;let s=await i();s.set(`Accept-Language`,n);let c=(await Me()).find(e=>Pe(e)===r)?.candidates.find(e=>e.kind===`relay`);return{runtimeKey:r,baseUrl:o,relay:a??(c?.kind===`relay`?c.relay:void 0),preferRelay:!!a,headers:Object.fromEntries(s.entries()),labels:e}}function qf(e){let t=0,n=!1;return{refresh:async()=>{let r=++t;try{if(await e.plugin.stop(),n||r!==t)return;let i=await e.resolveConfig();if(n||r!==t||!i)return;let a=await e.plugin.configure({config:i});!n&&r===t&&e.onState(a.state)}catch{!n&&r===t&&e.onError()}},stop:()=>{++t,e.plugin.stop().catch(e.onError)},dispose:()=>{n=!0,++t,e.plugin.stop().catch(e.onError)}}}var Jf=()=>{if(Gf()||typeof window>`u`)return!1;let e=window.Capacitor?.getPlatform?.();return e===`ios`||e===`android`},Yf=(e,t)=>{x()?.push?.registerApnsToken?.({token:e,platform:y(),locale:t})},Xf=e=>{let{enabled:t}=e,n=_e(e=>e.nativeNotificationsEnabled),r=De(e=>e.locale),i=Z.useRef(null),a=Z.useRef(r);a.current=r,Z.useEffect(()=>{if(!t||!n||!Jf())return;let e=!1,r=[];return ge(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-D5cqJIPw.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([80,1,2])).then(async({PushNotifications:t})=>{if(e)return;let n=await t.checkPermissions().catch(()=>null);if(n?.receive!==`granted`&&(n=await t.requestPermissions().catch(()=>null)),n?.receive!==`granted`)return;let o=await t.addListener(`registration`,e=>{i.current=e.value,Yf(e.value,a.current)}),s=await t.addListener(`registrationError`,e=>{console.warn(`[Push] APNs registration error:`,e)});if(await t.register().catch(()=>void 0),e){o.remove(),s.remove();return}r.push(()=>void o.remove(),()=>void s.remove())}).catch(()=>void 0),()=>{e=!0,r.forEach(e=>e())}},[t,n]),Z.useEffect(()=>{if(!t||!n||!Jf())return;let e=i.current;e&&Yf(e,r)},[t,n,r]),Z.useEffect(()=>{if(n)return;let e=i.current;e&&(i.current=null,x()?.push?.unregisterApnsToken?.({token:e}))},[n])},Zf=`YuriLiveActivity`,Qf=5e3,$f=3600,ep=`live`,tp=he(Zf),np=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable;function rp(){return typeof window>`u`?!1:np({isCapacitor:g(),platform:y(),pluginAvailable:q.isPluginAvailable(Zf)})}var ip=()=>tp,ap=new Set([`permission`,`input`,`retry`]),op=()=>({trackedSessionId:null,started:!1,startedAt:null,busySince:null,lastStatus:null,eventVersion:0,items:[]}),sp=(e,t)=>Math.max(Math.floor(e),t+1),cp=e=>e.failedEpoch===e.currentEpoch?e.previous:e.current,lp=e=>e.failedEpoch===e.currentEpoch&&e.retryCount<1,up=e=>e.hasSessionError?`error`:e.hasPendingPermissions?`permission`:e.hasPendingQuestions?`input`:e.statusType===`retry`?`retry`:e.statusType===`busy`?`working`:e.statusType===`idle`?`complete`:null,dp=e=>{let t=e.trim();return t.length<=80?t:`${t.slice(0,79)}…`},fp=e=>typeof e.parentID==`string`&&e.parentID.length>0?e.parentID:null,pp=e=>{if(e.runningIds.size===0)return[];let t=[];for(let n of e.sessions)!e.runningIds.has(n.id)||fp(n)||t.push({sessionId:n.id,title:dp(n.title??``),statusType:e.statuses[n.id]?.type??`busy`});return t},mp=e=>e!==`complete`&&e!==`error`,hp=e=>e.some(e=>e.status===`permission`)?`permission`:e.some(e=>e.status===`input`)?`input`:e.some(e=>e.status===`retry`)?`retry`:e.some(e=>e.status===`tool`)?`tool`:e.some(e=>e.status===`stale`)?`stale`:e.some(e=>e.status===`working`)?`working`:e.some(e=>e.status===`error`)?`error`:`complete`,gp=e=>{if(e.length<=4)return e;let t=e.filter(e=>mp(e.status)),n=e.filter(e=>!mp(e.status)).sort((e,t)=>(t.endedAt??0)-(e.endedAt??0)),r=[...t];for(let e of n){if(r.length>=4)break;r.push(e)}return r.slice(0,4)},_p=(e,t,n,r)=>{if(n&&n.length>0)return n;let i=r?.[e];return i&&i.length>0?i:t},vp=(e,t,n,r,i)=>{let a=new Map;for(let e of t)a.set(e.sessionId,e);let o=[],s=new Set;for(let t of e){if(i&&!i.has(t.sessionId))continue;let e=a.get(t.sessionId);if(e){let i=up({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;o.push({sessionId:t.sessionId,title:_p(t.sessionId,t.title,e.title,r),status:i,startedAt:t.startedAt,busySince:i===`working`?t.busySince??n:null})}else if(mp(t.status))o.push({...t,title:_p(t.sessionId,t.title,void 0,r),status:`complete`,endedAt:n,busySince:null});else{let e=_p(t.sessionId,t.title,void 0,r);o.push(e===t.title?t:{...t,title:e})}s.add(t.sessionId)}for(let e of t){if(s.has(e.sessionId))continue;let t=up({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;o.push({sessionId:e.sessionId,title:e.title,status:t,startedAt:n,busySince:t===`working`?n:null})}return gp(o)},yp=e=>e.map(e=>`${e.sessionId}\0${e.title}\0${e.status}\0${e.endedAt??``}`).join(`
|
|
16
16
|
`),bp=e=>e.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:e.startedAt};return e.endedAt!==void 0&&(t.endedAt=e.endedAt),t}),xp=(e,t,n,r,i)=>{let a=e.filter(e=>mp(e.status)),o=a[0]??e[0],s={sessionId:ep,startedAt:o?.startedAt??r,status:t,eventVersion:n,updatedAt:r,title:o?.title,workingCount:a.length,items:bp(e)};return i?.endedAt!==void 0&&(s.endedAt=i.endedAt),i?.dismissalSeconds!==void 0&&(s.dismissalSeconds=i.dismissalSeconds),s},Sp=e=>{let t={sessionId:e.sessionId,startedAt:e.startedAt,status:e.status,eventVersion:e.eventVersion,updatedAt:e.updatedAt};return e.endedAt!==void 0&&(t.endedAt=e.endedAt),e.dismissalSeconds!==void 0&&(t.dismissalSeconds=e.dismissalSeconds),e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items),t},Cp=(e,t,n,r)=>{let i=e.trackedSessionId;if(!i||!e.started)return{state:op(),commands:[]};let a=sp(t,e.eventVersion);return{state:op(),commands:[{type:`end`,payload:Sp({sessionId:i,startedAt:e.startedAt??t,status:n,eventVersion:a,updatedAt:t,endedAt:t,dismissalSeconds:r})}]}},wp=(e,t,n,r,i)=>{let a=sp(r,i);return{state:{trackedSessionId:e,started:!0,startedAt:n,busySince:null,lastStatus:t,eventVersion:a,items:[]},commands:[{type:`start`,payload:Sp({sessionId:e,startedAt:n,status:t,eventVersion:a,updatedAt:r})}]}},Tp=(e,t,n)=>{let r=up(t),i=e.busySince;if(r===`working`?i??=t.now:(!e.started&&!r||!e.started&&r===`complete`||!e.started&&r===`error`)&&(i=null),!e.started){if(r===`working`){let r=Qf-(t.now-(i??t.now));if(r>0)return{state:{...e,trackedSessionId:n,busySince:i},commands:[{type:`wait`,delayMs:r}]}}else if(!r||!ap.has(r))return{state:{...op(),trackedSessionId:n},commands:[]};return wp(n,r,i??t.now,t.now,e.eventVersion)}if(r===`complete`)return Cp({...e,busySince:i},t.now,`complete`,900);if(r===`error`)return Cp({...e,busySince:i},t.now,`error`,$f);if(!r||r===e.lastStatus)return{state:{...e,trackedSessionId:n,busySince:i},commands:[]};let a=sp(t.now,e.eventVersion);return{state:{trackedSessionId:n,started:!0,startedAt:e.startedAt??t.now,busySince:r===`working`?i:null,lastStatus:r,eventVersion:a,items:e.items},commands:[{type:`update`,payload:Sp({sessionId:n,startedAt:e.startedAt??t.now,status:r,eventVersion:a,updatedAt:t.now})}]}},Ep=(e,t,n)=>{let r=e.trackedSessionId;if(!r||!e.started)return{state:e,commands:[]};let i=sp(n,e.eventVersion);return{state:{...e,busySince:null,lastStatus:t,eventVersion:i},commands:[{type:`update`,payload:Sp({sessionId:r,startedAt:e.startedAt??n,status:t,eventVersion:i,updatedAt:n})}]}},Dp=(e,t,n)=>{let r=vp(e.items,n,t.now,t.sessionTitles,t.rootSessionIds),i=r.filter(e=>mp(e.status)),a=hp(r),o=i.reduce((e,t)=>{let n=t.busySince??t.startedAt;return e===null||n<e?n:e},null);if(!t.connected){let n=e.busySince===null?e:{...e,busySince:null};if(!n.started||n.lastStatus===`stale`)return{state:{...n,items:r},commands:[]};let i=sp(t.now,n.eventVersion),a=r.map(e=>mp(e.status)?{...e,status:`stale`}:e);return{state:{...n,items:a,lastStatus:`stale`,eventVersion:i,busySince:null},commands:[{type:`update`,payload:Sp(xp(a,`stale`,i,t.now))}]}}if(!e.started){if(i.length===0)return{state:op(),commands:[]};if(!i.some(e=>ap.has(e.status))){let n=Qf-(t.now-(o??t.now));if(n>0)return{state:{...e,trackedSessionId:ep,items:r,busySince:o},commands:[{type:`wait`,delayMs:n}]}}let n=o??t.now,s=r.map(e=>mp(e.status)?{...e,startedAt:e.busySince??n}:e),c=sp(t.now,e.eventVersion);return{state:{trackedSessionId:ep,started:!0,startedAt:n,busySince:null,lastStatus:a,eventVersion:c,items:s},commands:[{type:`start`,payload:Sp(xp(s,a,c,t.now))}]}}if(i.length===0){let n=r.some(e=>e.status===`error`)?`error`:`complete`,i=sp(t.now,e.eventVersion);return{state:op(),commands:[{type:`end`,payload:Sp(xp(r,n,i,t.now,{endedAt:t.now,dismissalSeconds:n===`error`?$f:900}))}]}}if(yp(e.items)===yp(r)&&e.lastStatus===a)return{state:{...e,trackedSessionId:ep,items:r,busySince:null},commands:[]};let s=sp(t.now,e.eventVersion);return{state:{trackedSessionId:ep,started:!0,startedAt:e.startedAt??o??t.now,busySince:null,lastStatus:a,eventVersion:s,items:r},commands:[{type:`update`,payload:Sp(xp(r,a,s,t.now))}]}},Op=(e,t)=>{if(t.catalog)return Dp(e,t,t.catalog);if(!t.connected){let n=e.busySince===null?e:{...e,busySince:null};return!n.started||n.lastStatus===`stale`||!n.trackedSessionId?{state:n,commands:[]}:Ep(n,`stale`,t.now)}let n=[],r=e;if(r.trackedSessionId&&r.trackedSessionId!==t.sessionId)if(r.started){let e=Cp(r,t.now,r.lastStatus??`complete`,0);n.push(...e.commands),r=e.state}else r=op();if(!t.sessionId){if(r.started){let e=Cp(r,t.now,`complete`,900);return{state:e.state,commands:[...n,...e.commands]}}return{state:op(),commands:n}}let i=Tp(r,t,t.sessionId);return{state:i.state,commands:[...n,...i.commands]}},kp=e=>e/1e3,Ap=e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:kp(e.startedAt)};return e.endedAt!==void 0&&(t.endedAt=kp(e.endedAt)),t},jp=e=>{let t={sessionId:e.sessionId,startedAt:kp(e.startedAt),status:e.status,eventVersion:e.eventVersion,updatedAt:kp(e.updatedAt)};return e.endedAt!==void 0&&(t.endedAt=kp(e.endedAt)),e.dismissalSeconds!==void 0&&(t.dismissalSeconds=e.dismissalSeconds),e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items.map(Ap)),t},Mp=e=>{let t={};return e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items),t},Np=(e,t,n)=>{if(!e||n.type===`wait`)return Promise.resolve();let r=jp(n.payload),i=Mp(r);return n.type===`start`?t.start({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,...i}):n.type===`update`?t.update({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,...i}):t.end({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,endedAt:r.endedAt,dismissalSeconds:r.dismissalSeconds,...i})},Pp=e=>e.getCurrentEpoch()===e.epoch?!e.getCurrentSessionId||e.getCurrentSessionId()===e.observation.sessionId:!1,Fp=async e=>{let t=e.state;if(!Pp(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let n=Op(t,e.observation),r=n.commands.find(e=>e.type===`wait`),i=r?.type===`wait`?r.delayMs:null,a=n.commands.filter(e=>e.type!==`wait`);if(a.length===0)return Pp(e)?{state:n.state,delayMs:i,retry:!1,superseded:!1}:{state:t,delayMs:null,retry:!1,superseded:!0};let o=t;try{for(let[r,i]of a.entries()){if(!Pp(e)||(await Np(e.available,e.plugin,i),!Pp(e)))return{state:t,delayMs:null,retry:!1,superseded:!0};let s=r===a.length-1;o=i.type===`end`&&!s?op():n.state}return{state:n.state,delayMs:i,retry:!1,superseded:!1}}catch{if(!Pp(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let r=cp({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),previous:o,current:n.state}),i=lp({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),retryCount:e.retryCount});return{state:r,delayMs:i?250:null,retry:i,superseded:!1}}},Ip=()=>({desired:null,registered:null}),Lp=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null},Rp=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=Lp(t.activityId),r=Lp(t.sessionId),i=Lp(t.token);return!n||!r||!i?null:{activityId:n,sessionId:r,token:i}},zp=(e,t)=>e.activityId===t.activityId&&e.token===t.token,Bp=(e,t)=>{let n=e.registered?.runtimeIdentity===t?e.registered:null;return e.desired===null&&n===e.registered?e:{desired:null,registered:n}},Vp=(e,t)=>{if(!t.connected)return[];if(e.desired&&t.enabled&&t.selectedSessionId&&e.desired.sessionId===t.selectedSessionId){let n=e.registered;return n&&zp(n,e.desired)&&n.runtimeIdentity===t.runtimeIdentity?[]:[{type:`register`,payload:{activityId:e.desired.activityId,sessionId:e.desired.sessionId,token:e.desired.token},runtimeIdentity:t.runtimeIdentity}]}return e.registered&&e.registered.runtimeIdentity===t.runtimeIdentity?[{type:`unregister`,payload:{token:e.registered.token},runtimeIdentity:t.runtimeIdentity}]:[]},Hp=(e,t,n)=>{let r=e;if(n.type===`pushToken`){if(!t.enabled||n.sessionId!==t.selectedSessionId)return{state:e,commands:[]};r={...e,desired:{activityId:n.activityId,sessionId:n.sessionId,token:n.token}}}else n.type===`localEndSucceeded`||n.type===`dispose`||!t.enabled||e.desired&&e.desired.sessionId!==t.selectedSessionId?r=Bp(e,t.runtimeIdentity):e.registered&&e.registered.runtimeIdentity!==t.runtimeIdentity&&!e.desired&&(r={...e,registered:null});return{state:r,commands:Vp(r,t)}},Up=async e=>{try{return await e}catch{return null}},Wp=async e=>{let t=e.state;for(let n of e.commands){if(n.runtimeIdentity!==e.getRuntimeIdentity()){n.type===`unregister`&&t.registered?.runtimeIdentity===n.runtimeIdentity&&(t={...t,registered:null});continue}if(n.type===`register`){let r=t.registered;if(n.runtimeIdentity!==e.getRuntimeIdentity()||(await Up(e.register(n.payload)))?.ok!==!0||n.runtimeIdentity!==e.getRuntimeIdentity())continue;if(t={...t,registered:{...n.payload,runtimeIdentity:n.runtimeIdentity}},r&&r.runtimeIdentity===n.runtimeIdentity&&r.token!==n.payload.token){if(n.runtimeIdentity!==e.getRuntimeIdentity())continue;await Up(e.unregister({token:r.token}))}continue}if(n.runtimeIdentity!==e.getRuntimeIdentity()){t.registered?.runtimeIdentity===n.runtimeIdentity&&(t={...t,registered:null});continue}(await Up(e.unregister(n.payload)))?.ok===!0&&t.registered?.token===n.payload.token&&(t={...t,registered:null})}return t},Gp=new Map,Kp=[];function qp(){let e=rp(),t=lt(e=>e.isConnected),n=Bt({enabled:e}),r=Tt(t=>e?t.statusById:Gp),i=Lt(t=>e?t.activeSessions:Kp),a=(0,Z.useMemo)(()=>e?Ge(n,r):new Set,[e,r,n]),o=(0,Z.useMemo)(()=>e?pp({runningIds:a,statuses:n,sessions:i}):[],[e,n,a,i]),c=(0,Z.useMemo)(()=>{if(!e)return{};let t={};for(let e of i){let n=e.parentID;if(typeof n==`string`&&n.length>0)continue;let r=typeof e.title==`string`?e.title.trim():``;r&&(t[e.id]=r.length<=80?r:`${r.slice(0,79)}…`)}return t},[e,i]),u=(0,Z.useMemo)(()=>{if(!e)return new Set;let t=new Set;for(let e of i){let n=e.parentID;typeof n==`string`&&n.length>0||t.add(e.id)}return t},[e,i]),d=(0,Z.useMemo)(()=>[o.map(e=>`${e.sessionId}\0${e.title}\0${e.statusType??``}`).join(`
|
|
17
17
|
`),Object.entries(c).map(([e,t])=>`${e}\0${t}`).join(`
|
|
18
18
|
`)].join(`
|
|
@@ -26,4 +26,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{S as t,_ as n,p as r,r
|
|
|
26
26
|
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
27
27
|
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
28
28
|
}
|
|
29
|
-
`}),t[52]=re):re=t[52];let H;return t[53]===ne?H=t[54]:(H=(0,$.jsxs)(`div`,{ref:b,className:`fixed inset-x-0 bottom-0 top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-header-height,56px))] z-20 pointer-events-none`,children:[ne,re]}),t[53]=ne,t[54]=H),H},Pm=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=Ee(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Er,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,$.jsx)(`span`,{className:`min-w-0 max-w-[60%] truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map((t,n)=>{let i=Ei(e.rows.map(Vm),n),o=r===`remaining`?t.window.remainingPercent:t.window.usedPercent,s=tr(t.window.valueLabel,o),c=Xn(t.window.resetAt,t.window.resetAfterFormatted??t.window.resetAtFormatted,a);return(0,$.jsxs)(Z.Fragment,{children:[i?(0,$.jsx)(`div`,{className:it(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-3 border-t border-[var(--surface-subtle)] pt-2`),children:i}):null,(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:t.subtitle?`${t.subtitle} · ${t.label}`:t.label}),c?(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-micro text-muted-foreground/70`,children:c}):null]}),(0,$.jsx)(`span`,{className:it(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,jm(t.window)),children:s===`-`?``:s})]})]},t.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 truncate typography-micro text-muted-foreground`,title:e.status,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,$.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},Fm=e=>{let t=(0,Q.c)(35),{open:n,onClose:r,items:i,rightOffset:a}=e,o=a===void 0?0:a,{t:s}=Ee(),c,l;if(t[0]!==r||t[1]!==n?(c=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},l=[r,n],t[0]=r,t[1]=n,t[2]=c,t[3]=l):(c=t[2],l=t[3]),Z.useEffect(c,l),!n)return null;let u;t[4]===r?u=t[5]:(u=(e,t,n)=>(0,$.jsxs)(`button`,{type:`button`,role:n===void 0?`menuitem`:`menuitemcheckbox`,"aria-checked":n,className:it(`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,t>0&&`border-t border-border/30`,e.disabled&&`cursor-not-allowed opacity-60`),style:{touchAction:`manipulation`},disabled:e.disabled,onClick:()=>{e.onSelect(),r()},children:[e.iconNode??(e.icon?(0,$.jsx)(X,{name:e.icon,className:it(`size-5 shrink-0 text-muted-foreground`,e.spinning&&`animate-spin`,e.key===`auto-read`&&`translate-x-px`)}):null),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:e.label}),e.badge&&e.badge>0?(0,$.jsx)(`span`,{className:`inline-flex size-2 shrink-0 rounded-full bg-primary`,"aria-hidden":!0}):null,n&&(0,$.jsx)(X,{name:`check`,className:`size-4 shrink-0 text-muted-foreground`})]},e.key),t[4]=r,t[5]=u);let d=u,f;t[6]===s?f=t[7]:(f=s(`mobile.menu.titleAria`),t[6]=s,t[7]=f);let p;t[8]===s?p=t[9]:(p=s(`mobile.surface.closeAria`),t[8]=s,t[9]=p);let m;t[10]===r?m=t[11]:(m=e=>{e.preventDefault(),r()},t[10]=r,t[11]=m);let h;t[12]!==p||t[13]!==m?(h=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":p,onPointerDown:m}),t[12]=p,t[13]=m,t[14]=h):h=t[14];let g=`max(1rem, calc(8px + ${o}px + var(--yuri-safe-area-right, 0px)))`,_;t[15]===g?_=t[16]:(_={right:g,animation:`mobile-menu-in 160ms cubic-bezier(0.32, 0.72, 0, 1) forwards`},t[15]=g,t[16]=_);let v;if(t[17]!==i||t[18]!==d){let e;t[20]===d?e=t[21]:(e=(e,t)=>d(e,t),t[20]=d,t[21]=e),v=i.map(e),t[17]=i,t[18]=d,t[19]=v}else v=t[19];let y;t[22]!==i.length||t[23]!==d||t[24]!==s?(y=(0,$.jsx)(ko,{children:e=>{let{enabled:t,available:n,toggle:r}=e;return d({key:`auto-read`,icon:`volume-up`,label:s(`mobile.menu.autoRead`),disabled:!n,onSelect:r},i.length,t)}}),t[22]=i.length,t[23]=d,t[24]=s,t[25]=y):y=t[25];let b;t[26]!==_||t[27]!==v||t[28]!==y?(b=(0,$.jsxs)(`div`,{id:dm,className:`pointer-events-auto absolute top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.25rem)] w-[min(220px,calc(100vw-1rem))] origin-top-right overflow-hidden rounded-2xl yuri-mobile-overlay-surface`,role:`menu`,style:_,onAnimationEnd:Hm,children:[v,y]}),t[26]=_,t[27]=v,t[28]=y,t[29]=b):b=t[29];let x;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`style`,{children:`@keyframes mobile-menu-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }`}),t[30]=x):x=t[30];let S;return t[31]!==b||t[32]!==f||t[33]!==h?(S=(0,$.jsxs)(`div`,{className:`pointer-events-none fixed inset-0 z-50`,role:`dialog`,"aria-modal":`true`,"aria-label":f,children:[h,b,x]}),t[31]=b,t[32]=f,t[33]=h,t[34]=S):S=t[34],S},Im=Z.memo(function(e){let t=(0,Q.c)(94),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=Ee(),{git:d}=ce(),f=Hd(i??``,a||void 0),p=f??l,m=Z.useRef(null),h=wt(i??``,a||void 0),g=wr(o),_=Cr(o),v=Sr(Um),y=Sr(Wm),b=lt(Gm),x=lt(Km),S=lt(qm),C=lt(Jm),w;t[0]===i?w=t[1]:(w=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=w);let T=Et(w),E=ii(Ym),D=ii(Xm),O=ii(Zm),k=ii(Qm),A=ii($m),j=ii(eh),M=ii(th),N=_e(nh);fi();let P,F;t[2]!==v||t[3]!==d||t[4]!==o?(P=()=>{o&&v(o,d)},F=[v,d,o],t[2]=v,t[3]=d,t[4]=o,t[5]=P,t[6]=F):(P=t[5],F=t[6]),Z.useEffect(P,F);let I,L;t[7]!==y||t[8]!==d||t[9]!==o?(I=()=>{if(o)return ht.onGitRefreshHint(e=>{Tm(e.directory)===o&&y(o,d)})},L=[y,d,o],t[7]=y,t[8]=d,t[9]=o,t[10]=I,t[11]=L):(I=t[10],L=t[11]),Z.useEffect(I,L);let R,ee;t[12]===D?(R=t[13],ee=t[14]):(R=()=>{D()},ee=[D],t[12]=D,t[13]=R,t[14]=ee),Z.useEffect(R,ee);let z,B;t[15]===j?(z=t[16],B=t[17]):(z=()=>{Dr(j)},B=[j],t[15]=j,t[16]=z,t[17]=B),Z.useEffect(z,B);let V,te;t[18]!==j||t[19]!==O||t[20]!==k||t[21]!==n||t[22]!==E?(V=()=>{!n||k||j.some(e=>!E.some(t=>t?.providerId===e))&&O()},te=[j,O,k,n,E],t[18]=j,t[19]=O,t[20]=k,t[21]=n,t[22]=E,t[23]=V,t[24]=te):(V=t[23],te=t[24]),Z.useEffect(V,te);let ne;t[25]===h?ne=t[26]:(ne=Ks(h),t[25]=h,t[26]=ne);let re=ne,H;t[27]!==S||t[28]!==x||t[29]!==re||t[30]!==T?(H=re??(T?{providerID:T.providerId,modelID:T.modelId}:null)??(x&&S?{providerID:x,modelID:S}:null),t[27]=S,t[28]=x,t[29]=re,t[30]=T,t[31]=H):H=t[31];let ie=H,U;if(t[32]!==C||t[33]!==ie||t[34]!==b){let e=(ie?b.find(e=>e.id===ie.providerID):void 0)?.models.find(e=>e.id===ie?.modelID),n;t[36]!==C||t[37]!==ie?(n=ie?C(ie.providerID,ie.modelID):void 0,t[36]=C,t[37]=ie,t[38]=n):n=t[38];let r=n;U=Hs(e?.limit,`context`)??r?.limit?.context??0,t[32]=C,t[33]=ie,t[34]=b,t[35]=U}else U=t[35];let ae=U,oe=Pt(i??``,ae,0,a||void 0),se=oe?.pending?null:oe?.totalTokens??0,le;t[39]!==ae||t[40]!==s||t[41]!==se?(le=Gs({totalTokens:se,contextLimit:ae,isDraft:s}),t[39]=ae,t[40]=s,t[41]=se,t[42]=le):le=t[42];let ue=le,de;t[43]!==_?.current||t[44]!==g||t[45]!==u?(de=g===!0?_?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[43]=_?.current,t[44]=g,t[45]=u,t[46]=de):de=t[46];let W=de,fe;if(t[47]!==j||t[48]!==E||t[49]!==M||t[50]!==u){let e=new Map(E.map(rh)),n;t[52]===j?n=t[53]:(n=e=>j.includes(e.id),t[52]=j,t[53]=n),fe=ui(E).filter(n).filter(t=>e.get(t.id)?.configured===!0).map(t=>{let n=e.get(t.id),r=[];for(let[e,t]of Ai(Object.entries(n?.usage?.windows??{}),n?.usage?.accounts))r.push({key:`window-${e}`,label:Yn(t.label??e),window:t});let i=Object.entries(n?.usage?.models??{}),a=M[t.id]??[],o=a.length>0?i.filter(e=>{let[t]=e;return a.includes(t)}):i;for(let[e,t]of o){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:Yn(a.label??i),subtitle:oi(e),window:a})}let s=!n.ok&&n.error?n.error:r.length===0?u(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:s}}),t[47]=j,t[48]=E,t[49]=M,t[50]=u,t[51]=fe}else fe=t[51];let G=fe,pe,me;t[54]!==n||t[55]!==G?(pe=()=>{!n||G.length===0||Dr(G.map(ih))},me=[n,G],t[54]=n,t[55]=G,t[56]=pe,t[57]=me):(pe=t[56],me=t[57]),Z.useEffect(pe,me);let K;t[58]===c?K=t[59]:(K=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[58]=c,t[59]=K);let he;t[60]!==p||t[61]!==f?(he=p?(0,$.jsx)(`span`,{className:it(`block truncate`,f?`yuri-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:p}):null,t[60]=p,t[61]=f,t[62]=he):he=t[62];let q;t[63]!==K||t[64]!==he?(q=(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center px-2 py-1.5 text-left`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[K,he]})}),t[63]=K,t[64]=he,t[65]=q):q=t[65];let ge;t[66]===u?ge=t[67]:(ge=u(`mobile.header.openMetadataAria`),t[66]=u,t[67]=ge);let ve;t[68]===r?ve=t[69]:(ve=()=>r(ah),t[68]=r,t[69]=ve);let ye;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ye={touchAction:`manipulation`},t[70]=ye):ye=t[70];let be=ue?.percentage??0,xe=ue?.pending,Se;t[71]!==be||t[72]!==xe?(Se=(0,$.jsx)(Is,{percentage:be,pending:xe}),t[71]=be,t[72]=xe,t[73]=Se):Se=t[73];let Ce;t[74]!==n||t[75]!==ge||t[76]!==ve||t[77]!==Se?(Ce=(0,$.jsx)(`button`,{ref:m,type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":ge,"aria-expanded":n,onClick:ve,style:ye,children:Se}),t[74]=n,t[75]=ge,t[76]=ve,t[77]=Se,t[78]=Ce):Ce=t[78];let we;t[79]===r?we=t[80]:(we=()=>r(!1),t[79]=r,t[80]=we);let Te;t[81]!==W||t[82]!==ue||t[83]!==k||t[84]!==n||t[85]!==A||t[86]!==we||t[87]!==N||t[88]!==G?(Te=(0,$.jsx)(Nm,{open:n,onClose:we,anchorRef:m,contextDisplay:ue,branchLabel:W,usageGroups:G,usageDisplayMode:A,isUsageLoading:k,timeFormatPreference:N}),t[81]=W,t[82]=ue,t[83]=k,t[84]=n,t[85]=A,t[86]=we,t[87]=N,t[88]=G,t[89]=Te):Te=t[89];let De;return t[90]!==q||t[91]!==Ce||t[92]!==Te?(De=(0,$.jsxs)($.Fragment,{children:[q,Ce,Te]}),t[90]=q,t[91]=Ce,t[92]=Te,t[93]=De):De=t[93],De}),Lm=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=Ee(),[a,o]=Z.useState(!1),s=O(e=>e.currentDirectory),c=Ot(e=>e.currentSessionId),l=Z.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=Ot(l)||s,d=Tm(u)||null,f=st(e=>e.projects),p=Ot(e=>e.availableWorktreesByProject),m=Z.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=Ot(m),g=Ze(c),_=Ot(e=>!!e.newSessionDraft?.open),v=Z.useMemo(()=>{let e=Tm(u);return e&&km((h?.projectDirectory?tt(f,h.projectDirectory):null)??Xe(f,p,e),e)||i(`mobile.header.noProject`)},[p,h?.projectDirectory,u,f,i]),y=g?.title?.trim()||(c?i(`mobile.sessions.untitled`):v),b=c?v:``;Z.useEffect(()=>{o(!1)},[c,u]);let x=K(()=>{o(!1),e()}),S=K(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Fs,{children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.sessions.openSheetAria`),onClick:x,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folders`,className:`size-5`})}),(0,$.jsx)(Im,{open:a,onOpenChange:o,currentSessionId:c,effectiveDirectory:u,gitDirectory:d,isNewSessionDraftOpen:_,primaryLabel:y,secondaryLabel:b}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:it(`flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`files`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.files`),"aria-pressed":r.activePanel===`files`,onClick:r.onToggleFiles,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(`button`,{type:`button`,className:it(`relative flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`changes`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.changes`),"aria-pressed":r.activePanel===`changes`,onClick:r.onToggleChanges,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-5`}),r.changesDirty?(0,$.jsx)(`span`,{className:`absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary`,"aria-hidden":!0}):null]})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.header.openMenuAria`),"aria-controls":dm,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`more-2`,className:`size-5`})})]})})},Rm=e=>{let t=(0,Q.c)(5),n=Ps();if(!n.enabled){let n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Lm,{...e}),t[0]=e,t[1]=n),n}let r;return t[2]!==e||t[3]!==n?(r=(0,$.jsx)(Fc,{...e,scope:n}),t[2]=e,t[3]=n,t[4]=r):r=t[4],r},zm=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=Ee(),r=vn();Ye(),at();let i=_e(e=>e.mobileSessionPanelOpen),a=_e(e=>e.setMobileSessionPanelOpen),o=_e(e=>e.isScheduledTasksDialogOpen),s=_e(e=>e.activeMainTab),c=ze(),l=_e(e=>e.setActiveMainTab),[u,d]=Z.useState(!1),[f,p]=Z.useState(!1),[m,h]=Z.useState(null),[g,v]=Z.useState(!1),[y,b]=Z.useState(!1),[x,S]=Z.useState(null),[C,w]=Z.useState(null),[T,E]=Z.useState(null),[D,k]=Z.useState(0),[A,j]=Z.useState(!1),[M,N]=Z.useState(!1),[P,F]=Z.useState(!1),[I,L]=Z.useState(!1),[R,ee]=Z.useState(!1),[z,B]=Z.useState(!1),[V,te]=Z.useState(`nav`),[ne,H]=Z.useState(!1),[ie,U]=Z.useState(!1),ae=K(()=>{H(!1),U(!0)}),oe=K(()=>{if(H(!1),G.enabled){we.info(n(`remoteProjects.nativeCapabilityUnavailable`,{capability:n(`remoteDesktop.title`)}));return}ae()}),se=K(()=>U(!1)),[ce,le]=Z.useState(!1),ue=K(()=>H(e=>!e)),de=K(()=>H(!1)),[W,fe]=Z.useState(null),G=Ps(),pe=A&&!G.enabled,me=O(e=>e.currentDirectory),he=_e(e=>e.setSettingsPage),q=ci(e=>e.available),ge=ci(e=>e.runtimeType),ve=Z.useMemo(()=>xm(),[]),ye=Z.useMemo(()=>ys(),[]),be=me??null,{data:xe=[],refetch:Se}=re({...za(be),enabled:pe}),{refetch:Ce}=re({...Ra(be),enabled:pe}),Te=Ha(e=>e.setMcpDraft),De=Ha(e=>e.setSelectedMcp),Oe=Cr(G.enabled?G.entry?.key??null:Tm(me)||null)?.files?.length??0;Z.useEffect(()=>ht.onDirectoryRequest(()=>ee(!0)),[]);let Ae=Z.useMemo(()=>_(),[]),je=jt(e=>e.secondary?.kind??null),Me=Ot(e=>G.enabled?null:e.currentSessionId),Ne=G.enabled?G.sessionId:Me,Pe=Ot(e=>e.setCurrentSession),Fe=Z.useMemo(()=>e=>!G.enabled&&Ne?e.getDirectoryForSession(Ne):null,[Ne,G.enabled]),Ie=Ot(Fe),Le=G.enabled?G.entry?.location.directory:Ie,Re=cr()===`portrait`,[Ve,He]=Z.useState(Ae&&!Re),[Ue,We]=Z.useState(null),Ge=K(e=>{if(e&&he(e),Ae){te(e?`page-content`:`nav`),F(!0);return}let t=jt.getState();if(e){t.openSettingsFromCurrent();return}he(`home`),t.setActiveTab(`settings`)}),Ke=K(()=>{Ge(`instances`)}),qe=K(()=>{jt.getState().openInstances()}),Je=K(async t=>{if(!t){qe();return}let n=e.connections.find(e=>e.id===t);!n||e.isBusy||ke(n)||(await e.connect({id:n.id,candidates:n.candidates,clientToken:n.clientToken,label:n.label}),ke(n)||qe())}),Xe=K(()=>{jt.getState().closeSecondary()}),Ze=K(async()=>{if(!z){B(!0);try{let t=await bs();switch(t.status){case`ok`:await e.connect({url:t.url,clientToken:t.clientToken,label:t.label});break;case`pairing`:await e.redeemPairingConnection(t.pairing);break;case`permission-denied`:we.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:we.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:we.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:we.error(n(`mobile.connect.scan.failed`))}}finally{B(!1)}}});Pr({enabled:!Ae,rootRoutesBlocked:i||u||f||g||y||o||pe||P||I||R||ne});let $e=K(()=>{let e=!Ve;e&&Re&&We(null),He(e)}),et=K(()=>{if(b(!1),S(null),w(null),p(!1),h(null),Ae){fe(null),We(`files`),Re&&He(!1);return}d(!0)}),tt=K(()=>{p(!1),h(null)}),nt=K(e=>{let t=e.path.trim();if(t){if(b(!1),S(null),w(null),fe(null),v(!1),Ae){_e.getState().setPendingFileFocusPath(t),We(`files`),Re&&He(!1);return}d(!1),h({path:t,targetLine:typeof e.targetLine==`number`&&Number.isFinite(e.targetLine)?Math.max(1,Math.trunc(e.targetLine)):void 0}),p(!0)}}),rt=_e(e=>e.pendingFileFocusPath);Z.useEffect(()=>{if(rt){if(Ae){et();return}nt({path:rt}),_e.getState().setPendingFileFocusPath(null)}},[rt,Ae,et,nt]);let Y=K((e=null)=>{if(b(!1),S(null),w(null),E(null),p(!1),h(null),fe(e),Ae){We(`changes`),Re&&He(!1);return}v(!0)}),ot=K((e,t,n)=>{fe(null),v(!1),p(!1),h(null),S(e??null),w(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(E(r),k(e=>e+1),Ae){We(`turn-diff`),Re&&He(!1);return}b(!0)}),st=K(()=>{We(null),fe(null),E(null)}),ct=K(e=>{if(Ue===e){st();return}e===`files`?et():Y()}),lt=Z.useRef(`changes`);Ue&&(lt.current=Ue);let[ut,dt]=Z.useState(!1);Z.useEffect(()=>{if(!Ae)return;if(Ue){dt(!0);return}let e=window.setTimeout(()=>dt(!1),240);return()=>window.clearTimeout(e)},[Ue,Ae]);let ft=Ue??lt.current,pt=ym(`left`,`yuri.ipad.leftSidebarWidth`,fm),mt=ym(`right`,`yuri.ipad.rightSidebarWidth`,pm),gt=Z.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{Y(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{Y({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:ot,openFile:({path:e,targetLine:t})=>{nt({path:e,targetLine:t})},openFiles:()=>et(),openSettings:e=>{Ge(e)}}),[Y,nt,et,Ge,ot]),_t=K(()=>{v(!1),fe(null)}),vt=K(()=>{b(!1),E(null)});xf(Z.useMemo(()=>({openSessions:()=>{if(Ae){He(!0);return}jt.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?et():e===`mcp`?j(!0):e===`instances`?Ke():e===`update`&&L(!0)},openChanges:({path:e,staged:t}={})=>{Y(e?{path:e,staged:t===!0}:null)},openSettings:e=>{Ge(e)}}),[Ae,Y,et,Ke,Ge]));let yt=Z.useRef(null),bt=Z.useRef(null),xt=Qe(G.enabled?null:Ne,G.enabled?void 0:Le||me||void 0),St=G.session?.parentID,Ct=G.enabled?St?{id:St,directory:Le}:null:xt,wt=K(()=>{Ct&&(G.enabled?G.openSession(Ct.id):Pe(Ct.id,Ct.directory))});qp();let Tt=Z.useRef(0);Z.useEffect(()=>(Tt.current+=1,le(!1),()=>{Tt.current+=1}),[Ne,G.key,G.entry]);let Et=K(()=>{let e=Ne;if(!e||ce)return;let t=Le||me||void 0,i=++Tt.current;le(!0),(async()=>{try{G.enabled?await G.refresh():await r.refreshSessionTranscript(e,{directory:t}),i===Tt.current&&we.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{i===Tt.current&&we.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{i===Tt.current&&le(!1)}})()}),Dt=!Ae&&(je===`chat`||je===`draft`);Z.useEffect(()=>{!Ae&&!Dt&&H(!1)},[Ae,Dt]),Z.useEffect(()=>{H(!1)},[Ne,G.key]);let kt=Ae&&s===`assistant`||!Ae&&!Dt||i||u||f||g||y||o||pe||P||I||R||ne||ie;Uf(bt,{onOpen:K(()=>{_r(xr)?.finish(`commit`)}),onPreviewStart:K(()=>{_r(xr)?.begin(`present`)}),onPreviewCancel:K(()=>{_r(xr)?.finish(`cancel`)}),onProgress:K(e=>{e!==null&&_r(xr)?.update(e)}),disabled:kt},Ae||Dt);let At=K(e=>{yt.current=e});wm(K(()=>ie?(se(),!0):ne?(H(!1),!0):R?(ee(!1),!0):o?(window.dispatchEvent(new Event(`yuri:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):Ir.backImmediately(`overlay`)?!0:f?(tt(),!0):u?(d(!1),!0):y?(vt(),!0):g?(_t(),!0):pe?(j(!1),!0):P?(F(!1),!0):I?(L(!1),!0):Ir.requestAnimatedBack(`root`)||yt.current?.()?!0:s===`assistant`?(l(`chat`),!0):Ct?(wt(),!0):!1));let Mt=q&&(ge===`desktop`||ge===`web`),Nt=K(()=>{if(G.enabled){we.info(n(`remoteProjects.configurationReadOnly`));return}let e=`new-mcp-server`,t=e,r=1;for(;xe.some(e=>e.name===t);)t=`${e}-${r}`,r+=1;Te({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),De(t),j(!1),Ge(`mcp`)}),Pt=K(()=>{if(M)return;if(G.enabled&&!G.entry){we.error(n(`remoteProjects.host-unavailable`));return}N(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([Ce(),Se(),e]).finally(()=>N(!1))}),Ft=Ot(e=>e.openNewSessionDraft),It=Z.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(G.enabled){if(!G.entry){we.error(n(`remoteProjects.host-unavailable`));return}G.openSession(null),Ae?l(`chat`):jt.getState().openRemoteProject();return}if(Ae){l(`chat`),Ft();return}jt.getState().openDraft()}}];return Ae||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>et()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:Oe,onSelect:()=>Y()}),G.enabled||e.push({key:`mcp`,iconNode:(0,$.jsx)(si,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>j(!0)}),Mt&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>L(!0)}),Ae&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>Ge()}),Ne&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:ce,spinning:ce,onSelect:Et}),e.push({key:`remote-desktop`,icon:`computer`,label:n(`remoteDesktop.title`),onSelect:oe}),e},[Ne,Oe,Ae,ce,Y,et,Ft,oe,Ge,Et,G,l,Mt,n]);return(0,$.jsx)(To,{remote:G.enabled,remoteState:G.owner?.state,sessionId:Ne??``,directory:Le||me||void 0,active:Ae?s!==`assistant`:je===`chat`||G.enabled&&je===`draft`,children:(0,$.jsx)(ei,{actions:gt,children:(0,$.jsxs)(ws,{children:[(0,$.jsxs)(`div`,{className:`yuri-mobile-app-shell main-content-safe-area flex h-[100dvh] flex-row text-foreground`,"data-page-scroll-lock":`true`,children:[Ae?(0,$.jsxs)(`aside`,{ref:pt.asideRef,className:it(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!Ve&&`border-r-0`),style:{width:Ve?pt.width:0,minWidth:Ve?pt.width:0,maxWidth:Ve?pt.width:0,"--yuri-ipad-sidebar-width":`${pt.width}px`,overflowX:`clip`,paddingTop:`var(--yuri-safe-area-top, 0px)`,transitionProperty:pt.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Ve,"data-page-scroll-lock":`true`,children:[Ve?(0,$.jsx)(bm,{side:`left`,isResizing:pt.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:pt.handleProps}):null,(0,$.jsx)(`div`,{className:it(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,pt.isResizing&&`pointer-events-none`,!Ve&&`pointer-events-none select-none opacity-0`),style:{width:`var(--yuri-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(sr,{children:(0,$.jsx)(ou,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&Re&&He(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,inert:ie||void 0,"aria-hidden":ie||void 0,children:Ae?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(Rm,{onOpenSessions:()=>$e(),menuOpen:ne,onToggleMenu:ue,surfaceShortcuts:{activePanel:Ue===`turn-diff`?`changes`:Ue,changesDirty:Oe>0,onToggleFiles:()=>ct(`files`),onToggleChanges:()=>ct(`changes`)}})}),(0,$.jsx)(`main`,{ref:bt,className:`relative min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(`div`,{className:`relative h-full w-full bg-background`,children:(0,$.jsx)(sr,{children:s===`assistant`?(0,$.jsx)(ao,{}):(0,$.jsx)(Qp,{})})})})]}):(0,$.jsx)(Ku,{className:`min-h-0 flex-1`,onAddProject:()=>ee(!0),onScanQr:ve&&ye?()=>{Ze()}:void 0,onSwitchInstance:ve?Je:void 0,onRemoteDesktop:ae,remoteDesktopActive:ie,instanceOptions:ve?e.connections.map(t=>({id:t.id,label:t.label,active:ke(t),disabled:e.isBusy})):void 0,onEnableAssistants:()=>{Ge(`assistants`)},instancesPage:ve?(0,$.jsx)(Am,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,instancesSecondaryPage:ve?(0,$.jsxs)(`div`,{className:`yuri-settings-workspace yuri-settings-workspace-mobile flex h-full min-h-0 flex-col bg-[var(--surface-background)]`,children:[(0,$.jsx)(Be,{title:n(`mobile.settings.switchInstance`),backAriaLabel:n(`header.actions.backAria`),onBack:Xe}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[var(--yuri-mobile-page-inline-inset)]`,children:(0,$.jsx)(pi,{className:`yuri-mobile-settings-detail-card`,children:(0,$.jsx)(Am,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:Ct?{id:Ct.id,directory:Ct.directory??null,...G.enabled?{onSelect:wt}:{}}:null,registerSecondaryBackHandler:At,scheduledContent:(e,t)=>(0,$.jsx)(Xi,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(Zp,{sessionId:G.enabled?G.sessionId??``:e.sessionId,directory:G.enabled?G.entry?.location.directory:e.directory,title:G.enabled?G.session?.title:void 0,onBack:()=>{de(),Ir.requestAnimatedBack(`root`)},onOpenMenu:ue,onCloseMenu:de,menuOpen:e.active&&ne,children:(0,$.jsx)(`main`,{ref:e.active?bt:void 0,className:`relative h-full min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(`div`,{className:`relative h-full w-full bg-background`,children:(0,$.jsx)(sr,{children:(0,$.jsx)(Qp,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:G.enabled?G.sessionId:e.sessionId||null,directory:G.enabled?G.entry?.location.directory??null:e.directory,viewKey:G.enabled?`${G.key}:${G.sessionId??`draft`}`:e.viewKey}})})})})})})}),Ae?(0,$.jsxs)(`aside`,{ref:mt.asideRef,className:it(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!Ue&&`border-l-0`),style:{width:Ue?mt.width:0,minWidth:Ue?mt.width:0,maxWidth:Ue?mt.width:0,"--yuri-ipad-sidebar-width":`${mt.width}px`,overflowX:`clip`,paddingTop:`var(--yuri-safe-area-top, 0px)`,transitionProperty:mt.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Ue,"data-page-scroll-lock":`true`,children:[Ue?(0,$.jsx)(bm,{side:`right`,isResizing:mt.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:mt.handleProps}):null,(0,$.jsx)(`div`,{className:it(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,mt.isResizing&&`pointer-events-none`,!Ue&&`pointer-events-none select-none opacity-0`),style:{width:`var(--yuri-ipad-sidebar-width)`,overflowX:`hidden`},children:ut?(0,$.jsx)(sr,{children:ft===`files`?(0,$.jsx)(em,{onClose:st}):ft===`turn-diff`?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.nav.changes`)}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:st,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)($p,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,targetFilePath:T,navigationRequestKey:D,flushContent:!0})})]}):W?.toolPatches?.length?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:W.toolPatches.length>1?n(`mobile.nav.changes`):W.path}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:st,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)($p,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:W.path,targetLine:W.targetLine??null,toolPatches:W.toolPatches,singleFileView:W.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(tm,{onClose:st,initialDiffPath:W?.path??null,initialDiffStaged:W?.staged===!0,initialDiffTargetLine:W?.targetLine??null})}):null})]}):null,(0,$.jsx)(Qi,{open:R,onOpenChange:ee,forceMobile:!0}),(0,$.jsx)(Fm,{open:ne,onClose:()=>H(!1),items:It,rightOffset:Ae&&Ue?mt.width:0}),(0,$.jsx)(Zi,{}),ie&&(0,$.jsx)(Fd,{onClose:se,instanceName:e.connections.find(ke)?.label}),u?(0,$.jsx)(br,{id:om,open:u,onOpenChange:e=>{e||d(!1)},ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(em,{onClose:()=>d(!1)})})}):null,f&&m?(0,$.jsx)(br,{id:am,open:f,onOpenChange:e=>{e||tt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:m.path.split(/[/\\]/).filter(Boolean).at(-1)??m.path}),ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(em,{onClose:tt,initialFilePath:m.path,directFilePreview:!0,hideFileHeader:!0},m.path)})}):null,(0,$.jsx)(br,{id:im,open:y,onOpenChange:e=>{e||vt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.nav.changes`)}),ariaLabel:n(`mobile.nav.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)($p,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,toolbarInSheetHeader:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,targetFilePath:T,navigationRequestKey:D,flushContent:!0})})}),g&&W?(0,$.jsx)(br,{id:rm,open:g,onOpenChange:e=>{e||_t()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:W.toolPatches&&W.toolPatches.length>1?n(`mobile.nav.changes`):W.path}),ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:W.toolPatches?.length?(0,$.jsx)($p,{hideStackedFileSidebar:!0,toolbarInSheetHeader:!0,diffScope:`turn`,targetFilePath:W.path,targetLine:W.targetLine??null,toolPatches:W.toolPatches,singleFileView:W.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(tm,{initialDiffPath:W.path,initialDiffStaged:W.staged,initialDiffTargetLine:W.targetLine??null,hideDiffHeader:!0})})}):g?(0,$.jsx)(br,{id:sm,open:g,onOpenChange:e=>{e||_t()},ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(tm,{onClose:_t,initialDiffPath:W?.path??null,initialDiffStaged:W?.staged===!0,initialDiffTargetLine:W?.targetLine??null})})}):null,pe?(0,$.jsx)(br,{id:cm,open:pe,onOpenChange:e=>{e||j(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mcpDropdown.title`)}),trailing:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:Nt,"aria-label":n(`settings.mcp.sidebar.actions.addServerTitle`),title:n(`settings.mcp.sidebar.actions.addServerTitle`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`add`,className:`size-5`})}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:Pt,disabled:M,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`refresh`,className:it(`size-5`,M&&`animate-spin`)})})]}),ariaLabel:n(`mcpDropdown.title`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(Pi,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,P&&Ae?(0,$.jsx)(br,{id:lm,open:P,onOpenChange:e=>{e||F(!1)},ariaLabel:n(`mobile.menu.settings`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(Ga,{forceMobile:!0,isWindowed:!0,initialMobileStage:V,visiblePageSlugs:[...fr],onClose:()=>F(!1),mobileInstancesPage:ve?(0,$.jsx)(Am,{connection:e,onConnect:()=>F(!1),onActiveConnectionDeleted:t}):void 0})})}):null,I?(0,$.jsx)(br,{id:um,open:I,onOpenChange:e=>{e||L(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.menu.update`)}),ariaLabel:n(`mobile.menu.update`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(Ua,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(Vc,{enabled:ve&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(sr,{children:(0,$.jsx)(Ta,{})}),(0,$.jsx)(Ki,{})]})})})};function Bm({apis:e}){Z.useEffect(()=>qe(),[]);let{t}=Ee(),n=lt(e=>e.initializeApp),r=lt(e=>e.isInitialized),i=lt(e=>e.isConnected),a=lt(e=>e.connectionPhase),o=O(e=>e.currentDirectory),c=Ot(e=>e.currentSessionId),l=Ot(e=>!!e.newSessionDraft?.open),d=Ot(e=>e.error),f=Ot(e=>e.clearError),m=_e(e=>e.setIsMobile),h=li(e=>e.refreshStatus),g=st(e=>e.projects),[_,v]=Z.useState(0),[y,x]=Z.useState(0),[S,C]=Z.useState(!1),[w,T]=Z.useState(`pending`),E=Z.useMemo(()=>Ae(),[]),[,D]=Z.useReducer(e=>e+1,0),k=Z.useMemo(()=>xm(),[]),A=Z.useRef(0),j=Z.useRef(0),M=Ie(()=>{T(`done`),v(e=>e+1)});Sf(K(e=>{M.redeemPairingConnection(e)}));let N=Cf({ready:k&&i&&r});Z.useEffect(()=>{!M.error||!p()||we.error(M.error)},[M.error]);let P=K(()=>{let t=p(),r=j.current+1;if(j.current=r,!t){Fe();return}let i=()=>{n(),h(e.github,{force:!0}),lt.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},a=()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),v(e=>e+1)};je().then(e=>{if(j.current===r){if(e===`no-connection`){a();return}if(e===`unreachable`){window.setTimeout(()=>{j.current===r&&je().then(e=>{if(j.current===r&&e!==`switched`&&e===`unchanged`){i();return}})},4e3);return}e!==`switched`&&i()}});let o=Date.now();o-A.current>=Dm&&(A.current=o,window.dispatchEvent(new Event(`yuri:system-resume`)))});Sm(),Cm(P),Z.useEffect(()=>{if(!k)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>P(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[k,P]),Z.useEffect(()=>(b(e),()=>b(null)),[e]),Z.useEffect(()=>{k&&Se().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[k]),Z.useEffect(()=>{if(!k)return;let e=!1,t=[];return Se().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`download`,e=>{ci.getState().setOtaDownloadPercent(e.percent)}),i=await n.addListener(`downloadFailed`,()=>{ci.getState().setOtaDownloadFailed()}),a=await n.addListener(`downloadComplete`,()=>{ci.getState().setOtaPhase(`pending_restart`)}),o=await n.addListener(`appReloaded`,()=>{ci.getState().setOtaPhase(`pending_restart`)}),s=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),ci.getState().setOtaPhase(`error`,`OTA update was reverted`)});if(e){r.remove(),i.remove(),a.remove(),o.remove(),s.remove();return}t.push(()=>void r.remove(),()=>void i.remove(),()=>void a.remove(),()=>void o.remove(),()=>void s.remove())}catch(e){console.warn(`[OTA] Failed to subscribe to Capgo updater events:`,e)}}),()=>{e=!0;for(let e of t)e()}},[k]),Z.useEffect(()=>s(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){Oa(),D();return}_a(e),jt.getState().reset(),x(e=>e+1),v(e=>e+1)}),[]),Z.useEffect(()=>{if(N===`pending`)return;if(N===`connect`){T(`done`);return}if(!k||i||p()){T(`done`);return}let e=!1;return T(`attempting`),Gt().then(e=>e?!0:Fe()).catch(()=>!1).then(()=>{e||T(`done`)}),()=>{e=!0}},[N]),Z.useEffect(()=>{m(!0)},[m]),Z.useEffect(()=>{k&&!p()||n()},[_,n,k]),mn({enabled:!k||!!p(),source:`mobileApp:recovery`}),Z.useEffect(()=>{i&&F.setDirectory(o)},[o,i]),Z.useEffect(()=>{i&&h(e.github,{force:!0})},[e.github,i,h]),Z.useEffect(()=>{if(!i||g.length===0)return;let e=!1;return(async()=>{await Promise.all(g.map(async t=>{if(t.hostId)return;let n=Tm(t.path);if(n)try{if(!(Sr.getState().directories.get(n)?.isGitRepo??await ge(()=>import(`./gitApi-BnO-MC2O.js`).then(e=>e.f).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([83,1,5,4,6,7,9,44,8,10,23,11,24,21,25,45,46,47,48,15,12,14,13,16,17,18,19,2,20,22,26,49,43,50,38,39,40,41,42,51,52,53,54,55,56,57])))||e)return;await Zr({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i,g]),Z.useEffect(()=>{if(!d)return;let e=window.setTimeout(()=>f(),5e3);return()=>window.clearTimeout(e)},[f,d]),Z.useEffect(()=>{if(!(!i&&(!k||p()))){C(!1);return}let e=window.setTimeout(()=>C(!0),8e3);return()=>window.clearTimeout(e)},[i,k,_,y]),Vn(),wn({enabled:!0}),Wn(),ka(),Xf({enabled:k&&i}),Jp();let I=tf(),L=!i&&a===`reconnecting`;if(!I)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(or,{width:120,height:120,isAnimated:!0})});let R=!!p();return k&&(!R||!i&&!L)?R?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-4`,children:[(0,$.jsx)(or,{width:120,height:120,isAnimated:!S}),S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]}),(0,$.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),v(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):w===`done`?(0,$.jsx)(Cs,{connection:M}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(or,{width:120,height:120,isAnimated:!0}),E?(0,$.jsxs)(`div`,{className:`absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center`,children:[(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.splash.connectingTo`)}),(0,$.jsxs)(`p`,{className:`typography-small text-foreground`,children:[E,(0,$.jsx)(En,{})]})]}):null]}):!i&&!L?S?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`max-w-sm space-y-3`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]})}):(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(or,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(sr,{children:(0,$.jsx)(Ue,{sdk:F.getSdkClient(),directory:o||``,bootstrapDirectory:!(l&&c===null),children:(0,$.jsxs)(dn,{apis:e,children:[(0,$.jsx)(Ii,{}),(0,$.jsx)(va,{ready:r,children:(0,$.jsx)(Jn,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(sa,{}),(0,$.jsx)(Kt,{}),(0,$.jsx)(nm,{}),(0,$.jsx)(Ln,{embeddedBackgroundWorkEnabled:r}),(0,$.jsx)(Yi,{}),(0,$.jsx)(Po,{}),(0,$.jsx)(Wo,{}),(0,$.jsx)(zm,{connection:M,onActiveConnectionDeleted:()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),jt.getState().reset(),v(e=>e+1)}}),(0,$.jsx)(bn,{position:`top-center`,offset:`calc(var(--yuri-safe-area-top, 0px) + 16px)`}),r?(0,$.jsx)(Oi,{}):null,r?(0,$.jsx)(Mi,{}):null,r?(0,$.jsx)(Ca,{autoStart:!1}):null]})})})]})},y)})}function Vm(e){return e.window}function Hm(e){e.currentTarget.style.transform=`none`}function Um(e){return e.ensureStatus}function Wm(e){return e.fetchStatus}function Gm(e){return e.providers}function Km(e){return e.currentProviderId}function qm(e){return e.currentModelId}function Jm(e){return e.getModelMetadata}function Ym(e){return e.results}function Xm(e){return e.loadSettings}function Zm(e){return e.fetchAllQuotas}function Qm(e){return e.isLoading}function $m(e){return e.displayMode}function eh(e){return e.dropdownProviderIds}function th(e){return e.selectedModels}function nh(e){return e.timeFormatPreference}function rh(e){return[e?.providerId,e]}function ih(e){return e.providerId}function ah(e){return!e}var oh=()=>{Oe(),E().then(()=>{Promise.all([D(),Mn()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),cn(),Gn(),Cn()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{uo()})};function sh(e){hr(),oh(),_e.getState().setIsMobile(!0),yo(),ur(),lr();let t=document.getElementById(`root`);if(!t)throw Error(`Root element not found`);let n=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`;n&&document.documentElement.classList.add(`yuri-native-app-active`);let r=n?{...e,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:e,i=(0,$.jsx)(Bm,{apis:r});(0,oo.createRoot)(t).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(_n,{children:(0,$.jsx)(Te,{children:(0,$.jsx)(kn,{children:(0,$.jsx)(pn,{children:(0,$.jsx)($i,{children:(0,$.jsx)(On,{children:n?i:(0,$.jsx)(jn,{children:i})})})})})})})}))}export{sh as renderMobileApp};
|
|
29
|
+
`}),t[52]=re):re=t[52];let H;return t[53]===ne?H=t[54]:(H=(0,$.jsxs)(`div`,{ref:b,className:`fixed inset-x-0 bottom-0 top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-header-height,56px))] z-20 pointer-events-none`,children:[ne,re]}),t[53]=ne,t[54]=H),H},Pm=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=Ee(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Er,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,$.jsx)(`span`,{className:`min-w-0 max-w-[60%] truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map((t,n)=>{let i=Ei(e.rows.map(Vm),n),o=r===`remaining`?t.window.remainingPercent:t.window.usedPercent,s=tr(t.window.valueLabel,o),c=Xn(t.window.resetAt,t.window.resetAfterFormatted??t.window.resetAtFormatted,a);return(0,$.jsxs)(Z.Fragment,{children:[i?(0,$.jsx)(`div`,{className:it(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-3 border-t border-[var(--surface-subtle)] pt-2`),children:i}):null,(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:t.subtitle?`${t.subtitle} · ${t.label}`:t.label}),c?(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-micro text-muted-foreground/70`,children:c}):null]}),(0,$.jsx)(`span`,{className:it(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,jm(t.window)),children:s===`-`?``:s})]})]},t.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 truncate typography-micro text-muted-foreground`,title:e.status,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,$.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},Fm=e=>{let t=(0,Q.c)(35),{open:n,onClose:r,items:i,rightOffset:a}=e,o=a===void 0?0:a,{t:s}=Ee(),c,l;if(t[0]!==r||t[1]!==n?(c=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},l=[r,n],t[0]=r,t[1]=n,t[2]=c,t[3]=l):(c=t[2],l=t[3]),Z.useEffect(c,l),!n)return null;let u;t[4]===r?u=t[5]:(u=(e,t,n)=>(0,$.jsxs)(`button`,{type:`button`,role:n===void 0?`menuitem`:`menuitemcheckbox`,"aria-checked":n,className:it(`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,t>0&&`border-t border-border/30`,e.disabled&&`cursor-not-allowed opacity-60`),style:{touchAction:`manipulation`},disabled:e.disabled,onClick:()=>{e.onSelect(),r()},children:[e.iconNode??(e.icon?(0,$.jsx)(X,{name:e.icon,className:it(`size-5 shrink-0 text-muted-foreground`,e.spinning&&`animate-spin`,e.key===`auto-read`&&`translate-x-px`)}):null),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:e.label}),e.badge&&e.badge>0?(0,$.jsx)(`span`,{className:`inline-flex size-2 shrink-0 rounded-full bg-primary`,"aria-hidden":!0}):null,n&&(0,$.jsx)(X,{name:`check`,className:`size-4 shrink-0 text-muted-foreground`})]},e.key),t[4]=r,t[5]=u);let d=u,f;t[6]===s?f=t[7]:(f=s(`mobile.menu.titleAria`),t[6]=s,t[7]=f);let p;t[8]===s?p=t[9]:(p=s(`mobile.surface.closeAria`),t[8]=s,t[9]=p);let m;t[10]===r?m=t[11]:(m=e=>{e.preventDefault(),r()},t[10]=r,t[11]=m);let h;t[12]!==p||t[13]!==m?(h=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":p,onPointerDown:m}),t[12]=p,t[13]=m,t[14]=h):h=t[14];let g=`max(1rem, calc(8px + ${o}px + var(--yuri-safe-area-right, 0px)))`,_;t[15]===g?_=t[16]:(_={right:g,animation:`mobile-menu-in 160ms cubic-bezier(0.32, 0.72, 0, 1) forwards`},t[15]=g,t[16]=_);let v;if(t[17]!==i||t[18]!==d){let e;t[20]===d?e=t[21]:(e=(e,t)=>d(e,t),t[20]=d,t[21]=e),v=i.map(e),t[17]=i,t[18]=d,t[19]=v}else v=t[19];let y;t[22]!==i.length||t[23]!==d||t[24]!==s?(y=(0,$.jsx)(ko,{children:e=>{let{enabled:t,available:n,toggle:r}=e;return d({key:`auto-read`,icon:`volume-up`,label:s(`mobile.menu.autoRead`),disabled:!n,onSelect:r},i.length,t)}}),t[22]=i.length,t[23]=d,t[24]=s,t[25]=y):y=t[25];let b;t[26]!==_||t[27]!==v||t[28]!==y?(b=(0,$.jsxs)(`div`,{id:dm,className:`pointer-events-auto absolute top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.25rem)] w-[min(220px,calc(100vw-1rem))] origin-top-right overflow-hidden rounded-2xl yuri-mobile-overlay-surface`,role:`menu`,style:_,onAnimationEnd:Hm,children:[v,y]}),t[26]=_,t[27]=v,t[28]=y,t[29]=b):b=t[29];let x;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`style`,{children:`@keyframes mobile-menu-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }`}),t[30]=x):x=t[30];let S;return t[31]!==b||t[32]!==f||t[33]!==h?(S=(0,$.jsxs)(`div`,{className:`pointer-events-none fixed inset-0 z-50`,role:`dialog`,"aria-modal":`true`,"aria-label":f,children:[h,b,x]}),t[31]=b,t[32]=f,t[33]=h,t[34]=S):S=t[34],S},Im=Z.memo(function(e){let t=(0,Q.c)(94),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=Ee(),{git:d}=ce(),f=Hd(i??``,a||void 0),p=f??l,m=Z.useRef(null),h=wt(i??``,a||void 0),g=wr(o),_=Cr(o),v=Sr(Um),y=Sr(Wm),b=lt(Gm),x=lt(Km),S=lt(qm),C=lt(Jm),w;t[0]===i?w=t[1]:(w=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=w);let T=Et(w),E=ii(Ym),D=ii(Xm),O=ii(Zm),k=ii(Qm),A=ii($m),j=ii(eh),M=ii(th),N=_e(nh);fi();let P,F;t[2]!==v||t[3]!==d||t[4]!==o?(P=()=>{o&&v(o,d)},F=[v,d,o],t[2]=v,t[3]=d,t[4]=o,t[5]=P,t[6]=F):(P=t[5],F=t[6]),Z.useEffect(P,F);let I,L;t[7]!==y||t[8]!==d||t[9]!==o?(I=()=>{if(o)return ht.onGitRefreshHint(e=>{Tm(e.directory)===o&&y(o,d)})},L=[y,d,o],t[7]=y,t[8]=d,t[9]=o,t[10]=I,t[11]=L):(I=t[10],L=t[11]),Z.useEffect(I,L);let R,ee;t[12]===D?(R=t[13],ee=t[14]):(R=()=>{D()},ee=[D],t[12]=D,t[13]=R,t[14]=ee),Z.useEffect(R,ee);let z,B;t[15]===j?(z=t[16],B=t[17]):(z=()=>{Dr(j)},B=[j],t[15]=j,t[16]=z,t[17]=B),Z.useEffect(z,B);let V,te;t[18]!==j||t[19]!==O||t[20]!==k||t[21]!==n||t[22]!==E?(V=()=>{!n||k||j.some(e=>!E.some(t=>t?.providerId===e))&&O()},te=[j,O,k,n,E],t[18]=j,t[19]=O,t[20]=k,t[21]=n,t[22]=E,t[23]=V,t[24]=te):(V=t[23],te=t[24]),Z.useEffect(V,te);let ne;t[25]===h?ne=t[26]:(ne=Ks(h),t[25]=h,t[26]=ne);let re=ne,H;t[27]!==S||t[28]!==x||t[29]!==re||t[30]!==T?(H=re??(T?{providerID:T.providerId,modelID:T.modelId}:null)??(x&&S?{providerID:x,modelID:S}:null),t[27]=S,t[28]=x,t[29]=re,t[30]=T,t[31]=H):H=t[31];let ie=H,U;if(t[32]!==C||t[33]!==ie||t[34]!==b){let e=(ie?b.find(e=>e.id===ie.providerID):void 0)?.models.find(e=>e.id===ie?.modelID),n;t[36]!==C||t[37]!==ie?(n=ie?C(ie.providerID,ie.modelID):void 0,t[36]=C,t[37]=ie,t[38]=n):n=t[38];let r=n;U=Hs(e?.limit,`context`)??r?.limit?.context??0,t[32]=C,t[33]=ie,t[34]=b,t[35]=U}else U=t[35];let ae=U,oe=Pt(i??``,ae,0,a||void 0),se=oe?.pending?null:oe?.totalTokens??0,le;t[39]!==ae||t[40]!==s||t[41]!==se?(le=Gs({totalTokens:se,contextLimit:ae,isDraft:s}),t[39]=ae,t[40]=s,t[41]=se,t[42]=le):le=t[42];let ue=le,de;t[43]!==_?.current||t[44]!==g||t[45]!==u?(de=g===!0?_?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[43]=_?.current,t[44]=g,t[45]=u,t[46]=de):de=t[46];let W=de,fe;if(t[47]!==j||t[48]!==E||t[49]!==M||t[50]!==u){let e=new Map(E.map(rh)),n;t[52]===j?n=t[53]:(n=e=>j.includes(e.id),t[52]=j,t[53]=n),fe=ui(E).filter(n).filter(t=>e.get(t.id)?.configured===!0).map(t=>{let n=e.get(t.id),r=[];for(let[e,t]of Ai(Object.entries(n?.usage?.windows??{}),n?.usage?.accounts))r.push({key:`window-${e}`,label:Yn(t.label??e),window:t});let i=Object.entries(n?.usage?.models??{}),a=M[t.id]??[],o=a.length>0?i.filter(e=>{let[t]=e;return a.includes(t)}):i;for(let[e,t]of o){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:Yn(a.label??i),subtitle:oi(e),window:a})}let s=!n.ok&&n.error?n.error:r.length===0?u(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:s}}),t[47]=j,t[48]=E,t[49]=M,t[50]=u,t[51]=fe}else fe=t[51];let G=fe,pe,me;t[54]!==n||t[55]!==G?(pe=()=>{!n||G.length===0||Dr(G.map(ih))},me=[n,G],t[54]=n,t[55]=G,t[56]=pe,t[57]=me):(pe=t[56],me=t[57]),Z.useEffect(pe,me);let K;t[58]===c?K=t[59]:(K=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[58]=c,t[59]=K);let he;t[60]!==p||t[61]!==f?(he=p?(0,$.jsx)(`span`,{className:it(`block truncate`,f?`yuri-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:p}):null,t[60]=p,t[61]=f,t[62]=he):he=t[62];let q;t[63]!==K||t[64]!==he?(q=(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center px-2 py-1.5 text-left`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[K,he]})}),t[63]=K,t[64]=he,t[65]=q):q=t[65];let ge;t[66]===u?ge=t[67]:(ge=u(`mobile.header.openMetadataAria`),t[66]=u,t[67]=ge);let ve;t[68]===r?ve=t[69]:(ve=()=>r(ah),t[68]=r,t[69]=ve);let ye;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ye={touchAction:`manipulation`},t[70]=ye):ye=t[70];let be=ue?.percentage??0,xe=ue?.pending,Se;t[71]!==be||t[72]!==xe?(Se=(0,$.jsx)(Is,{percentage:be,pending:xe}),t[71]=be,t[72]=xe,t[73]=Se):Se=t[73];let Ce;t[74]!==n||t[75]!==ge||t[76]!==ve||t[77]!==Se?(Ce=(0,$.jsx)(`button`,{ref:m,type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":ge,"aria-expanded":n,onClick:ve,style:ye,children:Se}),t[74]=n,t[75]=ge,t[76]=ve,t[77]=Se,t[78]=Ce):Ce=t[78];let we;t[79]===r?we=t[80]:(we=()=>r(!1),t[79]=r,t[80]=we);let Te;t[81]!==W||t[82]!==ue||t[83]!==k||t[84]!==n||t[85]!==A||t[86]!==we||t[87]!==N||t[88]!==G?(Te=(0,$.jsx)(Nm,{open:n,onClose:we,anchorRef:m,contextDisplay:ue,branchLabel:W,usageGroups:G,usageDisplayMode:A,isUsageLoading:k,timeFormatPreference:N}),t[81]=W,t[82]=ue,t[83]=k,t[84]=n,t[85]=A,t[86]=we,t[87]=N,t[88]=G,t[89]=Te):Te=t[89];let De;return t[90]!==q||t[91]!==Ce||t[92]!==Te?(De=(0,$.jsxs)($.Fragment,{children:[q,Ce,Te]}),t[90]=q,t[91]=Ce,t[92]=Te,t[93]=De):De=t[93],De}),Lm=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=Ee(),[a,o]=Z.useState(!1),s=O(e=>e.currentDirectory),c=Ot(e=>e.currentSessionId),l=Z.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=Ot(l)||s,d=Tm(u)||null,f=st(e=>e.projects),p=Ot(e=>e.availableWorktreesByProject),m=Z.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=Ot(m),g=Ze(c),_=Ot(e=>!!e.newSessionDraft?.open),v=Z.useMemo(()=>{let e=Tm(u);return e&&km((h?.projectDirectory?tt(f,h.projectDirectory):null)??Xe(f,p,e),e)||i(`mobile.header.noProject`)},[p,h?.projectDirectory,u,f,i]),y=g?.title?.trim()||(c?i(`mobile.sessions.untitled`):v),b=c?v:``;Z.useEffect(()=>{o(!1)},[c,u]);let x=K(()=>{o(!1),e()}),S=K(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Fs,{children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.sessions.openSheetAria`),onClick:x,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folders`,className:`size-5`})}),(0,$.jsx)(Im,{open:a,onOpenChange:o,currentSessionId:c,effectiveDirectory:u,gitDirectory:d,isNewSessionDraftOpen:_,primaryLabel:y,secondaryLabel:b}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:it(`flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`files`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.files`),"aria-pressed":r.activePanel===`files`,onClick:r.onToggleFiles,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(`button`,{type:`button`,className:it(`relative flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`changes`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.changes`),"aria-pressed":r.activePanel===`changes`,onClick:r.onToggleChanges,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-5`}),r.changesDirty?(0,$.jsx)(`span`,{className:`absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary`,"aria-hidden":!0}):null]})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.header.openMenuAria`),"aria-controls":dm,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`more-2`,className:`size-5`})})]})})},Rm=e=>{let t=(0,Q.c)(5),n=Ps();if(!n.enabled){let n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Lm,{...e}),t[0]=e,t[1]=n),n}let r;return t[2]!==e||t[3]!==n?(r=(0,$.jsx)(Fc,{...e,scope:n}),t[2]=e,t[3]=n,t[4]=r):r=t[4],r},zm=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=Ee(),r=vn();Ye(),at();let i=_e(e=>e.mobileSessionPanelOpen),a=_e(e=>e.setMobileSessionPanelOpen),o=_e(e=>e.isScheduledTasksDialogOpen),s=_e(e=>e.activeMainTab),c=ze(),l=_e(e=>e.setActiveMainTab),[u,d]=Z.useState(!1),[f,p]=Z.useState(!1),[m,h]=Z.useState(null),[g,v]=Z.useState(!1),[y,b]=Z.useState(!1),[x,S]=Z.useState(null),[C,w]=Z.useState(null),[T,E]=Z.useState(null),[D,k]=Z.useState(0),[A,j]=Z.useState(!1),[M,N]=Z.useState(!1),[P,F]=Z.useState(!1),[I,L]=Z.useState(!1),[R,ee]=Z.useState(!1),[z,B]=Z.useState(!1),[V,te]=Z.useState(`nav`),[ne,H]=Z.useState(!1),[ie,U]=Z.useState(!1),ae=K(()=>{H(!1),U(!0)}),oe=K(()=>{if(H(!1),G.enabled){we.info(n(`remoteProjects.nativeCapabilityUnavailable`,{capability:n(`remoteDesktop.title`)}));return}ae()}),se=K(()=>U(!1)),[ce,le]=Z.useState(!1),ue=K(()=>H(e=>!e)),de=K(()=>H(!1)),[W,fe]=Z.useState(null),G=Ps(),pe=A&&!G.enabled,me=O(e=>e.currentDirectory),he=_e(e=>e.setSettingsPage),q=ci(e=>e.available),ge=ci(e=>e.runtimeType),ve=Z.useMemo(()=>xm(),[]),ye=Z.useMemo(()=>ys(),[]),be=me??null,{data:xe=[],refetch:Se}=re({...za(be),enabled:pe}),{refetch:Ce}=re({...Ra(be),enabled:pe}),Te=Ha(e=>e.setMcpDraft),De=Ha(e=>e.setSelectedMcp),Oe=Cr(G.enabled?G.entry?.key??null:Tm(me)||null)?.files?.length??0;Z.useEffect(()=>ht.onDirectoryRequest(()=>ee(!0)),[]);let Ae=Z.useMemo(()=>_(),[]),je=jt(e=>e.secondary?.kind??null),Me=Ot(e=>G.enabled?null:e.currentSessionId),Ne=G.enabled?G.sessionId:Me,Pe=Ot(e=>e.setCurrentSession),Fe=Z.useMemo(()=>e=>!G.enabled&&Ne?e.getDirectoryForSession(Ne):null,[Ne,G.enabled]),Ie=Ot(Fe),Le=G.enabled?G.entry?.location.directory:Ie,Re=cr()===`portrait`,[Ve,He]=Z.useState(Ae&&!Re),[Ue,We]=Z.useState(null),Ge=K(e=>{if(e&&he(e),Ae){te(e?`page-content`:`nav`),F(!0);return}let t=jt.getState();if(e){t.openSettingsFromCurrent();return}he(`home`),t.setActiveTab(`settings`)}),Ke=K(()=>{Ge(`instances`)}),qe=K(()=>{jt.getState().openInstances()}),Je=K(async t=>{if(!t){qe();return}let n=e.connections.find(e=>e.id===t);!n||e.isBusy||ke(n)||(await e.connect({id:n.id,candidates:n.candidates,clientToken:n.clientToken,label:n.label}),ke(n)||qe())}),Xe=K(()=>{jt.getState().closeSecondary()}),Ze=K(async()=>{if(!z){B(!0);try{let t=await bs();switch(t.status){case`ok`:await e.connect({url:t.url,clientToken:t.clientToken,label:t.label});break;case`pairing`:await e.redeemPairingConnection(t.pairing);break;case`permission-denied`:we.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:we.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:we.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:we.error(n(`mobile.connect.scan.failed`))}}finally{B(!1)}}});Pr({enabled:!Ae,rootRoutesBlocked:i||u||f||g||y||o||pe||P||I||R||ne});let $e=K(()=>{let e=!Ve;e&&Re&&We(null),He(e)}),et=K(()=>{if(b(!1),S(null),w(null),p(!1),h(null),Ae){fe(null),We(`files`),Re&&He(!1);return}d(!0)}),tt=K(()=>{p(!1),h(null)}),nt=K(e=>{let t=e.path.trim();if(t){if(b(!1),S(null),w(null),fe(null),v(!1),Ae){_e.getState().setPendingFileFocusPath(t),We(`files`),Re&&He(!1);return}d(!1),h({path:t,targetLine:typeof e.targetLine==`number`&&Number.isFinite(e.targetLine)?Math.max(1,Math.trunc(e.targetLine)):void 0}),p(!0)}}),rt=_e(e=>e.pendingFileFocusPath);Z.useEffect(()=>{if(rt){if(Ae){et();return}nt({path:rt}),_e.getState().setPendingFileFocusPath(null)}},[rt,Ae,et,nt]);let Y=K((e=null)=>{if(b(!1),S(null),w(null),E(null),p(!1),h(null),fe(e),Ae){We(`changes`),Re&&He(!1);return}v(!0)}),ot=K((e,t,n)=>{fe(null),v(!1),p(!1),h(null),S(e??null),w(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(E(r),k(e=>e+1),Ae){We(`turn-diff`),Re&&He(!1);return}b(!0)}),st=K(()=>{We(null),fe(null),E(null)}),ct=K(e=>{if(Ue===e){st();return}e===`files`?et():Y()}),lt=Z.useRef(`changes`);Ue&&(lt.current=Ue);let[ut,dt]=Z.useState(!1);Z.useEffect(()=>{if(!Ae)return;if(Ue){dt(!0);return}let e=window.setTimeout(()=>dt(!1),240);return()=>window.clearTimeout(e)},[Ue,Ae]);let ft=Ue??lt.current,pt=ym(`left`,`yuri.ipad.leftSidebarWidth`,fm),mt=ym(`right`,`yuri.ipad.rightSidebarWidth`,pm),gt=Z.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{Y(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{Y({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:ot,openFile:({path:e,targetLine:t})=>{nt({path:e,targetLine:t})},openFiles:()=>et(),openSettings:e=>{Ge(e)}}),[Y,nt,et,Ge,ot]),_t=K(()=>{v(!1),fe(null)}),vt=K(()=>{b(!1),E(null)});xf(Z.useMemo(()=>({openSessions:()=>{if(Ae){He(!0);return}jt.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?et():e===`mcp`?j(!0):e===`instances`?Ke():e===`update`&&L(!0)},openChanges:({path:e,staged:t}={})=>{Y(e?{path:e,staged:t===!0}:null)},openSettings:e=>{Ge(e)}}),[Ae,Y,et,Ke,Ge]));let yt=Z.useRef(null),bt=Z.useRef(null),xt=Qe(G.enabled?null:Ne,G.enabled?void 0:Le||me||void 0),St=G.session?.parentID,Ct=G.enabled?St?{id:St,directory:Le}:null:xt,wt=K(()=>{Ct&&(G.enabled?G.openSession(Ct.id):Pe(Ct.id,Ct.directory))});qp();let Tt=Z.useRef(0);Z.useEffect(()=>(Tt.current+=1,le(!1),()=>{Tt.current+=1}),[Ne,G.key,G.entry]);let Et=K(()=>{let e=Ne;if(!e||ce)return;let t=Le||me||void 0,i=++Tt.current;le(!0),(async()=>{try{G.enabled?await G.refresh():await r.refreshSessionTranscript(e,{directory:t}),i===Tt.current&&we.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{i===Tt.current&&we.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{i===Tt.current&&le(!1)}})()}),Dt=!Ae&&(je===`chat`||je===`draft`);Z.useEffect(()=>{!Ae&&!Dt&&H(!1)},[Ae,Dt]),Z.useEffect(()=>{H(!1)},[Ne,G.key]);let kt=Ae&&s===`assistant`||!Ae&&!Dt||i||u||f||g||y||o||pe||P||I||R||ne||ie;Uf(bt,{onOpen:K(()=>{_r(xr)?.finish(`commit`)}),onPreviewStart:K(()=>{_r(xr)?.begin(`present`)}),onPreviewCancel:K(()=>{_r(xr)?.finish(`cancel`)}),onProgress:K(e=>{e!==null&&_r(xr)?.update(e)}),disabled:kt},Ae||Dt);let At=K(e=>{yt.current=e});wm(K(()=>ie?(se(),!0):ne?(H(!1),!0):R?(ee(!1),!0):o?(window.dispatchEvent(new Event(`yuri:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):Ir.backImmediately(`overlay`)?!0:f?(tt(),!0):u?(d(!1),!0):y?(vt(),!0):g?(_t(),!0):pe?(j(!1),!0):P?(F(!1),!0):I?(L(!1),!0):Ir.requestAnimatedBack(`root`)||yt.current?.()?!0:s===`assistant`?(l(`chat`),!0):Ct?(wt(),!0):!1));let Mt=q&&(ge===`desktop`||ge===`web`),Nt=K(()=>{if(G.enabled){we.info(n(`remoteProjects.configurationReadOnly`));return}let e=`new-mcp-server`,t=e,r=1;for(;xe.some(e=>e.name===t);)t=`${e}-${r}`,r+=1;Te({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),De(t),j(!1),Ge(`mcp`)}),Pt=K(()=>{if(M)return;if(G.enabled&&!G.entry){we.error(n(`remoteProjects.host-unavailable`));return}N(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([Ce(),Se(),e]).finally(()=>N(!1))}),Ft=Ot(e=>e.openNewSessionDraft),It=Z.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(G.enabled){if(!G.entry){we.error(n(`remoteProjects.host-unavailable`));return}G.openSession(null),Ae?l(`chat`):jt.getState().openRemoteProject();return}if(Ae){l(`chat`),Ft();return}jt.getState().openDraft()}}];return Ae||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>et()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:Oe,onSelect:()=>Y()}),G.enabled||e.push({key:`mcp`,iconNode:(0,$.jsx)(si,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>j(!0)}),Mt&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>L(!0)}),Ae&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>Ge()}),Ne&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:ce,spinning:ce,onSelect:Et}),e.push({key:`remote-desktop`,icon:`computer`,label:n(`remoteDesktop.title`),onSelect:oe}),e},[Ne,Oe,Ae,ce,Y,et,Ft,oe,Ge,Et,G,l,Mt,n]);return(0,$.jsx)(To,{remote:G.enabled,remoteState:G.owner?.state,sessionId:Ne??``,directory:Le||me||void 0,active:Ae?s!==`assistant`:je===`chat`||G.enabled&&je===`draft`,children:(0,$.jsx)(ei,{actions:gt,children:(0,$.jsxs)(ws,{children:[(0,$.jsxs)(`div`,{className:`yuri-mobile-app-shell main-content-safe-area flex h-[100dvh] flex-row text-foreground`,"data-page-scroll-lock":`true`,children:[Ae?(0,$.jsxs)(`aside`,{ref:pt.asideRef,className:it(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!Ve&&`border-r-0`),style:{width:Ve?pt.width:0,minWidth:Ve?pt.width:0,maxWidth:Ve?pt.width:0,"--yuri-ipad-sidebar-width":`${pt.width}px`,overflowX:`clip`,paddingTop:`var(--yuri-safe-area-top, 0px)`,transitionProperty:pt.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Ve,"data-page-scroll-lock":`true`,children:[Ve?(0,$.jsx)(bm,{side:`left`,isResizing:pt.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:pt.handleProps}):null,(0,$.jsx)(`div`,{className:it(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,pt.isResizing&&`pointer-events-none`,!Ve&&`pointer-events-none select-none opacity-0`),style:{width:`var(--yuri-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(sr,{children:(0,$.jsx)(ou,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&Re&&He(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,inert:ie||void 0,"aria-hidden":ie||void 0,children:Ae?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(Rm,{onOpenSessions:()=>$e(),menuOpen:ne,onToggleMenu:ue,surfaceShortcuts:{activePanel:Ue===`turn-diff`?`changes`:Ue,changesDirty:Oe>0,onToggleFiles:()=>ct(`files`),onToggleChanges:()=>ct(`changes`)}})}),(0,$.jsx)(`main`,{ref:bt,className:`relative min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(`div`,{className:`relative h-full w-full bg-background`,children:(0,$.jsx)(sr,{children:s===`assistant`?(0,$.jsx)(ao,{}):(0,$.jsx)(Qp,{})})})})]}):(0,$.jsx)(Ku,{className:`min-h-0 flex-1`,onAddProject:()=>ee(!0),onScanQr:ve&&ye?()=>{Ze()}:void 0,onSwitchInstance:ve?Je:void 0,onRemoteDesktop:ae,remoteDesktopActive:ie,instanceOptions:ve?e.connections.map(t=>({id:t.id,label:t.label,active:ke(t),disabled:e.isBusy})):void 0,onEnableAssistants:()=>{Ge(`assistants`)},instancesPage:ve?(0,$.jsx)(Am,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,instancesSecondaryPage:ve?(0,$.jsxs)(`div`,{className:`yuri-settings-workspace yuri-settings-workspace-mobile flex h-full min-h-0 flex-col bg-[var(--surface-background)]`,children:[(0,$.jsx)(Be,{title:n(`mobile.settings.switchInstance`),backAriaLabel:n(`header.actions.backAria`),onBack:Xe}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[var(--yuri-mobile-page-inline-inset)]`,children:(0,$.jsx)(pi,{className:`yuri-mobile-settings-detail-card`,children:(0,$.jsx)(Am,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:Ct?{id:Ct.id,directory:Ct.directory??null,...G.enabled?{onSelect:wt}:{}}:null,registerSecondaryBackHandler:At,scheduledContent:(e,t)=>(0,$.jsx)(Xi,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(Zp,{sessionId:G.enabled?G.sessionId??``:e.sessionId,directory:G.enabled?G.entry?.location.directory:e.directory,title:G.enabled?G.session?.title:void 0,onBack:()=>{de(),Ir.requestAnimatedBack(`root`)},onOpenMenu:ue,onCloseMenu:de,menuOpen:e.active&&ne,children:(0,$.jsx)(`main`,{ref:e.active?bt:void 0,className:`relative h-full min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(`div`,{className:`relative h-full w-full bg-background`,children:(0,$.jsx)(sr,{children:(0,$.jsx)(Qp,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:G.enabled?G.sessionId:e.sessionId||null,directory:G.enabled?G.entry?.location.directory??null:e.directory,viewKey:G.enabled?`${G.key}:${G.sessionId??`draft`}`:e.viewKey}})})})})})})}),Ae?(0,$.jsxs)(`aside`,{ref:mt.asideRef,className:it(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!Ue&&`border-l-0`),style:{width:Ue?mt.width:0,minWidth:Ue?mt.width:0,maxWidth:Ue?mt.width:0,"--yuri-ipad-sidebar-width":`${mt.width}px`,overflowX:`clip`,paddingTop:`var(--yuri-safe-area-top, 0px)`,transitionProperty:mt.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Ue,"data-page-scroll-lock":`true`,children:[Ue?(0,$.jsx)(bm,{side:`right`,isResizing:mt.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:mt.handleProps}):null,(0,$.jsx)(`div`,{className:it(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,mt.isResizing&&`pointer-events-none`,!Ue&&`pointer-events-none select-none opacity-0`),style:{width:`var(--yuri-ipad-sidebar-width)`,overflowX:`hidden`},children:ut?(0,$.jsx)(sr,{children:ft===`files`?(0,$.jsx)(em,{onClose:st}):ft===`turn-diff`?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.nav.changes`)}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:st,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)($p,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,targetFilePath:T,navigationRequestKey:D,flushContent:!0})})]}):W?.toolPatches?.length?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:W.toolPatches.length>1?n(`mobile.nav.changes`):W.path}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:st,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)($p,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:W.path,targetLine:W.targetLine??null,toolPatches:W.toolPatches,singleFileView:W.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(tm,{onClose:st,initialDiffPath:W?.path??null,initialDiffStaged:W?.staged===!0,initialDiffTargetLine:W?.targetLine??null})}):null})]}):null,(0,$.jsx)(Qi,{open:R,onOpenChange:ee,forceMobile:!0}),(0,$.jsx)(Fm,{open:ne,onClose:()=>H(!1),items:It,rightOffset:Ae&&Ue?mt.width:0}),(0,$.jsx)(Zi,{}),ie&&(0,$.jsx)(Fd,{onClose:se,instanceName:e.connections.find(ke)?.label}),u?(0,$.jsx)(br,{id:om,open:u,onOpenChange:e=>{e||d(!1)},ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(em,{onClose:()=>d(!1)})})}):null,f&&m?(0,$.jsx)(br,{id:am,open:f,onOpenChange:e=>{e||tt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:m.path.split(/[/\\]/).filter(Boolean).at(-1)??m.path}),ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(em,{onClose:tt,initialFilePath:m.path,directFilePreview:!0,hideFileHeader:!0},m.path)})}):null,(0,$.jsx)(br,{id:im,open:y,onOpenChange:e=>{e||vt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.nav.changes`)}),ariaLabel:n(`mobile.nav.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)($p,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,toolbarInSheetHeader:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,targetFilePath:T,navigationRequestKey:D,flushContent:!0})})}),g&&W?(0,$.jsx)(br,{id:rm,open:g,onOpenChange:e=>{e||_t()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:W.toolPatches&&W.toolPatches.length>1?n(`mobile.nav.changes`):W.path}),ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:W.toolPatches?.length?(0,$.jsx)($p,{hideStackedFileSidebar:!0,toolbarInSheetHeader:!0,diffScope:`turn`,targetFilePath:W.path,targetLine:W.targetLine??null,toolPatches:W.toolPatches,singleFileView:W.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(tm,{initialDiffPath:W.path,initialDiffStaged:W.staged,initialDiffTargetLine:W.targetLine??null,hideDiffHeader:!0})})}):g?(0,$.jsx)(br,{id:sm,open:g,onOpenChange:e=>{e||_t()},ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(tm,{onClose:_t,initialDiffPath:W?.path??null,initialDiffStaged:W?.staged===!0,initialDiffTargetLine:W?.targetLine??null})})}):null,pe?(0,$.jsx)(br,{id:cm,open:pe,onOpenChange:e=>{e||j(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mcpDropdown.title`)}),trailing:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:Nt,"aria-label":n(`settings.mcp.sidebar.actions.addServerTitle`),title:n(`settings.mcp.sidebar.actions.addServerTitle`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`add`,className:`size-5`})}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:Pt,disabled:M,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`refresh`,className:it(`size-5`,M&&`animate-spin`)})})]}),ariaLabel:n(`mcpDropdown.title`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(Pi,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,P&&Ae?(0,$.jsx)(br,{id:lm,open:P,onOpenChange:e=>{e||F(!1)},ariaLabel:n(`mobile.menu.settings`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(Ga,{forceMobile:!0,isWindowed:!0,initialMobileStage:V,visiblePageSlugs:[...fr],onClose:()=>F(!1),mobileInstancesPage:ve?(0,$.jsx)(Am,{connection:e,onConnect:()=>F(!1),onActiveConnectionDeleted:t}):void 0})})}):null,I?(0,$.jsx)(br,{id:um,open:I,onOpenChange:e=>{e||L(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.menu.update`)}),ariaLabel:n(`mobile.menu.update`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(Ua,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(Vc,{enabled:ve&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(sr,{children:(0,$.jsx)(Ta,{})}),(0,$.jsx)(Ki,{})]})})})};function Bm({apis:e}){Z.useEffect(()=>qe(),[]);let{t}=Ee(),n=lt(e=>e.initializeApp),r=lt(e=>e.isInitialized),i=lt(e=>e.isConnected),a=lt(e=>e.connectionPhase),o=O(e=>e.currentDirectory),c=Ot(e=>e.currentSessionId),l=Ot(e=>!!e.newSessionDraft?.open),d=Ot(e=>e.error),f=Ot(e=>e.clearError),m=_e(e=>e.setIsMobile),h=li(e=>e.refreshStatus),g=st(e=>e.projects),[_,v]=Z.useState(0),[y,x]=Z.useState(0),[S,C]=Z.useState(!1),[w,T]=Z.useState(`pending`),E=Z.useMemo(()=>Ae(),[]),[,D]=Z.useReducer(e=>e+1,0),k=Z.useMemo(()=>xm(),[]),A=Z.useRef(0),j=Z.useRef(0),M=Ie(()=>{T(`done`),v(e=>e+1)});Sf(K(e=>{M.redeemPairingConnection(e)}));let N=Cf({ready:k&&i&&r});Z.useEffect(()=>{!M.error||!p()||we.error(M.error)},[M.error]);let P=K(()=>{let t=p(),r=j.current+1;if(j.current=r,!t){Fe();return}let i=()=>{n(),h(e.github,{force:!0}),lt.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},a=()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),v(e=>e+1)};je().then(e=>{if(j.current===r){if(e===`no-connection`){a();return}if(e===`unreachable`){window.setTimeout(()=>{j.current===r&&je().then(e=>{if(j.current===r&&e!==`switched`&&e===`unchanged`){i();return}})},4e3);return}e!==`switched`&&i()}});let o=Date.now();o-A.current>=Dm&&(A.current=o,window.dispatchEvent(new Event(`yuri:system-resume`)))});Sm(),Cm(P),Z.useEffect(()=>{if(!k)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>P(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[k,P]),Z.useEffect(()=>(b(e),()=>b(null)),[e]),Z.useEffect(()=>{k&&Se().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[k]),Z.useEffect(()=>{if(!k)return;let e=!1,t=[];return Se().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`download`,e=>{ci.getState().setOtaDownloadPercent(e.percent)}),i=await n.addListener(`downloadFailed`,()=>{ci.getState().setOtaDownloadFailed()}),a=await n.addListener(`downloadComplete`,()=>{ci.getState().setOtaPhase(`pending_restart`)}),o=await n.addListener(`appReloaded`,()=>{ci.getState().setOtaPhase(`pending_restart`)}),s=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),ci.getState().setOtaPhase(`error`,`OTA update was reverted`)});if(e){r.remove(),i.remove(),a.remove(),o.remove(),s.remove();return}t.push(()=>void r.remove(),()=>void i.remove(),()=>void a.remove(),()=>void o.remove(),()=>void s.remove())}catch(e){console.warn(`[OTA] Failed to subscribe to Capgo updater events:`,e)}}),()=>{e=!0;for(let e of t)e()}},[k]),Z.useEffect(()=>s(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){Oa(),D();return}_a(e),jt.getState().reset(),x(e=>e+1),v(e=>e+1)}),[]),Z.useEffect(()=>{if(N===`pending`)return;if(N===`connect`){T(`done`);return}if(!k||i||p()){T(`done`);return}let e=!1;return T(`attempting`),Gt().then(e=>e?!0:Fe()).catch(()=>!1).then(()=>{e||T(`done`)}),()=>{e=!0}},[N]),Z.useEffect(()=>{m(!0)},[m]),Z.useEffect(()=>{k&&!p()||n()},[_,n,k]),mn({enabled:!k||!!p(),source:`mobileApp:recovery`}),Z.useEffect(()=>{i&&F.setDirectory(o)},[o,i]),Z.useEffect(()=>{i&&h(e.github,{force:!0})},[e.github,i,h]),Z.useEffect(()=>{if(!i||g.length===0)return;let e=!1;return(async()=>{await Promise.all(g.map(async t=>{if(t.hostId)return;let n=Tm(t.path);if(n)try{if(!(Sr.getState().directories.get(n)?.isGitRepo??await ge(()=>import(`./gitApi-DMqau005.js`).then(e=>e.f).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([83,1,5,4,6,7,9,44,8,10,23,11,24,21,25,45,46,47,48,15,12,14,13,16,17,18,19,2,20,22,26,49,43,50,38,39,40,41,42,51,52,53,54,55,56,57])))||e)return;await Zr({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i,g]),Z.useEffect(()=>{if(!d)return;let e=window.setTimeout(()=>f(),5e3);return()=>window.clearTimeout(e)},[f,d]),Z.useEffect(()=>{if(!(!i&&(!k||p()))){C(!1);return}let e=window.setTimeout(()=>C(!0),8e3);return()=>window.clearTimeout(e)},[i,k,_,y]),Vn(),wn({enabled:!0}),Wn(),ka(),Xf({enabled:k&&i}),Jp();let I=tf(),L=!i&&a===`reconnecting`;if(!I)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(or,{width:120,height:120,isAnimated:!0})});let R=!!p();return k&&(!R||!i&&!L)?R?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-4`,children:[(0,$.jsx)(or,{width:120,height:120,isAnimated:!S}),S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]}),(0,$.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),v(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):w===`done`?(0,$.jsx)(Cs,{connection:M}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(or,{width:120,height:120,isAnimated:!0}),E?(0,$.jsxs)(`div`,{className:`absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center`,children:[(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.splash.connectingTo`)}),(0,$.jsxs)(`p`,{className:`typography-small text-foreground`,children:[E,(0,$.jsx)(En,{})]})]}):null]}):!i&&!L?S?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`max-w-sm space-y-3`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]})}):(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(or,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(sr,{children:(0,$.jsx)(Ue,{sdk:F.getSdkClient(),directory:o||``,bootstrapDirectory:!(l&&c===null),children:(0,$.jsxs)(dn,{apis:e,children:[(0,$.jsx)(Ii,{}),(0,$.jsx)(va,{ready:r,children:(0,$.jsx)(Jn,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(sa,{}),(0,$.jsx)(Kt,{}),(0,$.jsx)(nm,{}),(0,$.jsx)(Ln,{embeddedBackgroundWorkEnabled:r}),(0,$.jsx)(Yi,{}),(0,$.jsx)(Po,{}),(0,$.jsx)(Wo,{}),(0,$.jsx)(zm,{connection:M,onActiveConnectionDeleted:()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),jt.getState().reset(),v(e=>e+1)}}),(0,$.jsx)(bn,{position:`top-center`,offset:`calc(var(--yuri-safe-area-top, 0px) + 16px)`}),r?(0,$.jsx)(Oi,{}):null,r?(0,$.jsx)(Mi,{}):null,r?(0,$.jsx)(Ca,{autoStart:!1}):null]})})})]})},y)})}function Vm(e){return e.window}function Hm(e){e.currentTarget.style.transform=`none`}function Um(e){return e.ensureStatus}function Wm(e){return e.fetchStatus}function Gm(e){return e.providers}function Km(e){return e.currentProviderId}function qm(e){return e.currentModelId}function Jm(e){return e.getModelMetadata}function Ym(e){return e.results}function Xm(e){return e.loadSettings}function Zm(e){return e.fetchAllQuotas}function Qm(e){return e.isLoading}function $m(e){return e.displayMode}function eh(e){return e.dropdownProviderIds}function th(e){return e.selectedModels}function nh(e){return e.timeFormatPreference}function rh(e){return[e?.providerId,e]}function ih(e){return e.providerId}function ah(e){return!e}var oh=()=>{Oe(),E().then(()=>{Promise.all([D(),Mn()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),cn(),Gn(),Cn()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{uo()})};function sh(e){hr(),oh(),_e.getState().setIsMobile(!0),yo(),ur(),lr();let t=document.getElementById(`root`);if(!t)throw Error(`Root element not found`);let n=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`;n&&document.documentElement.classList.add(`yuri-native-app-active`);let r=n?{...e,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:e,i=(0,$.jsx)(Bm,{apis:r});(0,oo.createRoot)(t).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(_n,{children:(0,$.jsx)(Te,{children:(0,$.jsx)(kn,{children:(0,$.jsx)(pn,{children:(0,$.jsx)($i,{children:(0,$.jsx)(On,{children:n?i:(0,$.jsx)(jn,{children:i})})})})})})})}))}export{sh as renderMobileApp};
|