@yuriai/web 0.2.20 → 0.2.24-beta.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.
Files changed (115) hide show
  1. package/dist/assets/{AgentAvatar-MK9jNcwx.js → AgentAvatar-uHQNjXpd.js} +1 -1
  2. package/dist/assets/AssistantView-CqihS590.js +3 -0
  3. package/dist/assets/{DiagramView-ys2UVvx1.js → DiagramView-CAl2hJW0.js} +1 -1
  4. package/dist/assets/{FadeInOnReveal-B1g8C4P7.js → FadeInOnReveal-C4jDW1zu.js} +1 -1
  5. package/dist/assets/{GuiPluginSurface-C1KQZUmj.js → GuiPluginSurface-D6-If8cj.js} +1 -1
  6. package/dist/assets/{GuiPluginWindow-D4TIvZDn.js → GuiPluginWindow-CBFALwNv.js} +1 -1
  7. package/dist/assets/Icon-B0ebXdpZ.js +1 -0
  8. package/dist/assets/{ImageLoadingPlaceholder-DM2ifWd8.js → ImageLoadingPlaceholder-BsOal94e.js} +1 -1
  9. package/dist/assets/{LoadingImage-BoaGSpZ_.js → LoadingImage-DU15BNuP.js} +1 -1
  10. package/dist/assets/MarkdownRenderer-D_rTN88T.js +2 -0
  11. package/dist/assets/{MarkdownRendererImpl-DL069I2q.js → MarkdownRendererImpl-DlSWKQY_.js} +1 -1
  12. package/dist/assets/{MarkstreamRendererImpl-CwR_p-oQ.js → MarkstreamRendererImpl-BSDk1Jis.js} +1 -1
  13. package/dist/assets/{MobileDetailNavigation-C7Z7mVZV.js → MobileDetailNavigation-B2IiMT5p.js} +1 -1
  14. package/dist/assets/{MobileResizableSheet-ChrM2_er.js → MobileResizableSheet-C5UIcZMP.js} +1 -1
  15. package/dist/assets/{MobileShareBridge-DtXwoQtk.js → MobileShareBridge-CfcbqwW6.js} +1 -1
  16. package/dist/assets/{MobileTabPageHeader-BT7U61qi.js → MobileTabPageHeader-9JAqOR2k.js} +1 -1
  17. package/dist/assets/{MultiRunWindow-CFWkmiwx.js → MultiRunWindow-BYI4hg_P.js} +1 -1
  18. package/dist/assets/{OnboardingScreen-Bb3wmiKY.js → OnboardingScreen-D5tX10Ru.js} +1 -1
  19. package/dist/assets/{OverlayScrollbar-DD6avzvO.js → OverlayScrollbar-Cd3itQWo.js} +1 -1
  20. package/dist/assets/SettingsView-BgwM4FwF.js +29 -0
  21. package/dist/assets/{SettingsWindow-jF7nPmJG.js → SettingsWindow-JHqJTA6L.js} +1 -1
  22. package/dist/assets/{TerminalView-Cms4rfIE.js → TerminalView-CqJgchfl.js} +1 -1
  23. package/dist/assets/{ToolOutputDialog-CBSb39qy.js → ToolOutputDialog-CrXMwUq9.js} +4 -4
  24. package/dist/assets/{YuriLogo-CeZsIqiE.js → YuriLogo-mo6nZ3PX.js} +1 -1
  25. package/dist/assets/{appThemeRegistry-Bps27som.js → appThemeRegistry-7-Ucu_cy.js} +1 -1
  26. package/dist/assets/{button--mt1oJ-H.js → button-RqfOQVDY.js} +1 -1
  27. package/dist/assets/{capgoAdapter-ZBPKiKyL.js → capgoAdapter-9z4borwr.js} +1 -1
  28. package/dist/assets/{collapsible-Dh2xZynB.js → collapsible-Dv8u92TF.js} +1 -1
  29. package/dist/assets/desktop-5DP3-Bao.js +1 -0
  30. package/dist/assets/{desktopHosts-B4HMNmrx.js → desktopHosts-CrVcscUO.js} +1 -1
  31. package/dist/assets/{desktopRelayRestore-CRl62mqn.js → desktopRelayRestore-DJFLfsuw.js} +1 -1
  32. package/dist/assets/{device-Coc5tapU.js → device-BKQ_0FdZ.js} +1 -1
  33. package/dist/assets/{diagram-CrQbE7QP.js → diagram-ChmjoQ5M.js} +1 -1
  34. package/dist/assets/{dialog-BG9W4FO9.js → dialog-BNwN9E77.js} +1 -1
  35. package/dist/assets/{dropdown-menu.styles-BOP49Dw2.js → dropdown-menu.styles-BeD-5cZr.js} +1 -1
  36. package/dist/assets/{es-CuWYQYZ1.js → es-BA49Soe0.js} +3 -3
  37. package/dist/assets/{fileMentionTouchSelection-m4Xsn0cx.js → fileMentionTouchSelection-3kl7GJMx.js} +1 -1
  38. package/dist/assets/{fileReferenceActions-BnPPqYXw.js → fileReferenceActions-B1o8IWgw.js} +1 -1
  39. package/dist/assets/{fr-yebDRPGw.js → fr-BC5SbQkf.js} +3 -3
  40. package/dist/assets/{gitApi-C1pkEDXu.js → gitApi-CdlAr0G6.js} +1 -1
  41. package/dist/assets/{gitApiHttp-CoNokuDM.js → gitApiHttp-Bnr4_wxy.js} +2 -2
  42. package/dist/assets/{host-BqNFap4A.js → host-DgJqhX6n.js} +1 -1
  43. package/dist/assets/{input-BMUm4I0i.js → input-0mf9njqM.js} +1 -1
  44. package/dist/assets/insertionBoundaries-CgOdACbG.js +1 -0
  45. package/dist/assets/{ja-f1wDEfxS.js → ja-ZVSLBCEX.js} +3 -3
  46. package/dist/assets/{ko-n8CMb8k9.js → ko-UEhdI-6j.js} +3 -3
  47. package/dist/assets/{main-djohnOii.js → main-F2ObdRqm.js} +2 -2
  48. package/dist/assets/main-nOs3EBA9.js +169 -0
  49. package/dist/assets/{markdownHeightCache-BWrnxGTO.js → markdownHeightCache-CghsqV5O.js} +1 -1
  50. package/dist/assets/{mcpQueries-BfSiXImW.js → mcpQueries-DS2belW7.js} +1 -1
  51. package/dist/assets/{miniChat-DXN8mcdi.js → miniChat-CnBDNbrx.js} +2 -2
  52. package/dist/assets/{mobile--08sYbKy.js → mobile-CV3-MHwD.js} +2 -2
  53. package/dist/assets/{mobileBackNavigation-EIV61ZvG.js → mobileBackNavigation-CX8dmR4X.js} +1 -1
  54. package/dist/assets/{multirun-Dfuqt2Sd.js → multirun-sEG8DT8R.js} +1 -1
  55. package/dist/assets/{native-config-Cswl9jqU.js → native-config-QhKCjYzE.js} +1 -1
  56. package/dist/assets/{persistence-CNEHspb4.js → persistence-BPb2hZ3c.js} +2 -2
  57. package/dist/assets/{pl-BpveZ1bR.js → pl-CtZa8Aps.js} +3 -3
  58. package/dist/assets/{platform-Q45KPuGv.js → platform-wGCQUVxr.js} +1 -1
  59. package/dist/assets/{projectMeta-CuVxfoYb.js → projectMeta-CVrggbn1.js} +1 -1
  60. package/dist/assets/{pt-BR-bq37AHb6.js → pt-BR-BLYFPwVu.js} +3 -3
  61. package/dist/assets/{readiness-DDF6yf-o.js → readiness-BtYBkmgM.js} +1 -1
  62. package/dist/assets/{renderElectronMiniChatApp-Cfs2xjgL.js → renderElectronMiniChatApp-yG8H5XZA.js} +2 -2
  63. package/dist/assets/renderMobileApp-QbFlyIjX.js +28 -0
  64. package/dist/assets/{runtimeConfig-DTkP4z43.js → runtimeConfig-JLSevBwB.js} +1 -1
  65. package/dist/assets/{runtimeEndpointReset-BMAP5ZCY.js → runtimeEndpointReset-CWadQNbz.js} +15 -15
  66. package/dist/assets/{scheduledTaskNavigation-7slq1geN.js → scheduledTaskNavigation-Dhcdlsyj.js} +1 -1
  67. package/dist/assets/{sessionChangeSummary-BYv_KUyn.js → sessionChangeSummary-BWq51EyC.js} +1 -1
  68. package/dist/assets/{sessionLookup-Cx0pE6yS.js → sessionLookup-CKLauQ7F.js} +1 -1
  69. package/dist/assets/{sortable-tabs-strip-D_efLXen.js → sortable-tabs-strip-B2s-35-E.js} +1 -1
  70. package/dist/assets/{speechSettingsQueries-BxHtdoOT.js → speechSettingsQueries-B95s6DcZ.js} +3 -3
  71. package/dist/assets/src-BWW10gG6.css +2 -0
  72. package/dist/assets/{store-CKBj6kYd.js → store-DRfILWJT.js} +3 -3
  73. package/dist/assets/{terminalApi-DFhCeMya.js → terminalApi-Cjd7Jry6.js} +1 -1
  74. package/dist/assets/{textarea-CNvFHvhC.js → textarea-Brud1txt.js} +1 -1
  75. package/dist/assets/{tooltip-C-gdI2Am.js → tooltip-Bs7jQMa0.js} +1 -1
  76. package/dist/assets/types-BecUO32k.js +2 -0
  77. package/dist/assets/{uk-Ds3imyqV.js → uk-CLu6Q5Pq.js} +3 -3
  78. package/dist/assets/{useAppFontEffects-Ucq0gPN8.js → useAppFontEffects-CW0A51vF.js} +53 -53
  79. package/dist/assets/{useDesktopWindowControlsLayout-BEscodj1.js → useDesktopWindowControlsLayout-CjGMTYs8.js} +1 -1
  80. package/dist/assets/{useEffectiveDirectory-BWRQNoDF.js → useEffectiveDirectory-Cu4UQ0_Y.js} +1 -1
  81. package/dist/assets/{useFontPreferences-DmeLn0t9.js → useFontPreferences-CGThMzt0.js} +1 -1
  82. package/dist/assets/{useMobileNavigationStore-DzkVc9H_.js → useMobileNavigationStore-BDtGCgi3.js} +16 -16
  83. package/dist/assets/useWorkerHighlightedLines-_RnSE1vt.js +7 -0
  84. package/dist/assets/{zh-CN-BNJ3ElZ9.js → zh-CN-794F19S6.js} +3 -3
  85. package/dist/assets/{zh-TW-C0jQloeH.js → zh-TW-CIVkGGCd.js} +3 -3
  86. package/dist/index.html +13 -13
  87. package/dist/mini-chat.html +13 -13
  88. package/dist/mobile.html +13 -13
  89. package/package.json +1 -1
  90. package/server/index.d.ts +9 -0
  91. package/server/index.js +10 -0
  92. package/server/lib/assistants/DOCUMENTATION.md +15 -0
  93. package/server/lib/assistants/harness.js +1 -4
  94. package/server/lib/assistants/harness.test.js +38 -0
  95. package/server/lib/assistants/summary.test.js +32 -0
  96. package/server/lib/realtime-proxy.js +2 -1
  97. package/server/lib/relay/tunnel-host.js +1 -0
  98. package/server/lib/remote-desktop/DOCUMENTATION.md +54 -0
  99. package/server/lib/remote-desktop/protocol.js +26 -0
  100. package/server/lib/remote-desktop/protocol.test.js +18 -0
  101. package/server/lib/remote-desktop/runtime.js +112 -0
  102. package/server/lib/remote-desktop/runtime.test.js +135 -0
  103. package/server/lib/ui-auth/DOCUMENTATION.md +2 -0
  104. package/server/lib/ui-auth/ui-auth.js +2 -1
  105. package/dist/assets/AssistantView-CVf9ta92.js +0 -3
  106. package/dist/assets/Icon-C93bLV0e.js +0 -1
  107. package/dist/assets/MarkdownRenderer-B8LWUc6A.js +0 -2
  108. package/dist/assets/SettingsView-B4xkRLZ3.js +0 -29
  109. package/dist/assets/desktop-CiqEZVr5.js +0 -1
  110. package/dist/assets/insertionBoundaries-WLpirs0A.js +0 -1
  111. package/dist/assets/main-CNmq04w8.js +0 -169
  112. package/dist/assets/renderMobileApp-B66uW5zc.js +0 -28
  113. package/dist/assets/src-DHHaXffU.css +0 -2
  114. package/dist/assets/types-BHKyslK4.js +0 -2
  115. package/dist/assets/useWorkerHighlightedLines-Dz6lLZ-1.js +0 -7
@@ -0,0 +1,28 @@
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-CrXMwUq9.js","assets/runtime-auth-BaBM02zI.js","assets/runtime-switch-DhMY9eiB.js","assets/runtime-fetch-DfALP7-b.js","assets/desktop-5DP3-Bao.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-base-ui-CdzJ6My_.js","assets/useUIStore-CEingF2z.js","assets/vendor-zustand-o69pgTEK.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/vendor-react-BP2cRVqX.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/runtime-file-resource-DtsKbFf3.js","assets/queryRuntime-DWgXfxGx.js","assets/fileQueries-Bd-OEFmO.js","assets/runtime-file-store-BVRgEtI-.js","assets/path-utils-jGozTg9d.js","assets/runtime-file-download-xvItwYMc.js","assets/platform-wGCQUVxr.js","assets/vendor-pierre-diffs-DPBtNDJ5.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/vendor-reactuses-core-BJ-jJ4YM.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-RqfOQVDY.js","assets/store-DRfILWJT.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-8jhE4Zyk.js","assets/vendor-framer-motion-BQ3-sJMO.js","assets/Icon-B0ebXdpZ.js","assets/dialog-BNwN9E77.js","assets/image-loading-DVZlFuU5.js","assets/image-loading-D9Z_BASK.css","assets/MobileWindowStack-DGLdgoGr.js","assets/appThemeRegistry-7-Ucu_cy.js","assets/useMobileNavigationStore-BDtGCgi3.js","assets/gitApiHttp-Bnr4_wxy.js","assets/vendor-opencode-client-fxfj4IA_.js","assets/vendor-effect-DV9F8PTZ.js","assets/persistence-BPb2hZ3c.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-sonner-ZS8XIOVl.js","assets/useAssistantUIStore-BZt-lLlW.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/MarkdownRenderer-D_rTN88T.js","assets/useEffectiveDirectory-Cu4UQ0_Y.js","assets/markdownHeightCache-CghsqV5O.js","assets/dualLimitLru-D8Sphgua.js","assets/toolHelpers-DL452NVK.js","assets/ImageLoadingPlaceholder-BsOal94e.js","assets/useWorkerHighlightedLines-_RnSE1vt.js","assets/markdownTheme-DHoKvD6O.js","assets/markdown-worker-oBGEB9Eg.js","assets/vendor-tanstack-react-virtual-B_EO--9t.js","assets/mobileBackNavigation-CX8dmR4X.js","assets/ToolOutputDialog-CbGuK5bP.css","assets/vendor-capacitor-push-notifications-D5cqJIPw.js","assets/vendor-capacitor-status-bar-D9bcMr9Q.js","assets/vendor-capacitor-keyboard-BRVcFyc9.js","assets/gitApi-CdlAr0G6.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,w as s}from"./runtime-auth-BaBM02zI.js";import{c,f as l,i as u,l as d,n as f,r as p,s as m,t as h}from"./runtime-switch-DhMY9eiB.js";import{n as g}from"./runtime-fetch-DfALP7-b.js";import{n as _,t as v}from"./runtimeAPIRegistry-C2VogTny.js";import{a as y,i as b}from"./vendor-zustand-o69pgTEK.js";import{it as x,nt as S,rt as C}from"./vendor-base-ui-CdzJ6My_.js";import{At as w,Nr as T,Pr as E,bt as D,yt as O}from"./gitApiHttp-Bnr4_wxy.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as k,x as A}from"./useUIStore-CEingF2z.js";import{At as j,r as M,t as N}from"./persistence-BPb2hZ3c.js";import{n as P,t as F}from"./vendor-react-BP2cRVqX.js";import{s as I}from"./vendor-tanstack-react-query-CdqCAt40.js";import{a as L,c as R,o as z,s as B,u as ee}from"./fileQueries-Bd-OEFmO.js";import{r as V,s as te}from"./runtime-file-resource-DtsKbFf3.js";import{o as ne}from"./path-utils-jGozTg9d.js";import{a as H,n as U,o as W}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as re}from"./pathNormalization-ewtPqJWn.js";import{n as ie,r as ae,t as oe}from"./platform-wGCQUVxr.js";import{t as G}from"./capgoAdapter-9z4borwr.js";/* empty css */import{a as se}from"./vendor-pierre-diffs-DPBtNDJ5.js";import{r as ce}from"./vendor-sonner-ZS8XIOVl.js";import{i as le,l as K,p as q,r as J}from"./vendor-reactuses-core-BJ-jJ4YM.js";import{d as ue,f as de,h as fe,r as Y,t as X}from"./button-RqfOQVDY.js";import{i as pe,n as me}from"./store-DRfILWJT.js";import{a as he,c as ge,d as _e,f as ve,i as ye,l as be,o as xe,p as Se,s as Ce,t as we,u as Te}from"./MobileShareBridge-CfcbqwW6.js";import{C as Ee,b as De,g as Oe,t as ke,x as Ae,y as je}from"./MobileDetailNavigation-B2IiMT5p.js";import{Br as Me,Ci as Ne,Da as Pe,F as Fe,Gi as Ie,Gr as Le,Gt as Re,Hr as ze,Ht as Be,Ir as Ve,Ki as He,Kr as Ue,Lr as We,Na as Ge,Pn as Ke,Pr as qe,Pt as Je,Qn as Ye,Ta as Xe,Ui as Ze,Ur as Qe,Ut as $e,Vi as et,Vr as tt,Wi as nt,Wr as rt,Xt as it,Yn as at,Zt as ot,a as st,d as ct,dn as lt,er as ut,fn as dt,hn as ft,ho as pt,jr as mt,kr as ht,ln as gt,mn as _t,nn as vt,nr as yt,o as bt,ri as xt,rn as St,sn as Ct,t as wt,wi as Tt,wr as Et,zr as Dt}from"./useMobileNavigationStore-BDtGCgi3.js";import{i as Ot,n as kt,r as At}from"./useAssistantUIStore-BZt-lLlW.js";import{n as jt}from"./useThemeSystem-8jhE4Zyk.js";import{n as Z}from"./Icon-B0ebXdpZ.js";import{F as Mt,I as Nt,M as Pt,N as Ft,p as It}from"./gitApi-CdlAr0G6.js";import{$ as Lt,At as Rt,B as zt,C as Bt,Ct as Vt,Dt as Ht,Et as Ut,J as Wt,K as Gt,L as Kt,Mt as qt,Nt as Jt,Ot as Yt,Q as Xt,R as Zt,Rt as Qt,S as $t,St as en,Tt as tn,X as nn,Y as rn,ct as an,i as on,jt as sn,kt as cn,lt as ln,q as un,r as dn,t as fn,vt as pn,wt as mn,yt as hn,z as gn}from"./useAppFontEffects-CW0A51vF.js";import{E as _n,T as vn,a as yn,f as bn,i as xn,n as Sn,s as Cn}from"./projectMeta-CVrggbn1.js";import{t as wn}from"./input-0mf9njqM.js";import{r as Tn}from"./tooltip-Bs7jQMa0.js";import{A as En,Ct as Dn,F as On,N as kn,T as An,at as jn,it as Mn,j as Nn,k as Pn,q as Fn,rt as In,ut as Ln}from"./speechSettingsQueries-B95s6DcZ.js";import{t as Rn}from"./YuriLogo-mo6nZ3PX.js";import{i as zn,o as Bn,t as Vn}from"./device-BKQ_0FdZ.js";import{d as Hn,o as Un}from"./image-loading-DVZlFuU5.js";import{C as Wn,a as Gn,c as Kn,d as qn,i as Jn,l as Yn,n as Xn,o as Zn,r as Qn,s as $n,t as er,u as tr}from"./MobileResizableSheet-C5UIcZMP.js";import{C as nr,r as rr,t as ir,w as ar}from"./sessionChangeSummary-BWq51EyC.js";import{b as or,h as sr,k as cr,v as lr,y as ur}from"./insertionBoundaries-CgOdACbG.js";import{A as dr,T as fr,a as pr,f as mr,j as hr,m as gr,t as _r}from"./appThemeRegistry-7-Ucu_cy.js";import{i as vr,n as yr,o as br}from"./MarkdownRenderer-D_rTN88T.js";import{n as xr,r as Sr}from"./textarea-Brud1txt.js";import{a as Cr,o as wr}from"./url-MRa-FtQa.js";import{a as Tr,c as Er,i as Dr,s as Or}from"./toolHelpers-DL452NVK.js";import{n as kr}from"./useEffectiveDirectory-Cu4UQ0_Y.js";import{t as Ar}from"./ImageLoadingPlaceholder-BsOal94e.js";import{t as jr}from"./LoadingImage-DU15BNuP.js";import{Q as Mr,ct as Nr,d as Pr,f as Fr,i as Ir,m as Lr,nt as Rr,ot as zr,rt as Br,s as Vr,t as Hr}from"./MobileTabPageHeader-9JAqOR2k.js";import{t as Ur}from"./useFontPreferences-CGThMzt0.js";import{$ as Wr,A as Gr,B as Kr,C as qr,Ct as Jr,E as Yr,F as Xr,G as Zr,H as Qr,I as $r,K as ei,L as ti,M as ni,N as ri,O as ii,P as ai,R as oi,S as si,St as ci,T as li,U as ui,V as di,W as fi,_ as pi,_t as mi,a as hi,at as gi,b as _i,bt as vi,ct as yi,d as bi,et as xi,g as Si,h as Ci,i as wi,it as Ti,j as Ei,l as Di,m as Oi,mt as ki,n as Ai,nt as ji,o as Mi,ot as Ni,p as Pi,pt as Fi,q as Ii,r as Li,rt as Ri,s as zi,st as Bi,t as Vi,u as Hi,v as Ui,vt as Wi,w as Gi,wt as Ki,x as qi,y as Ji,yt as Yi,z as Xi}from"./runtimeEndpointReset-CWadQNbz.js";import{c as Zi,l as Qi}from"./mcpQueries-DS2belW7.js";import{a as $i,c as ea,d as ta,f as na,i as ra,l as ia,m as aa,o as oa,p as sa,r as ca,s as la,t as ua,u as da}from"./SettingsView-BgwM4FwF.js";import{u as fa}from"./scheduledTaskNavigation-Dhcdlsyj.js";import{n as pa,r as ma,t as ha}from"./mobileBackNavigation-CX8dmR4X.js";import{a as ga,i as _a,o as va}from"./sessionLookup-CKLauQ7F.js";import{a as ya,c as ba,i as xa,o as Sa,r as Ca,s as wa,t as Ta}from"./AssistantView-CqihS590.js";var Q=e(x(),1),Ea=F(),Da=null,Oa=!1,ka=new Promise(e=>{Da=e});function Aa(){Oa||(Oa=!0,Da?.())}var ja=6,Ma=e=>e.parentID??null,Na=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},Pa=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),Fa=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=Pa(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return Na(n?n.path:e)},Ia=()=>{let e=We.getState().activeSessions,t=Ye.getState().index.session.unseenCount,n=pt.getState().projects,r=0,i=[];for(let a of e){let e=Ma(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:Fa(qe(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,ja).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},La=`__YURI_WIDGET_SNAPSHOT__`,Ra=()=>{typeof window>`u`||(window[La]=()=>{try{return JSON.stringify(Ia())}catch{return null}})},za=P(),Ba=H(`YuriScreenAwake`),Va=Promise.resolve(),Ha=0;function Ua(e){let t=Va.then(()=>Ba.setEnabled({enabled:e}));return Va=t.catch(()=>void 0),t}async function Wa(){if(U.isNativePlatform()&&U.isPluginAvailable(`YuriScreenAwake`)){Ha+=1;try{await Ua(!0)}catch(e){throw--Ha,e}let e=!1;return async()=>{e||(e=!0,--Ha,Ha===0&&await Ua(!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 $=C();function Ga({sessionId:e,directory:t,active:n,children:r}){let{t:i}=de(),a=lt(e,t),o=dt(e,t),[s,l]=K(`yuri.auto-read`,!1),u=s===!0,[d,f]=(0,Q.useState)(0),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(document.visibilityState===`visible`),y=zt({enabled:p}),b=(0,Q.useRef)({enabled:!1,generation:0,floor:0,seen:new Set,observed:new Set,pending:[],playing:!1}),x=(0,Q.useRef)(!1),S=n&&!!e&&o,C=J(()=>{let e=b.current;e.enabled=!1,e.generation+=1,e.pending=[],e.playing=!1,e.seen.clear(),e.observed.clear(),x.current=!1,y.stop(),g(null),m(!1)}),w=J(()=>{let e=b.current;if(!e.enabled||e.playing||!n||document.visibilityState!==`visible`)return;let t=e.pending.shift();if(!t)return;e.playing=!0,g(t);let r=e.generation;y.play(t.text,t=>{if(r===e.generation){if(e.playing=!1,g(null),t){C(),ce.error(i(`mobile.menu.autoReadFailed`));return}w()}})}),T=J(t=>{let n=b.current;!n.enabled||!S||t.sessionId!==e||!t.text.trim()||t.created<n.floor&&!n.observed.has(t.messageId)||n.seen.has(t.messageId)||(n.seen.add(t.messageId),n.pending.push(t),w())}),E=J((t,n)=>{b.current.enabled&&S&&t===e&&b.current.observed.add(n)}),D=J(()=>{if(u){l(!1),C();return}S&&(l(!0),y.unlock().catch(()=>{ce.error(i(`mobile.menu.autoReadFailed`))}))}),O=J(()=>{let e=b.current;e.floor=Math.max(0,...a.map(e=>e.time.created)),e.seen=new Set(a.filter(e=>e.time.completed!=null||e.role!==`assistant`).map(e=>e.id)),e.enabled=!0,m(!0)});(0,Q.useEffect)(()=>(C(),u&&S&&O(),C),[e,t,u,S,d,O,C]),(0,Q.useEffect)(()=>c(()=>{C(),f(e=>e+1)}),[C]);let k=J(()=>{l(!1),C()});le(`pointerdown`,()=>{if(!b.current.enabled||x.current)return;x.current=!0;let e=b.current.generation;y.unlock().catch(()=>{e===b.current.generation&&(x.current=!1)})},document),le(`visibilitychange`,()=>{v(document.visibilityState===`visible`),document.visibilityState===`visible`?w():(b.current.generation+=1,b.current.playing=!1,b.current.pending=[],y.stop(),g(null))},document),(0,Q.useEffect)(()=>{if(!p||!n||!_)return;let e=!1,t;return Wa().then(n=>{e?n().catch(()=>void 0):t=n}).catch(()=>{e||ce.warning(i(`mobile.menu.autoReadAwakeFailed`))}),()=>{e=!0,t?.().catch(()=>void 0)}},[p,n,_,e,t,d,i]);let A=(0,Q.useMemo)(()=>({enabled:u,available:S,toggle:D,rendered:T,streaming:E}),[u,S,D,T,E]),j=(0,Q.useMemo)(()=>p&&n&&_&&y.isPlaying&&h?.sessionId===e?{sessionId:e,messageId:h.messageId,stop:k}:null,[p,n,_,y.isPlaying,h,e,k]);return(0,$.jsx)(Zt.Provider,{value:A,children:(0,$.jsx)(gn.Provider,{value:j,children:r})})}function Ka(e){let t=(0,za.c)(3),{children:n}=e,r=(0,Q.useContext)(Zt);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 qa={getPlatform:()=>U.getPlatform(),isPluginAvailable:e=>U.isPluginAvailable(e),openInSystemBrowser:e=>wr.open(e),openExternal:Cr},Ja=async(e,t=qa)=>{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)},Ya=`mobile-app-update-available`,Xa=`mobile-app-update-toast-dismissed-version`,Za=()=>{let e=(0,za.c)(9),{t}=de(),n=Br(Qa),r=Br($a),i=Br(eo),a=Br(to),o=Br(no),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,e[0]=s):s=e[0];let c=Q.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(oe()!==`android`||r!==`mobile`||!n||!i||!a||o){tt.dismiss(Ya);return}A().getItem(Xa)!==i&&(c.current.has(i)||(c.current.add(i),tt.info(t(`mobileUpdate.toast.available.title`),{id:Ya,description:t(`mobileUpdate.toast.available.description`,{version:i}),duration:1/0,icon:(0,$.jsx)(Z,{name:`download`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.toast.actions.download`),onClick:()=>{Ja(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{A().setItem(Xa,i),tt.dismiss(Ya)}}})))},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]),Q.useEffect(l,u),null};function Qa(e){return e.available}function $a(e){return e.runtimeType}function eo(e){return e.info?.version}function to(e){return e.info?.downloadUrl}function no(e){return e.info?.inAppApply===!0}var ro=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),io=e=>e.enabled&&!e.alreadyChecked,ao=`mobile-ota-update-available`,oo=`mobile-ota-update-toast-dismissed-version`,so=()=>{let e=(0,za.c)(24),{t}=de(),[n,r]=Q.useState(!1),i=Q.useRef(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,e[0]=a):a=e[0];let o=Q.useRef(a),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=ie(),e[1]=s):s=e[1];let c=s,l=Br(co),u=Br(lo),d=Br(uo),f=Br(fo),p=Br(po),m=Br(mo),h=Br(ho),g=Br(go),_=Br(_o),v=d?.version,y=d?.inAppApply===!0,b,x;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{io({enabled:c,alreadyChecked:i.current})&&(i.current=!0,Br.getState().checkForUpdates().catch(vo))},x=[c],e[2]=b,e[3]=x):(b=e[2],x=e[3]),Q.useEffect(b,x);let S;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{r(!0)},e[4]=S):S=e[4];let C=J(S),w=J(yo),T,E;if(e[5]!==l||e[6]!==w||e[7]!==y||e[8]!==C||e[9]!==u||e[10]!==t||e[11]!==v?(T=()=>{if(!ro({enabled:c,runtimeType:u,available:l,inAppApply:y,version:v??``,dismissedVersion:A().getItem(oo),seenVersions:o.current})||!v){(!l||!y||u!==`mobile`)&&tt.dismiss(ao);return}o.current.add(v),tt.info(t(`mobileUpdate.ota.toast.available.title`),{id:ao,description:t(`mobileUpdate.ota.toast.available.description`,{version:v}),duration:1/0,icon:(0,$.jsx)(Z,{name:`refresh`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.ota.toast.actions.update`),onClick:C},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{w(v)}}})},E=[l,y,c,C,w,u,t,v],e[5]=l,e[6]=w,e[7]=y,e[8]=C,e[9]=u,e[10]=t,e[11]=v,e[12]=T,e[13]=E):(T=e[12],E=e[13]),Q.useEffect(T,E),!c)return null;let D;return e[14]!==n||e[15]!==g||e[16]!==p||e[17]!==f||e[18]!==h||e[19]!==d||e[20]!==m||e[21]!==_||e[22]!==u?(D=(0,$.jsx)(Rr,{open:n,onOpenChange:r,info:d,downloading:f,downloaded:p,progress:m,error:h,onDownload:g,onRestart:_,runtimeType:u}),e[14]=n,e[15]=g,e[16]=p,e[17]=f,e[18]=h,e[19]=d,e[20]=m,e[21]=_,e[22]=u,e[23]=D):D=e[23],D};function co(e){return e.available}function lo(e){return e.runtimeType}function uo(e){return e.info}function fo(e){return e.downloading}function po(e){return e.downloaded}function mo(e){return e.progress}function ho(e){return e.error}function go(e){return e.downloadUpdate}function _o(e){return e.restartToUpdate}function vo(){}function yo(e){A().setItem(oo,e),tt.dismiss(ao)}var bo=H(`BarcodeScanner`),xo=`yuri-barcode-scanner-active`,So=()=>Lo()?bo:null,Co=()=>window.Capacitor?.getPlatform?.()===`android`,wo=e=>typeof e==`object`&&e&&`message`in e?String(e.message??``):String(e??``),To=e=>/^\s*scan canceled\.?\s*$/i.test(wo(e)),Eo=e=>/denied access to camera/i.test(wo(e)),Do=e=>!To(e)&&!Eo(e),Oo=e=>{let t=wo(e);return/module/i.test(t)&&/not\s*available|unavailable/i.test(t)},ko=e=>{e.installGoogleBarcodeScannerModule?.().catch(()=>void 0)},Ao=e=>{let t=e.trim();if(!t)return null;if(/^yuri:\/\//i.test(t)){let e=sa(t);return e?{pairing:e}:null}return/^https?:\/\//i.test(t)?{url:t}:null},jo=e=>{let t=Ao(e);return t?`pairing`in t?{status:`pairing`,...t}:{status:`ok`,...t}:{status:`invalid`}},Mo=e=>{typeof document>`u`||document.documentElement.classList.toggle(xo,e)},No=e=>{try{e()}catch{}},Po=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))}},Fo=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))};Mo(!0);let c=Po(()=>s({status:`cancelled`}));try{let{App:e}=await W(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(jo(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=>{Eo(e)?s({status:`permission-denied`}):s({status:`failed`})}),await o}finally{Mo(!1),No(c),No(()=>r?.()),await Promise.allSettled([Promise.resolve(t?.remove()),Promise.resolve(n?.remove()),e.stopScan()])}},Io=e=>e.isNativePlatform&&e.isPluginAvailable,Lo=()=>Io({isNativePlatform:U.isNativePlatform(),isPluginAvailable:U.isPluginAvailable(`BarcodeScanner`)}),Ro=async()=>{let e=So();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?jo(n):{status:`cancelled`}}catch(t){return To(t)?{status:`cancelled`}:Eo(t)?{status:`permission-denied`}:Co()&&Do(t)&&e.startScan?(Oo(t)&&ko(e),Fo(e)):{status:`failed`}}return Co()&&e.startScan?Fo(e):{status:`unsupported`}}catch{return{status:`failed`}}},zo={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},Bo=({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}=de(),[p,m]=Q.useState(``),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),y=o??p,b=Q.useId(),x=e=>{g(null),m(e),s?.(e)},S=J(async()=>{if(!(e||t||_)){v(!0);try{let e=await navigator.clipboard.readText();x(e);let t=Ao(e);e.trim()&&(!t||!(`pairing`in t))&&d()}catch{g(f(`mobile.connect.link.pasteFallback`))}finally{v(!1)}}}),C=J(n=>{if(n.preventDefault(),e||t||_)return;let r=Ao(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)(wn,{...zo,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)(X,{variant:`outline`,size:`icon`,onClick:()=>void S(),disabled:e||t||_,"aria-label":f(`mobile.connect.link.paste`),children:(0,$.jsx)(Z,{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)(X,{type:`submit`,variant:i,size:`lg`,className:a,disabled:e||t||_||!y.trim(),children:f(t?`mobile.connect.connecting`:`mobile.connect.connectButton`)})]})},Vo=e=>{let t=(0,za.c)(6),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border/70`}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:n}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border/70`}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 py-3`,"aria-hidden":`true`,children:[r,i,a]}),t[4]=i,t[5]=o),o};function Ho({connection:e}){let{t}=de(),{connections:n,isBusy:r,error:i,pendingConnection:a}=e,o=Q.useMemo(()=>Lo(),[]),[s,c]=Q.useState(null),[l,u]=Q.useState(!1),[d,f]=Q.useState(null),[p,m]=Q.useState(!1),[h,g]=Q.useState(null),[_,v]=Q.useState(null),[y,b]=Q.useState(``),[x,S]=Q.useState(``),[C,w]=Q.useState(``),T=n[0],E=n.find(e=>e.id===_),D=r||p,O=s!==null||a!==null,k=t=>{e.setError(null),c(t)},A=()=>{e.setError(null),c(null),u(!0)},j=J(()=>{D||(a?(e.cancelPassword(),S(``)):k(null))}),M=J(async t=>{D||(g(t.id),S(``),await e.connect({id:t.id,candidates:t.candidates,label:t.label}))}),N=J(async()=>{if(!D){g(null),m(!0),e.setError(null);try{let n=await Ro();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)}}}),P=J(()=>d?(f(null),!0):O?(j(),!0):l?(u(!1),!0):!1);Q.useEffect(()=>{if(!ie())return;let e=!1,t;return W(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`,()=>{P()||n.minimizeApp().catch(()=>void 0)});e?r.remove():t=()=>{r.remove()}}).catch(()=>void 0),()=>{e=!0,t?.()}},[P]);let F=e=>h===e.id&&r&&!a&&s!==`rename`&&s!==`remove`?t(`mobile.connect.connecting`):h===e.id&&i?t(`mobile.connect.history.failed`):e.id===T?.id&&e.lastUsedAt>0?t(`mobile.connect.history.lastUsed`):t(`mobile.instances.status.saved`),I=e=>(0,$.jsxs)(X,{size:`lg`,variant:e?`default`:`ghost`,className:e?`yuri-welcome-primary w-full`:`w-full`,disabled:D,onClick:()=>void N(),children:[(0,$.jsx)(Z,{name:p?`loader-4`:`scan-2`,className:p?`size-5 animate-spin motion-reduce:animate-none`:`size-5`}),t(`mobile.connect.scanQr`)]}),L=t(a?`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:O||l,"aria-hidden":O||l||void 0,"data-welcome-paused":O||l||p?`true`:void 0,children:[(0,$.jsx)(`header`,{className:`yuri-welcome-brand`,children:(0,$.jsx)(mi,{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)(Rn,{width:144,height:144,className:`size-full`})})]}),(0,$.jsxs)(`div`,{className:`yuri-welcome-copy`,children:[(0,$.jsx)(`h1`,{children:t(T?`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:[T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(X,{variant:`outline`,className:`yuri-welcome-device`,disabled:D,onClick:A,children:[(0,$.jsx)(Z,{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:T.label}),(0,$.jsx)(`span`,{className:`block typography-small font-normal text-muted-foreground`,children:F(T)})]}),(0,$.jsx)(Z,{name:`arrow-right-s`,className:`size-5 text-muted-foreground`})]}),(0,$.jsx)(X,{size:`lg`,className:`yuri-welcome-primary w-full`,disabled:D,onClick:()=>void M(T),children:r&&h===T.id?t(`mobile.connect.connecting`):i&&h===T.id?t(`desktopHostSwitcher.actions.retry`):t(`mobile.connect.history.continue`)})]}):null,o?I(!T):T?null:(0,$.jsx)(X,{size:`lg`,className:`yuri-welcome-primary w-full`,disabled:D,onClick:()=>k(`more`),children:t(`mobile.connect.link.useLink`)}),i&&!O&&!l?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,(0,$.jsx)(X,{variant:`ghost`,size:`lg`,disabled:D,className:`mx-auto text-muted-foreground`,onClick:()=>k(`more`),children:t(`mobile.connect.welcome.moreOptions`)})]})]})]}),(0,$.jsxs)(Qn,{id:`welcome-history`,open:l,onOpenChange:u,presentation:`page`,edge:`right`,dismissGesture:!0,ariaLabel:t(`mobile.connect.history.title`),children:[(0,$.jsx)(ke,{title:t(`mobile.connect.history.title`),backAriaLabel:t(`header.actions.backAria`),onBack:()=>u(!1)}),(0,$.jsxs)(xr,{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,$.jsxs)(`div`,{className:`border-b border-border/60 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(X,{variant:`ghost`,className:`yuri-welcome-history-row min-w-0 flex-1`,disabled:D,onClick:()=>void M(e),children:[(0,$.jsx)(Z,{name:r&&h===e.id&&!O?`loader-4`:`computer`,className:r&&h===e.id&&!O?`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:F(e)})]})]}),(0,$.jsxs)(In,{open:d===e.id,onOpenChange:t=>f(t?e.id:null),children:[(0,$.jsx)(Ln,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,disabled:D,"aria-label":t(`mobile.connect.history.actions`,{name:e.label}),children:(0,$.jsx)(Z,{name:`more`,className:`size-5`})})}),(0,$.jsxs)(Mn,{align:`end`,children:[(0,$.jsxs)(jn,{onSelect:()=>{v(e.id),b(e.label),k(`rename`)},children:[(0,$.jsx)(Z,{name:`edit`,className:`size-4`}),t(`mobile.connect.history.rename`)]}),(0,$.jsxs)(jn,{onSelect:()=>{v(e.id),k(`remove`)},className:`text-[var(--status-error)]`,children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`size-4`}),t(`mobile.connect.history.remove`)]})]})]})]}),i&&h===e.id&&!O?(0,$.jsxs)(`div`,{className:`px-3 pb-2`,children:[(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}),(0,$.jsx)(X,{variant:`link`,size:`sm`,disabled:D,onClick:()=>void M(e),children:t(`desktopHostSwitcher.actions.retry`)})]}):null]},e.id)),i&&!h&&!O?(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)(Rn,{width:36,height:36,className:`mx-auto mb-5 opacity-40`}),o?I(!1):null,(0,$.jsx)(X,{variant:`ghost`,size:`lg`,className:`w-full`,disabled:D,onClick:()=>k(`more`),children:t(`mobile.connect.link.useLink`)})]})]}),(0,$.jsx)(er,{id:`welcome-options`,open:O,onOpenChange:e=>{e||j()},fitContent:!0,title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:L}),ariaLabel:L,closeAriaLabel:t(`mobile.surface.closeAria`),resizeAriaLabel:t(`mobile.connect.options.resize`),children:(0,$.jsx)(xr,{className:`px-5 py-5`,disableHorizontal:!0,fillContainer:!1,children:a?(0,$.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),r||e.submitPassword(x)},children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label`,children:a.label}),(0,$.jsx)(wn,{type:`password`,autoComplete:`current-password`,value:x,onChange:e=>S(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)(X,{type:`submit`,size:`lg`,className:`yuri-welcome-primary w-full`,disabled:r||!x.trim(),children:t(r?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(X,{variant:`ghost`,disabled:r,onClick:j,children:t(`mobile.connect.cancelPassword`)})]}):s===`rename`&&E?(0,$.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e.renameConnection(E.id,y).then(e=>{e&&c(null)})},children:[(0,$.jsx)(wn,{value:y,onChange:e=>b(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)(X,{type:`submit`,size:`lg`,disabled:r||!y.trim(),children:t(`mobile.instances.saveEdit`)})]}):s===`remove`&&E?(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:E.label})}),i?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,(0,$.jsx)(X,{variant:`destructive`,size:`lg`,disabled:r,onClick:()=>{e.removeConnection(E.id).then(e=>{e&&(c(null),g(null))})},children:t(`mobile.connect.history.remove`)}),(0,$.jsx)(X,{variant:`ghost`,disabled:r,onClick:j,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)(Bo,{value:C,onValueChange:t=>{w(t),e.setError(null)},showPasteButton:!0,inputClassName:`min-w-0 flex-1 text-[16px]`,buttonClassName:`yuri-welcome-primary w-full`,buttonVariant:`default`,disabled:D,isBusy:r,error:i,onInvalid:()=>e.setError(t(`mobile.connect.link.invalid`)),onRedeem:t=>{g(null),e.redeemPairingConnection(t)}}),(0,$.jsxs)(X,{variant:`outline`,className:`yuri-welcome-history-row`,disabled:D,onClick:A,children:[(0,$.jsx)(Z,{name:`history`,className:`size-6`}),(0,$.jsx)(`span`,{className:`flex-1 text-left`,children:t(`mobile.connect.history.title`)}),(0,$.jsx)(Z,{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 Uo(e){let t=(0,za.c)(17),{children:n}=e,r=k(Ko),i=k(Go),a=Q.useRef(null),o=Q.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],pa(c);let l,u;t[5]===r?(l=t[6],u=t[7]):(l=()=>{if(!r)return;let e=document.activeElement,t=rn(`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),Q.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)(ki,{presentation:`page`,onBack:Wo})}):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 Wo(){ha.requestAnimatedBack(`root`)}function Go(e){return e.setCommandPaletteOpen}function Ko(e){return e.isCommandPaletteOpen}var qo=e=>{let t=(0,za.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=Y(`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=Y(`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},Jo=`.yuri-mobile-composer`,Yo=`[data-btw-composer]`;function Xo(e,t){if(!e)return!1;let n=t;return!n||typeof n.closest!=`function`||!n.closest(Yo)}function Zo(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(Jo)}function Qo(e){if(!e||typeof e!=`object`||Zo(e))return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;return n===`TEXTAREA`||n===`INPUT`||t.isContentEditable===!0}function $o(e){return Zo(e??null)}function es(e,t){return e?`cache`:Zo(t??null)?`open`:Qo(t??null)?`field`:`ignore`}function ts(e,t){return!(t>0)||!(e>=0)?!1:t>e+24}function ns(e,t){return e>0?Math.max(0,Math.round(e/(Number.isFinite(t)&&t>0?t:1))):0}var rs=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),is=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},as=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},os=(e,t)=>t?`${e}\u0000staged`:e,ss=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=de(),{git:o}=ee(),s=rs(kr()??null),c=lr(s||null),l=or(s||null),u=sr(s||null),d=ur(e=>e.setActiveDirectory),f=ur(e=>e.ensureAll),p=ur(e=>e.fetchStatus),m=ur(e=>e.fetchBranches),h=ur(e=>e.prefetchDiffs),g=ur(e=>e.getDiff),_=ur(e=>e.setDiff),[v,y]=Q.useState(()=>t?{type:`diff`,path:t,staged:n,targetLine:r}:{type:`list`}),b=Q.useRef(null);Q.useEffect(()=>{t&&y(e=>e.type===`diff`&&e.path===t&&e.staged===n&&e.targetLine===r?e:{type:`diff`,path:t,staged:n,targetLine:r})},[t,n,r]);let[x,S]=Q.useState(null),[C,w]=Q.useState(null),[T,E]=Q.useState(``),[D,O]=Q.useState(new Set),[k,A]=Q.useState(!1),[j,M]=Q.useState(!1),[N,P]=Q.useState([]),[F,I]=Q.useState([]),[L,R]=Q.useState([]),[z,B]=Q.useState(null),[V,te]=Q.useState({key:null,loading:!1,error:null,resolved:!1}),[ne,H]=Q.useState(0),U=Q.useRef({key:null,generation:0}),[W,re]=Q.useState(!1),ie=_i(c)&&!W,ae=Q.useMemo(()=>{let e=c?.files??[];if(ie)return[];let t=new Map;for(let n of e)t.set(n.path,n);return Array.from(t.values()).sort((e,t)=>e.path.localeCompare(t.path))},[c?.files,ie]),oe=Q.useMemo(()=>ae.filter(is),[ae]),G=Q.useMemo(()=>ae.filter(as),[ae]),{deferredStagedCount:se,deferredUnstagedCount:ce}=Q.useMemo(()=>{if(!ie||!c)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of c.files??[])is(n)&&(e+=1),as(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[ie,c]),le=Q.useMemo(()=>{if(L.length>0)return L;let e=c?.tracking?.includes(`/`)?c.tracking.split(`/`)[0]:null;return e||z?[{name:e||`origin`,fetchUrl:z??``,pushUrl:z??``}]:[]},[z,L,c?.tracking]),K=Q.useMemo(()=>e=>!s||v.type!==`diff`?null:e.directories.get(s)?.diffCache.get(os(v.path,v.staged))??null,[s,v]),q=ur(K),ue=Q.useMemo(()=>v.type===`diff`?ae.find(e=>e.path===v.path)??null:null,[ae,v]),fe=v.type===`diff`&&s?`${s}\u0000${os(v.path,v.staged)}`:null,Y=V.key===fe,X=!!(fe&&!q&&(!Y||V.loading)),pe=Y?V.error:null,me=!!(ue||Y&&V.resolved),he=J(async(e,t=!0)=>{try{await Promise.all([p(e,o),m(e,o)])}catch(e){t&&tt.error(e instanceof Error?e.message:a(`gitView.toast.refreshRepositoryFailed`))}}),ge=J(async(e,t,n)=>{let r=()=>U.current.key===t&&U.current.generation===n;try{let[t,n]=await Promise.all([o.getRemotes(e).catch(()=>[]),o.getRemoteUrl?o.getRemoteUrl(e).catch(()=>null):Promise.resolve(null)]);if(!r())return;R(t),B(n)}catch{if(!r())return;R([]),B(null)}}),_e=J(e=>{if(e!==s)return{requestGeneration:null,promise:Promise.resolve()};let t=U.current.generation+1;return U.current={key:e,generation:t},{requestGeneration:t,promise:ge(e,e,t)}});Q.useEffect(()=>{s&&(d(s),f(s,o))},[s,f,o,d]),Q.useEffect(()=>{if(!s){U.current={key:null,generation:U.current.generation+1},R([]),B(null);return}let{requestGeneration:e,promise:t}=_e(s);return()=>{e!==null&&U.current.key===s&&U.current.generation===e&&(U.current={key:s,generation:e+1})}},[s,o,_e]),Q.useEffect(()=>{if(!s||ae.length===0)return;let e=Array.from(new Set([...oe.map(e=>e.path),...F,...ae.slice(0,20).map(e=>e.path)])).filter(Boolean);if(e.length===0)return;let t=window.setTimeout(()=>{h(s,o,e,{maxFiles:40})},120);return()=>window.clearTimeout(t)},[ae,s,o,h,oe,F]),Q.useEffect(()=>{if(v.type!==`diff`){te({key:null,loading:!1,error:null,resolved:!1});return}let e=os(v.path,v.staged);if(!s||!fe){te({key:null,loading:!1,error:null,resolved:!1});return}if(g(s,e)){te(e=>({key:fe,loading:!1,error:null,resolved:e.key===fe&&e.resolved||!!ue}));return}let t=!1;return te({key:fe,loading:!0,error:null,resolved:!1}),o.getGitFileDiff(s,{path:v.path,staged:v.staged||void 0}).then(n=>{t||(_(s,e,{original:n.original??``,modified:n.modified??``,isBinary:n.isBinary}),te(e=>e.key===fe?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||te(t=>t.key===fe?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[fe,s,ne,g,o,v,ue,_]);let ve=async(e,t)=>{if(!s)return;let n=s;S(e);try{let r=e=>{let t=`${e.name}/`,n=c?.tracking?.startsWith(t)?c.tracking.slice(t.length):void 0;return{remote:e.name,branch:n,rebase:!0}};if(e===`fetch`){if(!t)throw Error(a(`mobile.changes.noRemote`));await o.gitFetch(n,{remote:t.name}),tt.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){tt.error(a(`gitView.toast.commitOrStashBeforeSync`));return}await o.gitPull(n,r(t))}((await o.getGitStatus(n)).ahead??0)>0&&await o.gitPush(n),tt.success(a(`gitView.toast.alreadyUpToDate`))}await he(n,!1),await _e(n).promise}catch(e){tt.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{S(null)}},ye=J(async(e,t)=>{if(!s||e.length===0)return;let n=s;try{t===`stage`?e.length>1?await Ft(n,e):await Pt(n,e[0]):e.length>1?await Nt(n,e):await Mt(n,e[0]),await he(n,!1)}catch(e){tt.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),be=J((e,t=!1)=>{y({type:`diff`,path:e,staged:t,targetLine:null})}),xe=J(()=>v.type===`diff`&&(y({type:`list`}),!0));pa({id:`mobile-changes-diff`,active:v.type===`diff`&&!i,layer:`overlay`,onBack:xe,surfaceRef:b});let Se=J(async e=>{if(!s)return;let t=s;O(t=>new Set(t).add(e));try{await o.revertGitFile(t,e),tt.success(a(`gitView.toast.revertedFile`,{path:e})),await he(t,!1)}catch(e){tt.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(t=>{let n=new Set(t);return n.delete(e),n})}}),Ce=J(async e=>{if(!s||e.length===0||k)return;let t=s,n=Array.from(new Set(e));A(!0),O(new Set(n));try{await Promise.all(n.map(e=>o.revertGitFile(t,e))),await he(t,!1),tt.success(n.length===1?a(`gitView.toast.revertedFilesSingle`,{count:n.length}):a(`gitView.toast.revertedFilesPlural`,{count:n.length}))}catch(e){tt.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(new Set),A(!1)}}),we=J(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){P([]);return}E(e=>`${e.trim()}${e.trim()?`
3
+
4
+ `:``}${t.join(`
5
+ `)}`.trim()),P([])}),Te=J(async()=>{if(!s)return;let e=s,t=oe.map(e=>e.path).sort();if(t.length===0){tt.error(a(`gitView.toast.selectFileToDescribe`));return}M(!0);try{let{message:n}=await It(e,t);E(n.subject?.trim()??``),P(Array.isArray(n.highlights)?n.highlights:[])}catch(e){tt.error(e instanceof Error?e.message:a(`gitView.toast.generateCommitMessageFailed`))}finally{M(!1)}}),Ee=async(e={})=>{if(!s)return;let t=s;if(!T.trim()){tt.error(a(`gitView.toast.enterCommitMessage`));return}let n=oe.map(e=>e.path).sort();if(n.length===0){tt.error(a(`gitView.toast.selectFileToCommit`));return}w(e.pushAfter?`commitAndPush`:`commit`);try{if(await o.createGitCommit(t,T.trim(),{files:n}),tt.success(a(`gitView.toast.commitCreated`)),E(``),P([]),e.pushAfter){let e=c?.tracking?.split(`/`)[0],n=le.find(t=>t.name===e)??le[0];if(!n)throw Error(a(`mobile.changes.noRemote`));S(`sync`);let r=`${n.name}/`,i=c?.tracking?.startsWith(r)?c.tracking.slice(r.length):void 0;await o.gitFetch(t,{remote:n.name}),((await o.getGitStatus(t)).behind??0)>0&&await o.gitPull(t,{remote:n.name,branch:i,rebase:!0}),((await o.getGitStatus(t)).ahead??0)>0&&await o.gitPush(t),await he(t,!1),await _e(t).promise}else await he(t,!1)}catch(e){tt.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{w(null),e.pushAfter&&S(null)}},De=Q.useMemo(()=>{let e=[];return oe.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:oe,actionSymbol:`-`,actionAllLabel:a(`gitView.changes.unstageAllAria`),getActionLabel:e=>a(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void ye([e],`unstage`),onActionAll:e=>void ye(e,`unstage`),onViewDiff:e=>be(e,!0),onRevertFile:Se,showRevertActions:!1,accent:!0}),G.length>0&&e.push({id:`unstaged`,title:a(`gitView.changes.title`),entries:G,actionSymbol:`+`,actionAllLabel:a(`gitView.changes.stageAllAria`),getActionLabel:e=>a(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void ye([e],`stage`),onActionAll:e=>void ye(e,`stage`),onViewDiff:e=>be(e,!1),onRevertFile:Se}),e},[Se,be,ye,oe,a,G]),Oe=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)(Z,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c?.current||s||``})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:t})]});return s?u&&l===null?Oe((0,$.jsx)(cs,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):l===!1?Oe((0,$.jsx)(cs,{icon:!0,message:a(`gitView.empty.notGitRepository`),description:a(`gitView.empty.notGitRepositoryDescription`)})):v.type===`diff`?(0,$.jsx)(`div`,{ref:b,className:`h-full min-h-0`,children:(0,$.jsx)(ls,{path:v.path,directory:s,diff:q,fileExists:me,error:pe,loading:X,targetLine:v.targetLine,onBack:xe,onRetry:()=>H(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)(Z,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c?.current||s})]}),(0,$.jsx)(Yr,{syncAction:x,remotes:le,onSync:e=>void ve(`sync`,e),disabled:C!==null||u,aheadCount:c?.ahead??0,behindCount:c?.behind??0,trackingRemoteName:c?.tracking?.split(`/`)[0],hasUncommittedChanges:(c?.files?.length??0)>0})]}),ie?(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(qi,{stagedCount:se,unstagedCount:ce,onLoad:()=>re(!0)})}):ae.length>0?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-4 pt-4`,children:(0,$.jsx)(si,{groups:De,diffStats:c?.diffStats,revertingPaths:D,onRevertAll:Ce,isRevertingAll:k,headerBackgroundClassName:`bg-transparent`,onVisiblePathsChange:I})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-4 pt-3`,children:(0,$.jsx)(Ji,{stagedCount:oe.length,commitMessage:T,onCommitMessageChange:E,generatedHighlights:N,onInsertHighlights:we,onGenerateMessage:Te,isGeneratingMessage:j,onCommit:()=>void Ee({pushAfter:!1}),onCommitAndPush:()=>void Ee({pushAfter:!0}),commitAction:C,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(cs,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):Oe((0,$.jsx)(cs,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},cs=e=>{let t=(0,za.c)(13),{message:n,description:r,loading:i,icon:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c;t[0]===o?c=t[1]:(c=o?(0,$.jsx)(Z,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):null,t[0]=o,t[1]=c);let l;t[2]===s?l=t[3]:(l=s?(0,$.jsx)(Z,{name:`git-branch`,className:`size-6 text-muted-foreground`}):null,t[2]=s,t[3]=l);let u;t[4]===n?u=t[5]:(u=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[4]=n,t[5]=u);let d;t[6]===r?d=t[7]:(d=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[6]=r,t[7]=d);let f;return t[8]!==c||t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[c,l,u,d]})}),t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f},ls=e=>{let t=(0,za.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}=de(),m=ar(),h;t[0]===n?h=t[1]:(h=Tr(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)(X,{variant:`ghost`,size:`icon`,title:p(`diffView.actions.openFilePreview`),"aria-label":p(`diffView.actions.openFilePreview`),onClick:()=>m.openFile({path:ne(r,n)}),children:(0,$.jsx)(Z,{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)(Xn,{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)(Z,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-2`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:n})}),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)(X,{type:`button`,size:`sm`,variant:`outline`,onClick:u,children:p(`diffView.actions.retry`)})]})}):s?(0,$.jsx)(cs,{loading:!0,message:p(`diffView.state.loadingDiff`)}):a?i?i.isBinary?(0,$.jsx)(cs,{icon:!0,message:p(`diffView.binary.unavailable`)}):Er(n)?(0,$.jsx)(cs,{icon:!0,message:p(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(Sr,{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)(yi,{original:i.original,modified:i.modified,language:g,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:c,layout:`inline`})}):(0,$.jsx)(cs,{loading:!0,message:p(`diffView.state.loadingDiff`)}):(0,$.jsx)(cs,{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},us=e(S(),1),ds=`data-yuri-motion-id`,fs=`data-yuri-sheet-overscroll`,ps=`html, body { overscroll-behavior-y: none; }`,ms=[`input`,`textarea`,`select`,`[contenteditable]:not([contenteditable="false"])`,`[data-mobile-sheet-no-dismiss]`].join(`, `),hs=e=>e.closest(`[data-yuri-motion-id]`)?.getAttribute(`data-yuri-motion-id`)??null,gs=e=>{try{let t=e.contentDocument;return t?t.scrollingElement??t.documentElement:null}catch{return null}},_s=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)&&e<=1&&t>0,vs=(e,t,n)=>e?!0:_s(t,n),ys=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.Element},bs=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLElement},xs=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLStyleElement},Ss=(e,t)=>{if(typeof e.item==`function`){let n=e.item(t);if(n)return n}return e[t]??null},Cs=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=Ss(e,n);if(r?.identifier===t)return r}return null},ws=(e,t)=>{try{let n=e.defaultView?.getComputedStyle(t);if(!n)return!1;let r=n.overflowY;return(r===`auto`||r===`scroll`||r===`overlay`)&&t.scrollHeight>t.clientHeight+1}catch{return!1}},Ts=(e,t)=>{let n=[],r=new Set,i=t=>{!t||r.has(t)||ws(e,t)&&(r.add(t),n.push(t))},a=ys(e,t)?t:null;for(;a&&(bs(e,a)&&i(a),a!==e.documentElement&&a!==e.body);)a=a.parentElement;let o=e.scrollingElement??e.documentElement;return bs(e,o)&&i(o),n},Es=(e,t)=>{let n=Ts(e,t);if(n.length===0){let t=(e.scrollingElement??e.documentElement)?.scrollTop??1/0;return Number.isFinite(t)&&t<=1}return n.every(e=>e.scrollTop<=1)},Ds=e=>{let t=e.closest(`[${ds}]`);if(t instanceof HTMLElement){let e=t.getBoundingClientRect().height;if(Number.isFinite(e)&&e>0)return e}return window.innerHeight||1},Os=e=>{let t=null,n=()=>{t?.(),t=null;let n=(()=>{try{return e.contentDocument}catch{return null}})();if(!n)return;let r=hs(e);if(!r)return;let i=null;if(!xs(n,n.querySelector(`style[${fs}]`))){let e=n.createElement(`style`);e.setAttribute(fs,`true`),e.textContent=ps,(n.head??n.documentElement).appendChild(e),i=e}let a=null,o=()=>{a?.active&&a.controller.finish(`cancel`),a=null},s=t=>{if(o(),t.touches.length!==1||(ys(n,t.target)?t.target:null)?.closest(ms)||!Es(n,t.target))return;let r=Ss(t.touches,0);if(!r)return;let i=Ds(e);a={touchId:r.identifier,startX:r.screenX,startY:r.screenY,lastY:r.screenY,lastTime:t.timeStamp,lastVelocityTime:t.timeStamp,velocity:0,motionDistance:i,commitDistance:Jn(i,.1,40,64),active:!1,controller:null}},c=t=>{if(!a)return;if(t.touches.length!==1){o();return}let i=Cs(t.touches,a.touchId);if(!i){o();return}let s=i.screenY-a.startY,c=i.screenX-a.startX,l=t.timeStamp-a.lastTime;if(a.velocity=$n(a.velocity,i.screenY-a.lastY,l,t.timeStamp-a.lastVelocityTime,1),i.screenY!==a.lastY&&l>0&&(a.lastVelocityTime=t.timeStamp),a.lastY=i.screenY,a.lastTime=t.timeStamp,!a.active){if(!Es(n,t.target)){a=null;return}if(!vs(!1,gs(e)?.scrollTop??0,s)){a=null;return}if(!Kn(`bottom`,c,s,8,1))return;let i=qn(r);if(!i?.begin(`dismiss`)){a=null;return}a={...a,active:!0,controller:i}}let u=a;if(!u.active)return;t.preventDefault();let d=Gn(`bottom`,c,s);u.controller.update(Zn(d,u.motionDistance))},l=e=>{if(!a)return;let t=a,n=Cs(e.changedTouches,t.touchId);if(a=null,!t.active)return;if(!n){t.controller.finish(`cancel`);return}let r=e.timeStamp-t.lastTime;t.velocity=$n(t.velocity,n.screenY-t.lastY,r,e.timeStamp-t.lastVelocityTime,1),n.screenY!==t.lastY&&r>0&&(t.lastVelocityTime=e.timeStamp),t.lastY=n.screenY,t.lastTime=e.timeStamp;let i=n.screenY-t.startY,o=n.screenX-t.startX,s=Gn(`bottom`,o,i),c=Yn(s,t.velocity,t.commitDistance,.65,12);t.controller.finish(c?`commit`:`cancel`),e.preventDefault()},u=()=>o();n.addEventListener(`touchstart`,s,{capture:!0,passive:!0}),n.addEventListener(`touchmove`,c,{capture:!0,passive:!1}),n.addEventListener(`touchend`,l,{capture:!0,passive:!1}),n.addEventListener(`touchcancel`,u,{capture:!0,passive:!0}),t=()=>{o(),n.removeEventListener(`touchstart`,s,!0),n.removeEventListener(`touchmove`,c,!0),n.removeEventListener(`touchend`,l,!0),n.removeEventListener(`touchcancel`,u,!0);try{i?.remove()}catch{}i=null}};return e.addEventListener(`load`,n),n(),()=>{e.removeEventListener(`load`,n),t?.()}},ks=br(()=>W(()=>import(`./ToolOutputDialog-CrXMwUq9.js`),__vite__mapDeps([3,1,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,2,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]))),As=25e4,js=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Ms=e=>{let t=js(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},Ns=e=>{let t=js(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},Ps=(e,t)=>{let n=js(e),r=js(t);return!r||n===r?Ms(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},Fs=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``},Is=e=>/\.(md|mdx|markdown)$/i.test(e),Ls=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return`/api/fs/serve${t.startsWith(`/`)?t:`/${t}`}`},Rs=e=>V(Ls(e)).url,zs=e=>{let t=(0,za.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}=de(),{files:u}=ee(),d=kr()??null,f;t[0]===d?f=t[1]:(f=js(d),t[0]=d,t[1]=f);let p=f,m;t[2]!==o||t[3]!==p?(m=()=>{let e=js(o);return e?{type:`file`,path:e,returnDirectory:Ns(e)??p}:{type:`browser`,directory:p}},t[2]=o,t[3]=p,t[4]=m):m=t[4];let[h,g]=Q.useState(m),_=Q.useRef(null),[v,y]=Q.useState(``),b=k(qs),x=k(Js),S,C;t[5]===p?(S=t[6],C=t[7]):(S=()=>{p&&g(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:Ns(e.path)??p}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:p})},C=[p],t[5]=p,t[6]=S,t[7]=C),Q.useEffect(S,C);let w,T;t[8]!==b||t[9]!==p||t[10]!==x?(T=()=>{if(!b||!p)return;let e=js(b);if(!e){x(null);return}y(``),g({type:`file`,path:e,returnDirectory:Ns(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]),Q.useEffect(T,w);let E=h.type===`browser`?h.directory:h.returnDirectory,D=h.type===`browser`?h.directory:``,O=h.type===`file`?h.path:``,[A,j]=Q.useState(`preview`),M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{j(`preview`)},t[13]=M):M=t[13];let N;t[14]===O?N=t[15]:(N=[O],t[14]=O,t[15]=N),Q.useEffect(M,N);let P=cr(v,250),F;t[16]===v?F=t[17]:(F=v.trim(),t[16]=v,t[17]=F);let I=F,V;t[18]===P?V=t[19]:(V=P.trim(),t[18]=P,t[19]=V);let te=V,ne;t[20]!==D||t[21]!==p?(ne={scopeDirectory:p,directory:D},t[20]=D,t[21]=p,t[22]=ne):ne=t[22];let H=!!D,U;t[23]===H?U=t[24]:(U={enabled:H,refetchOnMount:`always`},t[23]=H,t[24]=U);let W=z(ne,U),re;t[25]!==D||t[26]!==te?(re={directory:D,query:te,maxResults:40},t[25]=D,t[26]=te,t[27]=re):re=t[27];let ie=!!(D&&te),ae;t[28]===ie?ae=t[29]:(ae={enabled:ie},t[28]=ie,t[29]=ae);let oe=B(re,ae),G;t[30]===O?G=t[31]:(G=O&&(!Er(O)||O.toLowerCase().endsWith(`.svg`)),t[30]=O,t[31]=G);let se=!!G,ce;t[32]!==O||t[33]!==p?(ce={scopeDirectory:p,path:O},t[32]=O,t[33]=p,t[34]=ce):ce=t[34];let le;t[35]===se?le=t[36]:(le={enabled:se},t[35]=se,t[36]=le);let K=R(ce,le),q=se&&K.data?.isBinary===!0,fe;t[37]!==O||t[38]!==K.data||t[39]!==K.error||t[40]!==K.isFetchedAfterMount||t[41]!==u||t[42]!==A||t[43]!==q?(fe=O&&u.readFile&&K.data&&K.isFetchedAfterMount&&!K.error&&!q&&(!Or(O)||A===`source`)&&(!Er(O)||O.toLowerCase().endsWith(`.svg`)),t[37]=O,t[38]=K.data,t[39]=K.error,t[40]=K.isFetchedAfterMount,t[41]=u,t[42]=A,t[43]=q,t[44]=fe):fe=t[44];let X=!!fe,pe;t[45]!==O||t[46]!==p?(pe={scopeDirectory:p,path:O},t[45]=O,t[46]=p,t[47]=pe):pe=t[47];let me;t[48]===X?me=t[49]:(me={enabled:X},t[48]=X,t[49]=me);let he=L(pe,me),ge=W.data?.entries.slice().sort(Ys)??[],_e;t[50]!==W.error||t[51]!==l?(_e=W.error?W.error instanceof Error?W.error.message:l(`mobile.files.error.listFailed`):null,t[50]=W.error,t[51]=l,t[52]=_e):_e=t[52];let ve=_e,ye=W.isFetching,be;t[53]===oe.data?be=t[54]:(be=oe.data??[],t[53]=oe.data,t[54]=be);let xe=be,Se=!!(I&&te&&v===P&&oe.isFetching),Ce;t[55]!==he.data||t[56]!==l?(Ce=he.data&&he.data.length>As?`${he.data.slice(0,As)}\n\n${l(`mobile.files.file.truncated`)}`:he.data??``,t[55]=he.data,t[56]=l,t[57]=Ce):Ce=t[57];let we=Ce,Te=K.error??he.error,Ee;t[58]!==u||t[59]!==q||t[60]!==se||t[61]!==Te||t[62]!==l?(Ee=se&&(!u.statFile||!q&&!u.readFile)?l(`mobile.files.error.readUnavailable`):Te?Te instanceof Error?Te.message:l(`filesView.error.readFileFailed`):null,t[58]=u,t[59]=q,t[60]=se,t[61]=Te,t[62]=l,t[63]=Ee):Ee=t[63];let De=Ee,Oe=!De&&(se&&(!K.data||!K.isFetchedAfterMount)||X&&he.isFetching&&he.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=J(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],pa(Ie);let Le;t[76]===l?Le=t[77]:(Le=async e=>{(await ue(e)).ok||tt.error(l(`mobile.files.toast.copyFailed`))},t[76]=l,t[77]=Le);let Re=Le,ze;t[78]!==we||t[79]!==l?(ze=async()=>{(await ue(we)).ok?tt.success(l(`mobile.files.toast.contentCopied`)):tt.error(l(`mobile.files.toast.copyFailed`))},t[78]=we,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)(Ks,{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]!==we||t[92]!==De||t[93]!==c||t[94]!==A||t[95]!==q||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)(Us,{path:h.path,content:we,error:De,isLoading:Oe,isBinary:q,hideHeader:c,htmlViewMode:A,onHtmlViewModeChange:j,onBack:Pe,onCopyPath:e,onCopyContent:n})}),t[90]=Pe,t[91]=we,t[92]=De,t[93]=c,t[94]=A,t[95]=q,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`):Ms(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]!==xe?(Ue=v.trim()?xe:[],t[105]=v,t[106]=xe,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=Ns(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)(Z,{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:Ms(a)}),onClick:()=>Ae(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{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]===W?Ze=t[125]:(Ze=()=>void W.refetch(),t[124]=W,t[125]=Ze);let Qe;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Qe={touchAction:`manipulation`},t[126]=Qe):Qe=t[126];let $e=ye&&`animate-spin`,et;t[127]===$e?et=t[128]:(et=Y(`size-5`,$e),t[127]=$e,t[128]=et);let nt;t[129]===et?nt=t[130]:(nt=(0,$.jsx)(Z,{name:`refresh`,className:et}),t[129]=et,t[130]=nt);let rt;t[131]!==Xe||t[132]!==Ze||t[133]!==nt?(rt=(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:nt}),t[131]=Xe,t[132]=Ze,t[133]=nt,t[134]=rt):rt=t[134];let it;t[135]!==Ge||t[136]!==Ke||t[137]!==qe||t[138]!==Ye||t[139]!==rt?(it=(0,$.jsxs)(`header`,{className:Ge,children:[Ke,qe,Ye,rt]}),t[135]=Ge,t[136]=Ke,t[137]=qe,t[138]=Ye,t[139]=rt,t[140]=it):it=t[140];let at;t[141]===Symbol.for(`react.memo_cache_sentinel`)?(at=(0,$.jsx)(Z,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[141]=at):at=t[141];let ot;t[142]===Symbol.for(`react.memo_cache_sentinel`)?(ot=e=>y(e.target.value),t[142]=ot):ot=t[142];let st;t[143]===l?st=t[144]:(st=l(`mobile.files.search.placeholder`),t[143]=l,t[144]=st);let ct;t[145]!==v||t[146]!==st?(ct=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[at,(0,$.jsx)(wn,{type:`text`,inputMode:`search`,value:v,onChange:ot,placeholder:st,className:`h-11 pl-9`})]})}),t[145]=v,t[146]=st,t[147]=ct):ct=t[147];let lt=Sr,ut=ve?(0,$.jsx)(Ks,{message:ve}):v.trim()?(0,$.jsx)(Vs,{results:We,isSearching:Se,onOpenFile:Me}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[ge.length===0&&!ye?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:l(`mobile.files.empty.directory`)}):null,ge.map(e=>(0,$.jsx)(Bs,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:Fs(e.size),onClick:()=>e.isDirectory?Ae(e.path):Me(e.path)},e.path))]}),dt;t[148]!==lt||t[149]!==ut?(dt=(0,$.jsx)(lt,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:ut}),t[148]=lt,t[149]=ut,t[150]=dt):dt=t[150];let ft;return t[151]!==Je||t[152]!==it||t[153]!==ct||t[154]!==dt?(ft=(0,$.jsxs)(`div`,{className:Je,children:[it,ct,dt]}),t[151]=Je,t[152]=it,t[153]=ct,t[154]=dt,t[155]=ft):ft=t[155],ft},Bs=e=>{let t=(0,za.c)(16),{name:n,path:r,directory:i,meta:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==r?(c=i?(0,$.jsx)(Z,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(hn,{filePath:r,className:`size-5 shrink-0`}),t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:n}),t[4]=n,t[5]=l);let u;t[6]===a?u=t[7]:(u=a?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:a}):null,t[6]=a,t[7]=u);let d;t[8]===i?d=t[9]:(d=i?(0,$.jsx)(Z,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null,t[8]=i,t[9]=d);let f;return t[10]!==o||t[11]!==c||t[12]!==l||t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-14 w-full items-center gap-3 border-b border-border/30 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:o,style:s,children:[c,l,u,d]}),t[10]=o,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f):f=t[15],f},Vs=e=>{let t=(0,za.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=de(),o=js(kr()??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)(Ks,{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)(Ks,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(Bs,{name:Ms(e.path),path:e.path,directory:!1,meta:Ps(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},Hs=e=>{let t=(0,za.c)(26),{path:n,canUseText:r,htmlViewMode:i,htmlFullscreen:a,onToggleHtmlViewMode:o,onEnterHtmlFullscreen:s,onCopyPath:c,onCopyContent:l}=e,{t:u}=de(),d;t[0]===n?d=t[1]:(d=Or(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)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:o,"aria-label":u(i===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(Z,{name:i===`preview`?`file-code`:`eye`,className:`size-4`})}),a?null:(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:s,"aria-label":u(`mobile.files.html.fullscreenAria`),children:(0,$.jsx)(Z,{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&&!Er(n)&&!f?(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:l,"aria-label":u(`mobile.files.copyContentAria`),children:(0,$.jsx)(Z,{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||Er(n)||f?(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:c,"aria-label":u(`mobile.files.copyPathAria`),children:(0,$.jsx)(Z,{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},Us=e=>{let t=(0,za.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}=de(),h=Q.useRef(null),g=kr(),_=Er(n)&&!n.toLowerCase().endsWith(`.svg`)?n:``,v;t[0]===n?v=t[1]:(v=Ns(n)??``,t[0]=n,t[1]=v);let y=Un(_,v,`preview`),[b,x]=Q.useState(``),S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S={open:!1,title:``,content:``},t[2]=S):S=t[2];let[C,w]=Q.useState(S),T=y.source,E;t[3]===n?E=t[4]:(E=Ms(n),t[3]=n,t[4]=E);let D=E,O;t[5]!==r||t[6]!==n?(O=Er(n)?`data:${Dr(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||(Er(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=J(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:Dr(n)},image:{url:t,mimeType:Dr(n),filename:D}})},t[21]=D,t[22]=_,t[23]=n,t[24]=j,t[25]=I):I=t[25];let L=J(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 z=J(R),B;t[27]===n?B=t[28]:(B=Or(n),t[27]=n,t[28]=B);let ee=B,[V,te]=Q.useState(!1),ne=Q.useRef(null),H;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{te(!1)},t[29]=H):H=t[29];let U;t[30]===n?U=t[31]:(U=[n],t[30]=n,t[31]=U),Q.useEffect(H,U);let W;t[32]!==c||t[33]!==l?(W=()=>{l(c===`preview`?`source`:`preview`)},t[32]=c,t[33]=l,t[34]=W):W=t[34];let re=J(W),ie;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>{te(!0)},t[35]=ie):ie=t[35];let ae=J(ie),oe;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>(te(!1),!0),t[36]=oe):oe=t[36];let G=J(oe),se=ee&&V,ce;t[37]!==G||t[38]!==se?(ce={id:`mobile-html-fullscreen`,active:se,layer:`overlay`,onBack:G,surfaceRef:ne},t[37]=G,t[38]=se,t[39]=ce):ce=t[39],pa(ce);let le=!o&&!a&&!i,K;t[40]!==ae||t[41]!==V||t[42]!==c||t[43]!==f||t[44]!==d||t[45]!==n||t[46]!==le||t[47]!==re?(K=(0,$.jsx)(Hs,{path:n,canUseText:le,htmlViewMode:c,htmlFullscreen:V,onToggleHtmlViewMode:re,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]=le,t[47]=re,t[48]=K):K=t[48];let q=K,ue;t[49]!==r||t[50]!==i||t[51]!==c||t[52]!==a||t[53]!==n||t[54]!==m?(ue=c===`source`?a?(0,$.jsx)(Ks,{loading:!0,message:m(`filesView.state.loading`)}):i?(0,$.jsx)(Ui,{message:i}):(0,$.jsx)(Gs,{path:n,content:r}):(0,$.jsx)(Ws,{path:n}),t[49]=r,t[50]=i,t[51]=c,t[52]=a,t[53]=n,t[54]=m,t[55]=ue):ue=t[55];let fe=ue,Y;t[56]!==G||t[57]!==ee||t[58]!==fe||t[59]!==V||t[60]!==c||t[61]!==D||t[62]!==m||t[63]!==re?(Y=ee?(0,$.jsxs)(`div`,{ref:ne,"data-mobile-html-preview":c===`preview`&&!V?`true`:void 0,"data-mobile-html-fullscreen":c===`preview`&&V?`true`:void 0,className:V?`fixed inset-0 z-[80] flex flex-col bg-background text-foreground`:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[V?(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-border/50 px-3 pb-2 pt-[max(0.5rem,env(safe-area-inset-top))]`,children:[(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:G,"aria-label":m(`mobile.files.html.exitFullscreenAria`),className:`shrink-0 text-muted-foreground`,children:(0,$.jsx)(Z,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-header text-foreground`,children:D}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:re,"aria-label":m(c===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(Z,{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]=G,t[57]=ee,t[58]=fe,t[59]=V,t[60]=c,t[61]=D,t[62]=m,t[63]=re,t[64]=Y):Y=t[64];let pe=Y,me=g??void 0,he;t[65]!==r||t[66]!==i||t[67]!==q||t[68]!==F||t[69]!==z||t[70]!==p||t[71]!==ee||t[72]!==V||t[73]!==pe||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?(he=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)(Xn,{children:[s,q]}):(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)(Z,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:D})}),s,q]}),(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)(Si,{path:n},n):ee&&!a&&!i?V&&typeof document<`u`?(0,us.createPortal)(pe,document.body):pe:a||y.loading?Er(n)?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-4`,children:(0,$.jsx)(Ar,{className:`aspect-square w-64 max-w-full rounded-lg`})}):(0,$.jsx)(Ks,{loading:!0,message:m(`filesView.state.loading`)}):N?(0,$.jsx)(Ui,{message:N}):Er(n)&&j?(0,$.jsx)(Sr,{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)(jr,{src:j,alt:D,className:`h-auto w-full rounded-lg object-contain`,draggable:!1,onError:F})})}):(0,$.jsx)(Gs,{path:n,content:r}))}),(0,$.jsx)(Kt,{containerRef:h}),C.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(ks,{popup:C,onOpenChange:z,isMobile:!0})}):null]})},t[65]=r,t[66]=i,t[67]=q,t[68]=F,t[69]=z,t[70]=p,t[71]=ee,t[72]=V,t[73]=pe,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]=he):he=t[85];let ge;return t[86]!==n||t[87]!==me||t[88]!==he?(ge=(0,$.jsx)(pi,{path:n,base:me,children:he}),t[86]=n,t[87]=me,t[88]=he,t[89]=ge):ge=t[89],ge},Ws=e=>{let t=(0,za.c)(29),{path:n}=e,{t:i}=de(),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=s(),t[0]=c):c=t[0];let l=c,u=Q.useRef(null),[d,f]=Q.useState(``),[p,m]=Q.useState(0),[g,_]=Q.useState(null),[v,y]=Q.useState(``),b,x;t[1]!==n||t[2]!==i?(b=()=>{let e=!1;if(f(``),_(null),y(``),l)return te({path:n}).then(async e=>{if(!e.ok)throw Error(i(`filesView.error.readFileFailed`));return e.text()}).then(t=>{e||(y(t),f(n))}).catch(t=>{e||(_(t instanceof Error?t.message:i(`filesView.error.readFileFailed`)),f(n))}),()=>{e=!0};let t=h(),s=a(t);r(t).then(t=>{e||!t||(f(n),_(null))}).catch(t=>{e||(_(t instanceof Error?t.message:i(`filesView.error.readFileFailed`)),f(n))});let c=o(()=>{e||(f(n),m(Xs),_(null))});return()=>{e=!0,s(),c()}},x=[n,l,i],t[1]=n,t[2]=i,t[3]=b,t[4]=x):(b=t[3],x=t[4]),Q.useEffect(b,x);let S;t[5]!==n||t[6]!==d?(S=()=>{if(d!==n)return;let e=u.current;if(e)return Os(e)},t[5]=n,t[6]=d,t[7]=S):S=t[7];let C;if(t[8]!==p||t[9]!==n||t[10]!==d||t[11]!==v?(C=[p,n,d,v],t[8]=p,t[9]=n,t[10]=d,t[11]=v,t[12]=C):C=t[12],Q.useEffect(S,C),g){let e;return t[13]===g?e=t[14]:(e=(0,$.jsx)(Ui,{message:g}),t[13]=g,t[14]=e),e}if(d!==n){let e;t[15]===i?e=t[16]:(e=i(`filesView.state.loading`),t[15]=i,t[16]=e);let n;return t[17]===e?n=t[18]:(n=(0,$.jsx)(Ks,{loading:!0,message:e}),t[17]=e,t[18]=n),n}let w;t[19]===n?w=t[20]:(w=l?void 0:Rs(n),t[19]=n,t[20]=w);let T=l?v:void 0,E;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(E={backgroundColor:`var(--surface-background)`},t[21]=E):E=t[21];let D;t[22]===i?D=t[23]:(D=i(`filesView.editor.htmlPreviewTitle`),t[22]=i,t[23]=D);let O;return t[24]!==p||t[25]!==w||t[26]!==T||t[27]!==D?(O=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:(0,$.jsx)(`iframe`,{ref:u,src:w,srcDoc:T,className:`h-full min-h-0 w-full flex-1 border-none bg-background`,style:E,sandbox:`allow-scripts allow-same-origin allow-forms`,title:D},p)}),t[24]=p,t[25]=w,t[26]=T,t[27]=D,t[28]=O):O=t[28],O},Gs=e=>{let t=(0,za.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=jt(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??Hn(!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)??Hn(!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=()=>{_r(l),_r(d)},p=[d,l],t[6]=d,t[7]=l,t[8]=f,t[9]=p):(f=t[8],p=t[9]),Q.useEffect(f,p);let m;t[10]!==d.metadata.id||t[11]!==l.metadata.id?(m={light:l.metadata.id,dark:d.metadata.id},t[10]=d.metadata.id,t[11]=l.metadata.id,t[12]=m):m=t[12];let h=m;if(Is(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Sr,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(yr,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=Ms(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=Tr(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)(Sr,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(se,{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},Ks=e=>{let t=(0,za.c)(7),{message:n,loading:r}=e,i=r!==void 0&&r,a;t[0]===i?a=t[1]:(a=i?(0,$.jsx)(Z,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(Z,{name:`folder-open-fill`,className:`size-6 text-muted-foreground`}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s};function qs(e){return e.pendingFileFocusPath}function Js(e){return e.setPendingFileFocusPath}function Ys(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}function Xs(e){return e+1}var Zs=y(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),Qs=y()(b(e=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(t,n)=>e(e=>({projectExpanded:{...e.projectExpanded,[t]:n}})),setWorktreeExpanded:(t,n)=>e(e=>({worktreeExpanded:{...e.worktreeExpanded,[t]:n}}))}),{name:`mobile-session-tree`,storage:j()}));typeof window<`u`&&c(e=>{m(e)&&Qs.persist.rehydrate()});var $s=36,ec=18,tc=e=>e.parentID??null,nc=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),rc=e=>{let t=e;return nc(t.directory??t.project?.worktree??null)},ic=e=>{let t=nc(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},ac=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},oc=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),sc=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))},cc=(e,t)=>{let n=nc(e),r=nc(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},lc=(e,t)=>e.worktrees.find(e=>nc(e.path)===t)??null,uc=(e,t)=>t===e.path||!!lc(e,t),dc=(e,t)=>{let n=nc(t);return n?e.find(e=>uc(e,n))??null:null},fc=(e,t,n)=>!n||`${e.title??``} ${e.id} ${rc(e)} ${t}`.toLowerCase().includes(n),pc=e=>{let t=(0,za.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?xn[n.icon]:null,c=n.color?Sn[n.color]:void 0,l=s??`folder-open`,u;t[0]===c?u=t[1]:(u=c?{color:c}:void 0,t[0]=c,t[1]=u);let d;t[2]!==o||t[3]!==l||t[4]!==u?(d=(0,$.jsx)(Z,{name:l,className:o,style:u}),t[2]=o,t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=d,p;t[6]===a?p=t[7]:(p=Y(`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)(yn,{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},mc=e=>{let t=(0,za.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=Y(`flex size-5 shrink-0 items-center justify-center text-muted-foreground/70 transition-transform duration-150`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-4`}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`span`,{"aria-hidden":!0,className:i,children:a}),t[3]=i,t[4]=o),o},hc=e=>{let t=(0,za.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},gc=e=>{let t=(0,za.c)(12),{onClick:n,className:r}=e,{t:i}=de(),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=Y(`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,r),t[2]=r,t[3]=s);let c;t[4]===n?c=t[5]:(c=e=>{e.stopPropagation(),n()},t[4]=n,t[5]=c);let l,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l={touchAction:`manipulation`},u=(0,$.jsx)(Z,{name:`node-tree`,className:`size-4`}),t[6]=l,t[7]=u):(l=t[6],u=t[7]);let d;return t[8]!==o||t[9]!==s||t[10]!==c?(d=(0,$.jsx)(`button`,{type:`button`,className:s,"aria-label":o,title:o,onClick:c,style:l,children:u}),t[8]=o,t[9]=s,t[10]=c,t[11]=d):d=t[11],d},_c=e=>{let t=(0,za.c)(10),{icon:n,label:r,onClick:i,destructive:a}=e,o=a!==void 0&&a?`destructive`:`ghost`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(Z,{name:n,className:`size-5 shrink-0`}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=l);let u;return t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(X,{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},vc=e=>{let t=(0,za.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}=de(),x;t[0]===n?x=t[1]:(x=sc(ac(n)),t[0]=n,t[1]=x);let S=x,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,R,z,B;if(t[2]!==r||t[3]!==_||t[4]!==y||t[5]!==v||t[6]!==g||t[7]!==i||t[8]!==h.onContextMenu||t[9]!==h.onPointerCancel||t[10]!==h.onPointerDown||t[11]!==h.onPointerMove||t[12]!==h.onPointerUp||t[13]!==h.pressed||t[14]!==u||t[15]!==l||t[16]!==n.title||t[17]!==b){B=n.title?.trim()||b(`mobile.sessions.untitled`);let e=r&&!_&&`bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]`,a=_&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`;t[36]!==e||t[37]!==a?(N=Y(`relative flex items-center gap-1 transition-colors`,e,a),t[36]=e,t[37]=a,t[38]=N):N=t[38],t[39]!==y||t[40]!==v||t[41]!==i||t[42]!==l||t[43]!==b?(P=v&&l?(0,$.jsx)(`button`,{type:`button`,className:`absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,style:{left:Math.max(i-32,2),top:0,bottom:0,touchAction:`manipulation`},"aria-label":b(y?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:e=>{e.stopPropagation(),l()},children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:Y(`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=Y(`flex min-h-12 min-w-0 flex-1 items-center gap-2.5 py-2 pr-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o,s),t[45]=o,t[46]=s,t[47]=w):w=t[47],t[48]===i?T=t[49]:(T={paddingLeft:i,touchAction:`manipulation`},t[48]=i,t[49]=T),E=u,D=h.onPointerDown,O=h.onPointerMove,k=h.onPointerUp,A=h.onPointerCancel,j=h.onContextMenu,M=_,z=`flex min-w-0 flex-1 flex-col`,L=`flex items-center gap-2.5`;let c=r?`bg-primary`:`bg-muted-foreground/30`,d;t[50]===c?d=t[51]:(d=Y(`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=Y(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),I=g?An(B,g):B,t[2]=r,t[3]=_,t[4]=y,t[5]=v,t[6]=g,t[7]=i,t[8]=h.onContextMenu,t[9]=h.onPointerCancel,t[10]=h.onPointerDown,t[11]=h.onPointerMove,t[12]=h.onPointerUp,t[13]=h.pressed,t[14]=u,t[15]=l,t[16]=n.title,t[17]=b,t[18]=C,t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A,t[26]=j,t[27]=M,t[28]=N,t[29]=P,t[30]=F,t[31]=I,t[32]=L,t[33]=R,t[34]=z,t[35]=B}else C=t[18],w=t[19],T=t[20],E=t[21],D=t[22],O=t[23],k=t[24],A=t[25],j=t[26],M=t[27],N=t[28],P=t[29],F=t[30],I=t[31],L=t[32],R=t[33],z=t[34],B=t[35];let ee;t[56]!==F||t[57]!==I?(ee=(0,$.jsx)(`span`,{className:F,children:I}),t[56]=F,t[57]=I,t[58]=ee):ee=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]!==ee||t[62]!==V||t[63]!==L||t[64]!==R?(te=(0,$.jsxs)(`span`,{className:L,children:[R,ee,V]}),t[61]=ee,t[62]=V,t[63]=L,t[64]=R,t[65]=te):te=t[65];let ne;t[66]!==a||t[67]!==g?(ne=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?An(a,g):a}):null,t[66]=a,t[67]=g,t[68]=ne):ne=t[68];let H;t[69]!==te||t[70]!==ne||t[71]!==z?(H=(0,$.jsxs)(`span`,{className:z,children:[te,ne]}),t[69]=te,t[70]=ne,t[71]=z,t[72]=H):H=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]!==H?(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:H}),t[73]=C,t[74]=w,t[75]=T,t[76]=E,t[77]=D,t[78]=O,t[79]=k,t[80]=A,t[81]=j,t[82]=M,t[83]=H,t[84]=U):U=t[84];let W;t[85]!==p||t[86]!==m?(W=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)(Ii,{})}):null,t[85]=p,t[86]=m,t[87]=W):W=t[87];let re;t[88]===b?re=t[89]:(re=b(`sessions.sidebar.session.menu.label`),t[88]=b,t[89]=re);let ie;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(Z,{name:`more-2`,className:`size-4`}),t[90]=ie):ie=t[90];let ae;t[91]!==h.onOpenActions||t[92]!==re?(ae=(0,$.jsx)(X,{variant:`ghost`,size:`icon`,"data-session-drag-ignore":!0,"aria-label":re,onClick:h.onOpenActions,children:ie}),t[91]=h.onOpenActions,t[92]=re,t[93]=ae):ae=t[93];let oe;t[94]!==_||t[95]!==f||t[96]!==d||t[97]!==b||t[98]!==B?(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:B}),onClick:f,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Z,{name:`archive`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:b(`sessions.sidebar.bulkActions.archive`)})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`mr-1.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":b(_?`mobile.sessions.cancelArchiveAria`:`mobile.sessions.archiveSessionAria`,{title:B}),onClick:d,style:{touchAction:`manipulation`},children:_?(0,$.jsx)(Z,{name:`close`,className:`size-4`}):(0,$.jsx)(Z,{name:`archive`,className:`size-4`})})]}):null,t[94]=_,t[95]=f,t[96]=d,t[97]=b,t[98]=B,t[99]=oe):oe=t[99];let G;return t[100]!==N||t[101]!==P||t[102]!==U||t[103]!==W||t[104]!==ae||t[105]!==oe?(G=(0,$.jsxs)(`div`,{className:N,children:[P,U,W,ae,oe]}),t[100]=N,t[101]=P,t[102]=U,t[103]=W,t[104]=ae,t[105]=oe,t[106]=G):G=t[106],G},yc=e=>{let t=(0,za.c)(15),{indent:n,showMore:r,showFewer:i,loadingMore:a,onShowMore:o,onShowFewer:s}=e,c=a!==void 0&&a,{t:l}=de();if(!r&&!i)return null;let u;t[0]===n?u=t[1]:(u={paddingLeft:n,touchAction:`manipulation`},t[0]=n,t[1]=u);let d;t[2]!==s||t[3]!==i||t[4]!==l?(d=i?(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:s,children:[(0,$.jsx)(Z,{name:`arrow-up-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showFewer`)})]}):null,t[2]=s,t[3]=i,t[4]=l,t[5]=d):d=t[5];let f;t[6]!==c||t[7]!==o||t[8]!==r||t[9]!==l?(f=r?(0,$.jsxs)(`button`,{type:`button`,className:Y(`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-60`,c&&`animate-pulse`),onClick:o,disabled:c,children:[(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showMore`)})]}):null,t[6]=c,t[7]=o,t[8]=r,t[9]=l,t[10]=f):f=t[10];let p;return t[11]!==u||t[12]!==d||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-h-10 w-full items-center gap-3 py-1.5 pr-3 text-muted-foreground`,style:u,children:[d,f]}),t[11]=u,t[12]=d,t[13]=f,t[14]=p):p=t[14],p},bc=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=de(),{git:i}=ee(),a=Tt(),o=Be(),s=We(e=>e.activeSessions),c=We(e=>e.activePaginationByDirectory),l=pt(e=>e.projects),u=pt(e=>e.activeProjectId),d=D(e=>e.currentDirectory),f=ct(e=>e.currentSessionId),p=ct(e=>e.availableWorktreesByProject),m=ct(e=>e.setCurrentSession),h=ct(e=>e.archiveSession),g=ct(e=>e.archiveSessions),_=ct(e=>e.updateSessionTitle),v=ct(e=>e.requestSessionSmartTitle),y=ct(e=>e.shareSession),b=ct(e=>e.unshareSession),x=ct(e=>e.openNewSessionDraft),S=pt(e=>e.setActiveProject),C=pt(e=>e.setActiveProjectIdOnly),w=pt(e=>e.removeProject),T=Dt();Ci();let E=Et(e=>e.sessionOrderByScope),O=Et(e=>e.sessionOrderActivityByScope),k=Me(),A=Qs(e=>e.projectExpanded),j=Qs(e=>e.worktreeExpanded),M=Qs(e=>e.setProjectExpanded),N=Qs(e=>e.setWorktreeExpanded),P=yt(e=>e.orderByProject),F=Zs(e=>e.expandedParents),I=Zs(e=>e.toggleParent),[L,R]=Q.useState(``),[z,B]=Q.useState(null),[V,te]=Q.useState(null),[ne,H]=Q.useState(0),[U,W]=Q.useState(!1),[re,ie]=Q.useState(!1),[ae,oe]=Q.useState(null),[G,se]=Q.useState(null),[ce,le]=Q.useState(null),[K,q]=Q.useState(null),[fe,pe]=Q.useState(null),[me,he]=Q.useState(``),[ge,_e]=Q.useState(!1),[ve,ye]=Q.useState(null),be=Q.useRef(null);be.current||=fi({onPressedKeyChange:q});let[xe,Se]=Q.useState(new Set),[Ce,we]=Q.useState(new Map),[Te,Ee]=Q.useState(new Map),De=gi(),Oe=Ti(),ke=J(e=>{Fe(e),xt(e)}),Ae=J(e=>{Promise.all(e.map(e=>(Fe(e),xt(e))))});Q.useEffect(()=>{if(!e){R(``),Ee(new Map),B(null),te(null),se(null),pe(null),ye(null),be.current?.reset();return}},[e]),Q.useEffect(()=>()=>{be.current?.reset()},[]),Q.useEffect(()=>{if(!e)return;if(l.length===0){ct.setState(e=>{let t=di(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),Se(e=>e.size===0?e:new Set),we(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(l.map(async e=>{let n=nc(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([Cn({id:e.id,path:n},{isCurrent:()=>!t}),bn(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(l.map(e=>nc(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);ct.setState(e=>{let t=di(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),Se(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 oc(r,t)?t:r}),we(t=>{let n=new Set(l.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,l,ne]);let je=Q.useMemo(()=>l.map(e=>({id:e.id,label:ic(e.path),path:nc(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:xe.has(nc(e.path)),worktrees:ut(P[e.id],p.get(nc(e.path))??[])})),[xe,l,P,p]),Ne=Q.useMemo(()=>{let e=new Map(o.map(e=>[e.id,e])),t=s.map(t=>{let n=e.get(t.id);return n?mt(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]),Pe=L.trim().toLowerCase(),Ie=Q.useMemo(()=>{let e=je.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===u})),t=(e,t,n)=>{let r=nc(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||ic(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 Ne){let r=rc(n);if(!r)continue;let i=nc(r),a=e.find(e=>uc(e.project,i));if(!a)continue;let o=lc(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=nc(e.path),r=ji(e.sessions.map(e=>({session:e})),E[n],O[n],T);e.sessions.sort((e,t)=>r({session:e},{session:t}));for(let n of e.sessions)tc(n)||(t.totalSessions+=1)}return e},[u,je,Ne,E,O,T]),Le=nc(d),Re=e=>e.isActive?Le===e.project.path?e.project.path:e.project.worktrees.find(e=>cc(Le,e.path))?.path??e.project.path:null,ze=e=>A[e.project.id]??!0,He=(e,t)=>j[`${e.project.id}::${t.key}`]??!1,Ue=e=>{Ee(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},Ge=()=>{se(null),be.current?.reset()},Ke=e=>({onOpenActions:()=>se(e),pressed:K===e.key||G?.key===e.key,onPointerDown:t=>{e.kind!==`session`&&(t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||be.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>se(e)}))},onPointerMove:e=>{be.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{be.current?.end(e.pointerId)},onPointerCancel:e=>{be.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),e.kind!==`session`&&be.current?.openFromContextMenu(e.key,()=>se(e))}}),qe=(e,t)=>{be.current?.consumeClick(e)||t()},Je=(e,t,n,r)=>{let i=Xi(),a=Kr();if(Ee(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=nc(t);if(!o)return;let s=We.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&ht(o)},Ye=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=Xi(),o=new Set(t.sessions.map(e=>e.id)),s=new Map;for(let e of t.sessions){let t=tc(e);if(t&&o.has(t)){let n=s.get(t)??[];n.push(e),s.set(t,n)}}let l=t.sessions.filter(e=>!tc(e)),u=Te.get(i)??a,d=Wr(l,u,Oe),p=l.length-d.length,m=c.get(nc(t.path)),h=m?.hasMore===!0,g=m?.loadingMore===!0,_=l.length>a&&u>a,v=(e,t)=>{let n=s.get(e.id)??[],i=n.length>0,a=!!F[e.id],o=De.has(e.id),c=i&&!a?n.filter(e=>De.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`),p=`session:${e.id}`;return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(vc,{session:e,active:f===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>I(e.id):void 0,confirmingArchive:V===e.id,onSelect:()=>qe(p,()=>$e(e)),onRequestArchive:()=>et(e.id),onConfirmArchive:()=>void nt(e),onStop:o||l?()=>Ae(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:d}),longPressHandlers:Ke({key:p,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+ec)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Pi,{scopeKey:V?null:nc(t.path),sessionIds:d.map(e=>e.id),folderIdBySessionId:new Map(d.map(e=>[e.id,Et.getState().getSessionFolderId(nc(t.path),e.id)])),onSessionDroppedOnFolder:()=>{},onSessionsReordered:(e,n)=>{Et.getState().reorderSessions(nc(t.path),d.map(e=>e.id),e,n,xi(t.sessions)).catch(()=>tt.error(r(`sessions.order.saveFailed`)))},children:d.map(e=>V?v(e,n):(0,$.jsx)(bi,{sessionId:e.id,sessionDirectory:t.path,sessionTitle:e.title??``,children:v(e,n)},e.id))}),(0,$.jsx)(yc,{indent:n,showMore:p>0||h,showFewer:_,loadingMore:g,onShowMore:()=>Je(i,t.path,u,l.length),onShowFewer:()=>Ue(i)})]})},Ze=(e,t)=>{M(e,!t)},Qe=(e,t,n)=>{N(`${e}::${t}`,!n)},$e=e=>{Wn();let n=rc(e)||null,r=dc(je,n??``);r&&C(r.id),m(e.id,n),t(!1)},et=e=>{te(t=>t===e?null:e)},nt=async e=>{te(null),await h(e.id)?ei({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`)}):tt.error(r(`sessions.sidebar.session.archive.error`))},rt=()=>{x(),t(!1)},it=e=>{oe(e),C(e),ie(!0)},at=e=>{let t=new Map;for(let e of Ne){let n=tc(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},ot=async e=>{let t=at(e.id),{archivedIds:n,failedIds:i}=await g(t);n.length>0&&ei({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&&tt.error(i.length===1?r(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):r(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}))},st=e=>{let t=at(e.id);Zr({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`)})},lt=async e=>{try{if(!(await y(e.id))?.share?.url){tt.error(r(`sessions.sidebar.session.share.error`));return}tt.success(r(`sessions.sidebar.session.share.successTitle`),{description:r(`sessions.sidebar.session.share.successDescription`)})}catch{tt.error(r(`sessions.sidebar.session.share.error`))}},dt=async e=>{if((await ue(e)).ok){tt.success(r(`sessions.sidebar.session.menu.copied`));return}tt.error(r(`sessions.sidebar.session.share.copyUrlError`))},ft=async e=>{try{if(await b(e)){tt.success(r(`sessions.sidebar.session.unshare.success`));return}tt.error(r(`sessions.sidebar.session.unshare.error`))}catch{tt.error(r(`sessions.sidebar.session.unshare.error`))}},gt=async()=>{if(!fe)return;let e=me.trim();if(e)try{await _(fe.id,e),pe(null),he(``)}catch{tt.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},_t=async()=>{if(!fe||ge)return;let e=fe.id;pe(null),he(``),_e(!0);try{await v(e)}catch{tt.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{_e(!1)}},vt=(e,n)=>{C(e.id),x({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},bt=e=>{(async()=>{try{await Cn({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=ct.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await Ve(n,Ne)})()},St=e=>{let t=rc(e),n=dc(je,t);if(!n)return ic(t)||t;let r=lc(n,nc(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},Ct=e=>{S(e.id),t(!1)},wt=Q.useMemo(()=>Pe?Ie.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Pe)?!0:e.buckets.some(t=>t.sessions.some(t=>fc(t,e.project.label,Pe)))):Ie,[Pe,Ie]),Ot=Q.useMemo(()=>Pe?Ne.filter(e=>{let t=rc(e);return fc(e,dc(je,t)?.label??``,Pe)}).sort((e,t)=>Xe(t)-Xe(e)):[],[Pe,je,Ne]),kt=Q.useMemo(()=>Pe?je.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Pe)).map(e=>({...e,sessionCount:Ne.filter(t=>!tc(t)&&uc(e,nc(rc(t)))).length})):[],[Pe,je,Ne]),At=Pe&&Ot.length===0&&kt.length===0,jt=je.length>0?(0,$.jsxs)(X,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:rt,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Z,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,Mt=je.find(e=>e.id===u)??null,Nt=Mt?.isGitRepo?(0,$.jsx)(X,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>it(Mt.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`node-tree`,className:`size-4`})}):null,Pt=(0,$.jsx)(X,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>W(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`})}),Ft=jt||Pt?(0,$.jsxs)($.Fragment,{children:[jt,Nt,Pt]}):null,It=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`):``,Rt=Q.useMemo(()=>{if(!G)return[];if(G.kind===`project`){let e=G.project;return Xr({gitRepository:e.isGitRepo,onNewSession:()=>{Ge(),vt(e,e.path)},onNewWorktree:()=>{Ge(),it(e.id)},onSyncSessions:()=>{Ge(),bt(e)},onEditProject:()=>{Ge(),B(e.id)},onCloseProject:()=>{Ge(),le(e)}})}if(G.kind===`worktree`){let{project:e,worktree:t}=G;return ti({onNewSession:()=>{Ge(),vt(e,t.path)},onDeleteWorktree:()=>{Ge(),ye({project:e,worktree:t})}})}let e=G.session,t=!!e.share?.url;return $r({pinned:T.has(e.id),shared:t,onRename:()=>{Ge(),he(e.title?.trim()||r(`mobile.sessions.untitled`)),pe(e)},onTogglePin:()=>{Ge(),k(e.id)},onShare:!a||t?void 0:()=>{Ge(),lt(e)},onCopyLink:a&&t?()=>{let t=e.share?.url;Ge(),t&&dt(t)}:void 0,onUnshare:a&&t?()=>{Ge(),ft(e.id)}:void 0,onArchive:()=>{Ge(),ot(e)},onDelete:()=>{Ge(),st(e)}})},[G,Ge,ot,dt,st,it,lt,ft,T,vt,bt,r,k]),zt=Rt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Rt.map(e=>{let t=(0,$.jsx)(_c,{icon:e.icon,label:oi(e,r),destructive:e.destructive,onClick:e.onClick},e.id);return e.separated?(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:t},e.id):t})}):null,Bt=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Z,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(wn,{value:L,onChange:e=>R(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:Y(`h-11 pl-9`,L&&`pr-10`)}),L?(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:()=>R(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsx)(Sr,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:je.length===0?(0,$.jsx)(xc,{title:r(`mobile.sessions.empty.noProjectsTitle`),description:r(`mobile.sessions.empty.noProjectsDescription`),action:(0,$.jsxs)(X,{type:`button`,size:`lg`,onClick:()=>W(!0),children:[(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):At?(0,$.jsx)(xc,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Pe?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 pt-2`,children:[Ot.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:Ot.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Ot.map((e,t)=>{let n=De.has(e.id),i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:Y(t>0&&`border-t border-border/30`),children:(0,$.jsx)(vc,{session:e,active:f===e.id,indent:12,contextLabel:St(e),highlightQuery:Pe,onSelect:()=>qe(`session:${e.id}`,()=>$e(e)),longPressHandlers:Ke({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>ke(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,kt.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:kt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:kt.map((e,t)=>{let n=`project:${e.id}`,r=Ke({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:Y(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:Y(`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:()=>qe(n,()=>Ct(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(pc,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:An(e.label,Pe)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(gc,{className:`mr-2`,onClick:()=>it(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:wt.map((e,t)=>{let n=ze(e),i=`project:${e.project.id}`,a=Ke({key:i,kind:`project`,project:e.project}),o=Pe?e.buckets.filter(t=>t.sessions.some(t=>fc(t,e.project.label,Pe))):e.buckets,s=Re(e);return(0,$.jsxs)(`section`,{className:Y(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:Y(`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:()=>qe(i,()=>Ze(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)(pc,{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}),Ce.get(e.project.id)?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:Ce.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(hc,{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=>De.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(),Ae(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Ii,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(gc,{className:`mr-2`,onClick:()=>it(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?Ye(e,t,$s):null,n.map(t=>{let n=He(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Ke({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:Y(`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:()=>qe(a,()=>Qe(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)(mc,{expanded:n}),(0,$.jsx)(Z,{name:`node-tree`,className:Y(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:Y(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(hc,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>De.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(),Ae(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Ii,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?Ye(e,t,$s):null]},t.key)})]})})()}):null]},e.project.id)})})}),(0,$.jsx)(li,{open:U,onOpenChange:W,forceMobile:!0}),(0,$.jsx)(Lt,{open:re,projectId:ae,onOpenChange:e=>{ie(e),e||oe(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?m(n.sessionId,e):x({selectedProjectId:ae,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(Fn,{open:!!G,title:It,onClose:Ge,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:zt}),(0,$.jsx)(Fn,{open:!!ce,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>le(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>le(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(X,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!ce)return;let e=ce;le(null),w(e.id),tt.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:ce?.label??``})})}),(0,$.jsx)(Fn,{open:!!fe,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{ge||(pe(null),he(``))},footer:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`default`,className:`flex-1`,disabled:ge,onClick:()=>{pe(null),he(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(X,{type:`button`,variant:`default`,className:`flex-1`,disabled:!me.trim()||ge,onClick:()=>void gt(),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(),gt()},children:[(0,$.jsx)(wn,{value:me,onChange:e=>he(e.target.value),autoFocus:!0,className:`h-12`,disabled:ge}),(0,$.jsxs)(X,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:ge,onClick:()=>void _t(),children:[ge?(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-4`}),r(`sessions.sidebar.session.rename.smartTitle`)]})]})}),ve?(0,$.jsx)(ui,{open:!0,project:{id:ve.project.id,path:ve.project.path},worktree:ve.worktree,onClose:()=>ye(null),onDeleted:()=>H(e=>e+1)}):null,(0,$.jsx)(Qr,{open:z!==null,project:je.find(e=>e.id===z)??null,onClose:()=>B(null),onWorktreesChanged:()=>H(e=>e+1)})]});return n===`sidebar`?e?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsx)(`div`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center justify-end gap-2 px-4`,children:Ft?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:Ft}):null}),Bt]}):null:(0,$.jsx)(er,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:Ft,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:Bt})},xc=e=>{let t=(0,za.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},Sc=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`;function Cc(e){let t=(0,za.c)(19),{swipe:n,actions:r}=e,{offset:i,dragging:a,actionRailRef:o,closeActions:s}=n,c=i!==0,l=a?`transition-none`:`transition-transform duration-150 ease-out`,u=!c&&`invisible pointer-events-none`,d;t[0]!==l||t[1]!==u?(d=Y(`yuri-mobile-session-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,l,u),t[0]=l,t[1]=u,t[2]=d):d=t[2];let f=`translate3d(calc(var(--yuri-mobile-session-actions-width) + ${i}px), 0, 0)`,p=c?`transform`:void 0,m;t[3]!==f||t[4]!==p?(m={transform:f,willChange:p},t[3]=f,t[4]=p,t[5]=m):m=t[5];let h=!c,g;if(t[6]!==r||t[7]!==s||t[8]!==c){let e;t[10]!==s||t[11]!==c?(e=e=>(0,$.jsxs)(X,{type:`button`,variant:e.destructive?`destructive`:`secondary`,className:Y(`yuri-mobile-session-action h-full flex-col rounded-none border-0 px-1`,!e.destructive&&`bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-active`),"aria-label":e.label,tabIndex:c?0:-1,onClick:()=>{s(),e.onClick()},children:[(0,$.jsx)(Z,{name:e.icon,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`yuri-mobile-session-action-label font-medium`,children:e.label})]},e.label),t[10]=s,t[11]=c,t[12]=e):e=t[12],g=r.map(e),t[6]=r,t[7]=s,t[8]=c,t[9]=g}else g=t[9];let _;return t[13]!==o||t[14]!==d||t[15]!==m||t[16]!==h||t[17]!==g?(_=(0,$.jsx)(`div`,{ref:o,"data-session-drag-ignore":!0,className:d,style:m,"aria-hidden":h,children:g}),t[13]=o,t[14]=d,t[15]=m,t[16]=h,t[17]=g,t[18]=_):_=t[18],_}var wc=10,Tc=`yuri:mobile-session-row-revealed`,Ec=e=>{window.dispatchEvent(new CustomEvent(Tc,{detail:e}))};function Dc(e,t,n){let r=(0,za.c)(32),i=n!==void 0&&n,[a,o]=Q.useState(0),[s,c]=Q.useState(!1),l=Q.useRef(null),u=Q.useRef(!1),d=Q.useRef(null),f,p;r[0]===i?(f=r[1],p=r[2]):(f=()=>{i&&(l.current=null,u.current=!0,o(0),c(!1))},p=[i],r[0]=i,r[1]=f,r[2]=p),Q.useEffect(f,p);let m;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{o(0)},r[3]=m):m=r[3];let h;r[4]===e?h=r[5]:(h=[e],r[4]=e,r[5]=h),Q.useEffect(m,h);let g;r[6]===e?g=r[7]:(g=t=>{t.detail!==e&&o(0)},r[6]=e,r[7]=g),le(Tc,g);let _;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>o(0),r[8]=_):_=r[8];let v=J(_),y;r[9]!==i||r[10]!==a?(y=e=>{if(i||e.button!==0||e.pointerType!==`touch`&&e.pointerType!==`pen`)return;let t=d.current?.offsetWidth??0;t<=0||(l.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startOffset:a,actionWidth:t,intent:`pending`},u.current=!1)},r[9]=i,r[10]=a,r[11]=y):y=r[11];let b=J(y),x;r[12]!==i||r[13]!==e?(x=t=>{if(i)return;let n=l.current;if(!n||n.pointerId!==t.pointerId)return;let r=t.clientX-n.startX,a=t.clientY-n.startY;if(n.intent===`pending`){let i=Math.abs(r),o=Math.abs(a);if(o>wc&&o>i){n.intent=`vertical`,l.current=null;return}if(i>wc&&i>o){n.intent=`horizontal`,c(!0),u.current=!0;try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}Ec(e)}}n.intent===`horizontal`&&(t.preventDefault(),o(Math.max(-n.actionWidth,Math.min(0,n.startOffset+r))))},r[12]=i,r[13]=e,r[14]=x):x=r[14];let S=J(x),C;r[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{let t=l.current;!t||t.pointerId!==e.pointerId||(l.current=null,t.intent===`horizontal`&&(c(!1),o(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))},r[15]=C):C=r[15];let w=J(C),T;r[16]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{let e=l.current;l.current=null,c(!1),o(e?.startOffset??0)},r[16]=T):T=r[16];let E=J(T),D;r[17]!==v||r[18]!==e||r[19]!==a||r[20]!==t?(D=()=>{if(u.current){u.current=!1;return}if(a!==0){v();return}Ec(e),t()},r[17]=v,r[18]=e,r[19]=a,r[20]=t,r[21]=D):D=r[21];let O=J(D),k=J(Oc),A;return r[22]!==v||r[23]!==s||r[24]!==w||r[25]!==k||r[26]!==E||r[27]!==b||r[28]!==S||r[29]!==O||r[30]!==a?(A={offset:a,dragging:s,actionRailRef:d,closeActions:v,handleSelect:O,handlePointerDown:b,handlePointerMove:S,finishGesture:w,handlePointerCancel:E,handleContextMenu:k},r[22]=v,r[23]=s,r[24]=w,r[25]=k,r[26]=E,r[27]=b,r[28]=S,r[29]=O,r[30]=a,r[31]=A):A=r[31],A}function Oc(e){e.preventDefault(),e.stopPropagation()}var kc=[{image:ta,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:na,titleKey:`assistants.guide.share.android.title`,descriptionKey:`assistants.guide.share.android.description`},{image:da,titleKey:`assistants.guide.share.pick.title`,descriptionKey:`assistants.guide.share.pick.description`}];function Ac(){let e=(0,za.c)(8),{t}=de(),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 jc(e){let t=(0,za.c)(35),{onEnable:n}=e,{t:r}=de(),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:Sc,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)(X,{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=kc.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 Mc(e){let t=(0,za.c)(48),{avatarSeed:n,unreadCount:r,assistantID:i,displayName:a,summary:o,enabled:s,editLabel:c,deleteLabel:l,onOpen:u,onEdit:d,onDelete:f,serverWorking:p}=e,m=wa(i,p!==void 0&&p),h=Dc(`assistant:${i}`,u),g=Q.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)(Cc,{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=!s&&`opacity-65`,C;t[12]!==x||t[13]!==S?(C=Y(`yuri-mobile-assistant-card relative z-10 motion-reduce:transition-none`,x,S),t[12]=x,t[13]=S,t[14]=C):C=t[14];let w=h.handleSelect,T=h.handlePointerDown,E=h.handlePointerMove,D=h.finishGesture,O=h.handlePointerCancel,k=h.handleContextMenu,A=`translate3d(${h.offset}px, 0, 0)`,j=h.offset===0?void 0:`transform`,M;t[15]!==A||t[16]!==j?(M={touchAction:`pan-y`,transform:A,willChange:j},t[15]=A,t[16]=j,t[17]=M):M=t[17];let N;t[18]!==i||t[19]!==n||t[20]!==a||t[21]!==m?(N=(0,$.jsx)(`span`,{className:`yuri-mobile-assistant-avatar`,children:(0,$.jsx)(Sa,{name:i,avatarSeed:n,size:44,label:a,working:m,hoverTarget:g})}),t[18]=i,t[19]=n,t[20]=a,t[21]=m,t[22]=N):N=t[22];let P;t[23]===a?P=t[24]:(P=(0,$.jsx)(`span`,{className:`yuri-mobile-entity-title yuri-mobile-assistant-name block min-w-0 truncate font-semibold text-foreground`,children:a}),t[23]=a,t[24]=P);let F;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(F=Y(`yuri-mobile-assistant-summary`,Ca),t[25]=F):F=t[25];let I;t[26]===o?I=t[27]:(I=(0,$.jsx)(`span`,{className:F,children:o}),t[26]=o,t[27]=I);let L;t[28]!==P||t[29]!==I?(L=(0,$.jsxs)(`span`,{className:`yuri-mobile-assistant-card-content min-w-0 flex-1`,children:[P,I]}),t[28]=P,t[29]=I,t[30]=L):L=t[30];let R;t[31]===r?R=t[32]:(R=(0,$.jsx)(ga,{count:r}),t[31]=r,t[32]=R);let z;t[33]!==h.finishGesture||t[34]!==h.handleContextMenu||t[35]!==h.handlePointerCancel||t[36]!==h.handlePointerDown||t[37]!==h.handlePointerMove||t[38]!==h.handleSelect||t[39]!==M||t[40]!==N||t[41]!==L||t[42]!==R||t[43]!==C?(z=(0,$.jsxs)(`button`,{ref:g,type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-feedback":`soft`,className:C,onClick:w,onPointerDown:T,onPointerMove:E,onPointerUp:D,onPointerCancel:O,onContextMenu:k,style:M,children:[N,L,R]}),t[33]=h.finishGesture,t[34]=h.handleContextMenu,t[35]=h.handlePointerCancel,t[36]=h.handlePointerDown,t[37]=h.handlePointerMove,t[38]=h.handleSelect,t[39]=M,t[40]=N,t[41]=L,t[42]=R,t[43]=C,t[44]=z):z=t[44];let B;return t[45]!==z||t[46]!==b?(B=(0,$.jsxs)(ra,{className:`yuri-mobile-assistant-card-shell relative isolate overflow-clip`,children:[b,z]}),t[45]=z,t[46]=b,t[47]=B):B=t[47],B}function Nc(e){let t=(0,za.c)(120),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=de(),o=ar(),s=Oe(),c=je();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=va(l),t[2]=l,t[3]=u);let d=u,f=Ot(Pc),[p,m]=Q.useState(null),h;t[4]===n?h=t[5]:(h=()=>n(),t[4]=n,t[5]=h);let g=J(h),_;t[6]!==o||t[7]!==f?(_=()=>{f(),o?.openSettings(`assistants`)},t[6]=o,t[7]=f,t[8]=_):_=t[8];let v=J(_),y;t[9]===r?y=t[10]:(y=e=>r(e),t[9]=r,t[10]=y);let b=J(y),x;t[11]===o?x=t[12]:(x=e=>{At(e,o?{openMobileSettings:o.openSettings}:void 0)},t[11]=o,t[12]=x);let S=J(x),C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{m(e)},t[13]=C):C=t[13];let w=J(C),T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{e||m(null)},t[14]=T):T=t[14];let E=J(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;if(s.isPending||s.data?.supported&&s.data.enabled&&c.isPending){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ra,{className:`yuri-mobile-assistant-loading`,children:(0,$.jsx)(Ac,{})}),t[21]=e):e=t[21];let n;return t[22]!==i||t[23]!==O?(n=(0,$.jsx)(oa,{title:O,className:i,surface:!1,children:e}),t[22]=i,t[23]=O,t[24]=n):n=t[24],n}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length>0){let e;t[25]===c.data?e=t[26]:(e=(0,$.jsx)(ba,{snapshot:c.data,compact:!0,mobile:!0}),t[25]=c.data,t[26]=e);let n;t[27]===a?n=t[28]:(n=a(`assistants.settings.create`),t[27]=a,t[28]=n);let r;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Z,{name:`add`,className:`size-5`}),t[29]=r):r=t[29];let o;t[30]!==v||t[31]!==n?(o=(0,$.jsx)(X,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:`yuri-mobile-inverse-action`,"aria-label":n,onClick:v,children:r}),t[30]=v,t[31]=n,t[32]=o):o=t[32];let s;t[33]!==e||t[34]!==o?(s=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e,o]}),t[33]=e,t[34]=o,t[35]=s):s=t[35];let l;t[36]===a?l=t[37]:(l=a(`assistants.listAria`),t[36]=a,t[37]=l);let u;if(t[38]!==d||t[39]!==M||t[40]!==A||t[41]!==S||t[42]!==b||t[43]!==w||t[44]!==a){let e;t[46]!==M||t[47]!==A||t[48]!==S||t[49]!==b||t[50]!==w||t[51]!==a?(e=e=>{let t=ye(e.name).displayName||e.name,n=xa(e.latestMessagePreview,a);return(0,$.jsx)(Mc,{assistantID:e.id,avatarSeed:e.avatarSeed,unreadCount:e.unreadCount??0,displayName:t,summary:n,enabled:e.enabled,editLabel:A,deleteLabel:M,assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onOpen:()=>b(e.id),onEdit:()=>S(e.id),onDelete:()=>w(e)},e.id)},t[46]=M,t[47]=A,t[48]=S,t[49]=b,t[50]=w,t[51]=a,t[52]=e):e=t[52],u=d.map(e),t[38]=d,t[39]=M,t[40]=A,t[41]=S,t[42]=b,t[43]=w,t[44]=a,t[45]=u}else u=t[45];let f;t[53]!==l||t[54]!==u?(f=(0,$.jsx)(`div`,{className:`yuri-mobile-assistant-catalog`,role:`listbox`,"aria-label":l,children:u}),t[53]=l,t[54]=u,t[55]=f):f=t[55];let m=p!==null,h;t[56]!==p||t[57]!==E||t[58]!==m?(h=(0,$.jsx)(ya,{assistant:p,open:m,onOpenChange:E}),t[56]=p,t[57]=E,t[58]=m,t[59]=h):h=t[59];let g;return t[60]!==i||t[61]!==O||t[62]!==s||t[63]!==f||t[64]!==h?(g=(0,$.jsxs)(oa,{title:O,className:i,surface:!1,scrollsWithPage:!0,trailing:s,children:[f,h]}),t[60]=i,t[61]=O,t[62]=s,t[63]=f,t[64]=h,t[65]=g):g=t[65],g}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`yuri-mobile-assistant-onboarding-icon`,children:(0,$.jsx)(Z,{name:`ai-agent`,className:`size-5`})}),t[66]=e):e=t[66];let n;t[67]===a?n=t[68]:(n=a(`assistants.onboarding.title`),t[67]=a,t[68]=n);let r;t[69]===n?r=t[70]:(r=(0,$.jsx)(`h2`,{children:n}),t[69]=n,t[70]=r);let o;t[71]===a?o=t[72]:(o=a(`assistants.onboarding.description`),t[71]=a,t[72]=o);let s;t[73]===o?s=t[74]:(s=(0,$.jsx)(`p`,{children:o}),t[73]=o,t[74]=s);let c;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Z,{name:`add`,className:`size-[18px]`}),t[75]=c):c=t[75];let l;t[76]===a?l=t[77]:(l=a(`assistants.onboarding.action`),t[76]=a,t[77]=l);let u;t[78]!==v||t[79]!==l?(u=(0,$.jsxs)(X,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:v,children:[c,l]}),t[78]=v,t[79]=l,t[80]=u):u=t[80];let d;t[81]!==r||t[82]!==s||t[83]!==u?(d=(0,$.jsxs)(ra,{className:`yuri-mobile-assistant-onboarding`,children:[e,r,s,u]}),t[81]=r,t[82]=s,t[83]=u,t[84]=d):d=t[84];let f;return t[85]!==i||t[86]!==O||t[87]!==d?(f=(0,$.jsx)(oa,{title:O,className:i,surface:!1,surfaceClassName:`yuri-mobile-assistant-state`,children:d}),t[85]=i,t[86]=O,t[87]=d,t[88]=f):f=t[88],f}let N=s.isSuccess&&s.data.supported===!1,P=s.isError||s.data?.supported===!0&&s.data.enabled&&c.isError,F=s.data?.supported===!0&&(s.data.enabled===!1||c.data?.enabled===!1),I;t[89]!==a||t[90]!==P||t[91]!==N?(I=a(P?`assistants.state.unavailable`:N?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[89]=a,t[90]=P,t[91]=N,t[92]=I):I=t[92];let L=I;if(F&&!P){let e;t[93]===g?e=t[94]:(e=(0,$.jsx)(jc,{onEnable:g}),t[93]=g,t[94]=e);let n;return t[95]!==i||t[96]!==O||t[97]!==e?(n=(0,$.jsx)(oa,{title:O,className:i,surface:!1,surfaceClassName:`yuri-mobile-assistant-guide-host`,children:e}),t[95]=i,t[96]=O,t[97]=e,t[98]=n):n=t[98],n}let R;t[99]===O?R=t[100]:(R=(0,$.jsx)(`span`,{className:`yuri-mobile-page-section-label`,children:O}),t[99]=O,t[100]=R);let z=N?`cloud-off`:`sparkling`,B;t[101]===z?B=t[102]:(B=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground`,children:(0,$.jsx)(Z,{name:z,weight:`medium`,className:`size-5`})}),t[101]=z,t[102]=B);let ee;t[103]===L?ee=t[104]:(ee=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:L}),t[103]=L,t[104]=ee);let V;t[105]!==a||t[106]!==P||t[107]!==N?(V=P?null:(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-small leading-relaxed text-muted-foreground`,children:a(N?`assistants.state.unsupportedDescription`:`assistants.state.instanceDisabledDescription`)}),t[105]=a,t[106]=P,t[107]=N,t[108]=V):V=t[108];let te;t[109]!==B||t[110]!==ee||t[111]!==V?(te=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[B,ee,V]}),t[109]=B,t[110]=ee,t[111]=V,t[112]=te):te=t[112];let ne;t[113]!==R||t[114]!==te?(ne=(0,$.jsx)($i,{label:R,cardClassName:`yuri-mobile-assistant-state-card`,children:te}),t[113]=R,t[114]=te,t[115]=ne):ne=t[115];let H;return t[116]!==i||t[117]!==O||t[118]!==ne?(H=(0,$.jsx)(oa,{title:O,className:i,surface:!1,surfaceClassName:`yuri-mobile-assistant-state`,children:ne}),t[116]=i,t[117]=O,t[118]=ne,t[119]=H):H=t[119],H}function Pc(e){return e.requestCreate}function Fc(e){let t=(0,za.c)(16),{assistantID:n,onBack:r}=e,{t:i}=de(),[a,o]=(0,Q.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)(ke,{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)(ra,{className:`yuri-mobile-settings-detail-card h-full`,children:(0,$.jsx)(Dn,{children:(0,$.jsx)(la,{assistantID:n,onItemDeleted: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 Ic(e){let t=(0,za.c)(13),{route:n}=e,{t:r}=de(),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)(ke,{title:i,backAriaLabel:a,onBack:Lc}),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)(Gt,{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 Lc(){ha.requestAnimatedBack(`root`)}var Rc=[{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 zc(e){let t=(0,za.c)(22),{activeTab:n,onTabChange:r,className:i,tabMarks:a}=e,{t:o}=de(),s=De(),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=J(u),f;t[4]!==n||t[5]!==r?(f=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Rc.findIndex(e=>e.id===n),i=Rc[e.key===`Home`?0:e.key===`End`?Rc.length-1:(t+(e.key===`ArrowRight`?1:-1)+Rc.length)%Rc.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=J(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=Rc.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)(X,{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:Y(`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)(Hi,{size:23,className:`size-[23px] shrink-0 items-center justify-center [&[data-assistant-navigation-avatar]]:scale-105`}):(0,$.jsx)(Z,{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)(_a,{className:`h-[18px] min-w-[18px] bg-foreground px-1 text-[11px] font-bold tracking-normal text-background shadow-none 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)(Z,{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)(ca,{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 Bc(e){return e.unreadCount>0?`unread`:e.working?`loading`:null}var Vc=`yuri-native-ios-tab-bar`,Hc=`YuriTabBar`,Uc=[`projects`,`assistant`,`scheduled`,`settings`],Wc=H(Hc),Gc=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function Kc(){return typeof window>`u`?!1:Gc({isCapacitor:ie(),platform:oe(),pluginAvailable:U.isPluginAvailable(Hc),nativeUiEnabled:dr()})}var qc=e=>e.classList.contains(`dark`)?`dark`:`light`,Jc=()=>fr(`--primary`),Yc=e=>typeof e==`string`&&Uc.includes(e),Xc=e=>typeof e==`string`&&Yc(e)?e:null,Zc=(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)),Qc=(e,t)=>{e.classList.toggle(Vc,t)},$c=(e,t)=>e&&!t,el=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&Zc(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},tl=()=>Wc,nl=`mobile-overlay-root`;function rl(e){let t=(0,za.c)(28),n=hr(),r;t[0]===n?r=t[1]:(r=n&&Kc(),t[0]=n,t[1]=r);let i=r,[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=(0,Q.useRef)(!1),p=(0,Q.useRef)(!1),m=J(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=JSON.stringify(e.tabs.map(al)),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:qc(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:Jc(),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(nl);e||(e=document.createElement(`div`),e.id=nl,document.body.appendChild(e));let t=()=>u(ln(e.children));t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[an]}),()=>n.disconnect()},S=[i],t[6]=i,t[7]=x,t[8]=S),(0,Q.useEffect)(x,S);let C;t[9]!==i||t[10]!==m?(C=()=>{if(!i)return;let e=!1,t=tl(),n=[];return t.addListener(`tabSelected`,e=>{let t=Xc(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`&&Qc(document.documentElement,!1)}},t[9]=i,t[10]=m,t[11]=C):C=t[11];let w;t[12]===i?w=t[13]:(w=[i],t[12]=i,t[13]=w),(0,Q.useEffect)(C,w);let T;t[14]!==e.activeTab||t[15]!==e.ariaLabel||t[16]!==e.tabs||t[17]!==e.visible||t[18]!==i||t[19]!==l?(T=()=>{if(!i||p.current)return;let t=!1,n=tl(),r={tabs:e.tabs.map(il),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=el({visible:$c(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`&&Qc(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&Qc(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&Qc(document.documentElement,!1))}),()=>{t=!0}},t[14]=e.activeTab,t[15]=e.ariaLabel,t[16]=e.tabs,t[17]=e.visible,t[18]=i,t[19]=l,t[20]=T):T=t[20];let E;return t[21]!==e.activeTab||t[22]!==e.ariaLabel||t[23]!==e.visible||t[24]!==i||t[25]!==l||t[26]!==g?(E=[i,e.visible,l,e.activeTab,e.ariaLabel,v,b,g],t[21]=e.activeTab,t[22]=e.ariaLabel,t[23]=e.visible,t[24]=i,t[25]=l,t[26]=g,t[27]=E):E=t[27],(0,Q.useLayoutEffect)(T,E),!i||s?`web`:a?`native`:`pending`}function il(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 al(e){return[e.id,e.label,e.badge??null,e.activity===!0,e.activity===!0?e.activityLabel??null:null]}function ol(e){let t=(0,za.c)(51),{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}=de(),p=r.activeTab,m=l.slice(-2),h=m.at(-1)??null,g=h?.key??null,_=h?.depth,v=m.length>1?m[m.length-2].key:null,y;t[0]===p?y=t[1]:(y=()=>new Set([p]),t[0]=p,t[1]=y);let[b,x]=Q.useState(y);b.has(p)||x(e=>{if(e.has(p))return e;let t=new Set(e);return t.add(p),t});let S=Q.useRef(null),C=Q.useRef(null),w=Q.useRef(null),T=Q.useRef(new Map),E=Q.useRef(null),D=Q.useRef(!1),O=Q.useRef(``),k=J(()=>h?.onBack());pa({id:h?`mobile-secondary:${h.key}`:`mobile-secondary:inactive`,active:!!h,onBack:k,surfaceRef:S,underlayRef:C}),Q.useLayoutEffect(()=>{let e=g===null?null:T.current.get(g)??null,t=v===null?w.current:T.current.get(v)??null;S.current=e,C.current=t},[g,_,v]);let A;t[2]===h?A=t[3]:(A=[h],t[2]=h,t[3]=A),Q.useLayoutEffect(()=>{if(h){if(!D.current){let e=document.activeElement;E.current=e instanceof HTMLElement?e:null,D.current=!0}O.current!==h.key&&(O.current=h.key,S.current?.focus());return}if(D.current){D.current=!1,O.current=``;let e=E.current;E.current=null,e&&e.isConnected&&e.focus()}},A);let j;t[4]===i?j=t[5]:(j=e=>{i(e)},t[4]=i,t[5]=j);let M=J(j),N=De(),P=Ae(),F=Ee(),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=Bc({unreadCount:N,working:P}),t[8]=N,t[9]=P,t[10]=R):R=t[10];let z=R,B;t[11]===F?B=t[12]:(B=Bc({unreadCount:0,working:F}),t[11]=F,t[12]=B);let ee=B,V;t[13]!==z||t[14]!==N||t[15]!==L||t[16]!==ee||t[17]!==f?(V=Rc.map(e=>{let t=e.id===`assistant`&&z===`loading`||e.id===`scheduled`&&ee===`loading`;return{id:e.id,label:f(e.labelKey),badge:e.id===`assistant`&&z===`unread`?N>99?`99+`:String(N):null,activity:t,activityLabel:t?L:null}}),t[13]=z,t[14]=N,t[15]=L,t[16]=ee,t[17]=f,t[18]=V):V=t[18];let te=V,ne=u&&!d&&!h,H;t[19]===f?H=t[20]:(H=f(`mobile.nav.aria`),t[19]=f,t[20]=H);let U;t[21]!==M||t[22]!==ne||t[23]!==te||t[24]!==p||t[25]!==H?(U={visible:ne,activeTab:p,tabs:te,ariaLabel:H,onTabChange:M},t[21]=M,t[22]=ne,t[23]=te,t[24]=p,t[25]=H,t[26]=U):U=t[26];let W=rl(U),re=W===`native`,ie=u&&W===`web`,ae=hr(),oe,G;t[27]!==ae||t[28]!==re?(oe=()=>{if(!ae){pr.shutdown();return}re&&mr(!0)&&pr.warm()},G=[ae,re],t[27]=ae,t[28]=re,t[29]=oe,t[30]=G):(oe=t[29],G=t[30]),Q.useEffect(oe,G);let se;t[31]===c?se=t[32]:(se=Y(`yuri-mobile-floating-shell relative isolate flex h-full min-h-0 flex-col overflow-hidden text-foreground`,`bg-[var(--yuri-mobile-page-background)]`,c),t[31]=c,t[32]=se);let ce=h?!0:void 0,le=h?!0:void 0,K=h?`true`:void 0,q;t[33]!==p||t[34]!==u||t[35]!==ie||t[36]!==f||t[37]!==n||t[38]!==b?(q=Rc.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:Y(`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)(sl,{tab:e.id,icon:e.icon}):null},e.id)}),t[33]=p,t[34]=u,t[35]=ie,t[36]=f,t[37]=n,t[38]=b,t[39]=q):q=t[39];let ue=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||re?!0:void 0,inert:h||re?!0:void 0,children:ie?(0,$.jsx)(zc,{activeTab:p,onTabChange:M,tabMarks:{assistant:z===`loading`?`loading`:null,scheduled:ee===`loading`?`loading`:null}}):null}):null,fe;t[40]!==w||t[41]!==ce||t[42]!==le||t[43]!==K||t[44]!==q||t[45]!==ue?(fe=(0,$.jsxs)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":ce,inert:le,"data-mobile-navigation-parked":K,className:`flex h-full min-h-0 flex-1 flex-col`,children:[q,ue]}),t[40]=w,t[41]=ce,t[42]=le,t[43]=K,t[44]=q,t[45]=ue,t[46]=fe):fe=t[46];let X=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:Y(`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)}),pe;return t[47]!==se||t[48]!==fe||t[49]!==X?(pe=(0,$.jsxs)(`div`,{className:se,children:[fe,X]}),t[47]=se,t[48]=fe,t[49]=X,t[50]=pe):pe=t[50],pe}function sl(e){let t=(0,za.c)(17),{tab:n,icon:r,className:i}=e,{t:a}=de(),o,s,c,l;if(t[0]!==i||t[1]!==r||t[2]!==a||t[3]!==n){let e=Rc.find(e=>e.id===n)??Rc[0];t[8]===i?c=t[9]:(c=Y(`flex min-h-[70dvh] flex-col items-center justify-center gap-3 text-center`,i),t[8]=i,t[9]=c),l=(0,$.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(Z,{name:r??e.icon,className:`size-6`})}),o=`typography-ui-label font-semibold tracking-[-0.01em] text-foreground`,s=a(e.labelKey),t[0]=i,t[1]=r,t[2]=a,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];let u;t[10]!==o||t[11]!==s?(u=(0,$.jsx)(`h1`,{className:o,children:s}),t[10]=o,t[11]=s,t[12]=u):u=t[12];let d;return t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:c,children:[l,u]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}var cl={neutral:void 0,info:{color:`var(--status-info)`,backgroundColor:`var(--status-info-background)`},success:{color:`var(--status-success)`,backgroundColor:`var(--status-success-background)`},warning:{color:`var(--status-warning)`,backgroundColor:`var(--status-warning-background)`},error:{color:`var(--status-error)`,backgroundColor:`var(--status-error-background)`}},ll=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/g,``);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n.length<=1?t:n.length===2?n[0]:n.slice(-3,-1).join(`/`)};function ul({project:e,expanded:t,embedded:n=!1,onToggle:r,onOpenActions:i,className:a,highlightQuery:o}){let{t:s}=de(),[c,l]=Q.useState(!1),u=Q.useRef(null);u.current||=fi({onPressedKeyChange:t=>l(t===e.id)}),Q.useEffect(()=>()=>u.current?.reset(),[]);let d=J(()=>{u.current?.consumeClick(e.id)||r(e)}),f=J(()=>i?.(e)),p=J(t=>{if(!i||t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0)return;let n=i;u.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{l(!1),n(e)}})}),m=J(e=>{u.current?.move(e.pointerId,e.clientX,e.clientY)}),h=J(e=>{u.current?.end(e.pointerId)}),g=J(e=>{u.current?.cancel(e.pointerId)}),_=J(t=>{if(!i)return;let n=i;t.preventDefault(),t.stopPropagation(),u.current?.openFromContextMenu(e.id,()=>{l(!1),n(e)})}),v=e.sessionCount===1?s(`mobile.sessions.project.sessionsSingle`):s(`mobile.sessions.project.sessionsPlural`,{count:e.sessionCount}),y=ll(e.path),b=(0,$.jsxs)(`article`,{"data-mobile-press-surface":`soft`,"data-pressed":c?`true`:void 0,className:Y(`yuri-mobile-project-card relative flex items-stretch overflow-hidden rounded-[var(--yuri-mobile-surface-radius)]`,a),children:[(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-surface-trigger":!0,className:`yuri-mobile-project-trigger flex min-w-0 flex-1 items-center text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-expanded":t,onClick:d,onPointerDown:p,onPointerMove:m,onPointerUp:h,onPointerCancel:g,onContextMenu:_,style:{touchAction:`pan-y`},children:[(0,$.jsx)(`span`,{className:Y(`yuri-mobile-project-icon yuri-mobile-glass-control flex shrink-0 items-center justify-center rounded-full text-muted-foreground`),style:cl[e.tone??`neutral`],"aria-hidden":!0,children:(0,$.jsx)(Z,{name:e.icon??`code-box`,className:`yuri-mobile-project-icon-glyph`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`yuri-mobile-project-title yuri-mobile-entity-title truncate font-semibold text-foreground`,children:o?An(e.name,o):e.name}),e.active?(0,$.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-[var(--status-success)] shadow-[0_0_0_3px_color-mix(in_srgb,var(--status-success)_12%,transparent)]`,"aria-label":s(`mobile.sessions.activeProjectAria`)}):null]}),(0,$.jsxs)(`span`,{className:`yuri-mobile-project-meta yuri-mobile-entity-meta flex min-w-0 items-center text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:v}),e.activityLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.activityLabel})]}):null,y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,title:e.path,children:y})]}):null]})]}),(0,$.jsx)(Z,{name:`arrow-down-s`,className:Y(`yuri-mobile-project-chevron shrink-0 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,t?`rotate-0`:`-rotate-90`)})]}),i?(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:`yuri-mobile-project-action self-center rounded-full text-muted-foreground`,"aria-label":s(`sessions.sidebar.project.actions.projectMenu`),onClick:f,children:(0,$.jsx)(Z,{name:`more-2`,className:`size-4`})}):null]});return n?b:(0,$.jsx)(ra,{asChild:!0,children:b})}var dl=({hasPendingQuestion:e,hasPendingPermission:t,running:n,unread:r})=>e?`question`:t?`permission`:n?`running`:r?`completed-unread`:`idle`;function fl(e){let t=(0,za.c)(131),{session:n,depth:r,hasChildren:i,expanded:a,paginationContinues:o,onToggleChildren:s,onSelect:c,onPin:l,onArchive:u,onOpenActions:d,indicator:f,className:p,highlightQuery:m}=e,h=r===void 0?0:r,g=i!==void 0&&i,_=a!==void 0&&a,v=o!==void 0&&o,{t:y}=de(),b=Q.useContext(Oi),x;t[0]!==c||t[1]!==n?(x=()=>c(n),t[0]=c,t[1]=n,t[2]=x):x=t[2];let S=Dc(n.id,x,b),{offset:C,dragging:w,handleSelect:T,handlePointerDown:E,handlePointerMove:D,finishGesture:O,handlePointerCancel:k,handleContextMenu:A}=S,j;t[3]!==d||t[4]!==n?(j=()=>d(n),t[3]=d,t[4]=n,t[5]=j):j=t[5];let M=J(j),N;t[6]===s?N=t[7]:(N=()=>s?.(),t[6]=s,t[7]=N);let P=J(N),F;t[8]!==n.pinned||t[9]!==y?(F=n.pinned?y(`sessions.sidebar.session.menu.unpin`):y(`sessions.sidebar.session.menu.pin`),t[8]=n.pinned,t[9]=y,t[10]=F):F=t[10];let I=F,L;t[11]!==f||t[12]!==n.unread?(L=f??dl({hasPendingQuestion:!1,hasPendingPermission:!1,running:!1,unread:!!n.unread}),t[11]=f,t[12]=n.unread,t[13]=L):L=t[13];let R=L,z;t[14]!==R||t[15]!==y?(z=R===`question`?y(`sessions.sidebar.session.status.questionRequired`):R===`permission`?y(`sessions.sidebar.session.status.permissionRequired`):R===`running`?y(`sessions.sidebar.session.status.active`):R===`completed-unread`?y(`sessions.sidebar.session.status.unread`):void 0,t[14]=R,t[15]=y,t[16]=z):z=t[16];let B=z;if(n.kind===`pagination`){let e=v&&`yuri-mobile-session-pagination-continues`,r;t[17]!==p||t[18]!==e?(r=Y(`yuri-mobile-session-row`,e,p),t[17]=p,t[18]=e,t[19]=r):r=t[19];let i;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(i={touchAction:`pan-y`},t[20]=i):i=t[20];let a;t[21]===n.title?a=t[22]:(a=(0,$.jsx)(`span`,{className:`yuri-mobile-entity-title min-w-0 flex-1 truncate text-left font-medium text-muted-foreground`,children:n.title}),t[21]=n.title,t[22]=a);let o;t[23]===n.subtitle?o=t[24]:(o=n.subtitle?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:n.subtitle}):null,t[23]=n.subtitle,t[24]=o);let s;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Z,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`}),t[25]=s):s=t[25];let c;t[26]!==T||t[27]!==a||t[28]!==o?(c=(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`yuri-mobile-session-pagination-row`,style:i,onClick:T,onPointerDown:pl,children:[a,o,s]}),t[26]=T,t[27]=a,t[28]=o,t[29]=c):c=t[29];let l;return t[30]!==r||t[31]!==c?(l=(0,$.jsx)(`div`,{className:r,children:c}),t[30]=r,t[31]=c,t[32]=l):l=t[32],l}let ee;t[33]===p?ee=t[34]:(ee=Y(`yuri-mobile-session-row relative isolate`,p),t[33]=p,t[34]=ee);let V=n.pinned?`unpin`:`pushpin`,te;t[35]!==l||t[36]!==n?(te=()=>l(n),t[35]=l,t[36]=n,t[37]=te):te=t[37];let ne;t[38]!==I||t[39]!==V||t[40]!==te?(ne={label:I,icon:V,onClick:te},t[38]=I,t[39]=V,t[40]=te,t[41]=ne):ne=t[41];let H;t[42]===y?H=t[43]:(H=y(`sessions.sidebar.bulkActions.archive`),t[42]=y,t[43]=H);let U;t[44]!==u||t[45]!==n?(U=()=>u(n),t[44]=u,t[45]=n,t[46]=U):U=t[46];let W;t[47]!==H||t[48]!==U?(W={label:H,icon:`archive`,destructive:!0,onClick:U},t[47]=H,t[48]=U,t[49]=W):W=t[49];let re;t[50]!==ne||t[51]!==W?(re=[ne,W],t[50]=ne,t[51]=W,t[52]=re):re=t[52];let ie;t[53]!==S||t[54]!==re?(ie=(0,$.jsx)(Cc,{swipe:S,actions:re}),t[53]=S,t[54]=re,t[55]=ie):ie=t[55];let ae=w?`transition-none`:`transition-[transform,background-color] duration-150`,oe=n.archived&&`opacity-55`,G;t[56]!==ae||t[57]!==oe?(G=Y(`yuri-mobile-session-row-content relative z-10 flex items-center`,`text-foreground`,`ease-out motion-reduce:transition-none`,ae,oe),t[56]=ae,t[57]=oe,t[58]=G):G=t[58];let se=w?`true`:void 0,ce=`translate3d(${C}px, 0, 0)`,le=C===0?void 0:`transform`,K;t[59]!==ce||t[60]!==le?(K={transform:ce,willChange:le},t[59]=ce,t[60]=le,t[61]=K):K=t[61];let q;t[62]!==_||t[63]!==P||t[64]!==g||t[65]!==s||t[66]!==y?(q=g&&s?(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:`min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":y(_?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:P,children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:Y(`size-3.5 transition-transform duration-150 motion-reduce:transition-none`,_?`rotate-0`:`-rotate-90`)})}):null,t[62]=_,t[63]=P,t[64]=g,t[65]=s,t[66]=y,t[67]=q):q=t[67];let ue=16+Math.min(h,4)*12,fe;t[68]===ue?fe=t[69]:(fe={paddingLeft:ue,touchAction:`pan-y`},t[68]=ue,t[69]=fe);let pe=!B||void 0,me;t[70]===R?me=t[71]:(me=R===`running`?(0,$.jsx)(Ii,{className:`motion-reduce:[&_svg]:animate-none`}):R===`question`?(0,$.jsx)(Z,{name:`question`,className:`size-3.5 text-[var(--status-warning)]`}):R===`permission`?(0,$.jsx)(Z,{name:`shield`,className:`size-3.5 text-destructive`}):(0,$.jsx)(`span`,{className:Y(`yuri-mobile-session-dot rounded-full`,R===`completed-unread`?`bg-[var(--status-info)]`:`bg-muted-foreground/35`)}),t[70]=R,t[71]=me);let he;t[72]!==B||t[73]!==R||t[74]!==pe||t[75]!==me?(he=(0,$.jsx)(`span`,{className:`yuri-mobile-session-status shrink-0`,"data-session-status":R,"aria-hidden":pe,"aria-label":B,title:B,children:me}),t[72]=B,t[73]=R,t[74]=pe,t[75]=me,t[76]=he):he=t[76];let ge=n.unread?`font-semibold`:`font-medium`,_e;t[77]===ge?_e=t[78]:(_e=Y(`yuri-mobile-session-title truncate`,ge),t[77]=ge,t[78]=_e);let ve;t[79]!==m||t[80]!==n.title?(ve=m?An(n.title,m):n.title,t[79]=m,t[80]=n.title,t[81]=ve):ve=t[81];let ye;t[82]!==_e||t[83]!==ve?(ye=(0,$.jsx)(`span`,{className:_e,children:ve}),t[82]=_e,t[83]=ve,t[84]=ye):ye=t[84];let be;t[85]===n.changes?be=t[86]:(be=n.changes?(0,$.jsx)(`span`,{className:`yuri-mobile-session-changes shrink-0 tabular-nums text-muted-foreground`,children:n.changes}):null,t[85]=n.changes,t[86]=be);let xe;t[87]===n.archived?xe=t[88]:(xe=n.archived?(0,$.jsx)(Z,{name:`archive`,className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}):null,t[87]=n.archived,t[88]=xe);let Se;t[89]!==ye||t[90]!==be||t[91]!==xe?(Se=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[ye,be,xe]}),t[89]=ye,t[90]=be,t[91]=xe,t[92]=Se):Se=t[92];let Ce;t[93]!==m||t[94]!==n.subtitle?(Ce=n.subtitle?(0,$.jsx)(`span`,{className:`yuri-mobile-session-subtitle truncate text-muted-foreground`,children:m?An(n.subtitle,m):n.subtitle}):null,t[93]=m,t[94]=n.subtitle,t[95]=Ce):Ce=t[95];let we;t[96]!==Se||t[97]!==Ce?(we=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[Se,Ce]}),t[96]=Se,t[97]=Ce,t[98]=we):we=t[98];let Te;t[99]===n.activityLabel?Te=t[100]:(Te=n.activityLabel?(0,$.jsx)(`span`,{className:`yuri-mobile-session-time tabular-nums`,children:n.activityLabel}):null,t[99]=n.activityLabel,t[100]=Te);let Ee;t[101]===Te?Ee=t[102]:(Ee=(0,$.jsx)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-muted-foreground`,children:Te}),t[101]=Te,t[102]=Ee);let De;t[103]!==O||t[104]!==A||t[105]!==k||t[106]!==E||t[107]!==D||t[108]!==T||t[109]!==fe||t[110]!==he||t[111]!==we||t[112]!==Ee?(De=(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`yuri-mobile-session-row-main flex min-w-0 flex-1 items-center text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,style:fe,onClick:T,onPointerDown:E,onPointerMove:D,onPointerUp:O,onPointerCancel:k,onContextMenu:A,children:[he,we,Ee]}),t[103]=O,t[104]=A,t[105]=k,t[106]=E,t[107]=D,t[108]=T,t[109]=fe,t[110]=he,t[111]=we,t[112]=Ee,t[113]=De):De=t[113];let Oe;t[114]===y?Oe=t[115]:(Oe=y(`sessions.sidebar.session.menu.label`),t[114]=y,t[115]=Oe);let ke;t[116]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,$.jsx)(Z,{name:`more-2`,className:`size-3.5`}),t[116]=ke):ke=t[116];let Ae;t[117]!==M||t[118]!==Oe?(Ae=(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:`mr-1 min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":Oe,"data-session-drag-ignore":!0,onClick:M,children:ke}),t[117]=M,t[118]=Oe,t[119]=Ae):Ae=t[119];let je;t[120]!==G||t[121]!==se||t[122]!==K||t[123]!==q||t[124]!==De||t[125]!==Ae?(je=(0,$.jsxs)(`div`,{className:G,"data-dragging":se,style:K,children:[q,De,Ae]}),t[120]=G,t[121]=se,t[122]=K,t[123]=q,t[124]=De,t[125]=Ae,t[126]=je):je=t[126];let Me;return t[127]!==ee||t[128]!==ie||t[129]!==je?(Me=(0,$.jsxs)(`div`,{className:ee,children:[ie,je]}),t[127]=ee,t[128]=ie,t[129]=je,t[130]=Me):Me=t[130],Me}function pl(){}var ml=Q.memo(fl),hl=10,gl=`yuri:mobile-worktree-row-revealed`,_l=e=>{window.dispatchEvent(new CustomEvent(gl,{detail:e}))};function vl(e){let t=(0,za.c)(10),n=vt(e.session.id),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={bootstrap:!1},t[0]=r):r=t[0];let i=_t(e.session.id,e.session.directory,r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a={bootstrap:!1},t[1]=a):a=t[1];let o=ft(e.session.id,e.session.directory,a).length>0,s=i.length>0,c=!!e.session.unread,l;t[2]!==n||t[3]!==o||t[4]!==s||t[5]!==c?(l=dl({hasPendingQuestion:o,hasPendingPermission:s,running:n,unread:c}),t[2]=n,t[3]=o,t[4]=s,t[5]=c,t[6]=l):l=t[6];let u=l,d;return t[7]!==u||t[8]!==e?(d=(0,$.jsx)(ml,{...e,indicator:u}),t[7]=u,t[8]=e,t[9]=d):d=t[9],d}var yl=Q.memo(vl);function bl(e){let t=(0,za.c)(25),{sessions:n,onSelectSession:r,onPinSession:i,onArchiveSession:a,onOpenSessionActions:o,highlightQuery:s,orderScope:c,onReorderSessions:l}=e,u;t[0]===n?u=t[1]:(u=n.filter(wl).map(Cl),t[0]=n,t[1]=u);let d=u,f;t[2]===d?f=t[3]:(f=new Map(d.map(Sl)),t[2]=d,t[3]=f);let p=f,m=!!(c&&l&&!s&&d.length>1),h;t[4]!==l||t[5]!==c||t[6]!==d?(h=(e,t)=>{c&&l?.(c,d,e,t)},t[4]=l,t[5]=c,t[6]=d,t[7]=h):h=t[7];let g=J(h),_;t[8]!==s||t[9]!==a||t[10]!==o||t[11]!==i||t[12]!==r||t[13]!==n||t[14]!==m?(_=n.map((e,t)=>{let c=e.kind===`pagination`&&n[t+1]?.kind===`pagination`,l=e.kind===`pagination`?ml:yl,u=(0,$.jsx)(l,{session:e,paginationContinues:c,highlightQuery:s,onSelect:r,onPin:i,onArchive:a,onOpenActions:o},e.id);return m&&e.kind!==`pagination`?(0,$.jsx)(bi,{sessionId:e.id,sessionDirectory:e.directory??null,sessionTitle:e.title,children:u},e.id):u}),t[8]=s,t[9]=a,t[10]=o,t[11]=i,t[12]=r,t[13]=n,t[14]=m,t[15]=_):_=t[15];let v;t[16]===_?v=t[17]:(v=(0,$.jsx)($.Fragment,{children:_}),t[16]=_,t[17]=v);let y=v,b;return t[18]!==p||t[19]!==g||t[20]!==c||t[21]!==y||t[22]!==d||t[23]!==m?(b=m?(0,$.jsx)(Pi,{scopeKey:c,sessionIds:d,folderIdBySessionId:p,onSessionDroppedOnFolder:xl,onSessionsReordered:g,children:y}):y,t[18]=p,t[19]=g,t[20]=c,t[21]=y,t[22]=d,t[23]=m,t[24]=b):b=t[24],b}function xl(){}function Sl(e){return[e,null]}function Cl(e){return e.id}function wl(e){return e.kind!==`pagination`}var Tl=Q.memo(bl);function El({project:e,worktree:t,expanded:n,onToggle:r,onNewSession:i,onOpenActions:a,onDelete:o,highlightQuery:s}){let{t:c}=de(),l=`${e.id}::${t.id}`,u=!!(i||o),d=!!a,f=Number(!!i)+Number(!!o),[p,m]=Q.useState(0),[h,g]=Q.useState(!1),[_,v]=Q.useState(!1),y=Q.useRef(null),b=Q.useRef(!1),x=Q.useRef(null),S=Q.useRef(null);S.current||=fi({onPressedKeyChange:e=>g(e===l)}),Q.useEffect(()=>()=>S.current?.reset(),[]),Q.useEffect(()=>{let e=e=>{e.detail!==l&&m(0)};return window.addEventListener(gl,e),()=>window.removeEventListener(gl,e)},[l]),Q.useEffect(()=>{m(0)},[l]);let C=J(()=>m(0)),w=p!==0,T=J(n=>{if(n.button===0&&(n.pointerType===`touch`||n.pointerType===`pen`)){if(u){let e=x.current?.offsetWidth??0;e>0&&(y.current={pointerId:n.pointerId,startX:n.clientX,startY:n.clientY,startOffset:p,actionWidth:e,intent:`pending`},b.current=!1)}d&&S.current?.start({pointerId:n.pointerId,key:l,clientX:n.clientX,clientY:n.clientY,onTrigger:()=>{g(!1),a?.(e,t)}})}}),E=J(e=>{let t=y.current;if(!t||t.pointerId!==e.pointerId){S.current?.move(e.pointerId,e.clientX,e.clientY);return}let n=e.clientX-t.startX,r=e.clientY-t.startY;if(S.current?.move(e.pointerId,e.clientX,e.clientY),t.intent===`pending`){let i=Math.abs(n),a=Math.abs(r);if(a>hl&&a>i){t.intent=`vertical`,y.current=null,S.current?.cancel(e.pointerId);return}if(i>hl&&i>a){t.intent=`horizontal`,v(!0),b.current=!0,S.current?.cancel(e.pointerId);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}_l(l)}}if(t.intent!==`horizontal`)return;e.preventDefault();let i=Math.max(-t.actionWidth,Math.min(0,t.startOffset+n));m(i)}),D=J(e=>{let t=y.current;S.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(y.current=null,t.intent===`horizontal`&&(v(!1),m(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),O=J(e=>{let t=y.current;y.current=null,S.current?.cancel(e.pointerId),v(!1),m(t?.startOffset??0)}),k=J(()=>{if(!S.current?.consumeClick(l)){if(b.current){b.current=!1;return}if(p!==0){C();return}r()}}),A=J(n=>{d&&(n.preventDefault(),n.stopPropagation(),S.current?.openFromContextMenu(l,()=>{g(!1),a?.(e,t)}))}),j=J(()=>{C(),i?.(e,t)}),M=J(()=>{C(),o?.(e,t)}),N=J(()=>a?.(e,t)),P=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`yuri-mobile-group-label-icon`,"aria-hidden":!0,children:(0,$.jsx)(Z,{name:`git-branch`,className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left yuri-mobile-entity-title font-semibold text-foreground`,children:s?An(t.name,s):t.name}),(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:t.sessionCount===1?c(`mobile.sessions.project.sessionsSingle`):c(`mobile.sessions.project.sessionsPlural`,{count:t.sessionCount})}),(0,$.jsx)(Z,{name:`arrow-down-s`,className:Y(`size-3.5 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,n?`rotate-0`:`-rotate-90`)})]});return(0,$.jsxs)(`div`,{className:`yuri-mobile-group-label yuri-mobile-worktree-label relative isolate overflow-hidden`,children:[u?(0,$.jsxs)(`div`,{ref:x,className:Y(`yuri-mobile-worktree-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,_?`transition-none`:`transition-transform duration-150 ease-out`,!w&&`invisible pointer-events-none`),style:{width:`calc(${f} * var(--yuri-mobile-worktree-action-width))`,transform:`translate3d(calc(100% + ${p}px), 0, 0)`,willChange:p===0?void 0:`transform`},"aria-hidden":!w,children:[i?(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`yuri-mobile-worktree-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":c(`mobile.sessions.newSessionAria`),tabIndex:w?0:-1,onClick:j,children:[(0,$.jsx)(Z,{name:`add`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`yuri-mobile-session-action-label font-medium`,children:c(`sessions.sidebar.project.actions.newSession`)})]}):null,o?(0,$.jsxs)(X,{type:`button`,variant:`destructive`,className:`yuri-mobile-worktree-action h-full flex-col rounded-none border-0 px-1`,"aria-label":c(`mobile.projectEdit.deleteWorktreeAria`,{label:t.name}),tabIndex:w?0:-1,onClick:M,children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`yuri-mobile-session-action-label font-medium`,children:c(`mobile.projectEdit.deleteWorktreeConfirmButton`)})]}):null]}):null,(0,$.jsxs)(`div`,{className:Y(`yuri-mobile-worktree-label-content relative z-10 flex min-w-0 flex-1 items-center`,`ease-out motion-reduce:transition-none`,_?`transition-none`:`transition-transform duration-150`),style:{transform:`translate3d(${p}px, 0, 0)`,willChange:p===0?void 0:`transform`},"data-pressed":h?`true`:void 0,children:[(0,$.jsx)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`yuri-mobile-group-label-trigger yuri-mobile-worktree-label-trigger`,"aria-expanded":n,onClick:k,onPointerDown:T,onPointerMove:E,onPointerUp:D,onPointerCancel:O,onContextMenu:A,style:{touchAction:`pan-y`},children:P}),d?(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:`yuri-mobile-worktree-more rounded-full text-muted-foreground`,"aria-label":c(`agentManager.detail.actions.worktreeActionsAria`),onClick:N,children:(0,$.jsx)(Z,{name:`more-2`,className:`size-3.5`})}):null]})]})}function Dl(e){let t=(0,za.c)(95),{projects:n,pinnedSessions:r,inProgressSessions:i,onAddProject:a,onNewSession:o,onScanQr:s,onSwitchInstance:c,onRemoteDesktop:l,instanceOptions:u,onToggleProject:d,onOpenProjectActions:f,onToggleWorktree:p,onNewWorktreeSession:m,onOpenWorktreeActions:h,onDeleteWorktree:g,onSelectSession:_,onPinSession:v,onArchiveSession:y,onOpenSessionActions:b,className:x,onReorderSessions:S}=e,C;t[0]===i?C=t[1]:(C=i===void 0?[]:i,t[0]=i,t[1]=C);let w=C,{t:T}=de(),[E,D]=Q.useState(!0),[O,k]=Q.useState(!1),A=J(a),j=J(o),M;t[2]===s?M=t[3]:(M=()=>s?.(),t[2]=s,t[3]=M);let N=J(M),P;t[4]===c?P=t[5]:(P=()=>c?.(),t[4]=c,t[5]=P);let F=J(P),I;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>k(e),t[6]=I):I=t[6];let L=J(I),R;t[7]===x?R=t[8]:(R=Y(`relative isolate mx-auto flex w-full max-w-[26rem] flex-col gap-5`,x),t[7]=x,t[8]=R);let z;t[9]===T?z=t[10]:(z=T(`mobile.sessions.section.projects`),t[9]=T,t[10]=z);let B;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(Di,{mobile:!0}),t[11]=B):B=t[11];let ee;t[12]===T?ee=t[13]:(ee=T(`mobile.projects.menu.label`),t[12]=T,t[13]=ee);let V=O?`rotate-45`:`rotate-0`,te;t[14]===V?te=t[15]:(te=Y(`size-5 transition-transform duration-150 motion-reduce:transition-none`,V),t[14]=V,t[15]=te);let ne;t[16]===te?ne=t[17]:(ne=(0,$.jsx)(Z,{name:`add`,className:te}),t[16]=te,t[17]=ne);let H;t[18]!==ne||t[19]!==ee?(H=(0,$.jsx)(Ln,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:`yuri-mobile-inverse-action`,"aria-label":ee,children:ne})}),t[18]=ne,t[19]=ee,t[20]=H):H=t[20];let U;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(Z,{name:`chat-new`,className:`size-4`}),t[21]=U):U=t[21];let W;t[22]===T?W=t[23]:(W=T(`mobile.projects.menu.newChat`),t[22]=T,t[23]=W);let re;t[24]!==j||t[25]!==W?(re=(0,$.jsxs)(jn,{className:`min-h-11`,onSelect:j,children:[U,W]}),t[24]=j,t[25]=W,t[26]=re):re=t[26];let ie;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(Z,{name:`folder`,className:`size-4`}),t[27]=ie):ie=t[27];let ae;t[28]===T?ae=t[29]:(ae=T(`mobile.projects.menu.newProject`),t[28]=T,t[29]=ae);let oe;t[30]!==A||t[31]!==ae?(oe=(0,$.jsxs)(jn,{className:`min-h-11`,onSelect:A,children:[ie,ae]}),t[30]=A,t[31]=ae,t[32]=oe):oe=t[32];let G;t[33]!==N||t[34]!==s||t[35]!==T?(G=s?(0,$.jsxs)(jn,{className:`min-h-11`,onSelect:N,children:[(0,$.jsx)(Z,{name:`scan-2`,className:`size-4`}),T(`mobile.projects.menu.scanQr`)]}):null,t[33]=N,t[34]=s,t[35]=T,t[36]=G):G=t[36];let se;t[37]!==F||t[38]!==u||t[39]!==c||t[40]!==T?(se=c&&u?.length?u.map(e=>(0,$.jsxs)(jn,{className:Y(`min-h-11`,e.active&&`bg-interactive-selection text-interactive-selection-foreground`),disabled:e.active||e.disabled,"aria-label":T(`desktopHostSwitcher.actions.switchToAria`,{instance:e.label}),onSelect:()=>c(e.id),children:[(0,$.jsx)(Z,{name:`server`,className:`size-4`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.active?(0,$.jsx)(Z,{name:`check`,className:`size-4`}):null]},e.id)):c?(0,$.jsxs)(jn,{className:`min-h-11`,onSelect:F,children:[(0,$.jsx)(Z,{name:`server`,className:`size-4`}),T(`mobile.projects.menu.switchInstance`)]}):null,t[37]=F,t[38]=u,t[39]=c,t[40]=T,t[41]=se):se=t[41];let ce;t[42]!==l||t[43]!==T?(ce=l?(0,$.jsxs)(jn,{className:`min-h-11`,onSelect:l,children:[(0,$.jsx)(Z,{name:`computer`,className:`size-4`}),T(`remoteDesktop.title`)]}):null,t[42]=l,t[43]=T,t[44]=ce):ce=t[44];let le;t[45]!==re||t[46]!==oe||t[47]!==G||t[48]!==se||t[49]!==ce?(le=(0,$.jsxs)(Mn,{align:`end`,side:`bottom`,className:`min-w-44`,children:[re,oe,G,se,ce]}),t[45]=re,t[46]=oe,t[47]=G,t[48]=se,t[49]=ce,t[50]=le):le=t[50];let K;t[51]!==L||t[52]!==O||t[53]!==H||t[54]!==le?(K=(0,$.jsxs)($.Fragment,{children:[B,(0,$.jsxs)(In,{open:O,onOpenChange:L,children:[H,le]})]}),t[51]=L,t[52]=O,t[53]=H,t[54]=le,t[55]=K):K=t[55];let q;t[56]!==K||t[57]!==z?(q=(0,$.jsx)(Hr,{title:z,trailing:K}),t[56]=K,t[57]=z,t[58]=q):q=t[58];let ue;t[59]!==w||t[60]!==y||t[61]!==b||t[62]!==v||t[63]!==S||t[64]!==_||t[65]!==E||t[66]!==r||t[67]!==T?(ue=r.length>0||w.length>0?(0,$.jsx)(ra,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`yuri-mobile-project-shell`,"aria-label":T(`mobile.sessions.section.pinned`),children:[(0,$.jsx)(ul,{project:{id:`__pinned__`,name:T(`mobile.sessions.section.pinned`),path:``,icon:`pushpin`,sessionCount:r.length+w.length},expanded:E,embedded:!0,onToggle:()=>D(kl)}),E?(0,$.jsxs)(`div`,{className:`yuri-mobile-project-groups`,role:`group`,children:[r.length>0?(0,$.jsx)(`div`,{className:`yuri-mobile-labeled-surface-group`,children:(0,$.jsx)(Tl,{sessions:r,orderScope:hi,onReorderSessions:S,onSelectSession:_,onPinSession:v,onArchiveSession:y,onOpenSessionActions:b})}):null,w.length>0?(0,$.jsx)(`div`,{className:`yuri-mobile-labeled-surface-group`,children:(0,$.jsx)(Tl,{sessions:w,onSelectSession:_,onPinSession:v,onArchiveSession:y,onOpenSessionActions:b})}):null]}):null]})}):null,t[59]=w,t[60]=y,t[61]=b,t[62]=v,t[63]=S,t[64]=_,t[65]=E,t[66]=r,t[67]=T,t[68]=ue):ue=t[68];let fe;t[69]!==A||t[70]!==y||t[71]!==g||t[72]!==m||t[73]!==f||t[74]!==b||t[75]!==h||t[76]!==v||t[77]!==S||t[78]!==_||t[79]!==d||t[80]!==p||t[81]!==n||t[82]!==T?(fe=n.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[52dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(`span`,{className:`mb-4 flex size-14 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(Z,{name:`folder-add`,className:`size-6`})}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:T(`mobile.sessions.empty.noProjectsTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:T(`mobile.sessions.empty.noProjectsDescription`)}),(0,$.jsxs)(X,{type:`button`,size:`lg`,className:`mt-4 min-h-10 rounded-full px-5`,onClick:A,children:[(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`}),T(`sessions.sidebar.header.actions.addProject`)]})]}):n.map(e=>{let t=e.expanded,n=e.worktrees.find(Ol)??(e.worktrees.length===1&&!e.worktrees[0]?.kind?e.worktrees[0]:void 0),r=e.worktrees.filter(e=>e!==n),i=n?.sessions??[];return(0,$.jsx)(ra,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`yuri-mobile-project-shell`,"aria-label":e.name,children:[(0,$.jsx)(ul,{project:e,expanded:t,embedded:!0,onToggle:()=>d(e),onOpenActions:()=>f(e)}),t?(0,$.jsxs)(`div`,{className:`yuri-mobile-project-groups`,role:`group`,"aria-label":e.name,children:[i.length>0?(0,$.jsx)(`div`,{className:`yuri-mobile-labeled-surface-group`,children:(0,$.jsx)(Tl,{sessions:i,orderScope:n?.path,onReorderSessions:S,onSelectSession:_,onPinSession:v,onArchiveSession:y,onOpenSessionActions:b})}):null,r.map(t=>{let n=!!t.expanded;return(0,$.jsx)($i,{className:`yuri-mobile-worktree-group`,ariaLabel:t.name,label:(0,$.jsx)(El,{project:e,worktree:t,expanded:n,onToggle:()=>p(e,t),onNewSession:m,onOpenActions:h,onDelete:g}),children:n&&t.sessions.length>0?(0,$.jsx)(Tl,{sessions:t.sessions,orderScope:t.path,onReorderSessions:S,onSelectSession:_,onPinSession:v,onArchiveSession:y,onOpenSessionActions:b}):null},t.id)})]}):null]})},e.id)}),t[69]=A,t[70]=y,t[71]=g,t[72]=m,t[73]=f,t[74]=b,t[75]=h,t[76]=v,t[77]=S,t[78]=_,t[79]=d,t[80]=p,t[81]=n,t[82]=T,t[83]=fe):fe=t[83];let pe;t[84]===T?pe=t[85]:(pe=T(`sessions.sidebar.header.actions.addProject`),t[84]=T,t[85]=pe);let me;t[86]!==A||t[87]!==pe?(me=(0,$.jsx)(`button`,{type:`button`,className:`sr-only`,onClick:A,children:pe}),t[86]=A,t[87]=pe,t[88]=me):me=t[88];let he;return t[89]!==q||t[90]!==ue||t[91]!==fe||t[92]!==me||t[93]!==R?(he=(0,$.jsxs)(`main`,{className:R,children:[q,ue,fe,me]}),t[89]=q,t[90]=ue,t[91]=fe,t[92]=me,t[93]=R,t[94]=he):he=t[94],he}function Ol(e){return e.kind===`main`}function kl(e){return!e}function Al(e){let t=(0,za.c)(13),{icon:n,label:r,onClick:i,destructive:a,disabled:o,spinning:s}=e,c=a!==void 0&&a,l=o!==void 0&&o,u=s!==void 0&&s,d;t[0]===i?d=t[1]:(d=()=>{Qe(`light`),i()},t[0]=i,t[1]=d);let f=J(d),p=c?`destructive`:`ghost`,m=u?`size-5 animate-spin`:`size-5`,h;t[2]!==n||t[3]!==m?(h=(0,$.jsx)(Z,{name:n,className:m}),t[2]=n,t[3]=m,t[4]=h):h=t[4];let g;t[5]===r?g=t[6]:(g=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[5]=r,t[6]=g);let _;return t[7]!==l||t[8]!==f||t[9]!==p||t[10]!==h||t[11]!==g?(_=(0,$.jsxs)(X,{type:`button`,variant:p,size:`lg`,className:`h-auto min-h-14 w-full justify-start gap-3 rounded-none supports-[corner-shape:squircle]:rounded-none px-4 leading-6 border-0 border-b border-[var(--surface-subtle)] last:border-b-0 active:bg-interactive-active dark:active:bg-interactive-active`,"data-mobile-press-feedback":`none`,disabled:l,onClick:f,children:[h,g]}),t[7]=l,t[8]=f,t[9]=p,t[10]=h,t[11]=g,t[12]=_):_=t[12],_}function jl(e,t,n){return e.reduce((e,t)=>{let n=!!t.separated,r=e.at(-1);return r?.separated===n?r.items.push(t):e.push({separated:n,items:[t]}),e},[]).map(e=>(0,$.jsx)(`div`,{className:`flex flex-col overflow-hidden rounded-2xl bg-[var(--surface-muted)]`,"data-mobile-action-group":e.separated?`separated`:`standard`,children:e.items.map(e=>(0,$.jsx)(Al,{icon:e.icon,label:oi(e,t),onClick:n(e.onClick),destructive:e.destructive,disabled:e.disabled,spinning:e.spinning},e.id))},e.items[0]?.id))}function Ml(e){let t=(0,za.c)(46),{open:n,target:r,actions:i,onOpenChange:a,refreshTranscriptDisabled:o,refreshTranscriptSpinning:s}=e,c=o!==void 0&&o,l=s!==void 0&&s,{t:u}=de(),d;t[0]===a?d=t[1]:(d=e=>()=>{a(!1),e?.()},t[0]=a,t[1]=d);let f=d,p;bb0:{if(!r){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[2]=e):e=t[2],p=e;break bb0}if(r.kind===`session`){let e;t[3]!==i.onArchive||t[4]!==i.onCopyLink||t[5]!==i.onDelete||t[6]!==i.onRefreshTranscript||t[7]!==i.onRename||t[8]!==i.onShare||t[9]!==i.onTogglePin||t[10]!==i.onUnshare||t[11]!==c||t[12]!==l||t[13]!==r.pinned||t[14]!==r.shared?(e=$r({pinned:r.pinned,shared:r.shared,onRename:i.onRename,onTogglePin:i.onTogglePin,onShare:i.onShare,onCopyLink:i.onCopyLink,onUnshare:i.onUnshare,onRefreshTranscript:i.onRefreshTranscript,onArchive:i.onArchive,onDelete:i.onDelete,refreshTranscriptDisabled:c,refreshTranscriptSpinning:l}),t[3]=i.onArchive,t[4]=i.onCopyLink,t[5]=i.onDelete,t[6]=i.onRefreshTranscript,t[7]=i.onRename,t[8]=i.onShare,t[9]=i.onTogglePin,t[10]=i.onUnshare,t[11]=c,t[12]=l,t[13]=r.pinned,t[14]=r.shared,t[15]=e):e=t[15],p=e;break bb0}if(r.kind===`project`){let e;t[16]!==i.onCloseProject||t[17]!==i.onEditProject||t[18]!==i.onNewSession||t[19]!==i.onNewWorktree||t[20]!==i.onSyncSessions||t[21]!==r.gitRepository?(e=Xr({gitRepository:r.gitRepository,onNewSession:i.onNewSession,onNewWorktree:i.onNewWorktree,onSyncSessions:i.onSyncSessions,onEditProject:i.onEditProject,onCloseProject:i.onCloseProject}),t[16]=i.onCloseProject,t[17]=i.onEditProject,t[18]=i.onNewSession,t[19]=i.onNewWorktree,t[20]=i.onSyncSessions,t[21]=r.gitRepository,t[22]=e):e=t[22],p=e;break bb0}let e;t[23]!==i.onDeleteWorktree||t[24]!==i.onNewSession?(e=ti({onNewSession:i.onNewSession,onDeleteWorktree:i.onDeleteWorktree}),t[23]=i.onDeleteWorktree,t[24]=i.onNewSession,t[25]=e):e=t[25],p=e}let m=p;if(!r)return null;let h;t[26]===r.title?h=t[27]:(h=(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:r.title}),t[26]=r.title,t[27]=h);let g=r.title,_;t[28]===u?_=t[29]:(_=u(`mobile.surface.closeAria`),t[28]=u,t[29]=_);let v;t[30]===u?v=t[31]:(v=u(`mobile.sessions.sheet.resizeAria`),t[30]=u,t[31]=v);let y;t[32]!==m||t[33]!==f||t[34]!==u?(y=jl(m,u,f),t[32]=m,t[33]=f,t[34]=u,t[35]=y):y=t[35];let b;t[36]===y?b=t[37]:(b=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain px-3 pb-3`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-5`,"data-page-scroll-lock":`true`,children:y})}),t[36]=y,t[37]=b);let x;return t[38]!==a||t[39]!==n||t[40]!==b||t[41]!==h||t[42]!==_||t[43]!==v||t[44]!==r.title?(x=(0,$.jsx)(er,{id:`mobile-row-actions-sheet`,open:n,onOpenChange:a,title:h,ariaLabel:g,closeAriaLabel:_,resizeAriaLabel:v,fitContent:!0,children:b}),t[38]=a,t[39]=n,t[40]=b,t[41]=h,t[42]=_,t[43]=v,t[44]=r.title,t[45]=x):x=t[45],x}function Nl(e,t){return e&&e.id===t.id&&e.kind===t.kind&&e.title===t.title&&e.subtitle===t.subtitle&&e.changes===t.changes&&e.activityLabel===t.activityLabel&&e.unread===t.unread&&e.pinned===t.pinned&&e.archived===t.archived&&e.active===t.active&&e.directory===t.directory&&e.expanded===t.expanded&&e.children===t.children?e:t}function Pl(e,t){if(!e||e.length===0)return t.slice();let n=new Map(e.map(e=>[e.id,e])),r=e.length===t.length,i=t.map((t,i)=>{let a=Nl(n.get(t.id)??e[i],t);return a!==e[i]&&(r=!1),a});if(r){let t=!0;for(let n=0;n<i.length;n+=1)if(i[n]!==e[n]){t=!1;break}if(t)return e}return i}var Fl=`__show_more__:`,Il=`__show_fewer__:`,Ll=e=>e.startsWith(Fl),Rl=e=>e.startsWith(Il),zl=e=>Ll(e)||Rl(e),Bl=e=>{let t=Ll(e)?Fl:Rl(e)?Il:null;if(!t)return null;let n=e.slice(t.length),r=n.indexOf(`::`);return r<=0?null:{kind:t===`__show_more__:`?`more`:`fewer`,projectId:n.slice(0,r),bucketKey:n.slice(r+2)}},Vl=e=>e.parentID??null,Hl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Ul=e=>{let t=e;return Hl(t.directory??t.project?.worktree??null)},Wl=(e,t)=>{if(t?.trim())return t.trim();let n=Hl(e);if(!n)return``;let r=n.split(`/`).filter(Boolean);return r[r.length-1]||n},Gl=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},Kl=e=>{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))},ql=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},Jl=(e,t)=>e.worktrees.find(e=>Hl(e.path)===t)??null,Yl=(e,t)=>{let n=t?.trim();return n?`${e} · ${n}`:e},Xl=(e,t)=>Li(e,{pinnedSessionIds:t,omitPinnedSessions:!1}).map(e=>e.session);function Zl(){Ci();let e=Et(e=>e.sessionOrderByScope),t=Et(e=>e.sessionOrderActivityByScope),{t:n}=de(),r=Be(),i=We(e=>e.activeSessions),a=We(e=>e.activePaginationByDirectory),o=pt(e=>e.projects),s=at(e=>e.projectSortOrder),c=Q.useMemo(()=>wi(o,s),[o,s]),l=pt(e=>e.activeProjectId),u=D(e=>e.currentDirectory),d=ct(e=>e.currentSessionId),f=ct(e=>e.availableWorktreesByProject),p=yt(e=>e.orderByProject),m=Dt(),h=Qs(e=>e.projectExpanded),g=Qs(e=>e.worktreeExpanded),_=Ye(e=>e.index.session.unseenCount),[v,y]=Q.useState(new Map),b=gi(),x=Q.useMemo(()=>Ri(b,d),[d,b]),S=Q.useMemo(()=>c.map(e=>{let t=Hl(e.path);return{id:e.id,label:Wl(t,e.label),path:t,icon:e.icon,worktrees:ut(p[e.id],f.get(t)??[])}}),[c,p,f]),C=Q.useMemo(()=>{let e=new Map(r.map(e=>[e.id,e])),t=i.map(t=>{let n=e.get(t.id);return n?mt(n,t):t}),n=new Set(t.map(e=>e.id));for(let e of r)n.has(e.id)||t.push(e);return t},[i,r]),w=Q.useMemo(()=>Ir(C,S.map(e=>({id:e.id,normalizedPath:e.path})),f,!1),[S,C,f]),T=Q.useMemo(()=>{let e=S.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===l,latestActivity:0})),t=new Map(e.map(e=>[e.project.id,e])),n=(e,t,n)=>{let r=Hl(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||n?.label||Wl(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a};for(let t of e){n(t,t.project.path,null);for(let e of t.project.worktrees)n(t,e.path,e)}for(let e of C){let r=w.bySessionId.get(e.id);if(!r)continue;let i=t.get(r.projectId);if(!i)continue;let a=r.kind===`worktree`?Jl(i.project,r.scopeDirectory):null;(a?n(i,a.path,a):n(i,i.project.path,null)).sessions.push(e)}for(let t of e)for(let e of t.buckets){e.sessions.sort((e,t)=>Xe(t)-Xe(e));let n=Xl(e.sessions,m);t.totalSessions+=n.length;for(let n of e.sessions){let e=Gl(n);e>t.latestActivity&&(t.latestActivity=e)}}return e},[l,w,m,S,C]),E=Q.useMemo(()=>{let e=new Map;for(let t of C)e.set(t.id,t);return e},[C]),O=Q.useMemo(()=>{let e=new Map;for(let t of S)e.set(t.id,t);return e},[S]),k=Q.useRef([]),A=Q.useRef([]),j=Q.useRef(new Map),{pinnedSessions:M,inProgressSessions:N}=Q.useMemo(()=>{let t=new Map(S.map(e=>[e.id,e])),r=n(`mobile.sessions.untitled`),i=new Map(k.current.map(e=>[e.id,e])),a=new Map(A.current.map(e=>[e.id,e])),o=(e,n,i)=>{let a=w.bySessionId.get(e.id),o=a?t.get(a.projectId):void 0;if(!o)return[];let s=a?.kind===`worktree`?Jl(o,a.scopeDirectory):null,c={id:e.id,directory:Ul(e),title:e.title?.trim()||r,subtitle:Yl(o.label,s?.branch),changes:ir(rr(e))??void 0,activityLabel:Kl(Gl(e))||void 0,unread:(_[e.id]??0)>0,pinned:n,archived:ql(e),active:d===e.id};return[Nl(i.get(e.id),c)]},s=Mi(C,m,e[hi]).flatMap(e=>o(e,!0,i)),c=zi(C,m,b,_).flatMap(e=>o(e,!1,a)),l=Pl(k.current,s),u=Pl(A.current,c);return k.current=l,A.current=u,{pinnedSessions:l,inProgressSessions:u}},[d,w,e,m,S,b,C,n,_]),P=Q.useMemo(()=>{let e=new Map;for(let t of T){let n=t.project.worktrees.length>0;for(let r of t.buckets){let i=Xl(r.sessions,m).length;e.set(`${t.project.id}::${r.key}`,{path:r.path,rootCount:i,hasWorktrees:n})}}return e},[m,T]),F=Q.useMemo(()=>{let r=Hl(u),i=new Map,o=e=>(e.kind!==`pagination`&&i.set(e.id,e),e),s=T.map(s=>{let c=h[s.project.id]??!0,l=Xi(),u=s.project.icon?xn[s.project.icon]:void 0,f=s.buckets.map(c=>{let u=`${s.project.id}::${c.key}`,f=g[u]??!1,p=v.get(u)??l,h=Hl(c.path),y=Xl(c.sessions,m).map(e=>({session:e})),b=y.sort(ji(y,e[h],t[h],m)).map(e=>e.session),S=Li(c.sessions,{pinnedSessionIds:m,omitPinnedSessions:!1}).map(e=>e.session),C=e=>{let t=Vl(e),r=(_[e.id]??0)>0&&!t,a={id:e.id,directory:c.path,title:e.title?.trim()||n(`mobile.sessions.untitled`),changes:ir(rr(e))??void 0,activityLabel:Kl(Gl(e))||void 0,unread:r,pinned:m.has(e.id),archived:ql(e),active:d===e.id},s=Nl(j.current.get(e.id)??i.get(e.id),a);return o(s)},w=Wr(b,p,x).map(C),T=b.length-w.length,E=a.get(Hl(c.path)),D=E?.hasMore===!0,O=b.length>l&&p>l,k=[...w];O&&k.push({id:`${Il}${s.project.id}::${c.key}`,kind:`pagination`,title:n(`sessions.sidebar.group.showFewer`)}),(T>0||D)&&k.push({id:`${Fl}${s.project.id}::${c.key}`,kind:`pagination`,title:n(`sessions.sidebar.group.showMore`),subtitle:E?.loadingMore?`…`:void 0});let A=Hl(c.path),M=!!(s.isActive&&r&&A&&(r===A||r.startsWith(`${A}/`))),N=c.worktree==null;return{id:c.key,name:N?n(`mobile.sessions.mainWorkspace`):c.label,path:c.path,kind:N?`main`:`worktree`,active:M,expanded:N?!0:f,sessionCount:b.length,sessions:k,catalogSessions:S.map(C)}});return{id:s.project.id,name:s.project.label,path:s.project.path,icon:u,sessionCount:s.totalSessions,activityLabel:Kl(s.latestActivity)||void 0,active:s.isActive,expanded:c,worktrees:f}});return j.current=i,s},[a,x,u,d,m,h,e,t,T,n,_,v,g]),I=e=>{for(let[t,n]of P)if(t.startsWith(`${e}::`))return n.hasWorktrees;return!1},L=(e,t)=>P.get(`${e}::${t}`)?.rootCount??0,R=e=>Xi();return{projects:F,pinnedSessions:M,inProgressSessions:N,sessionById:E,projectMetaById:O,allSessions:C,projectHasWorktrees:I,getBucketRootCount:L,getBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;return v.get(n)??R(e)},getBucketPageSize:R,getBucketDirectory:(e,t)=>P.get(`${e}::${t}`)?.path??null,showMoreBucketSessions:(e,t)=>{let n=`${e}::${t}`,r=P.get(n),i=Xi(),a=Kr(),o=v.get(n)??i,s=r?.rootCount??0;if(y(e=>{let t=new Map(e),r=Math.max(i,e.get(n)??i,o);return t.set(n,r+a),t}),Math.max(i,o)+a<s)return;let c=r?.path,l=Hl(c);if(!l)return;let u=We.getState().activePaginationByDirectory.get(l);u?.hasMore&&!u.loadingMore&&ht(l)},resetBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;y(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})}}}var Ql=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function $l({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,onRemoteDesktop:a,instanceOptions:o,className:s}){let{t:c}=de(),{git:l}=ee(),u=Tt(),d=Zl(),f=J((e,t,n,r)=>{let i=Et.getState(),a=e===`__pinned__`?e:re(e);if(!a||a!==`__pinned__`&&i.getSessionFolderId(a,n)!==i.getSessionFolderId(a,r))return;let o=a===`__pinned__`?{}:xi(d.allSessions.filter(e=>Ul(e)===a));i.reorderSessions(a,t,n,r,o).catch(()=>tt.error(c(`sessions.order.saveFailed`)))}),p=Qs(e=>e.setProjectExpanded),m=Qs(e=>e.setWorktreeExpanded),h=Me(),g=Dt(),_=ct(e=>e.archiveSessions),v=ct(e=>e.updateSessionTitle),y=ct(e=>e.requestSessionSmartTitle),b=ct(e=>e.shareSession),x=ct(e=>e.unshareSession),S=ct(e=>e.openNewSessionDraft),C=bt(e=>e.openDraft),w=bt(e=>e.openSession),T=pt(e=>e.projects),E=pt(e=>e.setActiveProjectIdOnly),D=pt(e=>e.removeProject),O=en(),[k,A]=Q.useState(null),[j,M]=Q.useState(!1),[N,P]=Q.useState(null),[F,I]=Q.useState(null),[L,R]=Q.useState(null),[z,B]=Q.useState(``),[V,te]=Q.useState(!1),[ne,H]=Q.useState(!1),[U,W]=Q.useState(null),[ie,ae]=Q.useState(null),[oe,G]=Q.useState(null),se=k?.kind===`session`?k.session.id:``,ce=it(se),le=ce?.type===`busy`||ce?.type===`retry`,K=k?.kind===`session`?Ul(k.session):``,q=!!se&&oe===se,fe=!K||q||le,Y=J(e=>{let t=new Map;for(let e of d.allSessions){let n=Vl(e);if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n}),pe=J(()=>{M(!1),A(null)}),me=J(t=>{if(zl(t.id)){let e=Bl(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&&Ul(n)||null;e({sessionId:t.id,directory:r})}),he=J(e=>{zl(e.id)||h(e.id)}),ge=J(async e=>{if(zl(e.id))return;let t=Y(e.id),{archivedIds:n,failedIds:r}=await _(t);n.length>0&&ei({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&&tt.error(r.length===1?c(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):c(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}),_e=J(()=>{if(!k||k.kind!==`session`)return;let e=k.session,t=Ul(e),n=ce?.type??`idle`;!t||oe===e.id||n===`busy`||n===`retry`||(G(e.id),(async()=>{try{await O.refreshSessionTranscript(e.id,{directory:t}),tt.success(c(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{tt.error(c(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{G(t=>t===e.id?null:t)}})())}),ve=J(e=>{if(zl(e.id))return;let t=d.sessionById.get(e.id);t&&(A({kind:`session`,session:t}),M(!0))}),ye=J(e=>{p(e.id,!e.expanded)}),be=J((e,t)=>{m(`${e.id}::${t.id}`,!t.expanded)}),xe=J((e,t)=>{E(e.id),C({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),Se=J(()=>{if(n){n();return}S()}),Ce=J(e=>{let t=d.projectMetaById.get(e.id);t&&(A({kind:`project`,project:t,isGitRepository:!1}),M(!0),l.checkIsGitRepository(t.path).then(e=>{A(n=>Ql(n,t.id,e))}).catch(()=>{A(e=>Ql(e,t.id,!1))}))}),we=J((e,t)=>{let n=re(t);return n?e.worktrees.find(e=>re(e.path)===n)||((ct.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>re(e.path)===n)??null):null}),Te=J((e,t)=>{let n=d.projectMetaById.get(e.id);n&&xe(n,t.path)}),Ee=J((e,t)=>{let n=d.projectMetaById.get(e.id);n&&(A({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),M(!0))}),De=J((e,t)=>{let n=d.projectMetaById.get(e.id);if(!n)return;let r=we(n,t.path);if(!r){tt.error(c(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}ae({project:n,worktree:r})}),Oe=J(e=>{W(e),E(e),H(!0)}),ke=J(e=>{(async()=>{let t=e.worktrees;try{t=(await Cn({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=ct.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await Ve([e.path,...t.map(e=>e.path)],d.allSessions)})()}),Ae=J((e,t)=>{let n=U;if(H(!1),W(null),t?.sessionId){w({sessionId:t.sessionId,directory:e});return}C({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),je=J(async e=>{try{if(!(await b(e.id))?.share?.url){tt.error(c(`sessions.sidebar.session.share.error`));return}tt.success(c(`sessions.sidebar.session.share.successTitle`),{description:c(`sessions.sidebar.session.share.successDescription`)})}catch{tt.error(c(`sessions.sidebar.session.share.error`))}}),Ne=J(async e=>{if((await ue(e)).ok){tt.success(c(`sessions.sidebar.session.menu.copied`));return}tt.error(c(`sessions.sidebar.session.share.copyUrlError`))}),Pe=J(async e=>{try{if(await x(e)){tt.success(c(`sessions.sidebar.session.unshare.success`));return}tt.error(c(`sessions.sidebar.session.unshare.error`))}catch{tt.error(c(`sessions.sidebar.session.unshare.error`))}}),Fe=J(e=>{let t=Y(e.id);Zr({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`)})}),Ie=J(async()=>{if(!L)return;let e=z.trim();if(e)try{await v(L.id,e),R(null),B(``)}catch{tt.error(c(`sessions.sidebar.session.menu.rename`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),Le=J(async()=>{if(!L||V)return;let e=L.id;R(null),B(``),te(!0);try{await y(e)}catch{tt.error(c(`sessions.sidebar.session.rename.smartTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{te(!1)}}),Re=Q.useMemo(()=>k?k.kind===`session`?{kind:`session`,title:k.session.title?.trim()||c(`mobile.sessions.untitled`),pinned:g.has(k.session.id),shared:!!k.session.share?.url}:k.kind===`project`?{kind:`project`,title:k.project.label,gitRepository:k.isGitRepository}:{kind:`worktree`,title:k.worktreeName}:null,[k,g,c]),ze=Q.useMemo(()=>{if(!k)return{};if(k.kind===`session`){let e=k.session;return{onRename:()=>{B(e.title?.trim()||c(`mobile.sessions.untitled`)),R(e)},onTogglePin:()=>h(e.id),onShare:u&&!e.share?.url?()=>{je(e)}:void 0,onCopyLink:u&&e.share?.url?()=>{Ne(e.share.url)}:void 0,onUnshare:u&&e.share?.url?()=>{Pe(e.id)}:void 0,onRefreshTranscript:_e,onArchive:()=>{ge({id:e.id,title:e.title?.trim()||c(`mobile.sessions.untitled`)})},onDelete:()=>Fe(e)}}if(k.kind===`project`){let e=k.project;return{onNewSession:()=>xe(e,e.path),onNewWorktree:()=>Oe(e.id),onSyncSessions:()=>ke(e),onEditProject:()=>P(e.id),onCloseProject:()=>I(e)}}let{project:e,worktreePath:t}=k;return{onNewSession:()=>xe(e,t),onDeleteWorktree:()=>{let n=we(e,t);if(!n){tt.error(c(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}ae({project:e,worktree:n})}}},[k,ge,Ne,Fe,_e,Oe,ke,je,Pe,we,u,xe,c,h]),Be=Q.useMemo(()=>{if(!N)return null;let e=T.find(e=>e.id===N),t=d.projectMetaById.get(N);if(!e||!t)return null;let n=k?.kind===`project`&&k.project.id===N?k.isGitRepository:t.worktrees.length>0;return{id:e.id,label:e.label?.trim()||t.label,path:re(e.path)||t.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:n,worktrees:t.worktrees}},[k,N,d.projectMetaById,T]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Dl,{className:s,projects:d.projects,pinnedSessions:d.pinnedSessions,inProgressSessions:d.inProgressSessions,onAddProject:t,onNewSession:Se,onScanQr:r,onSwitchInstance:i,instanceOptions:o,onRemoteDesktop:a,onToggleProject:ye,onOpenProjectActions:Ce,onToggleWorktree:be,onNewWorktreeSession:Te,onOpenWorktreeActions:Ee,onDeleteWorktree:De,onSelectSession:me,onPinSession:he,onArchiveSession:e=>{ge(e)},onOpenSessionActions:ve,onReorderSessions:f}),(0,$.jsx)(Ml,{open:j,target:Re,actions:ze,refreshTranscriptDisabled:fe,refreshTranscriptSpinning:q,onOpenChange:e=>{e?M(!0):pe()}}),(0,$.jsx)(Lt,{open:ne,projectId:U,onOpenChange:e=>{H(e),e||W(null)},onWorktreeCreated:Ae}),ie?(0,$.jsx)(ui,{open:!0,project:{id:ie.project.id,path:ie.project.path},worktree:ie.worktree,onClose:()=>ae(null)}):null,(0,$.jsx)(Fn,{open:!!F,title:c(`sessions.sidebar.project.actions.closeProject`),onClose:()=>I(null),closeAriaLabel:c(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>I(null),children:c(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(X,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!F)return;let e=F;I(null),D(e.id),tt.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:F?.label??``})})}),(0,$.jsx)(Fn,{open:!!L,title:c(`sessions.sidebar.session.menu.rename`),onClose:()=>{V||(R(null),B(``))},closeAriaLabel:c(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`default`,className:`flex-1`,disabled:V,onClick:()=>{R(null),B(``)},children:c(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(X,{type:`button`,variant:`default`,className:`flex-1`,disabled:!z.trim()||V,onClick:()=>void Ie(),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(),Ie()},children:[(0,$.jsx)(wn,{value:z,onChange:e=>B(e.target.value),autoFocus:!0,className:`h-12`,disabled:V}),(0,$.jsxs)(X,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:V,onClick:()=>void Le(),children:[V?(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-4`}),c(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(Qr,{open:N!==null,project:Be,onClose:()=>P(null)})]})}function eu(e){let t=(0,za.c)(10),{children:n,content:r,className:i,contentClassName:a,showHeader:o}=e,s=o===void 0||o,{t:c}=de(),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=Y(`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)(oa,{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 tu(e){let t=(0,za.c)(10),{className:n,contentClassName:r,instancesPage:i}=e,{t:a}=de(),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=[...fa],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(ua,{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)(oa,{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 nu(e){let t=(0,za.c)(112),{onAddProject:n,onScanQr:r,onSwitchInstance:i,onRemoteDesktop:a,instanceOptions:o,onEnableAssistants:s,instancesPage:c,instancesSecondaryPage:l,parentSessionTarget:u,registerSecondaryBackHandler:d,scheduledContent:f,renderChat:p,className:m}=e,h=u===void 0?null:u,{t:g}=de(),_=k(xu),v=bt(),y=bt(bu),b=bt(yu),x=bt(vu),S=bt(_u),C=bt(gu),w=bt(hu),T=bt(mu),E=bt(pu),D=bt(fu),O=bt(du),A=bt(uu),j=bt(lu),M;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(M=[],t[0]=M):M=t[0],Q.useEffect(cu,M);let N=v.secondary?.kind===`chat`?v.secondary.btw??null:null,P=Q.useRef(null),F,I;t[1]===N?(F=t[2],I=t[3]):(F=()=>{let e=P.current;P.current=N,e&&e!==N&&Xt.getState().clear({sessionId:e.sessionId,directory:e.directory}),N?Wt(un):nn(un)},I=[N],t[1]=N,t[2]=F,t[3]=I),Q.useEffect(F,I);let L;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(L=[],t[4]=L):L=t[4],Q.useEffect(ou,L);let R;t[5]===y?R=t[6]:(R=e=>{e===`settings`&&k.getState().setSettingsPage(`home`),y(e)},t[5]=y,t[6]=R);let z=J(R),B;t[7]===b?B=t[8]:(B=e=>{b(e)},t[7]=b,t[8]=B);let ee=J(B),V;t[9]===T?V=t[10]:(V=()=>{T()},t[9]=T,t[10]=V);let te=J(V),ne;t[11]===x?ne=t[12]:(ne=()=>{x()},t[11]=x,t[12]=ne);let H=J(ne),U;t[13]===S?U=t[14]:(U=e=>{S(e)},t[13]=S,t[14]=U);let W=J(U),ie=Q.useRef(null),[ae,oe]=Q.useState(!1),G;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{ie.current=e},t[15]=G):G=t[15];let se=J(G),ce;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>{oe(e)},t[16]=ce):ce=t[16];let le=J(ce),K;t[17]!==te||t[18]!==w||t[19]!==j||t[20]!==E?(K=()=>{if(ie.current?.())return!0;let e=bt.getState().secondary;return e?.kind===`chat`&&e.btw?(j(),!0):e?.kind===`assistant`&&e.settingsAssistantID?(w(),!0):e?.kind===`chat`&&e.routes.length>1?(E(),!0):e?(te(),!0):!1},t[17]=te,t[18]=w,t[19]=j,t[20]=E,t[21]=K):K=t[21];let q=J(K),ue=v.secondary!==null,fe;t[22]!==q||t[23]!==d?(fe=()=>{if(d)return d(()=>q()),()=>d(null)},t[22]=q,t[23]=d,t[24]=fe):fe=t[24];let Y;t[25]!==q||t[26]!==d||t[27]!==ue?(Y=[d,ue,q],t[25]=q,t[26]=d,t[27]=ue,t[28]=Y):Y=t[28],Q.useEffect(fe,Y);let X=ct(au),pe;t[29]===X?pe=t[30]:(pe=e=>X?e.getDirectoryForSession(X):null,t[29]=X,t[30]=pe);let me=ct(pe),he,ge;t[31]!==me||t[32]!==X||t[33]!==O||t[34]!==A?(he=()=>{let e=bt.getState().secondary;if(e?.kind===`draft`&&X){O({sessionId:X,directory:me});return}if(e?.kind!==`chat`||!X||wt({sessionId:X,directory:me})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==X||re(t.directory)!==re(me))&&A({sessionId:X,directory:me})},ge=[me,X,O,A],t[31]=me,t[32]=X,t[33]=O,t[34]=A,t[35]=he,t[36]=ge):(he=t[35],ge=t[36]),Q.useEffect(he,ge);let _e,ve;t[37]!==X||t[38]!==h||t[39]!==D?(_e=()=>{let e=bt.getState().secondary;if(e?.kind!==`chat`||!h)return;let t=e.routes.at(-1);!t||t.sessionId!==X||D({sessionId:h.id,directory:h.directory})},ve=[X,h,D],t[37]=X,t[38]=h,t[39]=D,t[40]=_e,t[41]=ve):(_e=t[40],ve=t[41]),Q.useEffect(_e,ve);let ye;t[42]!==le||t[43]!==se||t[44]!==f?(ye=typeof f==`function`?f(se,le):f,t[42]=le,t[43]=se,t[44]=f,t[45]=ye):ye=t[45];let be=ye,xe;t[46]!==H||t[47]!==o||t[48]!==n||t[49]!==a||t[50]!==r||t[51]!==i||t[52]!==ee?(xe=(0,$.jsx)($l,{onOpenChat:ee,onAddProject:n,onNewSession:H,onScanQr:r,onSwitchInstance:i,onRemoteDesktop:a,instanceOptions:o}),t[46]=H,t[47]=o,t[48]=n,t[49]=a,t[50]=r,t[51]=i,t[52]=ee,t[53]=xe):xe=t[53];let Se;t[54]!==s||t[55]!==W?(Se=(0,$.jsx)(Nc,{onEnable:s,onOpenAssistant:W}),t[54]=s,t[55]=W,t[56]=Se):Se=t[56];let Ce;t[57]===be?Ce=t[58]:(Ce=(0,$.jsx)(eu,{showHeader:!1,children:be}),t[57]=be,t[58]=Ce);let we;t[59]===c?we=t[60]:(we=(0,$.jsx)(tu,{instancesPage:c}),t[59]=c,t[60]=we);let Te;t[61]!==xe||t[62]!==Se||t[63]!==Ce||t[64]!==we?(Te={projects:xe,assistant:Se,scheduled:Ce,settings:we},t[61]=xe,t[62]=Se,t[63]=Ce,t[64]=we,t[65]=Te):Te=t[65];let Ee=Te,De=v.secondary?.kind??null,Oe;bb0:{if(!De){Oe=null;break bb0}let e;t[66]!==q||t[67]!==C||t[68]!==g?(e=e=>({key:`assistant-secondary`,depth:1,ariaLabel:g(`assistants.title`),onBack:q,content:(0,$.jsx)(Ta,{activeOverride:e,onMobileBack:iu,onMobileOpenSettings:C})}),t[66]=q,t[67]=C,t[68]=g,t[69]=e):e=t[69];let n=e;if(De===`assistant`){let e=v.secondary?.kind===`assistant`?v.secondary.settingsAssistantID:void 0,r=!e,i;t[70]!==n||t[71]!==r?(i=n(r),t[70]=n,t[71]=r,t[72]=i):i=t[72];let a;t[73]!==q||t[74]!==e||t[75]!==g?(a=e?[{key:`assistant-settings:${e}`,depth:2,ariaLabel:g(`assistants.conversation.openSettings`),onBack:q,content:(0,$.jsx)(Fc,{assistantID:e,onBack:ru})}]:[],t[73]=q,t[74]=e,t[75]=g,t[76]=a):a=t[76];let o;t[77]!==i||t[78]!==a?(o=[i,...a],t[77]=i,t[78]=a,t[79]=o):o=t[79],Oe=o;break bb0}if(De===`instances`){let e;t[80]===g?e=t[81]:(e=g(`mobile.settings.switchInstance`),t[80]=g,t[81]=e);let n;t[82]!==q||t[83]!==l||t[84]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:q,content:l}],t[82]=q,t[83]=l,t[84]=e,t[85]=n):n=t[85],Oe=n;break bb0}if(v.secondary?.kind===`draft`){let e;t[86]===g?e=t[87]:(e=g(`mobile.nav.secondaryPageAria`),t[86]=g,t[87]=e);let n;t[88]===p?n=t[89]:(n=p({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[88]=p,t[89]=n);let r;t[90]!==q||t[91]!==e||t[92]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:q,content:n}],t[90]=q,t[91]=e,t[92]=n,t[93]=r):r=t[93],Oe=r;break bb0}if(v.secondary?.kind!==`chat`){let e;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[94]=e):e=t[94],Oe=e;break bb0}let r=v.secondary.routes,i;if(t[95]!==n||t[96]!==q||t[97]!==v.secondary.btw||t[98]!==v.secondary.returnTo||t[99]!==p||t[100]!==r||t[101]!==g){let e=v.secondary.returnTo?[n(!1)]:[],a=v.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:g(`mobile.nav.secondaryPageAria`),onBack:q,content:p({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:g(`chat.btw.title`),onBack:q,content:(0,$.jsx)(Ic,{route:a})}]:[...e,...c],t[95]=n,t[96]=q,t[97]=v.secondary.btw,t[98]=v.secondary.returnTo,t[99]=p,t[100]=r,t[101]=g,t[102]=i}else i=t[102];Oe=i}let ke=Oe,Ae;t[103]===ke?Ae=t[104]:(Ae=ke??[],t[103]=ke,t[104]=Ae);let je=ae||_,Me;return t[105]!==m||t[106]!==v||t[107]!==z||t[108]!==Ae||t[109]!==je||t[110]!==Ee?(Me=(0,$.jsx)(ol,{className:m,navigation:v,onTabChange:z,tabs:Ee,secondaryPages:Ae,tabBarCovered:je}),t[105]=m,t[106]=v,t[107]=z,t[108]=Ae,t[109]=je,t[110]=Ee,t[111]=Me):Me=t[111],Me}function ru(){ha.requestAnimatedBack(`root`)}function iu(){return ha.requestAnimatedBack(`root`)}function au(e){return e.currentSessionId}function ou(){return su}function su(){return nn(un)}function cu(){return st()}function lu(e){return e.popBtw}function uu(e){return e.replaceChatSession}function du(e){return e.materializeDraftSession}function fu(e){return e.reconcileChatPredecessor}function pu(e){return e.popChatSession}function mu(e){return e.closeSecondary}function hu(e){return e.popAssistantSettings}function gu(e){return e.pushAssistantSettings}function _u(e){return e.openAssistant}function vu(e){return e.openDraft}function yu(e){return e.openSession}function bu(e){return e.setActiveTab}function xu(e){return e.isCommandPaletteOpen}function Su(e){let t=!1,n,i,a=!1,o,s,d=setTimeout(()=>C(`connection_failed`),6e4),p,m=Date.now(),h,g,_=(t,n)=>{(h!==t||g!==n)&&(h=t,g=n,e.onState(t,n))},v=Promise.resolve(),y=0,b=[],x=()=>!t&&e.transport===u()&&e.generation===f(),S=e=>{x()&&n?.readyState===1&&n.send(JSON.stringify(e))},C=r=>{if(t)return;S({type:`release`}),t=!0,w(),clearInterval(s),clearTimeout(d),clearTimeout(p),n?.close(),i?.close();let a=e.video.srcObject;a instanceof MediaStream&&a.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),_(`closed`,r)},w=c(()=>C(`runtime_changed`)),T=()=>{!x()||a||(a=!0,i?.close(),clearTimeout(p),S({type:`fallback`}))},E=async t=>{if(!x())return;if(m=Date.now(),t instanceof ArrayBuffer){if(t.byteLength>524288){C(`connection_failed`);return}o&&URL.revokeObjectURL(o),o=URL.createObjectURL(new Blob([t],{type:`image/jpeg`})),e.image.onload=()=>{x()&&(clearTimeout(d),e.onSize(e.image.naturalWidth,e.image.naturalHeight),_(`tunnel`),S({type:`ack`}))},e.image.onerror=()=>C(`connection_failed`),e.image.src=o;return}let n=JSON.parse(t);if(n.type===`error`){C(typeof n.code==`string`?n.code:`connection_failed`);return}if(n.type===`ready`)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`){T();return}i=new RTCPeerConnection({iceServers:Array.isArray(n.iceServers)?n.iceServers:[]}),i.onicecandidate=e=>{e.candidate&&S({type:`ice`,candidate:e.candidate.toJSON()})},i.onconnectionstatechange=()=>{(i?.connectionState===`failed`||i?.connectionState===`disconnected`)&&T()},i.ontrack=t=>{x()&&(e.video.srcObject=new MediaStream([t.track]),e.video.onloadeddata=()=>{!x()||a||(clearTimeout(d),clearTimeout(p),e.onSize(e.video.videoWidth,e.video.videoHeight),_(`webrtc`))},e.video.play().catch(T))},await i.setRemoteDescription({type:`offer`,sdp:n.sdp});for(let e of b.splice(0))await i.addIceCandidate(e);if(await i.setLocalDescription(await i.createAnswer()),!x()||a)return;S({type:`answer`,sdp:i.localDescription?.sdp}),p=setTimeout(T,7e3)}else n.type===`ice`&&n.candidate&&!a?i?.remoteDescription?await i.addIceCandidate(n.candidate):b.length<128&&b.push(n.candidate):n.type===`rtc-failed`&&T()};return _(`connecting`),(async()=>{try{if(await r(),!x())return;n=O(l().websocket(`/api/remote-desktop/ws`)),n.binaryType=`arraybuffer`,n.onopen=()=>{m=Date.now(),s=setInterval(()=>{if(!x()){C(`runtime_changed`);return}if(Date.now()-m>3e4){C(`connection_failed`);return}S({type:`ping`})},5e3)},n.onmessage=e=>{if(++y>128){C(`connection_failed`);return}v=v.then(()=>E(e.data)).catch(T).finally(()=>{y--})},n.onerror=()=>C(`connection_failed`),n.onclose=()=>C(`connection_failed`)}catch{C(`connection_failed`)}})(),{send:e=>S(e),close:C}}var Cu={scale:1,x:0,y:0};function wu(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 Tu(e,t,n){if(t.width<=0||t.height<=0||t.remoteWidth<=0||t.remoteHeight<=0)return null;let r=wu(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 Eu(e,t){let n=Math.max(1,Math.min(5,e.scale)),r=wu(t),i=(e,t,r,i)=>r*n<=i?(i-r*n)/2-t*n:Math.max(i-(t+r)*n,Math.min(-t*n,e));return{scale:n,x:i(e.x,r.x,r.width,t.width),y:i(e.y,r.y,r.height,t.height)}}function Du(e){let t=new Map,n={...Cu},r=null,i=null,a=!1,o=!1,s=!1,c=!1,l,u=null,d=()=>{a&&e.send({type:`release`}),a=!1},f=()=>{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))}};return{down(a,p){t.size>=2||(t.set(a,p),t.size===1&&(r=i=p,o=!1,s=!1,c=!1,l=setTimeout(()=>{let t=Tu(p,e.viewport(),n);t&&!o&&!s&&(e.send({type:`pointer`,action:`right`,...t}),c=!0)},550)),t.size===2&&(clearTimeout(l),s=!0,d(),u={...f(),transform:{...n}}))},move(d,p){if(t.has(d)){if(t.set(d,p),t.size===2&&u){let{midpoint:t,distance:r}=f(),i=Math.max(1,Math.min(5,u.transform.scale*r/u.distance)),a=i/u.transform.scale;n=Eu({scale:i,x:t.x-(u.midpoint.x-u.transform.x)*a,y:t.y-(u.midpoint.y-u.transform.y)*a},e.viewport()),e.apply(n);return}if(!(s||c||!r||!i)&&(Math.hypot(p.x-r.x,p.y-r.y)>6&&(o=!0,clearTimeout(l)),o)){if(e.scrollMode())e.send({type:`scroll`,dx:i.x-p.x,dy:i.y-p.y});else{let t=Tu(p,e.viewport(),n);if(t){let i=Tu(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}}},up(a,f,p=!1){if(t.has(a)){if(clearTimeout(l),t.delete(a),!p&&!s&&!o&&!c){let t=Tu(f,e.viewport(),n);t&&e.send({type:`pointer`,action:`click`,...t})}d(),t.size||(u=null,r=i=null,s=!1)}},reset(){clearTimeout(l),d(),t.clear(),u=null,r=i=null,s=!1,n={...Cu},e.apply(n)}}}var Ou=(e,t)=>({queryKey:[e,`remote-desktop`,t],queryFn:async({signal:n})=>{let r=()=>{if(e!==u()||t!==f())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 g(`/api/remote-desktop`,{signal:i.signal,headers:{Accept:`application/json`}});if(r(),[404,501].includes(e.status)||!e.headers.get(`content-type`)?.includes(`application/json`))throw Error(`unsupported`);if(!e.ok)throw Error(`connection_failed`);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}),ku=(e,t)=>{let n=(0,za.c)(3),r;return n[0]!==t||n[1]!==e?(r=Ou(e,t),n[0]=t,n[1]=e,n[2]=r):r=n[2],I(r)};function Au({onClose:e,instanceName:t}){let{t:n}=de(),[r]=Q.useState(()=>({transport:u(),generation:f()})),i=ku(r.transport,r.generation),[a,o]=Q.useState(0),[s,c]=Q.useState(`connecting`),[l,d]=Q.useState(),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(``),y=Q.useRef(null),b=Q.useRef(null),x=Q.useRef(null),S=Q.useRef(null),C=Q.useRef({width:1,height:1,remoteWidth:1920,remoteHeight:1080}),w=Q.useRef(null),T=Q.useRef(null),E=Q.useRef(new Map),D=J(e=>{w.current?.send(e)}),O=J(()=>p),[k]=Q.useState(()=>Du({viewport:()=>C.current,send:D,scrollMode:O,apply:e=>{b.current&&(b.current.style.transform=`translate(${e.x}px, ${e.y}px) scale(${e.scale})`)}})),A=J(()=>{T.current!==null&&cancelAnimationFrame(T.current),T.current=null;for(let[e,t]of E.current)k.move(e,t);E.current.clear()}),j=J(()=>{A(),k.reset(),w.current?.close(),w.current=null}),M=J((e,t)=>{c(e),d(t)}),N=J((e,t)=>{e<=0||t<=0||C.current.remoteWidth===e&&C.current.remoteHeight===t||(C.current={...C.current,remoteWidth:e,remoteHeight:t},k.reset())});q(y,([e])=>{e&&(C.current={...C.current,width:e.contentRect.width,height:e.contentRect.height},k.reset())}),le(`visibilitychange`,()=>{document.visibilityState===`hidden`&&j()},()=>document),Q.useEffect(()=>{if(!i.data?.supported||!i.data.enabled||!x.current||!S.current)return;let e=Su({...r,video:x.current,image:S.current,onSize:N,onState:M});return w.current=e,()=>{e.close(),w.current=null}},[i.data?.supported,i.data?.enabled,r,a,N,M]),Q.useEffect(()=>()=>{A(),k.reset()},[A,k]);let P=e=>{let t=y.current.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},F=s===`webrtc`||s===`tunnel`,I=i.data?.supported===!1||i.error?.message===`unsupported`,L=i.data?.supported===!0&&i.data.enabled!==!0,R=I||l===`helper_unavailable`?n(`remoteDesktop.unsupported`):L||l===`disabled`?n(`settings.remoteDesktop.disabled`):l===`permission_required`?n(`remoteDesktop.permissions`):l===`permission_denied`?n(`remoteDesktop.denied`):l===`runtime_changed`||i.error?.message===`runtime_changed`?n(`remoteDesktop.runtimeChanged`):l||i.error||s===`closed`?n(`remoteDesktop.failed`):n(`remoteDesktop.connecting`);return(0,$.jsx)(Fn,{open:!0,title:t?`${n(`remoteDesktop.title`)} · ${t}`:n(`remoteDesktop.title`),onClose:()=>{j(),e()},containedBody:!0,className:`h-[calc(100dvh-0.75rem)] max-w-none`,contentMaxHeightClassName:`max-h-none`,children:(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,$.jsxs)(`div`,{ref:y,className:`absolute inset-0 touch-none overflow-hidden bg-background`,"aria-label":n(`remoteDesktop.screen`),onPointerDown:e=>{F&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),A(),k.down(e.pointerId,P(e)))},onPointerMove:e=>{!F||!e.currentTarget.hasPointerCapture(e.pointerId)||(E.current.set(e.pointerId,P(e)),T.current===null&&(T.current=requestAnimationFrame(A)))},onPointerUp:e=>{A(),k.up(e.pointerId,P(e)),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:e=>{A(),k.up(e.pointerId,P(e),!0)},onLostPointerCapture:e=>k.up(e.pointerId,P(e),!0),onContextMenu:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{ref:b,className:`absolute inset-0 origin-top-left will-change-transform`,children:[(0,$.jsx)(`video`,{ref:x,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:S,alt:n(`remoteDesktop.screen`),draggable:!1,className:`pointer-events-none absolute inset-0 size-full object-contain`,style:{visibility:s===`tunnel`?`visible`:`hidden`}})]}),!F&&(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`&&!l&&!i.error&&!I&&!L&&(0,$.jsx)(Z,{name:`loader-4`,className:`size-5 animate-spin`}),(0,$.jsx)(`p`,{children:R}),(s===`closed`||i.error||L)&&!I&&l!==`runtime_changed`&&i.error?.message!==`runtime_changed`&&(0,$.jsx)(X,{onClick:()=>{j(),d(void 0),c(`connecting`),i.error||L?i.refetch():o(e=>e+1)},children:n(`remoteDesktop.retry`)})]})]}),(0,$.jsx)(`p`,{className:`sr-only`,children:n(`remoteDesktop.hint`)}),(0,$.jsxs)(`div`,{className:`pointer-events-none absolute inset-3 flex flex-col items-end justify-end gap-3`,children:[h&&(0,$.jsxs)(`div`,{className:`pointer-events-auto min-h-0 w-80 max-w-full overflow-y-auto overscroll-contain rounded-2xl border border-border/40 bg-[var(--surface-elevated)]/90 p-3 shadow-lg backdrop-blur-md`,children:[(0,$.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),_&&F&&(D({type:`text`,text:_}),v(``))},children:[(0,$.jsx)(wn,{className:`min-w-0`,value:_,maxLength:1024,onChange:e=>v(e.target.value),placeholder:n(`remoteDesktop.text`),"aria-label":n(`remoteDesktop.text`),disabled:!F,autoComplete:`off`}),(0,$.jsx)(X,{type:`submit`,size:`icon`,disabled:!F||!_,"aria-label":n(`remoteDesktop.send`),children:(0,$.jsx)(Z,{name:`send-plane-2`,className:`size-4`})})]}),(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[`Escape`,`Tab`,`Backspace`,`Enter`,`ArrowLeft`,`ArrowUp`,`ArrowDown`,`ArrowRight`].map(e=>(0,$.jsx)(X,{size:`xs`,variant:`ghost`,disabled:!F,onClick:()=>D({type:`key`,key:e}),"aria-label":n(`remoteDesktop.pressKey`,{key:e}),children:{Escape:`Esc`,Backspace:`⌫`,Enter:`↵`,ArrowLeft:`←`,ArrowUp:`↑`,ArrowDown:`↓`,ArrowRight:`→`}[e]??e},e))})]}),(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)(X,{size:`mobileIcon`,variant:`mobileGlass`,className:`opacity-60 hover:opacity-100 focus-visible:opacity-100 aria-pressed:opacity-100 aria-pressed:ring-2 aria-pressed:ring-foreground/30`,"aria-label":n(`remoteDesktop.scroll`),title:n(`remoteDesktop.scroll`),"aria-pressed":p,disabled:!F,onClick:()=>{k.reset(),m(e=>!e)},children:(0,$.jsx)(Z,{name:`expand-up-down`,className:`size-5`})}),(0,$.jsx)(X,{size:`mobileIcon`,variant:`mobileGlass`,className:`opacity-60 hover:opacity-100 focus-visible:opacity-100`,"aria-label":n(`remoteDesktop.fit`),title:n(`remoteDesktop.fit`),onClick:()=>k.reset(),children:(0,$.jsx)(Z,{name:`fullscreen-exit`,className:`size-5`})})]}),(0,$.jsx)(X,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto opacity-60 hover:opacity-100 focus-visible:opacity-100 aria-pressed:opacity-100 aria-pressed:ring-2 aria-pressed:ring-foreground/30`,disabled:!F,"aria-label":n(`remoteDesktop.text`),title:n(`remoteDesktop.text`),"aria-pressed":h,"aria-expanded":h,onClick:()=>g(e=>!e),children:(0,$.jsx)(Z,{name:`keyboard`,className:`size-5`})})]})]})]})})}var ju=Q.memo(Au);function Mu(e){let t=(0,za.c)(30),{percentage:n,pending:r}=e,i=r!==void 0&&r,{t:a}=de(),o,s,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==n||t[2]!==a){c=i?0:Pn(n)??0;let e=On(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}function Nu(e){let t=(0,za.c)(16),{title:n,subtitle:r,onBack:i,onOpenMenu:a,menuOpen:o,elevated:s,trailing:c}=e,l=o!==void 0&&o,u=s!==void 0&&s,{t:d}=de(),f=J(i),p=J(a),m;t[0]===d?m=t[1]:(m=d(`header.actions.backAria`),t[0]=d,t[1]=m);let h=u||l,g;t[2]===d?g=t[3]:(g=d(`mobile.menu.titleAria`),t[2]=d,t[3]=g);let _;t[4]!==p||t[5]!==l||t[6]!==g?(_=[{icon:`more-2`,ariaLabel:g,onClick:p,pressed:l}],t[4]=p,t[5]=l,t[6]=g,t[7]=_):_=t[7];let v;return t[8]!==f||t[9]!==r||t[10]!==m||t[11]!==h||t[12]!==_||t[13]!==n||t[14]!==c?(v=(0,$.jsx)(ke,{title:n,subtitle:r,backAriaLabel:m,onBack:f,overlay:!0,elevated:h,trailing:c,actions:_}),t[8]=f,t[9]=r,t[10]=m,t[11]=h,t[12]=_,t[13]=n,t[14]=c,t[15]=v):v=t[15],v}var Pu=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},Fu=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),Iu=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,Lu=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:`${Fu(t)}/${Fu(n)}`,colorClass:Iu(i)}},Ru=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},zu=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Bu=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`},Vu=e=>{let t=(0,za.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,$.jsx)(Z,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},Hu=e=>{let t=(0,za.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=de(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(Z,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(Z,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(vn,{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=Gr(e.rows.map(ld),n),o=r===`remaining`?t.window.remainingPercent:t.window.usedPercent,s=Nn(t.window.valueLabel,o),c=En(t.window.resetAt,t.window.resetAfterFormatted??t.window.resetAtFormatted,a);return(0,$.jsxs)(Q.Fragment,{children:[i?(0,$.jsx)(`div`,{className:Y(`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:Y(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,Bu(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},Uu=e=>{let t=(0,za.c)(47),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l}=e,{t:u}=de(),d=Q.useRef(null),[f,p]=Q.useState(n),[m,h]=Q.useState(!1),g,_;t[0]!==n||t[1]!==f?(g=()=>{if(n){p(!0),h(!1);return}if(!f)return;h(!0);let e=window.setTimeout(()=>{p(!1),h(!1)},140);return()=>window.clearTimeout(e)},_=[n,f],t[0]=n,t[1]=f,t[2]=g,t[3]=_):(g=t[2],_=t[3]),Q.useEffect(g,_);let v,y;if(t[4]!==r||t[5]!==n?(v=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},y=[r,n],t[4]=r,t[5]=n,t[6]=v,t[7]=y):(v=t[6],y=t[7]),Q.useEffect(v,y),!f)return null;let b;t[8]===u?b=t[9]:(b=u(`mobile.surface.closeAria`),t[8]=u,t[9]=b);let x;t[10]===r?x=t[11]:(x=e=>{e.preventDefault(),r()},t[10]=r,t[11]=x);let S;t[12]!==b||t[13]!==x?(S=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":b,onPointerDown:x}),t[12]=b,t[13]=x,t[14]=S):S=t[14];let C;t[15]===u?C=t[16]:(C=u(`mobile.header.openMetadataAria`),t[15]=u,t[16]=C);let w=m&&`pointer-events-none`,T;t[17]===w?T=t[18]:(T=Y(`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`,w),t[17]=w,t[18]=T);let E=`${m?`session-metadata-out`:`session-metadata-in`} ${m?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,D;t[19]===E?D=t[20]:(D={animation:E,maxHeight:`min(72dvh, calc(100dvh - var(--yuri-safe-area-top, 0px) - var(--yuri-mobile-detail-navigation-height, 3.5rem) - 1rem))`},t[19]=E,t[20]=D);let O;t[21]===u?O=t[22]:(O=u(`mobile.header.metadata.branch`),t[21]=u,t[22]=O);let k;t[23]!==a||t[24]!==O?(k=(0,$.jsx)(Vu,{iconName:`git-branch`,label:O,children:a}),t[23]=a,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==i||t[27]!==u?(A=i?(0,$.jsx)(Vu,{iconNode:(0,$.jsx)(Mu,{percentage:i.percentage,pending:i.pending}),label:u(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsx)(`span`,{className:Y(`font-semibold`,i.colorClass),children:i.pending?u(`contextUsage.pending`):`${i.percentage.toFixed(1)}%`}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:i.tokens})]})}):null,t[26]=i,t[27]=u,t[28]=A):A=t[28];let j;t[29]!==c||t[30]!==l||t[31]!==s||t[32]!==o?(j=(0,$.jsx)(Hu,{groups:o,displayMode:s,isLoading:c,timeFormatPreference:l}),t[29]=c,t[30]=l,t[31]=s,t[32]=o,t[33]=j):j=t[33];let M;t[34]!==k||t[35]!==A||t[36]!==j?(M=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[k,A,j]}),t[34]=k,t[35]=A,t[36]=j,t[37]=M):M=t[37];let N;t[38]!==T||t[39]!==D||t[40]!==M||t[41]!==C?(N=(0,$.jsx)(`div`,{ref:d,role:`dialog`,"aria-label":C,className:T,style:D,onPointerDown:ud,children:M}),t[38]=T,t[39]=D,t[40]=M,t[41]=C,t[42]=N):N=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(`style`,{children:`
6
+ @keyframes session-metadata-in {
7
+ from { opacity: 0; transform: translateY(-8px) scale(0.985); }
8
+ to { opacity: 1; transform: translateY(0) scale(1); }
9
+ }
10
+ @keyframes session-metadata-out {
11
+ from { opacity: 1; transform: translateY(0) scale(1); }
12
+ to { opacity: 0; transform: translateY(-6px) scale(0.985); }
13
+ }
14
+ `}),t[43]=P):P=t[43];let F;return t[44]!==N||t[45]!==S?(F=(0,$.jsxs)(`div`,{className:`fixed inset-0 z-40 pointer-events-none`,children:[S,N,P]}),t[44]=N,t[45]=S,t[46]=F):F=t[46],F};function Wu(e){let t=(0,za.c)(97),{sessionId:n,open:r,onOpenChange:i}=e,{t:a}=de(),{git:o}=ee(),[s,c]=Q.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=J(f),m=D(cd),h;t[4]===n?h=t[5]:(h=e=>n?e.getDirectoryForSession(n):null,t[4]=n,t[5]=h);let g=ct(h)||m,_;t[6]===g?_=t[7]:(_=zu(g)||null,t[6]=g,t[7]=_);let v=_,y=lt(n,g||void 0),b=or(v),x=lr(v),S=ur(sd),C=ur(od),w=Pe(ad),T=Pe(id),E=Pe(rd),O=Pe(nd),A;t[8]===n?A=t[9]:(A=e=>n?e.sessionModelSelections.get(n)??null:null,t[8]=n,t[9]=A);let j=Ge(A),M=Fr(td),N=Fr(ed),P=Fr($u),F=Fr(Qu),I=Fr(Zu),L=Fr(Xu),R=Fr(Yu),z=k(Ju);Pr();let B;t[10]===p?B=t[11]:(B=()=>{p(!1)},t[10]=p,t[11]=B);let V;t[12]!==g||t[13]!==n?(V=[n,g],t[12]=g,t[13]=n,t[14]=V):V=t[14],Q.useEffect(B,V);let te,ne;t[15]!==S||t[16]!==o||t[17]!==v?(te=()=>{v&&S(v,o)},ne=[S,o,v],t[15]=S,t[16]=o,t[17]=v,t[18]=te,t[19]=ne):(te=t[18],ne=t[19]),Q.useEffect(te,ne);let H,U;t[20]!==C||t[21]!==o||t[22]!==v?(U=()=>{if(v)return Ne.onGitRefreshHint(e=>{zu(e.directory)===v&&C(v,o)})},H=[C,o,v],t[20]=C,t[21]=o,t[22]=v,t[23]=H,t[24]=U):(H=t[23],U=t[24]),Q.useEffect(U,H);let W,re;t[25]===N?(W=t[26],re=t[27]):(W=()=>{N()},re=[N],t[25]=N,t[26]=W,t[27]=re),Q.useEffect(W,re);let ie,ae;t[28]===L?(ie=t[29],ae=t[30]):(ie=()=>{_n(L)},ae=[L],t[28]=L,t[29]=ie,t[30]=ae),Q.useEffect(ie,ae);let oe,G;t[31]!==L||t[32]!==P||t[33]!==F||t[34]!==u||t[35]!==M?(oe=()=>{!u||F||L.some(e=>!M.some(t=>t?.providerId===e))&&P()},G=[L,P,F,u,M],t[31]=L,t[32]=P,t[33]=F,t[34]=u,t[35]=M,t[36]=oe,t[37]=G):(oe=t[36],G=t[37]),Q.useEffect(oe,G);let se;t[38]===y?se=t[39]:(se=Ru(y),t[38]=y,t[39]=se);let ce=se,le;t[40]!==E||t[41]!==T||t[42]!==ce||t[43]!==j?(le=ce??(j?{providerID:j.providerId,modelID:j.modelId}:null)??(T&&E?{providerID:T,modelID:E}:null),t[40]=E,t[41]=T,t[42]=ce,t[43]=j,t[44]=le):le=t[44];let K=le,q;if(t[45]!==O||t[46]!==K||t[47]!==w){let e=(K?w.find(e=>e.id===K.providerID):void 0)?.models.find(e=>e.id===K?.modelID),n;t[49]!==O||t[50]!==K?(n=K?O(K.providerID,K.modelID):void 0,t[49]=O,t[50]=K,t[51]=n):n=t[51];let r=n;q=Pu(e?.limit,`context`)??r?.limit?.context??0,t[45]=O,t[46]=K,t[47]=w,t[48]=q}else q=t[48];let ue=q,fe=St(n,ue,0,g||void 0),Y=fe?.pending?null:fe?.totalTokens??0,pe;t[52]!==ue||t[53]!==d||t[54]!==Y?(pe=Lu({totalTokens:Y,contextLimit:ue,isDraft:d}),t[52]=ue,t[53]=d,t[54]=Y,t[55]=pe):pe=t[55];let me=pe,he;t[56]!==x?.current||t[57]!==b||t[58]!==a?(he=b===!0?x?.current?.trim()||a(`gitView.branch.detachedHead`):a(`common.unavailable`),t[56]=x?.current,t[57]=b,t[58]=a,t[59]=he):he=t[59];let ge=he,_e;if(t[60]!==L||t[61]!==M||t[62]!==R||t[63]!==a){let e=new Map(M.map(qu)),n;t[65]===L?n=t[66]:(n=e=>L.includes(e.id),t[65]=L,t[66]=n),_e=Nr(M).filter(n).filter(t=>e.get(t.id)?.configured===!0).map(t=>{let n=e.get(t.id),r=[];for(let[e,t]of Ei(Object.entries(n?.usage?.windows??{}),n?.usage?.accounts))r.push({key:`window-${e}`,label:kn(t.label??e),window:t});let i=Object.entries(n?.usage?.models??{}),o=R[t.id]??[],s=o.length>0?i.filter(e=>{let[t]=e;return o.includes(t)}):i;for(let[e,t]of s){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:kn(a.label??i),subtitle:Lr(e),window:a})}let c=!n.ok&&n.error?n.error:r.length===0?a(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:c}}),t[60]=L,t[61]=M,t[62]=R,t[63]=a,t[64]=_e}else _e=t[64];let ve=_e,ye,be;t[67]!==u||t[68]!==ve?(ye=()=>{!u||ve.length===0||_n(ve.map(Ku))},be=[u,ve],t[67]=u,t[68]=ve,t[69]=ye,t[70]=be):(ye=t[69],be=t[70]),Q.useEffect(ye,be);let xe;t[71]===p?xe=t[72]:(xe=()=>{p(Gu)},t[71]=p,t[72]=xe);let Se=J(xe),Ce;t[73]===p?Ce=t[74]:(Ce=()=>{p(!1)},t[73]=p,t[74]=Ce);let we=J(Ce),Te;t[75]===a?Te=t[76]:(Te=a(`mobile.header.openMetadataAria`),t[75]=a,t[76]=Te);let Ee=me?.percentage??0,De=me?.pending,Oe;t[77]!==Ee||t[78]!==De?(Oe=(0,$.jsx)(Mu,{percentage:Ee,pending:De}),t[77]=Ee,t[78]=De,t[79]=Oe):Oe=t[79];let ke;t[80]!==Se||t[81]!==u||t[82]!==Te||t[83]!==Oe?(ke=(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(X,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":Te,"aria-expanded":u,onClick:Se,children:Oe})}),t[80]=Se,t[81]=u,t[82]=Te,t[83]=Oe,t[84]=ke):ke=t[84];let Ae;t[85]!==ge||t[86]!==me||t[87]!==we||t[88]!==F||t[89]!==u||t[90]!==I||t[91]!==z||t[92]!==ve?(Ae=(0,$.jsx)(Uu,{open:u,onClose:we,contextDisplay:me,branchLabel:ge,usageGroups:ve,usageDisplayMode:I,isUsageLoading:F,timeFormatPreference:z}),t[85]=ge,t[86]=me,t[87]=we,t[88]=F,t[89]=u,t[90]=I,t[91]=z,t[92]=ve,t[93]=Ae):Ae=t[93];let je;return t[94]!==ke||t[95]!==Ae?(je=(0,$.jsxs)($.Fragment,{children:[ke,Ae]}),t[94]=ke,t[95]=Ae,t[96]=je):je=t[96],je}function Gu(e){return!e}function Ku(e){return e.providerId}function qu(e){return[e?.providerId,e]}function Ju(e){return e.timeFormatPreference}function Yu(e){return e.selectedModels}function Xu(e){return e.dropdownProviderIds}function Zu(e){return e.displayMode}function Qu(e){return e.isLoading}function $u(e){return e.fetchAllQuotas}function ed(e){return e.loadSettings}function td(e){return e.results}function nd(e){return e.getModelMetadata}function rd(e){return e.currentModelId}function id(e){return e.currentProviderId}function ad(e){return e.providers}function od(e){return e.fetchStatus}function sd(e){return e.ensureStatus}function cd(e){return e.currentDirectory}function ld(e){return e.window}function ud(e){e.stopPropagation()}function dd(e){return e.sessionId?e.userRefreshInFlight||e.backgroundResyncInFlight?`syncing`:e.hasRenderableTranscript?null:!e.isConnected&&e.connectionPhase===`reconnecting`||e.loadStatus!==`error`?`syncing`:null:null}function fd(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 pd(e,t){let n=(0,za.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,Q.useState)(a),c;n[4]===i?c=n[5]:(c=fd(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,Q.useEffect)(u,d),o.scope===i&&o.visible}function md(e,t){let n=(0,za.c)(20),{t:r}=de(),i=gt(e,t),{renderable:a}=Ct(e,t),o=Pe(vd),s=Pe(_d),c;n[0]!==t||n[1]!==e?(c=()=>T(e,t),n[0]=t,n[1]=e,n[2]=c):c=n[2];let l=(0,Q.useSyncExternalStore)(E,c,gd),u;n[3]!==t||n[4]!==e?(u=()=>Ie(e,t),n[3]=t,n[4]=e,n[5]=u):u=n[5];let d=(0,Q.useSyncExternalStore)(He,u,hd),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=dd({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=pd(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 hd(){return!1}function gd(){return!1}function _d(e){return e.connectionPhase}function vd(e){return e.isConnected}function yd(e){let t=(0,za.c)(32),{sessionId:n,directory:r,title:i,onBack:a,onOpenMenu:o,onCloseMenu:s,menuOpen:c,children:l,className:u}=e,d=c!==void 0&&c,{t:f}=de(),p=n.length===0,m=Re(p?null:n),h;t[0]!==p||t[1]!==m?.title||t[2]!==f||t[3]!==i?(h=p?i?.trim()||f(`mobile.menu.newSession`):i?.trim()||m?.title?.trim()||f(`mobile.sessions.untitled`),t[0]=p,t[1]=m?.title,t[2]=f,t[3]=i,t[4]=h):h=t[4];let g=h,_=md(p?``:n,r||void 0),[v,y]=Q.useState(!1),b;t[5]!==d||t[6]!==s?(b=e=>{e&&d&&s?.(),y(e)},t[5]=d,t[6]=s,t[7]=b):b=t[7];let x=J(b),S;t[8]!==v||t[9]!==o?(S=()=>{v&&y(!1),o()},t[8]=v,t[9]=o,t[10]=S):S=t[10];let C=J(S),w=d||v,T;t[11]===u?T=t[12]:(T=Y(`relative isolate flex h-full min-h-0 w-full flex-col overflow-hidden bg-background text-foreground`,u),t[11]=u,t[12]=T);let E;t[13]!==v||t[14]!==x||t[15]!==n?(E=(0,$.jsx)(Wu,{sessionId:n,open:v,onOpenChange:x}),t[13]=v,t[14]=x,t[15]=n,t[16]=E):E=t[16];let D;t[17]!==C||t[18]!==w||t[19]!==d||t[20]!==a||t[21]!==g||t[22]!==_||t[23]!==E?(D=(0,$.jsx)(Nu,{title:g,subtitle:_,onBack:a,onOpenMenu:C,menuOpen:d,elevated:w,trailing:E}),t[17]=C,t[18]=w,t[19]=d,t[20]=a,t[21]=g,t[22]=_,t[23]=E,t[24]=D):D=t[24];let O;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(O=Y(`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[25]=O):O=t[25];let k;t[26]===l?k=t[27]:(k=(0,$.jsx)(`div`,{className:O,children:l}),t[26]=l,t[27]=k);let A;return t[28]!==T||t[29]!==D||t[30]!==k?(A=(0,$.jsxs)(`main`,{className:T,children:[D,k]}),t[28]=T,t[29]=D,t[30]=k,t[31]=A):A=t[31],A}function bd(e){let t=(0,za.c)(4),n=e===void 0?2500:e,{uiFont:r}=Ur(),[i,a]=Q.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([dn(r).catch(Td),document.fonts?.ready?.then(wd).catch(Cd)??Promise.resolve(),ka.catch(Sd)]).then(xd),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]),Q.useEffect(o,s),i}function xd(){}function Sd(){}function Cd(){}function wd(){}function Td(){}var Ed=e=>e.replace(/^\/+|\/+$/g,``),Dd=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},Od=e=>{let t=Ed(e.pathname).split(`/`).filter(Boolean);return e.host?[e.host,...t]:t};function kd(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=Od(t),r=(n[0]??``).toLowerCase(),i=n.slice(1),a=t.searchParams;switch(r){case`connect`:{let t=sa(e);return t?{type:`connect`,pairing:t}:null}case`session`:{let e=i[0]||a.get(`id`)||``;return e?{type:`session`,sessionId:e,directory:Dd(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:Dd(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=Dd(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 Ad={},jd=null,Md=!1,Nd=null,Pd=e=>{switch(e.type){case`connect`:return jd?(jd(e.pairing),!0):!1;case`session`:return ae()?(ct.getState().setCurrentSession(e.sessionId,e.directory??null),!0):(bt.getState().openSession({sessionId:e.sessionId,directory:e.directory??null}),!0);case`assistant`:if(!ae()){let t=bt.getState();return t.setActiveTab(`assistant`),t.openAssistant(e.assistantId),!0}return kt(e.assistantId),!0;case`new-session`:return ae()?(ct.getState().openNewSessionDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0):(bt.getState().openDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0);case`open-project`:return ae()?(ct.getState().openNewSessionDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0):(bt.getState().openDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0);case`sessions`:return Ad.openSessions?(Ad.openSessions(e.filter),!0):!1;case`status`:return Ad.openSessions?(Ad.openSessions(),!0):(k.getState().setMobileSessionPanelOpen(!0),!0);case`view`:return Ad.openView?(Ad.openView(e.target),!0):!1;case`changes`:return Ad.openChanges?(Ad.openChanges({path:e.path,staged:e.staged}),!0):!1;case`settings`:return Ad.openSettings?(Ad.openSettings(e.section),!0):!1}return!1},Fd=()=>{if(!Nd||!Md&&Nd.type!==`connect`)return;let e=Nd;Nd=null,Pd(e)||(Nd=e)},Id=e=>{Nd=e,Fd()},Ld=e=>{let t=kd(e);t&&Id(t)},Rd=e=>{Md=e,Fd()},zd=e=>{let t=(0,za.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(Ad=e,Fd(),()=>{Ad===e&&(Ad={})}),r=[e],t[0]=e,t[1]=n,t[2]=r),Q.useEffect(n,r)},Bd=e=>{let t=(0,za.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(jd=e,Fd(),()=>{jd===e&&(jd=null)}),r=[e],t[0]=e,t[1]=n,t[2]=r),Q.useEffect(n,r)},Vd=e=>{let{ready:t}=e,[n,r]=Q.useState(()=>ie()?`pending`:`none`);return Q.useEffect(()=>{Rd(t)},[t]),Q.useEffect(()=>{if(!ie())return;let e=!1,t=[];return W(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=>{Ld(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=kd(a?.url);r(o?.type===`connect`?`connect`:o?`other`:`none`),o&&Id(o)}).catch(()=>{e||r(`none`)}),W(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-D5cqJIPw.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([75,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){Ld(n);return}let r=typeof t?.assistantID==`string`?t.assistantID.trim():``;if(r){Id({type:`assistant`,assistantId:r});return}let i=typeof t?.sessionId==`string`?t.sessionId:void 0;i&&Id({type:`session`,sessionId:i})});if(e){r.remove();return}t.push(()=>void r.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e())}},[]),n},Hd=.85,Ud=8,Wd=.35,Gd=.22,Kd=e=>({segmentStart:e,lastTouch:e,open:!1}),qd=e=>e*Wd,Jd=e=>e*Gd,Yd=(e,t)=>Math.max(0,e-t),Xd=(e,t)=>Math.max(0,t-e),Zd=(e,t)=>{let n=Math.abs(e);return n<Ud||Math.abs(t)<=n*Hd},Qd=(e,t,n)=>{let r=t.clientX-e.segmentStart.clientX,i=t.clientY-e.segmentStart.clientY,a=Yd(e.segmentStart.clientX,t.clientX),o=qd(n),s=Jd(n),c=e.open;return c=a<=0?!1:e.open?a>=s:a>=o&&Zd(r,i),{segmentStart:e.segmentStart,lastTouch:t,open:c}},$d=e=>{if(e.disabled||e.startedOnExcludedTarget)return{open:!1,back:!1};let t=e.endX-e.startX,n=e.endY-e.startY,r=Yd(e.startX,e.endX),i=Xd(e.startX,e.endX),a=qd(e.viewportWidth),o=Zd(t,n);return{open:r>=a&&o,back:i>=a&&o}},ef=(e,t,n)=>Math.min(Yd(e,t)/Math.max(1,qd(n)),1),tf=(e,t,n)=>Math.min(Xd(e,t)/Math.max(1,qd(n)),1),nf=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},rf=e=>{let t=document.elementFromPoint(e.clientX,e.clientY);return!!t?.closest(`.yuri-mobile-composer`)||nf(t)},af=1,of=(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===af?n:n.parentElement;return!!(r&&t.contains(r))},sf=e=>of(window.getSelection(),e),cf=(e,t,n)=>{let r=Q.useRef(t.onOpen);r.current=t.onOpen;let i=Q.useRef(t.onPreviewStart);i.current=t.onPreviewStart;let a=Q.useRef(t.onPreviewCancel);a.current=t.onPreviewCancel;let o=Q.useRef(t.onProgress);o.current=t.onProgress;let s=Q.useRef(t.onBack);s.current=t.onBack;let c=Q.useRef(t.onBackProgress);c.current=t.onBackProgress;let l=Q.useRef(t.disabled);l.current=t.disabled,Q.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=qd(g),n=ze({thresholdReached:p,distance:e,enterDistance:t,cancelDistance:Jd(g),available:!0});p=n.thresholdReached,n.event===`enter`&&(m=Qe(`medium`,{bypassCadence:!0})),n.event===`cancel`&&(Qe(`light`,{bypassCadence:!0}),m=!1)},y=e=>{o.current?.(null),p&&!e&&Qe(`light`,{bypassCadence:!0}),p=!1,m=!1,e?r.current():f&&a.current?.(),f=!1},b=e=>{c.current?.(null),p&&!e&&Qe(`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=rf(r)||sf(t),d=null,f=!1,p=!1,m=!1,h=0,_=Kd(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];_=Qd(_,r,g);let a=r.clientX-_.segmentStart.clientX,l=r.clientY-_.segmentStart.clientY;if(d===null){if(sf(t))return;let e=Math.abs(a);if(e<Ud||Math.abs(l)>e*Hd)return;if(a<0)d=`sessions`,f=!0,i.current?.();else if(s.current)d=`back`;else return}e.preventDefault(),h=d===`sessions`?Yd(_.segmentStart.clientX,r.clientX):Xd(_.segmentStart.clientX,r.clientX),v(h),d===`sessions`?o.current?.(ef(_.segmentStart.clientX,r.clientX,g)):c.current?.(tf(_.segmentStart.clientX,r.clientX,g))},C=e=>{if(!n||!_)return;if(n=!1,!d){_=null;return}let t=e.changedTouches[0];t&&(_=Qd(_,t,g),h=d===`sessions`?Yd(_.segmentStart.clientX,t.clientX):Xd(_.segmentStart.clientX,t.clientX),v(h));let r=d===`sessions`?_.open:$d({startX:_.segmentStart.clientX,startY:_.segmentStart.clientY,endX:_.lastTouch.clientX,endY:_.lastTouch.clientY,viewportWidth:g,disabled:!1,startedOnExcludedTarget:!1}).back;_=null,e.preventDefault(),r&&!m&&Qe(`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])},lf=H(`YuriNotifications`),uf=()=>U.getPlatform()===`android`&&U.isPluginAvailable(`YuriNotifications`);async function df(e,n){let r=p(),a=t(),o=a?``:h();if(!a&&!/^https?:\/\//.test(o))return null;let s=await i();s.set(`Accept-Language`,n);let c=(await Te()).find(e=>_e(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 ff(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 pf=()=>{if(uf()||typeof window>`u`)return!1;let e=window.Capacitor?.getPlatform?.();return e===`ios`||e===`android`},mf=(e,t)=>{v()?.push?.registerApnsToken?.({token:e,platform:oe(),locale:t})},hf=e=>{let{enabled:t}=e,n=k(e=>e.nativeNotificationsEnabled),r=pe(e=>e.locale),i=Q.useRef(null),a=Q.useRef(r);a.current=r,Q.useEffect(()=>{if(!t||!n||!pf())return;let e=!1,r=[];return W(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-D5cqJIPw.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([75,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,mf(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]),Q.useEffect(()=>{if(!t||!n||!pf())return;let e=i.current;e&&mf(e,r)},[t,n,r]),Q.useEffect(()=>{if(n)return;let e=i.current;e&&(i.current=null,v()?.push?.unregisterApnsToken?.({token:e}))},[n])},gf=`YuriLiveActivity`,_f=5e3,vf=3600,yf=`live`,bf=H(gf),xf=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable;function Sf(){return typeof window>`u`?!1:xf({isCapacitor:ie(),platform:oe(),pluginAvailable:U.isPluginAvailable(gf)})}var Cf=()=>bf,wf=new Set([`permission`,`input`,`retry`]),Tf=()=>({trackedSessionId:null,started:!1,startedAt:null,busySince:null,lastStatus:null,eventVersion:0,items:[]}),Ef=(e,t)=>Math.max(Math.floor(e),t+1),Df=e=>e.failedEpoch===e.currentEpoch?e.previous:e.current,Of=e=>e.failedEpoch===e.currentEpoch&&e.retryCount<1,kf=e=>e.hasSessionError?`error`:e.hasPendingPermissions?`permission`:e.hasPendingQuestions?`input`:e.statusType===`retry`?`retry`:e.statusType===`busy`?`working`:e.statusType===`idle`?`complete`:null,Af=e=>{let t=e.trim();return t.length<=80?t:`${t.slice(0,79)}…`},jf=e=>typeof e.parentID==`string`&&e.parentID.length>0?e.parentID:null,Mf=e=>{if(e.runningIds.size===0)return[];let t=[];for(let n of e.sessions)!e.runningIds.has(n.id)||jf(n)||t.push({sessionId:n.id,title:Af(n.title??``),statusType:e.statuses[n.id]?.type??`busy`});return t},Nf=e=>e!==`complete`&&e!==`error`,Pf=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`,Ff=e=>{if(e.length<=4)return e;let t=e.filter(e=>Nf(e.status)),n=e.filter(e=>!Nf(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)},If=(e,t,n,r)=>{if(n&&n.length>0)return n;let i=r?.[e];return i&&i.length>0?i:t},Lf=(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=kf({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;o.push({sessionId:t.sessionId,title:If(t.sessionId,t.title,e.title,r),status:i,startedAt:t.startedAt,busySince:i===`working`?t.busySince??n:null})}else if(Nf(t.status))o.push({...t,title:If(t.sessionId,t.title,void 0,r),status:`complete`,endedAt:n,busySince:null});else{let e=If(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=kf({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 Ff(o)},Rf=e=>e.map(e=>`${e.sessionId}\0${e.title}\0${e.status}\0${e.endedAt??``}`).join(`
15
+ `),zf=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}),Bf=(e,t,n,r,i)=>{let a=e.filter(e=>Nf(e.status)),o=a[0]??e[0],s={sessionId:yf,startedAt:o?.startedAt??r,status:t,eventVersion:n,updatedAt:r,title:o?.title,workingCount:a.length,items:zf(e)};return i?.endedAt!==void 0&&(s.endedAt=i.endedAt),i?.dismissalSeconds!==void 0&&(s.dismissalSeconds=i.dismissalSeconds),s},Vf=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},Hf=(e,t,n,r)=>{let i=e.trackedSessionId;if(!i||!e.started)return{state:Tf(),commands:[]};let a=Ef(t,e.eventVersion);return{state:Tf(),commands:[{type:`end`,payload:Vf({sessionId:i,startedAt:e.startedAt??t,status:n,eventVersion:a,updatedAt:t,endedAt:t,dismissalSeconds:r})}]}},Uf=(e,t,n,r,i)=>{let a=Ef(r,i);return{state:{trackedSessionId:e,started:!0,startedAt:n,busySince:null,lastStatus:t,eventVersion:a,items:[]},commands:[{type:`start`,payload:Vf({sessionId:e,startedAt:n,status:t,eventVersion:a,updatedAt:r})}]}},Wf=(e,t,n)=>{let r=kf(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||!wf.has(r))return{state:{...Tf(),trackedSessionId:n},commands:[]};return Uf(n,r,i??t.now,t.now,e.eventVersion)}if(r===`complete`)return Hf({...e,busySince:i},t.now,`complete`,900);if(r===`error`)return Hf({...e,busySince:i},t.now,`error`,vf);if(!r||r===e.lastStatus)return{state:{...e,trackedSessionId:n,busySince:i},commands:[]};let a=Ef(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:Vf({sessionId:n,startedAt:e.startedAt??t.now,status:r,eventVersion:a,updatedAt:t.now})}]}},Gf=(e,t,n)=>{let r=e.trackedSessionId;if(!r||!e.started)return{state:e,commands:[]};let i=Ef(n,e.eventVersion);return{state:{...e,busySince:null,lastStatus:t,eventVersion:i},commands:[{type:`update`,payload:Vf({sessionId:r,startedAt:e.startedAt??n,status:t,eventVersion:i,updatedAt:n})}]}},Kf=(e,t,n)=>{let r=Lf(e.items,n,t.now,t.sessionTitles,t.rootSessionIds),i=r.filter(e=>Nf(e.status)),a=Pf(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=Ef(t.now,n.eventVersion),a=r.map(e=>Nf(e.status)?{...e,status:`stale`}:e);return{state:{...n,items:a,lastStatus:`stale`,eventVersion:i,busySince:null},commands:[{type:`update`,payload:Vf(Bf(a,`stale`,i,t.now))}]}}if(!e.started){if(i.length===0)return{state:Tf(),commands:[]};if(!i.some(e=>wf.has(e.status))){let n=_f-(t.now-(o??t.now));if(n>0)return{state:{...e,trackedSessionId:yf,items:r,busySince:o},commands:[{type:`wait`,delayMs:n}]}}let n=o??t.now,s=r.map(e=>Nf(e.status)?{...e,startedAt:e.busySince??n}:e),c=Ef(t.now,e.eventVersion);return{state:{trackedSessionId:yf,started:!0,startedAt:n,busySince:null,lastStatus:a,eventVersion:c,items:s},commands:[{type:`start`,payload:Vf(Bf(s,a,c,t.now))}]}}if(i.length===0){let n=r.some(e=>e.status===`error`)?`error`:`complete`,i=Ef(t.now,e.eventVersion);return{state:Tf(),commands:[{type:`end`,payload:Vf(Bf(r,n,i,t.now,{endedAt:t.now,dismissalSeconds:n===`error`?vf:900}))}]}}if(Rf(e.items)===Rf(r)&&e.lastStatus===a)return{state:{...e,trackedSessionId:yf,items:r,busySince:null},commands:[]};let s=Ef(t.now,e.eventVersion);return{state:{trackedSessionId:yf,started:!0,startedAt:e.startedAt??o??t.now,busySince:null,lastStatus:a,eventVersion:s,items:r},commands:[{type:`update`,payload:Vf(Bf(r,a,s,t.now))}]}},qf=(e,t)=>{if(t.catalog)return Kf(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:[]}:Gf(n,`stale`,t.now)}let n=[],r=e;if(r.trackedSessionId&&r.trackedSessionId!==t.sessionId)if(r.started){let e=Hf(r,t.now,r.lastStatus??`complete`,0);n.push(...e.commands),r=e.state}else r=Tf();if(!t.sessionId){if(r.started){let e=Hf(r,t.now,`complete`,900);return{state:e.state,commands:[...n,...e.commands]}}return{state:Tf(),commands:n}}let i=Wf(r,t,t.sessionId);return{state:i.state,commands:[...n,...i.commands]}},Jf=e=>e/1e3,Yf=e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Jf(e.startedAt)};return e.endedAt!==void 0&&(t.endedAt=Jf(e.endedAt)),t},Xf=e=>{let t={sessionId:e.sessionId,startedAt:Jf(e.startedAt),status:e.status,eventVersion:e.eventVersion,updatedAt:Jf(e.updatedAt)};return e.endedAt!==void 0&&(t.endedAt=Jf(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(Yf)),t},Zf=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},Qf=(e,t,n)=>{if(!e||n.type===`wait`)return Promise.resolve();let r=Xf(n.payload),i=Zf(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})},$f=e=>e.getCurrentEpoch()===e.epoch?!e.getCurrentSessionId||e.getCurrentSessionId()===e.observation.sessionId:!1,ep=async e=>{let t=e.state;if(!$f(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let n=qf(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 $f(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(!$f(e)||(await Qf(e.available,e.plugin,i),!$f(e)))return{state:t,delayMs:null,retry:!1,superseded:!0};let s=r===a.length-1;o=i.type===`end`&&!s?Tf():n.state}return{state:n.state,delayMs:i,retry:!1,superseded:!1}}catch{if(!$f(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let r=Df({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),previous:o,current:n.state}),i=Of({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),retryCount:e.retryCount});return{state:r,delayMs:i?250:null,retry:i,superseded:!1}}},tp=()=>({desired:null,registered:null}),np=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null},rp=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=np(t.activityId),r=np(t.sessionId),i=np(t.token);return!n||!r||!i?null:{activityId:n,sessionId:r,token:i}},ip=(e,t)=>e.activityId===t.activityId&&e.token===t.token,ap=(e,t)=>{let n=e.registered?.runtimeIdentity===t?e.registered:null;return e.desired===null&&n===e.registered?e:{desired:null,registered:n}},op=(e,t)=>{if(!t.connected)return[];if(e.desired&&t.enabled&&t.selectedSessionId&&e.desired.sessionId===t.selectedSessionId){let n=e.registered;return n&&ip(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}]:[]},sp=(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=ap(e,t.runtimeIdentity):e.registered&&e.registered.runtimeIdentity!==t.runtimeIdentity&&!e.desired&&(r={...e,registered:null});return{state:r,commands:op(r,t)}},cp=async e=>{try{return await e}catch{return null}},lp=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 cp(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 cp(e.unregister({token:r.token}))}continue}if(n.runtimeIdentity!==e.getRuntimeIdentity()){t.registered?.runtimeIdentity===n.runtimeIdentity&&(t={...t,registered:null});continue}(await cp(e.unregister(n.payload)))?.ok===!0&&t.registered?.token===n.payload.token&&(t={...t,registered:null})}return t},up=new Map,dp=[];function fp(){let e=Sf(),t=Pe(e=>e.isConnected),n=$e({enabled:e}),r=et(t=>e?t.statusById:up),i=We(t=>e?t.activeSessions:dp),a=(0,Q.useMemo)(()=>e?Ke(n,r):new Set,[e,r,n]),o=(0,Q.useMemo)(()=>e?Mf({runningIds:a,statuses:n,sessions:i}):[],[e,n,a,i]),s=(0,Q.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]),l=(0,Q.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,Q.useMemo)(()=>[o.map(e=>`${e.sessionId}\0${e.title}\0${e.statusType??``}`).join(`
16
+ `),Object.entries(s).map(([e,t])=>`${e}\0${t}`).join(`
17
+ `)].join(`
18
+ ---
19
+ `),[o,s]),f=(0,Q.useRef)(Tf()),p=(0,Q.useRef)(tp()),m=(0,Q.useRef)(null),h=(0,Q.useRef)(0),g=(0,Q.useRef)(Promise.resolve()),_=(0,Q.useRef)(Promise.resolve()),y=(0,Q.useRef)(null),b=J(()=>({sessionId:yf,statusType:void 0,hasPendingPermissions:!1,hasPendingQuestions:!1,hasSessionError:!1,now:Date.now(),connected:t,catalog:o,sessionTitles:s,rootSessionIds:l})),x=J(n=>{_.current=_.current.then(async()=>{let r=sp(p.current,{selectedSessionId:yf,runtimeIdentity:u(),connected:t,enabled:e},n);p.current=r.state,r.commands.length!==0&&(p.current=await lp({state:p.current,commands:r.commands,getRuntimeIdentity:u,register:e=>v()?.push?.registerLiveActivityToken?.({...e,items:f.current.items.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Jf(e.startedAt)};return e.endedAt===void 0?t:{...t,endedAt:Jf(e.endedAt)}})})??Promise.resolve(null),unregister:e=>v()?.push?.unregisterLiveActivityToken?.(e)??Promise.resolve(null)}))}).catch(()=>void 0)}),S=J(e=>{let t=rp(e);t&&x({type:`pushToken`,...t,sessionId:yf})});(0,Q.useEffect)(()=>{x({type:e?`sync`:`dispose`})},[e,t]),(0,Q.useEffect)(()=>c(()=>{x({type:`sync`})}),[]),(0,Q.useEffect)(()=>{if(!e){y.current?.remove(),y.current=null;return}let t=!1,n=null,r=0,i=Cf(),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=b(),s=f.current.started,c=await ep({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)x({type:`localEndSucceeded`});else if(c.state.started){let e=p.current.desired;e&&v()?.push?.registerLiveActivityToken?.({activityId:e.activityId,sessionId:yf,token:e.token,items:c.state.items.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Jf(e.startedAt)};return e.endedAt===void 0?t:{...t,endedAt:Jf(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)&&!y.current)try{let e=await i.addListener(`pushToken`,e=>{S(e)});if(t){await e.remove();return}y.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,Q.useEffect)(()=>()=>{y.current?.remove(),y.current=null,x({type:`dispose`})},[])}function pp(){let e=(0,za.c)(49),t=k(hp),{t:r,locale:i}=de(),a;e[0]===r?a=e[1]:(a=r(`mobile.notifications.service`),e[0]=r,e[1]=a);let o=a,s;e[2]===r?s=e[3]:(s=r(`settings.page.notifications.title`),e[2]=r,e[3]=s);let l=s,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 A=O,j;e[24]===r?j=e[25]:(j=r(`mobile.notifications.server`),e[24]=r,e[25]=j);let M=j,N;e[26]===r?N=e[27]:(N=r(`mobile.notifications.relay`),e[26]=r,e[27]=N);let P=N,F;e[28]===r?F=e[29]:(F=r(`mobile.notifications.identity`),e[28]=r,e[29]=F);let I=F,L,R;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]!==I||e[40]!==i||e[41]!==h||e[42]!==P||e[43]!==A||e[44]!==M||e[45]!==o||e[46]!==_?(L=()=>{if(!uf())return;if(!t){lf.stop().catch(mp);return}let e=!1,r=t=>{e||(e=!0,tt.error(t))},a=ff({plugin:lf,resolveConfig:()=>df({service:o,alerts:l,connecting:d,connected:p,reconnecting:h,unavailable:_,gap:y,error:C,auth:T,endpoint:D,response:A,server:M,relay:P,identity:I},i),onState:e=>{(e===`denied`||e===`unavailable`)&&r(e===`denied`?x:_)},onError:()=>r(_)}),s=c(()=>{a.refresh()}),u=n(e=>{let{reason:t}=e;t===`invalidate`?a.stop():t!==`endpoint-switch`&&a.refresh()});return a.refresh(),()=>{s(),u(),a.dispose()}},R=[t,i,o,l,d,p,h,_,y,x,C,T,D,A,M,P,I],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]=I,e[40]=i,e[41]=h,e[42]=P,e[43]=A,e[44]=M,e[45]=o,e[46]=_,e[47]=L,e[48]=R):(L=e[47],R=e[48]),(0,Q.useEffect)(L,R)}function mp(){console.warn(`[Native notifications] stop failed`)}function hp(e){return e.nativeNotificationsEnabled}var gp=`mobile-direct-diff`,_p=`mobile-turn-diff`,vp=`mobile-direct-file`,yp=`mobile-files`,bp=`mobile-changes`,xp=`mobile-mcp`,Sp=`mobile-settings`,Cp=`mobile-update`,wp=`mobile-overflow-menu`,Tp=320,Ep=380,Dp=280,Op=560,kp=380,Ap=e=>Math.min(Op,Math.max(Dp,Math.round(e))),jp=(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 Mp(e,t,n){let r=(0,za.c)(17),i=Q.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(Op,Math.max(Dp,e)):n},r[0]=n,r[1]=t,r[2]=a):a=r[2];let[o,s]=Q.useState(a),[c,l]=Q.useState(!1),u=Q.useRef(0),d=Q.useRef(o),f=Q.useRef(null),p=Q.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=J(m),g;r[5]===e?g=r[6]:(g=t=>{if(p.current!==t.pointerId)return;let n=t.clientX-u.current,r=Ap(d.current+(e===`left`?n:-n));f.current!==r&&(f.current=r,jp(i,r))},r[5]=e,r[6]=g);let _=J(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=Ap(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=J(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 Np=e=>{let t=(0,za.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=Y(`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=Y(`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},Pp=()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,Fp=()=>{Q.useEffect(()=>{if(!Pp())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 W(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([76,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 W(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})=>{e&&a()});if(e){c.remove();return}t.push(()=>void c.remove())}).catch(()=>void 0),W(async()=>{let{Keyboard:e}=await import(`./vendor-capacitor-keyboard-BRVcFyc9.js`).then(e=>e.t);return{Keyboard:e}},__vite__mapDeps([77,1,2])).then(async({Keyboard:i})=>{if(e)return;let a=window.Capacitor?.getPlatform?.()===`android`;await i.setAccessoryBarVisible({isVisible:!1}).catch(()=>void 0);let o=`cubic-bezier(0.38, 0.7, 0.125, 1)`,s=null,c=null,l=0,u=!1,d=0,f=!1,p=(e,t)=>{n.style.setProperty(e,`${Math.max(0,Math.round(t))}px`)},m=()=>{s!==null&&(window.clearTimeout(s),s=null)},h=(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))},g=e=>e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`,_=e=>{for(let t of document.querySelectorAll(e))if(g(t))return t;return null},v=e=>{let t=[],n=e instanceof Element?e:null;if(n&&!Zo(n))return t;let r=n?.closest(`.yuri-mobile-composer`)??null,i=r&&g(r)?r:_(`.yuri-mobile-composer`);if(i&&t.push({el:i,factor:1}),i){let e=_(`.yuri-draft-center`);e&&t.push({el:e,factor:.5})}return t},y=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.isContentEditable),b=()=>{let e=document.activeElement;return!(y(e)&&!Zo(e))},x=e=>Zo(e),S=()=>{for(let e of document.querySelectorAll(`.yuri-mobile-composer, .yuri-draft-center`))e.style.transition=``,e.style.transform=``},C=()=>{let e=document.querySelector(`.yuri-mobile-app-shell`);d=e&&parseFloat(getComputedStyle(e).paddingBottom)||0};if(a){let i=`yuri.androidImeHeightRatio.v2`,a=`cubic-bezier(0.2, 0, 0, 1)`,o=`cubic-bezier(0.4, 0, 1, 1)`,s=null,c=!1,l=y,u=e=>Number.isFinite(e)?Math.min(.68,Math.max(.28,e)):.39,m=Math.round(window.innerHeight*(()=>{try{return u(Number.parseFloat(localStorage.getItem(i)??``))}catch{return .39}})()),g=0,_=e=>{if(m=Math.max(0,Math.round(e)),!(m<=0||window.innerHeight<=0))try{localStorage.setItem(i,String(u(m/window.innerHeight)))}catch{}},w=()=>{s!==null&&(window.clearTimeout(s),s=null)},T=e=>Math.max(0,Math.round(e-d)),E=(e,t)=>`translate3d(0, ${-e*t}px, 0)`,D=(e,t,r,i)=>{w();let a=T(e),o=v(i);n.classList.add(`yuri-kb-animating`);for(let{el:e,factor:n}of o)e.style.transition=`transform ${t}ms ${r}`,e.style.transform=E(a,n);return s=window.setTimeout(()=>{s=null,n.classList.remove(`yuri-kb-animating`);for(let{el:e}of o)e.style.transition=``},t+20),a},O=e=>{C();let t=Math.max(0,Math.round(e));f=!0,c=!1,g=t,n.classList.remove(`yuri-keyboard-open`,`yuri-kb-animating`),r(t),p(`--yuri-kb-layout`,0),p(`--yuri-kb-scroll-inset`,T(t)),w(),S(),h(`yuri:keyboard-settled`,{open:!0})},k=(e,t=`focus`)=>{if(t===`intent`){if(!b())return}else if(t===`focus`){if(!x(e))return}else if(!f&&!x(document.activeElement))return;if(C(),f){let i=g||m,o=T(i),s=v(t===`focus`?e:void 0);if(s.length===0||(c=!0,n.classList.add(`yuri-keyboard-open`),r(0),p(`--yuri-kb-scroll-inset`,0),s.every(({el:e,factor:t})=>e.style.transform===E(o,t))))return;D(i,60,a,t===`focus`?e:void 0),h(`yuri:keyboard-anim`,{phase:`show`,slide:o,durationMs:60,easing:a}),h(`yuri:keyboard-settled`,{open:!0});return}f=!0,c=!0,n.classList.add(`yuri-keyboard-open`),r(0),p(`--yuri-kb-layout`,0),p(`--yuri-kb-scroll-inset`,0),g=m;let i=D(g,200,a,t===`focus`?e:void 0);h(`yuri:keyboard-anim`,{phase:`show`,slide:i,durationMs:200,easing:a}),h(`yuri:keyboard-settled`,{open:!0})},A=e=>{if(!f){e&&l(document.activeElement)&&Zo(document.activeElement)&&document.activeElement.blur();return}let t=g||m,i=c;f=!1,c=!1,g=0,e&&l(document.activeElement)&&Zo(document.activeElement)&&document.activeElement.blur(),n.classList.remove(`yuri-keyboard-open`),r(0),p(`--yuri-kb-layout`,0),p(`--yuri-kb-scroll-inset`,0),h(`yuri:keyboard-intent`,{open:!1});let a=T(t);if(!i){w(),S(),h(`yuri:keyboard-settled`,{open:!1});return}D(0,100,o),h(`yuri:keyboard-anim`,{phase:`hide`,slide:a,durationMs:100,easing:o}),w(),s=window.setTimeout(()=>{s=null,n.classList.remove(`yuri-kb-animating`),S(),h(`yuri:keyboard-settled`,{open:!1})},120)},j=e=>{if(l(e.target)){if(Zo(e.target)){k(e.target,`focus`);return}O(g||m)}},M=e=>{if(l(e.target)&&!$o(e.relatedTarget)){if(Qo(e.relatedTarget)){h(`yuri:keyboard-intent`,{open:!1}),O(g||m);return}A(!1)}},N=e=>{let t=e,n=t.detail??t;if(n?.open===!0){let e=ns(n.height??0,window.devicePixelRatio||1),t=es(c,document.activeElement);if(e>0&&(t===`open`||t===`cache`)&&_(e),t===`open`&&k(document.activeElement,`ime`),t===`cache`&&ts(g||m,e)){g=e;let t=D(e,60,a,Zo(document.activeElement)?document.activeElement:void 0);h(`yuri:keyboard-anim`,{phase:`show`,slide:t,durationMs:60,easing:a})}t===`field`&&O(e||m)}n?.open===!1&&A(!0)},P=e=>{e.detail?.open===!0&&k(void 0,`intent`)};if(document.addEventListener(`focusin`,j,!0),document.addEventListener(`focusout`,M,!0),window.addEventListener(`yuri:ime-state`,N),window.addEventListener(`yuri:keyboard-intent`,P),e){w(),document.removeEventListener(`focusin`,j,!0),document.removeEventListener(`focusout`,M,!0),window.removeEventListener(`yuri:ime-state`,N),window.removeEventListener(`yuri:keyboard-intent`,P);return}t.push(w,()=>document.removeEventListener(`focusin`,j,!0),()=>document.removeEventListener(`focusout`,M,!0),()=>window.removeEventListener(`yuri:ime-state`,N),()=>window.removeEventListener(`yuri:keyboard-intent`,P));return}let w=`yuri.iosImeHeightRatio.v1`,T=e=>Number.isFinite(e)?Math.min(.68,Math.max(.28,e)):.39,E=()=>{try{let e=T(Number.parseFloat(localStorage.getItem(w)??``));return Math.round(window.innerHeight*e)}catch{return Math.round(window.innerHeight*.39)}},D=e=>{if(!(e<=0||window.innerHeight<=0))try{localStorage.setItem(w,String(T(e/window.innerHeight)))}catch{}},O=e=>{C();let t=Math.max(0,e-d);r(e),p(`--yuri-kb-layout`,e),p(`--yuri-kb-scroll-inset`,0),u=!0,S(),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&&g(n)?n:_(`.yuri-mobile-composer`))?.scrollIntoView({block:`end`,inline:`nearest`}),t},k=e=>{if(Xo(n.classList.contains(`yuri-native-ios-composer`),document.activeElement)||e.detail?.open!==!0||u||y(document.activeElement)&&!Zo(document.activeElement))return;f=!0,n.classList.remove(`yuri-kb-hide`),n.classList.add(`yuri-keyboard-open`);let t=l>0?l:E(),r=O(t);h(`yuri:keyboard-anim`,{phase:`show`,slide:r,durationMs:0,easing:o}),h(`yuri:keyboard-settled`,{open:!0})};window.addEventListener(`yuri:keyboard-intent`,k);let A=await i.addListener(`keyboardWillShow`,e=>{if(Xo(n.classList.contains(`yuri-native-ios-composer`),document.activeElement))return;m(),l=e.keyboardHeight,D(l);let t=Zo(document.activeElement)||n.classList.contains(`yuri-keyboard-open`)&&!y(document.activeElement);if(f=!0,n.classList.remove(`yuri-kb-hide`),c!==null&&(window.clearTimeout(c),c=null),!t){r(l),p(`--yuri-kb-layout`,0),C(),p(`--yuri-kb-scroll-inset`,Math.max(0,l-d)),n.classList.remove(`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-caret-hold`),S(),u=!1,h(`yuri:keyboard-settled`,{open:!0});return}n.classList.add(`yuri-keyboard-open`);let i=O(l);h(`yuri:keyboard-settled`,{open:!0}),h(`yuri:keyboard-anim`,{phase:`show`,slide:i,durationMs:0,easing:o})}),j=()=>{let e=document.activeElement;e instanceof HTMLElement&&Zo(e)&&e.blur()},M=()=>{f||(window.scrollTo(0,0),document.body.scrollTop!==0&&(document.body.scrollTop=0))},N=()=>{f=!1,m(),c!==null&&(window.clearTimeout(c),c=null),n.classList.remove(`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-caret-hold`,`yuri-kb-hide`),r(0),p(`--yuri-kb-scroll-inset`,0),p(`--yuri-kb-layout`,0),u=!1,S(),M(),window.setTimeout(M,350)},P=()=>{if(n.classList.contains(`yuri-native-ios-composer`)){N(),gr().blur(),h(`yuri:keyboard-settled`,{open:!1});return}if(!f)return;f=!1,m(),h(`yuri:keyboard-intent`,{open:!1}),j(),window.setTimeout(()=>{f||Zo(document.activeElement)&&(j(),h(`yuri:keyboard-intent`,{open:!1}))},80),c!==null&&(window.clearTimeout(c),c=null),n.classList.remove(`yuri-kb-caret-hold`,`yuri-kb-animating`);let e=Math.max(0,l-d);n.classList.remove(`yuri-keyboard-open`),r(0),p(`--yuri-kb-scroll-inset`,0),p(`--yuri-kb-layout`,0),u=!1,S(),M(),window.setTimeout(M,350),h(`yuri:keyboard-anim`,{phase:`hide`,slide:e,durationMs:0,easing:o}),n.classList.add(`yuri-kb-animating`,`yuri-kb-hide`),s=window.setTimeout(()=>{s=null,n.classList.remove(`yuri-kb-animating`,`yuri-kb-hide`),h(`yuri:keyboard-settled`,{open:!1})},260)},F=await i.addListener(`keyboardWillHide`,P),I=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.isContentEditable),L=e=>{if(f&&I(e.target)){if($o(e.relatedTarget)){p(`--yuri-kb-scroll-inset`,0);return}window.setTimeout(()=>{if(f&&!Zo(document.activeElement)){if(I(document.activeElement)){m(),n.classList.remove(`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-caret-hold`,`yuri-kb-hide`),r(l),p(`--yuri-kb-layout`,0),C(),p(`--yuri-kb-scroll-inset`,Math.max(0,l-d)),u=!1,S(),h(`yuri:keyboard-intent`,{open:!1}),h(`yuri:keyboard-settled`,{open:!0});return}P()}},0)}};if(document.addEventListener(`focusout`,L,!0),e){m(),document.removeEventListener(`focusout`,L,!0),window.removeEventListener(`yuri:keyboard-intent`,k),A.remove(),F.remove();return}t.push(m,()=>{c!==null&&(window.clearTimeout(c),c=null)},()=>document.removeEventListener(`focusout`,L,!0),()=>window.removeEventListener(`yuri:keyboard-intent`,k),()=>void A.remove(),()=>void F.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`)}},[])},Ip=e=>{let t=Q.useRef(!1);Q.useEffect(()=>{if(!Pp())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)),W(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])},Lp=e=>{Q.useEffect(()=>{if(!Pp())return;let t=!1,n=null;return W(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])},Rp=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),zp={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},Bp=1e3,Vp=e=>{let t=Rp(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},Hp=(e,t)=>Vp(e?e.path:t),Up=({connection:e,onActiveConnectionDeleted:t,onConnect:n})=>{let{t:r}=de(),i=e,{connections:a,isBusy:o,isPasswordBusy:s,error:c,pendingConnection:l,connect:u,submitPassword:d,cancelPassword:f,saveConnection:p,removeConnection:m,subscribeConnected:h,setError:g}=i,[_,v]=Q.useState(null),y=_?a.find(e=>e.id===_)??null:null,b=y?!y.candidates.some(e=>e.kind===`direct`):!1,[x,S]=Q.useState(null),[C,w]=Q.useState(``),[T,E]=Q.useState(``),[D,O]=Q.useState(``),[k,A]=Q.useState(``),[j,M]=Q.useState(!1),N=Q.useMemo(()=>Lo(),[]),[P,F]=Q.useState(!1),[I,L]=Q.useState(null),R=J(n);Q.useEffect(()=>h(R),[R,h]);let z=J(()=>{v(null),w(``),E(``),O(``),g(null),F(!1)}),B=J(e=>{e.preventDefault(),p({id:_??void 0,url:C,label:T,clientToken:D}).then(e=>{e&&z()})}),ee=J(e=>{i.redeemPairingConnection(e)}),V=J(()=>{g(r(`mobile.connect.link.invalid`))}),te=J(async()=>{if(!j){g(null),M(!0);try{let e=await Ro();switch(e.status){case`ok`:w(e.url),e.label&&E(e.label),e.clientToken&&O(e.clientToken),F(!0);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`))}}finally{M(!1)}}}),ne=J(e=>{e.preventDefault(),d(k)}),H=J(()=>{A(``),f()}),U=J(e=>{S(t=>t===e?null:e)}),W=J(e=>{S(null),_===e&&z();let n=a.length===1;m(e).then(e=>{e&&(n||be(e))&&t()})}),re=`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`;return l?(0,$.jsx)(`div`,{className:`yuri-settings-page-content`,children:(0,$.jsx)(Mr,{label:r(`mobile.connect.password.label`),itemId:`instances.manage`,children:(0,$.jsxs)(`form`,{className:`yuri-settings-group-row flex flex-col gap-3`,onSubmit:ne,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)(Z,{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`)?Ce(l):r(`mobile.connect.relay.badge`)})]})]}),(0,$.jsx)(`input`,{...zp,value:k,onChange:e=>A(e.target.value),placeholder:r(`mobile.connect.password.placeholder`),"aria-label":r(`mobile.connect.password.label`),type:`password`,autoFocus:!0,className:re}),c?(0,$.jsx)(`p`,{className:`px-1 typography-small text-[var(--status-error)]`,children:c}):null,(0,$.jsx)(X,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,disabled:s||!k.trim(),children:r(s?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full`,onClick:H,children:r(`mobile.connect.cancelPassword`)})]})})}):(0,$.jsxs)(`div`,{className:`yuri-settings-page-content`,children:[(0,$.jsx)(Mr,{label:r(`mobile.connect.saved.title`),itemId:`instances.manage`,children:a.length>0?a.map(e=>{let t=x===e.id,n=be(e),i=I===e.id,a=r(i?`mobile.connect.connecting`:n?`mobile.instances.status.connected`:`mobile.instances.status.saved`);return(0,$.jsxs)(`div`,{className:Y(`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||(L(e.id),u({id:e.id,candidates:e.candidates,clientToken:e.clientToken,label:e.label}).finally(()=>L(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)(Z,{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:Y(`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:()=>W(e.id),style:{touchAction:`manipulation`},children:[(0,$.jsx)(Z,{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)(Z,{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),w(e.candidates.some(e=>e.kind===`direct`)?Ce(e):``),E(e.label),O(e.clientToken||``),g(null)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{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:()=>U(e.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:t?`close`:`delete-bin`,className:`size-[18px]`})})]})]},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)(Mr,{label:r(y?`mobile.instances.editTitle`:`mobile.instances.addTitle`),cardClassName:!P&&!y?`!bg-background`:void 0,children:!P&&!y?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-col items-stretch gap-2`,children:[N?(0,$.jsxs)(X,{type:`button`,size:`lg`,className:`h-12 w-full`,onClick:()=>void te(),disabled:j,children:[(0,$.jsx)(Z,{name:`scan-2`,className:Y(`size-[18px]`,j&&`animate-pulse`)}),r(`mobile.connect.scanQr`)]}):null,(0,$.jsxs)(X,{type:`button`,variant:`ghost`,size:`lg`,className:`h-12 w-full`,onClick:()=>{g(null),F(!0)},children:[(0,$.jsx)(Z,{name:`add`,className:`size-[18px]`}),r(`mobile.instances.addManual`)]}),c?(0,$.jsx)(`p`,{className:`px-1 text-center typography-small text-[var(--status-error)]`,children:c}):null]}):(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`flex min-h-8 items-center justify-end px-1`,children:(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`xs`,onClick:z,children:r(`mobile.instances.cancelEdit`)})}),(0,$.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:B,children:[b?null:(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block px-1 typography-ui-label text-foreground`,children:r(`mobile.connect.url.label`)}),(0,$.jsx)(`input`,{...zp,value:C,onChange:e=>w(e.target.value),placeholder:r(`mobile.connect.url.placeholder`),type:`url`,inputMode:`url`,autoCapitalize:`none`,className:re})]}),(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block px-1 typography-ui-label text-foreground`,children:r(`mobile.instances.label.label`)}),(0,$.jsx)(`input`,{value:T,onChange:e=>E(e.target.value),placeholder:r(`mobile.instances.label.placeholder`),autoComplete:`off`,autoCapitalize:`words`,autoCorrect:`off`,spellCheck:!1,className:re})]}),(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block px-1 typography-ui-label text-foreground`,children:r(`mobile.connect.token.label`)}),(0,$.jsx)(`input`,{...zp,value:D,onChange:e=>O(e.target.value),placeholder:r(`mobile.connect.token.placeholder`),autoCapitalize:`none`,className:re}),(0,$.jsx)(`p`,{className:`px-1 typography-micro text-muted-foreground`,children:r(`mobile.connect.token.hint`)})]}),(0,$.jsx)(X,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,children:r(y?`mobile.instances.saveEdit`:`mobile.instances.saveNew`)})]}),y?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Vo,{label:r(`mobile.connect.link.divider`)}),(0,$.jsx)(Bo,{disabled:o||j,isBusy:o,inputClassName:re,onRedeem:ee,onInvalid:V})]}),c?(0,$.jsx)(`p`,{className:`px-1 typography-small text-[var(--status-error)]`,children:c}):null]})})]})},Wp=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`},Gp=e=>{let t=(0,za.c)(13),{icon:n,iconNode:r,label:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=r??(n?(0,$.jsx)(Z,{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},Kp=e=>{let t=(0,za.c)(55),{open:n,onClose:r,anchorRef:i,contextDisplay:a,branchLabel:o,usageGroups:s,usageDisplayMode:c,isUsageLoading:l,timeFormatPreference:u}=e,{t:d}=de(),f=Q.useRef(null),[p,m]=Q.useState(n),[h,g]=Q.useState(!1),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=ae(),t[0]=_):_=t[0];let v=_,y=Q.useRef(null),[b,x]=Q.useState(null),S,C;t[1]!==i||t[2]!==n||t[3]!==p?(S=()=>{if(!n||!v||!p)return;let e=()=>{let e=i.current?.getBoundingClientRect(),t=y.current?.getBoundingClientRect();if(!e||!t){x(null);return}let n=e.left-t.left,r=Math.min(Math.max(n,8),Math.max(8,t.width-kp-8));x(r)};e();let t=y.current;if(typeof ResizeObserver>`u`||!t)return;let r=new ResizeObserver(e);return r.observe(t),()=>r.disconnect()},C=[i,v,n,p],t[1]=i,t[2]=n,t[3]=p,t[4]=S,t[5]=C):(S=t[4],C=t[5]),Q.useLayoutEffect(S,C);let w=v&&b!==null,T,E;t[6]!==n||t[7]!==p?(T=()=>{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)},E=[n,p],t[6]=n,t[7]=p,t[8]=T,t[9]=E):(T=t[8],E=t[9]),Q.useEffect(T,E);let D,O;t[10]!==r||t[11]!==n?(D=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},O=[r,n],t[10]=r,t[11]=n,t[12]=D,t[13]=O):(D=t[12],O=t[13]),Q.useEffect(D,O);let k,A;if(t[14]!==i||t[15]!==r||t[16]!==n?(k=()=>{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)}},A=[i,r,n],t[14]=i,t[15]=r,t[16]=n,t[17]=k,t[18]=A):(k=t[17],A=t[18]),Q.useEffect(k,A),!p)return null;let j;t[19]===d?j=t[20]:(j=d(`mobile.header.openMetadataAria`),t[19]=d,t[20]=j);let M=w?`absolute origin-top-left`:`mx-3 mt-2`,N=h?`pointer-events-none`:`pointer-events-auto`,P;t[21]!==M||t[22]!==N?(P=Y(`overflow-x-hidden overflow-y-auto overscroll-contain rounded-[20px] yuri-mobile-overlay-surface p-2 will-change-transform`,M,N),t[21]=M,t[22]=N,t[23]=P):P=t[23];let F=`${h?`session-metadata-out`:`session-metadata-in`} ${h?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,I;t[24]!==b||t[25]!==w?(I=w?{top:8,left:b??8,width:`min(${kp}px, calc(100% - 16px))`}:null,t[24]=b,t[25]=w,t[26]=I):I=t[26];let L;t[27]!==F||t[28]!==I?(L={animation:F,maxHeight:`min(72dvh, calc(100dvh - var(--yuri-safe-area-top, 0px) - var(--yuri-header-height, 56px) - 1rem))`,...I},t[27]=F,t[28]=I,t[29]=L):L=t[29];let R;t[30]===d?R=t[31]:(R=d(`mobile.header.metadata.branch`),t[30]=d,t[31]=R);let z;t[32]!==o||t[33]!==R?(z=(0,$.jsx)(Gp,{icon:`git-branch`,label:R,children:o}),t[32]=o,t[33]=R,t[34]=z):z=t[34];let B;t[35]!==a||t[36]!==d?(B=a?(0,$.jsx)(Gp,{iconNode:(0,$.jsx)(Mu,{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:Y(`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 ee;t[38]!==l||t[39]!==u||t[40]!==c||t[41]!==s?(ee=(0,$.jsx)(qp,{groups:s,displayMode:c,isLoading:l,timeFormatPreference:u}),t[38]=l,t[39]=u,t[40]=c,t[41]=s,t[42]=ee):ee=t[42];let V;t[43]!==z||t[44]!==B||t[45]!==ee?(V=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[z,B,ee]}),t[43]=z,t[44]=B,t[45]=ee,t[46]=V):V=t[46];let te;t[47]!==j||t[48]!==P||t[49]!==L||t[50]!==V?(te=(0,$.jsx)(`div`,{ref:f,role:`dialog`,"aria-label":j,className:P,style:L,children:V}),t[47]=j,t[48]=P,t[49]=L,t[50]=V,t[51]=te):te=t[51];let ne;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(`style`,{children:`
20
+ @keyframes session-metadata-in {
21
+ from { opacity: 0; transform: translateY(-8px) scale(0.985); }
22
+ to { opacity: 1; transform: translateY(0) scale(1); }
23
+ }
24
+ @keyframes session-metadata-out {
25
+ from { opacity: 1; transform: translateY(0) scale(1); }
26
+ to { opacity: 0; transform: translateY(-6px) scale(0.985); }
27
+ }
28
+ `}),t[52]=ne):ne=t[52];let H;return t[53]===te?H=t[54]:(H=(0,$.jsxs)(`div`,{ref:y,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:[te,ne]}),t[53]=te,t[54]=H),H},qp=e=>{let t=(0,za.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=de(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(Z,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(Z,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(vn,{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=Gr(e.rows.map($p),n),o=r===`remaining`?t.window.remainingPercent:t.window.usedPercent,s=Nn(t.window.valueLabel,o),c=En(t.window.resetAt,t.window.resetAfterFormatted??t.window.resetAtFormatted,a);return(0,$.jsxs)(Q.Fragment,{children:[i?(0,$.jsx)(`div`,{className:Y(`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:Y(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,Wp(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},Jp=e=>{let t=(0,za.c)(35),{open:n,onClose:r,items:i,rightOffset:a}=e,o=a===void 0?0:a,{t:s}=de(),c,l;if(t[0]!==r||t[1]!==n?(c=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},l=[r,n],t[0]=r,t[1]=n,t[2]=c,t[3]=l):(c=t[2],l=t[3]),Q.useEffect(c,l),!n)return null;let u;t[4]===r?u=t[5]:(u=(e,t,n)=>(0,$.jsxs)(`button`,{type:`button`,role:n===void 0?`menuitem`:`menuitemcheckbox`,"aria-checked":n,className:Y(`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,t>0&&`border-t border-border/30`,e.disabled&&`cursor-not-allowed opacity-60`),style:{touchAction:`manipulation`},disabled:e.disabled,onClick:()=>{e.onSelect(),r()},children:[e.iconNode??(e.icon?(0,$.jsx)(Z,{name:e.icon,className:Y(`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)(Z,{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)(Ka,{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:wp,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:em,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},Yp=Q.memo(function(e){let t=(0,za.c)(94),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=de(),{git:d}=ee(),f=md(i??``,a||void 0),p=f??l,m=Q.useRef(null),h=lt(i??``,a||void 0),g=or(o),_=lr(o),v=ur(tm),y=ur(nm),b=Pe(rm),x=Pe(im),S=Pe(am),C=Pe(om),w;t[0]===i?w=t[1]:(w=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=w);let T=Ge(w),E=Fr(sm),D=Fr(cm),O=Fr(lm),A=Fr(um),j=Fr(dm),M=Fr(fm),N=Fr(pm),P=k(mm);Pr();let F,I;t[2]!==v||t[3]!==d||t[4]!==o?(F=()=>{o&&v(o,d)},I=[v,d,o],t[2]=v,t[3]=d,t[4]=o,t[5]=F,t[6]=I):(F=t[5],I=t[6]),Q.useEffect(F,I);let L,R;t[7]!==y||t[8]!==d||t[9]!==o?(L=()=>{if(o)return Ne.onGitRefreshHint(e=>{Rp(e.directory)===o&&y(o,d)})},R=[y,d,o],t[7]=y,t[8]=d,t[9]=o,t[10]=L,t[11]=R):(L=t[10],R=t[11]),Q.useEffect(L,R);let z,B;t[12]===D?(z=t[13],B=t[14]):(z=()=>{D()},B=[D],t[12]=D,t[13]=z,t[14]=B),Q.useEffect(z,B);let V,te;t[15]===M?(V=t[16],te=t[17]):(V=()=>{_n(M)},te=[M],t[15]=M,t[16]=V,t[17]=te),Q.useEffect(V,te);let ne,H;t[18]!==M||t[19]!==O||t[20]!==A||t[21]!==n||t[22]!==E?(ne=()=>{!n||A||M.some(e=>!E.some(t=>t?.providerId===e))&&O()},H=[M,O,A,n,E],t[18]=M,t[19]=O,t[20]=A,t[21]=n,t[22]=E,t[23]=ne,t[24]=H):(ne=t[23],H=t[24]),Q.useEffect(ne,H);let U;t[25]===h?U=t[26]:(U=Ru(h),t[25]=h,t[26]=U);let W=U,re;t[27]!==S||t[28]!==x||t[29]!==W||t[30]!==T?(re=W??(T?{providerID:T.providerId,modelID:T.modelId}:null)??(x&&S?{providerID:x,modelID:S}:null),t[27]=S,t[28]=x,t[29]=W,t[30]=T,t[31]=re):re=t[31];let ie=re,ae;if(t[32]!==C||t[33]!==ie||t[34]!==b){let e=(ie?b.find(e=>e.id===ie.providerID):void 0)?.models.find(e=>e.id===ie?.modelID),n;t[36]!==C||t[37]!==ie?(n=ie?C(ie.providerID,ie.modelID):void 0,t[36]=C,t[37]=ie,t[38]=n):n=t[38];let r=n;ae=Pu(e?.limit,`context`)??r?.limit?.context??0,t[32]=C,t[33]=ie,t[34]=b,t[35]=ae}else ae=t[35];let oe=ae,G=St(i??``,oe,0,a||void 0),se=G?.pending?null:G?.totalTokens??0,ce;t[39]!==oe||t[40]!==s||t[41]!==se?(ce=Lu({totalTokens:se,contextLimit:oe,isDraft:s}),t[39]=oe,t[40]=s,t[41]=se,t[42]=ce):ce=t[42];let le=ce,K;t[43]!==_?.current||t[44]!==g||t[45]!==u?(K=g===!0?_?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[43]=_?.current,t[44]=g,t[45]=u,t[46]=K):K=t[46];let q=K,J;if(t[47]!==M||t[48]!==E||t[49]!==N||t[50]!==u){let e=new Map(E.map(hm)),n;t[52]===M?n=t[53]:(n=e=>M.includes(e.id),t[52]=M,t[53]=n),J=Nr(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 Ei(Object.entries(n?.usage?.windows??{}),n?.usage?.accounts))r.push({key:`window-${e}`,label:kn(t.label??e),window:t});let i=Object.entries(n?.usage?.models??{}),a=N[t.id]??[],o=a.length>0?i.filter(e=>{let[t]=e;return a.includes(t)}):i;for(let[e,t]of o){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:kn(a.label??i),subtitle:Lr(e),window:a})}let s=!n.ok&&n.error?n.error:r.length===0?u(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:s}}),t[47]=M,t[48]=E,t[49]=N,t[50]=u,t[51]=J}else J=t[51];let ue=J,fe,X;t[54]!==n||t[55]!==ue?(fe=()=>{!n||ue.length===0||_n(ue.map(gm))},X=[n,ue],t[54]=n,t[55]=ue,t[56]=fe,t[57]=X):(fe=t[56],X=t[57]),Q.useEffect(fe,X);let pe;t[58]===c?pe=t[59]:(pe=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[58]=c,t[59]=pe);let me;t[60]!==p||t[61]!==f?(me=p?(0,$.jsx)(`span`,{className:Y(`block truncate`,f?`yuri-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:p}):null,t[60]=p,t[61]=f,t[62]=me):me=t[62];let he;t[63]!==pe||t[64]!==me?(he=(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,me]})}),t[63]=pe,t[64]=me,t[65]=he):he=t[65];let ge;t[66]===u?ge=t[67]:(ge=u(`mobile.header.openMetadataAria`),t[66]=u,t[67]=ge);let _e;t[68]===r?_e=t[69]:(_e=()=>r(_m),t[68]=r,t[69]=_e);let ve;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ve={touchAction:`manipulation`},t[70]=ve):ve=t[70];let ye=le?.percentage??0,be=le?.pending,xe;t[71]!==ye||t[72]!==be?(xe=(0,$.jsx)(Mu,{percentage:ye,pending:be}),t[71]=ye,t[72]=be,t[73]=xe):xe=t[73];let Se;t[74]!==n||t[75]!==ge||t[76]!==_e||t[77]!==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":ge,"aria-expanded":n,onClick:_e,style:ve,children:xe}),t[74]=n,t[75]=ge,t[76]=_e,t[77]=xe,t[78]=Se):Se=t[78];let Ce;t[79]===r?Ce=t[80]:(Ce=()=>r(!1),t[79]=r,t[80]=Ce);let we;t[81]!==q||t[82]!==le||t[83]!==A||t[84]!==n||t[85]!==j||t[86]!==Ce||t[87]!==P||t[88]!==ue?(we=(0,$.jsx)(Kp,{open:n,onClose:Ce,anchorRef:m,contextDisplay:le,branchLabel:q,usageGroups:ue,usageDisplayMode:j,isUsageLoading:A,timeFormatPreference:P}),t[81]=q,t[82]=le,t[83]=A,t[84]=n,t[85]=j,t[86]=Ce,t[87]=P,t[88]=ue,t[89]=we):we=t[89];let Te;return t[90]!==he||t[91]!==Se||t[92]!==we?(Te=(0,$.jsxs)($.Fragment,{children:[he,Se,we]}),t[90]=he,t[91]=Se,t[92]=we,t[93]=Te):Te=t[93],Te}),Xp=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=de(),[a,o]=Q.useState(!1),s=D(e=>e.currentDirectory),c=ct(e=>e.currentSessionId),l=Q.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=ct(l)||s,d=Rp(u)||null,f=pt(e=>e.projects),p=ct(e=>e.availableWorktreesByProject),m=Q.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=ct(m),g=Re(c),_=ct(e=>!!e.newSessionDraft?.open),v=Q.useMemo(()=>{let e=Rp(u);return e&&Hp((h?.projectDirectory?Ze(f,h.projectDirectory):null)??nt(f,p,e),e)||i(`mobile.header.noProject`)},[p,h?.projectDirectory,u,f,i]),y=g?.title?.trim()||(c?i(`mobile.sessions.untitled`):v),b=c?v:``;Q.useEffect(()=>{o(!1)},[c,u]);let x=J(()=>{o(!1),e()}),S=J(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(qo,{children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.sessions.openSheetAria`),onClick:x,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`folders`,className:`size-5`})}),(0,$.jsx)(Yp,{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:Y(`flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`files`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.files`),"aria-pressed":r.activePanel===`files`,onClick:r.onToggleFiles,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(`button`,{type:`button`,className:Y(`relative flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`changes`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.changes`),"aria-pressed":r.activePanel===`changes`,onClick:r.onToggleChanges,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Z,{name:`git-branch`,className:`size-5`}),r.changesDirty?(0,$.jsx)(`span`,{className:`absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary`,"aria-hidden":!0}):null]})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.header.openMenuAria`),"aria-controls":wp,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`more-2`,className:`size-5`})})]})})},Zp=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=de(),r=en();Le(),rt();let i=k(e=>e.mobileSessionPanelOpen),a=k(e=>e.setMobileSessionPanelOpen),o=k(e=>e.isScheduledTasksDialogOpen),s=k(e=>e.activeMainTab),c=Oe(),l=k(e=>e.setActiveMainTab),[u,d]=Q.useState(!1),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),[b,x]=Q.useState(null),[S,C]=Q.useState(null),[w,T]=Q.useState(null),[E,O]=Q.useState(0),[A,j]=Q.useState(!1),[M,N]=Q.useState(!1),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1),[R,z]=Q.useState(!1),[B,ee]=Q.useState(!1),[V,te]=Q.useState(`nav`),[ne,H]=Q.useState(!1),[U,W]=Q.useState(!1),re=J(()=>{H(!1),W(!0)}),ie=J(()=>W(!1)),[oe,G]=Q.useState(!1),se=J(()=>H(e=>!e)),le=J(()=>H(!1)),[K,q]=Q.useState(null),ue=D(e=>e.currentDirectory),fe=k(e=>e.setSettingsPage),pe=Br(e=>e.available),me=Br(e=>e.runtimeType),he=Q.useMemo(()=>Pp(),[]),ge=Q.useMemo(()=>Lo(),[]),{data:_e=[],refetch:ve}=Zi(ue??null,{enabled:A}),{refetch:ye}=Qi(ue??null,{enabled:A}),xe=ea(e=>e.setMcpDraft),Se=ea(e=>e.setSelectedMcp),Ce=lr(Rp(ue)||null)?.files?.length??0;Q.useEffect(()=>Ne.onDirectoryRequest(()=>z(!0)),[]);let we=Q.useMemo(()=>ae(),[]),Te=zn()===`portrait`,[Ee,De]=Q.useState(we&&!Te),[Ae,je]=Q.useState(null),Me=J(e=>{if(e&&fe(e),we){te(e?`page-content`:`nav`),F(!0);return}let t=bt.getState();if(e){t.openSettingsFromCurrent();return}fe(`home`),t.setActiveTab(`settings`)}),Pe=J(()=>{Me(`instances`)}),Fe=J(()=>{bt.getState().openInstances()}),Ie=J(async t=>{if(!t){Fe();return}let n=e.connections.find(e=>e.id===t);!n||e.isBusy||be(n)||(await e.connect({id:n.id,candidates:n.candidates,clientToken:n.clientToken,label:n.label}),be(n)||Fe())}),Re=J(()=>{bt.getState().closeSecondary()}),ze=J(async()=>{if(!B){ee(!0);try{let t=await Ro();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`:ce.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:ce.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:ce.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:ce.error(n(`mobile.connect.scan.failed`))}}finally{ee(!1)}}});ma({enabled:!we,rootRoutesBlocked:i||u||f||g||v||o||A||P||I||R||ne||U});let Be=J(()=>{let e=!Ee;e&&Te&&je(null),De(e)}),Ve=J(()=>{if(y(!1),x(null),C(null),p(!1),h(null),we){q(null),je(`files`),Te&&De(!1);return}d(!0)}),He=J(()=>{p(!1),h(null)}),Ue=J(e=>{let t=e.path.trim();if(t){if(y(!1),x(null),C(null),q(null),_(!1),we){k.getState().setPendingFileFocusPath(t),je(`files`),Te&&De(!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)}}),We=k(e=>e.pendingFileFocusPath);Q.useEffect(()=>{if(We){if(we){Ve();return}Ue({path:We}),k.getState().setPendingFileFocusPath(null)}},[We,we,Ve,Ue]);let Ge=J((e=null)=>{if(y(!1),x(null),C(null),T(null),p(!1),h(null),q(e),we){je(`changes`),Te&&De(!1);return}_(!0)}),Ke=J((e,t,n)=>{q(null),_(!1),p(!1),h(null),x(e??null),C(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(T(r),O(e=>e+1),we){je(`turn-diff`),Te&&De(!1);return}y(!0)}),qe=J(()=>{je(null),q(null),T(null)}),Je=J(e=>{if(Ae===e){qe();return}e===`files`?Ve():Ge()}),Ye=Q.useRef(`changes`);Ae&&(Ye.current=Ae);let[Xe,Ze]=Q.useState(!1);Q.useEffect(()=>{if(!we)return;if(Ae){Ze(!0);return}let e=window.setTimeout(()=>Ze(!1),240);return()=>window.clearTimeout(e)},[Ae,we]);let Qe=Ae??Ye.current,$e=Mp(`left`,`yuri.ipad.leftSidebarWidth`,Tp),et=Mp(`right`,`yuri.ipad.rightSidebarWidth`,Ep),tt=Q.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{Ge(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{Ge({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:Ke,openFile:({path:e,targetLine:t})=>{Ue({path:e,targetLine:t})},openFiles:()=>Ve(),openSettings:e=>{Me(e)}}),[Ge,Ue,Ve,Me,Ke]),nt=J(()=>{_(!1),q(null)}),it=J(()=>{y(!1),T(null)});zd(Q.useMemo(()=>({openSessions:()=>{if(we){De(!0);return}bt.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?Ve():e===`mcp`?j(!0):e===`instances`?Pe():e===`update`&&L(!0)},openChanges:({path:e,staged:t}={})=>{Ge(e?{path:e,staged:t===!0}:null)},openSettings:e=>{Me(e)}}),[we,Ge,Ve,Pe,Me]));let at=Q.useRef(null),st=Q.useRef(null),lt=ct(e=>e.currentSessionId),ut=ct(e=>e.setCurrentSession),dt=Q.useMemo(()=>e=>lt?e.getDirectoryForSession(lt):null,[lt]),ft=ct(dt),pt=ot(lt,ft||ue||void 0);fp();let mt=J(()=>{let e=lt;if(!e||oe)return;let t=ft||ue||void 0;G(!0),(async()=>{try{await r.refreshSessionTranscript(e,{directory:t}),ce.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{ce.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{G(!1)}})()}),ht=bt(e=>e.secondary?.kind??null),gt=!we&&(ht===`chat`||ht===`draft`);Q.useEffect(()=>{!we&&!gt&&H(!1)},[we,gt]),Q.useEffect(()=>{H(!1)},[lt]);let _t=we&&s===`assistant`||!we&&!gt||i||u||f||g||v||o||A||P||I||R||ne||U;cf(st,{onOpen:J(()=>{qn(tr)?.finish(`commit`)}),onPreviewStart:J(()=>{qn(tr)?.begin(`present`)}),onPreviewCancel:J(()=>{qn(tr)?.finish(`cancel`)}),onProgress:J(e=>{e!==null&&qn(tr)?.update(e)}),disabled:_t},we||gt);let vt=J(e=>{at.current=e});Lp(J(()=>U?(ie(),!0):ne?(H(!1),!0):R?(z(!1),!0):o?(window.dispatchEvent(new Event(`yuri:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):ha.backImmediately(`overlay`)?!0:f?(He(),!0):u?(d(!1),!0):v?(it(),!0):g?(nt(),!0):A?(j(!1),!0):P?(F(!1),!0):I?(L(!1),!0):ha.requestAnimatedBack(`root`)||at.current?.()?!0:s===`assistant`?(l(`chat`),!0):pt?(ut(pt.id,pt.directory),!0):!1));let yt=pe&&(me===`desktop`||me===`web`),xt=J(()=>{let e=`new-mcp-server`,t=e,n=1;for(;_e.some(e=>e.name===t);)t=`${e}-${n}`,n+=1;xe({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),Se(t),j(!1),Me(`mcp`)}),St=J(()=>{if(M)return;N(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([ye(),ve(),e]).finally(()=>N(!1))}),Ct=ct(e=>e.openNewSessionDraft),wt=Q.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(we){l(`chat`),Ct();return}bt.getState().openDraft()}}];return we||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>Ve()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:Ce,onSelect:()=>Ge()}),e.push({key:`mcp`,iconNode:(0,$.jsx)(zr,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>j(!0)}),yt&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>L(!0)}),we&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>Me()}),lt&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:oe,spinning:oe,onSelect:mt}),e.push({key:`remote-desktop`,icon:`computer`,label:n(`remoteDesktop.title`),onSelect:re}),e},[lt,Ce,we,oe,Ge,Ve,Ct,re,Me,mt,l,yt,n]);return(0,$.jsx)(Ga,{sessionId:lt??``,directory:ft||ue||void 0,active:we?s!==`assistant`:ht===`chat`,children:(0,$.jsx)(nr,{actions:tt,children:(0,$.jsxs)(Uo,{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:[we?(0,$.jsxs)(`aside`,{ref:$e.asideRef,className:Y(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!Ee&&`border-r-0`),style:{width:Ee?$e.width:0,minWidth:Ee?$e.width:0,maxWidth:Ee?$e.width:0,"--yuri-ipad-sidebar-width":`${$e.width}px`,overflowX:`clip`,paddingTop:`var(--yuri-safe-area-top, 0px)`,transitionProperty:$e.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Ee,"data-page-scroll-lock":`true`,children:[Ee?(0,$.jsx)(Np,{side:`left`,isResizing:$e.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:$e.handleProps}):null,(0,$.jsx)(`div`,{className:Y(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,$e.isResizing&&`pointer-events-none`,!Ee&&`pointer-events-none select-none opacity-0`),style:{width:`var(--yuri-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(Dn,{children:(0,$.jsx)(bc,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&Te&&De(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,children:we?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(Xp,{onOpenSessions:()=>Be(),menuOpen:ne,onToggleMenu:se,surfaceShortcuts:{activePanel:Ae===`turn-diff`?`changes`:Ae,changesDirty:Ce>0,onToggleFiles:()=>Je(`files`),onToggleChanges:()=>Je(`changes`)}})}),(0,$.jsx)(`main`,{ref:st,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)(Dn,{children:s===`assistant`?(0,$.jsx)(Ta,{}):(0,$.jsx)(Fi,{})})})})]}):(0,$.jsx)(nu,{className:`min-h-0 flex-1`,onAddProject:()=>z(!0),onScanQr:he&&ge?()=>{ze()}:void 0,onSwitchInstance:he?Ie:void 0,onRemoteDesktop:re,instanceOptions:he?e.connections.map(t=>({id:t.id,label:t.label,active:be(t),disabled:e.isBusy})):void 0,onEnableAssistants:()=>{Me(`assistants`)},instancesPage:he?(0,$.jsx)(Up,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,instancesSecondaryPage:he?(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)(ke,{title:n(`mobile.settings.switchInstance`),backAriaLabel:n(`header.actions.backAria`),onBack:Re}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[var(--yuri-mobile-page-inline-inset)]`,children:(0,$.jsx)(ra,{className:`yuri-mobile-settings-detail-card`,children:(0,$.jsx)(Up,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:pt?{id:pt.id,directory:pt.directory}:null,registerSecondaryBackHandler:vt,scheduledContent:(e,t)=>(0,$.jsx)(Gi,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(yd,{sessionId:e.sessionId,directory:e.directory,onBack:()=>{le(),ha.requestAnimatedBack(`root`)},onOpenMenu:se,onCloseMenu:le,menuOpen:e.active&&ne,children:(0,$.jsx)(`main`,{ref:e.active?st: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)(Dn,{children:(0,$.jsx)(Fi,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:e.sessionId||null,directory:e.directory,viewKey:e.viewKey}})})})})})})}),we?(0,$.jsxs)(`aside`,{ref:et.asideRef,className:Y(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!Ae&&`border-l-0`),style:{width:Ae?et.width:0,minWidth:Ae?et.width:0,maxWidth:Ae?et.width:0,"--yuri-ipad-sidebar-width":`${et.width}px`,overflowX:`clip`,paddingTop:`var(--yuri-safe-area-top, 0px)`,transitionProperty:et.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Ae,"data-page-scroll-lock":`true`,children:[Ae?(0,$.jsx)(Np,{side:`right`,isResizing:et.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:et.handleProps}):null,(0,$.jsx)(`div`,{className:Y(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,et.isResizing&&`pointer-events-none`,!Ae&&`pointer-events-none select-none opacity-0`),style:{width:`var(--yuri-ipad-sidebar-width)`,overflowX:`hidden`},children:Xe?(0,$.jsx)(Dn,{children:Qe===`files`?(0,$.jsx)(zs,{onClose:qe}):Qe===`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)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:qe,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Ni,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:w,navigationRequestKey:E,flushContent:!0})})]}):K?.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:K.toolPatches.length>1?n(`mobile.nav.changes`):K.path}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:qe,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Ni,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:K.path,targetLine:K.targetLine??null,toolPatches:K.toolPatches,singleFileView:K.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(ss,{onClose:qe,initialDiffPath:K?.path??null,initialDiffStaged:K?.staged===!0,initialDiffTargetLine:K?.targetLine??null})}):null})]}):null,(0,$.jsx)(li,{open:R,onOpenChange:z,forceMobile:!0}),(0,$.jsx)(Jp,{open:ne,onClose:()=>H(!1),items:wt,rightOffset:we&&Ae?et.width:0}),(0,$.jsx)(qr,{}),U&&(0,$.jsx)(ju,{onClose:ie,instanceName:e.connections.find(be)?.label}),u?(0,$.jsx)(er,{id:yp,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)(Dn,{children:(0,$.jsx)(zs,{onClose:()=>d(!1)})})}):null,f&&m?(0,$.jsx)(er,{id:vp,open:f,onOpenChange:e=>{e||He()},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)(Dn,{children:(0,$.jsx)(zs,{onClose:He,initialFilePath:m.path,directFilePreview:!0,hideFileHeader:!0},m.path)})}):null,(0,$.jsx)(er,{id:_p,open:v,onOpenChange:e=>{e||it()},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)(Dn,{children:(0,$.jsx)(Ni,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,toolbarInSheetHeader:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:w,navigationRequestKey:E,flushContent:!0})})}),g&&K?(0,$.jsx)(er,{id:gp,open:g,onOpenChange:e=>{e||nt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:K.toolPatches&&K.toolPatches.length>1?n(`mobile.nav.changes`):K.path}),ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Dn,{children:K.toolPatches?.length?(0,$.jsx)(Ni,{hideStackedFileSidebar:!0,toolbarInSheetHeader:!0,diffScope:`turn`,targetFilePath:K.path,targetLine:K.targetLine??null,toolPatches:K.toolPatches,singleFileView:K.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(ss,{initialDiffPath:K.path,initialDiffStaged:K.staged,initialDiffTargetLine:K.targetLine??null,hideDiffHeader:!0})})}):g?(0,$.jsx)(er,{id:bp,open:g,onOpenChange:e=>{e||nt()},ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Dn,{children:(0,$.jsx)(ss,{onClose:nt,initialDiffPath:K?.path??null,initialDiffStaged:K?.staged===!0,initialDiffTargetLine:K?.targetLine??null})})}):null,A?(0,$.jsx)(er,{id:xp,open:A,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)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:xt,"aria-label":n(`settings.mcp.sidebar.actions.addServerTitle`),title:n(`settings.mcp.sidebar.actions.addServerTitle`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`add`,className:`size-5`})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:St,disabled:M,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`refresh`,className:Y(`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)(Dn,{children:(0,$.jsx)(ci,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,P&&we?(0,$.jsx)(er,{id:Sp,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)(Dn,{children:(0,$.jsx)(ua,{forceMobile:!0,isWindowed:!0,initialMobileStage:V,visiblePageSlugs:[...fa],onClose:()=>F(!1),mobileInstancesPage:he?(0,$.jsx)(Up,{connection:e,onConnect:()=>F(!1),onActiveConnectionDeleted:t}):void 0})})}):null,I?(0,$.jsx)(er,{id:Cp,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)(Dn,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(aa,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(ia,{enabled:he&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(Dn,{children:(0,$.jsx)(ai,{})}),(0,$.jsx)(Yi,{})]})})})};function Qp({apis:e}){Q.useEffect(()=>Ue(),[]);let{t}=de(),n=Pe(e=>e.initializeApp),r=Pe(e=>e.isInitialized),i=Pe(e=>e.isConnected),a=Pe(e=>e.connectionPhase),o=D(e=>e.currentDirectory),s=ct(e=>e.currentSessionId),l=ct(e=>!!e.newSessionDraft?.open),u=ct(e=>e.error),f=ct(e=>e.clearError),p=k(e=>e.setIsMobile),m=Vr(e=>e.refreshStatus),g=pt(e=>e.projects),[v,y]=Q.useState(0),[b,x]=Q.useState(0),[S,C]=Q.useState(!1),[T,E]=Q.useState(`pending`),O=Q.useMemo(()=>ge(),[]),[,A]=Q.useReducer(e=>e+1,0),j=Q.useMemo(()=>Pp(),[]),M=Q.useRef(0),N=Q.useRef(0),P=Se(()=>{E(`done`),y(e=>e+1)});Bd(J(e=>{P.redeemPairingConnection(e)}));let F=Vd({ready:j&&i&&r});Q.useEffect(()=>{!P.error||!h()||ce.error(P.error)},[P.error]);let I=J(()=>{let t=h(),r=N.current+1;if(N.current=r,!t){xe();return}let i=()=>{n(),m(e.github,{force:!0}),Pe.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},a=()=>{d({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)};ve().then(e=>{if(N.current===r){if(e===`no-connection`){a();return}if(e===`unreachable`){window.setTimeout(()=>{N.current===r&&ve().then(e=>{if(N.current===r&&e!==`switched`&&e===`unchanged`){i();return}})},4e3);return}e!==`switched`&&i()}});let o=Date.now();o-M.current>=Bp&&(M.current=o,window.dispatchEvent(new Event(`yuri:system-resume`)))});Fp(),Ip(I),Q.useEffect(()=>{if(!j)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>I(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[j,I]),Q.useEffect(()=>(_(e),()=>_(null)),[e]),Q.useEffect(()=>{j&&G().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[j]),Q.useEffect(()=>{if(!j)return;let e=!1,t=[];return G().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`download`,e=>{Br.getState().setOtaDownloadPercent(e.percent)}),i=await n.addListener(`downloadFailed`,()=>{Br.getState().setOtaDownloadFailed()}),a=await n.addListener(`downloadComplete`,()=>{Br.getState().setOtaPhase(`pending_restart`)}),o=await n.addListener(`appReloaded`,()=>{Br.getState().setOtaPhase(`pending_restart`)}),s=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),Br.getState().setOtaPhase(`error`,`OTA update was reverted`)});if(e){r.remove(),i.remove(),a.remove(),o.remove(),s.remove();return}t.push(()=>void r.remove(),()=>void i.remove(),()=>void a.remove(),()=>void o.remove(),()=>void s.remove())}catch(e){console.warn(`[OTA] Failed to subscribe to Capgo updater events:`,e)}}),()=>{e=!0;for(let e of t)e()}},[j]),Q.useEffect(()=>c(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){Vi(),A();return}Ai(e),bt.getState().reset(),x(e=>e+1),y(e=>e+1)}),[]),Q.useEffect(()=>{if(F===`pending`)return;if(F===`connect`){E(`done`);return}if(!j||i||h()){E(`done`);return}let e=!1;return E(`attempting`),he().then(e=>e?!0:xe()).catch(()=>!1).then(()=>{e||E(`done`)}),()=>{e=!0}},[F]),Q.useEffect(()=>{p(!0)},[p]),Q.useEffect(()=>{j&&!h()||n()},[v,n,j]),tn({enabled:!j||!!h(),source:`mobileApp:recovery`}),Q.useEffect(()=>{i&&w.setDirectory(o)},[o,i]),Q.useEffect(()=>{i&&m(e.github,{force:!0})},[e.github,i,m]),Q.useEffect(()=>{if(!i||g.length===0)return;let e=!1;return(async()=>{await Promise.all(g.map(async t=>{let n=Rp(t.path);if(n)try{if(!(ur.getState().directories.get(n)?.isGitRepo??await W(()=>import(`./gitApi-CdlAr0G6.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([78,1,5,4,6,8,50,7,11,9,51,52,12,13,10,53,14,18,16,54,55,17,19,15,20,21,2,49,23,56,34,35,36,37,38,39,40,57,58,59,60])))||e)return;await Cn({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i,g]),Q.useEffect(()=>{if(!u)return;let e=window.setTimeout(()=>f(),5e3);return()=>window.clearTimeout(e)},[f,u]),Q.useEffect(()=>{if(!(!i&&(!j||h()))){C(!1);return}let e=window.setTimeout(()=>C(!0),8e3);return()=>window.clearTimeout(e)},[i,j,v,b]),fn(),Bt({enabled:!0}),$t(),ni(),hf({enabled:j&&i}),pp();let L=bd(),R=!i&&a===`reconnecting`;if(!L)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(Rn,{width:120,height:120,isAnimated:!0})});let z=!!h();return j&&(!z||!i&&!R)?z?(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)(Rn,{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)(X,{type:`button`,variant:`outline`,onClick:()=>{d({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):T===`done`?(0,$.jsx)(Ho,{connection:P}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(Rn,{width:120,height:120,isAnimated:!0}),O?(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:[O,(0,$.jsx)(pn,{})]})]}):null]}):!i&&!R?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)(Rn,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(Dn,{children:(0,$.jsx)(Je,{sdk:w.getSdkClient(),directory:o||``,bootstrapDirectory:!(l&&s===null),children:(0,$.jsx)(mn,{apis:e,children:(0,$.jsx)(ri,{ready:r,children:(0,$.jsx)(Tn,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(ii,{}),(0,$.jsx)(we,{}),(0,$.jsx)(on,{embeddedBackgroundWorkEnabled:r}),(0,$.jsx)(vi,{}),(0,$.jsx)(Za,{}),(0,$.jsx)(so,{}),(0,$.jsx)(Zp,{connection:P,onActiveConnectionDeleted:()=>{d({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),bt.getState().reset(),y(e=>e+1)}}),(0,$.jsx)(Vt,{position:`top-center`,offset:`calc(var(--yuri-safe-area-top, 0px) + 16px)`}),r?(0,$.jsx)(Wi,{}):null,r?(0,$.jsx)(Jr,{}):null]})})})})},b)})}function $p(e){return e.window}function em(e){e.currentTarget.style.transform=`none`}function tm(e){return e.ensureStatus}function nm(e){return e.fetchStatus}function rm(e){return e.providers}function im(e){return e.currentProviderId}function am(e){return e.currentModelId}function om(e){return e.getModelMetadata}function sm(e){return e.results}function cm(e){return e.loadSettings}function lm(e){return e.fetchAllQuotas}function um(e){return e.isLoading}function dm(e){return e.displayMode}function fm(e){return e.dropdownProviderIds}function pm(e){return e.selectedModels}function mm(e){return e.timeFormatPreference}function hm(e){return[e?.providerId,e]}function gm(e){return e.providerId}function _m(e){return!e}var vm=()=>{me(),N().then(()=>{Promise.all([M(),Qt()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),cn(),Yt(),Ht()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{Aa()})};function ym(e){vr(),vm(),k.getState().setIsMobile(!0),Ra(),Vn(),Bn();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)(Qp,{apis:r});(0,Ea.createRoot)(t).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(Ut,{children:(0,$.jsx)(fe,{children:(0,$.jsx)(Rt,{children:(0,$.jsx)(sn,{children:(0,$.jsx)(Ki,{children:(0,$.jsx)(qt,{children:n?i:(0,$.jsx)(Jt,{children:i})})})})})})})}))}export{ym as renderMobileApp};