@yuriai/web 0.2.40-beta.5 → 0.2.40-beta.6

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 (160) hide show
  1. package/dist/assets/{AgentAvatar-B7KbxN8Y.js → AgentAvatar-XDXiFZvA.js} +1 -1
  2. package/dist/assets/AssistantConversationSurface-B59k-lXE.css +1 -0
  3. package/dist/assets/AssistantConversationSurface-CQnJaKTn.js +3 -0
  4. package/dist/assets/AssistantSessionCard-DXY8-wyP.js +2 -0
  5. package/dist/assets/{AssistantUnreadBadge-vu4ZhTft.js → AssistantUnreadBadge-B-G015yE.js} +1 -1
  6. package/dist/assets/{AssistantView-CEfEWUIr.js → AssistantView-CasyQbii.js} +1 -1
  7. package/dist/assets/{DiagramView-Dlzr08J_.js → DiagramView-DhWnsM9v.js} +1 -1
  8. package/dist/assets/{FadeInOnReveal-DMRmNsau.js → FadeInOnReveal-Ca9EVP3a.js} +1 -1
  9. package/dist/assets/{GuiPluginPage-DVug4z_p.js → GuiPluginPage-DKOsUpVL.js} +1 -1
  10. package/dist/assets/{GuiPluginSurface-L43o6Xv8.js → GuiPluginSurface-BfXMBqdD.js} +1 -1
  11. package/dist/assets/{GuiPluginWindow-tHXkS18H.js → GuiPluginWindow-Dmg2Qui6.js} +1 -1
  12. package/dist/assets/{Icon-DizeYahT.js → Icon-ChyA050P.js} +1 -1
  13. package/dist/assets/{ImageLoadingPlaceholder-BZC5m_km.js → ImageLoadingPlaceholder-C8QUF5aV.js} +1 -1
  14. package/dist/assets/{LoadingImage-Csw4L-Dr.js → LoadingImage-BxRq1dMQ.js} +1 -1
  15. package/dist/assets/{MarkdownRenderer-D_0iKhQN.js → MarkdownRenderer-CvWLikEO.js} +2 -2
  16. package/dist/assets/{MarkdownRendererImpl-BZ0XgjS0.js → MarkdownRendererImpl-CcNsQOEn.js} +1 -1
  17. package/dist/assets/{MarkstreamRendererImpl-DBd6Glg9.js → MarkstreamRendererImpl-D9W5XXPo.js} +1 -1
  18. package/dist/assets/MobileDetailNavigation-CnwIZn5g.js +1 -0
  19. package/dist/assets/{MobileResizableSheet-CQQ7O-2X.js → MobileResizableSheet-Bpp079l7.js} +1 -1
  20. package/dist/assets/{MobileShareBridge-IO45gM2G.js → MobileShareBridge-C-GpJfF6.js} +1 -1
  21. package/dist/assets/MobileSurface-CrNI8cYQ.js +2 -0
  22. package/dist/assets/{MultiRunWindow-fJ3XfntS.js → MultiRunWindow-DvywQkz9.js} +1 -1
  23. package/dist/assets/{OnboardingScreen-MJS5T5rL.js → OnboardingScreen-BvueSxVk.js} +1 -1
  24. package/dist/assets/{OverlayScrollbar-jtMYTn1y.js → OverlayScrollbar-CPaH_j8g.js} +1 -1
  25. package/dist/assets/RemoteAssistantSessionCard-CFWE00xD.js +1 -0
  26. package/dist/assets/{SettingsView-ZWFLpPSI.js → SettingsView-Df6GCFPI.js} +10 -10
  27. package/dist/assets/{SettingsWindow-DGRmrIWz.js → SettingsWindow-BpaRjeR-.js} +1 -1
  28. package/dist/assets/{SetupTourDialog-BYbAubwA.js → SetupTourDialog-DD_4qiTz.js} +1 -1
  29. package/dist/assets/{TerminalView-CoJ6_9P1.js → TerminalView-CRTtNAfA.js} +1 -1
  30. package/dist/assets/{ToolOutputDialog-5xBwOJ6a.js → ToolOutputDialog-omGmWntf.js} +1 -1
  31. package/dist/assets/{VoiceSettings-CN33koSc.js → VoiceSettings-Du-Yd5MF.js} +2 -2
  32. package/dist/assets/{YuriWordmark-DnFAS-Ko.js → YuriWordmark-B7lmpLRB.js} +1 -1
  33. package/dist/assets/{capgoAdapter-CCLtBZL1.js → capgoAdapter-CqMX4zC-.js} +1 -1
  34. package/dist/assets/{checkbox-rOV6DjeG.js → checkbox-KNAgqjPZ.js} +1 -1
  35. package/dist/assets/{client-uz8O6TPX.js → client-1Fk5IbQR.js} +3 -3
  36. package/dist/assets/{collapsible-CKswuqAw.js → collapsible-CdiLY07j.js} +1 -1
  37. package/dist/assets/{context-menu-B4njwT_M.js → context-menu-CO_VRWeV.js} +1 -1
  38. package/dist/assets/{diagram-BppQ_USn.js → diagram-9b-Aaful.js} +1 -1
  39. package/dist/assets/{dialog-Bg8MJnOV.js → dialog-8YYmYPFP.js} +1 -1
  40. package/dist/assets/{fileMentionTouchSelection-D-AdTJVr.js → fileMentionTouchSelection-CLQBqWR8.js} +1 -1
  41. package/dist/assets/{gitApi-DVx_V1x6.js → gitApi-uhoLUa-e.js} +1 -1
  42. package/dist/assets/gitApiHttp-B0FJaIhU.js +3 -0
  43. package/dist/assets/{gui-DN2sVP96.js → gui-BMN3-WPc.js} +1 -1
  44. package/dist/assets/{host-DrGjjO6K.js → host-D9EDWNmx.js} +1 -1
  45. package/dist/assets/{input-DRjuZMeA.js → input-DK8VTvJw.js} +1 -1
  46. package/dist/assets/{input-store-CjUOfpyA.js → input-store-CsY-uaSj.js} +1 -1
  47. package/dist/assets/insertionBoundaries-rYqUxuB-.js +1 -0
  48. package/dist/assets/{main-D2s9J_jN.js → main-BMx-2MjO.js} +14 -14
  49. package/dist/assets/main-DzqojuZ1.js +2 -0
  50. package/dist/assets/{markdownHeightCache-BL99DlhC.js → markdownHeightCache-DAvnT6xF.js} +1 -1
  51. package/dist/assets/{mcpQueries-HzYMEVWd.js → mcpQueries-CpH8vPf1.js} +1 -1
  52. package/dist/assets/miniChat-BTE_XpRk.js +2 -0
  53. package/dist/assets/mobile-BBZOulQ1.js +2 -0
  54. package/dist/assets/{mobileBackNavigation--ZdrI-Yj.js → mobileBackNavigation-Cq08UPxZ.js} +1 -1
  55. package/dist/assets/{mobileConnections-C3eGEOPy.js → mobileConnections-ZehAozpe.js} +2 -2
  56. package/dist/assets/{multirun-CDYNyLBH.js → multirun-Cll2Meol.js} +1 -1
  57. package/dist/assets/{native-DsqzO52u.js → native-CDqNKjmz.js} +1 -1
  58. package/dist/assets/{native-config-DOawZfln.js → native-config-DtUZFauV.js} +1 -1
  59. package/dist/assets/{navigation-Ibk_Pw-q.js → navigation-J3d8PQcs.js} +2 -2
  60. package/dist/assets/openRemoteProjectSession-oJZpCDPT.js +1 -0
  61. package/dist/assets/{projectMeta-D1Ytss9U.js → projectMeta-BBpfOmij.js} +1 -1
  62. package/dist/assets/prompt-attachment-upload-9fjmgafL.js +1 -0
  63. package/dist/assets/{pwa-CXupOTsD.js → pwa-C8B1Mf_t.js} +1 -1
  64. package/dist/assets/{queue-abort-optimistic-CQXpIlq6.js → queue-abort-optimistic-B1Uskf6F.js} +1 -1
  65. package/dist/assets/{react-CgRToPwO.js → react-45rBMaUm.js} +1 -1
  66. package/dist/assets/{readiness-BfuZm6Yw.js → readiness-CrjBrUa_.js} +2 -2
  67. package/dist/assets/reference-history-DqfMBWzF.js +1 -0
  68. package/dist/assets/{remote-input-store-BOdCWpQY.js → remote-input-store-84i8uDyM.js} +1 -1
  69. package/dist/assets/remoteProjectQueries-B6lrEDMq.js +1 -0
  70. package/dist/assets/remoteSessionReference-YiGvdabX.js +1 -0
  71. package/dist/assets/renderElectronMiniChatApp-BuHQB0V8.js +2 -0
  72. package/dist/assets/renderMobileApp-D_VswCi0.js +29 -0
  73. package/dist/assets/{runtimeConfig-tHm7o_0I.js → runtimeConfig-CMbNyYbK.js} +1 -1
  74. package/dist/assets/runtimeEndpointReset-zo-HZQgX.js +151 -0
  75. package/dist/assets/scheduledTaskNavigation-y5g8D2ee.js +1 -0
  76. package/dist/assets/{select-B1On-Y4Z.js → select-VWoGVTBZ.js} +1 -1
  77. package/dist/assets/sessionLookup-JAf5UU7-.js +1 -0
  78. package/dist/assets/{sortable-tabs-strip-nD1Me06z.js → sortable-tabs-strip-Dbt3TTAs.js} +1 -1
  79. package/dist/assets/{speechSettingsQueries-BYhNpzDJ.js → speechSettingsQueries-Bidfcv0W.js} +1 -1
  80. package/dist/assets/{terminalApi-madXrfqA.js → terminalApi-Cq0vjFe1.js} +1 -1
  81. package/dist/assets/{textarea-Qt06OhhX.js → textarea-vyMsAV5p.js} +1 -1
  82. package/dist/assets/{tooltip-D382RCy1.js → tooltip-DWqHWi4N.js} +1 -1
  83. package/dist/assets/{types-CHszLAS3.js → types-DeOkRCgE.js} +1 -1
  84. package/dist/assets/{useAppFontEffects-CqXrCJVt.js → useAppFontEffects-z382Lhm_.js} +60 -60
  85. package/dist/assets/useDesktopWindowControlsLayout-BEs7i5qj.js +1 -0
  86. package/dist/assets/{useDictation-Bs7TWO9r.js → useDictation-e68rFA6y.js} +1 -1
  87. package/dist/assets/{useEffectiveDirectory-CCKRdyK9.js → useEffectiveDirectory-CcM3S1OQ.js} +1 -1
  88. package/dist/assets/{useFontPreferences-CPrl1_3z.js → useFontPreferences-CO-L-Gd7.js} +1 -1
  89. package/dist/assets/{useMobileNavigationStore-BNtVrnSw.js → useMobileNavigationStore-BA0IaUi_.js} +9 -9
  90. package/dist/assets/{usePluginsStore-bMuGciUE.js → usePluginsStore-BG5MW5LR.js} +1 -1
  91. package/dist/assets/{useProjectRuntimeAPIs-BFCXBu2J.js → useProjectRuntimeAPIs-Be4gXG7P.js} +1 -1
  92. package/dist/assets/{useStreamingTextThrottle-C8xAqcgP.js → useStreamingTextThrottle-DylP9HFC.js} +1 -1
  93. package/dist/assets/{vendor-opencode-client-cQ47ywrT.js → vendor-opencode-client-BM2r1f0o.js} +3 -3
  94. package/dist/assets/{vendor-opencode-plugin-BmdTE4Te.js → vendor-opencode-plugin-ZhpPgHCL.js} +1 -1
  95. package/dist/assets/{vendor-solid-js-D98iXT7C.js → vendor-solid-js-BBVUd3Hw.js} +1 -1
  96. package/dist/index.html +10 -10
  97. package/dist/mini-chat.html +10 -10
  98. package/dist/mobile.html +1 -1
  99. package/package.json +1 -1
  100. package/server/index.js +1 -0
  101. package/server/lib/assistants/DOCUMENTATION.md +87 -0
  102. package/server/lib/assistants/assign.js +10 -7
  103. package/server/lib/assistants/builtin-skills.js +1 -0
  104. package/server/lib/assistants/builtin-skills.test.js +1 -1
  105. package/server/lib/assistants/cards.js +6 -1
  106. package/server/lib/assistants/contact-store.js +22 -5
  107. package/server/lib/assistants/contact-tools.js +46 -26
  108. package/server/lib/assistants/execution-target.js +136 -0
  109. package/server/lib/assistants/opencode-tools.js +22 -9
  110. package/server/lib/assistants/remote-execution.test.js +378 -0
  111. package/server/lib/assistants/remote-watch-reconciler.js +43 -0
  112. package/server/lib/assistants/remote-watch-reconciler.test.js +88 -0
  113. package/server/lib/assistants/routes.js +1 -0
  114. package/server/lib/assistants/service.js +302 -99
  115. package/server/lib/assistants/yuri-project.http.test.js +2 -2
  116. package/server/lib/gui-customization/DOCUMENTATION.md +8 -2
  117. package/server/lib/gui-customization/projects-client.mjs +10 -8
  118. package/server/lib/gui-customization/projects-remote.js +101 -0
  119. package/server/lib/gui-customization/projects-remote.test.js +125 -0
  120. package/server/lib/gui-customization/projects.js +30 -6
  121. package/server/lib/gui-customization/projects.test.js +66 -1
  122. package/server/lib/gui-customization/session-skill.js +2 -2
  123. package/server/lib/gui-customization/session-skill.test.js +4 -0
  124. package/server/lib/gui-customization/skill/SKILL.md +3 -1
  125. package/server/lib/gui-customization/skill/references/projects.md +30 -3
  126. package/server/lib/gui-customization/skill/references/remote-connections.md +2 -0
  127. package/server/lib/opencode/DOCUMENTATION.md +6 -0
  128. package/server/lib/opencode/feature-routes-runtime.js +2 -0
  129. package/server/lib/opencode/v2-client.js +9 -4
  130. package/server/lib/remote-hosts/DOCUMENTATION.md +52 -0
  131. package/server/lib/remote-hosts/gateway.js +136 -36
  132. package/server/lib/remote-hosts/json-lifecycle.test.js +35 -0
  133. package/server/lib/remote-hosts/routes.js +10 -13
  134. package/server/lib/remote-hosts/routes.test.js +251 -0
  135. package/server/lib/remote-hosts/store.js +17 -3
  136. package/server/lib/remote-hosts/store.test.js +19 -0
  137. package/server/lib/remote-hosts/task-client.js +25 -0
  138. package/server/lib/remote-hosts/task-client.test.js +60 -0
  139. package/server/lib/remote-hosts/transport.js +7 -2
  140. package/server/lib/request-cors.js +1 -1
  141. package/server/lib/request-cors.test.js +1 -0
  142. package/server/lib/scheduled-tasks/session-skill.test.js +33 -2
  143. package/dist/assets/AssistantConversationSurface-BnK_KTBO.js +0 -3
  144. package/dist/assets/AssistantConversationSurface-n9w_Av0k.css +0 -1
  145. package/dist/assets/MobileDetailNavigation-xgwvsQuR.js +0 -1
  146. package/dist/assets/MobileSurface-DmYgZONB.js +0 -2
  147. package/dist/assets/gitApiHttp-DvTBxvX8.js +0 -3
  148. package/dist/assets/insertionBoundaries-DZtQt2Ah.js +0 -1
  149. package/dist/assets/main-BMFY9mtb.js +0 -2
  150. package/dist/assets/miniChat-BbJ0GKpk.js +0 -2
  151. package/dist/assets/mobile-_zUth69Z.js +0 -2
  152. package/dist/assets/prompt-attachment-upload-BNhDXymd.js +0 -1
  153. package/dist/assets/remoteProjectQueries-CkxdZNw4.js +0 -1
  154. package/dist/assets/renderElectronMiniChatApp-pJ59iC34.js +0 -2
  155. package/dist/assets/renderMobileApp-BQFC-gOA.js +0 -29
  156. package/dist/assets/runtimeEndpointReset-BhHWFNvo.js +0 -150
  157. package/dist/assets/scheduledTaskNavigation-BIDtQ4wN.js +0 -1
  158. package/dist/assets/sessionLookup-RcyTTDOy.js +0 -1
  159. package/dist/assets/useDesktopWindowControlsLayout-KH4UP7Gj.js +0 -1
  160. /package/dist/assets/{sessionLookup-8C8nv-EP.css → reference-history-8C8nv-EP.css} +0 -0
@@ -1,29 +0,0 @@
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-5xBwOJ6a.js","assets/runtime-auth-mjIpsk3N.js","assets/runtime-switch-BMjl5Y5W.js","assets/runtime-fetch-DKZOpfzo.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-wF65ZFgV.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-z2M4boRm.js","assets/vendor-react-P8wFrkcT.js","assets/vendor-tanstack-react-query-B-KblYBV.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/runtime-file-resource-CuLP3xp7.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-Dyjw5sZR.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-Cfmg-aDQ.js","assets/vendor-zustand-Cwko4FG1.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-EOAzZiAy.js","assets/runtime-file-download-D11Nnedg.js","assets/vendor-pierre-diffs-tqo4Z3TC.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/i18n-RH7UieOS.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-DunGyOfe.js","assets/tour-CQMBn8gJ.js","assets/useMobileNavigationStore-BNtVrnSw.js","assets/gitApiHttp-DvTBxvX8.js","assets/client-uz8O6TPX.js","assets/vendor-opencode-client-cQ47ywrT.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-BNhDXymd.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-B5HgJenP.js","assets/useAssistantUIStore-jOKVcBK8.js","assets/input-store-CjUOfpyA.js","assets/remoteProjectQueries-CkxdZNw4.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-C57Z9mV2.js","assets/vendor-framer-motion-CF9BQLta.js","assets/Icon-DizeYahT.js","assets/dialog-Bg8MJnOV.js","assets/dialog-CTYD3Sbr.css","assets/tap-LkQum5bB.js","assets/themes-BgDJcxRc.js","assets/MarkdownRenderer-D_0iKhQN.js","assets/useEffectiveDirectory-CCKRdyK9.js","assets/markdownHeightCache-BL99DlhC.js","assets/dualLimitLru-D8Sphgua.js","assets/MobileWindowStack-DGLdgoGr.js","assets/mobileBackNavigation--ZdrI-Yj.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/toolHelpers-iEHVHQ9p.js","assets/image-loading-DBqnxgDH.js","assets/image-loading-DA9JEHD8.css","assets/ImageLoadingPlaceholder-BZC5m_km.js","assets/vendor-tanstack-react-virtual-BkuqzrEV.js","assets/markdownTheme-DFDWa8Gh.js","assets/markdown-worker-oBGEB9Eg.js","assets/vendor-capacitor-push-notifications-D5cqJIPw.js","assets/vendor-capacitor-status-bar-D9bcMr9Q.js","assets/vendor-capacitor-keyboard-BRVcFyc9.js","assets/gitApi-DVx_V1x6.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{S as t,_ as n,p as r,r as i,t as a,v as o}from"./runtime-auth-mjIpsk3N.js";import{c as s,f as c,i as l,l as u,n as d,r as f,t as p}from"./runtime-switch-BMjl5Y5W.js";import{n as m}from"./runtime-fetch-DKZOpfzo.js";import{f as h,n as g,r as _,s as v,t as y}from"./platform-wF65ZFgV.js";import{n as b,t as x}from"./runtimeAPIRegistry-C2VogTny.js";import{a as S}from"./vendor-zustand-Cwko4FG1.js";import{it as C,ot as w,st as T}from"./vendor-base-ui-z2M4boRm.js";import{Mt as E,Pt as D,St as O,xt as k}from"./gitApiHttp-DvTBxvX8.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as A}from"./safeStorage-DTOhKN0V.js";import{Bt as j,Qt as M,Zt as N,dn as P,n as F,on as I,sn as L,un as R,zt as ee}from"./client-uz8O6TPX.js";import{n as z,t as B}from"./vendor-react-P8wFrkcT.js";import{f as V}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{c as te,o as H,s as ne}from"./vendor-tanstack-react-query-B-KblYBV.js";import{C as U,D as re,E as W,G as ie,S as ae,T as oe,V as se,k as ce,q as le,w as ue,z as G}from"./runtime-file-resource-CuLP3xp7.js";import{o as de}from"./path-utils-jGozTg9d.js";import{i as K,l as fe,m as pe,r as q}from"./vendor-reactuses-core-Dyjw5sZR.js";import{a as me,n as J,o as he}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as ge}from"./useUIStore-Cfmg-aDQ.js";import{a as _e,o as ve,s as ye,t as be}from"./useMobileHtmlPreviewStore-EOAzZiAy.js";import{t as xe}from"./capgoAdapter-CCLtBZL1.js";/* empty css */import{a as Se}from"./vendor-pierre-diffs-tqo4Z3TC.js";import{r as Ce}from"./vendor-sonner-B5HgJenP.js";import{r as we,t as Te}from"./i18n-RH7UieOS.js";import{i as Ee,n as De}from"./store-DunGyOfe.js";import{a as Oe,i as ke,l as Ae,o as je,r as Me,s as Ne,t as Pe,u as Fe}from"./mobileConnections-C3eGEOPy.js";import{S as Ie,b as Le,h as Re,t as ze,v as Be,y as Ve}from"./MobileDetailNavigation-xgwvsQuR.js";import{A as He,Ba as Ue,Ci as We,Cn as Ge,Cr as Ke,Di as qe,Dr as Je,Ei as Ye,Fr as Xe,H as Ze,In as Y,J as Qe,Ji as $e,Na as et,Pr as tt,Pt as nt,R as rt,Rn as it,Si as at,Ti as ot,Ua as st,Ui as ct,Xi as lt,_i as ut,ai as dt,ar as ft,at as pt,bi as mt,er as ht,fi as gt,gr as _t,hi as vt,hr as yt,in as bt,ir as xt,jr as St,kr as Ct,lt as wt,mr as Tt,na as Et,o as Dt,p as Ot,q as kt,rr as At,s as jt,st as Mt,t as Nt,tt as Pt,ui as Ft,ut as It,vi as Lt,wi as Rt,xi as zt,z as Bt}from"./useMobileNavigationStore-BNtVrnSw.js";import{i as Vt,n as Ht,r as Ut}from"./useAssistantUIStore-jOKVcBK8.js";import{a as Wt,o as Gt,t as Kt}from"./MobileShareBridge-IO45gM2G.js";import{d as qt,h as Jt,i as Yt,m as Xt,p as Zt}from"./remoteProjectQueries-CkxdZNw4.js";import{n as Qt}from"./useThemeSystem-C57Z9mV2.js";import{n as X}from"./Icon-DizeYahT.js";import{a as $t,i as en,n as tn,o as nn,r as rn,t as an}from"./dialog-Bg8MJnOV.js";import{$ as on,B as sn,Bt as cn,C as ln,Ct as un,D as dn,Dt as fn,Et as pn,Ft as mn,Gt as hn,Ht as gn,It as _n,J as vn,K as yn,Lt as bn,Nt as xn,Pt as Sn,Rt as Cn,S as wn,Tt as Tn,Ut as En,Vt as Dn,Wt as On,X as kn,Y as An,Zt as jn,et as Mn,i as Nn,it as Pn,jt as Fn,k as In,mt as Ln,pt as Rn,q as zn,r as Bn,rt as Vn,t as Hn,tt as Un,x as Wn,zt as Gn}from"./useAppFontEffects-CqXrCJVt.js";import{t as Kn}from"./input-DRjuZMeA.js";import{t as qn}from"./tap-LkQum5bB.js";import{r as Jn}from"./tooltip-D382RCy1.js";import{A as Yn,D as Xn,E as Zn,G as Qn,K as $n,M as er,O as tr,Q as nr,S as rr,W as ir,q as ar}from"./pwa-CXupOTsD.js";import{t as or}from"./YuriLogo-CvyJy_R9.js";import{o as sr}from"./react-CgRToPwO.js";import{i as cr,o as lr,t as ur}from"./device-QL8KNSLM.js";import{r as dr}from"./themes-BgDJcxRc.js";import{o as fr}from"./scheduledTaskNavigation-BIDtQ4wN.js";import{a as pr,n as mr,o as hr}from"./MarkdownRenderer-D_0iKhQN.js";import{C as gr,d as _r,n as vr,r as yr,t as br,u as xr}from"./MobileResizableSheet-CQQ7O-2X.js";import{E as Sr,T as Cr}from"./sessionLookup-RcyTTDOy.js";import{_ as wr,g as Tr,v as Er,w as Dr}from"./insertionBoundaries-DZtQt2Ah.js";import{l as Or,u as kr}from"./select-B1On-Y4Z.js";import{M as Ar,N as jr,O as Mr,h as Nr,i as Pr,n as Fr,r as Ir,s as Lr,t as Rr}from"./mobileBackNavigation--ZdrI-Yj.js";import{r as zr}from"./queue-abort-optimistic-CQXpIlq6.js";import{a as Br,c as Vr,i as Hr,s as Ur}from"./toolHelpers-iEHVHQ9p.js";import{o as Wr}from"./image-loading-DBqnxgDH.js";import{t as Gr}from"./ImageLoadingPlaceholder-BZC5m_km.js";import{t as Kr}from"./LoadingImage-Csw4L-Dr.js";import{n as qr,r as Jr}from"./textarea-Qt06OhhX.js";import{a as Yr,f as Xr,i as Zr,n as Qr,s as $r}from"./projectMeta-D1Ytss9U.js";import{r as ei}from"./ToolOutputDialog-5xBwOJ6a.js";import{n as ti,t as ni}from"./useProjectRuntimeAPIs-BFCXBu2J.js";import{$ as ri,A as ii,G as ai,M as oi,Q as si,Y as ci,d as li,et as ui,i as di,k as fi,n as pi,r as mi,t as hi}from"./MobileSurface-DmYgZONB.js";import{a as gi,i as _i}from"./AssistantConversationSurface-BnK_KTBO.js";import{t as vi}from"./useFontPreferences-CPrl1_3z.js";import{B as yi,Ct as bi,Dt as xi,E as Si,Et as Ci,F as wi,Ft as Ti,G as Ei,Ht as Di,I as Oi,It as ki,J as Ai,Jt as ji,K as Mi,Kt as Ni,L as Pi,Lt as Fi,Nt as Ii,Ot as Li,P as Ri,Q as zi,R as Bi,Rt as Vi,St as Hi,T as Ui,Tt as Wi,Ut as Gi,V as Ki,W as qi,Wt as Ji,X as Yi,Y as Xi,Z as Zi,Zt as Qi,_t as $i,a as ea,at as ta,c as na,ct as ra,d as ia,dt as aa,et as oa,f as sa,ft as ca,gt as la,ht as ua,i as da,it as fa,l as pa,lt as ma,mt as ha,n as ga,nt as _a,o as va,ot as ya,pt as ba,q as xa,qt as Sa,r as Ca,rt as wa,s as Ta,st as Ea,t as Da,tt as Oa,u as ka,ut as Aa,w as ja,wt as Ma,xt as Na,z as Pa,zt as Fa}from"./runtimeEndpointReset-BhHWFNvo.js";import{t as Ia}from"./YuriWordmark-DnFAS-Ko.js";import{r as La,t as Ra}from"./mcpQueries-HzYMEVWd.js";import{f as za}from"./usePluginsStore-bMuGciUE.js";import{a as Ba,i as Va,o as Ha,r as Ua,t as Wa}from"./SettingsView-ZWFLpPSI.js";import{a as Ga,i as Ka}from"./readiness-BfuZm6Yw.js";import{t as qa}from"./relay-preview-frame-src-BPyz3nXA.js";import{n as Ja}from"./project-preview-2H-TmJkd.js";import{n as Ya,r as Xa,t as Za}from"./AssistantUnreadBadge-vu4ZhTft.js";import{a as Qa,c as $a,i as eo,o as to,r as no,s as ro,t as io}from"./AssistantView-CEfEWUIr.js";var Z=e(T(),1),ao=B(),oo=null,so=!1,co=new Promise(e=>{oo=e});function lo(){so||(so=!0,oo?.())}var uo=6,fo=e=>e.parentID??null,po=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},mo=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),ho=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=mo(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return po(n?n.path:e)},go=()=>{let e=Lt.getState().activeSessions,t=Je.getState().index.session.unseenCount,n=Ue.getState().projects,r=0,i=[];for(let a of e){let e=fo(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:ho(vt(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,uo).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},_o=`__YURI_WIDGET_SNAPSHOT__`,vo=()=>{typeof window>`u`||(window[_o]=()=>{try{return JSON.stringify(go())}catch{return null}})},Q=z(),yo=me(`YuriScreenAwake`),bo=Promise.resolve(),xo=0;function So(e){let t=bo.then(()=>yo.setEnabled({enabled:e}));return bo=t.catch(()=>void 0),t}async function Co(){if(J.isNativePlatform()&&J.isPluginAvailable(`YuriScreenAwake`)){xo+=1;try{await So(!0)}catch(e){throw--xo,e}let e=!1;return async()=>{e||(e=!0,--xo,xo===0&&await So(!1))}}if(!navigator.wakeLock)throw Error(`Screen wake lock unavailable`);let e=await navigator.wakeLock.request(`screen`);return async()=>{e.released||await e.release()}}var $=w();function wo(e){let t=(0,Q.c)(3),n=ft(),r=e.remoteState??n??void 0,i;return t[0]!==e||t[1]!==r?(i=(0,$.jsx)(Do,{...e,remoteState:r}),t[0]=e,t[1]=r,t[2]=i):i=t[2],i}function To(e){let t=(0,Q.c)(6),{identity:n,onSource:r}=e,i=wt(e.sessionId,e.directory),a=It(e.sessionId,e.directory),o,s;return t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a?(o=()=>r({identity:n,resolved:a,getMessages:()=>i}),s=[n,r,i,a],t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o,t[5]=s):(o=t[4],s=t[5]),(0,Z.useLayoutEffect)(o,s),null}function Eo(e){let{identity:t,onSource:n}=e,r=e.remoteState,i=(0,Z.useMemo)(()=>r.scope(e.sessionId),[r,e.sessionId]),a=(0,Z.useMemo)(()=>e=>r.repository.subscribe(i,e),[r,i]),o=(0,Z.useMemo)(()=>()=>r.repository.hasSession?.(i)||r.repository.getRequestState?.(i)?.status===`ready`||r.repository.getTranscript(i).messageOrder.length>0,[r,i]),s=(0,Z.useSyncExternalStore)(a,o,o),c=q(function*(){let e=r.repository.getTranscript(i);for(let t of e.messageOrder)yield e.messagesByID[t]});return(0,Z.useLayoutEffect)(()=>n({identity:t,resolved:s,getMessages:c}),[t,n,s,c]),null}function Do(e){let{sessionId:t,directory:n,active:r,children:i,remoteState:a}=e,{t:o}=Te(),c=JSON.stringify([a?.entry.key??(e.remote?`remote-pending`:`local`),a?.entry.connectionGeneration,t,n]),l=(0,Z.useRef)(null),[u,d]=(0,Z.useState)(null),f=q(e=>{l.current=e,d(t=>t?.identity===e.identity&&t.resolved===e.resolved?t:{identity:e.identity,resolved:e.resolved})}),[p,m]=fe(`yuri.auto-read`,!1),h=p===!0,[g,_]=(0,Z.useState)(0),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(document.visibilityState===`visible`),w=Un({enabled:v}),T=(0,Z.useRef)({enabled:!1,generation:0,floor:0,seen:new Set,observed:new Set,pending:[],playing:!1}),E=(0,Z.useRef)(!1),D=r&&!!t&&u?.identity===c&&u.resolved,O=q(()=>{let e=T.current;e.enabled=!1,e.generation+=1,e.pending=[],e.playing=!1,e.seen.clear(),e.observed.clear(),E.current=!1,w.stop(),x(null),y(!1)}),k=q(()=>{let e=T.current;if(!e.enabled||e.playing||!r||document.visibilityState!==`visible`)return;let t=e.pending.shift();if(!t)return;e.playing=!0,x(t);let n=e.generation;w.play(t.text,t=>{if(n===e.generation){if(e.playing=!1,x(null),t){O(),Ce.error(o(`mobile.menu.autoReadFailed`));return}k()}},{target:t.target})}),A=q(e=>{let n=T.current;!n.enabled||!D||e.sessionId!==t||!e.text.trim()||e.created<n.floor&&!n.observed.has(e.messageId)||n.seen.has(e.messageId)||(n.seen.add(e.messageId),n.pending.push(e),k())}),j=q((e,n)=>{T.current.enabled&&D&&e===t&&T.current.observed.add(n)}),M=q(()=>{if(h){m(!1),O();return}D&&(m(!0),w.unlock().catch(()=>{Ce.error(o(`mobile.menu.autoReadFailed`))}))}),N=q(()=>{let e=T.current;e.floor=0,e.seen=new Set;for(let t of l.current?.getMessages()??[])e.floor=Math.max(e.floor,t.time.created),(t.time.completed!=null||t.role!==`assistant`)&&e.seen.add(t.id);e.enabled=!0,y(!0)});(0,Z.useEffect)(()=>(O(),h&&D&&N(),O),[t,n,c,h,D,g,N,O]),(0,Z.useEffect)(()=>s(()=>{O(),_(e=>e+1)}),[O]);let P=q(()=>{m(!1),O()});K(`pointerdown`,()=>{if(!T.current.enabled||E.current)return;E.current=!0;let e=T.current.generation;w.unlock().catch(()=>{e===T.current.generation&&(E.current=!1)})},document),K(`visibilitychange`,()=>{C(document.visibilityState===`visible`),document.visibilityState===`visible`?k():(T.current.generation+=1,T.current.playing=!1,T.current.pending=[],w.stop(),x(null))},document),(0,Z.useEffect)(()=>{if(!v||!D||!S)return;let e=!1,t;return Co().then(n=>{e?n().catch(()=>void 0):t=n}).catch(()=>{e||Ce.warning(o(`mobile.menu.autoReadAwakeFailed`))}),()=>{e=!0,t?.().catch(()=>void 0)}},[v,D,S,t,n,c,g,o]);let F=(0,Z.useMemo)(()=>({enabled:h,available:D,toggle:M,rendered:A,streaming:j}),[h,D,M,A,j]),I=(0,Z.useMemo)(()=>v&&r&&S&&w.isPlaying&&b?.sessionId===t?{sessionId:t,messageId:b.messageId,stop:P}:null,[v,r,S,w.isPlaying,b,t,P]);return(0,$.jsx)(on.Provider,{value:F,children:(0,$.jsxs)(Mn.Provider,{value:I,children:[a?(0,$.jsx)(Eo,{...e,identity:c,onSource:f,remoteState:a}):e.remote?null:(0,$.jsx)(To,{...e,identity:c,onSource:f}),i]})})}function Oo(e){let t=(0,Q.c)(3),{children:n}=e,r=(0,Z.useContext)(on);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 ko={getPlatform:()=>J.getPlatform(),isPluginAvailable:e=>J.isPluginAvailable(e),openInSystemBrowser:e=>ye.open(e),openExternal:ve},Ao=async(e,t=ko)=>{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)},jo=`mobile-app-update-available`,Mo=`mobile-app-update-toast-dismissed-version`,No=()=>{let e=(0,Q.c)(9),{t}=Te(),n=ci(Po),r=ci(Fo),i=ci(Io),a=ci(Lo),o=ci(Ro),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,e[0]=s):s=e[0];let c=Z.useRef(s),l,u;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(l=()=>{if(y()!==`android`||r!==`mobile`||!n||!i||!a||o){at.dismiss(jo);return}A().getItem(Mo)!==i&&(c.current.has(i)||(c.current.add(i),at.info(t(`mobileUpdate.toast.available.title`),{id:jo,description:t(`mobileUpdate.toast.available.description`,{version:i}),duration:1/0,icon:(0,$.jsx)(X,{name:`download`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.toast.actions.download`),onClick:()=>{Ao(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{A().setItem(Mo,i),at.dismiss(jo)}}})))},u=[n,a,o,r,t,i],e[1]=n,e[2]=a,e[3]=o,e[4]=r,e[5]=t,e[6]=i,e[7]=l,e[8]=u):(l=e[7],u=e[8]),Z.useEffect(l,u),null};function Po(e){return e.available}function Fo(e){return e.runtimeType}function Io(e){return e.info?.version}function Lo(e){return e.info?.downloadUrl}function Ro(e){return e.info?.inAppApply===!0}var zo=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Bo=e=>e.enabled&&!e.alreadyChecked,Vo=`mobile-ota-update-available`,Ho=`mobile-ota-update-toast-dismissed-version`,Uo=()=>{let e=(0,Q.c)(24),{t}=Te(),[n,r]=Z.useState(!1),i=Z.useRef(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,e[0]=a):a=e[0];let o=Z.useRef(a),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=g(),e[1]=s):s=e[1];let c=s,l=ci(Wo),u=ci(Go),d=ci(Ko),f=ci(qo),p=ci(Jo),m=ci(Yo),h=ci(Xo),_=ci(Zo),v=ci(Qo),y=d?.version,b=d?.inAppApply===!0,x,S;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{Bo({enabled:c,alreadyChecked:i.current})&&(i.current=!0,ci.getState().checkForUpdates().catch($o))},S=[c],e[2]=x,e[3]=S):(x=e[2],S=e[3]),Z.useEffect(x,S);let C;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{r(!0)},e[4]=C):C=e[4];let w=q(C),T=q(es),E,D;if(e[5]!==l||e[6]!==T||e[7]!==b||e[8]!==w||e[9]!==u||e[10]!==t||e[11]!==y?(E=()=>{if(!zo({enabled:c,runtimeType:u,available:l,inAppApply:b,version:y??``,dismissedVersion:A().getItem(Ho),seenVersions:o.current})||!y){(!l||!b||u!==`mobile`)&&at.dismiss(Vo);return}o.current.add(y),at.info(t(`mobileUpdate.ota.toast.available.title`),{id:Vo,description:t(`mobileUpdate.ota.toast.available.description`,{version:y}),duration:1/0,icon:(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.ota.toast.actions.update`),onClick:w},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{T(y)}}})},D=[l,b,c,w,T,u,t,y],e[5]=l,e[6]=T,e[7]=b,e[8]=w,e[9]=u,e[10]=t,e[11]=y,e[12]=E,e[13]=D):(E=e[12],D=e[13]),Z.useEffect(E,D),!c)return null;let O;return e[14]!==n||e[15]!==_||e[16]!==p||e[17]!==f||e[18]!==h||e[19]!==d||e[20]!==m||e[21]!==v||e[22]!==u?(O=(0,$.jsx)(ai,{open:n,onOpenChange:r,info:d,downloading:f,downloaded:p,progress:m,error:h,onDownload:_,onRestart:v,runtimeType:u}),e[14]=n,e[15]=_,e[16]=p,e[17]=f,e[18]=h,e[19]=d,e[20]=m,e[21]=v,e[22]=u,e[23]=O):O=e[23],O};function Wo(e){return e.available}function Go(e){return e.runtimeType}function Ko(e){return e.info}function qo(e){return e.downloading}function Jo(e){return e.downloaded}function Yo(e){return e.progress}function Xo(e){return e.error}function Zo(e){return e.downloadUpdate}function Qo(e){return e.restartToUpdate}function $o(){}function es(e){A().setItem(Ho,e),at.dismiss(Vo)}var ts=me(`BarcodeScanner`),ns=`yuri-barcode-scanner-active`,rs=()=>vs()?ts:null,is=()=>window.Capacitor?.getPlatform?.()===`android`,as=e=>typeof e==`object`&&e&&`message`in e?String(e.message??``):String(e??``),os=e=>/^\s*scan canceled\.?\s*$/i.test(as(e)),ss=e=>/denied access to camera/i.test(as(e)),cs=e=>!os(e)&&!ss(e),ls=e=>{let t=as(e);return/module/i.test(t)&&/not\s*available|unavailable/i.test(t)},us=e=>{e.installGoogleBarcodeScannerModule?.().catch(()=>void 0)},ds=e=>{let t=e.trim();if(!t)return null;if(/^yuri:\/\//i.test(t)){let e=Ba(t);return e?{pairing:e}:null}return/^https?:\/\//i.test(t)?{url:t}:null},fs=e=>{let t=ds(e);return t?`pairing`in t?{status:`pairing`,...t}:{status:`ok`,...t}:{status:`invalid`}},ps=e=>{typeof document>`u`||document.documentElement.classList.toggle(ns,e)},ms=e=>{try{e()}catch{}},hs=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))}},gs=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))};ps(!0);let c=hs(()=>s({status:`cancelled`}));try{let{App:e}=await he(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(fs(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=>{ss(e)?s({status:`permission-denied`}):s({status:`failed`})}),await o}finally{ps(!1),ms(c),ms(()=>r?.()),await Promise.allSettled([Promise.resolve(t?.remove()),Promise.resolve(n?.remove()),e.stopScan()])}},_s=e=>e.isNativePlatform&&e.isPluginAvailable,vs=()=>_s({isNativePlatform:J.isNativePlatform(),isPluginAvailable:J.isPluginAvailable(`BarcodeScanner`)}),ys=async()=>{let e=rs();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?fs(n):{status:`cancelled`}}catch(t){return os(t)?{status:`cancelled`}:ss(t)?{status:`permission-denied`}:is()&&cs(t)&&e.startScan?(ls(t)&&us(e),gs(e)):{status:`failed`}}return is()&&e.startScan?gs(e):{status:`unsupported`}}catch{return{status:`failed`}}},bs={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},xs=({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}=Te(),[p,m]=Z.useState(``),[h,g]=Z.useState(null),[_,v]=Z.useState(!1),y=o??p,b=Z.useId(),x=e=>{g(null),m(e),s?.(e)},S=q(async()=>{if(!(e||t||_)){v(!0);try{let e=await navigator.clipboard.readText();x(e);let t=ds(e);e.trim()&&(!t||!(`pairing`in t))&&d()}catch{g(f(`mobile.connect.link.pasteFallback`))}finally{v(!1)}}}),C=q(n=>{if(n.preventDefault(),e||t||_)return;let r=ds(y);if(!r||!(`pairing`in r)){d();return}u(r.pairing)});return(0,$.jsxs)(`form`,{className:`flex w-full flex-col gap-3`,onSubmit:C,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Kn,{...bs,value:y,onChange:e=>x(e.target.value),placeholder:f(`mobile.connect.link.placeholder`),"aria-label":f(`mobile.connect.link.label`),inputMode:`url`,autoCapitalize:`none`,tabIndex:n,disabled:e||t||_,"aria-invalid":!!l,"aria-describedby":l||h?b:void 0,className:r}),c?(0,$.jsx)(Y,{variant:`outline`,size:`icon`,onClick:()=>void S(),disabled:e||t||_,"aria-label":f(`mobile.connect.link.paste`),children:(0,$.jsx)(X,{name:`clipboard`,className:`size-5`})}):null]}),l||h?(0,$.jsx)(`p`,{id:b,role:`alert`,className:`typography-small text-[var(--status-error)]`,children:l||h}):null,(0,$.jsx)(Y,{type:`submit`,variant:i,size:`lg`,className:a,disabled:e||t||_||!y.trim(),children:f(t?`mobile.connect.connecting`:`mobile.connect.connectButton`)})]})};function Ss({connection:e}){let{t}=Te(),{connections:n,isBusy:r,error:i,pendingConnection:a}=e,o=Z.useMemo(()=>vs(),[]),[s,c]=Z.useState(null),[l,u]=Z.useState(!1),[d,f]=Z.useState(null),[p,m]=Z.useState(!1),[h,_]=Z.useState(null),[v,y]=Z.useState(null),[b,x]=Z.useState(``),[S,C]=Z.useState(``),[w,T]=Z.useState(``),E=n[0],D=n.find(e=>e.id===v),O=r||p,k=s!==null||a!==null,A=t=>{e.setError(null),c(t)},j=()=>{e.setError(null),c(null),u(!0)},M=q(()=>{O||(a?(e.cancelPassword(),C(``)):A(null))}),N=q(async t=>{O||(_(t.id),C(``),await e.connect({id:t.id,candidates:t.candidates,label:t.label}))}),P=q(async()=>{if(!O){_(null),m(!0),e.setError(null);try{let n=await ys();n.status===`ok`?await e.connect({url:n.url,label:n.label,clientToken:n.clientToken}):n.status===`pairing`?await e.redeemPairingConnection(n.pairing):n.status===`permission-denied`?e.setError(t(`mobile.connect.scan.permissionDenied`)):n.status===`invalid`?e.setError(t(`mobile.connect.scan.invalid`)):n.status===`unsupported`?e.setError(t(`mobile.connect.scan.unsupported`)):n.status===`failed`&&e.setError(t(`mobile.connect.scan.failed`))}catch{e.setError(t(`mobile.connect.scan.failed`))}finally{m(!1)}}}),F=q(()=>d?(f(null),!0):k?(M(),!0):l?(u(!1),!0):!1);Z.useEffect(()=>{if(!g())return;let e=!1,t;return he(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])).then(async({App:n})=>{let r=await n.addListener(`backButton`,()=>{F()||n.minimizeApp().catch(()=>void 0)});e?r.remove():t=()=>{r.remove()}}).catch(()=>void 0),()=>{e=!0,t?.()}},[F]);let I=e=>h===e.id&&r&&!a&&s!==`rename`&&s!==`remove`?t(`mobile.connect.connecting`):e.id===E?.id&&e.lastUsedAt>0?t(`mobile.connect.history.lastUsed`):t(`mobile.instances.status.saved`),L=e=>(0,$.jsxs)(Y,{size:`lg`,variant:e?`default`:`ghost`,className:e?`yuri-welcome-primary w-full`:`w-full`,disabled:O,onClick:()=>void P(),children:[(0,$.jsx)(X,{name:p?`loader-4`:`scan-2`,className:p?`size-5 animate-spin motion-reduce:animate-none`:`size-5`}),t(`mobile.connect.scanQr`)]}),R=t(a?a.reason===`pairing`?`mobile.connect.pairing.expired`:`mobile.connect.password.label`:s===`rename`?`mobile.connect.history.rename`:s===`remove`?`mobile.connect.history.remove`:`mobile.connect.welcome.moreOptions`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`main`,{className:`yuri-keyboard-fill-screen yuri-mobile-welcome`,inert:k||l,"aria-hidden":k||l||void 0,"data-welcome-paused":k||l||p?`true`:void 0,children:[(0,$.jsx)(`header`,{className:`yuri-welcome-brand`,children:(0,$.jsx)(Ia,{className:`block`,width:88})}),(0,$.jsxs)(`div`,{className:`yuri-welcome-content`,children:[(0,$.jsxs)(`div`,{className:`yuri-welcome-intro`,children:[(0,$.jsxs)(`div`,{className:`yuri-welcome-art`,"aria-hidden":`true`,children:[(0,$.jsx)(`span`,{className:`yuri-image-loading yuri-welcome-dots`}),(0,$.jsx)(`div`,{className:`yuri-welcome-logo`,children:(0,$.jsx)(or,{width:144,height:144,className:`size-full`})})]}),(0,$.jsxs)(`div`,{className:`yuri-welcome-copy`,children:[(0,$.jsx)(`h1`,{children:t(E?`mobile.connect.history.welcomeBack`:`mobile.connect.welcome.heading`)}),(0,$.jsx)(`p`,{children:t(`mobile.connect.welcome.pairingHint`)})]})]}),(0,$.jsxs)(`div`,{className:`yuri-welcome-actions flex w-full flex-col gap-3`,children:[E?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Y,{variant:`outline`,className:`yuri-welcome-device`,disabled:O,onClick:j,children:[(0,$.jsx)(X,{name:`computer`,className:`size-7`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 text-left`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label`,children:E.label}),(0,$.jsx)(`span`,{className:`block typography-small font-normal text-muted-foreground`,children:I(E)})]}),(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-5 text-muted-foreground`})]}),(0,$.jsx)(Y,{size:`lg`,className:`yuri-welcome-primary w-full`,disabled:O,onClick:()=>void N(E),children:r&&h===E.id?t(`mobile.connect.connecting`):i&&h===E.id?t(`desktopHostSwitcher.actions.retry`):t(`mobile.connect.history.continue`)})]}):null,o?L(!E):E?null:(0,$.jsx)(Y,{size:`lg`,className:`yuri-welcome-primary w-full`,disabled:O,onClick:()=>A(`more`),children:t(`mobile.connect.link.useLink`)}),i&&!k&&!l?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,(0,$.jsx)(Y,{variant:`ghost`,size:`lg`,disabled:O,className:`mx-auto text-muted-foreground`,onClick:()=>A(`more`),children:t(`mobile.connect.welcome.moreOptions`)})]})]})]}),(0,$.jsxs)(yr,{id:`welcome-history`,open:l,onOpenChange:u,presentation:`page`,edge:`right`,dismissGesture:!0,ariaLabel:t(`mobile.connect.history.title`),children:[(0,$.jsx)(ze,{title:t(`mobile.connect.history.title`),backAriaLabel:t(`header.actions.backAria`),onBack:()=>u(!1)}),(0,$.jsxs)(qr,{outerClassName:`flex-1`,className:`px-6 py-6`,disableHorizontal:!0,children:[(0,$.jsx)(`h1`,{className:`typography-h1 mb-3`,children:t(`mobile.connect.history.title`)}),(0,$.jsx)(`p`,{className:`mb-6 typography-ui-label font-normal text-muted-foreground`,children:t(n.length?`mobile.connect.history.description`:`mobile.connect.saved.empty`)}),n.map(e=>(0,$.jsx)(`div`,{className:`border-b border-border/60 py-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(Y,{variant:`ghost`,className:`yuri-welcome-history-row min-w-0 flex-1`,disabled:O,onClick:()=>void N(e),children:[(0,$.jsx)(X,{name:r&&h===e.id&&!k?`loader-4`:`computer`,className:r&&h===e.id&&!k?`size-7 animate-spin motion-reduce:animate-none`:`size-7`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 text-left`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label`,children:e.label}),(0,$.jsx)(`span`,{className:`block typography-small font-normal text-muted-foreground`,children:I(e)})]})]}),i&&h===e.id&&!k&&!r?(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,disabled:O,"aria-label":t(`desktopHostSwitcher.actions.retry`),onClick:()=>void N(e),children:(0,$.jsx)(X,{name:`error-warning-fill`,className:`size-5 text-[var(--status-error)]`})}):null,(0,$.jsxs)(Qn,{open:d===e.id,onOpenChange:t=>f(t?e.id:null),children:[(0,$.jsx)(nr,{asChild:!0,children:(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,disabled:O,"aria-label":t(`mobile.connect.history.actions`,{name:e.label}),children:(0,$.jsx)(X,{name:`more`,className:`size-5`})})}),(0,$.jsxs)($n,{align:`end`,children:[(0,$.jsxs)(ar,{onSelect:()=>{y(e.id),x(e.label),A(`rename`)},children:[(0,$.jsx)(X,{name:`edit`,className:`size-4`}),t(`mobile.connect.history.rename`)]}),(0,$.jsxs)(ar,{onSelect:()=>{y(e.id),A(`remove`)},className:`text-[var(--status-error)]`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-4 text-inherit`}),t(`mobile.connect.history.remove`)]})]})]})]})},e.id)),i&&!h&&!k?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null]}),(0,$.jsxs)(`div`,{className:`yuri-welcome-history-footer`,children:[(0,$.jsx)(or,{width:36,height:36,className:`mx-auto mb-5 opacity-40`}),o?L(!1):null,(0,$.jsx)(Y,{variant:`ghost`,size:`lg`,className:`w-full`,disabled:O,onClick:()=>A(`more`),children:t(`mobile.connect.link.useLink`)})]})]}),(0,$.jsx)(br,{id:`welcome-options`,open:k,onOpenChange:e=>{e||M()},fitContent:!0,title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:R}),ariaLabel:R,closeAriaLabel:t(`mobile.surface.closeAria`),resizeAriaLabel:t(`mobile.connect.options.resize`),children:(0,$.jsx)(qr,{className:`px-5 py-5`,disableHorizontal:!0,fillContainer:!1,children:a?.reason===`pairing`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(X,{name:`computer`,className:`size-6 shrink-0 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`min-w-0 flex-1 truncate typography-ui-label`,children:a.label}),n.some(e=>e.id===a.id)?(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,disabled:O,"aria-label":t(`mobile.instances.deleteAria`,{label:a.label}),onClick:()=>{y(a.id),e.cancelPassword(),A(`remove`)},children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-5`})}):null]}),(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.pairing.reconnectHint`)}),i?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,o?L(!0):null,(0,$.jsx)(Y,{variant:o?`ghost`:`default`,size:`lg`,disabled:O,onClick:()=>{e.cancelPassword(),A(`more`)},children:t(`mobile.connect.link.useLink`)})]}):a?(0,$.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),r||e.submitPassword(S)},children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label`,children:a.label}),(0,$.jsx)(Kn,{type:`password`,autoComplete:`current-password`,value:S,onChange:e=>C(e.target.value),"aria-label":t(`mobile.connect.password.label`),placeholder:t(`mobile.connect.password.placeholder`),disabled:r}),i?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,(0,$.jsx)(Y,{type:`submit`,size:`lg`,className:`yuri-welcome-primary w-full`,disabled:r||!S.trim(),children:t(r?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(Y,{variant:`ghost`,disabled:r,onClick:M,children:t(`mobile.connect.cancelPassword`)})]}):s===`rename`&&D?(0,$.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e.renameConnection(D.id,b).then(e=>{e&&c(null)})},children:[(0,$.jsx)(Kn,{value:b,onChange:e=>x(e.target.value),disabled:r,"aria-label":t(`mobile.instances.label.label`),autoComplete:`off`,maxLength:120}),i?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,(0,$.jsx)(Y,{type:`submit`,size:`lg`,disabled:r||!b.trim(),children:t(`mobile.instances.saveEdit`)})]}):s===`remove`&&D?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-normal`,children:t(`mobile.connect.history.removeHint`,{name:D.label})}),i?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:i}):null,(0,$.jsx)(Y,{variant:`destructive`,size:`lg`,disabled:r,onClick:()=>{e.removeConnection(D.id).then(e=>{e&&(c(null),_(null))})},children:t(`mobile.connect.history.remove`)}),(0,$.jsx)(Y,{variant:`ghost`,disabled:r,onClick:M,children:t(`mobile.instances.cancelEdit`)})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`typography-ui-header mb-2`,children:t(`mobile.connect.link.useLink`)}),(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.link.help`)})]}),(0,$.jsx)(xs,{value:w,onValueChange:t=>{T(t),e.setError(null)},showPasteButton:!0,inputClassName:`min-w-0 flex-1 text-[16px]`,buttonClassName:`yuri-welcome-primary w-full`,buttonVariant:`default`,disabled:O,isBusy:r,error:i,onInvalid:()=>e.setError(t(`mobile.connect.link.invalid`)),onRedeem:t=>{_(null),e.redeemPairingConnection(t)}}),(0,$.jsxs)(Y,{variant:`outline`,className:`yuri-welcome-history-row`,disabled:O,onClick:j,children:[(0,$.jsx)(X,{name:`history`,className:`size-6`}),(0,$.jsx)(`span`,{className:`flex-1 text-left`,children:t(`mobile.connect.history.title`)}),(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-5`})]}),(0,$.jsx)(`p`,{className:`typography-small leading-relaxed text-muted-foreground`,children:t(`mobile.connect.welcome.scanHint`)})]})})})]})}function Cs(e){let t=(0,Q.c)(17),{children:n}=e,r=ge(Es),i=ge(Ts),a=Z.useRef(null),o=Z.useRef(null),s;t[0]===i?s=t[1]:(s=()=>i(!1),t[0]=i,t[1]=s);let c;t[2]!==r||t[3]!==s?(c={id:`mobile-global-search`,active:r,onBack:s,surfaceRef:a,underlayRef:o},t[2]=r,t[3]=s,t[4]=c):c=t[4],Fr(c);let l,u;t[5]===r?(l=t[6],u=t[7]):(l=()=>{if(!r)return;let e=document.activeElement,t=An(`global-search-page`);return()=>{t(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},u=[r],t[5]=r,t[6]=l,t[7]=u),Z.useLayoutEffect(l,u);let d=r||void 0,f=r||void 0,p;t[8]!==n||t[9]!==d||t[10]!==f?(p=(0,$.jsx)(`div`,{ref:o,inert:d,"aria-hidden":f,className:`h-full min-h-0 w-full`,children:n}),t[8]=n,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===r?m=t[13]:(m=r?(0,$.jsx)(`div`,{ref:a,"data-mobile-search-page":`true`,className:`absolute inset-0 z-50 flex min-h-0 flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(Fa,{presentation:`page`,onBack:ws})}):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 ws(){Rr.requestAnimatedBack(`root`)}function Ts(e){return e.setCommandPaletteOpen}function Es(e){return e.isCommandPaletteOpen}async function Ds(e,t,n,i){if(i){let r=await Ja(i,e,n);if(!_e(e))return r;if(!t)throw Error(`unsupported_host`);let a=new URL(r.src,`http://runtime.invalid`);return{...r,src:`${t}${a.pathname}${a.search}${a.hash}`}}let a=d(),o=()=>{if(n.aborted||a!==d())throw new DOMException(`Preview ended`,`AbortError`)};o();let s=new URL(e);if(![`http:`,`https:`].includes(s.protocol)||s.username||s.password)throw Error(`invalid_url`);if(!_e(e))return{src:s.href};if(!t)throw Error(`unsupported_host`);let l=await m(`/api/preview/targets`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:s.href}),signal:n});if(!l.ok)throw Error(`preview_unavailable`);let u=await l.json();if(o(),typeof u.proxyBasePath!=`string`||!/^\/api\/preview\/proxy\/[a-f0-9]{16,64}$/i.test(u.proxyBasePath)||!qa(`${u.proxyBasePath}${s.pathname}`)||typeof u.previewToken!=`string`||!u.previewToken||typeof u.expiresAt!=`number`||!Number.isFinite(u.expiresAt)||u.expiresAt<=Date.now())throw Error(`invalid_preview`);await r(),o();let f=new URLSearchParams(s.search);f.delete(`yuri_client_token`),f.delete(`yuri_url_token`),f.set(`yuri_preview_token`,u.previewToken);let p=`${u.proxyBasePath}${s.pathname}?${f}${s.hash}`,h=new URL(c().authenticatedAsset(p),`http://runtime.invalid`);return{src:`${t}${h.pathname}${h.search}${h.hash}`,expiresAt:u.expiresAt}}function Os({url:e,hostOrigin:t,entry:n}){let{t:r}=Te(),i=Z.useRef(null),[s,c]=Z.useReducer(e=>e+1,0),l=n?JSON.stringify(n.queryScope):`local`,[u,d]=Z.useState();Z.useEffect(()=>{let r=new AbortController,i,c=0,u=async()=>{let a=++c;clearTimeout(i);try{let o=await Ds(e,t,r.signal,n);if(r.signal.aborted||a!==c)return;d({url:e,hostOrigin:t,scope:l,attempt:s,src:o.src}),o.expiresAt&&(i=setTimeout(()=>{u()},Math.max(1e3,o.expiresAt-Date.now()-1e4)))}catch{!r.signal.aborted&&a===c&&d({url:e,hostOrigin:t,scope:l,attempt:s,error:!0})}},f=_e(e),p=f?a():void 0,m=f?o(()=>{u()}):void 0;return u(),()=>{r.abort(),clearTimeout(i),m?.(),p?.()}},[e,t,s,n,l]);let f=u?.url===e&&u.hostOrigin===t&&u.scope===l&&u.attempt===s?u:void 0;return K(`message`,t=>{if(!f?.src||!_e(e)||t.source!==i.current?.contentWindow||t.origin!==new URL(f.src).origin)return;let r=t.data;r?.source===`yuri-preview-bridge`&&r.version===1&&r.type===`navigate-preview`&&typeof r.url==`string`&&be.getState().open(r.url,n?.location)}),f?.error?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3`,children:[(0,$.jsx)(Ga,{message:r(`contextPanel.preview.proxyError`)}),(0,$.jsx)(Y,{size:`sm`,onClick:c,children:r(`contextPanel.preview.actions.retry`)})]}):f?.src?(0,$.jsx)(`iframe`,{ref:i,src:f.src,title:r(`contextPanel.preview.iframeTitle`),onError:()=>d({url:e,hostOrigin:t,scope:l,attempt:s,error:!0}),className:`h-full w-full border-0`,sandbox:`allow-scripts allow-same-origin allow-forms`}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:r(`contextPanel.preview.loading`)})}function ks(e){let t=(0,Q.c)(10),{location:n,url:r,hostOrigin:i}=e,{t:a}=Te(),o=Xt(!0);if(!o.registry||o.registry.hubId!==n.hubId){let e;return t[0]!==o.error||t[1]!==a?(e=o.error?(0,$.jsx)(Ga,{message:o.error.message}):(0,$.jsx)(`div`,{className:`text-muted-foreground`,children:a(`contextPanel.preview.loading`)}),t[0]=o.error,t[1]=a,t[2]=e):e=t[2],e}let s;t[3]!==n||t[4]!==o.registry?(s=o.registry.resolve(n),t[3]=n,t[4]=o.registry,t[5]=s):s=t[5];let c;return t[6]!==i||t[7]!==s||t[8]!==r?(c=(0,$.jsx)(Os,{url:r,hostOrigin:i,entry:s}),t[6]=i,t[7]=s,t[8]=r,t[9]=c):c=t[9],c}function As(){let e=(0,Q.c)(17),{t}=Te(),n=be(Ms),r=W(),i=Z.useSyncExternalStore(s,d,d),a=n?.generation===i?n:null,o=!!a,c;e[0]===t?c=e[1]:(c=t(`contextPanel.preview.iframeTitle`),e[0]=t,e[1]=c);let l;e[2]===t?l=e[3]:(l=t(`guiPlugins.close`),e[2]=t,e[3]=l);let u;e[4]===t?u=e[5]:(u=t(`guiPlugins.resize`),e[4]=t,e[5]=u);let f=a?.url??``,p;e[6]!==a||e[7]!==i||e[8]!==r?(p=a?(0,$.jsx)(Ka,{children:e=>a.location?.hostId?r?.entry.location.hubId===a.location.hubId&&r.entry.location.hostId===a.location.hostId&&r.entry.location.directory===a.location.directory?(0,$.jsx)(Os,{url:a.url,hostOrigin:e?.hostOrigin,entry:r.entry}):(0,$.jsx)(ks,{location:a.location,url:a.url,hostOrigin:e?.hostOrigin}):(0,$.jsx)(Os,{url:a.url,hostOrigin:e?.hostOrigin})},i):null,e[6]=a,e[7]=i,e[8]=r,e[9]=p):p=e[9];let m;return e[10]!==o||e[11]!==c||e[12]!==l||e[13]!==u||e[14]!==f||e[15]!==p?(m=(0,$.jsx)(br,{id:`mobile-html-preview`,open:o,ariaLabel:c,closeAriaLabel:l,resizeAriaLabel:u,initiallyExpanded:!0,title:f,onOpenChange:js,children:p}),e[10]=o,e[11]=c,e[12]=l,e[13]=u,e[14]=f,e[15]=p,e[16]=m):m=e[16],m}function js(e){e||be.getState().close()}function Ms(e){return e.target}function Ns(){let e=Ue(e=>e.projects.find(t=>t.id===e.activeProjectId)),t=st(e=>e.remoteSession),n=!!e?.hostId,r=qt(),i=Xt(n&&r),a=r&&i.catalog?.supported!==!1,o=Z.useMemo(()=>e?.hubId&&e.hostId?{supported:!0,hubId:e.hubId,projects:[],hosts:[{id:e.hostId,name:e.hostId,source:`direct`,state:`offline`}]}:void 0,[e?.hubId,e?.hostId]),s=n&&a?i.registry??(o?Yt(o):void 0):void 0,c=e?.hostId,l=Z.useMemo(()=>e=>s&&c?s.subscribeHost(c,e):()=>{},[s,c]),u=Z.useMemo(()=>()=>s&&c?s.getHost(c):void 0,[s,c]),d=Z.useSyncExternalStore(l,u,u),f=t?.projectId===e?.id&&t?.location.hostId===c&&t?.location.hubId===(e?.hubId??s?.hubId),p=Z.useMemo(()=>s&&c&&e&&(!e.hubId||s.hubId===e.hubId)?{hubId:s.hubId,hostId:c,directory:f&&t?t.location.directory:e.path}:void 0,[s,c,e,f,t]),m=p&&s?s.resolve(p):void 0,[h,g]=Z.useState();Z.useEffect(()=>{if(!s||!m)return;let e=xt(s,m),t=e.retain();return g({entry:m,owner:e}),t},[s,m]);let _=h?.entry===m?h?.owner:void 0,y=f?t?.sessionId??null:null,b=Z.useMemo(()=>e=>_?_.state.subscribeSnapshot(e):()=>{},[_]),x=Z.useMemo(()=>()=>_&&y?_.state.getSnapshot(y).session:void 0,[_,y]),S=Z.useSyncExternalStore(b,x,x),C=Zt(s,c,n&&a);return{enabled:n,supported:a,project:e,registry:s,entry:m,owner:_,sessionId:y,session:S??C.data?.directories.find(e=>e.directory===p?.directory)?.sessions.find(e=>e.id===y),host:d,openSession:q(t=>{if(!e?.hostId||!p)throw Error(`Remote Host scope unavailable`);st.getState().openRemoteSession(e,p,t)}),refresh:q(async()=>{if(!_||!y)throw Error(`Remote session unavailable`);await _.state.repository.refreshFromAuthority(_.state.scope(y))}),key:p?v(p):e?.id??``,error:i.error}}var Ps=e=>{let t=(0,Q.c)(20),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({children:n,className:r,contentClassName:i,style:o,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=it(`yuri-mobile-header relative z-30 shrink-0 border-b border-border/30 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80`,r),t[6]=r,t[7]=s);let c;t[8]===o?c=t[9]:(c={paddingTop:`var(--yuri-safe-area-top, 0px)`,...o},t[8]=o,t[9]=c);let l;t[10]===i?l=t[11]:(l=it(`flex h-[var(--yuri-header-height,56px)] w-full items-center gap-1 px-2`,i),t[10]=i,t[11]=l);let u;t[12]!==n||t[13]!==l?(u=(0,$.jsx)(`div`,{className:l,children:n}),t[12]=n,t[13]=l,t[14]=u):u=t[14];let d;return t[15]!==a||t[16]!==s||t[17]!==c||t[18]!==u?(d=(0,$.jsx)(`header`,{className:s,style:c,...a,children:u}),t[15]=a,t[16]=s,t[17]=c,t[18]=u,t[19]=d):d=t[19],d};function Fs(e){let t=(0,Q.c)(30),{percentage:n,pending:r}=e,i=r!==void 0&&r,{t:a}=Te(),o,s,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==n||t[2]!==a){c=i?0:Zn(n)??0;let e=er(n);s=i?`var(--surface-muted-foreground)`:e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,o=2*Math.PI*7.5,l=`0 0 18 18`,u=`size-[18px] -rotate-90`,d=`progressbar`,t[12]===a?f=t[13]:(f=a(`contextUsage.aria.label`),t[12]=a,t[13]=f),t[14]!==i||t[15]!==a?(p=i?a(`contextUsage.pending`):void 0,t[14]=i,t[15]=a,t[16]=p):p=t[16],m=i?void 0:Math.round(c),t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m}else o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11];let h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[17]=h):h=t[17];let g=o*(1-c/100),_;t[18]!==o||t[19]!==s||t[20]!==g?(_=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:s,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:o,strokeDashoffset:g,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[18]=o,t[19]=s,t[20]=g,t[21]=_):_=t[21];let v;return t[22]!==_||t[23]!==l||t[24]!==u||t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m?(v=(0,$.jsxs)(`svg`,{viewBox:l,className:u,role:d,"aria-label":f,"aria-valuetext":p,"aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:[h,_]}),t[22]=_,t[23]=l,t[24]=u,t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=v):v=t[29],v}var Is=(e,t,n)=>H({queryKey:[...e.queryScope,`mobile-session-metadata`,t],staleTime:3e4,gcTime:1/0,retry:!1,queryFn:({signal:e})=>n(e)});function Ls(e){let t=G(e);return Is(e,`git`,async n=>{let r={signal:n,query:{directory:e.location.directory},headers:{"x-opencode-directory":e.location.directory}};return(await t.json(`/api/git/check`,r)).isGitRepository?{isGitRepository:!0,current:(await t.json(`/api/git/status`,{...r,query:{...r.query,mode:`light`}})).current}:{isGitRepository:!1,current:null}})}function Rs(e){let t=G(e);return Is(e,`quota-settings`,async e=>{let n=await t.json(`/api/config/settings`,{signal:e}),r=ri.map(e=>e.id),i=Array.isArray(n.usageDropdownProviders)?n.usageDropdownProviders.filter(e=>typeof e==`string`&&(e.startsWith(`magpie:`)||r.includes(e))):r,a={};if(n.usageSelectedModels&&typeof n.usageSelectedModels==`object`)for(let[e,t]of Object.entries(n.usageSelectedModels))Array.isArray(t)&&(a[e]=t.filter(e=>typeof e==`string`));return{providerIds:i,selectedModels:a,displayMode:n.usageDisplayMode===`remaining`?`remaining`:`usage`,autoRefresh:n.usageAutoRefresh===!0,refreshIntervalMs:typeof n.usageRefreshIntervalMs==`number`&&Number.isFinite(n.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(n.usageRefreshIntervalMs))):6e4}})}function zs(e,t){let n=G(e);return Is(e,`quota:${t}`,async e=>{let r=await n.json(`/api/quota/${encodeURIComponent(t)}`,{signal:e});if(!ie(r)||r.providerId!==t)throw Error(`Invalid quota response`);return r})}function Bs(e){let t=G(e);return Is(e,`magpie`,async n=>{let r=await t.json(`/api/quota/magpie`,{signal:n,query:{directory:e.location.directory}});if(!Array.isArray(r.sources)||!r.sources.every(e=>e&&typeof e.id==`string`&&Array.isArray(e.results)&&e.results.every(t=>ie(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return r.sources.flatMap(e=>e.results)})}var Vs=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},Hs=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),Us=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,Ws=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:`${Hs(t)}/${Hs(n)}`,colorClass:Us(i)}},Gs=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},Ks=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``);function qs(e,t,n){let r=(0,Q.c)(7),{t:i}=Te(),a;if(r[0]!==t||r[1]!==e||r[2]!==n||r[3]!==i){let o=new Map(e.map(Js)),s;r[5]===t?s=r[6]:(s=e=>t.includes(e.id),r[5]=t,r[6]=s),a=ui(e).filter(s).filter(e=>o.get(e.id)?.configured===!0).map(e=>{let t=o.get(e.id),r=[];for(let[e,n]of ki(Object.entries(t?.usage?.windows??{}),t?.usage?.accounts))r.push({key:`window-${e}`,label:Yn(n.label??e),window:n});let a=Object.entries(t?.usage?.models??{}),s=n[e.id]??[];for(let[e,t]of s.length>0?a.filter(e=>{let[t]=e;return s.includes(t)}):a){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:Yn(a.label??i),subtitle:oi(e),window:a})}return{providerId:e.id,providerName:e.name,rows:r,status:!t.ok&&t.error?t.error:r.length===0?i(`header.services.noRateLimitsReported`):null}}),r[0]=t,r[1]=e,r[2]=n,r[3]=i,r[4]=a}else a=r[4];return a}function Js(e){return[e?.providerId,e]}var Ys=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`},Xs=e=>{let t=(0,Q.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,$.jsx)(X,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},Zs=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=Te(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Or,{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=Ti(e.rows.map(Cc),n),o=r===`remaining`?t.window.remainingPercent:t.window.usedPercent,s=tr(t.window.valueLabel,o),c=Xn(t.window.resetAt,t.window.resetAfterFormatted??t.window.resetAtFormatted,a);return(0,$.jsxs)(Z.Fragment,{children:[i?(0,$.jsx)(`div`,{className:it(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-3 border-t border-[var(--surface-subtle)] pt-2`),children:i}):null,(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:t.subtitle?`${t.subtitle} · ${t.label}`:t.label}),c?(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-micro text-muted-foreground/70`,children:c}):null]}),(0,$.jsx)(`span`,{className:it(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,Ys(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},Qs=e=>{let t=(0,Q.c)(52),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l,error:u,onRetry:d}=e,{t:f}=Te(),p=Z.useRef(null),[m,h]=Z.useState(n),[g,_]=Z.useState(!1),v,y;t[0]!==n||t[1]!==m?(v=()=>{if(n){h(!0),_(!1);return}if(!m)return;_(!0);let e=window.setTimeout(()=>{h(!1),_(!1)},140);return()=>window.clearTimeout(e)},y=[n,m],t[0]=n,t[1]=m,t[2]=v,t[3]=y):(v=t[2],y=t[3]),Z.useEffect(v,y);let b,x;if(t[4]!==r||t[5]!==n?(b=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},x=[r,n],t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),Z.useEffect(b,x),!m)return null;let S;t[8]===f?S=t[9]:(S=f(`mobile.surface.closeAria`),t[8]=f,t[9]=S);let C;t[10]===r?C=t[11]:(C=e=>{e.preventDefault(),r()},t[10]=r,t[11]=C);let w;t[12]!==S||t[13]!==C?(w=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":S,onPointerDown:C}),t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;t[15]===f?T=t[16]:(T=f(`mobile.header.openMetadataAria`),t[15]=f,t[16]=T);let E=g&&`pointer-events-none`,D;t[17]===E?D=t[18]:(D=it(`pointer-events-auto absolute inset-x-3 top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.5rem)] overflow-x-hidden overflow-y-auto overscroll-contain rounded-[20px] yuri-mobile-overlay-surface yuri-mobile-overlay-surface--translucent p-2 will-change-transform`,E),t[17]=E,t[18]=D);let O=`${g?`session-metadata-out`:`session-metadata-in`} ${g?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,k;t[19]===O?k=t[20]:(k={animation:O,maxHeight:`min(72dvh, calc(100dvh - var(--yuri-safe-area-top, 0px) - var(--yuri-mobile-detail-navigation-height, 3.5rem) - 1rem))`},t[19]=O,t[20]=k);let A;t[21]===f?A=t[22]:(A=f(`mobile.header.metadata.branch`),t[21]=f,t[22]=A);let j;t[23]!==a||t[24]!==A?(j=(0,$.jsx)(Xs,{iconName:`git-branch`,label:A,children:a}),t[23]=a,t[24]=A,t[25]=j):j=t[25];let M;t[26]!==i||t[27]!==f?(M=i?(0,$.jsx)(Xs,{iconNode:(0,$.jsx)(Fs,{percentage:i.percentage,pending:i.pending}),label:f(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsx)(`span`,{className:it(`font-semibold`,i.colorClass),children:i.pending?f(`contextUsage.pending`):`${i.percentage.toFixed(1)}%`}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:i.tokens})]})}):null,t[26]=i,t[27]=f,t[28]=M):M=t[28];let N;t[29]!==c||t[30]!==l||t[31]!==s||t[32]!==o?(N=(0,$.jsx)(Zs,{groups:o,displayMode:s,isLoading:c,timeFormatPreference:l}),t[29]=c,t[30]=l,t[31]=s,t[32]=o,t[33]=N):N=t[33];let P;t[34]!==u||t[35]!==d||t[36]!==f?(P=u?(0,$.jsxs)(`div`,{role:`alert`,className:`px-2.5 py-2 typography-ui-label text-[var(--status-error)]`,children:[u,(0,$.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:d,children:f(`contextPanel.preview.actions.retry`)})]}):null,t[34]=u,t[35]=d,t[36]=f,t[37]=P):P=t[37];let F;t[38]!==j||t[39]!==M||t[40]!==N||t[41]!==P?(F=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[j,M,N,P]}),t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=F):F=t[42];let I;t[43]!==D||t[44]!==k||t[45]!==F||t[46]!==T?(I=(0,$.jsx)(`div`,{ref:p,role:`dialog`,"aria-label":T,className:D,style:k,onPointerDown:wc,children:F}),t[43]=D,t[44]=k,t[45]=F,t[46]=T,t[47]=I):I=t[47];let L;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(`style`,{children:`
3
- @keyframes session-metadata-in {
4
- from { opacity: 0; transform: translateY(-8px) scale(0.985); }
5
- to { opacity: 1; transform: translateY(0) scale(1); }
6
- }
7
- @keyframes session-metadata-out {
8
- from { opacity: 1; transform: translateY(0) scale(1); }
9
- to { opacity: 0; transform: translateY(-6px) scale(0.985); }
10
- }
11
- `}),t[48]=L):L=t[48];let R;return t[49]!==I||t[50]!==w?(R=(0,$.jsxs)(`div`,{className:`fixed inset-0 z-40 pointer-events-none`,children:[w,I,L]}),t[49]=I,t[50]=w,t[51]=R):R=t[51],R};function $s(e){let t=(0,Q.c)(9),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r=W(),i=st(ec);if(r?.entry.location.hostId){let e=i?.location.hubId===r.entry.location.hubId&&i.location.hostId===r.entry.location.hostId&&i.location.directory===r.entry.location.directory?i.sessionId:null,a=`${r.entry.key}:${e??``}`,o=e??``,s;return t[2]!==r.entry||t[3]!==n||t[4]!==a||t[5]!==o?(s=(0,$.jsx)(Sc,{...n,sessionId:o,entry:r.entry},a),t[2]=r.entry,t[3]=n,t[4]=a,t[5]=o,t[6]=s):s=t[6],s}let a;return t[7]===n?a=t[8]:(a=(0,$.jsx)(tc,{...n}),t[7]=n,t[8]=a),a}function ec(e){return e.remoteSession}function tc(e){let t=(0,Q.c)(90),{sessionId:n,open:r,onOpenChange:i}=e,{t:a}=Te(),{git:o}=se(),[s,c]=Z.useState(!1),l=r!==void 0,u=l?r:s,d=n.length===0,f;t[0]!==l||t[1]!==i||t[2]!==u?(f=e=>{let t=typeof e==`function`?e(u):e;l||c(t),i?.(t)},t[0]=l,t[1]=i,t[2]=u,t[3]=f):f=t[3];let p=q(f),m=O(vc),h;t[4]===n?h=t[5]:(h=e=>n?e.getDirectoryForSession(n):null,t[4]=n,t[5]=h);let g=Ot(h)||m,_;t[6]===g?_=t[7]:(_=Ks(g)||null,t[6]=g,t[7]=_);let v=_,y=wt(n,g||void 0),b=Er(v),x=Tr(v),S=wr(_c),C=wr(gc),w=lt(hc),T=lt(mc),E=lt(pc),D=lt(fc),k;t[8]===n?k=t[9]:(k=e=>n?e.sessionModelSelections.get(n)??null:null,t[8]=n,t[9]=k);let A=Et(k),j=ii(dc),M=ii(uc),N=ii(lc),P=ii(cc),F=ii(sc),I=ii(oc),L=ii(ac),R=ge(ic);fi();let ee;t[10]===p?ee=t[11]:(ee=()=>{p(!1)},t[10]=p,t[11]=ee);let z;t[12]!==g||t[13]!==n?(z=[n,g],t[12]=g,t[13]=n,t[14]=z):z=t[14],Z.useEffect(ee,z);let B,V;t[15]!==S||t[16]!==o||t[17]!==v?(B=()=>{v&&S(v,o)},V=[S,o,v],t[15]=S,t[16]=o,t[17]=v,t[18]=B,t[19]=V):(B=t[18],V=t[19]),Z.useEffect(B,V);let te,H;t[20]!==C||t[21]!==o||t[22]!==v?(H=()=>{if(v)return ht.onGitRefreshHint(e=>{Ks(e.directory)===v&&C(v,o)})},te=[C,o,v],t[20]=C,t[21]=o,t[22]=v,t[23]=te,t[24]=H):(te=t[23],H=t[24]),Z.useEffect(H,te);let ne,U;t[25]===M?(ne=t[26],U=t[27]):(ne=()=>{M()},U=[M],t[25]=M,t[26]=ne,t[27]=U),Z.useEffect(ne,U);let re,W;t[28]===I?(re=t[29],W=t[30]):(re=()=>{kr(I)},W=[I],t[28]=I,t[29]=re,t[30]=W),Z.useEffect(re,W);let ie,ae;t[31]!==I||t[32]!==N||t[33]!==P||t[34]!==u||t[35]!==j?(ie=()=>{!u||P||I.some(e=>!j.some(t=>t?.providerId===e))&&N()},ae=[I,N,P,u,j],t[31]=I,t[32]=N,t[33]=P,t[34]=u,t[35]=j,t[36]=ie,t[37]=ae):(ie=t[36],ae=t[37]),Z.useEffect(ie,ae);let oe;t[38]===y?oe=t[39]:(oe=Gs(y),t[38]=y,t[39]=oe);let ce=oe,le;t[40]!==E||t[41]!==T||t[42]!==ce||t[43]!==A?(le=ce??(A?{providerID:A.providerId,modelID:A.modelId}:null)??(T&&E?{providerID:T,modelID:E}:null),t[40]=E,t[41]=T,t[42]=ce,t[43]=A,t[44]=le):le=t[44];let ue=le,G;if(t[45]!==D||t[46]!==ue||t[47]!==w){let e=(ue?w.find(e=>e.id===ue.providerID):void 0)?.models.find(e=>e.id===ue?.modelID),n;t[49]!==D||t[50]!==ue?(n=ue?D(ue.providerID,ue.modelID):void 0,t[49]=D,t[50]=ue,t[51]=n):n=t[51];let r=n;G=Vs(e?.limit,`context`)??r?.limit?.context??0,t[45]=D,t[46]=ue,t[47]=w,t[48]=G}else G=t[48];let de=G,K=Pt(n,de,0,g||void 0),fe=K?.pending?null:K?.totalTokens??0,pe;t[52]!==de||t[53]!==d||t[54]!==fe?(pe=Ws({totalTokens:fe,contextLimit:de,isDraft:d}),t[52]=de,t[53]=d,t[54]=fe,t[55]=pe):pe=t[55];let me=pe,J;t[56]!==x?.current||t[57]!==b||t[58]!==a?(J=b===!0?x?.current?.trim()||a(`gitView.branch.detachedHead`):a(`common.unavailable`),t[56]=x?.current,t[57]=b,t[58]=a,t[59]=J):J=t[59];let he=J,_e=qs(j,I,L),ve,ye;t[60]!==u||t[61]!==_e?(ve=()=>{!u||_e.length===0||kr(_e.map(rc))},ye=[u,_e],t[60]=u,t[61]=_e,t[62]=ve,t[63]=ye):(ve=t[62],ye=t[63]),Z.useEffect(ve,ye);let be;t[64]===p?be=t[65]:(be=()=>{p(nc)},t[64]=p,t[65]=be);let xe=q(be),Se;t[66]===p?Se=t[67]:(Se=()=>{p(!1)},t[66]=p,t[67]=Se);let Ce=q(Se),we;t[68]===a?we=t[69]:(we=a(`mobile.header.openMetadataAria`),t[68]=a,t[69]=we);let Ee=me?.percentage??0,De=me?.pending,Oe;t[70]!==Ee||t[71]!==De?(Oe=(0,$.jsx)(Fs,{percentage:Ee,pending:De}),t[70]=Ee,t[71]=De,t[72]=Oe):Oe=t[72];let ke;t[73]!==xe||t[74]!==u||t[75]!==we||t[76]!==Oe?(ke=(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(Y,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":we,"aria-expanded":u,onClick:xe,children:Oe})}),t[73]=xe,t[74]=u,t[75]=we,t[76]=Oe,t[77]=ke):ke=t[77];let Ae;t[78]!==he||t[79]!==me||t[80]!==Ce||t[81]!==P||t[82]!==u||t[83]!==F||t[84]!==R||t[85]!==_e?(Ae=(0,$.jsx)(Qs,{open:u,onClose:Ce,contextDisplay:me,branchLabel:he,usageGroups:_e,usageDisplayMode:F,isUsageLoading:P,timeFormatPreference:R}),t[78]=he,t[79]=me,t[80]=Ce,t[81]=P,t[82]=u,t[83]=F,t[84]=R,t[85]=_e,t[86]=Ae):Ae=t[86];let je;return t[87]!==ke||t[88]!==Ae?(je=(0,$.jsxs)($.Fragment,{children:[ke,Ae]}),t[87]=ke,t[88]=Ae,t[89]=je):je=t[89],je}function nc(e){return!e}function rc(e){return e.providerId}function ic(e){return e.timeFormatPreference}function ac(e){return e.selectedModels}function oc(e){return e.dropdownProviderIds}function sc(e){return e.displayMode}function cc(e){return e.isLoading}function lc(e){return e.fetchAllQuotas}function uc(e){return e.loadSettings}function dc(e){return e.results}function fc(e){return e.getModelMetadata}function pc(e){return e.currentModelId}function mc(e){return e.currentProviderId}function hc(e){return e.providers}function gc(e){return e.fetchStatus}function _c(e){return e.ensureStatus}function vc(e){return e.currentDirectory}var yc=[],bc={},xc=[],Sc=Z.memo(function(e){let t=(0,Q.c)(113),{entry:n,sessionId:r,open:i,onOpenChange:a}=e,{t:o}=Te(),[s,c]=Z.useState(!1),u=i??s,d;t[0]!==i||t[1]!==a?(d=e=>{i===void 0&&c(e),a?.(e)},t[0]=i,t[1]=a,t[2]=d):d=t[2];let f=q(d),p=ge(Tc),m=Z.useSyncExternalStore(I,M,M),h;t[3]===n.location?h=t[4]:(h=N(n.location),t[3]=n.location,t[4]=h);let g=h,_;t[5]!==n.location||t[6]!==g||t[7]!==r?(_=g&&r?L(n.location,r):null,t[5]=n.location,t[6]=g,t[7]=r,t[8]=_):_=t[8];let v;t[9]!==m||t[10]!==_?(v={revision:m,scope:_},t[9]=m,t[10]=_,t[11]=v):v=t[11];let y=v.scope,b;t[12]!==g||t[13]!==y?(b=e=>g&&y?g.subscribe(y,e):Ec,t[12]=g,t[13]=y,t[14]=b):b=t[14];let x=b,S;t[15]!==g||t[16]!==y?(S=()=>g&&y?g.getTranscript(y):null,t[15]=g,t[16]=y,t[17]=S):S=t[17];let C=S,w=Z.useSyncExternalStore(x,C,C),T;t[18]!==n.location||t[19]!==r?(T=e=>e.getSessionModelSelection(r||`remote-new-session`,n.location),t[18]=n.location,t[19]=r,t[20]=T):T=t[20];let E=Et(T),D;t[21]===n?D=t[22]:(D=et(n.location.directory,l(),n),t[21]=n,t[22]=D);let O;t[23]!==u||t[24]!==D?(O={...D,enabled:u,gcTime:1/0},t[23]=u,t[24]=D,t[25]=O):O=t[25];let k=ne(O,le),A;t[26]===n?A=t[27]:(A=Ls(n),t[26]=n,t[27]=A);let P;t[28]!==u||t[29]!==A?(P={...A,enabled:u},t[28]=u,t[29]=A,t[30]=P):P=t[30];let F=ne(P,le),R;t[31]===n?R=t[32]:(R=Rs(n),t[31]=n,t[32]=R);let z;t[33]!==u||t[34]!==R?(z={...R,enabled:u},t[33]=u,t[34]=R,t[35]=z):z=t[35];let B=ne(z,le),V=u&&B.data?.autoRefresh?B.data.refreshIntervalMs:!1;B.data?.providerIds;let H;t[36]!==n||t[37]!==u||t[38]!==V||t[39]!==B.data?.providerIds?(H=u?(B.data?.providerIds??xc).filter(Dc).map(e=>({...zs(n,e),refetchInterval:V})):[],t[36]=n,t[37]=u,t[38]=V,t[39]=B.data?.providerIds,t[40]=H):H=t[40];let U=H,re;t[41]===U?re=t[42]:(re={queries:U},t[41]=U,t[42]=re);let W=te(re,le),ie;t[43]===n?ie=t[44]:(ie=Bs(n),t[43]=n,t[44]=ie);let ae;t[45]!==u||t[46]!==B.data?.providerIds?(ae=u&&!!B.data?.providerIds.some(Oc),t[45]=u,t[46]=B.data?.providerIds,t[47]=ae):ae=t[47];let oe;t[48]!==V||t[49]!==ie||t[50]!==ae?(oe={...ie,enabled:ae,refetchInterval:V},t[48]=V,t[49]=ie,t[50]=ae,t[51]=oe):oe=t[51];let se=ne(oe,le),ce;t[52]!==se.data||t[53]!==u||t[54]!==W?(ce=u?[...W.flatMap(kc),...se.data??yc]:yc,t[52]=se.data,t[53]=u,t[54]=W,t[55]=ce):ce=t[55];let ue=ce,G=u?B.data?.providerIds??xc:xc,de=qs(ue,G,B.data?.selectedModels??bc),K;bb0:{if(!w){K=null;break bb0}for(let e=w.messageOrder.length-1;e>=0;e--){let t=w.messagesByID[w.messageOrder[e]];if(!t)continue;let n=j([t],e=>w.partsByMessageID[e]);if(n){K=n;break bb0}}K=null}let fe=K,pe=fe&&`messageId`in fe&&w?w.messagesByID[fe.messageId]:void 0,me;if(t[56]!==fe||t[57]!==pe?.modelID||t[58]!==pe?.providerID||t[59]!==k.data?.providers||t[60]!==E?.modelId||t[61]!==E?.providerId||t[62]!==r){let e=k.data?.providers.find(e=>e.id===(E?.providerId??pe?.providerID))?.models[E?.modelId??pe?.modelID??``],n=ee(fe,e?.limit?.context??0,e?.limit?.output??0);me=Ws({totalTokens:!n||n.pending?null:n.totalTokens,contextLimit:n?.contextLimit??0,isDraft:!r}),t[56]=fe,t[57]=pe?.modelID,t[58]=pe?.providerID,t[59]=k.data?.providers,t[60]=E?.modelId,t[61]=E?.providerId,t[62]=r,t[63]=me}else me=t[63];let J=me,he;t[64]!==F.error||t[65]!==se||t[66]!==k.error||t[67]!==W||t[68]!==B.error?(he=F.error??B.error??k.error??se.error??W.find(Ac)?.error,t[64]=F.error,t[65]=se,t[66]=k.error,t[67]=W,t[68]=B.error,t[69]=he):he=t[69];let _e=he,ve;t[70]===f?ve=t[71]:(ve=()=>f(!1),t[70]=f,t[71]=ve);let ye=q(ve),be;t[72]!==u||t[73]!==f?(be=()=>f(!u),t[72]=u,t[73]=f,t[74]=be):be=t[74];let xe=q(be),Se;t[75]!==F||t[76]!==se||t[77]!==k||t[78]!==W||t[79]!==B||t[80]!==G?(Se=()=>{F.refetch(),B.refetch(),k.refetch(),G.some(jc)&&se.refetch();for(let e of W)e.refetch()},t[75]=F,t[76]=se,t[77]=k,t[78]=W,t[79]=B,t[80]=G,t[81]=Se):Se=t[81];let Ce=q(Se),we;t[82]===o?we=t[83]:(we=o(`mobile.header.openMetadataAria`),t[82]=o,t[83]=we);let Ee=J?.percentage??0,De=J?.pending,Oe;t[84]!==Ee||t[85]!==De?(Oe=(0,$.jsx)(Fs,{percentage:Ee,pending:De}),t[84]=Ee,t[85]=De,t[86]=Oe):Oe=t[86];let ke;t[87]!==u||t[88]!==we||t[89]!==Oe||t[90]!==xe?(ke=(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(Y,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":we,"aria-expanded":u,onClick:xe,children:Oe})}),t[87]=u,t[88]=we,t[89]=Oe,t[90]=xe,t[91]=ke):ke=t[91];let Ae;t[92]!==F.data||t[93]!==o?(Ae=F.data?.isGitRepository?F.data.current?.trim()||o(`gitView.branch.detachedHead`):o(`common.unavailable`),t[92]=F.data,t[93]=o,t[94]=Ae):Ae=t[94];let je=B.data?.displayMode??`usage`,Me;t[95]!==se||t[96]!==W||t[97]!==B.isFetching?(Me=B.isFetching||se.isFetching||W.some(Mc),t[95]=se,t[96]=W,t[97]=B.isFetching,t[98]=Me):Me=t[98];let Ne=_e?.message,Pe;t[99]!==ye||t[100]!==J||t[101]!==de||t[102]!==u||t[103]!==Ce||t[104]!==Ae||t[105]!==je||t[106]!==Me||t[107]!==Ne||t[108]!==p?(Pe=(0,$.jsx)(Qs,{open:u,onClose:ye,contextDisplay:J,branchLabel:Ae,usageGroups:de,usageDisplayMode:je,isUsageLoading:Me,timeFormatPreference:p,error:Ne,onRetry:Ce}),t[99]=ye,t[100]=J,t[101]=de,t[102]=u,t[103]=Ce,t[104]=Ae,t[105]=je,t[106]=Me,t[107]=Ne,t[108]=p,t[109]=Pe):Pe=t[109];let Fe;return t[110]!==ke||t[111]!==Pe?(Fe=(0,$.jsxs)($.Fragment,{children:[ke,Pe]}),t[110]=ke,t[111]=Pe,t[112]=Fe):Fe=t[112],Fe});function Cc(e){return e.window}function wc(e){e.stopPropagation()}function Tc(e){return e.timeFormatPreference}function Ec(){}function Dc(e){return!e.startsWith(`magpie:`)}function Oc(e){return e.startsWith(`magpie:`)}function kc(e){return e.data?[e.data]:yc}function Ac(e){return e.error}function jc(e){return e.startsWith(`magpie:`)}function Mc(e){return e.isFetching}function Nc(e){let t=(0,Q.c)(17),{scope:n,children:r}=e,{t:i}=Te();if(!n.supported){let e;t[0]===i?e=t[1]:(e=i(`remoteProjects.unsupported`),t[0]=i,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,$.jsx)(`div`,{role:`status`,children:e}),t[2]=e,t[3]=n),n}if(!n.registry||!n.entry||!n.owner){let e=n.error?`alert`:`status`,r;t[4]!==n.error?.message||t[5]!==i?(r=n.error?.message??i(`remoteProjects.state.connecting`),t[4]=n.error?.message,t[5]=i,t[6]=r):r=t[6];let a;return t[7]!==e||t[8]!==r?(a=(0,$.jsx)(`div`,{role:e,children:r}),t[7]=e,t[8]=r,t[9]=a):a=t[9],a}let a;t[10]!==r||t[11]!==n.owner.state?(a=(0,$.jsx)(At.Provider,{value:n.owner.state,children:r}),t[10]=r,t[11]=n.owner.state,t[12]=a):a=t[12];let o;return t[13]!==n.entry.location||t[14]!==n.registry||t[15]!==a?(o=(0,$.jsx)(ce,{registry:n.registry,location:n.entry.location,children:a}),t[13]=n.entry.location,t[14]=n.registry,t[15]=a,t[16]=o):o=t[16],o}function Pc(e){let t=(0,Q.c)(58),{scope:n,onOpenSessions:r,menuOpen:i,onToggleMenu:a,surfaceShortcuts:o}=e,{t:s}=Te(),[c,l]=Z.useState(!1),u;t[0]===r?u=t[1]:(u=()=>{l(!1),r()},t[0]=r,t[1]=u);let d=q(u),f;t[2]===a?f=t[3]:(f=()=>{l(!1),a()},t[2]=a,t[3]=f);let p=q(f),m;t[4]!==i||t[5]!==a?(m=e=>{e&&i&&a(),l(e)},t[4]=i,t[5]=a,t[6]=m):m=t[6];let h=q(m),g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>l(!1),t[7]=g):g=t[7];let _;t[8]!==n.key||t[9]!==n.sessionId?(_=[n.key,n.sessionId],t[8]=n.key,t[9]=n.sessionId,t[10]=_):_=t[10],Z.useEffect(g,_);let v;t[11]!==n.project?.label||t[12]!==n.project?.path||t[13]!==s?(v=n.project?.label?.trim()||n.project?.path.split(/[\\/]/).filter(Boolean).at(-1)||s(`mobile.header.noProject`),t[11]=n.project?.label,t[12]=n.project?.path,t[13]=s,t[14]=v):v=t[14];let y=v,b;t[15]===s?b=t[16]:(b=s(`mobile.sessions.openSheetAria`),t[15]=s,t[16]=b);let x;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(X,{name:`folders`,className:`size-5`}),t[17]=x):x=t[17];let S;t[18]!==d||t[19]!==b?(S=(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":b,onClick:d,children:x}),t[18]=d,t[19]=b,t[20]=S):S=t[20];let C;t[21]!==y||t[22]!==n.session?.title||t[23]!==n.sessionId||t[24]!==s?(C=n.session?.title?.trim()||(n.sessionId?s(`mobile.sessions.untitled`):y),t[21]=y,t[22]=n.session?.title,t[23]=n.sessionId,t[24]=s,t[25]=C):C=t[25];let w;t[26]===C?w=t[27]:(w=(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:C}),t[26]=C,t[27]=w);let T;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(X,{name:`computer`,className:`size-3 shrink-0`}),t[28]=T):T=t[28];let E=n.sessionId?`${y} · `:``,D=n.host?.name??n.entry?.location.hostId,O;t[29]!==E||t[30]!==D?(O=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[T,(0,$.jsxs)(`span`,{className:`truncate`,children:[E,D]})]}),t[29]=E,t[30]=D,t[31]=O):O=t[31];let k;t[32]!==w||t[33]!==O?(k=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col px-2 py-1.5 text-left leading-tight`,children:[w,O]}),t[32]=w,t[33]=O,t[34]=k):k=t[34];let A=n.sessionId??``,j;t[35]!==c||t[36]!==h||t[37]!==A?(j=(0,$.jsx)($s,{sessionId:A,open:c,onOpenChange:h}),t[35]=c,t[36]=h,t[37]=A,t[38]=j):j=t[38];let M;t[39]!==o||t[40]!==s?(M=o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":s(`mobile.menu.files`),"aria-pressed":o.activePanel===`files`,onClick:o.onToggleFiles,children:(0,$.jsx)(X,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(Y,{variant:`ghost`,size:`icon`,className:`relative`,"aria-label":s(`mobile.menu.changes`),"aria-pressed":o.activePanel===`changes`,onClick:o.onToggleChanges,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-5`}),o.changesDirty?(0,$.jsx)(`span`,{className:`absolute right-2 top-2 size-2 rounded-full bg-primary`,"aria-hidden":!0}):null]})]}):null,t[39]=o,t[40]=s,t[41]=M):M=t[41];let N;t[42]===s?N=t[43]:(N=s(`mobile.header.openMenuAria`),t[42]=s,t[43]=N);let P;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(X,{name:`more-2`,className:`size-5`}),t[44]=P):P=t[44];let F;t[45]!==p||t[46]!==i||t[47]!==N?(F=(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":N,"aria-controls":`mobile-overflow-menu`,"aria-expanded":i,"aria-haspopup":`menu`,onClick:p,children:P}),t[45]=p,t[46]=i,t[47]=N,t[48]=F):F=t[48];let I;t[49]!==k||t[50]!==j||t[51]!==M||t[52]!==F||t[53]!==S?(I=(0,$.jsxs)(Ps,{children:[S,k,j,M,F]}),t[49]=k,t[50]=j,t[51]=M,t[52]=F,t[53]=S,t[54]=I):I=t[54];let L;return t[55]!==n||t[56]!==I?(L=(0,$.jsx)(Nc,{scope:n,children:I}),t[55]=n,t[56]=I,t[57]=L):L=t[57],L}var Fc=`/assets/android-direct-share-1a0lp154.jpg`,Ic=`/assets/ios-share-sheet-B3Dlufnc.jpg`,Lc=`/assets/select-assistant-C89IRspC.jpg`,Rc=`yuri:assistant-share-welcome:v1`,zc=[{image:Ic,titleKey:`assistants.shareWelcome.example.chat.title`,descriptionKey:`assistants.shareWelcome.example.chat.description`},{image:Fc,titleKey:`assistants.shareWelcome.example.article.title`,descriptionKey:`assistants.shareWelcome.example.article.description`},{image:Lc,titleKey:`assistants.shareWelcome.example.note.title`,descriptionKey:`assistants.shareWelcome.example.note.description`}],Bc=e=>{let t=(0,Q.c)(40),{enabled:n,open:r,onOpenChange:i}=e,a=n!==void 0&&n,{t:o}=Te(),[s,c]=fe(Rc,!1),l=r!==void 0,u=l?r:a&&s!==!0,d;t[0]!==l||t[1]!==i||t[2]!==c?(d=()=>{l||c(!0),i?.(!1)},t[0]=l,t[1]=i,t[2]=c,t[3]=d):d=t[3];let f=q(d),p;t[4]!==f||t[5]!==i?(p=e=>{e?i?.(!0):f()},t[4]=f,t[5]=i,t[6]=p):p=t[6];let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground sm:size-12`,children:(0,$.jsx)(X,{name:`share-2`,className:`size-5`})}),t[7]=m):m=t[7];let h;t[8]===o?h=t[9]:(h=o(`assistants.shareWelcome.title`),t[8]=o,t[9]=h);let g;t[10]===h?g=t[11]:(g=(0,$.jsx)(nn,{className:`typography-ui-header text-left sm:text-3xl`,children:h}),t[10]=h,t[11]=g);let _;t[12]===o?_=t[13]:(_=o(`assistants.shareWelcome.description`),t[12]=o,t[13]=_);let v;t[14]===_?v=t[15]:(v=(0,$.jsx)(rn,{className:`typography-ui text-left leading-6 sm:max-w-3xl sm:text-base sm:leading-7`,children:_}),t[14]=_,t[15]=v);let y;t[16]!==g||t[17]!==v?(y=(0,$.jsxs)($t,{className:`flex-row items-start gap-3 px-5 pb-5 pt-6 text-left sm:gap-4 sm:px-8 sm:pb-6 sm:pt-8`,children:[m,(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1.5 sm:space-y-2`,children:[g,v]})]}),t[16]=g,t[17]=v,t[18]=y):y=t[18];let b;t[19]===o?b=t[20]:(b=o(`assistants.shareWelcome.examplesAria`),t[19]=o,t[20]=b);let x;t[21]===o?x=t[22]:(x=zc.map((e,t)=>(0,$.jsxs)(`article`,{className:`w-[min(78vw,19rem)] shrink-0 snap-center overflow-hidden rounded-xl border border-border bg-background lg:w-auto lg:min-w-0`,children:[(0,$.jsxs)(`div`,{className:`relative overflow-hidden border-b border-border bg-muted`,children:[(0,$.jsx)(`img`,{src:e.image,alt:``,className:`h-72 w-full object-cover object-bottom lg:h-[min(38vh,23rem)]`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-3 top-3 flex size-7 items-center justify-center rounded-full bg-[var(--surface-elevated)] typography-meta font-semibold text-foreground shadow-sm`,children:t+1})]}),(0,$.jsxs)(`div`,{className:`space-y-1 px-4 py-3.5 lg:min-h-25`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:o(e.titleKey)}),(0,$.jsx)(`p`,{className:`typography-meta leading-5 text-muted-foreground`,children:o(e.descriptionKey)})]})]},e.titleKey)),t[21]=o,t[22]=x);let S;t[23]!==b||t[24]!==x?(S=(0,$.jsx)(`div`,{className:`overflow-hidden px-5 pb-5 sm:px-8 sm:pb-7`,children:(0,$.jsx)(`div`,{className:`flex snap-x snap-mandatory gap-3 overflow-x-auto pb-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden lg:grid lg:grid-cols-3 lg:overflow-visible lg:pb-0`,"aria-label":b,children:x})}),t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]===o?C=t[27]:(C=o(`assistants.shareWelcome.action`),t[26]=o,t[27]=C);let w;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4`}),t[28]=w):w=t[28];let T;t[29]!==f||t[30]!==C?(T=(0,$.jsx)(en,{className:`border-t border-border px-5 py-4 sm:px-8 sm:py-5`,children:(0,$.jsxs)(Y,{size:`lg`,className:`w-full lg:mx-auto lg:w-72`,onClick:f,children:[C,w]})}),t[29]=f,t[30]=C,t[31]=T):T=t[31];let E;t[32]!==S||t[33]!==T||t[34]!==y?(E=(0,$.jsxs)(tn,{showCloseButton:!1,className:`w-[min(100%,31rem)] max-w-none gap-0 overflow-hidden rounded-2xl border-border bg-[var(--surface-elevated)] p-0 sm:w-[min(calc(100%-3rem),44rem)] lg:w-[min(calc(100%-4rem),74rem)]`,containerClassName:`fixed inset-0 z-50 flex items-end justify-center px-0 pt-8 sm:items-center sm:p-6`,children:[y,S,T]}),t[32]=S,t[33]=T,t[34]=y,t[35]=E):E=t[35];let D;return t[36]!==u||t[37]!==E||t[38]!==p?(D=(0,$.jsx)(an,{open:u,onOpenChange:p,children:E}),t[36]=u,t[37]=E,t[38]=p,t[39]=D):D=t[39],D},Vc=me(`YuriNativeHeader`),Hc=`header.yuri-mobile-detail-navigation, header.yuri-mobile-header`,Uc=`yuri-native-header-source`,Wc=`yuri-native-header-ready`,Gc=new Set([Wc,`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-hide`,`yuri-kb-caret-hold`]),Kc=`--yuri-native-viewport-top`,qc=`.fixed, [role="dialog"]`,Jc=new Set([`style`,`data-yuri-header-collapse-phase`,`data-yuri-header-collapse-rest`]),Yc=()=>parseFloat(document.documentElement.style.getPropertyValue(`--yuri-native-viewport-top`))||0,Xc=`[data-avatar-motion]`,Zc=new Set([`class`,`style`,`inert`,`aria-hidden`,`hidden`]),Qc=e=>{if(e.querySelector(`input, textarea, select, [contenteditable]:not([contenteditable="false"])`)||e.getClientRects().length===0||e.offsetHeight<=0||e.closest(`[inert],[aria-hidden="true"]`))return!1;let t=e.parentElement;if(!t||(typeof t.checkVisibility==`function`?!t.checkVisibility({visibilityProperty:!0,contentVisibilityAuto:!0,opacityProperty:!0}):getComputedStyle(t).visibility===`hidden`))return!1;let n=e.getBoundingClientRect().top-Yc();return e.dataset.yuriCollapsibleHeader===`true`||Math.abs(n)<=1},$c=(e,t)=>{let n=[...document.querySelectorAll(Hc)].filter(Qc);if(t&&e&&n.includes(e))return e;for(let e of n){let t=e.getBoundingClientRect(),n=document.elementFromPoint(t.left+t.width/2,t.bottom-4);if(n&&e.contains(n))return e}return n.at(-1)??null},el=()=>{let e=[];for(let t of document.styleSheets)try{for(let n of t.cssRules)e.push(n.cssText)}catch{}return e.join(`
12
- `)},tl=()=>{let e=0;for(let t of document.styleSheets)try{e+=t.cssRules.length}catch{}return`${document.styleSheets.length}:${e}`},nl=Vc,rl=()=>new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e(1)))});function il(){let e=document.documentElement,t=window,n=!1,r=0,i=0,a=null,o=``,s=``,c=``,l=``,u=!1,d=!1,f=[],p=()=>{if(!a)return;let e=parseFloat(a.style.getPropertyValue(`--yuri-mobile-header-collapse`))||0,n=a.dataset.yuriHeaderCollapsePhase??`rest`,r=a.dataset.yuriHeaderCollapseRest??`expanded`,i=`${e}|${n}|${r}`;i!==l&&(l=i,t.YuriHeaderCollapse?t.YuriHeaderCollapse.set(e,n,r):t.webkit?.messageHandlers?.yuriHeaderCollapse?.postMessage({progress:e,phase:n,rest:r}))},m=()=>{e.classList.remove(Wc),u&&(u=!1,o=``,Vc.update({seq:++r,visible:!1}).catch(()=>void 0))},h=()=>{if(i=0,n)return;let t=$c(a,d);if(t!==a){if(a?.classList.remove(Uc),m(),a=t,l=``,!t)return;t.classList.add(Uc),p()}if(!t)return;let f=window.devicePixelRatio||1,h=t.offsetHeight,g=parseFloat(getComputedStyle(t,`::after`).height)||0,_=Math.ceil(h*f),v=t.querySelector(qc)===null?Math.ceil(Math.max(h,g)*f):_,y=(h+2*(parseFloat(getComputedStyle(e).fontSize)||16))*f,b=t.cloneNode(!0);b.classList.remove(Uc),b.style.removeProperty(In),delete b.dataset.yuriHeaderCollapsePhase,delete b.dataset.yuriHeaderCollapseRest;for(let e of b.querySelectorAll(qc))e.style.display=`none`;let x=b.outerHTML,S=[...e.classList].filter(e=>!Gc.has(e)).join(` `),C=(e.getAttribute(`style`)??``).replace(RegExp(`${Kc}\\s*:[^;]*;?`,`g`),``),w=document.body.className,T=`${x}|${S}|${C}|${w}|${v}|${y}`,E=tl(),D=document.getElementById(`yuri-icon-sprite-v2`)?.outerHTML??``;if(T===o&&E===s&&D===c)return;o=T;let O={seq:++r,visible:!0,height:v,hitBottom:_,collapseDistance:y,html:x,rootClass:S,rootStyle:C,bodyClass:w};E!==s&&(s=E,O.css=el()),D!==c&&(c=D,O.sprite=D),u=!0,Vc.update(O).catch(()=>void 0)},g=()=>{!i&&!n&&(i=requestAnimationFrame(h))};f.push(Vc.addListener(`shown`,t=>{d&&t.seq===r&&a&&e.classList.add(Wc)})),f.push(Vc.addListener(`tap`,e=>{if(!a||!d)return;let t=a;try{for(let n of JSON.parse(e.path))t=t?.children[n]??null}catch{return}let n=t?.closest(`button, a, [role="button"]`);if(!n||!a.contains(n))return;let r={bubbles:!0,cancelable:!0,pointerType:`touch`,isPrimary:!0};n.dispatchEvent(new PointerEvent(`pointerdown`,r)),n.dispatchEvent(new PointerEvent(`pointerup`,r)),n.click()}));let _=new MutationObserver(e=>{if(!a||!a.isConnected){g();return}let t=!1;for(let n of e){if(n.target===a&&n.type===`attributes`&&Jc.has(n.attributeName??``)){p();continue}let e=n.target instanceof Element?n.target:n.target.parentElement;if(!(e?.closest(Xc)&&a.contains(e))){if(a.contains(n.target)||n.type===`attributes`&&n.target.contains(a))t=!0;else if(n.type===`attributes`&&Zc.has(n.attributeName??``)&&n.target instanceof Element&&n.target.querySelector(Hc))t=!0;else if(n.type===`childList`)for(let e of n.addedNodes)e instanceof Element&&(e.matches(Hc)||e.querySelector(Hc))&&(t=!0)}}t&&g()});_.observe(document.body,{subtree:!0,childList:!0,attributes:!0,characterData:!0});let v=new MutationObserver(g);v.observe(e,{attributes:!0,attributeFilter:[`class`,`style`]});let y=new MutationObserver(g);y.observe(document.head,{childList:!0,subtree:!0,characterData:!0}),window.addEventListener(`resize`,g),g(),t.__yuriImeOffset=t=>(window.dispatchEvent(new Event(`yuri:keyboard-native-layout`)),e.style.setProperty(Kc,`${Math.max(0,t)}px`),rl());let b=window;return b.__yuriNativeHeader=t=>(d=t,e.classList.toggle(Wc,t&&a!==null),rl()),()=>{n=!0,delete b.__yuriNativeHeader,i&&cancelAnimationFrame(i),_.disconnect(),v.disconnect(),y.disconnect(),window.removeEventListener(`resize`,g),delete t.__yuriImeOffset,e.classList.remove(Wc),a?.classList.remove(Uc),a=null;for(let e of f)e.then(e=>e.remove()).catch(()=>void 0);Vc.update({seq:++r,visible:!1}).catch(()=>void 0)}}var al=`.yuri-mobile-composer`,ol=`[data-btw-composer]`;function sl(e,t){if(!e)return!1;let n=t;return!n||typeof n.closest!=`function`||!n.closest(ol)}function cl(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(al)}function ll(e){return cl(e??null)}var ul=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),dl=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},fl=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},pl=(e,t)=>t?`${e}\u0000staged`:e,ml=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=Te(),{git:o,projectScope:s}=ti(),{generateCommitMessage:c,stageGitFile:l,stageGitFiles:u,unstageGitFile:d,unstageGitFiles:f}=qi(),p=ni(),m=s?p??null:ul(p??null),h=Tn(m||null),g=fn(m||null),_=un(m||null),v=pn(e=>e.setActiveDirectory),y=pn(e=>e.ensureAll),b=pn(e=>e.fetchStatus),x=pn(e=>e.fetchBranches),S=pn(e=>e.prefetchDiffs),C=pn(e=>e.getDiff),w=pn(e=>e.setDiff),[T,E]=Z.useState(()=>t?{type:`diff`,path:t,staged:n,targetLine:r}:{type:`list`}),D=Z.useRef(null);Z.useEffect(()=>{t&&E(e=>e.type===`diff`&&e.path===t&&e.staged===n&&e.targetLine===r?e:{type:`diff`,path:t,staged:n,targetLine:r})},[t,n,r]);let[O,k]=Z.useState(null),[A,j]=Z.useState(null),[M,N]=Z.useState(``),[P,F]=Z.useState(new Set),[I,L]=Z.useState(!1),[R,ee]=Z.useState(!1),[z,B]=Z.useState([]),[V,te]=Z.useState([]),[H,ne]=Z.useState([]),[U,re]=Z.useState(null),[W,ie]=Z.useState({key:null,loading:!1,error:null,resolved:!1}),[ae,oe]=Z.useState(0),se=Z.useRef({key:null,generation:0}),[ce,le]=Z.useState(!1),ue=Mi(h)&&!ce,G=Z.useMemo(()=>{let e=h?.files??[];if(ue)return[];let t=new Map;for(let n of e)t.set(n.path,n);return Array.from(t.values()).sort((e,t)=>e.path.localeCompare(t.path))},[h?.files,ue]),de=Z.useMemo(()=>G.filter(dl),[G]),K=Z.useMemo(()=>G.filter(fl),[G]),{deferredStagedCount:fe,deferredUnstagedCount:pe}=Z.useMemo(()=>{if(!ue||!h)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of h.files??[])dl(n)&&(e+=1),fl(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[ue,h]),me=Z.useMemo(()=>{if(H.length>0)return H;let e=h?.tracking?.includes(`/`)?h.tracking.split(`/`)[0]:null;return e||U?[{name:e||`origin`,fetchUrl:U??``,pushUrl:U??``}]:[]},[U,H,h?.tracking]),J=Z.useMemo(()=>e=>!m||T.type!==`diff`?null:e.directories.get(m)?.diffCache.get(pl(T.path,T.staged))??null,[m,T]),he=pn(J),ge=Z.useMemo(()=>T.type===`diff`?G.find(e=>e.path===T.path)??null:null,[G,T]),_e=T.type===`diff`&&m?`${m}\u0000${pl(T.path,T.staged)}`:null,ve=W.key===_e,ye=!!(_e&&!he&&(!ve||W.loading)),be=ve?W.error:null,xe=!!(ge||ve&&W.resolved),Se=q(async(e,t=!0)=>{try{await Promise.all([b(e,o),x(e,o)])}catch(e){t&&at.error(e instanceof Error?e.message:a(`gitView.toast.refreshRepositoryFailed`))}}),Ce=q(async(e,t,n)=>{let r=()=>se.current.key===t&&se.current.generation===n;try{let[t,n]=await Promise.all([o.getRemotes(e).catch(()=>[]),o.getRemoteUrl?o.getRemoteUrl(e).catch(()=>null):Promise.resolve(null)]);if(!r())return;ne(t),re(n)}catch{if(!r())return;ne([]),re(null)}}),we=q(e=>{if(e!==m)return{requestGeneration:null,promise:Promise.resolve()};let t=se.current.generation+1;return se.current={key:e,generation:t},{requestGeneration:t,promise:Ce(e,e,t)}});Z.useEffect(()=>{m&&(v(m),y(m,o))},[m,y,o,v]),Z.useEffect(()=>{if(!m){se.current={key:null,generation:se.current.generation+1},ne([]),re(null);return}let{requestGeneration:e,promise:t}=we(m);return()=>{e!==null&&se.current.key===m&&se.current.generation===e&&(se.current={key:m,generation:e+1})}},[m,o,we]),Z.useEffect(()=>{if(!m||G.length===0)return;let e=Array.from(new Set([...de.map(e=>e.path),...V,...G.slice(0,20).map(e=>e.path)])).filter(Boolean);if(e.length===0)return;let t=window.setTimeout(()=>{S(m,o,e,{maxFiles:40})},120);return()=>window.clearTimeout(t)},[G,m,o,S,de,V]),Z.useEffect(()=>{if(T.type!==`diff`){ie({key:null,loading:!1,error:null,resolved:!1});return}let e=pl(T.path,T.staged);if(!m||!_e){ie({key:null,loading:!1,error:null,resolved:!1});return}if(C(m,e)){ie(e=>({key:_e,loading:!1,error:null,resolved:e.key===_e&&e.resolved||!!ge}));return}let t=!1;return ie({key:_e,loading:!0,error:null,resolved:!1}),o.getGitFileDiff(m,{path:T.path,staged:T.staged||void 0}).then(n=>{t||(w(m,e,{original:n.original??``,modified:n.modified??``,isBinary:n.isBinary}),ie(e=>e.key===_e?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||ie(t=>t.key===_e?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[_e,m,ae,C,o,T,ge,w]);let Ee=async(e,t)=>{if(!m)return;let n=m;k(e);try{let r=e=>{let t=`${e.name}/`,n=h?.tracking?.startsWith(t)?h.tracking.slice(t.length):void 0;return{remote:e.name,branch:n,rebase:!0}};if(e===`fetch`){if(!t)throw Error(a(`mobile.changes.noRemote`));await o.gitFetch(n,{remote:t.name}),at.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){at.error(a(`gitView.toast.commitOrStashBeforeSync`));return}await o.gitPull(n,r(t))}((await o.getGitStatus(n)).ahead??0)>0&&await o.gitPush(n),at.success(a(`gitView.toast.alreadyUpToDate`))}await Se(n,!1),await we(n).promise}catch(e){at.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{k(null)}},De=q(async(e,t)=>{if(!m||e.length===0)return;let n=m;try{t===`stage`?e.length>1?await u(n,e):await l(n,e[0]):e.length>1?await f(n,e):await d(n,e[0]),await Se(n,!1)}catch(e){at.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),Oe=q((e,t=!1)=>{E({type:`diff`,path:e,staged:t,targetLine:null})}),ke=q(()=>T.type===`diff`&&(E({type:`list`}),!0));Fr({id:`mobile-changes-diff`,active:T.type===`diff`&&!i,layer:`overlay`,onBack:ke,surfaceRef:D});let Ae=q(async e=>{if(!m)return;let t=m;F(t=>new Set(t).add(e));try{await o.revertGitFile(t,e),at.success(a(`gitView.toast.revertedFile`,{path:e})),await Se(t,!1)}catch(e){at.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{F(t=>{let n=new Set(t);return n.delete(e),n})}}),je=q(async e=>{if(!m||e.length===0||I)return;let t=m,n=Array.from(new Set(e));L(!0),F(new Set(n));try{await Promise.all(n.map(e=>o.revertGitFile(t,e))),await Se(t,!1),at.success(n.length===1?a(`gitView.toast.revertedFilesSingle`,{count:n.length}):a(`gitView.toast.revertedFilesPlural`,{count:n.length}))}catch(e){at.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{F(new Set),L(!1)}}),Me=q(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){B([]);return}N(e=>`${e.trim()}${e.trim()?`
13
-
14
- `:``}${t.join(`
15
- `)}`.trim()),B([])}),Ne=q(async()=>{if(!m)return;let e=m,t=de.map(e=>e.path).sort();if(t.length===0){at.error(a(`gitView.toast.selectFileToDescribe`));return}ee(!0);try{let{message:n}=await c(e,t);N(n.subject?.trim()??``),B(Array.isArray(n.highlights)?n.highlights:[])}catch(e){at.error(e instanceof Error?e.message:a(`gitView.toast.generateCommitMessageFailed`))}finally{ee(!1)}}),Pe=async(e={})=>{if(!m)return;let t=m;if(!M.trim()){at.error(a(`gitView.toast.enterCommitMessage`));return}let n=de.map(e=>e.path).sort();if(n.length===0){at.error(a(`gitView.toast.selectFileToCommit`));return}j(e.pushAfter?`commitAndPush`:`commit`);try{if(await o.createGitCommit(t,M.trim(),{files:n}),at.success(a(`gitView.toast.commitCreated`)),N(``),B([]),e.pushAfter){let e=h?.tracking?.split(`/`)[0],n=me.find(t=>t.name===e)??me[0];if(!n)throw Error(a(`mobile.changes.noRemote`));k(`sync`);let r=`${n.name}/`,i=h?.tracking?.startsWith(r)?h.tracking.slice(r.length):void 0;await o.gitFetch(t,{remote:n.name}),((await o.getGitStatus(t)).behind??0)>0&&await o.gitPull(t,{remote:n.name,branch:i,rebase:!0}),((await o.getGitStatus(t)).ahead??0)>0&&await o.gitPush(t),await Se(t,!1),await we(t).promise}else await Se(t,!1)}catch(e){at.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{j(null),e.pushAfter&&k(null)}},Fe=Z.useMemo(()=>{let e=[];return de.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:de,actionSymbol:`-`,actionAllLabel:a(`gitView.changes.unstageAllAria`),getActionLabel:e=>a(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void De([e],`unstage`),onActionAll:e=>void De(e,`unstage`),onViewDiff:e=>Oe(e,!0),onRevertFile:Ae,showRevertActions:!1,accent:!0}),K.length>0&&e.push({id:`unstaged`,title:a(`gitView.changes.title`),entries:K,actionSymbol:`+`,actionAllLabel:a(`gitView.changes.stageAllAria`),getActionLabel:e=>a(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void De([e],`stage`),onActionAll:e=>void De(e,`stage`),onViewDiff:e=>Oe(e,!1),onRevertFile:Ae}),e},[Ae,Oe,De,de,a,K]),Ie=t=>(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[i?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:h?.current||m||``})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:t})]});return m?_&&g===null?Ie((0,$.jsx)(hl,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):g===!1?Ie((0,$.jsx)(hl,{icon:!0,message:a(`gitView.empty.notGitRepository`),description:a(`gitView.empty.notGitRepositoryDescription`)})):T.type===`diff`?(0,$.jsx)(`div`,{ref:D,className:`h-full min-h-0`,children:(0,$.jsx)(gl,{path:T.path,directory:m,diff:he,fileExists:xe,error:be,loading:ye,targetLine:T.targetLine,onBack:ke,onRetry:()=>oe(e=>e+1),hideHeader:i})}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:h?.current||m})]}),(0,$.jsx)(zi,{syncAction:O,remotes:me,onSync:e=>void Ee(`sync`,e),disabled:A!==null||_,aheadCount:h?.ahead??0,behindCount:h?.behind??0,trackingRemoteName:h?.tracking?.split(`/`)[0],hasUncommittedChanges:(h?.files?.length??0)>0})]}),ue?(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(xa,{stagedCount:fe,unstagedCount:pe,onLoad:()=>le(!0)})}):G.length>0?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-4 pt-4`,children:(0,$.jsx)(Ai,{groups:Fe,diffStats:h?.diffStats,revertingPaths:P,onRevertAll:je,isRevertingAll:I,headerBackgroundClassName:`bg-transparent`,onVisiblePathsChange:te})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-4 pt-3`,children:(0,$.jsx)(Ei,{stagedCount:de.length,commitMessage:M,onCommitMessageChange:N,generatedHighlights:z,onInsertHighlights:Me,onGenerateMessage:Ne,isGeneratingMessage:R,onCommit:()=>void Pe({pushAfter:!1}),onCommitAndPush:()=>void Pe({pushAfter:!0}),commitAction:A,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(hl,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):Ie((0,$.jsx)(hl,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},hl=e=>{let t=(0,Q.c)(13),{message:n,description:r,loading:i,icon:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c;t[0]===o?c=t[1]:(c=o?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):null,t[0]=o,t[1]=c);let l;t[2]===s?l=t[3]:(l=s?(0,$.jsx)(X,{name:`git-branch`,className:`size-6 text-muted-foreground`}):null,t[2]=s,t[3]=l);let u;t[4]===n?u=t[5]:(u=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[4]=n,t[5]=u);let d;t[6]===r?d=t[7]:(d=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[6]=r,t[7]=d);let f;return t[8]!==c||t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[c,l,u,d]})}),t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f},gl=e=>{let t=(0,Q.c)(26),{path:n,directory:r,diff:i,fileExists:a,error:o,loading:s,targetLine:c,onBack:l,onRetry:u,hideHeader:d}=e,f=d!==void 0&&d,{t:p}=Te(),m=Sr(),h;t[0]===n?h=t[1]:(h=Br(n)||`text`,t[0]=n,t[1]=h);let g=h,_;t[2]!==r||t[3]!==m||t[4]!==n||t[5]!==p?(_=m?(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,title:p(`diffView.actions.openFilePreview`),"aria-label":p(`diffView.actions.openFilePreview`),onClick:()=>m.openFile({path:de(r,n)}),children:(0,$.jsx)(X,{name:`eye`,className:`size-4`})}):null,t[2]=r,t[3]=m,t[4]=n,t[5]=p,t[6]=_):_=t[6];let v=_,y;t[7]!==f||t[8]!==l||t[9]!==n||t[10]!==v||t[11]!==p?(y=f?(0,$.jsx)(vr,{children:v}):(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":p(`header.actions.backAria`),onClick:l,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-2`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:n})}),v]}),t[7]=f,t[8]=l,t[9]=n,t[10]=v,t[11]=p,t[12]=y):y=t[12];let b;t[13]!==i||t[14]!==o||t[15]!==a||t[16]!==g||t[17]!==s||t[18]!==u||t[19]!==n||t[20]!==p||t[21]!==c?(b=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:o?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:p(`mobile.changes.diffDetail.loadFailed`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:o}),(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:`outline`,onClick:u,children:p(`diffView.actions.retry`)})]})}):s?(0,$.jsx)(hl,{loading:!0,message:p(`diffView.state.loadingDiff`)}):a?i?i.isBinary?(0,$.jsx)(hl,{icon:!0,message:p(`diffView.binary.unavailable`)}):Vr(n)?(0,$.jsx)(hl,{icon:!0,message:p(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(Jr,{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)(Li,{original:i.original,modified:i.modified,language:g,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:c,layout:`inline`})}):(0,$.jsx)(hl,{loading:!0,message:p(`diffView.state.loadingDiff`)}):(0,$.jsx)(hl,{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},_l=e(C(),1),vl=pr(()=>he(()=>import(`./ToolOutputDialog-5xBwOJ6a.js`).then(e=>e.n),__vite__mapDeps([3,1,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,2,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79]))),yl=25e4,bl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),xl=e=>{let t=bl(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},Sl=e=>{let t=bl(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},Cl=(e,t)=>{let n=bl(e),r=bl(t);return!r||n===r?xl(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},wl=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``},Tl=e=>/\.(md|mdx|markdown)$/i.test(e),El=e=>{let t=(0,Q.c)(156),{onClose:n,initialFilePath:r,directFilePreview:i,hideFileHeader:a}=e,o=r===void 0?null:r,s=i!==void 0&&i,c=a!==void 0&&a,{t:l}=Te(),{files:u}=ti(),d=ni()??null,f;t[0]===d?f=t[1]:(f=bl(d),t[0]=d,t[1]=f);let p=f,m;t[2]!==o||t[3]!==p?(m=()=>{let e=bl(o);return e?{type:`file`,path:e,returnDirectory:Sl(e)??p}:{type:`browser`,directory:p}},t[2]=o,t[3]=p,t[4]=m):m=t[4];let[h,g]=Z.useState(m),_=Z.useRef(null),[v,y]=Z.useState(``),b=ge(Pl),x=ge(Fl),S,C;t[5]===p?(S=t[6],C=t[7]):(S=()=>{p&&g(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:Sl(e.path)??p}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:p})},C=[p],t[5]=p,t[6]=S,t[7]=C),Z.useEffect(S,C);let w,T;t[8]!==b||t[9]!==p||t[10]!==x?(T=()=>{if(!b||!p)return;let e=bl(b);if(!e){x(null);return}y(``),g({type:`file`,path:e,returnDirectory:Sl(e)??p}),x(null)},w=[b,p,x],t[8]=b,t[9]=p,t[10]=x,t[11]=w,t[12]=T):(w=t[11],T=t[12]),Z.useEffect(T,w);let E=h.type===`browser`?h.directory:h.returnDirectory,D=h.type===`browser`?h.directory:``,O=h.type===`file`?h.path:``,[k,A]=Z.useState(`preview`),j;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{A(`preview`)},t[13]=j):j=t[13];let M;t[14]===O?M=t[15]:(M=[O],t[14]=O,t[15]=M),Z.useEffect(j,M);let N=Dr(v,250),P;t[16]===v?P=t[17]:(P=v.trim(),t[16]=v,t[17]=P);let F=P,I;t[18]===N?I=t[19]:(I=N.trim(),t[18]=N,t[19]=I);let L=I,R;t[20]!==D||t[21]!==p?(R={scopeDirectory:p,directory:D},t[20]=D,t[21]=p,t[22]=R):R=t[22];let ee=!!D,z;t[23]===ee?z=t[24]:(z={enabled:ee,refetchOnMount:`always`},t[23]=ee,t[24]=z);let B=U(R,z),V;t[25]!==D||t[26]!==L?(V={directory:D,query:L,maxResults:40},t[25]=D,t[26]=L,t[27]=V):V=t[27];let te=!!(D&&L),H;t[28]===te?H=t[29]:(H={enabled:te},t[28]=te,t[29]=H);let ne=ue(V,H),re;t[30]===O?re=t[31]:(re=O&&(!Vr(O)||O.toLowerCase().endsWith(`.svg`)),t[30]=O,t[31]=re);let W=!!re,ie;t[32]!==O||t[33]!==p?(ie={scopeDirectory:p,path:O},t[32]=O,t[33]=p,t[34]=ie):ie=t[34];let se;t[35]===W?se=t[36]:(se={enabled:W},t[35]=W,t[36]=se);let ce=oe(ie,se),le=W&&ce.data?.isBinary===!0,G;t[37]!==O||t[38]!==ce.data||t[39]!==ce.error||t[40]!==ce.isFetchedAfterMount||t[41]!==u||t[42]!==k||t[43]!==le?(G=O&&u.readFile&&ce.data&&ce.isFetchedAfterMount&&!ce.error&&!le&&(!Ur(O)||k===`source`)&&(!Vr(O)||O.toLowerCase().endsWith(`.svg`)),t[37]=O,t[38]=ce.data,t[39]=ce.error,t[40]=ce.isFetchedAfterMount,t[41]=u,t[42]=k,t[43]=le,t[44]=G):G=t[44];let de=!!G,K;t[45]!==O||t[46]!==p?(K={scopeDirectory:p,path:O},t[45]=O,t[46]=p,t[47]=K):K=t[47];let fe;t[48]===de?fe=t[49]:(fe={enabled:de},t[48]=de,t[49]=fe);let pe=ae(K,fe),me=B.data?.entries.slice().sort(Il)??[],J;t[50]!==B.error||t[51]!==l?(J=B.error?B.error instanceof Error?B.error.message:l(`mobile.files.error.listFailed`):null,t[50]=B.error,t[51]=l,t[52]=J):J=t[52];let he=J,_e=B.isFetching,ve;t[53]===ne.data?ve=t[54]:(ve=ne.data??[],t[53]=ne.data,t[54]=ve);let ye=ve,be=!!(F&&L&&v===N&&ne.isFetching),xe;t[55]!==pe.data||t[56]!==l?(xe=pe.data&&pe.data.length>yl?`${pe.data.slice(0,yl)}\n\n${l(`mobile.files.file.truncated`)}`:pe.data??``,t[55]=pe.data,t[56]=l,t[57]=xe):xe=t[57];let Se=xe,Ce=ce.error??pe.error,we;t[58]!==u||t[59]!==le||t[60]!==W||t[61]!==Ce||t[62]!==l?(we=W&&(!u.statFile||!le&&!u.readFile)?l(`mobile.files.error.readUnavailable`):Ce?Ce instanceof Error?Ce.message:l(`filesView.error.readFileFailed`):null,t[58]=u,t[59]=le,t[60]=W,t[61]=Ce,t[62]=l,t[63]=we):we=t[63];let Ee=we,De=!Ee&&(W&&(!ce.data||!ce.isFetchedAfterMount)||de&&pe.isFetching&&pe.data===void 0),Oe;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=e=>{y(``),g({type:`browser`,directory:e})},t[64]=Oe):Oe=t[64];let ke=Oe,Ae;t[65]!==E||t[66]!==p?(Ae=e=>{g({type:`file`,path:e,returnDirectory:E||p})},t[65]=E,t[66]=p,t[67]=Ae):Ae=t[67];let je=Ae,Me;t[68]!==s||t[69]!==n||t[70]!==h.returnDirectory||t[71]!==h.type?(Me=()=>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]=Me):Me=t[72];let Ne=q(Me),Pe=h.type===`file`,Fe;t[73]!==Ne||t[74]!==Pe?(Fe={id:`mobile-files-detail`,active:Pe,layer:`overlay`,onBack:Ne,surfaceRef:_},t[73]=Ne,t[74]=Pe,t[75]=Fe):Fe=t[75],Fr(Fe);let Ie;t[76]===l?Ie=t[77]:(Ie=async e=>{(await ct(e)).ok||at.error(l(`mobile.files.toast.copyFailed`))},t[76]=l,t[77]=Ie);let Le=Ie,Re;t[78]!==Se||t[79]!==l?(Re=async()=>{(await ct(Se)).ok?at.success(l(`mobile.files.toast.contentCopied`)):at.error(l(`mobile.files.toast.copyFailed`))},t[78]=Se,t[79]=l,t[80]=Re):Re=t[80];let ze=Re;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)(Nl,{message:e}),t[83]=e,t[84]=n),n}if(h.type===`file`){let e;t[85]!==Le||t[86]!==h.path?(e=()=>void Le(h.path),t[85]=Le,t[86]=h.path,t[87]=e):e=t[87];let n;t[88]===ze?n=t[89]:(n=()=>void ze(),t[88]=ze,t[89]=n);let r;return t[90]!==Ne||t[91]!==Se||t[92]!==Ee||t[93]!==c||t[94]!==k||t[95]!==le||t[96]!==De||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)(Al,{path:h.path,content:Se,error:Ee,isLoading:De,isBinary:le,hideHeader:c,htmlViewMode:k,onHtmlViewModeChange:A,onBack:Ne,onCopyPath:e,onCopyContent:n})}),t[90]=Ne,t[91]=Se,t[92]=Ee,t[93]=c,t[94]=k,t[95]=le,t[96]=De,t[97]=h.path,t[98]=e,t[99]=n,t[100]=r):r=t[100],r}let Be;t[101]!==p||t[102]!==h.directory||t[103]!==l?(Be=h.directory===p?l(`mobile.files.rootDirectory`):xl(h.directory),t[101]=p,t[102]=h.directory,t[103]=l,t[104]=Be):Be=t[104];let Ve=Be,He;t[105]!==v||t[106]!==ye?(He=v.trim()?ye:[],t[105]=v,t[106]=ye,t[107]=He):He=t[107];let Ue=He,We,Ge,Ke,qe;if(t[108]!==n||t[109]!==v||t[110]!==p||t[111]!==h.directory||t[112]!==l){let e=Sl(h.directory),r=h.directory!==p&&e!==null&&(e===p||e.startsWith(`${p}/`)),i=r&&!v.trim(),a=r?e:null;qe=`flex h-full flex-col overflow-hidden bg-background text-foreground`,We=`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[117]!==n||t[118]!==l?(Ge=n?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":l(`mobile.surface.closeAria`),onClick:n,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,t[117]=n,t[118]=l,t[119]=Ge):Ge=t[119],Ke=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:xl(a)}),onClick:()=>ke(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}):null,t[108]=n,t[109]=v,t[110]=p,t[111]=h.directory,t[112]=l,t[113]=We,t[114]=Ge,t[115]=Ke,t[116]=qe}else We=t[113],Ge=t[114],Ke=t[115],qe=t[116];let Je;t[120]===Ve?Je=t[121]:(Je=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:Ve})}),t[120]=Ve,t[121]=Je);let Ye;t[122]===l?Ye=t[123]:(Ye=l(`mobile.files.refreshAria`),t[122]=l,t[123]=Ye);let Xe;t[124]===B?Xe=t[125]:(Xe=()=>void B.refetch(),t[124]=B,t[125]=Xe);let Ze;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Ze={touchAction:`manipulation`},t[126]=Ze):Ze=t[126];let Y=_e&&`animate-spin`,Qe;t[127]===Y?Qe=t[128]:(Qe=it(`size-5`,Y),t[127]=Y,t[128]=Qe);let $e;t[129]===Qe?$e=t[130]:($e=(0,$.jsx)(X,{name:`refresh`,className:Qe}),t[129]=Qe,t[130]=$e);let et;t[131]!==Ye||t[132]!==Xe||t[133]!==$e?(et=(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":Ye,onClick:Xe,style:Ze,children:$e}),t[131]=Ye,t[132]=Xe,t[133]=$e,t[134]=et):et=t[134];let tt;t[135]!==We||t[136]!==Ge||t[137]!==Ke||t[138]!==Je||t[139]!==et?(tt=(0,$.jsxs)(`header`,{className:We,children:[Ge,Ke,Je,et]}),t[135]=We,t[136]=Ge,t[137]=Ke,t[138]=Je,t[139]=et,t[140]=tt):tt=t[140];let nt;t[141]===Symbol.for(`react.memo_cache_sentinel`)?(nt=(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[141]=nt):nt=t[141];let rt;t[142]===Symbol.for(`react.memo_cache_sentinel`)?(rt=e=>y(e.target.value),t[142]=rt):rt=t[142];let ot;t[143]===l?ot=t[144]:(ot=l(`mobile.files.search.placeholder`),t[143]=l,t[144]=ot);let st;t[145]!==v||t[146]!==ot?(st=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[nt,(0,$.jsx)(Kn,{type:`text`,inputMode:`search`,value:v,onChange:rt,placeholder:ot,className:`h-11 pl-9`})]})}),t[145]=v,t[146]=ot,t[147]=st):st=t[147];let lt=Jr,ut=he?(0,$.jsx)(Nl,{message:he}):v.trim()?(0,$.jsx)(Ol,{results:Ue,isSearching:be,onOpenFile:je}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[me.length===0&&!_e?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:l(`mobile.files.empty.directory`)}):null,me.map(e=>(0,$.jsx)(Dl,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:wl(e.size),onClick:()=>e.isDirectory?ke(e.path):je(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]!==qe||t[152]!==tt||t[153]!==st||t[154]!==dt?(ft=(0,$.jsxs)(`div`,{className:qe,children:[tt,st,dt]}),t[151]=qe,t[152]=tt,t[153]=st,t[154]=dt,t[155]=ft):ft=t[155],ft},Dl=e=>{let t=(0,Q.c)(16),{name:n,path:r,directory:i,meta:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==r?(c=i?(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(Fn,{filePath:r,className:`size-5 shrink-0`}),t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:n}),t[4]=n,t[5]=l);let u;t[6]===a?u=t[7]:(u=a?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:a}):null,t[6]=a,t[7]=u);let d;t[8]===i?d=t[9]:(d=i?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null,t[8]=i,t[9]=d);let f;return t[10]!==o||t[11]!==c||t[12]!==l||t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-14 w-full items-center gap-3 border-b border-border/30 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:o,style:s,children:[c,l,u,d]}),t[10]=o,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f):f=t[15],f},Ol=e=>{let t=(0,Q.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=Te(),o=bl(ni()??null);if(r){let e;t[0]===a?e=t[1]:(e=a(`common.loading`),t[0]=a,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,$.jsx)(Nl,{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)(Nl,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(Dl,{name:xl(e.path),path:e.path,directory:!1,meta:Cl(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},kl=e=>{let t=(0,Q.c)(26),{path:n,canUseText:r,htmlViewMode:i,htmlFullscreen:a,onToggleHtmlViewMode:o,onEnterHtmlFullscreen:s,onCopyPath:c,onCopyContent:l}=e,{t:u}=Te(),d;t[0]===n?d=t[1]:(d=Ur(n),t[0]=n,t[1]=d);let f=d,p;t[2]!==r||t[3]!==f||t[4]!==a||t[5]!==i||t[6]!==s||t[7]!==o||t[8]!==u?(p=f&&r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:o,"aria-label":u(i===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:i===`preview`?`file-code`:`eye`,className:`size-4`})}),a?null:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:s,"aria-label":u(`mobile.files.html.fullscreenAria`),children:(0,$.jsx)(X,{name:`fullscreen`,className:`size-4`})})]}):null,t[2]=r,t[3]=f,t[4]=a,t[5]=i,t[6]=s,t[7]=o,t[8]=u,t[9]=p):p=t[9];let m;t[10]!==r||t[11]!==f||t[12]!==l||t[13]!==n||t[14]!==u?(m=r&&!Vr(n)&&!f?(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:l,"aria-label":u(`mobile.files.copyContentAria`),children:(0,$.jsx)(X,{name:`file-copy`,className:`size-4`})}):null,t[10]=r,t[11]=f,t[12]=l,t[13]=n,t[14]=u,t[15]=m):m=t[15];let h;t[16]!==r||t[17]!==f||t[18]!==c||t[19]!==n||t[20]!==u?(h=!r||Vr(n)||f?(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:c,"aria-label":u(`mobile.files.copyPathAria`),children:(0,$.jsx)(X,{name:`clipboard`,className:`size-4`})}):null,t[16]=r,t[17]=f,t[18]=c,t[19]=n,t[20]=u,t[21]=h):h=t[21];let g;return t[22]!==p||t[23]!==m||t[24]!==h?(g=(0,$.jsxs)($.Fragment,{children:[p,m,h]}),t[22]=p,t[23]=m,t[24]=h,t[25]=g):g=t[25],g},Al=e=>{let t=(0,Q.c)(90),{path:n,content:r,error:i,isLoading:a,isBinary:o,hideHeader:s,htmlViewMode:c,onHtmlViewModeChange:l,onBack:u,onCopyPath:d,onCopyContent:f}=e,p=s!==void 0&&s,{t:m}=Te(),h=Z.useRef(null),g=ni(),_=Vr(n)&&!n.toLowerCase().endsWith(`.svg`)?n:``,v;t[0]===n?v=t[1]:(v=Sl(n)??``,t[0]=n,t[1]=v);let y=Wr(_,v,`preview`),[b,x]=Z.useState(``),S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S={open:!1,title:``,content:``},t[2]=S):S=t[2];let[C,w]=Z.useState(S),T=y.source,E;t[3]===n?E=t[4]:(E=xl(n),t[3]=n,t[4]=E);let D=E,O;t[5]!==r||t[6]!==n?(O=Vr(n)?`data:${Hr(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||(Vr(n)&&r?k:``),t[8]=r,t[9]=k,t[10]=T,t[11]=n,t[12]=A):A=t[12];let j=A,M;t[13]!==i||t[14]!==b||t[15]!==y.error||t[16]!==j||t[17]!==m?(M=i??y.error??(j&&b===j?m(`filesView.error.readFileFailed`):null),t[13]=i,t[14]=b,t[15]=y.error,t[16]=j,t[17]=m,t[18]=M):M=t[18];let N=M,P;t[19]===j?P=t[20]:(P=()=>x(j),t[19]=j,t[20]=P);let F=q(P),I;t[21]!==D||t[22]!==_||t[23]!==n||t[24]!==j?(I=e=>{let t=_||j;t&&w({open:!0,title:D,content:``,previewSource:e.currentTarget.querySelector(`img`)??void 0,metadata:{tool:`image-preview`,filename:D,mime:Hr(n)},image:{url:t,mimeType:Hr(n),filename:D}})},t[21]=D,t[22]=_,t[23]=n,t[24]=j,t[25]=I):I=t[25];let L=q(I),R;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{w(t=>t.open===e?t:{...t,open:e})},t[26]=R):R=t[26];let ee=q(R),z;t[27]===n?z=t[28]:(z=Ur(n),t[27]=n,t[28]=z);let B=z,[V,te]=Z.useState(!1),H=Z.useRef(null),ne;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(ne=()=>{te(!1)},t[29]=ne):ne=t[29];let U;t[30]===n?U=t[31]:(U=[n],t[30]=n,t[31]=U),Z.useEffect(ne,U);let re;t[32]!==c||t[33]!==l?(re=()=>{l(c===`preview`?`source`:`preview`)},t[32]=c,t[33]=l,t[34]=re):re=t[34];let W=q(re),ie;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>{te(!0)},t[35]=ie):ie=t[35];let ae=q(ie),oe;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>(te(!1),!0),t[36]=oe):oe=t[36];let se=q(oe),ce=B&&V,le;t[37]!==se||t[38]!==ce?(le={id:`mobile-html-fullscreen`,active:ce,layer:`overlay`,onBack:se,surfaceRef:H},t[37]=se,t[38]=ce,t[39]=le):le=t[39],Fr(le);let ue=!o&&!a&&!i,G;t[40]!==ae||t[41]!==V||t[42]!==c||t[43]!==f||t[44]!==d||t[45]!==n||t[46]!==ue||t[47]!==W?(G=(0,$.jsx)(kl,{path:n,canUseText:ue,htmlViewMode:c,htmlFullscreen:V,onToggleHtmlViewMode:W,onEnterHtmlFullscreen:ae,onCopyPath:d,onCopyContent:f}),t[40]=ae,t[41]=V,t[42]=c,t[43]=f,t[44]=d,t[45]=n,t[46]=ue,t[47]=W,t[48]=G):G=t[48];let de=G,K;t[49]!==r||t[50]!==i||t[51]!==c||t[52]!==a||t[53]!==n||t[54]!==m?(K=c===`source`?a?(0,$.jsx)(Nl,{loading:!0,message:m(`filesView.state.loading`)}):i?(0,$.jsx)(Ga,{message:i}):(0,$.jsx)(Ml,{path:n,content:r}):(0,$.jsx)(jl,{path:n}),t[49]=r,t[50]=i,t[51]=c,t[52]=a,t[53]=n,t[54]=m,t[55]=K):K=t[55];let fe=K,pe;t[56]!==se||t[57]!==B||t[58]!==fe||t[59]!==V||t[60]!==c||t[61]!==D||t[62]!==m||t[63]!==W?(pe=B?(0,$.jsxs)(`div`,{ref:H,"data-mobile-html-preview":c===`preview`&&!V?`true`:void 0,"data-mobile-html-fullscreen":c===`preview`&&V?`true`:void 0,className:V?`fixed inset-0 z-[80] flex flex-col bg-background text-foreground`:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[V?(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-border/50 px-3 pb-2 pt-[max(0.5rem,env(safe-area-inset-top))]`,children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:se,"aria-label":m(`mobile.files.html.exitFullscreenAria`),className:`shrink-0 text-muted-foreground`,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-header text-foreground`,children:D}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:W,"aria-label":m(c===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:c===`preview`?`file-code`:`eye`,className:`size-4`})})]}):null,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden bg-background`,children:fe})]}):null,t[56]=se,t[57]=B,t[58]=fe,t[59]=V,t[60]=c,t[61]=D,t[62]=m,t[63]=W,t[64]=pe):pe=t[64];let me=pe,J=g??void 0,he;t[65]!==r||t[66]!==i||t[67]!==de||t[68]!==F||t[69]!==ee||t[70]!==p||t[71]!==B||t[72]!==V||t[73]!==me||t[74]!==N||t[75]!==D||t[76]!==C||t[77]!==y.loading||t[78]!==o||t[79]!==a||t[80]!==u||t[81]!==L||t[82]!==n||t[83]!==j||t[84]!==m?(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)(vr,{children:[s,de]}):(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":m(`header.actions.backAria`),onClick:u,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:D})}),s,de]}),(0,$.jsx)(`div`,{ref:h,className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:t??(o&&!a&&!i?(0,$.jsx)(Pa,{path:n},n):B&&!a&&!i?V&&typeof document<`u`?(0,_l.createPortal)(me,document.body):me:a||y.loading?Vr(n)?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-4`,children:(0,$.jsx)(Gr,{className:`aspect-square w-64 max-w-full rounded-lg`})}):(0,$.jsx)(Nl,{loading:!0,message:m(`filesView.state.loading`)}):N?(0,$.jsx)(Ga,{message:N}):Vr(n)&&j?(0,$.jsx)(Jr,{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)(Kr,{src:j,alt:D,className:`h-auto w-full rounded-lg object-contain`,draggable:!1,onError:F})})}):(0,$.jsx)(Ml,{path:n,content:r}))}),(0,$.jsx)(sn,{containerRef:h}),C.open?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(vl,{popup:C,onOpenChange:ee,isMobile:!0})}):null]})},t[65]=r,t[66]=i,t[67]=de,t[68]=F,t[69]=ee,t[70]=p,t[71]=B,t[72]=V,t[73]=me,t[74]=N,t[75]=D,t[76]=C,t[77]=y.loading,t[78]=o,t[79]=a,t[80]=u,t[81]=L,t[82]=n,t[83]=j,t[84]=m,t[85]=he):he=t[85];let ge;return t[86]!==n||t[87]!==J||t[88]!==he?(ge=(0,$.jsx)(yi,{path:n,base:J,children:he}),t[86]=n,t[87]=J,t[88]=he,t[89]=ge):ge=t[89],ge},jl=e=>{let t=(0,Q.c)(5),{path:n}=e,{projectScope:r}=ti(),i=ni(),a=r?.location.directory??i??``,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={backgroundColor:`var(--surface-background)`},t[0]=o):o=t[0];let s;return t[1]!==n||t[2]!==r||t[3]!==a?(s=(0,$.jsx)(Ki,{path:n,directory:a,entry:r,className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-background`,iframeClassName:`h-full min-h-0 w-full flex-1 border-none bg-background`,iframeStyle:o}),t[1]=n,t[2]=r,t[3]=a,t[4]=s):s=t[4],s},Ml=e=>{let t=(0,Q.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=Qt(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??dr(!1),t[0]=a,t[1]=o,t[2]=c):c=t[2];let l=c,u;t[3]!==a||t[4]!==s?(u=a.find(e=>e.metadata.id===s)??dr(!0),t[3]=a,t[4]=s,t[5]=u):u=t[5];let d=u,f,p;t[6]!==d||t[7]!==l?(f=()=>{Pr(l),Pr(d)},p=[d,l],t[6]=d,t[7]=l,t[8]=f,t[9]=p):(f=t[8],p=t[9]),Z.useEffect(f,p);let m;t[10]!==d.metadata.id||t[11]!==l.metadata.id?(m={light:l.metadata.id,dark:d.metadata.id},t[10]=d.metadata.id,t[11]=l.metadata.id,t[12]=m):m=t[12];let h=m;if(Tl(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Jr,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(mr,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=xl(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=Br(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:xi},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)(Jr,{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},Nl=e=>{let t=(0,Q.c)(7),{message:n,loading:r}=e,i=r!==void 0&&r,a;t[0]===i?a=t[1]:(a=i?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-open-fill`,className:`size-6 text-muted-foreground`}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s};function Pl(e){return e.pendingFileFocusPath}function Fl(e){return e.setPendingFileFocusPath}function Il(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}var Ll=S(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),Rl=36,zl=18,Bl=e=>e.parentID??null,Vl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Hl=e=>{let t=e;return Vl(t.directory??t.project?.worktree??null)},Ul=e=>{let t=Vl(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},Wl=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},Gl=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),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,t)=>{let n=Vl(e),r=Vl(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},Jl=(e,t)=>e.worktrees.find(e=>Vl(e.path)===t)??null,Yl=(e,t)=>t===e.path||!!Jl(e,t),Xl=(e,t)=>{let n=Vl(t);return n?e.find(e=>Yl(e,n))??null:null},Zl=(e,t,n)=>!n||`${e.title??``} ${e.id} ${Hl(e)} ${t}`.toLowerCase().includes(n),Ql=e=>{let t=(0,Q.c)(14),{project:n,size:r}=e,i=r===void 0?`md`:r,a=i===`sm`?`size-6 rounded-md`:`size-8 rounded-lg`,o=i===`sm`?`size-3.5`:`size-4`,s=n.icon?Zr[n.icon]:null,c=n.color?Qr[n.color]:void 0,l=s??`folder-open`,u;t[0]===c?u=t[1]:(u=c?{color:c}:void 0,t[0]=c,t[1]=u);let d;t[2]!==o||t[3]!==l||t[4]!==u?(d=(0,$.jsx)(X,{name:l,className:o,style:u}),t[2]=o,t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=d,p;t[6]===a?p=t[7]:(p=it(`flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,a),t[6]=a,t[7]=p);let m;t[8]!==f||t[9]!==n?(m=n.iconImage?(0,$.jsx)(Yr,{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},$l=e=>{let t=(0,Q.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=it(`flex size-5 shrink-0 items-center justify-center text-muted-foreground/70 transition-transform duration-150`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`span`,{"aria-hidden":!0,className:i,children:a}),t[3]=i,t[4]=o),o},eu=e=>{let t=(0,Q.c)(2),{ariaLabel:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`inline-block size-1.5 shrink-0 rounded-full bg-primary`,"aria-label":n}),t[0]=n,t[1]=r),r},tu=e=>{let t=(0,Q.c)(12),{onClick:n,className:r}=e,{t:i}=Te(),a;t[0]===i?a=t[1]:(a=i(`sessions.sidebar.project.actions.newWorktree`),t[0]=i,t[1]=a);let o=a,s;t[2]===r?s=t[3]:(s=it(`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,r),t[2]=r,t[3]=s);let c;t[4]===n?c=t[5]:(c=e=>{e.stopPropagation(),n()},t[4]=n,t[5]=c);let l,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l={touchAction:`manipulation`},u=(0,$.jsx)(X,{name:`node-tree`,className:`size-4`}),t[6]=l,t[7]=u):(l=t[6],u=t[7]);let d;return t[8]!==o||t[9]!==s||t[10]!==c?(d=(0,$.jsx)(`button`,{type:`button`,className:s,"aria-label":o,title:o,onClick:c,style:l,children:u}),t[8]=o,t[9]=s,t[10]=c,t[11]=d):d=t[11],d},nu=e=>{let t=(0,Q.c)(10),{icon:n,label:r,onClick:i,destructive:a}=e,o=a!==void 0&&a?`destructive`:`ghost`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(X,{name:n,className:`size-5 shrink-0 text-inherit`}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=l);let u;return t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(Y,{type:`button`,variant:o,size:`default`,className:`min-h-12 w-full justify-start gap-3 rounded-xl px-3 typography-ui-label`,onClick:i,style:s,children:[c,l]}),t[5]=i,t[6]=o,t[7]=c,t[8]=l,t[9]=u):u=t[9],u},ru=e=>{let t=(0,Q.c)(107),{session:n,active:r,indent:i,contextLabel:a,confirmingArchive:o,hasChildren:s,expanded:c,onToggleChildren:l,onSelect:u,onRequestArchive:d,onConfirmArchive:f,onStop:p,stopAriaLabel:m,longPressHandlers:h,highlightQuery:g}=e,_=o!==void 0&&o,v=s!==void 0&&s,y=c!==void 0&&c,{t:b}=Te(),x;t[0]===n?x=t[1]:(x=Kl(Wl(n)),t[0]=n,t[1]=x);let S=x,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,R,ee,z;if(t[2]!==r||t[3]!==_||t[4]!==y||t[5]!==v||t[6]!==g||t[7]!==i||t[8]!==h.onContextMenu||t[9]!==h.onPointerCancel||t[10]!==h.onPointerDown||t[11]!==h.onPointerMove||t[12]!==h.onPointerUp||t[13]!==h.pressed||t[14]!==u||t[15]!==l||t[16]!==n.title||t[17]!==b){z=n.title?.trim()||b(`mobile.sessions.untitled`);let e=r&&!_&&`bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]`,a=_&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`;t[36]!==e||t[37]!==a?(N=it(`relative flex items-center gap-1 transition-colors`,e,a),t[36]=e,t[37]=a,t[38]=N):N=t[38],t[39]!==y||t[40]!==v||t[41]!==i||t[42]!==l||t[43]!==b?(P=v&&l?(0,$.jsx)(`button`,{type:`button`,className:`absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,style:{left:Math.max(i-32,2),top:0,bottom:0,touchAction:`manipulation`},"aria-label":b(y?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:e=>{e.stopPropagation(),l()},children:(0,$.jsx)(X,{name:`arrow-down-s`,className:it(`size-[18px] transition-transform duration-150`,y?`rotate-0`:`-rotate-90`)})}):null,t[39]=y,t[40]=v,t[41]=i,t[42]=l,t[43]=b,t[44]=P):P=t[44],C=`button`;let o=_&&`opacity-50`,s=h.pressed&&`bg-interactive-active scale-[0.99]`;t[45]!==o||t[46]!==s?(w=it(`flex min-h-12 min-w-0 flex-1 items-center gap-2.5 py-2 pr-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o,s),t[45]=o,t[46]=s,t[47]=w):w=t[47],t[48]===i?T=t[49]:(T={paddingLeft:i,touchAction:`manipulation`},t[48]=i,t[49]=T),E=u,D=h.onPointerDown,O=h.onPointerMove,k=h.onPointerUp,A=h.onPointerCancel,j=h.onContextMenu,M=_,ee=`flex min-w-0 flex-1 flex-col`,L=`flex items-center gap-2.5`;let c=r?`bg-primary`:`bg-muted-foreground/30`,d;t[50]===c?d=t[51]:(d=it(`size-1.5 shrink-0 rounded-full`,c),t[50]=c,t[51]=d),t[52]===d?R=t[53]:(R=(0,$.jsx)(`span`,{className:d,"aria-hidden":!0}),t[52]=d,t[53]=R);let f=r?`text-primary`:`text-foreground`;t[54]===f?F=t[55]:(F=it(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),I=g?rr(z,g):z,t[2]=r,t[3]=_,t[4]=y,t[5]=v,t[6]=g,t[7]=i,t[8]=h.onContextMenu,t[9]=h.onPointerCancel,t[10]=h.onPointerDown,t[11]=h.onPointerMove,t[12]=h.onPointerUp,t[13]=h.pressed,t[14]=u,t[15]=l,t[16]=n.title,t[17]=b,t[18]=C,t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A,t[26]=j,t[27]=M,t[28]=N,t[29]=P,t[30]=F,t[31]=I,t[32]=L,t[33]=R,t[34]=ee,t[35]=z}else C=t[18],w=t[19],T=t[20],E=t[21],D=t[22],O=t[23],k=t[24],A=t[25],j=t[26],M=t[27],N=t[28],P=t[29],F=t[30],I=t[31],L=t[32],R=t[33],ee=t[34],z=t[35];let B;t[56]!==F||t[57]!==I?(B=(0,$.jsx)(`span`,{className:F,children:I}),t[56]=F,t[57]=I,t[58]=B):B=t[58];let V;t[59]===S?V=t[60]:(V=S?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:S}):null,t[59]=S,t[60]=V);let te;t[61]!==B||t[62]!==V||t[63]!==L||t[64]!==R?(te=(0,$.jsxs)(`span`,{className:L,children:[R,B,V]}),t[61]=B,t[62]=V,t[63]=L,t[64]=R,t[65]=te):te=t[65];let H;t[66]!==a||t[67]!==g?(H=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?rr(a,g):a}):null,t[66]=a,t[67]=g,t[68]=H):H=t[68];let ne;t[69]!==te||t[70]!==H||t[71]!==ee?(ne=(0,$.jsxs)(`span`,{className:ee,children:[te,H]}),t[69]=te,t[70]=H,t[71]=ee,t[72]=ne):ne=t[72];let U;t[73]!==C||t[74]!==w||t[75]!==T||t[76]!==E||t[77]!==D||t[78]!==O||t[79]!==k||t[80]!==A||t[81]!==j||t[82]!==M||t[83]!==ne?(U=(0,$.jsx)(`button`,{type:C,className:w,style:T,onClick:E,onPointerDown:D,onPointerMove:O,onPointerUp:k,onPointerCancel:A,onContextMenu:j,disabled:M,children:ne}),t[73]=C,t[74]=w,t[75]=T,t[76]=E,t[77]=D,t[78]=O,t[79]=k,t[80]=A,t[81]=j,t[82]=M,t[83]=ne,t[84]=U):U=t[84];let re;t[85]!==p||t[86]!==m?(re=p?(0,$.jsx)(`button`,{type:`button`,className:`mr-0.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":m,onClick:e=>{e.stopPropagation(),p()},style:{touchAction:`manipulation`},children:(0,$.jsx)($i,{})}):null,t[85]=p,t[86]=m,t[87]=re):re=t[87];let W;t[88]===b?W=t[89]:(W=b(`sessions.sidebar.session.menu.label`),t[88]=b,t[89]=W);let ie;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(X,{name:`more-2`,className:`size-4`}),t[90]=ie):ie=t[90];let ae;t[91]!==h.onOpenActions||t[92]!==W?(ae=(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,"data-session-drag-ignore":!0,"aria-label":W,onClick:h.onOpenActions,children:ie}),t[91]=h.onOpenActions,t[92]=W,t[93]=ae):ae=t[93];let oe;t[94]!==_||t[95]!==f||t[96]!==d||t[97]!==b||t[98]!==z?(oe=d?(0,$.jsxs)($.Fragment,{children:[_?(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 shrink-0 items-center gap-1.5 rounded-xl bg-destructive px-3 text-destructive-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,"aria-label":b(`mobile.sessions.archiveSessionAria`,{title:z}),onClick:f,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`archive`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:b(`sessions.sidebar.bulkActions.archive`)})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`mr-1.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":b(_?`mobile.sessions.cancelArchiveAria`:`mobile.sessions.archiveSessionAria`,{title:z}),onClick:d,style:{touchAction:`manipulation`},children:_?(0,$.jsx)(X,{name:`close`,className:`size-4`}):(0,$.jsx)(X,{name:`archive`,className:`size-4`})})]}):null,t[94]=_,t[95]=f,t[96]=d,t[97]=b,t[98]=z,t[99]=oe):oe=t[99];let se;return t[100]!==N||t[101]!==P||t[102]!==U||t[103]!==re||t[104]!==ae||t[105]!==oe?(se=(0,$.jsxs)(`div`,{className:N,children:[P,U,re,ae,oe]}),t[100]=N,t[101]=P,t[102]=U,t[103]=re,t[104]=ae,t[105]=oe,t[106]=se):se=t[106],se},iu=e=>{let t=(0,Q.c)(15),{indent:n,showMore:r,showFewer:i,loadingMore:a,onShowMore:o,onShowFewer:s}=e,c=a!==void 0&&a,{t:l}=Te();if(!r&&!i)return null;let u;t[0]===n?u=t[1]:(u={paddingLeft:n,touchAction:`manipulation`},t[0]=n,t[1]=u);let d;t[2]!==s||t[3]!==i||t[4]!==l?(d=i?(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:s,children:[(0,$.jsx)(X,{name:`arrow-up-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showFewer`)})]}):null,t[2]=s,t[3]=i,t[4]=l,t[5]=d):d=t[5];let f;t[6]!==c||t[7]!==o||t[8]!==r||t[9]!==l?(f=r?(0,$.jsxs)(`button`,{type:`button`,className:it(`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-60`,c&&`animate-pulse`),onClick:o,disabled:c,children:[(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showMore`)})]}):null,t[6]=c,t[7]=o,t[8]=r,t[9]=l,t[10]=f):f=t[10];let p;return t[11]!==u||t[12]!==d||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-h-10 w-full items-center gap-3 py-1.5 pr-3 text-muted-foreground`,style:u,children:[d,f]}),t[11]=u,t[12]=d,t[13]=f,t[14]=p):p=t[14],p},au=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=Te(),{git:i}=se(),a=bt(),o=rt(),s=Lt(e=>e.activeSessions),c=Lt(e=>e.activePaginationByDirectory),l=Ue(e=>e.projects),u=Z.useMemo(()=>l.filter(e=>!e.hostId),[l]),d=l.some(e=>!!e.hostId),f=Xt(e&&d),p=f.catalog?.projects??[],m=Ue(e=>e.activeProjectId),h=O(e=>e.currentDirectory),g=Ot(e=>e.currentSessionId),_=Ot(e=>e.availableWorktreesByProject),v=Ot(e=>e.setCurrentSession),y=Ot(e=>e.archiveSession),b=Ot(e=>e.archiveSessions),x=Ot(e=>e.updateSessionTitle),S=Ot(e=>e.requestSessionSmartTitle),C=Ot(e=>e.shareSession),w=Ot(e=>e.unshareSession),T=Ot(e=>e.openNewSessionDraft),E=Ue(e=>e.setActiveProject),D=Ue(e=>e.setActiveProjectIdOnly),k=Ue(e=>e.removeProject),A=mt();Bi();let j=dt(e=>e.sessionOrderByScope),M=dt(e=>e.sessionOrderActivityByScope),N=zt(),P=wi(e=>e.projectExpanded),F=wi(e=>e.worktreeExpanded),I=wi(e=>e.setProjectExpanded),L=wi(e=>e.setWorktreeExpanded),R=St(e=>e.orderByProject),ee=Ll(e=>e.expandedParents),z=Ll(e=>e.toggleParent),[B,V]=Z.useState(``),[te,H]=Z.useState(null),[ne,U]=Z.useState(null),[re,W]=Z.useState(0),[ie,ae]=Z.useState(!1),[oe,ce]=Z.useState(!1),[le,ue]=Z.useState(null),[G,de]=Z.useState(null),K=G?.kind===`session`?G.session:null,{unread:fe,onToggleRead:pe}=fa(K,K?Hl(K):void 0),[me,J]=Z.useState(null),[he,ge]=Z.useState(null),[_e,ve]=Z.useState(null),[ye,be]=Z.useState(``),[xe,Se]=Z.useState(!1),[Ce,we]=Z.useState(null),Ee=Z.useRef(null);Ee.current||=ha({onPressedKeyChange:ge});let[De,Oe]=Z.useState(new Set),[ke,Ae]=Z.useState(new Map),[je,Me]=Z.useState(new Map),Ne=Wi(),Pe=Ma(),Fe=q(e=>{zr(e),nt(e)}),Ie=q(e=>{Promise.all(e.map(e=>(zr(e),nt(e))))});Z.useEffect(()=>{if(!e){V(``),Me(new Map),H(null),U(null),de(null),ve(null),we(null),Ee.current?.reset();return}},[e]),Z.useEffect(()=>()=>{Ee.current?.reset()},[]),Z.useEffect(()=>{if(!e)return;if(u.length===0){Ot.setState(e=>{let t=aa(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),Oe(e=>e.size===0?e:new Set),Ae(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(u.map(async e=>{let n=Vl(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([$r({id:e.id,path:n},{isCurrent:()=>!t}),Xr(n)]);return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:a.status===`fulfilled`?`success`:`failed`,worktrees:a.status===`fulfilled`?a.value.worktrees:void 0,rootBranchStatus:o.status===`fulfilled`?`success`:`failed`,rootBranch:o.status===`fulfilled`?o.value:void 0}}));if(t)return;let n=new Set(u.map(e=>Vl(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);Ot.setState(e=>{let t=aa(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),Oe(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 Gl(r,t)?t:r}),Ae(t=>{let n=new Set(u.map(e=>e.id)),r=new Map([...t].filter(([e])=>n.has(e)));for(let t of e){if(!t||t.gitStatus!==`success`)continue;if(!t.isGitRepo){r.delete(t.id);continue}if(t.rootBranchStatus!==`success`)continue;let e=t.rootBranch?.trim();e&&e!==`HEAD`?r.set(t.id,e):r.delete(t.id)}return r.size===t.size&&[...r].every(([e,n])=>t.get(e)===n)?t:r})})(),()=>{t=!0}},[i,e,u,re]);let Le=Z.useMemo(()=>u.map(e=>({id:e.id,label:Ul(e.path),path:Vl(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:De.has(Vl(e.path)),worktrees:Ct(R[e.id],_.get(Vl(e.path))??[])})),[De,u,R,_]),Re=Z.useMemo(()=>{let e=new Map(o.map(e=>[e.id,e])),t=s.map(t=>{let n=e.get(t.id);return n?gt(n,t):t}),n=new Set(t.map(e=>e.id));for(let e of o)n.has(e.id)||t.push(e);return t},[s,o]),ze=B.trim().toLowerCase(),Be=Z.useMemo(()=>{let e=Le.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===m})),t=(e,t,n)=>{let r=Vl(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||Ul(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 Re){let r=Hl(n);if(!r)continue;let i=Vl(r),a=e.find(e=>Yl(e.project,i));if(!a)continue;let o=Jl(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=Vl(e.path),r=bi(e.sessions.map(e=>({session:e})),j[n],M[n],A);e.sessions.sort((e,t)=>r({session:e},{session:t}));for(let n of e.sessions)Bl(n)||(t.totalSessions+=1)}return e},[m,Le,Re,j,M,A]),Ve=Vl(h),He=e=>e.isActive?Ve===e.project.path?e.project.path:e.project.worktrees.find(e=>ql(Ve,e.path))?.path??e.project.path:null,We=e=>P[e.project.id]??!0,Ge=(e,t)=>F[`${e.project.id}::${t.key}`]??!1,Ke=e=>{Me(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},qe=()=>{de(null),Ee.current?.reset()},Je=e=>({onOpenActions:()=>de(e),pressed:he===e.key||G?.key===e.key,onPointerDown:t=>{e.kind!==`session`&&(t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||Ee.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>de(e)}))},onPointerMove:e=>{Ee.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{Ee.current?.end(e.pointerId)},onPointerCancel:e=>{Ee.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),e.kind!==`session`&&Ee.current?.openFromContextMenu(e.key,()=>de(e))}}),Ye=(e,t)=>{Ee.current?.consumeClick(e)||t()},Xe=(e,t,n,r)=>{let i=ma(),a=Aa();if(Me(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=Vl(t);if(!o)return;let s=Lt.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&Ft(o)},Ze=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=ma(),o=new Set(t.sessions.map(e=>e.id)),s=new Map;for(let e of t.sessions){let t=Bl(e);if(t&&o.has(t)){let n=s.get(t)??[];n.push(e),s.set(t,n)}}let l=t.sessions.filter(e=>!Bl(e)),u=je.get(i)??a,d=Na(l,u,Pe),f=l.length-d.length,p=c.get(Vl(t.path)),m=p?.hasMore===!0,h=p?.loadingMore===!0,_=l.length>a&&u>a,v=(e,t)=>{let n=s.get(e.id)??[],i=n.length>0,a=!!ee[e.id],o=Ne.has(e.id),c=i&&!a?n.filter(e=>Ne.has(e.id)).map(e=>e.id):[],l=c.length>0,u=o?[e.id,...c]:c,d=e.title?.trim()||r(`mobile.sessions.untitled`),f=`session:${e.id}`;return(0,$.jsxs)(Z.Fragment,{children:[(0,$.jsx)(ru,{session:e,active:g===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>z(e.id):void 0,confirmingArchive:ne===e.id,onSelect:()=>Ye(f,()=>tt(e)),onRequestArchive:()=>ot(e.id),onConfirmArchive:()=>void st(e),onStop:o||l?()=>Ie(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:d}),longPressHandlers:Je({key:f,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+zl)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[l.length===0&&!m&&!h?(0,$.jsx)(`div`,{className:`py-1.5 pr-3 typography-ui-label font-normal text-muted-foreground/80`,style:{paddingLeft:n},children:r(`sessions.sidebar.group.empty.noSessionsInWorkspace`)}):null,(0,$.jsx)(Pi,{scopeKey:ne?null:Vl(t.path),sessionIds:d.map(e=>e.id),folderIdBySessionId:new Map(d.map(e=>[e.id,dt.getState().getSessionFolderId(Vl(t.path),e.id)])),onSessionDroppedOnFolder:()=>{},onSessionsReordered:(e,n)=>{dt.getState().reorderSessions(Vl(t.path),d.map(e=>e.id),e,n,Hi(t.sessions)).catch(()=>at.error(r(`sessions.order.saveFailed`)))},children:d.map(e=>ne?v(e,n):(0,$.jsx)(Oi,{sessionId:e.id,sessionDirectory:t.path,sessionTitle:e.title??``,children:v(e,n)},e.id))}),(0,$.jsx)(iu,{indent:n,showMore:f>0||m,showFewer:_,loadingMore:h,onShowMore:()=>Xe(i,t.path,u,l.length),onShowFewer:()=>Ke(i)})]})},Qe=(e,t)=>{I(e,!t)},et=(e,t,n)=>{L(`${e}::${t}`,!n)},tt=e=>{gr();let n=Hl(e)||null,r=Xl(Le,n??``);r&&D(r.id),v(e.id,n),t(!1)},ot=e=>{U(t=>t===e?null:e)},st=async e=>{U(null),await y(e.id)?la({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`)}):at.error(r(`sessions.sidebar.session.archive.error`))},lt=()=>{T(),t(!1)},ft=e=>{ue(e),D(e),ce(!0)},pt=e=>{let t=new Map;for(let e of Re){let n=Bl(e);if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n},ht=async e=>{let t=pt(e.id),{archivedIds:n,failedIds:i}=await b(t);n.length>0&&la({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&&at.error(i.length===1?r(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):r(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}))},_t=e=>{let t=pt(e.id);ua({sessionIds:t,message:t.length===1?r(`sessions.sidebar.session.delete.success`):r(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:r(`sessions.sidebar.undo`),commitFailedMessage:r(`sessions.sidebar.session.delete.error`)})},vt=async e=>{try{if(!(await C(e.id))?.share?.url){at.error(r(`sessions.sidebar.session.share.error`));return}at.success(r(`sessions.sidebar.session.share.successTitle`),{description:r(`sessions.sidebar.session.share.successDescription`)})}catch{at.error(r(`sessions.sidebar.session.share.error`))}},yt=async e=>{if((await ct(e)).ok){at.success(r(`sessions.sidebar.session.menu.copied`));return}at.error(r(`sessions.sidebar.session.share.copyUrlError`))},xt=async e=>{try{if(await w(e)){at.success(r(`sessions.sidebar.session.unshare.success`));return}at.error(r(`sessions.sidebar.session.unshare.error`))}catch{at.error(r(`sessions.sidebar.session.unshare.error`))}},wt=async()=>{if(!_e)return;let e=ye.trim();if(e)try{await x(_e.id,e),ve(null),be(``)}catch{at.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},Tt=async()=>{if(!_e||xe)return;let e=_e.id;ve(null),be(``),Se(!0);try{await S(e)}catch{at.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{Se(!1)}},Et=(e,n)=>{D(e.id),T({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},Dt=e=>{(async()=>{try{await $r({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=Ot.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await ut(n,Re)})()},kt=e=>{let t=Hl(e),n=Xl(Le,t);if(!n)return Ul(t)||t;let r=Jl(n,Vl(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},At=e=>{E(e.id),t(!1)},jt=Z.useMemo(()=>ze?Be.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(ze)?!0:e.buckets.some(t=>t.sessions.some(t=>Zl(t,e.project.label,ze)))):Be,[ze,Be]),Mt=Z.useMemo(()=>ze?Re.filter(e=>{let t=Hl(e);return Zl(e,Xl(Le,t)?.label??``,ze)}).sort((e,t)=>$e(t)-$e(e)):[],[ze,Le,Re]),Nt=Z.useMemo(()=>ze?Le.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(ze)).map(e=>({...e,sessionCount:Re.filter(t=>!Bl(t)&&Yl(e,Vl(Hl(t)))).length})):[],[ze,Le,Re]),Pt=ze&&Mt.length===0&&Nt.length===0,It=Le.length>0?(0,$.jsxs)(Y,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:lt,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,Rt=Le.find(e=>e.id===m)??null,Bt=Rt?.isGitRepo?(0,$.jsx)(Y,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>ft(Rt.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`node-tree`,className:`size-4`})}):null,Vt=(0,$.jsx)(Y,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>ae(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folder-add`,className:`size-4`})}),Ht=It||Vt?(0,$.jsxs)($.Fragment,{children:[It,Bt,Vt]}):null,Ut=G?.kind===`project`?G.project.label:G?.kind===`worktree`?G.worktree.branch||G.worktree.label||G.worktree.path:G?.kind===`session`?G.session.title?.trim()||r(`mobile.sessions.untitled`):``,Wt=Z.useMemo(()=>{if(!G)return[];if(G.kind===`project`){let e=G.project;return ta({gitRepository:e.isGitRepo,onNewSession:()=>{qe(),Et(e,e.path)},onNewWorktree:()=>{qe(),ft(e.id)},onSyncSessions:()=>{qe(),Dt(e)},onEditProject:()=>{qe(),H(e.id)},onCloseProject:()=>{qe(),J(e)}})}if(G.kind===`worktree`){let{project:e,worktree:t}=G;return Ea({onNewSession:()=>{qe(),Et(e,t.path)},onDeleteWorktree:()=>{qe(),we({project:e,worktree:t})}})}let e=G.session,t=!!e.share?.url;return ya({pinned:A.has(e.id),shared:t,unread:fe,onToggleRead:pe?()=>{qe(),pe()}:void 0,onRename:()=>{qe(),be(e.title?.trim()||r(`mobile.sessions.untitled`)),ve(e)},onTogglePin:()=>{qe(),N(e.id)},onShare:!a||t?void 0:()=>{qe(),vt(e)},onCopyLink:a&&t?()=>{let t=e.share?.url;qe(),t&&yt(t)}:void 0,onUnshare:a&&t?()=>{qe(),xt(e.id)}:void 0,onArchive:()=>{qe(),ht(e)},onDelete:()=>{qe(),_t(e)}})},[G,fe,qe,ht,yt,_t,ft,vt,xt,pe,A,Et,Dt,r,N]),Gt=Wt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Wt.map(e=>{let t=(0,$.jsx)(nu,{icon:e.icon,label:ra(e,r),destructive:e.destructive,onClick:e.onClick},e.id);return e.separated?(0,$.jsx)(`div`,{className:G?.kind===`project`?`border-t border-[var(--yuri-popup-divider)]`:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:t},e.id):t})}):null,Kt=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Kn,{value:B,onChange:e=>V(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:it(`h-11 pl-9`,B&&`pr-10`)}),B?(0,$.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":r(`mobile.sessions.clearSearchAria`),onClick:()=>V(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsxs)(Jr,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:[d&&f.registry&&p.map(e=>(0,$.jsx)(ea,{project:e,registry:f.registry,search:B,mobile:!0,reorderEnabled:!1},e.id)),Le.length===0&&!d?(0,$.jsx)(ou,{title:r(`mobile.sessions.empty.noProjectsTitle`),description:r(`mobile.sessions.empty.noProjectsDescription`),action:(0,$.jsxs)(Y,{type:`button`,size:`lg`,onClick:()=>ae(!0),children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):Pt&&!d?(0,$.jsx)(ou,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):ze?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 pt-2`,children:[Mt.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.sessions`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:Mt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Mt.map((e,t)=>{let n=Ne.has(e.id),i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:it(t>0&&`border-t border-border/30`),children:(0,$.jsx)(ru,{session:e,active:g===e.id,indent:12,contextLabel:kt(e),highlightQuery:ze,onSelect:()=>Ye(`session:${e.id}`,()=>tt(e)),longPressHandlers:Je({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>Fe(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,Nt.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.projects`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:Nt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Nt.map((e,t)=>{let n=`project:${e.id}`,r=Je({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:it(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:it(`flex min-h-14 min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,r.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(n,()=>At(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Ql,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:rr(e.label,ze)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(tu,{className:`mr-2`,onClick:()=>ft(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:jt.map((e,t)=>{let n=We(e),i=`project:${e.project.id}`,a=Je({key:i,kind:`project`,project:e.project}),o=ze?e.buckets.filter(t=>t.sessions.some(t=>Zl(t,e.project.label,ze))):e.buckets,s=He(e);return(0,$.jsxs)(`section`,{className:it(t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`div`,{className:`flex min-h-14 w-full items-center`,children:[(0,$.jsxs)(`button`,{type:`button`,className:it(`flex min-h-14 min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,a.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(i,()=>Qe(e.project.id,n)),onPointerDown:a.onPointerDown,onPointerMove:a.onPointerMove,onPointerUp:a.onPointerUp,onPointerCancel:a.onPointerCancel,onContextMenu:a.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:e.project.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)(Ql,{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}),ke.get(e.project.id)?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:ke.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(eu,{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=>Ne.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(),Ie(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)($i,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(tu,{className:`mr-2`,onClick:()=>ft(e.project.id)}):null]}),n?(0,$.jsx)(`div`,{className:`pb-2`,children:(()=>{let t=o.find(e=>e.worktree===null),n=o.filter(e=>e.worktree!==null);return(0,$.jsxs)($.Fragment,{children:[t&&(t.sessions.length>0||n.length===0)?Ze(e,t,Rl):null,n.map(t=>{let n=Ge(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Je({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:it(`flex min-h-11 w-full items-center gap-2 py-1.5 pl-4 pr-3 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>Ye(a,()=>et(e.project.id,t.key,n)),onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onPointerCancel:o.onPointerCancel,onContextMenu:o.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:t.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)($l,{expanded:n}),(0,$.jsx)(X,{name:`node-tree`,className:it(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:it(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(eu,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>Ne.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(),Ie(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)($i,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?Ze(e,t,Rl):null]},t.key)})]})})()}):null]},e.project.id)})})]}),(0,$.jsx)(Zi,{open:ie,onOpenChange:ae,forceMobile:!0}),(0,$.jsx)(Pn,{open:oe,projectId:le,onOpenChange:e=>{ce(e),e||ue(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?v(n.sessionId,e):T({selectedProjectId:le,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(ir,{open:!!G,title:Ut,onClose:qe,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Gt}),(0,$.jsx)(ir,{open:!!me,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>J(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>J(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!me)return;let e=me;J(null),k(e.id),at.success(r(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:r(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:r(`mobile.projects.closeConfirmMessage`,{title:me?.label??``})})}),(0,$.jsx)(ir,{open:!!_e,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{xe||(ve(null),be(``))},footer:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`default`,className:`flex-1`,disabled:xe,onClick:()=>{ve(null),be(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{type:`button`,variant:`default`,className:`flex-1`,disabled:!ye.trim()||xe,onClick:()=>void wt(),children:r(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),wt()},children:[(0,$.jsx)(Kn,{value:ye,onChange:e=>be(e.target.value),autoFocus:!0,className:`h-12`,disabled:xe}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:xe,onClick:()=>void Tt(),children:[xe?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),r(`sessions.sidebar.session.rename.smartTitle`)]})]})}),Ce?(0,$.jsx)(ba,{open:!0,project:{id:Ce.project.id,path:Ce.project.path},worktree:Ce.worktree,onClose:()=>we(null),onDeleted:()=>W(e=>e+1)}):null,(0,$.jsx)(ca,{open:te!==null,project:Le.find(e=>e.id===te)??null,onClose:()=>H(null),onWorktreesChanged:()=>W(e=>e+1)})]});return n===`sidebar`?e?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsx)(`div`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center justify-end gap-2 px-4`,children:Ht?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:Ht}):null}),Kt]}):null:(0,$.jsx)(br,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:Ht,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:Kt})},ou=e=>{let t=(0,Q.c)(10),{title:n,description:r,action:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i?(0,$.jsx)(`div`,{className:`pt-2`,children:i}):null,t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c},su=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,cu=[{image:Ic,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:Fc,titleKey:`assistants.guide.share.android.title`,descriptionKey:`assistants.guide.share.android.description`},{image:Lc,titleKey:`assistants.guide.share.pick.title`,descriptionKey:`assistants.guide.share.pick.description`}];function lu(){let e=(0,Q.c)(8),{t}=Te(),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 uu(e){let t=(0,Q.c)(35),{onEnable:n}=e,{t:r}=Te(),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:su,alt:``})}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=r(`assistants.guide.disabledTitle`),t[1]=r,t[2]=a);let o;t[3]===a?o=t[4]:(o=(0,$.jsx)(`h2`,{className:`yuri-mobile-assistant-guide-title`,children:a}),t[3]=a,t[4]=o);let s;t[5]===r?s=t[6]:(s=r(`assistants.guide.disabledDescription`),t[5]=r,t[6]=s);let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(`p`,{className:`yuri-mobile-assistant-guide-description`,children:s}),t[7]=s,t[8]=c);let l;t[9]===r?l=t[10]:(l=r(`assistants.guide.enableAction`),t[9]=r,t[10]=l);let u;t[11]!==n||t[12]!==l?(u=(0,$.jsx)(Y,{type:`button`,size:`lg`,onClick:n,children:l}),t[11]=n,t[12]=l,t[13]=u):u=t[13];let d;t[14]!==o||t[15]!==c||t[16]!==u?(d=(0,$.jsxs)(`div`,{className:`yuri-mobile-assistant-guide-body`,children:[o,c,u]}),t[14]=o,t[15]=c,t[16]=u,t[17]=d):d=t[17];let f;t[18]===r?f=t[19]:(f=r(`assistants.guide.shareTitle`),t[18]=r,t[19]=f);let p;t[20]===f?p=t[21]:(p=(0,$.jsx)(`h3`,{className:`yuri-mobile-assistant-guide-share-title`,children:f}),t[20]=f,t[21]=p);let m;t[22]===r?m=t[23]:(m=r(`assistants.guide.shareAria`),t[22]=r,t[23]=m);let h;t[24]===r?h=t[25]:(h=cu.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 du(e){let t=(0,Q.c)(51),{assistant:n,avatarSeed:r,unreadCount:i,assistantID:a,displayName:o,summary:s,editLabel:c,deleteLabel:l,onOpen:u,onEdit:d,onDelete:f,serverWorking:p}=e,m=gi(a,p!==void 0&&p),h=Ui(`assistant:${a}`,u),g=Z.useRef(null),_;t[0]!==c||t[1]!==d?(_={label:c,icon:`edit`,onClick:d},t[0]=c,t[1]=d,t[2]=_):_=t[2];let v;t[3]!==l||t[4]!==f?(v={label:l,icon:`delete-bin`,destructive:!0,onClick:f},t[3]=l,t[4]=f,t[5]=v):v=t[5];let y;t[6]!==_||t[7]!==v?(y=[_,v],t[6]=_,t[7]=v,t[8]=y):y=t[8];let b;t[9]!==h||t[10]!==y?(b=(0,$.jsx)(Si,{swipe:h,actions:y}),t[9]=h,t[10]=y,t[11]=b):b=t[11];let x=h.dragging?`transition-none`:`transition-transform duration-150 ease-out`,S;t[12]===x?S=t[13]:(S=it(`yuri-mobile-assistant-card relative z-10 motion-reduce:transition-none`,x),t[12]=x,t[13]=S);let C=h.handleSelect,w=h.handlePointerDown,T=h.handlePointerMove,E=h.finishGesture,D=h.handlePointerCancel,O=`translate3d(${h.offset}px, 0, 0)`,k=h.offset===0?void 0:`transform`,A;t[14]!==O||t[15]!==k?(A={touchAction:`pan-y`,transform:O,willChange:k},t[14]=O,t[15]=k,t[16]=A):A=t[16];let j;t[17]!==a||t[18]!==r||t[19]!==o||t[20]!==m?(j=(0,$.jsx)(`span`,{className:`yuri-mobile-assistant-avatar`,children:(0,$.jsx)(_i,{name:a,avatarSeed:r,size:44,label:o,working:m,hoverTarget:g})}),t[17]=a,t[18]=r,t[19]=o,t[20]=m,t[21]=j):j=t[21];let M;t[22]===o?M=t[23]:(M=(0,$.jsx)(`span`,{className:`yuri-mobile-entity-title yuri-mobile-assistant-name block min-w-0 truncate font-semibold text-foreground`,children:o}),t[22]=o,t[23]=M);let N;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(N=it(`yuri-mobile-assistant-summary`,no),t[24]=N):N=t[24];let P;t[25]===s?P=t[26]:(P=(0,$.jsx)(`span`,{className:N,children:s}),t[25]=s,t[26]=P);let F;t[27]!==M||t[28]!==P?(F=(0,$.jsxs)(`span`,{className:`yuri-mobile-assistant-card-content min-w-0 flex-1`,children:[M,P]}),t[27]=M,t[28]=P,t[29]=F):F=t[29];let I;t[30]===i?I=t[31]:(I=(0,$.jsx)(Ya,{count:i}),t[30]=i,t[31]=I);let L;t[32]!==h.finishGesture||t[33]!==h.handlePointerCancel||t[34]!==h.handlePointerDown||t[35]!==h.handlePointerMove||t[36]!==h.handleSelect||t[37]!==A||t[38]!==j||t[39]!==F||t[40]!==I||t[41]!==S?(L=(0,$.jsxs)(`button`,{ref:g,type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-feedback":`soft`,className:S,onClick:C,onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:D,style:A,children:[j,F,I]}),t[32]=h.finishGesture,t[33]=h.handlePointerCancel,t[34]=h.handlePointerDown,t[35]=h.handlePointerMove,t[36]=h.handleSelect,t[37]=A,t[38]=j,t[39]=F,t[40]=I,t[41]=S,t[42]=L):L=t[42];let R;t[43]!==n||t[44]!==f||t[45]!==d||t[46]!==L?(R=(0,$.jsx)($a,{assistant:n,onEdit:d,onDelete:f,trigger:L}),t[43]=n,t[44]=f,t[45]=d,t[46]=L,t[47]=R):R=t[47];let ee;return t[48]!==R||t[49]!==b?(ee=(0,$.jsxs)(pi,{className:`yuri-mobile-assistant-card-shell relative isolate overflow-clip`,children:[b,R]}),t[48]=R,t[49]=b,t[50]=ee):ee=t[50],ee}function fu(e){let t=(0,Q.c)(128),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=Te(),o=Sr(),s=Re(),c=Be();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=Xa(l),t[2]=l,t[3]=u);let d=u,f=Vt(pu),[p,m]=Z.useState(null),h;t[4]===n?h=t[5]:(h=()=>n(),t[4]=n,t[5]=h);let g=q(h),_;t[6]!==o||t[7]!==f?(_=()=>{f(),o?.openSettings(`assistants`)},t[6]=o,t[7]=f,t[8]=_):_=t[8];let v=q(_),y;t[9]===r?y=t[10]:(y=e=>r(e),t[9]=r,t[10]=y);let b=q(y),x;t[11]===o?x=t[12]:(x=e=>{Ut(e,o?{openMobileSettings:o.openSettings}:void 0)},t[11]=o,t[12]=x);let S=q(x),C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{m(e)},t[13]=C):C=t[13];let w=q(C),T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{e||m(null)},t[14]=T):T=t[14];let E=q(T),D;t[15]===a?D=t[16]:(D=a(`assistants.title`),t[15]=a,t[16]=D);let O=D,k;t[17]===a?k=t[18]:(k=a(`assistants.menu.edit`),t[17]=a,t[18]=k);let A=k,j;t[19]===a?j=t[20]:(j=a(`assistants.settings.delete`),t[19]=a,t[20]=j);let M=j,N;t[21]===i?N=t[22]:(N=it(`yuri-assistant-mobile-catalog-page`,i),t[21]=i,t[22]=N);let P=N;if(s.isPending||s.data?.supported&&s.data.enabled&&c.isPending){let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(pi,{className:`yuri-mobile-assistant-loading`,children:(0,$.jsx)(lu,{})}),t[23]=e):e=t[23];let n;return t[24]!==P||t[25]!==O?(n=(0,$.jsx)(di,{title:O,className:P,surface:!1,children:e}),t[24]=P,t[25]=O,t[26]=n):n=t[26],n}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length>0){let e;t[27]===c.data?e=t[28]:(e=(0,$.jsx)(to,{snapshot:c.data,compact:!0,mobile:!0}),t[27]=c.data,t[28]=e);let n;t[29]===a?n=t[30]:(n=a(`assistants.settings.create`),t[29]=a,t[30]=n);let r;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(X,{name:`add`,className:`size-5`}),t[31]=r):r=t[31];let i;t[32]!==v||t[33]!==n?(i=(0,$.jsx)(Y,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:`yuri-mobile-inverse-action`,"aria-label":n,onClick:v,children:r}),t[32]=v,t[33]=n,t[34]=i):i=t[34];let o;t[35]!==e||t[36]!==i?(o=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e,i]}),t[35]=e,t[36]=i,t[37]=o):o=t[37];let s;t[38]===a?s=t[39]:(s=a(`assistants.listAria`),t[38]=a,t[39]=s);let l;t[40]!==d.pinned||t[41]!==S||t[42]!==b||t[43]!==w?(l=(0,$.jsx)(ro,{contacts:d.pinned,onSelect:b,onEdit:S,onDelete:w}),t[40]=d.pinned,t[41]=S,t[42]=b,t[43]=w,t[44]=l):l=t[44];let u;if(t[45]!==d.unpinned||t[46]!==M||t[47]!==A||t[48]!==S||t[49]!==b||t[50]!==w||t[51]!==a){let e;t[53]!==M||t[54]!==A||t[55]!==S||t[56]!==b||t[57]!==w||t[58]!==a?(e=e=>{let t=Wt(e.name).displayName||e.name,n=eo(e.latestMessagePreview,a);return(0,$.jsx)(du,{assistant:e,assistantID:e.id,avatarSeed:e.avatarSeed,unreadCount:e.unreadCount??0,displayName:t,summary:n,editLabel:A,deleteLabel:M,assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onOpen:()=>b(e.id),onEdit:()=>S(e.id),onDelete:()=>w(e)},e.id)},t[53]=M,t[54]=A,t[55]=S,t[56]=b,t[57]=w,t[58]=a,t[59]=e):e=t[59],u=d.unpinned.map(e),t[45]=d.unpinned,t[46]=M,t[47]=A,t[48]=S,t[49]=b,t[50]=w,t[51]=a,t[52]=u}else u=t[52];let f;t[60]!==s||t[61]!==l||t[62]!==u?(f=(0,$.jsxs)(`div`,{className:`yuri-mobile-assistant-catalog`,role:`listbox`,"aria-label":s,children:[l,u]}),t[60]=s,t[61]=l,t[62]=u,t[63]=f):f=t[63];let m=p!==null,h;t[64]!==p||t[65]!==E||t[66]!==m?(h=(0,$.jsx)(Qa,{assistant:p,open:m,onOpenChange:E}),t[64]=p,t[65]=E,t[66]=m,t[67]=h):h=t[67];let g;return t[68]!==P||t[69]!==O||t[70]!==o||t[71]!==f||t[72]!==h?(g=(0,$.jsxs)(di,{title:O,className:P,surface:!1,scrollsWithPage:!0,trailing:o,children:[f,h]}),t[68]=P,t[69]=O,t[70]=o,t[71]=f,t[72]=h,t[73]=g):g=t[73],g}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`yuri-mobile-assistant-onboarding-icon`,children:(0,$.jsx)(X,{name:`ai-agent`,className:`size-5`})}),t[74]=e):e=t[74];let n;t[75]===a?n=t[76]:(n=a(`assistants.onboarding.title`),t[75]=a,t[76]=n);let r;t[77]===n?r=t[78]:(r=(0,$.jsx)(`h2`,{children:n}),t[77]=n,t[78]=r);let i;t[79]===a?i=t[80]:(i=a(`assistants.onboarding.description`),t[79]=a,t[80]=i);let o;t[81]===i?o=t[82]:(o=(0,$.jsx)(`p`,{children:i}),t[81]=i,t[82]=o);let s;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),t[83]=s):s=t[83];let c;t[84]===a?c=t[85]:(c=a(`assistants.onboarding.action`),t[84]=a,t[85]=c);let l;t[86]!==v||t[87]!==c?(l=(0,$.jsxs)(Y,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:v,children:[s,c]}),t[86]=v,t[87]=c,t[88]=l):l=t[88];let u;t[89]!==r||t[90]!==o||t[91]!==l?(u=(0,$.jsxs)(pi,{className:`yuri-mobile-assistant-onboarding`,children:[e,r,o,l]}),t[89]=r,t[90]=o,t[91]=l,t[92]=u):u=t[92];let d;return t[93]!==P||t[94]!==O||t[95]!==u?(d=(0,$.jsx)(di,{title:O,className:P,surface:!1,surfaceClassName:`yuri-mobile-assistant-state`,children:u}),t[93]=P,t[94]=O,t[95]=u,t[96]=d):d=t[96],d}let F=s.isSuccess&&s.data.supported===!1,I=s.isError||s.data?.supported===!0&&s.data.enabled&&c.isError,L=s.data?.supported===!0&&(s.data.enabled===!1||c.data?.enabled===!1),R;t[97]!==a||t[98]!==I||t[99]!==F?(R=a(I?`assistants.state.unavailable`:F?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[97]=a,t[98]=I,t[99]=F,t[100]=R):R=t[100];let ee=R;if(L&&!I){let e;t[101]===g?e=t[102]:(e=(0,$.jsx)(uu,{onEnable:g}),t[101]=g,t[102]=e);let n;return t[103]!==P||t[104]!==O||t[105]!==e?(n=(0,$.jsx)(di,{title:O,className:P,surface:!1,surfaceClassName:`yuri-mobile-assistant-guide-host`,children:e}),t[103]=P,t[104]=O,t[105]=e,t[106]=n):n=t[106],n}let z;t[107]===O?z=t[108]:(z=(0,$.jsx)(`span`,{className:`yuri-mobile-page-section-label`,children:O}),t[107]=O,t[108]=z);let B=F?`cloud-off`:`sparkling`,V;t[109]===B?V=t[110]:(V=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground`,children:(0,$.jsx)(X,{name:B,weight:`medium`,className:`size-5`})}),t[109]=B,t[110]=V);let te;t[111]===ee?te=t[112]:(te=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:ee}),t[111]=ee,t[112]=te);let H;t[113]!==a||t[114]!==I||t[115]!==F?(H=I?null:(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-small leading-relaxed text-muted-foreground`,children:a(F?`assistants.state.unsupportedDescription`:`assistants.state.instanceDisabledDescription`)}),t[113]=a,t[114]=I,t[115]=F,t[116]=H):H=t[116];let ne;t[117]!==V||t[118]!==te||t[119]!==H?(ne=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[V,te,H]}),t[117]=V,t[118]=te,t[119]=H,t[120]=ne):ne=t[120];let U;t[121]!==z||t[122]!==ne?(U=(0,$.jsx)(mi,{label:z,cardClassName:`yuri-mobile-assistant-state-card`,children:ne}),t[121]=z,t[122]=ne,t[123]=U):U=t[123];let re;return t[124]!==P||t[125]!==O||t[126]!==U?(re=(0,$.jsx)(di,{title:O,className:P,surface:!1,surfaceClassName:`yuri-mobile-assistant-state`,children:U}),t[124]=P,t[125]=O,t[126]=U,t[127]=re):re=t[127],re}function pu(e){return e.requestCreate}function mu(e){let t=(0,Q.c)(16),{assistantID:n,onBack:r}=e,{t:i}=Te(),[a,o]=(0,Z.useState)(null),s;t[0]===i?s=t[1]:(s=i(`assistants.title`),t[0]=i,t[1]=s);let c;t[2]===i?c=t[3]:(c=i(`settings.view.actions.back`),t[2]=i,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`div`,{ref:o}),t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==s||t[7]!==c?(u=(0,$.jsx)(ze,{title:s,backAriaLabel:c,onBack:r,trailing:l}),t[5]=r,t[6]=s,t[7]=c,t[8]=u):u=t[8];let d;t[9]!==n||t[10]!==r||t[11]!==a?(d=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-[var(--yuri-mobile-page-inline-inset)] pb-[var(--yuri-safe-area-bottom,env(safe-area-inset-bottom,0px))]`,children:(0,$.jsx)(pi,{className:`yuri-mobile-settings-detail-card h-full`,children:(0,$.jsx)(sr,{children:(0,$.jsx)(Ua,{assistantID:n,onItemDeleted:r,onSaved:r,saveActionContainer:a},n)})})}),t[9]=n,t[10]=r,t[11]=a,t[12]=d):d=t[12];let f;return t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`div`,{"data-settings-view":`true`,"data-mobile-settings-stage":`page-content`,className:`yuri-settings-workspace yuri-settings-workspace-mobile flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[u,d]}),t[13]=u,t[14]=d,t[15]=f):f=t[15],f}function hu(e){let t=(0,Q.c)(13),{route:n}=e,{t:r}=Te(),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)(ze,{title:i,backAriaLabel:a,onBack:gu}),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)(yn,{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 gu(){Rr.requestAnimatedBack(`root`)}var _u=[{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 vu(e){let t=(0,Q.c)(22),{activeTab:n,onTabChange:r,className:i,tabMarks:a}=e,{t:o}=Te(),s=Ve(),c;t[0]===o?c=t[1]:(c=o(`mobile.tabs.activity.loading`),t[0]=o,t[1]=c);let l=c,u;t[2]===r?u=t[3]:(u=e=>{r(e.currentTarget.dataset.tab)},t[2]=r,t[3]=u);let d=q(u),f;t[4]!==n||t[5]!==r?(f=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=_u.findIndex(e=>e.id===n),i=_u[e.key===`Home`?0:e.key===`End`?_u.length-1:(t+(e.key===`ArrowRight`?1:-1)+_u.length)%_u.length];r(i.id),document.getElementById(`mobile-tab-${i.id}`)?.focus()},t[4]=n,t[5]=r,t[6]=f):f=t[6];let p=q(f),m;t[7]===o?m=t[8]:(m=o(`mobile.nav.aria`),t[7]=o,t[8]=m);let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h={role:`tablist`},t[9]=h):h=t[9];let g;t[10]!==n||t[11]!==s||t[12]!==d||t[13]!==p||t[14]!==l||t[15]!==o||t[16]!==a?(g=_u.map(e=>{let t=e.id===n,r=o(e.labelKey),i=e.id===`assistant`&&s>0,c=!i&&a?.[e.id]===`loading`,u=i?`mobile-tab-assistant-unread`:c?`mobile-tab-${e.id}-activity`:void 0;return(0,$.jsxs)(Y,{id:`mobile-tab-${e.id}`,"data-tab":e.id,type:`button`,role:`tab`,variant:`ghost`,size:`sm`,"aria-controls":`mobile-tabpanel-${e.id}`,"aria-label":r,"aria-describedby":u,"aria-selected":t,tabIndex:t?0:-1,title:r,onClick:d,onKeyDown:p,className:it(`yuri-mobile-tab-button min-w-0 flex-1 flex-col overflow-visible`,`font-medium leading-none tracking-tight text-muted-foreground`,`transition-[background-color,color,box-shadow,transform] duration-100`,`hover:bg-transparent hover:text-foreground`,`active:bg-interactive-active`,`motion-reduce:transition-none`,t&&[`bg-interactive-selection/55 text-primary`,`hover:bg-interactive-selection/55 hover:text-primary`,`font-semibold`]),children:[(0,$.jsxs)(`span`,{className:`relative inline-flex size-[23px] shrink-0 items-center justify-center overflow-visible`,children:[e.id===`assistant`?(0,$.jsx)(da,{size:23,className:`size-[23px] shrink-0 items-center justify-center [&[data-assistant-navigation-avatar]]:scale-105`}):(0,$.jsx)(X,{name:e.icon,weight:`medium`,className:`size-[23px] shrink-0`}),u?(0,$.jsx)(`span`,{id:u,role:c?`status`:void 0,"aria-label":c?l:void 0,"data-mobile-tab-activity":c?`loading`:void 0,className:`pointer-events-none absolute left-full -top-1 ml-0.5 inline-flex z-10`,children:i?(0,$.jsx)(Za,{className:`h-[18px] min-w-[18px] px-1 text-[11px] font-bold tracking-normal ring-2 ring-background`}):(0,$.jsx)(`span`,{className:`inline-flex size-[18px] items-center justify-center rounded-full bg-foreground text-background ring-2 ring-background`,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin`})})}):null]}),(0,$.jsx)(`span`,{className:`yuri-mobile-tab-label block max-w-full overflow-hidden text-ellipsis whitespace-nowrap`,children:r})]},e.id)}),t[10]=n,t[11]=s,t[12]=d,t[13]=p,t[14]=l,t[15]=o,t[16]=a,t[17]=g):g=t[17];let _;return t[18]!==i||t[19]!==m||t[20]!==g?(_=(0,$.jsx)(hi,{as:`nav`,"aria-label":m,variant:`navigation`,surfaceProps:h,className:i,children:g}),t[18]=i,t[19]=m,t[20]=g,t[21]=_):_=t[21],_}function yu(e){return e.unreadCount>0?`unread`:e.working?`loading`:null}var bu=`yuri-native-ios-tab-bar`,xu=`YuriTabBar`,Su=[`projects`,`assistant`,`scheduled`,`settings`],Cu=me(xu),wu=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function Tu(){return typeof window>`u`?!1:wu({isCapacitor:g(),platform:y(),pluginAvailable:J.isPluginAvailable(xu),nativeUiEnabled:Ar()})}var Eu=e=>e.classList.contains(`dark`)?`dark`:`light`,Du=()=>Mr(`--primary`),Ou=e=>typeof e==`string`&&Su.includes(e),ku=e=>typeof e==`string`&&Ou(e)?e:null,Au=(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)),ju=(e,t)=>{e.classList.toggle(bu,t)},Mu=(e,t)=>e&&!t,Nu=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&Au(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},Pu=()=>Cu,Fu=`mobile-overlay-root`;function Iu(e){let t=(0,Q.c)(28),n=jr(),r;t[0]===n?r=t[1]:(r=n&&Tu(),t[0]=n,t[1]=r);let i=r,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=(0,Z.useRef)(!1),p=(0,Z.useRef)(!1),m=q(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=JSON.stringify(e.tabs.map(Ru)),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:Eu(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:Du(),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(Fu);e||(e=document.createElement(`div`),e.id=Fu,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:[Rn]}),()=>n.disconnect()},S=[i],t[6]=i,t[7]=x,t[8]=S),(0,Z.useEffect)(x,S);let C;t[9]!==i||t[10]!==m?(C=()=>{if(!i)return;let e=!1,t=Pu(),n=[];return t.addListener(`tabSelected`,e=>{let t=ku(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`&&ju(document.documentElement,!1)}},t[9]=i,t[10]=m,t[11]=C):C=t[11];let w;t[12]===i?w=t[13]:(w=[i],t[12]=i,t[13]=w),(0,Z.useEffect)(C,w);let T;t[14]!==e.activeTab||t[15]!==e.ariaLabel||t[16]!==e.tabs||t[17]!==e.visible||t[18]!==i||t[19]!==l?(T=()=>{if(!i||p.current)return;let t=!1,n=Pu(),r={tabs:e.tabs.map(Lu),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=Nu({visible:Mu(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`&&ju(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&ju(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&ju(document.documentElement,!1))}),()=>{t=!0}},t[14]=e.activeTab,t[15]=e.ariaLabel,t[16]=e.tabs,t[17]=e.visible,t[18]=i,t[19]=l,t[20]=T):T=t[20];let E;return t[21]!==e.activeTab||t[22]!==e.ariaLabel||t[23]!==e.visible||t[24]!==i||t[25]!==l||t[26]!==g?(E=[i,e.visible,l,e.activeTab,e.ariaLabel,v,b,g],t[21]=e.activeTab,t[22]=e.ariaLabel,t[23]=e.visible,t[24]=i,t[25]=l,t[26]=g,t[27]=E):E=t[27],(0,Z.useLayoutEffect)(T,E),!i||s?`web`:a?`native`:`pending`}function Lu(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 Ru(e){return[e.id,e.label,e.badge??null,e.activity===!0,e.activity===!0?e.activityLabel??null:null]}function zu(e){let t=(0,Q.c)(52),{tabs:n,navigation:r,onTabChange:i,secondaryPages:a,showTabBar:o,tabBarCovered:s,className:c}=e,l=a===void 0?[]:a,u=o===void 0||o,d=s!==void 0&&s,{t:f}=Te(),p=r.activeTab,m=l.slice(-2),h=m.at(-1)??null,g=h?.key??null,_=h?.depth,v=m.length>1?m[m.length-2].key:null,y;t[0]===p?y=t[1]:(y=()=>new Set([p]),t[0]=p,t[1]=y);let[b,x]=Z.useState(y);b.has(p)||x(e=>{if(e.has(p))return e;let t=new Set(e);return t.add(p),t});let S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(null),T=Z.useRef(new Map),E=Z.useRef(null),D=Z.useRef(!1),O=Z.useRef(``),k=q(()=>h?.onBack());Fr({id:h?`mobile-secondary:${h.key}`:`mobile-secondary:inactive`,active:!!h,onBack:k,surfaceRef:S,underlayRef:C}),Z.useLayoutEffect(()=>{let e=g===null?null:T.current.get(g)??null,t=v===null?w.current:T.current.get(v)??null;S.current=e,C.current=t},[g,_,v]);let A;t[2]===h?A=t[3]:(A=[h],t[2]=h,t[3]=A),Z.useLayoutEffect(()=>{if(h){if(!D.current){let e=document.activeElement;E.current=e instanceof HTMLElement?e:null,D.current=!0}O.current!==h.key&&(O.current=h.key,S.current?.focus());return}if(D.current){D.current=!1,O.current=``;let e=E.current;E.current=null,e&&e.isConnected&&e.focus()}},A);let j;t[4]===i?j=t[5]:(j=e=>{i(e)},t[4]=i,t[5]=j);let M=q(j),N=Ve(),P=Le(),F=Ie(),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=yu({unreadCount:N,working:P}),t[8]=N,t[9]=P,t[10]=R):R=t[10];let ee=R,z;t[11]===F?z=t[12]:(z=yu({unreadCount:0,working:F}),t[11]=F,t[12]=z);let B=z,V;t[13]!==ee||t[14]!==N||t[15]!==L||t[16]!==B||t[17]!==f?(V=_u.map(e=>{let t=e.id===`assistant`&&ee===`loading`||e.id===`scheduled`&&B===`loading`;return{id:e.id,label:f(e.labelKey),badge:e.id===`assistant`&&ee===`unread`?N>99?`99+`:String(N):null,activity:t,activityLabel:t?L:null}}),t[13]=ee,t[14]=N,t[15]=L,t[16]=B,t[17]=f,t[18]=V):V=t[18];let te=V,H=u&&!d&&!h,ne;t[19]===f?ne=t[20]:(ne=f(`mobile.nav.aria`),t[19]=f,t[20]=ne);let U;t[21]!==M||t[22]!==H||t[23]!==te||t[24]!==p||t[25]!==ne?(U={visible:H,activeTab:p,tabs:te,ariaLabel:ne,onTabChange:M},t[21]=M,t[22]=H,t[23]=te,t[24]=p,t[25]=ne,t[26]=U):U=t[26];let re=Iu(U),W=re===`native`,ie=u&&re===`web`,ae=jr(),oe,se;t[27]!==ae||t[28]!==W?(oe=()=>{if(!ae){Lr.shutdown();return}W&&Nr(!0)&&Lr.warm()},se=[ae,W],t[27]=ae,t[28]=W,t[29]=oe,t[30]=se):(oe=t[29],se=t[30]),Z.useEffect(oe,se);let ce=p===`assistant`&&`yuri-assistant-wallpaper`,le;t[31]!==c||t[32]!==ce?(le=it(`yuri-mobile-floating-shell relative isolate flex h-full min-h-0 flex-col overflow-hidden text-foreground`,`bg-[var(--yuri-mobile-page-background)]`,ce,c),t[31]=c,t[32]=ce,t[33]=le):le=t[33];let ue=h?!0:void 0,G=h?!0:void 0,de=h?`true`:void 0,K;t[34]!==p||t[35]!==u||t[36]!==ie||t[37]!==f||t[38]!==n||t[39]!==b?(K=_u.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:it(`scrollbar-none h-full min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--yuri-mobile-page-inline-inset)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+1rem)] outline-none`,u?`pb-[calc(var(--yuri-mobile-dock-height)+2.5rem+var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px)))]`:`pb-0`),children:t?n?.[e.id]??(0,$.jsx)(Bu,{tab:e.id,icon:e.icon}):null},e.id)}),t[34]=p,t[35]=u,t[36]=ie,t[37]=f,t[38]=n,t[39]=b,t[40]=K):K=t[40];let fe=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||W?!0:void 0,inert:h||W?!0:void 0,children:ie?(0,$.jsx)(vu,{activeTab:p,onTabChange:M,tabMarks:{assistant:ee===`loading`?`loading`:null,scheduled:B===`loading`?`loading`:null}}):null}):null,pe;t[41]!==w||t[42]!==ue||t[43]!==G||t[44]!==de||t[45]!==K||t[46]!==fe?(pe=(0,$.jsxs)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":ue,inert:G,"data-mobile-navigation-parked":de,className:`flex h-full min-h-0 flex-1 flex-col`,children:[K,fe]}),t[41]=w,t[42]=ue,t[43]=G,t[44]=de,t[45]=K,t[46]=fe,t[47]=pe):pe=t[47];let me=m.map((e,t)=>{let n=t===m.length-1;return(0,$.jsx)(`div`,{ref:t=>{t?T.current.set(e.key,t):T.current.delete(e.key)},"data-mobile-secondary-page":`true`,"data-mobile-secondary-active":n?`true`:`false`,role:n?`dialog`:void 0,"aria-modal":n?!0:void 0,"aria-label":n?e.ariaLabel??f(`mobile.nav.secondaryPageAria`):void 0,"aria-hidden":!n||void 0,inert:!n||void 0,tabIndex:n?-1:void 0,className:it(`absolute inset-0 flex h-full min-h-0 flex-col overflow-hidden bg-background outline-none`,n?`z-50`:`z-40`),children:e.content},e.key)}),J;return t[48]!==le||t[49]!==pe||t[50]!==me?(J=(0,$.jsxs)(`div`,{className:le,children:[pe,me]}),t[48]=le,t[49]=pe,t[50]=me,t[51]=J):J=t[51],J}function Bu(e){let t=(0,Q.c)(17),{tab:n,icon:r,className:i}=e,{t:a}=Te(),o,s,c,l;if(t[0]!==i||t[1]!==r||t[2]!==a||t[3]!==n){let e=_u.find(e=>e.id===n)??_u[0];t[8]===i?c=t[9]:(c=it(`flex min-h-[70dvh] flex-col items-center justify-center gap-3 text-center`,i),t[8]=i,t[9]=c),l=(0,$.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:r??e.icon,className:`size-6`})}),o=`typography-ui-label font-semibold tracking-[-0.01em] text-foreground`,s=a(e.labelKey),t[0]=i,t[1]=r,t[2]=a,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];let u;t[10]!==o||t[11]!==s?(u=(0,$.jsx)(`h1`,{className:o,children:s}),t[10]=o,t[11]=s,t[12]=u):u=t[12];let d;return t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:c,children:[l,u]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}var Vu=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function Hu({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,onRemoteDesktop:a,instanceOptions:o,className:s}){let{t:c}=Te(),{git:l}=se(),u=bt(),d=ka(),[f,p]=Z.useState(()=>new Map),m=q((e,t)=>{p(n=>{if(!t.length&&!n.has(e))return n;let r=new Map(n);return t.length?r.set(e,t):r.delete(e),r})}),g=q((e,t,n,r)=>{let i=dt.getState(),a=e===`__pinned__`?e:h(e);if(!a||a!==`__pinned__`&&i.getSessionFolderId(a,n)!==i.getSessionFolderId(a,r))return;let o=a===`__pinned__`?{}:Hi(d.allSessions.filter(e=>Ta(e)===a));i.reorderSessions(a,t,n,r,o).catch(()=>at.error(c(`sessions.order.saveFailed`)))}),_=wi(e=>e.setProjectExpanded),v=wi(e=>e.setWorktreeExpanded),y=zt(),b=mt(),x=Ot(e=>e.archiveSessions),S=Ot(e=>e.updateSessionTitle),C=Ot(e=>e.requestSessionSmartTitle),w=Ot(e=>e.shareSession),T=Ot(e=>e.unshareSession),E=Ot(e=>e.openNewSessionDraft),D=jt(e=>e.openDraft),O=jt(e=>e.openSession),k=Ue(e=>e.projects),A=Ke(e=>e.projectSortOrder),j=Ri(),M=Z.useMemo(()=>k.filter(e=>e.hostId).map(Jt),[k]),N=Z.useMemo(()=>[...d.inProgressSessions.map(e=>({session:e,time:d.sessionById.get(e.id)?$e(d.sessionById.get(e.id)):0})),...M.flatMap(e=>f.get(e.id)??[]).map(e=>({session:{id:e.identity,title:e.node.session.title||``,content:e.content},time:$e(e.node.session)}))].sort((e,t)=>t.time-e.time).map(e=>e.session),[d.inProgressSessions,d.sessionById,M,f]),P=Ue(e=>e.setActiveProjectIdOnly),F=Ue(e=>e.removeProject),I=xn(),[L,R]=Z.useState(null),[ee,z]=Z.useState(!1),[B,V]=Z.useState(null),[te,H]=Z.useState(null),[ne,U]=Z.useState(null),[re,W]=Z.useState(``),[ie,ae]=Z.useState(!1),[oe,ce]=Z.useState(!1),[le,ue]=Z.useState(null),[G,de]=Z.useState(null),[K,fe]=Z.useState(null),pe=L?.kind===`session`?L.session.id:``,me=kt(pe),J=me?.type===`busy`||me?.type===`retry`,he=L?.kind===`session`?Ta(L.session):``,{unread:ge,onToggleRead:_e}=fa(L?.kind===`session`?L.session:null,he),ve=!!pe&&K===pe,ye=!he||ve||J,be=q(e=>{let t=new Map;for(let e of d.allSessions){let n=va(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}),xe=q(()=>{z(!1),R(null)}),Se=q(t=>{if(na(t.id)){let e=pa(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&&Ta(n)||null;e({sessionId:t.id,directory:r})}),Ce=q(e=>{na(e.id)||y(e.id)}),we=q(async e=>{if(na(e.id))return;let t=be(e.id),{archivedIds:n,failedIds:r}=await x(t);n.length>0&&la({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&&at.error(r.length===1?c(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):c(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}),Ee=q(()=>{if(!L||L.kind!==`session`)return;let e=L.session,t=Ta(e),n=me?.type??`idle`;!t||K===e.id||n===`busy`||n===`retry`||(fe(e.id),(async()=>{try{await I.refreshSessionTranscript(e.id,{directory:t}),at.success(c(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{at.error(c(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{fe(t=>t===e.id?null:t)}})())}),De=q(e=>{if(na(e.id))return;let t=d.sessionById.get(e.id);t&&(R({kind:`session`,session:t}),z(!0))}),Oe=q(e=>{_(e.id,!e.expanded)}),ke=q((e,t)=>{v(`${e.id}::${t.id}`,!t.expanded)}),Ae=q((e,t)=>{P(e.id),D({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),je=q(()=>{let e=Ue.getState().getActiveProject();if(e?.hostId){ln(Jt(e),!0).catch(e=>at.error(e instanceof Error?e.message:String(e)));return}if(n){n();return}E()}),Me=q(e=>{let t=d.projectMetaById.get(e.id);t&&(R({kind:`project`,project:t,isGitRepository:!1}),z(!0),l.checkIsGitRepository(t.path).then(e=>{R(n=>Vu(n,t.id,e))}).catch(()=>{R(e=>Vu(e,t.id,!1))}))}),Ne=q((e,t)=>{let n=h(t);return n?e.worktrees.find(e=>h(e.path)===n)||((Ot.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>h(e.path)===n)??null):null}),Pe=q((e,t)=>{let n=d.projectMetaById.get(e.id);n&&Ae(n,t.path)}),Fe=q((e,t)=>{let n=d.projectMetaById.get(e.id);n&&(R({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),z(!0))}),Ie=q((e,t)=>{let n=d.projectMetaById.get(e.id);if(!n)return;let r=Ne(n,t.path);if(!r){at.error(c(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}de({project:n,worktree:r})}),Le=q(e=>{ue(e),P(e),ce(!0)}),Re=q(e=>{(async()=>{let t=e.worktrees;try{t=(await $r({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=Ot.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await ut([e.path,...t.map(e=>e.path)],d.allSessions)})()}),ze=q((e,t)=>{let n=le;if(ce(!1),ue(null),t?.sessionId){O({sessionId:t.sessionId,directory:e});return}D({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),Be=q(async e=>{try{if(!(await w(e.id))?.share?.url){at.error(c(`sessions.sidebar.session.share.error`));return}at.success(c(`sessions.sidebar.session.share.successTitle`),{description:c(`sessions.sidebar.session.share.successDescription`)})}catch{at.error(c(`sessions.sidebar.session.share.error`))}}),Ve=q(async e=>{if((await ct(e)).ok){at.success(c(`sessions.sidebar.session.menu.copied`));return}at.error(c(`sessions.sidebar.session.share.copyUrlError`))}),He=q(async e=>{try{if(await T(e)){at.success(c(`sessions.sidebar.session.unshare.success`));return}at.error(c(`sessions.sidebar.session.unshare.error`))}catch{at.error(c(`sessions.sidebar.session.unshare.error`))}}),We=q(e=>{let t=be(e.id);ua({sessionIds:t,message:t.length===1?c(`sessions.sidebar.session.delete.success`):c(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:c(`sessions.sidebar.undo`),commitFailedMessage:c(`sessions.sidebar.session.delete.error`)})}),Ge=q(async()=>{if(!ne)return;let e=re.trim();if(e)try{await S(ne.id,e),U(null),W(``)}catch{at.error(c(`sessions.sidebar.session.menu.rename`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),qe=q(async()=>{if(!ne||ie)return;let e=ne.id;U(null),W(``),ae(!0);try{await C(e)}catch{at.error(c(`sessions.sidebar.session.rename.smartTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{ae(!1)}}),Je=Z.useMemo(()=>L?L.kind===`session`?{kind:`session`,title:L.session.title?.trim()||c(`mobile.sessions.untitled`),pinned:b.has(L.session.id),shared:!!L.session.share?.url,unread:ge}:L.kind===`project`?{kind:`project`,title:L.project.label,gitRepository:L.isGitRepository}:{kind:`worktree`,title:L.worktreeName}:null,[L,ge,b,c]),Ye=Z.useMemo(()=>{if(!L)return{};if(L.kind===`session`){let e=L.session;return{onRename:()=>{W(e.title?.trim()||c(`mobile.sessions.untitled`)),U(e)},onTogglePin:()=>y(e.id),onToggleRead:_e,onShare:u&&!e.share?.url?()=>{Be(e)}:void 0,onCopyLink:u&&e.share?.url?()=>{Ve(e.share.url)}:void 0,onUnshare:u&&e.share?.url?()=>{He(e.id)}:void 0,onRefreshTranscript:Ee,onArchive:()=>{we({id:e.id,title:e.title?.trim()||c(`mobile.sessions.untitled`)})},onDelete:()=>We(e)}}if(L.kind===`project`){let e=L.project;return{onNewSession:()=>Ae(e,e.path),onNewWorktree:()=>Le(e.id),onSyncSessions:()=>Re(e),onEditProject:()=>V(e.id),onCloseProject:()=>H(e)}}let{project:e,worktreePath:t}=L;return{onNewSession:()=>Ae(e,t),onDeleteWorktree:()=>{let n=Ne(e,t);if(!n){at.error(c(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:c(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}de({project:e,worktree:n})}}},[L,we,Ve,We,Ee,Le,Re,Be,He,_e,Ne,u,Ae,c,y]),Xe=Z.useMemo(()=>{if(!B)return null;let e=k.find(e=>e.id===B),t=d.projectMetaById.get(B);if(!e||!t)return null;let n=L?.kind===`project`&&L.project.id===B?L.isGitRepository:t.worktrees.length>0;return{id:e.id,label:e.label?.trim()||t.label,path:h(e.path)||t.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:n,worktrees:t.worktrees}},[L,B,d.projectMetaById,k]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(sa,{remoteProjects:M,hostRegistry:j.registry,projectOrderIds:ia(k,A).map(e=>e.id),renderRemoteProject:j.registry?e=>(0,$.jsx)(ea,{project:e,registry:j.registry,mobile:!0,reorderEnabled:!1,onActivityItems:m}):void 0,remoteError:j.catalog.error?.message,className:s,projects:d.projects,pinnedSessions:d.pinnedSessions,inProgressSessions:N,onAddProject:t,onNewSession:je,onScanQr:r,onSwitchInstance:i,instanceOptions:o,onRemoteDesktop:a,onToggleProject:Oe,onOpenProjectActions:Me,onToggleWorktree:ke,onNewWorktreeSession:Pe,onOpenWorktreeActions:Fe,onDeleteWorktree:Ie,onSelectSession:Se,onPinSession:Ce,onArchiveSession:e=>{we(e)},onOpenSessionActions:De,onReorderSessions:g}),(0,$.jsx)(ja,{open:ee,target:Je,actions:Ye,refreshTranscriptDisabled:ye,refreshTranscriptSpinning:ve,onOpenChange:e=>{e?z(!0):xe()}}),(0,$.jsx)(Pn,{open:oe,projectId:le,onOpenChange:e=>{ce(e),e||ue(null)},onWorktreeCreated:ze}),G?(0,$.jsx)(ba,{open:!0,project:{id:G.project.id,path:G.project.path},worktree:G.worktree,onClose:()=>de(null)}):null,(0,$.jsx)(ir,{open:!!te,title:c(`sessions.sidebar.project.actions.closeProject`),onClose:()=>H(null),closeAriaLabel:c(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>H(null),children:c(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!te)return;let e=te;H(null),F(e.id),at.success(c(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:c(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:c(`mobile.projects.closeConfirmMessage`,{title:te?.label??``})})}),(0,$.jsx)(ir,{open:!!ne,title:c(`sessions.sidebar.session.menu.rename`),onClose:()=>{ie||(U(null),W(``))},closeAriaLabel:c(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`default`,className:`flex-1`,disabled:ie,onClick:()=>{U(null),W(``)},children:c(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{type:`button`,variant:`default`,className:`flex-1`,disabled:!re.trim()||ie,onClick:()=>void Ge(),children:c(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),Ge()},children:[(0,$.jsx)(Kn,{value:re,onChange:e=>W(e.target.value),autoFocus:!0,className:`h-12`,disabled:ie}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:ie,onClick:()=>void qe(),children:[ie?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),c(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(ca,{open:B!==null,project:Xe,onClose:()=>V(null)})]})}function Uu(e){let t=(0,Q.c)(10),{children:n,content:r,className:i,contentClassName:a,showHeader:o}=e,s=o===void 0||o,{t:c}=Te(),l;t[0]===c?l=t[1]:(l=c(`sessions.scheduledTasks.dialog.title`),t[0]=c,t[1]=l);let u;t[2]===a?u=t[3]:(u=it(`yuri-mobile-scheduled-content`,a),t[2]=a,t[3]=u);let d=n??r,f;return t[4]!==i||t[5]!==s||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,$.jsx)(di,{title:l,className:i,surface:!1,scrollsWithPage:!0,showHeader:s,surfaceClassName:u,children:d}),t[4]=i,t[5]=s,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function Wu(e){let t=(0,Q.c)(10),{className:n,contentClassName:r,instancesPage:i}=e,{t:a}=Te(),o;t[0]===a?o=t[1]:(o=a(`mobile.settings.placeholder.title`),t[0]=a,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=[...fr],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(Wa,{forceMobile:!0,isWindowed:!0,hideMobileHeader:!0,flowMobile:!0,autoOpenMobilePage:!0,visiblePageSlugs:s,mobileInstancesPage:i}),t[3]=i,t[4]=c);let l;return t[5]!==n||t[6]!==r||t[7]!==o||t[8]!==c?(l=(0,$.jsx)(di,{title:o,className:n,surface:!1,scrollsWithPage:!0,showHeader:!1,surfaceClassName:r,children:c}),t[5]=n,t[6]=r,t[7]=o,t[8]=c,t[9]=l):l=t[9],l}function Gu(e){let t=(0,Q.c)(115),{onAddProject:n,onScanQr:r,onSwitchInstance:i,onRemoteDesktop:a,remoteDesktopActive:o,instanceOptions:s,onEnableAssistants:c,instancesPage:l,instancesSecondaryPage:u,parentSessionTarget:d,registerSecondaryBackHandler:f,scheduledContent:p,renderChat:m,className:g}=e,_=o!==void 0&&o,v=d===void 0?null:d,{t:y}=Te(),b=ge(dd),x=jt(),S=jt(ud),C=jt(ld),w=jt(cd),T=jt(sd),E=jt(od),D=jt(ad),O=jt(id),k=jt(rd),A=jt(nd),j=jt(td),M=jt(ed),N=jt($u),P;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(P=[],t[0]=P):P=t[0],Z.useEffect(Qu,P);let F=x.secondary?.kind===`chat`?x.secondary.btw??null:null,I=Z.useRef(null),L,R;t[1]===F?(L=t[2],R=t[3]):(L=()=>{let e=I.current;I.current=F,e&&e!==F&&Vn.getState().clear({sessionId:e.sessionId,directory:e.directory}),F?vn(zn):kn(zn)},R=[F],t[1]=F,t[2]=L,t[3]=R),Z.useEffect(L,R);let ee;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(ee=[],t[4]=ee):ee=t[4],Z.useEffect(Xu,ee);let z;t[5]===S?z=t[6]:(z=e=>{e===`settings`&&ge.getState().setSettingsPage(`home`),S(e)},t[5]=S,t[6]=z);let B=q(z),V;t[7]===C?V=t[8]:(V=e=>{C(e)},t[7]=C,t[8]=V);let te=q(V),H;t[9]===O?H=t[10]:(H=()=>{O()},t[9]=O,t[10]=H);let ne=q(H),U;t[11]===w?U=t[12]:(U=()=>{w()},t[11]=w,t[12]=U);let re=q(U),W;t[13]===T?W=t[14]:(W=e=>{T(e)},t[13]=T,t[14]=W);let ie=q(W),ae=Z.useRef(null),[oe,se]=Z.useState(!1),ce;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>{ae.current=e},t[15]=ce):ce=t[15];let le=q(ce),ue;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>{se(e)},t[16]=ue):ue=t[16];let G=q(ue),de;t[17]!==ne||t[18]!==v||t[19]!==D||t[20]!==N||t[21]!==k?(de=()=>{if(ae.current?.())return!0;let e=jt.getState().secondary;return e?.kind===`chat`&&e.btw?(N(),!0):e?.kind===`assistant`&&e.settingsAssistantID?(D(),!0):(e?.kind===`draft`||e?.kind===`chat`)&&v?.onSelect?(v.onSelect(),!0):e?.kind===`chat`&&e.routes.length>1?(k(),!0):e?(ne(),!0):!1},t[17]=ne,t[18]=v,t[19]=D,t[20]=N,t[21]=k,t[22]=de):de=t[22];let K=q(de),fe=x.secondary!==null,pe;t[23]!==K||t[24]!==f?(pe=()=>{if(f)return f(()=>K()),()=>f(null)},t[23]=K,t[24]=f,t[25]=pe):pe=t[25];let me;t[26]!==K||t[27]!==f||t[28]!==fe?(me=[f,fe,K],t[26]=K,t[27]=f,t[28]=fe,t[29]=me):me=t[29],Z.useEffect(pe,me);let J=Ot(Yu),he=st(Ju),_e;t[30]===J?_e=t[31]:(_e=e=>J?e.getDirectoryForSession(J):null,t[30]=J,t[31]=_e);let ve=Ot(_e),ye,be;t[32]!==ve||t[33]!==J||t[34]!==j||t[35]!==he||t[36]!==M?(ye=()=>{let e=jt.getState().secondary;if(he)return;if(e?.kind===`draft`&&J){j({sessionId:J,directory:ve});return}if(e?.kind!==`chat`||!J||Nt({sessionId:J,directory:ve})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==J||h(t.directory)!==h(ve))&&M({sessionId:J,directory:ve})},be=[ve,J,j,M,he],t[32]=ve,t[33]=J,t[34]=j,t[35]=he,t[36]=M,t[37]=ye,t[38]=be):(ye=t[37],be=t[38]),Z.useEffect(ye,be);let xe,Se;t[39]!==J||t[40]!==v||t[41]!==A||t[42]!==he?(xe=()=>{let e=jt.getState().secondary;if(e?.kind!==`chat`||!v||v.onSelect||he)return;let t=e.routes.at(-1);!t||t.sessionId!==J||A({sessionId:v.id,directory:v.directory})},Se=[J,v,A,he],t[39]=J,t[40]=v,t[41]=A,t[42]=he,t[43]=xe,t[44]=Se):(xe=t[43],Se=t[44]),Z.useEffect(xe,Se);let Ce;t[45]!==G||t[46]!==le||t[47]!==p?(Ce=typeof p==`function`?p(le,G):p,t[45]=G,t[46]=le,t[47]=p,t[48]=Ce):Ce=t[48];let we=Ce,Ee;t[49]!==re||t[50]!==s||t[51]!==n||t[52]!==a||t[53]!==r||t[54]!==i||t[55]!==te?(Ee=(0,$.jsx)(Hu,{onOpenChat:te,onAddProject:n,onNewSession:re,onScanQr:r,onSwitchInstance:i,onRemoteDesktop:a,instanceOptions:s}),t[49]=re,t[50]=s,t[51]=n,t[52]=a,t[53]=r,t[54]=i,t[55]=te,t[56]=Ee):Ee=t[56];let De;t[57]!==c||t[58]!==ie?(De=(0,$.jsx)(fu,{onEnable:c,onOpenAssistant:ie}),t[57]=c,t[58]=ie,t[59]=De):De=t[59];let Oe;t[60]===we?Oe=t[61]:(Oe=(0,$.jsx)(Uu,{showHeader:!1,children:we}),t[60]=we,t[61]=Oe);let ke;t[62]===l?ke=t[63]:(ke=(0,$.jsx)(Wu,{instancesPage:l}),t[62]=l,t[63]=ke);let Ae;t[64]!==Ee||t[65]!==De||t[66]!==Oe||t[67]!==ke?(Ae={projects:Ee,assistant:De,scheduled:Oe,settings:ke},t[64]=Ee,t[65]=De,t[66]=Oe,t[67]=ke,t[68]=Ae):Ae=t[68];let je=Ae,Me=x.secondary?.kind??null,Ne;bb0:{if(!Me){Ne=null;break bb0}let e;t[69]!==K||t[70]!==E||t[71]!==y?(e=e=>({key:`assistant-secondary`,depth:1,ariaLabel:y(`assistants.title`),onBack:K,content:(0,$.jsx)(io,{activeOverride:e,onMobileBack:qu,onMobileOpenSettings:E})}),t[69]=K,t[70]=E,t[71]=y,t[72]=e):e=t[72];let n=e;if(Me===`assistant`){let e=x.secondary?.kind===`assistant`?x.secondary.settingsAssistantID:void 0,r=!e,i;t[73]!==n||t[74]!==r?(i=n(r),t[73]=n,t[74]=r,t[75]=i):i=t[75];let a;t[76]!==K||t[77]!==e||t[78]!==y?(a=e?[{key:`assistant-settings:${e}`,depth:2,ariaLabel:y(`assistants.conversation.openSettings`),onBack:K,content:(0,$.jsx)(mu,{assistantID:e,onBack:Ku})}]:[],t[76]=K,t[77]=e,t[78]=y,t[79]=a):a=t[79];let o;t[80]!==i||t[81]!==a?(o=[i,...a],t[80]=i,t[81]=a,t[82]=o):o=t[82],Ne=o;break bb0}if(Me===`instances`){let e;t[83]===y?e=t[84]:(e=y(`mobile.settings.switchInstance`),t[83]=y,t[84]=e);let n;t[85]!==K||t[86]!==u||t[87]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:K,content:u}],t[85]=K,t[86]=u,t[87]=e,t[88]=n):n=t[88],Ne=n;break bb0}if(x.secondary?.kind===`draft`){let e;t[89]===y?e=t[90]:(e=y(`mobile.nav.secondaryPageAria`),t[89]=y,t[90]=e);let n;t[91]===m?n=t[92]:(n=m({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[91]=m,t[92]=n);let r;t[93]!==K||t[94]!==e||t[95]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:K,content:n}],t[93]=K,t[94]=e,t[95]=n,t[96]=r):r=t[96],Ne=r;break bb0}if(x.secondary?.kind!==`chat`){let e;t[97]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[97]=e):e=t[97],Ne=e;break bb0}let r=x.secondary.routes,i;if(t[98]!==n||t[99]!==K||t[100]!==x.secondary.btw||t[101]!==x.secondary.returnTo||t[102]!==m||t[103]!==r||t[104]!==y){let e=x.secondary.returnTo?[n(!1)]:[],a=x.secondary.btw,o=r.slice(a?-1:-2),s=r.length-o.length+1+e.length,c=o.map((e,t)=>{let n=!a&&t===o.length-1;return{key:e.key,depth:s+t,ariaLabel:y(`mobile.nav.secondaryPageAria`),onBack:K,content:m({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:n})}});i=a?[...e,...c,{key:`chat-btw`,depth:r.length+1+e.length,ariaLabel:y(`chat.btw.title`),onBack:K,content:(0,$.jsx)(hu,{route:a})}]:[...e,...c],t[98]=n,t[99]=K,t[100]=x.secondary.btw,t[101]=x.secondary.returnTo,t[102]=m,t[103]=r,t[104]=y,t[105]=i}else i=t[105];Ne=i}let Pe=Ne,Fe;t[106]===Pe?Fe=t[107]:(Fe=Pe??[],t[106]=Pe,t[107]=Fe);let Ie=oe||b||_,Le;return t[108]!==g||t[109]!==x||t[110]!==B||t[111]!==Fe||t[112]!==Ie||t[113]!==je?(Le=(0,$.jsx)(zu,{className:g,navigation:x,onTabChange:B,tabs:je,secondaryPages:Fe,tabBarCovered:Ie}),t[108]=g,t[109]=x,t[110]=B,t[111]=Fe,t[112]=Ie,t[113]=je,t[114]=Le):Le=t[114],Le}function Ku(){Rr.requestAnimatedBack(`root`)}function qu(){return Rr.requestAnimatedBack(`root`)}function Ju(e){return e.remoteSession}function Yu(e){return e.currentSessionId}function Xu(){return Zu}function Zu(){return kn(zn)}function Qu(){return Dt()}function $u(e){return e.popBtw}function ed(e){return e.replaceChatSession}function td(e){return e.materializeDraftSession}function nd(e){return e.reconcileChatPredecessor}function rd(e){return e.popChatSession}function id(e){return e.closeSecondary}function ad(e){return e.popAssistantSettings}function od(e){return e.pushAssistantSettings}function sd(e){return e.openAssistant}function cd(e){return e.openDraft}function ld(e){return e.openSession}function ud(e){return e.setActiveTab}function dd(e){return e.isCommandPaletteOpen}function fd(e){let t=!1,n=0,r=0,i=!1,a,o,c,u=()=>e.transport===l()&&e.generation===d(),f=()=>document.visibilityState===`hidden`,p=()=>{r++;let e=a;a=void 0,clearTimeout(o),o=void 0,e?.close()},m=n=>{t||(t=!0,p(),x(),window.removeEventListener(`online`,_),window.removeEventListener(`pageshow`,y),window.removeEventListener(`yuri:system-resume`,v),document.removeEventListener(`visibilitychange`,b),e.onState(`closed`,n))},h=()=>{if(t||f())return;let e=navigator.onLine===!1||c===`permission_required`?6e4:Math.min(1e3*2**Math.min(n++,5),3e4);o=setTimeout(()=>{o=void 0,g()},e)},g=()=>{if(t||a||f())return;if(!u()){m(`runtime_changed`);return}if(clearTimeout(o),o=void 0,navigator.onLine===!1){h();return}let s=++r;a=pd({...e,onState:(i,o)=>{if(!(t||s!==r)){if(i===`closed`){if(a=void 0,c=o,!o||[`runtime_changed`,`disabled`,`unsupported`,`helper_unavailable`,`authentication_required`,`permission_denied`].includes(o)){m(o);return}e.onState(i,o),h();return}(i===`webrtc`||i===`tunnel`)&&(n=0,c=void 0),e.onState(i,o)}}}),a.setZoomed(i)},_=()=>{!t&&!f()&&!a&&g()},v=()=>{t||(p(),_())},y=e=>{e.persisted&&v()},b=()=>{f()?(p(),e.onState(`connecting`,void 0)):_()},x=s(()=>m(`runtime_changed`));return window.addEventListener(`online`,_),window.addEventListener(`pageshow`,y),window.addEventListener(`yuri:system-resume`,v),document.addEventListener(`visibilitychange`,b),g(),{send:e=>{!t&&u()&&a?.send(e)},close:()=>m(),setZoomed:e=>{i=e,a?.setZoomed(e)}}}function pd(e){let t=!1,n,i,a=!1,o,s,u=setTimeout(()=>E(`connection_failed`),6e4),f,p=Date.now(),m,h,g=!1,_=!1,v=!1,y=(t,n)=>{(m!==t||h!==n)&&(m=t,h=n,e.onState(t,n))},b=Promise.resolve(),x=0,S=[],C=()=>!t&&e.transport===l()&&e.generation===d(),w=e=>{if(!(!C()||n?.readyState!==1))try{n.send(JSON.stringify(e))}catch{E(`connection_failed`)}},T=()=>{!g||_===v||!C()||n?.readyState!==1||(w({type:`view`,zoomed:_}),v=_)},E=r=>{if(t)return;let a=C()&&n?.readyState===1;if(t=!0,a)try{n.send(JSON.stringify({type:`release`}))}catch{}clearInterval(s),clearTimeout(u),clearTimeout(f),n&&(n.onopen=null,n.onmessage=null,n.onerror=null,n.onclose=null,n.close()),i?.close();let c=e.video.srcObject;c instanceof MediaStream&&c.getTracks().forEach(e=>e.stop()),e.video.srcObject=null,e.video.onloadeddata=null,e.image.onload=null,e.image.onerror=null,e.image.removeAttribute(`src`),o&&URL.revokeObjectURL(o),y(`closed`,r)},D=()=>{!C()||a||(a=!0,i?.close(),clearTimeout(f),f=setTimeout(()=>E(`connection_failed`),15e3),w({type:`fallback`}))},O=async t=>{if(!C())return;if(p=Date.now(),t instanceof ArrayBuffer){if(t.byteLength>524288){E(`connection_failed`);return}o&&URL.revokeObjectURL(o),o=URL.createObjectURL(new Blob([t],{type:`image/jpeg`})),e.image.onload=()=>{C()&&(clearTimeout(u),clearTimeout(f),e.onSize(e.image.naturalWidth,e.image.naturalHeight),y(`tunnel`),w({type:`ack`}))},e.image.onerror=()=>E(`connection_failed`),e.image.src=o;return}let n=JSON.parse(t);if(n.type===`error`){E(typeof n.code==`string`?n.code:`connection_failed`);return}if(n.type===`ready`)g=n.zoomQuality===!0,T(),Number.isFinite(n.width)&&Number.isFinite(n.height)&&e.onSize(n.width,n.height);else if(n.type===`offer`&&!a){if(i||typeof n.sdp!=`string`||n.sdp.length>65536)throw Error(`invalid_offer`);if(typeof RTCPeerConnection>`u`){D();return}i=new RTCPeerConnection({iceServers:Array.isArray(n.iceServers)?n.iceServers:[]}),i.onicecandidate=e=>{e.candidate&&w({type:`ice`,candidate:e.candidate.toJSON()})},i.onconnectionstatechange=()=>{(i?.connectionState===`failed`||i?.connectionState===`disconnected`)&&D()},i.ontrack=t=>{C()&&(e.video.srcObject=new MediaStream([t.track]),e.video.onloadeddata=()=>{!C()||a||(clearTimeout(u),clearTimeout(f),e.onSize(e.video.videoWidth,e.video.videoHeight),y(`webrtc`))},e.video.play().catch(D))},await i.setRemoteDescription({type:`offer`,sdp:n.sdp});for(let e of S.splice(0))await i.addIceCandidate(e);if(await i.setLocalDescription(await i.createAnswer()),!C()||a)return;f=setTimeout(D,7e3),w({type:`answer`,sdp:i.localDescription?.sdp})}else n.type===`ice`&&n.candidate&&!a?i?.remoteDescription?await i.addIceCandidate(n.candidate):S.length<128&&S.push(n.candidate):n.type===`rtc-failed`&&D()};return y(`connecting`),(async()=>{try{if(await r(),!C())return;n=k(c().websocket(`/api/remote-desktop/ws`)),n.binaryType=`arraybuffer`,n.onopen=()=>{C()&&(p=Date.now(),s=setInterval(()=>{if(!C()){E(`runtime_changed`);return}if(Date.now()-p>3e4){E(`connection_failed`);return}w({type:`ping`})},5e3))},n.onmessage=e=>{if(C()){if(++x>128){E(`connection_failed`);return}b=b.then(()=>O(e.data)).catch(D).finally(()=>{x--})}},n.onerror=()=>E(`connection_failed`),n.onclose=e=>E(e.code===4001?`authentication_required`:`connection_failed`)}catch{E(`connection_failed`)}})(),{send:e=>w(e),close:E,setZoomed:e=>{_=e,T()}}}var md={scale:1,x:0,y:0};function hd(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 gd(e,t,n){if(t.width<=0||t.height<=0||t.remoteWidth<=0||t.remoteHeight<=0)return null;let r=hd(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 _d(e,t,n=1){let r=Math.max(n,Math.min(5,e.scale)),i=hd(t),a=(e,t,n,i)=>n*r<=i?(i-n*r)/2-t*r:Math.max(i-(t+n)*r,Math.min(-t*r,e));return{scale:r,x:a(e.x,i.x,i.width,t.width),y:a(e.y,i.y,i.height,t.height)}}function vd(e){let t=new Map,n={...md},r=null,i=null,a=!1,o=!1,s=!1,c=!1,l,u=null,d=0,f=null,p=()=>{a&&e.send({type:`release`}),a=!1},m=()=>{(n.scale!==1||n.x!==0||n.y!==0)&&(n={...md},e.apply(n,!0))},h=()=>{clearTimeout(l),p(),t.clear(),f=null,r=i=null,s=!1,u=null,n.scale<=1&&m()},g=()=>{let[e,n]=[...t.values()];return{midpoint:{x:(e.x+n.x)/2,y:(e.y+n.y)/2},distance:Math.max(1,Math.hypot(e.x-n.x,e.y-n.y))}},_={down(a,m){t.size>=2||(t.set(a,m),t.size===1&&(r=i=m,o=!1,s=!1,c=!1,d=Date.now(),e.mode()===`cursor`&&(l=setTimeout(()=>{let t=gd(m,e.viewport(),n);t&&!o&&!s&&(e.send({type:`pointer`,action:`right`,...t}),c=!0)},550))),t.size===2&&(clearTimeout(l),s=!0,u=null,p(),f={...g(),transform:{...n}}))},move(d,p){if(t.has(d)){if(t.set(d,p),t.size===2&&f){let{midpoint:t,distance:r}=g(),i=Math.max(.5,Math.min(5,f.transform.scale*r/f.distance)),a=i/f.transform.scale;n=_d({scale:i,x:t.x-(f.midpoint.x-f.transform.x)*a,y:t.y-(f.midpoint.y-f.transform.y)*a},e.viewport(),.5),e.apply(n);return}if(!(s||c||!r||!i)&&(Math.hypot(p.x-r.x,p.y-r.y)>6&&(o=!0,u=null,clearTimeout(l)),o)){if(e.mode()===`drag`)n={...n,x:n.x+p.x-i.x,y:n.y+p.y-i.y},e.apply(n);else{let t=gd(p,e.viewport(),n);if(t){let i=gd(r,e.viewport(),n);!a&&i&&(e.send({type:`pointer`,action:`down`,...i}),a=!0),a&&e.send({type:`pointer`,action:`move`,...t})}}i=p}}},moveMany(e){let n;for(let[r,i]of e)t.has(r)&&(t.set(r,i),n=[r,i]);n&&_.move(...n)},up(a,h,g=!1){if(t.has(a)){if(clearTimeout(l),t.delete(a),e.mode()===`cursor`&&!g&&!s&&!o&&!c){let t=gd(h,e.viewport(),n);t&&e.send({type:`pointer`,action:`click`,...t})}if(e.mode()===`drag`&&!g&&!s&&!o&&Date.now()-d<450){let t=Date.now(),r={x:h.x,y:h.y,time:t};if(qn(u,r)){if(n.scale>1)n={...md};else{let t=2.5,r=t/n.scale;n=_d({scale:t,x:h.x-(h.x-n.x)*r,y:h.y-(h.y-n.y)*r},e.viewport())}e.apply(n,!0),u=null}else u=r}else u=null;p(),t.size||(f=null,r=i=null,s=!1,n.scale<=1&&m())}},cancel:h,refit(){if(n.scale<=1){m();return}n=_d(n,e.viewport()),e.apply(n)},reset(){h(),n={...md},e.apply(n)}};return _}function yd(e,t,n){return n===90?{x:e.y-t.top,y:t.right-e.x}:n===-90?{x:t.bottom-e.y,y:e.x-t.left}:{x:e.x-t.left,y:e.y-t.top}}var bd=me(`YuriOrientation`);function xd(){return J.isNativePlatform()&&J.isPluginAvailable(`YuriOrientation`)}function Sd(e){return bd.lock({orientation:e})}function Cd(e){let t=(0,Q.c)(14),[n,r]=(0,Z.useState)(kd),[i]=(0,Z.useState)(Od),[a,o]=(0,Z.useState)(i),[s]=(0,Z.useState)(xd),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{let[t]=e;if(!t)return;let{width:n,height:i}=t.contentRect;n>0&&i>0&&r(e=>e.width===n&&e.height===i?e:{width:n,height:i})},t[0]=c):c=t[0],pe(e,c);let l,u;t[1]!==s||t[2]!==a?(l=()=>{s&&Sd(a).catch(Dd)},u=[s,a],t[1]=s,t[2]=a,t[3]=l,t[4]=u):(l=t[3],u=t[4]),(0,Z.useEffect)(l,u);let d,f;t[5]===s?(d=t[6],f=t[7]):(d=()=>{if(s)return Td},f=[s],t[5]=s,t[6]=d,t[7]=f),(0,Z.useEffect)(d,f);let p=!s&&a!==i,m=p?90:0,h=p?n.height:n.width,g=p?n.width:n.height,_;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>o(wd),t[8]=_):_=t[8];let v;return t[9]!==a||t[10]!==m||t[11]!==h||t[12]!==g?(v={orientation:a,rotation:m,width:h,height:g,toggle:_},t[9]=a,t[10]=m,t[11]=h,t[12]=g,t[13]=v):v=t[13],v}function wd(e){return e===`portrait`?`landscape`:`portrait`}function Td(){Sd(`portrait`).catch(Ed)}function Ed(){}function Dd(){}function Od(){return window.innerWidth>window.innerHeight?`landscape`:`portrait`}function kd(){return{width:window.innerWidth,height:window.innerHeight}}var Ad=(e,t)=>({queryKey:[e,`remote-desktop`,t],queryFn:async({signal:n})=>{let r=()=>{if(e!==l()||t!==d())throw Error(`runtime_changed`)};r();let i=new AbortController,a=()=>i.abort();n.addEventListener(`abort`,a,{once:!0}),n.aborted&&a();let o;try{return await Promise.race([(async()=>{let e=await m(`/api/remote-desktop`,{signal:i.signal,headers:{Accept:`application/json`}});if(r(),[401,403].includes(e.status))throw Error(`authentication_required`);if([404,501].includes(e.status))throw Error(`unsupported`);if(!e.ok)throw Error(`connection_failed`);if(!e.headers.get(`content-type`)?.includes(`application/json`))throw Error(`unsupported`);let t=await e.json();if(r(),!t||typeof t!=`object`||!(`supported`in t)||typeof t.supported!=`boolean`)throw Error(`unsupported`);return{supported:t.supported,enabled:`enabled`in t&&t.enabled===!0}})(),new Promise((e,t)=>{o=setTimeout(()=>{a(),t(Error(`connection_failed`))},1e4)})])}finally{clearTimeout(o),n.removeEventListener(`abort`,a)}},staleTime:3e4,retry:!1,refetchInterval:e=>{let t=e.state.error;return!t||[`unsupported`,`runtime_changed`,`authentication_required`].includes(t.message)?!1:Math.min(1e3*2**Math.min(Math.max(0,e.state.errorUpdateCount-1),5),3e4)},refetchIntervalInBackground:!1}),jd=(e,t)=>{let n=(0,Q.c)(3),r;return n[0]!==t||n[1]!==e?(r=Ad(e,t),n[0]=t,n[1]=e,n[2]=r):r=n[2],ne(r)},Md=[{key:`Escape`,icon:`corner-up-left`},{key:`Tab`,icon:`arrow-right-to-line`},{key:`Backspace`,icon:`delete-back`},{key:`Enter`,icon:`corner-down-left`},{key:`ArrowLeft`,icon:`arrow-left`},{key:`ArrowUp`,icon:`arrow-up`},{key:`ArrowDown`,icon:`arrow-down`},{key:`ArrowRight`,icon:`arrow-right`}];function Nd({onClose:e,instanceName:t}){let{t:n}=Te(),[r]=Z.useState(()=>({transport:l(),generation:d()})),i=jd(r.transport,r.generation),[a,o]=Z.useState(0),[s,c]=Z.useState(`connecting`),[u,f]=Z.useState(),[p,m]=Z.useState(`drag`),[h,g]=Z.useState(!1),[_,v]=Z.useState(``),y=Z.useRef(null),b=Z.useRef(null),x=Cd(b),S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(null),T=Z.useRef({width:1,height:1,remoteWidth:1920,remoteHeight:1080}),E=Z.useRef(null),D=Z.useRef(null),O=Z.useRef(new Map),k=Z.useRef(new Set),A=Z.useRef(!1),j=q(e=>{E.current?.send(e)}),M=q(()=>p),[N]=Z.useState(()=>vd({viewport:()=>T.current,send:j,mode:M,apply:(e,t)=>{let n=e.scale>(A.current?1.01:1.05);n!==A.current&&(A.current=n,E.current?.setZoomed(n)),S.current&&(S.current.style.transition=t&&!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`transform 180ms ease-out`:`none`,S.current.style.transform=`translate(${e.x}px, ${e.y}px) scale(${e.scale})`)}})),P=q(()=>{if(D.current!==null&&cancelAnimationFrame(D.current),D.current=null,O.current.size&&y.current){let e=y.current.getBoundingClientRect(),t=new Map([...O.current].map(([t,n])=>[t,yd(n,e,x.rotation)]));N.moveMany(t)}O.current.clear()}),F=q(()=>{P(),N.reset(),E.current?.close(),E.current=null}),I=q(()=>{F(),e()});Fr({id:`remote-desktop-page`,active:!0,layer:`root`,onBack:I,surfaceRef:b}),Z.useEffect(()=>An(`remote-desktop-page`),[]),Z.useLayoutEffect(()=>{let e=document.activeElement;return b.current?.focus({preventScroll:!0}),()=>{e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),K(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),Rr.requestBrowserBack())},()=>document);let L=q((e,t)=>{(e===`closed`||e===`connecting`)&&(O.current.clear(),k.current.clear(),N.cancel()),c(e),f(t)}),R=q((e,t)=>{if(e<=0||t<=0||T.current.remoteWidth===e&&T.current.remoteHeight===t)return;let n=T.current;T.current={...n,remoteWidth:e,remoteHeight:t},!(Math.abs(n.remoteWidth/n.remoteHeight-e/t)<.01)&&!k.current.size&&N.reset()});pe(y,([e])=>{if(!e)return;let{width:t,height:n}=e.contentRect,r=Math.abs(T.current.width-t)>=1||Math.abs(T.current.height-n)>=1;T.current={...T.current,width:t,height:n},r&&!k.current.size&&N.refit()}),ei(y),Z.useEffect(()=>{if(!i.data?.supported||!i.data.enabled||!C.current||!w.current)return;let e=fd({...r,video:C.current,image:w.current,onSize:R,onState:L});return E.current=e,e.setZoomed(A.current),()=>{e.close(),E.current=null}},[i.data?.supported,i.data?.enabled,r,a,R,L]),Z.useEffect(()=>()=>{P(),N.reset()},[P,N]);let ee=e=>{let t=y.current.getBoundingClientRect();return yd({x:e.clientX,y:e.clientY},t,x.rotation)},z=s===`webrtc`||s===`tunnel`,B=i.data?.supported===!1||i.error?.message===`unsupported`,V=i.data?.supported===!0&&i.data.enabled!==!0,te=B||u===`helper_unavailable`?n(`remoteDesktop.unsupported`):V||u===`disabled`?n(`settings.remoteDesktop.disabled`):u===`permission_required`?n(`remoteDesktop.permissions`):u===`permission_denied`?n(`remoteDesktop.denied`):u===`runtime_changed`||i.error?.message===`runtime_changed`?n(`remoteDesktop.runtimeChanged`):u||i.error||s===`closed`?n(`remoteDesktop.failed`):n(`remoteDesktop.connecting`);return(0,_l.createPortal)((0,$.jsx)(`div`,{ref:b,tabIndex:-1,"data-remote-desktop-page":!0,className:`yuri-keyboard-inset-surface yuri-keyboard-inset-snap fixed inset-0 z-[150] overflow-clip bg-background text-foreground outline-none`,children:(0,$.jsxs)(`main`,{"aria-label":t?`${n(`remoteDesktop.title`)} · ${t}`:n(`remoteDesktop.title`),className:`absolute left-0 top-0 flex flex-col overflow-clip bg-background`,style:{width:x.width,height:x.height,transformOrigin:`top left`,"--desktop-safe-top":`env(safe-area-inset-${x.rotation===90?`right`:x.rotation===-90?`left`:`top`}, 0px)`,"--desktop-safe-right":`env(safe-area-inset-${x.rotation===90?`bottom`:x.rotation===-90?`top`:`right`}, 0px)`,"--desktop-safe-bottom":`env(safe-area-inset-${x.rotation===90?`left`:x.rotation===-90?`right`:`bottom`}, 0px)`,"--desktop-safe-left":`env(safe-area-inset-${x.rotation===90?`top`:x.rotation===-90?`bottom`:`left`}, 0px)`,transform:x.rotation===90?`translateX(${x.height}px) rotate(90deg)`:x.rotation===-90?`translateY(${x.width}px) rotate(-90deg)`:void 0},children:[(0,$.jsxs)(`div`,{"data-remote-desktop-stage-region":!0,className:`relative min-h-0 flex-1 overflow-clip`,children:[(0,$.jsxs)(`div`,{ref:y,className:`absolute inset-0 touch-none overflow-clip bg-background`,"aria-label":n(`remoteDesktop.screen`),onPointerDown:e=>{z&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),k.current.add(e.pointerId),P(),N.down(e.pointerId,ee(e)))},onPointerMove:e=>{!z||!k.current.has(e.pointerId)||(e.preventDefault(),O.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),D.current===null&&(D.current=requestAnimationFrame(P)))},onPointerUp:e=>{P(),N.up(e.pointerId,ee(e)),k.current.delete(e.pointerId),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:e=>{P(),N.up(e.pointerId,ee(e),!0),k.current.delete(e.pointerId)},onContextMenu:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{ref:S,className:`absolute inset-0 origin-top-left will-change-transform`,children:[(0,$.jsx)(`video`,{ref:C,autoPlay:!0,muted:!0,playsInline:!0,className:`pointer-events-none absolute inset-0 size-full object-contain`,style:{visibility:s===`webrtc`?`visible`:`hidden`}}),(0,$.jsx)(`img`,{ref:w,alt:n(`remoteDesktop.screen`),draggable:!1,className:`pointer-events-none absolute inset-0 size-full object-contain`,style:{visibility:s===`tunnel`?`visible`:`hidden`}})]}),!z&&(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-4 p-6 text-center text-sm text-muted-foreground`,role:`status`,children:[s===`connecting`&&!u&&!i.error&&!B&&!V&&(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin`}),(0,$.jsx)(`p`,{children:te}),(s===`closed`||i.error||V)&&!B&&u!==`runtime_changed`&&i.error?.message!==`runtime_changed`&&(0,$.jsx)(Y,{onClick:()=>{F(),f(void 0),c(`connecting`),i.error||V?i.refetch():o(e=>e+1)},children:n(`remoteDesktop.retry`)})]})]}),(0,$.jsxs)(`div`,{className:`pointer-events-none absolute left-[max(0.75rem,var(--desktop-safe-left))] right-[max(0.75rem,var(--desktop-safe-right))] top-[max(0.75rem,var(--desktop-safe-top))] flex items-start justify-between gap-3`,children:[(0,$.jsx)(Y,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto`,"aria-label":n(`header.actions.backAria`),onClick:()=>Rr.requestBrowserBack(),children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(Y,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto`,"aria-label":n(`remoteDesktop.rotate`),title:n(`remoteDesktop.rotate`),onClick:()=>{P(),N.reset(),g(!1),x.toggle()},children:(0,$.jsx)(X,{name:`smartphone`,className:`size-5 rotate-45`})})]}),(0,$.jsx)(`p`,{className:`sr-only`,children:n(`remoteDesktop.hint`)}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute left-[max(0.75rem,var(--desktop-safe-left))] right-[max(0.75rem,var(--desktop-safe-right))] bottom-[max(0.75rem,var(--desktop-safe-bottom))] top-[calc(4rem+var(--desktop-safe-top))] flex flex-col items-end justify-end gap-3`,children:(0,$.jsxs)(`div`,{className:`flex w-full shrink-0 items-end justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`pointer-events-auto flex gap-3`,children:[(0,$.jsx)(Y,{size:`mobileIcon`,variant:`mobileGlass`,className:p===`drag`?`yuri-mobile-inverse-action`:void 0,"aria-label":n(`remoteDesktop.drag`),title:n(`remoteDesktop.drag`),"aria-pressed":p===`drag`,disabled:!z,onClick:()=>{P(),N.cancel(),m(`drag`)},children:(0,$.jsx)(X,{name:`hand`,className:`size-5`})}),(0,$.jsx)(Y,{size:`mobileIcon`,variant:`mobileGlass`,className:p===`cursor`?`yuri-mobile-inverse-action`:void 0,"aria-label":n(`remoteDesktop.cursor`),title:n(`remoteDesktop.cursor`),"aria-pressed":p===`cursor`,disabled:!z,onClick:()=>{P(),N.cancel(),m(`cursor`)},children:(0,$.jsx)(X,{name:`cursor`,className:`size-5`})})]}),(0,$.jsx)(Y,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto${h?` yuri-mobile-inverse-action`:``}`,disabled:!z,"aria-label":n(`remoteDesktop.text`),title:n(`remoteDesktop.text`),"aria-pressed":h,"aria-expanded":h,onClick:()=>g(e=>!e),children:(0,$.jsx)(X,{name:`keyboard`,className:`size-5`})})]})})]}),h&&(0,$.jsxs)(`footer`,{"data-remote-desktop-keyboard":!0,className:`max-h-[50%] w-full shrink-0 overflow-y-auto overscroll-contain border-t border-border bg-[var(--surface-elevated)] pt-3 pl-[max(0.75rem,var(--desktop-safe-left))] pr-[max(0.75rem,var(--desktop-safe-right))] pb-[max(0.75rem,var(--desktop-safe-bottom))]`,children:[(0,$.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),_&&z&&(j({type:`text`,text:_}),v(``))},children:[(0,$.jsx)(Kn,{className:`min-w-0 flex-1`,value:_,maxLength:1024,onChange:e=>v(e.target.value),placeholder:n(`remoteDesktop.text`),"aria-label":n(`remoteDesktop.text`),disabled:!z,autoComplete:`off`}),(0,$.jsx)(Y,{type:`submit`,size:`icon`,disabled:!z||!_,"aria-label":n(`remoteDesktop.send`),children:(0,$.jsx)(X,{name:`send-plane-2`,className:`size-4`})})]}),(0,$.jsx)(`div`,{className:`mt-2 grid grid-cols-4 gap-1 min-[360px]:grid-cols-8`,children:Md.map(({key:e,icon:t})=>(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`w-full`,disabled:!z,onClick:()=>j({type:`key`,key:e}),"aria-label":n(`remoteDesktop.pressKey`,{key:e}),title:n(`remoteDesktop.pressKey`,{key:e}),children:(0,$.jsx)(X,{name:t,className:`size-4`})},e))})]})]})}),document.body)}var Pd=Z.memo(Nd);function Fd(e){let t=(0,Q.c)(22),{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}=Te(),f=W(),p=q(i),m=q(a),h;t[0]!==f||t[1]!==n?(h=f?.entry.location.hostId?(0,$.jsx)(Id,{host:f}):n,t[0]=f,t[1]=n,t[2]=h):h=t[2];let g;t[3]===d?g=t[4]:(g=d(`header.actions.backAria`),t[3]=d,t[4]=g);let _=u||l,v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Ca,{mobile:!0}),t[5]=v):v=t[5];let y;t[6]===c?y=t[7]:(y=(0,$.jsxs)($.Fragment,{children:[v,c]}),t[6]=c,t[7]=y);let b;t[8]===d?b=t[9]:(b=d(`mobile.menu.titleAria`),t[8]=d,t[9]=b);let x;t[10]!==m||t[11]!==l||t[12]!==b?(x=[{icon:`more-2`,ariaLabel:b,onClick:m,pressed:l}],t[10]=m,t[11]=l,t[12]=b,t[13]=x):x=t[13];let S;return t[14]!==p||t[15]!==r||t[16]!==h||t[17]!==g||t[18]!==_||t[19]!==y||t[20]!==x?(S=(0,$.jsx)(ze,{title:h,subtitle:r,backAriaLabel:g,onBack:p,overlay:!0,collapsible:!0,elevated:_,trailing:y,actions:x}),t[14]=p,t[15]=r,t[16]=h,t[17]=g,t[18]=_,t[19]=y,t[20]=x,t[21]=S):S=t[21],S}function Id(e){let t=(0,Q.c)(22),{host:n}=e,{t:r}=Te(),{location:i}=n.entry,a;t[0]!==i.directory||t[1]!==i.hostId||t[2]!==i.hubId?(a=e=>e.remoteSession?.location.hubId===i.hubId&&e.remoteSession.location.hostId===i.hostId&&e.remoteSession.location.directory===i.directory?e.remoteSession:null,t[0]=i.directory,t[1]=i.hostId,t[2]=i.hubId,t[3]=a):a=t[3];let o=st(a),s=o?.sessionId,c=Zt(n.registry,i.hostId),l;t[4]!==i.directory||t[5]!==s||t[6]!==c.data?.directories?(l=c.data?.directories.find(e=>e.directory===i.directory)?.sessions.find(e=>e.id===s),t[4]=i.directory,t[5]=s,t[6]=c.data?.directories,t[7]=l):l=t[7];let u=l,d;t[8]!==n.entry||t[9]!==o?.draft?.title||t[10]!==s||t[11]!==u?.title||t[12]!==r?(d=s?(0,$.jsx)(Ld,{entry:n.entry,sessionId:s,fallback:u?.title||r(`mobile.sessions.untitled`)}):o?.draft?.title||r(`mobile.menu.newSession`),t[8]=n.entry,t[9]=o?.draft?.title,t[10]=s,t[11]=u?.title,t[12]=r,t[13]=d):d=t[13];let f;t[14]===d?f=t[15]:(f=(0,$.jsx)(`span`,{className:`truncate`,children:d}),t[14]=d,t[15]=f);let p;t[16]!==n.registry||t[17]!==i.hostId?(p=(0,$.jsx)(Sn,{registry:n.registry,hostId:i.hostId,showName:!0}),t[16]=n.registry,t[17]=i.hostId,t[18]=p):p=t[18];let m;return t[19]!==f||t[20]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[f,p]}),t[19]=f,t[20]=p,t[21]=m):m=t[21],m}var Ld=(0,Z.memo)(function(e){let t=(0,Q.c)(10),{entry:n,sessionId:r,fallback:i}=e,a;t[0]!==n.queryScope||t[1]!==r?(a=[...n.queryScope,`chat`,r,`session`],t[0]=n.queryScope,t[1]=r,t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=e=>e.id===r&&e.title?.trim()||null,t[3]=r,t[4]=o);let s;t[5]!==a||t[6]!==o?(s={queryKey:a,queryFn:V,enabled:!1,staleTime:1/0,gcTime:1/0,select:o},t[5]=a,t[6]=o,t[7]=s):s=t[7];let c=ne(s,le).data??i,l;return t[8]===c?l=t[9]:(l=(0,$.jsx)($.Fragment,{children:c}),t[8]=c,t[9]=l),l});function Rd(e){return e.sessionId?e.userRefreshInFlight||e.backgroundResyncInFlight?`syncing`:e.hasRenderableTranscript?null:!e.isConnected&&e.connectionPhase===`reconnecting`||e.loadStatus!==`error`?`syncing`:null:null}function zd(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 Bd(e,t){let n=(0,Q.c)(10),r;n[0]===t?r=n[1]:(r={key:t},n[0]=t,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a={scope:i,visible:!1},n[2]=i,n[3]=a);let[o,s]=(0,Z.useState)(a),c;n[4]===i?c=n[5]:(c=zd(e=>s({scope:i,visible:e})),n[4]=i,n[5]=c);let l=c,u,d;return n[6]!==e||n[7]!==l?(u=()=>(l.setRaw(e),()=>l.cancel()),d=[e,l],n[6]=e,n[7]=l,n[8]=u,n[9]=d):(u=n[8],d=n[9]),(0,Z.useEffect)(u,d),o.scope===i&&o.visible}function Vd(e,t){let n=(0,Q.c)(20),{t:r}=Te(),i=Mt(e,t),{renderable:a}=pt(e,t),o=lt(Gd),s=lt(Wd),c;n[0]!==t||n[1]!==e?(c=()=>R(e,t),n[0]=t,n[1]=e,n[2]=c):c=n[2];let l=(0,Z.useSyncExternalStore)(P,c,Ud),u;n[3]!==t||n[4]!==e?(u=()=>yt(e,t),n[3]=t,n[4]=e,n[5]=u):u=n[5];let d=(0,Z.useSyncExternalStore)(_t,u,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=Rd({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=Bd(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 Ud(){return!1}function Wd(e){return e.connectionPhase}function Gd(e){return e.isConnected}function Kd(e,t){let n=(0,Q.c)(38),{t:r}=Te(),i=re(e.registry,e.entry.location.hostId),a=(0,Z.useSyncExternalStore)(I,M,M),o;n[0]===e.entry.location?o=n[1]:(o=N(e.entry.location),n[0]=e.entry.location,n[1]=o);let s=o,c;n[2]!==e.entry.location||n[3]!==s||n[4]!==t?(c=s&&t?L(e.entry.location,t):null,n[2]=e.entry.location,n[3]=s,n[4]=t,n[5]=c):c=n[5];let l;n[6]!==a||n[7]!==c?(l={revision:a,scope:c},n[6]=a,n[7]=c,n[8]=l):l=n[8];let u=l.scope,d;n[9]!==s||n[10]!==u?(d=e=>s&&u?s.subscribe(u,e):Yd,n[9]=s,n[10]=u,n[11]=d):d=n[11];let f=d,p;n[12]!==s||n[13]!==u||n[14]!==t?(p=()=>!s||!u?t?`loading`:`idle`:s.getHydrationState?.(u).p0Satisfied?`renderable`:s.getRequestState?.(u).status??`loading`,n[12]=s,n[13]=u,n[14]=t,n[15]=p):p=n[15];let m=p,h=(0,Z.useSyncExternalStore)(f,m,m),g;n[16]===e.entry.location?g=n[17]:(g=v(e.entry.location),n[16]=e.entry.location,n[17]=g);let _=g,y;n[18]!==_||n[19]!==t?(y=()=>R(t,_),n[18]=_,n[19]=t,n[20]=y):y=n[20];let b=(0,Z.useSyncExternalStore)(P,y,Jd),x;n[21]!==_||n[22]!==t?(x=()=>yt(t,_),n[21]=_,n[22]=t,n[23]=x):x=n[23];let S=(0,Z.useSyncExternalStore)(_t,x,qd),C=h===`renderable`,w=h===`error`?`error`:h===`ready`?`ready`:`loading`,T=i?.state===`connected`,E=i?.state===`connected`?`connected`:i?.state===`connecting`?`connecting`:`reconnecting`,D;n[24]!==S||n[25]!==t||n[26]!==T||n[27]!==E||n[28]!==C||n[29]!==w||n[30]!==b?(D=Rd({sessionId:t,hasRenderableTranscript:C,loadStatus:w,userRefreshInFlight:b,backgroundResyncInFlight:S,isConnected:T,connectionPhase:E}),n[24]=S,n[25]=t,n[26]=T,n[27]=E,n[28]=C,n[29]=w,n[30]=b,n[31]=D):D=n[31];let O=D,k;n[32]!==_||n[33]!==t?(k=JSON.stringify([_,t]),n[32]=_,n[33]=t,n[34]=k):k=n[34];let A=Bd(O===`syncing`,k),j;return n[35]!==r||n[36]!==A?(j=A?r(`mobile.chat.syncingMessages`):null,n[35]=r,n[36]=A,n[37]=j):j=n[37],j}function qd(){return!1}function Jd(){return!1}function Yd(){}function Xd(e){let t=(0,Q.c)(3),n=W(),r;return t[0]!==n||t[1]!==e?(r=n?.entry.location.hostId?(0,$.jsx)(Qd,{...e,host:n}):(0,$.jsx)(Zd,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}function Zd(e){let t=(0,Q.c)(15),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({sessionId:i,directory:n,title:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{t:o}=Te(),s=i.length===0,c=Ze(s?null:i),l;t[5]!==s||t[6]!==c?.title||t[7]!==o||t[8]!==a?(l=s?a?.trim()||o(`mobile.menu.newSession`):a?.trim()||c?.title?.trim()||o(`mobile.sessions.untitled`),t[5]=s,t[6]=c?.title,t[7]=o,t[8]=a,t[9]=l):l=t[9];let u=l,d=Vd(s?``:i,n||void 0),f;return t[10]!==r||t[11]!==u||t[12]!==i||t[13]!==d?(f=(0,$.jsx)($d,{...r,sessionId:i,title:u,syncHint:d}),t[10]=r,t[11]=u,t[12]=i,t[13]=d,t[14]=f):f=t[14],f}function Qd(e){let t=(0,Q.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({host:n,sessionId:i,title:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]!==n.entry.location.directory||t[6]!==n.entry.location.hostId||t[7]!==n.entry.location.hubId?(o=e=>{let t=e.remoteSession;return t?.location.hubId===n.entry.location.hubId&&t.location.hostId===n.entry.location.hostId&&t.location.directory===n.entry.location.directory?t.sessionId:null},t[5]=n.entry.location.directory,t[6]=n.entry.location.hostId,t[7]=n.entry.location.hubId,t[8]=o):o=t[8];let s=st(o),c=i||s||``,l=Kd(n,c),u;return t[9]!==c||t[10]!==r||t[11]!==l||t[12]!==a?(u=(0,$.jsx)($d,{...r,sessionId:c,title:a,syncHint:l}),t[9]=c,t[10]=r,t[11]=l,t[12]=a,t[13]=u):u=t[13],u}function $d(e){let t=(0,Q.c)(31),{sessionId:n,title:r,onBack:i,onOpenMenu:a,onCloseMenu:o,menuOpen:s,children:c,className:l,syncHint:u}=e,d=s!==void 0&&s,{t:f}=Te(),[p,m]=Z.useState(!1),h;t[0]!==d||t[1]!==o?(h=e=>{e&&d&&o?.(),m(e)},t[0]=d,t[1]=o,t[2]=h):h=t[2];let g=q(h),_;t[3]!==p||t[4]!==a?(_=()=>{p&&m(!1),a()},t[3]=p,t[4]=a,t[5]=_):_=t[5];let v=q(_),y=d||p,b;t[6]===l?b=t[7]:(b=it(`mobile-chat-screen relative isolate flex h-full min-h-0 w-full flex-col overflow-hidden bg-background text-foreground`,l),t[6]=l,t[7]=b);let x;t[8]!==n||t[9]!==f||t[10]!==r?(x=r||f(n?`mobile.sessions.untitled`:`mobile.menu.newSession`),t[8]=n,t[9]=f,t[10]=r,t[11]=x):x=t[11];let S;t[12]!==p||t[13]!==g||t[14]!==n?(S=(0,$.jsx)($s,{sessionId:n,open:p,onOpenChange:g}),t[12]=p,t[13]=g,t[14]=n,t[15]=S):S=t[15];let C;t[16]!==v||t[17]!==y||t[18]!==d||t[19]!==i||t[20]!==u||t[21]!==x||t[22]!==S?(C=(0,$.jsx)(Fd,{title:x,subtitle:u,onBack:i,onOpenMenu:v,menuOpen:d,elevated:y,trailing:S}),t[16]=v,t[17]=y,t[18]=d,t[19]=i,t[20]=u,t[21]=x,t[22]=S,t[23]=C):C=t[23];let w;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(w=it(`mobile-chat-screen__content relative h-full min-h-0 flex-1`,`[&_[data-scrollbar=chat]>.yuri-chat-scroll-content]:pt-[calc(max(0.625rem,var(--yuri-safe-area-top,0px))+var(--yuri-mobile-detail-navigation-height)+1.25rem)]`),t[24]=w):w=t[24];let T;t[25]===c?T=t[26]:(T=(0,$.jsx)(`div`,{className:w,children:c}),t[25]=c,t[26]=T);let E;return t[27]!==b||t[28]!==C||t[29]!==T?(E=(0,$.jsxs)(`main`,{className:b,children:[C,T]}),t[27]=b,t[28]=C,t[29]=T,t[30]=E):E=t[30],E}function ef(e){let t=(0,Q.c)(4),n=e===void 0?2500:e,{uiFont:r}=vi(),[i,a]=Z.useState(!1),o,s;return t[0]!==n||t[1]!==r?(o=()=>{let e=!1,t=()=>{e||a(!0)},i=()=>{requestAnimationFrame(()=>requestAnimationFrame(t))},o=Promise.all([Bn(r).catch(of),document.fonts?.ready?.then(af).catch(rf)??Promise.resolve(),co.catch(nf)]).then(tf),s=new Promise(e=>{window.setTimeout(e,n)});return Promise.race([o,s]).then(i),()=>{e=!0}},s=[r,n],t[0]=n,t[1]=r,t[2]=o,t[3]=s):(o=t[2],s=t[3]),Z.useEffect(o,s),i}function tf(){}function nf(){}function rf(){}function af(){}function of(){}var sf=e=>e.replace(/^\/+|\/+$/g,``),cf=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},lf=e=>{let t=sf(e.pathname).split(`/`).filter(Boolean);return e.host?[e.host,...t]:t};function uf(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=lf(t),r=(n[0]??``).toLowerCase(),i=n.slice(1),a=t.searchParams;switch(r){case`connect`:{let t=Ba(e);return t?{type:`connect`,pairing:t}:null}case`session`:{let e=i[0]||a.get(`id`)||``;return e?{type:`session`,sessionId:e,directory:cf(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:cf(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=cf(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 df={},ff=null,pf=!1,mf=null,hf=e=>{switch(e.type){case`connect`:return ff?(ff(e.pairing),!0):!1;case`session`:return _()?(Ot.getState().setCurrentSession(e.sessionId,e.directory??null),!0):(jt.getState().openSession({sessionId:e.sessionId,directory:e.directory??null}),!0);case`assistant`:if(!_()){let t=jt.getState();return t.setActiveTab(`assistant`),t.openAssistant(e.assistantId),!0}return Ht(e.assistantId),!0;case`new-session`:return _()?(Ot.getState().openNewSessionDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0):(jt.getState().openDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0);case`open-project`:return _()?(Ot.getState().openNewSessionDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0):(jt.getState().openDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0);case`sessions`:return df.openSessions?(df.openSessions(e.filter),!0):!1;case`status`:return df.openSessions?(df.openSessions(),!0):(ge.getState().setMobileSessionPanelOpen(!0),!0);case`view`:return df.openView?(df.openView(e.target),!0):!1;case`changes`:return df.openChanges?(df.openChanges({path:e.path,staged:e.staged}),!0):!1;case`settings`:return df.openSettings?(df.openSettings(e.section),!0):!1}return!1},gf=()=>{if(!mf||!pf&&mf.type!==`connect`)return;let e=mf;mf=null,hf(e)||(mf=e)},_f=e=>{mf=e,gf()},vf=e=>{let t=uf(e);t&&_f(t)},yf=e=>{pf=e,gf()},bf=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(df=e,gf(),()=>{df===e&&(df={})}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},xf=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(ff=e,gf(),()=>{ff===e&&(ff=null)}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},Sf=e=>{let{ready:t}=e,[n,r]=Z.useState(()=>g()?`pending`:`none`);return Z.useEffect(()=>{yf(t)},[t]),Z.useEffect(()=>{if(!g())return;let e=!1,t=[];return he(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=>{vf(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=uf(a?.url);r(o?.type===`connect`?`connect`:o?`other`:`none`),o&&_f(o)}).catch(()=>{e||r(`none`)}),he(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-D5cqJIPw.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([80,1,2])).then(async({PushNotifications:n})=>{if(e)return;let r=await n.addListener(`pushNotificationActionPerformed`,e=>{let t=e?.notification?.data,n=typeof t?.url==`string`?t.url:typeof t?.deeplink==`string`?t.deeplink:void 0;if(n){vf(n);return}let r=typeof t?.assistantID==`string`?t.assistantID.trim():``;if(r){_f({type:`assistant`,assistantId:r});return}let i=typeof t?.sessionId==`string`?t.sessionId:void 0;i&&_f({type:`session`,sessionId:i})});if(e){r.remove();return}t.push(()=>void r.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e())}},[]),n},Cf=.85,wf=8,Tf=.35,Ef=.22,Df=e=>({segmentStart:e,lastTouch:e,open:!1}),Of=e=>e*Tf,kf=e=>e*Ef,Af=(e,t)=>Math.max(0,e-t),jf=(e,t)=>Math.max(0,t-e),Mf=(e,t)=>{let n=Math.abs(e);return n<wf||Math.abs(t)<=n*Cf},Nf=(e,t,n)=>{let r=t.clientX-e.segmentStart.clientX,i=t.clientY-e.segmentStart.clientY,a=Af(e.segmentStart.clientX,t.clientX),o=Of(n),s=kf(n),c=e.open;return c=a<=0?!1:e.open?a>=s:a>=o&&Mf(r,i),{segmentStart:e.segmentStart,lastTouch:t,open:c}},Pf=e=>{if(e.disabled||e.startedOnExcludedTarget)return{open:!1,back:!1};let t=e.endX-e.startX,n=e.endY-e.startY,r=Af(e.startX,e.endX),i=jf(e.startX,e.endX),a=Of(e.viewportWidth),o=Mf(t,n);return{open:r>=a&&o,back:i>=a&&o}},Ff=(e,t,n)=>Math.min(Af(e,t)/Math.max(1,Of(n)),1),If=(e,t,n)=>Math.min(jf(e,t)/Math.max(1,Of(n)),1),Lf=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`)||Lf(t)},zf=1,Bf=(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===zf?n:n.parentElement;return!!(r&&t.contains(r))},Vf=e=>Bf(window.getSelection(),e),Hf=(e,t,n)=>{let r=Z.useRef(t.onOpen);r.current=t.onOpen;let i=Z.useRef(t.onPreviewStart);i.current=t.onPreviewStart;let a=Z.useRef(t.onPreviewCancel);a.current=t.onPreviewCancel;let o=Z.useRef(t.onProgress);o.current=t.onProgress;let s=Z.useRef(t.onBack);s.current=t.onBack;let c=Z.useRef(t.onBackProgress);c.current=t.onBackProgress;let l=Z.useRef(t.disabled);l.current=t.disabled,Z.useEffect(()=>{let t=e.current;if(!t)return;let n=!1,u=!1,d=null,f=!1,p=!1,m=!1,h=0,g=0,_=null,v=e=>{let t=Of(g),n=We({thresholdReached:p,distance:e,enterDistance:t,cancelDistance:kf(g),available:!0});p=n.thresholdReached,n.event===`enter`&&(m=Rt(`medium`,{bypassCadence:!0})),n.event===`cancel`&&(Rt(`light`,{bypassCadence:!0}),m=!1)},y=e=>{o.current?.(null),p&&!e&&Rt(`light`,{bypassCadence:!0}),p=!1,m=!1,e?r.current():f&&a.current?.(),f=!1},b=e=>{c.current?.(null),p&&!e&&Rt(`light`,{bypassCadence:!0}),p=!1,m=!1,e&&s.current?.()},x=e=>{if(e.touches.length!==1){n=!1,_=null;return}if(l.current){n=!1,_=null;return}let r=e.touches[0];n=!0,g=window.innerWidth,u=Rf(r)||Vf(t),d=null,f=!1,p=!1,m=!1,h=0,_=Df(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];_=Nf(_,r,g);let a=r.clientX-_.segmentStart.clientX,l=r.clientY-_.segmentStart.clientY;if(d===null){if(Vf(t))return;let e=Math.abs(a);if(e<wf||Math.abs(l)>e*Cf)return;if(a<0)d=`sessions`,f=!0,i.current?.();else if(s.current)d=`back`;else return}e.preventDefault(),h=d===`sessions`?Af(_.segmentStart.clientX,r.clientX):jf(_.segmentStart.clientX,r.clientX),v(h),d===`sessions`?o.current?.(Ff(_.segmentStart.clientX,r.clientX,g)):c.current?.(If(_.segmentStart.clientX,r.clientX,g))},C=e=>{if(!n||!_)return;if(n=!1,!d){_=null;return}let t=e.changedTouches[0];t&&(_=Nf(_,t,g),h=d===`sessions`?Af(_.segmentStart.clientX,t.clientX):jf(_.segmentStart.clientX,t.clientX),v(h));let r=d===`sessions`?_.open:Pf({startX:_.segmentStart.clientX,startY:_.segmentStart.clientY,endX:_.lastTouch.clientX,endY:_.lastTouch.clientY,viewportWidth:g,disabled:!1,startedOnExcludedTarget:!1}).back;_=null,e.preventDefault(),r&&!m&&Rt(`medium`,{bypassCadence:!0}),d===`sessions`?y(r):b(r)},w=()=>{d===`sessions`&&y(!1),d===`back`&&b(!1),n=!1,_=null};return t.addEventListener(`touchstart`,x,{passive:!0,capture:!0}),t.addEventListener(`touchmove`,S,{passive:!1,capture:!0}),t.addEventListener(`touchend`,C,{passive:!1,capture:!0}),t.addEventListener(`touchcancel`,w,{passive:!0,capture:!0}),()=>{f&&y(!1),d===`back`&&b(!1),t.removeEventListener(`touchstart`,x,!0),t.removeEventListener(`touchmove`,S,!0),t.removeEventListener(`touchend`,C,!0),t.removeEventListener(`touchcancel`,w,!0)}},[e,n])},Uf=me(`YuriNotifications`),Wf=()=>J.getPlatform()===`android`&&J.isPluginAvailable(`YuriNotifications`);async function Gf(e,n){let r=f(),a=t(),o=a?``:p();if(!a&&!/^https?:\/\//.test(o))return null;let s=await i();s.set(`Accept-Language`,n);let c=(await je()).find(e=>Ne(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 Kf(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 qf=()=>{if(Wf()||typeof window>`u`)return!1;let e=window.Capacitor?.getPlatform?.();return e===`ios`||e===`android`},Jf=(e,t)=>{x()?.push?.registerApnsToken?.({token:e,platform:y(),locale:t})},Yf=e=>{let{enabled:t}=e,n=ge(e=>e.nativeNotificationsEnabled),r=Ee(e=>e.locale),i=Z.useRef(null),a=Z.useRef(r);a.current=r,Z.useEffect(()=>{if(!t||!n||!qf())return;let e=!1,r=[];return he(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-D5cqJIPw.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([80,1,2])).then(async({PushNotifications:t})=>{if(e)return;let n=await t.checkPermissions().catch(()=>null);if(n?.receive!==`granted`&&(n=await t.requestPermissions().catch(()=>null)),n?.receive!==`granted`)return;let o=await t.addListener(`registration`,e=>{i.current=e.value,Jf(e.value,a.current)}),s=await t.addListener(`registrationError`,e=>{console.warn(`[Push] APNs registration error:`,e)});if(await t.register().catch(()=>void 0),e){o.remove(),s.remove();return}r.push(()=>void o.remove(),()=>void s.remove())}).catch(()=>void 0),()=>{e=!0,r.forEach(e=>e())}},[t,n]),Z.useEffect(()=>{if(!t||!n||!qf())return;let e=i.current;e&&Jf(e,r)},[t,n,r]),Z.useEffect(()=>{if(n)return;let e=i.current;e&&(i.current=null,x()?.push?.unregisterApnsToken?.({token:e}))},[n])},Xf=`YuriLiveActivity`,Zf=5e3,Qf=3600,$f=`live`,ep=me(Xf),tp=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable;function np(){return typeof window>`u`?!1:tp({isCapacitor:g(),platform:y(),pluginAvailable:J.isPluginAvailable(Xf)})}var rp=()=>ep,ip=new Set([`permission`,`input`,`retry`]),ap=()=>({trackedSessionId:null,started:!1,startedAt:null,busySince:null,lastStatus:null,eventVersion:0,items:[]}),op=(e,t)=>Math.max(Math.floor(e),t+1),sp=e=>e.failedEpoch===e.currentEpoch?e.previous:e.current,cp=e=>e.failedEpoch===e.currentEpoch&&e.retryCount<1,lp=e=>e.hasSessionError?`error`:e.hasPendingPermissions?`permission`:e.hasPendingQuestions?`input`:e.statusType===`retry`?`retry`:e.statusType===`busy`?`working`:e.statusType===`idle`?`complete`:null,up=e=>{let t=e.trim();return t.length<=80?t:`${t.slice(0,79)}…`},dp=e=>typeof e.parentID==`string`&&e.parentID.length>0?e.parentID:null,fp=e=>{if(e.runningIds.size===0)return[];let t=[];for(let n of e.sessions)!e.runningIds.has(n.id)||dp(n)||t.push({sessionId:n.id,title:up(n.title??``),statusType:e.statuses[n.id]?.type??`busy`});return t},pp=e=>e!==`complete`&&e!==`error`,mp=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`,hp=e=>{if(e.length<=4)return e;let t=e.filter(e=>pp(e.status)),n=e.filter(e=>!pp(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)},gp=(e,t,n,r)=>{if(n&&n.length>0)return n;let i=r?.[e];return i&&i.length>0?i:t},_p=(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=lp({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;o.push({sessionId:t.sessionId,title:gp(t.sessionId,t.title,e.title,r),status:i,startedAt:t.startedAt,busySince:i===`working`?t.busySince??n:null})}else if(pp(t.status))o.push({...t,title:gp(t.sessionId,t.title,void 0,r),status:`complete`,endedAt:n,busySince:null});else{let e=gp(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=lp({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 hp(o)},vp=e=>e.map(e=>`${e.sessionId}\0${e.title}\0${e.status}\0${e.endedAt??``}`).join(`
16
- `),yp=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}),bp=(e,t,n,r,i)=>{let a=e.filter(e=>pp(e.status)),o=a[0]??e[0],s={sessionId:$f,startedAt:o?.startedAt??r,status:t,eventVersion:n,updatedAt:r,title:o?.title,workingCount:a.length,items:yp(e)};return i?.endedAt!==void 0&&(s.endedAt=i.endedAt),i?.dismissalSeconds!==void 0&&(s.dismissalSeconds=i.dismissalSeconds),s},xp=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},Sp=(e,t,n,r)=>{let i=e.trackedSessionId;if(!i||!e.started)return{state:ap(),commands:[]};let a=op(t,e.eventVersion);return{state:ap(),commands:[{type:`end`,payload:xp({sessionId:i,startedAt:e.startedAt??t,status:n,eventVersion:a,updatedAt:t,endedAt:t,dismissalSeconds:r})}]}},Cp=(e,t,n,r,i)=>{let a=op(r,i);return{state:{trackedSessionId:e,started:!0,startedAt:n,busySince:null,lastStatus:t,eventVersion:a,items:[]},commands:[{type:`start`,payload:xp({sessionId:e,startedAt:n,status:t,eventVersion:a,updatedAt:r})}]}},wp=(e,t,n)=>{let r=lp(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=Zf-(t.now-(i??t.now));if(r>0)return{state:{...e,trackedSessionId:n,busySince:i},commands:[{type:`wait`,delayMs:r}]}}else if(!r||!ip.has(r))return{state:{...ap(),trackedSessionId:n},commands:[]};return Cp(n,r,i??t.now,t.now,e.eventVersion)}if(r===`complete`)return Sp({...e,busySince:i},t.now,`complete`,900);if(r===`error`)return Sp({...e,busySince:i},t.now,`error`,Qf);if(!r||r===e.lastStatus)return{state:{...e,trackedSessionId:n,busySince:i},commands:[]};let a=op(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:xp({sessionId:n,startedAt:e.startedAt??t.now,status:r,eventVersion:a,updatedAt:t.now})}]}},Tp=(e,t,n)=>{let r=e.trackedSessionId;if(!r||!e.started)return{state:e,commands:[]};let i=op(n,e.eventVersion);return{state:{...e,busySince:null,lastStatus:t,eventVersion:i},commands:[{type:`update`,payload:xp({sessionId:r,startedAt:e.startedAt??n,status:t,eventVersion:i,updatedAt:n})}]}},Ep=(e,t,n)=>{let r=_p(e.items,n,t.now,t.sessionTitles,t.rootSessionIds),i=r.filter(e=>pp(e.status)),a=mp(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=op(t.now,n.eventVersion),a=r.map(e=>pp(e.status)?{...e,status:`stale`}:e);return{state:{...n,items:a,lastStatus:`stale`,eventVersion:i,busySince:null},commands:[{type:`update`,payload:xp(bp(a,`stale`,i,t.now))}]}}if(!e.started){if(i.length===0)return{state:ap(),commands:[]};if(!i.some(e=>ip.has(e.status))){let n=Zf-(t.now-(o??t.now));if(n>0)return{state:{...e,trackedSessionId:$f,items:r,busySince:o},commands:[{type:`wait`,delayMs:n}]}}let n=o??t.now,s=r.map(e=>pp(e.status)?{...e,startedAt:e.busySince??n}:e),c=op(t.now,e.eventVersion);return{state:{trackedSessionId:$f,started:!0,startedAt:n,busySince:null,lastStatus:a,eventVersion:c,items:s},commands:[{type:`start`,payload:xp(bp(s,a,c,t.now))}]}}if(i.length===0){let n=r.some(e=>e.status===`error`)?`error`:`complete`,i=op(t.now,e.eventVersion);return{state:ap(),commands:[{type:`end`,payload:xp(bp(r,n,i,t.now,{endedAt:t.now,dismissalSeconds:n===`error`?Qf:900}))}]}}if(vp(e.items)===vp(r)&&e.lastStatus===a)return{state:{...e,trackedSessionId:$f,items:r,busySince:null},commands:[]};let s=op(t.now,e.eventVersion);return{state:{trackedSessionId:$f,started:!0,startedAt:e.startedAt??o??t.now,busySince:null,lastStatus:a,eventVersion:s,items:r},commands:[{type:`update`,payload:xp(bp(r,a,s,t.now))}]}},Dp=(e,t)=>{if(t.catalog)return Ep(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:[]}:Tp(n,`stale`,t.now)}let n=[],r=e;if(r.trackedSessionId&&r.trackedSessionId!==t.sessionId)if(r.started){let e=Sp(r,t.now,r.lastStatus??`complete`,0);n.push(...e.commands),r=e.state}else r=ap();if(!t.sessionId){if(r.started){let e=Sp(r,t.now,`complete`,900);return{state:e.state,commands:[...n,...e.commands]}}return{state:ap(),commands:n}}let i=wp(r,t,t.sessionId);return{state:i.state,commands:[...n,...i.commands]}},Op=e=>e/1e3,kp=e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Op(e.startedAt)};return e.endedAt!==void 0&&(t.endedAt=Op(e.endedAt)),t},Ap=e=>{let t={sessionId:e.sessionId,startedAt:Op(e.startedAt),status:e.status,eventVersion:e.eventVersion,updatedAt:Op(e.updatedAt)};return e.endedAt!==void 0&&(t.endedAt=Op(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(kp)),t},jp=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},Mp=(e,t,n)=>{if(!e||n.type===`wait`)return Promise.resolve();let r=Ap(n.payload),i=jp(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})},Np=e=>e.getCurrentEpoch()===e.epoch?!e.getCurrentSessionId||e.getCurrentSessionId()===e.observation.sessionId:!1,Pp=async e=>{let t=e.state;if(!Np(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let n=Dp(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 Np(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(!Np(e)||(await Mp(e.available,e.plugin,i),!Np(e)))return{state:t,delayMs:null,retry:!1,superseded:!0};let s=r===a.length-1;o=i.type===`end`&&!s?ap():n.state}return{state:n.state,delayMs:i,retry:!1,superseded:!1}}catch{if(!Np(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let r=sp({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),previous:o,current:n.state}),i=cp({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),retryCount:e.retryCount});return{state:r,delayMs:i?250:null,retry:i,superseded:!1}}},Fp=()=>({desired:null,registered:null}),Ip=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null},Lp=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=Ip(t.activityId),r=Ip(t.sessionId),i=Ip(t.token);return!n||!r||!i?null:{activityId:n,sessionId:r,token:i}},Rp=(e,t)=>e.activityId===t.activityId&&e.token===t.token,zp=(e,t)=>{let n=e.registered?.runtimeIdentity===t?e.registered:null;return e.desired===null&&n===e.registered?e:{desired:null,registered:n}},Bp=(e,t)=>{if(!t.connected)return[];if(e.desired&&t.enabled&&t.selectedSessionId&&e.desired.sessionId===t.selectedSessionId){let n=e.registered;return n&&Rp(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}]:[]},Vp=(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=zp(e,t.runtimeIdentity):e.registered&&e.registered.runtimeIdentity!==t.runtimeIdentity&&!e.desired&&(r={...e,registered:null});return{state:r,commands:Bp(r,t)}},Hp=async e=>{try{return await e}catch{return null}},Up=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 Hp(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 Hp(e.unregister({token:r.token}))}continue}if(n.runtimeIdentity!==e.getRuntimeIdentity()){t.registered?.runtimeIdentity===n.runtimeIdentity&&(t={...t,registered:null});continue}(await Hp(e.unregister(n.payload)))?.ok===!0&&t.registered?.token===n.payload.token&&(t={...t,registered:null})}return t},Wp=new Map,Gp=[];function Kp(){let e=np(),t=lt(e=>e.isConnected),n=Bt({enabled:e}),r=Tt(t=>e?t.statusById:Wp),i=Lt(t=>e?t.activeSessions:Gp),a=(0,Z.useMemo)(()=>e?Ge(n,r):new Set,[e,r,n]),o=(0,Z.useMemo)(()=>e?fp({runningIds:a,statuses:n,sessions:i}):[],[e,n,a,i]),c=(0,Z.useMemo)(()=>{if(!e)return{};let t={};for(let e of i){let n=e.parentID;if(typeof n==`string`&&n.length>0)continue;let r=typeof e.title==`string`?e.title.trim():``;r&&(t[e.id]=r.length<=80?r:`${r.slice(0,79)}…`)}return t},[e,i]),u=(0,Z.useMemo)(()=>{if(!e)return new Set;let t=new Set;for(let e of i){let n=e.parentID;typeof n==`string`&&n.length>0||t.add(e.id)}return t},[e,i]),d=(0,Z.useMemo)(()=>[o.map(e=>`${e.sessionId}\0${e.title}\0${e.statusType??``}`).join(`
17
- `),Object.entries(c).map(([e,t])=>`${e}\0${t}`).join(`
18
- `)].join(`
19
- ---
20
- `),[o,c]),f=(0,Z.useRef)(ap()),p=(0,Z.useRef)(Fp()),m=(0,Z.useRef)(null),h=(0,Z.useRef)(0),g=(0,Z.useRef)(Promise.resolve()),_=(0,Z.useRef)(Promise.resolve()),v=(0,Z.useRef)(null),y=q(()=>({sessionId:$f,statusType:void 0,hasPendingPermissions:!1,hasPendingQuestions:!1,hasSessionError:!1,now:Date.now(),connected:t,catalog:o,sessionTitles:c,rootSessionIds:u})),b=q(n=>{_.current=_.current.then(async()=>{let r=Vp(p.current,{selectedSessionId:$f,runtimeIdentity:l(),connected:t,enabled:e},n);p.current=r.state,r.commands.length!==0&&(p.current=await Up({state:p.current,commands:r.commands,getRuntimeIdentity:l,register:e=>x()?.push?.registerLiveActivityToken?.({...e,items:f.current.items.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Op(e.startedAt)};return e.endedAt===void 0?t:{...t,endedAt:Op(e.endedAt)}})})??Promise.resolve(null),unregister:e=>x()?.push?.unregisterLiveActivityToken?.(e)??Promise.resolve(null)}))}).catch(()=>void 0)}),S=q(e=>{let t=Lp(e);t&&b({type:`pushToken`,...t,sessionId:$f})});(0,Z.useEffect)(()=>{b({type:e?`sync`:`dispose`})},[e,t]),(0,Z.useEffect)(()=>s(()=>{b({type:`sync`})}),[]),(0,Z.useEffect)(()=>{if(!e){v.current?.remove(),v.current=null;return}let t=!1,n=null,r=0,i=rp(),a=h.current+1;h.current=a;let o=()=>{g.current=g.current.then(async()=>{if(t||h.current!==a)return;if(m.current!==!0){if(m.current===!1)return;let e=await i.isSupported().catch(()=>({supported:!1}));if(t||h.current!==a||(m.current=e.supported===!0,!m.current))return}let e=y(),s=f.current.started,c=await Pp({available:!0,plugin:i,state:f.current,observation:e,epoch:a,getCurrentEpoch:()=>h.current,retryCount:r});if(!(t||h.current!==a||c.superseded)){if(f.current=c.state,s&&!c.state.started)b({type:`localEndSucceeded`});else if(c.state.started){let e=p.current.desired;e&&x()?.push?.registerLiveActivityToken?.({activityId:e.activityId,sessionId:$f,token:e.token,items:c.state.items.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Op(e.startedAt)};return e.endedAt===void 0?t:{...t,endedAt:Op(e.endedAt)}})})}c.retry?r+=1:r=0,c.delayMs!=null&&(n=setTimeout(()=>{o()},c.delayMs))}}).catch(()=>void 0)};return g.current=g.current.then(async()=>{if(!(t||h.current!==a)&&!v.current)try{let e=await i.addListener(`pushToken`,e=>{S(e)});if(t){await e.remove();return}v.current=e}catch{return}}).then(()=>{!t&&h.current===a&&o()}).catch(()=>void 0),()=>{t=!0,h.current===a&&(h.current+=1),n!==null&&clearTimeout(n)}},[e,t,d]),(0,Z.useEffect)(()=>()=>{v.current?.remove(),v.current=null,b({type:`dispose`})},[])}function qp(){let e=(0,Q.c)(49),t=ge(Yp),{t:r,locale:i}=Te(),a;e[0]===r?a=e[1]:(a=r(`mobile.notifications.service`),e[0]=r,e[1]=a);let o=a,c;e[2]===r?c=e[3]:(c=r(`settings.page.notifications.title`),e[2]=r,e[3]=c);let l=c,u;e[4]===r?u=e[5]:(u=r(`mobile.connect.connecting`),e[4]=r,e[5]=u);let d=u,f;e[6]===r?f=e[7]:(f=r(`mobile.notifications.connected`),e[6]=r,e[7]=f);let p=f,m;e[8]===r?m=e[9]:(m=r(`layout.browserProvider.status.reconnecting`),e[8]=r,e[9]=m);let h=m,g;e[10]===r?g=e[11]:(g=r(`mobile.notifications.unavailable`),e[10]=r,e[11]=g);let _=g,v;e[12]===r?v=e[13]:(v=r(`mobile.notifications.gap`),e[12]=r,e[13]=v);let y=v,b;e[14]===r?b=e[15]:(b=r(`settings.notifications.page.toast.permissionDenied.title`),e[14]=r,e[15]=b);let x=b,S;e[16]===r?S=e[17]:(S=r(`settings.notifications.page.template.defaults.error.title`),e[16]=r,e[17]=S);let C=S,w;e[18]===r?w=e[19]:(w=r(`mobile.notifications.auth`),e[18]=r,e[19]=w);let T=w,E;e[20]===r?E=e[21]:(E=r(`mobile.notifications.endpoint`),e[20]=r,e[21]=E);let D=E,O;e[22]===r?O=e[23]:(O=r(`mobile.notifications.response`),e[22]=r,e[23]=O);let k=O,A;e[24]===r?A=e[25]:(A=r(`mobile.notifications.server`),e[24]=r,e[25]=A);let j=A,M;e[26]===r?M=e[27]:(M=r(`mobile.notifications.relay`),e[26]=r,e[27]=M);let N=M,P;e[28]===r?P=e[29]:(P=r(`mobile.notifications.identity`),e[28]=r,e[29]=P);let F=P,I,L;e[30]!==l||e[31]!==T||e[32]!==p||e[33]!==d||e[34]!==x||e[35]!==t||e[36]!==D||e[37]!==C||e[38]!==y||e[39]!==F||e[40]!==i||e[41]!==h||e[42]!==N||e[43]!==k||e[44]!==j||e[45]!==o||e[46]!==_?(I=()=>{if(!Wf())return;if(!t){Uf.stop().catch(Jp);return}let e=!1,r=t=>{e||(e=!0,at.error(t))},a=Kf({plugin:Uf,resolveConfig:()=>Gf({service:o,alerts:l,connecting:d,connected:p,reconnecting:h,unavailable:_,gap:y,error:C,auth:T,endpoint:D,response:k,server:j,relay:N,identity:F},i),onState:e=>{(e===`denied`||e===`unavailable`)&&r(e===`denied`?x:_)},onError:()=>r(_)}),c=s(()=>{a.refresh()}),u=n(e=>{let{reason:t}=e;t===`invalidate`?a.stop():t!==`endpoint-switch`&&a.refresh()});return a.refresh(),()=>{c(),u(),a.dispose()}},L=[t,i,o,l,d,p,h,_,y,x,C,T,D,k,j,N,F],e[30]=l,e[31]=T,e[32]=p,e[33]=d,e[34]=x,e[35]=t,e[36]=D,e[37]=C,e[38]=y,e[39]=F,e[40]=i,e[41]=h,e[42]=N,e[43]=k,e[44]=j,e[45]=o,e[46]=_,e[47]=I,e[48]=L):(I=e[47],L=e[48]),(0,Z.useEffect)(I,L)}function Jp(){console.warn(`[Native notifications] stop failed`)}function Yp(e){return e.nativeNotificationsEnabled}function Xp(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Vi,{children:(0,$.jsx)(Xd,{...e})}),t[0]=e,t[1]=n),n}function Zp(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Vi,{children:(0,$.jsx)(Ii,{...e})}),t[0]=e,t[1]=n),n}function Qp(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Vi,{children:(0,$.jsx)(Ci,{...e})}),t[0]=e,t[1]=n),n}function $p(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Vi,{children:(0,$.jsx)(El,{...e})}),t[0]=e,t[1]=n),n}function em(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Vi,{children:(0,$.jsx)(ml,{...e})}),t[0]=e,t[1]=n),n}function tm(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Vi,{children:(0,$.jsx)(As,{})}),e[0]=t):t=e[0],t}var nm=`mobile-direct-diff`,rm=`mobile-turn-diff`,im=`mobile-direct-file`,am=`mobile-files`,om=`mobile-changes`,sm=`mobile-mcp`,cm=`mobile-settings`,lm=`mobile-update`,um=`mobile-overflow-menu`,dm=320,fm=380,pm=280,mm=560,hm=380,gm=e=>Math.min(mm,Math.max(pm,Math.round(e))),_m=(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 vm(e,t,n){let r=(0,Q.c)(17),i=Z.useRef(null),a;r[0]!==n||r[1]!==t?(a=()=>{if(typeof window>`u`)return n;let e=Number.parseInt(window.localStorage.getItem(t)??``,10);return Number.isFinite(e)?Math.min(mm,Math.max(pm,e)):n},r[0]=n,r[1]=t,r[2]=a):a=r[2];let[o,s]=Z.useState(a),[c,l]=Z.useState(!1),u=Z.useRef(0),d=Z.useRef(o),f=Z.useRef(null),p=Z.useRef(null),m;r[3]===o?m=r[4]:(m=e=>{try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}p.current=e.pointerId,u.current=e.clientX,d.current=o,f.current=o,l(!0),e.preventDefault()},r[3]=o,r[4]=m);let h=q(m),g;r[5]===e?g=r[6]:(g=t=>{if(p.current!==t.pointerId)return;let n=t.clientX-u.current,r=gm(d.current+(e===`left`?n:-n));f.current!==r&&(f.current=r,_m(i,r))},r[5]=e,r[6]=g);let _=q(g),v;r[7]===t?v=r[8]:(v=e=>{if(p.current!==e.pointerId)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let n=gm(f.current??d.current);p.current=null,f.current=null,l(!1),s(n);try{window.localStorage.setItem(t,String(n))}catch{}},r[7]=t,r[8]=v);let y=q(v),b;r[9]!==h||r[10]!==y||r[11]!==_?(b={onPointerDown:h,onPointerMove:_,onPointerUp:y,onPointerCancel:y},r[9]=h,r[10]=y,r[11]=_,r[12]=b):b=r[12];let x=b,S;return r[13]!==x||r[14]!==c||r[15]!==o?(S={asideRef:i,width:o,isResizing:c,handleProps:x},r[13]=x,r[14]=c,r[15]=o,r[16]=S):S=r[16],S}var ym=e=>{let t=(0,Q.c)(12),{side:n,isResizing:r,ariaLabel:i,handleProps:a}=e,o=n===`left`?`right-0`:`left-0`,s;t[0]===o?s=t[1]:(s=it(`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=it(`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},bm=()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,xm=()=>{Z.useEffect(()=>{if(!bm())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 he(async()=>{let{StatusBar:e,Style:t}=await import(`./vendor-capacitor-status-bar-D9bcMr9Q.js`).then(e=>e.t);return{StatusBar:e,Style:t}},__vite__mapDeps([81,1,2])).then(async({StatusBar:n,Style:r})=>{if(e)return;let i=window.Capacitor?.getPlatform?.(),a=async()=>{if(i===`android`){let e=document.documentElement.classList.contains(`dark`),t=(e?localStorage.getItem(`splashBgDark`):localStorage.getItem(`splashBgLight`))||(e?`#121212`:`#FFFFFF`);await n.setOverlaysWebView({overlay:!1}).catch(()=>void 0),await n.setBackgroundColor({color:t}).catch(()=>void 0),await n.setStyle({style:e?r.Dark:r.Light}).catch(()=>void 0),await n.show().catch(()=>void 0);return}await n.setStyle({style:r.Default}).catch(()=>void 0),await n.setOverlaysWebView({overlay:!0}).catch(()=>void 0),await n.show().catch(()=>void 0)};await a();let o=window.setTimeout(()=>void a(),400);t.push(()=>window.clearTimeout(o));let{App:s}=await he(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),c=await s.addListener(`appStateChange`,({isActive:e})=>{if(e&&a(),!e&&i===`ios`){let e=document.activeElement;e instanceof HTMLElement&&cl(e)&&e.blur()}});if(e){c.remove();return}t.push(()=>void c.remove())}).catch(()=>void 0),he(async()=>{let{Keyboard:e}=await import(`./vendor-capacitor-keyboard-BRVcFyc9.js`).then(e=>e.t);return{Keyboard:e}},__vite__mapDeps([82,1,2])).then(async({Keyboard:i})=>{if(e)return;let a=window.Capacitor?.getPlatform?.(),o=a===`android`;await i.setAccessoryBarVisible({isVisible:!1}).catch(()=>void 0);let s=`cubic-bezier(0.38, 0.7, 0.125, 1)`,c=null,l=null,u=0,d=!1,f=0,p=!1,m=(e,t)=>{n.style.setProperty(e,`${Math.max(0,Math.round(t))}px`)},h=()=>{c!==null&&(window.clearTimeout(c),c=null)},g=(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))},_=e=>e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`,v=e=>{for(let t of document.querySelectorAll(e))if(_(t))return t;return null},y=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.isContentEditable),b=()=>{for(let e of document.querySelectorAll(`.yuri-mobile-composer, .yuri-draft-center`))e.style.transition=``,e.style.transform=``},x=()=>{let e=document.querySelector(`.yuri-mobile-app-shell`);f=e&&parseFloat(getComputedStyle(e).paddingBottom)||0},S=!o&&a===`ios`,C=null,w=()=>{let e=document.activeElement,t=!(S&&sl(n.classList.contains(`yuri-native-ios-composer`),e))&&(y(e)?cl(e):C===!0);t!==C&&(C=t,r(t?0:u),m(`--yuri-kb-layout`,0),x(),m(`--yuri-kb-scroll-inset`,t?0:Math.max(0,u-f)),n.classList.remove(`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-caret-hold`,`yuri-kb-hide`),d=!1,p=!t&&u>0,n.classList.toggle(`yuri-native-ime`,t),nl.setImeSync({enabled:t}).catch(()=>void 0))};if(o||S){r(0),m(`--yuri-kb-layout`,0),m(`--yuri-kb-scroll-inset`,0);let i=e=>{let t=e;if(S&&!C)return;let i=t.detail??t;if(typeof i.open!=`boolean`)return;if(typeof i.height==`number`&&(u=i.open?i.height/(o&&window.devicePixelRatio||1):0),o&&!C){r(u),x(),m(`--yuri-kb-scroll-inset`,Math.max(0,u-f)),n.classList.remove(`yuri-keyboard-open`,`yuri-kb-animating`),g(`yuri:keyboard-settled`,{open:i.open,nativeResize:!1});return}let a=i.phase===`start`;if(n.classList.toggle(`yuri-keyboard-open`,i.open||a),n.classList.toggle(`yuri-kb-animating`,a),a){g(`yuri:keyboard-anim`,{phase:i.open?`show`:`hide`,durationMs:i.durationMs??0,nativeResize:!0});return}let s=cl(document.activeElement);o&&!i.open&&y(document.activeElement)&&s&&document.activeElement.blur(),!i.open&&(o||!s)&&g(`yuri:keyboard-intent`,{open:!1}),g(`yuri:keyboard-settled`,{open:i.open,nativeResize:!0})};window.addEventListener(`yuri:ime-state`,i),t.push(()=>window.removeEventListener(`yuri:ime-state`,i)),e||t.push(il()),w(),document.addEventListener(`focusin`,w,!0);let a=new MutationObserver(w);if(a.observe(n,{attributes:!0,attributeFilter:[`class`]}),t.push(()=>{a.disconnect(),document.removeEventListener(`focusin`,w,!0),n.classList.remove(`yuri-native-ime`),nl.setImeSync({enabled:!1}).catch(()=>void 0)}),o)return}let T=()=>!(S&&C),E=`yuri.iosImeHeightRatio.v1`,D=e=>Number.isFinite(e)?Math.min(.68,Math.max(.28,e)):.39,O=()=>{try{let e=D(Number.parseFloat(localStorage.getItem(E)??``));return Math.round(window.innerHeight*e)}catch{return Math.round(window.innerHeight*.39)}},k=e=>{if(!(e<=0||window.innerHeight<=0))try{localStorage.setItem(E,String(D(e/window.innerHeight)))}catch{}},A=e=>{x();let t=Math.max(0,e-f);r(e),m(`--yuri-kb-layout`,e),m(`--yuri-kb-scroll-inset`,0),d=!0,b(),window.scrollTo(0,0),document.body.scrollTop!==0&&(document.body.scrollTop=0);let n=document.activeElement instanceof Element?document.activeElement.closest(`.yuri-mobile-composer`):null;return(n&&_(n)?n:v(`.yuri-mobile-composer`))?.scrollIntoView({block:`end`,inline:`nearest`}),t},j=e=>{if(!T()||sl(n.classList.contains(`yuri-native-ios-composer`),document.activeElement)||e.detail?.open!==!0||d||y(document.activeElement)&&!cl(document.activeElement))return;p=!0,n.classList.remove(`yuri-kb-hide`),n.classList.add(`yuri-keyboard-open`);let t=u>0?u:O(),r=A(t);g(`yuri:keyboard-anim`,{phase:`show`,slide:r,durationMs:0,easing:s}),g(`yuri:keyboard-settled`,{open:!0})};window.addEventListener(`yuri:keyboard-intent`,j);let M=await i.addListener(`keyboardWillShow`,e=>{if(!T()||sl(n.classList.contains(`yuri-native-ios-composer`),document.activeElement))return;h(),u=e.keyboardHeight,k(u);let t=cl(document.activeElement)||n.classList.contains(`yuri-keyboard-open`)&&!y(document.activeElement);if(p=!0,n.classList.remove(`yuri-kb-hide`),l!==null&&(window.clearTimeout(l),l=null),!t){r(u),m(`--yuri-kb-layout`,0),x(),m(`--yuri-kb-scroll-inset`,Math.max(0,u-f)),n.classList.remove(`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-caret-hold`),b(),d=!1,g(`yuri:keyboard-settled`,{open:!0});return}n.classList.add(`yuri-keyboard-open`);let i=A(u);g(`yuri:keyboard-settled`,{open:!0}),g(`yuri:keyboard-anim`,{phase:`show`,slide:i,durationMs:0,easing:s})}),N=()=>{p||(window.scrollTo(0,0),document.body.scrollTop!==0&&(document.body.scrollTop=0))},P=()=>{p=!1,h(),l!==null&&(window.clearTimeout(l),l=null),n.classList.remove(`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-caret-hold`,`yuri-kb-hide`),r(0),m(`--yuri-kb-scroll-inset`,0),m(`--yuri-kb-layout`,0),d=!1,b(),N(),window.setTimeout(N,350)},F=()=>{if(!T())return;if(n.classList.contains(`yuri-native-ios-composer`)){P(),g(`yuri:keyboard-settled`,{open:!1});return}if(!p)return;p=!1,h(),cl(document.activeElement)||g(`yuri:keyboard-intent`,{open:!1}),l!==null&&(window.clearTimeout(l),l=null),n.classList.remove(`yuri-kb-caret-hold`,`yuri-kb-animating`);let e=Math.max(0,u-f);n.classList.remove(`yuri-keyboard-open`),r(0),m(`--yuri-kb-scroll-inset`,0),m(`--yuri-kb-layout`,0),d=!1,b(),N(),window.setTimeout(N,350),g(`yuri:keyboard-anim`,{phase:`hide`,slide:e,durationMs:0,easing:s}),n.classList.add(`yuri-kb-animating`,`yuri-kb-hide`),c=window.setTimeout(()=>{c=null,n.classList.remove(`yuri-kb-animating`,`yuri-kb-hide`),g(`yuri:keyboard-settled`,{open:!1})},260)},I=await i.addListener(`keyboardWillHide`,F),L=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.isContentEditable),R=e=>{if(T()&&p&&L(e.target)){if(ll(e.relatedTarget)){m(`--yuri-kb-scroll-inset`,0);return}window.setTimeout(()=>{if(p&&!cl(document.activeElement)){if(L(document.activeElement)){h(),n.classList.remove(`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-caret-hold`,`yuri-kb-hide`),r(u),m(`--yuri-kb-layout`,0),x(),m(`--yuri-kb-scroll-inset`,Math.max(0,u-f)),d=!1,b(),g(`yuri:keyboard-intent`,{open:!1}),g(`yuri:keyboard-settled`,{open:!0});return}F()}},0)}};if(document.addEventListener(`focusout`,R,!0),e){h(),document.removeEventListener(`focusout`,R,!0),window.removeEventListener(`yuri:keyboard-intent`,j),M.remove(),I.remove();return}t.push(h,()=>{l!==null&&(window.clearTimeout(l),l=null)},()=>document.removeEventListener(`focusout`,R,!0),()=>window.removeEventListener(`yuri:keyboard-intent`,j),()=>void M.remove(),()=>void I.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e()),n.classList.remove(`yuri-capacitor-app`,`yuri-keyboard-open`,`yuri-kb-animating`,`yuri-kb-hide`,`yuri-kb-caret-hold`,`yuri-platform-android`),n.style.removeProperty(`--yuri-keyboard-inset`),n.style.removeProperty(`--yuri-kb-shift`),n.style.removeProperty(`--yuri-kb-layout`),n.style.removeProperty(`--yuri-kb-scroll-inset`)}},[])},Sm=e=>{let t=Z.useRef(!1);Z.useEffect(()=>{if(!bm())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)),he(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])},Cm=e=>{Z.useEffect(()=>{if(!bm())return;let t=!1,n=null;return he(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])},wm=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Tm={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},Em=1e3,Dm=e=>{let t=wm(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},Om=(e,t)=>Dm(e?e.path:t),km=({connection:e,onActiveConnectionDeleted:t,onConnect:n})=>{let{t:r}=Te(),i=e,{connections:a,isBusy:o,isPasswordBusy:s,error:c,pendingConnection:l,connect:u,submitPassword:d,cancelPassword:f,renameConnection:p,removeConnection:m,subscribeConnected:h,setError:g}=i,[_,v]=Z.useState(null),y=_?a.find(e=>e.id===_)??null:null,[b,x]=Z.useState(null),[S,C]=Z.useState(``),[w,T]=Z.useState(``),[E,D]=Z.useState(!1),O=Z.useId(),k=Z.useId(),[A,j]=Z.useState(``),[M,N]=Z.useState(!1),P=Z.useMemo(()=>vs(),[]),[F,I]=Z.useState(null),[L,R]=Z.useState(null),ee=q(()=>{D(!1),T(``),n()});Z.useEffect(()=>h(ee),[ee,h]);let z=q(()=>{v(null),C(``),R(null),g(null),D(!1)}),B=q(()=>{o||M||(D(!1),g(null))}),V=q(()=>{o||M||z()}),te=q(e=>{e.preventDefault(),!(!_||!S.trim())&&p(_,S).then(e=>{e&&z()})}),H=q(e=>{i.redeemPairingConnection(e)}),ne=q(()=>{g(r(`mobile.connect.link.invalid`))}),U=q(async()=>{if(!M){g(null),R(null),N(!0);try{let e=await ys();switch(e.status){case`ok`:await u({url:e.url,label:e.label,clientToken:e.clientToken});break;case`pairing`:await i.redeemPairingConnection(e.pairing);break;case`permission-denied`:g(r(`mobile.connect.scan.permissionDenied`));break;case`invalid`:g(r(`mobile.connect.scan.invalid`));break;case`unsupported`:g(r(`mobile.connect.scan.unsupported`));break;case`failed`:g(r(`mobile.connect.scan.failed`))}}catch{g(r(`mobile.connect.scan.failed`))}finally{N(!1)}}}),re=q(e=>{e.preventDefault(),d(A)}),W=q(()=>{j(``),f()}),ie=q(e=>{x(t=>t===e?null:e)}),ae=q(e=>{x(null),_===e&&z();let n=a.length===1;m(e).then(e=>{e&&(n||Oe(e))&&t()})});if(l)return l.reason===`pairing`?(0,$.jsx)(`div`,{className:`yuri-settings-page-content`,children:(0,$.jsx)(za,{label:r(`mobile.connect.pairing.expired`),itemId:`instances.manage`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(X,{name:`computer`,className:`size-6 shrink-0 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`min-w-0 flex-1 truncate typography-ui-label`,children:l.label}),a.some(e=>e.id===l.id)?(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,disabled:o||M,"aria-label":r(`mobile.instances.deleteAria`,{label:l.label}),onClick:()=>{x(l.id),W()},children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-5`})}):null]}),(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:r(`mobile.connect.pairing.reconnectHint`)}),c?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:c}):null,P?(0,$.jsxs)(Y,{size:`lg`,disabled:o||M,onClick:()=>void U(),children:[(0,$.jsx)(X,{name:`scan-2`,className:`size-5`}),r(`mobile.connect.scanQr`)]}):null,(0,$.jsx)(Y,{variant:P?`ghost`:`default`,size:`lg`,disabled:o||M,onClick:()=>{W(),D(!0)},children:r(`mobile.connect.link.useLink`)})]})})}):(0,$.jsx)(`div`,{className:`yuri-settings-page-content`,children:(0,$.jsx)(za,{label:r(`mobile.connect.password.label`),itemId:`instances.manage`,children:(0,$.jsxs)(`form`,{className:`yuri-settings-group-row flex flex-col gap-3`,onSubmit:re,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`lock`,className:`size-[18px]`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label text-foreground`,children:l.label}),(0,$.jsx)(`p`,{className:`truncate typography-small text-muted-foreground`,children:l.candidates.some(e=>e.kind===`direct`)?Me(l):r(`mobile.connect.relay.badge`)})]})]}),(0,$.jsx)(`input`,{...Tm,value:A,onChange:e=>j(e.target.value),placeholder:r(`mobile.connect.password.placeholder`),"aria-label":r(`mobile.connect.password.label`),type:`password`,autoFocus:!0,className:`h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`}),c?(0,$.jsx)(`p`,{role:`alert`,className:`px-1 typography-small text-[var(--status-error)]`,children:c}):null,(0,$.jsx)(Y,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,disabled:s||!A.trim(),children:r(s?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full`,onClick:W,children:r(`mobile.connect.cancelPassword`)})]})})});let oe=(0,$.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:te,children:[(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block typography-ui-label text-foreground`,children:r(`mobile.instances.label.label`)}),(0,$.jsx)(Kn,{value:S,onChange:e=>C(e.target.value),placeholder:r(`mobile.instances.label.placeholder`),autoComplete:`off`,autoCapitalize:`words`,autoCorrect:`off`,spellCheck:!1,maxLength:120,autoFocus:!0,disabled:o||M,className:`h-12 w-full text-[16px]`})]}),c?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:c}):null,(0,$.jsx)(Y,{type:`submit`,size:`lg`,className:`w-full`,disabled:o||M||!S.trim(),children:r(`mobile.instances.saveEdit`)})]});return(0,$.jsxs)(`div`,{className:`yuri-settings-page-content`,children:[(0,$.jsx)(za,{label:r(`mobile.connect.saved.title`),itemId:`instances.manage`,children:a.length>0?a.map(e=>{let t=b===e.id,n=Oe(e),i=F===e.id,a=r(i?`mobile.connect.connecting`:n?`mobile.instances.status.connected`:`mobile.instances.status.saved`);return(0,$.jsxs)(Z.Fragment,{children:[(0,$.jsxs)(`div`,{className:it(`yuri-settings-group-row relative flex items-center`,t&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`),children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`desktopHostSwitcher.actions.switchToAria`,{instance:e.label}),"data-mobile-press-feedback":`none`,className:`absolute inset-0 z-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:pointer-events-none`,onClick:()=>{n||(g(null),R(e.id),I(e.id),u({id:e.id,candidates:e.candidates,clientToken:e.clientToken,label:e.label}).finally(()=>I(null)))},disabled:n||o&&!i||t,style:{touchAction:`manipulation`}}),(0,$.jsxs)(`div`,{className:`pointer-events-none relative z-[1] flex min-w-0 flex-1 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`server`,className:`size-[18px]`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:e.label})}),(0,$.jsx)(`span`,{className:it(`block truncate typography-small`,n&&!i?`text-[var(--status-success)]`:`text-muted-foreground`),children:a})]})]}),(0,$.jsxs)(`div`,{className:`relative z-10 flex shrink-0 items-center gap-0.5 pr-2`,children:[t?(0,$.jsxs)(`button`,{type:`button`,"aria-label":r(`mobile.instances.confirmDeleteAria`,{label:e.label}),className:`flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-destructive px-3 text-destructive-foreground transition-opacity active:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,onClick:()=>ae(e.id),style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:r(`mobile.instances.delete`)})]}):i?(0,$.jsx)(`span`,{className:`flex size-9 items-center justify-center text-muted-foreground`,"aria-hidden":!0,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-[18px] animate-spin`})}):(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`mobile.instances.edit`),className:`flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>{v(e.id),C(e.label),R(null),g(null)},style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`edit`,className:`size-[18px]`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":r(t?`mobile.instances.cancelDeleteAria`:`mobile.instances.deleteAria`,{label:e.label}),className:`flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>ie(e.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:t?`close`:`delete-bin`,className:`size-[18px]`})})]})]}),c&&L===e.id&&!t?(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,role:`alert`,children:(0,$.jsx)(`p`,{className:`typography-small text-[var(--status-error)]`,children:c})}):null]},e.id)}):(0,$.jsx)(`div`,{className:`yuri-settings-group-row flex items-center justify-center text-center typography-small text-muted-foreground`,children:r(`mobile.connect.saved.empty`)})}),(0,$.jsx)(za,{label:r(`mobile.instances.addTitle`),children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-col gap-3`,children:[P?(0,$.jsxs)(Y,{type:`button`,size:`lg`,className:`w-full`,onClick:()=>void U(),disabled:o||M,children:[(0,$.jsx)(X,{name:`scan-2`,className:it(`size-[18px]`,M&&`animate-pulse`)}),r(`mobile.connect.scanQr`)]}):null,(0,$.jsx)(Y,{type:`button`,variant:P?`ghost`:`default`,size:`lg`,className:`w-full`,disabled:o||M,onClick:()=>{R(null),g(null),D(!0)},children:r(`mobile.connect.link.useLink`)}),c&&!E&&!y&&!L?(0,$.jsx)(`p`,{role:`alert`,className:`typography-small text-[var(--status-error)]`,children:c}):null]})}),(0,$.jsx)(br,{id:`mobile-instance-edit-${k}`,open:y!==null,onOpenChange:e=>{e||V()},fitContent:!0,ariaLabel:r(`mobile.instances.editTitle`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.connect.options.resize`),children:(0,$.jsx)(qr,{className:`px-5 pb-5 pt-1`,disableHorizontal:!0,fillContainer:!1,children:oe})}),(0,$.jsx)(br,{id:`mobile-instance-add-${O}`,open:E,onOpenChange:e=>{e||B()},fitContent:!0,title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:r(`mobile.connect.link.useLink`)}),ariaLabel:r(`mobile.connect.link.useLink`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.connect.options.resize`),children:(0,$.jsx)(qr,{className:`px-5 py-5`,disableHorizontal:!0,fillContainer:!1,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:r(`mobile.connect.link.help`)}),(0,$.jsx)(xs,{value:w,onValueChange:e=>{T(e),g(null)},showPasteButton:!0,disabled:o||M,isBusy:o,inputClassName:`min-w-0 flex-1 text-[16px]`,buttonVariant:`default`,buttonClassName:`yuri-welcome-primary w-full`,error:c,onRedeem:H,onInvalid:ne})]})})})]})},Am=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`},jm=e=>{let t=(0,Q.c)(13),{icon:n,iconNode:r,label:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=r??(n?(0,$.jsx)(X,{name:n,className:`size-[18px]`}):null),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},Mm=e=>{let t=(0,Q.c)(55),{open:n,onClose:r,anchorRef:i,contextDisplay:a,branchLabel:o,usageGroups:s,usageDisplayMode:c,isUsageLoading:l,timeFormatPreference:u}=e,{t:d}=Te(),f=Z.useRef(null),[p,m]=Z.useState(n),[h,g]=Z.useState(!1),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=_(),t[0]=v):v=t[0];let y=v,b=Z.useRef(null),[x,S]=Z.useState(null),C,w;t[1]!==i||t[2]!==n||t[3]!==p?(C=()=>{if(!n||!y||!p)return;let e=()=>{let e=i.current?.getBoundingClientRect(),t=b.current?.getBoundingClientRect();if(!e||!t){S(null);return}let n=e.left-t.left,r=Math.min(Math.max(n,8),Math.max(8,t.width-hm-8));S(r)};e();let t=b.current;if(typeof ResizeObserver>`u`||!t)return;let r=new ResizeObserver(e);return r.observe(t),()=>r.disconnect()},w=[i,y,n,p],t[1]=i,t[2]=n,t[3]=p,t[4]=C,t[5]=w):(C=t[4],w=t[5]),Z.useLayoutEffect(C,w);let T=y&&x!==null,E,D;t[6]!==n||t[7]!==p?(E=()=>{if(n){m(!0),g(!1);return}if(!p)return;g(!0);let e=window.setTimeout(()=>{m(!1),g(!1)},140);return()=>window.clearTimeout(e)},D=[n,p],t[6]=n,t[7]=p,t[8]=E,t[9]=D):(E=t[8],D=t[9]),Z.useEffect(E,D);let O,k;t[10]!==r||t[11]!==n?(O=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},k=[r,n],t[10]=r,t[11]=n,t[12]=O,t[13]=k):(O=t[12],k=t[13]),Z.useEffect(O,k);let A,j;if(t[14]!==i||t[15]!==r||t[16]!==n?(A=()=>{if(!n)return;let e=e=>{let t=e.target;if(!(t instanceof Node)){r();return}f.current?.contains(t)||i.current?.contains(t)||r()};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`wheel`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`wheel`,e,!0)}},j=[i,r,n],t[14]=i,t[15]=r,t[16]=n,t[17]=A,t[18]=j):(A=t[17],j=t[18]),Z.useEffect(A,j),!p)return null;let M;t[19]===d?M=t[20]:(M=d(`mobile.header.openMetadataAria`),t[19]=d,t[20]=M);let N=T?`absolute origin-top-left`:`mx-3 mt-2`,P=h?`pointer-events-none`:`pointer-events-auto`,F;t[21]!==N||t[22]!==P?(F=it(`overflow-x-hidden overflow-y-auto overscroll-contain rounded-[20px] yuri-mobile-overlay-surface p-2 will-change-transform`,N,P),t[21]=N,t[22]=P,t[23]=F):F=t[23];let I=`${h?`session-metadata-out`:`session-metadata-in`} ${h?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,L;t[24]!==x||t[25]!==T?(L=T?{top:8,left:x??8,width:`min(${hm}px, calc(100% - 16px))`}:null,t[24]=x,t[25]=T,t[26]=L):L=t[26];let R;t[27]!==I||t[28]!==L?(R={animation:I,maxHeight:`min(72dvh, calc(100dvh - var(--yuri-safe-area-top, 0px) - var(--yuri-header-height, 56px) - 1rem))`,...L},t[27]=I,t[28]=L,t[29]=R):R=t[29];let ee;t[30]===d?ee=t[31]:(ee=d(`mobile.header.metadata.branch`),t[30]=d,t[31]=ee);let z;t[32]!==o||t[33]!==ee?(z=(0,$.jsx)(jm,{icon:`git-branch`,label:ee,children:o}),t[32]=o,t[33]=ee,t[34]=z):z=t[34];let B;t[35]!==a||t[36]!==d?(B=a?(0,$.jsx)(jm,{iconNode:(0,$.jsx)(Fs,{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:it(`font-semibold`,a.colorClass),children:a.pending?d(`contextUsage.pending`):`${a.percentage.toFixed(1)}%`}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:a.tokens})]})}):null,t[35]=a,t[36]=d,t[37]=B):B=t[37];let V;t[38]!==l||t[39]!==u||t[40]!==c||t[41]!==s?(V=(0,$.jsx)(Nm,{groups:s,displayMode:c,isLoading:l,timeFormatPreference:u}),t[38]=l,t[39]=u,t[40]=c,t[41]=s,t[42]=V):V=t[42];let te;t[43]!==z||t[44]!==B||t[45]!==V?(te=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[z,B,V]}),t[43]=z,t[44]=B,t[45]=V,t[46]=te):te=t[46];let H;t[47]!==M||t[48]!==F||t[49]!==R||t[50]!==te?(H=(0,$.jsx)(`div`,{ref:f,role:`dialog`,"aria-label":M,className:F,style:R,children:te}),t[47]=M,t[48]=F,t[49]=R,t[50]=te,t[51]=H):H=t[51];let ne;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(`style`,{children:`
21
- @keyframes session-metadata-in {
22
- from { opacity: 0; transform: translateY(-8px) scale(0.985); }
23
- to { opacity: 1; transform: translateY(0) scale(1); }
24
- }
25
- @keyframes session-metadata-out {
26
- from { opacity: 1; transform: translateY(0) scale(1); }
27
- to { opacity: 0; transform: translateY(-6px) scale(0.985); }
28
- }
29
- `}),t[52]=ne):ne=t[52];let U;return t[53]===H?U=t[54]:(U=(0,$.jsxs)(`div`,{ref:b,className:`fixed inset-x-0 bottom-0 top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-header-height,56px))] z-20 pointer-events-none`,children:[H,ne]}),t[53]=H,t[54]=U),U},Nm=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=Te(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Or,{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=Ti(e.rows.map(Bm),n),o=r===`remaining`?t.window.remainingPercent:t.window.usedPercent,s=tr(t.window.valueLabel,o),c=Xn(t.window.resetAt,t.window.resetAfterFormatted??t.window.resetAtFormatted,a);return(0,$.jsxs)(Z.Fragment,{children:[i?(0,$.jsx)(`div`,{className:it(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-3 border-t border-[var(--surface-subtle)] pt-2`),children:i}):null,(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:t.subtitle?`${t.subtitle} · ${t.label}`:t.label}),c?(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-micro text-muted-foreground/70`,children:c}):null]}),(0,$.jsx)(`span`,{className:it(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,Am(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},Pm=e=>{let t=(0,Q.c)(35),{open:n,onClose:r,items:i,rightOffset:a}=e,o=a===void 0?0:a,{t:s}=Te(),c,l;if(t[0]!==r||t[1]!==n?(c=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},l=[r,n],t[0]=r,t[1]=n,t[2]=c,t[3]=l):(c=t[2],l=t[3]),Z.useEffect(c,l),!n)return null;let u;t[4]===r?u=t[5]:(u=(e,t,n)=>(0,$.jsxs)(`button`,{type:`button`,role:n===void 0?`menuitem`:`menuitemcheckbox`,"aria-checked":n,className:it(`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,t>0&&`border-t border-border/30`,e.disabled&&`cursor-not-allowed opacity-60`),style:{touchAction:`manipulation`},disabled:e.disabled,onClick:()=>{e.onSelect(),r()},children:[e.iconNode??(e.icon?(0,$.jsx)(X,{name:e.icon,className:it(`size-5 shrink-0 text-muted-foreground`,e.spinning&&`animate-spin`,e.key===`auto-read`&&`translate-x-px`)}):null),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:e.label}),e.badge&&e.badge>0?(0,$.jsx)(`span`,{className:`inline-flex size-2 shrink-0 rounded-full bg-primary`,"aria-hidden":!0}):null,n&&(0,$.jsx)(X,{name:`check`,className:`size-4 shrink-0 text-muted-foreground`})]},e.key),t[4]=r,t[5]=u);let d=u,f;t[6]===s?f=t[7]:(f=s(`mobile.menu.titleAria`),t[6]=s,t[7]=f);let p;t[8]===s?p=t[9]:(p=s(`mobile.surface.closeAria`),t[8]=s,t[9]=p);let m;t[10]===r?m=t[11]:(m=e=>{e.preventDefault(),r()},t[10]=r,t[11]=m);let h;t[12]!==p||t[13]!==m?(h=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":p,onPointerDown:m}),t[12]=p,t[13]=m,t[14]=h):h=t[14];let g=`max(1rem, calc(8px + ${o}px + var(--yuri-safe-area-right, 0px)))`,_;t[15]===g?_=t[16]:(_={right:g,animation:`mobile-menu-in 160ms cubic-bezier(0.32, 0.72, 0, 1) forwards`},t[15]=g,t[16]=_);let v;if(t[17]!==i||t[18]!==d){let e;t[20]===d?e=t[21]:(e=(e,t)=>d(e,t),t[20]=d,t[21]=e),v=i.map(e),t[17]=i,t[18]=d,t[19]=v}else v=t[19];let y;t[22]!==i.length||t[23]!==d||t[24]!==s?(y=(0,$.jsx)(Oo,{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:um,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:Vm,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},Fm=Z.memo(function(e){let t=(0,Q.c)(94),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=Te(),{git:d}=se(),f=Vd(i??``,a||void 0),p=f??l,m=Z.useRef(null),h=wt(i??``,a||void 0),g=Er(o),_=Tr(o),v=wr(Hm),y=wr(Um),b=lt(Wm),x=lt(Gm),S=lt(Km),C=lt(qm),w;t[0]===i?w=t[1]:(w=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=w);let T=Et(w),E=ii(Jm),D=ii(Ym),O=ii(Xm),k=ii(Zm),A=ii(Qm),j=ii($m),M=ii(eh),N=ge(th);fi();let P,F;t[2]!==v||t[3]!==d||t[4]!==o?(P=()=>{o&&v(o,d)},F=[v,d,o],t[2]=v,t[3]=d,t[4]=o,t[5]=P,t[6]=F):(P=t[5],F=t[6]),Z.useEffect(P,F);let I,L;t[7]!==y||t[8]!==d||t[9]!==o?(I=()=>{if(o)return ht.onGitRefreshHint(e=>{wm(e.directory)===o&&y(o,d)})},L=[y,d,o],t[7]=y,t[8]=d,t[9]=o,t[10]=I,t[11]=L):(I=t[10],L=t[11]),Z.useEffect(I,L);let R,ee;t[12]===D?(R=t[13],ee=t[14]):(R=()=>{D()},ee=[D],t[12]=D,t[13]=R,t[14]=ee),Z.useEffect(R,ee);let z,B;t[15]===j?(z=t[16],B=t[17]):(z=()=>{kr(j)},B=[j],t[15]=j,t[16]=z,t[17]=B),Z.useEffect(z,B);let V,te;t[18]!==j||t[19]!==O||t[20]!==k||t[21]!==n||t[22]!==E?(V=()=>{!n||k||j.some(e=>!E.some(t=>t?.providerId===e))&&O()},te=[j,O,k,n,E],t[18]=j,t[19]=O,t[20]=k,t[21]=n,t[22]=E,t[23]=V,t[24]=te):(V=t[23],te=t[24]),Z.useEffect(V,te);let H;t[25]===h?H=t[26]:(H=Gs(h),t[25]=h,t[26]=H);let ne=H,U;t[27]!==S||t[28]!==x||t[29]!==ne||t[30]!==T?(U=ne??(T?{providerID:T.providerId,modelID:T.modelId}:null)??(x&&S?{providerID:x,modelID:S}:null),t[27]=S,t[28]=x,t[29]=ne,t[30]=T,t[31]=U):U=t[31];let re=U,W;if(t[32]!==C||t[33]!==re||t[34]!==b){let e=(re?b.find(e=>e.id===re.providerID):void 0)?.models.find(e=>e.id===re?.modelID),n;t[36]!==C||t[37]!==re?(n=re?C(re.providerID,re.modelID):void 0,t[36]=C,t[37]=re,t[38]=n):n=t[38];let r=n;W=Vs(e?.limit,`context`)??r?.limit?.context??0,t[32]=C,t[33]=re,t[34]=b,t[35]=W}else W=t[35];let ie=W,ae=Pt(i??``,ie,0,a||void 0),oe=ae?.pending?null:ae?.totalTokens??0,ce;t[39]!==ie||t[40]!==s||t[41]!==oe?(ce=Ws({totalTokens:oe,contextLimit:ie,isDraft:s}),t[39]=ie,t[40]=s,t[41]=oe,t[42]=ce):ce=t[42];let le=ce,ue;t[43]!==_?.current||t[44]!==g||t[45]!==u?(ue=g===!0?_?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[43]=_?.current,t[44]=g,t[45]=u,t[46]=ue):ue=t[46];let G=ue,de;if(t[47]!==j||t[48]!==E||t[49]!==M||t[50]!==u){let e=new Map(E.map(nh)),n;t[52]===j?n=t[53]:(n=e=>j.includes(e.id),t[52]=j,t[53]=n),de=ui(E).filter(n).filter(t=>e.get(t.id)?.configured===!0).map(t=>{let n=e.get(t.id),r=[];for(let[e,t]of ki(Object.entries(n?.usage?.windows??{}),n?.usage?.accounts))r.push({key:`window-${e}`,label:Yn(t.label??e),window:t});let i=Object.entries(n?.usage?.models??{}),a=M[t.id]??[],o=a.length>0?i.filter(e=>{let[t]=e;return a.includes(t)}):i;for(let[e,t]of o){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:Yn(a.label??i),subtitle:oi(e),window:a})}let s=!n.ok&&n.error?n.error:r.length===0?u(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:s}}),t[47]=j,t[48]=E,t[49]=M,t[50]=u,t[51]=de}else de=t[51];let K=de,fe,pe;t[54]!==n||t[55]!==K?(fe=()=>{!n||K.length===0||kr(K.map(rh))},pe=[n,K],t[54]=n,t[55]=K,t[56]=fe,t[57]=pe):(fe=t[56],pe=t[57]),Z.useEffect(fe,pe);let q;t[58]===c?q=t[59]:(q=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[58]=c,t[59]=q);let me;t[60]!==p||t[61]!==f?(me=p?(0,$.jsx)(`span`,{className:it(`block truncate`,f?`yuri-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:p}):null,t[60]=p,t[61]=f,t[62]=me):me=t[62];let J;t[63]!==q||t[64]!==me?(J=(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:[q,me]})}),t[63]=q,t[64]=me,t[65]=J):J=t[65];let he;t[66]===u?he=t[67]:(he=u(`mobile.header.openMetadataAria`),t[66]=u,t[67]=he);let _e;t[68]===r?_e=t[69]:(_e=()=>r(ih),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)(Fs,{percentage:ye,pending:be}),t[71]=ye,t[72]=be,t[73]=xe):xe=t[73];let Se;t[74]!==n||t[75]!==he||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":he,"aria-expanded":n,onClick:_e,style:ve,children:xe}),t[74]=n,t[75]=he,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]!==G||t[82]!==le||t[83]!==k||t[84]!==n||t[85]!==A||t[86]!==Ce||t[87]!==N||t[88]!==K?(we=(0,$.jsx)(Mm,{open:n,onClose:Ce,anchorRef:m,contextDisplay:le,branchLabel:G,usageGroups:K,usageDisplayMode:A,isUsageLoading:k,timeFormatPreference:N}),t[81]=G,t[82]=le,t[83]=k,t[84]=n,t[85]=A,t[86]=Ce,t[87]=N,t[88]=K,t[89]=we):we=t[89];let Ee;return t[90]!==J||t[91]!==Se||t[92]!==we?(Ee=(0,$.jsxs)($.Fragment,{children:[J,Se,we]}),t[90]=J,t[91]=Se,t[92]=we,t[93]=Ee):Ee=t[93],Ee}),Im=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=Te(),[a,o]=Z.useState(!1),s=O(e=>e.currentDirectory),c=Ot(e=>e.currentSessionId),l=Z.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=Ot(l)||s,d=wm(u)||null,f=Ue(e=>e.projects),p=Ot(e=>e.availableWorktreesByProject),m=Z.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=Ot(m),g=Ze(c),_=Ot(e=>!!e.newSessionDraft?.open),v=Z.useMemo(()=>{let e=wm(u);return e&&Om((h?.projectDirectory?tt(f,h.projectDirectory):null)??Xe(f,p,e),e)||i(`mobile.header.noProject`)},[p,h?.projectDirectory,u,f,i]),y=g?.title?.trim()||(c?i(`mobile.sessions.untitled`):v),b=c?v:``;Z.useEffect(()=>{o(!1)},[c,u]);let x=q(()=>{o(!1),e()}),S=q(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Ps,{children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.sessions.openSheetAria`),onClick:x,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folders`,className:`size-5`})}),(0,$.jsx)(Fm,{open:a,onOpenChange:o,currentSessionId:c,effectiveDirectory:u,gitDirectory:d,isNewSessionDraftOpen:_,primaryLabel:y,secondaryLabel:b}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:it(`flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`files`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.files`),"aria-pressed":r.activePanel===`files`,onClick:r.onToggleFiles,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(`button`,{type:`button`,className:it(`relative flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`changes`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.changes`),"aria-pressed":r.activePanel===`changes`,onClick:r.onToggleChanges,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-5`}),r.changesDirty?(0,$.jsx)(`span`,{className:`absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary`,"aria-hidden":!0}):null]})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.header.openMenuAria`),"aria-controls":um,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`more-2`,className:`size-5`})})]})})},Lm=e=>{let t=(0,Q.c)(5),n=Ns();if(!n.enabled){let n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Im,{...e}),t[0]=e,t[1]=n),n}let r;return t[2]!==e||t[3]!==n?(r=(0,$.jsx)(Pc,{...e,scope:n}),t[2]=e,t[3]=n,t[4]=r):r=t[4],r},Rm=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=Te(),r=xn();Ye(),ot();let i=ge(e=>e.mobileSessionPanelOpen),a=ge(e=>e.setMobileSessionPanelOpen),o=ge(e=>e.isScheduledTasksDialogOpen),s=ge(e=>e.activeMainTab),c=Re(),l=ge(e=>e.setActiveMainTab),[u,d]=Z.useState(!1),[f,p]=Z.useState(!1),[m,h]=Z.useState(null),[g,v]=Z.useState(!1),[y,b]=Z.useState(!1),[x,S]=Z.useState(null),[C,w]=Z.useState(null),[T,E]=Z.useState(null),[D,k]=Z.useState(0),[A,j]=Z.useState(!1),[M,N]=Z.useState(!1),[P,F]=Z.useState(!1),[I,L]=Z.useState(!1),[R,ee]=Z.useState(!1),[z,B]=Z.useState(!1),[V,te]=Z.useState(`nav`),[H,U]=Z.useState(!1),[re,W]=Z.useState(!1),ie=q(()=>{U(!1),W(!0)}),ae=q(()=>{if(U(!1),K.enabled){Ce.info(n(`remoteProjects.nativeCapabilityUnavailable`,{capability:n(`remoteDesktop.title`)}));return}ie()}),oe=q(()=>W(!1)),[se,ce]=Z.useState(!1),le=q(()=>U(e=>!e)),ue=q(()=>U(!1)),[G,de]=Z.useState(null),K=Ns(),fe=A&&!K.enabled,pe=O(e=>e.currentDirectory),me=ge(e=>e.setSettingsPage),J=ci(e=>e.available),he=ci(e=>e.runtimeType),_e=Z.useMemo(()=>bm(),[]),ve=Z.useMemo(()=>vs(),[]),ye=pe??null,{data:be=[],refetch:xe}=ne({...Ra(ye),enabled:fe}),{refetch:Se}=ne({...La(ye),enabled:fe}),we=Va(e=>e.setMcpDraft),Ee=Va(e=>e.setSelectedMcp),De=Tr(K.enabled?K.entry?.key??null:wm(pe)||null)?.files?.length??0;Z.useEffect(()=>ht.onDirectoryRequest(()=>ee(!0)),[]);let ke=Z.useMemo(()=>_(),[]),Ae=jt(e=>e.secondary?.kind??null),je=Ot(e=>K.enabled?null:e.currentSessionId),Me=K.enabled?K.sessionId:je,Ne=Ot(e=>e.setCurrentSession),Pe=Z.useMemo(()=>e=>!K.enabled&&Me?e.getDirectoryForSession(Me):null,[Me,K.enabled]),Fe=Ot(Pe),Ie=K.enabled?K.entry?.location.directory:Fe,Le=cr()===`portrait`,[Be,Ve]=Z.useState(ke&&!Le),[He,Ue]=Z.useState(null),We=q(e=>{if(e&&me(e),ke){te(e?`page-content`:`nav`),F(!0);return}let t=jt.getState();if(e){t.openSettingsFromCurrent();return}me(`home`),t.setActiveTab(`settings`)}),Ge=q(()=>{We(`instances`)}),Ke=q(()=>{jt.getState().openInstances()}),qe=q(async t=>{if(!t){Ke();return}let n=e.connections.find(e=>e.id===t);!n||e.isBusy||Oe(n)||(await e.connect({id:n.id,candidates:n.candidates,clientToken:n.clientToken,label:n.label}),Oe(n)||Ke())}),Je=q(()=>{jt.getState().closeSecondary()}),Xe=q(async()=>{if(!z){B(!0);try{let t=await ys();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{B(!1)}}});Ir({enabled:!ke,rootRoutesBlocked:i||u||f||g||y||o||fe||P||I||R||H});let Ze=q(()=>{let e=!Be;e&&Le&&Ue(null),Ve(e)}),$e=q(()=>{if(b(!1),S(null),w(null),p(!1),h(null),ke){de(null),Ue(`files`),Le&&Ve(!1);return}d(!0)}),et=q(()=>{p(!1),h(null)}),tt=q(e=>{let t=e.path.trim();if(t){if(b(!1),S(null),w(null),de(null),v(!1),ke){ge.getState().setPendingFileFocusPath(t),Ue(`files`),Le&&Ve(!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)}}),nt=ge(e=>e.pendingFileFocusPath);Z.useEffect(()=>{if(nt){if(ke){$e();return}tt({path:nt}),ge.getState().setPendingFileFocusPath(null)}},[nt,ke,$e,tt]);let rt=q((e=null)=>{if(b(!1),S(null),w(null),E(null),p(!1),h(null),de(e),ke){Ue(`changes`),Le&&Ve(!1);return}v(!0)}),at=q((e,t,n)=>{de(null),v(!1),p(!1),h(null),S(e??null),w(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(E(r),k(e=>e+1),ke){Ue(`turn-diff`),Le&&Ve(!1);return}b(!0)}),st=q(()=>{Ue(null),de(null),E(null)}),ct=q(e=>{if(He===e){st();return}e===`files`?$e():rt()}),lt=Z.useRef(`changes`);He&&(lt.current=He);let[ut,dt]=Z.useState(!1);Z.useEffect(()=>{if(!ke)return;if(He){dt(!0);return}let e=window.setTimeout(()=>dt(!1),240);return()=>window.clearTimeout(e)},[He,ke]);let ft=He??lt.current,pt=vm(`left`,`yuri.ipad.leftSidebarWidth`,dm),mt=vm(`right`,`yuri.ipad.rightSidebarWidth`,fm),gt=Z.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{rt(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{rt({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:at,openFile:({path:e,targetLine:t})=>{tt({path:e,targetLine:t})},openFiles:()=>$e(),openSettings:e=>{We(e)}}),[rt,tt,$e,We,at]),_t=q(()=>{v(!1),de(null)}),vt=q(()=>{b(!1),E(null)});bf(Z.useMemo(()=>({openSessions:()=>{if(ke){Ve(!0);return}jt.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?$e():e===`mcp`?j(!0):e===`instances`?Ge():e===`update`&&L(!0)},openChanges:({path:e,staged:t}={})=>{rt(e?{path:e,staged:t===!0}:null)},openSettings:e=>{We(e)}}),[ke,rt,$e,Ge,We]));let yt=Z.useRef(null),bt=Z.useRef(null),xt=Qe(K.enabled?null:Me,K.enabled?void 0:Ie||pe||void 0),St=K.session?.parentID,Ct=K.enabled?St?{id:St,directory:Ie}:null:xt,wt=q(()=>{Ct&&(K.enabled?K.openSession(Ct.id):Ne(Ct.id,Ct.directory))});Kp();let Tt=Z.useRef(0);Z.useEffect(()=>(Tt.current+=1,ce(!1),()=>{Tt.current+=1}),[Me,K.key,K.entry]);let Et=q(()=>{let e=Me;if(!e||se)return;let t=Ie||pe||void 0,i=++Tt.current;ce(!0),(async()=>{try{K.enabled?await K.refresh():await r.refreshSessionTranscript(e,{directory:t}),i===Tt.current&&Ce.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{i===Tt.current&&Ce.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{i===Tt.current&&ce(!1)}})()}),Dt=!ke&&(Ae===`chat`||Ae===`draft`);Z.useEffect(()=>{!ke&&!Dt&&U(!1)},[ke,Dt]),Z.useEffect(()=>{U(!1)},[Me,K.key]);let kt=ke&&s===`assistant`||!ke&&!Dt||i||u||f||g||y||o||fe||P||I||R||H||re;Hf(bt,{onOpen:q(()=>{_r(xr)?.finish(`commit`)}),onPreviewStart:q(()=>{_r(xr)?.begin(`present`)}),onPreviewCancel:q(()=>{_r(xr)?.finish(`cancel`)}),onProgress:q(e=>{e!==null&&_r(xr)?.update(e)}),disabled:kt},ke||Dt);let At=q(e=>{yt.current=e});Cm(q(()=>re?(oe(),!0):H?(U(!1),!0):R?(ee(!1),!0):o?(window.dispatchEvent(new Event(`yuri:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):Rr.backImmediately(`overlay`)?!0:f?(et(),!0):u?(d(!1),!0):y?(vt(),!0):g?(_t(),!0):fe?(j(!1),!0):P?(F(!1),!0):I?(L(!1),!0):Rr.requestAnimatedBack(`root`)||yt.current?.()?!0:s===`assistant`?(l(`chat`),!0):Ct?(wt(),!0):!1));let Mt=J&&(he===`desktop`||he===`web`),Nt=q(()=>{if(K.enabled){Ce.info(n(`remoteProjects.configurationReadOnly`));return}let e=`new-mcp-server`,t=e,r=1;for(;be.some(e=>e.name===t);)t=`${e}-${r}`,r+=1;we({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),Ee(t),j(!1),We(`mcp`)}),Pt=q(()=>{if(M)return;if(K.enabled&&!K.entry){Ce.error(n(`remoteProjects.host-unavailable`));return}N(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([Se(),xe(),e]).finally(()=>N(!1))}),Ft=Ot(e=>e.openNewSessionDraft),It=Z.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(K.enabled){if(!K.entry){Ce.error(n(`remoteProjects.host-unavailable`));return}K.openSession(null),ke?l(`chat`):jt.getState().openRemoteProject();return}if(ke){l(`chat`),Ft();return}jt.getState().openDraft()}}];return ke||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>$e()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:De,onSelect:()=>rt()}),K.enabled||e.push({key:`mcp`,iconNode:(0,$.jsx)(si,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>j(!0)}),Mt&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>L(!0)}),ke&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>We()}),Me&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:se,spinning:se,onSelect:Et}),e.push({key:`remote-desktop`,icon:`computer`,label:n(`remoteDesktop.title`),onSelect:ae}),e},[Me,De,ke,se,rt,$e,Ft,ae,We,Et,K,l,Mt,n]);return(0,$.jsx)(wo,{remote:K.enabled,remoteState:K.owner?.state,sessionId:Me??``,directory:Ie||pe||void 0,active:ke?s!==`assistant`:Ae===`chat`||K.enabled&&Ae===`draft`,children:(0,$.jsx)(Cr,{actions:gt,children:(0,$.jsxs)(Cs,{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:[ke?(0,$.jsxs)(`aside`,{ref:pt.asideRef,className:it(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!Be&&`border-r-0`),style:{width:Be?pt.width:0,minWidth:Be?pt.width:0,maxWidth:Be?pt.width:0,"--yuri-ipad-sidebar-width":`${pt.width}px`,overflowX:`clip`,paddingTop:`var(--yuri-safe-area-top, 0px)`,transitionProperty:pt.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Be,"data-page-scroll-lock":`true`,children:[Be?(0,$.jsx)(ym,{side:`left`,isResizing:pt.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:pt.handleProps}):null,(0,$.jsx)(`div`,{className:it(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,pt.isResizing&&`pointer-events-none`,!Be&&`pointer-events-none select-none opacity-0`),style:{width:`var(--yuri-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(sr,{children:(0,$.jsx)(au,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&Le&&Ve(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,inert:re||void 0,"aria-hidden":re||void 0,children:ke?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(Lm,{onOpenSessions:()=>Ze(),menuOpen:H,onToggleMenu:le,surfaceShortcuts:{activePanel:He===`turn-diff`?`changes`:He,changesDirty:De>0,onToggleFiles:()=>ct(`files`),onToggleChanges:()=>ct(`changes`)}})}),(0,$.jsx)(`main`,{ref:bt,className:`relative min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(`div`,{className:`relative h-full w-full bg-background`,children:(0,$.jsx)(sr,{children:s===`assistant`?(0,$.jsx)(io,{}):(0,$.jsx)(Zp,{})})})})]}):(0,$.jsx)(Gu,{className:`min-h-0 flex-1`,onAddProject:()=>ee(!0),onScanQr:_e&&ve?()=>{Xe()}:void 0,onSwitchInstance:_e?qe:void 0,onRemoteDesktop:ie,remoteDesktopActive:re,instanceOptions:_e?e.connections.map(t=>({id:t.id,label:t.label,active:Oe(t),disabled:e.isBusy})):void 0,onEnableAssistants:()=>{We(`assistants`)},instancesPage:_e?(0,$.jsx)(km,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,instancesSecondaryPage:_e?(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)(ze,{title:n(`mobile.settings.switchInstance`),backAriaLabel:n(`header.actions.backAria`),onBack:Je}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[var(--yuri-mobile-page-inline-inset)]`,children:(0,$.jsx)(pi,{className:`yuri-mobile-settings-detail-card`,children:(0,$.jsx)(km,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:Ct?{id:Ct.id,directory:Ct.directory??null,...K.enabled?{onSelect:wt}:{}}:null,registerSecondaryBackHandler:At,scheduledContent:(e,t)=>(0,$.jsx)(Yi,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(Xp,{sessionId:K.enabled?K.sessionId??``:e.sessionId,directory:K.enabled?K.entry?.location.directory:e.directory,title:K.enabled?K.session?.title:void 0,onBack:()=>{ue(),Rr.requestAnimatedBack(`root`)},onOpenMenu:le,onCloseMenu:ue,menuOpen:e.active&&H,children:(0,$.jsx)(`main`,{ref:e.active?bt:void 0,className:`relative h-full min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(`div`,{className:`relative h-full w-full bg-background`,children:(0,$.jsx)(sr,{children:(0,$.jsx)(Zp,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:K.enabled?K.sessionId:e.sessionId||null,directory:K.enabled?K.entry?.location.directory??null:e.directory,viewKey:K.enabled?`${K.key}:${K.sessionId??`draft`}`:e.viewKey}})})})})})})}),ke?(0,$.jsxs)(`aside`,{ref:mt.asideRef,className:it(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!He&&`border-l-0`),style:{width:He?mt.width:0,minWidth:He?mt.width:0,maxWidth:He?mt.width:0,"--yuri-ipad-sidebar-width":`${mt.width}px`,overflowX:`clip`,paddingTop:`var(--yuri-safe-area-top, 0px)`,transitionProperty:mt.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!He,"data-page-scroll-lock":`true`,children:[He?(0,$.jsx)(ym,{side:`right`,isResizing:mt.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:mt.handleProps}):null,(0,$.jsx)(`div`,{className:it(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,mt.isResizing&&`pointer-events-none`,!He&&`pointer-events-none select-none opacity-0`),style:{width:`var(--yuri-ipad-sidebar-width)`,overflowX:`hidden`},children:ut?(0,$.jsx)(sr,{children:ft===`files`?(0,$.jsx)($p,{onClose:st}):ft===`turn-diff`?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.nav.changes`)}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:st,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Qp,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,targetFilePath:T,navigationRequestKey:D,flushContent:!0})})]}):G?.toolPatches?.length?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--yuri-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:G.toolPatches.length>1?n(`mobile.nav.changes`):G.path}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:st,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Qp,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:G.path,targetLine:G.targetLine??null,toolPatches:G.toolPatches,singleFileView:G.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(em,{onClose:st,initialDiffPath:G?.path??null,initialDiffStaged:G?.staged===!0,initialDiffTargetLine:G?.targetLine??null})}):null})]}):null,(0,$.jsx)(Zi,{open:R,onOpenChange:ee,forceMobile:!0}),(0,$.jsx)(Pm,{open:H,onClose:()=>U(!1),items:It,rightOffset:ke&&He?mt.width:0}),(0,$.jsx)(Xi,{}),re&&(0,$.jsx)(Pd,{onClose:oe,instanceName:e.connections.find(Oe)?.label}),u?(0,$.jsx)(br,{id:am,open:u,onOpenChange:e=>{e||d(!1)},ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)($p,{onClose:()=>d(!1)})})}):null,f&&m?(0,$.jsx)(br,{id:im,open:f,onOpenChange:e=>{e||et()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:m.path.split(/[/\\]/).filter(Boolean).at(-1)??m.path}),ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)($p,{onClose:et,initialFilePath:m.path,directFilePreview:!0,hideFileHeader:!0},m.path)})}):null,(0,$.jsx)(br,{id:rm,open:y,onOpenChange:e=>{e||vt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.nav.changes`)}),ariaLabel:n(`mobile.nav.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(Qp,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,toolbarInSheetHeader:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,targetFilePath:T,navigationRequestKey:D,flushContent:!0})})}),g&&G?(0,$.jsx)(br,{id:nm,open:g,onOpenChange:e=>{e||_t()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:G.toolPatches&&G.toolPatches.length>1?n(`mobile.nav.changes`):G.path}),ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:G.toolPatches?.length?(0,$.jsx)(Qp,{hideStackedFileSidebar:!0,toolbarInSheetHeader:!0,diffScope:`turn`,targetFilePath:G.path,targetLine:G.targetLine??null,toolPatches:G.toolPatches,singleFileView:G.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(em,{initialDiffPath:G.path,initialDiffStaged:G.staged,initialDiffTargetLine:G.targetLine??null,hideDiffHeader:!0})})}):g?(0,$.jsx)(br,{id:om,open:g,onOpenChange:e=>{e||_t()},ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(em,{onClose:_t,initialDiffPath:G?.path??null,initialDiffStaged:G?.staged===!0,initialDiffTargetLine:G?.targetLine??null})})}):null,fe?(0,$.jsx)(br,{id:sm,open:fe,onOpenChange:e=>{e||j(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mcpDropdown.title`)}),trailing:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:Nt,"aria-label":n(`settings.mcp.sidebar.actions.addServerTitle`),title:n(`settings.mcp.sidebar.actions.addServerTitle`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`add`,className:`size-5`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:Pt,disabled:M,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`refresh`,className:it(`size-5`,M&&`animate-spin`)})})]}),ariaLabel:n(`mcpDropdown.title`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(Ni,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,P&&ke?(0,$.jsx)(br,{id:cm,open:P,onOpenChange:e=>{e||F(!1)},ariaLabel:n(`mobile.menu.settings`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(Wa,{forceMobile:!0,isWindowed:!0,initialMobileStage:V,visiblePageSlugs:[...fr],onClose:()=>F(!1),mobileInstancesPage:_e?(0,$.jsx)(km,{connection:e,onConnect:()=>F(!1),onActiveConnectionDeleted:t}):void 0})})}):null,I?(0,$.jsx)(br,{id:lm,open:I,onOpenChange:e=>{e||L(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.menu.update`)}),ariaLabel:n(`mobile.menu.update`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(sr,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(Ha,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(Bc,{enabled:_e&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(sr,{children:(0,$.jsx)(wa,{})}),(0,$.jsx)(Gi,{})]})})})};function zm({apis:e}){Z.useEffect(()=>qe(),[]);let{t}=Te(),n=lt(e=>e.initializeApp),r=lt(e=>e.isInitialized),i=lt(e=>e.isConnected),a=lt(e=>e.connectionPhase),o=O(e=>e.currentDirectory),c=Ot(e=>e.currentSessionId),l=Ot(e=>!!e.newSessionDraft?.open),d=Ot(e=>e.error),f=Ot(e=>e.clearError),m=ge(e=>e.setIsMobile),h=li(e=>e.refreshStatus),g=Ue(e=>e.projects),[_,v]=Z.useState(0),[y,x]=Z.useState(0),[S,C]=Z.useState(!1),[w,T]=Z.useState(`pending`),E=Z.useMemo(()=>ke(),[]),[,D]=Z.useReducer(e=>e+1,0),k=Z.useMemo(()=>bm(),[]),A=Z.useRef(0),j=Z.useRef(0),M=Fe(()=>{T(`done`),v(e=>e+1)});xf(q(e=>{M.redeemPairingConnection(e)}));let N=Sf({ready:k&&i&&r});Z.useEffect(()=>{!M.error||!p()||Ce.error(M.error)},[M.error]);let P=q(()=>{let t=p(),r=j.current+1;if(j.current=r,!t){Pe();return}let i=()=>{n(),h(e.github,{force:!0}),lt.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},a=()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),v(e=>e+1)};Ae().then(e=>{if(j.current===r){if(e===`no-connection`){a();return}if(e===`unreachable`){window.setTimeout(()=>{j.current===r&&Ae().then(e=>{if(j.current===r&&e!==`switched`&&e===`unchanged`){i();return}})},4e3);return}e!==`switched`&&i()}});let o=Date.now();o-A.current>=Em&&(A.current=o,window.dispatchEvent(new Event(`yuri:system-resume`)))});xm(),Sm(P),Z.useEffect(()=>{if(!k)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>P(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[k,P]),Z.useEffect(()=>(b(e),()=>b(null)),[e]),Z.useEffect(()=>{k&&xe().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[k]),Z.useEffect(()=>{if(!k)return;let e=!1,t=[];return xe().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`download`,e=>{ci.getState().setOtaDownloadPercent(e.percent)}),i=await n.addListener(`downloadFailed`,()=>{ci.getState().setOtaDownloadFailed()}),a=await n.addListener(`downloadComplete`,()=>{ci.getState().setOtaPhase(`pending_restart`)}),o=await n.addListener(`appReloaded`,()=>{ci.getState().setOtaPhase(`pending_restart`)}),s=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),ci.getState().setOtaPhase(`error`,`OTA update was reverted`)});if(e){r.remove(),i.remove(),a.remove(),o.remove(),s.remove();return}t.push(()=>void r.remove(),()=>void i.remove(),()=>void a.remove(),()=>void o.remove(),()=>void s.remove())}catch(e){console.warn(`[OTA] Failed to subscribe to Capgo updater events:`,e)}}),()=>{e=!0;for(let e of t)e()}},[k]),Z.useEffect(()=>s(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){Da(),D();return}ga(e),jt.getState().reset(),x(e=>e+1),v(e=>e+1)}),[]),Z.useEffect(()=>{if(N===`pending`)return;if(N===`connect`){T(`done`);return}if(!k||i||p()){T(`done`);return}let e=!1;return T(`attempting`),Gt().then(e=>e?!0:Pe()).catch(()=>!1).then(()=>{e||T(`done`)}),()=>{e=!0}},[N]),Z.useEffect(()=>{m(!0)},[m]),Z.useEffect(()=>{k&&!p()||n()},[_,n,k]),bn({enabled:!k||!!p(),source:`mobileApp:recovery`}),Z.useEffect(()=>{i&&F.setDirectory(o)},[o,i]),Z.useEffect(()=>{i&&h(e.github,{force:!0})},[e.github,i,h]),Z.useEffect(()=>{if(!i||g.length===0)return;let e=!1;return(async()=>{await Promise.all(g.map(async t=>{if(t.hostId)return;let n=wm(t.path);if(n)try{if(!(wr.getState().directories.get(n)?.isGitRepo??await he(()=>import(`./gitApi-DVx_V1x6.js`).then(e=>e.f).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([83,1,5,4,6,7,9,44,8,10,23,11,24,21,25,45,46,47,48,15,12,14,13,16,17,18,19,2,20,22,26,49,43,50,38,39,40,41,42,51,52,53,54,55,56,57])))||e)return;await $r({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i,g]),Z.useEffect(()=>{if(!d)return;let e=window.setTimeout(()=>f(),5e3);return()=>window.clearTimeout(e)},[f,d]),Z.useEffect(()=>{if(!(!i&&(!k||p()))){C(!1);return}let e=window.setTimeout(()=>C(!0),8e3);return()=>window.clearTimeout(e)},[i,k,_,y]),Hn(),wn({enabled:!0}),Wn(),Oa(),Yf({enabled:k&&i}),qp();let I=ef(),L=!i&&a===`reconnecting`;if(!I)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(or,{width:120,height:120,isAnimated:!0})});let R=!!p();return k&&(!R||!i&&!L)?R?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-4`,children:[(0,$.jsx)(or,{width:120,height:120,isAnimated:!S}),S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]}),(0,$.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),v(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):w===`done`?(0,$.jsx)(Ss,{connection:M}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(or,{width:120,height:120,isAnimated:!0}),E?(0,$.jsxs)(`div`,{className:`absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center`,children:[(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.splash.connectingTo`)}),(0,$.jsxs)(`p`,{className:`typography-small text-foreground`,children:[E,(0,$.jsx)(dn,{})]})]}):null]}):!i&&!L?S?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`max-w-sm space-y-3`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]})}):(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(or,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(sr,{children:(0,$.jsx)(He,{sdk:F.getSdkClient(),directory:o||``,bootstrapDirectory:!(l&&c===null),children:(0,$.jsxs)(_n,{apis:e,children:[(0,$.jsx)(Fi,{}),(0,$.jsx)(_a,{ready:r,children:(0,$.jsx)(Jn,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(oa,{}),(0,$.jsx)(Kt,{}),(0,$.jsx)(tm,{}),(0,$.jsx)(Nn,{embeddedBackgroundWorkEnabled:r}),(0,$.jsx)(Ji,{}),(0,$.jsx)(No,{}),(0,$.jsx)(Uo,{}),(0,$.jsx)(Rm,{connection:M,onActiveConnectionDeleted:()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),jt.getState().reset(),v(e=>e+1)}}),(0,$.jsx)(mn,{position:`top-center`,offset:`calc(var(--yuri-safe-area-top, 0px) + 16px)`}),r?(0,$.jsx)(Di,{}):null,r?(0,$.jsx)(ji,{}):null,r?(0,$.jsx)(Sa,{autoStart:!1}):null]})})})]})},y)})}function Bm(e){return e.window}function Vm(e){e.currentTarget.style.transform=`none`}function Hm(e){return e.ensureStatus}function Um(e){return e.fetchStatus}function Wm(e){return e.providers}function Gm(e){return e.currentProviderId}function Km(e){return e.currentModelId}function qm(e){return e.getModelMetadata}function Jm(e){return e.results}function Ym(e){return e.loadSettings}function Xm(e){return e.fetchAllQuotas}function Zm(e){return e.isLoading}function Qm(e){return e.displayMode}function $m(e){return e.dropdownProviderIds}function eh(e){return e.selectedModels}function th(e){return e.timeFormatPreference}function nh(e){return[e?.providerId,e]}function rh(e){return e.providerId}function ih(e){return!e}var ah=()=>{De(),E().then(()=>{Promise.all([D(),jn()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),Dn(),cn(),Gn()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{lo()})};function oh(e){hr(),ah(),ge.getState().setIsMobile(!0),vo(),ur(),lr();let t=document.getElementById(`root`);if(!t)throw Error(`Root element not found`);let n=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`;n&&document.documentElement.classList.add(`yuri-native-app-active`);let r=n?{...e,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:e,i=(0,$.jsx)(zm,{apis:r});(0,ao.createRoot)(t).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(Cn,{children:(0,$.jsx)(we,{children:(0,$.jsx)(gn,{children:(0,$.jsx)(En,{children:(0,$.jsx)(Qi,{children:(0,$.jsx)(On,{children:n?i:(0,$.jsx)(hn,{children:i})})})})})})})}))}export{oh as renderMobileApp};