@yuriai/web 0.3.2-beta.6 → 0.3.2
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-b8inwRDh.js → AgentAvatar-DmvbnnMh.js} +1 -1
- package/dist/assets/{AssistantConversationSurface-DcXXPlNA.js → AssistantConversationSurface-DxmQrzax.js} +3 -3
- package/dist/assets/{AssistantSessionCard-DX7b5oge.js → AssistantSessionCard-CsZIdhOH.js} +2 -2
- package/dist/assets/{AssistantUnreadBadge-D2d4OBjo.js → AssistantUnreadBadge-0K84uUof.js} +1 -1
- package/dist/assets/{AssistantView-oeyp5moU.js → AssistantView-eo7zU0tW.js} +1 -1
- package/dist/assets/{DiagramView-zPxVoYfO.js → DiagramView-CwgPnPU8.js} +1 -1
- package/dist/assets/{FadeInOnReveal-DqqNgA5K.js → FadeInOnReveal-CIabuv8E.js} +1 -1
- package/dist/assets/{GuiPluginPage-XEOZ2YIE.js → GuiPluginPage-CBWlpM7-.js} +1 -1
- package/dist/assets/{GuiPluginSurface-BLoRfTGO.js → GuiPluginSurface-4piMFmC2.js} +1 -1
- package/dist/assets/{GuiPluginWindow-BS0XZ8UB.js → GuiPluginWindow-D02tLdop.js} +1 -1
- package/dist/assets/{Icon-DNZA_riL.js → Icon-Br-W35tz.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-xLFiotWm.js → ImageLoadingPlaceholder-EHe_20yz.js} +1 -1
- package/dist/assets/{LoadingImage-B1Q7emSX.js → LoadingImage-DNt-_HCJ.js} +1 -1
- package/dist/assets/MarkdownRenderer-BjRyxBUx.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-CL86tRxk.js → MarkdownRendererImpl-CxfAdy1l.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-CbS9t0Lb.js → MarkstreamRendererImpl-B1ALcl04.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-D9OZvTH7.js → MobileDetailNavigation-DNLOs1n6.js} +1 -1
- package/dist/assets/MobileResizableSheet-Bp_8Cf4j.js +1 -0
- package/dist/assets/{MobileShareBridge-BqhP1wSW.js → MobileShareBridge-9zfdEyQ_.js} +1 -1
- package/dist/assets/{MobileSurface-DFRJ7nyL.js → MobileSurface-B1O-lCca.js} +1 -1
- package/dist/assets/{MultiRunWindow-BjmrZIN8.js → MultiRunWindow-DMvB8O02.js} +1 -1
- package/dist/assets/{OnboardingScreen-6UdQ9pI2.js → OnboardingScreen-DgxRaKDc.js} +1 -1
- package/dist/assets/{OverlayScrollbar-BsUherue.js → OverlayScrollbar-CcX4ZP8W.js} +1 -1
- package/dist/assets/{RemoteAssistantSessionCard-DuhxRmG_.js → RemoteAssistantSessionCard-BJz_SKef.js} +1 -1
- package/dist/assets/{SettingsView-CmYrql0Y.js → SettingsView-D7Kb5iGY.js} +3 -3
- package/dist/assets/{SettingsWindow-DbAjbzAm.js → SettingsWindow-YzVAr8Bo.js} +1 -1
- package/dist/assets/{SetupTourDialog-sMu7cJS7.js → SetupTourDialog-Dw9q3oII.js} +1 -1
- package/dist/assets/{TerminalView-BmdJXwbs.js → TerminalView-DZChxb-F.js} +1 -1
- package/dist/assets/{ToolOutputDialog-C03nGQvh.js → ToolOutputDialog-2F74CchZ.js} +1 -1
- package/dist/assets/{VoiceSettings-DV3EAW04.js → VoiceSettings-CJh5q7QP.js} +1 -1
- package/dist/assets/{YuriLogo-DNvrroBa.js → YuriLogo-BKdnDJwl.js} +1 -1
- package/dist/assets/{YuriWordmark-bJX68f2Y.js → YuriWordmark-D2e-o9nW.js} +1 -1
- package/dist/assets/{assistant-attachment-cache-zu9sz4ex.js → assistant-attachment-cache-BYvIyn1x.js} +1 -1
- package/dist/assets/{capgoAdapter-SjN4JN3S.js → capgoAdapter-Q9jzJN69.js} +1 -1
- package/dist/assets/{checkbox-BmDsqYlN.js → checkbox-CqeGKP3Z.js} +1 -1
- package/dist/assets/{client-CgAFd1ew.js → client-CzjApAA4.js} +4 -4
- package/dist/assets/{collapsible-CYFRNuOh.js → collapsible-BSOetNHq.js} +1 -1
- package/dist/assets/{context-menu-Ba6Opvzx.js → context-menu-r_DjszgU.js} +1 -1
- package/dist/assets/{desktopHosts-135cuRCE.js → desktopHosts-BsTrBVja.js} +1 -1
- package/dist/assets/{desktopRelayRestore-1aUztDPU.js → desktopRelayRestore-BxbRKak_.js} +1 -1
- package/dist/assets/{device-C8ZHblkr.js → device-BlmHHWT1.js} +1 -1
- package/dist/assets/{diagram-D0rZqQqX.js → diagram-CxwT-HHn.js} +1 -1
- package/dist/assets/{dialog-DcdiMxIb.js → dialog-rXqw-6ab.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-BZufsE6q.js → fileMentionTouchSelection-C0O4_Efn.js} +1 -1
- package/dist/assets/{fileReferenceActions-DX-Stroq.js → fileReferenceActions-DLTUzjwi.js} +1 -1
- package/dist/assets/{gitApi-B74KW8UU.js → gitApi-BA93t0ww.js} +1 -1
- package/dist/assets/gitApiHttp-BgUDBfaJ.js +3 -0
- package/dist/assets/{gui-BMN3-WPc.js → gui-KxRdG4j0.js} +1 -1
- package/dist/assets/{historyImportQueries-eR7Bj6VN.js → historyImportQueries-DiGQ8duS.js} +1 -1
- package/dist/assets/{host-iM7aLAip.js → host-BBp7NPZz.js} +1 -1
- package/dist/assets/{i18n-OsFhnlRH.js → i18n-BvjeIWrT.js} +1 -1
- package/dist/assets/{image-loading-ZB1bYt51.js → image-loading-Dlh4FIPJ.js} +1 -1
- package/dist/assets/{input-BSVjxHBf.js → input-9Y3tNEd9.js} +1 -1
- package/dist/assets/{input-store-DRTu4uZc.js → input-store-wWToFdzi.js} +1 -1
- package/dist/assets/{insertionBoundaries-Dt_DdXrL.js → insertionBoundaries-Dl5RMmA3.js} +1 -1
- package/dist/assets/main-Cli25Koo.js +169 -0
- package/dist/assets/{main-BezENVit.js → main-Dj1N_rUJ.js} +2 -2
- package/dist/assets/{markdownHeightCache-248kmm0A.js → markdownHeightCache-CaBnqn2C.js} +1 -1
- package/dist/assets/{mcpQueries-Da7X2ZE0.js → mcpQueries-DCgOzZ7g.js} +1 -1
- package/dist/assets/miniChat-Ct0NeLs3.js +2 -0
- package/dist/assets/mobile-Kg6aWex1.js +2 -0
- package/dist/assets/{mobileBackNavigation-CbHUVgUi.js → mobileBackNavigation-XjzoONfU.js} +1 -1
- package/dist/assets/{mobileConnections-B2OHZP1-.js → mobileConnections-plT2Z1fc.js} +2 -2
- package/dist/assets/{multirun-BtlXFSSx.js → multirun-1YatqupB.js} +1 -1
- package/dist/assets/{native-config-C7I5Js2W.js → native-config-C0CpO-0Q.js} +1 -1
- package/dist/assets/{navigation-Bart975B.js → navigation-Bz_aROXw.js} +2 -2
- package/dist/assets/{openRemoteProjectSession-BHawZ5DM.js → openRemoteProjectSession-9kfNj2Jy.js} +1 -1
- package/dist/assets/{platform-wF65ZFgV.js → platform-CiUKDeXd.js} +1 -1
- package/dist/assets/{project-preview-BhNspxqe.js → project-preview-BjTq299L.js} +1 -1
- package/dist/assets/{projectActions-50e_f9dI.js → projectActions-BPmI9_mW.js} +1 -1
- package/dist/assets/{projectMeta-548A_zjC.js → projectMeta-CBxwAjHm.js} +1 -1
- package/dist/assets/{prompt-attachment-upload-8bssUUT3.js → prompt-attachment-upload-Bem87nmm.js} +1 -1
- package/dist/assets/{pwa-BGxwZ3sK.js → pwa-1EqcEjis.js} +2 -2
- package/dist/assets/qoder-zGvP_RLr.svg +5 -0
- package/dist/assets/queue-abort-optimistic-C6AsLSmI.js +1 -0
- package/dist/assets/{react-DUWkLJW_.js → react-B_qpic0Y.js} +1 -1
- package/dist/assets/readiness-DcOz5lOE.js +2 -0
- package/dist/assets/{reference-history-D7pv4xBj.js → reference-history-DOMZlJml.js} +1 -1
- package/dist/assets/{remote-input-store-DFBMyVS-.js → remote-input-store-BvlOGMu_.js} +1 -1
- package/dist/assets/{remoteProjectQueries-8giIAvzL.js → remoteProjectQueries-yX3kOkR6.js} +1 -1
- package/dist/assets/{remoteSessionReference-D4uRxFrm.js → remoteSessionReference-Cn7Wzrg6.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CRP1yE3w.js → renderElectronMiniChatApp-B-hPtyBl.js} +2 -2
- package/dist/assets/renderMobileApp-CuOXMDN3.js +29 -0
- package/dist/assets/{runtime-auth-mjIpsk3N.js → runtime-auth-DA-qfGHk.js} +1 -1
- package/dist/assets/{runtime-fetch-DKZOpfzo.js → runtime-fetch-V-iMWR8t.js} +1 -1
- package/dist/assets/{runtime-file-download-Dc459c9e.js → runtime-file-download-DxL4XbME.js} +1 -1
- package/dist/assets/{runtime-file-resource-DnhWnndu.js → runtime-file-resource-CKQQEwNv.js} +1 -1
- package/dist/assets/{runtime-switch-BMjl5Y5W.js → runtime-switch-DEPKHgdL.js} +1 -1
- package/dist/assets/{runtimeConfig-CVQXB6Sk.js → runtimeConfig-C1A5pejN.js} +1 -1
- package/dist/assets/runtimeEndpointReset-oiLvIGYI.js +151 -0
- package/dist/assets/{scheduledTaskNavigation-Bi7sRiFW.js → scheduledTaskNavigation-CdBHn9ti.js} +1 -1
- package/dist/assets/{select-DikdnuBx.js → select-CK1DjdEi.js} +1 -1
- package/dist/assets/{sessionLookup-DIImfb9J.js → sessionLookup-CmckqEe_.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-2Mhh65oR.js → sortable-tabs-strip-Bd9uV_sY.js} +1 -1
- package/dist/assets/{speechSettingsQueries-B3yVfEX8.js → speechSettingsQueries-BHZs2Dyf.js} +1 -1
- package/dist/assets/src-aLILBedG.css +2 -0
- package/dist/assets/{terminalApi-eR_918UZ.js → terminalApi-CwTOFYhX.js} +1 -1
- package/dist/assets/{textarea-CjzOsOcb.js → textarea-DvCd0eUo.js} +1 -1
- package/dist/assets/{tooltip-o8hl4eie.js → tooltip-B93KmoPh.js} +1 -1
- package/dist/assets/types-ClAbMq1_.js +2 -0
- package/dist/assets/{useAppFontEffects-BPTPdll8.js → useAppFontEffects-EXiDcoNt.js} +62 -62
- package/dist/assets/{useAssistantUIStore-CphyXHEY.js → useAssistantUIStore-CI42fWZh.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-ug8tD9Vh.js → useDesktopWindowControlsLayout-4TLDMOLv.js} +1 -1
- package/dist/assets/{useDictation-Do12BpsS.js → useDictation-OLmxagFb.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-DP_Vb2yB.js → useEffectiveDirectory-DFe0GivQ.js} +1 -1
- package/dist/assets/{useFontPreferences-DFF-uEAD.js → useFontPreferences-DN1mCOsX.js} +1 -1
- package/dist/assets/{useMobileHtmlPreviewStore-DUquFMmd.js → useMobileHtmlPreviewStore-DzzgY1eS.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-CXvADUF9.js → useMobileNavigationStore-BtHQN423.js} +12 -12
- package/dist/assets/{usePluginsStore-CfZJ7xPI.js → usePluginsStore-Ch1DaoBM.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-C47fBxo8.js → useProjectRuntimeAPIs-CnTyVRex.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-BZD-fFFZ.js → useStreamingTextThrottle-DAr0FPKI.js} +1 -1
- package/dist/assets/{useUIStore-CYex4rbF.js → useUIStore-DjizmHAt.js} +1 -1
- package/dist/index.html +20 -20
- package/dist/mini-chat.html +20 -20
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
- package/server/lib/gui-network/DOCUMENTATION.md +9 -1
- package/server/lib/realtime-proxy.js +4 -2
- package/server/lib/realtime-proxy.test.js +5 -4
- package/server/lib/relay/tunnel-host.js +15 -5
- package/server/lib/relay/tunnel-host.test.js +24 -0
- package/server/lib/remote-hosts/DOCUMENTATION.md +15 -2
- package/server/lib/remote-hosts/gateway.js +14 -4
- package/server/lib/remote-hosts/routes.js +9 -1
- package/server/lib/remote-hosts/routes.test.js +137 -7
- package/server/lib/remote-hosts/transport.js +1 -1
- package/server/lib/session-index/DOCUMENTATION.md +3 -0
- package/server/lib/session-index/service.js +4 -4
- package/server/lib/ui-auth/ui-auth.js +1 -1
- package/server/lib/ui-auth/ui-auth.test.js +3 -0
- package/dist/assets/MarkdownRenderer-D2oCSF9S.js +0 -2
- package/dist/assets/MobileResizableSheet-CJLBR89R.js +0 -1
- package/dist/assets/gitApiHttp-BEMPJCIG.js +0 -3
- package/dist/assets/main-CN6evHsO.js +0 -169
- package/dist/assets/miniChat-BYxNlok6.js +0 -2
- package/dist/assets/mobile-CVir7hmR.js +0 -2
- package/dist/assets/queue-abort-optimistic-Axqv48kA.js +0 -1
- package/dist/assets/readiness-DpD_wUMJ.js +0 -2
- package/dist/assets/renderMobileApp-DDcooBwa.js +0 -29
- package/dist/assets/runtimeEndpointReset-SUR75n8I.js +0 -151
- package/dist/assets/src-DRyZ4dLj.css +0 -2
- package/dist/assets/types-CsZ29VjS.js +0 -2
|
@@ -0,0 +1,29 @@
|
|
|
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-2F74CchZ.js","assets/runtime-auth-DA-qfGHk.js","assets/runtime-switch-DEPKHgdL.js","assets/runtime-fetch-V-iMWR8t.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-CiUKDeXd.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-fom6orB6.js","assets/vendor-react-D5BntRmA.js","assets/vendor-tanstack-react-query-ChSd65dm.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/runtime-file-resource-CKQQEwNv.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-B8s-Rcd-.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-DjizmHAt.js","assets/vendor-zustand-CNn3HHhT.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-DzzgY1eS.js","assets/runtime-file-download-DxL4XbME.js","assets/vendor-pierre-diffs-HJfPTtu2.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-BvjeIWrT.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-Dj5cSf8B.js","assets/tour-CMXP3Kif.js","assets/useMobileNavigationStore-BtHQN423.js","assets/gitApiHttp-BgUDBfaJ.js","assets/client-CzjApAA4.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-Bem87nmm.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-Y-KPX915.js","assets/useAssistantUIStore-CI42fWZh.js","assets/input-store-wWToFdzi.js","assets/remoteProjectQueries-yX3kOkR6.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/toolHelpers-iEHVHQ9p.js","assets/useThemeSystem-D2YBbLma.js","assets/vendor-framer-motion-DiGWHm7K.js","assets/Icon-Br-W35tz.js","assets/dialog-rXqw-6ab.js","assets/dialog-DYOEW9DC.css","assets/tap-LkQum5bB.js","assets/themes-BgDJcxRc.js","assets/MarkdownRenderer-BjRyxBUx.js","assets/useEffectiveDirectory-DFe0GivQ.js","assets/markdownHeightCache-CaBnqn2C.js","assets/dualLimitLru-D8Sphgua.js","assets/MobileWindowStack-DGLdgoGr.js","assets/mobileBackNavigation-XjzoONfU.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/image-loading-Dlh4FIPJ.js","assets/image-loading-DA9JEHD8.css","assets/ImageLoadingPlaceholder-EHe_20yz.js","assets/vendor-tanstack-react-virtual-WY42p6U6.js","assets/markdownTheme-C2LJ3cJo.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-BA93t0ww.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-DA-qfGHk.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-DEPKHgdL.js";import{n as m}from"./runtime-fetch-V-iMWR8t.js";import{f as h,n as g,r as _,s as v,t as y}from"./platform-CiUKDeXd.js";import{n as b,t as x}from"./runtimeAPIRegistry-C2VogTny.js";import{a as S}from"./vendor-zustand-CNn3HHhT.js";import{it as C,ot as w,st as T}from"./vendor-base-ui-fom6orB6.js";import{Mt as E,Pt as D,St as O,xt as k}from"./gitApiHttp-BgUDBfaJ.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as A}from"./safeStorage-DTOhKN0V.js";import{Rt as j,Xt as M,Zt as N,an as P,ln as F,n as I,on as L,un as R,zt as ee}from"./client-CzjApAA4.js";import{n as z,t as B}from"./vendor-react-D5BntRmA.js";import{f as V}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{c as te,o as H,s as ne}from"./vendor-tanstack-react-query-ChSd65dm.js";import{C as U,D as re,E as W,G as ie,S as ae,T as oe,V as se,k as ce,q as le,w as ue,z as G}from"./runtime-file-resource-CKQQEwNv.js";import{o as de}from"./path-utils-jGozTg9d.js";import{i as K,l as fe,m as pe,r as q}from"./vendor-reactuses-core-B8s-Rcd-.js";import{a as me,n as he,o as ge}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as _e}from"./useUIStore-DjizmHAt.js";import{a as ve,o as ye,s as be,t as xe}from"./useMobileHtmlPreviewStore-DzzgY1eS.js";import{t as Se}from"./capgoAdapter-Q9jzJN69.js";/* empty css */import{a as Ce}from"./vendor-pierre-diffs-HJfPTtu2.js";import{r as we}from"./vendor-sonner-Y-KPX915.js";import{r as Te,t as Ee}from"./i18n-BvjeIWrT.js";import{i as De,n as Oe}from"./store-Dj5cSf8B.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-plT2Z1fc.js";import{S as Le,b as Re,h as ze,t as Be,v as Ve,y as He}from"./MobileDetailNavigation-DNLOs1n6.js";import{A as Ue,Ar as We,Ci as J,Cn as Ge,Di as Ke,Ei as qe,Fa as Je,Fr as Ye,Ga as Xe,H as Ze,Ha as Qe,In as Y,Ir as $e,J as et,Mr as tt,Oi as nt,Or as rt,Pt as it,R as at,Rn as ot,Si as st,Ti as ct,Wi as lt,Yi as ut,Zi as dt,_r as ft,ar as pt,at as mt,di as ht,er as gt,gi as _t,gr as vt,hr as yt,in as bt,ir as xt,lt as St,o as Ct,oi as wt,or as Tt,p as Et,pi as Dt,q as Ot,ra as kt,s as At,st as jt,t as Mt,tt as Nt,ut as Pt,vi as Ft,wi as It,wr as Lt,xi as Rt,yi as zt,z as Bt}from"./useMobileNavigationStore-BtHQN423.js";import{i as Vt,n as Ht,r as Ut}from"./useAssistantUIStore-CI42fWZh.js";import{a as Wt,o as Gt,t as Kt}from"./MobileShareBridge-9zfdEyQ_.js";import{d as qt,h as Jt,i as Yt,m as Xt,p as Zt}from"./remoteProjectQueries-yX3kOkR6.js";import{a as Qt,c as $t,i as en,s as tn}from"./toolHelpers-iEHVHQ9p.js";import{n as nn}from"./useThemeSystem-D2YBbLma.js";import{n as X}from"./Icon-Br-W35tz.js";import{a as rn,i as an,n as on,o as sn,r as cn,t as ln}from"./dialog-rXqw-6ab.js";import{At as un,Bt as dn,D as fn,Et as pn,G as mn,Gt as hn,Ht as gn,It as _n,K as vn,Kt as yn,Lt as bn,Mt as xn,Nt as Sn,Q as Cn,Qt as wn,R as Tn,Rt as En,S as Dn,St as On,T as kn,Tt as An,U as jn,Ut as Mn,Vt as Nn,W as Pn,Wt as Fn,X as In,Z as Ln,dt as Rn,ft as zn,ht as Bn,i as Vn,nt as Hn,q as Un,r as Wn,t as Gn,tt as Kn,wt as qn,x as Jn,zt as Yn}from"./useAppFontEffects-EXiDcoNt.js";import{t as Xn}from"./input-9Y3tNEd9.js";import{t as Zn}from"./tap-LkQum5bB.js";import{r as Qn}from"./tooltip-B93KmoPh.js";import{A as $n,D as er,E as tr,G as nr,K as rr,M as ir,O as ar,Q as or,S as sr,W as cr,q as lr}from"./pwa-1EqcEjis.js";import{t as ur}from"./YuriLogo-BKdnDJwl.js";import{o as dr}from"./react-B_qpic0Y.js";import{i as fr,o as pr,t as mr}from"./device-BlmHHWT1.js";import{r as hr}from"./themes-BgDJcxRc.js";import{o as gr}from"./scheduledTaskNavigation-CdBHn9ti.js";import{a as _r,n as vr,o as yr}from"./MarkdownRenderer-BjRyxBUx.js";import{C as br,d as xr,n as Sr,r as Cr,t as wr,u as Tr}from"./MobileResizableSheet-Bp_8Cf4j.js";import{_ as Er,g as Dr,v as Or,w as kr}from"./insertionBoundaries-Dl5RMmA3.js";import{l as Ar,u as jr}from"./select-CK1DjdEi.js";import{M as Mr,N as Nr,O as Pr,h as Fr,i as Ir,n as Lr,r as Rr,s as zr,t as Br}from"./mobileBackNavigation-XjzoONfU.js";import{r as Vr}from"./queue-abort-optimistic-C6AsLSmI.js";import{o as Hr}from"./image-loading-Dlh4FIPJ.js";import{t as Ur}from"./ImageLoadingPlaceholder-EHe_20yz.js";import{t as Wr}from"./LoadingImage-DNt-_HCJ.js";import{n as Gr,r as Kr}from"./textarea-DvCd0eUo.js";import{a as qr,f as Jr,i as Yr,n as Xr,s as Zr}from"./projectMeta-CBxwAjHm.js";import{r as Qr}from"./ToolOutputDialog-2F74CchZ.js";import{c as $r,s as ei}from"./sessionLookup-CmckqEe_.js";import{n as ti,t as ni}from"./useProjectRuntimeAPIs-CnTyVRex.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-B1O-lCca.js";import{t as gi}from"./openRemoteProjectSession-9kfNj2Jy.js";import{i as _i,r as vi}from"./AssistantConversationSurface-DxmQrzax.js";import{t as yi}from"./useFontPreferences-DN1mCOsX.js";import{$ as bi,B as xi,Bt as Si,C as Ci,Ct as wi,D as Ti,Dt as Ei,E as Di,Et as Oi,F as ki,G as Ai,Gt as ji,H as Mi,I as Ni,It as Pi,J as Fi,Jt as Ii,K as Li,L as Ri,Lt as zi,Ot as Bi,Pt as Vi,Q as Hi,Qt as Ui,R as Wi,Rt as Gi,St as Ki,T as qi,Tt as Ji,Ut as Yi,V as Xi,Wt as Zi,X as Qi,Y as $i,Yt as ea,Z as ta,_t as na,a as ra,at as ia,b as aa,c as oa,ct as sa,d as ca,dt as la,f as ua,ft as da,gt as fa,ht as pa,i as ma,it as ha,kt as ga,l as _a,lt as va,mt as ya,n as ba,nt as xa,o as Sa,ot as Ca,pt as wa,q as Ta,qt as Ea,r as Da,rt as Oa,s as ka,st as Aa,t as ja,tt as Ma,u as Na,ut as Pa,vt as Fa,wt as Ia,z as La,zt as Ra}from"./runtimeEndpointReset-oiLvIGYI.js";import{t as za}from"./YuriWordmark-D2e-o9nW.js";import{r as Ba,t as Va}from"./mcpQueries-DCgOzZ7g.js";import{f as Ha}from"./usePluginsStore-Ch1DaoBM.js";import{a as Ua,i as Wa,o as Ga,r as Ka,t as qa}from"./SettingsView-D7Kb5iGY.js";import{i as Ja,s as Ya}from"./readiness-DcOz5lOE.js";import{t as Xa}from"./relay-preview-frame-src-BPyz3nXA.js";import{n as Za}from"./project-preview-BjTq299L.js";import{n as Qa,r as $a,t as eo}from"./AssistantUnreadBadge-0K84uUof.js";import{a as to,c as no,i as ro,o as io,r as ao,s as oo,t as so}from"./AssistantView-eo7zU0tW.js";var Z=e(T(),1),co=B(),lo=null,uo=!1,fo=new Promise(e=>{lo=e});function po(){uo||(uo=!0,lo?.())}var mo=6,ho=e=>e.parentID??null,go=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},_o=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),vo=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=_o(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return go(n?n.path:e)},yo=()=>{let e=zt.getState().activeSessions,t=rt.getState().index.session.unseenCount,n=Qe.getState().projects,r=0,i=[];for(let a of e){let e=ho(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:vo(_t(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,mo).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},bo=`__YURI_WIDGET_SNAPSHOT__`,xo=()=>{typeof window>`u`||(window[bo]=()=>{try{return JSON.stringify(yo())}catch{return null}})},Q=z(),So=me(`YuriScreenAwake`),Co=Promise.resolve(),wo=0;function To(e){let t=Co.then(()=>So.setEnabled({enabled:e}));return Co=t.catch(()=>void 0),t}async function Eo(){if(he.isNativePlatform()&&he.isPluginAvailable(`YuriScreenAwake`)){wo+=1;try{await To(!0)}catch(e){throw--wo,e}let e=!1;return async()=>{e||(e=!0,--wo,wo===0&&await To(!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 Do(e){let t=(0,Q.c)(3),n=Tt(),r=e.remoteState??n??void 0,i;return t[0]!==e||t[1]!==r?(i=(0,$.jsx)(Ao,{...e,remoteState:r}),t[0]=e,t[1]=r,t[2]=i):i=t[2],i}function Oo(e){let t=(0,Q.c)(6),{identity:n,onSource:r}=e,i=St(e.sessionId,e.directory),a=Pt(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 ko(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=q(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 Ao(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=q(e=>{l.current=e,d(t=>t?.identity===e.identity&&t.resolved===e.resolved?t:{identity:e.identity,resolved:e.resolved})}),[p,m]=fe(`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=Cn({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=q(()=>{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=q(()=>{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=q(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=q((e,n)=>{T.current.enabled&&D&&e===t&&T.current.observed.add(n)}),M=q(()=>{if(h){m(!1),O();return}D&&(m(!0),w.unlock().catch(()=>{we.error(o(`mobile.menu.autoReadFailed`))}))}),N=q(()=>{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=q(()=>{m(!1),O()});K(`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),K(`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 Eo().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)(In.Provider,{value:F,children:(0,$.jsxs)(Ln.Provider,{value:I,children:[a?(0,$.jsx)(ko,{...e,identity:c,onSource:f,remoteState:a}):e.remote?null:(0,$.jsx)(Oo,{...e,identity:c,onSource:f}),i]})})}function jo(e){let t=(0,Q.c)(3),{children:n}=e,r=(0,Z.useContext)(In);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 Mo={getPlatform:()=>he.getPlatform(),isPluginAvailable:e=>he.isPluginAvailable(e),openInSystemBrowser:e=>be.open(e),openExternal:ye},No=async(e,t=Mo)=>{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)},Po=`mobile-app-update-available`,Fo=`mobile-app-update-toast-dismissed-version`,Io=()=>{let e=(0,Q.c)(9),{t}=Ee(),n=ci(Lo),r=ci(Ro),i=ci(zo),a=ci(Bo),o=ci(Vo),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){J.dismiss(Po);return}A().getItem(Fo)!==i&&(c.current.has(i)||(c.current.add(i),J.info(t(`mobileUpdate.toast.available.title`),{id:Po,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:()=>{No(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{A().setItem(Fo,i),J.dismiss(Po)}}})))},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 Lo(e){return e.available}function Ro(e){return e.runtimeType}function zo(e){return e.info?.version}function Bo(e){return e.info?.downloadUrl}function Vo(e){return e.info?.inAppApply===!0}var Ho=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Uo=e=>e.enabled&&!e.alreadyChecked,Wo=`mobile-ota-update-available`,Go=`mobile-ota-update-toast-dismissed-version`,Ko=()=>{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(qo),u=ci(Jo),d=ci(Yo),f=ci(Xo),p=ci(Zo),m=ci(Qo),h=ci($o),_=ci(es),v=ci(ts),y=d?.version,b=d?.inAppApply===!0,x,S;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{Uo({enabled:c,alreadyChecked:i.current})&&(i.current=!0,ci.getState().checkForUpdates().catch(ns))},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=q(C),T=q(rs),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(!Ho({enabled:c,runtimeType:u,available:l,inAppApply:b,version:y??``,dismissedVersion:A().getItem(Go),seenVersions:o.current})||!y){(!l||!b||u!==`mobile`)&&J.dismiss(Wo);return}o.current.add(y),J.info(t(`mobileUpdate.ota.toast.available.title`),{id:Wo,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 qo(e){return e.available}function Jo(e){return e.runtimeType}function Yo(e){return e.info}function Xo(e){return e.downloading}function Zo(e){return e.downloaded}function Qo(e){return e.progress}function $o(e){return e.error}function es(e){return e.downloadUpdate}function ts(e){return e.restartToUpdate}function ns(){}function rs(e){A().setItem(Go,e),J.dismiss(Wo)}var is=me(`BarcodeScanner`),as=`yuri-barcode-scanner-active`,os=()=>xs()?is:null,ss=()=>window.Capacitor?.getPlatform?.()===`android`,cs=e=>typeof e==`object`&&e&&`message`in e?String(e.message??``):String(e??``),ls=e=>/^\s*scan canceled\.?\s*$/i.test(cs(e)),us=e=>/denied access to camera/i.test(cs(e)),ds=e=>!ls(e)&&!us(e),fs=e=>{let t=cs(e);return/module/i.test(t)&&/not\s*available|unavailable/i.test(t)},ps=e=>{e.installGoogleBarcodeScannerModule?.().catch(()=>void 0)},ms=e=>{let t=e.trim();if(!t)return null;if(/^yuri:\/\//i.test(t)){let e=Ua(t);return e?{pairing:e}:null}return/^https?:\/\//i.test(t)?{url:t}:null},hs=e=>{let t=ms(e);return t?`pairing`in t?{status:`pairing`,...t}:{status:`ok`,...t}:{status:`invalid`}},gs=e=>{typeof document>`u`||document.documentElement.classList.toggle(as,e)},_s=e=>{try{e()}catch{}},vs=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))}},ys=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))};gs(!0);let c=vs(()=>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(hs(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=>{us(e)?s({status:`permission-denied`}):s({status:`failed`})}),await o}finally{gs(!1),_s(c),_s(()=>r?.()),await Promise.allSettled([Promise.resolve(t?.remove()),Promise.resolve(n?.remove()),e.stopScan()])}},bs=e=>e.isNativePlatform&&e.isPluginAvailable,xs=()=>bs({isNativePlatform:he.isNativePlatform(),isPluginAvailable:he.isPluginAvailable(`BarcodeScanner`)}),Ss=async()=>{let e=os();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?hs(n):{status:`cancelled`}}catch(t){return ls(t)?{status:`cancelled`}:us(t)?{status:`permission-denied`}:ss()&&ds(t)&&e.startScan?(fs(t)&&ps(e),ys(e)):{status:`failed`}}return ss()&&e.startScan?ys(e):{status:`unsupported`}}catch{return{status:`failed`}}},Cs={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},ws=({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=q(async()=>{if(!(e||t||_)){v(!0);try{let e=await navigator.clipboard.readText();x(e);let t=ms(e);e.trim()&&(!t||!(`pairing`in t))&&d()}catch{g(f(`mobile.connect.link.pasteFallback`))}finally{v(!1)}}}),C=q(n=>{if(n.preventDefault(),e||t||_)return;let r=ms(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)(Xn,{...Cs,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)(Y,{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)(Y,{type:`submit`,variant:i,size:`lg`,className:a,disabled:e||t||_||!y.trim(),children:f(t?`mobile.connect.connecting`:`mobile.connect.connectButton`)})]})};function Ts({connection:e}){let{t}=Ee(),{connections:n,isBusy:r,error:i,pendingConnection:a}=e,o=Z.useMemo(()=>xs(),[]),[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=q(()=>{O||(a?(e.cancelPassword(),C(``)):A(null))}),N=q(async t=>{O||(_(t.id),C(``),await e.connect({id:t.id,candidates:t.candidates,label:t.label}))}),P=q(async()=>{if(!O){_(null),m(!0),e.setError(null);try{let n=await Ss();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=q(()=>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)(Y,{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)(za,{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)(ur,{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)(Y,{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)(Y,{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)(Y,{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)(Y,{variant:`ghost`,size:`lg`,disabled:O,className:`mx-auto text-muted-foreground`,onClick:()=>A(`more`),children:t(`mobile.connect.welcome.moreOptions`)})]})]})]}),(0,$.jsxs)(Cr,{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)(Y,{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)(Y,{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)(nr,{open:d===e.id,onOpenChange:t=>f(t?e.id:null),children:[(0,$.jsx)(or,{asChild:!0,children:(0,$.jsx)(Y,{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)(rr,{align:`end`,children:[(0,$.jsxs)(lr,{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)(lr,{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)(ur,{width:36,height:36,className:`mx-auto mb-5 opacity-40`}),o?L(!1):null,(0,$.jsx)(Y,{variant:`ghost`,size:`lg`,className:`w-full`,disabled:O,onClick:()=>A(`more`),children:t(`mobile.connect.link.useLink`)})]})]}),(0,$.jsx)(wr,{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)(Y,{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)(Y,{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)(Xn,{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)(Y,{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)(Y,{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)(Xn,{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)(Y,{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)(Y,{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)(Y,{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)(ws,{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)(Y,{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 Es(e){let t=(0,Q.c)(17),{children:n}=e,r=_e(ks),i=_e(Os),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],Lr(c);let l,u;t[5]===r?(l=t[6],u=t[7]):(l=()=>{if(!r)return;let e=document.activeElement,t=vn(`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)(Si,{presentation:`page`,onBack:Ds})}):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 Ds(){Br.requestAnimatedBack(`root`)}function Os(e){return e.setCommandPaletteOpen}function ks(e){return e.isCommandPaletteOpen}async function As(e,t,n,i){if(i){let r=await Za(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)||!Xa(`${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 js({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 As(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 K(`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)(Ya,{message:r(`contextPanel.preview.proxyError`)}),(0,$.jsx)(Y,{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 Ms(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)(Ya,{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)(js,{url:r,hostOrigin:i,entry:s}),t[6]=i,t[7]=s,t[8]=r,t[9]=c):c=t[9],c}function Ns(){let e=(0,Q.c)(17),{t}=Ee(),n=xe(Fs),r=W(),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)(Ja,{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)(js,{url:a.url,hostOrigin:e?.hostOrigin,entry:r.entry}):(0,$.jsx)(Ms,{location:a.location,url:a.url,hostOrigin:e?.hostOrigin}):(0,$.jsx)(js,{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)(wr,{id:`mobile-html-preview`,open:o,ariaLabel:c,closeAriaLabel:l,resizeAriaLabel:u,initiallyExpanded:!0,title:f,onOpenChange:Ps,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 Ps(e){e||xe.getState().close()}function Fs(e){return e.target}function Is(){let e=Qe(e=>e.projects.find(t=>t.id===e.activeProjectId)),t=Xe(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=pt(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:q(t=>{if(!e?.hostId||!p)throw Error(`Remote Host scope unavailable`);Xe.getState().openRemoteSession(e,p,t)}),refresh:q(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 Ls=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=ot(`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=ot(`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 Rs(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:tr(n)??0;let e=ir(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 zs=(e,t,n)=>H({queryKey:[...e.queryScope,`mobile-session-metadata`,t],staleTime:3e4,gcTime:1/0,retry:!1,queryFn:({signal:e})=>n(e)});function Bs(e){let t=G(e);return zs(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 Vs(e){let t=G(e);return zs(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 Hs(e,t){let n=G(e);return zs(e,`quota:${t}`,async e=>{let r=await n.json(`/api/quota/${encodeURIComponent(t)}`,{signal:e});if(!ie(r)||r.providerId!==t)throw Error(`Invalid quota response`);return r})}function Us(e){let t=G(e);return zs(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=>ie(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 Ws=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},Gs=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),Ks=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,qs=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:`${Gs(t)}/${Gs(n)}`,colorClass:Ks(i)}},Js=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},Ys=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``);function Xs(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(Zs)),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 zi(Object.entries(t?.usage?.windows??{}),t?.usage?.accounts))r.push({key:`window-${e}`,label:$n(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:$n(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 Zs(e){return[e?.providerId,e]}var Qs=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`},$s=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},ec=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)(Ar,{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=Pi(e.rows.map(Tc),n),o=r===`remaining`?t.window.remainingPercent:t.window.usedPercent,s=ar(t.window.valueLabel,o),c=er(t.window.resetAt,t.window.resetAfterFormatted??t.window.resetAtFormatted,a);return(0,$.jsxs)(Z.Fragment,{children:[i?(0,$.jsx)(`div`,{className:ot(`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:ot(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,Qs(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},tc=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=ot(`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)($s,{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)($s,{iconNode:(0,$.jsx)(Rs,{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:ot(`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)(ec,{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)(Y,{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:Ec,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
|
+
@keyframes session-metadata-in {
|
|
4
|
+
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
5
|
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
6
|
+
}
|
|
7
|
+
@keyframes session-metadata-out {
|
|
8
|
+
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
9
|
+
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
10
|
+
}
|
|
11
|
+
`}),t[48]=L):L=t[48];let R;return t[49]!==I||t[50]!==w?(R=(0,$.jsxs)(`div`,{className:`fixed inset-0 z-40 pointer-events-none`,children:[w,I,L]}),t[49]=I,t[50]=w,t[51]=R):R=t[51],R};function nc(e){let t=(0,Q.c)(9),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r=W(),i=Xe(rc);if(r?.entry.location.hostId){let e=i?.location.hubId===r.entry.location.hubId&&i.location.hostId===r.entry.location.hostId&&i.location.directory===r.entry.location.directory?i.sessionId:null,a=`${r.entry.key}:${e??``}`,o=e??``,s;return t[2]!==r.entry||t[3]!==n||t[4]!==a||t[5]!==o?(s=(0,$.jsx)(wc,{...n,sessionId:o,entry:r.entry},a),t[2]=r.entry,t[3]=n,t[4]=a,t[5]=o,t[6]=s):s=t[6],s}let a;return t[7]===n?a=t[8]:(a=(0,$.jsx)(ic,{...n}),t[7]=n,t[8]=a),a}function rc(e){return e.remoteSession}function ic(e){let t=(0,Q.c)(86),{sessionId:n,open:r,onOpenChange:i}=e,{t:a}=Ee(),{git:o}=se(),[s,c]=Z.useState(!1),l=r!==void 0,u=l?r:s,d=n.length===0,f;t[0]!==l||t[1]!==i||t[2]!==u?(f=e=>{let t=typeof e==`function`?e(u):e;l||c(t),i?.(t)},t[0]=l,t[1]=i,t[2]=u,t[3]=f):f=t[3];let p=q(f),m=O(bc),h;t[4]===n?h=t[5]:(h=e=>n?e.getDirectoryForSession(n):null,t[4]=n,t[5]=h);let g=Et(h)||m,_;t[6]===g?_=t[7]:(_=Ys(g)||null,t[6]=g,t[7]=_);let v=_,y=St(n,g||void 0),b=Or(v),x=Dr(v),S=Er(yc),C=Er(vc),w=dt(_c),T=dt(gc),E=dt(hc),D=dt(mc),k;t[8]===n?k=t[9]:(k=e=>n?e.sessionModelSelections.get(n)??null:null,t[8]=n,t[9]=k);let A=kt(k),j=ii(pc),M=ii(fc),N=ii(dc),P=ii(uc),F=ii(lc),I=ii(cc),L=_e(sc);fi();let R;t[10]===p?R=t[11]:(R=()=>{p(!1)},t[10]=p,t[11]=R);let ee;t[12]!==g||t[13]!==n?(ee=[n,g],t[12]=g,t[13]=n,t[14]=ee):ee=t[14],Z.useEffect(R,ee);let z,B;t[15]!==S||t[16]!==o||t[17]!==v?(z=()=>{v&&S(v,o)},B=[S,o,v],t[15]=S,t[16]=o,t[17]=v,t[18]=z,t[19]=B):(z=t[18],B=t[19]),Z.useEffect(z,B);let V,te;t[20]!==C||t[21]!==o||t[22]!==v?(te=()=>{if(v)return gt.onGitRefreshHint(e=>{Ys(e.directory)===v&&C(v,o)})},V=[C,o,v],t[20]=C,t[21]=o,t[22]=v,t[23]=V,t[24]=te):(V=t[23],te=t[24]),Z.useEffect(te,V);let H,ne;t[25]===M?(H=t[26],ne=t[27]):(H=()=>{M()},ne=[M],t[25]=M,t[26]=H,t[27]=ne),Z.useEffect(H,ne);let U,re;t[28]===F?(U=t[29],re=t[30]):(U=()=>{jr(F)},re=[F],t[28]=F,t[29]=U,t[30]=re),Z.useEffect(U,re);let W,ie;t[31]===u?(W=t[32],ie=t[33]):(W=()=>{!u||ii.getState().isLoading||ii.getState().fetchAllQuotas()},ie=[u],t[31]=u,t[32]=W,t[33]=ie),Z.useEffect(W,ie);let ae;t[34]===y?ae=t[35]:(ae=Js(y),t[34]=y,t[35]=ae);let oe=ae,ce;t[36]!==E||t[37]!==T||t[38]!==oe||t[39]!==A?(ce=oe??(A?{providerID:A.providerId,modelID:A.modelId}:null)??(T&&E?{providerID:T,modelID:E}:null),t[36]=E,t[37]=T,t[38]=oe,t[39]=A,t[40]=ce):ce=t[40];let le=ce,ue;if(t[41]!==D||t[42]!==le||t[43]!==w){let e=(le?w.find(e=>e.id===le.providerID):void 0)?.models.find(e=>e.id===le?.modelID),n;t[45]!==D||t[46]!==le?(n=le?D(le.providerID,le.modelID):void 0,t[45]=D,t[46]=le,t[47]=n):n=t[47];let r=n;ue=Ws(e?.limit,`context`)??r?.limit?.context??0,t[41]=D,t[42]=le,t[43]=w,t[44]=ue}else ue=t[44];let G=ue,de=Nt(n,G,0,g||void 0),K=de?.pending?null:de?.totalTokens??0,fe;t[48]!==G||t[49]!==d||t[50]!==K?(fe=qs({totalTokens:K,contextLimit:G,isDraft:d}),t[48]=G,t[49]=d,t[50]=K,t[51]=fe):fe=t[51];let pe=fe,me;t[52]!==x?.current||t[53]!==b||t[54]!==a?(me=b===!0?x?.current?.trim()||a(`gitView.branch.detachedHead`):a(`common.unavailable`),t[52]=x?.current,t[53]=b,t[54]=a,t[55]=me):me=t[55];let he=me,ge=Xs(j,F,I),ve,ye;t[56]!==u||t[57]!==ge?(ve=()=>{!u||ge.length===0||jr(ge.map(oc))},ye=[u,ge],t[56]=u,t[57]=ge,t[58]=ve,t[59]=ye):(ve=t[58],ye=t[59]),Z.useEffect(ve,ye);let be;t[60]===p?be=t[61]:(be=()=>{p(ac)},t[60]=p,t[61]=be);let xe=q(be),Se;t[62]===p?Se=t[63]:(Se=()=>{p(!1)},t[62]=p,t[63]=Se);let Ce=q(Se),we;t[64]===a?we=t[65]:(we=a(`mobile.header.openMetadataAria`),t[64]=a,t[65]=we);let Te=pe?.percentage??0,De=pe?.pending,Oe;t[66]!==Te||t[67]!==De?(Oe=(0,$.jsx)(Rs,{percentage:Te,pending:De}),t[66]=Te,t[67]=De,t[68]=Oe):Oe=t[68];let ke;t[69]!==xe||t[70]!==u||t[71]!==we||t[72]!==Oe?(ke=(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(Y,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":we,"aria-expanded":u,onClick:xe,children:Oe})}),t[69]=xe,t[70]=u,t[71]=we,t[72]=Oe,t[73]=ke):ke=t[73];let Ae;t[74]!==he||t[75]!==pe||t[76]!==Ce||t[77]!==N||t[78]!==u||t[79]!==P||t[80]!==L||t[81]!==ge?(Ae=(0,$.jsx)(tc,{open:u,onClose:Ce,contextDisplay:pe,branchLabel:he,usageGroups:ge,usageDisplayMode:P,isUsageLoading:N,timeFormatPreference:L}),t[74]=he,t[75]=pe,t[76]=Ce,t[77]=N,t[78]=u,t[79]=P,t[80]=L,t[81]=ge,t[82]=Ae):Ae=t[82];let je;return t[83]!==ke||t[84]!==Ae?(je=(0,$.jsxs)($.Fragment,{children:[ke,Ae]}),t[83]=ke,t[84]=Ae,t[85]=je):je=t[85],je}function ac(e){return!e}function oc(e){return e.providerId}function sc(e){return e.timeFormatPreference}function cc(e){return e.selectedModels}function lc(e){return e.dropdownProviderIds}function uc(e){return e.displayMode}function dc(e){return e.isLoading}function fc(e){return e.loadSettings}function pc(e){return e.results}function mc(e){return e.getModelMetadata}function hc(e){return e.currentModelId}function gc(e){return e.currentProviderId}function _c(e){return e.providers}function vc(e){return e.fetchStatus}function yc(e){return e.ensureStatus}function bc(e){return e.currentDirectory}var xc=[],Sc={},Cc=[],wc=Z.memo(function(e){let t=(0,Q.c)(113),{entry:n,sessionId:r,open:i,onOpenChange:a}=e,{t:o}=Ee(),[s,c]=Z.useState(!1),u=i??s,d;t[0]!==i||t[1]!==a?(d=e=>{i===void 0&&c(e),a?.(e)},t[0]=i,t[1]=a,t[2]=d):d=t[2];let f=q(d),p=_e(Dc),m=Z.useSyncExternalStore(P,N,N),h;t[3]===n.location?h=t[4]:(h=M(n.location),t[3]=n.location,t[4]=h);let g=h,_;t[5]!==n.location||t[6]!==g||t[7]!==r?(_=g&&r?L(n.location,r):null,t[5]=n.location,t[6]=g,t[7]=r,t[8]=_):_=t[8];let v;t[9]!==m||t[10]!==_?(v={revision:m,scope:_},t[9]=m,t[10]=_,t[11]=v):v=t[11];let y=v.scope,b;t[12]!==g||t[13]!==y?(b=e=>g&&y?g.subscribe(y,e):Oc,t[12]=g,t[13]=y,t[14]=b):b=t[14];let x=b,S;t[15]!==g||t[16]!==y?(S=()=>g&&y?g.getTranscript(y):null,t[15]=g,t[16]=y,t[17]=S):S=t[17];let C=S,w=Z.useSyncExternalStore(x,C,C),T;t[18]!==n.location||t[19]!==r?(T=e=>e.getSessionModelSelection(r||`remote-new-session`,n.location),t[18]=n.location,t[19]=r,t[20]=T):T=t[20];let E=kt(T),D;t[21]===n?D=t[22]:(D=Je(n.location.directory,l(),n),t[21]=n,t[22]=D);let O;t[23]!==u||t[24]!==D?(O={...D,enabled:u,gcTime:1/0},t[23]=u,t[24]=D,t[25]=O):O=t[25];let k=ne(O,le),A;t[26]===n?A=t[27]:(A=Bs(n),t[26]=n,t[27]=A);let F;t[28]!==u||t[29]!==A?(F={...A,enabled:u},t[28]=u,t[29]=A,t[30]=F):F=t[30];let I=ne(F,le),R;t[31]===n?R=t[32]:(R=Vs(n),t[31]=n,t[32]=R);let z;t[33]!==u||t[34]!==R?(z={...R,enabled:u},t[33]=u,t[34]=R,t[35]=z):z=t[35];let B=ne(z,le),V=u&&B.data?.autoRefresh?B.data.refreshIntervalMs:!1;B.data?.providerIds;let H;t[36]!==n||t[37]!==u||t[38]!==V||t[39]!==B.data?.providerIds?(H=u?(B.data?.providerIds??Cc).filter(kc).map(e=>({...Hs(n,e),refetchInterval:V})):[],t[36]=n,t[37]=u,t[38]=V,t[39]=B.data?.providerIds,t[40]=H):H=t[40];let U=H,re;t[41]===U?re=t[42]:(re={queries:U},t[41]=U,t[42]=re);let W=te(re,le),ie;t[43]===n?ie=t[44]:(ie=Us(n),t[43]=n,t[44]=ie);let ae;t[45]!==u||t[46]!==B.data?.providerIds?(ae=u&&!!B.data?.providerIds.some(Ac),t[45]=u,t[46]=B.data?.providerIds,t[47]=ae):ae=t[47];let oe;t[48]!==V||t[49]!==ie||t[50]!==ae?(oe={...ie,enabled:ae,refetchInterval:V},t[48]=V,t[49]=ie,t[50]=ae,t[51]=oe):oe=t[51];let se=ne(oe,le),ce;t[52]!==se.data||t[53]!==u||t[54]!==W?(ce=u?[...W.flatMap(jc),...se.data??xc]:xc,t[52]=se.data,t[53]=u,t[54]=W,t[55]=ce):ce=t[55];let ue=ce,G=u?B.data?.providerIds??Cc:Cc,de=Xs(ue,G,B.data?.selectedModels??Sc),K;bb0:{if(!w){K=null;break bb0}for(let e=w.messageOrder.length-1;e>=0;e--){let t=w.messagesByID[w.messageOrder[e]];if(!t)continue;let n=ee([t],e=>w.partsByMessageID[e]);if(n){K=n;break bb0}}K=null}let fe=K,pe=fe&&`messageId`in fe&&w?w.messagesByID[fe.messageId]:void 0,me;if(t[56]!==fe||t[57]!==pe?.modelID||t[58]!==pe?.providerID||t[59]!==k.data?.providers||t[60]!==E?.modelId||t[61]!==E?.providerId||t[62]!==r){let e=k.data?.providers.find(e=>e.id===(E?.providerId??pe?.providerID))?.models[E?.modelId??pe?.modelID??``],n=j(fe,e?.limit?.context??0,e?.limit?.output??0);me=qs({totalTokens:!n||n.pending?null:n.totalTokens,contextLimit:n?.contextLimit??0,isDraft:!r}),t[56]=fe,t[57]=pe?.modelID,t[58]=pe?.providerID,t[59]=k.data?.providers,t[60]=E?.modelId,t[61]=E?.providerId,t[62]=r,t[63]=me}else me=t[63];let he=me,ge;t[64]!==I.error||t[65]!==se||t[66]!==k.error||t[67]!==W||t[68]!==B.error?(ge=I.error??B.error??k.error??se.error??W.find(Mc)?.error,t[64]=I.error,t[65]=se,t[66]=k.error,t[67]=W,t[68]=B.error,t[69]=ge):ge=t[69];let ve=ge,ye;t[70]===f?ye=t[71]:(ye=()=>f(!1),t[70]=f,t[71]=ye);let be=q(ye),xe;t[72]!==u||t[73]!==f?(xe=()=>f(!u),t[72]=u,t[73]=f,t[74]=xe):xe=t[74];let Se=q(xe),Ce;t[75]!==I||t[76]!==se||t[77]!==k||t[78]!==W||t[79]!==B||t[80]!==G?(Ce=()=>{I.refetch(),B.refetch(),k.refetch(),G.some(Nc)&&se.refetch();for(let e of W)e.refetch()},t[75]=I,t[76]=se,t[77]=k,t[78]=W,t[79]=B,t[80]=G,t[81]=Ce):Ce=t[81];let we=q(Ce),Te;t[82]===o?Te=t[83]:(Te=o(`mobile.header.openMetadataAria`),t[82]=o,t[83]=Te);let De=he?.percentage??0,Oe=he?.pending,ke;t[84]!==De||t[85]!==Oe?(ke=(0,$.jsx)(Rs,{percentage:De,pending:Oe}),t[84]=De,t[85]=Oe,t[86]=ke):ke=t[86];let Ae;t[87]!==u||t[88]!==Te||t[89]!==ke||t[90]!==Se?(Ae=(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(Y,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":Te,"aria-expanded":u,onClick:Se,children:ke})}),t[87]=u,t[88]=Te,t[89]=ke,t[90]=Se,t[91]=Ae):Ae=t[91];let je;t[92]!==I.data||t[93]!==o?(je=I.data?.isGitRepository?I.data.current?.trim()||o(`gitView.branch.detachedHead`):o(`common.unavailable`),t[92]=I.data,t[93]=o,t[94]=je):je=t[94];let Me=B.data?.displayMode??`usage`,Ne;t[95]!==se||t[96]!==W||t[97]!==B.isFetching?(Ne=B.isFetching||se.isFetching||W.some(Pc),t[95]=se,t[96]=W,t[97]=B.isFetching,t[98]=Ne):Ne=t[98];let Pe=ve?.message,Fe;t[99]!==be||t[100]!==he||t[101]!==de||t[102]!==u||t[103]!==we||t[104]!==je||t[105]!==Me||t[106]!==Ne||t[107]!==Pe||t[108]!==p?(Fe=(0,$.jsx)(tc,{open:u,onClose:be,contextDisplay:he,branchLabel:je,usageGroups:de,usageDisplayMode:Me,isUsageLoading:Ne,timeFormatPreference:p,error:Pe,onRetry:we}),t[99]=be,t[100]=he,t[101]=de,t[102]=u,t[103]=we,t[104]=je,t[105]=Me,t[106]=Ne,t[107]=Pe,t[108]=p,t[109]=Fe):Fe=t[109];let Ie;return t[110]!==Ae||t[111]!==Fe?(Ie=(0,$.jsxs)($.Fragment,{children:[Ae,Fe]}),t[110]=Ae,t[111]=Fe,t[112]=Ie):Ie=t[112],Ie});function Tc(e){return e.window}function Ec(e){e.stopPropagation()}function Dc(e){return e.timeFormatPreference}function Oc(){}function kc(e){return!e.startsWith(`magpie:`)}function Ac(e){return e.startsWith(`magpie:`)}function jc(e){return e.data?[e.data]:xc}function Mc(e){return e.error}function Nc(e){return e.startsWith(`magpie:`)}function Pc(e){return e.isFetching}function Fc(e){let t=(0,Q.c)(17),{scope:n,children:r}=e,{t:i}=Ee();if(!n.supported){let e;t[0]===i?e=t[1]:(e=i(`remoteProjects.unsupported`),t[0]=i,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,$.jsx)(`div`,{role:`status`,children:e}),t[2]=e,t[3]=n),n}if(!n.registry||!n.entry||!n.owner){let e=n.error?`alert`:`status`,r;t[4]!==n.error?.message||t[5]!==i?(r=n.error?.message??i(`remoteProjects.state.connecting`),t[4]=n.error?.message,t[5]=i,t[6]=r):r=t[6];let a;return t[7]!==e||t[8]!==r?(a=(0,$.jsx)(`div`,{role:e,children:r}),t[7]=e,t[8]=r,t[9]=a):a=t[9],a}let a;t[10]!==r||t[11]!==n.owner.state?(a=(0,$.jsx)(xt.Provider,{value:n.owner.state,children:r}),t[10]=r,t[11]=n.owner.state,t[12]=a):a=t[12];let o;return t[13]!==n.entry.location||t[14]!==n.registry||t[15]!==a?(o=(0,$.jsx)(ce,{registry:n.registry,location:n.entry.location,children:a}),t[13]=n.entry.location,t[14]=n.registry,t[15]=a,t[16]=o):o=t[16],o}function Ic(e){let t=(0,Q.c)(58),{scope:n,onOpenSessions:r,menuOpen:i,onToggleMenu:a,surfaceShortcuts:o}=e,{t:s}=Ee(),[c,l]=Z.useState(!1),u;t[0]===r?u=t[1]:(u=()=>{l(!1),r()},t[0]=r,t[1]=u);let d=q(u),f;t[2]===a?f=t[3]:(f=()=>{l(!1),a()},t[2]=a,t[3]=f);let p=q(f),m;t[4]!==i||t[5]!==a?(m=e=>{e&&i&&a(),l(e)},t[4]=i,t[5]=a,t[6]=m):m=t[6];let h=q(m),g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>l(!1),t[7]=g):g=t[7];let _;t[8]!==n.key||t[9]!==n.sessionId?(_=[n.key,n.sessionId],t[8]=n.key,t[9]=n.sessionId,t[10]=_):_=t[10],Z.useEffect(g,_);let v;t[11]!==n.project?.label||t[12]!==n.project?.path||t[13]!==s?(v=n.project?.label?.trim()||n.project?.path.split(/[\\/]/).filter(Boolean).at(-1)||s(`mobile.header.noProject`),t[11]=n.project?.label,t[12]=n.project?.path,t[13]=s,t[14]=v):v=t[14];let y=v,b;t[15]===s?b=t[16]:(b=s(`mobile.sessions.openSheetAria`),t[15]=s,t[16]=b);let x;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(X,{name:`folders`,className:`size-5`}),t[17]=x):x=t[17];let S;t[18]!==d||t[19]!==b?(S=(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":b,onClick:d,children:x}),t[18]=d,t[19]=b,t[20]=S):S=t[20];let C;t[21]!==y||t[22]!==n.session?.title||t[23]!==n.sessionId||t[24]!==s?(C=n.session?.title?.trim()||(n.sessionId?s(`mobile.sessions.untitled`):y),t[21]=y,t[22]=n.session?.title,t[23]=n.sessionId,t[24]=s,t[25]=C):C=t[25];let w;t[26]===C?w=t[27]:(w=(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:C}),t[26]=C,t[27]=w);let T;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(X,{name:`computer`,className:`size-3 shrink-0`}),t[28]=T):T=t[28];let E=n.sessionId?`${y} · `:``,D=n.host?.name??n.entry?.location.hostId,O;t[29]!==E||t[30]!==D?(O=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[T,(0,$.jsxs)(`span`,{className:`truncate`,children:[E,D]})]}),t[29]=E,t[30]=D,t[31]=O):O=t[31];let k;t[32]!==w||t[33]!==O?(k=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col px-2 py-1.5 text-left leading-tight`,children:[w,O]}),t[32]=w,t[33]=O,t[34]=k):k=t[34];let A=n.sessionId??``,j;t[35]!==c||t[36]!==h||t[37]!==A?(j=(0,$.jsx)(nc,{sessionId:A,open:c,onOpenChange:h}),t[35]=c,t[36]=h,t[37]=A,t[38]=j):j=t[38];let M;t[39]!==o||t[40]!==s?(M=o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":s(`mobile.menu.files`),"aria-pressed":o.activePanel===`files`,onClick:o.onToggleFiles,children:(0,$.jsx)(X,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(Y,{variant:`ghost`,size:`icon`,className:`relative`,"aria-label":s(`mobile.menu.changes`),"aria-pressed":o.activePanel===`changes`,onClick:o.onToggleChanges,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-5`}),o.changesDirty?(0,$.jsx)(`span`,{className:`absolute right-2 top-2 size-2 rounded-full bg-primary`,"aria-hidden":!0}):null]})]}):null,t[39]=o,t[40]=s,t[41]=M):M=t[41];let N;t[42]===s?N=t[43]:(N=s(`mobile.header.openMenuAria`),t[42]=s,t[43]=N);let P;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(X,{name:`more-2`,className:`size-5`}),t[44]=P):P=t[44];let F;t[45]!==p||t[46]!==i||t[47]!==N?(F=(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":N,"aria-controls":`mobile-overflow-menu`,"aria-expanded":i,"aria-haspopup":`menu`,onClick:p,children:P}),t[45]=p,t[46]=i,t[47]=N,t[48]=F):F=t[48];let I;t[49]!==k||t[50]!==j||t[51]!==M||t[52]!==F||t[53]!==S?(I=(0,$.jsxs)(Ls,{children:[S,k,j,M,F]}),t[49]=k,t[50]=j,t[51]=M,t[52]=F,t[53]=S,t[54]=I):I=t[54];let L;return t[55]!==n||t[56]!==I?(L=(0,$.jsx)(Fc,{scope:n,children:I}),t[55]=n,t[56]=I,t[57]=L):L=t[57],L}var Lc=`/assets/android-direct-share-1a0lp154.jpg`,Rc=`/assets/ios-share-sheet-B3Dlufnc.jpg`,zc=`/assets/select-assistant-C89IRspC.jpg`,Bc=`yuri:assistant-share-welcome:v1`,Vc=[{image:Rc,titleKey:`assistants.shareWelcome.example.chat.title`,descriptionKey:`assistants.shareWelcome.example.chat.description`},{image:Lc,titleKey:`assistants.shareWelcome.example.article.title`,descriptionKey:`assistants.shareWelcome.example.article.description`},{image:zc,titleKey:`assistants.shareWelcome.example.note.title`,descriptionKey:`assistants.shareWelcome.example.note.description`}],Hc=e=>{let t=(0,Q.c)(40),{enabled:n,open:r,onOpenChange:i}=e,a=n!==void 0&&n,{t:o}=Ee(),[s,c]=fe(Bc,!1),l=r!==void 0,u=l?r:a&&s!==!0,d;t[0]!==l||t[1]!==i||t[2]!==c?(d=()=>{l||c(!0),i?.(!1)},t[0]=l,t[1]=i,t[2]=c,t[3]=d):d=t[3];let f=q(d),p;t[4]!==f||t[5]!==i?(p=e=>{e?i?.(!0):f()},t[4]=f,t[5]=i,t[6]=p):p=t[6];let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground sm:size-12`,children:(0,$.jsx)(X,{name:`share-2`,className:`size-5`})}),t[7]=m):m=t[7];let h;t[8]===o?h=t[9]:(h=o(`assistants.shareWelcome.title`),t[8]=o,t[9]=h);let g;t[10]===h?g=t[11]:(g=(0,$.jsx)(sn,{className:`typography-ui-header text-left sm:text-3xl`,children:h}),t[10]=h,t[11]=g);let _;t[12]===o?_=t[13]:(_=o(`assistants.shareWelcome.description`),t[12]=o,t[13]=_);let v;t[14]===_?v=t[15]:(v=(0,$.jsx)(cn,{className:`typography-ui text-left leading-6 sm:max-w-3xl sm:text-base sm:leading-7`,children:_}),t[14]=_,t[15]=v);let y;t[16]!==g||t[17]!==v?(y=(0,$.jsxs)(rn,{className:`flex-row items-start gap-3 px-5 pb-5 pt-6 text-left sm:gap-4 sm:px-8 sm:pb-6 sm:pt-8`,children:[m,(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1.5 sm:space-y-2`,children:[g,v]})]}),t[16]=g,t[17]=v,t[18]=y):y=t[18];let b;t[19]===o?b=t[20]:(b=o(`assistants.shareWelcome.examplesAria`),t[19]=o,t[20]=b);let x;t[21]===o?x=t[22]:(x=Vc.map((e,t)=>(0,$.jsxs)(`article`,{className:`w-[min(78vw,19rem)] shrink-0 snap-center overflow-hidden rounded-xl border border-border bg-background lg:w-auto lg:min-w-0`,children:[(0,$.jsxs)(`div`,{className:`relative overflow-hidden border-b border-border bg-muted`,children:[(0,$.jsx)(`img`,{src:e.image,alt:``,className:`h-72 w-full object-cover object-bottom lg:h-[min(38vh,23rem)]`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-3 top-3 flex size-7 items-center justify-center rounded-full bg-[var(--surface-elevated)] typography-meta font-semibold text-foreground shadow-sm`,children:t+1})]}),(0,$.jsxs)(`div`,{className:`space-y-1 px-4 py-3.5 lg:min-h-25`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:o(e.titleKey)}),(0,$.jsx)(`p`,{className:`typography-meta leading-5 text-muted-foreground`,children:o(e.descriptionKey)})]})]},e.titleKey)),t[21]=o,t[22]=x);let S;t[23]!==b||t[24]!==x?(S=(0,$.jsx)(`div`,{className:`overflow-hidden px-5 pb-5 sm:px-8 sm:pb-7`,children:(0,$.jsx)(`div`,{className:`flex snap-x snap-mandatory gap-3 overflow-x-auto pb-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden lg:grid lg:grid-cols-3 lg:overflow-visible lg:pb-0`,"aria-label":b,children:x})}),t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]===o?C=t[27]:(C=o(`assistants.shareWelcome.action`),t[26]=o,t[27]=C);let w;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4`}),t[28]=w):w=t[28];let T;t[29]!==f||t[30]!==C?(T=(0,$.jsx)(an,{className:`border-t border-border px-5 py-4 sm:px-8 sm:py-5`,children:(0,$.jsxs)(Y,{size:`lg`,className:`w-full lg:mx-auto lg:w-72`,onClick:f,children:[C,w]})}),t[29]=f,t[30]=C,t[31]=T):T=t[31];let E;t[32]!==S||t[33]!==T||t[34]!==y?(E=(0,$.jsxs)(on,{showCloseButton:!1,className:`w-[min(100%,31rem)] max-w-none gap-0 overflow-hidden rounded-2xl border-border bg-[var(--surface-elevated)] p-0 sm:w-[min(calc(100%-3rem),44rem)] lg:w-[min(calc(100%-4rem),74rem)]`,containerClassName:`fixed inset-0 z-50 flex items-end justify-center px-0 pt-8 sm:items-center sm:p-6`,children:[y,S,T]}),t[32]=S,t[33]=T,t[34]=y,t[35]=E):E=t[35];let D;return t[36]!==u||t[37]!==E||t[38]!==p?(D=(0,$.jsx)(ln,{open:u,onOpenChange:p,children:E}),t[36]=u,t[37]=E,t[38]=p,t[39]=D):D=t[39],D},Uc=me(`YuriNativeHeader`),Wc=`header.yuri-mobile-detail-navigation, header.yuri-mobile-header`,Gc=`yuri-native-header-source`,Kc=`yuri-native-header-ready`,qc=new Set([Kc,`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-hide`,`yuri-kb-caret-hold`]),Jc=`--yuri-native-viewport-top`,Yc=`.fixed, [role="dialog"]`,Xc=new Set([`style`,`data-yuri-header-collapse-phase`,`data-yuri-header-collapse-rest`]),Zc=()=>parseFloat(document.documentElement.style.getPropertyValue(`--yuri-native-viewport-top`))||0,Qc=`[data-avatar-motion]`,$c=new Set([`class`,`style`,`inert`,`aria-hidden`,`hidden`]),el=e=>{if(e.querySelector(`input, textarea, select, [contenteditable]:not([contenteditable="false"])`)||e.getClientRects().length===0||e.offsetHeight<=0||e.closest(`[inert],[aria-hidden="true"]`))return!1;let t=e.parentElement;if(!t||(typeof t.checkVisibility==`function`?!t.checkVisibility({visibilityProperty:!0,contentVisibilityAuto:!0,opacityProperty:!0}):getComputedStyle(t).visibility===`hidden`))return!1;let n=e.getBoundingClientRect().top-Zc();return e.dataset.yuriCollapsibleHeader===`true`||Math.abs(n)<=1},tl=(e,t)=>{let n=[...document.querySelectorAll(Wc)].filter(el);if(t&&e&&n.includes(e))return e;for(let e of n){let t=e.getBoundingClientRect(),n=document.elementFromPoint(t.left+t.width/2,t.bottom-4);if(n&&e.contains(n))return e}return n.at(-1)??null},nl=()=>{let e=[];for(let t of document.styleSheets)try{for(let n of t.cssRules)e.push(n.cssText)}catch{}return e.join(`
|
|
12
|
+
`)},rl=()=>{let e=0;for(let t of document.styleSheets)try{e+=t.cssRules.length}catch{}return`${document.styleSheets.length}:${e}`},il=Uc,al=()=>new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e(1)))});function ol(){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(Kc),u&&(u=!1,o=``,Uc.update({seq:++r,visible:!1}).catch(()=>void 0))},h=()=>{if(i=0,n)return;let t=tl(a,d);if(t!==a){if(a?.classList.remove(Gc),m(),a=t,l=``,!t)return;t.classList.add(Gc),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(Yc)===null?Math.ceil(Math.max(h,g)*f):_,y=(h+2*(parseFloat(getComputedStyle(e).fontSize)||16))*f,b=t.cloneNode(!0);b.classList.remove(Gc),b.style.removeProperty(fn),delete b.dataset.yuriHeaderCollapsePhase,delete b.dataset.yuriHeaderCollapseRest;for(let e of b.querySelectorAll(Yc))e.style.display=`none`;let x=b.outerHTML,S=[...e.classList].filter(e=>!qc.has(e)).join(` `),C=(e.getAttribute(`style`)??``).replace(RegExp(`${Jc}\\s*:[^;]*;?`,`g`),``),w=document.body.className,T=`${x}|${S}|${C}|${w}|${v}|${y}`,E=rl(),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=nl()),D!==c&&(c=D,O.sprite=D),u=!0,Uc.update(O).catch(()=>void 0)},g=()=>{!i&&!n&&(i=requestAnimationFrame(h))};f.push(Uc.addListener(`shown`,t=>{d&&t.seq===r&&a&&e.classList.add(Kc)})),f.push(Uc.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`&&Xc.has(n.attributeName??``)){p();continue}let e=n.target instanceof Element?n.target:n.target.parentElement;if(!(e?.closest(Qc)&&a.contains(e))){if(a.contains(n.target)||n.type===`attributes`&&n.target.contains(a))t=!0;else if(n.type===`attributes`&&$c.has(n.attributeName??``)&&n.target instanceof Element&&n.target.querySelector(Wc))t=!0;else if(n.type===`childList`)for(let e of n.addedNodes)e instanceof Element&&(e.matches(Wc)||e.querySelector(Wc))&&(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(()=>{s=``,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(Jc,`${Math.max(0,t)}px`),al());let b=window;return b.__yuriNativeHeader=t=>(d=t,e.classList.toggle(Kc,t&&a!==null),al()),()=>{n=!0,delete b.__yuriNativeHeader,i&&cancelAnimationFrame(i),_.disconnect(),v.disconnect(),y.disconnect(),window.removeEventListener(`resize`,g),delete t.__yuriImeOffset,e.classList.remove(Kc),a?.classList.remove(Gc),a=null;for(let e of f)e.then(e=>e.remove()).catch(()=>void 0);Uc.update({seq:++r,visible:!1}).catch(()=>void 0)}}var sl=`.yuri-mobile-composer`,cl=`[data-btw-composer]`;function ll(e,t){if(!e)return!1;let n=t;return!n||typeof n.closest!=`function`||!n.closest(cl)}function ul(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(sl)}function dl(e){return ul(e??null)}var fl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),pl=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},ml=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},hl=(e,t)=>t?`${e}\u0000staged`:e,gl=({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}=Ai(),p=ni(),m=s?p??null:fl(p??null),h=qn(m||null),g=pn(m||null),_=On(m||null),v=An(e=>e.setActiveDirectory),y=An(e=>e.ensureAll),b=An(e=>e.fetchStatus),x=An(e=>e.fetchBranches),S=An(e=>e.prefetchDiffs),C=An(e=>e.getDiff),w=An(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([]),[H,ne]=Z.useState([]),[U,re]=Z.useState(null),[W,ie]=Z.useState({key:null,loading:!1,error:null,resolved:!1}),[ae,oe]=Z.useState(0),se=Z.useRef({key:null,generation:0}),[ce,le]=Z.useState(!1),ue=Ta(h)&&!ce,G=Z.useMemo(()=>{let e=h?.files??[];if(ue)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,ue]),de=Z.useMemo(()=>G.filter(pl),[G]),K=Z.useMemo(()=>G.filter(ml),[G]),{deferredStagedCount:fe,deferredUnstagedCount:pe}=Z.useMemo(()=>{if(!ue||!h)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of h.files??[])pl(n)&&(e+=1),ml(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[ue,h]),me=Z.useMemo(()=>{if(H.length>0)return H;let e=h?.tracking?.includes(`/`)?h.tracking.split(`/`)[0]:null;return e||U?[{name:e||`origin`,fetchUrl:U??``,pushUrl:U??``}]:[]},[U,H,h?.tracking]),he=Z.useMemo(()=>e=>!m||T.type!==`diff`?null:e.directories.get(m)?.diffCache.get(hl(T.path,T.staged))??null,[m,T]),ge=An(he),_e=Z.useMemo(()=>T.type===`diff`?G.find(e=>e.path===T.path)??null:null,[G,T]),ve=T.type===`diff`&&m?`${m}\u0000${hl(T.path,T.staged)}`:null,ye=W.key===ve,be=!!(ve&&!ge&&(!ye||W.loading)),xe=ye?W.error:null,Se=!!(_e||ye&&W.resolved),Ce=q(async(e,t=!0)=>{try{await Promise.all([b(e,o),x(e,o)])}catch(e){t&&J.error(e instanceof Error?e.message:a(`gitView.toast.refreshRepositoryFailed`))}}),we=q(async(e,t,n)=>{let r=()=>se.current.key===t&&se.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;ne(t),re(n)}catch{if(!r())return;ne([]),re(null)}}),Te=q(e=>{if(e!==m)return{requestGeneration:null,promise:Promise.resolve()};let t=se.current.generation+1;return se.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){se.current={key:null,generation:se.current.generation+1},ne([]),re(null);return}let{requestGeneration:e,promise:t}=Te(m);return()=>{e!==null&&se.current.key===m&&se.current.generation===e&&(se.current={key:m,generation:e+1})}},[m,o,Te]),Z.useEffect(()=>{if(!m||G.length===0)return;let e=Array.from(new Set([...de.map(e=>e.path),...V,...G.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)},[G,m,o,S,de,V]),Z.useEffect(()=>{if(T.type!==`diff`){ie({key:null,loading:!1,error:null,resolved:!1});return}let e=hl(T.path,T.staged);if(!m||!ve){ie({key:null,loading:!1,error:null,resolved:!1});return}if(C(m,e)){ie(e=>({key:ve,loading:!1,error:null,resolved:e.key===ve&&e.resolved||!!_e}));return}let t=!1;return ie({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}),ie(e=>e.key===ve?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||ie(t=>t.key===ve?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[ve,m,ae,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}),J.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){J.error(a(`gitView.toast.commitOrStashBeforeSync`));return}await o.gitPull(n,r(t))}((await o.getGitStatus(n)).ahead??0)>0&&await o.gitPush(n),J.success(a(`gitView.toast.alreadyUpToDate`))}await Ce(n,!1),await Te(n).promise}catch(e){J.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{k(null)}},Oe=q(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){J.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),ke=q((e,t=!1)=>{E({type:`diff`,path:e,staged:t,targetLine:null})}),Ae=q(()=>T.type===`diff`&&(E({type:`list`}),!0));Lr({id:`mobile-changes-diff`,active:T.type===`diff`&&!i,layer:`overlay`,onBack:Ae,surfaceRef:D});let je=q(async e=>{if(!m)return;let t=m;F(t=>new Set(t).add(e));try{await o.revertGitFile(t,e),J.success(a(`gitView.toast.revertedFile`,{path:e})),await Ce(t,!1)}catch(e){J.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{F(t=>{let n=new Set(t);return n.delete(e),n})}}),Me=q(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),J.success(n.length===1?a(`gitView.toast.revertedFilesSingle`,{count:n.length}):a(`gitView.toast.revertedFilesPlural`,{count:n.length}))}catch(e){J.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{F(new Set),L(!1)}}),Ne=q(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){B([]);return}N(e=>`${e.trim()}${e.trim()?`
|
|
13
|
+
|
|
14
|
+
`:``}${t.join(`
|
|
15
|
+
`)}`.trim()),B([])}),Pe=q(async()=>{if(!m)return;let e=m,t=de.map(e=>e.path).sort();if(t.length===0){J.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){J.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()){J.error(a(`gitView.toast.enterCommitMessage`));return}let n=de.map(e=>e.path).sort();if(n.length===0){J.error(a(`gitView.toast.selectFileToCommit`));return}j(e.pushAfter?`commitAndPush`:`commit`);try{if(await o.createGitCommit(t,M.trim(),{files:n}),J.success(a(`gitView.toast.commitCreated`)),N(``),B([]),e.pushAfter){let e=h?.tracking?.split(`/`)[0],n=me.find(t=>t.name===e)??me[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){J.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{j(null),e.pushAfter&&k(null)}},Ie=Z.useMemo(()=>{let e=[];return de.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:de,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}),K.length>0&&e.push({id:`unstaged`,title:a(`gitView.changes.title`),entries:K,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,de,a,K]),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)(_l,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):g===!1?Le((0,$.jsx)(_l,{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)(vl,{path:T.path,directory:m,diff:ge,fileExists:Se,error:xe,loading:be,targetLine:T.targetLine,onBack:Ae,onRetry:()=>oe(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:me,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})]}),ue?(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Fi,{stagedCount:fe,unstagedCount:pe,onLoad:()=>le(!0)})}):G.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)($i,{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)(Li,{stagedCount:de.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)(_l,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):Le((0,$.jsx)(_l,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},_l=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},vl=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=Qt(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)(Y,{variant:`ghost`,size:`icon`,title:p(`diffView.actions.openFilePreview`),"aria-label":p(`diffView.actions.openFilePreview`),onClick:()=>m.openFile({path:de(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)(Sr,{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)(Y,{type:`button`,size:`sm`,variant:`outline`,onClick:u,children:p(`diffView.actions.retry`)})]})}):s?(0,$.jsx)(_l,{loading:!0,message:p(`diffView.state.loadingDiff`)}):a?i?i.isBinary?(0,$.jsx)(_l,{icon:!0,message:p(`diffView.binary.unavailable`)}):$t(n)?(0,$.jsx)(_l,{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)(ga,{original:i.original,modified:i.modified,language:g,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:c,layout:`inline`})}):(0,$.jsx)(_l,{loading:!0,message:p(`diffView.state.loadingDiff`)}):(0,$.jsx)(_l,{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},yl=e(C(),1),bl=_r(()=>ge(()=>import(`./ToolOutputDialog-2F74CchZ.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]))),xl=25e4,Sl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Cl=e=>{let t=Sl(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},wl=e=>{let t=Sl(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},Tl=(e,t)=>{let n=Sl(e),r=Sl(t);return!r||n===r?Cl(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},El=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``},Dl=e=>/\.(md|mdx|markdown)$/i.test(e),Ol=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=Sl(d),t[0]=d,t[1]=f);let p=f,m;t[2]!==o||t[3]!==p?(m=()=>{let e=Sl(o);return e?{type:`file`,path:e,returnDirectory:wl(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(Il),x=_e(Ll),S,C;t[5]===p?(S=t[6],C=t[7]):(S=()=>{p&&g(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:wl(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=Sl(b);if(!e){x(null);return}y(``),g({type:`file`,path:e,returnDirectory:wl(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=kr(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=U(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),H;t[28]===te?H=t[29]:(H={enabled:te},t[28]=te,t[29]=H);let ne=ue(V,H),re;t[30]===O?re=t[31]:(re=O&&(!$t(O)||O.toLowerCase().endsWith(`.svg`)),t[30]=O,t[31]=re);let W=!!re,ie;t[32]!==O||t[33]!==p?(ie={scopeDirectory:p,path:O},t[32]=O,t[33]=p,t[34]=ie):ie=t[34];let se;t[35]===W?se=t[36]:(se={enabled:W},t[35]=W,t[36]=se);let ce=oe(ie,se),le=W&&ce.data?.isBinary===!0,G;t[37]!==O||t[38]!==ce.data||t[39]!==ce.error||t[40]!==ce.isFetchedAfterMount||t[41]!==u||t[42]!==k||t[43]!==le?(G=O&&u.readFile&&ce.data&&ce.isFetchedAfterMount&&!ce.error&&!le&&(!tn(O)||k===`source`)&&(!$t(O)||O.toLowerCase().endsWith(`.svg`)),t[37]=O,t[38]=ce.data,t[39]=ce.error,t[40]=ce.isFetchedAfterMount,t[41]=u,t[42]=k,t[43]=le,t[44]=G):G=t[44];let de=!!G,K;t[45]!==O||t[46]!==p?(K={scopeDirectory:p,path:O},t[45]=O,t[46]=p,t[47]=K):K=t[47];let fe;t[48]===de?fe=t[49]:(fe={enabled:de},t[48]=de,t[49]=fe);let pe=ae(K,fe),me=B.data?.entries.slice().sort(Rl)??[],he;t[50]!==B.error||t[51]!==l?(he=B.error?B.error instanceof Error?B.error.message:l(`mobile.files.error.listFailed`):null,t[50]=B.error,t[51]=l,t[52]=he):he=t[52];let ge=he,ve=B.isFetching,ye;t[53]===ne.data?ye=t[54]:(ye=ne.data??[],t[53]=ne.data,t[54]=ye);let be=ye,xe=!!(F&&L&&v===N&&ne.isFetching),Se;t[55]!==pe.data||t[56]!==l?(Se=pe.data&&pe.data.length>xl?`${pe.data.slice(0,xl)}\n\n${l(`mobile.files.file.truncated`)}`:pe.data??``,t[55]=pe.data,t[56]=l,t[57]=Se):Se=t[57];let Ce=Se,we=ce.error??pe.error,Te;t[58]!==u||t[59]!==le||t[60]!==W||t[61]!==we||t[62]!==l?(Te=W&&(!u.statFile||!le&&!u.readFile)?l(`mobile.files.error.readUnavailable`):we?we instanceof Error?we.message:l(`filesView.error.readFileFailed`):null,t[58]=u,t[59]=le,t[60]=W,t[61]=we,t[62]=l,t[63]=Te):Te=t[63];let De=Te,Oe=!De&&(W&&(!ce.data||!ce.isFetchedAfterMount)||de&&pe.isFetching&&pe.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=q(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],Lr(Ie);let Le;t[76]===l?Le=t[77]:(Le=async e=>{(await lt(e)).ok||J.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 lt(Ce)).ok?J.success(l(`mobile.files.toast.contentCopied`)):J.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)(Fl,{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]!==le||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)(Ml,{path:h.path,content:Ce,error:De,isLoading:Oe,isBinary:le,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]=le,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`):Cl(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=wl(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:Cl(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 Qe;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Qe={touchAction:`manipulation`},t[126]=Qe):Qe=t[126];let Y=ve&&`animate-spin`,$e;t[127]===Y?$e=t[128]:($e=ot(`size-5`,Y),t[127]=Y,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:Qe,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 it;t[142]===Symbol.for(`react.memo_cache_sentinel`)?(it=e=>y(e.target.value),t[142]=it):it=t[142];let at;t[143]===l?at=t[144]:(at=l(`mobile.files.search.placeholder`),t[143]=l,t[144]=at);let st;t[145]!==v||t[146]!==at?(st=(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)(Xn,{type:`text`,inputMode:`search`,value:v,onChange:it,placeholder:at,className:`h-11 pl-9`})]})}),t[145]=v,t[146]=at,t[147]=st):st=t[147];let ct=Kr,ut=ge?(0,$.jsx)(Fl,{message:ge}):v.trim()?(0,$.jsx)(Al,{results:We,isSearching:xe,onOpenFile:Me}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[me.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,me.map(e=>(0,$.jsx)(kl,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:El(e.size),onClick:()=>e.isDirectory?Ae(e.path):Me(e.path)},e.path))]}),dt;t[148]!==ct||t[149]!==ut?(dt=(0,$.jsx)(ct,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:ut}),t[148]=ct,t[149]=ut,t[150]=dt):dt=t[150];let ft;return t[151]!==Je||t[152]!==nt||t[153]!==st||t[154]!==dt?(ft=(0,$.jsxs)(`div`,{className:Je,children:[nt,st,dt]}),t[151]=Je,t[152]=nt,t[153]=st,t[154]=dt,t[155]=ft):ft=t[155],ft},kl=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)(un,{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},Al=e=>{let t=(0,Q.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=Ee(),o=Sl(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)(Fl,{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)(Fl,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(kl,{name:Cl(e.path),path:e.path,directory:!1,meta:Tl(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},jl=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=tn(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)(Y,{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)(Y,{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&&!$t(n)&&!f?(0,$.jsx)(Y,{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||$t(n)||f?(0,$.jsx)(Y,{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},Ml=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(),_=$t(n)&&!n.toLowerCase().endsWith(`.svg`)?n:``,v;t[0]===n?v=t[1]:(v=wl(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=Cl(n),t[3]=n,t[4]=E);let D=E,O;t[5]!==r||t[6]!==n?(O=$t(n)?`data:${en(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||($t(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=q(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:en(n)},image:{url:t,mimeType:en(n),filename:D}})},t[21]=D,t[22]=_,t[23]=n,t[24]=j,t[25]=I):I=t[25];let L=q(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=q(R),z;t[27]===n?z=t[28]:(z=tn(n),t[27]=n,t[28]=z);let B=z,[V,te]=Z.useState(!1),H=Z.useRef(null),ne;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(ne=()=>{te(!1)},t[29]=ne):ne=t[29];let U;t[30]===n?U=t[31]:(U=[n],t[30]=n,t[31]=U),Z.useEffect(ne,U);let re;t[32]!==c||t[33]!==l?(re=()=>{l(c===`preview`?`source`:`preview`)},t[32]=c,t[33]=l,t[34]=re):re=t[34];let W=q(re),ie;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>{te(!0)},t[35]=ie):ie=t[35];let ae=q(ie),oe;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>(te(!1),!0),t[36]=oe):oe=t[36];let se=q(oe),ce=B&&V,le;t[37]!==se||t[38]!==ce?(le={id:`mobile-html-fullscreen`,active:ce,layer:`overlay`,onBack:se,surfaceRef:H},t[37]=se,t[38]=ce,t[39]=le):le=t[39],Lr(le);let ue=!o&&!a&&!i,G;t[40]!==ae||t[41]!==V||t[42]!==c||t[43]!==f||t[44]!==d||t[45]!==n||t[46]!==ue||t[47]!==W?(G=(0,$.jsx)(jl,{path:n,canUseText:ue,htmlViewMode:c,htmlFullscreen:V,onToggleHtmlViewMode:W,onEnterHtmlFullscreen:ae,onCopyPath:d,onCopyContent:f}),t[40]=ae,t[41]=V,t[42]=c,t[43]=f,t[44]=d,t[45]=n,t[46]=ue,t[47]=W,t[48]=G):G=t[48];let de=G,K;t[49]!==r||t[50]!==i||t[51]!==c||t[52]!==a||t[53]!==n||t[54]!==m?(K=c===`source`?a?(0,$.jsx)(Fl,{loading:!0,message:m(`filesView.state.loading`)}):i?(0,$.jsx)(Ya,{message:i}):(0,$.jsx)(Pl,{path:n,content:r}):(0,$.jsx)(Nl,{path:n}),t[49]=r,t[50]=i,t[51]=c,t[52]=a,t[53]=n,t[54]=m,t[55]=K):K=t[55];let fe=K,pe;t[56]!==se||t[57]!==B||t[58]!==fe||t[59]!==V||t[60]!==c||t[61]!==D||t[62]!==m||t[63]!==W?(pe=B?(0,$.jsxs)(`div`,{ref:H,"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)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:se,"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)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:W,"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:fe})]}):null,t[56]=se,t[57]=B,t[58]=fe,t[59]=V,t[60]=c,t[61]=D,t[62]=m,t[63]=W,t[64]=pe):pe=t[64];let me=pe,he=g??void 0,ge;t[65]!==r||t[66]!==i||t[67]!==de||t[68]!==F||t[69]!==ee||t[70]!==p||t[71]!==B||t[72]!==V||t[73]!==me||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)(Sr,{children:[s,de]}):(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,de]}),(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)(xi,{path:n},n):B&&!a&&!i?V&&typeof document<`u`?(0,yl.createPortal)(me,document.body):me:a||y.loading?$t(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)(Fl,{loading:!0,message:m(`filesView.state.loading`)}):N?(0,$.jsx)(Ya,{message:N}):$t(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)(Pl,{path:n,content:r}))}),(0,$.jsx)(Tn,{containerRef:h}),C.open?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(bl,{popup:C,onOpenChange:ee,isMobile:!0})}):null]})},t[65]=r,t[66]=i,t[67]=de,t[68]=F,t[69]=ee,t[70]=p,t[71]=B,t[72]=V,t[73]=me,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]!==he||t[88]!==ge?(_e=(0,$.jsx)(Xi,{path:n,base:he,children:ge}),t[86]=n,t[87]=he,t[88]=ge,t[89]=_e):_e=t[89],_e},Nl=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)(Mi,{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},Pl=e=>{let t=(0,Q.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=nn(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??hr(!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)??hr(!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=()=>{Ir(l),Ir(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(Dl(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)(vr,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=Cl(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=Qt(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:Bi},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},Fl=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 Il(e){return e.pendingFileFocusPath}function Ll(e){return e.setPendingFileFocusPath}function Rl(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}var zl=S(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),Bl=36,Vl=18,Hl=e=>e.parentID??null,Ul=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Wl=e=>{let t=e;return Ul(t.directory??t.project?.worktree??null)},Gl=e=>{let t=Ul(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},Kl=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},ql=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),Jl=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))},Yl=(e,t)=>{let n=Ul(e),r=Ul(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},Xl=(e,t)=>e.worktrees.find(e=>Ul(e.path)===t)??null,Zl=(e,t)=>t===e.path||!!Xl(e,t),Ql=(e,t)=>{let n=Ul(t);return n?e.find(e=>Zl(e,n))??null:null},$l=(e,t,n)=>!n||`${e.title??``} ${e.id} ${Wl(e)} ${t}`.toLowerCase().includes(n),eu=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=ot(`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},tu=e=>{let t=(0,Q.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=ot(`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},nu=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},ru=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=ot(`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},iu=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)(Y,{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},au=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=Jl(Kl(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=ot(`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:ot(`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=ot(`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=ot(`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=ot(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),I=g?sr(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 H;t[66]!==a||t[67]!==g?(H=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?sr(a,g):a}):null,t[66]=a,t[67]=g,t[68]=H):H=t[68];let ne;t[69]!==te||t[70]!==H||t[71]!==ee?(ne=(0,$.jsxs)(`span`,{className:ee,children:[te,H]}),t[69]=te,t[70]=H,t[71]=ee,t[72]=ne):ne=t[72];let U;t[73]!==C||t[74]!==w||t[75]!==T||t[76]!==E||t[77]!==D||t[78]!==O||t[79]!==k||t[80]!==A||t[81]!==j||t[82]!==M||t[83]!==ne?(U=(0,$.jsx)(`button`,{type:C,className:w,style:T,onClick:E,onPointerDown:D,onPointerMove:O,onPointerUp:k,onPointerCancel:A,onContextMenu:j,disabled:M,children:ne}),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]=ne,t[84]=U):U=t[84];let re;t[85]!==p||t[86]!==m?(re=p?(0,$.jsx)(`button`,{type:`button`,className:`mr-0.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":m,onClick:e=>{e.stopPropagation(),p()},style:{touchAction:`manipulation`},children:(0,$.jsx)(Fa,{})}):null,t[85]=p,t[86]=m,t[87]=re):re=t[87];let W;t[88]===b?W=t[89]:(W=b(`sessions.sidebar.session.menu.label`),t[88]=b,t[89]=W);let ie;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(X,{name:`more-2`,className:`size-4`}),t[90]=ie):ie=t[90];let ae;t[91]!==h.onOpenActions||t[92]!==W?(ae=(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,"data-session-drag-ignore":!0,"aria-label":W,onClick:h.onOpenActions,children:ie}),t[91]=h.onOpenActions,t[92]=W,t[93]=ae):ae=t[93];let oe;t[94]!==_||t[95]!==f||t[96]!==d||t[97]!==b||t[98]!==z?(oe=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]=oe):oe=t[99];let se;return t[100]!==N||t[101]!==P||t[102]!==U||t[103]!==re||t[104]!==ae||t[105]!==oe?(se=(0,$.jsxs)(`div`,{className:N,children:[P,U,re,ae,oe]}),t[100]=N,t[101]=P,t[102]=U,t[103]=re,t[104]=ae,t[105]=oe,t[106]=se):se=t[106],se},ou=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:ot(`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},su=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=Ee(),{git:i}=se(),a=bt(),o=at(),s=zt(e=>e.activeSessions),c=zt(e=>e.activePaginationByDirectory),l=Qe(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=Qe(e=>e.activeProjectId),h=O(e=>e.currentDirectory),g=Et(e=>e.currentSessionId),_=Et(e=>e.availableWorktreesByProject),v=Et(e=>e.setCurrentSession),y=Et(e=>e.archiveSession),b=Et(e=>e.archiveSessions),x=Et(e=>e.updateSessionTitle),S=Et(e=>e.requestSessionSmartTitle),C=Et(e=>e.shareSession),w=Et(e=>e.unshareSession),T=Et(e=>e.openNewSessionDraft),E=Qe(e=>e.setActiveProject),D=Qe(e=>e.setActiveProjectIdOnly),k=Qe(e=>e.removeProject),A=Rt();La();let j=wt(e=>e.sessionOrderByScope),M=wt(e=>e.sessionOrderActivityByScope),N=st(),P=Ni(e=>e.projectExpanded),F=Ni(e=>e.worktreeExpanded),I=Ni(e=>e.setProjectExpanded),L=Ni(e=>e.setWorktreeExpanded),R=tt(e=>e.orderByProject),ee=zl(e=>e.expandedParents),z=zl(e=>e.toggleParent),[B,V]=Z.useState(``),[te,H]=Z.useState(null),[ne,U]=Z.useState(null),[re,W]=Z.useState(0),[ie,ae]=Z.useState(!1),[oe,ce]=Z.useState(!1),[le,ue]=Z.useState(null),[G,de]=Z.useState(null),K=G?.kind===`session`?G.session:null,{unread:fe,onToggleRead:pe}=ia(K,K?Wl(K):void 0),[me,he]=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||=pa({onPressedKeyChange:_e});let[Oe,ke]=Z.useState(new Set),[Ae,je]=Z.useState(new Map),[Me,Ne]=Z.useState(new Map),Pe=Oi(),Fe=Ji(),Ie=q(e=>{Vr(e),it(e)}),Le=q(e=>{Promise.all(e.map(e=>(Vr(e),it(e))))});Z.useEffect(()=>{if(!e){V(``),Ne(new Map),H(null),U(null),de(null),ye(null),Te(null),De.current?.reset();return}},[e]),Z.useEffect(()=>()=>{De.current?.reset()},[]),Z.useEffect(()=>{if(!e)return;if(u.length===0){Et.setState(e=>{let t=da(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=Ul(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=>Ul(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);Et.setState(e=>{let t=da(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 ql(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,re]);let Re=Z.useMemo(()=>u.map(e=>({id:e.id,label:Gl(e.path),path:Ul(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:Oe.has(Ul(e.path)),worktrees:We(R[e.id],_.get(Ul(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?Dt(n,t):t}),n=new Set(t.map(e=>e.id));for(let e of o)n.has(e.id)||t.push(e);return t},[s,o]),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=Ul(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||Gl(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=Wl(n);if(!r)continue;let i=Ul(r),a=e.find(e=>Zl(e.project,i));if(!a)continue;let o=Xl(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=Ul(e.path),r=Ia(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)Hl(n)||(t.totalSessions+=1)}return e},[m,Re,ze,j,M,A]),He=Ul(h),Ue=e=>e.isActive?He===e.project.path?e.project.path:e.project.worktrees.find(e=>Yl(He,e.path))?.path??e.project.path:null,Ge=e=>P[e.project.id]??!0,Ke=(e,t)=>F[`${e.project.id}::${t.key}`]??!1,qe=e=>{Ne(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},Je=()=>{de(null),De.current?.reset()},Ye=e=>({onOpenActions:()=>de(e),pressed:ge===e.key||G?.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:()=>de(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,()=>de(e))}}),Xe=(e,t)=>{De.current?.consumeClick(e)||t()},Ze=(e,t,n,r)=>{let i=Pa(),a=la();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=Ul(t);if(!o)return;let s=zt.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&ht(o)},$e=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=Pa(),o=new Set(t.sessions.map(e=>e.id)),s=new Map;for(let e of t.sessions){let t=Hl(e);if(t&&o.has(t)){let n=s.get(t)??[];n.push(e),s.set(t,n)}}let l=t.sessions.filter(e=>!Hl(e)),u=Me.get(i)??a,d=Ki(l,u,Fe),f=l.length-d.length,p=c.get(Ul(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)(au,{session:e,active:g===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>z(e.id):void 0,confirmingArchive:ne===e.id,onSelect:()=>Xe(f,()=>rt(e)),onRequestArchive:()=>ct(e.id),onConfirmArchive:()=>void dt(e),onStop:o||l?()=>Le(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:d}),longPressHandlers:Ye({key:f,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+Vl)):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)(Wi,{scopeKey:ne?null:Ul(t.path),sessionIds:d.map(e=>e.id),folderIdBySessionId:new Map(d.map(e=>[e.id,wt.getState().getSessionFolderId(Ul(t.path),e.id)])),onSessionDroppedOnFolder:()=>{},onSessionsReordered:(e,n)=>{wt.getState().reorderSessions(Ul(t.path),d.map(e=>e.id),e,n,wi(t.sessions)).catch(()=>J.error(r(`sessions.order.saveFailed`)))},children:d.map(e=>ne?v(e,n):(0,$.jsx)(Ri,{sessionId:e.id,sessionDirectory:t.path,sessionTitle:e.title??``,children:v(e,n)},e.id))}),(0,$.jsx)(ou,{indent:n,showMore:f>0||m,showFewer:_,loadingMore:h,onShowMore:()=>Ze(i,t.path,u,l.length),onShowFewer:()=>qe(i)})]})},et=(e,t)=>{I(e,!t)},nt=(e,t,n)=>{L(`${e}::${t}`,!n)},rt=e=>{br();let n=Wl(e)||null,r=Ql(Re,n??``);r&&D(r.id),v(e.id,n),t(!1)},ct=e=>{U(t=>t===e?null:e)},dt=async e=>{U(null),await y(e.id)?na({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`)}):J.error(r(`sessions.sidebar.session.archive.error`))},ft=()=>{T(),t(!1)},pt=e=>{ue(e),D(e),ce(!0)},mt=e=>{let t=new Map;for(let e of ze){let n=Hl(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},gt=async e=>{let t=mt(e.id),{archivedIds:n,failedIds:i}=await b(t);n.length>0&&na({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&&J.error(i.length===1?r(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):r(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}))},_t=e=>{let t=mt(e.id);fa({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){J.error(r(`sessions.sidebar.session.share.error`));return}J.success(r(`sessions.sidebar.session.share.successTitle`),{description:r(`sessions.sidebar.session.share.successDescription`)})}catch{J.error(r(`sessions.sidebar.session.share.error`))}},yt=async e=>{if((await lt(e)).ok){J.success(r(`sessions.sidebar.session.menu.copied`));return}J.error(r(`sessions.sidebar.session.share.copyUrlError`))},xt=async e=>{try{if(await w(e)){J.success(r(`sessions.sidebar.session.unshare.success`));return}J.error(r(`sessions.sidebar.session.unshare.error`))}catch{J.error(r(`sessions.sidebar.session.unshare.error`))}},St=async()=>{if(!ve)return;let e=be.trim();if(e)try{await x(ve.id,e),ye(null),xe(``)}catch{J.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},Ct=async()=>{if(!ve||Se)return;let e=ve.id;ye(null),xe(``),Ce(!0);try{await S(e)}catch{J.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{Ce(!1)}},Tt=(e,n)=>{D(e.id),T({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},Ot=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=Et.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await Ft(n,ze)})()},kt=e=>{let t=Wl(e),n=Ql(Re,t);if(!n)return Gl(t)||t;let r=Xl(n,Ul(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=>$l(t,e.project.label,Be)))):Ve,[Be,Ve]),Mt=Z.useMemo(()=>Be?ze.filter(e=>{let t=Wl(e);return $l(e,Ql(Re,t)?.label??``,Be)}).sort((e,t)=>ut(t)-ut(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=>!Hl(t)&&Zl(e,Ul(Wl(t)))).length})):[],[Be,Re,ze]),Pt=Be&&Mt.length===0&&Nt.length===0,It=Re.length>0?(0,$.jsxs)(Y,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:ft,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,Lt=Re.find(e=>e.id===m)??null,Bt=Lt?.isGitRepo?(0,$.jsx)(Y,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>pt(Lt.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`node-tree`,className:`size-4`})}):null,Vt=(0,$.jsx)(Y,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>ae(!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=G?.kind===`project`?G.project.label:G?.kind===`worktree`?G.worktree.branch||G.worktree.label||G.worktree.path:G?.kind===`session`?G.session.title?.trim()||r(`mobile.sessions.untitled`):``,Wt=Z.useMemo(()=>{if(!G)return[];if(G.kind===`project`){let e=G.project;return Ca({gitRepository:e.isGitRepo,onNewSession:()=>{Je(),Tt(e,e.path)},onNewWorktree:()=>{Je(),pt(e.id)},onSyncSessions:()=>{Je(),Ot(e)},onEditProject:()=>{Je(),H(e.id)},onCloseProject:()=>{Je(),he(e)}})}if(G.kind===`worktree`){let{project:e,worktree:t}=G;return sa({onNewSession:()=>{Je(),Tt(e,t.path)},onDeleteWorktree:()=>{Je(),Te({project:e,worktree:t})}})}let e=G.session,t=!!e.share?.url;return Aa({pinned:A.has(e.id),shared:t,unread:fe,onToggleRead:pe?()=>{Je(),pe()}:void 0,onRename:()=>{Je(),xe(e.title?.trim()||r(`mobile.sessions.untitled`)),ye(e)},onTogglePin:()=>{Je(),N(e.id)},onShare:!a||t?void 0:()=>{Je(),vt(e)},onCopyLink:a&&t?()=>{let t=e.share?.url;Je(),t&&yt(t)}:void 0,onUnshare:a&&t?()=>{Je(),xt(e.id)}:void 0,onArchive:()=>{Je(),gt(e)},onDelete:()=>{Je(),_t(e)}})},[G,fe,Je,gt,yt,_t,pt,vt,xt,pe,A,Tt,Ot,r,N]),Gt=Wt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Wt.map(e=>{let t=(0,$.jsx)(iu,{icon:e.icon,label:va(e,r),destructive:e.destructive,onClick:e.onClick},e.id);return e.separated?(0,$.jsx)(`div`,{className:G?.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)(Xn,{value:B,onChange:e=>V(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:ot(`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)(ra,{project:e,registry:f.registry,search:B,mobile:!0,reorderEnabled:!1},e.id)),Re.length===0&&!d?(0,$.jsx)(cu,{title:r(`mobile.sessions.empty.noProjectsTitle`),description:r(`mobile.sessions.empty.noProjectsDescription`),action:(0,$.jsxs)(Y,{type:`button`,size:`lg`,onClick:()=>ae(!0),children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):Pt&&!d?(0,$.jsx)(cu,{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:ot(t>0&&`border-t border-border/30`),children:(0,$.jsx)(au,{session:e,active:g===e.id,indent:12,contextLabel:kt(e),highlightQuery:Be,onSelect:()=>Xe(`session:${e.id}`,()=>rt(e)),longPressHandlers:Ye({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=Ye({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:ot(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:ot(`flex min-h-14 min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,r.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Xe(n,()=>At(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(eu,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:sr(e.label,Be)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(ru,{className:`mr-2`,onClick:()=>pt(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:jt.map((e,t)=>{let n=Ge(e),i=`project:${e.project.id}`,a=Ye({key:i,kind:`project`,project:e.project}),o=Be?e.buckets.filter(t=>t.sessions.some(t=>$l(t,e.project.label,Be))):e.buckets,s=Ue(e);return(0,$.jsxs)(`section`,{className:ot(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:ot(`flex min-h-14 min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,a.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Xe(i,()=>et(e.project.id,n)),onPointerDown:a.onPointerDown,onPointerMove:a.onPointerMove,onPointerUp:a.onPointerUp,onPointerCancel:a.onPointerCancel,onContextMenu:a.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:e.project.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)(eu,{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)(nu,{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)(Fa,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(ru,{className:`mr-2`,onClick:()=>pt(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)?$e(e,t,Bl):null,n.map(t=>{let n=Ke(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Ye({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:ot(`flex min-h-11 w-full items-center gap-2 py-1.5 pl-4 pr-3 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Xe(a,()=>nt(e.project.id,t.key,n)),onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onPointerCancel:o.onPointerCancel,onContextMenu:o.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:t.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)(tu,{expanded:n}),(0,$.jsx)(X,{name:`node-tree`,className:ot(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:ot(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(nu,{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)(Fa,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?$e(e,t,Bl):null]},t.key)})]})})()}):null]},e.project.id)})})]}),(0,$.jsx)(Hi,{open:ie,onOpenChange:ae,forceMobile:!0}),(0,$.jsx)(Hn,{open:oe,projectId:le,onOpenChange:e=>{ce(e),e||ue(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?v(n.sessionId,e):T({selectedProjectId:le,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(cr,{open:!!G,title:Ut,onClose:Je,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Gt}),(0,$.jsx)(cr,{open:!!me,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>he(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>he(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!me)return;let e=me;he(null),k(e.id),J.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:me?.label??``})})}),(0,$.jsx)(cr,{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)(Y,{type:`button`,variant:`default`,className:`flex-1`,disabled:Se,onClick:()=>{ye(null),xe(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{type:`button`,variant:`default`,className:`flex-1`,disabled:!be.trim()||Se,onClick:()=>void St(),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(),St()},children:[(0,$.jsx)(Xn,{value:be,onChange:e=>xe(e.target.value),autoFocus:!0,className:`h-12`,disabled:Se}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:Se,onClick:()=>void Ct(),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)(ya,{open:!0,project:{id:we.project.id,path:we.project.path},worktree:we.worktree,onClose:()=>Te(null),onDeleted:()=>W(e=>e+1)}):null,(0,$.jsx)(wa,{open:te!==null,project:Re.find(e=>e.id===te)??null,onClose:()=>H(null),onWorktreesChanged:()=>W(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)(wr,{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})},cu=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},lu=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,uu=[{image:Rc,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:Lc,titleKey:`assistants.guide.share.android.title`,descriptionKey:`assistants.guide.share.android.description`},{image:zc,titleKey:`assistants.guide.share.pick.title`,descriptionKey:`assistants.guide.share.pick.description`}];function du(){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 fu(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:lu,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)(Y,{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=uu.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 pu(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=Di(`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)(Ti,{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=ot(`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=ot(`yuri-mobile-assistant-summary`,ao),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)(Qa,{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)(no,{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 mu(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=$a(l),t[2]=l,t[3]=u);let d=u,f=Vt(hu),[p,m]=Z.useState(null),h;t[4]===n?h=t[5]:(h=()=>n(),t[4]=n,t[5]=h);let g=q(h),_;t[6]!==o||t[7]!==f?(_=()=>{f(),o?.openSettings(`assistants`)},t[6]=o,t[7]=f,t[8]=_):_=t[8];let v=q(_),y;t[9]===r?y=t[10]:(y=e=>r(e),t[9]=r,t[10]=y);let b=q(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=q(x),C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{m(e)},t[13]=C):C=t[13];let w=q(C),T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{e||m(null)},t[14]=T):T=t[14];let E=q(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=ot(`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)(du,{})}),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)(io,{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)(Y,{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)(oo,{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=ro(e.latestMessagePreview,a);return(0,$.jsx)(pu,{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)(to,{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)(Y,{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)(fu,{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 H;t[113]!==a||t[114]!==I||t[115]!==F?(H=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]=H):H=t[116];let ne;t[117]!==V||t[118]!==te||t[119]!==H?(ne=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[V,te,H]}),t[117]=V,t[118]=te,t[119]=H,t[120]=ne):ne=t[120];let U;t[121]!==z||t[122]!==ne?(U=(0,$.jsx)(mi,{label:z,cardClassName:`yuri-mobile-assistant-state-card`,children:ne}),t[121]=z,t[122]=ne,t[123]=U):U=t[123];let re;return t[124]!==P||t[125]!==O||t[126]!==U?(re=(0,$.jsx)(di,{title:O,className:P,surface:!1,surfaceClassName:`yuri-mobile-assistant-state`,children:U}),t[124]=P,t[125]=O,t[126]=U,t[127]=re):re=t[127],re}function hu(e){return e.requestCreate}function gu(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)(dr,{children:(0,$.jsx)(Ka,{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 _u(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:vu}),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)(jn,{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 vu(){Br.requestAnimatedBack(`root`)}var yu=[{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 bu(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=q(u),f;t[4]!==n||t[5]!==r?(f=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=yu.findIndex(e=>e.id===n),i=yu[e.key===`Home`?0:e.key===`End`?yu.length-1:(t+(e.key===`ArrowRight`?1:-1)+yu.length)%yu.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=q(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=yu.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)(Y,{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:ot(`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)(ma,{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)(eo,{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 xu(e){return e.unreadCount>0?`unread`:e.working?`loading`:null}var Su=`yuri-native-ios-tab-bar`,Cu=`YuriTabBar`,wu=[`projects`,`assistant`,`scheduled`,`settings`],Tu=me(Cu),Eu=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function Du(){return typeof window>`u`?!1:Eu({isCapacitor:g(),platform:y(),pluginAvailable:he.isPluginAvailable(Cu),nativeUiEnabled:Mr()})}var Ou=e=>e.classList.contains(`dark`)?`dark`:`light`,ku=()=>Pr(`--primary`),Au=e=>typeof e==`string`&&wu.includes(e),ju=e=>typeof e==`string`&&Au(e)?e:null,Mu=(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)),Nu=(e,t)=>{e.classList.toggle(Su,t)},Pu=(e,t)=>e&&!t,Fu=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&Mu(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},Iu=()=>Tu,Lu=`mobile-overlay-root`;function Ru(e){let t=(0,Q.c)(28),n=Nr(),r;t[0]===n?r=t[1]:(r=n&&Du(),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=q(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=JSON.stringify(e.tabs.map(Bu)),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:Ou(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:ku(),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(Lu);e||(e=document.createElement(`div`),e.id=Lu,document.body.appendChild(e));let t=()=>u(zn(e.children));t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[Rn]}),()=>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=Iu(),n=[];return t.addListener(`tabSelected`,e=>{let t=ju(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`&&Nu(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=Iu(),r={tabs:e.tabs.map(zu),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=Fu({visible:Pu(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`&&Nu(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&Nu(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&Nu(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 zu(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 Bu(e){return[e.id,e.label,e.badge??null,e.activity===!0,e.activity===!0?e.activityLabel??null:null]}function Vu(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=q(()=>h?.onBack());Lr({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=q(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=xu({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=xu({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=yu.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,H=u&&!d&&!h,ne;t[19]===f?ne=t[20]:(ne=f(`mobile.nav.aria`),t[19]=f,t[20]=ne);let U;t[21]!==M||t[22]!==H||t[23]!==te||t[24]!==p||t[25]!==ne?(U={visible:H,activeTab:p,tabs:te,ariaLabel:ne,onTabChange:M},t[21]=M,t[22]=H,t[23]=te,t[24]=p,t[25]=ne,t[26]=U):U=t[26];let re=Ru(U),W=re===`native`,ie=u&&re===`web`,ae=Nr(),oe,se;t[27]!==ae||t[28]!==W?(oe=()=>{if(!ae){zr.shutdown();return}W&&Fr(!0)&&zr.warm()},se=[ae,W],t[27]=ae,t[28]=W,t[29]=oe,t[30]=se):(oe=t[29],se=t[30]),Z.useEffect(oe,se);let ce=p===`assistant`&&`yuri-assistant-wallpaper`,le;t[31]!==c||t[32]!==ce?(le=ot(`yuri-mobile-floating-shell relative isolate flex h-full min-h-0 flex-col overflow-hidden text-foreground`,`bg-[var(--yuri-mobile-page-background)]`,ce,c),t[31]=c,t[32]=ce,t[33]=le):le=t[33];let ue=h?!0:void 0,G=h?!0:void 0,de=h?`true`:void 0,K;t[34]!==p||t[35]!==u||t[36]!==ie||t[37]!==f||t[38]!==n||t[39]!==b?(K=yu.map(e=>{let t=b.has(e.id);return(0,$.jsx)(`section`,{id:`mobile-tabpanel-${e.id}`,role:`tabpanel`,"aria-labelledby":ie?`mobile-tab-${e.id}`:void 0,"aria-label":ie?void 0:f(e.labelKey),hidden:p!==e.id,tabIndex:0,className:ot(`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)(Hu,{tab:e.id,icon:e.icon}):null},e.id)}),t[34]=p,t[35]=u,t[36]=ie,t[37]=f,t[38]=n,t[39]=b,t[40]=K):K=t[40];let fe=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||W?!0:void 0,inert:h||W?!0:void 0,children:ie?(0,$.jsx)(bu,{activeTab:p,onTabChange:M,tabMarks:{assistant:ee===`loading`?`loading`:null,scheduled:B===`loading`?`loading`:null}}):null}):null,pe;t[41]!==w||t[42]!==ue||t[43]!==G||t[44]!==de||t[45]!==K||t[46]!==fe?(pe=(0,$.jsxs)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":ue,inert:G,"data-mobile-navigation-parked":de,className:`flex h-full min-h-0 flex-1 flex-col`,children:[K,fe]}),t[41]=w,t[42]=ue,t[43]=G,t[44]=de,t[45]=K,t[46]=fe,t[47]=pe):pe=t[47];let me=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:ot(`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)}),he;return t[48]!==le||t[49]!==pe||t[50]!==me?(he=(0,$.jsxs)(`div`,{className:le,children:[pe,me]}),t[48]=le,t[49]=pe,t[50]=me,t[51]=he):he=t[51],he}function Hu(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=yu.find(e=>e.id===n)??yu[0];t[8]===i?c=t[9]:(c=ot(`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 Uu=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function Wu({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,onRemoteDesktop:a,instanceOptions:o,className:s}){let{t:c}=Ee(),{git:l}=se(),u=bt(),d=Na(),[f,p]=Z.useState(()=>new Map),m=q((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=q((e,t,n,r)=>{let i=wt.getState(),a=e===`__pinned__`?e:h(e);if(!a||a!==`__pinned__`&&i.getSessionFolderId(a,n)!==i.getSessionFolderId(a,r))return;let o=a===`__pinned__`?{}:wi(d.allSessions.filter(e=>ka(e)===a));i.reorderSessions(a,t,n,r,o).catch(()=>J.error(c(`sessions.order.saveFailed`)))}),_=Ni(e=>e.setProjectExpanded),v=Ni(e=>e.setWorktreeExpanded),y=st(),b=Rt(),x=Et(e=>e.archiveSessions),S=Et(e=>e.updateSessionTitle),C=Et(e=>e.requestSessionSmartTitle),w=Et(e=>e.shareSession),T=Et(e=>e.unshareSession),E=Et(e=>e.openNewSessionDraft),D=At(e=>e.openDraft),O=At(e=>e.openSession),k=Qe(e=>e.projects),A=Lt(e=>e.projectSortOrder),j=ki(),M=Z.useMemo(()=>k.filter(e=>e.hostId).map(Jt),[k]),N=Z.useMemo(()=>M.flatMap(e=>f.get(e.id)??[]).map(e=>({pinned:!!e.pinned,time:ut(e.node.session),session:{id:e.identity,title:e.node.session.title||``,content:e.content}})),[M,f]),P=wt(e=>e.sessionOrderByScope[aa]),F=Z.useMemo(()=>Ci([...d.pinnedSessions,...N.filter(e=>e.pinned).map(e=>e.session)],e=>e.id,P),[d.pinnedSessions,N,P]),I=Z.useMemo(()=>[...d.inProgressSessions.map(e=>({session:e,time:d.sessionById.get(e.id)?ut(d.sessionById.get(e.id)):0})),...N.filter(e=>!e.pinned)].sort((e,t)=>t.time-e.time).map(e=>e.session),[d.inProgressSessions,d.sessionById,N]),L=Qe(e=>e.setActiveProjectIdOnly),R=Qe(e=>e.removeProject),ee=xn(),[z,B]=Z.useState(null),[V,te]=Z.useState(!1),[H,ne]=Z.useState(null),[U,re]=Z.useState(null),[W,ie]=Z.useState(null),[ae,oe]=Z.useState(``),[ce,le]=Z.useState(!1),[ue,G]=Z.useState(!1),[de,K]=Z.useState(null),[fe,pe]=Z.useState(null),[me,he]=Z.useState(null),ge=z?.kind===`session`?z.session.id:``,_e=Ot(ge),ve=_e?.type===`busy`||_e?.type===`retry`,ye=z?.kind===`session`?ka(z.session):``,{unread:be,onToggleRead:xe}=ia(z?.kind===`session`?z.session:null,ye),Se=!!ge&&me===ge,Ce=!ye||Se||ve,we=q(e=>{let t=new Map;for(let e of d.allSessions){let n=Sa(e);if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n}),Te=q(()=>{te(!1),B(null)}),De=q(t=>{if(oa(t.id)){let e=_a(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&&ka(n)||null;e({sessionId:t.id,directory:r})}),Oe=q(e=>{oa(e.id)||y(e.id)}),ke=q(async e=>{if(oa(e.id))return;let t=we(e.id),{archivedIds:n,failedIds:r}=await x(t);n.length>0&&na({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&&J.error(r.length===1?c(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):c(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}),Ae=q(()=>{if(!z||z.kind!==`session`)return;let e=z.session,t=ka(e),n=_e?.type??`idle`;!t||me===e.id||n===`busy`||n===`retry`||(he(e.id),(async()=>{try{await ee.refreshSessionTranscript(e.id,{directory:t}),J.success(c(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{J.error(c(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{he(t=>t===e.id?null:t)}})())}),je=q(e=>{if(oa(e.id))return;let t=d.sessionById.get(e.id);t&&(B({kind:`session`,session:t}),te(!0))}),Me=q(e=>{_(e.id,!e.expanded)}),Ne=q((e,t)=>{v(`${e.id}::${t.id}`,!t.expanded)}),Pe=q((e,t)=>{L(e.id),D({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),Fe=q(()=>{let e=Qe.getState().getActiveProject();if(e?.hostId){gi(Jt(e),!0).catch(e=>J.error(e instanceof Error?e.message:String(e)));return}if(n){n();return}E()}),Ie=q(e=>{let t=d.projectMetaById.get(e.id);t&&(B({kind:`project`,project:t,isGitRepository:!1}),te(!0),l.checkIsGitRepository(t.path).then(e=>{B(n=>Uu(n,t.id,e))}).catch(()=>{B(e=>Uu(e,t.id,!1))}))}),Le=q((e,t)=>{let n=h(t);return n?e.worktrees.find(e=>h(e.path)===n)||((Et.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>h(e.path)===n)??null):null}),Re=q((e,t)=>{let n=d.projectMetaById.get(e.id);n&&Pe(n,t.path)}),ze=q((e,t)=>{let n=d.projectMetaById.get(e.id);n&&(B({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),te(!0))}),Be=q((e,t)=>{let n=d.projectMetaById.get(e.id);if(!n)return;let r=Le(n,t.path);if(!r){J.error(c(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}pe({project:n,worktree:r})}),Ve=q(e=>{K(e),L(e),G(!0)}),He=q(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=Et.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await Ft([e.path,...t.map(e=>e.path)],d.allSessions)})()}),Ue=q((e,t)=>{let n=de;if(G(!1),K(null),t?.sessionId){O({sessionId:t.sessionId,directory:e});return}D({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),We=q(async e=>{try{if(!(await w(e.id))?.share?.url){J.error(c(`sessions.sidebar.session.share.error`));return}J.success(c(`sessions.sidebar.session.share.successTitle`),{description:c(`sessions.sidebar.session.share.successDescription`)})}catch{J.error(c(`sessions.sidebar.session.share.error`))}}),Ge=q(async e=>{if((await lt(e)).ok){J.success(c(`sessions.sidebar.session.menu.copied`));return}J.error(c(`sessions.sidebar.session.share.copyUrlError`))}),Ke=q(async e=>{try{if(await T(e)){J.success(c(`sessions.sidebar.session.unshare.success`));return}J.error(c(`sessions.sidebar.session.unshare.error`))}catch{J.error(c(`sessions.sidebar.session.unshare.error`))}}),qe=q(e=>{let t=we(e.id);fa({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`)})}),Je=q(async()=>{if(!W)return;let e=ae.trim();if(e)try{await S(W.id,e),ie(null),oe(``)}catch{J.error(c(`sessions.sidebar.session.menu.rename`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),Ye=q(async()=>{if(!W||ce)return;let e=W.id;ie(null),oe(``),le(!0);try{await C(e)}catch{J.error(c(`sessions.sidebar.session.rename.smartTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{le(!1)}}),Xe=Z.useMemo(()=>z?z.kind===`session`?{kind:`session`,title:z.session.title?.trim()||c(`mobile.sessions.untitled`),pinned:b.has(z.session.id),shared:!!z.session.share?.url,unread:be}:z.kind===`project`?{kind:`project`,title:z.project.label,gitRepository:z.isGitRepository}:{kind:`worktree`,title:z.worktreeName}:null,[z,be,b,c]),Ze=Z.useMemo(()=>{if(!z)return{};if(z.kind===`session`){let e=z.session;return{onRename:()=>{oe(e.title?.trim()||c(`mobile.sessions.untitled`)),ie(e)},onTogglePin:()=>y(e.id),onToggleRead:xe,onShare:u&&!e.share?.url?()=>{We(e)}:void 0,onCopyLink:u&&e.share?.url?()=>{Ge(e.share.url)}:void 0,onUnshare:u&&e.share?.url?()=>{Ke(e.id)}:void 0,onRefreshTranscript:Ae,onArchive:()=>{ke({id:e.id,title:e.title?.trim()||c(`mobile.sessions.untitled`)})},onDelete:()=>qe(e)}}if(z.kind===`project`){let e=z.project;return{onNewSession:()=>Pe(e,e.path),onNewWorktree:()=>Ve(e.id),onSyncSessions:()=>He(e),onEditProject:()=>ne(e.id),onCloseProject:()=>re(e)}}let{project:e,worktreePath:t}=z;return{onNewSession:()=>Pe(e,t),onDeleteWorktree:()=>{let n=Le(e,t);if(!n){J.error(c(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}pe({project:e,worktree:n})}}},[z,ke,Ge,qe,Ae,Ve,He,We,Ke,xe,Le,u,Pe,c,y]),$e=Z.useMemo(()=>{if(!H)return null;let e=k.find(e=>e.id===H),t=d.projectMetaById.get(H);if(!e||!t)return null;let n=z?.kind===`project`&&z.project.id===H?z.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}},[z,H,d.projectMetaById,k]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ua,{remoteProjects:M,hostRegistry:j.registry,projectOrderIds:ca(k,A).map(e=>e.id),renderRemoteProject:j.registry?e=>(0,$.jsx)(ra,{project:e,registry:j.registry,mobile:!0,reorderEnabled:!1,onActivityItems:m}):void 0,remoteError:j.catalog.error?.message,className:s,projects:d.projects,pinnedSessions:F,inProgressSessions:I,onAddProject:t,onNewSession:Fe,onScanQr:r,onSwitchInstance:i,instanceOptions:o,onRemoteDesktop:a,onToggleProject:Me,onOpenProjectActions:Ie,onToggleWorktree:Ne,onNewWorktreeSession:Re,onOpenWorktreeActions:ze,onDeleteWorktree:Be,onSelectSession:De,onPinSession:Oe,onArchiveSession:e=>{ke(e)},onOpenSessionActions:je,onReorderSessions:g}),(0,$.jsx)(qi,{open:V,target:Xe,actions:Ze,refreshTranscriptDisabled:Ce,refreshTranscriptSpinning:Se,onOpenChange:e=>{e?te(!0):Te()}}),(0,$.jsx)(Hn,{open:ue,projectId:de,onOpenChange:e=>{G(e),e||K(null)},onWorktreeCreated:Ue}),fe?(0,$.jsx)(ya,{open:!0,project:{id:fe.project.id,path:fe.project.path},worktree:fe.worktree,onClose:()=>pe(null)}):null,(0,$.jsx)(cr,{open:!!U,title:c(`sessions.sidebar.project.actions.closeProject`),onClose:()=>re(null),closeAriaLabel:c(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>re(null),children:c(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!U)return;let e=U;re(null),R(e.id),J.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:U?.label??``})})}),(0,$.jsx)(cr,{open:!!W,title:c(`sessions.sidebar.session.menu.rename`),onClose:()=>{ce||(ie(null),oe(``))},closeAriaLabel:c(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`default`,className:`flex-1`,disabled:ce,onClick:()=>{ie(null),oe(``)},children:c(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{type:`button`,variant:`default`,className:`flex-1`,disabled:!ae.trim()||ce,onClick:()=>void Je(),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(),Je()},children:[(0,$.jsx)(Xn,{value:ae,onChange:e=>oe(e.target.value),autoFocus:!0,className:`h-12`,disabled:ce}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:ce,onClick:()=>void Ye(),children:[ce?(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)(wa,{open:H!==null,project:$e,onClose:()=>ne(null)})]})}function Gu(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=ot(`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 Ku(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=[...gr],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(qa,{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 qu(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(pd),x=At(),S=At(fd),C=At(dd),w=At(ud),T=At(ld),E=At(cd),D=At(sd),O=At(od),k=At(ad),A=At(id),j=At(rd),M=At(nd),N=At(td),P;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(P=[],t[0]=P):P=t[0],Z.useEffect(ed,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&&Kn.getState().clear({sessionId:e.sessionId,directory:e.directory}),F?mn(Pn):Un(Pn)},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(Qu,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=q(z),V;t[7]===C?V=t[8]:(V=e=>{C(e)},t[7]=C,t[8]=V);let te=q(V),H;t[9]===O?H=t[10]:(H=()=>{O()},t[9]=O,t[10]=H);let ne=q(H),U;t[11]===w?U=t[12]:(U=()=>{w()},t[11]=w,t[12]=U);let re=q(U),W;t[13]===T?W=t[14]:(W=e=>{T(e)},t[13]=T,t[14]=W);let ie=q(W),ae=Z.useRef(null),[oe,se]=Z.useState(!1),ce;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>{ae.current=e},t[15]=ce):ce=t[15];let le=q(ce),ue;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>{se(e)},t[16]=ue):ue=t[16];let G=q(ue),de;t[17]!==ne||t[18]!==v||t[19]!==D||t[20]!==N||t[21]!==k?(de=()=>{if(ae.current?.())return!0;let e=At.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?(ne(),!0):!1},t[17]=ne,t[18]=v,t[19]=D,t[20]=N,t[21]=k,t[22]=de):de=t[22];let K=q(de),fe=x.secondary!==null,pe;t[23]!==K||t[24]!==f?(pe=()=>{if(f)return f(()=>K()),()=>f(null)},t[23]=K,t[24]=f,t[25]=pe):pe=t[25];let me;t[26]!==K||t[27]!==f||t[28]!==fe?(me=[f,fe,K],t[26]=K,t[27]=f,t[28]=fe,t[29]=me):me=t[29],Z.useEffect(pe,me);let he=Et(Zu),ge=Xe(Xu),ve;t[30]===he?ve=t[31]:(ve=e=>he?e.getDirectoryForSession(he):null,t[30]=he,t[31]=ve);let ye=Et(ve),be,xe;t[32]!==ye||t[33]!==he||t[34]!==j||t[35]!==ge||t[36]!==M?(be=()=>{let e=At.getState().secondary;if(ge)return;if(e?.kind===`draft`&&he){j({sessionId:he,directory:ye});return}if(e?.kind!==`chat`||!he||Mt({sessionId:he,directory:ye})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==he||h(t.directory)!==h(ye))&&M({sessionId:he,directory:ye})},xe=[ye,he,j,M,ge],t[32]=ye,t[33]=he,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]!==he||t[40]!==v||t[41]!==A||t[42]!==ge?(Se=()=>{let e=At.getState().secondary;if(e?.kind!==`chat`||!v||v.onSelect||ge)return;let t=e.routes.at(-1);!t||t.sessionId!==he||A({sessionId:v.id,directory:v.directory})},Ce=[he,v,A,ge],t[39]=he,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]!==G||t[46]!==le||t[47]!==p?(we=typeof p==`function`?p(le,G):p,t[45]=G,t[46]=le,t[47]=p,t[48]=we):we=t[48];let Te=we,De;t[49]!==re||t[50]!==s||t[51]!==n||t[52]!==a||t[53]!==r||t[54]!==i||t[55]!==te?(De=(0,$.jsx)(Wu,{onOpenChat:te,onAddProject:n,onNewSession:re,onScanQr:r,onSwitchInstance:i,onRemoteDesktop:a,instanceOptions:s}),t[49]=re,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]!==ie?(Oe=(0,$.jsx)(mu,{onEnable:c,onOpenAssistant:ie}),t[57]=c,t[58]=ie,t[59]=Oe):Oe=t[59];let ke;t[60]===Te?ke=t[61]:(ke=(0,$.jsx)(Gu,{showHeader:!1,children:Te}),t[60]=Te,t[61]=ke);let Ae;t[62]===l?Ae=t[63]:(Ae=(0,$.jsx)(Ku,{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]!==K||t[70]!==E||t[71]!==y?(e=e=>({key:`assistant-secondary`,depth:1,ariaLabel:y(`assistants.title`),onBack:K,content:(0,$.jsx)(so,{activeOverride:e,onMobileBack:Yu,onMobileOpenSettings:E})}),t[69]=K,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]!==K||t[77]!==e||t[78]!==y?(a=e?[{key:`assistant-settings:${e}`,depth:2,ariaLabel:y(`assistants.conversation.openSettings`),onBack:K,content:(0,$.jsx)(gu,{assistantID:e,onBack:Ju})}]:[],t[76]=K,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]!==K||t[86]!==u||t[87]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:K,content:u}],t[85]=K,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]!==K||t[94]!==e||t[95]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:K,content:n}],t[93]=K,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]!==K||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:K,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:K,content:(0,$.jsx)(_u,{route:a})}]:[...e,...c],t[98]=n,t[99]=K,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=oe||b||_,Re;return t[108]!==g||t[109]!==x||t[110]!==B||t[111]!==Ie||t[112]!==Le||t[113]!==Me?(Re=(0,$.jsx)(Vu,{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 Ju(){Br.requestAnimatedBack(`root`)}function Yu(){return Br.requestAnimatedBack(`root`)}function Xu(e){return e.remoteSession}function Zu(e){return e.currentSessionId}function Qu(){return $u}function $u(){return Un(Pn)}function ed(){return Ct()}function td(e){return e.popBtw}function nd(e){return e.replaceChatSession}function rd(e){return e.materializeDraftSession}function id(e){return e.reconcileChatPredecessor}function ad(e){return e.popChatSession}function od(e){return e.closeSecondary}function sd(e){return e.popAssistantSettings}function cd(e){return e.pushAssistantSettings}function ld(e){return e.openAssistant}function ud(e){return e.openDraft}function dd(e){return e.openSession}function fd(e){return e.setActiveTab}function pd(e){return e.isCommandPaletteOpen}function md(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=hd({...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 hd(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 gd={scale:1,x:0,y:0};function _d(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 vd(e,t,n){if(t.width<=0||t.height<=0||t.remoteWidth<=0||t.remoteHeight<=0)return null;let r=_d(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 yd(e,t,n=1){let r=Math.max(n,Math.min(5,e.scale)),i=_d(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 bd(e){let t=new Map,n={...gd},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={...gd},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=vd(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=yd({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=vd(p,e.viewport(),n);if(t){let i=vd(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=vd(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(Zn(u,r)){if(n.scale>1)n={...gd};else{let t=2.5,r=t/n.scale;n=yd({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=yd(n,e.viewport()),e.apply(n)},reset(){h(),n={...gd},e.apply(n)}};return _}function xd(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 Sd=me(`YuriOrientation`);function Cd(){return he.isNativePlatform()&&he.isPluginAvailable(`YuriOrientation`)}function wd(e){return Sd.lock({orientation:e})}function Td(e){let t=(0,Q.c)(14),[n,r]=(0,Z.useState)(jd),[i]=(0,Z.useState)(Ad),[a,o]=(0,Z.useState)(i),[s]=(0,Z.useState)(Cd),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],pe(e,c);let l,u;t[1]!==s||t[2]!==a?(l=()=>{s&&wd(a).catch(kd)},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 Dd},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(Ed),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 Ed(e){return e===`portrait`?`landscape`:`portrait`}function Dd(){wd(`portrait`).catch(Od)}function Od(){}function kd(){}function Ad(){return window.innerWidth>window.innerHeight?`landscape`:`portrait`}function jd(){return{width:window.innerWidth,height:window.innerHeight}}var Md=(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}),Nd=(e,t)=>{let n=(0,Q.c)(3),r;return n[0]!==t||n[1]!==e?(r=Md(e,t),n[0]=t,n[1]=e,n[2]=r):r=n[2],ne(r)},Pd=[{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 Fd({onClose:e,instanceName:t}){let{t:n}=Ee(),[r]=Z.useState(()=>({transport:l(),generation:d()})),i=Nd(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=Td(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=q(e=>{E.current?.send(e)}),M=q(()=>p),[N]=Z.useState(()=>bd({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=q(()=>{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,xd(n,e,x.rotation)]));N.moveMany(t)}O.current.clear()}),F=q(()=>{P(),N.reset(),E.current?.close(),E.current=null}),I=q(()=>{F(),e()});Lr({id:`remote-desktop-page`,active:!0,layer:`root`,onBack:I,surfaceRef:b}),Z.useEffect(()=>vn(`remote-desktop-page`),[]),Z.useLayoutEffect(()=>{let e=document.activeElement;return b.current?.focus({preventScroll:!0}),()=>{e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),K(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),Br.requestBrowserBack())},()=>document);let L=q((e,t)=>{(e===`closed`||e===`connecting`)&&(O.current.clear(),k.current.clear(),N.cancel()),c(e),f(t)}),R=q((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()});pe(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=md({...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 xd({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,yl.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)(Y,{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)(Y,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto`,"aria-label":n(`header.actions.backAria`),onClick:()=>Br.requestBrowserBack(),children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(Y,{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)(Y,{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)(Y,{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)(Y,{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)(Xn,{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)(Y,{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:Pd.map(({key:e,icon:t})=>(0,$.jsx)(Y,{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 Id=Z.memo(Fd);function Ld(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=W(),p=q(i),m=q(a),h;t[0]!==f||t[1]!==n?(h=f?.entry.location.hostId?(0,$.jsx)(Rd,{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)(Sn,{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)(Da,{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 Rd(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=Xe(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)(zd,{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 zd=(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=ne(s,le).data??i,l;return t[8]===c?l=t[9]:(l=(0,$.jsx)($.Fragment,{children:c}),t[8]=c,t[9]=l),l});function Bd(e){return e.sessionId?e.userRefreshInFlight||e.backgroundResyncInFlight?`syncing`:e.hasRenderableTranscript?null:!e.isConnected&&e.connectionPhase===`reconnecting`||e.loadStatus!==`error`?`syncing`:null:null}function Vd(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 Hd(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=Vd(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 Ud(e,t){let n=(0,Q.c)(20),{t:r}=Ee(),i=jt(e,t),{renderable:a}=mt(e,t),o=dt(qd),s=dt(Kd),c;n[0]!==t||n[1]!==e?(c=()=>F(e,t),n[0]=t,n[1]=e,n[2]=c):c=n[2];let l=(0,Z.useSyncExternalStore)(R,c,Gd),u;n[3]!==t||n[4]!==e?(u=()=>vt(e,t),n[3]=t,n[4]=e,n[5]=u):u=n[5];let d=(0,Z.useSyncExternalStore)(ft,u,Wd),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=Bd({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=Hd(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 Wd(){return!1}function Gd(){return!1}function Kd(e){return e.connectionPhase}function qd(e){return e.isConnected}function Jd(e,t){let n=(0,Q.c)(41),{t:r}=Ee(),i=re(e.registry,e.entry.location.hostId),a=(0,Z.useSyncExternalStore)(P,N,N),o;n[0]===e.entry.location?o=n[1]:(o=M(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):Zd,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=()=>F(t,_),n[18]=_,n[19]=t,n[20]=y):y=n[20];let b=(0,Z.useSyncExternalStore)(R,y,Xd),x;n[21]!==_||n[22]!==t?(x=()=>vt(t,_),n[21]=_,n[22]=t,n[23]=x):x=n[23];let S=(0,Z.useSyncExternalStore)(ft,x,Yd),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=Bd({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=Hd(O===`syncing`,k),j;if(n[35]!==i||n[36]!==r){j=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Bn(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 I;return n[38]!==r||n[39]!==A?(I=A?r(`mobile.chat.syncingMessages`):null,n[38]=r,n[39]=A,n[40]=I):I=n[40],I}function Yd(){return!1}function Xd(){return!1}function Zd(){}function Qd(e){let t=(0,Q.c)(3),n=W(),r;return t[0]!==n||t[1]!==e?(r=n?.entry.location.hostId?(0,$.jsx)(ef,{...e,host:n}):(0,$.jsx)($d,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}function $d(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=Ud(s?``:i,n||void 0),f;return t[10]!==r||t[11]!==u||t[12]!==i||t[13]!==d?(f=(0,$.jsx)(tf,{...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 ef(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=Xe(o),c=i||s||``,l=Jd(n,c),u;return t[9]!==c||t[10]!==r||t[11]!==l||t[12]!==a?(u=(0,$.jsx)(tf,{...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 tf(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=q(h),_;t[3]!==p||t[4]!==a?(_=()=>{p&&m(!1),a()},t[3]=p,t[4]=a,t[5]=_):_=t[5];let v=q(_),y=d||p,b;t[6]===l?b=t[7]:(b=ot(`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)(nc,{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)(Ld,{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=ot(`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 nf(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([Wn(r).catch(cf),document.fonts?.ready?.then(sf).catch(of)??Promise.resolve(),fo.catch(af)]).then(rf),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 rf(){}function af(){}function of(){}function sf(){}function cf(){}var lf=e=>e.replace(/^\/+|\/+$/g,``),uf=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},df=e=>{let t=lf(e.pathname).split(`/`).filter(Boolean);return e.host?[e.host,...t]:t};function ff(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=df(t),r=(n[0]??``).toLowerCase(),i=n.slice(1),a=t.searchParams;switch(r){case`connect`:{let t=Ua(e);return t?{type:`connect`,pairing:t}:null}case`session`:{let e=i[0]||a.get(`id`)||``;return e?{type:`session`,sessionId:e,directory:uf(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:uf(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=uf(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 pf={},mf=null,hf=!1,gf=null,_f=e=>{switch(e.type){case`connect`:return mf?(mf(e.pairing),!0):!1;case`session`:return _()?(Et.getState().setCurrentSession(e.sessionId,e.directory??null),!0):(At.getState().openSession({sessionId:e.sessionId,directory:e.directory??null}),!0);case`assistant`:if(!_()){let t=At.getState();return t.setActiveTab(`assistant`),t.openAssistant(e.assistantId),!0}return Ht(e.assistantId),!0;case`new-session`:return _()?(Et.getState().openNewSessionDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0):(At.getState().openDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0);case`open-project`:return _()?(Et.getState().openNewSessionDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0):(At.getState().openDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0);case`sessions`:return pf.openSessions?(pf.openSessions(e.filter),!0):!1;case`status`:return pf.openSessions?(pf.openSessions(),!0):(_e.getState().setMobileSessionPanelOpen(!0),!0);case`view`:return pf.openView?(pf.openView(e.target),!0):!1;case`changes`:return pf.openChanges?(pf.openChanges({path:e.path,staged:e.staged}),!0):!1;case`settings`:return pf.openSettings?(pf.openSettings(e.section),!0):!1}return!1},vf=()=>{if(!gf||!hf&&gf.type!==`connect`)return;let e=gf;gf=null,_f(e)||(gf=e)},yf=e=>{gf=e,vf()},bf=e=>{let t=ff(e);t&&yf(t)},xf=e=>{hf=e,vf()},Sf=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(pf=e,vf(),()=>{pf===e&&(pf={})}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},Cf=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(mf=e,vf(),()=>{mf===e&&(mf=null)}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},wf=e=>{let{ready:t}=e,[n,r]=Z.useState(()=>g()?`pending`:`none`);return Z.useEffect(()=>{xf(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=>{bf(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=ff(a?.url);r(o?.type===`connect`?`connect`:o?`other`:`none`),o&&yf(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){bf(n);return}let r=typeof t?.assistantID==`string`?t.assistantID.trim():``;if(r){yf({type:`assistant`,assistantId:r});return}let i=typeof t?.sessionId==`string`?t.sessionId:void 0;i&&yf({type:`session`,sessionId:i})});if(e){r.remove();return}t.push(()=>void r.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e())}},[]),n},Tf=.85,Ef=8,Df=.35,Of=.22,kf=e=>({segmentStart:e,lastTouch:e,open:!1}),Af=e=>e*Df,jf=e=>e*Of,Mf=(e,t)=>Math.max(0,e-t),Nf=(e,t)=>Math.max(0,t-e),Pf=(e,t)=>{let n=Math.abs(e);return n<Ef||Math.abs(t)<=n*Tf},Ff=(e,t,n)=>{let r=t.clientX-e.segmentStart.clientX,i=t.clientY-e.segmentStart.clientY,a=Mf(e.segmentStart.clientX,t.clientX),o=Af(n),s=jf(n),c=e.open;return c=a<=0?!1:e.open?a>=s:a>=o&&Pf(r,i),{segmentStart:e.segmentStart,lastTouch:t,open:c}},If=e=>{if(e.disabled||e.startedOnExcludedTarget)return{open:!1,back:!1};let t=e.endX-e.startX,n=e.endY-e.startY,r=Mf(e.startX,e.endX),i=Nf(e.startX,e.endX),a=Af(e.viewportWidth),o=Pf(t,n);return{open:r>=a&&o,back:i>=a&&o}},Lf=(e,t,n)=>Math.min(Mf(e,t)/Math.max(1,Af(n)),1),Rf=(e,t,n)=>Math.min(Nf(e,t)/Math.max(1,Af(n)),1),zf=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},Bf=e=>{let t=document.elementFromPoint(e.clientX,e.clientY);return!!t?.closest(`.yuri-mobile-composer`)||zf(t)},Vf=1,Hf=(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===Vf?n:n.parentElement;return!!(r&&t.contains(r))},Uf=e=>Hf(window.getSelection(),e),Wf=(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=Af(g),n=It({thresholdReached:p,distance:e,enterDistance:t,cancelDistance:jf(g),available:!0});p=n.thresholdReached,n.event===`enter`&&(m=ct(`medium`,{bypassCadence:!0})),n.event===`cancel`&&(ct(`light`,{bypassCadence:!0}),m=!1)},y=e=>{o.current?.(null),p&&!e&&ct(`light`,{bypassCadence:!0}),p=!1,m=!1,e?r.current():f&&a.current?.(),f=!1},b=e=>{c.current?.(null),p&&!e&&ct(`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=Bf(r)||Uf(t),d=null,f=!1,p=!1,m=!1,h=0,_=kf(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];_=Ff(_,r,g);let a=r.clientX-_.segmentStart.clientX,l=r.clientY-_.segmentStart.clientY;if(d===null){if(Uf(t))return;let e=Math.abs(a);if(e<Ef||Math.abs(l)>e*Tf)return;if(a<0)d=`sessions`,f=!0,i.current?.();else if(s.current)d=`back`;else return}e.preventDefault(),h=d===`sessions`?Mf(_.segmentStart.clientX,r.clientX):Nf(_.segmentStart.clientX,r.clientX),v(h),d===`sessions`?o.current?.(Lf(_.segmentStart.clientX,r.clientX,g)):c.current?.(Rf(_.segmentStart.clientX,r.clientX,g))},C=e=>{if(!n||!_)return;if(n=!1,!d){_=null;return}let t=e.changedTouches[0];t&&(_=Ff(_,t,g),h=d===`sessions`?Mf(_.segmentStart.clientX,t.clientX):Nf(_.segmentStart.clientX,t.clientX),v(h));let r=d===`sessions`?_.open:If({startX:_.segmentStart.clientX,startY:_.segmentStart.clientY,endX:_.lastTouch.clientX,endY:_.lastTouch.clientY,viewportWidth:g,disabled:!1,startedOnExcludedTarget:!1}).back;_=null,e.preventDefault(),r&&!m&&ct(`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])},Gf=me(`YuriNotifications`),Kf=()=>he.getPlatform()===`android`&&he.isPluginAvailable(`YuriNotifications`);async function qf(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 Jf(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 Yf=()=>{if(Kf()||typeof window>`u`)return!1;let e=window.Capacitor?.getPlatform?.();return e===`ios`||e===`android`},Xf=(e,t)=>{x()?.push?.registerApnsToken?.({token:e,platform:y(),locale:t})},Zf=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||!Yf())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,Xf(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||!Yf())return;let e=i.current;e&&Xf(e,r)},[t,n,r]),Z.useEffect(()=>{if(n)return;let e=i.current;e&&(i.current=null,x()?.push?.unregisterApnsToken?.({token:e}))},[n])},Qf=`YuriLiveActivity`,$f=5e3,ep=3600,tp=`live`,np=me(Qf),rp=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable;function ip(){return typeof window>`u`?!1:rp({isCapacitor:g(),platform:y(),pluginAvailable:he.isPluginAvailable(Qf)})}var ap=()=>np,op=new Set([`permission`,`input`,`retry`]),sp=()=>({trackedSessionId:null,started:!1,startedAt:null,busySince:null,lastStatus:null,eventVersion:0,items:[]}),cp=(e,t)=>Math.max(Math.floor(e),t+1),lp=e=>e.failedEpoch===e.currentEpoch?e.previous:e.current,up=e=>e.failedEpoch===e.currentEpoch&&e.retryCount<1,dp=e=>e.hasSessionError?`error`:e.hasPendingPermissions?`permission`:e.hasPendingQuestions?`input`:e.statusType===`retry`?`retry`:e.statusType===`busy`?`working`:e.statusType===`idle`?`complete`:null,fp=e=>{let t=e.trim();return t.length<=80?t:`${t.slice(0,79)}…`},pp=e=>typeof e.parentID==`string`&&e.parentID.length>0?e.parentID:null,mp=e=>{if(e.runningIds.size===0)return[];let t=[];for(let n of e.sessions)!e.runningIds.has(n.id)||pp(n)||t.push({sessionId:n.id,title:fp(n.title??``),statusType:e.statuses[n.id]?.type??`busy`});return t},hp=e=>e!==`complete`&&e!==`error`,gp=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`,_p=e=>{if(e.length<=4)return e;let t=e.filter(e=>hp(e.status)),n=e.filter(e=>!hp(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)},vp=(e,t,n,r)=>{if(n&&n.length>0)return n;let i=r?.[e];return i&&i.length>0?i:t},yp=(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=dp({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;o.push({sessionId:t.sessionId,title:vp(t.sessionId,t.title,e.title,r),status:i,startedAt:t.startedAt,busySince:i===`working`?t.busySince??n:null})}else if(hp(t.status))o.push({...t,title:vp(t.sessionId,t.title,void 0,r),status:`complete`,endedAt:n,busySince:null});else{let e=vp(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=dp({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 _p(o)},bp=e=>e.map(e=>`${e.sessionId}\0${e.title}\0${e.status}\0${e.endedAt??``}`).join(`
|
|
16
|
+
`),xp=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}),Sp=(e,t,n,r,i)=>{let a=e.filter(e=>hp(e.status)),o=a[0]??e[0],s={sessionId:tp,startedAt:o?.startedAt??r,status:t,eventVersion:n,updatedAt:r,title:o?.title,workingCount:a.length,items:xp(e)};return i?.endedAt!==void 0&&(s.endedAt=i.endedAt),i?.dismissalSeconds!==void 0&&(s.dismissalSeconds=i.dismissalSeconds),s},Cp=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},wp=(e,t,n,r)=>{let i=e.trackedSessionId;if(!i||!e.started)return{state:sp(),commands:[]};let a=cp(t,e.eventVersion);return{state:sp(),commands:[{type:`end`,payload:Cp({sessionId:i,startedAt:e.startedAt??t,status:n,eventVersion:a,updatedAt:t,endedAt:t,dismissalSeconds:r})}]}},Tp=(e,t,n,r,i)=>{let a=cp(r,i);return{state:{trackedSessionId:e,started:!0,startedAt:n,busySince:null,lastStatus:t,eventVersion:a,items:[]},commands:[{type:`start`,payload:Cp({sessionId:e,startedAt:n,status:t,eventVersion:a,updatedAt:r})}]}},Ep=(e,t,n)=>{let r=dp(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=$f-(t.now-(i??t.now));if(r>0)return{state:{...e,trackedSessionId:n,busySince:i},commands:[{type:`wait`,delayMs:r}]}}else if(!r||!op.has(r))return{state:{...sp(),trackedSessionId:n},commands:[]};return Tp(n,r,i??t.now,t.now,e.eventVersion)}if(r===`complete`)return wp({...e,busySince:i},t.now,`complete`,900);if(r===`error`)return wp({...e,busySince:i},t.now,`error`,ep);if(!r||r===e.lastStatus)return{state:{...e,trackedSessionId:n,busySince:i},commands:[]};let a=cp(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:Cp({sessionId:n,startedAt:e.startedAt??t.now,status:r,eventVersion:a,updatedAt:t.now})}]}},Dp=(e,t,n)=>{let r=e.trackedSessionId;if(!r||!e.started)return{state:e,commands:[]};let i=cp(n,e.eventVersion);return{state:{...e,busySince:null,lastStatus:t,eventVersion:i},commands:[{type:`update`,payload:Cp({sessionId:r,startedAt:e.startedAt??n,status:t,eventVersion:i,updatedAt:n})}]}},Op=(e,t,n)=>{let r=yp(e.items,n,t.now,t.sessionTitles,t.rootSessionIds),i=r.filter(e=>hp(e.status)),a=gp(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=cp(t.now,n.eventVersion),a=r.map(e=>hp(e.status)?{...e,status:`stale`}:e);return{state:{...n,items:a,lastStatus:`stale`,eventVersion:i,busySince:null},commands:[{type:`update`,payload:Cp(Sp(a,`stale`,i,t.now))}]}}if(!e.started){if(i.length===0)return{state:sp(),commands:[]};if(!i.some(e=>op.has(e.status))){let n=$f-(t.now-(o??t.now));if(n>0)return{state:{...e,trackedSessionId:tp,items:r,busySince:o},commands:[{type:`wait`,delayMs:n}]}}let n=o??t.now,s=r.map(e=>hp(e.status)?{...e,startedAt:e.busySince??n}:e),c=cp(t.now,e.eventVersion);return{state:{trackedSessionId:tp,started:!0,startedAt:n,busySince:null,lastStatus:a,eventVersion:c,items:s},commands:[{type:`start`,payload:Cp(Sp(s,a,c,t.now))}]}}if(i.length===0){let n=r.some(e=>e.status===`error`)?`error`:`complete`,i=cp(t.now,e.eventVersion);return{state:sp(),commands:[{type:`end`,payload:Cp(Sp(r,n,i,t.now,{endedAt:t.now,dismissalSeconds:n===`error`?ep:900}))}]}}if(bp(e.items)===bp(r)&&e.lastStatus===a)return{state:{...e,trackedSessionId:tp,items:r,busySince:null},commands:[]};let s=cp(t.now,e.eventVersion);return{state:{trackedSessionId:tp,started:!0,startedAt:e.startedAt??o??t.now,busySince:null,lastStatus:a,eventVersion:s,items:r},commands:[{type:`update`,payload:Cp(Sp(r,a,s,t.now))}]}},kp=(e,t)=>{if(t.catalog)return Op(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:[]}:Dp(n,`stale`,t.now)}let n=[],r=e;if(r.trackedSessionId&&r.trackedSessionId!==t.sessionId)if(r.started){let e=wp(r,t.now,r.lastStatus??`complete`,0);n.push(...e.commands),r=e.state}else r=sp();if(!t.sessionId){if(r.started){let e=wp(r,t.now,`complete`,900);return{state:e.state,commands:[...n,...e.commands]}}return{state:sp(),commands:n}}let i=Ep(r,t,t.sessionId);return{state:i.state,commands:[...n,...i.commands]}},Ap=e=>e/1e3,jp=e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Ap(e.startedAt)};return e.endedAt!==void 0&&(t.endedAt=Ap(e.endedAt)),t},Mp=e=>{let t={sessionId:e.sessionId,startedAt:Ap(e.startedAt),status:e.status,eventVersion:e.eventVersion,updatedAt:Ap(e.updatedAt)};return e.endedAt!==void 0&&(t.endedAt=Ap(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(jp)),t},Np=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},Pp=(e,t,n)=>{if(!e||n.type===`wait`)return Promise.resolve();let r=Mp(n.payload),i=Np(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})},Fp=e=>e.getCurrentEpoch()===e.epoch?!e.getCurrentSessionId||e.getCurrentSessionId()===e.observation.sessionId:!1,Ip=async e=>{let t=e.state;if(!Fp(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let n=kp(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 Fp(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(!Fp(e)||(await Pp(e.available,e.plugin,i),!Fp(e)))return{state:t,delayMs:null,retry:!1,superseded:!0};let s=r===a.length-1;o=i.type===`end`&&!s?sp():n.state}return{state:n.state,delayMs:i,retry:!1,superseded:!1}}catch{if(!Fp(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let r=lp({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),previous:o,current:n.state}),i=up({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),retryCount:e.retryCount});return{state:r,delayMs:i?250:null,retry:i,superseded:!1}}},Lp=()=>({desired:null,registered:null}),Rp=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null},zp=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=Rp(t.activityId),r=Rp(t.sessionId),i=Rp(t.token);return!n||!r||!i?null:{activityId:n,sessionId:r,token:i}},Bp=(e,t)=>e.activityId===t.activityId&&e.token===t.token,Vp=(e,t)=>{let n=e.registered?.runtimeIdentity===t?e.registered:null;return e.desired===null&&n===e.registered?e:{desired:null,registered:n}},Hp=(e,t)=>{if(!t.connected)return[];if(e.desired&&t.enabled&&t.selectedSessionId&&e.desired.sessionId===t.selectedSessionId){let n=e.registered;return n&&Bp(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}]:[]},Up=(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=Vp(e,t.runtimeIdentity):e.registered&&e.registered.runtimeIdentity!==t.runtimeIdentity&&!e.desired&&(r={...e,registered:null});return{state:r,commands:Hp(r,t)}},Wp=async e=>{try{return await e}catch{return null}},Gp=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 Wp(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 Wp(e.unregister({token:r.token}))}continue}if(n.runtimeIdentity!==e.getRuntimeIdentity()){t.registered?.runtimeIdentity===n.runtimeIdentity&&(t={...t,registered:null});continue}(await Wp(e.unregister(n.payload)))?.ok===!0&&t.registered?.token===n.payload.token&&(t={...t,registered:null})}return t},Kp=new Map,qp=[];function Jp(){let e=ip(),t=dt(e=>e.isConnected),n=Bt({enabled:e}),r=yt(t=>e?t.statusById:Kp),i=zt(t=>e?t.activeSessions:qp),a=(0,Z.useMemo)(()=>e?Ge(n,r):new Set,[e,r,n]),o=(0,Z.useMemo)(()=>e?mp({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
|
+
`),Object.entries(c).map(([e,t])=>`${e}\0${t}`).join(`
|
|
18
|
+
`)].join(`
|
|
19
|
+
---
|
|
20
|
+
`),[o,c]),f=(0,Z.useRef)(sp()),p=(0,Z.useRef)(Lp()),m=(0,Z.useRef)(null),h=(0,Z.useRef)(0),g=(0,Z.useRef)(Promise.resolve()),_=(0,Z.useRef)(Promise.resolve()),v=(0,Z.useRef)(null),y=q(()=>({sessionId:tp,statusType:void 0,hasPendingPermissions:!1,hasPendingQuestions:!1,hasSessionError:!1,now:Date.now(),connected:t,catalog:o,sessionTitles:c,rootSessionIds:u})),b=q(n=>{_.current=_.current.then(async()=>{let r=Up(p.current,{selectedSessionId:tp,runtimeIdentity:l(),connected:t,enabled:e},n);p.current=r.state,r.commands.length!==0&&(p.current=await Gp({state:p.current,commands:r.commands,getRuntimeIdentity:l,register:e=>x()?.push?.registerLiveActivityToken?.({...e,items:f.current.items.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Ap(e.startedAt)};return e.endedAt===void 0?t:{...t,endedAt:Ap(e.endedAt)}})})??Promise.resolve(null),unregister:e=>x()?.push?.unregisterLiveActivityToken?.(e)??Promise.resolve(null)}))}).catch(()=>void 0)}),S=q(e=>{let t=zp(e);t&&b({type:`pushToken`,...t,sessionId:tp})});(0,Z.useEffect)(()=>{b({type:e?`sync`:`dispose`})},[e,t]),(0,Z.useEffect)(()=>s(()=>{b({type:`sync`})}),[]),(0,Z.useEffect)(()=>{if(!e){v.current?.remove(),v.current=null;return}let t=!1,n=null,r=0,i=ap(),a=h.current+1;h.current=a;let o=()=>{g.current=g.current.then(async()=>{if(t||h.current!==a)return;if(m.current!==!0){if(m.current===!1)return;let e=await i.isSupported().catch(()=>({supported:!1}));if(t||h.current!==a||(m.current=e.supported===!0,!m.current))return}let e=y(),s=f.current.started,c=await Ip({available:!0,plugin:i,state:f.current,observation:e,epoch:a,getCurrentEpoch:()=>h.current,retryCount:r});if(!(t||h.current!==a||c.superseded)){if(f.current=c.state,s&&!c.state.started)b({type:`localEndSucceeded`});else if(c.state.started){let e=p.current.desired;e&&x()?.push?.registerLiveActivityToken?.({activityId:e.activityId,sessionId:tp,token:e.token,items:c.state.items.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Ap(e.startedAt)};return e.endedAt===void 0?t:{...t,endedAt:Ap(e.endedAt)}})})}c.retry?r+=1:r=0,c.delayMs!=null&&(n=setTimeout(()=>{o()},c.delayMs))}}).catch(()=>void 0)};return g.current=g.current.then(async()=>{if(!(t||h.current!==a)&&!v.current)try{let e=await i.addListener(`pushToken`,e=>{S(e)});if(t){await e.remove();return}v.current=e}catch{return}}).then(()=>{!t&&h.current===a&&o()}).catch(()=>void 0),()=>{t=!0,h.current===a&&(h.current+=1),n!==null&&clearTimeout(n)}},[e,t,d]),(0,Z.useEffect)(()=>()=>{v.current?.remove(),v.current=null,b({type:`dispose`})},[])}function Yp(){let e=(0,Q.c)(49),t=_e(Zp),{t:r,locale:i}=Ee(),a;e[0]===r?a=e[1]:(a=r(`mobile.notifications.service`),e[0]=r,e[1]=a);let o=a,c;e[2]===r?c=e[3]:(c=r(`settings.page.notifications.title`),e[2]=r,e[3]=c);let l=c,u;e[4]===r?u=e[5]:(u=r(`mobile.connect.connecting`),e[4]=r,e[5]=u);let d=u,f;e[6]===r?f=e[7]:(f=r(`mobile.notifications.connected`),e[6]=r,e[7]=f);let p=f,m;e[8]===r?m=e[9]:(m=r(`layout.browserProvider.status.reconnecting`),e[8]=r,e[9]=m);let h=m,g;e[10]===r?g=e[11]:(g=r(`mobile.notifications.unavailable`),e[10]=r,e[11]=g);let _=g,v;e[12]===r?v=e[13]:(v=r(`mobile.notifications.gap`),e[12]=r,e[13]=v);let y=v,b;e[14]===r?b=e[15]:(b=r(`settings.notifications.page.toast.permissionDenied.title`),e[14]=r,e[15]=b);let x=b,S;e[16]===r?S=e[17]:(S=r(`settings.notifications.page.template.defaults.error.title`),e[16]=r,e[17]=S);let C=S,w;e[18]===r?w=e[19]:(w=r(`mobile.notifications.auth`),e[18]=r,e[19]=w);let T=w,E;e[20]===r?E=e[21]:(E=r(`mobile.notifications.endpoint`),e[20]=r,e[21]=E);let D=E,O;e[22]===r?O=e[23]:(O=r(`mobile.notifications.response`),e[22]=r,e[23]=O);let k=O,A;e[24]===r?A=e[25]:(A=r(`mobile.notifications.server`),e[24]=r,e[25]=A);let j=A,M;e[26]===r?M=e[27]:(M=r(`mobile.notifications.relay`),e[26]=r,e[27]=M);let N=M,P;e[28]===r?P=e[29]:(P=r(`mobile.notifications.identity`),e[28]=r,e[29]=P);let F=P,I,L;e[30]!==l||e[31]!==T||e[32]!==p||e[33]!==d||e[34]!==x||e[35]!==t||e[36]!==D||e[37]!==C||e[38]!==y||e[39]!==F||e[40]!==i||e[41]!==h||e[42]!==N||e[43]!==k||e[44]!==j||e[45]!==o||e[46]!==_?(I=()=>{if(!Kf())return;if(!t){Gf.stop().catch(Xp);return}let e=!1,r=t=>{e||(e=!0,J.error(t))},a=Jf({plugin:Gf,resolveConfig:()=>qf({service:o,alerts:l,connecting:d,connected:p,reconnecting:h,unavailable:_,gap:y,error:C,auth:T,endpoint:D,response:k,server:j,relay:N,identity:F},i),onState:e=>{(e===`denied`||e===`unavailable`)&&r(e===`denied`?x:_)},onError:()=>r(_)}),c=s(()=>{a.refresh()}),u=n(e=>{let{reason:t}=e;t===`invalidate`?a.stop():t!==`endpoint-switch`&&a.refresh()});return a.refresh(),()=>{c(),u(),a.dispose()}},L=[t,i,o,l,d,p,h,_,y,x,C,T,D,k,j,N,F],e[30]=l,e[31]=T,e[32]=p,e[33]=d,e[34]=x,e[35]=t,e[36]=D,e[37]=C,e[38]=y,e[39]=F,e[40]=i,e[41]=h,e[42]=N,e[43]=k,e[44]=j,e[45]=o,e[46]=_,e[47]=I,e[48]=L):(I=e[47],L=e[48]),(0,Z.useEffect)(I,L)}function Xp(){console.warn(`[Native notifications] stop failed`)}function Zp(e){return e.nativeNotificationsEnabled}function Qp(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Ra,{children:(0,$.jsx)(Qd,{...e})}),t[0]=e,t[1]=n),n}function $p(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Ra,{children:(0,$.jsx)(Vi,{...e})}),t[0]=e,t[1]=n),n}function em(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Ra,{children:(0,$.jsx)(Ei,{...e})}),t[0]=e,t[1]=n),n}function tm(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Ra,{children:(0,$.jsx)(Ol,{...e})}),t[0]=e,t[1]=n),n}function nm(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Ra,{children:(0,$.jsx)(gl,{...e})}),t[0]=e,t[1]=n),n}function rm(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ra,{children:(0,$.jsx)(Ns,{})}),e[0]=t):t=e[0],t}var im=`mobile-direct-diff`,am=`mobile-turn-diff`,om=`mobile-direct-file`,sm=`mobile-files`,cm=`mobile-changes`,lm=`mobile-mcp`,um=`mobile-settings`,dm=`mobile-update`,fm=`mobile-overflow-menu`,pm=320,mm=380,hm=280,gm=560,_m=380,vm=e=>Math.min(gm,Math.max(hm,Math.round(e))),ym=(e,t)=>{let n=e.current;n&&(n.style.width=`${t}px`,n.style.minWidth=`${t}px`,n.style.maxWidth=`${t}px`,n.style.setProperty(`--yuri-ipad-sidebar-width`,`${t}px`))};function bm(e,t,n){let r=(0,Q.c)(17),i=Z.useRef(null),a;r[0]!==n||r[1]!==t?(a=()=>{if(typeof window>`u`)return n;let e=Number.parseInt(window.localStorage.getItem(t)??``,10);return Number.isFinite(e)?Math.min(gm,Math.max(hm,e)):n},r[0]=n,r[1]=t,r[2]=a):a=r[2];let[o,s]=Z.useState(a),[c,l]=Z.useState(!1),u=Z.useRef(0),d=Z.useRef(o),f=Z.useRef(null),p=Z.useRef(null),m;r[3]===o?m=r[4]:(m=e=>{try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}p.current=e.pointerId,u.current=e.clientX,d.current=o,f.current=o,l(!0),e.preventDefault()},r[3]=o,r[4]=m);let h=q(m),g;r[5]===e?g=r[6]:(g=t=>{if(p.current!==t.pointerId)return;let n=t.clientX-u.current,r=vm(d.current+(e===`left`?n:-n));f.current!==r&&(f.current=r,ym(i,r))},r[5]=e,r[6]=g);let _=q(g),v;r[7]===t?v=r[8]:(v=e=>{if(p.current!==e.pointerId)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let n=vm(f.current??d.current);p.current=null,f.current=null,l(!1),s(n);try{window.localStorage.setItem(t,String(n))}catch{}},r[7]=t,r[8]=v);let y=q(v),b;r[9]!==h||r[10]!==y||r[11]!==_?(b={onPointerDown:h,onPointerMove:_,onPointerUp:y,onPointerCancel:y},r[9]=h,r[10]=y,r[11]=_,r[12]=b):b=r[12];let x=b,S;return r[13]!==x||r[14]!==c||r[15]!==o?(S={asideRef:i,width:o,isResizing:c,handleProps:x},r[13]=x,r[14]=c,r[15]=o,r[16]=S):S=r[16],S}var xm=e=>{let t=(0,Q.c)(12),{side:n,isResizing:r,ariaLabel:i,handleProps:a}=e,o=n===`left`?`right-0`:`left-0`,s;t[0]===o?s=t[1]:(s=ot(`absolute inset-y-0 z-30 w-6 cursor-col-resize touch-none`,o),t[0]=o,t[1]=s);let c=n===`left`?`right-0`:`left-0`,l=r&&`bg-[var(--interactive-border)]`,u;t[2]!==c||t[3]!==l?(u=ot(`absolute inset-y-0 w-[3px] transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(`div`,{className:u}),t[5]=u,t[6]=d);let f;return t[7]!==i||t[8]!==a||t[9]!==s||t[10]!==d?(f=(0,$.jsx)(`div`,{className:s,role:`separator`,"aria-orientation":`vertical`,"aria-label":i,...a,children:d}),t[7]=i,t[8]=a,t[9]=s,t[10]=d,t[11]=f):f=t[11],f},Sm=()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,Cm=()=>{Z.useEffect(()=>{if(!Sm())return;document.documentElement.classList.add(`yuri-native-app-active`);let e=!1,t=[],n=document.documentElement;n.classList.add(`yuri-capacitor-app`),window.Capacitor?.getPlatform?.()===`android`&&n.classList.add(`yuri-platform-android`);let r=e=>{n.style.setProperty(`--yuri-keyboard-inset`,`${Math.max(0,Math.round(e))}px`)};return ge(async()=>{let{StatusBar:e,Style:t}=await import(`./vendor-capacitor-status-bar-D9bcMr9Q.js`).then(e=>e.t);return{StatusBar:e,Style:t}},__vite__mapDeps([81,1,2])).then(async({StatusBar:n,Style:r})=>{if(e)return;let i=window.Capacitor?.getPlatform?.(),a=async()=>{if(i===`android`){let e=document.documentElement.classList.contains(`dark`),t=(e?localStorage.getItem(`splashBgDark`):localStorage.getItem(`splashBgLight`))||(e?`#121212`:`#FFFFFF`);await n.setOverlaysWebView({overlay:!1}).catch(()=>void 0),await n.setBackgroundColor({color:t}).catch(()=>void 0),await n.setStyle({style:e?r.Dark:r.Light}).catch(()=>void 0),await n.show().catch(()=>void 0);return}await n.setStyle({style:r.Default}).catch(()=>void 0),await n.setOverlaysWebView({overlay:!0}).catch(()=>void 0),await n.show().catch(()=>void 0)};await a();let o=window.setTimeout(()=>void a(),400);t.push(()=>window.clearTimeout(o));let{App:s}=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])),c=await s.addListener(`appStateChange`,({isActive:e})=>{if(e&&a(),!e&&i===`ios`){let e=document.activeElement;e instanceof HTMLElement&&ul(e)&&e.blur()}});if(e){c.remove();return}t.push(()=>void c.remove())}).catch(()=>void 0),ge(async()=>{let{Keyboard:e}=await import(`./vendor-capacitor-keyboard-BRVcFyc9.js`).then(e=>e.t);return{Keyboard:e}},__vite__mapDeps([82,1,2])).then(async({Keyboard:i})=>{if(e)return;let a=window.Capacitor?.getPlatform?.(),o=a===`android`;await i.setAccessoryBarVisible({isVisible:!1}).catch(()=>void 0);let s=`cubic-bezier(0.38, 0.7, 0.125, 1)`,c=null,l=null,u=0,d=!1,f=0,p=!1,m=(e,t)=>{n.style.setProperty(e,`${Math.max(0,Math.round(t))}px`)},h=()=>{c!==null&&(window.clearTimeout(c),c=null)},g=(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))},_=e=>e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`,v=e=>{for(let t of document.querySelectorAll(e))if(_(t))return t;return null},y=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.isContentEditable),b=()=>{for(let e of document.querySelectorAll(`.yuri-mobile-composer, .yuri-draft-center`))e.style.transition=``,e.style.transform=``},x=()=>{let e=document.querySelector(`.yuri-mobile-app-shell`);f=e&&parseFloat(getComputedStyle(e).paddingBottom)||0},S=!o&&a===`ios`,C=null,w=()=>{let e=document.activeElement,t=!(S&&ll(n.classList.contains(`yuri-native-ios-composer`),e))&&(y(e)?ul(e):C===!0);t!==C&&(C=t,r(t?0:u),m(`--yuri-kb-layout`,0),x(),m(`--yuri-kb-scroll-inset`,t?0:Math.max(0,u-f)),n.classList.remove(`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-caret-hold`,`yuri-kb-hide`),d=!1,p=!t&&u>0,n.classList.toggle(`yuri-native-ime`,t),il.setImeSync({enabled:t}).catch(()=>void 0))};if(o||S){r(0),m(`--yuri-kb-layout`,0),m(`--yuri-kb-scroll-inset`,0);let i=e=>{let t=e;if(S&&!C)return;let i=t.detail??t;if(typeof i.open!=`boolean`)return;if(typeof i.height==`number`&&(u=i.open?i.height/(o&&window.devicePixelRatio||1):0),o&&!C){r(u),x(),m(`--yuri-kb-scroll-inset`,Math.max(0,u-f)),n.classList.remove(`yuri-keyboard-open`,`yuri-kb-animating`),g(`yuri:keyboard-settled`,{open:i.open,nativeResize:!1});return}let a=i.phase===`start`;if(n.classList.toggle(`yuri-keyboard-open`,i.open||a),n.classList.toggle(`yuri-kb-animating`,a),a){g(`yuri:keyboard-anim`,{phase:i.open?`show`:`hide`,durationMs:i.durationMs??0,nativeResize:!0});return}let s=ul(document.activeElement);o&&!i.open&&y(document.activeElement)&&s&&document.activeElement.blur(),!i.open&&(o||!s)&&g(`yuri:keyboard-intent`,{open:!1}),g(`yuri:keyboard-settled`,{open:i.open,nativeResize:!0})};window.addEventListener(`yuri:ime-state`,i),t.push(()=>window.removeEventListener(`yuri:ime-state`,i)),e||t.push(ol()),w(),document.addEventListener(`focusin`,w,!0);let a=new MutationObserver(w);if(a.observe(n,{attributes:!0,attributeFilter:[`class`]}),t.push(()=>{a.disconnect(),document.removeEventListener(`focusin`,w,!0),n.classList.remove(`yuri-native-ime`),il.setImeSync({enabled:!1}).catch(()=>void 0)}),o)return}let T=()=>!(S&&C),E=`yuri.iosImeHeightRatio.v1`,D=e=>Number.isFinite(e)?Math.min(.68,Math.max(.28,e)):.39,O=()=>{try{let e=D(Number.parseFloat(localStorage.getItem(E)??``));return Math.round(window.innerHeight*e)}catch{return Math.round(window.innerHeight*.39)}},k=e=>{if(!(e<=0||window.innerHeight<=0))try{localStorage.setItem(E,String(D(e/window.innerHeight)))}catch{}},A=e=>{x();let t=Math.max(0,e-f);r(e),m(`--yuri-kb-layout`,e),m(`--yuri-kb-scroll-inset`,0),d=!0,b(),window.scrollTo(0,0),document.body.scrollTop!==0&&(document.body.scrollTop=0);let n=document.activeElement instanceof Element?document.activeElement.closest(`.yuri-mobile-composer`):null;return(n&&_(n)?n:v(`.yuri-mobile-composer`))?.scrollIntoView({block:`end`,inline:`nearest`}),t},j=e=>{if(!T()||ll(n.classList.contains(`yuri-native-ios-composer`),document.activeElement)||e.detail?.open!==!0||d||y(document.activeElement)&&!ul(document.activeElement))return;p=!0,n.classList.remove(`yuri-kb-hide`),n.classList.add(`yuri-keyboard-open`);let t=u>0?u:O(),r=A(t);g(`yuri:keyboard-anim`,{phase:`show`,slide:r,durationMs:0,easing:s}),g(`yuri:keyboard-settled`,{open:!0})};window.addEventListener(`yuri:keyboard-intent`,j);let M=await i.addListener(`keyboardWillShow`,e=>{if(!T()||ll(n.classList.contains(`yuri-native-ios-composer`),document.activeElement))return;h(),u=e.keyboardHeight,k(u);let t=ul(document.activeElement)||n.classList.contains(`yuri-keyboard-open`)&&!y(document.activeElement);if(p=!0,n.classList.remove(`yuri-kb-hide`),l!==null&&(window.clearTimeout(l),l=null),!t){r(u),m(`--yuri-kb-layout`,0),x(),m(`--yuri-kb-scroll-inset`,Math.max(0,u-f)),n.classList.remove(`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-caret-hold`),b(),d=!1,g(`yuri:keyboard-settled`,{open:!0});return}n.classList.add(`yuri-keyboard-open`);let i=A(u);g(`yuri:keyboard-settled`,{open:!0}),g(`yuri:keyboard-anim`,{phase:`show`,slide:i,durationMs:0,easing:s})}),N=()=>{p||(window.scrollTo(0,0),document.body.scrollTop!==0&&(document.body.scrollTop=0))},P=()=>{p=!1,h(),l!==null&&(window.clearTimeout(l),l=null),n.classList.remove(`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-caret-hold`,`yuri-kb-hide`),r(0),m(`--yuri-kb-scroll-inset`,0),m(`--yuri-kb-layout`,0),d=!1,b(),N(),window.setTimeout(N,350)},F=()=>{if(!T())return;if(n.classList.contains(`yuri-native-ios-composer`)){P(),g(`yuri:keyboard-settled`,{open:!1});return}if(!p)return;p=!1,h(),ul(document.activeElement)||g(`yuri:keyboard-intent`,{open:!1}),l!==null&&(window.clearTimeout(l),l=null),n.classList.remove(`yuri-kb-caret-hold`,`yuri-kb-animating`);let e=Math.max(0,u-f);n.classList.remove(`yuri-keyboard-open`),r(0),m(`--yuri-kb-scroll-inset`,0),m(`--yuri-kb-layout`,0),d=!1,b(),N(),window.setTimeout(N,350),g(`yuri:keyboard-anim`,{phase:`hide`,slide:e,durationMs:0,easing:s}),n.classList.add(`yuri-kb-animating`,`yuri-kb-hide`),c=window.setTimeout(()=>{c=null,n.classList.remove(`yuri-kb-animating`,`yuri-kb-hide`),g(`yuri:keyboard-settled`,{open:!1})},260)},I=await i.addListener(`keyboardWillHide`,F),L=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.isContentEditable),R=e=>{if(T()&&p&&L(e.target)){if(dl(e.relatedTarget)){m(`--yuri-kb-scroll-inset`,0);return}window.setTimeout(()=>{if(p&&!ul(document.activeElement)){if(L(document.activeElement)){h(),n.classList.remove(`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-caret-hold`,`yuri-kb-hide`),r(u),m(`--yuri-kb-layout`,0),x(),m(`--yuri-kb-scroll-inset`,Math.max(0,u-f)),d=!1,b(),g(`yuri:keyboard-intent`,{open:!1}),g(`yuri:keyboard-settled`,{open:!0});return}F()}},0)}};if(document.addEventListener(`focusout`,R,!0),e){h(),document.removeEventListener(`focusout`,R,!0),window.removeEventListener(`yuri:keyboard-intent`,j),M.remove(),I.remove();return}t.push(h,()=>{l!==null&&(window.clearTimeout(l),l=null)},()=>document.removeEventListener(`focusout`,R,!0),()=>window.removeEventListener(`yuri:keyboard-intent`,j),()=>void M.remove(),()=>void I.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e()),n.classList.remove(`yuri-capacitor-app`,`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-hide`,`yuri-kb-caret-hold`,`yuri-platform-android`),n.style.removeProperty(`--yuri-keyboard-inset`),n.style.removeProperty(`--yuri-kb-shift`),n.style.removeProperty(`--yuri-kb-layout`),n.style.removeProperty(`--yuri-kb-scroll-inset`)}},[])},wm=e=>{let t=Z.useRef(!1);Z.useEffect(()=>{if(!Sm())return;let n=!1,r=[],i=()=>{t.current&&(t.current=!1,e())},a=()=>{if(document.visibilityState===`hidden`){t.current=!0;return}i()};return document.addEventListener(`visibilitychange`,a),r.push(()=>document.removeEventListener(`visibilitychange`,a)),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:e})=>{if(n)return;let a=await e.getState().catch(()=>null);if(n)return;a&&document.documentElement.classList.toggle(`yuri-native-app-active`,a.isActive);let o=await e.addListener(`appStateChange`,({isActive:e})=>{if(document.documentElement.classList.toggle(`yuri-native-app-active`,e),!e){t.current=!0;return}i()}),s=await e.addListener(`resume`,i);if(n){o.remove(),s.remove();return}r.push(()=>void o.remove(),()=>void s.remove())}).catch(()=>void 0),()=>{n=!0,r.forEach(e=>e()),document.documentElement.classList.remove(`yuri-native-app-active`)}},[e])},Tm=e=>{Z.useEffect(()=>{if(!Sm())return;let t=!1,n=null;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:r})=>{if(t)return;let i=await r.addListener(`backButton`,()=>{e()||r.minimizeApp().catch(()=>void 0)});if(t){i.remove();return}n=()=>void i.remove()}).catch(()=>void 0),()=>{t=!0,n?.()}},[e])},Em=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Dm={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},Om=1e3,km=e=>{let t=Em(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},Am=(e,t)=>km(e?e.path:t),jm=({connection:e,onActiveConnectionDeleted:t,onConnect:n})=>{let{t:r}=Ee(),i=e,{connections:a,isBusy:o,isPasswordBusy:s,error:c,pendingConnection:l,connect:u,submitPassword:d,cancelPassword:f,renameConnection:p,removeConnection:m,subscribeConnected:h,setError:g}=i,[_,v]=Z.useState(null),y=_?a.find(e=>e.id===_)??null:null,[b,x]=Z.useState(null),[S,C]=Z.useState(``),[w,T]=Z.useState(``),[E,D]=Z.useState(!1),O=Z.useId(),k=Z.useId(),[A,j]=Z.useState(``),[M,N]=Z.useState(!1),P=Z.useMemo(()=>xs(),[]),[F,I]=Z.useState(null),[L,R]=Z.useState(null),ee=q(()=>{D(!1),T(``),n()});Z.useEffect(()=>h(ee),[ee,h]);let z=q(()=>{v(null),C(``),R(null),g(null),D(!1)}),B=q(()=>{o||M||(D(!1),g(null))}),V=q(()=>{o||M||z()}),te=q(e=>{e.preventDefault(),!(!_||!S.trim())&&p(_,S).then(e=>{e&&z()})}),H=q(e=>{i.redeemPairingConnection(e)}),ne=q(()=>{g(r(`mobile.connect.link.invalid`))}),U=q(async()=>{if(!M){g(null),R(null),N(!0);try{let e=await Ss();switch(e.status){case`ok`:await u({url:e.url,label:e.label,clientToken:e.clientToken});break;case`pairing`:await i.redeemPairingConnection(e.pairing);break;case`permission-denied`:g(r(`mobile.connect.scan.permissionDenied`));break;case`invalid`:g(r(`mobile.connect.scan.invalid`));break;case`unsupported`:g(r(`mobile.connect.scan.unsupported`));break;case`failed`:g(r(`mobile.connect.scan.failed`))}}catch{g(r(`mobile.connect.scan.failed`))}finally{N(!1)}}}),re=q(e=>{e.preventDefault(),d(A)}),W=q(()=>{j(``),f()}),ie=q(e=>{x(t=>t===e?null:e)}),ae=q(e=>{x(null),_===e&&z();let n=a.length===1;m(e).then(e=>{e&&(n||ke(e))&&t()})});if(l)return l.reason===`pairing`?(0,$.jsx)(`div`,{className:`yuri-settings-page-content`,children:(0,$.jsx)(Ha,{label:r(`mobile.connect.pairing.expired`),itemId:`instances.manage`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-col gap-3`,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:l.label}),a.some(e=>e.id===l.id)?(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,disabled:o||M,"aria-label":r(`mobile.instances.deleteAria`,{label:l.label}),onClick:()=>{x(l.id),W()},children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-5`})}):null]}),(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:r(`mobile.connect.pairing.reconnectHint`)}),c?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:c}):null,P?(0,$.jsxs)(Y,{size:`lg`,disabled:o||M,onClick:()=>void U(),children:[(0,$.jsx)(X,{name:`scan-2`,className:`size-5`}),r(`mobile.connect.scanQr`)]}):null,(0,$.jsx)(Y,{variant:P?`ghost`:`default`,size:`lg`,disabled:o||M,onClick:()=>{W(),D(!0)},children:r(`mobile.connect.link.useLink`)})]})})}):(0,$.jsx)(`div`,{className:`yuri-settings-page-content`,children:(0,$.jsx)(Ha,{label:r(`mobile.connect.password.label`),itemId:`instances.manage`,children:(0,$.jsxs)(`form`,{className:`yuri-settings-group-row flex flex-col gap-3`,onSubmit:re,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`lock`,className:`size-[18px]`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label text-foreground`,children:l.label}),(0,$.jsx)(`p`,{className:`truncate typography-small text-muted-foreground`,children:l.candidates.some(e=>e.kind===`direct`)?Ne(l):r(`mobile.connect.relay.badge`)})]})]}),(0,$.jsx)(`input`,{...Dm,value:A,onChange:e=>j(e.target.value),placeholder:r(`mobile.connect.password.placeholder`),"aria-label":r(`mobile.connect.password.label`),type:`password`,autoFocus:!0,className:`h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`}),c?(0,$.jsx)(`p`,{role:`alert`,className:`px-1 typography-small text-[var(--status-error)]`,children:c}):null,(0,$.jsx)(Y,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,disabled:s||!A.trim(),children:r(s?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full`,onClick:W,children:r(`mobile.connect.cancelPassword`)})]})})});let oe=(0,$.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:te,children:[(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block typography-ui-label text-foreground`,children:r(`mobile.instances.label.label`)}),(0,$.jsx)(Xn,{value:S,onChange:e=>C(e.target.value),placeholder:r(`mobile.instances.label.placeholder`),autoComplete:`off`,autoCapitalize:`words`,autoCorrect:`off`,spellCheck:!1,maxLength:120,autoFocus:!0,disabled:o||M,className:`h-12 w-full text-[16px]`})]}),c?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:c}):null,(0,$.jsx)(Y,{type:`submit`,size:`lg`,className:`w-full`,disabled:o||M||!S.trim(),children:r(`mobile.instances.saveEdit`)})]});return(0,$.jsxs)(`div`,{className:`yuri-settings-page-content`,children:[(0,$.jsx)(Ha,{label:r(`mobile.connect.saved.title`),itemId:`instances.manage`,children:a.length>0?a.map(e=>{let t=b===e.id,n=ke(e),i=F===e.id,a=r(i?`mobile.connect.connecting`:n?`mobile.instances.status.connected`:`mobile.instances.status.saved`);return(0,$.jsxs)(Z.Fragment,{children:[(0,$.jsxs)(`div`,{className:ot(`yuri-settings-group-row relative flex items-center`,t&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`),children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`desktopHostSwitcher.actions.switchToAria`,{instance:e.label}),"data-mobile-press-feedback":`none`,className:`absolute inset-0 z-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:pointer-events-none`,onClick:()=>{n||(g(null),R(e.id),I(e.id),u({id:e.id,candidates:e.candidates,clientToken:e.clientToken,label:e.label}).finally(()=>I(null)))},disabled:n||o&&!i||t,style:{touchAction:`manipulation`}}),(0,$.jsxs)(`div`,{className:`pointer-events-none relative z-[1] flex min-w-0 flex-1 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`server`,className:`size-[18px]`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:e.label})}),(0,$.jsx)(`span`,{className:ot(`block truncate typography-small`,n&&!i?`text-[var(--status-success)]`:`text-muted-foreground`),children:a})]})]}),(0,$.jsxs)(`div`,{className:`relative z-10 flex shrink-0 items-center gap-0.5 pr-2`,children:[t?(0,$.jsxs)(`button`,{type:`button`,"aria-label":r(`mobile.instances.confirmDeleteAria`,{label:e.label}),className:`flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-destructive px-3 text-destructive-foreground transition-opacity active:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,onClick:()=>ae(e.id),style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:r(`mobile.instances.delete`)})]}):i?(0,$.jsx)(`span`,{className:`flex size-9 items-center justify-center text-muted-foreground`,"aria-hidden":!0,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-[18px] animate-spin`})}):(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`mobile.instances.edit`),className:`flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>{v(e.id),C(e.label),R(null),g(null)},style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`edit`,className:`size-[18px]`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":r(t?`mobile.instances.cancelDeleteAria`:`mobile.instances.deleteAria`,{label:e.label}),className:`flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>ie(e.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:t?`close`:`delete-bin`,className:`size-[18px]`})})]})]}),c&&L===e.id&&!t?(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,role:`alert`,children:(0,$.jsx)(`p`,{className:`typography-small text-[var(--status-error)]`,children:c})}):null]},e.id)}):(0,$.jsx)(`div`,{className:`yuri-settings-group-row flex items-center justify-center text-center typography-small text-muted-foreground`,children:r(`mobile.connect.saved.empty`)})}),(0,$.jsx)(Ha,{label:r(`mobile.instances.addTitle`),children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-col gap-3`,children:[P?(0,$.jsxs)(Y,{type:`button`,size:`lg`,className:`w-full`,onClick:()=>void U(),disabled:o||M,children:[(0,$.jsx)(X,{name:`scan-2`,className:ot(`size-[18px]`,M&&`animate-pulse`)}),r(`mobile.connect.scanQr`)]}):null,(0,$.jsx)(Y,{type:`button`,variant:P?`ghost`:`default`,size:`lg`,className:`w-full`,disabled:o||M,onClick:()=>{R(null),g(null),D(!0)},children:r(`mobile.connect.link.useLink`)}),c&&!E&&!y&&!L?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:c}):null]})}),(0,$.jsx)(wr,{id:`mobile-instance-edit-${k}`,open:y!==null,onOpenChange:e=>{e||V()},fitContent:!0,ariaLabel:r(`mobile.instances.editTitle`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.connect.options.resize`),children:(0,$.jsx)(Gr,{className:`px-5 pb-5 pt-1`,disableHorizontal:!0,fillContainer:!1,children:oe})}),(0,$.jsx)(wr,{id:`mobile-instance-add-${O}`,open:E,onOpenChange:e=>{e||B()},fitContent:!0,title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:r(`mobile.connect.link.useLink`)}),ariaLabel:r(`mobile.connect.link.useLink`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.connect.options.resize`),children:(0,$.jsx)(Gr,{className:`px-5 py-5`,disableHorizontal:!0,fillContainer:!1,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:r(`mobile.connect.link.help`)}),(0,$.jsx)(ws,{value:w,onValueChange:e=>{T(e),g(null)},showPasteButton:!0,disabled:o||M,isBusy:o,inputClassName:`min-w-0 flex-1 text-[16px]`,buttonVariant:`default`,buttonClassName:`yuri-welcome-primary w-full`,error:c,onRedeem:H,onInvalid:ne})]})})})]})},Mm=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`},Nm=e=>{let t=(0,Q.c)(13),{icon:n,iconNode:r,label:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=r??(n?(0,$.jsx)(X,{name:n,className:`size-[18px]`}):null),t[0]=n,t[1]=r,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},Pm=e=>{let t=(0,Q.c)(55),{open:n,onClose:r,anchorRef:i,contextDisplay:a,branchLabel:o,usageGroups:s,usageDisplayMode:c,isUsageLoading:l,timeFormatPreference:u}=e,{t:d}=Ee(),f=Z.useRef(null),[p,m]=Z.useState(n),[h,g]=Z.useState(!1),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=_(),t[0]=v):v=t[0];let y=v,b=Z.useRef(null),[x,S]=Z.useState(null),C,w;t[1]!==i||t[2]!==n||t[3]!==p?(C=()=>{if(!n||!y||!p)return;let e=()=>{let e=i.current?.getBoundingClientRect(),t=b.current?.getBoundingClientRect();if(!e||!t){S(null);return}let n=e.left-t.left,r=Math.min(Math.max(n,8),Math.max(8,t.width-_m-8));S(r)};e();let t=b.current;if(typeof ResizeObserver>`u`||!t)return;let r=new ResizeObserver(e);return r.observe(t),()=>r.disconnect()},w=[i,y,n,p],t[1]=i,t[2]=n,t[3]=p,t[4]=C,t[5]=w):(C=t[4],w=t[5]),Z.useLayoutEffect(C,w);let T=y&&x!==null,E,D;t[6]!==n||t[7]!==p?(E=()=>{if(n){m(!0),g(!1);return}if(!p)return;g(!0);let e=window.setTimeout(()=>{m(!1),g(!1)},140);return()=>window.clearTimeout(e)},D=[n,p],t[6]=n,t[7]=p,t[8]=E,t[9]=D):(E=t[8],D=t[9]),Z.useEffect(E,D);let O,k;t[10]!==r||t[11]!==n?(O=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},k=[r,n],t[10]=r,t[11]=n,t[12]=O,t[13]=k):(O=t[12],k=t[13]),Z.useEffect(O,k);let A,j;if(t[14]!==i||t[15]!==r||t[16]!==n?(A=()=>{if(!n)return;let e=e=>{let t=e.target;if(!(t instanceof Node)){r();return}f.current?.contains(t)||i.current?.contains(t)||r()};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`wheel`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`wheel`,e,!0)}},j=[i,r,n],t[14]=i,t[15]=r,t[16]=n,t[17]=A,t[18]=j):(A=t[17],j=t[18]),Z.useEffect(A,j),!p)return null;let M;t[19]===d?M=t[20]:(M=d(`mobile.header.openMetadataAria`),t[19]=d,t[20]=M);let N=T?`absolute origin-top-left`:`mx-3 mt-2`,P=h?`pointer-events-none`:`pointer-events-auto`,F;t[21]!==N||t[22]!==P?(F=ot(`overflow-x-hidden overflow-y-auto overscroll-contain rounded-[20px] yuri-mobile-overlay-surface p-2 will-change-transform`,N,P),t[21]=N,t[22]=P,t[23]=F):F=t[23];let I=`${h?`session-metadata-out`:`session-metadata-in`} ${h?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,L;t[24]!==x||t[25]!==T?(L=T?{top:8,left:x??8,width:`min(${_m}px, calc(100% - 16px))`}:null,t[24]=x,t[25]=T,t[26]=L):L=t[26];let R;t[27]!==I||t[28]!==L?(R={animation:I,maxHeight:`min(72dvh, calc(100dvh - var(--yuri-safe-area-top, 0px) - var(--yuri-header-height, 56px) - 1rem))`,...L},t[27]=I,t[28]=L,t[29]=R):R=t[29];let ee;t[30]===d?ee=t[31]:(ee=d(`mobile.header.metadata.branch`),t[30]=d,t[31]=ee);let z;t[32]!==o||t[33]!==ee?(z=(0,$.jsx)(Nm,{icon:`git-branch`,label:ee,children:o}),t[32]=o,t[33]=ee,t[34]=z):z=t[34];let B;t[35]!==a||t[36]!==d?(B=a?(0,$.jsx)(Nm,{iconNode:(0,$.jsx)(Rs,{percentage:a.percentage,pending:a.pending}),label:d(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsx)(`span`,{className:ot(`font-semibold`,a.colorClass),children:a.pending?d(`contextUsage.pending`):`${a.percentage.toFixed(1)}%`}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:a.tokens})]})}):null,t[35]=a,t[36]=d,t[37]=B):B=t[37];let V;t[38]!==l||t[39]!==u||t[40]!==c||t[41]!==s?(V=(0,$.jsx)(Fm,{groups:s,displayMode:c,isLoading:l,timeFormatPreference:u}),t[38]=l,t[39]=u,t[40]=c,t[41]=s,t[42]=V):V=t[42];let te;t[43]!==z||t[44]!==B||t[45]!==V?(te=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[z,B,V]}),t[43]=z,t[44]=B,t[45]=V,t[46]=te):te=t[46];let H;t[47]!==M||t[48]!==F||t[49]!==R||t[50]!==te?(H=(0,$.jsx)(`div`,{ref:f,role:`dialog`,"aria-label":M,className:F,style:R,children:te}),t[47]=M,t[48]=F,t[49]=R,t[50]=te,t[51]=H):H=t[51];let ne;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(`style`,{children:`
|
|
21
|
+
@keyframes session-metadata-in {
|
|
22
|
+
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
23
|
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
24
|
+
}
|
|
25
|
+
@keyframes session-metadata-out {
|
|
26
|
+
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
27
|
+
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
28
|
+
}
|
|
29
|
+
`}),t[52]=ne):ne=t[52];let U;return t[53]===H?U=t[54]:(U=(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:[H,ne]}),t[53]=H,t[54]=U),U},Fm=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)(Ar,{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=Pi(e.rows.map(Hm),n),o=r===`remaining`?t.window.remainingPercent:t.window.usedPercent,s=ar(t.window.valueLabel,o),c=er(t.window.resetAt,t.window.resetAfterFormatted??t.window.resetAtFormatted,a);return(0,$.jsxs)(Z.Fragment,{children:[i?(0,$.jsx)(`div`,{className:ot(`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:ot(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,Mm(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},Im=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:ot(`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:ot(`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)(jo,{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:fm,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:Um,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},Lm=Z.memo(function(e){let t=(0,Q.c)(90),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=Ee(),{git:d}=se(),f=Ud(i??``,a||void 0),p=f??l,m=Z.useRef(null),h=St(i??``,a||void 0),g=Or(o),_=Dr(o),v=Er(Wm),y=Er(Gm),b=dt(Km),x=dt(qm),S=dt(Jm),C=dt(Ym),w;t[0]===i?w=t[1]:(w=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=w);let T=kt(w),E=ii(Xm),D=ii(Zm),O=ii(Qm),k=ii($m),A=ii(eh),j=ii(th),M=_e(nh);fi();let N,P;t[2]!==v||t[3]!==d||t[4]!==o?(N=()=>{o&&v(o,d)},P=[v,d,o],t[2]=v,t[3]=d,t[4]=o,t[5]=N,t[6]=P):(N=t[5],P=t[6]),Z.useEffect(N,P);let F,I;t[7]!==y||t[8]!==d||t[9]!==o?(F=()=>{if(o)return gt.onGitRefreshHint(e=>{Em(e.directory)===o&&y(o,d)})},I=[y,d,o],t[7]=y,t[8]=d,t[9]=o,t[10]=F,t[11]=I):(F=t[10],I=t[11]),Z.useEffect(F,I);let L,R;t[12]===D?(L=t[13],R=t[14]):(L=()=>{D()},R=[D],t[12]=D,t[13]=L,t[14]=R),Z.useEffect(L,R);let ee,z;t[15]===A?(ee=t[16],z=t[17]):(ee=()=>{jr(A)},z=[A],t[15]=A,t[16]=ee,t[17]=z),Z.useEffect(ee,z);let B,V;t[18]===n?(B=t[19],V=t[20]):(B=()=>{!n||ii.getState().isLoading||ii.getState().fetchAllQuotas()},V=[n],t[18]=n,t[19]=B,t[20]=V),Z.useEffect(B,V);let te;t[21]===h?te=t[22]:(te=Js(h),t[21]=h,t[22]=te);let H=te,ne;t[23]!==S||t[24]!==x||t[25]!==H||t[26]!==T?(ne=H??(T?{providerID:T.providerId,modelID:T.modelId}:null)??(x&&S?{providerID:x,modelID:S}:null),t[23]=S,t[24]=x,t[25]=H,t[26]=T,t[27]=ne):ne=t[27];let U=ne,re;if(t[28]!==C||t[29]!==U||t[30]!==b){let e=(U?b.find(e=>e.id===U.providerID):void 0)?.models.find(e=>e.id===U?.modelID),n;t[32]!==C||t[33]!==U?(n=U?C(U.providerID,U.modelID):void 0,t[32]=C,t[33]=U,t[34]=n):n=t[34];let r=n;re=Ws(e?.limit,`context`)??r?.limit?.context??0,t[28]=C,t[29]=U,t[30]=b,t[31]=re}else re=t[31];let W=re,ie=Nt(i??``,W,0,a||void 0),ae=ie?.pending?null:ie?.totalTokens??0,oe;t[35]!==W||t[36]!==s||t[37]!==ae?(oe=qs({totalTokens:ae,contextLimit:W,isDraft:s}),t[35]=W,t[36]=s,t[37]=ae,t[38]=oe):oe=t[38];let ce=oe,le;t[39]!==_?.current||t[40]!==g||t[41]!==u?(le=g===!0?_?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[39]=_?.current,t[40]=g,t[41]=u,t[42]=le):le=t[42];let ue=le,G;if(t[43]!==A||t[44]!==E||t[45]!==j||t[46]!==u){let e=new Map(E.map(rh)),n;t[48]===A?n=t[49]:(n=e=>A.includes(e.id),t[48]=A,t[49]=n),G=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 zi(Object.entries(n?.usage?.windows??{}),n?.usage?.accounts))r.push({key:`window-${e}`,label:$n(t.label??e),window:t});let i=Object.entries(n?.usage?.models??{}),a=j[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:$n(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[43]=A,t[44]=E,t[45]=j,t[46]=u,t[47]=G}else G=t[47];let de=G,K,fe;t[50]!==n||t[51]!==de?(K=()=>{!n||de.length===0||jr(de.map(ih))},fe=[n,de],t[50]=n,t[51]=de,t[52]=K,t[53]=fe):(K=t[52],fe=t[53]),Z.useEffect(K,fe);let pe;t[54]===c?pe=t[55]:(pe=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[54]=c,t[55]=pe);let q;t[56]!==p||t[57]!==f?(q=p?(0,$.jsx)(`span`,{className:ot(`block truncate`,f?`yuri-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:p}):null,t[56]=p,t[57]=f,t[58]=q):q=t[58];let me;t[59]!==pe||t[60]!==q?(me=(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:[pe,q]})}),t[59]=pe,t[60]=q,t[61]=me):me=t[61];let he;t[62]===u?he=t[63]:(he=u(`mobile.header.openMetadataAria`),t[62]=u,t[63]=he);let ge;t[64]===r?ge=t[65]:(ge=()=>r(ah),t[64]=r,t[65]=ge);let ve;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(ve={touchAction:`manipulation`},t[66]=ve):ve=t[66];let ye=ce?.percentage??0,be=ce?.pending,xe;t[67]!==ye||t[68]!==be?(xe=(0,$.jsx)(Rs,{percentage:ye,pending:be}),t[67]=ye,t[68]=be,t[69]=xe):xe=t[69];let Se;t[70]!==n||t[71]!==he||t[72]!==ge||t[73]!==xe?(Se=(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":he,"aria-expanded":n,onClick:ge,style:ve,children:xe}),t[70]=n,t[71]=he,t[72]=ge,t[73]=xe,t[74]=Se):Se=t[74];let Ce;t[75]===r?Ce=t[76]:(Ce=()=>r(!1),t[75]=r,t[76]=Ce);let we;t[77]!==ue||t[78]!==ce||t[79]!==O||t[80]!==n||t[81]!==k||t[82]!==Ce||t[83]!==M||t[84]!==de?(we=(0,$.jsx)(Pm,{open:n,onClose:Ce,anchorRef:m,contextDisplay:ce,branchLabel:ue,usageGroups:de,usageDisplayMode:k,isUsageLoading:O,timeFormatPreference:M}),t[77]=ue,t[78]=ce,t[79]=O,t[80]=n,t[81]=k,t[82]=Ce,t[83]=M,t[84]=de,t[85]=we):we=t[85];let Te;return t[86]!==me||t[87]!==Se||t[88]!==we?(Te=(0,$.jsxs)($.Fragment,{children:[me,Se,we]}),t[86]=me,t[87]=Se,t[88]=we,t[89]=Te):Te=t[89],Te}),Rm=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=Ee(),[a,o]=Z.useState(!1),s=O(e=>e.currentDirectory),c=Et(e=>e.currentSessionId),l=Z.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=Et(l)||s,d=Em(u)||null,f=Qe(e=>e.projects),p=Et(e=>e.availableWorktreesByProject),m=Z.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=Et(m),g=Ze(c),_=Et(e=>!!e.newSessionDraft?.open),v=Z.useMemo(()=>{let e=Em(u);return e&&Am((h?.projectDirectory?Ye(f,h.projectDirectory):null)??$e(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=q(()=>{o(!1),e()}),S=q(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Ls,{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)(Lm,{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:ot(`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:ot(`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":fm,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`more-2`,className:`size-5`})})]})})},zm=e=>{let t=(0,Q.c)(5),n=Is();if(!n.enabled){let n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Rm,{...e}),t[0]=e,t[1]=n),n}let r;return t[2]!==e||t[3]!==n?(r=(0,$.jsx)(Ic,{...e,scope:n}),t[2]=e,t[3]=n,t[4]=r):r=t[4],r},Bm=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=Ee(),r=xn();Ke(),qe();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`),[H,U]=Z.useState(!1),[re,W]=Z.useState(!1),ie=q(()=>{U(!1),W(!0)}),ae=q(()=>{if(U(!1),K.enabled){we.info(n(`remoteProjects.nativeCapabilityUnavailable`,{capability:n(`remoteDesktop.title`)}));return}ie()}),oe=q(()=>W(!1)),[se,ce]=Z.useState(!1),le=q(()=>U(e=>!e)),ue=q(()=>U(!1)),[G,de]=Z.useState(null),K=Is(),fe=A&&!K.enabled,pe=O(e=>e.currentDirectory),me=_e(e=>e.setSettingsPage),he=ci(e=>e.available),ge=ci(e=>e.runtimeType),ve=Z.useMemo(()=>Sm(),[]),ye=Z.useMemo(()=>xs(),[]),be=pe??null,{data:xe=[],refetch:Se}=ne({...Va(be),enabled:fe}),{refetch:Ce}=ne({...Ba(be),enabled:fe}),Te=Wa(e=>e.setMcpDraft),De=Wa(e=>e.setSelectedMcp),Oe=Dr(K.enabled?K.entry?.key??null:Em(pe)||null)?.files?.length??0;Z.useEffect(()=>gt.onDirectoryRequest(()=>ee(!0)),[]);let Ae=Z.useMemo(()=>_(),[]),je=At(e=>e.secondary?.kind??null),Me=Et(e=>K.enabled?null:e.currentSessionId),Ne=K.enabled?K.sessionId:Me,Pe=Et(e=>e.setCurrentSession),Fe=Z.useMemo(()=>e=>!K.enabled&&Ne?e.getDirectoryForSession(Ne):null,[Ne,K.enabled]),Ie=Et(Fe),Le=K.enabled?K.entry?.location.directory:Ie,Re=fr()===`portrait`,[Ve,He]=Z.useState(Ae&&!Re),[Ue,We]=Z.useState(null),J=q(e=>{if(e&&me(e),Ae){te(e?`page-content`:`nav`),F(!0);return}let t=At.getState();if(e){t.openSettingsFromCurrent();return}me(`home`),t.setActiveTab(`settings`)}),Ge=q(()=>{J(`instances`)}),Je=q(()=>{At.getState().openInstances()}),Ye=q(async t=>{if(!t){Je();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)||Je())}),Xe=q(()=>{At.getState().closeSecondary()}),Ze=q(async()=>{if(!z){B(!0);try{let t=await Ss();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)}}});Rr({enabled:!Ae,rootRoutesBlocked:i||u||f||g||y||o||fe||P||I||R||H});let Qe=q(()=>{let e=!Ve;e&&Re&&We(null),He(e)}),$e=q(()=>{if(b(!1),S(null),w(null),p(!1),h(null),Ae){de(null),We(`files`),Re&&He(!1);return}d(!0)}),tt=q(()=>{p(!1),h(null)}),nt=q(e=>{let t=e.path.trim();if(t){if(b(!1),S(null),w(null),de(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){$e();return}nt({path:rt}),_e.getState().setPendingFileFocusPath(null)}},[rt,Ae,$e,nt]);let it=q((e=null)=>{if(b(!1),S(null),w(null),E(null),p(!1),h(null),de(e),Ae){We(`changes`),Re&&He(!1);return}v(!0)}),at=q((e,t,n)=>{de(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=q(()=>{We(null),de(null),E(null)}),ct=q(e=>{if(Ue===e){st();return}e===`files`?$e():it()}),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=bm(`left`,`yuri.ipad.leftSidebarWidth`,pm),mt=bm(`right`,`yuri.ipad.rightSidebarWidth`,mm),ht=Z.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{it(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{it({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:at,openFile:({path:e,targetLine:t})=>{nt({path:e,targetLine:t})},openFiles:()=>$e(),openSettings:e=>{J(e)}}),[it,nt,$e,J,at]),_t=q(()=>{v(!1),de(null)}),vt=q(()=>{b(!1),E(null)});Sf(Z.useMemo(()=>({openSessions:()=>{if(Ae){He(!0);return}At.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?$e():e===`mcp`?j(!0):e===`instances`?Ge():e===`update`&&L(!0)},openChanges:({path:e,staged:t}={})=>{it(e?{path:e,staged:t===!0}:null)},openSettings:e=>{J(e)}}),[Ae,it,$e,Ge,J]));let yt=Z.useRef(null),bt=Z.useRef(null),xt=et(K.enabled?null:Ne,K.enabled?void 0:Le||pe||void 0),St=K.session?.parentID,Ct=K.enabled?St?{id:St,directory:Le}:null:xt,wt=q(()=>{Ct&&(K.enabled?K.openSession(Ct.id):Pe(Ct.id,Ct.directory))});Jp();let Tt=Z.useRef(0);Z.useEffect(()=>(Tt.current+=1,ce(!1),()=>{Tt.current+=1}),[Ne,K.key,K.entry]);let Dt=q(()=>{let e=Ne;if(!e||se)return;let t=Le||pe||void 0,i=++Tt.current;ce(!0),(async()=>{try{K.enabled?await K.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&&ce(!1)}})()}),Ot=!Ae&&(je===`chat`||je===`draft`);Z.useEffect(()=>{!Ae&&!Ot&&U(!1)},[Ae,Ot]),Z.useEffect(()=>{U(!1)},[Ne,K.key]);let kt=Ae&&s===`assistant`||!Ae&&!Ot||i||u||f||g||y||o||fe||P||I||R||H||re;Wf(bt,{onOpen:q(()=>{xr(Tr)?.finish(`commit`)}),onPreviewStart:q(()=>{xr(Tr)?.begin(`present`)}),onPreviewCancel:q(()=>{xr(Tr)?.finish(`cancel`)}),onProgress:q(e=>{e!==null&&xr(Tr)?.update(e)}),disabled:kt},Ae||Ot);let jt=q(e=>{yt.current=e});Tm(q(()=>re?(oe(),!0):H?(U(!1),!0):R?(ee(!1),!0):o?(window.dispatchEvent(new Event(`yuri:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):Br.backImmediately(`overlay`)?!0:f?(tt(),!0):u?(d(!1),!0):y?(vt(),!0):g?(_t(),!0):fe?(j(!1),!0):P?(F(!1),!0):I?(L(!1),!0):Br.requestAnimatedBack(`root`)||yt.current?.()?!0:s===`assistant`?(l(`chat`),!0):Ct?(wt(),!0):!1));let Mt=he&&(ge===`desktop`||ge===`web`),Nt=q(()=>{if(K.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),J(`mcp`)}),Pt=q(()=>{if(M)return;if(K.enabled&&!K.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=Et(e=>e.openNewSessionDraft),It=Z.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(K.enabled){if(!K.entry){we.error(n(`remoteProjects.host-unavailable`));return}K.openSession(null),Ae?l(`chat`):At.getState().openRemoteProject();return}if(Ae){l(`chat`),Ft();return}At.getState().openDraft()}}];return Ae||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>$e()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:Oe,onSelect:()=>it()}),K.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:()=>J()}),Ne&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:se,spinning:se,onSelect:Dt}),e.push({key:`remote-desktop`,icon:`computer`,label:n(`remoteDesktop.title`),onSelect:ae}),e},[Ne,Oe,Ae,se,it,$e,Ft,ae,J,Dt,K,l,Mt,n]);return(0,$.jsx)(Do,{remote:K.enabled,remoteState:K.owner?.state,sessionId:Ne??``,directory:Le||pe||void 0,active:Ae?s!==`assistant`:je===`chat`||K.enabled&&je===`draft`,children:(0,$.jsx)(ei,{actions:ht,children:(0,$.jsxs)(Es,{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:ot(`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)(xm,{side:`left`,isResizing:pt.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:pt.handleProps}):null,(0,$.jsx)(`div`,{className:ot(`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)(dr,{children:(0,$.jsx)(su,{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:re||void 0,"aria-hidden":re||void 0,children:Ae?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(zm,{onOpenSessions:()=>Qe(),menuOpen:H,onToggleMenu:le,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)(dr,{children:s===`assistant`?(0,$.jsx)(so,{}):(0,$.jsx)($p,{})})})})]}):(0,$.jsx)(qu,{className:`min-h-0 flex-1`,onAddProject:()=>ee(!0),onScanQr:ve&&ye?()=>{Ze()}:void 0,onSwitchInstance:ve?Ye:void 0,onRemoteDesktop:ie,remoteDesktopActive:re,instanceOptions:ve?e.connections.map(t=>({id:t.id,label:t.label,active:ke(t),disabled:e.isBusy})):void 0,onEnableAssistants:()=>{J(`assistants`)},instancesPage:ve?(0,$.jsx)(jm,{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)(jm,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:Ct?{id:Ct.id,directory:Ct.directory??null,...K.enabled?{onSelect:wt}:{}}:null,registerSecondaryBackHandler:jt,scheduledContent:(e,t)=>(0,$.jsx)(ta,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(Qp,{sessionId:K.enabled?K.sessionId??``:e.sessionId,directory:K.enabled?K.entry?.location.directory:e.directory,title:K.enabled?K.session?.title:void 0,onBack:()=>{ue(),Br.requestAnimatedBack(`root`)},onOpenMenu:le,onCloseMenu:ue,menuOpen:e.active&&H,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)(dr,{children:(0,$.jsx)($p,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:K.enabled?K.sessionId:e.sessionId||null,directory:K.enabled?K.entry?.location.directory??null:e.directory,viewKey:K.enabled?`${K.key}:${K.sessionId??`draft`}`:e.viewKey}})})})})})})}),Ae?(0,$.jsxs)(`aside`,{ref:mt.asideRef,className:ot(`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)(xm,{side:`right`,isResizing:mt.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:mt.handleProps}):null,(0,$.jsx)(`div`,{className:ot(`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)(dr,{children:ft===`files`?(0,$.jsx)(tm,{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)(Y,{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)(em,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,targetFilePath:T,navigationRequestKey:D,flushContent:!0})})]}):G?.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:G.toolPatches.length>1?n(`mobile.nav.changes`):G.path}),(0,$.jsx)(Y,{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)(em,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:G.path,targetLine:G.targetLine??null,toolPatches:G.toolPatches,singleFileView:G.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(nm,{onClose:st,initialDiffPath:G?.path??null,initialDiffStaged:G?.staged===!0,initialDiffTargetLine:G?.targetLine??null})}):null})]}):null,(0,$.jsx)(Hi,{open:R,onOpenChange:ee,forceMobile:!0}),(0,$.jsx)(Im,{open:H,onClose:()=>U(!1),items:It,rightOffset:Ae&&Ue?mt.width:0}),(0,$.jsx)(Qi,{}),re&&(0,$.jsx)(Id,{onClose:oe,instanceName:e.connections.find(ke)?.label}),u?(0,$.jsx)(wr,{id:sm,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)(dr,{children:(0,$.jsx)(tm,{onClose:()=>d(!1)})})}):null,f&&m?(0,$.jsx)(wr,{id:om,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)(dr,{children:(0,$.jsx)(tm,{onClose:tt,initialFilePath:m.path,directFilePreview:!0,hideFileHeader:!0},m.path)})}):null,(0,$.jsx)(wr,{id:am,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)(dr,{children:(0,$.jsx)(em,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,toolbarInSheetHeader:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,targetFilePath:T,navigationRequestKey:D,flushContent:!0})})}),g&&G?(0,$.jsx)(wr,{id:im,open:g,onOpenChange:e=>{e||_t()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:G.toolPatches&&G.toolPatches.length>1?n(`mobile.nav.changes`):G.path}),ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(dr,{children:G.toolPatches?.length?(0,$.jsx)(em,{hideStackedFileSidebar:!0,toolbarInSheetHeader:!0,diffScope:`turn`,targetFilePath:G.path,targetLine:G.targetLine??null,toolPatches:G.toolPatches,singleFileView:G.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(nm,{initialDiffPath:G.path,initialDiffStaged:G.staged,initialDiffTargetLine:G.targetLine??null,hideDiffHeader:!0})})}):g?(0,$.jsx)(wr,{id:cm,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)(dr,{children:(0,$.jsx)(nm,{onClose:_t,initialDiffPath:G?.path??null,initialDiffStaged:G?.staged===!0,initialDiffTargetLine:G?.targetLine??null})})}):null,fe?(0,$.jsx)(wr,{id:lm,open:fe,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)(Y,{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)(Y,{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:ot(`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)(dr,{children:(0,$.jsx)(Ea,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,P&&Ae?(0,$.jsx)(wr,{id:um,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)(dr,{children:(0,$.jsx)(qa,{forceMobile:!0,isWindowed:!0,initialMobileStage:V,visiblePageSlugs:[...gr],onClose:()=>F(!1),mobileInstancesPage:ve?(0,$.jsx)(jm,{connection:e,onConnect:()=>F(!1),onActiveConnectionDeleted:t}):void 0})})}):null,I?(0,$.jsx)(wr,{id:dm,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)(dr,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(Ga,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(Hc,{enabled:ve&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(dr,{children:(0,$.jsx)(ha,{})}),(0,$.jsx)(Zi,{})]})})})};function Vm({apis:e}){Z.useEffect(()=>nt(),[]);let{t}=Ee(),n=dt(e=>e.initializeApp),r=dt(e=>e.isInitialized),i=dt(e=>e.isConnected),a=dt(e=>e.connectionPhase),o=O(e=>e.currentDirectory),c=Et(e=>e.currentSessionId),l=Et(e=>!!e.newSessionDraft?.open),d=Et(e=>e.error),f=Et(e=>e.clearError),m=_e(e=>e.setIsMobile),h=li(e=>e.refreshStatus),g=Qe(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(()=>Sm(),[]),A=Z.useRef(0),j=Z.useRef(0),M=Ie(()=>{T(`done`),v(e=>e+1)});Cf(q(e=>{M.redeemPairingConnection(e)}));let N=wf({ready:k&&i&&r});Z.useEffect(()=>{!M.error||!p()||we.error(M.error)},[M.error]);let P=q(()=>{let t=p(),r=j.current+1;if(j.current=r,!t){Fe();return}let i=()=>{n(),h(e.github,{force:!0}),dt.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>=Om&&(A.current=o,window.dispatchEvent(new Event(`yuri:system-resume`)))});Cm(),wm(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){ja(),D();return}ba(e),At.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]),En({enabled:!k||!!p(),source:`mobileApp:recovery`}),Z.useEffect(()=>{i&&I.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=Em(t.path);if(n)try{if(!(Er.getState().directories.get(n)?.isGitRepo??await ge(()=>import(`./gitApi-BA93t0ww.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,58])))||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]),Gn(),Dn({enabled:!0}),Jn(),xa(),Zf({enabled:k&&i}),Yp();let F=nf(),L=!i&&a===`reconnecting`;if(!F)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(ur,{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)(ur,{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)(Y,{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)(Ts,{connection:M}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(ur,{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)(kn,{})]})]}):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)(ur,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(dr,{children:(0,$.jsx)(Ue,{sdk:I.getSdkClient(),directory:o||``,bootstrapDirectory:!(l&&c===null),children:(0,$.jsxs)(bn,{apis:e,children:[(0,$.jsx)(Gi,{}),(0,$.jsx)(Oa,{ready:r,children:(0,$.jsx)(Qn,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(Ma,{}),(0,$.jsx)(Kt,{}),(0,$.jsx)(rm,{}),(0,$.jsx)(Vn,{embeddedBackgroundWorkEnabled:r}),(0,$.jsx)(ji,{}),(0,$.jsx)(Io,{}),(0,$.jsx)(Ko,{}),(0,$.jsx)(Bm,{connection:M,onActiveConnectionDeleted:()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),At.getState().reset(),v(e=>e+1)}}),(0,$.jsx)(_n,{position:`top-center`,offset:`calc(var(--yuri-safe-area-top, 0px) + 16px)`}),r?(0,$.jsx)(Yi,{}):null,r?(0,$.jsx)(ea,{}):null,r?(0,$.jsx)(Ii,{autoStart:!1}):null]})})})]})},y)})}function Hm(e){return e.window}function Um(e){e.currentTarget.style.transform=`none`}function Wm(e){return e.ensureStatus}function Gm(e){return e.fetchStatus}function Km(e){return e.providers}function qm(e){return e.currentProviderId}function Jm(e){return e.currentModelId}function Ym(e){return e.getModelMetadata}function Xm(e){return e.results}function Zm(e){return e.loadSettings}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(),wn()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),gn(),Nn(),dn()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{po()})};function sh(e){yr(),oh(),_e.getState().setIsMobile(!0),xo(),mr(),pr();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)(Vm,{apis:r});(0,co.createRoot)(t).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(Yn,{children:(0,$.jsx)(Te,{children:(0,$.jsx)(Mn,{children:(0,$.jsx)(Fn,{children:(0,$.jsx)(Ui,{children:(0,$.jsx)(hn,{children:n?i:(0,$.jsx)(yn,{children:i})})})})})})})}))}export{sh as renderMobileApp};
|